summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSantiago Etchebehere <santie@google.com>2019-05-23 16:53:43 -0700
committerSantiago Etchebehere <santie@google.com>2019-05-23 16:53:45 -0700
commit8c18e6d5889ec2a1a55d0ddbaa66ad0cf27e436f (patch)
tree9a8b8fa7d0da034f164eb99bc3daf3740d1d4146 /src
parent943fe40429b8df359baa8e8eb133e52e35973e69 (diff)
downloadandroid_packages_apps_WallpaperPicker2-8c18e6d5889ec2a1a55d0ddbaa66ad0cf27e436f.tar.gz
android_packages_apps_WallpaperPicker2-8c18e6d5889ec2a1a55d0ddbaa66ad0cf27e436f.tar.bz2
android_packages_apps_WallpaperPicker2-8c18e6d5889ec2a1a55d0ddbaa66ad0cf27e436f.zip
Do not show toast when coming from PreviewFragment
TopLevelPickerActivity shows a Toast to confirm wallpaper has been set successfully, and PreviewFragment also shows it (as it could be called from other, Activities). So in TopLevelPickerActivity, when coming from PreviewFragment, we don't want to show the Toast as it was already shown once. Fixes: 123589179 Change-Id: I218e743e7873c13e42d7018a54c2fc4099569de5
Diffstat (limited to 'src')
-rwxr-xr-xsrc/com/android/wallpaper/picker/individual/IndividualPickerActivity.java28
1 files changed, 18 insertions, 10 deletions
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.R;
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 @@ public class IndividualPickerActivity extends BaseActivity {
"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 class IndividualPickerActivity extends BaseActivity {
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 @@ public class IndividualPickerActivity extends BaseActivity {
if ((!BuildCompat.isAtLeastL() || resultCode == Activity.RESULT_OK)
&& mLiveWallpaperStatusChecker.isNoBackupImageWallpaperSet()
&& mCategory.getWallpaperRotationInitializer().startRotation(getApplicationContext())) {
- finishWithResultOk();
+ finishWithResultOk(true);
}
break;
@@ -202,7 +207,9 @@ public class IndividualPickerActivity extends BaseActivity {
*/
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 @@ public class IndividualPickerActivity extends BaseActivity {
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();