diff options
author | Danny Baumann <dannybaumann@web.de> | 2014-07-08 11:11:16 +0200 |
---|---|---|
committer | Danny Baumann <dannybaumann@web.de> | 2014-07-09 12:24:36 +0200 |
commit | 22aecd384c4ec60c8c663540875beede462d40b7 (patch) | |
tree | 16dd54926546c28b14c2df4d7ae4dfdadbe99445 | |
parent | c012ca5b623e96a1e545d499ed43b3f649ba136f (diff) | |
download | android_packages_wallpapers_PhotoPhase-22aecd384c4ec60c8c663540875beede462d40b7.tar.gz android_packages_wallpapers_PhotoPhase-22aecd384c4ec60c8c663540875beede462d40b7.tar.bz2 android_packages_wallpapers_PhotoPhase-22aecd384c4ec60c8c663540875beede462d40b7.zip |
Improve preference summary strings.
Remove some redundant summaries (e.g. for interval sliders) and make
summaries of list preferences adapt to the respective selection.
Change-Id: Ie120125fd36aef9b609326eb2d0e65224b7973d3
8 files changed, 123 insertions, 35 deletions
diff --git a/res/values/arrays.xml b/res/values/arrays.xml index 6ef1d88..df43a31 100644 --- a/res/values/arrays.xml +++ b/res/values/arrays.xml @@ -41,6 +41,13 @@ <item>@string/touch_actions_share</item> </string-array> + <string-array name="touch_actions_summaries" translatable="false"> + <item>@string/touch_actions_none_summary</item> + <item>@string/touch_actions_transition_summary</item> + <item>@string/touch_actions_open_summary</item> + <item>@string/touch_actions_share_summary</item> + </string-array> + <string-array name="touch_actions_values" translatable="false"> <item>0</item> <item>1</item> diff --git a/res/values/strings.xml b/res/values/strings.xml index a63963c..b26417a 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -38,6 +38,8 @@ <string name="mnu_deselect_album">Deselect album</string> <!-- Formats --> + <string name="format_disabled">Disabled</string> + <string name="format_rotate_only">On rotation</string> <string name="format_seconds">%s sec.</string> <string name="format_minutes">%s min.</string> <string name="format_hours">%s h.</string> @@ -49,25 +51,23 @@ <string name="pref_general_summary">General settings, effects and transitions</string> <string name="pref_general_settings">Settings</string> <string name="pref_general_settings_wallpaper_dim">Wallpaper dim</string> - <string name="pref_general_settings_wallpaper_dim_summary">Set the brightness to balance visualization and battery performance</string> <string name="pref_general_settings_background_color">Background color</string> <string name="pref_general_settings_background_color_summary">Set the background color</string> <string name="pref_general_touch_action">Touch action</string> - <string name="pref_general_touch_action_summary">Select the action to apply when touching a frame</string> + <string name="pref_general_touch_action_summary_format"><xliff:g id="action_summary">%1$s</xliff:g> when touching a frame</string> <string name="pref_general_aspect_ratio_correction">Aspect ratio</string> <string name="pref_general_aspect_ratio_correction_summary">Try to fix the picture\'s aspect ratio by cropping it to fit the destination frame</string> <string name="pref_general_transitions">Transitions</string> <string name="pref_general_transitions_types">Types</string> - <string name="pref_general_transitions_types_summary">Select the transition effects to be applied</string> + <string name="pref_general_transitions_types_summary_format"><xliff:g id="selected">%1$d</xliff:g> of <xliff:g id="total">%2$d</xliff:g> types selected</string> <string name="pref_general_transitions_interval">Interval</string> - <string name="pref_general_transitions_interval_summary">Set how often picture transitions are triggered</string> <string name="pref_general_effects">Effects</string> <string name="pref_general_effects_types">Types</string> - <string name="pref_general_effects_types_summary">Select the image effects to be applied</string> + <string name="pref_general_effects_types_summary_format"><xliff:g id="selected">%1$d</xliff:g> of <xliff:g id="total">%2$d</xliff:g> image effects selected</string> <string name="pref_media">Media</string> - <string name="pref_media_summary">Select albums to be displayed, refresh interval, and other media settings</string> + <string name="pref_media_summary">Albums to be displayed, refresh interval, and other media settings</string> <string name="pref_media_settings">Settings</string> <string name="pref_media_settings_refresh_interval">Refresh interval</string> <string name="pref_media_settings_refresh_interval_disable">Searching for new pictures is disabled</string> @@ -81,16 +81,20 @@ <string name="pref_media_auto_select_new_summary">Automatically select new albums when media discovery occurs</string> <string name="pref_layout">Layout</string> - <string name="pref_layout_summary">Select how pictures are positioned on the screen</string> + <string name="pref_layout_summary">Positioning of pictures on the screen</string> <string name="pref_layout_disposition">Arrangement</string> <string name="pref_random_dispositions">Random</string> <string name="pref_random_dispositions_summary">Generate random arrangements at a chosen interval</string> <string name="pref_random_dispositions_interval">Interval</string> - <string name="pref_random_dispositions_interval_summary">Select how often the layout will be changed. Set to 0 to re-layout only when the app is loaded or rotated</string> <string name="pref_disposition_portrait">Portrait arrangement</string> - <string name="pref_disposition_portrait_summary">Select how pictures are arranged on a portrait screen</string> <string name="pref_disposition_landscape">Landscape arrangement</string> - <string name="pref_disposition_landscape_summary">Select how pictures are arranged on a landscape screen</string> + <plurals name="pref_disposition_summary_format"> + <item quantity="one">1 image is shown in <xliff:g id="orientation">%2$s</xliff:g></item> + <item quantity="other"><xliff:g id="count">%1$d</xliff:g> images are shown in <xliff:g id="orientation">%2$s</xliff:g></item> + </plurals> + <string name="disposition_orientation_portrait">portrait orientation</string> + <string name="disposition_orientation_landscape">landscape orientation</string> + <!-- [2 lines one for describe long tap and another for describe swipe] --> <string name="pref_disposition_description">Long tap a frame and drag \u0026 drop its borders. Swipe left and right to show defined templates</string> <string name="pref_disposition_template">Template <xliff:g id="number_of_template">%1$s</xliff:g> of <xliff:g id="total_of_templates">%2$s</xliff:g></string> @@ -112,6 +116,10 @@ <string name="touch_actions_transition">Perform transition</string> <string name="touch_actions_open">Open</string> <string name="touch_actions_share">Share</string> + <string name="touch_actions_none_summary">Do nothing</string> + <string name="touch_actions_transition_summary">Perform image transition</string> + <string name="touch_actions_open_summary">Open the image</string> + <string name="touch_actions_share_summary">Share the image</string> <!-- Transitions --> <string name="transitions_cube">Cube</string> diff --git a/res/xml/preferences_general.xml b/res/xml/preferences_general.xml index c991aee..e6e89a1 100644 --- a/res/xml/preferences_general.xml +++ b/res/xml/preferences_general.xml @@ -25,7 +25,6 @@ <org.cyanogenmod.wallpapers.photophase.preferences.SeekBarProgressPreference android:key="ui_wallpaper_dim" android:title="@string/pref_general_settings_wallpaper_dim" - android:summary="@string/pref_general_settings_wallpaper_dim_summary" android:persistent="true" android:defaultValue="0" /> @@ -66,7 +65,6 @@ <MultiSelectListPreference android:key="ui_transition_types" android:title="@string/pref_general_transitions_types" - android:summary="@string/pref_general_transitions_types_summary" android:persistent="true" android:entries="@array/transitions_labels" android:entryValues="@array/transitions_values" @@ -76,7 +74,6 @@ <org.cyanogenmod.wallpapers.photophase.preferences.SeekBarProgressPreference android:key="ui_transition_interval" android:title="@string/pref_general_transitions_interval" - android:summary="@string/pref_general_transitions_interval_summary" android:persistent="true" android:defaultValue="2" /> diff --git a/res/xml/preferences_layout.xml b/res/xml/preferences_layout.xml index 796c5e4..62d0272 100644 --- a/res/xml/preferences_layout.xml +++ b/res/xml/preferences_layout.xml @@ -33,7 +33,6 @@ <org.cyanogenmod.wallpapers.photophase.preferences.SeekBarProgressPreference android:key="ui_disposition_random_interval" android:title="@string/pref_random_dispositions_interval" - android:summary="@string/pref_random_dispositions_interval_summary" android:persistent="true" android:defaultValue="0" android:dependency="ui_disposition_random" /> @@ -42,7 +41,6 @@ <Preference android:key="ui_disposition_portrait" android:title="@string/pref_disposition_portrait" - android:summary="@string/pref_disposition_portrait_summary" android:fragment="org.cyanogenmod.wallpapers.photophase.preferences.PortraitDispositionFragment" android:persistent="false" /> @@ -50,7 +48,6 @@ <Preference android:key="ui_disposition_landscape" android:title="@string/pref_disposition_landscape" - android:summary="@string/pref_disposition_landscape_summary" android:fragment="org.cyanogenmod.wallpapers.photophase.preferences.LandscapeDispositionFragment" android:persistent="false" /> diff --git a/src/org/cyanogenmod/wallpapers/photophase/preferences/DispositionFragment.java b/src/org/cyanogenmod/wallpapers/photophase/preferences/DispositionFragment.java index 4c663ab..e71b720 100644 --- a/src/org/cyanogenmod/wallpapers/photophase/preferences/DispositionFragment.java +++ b/src/org/cyanogenmod/wallpapers/photophase/preferences/DispositionFragment.java @@ -156,7 +156,7 @@ public abstract class DispositionFragment extends PreferenceFragment * {@inheritDoc} */ @Override - public void onDestroyView() { + public void onPause() { // Saved ? if (mOkPressed) { boolean saved = false; @@ -181,7 +181,7 @@ public abstract class DispositionFragment extends PreferenceFragment } } - super.onDestroyView(); + super.onPause(); } /** diff --git a/src/org/cyanogenmod/wallpapers/photophase/preferences/GeneralPreferenceFragment.java b/src/org/cyanogenmod/wallpapers/photophase/preferences/GeneralPreferenceFragment.java index d7a0d1c..de3883a 100644 --- a/src/org/cyanogenmod/wallpapers/photophase/preferences/GeneralPreferenceFragment.java +++ b/src/org/cyanogenmod/wallpapers/photophase/preferences/GeneralPreferenceFragment.java @@ -36,6 +36,8 @@ import org.cyanogenmod.wallpapers.photophase.preferences.PreferencesProvider.Pre import org.cyanogenmod.wallpapers.photophase.preferences.SeekBarProgressPreference.OnDisplayProgress; import org.cyanogenmod.wallpapers.photophase.widgets.ColorPickerPreference; +import java.util.Set; + /** * A fragment class with all the general settings */ @@ -58,6 +60,7 @@ public class GeneralPreferenceFragment extends PreferenceFragment { private final OnPreferenceChangeListener mOnChangeListener = new OnPreferenceChangeListener() { @Override + @SuppressWarnings("unchecked") public boolean onPreferenceChange(final Preference preference, Object newValue) { String key = preference.getKey(); if (DEBUG) Log.d(TAG, "Preference changed: " + key + "=" + newValue); @@ -71,12 +74,17 @@ public class GeneralPreferenceFragment extends PreferenceFragment { mRedrawFlag = true; } else if (key.compareTo("ui_transition_types") == 0) { mRedrawFlag = true; + updateTransitionTypeSummary((Set<String>) newValue); } else if (key.compareTo("ui_transition_interval") == 0) { mRedrawFlag = true; } else if (key.compareTo("ui_effect_types") == 0) { mRedrawFlag = true; mEmptyTextureQueueFlag = true; + updateEffectTypeSummary((Set<String>) newValue); + } else if (key.compareTo("ui_touch_action") == 0) { + updateTouchActionSummary((String) newValue); } + return true; } }; @@ -109,6 +117,7 @@ public class GeneralPreferenceFragment extends PreferenceFragment { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + final String formatDisabled = getString(R.string.format_disabled); final String formatSeconds = getString(R.string.format_seconds); final String formatMinutes = getString(R.string.format_minutes); final String formatDim = getString(R.string.format_dim); @@ -135,12 +144,14 @@ public class GeneralPreferenceFragment extends PreferenceFragment { mTouchActions = (ListPreference)findPreference("ui_touch_action"); mTouchActions.setOnPreferenceChangeListener(mOnChangeListener); + updateTouchActionSummary(mTouchActions.getValue()); mFixAspectRatio = (CheckBoxPreference)findPreference("ui_fix_aspect_ratio"); mFixAspectRatio.setOnPreferenceChangeListener(mOnChangeListener); mTransitionsTypes = (MultiSelectListPreference)findPreference("ui_transition_types"); mTransitionsTypes.setOnPreferenceChangeListener(mOnChangeListener); + updateTransitionTypeSummary(mTransitionsTypes.getValues()); final int[] transitionsIntervals = res.getIntArray(R.array.transitions_intervals_values); mTransitionsInterval = (SeekBarProgressPreference)findPreference("ui_transition_interval"); @@ -155,20 +166,43 @@ public class GeneralPreferenceFragment extends PreferenceFragment { mTransitionsInterval.setOnDisplayProgress(new OnDisplayProgress() { @Override public String onDisplayProgress(int progress) { - if (transitionsIntervals[progress] < 60000) { + int interval = transitionsIntervals[progress]; + if (interval == 0) { + mTransitionsInterval.setFormat(formatDisabled); + return null; + } else if (interval < 60000) { // Seconds mTransitionsInterval.setFormat(formatSeconds); - return String.valueOf(transitionsIntervals[progress] / 1000); + return String.valueOf(interval / 1000); } // Minutes mTransitionsInterval.setFormat(formatMinutes); - return String.valueOf(transitionsIntervals[progress] / 1000 / 60); + return String.valueOf(interval / 1000 / 60); } }); mTransitionsInterval.setOnPreferenceChangeListener(mOnChangeListener); mEffectsTypes = (MultiSelectListPreference)findPreference("ui_effect_types"); mEffectsTypes.setOnPreferenceChangeListener(mOnChangeListener); + updateEffectTypeSummary(mTransitionsTypes.getValues()); + } + + private void updateTouchActionSummary(String value) { + int selectionIndex = mTouchActions.findIndexOfValue(value); + String[] summaries = getResources().getStringArray(R.array.touch_actions_summaries); + mTouchActions.setSummary(getString(R.string.pref_general_touch_action_summary_format, + summaries[selectionIndex])); } + private void updateTransitionTypeSummary(Set<String> selected) { + CharSequence summary = getString(R.string.pref_general_transitions_types_summary_format, + selected.size(), mTransitionsTypes.getEntries().length); + mTransitionsTypes.setSummary(summary); + } + + private void updateEffectTypeSummary(Set<String> selected) { + CharSequence summary = getString(R.string.pref_general_effects_types_summary_format, + selected.size(), mEffectsTypes.getEntries().length); + mEffectsTypes.setSummary(summary); + } } diff --git a/src/org/cyanogenmod/wallpapers/photophase/preferences/LayoutPreferenceFragment.java b/src/org/cyanogenmod/wallpapers/photophase/preferences/LayoutPreferenceFragment.java index 46a55e9..f5326d2 100644 --- a/src/org/cyanogenmod/wallpapers/photophase/preferences/LayoutPreferenceFragment.java +++ b/src/org/cyanogenmod/wallpapers/photophase/preferences/LayoutPreferenceFragment.java @@ -94,6 +94,7 @@ public class LayoutPreferenceFragment extends PreferenceFragment { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + final String formatOnRotation = getString(R.string.format_rotate_only); final String formatSeconds = getString(R.string.format_seconds); final String formatMinutes = getString(R.string.format_minutes); final String formatHours = getString(R.string.format_hours); @@ -128,22 +129,27 @@ public class LayoutPreferenceFragment extends PreferenceFragment { mRandomDispositionsInterval.setOnDisplayProgress(new OnDisplayProgress() { @Override public String onDisplayProgress(int progress) { - if (randomDispositionsIntervals[progress] < 60000) { + int interval = randomDispositionsIntervals[progress]; + if (interval == 0) { + // Disabled + mRandomDispositionsInterval.setFormat(formatOnRotation); + return null; + } else if (interval < 60000) { // Seconds mRandomDispositionsInterval.setFormat(formatSeconds); - return String.valueOf(randomDispositionsIntervals[progress] / 1000); - } else if (randomDispositionsIntervals[progress] < 3600000) { + return String.valueOf(interval / 1000); + } else if (interval < 3600000) { // Minutes mRandomDispositionsInterval.setFormat(formatMinutes); - return String.valueOf(randomDispositionsIntervals[progress] / 1000 / 60); - } else if (randomDispositionsIntervals[progress] < 86400000) { + return String.valueOf(interval / 1000 / 60); + } else if (interval < 86400000) { // Hours mRandomDispositionsInterval.setFormat(formatHours); - return String.valueOf(randomDispositionsIntervals[progress] / 1000 / 60 / 60); + return String.valueOf(interval / 1000 / 60 / 60); } // Days mRandomDispositionsInterval.setFormat(formatDays); - return String.valueOf(randomDispositionsIntervals[progress] / 1000 / 60 / 60 / 24); + return String.valueOf(interval / 1000 / 60 / 60 / 24); } }); mRandomDispositionsInterval.setOnPreferenceChangeListener(mOnChangeListener); @@ -156,4 +162,23 @@ public class LayoutPreferenceFragment extends PreferenceFragment { mLandscapeDisposition = findPreference("ui_disposition_landscape"); mLandscapeDisposition.setEnabled(!Preferences.Layout.isRandomDispositions()); } + + @Override + public void onResume() { + super.onResume(); + + updateArrangementSummary(mPortraitDisposition, + PreferencesProvider.Preferences.Layout.getPortraitDisposition().size(), + R.string.disposition_orientation_portrait); + updateArrangementSummary(mLandscapeDisposition, + PreferencesProvider.Preferences.Layout.getLandscapeDisposition().size(), + R.string.disposition_orientation_landscape); + } + + private void updateArrangementSummary(Preference pref, int count, int orientationLabelResId) { + String orientation = getString(orientationLabelResId); + String summary = getResources().getQuantityString( + R.plurals.pref_disposition_summary_format, count, count, orientation); + pref.setSummary(summary); + } } diff --git a/src/org/cyanogenmod/wallpapers/photophase/preferences/SeekBarProgressPreference.java b/src/org/cyanogenmod/wallpapers/photophase/preferences/SeekBarProgressPreference.java index d1411a7..3f1de6f 100644 --- a/src/org/cyanogenmod/wallpapers/photophase/preferences/SeekBarProgressPreference.java +++ b/src/org/cyanogenmod/wallpapers/photophase/preferences/SeekBarProgressPreference.java @@ -20,6 +20,7 @@ package org.cyanogenmod.wallpapers.photophase.preferences; import android.content.Context; import android.util.AttributeSet; import android.view.View; +import android.widget.SeekBar; import android.widget.TextView; import org.cyanogenmod.wallpapers.photophase.R; @@ -96,7 +97,7 @@ public class SeekBarProgressPreference extends SeekBarPreference { protected void onBindView(View view) { super.onBindView(view); mTextView = (TextView) view.findViewById(R.id.text); - setText(); + setText(getProgress()); } /** @@ -108,18 +109,37 @@ public class SeekBarProgressPreference extends SeekBarPreference { @Override protected void setProgress(int progress, boolean notifyChanged) { super.setProgress(progress, notifyChanged); - setText(); + setText(progress); + } + + /** + * {@inheritDoc} + */ + @Override + public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { + super.onProgressChanged(seekBar, progress, fromUser); + if (fromUser) { + setText(progress); + syncProgress(seekBar); + } + } + + /** + * {@inheritDoc} + */ + @Override + public void onStopTrackingTouch(SeekBar seekBar) { + super.onStopTrackingTouch(seekBar); + setText(getProgress()); } /** * Method that displays the progress value */ - private void setText() { + private void setText(int progress) { if (mTextView != null) { - String value = String.valueOf(getProgress()); - if (mOnDisplayProgress != null) { - value = mOnDisplayProgress.onDisplayProgress(getProgress()); - } + String value = mOnDisplayProgress != null + ? mOnDisplayProgress.onDisplayProgress(progress) : String.valueOf(progress); mTextView.setText(String.format(mFormat, value)); } } |