mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-29 13:26:50 +01:00
Fossil/Skagen Hybrids: Add input types to watchface/widget settings
This commit is contained in:
parent
0ae14fb80a
commit
e305a9133f
@ -18,17 +18,16 @@ package nodomain.freeyourgadget.gadgetbridge.devices.qhybrid;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.InputType;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import androidx.preference.EditTextPreference;
|
||||
import androidx.preference.ListPreference;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
import androidx.preference.SwitchPreference;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractGBActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractPreferenceFragment;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractSettingsActivityV2;
|
||||
|
||||
@ -88,59 +87,64 @@ public class HybridHRWatchfaceSettingsActivity extends AbstractSettingsActivityV
|
||||
public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
|
||||
setPreferencesFromResource(R.xml.fossil_hr_watchface_settings, rootKey);
|
||||
|
||||
EditTextPreference refresh_full = (EditTextPreference) findPreference("pref_hybridhr_watchface_refresh_full");
|
||||
EditTextPreference refresh_full = findPreference("pref_hybridhr_watchface_refresh_full");
|
||||
refresh_full.setOnPreferenceChangeListener(this);
|
||||
refresh_full.setText(Integer.toString(settings.getDisplayTimeoutFull()));
|
||||
refresh_full.setSummary(Integer.toString(settings.getDisplayTimeoutFull()));
|
||||
setInputTypeFor("pref_hybridhr_watchface_refresh_full", InputType.TYPE_CLASS_NUMBER);
|
||||
|
||||
EditTextPreference refresh_partial = (EditTextPreference) findPreference("pref_hybridhr_watchface_refresh_partial");
|
||||
EditTextPreference refresh_partial = findPreference("pref_hybridhr_watchface_refresh_partial");
|
||||
refresh_partial.setOnPreferenceChangeListener(this);
|
||||
refresh_partial.setText(Integer.toString(settings.getDisplayTimeoutPartial()));
|
||||
refresh_partial.setSummary(Integer.toString(settings.getDisplayTimeoutPartial()));
|
||||
setInputTypeFor("pref_hybridhr_watchface_refresh_partial", InputType.TYPE_CLASS_NUMBER);
|
||||
|
||||
SwitchPreference wrist_flick_relative = (SwitchPreference) findPreference("pref_hybridhr_watchface_wrist_flick_relative");
|
||||
SwitchPreference wrist_flick_relative = findPreference("pref_hybridhr_watchface_wrist_flick_relative");
|
||||
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");
|
||||
EditTextPreference wrist_flick_hour_hand = findPreference("pref_hybridhr_watchface_wrist_flick_hour_hand");
|
||||
wrist_flick_hour_hand.setOnPreferenceChangeListener(this);
|
||||
wrist_flick_hour_hand.setText(Integer.toString(settings.getWristFlickMoveHour()));
|
||||
wrist_flick_hour_hand.setSummary(Integer.toString(settings.getWristFlickMoveHour()));
|
||||
setInputTypeFor("pref_hybridhr_watchface_wrist_flick_hour_hand", InputType.TYPE_CLASS_NUMBER);
|
||||
|
||||
EditTextPreference wrist_flick_minute_hand = (EditTextPreference) findPreference("pref_hybridhr_watchface_wrist_flick_minute_hand");
|
||||
EditTextPreference wrist_flick_minute_hand = findPreference("pref_hybridhr_watchface_wrist_flick_minute_hand");
|
||||
wrist_flick_minute_hand.setOnPreferenceChangeListener(this);
|
||||
wrist_flick_minute_hand.setText(Integer.toString(settings.getWristFlickMoveMinute()));
|
||||
wrist_flick_minute_hand.setSummary(Integer.toString(settings.getWristFlickMoveMinute()));
|
||||
setInputTypeFor("pref_hybridhr_watchface_wrist_flick_minute_hand", InputType.TYPE_CLASS_NUMBER);
|
||||
|
||||
EditTextPreference wrist_flick_duration = (EditTextPreference) findPreference("pref_hybridhr_watchface_wrist_flick_duration");
|
||||
EditTextPreference wrist_flick_duration = findPreference("pref_hybridhr_watchface_wrist_flick_duration");
|
||||
wrist_flick_duration.setOnPreferenceChangeListener(this);
|
||||
wrist_flick_duration.setText(Integer.toString(settings.getWristFlickDuration()));
|
||||
wrist_flick_duration.setSummary(Integer.toString(settings.getWristFlickDuration()));
|
||||
setInputTypeFor("pref_hybridhr_watchface_wrist_flick_duration", InputType.TYPE_CLASS_NUMBER);
|
||||
|
||||
ListPreference toggle_widgets = (ListPreference) findPreference("pref_hybridhr_watchface_toggle_widgets");
|
||||
ListPreference toggle_widgets = findPreference("pref_hybridhr_watchface_toggle_widgets");
|
||||
toggle_widgets.setOnPreferenceChangeListener(this);
|
||||
toggle_widgets.setValue(settings.getToggleWidgetsEvent());
|
||||
toggle_widgets.setSummary(toggle_widgets.getEntry());
|
||||
|
||||
ListPreference toggle_backlight = (ListPreference) findPreference("pref_hybridhr_watchface_toggle_backlight");
|
||||
ListPreference toggle_backlight = findPreference("pref_hybridhr_watchface_toggle_backlight");
|
||||
toggle_backlight.setOnPreferenceChangeListener(this);
|
||||
toggle_backlight.setValue(settings.getToggleBacklightEvent());
|
||||
toggle_backlight.setSummary(toggle_backlight.getEntry());
|
||||
|
||||
ListPreference move_hands = (ListPreference) findPreference("pref_hybridhr_watchface_move_hands");
|
||||
ListPreference move_hands = findPreference("pref_hybridhr_watchface_move_hands");
|
||||
move_hands.setOnPreferenceChangeListener(this);
|
||||
move_hands.setValue(settings.getMoveHandsEvent());
|
||||
move_hands.setSummary(move_hands.getEntry());
|
||||
|
||||
SwitchPreference power_saving_display = (SwitchPreference) findPreference("pref_hybridhr_watchface_power_saving_display");
|
||||
SwitchPreference power_saving_display = findPreference("pref_hybridhr_watchface_power_saving_display");
|
||||
power_saving_display.setOnPreferenceChangeListener(this);
|
||||
power_saving_display.setChecked(settings.getPowersaveDisplay());
|
||||
|
||||
SwitchPreference power_saving_hands = (SwitchPreference) findPreference("pref_hybridhr_watchface_power_saving_hands");
|
||||
SwitchPreference power_saving_hands = findPreference("pref_hybridhr_watchface_power_saving_hands");
|
||||
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");
|
||||
SwitchPreference light_up_on_notification = findPreference("pref_hybridhr_watchface_light_up_on_notification");
|
||||
light_up_on_notification.setOnPreferenceChangeListener(this);
|
||||
light_up_on_notification.setChecked(settings.getLightUpOnNotification());
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ package nodomain.freeyourgadget.gadgetbridge.devices.qhybrid;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.InputType;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import androidx.preference.EditTextPreference;
|
||||
@ -104,7 +105,7 @@ public class HybridHRWatchfaceWidgetActivity extends AbstractSettingsActivityV2
|
||||
setPreferencesFromResource(R.xml.fossil_hr_widget_settings, rootKey);
|
||||
|
||||
widgetTypes = HybridHRWatchfaceWidget.getAvailableWidgetTypes(requireActivity().getBaseContext());
|
||||
ListPreference widgetType = (ListPreference) findPreference("pref_hybridhr_widget_type");
|
||||
ListPreference widgetType = findPreference("pref_hybridhr_widget_type");
|
||||
widgetType.setOnPreferenceChangeListener(this);
|
||||
widgetType.setEntries(widgetTypes.values().toArray(new String[0]));
|
||||
widgetType.setEntryValues(widgetTypes.keySet().toArray(new String[0]));
|
||||
@ -113,65 +114,70 @@ public class HybridHRWatchfaceWidgetActivity extends AbstractSettingsActivityV2
|
||||
updateEnabledCategories();
|
||||
|
||||
widgetColors = new String[]{getString(R.string.watchface_dialog_widget_color_white), getString(R.string.watchface_dialog_widget_color_black)};
|
||||
ListPreference widgetColor = (ListPreference) findPreference("pref_hybridhr_widget_color");
|
||||
ListPreference widgetColor = findPreference("pref_hybridhr_widget_color");
|
||||
widgetColor.setOnPreferenceChangeListener(this);
|
||||
widgetColor.setEntries(widgetColors);
|
||||
widgetColor.setEntryValues(new String[]{"0", "1"});
|
||||
widgetColor.setValueIndex(widget.getColor());
|
||||
widgetColor.setSummary(widgetColors[widget.getColor()]);
|
||||
|
||||
ListPreference widgetBg = (ListPreference) findPreference("pref_hybridhr_widget_background");
|
||||
ListPreference widgetBg = findPreference("pref_hybridhr_widget_background");
|
||||
widgetBg.setOnPreferenceChangeListener(this);
|
||||
widgetBg.setValue(widget.getBackground());
|
||||
widgetBg.setSummary(widgetBg.getEntry());
|
||||
|
||||
EditTextPreference posX = (EditTextPreference) findPreference("pref_hybridhr_widget_pos_x");
|
||||
EditTextPreference posX = findPreference("pref_hybridhr_widget_pos_x");
|
||||
posX.setOnPreferenceChangeListener(this);
|
||||
posX.setText(Integer.toString(widget.getPosX()));
|
||||
posX.setSummary(Integer.toString(widget.getPosX()));
|
||||
setInputTypeFor("pref_hybridhr_widget_pos_x", InputType.TYPE_CLASS_NUMBER);
|
||||
|
||||
EditTextPreference posY = (EditTextPreference) findPreference("pref_hybridhr_widget_pos_y");
|
||||
EditTextPreference posY = findPreference("pref_hybridhr_widget_pos_y");
|
||||
posY.setOnPreferenceChangeListener(this);
|
||||
posY.setText(Integer.toString(widget.getPosY()));
|
||||
posY.setSummary(Integer.toString(widget.getPosY()));
|
||||
setInputTypeFor("pref_hybridhr_widget_pos_y", InputType.TYPE_CLASS_NUMBER);
|
||||
|
||||
LinkedHashMap<String, String> positionPresets = new LinkedHashMap<String, String>();
|
||||
for (final HybridHRWidgetPosition position : widget.defaultPositions) {
|
||||
positionPresets.put(String.valueOf(position.hintStringResource), getString(position.hintStringResource));
|
||||
}
|
||||
ListPreference widgetPositionPreset = (ListPreference) findPreference("pref_hybridhr_widget_pos_preset");
|
||||
ListPreference widgetPositionPreset = findPreference("pref_hybridhr_widget_pos_preset");
|
||||
widgetPositionPreset.setOnPreferenceChangeListener(this);
|
||||
widgetPositionPreset.setEntries(positionPresets.values().toArray(new String[0]));
|
||||
widgetPositionPreset.setEntryValues(positionPresets.keySet().toArray(new String[0]));
|
||||
|
||||
String[] timezonesList = TimeZone.getAvailableIDs();
|
||||
ListPreference widgetTimezone = (ListPreference) findPreference("pref_hybridhr_widget_timezone");
|
||||
ListPreference widgetTimezone = findPreference("pref_hybridhr_widget_timezone");
|
||||
widgetTimezone.setOnPreferenceChangeListener(this);
|
||||
widgetTimezone.setEntries(timezonesList);
|
||||
widgetTimezone.setEntryValues(timezonesList);
|
||||
widgetTimezone.setValue(widget.getExtraConfigString("tzName", WIDGET_2NDTZ_DEFAULT_TZ));
|
||||
widgetTimezone.setSummary(widget.getExtraConfigString("tzName", WIDGET_2NDTZ_DEFAULT_TZ));
|
||||
|
||||
EditTextPreference timezoneDuration = (EditTextPreference) findPreference("pref_hybridhr_widget_timezone_timeout");
|
||||
EditTextPreference timezoneDuration = findPreference("pref_hybridhr_widget_timezone_timeout");
|
||||
timezoneDuration.setOnPreferenceChangeListener(this);
|
||||
timezoneDuration.setText(Integer.toString(widget.getExtraConfigInt("timeout_secs", WIDGET_2NDTZ_DEFAULT_TIMEOUT)));
|
||||
timezoneDuration.setSummary(Integer.toString(widget.getExtraConfigInt("timeout_secs", WIDGET_2NDTZ_DEFAULT_TIMEOUT)));
|
||||
setInputTypeFor("pref_hybridhr_widget_timezone_timeout", InputType.TYPE_CLASS_NUMBER);
|
||||
|
||||
EditTextPreference width = (EditTextPreference) findPreference("pref_hybridhr_widget_width");
|
||||
EditTextPreference width = findPreference("pref_hybridhr_widget_width");
|
||||
width.setOnPreferenceChangeListener(this);
|
||||
width.setText(Integer.toString(widget.getWidth()));
|
||||
width.setSummary(Integer.toString(widget.getWidth()));
|
||||
setInputTypeFor("pref_hybridhr_widget_width", InputType.TYPE_CLASS_NUMBER);
|
||||
|
||||
EditTextPreference customWidgetTimeout = (EditTextPreference) findPreference("pref_hybridhr_widget_custom_timeout");
|
||||
EditTextPreference customWidgetTimeout = findPreference("pref_hybridhr_widget_custom_timeout");
|
||||
customWidgetTimeout.setOnPreferenceChangeListener(this);
|
||||
customWidgetTimeout.setText(Integer.toString(widget.getExtraConfigInt("update_timeout", WIDGET_CUSTOM_DEFAULT_TIMEOUT)));
|
||||
customWidgetTimeout.setSummary(Integer.toString(widget.getExtraConfigInt("update_timeout", WIDGET_CUSTOM_DEFAULT_TIMEOUT)));
|
||||
setInputTypeFor("pref_hybridhr_widget_custom_timeout", InputType.TYPE_CLASS_NUMBER);
|
||||
|
||||
SwitchPreference customWidgetHideText = (SwitchPreference) findPreference("pref_hybridhr_widget_custom_hide_text");
|
||||
SwitchPreference customWidgetHideText = findPreference("pref_hybridhr_widget_custom_hide_text");
|
||||
customWidgetHideText.setOnPreferenceChangeListener(this);
|
||||
customWidgetHideText.setChecked(widget.getExtraConfigBoolean("timeout_hide_text", WIDGET_CUSTOM_DEFAULT_HIDE_TEXT));
|
||||
|
||||
SwitchPreference customWidgetShowCircle = (SwitchPreference) findPreference("pref_hybridhr_widget_custom_show_circle");
|
||||
SwitchPreference customWidgetShowCircle = findPreference("pref_hybridhr_widget_custom_show_circle");
|
||||
customWidgetShowCircle.setOnPreferenceChangeListener(this);
|
||||
customWidgetShowCircle.setChecked(widget.getExtraConfigBoolean("timeout_show_circle", WIDGET_CUSTOM_DEFAULT_SHOW_CIRCLE));
|
||||
}
|
||||
@ -215,8 +221,8 @@ public class HybridHRWatchfaceWidgetActivity extends AbstractSettingsActivityV2
|
||||
if (newValue.toString().equals(String.valueOf(position.hintStringResource))) {
|
||||
widget.setPosX(position.posX);
|
||||
widget.setPosY(position.posY);
|
||||
EditTextPreference prefPosX = (EditTextPreference) findPreference("pref_hybridhr_widget_pos_x");
|
||||
EditTextPreference prefPosY = (EditTextPreference) findPreference("pref_hybridhr_widget_pos_y");
|
||||
EditTextPreference prefPosX = findPreference("pref_hybridhr_widget_pos_x");
|
||||
EditTextPreference prefPosY = findPreference("pref_hybridhr_widget_pos_y");
|
||||
prefPosX.setSummary(String.valueOf(position.posX));
|
||||
prefPosY.setSummary(String.valueOf(position.posY));
|
||||
}
|
||||
@ -249,13 +255,13 @@ public class HybridHRWatchfaceWidgetActivity extends AbstractSettingsActivityV2
|
||||
}
|
||||
|
||||
private void updateEnabledCategories() {
|
||||
PreferenceCategory cat2ndTZ = (PreferenceCategory) findPreference("widget_pref_category_2nd_tz_widget");
|
||||
PreferenceCategory cat2ndTZ = findPreference("widget_pref_category_2nd_tz_widget");
|
||||
if (widget.getWidgetType().equals("widget2ndTZ")) {
|
||||
cat2ndTZ.setEnabled(true);
|
||||
} else {
|
||||
cat2ndTZ.setEnabled(false);
|
||||
}
|
||||
PreferenceCategory catCustom = (PreferenceCategory) findPreference("widget_pref_category_custom_widget");
|
||||
PreferenceCategory catCustom = findPreference("widget_pref_category_custom_widget");
|
||||
if (widget.getWidgetType().equals("widgetCustom")) {
|
||||
catCustom.setEnabled(true);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user