1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-07-22 06:41:06 +02:00

Fossil Hybrid HR: Add toggling of backlight with physical button event

This commit is contained in:
Arjan Schrijver 2022-08-01 17:21:55 +02:00
parent 44c087b666
commit 5f4d3f441f
10 changed files with 41 additions and 9 deletions

View File

@ -399,6 +399,9 @@ public class HybridHRWatchfaceDesignerActivity extends AbstractGBActivity implem
if (watchfaceConfig.has("toggle_widgets_event")) {
watchfaceSettings.setToggleWidgetsEvent(watchfaceConfig.getString("toggle_widgets_event"));
}
if (watchfaceConfig.has("toggle_backlight_event")) {
watchfaceSettings.setToggleBacklightEvent(watchfaceConfig.getString("toggle_backlight_event"));
}
if (watchfaceConfig.has("powersave_display")) {
watchfaceSettings.setPowersaveDisplay(watchfaceConfig.getBoolean("powersave_display"));
}

View File

@ -302,6 +302,7 @@ public class HybridHRWatchfaceFactory {
config.put("wrist_flick_move_hour", settings.getWristFlickMoveHour());
config.put("wrist_flick_move_minute", settings.getWristFlickMoveMinute());
config.put("toggle_widgets_event", settings.getToggleWidgetsEvent());
config.put("toggle_backlight_event", settings.getToggleBacklightEvent());
config.put("powersave_display", settings.getPowersaveDisplay());
config.put("powersave_hands", settings.getPowersaveHands());
config.put("light_up_on_notification", settings.getLightUpOnNotification());

View File

@ -26,6 +26,7 @@ public class HybridHRWatchfaceSettings implements Serializable {
private int wristFlickMoveHour = 360;
private int wristFlickMoveMinute = -360;
private String toggleWidgetsEvent = "";
private String toggleBacklightEvent = "";
private boolean powersaveDisplay = false;
private boolean powersaveHands = false;
private boolean lightUpOnNotification = false;
@ -109,6 +110,14 @@ public class HybridHRWatchfaceSettings implements Serializable {
this.toggleWidgetsEvent = event;
}
public String getToggleBacklightEvent() {
return toggleBacklightEvent;
}
public void setToggleBacklightEvent(String event) {
this.toggleBacklightEvent = event;
}
public boolean getPowersaveDisplay() {
return powersaveDisplay;
}

View File

@ -110,6 +110,11 @@ public class HybridHRWatchfaceSettingsActivity extends AbstractSettingsActivity
toggle_widgets.setValue(settings.getToggleWidgetsEvent());
toggle_widgets.setSummary(toggle_widgets.getEntry());
ListPreference toggle_backlight = (ListPreference) findPreference("pref_hybridhr_watchface_toggle_backlight");
toggle_backlight.setOnPreferenceChangeListener(this);
toggle_backlight.setValue(settings.getToggleBacklightEvent());
toggle_backlight.setSummary(toggle_backlight.getEntry());
SwitchPreference power_saving_display = (SwitchPreference) findPreference("pref_hybridhr_watchface_power_saving_display");
power_saving_display.setOnPreferenceChangeListener(this);
power_saving_display.setChecked(settings.getPowersaveDisplay());
@ -154,6 +159,11 @@ public class HybridHRWatchfaceSettingsActivity extends AbstractSettingsActivity
((ListPreference)preference).setValue(newValue.toString());
preference.setSummary(((ListPreference)preference).getEntry());
break;
case "pref_hybridhr_watchface_toggle_backlight":
settings.setToggleBacklightEvent(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;

View File

@ -20,7 +20,7 @@ import java.util.HashMap;
import java.util.Map;
public final class QHybridConstants {
public static final String HYBRIDHR_WATCHFACE_VERSION = "1.3";
public static final String HYBRIDHR_WATCHFACE_VERSION = "1.4";
public static final int HYBRID_HR_WATCHFACE_WIDGET_SIZE = 76;
public static Map<String, String> KNOWN_WAPP_VERSIONS = new HashMap<String, String>() {

View File

@ -1824,7 +1824,7 @@
<item>widget_bg_dashed_circle</item>
</string-array>
<string-array name="pref_hybridhr_watchface_togglewidgets_items">
<string-array name="pref_hybridhr_watchface_buttonevents_items">
<item name="">@string/menuitem_nothing</item>
<item name="top_short_press_release">@string/pref_title_upper_button_function_short</item>
<item name="top_hold">@string/pref_title_upper_button_function_long</item>
@ -1832,7 +1832,7 @@
<item name="bottom_short_press_release">@string/pref_title_lower_button_function_short</item>
<item name="bottom_hold">@string/pref_title_lower_button_function_long</item>
</string-array>
<string-array name="pref_hybridhr_watchface_togglewidgets_values">
<string-array name="pref_hybridhr_watchface_buttonevents_values">
<item></item>
<item>top_short_press_release</item>
<item>top_hold</item>

View File

@ -1472,8 +1472,9 @@
<string name="watchface_setting_wrist_flick_hour">Hour hand (-360 to 360)</string>
<string name="watchface_setting_wrist_flick_minute">Minute hand (-360 to 360)</string>
<string name="watchface_setting_wrist_flick_duration">Duration (in ms)</string>
<string name="watchface_setting_title_button_toggle_widgets">Toggle widgets</string>
<string name="watchface_setting_button_toggle_widgets">Button action</string>
<string name="watchface_setting_title_custom_events">Custom events</string>
<string name="watchface_setting_button_toggle_widgets">Toggle widgets</string>
<string name="watchface_setting_button_toggle_backlight">Turn backlight on</string>
<string name="watchface_cache_confirm_overwrite">A watchface with this name already exists in the cache. Do you want to overwrite it?</string>
<string name="watchface_upload_failed">Upload of the watchface failed. Please try again.</string>
<string name="watchface_widget_type_battery">Battery</string>

View File

@ -45,16 +45,24 @@
</PreferenceCategory>
<PreferenceCategory
android:title="@string/watchface_setting_title_button_toggle_widgets">
android:title="@string/watchface_setting_title_custom_events">
<ListPreference
android:persistent="false"
android:title="@string/watchface_setting_button_toggle_widgets"
android:key="pref_hybridhr_watchface_toggle_widgets"
android:entries="@array/pref_hybridhr_watchface_togglewidgets_items"
android:entryValues="@array/pref_hybridhr_watchface_togglewidgets_values"
android:entries="@array/pref_hybridhr_watchface_buttonevents_items"
android:entryValues="@array/pref_hybridhr_watchface_buttonevents_values"
android:dialogTitle="@string/watchface_setting_button_toggle_widgets"
android:negativeButtonText="@string/Cancel"/>
<ListPreference
android:persistent="false"
android:title="@string/watchface_setting_button_toggle_backlight"
android:key="pref_hybridhr_watchface_toggle_backlight"
android:entries="@array/pref_hybridhr_watchface_buttonevents_items"
android:entryValues="@array/pref_hybridhr_watchface_buttonevents_values"
android:dialogTitle="@string/watchface_setting_button_toggle_backlight"
android:negativeButtonText="@string/Cancel"/>
</PreferenceCategory>

@ -1 +1 @@
Subproject commit 0e2551757d8c70031c2533d3d94a0f284c05ca9f
Subproject commit 6b3754690359b8ae964d73d18e607d4631e1eaf2