mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-27 12:26:48 +01:00
Fossil Hybrid HR: Add toggling of widgets with physical button event
This commit is contained in:
parent
03db850b3e
commit
0b6c2db606
Binary file not shown.
@ -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"));
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1824,6 +1824,23 @@
|
||||
<item>widget_bg_dashed_circle</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_hybridhr_watchface_togglewidgets_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>
|
||||
<item name="middle_short_press_release">@string/pref_title_middle_button_function_short</item>
|
||||
<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">
|
||||
<item></item>
|
||||
<item>top_short_press_release</item>
|
||||
<item>top_hold</item>
|
||||
<item>middle_short_press_release</item>
|
||||
<item>bottom_short_press_release</item>
|
||||
<item>bottom_hold</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="activity_filter_quick_filter_period_items">
|
||||
<item>@string/sports_activity_quick_filter_select</item>
|
||||
<item>@string/sports_activity_quick_filter_this_week</item>
|
||||
|
@ -1470,6 +1470,8 @@
|
||||
<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_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>
|
||||
|
@ -44,6 +44,20 @@
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/watchface_setting_title_button_toggle_widgets">
|
||||
|
||||
<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:dialogTitle="@string/watchface_setting_button_toggle_widgets"
|
||||
android:negativeButtonText="@string/Cancel"/>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/watchface_setting_title_power_saving">
|
||||
|
||||
|
2
external/fossil-hr-watchface
vendored
2
external/fossil-hr-watchface
vendored
@ -1 +1 @@
|
||||
Subproject commit 84b3c55cda7515761600daaebe79582c6e0d4686
|
||||
Subproject commit 0e2551757d8c70031c2533d3d94a0f284c05ca9f
|
Loading…
Reference in New Issue
Block a user