Merge "Minor fixes based on review comments to the first CL for app startup." into androidx-master-dev
diff --git a/buildSrc/src/main/kotlin/androidx/build/PublishDocsRules.kt b/buildSrc/src/main/kotlin/androidx/build/PublishDocsRules.kt
index 2a6d0c7..40ba5e3 100644
--- a/buildSrc/src/main/kotlin/androidx/build/PublishDocsRules.kt
+++ b/buildSrc/src/main/kotlin/androidx/build/PublishDocsRules.kt
@@ -100,7 +100,7 @@
ignore(LibraryGroups.NAVIGATION.group, "navigation-dynamic-features-fragment")
ignore(LibraryGroups.NAVIGATION.group, "navigation-safe-args-generator")
ignore(LibraryGroups.NAVIGATION.group, "navigation-safe-args-gradle-plugin")
- prebuilts(LibraryGroups.NAVIGATION, "2.2.0-rc04")
+ prebuilts(LibraryGroups.NAVIGATION, "2.2.0")
ignore(LibraryGroups.PAGING.group, "paging-guava")
ignore(LibraryGroups.PAGING.group, "paging-testutils")
prebuilts(LibraryGroups.PAGING, "2.1.0")
diff --git a/buildSrc/src/main/kotlin/androidx/build/metalava/MetalavaRunner.kt b/buildSrc/src/main/kotlin/androidx/build/metalava/MetalavaRunner.kt
index 3fdf342..291ef62 100644
--- a/buildSrc/src/main/kotlin/androidx/build/metalava/MetalavaRunner.kt
+++ b/buildSrc/src/main/kotlin/androidx/build/metalava/MetalavaRunner.kt
@@ -112,7 +112,6 @@
"ExecutorRegistration",
"NotCloseable",
"UseIcu",
- "NoByteOrShort",
"SamShouldBeLast",
"MissingJvmStatic",
@@ -134,6 +133,7 @@
"AbstractInner",
"ArrayReturn",
"MethodNameTense",
+ "NoByteOrShort",
"CommonArgsFirst"
).joinToString()
)
diff --git a/camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/ImageCaptureTest.java b/camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/ImageCaptureTest.java
index 77e1c6a..9599fb8 100644
--- a/camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/ImageCaptureTest.java
+++ b/camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/ImageCaptureTest.java
@@ -72,6 +72,7 @@
import androidx.camera.testing.fakes.FakeCaptureStage;
import androidx.camera.testing.fakes.FakeLifecycleOwner;
import androidx.camera.testing.fakes.FakeUseCaseConfig;
+import androidx.concurrent.futures.ResolvableFuture;
import androidx.core.content.ContextCompat;
import androidx.core.util.Preconditions;
import androidx.test.core.app.ApplicationProvider;
@@ -100,7 +101,6 @@
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicReference;
@LargeTest
@RunWith(AndroidJUnit4.class)
@@ -189,7 +189,7 @@
}
@Test
- public void capturedImageHasCorrectSize() {
+ public void capturedImageHasCorrectSize() throws ExecutionException, InterruptedException {
ImageCapture useCase = new ImageCapture.Builder().setTargetResolution(
DEFAULT_RESOLUTION).setTargetRotation(Surface.ROTATION_0).build();
@@ -199,7 +199,7 @@
mLifecycleOwner.startAndResume();
});
- AtomicReference<ImageProperties> imageProperties = new AtomicReference<>(null);
+ ResolvableFuture<ImageProperties> imageProperties = ResolvableFuture.create();
OnImageCapturedCallback callback = createMockOnImageCapturedCallback(imageProperties);
useCase.takePicture(mMainExecutor, callback);
// Wait for the signal that the image has been captured.
@@ -224,7 +224,8 @@
}
@Test
- public void canSupportGuaranteedSize() throws CameraInfoUnavailableException {
+ public void canSupportGuaranteedSize()
+ throws CameraInfoUnavailableException, ExecutionException, InterruptedException {
// CameraSelector.LENS_FACING_FRONT/LENS_FACING_BACK are defined as constant int 0 and 1.
// Using for-loop to check both front and back device cameras can support the guaranteed
// 640x480 size.
@@ -251,7 +252,7 @@
mLifecycleOwner.startAndResume();
});
- AtomicReference<ImageProperties> imageProperties = new AtomicReference<>(null);
+ ResolvableFuture<ImageProperties> imageProperties = ResolvableFuture.create();
OnImageCapturedCallback callback = createMockOnImageCapturedCallback(imageProperties);
useCase.takePicture(mMainExecutor, callback);
// Wait for the signal that the image has been captured.
@@ -544,7 +545,8 @@
}
@Test
- public void takePicture_withBufferFormatRaw10() throws CameraAccessException {
+ public void takePicture_withBufferFormatRaw10()
+ throws CameraAccessException, ExecutionException, InterruptedException {
CameraCharacteristics cameraCharacteristics =
CameraUtil.getCameraManager().getCameraCharacteristics(mCameraId);
StreamConfigurationMap map =
@@ -564,7 +566,7 @@
mLifecycleOwner.startAndResume();
});
- AtomicReference<ImageProperties> imageProperties = new AtomicReference<>();
+ ResolvableFuture<ImageProperties> imageProperties = ResolvableFuture.create();
OnImageCapturedCallback callback = createMockOnImageCapturedCallback(imageProperties);
useCase.takePicture(mMainExecutor, callback);
// Wait for the signal that the image has been captured.
@@ -753,7 +755,7 @@
}
private OnImageCapturedCallback createMockOnImageCapturedCallback(
- @Nullable AtomicReference<ImageProperties> resultProperties) {
+ @Nullable ResolvableFuture<ImageProperties> resultProperties) {
OnImageCapturedCallback callback = mock(OnImageCapturedCallback.class);
doAnswer(
i -> {
diff --git a/camera/camera-testing/src/main/java/androidx/camera/testing/CoreAppTestUtil.java b/camera/camera-testing/src/main/java/androidx/camera/testing/CoreAppTestUtil.java
index d712f7c..18d6cda 100644
--- a/camera/camera-testing/src/main/java/androidx/camera/testing/CoreAppTestUtil.java
+++ b/camera/camera-testing/src/main/java/androidx/camera/testing/CoreAppTestUtil.java
@@ -29,6 +29,7 @@
public final class CoreAppTestUtil {
private static final int DISMISS_LOCK_SCREEN_CODE = 82;
+ private static final int MAX_TIMEOUT_MS = 3000;
private CoreAppTestUtil() {
}
@@ -67,7 +68,9 @@
UiDevice device = UiDevice.getInstance(instrumentation);
// In case the lock screen on top, the action to dismiss it.
device.pressKeyCode(DISMISS_LOCK_SCREEN_CODE);
+
device.pressHome();
+ device.waitForIdle(MAX_TIMEOUT_MS);
// Close system dialogs first to avoid interrupt.
instrumentation.getTargetContext().sendBroadcast(
diff --git a/camera/integration-tests/coretestapp/src/androidTest/java/androidx/camera/integration/core/BasicUITest.java b/camera/integration-tests/coretestapp/src/androidTest/java/androidx/camera/integration/core/BasicUITest.java
index a6f7213..ae17968 100644
--- a/camera/integration-tests/coretestapp/src/androidTest/java/androidx/camera/integration/core/BasicUITest.java
+++ b/camera/integration-tests/coretestapp/src/androidTest/java/androidx/camera/integration/core/BasicUITest.java
@@ -139,6 +139,7 @@
// Returns to Home to restart next test.
mDevice.pressHome();
+ mDevice.waitForIdle(3000);
}
}
diff --git a/camera/integration-tests/coretestapp/src/androidTest/java/androidx/camera/integration/core/ExistingActivityLifecycleTest.java b/camera/integration-tests/coretestapp/src/androidTest/java/androidx/camera/integration/core/ExistingActivityLifecycleTest.java
index bd742a8..85e3aca 100644
--- a/camera/integration-tests/coretestapp/src/androidTest/java/androidx/camera/integration/core/ExistingActivityLifecycleTest.java
+++ b/camera/integration-tests/coretestapp/src/androidTest/java/androidx/camera/integration/core/ExistingActivityLifecycleTest.java
@@ -41,9 +41,7 @@
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.rule.ActivityTestRule;
import androidx.test.rule.GrantPermissionRule;
-import androidx.test.uiautomator.By;
import androidx.test.uiautomator.UiDevice;
-import androidx.test.uiautomator.Until;
import org.junit.After;
import org.junit.Assert;
@@ -202,12 +200,12 @@
private void pressHomeButton() {
mDevice.pressHome();
- mDevice.wait(Until.hasObject(By.pkg(mLauncherPackageName).depth(0)), LAUNCH_TIMEOUT_MS);
+ mDevice.waitForIdle(LAUNCH_TIMEOUT_MS);
}
private void pressBackButton() {
mDevice.pressBack();
- mDevice.wait(Until.hasObject(By.pkg(mLauncherPackageName).depth(0)), LAUNCH_TIMEOUT_MS);
+ mDevice.waitForIdle(LAUNCH_TIMEOUT_MS);
}
diff --git a/camera/integration-tests/coretestapp/src/androidTest/java/androidx/camera/integration/core/NewActivityLifecycleTest.java b/camera/integration-tests/coretestapp/src/androidTest/java/androidx/camera/integration/core/NewActivityLifecycleTest.java
index 1d2a122..4a8ea1e 100644
--- a/camera/integration-tests/coretestapp/src/androidTest/java/androidx/camera/integration/core/NewActivityLifecycleTest.java
+++ b/camera/integration-tests/coretestapp/src/androidTest/java/androidx/camera/integration/core/NewActivityLifecycleTest.java
@@ -38,9 +38,7 @@
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.rule.ActivityTestRule;
import androidx.test.rule.GrantPermissionRule;
-import androidx.test.uiautomator.By;
import androidx.test.uiautomator.UiDevice;
-import androidx.test.uiautomator.Until;
import org.junit.After;
import org.junit.Before;
@@ -129,7 +127,7 @@
private void pressHomeButton() {
mDevice.pressHome();
- mDevice.wait(Until.hasObject(By.pkg(mLauncherPackageName).depth(0)), LAUNCH_TIMEOUT_MS);
+ mDevice.waitForIdle(LAUNCH_TIMEOUT_MS);
}
}
diff --git a/camera/integration-tests/coretestapp/src/androidTest/java/androidx/camera/integration/core/TakePictureTest.kt b/camera/integration-tests/coretestapp/src/androidTest/java/androidx/camera/integration/core/TakePictureTest.kt
index 2dc09d7..5729097 100644
--- a/camera/integration-tests/coretestapp/src/androidTest/java/androidx/camera/integration/core/TakePictureTest.kt
+++ b/camera/integration-tests/coretestapp/src/androidTest/java/androidx/camera/integration/core/TakePictureTest.kt
@@ -102,6 +102,7 @@
// Returns to Home to restart next test.
mDevice.pressHome()
+ mDevice.waitForIdle(3000)
}
private fun checkPreviewReady() {
diff --git a/camera/integration-tests/coretestapp/src/androidTest/java/androidx/camera/integration/core/ToggleButtonUITest.java b/camera/integration-tests/coretestapp/src/androidTest/java/androidx/camera/integration/core/ToggleButtonUITest.java
index 5389e96..6b84139 100644
--- a/camera/integration-tests/coretestapp/src/androidTest/java/androidx/camera/integration/core/ToggleButtonUITest.java
+++ b/camera/integration-tests/coretestapp/src/androidTest/java/androidx/camera/integration/core/ToggleButtonUITest.java
@@ -48,9 +48,7 @@
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.rule.ActivityTestRule;
import androidx.test.rule.GrantPermissionRule;
-import androidx.test.uiautomator.By;
import androidx.test.uiautomator.UiDevice;
-import androidx.test.uiautomator.Until;
import junit.framework.AssertionFailedError;
@@ -70,7 +68,6 @@
private final UiDevice mDevice =
UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
- private final String mLauncherPackageName = mDevice.getLauncherPackageName();
private final Intent mIntent = ApplicationProvider.getApplicationContext().getPackageManager()
.getLaunchIntentForPackage(BASIC_SAMPLE_PACKAGE);
@@ -109,8 +106,14 @@
@After
public void tearDown() {
- pressBackAndReturnHome();
+ // Idles Espresso thread and make activity complete each action.
+ waitFor(new ElapsedTimeIdlingResource(IDLE_TIMEOUT_MS));
+
mActivityRule.finishActivity();
+
+ // Returns to Home to restart next test.
+ mDevice.pressHome();
+ mDevice.waitForIdle(IDLE_TIMEOUT_MS);
}
@Test
@@ -136,8 +139,6 @@
// The mode3 should be different from first and second time.
assertNotEquals(mode3, mode2);
assertNotEquals(mode3, mode1);
-
- waitForIdlingRegistryAndPressBackAndHomeButton();
}
@Test
@@ -155,8 +156,6 @@
// By pressing the torch toggle button two times, it should switch back to original state.
onView(withId(R.id.torch_toggle)).perform(click());
assertEquals(isTorchOn(cameraInfo), isTorchOn);
-
- waitForIdlingRegistryAndPressBackAndHomeButton();
}
@Test
@@ -185,32 +184,12 @@
assertNotNull(mActivityRule.getActivity().getPreview());
}
}
-
- waitForIdlingRegistryAndPressBackAndHomeButton();
- }
-
- private void waitForIdlingRegistryAndPressBackAndHomeButton() {
- // Idles Espresso thread and make activity complete each action.
- waitFor(new ElapsedTimeIdlingResource(IDLE_TIMEOUT_MS));
-
- mDevice.pressBack();
-
- // Returns to Home to restart next test.
- mDevice.pressHome();
- mDevice.wait(Until.hasObject(By.pkg(mLauncherPackageName).depth(0)), IDLE_TIMEOUT_MS);
}
private boolean isTorchOn(CameraInfo cameraInfo) {
return cameraInfo.getTorchState().getValue() == TorchState.ON;
}
- private void pressBackAndReturnHome() {
- mDevice.pressBack();
-
- // Returns to Home to restart next test.
- mDevice.pressHome();
- }
-
private boolean detectButtonVisibility(int resource) {
try {
onView(withId(resource)).check(matches(isDisplayed()));
diff --git a/camera/integration-tests/viewtestapp/src/androidTest/java/androidx/camera/integration/view/PreviewViewAppPreviewUpdateTest.java b/camera/integration-tests/viewtestapp/src/androidTest/java/androidx/camera/integration/view/PreviewViewAppPreviewUpdateTest.java
index 7c0169b..5a6749f 100644
--- a/camera/integration-tests/viewtestapp/src/androidTest/java/androidx/camera/integration/view/PreviewViewAppPreviewUpdateTest.java
+++ b/camera/integration-tests/viewtestapp/src/androidTest/java/androidx/camera/integration/view/PreviewViewAppPreviewUpdateTest.java
@@ -47,6 +47,7 @@
@LargeTest
public final class PreviewViewAppPreviewUpdateTest {
private static final int WAIT_TIMEOUT = 10000;
+ private static final int MAX_TIMEOUT_MS = 3000;
private final UiDevice mDevice = UiDevice.getInstance(getInstrumentation());
private Intent mIntent =
new Intent("androidx.camera.integration.view.action.PREVIEWVIEWAPP");
@@ -137,9 +138,11 @@
private void pressHomeButton() {
mDevice.pressHome();
+ mDevice.waitForIdle(MAX_TIMEOUT_MS);
}
private void pressBackButton() {
mDevice.pressBack();
+ mDevice.waitForIdle(MAX_TIMEOUT_MS);
}
}
diff --git a/core/core-ktx/api/api_lint.ignore b/core/core-ktx/api/api_lint.ignore
index f510d88..de50ebe 100644
--- a/core/core-ktx/api/api_lint.ignore
+++ b/core/core-ktx/api/api_lint.ignore
@@ -31,6 +31,10 @@
Method ViewGroupKt.iterator appears to be throwing java.lang.IndexOutOfBoundsException; this should be listed in the documentation; see https://android.github.io/kotlin-guides/interop.html#document-exceptions
+NoByteOrShort: androidx.core.util.HalfKt#toHalf(short) parameter #0:
+ Should avoid odd sized primitives; use `int` instead of `short` in parameter $this$toHalf in androidx.core.util.HalfKt.toHalf(short $this$toHalf)
+
+
PairedRegistration: androidx.core.animation.AnimatorKt#addListener(android.animation.Animator, kotlin.jvm.functions.Function1<? super android.animation.Animator,kotlin.Unit>, kotlin.jvm.functions.Function1<? super android.animation.Animator,kotlin.Unit>, kotlin.jvm.functions.Function1<? super android.animation.Animator,kotlin.Unit>, kotlin.jvm.functions.Function1<? super android.animation.Animator,kotlin.Unit>):
Found addListener but not removeListener in androidx.core.animation.AnimatorKt
PairedRegistration: androidx.core.animation.AnimatorKt#addPauseListener(android.animation.Animator, kotlin.jvm.functions.Function1<? super android.animation.Animator,kotlin.Unit>, kotlin.jvm.functions.Function1<? super android.animation.Animator,kotlin.Unit>):
diff --git a/exifinterface/exifinterface/api/api_lint.ignore b/exifinterface/exifinterface/api/api_lint.ignore
index 0e7bfcf..d22dffd 100644
--- a/exifinterface/exifinterface/api/api_lint.ignore
+++ b/exifinterface/exifinterface/api/api_lint.ignore
@@ -11,5 +11,219 @@
Missing nullability on parameter `location` in method `setGpsInfo`
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#ALTITUDE_ABOVE_SEA_LEVEL:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.ALTITUDE_ABOVE_SEA_LEVEL
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#ALTITUDE_BELOW_SEA_LEVEL:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.ALTITUDE_BELOW_SEA_LEVEL
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#CONTRAST_HARD:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.CONTRAST_HARD
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#CONTRAST_NORMAL:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.CONTRAST_NORMAL
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#CONTRAST_SOFT:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.CONTRAST_SOFT
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#EXPOSURE_MODE_AUTO:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.EXPOSURE_MODE_AUTO
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#EXPOSURE_MODE_AUTO_BRACKET:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.EXPOSURE_MODE_AUTO_BRACKET
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#EXPOSURE_MODE_MANUAL:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.EXPOSURE_MODE_MANUAL
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#EXPOSURE_PROGRAM_ACTION:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.EXPOSURE_PROGRAM_ACTION
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#EXPOSURE_PROGRAM_APERTURE_PRIORITY:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.EXPOSURE_PROGRAM_APERTURE_PRIORITY
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#EXPOSURE_PROGRAM_CREATIVE:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.EXPOSURE_PROGRAM_CREATIVE
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#EXPOSURE_PROGRAM_LANDSCAPE_MODE:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.EXPOSURE_PROGRAM_LANDSCAPE_MODE
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#EXPOSURE_PROGRAM_MANUAL:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.EXPOSURE_PROGRAM_MANUAL
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#EXPOSURE_PROGRAM_NORMAL:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.EXPOSURE_PROGRAM_NORMAL
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#EXPOSURE_PROGRAM_NOT_DEFINED:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.EXPOSURE_PROGRAM_NOT_DEFINED
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#EXPOSURE_PROGRAM_PORTRAIT_MODE:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.EXPOSURE_PROGRAM_PORTRAIT_MODE
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#EXPOSURE_PROGRAM_SHUTTER_PRIORITY:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.EXPOSURE_PROGRAM_SHUTTER_PRIORITY
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#FILE_SOURCE_DSC:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.FILE_SOURCE_DSC
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#FILE_SOURCE_OTHER:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.FILE_SOURCE_OTHER
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#FILE_SOURCE_REFLEX_SCANNER:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.FILE_SOURCE_REFLEX_SCANNER
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#FILE_SOURCE_TRANSPARENT_SCANNER:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.FILE_SOURCE_TRANSPARENT_SCANNER
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#FLAG_FLASH_FIRED:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.FLAG_FLASH_FIRED
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#FLAG_FLASH_MODE_AUTO:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.FLAG_FLASH_MODE_AUTO
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#FLAG_FLASH_MODE_COMPULSORY_FIRING:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.FLAG_FLASH_MODE_COMPULSORY_FIRING
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#FLAG_FLASH_MODE_COMPULSORY_SUPPRESSION:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.FLAG_FLASH_MODE_COMPULSORY_SUPPRESSION
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#FLAG_FLASH_NO_FLASH_FUNCTION:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.FLAG_FLASH_NO_FLASH_FUNCTION
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#FLAG_FLASH_RED_EYE_SUPPORTED:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.FLAG_FLASH_RED_EYE_SUPPORTED
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#FLAG_FLASH_RETURN_LIGHT_DETECTED:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.FLAG_FLASH_RETURN_LIGHT_DETECTED
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#FLAG_FLASH_RETURN_LIGHT_NOT_DETECTED:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.FLAG_FLASH_RETURN_LIGHT_NOT_DETECTED
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#FORMAT_CHUNKY:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.FORMAT_CHUNKY
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#FORMAT_PLANAR:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.FORMAT_PLANAR
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#GAIN_CONTROL_HIGH_GAIN_DOWN:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.GAIN_CONTROL_HIGH_GAIN_DOWN
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#GAIN_CONTROL_HIGH_GAIN_UP:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.GAIN_CONTROL_HIGH_GAIN_UP
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#GAIN_CONTROL_LOW_GAIN_DOWN:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.GAIN_CONTROL_LOW_GAIN_DOWN
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#GAIN_CONTROL_LOW_GAIN_UP:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.GAIN_CONTROL_LOW_GAIN_UP
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#GAIN_CONTROL_NONE:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.GAIN_CONTROL_NONE
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#GPS_MEASUREMENT_DIFFERENTIAL_CORRECTED:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.GPS_MEASUREMENT_DIFFERENTIAL_CORRECTED
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#GPS_MEASUREMENT_NO_DIFFERENTIAL:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.GPS_MEASUREMENT_NO_DIFFERENTIAL
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#LIGHT_SOURCE_CLOUDY_WEATHER:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.LIGHT_SOURCE_CLOUDY_WEATHER
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#LIGHT_SOURCE_COOL_WHITE_FLUORESCENT:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.LIGHT_SOURCE_COOL_WHITE_FLUORESCENT
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#LIGHT_SOURCE_D50:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.LIGHT_SOURCE_D50
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#LIGHT_SOURCE_D55:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.LIGHT_SOURCE_D55
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#LIGHT_SOURCE_D65:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.LIGHT_SOURCE_D65
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#LIGHT_SOURCE_D75:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.LIGHT_SOURCE_D75
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#LIGHT_SOURCE_DAYLIGHT:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.LIGHT_SOURCE_DAYLIGHT
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#LIGHT_SOURCE_DAYLIGHT_FLUORESCENT:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.LIGHT_SOURCE_DAYLIGHT_FLUORESCENT
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#LIGHT_SOURCE_DAY_WHITE_FLUORESCENT:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.LIGHT_SOURCE_DAY_WHITE_FLUORESCENT
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#LIGHT_SOURCE_FINE_WEATHER:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.LIGHT_SOURCE_FINE_WEATHER
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#LIGHT_SOURCE_FLASH:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.LIGHT_SOURCE_FLASH
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#LIGHT_SOURCE_FLUORESCENT:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.LIGHT_SOURCE_FLUORESCENT
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#LIGHT_SOURCE_ISO_STUDIO_TUNGSTEN:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.LIGHT_SOURCE_ISO_STUDIO_TUNGSTEN
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#LIGHT_SOURCE_OTHER:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.LIGHT_SOURCE_OTHER
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#LIGHT_SOURCE_SHADE:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.LIGHT_SOURCE_SHADE
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#LIGHT_SOURCE_STANDARD_LIGHT_A:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.LIGHT_SOURCE_STANDARD_LIGHT_A
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#LIGHT_SOURCE_STANDARD_LIGHT_B:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.LIGHT_SOURCE_STANDARD_LIGHT_B
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#LIGHT_SOURCE_STANDARD_LIGHT_C:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.LIGHT_SOURCE_STANDARD_LIGHT_C
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#LIGHT_SOURCE_TUNGSTEN:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.LIGHT_SOURCE_TUNGSTEN
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#LIGHT_SOURCE_UNKNOWN:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.LIGHT_SOURCE_UNKNOWN
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#LIGHT_SOURCE_WARM_WHITE_FLUORESCENT:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.LIGHT_SOURCE_WARM_WHITE_FLUORESCENT
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#LIGHT_SOURCE_WHITE_FLUORESCENT:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.LIGHT_SOURCE_WHITE_FLUORESCENT
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#METERING_MODE_AVERAGE:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.METERING_MODE_AVERAGE
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#METERING_MODE_CENTER_WEIGHT_AVERAGE:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.METERING_MODE_CENTER_WEIGHT_AVERAGE
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#METERING_MODE_MULTI_SPOT:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.METERING_MODE_MULTI_SPOT
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#METERING_MODE_OTHER:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.METERING_MODE_OTHER
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#METERING_MODE_PARTIAL:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.METERING_MODE_PARTIAL
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#METERING_MODE_PATTERN:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.METERING_MODE_PATTERN
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#METERING_MODE_SPOT:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.METERING_MODE_SPOT
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#METERING_MODE_UNKNOWN:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.METERING_MODE_UNKNOWN
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#RENDERED_PROCESS_CUSTOM:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.RENDERED_PROCESS_CUSTOM
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#RENDERED_PROCESS_NORMAL:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.RENDERED_PROCESS_NORMAL
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#RESOLUTION_UNIT_CENTIMETERS:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.RESOLUTION_UNIT_CENTIMETERS
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#RESOLUTION_UNIT_INCHES:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.RESOLUTION_UNIT_INCHES
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#SATURATION_HIGH:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.SATURATION_HIGH
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#SATURATION_LOW:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.SATURATION_LOW
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#SATURATION_NORMAL:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.SATURATION_NORMAL
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#SCENE_CAPTURE_TYPE_LANDSCAPE:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.SCENE_CAPTURE_TYPE_LANDSCAPE
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#SCENE_CAPTURE_TYPE_NIGHT:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.SCENE_CAPTURE_TYPE_NIGHT
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#SCENE_CAPTURE_TYPE_PORTRAIT:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.SCENE_CAPTURE_TYPE_PORTRAIT
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#SCENE_CAPTURE_TYPE_STANDARD:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.SCENE_CAPTURE_TYPE_STANDARD
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#SCENE_TYPE_DIRECTLY_PHOTOGRAPHED:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.SCENE_TYPE_DIRECTLY_PHOTOGRAPHED
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#SENSITIVITY_TYPE_ISO_SPEED:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.SENSITIVITY_TYPE_ISO_SPEED
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#SENSITIVITY_TYPE_REI:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.SENSITIVITY_TYPE_REI
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#SENSITIVITY_TYPE_REI_AND_ISO:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.SENSITIVITY_TYPE_REI_AND_ISO
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#SENSITIVITY_TYPE_SOS:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.SENSITIVITY_TYPE_SOS
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#SENSITIVITY_TYPE_SOS_AND_ISO:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.SENSITIVITY_TYPE_SOS_AND_ISO
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#SENSITIVITY_TYPE_SOS_AND_REI:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.SENSITIVITY_TYPE_SOS_AND_REI
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#SENSITIVITY_TYPE_SOS_AND_REI_AND_ISO:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.SENSITIVITY_TYPE_SOS_AND_REI_AND_ISO
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#SENSITIVITY_TYPE_UNKNOWN:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.SENSITIVITY_TYPE_UNKNOWN
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#SENSOR_TYPE_COLOR_SEQUENTIAL:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.SENSOR_TYPE_COLOR_SEQUENTIAL
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#SENSOR_TYPE_COLOR_SEQUENTIAL_LINEAR:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.SENSOR_TYPE_COLOR_SEQUENTIAL_LINEAR
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#SENSOR_TYPE_NOT_DEFINED:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.SENSOR_TYPE_NOT_DEFINED
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#SENSOR_TYPE_ONE_CHIP:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.SENSOR_TYPE_ONE_CHIP
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#SENSOR_TYPE_THREE_CHIP:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.SENSOR_TYPE_THREE_CHIP
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#SENSOR_TYPE_TRILINEAR:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.SENSOR_TYPE_TRILINEAR
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#SENSOR_TYPE_TWO_CHIP:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.SENSOR_TYPE_TWO_CHIP
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#SHARPNESS_HARD:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.SHARPNESS_HARD
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#SHARPNESS_NORMAL:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.SHARPNESS_NORMAL
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#SHARPNESS_SOFT:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.SHARPNESS_SOFT
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#SUBJECT_DISTANCE_RANGE_CLOSE_VIEW:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.SUBJECT_DISTANCE_RANGE_CLOSE_VIEW
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#SUBJECT_DISTANCE_RANGE_DISTANT_VIEW:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.SUBJECT_DISTANCE_RANGE_DISTANT_VIEW
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#SUBJECT_DISTANCE_RANGE_MACRO:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.SUBJECT_DISTANCE_RANGE_MACRO
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#SUBJECT_DISTANCE_RANGE_UNKNOWN:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.SUBJECT_DISTANCE_RANGE_UNKNOWN
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#WHITE_BALANCE_AUTO:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.WHITE_BALANCE_AUTO
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#WHITE_BALANCE_MANUAL:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.WHITE_BALANCE_MANUAL
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#Y_CB_CR_POSITIONING_CENTERED:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.Y_CB_CR_POSITIONING_CENTERED
+NoByteOrShort: androidx.exifinterface.media.ExifInterface#Y_CB_CR_POSITIONING_CO_SITED:
+ Should avoid odd sized primitives; use `int` instead of `short` in field androidx.exifinterface.media.ExifInterface.Y_CB_CR_POSITIONING_CO_SITED
+
+
UseParcelFileDescriptor: androidx.exifinterface.media.ExifInterface#ExifInterface(java.io.FileDescriptor) parameter #0:
Must use ParcelFileDescriptor instead of FileDescriptor in parameter fileDescriptor in androidx.exifinterface.media.ExifInterface(java.io.FileDescriptor fileDescriptor)
diff --git a/jetifier/jetifier/processor/src/main/kotlin/com/android/tools/build/jetifier/processor/transform/metainf/MetaInfTransformer.kt b/jetifier/jetifier/processor/src/main/kotlin/com/android/tools/build/jetifier/processor/transform/metainf/MetaInfTransformer.kt
index 82c658e..52d934a 100644
--- a/jetifier/jetifier/processor/src/main/kotlin/com/android/tools/build/jetifier/processor/transform/metainf/MetaInfTransformer.kt
+++ b/jetifier/jetifier/processor/src/main/kotlin/com/android/tools/build/jetifier/processor/transform/metainf/MetaInfTransformer.kt
@@ -43,7 +43,8 @@
"androidx.activity_activity-ktx.version",
"androidx.lifecycle_lifecycle-runtime-ktx.version",
"androidx.dynamicanimation_dynamicanimation-ktx.version",
- "androidx.annotation_annotation-experimental.version"
+ "androidx.annotation_annotation-experimental.version",
+ "androidx.navigation_navigation-testing.version"
)
}
diff --git a/media2/widget/src/androidTest/java/androidx/media2/widget/VideoView_WithPlayerTest.java b/media2/widget/src/androidTest/java/androidx/media2/widget/VideoView_WithPlayerTest.java
index f074256..a4ac0ca 100644
--- a/media2/widget/src/androidTest/java/androidx/media2/widget/VideoView_WithPlayerTest.java
+++ b/media2/widget/src/androidTest/java/androidx/media2/widget/VideoView_WithPlayerTest.java
@@ -152,7 +152,9 @@
public void testPlayVideoOnTextureView() throws Throwable {
final VideoView.OnViewTypeChangedListener mockViewTypeListener =
mock(VideoView.OnViewTypeChangedListener.class);
-
+ if (setViewTypeMayCrash()) {
+ return;
+ }
DefaultPlayerCallback callback = new DefaultPlayerCallback();
PlayerWrapper playerWrapper = createPlayerWrapper(callback, mMediaItem, null);
setPlayerWrapper(playerWrapper);
@@ -181,6 +183,9 @@
public void testPlayVideoWithVisibilityChange() throws Throwable {
final VideoView.OnViewTypeChangedListener mockViewTypeListener =
mock(VideoView.OnViewTypeChangedListener.class);
+ if (setViewTypeMayCrash()) {
+ return;
+ }
DefaultPlayerCallback callback = new DefaultPlayerCallback();
PlayerWrapper playerWrapper = createPlayerWrapper(callback, mMediaItem, null);
@@ -240,6 +245,9 @@
@Test
public void testSetViewType() throws Throwable {
+ if (setViewTypeMayCrash()) {
+ return;
+ }
final VideoView.OnViewTypeChangedListener mockViewTypeListener =
mock(VideoView.OnViewTypeChangedListener.class);
@@ -415,6 +423,15 @@
}
}
+ private boolean setViewTypeMayCrash() {
+ // TODO(b/143496920): Remove this method which is a guard to avoid crash.
+ // Need to skip the tests, which call VV#setViewType(), on the emulator with API 26.
+ if (Build.DEVICE.startsWith("generic_") && Build.VERSION.SDK_INT == 26) {
+ return true;
+ }
+ return false;
+ }
+
private Bitmap getVideoScreenshot() {
Bitmap bitmap = Bitmap.createBitmap(mVideoView.getWidth(),
mVideoView.getHeight(), Bitmap.Config.RGB_565);
diff --git a/navigation/navigation-testing/build.gradle b/navigation/navigation-testing/build.gradle
index 7345623..547d928 100644
--- a/navigation/navigation-testing/build.gradle
+++ b/navigation/navigation-testing/build.gradle
@@ -47,7 +47,7 @@
androidx {
name = "Android Navigation Testing"
- publish = Publish.NONE
+ publish = Publish.SNAPSHOT_AND_RELEASE
mavenVersion = LibraryVersions.NAVIGATION
mavenGroup = LibraryGroups.NAVIGATION
inceptionYear = "2017"
diff --git a/paging/common/api/restricted_3.0.0-alpha01.txt b/paging/common/api/restricted_3.0.0-alpha01.txt
index c0968a0..a435181 100644
--- a/paging/common/api/restricted_3.0.0-alpha01.txt
+++ b/paging/common/api/restricted_3.0.0-alpha01.txt
@@ -72,11 +72,6 @@
field public final int requestedLoadSize;
}
- @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP) public final class LegacyPagingSource<Key, Value> extends androidx.paging.PagingSource<Key,Value> {
- ctor public LegacyPagingSource(internal androidx.paging.DataSource<Key,Value> dataSource, kotlinx.coroutines.CoroutineDispatcher fetchDispatcher);
- method public suspend Object load(androidx.paging.PagingSource.LoadParams<Key> params, kotlin.coroutines.Continuation<? super androidx.paging.PagingSource.LoadResult<Key,Value>> p);
- }
-
public abstract sealed class LoadState {
}
diff --git a/paging/common/api/restricted_current.txt b/paging/common/api/restricted_current.txt
index c0968a0..a435181 100644
--- a/paging/common/api/restricted_current.txt
+++ b/paging/common/api/restricted_current.txt
@@ -72,11 +72,6 @@
field public final int requestedLoadSize;
}
- @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP) public final class LegacyPagingSource<Key, Value> extends androidx.paging.PagingSource<Key,Value> {
- ctor public LegacyPagingSource(internal androidx.paging.DataSource<Key,Value> dataSource, kotlinx.coroutines.CoroutineDispatcher fetchDispatcher);
- method public suspend Object load(androidx.paging.PagingSource.LoadParams<Key> params, kotlin.coroutines.Continuation<? super androidx.paging.PagingSource.LoadResult<Key,Value>> p);
- }
-
public abstract sealed class LoadState {
}
diff --git a/paging/common/src/main/kotlin/androidx/paging/LegacyPagingSource.kt b/paging/common/src/main/kotlin/androidx/paging/LegacyPagingSource.kt
index 6822e14..af0cd01 100644
--- a/paging/common/src/main/kotlin/androidx/paging/LegacyPagingSource.kt
+++ b/paging/common/src/main/kotlin/androidx/paging/LegacyPagingSource.kt
@@ -16,7 +16,6 @@
package androidx.paging
-import androidx.annotation.RestrictTo
import androidx.paging.DataSource.KeyType.ITEM_KEYED
import androidx.paging.DataSource.KeyType.PAGE_KEYED
import androidx.paging.DataSource.KeyType.POSITIONAL
@@ -26,11 +25,8 @@
/**
* A wrapper around [DataSource] which adapts it to the [PagingSource] API.
- *
- * @hide
*/
-@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
-class LegacyPagingSource<Key : Any, Value : Any>(
+internal class LegacyPagingSource<Key : Any, Value : Any>(
internal val dataSource: DataSource<Key, Value>,
private val fetchDispatcher: CoroutineDispatcher = DirectDispatcher
) : PagingSource<Key, Value>() {
diff --git a/paging/runtime/api/3.0.0-alpha01.txt b/paging/runtime/api/3.0.0-alpha01.txt
index c38b03f..34eeffe 100644
--- a/paging/runtime/api/3.0.0-alpha01.txt
+++ b/paging/runtime/api/3.0.0-alpha01.txt
@@ -57,6 +57,11 @@
method public static <Key, Value> androidx.lifecycle.LiveData<androidx.paging.PagedList<Value>> toLiveData(kotlin.jvm.functions.Function0<? extends androidx.paging.PagingSource<Key,Value>>, int pageSize, Key? initialLoadKey = null, androidx.paging.PagedList.BoundaryCallback<Value>? boundaryCallback = null, kotlinx.coroutines.CoroutineScope coroutineScope = GlobalScope, kotlinx.coroutines.CoroutineDispatcher fetchDispatcher = Dispatchers.IO);
}
+ public final class LivePagingData {
+ method public static <Key, Value> androidx.lifecycle.LiveData<androidx.paging.PagingData<Value>> create(androidx.paging.PagingConfig config, Key? initialKey, kotlin.jvm.functions.Function0<? extends androidx.paging.PagingSource<Key,Value>> pagingSourceFactory);
+ method public static <Key, Value> androidx.lifecycle.LiveData<androidx.paging.PagingData<Value>> create(androidx.paging.PagingConfig config, kotlin.jvm.functions.Function0<? extends androidx.paging.PagingSource<Key,Value>> pagingSourceFactory);
+ }
+
public final class NullPaddedListDiffHelperKt {
}
diff --git a/paging/runtime/api/current.txt b/paging/runtime/api/current.txt
index c38b03f..34eeffe 100644
--- a/paging/runtime/api/current.txt
+++ b/paging/runtime/api/current.txt
@@ -57,6 +57,11 @@
method public static <Key, Value> androidx.lifecycle.LiveData<androidx.paging.PagedList<Value>> toLiveData(kotlin.jvm.functions.Function0<? extends androidx.paging.PagingSource<Key,Value>>, int pageSize, Key? initialLoadKey = null, androidx.paging.PagedList.BoundaryCallback<Value>? boundaryCallback = null, kotlinx.coroutines.CoroutineScope coroutineScope = GlobalScope, kotlinx.coroutines.CoroutineDispatcher fetchDispatcher = Dispatchers.IO);
}
+ public final class LivePagingData {
+ method public static <Key, Value> androidx.lifecycle.LiveData<androidx.paging.PagingData<Value>> create(androidx.paging.PagingConfig config, Key? initialKey, kotlin.jvm.functions.Function0<? extends androidx.paging.PagingSource<Key,Value>> pagingSourceFactory);
+ method public static <Key, Value> androidx.lifecycle.LiveData<androidx.paging.PagingData<Value>> create(androidx.paging.PagingConfig config, kotlin.jvm.functions.Function0<? extends androidx.paging.PagingSource<Key,Value>> pagingSourceFactory);
+ }
+
public final class NullPaddedListDiffHelperKt {
}
diff --git a/paging/runtime/api/public_plus_experimental_3.0.0-alpha01.txt b/paging/runtime/api/public_plus_experimental_3.0.0-alpha01.txt
index c38b03f..34eeffe 100644
--- a/paging/runtime/api/public_plus_experimental_3.0.0-alpha01.txt
+++ b/paging/runtime/api/public_plus_experimental_3.0.0-alpha01.txt
@@ -57,6 +57,11 @@
method public static <Key, Value> androidx.lifecycle.LiveData<androidx.paging.PagedList<Value>> toLiveData(kotlin.jvm.functions.Function0<? extends androidx.paging.PagingSource<Key,Value>>, int pageSize, Key? initialLoadKey = null, androidx.paging.PagedList.BoundaryCallback<Value>? boundaryCallback = null, kotlinx.coroutines.CoroutineScope coroutineScope = GlobalScope, kotlinx.coroutines.CoroutineDispatcher fetchDispatcher = Dispatchers.IO);
}
+ public final class LivePagingData {
+ method public static <Key, Value> androidx.lifecycle.LiveData<androidx.paging.PagingData<Value>> create(androidx.paging.PagingConfig config, Key? initialKey, kotlin.jvm.functions.Function0<? extends androidx.paging.PagingSource<Key,Value>> pagingSourceFactory);
+ method public static <Key, Value> androidx.lifecycle.LiveData<androidx.paging.PagingData<Value>> create(androidx.paging.PagingConfig config, kotlin.jvm.functions.Function0<? extends androidx.paging.PagingSource<Key,Value>> pagingSourceFactory);
+ }
+
public final class NullPaddedListDiffHelperKt {
}
diff --git a/paging/runtime/api/public_plus_experimental_current.txt b/paging/runtime/api/public_plus_experimental_current.txt
index c38b03f..34eeffe 100644
--- a/paging/runtime/api/public_plus_experimental_current.txt
+++ b/paging/runtime/api/public_plus_experimental_current.txt
@@ -57,6 +57,11 @@
method public static <Key, Value> androidx.lifecycle.LiveData<androidx.paging.PagedList<Value>> toLiveData(kotlin.jvm.functions.Function0<? extends androidx.paging.PagingSource<Key,Value>>, int pageSize, Key? initialLoadKey = null, androidx.paging.PagedList.BoundaryCallback<Value>? boundaryCallback = null, kotlinx.coroutines.CoroutineScope coroutineScope = GlobalScope, kotlinx.coroutines.CoroutineDispatcher fetchDispatcher = Dispatchers.IO);
}
+ public final class LivePagingData {
+ method public static <Key, Value> androidx.lifecycle.LiveData<androidx.paging.PagingData<Value>> create(androidx.paging.PagingConfig config, Key? initialKey, kotlin.jvm.functions.Function0<? extends androidx.paging.PagingSource<Key,Value>> pagingSourceFactory);
+ method public static <Key, Value> androidx.lifecycle.LiveData<androidx.paging.PagingData<Value>> create(androidx.paging.PagingConfig config, kotlin.jvm.functions.Function0<? extends androidx.paging.PagingSource<Key,Value>> pagingSourceFactory);
+ }
+
public final class NullPaddedListDiffHelperKt {
}
diff --git a/paging/runtime/api/restricted_3.0.0-alpha01.txt b/paging/runtime/api/restricted_3.0.0-alpha01.txt
index c38b03f..34eeffe 100644
--- a/paging/runtime/api/restricted_3.0.0-alpha01.txt
+++ b/paging/runtime/api/restricted_3.0.0-alpha01.txt
@@ -57,6 +57,11 @@
method public static <Key, Value> androidx.lifecycle.LiveData<androidx.paging.PagedList<Value>> toLiveData(kotlin.jvm.functions.Function0<? extends androidx.paging.PagingSource<Key,Value>>, int pageSize, Key? initialLoadKey = null, androidx.paging.PagedList.BoundaryCallback<Value>? boundaryCallback = null, kotlinx.coroutines.CoroutineScope coroutineScope = GlobalScope, kotlinx.coroutines.CoroutineDispatcher fetchDispatcher = Dispatchers.IO);
}
+ public final class LivePagingData {
+ method public static <Key, Value> androidx.lifecycle.LiveData<androidx.paging.PagingData<Value>> create(androidx.paging.PagingConfig config, Key? initialKey, kotlin.jvm.functions.Function0<? extends androidx.paging.PagingSource<Key,Value>> pagingSourceFactory);
+ method public static <Key, Value> androidx.lifecycle.LiveData<androidx.paging.PagingData<Value>> create(androidx.paging.PagingConfig config, kotlin.jvm.functions.Function0<? extends androidx.paging.PagingSource<Key,Value>> pagingSourceFactory);
+ }
+
public final class NullPaddedListDiffHelperKt {
}
diff --git a/paging/runtime/api/restricted_current.txt b/paging/runtime/api/restricted_current.txt
index c38b03f..34eeffe 100644
--- a/paging/runtime/api/restricted_current.txt
+++ b/paging/runtime/api/restricted_current.txt
@@ -57,6 +57,11 @@
method public static <Key, Value> androidx.lifecycle.LiveData<androidx.paging.PagedList<Value>> toLiveData(kotlin.jvm.functions.Function0<? extends androidx.paging.PagingSource<Key,Value>>, int pageSize, Key? initialLoadKey = null, androidx.paging.PagedList.BoundaryCallback<Value>? boundaryCallback = null, kotlinx.coroutines.CoroutineScope coroutineScope = GlobalScope, kotlinx.coroutines.CoroutineDispatcher fetchDispatcher = Dispatchers.IO);
}
+ public final class LivePagingData {
+ method public static <Key, Value> androidx.lifecycle.LiveData<androidx.paging.PagingData<Value>> create(androidx.paging.PagingConfig config, Key? initialKey, kotlin.jvm.functions.Function0<? extends androidx.paging.PagingSource<Key,Value>> pagingSourceFactory);
+ method public static <Key, Value> androidx.lifecycle.LiveData<androidx.paging.PagingData<Value>> create(androidx.paging.PagingConfig config, kotlin.jvm.functions.Function0<? extends androidx.paging.PagingSource<Key,Value>> pagingSourceFactory);
+ }
+
public final class NullPaddedListDiffHelperKt {
}
diff --git a/paging/runtime/build.gradle b/paging/runtime/build.gradle
index 6c43f30..9ef2307 100644
--- a/paging/runtime/build.gradle
+++ b/paging/runtime/build.gradle
@@ -34,12 +34,12 @@
// Ensure that the -ktx dependency graph mirrors the Java dependency graph
api(project(":paging:paging-common-ktx"))
- api("androidx.arch.core:core-runtime:2.1.0")
- api("androidx.lifecycle:lifecycle-runtime:2.1.0")
- api("androidx.lifecycle:lifecycle-livedata:2.1.0")
+ api(project(":lifecycle:lifecycle-runtime-ktx"))
+ api(project(":lifecycle:lifecycle-livedata-ktx"))
api("androidx.recyclerview:recyclerview:1.1.0")
api(KOTLIN_STDLIB)
api(KOTLIN_COROUTINES_ANDROID)
+ implementation(project(":core:core-ktx"))
androidTestImplementation project(':paging:paging-testutils')
androidTestImplementation project(':internal-testutils-common')
diff --git a/paging/runtime/src/androidTest/java/androidx/paging/LivePagedListTest.kt b/paging/runtime/src/androidTest/java/androidx/paging/LivePagedListTest.kt
index 43db18a..ce5c600 100644
--- a/paging/runtime/src/androidTest/java/androidx/paging/LivePagedListTest.kt
+++ b/paging/runtime/src/androidTest/java/androidx/paging/LivePagedListTest.kt
@@ -76,19 +76,14 @@
) {
}
- override fun loadRange(params: LoadRangeParams, callback: LoadRangeCallback<String>) {
- }
+ override fun loadRange(params: LoadRangeParams, callback: LoadRangeCallback<String>) {}
}
private val dataSourceFactory = object : DataSource.Factory<Int, String>() {
- override fun create(): DataSource<Int, String> {
- return dataSource
- }
+ override fun create(): DataSource<Int, String> = dataSource
}
- private val pagingSource = LegacyPagingSource(dataSource, Dispatchers.Main)
-
- private val pagingSourceFactory = { pagingSource }
+ private val pagingSourceFactory = dataSourceFactory.asPagingSourceFactory(Dispatchers.Main)
private val config = Config(10)
}
diff --git a/paging/runtime/src/main/java/androidx/paging/LivePagedListBuilder.kt b/paging/runtime/src/main/java/androidx/paging/LivePagedListBuilder.kt
index 1ce9fb4..deead61 100644
--- a/paging/runtime/src/main/java/androidx/paging/LivePagedListBuilder.kt
+++ b/paging/runtime/src/main/java/androidx/paging/LivePagedListBuilder.kt
@@ -198,7 +198,7 @@
*/
fun build(): LiveData<PagedList<Value>> {
val pagingSourceFactory = pagingSourceFactory
- ?: dataSourceFactory?.let { { LegacyPagingSource(it.create()) } }
+ ?: dataSourceFactory?.asPagingSourceFactory(fetchDispatcher)
check(pagingSourceFactory != null) {
"LivePagedList cannot be built without a PagingSourceFactory or DataSource.Factory"
diff --git a/paging/runtime/src/main/java/androidx/paging/LivePagingData.kt b/paging/runtime/src/main/java/androidx/paging/LivePagingData.kt
new file mode 100644
index 0000000..2d3ef52
--- /dev/null
+++ b/paging/runtime/src/main/java/androidx/paging/LivePagingData.kt
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+@file:JvmName("LivePagingData")
+
+package androidx.paging
+
+import androidx.lifecycle.LiveData
+import androidx.lifecycle.asLiveData
+
+/**
+ * Construct the primary Paging reactive stream: `LiveData<PagingData<T>>`.
+ *
+ * Creates a stream of [PagingData] objects, each of which represents a single generation of
+ * paginated data. These objects can be transformed to alter data as it loads, and presented in a
+ * `RecyclerView`.
+ */
+@Suppress("FunctionName")
+@JvmName("create")
+fun <Key : Any, Value : Any> LivePagingData(
+ config: PagingConfig,
+ initialKey: Key?,
+ pagingSourceFactory: () -> PagingSource<Key, Value>
+): LiveData<PagingData<Value>> = PagingDataFlow(config, initialKey, pagingSourceFactory)
+ .asLiveData()
+
+/**
+ * Construct the primary Paging reactive stream: `LiveData<PagingData<T>>`.
+ *
+ * Creates a stream of [PagingData] objects, each of which represents a single generation of
+ * paginated data. These objects can be transformed to alter data as it loads, and presented in a
+ * `RecyclerView`.
+ */
+@Suppress("FunctionName")
+@JvmName("create")
+fun <Key : Any, Value : Any> LivePagingData(
+ config: PagingConfig,
+ pagingSourceFactory: () -> PagingSource<Key, Value>
+): LiveData<PagingData<Value>> = PagingDataFlow(config, pagingSourceFactory)
+ .asLiveData()
diff --git a/paging/rxjava2/src/main/java/androidx/paging/RxPagedListBuilder.kt b/paging/rxjava2/src/main/java/androidx/paging/RxPagedListBuilder.kt
index 1875e23..578b36d 100644
--- a/paging/rxjava2/src/main/java/androidx/paging/RxPagedListBuilder.kt
+++ b/paging/rxjava2/src/main/java/androidx/paging/RxPagedListBuilder.kt
@@ -212,18 +212,16 @@
* @return The [Observable] of PagedLists
*/
fun buildObservable(): Observable<PagedList<Value>> {
- if (notifyDispatcher == null) {
- notifyScheduler = ScheduledExecutor(ArchTaskExecutor.getMainThreadExecutor())
- notifyDispatcher = notifyScheduler!!.asCoroutineDispatcher()
- }
- if (fetchDispatcher == null) {
- val scheduledExecutor = ScheduledExecutor(ArchTaskExecutor.getIOThreadExecutor())
- fetchScheduler = scheduledExecutor
- fetchDispatcher = fetchScheduler!!.asCoroutineDispatcher()
- }
+ val notifyScheduler = notifyScheduler
+ ?: ScheduledExecutor(ArchTaskExecutor.getMainThreadExecutor())
+ val notifyDispatcher = notifyDispatcher ?: notifyScheduler.asCoroutineDispatcher()
+
+ val fetchScheduler = fetchScheduler
+ ?: ScheduledExecutor(ArchTaskExecutor.getIOThreadExecutor())
+ val fetchDispatcher = fetchDispatcher ?: fetchScheduler.asCoroutineDispatcher()
val pagingSourceFactory = pagingSourceFactory
- ?: dataSourceFactory?.let { { LegacyPagingSource(it.create()) } }
+ ?: dataSourceFactory?.asPagingSourceFactory(fetchDispatcher)
check(pagingSourceFactory != null) {
"LivePagedList cannot be built without a PagingSourceFactory or DataSource.Factory"
@@ -236,8 +234,8 @@
config,
boundaryCallback,
pagingSourceFactory,
- notifyDispatcher!!,
- fetchDispatcher!!
+ notifyDispatcher,
+ fetchDispatcher
)
)
.observeOn(notifyScheduler)
diff --git a/recyclerview/recyclerview/api/1.2.0-alpha01.txt b/recyclerview/recyclerview/api/1.2.0-alpha01.txt
index 4a6f640..83d6c44 100644
--- a/recyclerview/recyclerview/api/1.2.0-alpha01.txt
+++ b/recyclerview/recyclerview/api/1.2.0-alpha01.txt
@@ -473,6 +473,7 @@
method public abstract int getItemCount();
method public long getItemId(int);
method public int getItemViewType(int);
+ method public final androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationStrategy getStateRestorationStrategy();
method public final boolean hasObservers();
method public final boolean hasStableIds();
method public final void notifyDataSetChanged();
@@ -496,9 +497,16 @@
method public void onViewRecycled(VH);
method public void registerAdapterDataObserver(androidx.recyclerview.widget.RecyclerView.AdapterDataObserver);
method public void setHasStableIds(boolean);
+ method public void setStateRestorationStrategy(androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationStrategy);
method public void unregisterAdapterDataObserver(androidx.recyclerview.widget.RecyclerView.AdapterDataObserver);
}
+ public enum RecyclerView.Adapter.StateRestorationStrategy {
+ enum_constant public static final androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationStrategy ALLOW;
+ enum_constant public static final androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationStrategy PREVENT;
+ enum_constant public static final androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationStrategy PREVENT_WHEN_EMPTY;
+ }
+
public abstract static class RecyclerView.AdapterDataObserver {
ctor public RecyclerView.AdapterDataObserver();
method public void onChanged();
@@ -507,6 +515,7 @@
method public void onItemRangeInserted(int, int);
method public void onItemRangeMoved(int, int, int);
method public void onItemRangeRemoved(int, int);
+ method public void onStateRestorationStrategyChanged();
}
public static interface RecyclerView.ChildDrawingOrderCallback {
diff --git a/recyclerview/recyclerview/api/current.txt b/recyclerview/recyclerview/api/current.txt
index 4a6f640..83d6c44 100644
--- a/recyclerview/recyclerview/api/current.txt
+++ b/recyclerview/recyclerview/api/current.txt
@@ -473,6 +473,7 @@
method public abstract int getItemCount();
method public long getItemId(int);
method public int getItemViewType(int);
+ method public final androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationStrategy getStateRestorationStrategy();
method public final boolean hasObservers();
method public final boolean hasStableIds();
method public final void notifyDataSetChanged();
@@ -496,9 +497,16 @@
method public void onViewRecycled(VH);
method public void registerAdapterDataObserver(androidx.recyclerview.widget.RecyclerView.AdapterDataObserver);
method public void setHasStableIds(boolean);
+ method public void setStateRestorationStrategy(androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationStrategy);
method public void unregisterAdapterDataObserver(androidx.recyclerview.widget.RecyclerView.AdapterDataObserver);
}
+ public enum RecyclerView.Adapter.StateRestorationStrategy {
+ enum_constant public static final androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationStrategy ALLOW;
+ enum_constant public static final androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationStrategy PREVENT;
+ enum_constant public static final androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationStrategy PREVENT_WHEN_EMPTY;
+ }
+
public abstract static class RecyclerView.AdapterDataObserver {
ctor public RecyclerView.AdapterDataObserver();
method public void onChanged();
@@ -507,6 +515,7 @@
method public void onItemRangeInserted(int, int);
method public void onItemRangeMoved(int, int, int);
method public void onItemRangeRemoved(int, int);
+ method public void onStateRestorationStrategyChanged();
}
public static interface RecyclerView.ChildDrawingOrderCallback {
diff --git a/recyclerview/recyclerview/api/public_plus_experimental_1.2.0-alpha01.txt b/recyclerview/recyclerview/api/public_plus_experimental_1.2.0-alpha01.txt
index 4a6f640..83d6c44 100644
--- a/recyclerview/recyclerview/api/public_plus_experimental_1.2.0-alpha01.txt
+++ b/recyclerview/recyclerview/api/public_plus_experimental_1.2.0-alpha01.txt
@@ -473,6 +473,7 @@
method public abstract int getItemCount();
method public long getItemId(int);
method public int getItemViewType(int);
+ method public final androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationStrategy getStateRestorationStrategy();
method public final boolean hasObservers();
method public final boolean hasStableIds();
method public final void notifyDataSetChanged();
@@ -496,9 +497,16 @@
method public void onViewRecycled(VH);
method public void registerAdapterDataObserver(androidx.recyclerview.widget.RecyclerView.AdapterDataObserver);
method public void setHasStableIds(boolean);
+ method public void setStateRestorationStrategy(androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationStrategy);
method public void unregisterAdapterDataObserver(androidx.recyclerview.widget.RecyclerView.AdapterDataObserver);
}
+ public enum RecyclerView.Adapter.StateRestorationStrategy {
+ enum_constant public static final androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationStrategy ALLOW;
+ enum_constant public static final androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationStrategy PREVENT;
+ enum_constant public static final androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationStrategy PREVENT_WHEN_EMPTY;
+ }
+
public abstract static class RecyclerView.AdapterDataObserver {
ctor public RecyclerView.AdapterDataObserver();
method public void onChanged();
@@ -507,6 +515,7 @@
method public void onItemRangeInserted(int, int);
method public void onItemRangeMoved(int, int, int);
method public void onItemRangeRemoved(int, int);
+ method public void onStateRestorationStrategyChanged();
}
public static interface RecyclerView.ChildDrawingOrderCallback {
diff --git a/recyclerview/recyclerview/api/public_plus_experimental_current.txt b/recyclerview/recyclerview/api/public_plus_experimental_current.txt
index 4a6f640..83d6c44 100644
--- a/recyclerview/recyclerview/api/public_plus_experimental_current.txt
+++ b/recyclerview/recyclerview/api/public_plus_experimental_current.txt
@@ -473,6 +473,7 @@
method public abstract int getItemCount();
method public long getItemId(int);
method public int getItemViewType(int);
+ method public final androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationStrategy getStateRestorationStrategy();
method public final boolean hasObservers();
method public final boolean hasStableIds();
method public final void notifyDataSetChanged();
@@ -496,9 +497,16 @@
method public void onViewRecycled(VH);
method public void registerAdapterDataObserver(androidx.recyclerview.widget.RecyclerView.AdapterDataObserver);
method public void setHasStableIds(boolean);
+ method public void setStateRestorationStrategy(androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationStrategy);
method public void unregisterAdapterDataObserver(androidx.recyclerview.widget.RecyclerView.AdapterDataObserver);
}
+ public enum RecyclerView.Adapter.StateRestorationStrategy {
+ enum_constant public static final androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationStrategy ALLOW;
+ enum_constant public static final androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationStrategy PREVENT;
+ enum_constant public static final androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationStrategy PREVENT_WHEN_EMPTY;
+ }
+
public abstract static class RecyclerView.AdapterDataObserver {
ctor public RecyclerView.AdapterDataObserver();
method public void onChanged();
@@ -507,6 +515,7 @@
method public void onItemRangeInserted(int, int);
method public void onItemRangeMoved(int, int, int);
method public void onItemRangeRemoved(int, int);
+ method public void onStateRestorationStrategyChanged();
}
public static interface RecyclerView.ChildDrawingOrderCallback {
diff --git a/recyclerview/recyclerview/api/restricted_1.2.0-alpha01.txt b/recyclerview/recyclerview/api/restricted_1.2.0-alpha01.txt
index 6d5fda3..3da68a4 100644
--- a/recyclerview/recyclerview/api/restricted_1.2.0-alpha01.txt
+++ b/recyclerview/recyclerview/api/restricted_1.2.0-alpha01.txt
@@ -473,6 +473,7 @@
method public abstract int getItemCount();
method public long getItemId(int);
method public int getItemViewType(int);
+ method public final androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationStrategy getStateRestorationStrategy();
method public final boolean hasObservers();
method public final boolean hasStableIds();
method public final void notifyDataSetChanged();
@@ -496,9 +497,16 @@
method public void onViewRecycled(VH);
method public void registerAdapterDataObserver(androidx.recyclerview.widget.RecyclerView.AdapterDataObserver);
method public void setHasStableIds(boolean);
+ method public void setStateRestorationStrategy(androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationStrategy);
method public void unregisterAdapterDataObserver(androidx.recyclerview.widget.RecyclerView.AdapterDataObserver);
}
+ public enum RecyclerView.Adapter.StateRestorationStrategy {
+ enum_constant public static final androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationStrategy ALLOW;
+ enum_constant public static final androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationStrategy PREVENT;
+ enum_constant public static final androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationStrategy PREVENT_WHEN_EMPTY;
+ }
+
public abstract static class RecyclerView.AdapterDataObserver {
ctor public RecyclerView.AdapterDataObserver();
method public void onChanged();
@@ -507,6 +515,7 @@
method public void onItemRangeInserted(int, int);
method public void onItemRangeMoved(int, int, int);
method public void onItemRangeRemoved(int, int);
+ method public void onStateRestorationStrategyChanged();
}
public static interface RecyclerView.ChildDrawingOrderCallback {
diff --git a/recyclerview/recyclerview/api/restricted_current.txt b/recyclerview/recyclerview/api/restricted_current.txt
index 6d5fda3..3da68a4 100644
--- a/recyclerview/recyclerview/api/restricted_current.txt
+++ b/recyclerview/recyclerview/api/restricted_current.txt
@@ -473,6 +473,7 @@
method public abstract int getItemCount();
method public long getItemId(int);
method public int getItemViewType(int);
+ method public final androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationStrategy getStateRestorationStrategy();
method public final boolean hasObservers();
method public final boolean hasStableIds();
method public final void notifyDataSetChanged();
@@ -496,9 +497,16 @@
method public void onViewRecycled(VH);
method public void registerAdapterDataObserver(androidx.recyclerview.widget.RecyclerView.AdapterDataObserver);
method public void setHasStableIds(boolean);
+ method public void setStateRestorationStrategy(androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationStrategy);
method public void unregisterAdapterDataObserver(androidx.recyclerview.widget.RecyclerView.AdapterDataObserver);
}
+ public enum RecyclerView.Adapter.StateRestorationStrategy {
+ enum_constant public static final androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationStrategy ALLOW;
+ enum_constant public static final androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationStrategy PREVENT;
+ enum_constant public static final androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationStrategy PREVENT_WHEN_EMPTY;
+ }
+
public abstract static class RecyclerView.AdapterDataObserver {
ctor public RecyclerView.AdapterDataObserver();
method public void onChanged();
@@ -507,6 +515,7 @@
method public void onItemRangeInserted(int, int);
method public void onItemRangeMoved(int, int, int);
method public void onItemRangeRemoved(int, int);
+ method public void onStateRestorationStrategyChanged();
}
public static interface RecyclerView.ChildDrawingOrderCallback {
diff --git a/recyclerview/recyclerview/build.gradle b/recyclerview/recyclerview/build.gradle
index 431d8ad9..9f19aac 100644
--- a/recyclerview/recyclerview/build.gradle
+++ b/recyclerview/recyclerview/build.gradle
@@ -22,6 +22,7 @@
androidTestImplementation(ESPRESSO_CORE, libs.exclude_for_espresso)
androidTestImplementation(MOCKITO_CORE, libs.exclude_bytebuddy) // DexMaker has it"s own MockMaker
androidTestImplementation(DEXMAKER_MOCKITO, libs.exclude_bytebuddy) // DexMaker has it"s own MockMaker
+ androidTestImplementation(TRUTH)
androidTestImplementation(JUNIT)
androidTestImplementation(KOTLIN_STDLIB)
androidTestImplementation(project(":internal-testutils-espresso"))
diff --git a/recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/LazyStateRestorationTest.kt b/recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/LazyStateRestorationTest.kt
new file mode 100644
index 0000000..0ee2d89
--- /dev/null
+++ b/recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/LazyStateRestorationTest.kt
@@ -0,0 +1,272 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.recyclerview.widget
+
+import android.content.Context
+import android.graphics.Rect
+import android.os.Parcel
+import android.os.Parcelable
+import android.view.View
+import android.view.View.MeasureSpec.AT_MOST
+import android.view.ViewGroup
+import androidx.recyclerview.widget.BaseRecyclerViewInstrumentationTest.Item
+import androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationStrategy.PREVENT_WHEN_EMPTY
+import androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationStrategy.ALLOW
+import androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationStrategy.PREVENT
+import androidx.recyclerview.widget.StaggeredGridLayoutManager.GAP_HANDLING_NONE
+import androidx.recyclerview.widget.StaggeredGridLayoutManager.VERTICAL
+import androidx.test.annotation.UiThreadTest
+import androidx.test.core.app.ApplicationProvider.getApplicationContext
+import androidx.test.filters.SmallTest
+import com.google.common.truth.Truth.assertThat
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.Parameterized
+import java.util.LinkedHashMap
+import java.util.UUID
+
+@RunWith(Parameterized::class)
+@SmallTest
+class LazyStateRestorationTest(
+ private val layoutManagerFactory: LayoutManagerFactory
+) {
+ private lateinit var recyclerView: RecyclerView
+ private val items = (0..99).map { Item(it, "text $it") }
+ @Before
+ fun init() {
+ recyclerView = RecyclerView(getApplicationContext())
+ recyclerView.itemAnimator = null
+ recyclerView.adapter = LazyStateAdapter(items)
+ recyclerView.layoutManager = createLayoutManager()
+ }
+
+ private fun createLayoutManager(): RecyclerView.LayoutManager {
+ return layoutManagerFactory.create(getApplicationContext())
+ }
+
+ private fun measureAndLayout() {
+ measure()
+ layout()
+ }
+
+ private fun measure() {
+ recyclerView.measure(AT_MOST or 320, AT_MOST or 240)
+ }
+
+ private fun layout() {
+ recyclerView.layout(0, 0, 320, 320)
+ }
+
+ private fun restore(
+ setAdapter: Boolean
+ ) {
+ val prevAdapter = checkNotNull(recyclerView.adapter as? LazyStateAdapter) {
+ "Previous RecyclerView should have a LazyStateAdapter for the test"
+ }
+ val savedState = saveState()
+ recyclerView = RecyclerView(getApplicationContext())
+ recyclerView.layoutManager = createLayoutManager()
+ recyclerView.onRestoreInstanceState(savedState)
+ if (setAdapter) {
+ recyclerView.adapter = LazyStateAdapter(prevAdapter.items)
+ }
+ }
+
+ private fun saveState(): Parcelable {
+ val parcel = Parcel.obtain()
+ val parcelSuffix = UUID.randomUUID().toString()
+ val savedState = recyclerView.onSaveInstanceState()
+ savedState!!.writeToParcel(parcel, 0)
+ parcel.writeString(parcelSuffix)
+ // reset position for reading
+ parcel.setDataPosition(0)
+ return savedState
+ }
+
+ @Test
+ @UiThreadTest
+ fun default() {
+ measureAndLayout()
+ recyclerView.scrollBy(0, 113)
+ val coordinates = recyclerView.collectChildCoordinates()
+ restore(setAdapter = true)
+ measureAndLayout()
+ val restoredCoordinates = recyclerView.collectChildCoordinates()
+ assertThat(restoredCoordinates).isEqualTo(coordinates)
+ }
+
+ @Test
+ @UiThreadTest
+ fun countBased() {
+ measureAndLayout()
+ recyclerView.scrollBy(0, 113)
+ val coordinates = recyclerView.collectChildCoordinates()
+ restore(setAdapter = false)
+ val adapter = LazyStateAdapter(emptyList())
+ adapter.stateRestorationStrategy = PREVENT_WHEN_EMPTY
+ recyclerView.adapter = adapter
+ measureAndLayout()
+ // test sanity
+ assertThat(recyclerView.collectChildCoordinates()).isEmpty()
+ adapter.items = items
+ adapter.notifyDataSetChanged()
+ measureAndLayout()
+ val restored = recyclerView.collectChildCoordinates()
+ assertThat(restored).isEqualTo(coordinates)
+ }
+
+ @Test
+ @UiThreadTest
+ fun manual() {
+ measureAndLayout()
+ recyclerView.scrollBy(0, 113)
+ val coordinates = recyclerView.collectChildCoordinates()
+ restore(setAdapter = true)
+ val adapter = recyclerView.adapter as LazyStateAdapter
+ adapter.stateRestorationStrategy = PREVENT
+ measureAndLayout()
+ // test sanity, we should layout whatever is available
+ assertThat(recyclerView.collectChildCoordinates()).isNotEmpty()
+ // make sure we didn't restore
+ assertThat(recyclerView.collectChildCoordinates()).isNotEqualTo(coordinates)
+
+ // notifying item change does not matter
+ adapter.items = adapter.items.subList(0, 90)
+ adapter.notifyDataSetChanged()
+ measureAndLayout()
+ // still not restored
+ assertThat(recyclerView.collectChildCoordinates()).isNotEqualTo(coordinates)
+ adapter.stateRestorationStrategy = ALLOW
+ assertThat(recyclerView.isLayoutRequested).isTrue()
+ measureAndLayout()
+ // now we should restore
+ val restored = recyclerView.collectChildCoordinates()
+ assertThat(restored).isEqualTo(coordinates)
+ }
+
+ @Test
+ @UiThreadTest
+ fun scrollToPositionOverridesState() {
+ measureAndLayout()
+ recyclerView.scrollBy(0, 113)
+ restore(setAdapter = true)
+ val adapter = recyclerView.adapter as LazyStateAdapter
+ adapter.stateRestorationStrategy = PREVENT
+ measureAndLayout()
+ // state is not restored yet, trigger a scroll
+ recyclerView.scrollToPosition(40)
+ measureAndLayout()
+ // relayout so that SGLM can settle
+ recyclerView.requestLayout()
+ measureAndLayout()
+ val scrolled = recyclerView.collectChildCoordinates()
+
+ assertThat(recyclerView.collectChildCoordinates()).isEqualTo(scrolled)
+ // now restore state, it should be ignored
+ adapter.stateRestorationStrategy = ALLOW
+ measureAndLayout()
+ val coordinates = recyclerView.collectChildCoordinates()
+ assertThat(coordinates).isEqualTo(scrolled)
+ }
+
+ companion object {
+ @Parameterized.Parameters(name = "{0}")
+ @JvmStatic
+ fun params(): List<LayoutManagerFactory> = listOf(
+ LinearLayoutManagerFactory(),
+ GridLayoutManagerFactory(),
+ StaggeredGridLayoutManagerFactory()
+ )
+ }
+
+ abstract class LayoutManagerFactory {
+ abstract fun create(context: Context): RecyclerView.LayoutManager
+ abstract fun describe(): String
+ override fun toString() = describe()
+ }
+
+ private class LinearLayoutManagerFactory : LayoutManagerFactory() {
+ override fun create(context: Context): RecyclerView.LayoutManager {
+ return LinearLayoutManager(context)
+ }
+
+ override fun describe() = "LinearLayoutManager"
+ }
+
+ private class GridLayoutManagerFactory : LayoutManagerFactory() {
+ override fun create(context: Context): RecyclerView.LayoutManager {
+ return GridLayoutManager(context, 3)
+ }
+
+ override fun describe() = "GridLayoutManager"
+ }
+
+ private class StaggeredGridLayoutManagerFactory : LayoutManagerFactory() {
+ override fun create(context: Context): RecyclerView.LayoutManager {
+ return StaggeredGridLayoutManager(3, VERTICAL).also {
+ it.gapStrategy = GAP_HANDLING_NONE
+ }
+ }
+
+ override fun describe() = "StaggeredGridLayoutManager"
+ }
+
+ private class LazyStateAdapter(
+ var items: List<Item>
+ ) : RecyclerView.Adapter<LazyStateViewHolder>() {
+ override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): LazyStateViewHolder {
+ return LazyStateViewHolder(parent.context)
+ }
+
+ override fun onBindViewHolder(holder: LazyStateViewHolder, position: Int) {
+ holder.bindTo(items[position])
+ }
+
+ override fun getItemCount() = items.size
+ }
+
+ private class LazyStateViewHolder(
+ context: Context
+ ) : RecyclerView.ViewHolder(
+ View(context)
+ ) {
+ var item: Item? = null
+ fun bindTo(item: Item) {
+ this.item = item
+ itemView.layoutParams = RecyclerView.LayoutParams(
+ RecyclerView.LayoutParams.MATCH_PARENT,
+ 25 + (item.mId % 10)
+ )
+ }
+ }
+
+ private fun RecyclerView.collectChildCoordinates(): Map<Item, Rect> {
+ val items = LinkedHashMap<Item, Rect>()
+ val layoutBounds = Rect(0, 0, width, height)
+ for (i in 0 until childCount) {
+ val child = getChildAt(i)
+ val lp = child!!.layoutParams as RecyclerView.LayoutParams
+ val vh = lp.mViewHolder as LazyStateViewHolder
+ val rect = Rect(child.left, child.top, child.right, child.bottom)
+ if (rect.intersect(layoutBounds)) {
+ items[vh.item!!] = rect
+ }
+ }
+ return items
+ }
+}
\ No newline at end of file
diff --git a/recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/LinearLayoutManagerSavedStateTest.java b/recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/LinearLayoutManagerSavedStateTest.java
index 78bf4da..8ace7e8 100644
--- a/recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/LinearLayoutManagerSavedStateTest.java
+++ b/recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/LinearLayoutManagerSavedStateTest.java
@@ -47,7 +47,7 @@
public LinearLayoutManagerSavedStateTest(Config config, boolean waitForLayout,
boolean loadDataAfterRestore, PostLayoutRunnable postLayoutOperation,
- PostRestoreRunnable postRestoreOperation) {
+ PostRestoreRunnable postRestoreOperation, int index) {
mConfig = config;
mWaitForLayout = waitForLayout;
mLoadDataAfterRestore = loadDataAfterRestore;
@@ -80,7 +80,7 @@
}
@Parameterized.Parameters(name = "{0},waitForLayout:{1},loadDataAfterRestore:{2}"
- + ",postLayout:{3},postRestore:{4}")
+ + ",postLayout:{3},postRestore:{4},testIndex:{5}")
public static Iterable<Object[]> params()
throws IllegalAccessException, CloneNotSupportedException, NoSuchFieldException {
PostLayoutRunnable[] postLayoutOptions = new PostLayoutRunnable[]{
@@ -250,6 +250,7 @@
variations = addConfigVariation(variations, "mRecycleChildrenOnDetach", true);
List<Object[]> params = new ArrayList<>();
+ int index = 0;
for (Config config : variations) {
for (PostLayoutRunnable postLayoutRunnable : postLayoutOptions) {
for (boolean waitForLayout : waitForLayoutOptions) {
@@ -257,7 +258,8 @@
for (boolean loadDataAfterRestore : loadDataAfterRestoreOptions) {
params.add(new Object[]{
config.clone(), waitForLayout,
- loadDataAfterRestore, postLayoutRunnable, postRestoreRunnable
+ loadDataAfterRestore, postLayoutRunnable, postRestoreRunnable,
+ index++
});
}
}
diff --git a/recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/RecyclerViewBasicTest.java b/recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/RecyclerViewBasicTest.java
index a8b94e7..ccd9716d 100644
--- a/recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/RecyclerViewBasicTest.java
+++ b/recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/RecyclerViewBasicTest.java
@@ -20,7 +20,6 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
@@ -311,19 +310,17 @@
savedState = RecyclerView.SavedState.CREATOR.createFromParcel(parcel);
RecyclerView restored = new RecyclerView(getContext());
+ mRecyclerView = restored;
MockLayoutManager mlmRestored = new MockLayoutManager();
restored.setLayoutManager(mlmRestored);
restored.setAdapter(new MockAdapter(3));
restored.onRestoreInstanceState(savedState);
-
+ layout();
assertEquals("Parcel reading should not go out of bounds", parcelSuffix,
parcel.readString());
assertEquals("When unmarshalling, all of the parcel should be read", 0, parcel.dataAvail());
assertEquals("uuid in layout manager should be preserved properly", mlm.mUuid,
mlmRestored.mUuid);
- assertNotSame("stateless parameter should not be preserved", mlm.mLayoutCount,
- mlmRestored.mLayoutCount);
- layout();
}
@Test
diff --git a/recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/StaggeredGridLayoutManagerSavedStateTest.java b/recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/StaggeredGridLayoutManagerSavedStateTest.java
index f696531..b5f19cc 100644
--- a/recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/StaggeredGridLayoutManagerSavedStateTest.java
+++ b/recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/StaggeredGridLayoutManagerSavedStateTest.java
@@ -16,7 +16,10 @@
package androidx.recyclerview.widget;
+import static androidx.recyclerview.widget.StaggeredGridLayoutManager.GAP_HANDLING_NONE;
+
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import android.graphics.Rect;
import android.os.Parcel;
@@ -40,24 +43,32 @@
private final Config mConfig;
private final boolean mLoadDataAfterRestore;
private final PostLayoutRunnable mPostLayoutOperations;
+ private final PostRestoreRunnable mPostRestoreOperations;
public StaggeredGridLayoutManagerSavedStateTest(
Config config,
boolean loadDataAfterRestore,
- PostLayoutRunnable postLayoutOperations) throws CloneNotSupportedException {
+ PostLayoutRunnable postLayoutOperations,
+ PostRestoreRunnable postRestoreOperations,
+ int index) throws CloneNotSupportedException {
this.mConfig = (Config) config.clone();
this.mLoadDataAfterRestore = loadDataAfterRestore;
this.mPostLayoutOperations = postLayoutOperations;
+ this.mPostRestoreOperations = postRestoreOperations;
if (postLayoutOperations != null) {
postLayoutOperations.mTest = this;
}
+ if (mPostRestoreOperations != null) {
+ mPostRestoreOperations.mTest = this;
+ }
}
- @Parameterized.Parameters(name = "config={0},loadDataAfterRestore={1},postLayoutRunnable={2}")
+ @Parameterized.Parameters(name = "config={0},loadDataAfterRestore={1},postLayoutRunnable={2}"
+ + ",postRestoreRunnable={3},index={4}")
public static List<Object[]> getParams() throws CloneNotSupportedException {
List<Config> variations = createBaseVariations();
- PostLayoutRunnable[] postLayoutOptions = new PostLayoutRunnable[]{
+ final PostLayoutRunnable[] postLayoutOptions = new PostLayoutRunnable[]{
new PostLayoutRunnable() {
@Override
public void run() throws Throwable {
@@ -111,6 +122,43 @@
}
}
};
+ PostRestoreRunnable[] postRestoreOptions = new PostRestoreRunnable[]{
+ new PostRestoreRunnable() {
+ @Override
+ String describe() {
+ return "doing_nothing";
+ }
+ },
+ new PostRestoreRunnable() {
+ int mPosition;
+
+ @Override
+ void onAfterRestore(Config config) throws Throwable {
+ mPosition = adapter().getItemCount() / 2;
+ layoutManager().scrollToPosition(mPosition);
+ }
+
+ @Override
+ boolean shouldLayoutMatch(Config config) {
+ return adapter().getItemCount() <= config.mSpanCount
+ && config.mGapStrategy != GAP_HANDLING_NONE;
+ }
+
+ @Override
+ void onAfterReLayout(Config config) {
+ if (adapter().getItemCount() > 0) {
+ assertNotNull(
+ "view at " + mPosition + " should be visible",
+ layoutManager().findViewByPosition(mPosition));
+ }
+ }
+
+ @Override
+ String describe() {
+ return "scroll_to_pos_" + mPosition;
+ }
+ }
+ };
boolean[] loadDataAfterRestoreOptions = new boolean[]{false, true};
List<Config> testVariations = new ArrayList<Config>();
testVariations.addAll(variations);
@@ -123,12 +171,15 @@
testVariations.add(clone);
}
+ int index = 0;
List<Object[]> params = new ArrayList<>();
for (Config config : testVariations) {
- for (PostLayoutRunnable runnable : postLayoutOptions) {
- for (boolean loadDataAfterRestore : loadDataAfterRestoreOptions) {
- params.add(new Object[]{config, loadDataAfterRestore,
- runnable});
+ for (PostLayoutRunnable postLayout : postLayoutOptions) {
+ for (PostRestoreRunnable postRestore : postRestoreOptions) {
+ for (boolean loadDataAfterRestore : loadDataAfterRestoreOptions) {
+ params.add(new Object[]{config, loadDataAfterRestore,
+ postLayout, postRestore, index++});
+ }
}
}
}
@@ -192,7 +243,7 @@
if (mLoadDataAfterRestore) {
mAdapter.resetItemsTo(mItems);
}
-
+ mPostRestoreOperations.onAfterRestore(mConfig);
assertEquals("Parcel reading should not go out of bounds", parcelSuffix,
parcel.readString());
mLayoutManager.expectLayouts(1);
@@ -206,16 +257,23 @@
mConfig.mSpanCount, mLayoutManager.getSpanCount());
assertEquals(mConfig + " on saved state, gap strategy should be preserved",
mConfig.mGapStrategy, mLayoutManager.getGapStrategy());
- assertEquals(mConfig + " on saved state, first completely visible child position should"
- + " be preserved", firstCompletelyVisiblePosition,
- mLayoutManager.findFirstVisibleItemPositionInt());
+ if (mPostRestoreOperations.shouldLayoutMatch(mConfig)) {
+ assertEquals(mConfig + " on saved state, first completely visible child "
+ + "position should be preserved", firstCompletelyVisiblePosition,
+ mLayoutManager.findFirstVisibleItemPositionInt());
+ }
final boolean strictItemEquality = !mLoadDataAfterRestore;
- assertRectSetsEqual(mConfig + "\npost layout op:" + mPostLayoutOperations.describe()
- + ": on restore, previous view positions should be preserved",
- before, mLayoutManager.collectChildCoordinates(), strictItemEquality);
+ if (mPostRestoreOperations.shouldLayoutMatch(mConfig)) {
+ assertRectSetsEqual(mConfig + "\npost layout op:" + mPostLayoutOperations.describe()
+ + ": on restore, previous view positions should be preserved",
+ before, mLayoutManager.collectChildCoordinates(), strictItemEquality);
- // TODO add tests for changing values after restore before layout
+ } else {
+ assertRectSetsNotEqual(mConfig + "\npost layout op:" + mPostLayoutOperations.describe()
+ + ": on restore, previous view positions should be different",
+ before, mLayoutManager.collectChildCoordinates());
+ }
}
static abstract class PostLayoutRunnable {
@@ -250,4 +308,38 @@
return describe();
}
}
+
+ abstract static class PostRestoreRunnable {
+ StaggeredGridLayoutManagerSavedStateTest mTest;
+
+ public void setup(StaggeredGridLayoutManagerSavedStateTest test) {
+ mTest = test;
+ }
+
+ public WrappedLayoutManager layoutManager() {
+ return mTest.mLayoutManager;
+ }
+
+ public GridTestAdapter adapter() {
+ return mTest.mAdapter;
+ }
+
+ void onAfterRestore(Config config) throws Throwable {
+ }
+
+ abstract String describe();
+
+ boolean shouldLayoutMatch(Config config) {
+ return true;
+ }
+
+ void onAfterReLayout(Config config) {
+
+ }
+
+ @Override
+ public String toString() {
+ return describe();
+ }
+ }
}
diff --git a/recyclerview/recyclerview/src/main/java/androidx/recyclerview/widget/LinearLayoutManager.java b/recyclerview/recyclerview/src/main/java/androidx/recyclerview/widget/LinearLayoutManager.java
index 7ab6cba..a0b6157 100644
--- a/recyclerview/recyclerview/src/main/java/androidx/recyclerview/widget/LinearLayoutManager.java
+++ b/recyclerview/recyclerview/src/main/java/androidx/recyclerview/widget/LinearLayoutManager.java
@@ -120,6 +120,11 @@
int mPendingScrollPosition = RecyclerView.NO_POSITION;
/**
+ * Set if {@link #scrollToPosition(int)} or its variants is called. Even if the state is
+ * restored lazily, we'll ignore the saved state.
+ */
+ boolean mIgnoreSavedScrollPosition = false;
+ /**
* Used to keep the offset value when {@link #scrollToPositionWithOffset(int, int)} is
* called.
*/
@@ -278,6 +283,9 @@
public void onRestoreInstanceState(Parcelable state) {
if (state instanceof SavedState) {
mPendingSavedState = (SavedState) state;
+ if (mIgnoreSavedScrollPosition) {
+ mPendingSavedState.invalidateAnchor();
+ }
requestLayout();
if (DEBUG) {
Log.d(TAG, "loaded saved state");
@@ -1072,6 +1080,7 @@
if (mPendingSavedState != null) {
mPendingSavedState.invalidateAnchor();
}
+ mIgnoreSavedScrollPosition = true;
requestLayout();
}
@@ -1100,6 +1109,7 @@
if (mPendingSavedState != null) {
mPendingSavedState.invalidateAnchor();
}
+ mIgnoreSavedScrollPosition = true;
requestLayout();
}
diff --git a/recyclerview/recyclerview/src/main/java/androidx/recyclerview/widget/RecyclerView.java b/recyclerview/recyclerview/src/main/java/androidx/recyclerview/widget/RecyclerView.java
index 5cc9511..baa2caf 100644
--- a/recyclerview/recyclerview/src/main/java/androidx/recyclerview/widget/RecyclerView.java
+++ b/recyclerview/recyclerview/src/main/java/androidx/recyclerview/widget/RecyclerView.java
@@ -366,7 +366,7 @@
final Recycler mRecycler = new Recycler();
- private SavedState mPendingSavedState;
+ SavedState mPendingSavedState;
/**
* Handles adapter updates
@@ -1394,9 +1394,6 @@
mPendingSavedState = (SavedState) state;
super.onRestoreInstanceState(mPendingSavedState.getSuperState());
- if (mLayout != null && mPendingSavedState.mLayoutState != null) {
- mLayout.onRestoreInstanceState(mPendingSavedState.mLayoutState);
- }
}
/**
@@ -4124,13 +4121,17 @@
mAdapterHelper.consumeUpdatesInOnePass();
mState.mItemCount = mAdapter.getItemCount();
mState.mDeletedInvisibleItemCountSincePreviousLayout = 0;
-
+ if (mPendingSavedState != null && mAdapter.canRestoreState()) {
+ if (mPendingSavedState.mLayoutState != null) {
+ mLayout.onRestoreInstanceState(mPendingSavedState.mLayoutState);
+ }
+ mPendingSavedState = null;
+ }
// Step 2: Run layout
mState.mInPreLayout = false;
mLayout.onLayoutChildren(mRecycler, mState);
mState.mStructureChanged = false;
- mPendingSavedState = null;
// onLayoutChildren may have caused client code to disable item animations; re-check
mState.mRunSimpleAnimations = mState.mRunSimpleAnimations && mItemAnimator != null;
@@ -5578,6 +5579,20 @@
requestLayout();
}
}
+
+ @Override
+ public void onStateRestorationStrategyChanged() {
+ if (mPendingSavedState == null) {
+ return;
+ }
+ // If there is a pending saved state and the new mode requires us to restore it,
+ // we'll request a layout which will call the adapter to see if it can restore state
+ // and trigger state restoration
+ Adapter<?> adapter = mAdapter;
+ if (adapter != null && adapter.canRestoreState()) {
+ requestLayout();
+ }
+ }
}
/**
@@ -6980,6 +6995,7 @@
public abstract static class Adapter<VH extends ViewHolder> {
private final AdapterDataObservable mObservable = new AdapterDataObservable();
private boolean mHasStableIds = false;
+ private StateRestorationStrategy mStateRestorationStrategy = StateRestorationStrategy.ALLOW;
/**
* Called when RecyclerView needs a new {@link ViewHolder} of the given type to represent
@@ -7527,6 +7543,91 @@
public final void notifyItemRangeRemoved(int positionStart, int itemCount) {
mObservable.notifyItemRangeRemoved(positionStart, itemCount);
}
+
+ /**
+ * Sets the state restoration strategy for the Adapter.
+ *
+ * By default, it is set to {@link StateRestorationStrategy#ALLOW} which means RecyclerView
+ * expects any set Adapter to be immediately capable of restoring the RecyclerView's saved
+ * scroll position.
+ * <p>
+ * This behaviour might be undesired if the Adapter's data is loaded asynchronously, and
+ * thus unavailable during initial layout (e.g. after Activity rotation). To avoid losing
+ * scroll position, you can change this to be either
+ * {@link StateRestorationStrategy#PREVENT_WHEN_EMPTY} or
+ * {@link StateRestorationStrategy#PREVENT}.
+ * Note that the former means your RecyclerView will restore state as soon as Adapter has
+ * 1 or more items while the latter requires you to call
+ * {@link #setStateRestorationStrategy(StateRestorationStrategy)} with either
+ * {@link StateRestorationStrategy#ALLOW} or
+ * {@link StateRestorationStrategy#PREVENT_WHEN_EMPTY} again when the Adapter is
+ * ready to restore its state.
+ * <p>
+ * RecyclerView will still layout even when State restoration is disabled. The behavior of
+ * how State is restored is up to the {@link LayoutManager}. All default LayoutManagers
+ * will override current state with restored state when state restoration happens (unless
+ * an explicit call to {@link LayoutManager#scrollToPosition(int)} is made).
+ * <p>
+ * Calling this method after state is restored will not have any effect other than changing
+ * the return value of {@link #getStateRestorationStrategy()}.
+ *
+ * @param strategy The saved state restoration strategy for this Adapter.
+ * @see #getStateRestorationStrategy()
+ */
+ public void setStateRestorationStrategy(@NonNull StateRestorationStrategy strategy) {
+ mStateRestorationStrategy = strategy;
+ mObservable.notifyStateRestorationStrategyChanged();
+ }
+
+ /**
+ * Returns when this Adapter wants to restore the state.
+ *
+ * @return The current {@link StateRestorationStrategy} for this Adapter. Defaults to
+ * {@link StateRestorationStrategy#ALLOW}.
+ * @see #setStateRestorationStrategy(StateRestorationStrategy)
+ */
+ @NonNull
+ public final StateRestorationStrategy getStateRestorationStrategy() {
+ return mStateRestorationStrategy;
+ }
+
+ /**
+ * Called by the RecyclerView to decide whether the SavedState should be given to the
+ * LayoutManager or not.
+ *
+ * @return {@code true} if the Adapter is ready to restore its state, {@code false}
+ * otherwise.
+ */
+ boolean canRestoreState() {
+ switch (mStateRestorationStrategy) {
+ case PREVENT: return false;
+ case PREVENT_WHEN_EMPTY: return getItemCount() > 0;
+ default: return true;
+ }
+ }
+
+ /**
+ * Defines how this Adapter wants to restore its state after a view reconstruction (e.g.
+ * configuration change).
+ */
+ public enum StateRestorationStrategy {
+ /**
+ * Adapter is ready to restore State immediately, RecyclerView will provide the state
+ * to the LayoutManager in the next layout pass.
+ */
+ ALLOW,
+ /**
+ * Adapter is ready to restore State when it has more than 0 items. RecyclerView will
+ * provide the state to the LayoutManager as soon as the Adapter has 1 or more items.
+ */
+ PREVENT_WHEN_EMPTY,
+ /**
+ * RecyclerView will not restore the state for the Adapter until a call to
+ * {@link #setStateRestorationStrategy(StateRestorationStrategy)} is made with either
+ * {@link #ALLOW} or {@link #PREVENT_WHEN_EMPTY}.
+ */
+ PREVENT
+ }
}
@SuppressWarnings("unchecked")
@@ -10293,7 +10394,16 @@
return null;
}
-
+ /**
+ * Called when the RecyclerView is ready to restore the state based on a previous
+ * RecyclerView.
+ *
+ * Notice that this might happen after an actual layout, based on how Adapter prefers to
+ * restore State. See {@link Adapter#getStateRestorationStrategy()} for more information.
+ *
+ * @param state The parcelable that was returned by the previous LayoutManager's
+ * {@link #onSaveInstanceState()} method.
+ */
public void onRestoreInstanceState(Parcelable state) {
}
@@ -11728,6 +11838,18 @@
public void onItemRangeMoved(int fromPosition, int toPosition, int itemCount) {
// do nothing
}
+
+ /**
+ * Called when the {@link Adapter.StateRestorationStrategy} of the {@link Adapter} changed.
+ * When this method is called, the Adapter might be ready to restore its state if it has
+ * not already been restored.
+ *
+ * @see Adapter#getStateRestorationStrategy()
+ * @see Adapter#setStateRestorationStrategy(Adapter.StateRestorationStrategy)
+ */
+ public void onStateRestorationStrategyChanged() {
+ // do nothing
+ }
}
/**
@@ -12238,6 +12360,12 @@
}
}
+ public void notifyStateRestorationStrategyChanged() {
+ for (int i = mObservers.size() - 1; i >= 0; i--) {
+ mObservers.get(i).onStateRestorationStrategyChanged();
+ }
+ }
+
public void notifyItemRangeChanged(int positionStart, int itemCount) {
notifyItemRangeChanged(positionStart, itemCount, null);
}
diff --git a/recyclerview/recyclerview/src/main/java/androidx/recyclerview/widget/StaggeredGridLayoutManager.java b/recyclerview/recyclerview/src/main/java/androidx/recyclerview/widget/StaggeredGridLayoutManager.java
index 0df077d..3072c89 100644
--- a/recyclerview/recyclerview/src/main/java/androidx/recyclerview/widget/StaggeredGridLayoutManager.java
+++ b/recyclerview/recyclerview/src/main/java/androidx/recyclerview/widget/StaggeredGridLayoutManager.java
@@ -151,6 +151,13 @@
int mPendingScrollPositionOffset = INVALID_OFFSET;
/**
+ * Set if {@link #scrollToPosition(int)} or its variants is called. Even if the state is
+ * restored lazily, we'll ignore the saved state because we'll have different span information
+ * and other state cannot be used anymore.
+ */
+ private boolean mIgnoreSavedStatePositions = false;
+
+ /**
* Keeps the mapping between the adapter positions and spans. This is necessary to provide
* a consistent experience when user scrolls the list.
*/
@@ -1220,6 +1227,10 @@
public void onRestoreInstanceState(Parcelable state) {
if (state instanceof SavedState) {
mPendingSavedState = (SavedState) state;
+ if (mIgnoreSavedStatePositions) {
+ mPendingSavedState.invalidateAnchorPositionInfo();
+ mPendingSavedState.invalidateSpanInfo();
+ }
requestLayout();
} else if (DEBUG) {
Log.d(TAG, "invalid saved state class");
@@ -2040,6 +2051,7 @@
}
mPendingScrollPosition = position;
mPendingScrollPositionOffset = INVALID_OFFSET;
+ mIgnoreSavedStatePositions = true;
requestLayout();
}
@@ -2062,6 +2074,7 @@
}
mPendingScrollPosition = position;
mPendingScrollPositionOffset = offset;
+ mIgnoreSavedStatePositions = true;
requestLayout();
}
diff --git a/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/core/WithConstraintsBenchmark.kt b/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/core/WithConstraintsBenchmark.kt
index ce493f0..4433072 100644
--- a/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/core/WithConstraintsBenchmark.kt
+++ b/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/core/WithConstraintsBenchmark.kt
@@ -123,7 +123,7 @@
@Composable
private fun ChangingConstraintsLayout(size: State<IntPx>, children: @Composable() () -> Unit) {
Layout(children) { measurables, _ ->
- val constraints = Constraints.tightConstraints(size.value, size.value)
+ val constraints = Constraints.fixed(size.value, size.value)
measurables.first().measure(constraints).place(0.ipx, 0.ipx)
layout(100.ipx, 100.ipx) {}
}
diff --git a/ui/ui-core/api/0.1.0-dev04.txt b/ui/ui-core/api/0.1.0-dev04.txt
index 6522680..c72417d 100644
--- a/ui/ui-core/api/0.1.0-dev04.txt
+++ b/ui/ui-core/api/0.1.0-dev04.txt
@@ -74,9 +74,9 @@
}
public static final class Constraints.Companion {
- method public androidx.ui.core.Constraints tightConstraints(androidx.ui.unit.IntPx width, androidx.ui.unit.IntPx height);
- method public androidx.ui.core.Constraints tightConstraintsForHeight(androidx.ui.unit.IntPx height);
- method public androidx.ui.core.Constraints tightConstraintsForWidth(androidx.ui.unit.IntPx width);
+ method public androidx.ui.core.Constraints fixed(androidx.ui.unit.IntPx width, androidx.ui.unit.IntPx height);
+ method public androidx.ui.core.Constraints fixedHeight(androidx.ui.unit.IntPx height);
+ method public androidx.ui.core.Constraints fixedWidth(androidx.ui.unit.IntPx width);
}
public final class ConstraintsKt {
@@ -84,17 +84,11 @@
method public static androidx.ui.core.Constraints enforce(androidx.ui.core.Constraints, androidx.ui.core.Constraints otherConstraints);
method public static boolean getHasBoundedHeight(androidx.ui.core.Constraints);
method public static boolean getHasBoundedWidth(androidx.ui.core.Constraints);
- method public static boolean getHasTightHeight(androidx.ui.core.Constraints);
- method public static boolean getHasTightWidth(androidx.ui.core.Constraints);
- method public static boolean isTight(androidx.ui.core.Constraints);
+ method public static boolean getHasFixedHeight(androidx.ui.core.Constraints);
+ method public static boolean getHasFixedWidth(androidx.ui.core.Constraints);
method public static boolean isZero(androidx.ui.core.Constraints);
- method public static androidx.ui.core.Constraints looseMax(androidx.ui.core.Constraints);
- method public static androidx.ui.core.Constraints looseMin(androidx.ui.core.Constraints);
method public static androidx.ui.core.Constraints offset(androidx.ui.core.Constraints, androidx.ui.unit.IntPx horizontal = 0.ipx, androidx.ui.unit.IntPx vertical = 0.ipx);
method public static boolean satisfiedBy(androidx.ui.core.Constraints, androidx.ui.unit.IntPxSize size);
- method public static androidx.ui.core.Constraints tightMax(androidx.ui.core.Constraints);
- method public static androidx.ui.core.Constraints tightMin(androidx.ui.core.Constraints);
- method public static androidx.ui.core.Constraints withTight(androidx.ui.core.Constraints, androidx.ui.unit.IntPx? width = null, androidx.ui.unit.IntPx? height = null);
}
public final class ConsumedData {
diff --git a/ui/ui-core/api/current.txt b/ui/ui-core/api/current.txt
index 6522680..c72417d 100644
--- a/ui/ui-core/api/current.txt
+++ b/ui/ui-core/api/current.txt
@@ -74,9 +74,9 @@
}
public static final class Constraints.Companion {
- method public androidx.ui.core.Constraints tightConstraints(androidx.ui.unit.IntPx width, androidx.ui.unit.IntPx height);
- method public androidx.ui.core.Constraints tightConstraintsForHeight(androidx.ui.unit.IntPx height);
- method public androidx.ui.core.Constraints tightConstraintsForWidth(androidx.ui.unit.IntPx width);
+ method public androidx.ui.core.Constraints fixed(androidx.ui.unit.IntPx width, androidx.ui.unit.IntPx height);
+ method public androidx.ui.core.Constraints fixedHeight(androidx.ui.unit.IntPx height);
+ method public androidx.ui.core.Constraints fixedWidth(androidx.ui.unit.IntPx width);
}
public final class ConstraintsKt {
@@ -84,17 +84,11 @@
method public static androidx.ui.core.Constraints enforce(androidx.ui.core.Constraints, androidx.ui.core.Constraints otherConstraints);
method public static boolean getHasBoundedHeight(androidx.ui.core.Constraints);
method public static boolean getHasBoundedWidth(androidx.ui.core.Constraints);
- method public static boolean getHasTightHeight(androidx.ui.core.Constraints);
- method public static boolean getHasTightWidth(androidx.ui.core.Constraints);
- method public static boolean isTight(androidx.ui.core.Constraints);
+ method public static boolean getHasFixedHeight(androidx.ui.core.Constraints);
+ method public static boolean getHasFixedWidth(androidx.ui.core.Constraints);
method public static boolean isZero(androidx.ui.core.Constraints);
- method public static androidx.ui.core.Constraints looseMax(androidx.ui.core.Constraints);
- method public static androidx.ui.core.Constraints looseMin(androidx.ui.core.Constraints);
method public static androidx.ui.core.Constraints offset(androidx.ui.core.Constraints, androidx.ui.unit.IntPx horizontal = 0.ipx, androidx.ui.unit.IntPx vertical = 0.ipx);
method public static boolean satisfiedBy(androidx.ui.core.Constraints, androidx.ui.unit.IntPxSize size);
- method public static androidx.ui.core.Constraints tightMax(androidx.ui.core.Constraints);
- method public static androidx.ui.core.Constraints tightMin(androidx.ui.core.Constraints);
- method public static androidx.ui.core.Constraints withTight(androidx.ui.core.Constraints, androidx.ui.unit.IntPx? width = null, androidx.ui.unit.IntPx? height = null);
}
public final class ConsumedData {
diff --git a/ui/ui-core/api/public_plus_experimental_0.1.0-dev04.txt b/ui/ui-core/api/public_plus_experimental_0.1.0-dev04.txt
index 6522680..c72417d 100644
--- a/ui/ui-core/api/public_plus_experimental_0.1.0-dev04.txt
+++ b/ui/ui-core/api/public_plus_experimental_0.1.0-dev04.txt
@@ -74,9 +74,9 @@
}
public static final class Constraints.Companion {
- method public androidx.ui.core.Constraints tightConstraints(androidx.ui.unit.IntPx width, androidx.ui.unit.IntPx height);
- method public androidx.ui.core.Constraints tightConstraintsForHeight(androidx.ui.unit.IntPx height);
- method public androidx.ui.core.Constraints tightConstraintsForWidth(androidx.ui.unit.IntPx width);
+ method public androidx.ui.core.Constraints fixed(androidx.ui.unit.IntPx width, androidx.ui.unit.IntPx height);
+ method public androidx.ui.core.Constraints fixedHeight(androidx.ui.unit.IntPx height);
+ method public androidx.ui.core.Constraints fixedWidth(androidx.ui.unit.IntPx width);
}
public final class ConstraintsKt {
@@ -84,17 +84,11 @@
method public static androidx.ui.core.Constraints enforce(androidx.ui.core.Constraints, androidx.ui.core.Constraints otherConstraints);
method public static boolean getHasBoundedHeight(androidx.ui.core.Constraints);
method public static boolean getHasBoundedWidth(androidx.ui.core.Constraints);
- method public static boolean getHasTightHeight(androidx.ui.core.Constraints);
- method public static boolean getHasTightWidth(androidx.ui.core.Constraints);
- method public static boolean isTight(androidx.ui.core.Constraints);
+ method public static boolean getHasFixedHeight(androidx.ui.core.Constraints);
+ method public static boolean getHasFixedWidth(androidx.ui.core.Constraints);
method public static boolean isZero(androidx.ui.core.Constraints);
- method public static androidx.ui.core.Constraints looseMax(androidx.ui.core.Constraints);
- method public static androidx.ui.core.Constraints looseMin(androidx.ui.core.Constraints);
method public static androidx.ui.core.Constraints offset(androidx.ui.core.Constraints, androidx.ui.unit.IntPx horizontal = 0.ipx, androidx.ui.unit.IntPx vertical = 0.ipx);
method public static boolean satisfiedBy(androidx.ui.core.Constraints, androidx.ui.unit.IntPxSize size);
- method public static androidx.ui.core.Constraints tightMax(androidx.ui.core.Constraints);
- method public static androidx.ui.core.Constraints tightMin(androidx.ui.core.Constraints);
- method public static androidx.ui.core.Constraints withTight(androidx.ui.core.Constraints, androidx.ui.unit.IntPx? width = null, androidx.ui.unit.IntPx? height = null);
}
public final class ConsumedData {
diff --git a/ui/ui-core/api/public_plus_experimental_current.txt b/ui/ui-core/api/public_plus_experimental_current.txt
index 6522680..c72417d 100644
--- a/ui/ui-core/api/public_plus_experimental_current.txt
+++ b/ui/ui-core/api/public_plus_experimental_current.txt
@@ -74,9 +74,9 @@
}
public static final class Constraints.Companion {
- method public androidx.ui.core.Constraints tightConstraints(androidx.ui.unit.IntPx width, androidx.ui.unit.IntPx height);
- method public androidx.ui.core.Constraints tightConstraintsForHeight(androidx.ui.unit.IntPx height);
- method public androidx.ui.core.Constraints tightConstraintsForWidth(androidx.ui.unit.IntPx width);
+ method public androidx.ui.core.Constraints fixed(androidx.ui.unit.IntPx width, androidx.ui.unit.IntPx height);
+ method public androidx.ui.core.Constraints fixedHeight(androidx.ui.unit.IntPx height);
+ method public androidx.ui.core.Constraints fixedWidth(androidx.ui.unit.IntPx width);
}
public final class ConstraintsKt {
@@ -84,17 +84,11 @@
method public static androidx.ui.core.Constraints enforce(androidx.ui.core.Constraints, androidx.ui.core.Constraints otherConstraints);
method public static boolean getHasBoundedHeight(androidx.ui.core.Constraints);
method public static boolean getHasBoundedWidth(androidx.ui.core.Constraints);
- method public static boolean getHasTightHeight(androidx.ui.core.Constraints);
- method public static boolean getHasTightWidth(androidx.ui.core.Constraints);
- method public static boolean isTight(androidx.ui.core.Constraints);
+ method public static boolean getHasFixedHeight(androidx.ui.core.Constraints);
+ method public static boolean getHasFixedWidth(androidx.ui.core.Constraints);
method public static boolean isZero(androidx.ui.core.Constraints);
- method public static androidx.ui.core.Constraints looseMax(androidx.ui.core.Constraints);
- method public static androidx.ui.core.Constraints looseMin(androidx.ui.core.Constraints);
method public static androidx.ui.core.Constraints offset(androidx.ui.core.Constraints, androidx.ui.unit.IntPx horizontal = 0.ipx, androidx.ui.unit.IntPx vertical = 0.ipx);
method public static boolean satisfiedBy(androidx.ui.core.Constraints, androidx.ui.unit.IntPxSize size);
- method public static androidx.ui.core.Constraints tightMax(androidx.ui.core.Constraints);
- method public static androidx.ui.core.Constraints tightMin(androidx.ui.core.Constraints);
- method public static androidx.ui.core.Constraints withTight(androidx.ui.core.Constraints, androidx.ui.unit.IntPx? width = null, androidx.ui.unit.IntPx? height = null);
}
public final class ConsumedData {
diff --git a/ui/ui-core/api/restricted_0.1.0-dev04.txt b/ui/ui-core/api/restricted_0.1.0-dev04.txt
index 6522680..c72417d 100644
--- a/ui/ui-core/api/restricted_0.1.0-dev04.txt
+++ b/ui/ui-core/api/restricted_0.1.0-dev04.txt
@@ -74,9 +74,9 @@
}
public static final class Constraints.Companion {
- method public androidx.ui.core.Constraints tightConstraints(androidx.ui.unit.IntPx width, androidx.ui.unit.IntPx height);
- method public androidx.ui.core.Constraints tightConstraintsForHeight(androidx.ui.unit.IntPx height);
- method public androidx.ui.core.Constraints tightConstraintsForWidth(androidx.ui.unit.IntPx width);
+ method public androidx.ui.core.Constraints fixed(androidx.ui.unit.IntPx width, androidx.ui.unit.IntPx height);
+ method public androidx.ui.core.Constraints fixedHeight(androidx.ui.unit.IntPx height);
+ method public androidx.ui.core.Constraints fixedWidth(androidx.ui.unit.IntPx width);
}
public final class ConstraintsKt {
@@ -84,17 +84,11 @@
method public static androidx.ui.core.Constraints enforce(androidx.ui.core.Constraints, androidx.ui.core.Constraints otherConstraints);
method public static boolean getHasBoundedHeight(androidx.ui.core.Constraints);
method public static boolean getHasBoundedWidth(androidx.ui.core.Constraints);
- method public static boolean getHasTightHeight(androidx.ui.core.Constraints);
- method public static boolean getHasTightWidth(androidx.ui.core.Constraints);
- method public static boolean isTight(androidx.ui.core.Constraints);
+ method public static boolean getHasFixedHeight(androidx.ui.core.Constraints);
+ method public static boolean getHasFixedWidth(androidx.ui.core.Constraints);
method public static boolean isZero(androidx.ui.core.Constraints);
- method public static androidx.ui.core.Constraints looseMax(androidx.ui.core.Constraints);
- method public static androidx.ui.core.Constraints looseMin(androidx.ui.core.Constraints);
method public static androidx.ui.core.Constraints offset(androidx.ui.core.Constraints, androidx.ui.unit.IntPx horizontal = 0.ipx, androidx.ui.unit.IntPx vertical = 0.ipx);
method public static boolean satisfiedBy(androidx.ui.core.Constraints, androidx.ui.unit.IntPxSize size);
- method public static androidx.ui.core.Constraints tightMax(androidx.ui.core.Constraints);
- method public static androidx.ui.core.Constraints tightMin(androidx.ui.core.Constraints);
- method public static androidx.ui.core.Constraints withTight(androidx.ui.core.Constraints, androidx.ui.unit.IntPx? width = null, androidx.ui.unit.IntPx? height = null);
}
public final class ConsumedData {
diff --git a/ui/ui-core/api/restricted_current.txt b/ui/ui-core/api/restricted_current.txt
index 6522680..c72417d 100644
--- a/ui/ui-core/api/restricted_current.txt
+++ b/ui/ui-core/api/restricted_current.txt
@@ -74,9 +74,9 @@
}
public static final class Constraints.Companion {
- method public androidx.ui.core.Constraints tightConstraints(androidx.ui.unit.IntPx width, androidx.ui.unit.IntPx height);
- method public androidx.ui.core.Constraints tightConstraintsForHeight(androidx.ui.unit.IntPx height);
- method public androidx.ui.core.Constraints tightConstraintsForWidth(androidx.ui.unit.IntPx width);
+ method public androidx.ui.core.Constraints fixed(androidx.ui.unit.IntPx width, androidx.ui.unit.IntPx height);
+ method public androidx.ui.core.Constraints fixedHeight(androidx.ui.unit.IntPx height);
+ method public androidx.ui.core.Constraints fixedWidth(androidx.ui.unit.IntPx width);
}
public final class ConstraintsKt {
@@ -84,17 +84,11 @@
method public static androidx.ui.core.Constraints enforce(androidx.ui.core.Constraints, androidx.ui.core.Constraints otherConstraints);
method public static boolean getHasBoundedHeight(androidx.ui.core.Constraints);
method public static boolean getHasBoundedWidth(androidx.ui.core.Constraints);
- method public static boolean getHasTightHeight(androidx.ui.core.Constraints);
- method public static boolean getHasTightWidth(androidx.ui.core.Constraints);
- method public static boolean isTight(androidx.ui.core.Constraints);
+ method public static boolean getHasFixedHeight(androidx.ui.core.Constraints);
+ method public static boolean getHasFixedWidth(androidx.ui.core.Constraints);
method public static boolean isZero(androidx.ui.core.Constraints);
- method public static androidx.ui.core.Constraints looseMax(androidx.ui.core.Constraints);
- method public static androidx.ui.core.Constraints looseMin(androidx.ui.core.Constraints);
method public static androidx.ui.core.Constraints offset(androidx.ui.core.Constraints, androidx.ui.unit.IntPx horizontal = 0.ipx, androidx.ui.unit.IntPx vertical = 0.ipx);
method public static boolean satisfiedBy(androidx.ui.core.Constraints, androidx.ui.unit.IntPxSize size);
- method public static androidx.ui.core.Constraints tightMax(androidx.ui.core.Constraints);
- method public static androidx.ui.core.Constraints tightMin(androidx.ui.core.Constraints);
- method public static androidx.ui.core.Constraints withTight(androidx.ui.core.Constraints, androidx.ui.unit.IntPx? width = null, androidx.ui.unit.IntPx? height = null);
}
public final class ConsumedData {
diff --git a/ui/ui-core/src/main/java/androidx/ui/core/Constraints.kt b/ui/ui-core/src/main/java/androidx/ui/core/Constraints.kt
index 83cf619..27c3273 100644
--- a/ui/ui-core/src/main/java/androidx/ui/core/Constraints.kt
+++ b/ui/ui-core/src/main/java/androidx/ui/core/Constraints.kt
@@ -26,17 +26,17 @@
/**
* Immutable constraints used for measuring child [Layout]s. A parent [Layout]
- * can measure their children using the [measure] method on the corresponding [Measurable]s,
- * method which takes the [Constraints] the child has to follow. A [measure]d child is then
- * responsible to choose for themselves and return a size which satisfies the received set
- * of [Constraints]:
+ * can measure their children using the measure method on the corresponding [Measurable]s,
+ * method which takes the [Constraints] the child has to follow. A measured child is then
+ * responsible to choose for themselves and return a size which satisfies the set of [Constraints]
+ * received from their parent:
* - minWidth <= chosenWidth <= maxWidth
* - minHeight <= chosenHeight <= maxHeight
* The parent can then access the child chosen size on the resulting [Placeable]. The parent is
* responsible of defining a valid positioning of the children according to their sizes, so the
* parent needs to measure the children with appropriate [Constraints], such that whatever valid
* sizes children choose, they can be laid out in a way that also respects the parent's incoming
- * [Constraints]. Note that different children can be [measure]d with different [Constraints].
+ * [Constraints]. Note that different children can be measured with different [Constraints].
* A set of [Constraints] can have infinite maxWidth and/or maxHeight. This is a trick often
* used by parents to ask their children for their preferred size: unbounded constraints force
* children whose default behavior is to fill the available space (always size to
@@ -70,15 +70,14 @@
companion object {
/**
- * Creates constraints tight in both dimensions.
+ * Creates constraints for fixed size in both dimensions.
*/
- fun tightConstraints(width: IntPx, height: IntPx) =
- Constraints(width, width, height, height)
+ fun fixed(width: IntPx, height: IntPx) = Constraints(width, width, height, height)
/**
- * Creates constraints with tight width and loose height.
+ * Creates constraints for fixed width and unspecified height.
*/
- fun tightConstraintsForWidth(width: IntPx) = Constraints(
+ fun fixedWidth(width: IntPx) = Constraints(
minWidth = width,
maxWidth = width,
minHeight = IntPx.Zero,
@@ -86,9 +85,9 @@
)
/**
- * Creates constraints with tight height and loose width.
+ * Creates constraints for fixed height and unspecified width.
*/
- fun tightConstraintsForHeight(height: IntPx) = Constraints(
+ fun fixedHeight(height: IntPx) = Constraints(
minWidth = IntPx.Zero,
maxWidth = IntPx.Infinity,
minHeight = height,
@@ -110,24 +109,18 @@
val Constraints.hasBoundedWidth get() = maxWidth.isFinite()
/**
- * Whether there is exactly one size that satisfies the constraints.
- * @see hasTightHeight
- * @see hasTightWidth
- */
-val Constraints.isTight get() = minWidth == maxWidth && minHeight == maxHeight
-
-/**
* Whether there is exactly one width value that satisfies the constraints.
*/
-val Constraints.hasTightWidth get() = maxWidth == minWidth
+val Constraints.hasFixedWidth get() = maxWidth == minWidth
/**
* Whether there is exactly one height value that satisfies the constraints.
*/
-val Constraints.hasTightHeight get() = maxHeight == minHeight
+val Constraints.hasFixedHeight get() = maxHeight == minHeight
/**
- * Whether there is exactly one height value that satisfies the constraints.
+ * Whether the area of a component respecting these constraints will definitely be 0.
+ * This is true when at least one of maxWidth and maxHeight are 0.
*/
val Constraints.isZero get() = maxWidth == IntPx.Zero || maxHeight == IntPx.Zero
@@ -142,16 +135,6 @@
)
/**
- * Returns a copy of the current instance, overriding the specified values to be tight.
- */
-fun Constraints.withTight(width: IntPx? = null, height: IntPx? = null) = Constraints(
- minWidth = width ?: this.minWidth,
- maxWidth = width ?: this.maxWidth,
- minHeight = height ?: this.minHeight,
- maxHeight = height ?: this.maxHeight
-)
-
-/**
* Takes a size and returns the closest size to it that satisfies the constraints.
*/
fun Constraints.constrain(size: IntPxSize) = IntPxSize(
@@ -167,30 +150,6 @@
minHeight <= size.height && size.height <= maxHeight
/**
- * Returns a copy of the current instance with no min constraints.
- */
-fun Constraints.looseMin() = this.copy(minWidth = 0.ipx, minHeight = 0.ipx)
-
-/**
- * Returns a copy of the current instance with no max constraints.
- */
-fun Constraints.looseMax() = this.copy(maxWidth = IntPx.Infinity, maxHeight = IntPx.Infinity)
-
-/**
- * Returns a copy of the current instance with the constraints tightened to their smallest size.
- */
-fun Constraints.tightMin() = this.withTight(width = minWidth, height = minHeight)
-
-/**
- * Returns a copy of the current instance with the constraints tightened to their largest size.
- * Note that if any of the constraints are unbounded, they will be left unchanged.
- */
-fun Constraints.tightMax() = this.copy(
- minWidth = if (hasBoundedWidth) maxWidth else minWidth,
- minHeight = if (hasBoundedHeight) maxHeight else minHeight
-)
-
-/**
* Returns the Constraints obtained by offsetting the current instance with the given values.
*/
fun Constraints.offset(horizontal: IntPx = 0.ipx, vertical: IntPx = 0.ipx) = Constraints(
diff --git a/ui/ui-core/src/test/java/androidx/ui/core/ConstraintsTest.kt b/ui/ui-core/src/test/java/androidx/ui/core/ConstraintsTest.kt
index 1f68ddc..79aa819 100644
--- a/ui/ui-core/src/test/java/androidx/ui/core/ConstraintsTest.kt
+++ b/ui/ui-core/src/test/java/androidx/ui/core/ConstraintsTest.kt
@@ -39,13 +39,13 @@
val constraints = Constraints(0.ipx, 1.ipx, 2.ipx, 3.ipx)
constraints.assertEquals(0.ipx, 1.ipx, 2.ipx, 3.ipx)
- val tightConstraintsForWidth = Constraints.tightConstraintsForWidth(5.ipx)
+ val tightConstraintsForWidth = Constraints.fixedWidth(5.ipx)
tightConstraintsForWidth.assertEquals(5.ipx, 5.ipx, IntPx.Zero, IntPx.Infinity)
- val tightConstraintsForHeight = Constraints.tightConstraintsForHeight(5.ipx)
+ val tightConstraintsForHeight = Constraints.fixedHeight(5.ipx)
tightConstraintsForHeight.assertEquals(IntPx.Zero, IntPx.Infinity, 5.ipx, 5.ipx)
- val tightConstraints = Constraints.tightConstraints(5.ipx, 7.ipx)
+ val tightConstraints = Constraints.fixed(5.ipx, 7.ipx)
tightConstraints.assertEquals(5.ipx, 5.ipx, 7.ipx, 7.ipx)
}
@@ -61,16 +61,14 @@
}
@Test
- fun hasTightDimensions() {
+ fun hasFixedDimensions() {
val untight = Constraints(3.ipx, 4.ipx, 8.ipx, 9.ipx)
- assertFalse(untight.hasTightWidth)
- assertFalse(untight.hasTightHeight)
- assertFalse(untight.isTight)
+ assertFalse(untight.hasFixedWidth)
+ assertFalse(untight.hasFixedHeight)
val tight = Constraints(3.ipx, 3.ipx, 5.ipx, 5.ipx)
- assertTrue(tight.hasTightWidth)
- assertTrue(tight.hasTightHeight)
- assertTrue(tight.isTight)
+ assertTrue(tight.hasFixedWidth)
+ assertTrue(tight.hasFixedHeight)
}
@Test
@@ -100,13 +98,6 @@
}
@Test
- fun withTight() {
- val constraints = Constraints(2.ipx, 3.ipx, 2.ipx, 3.ipx)
- constraints.withTight().assertEquals(2.ipx, 3.ipx, 2.ipx, 3.ipx)
- constraints.withTight(7.ipx, 8.ipx).assertEquals(7.ipx, 7.ipx, 8.ipx, 8.ipx)
- }
-
- @Test
fun constrain() {
val constraints = Constraints(2.ipx, 5.ipx, 2.ipx, 5.ipx)
assertEquals(IntPxSize(2.ipx, 2.ipx), constraints.constrain(IntPxSize(1.ipx, 1.ipx)))
@@ -127,28 +118,6 @@
}
@Test
- fun loose() {
- val bounded = Constraints(2.ipx, 5.ipx, 2.ipx, 5.ipx)
- bounded.looseMin().assertEquals(0.ipx, 5.ipx, 0.ipx, 5.ipx)
- bounded.looseMax().assertEquals(2.ipx, IntPx.Infinity, 2.ipx, IntPx.Infinity)
-
- val unbounded = Constraints(2.ipx, IntPx.Infinity, 2.ipx, IntPx.Infinity)
- unbounded.looseMin().assertEquals(0.ipx, IntPx.Infinity, 0.ipx, IntPx.Infinity)
- unbounded.looseMax().assertEquals(2.ipx, IntPx.Infinity, 2.ipx, IntPx.Infinity)
- }
-
- @Test
- fun tight() {
- val bounded = Constraints(2.ipx, 5.ipx, 2.ipx, 5.ipx)
- bounded.tightMin().assertEquals(2.ipx, 2.ipx, 2.ipx, 2.ipx)
- bounded.tightMax().assertEquals(5.ipx, 5.ipx, 5.ipx, 5.ipx)
-
- val unbounded = Constraints(2.ipx, IntPx.Infinity, 2.ipx, IntPx.Infinity)
- unbounded.tightMin().assertEquals(2.ipx, 2.ipx, 2.ipx, 2.ipx)
- unbounded.tightMax().assertEquals(2.ipx, IntPx.Infinity, 2.ipx, IntPx.Infinity)
- }
-
- @Test
fun offset() {
val constraints = Constraints(2.ipx, 2.ipx, 5.ipx, 5.ipx)
constraints.offset(horizontal = 2.ipx, vertical = 3.ipx).assertEquals(
diff --git a/ui/ui-framework/integration-tests/framework-demos/src/main/java/androidx/ui/framework/demos/MultipleCollect.kt b/ui/ui-framework/integration-tests/framework-demos/src/main/java/androidx/ui/framework/demos/MultipleCollect.kt
index 5d5677b..176e918 100644
--- a/ui/ui-framework/integration-tests/framework-demos/src/main/java/androidx/ui/framework/demos/MultipleCollect.kt
+++ b/ui/ui-framework/integration-tests/framework-demos/src/main/java/androidx/ui/framework/demos/MultipleCollect.kt
@@ -78,17 +78,17 @@
)
}) { measurables, constraints ->
val headerPlaceable = measurables.first { it.tag == "header" }.measure(
- Constraints.tightConstraints(constraints.maxWidth, 100.ipx)
+ Constraints.fixed(constraints.maxWidth, 100.ipx)
)
val footerPadding = 50.ipx
val footerPlaceable = measurables.first { it.tag == "footer" }.measure(
- Constraints.tightConstraints(constraints.maxWidth - footerPadding * 2, 100.ipx)
+ Constraints.fixed(constraints.maxWidth - footerPadding * 2, 100.ipx)
)
val itemHeight =
(constraints.maxHeight - headerPlaceable.height - footerPlaceable.height) /
measurables.filter { it.tag == "content" }.size
val contentPlaceables = measurables.filter { it.tag == "content" }.map { measurable ->
- measurable.measure(Constraints.tightConstraints(constraints.maxWidth, itemHeight))
+ measurable.measure(Constraints.fixed(constraints.maxWidth, itemHeight))
}
layout(constraints.maxWidth, constraints.maxHeight) {
diff --git a/ui/ui-framework/integration-tests/samples/src/main/java/androidx/ui/framework/samples/LayoutSample.kt b/ui/ui-framework/integration-tests/samples/src/main/java/androidx/ui/framework/samples/LayoutSample.kt
index 3278903..8d75bc0 100644
--- a/ui/ui-framework/integration-tests/samples/src/main/java/androidx/ui/framework/samples/LayoutSample.kt
+++ b/ui/ui-framework/integration-tests/samples/src/main/java/androidx/ui/framework/samples/LayoutSample.kt
@@ -108,7 +108,7 @@
val placeables = measurables.map { measurable ->
when (measurable.tag) {
// You should use appropriate constraints. Here we measure with dummy constraints.
- "header" -> measurable.measure(Constraints.tightConstraints(100.ipx, 100.ipx))
+ "header" -> measurable.measure(Constraints.fixed(100.ipx, 100.ipx))
"footer" -> measurable.measure(constraints)
else -> error("Unexpected tag")
}
diff --git a/ui/ui-framework/src/androidTest/java/androidx/ui/core/PopupTest.kt b/ui/ui-framework/src/androidTest/java/androidx/ui/core/PopupTest.kt
index 5f88291..deae4ca1 100644
--- a/ui/ui-framework/src/androidTest/java/androidx/ui/core/PopupTest.kt
+++ b/ui/ui-framework/src/androidTest/java/androidx/ui/core/PopupTest.kt
@@ -29,6 +29,7 @@
import androidx.ui.unit.IntPx
import androidx.ui.unit.IntPxPosition
import androidx.ui.unit.IntPxSize
+import androidx.ui.unit.ipx
import androidx.ui.unit.isFinite
import androidx.ui.unit.toPxPosition
import androidx.ui.unit.toPxSize
@@ -557,7 +558,7 @@
Layout(children) { measurables, constraints ->
val measurable = measurables.firstOrNull()
// The child cannot be larger than our max constraints, but we ignore min constraints.
- val placeable = measurable?.measure(constraints.looseMin())
+ val placeable = measurable?.measure(constraints.copy(minWidth = 0.ipx, minHeight = 0.ipx))
// The layout is as large as possible for bounded constraints,
// or wrap content otherwise.
diff --git a/ui/ui-framework/src/androidTest/java/androidx/ui/core/TextLayoutTest.kt b/ui/ui-framework/src/androidTest/java/androidx/ui/core/TextLayoutTest.kt
index adead6a..e3540d0 100644
--- a/ui/ui-framework/src/androidTest/java/androidx/ui/core/TextLayoutTest.kt
+++ b/ui/ui-framework/src/androidTest/java/androidx/ui/core/TextLayoutTest.kt
@@ -180,7 +180,9 @@
override fun run() {
activity.setContent {
Layout(composable) { measurables, constraints ->
- val placeables = measurables.map { it.measure(constraints.looseMin()) }
+ val placeables = measurables.map {
+ it.measure(constraints.copy(minWidth = 0.ipx, minHeight = 0.ipx))
+ }
layout(constraints.maxWidth, constraints.maxHeight) {
var top = 0.px
placeables.forEach {
diff --git a/ui/ui-framework/src/androidTest/java/androidx/ui/core/test/AndroidLayoutDrawTest.kt b/ui/ui-framework/src/androidTest/java/androidx/ui/core/test/AndroidLayoutDrawTest.kt
index e05f728..eed565f 100644
--- a/ui/ui-framework/src/androidTest/java/androidx/ui/core/test/AndroidLayoutDrawTest.kt
+++ b/ui/ui-framework/src/androidTest/java/androidx/ui/core/test/AndroidLayoutDrawTest.kt
@@ -53,7 +53,6 @@
import androidx.ui.core.draw
import androidx.ui.core.drawWithContent
import androidx.ui.core.globalPosition
-import androidx.ui.core.looseMin
import androidx.ui.core.offset
import androidx.ui.core.setContent
import androidx.ui.core.tag
@@ -392,8 +391,8 @@
val childrenCount = 3
val childConstraints = arrayOf(
Constraints(),
- Constraints.tightConstraintsForWidth(50.ipx),
- Constraints.tightConstraintsForHeight(50.ipx)
+ Constraints.fixedWidth(50.ipx),
+ Constraints.fixedHeight(50.ipx)
)
val headerChildrenCount = 1
val footerChildrenCount = 2
@@ -2024,7 +2023,7 @@
private val AlignTopLeft = object : LayoutModifier {
override fun DensityScope.modifyConstraints(constraints: Constraints) =
- constraints.looseMin()
+ constraints.copy(minWidth = 0.ipx, minHeight = 0.ipx)
override fun DensityScope.modifySize(
constraints: Constraints,
childSize: IntPxSize
@@ -2257,7 +2256,7 @@
children: @Composable() () -> Unit = {}
) {
Layout(children = children, modifier = modifier) { measurables, _ ->
- val newConstraints = Constraints.tightConstraints(size, size)
+ val newConstraints = Constraints.fixed(size, size)
val placeables = measurables.map { m ->
m.measure(newConstraints)
}
@@ -2335,7 +2334,7 @@
Layout(children = children) { measurables, _ ->
val testConstraints = Constraints()
measurables.forEach { it.measure(testConstraints) }
- val childConstraints = Constraints.tightConstraints(size, size)
+ val childConstraints = Constraints.fixed(size, size)
try {
val placeables2 = measurables.map { it.measure(childConstraints) }
fail("Measuring twice on the same Measurable should throw an exception")
@@ -2636,7 +2635,7 @@
}
override fun DensityScope.modifyConstraints(constraints: Constraints): Constraints {
- return Constraints.tightConstraints(10.ipx, 10.ipx)
+ return Constraints.fixed(10.ipx, 10.ipx)
}
override fun DensityScope.modifySize(
diff --git a/ui/ui-framework/src/androidTest/java/androidx/ui/core/test/WithConstraintsTest.kt b/ui/ui-framework/src/androidTest/java/androidx/ui/core/test/WithConstraintsTest.kt
index e333ff6..c232ebe 100644
--- a/ui/ui-framework/src/androidTest/java/androidx/ui/core/test/WithConstraintsTest.kt
+++ b/ui/ui-framework/src/androidTest/java/androidx/ui/core/test/WithConstraintsTest.kt
@@ -144,7 +144,7 @@
}
}) { measurables, constraints3 ->
val placeable = measurables[0].measure(
- Constraints.tightConstraints(
+ Constraints.fixed(
model.size,
model.size
)
@@ -283,13 +283,13 @@
}
}
assertTrue(latch.await(1, TimeUnit.SECONDS))
- assertEquals(Constraints.tightConstraints(50.ipx, 50.ipx), actualConstraints)
+ assertEquals(Constraints.fixed(50.ipx, 50.ipx), actualConstraints)
latch = CountDownLatch(1)
rule.runOnUiThread { model.value = 100.ipx }
assertTrue(latch.await(1, TimeUnit.SECONDS))
- assertEquals(Constraints.tightConstraints(100.ipx, 100.ipx), actualConstraints)
+ assertEquals(Constraints.fixed(100.ipx, 100.ipx), actualConstraints)
}
@Test
@@ -535,7 +535,7 @@
private fun ChangingConstraintsLayout(size: ValueModel<IntPx>, children: @Composable() () -> Unit) {
Layout(children) { measurables, _ ->
layout(100.ipx, 100.ipx) {
- val constraints = Constraints.tightConstraints(size.value, size.value)
+ val constraints = Constraints.fixed(size.value, size.value)
measurables.first().measure(constraints).place(0.ipx, 0.ipx)
}
}
diff --git a/ui/ui-framework/src/main/java/androidx/ui/core/TextFieldDelegate.kt b/ui/ui-framework/src/main/java/androidx/ui/core/TextFieldDelegate.kt
index 7ac3bc3..84a3909 100644
--- a/ui/ui-framework/src/main/java/androidx/ui/core/TextFieldDelegate.kt
+++ b/ui/ui-framework/src/main/java/androidx/ui/core/TextFieldDelegate.kt
@@ -104,7 +104,7 @@
): Triple<IntPx, IntPx, TextLayoutResult> {
val layoutResult = if (constraints.maxWidth.isFinite()) {
textDelegate.layout(
- Constraints.tightConstraintsForWidth(constraints.maxWidth),
+ Constraints.fixedWidth(constraints.maxWidth),
prevResultText
)
} else {
@@ -112,7 +112,7 @@
// falling back to wrap-content behavior since it may be in the horizontal scroller.
textDelegate.layoutIntrinsics()
textDelegate.layout(
- Constraints.tightConstraintsForWidth(textDelegate.maxIntrinsicWidth),
+ Constraints.fixedWidth(textDelegate.maxIntrinsicWidth),
prevResultText
)
}
diff --git a/ui/ui-framework/src/main/java/androidx/ui/core/selection/SelectionContainer.kt b/ui/ui-framework/src/main/java/androidx/ui/core/selection/SelectionContainer.kt
index 7b16ba5..7f8a404 100644
--- a/ui/ui-framework/src/main/java/androidx/ui/core/selection/SelectionContainer.kt
+++ b/ui/ui-framework/src/main/java/androidx/ui/core/selection/SelectionContainer.kt
@@ -29,10 +29,8 @@
import androidx.ui.core.gesture.LongPressDragGestureDetector
import androidx.ui.core.gesture.PressReleasedGestureDetector
import androidx.ui.core.gesture.TouchSlopDragGestureDetector
-import androidx.ui.core.hasTightHeight
-import androidx.ui.core.hasTightWidth
-import androidx.ui.core.looseMin
-import androidx.ui.core.withTight
+import androidx.ui.core.hasFixedHeight
+import androidx.ui.core.hasFixedWidth
import androidx.ui.unit.Dp
import androidx.ui.unit.IntPx
import androidx.ui.unit.IntPxPosition
@@ -187,12 +185,17 @@
) {
Layout(children) { measurables, incomingConstraints ->
val containerConstraints = Constraints()
- .withTight(width?.toIntPx(), height?.toIntPx())
+ .copy(
+ width?.toIntPx() ?: 0.ipx,
+ width?.toIntPx() ?: IntPx.Infinity,
+ height?.toIntPx() ?: 0.ipx,
+ height?.toIntPx() ?: IntPx.Infinity
+ )
.enforce(incomingConstraints)
- val childConstraints = containerConstraints.looseMin()
+ val childConstraints = containerConstraints.copy(minWidth = 0.ipx, minHeight = 0.ipx)
var placeable: Placeable? = null
val containerWidth = if (
- containerConstraints.hasTightWidth &&
+ containerConstraints.hasFixedWidth &&
containerConstraints.maxWidth.isFinite()
) {
containerConstraints.maxWidth
@@ -201,7 +204,7 @@
max((placeable?.width ?: 0.ipx), containerConstraints.minWidth)
}
val containerHeight = if (
- containerConstraints.hasTightHeight &&
+ containerConstraints.hasFixedHeight &&
containerConstraints.maxHeight.isFinite()
) {
containerConstraints.maxHeight
diff --git a/ui/ui-framework/src/main/java/androidx/ui/core/selection/SelectionHandles.kt b/ui/ui-framework/src/main/java/androidx/ui/core/selection/SelectionHandles.kt
index 0d69168..b94ad32 100644
--- a/ui/ui-framework/src/main/java/androidx/ui/core/selection/SelectionHandles.kt
+++ b/ui/ui-framework/src/main/java/androidx/ui/core/selection/SelectionHandles.kt
@@ -21,7 +21,6 @@
import androidx.ui.core.Constraints
import androidx.ui.core.Draw
import androidx.ui.core.Layout
-import androidx.ui.core.withTight
import androidx.ui.geometry.Rect
import androidx.ui.graphics.Color
import androidx.ui.graphics.Paint
@@ -81,7 +80,7 @@
children: @Composable() () -> Unit
) {
Layout(children) { measurables, _ ->
- val constraints = Constraints().withTight(width.toIntPx(), height.toIntPx())
+ val constraints = Constraints.fixed(width.toIntPx(), height.toIntPx())
val placeables = measurables.map { measurable ->
measurable.measure(constraints)
}
diff --git a/ui/ui-framework/src/test/java/androidx/ui/core/TextFieldDelegateTest.kt b/ui/ui-framework/src/test/java/androidx/ui/core/TextFieldDelegateTest.kt
index 54880f5..147c8ee 100644
--- a/ui/ui-framework/src/test/java/androidx/ui/core/TextFieldDelegateTest.kt
+++ b/ui/ui-framework/src/test/java/androidx/ui/core/TextFieldDelegateTest.kt
@@ -498,6 +498,6 @@
assertThat(res.first).isEqualTo(123.ipx)
assertEquals(512.ipx, res.second)
- verify(mDelegate, times(1)).layout(Constraints.tightConstraintsForWidth(123.ipx))
+ verify(mDelegate, times(1)).layout(Constraints.fixedWidth(123.ipx))
}
}
diff --git a/ui/ui-layout/api/0.1.0-dev04.txt b/ui/ui-layout/api/0.1.0-dev04.txt
index 62add70..581a9dc 100644
--- a/ui/ui-layout/api/0.1.0-dev04.txt
+++ b/ui/ui-layout/api/0.1.0-dev04.txt
@@ -136,8 +136,6 @@
@androidx.ui.layout.LayoutScopeMarker public abstract sealed class FlexScope {
method public final androidx.ui.core.ParentDataModifier LayoutFlexible(@FloatRange(from=0.0, fromInclusive=false) float flex, boolean tight = true);
method public final androidx.ui.core.ParentDataModifier RelativeToSiblings(androidx.ui.layout.LayoutGravity, kotlin.jvm.functions.Function1<? super androidx.ui.core.Placeable,androidx.ui.unit.IntPx> alignmentLineBlock);
- method public final androidx.ui.core.ParentDataModifier getLayoutInflexible();
- property public final androidx.ui.core.ParentDataModifier LayoutInflexible;
}
public enum FlowCrossAxisAlignment {
diff --git a/ui/ui-layout/api/current.txt b/ui/ui-layout/api/current.txt
index 62add70..581a9dc 100644
--- a/ui/ui-layout/api/current.txt
+++ b/ui/ui-layout/api/current.txt
@@ -136,8 +136,6 @@
@androidx.ui.layout.LayoutScopeMarker public abstract sealed class FlexScope {
method public final androidx.ui.core.ParentDataModifier LayoutFlexible(@FloatRange(from=0.0, fromInclusive=false) float flex, boolean tight = true);
method public final androidx.ui.core.ParentDataModifier RelativeToSiblings(androidx.ui.layout.LayoutGravity, kotlin.jvm.functions.Function1<? super androidx.ui.core.Placeable,androidx.ui.unit.IntPx> alignmentLineBlock);
- method public final androidx.ui.core.ParentDataModifier getLayoutInflexible();
- property public final androidx.ui.core.ParentDataModifier LayoutInflexible;
}
public enum FlowCrossAxisAlignment {
diff --git a/ui/ui-layout/api/public_plus_experimental_0.1.0-dev04.txt b/ui/ui-layout/api/public_plus_experimental_0.1.0-dev04.txt
index 62add70..581a9dc 100644
--- a/ui/ui-layout/api/public_plus_experimental_0.1.0-dev04.txt
+++ b/ui/ui-layout/api/public_plus_experimental_0.1.0-dev04.txt
@@ -136,8 +136,6 @@
@androidx.ui.layout.LayoutScopeMarker public abstract sealed class FlexScope {
method public final androidx.ui.core.ParentDataModifier LayoutFlexible(@FloatRange(from=0.0, fromInclusive=false) float flex, boolean tight = true);
method public final androidx.ui.core.ParentDataModifier RelativeToSiblings(androidx.ui.layout.LayoutGravity, kotlin.jvm.functions.Function1<? super androidx.ui.core.Placeable,androidx.ui.unit.IntPx> alignmentLineBlock);
- method public final androidx.ui.core.ParentDataModifier getLayoutInflexible();
- property public final androidx.ui.core.ParentDataModifier LayoutInflexible;
}
public enum FlowCrossAxisAlignment {
diff --git a/ui/ui-layout/api/public_plus_experimental_current.txt b/ui/ui-layout/api/public_plus_experimental_current.txt
index 62add70..581a9dc 100644
--- a/ui/ui-layout/api/public_plus_experimental_current.txt
+++ b/ui/ui-layout/api/public_plus_experimental_current.txt
@@ -136,8 +136,6 @@
@androidx.ui.layout.LayoutScopeMarker public abstract sealed class FlexScope {
method public final androidx.ui.core.ParentDataModifier LayoutFlexible(@FloatRange(from=0.0, fromInclusive=false) float flex, boolean tight = true);
method public final androidx.ui.core.ParentDataModifier RelativeToSiblings(androidx.ui.layout.LayoutGravity, kotlin.jvm.functions.Function1<? super androidx.ui.core.Placeable,androidx.ui.unit.IntPx> alignmentLineBlock);
- method public final androidx.ui.core.ParentDataModifier getLayoutInflexible();
- property public final androidx.ui.core.ParentDataModifier LayoutInflexible;
}
public enum FlowCrossAxisAlignment {
diff --git a/ui/ui-layout/api/restricted_0.1.0-dev04.txt b/ui/ui-layout/api/restricted_0.1.0-dev04.txt
index 62add70..581a9dc 100644
--- a/ui/ui-layout/api/restricted_0.1.0-dev04.txt
+++ b/ui/ui-layout/api/restricted_0.1.0-dev04.txt
@@ -136,8 +136,6 @@
@androidx.ui.layout.LayoutScopeMarker public abstract sealed class FlexScope {
method public final androidx.ui.core.ParentDataModifier LayoutFlexible(@FloatRange(from=0.0, fromInclusive=false) float flex, boolean tight = true);
method public final androidx.ui.core.ParentDataModifier RelativeToSiblings(androidx.ui.layout.LayoutGravity, kotlin.jvm.functions.Function1<? super androidx.ui.core.Placeable,androidx.ui.unit.IntPx> alignmentLineBlock);
- method public final androidx.ui.core.ParentDataModifier getLayoutInflexible();
- property public final androidx.ui.core.ParentDataModifier LayoutInflexible;
}
public enum FlowCrossAxisAlignment {
diff --git a/ui/ui-layout/api/restricted_current.txt b/ui/ui-layout/api/restricted_current.txt
index 62add70..581a9dc 100644
--- a/ui/ui-layout/api/restricted_current.txt
+++ b/ui/ui-layout/api/restricted_current.txt
@@ -136,8 +136,6 @@
@androidx.ui.layout.LayoutScopeMarker public abstract sealed class FlexScope {
method public final androidx.ui.core.ParentDataModifier LayoutFlexible(@FloatRange(from=0.0, fromInclusive=false) float flex, boolean tight = true);
method public final androidx.ui.core.ParentDataModifier RelativeToSiblings(androidx.ui.layout.LayoutGravity, kotlin.jvm.functions.Function1<? super androidx.ui.core.Placeable,androidx.ui.unit.IntPx> alignmentLineBlock);
- method public final androidx.ui.core.ParentDataModifier getLayoutInflexible();
- property public final androidx.ui.core.ParentDataModifier LayoutInflexible;
}
public enum FlowCrossAxisAlignment {
diff --git a/ui/ui-layout/integration-tests/samples/src/main/java/androidx/ui/layout/samples/FlexSample.kt b/ui/ui-layout/integration-tests/samples/src/main/java/androidx/ui/layout/samples/FlexSample.kt
index 18f02be1..b2269af 100644
--- a/ui/ui-layout/integration-tests/samples/src/main/java/androidx/ui/layout/samples/FlexSample.kt
+++ b/ui/ui-layout/integration-tests/samples/src/main/java/androidx/ui/layout/samples/FlexSample.kt
@@ -34,11 +34,8 @@
@Composable
fun SimpleRow() {
Row {
- // The child with no flexibility modifier is inflexible by default, will have the specified
- // size.
+ // The child with no flexibility modifier is inflexible and will have the specified size.
SizedRectangle(color = Color.Magenta, width = 40.dp, height = 80.dp)
- // Inflexible, the child will have the specified size.
- SizedRectangle(LayoutInflexible, color = Color.Red, width = 80.dp, height = 40.dp)
// Flexible, the child will occupy have of the remaining width.
SizedRectangle(LayoutFlexible(1f), color = Color.Yellow, height = 40.dp)
// Flexible not tight, the child will occupy at most half of the remaining width.
@@ -50,11 +47,8 @@
@Composable
fun SimpleColumn() {
Column {
- // The child with no flexibility modifier is inflexible by default, will have the specified
- // size.
+ // The child with no flexibility modifier is inflexible and will have the specified size.
SizedRectangle(color = Color.Magenta, width = 40.dp, height = 80.dp)
- // Inflexible, the child will have the specified size.
- SizedRectangle(LayoutInflexible, color = Color.Red, width = 80.dp, height = 40.dp)
// Flexible, the child will occupy have of the remaining height.
SizedRectangle(LayoutFlexible(1f), color = Color.Yellow, width = 40.dp)
// Flexible not tight, the child will occupy at most half of the remaining height.
diff --git a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/FlexTest.kt b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/FlexTest.kt
index b83484e..669bef2 100644
--- a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/FlexTest.kt
+++ b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/FlexTest.kt
@@ -49,6 +49,7 @@
import androidx.ui.layout.Wrap
import androidx.ui.unit.Dp
import androidx.ui.unit.IntPx
+import androidx.ui.unit.Px
import androidx.ui.unit.PxPosition
import androidx.ui.unit.PxSize
import androidx.ui.unit.dp
@@ -2898,30 +2899,29 @@
@Test
fun testFlexModifiersChain_leftMostWins() = withDensity(density) {
val positionedLatch = CountDownLatch(1)
- val containerSize = Ref<PxSize>()
- val containerPosition = Ref<PxPosition>()
- val sizeIntPx = 40.dp.toIntPx()
+ val containerHeight = Ref<Px>()
+ val columnHeight = 24.ipx
show {
Align(Alignment.TopLeft) {
- Column(LayoutHeight.Fill) {
+ Column(LayoutHeight(columnHeight.toDp())) {
OnChildPositioned(onPositioned = { coordinates ->
- containerSize.value = coordinates.size
- containerPosition.value = coordinates.localToGlobal(PxPosition(0.px, 0.px))
+ containerHeight.value = coordinates.size.height
positionedLatch.countDown()
}) {
Container(
- LayoutInflexible + LayoutFlexible(1f),
- width = 40.dp, height = 40.dp) {}
+ LayoutFlexible(2f) + LayoutFlexible(1f)
+ ) {}
}
+ Container(LayoutFlexible(1f)) {}
}
}
}
positionedLatch.await(1, TimeUnit.SECONDS)
- assertNotNull(containerSize)
- assertEquals(PxSize(sizeIntPx, sizeIntPx), containerSize.value)
+ assertNotNull(containerHeight.value)
+ Assert.assertEquals(columnHeight.toPx() * 2 / 3, containerHeight.value)
}
@Test
diff --git a/ui/ui-layout/src/main/java/androidx/ui/layout/Align.kt b/ui/ui-layout/src/main/java/androidx/ui/layout/Align.kt
index 63ee82d..f30c91c 100644
--- a/ui/ui-layout/src/main/java/androidx/ui/layout/Align.kt
+++ b/ui/ui-layout/src/main/java/androidx/ui/layout/Align.kt
@@ -21,7 +21,6 @@
import androidx.ui.core.Constraints
import androidx.ui.core.Layout
import androidx.ui.core.LayoutModifier
-import androidx.ui.core.looseMin
import androidx.ui.unit.DensityScope
import androidx.ui.unit.IntPxPosition
import androidx.ui.unit.IntPxSize
@@ -46,7 +45,7 @@
Layout(children) { measurables, constraints ->
val measurable = measurables.firstOrNull()
// The child cannot be larger than our max constraints, but we ignore min constraints.
- val placeable = measurable?.measure(constraints.looseMin())
+ val placeable = measurable?.measure(constraints.copy(minWidth = 0.ipx, minHeight = 0.ipx))
// The layout is as large as possible for bounded constraints,
// or wrap content otherwise.
@@ -225,7 +224,7 @@
private val direction: Direction
) : LayoutModifier {
override fun DensityScope.modifyConstraints(constraints: Constraints) = when (direction) {
- Direction.Both -> constraints.looseMin()
+ Direction.Both -> constraints.copy(minWidth = 0.ipx, minHeight = 0.ipx)
Direction.Horizontal -> constraints.copy(minWidth = 0.ipx)
Direction.Vertical -> constraints.copy(minHeight = 0.ipx)
}
diff --git a/ui/ui-layout/src/main/java/androidx/ui/layout/AspectRatio.kt b/ui/ui-layout/src/main/java/androidx/ui/layout/AspectRatio.kt
index 247117c..da98f0d 100644
--- a/ui/ui-layout/src/main/java/androidx/ui/layout/AspectRatio.kt
+++ b/ui/ui-layout/src/main/java/androidx/ui/layout/AspectRatio.kt
@@ -58,7 +58,7 @@
override fun DensityScope.modifyConstraints(constraints: Constraints): Constraints {
val size = constraints.findSizeWith(aspectRatio)
return if (size != null)
- Constraints.tightConstraints(size.width, size.height)
+ Constraints.fixed(size.width, size.height)
else
constraints
}
@@ -124,7 +124,7 @@
val measurable = measurables.firstOrNull()
val childConstraints = if (size != null) {
- Constraints.tightConstraints(size.width, size.height)
+ Constraints.fixed(size.width, size.height)
} else {
constraints
}
diff --git a/ui/ui-layout/src/main/java/androidx/ui/layout/Container.kt b/ui/ui-layout/src/main/java/androidx/ui/layout/Container.kt
index 6eec551..0af085e 100644
--- a/ui/ui-layout/src/main/java/androidx/ui/layout/Container.kt
+++ b/ui/ui-layout/src/main/java/androidx/ui/layout/Container.kt
@@ -23,11 +23,9 @@
import androidx.ui.core.Modifier
import androidx.ui.core.Placeable
import androidx.ui.core.enforce
-import androidx.ui.core.hasTightHeight
-import androidx.ui.core.hasTightWidth
-import androidx.ui.core.looseMin
+import androidx.ui.core.hasFixedHeight
+import androidx.ui.core.hasFixedWidth
import androidx.ui.core.offset
-import androidx.ui.core.withTight
import androidx.ui.unit.Dp
import androidx.ui.unit.IntPxSize
import androidx.ui.unit.dp
@@ -68,15 +66,19 @@
) {
Layout(children, modifier) { measurables, incomingConstraints ->
val containerConstraints = Constraints(constraints)
- .withTight(width?.toIntPx(), height?.toIntPx())
- .enforce(incomingConstraints)
+ .copy(
+ width?.toIntPx() ?: constraints.minWidth.toIntPx(),
+ width?.toIntPx() ?: constraints.maxWidth.toIntPx(),
+ height?.toIntPx() ?: constraints.minHeight.toIntPx(),
+ height?.toIntPx() ?: constraints.maxHeight.toIntPx()
+ ).enforce(incomingConstraints)
val totalHorizontal = padding.left.toIntPx() + padding.right.toIntPx()
val totalVertical = padding.top.toIntPx() + padding.bottom.toIntPx()
val childConstraints = containerConstraints
- .looseMin()
+ .copy(minWidth = 0.ipx, minHeight = 0.ipx)
.offset(-totalHorizontal, -totalVertical)
var placeable: Placeable? = null
- val containerWidth = if ((containerConstraints.hasTightWidth || expanded) &&
+ val containerWidth = if ((containerConstraints.hasFixedWidth || expanded) &&
containerConstraints.maxWidth.isFinite()
) {
containerConstraints.maxWidth
@@ -84,7 +86,7 @@
placeable = measurables.firstOrNull()?.measure(childConstraints)
max((placeable?.width ?: 0.ipx) + totalHorizontal, containerConstraints.minWidth)
}
- val containerHeight = if ((containerConstraints.hasTightHeight || expanded) &&
+ val containerHeight = if ((containerConstraints.hasFixedHeight || expanded) &&
containerConstraints.maxHeight.isFinite()
) {
containerConstraints.maxHeight
diff --git a/ui/ui-layout/src/main/java/androidx/ui/layout/Flex.kt b/ui/ui-layout/src/main/java/androidx/ui/layout/Flex.kt
index f851006..118a77a 100644
--- a/ui/ui-layout/src/main/java/androidx/ui/layout/Flex.kt
+++ b/ui/ui-layout/src/main/java/androidx/ui/layout/Flex.kt
@@ -169,16 +169,18 @@
}
/**
- * A FlexScope provides a scope for Inflexible/Flexible functions.
+ * Base class for scopes of [Row] and [Column], containing scoped modifiers.
*/
@LayoutScopeMarker
sealed class FlexScope {
/**
- * A layout modifier within a [Column] or [Row] that makes the target component flexible.
- * It will be assigned a space according to its flex weight relative to the flexible siblings.
+ * A layout modifier within a [Column] or [Row] that makes the target component flexible in
+ * the main direction of the parent (vertically in [Column] and horizontally in [Row]).
+ * It will be assigned a space according to its flex weight, proportional to the flex
+ * weights of other flexible siblings. If a sibling is not flexible, its flex weight will be 0.
* When [tight] is set to true, the target component is forced to occupy the entire space
* assigned to it by the parent. [LayoutFlexible] children will be measured after all the
- * [LayoutInflexible] ones have been measured, in order to divide the unclaimed space between
+ * inflexible ones have been measured, in order to divide the unclaimed space between
* them.
*/
fun LayoutFlexible(
@@ -194,31 +196,21 @@
}
/**
- * A layout modifier within a [Column] or [Row] that makes the target component inflexible.
- * All [LayoutInflexible] children will be measured before the [LayoutFlexible] ones. They will
- * be measured in the order they appear, without min constraints and with max constraints in
- * the main direction of the layout (maxHeight for Column and maxWidth for Row) such that
- * the sum of the space occupied by inflexible children will not exceed the incoming constraint
- * of the [Column] or [Row]: for example the first child of a [Column] will be measured with
- * maxHeight = column's maxHeight; the second child will be measured with maxHeight = column's
- * maxHeight - first child's height, and so on.
- */
- val LayoutInflexible: ParentDataModifier = InflexibleModifier
-
- internal companion object {
- val InflexibleModifier: ParentDataModifier = FlexModifier(
- FlexChildProperties(0f, FlexFit.Loose)
- )
- }
-
- /**
- * A layout modifier within a [Column] or [Row] that positions target component in a
- * perpendicular direction according to the [AlignmentLine] which is provided through the
- * [alignmentLineBlock].
- * If target component is the only component with the specified RelativeToSiblings modifier
- * within a Column or Row, then the component will be positioned using
- * [LayoutGravity.Start][ColumnScope.Start] in Column or [LayoutGravity.Top][RowScope.Top] in
- * Row respectively.
+ * A layout modifier within a [Column] or [Row] that positions its target component relative
+ * to all other elements within the container which have [LayoutGravity.RelativeToSiblings].
+ * The [alignmentLineBlock] accepts the [Placeable] of the targeted layout and returns the
+ * position, perpendicular to the layout direction, along which the target should align
+ * such that it coincides with the alignment lines of all other siblings with
+ * [LayoutGravity.RelativeToSiblings].
+ * Within a [Column] or [Row], all components with [LayoutGravity.RelativeToSiblings] will
+ * align using the specified [AlignmentLine]s or values obtained from [alignmentLineBlock]s,
+ * forming a sibling group. At least one element of the sibling group will be placed as it had
+ * [LayoutGravity.Start][ColumnScope.Start] in [Column] or [LayoutGravity.Top][RowScope.Top]
+ * in [Row], respectively, and the alignment of the other siblings will be then determined
+ * such that the alignment lines coincide. Note that if the target component is the only one
+ * with the [RelativeToSiblings] modifier specified, then the component will be positioned
+ * using [LayoutGravity.Start][ColumnScope.Start] in [Column] or
+ * [LayoutGravity.Top][RowScope.Top] in [Row] respectively.
*
* Example usage:
* @sample androidx.ui.layout.samples.SimpleRelativeToSiblings
@@ -233,29 +225,36 @@
* A ColumnScope provides a scope for the children of a [Column].
*/
@Suppress("unused") // Note: Gravity object provides a scope only but is never used itself
-class ColumnScope internal constructor() : FlexScope() {
+class ColumnScope private constructor() : FlexScope() {
/**
- * A layout modifier within a Column that positions target component in a horizontal direction
- * so that its start edge is aligned to the start edge of the horizontal axis.
+ * A layout modifier within a [Column] that positions its target component horizontally
+ * such that its start edge is aligned to the start edge of the [Column].
*/
// TODO: Consider ltr/rtl.
val LayoutGravity.Start: ParentDataModifier get() = StartGravityModifier
/**
- * A layout modifier within a Column that positions target component in a horizontal direction
- * so that its center is in the middle of the horizontal axis.
+ * A layout modifier within a [Column] that positions its target component horizontally
+ * such that its center is in the middle of the [Column].
*/
val LayoutGravity.Center: ParentDataModifier get() = CenterGravityModifier
/**
- * A layout modifier within a Column that positions target component in a horizontal direction
- * so that its end edge is aligned to the end edge of the horizontal axis.
+ * A layout modifier within a [Column] that positions its target component horizontally
+ * such that its end edge is aligned to the end edge of the [Column].
*/
val LayoutGravity.End: ParentDataModifier get() = EndGravityModifier
/**
- * A layout modifier within a [Column] that positions target component in a perpendicular
- * direction according to the [AlignmentLine].
- * If target component is the only component within a Column with the specified
- * RelativeToSiblings modifier, or if the provided alignment line is not defined for the
- * component, the component will be positioned using [LayoutGravity.Start].
+ * A layout modifier within a [Column] that positions its target component horizontally
+ * according to the specified [VerticalAlignmentLine], such that the position of the alignment
+ * line coincides with the alignment lines of all other siblings having their gravity set to
+ * [LayoutGravity.RelativeToSiblings].
+ * Within a [Column], all components with [LayoutGravity.RelativeToSiblings] will align
+ * horizontally using the specified [AlignmentLine]s or values obtained from
+ * [alignmentLineBlocks][FlexScope.RelativeToSiblings], forming a sibling group.
+ * At least one element of the sibling group will be placed as it had
+ * [LayoutGravity.Start][ColumnScope.Start] in [Column], and the alignment of the other
+ * siblings will be then determined such that the alignment lines coincide. Note that if
+ * the target component is the only one with the [RelativeToSiblings] modifier specified,
+ * then the component will be positioned using [LayoutGravity.Start][ColumnScope.Start].
*
* Example usage:
*
@@ -265,6 +264,8 @@
SiblingsAlignedModifier.WithAlignmentLine(alignmentLine)
internal companion object {
+ internal val Instance = ColumnScope()
+
val StartGravityModifier: ParentDataModifier = GravityModifier(CrossAxisAlignment.Start)
val CenterGravityModifier: ParentDataModifier = GravityModifier(CrossAxisAlignment.Center)
val EndGravityModifier: ParentDataModifier = GravityModifier(CrossAxisAlignment.End)
@@ -275,28 +276,35 @@
* A RowScope provides a scope for the children of a [Row].
*/
@Suppress("unused") // Note: Gravity object provides a scope only but is never used itself
-class RowScope internal constructor() : FlexScope() {
+class RowScope private constructor() : FlexScope() {
/**
- * A layout modifier within a Row that positions target component in a vertical direction
- * so that its top edge is aligned to the top edge of the vertical axis.
+ * A layout modifier within a [Row] that positions its target component vertically
+ * such that its top edge is aligned to the top edge of the [Row].
*/
val LayoutGravity.Top: ParentDataModifier get() = TopGravityModifier
/**
- * A layout modifier within a Row that positions target component in a vertical direction
- * so that its center is in the middle of the vertical axis.
+ * A layout modifier within a Row that positions target component vertically
+ * such that its center is in the middle of the [Row].
*/
val LayoutGravity.Center: ParentDataModifier get() = CenterGravityModifier
/**
- * A layout modifier within a Row that positions target component in a vertical direction
- * so that its bottom edge is aligned to the bottom edge of the vertical axis.
+ * A layout modifier within a Row that positions target component vertically
+ * such that its bottom edge is aligned to the bottom edge of the [Row].
*/
val LayoutGravity.Bottom: ParentDataModifier get() = BottomGravityModifier
/**
- * A layout modifier within a [Row] that positions target component in a perpendicular
- * direction according to the [AlignmentLine].
- * If target component is the only component within a Row with the specified
- * RelativeToSiblings modifier, or if the provided alignment line is not defined for the
- * component, the component will be positioned using [LayoutGravity.Top].
+ * A layout modifier within a [Row] that positions its target component vertically
+ * according to the specified [HorizontalAlignmentLine], such that the position of the alignment
+ * line coincides with the alignment lines of all other siblings having their gravity set to
+ * [LayoutGravity.RelativeToSiblings].
+ * Within a [Row], all components with [LayoutGravity.RelativeToSiblings] will align
+ * vertically using the specified [AlignmentLine]s or values obtained from
+ * [alignmentLineBlocks][FlexScope.RelativeToSiblings], forming a sibling group.
+ * At least one element of the sibling group will be placed as it had
+ * [LayoutGravity.Top][RowScope.Top] in [Row], and the alignment of the other
+ * siblings will be then determined such that the alignment lines coincide. Note that if
+ * the target component is the only one with the [RelativeToSiblings] modifier specified,
+ * then the component will be positioned using [LayoutGravity.Top][RowScope.Top].
*
* Example usage:
* @sample androidx.ui.layout.samples.SimpleRelativeToSiblingsInRow
@@ -306,6 +314,8 @@
): ParentDataModifier = SiblingsAlignedModifier.WithAlignmentLine(alignmentLine)
internal companion object {
+ internal val Instance = RowScope()
+
val TopGravityModifier: ParentDataModifier = GravityModifier(CrossAxisAlignment.Start)
val CenterGravityModifier: ParentDataModifier = GravityModifier(CrossAxisAlignment.Center)
val BottomGravityModifier: ParentDataModifier = GravityModifier(CrossAxisAlignment.End)
@@ -313,11 +323,11 @@
}
/**
- * A composable that places its children in a horizontal sequence and is able to assign them widths
- * according to their flex weights provided through [androidx.ui.layout.FlexScope.LayoutFlexible]
- * modifier.
- * If [androidx.ui.layout.FlexScope.LayoutInflexible] or no modifier is provided, the child will be
- * treated as inflexible, and will be sized to its preferred width.
+ * A layout composable that places its children in a horizontal sequence.
+ * The layout model is able to assign children widths according to their flex weights provided
+ * using the [androidx.ui.layout.FlexScope.LayoutFlexible] modifier. If a child is not
+ * [flexible][androidx.ui.layout.FlexScope.LayoutFlexible], it will be considered inflexible
+ * and will be sized to its preferred width.
*
* Example usage:
*
@@ -338,16 +348,16 @@
arrangement = arrangement,
crossAxisAlignment = CrossAxisAlignment.Start,
crossAxisSize = SizeMode.Wrap,
- children = { RowScope().children() }
+ children = { RowScope.Instance.children() }
)
}
/**
- * A composable that places its children in a vertical sequence and is able to assign them heights
- * according to their flex weights provided through [androidx.ui.layout.FlexScope.LayoutFlexible]
- * modifiers.
- * If [androidx.ui.layout.FlexScope.LayoutInflexible] or no modifier is provided, the child will be
- * treated as inflexible, and will be sized to its preferred height.
+ * A layout composable that places its children in a vertical sequence.
+ * The layout model is able to assign children heights according to their flex weights provided
+ * using the [androidx.ui.layout.FlexScope.LayoutFlexible] modifier. If a child is not
+ * [flexible][androidx.ui.layout.FlexScope.LayoutFlexible], it will be considered inflexible
+ * and will be sized to its preferred width.
*
* Example usage:
*
@@ -368,7 +378,7 @@
arrangement = arrangement,
crossAxisAlignment = CrossAxisAlignment.Start,
crossAxisSize = SizeMode.Wrap,
- children = { ColumnScope().children() }
+ children = { ColumnScope.Instance.children() }
)
}
diff --git a/ui/ui-layout/src/main/java/androidx/ui/layout/Intrinsic.kt b/ui/ui-layout/src/main/java/androidx/ui/layout/Intrinsic.kt
index de48dc3..8ca9aac 100644
--- a/ui/ui-layout/src/main/java/androidx/ui/layout/Intrinsic.kt
+++ b/ui/ui-layout/src/main/java/androidx/ui/layout/Intrinsic.kt
@@ -58,7 +58,7 @@
val measurable = measurables.firstOrNull()
val width = measurable?.minIntrinsicWidth(constraints.maxHeight) ?: 0.ipx
val placeable = measurable?.measure(
- Constraints.tightConstraintsForWidth(width).enforce(constraints)
+ Constraints.fixedWidth(width).enforce(constraints)
)
layout(placeable?.width ?: 0.ipx, placeable?.height ?: 0.ipx) {
placeable?.place(0.ipx, 0.ipx)
@@ -103,7 +103,7 @@
val measurable = measurables.firstOrNull()
val height = measurable?.minIntrinsicHeight(constraints.maxWidth) ?: 0.ipx
val placeable = measurable?.measure(
- Constraints.tightConstraintsForHeight(height).enforce(constraints)
+ Constraints.fixedHeight(height).enforce(constraints)
)
layout(placeable?.width ?: 0.ipx, placeable?.height ?: 0.ipx) {
placeable?.place(0.ipx, 0.ipx)
@@ -148,7 +148,7 @@
val measurable = measurables.firstOrNull()
val width = measurable?.maxIntrinsicWidth(constraints.maxHeight) ?: 0.ipx
val placeable = measurable?.measure(
- Constraints.tightConstraintsForWidth(width).enforce(constraints)
+ Constraints.fixedWidth(width).enforce(constraints)
)
layout(placeable?.width ?: 0.ipx, placeable?.height ?: 0.ipx) {
placeable?.place(0.ipx, 0.ipx)
@@ -193,7 +193,7 @@
val measurable = measurables.firstOrNull()
val height = measurable?.maxIntrinsicHeight(constraints.maxWidth) ?: 0.ipx
val placeable = measurable?.measure(
- Constraints.tightConstraintsForHeight(height).enforce(constraints)
+ Constraints.fixedHeight(height).enforce(constraints)
)
layout(placeable?.width ?: 0.ipx, placeable?.height ?: 0.ipx) {
placeable?.place(0.ipx, 0.ipx)
diff --git a/ui/ui-layout/src/main/java/androidx/ui/layout/SizeModifiers.kt b/ui/ui-layout/src/main/java/androidx/ui/layout/SizeModifiers.kt
index 3179784..f29edde 100644
--- a/ui/ui-layout/src/main/java/androidx/ui/layout/SizeModifiers.kt
+++ b/ui/ui-layout/src/main/java/androidx/ui/layout/SizeModifiers.kt
@@ -23,7 +23,6 @@
import androidx.ui.core.enforce
import androidx.ui.core.hasBoundedHeight
import androidx.ui.core.hasBoundedWidth
-import androidx.ui.core.withTight
import androidx.ui.unit.DensityScope
import androidx.ui.unit.Dp
import androidx.ui.unit.IntPx
@@ -145,7 +144,7 @@
object Fill : LayoutModifier {
override fun DensityScope.modifyConstraints(constraints: Constraints): Constraints =
if (constraints.hasBoundedWidth) {
- constraints.withTight(width = constraints.maxWidth)
+ constraints.copy(minWidth = constraints.maxWidth, maxWidth = constraints.maxWidth)
} else {
constraints
}
@@ -241,7 +240,10 @@
object Fill : LayoutModifier {
override fun DensityScope.modifyConstraints(constraints: Constraints): Constraints =
if (constraints.hasBoundedHeight) {
- constraints.withTight(height = constraints.maxHeight)
+ constraints.copy(
+ minHeight = constraints.maxHeight,
+ maxHeight = constraints.maxHeight
+ )
} else {
constraints
}
@@ -384,11 +386,16 @@
object Fill : LayoutModifier {
override fun DensityScope.modifyConstraints(constraints: Constraints): Constraints =
when {
- constraints.hasBoundedWidth && constraints.hasBoundedHeight -> constraints
- .withTight(width = constraints.maxWidth, height = constraints.maxHeight)
- constraints.hasBoundedWidth -> constraints.withTight(width = constraints.maxWidth)
- constraints.hasBoundedHeight -> constraints.withTight(
- height = constraints.maxHeight)
+ constraints.hasBoundedWidth && constraints.hasBoundedHeight -> constraints.copy(
+ minWidth = constraints.maxWidth,
+ minHeight = constraints.maxHeight
+ )
+ constraints.hasBoundedWidth -> constraints.copy(
+ minWidth = constraints.maxWidth
+ )
+ constraints.hasBoundedHeight -> constraints.copy(
+ minHeight = constraints.maxHeight
+ )
else -> constraints
}
}
diff --git a/ui/ui-layout/src/main/java/androidx/ui/layout/Stack.kt b/ui/ui-layout/src/main/java/androidx/ui/layout/Stack.kt
index a4099a6..a687c77e 100644
--- a/ui/ui-layout/src/main/java/androidx/ui/layout/Stack.kt
+++ b/ui/ui-layout/src/main/java/androidx/ui/layout/Stack.kt
@@ -24,10 +24,10 @@
import androidx.ui.core.Modifier
import androidx.ui.core.ParentDataModifier
import androidx.ui.core.Placeable
-import androidx.ui.core.looseMin
import androidx.ui.unit.DensityScope
import androidx.ui.unit.IntPx
import androidx.ui.unit.IntPxSize
+import androidx.ui.unit.ipx
import androidx.ui.unit.isFinite
import androidx.ui.unit.max
@@ -51,8 +51,9 @@
Layout(stackChildren, modifier = modifier) { measurables, constraints ->
val placeables = arrayOfNulls<Placeable>(measurables.size)
// First measure aligned children to get the size of the layout.
+ val childConstraints = constraints.copy(minWidth = 0.ipx, minHeight = 0.ipx)
(0 until measurables.size).filter { i -> !measurables[i].stretch }.forEach { i ->
- placeables[i] = measurables[i].measure(constraints.looseMin())
+ placeables[i] = measurables[i].measure(childConstraints)
}
val (stackWidth, stackHeight) = with(placeables.filterNotNull()) {
Pair(
diff --git a/ui/ui-layout/src/main/java/androidx/ui/layout/Table.kt b/ui/ui-layout/src/main/java/androidx/ui/layout/Table.kt
index 12e6b35..3cb26c8 100644
--- a/ui/ui-layout/src/main/java/androidx/ui/layout/Table.kt
+++ b/ui/ui-layout/src/main/java/androidx/ui/layout/Table.kt
@@ -610,7 +610,7 @@
}
}
val decorationConstraints =
- Constraints.tightConstraints(tableSize.width, tableSize.height)
+ Constraints.fixed(tableSize.width, tableSize.height)
measurables.filter { it.rowIndex == null }.forEach {
it.measure(decorationConstraints).place(IntPx.Zero, IntPx.Zero)
}
diff --git a/ui/ui-layout/src/main/java/androidx/ui/layout/Wrap.kt b/ui/ui-layout/src/main/java/androidx/ui/layout/Wrap.kt
index fe392c6..16104a5 100644
--- a/ui/ui-layout/src/main/java/androidx/ui/layout/Wrap.kt
+++ b/ui/ui-layout/src/main/java/androidx/ui/layout/Wrap.kt
@@ -21,7 +21,6 @@
import androidx.ui.core.Constraints
import androidx.ui.core.Layout
import androidx.ui.core.LayoutModifier
-import androidx.ui.core.looseMin
import androidx.ui.unit.DensityScope
import androidx.ui.unit.IntPxPosition
import androidx.ui.unit.IntPxSize
@@ -42,7 +41,7 @@
Layout(children) { measurables, constraints ->
val measurable = measurables.firstOrNull()
// The child cannot be larger than our max constraints, but we ignore min constraints.
- val placeable = measurable?.measure(constraints.looseMin())
+ val placeable = measurable?.measure(constraints.copy(minWidth = 0.ipx, minHeight = 0.ipx))
// Try to be as small as possible.
val layoutWidth = max(placeable?.width ?: 0.ipx, constraints.minWidth)
@@ -67,7 +66,8 @@
* size itself to min incoming constraints and place its content in the center.
*/
val LayoutWrapped: LayoutModifier = object : LayoutModifier {
- override fun DensityScope.modifyConstraints(constraints: Constraints) = constraints.looseMin()
+ override fun DensityScope.modifyConstraints(constraints: Constraints) =
+ constraints.copy(minWidth = 0.ipx, minHeight = 0.ipx)
override fun DensityScope.modifySize(
constraints: Constraints,
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/DataTable.kt b/ui/ui-material/src/main/java/androidx/ui/material/DataTable.kt
index 55471c3..c472027 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/DataTable.kt
+++ b/ui/ui-material/src/main/java/androidx/ui/material/DataTable.kt
@@ -463,7 +463,7 @@
measurables.forEach { measurable ->
val i = measurable.parentData as Int
val placeable = measurable.measure(
- Constraints.tightConstraints(
+ Constraints.fixed(
width = constraints.maxWidth,
height = verticalOffsets[i + 2] - verticalOffsets[i + 1]
)
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/Tab.kt b/ui/ui-material/src/main/java/androidx/ui/material/Tab.kt
index 1908d00..e38f9a3 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/Tab.kt
+++ b/ui/ui-material/src/main/java/androidx/ui/material/Tab.kt
@@ -26,6 +26,7 @@
import androidx.ui.animation.PxPropKey
import androidx.ui.animation.Transition
import androidx.ui.core.Alignment
+import androidx.ui.core.Constraints
import androidx.ui.core.FirstBaseline
import androidx.ui.core.LastBaseline
import androidx.ui.core.Layout
@@ -38,7 +39,6 @@
import androidx.ui.core.WithConstraints
import androidx.ui.core.ambientDensity
import androidx.ui.core.tag
-import androidx.ui.core.withTight
import androidx.ui.foundation.ColoredRect
import androidx.ui.foundation.HorizontalScroller
import androidx.ui.foundation.ScrollerPosition
@@ -281,13 +281,13 @@
// The divider is measured with its own height, and width equal to the total width
// of the tab row, and then placed on top of the tabs.
measurables.firstOrNull { it.tag == DividerTag }
- ?.measure(constraints.withTight(width = layoutWidth))
+ ?.measure(constraints.copy(minWidth = layoutWidth, maxWidth = layoutWidth))
?.run { place(IntPx.Zero, layoutHeight - height) }
// The indicator container is measured to fill the entire space occupied by the tab
// row, and then placed on top of the divider.
measurables.firstOrNull { it.tag == IndicatorTag }
- ?.measure(constraints.withTight(width = layoutWidth, height = layoutHeight))
+ ?.measure(Constraints.fixed(layoutWidth, layoutHeight))
?.place(IntPx.Zero, IntPx.Zero)
}
}
diff --git a/ui/ui-platform/src/main/java/androidx/ui/core/AndroidOwner.kt b/ui/ui-platform/src/main/java/androidx/ui/core/AndroidOwner.kt
index 6d1a84a..737e58a 100644
--- a/ui/ui-platform/src/main/java/androidx/ui/core/AndroidOwner.kt
+++ b/ui/ui-platform/src/main/java/androidx/ui/core/AndroidOwner.kt
@@ -109,7 +109,7 @@
}
private val pointerInputEventProcessor = PointerInputEventProcessor(root)
- var constraints = Constraints.tightConstraints(width = IntPx.Zero, height = IntPx.Zero)
+ var constraints = Constraints.fixed(width = IntPx.Zero, height = IntPx.Zero)
// TODO(mount): reinstate when coroutines are supported by IR compiler
// private val ownerScope = CoroutineScope(Dispatchers.Main.immediate + Job())
diff --git a/ui/ui-platform/src/main/java/androidx/ui/core/ComponentNodes.kt b/ui/ui-platform/src/main/java/androidx/ui/core/ComponentNodes.kt
index 5f9076b..10a2672 100644
--- a/ui/ui-platform/src/main/java/androidx/ui/core/ComponentNodes.kt
+++ b/ui/ui-platform/src/main/java/androidx/ui/core/ComponentNodes.kt
@@ -823,7 +823,7 @@
/**
* The constraints used the last time [layout] was called.
*/
- var constraints: Constraints = Constraints.tightConstraints(IntPx.Zero, IntPx.Zero)
+ var constraints: Constraints = Constraints.fixed(IntPx.Zero, IntPx.Zero)
/**
* Implementation oddity around composition; used to capture a reference to this
diff --git a/ui/ui-text/src/test/java/androidx/ui/text/TextLayoutHelperTest.kt b/ui/ui-text/src/test/java/androidx/ui/text/TextLayoutHelperTest.kt
index 7d83f0a..44254d1 100644
--- a/ui/ui-text/src/test/java/androidx/ui/text/TextLayoutHelperTest.kt
+++ b/ui/ui-text/src/test/java/androidx/ui/text/TextLayoutHelperTest.kt
@@ -52,7 +52,7 @@
density = Density(1.0f),
layoutDirection = LayoutDirection.Ltr,
resourceLoader = resourceLoader,
- constraints = Constraints.tightConstraintsForWidth(100.ipx)
+ constraints = Constraints.fixedWidth(100.ipx)
),
multiParagraph = mock(),
size = IntPxSize(50.ipx, 50.ipx)
@@ -61,7 +61,7 @@
@Test
fun testCanResue_same() {
- val constraints = Constraints.tightConstraintsForWidth(100.ipx)
+ val constraints = Constraints.fixedWidth(100.ipx)
assertThat(referenceResult.canReuse(
text = AnnotatedString.Builder("Hello, World").toAnnotatedString(),
style = TextStyle(),
@@ -77,7 +77,7 @@
@Test
fun testCanResue_different_text() {
- val constraints = Constraints.tightConstraintsForWidth(100.ipx)
+ val constraints = Constraints.fixedWidth(100.ipx)
assertThat(referenceResult.canReuse(
text = AnnotatedString.Builder("Hello, Android").toAnnotatedString(),
style = TextStyle(),
@@ -93,7 +93,7 @@
@Test
fun testCanResue_different_style() {
- val constraints = Constraints.tightConstraintsForWidth(100.ipx)
+ val constraints = Constraints.fixedWidth(100.ipx)
assertThat(referenceResult.canReuse(
text = AnnotatedString.Builder("Hello, World").toAnnotatedString(),
style = TextStyle(fontSize = 1.5.em),
@@ -109,7 +109,7 @@
@Test
fun testCanResue_different_maxLines() {
- val constraints = Constraints.tightConstraintsForWidth(100.ipx)
+ val constraints = Constraints.fixedWidth(100.ipx)
assertThat(referenceResult.canReuse(
text = AnnotatedString.Builder("Hello, World").toAnnotatedString(),
style = TextStyle(),
@@ -125,7 +125,7 @@
@Test
fun testCanResue_different_softWrap() {
- val constraints = Constraints.tightConstraintsForWidth(100.ipx)
+ val constraints = Constraints.fixedWidth(100.ipx)
assertThat(referenceResult.canReuse(
text = AnnotatedString.Builder("Hello, World").toAnnotatedString(),
style = TextStyle(),
@@ -141,7 +141,7 @@
@Test
fun testCanResue_different_overflow() {
- val constraints = Constraints.tightConstraintsForWidth(100.ipx)
+ val constraints = Constraints.fixedWidth(100.ipx)
assertThat(referenceResult.canReuse(
text = AnnotatedString.Builder("Hello, World").toAnnotatedString(),
style = TextStyle(),
@@ -157,7 +157,7 @@
@Test
fun testCanResue_different_density() {
- val constraints = Constraints.tightConstraintsForWidth(100.ipx)
+ val constraints = Constraints.fixedWidth(100.ipx)
assertThat(referenceResult.canReuse(
text = AnnotatedString.Builder("Hello, World").toAnnotatedString(),
style = TextStyle(),
@@ -173,7 +173,7 @@
@Test
fun testCanResue_different_layoutDirection() {
- val constraints = Constraints.tightConstraintsForWidth(100.ipx)
+ val constraints = Constraints.fixedWidth(100.ipx)
assertThat(referenceResult.canReuse(
text = AnnotatedString.Builder("Hello, World").toAnnotatedString(),
style = TextStyle(),
@@ -189,7 +189,7 @@
@Test
fun testCanResue_different_resourceLoader() {
- val constraints = Constraints.tightConstraintsForWidth(100.ipx)
+ val constraints = Constraints.fixedWidth(100.ipx)
assertThat(referenceResult.canReuse(
text = AnnotatedString.Builder("Hello, World").toAnnotatedString(),
style = TextStyle(),
@@ -214,7 +214,7 @@
density = Density(1.0f),
layoutDirection = LayoutDirection.Ltr,
resourceLoader = resourceLoader,
- constraints = Constraints.tightConstraintsForWidth(200.ipx)
+ constraints = Constraints.fixedWidth(200.ipx)
)).isFalse()
}
}
diff --git a/ui/ui-util/api/api_lint.ignore b/ui/ui-util/api/api_lint.ignore
new file mode 100644
index 0000000..cc585e2
--- /dev/null
+++ b/ui/ui-util/api/api_lint.ignore
@@ -0,0 +1,9 @@
+// Baseline format: 1.0
+NoByteOrShort: androidx.ui.util.Float16#Float16(short) parameter #0:
+ Should avoid odd sized primitives; use `int` instead of `short` in parameter halfValue in androidx.ui.util.Float16(short halfValue)
+NoByteOrShort: androidx.ui.util.Float16#getHalfValue():
+ Should avoid odd sized primitives; use `int` instead of `short` in method androidx.ui.util.Float16.getHalfValue()
+NoByteOrShort: androidx.ui.util.Float16#toByte():
+ Should avoid odd sized primitives; use `int` instead of `byte` in method androidx.ui.util.Float16.toByte()
+NoByteOrShort: androidx.ui.util.Float16#toShort():
+ Should avoid odd sized primitives; use `int` instead of `short` in method androidx.ui.util.Float16.toShort()
diff --git a/webkit/OWNERS b/webkit/OWNERS
index b33da57..e054e6f 100644
--- a/webkit/OWNERS
+++ b/webkit/OWNERS
@@ -1,4 +1,5 @@
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
diff --git a/webkit/integration-tests/testapp/src/androidTest/java/com/example/androidx/webkit/AssetLoaderAjaxActivityTestAppTest.java b/webkit/integration-tests/testapp/src/androidTest/java/com/example/androidx/webkit/AssetLoaderAjaxActivityTestAppTest.java
new file mode 100644
index 0000000..bc07f31
--- /dev/null
+++ b/webkit/integration-tests/testapp/src/androidTest/java/com/example/androidx/webkit/AssetLoaderAjaxActivityTestAppTest.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.androidx.webkit;
+
+import androidx.test.filters.LargeTest;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/**
+ * Integeration test for AssetLoaderAjaxActivity demo activity.
+ */
+@RunWith(JUnit4.class)
+@LargeTest
+public final class AssetLoaderAjaxActivityTestAppTest {
+
+ @Rule
+ public IntegrationActivityTestRule<AssetLoaderAjaxActivity> mRule =
+ new IntegrationActivityTestRule<>(AssetLoaderAjaxActivity.class,
+ R.id.webview_asset_loader_webview);
+
+ @Test
+ public void testAssetLoaderAjaxActivity() {
+ mRule.assertHtmlElementContainsText(R.id.webview_asset_loader_webview, "title",
+ "Loaded HTML should appear below on success");
+ mRule.assertHtmlElementContainsText(R.id.webview_asset_loader_webview, "assets_html",
+ "Successfully loaded html from assets!");
+ mRule.assertHtmlElementContainsText(R.id.webview_asset_loader_webview, "res_html",
+ "Successfully loaded html from resources!");
+ }
+}
diff --git a/webkit/integration-tests/testapp/src/androidTest/java/com/example/androidx/webkit/AssetLoaderInternalStorageActivityTestAppTest.java b/webkit/integration-tests/testapp/src/androidTest/java/com/example/androidx/webkit/AssetLoaderInternalStorageActivityTestAppTest.java
new file mode 100644
index 0000000..82ba14b
--- /dev/null
+++ b/webkit/integration-tests/testapp/src/androidTest/java/com/example/androidx/webkit/AssetLoaderInternalStorageActivityTestAppTest.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.androidx.webkit;
+
+import androidx.test.filters.LargeTest;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/**
+ * Integeration test for AssetLoaderInternalStorageActivity demo activity.
+ */
+@RunWith(JUnit4.class)
+@LargeTest
+public final class AssetLoaderInternalStorageActivityTestAppTest {
+
+ @Rule
+ public IntegrationActivityTestRule<AssetLoaderInternalStorageActivity> mRule =
+ new IntegrationActivityTestRule<>(AssetLoaderInternalStorageActivity.class,
+ R.id.webview_asset_loader_webview);
+
+ @Test
+ public void testAssetLoaderInternalStorageActivity() {
+ mRule.assertHtmlElementContainsText(R.id.webview_asset_loader_webview, "data_success_msg",
+ "Successfully loaded html from app files dir!");
+ }
+}
diff --git a/webkit/integration-tests/testapp/src/androidTest/java/com/example/androidx/webkit/AssetLoaderSimpleActivityTestAppTest.java b/webkit/integration-tests/testapp/src/androidTest/java/com/example/androidx/webkit/AssetLoaderSimpleActivityTestAppTest.java
new file mode 100644
index 0000000..aeda465c
--- /dev/null
+++ b/webkit/integration-tests/testapp/src/androidTest/java/com/example/androidx/webkit/AssetLoaderSimpleActivityTestAppTest.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.androidx.webkit;
+
+import androidx.test.filters.LargeTest;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/**
+ * Integeration test for AssetLoaderSimpleActivity demo activity.
+ */
+@RunWith(JUnit4.class)
+@LargeTest
+public final class AssetLoaderSimpleActivityTestAppTest {
+
+ @Rule
+ public IntegrationActivityTestRule<AssetLoaderSimpleActivity> mRule =
+ new IntegrationActivityTestRule<>(AssetLoaderSimpleActivity.class,
+ R.id.webview_asset_loader_webview);
+
+ @Test
+ public void testAssetLoaderSimpleActivity() {
+ mRule.assertHtmlElementContainsText(R.id.webview_asset_loader_webview, "assets_success_msg",
+ "Successfully loaded html from assets!");
+ }
+}
diff --git a/webkit/integration-tests/testapp/src/androidTest/java/com/example/androidx/webkit/IntegrationActivityTestRule.java b/webkit/integration-tests/testapp/src/androidTest/java/com/example/androidx/webkit/IntegrationActivityTestRule.java
new file mode 100644
index 0000000..08e6806
--- /dev/null
+++ b/webkit/integration-tests/testapp/src/androidTest/java/com/example/androidx/webkit/IntegrationActivityTestRule.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.androidx.webkit;
+
+import static androidx.test.espresso.matcher.ViewMatchers.withId;
+import static androidx.test.espresso.web.assertion.WebViewAssertions.webMatches;
+import static androidx.test.espresso.web.sugar.Web.onWebView;
+import static androidx.test.espresso.web.webdriver.DriverAtoms.findElement;
+import static androidx.test.espresso.web.webdriver.DriverAtoms.getText;
+
+import static org.hamcrest.Matchers.containsString;
+
+import androidx.annotation.IdRes;
+import androidx.test.espresso.web.webdriver.Locator;
+import androidx.test.rule.ActivityTestRule;
+
+/**
+ * Launch, interact, and verify conditions in an activity that has a WebView instance
+ * in the integration test app.
+ *
+ * <p>
+ * Note that this class relies on Espresso's wait for idle behavior to synchronize
+ * operations with UI updates from the test application. If there are any async
+ * UI updates, then the test activity must ensure that actions and assertions do not execute
+ * before pending they are completed. Implementing an
+ * {@link androidx.test.espresso.IdlingResource} in the test application is the standard way
+ * of doing this.
+ */
+public class IntegrationActivityTestRule<T extends android.app.Activity>
+ extends ActivityTestRule<T> {
+
+ private @IdRes int[] mWebViewIds;
+
+ /**
+ * @param activityClass the activity to start the test from.
+ * @param webViewIds IDs of all WebView objects in the launched activity to enable javascript
+ * in them.
+ */
+ public IntegrationActivityTestRule(Class<T> activityClass, @IdRes int... webViewIds) {
+ super(activityClass);
+ mWebViewIds = webViewIds;
+ }
+
+ @Override
+ public void afterActivityLaunched() {
+ // Javascript has to be enabled in order for espresso tests to work.
+ if (mWebViewIds == null) return;
+ for (@IdRes int webViewId : mWebViewIds) {
+ onWebView(withId(webViewId)).forceJavascriptEnabled();
+ }
+ }
+
+ /**
+ * Assert that an HTML element in the given WebView object contains the given text.
+ *
+ * @param webViewId ID of the WebView object that contains the HTML object.
+ * @param tagId the ID attribute of the HTML tag.
+ * @param text the expected text inside the HTML element.
+ */
+ public static void assertHtmlElementContainsText(@IdRes int webViewId,
+ String tagId, String text) {
+ onWebView(withId(webViewId))
+ .withElement(findElement(Locator.ID, tagId))
+ .check(webMatches(getText(),
+ containsString(text)));
+ }
+}
diff --git a/webkit/integration-tests/testapp/src/androidTest/java/com/example/androidx/webkit/WebViewAssetLoaderTestAppTest.java b/webkit/integration-tests/testapp/src/androidTest/java/com/example/androidx/webkit/WebViewAssetLoaderTestAppTest.java
deleted file mode 100644
index d7dd962..0000000
--- a/webkit/integration-tests/testapp/src/androidTest/java/com/example/androidx/webkit/WebViewAssetLoaderTestAppTest.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.androidx.webkit;
-
-import static androidx.test.espresso.matcher.ViewMatchers.withId;
-import static androidx.test.espresso.web.assertion.WebViewAssertions.webMatches;
-import static androidx.test.espresso.web.sugar.Web.onWebView;
-import static androidx.test.espresso.web.webdriver.DriverAtoms.findElement;
-import static androidx.test.espresso.web.webdriver.DriverAtoms.getText;
-
-import static org.hamcrest.Matchers.containsString;
-
-import androidx.annotation.IdRes;
-import androidx.test.espresso.web.webdriver.Locator;
-import androidx.test.filters.LargeTest;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-/**
- * Integeration tests for AssetLoader demo activities.
- *
- * Tests the following activities:
- * <ul>
- * <li>AssetLoaderDemoActivity.</li>
- * <li>AssetLoaderAjaxActivity.</li>
- * <li>AssetLoaderInternalStorageActivity.</li>
- * </ul>
- */
-@RunWith(JUnit4.class)
-@LargeTest
-public final class WebViewAssetLoaderTestAppTest {
-
- /**
- * A test rule to set up the tests for WebViewAssetLoader demo Activities.
- * It does the following:
- * <ol>
- * <li> Launch {@code MainActivity}. </li>
- * <li> Clicks on the "WebView Asset Loader Demos" in the main menu to open
- * {@code AssetLoaderListActivity}. </li>
- * <li> Clicks on the Activity to be tested in the menu.</li>
- * <li> Force enables Javascript since it's required by Espresso library to test WebView
- * contents.</li>
- * </ol>
- */
- public class IntegrationAppWebViewTestRule extends IntegrationAppTestRule {
- /**
- * Opens the activity to be tested from WebViewAssetLoader demos activity list and force
- * Javascript to be enabled in the WebView instance in that activity.
- * @param activityTitleId resource id for the title of the activity to be opened.
- */
- public void openByActivityTitle(@IdRes int activityTitleId) {
- clickMenuListItem(activityTitleId);
- // All the activities in "WebView Asset Loader Demos" uses the same
- // "layout/activity_asset_loader" so all the WebViews have the same ID:
- // R.id.webview_asset_loader_webview.
- // Not all WebViews in the app have javascript turned on, however since the only way
- // to automate WebViews is through javascript, it must be enabled.
- onWebView(withId(R.id.webview_asset_loader_webview)).forceJavascriptEnabled();
- }
-
- }
-
- @Rule
- public IntegrationAppWebViewTestRule mRule = new IntegrationAppWebViewTestRule();
-
- @Before
- public void setUp() {
- // Open the activity of WebViewAssetLoader demo activities from the main Activity list.
- mRule.clickMenuListItem(R.string.asset_loader_list_activity_title);
- }
-
- @Test
- public void testAssetLoaderSimpleActivity() {
- mRule.openByActivityTitle(R.string.asset_loader_simple_activity_title);
- onWebView()
- .withElement(findElement(Locator.TAG_NAME, "h3"))
- .check(webMatches(getText(),
- containsString("Successfully loaded html from assets!")));
- }
-
- @Test
- public void testAssetLoaderAjaxActivity() {
- mRule.openByActivityTitle(R.string.asset_loader_ajax_activity_title);
- onWebView()
- .withElement(findElement(Locator.TAG_NAME, "h1"))
- .check(webMatches(getText(),
- containsString("Loaded HTML should appear below on success")))
- .withElement(findElement(Locator.ID, "assets_html"))
- .check(webMatches(getText(),
- containsString("Successfully loaded html from assets!")))
- .withElement(findElement(Locator.ID, "res_html"))
- .check(webMatches(getText(),
- containsString("Successfully loaded html from resources!")));
- }
-
- @Test
- public void testAssetLoaderInternalStorageActivity() {
- mRule.openByActivityTitle(R.string.asset_loader_internal_storage_activity_title);
- onWebView()
- .withElement(findElement(Locator.TAG_NAME, "h3"))
- .check(webMatches(getText(),
- containsString("Successfully loaded html from app files dir!")));
- }
-}
diff --git a/webkit/integration-tests/testapp/src/main/assets/www/ajax_requests.html b/webkit/integration-tests/testapp/src/main/assets/www/ajax_requests.html
index 12299b1..95e92ec 100644
--- a/webkit/integration-tests/testapp/src/main/assets/www/ajax_requests.html
+++ b/webkit/integration-tests/testapp/src/main/assets/www/ajax_requests.html
@@ -54,7 +54,7 @@
</head>
<body>
- <h1>Loaded HTML should appear below on success</h1>
+ <h1 id="title">Loaded HTML should appear below on success</h1>
<hr>
<div id="assets_html"></div>
<div id="res_html"></div>
diff --git a/webkit/integration-tests/testapp/src/main/assets/www/some_text.html b/webkit/integration-tests/testapp/src/main/assets/www/some_text.html
index c7578bc..da7ec73 100644
--- a/webkit/integration-tests/testapp/src/main/assets/www/some_text.html
+++ b/webkit/integration-tests/testapp/src/main/assets/www/some_text.html
@@ -12,4 +12,4 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<h3>Successfully loaded html from assets!</h3>
+<h3 id="assets_success_msg">Successfully loaded html from assets!</h3>
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/AssetLoaderInternalStorageActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/AssetLoaderInternalStorageActivity.java
index 88ae121..4a0373d 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/AssetLoaderInternalStorageActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/AssetLoaderInternalStorageActivity.java
@@ -43,7 +43,7 @@
*/
public class AssetLoaderInternalStorageActivity extends AppCompatActivity {
private static final String DEMO_HTML_CONTENT =
- "<h3>Successfully loaded html from app files dir!</h3>";
+ "<h3 id=\"data_success_msg\">Successfully loaded html from app files dir!</h3>";
@NonNull private File mPublicDir;
@NonNull private File mDemoFile;
diff --git a/webkit/integration-tests/testapp/src/main/res/raw/some_text.html b/webkit/integration-tests/testapp/src/main/res/raw/some_text.html
index 502e241..3f1dcb1 100644
--- a/webkit/integration-tests/testapp/src/main/res/raw/some_text.html
+++ b/webkit/integration-tests/testapp/src/main/res/raw/some_text.html
@@ -12,4 +12,4 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<h3>Successfully loaded html from resources!</h3>
+<h3 id="res_success_msg">Successfully loaded html from resources!</h3>
diff --git a/work/workmanager/api/api_lint.ignore b/work/workmanager/api/api_lint.ignore
index 88176e0..6185dcc 100644
--- a/work/workmanager/api/api_lint.ignore
+++ b/work/workmanager/api/api_lint.ignore
@@ -17,6 +17,14 @@
Missing nullability on field `EMPTY` in class `class androidx.work.Data`
+NoByteOrShort: androidx.work.Data#getByte(String, byte):
+ Should avoid odd sized primitives; use `int` instead of `byte` in method androidx.work.Data.getByte(String,byte)
+NoByteOrShort: androidx.work.Data#getByte(String, byte) parameter #1:
+ Should avoid odd sized primitives; use `int` instead of `byte` in parameter defaultValue in androidx.work.Data.getByte(String key, byte defaultValue)
+NoByteOrShort: androidx.work.Data.Builder#putByte(String, byte) parameter #1:
+ Should avoid odd sized primitives; use `int` instead of `byte` in parameter value in androidx.work.Data.Builder.putByte(String key, byte value)
+
+
SetterReturnsThis: androidx.work.WorkRequest.Builder#setBackoffCriteria(androidx.work.BackoffPolicy, java.time.Duration):
Methods must return the builder object (return type androidx.work.WorkRequest.Builder<B,W> instead of B): method androidx.work.WorkRequest.Builder.setBackoffCriteria(androidx.work.BackoffPolicy,java.time.Duration)
SetterReturnsThis: androidx.work.WorkRequest.Builder#setBackoffCriteria(androidx.work.BackoffPolicy, long, java.util.concurrent.TimeUnit):