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

Commit 63220007 authored by Tony Wickham's avatar Tony Wickham
Browse files

Remove all apps arrow after getting to all apps 5 times

- Instead of ScrimView implementing StateListener, added
  mAccessibilityLauncherStateListener.
- Added allAppsStateListener to determine whether we
  reached all apps 5 times.

Bug: 151768994
Change-Id: I01790ce577879eab2e4568fcda19d0245b256d13
parent 133cd544
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -75,5 +75,22 @@ public class QuickstepOnboardingPrefs extends OnboardingPrefs<BaseQuickstepLaunc
                }
            });
        }

        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
+8 −3
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ public class OnboardingPrefs<T extends Launcher> {
    public static final String SHELF_BOUNCE_SEEN = "launcher.shelf_bounce_seen";
    public static final String HOME_BOUNCE_COUNT = "launcher.home_bounce_count";
    public static final String SHELF_BOUNCE_COUNT = "launcher.shelf_bounce_count";
    public static final String ALL_APPS_COUNT = "launcher.all_apps_count";

    /**
     * Events that either have happened or have not (booleans).
@@ -54,15 +55,17 @@ public class OnboardingPrefs<T extends Launcher> {
    @StringDef(value = {
            HOME_BOUNCE_COUNT,
            SHELF_BOUNCE_COUNT,
            ALL_APPS_COUNT,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface EventCountKey {}

    private static final Map<String, Integer> MAX_COUNTS;
    static {
        Map<String, Integer> maxCounts = new ArrayMap<>(2);
        Map<String, Integer> maxCounts = new ArrayMap<>(3);
        maxCounts.put(HOME_BOUNCE_COUNT, 3);
        maxCounts.put(SHELF_BOUNCE_COUNT, 3);
        maxCounts.put(ALL_APPS_COUNT, 5);
        MAX_COUNTS = Collections.unmodifiableMap(maxCounts);
    }

@@ -98,13 +101,15 @@ public class OnboardingPrefs<T extends Launcher> {

    /**
     * Add 1 to the given event count, if we haven't already reached the max count.
     * @return Whether we have now reached the max count.
     */
    public void incrementEventCount(@EventCountKey String eventKey) {
    public boolean incrementEventCount(@EventCountKey String eventKey) {
        int count = getCount(eventKey);
        if (hasReachedMaxCount(count, eventKey)) {
            return;
            return true;
        }
        count++;
        mSharedPrefs.edit().putInt(eventKey, count).apply();
        return hasReachedMaxCount(count, eventKey);
    }
}
+22 −20
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ import java.util.List;
 * Simple scrim which draws a flat color
 */
public class ScrimView<T extends Launcher> extends View implements Insettable, OnChangeListener,
        AccessibilityStateChangeListener, StateListener {
        AccessibilityStateChangeListener {

    public static final IntProperty<ScrimView> DRAG_HANDLE_ALPHA =
            new IntProperty<ScrimView>("dragHandleAlpha") {
@@ -116,6 +116,18 @@ public class ScrimView<T extends Launcher> extends View implements Insettable, O
    private final AccessibilityManager mAM;
    protected final int mEndScrim;

    private final StateListener mAccessibilityLauncherStateListener = new StateListener() {
        @Override
        public void onStateTransitionStart(LauncherState toState) {}

        @Override
        public void onStateTransitionComplete(LauncherState finalState) {
            setImportantForAccessibility(finalState == ALL_APPS
                    ? IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
                    : IMPORTANT_FOR_ACCESSIBILITY_AUTO);
        }
    };

    protected float mMaxScrimAlpha;

    protected float mProgress = 1;
@@ -177,7 +189,7 @@ public class ScrimView<T extends Launcher> extends View implements Insettable, O
    @Override
    public void setInsets(Rect insets) {
        updateDragHandleBounds();
        updateDragHandleVisibility(null);
        updateDragHandleVisibility();
    }

    @Override
@@ -375,18 +387,22 @@ public class ScrimView<T extends Launcher> extends View implements Insettable, O
    @Override
    public void onAccessibilityStateChanged(boolean enabled) {
        LauncherStateManager stateManager = mLauncher.getStateManager();
        stateManager.removeStateListener(this);
        stateManager.removeStateListener(mAccessibilityLauncherStateListener);

        if (enabled) {
            stateManager.addStateListener(this);
            handleStateChangedComplete(stateManager.getState());
            stateManager.addStateListener(mAccessibilityLauncherStateListener);
            mAccessibilityLauncherStateListener.onStateTransitionComplete(stateManager.getState());
        } else {
            setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);
        }
        updateDragHandleVisibility();
    }

    public void updateDragHandleVisibility() {
        updateDragHandleVisibility(null);
    }

    private void updateDragHandleVisibility(Drawable recycle) {
    private void updateDragHandleVisibility(@Nullable Drawable recycle) {
        boolean visible = shouldDragHandleBeVisible();
        boolean wasVisible = mDragHandle != null;
        if (visible != wasVisible) {
@@ -424,20 +440,6 @@ public class ScrimView<T extends Launcher> extends View implements Insettable, O
        mAccessibilityHelper.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
    }

    @Override
    public void onStateTransitionStart(LauncherState toState) {}

    @Override
    public void onStateTransitionComplete(LauncherState finalState) {
        handleStateChangedComplete(finalState);
    }

    private void handleStateChangedComplete(LauncherState finalState) {
        setImportantForAccessibility(finalState == ALL_APPS
                ? IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
                : IMPORTANT_FOR_ACCESSIBILITY_AUTO);
    }

    protected class AccessibilityHelper extends ExploreByTouchHelper {

        private static final int DRAG_HANDLE_ID = 1;