mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-27 06:41:15 +00:00
Improved handling for empty device IDs.
This commit is contained in:
parent
34fead0623
commit
3d09d43bd4
3 changed files with 11 additions and 5 deletions
|
@ -373,7 +373,7 @@ public class FolderFragment extends Fragment
|
||||||
inflater.inflate(R.layout.item_device_form, mDevicesContainer);
|
inflater.inflate(R.layout.item_device_form, mDevicesContainer);
|
||||||
SwitchCompat deviceView = (SwitchCompat) mDevicesContainer.getChildAt(mDevicesContainer.getChildCount()-1);
|
SwitchCompat deviceView = (SwitchCompat) mDevicesContainer.getChildAt(mDevicesContainer.getChildCount()-1);
|
||||||
deviceView.setChecked(mFolder.deviceIds.contains(device.deviceID));
|
deviceView.setChecked(mFolder.deviceIds.contains(device.deviceID));
|
||||||
deviceView.setText(device.name);
|
deviceView.setText(RestApi.getDeviceDisplayName(device));
|
||||||
deviceView.setTag(device);
|
deviceView.setTag(device);
|
||||||
deviceView.setOnCheckedChangeListener(mOnShareChangeListener);
|
deviceView.setOnCheckedChangeListener(mOnShareChangeListener);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
@ -1140,4 +1141,12 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
|
||||||
mRestartPostponed = true;
|
mRestartPostponed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the device name, or the first characters of the ID if the name is empty.
|
||||||
|
*/
|
||||||
|
public static String getDeviceDisplayName(Device device) {
|
||||||
|
return (TextUtils.isEmpty(device.name))
|
||||||
|
? device.deviceID.substring(0, 7)
|
||||||
|
: device.name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,10 +54,7 @@ public class DevicesAdapter extends ArrayAdapter<RestApi.Device>
|
||||||
String deviceId = getItem(position).deviceID;
|
String deviceId = getItem(position).deviceID;
|
||||||
RestApi.Connection conn = mConnections.get(deviceId);
|
RestApi.Connection conn = mConnections.get(deviceId);
|
||||||
|
|
||||||
String displayName = (TextUtils.isEmpty(getItem(position).name))
|
name.setText(RestApi.getDeviceDisplayName(getItem(position)));
|
||||||
? deviceId.substring(0, 7)
|
|
||||||
: getItem(position).name;
|
|
||||||
name.setText(displayName);
|
|
||||||
Resources r = getContext().getResources();
|
Resources r = getContext().getResources();
|
||||||
if (conn != null && conn.connected) {
|
if (conn != null && conn.connected) {
|
||||||
if (conn.completion == 100) {
|
if (conn.completion == 100) {
|
||||||
|
|
Loading…
Reference in a new issue