Merge "Reuse existing temporary wallpaper tiles when selecting same photo." into ub-launcher3-burnaby-polish
This commit is contained in:
@@ -842,12 +842,31 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addTemporaryWallpaperTile(final Uri uri, boolean fromRestore) {
|
private void addTemporaryWallpaperTile(final Uri uri, boolean fromRestore) {
|
||||||
mTempWallpaperTiles.add(uri);
|
// Add a tile for the image picked from Gallery, reusing the existing tile if there is one.
|
||||||
// Add a tile for the image picked from Gallery
|
FrameLayout existingImageThumbnail = null;
|
||||||
final FrameLayout pickedImageThumbnail = (FrameLayout) getLayoutInflater().
|
int indexOfExistingTile = 0;
|
||||||
inflate(R.layout.wallpaper_picker_item, mWallpapersView, false);
|
for (; indexOfExistingTile < mWallpapersView.getChildCount(); indexOfExistingTile++) {
|
||||||
pickedImageThumbnail.setVisibility(View.GONE);
|
FrameLayout thumbnail = (FrameLayout) mWallpapersView.getChildAt(indexOfExistingTile);
|
||||||
mWallpapersView.addView(pickedImageThumbnail, 0);
|
Object tag = thumbNail.getTag();
|
||||||
|
if (tag instanceof UriWallpaperInfo && ((UriWallpaperInfo) tag).mUri.equals(uri)) {
|
||||||
|
existingImageThumbnail = thumbNail;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
final FrameLayout pickedImageThumbnail;
|
||||||
|
if (existingImageThumbnail != null) {
|
||||||
|
pickedImageThumbnail = existingImageThumbnail;
|
||||||
|
// Always move the existing wallpaper to the front so user can see it without scrolling.
|
||||||
|
mWallpapersView.removeViewAt(indexOfExistingTile);
|
||||||
|
mWallpapersView.addView(existingImageThumbnail, 0);
|
||||||
|
} else {
|
||||||
|
// This is the first time this temporary wallpaper has been added
|
||||||
|
pickedImageThumbnail = (FrameLayout) getLayoutInflater()
|
||||||
|
.inflate(R.layout.wallpaper_picker_item, mWallpapersView, false);
|
||||||
|
pickedImageThumbnail.setVisibility(View.GONE);
|
||||||
|
mWallpapersView.addView(pickedImageThumbnail, 0);
|
||||||
|
mTempWallpaperTiles.add(uri);
|
||||||
|
}
|
||||||
|
|
||||||
// Load the thumbnail
|
// Load the thumbnail
|
||||||
final ImageView image = (ImageView) pickedImageThumbnail.findViewById(R.id.wallpaper_image);
|
final ImageView image = (ImageView) pickedImageThumbnail.findViewById(R.id.wallpaper_image);
|
||||||
@@ -857,7 +876,8 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
|
|||||||
protected Bitmap doInBackground(Void...args) {
|
protected Bitmap doInBackground(Void...args) {
|
||||||
try {
|
try {
|
||||||
int rotation = BitmapUtils.getRotationFromExif(context, uri);
|
int rotation = BitmapUtils.getRotationFromExif(context, uri);
|
||||||
return createThumbnail(defaultSize, context, uri, null, null, 0, rotation, false);
|
return createThumbnail(defaultSize, context, uri, null, null, 0, rotation,
|
||||||
|
false);
|
||||||
} catch (SecurityException securityException) {
|
} catch (SecurityException securityException) {
|
||||||
if (isActivityDestroyed()) {
|
if (isActivityDestroyed()) {
|
||||||
// Temporarily granted permissions are revoked when the activity
|
// Temporarily granted permissions are revoked when the activity
|
||||||
|
|||||||
Reference in New Issue
Block a user