From e9b75119b3f02382327e66c4fb66bac3bd17409d Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Thu, 28 Apr 2022 20:39:06 +0200 Subject: [PATCH] improve bot badge (#2466) * improve bot badge * change badge corner radius --- .../tusky/adapter/AccountViewHolder.java | 3 +-- .../tusky/adapter/NotificationsAdapter.java | 3 +-- .../tusky/adapter/StatusBaseViewHolder.java | 7 ++++--- app/src/main/res/drawable/bot_badge.xml | 13 +++++++++++++ app/src/main/res/values-night/theme_colors.xml | 3 +++ app/src/main/res/values/theme_colors.xml | 3 +++ 6 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 app/src/main/res/drawable/bot_badge.xml diff --git a/app/src/main/java/com/keylesspalace/tusky/adapter/AccountViewHolder.java b/app/src/main/java/com/keylesspalace/tusky/adapter/AccountViewHolder.java index f4824389..6672fff3 100644 --- a/app/src/main/java/com/keylesspalace/tusky/adapter/AccountViewHolder.java +++ b/app/src/main/java/com/keylesspalace/tusky/adapter/AccountViewHolder.java @@ -45,8 +45,7 @@ public class AccountViewHolder extends RecyclerView.ViewHolder { ImageLoadingHelper.loadAvatar(account.getAvatar(), avatar, avatarRadius, animateAvatar); if (showBotOverlay && account.getBot()) { avatarInset.setVisibility(View.VISIBLE); - avatarInset.setImageResource(R.drawable.ic_bot_24dp); - avatarInset.setBackgroundColor(0x50ffffff); + avatarInset.setImageResource(R.drawable.bot_badge); } else { avatarInset.setVisibility(View.GONE); } diff --git a/app/src/main/java/com/keylesspalace/tusky/adapter/NotificationsAdapter.java b/app/src/main/java/com/keylesspalace/tusky/adapter/NotificationsAdapter.java index f8885f36..f681e64f 100644 --- a/app/src/main/java/com/keylesspalace/tusky/adapter/NotificationsAdapter.java +++ b/app/src/main/java/com/keylesspalace/tusky/adapter/NotificationsAdapter.java @@ -575,9 +575,8 @@ public class NotificationsAdapter extends RecyclerView.Adapter { if (statusDisplayOptions.showBotOverlay() && isBot) { notificationAvatar.setVisibility(View.VISIBLE); - notificationAvatar.setBackgroundColor(0x50ffffff); Glide.with(notificationAvatar) - .load(R.drawable.ic_bot_24dp) + .load(ContextCompat.getDrawable(notificationAvatar.getContext(), R.drawable.bot_badge)) .into(notificationAvatar); } else { diff --git a/app/src/main/java/com/keylesspalace/tusky/adapter/StatusBaseViewHolder.java b/app/src/main/java/com/keylesspalace/tusky/adapter/StatusBaseViewHolder.java index c7427450..2a5b3f2c 100644 --- a/app/src/main/java/com/keylesspalace/tusky/adapter/StatusBaseViewHolder.java +++ b/app/src/main/java/com/keylesspalace/tusky/adapter/StatusBaseViewHolder.java @@ -21,6 +21,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AlertDialog; import androidx.constraintlayout.widget.ConstraintLayout; +import androidx.core.content.ContextCompat; import androidx.core.text.HtmlCompat; import androidx.recyclerview.widget.DefaultItemAnimator; import androidx.recyclerview.widget.LinearLayoutManager; @@ -28,6 +29,7 @@ import androidx.recyclerview.widget.RecyclerView; import com.bumptech.glide.Glide; import com.bumptech.glide.RequestBuilder; +import com.bumptech.glide.load.engine.DiskCacheStrategy; import com.bumptech.glide.load.resource.bitmap.CenterCrop; import com.bumptech.glide.load.resource.bitmap.GranularRoundedCorners; import com.google.android.material.button.MaterialButton; @@ -287,11 +289,10 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder { if (statusDisplayOptions.showBotOverlay() && isBot) { avatarInset.setVisibility(View.VISIBLE); - avatarInset.setBackgroundColor(0x50ffffff); Glide.with(avatarInset) - .load(R.drawable.ic_bot_24dp) + // passing the drawable id directly into .load() ignores night mode https://github.com/bumptech/glide/issues/4692 + .load(ContextCompat.getDrawable(avatarInset.getContext(), R.drawable.bot_badge)) .into(avatarInset); - } else { avatarInset.setVisibility(View.GONE); } diff --git a/app/src/main/res/drawable/bot_badge.xml b/app/src/main/res/drawable/bot_badge.xml new file mode 100644 index 00000000..6f857df5 --- /dev/null +++ b/app/src/main/res/drawable/bot_badge.xml @@ -0,0 +1,13 @@ + + + + diff --git a/app/src/main/res/values-night/theme_colors.xml b/app/src/main/res/values-night/theme_colors.xml index e45c45fb..21e56190 100644 --- a/app/src/main/res/values-night/theme_colors.xml +++ b/app/src/main/res/values-night/theme_colors.xml @@ -24,4 +24,7 @@ false + @color/white + @color/tusky_grey_10 + \ No newline at end of file diff --git a/app/src/main/res/values/theme_colors.xml b/app/src/main/res/values/theme_colors.xml index bf5b79fc..657363d8 100644 --- a/app/src/main/res/values/theme_colors.xml +++ b/app/src/main/res/values/theme_colors.xml @@ -24,4 +24,7 @@ true + @color/tusky_grey_20 + @color/white + \ No newline at end of file