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

Commit 75418ccf authored by Tracy Zhou's avatar Tracy Zhou
Browse files

Update QuickScrub tip according to the latest spec.

- Treat inreaction to the tip as 1st dismissal.
- Show tip after 1st dismissal based on Overview opened count instead of
app launch count.

Bug: 70180942
Test: manual test
Change-Id: I4410c78ac547ad49bd135dede71e79aaca2e1b10
parent ca6f3653
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -94,6 +94,8 @@ public final class Prefs {
        String OVERVIEW_OPENED_FROM_HOME_COUNT = "OverviewOpenedFromHomeCount";
        String OVERVIEW_OPENED_FROM_HOME_COUNT = "OverviewOpenedFromHomeCount";
        String HAS_SEEN_RECENTS_SWIPE_UP_ONBOARDING = "HasSeenRecentsSwipeUpOnboarding";
        String HAS_SEEN_RECENTS_SWIPE_UP_ONBOARDING = "HasSeenRecentsSwipeUpOnboarding";
        String HAS_SEEN_RECENTS_QUICK_SCRUB_ONBOARDING = "HasSeenRecentsQuickScrubOnboarding";
        String HAS_SEEN_RECENTS_QUICK_SCRUB_ONBOARDING = "HasSeenRecentsQuickScrubOnboarding";
        String HAS_DISMISSED_RECENTS_QUICK_SCRUB_ONBOARDING_ONCE =
                "HasDismissedRecentsQuickScrubOnboardingOnce";
        String SEEN_RINGER_GUIDANCE_COUNT = "RingerGuidanceCount";
        String SEEN_RINGER_GUIDANCE_COUNT = "RingerGuidanceCount";
        String QS_TILE_SPECS_REVEALED = "QsTileSpecsRevealed";
        String QS_TILE_SPECS_REVEALED = "QsTileSpecsRevealed";
        String QS_HAS_TURNED_OFF_MOBILE_DATA = "QsHasTurnedOffMobileData";
        String QS_HAS_TURNED_OFF_MOBILE_DATA = "QsHasTurnedOffMobileData";
+47 −24
Original line number Original line Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.recents;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;


import static com.android.systemui.Prefs.Key.HAS_DISMISSED_RECENTS_QUICK_SCRUB_ONBOARDING_ONCE;
import static com.android.systemui.Prefs.Key.HAS_SEEN_RECENTS_QUICK_SCRUB_ONBOARDING;
import static com.android.systemui.Prefs.Key.HAS_SEEN_RECENTS_QUICK_SCRUB_ONBOARDING;
import static com.android.systemui.Prefs.Key.HAS_SEEN_RECENTS_SWIPE_UP_ONBOARDING;
import static com.android.systemui.Prefs.Key.HAS_SEEN_RECENTS_SWIPE_UP_ONBOARDING;
import static com.android.systemui.Prefs.Key.OVERVIEW_OPENED_COUNT;
import static com.android.systemui.Prefs.Key.OVERVIEW_OPENED_COUNT;
@@ -76,9 +77,6 @@ public class RecentsOnboarding {
    // After explicitly dismissing, show again after launching this number of apps for swipe-up
    // After explicitly dismissing, show again after launching this number of apps for swipe-up
    // tips.
    // tips.
    private static final int SWIPE_UP_SHOW_ON_APP_LAUNCH_AFTER_DISMISS = 5;
    private static final int SWIPE_UP_SHOW_ON_APP_LAUNCH_AFTER_DISMISS = 5;
    // After explicitly dismissing, show again after launching this number of apps for QuickScrub
    // tips.
    private static final int QUICK_SCRUB_SHOW_ON_APP_LAUNCH_AFTER_DISMISS = 10;


    private final Context mContext;
    private final Context mContext;
    private final WindowManager mWindowManager;
    private final WindowManager mWindowManager;
@@ -99,7 +97,7 @@ public class RecentsOnboarding {
    private boolean mHasDismissedSwipeUpTip;
    private boolean mHasDismissedSwipeUpTip;
    private boolean mHasDismissedQuickScrubTip;
    private boolean mHasDismissedQuickScrubTip;
    private int mNumAppsLaunchedSinceSwipeUpTipDismiss;
    private int mNumAppsLaunchedSinceSwipeUpTipDismiss;
    private int mNumAppsLaunchedSinceQuickScrubTipDismiss;
    private int mOverviewOpenedCountSinceQuickScrubTipDismiss;


    private final SysUiTaskStackChangeListener mTaskListener = new SysUiTaskStackChangeListener() {
    private final SysUiTaskStackChangeListener mTaskListener = new SysUiTaskStackChangeListener() {
        @Override
        @Override
@@ -145,10 +143,9 @@ public class RecentsOnboarding {
                } else {
                } else {
                    if (getOpenedOverviewCount() >= QUICK_SCRUB_SHOW_ON_OVERVIEW_OPENED_COUNT) {
                    if (getOpenedOverviewCount() >= QUICK_SCRUB_SHOW_ON_OVERVIEW_OPENED_COUNT) {
                        if (mHasDismissedQuickScrubTip) {
                        if (mHasDismissedQuickScrubTip) {
                            mNumAppsLaunchedSinceQuickScrubTipDismiss++;
                            if (mOverviewOpenedCountSinceQuickScrubTipDismiss
                            if (mNumAppsLaunchedSinceQuickScrubTipDismiss
                                    == QUICK_SCRUB_SHOW_ON_OVERVIEW_OPENED_COUNT) {
                                    == QUICK_SCRUB_SHOW_ON_APP_LAUNCH_AFTER_DISMISS) {
                                mOverviewOpenedCountSinceQuickScrubTipDismiss = 0;
                                mNumAppsLaunchedSinceQuickScrubTipDismiss = 0;
                                show(R.string.recents_quick_scrub_onboarding);
                                show(R.string.recents_quick_scrub_onboarding);
                            }
                            }
                        } else {
                        } else {
@@ -166,14 +163,19 @@ public class RecentsOnboarding {
            new OverviewProxyService.OverviewProxyListener() {
            new OverviewProxyService.OverviewProxyListener() {
                @Override
                @Override
                public void onOverviewShown(boolean fromHome) {
                public void onOverviewShown(boolean fromHome) {
                    boolean alreadySeenRecentsOnboarding = hasSeenSwipeUpOnboarding();
                    if (!hasSeenSwipeUpOnboarding() && !fromHome) {
                    if (!alreadySeenRecentsOnboarding && !fromHome) {
                        setHasSeenSwipeUpOnboarding(true);
                        setHasSeenSwipeUpOnboarding(true);
                    }
                    }
                    if (fromHome) {
                    if (fromHome) {
                        setOpenedOverviewFromHomeCount(getOpenedOverviewFromHomeCount() + 1);
                        setOpenedOverviewFromHomeCount(getOpenedOverviewFromHomeCount() + 1);
                    }
                    }
                    setOpenedOverviewCount(getOpenedOverviewCount() + 1);
                    setOpenedOverviewCount(getOpenedOverviewCount() + 1);

                    if (getOpenedOverviewCount() >= QUICK_SCRUB_SHOW_ON_OVERVIEW_OPENED_COUNT) {
                        if (mHasDismissedQuickScrubTip) {
                            mOverviewOpenedCountSinceQuickScrubTipDismiss++;
                        }
                    }
                }
                }


                @Override
                @Override
@@ -191,7 +193,11 @@ public class RecentsOnboarding {
        public void onViewAttachedToWindow(View view) {
        public void onViewAttachedToWindow(View view) {
            if (view == mLayout) {
            if (view == mLayout) {
                mLayoutAttachedToWindow = true;
                mLayoutAttachedToWindow = true;
                if (view.getTag().equals(R.string.recents_swipe_up_onboarding)) {
                    mHasDismissedSwipeUpTip = false;
                    mHasDismissedSwipeUpTip = false;
                } else {
                    mHasDismissedQuickScrubTip = false;
                }
            }
            }
        }
        }


@@ -199,6 +205,17 @@ public class RecentsOnboarding {
        public void onViewDetachedFromWindow(View view) {
        public void onViewDetachedFromWindow(View view) {
            if (view == mLayout) {
            if (view == mLayout) {
                mLayoutAttachedToWindow = false;
                mLayoutAttachedToWindow = false;
                if (view.getTag().equals(R.string.recents_quick_scrub_onboarding)) {
                    mHasDismissedQuickScrubTip = true;
                    if (hasDismissedQuickScrubOnboardingOnce()) {
                        // If user dismisses the quick scrub tip twice, we consider user has seen it
                        // and do not show it again.
                        setHasSeenQuickScrubOnboarding(true);
                    } else {
                        setHasDismissedQuickScrubOnboardingOnce(true);
                    }
                    mOverviewOpenedCountSinceQuickScrubTipDismiss = 0;
                }
            }
            }
        }
        }
    };
    };
@@ -228,15 +245,6 @@ public class RecentsOnboarding {
            if (v.getTag().equals(R.string.recents_swipe_up_onboarding)) {
            if (v.getTag().equals(R.string.recents_swipe_up_onboarding)) {
                mHasDismissedSwipeUpTip = true;
                mHasDismissedSwipeUpTip = true;
                mNumAppsLaunchedSinceSwipeUpTipDismiss = 0;
                mNumAppsLaunchedSinceSwipeUpTipDismiss = 0;
            } else {
                if (mHasDismissedQuickScrubTip) {
                    // If user dismisses the quick scrub tip twice, we consider user has seen it
                    // and do not show it again.
                    setHasSeenQuickScrubOnboarding(true);
                } else {
                    mHasDismissedQuickScrubTip = true;
                }
                mNumAppsLaunchedSinceQuickScrubTipDismiss = 0;
            }
            }
        });
        });


@@ -252,6 +260,7 @@ public class RecentsOnboarding {
        if (RESET_PREFS_FOR_DEBUG) {
        if (RESET_PREFS_FOR_DEBUG) {
            setHasSeenSwipeUpOnboarding(false);
            setHasSeenSwipeUpOnboarding(false);
            setHasSeenQuickScrubOnboarding(false);
            setHasSeenQuickScrubOnboarding(false);
            setHasDismissedQuickScrubOnboardingOnce(false);
            setOpenedOverviewCount(0);
            setOpenedOverviewCount(0);
            setOpenedOverviewFromHomeCount(0);
            setOpenedOverviewFromHomeCount(0);
        }
        }
@@ -289,7 +298,7 @@ public class RecentsOnboarding {
        mHasDismissedSwipeUpTip = false;
        mHasDismissedSwipeUpTip = false;
        mHasDismissedQuickScrubTip = false;
        mHasDismissedQuickScrubTip = false;
        mNumAppsLaunchedSinceSwipeUpTipDismiss = 0;
        mNumAppsLaunchedSinceSwipeUpTipDismiss = 0;
        mNumAppsLaunchedSinceQuickScrubTipDismiss = 0;
        mOverviewOpenedCountSinceQuickScrubTipDismiss = 0;
        hide(false);
        hide(false);
    }
    }


@@ -303,11 +312,15 @@ public class RecentsOnboarding {
        if (!shouldShow()) {
        if (!shouldShow()) {
            return;
            return;
        }
        }
        if (mLayoutAttachedToWindow) {
            hide(false);
        }
        mDismissView.setTag(stringRes);
        mDismissView.setTag(stringRes);
        mLayout.setTag(stringRes);
        mTextView.setText(stringRes);
        mTextView.setText(stringRes);
        // Only show in portrait.
        // Only show in portrait.
        int orientation = mContext.getResources().getConfiguration().orientation;
        int orientation = mContext.getResources().getConfiguration().orientation;
        if (!mLayoutAttachedToWindow && orientation == Configuration.ORIENTATION_PORTRAIT) {
        if (orientation == Configuration.ORIENTATION_PORTRAIT) {
            mLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
            mLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE);


            mWindowManager.addView(mLayout, getWindowLayoutParams());
            mWindowManager.addView(mLayout, getWindowLayoutParams());
@@ -348,11 +361,11 @@ public class RecentsOnboarding {
                        .withLayer()
                        .withLayer()
                        .setDuration(SHOW_HIDE_DURATION_MS)
                        .setDuration(SHOW_HIDE_DURATION_MS)
                        .setInterpolator(new AccelerateInterpolator())
                        .setInterpolator(new AccelerateInterpolator())
                        .withEndAction(() -> mWindowManager.removeView(mLayout))
                        .withEndAction(() -> mWindowManager.removeViewImmediate(mLayout))
                        .start();
                        .start();
            } else {
            } else {
                mLayout.animate().cancel();
                mLayout.animate().cancel();
                mWindowManager.removeView(mLayout);
                mWindowManager.removeViewImmediate(mLayout);
            }
            }
        }
        }
    }
    }
@@ -400,6 +413,16 @@ public class RecentsOnboarding {
        }
        }
    }
    }


    private boolean hasDismissedQuickScrubOnboardingOnce() {
        return Prefs.getBoolean(mContext, HAS_DISMISSED_RECENTS_QUICK_SCRUB_ONBOARDING_ONCE, false);
    }

    private void setHasDismissedQuickScrubOnboardingOnce(
            boolean hasDismissedQuickScrubOnboardingOnce) {
        Prefs.putBoolean(mContext, HAS_DISMISSED_RECENTS_QUICK_SCRUB_ONBOARDING_ONCE,
                hasDismissedQuickScrubOnboardingOnce);
    }

    private int getOpenedOverviewFromHomeCount() {
    private int getOpenedOverviewFromHomeCount() {
        return Prefs.getInt(mContext, OVERVIEW_OPENED_FROM_HOME_COUNT, 0);
        return Prefs.getInt(mContext, OVERVIEW_OPENED_FROM_HOME_COUNT, 0);
    }
    }