From 0b6c2db60691c79ad6ec0d1e9ad0e949e1b3f093 Mon Sep 17 00:00:00 2001 From: Arjan Schrijver Date: Mon, 25 Jul 2022 22:23:22 +0200 Subject: [PATCH] Fossil Hybrid HR: Add toggling of widgets with physical button event --- .../assets/fossil_hr/openSourceWatchface.bin | Bin 8102 -> 8326 bytes .../HybridHRWatchfaceDesignerActivity.java | 3 + .../qhybrid/HybridHRWatchfaceFactory.java | 3 +- .../qhybrid/HybridHRWatchfaceSettings.java | 9 ++ .../HybridHRWatchfaceSettingsActivity.java | 105 ++++++++++-------- app/src/main/res/values/arrays.xml | 17 +++ app/src/main/res/values/strings.xml | 2 + .../res/xml/fossil_hr_watchface_settings.xml | 14 +++ external/fossil-hr-watchface | 2 +- 9 files changed, 105 insertions(+), 50 deletions(-) diff --git a/app/src/main/assets/fossil_hr/openSourceWatchface.bin b/app/src/main/assets/fossil_hr/openSourceWatchface.bin index d019ff0d919c46d71669366ddea5ddec8cde6d67..f73d261b0ae180bdcdc4c34f89bdd5f1b5aff696 100644 GIT binary patch delta 2386 zcmZve?Q9G39BqU11-Mjz+lz3%2&+qQrlfaUhZ>&MKhix=>TdI_ zL2rD>`<&xV410H1y~(xSmUZ6N_1?A(-aRAU_S?K2w|i4}c=b`w-ROCDdiQSfcGkRI zW8QstdG~LgN@&R@Ok`}^&Sw9+%ez2rh6#I^YZIwq>)Kd)JX6KGUPtMwoiE0lAs7b* z#N*&k=(;`BD#J45+^v`Fa?RZW&Q^%FLa+_|d%)Qa&JM$NxC7J_1XG~u;J6UE`h9z* zC-gwwYnI3I-!+fAyYysgvP-6=x;zr?0{1?tsxPMcJ~b8GpG>`<>T5*1A$S17&qLT^ zp!yGjI}QF9Ap9cu4?+A8_^Tn>1J1(`JPb|_{JjwG1$Q5W`@orjUI$}0SFF2bO79g=;P@>bqTl8K~S@XV|NyUS-mr}ww6pCf*RITYtojKWmzpP@;dcp z@V^4#BM?6V;bDjmLpY~j&y0@5a}XQ>*9ZS7M90864v}0g_>V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%2c} zEKFR~-=(Y5vJy?`tg4TX$IOqIo1A^Rpz{A&mdl-edZ)_g1?LHLV`#M)g(BRx+~LBA1_J$MVuj5hS0{$c59X0esM`!zY@f_pAvOQ&r7EVc%=-)F3r^=0MSS2MD z71A5dqvk6AnCZwO8tE5<2zpAoQ=}GA@`EKmyR9FR1=5A2+F4oEp2*a=rRhR4SC@6m z%f6;`!H~$*HX2Q;Ok<;EPR0{o!-QTVo&t#7Y#P_NF4)`tRJyS`lT8TWat;M9+hFTAwTX zJT14`JM^~lu0nVkiU0(%^TOPP#q8qO-v#>uco!hLU>vYf zYWp5|@{H<(Rn1eKapUGF$+fl?jW>7?qW3|42;qm|e{`j>iiwJO$_N#M4bujVGYQd0 z;D0=u_zaSCoSXN_T(0WVIQLx4lrS9}(jCZP>}O^sGvQ$u@0bE8$)+|b_8 z(rDGS=s&A_3b`0?8mwF{ZW);t&1Q}ln?lxQ_RFl7#td3#zN)dTnV)MX6EoZDsxtoo Dy9T|R diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/HybridHRWatchfaceDesignerActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/HybridHRWatchfaceDesignerActivity.java index a940ef603..deef83016 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/HybridHRWatchfaceDesignerActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/HybridHRWatchfaceDesignerActivity.java @@ -393,6 +393,9 @@ public class HybridHRWatchfaceDesignerActivity extends AbstractGBActivity implem if (watchfaceConfig.has("wrist_flick_move_minute")) { watchfaceSettings.setWristFlickMoveMinute(watchfaceConfig.getInt("wrist_flick_move_minute")); } + if (watchfaceConfig.has("toggle_widgets_event")) { + watchfaceSettings.setToggleWidgetsEvent(watchfaceConfig.getString("toggle_widgets_event")); + } if (watchfaceConfig.has("powersave_display")) { watchfaceSettings.setPowersaveDisplay(watchfaceConfig.getBoolean("powersave_display")); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/HybridHRWatchfaceFactory.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/HybridHRWatchfaceFactory.java index 15a4ff64a..6e85ead4c 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/HybridHRWatchfaceFactory.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/HybridHRWatchfaceFactory.java @@ -301,9 +301,10 @@ public class HybridHRWatchfaceFactory { config.put("wrist_flick_duration", settings.getWristFlickDuration()); config.put("wrist_flick_move_hour", settings.getWristFlickMoveHour()); config.put("wrist_flick_move_minute", settings.getWristFlickMoveMinute()); - config.put("light_up_on_notification", settings.getLightUpOnNotification()); + config.put("toggle_widgets_event", settings.getToggleWidgetsEvent()); config.put("powersave_display", settings.getPowersaveDisplay()); config.put("powersave_hands", settings.getPowersaveHands()); + config.put("light_up_on_notification", settings.getLightUpOnNotification()); configuration.put("config", config); return configuration.toString(); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/HybridHRWatchfaceSettings.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/HybridHRWatchfaceSettings.java index ef3ebe074..c11309f42 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/HybridHRWatchfaceSettings.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/HybridHRWatchfaceSettings.java @@ -25,6 +25,7 @@ public class HybridHRWatchfaceSettings implements Serializable { private int wristFlickDuration = 2200; private int wristFlickMoveHour = 360; private int wristFlickMoveMinute = -360; + private String toggleWidgetsEvent = ""; private boolean powersaveDisplay = false; private boolean powersaveHands = false; private boolean lightUpOnNotification = false; @@ -100,6 +101,14 @@ public class HybridHRWatchfaceSettings implements Serializable { } } + public String getToggleWidgetsEvent() { + return toggleWidgetsEvent; + } + + public void setToggleWidgetsEvent(String event) { + this.toggleWidgetsEvent = event; + } + public boolean getPowersaveDisplay() { return powersaveDisplay; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/HybridHRWatchfaceSettingsActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/HybridHRWatchfaceSettingsActivity.java index 50485eb99..82d3e22b9 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/HybridHRWatchfaceSettingsActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/HybridHRWatchfaceSettingsActivity.java @@ -19,6 +19,7 @@ package nodomain.freeyourgadget.gadgetbridge.devices.qhybrid; import android.content.Intent; import android.os.Bundle; import android.preference.EditTextPreference; +import android.preference.ListPreference; import android.preference.Preference; import android.preference.PreferenceFragment; import android.preference.SwitchPreference; @@ -68,7 +69,7 @@ public class HybridHRWatchfaceSettingsActivity extends AbstractSettingsActivity return super.onOptionsItemSelected(item); } - public static class HybridHRWatchfaceSettingsFragment extends PreferenceFragment + public static class HybridHRWatchfaceSettingsFragment extends PreferenceFragment implements Preference.OnPreferenceChangeListener { @Override public void onCreate(final Bundle savedInstanceState) { @@ -76,86 +77,94 @@ public class HybridHRWatchfaceSettingsActivity extends AbstractSettingsActivity addPreferencesFromResource(R.xml.fossil_hr_watchface_settings); EditTextPreference refresh_full = (EditTextPreference) findPreference("pref_hybridhr_watchface_refresh_full"); - refresh_full.setOnPreferenceChangeListener(new PreferenceChangeListener()); + refresh_full.setOnPreferenceChangeListener(this); refresh_full.setText(Integer.toString(settings.getDisplayTimeoutFull())); refresh_full.setSummary(Integer.toString(settings.getDisplayTimeoutFull())); EditTextPreference refresh_partial = (EditTextPreference) findPreference("pref_hybridhr_watchface_refresh_partial"); - refresh_partial.setOnPreferenceChangeListener(new PreferenceChangeListener()); + refresh_partial.setOnPreferenceChangeListener(this); refresh_partial.setText(Integer.toString(settings.getDisplayTimeoutPartial())); refresh_partial.setSummary(Integer.toString(settings.getDisplayTimeoutPartial())); SwitchPreference wrist_flick_relative = (SwitchPreference) findPreference("pref_hybridhr_watchface_wrist_flick_relative"); - wrist_flick_relative.setOnPreferenceChangeListener(new PreferenceChangeListener()); + wrist_flick_relative.setOnPreferenceChangeListener(this); wrist_flick_relative.setChecked(settings.isWristFlickHandsMoveRelative()); EditTextPreference wrist_flick_hour_hand = (EditTextPreference) findPreference("pref_hybridhr_watchface_wrist_flick_hour_hand"); - wrist_flick_hour_hand.setOnPreferenceChangeListener(new PreferenceChangeListener()); + wrist_flick_hour_hand.setOnPreferenceChangeListener(this); wrist_flick_hour_hand.setText(Integer.toString(settings.getWristFlickMoveHour())); wrist_flick_hour_hand.setSummary(Integer.toString(settings.getWristFlickMoveHour())); EditTextPreference wrist_flick_minute_hand = (EditTextPreference) findPreference("pref_hybridhr_watchface_wrist_flick_minute_hand"); - wrist_flick_minute_hand.setOnPreferenceChangeListener(new PreferenceChangeListener()); + wrist_flick_minute_hand.setOnPreferenceChangeListener(this); wrist_flick_minute_hand.setText(Integer.toString(settings.getWristFlickMoveMinute())); wrist_flick_minute_hand.setSummary(Integer.toString(settings.getWristFlickMoveMinute())); EditTextPreference wrist_flick_duration = (EditTextPreference) findPreference("pref_hybridhr_watchface_wrist_flick_duration"); - wrist_flick_duration.setOnPreferenceChangeListener(new PreferenceChangeListener()); + wrist_flick_duration.setOnPreferenceChangeListener(this); wrist_flick_duration.setText(Integer.toString(settings.getWristFlickDuration())); wrist_flick_duration.setSummary(Integer.toString(settings.getWristFlickDuration())); + ListPreference toggle_widgets = (ListPreference) findPreference("pref_hybridhr_watchface_toggle_widgets"); + toggle_widgets.setOnPreferenceChangeListener(this); + toggle_widgets.setValue(settings.getToggleWidgetsEvent()); + toggle_widgets.setSummary(toggle_widgets.getEntry()); + SwitchPreference power_saving_display = (SwitchPreference) findPreference("pref_hybridhr_watchface_power_saving_display"); - power_saving_display.setOnPreferenceChangeListener(new PreferenceChangeListener()); + power_saving_display.setOnPreferenceChangeListener(this); power_saving_display.setChecked(settings.getPowersaveDisplay()); SwitchPreference power_saving_hands = (SwitchPreference) findPreference("pref_hybridhr_watchface_power_saving_hands"); - power_saving_hands.setOnPreferenceChangeListener(new PreferenceChangeListener()); + power_saving_hands.setOnPreferenceChangeListener(this); power_saving_hands.setChecked(settings.getPowersaveHands()); SwitchPreference light_up_on_notification = (SwitchPreference) findPreference("pref_hybridhr_watchface_light_up_on_notification"); - light_up_on_notification.setOnPreferenceChangeListener(new PreferenceChangeListener()); + light_up_on_notification.setOnPreferenceChangeListener(this); light_up_on_notification.setChecked(settings.getLightUpOnNotification()); } - private static class PreferenceChangeListener implements Preference.OnPreferenceChangeListener { - @Override - public boolean onPreferenceChange(Preference preference, Object newValue) { - switch (preference.getKey()) { - case "pref_hybridhr_watchface_refresh_full": - settings.setDisplayTimeoutFull(Integer.parseInt(newValue.toString())); - preference.setSummary(newValue.toString()); - break; - case "pref_hybridhr_watchface_refresh_partial": - settings.setDisplayTimeoutPartial(Integer.parseInt(newValue.toString())); - preference.setSummary(newValue.toString()); - break; - case "pref_hybridhr_watchface_wrist_flick_relative": - settings.setWristFlickHandsMoveRelative((boolean) newValue); - break; - case "pref_hybridhr_watchface_wrist_flick_hour_hand": - settings.setWristFlickMoveHour(Integer.parseInt(newValue.toString())); - preference.setSummary(newValue.toString()); - break; - case "pref_hybridhr_watchface_wrist_flick_minute_hand": - settings.setWristFlickMoveMinute(Integer.parseInt(newValue.toString())); - preference.setSummary(newValue.toString()); - break; - case "pref_hybridhr_watchface_light_up_on_notification": - settings.setLightUpOnNotification((boolean) newValue); - break; - case "pref_hybridhr_watchface_wrist_flick_duration": - settings.setWristFlickDuration(Integer.parseInt(newValue.toString())); - preference.setSummary(newValue.toString()); - break; - case "pref_hybridhr_watchface_power_saving_display": - settings.setPowersaveDisplay((boolean) newValue); - break; - case "pref_hybridhr_watchface_power_saving_hands": - settings.setPowersaveHands((boolean) newValue); - break; - } - return true; + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + switch (preference.getKey()) { + case "pref_hybridhr_watchface_refresh_full": + settings.setDisplayTimeoutFull(Integer.parseInt(newValue.toString())); + preference.setSummary(newValue.toString()); + break; + case "pref_hybridhr_watchface_refresh_partial": + settings.setDisplayTimeoutPartial(Integer.parseInt(newValue.toString())); + preference.setSummary(newValue.toString()); + break; + case "pref_hybridhr_watchface_wrist_flick_relative": + settings.setWristFlickHandsMoveRelative((boolean) newValue); + break; + case "pref_hybridhr_watchface_wrist_flick_hour_hand": + settings.setWristFlickMoveHour(Integer.parseInt(newValue.toString())); + preference.setSummary(newValue.toString()); + break; + case "pref_hybridhr_watchface_wrist_flick_minute_hand": + settings.setWristFlickMoveMinute(Integer.parseInt(newValue.toString())); + preference.setSummary(newValue.toString()); + break; + case "pref_hybridhr_watchface_wrist_flick_duration": + settings.setWristFlickDuration(Integer.parseInt(newValue.toString())); + preference.setSummary(newValue.toString()); + break; + case "pref_hybridhr_watchface_toggle_widgets": + settings.setToggleWidgetsEvent(newValue.toString()); + ((ListPreference)preference).setValue(newValue.toString()); + preference.setSummary(((ListPreference)preference).getEntry()); + break; + case "pref_hybridhr_watchface_power_saving_display": + settings.setPowersaveDisplay((boolean) newValue); + break; + case "pref_hybridhr_watchface_power_saving_hands": + settings.setPowersaveHands((boolean) newValue); + break; + case "pref_hybridhr_watchface_light_up_on_notification": + settings.setLightUpOnNotification((boolean) newValue); + break; } + return true; } } } diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 712a59c80..40ced400d 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -1824,6 +1824,23 @@ widget_bg_dashed_circle + + @string/menuitem_nothing + @string/pref_title_upper_button_function_short + @string/pref_title_upper_button_function_long + @string/pref_title_middle_button_function_short + @string/pref_title_lower_button_function_short + @string/pref_title_lower_button_function_long + + + + top_short_press_release + top_hold + middle_short_press_release + bottom_short_press_release + bottom_hold + + @string/sports_activity_quick_filter_select @string/sports_activity_quick_filter_this_week diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index eedf4e4c4..4802b752d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1470,6 +1470,8 @@ Hour hand (-360 to 360) Minute hand (-360 to 360) Duration (in ms) + Toggle widgets + Button action A watchface with this name already exists in the cache. Do you want to overwrite it? Upload of the watchface failed. Please try again. Battery diff --git a/app/src/main/res/xml/fossil_hr_watchface_settings.xml b/app/src/main/res/xml/fossil_hr_watchface_settings.xml index 8b114eca4..d6d47fd82 100644 --- a/app/src/main/res/xml/fossil_hr_watchface_settings.xml +++ b/app/src/main/res/xml/fossil_hr_watchface_settings.xml @@ -44,6 +44,20 @@ + + + + + + diff --git a/external/fossil-hr-watchface b/external/fossil-hr-watchface index 84b3c55cd..0e2551757 160000 --- a/external/fossil-hr-watchface +++ b/external/fossil-hr-watchface @@ -1 +1 @@ -Subproject commit 84b3c55cda7515761600daaebe79582c6e0d4686 +Subproject commit 0e2551757d8c70031c2533d3d94a0f284c05ca9f