From 394c2e381d9a9cd04f2706e34bf6d3c81e2cbd70 Mon Sep 17 00:00:00 2001 From: Matt Garnes Date: Wed, 13 May 2015 12:16:11 -0700 Subject: Support override to display Wallpaper preview from left edge. Add resource config override to display the preview of preloaded resource wallpapers from the left edge to match how they display when set as the wallpaper. Change-Id: I4aef9e1818ec6942c9b41055b5573308db58a1be --- WallpaperPicker/res/values/config.xml | 1 + .../com/android/launcher3/WallpaperPickerActivity.java | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/WallpaperPicker/res/values/config.xml b/WallpaperPicker/res/values/config.xml index 71580b5b0..43dd5846b 100644 --- a/WallpaperPicker/res/values/config.xml +++ b/WallpaperPicker/res/values/config.xml @@ -18,4 +18,5 @@ false + false diff --git a/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java b/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java index e4fa637bc..27f1a53aa 100755 --- a/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java +++ b/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java @@ -94,6 +94,7 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { private View mSelectedTile; private boolean mIgnoreNextTap; + private boolean mResourcePreviewMoveToLeft = false; private OnClickListener mThumbnailOnClickListener; private LinearLayout mWallpapersView; @@ -231,11 +232,13 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { public static class ResourceWallpaperInfo extends WallpaperTileInfo { private Resources mResources; private int mResId; + private boolean mMoveToLeft; - public ResourceWallpaperInfo(Resources res, int resId, Drawable thumb) { + public ResourceWallpaperInfo(Resources res, int resId, Drawable thumb, boolean moveToLeft) { mResources = res; mResId = resId; mThumb = thumb; + mMoveToLeft = moveToLeft; } @Override public void onClick(WallpaperPickerActivity a) { @@ -254,6 +257,9 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { v.setScale(wallpaperSize.x / crop.width()); v.setTouchEnabled(false); a.setSystemWallpaperVisiblity(false); + if (mMoveToLeft) { + v.moveToLeft(); + } } @Override public void onSave(WallpaperPickerActivity a) { @@ -379,6 +385,9 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { protected void init() { setContentView(R.layout.wallpaper_picker); + mResourcePreviewMoveToLeft = + getResources().getBoolean(R.bool.resource_wallpaper_preview_left_edge); + mCropView = (CropView) findViewById(R.id.cropView); mCropView.setVisibility(View.INVISIBLE); @@ -1089,7 +1098,8 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { } } if (defaultWallpaperExists) { - return new ResourceWallpaperInfo(sysRes, resId, new BitmapDrawable(thumb)); + return new ResourceWallpaperInfo(sysRes, resId, + new BitmapDrawable(thumb), mResourcePreviewMoveToLeft); } return null; } @@ -1151,7 +1161,8 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { if (thumbRes != 0) { ResourceWallpaperInfo wallpaperInfo = - new ResourceWallpaperInfo(res, resId, res.getDrawable(thumbRes)); + new ResourceWallpaperInfo(res, resId, + res.getDrawable(thumbRes), mResourcePreviewMoveToLeft); known.add(wallpaperInfo); // Log.d(TAG, "add: [" + packageName + "]: " + extra + " (" + res + ")"); } -- cgit v1.2.3