summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2016-07-14 14:17:00 -0700
committerSunny Goyal <sunnygoyal@google.com>2016-07-18 09:54:04 -0700
commitcd1d8432cf47bffe716bd4ae57bfe2596881d9ef (patch)
tree4e02822b1608e3d950a5330e05e144a44e7c8c9b /src
parentab7697f9200cfa59c9e9a667b67d726102a179d1 (diff)
downloadandroid_packages_wallpapers_LivePicker-cd1d8432cf47bffe716bd4ae57bfe2596881d9ef.tar.gz
android_packages_wallpapers_LivePicker-cd1d8432cf47bffe716bd4ae57bfe2596881d9ef.tar.bz2
android_packages_wallpapers_LivePicker-cd1d8432cf47bffe716bd4ae57bfe2596881d9ef.zip
Adding icons in Set Wallpaper disambiguation dialog UI
Bug: 29319713 Change-Id: If8b689e9b27a3cbd1f5123cc584cda3662f2ee38
Diffstat (limited to 'src')
-rw-r--r--src/com/android/wallpaper/livepicker/LiveWallpaperPreview.java38
1 files changed, 33 insertions, 5 deletions
diff --git a/src/com/android/wallpaper/livepicker/LiveWallpaperPreview.java b/src/com/android/wallpaper/livepicker/LiveWallpaperPreview.java
index 927ffc6..b2d8a78 100644
--- a/src/com/android/wallpaper/livepicker/LiveWallpaperPreview.java
+++ b/src/com/android/wallpaper/livepicker/LiveWallpaperPreview.java
@@ -42,13 +42,16 @@ import android.service.wallpaper.WallpaperSettingsActivity;
import android.support.design.widget.BottomSheetBehavior;
import android.text.TextUtils;
import android.util.Log;
+import android.view.ContextThemeWrapper;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
+import android.view.ViewGroup;
import android.view.WindowManager.LayoutParams;
import android.view.animation.AnimationUtils;
+import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;
@@ -258,9 +261,10 @@ public class LiveWallpaperPreview extends Activity {
finish();
} else {
// Otherwise, prompt to either set on home or both home and lock screen.
- new AlertDialog.Builder(this, android.R.style.Theme_Material_Light_Dialog)
+ Context themedContext = new ContextThemeWrapper(this, android.R.style.Theme_DeviceDefault_Settings);
+ new AlertDialog.Builder(themedContext)
.setTitle(R.string.set_live_wallpaper)
- .setItems(R.array.which_wallpaper_options, new DialogInterface.OnClickListener() {
+ .setAdapter(new WallpaperTargetAdapter(themedContext), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
try {
@@ -271,9 +275,7 @@ public class LiveWallpaperPreview extends Activity {
mWallpaperManager.clear(WallpaperManager.FLAG_LOCK);
}
setResult(RESULT_OK);
- } catch (RuntimeException e) {
- Log.w(LOG_TAG, "Failure setting wallpaper", e);
- } catch (IOException e) {
+ } catch (RuntimeException|IOException e) {
Log.w(LOG_TAG, "Failure setting wallpaper", e);
}
finish();
@@ -487,4 +489,30 @@ public class LiveWallpaperPreview extends Activity {
});
}
}
+
+ private static class WallpaperTargetAdapter extends ArrayAdapter<CharSequence> {
+
+ public WallpaperTargetAdapter(Context context) {
+ super(context, R.layout.wallpaper_target_dialog_item,
+ context.getResources().getTextArray(R.array.which_wallpaper_options));
+ }
+
+ @Override
+ public boolean hasStableIds() {
+ return true;
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return position;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ TextView tv = (TextView) super.getView(position, convertView, parent);
+ tv.setCompoundDrawablesRelativeWithIntrinsicBounds(
+ position == 0 ? R.drawable.ic_home : R.drawable.ic_device, 0, 0, 0);
+ return tv;
+ }
+ }
}