mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 17:11:56 +01:00
Also use device alias if set in notification
This commit is contained in:
parent
a8328d4a96
commit
cdc149338a
@ -8,6 +8,7 @@
|
|||||||
* Amazfit Bip S: remove disconnect notification and button action settings (they do not work)
|
* Amazfit Bip S: remove disconnect notification and button action settings (they do not work)
|
||||||
* Fossil Hybrid HR: Add last notification widget
|
* Fossil Hybrid HR: Add last notification widget
|
||||||
* Try to fix vanishing incoming call information when VoIP call support is enabled
|
* 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
|
#### Version 0.44.1
|
||||||
* Amazfit Bip S: Support setting shortcuts
|
* Amazfit Bip S: Support setting shortcuts
|
||||||
|
@ -612,10 +612,8 @@ public class GBDeviceAdapterv2 extends RecyclerView.Adapter<GBDeviceAdapterv2.Vi
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getUniqueDeviceName(GBDevice device) {
|
private String getUniqueDeviceName(GBDevice device) {
|
||||||
String deviceName = device.getAlias();
|
String deviceName = device.getAliasOrName();
|
||||||
if (deviceName == null || deviceName.equals("")) {
|
|
||||||
deviceName = device.getName();
|
|
||||||
}
|
|
||||||
if (!isUniqueDeviceName(device, deviceName)) {
|
if (!isUniqueDeviceName(device, deviceName)) {
|
||||||
if (device.getModel() != null) {
|
if (device.getModel() != null) {
|
||||||
deviceName = deviceName + " " + device.getModel();
|
deviceName = deviceName + " " + device.getModel();
|
||||||
|
@ -22,6 +22,10 @@ import android.content.Intent;
|
|||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -30,9 +34,6 @@ import java.util.Collections;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
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.GBApplication;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.BatteryState;
|
import nodomain.freeyourgadget.gadgetbridge.model.BatteryState;
|
||||||
@ -153,6 +154,7 @@ public class GBDevice implements Parcelable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return mName;
|
return mName;
|
||||||
}
|
}
|
||||||
@ -161,6 +163,13 @@ public class GBDevice implements Parcelable {
|
|||||||
return mAlias;
|
return mAlias;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getAliasOrName() {
|
||||||
|
if (mAlias != null && !mAlias.equals("")) {
|
||||||
|
return mAlias;
|
||||||
|
}
|
||||||
|
return mName;
|
||||||
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
LOG.warn("Ignoring setting of GBDevice name to null for " + this);
|
LOG.warn("Ignoring setting of GBDevice name to null for " + this);
|
||||||
|
@ -91,7 +91,7 @@ public class GB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Notification createNotification(GBDevice device, Context context) {
|
public static Notification createNotification(GBDevice device, Context context) {
|
||||||
String deviceName = device.getName();
|
String deviceName = device.getAliasOrName();
|
||||||
String text = device.getStateString();
|
String text = device.getStateString();
|
||||||
if (device.getBatteryLevel() != GBDevice.BATTERY_UNKNOWN) {
|
if (device.getBatteryLevel() != GBDevice.BATTERY_UNKNOWN) {
|
||||||
text += ": " + context.getString(R.string.battery) + " " + device.getBatteryLevel() + "%";
|
text += ": " + context.getString(R.string.battery) + " " + device.getBatteryLevel() + "%";
|
||||||
|
Loading…
Reference in New Issue
Block a user