1. 程式人生 > >Android系統完整顯示桌布, 不做X2拉伸處理

Android系統完整顯示桌布, 不做X2拉伸處理

Android系統內建牆紙尺寸跟螢幕尺寸相同, 全尺寸完整顯示桌布, 不做X2拉伸處理:

packages\apps\Launcher3\src\com\android\launcher3\util\WallpaperUtils.java

@@ -24,6 +24,9 @@ import android.graphics.Point;
 import android.os.Build;
 import android.view.WindowManager;
 
+// lds add for fix wallpaper size same as lcm screen size at 20160530
+import android.os.SystemProperties;
+
 import com.android.launcher3.Utilities;
 
 /**
@@ -100,22 +103,43 @@ public final class WallpaperUtils {
 
             int maxDim = Math.max(maxDims.x, maxDims.y);
             int minDim = Math.max(minDims.x, minDims.y);
+                       
+                       // lds add for fix wallpaper size same as lcm screen size at 20160530
+                       int realWith = minDim;
 
             if (Utilities.ATLEAST_JB_MR1) {
                 Point realSize = new Point();
                 windowManager.getDefaultDisplay().getRealSize(realSize);
                 maxDim = Math.max(realSize.x, realSize.y);
                 minDim = Math.min(realSize.x, realSize.y);
+                               
+                               // lds add for fix wallpaper size same as lcm screen size at 20160530
+                               if(SystemProperties.get("ro.wallpaper.same.phonescreen").equals("1")){
+                                       realWith = realSize.x;
+                               }
+                               // add end
             }
 
             // We need to ensure that there is enough extra space in the wallpaper
             // for the intended parallax effects
             final int defaultWidth, defaultHeight;
             if (res.getConfiguration().smallestScreenWidthDp >= 720) {
-                defaultWidth = (int) (maxDim * wallpaperTravelToScreenWidthRatio(maxDim, minDim));
+                               // lds add for fix wallpaper size same as lcm screen size at 20160530
+                               if(SystemProperties.get("ro.wallpaper.same.phonescreen").equals("1")){
+                                       defaultWidth = realWith;
+                               } else {
+                                       defaultWidth = (int) (maxDim * wallpaperTravelToScreenWidthRatio(maxDim, minDim));
+                               }
+                               // add end
                 defaultHeight = maxDim;
             } else {
-                defaultWidth = Math.max((int) (minDim * WALLPAPER_SCREENS_SPAN), maxDim);
+                               // lds add for fix wallpaper size same as lcm screen size at 20160530
+                               if(SystemProperties.get("ro.wallpaper.same.phonescreen").equals("1")){
+                                       defaultWidth = realWith;
+                               } else {
+                                       defaultWidth = Math.max((int) (minDim * WALLPAPER_SCREENS_SPAN), maxDim);
+                               }
+                               // add end
                 defaultHeight = maxDim;
             }
             sDefaultWallpaperSize = new Point(defaultWidth, defaultHeight);