diff --git a/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java b/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java index 5259b9c18..0d329f130 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java +++ b/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java @@ -27,6 +27,7 @@ public class GlobalUserPreferences{ public static boolean disableMarquee; public static boolean disableSwipe; public static boolean voteButtonForSingleChoice; + public static boolean showDifferentiatedPushNoticationIcons; public static ThemePreference theme; public static ColorPreference color; @@ -50,6 +51,7 @@ public class GlobalUserPreferences{ showReplies=prefs.getBoolean("showReplies", true); showBoosts=prefs.getBoolean("showBoosts", true); loadNewPosts=prefs.getBoolean("loadNewPosts", true); + showDifferentiatedPushNoticationIcons=prefs.getBoolean("showDifferentiatedPushNoticationIcons", false); showFederatedTimeline=prefs.getBoolean("showFederatedTimeline", !BuildConfig.BUILD_TYPE.equals("playRelease")); showInteractionCounts=prefs.getBoolean("showInteractionCounts", false); alwaysExpandContentWarnings=prefs.getBoolean("alwaysExpandContentWarnings", false); @@ -84,6 +86,7 @@ public class GlobalUserPreferences{ .putBoolean("alwaysExpandContentWarnings", alwaysExpandContentWarnings) .putBoolean("disableMarquee", disableMarquee) .putBoolean("disableSwipe", disableSwipe) + .putBoolean("showDifferentiatedPushNoticationIcons", showDifferentiatedPushNoticationIcons) .putInt("theme", theme.ordinal()) .putString("color", color.name()) .putString("recentLanguages", gson.toJson(recentLanguages)) diff --git a/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java b/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java index f67868a85..d56356ded 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java +++ b/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java @@ -143,14 +143,19 @@ public class PushNotificationReceiver extends BroadcastReceiver{ .setCategory(Notification.CATEGORY_SOCIAL) .setAutoCancel(true) .setColor(context.getColor(R.color.shortcut_icon_background)); - switch (pn.notificationType) { - case FAVORITE -> builder.setSmallIcon(R.drawable.ic_fluent_star_24_filled); - case REBLOG -> builder.setSmallIcon(R.drawable.ic_fluent_arrow_repeat_all_24_filled); - case FOLLOW -> builder.setSmallIcon(R.drawable.ic_fluent_person_add_24_filled); - case MENTION -> builder.setSmallIcon(R.drawable.ic_fluent_mention_24_filled); - case POLL -> builder.setSmallIcon(R.drawable.ic_fluent_poll_24_filled); - default -> builder.setSmallIcon(R.drawable.ic_ntf_logo); + if(GlobalUserPreferences.showDifferentiatedPushNoticationIcons){ + switch (pn.notificationType) { + case FAVORITE -> builder.setSmallIcon(R.drawable.ic_fluent_star_24_filled); + case REBLOG -> builder.setSmallIcon(R.drawable.ic_fluent_arrow_repeat_all_24_filled); + case FOLLOW -> builder.setSmallIcon(R.drawable.ic_fluent_person_add_24_filled); + case MENTION -> builder.setSmallIcon(R.drawable.ic_fluent_mention_24_filled); + case POLL -> builder.setSmallIcon(R.drawable.ic_fluent_poll_24_filled); + default -> builder.setSmallIcon(R.drawable.ic_ntf_logo); + } + }else{ + builder.setSmallIcon(R.drawable.ic_ntf_logo); } + if(avatar!=null){ builder.setLargeIcon(UiUtils.getBitmapFromDrawable(avatar)); } diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java index 3e2c13790..3f5fa9941 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java @@ -9,6 +9,7 @@ import android.graphics.Canvas; import android.graphics.Rect; import android.os.Build; import android.os.Bundle; +import android.provider.Settings; import android.view.Gravity; import android.view.LayoutInflater; import android.view.MenuItem; @@ -18,8 +19,6 @@ import android.view.WindowInsets; import android.view.WindowManager; import android.view.animation.LinearInterpolator; import android.widget.Button; -import android.widget.EditText; -import android.widget.FrameLayout; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.PopupMenu; @@ -52,7 +51,6 @@ import org.joinmastodon.android.ui.utils.UiUtils; import org.joinmastodon.android.updater.GithubSelfUpdater; import java.util.ArrayList; -import java.util.Objects; import java.util.function.Consumer; import androidx.annotation.DrawableRes; @@ -146,6 +144,8 @@ public class SettingsFragment extends MastodonToolbarFragment{ GlobalUserPreferences.save(); needAppRestart=true; })); + items.add(new SwitchItem(R.string.sk_settings_show_differentiated_notification_icons, R.drawable.ic_fluent_earth_24_regular, GlobalUserPreferences.showDifferentiatedPushNoticationIcons, this::onNotificationStyleChanged)); + items.add(new HeaderItem(R.string.home_timeline)); items.add(new SwitchItem(R.string.sk_settings_show_replies, R.drawable.ic_fluent_chat_multiple_24_regular, GlobalUserPreferences.showReplies, i->{ @@ -355,6 +355,12 @@ public class SettingsFragment extends MastodonToolbarFragment{ needUpdateNotificationSettings=true; } + private void onNotificationStyleChanged(SwitchItem item){ + GlobalUserPreferences.showDifferentiatedPushNoticationIcons=item.checked; + GlobalUserPreferences.save(); + } + + private void onNotificationsPolicyChanged(PushSubscription.Policy policy){ PushSubscription subscription=getPushSubscription(); PushSubscription.Policy prevPolicy=subscription.policy; diff --git a/mastodon/src/main/res/values/strings_sk.xml b/mastodon/src/main/res/values/strings_sk.xml index 0f700d6f1..1011dc6b7 100644 --- a/mastodon/src/main/res/values/strings_sk.xml +++ b/mastodon/src/main/res/values/strings_sk.xml @@ -78,6 +78,7 @@ Delete all Are you sure you want to clear all notifications\? Enable deleting notifications + Custom icons for interactions Publish button text Customize Publish button text Hide translate button in timeline