mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-27 15:26:58 +00:00
Merge branch '11-dev_minus1-pref' into 11-dev
This commit is contained in:
@@ -89,4 +89,5 @@
|
||||
<string name="dt2s_a11y_hint_title">Accessibility service required</string>
|
||||
<string name="dt2s_a11y_hint">To use Double Tap to Sleep, enable the accessibility service.</string>
|
||||
<string name="dt2s_warning_open_settings">Open Settings</string>
|
||||
<string name="minus_one_enable">Show Feed</string>
|
||||
</resources>
|
||||
|
||||
@@ -34,7 +34,7 @@ import com.android.launcher3.Utilities
|
||||
class FeedBridge(private val context: Context) {
|
||||
|
||||
private val shouldUseFeed = context.applicationInfo.flags and FLAG_SYSTEM == 0
|
||||
private val prefs = PreferenceManager.getInstance(context)
|
||||
private val prefs by lazy { PreferenceManager.getInstance(context) }
|
||||
private val bridgePackages by lazy {
|
||||
listOf(
|
||||
PixelBridgeInfo("com.google.android.apps.nexuslauncher", R.integer.bridge_signature_hash),
|
||||
|
||||
@@ -27,10 +27,6 @@ import com.android.launcher3.LauncherAppState
|
||||
open class LawnchairLauncher : Launcher() {
|
||||
private var paused = false
|
||||
|
||||
override fun getDefaultOverlay(): LauncherOverlayManager {
|
||||
return OverlayCallbackImpl(this)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ open class LawnchairLauncherQuickstep : QuickstepLauncher(), LifecycleOwner,
|
||||
super.onBackPressed()
|
||||
}
|
||||
val gestureController by lazy { GestureController(this) }
|
||||
private val defaultOverlay by lazy { OverlayCallbackImpl(this) }
|
||||
|
||||
override fun setupViews() {
|
||||
super.setupViews()
|
||||
@@ -109,7 +110,7 @@ open class LawnchairLauncherQuickstep : QuickstepLauncher(), LifecycleOwner,
|
||||
}
|
||||
|
||||
override fun getDefaultOverlay(): LauncherOverlayManager {
|
||||
return OverlayCallbackImpl(this)
|
||||
return defaultOverlay
|
||||
}
|
||||
|
||||
open fun restartIfPending() {
|
||||
|
||||
@@ -3,21 +3,22 @@ package app.lawnchair.nexuslauncher;
|
||||
import static android.content.pm.ApplicationInfo.FLAG_SYSTEM;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.systemui.plugins.shared.LauncherOverlayManager;
|
||||
import com.android.systemui.plugins.shared.LauncherOverlayManager.LauncherOverlay;
|
||||
|
||||
import com.google.android.libraries.launcherclient.ISerializableScrollCallback;
|
||||
import com.google.android.libraries.launcherclient.LauncherClient;
|
||||
import com.google.android.libraries.launcherclient.LauncherClientCallbacks;
|
||||
import com.google.android.libraries.launcherclient.StaticInteger;
|
||||
|
||||
import app.lawnchair.FeedBridge;
|
||||
import app.lawnchair.LawnchairLauncherQuickstep;
|
||||
import app.lawnchair.util.preferences.PrefEntry;
|
||||
import app.lawnchair.util.preferences.PreferenceManager;
|
||||
|
||||
/**
|
||||
* Implements {@link LauncherOverlay} and passes all the corresponding events to {@link
|
||||
@@ -28,7 +29,7 @@ import app.lawnchair.FeedBridge;
|
||||
*/
|
||||
public class OverlayCallbackImpl
|
||||
implements LauncherOverlay, LauncherClientCallbacks, LauncherOverlayManager,
|
||||
OnSharedPreferenceChangeListener, ISerializableScrollCallback {
|
||||
ISerializableScrollCallback {
|
||||
|
||||
// TODO: migrate to PreferenceManager
|
||||
final static String ENABLE_MINUS_ONE = "pref_enableMinusOne";
|
||||
@@ -42,14 +43,14 @@ public class OverlayCallbackImpl
|
||||
boolean mFlagsChanged = false;
|
||||
private int mFlags;
|
||||
|
||||
public OverlayCallbackImpl(Launcher launcher) {
|
||||
SharedPreferences prefs = Utilities.getPrefs(launcher);
|
||||
public OverlayCallbackImpl(LawnchairLauncherQuickstep launcher) {
|
||||
PreferenceManager prefs = PreferenceManager.getInstance(launcher);
|
||||
PrefEntry<Boolean> minusOnePref = prefs.getMinusOneEnable();
|
||||
|
||||
mLauncher = launcher;
|
||||
mClient = new LauncherClient(mLauncher, this, new StaticInteger(
|
||||
(prefs.getBoolean(ENABLE_MINUS_ONE,
|
||||
minusOneAvailable()) ? 1 : 0) | 2 | 4 | 8));
|
||||
prefs.registerOnSharedPreferenceChangeListener(this);
|
||||
(minusOnePref.get() ? 1 : 0) | 2 | 4 | 8));
|
||||
minusOnePref.subscribe(launcher, (enabled) -> mLauncher.setLauncherOverlay(enabled ? this : null));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -118,14 +119,6 @@ public class OverlayCallbackImpl
|
||||
@Override
|
||||
public void onActivityDestroyed(Activity activity) {
|
||||
mClient.mDestroyed = true;
|
||||
mLauncher.getSharedPrefs().unregisterOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
|
||||
if (ENABLE_MINUS_ONE.equals(key)) {
|
||||
mClient.showOverlay(prefs.getBoolean(ENABLE_MINUS_ONE, minusOneAvailable()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -178,8 +171,8 @@ public class OverlayCallbackImpl
|
||||
}
|
||||
}
|
||||
|
||||
boolean minusOneAvailable() {
|
||||
return FeedBridge.useBridge(mLauncher)
|
||||
|| ((mLauncher.getApplicationInfo().flags & FLAG_SYSTEM) == FLAG_SYSTEM);
|
||||
public static boolean minusOneAvailable(Context context) {
|
||||
return FeedBridge.useBridge(context)
|
||||
|| ((context.getApplicationInfo().flags & FLAG_SYSTEM) == FLAG_SYSTEM);
|
||||
}
|
||||
}
|
||||
@@ -42,6 +42,11 @@ fun HomeScreenPreferences() {
|
||||
pageMeta.provide(Meta(title = stringResource(id = R.string.home_screen_label)))
|
||||
PreferenceLayout {
|
||||
PreferenceGroup(heading = "General", isFirstChild = true) {
|
||||
SwitchPreference(
|
||||
prefs.minusOneEnable.getAdapter(),
|
||||
label = stringResource(id = R.string.minus_one_enable),
|
||||
showDivider = true
|
||||
)
|
||||
SwitchPreference(
|
||||
prefs.addIconToHome.getAdapter(),
|
||||
label = stringResource(id = R.string.auto_add_shortcuts_label),
|
||||
|
||||
@@ -21,7 +21,7 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import app.lawnchair.LawnchairLauncher
|
||||
import app.lawnchair.LawnchairLauncherQuickstep
|
||||
import app.lawnchair.launcher
|
||||
import app.lawnchair.nexuslauncher.OverlayCallbackImpl
|
||||
import com.android.launcher3.BuildConfig
|
||||
import com.android.launcher3.LauncherAppState
|
||||
import com.android.launcher3.states.RotationHelper
|
||||
@@ -41,6 +41,7 @@ class PreferenceManager private constructor(context: Context) : BasePreferenceMa
|
||||
LawnchairLauncher.getLauncher(context).scheduleRestart()
|
||||
}
|
||||
}
|
||||
|
||||
private val reloadGrid = scheduleRestart
|
||||
|
||||
val hiddenAppSet = StringSetPref("hidden-app-set", setOf())
|
||||
@@ -60,6 +61,7 @@ class PreferenceManager private constructor(context: Context) : BasePreferenceMa
|
||||
val allAppsTextSizeFactor = FloatPref("pref_allAppsTextSizeFactor", 1F, scheduleRestart)
|
||||
val allAppsColumns = IdpIntPref("pref_allAppsColumns", { numAllAppsColumns }, reloadGrid)
|
||||
val smartSpaceEnable = BoolPref("pref_smartSpaceEnable", true, scheduleRestart)
|
||||
val minusOneEnable = BoolPref("pref_enableMinusOne", OverlayCallbackImpl.minusOneAvailable(context))
|
||||
|
||||
// TODO: Add the ability to manually delete empty pages.
|
||||
val allowEmptyPages = BoolPref("pref_allowEmptyPages", false)
|
||||
|
||||
Reference in New Issue
Block a user