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

Commit f6457c82 authored by Eric Rahm's avatar Eric Rahm Committed by Android (Google) Code Review
Browse files

Merge "Updated check for round scrollbars to remove checking location at origin." into main

parents c77cf0b5 b4e35ec8
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -32104,9 +32104,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            return false;
        }
        getLocationInWindow(mAttachInfo.mTmpLocation);
        return mAttachInfo.mTmpLocation[0] == insets.getStableInsetLeft()
                && mAttachInfo.mTmpLocation[1] == insets.getStableInsetTop();
        return true;
    }
    /**
+39 −0
Original line number Diff line number Diff line
@@ -92,4 +92,43 @@ public class ViewAttachTest extends
            assertFalse(shouldDrawRoundScrollbars);
        }
    }

    /**
     * Make sure that on any attached view, if the view is full-screen and hosted
     * on a round device, the round scrollbars will be displayed even if the activity
     * window is offset.
     *
     * @throws Throwable
     */
    @UiThreadTest
    public void testRoundScrollbarsWithMargins() throws Throwable {
        final ViewAttachTestActivity activity = getActivity();
        final View rootView = activity.getWindow().getDecorView();
        final WindowManager.LayoutParams params =
                new WindowManager.LayoutParams(
                    rootView.getWidth(),
                    rootView.getHeight(),
                    50, /* xPosition */
                    0, /* yPosition */
                    WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
                    WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
                    PixelFormat.TRANSLUCENT);

        rootView.setLayoutParams(params);

        // Configure margins to make sure they don't cause issues configuring rounded scrollbars.
        final ViewGroup.MarginLayoutParams lp = new ViewGroup.MarginLayoutParams(1, 1);
        lp.setMargins(1, 2, 3, 4);
        rootView.setLayoutParams(lp);

        View contentView = activity.findViewById(R.id.view_attach_view);
        boolean shouldDrawRoundScrollbars = contentView.shouldDrawRoundScrollbar();

        if (activity.getResources().getConfiguration().isScreenRound()) {
            assertTrue(shouldDrawRoundScrollbars);
        } else {
            // Never draw round scrollbars on non-round devices.
            assertFalse(shouldDrawRoundScrollbars);
        }
    }
}