diff options
-rw-r--r-- | res/values/strings.xml | 2 | ||||
-rw-r--r-- | res/xml/preferences.xml | 5 | ||||
-rw-r--r-- | src/com/cyanogenmod/trebuchet/PagedView.java | 13 | ||||
-rw-r--r-- | src/com/cyanogenmod/trebuchet/Workspace.java | 17 | ||||
-rw-r--r-- | src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java | 4 |
5 files changed, 37 insertions, 4 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml index f4e1b8c..e00fc7c 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -312,6 +312,8 @@ s --> <string name="preferences_interface_homescreen_indicator_category">Indicator</string> <string name="preferences_interface_homescreen_indicator_enable_title">Show Page Indicator</string> <string name="preferences_interface_homescreen_indicator_enable_summary">Show current page indicator at the bottom of the screen</string> + <string name="preferences_interface_homescreen_indicator_fade_title">Fade Indicator</string> + <string name="preferences_interface_homescreen_indicator_fade_summary">Fade the indicator after the homescreen has changed</string> <!-- Drawer --> <string name="preferences_interface_drawer_title">Drawer</string> diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml index a39c434..030b250 100644 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@ -65,6 +65,11 @@ android:title="@string/preferences_interface_homescreen_indicator_enable_title" android:summary="@string/preferences_interface_homescreen_indicator_enable_summary" android:defaultValue="true" /> + <CheckBoxPreference android:key="ui_homescreen_indicator_fade" + android:title="@string/preferences_interface_homescreen_indicator_fade_title" + android:summary="@string/preferences_interface_homescreen_indicator_fade_summary" + android:defaultValue="true" + android:dependency="ui_homescreen_indicator_enable" /> </PreferenceCategory> </PreferenceScreen> diff --git a/src/com/cyanogenmod/trebuchet/PagedView.java b/src/com/cyanogenmod/trebuchet/PagedView.java index d7ea517..0e744d6 100644 --- a/src/com/cyanogenmod/trebuchet/PagedView.java +++ b/src/com/cyanogenmod/trebuchet/PagedView.java @@ -181,6 +181,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc private boolean mShouldShowScrollIndicatorImmediately = false; protected static final int sScrollIndicatorFadeInDuration = 150; protected static final int sScrollIndicatorFadeOutDuration = 650; + protected static final int sScrollIndicatorFadeOutShortDuration = 150; protected static final int sScrollIndicatorFlashDuration = 650; private boolean mScrollingPaused = false; @@ -1752,6 +1753,10 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc } protected void showScrollingIndicator(boolean immediately) { + showScrollingIndicator(immediately, sScrollIndicatorFadeInDuration); + } + + protected void showScrollingIndicator(boolean immediately, int duration) { mShouldShowScrollIndicator = true; mShouldShowScrollIndicatorImmediately = true; if (getChildCount() <= 1) return; @@ -1768,7 +1773,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc mScrollIndicator.setAlpha(1f); } else { mScrollIndicatorAnimator = LauncherAnimUtils.ofFloat(mScrollIndicator, "alpha", 1f); - mScrollIndicatorAnimator.setDuration(sScrollIndicatorFadeInDuration); + mScrollIndicatorAnimator.setDuration(duration); mScrollIndicatorAnimator.start(); } } @@ -1781,6 +1786,10 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc } protected void hideScrollingIndicator(boolean immediately) { + hideScrollingIndicator(immediately, sScrollIndicatorFadeOutDuration); + } + + protected void hideScrollingIndicator(boolean immediately, int duration) { if (getChildCount() <= 1) return; if (!isScrollingIndicatorEnabled()) return; @@ -1794,7 +1803,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc mScrollIndicator.setAlpha(0f); } else { mScrollIndicatorAnimator = LauncherAnimUtils.ofFloat(mScrollIndicator, "alpha", 0f); - mScrollIndicatorAnimator.setDuration(sScrollIndicatorFadeOutDuration); + mScrollIndicatorAnimator.setDuration(duration); mScrollIndicatorAnimator.addListener(new AnimatorListenerAdapter() { private boolean cancelled = false; @Override diff --git a/src/com/cyanogenmod/trebuchet/Workspace.java b/src/com/cyanogenmod/trebuchet/Workspace.java index b355bc6..692c608 100644 --- a/src/com/cyanogenmod/trebuchet/Workspace.java +++ b/src/com/cyanogenmod/trebuchet/Workspace.java @@ -269,6 +269,7 @@ public class Workspace extends SmoothPagedView private boolean mResizeAnyWidget; private boolean mScrollWallpaper; private boolean mShowScrollingIndicator; + private boolean mFadeScrollingIndicator; /** * Used to inflate the Workspace from XML. @@ -347,6 +348,7 @@ public class Workspace extends SmoothPagedView mResizeAnyWidget = PreferencesProvider.Interface.Homescreen.getResizeAnyWidget(context); mScrollWallpaper = PreferencesProvider.Interface.Homescreen.getScrollWallpaper(context); mShowScrollingIndicator = PreferencesProvider.Interface.Homescreen.getShowScrollingIndicator(context); + mFadeScrollingIndicator = PreferencesProvider.Interface.Homescreen.getFadeScrollingIndicator(context); initWorkspace(); @@ -816,7 +818,9 @@ public class Workspace extends SmoothPagedView } protected void onPageEndMoving() { - super.onPageEndMoving(); + if (mFadeScrollingIndicator) { + hideScrollingIndicator(false); + } if (isHardwareAccelerated()) { updateChildrenLayersEnabled(false); @@ -838,7 +842,7 @@ public class Workspace extends SmoothPagedView } // Hide the scroll indicator as you pan the page - if (!mDragController.isDragging()) { + if (mFadeScrollingIndicator && !mDragController.isDragging()) { hideScrollingIndicator(false); } } @@ -861,6 +865,15 @@ public class Workspace extends SmoothPagedView Launcher.setScreen(mCurrentPage); }; + @Override + protected void flashScrollingIndicator(boolean animated) { + if (mFadeScrollingIndicator) { + super.flashScrollingIndicator(animated); + } else { + showScrollingIndicator(true); + } + } + // As a ratio of screen height, the total distance we want the parallax effect to span // horizontally private float wallpaperTravelToScreenWidthRatio(int width, int height) { diff --git a/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java b/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java index ff7b29d..50ca006 100644 --- a/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java +++ b/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java @@ -67,6 +67,10 @@ public final class PreferencesProvider { final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0); return preferences.getBoolean("ui_homescreen_indicator_enable", true); } + public static boolean getFadeScrollingIndicator(Context context) { + final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0); + return preferences.getBoolean("ui_homescreen_indicator_fade", true); + } } public static class Drawer { |