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

Commit b4e35ec8 authored by Garvit Narang's avatar Garvit Narang Committed by Eric Rahm
Browse files

Updated check for round scrollbars to remove checking location at

origin.

Bug: 216192267
Fixes: 272533831

Test: Manual Testing including flashing the watch with updated view and confirming round scrollbar for full screen view on top left corner and a full screen view starting at non origin point. Also verified that a square scrollbar is generated for a non full screen view regardless of placement.
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:812d1d8db5c79083927dba3ac41a79f015186690)

Merged-In: I9293b4d923887d6a63eacc148c18ad8e21f523f2
Change-Id: I9293b4d923887d6a63eacc148c18ad8e21f523f2
parent 5eb5b1f8
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);
        }
    }
}