diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2017-08-03 07:31:51 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2017-08-03 07:31:51 +0000 |
commit | 48b0785889fc9e1b1c42ca2afc9ba7e3e88ad3bb (patch) | |
tree | d6f55ccd2fe101353692278a7335aa4a72d1b75c | |
parent | 0e73080e2d0b0239bc0099fe12268ab289987460 (diff) | |
parent | 301b7ba1244a5f6375e71cc24cdc849367da4e67 (diff) | |
download | android_packages_wallpapers_LivePicker-48b0785889fc9e1b1c42ca2afc9ba7e3e88ad3bb.tar.gz android_packages_wallpapers_LivePicker-48b0785889fc9e1b1c42ca2afc9ba7e3e88ad3bb.tar.bz2 android_packages_wallpapers_LivePicker-48b0785889fc9e1b1c42ca2afc9ba7e3e88ad3bb.zip |
release-request-ca4ad653-1655-436a-b65c-2527b02ae5f2-for-git_oc-mr1-release-4241196 snap-temp-L48200000088705722
Change-Id: I412bc8635f4f49854ec7f9128e5c4ba29c95b3b0
-rw-r--r-- | src/com/android/wallpaper/livepicker/LiveWallpaperPreview.java | 24 |
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()); |