diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2016-07-14 14:17:00 -0700 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2016-07-18 09:54:04 -0700 |
commit | cd1d8432cf47bffe716bd4ae57bfe2596881d9ef (patch) | |
tree | 4e02822b1608e3d950a5330e05e144a44e7c8c9b | |
parent | ab7697f9200cfa59c9e9a667b67d726102a179d1 (diff) | |
download | android_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
-rw-r--r-- | res/drawable-sw600dp/ic_device.xml | 27 | ||||
-rw-r--r-- | res/drawable/ic_device.xml | 27 | ||||
-rw-r--r-- | res/drawable/ic_home.xml | 27 | ||||
-rw-r--r-- | res/layout/wallpaper_target_dialog_item.xml | 28 | ||||
-rw-r--r-- | src/com/android/wallpaper/livepicker/LiveWallpaperPreview.java | 38 |
5 files changed, 142 insertions, 5 deletions
diff --git a/res/drawable-sw600dp/ic_device.xml b/res/drawable-sw600dp/ic_device.xml new file mode 100644 index 0000000..9af391c --- /dev/null +++ b/res/drawable-sw600dp/ic_device.xml @@ -0,0 +1,27 @@ +<!-- + ~ Copyright (C) 2016 The Android Open Source Project + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License + --> +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:height="24.0dp" + android:viewportHeight="24.0" + android:viewportWidth="24.0" + android:width="24.0dp" + android:tint="?android:attr/colorAccent"> + + <path + android:fillColor="#FFFFFFFF" + android:pathData="M21 4H3c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h18c1.1 0 1.99-.9 1.99-2L23 6c0-1.1-.9-2-2-2zm-2 14H5V6h14v12z" /> + +</vector> diff --git a/res/drawable/ic_device.xml b/res/drawable/ic_device.xml new file mode 100644 index 0000000..82a69cb --- /dev/null +++ b/res/drawable/ic_device.xml @@ -0,0 +1,27 @@ +<!-- +Copyright (C) 2016 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:height="24.0dp" + android:viewportHeight="24.0" + android:viewportWidth="24.0" + android:width="24.0dp" + android:tint="?android:attr/colorAccent"> + + <path + android:fillColor="#FFFFFFFF" + android:pathData="M17 1.01L7 1c-1.1 0-2 .9-2 2v18c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V3c0-1.1-.9-1.99-2-1.99zM17 19H7V5h10v14z" /> + +</vector> diff --git a/res/drawable/ic_home.xml b/res/drawable/ic_home.xml new file mode 100644 index 0000000..5eb2e92 --- /dev/null +++ b/res/drawable/ic_home.xml @@ -0,0 +1,27 @@ +<!-- +Copyright (C) 2016 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:height="24.0dp" + android:viewportHeight="24.0" + android:viewportWidth="24.0" + android:width="24.0dp" + android:tint="?android:attr/colorAccent"> + + <path + android:fillColor="#FFFFFFFF" + android:pathData="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z" /> + +</vector> diff --git a/res/layout/wallpaper_target_dialog_item.xml b/res/layout/wallpaper_target_dialog_item.xml new file mode 100644 index 0000000..01831a7 --- /dev/null +++ b/res/layout/wallpaper_target_dialog_item.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2016 The Android Open Source Project + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License + --> +<TextView xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@android:id/text1" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:minHeight="?android:attr/listPreferredItemHeightSmall" + android:textAppearance="?android:attr/textAppearanceListItemSmall" + android:textColor="?android:attr/textColorAlertDialogListItem" + android:gravity="center_vertical" + android:paddingStart="?android:attr/listPreferredItemPaddingStart" + android:drawablePadding="?android:attr/listPreferredItemPaddingStart" + android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" + android:ellipsize="marquee" />
\ No newline at end of file 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; + } + } } |