From 1ccb7ab7857c7944d0af60496075d4a23e7a24ee Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Thu, 12 Mar 2020 13:48:25 +0100 Subject: [PATCH] Fossil: Allow swiching off the device specific "Q" notification icon --- .../devicesettings/DeviceSettingsPreferenceConst.java | 1 + .../gadgetbridge/devices/qhybrid/QHybridCoordinator.java | 6 ++++-- .../service/devices/qhybrid/QHybridSupport.java | 7 +++++-- app/src/main/res/values/strings.xml | 2 ++ app/src/main/res/xml/devicesettings_custom_deviceicon.xml | 8 ++++++++ 5 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 app/src/main/res/xml/devicesettings_custom_deviceicon.xml diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSettingsPreferenceConst.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSettingsPreferenceConst.java index 027ecca5d..a40bdf45a 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSettingsPreferenceConst.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSettingsPreferenceConst.java @@ -24,4 +24,5 @@ public class DeviceSettingsPreferenceConst { public static final String PREF_RESERVER_ALARMS_CALENDAR = "reserve_alarms_calendar"; public static final String PREF_ALLOW_HIGH_MTU = "allow_high_mtu"; public static final String PREF_SYNC_CALENDAR = "sync_calendar"; + public static final String PREF_USE_CUSTOM_DEVICEICON = "use_custom_deviceicon"; } \ No newline at end of file diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/QHybridCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/QHybridCoordinator.java index 81affe9ca..4f4802d9c 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/QHybridCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/QHybridCoordinator.java @@ -183,11 +183,13 @@ public class QHybridCoordinator extends AbstractDeviceCoordinator { if (isHybridHR()) { return new int[]{ R.xml.devicesettings_fossilhybridhr, - R.xml.devicesettings_pairingkey + R.xml.devicesettings_pairingkey, + R.xml.devicesettings_custom_deviceicon }; } return new int[]{ - R.xml.devicesettings_pairingkey + R.xml.devicesettings_pairingkey, + R.xml.devicesettings_custom_deviceicon }; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/QHybridSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/QHybridSupport.java index 98c71b37b..f30191093 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/QHybridSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/QHybridSupport.java @@ -48,6 +48,7 @@ import java.util.UUID; import nodomain.freeyourgadget.gadgetbridge.BuildConfig; import nodomain.freeyourgadget.gadgetbridge.GBApplication; import nodomain.freeyourgadget.gadgetbridge.R; +import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo; import nodomain.freeyourgadget.gadgetbridge.devices.qhybrid.NotificationConfiguration; import nodomain.freeyourgadget.gadgetbridge.devices.qhybrid.PackageConfigHelper; @@ -350,8 +351,10 @@ public class QHybridSupport extends QHybridBaseSupport { this.useActivityHand = GBApplication.getPrefs().getBoolean("QHYBRID_USE_ACTIVITY_HAND", false); getDevice().addDeviceInfo(new GenericItem(ITEM_USE_ACTIVITY_HAND, String.valueOf(this.useActivityHand))); - getDevice().setNotificationIconConnected(R.drawable.ic_notification_qhybrid); - getDevice().setNotificationIconDisconnected(R.drawable.ic_notification_disconnected_qhybrid); + if (GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getBoolean(DeviceSettingsPreferenceConst.PREF_USE_CUSTOM_DEVICEICON, true)) { + getDevice().setNotificationIconConnected(R.drawable.ic_notification_qhybrid); + getDevice().setNotificationIconDisconnected(R.drawable.ic_notification_disconnected_qhybrid); + } for (int i = 2; i <= 7; i++) builder.notify(getCharacteristic(UUID.fromString("3dda000" + i + "-957f-7d4a-34a6-74696673696d")), true); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4b9d64175..8b75892ac 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -145,6 +145,8 @@ Send sunrise and sunset times based on the location to the Pebble timeline Sync calendar Send calendar events to the timeline + Show device specific notification icon + Show a device specific Android notification icon instead the Gadgetbridge icon when connected Autoremove dismissed notifications Notifications are automatically removed from the Pebble when dismissed from the Android device Privacy mode diff --git a/app/src/main/res/xml/devicesettings_custom_deviceicon.xml b/app/src/main/res/xml/devicesettings_custom_deviceicon.xml new file mode 100644 index 000000000..5c6137434 --- /dev/null +++ b/app/src/main/res/xml/devicesettings_custom_deviceicon.xml @@ -0,0 +1,8 @@ + + + +