From 6f2ef588972e353837ae865bd56b7b6756ac5350 Mon Sep 17 00:00:00 2001 From: Govinda Wasserman Date: Wed, 19 Oct 2022 13:08:10 -0400 Subject: Adds a notification to work profile screenshots Test: Setup a work profile Test: Take a screenshot of a standard app Test: Observe normal screenshot flow Test: Take a screenshot of a work profile app Test: Observe that a notification appears below the screenshot BUG: 254245929 Change-Id: Ib48861fbe8bf28d7a1cfbb9ce1b60e2af1c3018e --- packages/SystemUI/res/layout/screenshot_static.xml | 41 ++++++++++++++++++++-- packages/SystemUI/res/values/strings.xml | 2 ++ .../systemui/screenshot/ScreenshotController.java | 19 ++++++++-- .../systemui/screenshot/ScreenshotView.java | 19 ++++++++++ 4 files changed, 76 insertions(+), 5 deletions(-) diff --git a/packages/SystemUI/res/layout/screenshot_static.xml b/packages/SystemUI/res/layout/screenshot_static.xml index 1ac78d491d78..88429925eed0 100644 --- a/packages/SystemUI/res/layout/screenshot_static.xml +++ b/packages/SystemUI/res/layout/screenshot_static.xml @@ -44,7 +44,7 @@ app:layout_constraintHorizontal_bias="0" app:layout_constraintWidth_percent="1.0" app:layout_constraintWidth_max="wrap" - app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintBottom_toTopOf="@id/screenshot_message_container" app:layout_constraintStart_toEndOf="@+id/screenshot_preview_border" app:layout_constraintEnd_toEndOf="parent"> + + + + + + + + diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index 212c77b50477..14cbcf64ab64 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -235,6 +235,8 @@ Left boundary %1$d percent Right boundary %1$d percent + + Work screenshots are saved in the work %1$s app Screen Recorder diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.java b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.java index 9b5295d1bb3d..d395bd33241d 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.java @@ -63,6 +63,7 @@ import android.os.Bundle; import android.os.Process; import android.os.RemoteException; import android.os.UserHandle; +import android.os.UserManager; import android.provider.Settings; import android.util.DisplayMetrics; import android.util.Log; @@ -276,6 +277,7 @@ public class ScreenshotController { mScreenshotNotificationSmartActionsProvider; private final TimeoutHandler mScreenshotHandler; private final ActionIntentExecutor mActionExecutor; + private final UserManager mUserManager; private ScreenshotView mScreenshotView; private Bitmap mScreenBitmap; @@ -314,7 +316,8 @@ public class ScreenshotController { TimeoutHandler timeoutHandler, BroadcastSender broadcastSender, ScreenshotNotificationSmartActionsProvider screenshotNotificationSmartActionsProvider, - ActionIntentExecutor actionExecutor + ActionIntentExecutor actionExecutor, + UserManager userManager ) { mScreenshotSmartActions = screenshotSmartActions; mNotificationsController = screenshotNotificationsController; @@ -345,6 +348,7 @@ public class ScreenshotController { mWindowManager = mContext.getSystemService(WindowManager.class); mFlags = flags; mActionExecutor = actionExecutor; + mUserManager = userManager; mAccessibilityManager = AccessibilityManager.getInstance(mContext); @@ -975,16 +979,25 @@ public class ScreenshotController { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); - mScreenshotView.setChipIntents(imageData); + doPostAnimation(imageData); } }); } else { - mScreenshotView.setChipIntents(imageData); + doPostAnimation(imageData); } }); } } + private void doPostAnimation(ScreenshotController.SavedImageData imageData) { + mScreenshotView.setChipIntents(imageData); + if (mFlags.isEnabled(SCREENSHOT_WORK_PROFILE_POLICY) + && mUserManager.isManagedProfile(imageData.owner.getIdentifier())) { + // TODO: Read app from configuration + mScreenshotView.showWorkProfileMessage("Files"); + } + } + /** * Sets up the action shade and its entrance animation, once we get the Quick Share action data. */ diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotView.java b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotView.java index 27331ae7a389..0a4b550882c9 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotView.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotView.java @@ -80,6 +80,7 @@ import android.widget.FrameLayout; import android.widget.HorizontalScrollView; import android.widget.ImageView; import android.widget.LinearLayout; +import android.widget.TextView; import androidx.constraintlayout.widget.ConstraintLayout; @@ -137,6 +138,8 @@ public class ScreenshotView extends FrameLayout implements private ImageView mScrollingScrim; private DraggableConstraintLayout mScreenshotStatic; + private ViewGroup mMessageContainer; + private TextView mMessageContent; private ImageView mScreenshotPreview; private ImageView mScreenshotBadge; private View mScreenshotPreviewBorder; @@ -340,10 +343,26 @@ public class ScreenshotView extends FrameLayout implements } } + /** + * Show a notification under the screenshot view indicating that a work profile screenshot has + * been taken and which app can be used to view it. + * + * @param appName The name of the app to use to view screenshots + */ + void showWorkProfileMessage(String appName) { + mMessageContent.setText( + mContext.getString(R.string.screenshot_work_profile_notification, appName)); + mMessageContainer.setVisibility(VISIBLE); + } + @Override // View protected void onFinishInflate() { mScrollingScrim = requireNonNull(findViewById(R.id.screenshot_scrolling_scrim)); mScreenshotStatic = requireNonNull(findViewById(R.id.screenshot_static)); + mMessageContainer = + requireNonNull(mScreenshotStatic.findViewById(R.id.screenshot_message_container)); + mMessageContent = + requireNonNull(mMessageContainer.findViewById(R.id.screenshot_message_content)); mScreenshotPreview = requireNonNull(findViewById(R.id.screenshot_preview)); mScreenshotPreviewBorder = requireNonNull( -- cgit v1.2.3-59-g8ed1b