1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-03 17:02:13 +01:00

Also use device alias if set in notification

This commit is contained in:
Andreas Shimokawa 2020-06-12 22:49:16 +02:00
parent a8328d4a96
commit cdc149338a
4 changed files with 16 additions and 8 deletions

View File

@ -8,6 +8,7 @@
* Amazfit Bip S: remove disconnect notification and button action settings (they do not work)
* Fossil Hybrid HR: Add last notification widget
* Try to fix vanishing incoming call information when VoIP call support is enabled
* Allow setting device aliases (useful if you manage multiple ones of the same type)
#### Version 0.44.1
* Amazfit Bip S: Support setting shortcuts

View File

@ -612,10 +612,8 @@ public class GBDeviceAdapterv2 extends RecyclerView.Adapter<GBDeviceAdapterv2.Vi
}
private String getUniqueDeviceName(GBDevice device) {
String deviceName = device.getAlias();
if (deviceName == null || deviceName.equals("")) {
deviceName = device.getName();
}
String deviceName = device.getAliasOrName();
if (!isUniqueDeviceName(device, deviceName)) {
if (device.getModel() != null) {
deviceName = deviceName + " " + device.getModel();

View File

@ -22,6 +22,10 @@ import android.content.Intent;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -30,9 +34,6 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.model.BatteryState;
@ -153,6 +154,7 @@ public class GBDevice implements Parcelable {
}
}
public String getName() {
return mName;
}
@ -161,6 +163,13 @@ public class GBDevice implements Parcelable {
return mAlias;
}
public String getAliasOrName() {
if (mAlias != null && !mAlias.equals("")) {
return mAlias;
}
return mName;
}
public void setName(String name) {
if (name == null) {
LOG.warn("Ignoring setting of GBDevice name to null for " + this);

View File

@ -91,7 +91,7 @@ public class GB {
}
public static Notification createNotification(GBDevice device, Context context) {
String deviceName = device.getName();
String deviceName = device.getAliasOrName();
String text = device.getStateString();
if (device.getBatteryLevel() != GBDevice.BATTERY_UNKNOWN) {
text += ": " + context.getString(R.string.battery) + " " + device.getBatteryLevel() + "%";