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
This commit is contained in:
parent
b598e968e2
commit
88be649d21
|
@ -0,0 +1,19 @@
|
||||||
|
<!--
|
||||||
|
Copyright (C) 2021 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.
|
||||||
|
-->
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
|
||||||
|
<solid android:color="@color/arrow_tip_view_bg" />
|
||||||
|
<corners android:radius="@dimen/tooltip_corner_radius" />
|
||||||
|
</shape>
|
|
@ -23,4 +23,8 @@
|
||||||
<!-- Modal Dialogs -->
|
<!-- Modal Dialogs -->
|
||||||
<color name="go_modal_dialog_background">#FFFFFF</color>
|
<color name="go_modal_dialog_background">#FFFFFF</color>
|
||||||
<color name="go_modal_dialog_background_dark">#424242</color>
|
<color name="go_modal_dialog_background_dark">#424242</color>
|
||||||
|
|
||||||
|
<!-- Tooltip Color -->
|
||||||
|
<color name="arrow_tip_view_bg">#1A73E8</color>
|
||||||
|
<color name="arrow_tip_view_content">#FFFFFF</color>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -36,4 +36,8 @@
|
||||||
<dimen name="modal_dialog_vertical_spacer">12dp</dimen>
|
<dimen name="modal_dialog_vertical_spacer">12dp</dimen>
|
||||||
<dimen name="modal_dialog_corner_radius">8dp</dimen>
|
<dimen name="modal_dialog_corner_radius">8dp</dimen>
|
||||||
<dimen name="confirmation_dialog_text_height">216dp</dimen>
|
<dimen name="confirmation_dialog_text_height">216dp</dimen>
|
||||||
|
|
||||||
|
<!-- Tooltip -->
|
||||||
|
<dimen name="tooltip_corner_radius">8dp</dimen>
|
||||||
|
<dimen name="tooltip_top_margin">3dp</dimen>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
package com.android.quickstep;
|
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_NO_THUMBNAIL;
|
||||||
import static com.android.quickstep.views.OverviewActionsView.DISABLED_ROTATED;
|
import static com.android.quickstep.views.OverviewActionsView.DISABLED_ROTATED;
|
||||||
|
|
||||||
|
@ -30,6 +32,7 @@ import android.content.SharedPreferences;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.Matrix;
|
import android.graphics.Matrix;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
|
import android.os.Handler;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
@ -46,7 +49,8 @@ import com.android.launcher3.BaseDraggingActivity;
|
||||||
import com.android.launcher3.R;
|
import com.android.launcher3.R;
|
||||||
import com.android.launcher3.Utilities;
|
import com.android.launcher3.Utilities;
|
||||||
import com.android.quickstep.util.AssistContentRequester;
|
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.quickstep.views.TaskThumbnailView;
|
||||||
import com.android.systemui.shared.recents.model.Task;
|
import com.android.systemui.shared.recents.model.Task;
|
||||||
import com.android.systemui.shared.recents.model.ThumbnailData;
|
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 NIU_ACTIONS_CONFIRMED = "launcher_go.niu_actions_confirmed";
|
||||||
private static final String TAG = "TaskOverlayFactoryGo";
|
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;
|
private AssistContentRequester mContentRequester;
|
||||||
|
|
||||||
public TaskOverlayFactoryGo(Context context) {
|
public TaskOverlayFactoryGo(Context context) {
|
||||||
|
@ -84,7 +91,7 @@ public final class TaskOverlayFactoryGo extends TaskOverlayFactory {
|
||||||
* Overlay on each task handling Overview Action Buttons.
|
* Overlay on each task handling Overview Action Buttons.
|
||||||
* @param <T> The type of View in which the overlay will be placed
|
* @param <T> The type of View in which the overlay will be placed
|
||||||
*/
|
*/
|
||||||
public static final class TaskOverlayGo<T extends OverviewActionsView> extends TaskOverlay {
|
public static final class TaskOverlayGo<T extends GoOverviewActionsView> extends TaskOverlay {
|
||||||
private String mNIUPackageName;
|
private String mNIUPackageName;
|
||||||
private String mTaskPackageName;
|
private String mTaskPackageName;
|
||||||
private String mWebUrl;
|
private String mWebUrl;
|
||||||
|
@ -99,6 +106,7 @@ public final class TaskOverlayFactoryGo extends TaskOverlayFactory {
|
||||||
AssistContentRequester assistContentRequester) {
|
AssistContentRequester assistContentRequester) {
|
||||||
super(taskThumbnailView);
|
super(taskThumbnailView);
|
||||||
mFactoryContentRequester = assistContentRequester;
|
mFactoryContentRequester = assistContentRequester;
|
||||||
|
mSharedPreferences = Utilities.getPrefs(mApplicationContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -134,6 +142,18 @@ public final class TaskOverlayFactoryGo extends TaskOverlayFactory {
|
||||||
|
|
||||||
int taskId = task.key.id;
|
int taskId = task.key.id;
|
||||||
mFactoryContentRequester.requestAssistContent(taskId, this::onAssistContentReceived);
|
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. */
|
/** Provide Assist Content to the overlay. */
|
||||||
|
@ -149,6 +169,12 @@ public final class TaskOverlayFactoryGo extends TaskOverlayFactory {
|
||||||
mWebUrl = null;
|
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
|
* 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) {
|
private void onNiuActionsConfirmationReject(View v) {
|
||||||
mConfirmationDialog.cancel();
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -21,14 +21,20 @@ import android.util.AttributeSet;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.annotation.Px;
|
||||||
|
|
||||||
import com.android.launcher3.R;
|
import com.android.launcher3.R;
|
||||||
|
import com.android.launcher3.views.ArrowTipView;
|
||||||
import com.android.quickstep.TaskOverlayFactoryGo.OverlayUICallbacksGo;
|
import com.android.quickstep.TaskOverlayFactoryGo.OverlayUICallbacksGo;
|
||||||
|
import com.android.quickstep.util.RecentsOrientedState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* View for showing Go-specific action buttons in Overview
|
* View for showing Go-specific action buttons in Overview
|
||||||
*/
|
*/
|
||||||
public final class GoOverviewActionsView extends OverviewActionsView<OverlayUICallbacksGo> {
|
public class GoOverviewActionsView extends OverviewActionsView<OverlayUICallbacksGo> {
|
||||||
|
|
||||||
|
private ArrowTipView mArrowTipView;
|
||||||
|
|
||||||
public GoOverviewActionsView(Context context) {
|
public GoOverviewActionsView(Context context) {
|
||||||
this(context, null);
|
this(context, null);
|
||||||
}
|
}
|
||||||
|
@ -72,4 +78,46 @@ public final class GoOverviewActionsView extends OverviewActionsView<OverlayUICa
|
||||||
mCallbacks.onSearch();
|
mCallbacks.onSearch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows Tooltip for action icons
|
||||||
|
*/
|
||||||
|
private void showToolTip(int viewId, int textResourceId) {
|
||||||
|
int[] location = new int[2];
|
||||||
|
@Px int topMargin = getResources().getDimensionPixelSize(R.dimen.tooltip_top_margin);
|
||||||
|
findViewById(viewId).getLocationOnScreen(location);
|
||||||
|
mArrowTipView = new ArrowTipView(getContext(), /* isPointingUp= */ false)
|
||||||
|
.showAtLocation(getResources().getString(textResourceId),
|
||||||
|
/* arrowXCoord= */ location[0] + findViewById(viewId).getWidth() / 2,
|
||||||
|
/* yCoord= */ location[1] - topMargin);
|
||||||
|
|
||||||
|
mArrowTipView.bringToFront();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows Tooltip for listen action icon
|
||||||
|
*/
|
||||||
|
public void showListenToolTip() {
|
||||||
|
showToolTip(/* viewId= */ R.id.action_listen,
|
||||||
|
/* textResourceId= */ R.string.tooltip_listen);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows Tooltip for translate action icon
|
||||||
|
*/
|
||||||
|
public void showTranslateToolTip() {
|
||||||
|
showToolTip(/* viewId= */ R.id.action_translate,
|
||||||
|
/* textResourceId= */ R.string.tooltip_translate);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when device orientation is changed
|
||||||
|
*/
|
||||||
|
public void updateOrientationState(RecentsOrientedState orientedState) {
|
||||||
|
// dismiss tooltip
|
||||||
|
boolean canLauncherRotate = orientedState.canRecentsActivityRotate();
|
||||||
|
if (mArrowTipView != null && !canLauncherRotate) {
|
||||||
|
mArrowTipView.close(/* animate= */ false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -267,6 +267,12 @@ public class TaskOverlayFactory implements ResourceBasedOverride {
|
||||||
return mThumbnailView.getScaledInsets();
|
return mThumbnailView.getScaledInsets();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the device rotated.
|
||||||
|
*/
|
||||||
|
public void updateOrientationState(RecentsOrientedState state) {
|
||||||
|
}
|
||||||
|
|
||||||
protected void showBlockedByPolicyMessage() {
|
protected void showBlockedByPolicyMessage() {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
mThumbnailView.getContext(),
|
mThumbnailView.getContext(),
|
||||||
|
|
|
@ -65,7 +65,7 @@ import java.util.function.IntConsumer;
|
||||||
* This class has initial default state assuming the device and foreground app have
|
* This class has initial default state assuming the device and foreground app have
|
||||||
* no ({@link Surface#ROTATION_0} rotation.
|
* no ({@link Surface#ROTATION_0} rotation.
|
||||||
*/
|
*/
|
||||||
public final class RecentsOrientedState implements
|
public class RecentsOrientedState implements
|
||||||
SharedPreferences.OnSharedPreferenceChangeListener {
|
SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
|
|
||||||
private static final String TAG = "RecentsOrientedState";
|
private static final String TAG = "RecentsOrientedState";
|
||||||
|
|
|
@ -800,6 +800,7 @@ public class TaskView extends FrameLayout implements Reusable {
|
||||||
mIconView.setRotation(orientationHandler.getDegreesRotated());
|
mIconView.setRotation(orientationHandler.getDegreesRotated());
|
||||||
snapshotParams.topMargin = deviceProfile.overviewTaskThumbnailTopMarginPx;
|
snapshotParams.topMargin = deviceProfile.overviewTaskThumbnailTopMarginPx;
|
||||||
mSnapshotView.setLayoutParams(snapshotParams);
|
mSnapshotView.setLayoutParams(snapshotParams);
|
||||||
|
getThumbnail().getTaskOverlay().updateOrientationState(orientationState);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setIconAndDimTransitionProgress(float progress, boolean invert) {
|
private void setIconAndDimTransitionProgress(float progress, boolean invert) {
|
||||||
|
|
Loading…
Reference in New Issue