Merge "Do not show toast when coming from PreviewFragment" into ub-launcher3-qt-r1-dev
am: 5033f3f3d1
Change-Id: I9c46fdb28886b19bfba774367156ad035b2fe12a
diff --git a/src/com/android/wallpaper/picker/individual/IndividualPickerActivity.java b/src/com/android/wallpaper/picker/individual/IndividualPickerActivity.java
index 24eb535..9b1c53b 100755
--- a/src/com/android/wallpaper/picker/individual/IndividualPickerActivity.java
+++ b/src/com/android/wallpaper/picker/individual/IndividualPickerActivity.java
@@ -41,6 +41,7 @@
import com.android.wallpaper.compat.BuildCompat;
import com.android.wallpaper.model.Category;
import com.android.wallpaper.model.InlinePreviewIntentFactory;
+import com.android.wallpaper.model.LiveWallpaperInfo;
import com.android.wallpaper.model.PickerIntentFactory;
import com.android.wallpaper.model.WallpaperInfo;
import com.android.wallpaper.module.Injector;
@@ -63,6 +64,7 @@
"com.android.wallpaper.category_collection_id";
private static final int PREVIEW_WALLPAPER_REQUEST_CODE = 0;
private static final int NO_BACKUP_IMAGE_WALLPAPER_REQUEST_CODE = 1;
+ private static final int PREVIEW_LIVEWALLPAPER_REQUEST_CODE = 2;
private static final String KEY_CATEGORY_COLLECTION_ID = "key_category_collection_id";
private InlinePreviewIntentFactory mPreviewIntentFactory;
@@ -171,13 +173,16 @@
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
+ boolean shouldShowMessage = false;
switch (requestCode) {
+ case PREVIEW_LIVEWALLPAPER_REQUEST_CODE:
+ shouldShowMessage = true;
case PREVIEW_WALLPAPER_REQUEST_CODE:
if (resultCode == Activity.RESULT_OK) {
mWallpaperPersister.onLiveWallpaperSet();
// The wallpaper was set, so finish this activity with result OK.
- finishWithResultOk();
+ finishWithResultOk(shouldShowMessage);
}
break;
@@ -188,7 +193,7 @@
if ((!BuildCompat.isAtLeastL() || resultCode == Activity.RESULT_OK)
&& mLiveWallpaperStatusChecker.isNoBackupImageWallpaperSet()
&& mCategory.getWallpaperRotationInitializer().startRotation(getApplicationContext())) {
- finishWithResultOk();
+ finishWithResultOk(true);
}
break;
@@ -202,7 +207,9 @@
*/
public void showPreview(WallpaperInfo wallpaperInfo) {
mWallpaperPersister.setWallpaperInfoInPreview(wallpaperInfo);
- wallpaperInfo.showPreview(this, mPreviewIntentFactory, PREVIEW_WALLPAPER_REQUEST_CODE);
+ wallpaperInfo.showPreview(this, mPreviewIntentFactory,
+ wallpaperInfo instanceof LiveWallpaperInfo ? PREVIEW_LIVEWALLPAPER_REQUEST_CODE
+ : PREVIEW_WALLPAPER_REQUEST_CODE);
}
/**
@@ -217,14 +224,15 @@
this, intent, NO_BACKUP_IMAGE_WALLPAPER_REQUEST_CODE);
}
- private void finishWithResultOk() {
- try {
- Toast.makeText(this, R.string.wallpaper_set_successfully_message,
- Toast.LENGTH_SHORT).show();
- } catch (NotFoundException e) {
- Log.e(TAG, "Could not show toast " + e);
+ private void finishWithResultOk(boolean shouldShowMessage) {
+ if (shouldShowMessage) {
+ try {
+ Toast.makeText(this, R.string.wallpaper_set_successfully_message,
+ Toast.LENGTH_SHORT).show();
+ } catch (NotFoundException e) {
+ Log.e(TAG, "Could not show toast " + e);
+ }
}
-
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
setResult(Activity.RESULT_OK);
finish();