1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-18 14:47:46 +01:00

allows to set custom notification icons per device

This commit is contained in:
Daniel Dakhno 2019-10-11 03:46:42 +02:00 committed by Andreas Shimokawa
parent 5c3c81fe6f
commit b7a660ae58
2 changed files with 35 additions and 1 deletions

View File

@ -82,6 +82,10 @@ public class GBDevice implements Parcelable {
private List<ItemWithDetails> mDeviceInfos; private List<ItemWithDetails> mDeviceInfos;
private HashMap<String, Object> mExtraInfos; 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) { public GBDevice(String address, String name, DeviceType deviceType) {
this(address, null, name, deviceType); this(address, null, name, deviceType);
} }
@ -110,6 +114,9 @@ public class GBDevice implements Parcelable {
mBusyTask = in.readString(); mBusyTask = in.readString();
mDeviceInfos = in.readArrayList(getClass().getClassLoader()); mDeviceInfos = in.readArrayList(getClass().getClassLoader());
mExtraInfos = (HashMap) in.readSerializable(); mExtraInfos = (HashMap) in.readSerializable();
mNotificationIconConnected = in.readInt();
mNotificationIconDisconnected = in.readInt();
mNotificationIconLowBattery = in.readInt();
validate(); validate();
} }
@ -131,6 +138,9 @@ public class GBDevice implements Parcelable {
dest.writeString(mBusyTask); dest.writeString(mBusyTask);
dest.writeList(mDeviceInfos); dest.writeList(mDeviceInfos);
dest.writeSerializable(mExtraInfos); dest.writeSerializable(mExtraInfos);
dest.writeInt(mNotificationIconConnected);
dest.writeInt(mNotificationIconDisconnected);
dest.writeInt(mNotificationIconLowBattery);
} }
private void validate() { private void validate() {
@ -221,6 +231,30 @@ public class GBDevice implements Parcelable {
return mBusyTask; 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 * Marks the device as busy, performing a certain task. While busy, no other operations will
* be performed on the device. * be performed on the device.

View File

@ -98,7 +98,7 @@ public class GB {
builder.setContentTitle(deviceName) builder.setContentTitle(deviceName)
.setTicker(deviceName + " - " + text) .setTicker(deviceName + " - " + text)
.setContentText(text) .setContentText(text)
.setSmallIcon(connected ? R.drawable.ic_notification : R.drawable.ic_notification_disconnected) .setSmallIcon(connected ? device.getNotificationIconConnected() : device.getNotificationIconDisconnected())
.setContentIntent(getContentIntent(context)) .setContentIntent(getContentIntent(context))
.setColor(context.getResources().getColor(R.color.accent)) .setColor(context.getResources().getColor(R.color.accent))
.setOngoing(true); .setOngoing(true);