diff options
author | Jorge Ruesga <jorge@ruesga.com> | 2013-08-08 18:34:50 +0200 |
---|---|---|
committer | Jorge Ruesga <jorge@ruesga.com> | 2013-08-08 18:34:50 +0200 |
commit | b60b176524fa7862d1c0faba15a36d34124fadc7 (patch) | |
tree | 239c368dbf46d5729a0c79ff6e741e334c94c656 /src/org/cyanogenmod/wallpapers/photophase/preferences | |
parent | aa4f1a103313b9f30b4c0c146ad9d9f1259e9b1a (diff) | |
download | android_packages_wallpapers_PhotoPhase-b60b176524fa7862d1c0faba15a36d34124fadc7.tar.gz android_packages_wallpapers_PhotoPhase-b60b176524fa7862d1c0faba15a36d34124fadc7.tar.bz2 android_packages_wallpapers_PhotoPhase-b60b176524fa7862d1c0faba15a36d34124fadc7.zip |
Aspect ratio correction (settings) (#14)
Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
Diffstat (limited to 'src/org/cyanogenmod/wallpapers/photophase/preferences')
4 files changed, 85 insertions, 1 deletions
diff --git a/src/org/cyanogenmod/wallpapers/photophase/preferences/AspectRatioCorrection.java b/src/org/cyanogenmod/wallpapers/photophase/preferences/AspectRatioCorrection.java new file mode 100644 index 0000000..e3732f8 --- /dev/null +++ b/src/org/cyanogenmod/wallpapers/photophase/preferences/AspectRatioCorrection.java @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2013 The CyanogenMod Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.cyanogenmod.wallpapers.photophase.preferences; + +/** + * An enumeration with all the touch actions supported + */ +public enum AspectRatioCorrection { + /** + * Do not apply aspect ratio correction + */ + NONE(0), + /** + * Center the image and crop the image using the shortest size of the image + */ + CROP(1), + /** + * Center using the largest size of the image + */ + CENTER(2); + + private final int mValue; + + /** + * Constructor of <code>AspectRatioCorrection</code> + * + * @param id The unique identifier + */ + private AspectRatioCorrection(int value) { + mValue = value; + } + + /** + * Method that returns the value + * + * @return int The value + */ + public int getValue() { + return mValue; + } + + /** + * Method that gets the reference of a AspectRatioCorrection from its value + * + * @param value The value + * @return AspectRatioCorrection The reference + */ + public static final AspectRatioCorrection fromValue(int value) { + if (value == CROP.mValue) return CROP; + if (value == CENTER.mValue) return CENTER; + return NONE; + } +} diff --git a/src/org/cyanogenmod/wallpapers/photophase/preferences/GeneralPreferenceFragment.java b/src/org/cyanogenmod/wallpapers/photophase/preferences/GeneralPreferenceFragment.java index edf4880..b495757 100644 --- a/src/org/cyanogenmod/wallpapers/photophase/preferences/GeneralPreferenceFragment.java +++ b/src/org/cyanogenmod/wallpapers/photophase/preferences/GeneralPreferenceFragment.java @@ -46,6 +46,7 @@ public class GeneralPreferenceFragment extends PreferenceFragment { private SeekBarProgressPreference mWallpaperDim; private ColorPickerPreference mBackgroundColor; private ListPreference mTouchActions; + private ListPreference mAspectRatioCorrection; private MultiSelectListPreference mTransitionsTypes; private SeekBarProgressPreference mTransitionsInterval; private MultiSelectListPreference mEffectsTypes; @@ -64,6 +65,8 @@ public class GeneralPreferenceFragment extends PreferenceFragment { mRedrawFlag = true; int color = ((Integer)newValue).intValue(); Colors.setBackground(new GLColor(color)); + } else if (key.compareTo("ui_aspect_ratio_correction") == 0) { + mRedrawFlag = true; } else if (key.compareTo("ui_transition_types") == 0) { mRedrawFlag = true; } else if (key.compareTo("ui_transition_interval") == 0) { @@ -125,6 +128,9 @@ public class GeneralPreferenceFragment extends PreferenceFragment { mTouchActions = (ListPreference)findPreference("ui_touch_action"); mTouchActions.setOnPreferenceChangeListener(mOnChangeListener); + mAspectRatioCorrection = (ListPreference)findPreference("ui_aspect_ratio_correction"); + mAspectRatioCorrection.setOnPreferenceChangeListener(mOnChangeListener); + mTransitionsTypes = (MultiSelectListPreference)findPreference("ui_transition_types"); mTransitionsTypes.setOnPreferenceChangeListener(mOnChangeListener); diff --git a/src/org/cyanogenmod/wallpapers/photophase/preferences/PreferencesProvider.java b/src/org/cyanogenmod/wallpapers/photophase/preferences/PreferencesProvider.java index 78d3686..fd4b172 100644 --- a/src/org/cyanogenmod/wallpapers/photophase/preferences/PreferencesProvider.java +++ b/src/org/cyanogenmod/wallpapers/photophase/preferences/PreferencesProvider.java @@ -197,6 +197,17 @@ public final class PreferencesProvider { } /** + * Return the current user preference about how to fix the aspect ratio of + * the current image of the frame. + * + * @return AspectRatioCorrection The correction mode (default NONE) + */ + public static AspectRatioCorrection getAspectRatioCorrection() { + return AspectRatioCorrection.fromValue( + Integer.valueOf(getString("ui_aspect_ratio_correction", "0"))) ; + } + + /** * Transitions preferences */ public static class Transitions { diff --git a/src/org/cyanogenmod/wallpapers/photophase/preferences/TouchAction.java b/src/org/cyanogenmod/wallpapers/photophase/preferences/TouchAction.java index 792b8d1..498c1bd 100644 --- a/src/org/cyanogenmod/wallpapers/photophase/preferences/TouchAction.java +++ b/src/org/cyanogenmod/wallpapers/photophase/preferences/TouchAction.java @@ -33,7 +33,7 @@ public enum TouchAction { */ OPEN(2), /** - * Share/send the picture of the frame + * Share/send the picture of the frame */ SHARE(3); |