Feat: Initial Impl to Hide Clock on Home Screen First Page
- TODO : only hide if there's a widget clock
This commit is contained in:
@@ -66,6 +66,31 @@ class LawnchairApp : Application() {
|
||||
QuickStepContract.sRecentsDisabled = !recentsEnabled
|
||||
}
|
||||
|
||||
fun hideClockInStatusBar() {
|
||||
if (!isRecentsEnabled) return
|
||||
try {
|
||||
val currentBlacklist = Settings.Secure.getString(contentResolver, "icon_blacklist") ?: ""
|
||||
val newBlacklist = if (currentBlacklist.contains("clock")) {
|
||||
currentBlacklist
|
||||
} else {
|
||||
"$currentBlacklist,clock"
|
||||
}
|
||||
Settings.Secure.putString(contentResolver, "icon_blacklist", newBlacklist)
|
||||
} catch (_: Exception) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
fun restoreClockInStatusBar() {
|
||||
if (!isRecentsEnabled) return
|
||||
try {
|
||||
val currentBlacklist = Settings.Secure.getString(contentResolver, "icon_blacklist") ?: ""
|
||||
val newBlacklist = currentBlacklist.split(",").filter { it != "clock" }.joinToString(",")
|
||||
Settings.Secure.putString(contentResolver, "icon_blacklist", newBlacklist)
|
||||
} catch (_: Exception) {
|
||||
}
|
||||
}
|
||||
|
||||
fun onLauncherAppStateCreated() {
|
||||
registerActivityLifecycleCallbacks(activityHandler)
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ import com.android.launcher3.statemanager.StateManager
|
||||
import com.android.launcher3.statemanager.StateManager.StateHandler
|
||||
import com.android.launcher3.uioverrides.QuickstepLauncher
|
||||
import com.android.launcher3.uioverrides.states.AllAppsState
|
||||
import com.android.launcher3.uioverrides.states.BackgroundAppState
|
||||
import com.android.launcher3.uioverrides.states.OverviewState
|
||||
import com.android.launcher3.util.ActivityOptionsWrapper
|
||||
import com.android.launcher3.util.Executors
|
||||
@@ -109,6 +110,23 @@ class LawnchairLauncher : QuickstepLauncher() {
|
||||
}
|
||||
override fun onStateTransitionComplete(finalState: LauncherState) {}
|
||||
}
|
||||
private val statusBarClockListener = object : StateManager.StateListener<LauncherState> {
|
||||
override fun onStateTransitionStart(toState: LauncherState) {
|
||||
when (toState) {
|
||||
is BackgroundAppState,
|
||||
is OverviewState,
|
||||
is AllAppsState,
|
||||
-> {
|
||||
LawnchairApp.instance.restoreClockInStatusBar()
|
||||
}
|
||||
else -> {
|
||||
workspace.updateStatusbarClock()
|
||||
}
|
||||
}
|
||||
}
|
||||
override fun onStateTransitionComplete(finalState: LauncherState) {}
|
||||
}
|
||||
|
||||
private lateinit var colorScheme: ColorScheme
|
||||
private var hasBackGesture = false
|
||||
|
||||
@@ -158,6 +176,8 @@ class LawnchairLauncher : QuickstepLauncher() {
|
||||
}
|
||||
}.launchIn(scope = lifecycleScope)
|
||||
|
||||
launcher.stateManager.addStateListener(statusBarClockListener)
|
||||
|
||||
preferenceManager2.rememberPosition.get().onEach {
|
||||
with(launcher.stateManager) {
|
||||
if (it) {
|
||||
|
||||
@@ -31,7 +31,6 @@ import static com.android.launcher3.LauncherState.HINT_STATE;
|
||||
import static com.android.launcher3.LauncherState.NORMAL;
|
||||
import static com.android.launcher3.LauncherState.SPRING_LOADED;
|
||||
import static com.android.launcher3.MotionEventsUtils.isTrackpadMultiFingerSwipe;
|
||||
import static com.android.launcher3.Utilities.SHOULD_SHOW_FIRST_PAGE_WIDGET;
|
||||
import static com.android.launcher3.anim.AnimatorListeners.forSuccessCallback;
|
||||
import static com.android.launcher3.config.FeatureFlags.FOLDABLE_SINGLE_PAGE;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_HOME;
|
||||
@@ -55,7 +54,6 @@ import android.graphics.Bitmap;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
@@ -75,9 +73,7 @@ import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.core.graphics.drawable.DrawableKt;
|
||||
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.app.animation.Interpolators;
|
||||
import com.android.launcher3.accessibility.AccessibleDragListenerAdapter;
|
||||
import com.android.launcher3.accessibility.WorkspaceAccessibilityHelper;
|
||||
@@ -135,8 +131,6 @@ import com.android.launcher3.widget.PendingAddWidgetInfo;
|
||||
import com.android.launcher3.widget.PendingAppWidgetHostView;
|
||||
import com.android.launcher3.widget.WidgetManagerHelper;
|
||||
import com.android.launcher3.widget.util.WidgetSizes;
|
||||
import com.android.systemui.plugins.shared.LauncherOverlayManager.LauncherOverlay;
|
||||
import com.google.android.renderscript.Toolkit;
|
||||
import com.patrykmichalik.opto.core.PreferenceExtensionsKt;
|
||||
import com.android.systemui.plugins.shared.LauncherOverlayManager.LauncherOverlayCallbacks;
|
||||
import com.android.systemui.plugins.shared.LauncherOverlayManager.LauncherOverlayTouchProxy;
|
||||
@@ -148,6 +142,8 @@ import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import app.lawnchair.LawnchairApp;
|
||||
import app.lawnchair.LawnchairAppKt;
|
||||
import app.lawnchair.preferences.PreferenceManager;
|
||||
import app.lawnchair.preferences2.PreferenceManager2;
|
||||
import app.lawnchair.smartspace.SmartspaceAppWidgetProvider;
|
||||
@@ -615,6 +611,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
}
|
||||
stateManager.removeStateListener(this);
|
||||
}
|
||||
updateStatusbarClock();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -635,6 +632,14 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
setWallpaperDimension();
|
||||
}
|
||||
|
||||
public void updateStatusbarClock() {
|
||||
if (mCurrentPage == 0) {
|
||||
LawnchairAppKt.getLawnchairApp(mLauncher).hideClockInStatusBar();
|
||||
} else {
|
||||
LawnchairAppKt.getLawnchairApp(mLauncher).restoreClockInStatusBar();
|
||||
}
|
||||
}
|
||||
|
||||
private void setupLayoutTransition() {
|
||||
// We want to show layout transitions when pages are deleted, to close the gap.
|
||||
mLayoutTransition = new LayoutTransition();
|
||||
@@ -1511,6 +1516,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
.setPageIndex(prevPage))
|
||||
.build())
|
||||
.log(event);
|
||||
updateStatusbarClock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user