diff --git a/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java b/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java index 2f62ba21c..5ff82c708 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java +++ b/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java @@ -65,6 +65,7 @@ public class GlobalUserPreferences{ public static boolean showSuicideHelp; public static boolean underlinedLinks; public static ColorPreference color; + public static boolean likeIcon; // MOSHIDON public static boolean showDividers; @@ -142,6 +143,7 @@ public class GlobalUserPreferences{ showSuicideHelp=prefs.getBoolean("showSuicideHelp", true); underlinedLinks=prefs.getBoolean("underlinedLinks", true); color=ColorPreference.valueOf(prefs.getString("color", MATERIAL3.name())); + likeIcon=prefs.getBoolean("likeIcon", false); // MOSHIDON uniformNotificationIcon=prefs.getBoolean("uniformNotificationIcon", false); @@ -219,6 +221,7 @@ public class GlobalUserPreferences{ .putBoolean("showSuicideHelp", showSuicideHelp) .putBoolean("underlinedLinks", underlinedLinks) .putString("color", color.name()) + .putBoolean("likeIcon", likeIcon) // MOSHIDON .putBoolean("defaultToUnlistedReplies", defaultToUnlistedReplies) diff --git a/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java b/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java index ffb16c4df..11f3048d1 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java +++ b/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java @@ -17,7 +17,6 @@ import android.graphics.drawable.Drawable; import android.opengl.Visibility; import android.os.Build; import android.os.Bundle; -import android.text.SpannableStringBuilder; import android.text.TextUtils; import android.util.Log; @@ -28,7 +27,6 @@ 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; @@ -39,7 +37,6 @@ import org.joinmastodon.android.model.PushNotification; import org.joinmastodon.android.model.Status; import org.joinmastodon.android.model.StatusPrivacy; import org.joinmastodon.android.model.StatusPrivacy; -import org.joinmastodon.android.ui.text.HtmlParser; import org.joinmastodon.android.ui.utils.UiUtils; import org.parceler.Parcels; @@ -165,7 +162,6 @@ 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; @@ -220,7 +216,7 @@ public class PushNotificationReceiver extends BroadcastReceiver{ if (!GlobalUserPreferences.uniformNotificationIcon) { builder.setSmallIcon(switch (pn.notificationType) { - case FAVORITE -> lp.likeIcon ? R.drawable.ic_fluent_heart_24_filled : R.drawable.ic_fluent_star_24_filled; + case FAVORITE -> GlobalUserPreferences.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/api/session/AccountLocalPreferences.java b/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountLocalPreferences.java index 20a12e69e..bd6566506 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountLocalPreferences.java +++ b/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountLocalPreferences.java @@ -49,7 +49,6 @@ public class AccountLocalPreferences{ public boolean emojiReactionsEnabled; public ShowEmojiReactions showEmojiReactions; public ColorPreference color; - public boolean likeIcon; public ArrayList recentCustomEmoji; private final static Type recentLanguagesType=new TypeToken>() {}.getType(); @@ -86,7 +85,6 @@ public class AccountLocalPreferences{ emojiReactionsEnabled=prefs.getBoolean("emojiReactionsEnabled", session.getInstance().isPresent() && session.getInstance().get().isAkkoma()); showEmojiReactions=ShowEmojiReactions.valueOf(prefs.getString("showEmojiReactions", ShowEmojiReactions.HIDE_EMPTY.name())); color=prefs.contains("color") ? ColorPreference.valueOf(prefs.getString("color", null)) : null; - likeIcon=prefs.getBoolean("likeIcon", false); recentCustomEmoji=fromJson(prefs.getString("recentCustomEmoji", null), recentCustomEmojiType, new ArrayList<>()); // MOSHIDON @@ -130,7 +128,6 @@ public class AccountLocalPreferences{ .putBoolean("emojiReactionsEnabled", emojiReactionsEnabled) .putString("showEmojiReactions", showEmojiReactions.name()) .putString("color", color!=null ? color.name() : null) - .putBoolean("likeIcon", likeIcon) .putString("recentCustomEmoji", gson.toJson(recentCustomEmoji)) // MOSHIDON diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsDisplayFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsDisplayFragment.java index 6940d3440..b14543ab3 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsDisplayFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsDisplayFragment.java @@ -80,7 +80,7 @@ public class SettingsDisplayFragment extends BaseSettingsFragment{ spectatorModeItem=new CheckableListItem<>(R.string.sk_settings_hide_interaction, 0, CheckableListItem.Style.SWITCH, GlobalUserPreferences.spectatorMode, R.drawable.ic_fluent_star_off_24_regular, ()->toggleCheckableItem(spectatorModeItem)), hideFabItem=new CheckableListItem<>(R.string.sk_settings_hide_fab, 0, CheckableListItem.Style.SWITCH, GlobalUserPreferences.autoHideFab, R.drawable.ic_fluent_edit_24_regular, ()->toggleCheckableItem(hideFabItem)), translateOpenedItem=new CheckableListItem<>(R.string.sk_settings_translate_only_opened, 0, CheckableListItem.Style.SWITCH, GlobalUserPreferences.translateButtonOpenedOnly, R.drawable.ic_fluent_translate_24_regular, ()->toggleCheckableItem(translateOpenedItem)), - likeIconItem=new CheckableListItem<>(R.string.sk_settings_like_icon, 0, CheckableListItem.Style.SWITCH, lp.likeIcon, R.drawable.ic_fluent_heart_24_regular, ()->toggleCheckableItem(likeIconItem)), + likeIconItem=new CheckableListItem<>(R.string.sk_settings_like_icon, 0, CheckableListItem.Style.SWITCH, GlobalUserPreferences.likeIcon, R.drawable.ic_fluent_heart_24_regular, ()->toggleCheckableItem(likeIconItem)), underlinedLinksItem=new CheckableListItem<>(R.string.sk_settings_underlined_links, 0, CheckableListItem.Style.SWITCH, GlobalUserPreferences.underlinedLinks, R.drawable.ic_fluent_text_underline_24_regular, ()->toggleCheckableItem(underlinedLinksItem)), showPostDividersItem=new CheckableListItem<>(R.string.mo_enable_dividers, 0, CheckableListItem.Style.SWITCH, GlobalUserPreferences.showDividers, R.drawable.ic_fluent_timeline_24_regular, ()->toggleCheckableItem(showPostDividersItem)), disablePillItem=new CheckableListItem<>(R.string.sk_disable_pill_shaped_active_indicator, 0, CheckableListItem.Style.SWITCH, GlobalUserPreferences.disableM3PillActiveIndicator, R.drawable.ic_fluent_pill_24_regular, ()->toggleCheckableItem(disablePillItem)), @@ -109,18 +109,17 @@ public class SettingsDisplayFragment extends BaseSettingsFragment{ protected void onHidden(){ super.onHidden(); - boolean restartPlease= - GlobalUserPreferences.disableM3PillActiveIndicator!=disablePillItem.checked || - GlobalUserPreferences.showNavigationLabels!=showNavigationLabelsItem.checked || - GlobalUserPreferences.showMediaPreview !=showMediaPreviewItem.checked || - GlobalUserPreferences.showDividers!=showPostDividersItem.checked || - lp.likeIcon!=likeIconItem.checked; + boolean restartPlease=GlobalUserPreferences.disableM3PillActiveIndicator!=disablePillItem.checked + || GlobalUserPreferences.showNavigationLabels!=showNavigationLabelsItem.checked + || GlobalUserPreferences.showMediaPreview!=showMediaPreviewItem.checked + || GlobalUserPreferences.showDividers!=showPostDividersItem.checked + || GlobalUserPreferences.likeIcon!=likeIconItem.checked; + ; lp.revealCWs=revealCWsItem.checked; lp.hideSensitiveMedia=hideSensitiveMediaItem.checked; lp.showInteractionCounts=interactionCountsItem.checked; lp.customEmojiInNames=emojiInNamesItem.checked; - lp.likeIcon=likeIconItem.checked; lp.save(); GlobalUserPreferences.toolbarMarquee=marqueeItem.checked; GlobalUserPreferences.relocatePublishButton=relocatePublishButtonItem.checked; @@ -134,6 +133,7 @@ public class SettingsDisplayFragment extends BaseSettingsFragment{ GlobalUserPreferences.spectatorMode=spectatorModeItem.checked; GlobalUserPreferences.autoHideFab=hideFabItem.checked; GlobalUserPreferences.translateButtonOpenedOnly=translateOpenedItem.checked; + GlobalUserPreferences.likeIcon=likeIconItem.checked; GlobalUserPreferences.underlinedLinks=underlinedLinksItem.checked; GlobalUserPreferences.showDividers=showPostDividersItem.checked; GlobalUserPreferences.disableM3PillActiveIndicator=disablePillItem.checked; diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/ExtendedFooterStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/ExtendedFooterStatusDisplayItem.java index 7cee2053c..b55f8a8bc 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/ExtendedFooterStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/ExtendedFooterStatusDisplayItem.java @@ -13,6 +13,7 @@ import android.widget.Button; import android.widget.ImageView; import android.widget.TextView; +import org.joinmastodon.android.GlobalUserPreferences; import org.joinmastodon.android.R; import org.joinmastodon.android.api.session.AccountSession; import org.joinmastodon.android.api.session.AccountSessionManager; @@ -77,9 +78,7 @@ public class ExtendedFooterStatusDisplayItem extends StatusDisplayItem{ @Override public void onBind(ExtendedFooterStatusDisplayItem item){ Status s=item.status; - AccountSession session=AccountSessionManager.get(item.accountID); - boolean like=session!=null && session.getLocalPreferences().likeIcon; - favorites.setCompoundDrawablesRelativeWithIntrinsicBounds(like ? R.drawable.ic_fluent_heart_20_regular : R.drawable.ic_fluent_star_20_regular, 0, 0, 0); + favorites.setCompoundDrawablesRelativeWithIntrinsicBounds(GlobalUserPreferences.likeIcon ? R.drawable.ic_fluent_heart_20_regular : R.drawable.ic_fluent_star_20_regular, 0, 0, 0); favorites.setText(context.getResources().getQuantityString(R.plurals.x_favorites, (int)(s.favouritesCount%1000), s.favouritesCount)); reblogs.setText(context.getResources().getQuantityString(R.plurals.x_reblogs, (int) (s.reblogsCount % 1000), s.reblogsCount)); reblogs.setVisibility(s.visibility != StatusPrivacy.DIRECT ? View.VISIBLE : View.GONE); 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 d66573807..13301de0b 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 @@ -150,13 +150,10 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{ boolean condenseBottom = !item.isMainStatus && item.hasDescendantNeighbor && !nextIsWarning; - - AccountSession session=AccountSessionManager.get(item.accountID); - boolean like=session!=null && session.getLocalPreferences().likeIcon; ColorStateList color=item.parentFragment.getResources().getColorStateList( - like ? R.color.like_icon : R.color.favorite_icon, item.parentFragment.getContext().getTheme() + GlobalUserPreferences.likeIcon ? R.color.like_icon : R.color.favorite_icon, item.parentFragment.getContext().getTheme() ); - favIcon.setImageResource(like ? R.drawable.ic_fluent_heart_24_selector : R.drawable.ic_fluent_star_24_selector); + favIcon.setImageResource(GlobalUserPreferences.likeIcon ? R.drawable.ic_fluent_heart_24_selector : R.drawable.ic_fluent_star_24_selector); favIcon.setImageTintList(color); favorites.setTextColor(color); @@ -401,8 +398,7 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{ R.string.sk_favorite_as, R.string.sk_favorited_as, R.string.sk_already_favorited, - AccountSessionManager.get(item.accountID).getLocalPreferences().likeIcon ? - R.drawable.ic_fluent_heart_28_regular : R.drawable.ic_fluent_star_28_regular + GlobalUserPreferences.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 dff55373f..ae9ffae02 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 @@ -47,14 +47,12 @@ 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); @@ -163,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 -> item.lp.likeIcon ? R.drawable.ic_fluent_heart_24_filled : R.drawable.ic_fluent_star_24_filled; + case FAVORITE -> GlobalUserPreferences.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; @@ -174,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 -> item.lp.likeIcon ? R.attr.colorLike : R.attr.colorFavorite; + case FAVORITE -> GlobalUserPreferences.likeIcon ? R.attr.colorLike : R.attr.colorFavorite; case REBLOG -> R.attr.colorBoost; case POLL -> R.attr.colorPoll; default -> android.R.attr.colorAccent;