Snap for 7531772 from 79cb4c6c4f to tm-release

Change-Id: Ie905b6ee191a0671936ce95a41a45a1d76a08603
This commit is contained in:
Android Build Coastguard Worker
2021-07-09 03:08:13 +00:00
12 changed files with 185 additions and 10 deletions
@@ -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>
@@ -76,12 +76,12 @@
<Button
style="@style/ModalDialogButton"
android:id="@+id/niu_actions_confirmation_reject"
android:text="@string/niu_actions_confirmation_no"/>
android:text="@string/dialog_cancel"/>
<Button
style="@style/ModalDialogButton"
android:id="@+id/niu_actions_confirmation_accept"
android:text="@string/niu_actions_confirmation_yes"/>
android:text="@string/dialog_acknowledge"/>
</LinearLayout>
</LinearLayout>
+4
View File
@@ -23,4 +23,8 @@
<!-- Modal Dialogs -->
<color name="go_modal_dialog_background">#FFFFFF</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>
+4
View File
@@ -36,4 +36,8 @@
<dimen name="modal_dialog_vertical_spacer">12dp</dimen>
<dimen name="modal_dialog_corner_radius">8dp</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>
+25 -4
View File
@@ -11,13 +11,34 @@
<string name="action_translate">Translate</string>
<!-- Label for a button that triggers Search on a screenshot of the current app. [CHAR_LIMIT=40] -->
<string name="action_search">Lens</string>
<!-- ******* Dialogs ******* -->
<!-- Label for a button that acknowledges the contents of the dialog. [CHAR_LIMIT=40] -->
<string name="dialog_acknowledge">GOT IT</string>
<!-- Label for a button that cancels the dialog. [CHAR_LIMIT=40] -->
<string name="dialog_cancel">CANCEL</string>
<!-- Label for a button that redirects the user to Settings. [CHAR_LIMIT=40] -->
<string name="dialog_settings">SETTINGS</string>
<!-- ******* NIU Actions First-Run Confirmation Dialog ******* -->
<!-- Dialog title -->
<string name="niu_actions_confirmation_title">Translate or listen to text on screen</string>
<!-- Dialog content -->
<string name="niu_actions_confirmation_text">Information such as text on your screen, web addresses, and screenshots may be shared with Google.\n\nTo change what information you share, go to <b>Settings > Apps > Default apps > Digital assistant app</b>.</string>
<!-- Label for a button that rejects the feature. [CHAR_LIMIT=40] -->
<string name="niu_actions_confirmation_no">CANCEL</string>
<!-- Label for a button that accepts the feature. [CHAR_LIMIT=40] -->
<string name="niu_actions_confirmation_yes">GOT IT</string>
<!-- ******* NIU Actions Default Assistant Error Dialogs ******* -->
<!-- Assistant not selected: Dialog title -->
<string name="assistant_not_selected_title">Choose an assistant to use this feature</string>
<!-- Assistant not selected: Dialog content -->
<string name="assistant_not_selected_text">To listen to or translate text on your screen, choose a digital assistant app in Settings</string>
<!-- Assistant not supported: Dialog title -->
<string name="assistant_not_supported_title">Change your assistant to use this feature</string>
<!-- Assistant not supported: Dialog content -->
<string name="assistant_not_supported_text">To listen to or translate text on your screen, change your digital assistant app in Settings</string>
<!-- ******* NIU Actions Tooltip ******* -->
<!-- Tooltip to highlight and explain the Listen button -->
<string name="tooltip_listen">Tap here to listen to text on this screen</string>
<!-- Tooltip to highlight and explain the Translate button -->
<string name="tooltip_translate">Tap here to translate text on this screen</string>
</resources>
@@ -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 <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 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();
}
}
}
/**
@@ -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<OverlayUICallbacksGo> {
public class GoOverviewActionsView extends OverviewActionsView<OverlayUICallbacksGo> {
private ArrowTipView mArrowTipView;
public GoOverviewActionsView(Context context) {
this(context, null);
}
@@ -72,4 +78,46 @@ public final class GoOverviewActionsView extends OverviewActionsView<OverlayUICa
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);
}
}
}
@@ -266,6 +266,12 @@ public class TaskOverlayFactory implements ResourceBasedOverride {
return mThumbnailView.getScaledInsets();
}
/**
* Called when the device rotated.
*/
public void updateOrientationState(RecentsOrientedState state) {
}
protected void showBlockedByPolicyMessage() {
Toast.makeText(
mThumbnailView.getContext(),
@@ -65,7 +65,7 @@ import java.util.function.IntConsumer;
* This class has initial default state assuming the device and foreground app have
* no ({@link Surface#ROTATION_0} rotation.
*/
public final class RecentsOrientedState implements
public class RecentsOrientedState implements
SharedPreferences.OnSharedPreferenceChangeListener {
private static final String TAG = "RecentsOrientedState";
@@ -794,6 +794,7 @@ public class TaskView extends FrameLayout implements Reusable {
mIconView.setRotation(orientationHandler.getDegreesRotated());
snapshotParams.topMargin = deviceProfile.overviewTaskThumbnailTopMarginPx;
mSnapshotView.setLayoutParams(snapshotParams);
getThumbnail().getTaskOverlay().updateOrientationState(orientationState);
}
private void setIconAndDimTransitionProgress(float progress, boolean invert) {
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ 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.
-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
<item android:bottom="8dp" android:top="8dp">
<shape android:shape="rectangle">
<corners android:radius="@dimen/rounded_button_radius" />
<stroke android:width="1dp" android:color="?androidprv:attr/colorAccentPrimaryVariant" />
<padding
android:left="@dimen/rounded_button_padding"
android:right="@dimen/rounded_button_padding" />
</shape>
</item>
</layer-list>
+2
View File
@@ -128,6 +128,8 @@
<dimen name="work_profile_footer_text_size">16sp</dimen>
<dimen name="work_edu_card_margin">16dp</dimen>
<!-- rounded button shown inside card views, and snack bars -->
<dimen name="padded_rounded_button_height">48dp</dimen>
<dimen name="rounded_button_height">32dp</dimen>
<dimen name="rounded_button_radius">16dp</dimen>
<dimen name="rounded_button_padding">8dp</dimen>