From fddef4634cb3b06c85662c24ffa33026d1348d54 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Thu, 12 Feb 2015 09:51:48 -0800 Subject: Fixing logic to determine if wallpaper change. > Current logic to determine if livewallpaper changed returns true all the time > Use returnCode passed by the calling activity. Change-Id: Ida800a90451b1f7d368234e1a7e10938dcf2f6f7 --- .../launcher3/LiveWallpaperListAdapter.java | 4 ++-- .../android/launcher3/WallpaperPickerActivity.java | 28 ++-------------------- 2 files changed, 4 insertions(+), 28 deletions(-) (limited to 'WallpaperPicker') diff --git a/WallpaperPicker/src/com/android/launcher3/LiveWallpaperListAdapter.java b/WallpaperPicker/src/com/android/launcher3/LiveWallpaperListAdapter.java index 88f4461bf..0a9050cff 100644 --- a/WallpaperPicker/src/com/android/launcher3/LiveWallpaperListAdapter.java +++ b/WallpaperPicker/src/com/android/launcher3/LiveWallpaperListAdapter.java @@ -122,8 +122,8 @@ public class LiveWallpaperListAdapter extends BaseAdapter implements ListAdapter Intent preview = new Intent(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER); preview.putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT, mInfo.getComponent()); - a.onLiveWallpaperPickerLaunch(mInfo); - a.startActivityForResultSafely(preview, WallpaperPickerActivity.PICK_LIVE_WALLPAPER); + a.startActivityForResultSafely(preview, + WallpaperPickerActivity.PICK_WALLPAPER_THIRD_PARTY_ACTIVITY); } } diff --git a/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java b/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java index 09e096396..4ad7b6a6b 100644 --- a/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java +++ b/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java @@ -20,7 +20,6 @@ import android.animation.LayoutTransition; import android.annotation.TargetApi; import android.app.ActionBar; import android.app.Activity; -import android.app.WallpaperInfo; import android.app.WallpaperManager; import android.content.Context; import android.content.Intent; @@ -83,7 +82,6 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { public static final int IMAGE_PICK = 5; public static final int PICK_WALLPAPER_THIRD_PARTY_ACTIVITY = 6; - public static final int PICK_LIVE_WALLPAPER = 7; private static final String TEMP_WALLPAPER_TILES = "TEMP_WALLPAPER_TILES"; private static final String SELECTED_INDEX = "SELECTED_INDEX"; private static final int FLAG_POST_DELAY_MILLIS = 200; @@ -102,9 +100,7 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { ArrayList mTempWallpaperTiles = new ArrayList(); private SavedWallpaperImages mSavedImages; - private WallpaperInfo mLiveWallpaperInfoOnPickerLaunch; private int mSelectedIndex = -1; - private WallpaperInfo mLastClickedLiveWallpaperInfo; public static abstract class WallpaperTileInfo { protected View mView; @@ -885,25 +881,10 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { Uri uri = data.getData(); addTemporaryWallpaperTile(uri, false); } - } else if (requestCode == PICK_WALLPAPER_THIRD_PARTY_ACTIVITY) { + } else if (requestCode == PICK_WALLPAPER_THIRD_PARTY_ACTIVITY && resultCode == RESULT_OK) { + // Something was set on the third-party activity. setResult(RESULT_OK); finish(); - } else if (requestCode == PICK_LIVE_WALLPAPER) { - WallpaperManager wm = WallpaperManager.getInstance(this); - final WallpaperInfo oldLiveWallpaper = mLiveWallpaperInfoOnPickerLaunch; - final WallpaperInfo clickedWallpaper = mLastClickedLiveWallpaperInfo; - WallpaperInfo newLiveWallpaper = wm.getWallpaperInfo(); - // Try to figure out if a live wallpaper was set; - if (newLiveWallpaper != null && - (oldLiveWallpaper == null - || !oldLiveWallpaper.getComponent() - .equals(newLiveWallpaper.getComponent()) - || clickedWallpaper.getComponent() - .equals(oldLiveWallpaper.getComponent()))) { - // Return if a live wallpaper was set - setResult(RESULT_OK); - finish(); - } } } @@ -1110,11 +1091,6 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { return mSavedImages; } - public void onLiveWallpaperPickerLaunch(WallpaperInfo info) { - mLastClickedLiveWallpaperInfo = info; - mLiveWallpaperInfoOnPickerLaunch = WallpaperManager.getInstance(this).getWallpaperInfo(); - } - static class ZeroPaddingDrawable extends LevelListDrawable { public ZeroPaddingDrawable(Drawable d) { super(); -- cgit v1.2.3