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

Commit 83d455b4 authored by Miranda Kephart's avatar Miranda Kephart Committed by Automerger Merge Worker
Browse files

Merge "Update screenshot UI for dark theme" into rvc-dev am: a0397fc6

Change-Id: Ibad1a33c3b82dc35035189bc7f5ed32a5883c2b8
parents 7c98a045 a0397fc6
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -20,9 +20,9 @@
        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"/>
        android:fillColor="@color/global_screenshot_dismiss_background"
        android:pathData="M24,24m-16,0a16,16 0,1 1,32 0a16,16 0,1 1,-32 0"/>
    <path
        android:fillColor="@color/GM2_grey_500"
        android:fillColor="@color/global_screenshot_dismiss_foreground"
        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
+1 −0
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@
        android:visibility="gone"
        android:contentDescription="@string/screenshot_dismiss_ui_description">
        <ImageView
            android:id="@+id/global_screenshot_dismiss_image"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_margin="@dimen/screenshot_dismiss_button_margin"
+7 −2
Original line number Diff line number Diff line
@@ -72,9 +72,14 @@
    <color name="global_actions_alert_text">@color/GM2_red_300</color>

    <!-- Global screenshot actions -->
    <color name="global_screenshot_button_background">@color/GM2_grey_900</color>
    <color name="global_screenshot_button_background">@color/GM2_grey_800</color>
    <color name="global_screenshot_button_ripple">#42FFFFFF</color>
    <color name="global_screenshot_button_text">@color/GM2_blue_300</color>
    <color name="global_screenshot_button_text">#FFFFFF</color>
    <color name="global_screenshot_button_border">@color/GM2_grey_600</color>
    <color name="global_screenshot_button_icon">@color/GM2_blue_300</color>
    <color name="global_screenshot_dismiss_background">@color/GM2_grey_800</color>
    <color name="global_screenshot_dismiss_foreground">#FFFFFF</color>


    <!-- Biometric dialog colors -->
    <color name="biometric_dialog_gray">#ff888888</color>
+2 −0
Original line number Diff line number Diff line
@@ -198,6 +198,8 @@
    <color name="global_screenshot_button_border">@color/GM2_grey_300</color>
    <color name="global_screenshot_button_ripple">#1f000000</color>
    <color name="global_screenshot_button_icon">@color/GM2_blue_500</color>
    <color name="global_screenshot_dismiss_background">#FFFFFF</color>
    <color name="global_screenshot_dismiss_foreground">@color/GM2_grey_500</color>

    <!-- GM2 colors -->
    <color name="GM2_grey_50">#F8F9FA</color>
+41 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Insets;
@@ -184,9 +185,11 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset
    private final LinearLayout mActionsView;
    private final ImageView mBackgroundProtection;
    private final FrameLayout mDismissButton;
    private final ImageView mDismissImage;

    private Bitmap mScreenBitmap;
    private Animator mScreenshotAnimation;
    private boolean mInDarkMode = false;

    private float mScreenshotOffsetXPx;
    private float mScreenshotOffsetYPx;
@@ -250,6 +253,7 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset
            mUiEventLogger.log(ScreenshotEvent.SCREENSHOT_EXPLICIT_DISMISSAL);
            clearScreenshot("dismiss_button");
        });
        mDismissImage = mDismissButton.findViewById(R.id.global_screenshot_dismiss_image);

        mScreenshotFlash = mScreenshotLayout.findViewById(R.id.global_screenshot_flash);
        mScreenshotSelectorView = mScreenshotLayout.findViewById(R.id.global_screenshot_selector);
@@ -356,6 +360,8 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset
        mScreenBitmap.setHasAlpha(false);
        mScreenBitmap.prepareToDraw();

        updateDarkTheme();

        mWindowManager.addView(mScreenshotLayout, mWindowLayoutParams);
        mScreenshotLayout.getViewTreeObserver().addOnComputeInternalInsetsListener(this);

@@ -453,6 +459,41 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset
                mContext.getResources().getString(R.string.screenshot_preview_description));
    }

    /**
     * Update assets (called when the dark theme status changes). We only need to update the dismiss
     * button and the actions container background, since the buttons are re-inflated on demand.
     */
    private void reloadAssets() {
        mDismissImage.setImageDrawable(mContext.getDrawable(R.drawable.screenshot_cancel));
        mActionsContainer.setBackground(
                mContext.getDrawable(R.drawable.action_chip_container_background));

    }

    /**
     * Checks the current dark theme status and updates if it has changed.
     */
    private void updateDarkTheme() {
        int currentNightMode = mContext.getResources().getConfiguration().uiMode
                & Configuration.UI_MODE_NIGHT_MASK;
        switch (currentNightMode) {
            case Configuration.UI_MODE_NIGHT_NO:
                // Night mode is not active, we're using the light theme
                if (mInDarkMode) {
                    mInDarkMode = false;
                    reloadAssets();
                }
                break;
            case Configuration.UI_MODE_NIGHT_YES:
                // Night mode is active, we're using dark theme
                if (!mInDarkMode) {
                    mInDarkMode = true;
                    reloadAssets();
                }
                break;
        }
    }

    /**
     * Starts the animation after taking the screenshot
     */