1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-26 10:35:50 +01:00

Use simple summary provider for vibration pattern counts

This commit is contained in:
José Rebelo 2023-12-08 10:45:07 +00:00
parent b4aca410b4
commit 77329813b9
2 changed files with 93 additions and 89 deletions

View File

@ -98,14 +98,7 @@ public class HuamiSettingsCustomizer implements DeviceSpecificSettingsCustomizer
@Override @Override
public Set<String> getPreferenceKeysWithSummary() { public Set<String> getPreferenceKeysWithSummary() {
final Set<String> keysWithSummary = new HashSet<>(); return new HashSet<>();
for (HuamiVibrationPatternNotificationType notificationType : HuamiVibrationPatternNotificationType.values()) {
final String typeKey = notificationType.name().toLowerCase(Locale.ROOT);
keysWithSummary.add(HuamiConst.PREF_HUAMI_VIBRATION_COUNT_PREFIX + typeKey);
}
return keysWithSummary;
} }
public static final Creator<HuamiSettingsCustomizer> CREATOR = new Creator<HuamiSettingsCustomizer>() { public static final Creator<HuamiSettingsCustomizer> CREATOR = new Creator<HuamiSettingsCustomizer>() {

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceScreen <PreferenceScreen
android:icon="@drawable/ic_vibration" android:icon="@drawable/ic_vibration"
android:key="vibration_patterns_key" android:key="vibration_patterns_key"
@ -10,10 +11,10 @@
<PreferenceCategory android:title="@string/pref_screen_vibration_patterns_title" /> <PreferenceCategory android:title="@string/pref_screen_vibration_patterns_title" />
<PreferenceScreen <PreferenceScreen
android:key="vibration_profile_key_app_alerts"
android:icon="@drawable/ic_settings_applications" android:icon="@drawable/ic_settings_applications"
android:title="@string/pref_screen_notification_profile_generic" android:key="vibration_profile_key_app_alerts"
android:persistent="false"> android:persistent="false"
android:title="@string/pref_screen_notification_profile_generic">
<!-- workaround for missing toolbar --> <!-- workaround for missing toolbar -->
<PreferenceCategory android:title="@string/pref_screen_notification_profile_generic" /> <PreferenceCategory android:title="@string/pref_screen_notification_profile_generic" />
@ -23,27 +24,28 @@
android:entries="@array/vibration_profile" android:entries="@array/vibration_profile"
android:entryValues="@array/vibration_profile_values" android:entryValues="@array/vibration_profile_values"
android:key="huami_vibration_profile_app_alerts" android:key="huami_vibration_profile_app_alerts"
android:title="@string/miband_prefs_vibration" android:summary="%s"
android:summary="%s" /> android:title="@string/miband_prefs_vibration" />
<EditTextPreference <EditTextPreference
android:defaultValue="2" android:defaultValue="2"
android:inputType="number" android:inputType="number"
android:key="huami_vibration_count_app_alerts" android:key="huami_vibration_count_app_alerts"
android:maxLength="1" android:maxLength="1"
android:title="@string/pref_title_notifications_repetitions" /> android:title="@string/pref_title_notifications_repetitions"
app:useSimpleSummaryProvider="true" />
<Preference <Preference
android:persistent="false"
android:key="huami_vibration_try_app_alerts" android:key="huami_vibration_try_app_alerts"
android:title="@string/vibration_try"/> android:persistent="false"
android:title="@string/vibration_try" />
</PreferenceScreen> </PreferenceScreen>
<PreferenceScreen <PreferenceScreen
android:key="vibration_profile_key_incoming_call"
android:icon="@drawable/ic_phone" android:icon="@drawable/ic_phone"
android:title="@string/pref_screen_notification_profile_incoming_call" android:key="vibration_profile_key_incoming_call"
android:persistent="false"> android:persistent="false"
android:title="@string/pref_screen_notification_profile_incoming_call">
<!-- workaround for missing toolbar --> <!-- workaround for missing toolbar -->
<PreferenceCategory android:title="@string/pref_screen_notification_profile_incoming_call" /> <PreferenceCategory android:title="@string/pref_screen_notification_profile_incoming_call" />
@ -53,27 +55,28 @@
android:entries="@array/vibration_profile" android:entries="@array/vibration_profile"
android:entryValues="@array/vibration_profile_values" android:entryValues="@array/vibration_profile_values"
android:key="huami_vibration_profile_incoming_call" android:key="huami_vibration_profile_incoming_call"
android:title="@string/miband_prefs_vibration" android:summary="%s"
android:summary="%s" /> android:title="@string/miband_prefs_vibration" />
<EditTextPreference <EditTextPreference
android:defaultValue="1" android:defaultValue="1"
android:inputType="number" android:inputType="number"
android:key="huami_vibration_count_incoming_call" android:key="huami_vibration_count_incoming_call"
android:maxLength="1" android:maxLength="1"
android:title="@string/pref_title_notifications_repetitions" /> android:title="@string/pref_title_notifications_repetitions"
app:useSimpleSummaryProvider="true" />
<Preference <Preference
android:persistent="false"
android:key="huami_vibration_try_incoming_call" android:key="huami_vibration_try_incoming_call"
android:title="@string/vibration_try"/> android:persistent="false"
android:title="@string/vibration_try" />
</PreferenceScreen> </PreferenceScreen>
<PreferenceScreen <PreferenceScreen
android:key="vibration_profile_key_incoming_sms"
android:icon="@drawable/ic_message_outline" android:icon="@drawable/ic_message_outline"
android:title="@string/pref_screen_notification_profile_sms" android:key="vibration_profile_key_incoming_sms"
android:persistent="false"> android:persistent="false"
android:title="@string/pref_screen_notification_profile_sms">
<!-- workaround for missing toolbar --> <!-- workaround for missing toolbar -->
<PreferenceCategory android:title="@string/pref_screen_notification_profile_sms" /> <PreferenceCategory android:title="@string/pref_screen_notification_profile_sms" />
@ -83,27 +86,28 @@
android:entries="@array/vibration_profile" android:entries="@array/vibration_profile"
android:entryValues="@array/vibration_profile_values" android:entryValues="@array/vibration_profile_values"
android:key="huami_vibration_profile_incoming_sms" android:key="huami_vibration_profile_incoming_sms"
android:title="@string/miband_prefs_vibration" android:summary="%s"
android:summary="%s" /> android:title="@string/miband_prefs_vibration" />
<EditTextPreference <EditTextPreference
android:defaultValue="2" android:defaultValue="2"
android:inputType="number" android:inputType="number"
android:key="huami_vibration_count_incoming_sms" android:key="huami_vibration_count_incoming_sms"
android:maxLength="1" android:maxLength="1"
android:title="@string/pref_title_notifications_repetitions" /> android:title="@string/pref_title_notifications_repetitions"
app:useSimpleSummaryProvider="true" />
<Preference <Preference
android:persistent="false"
android:key="huami_vibration_try_incoming_sms" android:key="huami_vibration_try_incoming_sms"
android:title="@string/vibration_try"/> android:persistent="false"
android:title="@string/vibration_try" />
</PreferenceScreen> </PreferenceScreen>
<PreferenceScreen <PreferenceScreen
android:key="vibration_profile_key_goal_notification"
android:icon="@drawable/ic_star_gray" android:icon="@drawable/ic_star_gray"
android:title="@string/mi2_prefs_goal_notification" android:key="vibration_profile_key_goal_notification"
android:persistent="false"> android:persistent="false"
android:title="@string/mi2_prefs_goal_notification">
<!-- workaround for missing toolbar --> <!-- workaround for missing toolbar -->
<PreferenceCategory android:title="@string/mi2_prefs_goal_notification" /> <PreferenceCategory android:title="@string/mi2_prefs_goal_notification" />
@ -113,27 +117,28 @@
android:entries="@array/vibration_profile" android:entries="@array/vibration_profile"
android:entryValues="@array/vibration_profile_values" android:entryValues="@array/vibration_profile_values"
android:key="huami_vibration_profile_goal_notification" android:key="huami_vibration_profile_goal_notification"
android:title="@string/miband_prefs_vibration" android:summary="%s"
android:summary="%s" /> android:title="@string/miband_prefs_vibration" />
<EditTextPreference <EditTextPreference
android:defaultValue="1" android:defaultValue="1"
android:inputType="number" android:inputType="number"
android:key="huami_vibration_count_goal_notification" android:key="huami_vibration_count_goal_notification"
android:maxLength="1" android:maxLength="1"
android:title="@string/pref_title_notifications_repetitions" /> android:title="@string/pref_title_notifications_repetitions"
app:useSimpleSummaryProvider="true" />
<Preference <Preference
android:persistent="false"
android:key="huami_vibration_try_goal_notification" android:key="huami_vibration_try_goal_notification"
android:title="@string/vibration_try"/> android:persistent="false"
android:title="@string/vibration_try" />
</PreferenceScreen> </PreferenceScreen>
<PreferenceScreen <PreferenceScreen
android:key="vibration_profile_key_alarm"
android:icon="@drawable/ic_access_alarms" android:icon="@drawable/ic_access_alarms"
android:title="@string/vibration_profile_alarm_clock" android:key="vibration_profile_key_alarm"
android:persistent="false"> android:persistent="false"
android:title="@string/vibration_profile_alarm_clock">
<!-- workaround for missing toolbar --> <!-- workaround for missing toolbar -->
<PreferenceCategory android:title="@string/vibration_profile_alarm_clock" /> <PreferenceCategory android:title="@string/vibration_profile_alarm_clock" />
@ -143,27 +148,28 @@
android:entries="@array/vibration_profile" android:entries="@array/vibration_profile"
android:entryValues="@array/vibration_profile_values" android:entryValues="@array/vibration_profile_values"
android:key="huami_vibration_profile_alarm" android:key="huami_vibration_profile_alarm"
android:title="@string/miband_prefs_vibration" android:summary="%s"
android:summary="%s" /> android:title="@string/miband_prefs_vibration" />
<EditTextPreference <EditTextPreference
android:defaultValue="7" android:defaultValue="7"
android:inputType="number" android:inputType="number"
android:key="huami_vibration_count_alarm" android:key="huami_vibration_count_alarm"
android:maxLength="1" android:maxLength="1"
android:title="@string/pref_title_notifications_repetitions" /> android:title="@string/pref_title_notifications_repetitions"
app:useSimpleSummaryProvider="true" />
<Preference <Preference
android:persistent="false"
android:key="huami_vibration_try_alarm" android:key="huami_vibration_try_alarm"
android:title="@string/vibration_try"/> android:persistent="false"
android:title="@string/vibration_try" />
</PreferenceScreen> </PreferenceScreen>
<PreferenceScreen <PreferenceScreen
android:key="vibration_profile_key_idle_alerts"
android:icon="@drawable/ic_chair" android:icon="@drawable/ic_chair"
android:title="@string/pref_screen_notification_idle_alerts" android:key="vibration_profile_key_idle_alerts"
android:persistent="false"> android:persistent="false"
android:title="@string/pref_screen_notification_idle_alerts">
<!-- workaround for missing toolbar --> <!-- workaround for missing toolbar -->
<PreferenceCategory android:title="@string/pref_screen_notification_idle_alerts" /> <PreferenceCategory android:title="@string/pref_screen_notification_idle_alerts" />
@ -173,27 +179,28 @@
android:entries="@array/vibration_profile" android:entries="@array/vibration_profile"
android:entryValues="@array/vibration_profile_values" android:entryValues="@array/vibration_profile_values"
android:key="huami_vibration_profile_idle_alerts" android:key="huami_vibration_profile_idle_alerts"
android:title="@string/miband_prefs_vibration" android:summary="%s"
android:summary="%s" /> android:title="@string/miband_prefs_vibration" />
<EditTextPreference <EditTextPreference
android:defaultValue="2" android:defaultValue="2"
android:inputType="number" android:inputType="number"
android:key="huami_vibration_count_idle_alerts" android:key="huami_vibration_count_idle_alerts"
android:maxLength="1" android:maxLength="1"
android:title="@string/pref_title_notifications_repetitions" /> android:title="@string/pref_title_notifications_repetitions"
app:useSimpleSummaryProvider="true" />
<Preference <Preference
android:persistent="false"
android:key="huami_vibration_try_idle_alerts" android:key="huami_vibration_try_idle_alerts"
android:title="@string/vibration_try"/> android:persistent="false"
android:title="@string/vibration_try" />
</PreferenceScreen> </PreferenceScreen>
<PreferenceScreen <PreferenceScreen
android:key="vibration_profile_key_event_reminder"
android:icon="@drawable/ic_device_set_reminders" android:icon="@drawable/ic_device_set_reminders"
android:title="@string/pref_screen_notification_profile_event_reminder" android:key="vibration_profile_key_event_reminder"
android:persistent="false"> android:persistent="false"
android:title="@string/pref_screen_notification_profile_event_reminder">
<!-- workaround for missing toolbar --> <!-- workaround for missing toolbar -->
<PreferenceCategory android:title="@string/pref_screen_notification_profile_event_reminder" /> <PreferenceCategory android:title="@string/pref_screen_notification_profile_event_reminder" />
@ -203,27 +210,28 @@
android:entries="@array/vibration_profile" android:entries="@array/vibration_profile"
android:entryValues="@array/vibration_profile_values" android:entryValues="@array/vibration_profile_values"
android:key="huami_vibration_profile_event_reminder" android:key="huami_vibration_profile_event_reminder"
android:title="@string/miband_prefs_vibration" android:summary="%s"
android:summary="%s" /> android:title="@string/miband_prefs_vibration" />
<EditTextPreference <EditTextPreference
android:defaultValue="1" android:defaultValue="1"
android:inputType="number" android:inputType="number"
android:key="huami_vibration_count_event_reminder" android:key="huami_vibration_count_event_reminder"
android:maxLength="1" android:maxLength="1"
android:title="@string/pref_title_notifications_repetitions" /> android:title="@string/pref_title_notifications_repetitions"
app:useSimpleSummaryProvider="true" />
<Preference <Preference
android:persistent="false"
android:key="huami_vibration_try_event_reminder" android:key="huami_vibration_try_event_reminder"
android:title="@string/vibration_try"/> android:persistent="false"
android:title="@string/vibration_try" />
</PreferenceScreen> </PreferenceScreen>
<PreferenceScreen <PreferenceScreen
android:key="vibration_profile_key_find_band"
android:icon="@drawable/ic_action_find_lost_device" android:icon="@drawable/ic_action_find_lost_device"
android:title="@string/pref_screen_notification_profile_find_device" android:key="vibration_profile_key_find_band"
android:persistent="false"> android:persistent="false"
android:title="@string/pref_screen_notification_profile_find_device">
<!-- workaround for missing toolbar --> <!-- workaround for missing toolbar -->
<PreferenceCategory android:title="@string/pref_screen_notification_profile_find_device" /> <PreferenceCategory android:title="@string/pref_screen_notification_profile_find_device" />
@ -233,27 +241,28 @@
android:entries="@array/vibration_profile" android:entries="@array/vibration_profile"
android:entryValues="@array/vibration_profile_values" android:entryValues="@array/vibration_profile_values"
android:key="huami_vibration_profile_find_band" android:key="huami_vibration_profile_find_band"
android:title="@string/miband_prefs_vibration" android:summary="%s"
android:summary="%s" /> android:title="@string/miband_prefs_vibration" />
<EditTextPreference <EditTextPreference
android:defaultValue="1" android:defaultValue="1"
android:inputType="number" android:inputType="number"
android:key="huami_vibration_count_find_band" android:key="huami_vibration_count_find_band"
android:maxLength="1" android:maxLength="1"
android:title="@string/pref_title_notifications_repetitions" /> android:title="@string/pref_title_notifications_repetitions"
app:useSimpleSummaryProvider="true" />
<Preference <Preference
android:persistent="false"
android:key="huami_vibration_try_find_band" android:key="huami_vibration_try_find_band"
android:title="@string/vibration_try"/> android:persistent="false"
android:title="@string/vibration_try" />
</PreferenceScreen> </PreferenceScreen>
<PreferenceScreen <PreferenceScreen
android:key="vibration_profile_key_todo_list"
android:icon="@drawable/ic_checklist" android:icon="@drawable/ic_checklist"
android:title="@string/pref_screen_notification_profile_todo_list" android:key="vibration_profile_key_todo_list"
android:persistent="false"> android:persistent="false"
android:title="@string/pref_screen_notification_profile_todo_list">
<!-- workaround for missing toolbar --> <!-- workaround for missing toolbar -->
<PreferenceCategory android:title="@string/pref_screen_notification_profile_todo_list" /> <PreferenceCategory android:title="@string/pref_screen_notification_profile_todo_list" />
@ -263,27 +272,28 @@
android:entries="@array/vibration_profile" android:entries="@array/vibration_profile"
android:entryValues="@array/vibration_profile_values" android:entryValues="@array/vibration_profile_values"
android:key="huami_vibration_profile_todo_list" android:key="huami_vibration_profile_todo_list"
android:title="@string/miband_prefs_vibration" android:summary="%s"
android:summary="%s" /> android:title="@string/miband_prefs_vibration" />
<EditTextPreference <EditTextPreference
android:defaultValue="2" android:defaultValue="2"
android:inputType="number" android:inputType="number"
android:key="huami_vibration_count_todo_list" android:key="huami_vibration_count_todo_list"
android:maxLength="1" android:maxLength="1"
android:title="@string/pref_title_notifications_repetitions" /> android:title="@string/pref_title_notifications_repetitions"
app:useSimpleSummaryProvider="true" />
<Preference <Preference
android:persistent="false"
android:key="huami_vibration_try_todo_list" android:key="huami_vibration_try_todo_list"
android:title="@string/vibration_try"/> android:persistent="false"
android:title="@string/vibration_try" />
</PreferenceScreen> </PreferenceScreen>
<PreferenceScreen <PreferenceScreen
android:key="vibration_profile_key_schedule"
android:icon="@drawable/ic_calendar_to" android:icon="@drawable/ic_calendar_to"
android:title="@string/pref_screen_notification_profile_schedule" android:key="vibration_profile_key_schedule"
android:persistent="false"> android:persistent="false"
android:title="@string/pref_screen_notification_profile_schedule">
<!-- workaround for missing toolbar --> <!-- workaround for missing toolbar -->
<PreferenceCategory android:title="@string/pref_screen_notification_profile_schedule" /> <PreferenceCategory android:title="@string/pref_screen_notification_profile_schedule" />
@ -293,20 +303,21 @@
android:entries="@array/vibration_profile" android:entries="@array/vibration_profile"
android:entryValues="@array/vibration_profile_values" android:entryValues="@array/vibration_profile_values"
android:key="huami_vibration_profile_schedule" android:key="huami_vibration_profile_schedule"
android:title="@string/miband_prefs_vibration" android:summary="%s"
android:summary="%s" /> android:title="@string/miband_prefs_vibration" />
<EditTextPreference <EditTextPreference
android:defaultValue="2" android:defaultValue="2"
android:inputType="number" android:inputType="number"
android:key="huami_vibration_count_schedule" android:key="huami_vibration_count_schedule"
android:maxLength="1" android:maxLength="1"
android:title="@string/pref_title_notifications_repetitions" /> android:title="@string/pref_title_notifications_repetitions"
app:useSimpleSummaryProvider="true" />
<Preference <Preference
android:persistent="false"
android:key="huami_vibration_try_schedule" android:key="huami_vibration_try_schedule"
android:title="@string/vibration_try"/> android:persistent="false"
android:title="@string/vibration_try" />
</PreferenceScreen> </PreferenceScreen>
</PreferenceScreen> </PreferenceScreen>
</androidx.preference.PreferenceScreen> </androidx.preference.PreferenceScreen>