diff --git a/res/layout/wallpaper_picker.xml b/res/layout/wallpaper_picker.xml
index 620ce1fa18..c36493d2fe 100644
--- a/res/layout/wallpaper_picker.xml
+++ b/res/layout/wallpaper_picker.xml
@@ -27,11 +27,6 @@
android:id="@+id/cropView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
-
MAX_PREVIEW_SIZE || height > MAX_PREVIEW_SIZE) {
+ width /= 2;
+ height /= 2;
+ }
+ Bitmap b = Bitmap.createBitmap((int) width, (int) height, Bitmap.Config.ARGB_8888);
+ Canvas c = new Canvas(b);
+ mDrawable.setBounds(new Rect(0, 0, (int) width, (int) height));
+ mDrawable.draw(c);
+ c.setBitmap(null);
+ mPreview = new BitmapTexture(b);
+ }
+ return mPreview;
+ }
+
+ @Override
+ public Bitmap getTile(int level, int x, int y, Bitmap bitmap) {
+ int tileSize = getTileSize();
+ if (bitmap == null) {
+ bitmap = Bitmap.createBitmap(tileSize, tileSize, Bitmap.Config.ARGB_8888);
+ }
+ Canvas c = new Canvas(bitmap);
+ Rect bounds = new Rect(0, 0, getImageWidth(), getImageHeight());
+ bounds.offset(-x, -y);
+ mDrawable.setBounds(bounds);
+ mDrawable.draw(c);
+ c.setBitmap(null);
+ return bitmap;
+ }
+}
diff --git a/src/com/android/launcher3/WallpaperPickerActivity.java b/src/com/android/launcher3/WallpaperPickerActivity.java
index 9c6ee6ec0e..c58d660638 100644
--- a/src/com/android/launcher3/WallpaperPickerActivity.java
+++ b/src/com/android/launcher3/WallpaperPickerActivity.java
@@ -90,7 +90,6 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
private LinearLayout mWallpapersView;
private View mWallpaperStrip;
- private ImageView mDefaultWallpaperView;
private ActionMode.Callback mActionModeCallback;
private ActionMode mActionMode;
@@ -134,8 +133,8 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
}
@Override
public void onClick(WallpaperPickerActivity a) {
- a.setCropViewTileSource(
- new BitmapRegionTileSource.UriBitmapSource(a, mUri, 1024), true, false);
+ a.setCropViewTileSource(new BitmapRegionTileSource.UriBitmapSource(
+ a, mUri, BitmapRegionTileSource.MAX_PREVIEW_SIZE), true, false);
}
@Override
public void onSave(final WallpaperPickerActivity a) {
@@ -174,11 +173,11 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
@Override
public void onClick(WallpaperPickerActivity a) {
BitmapRegionTileSource.ResourceBitmapSource bitmapSource =
- new BitmapRegionTileSource.ResourceBitmapSource(mResources, mResId, 1024);
+ new BitmapRegionTileSource.ResourceBitmapSource(
+ mResources, mResId, BitmapRegionTileSource.MAX_PREVIEW_SIZE);
bitmapSource.loadInBackground();
BitmapRegionTileSource source = new BitmapRegionTileSource(a, bitmapSource);
CropView v = a.getCropView();
- a.getDefaultWallpaperView().setVisibility(View.INVISIBLE);
v.setTileSource(source, null);
Point wallpaperSize = WallpaperCropActivity.getDefaultWallpaperSize(
a.getResources(), a.getWindowManager());
@@ -210,15 +209,15 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
}
@Override
public void onClick(WallpaperPickerActivity a) {
- a.getCropView().setTouchEnabled(false);
- ImageView defaultWallpaperView = a.getDefaultWallpaperView();
- defaultWallpaperView.setVisibility(View.VISIBLE);
+ CropView c = a.getCropView();
+
Drawable defaultWallpaper = WallpaperManager.getInstance(a).getBuiltInDrawable(
- defaultWallpaperView.getWidth(), defaultWallpaperView.getHeight(),
- false, 0.5f, 0.5f);
- if (defaultWallpaper != null) {
- defaultWallpaperView.setBackgroundDrawable(defaultWallpaper);
- }
+ c.getWidth(), c.getHeight(), false, 0.5f, 0.5f);
+
+ c.setTileSource(
+ new DrawableTileSource(a, defaultWallpaper, DrawableTileSource.MAX_PREVIEW_SIZE), null);
+ c.setScale(1f);
+ c.setTouchEnabled(false);
}
@Override
public void onSave(WallpaperPickerActivity a) {
@@ -248,7 +247,6 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
setContentView(R.layout.wallpaper_picker);
mCropView = (CropView) findViewById(R.id.cropView);
- mDefaultWallpaperView = (ImageView) findViewById(R.id.defaultWallpaperView);
mWallpaperStrip = findViewById(R.id.wallpaper_strip);
mCropView.setTouchCallback(new CropView.TouchCallback() {
LauncherViewPropertyAnimator mAnim;
@@ -409,7 +407,7 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
// Select the first item; wait for a layout pass so that we initialize the dimensions of
// cropView or the defaultWallpaperView first
- mDefaultWallpaperView.addOnLayoutChangeListener(new OnLayoutChangeListener() {
+ mCropView.addOnLayoutChangeListener(new OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom,
int oldLeft, int oldTop, int oldRight, int oldBottom) {
@@ -530,7 +528,6 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
@Override
public void setCropViewTileSource(final BitmapRegionTileSource.BitmapSource bitmapSource,
final boolean touchEnabled, boolean moveToLeft) {
- getDefaultWallpaperView().setVisibility(View.INVISIBLE);
super.setCropViewTileSource(bitmapSource, touchEnabled, moveToLeft);
}
@@ -899,10 +896,6 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
return mCropView;
}
- public ImageView getDefaultWallpaperView() {
- return mDefaultWallpaperView;
- }
-
public SavedWallpaperImages getSavedImages() {
return mSavedImages;
}
diff --git a/src/com/android/photos/BitmapRegionTileSource.java b/src/com/android/photos/BitmapRegionTileSource.java
index 74284b236f..b5774f40a5 100644
--- a/src/com/android/photos/BitmapRegionTileSource.java
+++ b/src/com/android/photos/BitmapRegionTileSource.java
@@ -55,7 +55,7 @@ public class BitmapRegionTileSource implements TiledImageRenderer.TileSource {
private static final int GL_SIZE_LIMIT = 2048;
// This must be no larger than half the size of the GL_SIZE_LIMIT
// due to decodePreview being allowed to be up to 2x the size of the target
- private static final int MAX_PREVIEW_SIZE = 1024;
+ public static final int MAX_PREVIEW_SIZE = GL_SIZE_LIMIT / 2;
public static abstract class BitmapSource {
private BitmapRegionDecoder mDecoder;