OSDN Git Service

Defaulting wallpaper offset to edge of the screen.
authorWinson <winsonc@google.com>
Thu, 28 Jul 2016 02:45:52 +0000 (19:45 -0700)
committerWinson Chung <winsonc@google.com>
Fri, 29 Jul 2016 05:46:09 +0000 (05:46 +0000)
- To match the AOSP launcher which no longer centers the default page,
  we now align the wallpaper to either edge of the screen (depending on
  RTL).  This prevents a jump in the keyguard when starting the device
  due to the wallpaper offset being initialized before Launcher is
  started and can update the offset itself.

Bug: 28795125
Change-Id: Ica96a367157aef696b361601d346774960430fbf

services/core/java/com/android/server/wm/WallpaperController.java
services/core/java/com/android/server/wm/WindowState.java

index 18f97a7..a976b36 100644 (file)
@@ -246,7 +246,10 @@ class WallpaperController {
 
     boolean updateWallpaperOffset(WindowState wallpaperWin, int dw, int dh, boolean sync) {
         boolean rawChanged = false;
-        float wpx = mLastWallpaperX >= 0 ? mLastWallpaperX : 0.5f;
+        // Set the default wallpaper x-offset to either edge of the screen (depending on RTL), to
+        // match the behavior of most Launchers
+        float defaultWallpaperX = wallpaperWin.isRtl() ? 1f : 0f;
+        float wpx = mLastWallpaperX >= 0 ? mLastWallpaperX : defaultWallpaperX;
         float wpxs = mLastWallpaperXStep >= 0 ? mLastWallpaperXStep : -1.0f;
         int availw = wallpaperWin.mFrame.right - wallpaperWin.mFrame.left - dw;
         int offset = availw > 0 ? -(int)(availw * wpx + .5f) : 0;
index 155d8d0..94226ca 100644 (file)
@@ -2939,4 +2939,8 @@ final class WindowState implements WindowManagerPolicy.WindowState {
             return -1;
         }
     }
+
+    public boolean isRtl() {
+        return mMergedConfiguration.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
+    }
 }