Fix more build errors

This commit is contained in:
Suphon Thanakornpakapong
2022-05-08 22:53:06 +07:00
parent 562611b75d
commit 952551cb4c
14 changed files with 104 additions and 35 deletions

View File

@@ -0,0 +1,35 @@
package com.android.systemui.shared;
import android.annotation.SuppressLint;
import android.os.Build;
import app.lawnchair.compatlib.ActivityManagerCompat;
import app.lawnchair.compatlib.QuickstepCompatFactory;
import app.lawnchair.compatlib.eleven.QuickstepCompatFactoryVR;
import app.lawnchair.compatlib.twelve.QuickstepCompatFactoryVS;
public class QuickstepCompat {
private static final QuickstepCompatFactory sFactory;
private static final ActivityManagerCompat sActivityManagerCompat;
@SuppressLint("AnnotateVersionCheck")
public static final boolean ATLEAST_S = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S;
static {
if (ATLEAST_S) {
sFactory = new QuickstepCompatFactoryVS();
} else {
sFactory = new QuickstepCompatFactoryVR();
}
sActivityManagerCompat = sFactory.getActivityManagerCompat();
}
public static QuickstepCompatFactory getFactory() {
return sFactory;
}
public static ActivityManagerCompat getActivityManagerCompat() {
return sActivityManagerCompat;
}
}

View File

