Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

Commit

Permalink
[temporary] hide screenshot action buttons when keyguard is locked
Browse files Browse the repository at this point in the history
The previous change broke screenshot action buttons (edit, share and
scroll), when keyguard is locked. This change hides them, if the
keyguard is locked.
  • Loading branch information
octocorvus authored and muhomorr committed Aug 18, 2023
1 parent 9968826 commit e5e6b2a
Showing 1 changed file with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import android.animation.AnimatorSet;
import android.animation.ValueAnimator;
import android.app.ActivityManager;
import android.app.KeyguardManager;
import android.app.Notification;
import android.app.PendingIntent;
import android.content.Context;
Expand Down Expand Up @@ -170,6 +171,7 @@ interface ScreenshotViewCallback {
private long mDefaultTimeoutOfTimeoutHandler;
private ActionIntentExecutor mActionExecutor;
private FeatureFlags mFlags;
private KeyguardManager mKeyguardManager;

private enum PendingInteraction {
PREVIEW,
Expand Down Expand Up @@ -737,8 +739,10 @@ ValueAnimator createScreenshotActionsShadeAnimation() {
/ SCREENSHOT_ACTIONS_EXPANSION_DURATION_MS;
mActionsContainer.setAlpha(0f);
mActionsContainerBackground.setAlpha(0f);
mActionsContainer.setVisibility(View.VISIBLE);
mActionsContainerBackground.setVisibility(View.VISIBLE);
if (!isKeyguardLocked()) {
mActionsContainer.setVisibility(View.VISIBLE);
mActionsContainerBackground.setVisibility(View.VISIBLE);
}

animator.addListener(new AnimatorListenerAdapter() {
@Override
Expand Down Expand Up @@ -824,6 +828,9 @@ void setChipIntents(ScreenshotController.SavedImageData imageData) {
});
mScreenshotPreview.setOnClickListener(v -> {
mUiEventLogger.log(ScreenshotEvent.SCREENSHOT_PREVIEW_TAPPED, 0, mPackageName);
if (isKeyguardLocked()) {
return;
}
if (mFlags.isEnabled(Flags.SCREENSHOT_WORK_PROFILE_POLICY)) {
prepareSharedTransition();
mActionExecutor.launchIntentAsync(
Expand Down Expand Up @@ -1044,8 +1051,10 @@ void restoreNonScrollingUi() {
if (mAccessibilityManager.isEnabled()) {
mDismissButton.setVisibility(View.VISIBLE);
}
mActionsContainer.setVisibility(View.VISIBLE);
mActionsContainerBackground.setVisibility(View.VISIBLE);
if (!isKeyguardLocked()) {
mActionsContainer.setVisibility(View.VISIBLE);
mActionsContainerBackground.setVisibility(View.VISIBLE);
}
mScreenshotPreviewBorder.setVisibility(View.VISIBLE);
mScreenshotPreview.setVisibility(View.VISIBLE);
// reset the timeout
Expand Down Expand Up @@ -1130,6 +1139,13 @@ private void prepareSharedTransition() {
createScreenshotFadeDismissAnimation().start();
}

private boolean isKeyguardLocked() {
if (mKeyguardManager == null) {
mKeyguardManager = requireNonNull(mContext.getSystemService(KeyguardManager.class));
}
return mKeyguardManager.isKeyguardLocked();
}

ValueAnimator createScreenshotFadeDismissAnimation() {
ValueAnimator alphaAnim = ValueAnimator.ofFloat(0, 1);
alphaAnim.addUpdateListener(animation -> {
Expand Down

0 comments on commit e5e6b2a

Please sign in to comment.