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 cfe235889..ab65644c9 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 @@ -219,6 +219,8 @@ public class DeviceSettingsPreferenceConst { public static final String PREF_FIND_PHONE = "prefs_find_phone"; public static final String PREF_FIND_PHONE_DURATION = "prefs_find_phone_duration"; public static final String PREF_AUTOLIGHT = "autolight"; + + public static final String PREF_PREVIEW_MESSAGE_IN_TITLE = "preview_message_in_title"; public static final String PREF_AUTOREMOVE_MESSAGE = "autoremove_message"; public static final String PREF_AUTOREMOVE_NOTIFICATIONS = "autoremove_notifications"; public static final String PREF_SCREEN_ON_ON_NOTIFICATIONS = "screen_on_on_notifications"; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSpecificSettingsFragment.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSpecificSettingsFragment.java index 243c67a78..298c19204 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSpecificSettingsFragment.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSpecificSettingsFragment.java @@ -398,6 +398,7 @@ public class DeviceSpecificSettingsFragment extends AbstractPreferenceFragment i addPreferenceHandlerFor(PREF_AUTOLIGHT); addPreferenceHandlerFor(PREF_AUTOREMOVE_MESSAGE); addPreferenceHandlerFor(PREF_AUTOREMOVE_NOTIFICATIONS); + addPreferenceHandlerFor(PREF_PREVIEW_MESSAGE_IN_TITLE); addPreferenceHandlerFor(PREF_SCREEN_ON_ON_NOTIFICATIONS); addPreferenceHandlerFor(PREF_WORKOUT_KEEP_SCREEN_ON); addPreferenceHandlerFor(PREF_KEY_VIBRATION); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/casio/gbx100/CasioGBX100DeviceCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/casio/gbx100/CasioGBX100DeviceCoordinator.java index 52bb461d4..62835ca54 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/casio/gbx100/CasioGBX100DeviceCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/casio/gbx100/CasioGBX100DeviceCoordinator.java @@ -152,7 +152,8 @@ public class CasioGBX100DeviceCoordinator extends CasioDeviceCoordinator { R.xml.devicesettings_operating_sounds, R.xml.devicesettings_fake_ring_duration, R.xml.devicesettings_autoremove_message, - R.xml.devicesettings_transliteration + R.xml.devicesettings_transliteration, + R.xml.devicesettings_preview_message_in_title }; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/AbstractDeviceSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/AbstractDeviceSupport.java index 78b1c1d87..a3b82469b 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/AbstractDeviceSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/AbstractDeviceSupport.java @@ -274,8 +274,12 @@ public abstract class AbstractDeviceSupport implements DeviceSupport { context.startActivity(intent); LOG.debug("CompanionDeviceManager associations were found, starting intent"); } else { + LOG.warn("CompanionDeviceManager associations were not found, going to try to start intent anyway"); GB.notify(GB.NOTIFICATION_ID_PHONE_FIND, notification.build(), context); - LOG.warn("CompanionDeviceManager associations were not found, can't start intent"); + // Originally the Phone Find activity wasn't being started if no companion associations. + // Casio GDB-200 doesn't register companion but this still seems to work, so keeping + // warning but starting activity anyway + context.startActivity(intent); } } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gbx100/CasioGBX100DeviceSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gbx100/CasioGBX100DeviceSupport.java index 79931ce5c..a8bdf7c98 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gbx100/CasioGBX100DeviceSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gbx100/CasioGBX100DeviceSupport.java @@ -78,6 +78,7 @@ import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.Dev import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_FIND_PHONE_DURATION; import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_KEY_VIBRATION; import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_OPERATING_SOUNDS; +import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_PREVIEW_MESSAGE_IN_TITLE; import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_TIMEFORMAT; import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_WEARLOCATION; import static nodomain.freeyourgadget.gadgetbridge.model.ActivityUser.PREF_USER_ACTIVETIME_MINUTES; @@ -257,9 +258,13 @@ public class CasioGBX100DeviceSupport extends Casio2C2DSupport implements Shared } private void showNotification(byte icon, String sender, String title, String message, int id, boolean delete) { - title = title + "-" + message; - title = title.substring(0, Math.min(title.length(), 30)); - title = title + ".."; + SharedPreferences sharedPreferences = GBApplication.getDeviceSpecificSharedPrefs(getDevice().getAddress()); + boolean showMessagePreview = sharedPreferences.getBoolean(PREF_PREVIEW_MESSAGE_IN_TITLE, true); + if (showMessagePreview) { + title = title + "-" + message; + title = title.substring(0, Math.min(title.length(), 30)); + title = title + ".."; + } byte[] titleBytes = new byte[0]; if(title != null) titleBytes = title.getBytes(StandardCharsets.UTF_8); @@ -417,7 +422,7 @@ public class CasioGBX100DeviceSupport extends Casio2C2DSupport implements Shared findPhoneEvent.event = GBDeviceEventFindPhone.Event.START; evaluateGBDeviceEvent(findPhoneEvent); - if(!findPhone.equals(getContext().getString(R.string.p_on))) { + if(findPhone.equals(getContext().getString(R.string.p_on))) { String duration = sharedPreferences.getString(PREF_FIND_PHONE_DURATION, "0"); try { @@ -433,7 +438,9 @@ public class CasioGBX100DeviceSupport extends Casio2C2DSupport implements Shared this.mFindPhoneHandler.postDelayed(new Runnable() { @Override public void run() { - onReverseFindDevice(false); + GBDeviceEventFindPhone findPhoneEvent = new GBDeviceEventFindPhone(); + findPhoneEvent.event = GBDeviceEventFindPhone.Event.STOP; + evaluateGBDeviceEvent(findPhoneEvent); } }, iDuration * 1000); } @@ -635,6 +642,9 @@ public class CasioGBX100DeviceSupport extends Casio2C2DSupport implements Shared case PREF_FIND_PHONE_DURATION: // No action, we check the shared preferences when the device tries to ring the phone. break; + case PREF_PREVIEW_MESSAGE_IN_TITLE: + // No action, we check it when message is received + break; default: } } catch (IOException e) { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9550da72b..c11bab637 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -332,6 +332,8 @@ Send calendar events to the timeline Show device specific notification icon Show a device specific Android notification icon instead the Gadgetbridge icon when connected + Show a preview of the message in the title + Shows a preview of the message in the title of a notification as allowed by the device Autoremove dismissed notifications Notifications are automatically removed from the device when dismissed from the phone Screen On on Notifications