@@ -36,6 +36,8 @@ public class Utilities {
private static final float TABLET_MIN_DPS = 600;
public static final boolean ATLEAST_S_V2 = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S_V2;
/**
* Posts a runnable on a handler at the front of the queue ignoring any sync barriers.
*/

View File

@@ -71,7 +71,7 @@ public class ActivityManagerWrapper {
// Should match the value in AssistManager
private static final String INVOCATION_TIME_MS_KEY = "invocation_time_ms";
private final ActivityTaskManager mAtm = ActivityTaskManager.getInstance();
private final ActivityTaskManager mAtm = null;
private ActivityManagerWrapper() { }
public static ActivityManagerWrapper getInstance() {
@@ -103,6 +103,7 @@ public class ActivityManagerWrapper {
* list (can be {@code null}).
*/
public ActivityManager.RunningTaskInfo getRunningTask(boolean filterOnlyVisibleRecents) {
// TODO: Switch to QuickstepCompat call
// Note: The set of running tasks from the system is ordered by recency
List<ActivityManager.RunningTaskInfo> tasks =
mAtm.getTasks(1, filterOnlyVisibleRecents);

View File

@@ -24,6 +24,7 @@ import android.app.ActivityOptions;
import android.content.Context;
import android.os.Handler;
import com.android.systemui.shared.QuickstepCompat;
import com.android.systemui.shared.recents.model.Task;
/**
@@ -60,8 +61,13 @@ public abstract class ActivityOptionsCompat {
public static ActivityOptions makeRemoteAnimation(
RemoteAnimationAdapterCompat remoteAnimationAdapter) {
if (QuickstepCompat.ATLEAST_S) {
return ActivityOptions.makeRemoteAnimation(remoteAnimationAdapter.getWrapped(),
remoteAnimationAdapter.getRemoteTransition().getTransition());
} else {
return ActivityOptions.makeRemoteAnimation(remoteAnimationAdapter.getWrapped());
}
}
/**
@@ -77,6 +83,18 @@ public abstract class ActivityOptionsCompat {
*/
public static ActivityOptions makeCustomAnimation(Context context, int enterResId,
int exitResId, final Runnable callback, final Handler callbackHandler) {
if (!QuickstepCompat.ATLEAST_S) {
return ActivityOptions.makeCustomAnimation(context, enterResId, exitResId,
callbackHandler,
new ActivityOptions.OnAnimationStartedListener() {
@Override
public void onAnimationStarted() {
if (callback != null) {
callbackHandler.post(callback);
}
}
}, null /* finishedListener */);
}
return ActivityOptions.makeCustomTaskAnimation(context, enterResId, exitResId,
callbackHandler,
new ActivityOptions.OnAnimationStartedListener() {
@@ -101,7 +119,9 @@ public abstract class ActivityOptionsCompat {
* Sets the launch event time from launcher.
*/
public static ActivityOptions setLauncherSourceInfo(ActivityOptions opts, long uptimeMillis) {
if (QuickstepCompat.ATLEAST_S) {
opts.setSourceInfo(ActivityOptions.SourceInfo.TYPE_LAUNCHER, uptimeMillis);
}
return opts;
}

View File

@@ -16,7 +16,9 @@
package com.android.systemui.unfold.config
import android.content.Context
import android.os.Build
import android.os.SystemProperties
import com.android.systemui.shared.recents.utilities.Utilities
internal class ResourceUnfoldTransitionConfig(
private val context: Context
@@ -32,11 +34,17 @@ internal class ResourceUnfoldTransitionConfig(
get() = SystemProperties.getInt(UNFOLD_TRANSITION_MODE_PROPERTY_NAME,
UNFOLD_TRANSITION_PROPERTY_ENABLED) == UNFOLD_TRANSITION_PROPERTY_ENABLED
private fun readIsEnabledResource(): Boolean = context.resources
private fun readIsEnabledResource(): Boolean {
if (!Utilities.ATLEAST_S_V2) return false
return context.resources
.getBoolean(com.android.internal.R.bool.config_unfoldTransitionEnabled)
}
private fun readIsHingeAngleEnabled(): Boolean = context.resources
private fun readIsHingeAngleEnabled(): Boolean {
if (!Utilities.ATLEAST_S_V2) return false
return context.resources
.getBoolean(com.android.internal.R.bool.config_unfoldTransitionHingeAngle)
}
}
/**

View File

@@ -1,7 +1,7 @@
buildscript {
ext {
kotlin_version = '1.6.10'
compose_version = '1.2.0-alpha04'
kotlin_version = '1.6.20'
compose_version = '1.2.0-alpha08'
accompanist_version = '0.24.2-alpha'
libsu_version = '3.1.2'
protocVersion = '3.18.0'
@@ -325,14 +325,14 @@ dependencies {
implementation "androidx.compose.ui:ui-tooling:$compose_version"
implementation "androidx.compose.foundation:foundation:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.material3:material3:1.0.0-alpha06"
implementation "androidx.compose.material3:material3:1.0.0-alpha10"
implementation "androidx.compose.runtime:runtime-livedata:$compose_version"
implementation "androidx.compose.runtime:runtime-rxjava2:$compose_version"
implementation "androidx.compose.compiler:compiler:$compose_version"
implementation "androidx.constraintlayout:constraintlayout:2.1.3"
implementation 'androidx.activity:activity-compose:1.4.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:2.4.1'
implementation "androidx.navigation:navigation-compose:2.4.1"
implementation "androidx.navigation:navigation-compose:2.4.2"
implementation "androidx.palette:palette-ktx:${ANDROID_X_VERSION}"
implementation "androidx.slice:slice-core:1.1.0-alpha02"
implementation "com.google.accompanist:accompanist-drawablepainter:$accompanist_version"

View File

@@ -10,8 +10,8 @@ GRADLE_CLASS_PATH=com.android.tools.build:gradle:4.0.0
PROTOBUF_CLASS_PATH=com.google.protobuf:protobuf-gradle-plugin:0.8.16
PROTOBUF_DEPENDENCY=com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-7
BUILD_TOOLS_VERSION=31.0.0
COMPILE_SDK=android-31
BUILD_TOOLS_VERSION=32.0.0
COMPILE_SDK=android-32
org.gradle.jvmargs=-Xmx2048m

View File

@@ -18,6 +18,7 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="com.google.android.apps.nexuslauncher.permission.QSB"/>

View File

@@ -39,9 +39,8 @@ import androidx.lifecycle.*
import androidx.savedstate.SavedStateRegistry
import androidx.savedstate.SavedStateRegistryController
import androidx.savedstate.SavedStateRegistryOwner
import androidx.savedstate.ViewTreeSavedStateRegistryOwner
import androidx.savedstate.setViewTreeSavedStateRegistryOwner
import app.lawnchair.gestures.GestureController
import app.lawnchair.icons.CustomAdaptiveIconDrawable
import app.lawnchair.nexuslauncher.OverlayCallbackImpl
import app.lawnchair.preferences.PreferenceManager
import app.lawnchair.preferences2.PreferenceManager2
@@ -54,6 +53,7 @@ import app.lawnchair.ui.popup.LawnchairShortcut
import app.lawnchair.util.Constants.LAWNICONS_PACKAGE_NAME
import app.lawnchair.util.isPackageInstalled
import com.android.launcher3.*
import com.android.launcher3.R
import com.android.launcher3.allapps.AllAppsContainerView
import com.android.launcher3.allapps.search.SearchAdapterProvider
import com.android.launcher3.popup.SystemShortcut
@@ -79,6 +79,8 @@ class LawnchairLauncher : QuickstepLauncher(), LifecycleOwner,
private val lifecycleRegistry = LifecycleRegistry(this)
private val savedStateRegistryController = SavedStateRegistryController.create(this)
override val savedStateRegistry: SavedStateRegistry
get() = savedStateRegistryController.savedStateRegistry
private val activityResultRegistry = object : ActivityResultRegistry() {
override fun <I : Any?, O : Any?> onLaunch(
requestCode: Int,
@@ -155,7 +157,6 @@ class LawnchairLauncher : QuickstepLauncher(), LifecycleOwner,
private val defaultOverlay by lazy { OverlayCallbackImpl(this) }
private val prefs by lazy { PreferenceManager.getInstance(this) }
private val preferenceManager2 by lazy { PreferenceManager2.getInstance(this) }
private val invariantDeviceProfile by lazy { InvariantDeviceProfile.INSTANCE.get(this) }
private val insetsController by lazy { WindowInsetsControllerCompat(launcher.window, rootView) }
var allAppsScrimColor = 0
@@ -238,7 +239,7 @@ class LawnchairLauncher : QuickstepLauncher(), LifecycleOwner,
super.setupViews()
val launcherRootView = findViewById<LauncherRootView>(R.id.launcher)
ViewTreeLifecycleOwner.set(launcherRootView, this)
ViewTreeSavedStateRegistryOwner.set(launcherRootView, this)
launcherRootView.setViewTreeSavedStateRegistryOwner(this)
}
override fun collectStateHandlers(out: MutableList<StateManager.StateHandler<*>>) {
@@ -326,10 +327,6 @@ class LawnchairLauncher : QuickstepLauncher(), LifecycleOwner,
return lifecycleRegistry
}
override fun getSavedStateRegistry(): SavedStateRegistry {
return savedStateRegistryController.savedStateRegistry
}
override fun getActivityResultRegistry(): ActivityResultRegistry {
return activityResultRegistry
}

View File

@@ -7,7 +7,6 @@ import android.graphics.drawable.GradientDrawable
import android.util.TypedValue
import androidx.annotation.AttrRes
import androidx.annotation.DrawableRes
import androidx.appcompat.content.res.AppCompatResources
import app.lawnchair.theme.ResourceToken
import app.lawnchair.theme.UiColorMode
import app.lawnchair.theme.color.ColorToken
@@ -20,7 +19,7 @@ data class ResourceDrawableToken<T : Drawable>(@DrawableRes private val resId: I
@Suppress("UNCHECKED_CAST")
override fun resolve(context: Context, scheme: ColorScheme, uiColorMode: UiColorMode): T {
return AppCompatResources.getDrawable(context, resId) as T
return context.getDrawable(resId) as T
}
}

View File

@@ -80,6 +80,8 @@ import java.util.Map;
import java.util.Objects;
import java.util.stream.IntStream;
import app.lawnchair.LawnchairApp;
/**
* Model delegate which loads prediction items
*/
@@ -178,7 +180,7 @@ public class QuickstepModelDelegate extends ModelDelegate {
// Only register for launcher snapshot logging if this is the primary ModelDelegate
// instance, as there will be additional instances that may be destroyed at any time.
if (mIsPrimaryInstance) {
if (mIsPrimaryInstance && LawnchairApp.isRecentsEnabled()) {
registerSnapshotLoggingCallback();
}
}

View File

@@ -86,6 +86,7 @@ public class OverviewActionsView<T extends OverlayUICallbacks> extends FrameLayo
private final MultiValueAlpha mMultiValueAlpha;
private Button mSplitButton;
private View mSplitSpace;
@ActionsHiddenFlags
private int mHiddenFlags;
@@ -120,6 +121,8 @@ public class OverviewActionsView<T extends OverlayUICallbacks> extends FrameLayo
mSplitButton = findViewById(R.id.action_split);
mSplitButton.setOnClickListener(this);
mSplitSpace = findViewById(R.id.action_split_space);
}
/**
@@ -224,7 +227,7 @@ public class OverviewActionsView<T extends OverlayUICallbacks> extends FrameLayo
dp.isVerticalBarLayout() ? 0 : dp.overviewActionsButtonSpacing,
ViewGroup.LayoutParams.MATCH_PARENT);
params.weight = dp.isVerticalBarLayout() ? 1 : 0;
findViewById(R.id.action_split_space).setLayoutParams(params);
mSplitSpace.setLayoutParams(params);
requestLayout();
@@ -239,7 +242,7 @@ public class OverviewActionsView<T extends OverlayUICallbacks> extends FrameLayo
}
mSplitButton.setVisibility(visible ? VISIBLE : GONE);
findViewById(R.id.action_split_space).setVisibility(visible ? VISIBLE : GONE);
mSplitSpace.setVisibility(visible ? VISIBLE : GONE);
}
/** Get the top margin associated with the action buttons in Overview. */

View File

@@ -16,7 +16,6 @@
package com.android.launcher3.popup;
import static androidx.core.content.ContextCompat.getColorStateList;
import static com.android.launcher3.anim.Interpolators.ACCELERATED_EASE;
import static com.android.launcher3.anim.Interpolators.DECELERATED_EASE;
import static com.android.launcher3.anim.Interpolators.LINEAR;
@@ -133,7 +132,7 @@ public abstract class ArrowPopup<T extends Context & ActivityContext>
private final String mIterateChildrenTag;
private final int[] mColorIds;
private final int[] mColors;
public ArrowPopup(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
@@ -180,10 +179,13 @@ public abstract class ArrowPopup<T extends Context & ActivityContext>
// TODO: use ColorTokens
if (shouldUseColorExtraction) {
mColorIds = new int[]{R.color.popup_shade_first, R.color.popup_shade_second,
R.color.popup_shade_third};
mColors = new int[] {
ColorTokens.PopupShadeFirst.resolveColor(context),
ColorTokens.PopupShadeSecond.resolveColor(context),
ColorTokens.PopupShadeThird.resolveColor(context)};
} else {
mColorIds = new int[]{R.color.popup_shade_first};
mColors = new int[] {
ColorTokens.PopupShadeFirst.resolveColor(context)};
}
}
@@ -235,15 +237,14 @@ public abstract class ArrowPopup<T extends Context & ActivityContext>
}
/**
* @param backgroundColor When Color.TRANSPARENT, we get color from {@link #mColorIds}.
* @param backgroundColor When Color.TRANSPARENT, we get color from {@link #mColors}.
* Otherwise, we will use this color for all child views.
*/
protected void assignMarginsAndBackgrounds(ViewGroup viewGroup, int backgroundColor) {
int[] colors = null;
if (backgroundColor == Color.TRANSPARENT) {
// Lazily get the colors so they match the current wallpaper colors.
colors = Arrays.stream(mColorIds).map(
r -> getColorStateList(getContext(), r).getDefaultColor()).toArray();
colors = mColors;
}
int count = viewGroup.getChildCount();