From 6670d16341f2311925765511c54afab196a0d2bd Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Fri, 28 Aug 2015 17:43:21 -0700 Subject: Moving the set wallpaper button to the top to match the default launcher style Using a cog image instead of the Settings... button Change-Id: Ia106ff1bd978ab67fd8405e2cd66cf701d29e7a4 --- .../wallpaper/livepicker/LiveWallpaperPreview.java | 36 ++++++++++++++-------- 1 file changed, 24 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/com/android/wallpaper/livepicker/LiveWallpaperPreview.java b/src/com/android/wallpaper/livepicker/LiveWallpaperPreview.java index 72ba27a..31fff0f 100644 --- a/src/com/android/wallpaper/livepicker/LiveWallpaperPreview.java +++ b/src/com/android/wallpaper/livepicker/LiveWallpaperPreview.java @@ -16,6 +16,7 @@ package com.android.wallpaper.livepicker; +import android.app.ActionBar; import android.app.Activity; import android.app.WallpaperManager; import android.app.WallpaperInfo; @@ -33,6 +34,8 @@ import android.os.RemoteException; import android.os.IBinder; import android.os.ParcelFileDescriptor; import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; import android.view.MotionEvent; import android.view.View; import android.view.WindowManager; @@ -81,20 +84,25 @@ public class LiveWallpaperPreview extends Activity { finish(); } - setContentView(R.layout.live_wallpaper_preview); - mView = findViewById(R.id.configure); + final ActionBar actionBar = getActionBar(); + actionBar.setCustomView(R.layout.live_wallpaper_preview); + mView = actionBar.getCustomView(); mSettings = extras.getString(EXTRA_LIVE_WALLPAPER_SETTINGS); mPackageName = extras.getString(EXTRA_LIVE_WALLPAPER_PACKAGE); - if (mSettings == null) { - mView.setVisibility(View.GONE); - } - mWallpaperManager = WallpaperManager.getInstance(this); mWallpaperConnection = new WallpaperConnection(mWallpaperIntent); } + @Override + public boolean onCreateOptionsMenu(Menu menu) { + if (mSettings != null) { + getMenuInflater().inflate(R.menu.menu_preview, menu); + } + return super.onCreateOptionsMenu(menu); + } + public void setLiveWallpaper(View v) { try { mWallpaperManager.getIWallpaperManager().setWallpaperComponent( @@ -110,12 +118,16 @@ public class LiveWallpaperPreview extends Activity { finish(); } - @SuppressWarnings({"UnusedDeclaration"}) - public void configureLiveWallpaper(View v) { - Intent intent = new Intent(); - intent.setComponent(new ComponentName(mPackageName, mSettings)); - intent.putExtra(WallpaperSettingsActivity.EXTRA_PREVIEW_MODE, true); - startActivity(intent); + @Override + public boolean onOptionsItemSelected(MenuItem item) { + if (item.getItemId() == R.id.configure) { + Intent intent = new Intent(); + intent.setComponent(new ComponentName(mPackageName, mSettings)); + intent.putExtra(WallpaperSettingsActivity.EXTRA_PREVIEW_MODE, true); + startActivity(intent); + return true; + } + return super.onOptionsItemSelected(item); } @Override -- cgit v1.2.3