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

Commit d870b880 authored by Mihai Popa's avatar Mihai Popa
Browse files

[Magnifier-27] Make it more prominent

When used on views with a dark background, the magnifier does not really
stand out from the view, which is potentially confusing for users. This
CL mixes the magnifier content with 5% white in order to make the
magnifier more prominent on dark backgrounds. Also, the CL increases the
elevation of the magnifier window, useful in light backgrounds.

Bug: 70608551
Test: manual testing
Test: atest CtsWidgetTestCases:android.widget.cts.MagnifierTest
Change-Id: I7c6e4418b49b7fe0d69344668fa66d39417b4ecc
parent 6611f83f
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.annotation.UiThread;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Outline;
import android.graphics.Paint;
import android.graphics.PixelFormat;
@@ -319,6 +320,10 @@ public final class Magnifier {
     * producing a shakiness effect for the magnifier content.
     */
    private static class InternalPopupWindow {
        // The alpha set on the magnifier's content, which defines how
        // prominent the white background is.
        private static final int CONTENT_BITMAP_ALPHA = 242;

        // Display associated to the view the magnifier is attached to.
        private final Display mDisplay;
        // The size of the content of the magnifier.
@@ -511,10 +516,13 @@ public final class Magnifier {
                final DisplayListCanvas canvas =
                        mBitmapRenderNode.start(mContentWidth, mContentHeight);
                try {
                    canvas.drawColor(Color.WHITE);

                    final Rect srcRect = new Rect(0, 0, mBitmap.getWidth(), mBitmap.getHeight());
                    final Rect dstRect = new Rect(0, 0, mContentWidth, mContentHeight);
                    final Paint paint = new Paint();
                    paint.setFilterBitmap(true);
                    paint.setAlpha(CONTENT_BITMAP_ALPHA);
                    canvas.drawBitmap(mBitmap, srcRect, dstRect, paint);
                } finally {
                    mBitmapRenderNode.end(canvas);
+1 −1
Original line number Diff line number Diff line
@@ -541,7 +541,7 @@
    <!-- Magnifier dimensions -->
    <dimen name="magnifier_width">100dp</dimen>
    <dimen name="magnifier_height">48dp</dimen>
    <dimen name="magnifier_elevation">2dp</dimen>
    <dimen name="magnifier_elevation">4dp</dimen>
    <dimen name="magnifier_offset">42dp</dimen>
    <item type="dimen" format="float" name="magnifier_zoom_scale">1.25</item>