Merge "Remove RecentsOnboarding" into sc-dev am: 6a8ca02c6f
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15322566 Change-Id: I32a553a44b21534f491a1d7c044060c24696a297
This commit is contained in:
@@ -1006,8 +1006,6 @@
|
|||||||
<!-- Default name for the media device shown in the output switcher when the name is not available [CHAR LIMIT=30] -->
|
<!-- Default name for the media device shown in the output switcher when the name is not available [CHAR LIMIT=30] -->
|
||||||
<string name="media_seamless_remote_device">Device</string>
|
<string name="media_seamless_remote_device">Device</string>
|
||||||
|
|
||||||
<!-- Recents: Text that shows above the navigation bar after launching a few apps. [CHAR LIMIT=NONE] -->
|
|
||||||
<string name="recents_swipe_up_onboarding">Swipe up to switch apps</string>
|
|
||||||
<!-- QuickStep: Accessibility to toggle overview [CHAR LIMIT=40] -->
|
<!-- QuickStep: Accessibility to toggle overview [CHAR LIMIT=40] -->
|
||||||
<string name="quick_step_accessibility_toggle_overview">Toggle Overview</string>
|
<string name="quick_step_accessibility_toggle_overview">Toggle Overview</string>
|
||||||
|
|
||||||
|
|||||||
@@ -21,8 +21,4 @@ public class LauncherEventUtil {
|
|||||||
// Constants for the Action
|
// Constants for the Action
|
||||||
public static final int VISIBLE = 0;
|
public static final int VISIBLE = 0;
|
||||||
public static final int DISMISS = 1;
|
public static final int DISMISS = 1;
|
||||||
|
|
||||||
// Constants for the Target (View)
|
|
||||||
public static final int RECENTS_SWIPE_UP_ONBOARDING_TIP = 0;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,8 +64,6 @@ public final class Prefs {
|
|||||||
Key.QS_NIGHTDISPLAY_ADDED,
|
Key.QS_NIGHTDISPLAY_ADDED,
|
||||||
Key.QS_LONG_PRESS_TOOLTIP_SHOWN_COUNT,
|
Key.QS_LONG_PRESS_TOOLTIP_SHOWN_COUNT,
|
||||||
Key.SEEN_MULTI_USER,
|
Key.SEEN_MULTI_USER,
|
||||||
Key.HAS_SEEN_RECENTS_SWIPE_UP_ONBOARDING,
|
|
||||||
Key.OVERVIEW_OPENED_FROM_HOME_COUNT,
|
|
||||||
Key.SEEN_RINGER_GUIDANCE_COUNT,
|
Key.SEEN_RINGER_GUIDANCE_COUNT,
|
||||||
Key.QS_HAS_TURNED_OFF_MOBILE_DATA,
|
Key.QS_HAS_TURNED_OFF_MOBILE_DATA,
|
||||||
Key.TOUCHED_RINGER_TOGGLE,
|
Key.TOUCHED_RINGER_TOGGLE,
|
||||||
@@ -107,10 +105,6 @@ public final class Prefs {
|
|||||||
*/
|
*/
|
||||||
String QS_LONG_PRESS_TOOLTIP_SHOWN_COUNT = "QsLongPressTooltipShownCount";
|
String QS_LONG_PRESS_TOOLTIP_SHOWN_COUNT = "QsLongPressTooltipShownCount";
|
||||||
String SEEN_MULTI_USER = "HasSeenMultiUser";
|
String SEEN_MULTI_USER = "HasSeenMultiUser";
|
||||||
String OVERVIEW_OPENED_FROM_HOME_COUNT = "OverviewOpenedFromHomeCount";
|
|
||||||
String HAS_SEEN_RECENTS_SWIPE_UP_ONBOARDING = "HasSeenRecentsSwipeUpOnboarding";
|
|
||||||
String DISMISSED_RECENTS_SWIPE_UP_ONBOARDING_COUNT =
|
|
||||||
"DismissedRecentsSwipeUpOnboardingCount";
|
|
||||||
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";
|
||||||
|
|||||||
@@ -1047,10 +1047,6 @@ public class NavigationBar implements View.OnAttachStateChangeListener,
|
|||||||
// Returns true if the bar mode is changed.
|
// Returns true if the bar mode is changed.
|
||||||
private boolean updateBarMode(int barMode) {
|
private boolean updateBarMode(int barMode) {
|
||||||
if (mNavigationBarMode != barMode) {
|
if (mNavigationBarMode != barMode) {
|
||||||
if (mNavigationBarMode == MODE_TRANSPARENT
|
|
||||||
|| mNavigationBarMode == MODE_LIGHTS_OUT_TRANSPARENT) {
|
|
||||||
mNavigationBarView.hideRecentsOnboarding();
|
|
||||||
}
|
|
||||||
mNavigationBarMode = barMode;
|
mNavigationBarMode = barMode;
|
||||||
checkNavBarModes();
|
checkNavBarModes();
|
||||||
if (mAutoHideController != null) {
|
if (mAutoHideController != null) {
|
||||||
|
|||||||
@@ -82,7 +82,6 @@ import com.android.systemui.navigationbar.gestural.FloatingRotationButton;
|
|||||||
import com.android.systemui.navigationbar.gestural.RegionSamplingHelper;
|
import com.android.systemui.navigationbar.gestural.RegionSamplingHelper;
|
||||||
import com.android.systemui.recents.OverviewProxyService;
|
import com.android.systemui.recents.OverviewProxyService;
|
||||||
import com.android.systemui.recents.Recents;
|
import com.android.systemui.recents.Recents;
|
||||||
import com.android.systemui.recents.RecentsOnboarding;
|
|
||||||
import com.android.systemui.shared.system.ActivityManagerWrapper;
|
import com.android.systemui.shared.system.ActivityManagerWrapper;
|
||||||
import com.android.systemui.shared.system.QuickStepContract;
|
import com.android.systemui.shared.system.QuickStepContract;
|
||||||
import com.android.systemui.shared.system.SysUiStatsLog;
|
import com.android.systemui.shared.system.SysUiStatsLog;
|
||||||
@@ -164,7 +163,6 @@ public class NavigationBarView extends FrameLayout implements
|
|||||||
private Configuration mTmpLastConfiguration;
|
private Configuration mTmpLastConfiguration;
|
||||||
|
|
||||||
private NavigationBarInflaterView mNavigationInflaterView;
|
private NavigationBarInflaterView mNavigationInflaterView;
|
||||||
private RecentsOnboarding mRecentsOnboarding;
|
|
||||||
private NotificationPanelViewController mPanelView;
|
private NotificationPanelViewController mPanelView;
|
||||||
private RotationContextButton mRotationContextButton;
|
private RotationContextButton mRotationContextButton;
|
||||||
private FloatingRotationButton mFloatingRotationButton;
|
private FloatingRotationButton mFloatingRotationButton;
|
||||||
@@ -323,7 +321,6 @@ public class NavigationBarView extends FrameLayout implements
|
|||||||
updateRotationButton();
|
updateRotationButton();
|
||||||
|
|
||||||
mOverviewProxyService = Dependency.get(OverviewProxyService.class);
|
mOverviewProxyService = Dependency.get(OverviewProxyService.class);
|
||||||
mRecentsOnboarding = new RecentsOnboarding(context, mOverviewProxyService);
|
|
||||||
|
|
||||||
mConfiguration = new Configuration();
|
mConfiguration = new Configuration();
|
||||||
mTmpLastConfiguration = new Configuration();
|
mTmpLastConfiguration = new Configuration();
|
||||||
@@ -697,7 +694,6 @@ public class NavigationBarView extends FrameLayout implements
|
|||||||
|
|
||||||
updateNavButtonIcons();
|
updateNavButtonIcons();
|
||||||
updateSlippery();
|
updateSlippery();
|
||||||
setUpSwipeUpOnboarding(isQuickStepSwipeUpEnabled());
|
|
||||||
updateDisabledSystemUiStateFlags();
|
updateDisabledSystemUiStateFlags();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -873,7 +869,6 @@ public class NavigationBarView extends FrameLayout implements
|
|||||||
updateSlippery();
|
updateSlippery();
|
||||||
reloadNavIcons();
|
reloadNavIcons();
|
||||||
updateNavButtonIcons();
|
updateNavButtonIcons();
|
||||||
setUpSwipeUpOnboarding(isQuickStepSwipeUpEnabled());
|
|
||||||
WindowManagerWrapper.getInstance().setNavBarVirtualKeyHapticFeedbackEnabled(!showSwipeUpUI);
|
WindowManagerWrapper.getInstance().setNavBarVirtualKeyHapticFeedbackEnabled(!showSwipeUpUI);
|
||||||
getHomeButton().setAccessibilityDelegate(
|
getHomeButton().setAccessibilityDelegate(
|
||||||
showSwipeUpUI ? mQuickStepAccessibilityDelegate : null);
|
showSwipeUpUI ? mQuickStepAccessibilityDelegate : null);
|
||||||
@@ -917,7 +912,6 @@ public class NavigationBarView extends FrameLayout implements
|
|||||||
mNavBarMode = mode;
|
mNavBarMode = mode;
|
||||||
mBarTransitions.onNavigationModeChanged(mNavBarMode);
|
mBarTransitions.onNavigationModeChanged(mNavBarMode);
|
||||||
mEdgeBackGestureHandler.onNavigationModeChanged(mNavBarMode);
|
mEdgeBackGestureHandler.onNavigationModeChanged(mNavBarMode);
|
||||||
mRecentsOnboarding.onNavigationModeChanged(mNavBarMode);
|
|
||||||
updateRotationButton();
|
updateRotationButton();
|
||||||
|
|
||||||
if (isGesturalMode(mNavBarMode)) {
|
if (isGesturalMode(mNavBarMode)) {
|
||||||
@@ -933,10 +927,6 @@ public class NavigationBarView extends FrameLayout implements
|
|||||||
mContextualButtonGroup.setButtonVisibility(R.id.accessibility_button, visible);
|
mContextualButtonGroup.setButtonVisibility(R.id.accessibility_button, visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
void hideRecentsOnboarding() {
|
|
||||||
mRecentsOnboarding.hide(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFinishInflate() {
|
public void onFinishInflate() {
|
||||||
super.onFinishInflate();
|
super.onFinishInflate();
|
||||||
@@ -981,7 +971,6 @@ public class NavigationBarView extends FrameLayout implements
|
|||||||
super.onLayout(changed, left, top, right, bottom);
|
super.onLayout(changed, left, top, right, bottom);
|
||||||
|
|
||||||
notifyActiveTouchRegions();
|
notifyActiveTouchRegions();
|
||||||
mRecentsOnboarding.setNavBarHeight(getMeasuredHeight());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1197,7 +1186,6 @@ public class NavigationBarView extends FrameLayout implements
|
|||||||
updateIcons(mTmpLastConfiguration);
|
updateIcons(mTmpLastConfiguration);
|
||||||
updateRecentsIcon();
|
updateRecentsIcon();
|
||||||
mEdgeBackGestureHandler.onConfigurationChanged(mConfiguration);
|
mEdgeBackGestureHandler.onConfigurationChanged(mConfiguration);
|
||||||
mRecentsOnboarding.onConfigurationChanged(mConfiguration);
|
|
||||||
if (uiCarModeChanged || mTmpLastConfiguration.densityDpi != mConfiguration.densityDpi
|
if (uiCarModeChanged || mTmpLastConfiguration.densityDpi != mConfiguration.densityDpi
|
||||||
|| mTmpLastConfiguration.getLayoutDirection() != mConfiguration.getLayoutDirection()) {
|
|| mTmpLastConfiguration.getLayoutDirection() != mConfiguration.getLayoutDirection()) {
|
||||||
// If car mode or density changes, we need to reset the icons.
|
// If car mode or density changes, we need to reset the icons.
|
||||||
@@ -1261,7 +1249,6 @@ public class NavigationBarView extends FrameLayout implements
|
|||||||
requestApplyInsets();
|
requestApplyInsets();
|
||||||
reorient();
|
reorient();
|
||||||
onNavigationModeChanged(mNavBarMode);
|
onNavigationModeChanged(mNavBarMode);
|
||||||
setUpSwipeUpOnboarding(isQuickStepSwipeUpEnabled());
|
|
||||||
if (mRotationButtonController != null) {
|
if (mRotationButtonController != null) {
|
||||||
mRotationButtonController.registerListeners();
|
mRotationButtonController.registerListeners();
|
||||||
}
|
}
|
||||||
@@ -1277,7 +1264,6 @@ public class NavigationBarView extends FrameLayout implements
|
|||||||
protected void onDetachedFromWindow() {
|
protected void onDetachedFromWindow() {
|
||||||
super.onDetachedFromWindow();
|
super.onDetachedFromWindow();
|
||||||
Dependency.get(NavigationModeController.class).removeListener(this);
|
Dependency.get(NavigationModeController.class).removeListener(this);
|
||||||
setUpSwipeUpOnboarding(false);
|
|
||||||
for (int i = 0; i < mButtonDispatchers.size(); ++i) {
|
for (int i = 0; i < mButtonDispatchers.size(); ++i) {
|
||||||
mButtonDispatchers.valueAt(i).onDestroy();
|
mButtonDispatchers.valueAt(i).onDestroy();
|
||||||
}
|
}
|
||||||
@@ -1294,14 +1280,6 @@ public class NavigationBarView extends FrameLayout implements
|
|||||||
mOnComputeInternalInsetsListener);
|
mOnComputeInternalInsetsListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUpSwipeUpOnboarding(boolean connectedToOverviewProxy) {
|
|
||||||
if (connectedToOverviewProxy) {
|
|
||||||
mRecentsOnboarding.onConnectedToLauncher();
|
|
||||||
} else {
|
|
||||||
mRecentsOnboarding.onDisconnectedFromLauncher();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dump(PrintWriter pw) {
|
public void dump(PrintWriter pw) {
|
||||||
final Rect r = new Rect();
|
final Rect r = new Rect();
|
||||||
final Point size = new Point();
|
final Point size = new Point();
|
||||||
@@ -1345,7 +1323,6 @@ public class NavigationBarView extends FrameLayout implements
|
|||||||
}
|
}
|
||||||
mBarTransitions.dump(pw);
|
mBarTransitions.dump(pw);
|
||||||
mContextualButtonGroup.dump(pw);
|
mContextualButtonGroup.dump(pw);
|
||||||
mRecentsOnboarding.dump(pw);
|
|
||||||
mRegionSamplingHelper.dump(pw);
|
mRegionSamplingHelper.dump(pw);
|
||||||
mEdgeBackGestureHandler.dump(pw);
|
mEdgeBackGestureHandler.dump(pw);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,490 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2018 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.systemui.recents;
|
|
||||||
|
|
||||||
import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
|
|
||||||
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON;
|
|
||||||
|
|
||||||
import static com.android.systemui.Prefs.Key.DISMISSED_RECENTS_SWIPE_UP_ONBOARDING_COUNT;
|
|
||||||
import static com.android.systemui.Prefs.Key.HAS_SEEN_RECENTS_SWIPE_UP_ONBOARDING;
|
|
||||||
import static com.android.systemui.Prefs.Key.OVERVIEW_OPENED_FROM_HOME_COUNT;
|
|
||||||
import static com.android.systemui.shared.system.LauncherEventUtil.DISMISS;
|
|
||||||
import static com.android.systemui.shared.system.LauncherEventUtil.RECENTS_SWIPE_UP_ONBOARDING_TIP;
|
|
||||||
import static com.android.systemui.shared.system.LauncherEventUtil.VISIBLE;
|
|
||||||
|
|
||||||
import android.annotation.StringRes;
|
|
||||||
import android.annotation.TargetApi;
|
|
||||||
import android.app.ActivityManager;
|
|
||||||
import android.content.BroadcastReceiver;
|
|
||||||
import android.content.ComponentName;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.IntentFilter;
|
|
||||||
import android.content.res.Configuration;
|
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.graphics.CornerPathEffect;
|
|
||||||
import android.graphics.Paint;
|
|
||||||
import android.graphics.PixelFormat;
|
|
||||||
import android.graphics.drawable.ShapeDrawable;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.RemoteException;
|
|
||||||
import android.os.SystemProperties;
|
|
||||||
import android.os.UserManager;
|
|
||||||
import android.util.TypedValue;
|
|
||||||
import android.view.Gravity;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.view.animation.AccelerateInterpolator;
|
|
||||||
import android.view.animation.DecelerateInterpolator;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import com.android.systemui.Dependency;
|
|
||||||
import com.android.systemui.Prefs;
|
|
||||||
import com.android.systemui.R;
|
|
||||||
import com.android.systemui.broadcast.BroadcastDispatcher;
|
|
||||||
import com.android.systemui.shared.recents.IOverviewProxy;
|
|
||||||
import com.android.systemui.shared.system.ActivityManagerWrapper;
|
|
||||||
import com.android.systemui.shared.system.QuickStepContract;
|
|
||||||
import com.android.systemui.shared.system.TaskStackChangeListener;
|
|
||||||
import com.android.systemui.shared.system.TaskStackChangeListeners;
|
|
||||||
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Shows onboarding for the new recents interaction in P (codenamed quickstep).
|
|
||||||
*/
|
|
||||||
@TargetApi(Build.VERSION_CODES.P)
|
|
||||||
public class RecentsOnboarding {
|
|
||||||
|
|
||||||
private static final String TAG = "RecentsOnboarding";
|
|
||||||
private static final boolean RESET_PREFS_FOR_DEBUG = false;
|
|
||||||
private static final boolean ONBOARDING_ENABLED = true;
|
|
||||||
private static final long SHOW_DELAY_MS = 500;
|
|
||||||
private static final long SHOW_DURATION_MS = 300;
|
|
||||||
private static final long HIDE_DURATION_MS = 100;
|
|
||||||
// Show swipe-up tips after opening overview from home this number of times.
|
|
||||||
private static final int SWIPE_UP_SHOW_ON_OVERVIEW_OPENED_FROM_HOME_COUNT = 3;
|
|
||||||
// Maximum number of dismissals while still showing swipe-up tips.
|
|
||||||
private static final int MAX_DISMISSAL_ON_SWIPE_UP_SHOW = 2;
|
|
||||||
// Number of dismissals for swipe-up tips when exponential backoff starts.
|
|
||||||
private static final int BACKOFF_DISMISSAL_COUNT_ON_SWIPE_UP_SHOW = 1;
|
|
||||||
// After explicitly dismissing for <= BACKOFF_DISMISSAL_COUNT_ON_SWIPE_UP_SHOW times, show again
|
|
||||||
// after launching this number of apps for swipe-up tips.
|
|
||||||
private static final int SWIPE_UP_SHOW_ON_APP_LAUNCH_AFTER_DISMISS = 5;
|
|
||||||
// After explicitly dismissing for > BACKOFF_DISMISSAL_COUNT_ON_SWIPE_UP_SHOW but
|
|
||||||
// <= MAX_DISMISSAL_ON_SWIPE_UP_SHOW times, show again after launching this number of apps for
|
|
||||||
// swipe-up tips.
|
|
||||||
private static final int SWIPE_UP_SHOW_ON_APP_LAUNCH_AFTER_DISMISS_BACK_OFF = 40;
|
|
||||||
|
|
||||||
private final Context mContext;
|
|
||||||
private final WindowManager mWindowManager;
|
|
||||||
private final OverviewProxyService mOverviewProxyService;
|
|
||||||
private Set<String> mBlacklistedPackages;
|
|
||||||
private final View mLayout;
|
|
||||||
private final TextView mTextView;
|
|
||||||
private final ImageView mDismissView;
|
|
||||||
private final View mArrowView;
|
|
||||||
private final int mOnboardingToastColor;
|
|
||||||
private final int mOnboardingToastArrowRadius;
|
|
||||||
private int mNavBarHeight;
|
|
||||||
private int mNavBarMode = NAV_BAR_MODE_3BUTTON;
|
|
||||||
|
|
||||||
private boolean mOverviewProxyListenerRegistered;
|
|
||||||
private boolean mTaskListenerRegistered;
|
|
||||||
private boolean mLayoutAttachedToWindow;
|
|
||||||
private boolean mHasDismissedSwipeUpTip;
|
|
||||||
private int mNumAppsLaunchedSinceSwipeUpTipDismiss;
|
|
||||||
|
|
||||||
private final TaskStackChangeListener mTaskListener = new TaskStackChangeListener() {
|
|
||||||
private String mLastPackageName;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTaskCreated(int taskId, ComponentName componentName) {
|
|
||||||
onAppLaunch();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTaskMovedToFront(int taskId) {
|
|
||||||
onAppLaunch();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onAppLaunch() {
|
|
||||||
if (!isRecentsOnboardingEnabled()) {
|
|
||||||
onDisconnectedFromLauncher();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ActivityManager.RunningTaskInfo info = ActivityManagerWrapper.getInstance()
|
|
||||||
.getRunningTask();
|
|
||||||
if (info == null || info.baseActivity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (mBlacklistedPackages.contains(info.baseActivity.getPackageName())) {
|
|
||||||
hide(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (info.baseActivity.getPackageName().equals(mLastPackageName)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mLastPackageName = info.baseActivity.getPackageName();
|
|
||||||
int activityType = info.configuration.windowConfiguration.getActivityType();
|
|
||||||
if (activityType == ACTIVITY_TYPE_STANDARD) {
|
|
||||||
boolean alreadySeenSwipeUpOnboarding = hasSeenSwipeUpOnboarding();
|
|
||||||
if (alreadySeenSwipeUpOnboarding) {
|
|
||||||
onDisconnectedFromLauncher();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean shouldLog = false;
|
|
||||||
if (!alreadySeenSwipeUpOnboarding) {
|
|
||||||
if (getOpenedOverviewFromHomeCount()
|
|
||||||
>= SWIPE_UP_SHOW_ON_OVERVIEW_OPENED_FROM_HOME_COUNT) {
|
|
||||||
if (mHasDismissedSwipeUpTip) {
|
|
||||||
int hasDimissedSwipeUpOnboardingCount =
|
|
||||||
getDismissedSwipeUpOnboardingCount();
|
|
||||||
if (hasDimissedSwipeUpOnboardingCount
|
|
||||||
> MAX_DISMISSAL_ON_SWIPE_UP_SHOW) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final int swipeUpShowOnAppLauncherAfterDismiss =
|
|
||||||
hasDimissedSwipeUpOnboardingCount
|
|
||||||
<= BACKOFF_DISMISSAL_COUNT_ON_SWIPE_UP_SHOW
|
|
||||||
? SWIPE_UP_SHOW_ON_APP_LAUNCH_AFTER_DISMISS
|
|
||||||
: SWIPE_UP_SHOW_ON_APP_LAUNCH_AFTER_DISMISS_BACK_OFF;
|
|
||||||
mNumAppsLaunchedSinceSwipeUpTipDismiss++;
|
|
||||||
if (mNumAppsLaunchedSinceSwipeUpTipDismiss
|
|
||||||
>= swipeUpShowOnAppLauncherAfterDismiss) {
|
|
||||||
mNumAppsLaunchedSinceSwipeUpTipDismiss = 0;
|
|
||||||
shouldLog = show(R.string.recents_swipe_up_onboarding);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
shouldLog = show(R.string.recents_swipe_up_onboarding);
|
|
||||||
}
|
|
||||||
if (shouldLog) {
|
|
||||||
notifyOnTip(VISIBLE, RECENTS_SWIPE_UP_ONBOARDING_TIP);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
hide(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private OverviewProxyService.OverviewProxyListener mOverviewProxyListener =
|
|
||||||
new OverviewProxyService.OverviewProxyListener() {
|
|
||||||
@Override
|
|
||||||
public void onOverviewShown(boolean fromHome) {
|
|
||||||
if (!hasSeenSwipeUpOnboarding() && !fromHome) {
|
|
||||||
setHasSeenSwipeUpOnboarding(true);
|
|
||||||
}
|
|
||||||
if (fromHome) {
|
|
||||||
incrementOpenedOverviewFromHomeCount();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onQuickStepStarted() {
|
|
||||||
hide(true);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private final View.OnAttachStateChangeListener mOnAttachStateChangeListener
|
|
||||||
= new View.OnAttachStateChangeListener() {
|
|
||||||
|
|
||||||
private final BroadcastDispatcher mBroadcastDispatcher = Dependency.get(
|
|
||||||
BroadcastDispatcher.class);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onViewAttachedToWindow(View view) {
|
|
||||||
if (view == mLayout) {
|
|
||||||
mBroadcastDispatcher.registerReceiver(mReceiver,
|
|
||||||
new IntentFilter(Intent.ACTION_SCREEN_OFF));
|
|
||||||
mLayoutAttachedToWindow = true;
|
|
||||||
if (view.getTag().equals(R.string.recents_swipe_up_onboarding)) {
|
|
||||||
mHasDismissedSwipeUpTip = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onViewDetachedFromWindow(View view) {
|
|
||||||
if (view == mLayout) {
|
|
||||||
mLayoutAttachedToWindow = false;
|
|
||||||
mBroadcastDispatcher.unregisterReceiver(mReceiver);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public RecentsOnboarding(Context context, OverviewProxyService overviewProxyService) {
|
|
||||||
mContext = context;
|
|
||||||
mOverviewProxyService = overviewProxyService;
|
|
||||||
final Resources res = context.getResources();
|
|
||||||
mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
|
|
||||||
mBlacklistedPackages = new HashSet<>();
|
|
||||||
Collections.addAll(mBlacklistedPackages, res.getStringArray(
|
|
||||||
R.array.recents_onboarding_blacklisted_packages));
|
|
||||||
mLayout = LayoutInflater.from(mContext).inflate(R.layout.recents_onboarding, null);
|
|
||||||
mTextView = mLayout.findViewById(R.id.onboarding_text);
|
|
||||||
mDismissView = mLayout.findViewById(R.id.dismiss);
|
|
||||||
mArrowView = mLayout.findViewById(R.id.arrow);
|
|
||||||
|
|
||||||
TypedValue typedValue = new TypedValue();
|
|
||||||
context.getTheme().resolveAttribute(android.R.attr.colorAccent, typedValue, true);
|
|
||||||
mOnboardingToastColor = res.getColor(typedValue.resourceId);
|
|
||||||
mOnboardingToastArrowRadius = res.getDimensionPixelSize(
|
|
||||||
R.dimen.recents_onboarding_toast_arrow_corner_radius);
|
|
||||||
|
|
||||||
mLayout.addOnAttachStateChangeListener(mOnAttachStateChangeListener);
|
|
||||||
mDismissView.setOnClickListener(v -> {
|
|
||||||
hide(true);
|
|
||||||
if (v.getTag().equals(R.string.recents_swipe_up_onboarding)) {
|
|
||||||
mHasDismissedSwipeUpTip = true;
|
|
||||||
mNumAppsLaunchedSinceSwipeUpTipDismiss = 0;
|
|
||||||
setDismissedSwipeUpOnboardingCount(getDismissedSwipeUpOnboardingCount() + 1);
|
|
||||||
if (getDismissedSwipeUpOnboardingCount() > MAX_DISMISSAL_ON_SWIPE_UP_SHOW) {
|
|
||||||
setHasSeenSwipeUpOnboarding(true);
|
|
||||||
}
|
|
||||||
notifyOnTip(DISMISS, RECENTS_SWIPE_UP_ONBOARDING_TIP);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
ViewGroup.LayoutParams arrowLp = mArrowView.getLayoutParams();
|
|
||||||
ShapeDrawable arrowDrawable = new ShapeDrawable(TriangleShape.create(
|
|
||||||
arrowLp.width, arrowLp.height, false));
|
|
||||||
Paint arrowPaint = arrowDrawable.getPaint();
|
|
||||||
arrowPaint.setColor(mOnboardingToastColor);
|
|
||||||
// The corner path effect won't be reflected in the shadow, but shouldn't be noticeable.
|
|
||||||
arrowPaint.setPathEffect(new CornerPathEffect(mOnboardingToastArrowRadius));
|
|
||||||
mArrowView.setBackground(arrowDrawable);
|
|
||||||
|
|
||||||
if (RESET_PREFS_FOR_DEBUG) {
|
|
||||||
setHasSeenSwipeUpOnboarding(false);
|
|
||||||
setDismissedSwipeUpOnboardingCount(0);
|
|
||||||
setOpenedOverviewFromHomeCount(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void notifyOnTip(int action, int target) {
|
|
||||||
try {
|
|
||||||
IOverviewProxy overviewProxy = mOverviewProxyService.getProxy();
|
|
||||||
if (overviewProxy != null) {
|
|
||||||
overviewProxy.onTip(action, target);
|
|
||||||
}
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onNavigationModeChanged(int mode) {
|
|
||||||
mNavBarMode = mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onConnectedToLauncher() {
|
|
||||||
if (!isRecentsOnboardingEnabled()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasSeenSwipeUpOnboarding()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!mOverviewProxyListenerRegistered) {
|
|
||||||
mOverviewProxyService.addCallback(mOverviewProxyListener);
|
|
||||||
mOverviewProxyListenerRegistered = true;
|
|
||||||
}
|
|
||||||
if (!mTaskListenerRegistered) {
|
|
||||||
TaskStackChangeListeners.getInstance().registerTaskStackListener(mTaskListener);
|
|
||||||
mTaskListenerRegistered = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onDisconnectedFromLauncher() {
|
|
||||||
if (mOverviewProxyListenerRegistered) {
|
|
||||||
mOverviewProxyService.removeCallback(mOverviewProxyListener);
|
|
||||||
mOverviewProxyListenerRegistered = false;
|
|
||||||
}
|
|
||||||
if (mTaskListenerRegistered) {
|
|
||||||
TaskStackChangeListeners.getInstance().unregisterTaskStackListener(mTaskListener);
|
|
||||||
mTaskListenerRegistered = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
mHasDismissedSwipeUpTip = false;
|
|
||||||
mNumAppsLaunchedSinceSwipeUpTipDismiss = 0;
|
|
||||||
hide(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onConfigurationChanged(Configuration newConfiguration) {
|
|
||||||
if (newConfiguration.orientation != Configuration.ORIENTATION_PORTRAIT) {
|
|
||||||
hide(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean show(@StringRes int stringRes) {
|
|
||||||
if (!shouldShow()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
mDismissView.setTag(stringRes);
|
|
||||||
mLayout.setTag(stringRes);
|
|
||||||
mTextView.setText(stringRes);
|
|
||||||
// Only show in portrait.
|
|
||||||
int orientation = mContext.getResources().getConfiguration().orientation;
|
|
||||||
if (!mLayoutAttachedToWindow && orientation == Configuration.ORIENTATION_PORTRAIT) {
|
|
||||||
mLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
|
|
||||||
|
|
||||||
final int gravity;
|
|
||||||
final int x;
|
|
||||||
if (stringRes == R.string.recents_swipe_up_onboarding) {
|
|
||||||
gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
|
|
||||||
x = 0;
|
|
||||||
} else {
|
|
||||||
int layoutDirection =
|
|
||||||
mContext.getResources().getConfiguration().getLayoutDirection();
|
|
||||||
gravity = Gravity.BOTTOM | (layoutDirection == View.LAYOUT_DIRECTION_LTR
|
|
||||||
? Gravity.LEFT : Gravity.RIGHT);
|
|
||||||
x = mContext.getResources().getDimensionPixelSize(
|
|
||||||
R.dimen.recents_quick_scrub_onboarding_margin_start);
|
|
||||||
}
|
|
||||||
mWindowManager.addView(mLayout, getWindowLayoutParams(gravity, x));
|
|
||||||
mLayout.setAlpha(0);
|
|
||||||
mLayout.animate()
|
|
||||||
.alpha(1f)
|
|
||||||
.withLayer()
|
|
||||||
.setStartDelay(SHOW_DELAY_MS)
|
|
||||||
.setDuration(SHOW_DURATION_MS)
|
|
||||||
.setInterpolator(new DecelerateInterpolator())
|
|
||||||
.start();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return True unless setprop has been set to false, we're in demo mode, or running tests in
|
|
||||||
* automation.
|
|
||||||
*/
|
|
||||||
private boolean shouldShow() {
|
|
||||||
return SystemProperties.getBoolean("persist.quickstep.onboarding.enabled",
|
|
||||||
!(mContext.getSystemService(UserManager.class)).isDemoUser() &&
|
|
||||||
!ActivityManager.isRunningInTestHarness());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void hide(boolean animate) {
|
|
||||||
if (mLayoutAttachedToWindow) {
|
|
||||||
if (animate) {
|
|
||||||
mLayout.animate()
|
|
||||||
.alpha(0f)
|
|
||||||
.withLayer()
|
|
||||||
.setStartDelay(0)
|
|
||||||
.setDuration(HIDE_DURATION_MS)
|
|
||||||
.setInterpolator(new AccelerateInterpolator())
|
|
||||||
.withEndAction(() -> mWindowManager.removeViewImmediate(mLayout))
|
|
||||||
.start();
|
|
||||||
} else {
|
|
||||||
mLayout.animate().cancel();
|
|
||||||
mWindowManager.removeViewImmediate(mLayout);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNavBarHeight(int navBarHeight) {
|
|
||||||
mNavBarHeight = navBarHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dump(PrintWriter pw) {
|
|
||||||
pw.println("RecentsOnboarding");
|
|
||||||
pw.println(" mTaskListenerRegistered: " + mTaskListenerRegistered);
|
|
||||||
pw.println(" mOverviewProxyListenerRegistered: " + mOverviewProxyListenerRegistered);
|
|
||||||
pw.println(" mLayoutAttachedToWindow: " + mLayoutAttachedToWindow);
|
|
||||||
pw.println(" mHasDismissedSwipeUpTip: " + mHasDismissedSwipeUpTip);
|
|
||||||
pw.println(" mNumAppsLaunchedSinceSwipeUpTipDismiss: "
|
|
||||||
+ mNumAppsLaunchedSinceSwipeUpTipDismiss);
|
|
||||||
pw.println(" hasSeenSwipeUpOnboarding: " + hasSeenSwipeUpOnboarding());
|
|
||||||
pw.println(" getDismissedSwipeUpOnboardingCount: "
|
|
||||||
+ getDismissedSwipeUpOnboardingCount());
|
|
||||||
pw.println(" getOpenedOverviewFromHomeCount: " + getOpenedOverviewFromHomeCount());
|
|
||||||
}
|
|
||||||
|
|
||||||
private WindowManager.LayoutParams getWindowLayoutParams(int gravity, int x) {
|
|
||||||
int flags = WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
|
|
||||||
| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
|
|
||||||
final WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
|
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
|
||||||
x, -mNavBarHeight / 2,
|
|
||||||
WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY,
|
|
||||||
flags,
|
|
||||||
PixelFormat.TRANSLUCENT);
|
|
||||||
lp.privateFlags |= WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS;
|
|
||||||
lp.setTitle("RecentsOnboarding");
|
|
||||||
lp.gravity = gravity;
|
|
||||||
return lp;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isRecentsOnboardingEnabled() {
|
|
||||||
return ONBOARDING_ENABLED && !QuickStepContract.isGesturalMode(mNavBarMode);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean hasSeenSwipeUpOnboarding() {
|
|
||||||
return Prefs.getBoolean(mContext, HAS_SEEN_RECENTS_SWIPE_UP_ONBOARDING, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setHasSeenSwipeUpOnboarding(boolean hasSeenSwipeUpOnboarding) {
|
|
||||||
Prefs.putBoolean(mContext, HAS_SEEN_RECENTS_SWIPE_UP_ONBOARDING, hasSeenSwipeUpOnboarding);
|
|
||||||
if (hasSeenSwipeUpOnboarding) {
|
|
||||||
onDisconnectedFromLauncher();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getDismissedSwipeUpOnboardingCount() {
|
|
||||||
return Prefs.getInt(mContext, DISMISSED_RECENTS_SWIPE_UP_ONBOARDING_COUNT, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setDismissedSwipeUpOnboardingCount(int dismissedSwipeUpOnboardingCount) {
|
|
||||||
Prefs.putInt(mContext, DISMISSED_RECENTS_SWIPE_UP_ONBOARDING_COUNT,
|
|
||||||
dismissedSwipeUpOnboardingCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getOpenedOverviewFromHomeCount() {
|
|
||||||
return Prefs.getInt(mContext, OVERVIEW_OPENED_FROM_HOME_COUNT, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void incrementOpenedOverviewFromHomeCount() {
|
|
||||||
int openedOverviewFromHomeCount = getOpenedOverviewFromHomeCount();
|
|
||||||
if (openedOverviewFromHomeCount >= SWIPE_UP_SHOW_ON_OVERVIEW_OPENED_FROM_HOME_COUNT) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setOpenedOverviewFromHomeCount(openedOverviewFromHomeCount + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setOpenedOverviewFromHomeCount(int openedOverviewFromHomeCount) {
|
|
||||||
Prefs.putInt(mContext, OVERVIEW_OPENED_FROM_HOME_COUNT, openedOverviewFromHomeCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
|
||||||
@Override
|
|
||||||
public void onReceive(Context context, Intent intent) {
|
|
||||||
if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
|
|
||||||
hide(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user