mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-11 06:44:00 +00:00
fixed crashes NPE's below 12
This commit is contained in:
@@ -32,14 +32,19 @@ 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;
|
||||
import com.android.quickstep.util.BaseDepthController;
|
||||
import com.patrykmichalik.opto.core.PreferenceExtensionsKt;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import app.lawnchair.compat.LawnchairQuickstepCompat;
|
||||
import app.lawnchair.preferences2.PreferenceManager2;
|
||||
|
||||
/**
|
||||
* Controls blur and wallpaper zoom, for the Launcher surface only.
|
||||
*/
|
||||
@@ -57,14 +62,24 @@ public class DepthController extends BaseDepthController implements StateHandler
|
||||
|
||||
private View.OnAttachStateChangeListener mOnAttachListener;
|
||||
|
||||
private final boolean mEnableDepth;
|
||||
|
||||
public DepthController(Launcher l) {
|
||||
super(l);
|
||||
var pref = PreferenceManager2.getInstance(l).getWallpaperDepthEffect();
|
||||
mEnableDepth = PreferenceExtensionsKt.firstBlocking(pref);
|
||||
}
|
||||
|
||||
private void onLauncherDraw() {
|
||||
View view = mLauncher.getDragLayer();
|
||||
ViewRootImpl viewRootImpl = view.getViewRootImpl();
|
||||
setSurface(viewRootImpl != null ? viewRootImpl.getSurfaceControl() : null);
|
||||
try {
|
||||
if (Utilities.ATLEAST_Q) {
|
||||
setSurface(viewRootImpl != null ? viewRootImpl.getSurfaceControl() : null);
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
// Ignore any exceptions
|
||||
}
|
||||
view.post(() -> view.getViewTreeObserver().removeOnDrawListener(mOnDrawListener));
|
||||
}
|
||||
|
||||
@@ -74,8 +89,12 @@ public class DepthController extends BaseDepthController implements StateHandler
|
||||
mOnAttachListener = new View.OnAttachStateChangeListener() {
|
||||
@Override
|
||||
public void onViewAttachedToWindow(View view) {
|
||||
CrossWindowBlurListeners.getInstance().addListener(mLauncher.getMainExecutor(),
|
||||
mCrossWindowBlurListener);
|
||||
try {
|
||||
CrossWindowBlurListeners.getInstance().addListener(mLauncher.getMainExecutor(),
|
||||
mCrossWindowBlurListener);
|
||||
} catch (Throwable t) {
|
||||
// Ignore
|
||||
}
|
||||
mLauncher.getScrimView().addOpaquenessListener(mOpaquenessListener);
|
||||
|
||||
// To handle the case where window token is invalid during last setDepth call.
|
||||
@@ -108,7 +127,11 @@ public class DepthController extends BaseDepthController implements StateHandler
|
||||
|
||||
private void removeSecondaryListeners() {
|
||||
if (mCrossWindowBlurListener != null) {
|
||||
CrossWindowBlurListeners.getInstance().removeListener(mCrossWindowBlurListener);
|
||||
try {
|
||||
CrossWindowBlurListeners.getInstance().removeListener(mCrossWindowBlurListener);
|
||||
} catch (Throwable t) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
if (mOpaquenessListener != null) {
|
||||
mLauncher.getScrimView().removeOpaquenessListener(mOpaquenessListener);
|
||||
@@ -154,8 +177,14 @@ public class DepthController extends BaseDepthController implements StateHandler
|
||||
|
||||
@Override
|
||||
protected void applyDepthAndBlur() {
|
||||
ensureDependencies();
|
||||
super.applyDepthAndBlur();
|
||||
try {
|
||||
if (LawnchairQuickstepCompat.ATLEAST_R && mEnableDepth) {
|
||||
ensureDependencies();
|
||||
super.applyDepthAndBlur();
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -185,30 +185,34 @@ public class SystemUiProxy implements ISystemUiProxy, NavHandle, SafeCloseable {
|
||||
* different process). It is bare-bones, so it's expected that the component and options will
|
||||
* be provided via fill-in intent.
|
||||
*/
|
||||
private final PendingIntent mRecentsPendingIntent;
|
||||
private PendingIntent mRecentsPendingIntent;
|
||||
|
||||
@Nullable
|
||||
private final ProxyUnfoldTransitionProvider mUnfoldTransitionProvider;
|
||||
private ProxyUnfoldTransitionProvider mUnfoldTransitionProvider;
|
||||
|
||||
private SystemUiProxy(Context context) {
|
||||
mContext = context;
|
||||
mAsyncHandler = new Handler(UI_HELPER_EXECUTOR.getLooper(), this::handleMessageAsync);
|
||||
final Intent baseIntent = new Intent().setPackage(mContext.getPackageName());
|
||||
final ActivityOptions options = ActivityOptions.makeBasic();
|
||||
if (Utilities.ATLEAST_U) {
|
||||
options.setPendingIntentCreatorBackgroundActivityStartMode(
|
||||
ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED);
|
||||
if (Utilities.ATLEAST_Q) {
|
||||
|
||||
final ActivityOptions options = ActivityOptions.makeBasic();
|
||||
if (Utilities.ATLEAST_U) {
|
||||
options.setPendingIntentCreatorBackgroundActivityStartMode(
|
||||
ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED);
|
||||
}
|
||||
|
||||
mRecentsPendingIntent = LawnchairQuickstepCompat.ATLEAST_V ? PendingIntent.getActivity(mContext, 0, baseIntent,
|
||||
PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT
|
||||
| Intent.FILL_IN_COMPONENT, options.toBundle()) : PendingIntent.getActivity(mContext, 0, baseIntent,
|
||||
PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT
|
||||
| Intent.FILL_IN_COMPONENT) ;
|
||||
|
||||
mUnfoldTransitionProvider =
|
||||
(enableUnfoldStateAnimation() && new ResourceUnfoldTransitionConfig().isEnabled())
|
||||
? new ProxyUnfoldTransitionProvider() : null;
|
||||
}
|
||||
|
||||
mRecentsPendingIntent = LawnchairQuickstepCompat.ATLEAST_V ? PendingIntent.getActivity(mContext, 0, baseIntent,
|
||||
PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT
|
||||
| Intent.FILL_IN_COMPONENT) : PendingIntent.getActivity(mContext, 0, baseIntent,
|
||||
PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT
|
||||
| Intent.FILL_IN_COMPONENT, options.toBundle()) ;
|
||||
|
||||
mUnfoldTransitionProvider =
|
||||
(enableUnfoldStateAnimation() && new ResourceUnfoldTransitionConfig().isEnabled())
|
||||
? new ProxyUnfoldTransitionProvider() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user