summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXin Li <delphij@google.com>2017-11-13 14:35:49 -0800
committerXin Li <delphij@google.com>2017-11-13 14:35:49 -0800
commit8d52073f686540219842e433c559ea2e7fa7cb38 (patch)
tree8e9e08d4247f0ed38e03ed24df198d9ad97d3c8a
parent8a85d46930ad6c9e63b03957ff68db9c2619bf9e (diff)
parent09e2eb749f4bf71d13cdc07ee35c5c52991d87c0 (diff)
downloadandroid_packages_wallpapers_LivePicker-8d52073f686540219842e433c559ea2e7fa7cb38.tar.gz
android_packages_wallpapers_LivePicker-8d52073f686540219842e433c559ea2e7fa7cb38.tar.bz2
android_packages_wallpapers_LivePicker-8d52073f686540219842e433c559ea2e7fa7cb38.zip
Merge commit '09e2eb749f4bf71d13cdc07ee35c5c52991d87c0' into HEAD
Change-Id: I5c5945d72d09f803a97554c1fd6114e6d51f498f
-rw-r--r--src/com/android/wallpaper/livepicker/LiveWallpaperPreview.java24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/com/android/wallpaper/livepicker/LiveWallpaperPreview.java b/src/com/android/wallpaper/livepicker/LiveWallpaperPreview.java
index 6dab5c6..25ce3a4 100644
--- a/src/com/android/wallpaper/livepicker/LiveWallpaperPreview.java
+++ b/src/com/android/wallpaper/livepicker/LiveWallpaperPreview.java
@@ -27,6 +27,7 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.ServiceConnection;
+import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources.NotFoundException;
import android.graphics.Rect;
@@ -71,9 +72,9 @@ public class LiveWallpaperPreview extends Activity {
private WallpaperManager mWallpaperManager;
private WallpaperConnection mWallpaperConnection;
- private String mSettings;
private String mPackageName;
private Intent mWallpaperIntent;
+ private Intent mSettingsIntent;
private TextView mAttributionTitle;
private TextView mAttributionSubtitle1;
@@ -115,11 +116,23 @@ public class LiveWallpaperPreview extends Activity {
mSpacer = findViewById(R.id.spacer);
mLoading = findViewById(R.id.loading);
- mSettings = info.getSettingsActivity();
mPackageName = info.getPackageName();
mWallpaperIntent = new Intent(WallpaperService.SERVICE_INTERFACE)
.setClassName(info.getPackageName(), info.getServiceName());
+ final String settingsActivity = info.getSettingsActivity();
+ if (settingsActivity != null) {
+ mSettingsIntent = new Intent();
+ mSettingsIntent.setComponent(new ComponentName(mPackageName, settingsActivity));
+ mSettingsIntent.putExtra(WallpaperSettingsActivity.EXTRA_PREVIEW_MODE, true);
+ final PackageManager pm = getPackageManager();
+ final ActivityInfo activityInfo = mSettingsIntent.resolveActivityInfo(pm, 0);
+ if (activityInfo == null) {
+ Log.e(LOG_TAG, "Couldn't find settings activity: " + settingsActivity);
+ mSettingsIntent = null;
+ }
+ }
+
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setActionBar(toolbar);
getActionBar().setDisplayHomeAsUpEnabled(true);
@@ -253,7 +266,7 @@ public class LiveWallpaperPreview extends Activity {
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_preview, menu);
- menu.findItem(R.id.configure).setVisible(mSettings != null);
+ menu.findItem(R.id.configure).setVisible(mSettingsIntent != null);
menu.findItem(R.id.set_wallpaper).getActionView().setOnClickListener(
this::setLiveWallpaper);
return super.onCreateOptionsMenu(menu);
@@ -308,10 +321,7 @@ public class LiveWallpaperPreview extends Activity {
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.configure) {
- Intent intent = new Intent();
- intent.setComponent(new ComponentName(mPackageName, mSettings));
- intent.putExtra(WallpaperSettingsActivity.EXTRA_PREVIEW_MODE, true);
- startActivity(intent);
+ startActivity(mSettingsIntent);
return true;
} else if (id == R.id.set_wallpaper) {
setLiveWallpaper(getWindow().getDecorView());