Remove locked notification none mode

This commit is contained in:
ajp_anton
2026-05-30 17:51:11 +00:00
parent f66326f613
commit bd7b07def0
9 changed files with 20 additions and 209 deletions
@@ -325,7 +325,6 @@ public final class UnlockedIconSnapshotRenderController {
} }
if (scene.isLockscreen()) { if (scene.isLockscreen()) {
return settings.layoutNotifEnabledLockscreen return settings.layoutNotifEnabledLockscreen
&& !"none".equals(settings.lockedNotificationMode)
&& scene.notificationDisplayStyle() != se.ajpanton.statusbartweak.runtime.mode.NotificationDisplayStyle.NONE && scene.notificationDisplayStyle() != se.ajpanton.statusbartweak.runtime.mode.NotificationDisplayStyle.NONE
&& scene.notificationDisplayStyle() != se.ajpanton.statusbartweak.runtime.mode.NotificationDisplayStyle.CARDS; && scene.notificationDisplayStyle() != se.ajpanton.statusbartweak.runtime.mode.NotificationDisplayStyle.CARDS;
} }
@@ -550,9 +550,6 @@ final class UnlockedLayoutPlanner {
private int notificationCountForScene(SbtSettings settings, SceneKey scene) { private int notificationCountForScene(SbtSettings settings, SceneKey scene) {
if (scene != null && scene.isLockscreen()) { if (scene != null && scene.isLockscreen()) {
if ("none".equals(settings.lockedNotificationMode)) {
return 0;
}
NotificationDisplayStyle style = scene.notificationDisplayStyle(); NotificationDisplayStyle style = scene.notificationDisplayStyle();
if (style == NotificationDisplayStyle.NONE || style == NotificationDisplayStyle.CARDS) { if (style == NotificationDisplayStyle.NONE || style == NotificationDisplayStyle.CARDS) {
return 0; return 0;
@@ -688,7 +688,7 @@ public final class SbtSettings {
} else { } else {
this.appIconExceptionRules = Collections.emptyMap(); this.appIconExceptionRules = Collections.emptyMap();
} }
this.lockedNotificationMode = lockedNotificationMode != null ? lockedNotificationMode : "dot"; this.lockedNotificationMode = sanitizeLockedNotificationMode(lockedNotificationMode);
this.debugVisualizeNotificationContainer = debugVisualizeNotificationContainer; this.debugVisualizeNotificationContainer = debugVisualizeNotificationContainer;
this.debugVisualizeStatusContainer = debugVisualizeStatusContainer; this.debugVisualizeStatusContainer = debugVisualizeStatusContainer;
this.debugVisualizeClockContainer = debugVisualizeClockContainer; this.debugVisualizeClockContainer = debugVisualizeClockContainer;
@@ -815,6 +815,13 @@ public final class SbtSettings {
); );
} }
private static String sanitizeLockedNotificationMode(String mode) {
if ("cards".equals(mode) || "icons".equals(mode) || "dot".equals(mode)) {
return mode;
}
return "dot";
}
public static SbtSettings from(Context context) { public static SbtSettings from(Context context) {
if (context == null) { if (context == null) {
return defaults(); return defaults();
@@ -26,7 +26,6 @@ import java.util.Map;
import se.ajpanton.statusbartweak.R; import se.ajpanton.statusbartweak.R;
import se.ajpanton.statusbartweak.shell.debug.DebugNotifications; import se.ajpanton.statusbartweak.shell.debug.DebugNotifications;
import se.ajpanton.statusbartweak.shell.debug.NotificationDisplayStyleSettings;
import se.ajpanton.statusbartweak.shell.settings.ClockCameraTypeSupport; import se.ajpanton.statusbartweak.shell.settings.ClockCameraTypeSupport;
import se.ajpanton.statusbartweak.shell.settings.SbtDefaults; import se.ajpanton.statusbartweak.shell.settings.SbtDefaults;
import se.ajpanton.statusbartweak.shell.settings.SbtSettings; import se.ajpanton.statusbartweak.shell.settings.SbtSettings;
@@ -62,10 +61,6 @@ public class IconsDebugFragment extends Fragment {
root.findViewById(R.id.debug_visualize_camera_cutout_switch); root.findViewById(R.id.debug_visualize_camera_cutout_switch);
MaterialButton restartSystemUiButton = root.findViewById(R.id.debug_restart_systemui_button); MaterialButton restartSystemUiButton = root.findViewById(R.id.debug_restart_systemui_button);
SwitchMaterial cycleIconsSwitch = root.findViewById(R.id.debug_cycle_icons_switch); SwitchMaterial cycleIconsSwitch = root.findViewById(R.id.debug_cycle_icons_switch);
TextView notificationStyleCurrent = root.findViewById(R.id.debug_notification_style_current);
MaterialButton notificationStyleCards = root.findViewById(R.id.debug_notification_style_cards);
MaterialButton notificationStyleIcons = root.findViewById(R.id.debug_notification_style_icons);
MaterialButton notificationStyleDot = root.findViewById(R.id.debug_notification_style_dot);
TextView currentCameraIdentified = root.findViewById(R.id.debug_camera_current_identified); TextView currentCameraIdentified = root.findViewById(R.id.debug_camera_current_identified);
LinearLayout currentCameraOverrideRow = root.findViewById(R.id.debug_camera_current_override_row); LinearLayout currentCameraOverrideRow = root.findViewById(R.id.debug_camera_current_override_row);
TextView currentCameraOverride = root.findViewById(R.id.debug_camera_current_override); TextView currentCameraOverride = root.findViewById(R.id.debug_camera_current_override);
@@ -112,11 +107,6 @@ public class IconsDebugFragment extends Fragment {
SbtSettings.KEY_DEBUG_VISUALIZE_CAMERA_CUTOUT, SbtSettings.KEY_DEBUG_VISUALIZE_CAMERA_CUTOUT,
SbtDefaults.DEBUG_VISUALIZE_CAMERA_CUTOUT_DEFAULT); SbtDefaults.DEBUG_VISUALIZE_CAMERA_CUTOUT_DEFAULT);
bindRestartSystemUiButton(restartSystemUiButton); bindRestartSystemUiButton(restartSystemUiButton);
bindNotificationStyleControls(
notificationStyleCurrent,
notificationStyleCards,
notificationStyleIcons,
notificationStyleDot);
updateVisualizerSwitchAvailability( updateVisualizerSwitchAvailability(
prefs, prefs,
visualizeNotificationContainerSwitch, visualizeNotificationContainerSwitch,
@@ -198,76 +188,6 @@ public class IconsDebugFragment extends Fragment {
restartButton.setOnClickListener(v -> restartSystemUi()); restartButton.setOnClickListener(v -> restartSystemUi());
} }
private void bindNotificationStyleControls(
TextView currentView,
MaterialButton cardsButton,
MaterialButton iconsButton,
MaterialButton dotButton
) {
updateNotificationStyleUi(currentView);
if (cardsButton != null) {
cardsButton.setOnClickListener(v -> writeNotificationStyle(
NotificationDisplayStyleSettings.Style.CARDS,
currentView));
}
if (iconsButton != null) {
iconsButton.setOnClickListener(v -> writeNotificationStyle(
NotificationDisplayStyleSettings.Style.ICONS,
currentView));
}
if (dotButton != null) {
dotButton.setOnClickListener(v -> writeNotificationStyle(
NotificationDisplayStyleSettings.Style.DOT,
currentView));
}
}
private void updateNotificationStyleUi(TextView currentView) {
Context context = requireContext();
NotificationDisplayStyleSettings.State state =
NotificationDisplayStyleSettings.read(context);
if (currentView != null) {
currentView.setText(getString(
R.string.debug_notification_style_current,
readableNotificationStyle(state.style())));
}
}
private void writeNotificationStyle(
NotificationDisplayStyleSettings.Style style,
TextView currentView
) {
Context appContext = requireContext().getApplicationContext();
new Thread(() -> {
boolean success = NotificationDisplayStyleSettings.write(appContext, style);
if (!isAdded()) {
return;
}
requireActivity().runOnUiThread(() -> {
updateNotificationStyleUi(currentView);
Toast.makeText(
requireContext(),
success
? R.string.debug_notification_style_write_done
: R.string.debug_notification_style_write_failed,
success ? Toast.LENGTH_SHORT : Toast.LENGTH_LONG).show();
});
}, "StatusBarTweak:NotificationStyleWrite").start();
}
private String readableNotificationStyle(NotificationDisplayStyleSettings.Style style) {
if (style == NotificationDisplayStyleSettings.Style.CARDS) {
return getString(R.string.debug_notification_style_cards);
}
if (style == NotificationDisplayStyleSettings.Style.ICONS) {
return getString(R.string.debug_notification_style_icons);
}
if (style == NotificationDisplayStyleSettings.Style.DOT) {
return getString(R.string.debug_notification_style_dot);
}
return getString(R.string.debug_notification_style_unknown);
}
private void updateVisualizerSwitchAvailability(SharedPreferences prefs, private void updateVisualizerSwitchAvailability(SharedPreferences prefs,
SwitchMaterial notificationSwitch, SwitchMaterial notificationSwitch,
SwitchMaterial statusSwitch, SwitchMaterial statusSwitch,
@@ -90,8 +90,7 @@ public final class LayoutHomeFragment extends Fragment {
requireContext(), requireContext(),
prefs, prefs,
lockedModeGroup, lockedModeGroup,
lockedModeHint, lockedModeHint);
layoutEnabled);
} }
private View paddingCard(Context context, SharedPreferences prefs) { private View paddingCard(Context context, SharedPreferences prefs) {
@@ -16,7 +16,6 @@ final class LockedNotificationModeUi {
static final String MODE_CARDS = "cards"; static final String MODE_CARDS = "cards";
static final String MODE_ICONS = "icons"; static final String MODE_ICONS = "icons";
static final String MODE_DOT = "dot"; static final String MODE_DOT = "dot";
static final String MODE_NONE = "none";
private LockedNotificationModeUi() { private LockedNotificationModeUi() {
} }
@@ -25,10 +24,9 @@ final class LockedNotificationModeUi {
Context context, Context context,
SharedPreferences prefs, SharedPreferences prefs,
RadioGroup group, RadioGroup group,
TextView hint, TextView hint
boolean layoutEnabled
) { ) {
bind(context, prefs, group, hint, layoutEnabled, null); bind(context, prefs, group, hint, null);
} }
static void bind( static void bind(
@@ -36,7 +34,6 @@ final class LockedNotificationModeUi {
SharedPreferences prefs, SharedPreferences prefs,
RadioGroup group, RadioGroup group,
TextView hint, TextView hint,
boolean layoutEnabled,
Runnable onChanged Runnable onChanged
) { ) {
if (context == null || prefs == null || group == null) { if (context == null || prefs == null || group == null) {
@@ -46,45 +43,29 @@ final class LockedNotificationModeUi {
RadioButton cards = button(context, R.string.debug_notification_style_cards, MODE_CARDS); RadioButton cards = button(context, R.string.debug_notification_style_cards, MODE_CARDS);
RadioButton icons = button(context, R.string.debug_notification_style_icons, MODE_ICONS); RadioButton icons = button(context, R.string.debug_notification_style_icons, MODE_ICONS);
RadioButton dot = button(context, R.string.debug_notification_style_dot, MODE_DOT); RadioButton dot = button(context, R.string.debug_notification_style_dot, MODE_DOT);
RadioButton none = button(context, R.string.layout_locked_notifications_none, MODE_NONE);
group.removeAllViews(); group.removeAllViews();
group.addView(cards); group.addView(cards);
group.addView(icons); group.addView(icons);
group.addView(dot); group.addView(dot);
group.addView(none);
String stored = prefs.getString(SbtSettings.KEY_LOCKED_NOTIFICATION_MODE, MODE_DOT);
NotificationDisplayStyleSettings.Style androidStyle = NotificationDisplayStyleSettings.Style androidStyle =
NotificationDisplayStyleSettings.read(context).style(); NotificationDisplayStyleSettings.read(context).style();
String current = currentMode(androidStyle, stored, layoutEnabled); String current = currentMode(androidStyle);
if (layoutEnabled && MODE_NONE.equals(stored)
&& androidStyle != NotificationDisplayStyleSettings.Style.DOT) {
writeMode(context, MODE_NONE);
}
group.check(idForMode(group, current)); group.check(idForMode(group, current));
none.setEnabled(layoutEnabled);
none.setAlpha(layoutEnabled ? 1f : 0.45f);
if (hint != null) { if (hint != null) {
boolean rememberedNone = MODE_NONE.equals(stored) && !layoutEnabled; hint.setText(R.string.layout_locked_notifications_hint);
hint.setText(rememberedNone
? R.string.layout_locked_notifications_none_disabled
: R.string.layout_locked_notifications_hint);
} }
group.setOnCheckedChangeListener((radioGroup, checkedId) -> { group.setOnCheckedChangeListener((radioGroup, checkedId) -> {
String mode = modeForId(radioGroup, checkedId); String mode = modeForId(radioGroup, checkedId);
if (MODE_NONE.equals(mode) && !layoutEnabled) {
radioGroup.check(idForMode(radioGroup, MODE_DOT));
return;
}
boolean ok = writeMode(context, mode); boolean ok = writeMode(context, mode);
if (!ok) { if (!ok) {
Toast.makeText( Toast.makeText(
context, context,
R.string.debug_notification_style_write_failed, R.string.debug_notification_style_write_failed,
Toast.LENGTH_SHORT).show(); Toast.LENGTH_SHORT).show();
bind(context, prefs, group, hint, layoutEnabled); bind(context, prefs, group, hint);
return; return;
} }
prefs.edit().putString(SbtSettings.KEY_LOCKED_NOTIFICATION_MODE, mode).apply(); prefs.edit().putString(SbtSettings.KEY_LOCKED_NOTIFICATION_MODE, mode).apply();
@@ -95,21 +76,13 @@ final class LockedNotificationModeUi {
}); });
} }
static String currentMode(Context context, SharedPreferences prefs, boolean layoutEnabled) { static String currentMode(Context context) {
String stored = prefs.getString(SbtSettings.KEY_LOCKED_NOTIFICATION_MODE, MODE_DOT);
NotificationDisplayStyleSettings.Style style = NotificationDisplayStyleSettings.Style style =
NotificationDisplayStyleSettings.read(context).style(); NotificationDisplayStyleSettings.read(context).style();
return currentMode(style, stored, layoutEnabled); return currentMode(style);
} }
private static String currentMode( private static String currentMode(NotificationDisplayStyleSettings.Style androidStyle) {
NotificationDisplayStyleSettings.Style androidStyle,
String stored,
boolean layoutEnabled
) {
if (MODE_NONE.equals(stored) && layoutEnabled) {
return MODE_NONE;
}
if (androidStyle == NotificationDisplayStyleSettings.Style.CARDS) { if (androidStyle == NotificationDisplayStyleSettings.Style.CARDS) {
return MODE_CARDS; return MODE_CARDS;
} }
@@ -66,18 +66,16 @@ abstract class LockedSceneLayoutFragment extends Fragment {
} }
private void bindMode(Context context, SharedPreferences prefs) { private void bindMode(Context context, SharedPreferences prefs) {
boolean layoutEnabled = prefs.getBoolean(SbtSettings.KEY_CLOCK_ENABLED, SbtDefaults.CLOCK_ENABLED_DEFAULT);
LockedNotificationModeUi.bind( LockedNotificationModeUi.bind(
context, context,
prefs, prefs,
modeGroup, modeGroup,
modeHint, modeHint,
layoutEnabled,
() -> rebuildDynamic( () -> rebuildDynamic(
context, context,
prefs, prefs,
LockedNotificationModeUi.currentMode(context, prefs, layoutEnabled))); LockedNotificationModeUi.currentMode(context)));
rebuildDynamic(context, prefs, LockedNotificationModeUi.currentMode(context, prefs, layoutEnabled)); rebuildDynamic(context, prefs, LockedNotificationModeUi.currentMode(context));
} }
private void rebuildDynamic(Context context, SharedPreferences prefs, String mode) { private void rebuildDynamic(Context context, SharedPreferences prefs, String mode) {
@@ -168,7 +166,7 @@ abstract class LockedSceneLayoutFragment extends Fragment {
SbtDefaults.LAYOUT_STATUS_VERTICAL_OFFSET_PX_DEFAULT)); SbtDefaults.LAYOUT_STATUS_VERTICAL_OFFSET_PX_DEFAULT));
if (LockedNotificationModeUi.MODE_CARDS.equals(mode)) { if (LockedNotificationModeUi.MODE_CARDS.equals(mode)) {
cardsByOrderKey.put("notifications", cardsNotificationCard(context, prefs)); cardsByOrderKey.put("notifications", cardsNotificationCard(context, prefs));
} else if (!LockedNotificationModeUi.MODE_NONE.equals(mode)) { } else {
cardsByOrderKey.put("notifications", configuredIconContainersCardFromLayout( cardsByOrderKey.put("notifications", configuredIconContainersCardFromLayout(
context, context,
prefs, prefs,
@@ -73,81 +73,6 @@
</LinearLayout> </LinearLayout>
</com.google.android.material.card.MaterialCardView> </com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:cardUseCompatPadding="true"
app:strokeColor="@color/sbt_card_outline"
app:strokeWidth="1dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:letterSpacing="0.03"
android:text="@string/debug_section_android_notification_style"
android:textAllCaps="true"
android:textAppearance="?attr/textAppearanceSubtitle1"
android:textStyle="bold" />
<TextView
android:id="@+id/debug_notification_style_current"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:textAppearance="?attr/textAppearanceSubtitle2" />
<TextView
android:id="@+id/debug_notification_style_hint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/debug_notification_style_hint"
android:textAppearance="?attr/textAppearanceBody2" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<com.google.android.material.button.MaterialButton
android:id="@+id/debug_notification_style_cards"
style="?attr/materialButtonOutlinedStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/debug_notification_style_cards" />
<com.google.android.material.button.MaterialButton
android:id="@+id/debug_notification_style_icons"
style="?attr/materialButtonOutlinedStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_weight="1"
android:text="@string/debug_notification_style_icons" />
<com.google.android.material.button.MaterialButton
android:id="@+id/debug_notification_style_dot"
style="?attr/materialButtonOutlinedStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_weight="1"
android:text="@string/debug_notification_style_dot" />
</LinearLayout>
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView <com.google.android.material.card.MaterialCardView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
-7
View File
@@ -30,15 +30,10 @@
<string name="debug_restart_systemui">Restart SystemUI</string> <string name="debug_restart_systemui">Restart SystemUI</string>
<string name="debug_restart_systemui_started">SystemUI restart requested.</string> <string name="debug_restart_systemui_started">SystemUI restart requested.</string>
<string name="debug_restart_systemui_failed">Could not restart SystemUI. Root shell failed.</string> <string name="debug_restart_systemui_failed">Could not restart SystemUI. Root shell failed.</string>
<string name="debug_section_android_notification_style">Android notification style</string>
<string name="debug_notification_style_current">Current: %1$s</string>
<string name="debug_notification_style_hint">Temporary control for Samsung lockscreen/AOD notification style. Writes use root shell.</string>
<string name="debug_notification_style_cards">Cards</string> <string name="debug_notification_style_cards">Cards</string>
<string name="debug_notification_style_icons">Icons</string> <string name="debug_notification_style_icons">Icons</string>
<string name="debug_notification_style_dot">Dot</string> <string name="debug_notification_style_dot">Dot</string>
<string name="debug_notification_style_unknown">unknown</string>
<string name="debug_notification_style_write_failed">Could not write notification style. Root shell failed.</string> <string name="debug_notification_style_write_failed">Could not write notification style. Root shell failed.</string>
<string name="debug_notification_style_write_done">Notification style changed.</string>
<string name="debug_section_notification_icons">Notification icons</string> <string name="debug_section_notification_icons">Notification icons</string>
<string name="debug_cycle_icons_label">Cycle debug icons</string> <string name="debug_cycle_icons_label">Cycle debug icons</string>
<string name="debug_cycle_icons_hint">Cycles visible debug icons between 0 and the configured count every 2 seconds.</string> <string name="debug_cycle_icons_hint">Cycles visible debug icons between 0 and the configured count every 2 seconds.</string>
@@ -177,8 +172,6 @@
<string name="layout_icon_container_count">Number of containers</string> <string name="layout_icon_container_count">Number of containers</string>
<string name="layout_locked_notifications_title">Locked notifications mode</string> <string name="layout_locked_notifications_title">Locked notifications mode</string>
<string name="layout_locked_notifications_hint">Mirrors the Samsung notification display style for AOD and lockscreen.</string> <string name="layout_locked_notifications_hint">Mirrors the Samsung notification display style for AOD and lockscreen.</string>
<string name="layout_locked_notifications_none">None</string>
<string name="layout_locked_notifications_none_disabled">None is remembered, but Layout OFF uses Dot.</string>
<string name="layout_misc_title">Misc</string> <string name="layout_misc_title">Misc</string>
<string name="label_max_unlocked_icons_per_row">Max unlocked icons per row</string> <string name="label_max_unlocked_icons_per_row">Max unlocked icons per row</string>
<string name="layout_padding_title">Padding</string> <string name="layout_padding_title">Padding</string>