Skip to content

Commit

Permalink
Fix crash a9 (LawnchairLauncher#3836)
Browse files Browse the repository at this point in the history
* Fix crash on Android 9 (LawnchairLauncher#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>
  • Loading branch information
MrSluffy and Rafael2616 authored Dec 9, 2023
1 parent dedd16d commit 5931c9a
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 29 deletions.
5 changes: 5 additions & 0 deletions lawnchair/res/values-v28/colors.xml
Original file line number Diff line number Diff line change
@@ -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>
3 changes: 3 additions & 0 deletions lawnchair/src/app/lawnchair/theme/color/ColorTokens.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
17 changes: 11 additions & 6 deletions lawnchair/src/app/lawnchair/util/LawnchairUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
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;
Expand Down Expand Up @@ -64,7 +65,9 @@ public DepthController(Launcher l) {
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));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,20 +154,22 @@ public RecentsAnimationDeviceState(Context context, boolean isInstanceForTouches
}
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);
Expand Down Expand Up @@ -219,9 +221,11 @@ public void onActivityUnpinned() {
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) {
Expand Down Expand Up @@ -258,6 +262,8 @@ public void onDisplayInfoChanged(Context context, Info info, int flags) {
mMode = info.navigationMode;
mNavBarPosition = new NavBarPosition(mMode, info);

if (mExclusionListener == null) return;

if (mMode == NO_BUTTON) {
mExclusionListener.register();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
4 changes: 2 additions & 2 deletions src/com/android/launcher3/BubbleTextView.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@

import app.lawnchair.font.FontManager;
import app.lawnchair.preferences.PreferenceManager;
import app.lawnchair.theme.color.ColorTokens;
import app.lawnchair.util.LawnchairUtilsKt;

/**
Expand Down Expand Up @@ -392,8 +393,7 @@ protected void applyIconAndLabel(ItemInfoWithIcon info) {
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);
}
Expand Down
5 changes: 4 additions & 1 deletion src/com/android/launcher3/Workspace.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
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;
Expand Down Expand Up @@ -409,7 +410,9 @@ private void setPageIndicatorInset() {
} 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);
Expand Down

0 comments on commit 5931c9a

Please sign in to comment.