Add experimental generic AOD compatibility
This commit is contained in:
+23
-4
@@ -1434,7 +1434,7 @@ final class StockLayoutCanvasController {
|
||||
}
|
||||
hideLockscreenCardsNotificationHost(root);
|
||||
if (activeScene.notificationDisplayStyle() == NotificationDisplayStyle.CARDS
|
||||
&& isAodLayoutRoot(root)) {
|
||||
&& isAodLayoutRoot(root, activeScene)) {
|
||||
renderAodCardsNotificationStripIfNeeded(root, settings, activeScene);
|
||||
} else {
|
||||
removeAodCardsNotificationHost(root);
|
||||
@@ -2308,7 +2308,7 @@ final class StockLayoutCanvasController {
|
||||
boolean unlockedScene = activeScene != null && activeScene.isUnlocked();
|
||||
boolean aodScene = activeScene != null && activeScene.isAod();
|
||||
boolean rootDirty = dirtyUnlockedLayoutRoots.remove(root);
|
||||
boolean aodLayoutRoot = aodScene && isAodLayoutRoot(root);
|
||||
boolean aodLayoutRoot = aodScene && isAodLayoutRoot(root, activeScene);
|
||||
boolean hasAodLayoutPlan = aodScene && unlockedIconRenderController.hasLayoutPlan(root);
|
||||
boolean layoutRoot = aodScene ? aodLayoutRoot : statusBarRoot;
|
||||
if (aodScene
|
||||
@@ -4996,7 +4996,8 @@ final class StockLayoutCanvasController {
|
||||
SceneKey activeScene
|
||||
) {
|
||||
if (!isStatusBarLayoutRoot(root, activeScene)
|
||||
&& !(activeScene != null && activeScene.isAod() && isAodLayoutRoot(root))) {
|
||||
&& !(activeScene != null && activeScene.isAod()
|
||||
&& isAodLayoutRoot(root, activeScene))) {
|
||||
return null;
|
||||
}
|
||||
if (activeScene != null
|
||||
@@ -5100,7 +5101,25 @@ final class StockLayoutCanvasController {
|
||||
}
|
||||
|
||||
private boolean isAodLayoutRoot(View root) {
|
||||
return isAodRoot(root) || hasConfirmedAodPluginDescendant(root);
|
||||
return isAodLayoutRoot(root, null);
|
||||
}
|
||||
|
||||
private boolean isAodLayoutRoot(View root, SceneKey activeScene) {
|
||||
return isAodRoot(root)
|
||||
|| hasConfirmedAodPluginDescendant(root)
|
||||
|| isExperimentalAodStatusBarRoot(root, activeScene);
|
||||
}
|
||||
|
||||
private boolean isExperimentalAodStatusBarRoot(View root, SceneKey activeScene) {
|
||||
if (root == null
|
||||
|| activeScene == null
|
||||
|| !activeScene.isAod()
|
||||
|| isSamsungDevice()
|
||||
|| !isUnlockedStatusBarRoot(root)) {
|
||||
return false;
|
||||
}
|
||||
SbtSettings settings = RuntimeSettingsCache.get(root.getContext());
|
||||
return settings.debugExperimentalAodStatusbarRoot;
|
||||
}
|
||||
|
||||
private boolean hasConfirmedAodPluginDescendant(View root) {
|
||||
|
||||
+5
-1
@@ -2,6 +2,7 @@ package se.ajpanton.statusbartweak.runtime.render;
|
||||
|
||||
import android.app.KeyguardManager;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
@@ -464,7 +465,10 @@ public final class UnlockedIconSnapshotRenderController {
|
||||
NotificationDisplayStyle style = scene.notificationDisplayStyle();
|
||||
return settings.layoutNotifEnabledAod
|
||||
&& (style == NotificationDisplayStyle.ICONS
|
||||
|| style == NotificationDisplayStyle.DOT);
|
||||
|| style == NotificationDisplayStyle.DOT
|
||||
|| (style == NotificationDisplayStyle.UNKNOWN
|
||||
&& settings.debugExperimentalAodStatusbarRoot
|
||||
&& !"samsung".equalsIgnoreCase(Build.MANUFACTURER)));
|
||||
}
|
||||
return settings.layoutNotifEnabledUnlocked;
|
||||
}
|
||||
|
||||
+10
-1
@@ -1,6 +1,7 @@
|
||||
package se.ajpanton.statusbartweak.runtime.render;
|
||||
|
||||
import android.graphics.Rect;
|
||||
import android.os.Build;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
@@ -856,7 +857,9 @@ final class UnlockedLayoutPlanner {
|
||||
if (style == NotificationDisplayStyle.DOT) {
|
||||
return settings.layoutNotifEnabledAod ? 1 : 0;
|
||||
}
|
||||
if (style != NotificationDisplayStyle.ICONS) {
|
||||
if (style != NotificationDisplayStyle.ICONS
|
||||
&& !(style == NotificationDisplayStyle.UNKNOWN
|
||||
&& isExperimentalGenericAod(settings))) {
|
||||
return 0;
|
||||
}
|
||||
return settings.layoutNotifEnabledAod ? settings.layoutNotifAodCount : 0;
|
||||
@@ -870,6 +873,12 @@ final class UnlockedLayoutPlanner {
|
||||
&& scene.notificationDisplayStyle() == NotificationDisplayStyle.DOT;
|
||||
}
|
||||
|
||||
private boolean isExperimentalGenericAod(SbtSettings settings) {
|
||||
return settings != null
|
||||
&& settings.debugExperimentalAodStatusbarRoot
|
||||
&& !"samsung".equalsIgnoreCase(Build.MANUFACTURER);
|
||||
}
|
||||
|
||||
private ArrayList<SnapshotPlacement> unreadNotificationPlacements(
|
||||
ArrayList<SnapshotPlacement> placements
|
||||
) {
|
||||
|
||||
+36
-10
@@ -4,6 +4,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.BatteryManager;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -63,7 +64,7 @@ final class UnlockedStockSourceCollector {
|
||||
ArrayList<SnapshotSource> statusChips = new ArrayList<>();
|
||||
ArrayList<SnapshotSource> statusChipMetrics = new ArrayList<>();
|
||||
if (scene != null && scene.isAod()) {
|
||||
collectAodStatusSnapshotViews(root, statusIcons, scene);
|
||||
collectAodStatusSnapshotViews(root, statusIcons, scene, settings);
|
||||
}
|
||||
if (statusIcons.isEmpty()) {
|
||||
if (anchors.statusRoot != null) {
|
||||
@@ -82,8 +83,7 @@ final class UnlockedStockSourceCollector {
|
||||
selectDualSimStatusSignals(statusIcons, settings);
|
||||
normalizeStatusIconSourceBounds(root, statusIcons);
|
||||
if (scene != null && scene.isAod()) {
|
||||
if (scene.notificationDisplayStyle() == NotificationDisplayStyle.ICONS
|
||||
|| scene.notificationDisplayStyle() == NotificationDisplayStyle.DOT) {
|
||||
if (isAodIconNotificationStyle(scene, settings)) {
|
||||
notificationIcons.addAll(
|
||||
LockscreenCardsNotificationIconSourceStore.snapshotSourcesForAodIconsRoot(root));
|
||||
if (notificationIcons.isEmpty()
|
||||
@@ -92,6 +92,12 @@ final class UnlockedStockSourceCollector {
|
||||
LockscreenCardsNotificationIconSourceStore
|
||||
.snapshotAodNotificationPackageSources(root));
|
||||
}
|
||||
if (notificationIcons.isEmpty() && isExperimentalGenericAod(settings)) {
|
||||
View notificationRoot = anchors != null && anchors.notificationRoot != null
|
||||
? anchors.notificationRoot
|
||||
: root;
|
||||
collectNotificationSnapshotViews(notificationRoot, notificationIcons);
|
||||
}
|
||||
}
|
||||
} else if (anchors.notificationRoot != null) {
|
||||
collectNotificationSnapshotViews(anchors.notificationRoot, notificationIcons);
|
||||
@@ -111,14 +117,14 @@ final class UnlockedStockSourceCollector {
|
||||
private void collectAodStatusSnapshotViews(
|
||||
View root,
|
||||
ArrayList<SnapshotSource> out,
|
||||
SceneKey scene
|
||||
SceneKey scene,
|
||||
SbtSettings settings
|
||||
) {
|
||||
if (root == null || out == null) {
|
||||
return;
|
||||
}
|
||||
boolean iconMode = scene != null
|
||||
&& (scene.notificationDisplayStyle() == NotificationDisplayStyle.ICONS
|
||||
|| scene.notificationDisplayStyle() == NotificationDisplayStyle.DOT);
|
||||
&& isAodIconNotificationStyle(scene, settings);
|
||||
View excludedNotificationContainer = iconMode
|
||||
? LockscreenCardsNotificationIconSourceStore.sourceContainerForAodIconsRoot(root)
|
||||
: LockscreenCardsNotificationIconSourceStore.sourceContainerForRoot(root);
|
||||
@@ -129,6 +135,22 @@ final class UnlockedStockSourceCollector {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isAodIconNotificationStyle(SceneKey scene, SbtSettings settings) {
|
||||
if (scene == null || !scene.isAod()) {
|
||||
return false;
|
||||
}
|
||||
NotificationDisplayStyle style = scene.notificationDisplayStyle();
|
||||
return style == NotificationDisplayStyle.ICONS
|
||||
|| style == NotificationDisplayStyle.DOT
|
||||
|| (style == NotificationDisplayStyle.UNKNOWN && isExperimentalGenericAod(settings));
|
||||
}
|
||||
|
||||
private boolean isExperimentalGenericAod(SbtSettings settings) {
|
||||
return settings != null
|
||||
&& settings.debugExperimentalAodStatusbarRoot
|
||||
&& !"samsung".equalsIgnoreCase(Build.MANUFACTURER);
|
||||
}
|
||||
|
||||
private String reflectString(View view, String methodName, String... fieldNames) {
|
||||
Object methodValue = ReflectionSupport.invokeMethod(view, methodName);
|
||||
if (methodValue != null) {
|
||||
@@ -193,7 +215,7 @@ final class UnlockedStockSourceCollector {
|
||||
statusSourceSignature = 31 * statusSourceSignature + batteryChargingSignature(root);
|
||||
if (scene != null && scene.isAod()) {
|
||||
statusSourceSignature = 31 * statusSourceSignature
|
||||
+ aodLayoutAnchorSignature(root, anchors, scene);
|
||||
+ aodLayoutAnchorSignature(root, anchors, scene, settings);
|
||||
}
|
||||
int notificationSourceSignature = sourceLayoutListSignature(
|
||||
previousIcons != null ? previousIcons.notificationIcons : null);
|
||||
@@ -238,13 +260,17 @@ final class UnlockedStockSourceCollector {
|
||||
chipSourceSignature);
|
||||
}
|
||||
|
||||
private int aodLayoutAnchorSignature(View root, RootAnchors anchors, SceneKey scene) {
|
||||
private int aodLayoutAnchorSignature(
|
||||
View root,
|
||||
RootAnchors anchors,
|
||||
SceneKey scene,
|
||||
SbtSettings settings
|
||||
) {
|
||||
if (root == null) {
|
||||
return 0;
|
||||
}
|
||||
boolean iconMode = scene != null
|
||||
&& (scene.notificationDisplayStyle() == NotificationDisplayStyle.ICONS
|
||||
|| scene.notificationDisplayStyle() == NotificationDisplayStyle.DOT);
|
||||
&& isAodIconNotificationStyle(scene, settings);
|
||||
View notificationContainer = iconMode
|
||||
? LockscreenCardsNotificationIconSourceStore.sourceContainerForAodIconsRoot(root)
|
||||
: LockscreenCardsNotificationIconSourceStore.sourceContainerForRoot(root);
|
||||
|
||||
@@ -99,6 +99,7 @@ public final class SbtDefaults {
|
||||
public static final boolean DEBUG_VISUALIZE_CHIP_CONTAINER_DEFAULT = false;
|
||||
public static final boolean DEBUG_VISUALIZE_CAMERA_CUTOUT_DEFAULT = false;
|
||||
public static final boolean DEBUG_VISUALIZE_AOD_STOCK_CONTAINERS_DEFAULT = false;
|
||||
public static final boolean DEBUG_EXPERIMENTAL_AOD_STATUSBAR_ROOT_DEFAULT = false;
|
||||
|
||||
public static final int LAYOUT_PADDING_CUTOUT_PX_DEFAULT = 0;
|
||||
public static final int LAYOUT_PADDING_LEFT_PX_DEFAULT = 0;
|
||||
|
||||
@@ -39,6 +39,8 @@ public final class SbtSettings {
|
||||
"debug_visualize_camera_cutout";
|
||||
public static final String KEY_DEBUG_VISUALIZE_AOD_STOCK_CONTAINERS =
|
||||
"debug_visualize_aod_stock_containers";
|
||||
public static final String KEY_DEBUG_EXPERIMENTAL_AOD_STATUSBAR_ROOT =
|
||||
"debug_experimental_aod_statusbar_root";
|
||||
public static final String KEY_LOCKED_NOTIFICATION_MODE =
|
||||
"locked_notification_mode";
|
||||
public static final String KEY_UNLOCKED_MAX_ICONS_PER_ROW = "unlocked_max_icons_per_row";
|
||||
@@ -425,6 +427,7 @@ public final class SbtSettings {
|
||||
public final boolean debugVisualizeChipContainer;
|
||||
public final boolean debugVisualizeCameraCutout;
|
||||
public final boolean debugVisualizeAodStockContainers;
|
||||
public final boolean debugExperimentalAodStatusbarRoot;
|
||||
|
||||
private SbtSettings(boolean enableAodCutoutLimit,
|
||||
boolean enableLockCutoutLimit,
|
||||
@@ -558,7 +561,8 @@ public final class SbtSettings {
|
||||
boolean debugVisualizeClockContainer,
|
||||
boolean debugVisualizeChipContainer,
|
||||
boolean debugVisualizeCameraCutout,
|
||||
boolean debugVisualizeAodStockContainers) {
|
||||
boolean debugVisualizeAodStockContainers,
|
||||
boolean debugExperimentalAodStatusbarRoot) {
|
||||
this.enableAodCutoutLimit = enableAodCutoutLimit;
|
||||
this.enableLockCutoutLimit = enableLockCutoutLimit;
|
||||
this.unlockedMaxIconsPerRow = unlockedMaxIconsPerRow;
|
||||
@@ -861,6 +865,7 @@ public final class SbtSettings {
|
||||
this.debugVisualizeChipContainer = debugVisualizeChipContainer;
|
||||
this.debugVisualizeCameraCutout = debugVisualizeCameraCutout;
|
||||
this.debugVisualizeAodStockContainers = debugVisualizeAodStockContainers;
|
||||
this.debugExperimentalAodStatusbarRoot = debugExperimentalAodStatusbarRoot;
|
||||
}
|
||||
|
||||
public static SbtSettings defaults() {
|
||||
@@ -997,7 +1002,8 @@ public final class SbtSettings {
|
||||
SbtDefaults.DEBUG_VISUALIZE_CLOCK_CONTAINER_DEFAULT,
|
||||
SbtDefaults.DEBUG_VISUALIZE_CHIP_CONTAINER_DEFAULT,
|
||||
SbtDefaults.DEBUG_VISUALIZE_CAMERA_CUTOUT_DEFAULT,
|
||||
SbtDefaults.DEBUG_VISUALIZE_AOD_STOCK_CONTAINERS_DEFAULT
|
||||
SbtDefaults.DEBUG_VISUALIZE_AOD_STOCK_CONTAINERS_DEFAULT,
|
||||
SbtDefaults.DEBUG_EXPERIMENTAL_AOD_STATUSBAR_ROOT_DEFAULT
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1472,7 +1478,10 @@ public final class SbtSettings {
|
||||
SbtDefaults.DEBUG_VISUALIZE_CAMERA_CUTOUT_DEFAULT),
|
||||
prefs.getBoolean(
|
||||
KEY_DEBUG_VISUALIZE_AOD_STOCK_CONTAINERS,
|
||||
SbtDefaults.DEBUG_VISUALIZE_AOD_STOCK_CONTAINERS_DEFAULT)
|
||||
SbtDefaults.DEBUG_VISUALIZE_AOD_STOCK_CONTAINERS_DEFAULT),
|
||||
prefs.getBoolean(
|
||||
KEY_DEBUG_EXPERIMENTAL_AOD_STATUSBAR_ROOT,
|
||||
SbtDefaults.DEBUG_EXPERIMENTAL_AOD_STATUSBAR_ROOT_DEFAULT)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1780,7 +1789,10 @@ public final class SbtSettings {
|
||||
SbtDefaults.DEBUG_VISUALIZE_CAMERA_CUTOUT_DEFAULT),
|
||||
bundle.getBoolean(
|
||||
KEY_DEBUG_VISUALIZE_AOD_STOCK_CONTAINERS,
|
||||
SbtDefaults.DEBUG_VISUALIZE_AOD_STOCK_CONTAINERS_DEFAULT)
|
||||
SbtDefaults.DEBUG_VISUALIZE_AOD_STOCK_CONTAINERS_DEFAULT),
|
||||
bundle.getBoolean(
|
||||
KEY_DEBUG_EXPERIMENTAL_AOD_STATUSBAR_ROOT,
|
||||
SbtDefaults.DEBUG_EXPERIMENTAL_AOD_STATUSBAR_ROOT_DEFAULT)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -195,6 +195,9 @@ public class SbtSettingsProvider extends ContentProvider {
|
||||
out.putBoolean(SbtSettings.KEY_DEBUG_VISUALIZE_AOD_STOCK_CONTAINERS,
|
||||
prefs.getBoolean(SbtSettings.KEY_DEBUG_VISUALIZE_AOD_STOCK_CONTAINERS,
|
||||
SbtDefaults.DEBUG_VISUALIZE_AOD_STOCK_CONTAINERS_DEFAULT));
|
||||
out.putBoolean(SbtSettings.KEY_DEBUG_EXPERIMENTAL_AOD_STATUSBAR_ROOT,
|
||||
prefs.getBoolean(SbtSettings.KEY_DEBUG_EXPERIMENTAL_AOD_STATUSBAR_ROOT,
|
||||
SbtDefaults.DEBUG_EXPERIMENTAL_AOD_STATUSBAR_ROOT_DEFAULT));
|
||||
out.putInt(SbtSettings.KEY_LAYOUT_PADDING_CUTOUT_PX,
|
||||
prefs.getInt(SbtSettings.KEY_LAYOUT_PADDING_CUTOUT_PX,
|
||||
SbtDefaults.LAYOUT_PADDING_CUTOUT_PX_DEFAULT));
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.Manifest;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -64,6 +65,8 @@ public class IconsDebugFragment extends Fragment {
|
||||
SwitchMaterial visualizeAodStockContainersSwitch =
|
||||
root.findViewById(R.id.debug_visualize_aod_stock_containers_switch);
|
||||
MaterialButton restartSystemUiButton = root.findViewById(R.id.debug_restart_systemui_button);
|
||||
SwitchMaterial experimentalAodStatusbarRootSwitch =
|
||||
root.findViewById(R.id.debug_experimental_aod_statusbar_root_switch);
|
||||
SwitchMaterial cycleIconsSwitch = root.findViewById(R.id.debug_cycle_icons_switch);
|
||||
TextView currentCameraIdentified = root.findViewById(R.id.debug_camera_current_identified);
|
||||
LinearLayout currentCameraOverrideRow = root.findViewById(R.id.debug_camera_current_override_row);
|
||||
@@ -137,6 +140,17 @@ public class IconsDebugFragment extends Fragment {
|
||||
SbtSettings.KEY_DEBUG_VISUALIZE_AOD_STOCK_CONTAINERS,
|
||||
SbtDefaults.DEBUG_VISUALIZE_AOD_STOCK_CONTAINERS_DEFAULT,
|
||||
true);
|
||||
ViewTreeSupport.bindBooleanPreference(
|
||||
requireContext(),
|
||||
prefs,
|
||||
experimentalAodStatusbarRootSwitch,
|
||||
SbtSettings.KEY_DEBUG_EXPERIMENTAL_AOD_STATUSBAR_ROOT,
|
||||
SbtDefaults.DEBUG_EXPERIMENTAL_AOD_STATUSBAR_ROOT_DEFAULT,
|
||||
true);
|
||||
if (isSamsungDevice() && experimentalAodStatusbarRootSwitch != null) {
|
||||
experimentalAodStatusbarRootSwitch.setChecked(false);
|
||||
experimentalAodStatusbarRootSwitch.setEnabled(false);
|
||||
}
|
||||
bindRestartSystemUiButton(restartSystemUiButton);
|
||||
updateVisualizerSwitchAvailability(
|
||||
prefs,
|
||||
@@ -187,6 +201,10 @@ public class IconsDebugFragment extends Fragment {
|
||||
return root;
|
||||
}
|
||||
|
||||
private boolean isSamsungDevice() {
|
||||
return "samsung".equalsIgnoreCase(Build.MANUFACTURER);
|
||||
}
|
||||
|
||||
private void styleCompactCounterButton(MaterialButton button) {
|
||||
ViewTreeSupport.styleCompactButtonText(button, 13f);
|
||||
}
|
||||
|
||||
@@ -111,6 +111,13 @@
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/debug_restart_systemui" />
|
||||
|
||||
<com.google.android.material.switchmaterial.SwitchMaterial
|
||||
android:id="@+id/debug_experimental_aod_statusbar_root_switch"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@string/debug_experimental_aod_statusbar_root" />
|
||||
|
||||
</LinearLayout>
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
<string name="debug_visualize_aod_stock_containers">AOD stock containers and derived statusbar</string>
|
||||
<string name="debug_section_systemui">SystemUI</string>
|
||||
<string name="debug_restart_systemui">Restart SystemUI</string>
|
||||
<string name="debug_experimental_aod_statusbar_root">Experimental non-Samsung AOD statusbar layout</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_notification_style_cards">Cards</string>
|
||||
|
||||
Reference in New Issue
Block a user