From 3a962c7c0547a002ab15c075dae617f5fef91bb0 Mon Sep 17 00:00:00 2001 From: LucasGGamerM Date: Sat, 31 Dec 2022 13:47:55 -0300 Subject: [PATCH] Refactoring the uniform notification icon setting --- .../joinmastodon/android/GlobalUserPreferences.java | 6 +++--- .../joinmastodon/android/PushNotificationReceiver.java | 4 +--- .../android/fragments/SettingsFragment.java | 10 ++++------ mastodon/src/main/res/values/strings_sk.xml | 1 + 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java b/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java index 19fd6cce8..cebb4ab61 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java +++ b/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java @@ -28,7 +28,7 @@ public class GlobalUserPreferences{ public static boolean disableSwipe; public static boolean disableDividers; public static boolean voteButtonForSingleChoice; - public static boolean showDifferentiatedPushNoticationIcons; + public static boolean showUniformPushNoticationIcons; public static boolean relocatePublishButton; public static boolean enableDeleteNotifications; public static ThemePreference theme; @@ -54,7 +54,7 @@ public class GlobalUserPreferences{ showReplies=prefs.getBoolean("showReplies", true); showBoosts=prefs.getBoolean("showBoosts", true); loadNewPosts=prefs.getBoolean("loadNewPosts", true); - showDifferentiatedPushNoticationIcons=prefs.getBoolean("showDifferentiatedPushNoticationIcons", false); + showUniformPushNoticationIcons=prefs.getBoolean("showUniformPushNotificationIcons", true); showFederatedTimeline=prefs.getBoolean("showFederatedTimeline", !BuildConfig.BUILD_TYPE.equals("playRelease")); showInteractionCounts=prefs.getBoolean("showInteractionCounts", false); alwaysExpandContentWarnings=prefs.getBoolean("alwaysExpandContentWarnings", false); @@ -94,7 +94,7 @@ public class GlobalUserPreferences{ .putBoolean("disableSwipe", disableSwipe) .putBoolean("disableDividers", disableDividers) .putBoolean("relocatePublishButton", relocatePublishButton) - .putBoolean("showDifferentiatedPushNoticationIcons", showDifferentiatedPushNoticationIcons) + .putBoolean("showUniformPushNotificationIcons", showUniformPushNoticationIcons) .putBoolean("enableDeleteNotifications", enableDeleteNotifications) .putInt("theme", theme.ordinal()) .putString("color", color.name()) diff --git a/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java b/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java index d56356ded..3a8f01861 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java +++ b/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java @@ -8,9 +8,7 @@ import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; -import android.graphics.Bitmap; import android.graphics.drawable.Drawable; -import android.graphics.drawable.Icon; import android.os.Build; import android.os.Bundle; import android.text.TextUtils; @@ -143,7 +141,7 @@ public class PushNotificationReceiver extends BroadcastReceiver{ .setCategory(Notification.CATEGORY_SOCIAL) .setAutoCancel(true) .setColor(context.getColor(R.color.shortcut_icon_background)); - if(GlobalUserPreferences.showDifferentiatedPushNoticationIcons){ + if(!GlobalUserPreferences.showUniformPushNoticationIcons){ 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); 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 c39a28fb3..cedc401b8 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java @@ -10,7 +10,6 @@ import android.graphics.Rect; import android.os.Build; import android.os.Bundle; import android.util.TypedValue; - import android.provider.Settings; import android.view.Gravity; import android.view.LayoutInflater; import android.view.MenuItem; @@ -20,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.LinearLayout; @@ -131,6 +128,7 @@ public class SettingsFragment extends MastodonToolbarFragment{ case NORD -> R.string.sk_color_palette_nord; }); })); + items.add(new SwitchItem(R.string.sk_settings_uniform_icon_for_notifications, R.drawable.ic_ntf_logo, GlobalUserPreferences.showUniformPushNoticationIcons, this::onNotificationStyleChanged)); items.add(new HeaderItem(R.string.settings_behavior)); items.add(new SwitchItem(R.string.sk_settings_show_federated_timeline, R.drawable.ic_fluent_earth_24_regular, GlobalUserPreferences.showFederatedTimeline, i->{ @@ -159,7 +157,7 @@ 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 SwitchItem(R.string.sk_settings_show_differentiated_notification_icons, R.drawable.ic_ntf_logo, GlobalUserPreferences.showUniformPushNoticationIcons, this::onNotificationStyleChanged)); items.add(new SwitchItem(R.string.sk_disable_dividers, R.drawable.ic_fluent_timeline_24_regular, GlobalUserPreferences.disableDividers, i->{ GlobalUserPreferences.disableDividers=i.checked; GlobalUserPreferences.save(); @@ -237,7 +235,7 @@ public class SettingsFragment extends MastodonToolbarFragment{ GlobalUserPreferences.recentLanguages.remove(accountID); GlobalUserPreferences.save(); }))); - items.add(new TextItem(R.string.log_out, this::confirmLogOut)); +// items.add(new TextItem(R.string.log_out, this::confirmLogOut)); items.add(new FooterItem(getString(R.string.sk_settings_app_version, BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE))); } @@ -402,7 +400,7 @@ public class SettingsFragment extends MastodonToolbarFragment{ } private void onNotificationStyleChanged(SwitchItem item){ - GlobalUserPreferences.showDifferentiatedPushNoticationIcons=item.checked; + GlobalUserPreferences.showUniformPushNoticationIcons=item.checked; GlobalUserPreferences.save(); } diff --git a/mastodon/src/main/res/values/strings_sk.xml b/mastodon/src/main/res/values/strings_sk.xml index a25e7bb3a..fece608f0 100644 --- a/mastodon/src/main/res/values/strings_sk.xml +++ b/mastodon/src/main/res/values/strings_sk.xml @@ -107,4 +107,5 @@ Reply with other account Resource could not be found Looking it up on %s + Uniform icon for all notifications \ No newline at end of file