diff --git a/go/quickstep/res/drawable/round_rect_dialog.xml b/go/quickstep/res/drawable/round_rect_dialog.xml
new file mode 100644
index 0000000000..bbb7c5b545
--- /dev/null
+++ b/go/quickstep/res/drawable/round_rect_dialog.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
diff --git a/go/quickstep/res/layout/niu_actions_confirmation_dialog.xml b/go/quickstep/res/layout/niu_actions_confirmation_dialog.xml
new file mode 100644
index 0000000000..db1531ac58
--- /dev/null
+++ b/go/quickstep/res/layout/niu_actions_confirmation_dialog.xml
@@ -0,0 +1,94 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/go/quickstep/res/values-land/dimens.xml b/go/quickstep/res/values-land/dimens.xml
new file mode 100644
index 0000000000..50970162cd
--- /dev/null
+++ b/go/quickstep/res/values-land/dimens.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+ 360dp
+ 168dp
+
diff --git a/go/quickstep/res/values/attrs.xml b/go/quickstep/res/values/attrs.xml
index 03eab50d32..cdbdc2afe7 100644
--- a/go/quickstep/res/values/attrs.xml
+++ b/go/quickstep/res/values/attrs.xml
@@ -19,4 +19,6 @@
+
+
\ No newline at end of file
diff --git a/go/quickstep/res/values/colors.xml b/go/quickstep/res/values/colors.xml
index ae72ef63dc..8034be217d 100644
--- a/go/quickstep/res/values/colors.xml
+++ b/go/quickstep/res/values/colors.xml
@@ -20,4 +20,7 @@
#F8F9FA
#70FFFFFF
#474747
+
+ #FFFFFF
+ #424242
diff --git a/go/quickstep/res/values/dimens.xml b/go/quickstep/res/values/dimens.xml
index 55cd138f12..0a7ac4563d 100644
--- a/go/quickstep/res/values/dimens.xml
+++ b/go/quickstep/res/values/dimens.xml
@@ -28,4 +28,12 @@
0dp
24dp
28dp
+
+
+ 288dp
+ 24dp
+ 8dp
+ 12dp
+ 8dp
+ 216dp
diff --git a/go/quickstep/res/values/strings.xml b/go/quickstep/res/values/strings.xml
index 61c8cd9343..6e9e63e3c2 100644
--- a/go/quickstep/res/values/strings.xml
+++ b/go/quickstep/res/values/strings.xml
@@ -11,4 +11,13 @@
Translate
Lens
+
+
+ Translate or listen to text on screen
+
+ 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 Settings > Apps > Default apps > Digital assistant app.
+
+ CANCEL
+
+ GOT IT
diff --git a/go/quickstep/res/values/styles.xml b/go/quickstep/res/values/styles.xml
index ffe8f4607d..561531b623 100644
--- a/go/quickstep/res/values/styles.xml
+++ b/go/quickstep/res/values/styles.xml
@@ -20,12 +20,14 @@
- @color/go_overview_text_color
- @color/go_overview_text_color
- @color/go_overview_button_color
+ - @color/go_modal_dialog_background
@@ -56,4 +58,33 @@
- wrap_content
- vertical
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/go/quickstep/src/com/android/quickstep/TaskOverlayFactoryGo.java b/go/quickstep/src/com/android/quickstep/TaskOverlayFactoryGo.java
index b823c36501..37f535200a 100644
--- a/go/quickstep/src/com/android/quickstep/TaskOverlayFactoryGo.java
+++ b/go/quickstep/src/com/android/quickstep/TaskOverlayFactoryGo.java
@@ -20,20 +20,31 @@ import static com.android.quickstep.views.OverviewActionsView.DISABLED_NO_THUMBN
import static com.android.quickstep.views.OverviewActionsView.DISABLED_ROTATED;
import android.annotation.SuppressLint;
+import android.app.AlertDialog;
import android.app.assist.AssistContent;
import android.content.ActivityNotFoundException;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
+import android.content.SharedPreferences;
+import android.graphics.Color;
import android.graphics.Matrix;
+import android.graphics.drawable.ColorDrawable;
import android.os.SystemClock;
import android.os.UserManager;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.Button;
import androidx.annotation.VisibleForTesting;
+import com.android.launcher3.BaseActivity;
+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.views.TaskThumbnailView;
@@ -53,6 +64,7 @@ public final class TaskOverlayFactoryGo extends TaskOverlayFactory {
public static final String ACTIONS_ERROR_CODE = "niu_actions_app_error_code";
public static final int ERROR_PERMISSIONS_STRUCTURE = 1;
public static final int ERROR_PERMISSIONS_SCREENSHOT = 2;
+ private static final String NIU_ACTIONS_CONFIRMED = "launcher_go.niu_actions_confirmed";
private static final String TAG = "TaskOverlayFactoryGo";
private AssistContentRequester mContentRequester;
@@ -79,6 +91,9 @@ public final class TaskOverlayFactoryGo extends TaskOverlayFactory {
private boolean mAssistStructurePermitted;
private boolean mAssistScreenshotPermitted;
private AssistContentRequester mFactoryContentRequester;
+ private SharedPreferences mSharedPreferences;
+ private String mPreviousAction;
+ private AlertDialog mConfirmationDialog;
private TaskOverlayGo(TaskThumbnailView taskThumbnailView,
AssistContentRequester assistContentRequester) {
@@ -92,6 +107,12 @@ public final class TaskOverlayFactoryGo extends TaskOverlayFactory {
@Override
public void initOverlay(Task task, ThumbnailData thumbnail, Matrix matrix,
boolean rotated) {
+ if (mConfirmationDialog != null && mConfirmationDialog.isShowing()) {
+ // Redraw the dialog in case the layout changed
+ mConfirmationDialog.dismiss();
+ showConfirmationDialog();
+ }
+
getActionsView().updateDisabledFlags(DISABLED_NO_THUMBNAIL, thumbnail == null);
checkSettings();
if (thumbnail == null || TextUtils.isEmpty(mNIUPackageName)) {
@@ -105,6 +126,7 @@ public final class TaskOverlayFactoryGo extends TaskOverlayFactory {
boolean isAllowedByPolicy = mThumbnailView.isRealSnapshot() && !isManagedProfileTask;
getActionsView().setCallbacks(new OverlayUICallbacksGoImpl(isAllowedByPolicy, task));
mTaskPackageName = task.key.getPackageName();
+ mSharedPreferences = Utilities.getPrefs(mApplicationContext);
if (!mAssistStructurePermitted || !mAssistScreenshotPermitted) {
return;
@@ -131,6 +153,12 @@ public final class TaskOverlayFactoryGo extends TaskOverlayFactory {
* Creates and sends an Intent corresponding to the button that was clicked
*/
private void sendNIUIntent(String actionType) {
+ if (!mSharedPreferences.getBoolean(NIU_ACTIONS_CONFIRMED, false)) {
+ mPreviousAction = actionType;
+ showConfirmationDialog();
+ return;
+ }
+
Intent intent = createNIUIntent(actionType);
// Only add and send the image if the appropriate permissions are held
if (mAssistStructurePermitted && mAssistScreenshotPermitted) {
@@ -218,6 +246,35 @@ public final class TaskOverlayFactoryGo extends TaskOverlayFactory {
public void setImageActionsAPI(ImageActionsApi imageActionsApi) {
mImageApi = imageActionsApi;
}
+
+ private void showConfirmationDialog() {
+ BaseDraggingActivity activity = BaseActivity.fromContext(getActionsView().getContext());
+ LayoutInflater inflater = LayoutInflater.from(activity);
+ View view = inflater.inflate(R.layout.niu_actions_confirmation_dialog, /* root */ null);
+
+ Button acceptButton = view.findViewById(R.id.niu_actions_confirmation_accept);
+ acceptButton.setOnClickListener(this::onNiuActionsConfirmationAccept);
+
+ Button rejectButton = view.findViewById(R.id.niu_actions_confirmation_reject);
+ rejectButton.setOnClickListener(this::onNiuActionsConfirmationReject);
+
+ mConfirmationDialog = new AlertDialog.Builder(activity)
+ .setView(view)
+ .create();
+ mConfirmationDialog.getWindow()
+ .setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
+ mConfirmationDialog.show();
+ }
+
+ private void onNiuActionsConfirmationAccept(View v) {
+ mConfirmationDialog.dismiss();
+ mSharedPreferences.edit().putBoolean(NIU_ACTIONS_CONFIRMED, true).apply();
+ sendNIUIntent(mPreviousAction);
+ }
+
+ private void onNiuActionsConfirmationReject(View v) {
+ mConfirmationDialog.cancel();
+ }
}
/**