Use correct APIs to detect conditions for round scrollbars. am: 99485ef841
am: 50bc6a1998
Change-Id: Iab07814fd54b35705a20088e29c78a56ea943eba
This commit is contained in:
@@ -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
|
* Determine if this view is rendered on a round wearable device and is the main view
|
||||||
* on the screen.
|
* on the screen.
|
||||||
*/
|
*/
|
||||||
private boolean shouldDrawRoundScrollbar() {
|
boolean shouldDrawRoundScrollbar() {
|
||||||
if (!mResources.getConfiguration().isScreenRound() || mAttachInfo == null) {
|
if (!mResources.getConfiguration().isScreenRound() || mAttachInfo == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -23927,7 +23927,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
getLocationOnScreen(mAttachInfo.mTmpLocation);
|
getLocationInWindow(mAttachInfo.mTmpLocation);
|
||||||
return mAttachInfo.mTmpLocation[0] == insets.getStableInsetLeft()
|
return mAttachInfo.mTmpLocation[0] == insets.getStableInsetLeft()
|
||||||
&& mAttachInfo.mTmpLocation[1] == insets.getStableInsetTop();
|
&& mAttachInfo.mTmpLocation[1] == insets.getStableInsetTop();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,9 +16,17 @@
|
|||||||
|
|
||||||
package android.view;
|
package android.view;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
|
import android.graphics.PixelFormat;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.test.ActivityInstrumentationTestCase2;
|
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
|
public class ViewAttachTest extends
|
||||||
ActivityInstrumentationTestCase2<ViewAttachTestActivity> {
|
ActivityInstrumentationTestCase2<ViewAttachTestActivity> {
|
||||||
@@ -51,4 +59,38 @@ public class ViewAttachTest extends
|
|||||||
SystemClock.sleep(250);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user