diff options
Diffstat (limited to 'src')
4 files changed, 98 insertions, 19 deletions
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)); } } |