diff options
author | Chuck Liao <chuckliao@google.com> | 2021-07-23 19:29:34 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-07-23 19:29:34 +0000 |
commit | c22dbd7eec70247bfeb72bc1ed639a8a3ad8343a (patch) | |
tree | 4da1225c5be4fd0cb544c0d872a41b3a3b57aae6 | |
parent | cbeeaa54d3634f91d0b74afc91aa7145fb12992d (diff) | |
parent | 369e082d737bb4fa0a9a6689536385ef0314b654 (diff) | |
download | platform_packages_apps_WallpaperPicker2-c22dbd7eec70247bfeb72bc1ed639a8a3ad8343a.tar.gz platform_packages_apps_WallpaperPicker2-c22dbd7eec70247bfeb72bc1ed639a8a3ad8343a.tar.bz2 platform_packages_apps_WallpaperPicker2-c22dbd7eec70247bfeb72bc1ed639a8a3ad8343a.zip |
Use check mark to indicate the applied wallpaper am: 369e082d73
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/WallpaperPicker2/+/15155680
Change-Id: I25ac1a93b8594f021c9c1a7677695bc9c96fe34e
-rw-r--r-- | res/drawable/ic_check_wallpaper_24dp.xml | 25 | ||||
-rw-r--r-- | res/drawable/wallpaper_check_circle_24dp.xml | 29 | ||||
-rwxr-xr-x | res/layout/grid_item_image.xml | 3 | ||||
-rwxr-xr-x | res/layout/grid_item_my_photos.xml | 2 | ||||
-rwxr-xr-x | res/layout/grid_item_rotation_desktop.xml | 2 | ||||
-rwxr-xr-x | src/com/android/wallpaper/picker/individual/IndividualPickerFragment.java | 39 |
6 files changed, 90 insertions, 10 deletions
diff --git a/res/drawable/ic_check_wallpaper_24dp.xml b/res/drawable/ic_check_wallpaper_24dp.xml new file mode 100644 index 0000000..eeee07e --- /dev/null +++ b/res/drawable/ic_check_wallpaper_24dp.xml @@ -0,0 +1,25 @@ +<!-- + Copyright (C) 2021 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" + xmlns:androidprv="http://schemas.android.com/apk/prv/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + <path + android:fillColor="?androidprv:attr/textColorOnAccent" + android:pathData="M9,16.17L4.83,12l-1.42,1.41L9,19 21,7l-1.41,-1.41L9,16.17z"/> +</vector> diff --git a/res/drawable/wallpaper_check_circle_24dp.xml b/res/drawable/wallpaper_check_circle_24dp.xml new file mode 100644 index 0000000..1249111 --- /dev/null +++ b/res/drawable/wallpaper_check_circle_24dp.xml @@ -0,0 +1,29 @@ +<!-- + Copyright (C) 2021 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. +--> +<layer-list xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"> + <item> + <shape android:shape="oval"> + <size android:width="24dp" android:height="24dp" /> + <solid android:color="?androidprv:attr/colorAccentPrimary" /> + </shape> + </item> + <item + android:width="@dimen/grid_item_badge_indicator_size" + android:height="@dimen/grid_item_badge_indicator_size" + android:drawable="@drawable/ic_check_wallpaper_24dp" + android:gravity="center" /> +</layer-list> diff --git a/res/layout/grid_item_image.xml b/res/layout/grid_item_image.xml index 7a00b59..b4e2b1e 100755 --- a/res/layout/grid_item_image.xml +++ b/res/layout/grid_item_image.xml @@ -35,7 +35,7 @@ android:layout_height="match_parent" android:foreground="@drawable/wallpaper_option_border"> - <com.android.wallpaper.picker.individual.CustomShapeImageView + <ImageView android:id="@+id/thumbnail" android:layout_width="match_parent" android:layout_height="match_parent" @@ -53,7 +53,6 @@ android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentEnd="true" - android:background="@drawable/ic_download_badge" android:visibility="gone" /> <FrameLayout diff --git a/res/layout/grid_item_my_photos.xml b/res/layout/grid_item_my_photos.xml index eab77dc..e88b21e 100755 --- a/res/layout/grid_item_my_photos.xml +++ b/res/layout/grid_item_my_photos.xml @@ -27,7 +27,7 @@ android:focusable="true" android:foreground="?attr/selectableItemBackground"> - <com.android.wallpaper.picker.individual.CustomShapeImageView + <ImageView android:id="@+id/thumbnail" android:layout_width="match_parent" android:layout_height="match_parent" diff --git a/res/layout/grid_item_rotation_desktop.xml b/res/layout/grid_item_rotation_desktop.xml index 61502ae..85a6902 100755 --- a/res/layout/grid_item_rotation_desktop.xml +++ b/res/layout/grid_item_rotation_desktop.xml @@ -27,7 +27,7 @@ android:focusable="true" android:foreground="?attr/selectableItemBackground"> - <com.android.wallpaper.picker.individual.CustomShapeImageView + <ImageView android:id="@+id/thumbnail" android:layout_width="match_parent" android:layout_height="match_parent" diff --git a/src/com/android/wallpaper/picker/individual/IndividualPickerFragment.java b/src/com/android/wallpaper/picker/individual/IndividualPickerFragment.java index a7d1f5c..bb7a1d0 100755 --- a/src/com/android/wallpaper/picker/individual/IndividualPickerFragment.java +++ b/src/com/android/wallpaper/picker/individual/IndividualPickerFragment.java @@ -38,8 +38,11 @@ import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.RelativeLayout; import android.widget.Toast; +import androidx.annotation.DrawableRes; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.cardview.widget.CardView; @@ -1068,6 +1071,7 @@ public class IndividualPickerFragment extends AppbarFragment startActivity(exploreIntent); } + // TODO: Dead code. Should remove this method in the future. private void updateActivatedStatus(WallpaperInfo wallpaperInfo, boolean isActivated) { if (wallpaperInfo == null) { return; @@ -1077,14 +1081,14 @@ public class IndividualPickerFragment extends AppbarFragment ? index + 1 : index; ViewHolder holder = mImageGrid.findViewHolderForAdapterPosition(index); if (holder != null) { - CustomShapeImageView thumbnail = holder.itemView.findViewById(R.id.thumbnail); - thumbnail.setClipped(isActivated); + holder.itemView.setActivated(isActivated); } else { // Item is not visible, make sure the item is re-bound when it becomes visible. mAdapter.notifyItemChanged(index); } } + // TODO: Dead code. Should remove this method in the future. private void updateAppliedStatus(WallpaperInfo wallpaperInfo, boolean isApplied) { if (wallpaperInfo == null) { return; @@ -1093,7 +1097,9 @@ public class IndividualPickerFragment extends AppbarFragment index = (shouldShowRotationTile() || mCategory.supportsCustomPhotos()) ? index + 1 : index; ViewHolder holder = mImageGrid.findViewHolderForAdapterPosition(index); - if (holder == null) { + if (holder != null) { + mAdapter.showBadge(holder, R.drawable.wallpaper_check_circle_24dp, isApplied); + } else { // Item is not visible, make sure the item is re-bound when it becomes visible. mAdapter.notifyItemChanged(index); } @@ -1436,7 +1442,7 @@ public class IndividualPickerFragment extends AppbarFragment WallpaperInfo wallpaper = mWallpapers.get(wallpaperIndex); wallpaper.computePlaceholderColor(holder.itemView.getContext()); ((IndividualHolder) holder).bindWallpaper(wallpaper); - boolean isWallpaperApplied = mAppliedWallpaperIds.contains(wallpaper.getWallpaperId()); + boolean isWallpaperApplied = isWallpaperApplied(wallpaper); if (isWallpaperApplied) { mSelectedAdapterPosition = position; @@ -1447,8 +1453,29 @@ public class IndividualPickerFragment extends AppbarFragment int radiusId = isFewerColumnLayout() ? R.dimen.grid_item_all_radius : R.dimen.grid_item_all_radius_small; container.setRadius(getResources().getDimension(radiusId)); - CustomShapeImageView thumbnail = holder.itemView.findViewById(R.id.thumbnail); - thumbnail.setClipped(isWallpaperApplied); + showBadge(holder, R.drawable.wallpaper_check_circle_24dp, isWallpaperApplied); + } + + protected boolean isWallpaperApplied(WallpaperInfo wallpaper) { + return mAppliedWallpaperIds.contains(wallpaper.getWallpaperId()); + } + + protected void showBadge(ViewHolder holder, @DrawableRes int icon, boolean show) { + ImageView badge = holder.itemView.findViewById(R.id.indicator_icon); + if (show) { + final float margin = isFewerColumnLayout() ? getResources().getDimension( + R.dimen.grid_item_badge_margin) : getResources().getDimension( + R.dimen.grid_item_badge_margin_small); + final RelativeLayout.LayoutParams layoutParams = + (RelativeLayout.LayoutParams) badge.getLayoutParams(); + layoutParams.setMargins(/* left= */ (int) margin, /* top= */ (int) margin, + /* right= */ (int) margin, /* bottom= */ (int) margin); + badge.setLayoutParams(layoutParams); + badge.setBackgroundResource(icon); + badge.setVisibility(View.VISIBLE); + } else { + badge.setVisibility(View.GONE); + } } } |