diff options
-rw-r--r-- | res/values/strings.xml | 2 | ||||
-rw-r--r-- | res/xml/preferences.xml | 5 | ||||
-rw-r--r-- | src/com/android/launcher2/Launcher.java | 1 | ||||
-rw-r--r-- | src/com/android/launcher2/PagedView.java | 13 | ||||
-rw-r--r-- | src/com/android/launcher2/Workspace.java | 17 | ||||
-rw-r--r-- | src/com/android/launcher2/preference/PreferencesProvider.java | 4 |
6 files changed, 37 insertions, 5 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml index 209e3d123..f2991d42c 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -260,6 +260,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 22094f082..cb20f50ed 100644 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@ -34,6 +34,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/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index aaa479b04..585b8eeff 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -2410,7 +2410,6 @@ public final class Launcher extends Activity ((LauncherTransitionable) fromView).onLauncherTransitionEnd(instance, alphaAnim, true); } - mWorkspace.hideScrollingIndicator(false); } }); diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java index 5c1419198..0f78e5630 100644 --- a/src/com/android/launcher2/PagedView.java +++ b/src/com/android/launcher2/PagedView.java @@ -173,6 +173,7 @@ public abstract class PagedView extends ViewGroup { private boolean mHasScrollIndicator = true; protected static final int sScrollIndicatorFadeInDuration = 150; protected static final int sScrollIndicatorFadeOutDuration = 650; + protected static final int sScrollIndicatorFadeOutShortDuration = 150; protected static final int sScrollIndicatorFlashDuration = 650; // If set, will defer loading associated pages until the scrolling settles @@ -1765,6 +1766,10 @@ public abstract class PagedView extends ViewGroup { } protected void showScrollingIndicator(boolean immediately) { + showScrollingIndicator(immediately, sScrollIndicatorFadeInDuration); + } + + protected void showScrollingIndicator(boolean immediately, int duration) { if (getChildCount() <= 1) return; if (!isScrollingIndicatorEnabled()) return; @@ -1780,13 +1785,17 @@ public abstract class PagedView extends ViewGroup { mScrollIndicator.setAlpha(1f); } else { mScrollIndicatorAnimator = ObjectAnimator.ofFloat(mScrollIndicator, "alpha", 1f); - mScrollIndicatorAnimator.setDuration(sScrollIndicatorFadeInDuration); + mScrollIndicatorAnimator.setDuration(duration); mScrollIndicatorAnimator.start(); } } } protected void hideScrollingIndicator(boolean immediately) { + hideScrollingIndicator(immediately, sScrollIndicatorFadeOutDuration); + } + + protected void hideScrollingIndicator(boolean immediately, int duration) { if (getChildCount() <= 1) return; if (!isScrollingIndicatorEnabled()) return; @@ -1802,7 +1811,7 @@ public abstract class PagedView extends ViewGroup { mScrollIndicator.setAlpha(0f); } else { mScrollIndicatorAnimator = ObjectAnimator.ofFloat(mScrollIndicator, "alpha", 0f); - mScrollIndicatorAnimator.setDuration(sScrollIndicatorFadeOutDuration); + mScrollIndicatorAnimator.setDuration(duration); mScrollIndicatorAnimator.addListener(new AnimatorListenerAdapter() { private boolean cancelled = false; @Override diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index 5313cd985..a5e34edef 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -242,6 +242,7 @@ public class Workspace extends SmoothPagedView private boolean mShowSearchBar; private boolean mResizeAnyWidget; private boolean mShowScrollingIndicator; + private boolean mFadeScrollingIndicator; /** * Used to inflate the Workspace from XML. @@ -318,6 +319,7 @@ public class Workspace extends SmoothPagedView mShowSearchBar = PreferencesProvider.Interface.Homescreen.getShowSearchBar(context); mResizeAnyWidget = PreferencesProvider.Interface.Homescreen.getResizeAnyWidget(context); mShowScrollingIndicator = PreferencesProvider.Interface.Homescreen.getShowScrollingIndicator(context); + mFadeScrollingIndicator = PreferencesProvider.Interface.Homescreen.getFadeScrollingIndicator(context); mLauncher = (Launcher) context; initWorkspace(); @@ -686,7 +688,9 @@ public class Workspace extends SmoothPagedView } protected void onPageEndMoving() { - super.onPageEndMoving(); + if (mFadeScrollingIndicator) { + hideScrollingIndicator(false); + } if (isHardwareAccelerated()) { updateChildrenLayersEnabled(); @@ -716,6 +720,15 @@ public class Workspace extends SmoothPagedView Launcher.setScreen(mCurrentPage); }; + @Override + protected void flashScrollingIndicator() { + if (mFadeScrollingIndicator) { + super.flashScrollingIndicator(); + } else { + showScrollingIndicator(true); + } + } + // As a ratio of screen height, the total distance we want the parallax effect to span // vertically private float wallpaperTravelToScreenHeightRatio(int width, int height) { @@ -1595,7 +1608,7 @@ public class Workspace extends SmoothPagedView if (oldState == State.NORMAL && state == State.SMALL) { zoomIn = false; if (animated) { - hideScrollingIndicator(true); + hideScrollingIndicator(false, sScrollIndicatorFadeOutShortDuration); } setLayoutScale(finalScaleFactor); updateChildrenLayersEnabled(); diff --git a/src/com/android/launcher2/preference/PreferencesProvider.java b/src/com/android/launcher2/preference/PreferencesProvider.java index 20d3d832c..c28979b84 100644 --- a/src/com/android/launcher2/preference/PreferencesProvider.java +++ b/src/com/android/launcher2/preference/PreferencesProvider.java @@ -22,6 +22,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 { |