From a5c197b4961e9eed995162a26d60767c9e2366ae Mon Sep 17 00:00:00 2001 From: sk Date: Sun, 8 Oct 2023 13:04:26 +0200 Subject: [PATCH] hearts everywhere closes sk22#846 --- .../org/joinmastodon/android/PushNotificationReceiver.java | 4 +++- .../android/ui/displayitems/FooterStatusDisplayItem.java | 3 ++- .../displayitems/NotificationHeaderStatusDisplayItem.java | 7 +++++-- .../src/main/res/drawable/ic_fluent_heart_28_regular.xml | 3 +++ mastodon/src/main/res/values/attrs.xml | 1 + mastodon/src/main/res/values/palettes.xml | 1 + 6 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 mastodon/src/main/res/drawable/ic_fluent_heart_28_regular.xml diff --git a/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java b/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java index 86135f975..aefe947f4 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java +++ b/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java @@ -24,6 +24,7 @@ import org.joinmastodon.android.api.requests.statuses.CreateStatus; import org.joinmastodon.android.api.requests.statuses.SetStatusBookmarked; import org.joinmastodon.android.api.requests.statuses.SetStatusFavorited; import org.joinmastodon.android.api.requests.statuses.SetStatusReblogged; +import org.joinmastodon.android.api.session.AccountLocalPreferences; import org.joinmastodon.android.api.session.AccountSession; import org.joinmastodon.android.api.session.AccountSessionManager; import org.joinmastodon.android.model.Account; @@ -158,6 +159,7 @@ public class PushNotificationReceiver extends BroadcastReceiver{ private void notify(Context context, PushNotification pn, String accountID, org.joinmastodon.android.model.Notification notification){ NotificationManager nm=context.getSystemService(NotificationManager.class); AccountSession session=AccountSessionManager.get(accountID); + AccountLocalPreferences lp=session.getLocalPreferences(); Account self=session.self; String accountName="@"+self.username+"@"+AccountSessionManager.getInstance().getAccount(accountID).domain; Notification.Builder builder; @@ -212,7 +214,7 @@ public class PushNotificationReceiver extends BroadcastReceiver{ if (!GlobalUserPreferences.uniformNotificationIcon) { builder.setSmallIcon(switch (pn.notificationType) { - case FAVORITE -> R.drawable.ic_fluent_star_24_filled; + case FAVORITE -> lp.likeIcon ? R.drawable.ic_fluent_heart_24_filled : R.drawable.ic_fluent_star_24_filled; case REBLOG -> R.drawable.ic_fluent_arrow_repeat_all_24_filled; case FOLLOW -> R.drawable.ic_fluent_person_add_24_filled; case MENTION -> R.drawable.ic_fluent_mention_24_filled; diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FooterStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FooterStatusDisplayItem.java index 675ac812f..21fb7347f 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FooterStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FooterStatusDisplayItem.java @@ -321,7 +321,8 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{ R.string.sk_favorite_as, R.string.sk_favorited_as, R.string.sk_already_favorited, - R.drawable.ic_fluent_star_28_regular + AccountSessionManager.get(item.accountID).getLocalPreferences().likeIcon ? + R.drawable.ic_fluent_heart_28_regular : R.drawable.ic_fluent_star_28_regular ); return true; } diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/NotificationHeaderStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/NotificationHeaderStatusDisplayItem.java index 30b40043c..981b38bba 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/NotificationHeaderStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/NotificationHeaderStatusDisplayItem.java @@ -20,6 +20,7 @@ import android.widget.TextView; import org.joinmastodon.android.GlobalUserPreferences; import org.joinmastodon.android.R; +import org.joinmastodon.android.api.session.AccountLocalPreferences; import org.joinmastodon.android.api.session.AccountSession; import org.joinmastodon.android.api.session.AccountSessionManager; import org.joinmastodon.android.fragments.BaseStatusListFragment; @@ -47,12 +48,14 @@ public class NotificationHeaderStatusDisplayItem extends StatusDisplayItem{ private final CustomEmojiHelper emojiHelper=new CustomEmojiHelper(); private final CharSequence text; private final CharSequence timestamp; + private final AccountLocalPreferences lp; public NotificationHeaderStatusDisplayItem(String parentID, BaseStatusListFragment parentFragment, Notification notification, String accountID){ super(parentID, parentFragment); this.notification=notification; this.accountID=accountID; this.timestamp=notification.createdAt==null ? null : UiUtils.formatRelativeTimestamp(context, notification.createdAt); + this.lp=AccountSessionManager.get(accountID).getLocalPreferences(); if(notification.type==Notification.Type.POLL){ text=parentFragment.getString(R.string.poll_ended); @@ -158,7 +161,7 @@ public class NotificationHeaderStatusDisplayItem extends StatusDisplayItem{ timestamp.setText(item.timestamp); avatar.setVisibility(item.notification.type==Notification.Type.POLL ? View.GONE : View.VISIBLE); icon.setImageResource(switch(item.notification.type){ - case FAVORITE -> R.drawable.ic_fluent_star_24_filled; + case FAVORITE -> item.lp.likeIcon ? R.drawable.ic_fluent_heart_24_filled : R.drawable.ic_fluent_star_24_filled; case REBLOG -> R.drawable.ic_fluent_arrow_repeat_all_24_filled; case FOLLOW, FOLLOW_REQUEST -> R.drawable.ic_fluent_person_add_24_filled; case POLL -> R.drawable.ic_fluent_poll_24_filled; @@ -169,7 +172,7 @@ public class NotificationHeaderStatusDisplayItem extends StatusDisplayItem{ default -> throw new IllegalStateException("Unexpected value: "+item.notification.type); }); icon.setImageTintList(ColorStateList.valueOf(UiUtils.getThemeColor(item.parentFragment.getActivity(), switch(item.notification.type){ - case FAVORITE -> R.attr.colorFavorite; + case FAVORITE -> item.lp.likeIcon ? R.attr.colorLike : R.attr.colorFavorite; case REBLOG -> R.attr.colorBoost; case POLL -> R.attr.colorPoll; default -> android.R.attr.colorAccent; diff --git a/mastodon/src/main/res/drawable/ic_fluent_heart_28_regular.xml b/mastodon/src/main/res/drawable/ic_fluent_heart_28_regular.xml new file mode 100644 index 000000000..275f7b506 --- /dev/null +++ b/mastodon/src/main/res/drawable/ic_fluent_heart_28_regular.xml @@ -0,0 +1,3 @@ + + + diff --git a/mastodon/src/main/res/values/attrs.xml b/mastodon/src/main/res/values/attrs.xml index 9a030c3a9..2482de876 100644 --- a/mastodon/src/main/res/values/attrs.xml +++ b/mastodon/src/main/res/values/attrs.xml @@ -30,6 +30,7 @@ + diff --git a/mastodon/src/main/res/values/palettes.xml b/mastodon/src/main/res/values/palettes.xml index d30c15a18..a3d90d37b 100644 --- a/mastodon/src/main/res/values/palettes.xml +++ b/mastodon/src/main/res/values/palettes.xml @@ -54,6 +54,7 @@ ?colorPrimary200 @color/favorite_selected + @color/like_selected ?colorM3Primary @color/bookmark_selected #14000000