mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-26 22:31:16 +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);
|
||||
SwitchCompat deviceView = (SwitchCompat) mDevicesContainer.getChildAt(mDevicesContainer.getChildCount()-1);
|
||||
deviceView.setChecked(mFolder.deviceIds.contains(device.deviceID));
|
||||
deviceView.setText(device.name);
|
||||
deviceView.setText(RestApi.getDeviceDisplayName(device));
|
||||
deviceView.setTag(device);
|
||||
deviceView.setOnCheckedChangeListener(mOnShareChangeListener);
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
@ -1140,4 +1141,12 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
|
|||
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;
|
||||
RestApi.Connection conn = mConnections.get(deviceId);
|
||||
|
||||
String displayName = (TextUtils.isEmpty(getItem(position).name))
|
||||
? deviceId.substring(0, 7)
|
||||
: getItem(position).name;
|
||||
name.setText(displayName);
|
||||
name.setText(RestApi.getDeviceDisplayName(getItem(position)));
|
||||
Resources r = getContext().getResources();
|
||||
if (conn != null && conn.connected) {
|
||||
if (conn.completion == 100) {
|
||||
|
|
Loading…
Reference in a new issue