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

Commit 99485ef8 authored by Aga Madurska's avatar Aga Madurska
Browse files

Use correct APIs to detect conditions for round scrollbars.

Bug: 34876394

Test: Performed manually.

Change-Id: I9e690e99fd8d925c589ebd19d9c6754eeb63b1d8
parent 7b89a7b1
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -23910,7 +23910,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * Determine if this view is rendered on a round wearable device and is the main view
     * on the screen.
     */
    private boolean shouldDrawRoundScrollbar() {
    boolean shouldDrawRoundScrollbar() {
        if (!mResources.getConfiguration().isScreenRound() || mAttachInfo == null) {
            return false;
        }
@@ -23927,7 +23927,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            return false;
        }
        getLocationOnScreen(mAttachInfo.mTmpLocation);
        getLocationInWindow(mAttachInfo.mTmpLocation);
        return mAttachInfo.mTmpLocation[0] == insets.getStableInsetLeft()
                && mAttachInfo.mTmpLocation[1] == insets.getStableInsetTop();
    }
+42 −0
Original line number Diff line number Diff line
@@ -16,9 +16,17 @@

package android.view;

import android.content.Context;
import android.content.pm.ActivityInfo;
import android.graphics.PixelFormat;
import android.os.SystemClock;
import android.test.ActivityInstrumentationTestCase2;
import android.test.UiThreadTest;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;

import com.android.frameworks.coretests.R;

public class ViewAttachTest extends
        ActivityInstrumentationTestCase2<ViewAttachTestActivity> {
@@ -51,4 +59,38 @@ public class ViewAttachTest extends
            SystemClock.sleep(250);
        }
    }

    /**
     * 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 testRoundScrollbars() 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);

        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);
        }
    }
}