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

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

Merge "Add a dismiss button to screenshot corner flow"

parents f96ddaae a2ebd761
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
<!--
  ~ 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.
  -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0"
        android:tint="?attr/colorControlNormal">
    <path
        android:fillColor="@android:color/white"
        android:pathData="M12,2C6.47,2 2,6.47 2,12s4.47,10 10,10 10,-4.47 10,-10S17.53,2 12,2zM17,15.59L15.59,17 12,13.41 8.41,17 7,15.59 10.59,12 7,8.41 8.41,7 12,10.59 15.59,7 17,8.41 13.41,12 17,15.59z"/>
</vector>
 No newline at end of file
+28 −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.
  -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="48dp"
        android:height="48dp"
        android:viewportWidth="48.0"
        android:viewportHeight="48.0">
    <path
        android:pathData="M24,24m-16,0a16,16 0,1 1,32 0a16,16 0,1 1,-32 0"
        android:fillColor="@android:color/white"/>
    <path
        android:fillColor="@color/GM2_grey_500"
        android:pathData="M31,18.41L29.59,17 24,22.59 18.41,17 17,18.41 22.59,24 17,29.59 18.41,31 24,25.41 29.59,31 31,29.59 25.41,24z"/>
</vector>
 No newline at end of file
+13 −1
Original line number Diff line number Diff line
@@ -55,10 +55,22 @@
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:elevation="8dp"
        android:elevation="@dimen/screenshot_preview_elevation"
        android:visibility="gone"
        android:background="@drawable/screenshot_rounded_corners"
        android:adjustViewBounds="true"/>
    <FrameLayout
        android:id="@+id/global_screenshot_dismiss_button"
        android:layout_width="@dimen/screenshot_dismiss_button_tappable_size"
        android:layout_height="@dimen/screenshot_dismiss_button_tappable_size"
        android:elevation="9dp"
        android:visibility="gone">
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_margin="@dimen/screenshot_dismiss_button_margin"
            android:src="@drawable/screenshot_cancel"/>
    </FrameLayout>
    <ImageView
        android:id="@+id/global_screenshot_flash"
        android:layout_width="match_parent"
+19 −6
Original line number Diff line number Diff line
@@ -103,7 +103,8 @@
    <item name="status_bar_icon_scale_factor" format="float" type="dimen">1.0</item>

    <dimen name="group_overflow_number_size">@*android:dimen/notification_text_size</dimen>
    <dimen name="group_overflow_number_padding">@*android:dimen/notification_content_margin_end</dimen>
    <dimen name="group_overflow_number_padding">@*android:dimen/notification_content_margin_end
    </dimen>

    <!-- max height of a notification such that the content can still fade out when closing -->
    <dimen name="max_notification_fadeout_height">100dp</dimen>
@@ -267,7 +268,9 @@
    <dimen name="status_bar_icon_drawing_size">15dp</dimen>

    <!-- size at which Notification icons will be drawn on Ambient Display -->
    <dimen name="status_bar_icon_drawing_size_dark">@*android:dimen/notification_header_icon_size_ambient</dimen>
    <dimen name="status_bar_icon_drawing_size_dark">
        @*android:dimen/notification_header_icon_size_ambient
    </dimen>

    <!-- size of notification icons when the notifications are hidden -->
    <dimen name="hidden_shelf_icon_size">16dp</dimen>
@@ -299,8 +302,11 @@
    <dimen name="global_screenshot_legacy_bg_padding">20dp</dimen>
    <dimen name="global_screenshot_bg_padding">20dp</dimen>
    <dimen name="global_screenshot_x_scale">80dp</dimen>
    <dimen name="screenshot_preview_elevation">8dp</dimen>
    <dimen name="screenshot_offset_y">48dp</dimen>
    <dimen name="screenshot_offset_x">16dp</dimen>
    <dimen name="screenshot_dismiss_button_tappable_size">48dp</dimen>
    <dimen name="screenshot_dismiss_button_margin">8dp</dimen>
    <dimen name="screenshot_action_container_offset_y">32dp</dimen>
    <dimen name="screenshot_action_container_corner_radius">10dp</dimen>
    <dimen name="screenshot_action_container_padding_vertical">10dp</dimen>
@@ -597,10 +603,14 @@

    <!-- The height of the divider between the individual notifications in a notification
         group. -->
    <dimen name="notification_children_container_divider_height">@dimen/notification_divider_height</dimen>
    <dimen name="notification_children_container_divider_height">
        @dimen/notification_divider_height
    </dimen>

    <!-- The top margin for the notification children container in its non-expanded form. -->
    <dimen name="notification_children_container_margin_top">@*android:dimen/notification_content_margin_top</dimen>
    <dimen name="notification_children_container_margin_top">
        @*android:dimen/notification_content_margin_top
    </dimen>

    <!-- The height of a notification header -->
    <dimen name="notification_header_height">53dp</dimen>
@@ -1061,9 +1071,12 @@
    <integer name="wireless_charging_scale_dots_duration">83</integer>
    <integer name="wireless_charging_num_dots">16</integer>
    <!-- Starting text size in sp of batteryLevel for wireless charging animation -->
    <item name="wireless_charging_anim_battery_level_text_size_start" format="float" type="dimen">0</item>
    <item name="wireless_charging_anim_battery_level_text_size_start" format="float" type="dimen">
        0
    </item>
    <!-- Ending text size in sp of batteryLevel for wireless charging animation -->
    <item name="wireless_charging_anim_battery_level_text_size_end" format="float" type="dimen">24</item>
    <item name="wireless_charging_anim_battery_level_text_size_end" format="float" type="dimen">24
    </item>
    <!-- time until battery info is at full opacity-->
    <integer name="wireless_charging_anim_opacity_offset">80</integer>
    <!-- duration batteryLevel opacity goes from 0 to 1 duration -->
