diff --git a/quickstep/src/com/android/launcher3/appprediction/AllAppsTipView.java b/quickstep/src/com/android/launcher3/appprediction/AllAppsTipView.java deleted file mode 100644 index 98bf483a3d..0000000000 --- a/quickstep/src/com/android/launcher3/appprediction/AllAppsTipView.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * Copyright (C) 2019 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.launcher3.appprediction; - -import static com.android.launcher3.AbstractFloatingView.TYPE_DISCOVERY_BOUNCE; -import static com.android.launcher3.AbstractFloatingView.TYPE_ON_BOARD_POPUP; -import static com.android.launcher3.LauncherState.ALL_APPS; - -import android.os.UserManager; - -import com.android.launcher3.AbstractFloatingView; -import com.android.launcher3.Launcher; -import com.android.launcher3.LauncherState; -import com.android.launcher3.R; -import com.android.launcher3.Utilities; -import com.android.launcher3.allapps.FloatingHeaderView; -import com.android.launcher3.statemanager.StateManager.StateListener; -import com.android.launcher3.views.ArrowTipView; - -/** - * ArrowTip helper aligned just above prediction apps, shown to users that enter all apps for the - * first time. - */ -public class AllAppsTipView { - - private static final String ALL_APPS_TIP_SEEN = "launcher.all_apps_tip_seen"; - - private static boolean showAllAppsTipIfNecessary(Launcher launcher) { - FloatingHeaderView floatingHeaderView = launcher.getAppsView().getFloatingHeaderView(); - if (!floatingHeaderView.hasVisibleContent() - || AbstractFloatingView.getOpenView(launcher, - TYPE_ON_BOARD_POPUP | TYPE_DISCOVERY_BOUNCE) != null - || !launcher.isInState(ALL_APPS) - || hasSeenAllAppsTip(launcher) - || launcher.getSystemService(UserManager.class).isDemoUser() - || Utilities.IS_RUNNING_IN_TEST_HARNESS) { - return false; - } - - int[] coords = new int[2]; - floatingHeaderView.findFixedRowByType(PredictionRowView.class).getLocationOnScreen(coords); - ArrowTipView arrowTipView = new ArrowTipView(launcher).setOnClosedCallback(() -> { - launcher.getSharedPrefs().edit().putBoolean(ALL_APPS_TIP_SEEN, true).apply(); - // TODO: add log to WW - }); - arrowTipView.show(launcher.getString(R.string.all_apps_prediction_tip), coords[1]); - - return true; - } - - private static boolean hasSeenAllAppsTip(Launcher launcher) { - return launcher.getSharedPrefs().getBoolean(ALL_APPS_TIP_SEEN, false); - } - - public static void scheduleShowIfNeeded(Launcher launcher) { - if (!hasSeenAllAppsTip(launcher)) { - launcher.getStateManager().addStateListener(new StateListener() { - @Override - public void onStateTransitionComplete(LauncherState finalState) { - if (finalState == ALL_APPS) { - if (showAllAppsTipIfNecessary(launcher)) { - launcher.getStateManager().removeStateListener(this); - } - } - } - }); - } - } -} diff --git a/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java b/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java index 6d5975f5fa..de040821b4 100644 --- a/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java +++ b/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java @@ -88,7 +88,6 @@ public class PredictionRowView extends LinearLayout implements @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); - AllAppsTipView.scheduleShowIfNeeded(mLauncher); } public void setup(FloatingHeaderView parent, FloatingHeaderRow[] rows, boolean tabsHidden) { diff --git a/res/drawable/all_apps_tabs_background.xml b/res/drawable/all_apps_tabs_background.xml index f88252217e..a345dd3afc 100644 --- a/res/drawable/all_apps_tabs_background.xml +++ b/res/drawable/all_apps_tabs_background.xml @@ -16,8 +16,9 @@ + android:top="@dimen/all_apps_tabs_vertical_padding" + android:bottom="@dimen/all_apps_tabs_vertical_padding +"> diff --git a/res/layout/arrow_toast.xml b/res/layout/arrow_toast.xml index ae60e1bf06..c071becb84 100644 --- a/res/layout/arrow_toast.xml +++ b/res/layout/arrow_toast.xml @@ -14,9 +14,7 @@ limitations under the License. --> - @@ -40,7 +38,8 @@ android:gravity="center" android:layout_gravity="center_vertical" android:textColor="@color/arrow_tip_view_content" - android:textSize="16sp"/> + android:textSize="16sp" /> + + android:contentDescription="@string/accessibility_close" /> diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 394aecb140..c5f36ce2ea 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -105,6 +105,7 @@ 8dp 2dp + 10dp 3dp diff --git a/src/com/android/launcher3/views/ArrowTipView.java b/src/com/android/launcher3/views/ArrowTipView.java index 4ee365ede0..ef3df5fa37 100644 --- a/src/com/android/launcher3/views/ArrowTipView.java +++ b/src/com/android/launcher3/views/ArrowTipView.java @@ -53,11 +53,19 @@ public class ArrowTipView extends AbstractFloatingView { protected final BaseDraggingActivity mActivity; private final Handler mHandler = new Handler(); + private final boolean mIsPointingUp; + private final int mArrowWidth; private Runnable mOnClosed; public ArrowTipView(Context context) { + this(context, false); + } + + public ArrowTipView(Context context, boolean isPointingUp) { super(context, null, 0); mActivity = BaseDraggingActivity.fromContext(context); + mIsPointingUp = isPointingUp; + mArrowWidth = context.getResources().getDimensionPixelSize(R.dimen.arrow_toast_arrow_width); init(context); } @@ -105,13 +113,17 @@ public class ArrowTipView extends AbstractFloatingView { View arrowView = findViewById(R.id.arrow); ViewGroup.LayoutParams arrowLp = arrowView.getLayoutParams(); ShapeDrawable arrowDrawable = new ShapeDrawable(TriangleShape.create( - arrowLp.width, arrowLp.height, false)); + arrowLp.width, arrowLp.height, mIsPointingUp)); Paint arrowPaint = arrowDrawable.getPaint(); - arrowPaint.setColor(ContextCompat.getColor(getContext(), R.color.arrow_tip_view_bg)); + arrowPaint.setColor(ContextCompat.getColor(getContext(), R.color.arrow_tip_view_bg)); // The corner path effect won't be reflected in the shadow, but shouldn't be noticeable. arrowPaint.setPathEffect(new CornerPathEffect( context.getResources().getDimension(R.dimen.arrow_toast_corner_radius))); arrowView.setBackground(arrowDrawable); + if (mIsPointingUp) { + removeView(arrowView); + addView(arrowView, 0); + } mIsOpen = true; @@ -128,10 +140,10 @@ public class ArrowTipView extends AbstractFloatingView { /** * Show the ArrowTipView (tooltip) center, start, or end aligned. * - * @param text The text to be shown in the tooltip. - * @param gravity The gravity aligns the tooltip center, start, or end. + * @param text The text to be shown in the tooltip. + * @param gravity The gravity aligns the tooltip center, start, or end. * @param arrowMarginStart The margin from start to place arrow (ignored if center) - * @param top The Y coordinate of the bottom of tooltip. + * @param top The Y coordinate of the bottom of tooltip. * @return The tooltip. */ public ArrowTipView show(String text, int gravity, int arrowMarginStart, int top) { @@ -149,15 +161,15 @@ public class ArrowTipView extends AbstractFloatingView { arrowMarginStart = parent.getMeasuredWidth() - arrowMarginStart; } if (gravity == Gravity.END) { - lp.setMarginEnd(parent.getMeasuredWidth() - arrowMarginStart); + lp.setMarginEnd(parent.getMeasuredWidth() - arrowMarginStart - mArrowWidth); } else if (gravity == Gravity.START) { - lp.setMarginStart(arrowMarginStart); + lp.setMarginStart(arrowMarginStart - mArrowWidth / 2); } requestLayout(); params.leftMargin = mActivity.getDeviceProfile().workspacePadding.left; params.rightMargin = mActivity.getDeviceProfile().workspacePadding.right; - post(() -> setY(top - getHeight())); + post(() -> setY(top - (mIsPointingUp ? 0 : getHeight()))); setAlpha(0); animate() .alpha(1f) @@ -172,13 +184,14 @@ public class ArrowTipView extends AbstractFloatingView { /** * Show the ArrowTipView (tooltip) custom aligned. * - * @param text The text to be shown in the tooltip. + * @param text The text to be shown in the tooltip. * @param arrowXCoord The X coordinate for the arrow on the tip. The arrow is usually in the * center of ArrowTipView unless the ArrowTipView goes beyond screen margin. - * @param yCoord The Y coordinate of the bottom of the tooltip. + * @param yCoord The Y coordinate of the bottom of the tooltip. * @return The tool tip view. */ - @Nullable public ArrowTipView showAtLocation(String text, int arrowXCoord, int yCoord) { + @Nullable + public ArrowTipView showAtLocation(String text, int arrowXCoord, int yCoord) { ViewGroup parent = mActivity.getDragLayer(); @Px int parentViewWidth = parent.getWidth(); @Px int textViewWidth = getContext().getResources()