Merge "Revert "Post a silent notification if screenshot is dismissed"" into rvc-dev am: 3a9ce8d11a

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11851515

Change-Id: I05c2ec3fa2b232296dd3eee02d700a981fd9e86e
This commit is contained in:
Miranda Kephart
2020-06-15 18:54:35 +00:00
committed by Automerger Merge Worker
2 changed files with 36 additions and 30 deletions

View File

@@ -215,7 +215,6 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset
private Animator mScreenshotAnimation; private Animator mScreenshotAnimation;
private Runnable mOnCompleteRunnable; private Runnable mOnCompleteRunnable;
private Animator mDismissAnimation; private Animator mDismissAnimation;
private SavedImageData mImageData;
private boolean mInDarkMode = false; private boolean mInDarkMode = false;
private boolean mDirectionLTR = true; private boolean mDirectionLTR = true;
private boolean mOrientationPortrait = true; private boolean mOrientationPortrait = true;
@@ -234,9 +233,6 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset
switch (msg.what) { switch (msg.what) {
case MESSAGE_CORNER_TIMEOUT: case MESSAGE_CORNER_TIMEOUT:
mUiEventLogger.log(ScreenshotEvent.SCREENSHOT_INTERACTION_TIMEOUT); mUiEventLogger.log(ScreenshotEvent.SCREENSHOT_INTERACTION_TIMEOUT);
if (mImageData != null) {
mNotificationsController.showSilentScreenshotNotification(mImageData);
}
GlobalScreenshot.this.dismissScreenshot("timeout", false); GlobalScreenshot.this.dismissScreenshot("timeout", false);
mOnCompleteRunnable.run(); mOnCompleteRunnable.run();
break; break;
@@ -408,9 +404,6 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset
mDismissButton = mScreenshotLayout.findViewById(R.id.global_screenshot_dismiss_button); mDismissButton = mScreenshotLayout.findViewById(R.id.global_screenshot_dismiss_button);
mDismissButton.setOnClickListener(view -> { mDismissButton.setOnClickListener(view -> {
mUiEventLogger.log(ScreenshotEvent.SCREENSHOT_EXPLICIT_DISMISSAL); mUiEventLogger.log(ScreenshotEvent.SCREENSHOT_EXPLICIT_DISMISSAL);
if (mImageData != null) {
mNotificationsController.showSilentScreenshotNotification(mImageData);
}
dismissScreenshot("dismiss_button", false); dismissScreenshot("dismiss_button", false);
mOnCompleteRunnable.run(); mOnCompleteRunnable.run();
}); });
@@ -450,10 +443,6 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset
}); });
} }
mImageData = null; // make sure we clear the current stored data
mNotificationsController.reset();
mNotificationsController.setImage(mScreenBitmap);
mSaveInBgTask = new SaveImageInBackgroundTask(mContext, data); mSaveInBgTask = new SaveImageInBackgroundTask(mContext, data);
mSaveInBgTask.execute(); mSaveInBgTask.execute();
} }
@@ -670,7 +659,6 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset
*/ */
private void showUiOnActionsReady(SavedImageData imageData) { private void showUiOnActionsReady(SavedImageData imageData) {
logSuccessOnActionsReady(imageData); logSuccessOnActionsReady(imageData);
mImageData = imageData;
AccessibilityManager accessibilityManager = (AccessibilityManager) AccessibilityManager accessibilityManager = (AccessibilityManager)
mContext.getSystemService(Context.ACCESSIBILITY_SERVICE); mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);

View File

@@ -148,11 +148,43 @@ public class ScreenshotNotificationsController {
} }
/** /**
* Shows a silent notification with the saved screenshot and actions that can be taken with it. * Shows a notification to inform the user that a screenshot is currently being saved.
*/
public void showSavingScreenshotNotification() {
final long now = System.currentTimeMillis();
mPublicNotificationBuilder
.setContentTitle(mResources.getString(R.string.screenshot_saving_title))
.setSmallIcon(R.drawable.stat_notify_image)
.setCategory(Notification.CATEGORY_PROGRESS)
.setWhen(now)
.setShowWhen(true)
.setColor(mResources.getColor(
com.android.internal.R.color.system_notification_accent_color));
SystemUI.overrideNotificationAppName(mContext, mPublicNotificationBuilder, true);
mNotificationBuilder
.setContentTitle(mResources.getString(R.string.screenshot_saving_title))
.setSmallIcon(R.drawable.stat_notify_image)
.setWhen(now)
.setShowWhen(true)
.setColor(mResources.getColor(
com.android.internal.R.color.system_notification_accent_color))
.setStyle(mNotificationStyle)
.setPublicVersion(mPublicNotificationBuilder.build());
mNotificationBuilder.setFlag(Notification.FLAG_NO_CLEAR, true);
SystemUI.overrideNotificationAppName(mContext, mNotificationBuilder, true);
mNotificationManager.notify(SystemMessageProto.SystemMessage.NOTE_GLOBAL_SCREENSHOT,
mNotificationBuilder.build());
}
/**
* Shows a notification with the saved screenshot and actions that can be taken with it.
* *
* @param actionData SavedImageData struct with image URI and actions * @param actionData SavedImageData struct with image URI and actions
*/ */
public void showSilentScreenshotNotification( public void showScreenshotActionsNotification(
GlobalScreenshot.SavedImageData actionData) { GlobalScreenshot.SavedImageData actionData) {
mNotificationBuilder.addAction(actionData.shareAction); mNotificationBuilder.addAction(actionData.shareAction);
mNotificationBuilder.addAction(actionData.editAction); mNotificationBuilder.addAction(actionData.editAction);
@@ -174,34 +206,20 @@ public class ScreenshotNotificationsController {
.setContentTitle(mResources.getString(R.string.screenshot_saved_title)) .setContentTitle(mResources.getString(R.string.screenshot_saved_title))
.setContentText(mResources.getString(R.string.screenshot_saved_text)) .setContentText(mResources.getString(R.string.screenshot_saved_text))
.setContentIntent(PendingIntent.getActivity(mContext, 0, launchIntent, 0)) .setContentIntent(PendingIntent.getActivity(mContext, 0, launchIntent, 0))
.setSmallIcon(R.drawable.stat_notify_image)
.setCategory(Notification.CATEGORY_PROGRESS)
.setWhen(now) .setWhen(now)
.setShowWhen(true)
.setAutoCancel(true) .setAutoCancel(true)
.setColor(mContext.getColor( .setColor(mContext.getColor(
com.android.internal.R.color.system_notification_accent_color)) com.android.internal.R.color.system_notification_accent_color));
.setGroup("silent")
.setGroupAlertBehavior(Notification.GROUP_ALERT_SUMMARY);
mNotificationBuilder mNotificationBuilder
.setContentTitle(mResources.getString(R.string.screenshot_saved_title)) .setContentTitle(mResources.getString(R.string.screenshot_saved_title))
.setContentText(mResources.getString(R.string.screenshot_saved_text)) .setContentText(mResources.getString(R.string.screenshot_saved_text))
.setContentIntent(PendingIntent.getActivity(mContext, 0, launchIntent, 0)) .setContentIntent(PendingIntent.getActivity(mContext, 0, launchIntent, 0))
.setSmallIcon(R.drawable.stat_notify_image)
.setCategory(Notification.CATEGORY_PROGRESS)
.setWhen(now) .setWhen(now)
.setShowWhen(true)
.setAutoCancel(true) .setAutoCancel(true)
.setColor(mContext.getColor( .setColor(mContext.getColor(
com.android.internal.R.color.system_notification_accent_color)) com.android.internal.R.color.system_notification_accent_color))
.setPublicVersion(mPublicNotificationBuilder.build()) .setPublicVersion(mPublicNotificationBuilder.build())
.setStyle(mNotificationStyle) .setFlag(Notification.FLAG_NO_CLEAR, false);
.setFlag(Notification.FLAG_NO_CLEAR, false)
.setGroup("silent")
.setGroupAlertBehavior(Notification.GROUP_ALERT_SUMMARY);
SystemUI.overrideNotificationAppName(mContext, mPublicNotificationBuilder, true);
SystemUI.overrideNotificationAppName(mContext, mNotificationBuilder, true);
mNotificationManager.notify(SystemMessageProto.SystemMessage.NOTE_GLOBAL_SCREENSHOT, mNotificationManager.notify(SystemMessageProto.SystemMessage.NOTE_GLOBAL_SCREENSHOT,
mNotificationBuilder.build()); mNotificationBuilder.build());