From 88be649d21e6fbf43297764486d55bcb258547e9 Mon Sep 17 00:00:00 2001 From: kumarashishg Date: Mon, 28 Jun 2021 10:53:48 +0000 Subject: [PATCH] NIU Actions: Add NIU Actions tooltip These tooltips are added to educate the user about NIU buttons actions. We have added tooltips for Translate and Listen NIU actions buttons. Bug: 186006700 Test: Manual Change-Id: Ib076c2a44055b62f2daf06bddf45aca220a28756 --- .../arrow_toast_rounded_background.xml | 19 +++++++ go/quickstep/res/values/colors.xml | 4 ++ go/quickstep/res/values/dimens.xml | 4 ++ .../quickstep/TaskOverlayFactoryGo.java | 44 +++++++++++++++- .../views/GoOverviewActionsView.java | 50 ++++++++++++++++++- .../android/quickstep/TaskOverlayFactory.java | 6 +++ .../quickstep/util/RecentsOrientedState.java | 2 +- .../com/android/quickstep/views/TaskView.java | 1 + 8 files changed, 126 insertions(+), 4 deletions(-) create mode 100644 go/quickstep/res/drawable/arrow_toast_rounded_background.xml diff --git a/go/quickstep/res/drawable/arrow_toast_rounded_background.xml b/go/quickstep/res/drawable/arrow_toast_rounded_background.xml new file mode 100644 index 0000000000..9c815fd19f --- /dev/null +++ b/go/quickstep/res/drawable/arrow_toast_rounded_background.xml @@ -0,0 +1,19 @@ + + + + + diff --git a/go/quickstep/res/values/colors.xml b/go/quickstep/res/values/colors.xml index 8034be217d..4ce7669a78 100644 --- a/go/quickstep/res/values/colors.xml +++ b/go/quickstep/res/values/colors.xml @@ -23,4 +23,8 @@ #FFFFFF #424242 + + + #1A73E8 + #FFFFFF diff --git a/go/quickstep/res/values/dimens.xml b/go/quickstep/res/values/dimens.xml index 0a7ac4563d..c14df508b7 100644 --- a/go/quickstep/res/values/dimens.xml +++ b/go/quickstep/res/values/dimens.xml @@ -36,4 +36,8 @@ 12dp 8dp 216dp + + + 8dp + 3dp diff --git a/go/quickstep/src/com/android/quickstep/TaskOverlayFactoryGo.java b/go/quickstep/src/com/android/quickstep/TaskOverlayFactoryGo.java index 37f535200a..f3c7a026bd 100644 --- a/go/quickstep/src/com/android/quickstep/TaskOverlayFactoryGo.java +++ b/go/quickstep/src/com/android/quickstep/TaskOverlayFactoryGo.java @@ -16,6 +16,8 @@ package com.android.quickstep; +import static android.view.Surface.ROTATION_0; + import static com.android.quickstep.views.OverviewActionsView.DISABLED_NO_THUMBNAIL; import static com.android.quickstep.views.OverviewActionsView.DISABLED_ROTATED; @@ -30,6 +32,7 @@ import android.content.SharedPreferences; import android.graphics.Color; import android.graphics.Matrix; import android.graphics.drawable.ColorDrawable; +import android.os.Handler; import android.os.SystemClock; import android.os.UserManager; import android.provider.Settings; @@ -46,7 +49,8 @@ import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.quickstep.util.AssistContentRequester; -import com.android.quickstep.views.OverviewActionsView; +import com.android.quickstep.util.RecentsOrientedState; +import com.android.quickstep.views.GoOverviewActionsView; import com.android.quickstep.views.TaskThumbnailView; import com.android.systemui.shared.recents.model.Task; import com.android.systemui.shared.recents.model.ThumbnailData; @@ -67,6 +71,9 @@ public final class TaskOverlayFactoryGo extends TaskOverlayFactory { private static final String NIU_ACTIONS_CONFIRMED = "launcher_go.niu_actions_confirmed"; private static final String TAG = "TaskOverlayFactoryGo"; + public static final String LISTEN_TOOL_TIP_SEEN = "launcher.go_listen_tip_seen"; + public static final String TRANSLATE_TOOL_TIP_SEEN = "launcher.go_translate_tip_seen"; + private AssistContentRequester mContentRequester; public TaskOverlayFactoryGo(Context context) { @@ -84,7 +91,7 @@ public final class TaskOverlayFactoryGo extends TaskOverlayFactory { * Overlay on each task handling Overview Action Buttons. * @param The type of View in which the overlay will be placed */ - public static final class TaskOverlayGo extends TaskOverlay { + public static final class TaskOverlayGo extends TaskOverlay { private String mNIUPackageName; private String mTaskPackageName; private String mWebUrl; @@ -99,6 +106,7 @@ public final class TaskOverlayFactoryGo extends TaskOverlayFactory { AssistContentRequester assistContentRequester) { super(taskThumbnailView); mFactoryContentRequester = assistContentRequester; + mSharedPreferences = Utilities.getPrefs(mApplicationContext); } /** @@ -134,6 +142,18 @@ public final class TaskOverlayFactoryGo extends TaskOverlayFactory { int taskId = task.key.id; mFactoryContentRequester.requestAssistContent(taskId, this::onAssistContentReceived); + + RecentsOrientedState orientedState = + mThumbnailView.getTaskView().getRecentsView().getPagedViewOrientedState(); + boolean isInLandscape = orientedState.getDisplayRotation() != ROTATION_0; + + // show tooltips in portrait mode only + // TODO: remove If check once b/183714277 is fixed + if (!isInLandscape) { + new Handler().post(() -> { + showTooltipsIfUnseen(); + }); + } } /** Provide Assist Content to the overlay. */ @@ -149,6 +169,12 @@ public final class TaskOverlayFactoryGo extends TaskOverlayFactory { mWebUrl = null; } + @Override + public void updateOrientationState(RecentsOrientedState state) { + super.updateOrientationState(state); + ((GoOverviewActionsView) getActionsView()).updateOrientationState(state); + } + /** * Creates and sends an Intent corresponding to the button that was clicked */ @@ -275,6 +301,20 @@ public final class TaskOverlayFactoryGo extends TaskOverlayFactory { private void onNiuActionsConfirmationReject(View v) { mConfirmationDialog.cancel(); } + + /** + * Checks and Shows the tooltip if they are not seen by user + * Order of tooltips are translate and then listen + */ + private void showTooltipsIfUnseen() { + if (!mSharedPreferences.getBoolean(TRANSLATE_TOOL_TIP_SEEN, false)) { + ((GoOverviewActionsView) getActionsView()).showTranslateToolTip(); + mSharedPreferences.edit().putBoolean(TRANSLATE_TOOL_TIP_SEEN, true).apply(); + } else if (!mSharedPreferences.getBoolean(LISTEN_TOOL_TIP_SEEN, false)) { + ((GoOverviewActionsView) getActionsView()).showListenToolTip(); + mSharedPreferences.edit().putBoolean(LISTEN_TOOL_TIP_SEEN, true).apply(); + } + } } /** diff --git a/go/quickstep/src/com/android/quickstep/views/GoOverviewActionsView.java b/go/quickstep/src/com/android/quickstep/views/GoOverviewActionsView.java index 9997d16e2d..5b535a2f53 100644 --- a/go/quickstep/src/com/android/quickstep/views/GoOverviewActionsView.java +++ b/go/quickstep/src/com/android/quickstep/views/GoOverviewActionsView.java @@ -21,14 +21,20 @@ import android.util.AttributeSet; import android.view.View; import androidx.annotation.Nullable; +import androidx.annotation.Px; import com.android.launcher3.R; +import com.android.launcher3.views.ArrowTipView; import com.android.quickstep.TaskOverlayFactoryGo.OverlayUICallbacksGo; +import com.android.quickstep.util.RecentsOrientedState; /** * View for showing Go-specific action buttons in Overview */ -public final class GoOverviewActionsView extends OverviewActionsView { +public class GoOverviewActionsView extends OverviewActionsView { + + private ArrowTipView mArrowTipView; + public GoOverviewActionsView(Context context) { this(context, null); } @@ -72,4 +78,46 @@ public final class GoOverviewActionsView extends OverviewActionsView