mirror of
https://github.com/syncthing/syncthing-android.git
synced 2025-01-11 04:25:53 +00:00
Moved getDeviceName() into Device class
This commit is contained in:
parent
9cba4e0ef0
commit
9b3968683b
5 changed files with 14 additions and 12 deletions
|
@ -396,7 +396,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.getDevices().contains(device.deviceID));
|
||||
deviceView.setText(RestApi.getDeviceDisplayName(device));
|
||||
deviceView.setText(device.getDisplayName());
|
||||
deviceView.setTag(device);
|
||||
deviceView.setOnCheckedChangeListener(mCheckedListener);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.nutomic.syncthingandroid.model;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -9,4 +11,13 @@ public class Device implements Serializable {
|
|||
public String deviceID;
|
||||
public String compression;
|
||||
public boolean introducer;
|
||||
|
||||
/**
|
||||
* Returns the device name, or the first characters of the ID if the name is empty.
|
||||
*/
|
||||
public String getDisplayName() {
|
||||
return (TextUtils.isEmpty(name))
|
||||
? deviceID.substring(0, 7)
|
||||
: name;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ public class EventProcessor implements SyncthingService.OnWebGuiAvailableListene
|
|||
String deviceName = null;
|
||||
for (Device d : mApi.getDevices(false)) {
|
||||
if (d.deviceID.equals(deviceId))
|
||||
deviceName = RestApi.getDeviceDisplayName(d);
|
||||
deviceName = d.getDisplayName();
|
||||
}
|
||||
title = mContext.getString(R.string.folder_rejected, deviceName,
|
||||
folderLabel.isEmpty() ? folderId : folderLabel + " (" + folderId + ")");
|
||||
|
|
|
@ -909,13 +909,4 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
|
|||
public void setRestartPostponed() {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ public class DevicesAdapter extends ArrayAdapter<Device>
|
|||
String deviceId = getItem(position).deviceID;
|
||||
Connection conn = mConnections.get(deviceId);
|
||||
|
||||
name.setText(RestApi.getDeviceDisplayName(getItem(position)));
|
||||
name.setText(getItem(position).getDisplayName());
|
||||
Resources r = getContext().getResources();
|
||||
if (conn != null && conn.connected) {
|
||||
if (conn.completion == 100) {
|
||||
|
|
Loading…
Reference in a new issue