1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-27 19:15:50 +01:00

Fixed find phone on, added preference to preview messages on Casio GDB-200

This commit is contained in:
foxstidious 2023-09-30 11:22:00 -04:00 committed by José Rebelo
parent a1b59774d4
commit 6be7f7c9cc
6 changed files with 27 additions and 7 deletions

View File

@ -219,6 +219,8 @@ public class DeviceSettingsPreferenceConst {
public static final String PREF_FIND_PHONE = "prefs_find_phone"; 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_FIND_PHONE_DURATION = "prefs_find_phone_duration";
public static final String PREF_AUTOLIGHT = "autolight"; 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_MESSAGE = "autoremove_message";
public static final String PREF_AUTOREMOVE_NOTIFICATIONS = "autoremove_notifications"; public static final String PREF_AUTOREMOVE_NOTIFICATIONS = "autoremove_notifications";
public static final String PREF_SCREEN_ON_ON_NOTIFICATIONS = "screen_on_on_notifications"; public static final String PREF_SCREEN_ON_ON_NOTIFICATIONS = "screen_on_on_notifications";

View File

@ -398,6 +398,7 @@ public class DeviceSpecificSettingsFragment extends AbstractPreferenceFragment i
addPreferenceHandlerFor(PREF_AUTOLIGHT); addPreferenceHandlerFor(PREF_AUTOLIGHT);
addPreferenceHandlerFor(PREF_AUTOREMOVE_MESSAGE); addPreferenceHandlerFor(PREF_AUTOREMOVE_MESSAGE);
addPreferenceHandlerFor(PREF_AUTOREMOVE_NOTIFICATIONS); addPreferenceHandlerFor(PREF_AUTOREMOVE_NOTIFICATIONS);
addPreferenceHandlerFor(PREF_PREVIEW_MESSAGE_IN_TITLE);
addPreferenceHandlerFor(PREF_SCREEN_ON_ON_NOTIFICATIONS); addPreferenceHandlerFor(PREF_SCREEN_ON_ON_NOTIFICATIONS);
addPreferenceHandlerFor(PREF_WORKOUT_KEEP_SCREEN_ON); addPreferenceHandlerFor(PREF_WORKOUT_KEEP_SCREEN_ON);
addPreferenceHandlerFor(PREF_KEY_VIBRATION); addPreferenceHandlerFor(PREF_KEY_VIBRATION);

View File

@ -152,7 +152,8 @@ public class CasioGBX100DeviceCoordinator extends CasioDeviceCoordinator {
R.xml.devicesettings_operating_sounds, R.xml.devicesettings_operating_sounds,
R.xml.devicesettings_fake_ring_duration, R.xml.devicesettings_fake_ring_duration,
R.xml.devicesettings_autoremove_message, R.xml.devicesettings_autoremove_message,
R.xml.devicesettings_transliteration R.xml.devicesettings_transliteration,
R.xml.devicesettings_preview_message_in_title
}; };
} }

View File

@ -274,8 +274,12 @@ public abstract class AbstractDeviceSupport implements DeviceSupport {
context.startActivity(intent); context.startActivity(intent);
LOG.debug("CompanionDeviceManager associations were found, starting intent"); LOG.debug("CompanionDeviceManager associations were found, starting intent");
} else { } 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); 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);
} }
} }

View File

@ -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_FIND_PHONE_DURATION;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_KEY_VIBRATION; 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_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_TIMEFORMAT;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_WEARLOCATION; import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_WEARLOCATION;
import static nodomain.freeyourgadget.gadgetbridge.model.ActivityUser.PREF_USER_ACTIVETIME_MINUTES; 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) { private void showNotification(byte icon, String sender, String title, String message, int id, boolean delete) {
SharedPreferences sharedPreferences = GBApplication.getDeviceSpecificSharedPrefs(getDevice().getAddress());
boolean showMessagePreview = sharedPreferences.getBoolean(PREF_PREVIEW_MESSAGE_IN_TITLE, true);
if (showMessagePreview) {
title = title + "-" + message; title = title + "-" + message;
title = title.substring(0, Math.min(title.length(), 30)); title = title.substring(0, Math.min(title.length(), 30));
title = title + ".."; title = title + "..";
}
byte[] titleBytes = new byte[0]; byte[] titleBytes = new byte[0];
if(title != null) if(title != null)
titleBytes = title.getBytes(StandardCharsets.UTF_8); titleBytes = title.getBytes(StandardCharsets.UTF_8);
@ -417,7 +422,7 @@ public class CasioGBX100DeviceSupport extends Casio2C2DSupport implements Shared
findPhoneEvent.event = GBDeviceEventFindPhone.Event.START; findPhoneEvent.event = GBDeviceEventFindPhone.Event.START;
evaluateGBDeviceEvent(findPhoneEvent); 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"); String duration = sharedPreferences.getString(PREF_FIND_PHONE_DURATION, "0");
try { try {
@ -433,7 +438,9 @@ public class CasioGBX100DeviceSupport extends Casio2C2DSupport implements Shared
this.mFindPhoneHandler.postDelayed(new Runnable() { this.mFindPhoneHandler.postDelayed(new Runnable() {
@Override @Override
public void run() { public void run() {
onReverseFindDevice(false); GBDeviceEventFindPhone findPhoneEvent = new GBDeviceEventFindPhone();
findPhoneEvent.event = GBDeviceEventFindPhone.Event.STOP;
evaluateGBDeviceEvent(findPhoneEvent);
} }
}, iDuration * 1000); }, iDuration * 1000);
} }
@ -635,6 +642,9 @@ public class CasioGBX100DeviceSupport extends Casio2C2DSupport implements Shared
case PREF_FIND_PHONE_DURATION: case PREF_FIND_PHONE_DURATION:
// No action, we check the shared preferences when the device tries to ring the phone. // No action, we check the shared preferences when the device tries to ring the phone.
break; break;
case PREF_PREVIEW_MESSAGE_IN_TITLE:
// No action, we check it when message is received
break;
default: default:
} }
} catch (IOException e) { } catch (IOException e) {

View File

@ -332,6 +332,8 @@
<string name="pref_summary_enable_calendar_sync">Send calendar events to the timeline</string> <string name="pref_summary_enable_calendar_sync">Send calendar events to the timeline</string>
<string name="pref_title_custom_deviceicon">Show device specific notification icon</string> <string name="pref_title_custom_deviceicon">Show device specific notification icon</string>
<string name="pref_summary_custom_deviceicon">Show a device specific Android notification icon instead the Gadgetbridge icon when connected</string> <string name="pref_summary_custom_deviceicon">Show a device specific Android notification icon instead the Gadgetbridge icon when connected</string>
<string name="pref_title_preview_message_in_title">Show a preview of the message in the title</string>
<string name="pref_summary_preview_message_in_title">Shows a preview of the message in the title of a notification as allowed by the device</string>
<string name="pref_title_autoremove_notifications">Autoremove dismissed notifications</string> <string name="pref_title_autoremove_notifications">Autoremove dismissed notifications</string>
<string name="pref_summary_autoremove_notifications">Notifications are automatically removed from the device when dismissed from the phone</string> <string name="pref_summary_autoremove_notifications">Notifications are automatically removed from the device when dismissed from the phone</string>
<string name="pref_title_screen_on_on_notifications">Screen On on Notifications</string> <string name="pref_title_screen_on_on_notifications">Screen On on Notifications</string>