+23 −16
Original line number Diff line number Diff line
@@ -69,6 +69,7 @@ import android.view.ViewOutlineProvider;
import android.view.ViewTreeObserver;
import android.view.WindowManager;
import android.view.animation.Interpolator;
import android.widget.FrameLayout;
import android.widget.HorizontalScrollView;
import android.widget.ImageView;
import android.widget.LinearLayout;
@@ -143,7 +144,7 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset
    private static final float BACKGROUND_ALPHA = 0.5f;
    private static final float SCREENSHOT_DROP_IN_MIN_SCALE = 0.725f;
    private static final float ROUNDED_CORNER_RADIUS = .05f;
    private static final long SCREENSHOT_CORNER_TIMEOUT_MILLIS = 8000;
    private static final long SCREENSHOT_CORNER_TIMEOUT_MILLIS = 6000;
    private static final int MESSAGE_CORNER_TIMEOUT = 2;

    private final ScreenshotNotificationsController mNotificationsController;
@@ -162,6 +163,7 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset
    private final HorizontalScrollView mActionsContainer;
    private final LinearLayout mActionsView;
    private final ImageView mBackgroundProtection;
    private final FrameLayout mDismissButton;

    private Bitmap mScreenBitmap;
    private AnimatorSet mScreenshotAnimation;
@@ -170,6 +172,7 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset
    private float mScreenshotOffsetYPx;
    private float mScreenshotHeightPx;
    private float mCornerScale;
    private float mDismissButtonSize;

    private AsyncTask<Void, Void, Void> mSaveInBgTask;

@@ -216,19 +219,14 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset
        mActionsView = mScreenshotLayout.findViewById(R.id.global_screenshot_actions);
        mBackgroundProtection = mScreenshotLayout.findViewById(
                R.id.global_screenshot_actions_background);
        mDismissButton = mScreenshotLayout.findViewById(R.id.global_screenshot_dismiss_button);
        mDismissButton.setOnClickListener(view -> clearScreenshot("dismiss_button"));

        mScreenshotFlash = mScreenshotLayout.findViewById(R.id.global_screenshot_flash);
        mScreenshotSelectorView = mScreenshotLayout.findViewById(R.id.global_screenshot_selector);
        mScreenshotLayout.setFocusable(true);
        mScreenshotSelectorView.setFocusable(true);
        mScreenshotSelectorView.setFocusableInTouchMode(true);
        mScreenshotLayout.setOnTouchListener((v, event) -> {
            if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
                clearScreenshot("tap_outside");
            }
            // Intercept and ignore all touch events
            return true;
        });

        // Setup the window that we are going to use
        mWindowLayoutParams = new WindowManager.LayoutParams(
@@ -254,6 +252,8 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset
                resources.getDimensionPixelSize(R.dimen.screenshot_action_container_offset_y);
        mCornerScale = resources.getDimensionPixelSize(R.dimen.global_screenshot_x_scale)
                / (float) mDisplayMetrics.widthPixels;
        mDismissButtonSize = resources.getDimensionPixelSize(
                R.dimen.screenshot_dismiss_button_tappable_size);

        // Setup the Camera shutter sound
        mCameraSound = new MediaActionSound();
@@ -271,6 +271,9 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset
        Rect actionsRect = new Rect();
        mActionsContainer.getBoundsOnScreen(actionsRect);
        touchRegion.op(actionsRect, Region.Op.UNION);
        Rect dismissRect = new Rect();
        mDismissButton.getBoundsOnScreen(dismissRect);
        touchRegion.op(dismissRect, Region.Op.UNION);

        inoutInfo.touchableRegion.set(touchRegion);
    }
@@ -408,6 +411,7 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset
        mActionsContainer.setVisibility(View.GONE);
        mBackgroundView.setVisibility(View.GONE);
        mBackgroundProtection.setAlpha(0f);
        mDismissButton.setVisibility(View.GONE);
        mScreenshotView.setVisibility(View.GONE);
        mScreenshotView.setLayerType(View.LAYER_TYPE_NONE, null);
    }
@@ -615,6 +619,17 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset
            mScreenshotView.setTranslationX(t * finalPos.x);
            mScreenshotView.setTranslationY(t * finalPos.y);
        });
        anim.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                Rect bounds = new Rect();
                mScreenshotView.getBoundsOnScreen(bounds);
                mDismissButton.setX(bounds.right - mDismissButtonSize / 2f);
                mDismissButton.setY(bounds.top - mDismissButtonSize / 2f);
                mDismissButton.setVisibility(View.VISIBLE);
            }
        });
        return anim;
    }

@@ -686,14 +701,6 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset
            mBackgroundProtection.setAlpha(t);
            mActionsContainer.setY(mDisplayMetrics.heightPixels - actionsViewHeight * t);
        });
        animator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                mScreenshotView.requestFocus();
                mScreenshotView.setElevation(50);
            }
        });
        return animator;
    }