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

Commit ff851051 authored by Miranda Kephart's avatar Miranda Kephart Committed by Android (Google) Code Review
Browse files

Merge "Add profile badges to screenshot UI" into tm-qpr-dev

parents ea7e2c10 f4067070
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2020 The Android Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
        android:shape="oval">
    <solid android:color="?androidprv:attr/colorSurface"/>
</shape>
+12 −2
Original line number Diff line number Diff line
@@ -103,8 +103,18 @@
        app:layout_constraintBottom_toBottomOf="@id/screenshot_preview_border"
        app:layout_constraintStart_toStartOf="@id/screenshot_preview_border"
        app:layout_constraintEnd_toEndOf="@id/screenshot_preview_border"
        app:layout_constraintTop_toTopOf="@id/screenshot_preview_border">
    </ImageView>
        app:layout_constraintTop_toTopOf="@id/screenshot_preview_border"/>
    <ImageView
        android:id="@+id/screenshot_badge"
        android:layout_width="24dp"
        android:layout_height="24dp"
        android:padding="4dp"
        android:visibility="gone"
        android:background="@drawable/overlay_badge_background"
        android:elevation="8dp"
        android:src="@drawable/overlay_cancel"
        app:layout_constraintBottom_toBottomOf="@id/screenshot_preview_border"
        app:layout_constraintEnd_toEndOf="@id/screenshot_preview_border"/>
    <FrameLayout
        android:id="@+id/screenshot_dismiss_button"
        android:layout_width="@dimen/overlay_dismiss_button_tappable_size"
+7 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static android.content.res.Configuration.ORIENTATION_PORTRAIT;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.WindowManager.LayoutParams.TYPE_SCREENSHOT;

import static com.android.systemui.flags.Flags.SCREENSHOT_WORK_PROFILE_POLICY;
import static com.android.systemui.screenshot.LogConfig.DEBUG_ANIM;
import static com.android.systemui.screenshot.LogConfig.DEBUG_CALLBACK;
import static com.android.systemui.screenshot.LogConfig.DEBUG_DISMISS;
@@ -634,6 +635,11 @@ public class ScreenshotController {
                        return true;
                    }
                });

        if (mFlags.isEnabled(SCREENSHOT_WORK_PROFILE_POLICY)) {
            mScreenshotView.badgeScreenshot(
                    mContext.getPackageManager().getUserBadgeForDensity(owner, 0));
        }
        mScreenshotView.setScreenshot(mScreenBitmap, screenInsets);
        if (DEBUG_WINDOW) {
            Log.d(TAG, "setContentView: " + mScreenshotView);
+16 −9
Original line number Diff line number Diff line
@@ -74,7 +74,6 @@ import android.view.WindowInsets;
import android.view.WindowManager;
import android.view.WindowMetrics;
import android.view.accessibility.AccessibilityManager;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
import android.widget.FrameLayout;
@@ -122,15 +121,9 @@ public class ScreenshotView extends FrameLayout implements
    private static final long SCREENSHOT_TO_CORNER_SCALE_DURATION_MS = 234;
    private static final long SCREENSHOT_ACTIONS_EXPANSION_DURATION_MS = 400;
    private static final long SCREENSHOT_ACTIONS_ALPHA_DURATION_MS = 100;
    private static final long SCREENSHOT_DISMISS_X_DURATION_MS = 350;
    private static final long SCREENSHOT_DISMISS_ALPHA_DURATION_MS = 350;
    private static final long SCREENSHOT_DISMISS_ALPHA_OFFSET_MS = 50; // delay before starting fade
    private static final float SCREENSHOT_ACTIONS_START_SCALE_X = .7f;
    private static final float ROUNDED_CORNER_RADIUS = .25f;
    private static final int SWIPE_PADDING_DP = 12; // extra padding around views to allow swipe

    private final Interpolator mAccelerateInterpolator = new AccelerateInterpolator();

    private final Resources mResources;
    private final Interpolator mFastOutSlowIn;
    private final DisplayMetrics mDisplayMetrics;
@@ -145,6 +138,7 @@ public class ScreenshotView extends FrameLayout implements
    private ImageView mScrollingScrim;
    private DraggableConstraintLayout mScreenshotStatic;
    private ImageView mScreenshotPreview;
    private ImageView mScreenshotBadge;
    private View mScreenshotPreviewBorder;
    private ImageView mScrollablePreview;
    private ImageView mScreenshotFlash;
@@ -355,6 +349,7 @@ public class ScreenshotView extends FrameLayout implements
        mScreenshotPreviewBorder = requireNonNull(
                findViewById(R.id.screenshot_preview_border));
        mScreenshotPreview.setClipToOutline(true);
        mScreenshotBadge = requireNonNull(findViewById(R.id.screenshot_badge));

        mActionsContainerBackground = requireNonNull(findViewById(
                R.id.actions_container_background));
@@ -595,8 +590,11 @@ public class ScreenshotView extends FrameLayout implements

        ValueAnimator borderFadeIn = ValueAnimator.ofFloat(0, 1);
        borderFadeIn.setDuration(100);
        borderFadeIn.addUpdateListener((animation) ->
                mScreenshotPreviewBorder.setAlpha(animation.getAnimatedFraction()));
        borderFadeIn.addUpdateListener((animation) -> {
            float borderAlpha = animation.getAnimatedFraction();
            mScreenshotPreviewBorder.setAlpha(borderAlpha);
            mScreenshotBadge.setAlpha(borderAlpha);
        });

        if (showFlash) {
            dropInAnimation.play(flashOutAnimator).after(flashInAnimator);
@@ -763,6 +761,11 @@ public class ScreenshotView extends FrameLayout implements
        return animator;
    }

    void badgeScreenshot(Drawable badge) {
        mScreenshotBadge.setImageDrawable(badge);
        mScreenshotBadge.setVisibility(badge != null ? View.VISIBLE : View.GONE);
    }

    void setChipIntents(ScreenshotController.SavedImageData imageData) {
        mShareChip.setOnClickListener(v -> {
            mUiEventLogger.log(ScreenshotEvent.SCREENSHOT_SHARE_TAPPED, 0, mPackageName);
@@ -1027,6 +1030,9 @@ public class ScreenshotView extends FrameLayout implements
        mScreenshotPreview.setVisibility(View.INVISIBLE);
        mScreenshotPreview.setAlpha(1f);
        mScreenshotPreviewBorder.setAlpha(0);
        mScreenshotBadge.setAlpha(0f);
        mScreenshotBadge.setVisibility(View.GONE);
        mScreenshotBadge.setImageDrawable(null);
        mPendingSharedTransition = false;
        mActionsContainerBackground.setVisibility(View.GONE);
        mActionsContainer.setVisibility(View.GONE);
@@ -1082,6 +1088,7 @@ public class ScreenshotView extends FrameLayout implements
            mActionsContainerBackground.setAlpha(alpha);
            mActionsContainer.setAlpha(alpha);
            mScreenshotPreviewBorder.setAlpha(alpha);
            mScreenshotBadge.setAlpha(alpha);
        });
        alphaAnim.setDuration(600);
        return alphaAnim;