Allow overriding window corner radius
This commit is contained in:
@@ -98,4 +98,7 @@
|
||||
<string name="theme_follow_wallpaper">Follow wallpaper</string>
|
||||
<string name="quickstep_label">Recents</string>
|
||||
<string name="clear_all_as_action_label">Show “Clear all” at bottom</string>
|
||||
<string name="window_corner_radius_label">Corner radius</string>
|
||||
<string name="override_window_corner_radius_label">Custom corner radius</string>
|
||||
<string name="override_window_corner_radius_description">If the default doesn\'t match your screen</string>
|
||||
</resources>
|
||||
|
||||
@@ -81,6 +81,8 @@ class PreferenceManager private constructor(private val context: Context) : Base
|
||||
val workspaceDt2s = BoolPref("pref_doubleTap2Sleep", true)
|
||||
val launcherTheme = StringPref("pref_launcherTheme", "system")
|
||||
val clearAllAsAction = BoolPref("pref_clearAllAsAction", false)
|
||||
val overrideWindowCornerRadius = BoolPref("pref_overrideWindowCornerRadius", false, recreate)
|
||||
val windowCornerRadius = FloatPref("pref_windowCornerRadius", 1f, recreate)
|
||||
|
||||
init {
|
||||
sp.registerOnSharedPreferenceChangeListener(this)
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
package app.lawnchair.ui.preferences
|
||||
|
||||
import androidx.compose.animation.ExperimentalAnimationApi
|
||||
import androidx.compose.animation.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.navigation.NavGraphBuilder
|
||||
import app.lawnchair.preferences.getAdapter
|
||||
import app.lawnchair.preferences.observeAsState
|
||||
import app.lawnchair.preferences.preferenceManager
|
||||
import app.lawnchair.ui.preferences.components.PreferenceGroup
|
||||
import app.lawnchair.ui.preferences.components.PreferenceLayout
|
||||
import app.lawnchair.ui.preferences.components.SliderPreference
|
||||
import app.lawnchair.ui.preferences.components.SwitchPreference
|
||||
import app.lawnchair.util.Meta
|
||||
import app.lawnchair.util.pageMeta
|
||||
import com.android.launcher3.R
|
||||
|
||||
|
||||
@ExperimentalAnimationApi
|
||||
fun NavGraphBuilder.quickstepGraph(route: String) {
|
||||
preferenceGraph(route, { QuickstepPreferences() })
|
||||
@@ -23,13 +25,36 @@ fun NavGraphBuilder.quickstepGraph(route: String) {
|
||||
@Composable
|
||||
fun QuickstepPreferences() {
|
||||
pageMeta.provide(Meta(title = stringResource(id = R.string.quickstep_label)))
|
||||
val prefs = preferenceManager()
|
||||
PreferenceLayout {
|
||||
PreferenceGroup(isFirstChild = true) {
|
||||
SwitchPreference(
|
||||
adapter = preferenceManager().clearAllAsAction.getAdapter(),
|
||||
adapter = prefs.clearAllAsAction.getAdapter(),
|
||||
label = stringResource(id = R.string.clear_all_as_action_label),
|
||||
showDivider = false
|
||||
)
|
||||
}
|
||||
PreferenceGroup(heading = stringResource(id = R.string.window_corner_radius_label)) {
|
||||
val overrideWindowCornerRadius by prefs.overrideWindowCornerRadius.observeAsState()
|
||||
SwitchPreference(
|
||||
adapter = prefs.overrideWindowCornerRadius.getAdapter(),
|
||||
label = stringResource(id = R.string.override_window_corner_radius_label),
|
||||
description = stringResource(id = R.string.override_window_corner_radius_description),
|
||||
showDivider = overrideWindowCornerRadius
|
||||
)
|
||||
AnimatedVisibility(
|
||||
visible = overrideWindowCornerRadius,
|
||||
enter = expandVertically() + fadeIn(),
|
||||
exit = shrinkVertically() + fadeOut()
|
||||
) {
|
||||
SliderPreference(
|
||||
label = stringResource(id = R.string.window_corner_radius_label),
|
||||
adapter = prefs.windowCornerRadius.getAdapter(),
|
||||
steps = 0,
|
||||
valueRange = 80f..150f,
|
||||
showDivider = false
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,9 +63,9 @@ fun SliderPreference(
|
||||
) {
|
||||
Text(
|
||||
text = if (showAsPercentage) {
|
||||
"${(adapter.state.value * 100).roundToInt()}%"
|
||||
"${(sliderValue * 100).roundToInt()}%"
|
||||
} else {
|
||||
"${adapter.state.value.roundToInt()}"
|
||||
"${sliderValue.roundToInt()}"
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -21,15 +21,13 @@ import android.app.PendingIntent
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Looper
|
||||
|
||||
import app.lawnchair.preferences.PreferenceManager
|
||||
import com.android.launcher3.util.Executors.MAIN_EXECUTOR
|
||||
|
||||
import com.android.systemui.shared.system.QuickStepContract
|
||||
import java.util.concurrent.Callable
|
||||
import java.util.concurrent.ExecutionException
|
||||
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
|
||||
fun <T, A> ensureOnMainThread(creator: (A) -> T): (A) -> T {
|
||||
return { it ->
|
||||
if (Looper.myLooper() == Looper.getMainLooper()) {
|
||||
@@ -79,4 +77,19 @@ fun restartLauncher(context: Context, intent: Intent?) {
|
||||
|
||||
fun killLauncher() {
|
||||
exitProcess(0)
|
||||
}
|
||||
}
|
||||
|
||||
fun getWindowCornerRadius(context: Context): Float {
|
||||
val prefs = PreferenceManager.getInstance(context)
|
||||
if (prefs.overrideWindowCornerRadius.get()) {
|
||||
return prefs.windowCornerRadius.get()
|
||||
}
|
||||
return QuickStepContract.getWindowCornerRadius(context.resources)
|
||||
}
|
||||
|
||||
fun supportsRoundedCornersOnWindows(context: Context): Boolean {
|
||||
if (PreferenceManager.getInstance(context).overrideWindowCornerRadius.get()) {
|
||||
return true
|
||||
}
|
||||
return QuickStepContract.supportsRoundedCornersOnWindows(context.resources)
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.android.quickstep.util;
|
||||
|
||||
import static com.android.systemui.shared.system.QuickStepContract.supportsRoundedCornersOnWindows;
|
||||
import static app.lawnchair.util.LawnchairUtilsKt.supportsRoundedCornersOnWindows;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
@@ -25,7 +25,7 @@ import com.android.launcher3.util.Themes;
|
||||
public class TaskCornerRadius {
|
||||
|
||||
public static float get(Context context) {
|
||||
return supportsRoundedCornersOnWindows(context.getResources()) ?
|
||||
return supportsRoundedCornersOnWindows(context) ?
|
||||
Themes.getDialogCornerRadius(context):
|
||||
context.getResources().getDimension(R.dimen.task_corner_radius_small);
|
||||
}
|
||||
|
||||
@@ -104,6 +104,8 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import app.lawnchair.util.LawnchairUtilsKt;
|
||||
|
||||
/**
|
||||
* A task in the Recents view.
|
||||
*/
|
||||
@@ -1089,7 +1091,7 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
|
||||
|
||||
public FullscreenDrawParams(Context context) {
|
||||
mCornerRadius = TaskCornerRadius.get(context);
|
||||
mWindowCornerRadius = QuickStepContract.getWindowCornerRadius(context.getResources());
|
||||
mWindowCornerRadius = LawnchairUtilsKt.getWindowCornerRadius(context);
|
||||
|
||||
mCurrentDrawnCornerRadius = mCornerRadius;
|
||||
}
|
||||
|
||||
@@ -35,8 +35,8 @@ import static com.android.launcher3.dragndrop.DragLayer.ALPHA_INDEX_TRANSITIONS;
|
||||
import static com.android.launcher3.statehandlers.DepthController.DEPTH;
|
||||
import static com.android.launcher3.views.FloatingIconView.SHAPE_PROGRESS_DURATION;
|
||||
import static com.android.quickstep.TaskUtils.taskIsATargetWithMode;
|
||||
import static com.android.systemui.shared.system.QuickStepContract.getWindowCornerRadius;
|
||||
import static com.android.systemui.shared.system.QuickStepContract.supportsRoundedCornersOnWindows;
|
||||
import static app.lawnchair.util.LawnchairUtilsKt.getWindowCornerRadius;
|
||||
import static app.lawnchair.util.LawnchairUtilsKt.supportsRoundedCornersOnWindows;
|
||||
import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_CLOSING;
|
||||
import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_OPENING;
|
||||
|
||||
@@ -90,6 +90,8 @@ import com.android.systemui.shared.system.RemoteAnimationTargetCompat;
|
||||
import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat.SurfaceParams;
|
||||
import com.android.systemui.shared.system.WindowManagerWrapper;
|
||||
|
||||
import app.lawnchair.util.LawnchairUtilsKt;
|
||||
|
||||
/**
|
||||
* {@link LauncherAppTransitionManager} with Quickstep-specific app transitions for launching from
|
||||
* home and/or all-apps. Not used for 3p launchers.
|
||||
@@ -522,10 +524,10 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans
|
||||
endCrop = windowTargetBounds.height();
|
||||
}
|
||||
|
||||
final float initialWindowRadius = supportsRoundedCornersOnWindows(mLauncher.getResources())
|
||||
final float initialWindowRadius = supportsRoundedCornersOnWindows(mLauncher)
|
||||
? startCrop / 2f : 0f;
|
||||
final float windowRadius = mDeviceProfile.isMultiWindowMode
|
||||
? 0 : getWindowCornerRadius(mLauncher.getResources());
|
||||
? 0 : getWindowCornerRadius(mLauncher);
|
||||
appAnimator.addUpdateListener(new MultiValueUpdateListener() {
|
||||
FloatProp mDx = new FloatProp(0, dX, 0, xDuration, AGGRESSIVE_EASE);
|
||||
FloatProp mDy = new FloatProp(0, dY, 0, yDuration, AGGRESSIVE_EASE);
|
||||
@@ -715,7 +717,7 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans
|
||||
ValueAnimator unlockAnimator = ValueAnimator.ofFloat(0, 1);
|
||||
unlockAnimator.setDuration(CLOSING_TRANSITION_DURATION_MS);
|
||||
float cornerRadius = mDeviceProfile.isMultiWindowMode ? 0 :
|
||||
QuickStepContract.getWindowCornerRadius(mLauncher.getResources());
|
||||
LawnchairUtilsKt.getWindowCornerRadius(mLauncher);
|
||||
unlockAnimator.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
@@ -745,7 +747,7 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans
|
||||
ValueAnimator closingAnimator = ValueAnimator.ofFloat(0, 1);
|
||||
int duration = CLOSING_TRANSITION_DURATION_MS;
|
||||
float windowCornerRadius = mDeviceProfile.isMultiWindowMode
|
||||
? 0 : getWindowCornerRadius(mLauncher.getResources());
|
||||
? 0 : getWindowCornerRadius(mLauncher);
|
||||
closingAnimator.setDuration(duration);
|
||||
closingAnimator.addUpdateListener(new MultiValueUpdateListener() {
|
||||
FloatProp mDy = new FloatProp(0, mClosingWindowTransY, 0, duration, DEACCEL_1_7);
|
||||
|
||||
@@ -38,6 +38,8 @@ import com.android.systemui.shared.system.TaskStackChangeListener;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import app.lawnchair.util.LawnchairUtilsKt;
|
||||
|
||||
public class RotationTouchHelper implements
|
||||
SysUINavigationMode.NavigationModeChangeListener,
|
||||
DefaultDisplay.DisplayInfoChangeListener {
|
||||
@@ -128,7 +130,7 @@ public class RotationTouchHelper implements
|
||||
mDisplayId = mDefaultDisplay.getInfo().id;
|
||||
|
||||
mOrientationTouchTransformer = new OrientationTouchTransformer(resources, mMode,
|
||||
() -> QuickStepContract.getWindowCornerRadius(resources));
|
||||
() -> LawnchairUtilsKt.getWindowCornerRadius(context));
|
||||
|
||||
// Register for navigation mode changes
|
||||
onNavigationModeChanged(mSysUiNavMode.addModeChangeListener(this));
|
||||
|
||||
@@ -54,6 +54,8 @@ import com.android.quickstep.util.NavBarPosition;
|
||||
import com.android.quickstep.util.TriggerSwipeUpTouchTracker;
|
||||
import com.android.systemui.shared.system.QuickStepContract;
|
||||
|
||||
import app.lawnchair.util.LawnchairUtilsKt;
|
||||
|
||||
/** Utility class to handle Home and Assistant gestures. */
|
||||
public class NavBarGestureHandler implements OnTouchListener,
|
||||
TriggerSwipeUpTouchTracker.OnSwipeUpListener {
|
||||
@@ -120,7 +122,7 @@ public class NavBarGestureHandler implements OnTouchListener,
|
||||
mAssistantGestureDetector = new GestureDetector(context, new AssistantGestureListener());
|
||||
int assistantWidth = resources.getDimensionPixelSize(R.dimen.gestures_assistant_width);
|
||||
final float assistantHeight = Math.max(mBottomGestureHeight,
|
||||
QuickStepContract.getWindowCornerRadius(resources));
|
||||
LawnchairUtilsKt.getWindowCornerRadius(context));
|
||||
mAssistantLeftRegion.bottom = mAssistantRightRegion.bottom = mDisplaySize.y;
|
||||
mAssistantLeftRegion.top = mAssistantRightRegion.top = mDisplaySize.y - assistantHeight;
|
||||
mAssistantLeftRegion.left = 0;
|
||||
|
||||
+3
-1
@@ -59,6 +59,8 @@ import com.android.quickstep.util.TransformParams;
|
||||
import com.android.systemui.shared.system.QuickStepContract;
|
||||
import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat.SurfaceParams;
|
||||
|
||||
import app.lawnchair.util.LawnchairUtilsKt;
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.R)
|
||||
abstract class SwipeUpGestureTutorialController extends TutorialController {
|
||||
private final ViewSwipeUpAnimation mViewSwipeUpAnimation;
|
||||
@@ -85,7 +87,7 @@ abstract class SwipeUpGestureTutorialController extends TutorialController {
|
||||
dp.updateInsets(new Rect(insets.left, insets.top, insets.right, insets.bottom));
|
||||
mViewSwipeUpAnimation.initDp(dp);
|
||||
|
||||
mFakeTaskViewRadius = QuickStepContract.getWindowCornerRadius(mContext.getResources());
|
||||
mFakeTaskViewRadius = LawnchairUtilsKt.getWindowCornerRadius(mContext);
|
||||
mFakeTaskView.setClipToOutline(true);
|
||||
mFakeTaskView.setOutlineProvider(new ViewOutlineProvider() {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user