Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8c30fe63 authored by Miranda Kephart's avatar Miranda Kephart Committed by Automerger Merge Worker
Browse files

Merge "Revert "Post a silent notification if screenshot is dismissed"" into...

Merge "Revert "Post a silent notification if screenshot is dismissed"" into rvc-dev am: 3a9ce8d1 am: 6025e31c am: 29f33b80 am: 9519294d

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

Change-Id: Id4076aad4fe8dc357c6eb39a4eccf223e17a66d4
parents 7d3204bd 9519294d
Loading
Loading
Loading
Loading
+0 −12
Original line number Diff line number Diff line
@@ -215,7 +215,6 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset
    private Animator mScreenshotAnimation;
    private Runnable mOnCompleteRunnable;
    private Animator mDismissAnimation;
    private SavedImageData mImageData;
    private boolean mInDarkMode = false;
    private boolean mDirectionLTR = true;
    private boolean mOrientationPortrait = true;
@@ -234,9 +233,6 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset
            switch (msg.what) {
                case MESSAGE_CORNER_TIMEOUT:
                    mUiEventLogger.log(ScreenshotEvent.SCREENSHOT_INTERACTION_TIMEOUT);
                    if (mImageData != null) {
                        mNotificationsController.showSilentScreenshotNotification(mImageData);
                    }
                    GlobalScreenshot.this.dismissScreenshot("timeout", false);
                    mOnCompleteRunnable.run();
                    break;
@@ -408,9 +404,6 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset
        mDismissButton = mScreenshotLayout.findViewById(R.id.global_screenshot_dismiss_button);
        mDismissButton.setOnClickListener(view -> {
            mUiEventLogger.log(ScreenshotEvent.SCREENSHOT_EXPLICIT_DISMISSAL);
            if (mImageData != null) {
                mNotificationsController.showSilentScreenshotNotification(mImageData);
            }
            dismissScreenshot("dismiss_button", false);
            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.execute();
    }
@@ -670,7 +659,6 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset
     */
    private void showUiOnActionsReady(SavedImageData imageData) {
        logSuccessOnActionsReady(imageData);
        mImageData = imageData;

        AccessibilityManager accessibilityManager = (AccessibilityManager)
                mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
+36 −18
Original line number Diff line number Diff line
@@ -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
     */
    public void showSilentScreenshotNotification(
    public void showScreenshotActionsNotification(
            GlobalScreenshot.SavedImageData actionData) {
        mNotificationBuilder.addAction(actionData.shareAction);
        mNotificationBuilder.addAction(actionData.editAction);
@@ -174,34 +206,20 @@ public class ScreenshotNotificationsController {
                .setContentTitle(mResources.getString(R.string.screenshot_saved_title))
                .setContentText(mResources.getString(R.string.screenshot_saved_text))
                .setContentIntent(PendingIntent.getActivity(mContext, 0, launchIntent, 0))
                .setSmallIcon(R.drawable.stat_notify_image)
                .setCategory(Notification.CATEGORY_PROGRESS)
                .setWhen(now)
                .setShowWhen(true)
                .setAutoCancel(true)
                .setColor(mContext.getColor(
                        com.android.internal.R.color.system_notification_accent_color))
                .setGroup("silent")
                .setGroupAlertBehavior(Notification.GROUP_ALERT_SUMMARY);
                        com.android.internal.R.color.system_notification_accent_color));
        mNotificationBuilder
                .setContentTitle(mResources.getString(R.string.screenshot_saved_title))
                .setContentText(mResources.getString(R.string.screenshot_saved_text))
                .setContentIntent(PendingIntent.getActivity(mContext, 0, launchIntent, 0))
                .setSmallIcon(R.drawable.stat_notify_image)
                .setCategory(Notification.CATEGORY_PROGRESS)
                .setWhen(now)
                .setShowWhen(true)
                .setAutoCancel(true)
                .setColor(mContext.getColor(
                        com.android.internal.R.color.system_notification_accent_color))
                .setPublicVersion(mPublicNotificationBuilder.build())
                .setStyle(mNotificationStyle)
                .setFlag(Notification.FLAG_NO_CLEAR, false)
                .setGroup("silent")
                .setGroupAlertBehavior(Notification.GROUP_ALERT_SUMMARY);

        SystemUI.overrideNotificationAppName(mContext, mPublicNotificationBuilder, true);
        SystemUI.overrideNotificationAppName(mContext, mNotificationBuilder, true);
                .setFlag(Notification.FLAG_NO_CLEAR, false);

        mNotificationManager.notify(SystemMessageProto.SystemMessage.NOTE_GLOBAL_SCREENSHOT,
                mNotificationBuilder.build());