Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 047a54a2 authored by Tony Wickham's avatar Tony Wickham Committed by Android (Google) Code Review
Browse files

Merge changes I01790ce5,I938e23af into ub-launcher3-rvc-dev

* changes:
  Remove all apps arrow after getting to all apps 5 times
  Refactor some onboarding-related shared prefs into a class
parents fc8dc9a5 63220007
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -58,7 +58,6 @@ import androidx.annotation.WorkerThread;
import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.allapps.DiscoveryBounce;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.logging.UserEventDispatcher;
import com.android.launcher3.model.AppLaunchTracker;
@@ -68,6 +67,7 @@ import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.tracing.nano.LauncherTraceProto;
import com.android.launcher3.tracing.nano.TouchInteractionServiceProto;
import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper;
import com.android.launcher3.util.OnboardingPrefs;
import com.android.launcher3.util.TraceHelper;
import com.android.quickstep.inputconsumers.AccessibilityInputConsumer;
import com.android.quickstep.inputconsumers.AssistantInputConsumer;
@@ -378,7 +378,7 @@ public class TouchInteractionService extends Service implements PluginListener<O
        if (!sharedPrefs.getBoolean(HAS_ENABLED_QUICKSTEP_ONCE, true)) {
            sharedPrefs.edit()
                    .putBoolean(HAS_ENABLED_QUICKSTEP_ONCE, true)
                    .putBoolean(DiscoveryBounce.HOME_BOUNCE_SEEN, false)
                    .putBoolean(OnboardingPrefs.HOME_BOUNCE_SEEN, false)
                    .apply();
        }
    }
+9 −46
Original line number Diff line number Diff line
@@ -17,14 +17,7 @@ package com.android.launcher3;

import static com.android.launcher3.AbstractFloatingView.TYPE_ALL;
import static com.android.launcher3.AbstractFloatingView.TYPE_HIDE_BACK_BUTTON;
import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.allapps.DiscoveryBounce.BOUNCE_MAX_COUNT;
import static com.android.launcher3.allapps.DiscoveryBounce.HOME_BOUNCE_COUNT;
import static com.android.launcher3.allapps.DiscoveryBounce.HOME_BOUNCE_SEEN;
import static com.android.launcher3.allapps.DiscoveryBounce.SHELF_BOUNCE_COUNT;
import static com.android.launcher3.allapps.DiscoveryBounce.SHELF_BOUNCE_SEEN;
import static com.android.quickstep.SysUINavigationMode.removeShelfFromOverview;
import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_HOME_KEY;

@@ -32,6 +25,7 @@ import android.animation.AnimatorSet;
import android.animation.ValueAnimator;
import android.content.Intent;
import android.content.IntentSender;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.CancellationSignal;
import android.view.View;
@@ -47,12 +41,14 @@ import com.android.launcher3.statehandlers.BackButtonAlphaHandler;
import com.android.launcher3.statehandlers.DepthController;
import com.android.launcher3.touch.PagedOrientationHandler;
import com.android.launcher3.uioverrides.RecentsViewStateController;
import com.android.launcher3.util.OnboardingPrefs;
import com.android.launcher3.util.UiThreadHelper;
import com.android.quickstep.RecentsModel;
import com.android.quickstep.SysUINavigationMode;
import com.android.quickstep.SysUINavigationMode.Mode;
import com.android.quickstep.SysUINavigationMode.NavigationModeChangeListener;
import com.android.quickstep.SystemUiProxy;
import com.android.quickstep.util.QuickstepOnboardingPrefs;
import com.android.quickstep.util.RemoteAnimationProvider;
import com.android.quickstep.util.RemoteFadeOutAnimationListener;
import com.android.quickstep.util.ShelfPeekAnim;
@@ -86,45 +82,6 @@ public abstract class BaseQuickstepLauncher extends Launcher
        super.onCreate(savedInstanceState);

        SysUINavigationMode.INSTANCE.get(this).addModeChangeListener(this);

        if (!getSharedPrefs().getBoolean(HOME_BOUNCE_SEEN, false)) {
            getStateManager().addStateListener(new LauncherStateManager.StateListener() {
                @Override
                public void onStateTransitionStart(LauncherState toState) { }

                @Override
                public void onStateTransitionComplete(LauncherState finalState) {
                    boolean swipeUpEnabled = SysUINavigationMode.INSTANCE
                            .get(BaseQuickstepLauncher.this).getMode().hasGestures;
                    LauncherState prevState = getStateManager().getLastState();

                    if (((swipeUpEnabled && finalState == OVERVIEW) || (!swipeUpEnabled
                            && finalState == ALL_APPS && prevState == NORMAL) || BOUNCE_MAX_COUNT
                            <= getSharedPrefs().getInt(HOME_BOUNCE_COUNT, 0))) {
                        getSharedPrefs().edit().putBoolean(HOME_BOUNCE_SEEN, true).apply();
                        getStateManager().removeStateListener(this);
                    }
                }
            });
        }

        if (!getSharedPrefs().getBoolean(SHELF_BOUNCE_SEEN, false)) {
            getStateManager().addStateListener(new LauncherStateManager.StateListener() {
                @Override
                public void onStateTransitionStart(LauncherState toState) { }

                @Override
                public void onStateTransitionComplete(LauncherState finalState) {
                    LauncherState prevState = getStateManager().getLastState();

                    if ((finalState == ALL_APPS && prevState == OVERVIEW) || BOUNCE_MAX_COUNT
                            <= getSharedPrefs().getInt(SHELF_BOUNCE_COUNT, 0)) {
                        getSharedPrefs().edit().putBoolean(SHELF_BOUNCE_SEEN, true).apply();
                        getStateManager().removeStateListener(this);
                    }
                }
            });
        }
    }

    @Override
