SystemUI: screenshot: Add delete action chip intent
[ghostrider-reborn] updated to android 12, 13
Co-authored-by: Adithya R <gh0strider.2k18.reborn@gmail.com>
Change-Id: Ia55ac91c2db2f44062674a699f8df63c96e1de5c
diff --git a/packages/SystemUI/res/layout/screenshot_static.xml b/packages/SystemUI/res/layout/screenshot_static.xml
index 3b728a9..a654b79 100644
--- a/packages/SystemUI/res/layout/screenshot_static.xml
+++ b/packages/SystemUI/res/layout/screenshot_static.xml
@@ -57,6 +57,8 @@
<include layout="@layout/overlay_action_chip"
android:id="@+id/screenshot_edit_chip"/>
<include layout="@layout/overlay_action_chip"
+ android:id="@+id/screenshot_delete_chip"/>
+ <include layout="@layout/overlay_action_chip"
android:id="@+id/screenshot_scroll_chip"
android:visibility="gone" />
</LinearLayout>
diff --git a/packages/SystemUI/res/values/leaf_strings.xml b/packages/SystemUI/res/values/leaf_strings.xml
index c55bcda..52af5fb 100644
--- a/packages/SystemUI/res/values/leaf_strings.xml
+++ b/packages/SystemUI/res/values/leaf_strings.xml
@@ -38,4 +38,9 @@
<string name="usage_data">used today</string>
<string name="usage_data_default_suffix">Data</string>
<string name="usage_wifi_default_suffix">Wi-Fi</string>
+
+ <!-- Label for UI element which allows deleting the screenshot [CHAR LIMIT=30] -->
+ <string name="screenshot_delete_label">Delete</string>
+ <!-- Content description indicating that tapping the element will allow deleting the screenshot [CHAR LIMIT=NONE] -->
+ <string name="screenshot_delete_description">Delete screenshot</string>
</resources>
diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotEvent.java b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotEvent.java
index 7a62bae..ce1acd6 100644
--- a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotEvent.java
+++ b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotEvent.java
@@ -54,6 +54,8 @@
SCREENSHOT_EDIT_TAPPED(308),
@UiEvent(doc = "screenshot share button tapped")
SCREENSHOT_SHARE_TAPPED(309),
+ @UiEvent(doc = "screenshot delete button tapped")
+ SCREENSHOT_DELETE_TAPPED(369),
@UiEvent(doc = "screenshot smart action chip tapped")
SCREENSHOT_SMART_ACTION_TAPPED(374),
@UiEvent(doc = "screenshot scroll tapped")
diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotView.java b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotView.java
index 31c9284..5dde3c1 100644
--- a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotView.java
+++ b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotView.java
@@ -150,6 +150,7 @@
private OverlayActionChip mEditChip;
private OverlayActionChip mScrollChip;
private OverlayActionChip mQuickShareChip;
+ private OverlayActionChip mDeleteChip;
private UiEventLogger mUiEventLogger;
private ScreenshotViewCallback mCallbacks;
@@ -173,6 +174,7 @@
private enum PendingInteraction {
PREVIEW,
EDIT,
+ DELETE,
SHARE,
QUICK_SHARE
}
@@ -380,6 +382,7 @@
mShareChip = requireNonNull(mActionsContainer.findViewById(R.id.screenshot_share_chip));
mEditChip = requireNonNull(mActionsContainer.findViewById(R.id.screenshot_edit_chip));
mScrollChip = requireNonNull(mActionsContainer.findViewById(R.id.screenshot_scroll_chip));
+ mDeleteChip = requireNonNull(mActionsContainer.findViewById(R.id.screenshot_delete_chip));
setFocusable(true);
mActionsContainer.setScrollX(0);
@@ -691,6 +694,7 @@
if (mQuickShareChip != null) {
mQuickShareChip.setIsPending(false);
}
+ mDeleteChip.setIsPending(false);
mPendingInteraction = PendingInteraction.SHARE;
});
chips.add(mShareChip);
@@ -705,16 +709,31 @@
if (mQuickShareChip != null) {
mQuickShareChip.setIsPending(false);
}
+ mDeleteChip.setIsPending(false);
mPendingInteraction = PendingInteraction.EDIT;
});
chips.add(mEditChip);
+ mDeleteChip.setContentDescription(mContext.getString(R.string.screenshot_delete_label));
+ mDeleteChip.setIcon(Icon.createWithResource(mContext, R.drawable.ic_screenshot_delete), true);
+ mDeleteChip.setOnClickListener(v -> {
+ mDeleteChip.setIsPending(true);
+ mEditChip.setIsPending(false);
+ mShareChip.setIsPending(false);
+ if (mQuickShareChip != null) {
+ mQuickShareChip.setIsPending(false);
+ }
+ mPendingInteraction = PendingInteraction.DELETE;
+ });
+ chips.add(mDeleteChip);
+
mScreenshotPreview.setOnClickListener(v -> {
mShareChip.setIsPending(false);
mEditChip.setIsPending(false);
if (mQuickShareChip != null) {
mQuickShareChip.setIsPending(false);
}
+ mDeleteChip.setIsPending(false);
mPendingInteraction = PendingInteraction.PREVIEW;
});
@@ -812,6 +831,10 @@
imageData.editTransition.get().bundle,
imageData.owner, true);
});
+ mDeleteChip.setPendingIntent(imageData.deleteAction.actionIntent, () -> {
+ mUiEventLogger.log(ScreenshotEvent.SCREENSHOT_DELETE_TAPPED);
+ animateDismissal();
+ });
mScreenshotPreview.setOnClickListener(v -> {
mUiEventLogger.log(ScreenshotEvent.SCREENSHOT_PREVIEW_TAPPED, 0, mPackageName);
prepareSharedTransition();
@@ -851,6 +874,9 @@
case EDIT:
mEditChip.callOnClick();
break;
+ case DELETE:
+ mDeleteChip.callOnClick();
+ break;
case QUICK_SHARE:
mQuickShareChip.callOnClick();
break;
@@ -893,6 +919,7 @@
mQuickShareChip.setOnClickListener(v -> {
mShareChip.setIsPending(false);
mEditChip.setIsPending(false);
+ mDeleteChip.setIsPending(false);
mQuickShareChip.setIsPending(true);
mPendingInteraction = PendingInteraction.QUICK_SHARE;
});
@@ -1080,8 +1107,10 @@
mShareChip.setOnClickListener(null);
mScrollingScrim.setVisibility(View.GONE);
mEditChip.setOnClickListener(null);
+ mDeleteChip.setOnClickListener(null);
mShareChip.setIsPending(false);
mEditChip.setIsPending(false);
+ mDeleteChip.setIsPending(false);
mPendingInteraction = null;
for (OverlayActionChip chip : mSmartChips) {
mActionsView.removeView(chip);