Refactoring the uniform notification icon setting

This commit is contained in:
LucasGGamerM 2022-12-31 13:47:55 -03:00
parent 99e3658938
commit 3a962c7c05
4 changed files with 9 additions and 12 deletions

View File

@ -28,7 +28,7 @@ public class GlobalUserPreferences{
public static boolean disableSwipe; public static boolean disableSwipe;
public static boolean disableDividers; public static boolean disableDividers;
public static boolean voteButtonForSingleChoice; public static boolean voteButtonForSingleChoice;
public static boolean showDifferentiatedPushNoticationIcons; public static boolean showUniformPushNoticationIcons;
public static boolean relocatePublishButton; public static boolean relocatePublishButton;
public static boolean enableDeleteNotifications; public static boolean enableDeleteNotifications;
public static ThemePreference theme; public static ThemePreference theme;
@ -54,7 +54,7 @@ public class GlobalUserPreferences{
showReplies=prefs.getBoolean("showReplies", true); showReplies=prefs.getBoolean("showReplies", true);
showBoosts=prefs.getBoolean("showBoosts", true); showBoosts=prefs.getBoolean("showBoosts", true);
loadNewPosts=prefs.getBoolean("loadNewPosts", 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")); showFederatedTimeline=prefs.getBoolean("showFederatedTimeline", !BuildConfig.BUILD_TYPE.equals("playRelease"));
showInteractionCounts=prefs.getBoolean("showInteractionCounts", false); showInteractionCounts=prefs.getBoolean("showInteractionCounts", false);
alwaysExpandContentWarnings=prefs.getBoolean("alwaysExpandContentWarnings", false); alwaysExpandContentWarnings=prefs.getBoolean("alwaysExpandContentWarnings", false);
@ -94,7 +94,7 @@ public class GlobalUserPreferences{
.putBoolean("disableSwipe", disableSwipe) .putBoolean("disableSwipe", disableSwipe)
.putBoolean("disableDividers", disableDividers) .putBoolean("disableDividers", disableDividers)
.putBoolean("relocatePublishButton", relocatePublishButton) .putBoolean("relocatePublishButton", relocatePublishButton)
.putBoolean("showDifferentiatedPushNoticationIcons", showDifferentiatedPushNoticationIcons) .putBoolean("showUniformPushNotificationIcons", showUniformPushNoticationIcons)
.putBoolean("enableDeleteNotifications", enableDeleteNotifications) .putBoolean("enableDeleteNotifications", enableDeleteNotifications)
.putInt("theme", theme.ordinal()) .putInt("theme", theme.ordinal())
.putString("color", color.name()) .putString("color", color.name())

View File

@ -8,9 +8,7 @@ import android.app.PendingIntent;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.graphics.drawable.Icon;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.text.TextUtils; import android.text.TextUtils;
@ -143,7 +141,7 @@ public class PushNotificationReceiver extends BroadcastReceiver{
.setCategory(Notification.CATEGORY_SOCIAL) .setCategory(Notification.CATEGORY_SOCIAL)
.setAutoCancel(true) .setAutoCancel(true)
.setColor(context.getColor(R.color.shortcut_icon_background)); .setColor(context.getColor(R.color.shortcut_icon_background));
if(GlobalUserPreferences.showDifferentiatedPushNoticationIcons){ if(!GlobalUserPreferences.showUniformPushNoticationIcons){
switch (pn.notificationType) { switch (pn.notificationType) {
case FAVORITE -> builder.setSmallIcon(R.drawable.ic_fluent_star_24_filled); 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 REBLOG -> builder.setSmallIcon(R.drawable.ic_fluent_arrow_repeat_all_24_filled);

View File

@ -10,7 +10,6 @@ import android.graphics.Rect;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.util.TypedValue; import android.util.TypedValue;
import android.provider.Settings;
import android.view.Gravity; import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MenuItem; import android.view.MenuItem;
@ -20,8 +19,6 @@ import android.view.WindowInsets;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.animation.LinearInterpolator; import android.view.animation.LinearInterpolator;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
@ -131,6 +128,7 @@ public class SettingsFragment extends MastodonToolbarFragment{
case NORD -> R.string.sk_color_palette_nord; 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 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->{ 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(); GlobalUserPreferences.save();
needAppRestart=true; 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->{ items.add(new SwitchItem(R.string.sk_disable_dividers, R.drawable.ic_fluent_timeline_24_regular, GlobalUserPreferences.disableDividers, i->{
GlobalUserPreferences.disableDividers=i.checked; GlobalUserPreferences.disableDividers=i.checked;
GlobalUserPreferences.save(); GlobalUserPreferences.save();
@ -237,7 +235,7 @@ public class SettingsFragment extends MastodonToolbarFragment{
GlobalUserPreferences.recentLanguages.remove(accountID); GlobalUserPreferences.recentLanguages.remove(accountID);
GlobalUserPreferences.save(); 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))); 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){ private void onNotificationStyleChanged(SwitchItem item){
GlobalUserPreferences.showDifferentiatedPushNoticationIcons=item.checked; GlobalUserPreferences.showUniformPushNoticationIcons=item.checked;
GlobalUserPreferences.save(); GlobalUserPreferences.save();
} }

View File

@ -107,4 +107,5 @@
<string name="sk_reply_as">Reply with other account</string> <string name="sk_reply_as">Reply with other account</string>
<string name="sk_resource_not_found">Resource could not be found</string> <string name="sk_resource_not_found">Resource could not be found</string>
<string name="sk_loading_resource_on_instance_title">Looking it up on %s</string> <string name="sk_loading_resource_on_instance_title">Looking it up on %s</string>
<string name="sk_settings_uniform_icon_for_notifications">Uniform icon for all notifications</string>
</resources> </resources>