Merge "Remove AllApps prediction edu" into sc-dev am: bd883ea788

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/14682074

Change-Id: Ic51e0fecefab7e8494d012ec4b082c2212550edc
This commit is contained in:
Samuel Fufa 2021-05-27 11:31:02 +00:00 committed by Automerger Merge Worker
commit b53a58288a
6 changed files with 33 additions and 103 deletions

View File

@ -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<LauncherState>() {
@Override
public void onStateTransitionComplete(LauncherState finalState) {
if (finalState == ALL_APPS) {
if (showAllAppsTipIfNecessary(launcher)) {
launcher.getStateManager().removeStateListener(this);
}
}
}
});
}
}
}

View File

@ -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) {

View File

@ -16,8 +16,9 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
<item
android:top="6dp"
android:bottom="6dp">
android:top="@dimen/all_apps_tabs_vertical_padding"
android:bottom="@dimen/all_apps_tabs_vertical_padding
">
<shape android:shape="rectangle">
<solid android:color="?androidprv:attr/colorSurface" />
<corners android:radius="@dimen/all_apps_header_pill_corner_radius" />

View File

@ -14,9 +14,7 @@
limitations under the License.
-->
<merge
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
<merge xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="wrap_content">
@ -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" />
<ImageView
android:id="@+id/dismiss"
android:layout_width="40dp"
@ -53,13 +52,13 @@
android:src="@drawable/ic_remove_no_shadow"
android:tint="@color/arrow_tip_view_content"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/accessibility_close"/>
android:contentDescription="@string/accessibility_close" />
</LinearLayout>
<View
android:id="@+id/arrow"
android:elevation="2dp"
android:layout_width="10dp"
android:layout_width="@dimen/arrow_toast_arrow_width"
android:layout_height="8dp"
android:layout_marginTop="-2dp"/>
</merge>

View File

@ -105,6 +105,7 @@
<dimen name="all_apps_tip_bottom_margin">8dp</dimen>
<!-- The size of corner radius of the arrow in the arrow toast. -->
<dimen name="arrow_toast_corner_radius">2dp</dimen>
<dimen name="arrow_toast_arrow_width">10dp</dimen>
<!-- Search bar in All Apps -->
<dimen name="all_apps_header_max_elevation">3dp</dimen>

View File

@ -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()