@@ -243,6 +200,12 @@ public abstract class BaseQuickstepLauncher extends Launcher
        return mDepthController;
    }

    @Override
    protected OnboardingPrefs createOnboardingPrefs(SharedPreferences sharedPrefs,
            LauncherStateManager stateManager) {
        return new QuickstepOnboardingPrefs(this, sharedPrefs, stateManager);
    }

    @Override
    protected ScaleAndTranslation getOverviewScaleAndTranslationForNormalState() {
        if (SysUINavigationMode.getMode(this) == Mode.NO_BUTTON) {
+96 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.android.quickstep.util;

import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.OVERVIEW;

import android.content.SharedPreferences;

import com.android.launcher3.BaseQuickstepLauncher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.LauncherStateManager;
import com.android.launcher3.LauncherStateManager.StateListener;
import com.android.launcher3.util.OnboardingPrefs;
import com.android.quickstep.SysUINavigationMode;

/**
 * Extends {@link OnboardingPrefs} for quickstep-specific onboarding data.
 */
public class QuickstepOnboardingPrefs extends OnboardingPrefs<BaseQuickstepLauncher> {

    public QuickstepOnboardingPrefs(BaseQuickstepLauncher launcher, SharedPreferences sharedPrefs,
            LauncherStateManager stateManager) {
        super(launcher, sharedPrefs, stateManager);

        if (!getBoolean(HOME_BOUNCE_SEEN)) {
            mStateManager.addStateListener(new StateListener() {
                @Override
                public void onStateTransitionStart(LauncherState toState) { }

                @Override
                public void onStateTransitionComplete(LauncherState finalState) {
                    boolean swipeUpEnabled = SysUINavigationMode.INSTANCE
                            .get(mLauncher).getMode().hasGestures;
                    LauncherState prevState = mStateManager.getLastState();

                    if (((swipeUpEnabled && finalState == OVERVIEW) || (!swipeUpEnabled
                            && finalState == ALL_APPS && prevState == NORMAL) ||
                            hasReachedMaxCount(HOME_BOUNCE_COUNT))) {
                        mSharedPrefs.edit().putBoolean(HOME_BOUNCE_SEEN, true).apply();
                        mStateManager.removeStateListener(this);
                    }
                }
            });
        }

        if (!getBoolean(SHELF_BOUNCE_SEEN)) {
            mStateManager.addStateListener(new StateListener() {
                @Override
                public void onStateTransitionStart(LauncherState toState) { }

                @Override
                public void onStateTransitionComplete(LauncherState finalState) {
                    LauncherState prevState = mStateManager.getLastState();

                    if ((finalState == ALL_APPS && prevState == OVERVIEW) ||
                            hasReachedMaxCount(SHELF_BOUNCE_COUNT)) {
                        mSharedPrefs.edit().putBoolean(SHELF_BOUNCE_SEEN, true).apply();
                        mStateManager.removeStateListener(this);
                    }
                }
            });
        }

        if (!hasReachedMaxCount(ALL_APPS_COUNT)) {
            mStateManager.addStateListener(new StateListener() {
                @Override
                public void onStateTransitionStart(LauncherState toState) { }

                @Override
                public void onStateTransitionComplete(LauncherState finalState) {
                    if (finalState == ALL_APPS) {
                        if (incrementEventCount(ALL_APPS_COUNT)) {
                            mStateManager.removeStateListener(this);
                            mLauncher.getScrimView().updateDragHandleVisibility();
                        }
                    }
                }
            });
        }
    }
}
+9 −3
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import com.android.launcher3.Utilities;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.uioverrides.states.OverviewState;
import com.android.launcher3.util.OnboardingPrefs;
import com.android.launcher3.util.Themes;
import com.android.launcher3.views.ScrimView;
import com.android.quickstep.SysUINavigationMode;
@@ -75,6 +76,7 @@ public class ShelfScrimView extends ScrimView<BaseQuickstepLauncher>
    private final float mRadius;
    private final int mMaxScrimAlpha;
    private final Paint mPaint;
    private final OnboardingPrefs mOnboardingPrefs;

    // Mid point where the alpha changes
    private int mMidAlpha;
@@ -100,6 +102,7 @@ public class ShelfScrimView extends ScrimView<BaseQuickstepLauncher>
    private boolean mRemainingScreenPathValid = false;

    private Mode mSysUINavigationMode;
    private boolean mIsTwoZoneSwipeModel;

    public ShelfScrimView(Context context, AttributeSet attrs) {
        super(context, attrs);
@@ -108,6 +111,7 @@ public class ShelfScrimView extends ScrimView<BaseQuickstepLauncher>
        mEndAlpha = Color.alpha(mEndScrim);
        mRadius = BOTTOM_CORNER_RADIUS_RATIO * Themes.getDialogCornerRadius(context);
        mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mOnboardingPrefs = mLauncher.getOnboardingPrefs();

        // Just assume the easiest UI for now, until we have the proper layout information.
        mDrawingFlatColor = true;
@@ -140,9 +144,11 @@ public class ShelfScrimView extends ScrimView<BaseQuickstepLauncher>
            // Show the shelf more quickly before reaching overview progress.
            mBeforeMidProgressColorInterpolator = ACCEL_2;
            mAfterMidProgressColorInterpolator = ACCEL;
            mIsTwoZoneSwipeModel = FeatureFlags.ENABLE_OVERVIEW_ACTIONS.get();
        } else {
            mBeforeMidProgressColorInterpolator = ACCEL;
            mAfterMidProgressColorInterpolator = Interpolators.clampToProgress(ACCEL, 0.5f, 1f);
            mIsTwoZoneSwipeModel = false;
        }
    }

@@ -236,9 +242,9 @@ public class ShelfScrimView extends ScrimView<BaseQuickstepLauncher>

    @Override
    protected boolean shouldDragHandleBeVisible() {
        boolean twoZoneSwipeModel = FeatureFlags.ENABLE_OVERVIEW_ACTIONS.get()
                && SysUINavigationMode.removeShelfFromOverview(mLauncher);
        return twoZoneSwipeModel || super.shouldDragHandleBeVisible();
        boolean needsAllAppsEdu = mIsTwoZoneSwipeModel
                && !mOnboardingPrefs.hasReachedMaxCount(OnboardingPrefs.ALL_APPS_COUNT);
        return needsAllAppsEdu || super.shouldDragHandleBeVisible();
    }

    @Override
+13 −0
Original line number Diff line number Diff line
@@ -139,6 +139,7 @@ import com.android.launcher3.util.IntArray;
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.MultiValueAlpha;
import com.android.launcher3.util.MultiValueAlpha.AlphaProperty;
import com.android.launcher3.util.OnboardingPrefs;
import com.android.launcher3.util.PackageManagerHelper;
import com.android.launcher3.util.PackageUserKey;
import com.android.launcher3.util.PendingRequestArgs;
@@ -300,6 +301,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
    // We only want to get the SharedPreferences once since it does an FS stat each time we get
    // it from the context.
    private SharedPreferences mSharedPrefs;
    private OnboardingPrefs mOnboardingPrefs;

    // Activity result which needs to be processed after workspace has loaded.
    private ActivityResultInfo mPendingActivityResult;
@@ -367,6 +369,8 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
        mAllAppsController = new AllAppsTransitionController(this);
        mStateManager = new LauncherStateManager(this);

        mOnboardingPrefs = createOnboardingPrefs(mSharedPrefs, mStateManager);

        mAppWidgetManager = new WidgetManagerHelper(this);
        mAppWidgetHost = new LauncherAppWidgetHost(this,
                appWidgetId -> getWorkspace().removeWidget(appWidgetId));
@@ -458,6 +462,15 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
        return new LauncherOverlayManager() { };
    }

    protected OnboardingPrefs createOnboardingPrefs(SharedPreferences sharedPrefs,
            LauncherStateManager stateManager) {
        return new OnboardingPrefs<>(this, sharedPrefs, stateManager);
    }

    public OnboardingPrefs getOnboardingPrefs() {
        return mOnboardingPrefs;
    }

    @Override
    public void onPluginConnected(OverlayPlugin overlayManager, Context context) {
        switchOverlay(() -> overlayManager.createOverlayManager(this, this));
Loading