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 /src/com/android/wallpaper/picker/individual/IndividualPickerFragment.java | |
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
Diffstat (limited to 'src/com/android/wallpaper/picker/individual/IndividualPickerFragment.java')
-rwxr-xr-x | src/com/android/wallpaper/picker/individual/IndividualPickerFragment.java | 39 |
1 files changed, 33 insertions, 6 deletions
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); + } } } |