Permalink
Browse files

Preferences: Scroll Wallpaper

Change-Id: I92fc0fef3d2efd956923e85c5a264f42cbad524b
  • Loading branch information...
1 parent 4d59354 commit c9193eb9bd83c43a56053d27e3b493ecb7f766d9 nebkat committed with preludedrew Apr 16, 2012
@@ -271,7 +271,8 @@ s -->
<string name="preferences_interface_homescreen_general_category">General</string>
<string name="preferences_interface_homescreen_general_search_title">Search Bar</string>
<string name="preferences_interface_homescreen_general_search_summary">Enable persistent search bar</string>
-
+ <string name="preferences_interface_homescreen_scrolling_scroll_wallpaper_title">Scroll wallpaper</string>
+ <string name="preferences_interface_homescreen_scrolling_scroll_wallpaper_summary">Scroll wallpaper when scrolling homescreens</string>
<!-- Drawer -->
<string name="preferences_interface_drawer_title">Drawer</string>
@@ -26,6 +26,10 @@
android:summary="@string/preferences_interface_homescreen_general_search_summary"
android:defaultValue="false" />
</PreferenceCategory>
+ <CheckBoxPreference android:key="ui_homescreen_scrolling_scroll_wallpaper"
+ android:title="@string/preferences_interface_homescreen_scrolling_scroll_wallpaper_title"
+ android:summary="@string/preferences_interface_homescreen_scrolling_scroll_wallpaper_summary"
+ android:defaultValue="true" />
</PreferenceScreen>
<!-- Drawer -->
@@ -241,6 +241,7 @@
// Preferences
private boolean mShowSearchBar;
+ private boolean mScrollWallpaper;
/**
* Used to inflate the Workspace from XML.
@@ -315,6 +316,7 @@ public Workspace(Context context, AttributeSet attrs, int defStyle) {
// Preferences
mShowSearchBar = PreferencesProvider.Interface.Homescreen.getShowSearchBar(context);
+ mScrollWallpaper = PreferencesProvider.Interface.Homescreen.getScrollWallpaper(context);
mLauncher = (Launcher) context;
initWorkspace();
@@ -420,24 +422,23 @@ public void onAnimationStart(Animator animation) {
@Override
public void onAnimationEnd(Animator animation) {
mIsSwitchingState = false;
- mWallpaperOffset.setOverrideHorizontalCatchupConstant(false);
+ if (mScrollWallpaper) {
+ mWallpaperOffset.setOverrideHorizontalCatchupConstant(false);
+ }
mAnimator = null;
updateChildrenLayersEnabled();
}
};
mSnapVelocity = 600;
- mWallpaperOffset = new WallpaperOffsetInterpolator();
Display display = mLauncher.getWindowManager().getDefaultDisplay();
mDisplayWidth = display.getWidth();
mDisplayHeight = display.getHeight();
- mWallpaperTravelWidth = (int) (mDisplayWidth *
- wallpaperTravelToScreenWidthRatio(mDisplayWidth, mDisplayHeight));
- }
-
- @Override
- protected int getScrollMode() {
- return SmoothPagedView.X_LARGE_MODE;
+ if (mScrollWallpaper) {
+ mWallpaperOffset = new WallpaperOffsetInterpolator();
+ mWallpaperTravelWidth = (int) (mDisplayWidth *
+ wallpaperTravelToScreenWidthRatio(mDisplayWidth, mDisplayHeight));
+ }
}
@Override
@@ -850,6 +851,11 @@ private void syncWallpaperOffsetWithScroll() {
}
}
+ private void centerWallpaperOffset() {
+ mWallpaperManager.setWallpaperOffsetSteps(0.5f, 0);
+ mWallpaperManager.setWallpaperOffsets(getWindowToken(), 0.5f, 0);
+ }
+
public void updateWallpaperOffsetImmediately() {
mUpdateWallpaperOffsetImmediately = true;
}
@@ -879,13 +885,17 @@ private void updateWallpaperOffsets() {
@Override
protected void updateCurrentPageScroll() {
super.updateCurrentPageScroll();
- computeWallpaperScrollRatio(mCurrentPage);
+ if (mScrollWallpaper) {
+ computeWallpaperScrollRatio(mCurrentPage);
+ }
}
@Override
protected void snapToPage(int whichPage) {
super.snapToPage(whichPage);
- computeWallpaperScrollRatio(whichPage);
+ if (mScrollWallpaper) {
+ computeWallpaperScrollRatio(whichPage);
+ }
}
private void computeWallpaperScrollRatio(int page) {
@@ -1018,7 +1028,9 @@ public void jumpToFinal() {
@Override
public void computeScroll() {
super.computeScroll();
- syncWallpaperOffsetWithScroll();
+ if (mScrollWallpaper) {
+ syncWallpaperOffsetWithScroll();
+ }
}
void showOutlines() {
@@ -1280,7 +1292,9 @@ public void run() {
@Override
protected void onDraw(Canvas canvas) {
- updateWallpaperOffsets();
+ if (mScrollWallpaper) {
+ updateWallpaperOffsets();
+ }
// Draw the background gradient if necessary
if (mBackground != null && mBackgroundAlpha > 0.0f && mDrawBackground) {
@@ -3151,6 +3165,9 @@ void setup(DragController dragController) {
// needed
updateChildrenLayersEnabled();
setWallpaperDimension();
+ if (!mScrollWallpaper) {
+ centerWallpaperOffset();
+ }
}
/**
@@ -14,6 +14,10 @@ public static boolean getShowSearchBar(Context context) {
final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
return preferences.getBoolean("ui_homescreen_general_search", false);
}
+ public static boolean getScrollWallpaper(Context context) {
+ final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
+ return preferences.getBoolean("ui_homescreen_scrolling_scroll_wallpaper", true);
+ }
}
public static class Drawer {

0 comments on commit c9193eb

Please sign in to comment.