2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-29 13:17:43 +00:00

We now update the name of a device if it changed the next time we see it

This commit is contained in:
Albert Vaca 2015-03-01 20:57:45 -08:00
parent 63a3b6afe4
commit db3f4a2fec

View File

@ -56,7 +56,7 @@ public class Device implements BaseLink.PackageReceiver {
private final Context context; private final Context context;
private final String deviceId; private final String deviceId;
private final String name; private String name;
public PublicKey publicKey; public PublicKey publicKey;
private int notificationId; private int notificationId;
private int protocolVersion; private int protocolVersion;
@ -93,7 +93,7 @@ public class Device implements BaseLink.PackageReceiver {
this.context = context; this.context = context;
this.deviceId = deviceId; this.deviceId = deviceId;
this.name = settings.getString("deviceName", "unknown device"); this.name = settings.getString("deviceName", context.getString(R.string.unknown_device));
this.pairStatus = PairStatus.Paired; this.pairStatus = PairStatus.Paired;
this.protocolVersion = NetworkPackage.ProtocolVersion; //We don't know it yet this.protocolVersion = NetworkPackage.ProtocolVersion; //We don't know it yet
@ -115,7 +115,7 @@ public class Device implements BaseLink.PackageReceiver {
this.context = context; this.context = context;
this.deviceId = np.getString("deviceId"); this.deviceId = np.getString("deviceId");
this.name = np.getString("deviceName", "unidentified device"); this.name = np.getString("deviceName", context.getString(R.string.unknown_device));
this.protocolVersion = np.getInt("protocolVersion"); this.protocolVersion = np.getInt("protocolVersion");
this.pairStatus = PairStatus.NotPaired; this.pairStatus = PairStatus.NotPaired;
this.publicKey = null; this.publicKey = null;
@ -324,6 +324,16 @@ public class Device implements BaseLink.PackageReceiver {
this.protocolVersion = identityPackage.getInt("protocolVersion"); this.protocolVersion = identityPackage.getInt("protocolVersion");
if (identityPackage.has("deviceName")) {
this.name = identityPackage.getString("deviceName", this.name);
SharedPreferences.Editor editor = settings.edit();
editor.putString("deviceName", this.name);
String encodedPublicKey = Base64.encodeToString(publicKey.getEncoded(), 0);
editor.putString("publicKey", encodedPublicKey);
editor.apply();
}
links.add(link); links.add(link);
try { try {