Fix crash a9 (#3836)

* Fix crash on Android 9 (#3808)

- Initial support for A9


Co-authored-by: John Andrew Camu <werdna.jac@gmail.com>
Co-authored-by: Rafael de Moura Dev <93414086+Rafael2616@users.noreply.github.com>
This commit is contained in:
John Andrew Camu
2023-12-09 14:13:47 +08:00
committed by GitHub
parent dedd16d2c5
commit 5931c9afec
8 changed files with 55 additions and 29 deletions

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="system_accent1_100">@android:color/transparent</color>
<color name="accent_primary_device_default">@android:color/transparent</color>
</resources>

View File

@@ -39,6 +39,7 @@ object ColorTokens {
val Accent3_50 = SwatchColorToken(Swatch.Accent3, Shade.S50)
val Accent3_100 = SwatchColorToken(Swatch.Accent3, Shade.S100)
val Accent3_200 = SwatchColorToken(Swatch.Accent3, Shade.S200)
val SurfaceLight = Neutral1_500.setLStar(98.0)
val SurfaceDark = Neutral1_800
@@ -82,6 +83,8 @@ object ColorTokens {
@JvmField val FolderDotColor = Accent3_100
@JvmField val DotColor = Accent3_200
@JvmField val FolderBackgroundColor = DayNightColorToken(Neutral1_50.setLStar(98.0), Neutral2_50.setLStar(30.0))
@JvmField val FolderIconBorderColor = ColorPrimary

View File

@@ -43,6 +43,7 @@ import app.lawnchair.preferences.PreferenceManager
import app.lawnchair.preferences2.PreferenceManager2
import app.lawnchair.theme.color.ColorTokens
import com.android.launcher3.R
import com.android.launcher3.Utilities
import com.android.launcher3.util.Executors.MAIN_EXECUTOR
import com.android.launcher3.util.Themes
import com.android.systemui.shared.system.QuickStepContract
@@ -114,17 +115,21 @@ fun getPrefsIfUnlocked(context: Context): PreferenceManager? {
fun getWindowCornerRadius(context: Context): Float {
val prefs = getPrefsIfUnlocked(context)
if (prefs != null && prefs.overrideWindowCornerRadius.get()) {
return prefs.windowCornerRadius.get().toFloat()
return when {
prefs?.overrideWindowCornerRadius?.get() == true -> prefs.windowCornerRadius.get().toFloat()
Utilities.ATLEAST_Q -> QuickStepContract.getWindowCornerRadius(context)
else -> 0.0f
}
return QuickStepContract.getWindowCornerRadius(context)
}
fun supportsRoundedCornersOnWindows(context: Context): Boolean {
if (getPrefsIfUnlocked(context)?.overrideWindowCornerRadius?.get() == true) {
return true
val prefs = getPrefsIfUnlocked(context)
return when {
prefs?.overrideWindowCornerRadius?.get() == true -> true
Utilities.ATLEAST_Q -> QuickStepContract.supportsRoundedCornersOnWindows(context.resources)
else -> false
}
return QuickStepContract.supportsRoundedCornersOnWindows(context.resources)
}
fun overrideAllAppsTextColor(textView: TextView) {

View File

@@ -32,6 +32,7 @@ import android.view.ViewTreeObserver;
import com.android.launcher3.BaseActivity;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.Utilities;
import com.android.launcher3.anim.PendingAnimation;
import com.android.launcher3.statemanager.StateManager.StateHandler;
import com.android.launcher3.states.StateAnimationConfig;
@@ -64,7 +65,9 @@ public class DepthController extends BaseDepthController implements StateHandler
private void onLauncherDraw() {
View view = mLauncher.getDragLayer();
ViewRootImpl viewRootImpl = view.getViewRootImpl();
setSurface(viewRootImpl != null ? viewRootImpl.getSurfaceControl() : null);
if (Utilities.ATLEAST_Q) {
setSurface(viewRootImpl != null ? viewRootImpl.getSurfaceControl() : null);
}
view.post(() -> view.getViewTreeObserver().removeOnDrawListener(mOnDrawListener));
}

View File

@@ -154,20 +154,22 @@ public class RecentsAnimationDeviceState implements DisplayInfoChangeListener {
}
runOnDestroy(() -> mUserUnlockedReceiver.unregisterReceiverSafely(mContext));
// Register for exclusion updates
mExclusionListener = new SystemGestureExclusionListenerCompat(mDisplayId) {
@Override
@BinderThread
public void onExclusionChanged(Region region) {
if (region == null) {
// Don't think this is possible but just in case, don't let it be null.
region = new Region();
if (Utilities.ATLEAST_Q) {
// Register for exclusion updates
mExclusionListener = new SystemGestureExclusionListenerCompat(mDisplayId) {
@Override
@BinderThread
public void onExclusionChanged(Region region) {
if (region == null) {
// Don't think this is possible but just in case, don't let it be null.
region = new Region();
}
// Assignments are atomic, it should be safe on binder thread
mExclusionRegion = region;
}
// Assignments are atomic, it should be safe on binder thread
mExclusionRegion = region;
}
};
runOnDestroy(mExclusionListener::unregister);
};
runOnDestroy(mExclusionListener::unregister);
}
// Register for display changes changes
mDisplayController.addChangeListener(this);
@@ -219,9 +221,11 @@ public class RecentsAnimationDeviceState implements DisplayInfoChangeListener {
mPipIsActive = false;
}
};
TaskStackChangeListeners.getInstance().registerTaskStackListener(mPipListener);
runOnDestroy(() ->
TaskStackChangeListeners.getInstance().unregisterTaskStackListener(mPipListener));
if (Utilities.ATLEAST_Q) {
TaskStackChangeListeners.getInstance().registerTaskStackListener(mPipListener);
runOnDestroy(() ->
TaskStackChangeListeners.getInstance().unregisterTaskStackListener(mPipListener));
}
}
private void runOnDestroy(Runnable action) {
@@ -258,6 +262,8 @@ public class RecentsAnimationDeviceState implements DisplayInfoChangeListener {
mMode = info.navigationMode;
mNavBarPosition = new NavBarPosition(mMode, info);
if (mExclusionListener == null) return;
if (mMode == NO_BUTTON) {
mExclusionListener.register();
} else {

View File

@@ -16,8 +16,9 @@
package com.android.quickstep.util;
import android.os.VibrationEffect;
import com.android.launcher3.Utilities;
public class VibrationConstants {
public static final VibrationEffect EFFECT_TEXTURE_TICK =
VibrationEffect.createPredefined(VibrationEffect.EFFECT_TEXTURE_TICK);
}
public static final VibrationEffect EFFECT_TEXTURE_TICK = Utilities.ATLEAST_Q ?
VibrationEffect.createPredefined(VibrationEffect.EFFECT_TEXTURE_TICK) : VibrationEffect.createOneShot(50, VibrationEffect.DEFAULT_AMPLITUDE);
}

View File

@@ -88,6 +88,7 @@ import java.util.Locale;
import app.lawnchair.font.FontManager;
import app.lawnchair.preferences.PreferenceManager;
import app.lawnchair.theme.color.ColorTokens;
import app.lawnchair.util.LawnchairUtilsKt;
/**
@@ -392,8 +393,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
boolean useTheme = shouldUseTheme();
FastBitmapDrawable iconDrawable = info.newIcon(getContext(), useTheme);
mDotParams.appColor = iconDrawable.getIconColor();
mDotParams.color = getContext().getResources()
.getColor(android.R.color.system_accent3_200, getContext().getTheme());
mDotParams.color = ColorTokens.DotColor.resolveColor(getContext());
setIcon(iconDrawable);
applyLabel(info);
}

View File

@@ -68,6 +68,7 @@ import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import com.android.launcher3.Utilities;
import com.android.launcher3.accessibility.AccessibleDragListenerAdapter;
import com.android.launcher3.accessibility.WorkspaceAccessibilityHelper;
import com.android.launcher3.anim.Interpolators;
@@ -409,7 +410,9 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
} else {
lp.leftMargin = lp.rightMargin = 0;
lp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
boolean isDisabledHotseat = getHotseat() != null && getHotseat().getQsb().getSourceLayoutResId() == R.layout.empty_view;
boolean isDisabledHotseat = Utilities.ATLEAST_Q &&
getHotseat() != null &&
getHotseat().getQsb().getSourceLayoutResId() == R.layout.empty_view;
lp.bottomMargin = (padding.bottom) + grid.hotseatBarBottomSpacePx - (isDisabledHotseat ? grid.workspaceCellPaddingXPx * 3 : 0);
}
mPageIndicator.setLayoutParams(lp);