mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-18 06:37:47 +01:00
allows to set custom notification icons per device
This commit is contained in:
parent
5c3c81fe6f
commit
b7a660ae58
@ -82,6 +82,10 @@ public class GBDevice implements Parcelable {
|
||||
private List<ItemWithDetails> mDeviceInfos;
|
||||
private HashMap<String, Object> mExtraInfos;
|
||||
|
||||
private int mNotificationIconConnected = R.drawable.ic_notification;
|
||||
private int mNotificationIconDisconnected = R.drawable.ic_notification_disconnected;
|
||||
private int mNotificationIconLowBattery = R.drawable.ic_notification_low_battery;
|
||||
|
||||
public GBDevice(String address, String name, DeviceType deviceType) {
|
||||
this(address, null, name, deviceType);
|
||||
}
|
||||
@ -110,6 +114,9 @@ public class GBDevice implements Parcelable {
|
||||
mBusyTask = in.readString();
|
||||
mDeviceInfos = in.readArrayList(getClass().getClassLoader());
|
||||
mExtraInfos = (HashMap) in.readSerializable();
|
||||
mNotificationIconConnected = in.readInt();
|
||||
mNotificationIconDisconnected = in.readInt();
|
||||
mNotificationIconLowBattery = in.readInt();
|
||||
|
||||
validate();
|
||||
}
|
||||
@ -131,6 +138,9 @@ public class GBDevice implements Parcelable {
|
||||
dest.writeString(mBusyTask);
|
||||
dest.writeList(mDeviceInfos);
|
||||
dest.writeSerializable(mExtraInfos);
|
||||
dest.writeInt(mNotificationIconConnected);
|
||||
dest.writeInt(mNotificationIconDisconnected);
|
||||
dest.writeInt(mNotificationIconLowBattery);
|
||||
}
|
||||
|
||||
private void validate() {
|
||||
@ -221,6 +231,30 @@ public class GBDevice implements Parcelable {
|
||||
return mBusyTask;
|
||||
}
|
||||
|
||||
public int getNotificationIconConnected() {
|
||||
return mNotificationIconConnected;
|
||||
}
|
||||
|
||||
public void setNotificationIconConnected(int mNotificationIconConnected) {
|
||||
this.mNotificationIconConnected = mNotificationIconConnected;
|
||||
}
|
||||
|
||||
public int getNotificationIconDisconnected() {
|
||||
return mNotificationIconDisconnected;
|
||||
}
|
||||
|
||||
public void setNotificationIconDisconnected(int notificationIconDisconnected) {
|
||||
this.mNotificationIconDisconnected = notificationIconDisconnected;
|
||||
}
|
||||
|
||||
public int getNotificationIconLowBattery() {
|
||||
return mNotificationIconLowBattery;
|
||||
}
|
||||
|
||||
public void setNotificationIconLowBattery(int mNotificationIconLowBattery) {
|
||||
this.mNotificationIconLowBattery = mNotificationIconLowBattery;
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the device as busy, performing a certain task. While busy, no other operations will
|
||||
* be performed on the device.
|
||||
|
@ -98,7 +98,7 @@ public class GB {
|
||||
builder.setContentTitle(deviceName)
|
||||
.setTicker(deviceName + " - " + text)
|
||||
.setContentText(text)
|
||||
.setSmallIcon(connected ? R.drawable.ic_notification : R.drawable.ic_notification_disconnected)
|
||||
.setSmallIcon(connected ? device.getNotificationIconConnected() : device.getNotificationIconDisconnected())
|
||||
.setContentIntent(getContentIntent(context))
|
||||
.setColor(context.getResources().getColor(R.color.accent))
|
||||
.setOngoing(true);
|
||||
|
Loading…
Reference in New Issue
Block a user