Merge "Regenerate old API files using new metalava." into androidx-master-dev
diff --git a/.github/workflows/presubmit.yml b/.github/workflows/presubmit.yml
new file mode 100644
index 0000000..cb4f2b3
--- /dev/null
+++ b/.github/workflows/presubmit.yml
@@ -0,0 +1,58 @@
+name: AndroidX Presubmits
+on: [push, pull_request]
+
+jobs:
+ # This workflow contains a single job called "build"
+ build:
+ strategy:
+ fail-fast: false
+ matrix:
+ os: [macos-latest]
+ # The type of runner that the job will run on
+ runs-on: ${{ matrix.os }}
+ # Steps represent a sequence of tasks that will be executed as part of the job
+ steps:
+ - name: Setup Java environment based on setup-java
+ uses: actions/setup-java@v1
+ with:
+ java-version: "11"
+ java-package: jdk
+ architecture: x64
+ # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
+ - name: checkout
+ uses: actions/checkout@v2
+ with:
+ # Forces to fetch all history
+ fetch-depth: 0
+ # build cache
+ - name: cache
+ uses: actions/cache@v1.1.2
+ with:
+ path: ~/.gradle/caches
+ key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
+ # An ordered list of keys to use for restoring the cache if no cache hit occurred for key
+ restore-keys: |
+ ${{ runner.os }}-gradle-
+ - uses: actions/cache@v1.1.2
+ with:
+ path: ~/.gradle/wrapper
+ key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}
+ - uses: actions/cache@v1.1.2
+ with:
+ path: ~/.konan
+ key: ${{ runner.os }}-konan
+ - name: create output directory
+ run: echo ~$HOME/dist && mkdir -p ~/dist
+ - name: set environment
+ # Makes the assumption that we are running on macOS currently.
+ run: echo ::set-env name=DIST_DIR::$(echo $HOME)/dist && echo ::set-env name=ANDROID_SDK_ROOT::$(echo $HOME)/Library/Android/sdk
+ - name: test environment
+ run: echo $DIST_DIR && ls $HOME/Library/Android/sdk
+ - name: build on server
+ run: cd playground && ./gradlew --build-file build.gradle -Pandroidx.sdkPath=$(echo $HOME)/Library/Android/sdk :buildOnServer && cd ..
+ - name: Upload Results
+ if: always()
+ uses: actions/upload-artifact@v2
+ with:
+ name: artifacts
+ path: ~/dist
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
index 32e6500..29d8ebf 100644
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -5,6 +5,7 @@
<inspection_tool class="AndroidLintLambdaLast" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="AndroidLintNoHardKeywords" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="AndroidLintSyntheticAccessor" enabled="true" level="WARNING" enabled_by_default="true">
+ <scope name="buildSrc" level="WARNING" enabled="false" />
<scope name="Compose" level="WARNING" enabled="false" />
</inspection_tool>
<inspection_tool class="AndroidLintUnknownNullness" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
diff --git a/.idea/scopes/buildSrc.xml b/.idea/scopes/buildSrc.xml
new file mode 100644
index 0000000..ef38c9e7
--- /dev/null
+++ b/.idea/scopes/buildSrc.xml
@@ -0,0 +1,3 @@
+<component name="DependencyValidationManager">
+ <scope name="buildSrc" pattern="src:androidx.build..*" />
+</component>
\ No newline at end of file
diff --git a/appcompat/appcompat/api/1.3.0-alpha01.txt b/appcompat/appcompat/api/1.3.0-alpha01.txt
index e06cc21..dc3c5ab 100644
--- a/appcompat/appcompat/api/1.3.0-alpha01.txt
+++ b/appcompat/appcompat/api/1.3.0-alpha01.txt
@@ -466,7 +466,7 @@
ctor public AppCompatAutoCompleteTextView(android.content.Context, android.util.AttributeSet?, int);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportBackgroundTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
method public void setTextAppearance(android.content.Context!, int);
@@ -482,7 +482,7 @@
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportCompoundDrawablesTintMode();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setAutoSizeTextTypeUniformWithConfiguration(int, int, int, int) throws java.lang.IllegalArgumentException;
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setAutoSizeTextTypeUniformWithPresetSizes(int[], int) throws java.lang.IllegalArgumentException;
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method public void setSupportAllCaps(boolean);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
@@ -499,7 +499,7 @@
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportButtonTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportButtonTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportButtonTintList(android.content.res.ColorStateList?);
@@ -520,7 +520,7 @@
method public androidx.core.widget.RichContentReceiverCompat<android.widget.TextView!>? getRichContentReceiverCompat();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportBackgroundTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method public void setRichContentReceiverCompat(androidx.core.widget.RichContentReceiverCompat<android.widget.TextView!>?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
@@ -533,7 +533,7 @@
ctor public AppCompatImageButton(android.content.Context, android.util.AttributeSet?, int);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportBackgroundTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
}
@@ -544,7 +544,7 @@
ctor public AppCompatImageView(android.content.Context, android.util.AttributeSet?, int);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportBackgroundTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
}
@@ -555,7 +555,7 @@
ctor public AppCompatMultiAutoCompleteTextView(android.content.Context, android.util.AttributeSet?, int);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportBackgroundTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
method public void setTextAppearance(android.content.Context!, int);
@@ -569,7 +569,7 @@
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportButtonTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportButtonTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportButtonTintList(android.content.res.ColorStateList?);
@@ -597,7 +597,7 @@
ctor public AppCompatSpinner(android.content.Context, android.util.AttributeSet?, int, int, android.content.res.Resources.Theme!);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportBackgroundTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
}
@@ -613,7 +613,7 @@
method public androidx.core.text.PrecomputedTextCompat.Params getTextMetricsParamsCompat();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setAutoSizeTextTypeUniformWithConfiguration(int, int, int, int) throws java.lang.IllegalArgumentException;
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setAutoSizeTextTypeUniformWithPresetSizes(int[], int) throws java.lang.IllegalArgumentException;
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method public void setPrecomputedText(androidx.core.text.PrecomputedTextCompat);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
@@ -624,10 +624,14 @@
method public void setTextMetricsParamsCompat(androidx.core.text.PrecomputedTextCompat.Params);
}
- public class AppCompatToggleButton extends android.widget.ToggleButton {
+ public class AppCompatToggleButton extends android.widget.ToggleButton implements androidx.core.view.TintableBackgroundView {
ctor public AppCompatToggleButton(android.content.Context);
ctor public AppCompatToggleButton(android.content.Context, android.util.AttributeSet?);
ctor public AppCompatToggleButton(android.content.Context, android.util.AttributeSet?, int);
+ method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportBackgroundTintList();
+ method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
+ method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
+ method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
}
public class LinearLayoutCompat extends android.view.ViewGroup {
diff --git a/appcompat/appcompat/api/current.txt b/appcompat/appcompat/api/current.txt
index e06cc21..dc3c5ab 100644
--- a/appcompat/appcompat/api/current.txt
+++ b/appcompat/appcompat/api/current.txt
@@ -466,7 +466,7 @@
ctor public AppCompatAutoCompleteTextView(android.content.Context, android.util.AttributeSet?, int);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportBackgroundTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
method public void setTextAppearance(android.content.Context!, int);
@@ -482,7 +482,7 @@
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportCompoundDrawablesTintMode();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setAutoSizeTextTypeUniformWithConfiguration(int, int, int, int) throws java.lang.IllegalArgumentException;
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setAutoSizeTextTypeUniformWithPresetSizes(int[], int) throws java.lang.IllegalArgumentException;
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method public void setSupportAllCaps(boolean);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
@@ -499,7 +499,7 @@
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportButtonTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportButtonTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportButtonTintList(android.content.res.ColorStateList?);
@@ -520,7 +520,7 @@
method public androidx.core.widget.RichContentReceiverCompat<android.widget.TextView!>? getRichContentReceiverCompat();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportBackgroundTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method public void setRichContentReceiverCompat(androidx.core.widget.RichContentReceiverCompat<android.widget.TextView!>?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
@@ -533,7 +533,7 @@
ctor public AppCompatImageButton(android.content.Context, android.util.AttributeSet?, int);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportBackgroundTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
}
@@ -544,7 +544,7 @@
ctor public AppCompatImageView(android.content.Context, android.util.AttributeSet?, int);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportBackgroundTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
}
@@ -555,7 +555,7 @@
ctor public AppCompatMultiAutoCompleteTextView(android.content.Context, android.util.AttributeSet?, int);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportBackgroundTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
method public void setTextAppearance(android.content.Context!, int);
@@ -569,7 +569,7 @@
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportButtonTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportButtonTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportButtonTintList(android.content.res.ColorStateList?);
@@ -597,7 +597,7 @@
ctor public AppCompatSpinner(android.content.Context, android.util.AttributeSet?, int, int, android.content.res.Resources.Theme!);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportBackgroundTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
}
@@ -613,7 +613,7 @@
method public androidx.core.text.PrecomputedTextCompat.Params getTextMetricsParamsCompat();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setAutoSizeTextTypeUniformWithConfiguration(int, int, int, int) throws java.lang.IllegalArgumentException;
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setAutoSizeTextTypeUniformWithPresetSizes(int[], int) throws java.lang.IllegalArgumentException;
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method public void setPrecomputedText(androidx.core.text.PrecomputedTextCompat);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
@@ -624,10 +624,14 @@
method public void setTextMetricsParamsCompat(androidx.core.text.PrecomputedTextCompat.Params);
}
- public class AppCompatToggleButton extends android.widget.ToggleButton {
+ public class AppCompatToggleButton extends android.widget.ToggleButton implements androidx.core.view.TintableBackgroundView {
ctor public AppCompatToggleButton(android.content.Context);
ctor public AppCompatToggleButton(android.content.Context, android.util.AttributeSet?);
ctor public AppCompatToggleButton(android.content.Context, android.util.AttributeSet?, int);
+ method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportBackgroundTintList();
+ method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
+ method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
+ method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
}
public class LinearLayoutCompat extends android.view.ViewGroup {
diff --git a/appcompat/appcompat/api/public_plus_experimental_1.3.0-alpha01.txt b/appcompat/appcompat/api/public_plus_experimental_1.3.0-alpha01.txt
index b48b85b..09e7731 100644
--- a/appcompat/appcompat/api/public_plus_experimental_1.3.0-alpha01.txt
+++ b/appcompat/appcompat/api/public_plus_experimental_1.3.0-alpha01.txt
@@ -466,7 +466,7 @@
ctor public AppCompatAutoCompleteTextView(android.content.Context, android.util.AttributeSet?, int);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportBackgroundTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
method public void setTextAppearance(android.content.Context!, int);
@@ -482,7 +482,7 @@
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportCompoundDrawablesTintMode();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setAutoSizeTextTypeUniformWithConfiguration(int, int, int, int) throws java.lang.IllegalArgumentException;
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setAutoSizeTextTypeUniformWithPresetSizes(int[], int) throws java.lang.IllegalArgumentException;
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method public void setSupportAllCaps(boolean);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
@@ -499,7 +499,7 @@
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportButtonTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportButtonTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportButtonTintList(android.content.res.ColorStateList?);
@@ -520,7 +520,7 @@
method public androidx.core.widget.RichContentReceiverCompat<android.widget.TextView!>? getRichContentReceiverCompat();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportBackgroundTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method public void setRichContentReceiverCompat(androidx.core.widget.RichContentReceiverCompat<android.widget.TextView!>?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
@@ -535,7 +535,7 @@
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportImageTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportImageTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportImageTintList(android.content.res.ColorStateList?);
@@ -550,7 +550,7 @@
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportImageTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportImageTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportImageTintList(android.content.res.ColorStateList?);
@@ -563,7 +563,7 @@
ctor public AppCompatMultiAutoCompleteTextView(android.content.Context, android.util.AttributeSet?, int);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportBackgroundTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
method public void setTextAppearance(android.content.Context!, int);
@@ -577,7 +577,7 @@
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportButtonTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportButtonTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportButtonTintList(android.content.res.ColorStateList?);
@@ -605,7 +605,7 @@
ctor public AppCompatSpinner(android.content.Context, android.util.AttributeSet?, int, int, android.content.res.Resources.Theme!);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportBackgroundTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
}
@@ -621,7 +621,7 @@
method public androidx.core.text.PrecomputedTextCompat.Params getTextMetricsParamsCompat();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setAutoSizeTextTypeUniformWithConfiguration(int, int, int, int) throws java.lang.IllegalArgumentException;
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setAutoSizeTextTypeUniformWithPresetSizes(int[], int) throws java.lang.IllegalArgumentException;
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method public void setPrecomputedText(androidx.core.text.PrecomputedTextCompat);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
@@ -632,10 +632,14 @@
method public void setTextMetricsParamsCompat(androidx.core.text.PrecomputedTextCompat.Params);
}
- public class AppCompatToggleButton extends android.widget.ToggleButton {
+ public class AppCompatToggleButton extends android.widget.ToggleButton implements androidx.core.view.TintableBackgroundView {
ctor public AppCompatToggleButton(android.content.Context);
ctor public AppCompatToggleButton(android.content.Context, android.util.AttributeSet?);
ctor public AppCompatToggleButton(android.content.Context, android.util.AttributeSet?, int);
+ method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportBackgroundTintList();
+ method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
+ method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
+ method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
}
public class LinearLayoutCompat extends android.view.ViewGroup {
diff --git a/appcompat/appcompat/api/public_plus_experimental_current.txt b/appcompat/appcompat/api/public_plus_experimental_current.txt
index b48b85b..09e7731 100644
--- a/appcompat/appcompat/api/public_plus_experimental_current.txt
+++ b/appcompat/appcompat/api/public_plus_experimental_current.txt
@@ -466,7 +466,7 @@
ctor public AppCompatAutoCompleteTextView(android.content.Context, android.util.AttributeSet?, int);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportBackgroundTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
method public void setTextAppearance(android.content.Context!, int);
@@ -482,7 +482,7 @@
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportCompoundDrawablesTintMode();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setAutoSizeTextTypeUniformWithConfiguration(int, int, int, int) throws java.lang.IllegalArgumentException;
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setAutoSizeTextTypeUniformWithPresetSizes(int[], int) throws java.lang.IllegalArgumentException;
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method public void setSupportAllCaps(boolean);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
@@ -499,7 +499,7 @@
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportButtonTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportButtonTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportButtonTintList(android.content.res.ColorStateList?);
@@ -520,7 +520,7 @@
method public androidx.core.widget.RichContentReceiverCompat<android.widget.TextView!>? getRichContentReceiverCompat();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportBackgroundTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method public void setRichContentReceiverCompat(androidx.core.widget.RichContentReceiverCompat<android.widget.TextView!>?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
@@ -535,7 +535,7 @@
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportImageTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportImageTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportImageTintList(android.content.res.ColorStateList?);
@@ -550,7 +550,7 @@
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportImageTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportImageTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportImageTintList(android.content.res.ColorStateList?);
@@ -563,7 +563,7 @@
ctor public AppCompatMultiAutoCompleteTextView(android.content.Context, android.util.AttributeSet?, int);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportBackgroundTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
method public void setTextAppearance(android.content.Context!, int);
@@ -577,7 +577,7 @@
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportButtonTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportButtonTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportButtonTintList(android.content.res.ColorStateList?);
@@ -605,7 +605,7 @@
ctor public AppCompatSpinner(android.content.Context, android.util.AttributeSet?, int, int, android.content.res.Resources.Theme!);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportBackgroundTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
}
@@ -621,7 +621,7 @@
method public androidx.core.text.PrecomputedTextCompat.Params getTextMetricsParamsCompat();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setAutoSizeTextTypeUniformWithConfiguration(int, int, int, int) throws java.lang.IllegalArgumentException;
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setAutoSizeTextTypeUniformWithPresetSizes(int[], int) throws java.lang.IllegalArgumentException;
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method public void setPrecomputedText(androidx.core.text.PrecomputedTextCompat);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
@@ -632,10 +632,14 @@
method public void setTextMetricsParamsCompat(androidx.core.text.PrecomputedTextCompat.Params);
}
- public class AppCompatToggleButton extends android.widget.ToggleButton {
+ public class AppCompatToggleButton extends android.widget.ToggleButton implements androidx.core.view.TintableBackgroundView {
ctor public AppCompatToggleButton(android.content.Context);
ctor public AppCompatToggleButton(android.content.Context, android.util.AttributeSet?);
ctor public AppCompatToggleButton(android.content.Context, android.util.AttributeSet?, int);
+ method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportBackgroundTintList();
+ method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
+ method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
+ method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
}
public class LinearLayoutCompat extends android.view.ViewGroup {
diff --git a/appcompat/appcompat/api/restricted_1.3.0-alpha01.txt b/appcompat/appcompat/api/restricted_1.3.0-alpha01.txt
index d722032..6f63cec 100644
--- a/appcompat/appcompat/api/restricted_1.3.0-alpha01.txt
+++ b/appcompat/appcompat/api/restricted_1.3.0-alpha01.txt
@@ -1338,7 +1338,7 @@
ctor public AppCompatAutoCompleteTextView(android.content.Context, android.util.AttributeSet?, int);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportBackgroundTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
method public void setTextAppearance(android.content.Context!, int);
@@ -1354,7 +1354,7 @@
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportCompoundDrawablesTintMode();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setAutoSizeTextTypeUniformWithConfiguration(int, int, int, int) throws java.lang.IllegalArgumentException;
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setAutoSizeTextTypeUniformWithPresetSizes(int[], int) throws java.lang.IllegalArgumentException;
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method public void setSupportAllCaps(boolean);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
@@ -1371,7 +1371,7 @@
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportButtonTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportButtonTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportButtonTintList(android.content.res.ColorStateList?);
@@ -1401,7 +1401,7 @@
method public androidx.core.widget.RichContentReceiverCompat<android.widget.TextView!>? getRichContentReceiverCompat();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportBackgroundTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method public void setRichContentReceiverCompat(androidx.core.widget.RichContentReceiverCompat<android.widget.TextView!>?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
@@ -1416,7 +1416,7 @@
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportImageTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportImageTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportImageTintList(android.content.res.ColorStateList?);
@@ -1437,7 +1437,7 @@
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportImageTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportImageTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportImageTintList(android.content.res.ColorStateList?);
@@ -1450,7 +1450,7 @@
ctor public AppCompatMultiAutoCompleteTextView(android.content.Context, android.util.AttributeSet?, int);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportBackgroundTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
method public void setTextAppearance(android.content.Context!, int);
@@ -1464,7 +1464,7 @@
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportButtonTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportButtonTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportButtonTintList(android.content.res.ColorStateList?);
@@ -1492,7 +1492,7 @@
ctor public AppCompatSpinner(android.content.Context, android.util.AttributeSet?, int, int, android.content.res.Resources.Theme!);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportBackgroundTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
}
@@ -1508,7 +1508,7 @@
method public androidx.core.text.PrecomputedTextCompat.Params getTextMetricsParamsCompat();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setAutoSizeTextTypeUniformWithConfiguration(int, int, int, int) throws java.lang.IllegalArgumentException;
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setAutoSizeTextTypeUniformWithPresetSizes(int[], int) throws java.lang.IllegalArgumentException;
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method public void setPrecomputedText(androidx.core.text.PrecomputedTextCompat);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
@@ -1519,10 +1519,14 @@
method public void setTextMetricsParamsCompat(androidx.core.text.PrecomputedTextCompat.Params);
}
- public class AppCompatToggleButton extends android.widget.ToggleButton {
+ public class AppCompatToggleButton extends android.widget.ToggleButton implements androidx.core.view.TintableBackgroundView {
ctor public AppCompatToggleButton(android.content.Context);
ctor public AppCompatToggleButton(android.content.Context, android.util.AttributeSet?);
ctor public AppCompatToggleButton(android.content.Context, android.util.AttributeSet?, int);
+ method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportBackgroundTintList();
+ method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
+ method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
+ method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
}
@RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public class ButtonBarLayout extends android.widget.LinearLayout {
diff --git a/appcompat/appcompat/api/restricted_current.txt b/appcompat/appcompat/api/restricted_current.txt
index d722032..6f63cec 100644
--- a/appcompat/appcompat/api/restricted_current.txt
+++ b/appcompat/appcompat/api/restricted_current.txt
@@ -1338,7 +1338,7 @@
ctor public AppCompatAutoCompleteTextView(android.content.Context, android.util.AttributeSet?, int);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportBackgroundTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
method public void setTextAppearance(android.content.Context!, int);
@@ -1354,7 +1354,7 @@
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportCompoundDrawablesTintMode();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setAutoSizeTextTypeUniformWithConfiguration(int, int, int, int) throws java.lang.IllegalArgumentException;
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setAutoSizeTextTypeUniformWithPresetSizes(int[], int) throws java.lang.IllegalArgumentException;
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method public void setSupportAllCaps(boolean);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
@@ -1371,7 +1371,7 @@
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportButtonTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportButtonTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportButtonTintList(android.content.res.ColorStateList?);
@@ -1401,7 +1401,7 @@
method public androidx.core.widget.RichContentReceiverCompat<android.widget.TextView!>? getRichContentReceiverCompat();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportBackgroundTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method public void setRichContentReceiverCompat(androidx.core.widget.RichContentReceiverCompat<android.widget.TextView!>?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
@@ -1416,7 +1416,7 @@
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportImageTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportImageTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportImageTintList(android.content.res.ColorStateList?);
@@ -1437,7 +1437,7 @@
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportImageTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportImageTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportImageTintList(android.content.res.ColorStateList?);
@@ -1450,7 +1450,7 @@
ctor public AppCompatMultiAutoCompleteTextView(android.content.Context, android.util.AttributeSet?, int);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportBackgroundTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
method public void setTextAppearance(android.content.Context!, int);
@@ -1464,7 +1464,7 @@
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportButtonTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportButtonTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportButtonTintList(android.content.res.ColorStateList?);
@@ -1492,7 +1492,7 @@
ctor public AppCompatSpinner(android.content.Context, android.util.AttributeSet?, int, int, android.content.res.Resources.Theme!);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportBackgroundTintList();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
}
@@ -1508,7 +1508,7 @@
method public androidx.core.text.PrecomputedTextCompat.Params getTextMetricsParamsCompat();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setAutoSizeTextTypeUniformWithConfiguration(int, int, int, int) throws java.lang.IllegalArgumentException;
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setAutoSizeTextTypeUniformWithPresetSizes(int[], int) throws java.lang.IllegalArgumentException;
- method public void setBackgroundDrawable(android.graphics.drawable.Drawable!);
+ method public void setBackgroundDrawable(android.graphics.drawable.Drawable?);
method public void setPrecomputedText(androidx.core.text.PrecomputedTextCompat);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
@@ -1519,10 +1519,14 @@
method public void setTextMetricsParamsCompat(androidx.core.text.PrecomputedTextCompat.Params);
}
- public class AppCompatToggleButton extends android.widget.ToggleButton {
+ public class AppCompatToggleButton extends android.widget.ToggleButton implements androidx.core.view.TintableBackgroundView {
ctor public AppCompatToggleButton(android.content.Context);
ctor public AppCompatToggleButton(android.content.Context, android.util.AttributeSet?);
ctor public AppCompatToggleButton(android.content.Context, android.util.AttributeSet?, int);
+ method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.content.res.ColorStateList? getSupportBackgroundTintList();
+ method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.PorterDuff.Mode? getSupportBackgroundTintMode();
+ method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintList(android.content.res.ColorStateList?);
+ method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setSupportBackgroundTintMode(android.graphics.PorterDuff.Mode?);
}
@RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public class ButtonBarLayout extends android.widget.LinearLayout {
diff --git a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/widget/AppCompatToggleButtonTest.java b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/widget/AppCompatToggleButtonTest.java
index 12a3d27..0d1c92e 100644
--- a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/widget/AppCompatToggleButtonTest.java
+++ b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/widget/AppCompatToggleButtonTest.java
@@ -19,36 +19,30 @@
import static org.junit.Assert.assertEquals;
import android.graphics.Typeface;
-import android.view.ViewGroup;
import androidx.appcompat.test.R;
import androidx.core.content.res.ResourcesCompat;
import androidx.test.ext.junit.runners.AndroidJUnit4;
-import androidx.test.filters.SmallTest;
-import androidx.test.rule.ActivityTestRule;
+import androidx.test.filters.MediumTest;
-import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Provides tests specific to {@link AppCompatToggleButton} class.
*/
-@SmallTest
+@MediumTest
@RunWith(AndroidJUnit4.class)
-public class AppCompatToggleButtonTest {
+public class AppCompatToggleButtonTest
+ extends AppCompatBaseViewTest<AppCompatToggleButtonActivity, AppCompatToggleButton> {
+ public AppCompatToggleButtonTest() {
+ super(AppCompatToggleButtonActivity.class);
+ }
- @Rule
- public final ActivityTestRule<AppCompatToggleButtonActivity> mActivityTestRule =
- new ActivityTestRule(AppCompatToggleButtonActivity.class);
- private AppCompatToggleButtonActivity mActivity;
- private ViewGroup mContainer;
-
- @Before
- public void setUp() {
- mActivity = mActivityTestRule.getActivity();
- mContainer = mActivity.findViewById(androidx.appcompat.test.R.id.container);
+ @Override
+ protected boolean hasBackgroundByDefault() {
+ // Button has default background set on it
+ return true;
}
@Test
diff --git a/appcompat/appcompat/src/androidTest/res/layout/appcompat_button_activity.xml b/appcompat/appcompat/src/androidTest/res/layout/appcompat_button_activity.xml
index 0f7cc93..a2f93eb 100644
--- a/appcompat/appcompat/src/androidTest/res/layout/appcompat_button_activity.xml
+++ b/appcompat/appcompat/src/androidTest/res/layout/appcompat_button_activity.xml
@@ -63,7 +63,7 @@
app:backgroundTintMode="src_in"
android:focusable="false" />
- <androidx.appcompat.widget.AppCompatTextView
+ <androidx.appcompat.widget.AppCompatButton
android:id="@+id/view_tinted_background"
android:layout_width="match_parent"
android:layout_height="wrap_content"
diff --git a/appcompat/appcompat/src/androidTest/res/layout/appcompat_togglebutton_activity.xml b/appcompat/appcompat/src/androidTest/res/layout/appcompat_togglebutton_activity.xml
index 225c109..b5f6de6 100644
--- a/appcompat/appcompat/src/androidTest/res/layout/appcompat_togglebutton_activity.xml
+++ b/appcompat/appcompat/src/androidTest/res/layout/appcompat_togglebutton_activity.xml
@@ -1,5 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2018 The Android Open Source Project
+<?xml version="1.0" encoding="utf-8"?><!-- Copyright (C) 2018 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.
@@ -14,19 +13,60 @@
limitations under the License.
-->
-<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- android:id="@+id/container"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:id="@+id/container"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <View
+ android:id="@+id/for_focus"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
+ android:layout_height="4dp"
+ android:focusable="true" />
<androidx.appcompat.widget.AppCompatToggleButton
- android:id="@+id/togglebutton_fontresource"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/sample_text1"
- app:fontFamily="@font/samplefont" />
+ android:id="@+id/view_tinted_no_background"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:focusable="false"
+ app:backgroundTint="@color/color_state_list_lilac"
+ app:backgroundTintMode="src_in" />
+
+ <androidx.appcompat.widget.AppCompatToggleButton
+ android:id="@+id/view_tinted_background"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="@drawable/test_drawable"
+ android:focusable="false"
+ app:backgroundTint="@color/color_state_list_lilac"
+ app:backgroundTintMode="src_in" />
+
+ <androidx.appcompat.widget.AppCompatToggleButton
+ android:id="@+id/view_untinted_no_background"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:focusable="false" />
+
+ <androidx.appcompat.widget.AppCompatToggleButton
+ android:id="@+id/view_untinted_background"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="@drawable/test_background_green"
+ android:focusable="false" />
+
+ <androidx.appcompat.widget.AppCompatToggleButton
+ android:id="@+id/button_untinted"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:focusable="false" />
+
+ <androidx.appcompat.widget.AppCompatToggleButton
+ android:id="@+id/togglebutton_fontresource"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/sample_text1"
+ app:fontFamily="@font/samplefont" />
</LinearLayout>
\ No newline at end of file
diff --git a/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatAutoCompleteTextView.java b/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatAutoCompleteTextView.java
index 1bc06a4..3190ebc 100644
--- a/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatAutoCompleteTextView.java
+++ b/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatAutoCompleteTextView.java
@@ -106,7 +106,7 @@
}
@Override
- public void setBackgroundDrawable(Drawable background) {
+ public void setBackgroundDrawable(@Nullable Drawable background) {
super.setBackgroundDrawable(background);
if (mBackgroundTintHelper != null) {
mBackgroundTintHelper.onSetBackgroundDrawable(background);
diff --git a/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatButton.java b/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatButton.java
index d51bc16..7f3a37e 100644
--- a/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatButton.java
+++ b/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatButton.java
@@ -48,6 +48,7 @@
* {@link androidx.core.view.ViewCompat}.</li>
* <li>Allows setting of the background tint using {@link R.attr#backgroundTint} and
* {@link R.attr#backgroundTintMode}.</li>
+ * <li>Allows setting of the font family using {@link android.R.attr#fontFamily}</li>
* </ul>
*
* <p>This will automatically be used when you use {@link Button} in your layouts
@@ -92,7 +93,7 @@
}
@Override
- public void setBackgroundDrawable(Drawable background) {
+ public void setBackgroundDrawable(@Nullable Drawable background) {
super.setBackgroundDrawable(background);
if (mBackgroundTintHelper != null) {
mBackgroundTintHelper.onSetBackgroundDrawable(background);
diff --git a/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatCheckBox.java b/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatCheckBox.java
index 1a72501..1adf364 100644
--- a/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatCheckBox.java
+++ b/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatCheckBox.java
@@ -209,7 +209,7 @@
}
@Override
- public void setBackgroundDrawable(Drawable background) {
+ public void setBackgroundDrawable(@Nullable Drawable background) {
super.setBackgroundDrawable(background);
if (mBackgroundTintHelper != null) {
mBackgroundTintHelper.onSetBackgroundDrawable(background);
diff --git a/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatEditText.java b/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatEditText.java
index 3982161..73874b8 100644
--- a/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatEditText.java
+++ b/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatEditText.java
@@ -121,7 +121,7 @@
}
@Override
- public void setBackgroundDrawable(Drawable background) {
+ public void setBackgroundDrawable(@Nullable Drawable background) {
super.setBackgroundDrawable(background);
if (mBackgroundTintHelper != null) {
mBackgroundTintHelper.onSetBackgroundDrawable(background);
diff --git a/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatImageButton.java b/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatImageButton.java
index de944c6..fe65b79 100644
--- a/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatImageButton.java
+++ b/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatImageButton.java
@@ -122,7 +122,7 @@
}
@Override
- public void setBackgroundDrawable(Drawable background) {
+ public void setBackgroundDrawable(@Nullable Drawable background) {
super.setBackgroundDrawable(background);
if (mBackgroundTintHelper != null) {
mBackgroundTintHelper.onSetBackgroundDrawable(background);
diff --git a/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatImageView.java b/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatImageView.java
index 53ec8e4..ba964d9 100644
--- a/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatImageView.java
+++ b/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatImageView.java
@@ -132,7 +132,7 @@
}
@Override
- public void setBackgroundDrawable(Drawable background) {
+ public void setBackgroundDrawable(@Nullable Drawable background) {
super.setBackgroundDrawable(background);
if (mBackgroundTintHelper != null) {
mBackgroundTintHelper.onSetBackgroundDrawable(background);
diff --git a/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatMultiAutoCompleteTextView.java b/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatMultiAutoCompleteTextView.java
index 123df21..3910f28 100644
--- a/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatMultiAutoCompleteTextView.java
+++ b/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatMultiAutoCompleteTextView.java
@@ -104,7 +104,7 @@
}
@Override
- public void setBackgroundDrawable(Drawable background) {
+ public void setBackgroundDrawable(@Nullable Drawable background) {
super.setBackgroundDrawable(background);
if (mBackgroundTintHelper != null) {
mBackgroundTintHelper.onSetBackgroundDrawable(background);
diff --git a/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatRadioButton.java b/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatRadioButton.java
index 056d8bd..2550334 100644
--- a/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatRadioButton.java
+++ b/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatRadioButton.java
@@ -208,7 +208,7 @@
}
@Override
- public void setBackgroundDrawable(Drawable background) {
+ public void setBackgroundDrawable(@Nullable Drawable background) {
super.setBackgroundDrawable(background);
if (mBackgroundTintHelper != null) {
mBackgroundTintHelper.onSetBackgroundDrawable(background);
diff --git a/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatSpinner.java b/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatSpinner.java
index 3662dab..a7751b1 100644
--- a/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatSpinner.java
+++ b/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatSpinner.java
@@ -481,7 +481,7 @@
}
@Override
- public void setBackgroundDrawable(Drawable background) {
+ public void setBackgroundDrawable(@Nullable Drawable background) {
super.setBackgroundDrawable(background);
if (mBackgroundTintHelper != null) {
mBackgroundTintHelper.onSetBackgroundDrawable(background);
diff --git a/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatTextView.java b/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatTextView.java
index c1728b2..636337f 100644
--- a/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatTextView.java
+++ b/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatTextView.java
@@ -120,7 +120,7 @@
}
@Override
- public void setBackgroundDrawable(Drawable background) {
+ public void setBackgroundDrawable(@Nullable Drawable background) {
super.setBackgroundDrawable(background);
if (mBackgroundTintHelper != null) {
mBackgroundTintHelper.onSetBackgroundDrawable(background);
diff --git a/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatToggleButton.java b/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatToggleButton.java
index a98012b..f03aab1 100644
--- a/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatToggleButton.java
+++ b/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatToggleButton.java
@@ -16,25 +16,40 @@
package androidx.appcompat.widget;
+import static androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX;
+
import android.content.Context;
+import android.content.res.ColorStateList;
+import android.graphics.PorterDuff;
+import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.ToggleButton;
+import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import androidx.annotation.RestrictTo;
+import androidx.appcompat.R;
+import androidx.core.view.TintableBackgroundView;
+import androidx.core.view.ViewCompat;
/**
* A {@link ToggleButton} which supports compatible features on older versions of the platform,
* including:
* <ul>
+ * <li>Allows dynamic tint of its background via the background tint methods in
+ * {@link androidx.core.view.ViewCompat}.</li>
+ * <li>Allows setting of the background tint using {@link R.attr#backgroundTint} and
+ * {@link R.attr#backgroundTintMode}.</li>
* <li>Allows setting of the font family using {@link android.R.attr#fontFamily}</li>
* </ul>
*
* <p>This will automatically be used when you use {@link ToggleButton} in your layouts.
* You should only need to manually use this class when writing custom views.</p>
*/
-public class AppCompatToggleButton extends ToggleButton {
+public class AppCompatToggleButton extends ToggleButton implements TintableBackgroundView {
+ private final AppCompatBackgroundHelper mBackgroundTintHelper;
private final AppCompatTextHelper mTextHelper;
public AppCompatToggleButton(@NonNull Context context) {
@@ -51,7 +66,93 @@
ThemeUtils.checkAppCompatTheme(this, getContext());
+ mBackgroundTintHelper = new AppCompatBackgroundHelper(this);
+ mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);
+
mTextHelper = new AppCompatTextHelper(this);
mTextHelper.loadFromAttributes(attrs, defStyleAttr);
}
+
+ @Override
+ public void setBackgroundResource(@DrawableRes int resId) {
+ super.setBackgroundResource(resId);
+ if (mBackgroundTintHelper != null) {
+ mBackgroundTintHelper.onSetBackgroundResource(resId);
+ }
+ }
+
+ @Override
+ public void setBackgroundDrawable(@Nullable Drawable background) {
+ super.setBackgroundDrawable(background);
+ if (mBackgroundTintHelper != null) {
+ mBackgroundTintHelper.onSetBackgroundDrawable(background);
+ }
+ }
+
+ /**
+ * This should be accessed via
+ * {@link ViewCompat#setBackgroundTintList(android.view.View, ColorStateList)}
+ *
+ * @hide
+ */
+ @RestrictTo(LIBRARY_GROUP_PREFIX)
+ @Override
+ public void setSupportBackgroundTintList(@Nullable ColorStateList tint) {
+ if (mBackgroundTintHelper != null) {
+ mBackgroundTintHelper.setSupportBackgroundTintList(tint);
+ }
+ }
+
+ /**
+ * This should be accessed via
+ * {@link ViewCompat#getBackgroundTintList(android.view.View)}
+ *
+ * @hide
+ */
+ @RestrictTo(LIBRARY_GROUP_PREFIX)
+ @Override
+ @Nullable
+ public ColorStateList getSupportBackgroundTintList() {
+ return mBackgroundTintHelper != null
+ ? mBackgroundTintHelper.getSupportBackgroundTintList() : null;
+ }
+
+ /**
+ * This should be accessed via
+ * {@link ViewCompat#setBackgroundTintMode(android.view.View, PorterDuff.Mode)}
+ *
+ * @hide
+ */
+ @RestrictTo(LIBRARY_GROUP_PREFIX)
+ @Override
+ public void setSupportBackgroundTintMode(@Nullable PorterDuff.Mode tintMode) {
+ if (mBackgroundTintHelper != null) {
+ mBackgroundTintHelper.setSupportBackgroundTintMode(tintMode);
+ }
+ }
+
+ /**
+ * This should be accessed via
+ * {@link ViewCompat#getBackgroundTintMode(android.view.View)}
+ *
+ * @hide
+ */
+ @RestrictTo(LIBRARY_GROUP_PREFIX)
+ @Override
+ @Nullable
+ public PorterDuff.Mode getSupportBackgroundTintMode() {
+ return mBackgroundTintHelper != null
+ ? mBackgroundTintHelper.getSupportBackgroundTintMode() : null;
+ }
+
+ @Override
+ protected void drawableStateChanged() {
+ super.drawableStateChanged();
+ if (mBackgroundTintHelper != null) {
+ mBackgroundTintHelper.applySupportBackgroundTint();
+ }
+ if (mTextHelper != null) {
+ mTextHelper.applyCompoundDrawablesTints();
+ }
+ }
}
diff --git a/browser/browser/api/1.3.0-alpha03.txt b/browser/browser/api/1.3.0-alpha03.txt
index 659600b..2ece108 100644
--- a/browser/browser/api/1.3.0-alpha03.txt
+++ b/browser/browser/api/1.3.0-alpha03.txt
@@ -334,11 +334,11 @@
public final class TrustedWebActivityServiceConnection {
method public boolean areNotificationsEnabled(String) throws android.os.RemoteException;
method public void cancel(String, int) throws android.os.RemoteException;
- method public android.os.Bundle? extraCommand(String, android.os.Bundle, androidx.browser.trusted.TrustedWebActivityCallback?) throws android.os.RemoteException;
method public android.content.ComponentName getComponentName();
method public android.graphics.Bitmap? getSmallIconBitmap() throws android.os.RemoteException;
method public int getSmallIconId() throws android.os.RemoteException;
method public boolean notify(String, int, android.app.Notification, String) throws android.os.RemoteException;
+ method public android.os.Bundle? sendExtraCommand(String, android.os.Bundle, androidx.browser.trusted.TrustedWebActivityCallback?) throws android.os.RemoteException;
}
public final class TrustedWebActivityServiceConnectionPool {
diff --git a/browser/browser/api/current.txt b/browser/browser/api/current.txt
index 659600b..2ece108 100644
--- a/browser/browser/api/current.txt
+++ b/browser/browser/api/current.txt
@@ -334,11 +334,11 @@
public final class TrustedWebActivityServiceConnection {
method public boolean areNotificationsEnabled(String) throws android.os.RemoteException;
method public void cancel(String, int) throws android.os.RemoteException;
- method public android.os.Bundle? extraCommand(String, android.os.Bundle, androidx.browser.trusted.TrustedWebActivityCallback?) throws android.os.RemoteException;
method public android.content.ComponentName getComponentName();
method public android.graphics.Bitmap? getSmallIconBitmap() throws android.os.RemoteException;
method public int getSmallIconId() throws android.os.RemoteException;
method public boolean notify(String, int, android.app.Notification, String) throws android.os.RemoteException;
+ method public android.os.Bundle? sendExtraCommand(String, android.os.Bundle, androidx.browser.trusted.TrustedWebActivityCallback?) throws android.os.RemoteException;
}
public final class TrustedWebActivityServiceConnectionPool {
diff --git a/browser/browser/api/public_plus_experimental_1.3.0-alpha03.txt b/browser/browser/api/public_plus_experimental_1.3.0-alpha03.txt
index 659600b..2ece108 100644
--- a/browser/browser/api/public_plus_experimental_1.3.0-alpha03.txt
+++ b/browser/browser/api/public_plus_experimental_1.3.0-alpha03.txt
@@ -334,11 +334,11 @@
public final class TrustedWebActivityServiceConnection {
method public boolean areNotificationsEnabled(String) throws android.os.RemoteException;
method public void cancel(String, int) throws android.os.RemoteException;
- method public android.os.Bundle? extraCommand(String, android.os.Bundle, androidx.browser.trusted.TrustedWebActivityCallback?) throws android.os.RemoteException;
method public android.content.ComponentName getComponentName();
method public android.graphics.Bitmap? getSmallIconBitmap() throws android.os.RemoteException;
method public int getSmallIconId() throws android.os.RemoteException;
method public boolean notify(String, int, android.app.Notification, String) throws android.os.RemoteException;
+ method public android.os.Bundle? sendExtraCommand(String, android.os.Bundle, androidx.browser.trusted.TrustedWebActivityCallback?) throws android.os.RemoteException;
}
public final class TrustedWebActivityServiceConnectionPool {
diff --git a/browser/browser/api/public_plus_experimental_current.txt b/browser/browser/api/public_plus_experimental_current.txt
index 659600b..2ece108 100644
--- a/browser/browser/api/public_plus_experimental_current.txt
+++ b/browser/browser/api/public_plus_experimental_current.txt
@@ -334,11 +334,11 @@
public final class TrustedWebActivityServiceConnection {
method public boolean areNotificationsEnabled(String) throws android.os.RemoteException;
method public void cancel(String, int) throws android.os.RemoteException;
- method public android.os.Bundle? extraCommand(String, android.os.Bundle, androidx.browser.trusted.TrustedWebActivityCallback?) throws android.os.RemoteException;
method public android.content.ComponentName getComponentName();
method public android.graphics.Bitmap? getSmallIconBitmap() throws android.os.RemoteException;
method public int getSmallIconId() throws android.os.RemoteException;
method public boolean notify(String, int, android.app.Notification, String) throws android.os.RemoteException;
+ method public android.os.Bundle? sendExtraCommand(String, android.os.Bundle, androidx.browser.trusted.TrustedWebActivityCallback?) throws android.os.RemoteException;
}
public final class TrustedWebActivityServiceConnectionPool {
diff --git a/browser/browser/api/restricted_1.3.0-alpha03.txt b/browser/browser/api/restricted_1.3.0-alpha03.txt
index d514deb..5594db9 100644
--- a/browser/browser/api/restricted_1.3.0-alpha03.txt
+++ b/browser/browser/api/restricted_1.3.0-alpha03.txt
@@ -345,11 +345,11 @@
public final class TrustedWebActivityServiceConnection {
method public boolean areNotificationsEnabled(String) throws android.os.RemoteException;
method public void cancel(String, int) throws android.os.RemoteException;
- method public android.os.Bundle? extraCommand(String, android.os.Bundle, androidx.browser.trusted.TrustedWebActivityCallback?) throws android.os.RemoteException;
method public android.content.ComponentName getComponentName();
method public android.graphics.Bitmap? getSmallIconBitmap() throws android.os.RemoteException;
method public int getSmallIconId() throws android.os.RemoteException;
method public boolean notify(String, int, android.app.Notification, String) throws android.os.RemoteException;
+ method public android.os.Bundle? sendExtraCommand(String, android.os.Bundle, androidx.browser.trusted.TrustedWebActivityCallback?) throws android.os.RemoteException;
}
public final class TrustedWebActivityServiceConnectionPool {
diff --git a/browser/browser/api/restricted_current.txt b/browser/browser/api/restricted_current.txt
index d514deb..5594db9 100644
--- a/browser/browser/api/restricted_current.txt
+++ b/browser/browser/api/restricted_current.txt
@@ -345,11 +345,11 @@
public final class TrustedWebActivityServiceConnection {
method public boolean areNotificationsEnabled(String) throws android.os.RemoteException;
method public void cancel(String, int) throws android.os.RemoteException;
- method public android.os.Bundle? extraCommand(String, android.os.Bundle, androidx.browser.trusted.TrustedWebActivityCallback?) throws android.os.RemoteException;
method public android.content.ComponentName getComponentName();
method public android.graphics.Bitmap? getSmallIconBitmap() throws android.os.RemoteException;
method public int getSmallIconId() throws android.os.RemoteException;
method public boolean notify(String, int, android.app.Notification, String) throws android.os.RemoteException;
+ method public android.os.Bundle? sendExtraCommand(String, android.os.Bundle, androidx.browser.trusted.TrustedWebActivityCallback?) throws android.os.RemoteException;
}
public final class TrustedWebActivityServiceConnectionPool {
diff --git a/browser/browser/src/main/java/androidx/browser/trusted/TrustedWebActivityServiceConnection.java b/browser/browser/src/main/java/androidx/browser/trusted/TrustedWebActivityServiceConnection.java
index 2f95d09..56b62f1 100644
--- a/browser/browser/src/main/java/androidx/browser/trusted/TrustedWebActivityServiceConnection.java
+++ b/browser/browser/src/main/java/androidx/browser/trusted/TrustedWebActivityServiceConnection.java
@@ -177,7 +177,7 @@
*/
@SuppressWarnings("NullAway") // TODO: b/142938599
@Nullable
- public Bundle extraCommand(@NonNull String commandName, @NonNull Bundle args,
+ public Bundle sendExtraCommand(@NonNull String commandName, @NonNull Bundle args,
@Nullable TrustedWebActivityCallback callback) throws RemoteException {
ITrustedWebActivityCallback callbackBinder = wrapCallback(callback);
IBinder binder = callbackBinder == null ? null : callbackBinder.asBinder();
diff --git a/buildSrc/src/main/kotlin/androidx/build/AndroidXGradleProperties.kt b/buildSrc/src/main/kotlin/androidx/build/AndroidXGradleProperties.kt
index 13ae3be..cc59e99 100644
--- a/buildSrc/src/main/kotlin/androidx/build/AndroidXGradleProperties.kt
+++ b/buildSrc/src/main/kotlin/androidx/build/AndroidXGradleProperties.kt
@@ -51,3 +51,9 @@
*/
fun Project.isCoverageEnabled(): Boolean =
(project.findProperty("androidx.coverageEnabled") as? String)?.toBoolean() ?: true
+
+/**
+ * Returns the path to the Android SDK to be used.
+ */
+fun Project.androidxSdkPath(): String? =
+ project.findProperty("androidx.sdkPath") as? String
diff --git a/buildSrc/src/main/kotlin/androidx/build/SdkHelper.kt b/buildSrc/src/main/kotlin/androidx/build/SdkHelper.kt
index e0473ec..c18a3ec 100644
--- a/buildSrc/src/main/kotlin/androidx/build/SdkHelper.kt
+++ b/buildSrc/src/main/kotlin/androidx/build/SdkHelper.kt
@@ -52,6 +52,11 @@
* Returns the root project's platform-specific SDK path as a file.
*/
fun Project.getSdkPath(): File {
+ val sdkPath = androidxSdkPath()
+ if (sdkPath != null) {
+ return File(sdkPath)
+ }
+
val osName = System.getProperty("os.name").toLowerCase(Locale.US)
val isMacOsX = osName.contains("mac os x") ||
osName.contains("darwin") ||
diff --git a/busytown/impl/build.sh b/busytown/impl/build.sh
index b24b96f..c80f25e 100755
--- a/busytown/impl/build.sh
+++ b/busytown/impl/build.sh
@@ -31,5 +31,5 @@
echoAndDo "ls -la out"
# run gradle
-echoAndDo OUT_DIR=out/ui DIST_DIR=$DIST_DIR/ui ANDROID_HOME=./prebuilts/fullsdk-linux frameworks/support/ui/gradlew -p frameworks/support/ui --stacktrace "$@"
-echoAndDo OUT_DIR=out DIST_DIR=$DIST_DIR ANDROID_HOME=./prebuilts/fullsdk-linux frameworks/support/gradlew -p frameworks/support --stacktrace "$@"
+echoAndDo OUT_DIR=out/ui DIST_DIR=$DIST_DIR/ui ANDROID_HOME=./prebuilts/fullsdk-linux frameworks/support/ui/gradlew -p frameworks/support/ui "$@"
+echoAndDo OUT_DIR=out DIST_DIR=$DIST_DIR ANDROID_HOME=./prebuilts/fullsdk-linux frameworks/support/gradlew -p frameworks/support "$@"
diff --git a/camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/internal/Camera2CameraImplTest.java b/camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/internal/Camera2CameraImplTest.java
index 1424890..0630e97 100644
--- a/camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/internal/Camera2CameraImplTest.java
+++ b/camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/internal/Camera2CameraImplTest.java
@@ -49,6 +49,7 @@
import androidx.camera.core.CameraControl;
import androidx.camera.core.CameraInfo;
import androidx.camera.core.CameraSelector;
+import androidx.camera.core.CameraUnavailableException;
import androidx.camera.core.UseCase;
import androidx.camera.core.impl.CameraCaptureCallback;
import androidx.camera.core.impl.CameraCaptureResult;
@@ -148,7 +149,7 @@
}
@Before
- public void setup() {
+ public void setup() throws CameraUnavailableException {
assumeTrue(CameraUtil.deviceHasCamera());
mMockOnImageAvailableListener = Mockito.mock(ImageReader.OnImageAvailableListener.class);
mSessionStateCallback = new SemaphoreReleasingCamera2Callbacks.SessionStateCallback();
diff --git a/camera/camera-camera2/src/main/java/androidx/camera/camera2/Camera2Config.java b/camera/camera-camera2/src/main/java/androidx/camera/camera2/Camera2Config.java
index 51ea432..1c227eb 100644
--- a/camera/camera-camera2/src/main/java/androidx/camera/camera2/Camera2Config.java
+++ b/camera/camera-camera2/src/main/java/androidx/camera/camera2/Camera2Config.java
@@ -24,7 +24,9 @@
import androidx.camera.camera2.internal.ImageCaptureConfigProvider;
import androidx.camera.camera2.internal.PreviewConfigProvider;
import androidx.camera.camera2.internal.VideoCaptureConfigProvider;
+import androidx.camera.core.CameraUnavailableException;
import androidx.camera.core.CameraXConfig;
+import androidx.camera.core.InitializationException;
import androidx.camera.core.impl.CameraDeviceSurfaceManager;
import androidx.camera.core.impl.CameraFactory;
import androidx.camera.core.impl.ExtendableUseCaseConfigFactory;
@@ -52,8 +54,13 @@
CameraFactory.Provider cameraFactoryProvider = Camera2CameraFactory::new;
// Create the DeviceSurfaceManager for Camera2
- CameraDeviceSurfaceManager.Provider surfaceManagerProvider =
- Camera2DeviceSurfaceManager::new;
+ CameraDeviceSurfaceManager.Provider surfaceManagerProvider = context -> {
+ try {
+ return new Camera2DeviceSurfaceManager(context);
+ } catch (CameraUnavailableException e) {
+ throw new InitializationException(e);
+ }
+ };
// Create default configuration factory
UseCaseConfigFactory.Provider configFactoryProvider = context -> {
diff --git a/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/Camera2CameraFactory.java b/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/Camera2CameraFactory.java
index 7583185..b67aa3d 100644
--- a/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/Camera2CameraFactory.java
+++ b/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/Camera2CameraFactory.java
@@ -17,11 +17,11 @@
package androidx.camera.camera2.internal;
import android.content.Context;
-import android.hardware.camera2.CameraAccessException;
import androidx.annotation.NonNull;
+import androidx.camera.camera2.internal.compat.CameraAccessExceptionCompat;
import androidx.camera.camera2.internal.compat.CameraManagerCompat;
-import androidx.camera.core.CameraInfoUnavailableException;
+import androidx.camera.core.CameraUnavailableException;
import androidx.camera.core.impl.CameraFactory;
import androidx.camera.core.impl.CameraInternal;
import androidx.camera.core.impl.CameraStateRegistry;
@@ -52,8 +52,7 @@
@Override
@NonNull
- public CameraInternal getCamera(@NonNull String cameraId)
- throws CameraInfoUnavailableException {
+ public CameraInternal getCamera(@NonNull String cameraId) throws CameraUnavailableException {
if (!getAvailableCameraIds().contains(cameraId)) {
throw new IllegalArgumentException(
"The given camera id is not on the available camera id list.");
@@ -64,13 +63,12 @@
@Override
@NonNull
- public Set<String> getAvailableCameraIds() throws CameraInfoUnavailableException {
+ public Set<String> getAvailableCameraIds() throws CameraUnavailableException {
List<String> camerasList;
try {
- camerasList = Arrays.asList(mCameraManager.unwrap().getCameraIdList());
- } catch (CameraAccessException e) {
- throw new CameraInfoUnavailableException(
- "Unable to retrieve list of cameras on device.", e);
+ camerasList = Arrays.asList(mCameraManager.getCameraIdList());
+ } catch (CameraAccessExceptionCompat e) {
+ throw CameraUnavailableExceptionHelper.createFrom(e);
}
// Use a LinkedHashSet to preserve order
return new LinkedHashSet<>(camerasList);
diff --git a/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/Camera2CameraImpl.java b/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/Camera2CameraImpl.java
index 60c9723..a9f9852 100644
--- a/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/Camera2CameraImpl.java
+++ b/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/Camera2CameraImpl.java
@@ -35,9 +35,11 @@
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.camera.camera2.internal.annotation.CameraExecutor;
+import androidx.camera.camera2.internal.compat.CameraAccessExceptionCompat;
import androidx.camera.camera2.internal.compat.CameraManagerCompat;
import androidx.camera.core.CameraControl;
import androidx.camera.core.CameraInfo;
+import androidx.camera.core.CameraUnavailableException;
import androidx.camera.core.Preview;
import androidx.camera.core.UseCase;
import androidx.camera.core.impl.CameraControlInternal;
@@ -173,14 +175,14 @@
* Used as a fence to ensure the number of simultaneously
* opened cameras is limited.
* @param executor the executor for on which all camera operations run
- * @throws IllegalStateException if the {@link CameraCharacteristics} is unavailable. This
- * could occur if the camera was disconnected.
+ * @throws CameraUnavailableException if the {@link CameraCharacteristics} is unavailable. This
+ * could occur if the camera was disconnected.
*/
Camera2CameraImpl(@NonNull CameraManagerCompat cameraManager,
@NonNull String cameraId,
@NonNull CameraStateRegistry cameraStateRegistry,
@NonNull Executor executor,
- @NonNull Handler schedulerHandler) {
+ @NonNull Handler schedulerHandler) throws CameraUnavailableException {
mCameraManager = cameraManager;
mCameraStateRegistry = cameraStateRegistry;
ScheduledExecutorService executorScheduler =
@@ -192,7 +194,7 @@
try {
CameraCharacteristics cameraCharacteristics =
- mCameraManager.unwrap().getCameraCharacteristics(cameraId);
+ mCameraManager.getCameraCharacteristics(cameraId);
mCameraControlInternal = new Camera2CameraControl(cameraCharacteristics,
executorScheduler, mExecutor, new ControlUpdateListenerInternal());
mCameraInfoInternal = new Camera2CameraInfoImpl(
@@ -202,8 +204,8 @@
Camera2CameraInfoImpl camera2CameraInfo = (Camera2CameraInfoImpl) mCameraInfoInternal;
mCaptureSessionBuilder.setSupportedHardwareLevel(
camera2CameraInfo.getSupportedHardwareLevel());
- } catch (CameraAccessException e) {
- throw new IllegalStateException("Cannot access camera", e);
+ } catch (CameraAccessExceptionCompat e) {
+ throw CameraUnavailableExceptionHelper.createFrom(e);
}
mCaptureSessionBuilder.setExecutor(mExecutor);
mCaptureSessionBuilder.setCompatHandler(schedulerHandler);
@@ -856,10 +858,18 @@
try {
mCameraManager.openCamera(mCameraInfoInternal.getCameraId(), mExecutor,
createDeviceStateCallback());
- } catch (CameraAccessException e) {
- // Camera2 will call the onError() callback with the specific error code that caused
- // this failure. No need to do anything here.
+ } catch (CameraAccessExceptionCompat e) {
debugLog("Unable to open camera due to " + e.getMessage());
+ switch (e.getReason()) {
+ case CameraAccessExceptionCompat.CAMERA_UNAVAILABLE_DO_NOT_DISTURB:
+ // Camera2 is unable to call the onError() callback for this case. It has to
+ // reset the state here.
+ setState(InternalState.INITIALIZED);
+ break;
+ default:
+ // Camera2 will call the onError() callback with the specific error code that
+ // caused this failure. No need to do anything here.
+ }
}
}
diff --git a/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/Camera2DeviceSurfaceManager.java b/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/Camera2DeviceSurfaceManager.java
index 09e310c..97f4aa1 100644
--- a/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/Camera2DeviceSurfaceManager.java
+++ b/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/Camera2DeviceSurfaceManager.java
@@ -17,8 +17,6 @@
package androidx.camera.camera2.internal;
import android.content.Context;
-import android.hardware.camera2.CameraAccessException;
-import android.hardware.camera2.CameraManager;
import android.media.CamcorderProfile;
import android.util.Rational;
import android.util.Size;
@@ -27,6 +25,9 @@
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
+import androidx.camera.camera2.internal.compat.CameraAccessExceptionCompat;
+import androidx.camera.camera2.internal.compat.CameraManagerCompat;
+import androidx.camera.core.CameraUnavailableException;
import androidx.camera.core.impl.CameraDeviceSurfaceManager;
import androidx.camera.core.impl.ImageOutputConfig;
import androidx.camera.core.impl.SurfaceConfig;
@@ -62,12 +63,13 @@
* @hide
*/
@RestrictTo(Scope.LIBRARY)
- public Camera2DeviceSurfaceManager(@NonNull Context context) {
+ public Camera2DeviceSurfaceManager(@NonNull Context context) throws CameraUnavailableException {
this(context, CamcorderProfile::hasProfile);
}
Camera2DeviceSurfaceManager(@NonNull Context context,
- @NonNull CamcorderProfileHelper camcorderProfileHelper) {
+ @NonNull CamcorderProfileHelper camcorderProfileHelper)
+ throws CameraUnavailableException {
Preconditions.checkNotNull(camcorderProfileHelper);
mCamcorderProfileHelper = camcorderProfileHelper;
init(context);
@@ -76,10 +78,9 @@
/**
* Prepare necessary resources for the surface manager.
*/
- private void init(@NonNull Context context) {
+ private void init(@NonNull Context context) throws CameraUnavailableException {
Preconditions.checkNotNull(context);
- CameraManager cameraManager = Preconditions.checkNotNull(
- (CameraManager) context.getSystemService(Context.CAMERA_SERVICE));
+ CameraManagerCompat cameraManager = CameraManagerCompat.from(context);
try {
for (String cameraId : cameraManager.getCameraIdList()) {
@@ -88,8 +89,8 @@
new SupportedSurfaceCombination(
context, cameraId, mCamcorderProfileHelper));
}
- } catch (CameraAccessException e) {
- throw new IllegalArgumentException("Fail to get camera id list", e);
+ } catch (CameraAccessExceptionCompat e) {
+ throw CameraUnavailableExceptionHelper.createFrom(e);
}
}
diff --git a/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/CameraUnavailableExceptionHelper.java b/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/CameraUnavailableExceptionHelper.java
new file mode 100644
index 0000000..0515f8f
--- /dev/null
+++ b/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/CameraUnavailableExceptionHelper.java
@@ -0,0 +1,63 @@
+/*
+ * 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 androidx.camera.camera2.internal;
+
+import androidx.annotation.NonNull;
+import androidx.camera.camera2.internal.compat.CameraAccessExceptionCompat;
+import androidx.camera.core.CameraUnavailableException;
+
+/**
+ * Helper class to create a {@link CameraUnavailableException}.
+ */
+public final class CameraUnavailableExceptionHelper {
+
+ private CameraUnavailableExceptionHelper() {}
+
+ /**
+ * Create {@link CameraUnavailableException} from {@link CameraAccessExceptionCompat}.
+ *
+ * @param e the {@link CameraAccessExceptionCompat}.
+ * @return the {@link CameraUnavailableException}.
+ */
+ @NonNull
+ public static CameraUnavailableException createFrom(@NonNull CameraAccessExceptionCompat e) {
+ int errorCode;
+ switch (e.getReason()) {
+ case CameraAccessExceptionCompat.CAMERA_DISABLED:
+ errorCode = CameraUnavailableException.CAMERA_DISABLED;
+ break;
+ case CameraAccessExceptionCompat.CAMERA_DISCONNECTED:
+ errorCode = CameraUnavailableException.CAMERA_DISCONNECTED;
+ break;
+ case CameraAccessExceptionCompat.CAMERA_ERROR:
+ errorCode = CameraUnavailableException.CAMERA_ERROR;
+ break;
+ case CameraAccessExceptionCompat.CAMERA_IN_USE:
+ errorCode = CameraUnavailableException.CAMERA_IN_USE;
+ break;
+ case CameraAccessExceptionCompat.MAX_CAMERAS_IN_USE:
+ errorCode = CameraUnavailableException.CAMERA_MAX_IN_USE;
+ break;
+ case CameraAccessExceptionCompat.CAMERA_UNAVAILABLE_DO_NOT_DISTURB:
+ errorCode = CameraUnavailableException.CAMERA_UNAVAILABLE_DO_NOT_DISTURB;
+ break;
+ default:
+ errorCode = CameraUnavailableException.CAMERA_UNKNOWN_ERROR;
+ }
+ return new CameraUnavailableException(errorCode, e);
+ }
+}
diff --git a/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/SupportedSurfaceCombination.java b/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/SupportedSurfaceCombination.java
index ffd508b..20b4c4e 100644
--- a/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/SupportedSurfaceCombination.java
+++ b/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/SupportedSurfaceCombination.java
@@ -20,9 +20,7 @@
import android.graphics.ImageFormat;
import android.graphics.Point;
import android.graphics.SurfaceTexture;
-import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraCharacteristics;
-import android.hardware.camera2.CameraManager;
import android.hardware.camera2.params.StreamConfigurationMap;
import android.media.CamcorderProfile;
import android.os.Build;
@@ -32,9 +30,13 @@
import android.view.Surface;
import android.view.WindowManager;
+import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
+import androidx.camera.camera2.internal.compat.CameraAccessExceptionCompat;
+import androidx.camera.camera2.internal.compat.CameraManagerCompat;
import androidx.camera.core.AspectRatio;
+import androidx.camera.core.CameraUnavailableException;
import androidx.camera.core.CameraX;
import androidx.camera.core.impl.ImageFormatConstants;
import androidx.camera.core.impl.ImageOutputConfig;
@@ -78,22 +80,34 @@
private static final Rational ASPECT_RATIO_9_16 = new Rational(9, 16);
private final List<SurfaceCombination> mSurfaceCombinations = new ArrayList<>();
private final Map<Integer, Size> mMaxSizeCache = new HashMap<>();
- private String mCameraId;
- private CameraCharacteristics mCharacteristics;
- private int mHardwareLevel = CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY;
+ private final String mCameraId;
+ private final CamcorderProfileHelper mCamcorderProfileHelper;
+ private final CameraCharacteristics mCharacteristics;
+ private final int mHardwareLevel;
private boolean mIsRawSupported = false;
private boolean mIsBurstCaptureSupported = false;
private SurfaceSizeDefinition mSurfaceSizeDefinition;
- private CamcorderProfileHelper mCamcorderProfileHelper;
- SupportedSurfaceCombination(
- Context context, String cameraId, CamcorderProfileHelper camcorderProfileHelper) {
- mCameraId = cameraId;
- mCamcorderProfileHelper = camcorderProfileHelper;
- init(context);
- }
-
- private SupportedSurfaceCombination() {
+ SupportedSurfaceCombination(@NonNull Context context, @NonNull String cameraId,
+ @NonNull CamcorderProfileHelper camcorderProfileHelper)
+ throws CameraUnavailableException {
+ mCameraId = Preconditions.checkNotNull(cameraId);
+ mCamcorderProfileHelper = Preconditions.checkNotNull(camcorderProfileHelper);
+ CameraManagerCompat cameraManager = CameraManagerCompat.from(context);
+ WindowManager windowManager =
+ (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
+ try {
+ mCharacteristics = cameraManager.getCameraCharacteristics(mCameraId);
+ Integer keyValue = mCharacteristics.get(
+ CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL);
+ mHardwareLevel = keyValue != null ? keyValue
+ : CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY;
+ } catch (CameraAccessExceptionCompat e) {
+ throw CameraUnavailableExceptionHelper.createFrom(e);
+ }
+ generateSupportedCombinationList();
+ generateSurfaceSizeDefinition(windowManager);
+ checkCustomization();
}
String getCameraId() {
@@ -647,10 +661,6 @@
// Try to retrieve supported resolutions if there is no customization.
if (outputSizes == null) {
- if (mCharacteristics == null) {
- throw new IllegalStateException("CameraCharacteristics is null.");
- }
-
StreamConfigurationMap map =
mCharacteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
@@ -696,24 +706,6 @@
return Collections.max(Arrays.asList(outputSizes), new CompareSizesByArea());
}
- private void init(Context context) {
- CameraManager cameraManager =
- (CameraManager) context.getSystemService(Context.CAMERA_SERVICE);
- WindowManager windowManager =
- (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
-
- try {
- generateSupportedCombinationList(cameraManager);
- generateSurfaceSizeDefinition(windowManager);
- } catch (CameraAccessException e) {
- throw new IllegalArgumentException(
- "Generate supported combination list and size definition fail - CameraId:"
- + mCameraId,
- e);
- }
- checkCustomization();
- }
-
List<SurfaceCombination> getLegacySupportedCombinationList() {
List<SurfaceCombination> combinationList = new ArrayList<>();
@@ -1039,17 +1031,7 @@
return combinationList;
}
- private void generateSupportedCombinationList(CameraManager cameraManager)
- throws CameraAccessException {
- mCharacteristics = cameraManager.getCameraCharacteristics(mCameraId);
-
- Integer keyValue = mCharacteristics.get(
- CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL);
-
- if (keyValue != null) {
- mHardwareLevel = keyValue;
- }
-
+ private void generateSupportedCombinationList() {
mSurfaceCombinations.addAll(getLegacySupportedCombinationList());
if (mHardwareLevel == CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED
diff --git a/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/compat/CameraAccessExceptionCompat.java b/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/compat/CameraAccessExceptionCompat.java
new file mode 100644
index 0000000..6ef2237
--- /dev/null
+++ b/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/compat/CameraAccessExceptionCompat.java
@@ -0,0 +1,278 @@
+/*
+ * 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 androidx.camera.camera2.internal.compat;
+
+import android.app.NotificationManager;
+import android.hardware.camera2.CameraAccessException;
+import android.hardware.camera2.CameraDevice;
+
+import androidx.annotation.IntDef;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.annotation.RestrictTo;
+import androidx.annotation.VisibleForTesting;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Helper for accessing features in {@link CameraAccessException} in a backwards compatible fashion.
+ */
+public class CameraAccessExceptionCompat extends Exception {
+
+ // Start of the CameraAccessException error
+ // *********************************************************************************************
+ /**
+ * The camera device is in use already.
+ */
+ public static final int CAMERA_IN_USE = 4; // Equal to CameraAccessException.CAMERA_IN_USE.
+
+ /**
+ * The system-wide limit for number of open cameras or camera resources has been reached, and
+ * more camera devices cannot be opened or torch mode cannot be turned on until previous
+ * instances are closed.
+ */
+ public static final int MAX_CAMERAS_IN_USE = 5;
+ // Equal to CameraAccessException.MAX_CAMERAS_IN_USE.
+
+ /**
+ * The camera is disabled due to a device policy, and cannot be opened.
+ *
+ * @see android.app.admin.DevicePolicyManager#setCameraDisabled(android.content.ComponentName,
+ * boolean)
+ */
+ public static final int CAMERA_DISABLED = 1; // Equal to CameraAccessException.CAMERA_DISABLED.
+
+ /**
+ * The camera device is removable and has been disconnected from the Android device, or the
+ * camera id used with {@link android.hardware.camera2.CameraManager#openCamera} is no longer
+ * valid, or the camera service has shut down the connection due to a higher-priority access
+ * request for the camera device.
+ */
+ public static final int CAMERA_DISCONNECTED = 2;
+ // Equal to CameraAccessException.CAMERA_DISCONNECTED.
+
+ /**
+ * The camera device is currently in the error state.
+ *
+ * <p>The camera has failed to open or has failed at a later time as a result of some
+ * non-user interaction. Refer to {@link CameraDevice.StateCallback#onError} for the exact
+ * nature of the error.</p>
+ *
+ * <p>No further calls to the camera will succeed. Clean up the camera with
+ * {@link CameraDevice#close} and try handling the error in order to successfully re-open the
+ * camera.</p>
+ */
+ public static final int CAMERA_ERROR = 3; // Equal to CameraAccessException.CAMERA_ERROR.
+
+ /**
+ * A deprecated HAL version is in use.
+ *
+ * @hide
+ */
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ public static final int CAMERA_DEPRECATED_HAL = 1000;
+ // Equal to CameraAccessException.CAMERA_DEPRECATED_HAL.
+
+ @VisibleForTesting
+ static final Set<Integer> PLATFORM_ERRORS =
+ Collections.unmodifiableSet(new HashSet<>(Arrays.asList(CAMERA_IN_USE,
+ MAX_CAMERAS_IN_USE, CAMERA_DISABLED, CAMERA_DISCONNECTED, CAMERA_ERROR)));
+
+ // End of the CameraAccessException error
+ // *********************************************************************************************
+
+ // Start of the CameraAccessExceptionCompat error
+ // *********************************************************************************************
+
+ // Compat specific errors should start at 10001
+
+ /**
+ * The camera is unavailable due to {@link NotificationManager.Policy}. Some API 28 devices
+ * cannot access the camera when the device is in "Do Not Disturb" mode. The camera will not
+ * be accessible until "Do Not Disturb" mode is disabled.
+ *
+ * @see NotificationManager#getCurrentInterruptionFilter()
+ * @see NotificationManager#ACTION_INTERRUPTION_FILTER_CHANGED
+ */
+ public static final int CAMERA_UNAVAILABLE_DO_NOT_DISTURB = 10001;
+
+ @VisibleForTesting
+ static final Set<Integer> COMPAT_ERRORS = Collections.unmodifiableSet(
+ new HashSet<>(Arrays.asList(CAMERA_UNAVAILABLE_DO_NOT_DISTURB)));
+
+ // End of the CameraAccessExceptionCompat error
+ // *********************************************************************************************
+
+ private final int mReason;
+
+ private final CameraAccessException mCameraAccessException;
+
+ /** @hide */
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(value = {
+ CAMERA_IN_USE,
+ MAX_CAMERAS_IN_USE,
+ CAMERA_DISABLED,
+ CAMERA_DISCONNECTED,
+ CAMERA_ERROR,
+
+ // Start of the compat error
+ CAMERA_UNAVAILABLE_DO_NOT_DISTURB
+ })
+ public @interface AccessError {
+ }
+
+ public CameraAccessExceptionCompat(@AccessError int reason) {
+ super(getDefaultMessage(reason));
+ mReason = reason;
+ mCameraAccessException = PLATFORM_ERRORS.contains(reason)
+ ? new CameraAccessException(reason) : null;
+ }
+
+ public CameraAccessExceptionCompat(@AccessError int reason, @Nullable String message) {
+ super(getCombinedMessage(reason, message));
+ mReason = reason;
+ mCameraAccessException = PLATFORM_ERRORS.contains(reason)
+ ? new CameraAccessException(reason, message) : null;
+ }
+
+ public CameraAccessExceptionCompat(@AccessError int reason, @Nullable String message,
+ @Nullable Throwable cause) {
+ super(getCombinedMessage(reason, message), cause);
+ mReason = reason;
+ mCameraAccessException = PLATFORM_ERRORS.contains(reason)
+ ? new CameraAccessException(reason, message, cause) : null;
+ }
+
+ public CameraAccessExceptionCompat(@AccessError int reason, @Nullable Throwable cause) {
+ super(getDefaultMessage(reason), cause);
+ mReason = reason;
+ mCameraAccessException = PLATFORM_ERRORS.contains(reason)
+ ? new CameraAccessException(reason, null, cause) : null;
+ }
+
+ private CameraAccessExceptionCompat(@NonNull CameraAccessException e) {
+ super(e.getMessage(), e.getCause());
+ mReason = e.getReason();
+ mCameraAccessException = e;
+ }
+
+ /**
+ * The reason for the failure to access the camera.
+ */
+ @AccessError
+ public final int getReason() {
+ return mReason;
+ }
+
+ /**
+ * Provides the platform class object represented by this object.
+ *
+ * @return platform class object, null if it is a compat specific error.
+ */
+ @Nullable
+ public CameraAccessException toCameraAccessException() {
+ return mCameraAccessException;
+ }
+
+ /**
+ * Provides a backward-compatible wrapper for {@link CameraAccessException}.
+ *
+ * @param cameraAccessException {@link CameraAccessException} class to wrap
+ * @return wrapped class
+ */
+ @NonNull
+ public static CameraAccessExceptionCompat toCameraAccessExceptionCompat(
+ @NonNull CameraAccessException cameraAccessException) {
+ if (cameraAccessException == null) {
+ throw new NullPointerException("cameraAccessException should not be null");
+ }
+ return new CameraAccessExceptionCompat(cameraAccessException);
+ }
+
+ @Nullable
+ private static String getDefaultMessage(@AccessError int problem) {
+ switch (problem) {
+ case CAMERA_IN_USE:
+ return "The camera device is in use already";
+ case MAX_CAMERAS_IN_USE:
+ return "The system-wide limit for number of open cameras has been reached, "
+ + "and more camera devices cannot be opened until previous instances "
+ + "are closed.";
+ case CAMERA_DISCONNECTED:
+ return "The camera device is removable and has been disconnected from the "
+ + "Android device, or the camera service has shut down the connection due "
+ + "to a higher-priority access request for the camera device.";
+ case CAMERA_DISABLED:
+ return "The camera is disabled due to a device policy, and cannot be opened.";
+ case CAMERA_ERROR:
+ return "The camera device is currently in the error state; "
+ + "no further calls to it will succeed.";
+
+ // Start of the compat errors
+ case CAMERA_UNAVAILABLE_DO_NOT_DISTURB:
+ return "Some API 28 devices cannot access the camera when the device is in \"Do "
+ + "Not Disturb\" mode. The camera will not be accessible until \"Do Not "
+ + "Disturb\" mode is disabled.";
+ }
+ return null;
+ }
+
+ private static String getCombinedMessage(@AccessError int problem, String message) {
+ String problemString = getProblemString(problem);
+ return String.format("%s (%d): %s", problemString, problem, message);
+ }
+
+ @NonNull
+ private static String getProblemString(int problem) {
+ String problemString;
+ switch (problem) {
+ case CAMERA_IN_USE:
+ problemString = "CAMERA_IN_USE";
+ break;
+ case MAX_CAMERAS_IN_USE:
+ problemString = "MAX_CAMERAS_IN_USE";
+ break;
+ case CAMERA_DISCONNECTED:
+ problemString = "CAMERA_DISCONNECTED";
+ break;
+ case CAMERA_DISABLED:
+ problemString = "CAMERA_DISABLED";
+ break;
+ case CAMERA_ERROR:
+ problemString = "CAMERA_ERROR";
+ break;
+ case CAMERA_DEPRECATED_HAL:
+ problemString = "CAMERA_DEPRECATED_HAL";
+ break;
+
+ // Start of the compat errors
+ case CAMERA_UNAVAILABLE_DO_NOT_DISTURB:
+ problemString = "CAMERA_UNAVAILABLE_DO_NOT_DISTURB";
+ break;
+ default:
+ problemString = "<UNKNOWN ERROR>";
+ }
+ return problemString;
+ }
+}
diff --git a/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/compat/CameraManagerCompat.java b/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/compat/CameraManagerCompat.java
index e4594e0..765b09f 100644
--- a/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/compat/CameraManagerCompat.java
+++ b/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/compat/CameraManagerCompat.java
@@ -18,6 +18,7 @@
import android.content.Context;
import android.hardware.camera2.CameraAccessException;
+import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraDevice;
import android.hardware.camera2.CameraManager;
import android.os.Build;
@@ -62,9 +63,11 @@
@NonNull
public static CameraManagerCompat from(@NonNull Context context,
@NonNull Handler compatHandler) {
- // Can use Executor directly on API 28+
- if (Build.VERSION.SDK_INT >= 28) {
- return new CameraManagerCompat(new CameraManagerCompatApi28Impl(context));
+ if (Build.VERSION.SDK_INT >= 29) {
+ return new CameraManagerCompat(new CameraManagerCompatApi29Impl(context));
+ } else if (Build.VERSION.SDK_INT >= 28) {
+ // Can use Executor directly on API 28+
+ return new CameraManagerCompat(CameraManagerCompatApi28Impl.create(context));
}
// Pass compat handler to implementation.
@@ -73,6 +76,21 @@
}
/**
+ * Return the list of currently connected camera devices by identifier, including cameras that
+ * may be in use by other camera API clients.
+ *
+ * <p>The behavior of this method matches that of {@link CameraManager#getCameraIdList()},
+ * except that {@link CameraAccessExceptionCompat} is thrown in place of
+ * {@link CameraAccessException} for convenience.
+ *
+ * @return The list of currently connected camera devices.
+ */
+ @NonNull
+ public String[] getCameraIdList() throws CameraAccessExceptionCompat {
+ return mImpl.getCameraIdList();
+ }
+
+ /**
* Register a callback to be notified about camera device availability.
*
* <p>The behavior of this method matches that of {@link
@@ -115,6 +133,29 @@
}
/**
+ * Query the capabilities of a camera device. These capabilities are immutable for a given
+ * camera.
+ *
+ * <p>The behavior of this method matches that of
+ * {@link CameraManager#getCameraCharacteristics(String)}.
+ *
+ * @param cameraId The id of the camera device to query. This could be either a standalone
+ * camera ID which can be directly opened by {@link #openCamera}, or a physical camera ID that
+ * can only used as part of a logical multi-camera.
+ * @return The properties of the given camera
+ *
+ * @throws IllegalArgumentException if the cameraId does not match any known camera device.
+ * @throws CameraAccessExceptionCompat if the camera device has been disconnected or the
+ * device is in Do Not Disturb mode with an early version
+ * of Android P.
+ */
+ @NonNull
+ public CameraCharacteristics getCameraCharacteristics(@NonNull String cameraId)
+ throws CameraAccessExceptionCompat {
+ return mImpl.getCameraCharacteristics(cameraId);
+ }
+
+ /**
* Open a connection to a camera with the given ID.
*
* <p>The behavior of this method matches that of
@@ -124,15 +165,15 @@
* @param cameraId The unique identifier of the camera device to open
* @param executor The executor which will be used when invoking the callback.
* @param callback The callback which is invoked once the camera is opened
- * @throws CameraAccessException if the camera is disabled by device policy,
- * has been disconnected, or is being used by a
- * higher-priority camera API client.
- * @throws IllegalArgumentException if cameraId, the callback or the executor was null,
- * or the cameraId does not match any currently or
- * previously available
- * camera device.
- * @throws SecurityException if the application does not have permission to
- * access the camera
+ * @throws CameraAccessExceptionCompat if the camera is disabled by device policy, has been
+ * disconnected, is being used by a higher-priority
+ * camera API client or the device is in Do Not Disturb
+ * mode with an early version of Android P.
+ * @throws IllegalArgumentException if cameraId, the callback or the executor was null,
+ * or the cameraId does not match any currently or
+ * previously available camera device.
+ * @throws SecurityException if the application does not have permission to access
+ * the camera
* @see CameraManager#getCameraIdList
* @see android.app.admin.DevicePolicyManager#setCameraDisabled
*/
@@ -140,7 +181,7 @@
public void openCamera(@NonNull String cameraId,
@NonNull /*@CallbackExecutor*/ Executor executor,
@NonNull CameraDevice.StateCallback callback)
- throws CameraAccessException {
+ throws CameraAccessExceptionCompat {
mImpl.openCamera(cameraId, executor, callback);
}
@@ -157,17 +198,23 @@
interface CameraManagerCompatImpl {
+ String[] getCameraIdList() throws CameraAccessExceptionCompat;
+
void registerAvailabilityCallback(
@NonNull /* @CallbackExecutor */ Executor executor,
@NonNull CameraManager.AvailabilityCallback callback);
void unregisterAvailabilityCallback(@NonNull CameraManager.AvailabilityCallback callback);
+ @NonNull
+ CameraCharacteristics getCameraCharacteristics(@NonNull String cameraId)
+ throws CameraAccessExceptionCompat;
+
@RequiresPermission(android.Manifest.permission.CAMERA)
void openCamera(@NonNull String cameraId,
@NonNull /* @CallbackExecutor */ Executor executor,
@NonNull CameraDevice.StateCallback callback)
- throws CameraAccessException;
+ throws CameraAccessExceptionCompat;
@NonNull
CameraManager getCameraManager();
diff --git a/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/compat/CameraManagerCompatApi28Impl.java b/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/compat/CameraManagerCompatApi28Impl.java
index 62482fb..b666919 100644
--- a/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/compat/CameraManagerCompatApi28Impl.java
+++ b/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/compat/CameraManagerCompatApi28Impl.java
@@ -18,21 +18,30 @@
import android.content.Context;
import android.hardware.camera2.CameraAccessException;
+import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraDevice;
import android.hardware.camera2.CameraManager;
+import android.os.Build;
+import androidx.annotation.GuardedBy;
import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.RequiresPermission;
+import java.util.HashMap;
+import java.util.Map;
import java.util.concurrent.Executor;
@RequiresApi(28)
class CameraManagerCompatApi28Impl extends CameraManagerCompatBaseImpl {
- CameraManagerCompatApi28Impl(@NonNull Context context) {
- // No extra params needed for this API level
- super(context, /*cameraManagerParams=*/ null);
+ CameraManagerCompatApi28Impl(@NonNull Context context, @Nullable Object cameraManagerParams) {
+ super(context, cameraManagerParams);
+ }
+
+ static CameraManagerCompatApi28Impl create(@NonNull Context context) {
+ return new CameraManagerCompatApi28Impl(context, new CameraManagerCompatParamsApi28());
}
@Override
@@ -54,10 +63,125 @@
@RequiresPermission(android.Manifest.permission.CAMERA)
@Override
public void openCamera(@NonNull String cameraId, @NonNull Executor executor,
- @NonNull CameraDevice.StateCallback callback) throws CameraAccessException {
+ @NonNull CameraDevice.StateCallback callback) throws CameraAccessExceptionCompat {
- // Pass through directly to the executor API that exists on this API level.
- mCameraManager.openCamera(cameraId, executor, callback);
+ try {
+ // Pass through directly to the executor API that exists on this API level.
+ mCameraManager.openCamera(cameraId, executor, callback);
+ } catch (CameraAccessException e) {
+ throw CameraAccessExceptionCompat.toCameraAccessExceptionCompat(e);
+ } catch (IllegalArgumentException | SecurityException e) {
+ // Re-throw those RuntimeException will be thrown by CameraManager#openCamera.
+ throw e;
+ } catch (RuntimeException e) {
+ if (isDndFailCase(e)) {
+ throwDndException(e);
+ }
+ throw e;
+ }
+ }
+
+ @NonNull
+ @Override
+ public CameraCharacteristics getCameraCharacteristics(@NonNull String cameraId)
+ throws CameraAccessExceptionCompat {
+ CameraCharacteristics cameraCharacteristics;
+ try {
+ cameraCharacteristics = super.getCameraCharacteristics(cameraId);
+
+ if (Build.VERSION.SDK_INT == 28) {
+ // Update the cache if it doesn't exist.
+ synchronized (CameraManagerCompatParamsApi28.sCameraCharacteristicsMap) {
+ if (!CameraManagerCompatParamsApi28.sCameraCharacteristicsMap.containsKey(
+ cameraId)) {
+ CameraManagerCompatParamsApi28.sCameraCharacteristicsMap.put(cameraId,
+ cameraCharacteristics);
+ }
+ }
+ }
+ } catch (RuntimeException e) {
+ if (isDndFailCase(e)) {
+ // Get from cache if it exists.
+ synchronized (CameraManagerCompatParamsApi28.sCameraCharacteristicsMap) {
+ if (CameraManagerCompatParamsApi28.sCameraCharacteristicsMap.containsKey(
+ cameraId)) {
+ return CameraManagerCompatParamsApi28.sCameraCharacteristicsMap.get(
+ cameraId);
+ }
+ }
+ throwDndException(e);
+ }
+ throw e;
+ }
+ return cameraCharacteristics;
+ }
+
+ private void throwDndException(@NonNull Throwable cause) throws CameraAccessExceptionCompat {
+ throw new CameraAccessExceptionCompat(
+ CameraAccessExceptionCompat.CAMERA_UNAVAILABLE_DO_NOT_DISTURB, cause);
+ }
+
+ /*
+ * Check if the exception is due to Do Not Disturb being on, which is only on specific builds
+ * of P. See b/149413835 and b/132362603.
+ */
+ private boolean isDndFailCase(@NonNull Throwable throwable) {
+ return Build.VERSION.SDK_INT == 28 && isDndRuntimeException(throwable);
+ }
+
+ /*
+ * The full stack
+ *
+ * java.lang.RuntimeException: Camera is being used after Camera.release() was called
+ * at android.hardware.Camera._enableShutterSound(Native Method)
+ * at android.hardware.Camera.updateAppOpsPlayAudio(Camera.java:1770)
+ * at android.hardware.Camera.initAppOps(Camera.java:582)
+ * at android.hardware.Camera.<init>(Camera.java:575)
+ * at android.hardware.Camera.getEmptyParameters(Camera.java:2130)
+ * at android.hardware.camera2.legacy.LegacyMetadataMapper.createCharacteristics
+ * (LegacyMetadataMapper.java:151)
+ * at android.hardware.camera2.CameraManager.getCameraCharacteristics(CameraManager.java:274)
+ *
+ * This method check the first stack is "_enableShutterSound"
+ */
+ private static boolean isDndRuntimeException(@NonNull Throwable throwable) {
+ if (throwable.getClass().equals(RuntimeException.class)) {
+ StackTraceElement[] stackTraceElement;
+ if ((stackTraceElement = throwable.getStackTrace()) == null
+ || stackTraceElement.length < 0) {
+ return false;
+ }
+ return "_enableShutterSound".equals(stackTraceElement[0].getMethodName());
+ }
+ return false;
+ }
+
+ static final class CameraManagerCompatParamsApi28 {
+ /*
+ * This is a workaround by caching CameraCharacteristics. There is an issue with the early
+ * version of API 28. If the device "Do Not Disturb (DND)" mode is enabled, a
+ * RuntimeException is thrown when calling
+ * CameraManager#getCameraCharacteristics() and CameraManager#openCamera(). Caching the
+ * CameraCharacteristics can prevent library users from encountering the exception as
+ * possible, even if it will rethrow CameraAccessExceptionCompat.
+ *
+ * When DND error occurs, we expect the developer can notify the user to turn off DND.
+ * Since developer usually do not expect API CameraManager#getCameraCharacteristics() to
+ * throw exception, and this API may be widely and discretely called by users, it may not be
+ * easy to display notification with a single design. If the exception can be thrown in a
+ * single location such as CameraManager#openCamera(), it is much easier to notify the
+ * user of the DND situation. Usually the situation that the camera fails to open is well
+ * handled.
+ *
+ * The cache will only be used in the case of DND failure, so it won't affect
+ * general use. Make the cache "static" because it is shared between CameraManagerCompat
+ * instances.
+ */
+ @GuardedBy("sCameraCharacteristicsMap")
+ static final Map<String, CameraCharacteristics> sCameraCharacteristicsMap = new HashMap<>();
+
+ CameraManagerCompatParamsApi28() {
+ }
}
}
diff --git a/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/compat/CameraManagerCompatApi29Impl.java b/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/compat/CameraManagerCompatApi29Impl.java
new file mode 100644
index 0000000..b0d916e
--- /dev/null
+++ b/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/compat/CameraManagerCompatApi29Impl.java
@@ -0,0 +1,64 @@
+/*
+ * 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.camera.camera2.internal.compat;
+
+import android.content.Context;
+import android.hardware.camera2.CameraAccessException;
+import android.hardware.camera2.CameraCharacteristics;
+import android.hardware.camera2.CameraDevice;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.RequiresApi;
+import androidx.annotation.RequiresPermission;
+
+import java.util.concurrent.Executor;
+
+@RequiresApi(29)
+class CameraManagerCompatApi29Impl extends CameraManagerCompatApi28Impl {
+
+ CameraManagerCompatApi29Impl(@NonNull Context context) {
+ // No extra params needed for this API level
+ super(context, /*cameraManagerParams=*/ null);
+ }
+
+ @RequiresPermission(android.Manifest.permission.CAMERA)
+ @Override
+ public void openCamera(@NonNull String cameraId, @NonNull Executor executor,
+ @NonNull CameraDevice.StateCallback callback) throws CameraAccessExceptionCompat {
+
+ try {
+ // Pass through directly to override the DND workaround on API 28
+ mCameraManager.openCamera(cameraId, executor, callback);
+ } catch (CameraAccessException e) {
+ throw CameraAccessExceptionCompat.toCameraAccessExceptionCompat(e);
+ }
+ }
+
+ @NonNull
+ @Override
+ public CameraCharacteristics getCameraCharacteristics(@NonNull String cameraId)
+ throws CameraAccessExceptionCompat {
+
+ try {
+ // Pass through directly to override the DND workaround on API 28
+ return mCameraManager.getCameraCharacteristics(cameraId);
+ } catch (CameraAccessException e) {
+ throw CameraAccessExceptionCompat.toCameraAccessExceptionCompat(e);
+ }
+ }
+}
+
diff --git a/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/compat/CameraManagerCompatBaseImpl.java b/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/compat/CameraManagerCompatBaseImpl.java
index 19eab64..eee8d32 100644
--- a/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/compat/CameraManagerCompatBaseImpl.java
+++ b/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/compat/CameraManagerCompatBaseImpl.java
@@ -18,6 +18,7 @@
import android.content.Context;
import android.hardware.camera2.CameraAccessException;
+import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraDevice;
import android.hardware.camera2.CameraManager;
import android.os.Handler;
@@ -51,6 +52,15 @@
}
@Override
+ public String[] getCameraIdList() throws CameraAccessExceptionCompat {
+ try {
+ return mCameraManager.getCameraIdList();
+ } catch (CameraAccessException e) {
+ throw CameraAccessExceptionCompat.toCameraAccessExceptionCompat(e);
+ }
+ }
+
+ @Override
public void registerAvailabilityCallback(@NonNull Executor executor,
@NonNull CameraManager.AvailabilityCallback callback) {
if (executor == null) {
@@ -90,10 +100,21 @@
mCameraManager.unregisterAvailabilityCallback(wrapper);
}
+ @Override
+ @NonNull
+ public CameraCharacteristics getCameraCharacteristics(@NonNull String cameraId)
+ throws CameraAccessExceptionCompat {
+ try {
+ return mCameraManager.getCameraCharacteristics(cameraId);
+ } catch (CameraAccessException e) {
+ throw CameraAccessExceptionCompat.toCameraAccessExceptionCompat(e);
+ }
+ }
+
@RequiresPermission(android.Manifest.permission.CAMERA)
@Override
public void openCamera(@NonNull String cameraId, @NonNull Executor executor,
- @NonNull CameraDevice.StateCallback callback) throws CameraAccessException {
+ @NonNull CameraDevice.StateCallback callback) throws CameraAccessExceptionCompat {
Preconditions.checkNotNull(executor);
Preconditions.checkNotNull(callback);
@@ -102,7 +123,11 @@
new CameraDeviceCompat.StateCallbackExecutorWrapper(executor, callback);
CameraManagerCompatParamsApi21 params = (CameraManagerCompatParamsApi21) mObject;
- mCameraManager.openCamera(cameraId, cb, params.mCompatHandler);
+ try {
+ mCameraManager.openCamera(cameraId, cb, params.mCompatHandler);
+ } catch (CameraAccessException e) {
+ throw CameraAccessExceptionCompat.toCameraAccessExceptionCompat(e);
+ }
}
@NonNull
diff --git a/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/Camera2DeviceSurfaceManagerTest.java b/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/Camera2DeviceSurfaceManagerTest.java
index ed2c487..546110e 100644
--- a/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/Camera2DeviceSurfaceManagerTest.java
+++ b/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/Camera2DeviceSurfaceManagerTest.java
@@ -38,9 +38,11 @@
import androidx.camera.core.AspectRatio;
import androidx.camera.core.CameraSelector;
+import androidx.camera.core.CameraUnavailableException;
import androidx.camera.core.CameraX;
import androidx.camera.core.CameraXConfig;
import androidx.camera.core.ImageCapture;
+import androidx.camera.core.InitializationException;
import androidx.camera.core.Preview;
import androidx.camera.core.UseCase;
import androidx.camera.core.VideoCapture;
@@ -153,7 +155,8 @@
}
@Test
- public void checkLegacySurfaceCombinationSupportedInLegacyDevice() {
+ public void checkLegacySurfaceCombinationSupportedInLegacyDevice()
+ throws CameraUnavailableException {
SupportedSurfaceCombination supportedSurfaceCombination =
new SupportedSurfaceCombination(
mContext, LEGACY_CAMERA_ID, mMockCamcorderProfileHelper);
@@ -170,7 +173,8 @@
}
@Test
- public void checkLimitedSurfaceCombinationNotSupportedInLegacyDevice() {
+ public void checkLimitedSurfaceCombinationNotSupportedInLegacyDevice()
+ throws CameraUnavailableException {
SupportedSurfaceCombination supportedSurfaceCombination =
new SupportedSurfaceCombination(
mContext, LEGACY_CAMERA_ID, mMockCamcorderProfileHelper);
@@ -187,7 +191,8 @@
}
@Test
- public void checkFullSurfaceCombinationNotSupportedInLegacyDevice() {
+ public void checkFullSurfaceCombinationNotSupportedInLegacyDevice()
+ throws CameraUnavailableException {
SupportedSurfaceCombination supportedSurfaceCombination =
new SupportedSurfaceCombination(
mContext, LEGACY_CAMERA_ID, mMockCamcorderProfileHelper);
@@ -204,7 +209,8 @@
}
@Test
- public void checkLevel3SurfaceCombinationNotSupportedInLegacyDevice() {
+ public void checkLevel3SurfaceCombinationNotSupportedInLegacyDevice()
+ throws CameraUnavailableException {
SupportedSurfaceCombination supportedSurfaceCombination =
new SupportedSurfaceCombination(
mContext, LEGACY_CAMERA_ID, mMockCamcorderProfileHelper);
@@ -221,7 +227,8 @@
}
@Test
- public void checkLimitedSurfaceCombinationSupportedInLimitedDevice() {
+ public void checkLimitedSurfaceCombinationSupportedInLimitedDevice()
+ throws CameraUnavailableException {
SupportedSurfaceCombination supportedSurfaceCombination =
new SupportedSurfaceCombination(
mContext, LIMITED_CAMERA_ID, mMockCamcorderProfileHelper);
@@ -238,7 +245,8 @@
}
@Test
- public void checkFullSurfaceCombinationNotSupportedInLimitedDevice() {
+ public void checkFullSurfaceCombinationNotSupportedInLimitedDevice()
+ throws CameraUnavailableException {
SupportedSurfaceCombination supportedSurfaceCombination =
new SupportedSurfaceCombination(
mContext, LIMITED_CAMERA_ID, mMockCamcorderProfileHelper);
@@ -255,7 +263,8 @@
}
@Test
- public void checkLevel3SurfaceCombinationNotSupportedInLimitedDevice() {
+ public void checkLevel3SurfaceCombinationNotSupportedInLimitedDevice()
+ throws CameraUnavailableException {
SupportedSurfaceCombination supportedSurfaceCombination =
new SupportedSurfaceCombination(
mContext, LIMITED_CAMERA_ID, mMockCamcorderProfileHelper);
@@ -272,7 +281,8 @@
}
@Test
- public void checkFullSurfaceCombinationSupportedInFullDevice() {
+ public void checkFullSurfaceCombinationSupportedInFullDevice()
+ throws CameraUnavailableException {
SupportedSurfaceCombination supportedSurfaceCombination =
new SupportedSurfaceCombination(
mContext, FULL_CAMERA_ID, mMockCamcorderProfileHelper);
@@ -289,7 +299,8 @@
}
@Test
- public void checkLevel3SurfaceCombinationNotSupportedInFullDevice() {
+ public void checkLevel3SurfaceCombinationNotSupportedInFullDevice()
+ throws CameraUnavailableException {
SupportedSurfaceCombination supportedSurfaceCombination =
new SupportedSurfaceCombination(
mContext, FULL_CAMERA_ID, mMockCamcorderProfileHelper);
@@ -306,7 +317,8 @@
}
@Test
- public void checkLevel3SurfaceCombinationSupportedInLevel3Device() {
+ public void checkLevel3SurfaceCombinationSupportedInLevel3Device()
+ throws CameraUnavailableException {
SupportedSurfaceCombination supportedSurfaceCombination =
new SupportedSurfaceCombination(
mContext, LEVEL3_CAMERA_ID, mMockCamcorderProfileHelper);
@@ -489,7 +501,7 @@
}
@Test
- public void checkPreviewAspectRatioInLegacyDevice() {
+ public void checkPreviewAspectRatioInLegacyDevice() throws CameraUnavailableException {
SupportedSurfaceCombination supportedSurfaceCombination =
new SupportedSurfaceCombination(
mContext, LEGACY_CAMERA_ID, mMockCamcorderProfileHelper);
@@ -584,8 +596,13 @@
private CameraXConfig createFakeAppConfig() {
// Create the DeviceSurfaceManager for Camera2
- CameraDeviceSurfaceManager.Provider surfaceManagerProvider = context ->
- new Camera2DeviceSurfaceManager(mContext, mMockCamcorderProfileHelper);
+ CameraDeviceSurfaceManager.Provider surfaceManagerProvider = context -> {
+ try {
+ return new Camera2DeviceSurfaceManager(mContext, mMockCamcorderProfileHelper);
+ } catch (CameraUnavailableException e) {
+ throw new InitializationException(e);
+ }
+ };
// Create default configuration factory
UseCaseConfigFactory.Provider factoryProvider = context -> {
diff --git a/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/SupportedSurfaceCombinationTest.java b/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/SupportedSurfaceCombinationTest.java
index 5c8f196..06b0b19 100644
--- a/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/SupportedSurfaceCombinationTest.java
+++ b/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/SupportedSurfaceCombinationTest.java
@@ -40,6 +40,7 @@
import androidx.camera.camera2.Camera2Config;
import androidx.camera.core.AspectRatio;
import androidx.camera.core.CameraSelector;
+import androidx.camera.core.CameraUnavailableException;
import androidx.camera.core.CameraX;
import androidx.camera.core.CameraXConfig;
import androidx.camera.core.ImageAnalysis;
@@ -172,7 +173,8 @@
}
@Test
- public void checkLegacySurfaceCombinationSupportedInLegacyDevice() {
+ public void checkLegacySurfaceCombinationSupportedInLegacyDevice()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -188,7 +190,8 @@
}
@Test
- public void checkLegacySurfaceCombinationSubListSupportedInLegacyDevice() {
+ public void checkLegacySurfaceCombinationSubListSupportedInLegacyDevice()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -202,7 +205,8 @@
}
@Test
- public void checkLimitedSurfaceCombinationNotSupportedInLegacyDevice() {
+ public void checkLimitedSurfaceCombinationNotSupportedInLegacyDevice()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -218,7 +222,8 @@
}
@Test
- public void checkFullSurfaceCombinationNotSupportedInLegacyDevice() {
+ public void checkFullSurfaceCombinationNotSupportedInLegacyDevice()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -234,7 +239,8 @@
}
@Test
- public void checkLevel3SurfaceCombinationNotSupportedInLegacyDevice() {
+ public void checkLevel3SurfaceCombinationNotSupportedInLegacyDevice()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -250,7 +256,8 @@
}
@Test
- public void checkLimitedSurfaceCombinationSupportedInLimitedDevice() {
+ public void checkLimitedSurfaceCombinationSupportedInLimitedDevice()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -266,7 +273,8 @@
}
@Test
- public void checkLimitedSurfaceCombinationSubListSupportedInLimited3Device() {
+ public void checkLimitedSurfaceCombinationSubListSupportedInLimited3Device()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -280,7 +288,8 @@
}
@Test
- public void checkFullSurfaceCombinationNotSupportedInLimitedDevice() {
+ public void checkFullSurfaceCombinationNotSupportedInLimitedDevice()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -296,7 +305,8 @@
}
@Test
- public void checkLevel3SurfaceCombinationNotSupportedInLimitedDevice() {
+ public void checkLevel3SurfaceCombinationNotSupportedInLimitedDevice()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -312,7 +322,8 @@
}
@Test
- public void checkFullSurfaceCombinationSupportedInFullDevice() {
+ public void checkFullSurfaceCombinationSupportedInFullDevice()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -328,7 +339,8 @@
}
@Test
- public void checkFullSurfaceCombinationSubListSupportedInFullDevice() {
+ public void checkFullSurfaceCombinationSubListSupportedInFullDevice()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -342,7 +354,8 @@
}
@Test
- public void checkLevel3SurfaceCombinationNotSupportedInFullDevice() {
+ public void checkLevel3SurfaceCombinationNotSupportedInFullDevice()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -358,7 +371,8 @@
}
@Test
- public void checkLimitedSurfaceCombinationSupportedInRawDevice() {
+ public void checkLimitedSurfaceCombinationSupportedInRawDevice()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL,
new int[]{CameraMetadata.REQUEST_AVAILABLE_CAPABILITIES_RAW});
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
@@ -375,7 +389,8 @@
}
@Test
- public void checkLegacySurfaceCombinationSupportedInRawDevice() {
+ public void checkLegacySurfaceCombinationSupportedInRawDevice()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL,
new int[]{CameraMetadata.REQUEST_AVAILABLE_CAPABILITIES_RAW});
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
@@ -392,7 +407,8 @@
}
@Test
- public void checkFullSurfaceCombinationSupportedInRawDevice() {
+ public void checkFullSurfaceCombinationSupportedInRawDevice()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL,
new int[]{CameraMetadata.REQUEST_AVAILABLE_CAPABILITIES_RAW});
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
@@ -409,7 +425,8 @@
}
@Test
- public void checkRawSurfaceCombinationSupportedInRawDevice() {
+ public void checkRawSurfaceCombinationSupportedInRawDevice()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL,
new int[]{CameraMetadata.REQUEST_AVAILABLE_CAPABILITIES_RAW});
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
@@ -426,7 +443,8 @@
}
@Test
- public void checkLevel3SurfaceCombinationSupportedInLevel3Device() {
+ public void checkLevel3SurfaceCombinationSupportedInLevel3Device()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_3);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -442,7 +460,8 @@
}
@Test
- public void checkLevel3SurfaceCombinationSubListSupportedInLevel3Device() {
+ public void checkLevel3SurfaceCombinationSubListSupportedInLevel3Device()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_3);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -456,7 +475,8 @@
}
@Test
- public void checkTargetAspectRatioForPreviewInLegacyDevice() {
+ public void checkTargetAspectRatioForPreviewInLegacyDevice()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -506,7 +526,8 @@
}
@Test
- public void checkDefaultAspectRatioAndResolutionForMixedUseCase() {
+ public void checkDefaultAspectRatioAndResolutionForMixedUseCase()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -550,7 +571,8 @@
}
@Test
- public void checkSmallSizesAreFilteredOutByDefaultSize480p() {
+ public void checkSmallSizesAreFilteredOutByDefaultSize480p()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -590,7 +612,7 @@
}
@Test
- public void checkAspectRatioMatchedSizeCanBeSelected() {
+ public void checkAspectRatioMatchedSizeCanBeSelected() throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -613,7 +635,8 @@
}
@Test
- public void checkCorrectAspectRatioNotMatchedSizeCanBeSelected() {
+ public void checkCorrectAspectRatioNotMatchedSizeCanBeSelected()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -636,7 +659,8 @@
@Test
- public void suggestedResolutionsForMixedUseCaseNotSupportedInLegacyDevice() {
+ public void suggestedResolutionsForMixedUseCaseNotSupportedInLegacyDevice()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -663,7 +687,8 @@
}
@Test
- public void getSuggestedResolutionsForMixedUseCaseInLimitedDevice() {
+ public void getSuggestedResolutionsForMixedUseCaseInLimitedDevice()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -695,7 +720,8 @@
}
@Test
- public void getSuggestedResolutionsWithSameSupportedListForDifferentUseCases() {
+ public void getSuggestedResolutionsWithSameSupportedListForDifferentUseCases()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -732,7 +758,7 @@
}
@Test
- public void setTargetAspectRatioForMixedUseCases() {
+ public void setTargetAspectRatioForMixedUseCases() throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -803,7 +829,8 @@
}
@Test
- public void getSuggestedResolutionsForCustomizedSupportedResolutions() {
+ public void getSuggestedResolutionsForCustomizedSupportedResolutions()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -842,7 +869,7 @@
}
@Test
- public void transformSurfaceConfigWithYUVAnalysisSize() {
+ public void transformSurfaceConfigWithYUVAnalysisSize() throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -855,7 +882,7 @@
}
@Test
- public void transformSurfaceConfigWithYUVPreviewSize() {
+ public void transformSurfaceConfigWithYUVPreviewSize() throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -868,7 +895,7 @@
}
@Test
- public void transformSurfaceConfigWithYUVRecordSize() {
+ public void transformSurfaceConfigWithYUVRecordSize() throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -881,7 +908,7 @@
}
@Test
- public void transformSurfaceConfigWithYUVMaximumSize() {
+ public void transformSurfaceConfigWithYUVMaximumSize() throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -894,7 +921,7 @@
}
@Test
- public void transformSurfaceConfigWithYUVNotSupportSize() {
+ public void transformSurfaceConfigWithYUVNotSupportSize() throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -908,7 +935,7 @@
}
@Test
- public void transformSurfaceConfigWithJPEGAnalysisSize() {
+ public void transformSurfaceConfigWithJPEGAnalysisSize() throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -921,7 +948,7 @@
}
@Test
- public void transformSurfaceConfigWithJPEGPreviewSize() {
+ public void transformSurfaceConfigWithJPEGPreviewSize() throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -934,7 +961,7 @@
}
@Test
- public void transformSurfaceConfigWithJPEGRecordSize() {
+ public void transformSurfaceConfigWithJPEGRecordSize() throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -947,7 +974,7 @@
}
@Test
- public void transformSurfaceConfigWithJPEGMaximumSize() {
+ public void transformSurfaceConfigWithJPEGMaximumSize() throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -960,7 +987,7 @@
}
@Test
- public void transformSurfaceConfigWithJPEGNotSupportSize() {
+ public void transformSurfaceConfigWithJPEGNotSupportSize() throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -974,7 +1001,7 @@
}
@Test
- public void getMaximumSizeForImageFormat() {
+ public void getMaximumSizeForImageFormat() throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -987,7 +1014,8 @@
}
@Test
- public void isAspectRatioMatchWithSupportedMod16Resolution() {
+ public void isAspectRatioMatchWithSupportedMod16Resolution()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -1035,7 +1063,7 @@
}
@Test
- public void getSupportedOutputSizes_noConfigSettings() {
+ public void getSupportedOutputSizes_noConfigSettings() throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -1062,7 +1090,7 @@
}
@Test
- public void getSupportedOutputSizes_aspectRatio4x3() {
+ public void getSupportedOutputSizes_aspectRatio4x3() throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -1094,7 +1122,7 @@
}
@Test
- public void getSupportedOutputSizes_aspectRatio16x9() {
+ public void getSupportedOutputSizes_aspectRatio16x9() throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -1127,7 +1155,8 @@
}
@Test
- public void getSupportedOutputSizes_targetResolution1080x1920InRotation0() {
+ public void getSupportedOutputSizes_targetResolution1080x1920InRotation0()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -1160,7 +1189,8 @@
}
@Test
- public void getSupportedOutputSizes_targetResolutionLargerThan640x480() {
+ public void getSupportedOutputSizes_targetResolutionLargerThan640x480()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -1192,7 +1222,8 @@
}
@Test
- public void getSupportedOutputSizes_targetResolutionSmallerThan640x480() {
+ public void getSupportedOutputSizes_targetResolutionSmallerThan640x480()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -1219,7 +1250,8 @@
}
@Test
- public void getSupportedOutputSizes_targetResolution1800x1440NearTo4x3() {
+ public void getSupportedOutputSizes_targetResolution1800x1440NearTo4x3()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -1251,7 +1283,8 @@
}
@Test
- public void getSupportedOutputSizes_aspectRatioCustom4x3_targetResolution1800x1440NearTo4x3() {
+ public void getSupportedOutputSizes_aspectRatioCustom4x3_targetResolution1800x1440NearTo4x3()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -1284,7 +1317,8 @@
}
@Test
- public void getSupportedOutputSizes_aspectRatioCustom16x9_targetResolution1800x1440NearTo4x3() {
+ public void getSupportedOutputSizes_aspectRatioCustom16x9_targetResolution1800x1440NearTo4x3()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -1318,7 +1352,8 @@
}
@Test
- public void getSupportedOutputSizes_targetResolution1280x600NearTo16x9() {
+ public void getSupportedOutputSizes_targetResolution1280x600NearTo16x9()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -1347,7 +1382,8 @@
}
@Test
- public void getSupportedOutputSizes_aspectRatioCustom16x9_targetResolution1280x600NearTo16x9() {
+ public void getSupportedOutputSizes_aspectRatioCustom16x9_targetResolution1280x600NearTo16x9()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -1378,7 +1414,8 @@
}
@Test
- public void getSupportedOutputSizes_aspectRatioCustom4x3_targetResolution1280x600NearTo16x9() {
+ public void getSupportedOutputSizes_aspectRatioCustom4x3_targetResolution1280x600NearTo16x9()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -1409,7 +1446,7 @@
}
@Test
- public void getSupportedOutputSizes_maxResolution1280x720() {
+ public void getSupportedOutputSizes_maxResolution1280x720() throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -1432,7 +1469,8 @@
}
@Test
- public void getSupportedOutputSizes_defaultResolution1280x720_noTargetResolution() {
+ public void getSupportedOutputSizes_defaultResolution1280x720_noTargetResolution()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -1456,7 +1494,8 @@
}
@Test
- public void getSupportedOutputSizes_defaultResolution1280x720_targetResolution1920x1080() {
+ public void getSupportedOutputSizes_defaultResolution1280x720_targetResolution1920x1080()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -1489,7 +1528,8 @@
}
@Test
- public void getSupportedOutputSizes_fallbackToGuaranteedResolution_whenNotFulfillConditions() {
+ public void getSupportedOutputSizes_fallbackToGuaranteedResolution_whenNotFulfillConditions()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY, new Size[]{
new Size(640, 480),
new Size(320, 240),
@@ -1514,7 +1554,8 @@
}
@Test
- public void getSupportedOutputSizes_whenMaxSizeSmallerThanDefaultMiniSize() {
+ public void getSupportedOutputSizes_whenMaxSizeSmallerThanDefaultMiniSize()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY, new Size[]{
new Size(640, 480),
new Size(320, 240),
@@ -1542,7 +1583,8 @@
}
@Test
- public void getSupportedOutputSizes_whenMaxSizeSmallerThanSmallTargetResolution() {
+ public void getSupportedOutputSizes_whenMaxSizeSmallerThanSmallTargetResolution()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY, new Size[]{
new Size(640, 480),
new Size(320, 240),
@@ -1571,7 +1613,8 @@
}
@Test
- public void getSupportedOutputSizes_whenBothMaxAndTargetResolutionsSmallerThan640x480() {
+ public void getSupportedOutputSizes_whenBothMaxAndTargetResolutionsSmallerThan640x480()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY, new Size[]{
new Size(640, 480),
new Size(320, 240),
@@ -1601,7 +1644,8 @@
}
@Test
- public void getSupportedOutputSizes_whenMaxSizeSmallerThanBigTargetResolution() {
+ public void getSupportedOutputSizes_whenMaxSizeSmallerThanBigTargetResolution()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY);
SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
mContext, CAMERA_ID, mMockCamcorderProfileHelper);
@@ -1633,7 +1677,8 @@
}
@Test
- public void getSupportedOutputSizes_whenNoSizeBetweenMaxSizeAndTargetResolution() {
+ public void getSupportedOutputSizes_whenNoSizeBetweenMaxSizeAndTargetResolution()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY, new Size[]{
new Size(640, 480),
new Size(320, 240),
@@ -1662,7 +1707,8 @@
}
@Test
- public void getSupportedOutputSizes_whenTargetResolutionSmallerThanAnySize() {
+ public void getSupportedOutputSizes_whenTargetResolutionSmallerThanAnySize()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY, new Size[]{
new Size(640, 480),
new Size(320, 240),
@@ -1689,7 +1735,8 @@
}
@Test(expected = IllegalArgumentException.class)
- public void getSupportedOutputSizes_whenMaxResolutionSmallerThanAnySize() {
+ public void getSupportedOutputSizes_whenMaxResolutionSmallerThanAnySize()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY, new Size[]{
new Size(640, 480),
new Size(320, 240),
@@ -1708,7 +1755,8 @@
}
@Test
- public void getSupportedOutputSizes_whenMod16IsIgnoredForSmallSizes() {
+ public void getSupportedOutputSizes_whenMod16IsIgnoredForSmallSizes()
+ throws CameraUnavailableException {
setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY, new Size[]{
new Size(640, 480),
new Size(320, 240),
diff --git a/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/compat/CameraAccessExceptionCompatTest.java b/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/compat/CameraAccessExceptionCompatTest.java
new file mode 100644
index 0000000..d4b6dbd
--- /dev/null
+++ b/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/compat/CameraAccessExceptionCompatTest.java
@@ -0,0 +1,81 @@
+/*
+ * 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.camera.camera2.internal.compat;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.hardware.camera2.CameraAccessException;
+import android.os.Build;
+
+import androidx.test.filters.SmallTest;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+import org.robolectric.annotation.internal.DoNotInstrument;
+
+@SmallTest
+@RunWith(RobolectricTestRunner.class)
+@DoNotInstrument
+@Config(minSdk = Build.VERSION_CODES.LOLLIPOP)
+public final class CameraAccessExceptionCompatTest {
+
+ @Test
+ public void createCameraAccessExceptionCompat_byCompatError() {
+ for (int error : CameraAccessExceptionCompat.COMPAT_ERRORS) {
+ CameraAccessExceptionCompat cameraAccessExceptionCompat =
+ new CameraAccessExceptionCompat(error);
+
+ assertThat(cameraAccessExceptionCompat.getReason()).isEqualTo(error);
+ assertThat(cameraAccessExceptionCompat.toCameraAccessException()).isNull();
+ }
+ }
+
+ @Test
+ public void createCameraAccessExceptionCompat_byCamera2AccessError() {
+ Throwable cause = new RuntimeException();
+ for (int error : CameraAccessExceptionCompat.PLATFORM_ERRORS) {
+ CameraAccessExceptionCompat cameraAccessExceptionCompat =
+ new CameraAccessExceptionCompat(error, cause);
+
+ assertThat(cameraAccessExceptionCompat.getReason()).isEqualTo(error);
+
+ CameraAccessException cameraAccessException =
+ cameraAccessExceptionCompat.toCameraAccessException();
+
+ assertThat(cameraAccessException).isNotNull();
+ assertThat(cameraAccessException.getReason()).isEqualTo(error);
+ assertThat(cameraAccessException.getCause()).isEqualTo(cause);
+ }
+ }
+
+ @Test
+ public void createCameraAccessExceptionCompat_byCameraAccessException() {
+ for (int error : CameraAccessExceptionCompat.PLATFORM_ERRORS) {
+ CameraAccessException cameraAccessException = new CameraAccessException(error);
+ CameraAccessExceptionCompat cameraAccessExceptionCompat =
+ CameraAccessExceptionCompat.toCameraAccessExceptionCompat(
+ cameraAccessException);
+
+ assertThat(cameraAccessExceptionCompat.getReason()).isEqualTo(error);
+ assertThat(cameraAccessExceptionCompat.toCameraAccessException())
+ .isEqualTo(cameraAccessException);
+
+ }
+ }
+}
diff --git a/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/compat/CameraManagerCompatTest.java b/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/compat/CameraManagerCompatTest.java
index bddd411..b66a1e5 100644
--- a/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/compat/CameraManagerCompatTest.java
+++ b/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/compat/CameraManagerCompatTest.java
@@ -25,6 +25,7 @@
import android.content.Context;
import android.hardware.camera2.CameraAccessException;
+import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraDevice;
import android.hardware.camera2.CameraManager;
import android.os.Build;
@@ -77,8 +78,16 @@
}
@Test
+ public void getCameraCharacteristics_callUnderlyingMethod() throws CameraAccessExceptionCompat {
+ CameraManagerCompat manager = CameraManagerCompat.from(mContext);
+ manager.getCameraCharacteristics(CAMERA_ID);
+
+ verify(mInteractionCallback, times(1)).getCameraCharacteristics(any(String.class));
+ }
+
+ @Test
@Config(maxSdk = 27)
- public void openCamera_callsHandlerMethod() throws CameraAccessException {
+ public void openCamera_callsHandlerMethod() throws CameraAccessExceptionCompat {
CameraManagerCompat manager = CameraManagerCompat.from(mContext);
manager.openCamera(CAMERA_ID, mock(Executor.class),
mock(CameraDevice.StateCallback.class));
@@ -89,7 +98,7 @@
@Test
@Config(minSdk = 28)
- public void openCamera_callsExecutorMethod() throws CameraAccessException {
+ public void openCamera_callsExecutorMethod() throws CameraAccessExceptionCompat {
CameraManagerCompat manager = CameraManagerCompat.from(mContext);
manager.openCamera(CAMERA_ID, mock(Executor.class),
mock(CameraDevice.StateCallback.class));
@@ -184,6 +193,8 @@
private static final String[] EMPTY_ID_LIST = new String[]{};
private final List<Callback> mCallbacks = new ArrayList<>();
+ private final CameraCharacteristics mCameraCharacteristics =
+ mock(CameraCharacteristics.class);
void addCallback(Callback callback) {
mCallbacks.add(callback);
@@ -199,6 +210,15 @@
return EMPTY_ID_LIST;
}
+ @NonNull
+ @Implementation
+ protected CameraCharacteristics getCameraCharacteristics(@NonNull String cameraId) {
+ for (Callback cb : mCallbacks) {
+ cb.getCameraCharacteristics(cameraId);
+ }
+ return mCameraCharacteristics;
+ }
+
@Implementation
protected void openCamera(@NonNull String cameraId,
@NonNull CameraDevice.StateCallback callback, @Nullable Handler handler) {
@@ -245,6 +265,9 @@
@NonNull
String[] getCameraIdList();
+ @NonNull
+ CameraCharacteristics getCameraCharacteristics(@NonNull String cameraId);
+
void openCamera(@NonNull String cameraId,
@NonNull CameraDevice.StateCallback callback, @Nullable Handler handler);
diff --git a/camera/camera-core/api/1.0.0-beta05.txt b/camera/camera-core/api/1.0.0-beta05.txt
index ac0d987..1b9883a 100644
--- a/camera/camera-core/api/1.0.0-beta05.txt
+++ b/camera/camera-core/api/1.0.0-beta05.txt
@@ -46,6 +46,21 @@
method public androidx.camera.core.CameraSelector.Builder requireLensFacing(int);
}
+ public class CameraUnavailableException extends java.lang.Exception {
+ ctor public CameraUnavailableException(int);
+ ctor public CameraUnavailableException(int, String?);
+ ctor public CameraUnavailableException(int, String?, Throwable?);
+ ctor public CameraUnavailableException(int, Throwable?);
+ method public int getReason();
+ field public static final int CAMERA_DISABLED = 1; // 0x1
+ field public static final int CAMERA_DISCONNECTED = 2; // 0x2
+ field public static final int CAMERA_ERROR = 3; // 0x3
+ field public static final int CAMERA_IN_USE = 4; // 0x4
+ field public static final int CAMERA_MAX_IN_USE = 5; // 0x5
+ field public static final int CAMERA_UNAVAILABLE_DO_NOT_DISTURB = 6; // 0x6
+ field public static final int CAMERA_UNKNOWN_ERROR = 0; // 0x0
+ }
+
public final class CameraXConfig {
}
@@ -215,6 +230,12 @@
method public int getRowStride();
}
+ public class InitializationException extends java.lang.Exception {
+ ctor public InitializationException(String?);
+ ctor public InitializationException(String?, Throwable?);
+ ctor public InitializationException(Throwable?);
+ }
+
public class MeteringPoint {
method public float getSize();
}
diff --git a/camera/camera-core/api/current.txt b/camera/camera-core/api/current.txt
index ac0d987..1b9883a 100644
--- a/camera/camera-core/api/current.txt
+++ b/camera/camera-core/api/current.txt
@@ -46,6 +46,21 @@
method public androidx.camera.core.CameraSelector.Builder requireLensFacing(int);
}
+ public class CameraUnavailableException extends java.lang.Exception {
+ ctor public CameraUnavailableException(int);
+ ctor public CameraUnavailableException(int, String?);
+ ctor public CameraUnavailableException(int, String?, Throwable?);
+ ctor public CameraUnavailableException(int, Throwable?);
+ method public int getReason();
+ field public static final int CAMERA_DISABLED = 1; // 0x1
+ field public static final int CAMERA_DISCONNECTED = 2; // 0x2
+ field public static final int CAMERA_ERROR = 3; // 0x3
+ field public static final int CAMERA_IN_USE = 4; // 0x4
+ field public static final int CAMERA_MAX_IN_USE = 5; // 0x5
+ field public static final int CAMERA_UNAVAILABLE_DO_NOT_DISTURB = 6; // 0x6
+ field public static final int CAMERA_UNKNOWN_ERROR = 0; // 0x0
+ }
+
public final class CameraXConfig {
}
@@ -215,6 +230,12 @@
method public int getRowStride();
}
+ public class InitializationException extends java.lang.Exception {
+ ctor public InitializationException(String?);
+ ctor public InitializationException(String?, Throwable?);
+ ctor public InitializationException(Throwable?);
+ }
+
public class MeteringPoint {
method public float getSize();
}
diff --git a/camera/camera-core/api/public_plus_experimental_1.0.0-beta05.txt b/camera/camera-core/api/public_plus_experimental_1.0.0-beta05.txt
index 24f35c1..9b348d20 100644
--- a/camera/camera-core/api/public_plus_experimental_1.0.0-beta05.txt
+++ b/camera/camera-core/api/public_plus_experimental_1.0.0-beta05.txt
@@ -46,6 +46,21 @@
method public androidx.camera.core.CameraSelector.Builder requireLensFacing(int);
}
+ public class CameraUnavailableException extends java.lang.Exception {
+ ctor public CameraUnavailableException(int);
+ ctor public CameraUnavailableException(int, String?);
+ ctor public CameraUnavailableException(int, String?, Throwable?);
+ ctor public CameraUnavailableException(int, Throwable?);
+ method public int getReason();
+ field public static final int CAMERA_DISABLED = 1; // 0x1
+ field public static final int CAMERA_DISCONNECTED = 2; // 0x2
+ field public static final int CAMERA_ERROR = 3; // 0x3
+ field public static final int CAMERA_IN_USE = 4; // 0x4
+ field public static final int CAMERA_MAX_IN_USE = 5; // 0x5
+ field public static final int CAMERA_UNAVAILABLE_DO_NOT_DISTURB = 6; // 0x6
+ field public static final int CAMERA_UNKNOWN_ERROR = 0; // 0x0
+ }
+
public final class CameraXConfig {
}
@@ -223,6 +238,12 @@
method public int getRowStride();
}
+ public class InitializationException extends java.lang.Exception {
+ ctor public InitializationException(String?);
+ ctor public InitializationException(String?, Throwable?);
+ ctor public InitializationException(Throwable?);
+ }
+
public class MeteringPoint {
method public float getSize();
}
diff --git a/camera/camera-core/api/public_plus_experimental_current.txt b/camera/camera-core/api/public_plus_experimental_current.txt
index 24f35c1..9b348d20 100644
--- a/camera/camera-core/api/public_plus_experimental_current.txt
+++ b/camera/camera-core/api/public_plus_experimental_current.txt
@@ -46,6 +46,21 @@
method public androidx.camera.core.CameraSelector.Builder requireLensFacing(int);
}
+ public class CameraUnavailableException extends java.lang.Exception {
+ ctor public CameraUnavailableException(int);
+ ctor public CameraUnavailableException(int, String?);
+ ctor public CameraUnavailableException(int, String?, Throwable?);
+ ctor public CameraUnavailableException(int, Throwable?);
+ method public int getReason();
+ field public static final int CAMERA_DISABLED = 1; // 0x1
+ field public static final int CAMERA_DISCONNECTED = 2; // 0x2
+ field public static final int CAMERA_ERROR = 3; // 0x3
+ field public static final int CAMERA_IN_USE = 4; // 0x4
+ field public static final int CAMERA_MAX_IN_USE = 5; // 0x5
+ field public static final int CAMERA_UNAVAILABLE_DO_NOT_DISTURB = 6; // 0x6
+ field public static final int CAMERA_UNKNOWN_ERROR = 0; // 0x0
+ }
+
public final class CameraXConfig {
}
@@ -223,6 +238,12 @@
method public int getRowStride();
}
+ public class InitializationException extends java.lang.Exception {
+ ctor public InitializationException(String?);
+ ctor public InitializationException(String?, Throwable?);
+ ctor public InitializationException(Throwable?);
+ }
+
public class MeteringPoint {
method public float getSize();
}
diff --git a/camera/camera-core/api/restricted_1.0.0-beta05.txt b/camera/camera-core/api/restricted_1.0.0-beta05.txt
index ac0d987..1b9883a 100644
--- a/camera/camera-core/api/restricted_1.0.0-beta05.txt
+++ b/camera/camera-core/api/restricted_1.0.0-beta05.txt
@@ -46,6 +46,21 @@
method public androidx.camera.core.CameraSelector.Builder requireLensFacing(int);
}
+ public class CameraUnavailableException extends java.lang.Exception {
+ ctor public CameraUnavailableException(int);
+ ctor public CameraUnavailableException(int, String?);
+ ctor public CameraUnavailableException(int, String?, Throwable?);
+ ctor public CameraUnavailableException(int, Throwable?);
+ method public int getReason();
+ field public static final int CAMERA_DISABLED = 1; // 0x1
+ field public static final int CAMERA_DISCONNECTED = 2; // 0x2
+ field public static final int CAMERA_ERROR = 3; // 0x3
+ field public static final int CAMERA_IN_USE = 4; // 0x4
+ field public static final int CAMERA_MAX_IN_USE = 5; // 0x5
+ field public static final int CAMERA_UNAVAILABLE_DO_NOT_DISTURB = 6; // 0x6
+ field public static final int CAMERA_UNKNOWN_ERROR = 0; // 0x0
+ }
+
public final class CameraXConfig {
}
@@ -215,6 +230,12 @@
method public int getRowStride();
}
+ public class InitializationException extends java.lang.Exception {
+ ctor public InitializationException(String?);
+ ctor public InitializationException(String?, Throwable?);
+ ctor public InitializationException(Throwable?);
+ }
+
public class MeteringPoint {
method public float getSize();
}
diff --git a/camera/camera-core/api/restricted_current.txt b/camera/camera-core/api/restricted_current.txt
index ac0d987..1b9883a 100644
--- a/camera/camera-core/api/restricted_current.txt
+++ b/camera/camera-core/api/restricted_current.txt
@@ -46,6 +46,21 @@
method public androidx.camera.core.CameraSelector.Builder requireLensFacing(int);
}
+ public class CameraUnavailableException extends java.lang.Exception {
+ ctor public CameraUnavailableException(int);
+ ctor public CameraUnavailableException(int, String?);
+ ctor public CameraUnavailableException(int, String?, Throwable?);
+ ctor public CameraUnavailableException(int, Throwable?);
+ method public int getReason();
+ field public static final int CAMERA_DISABLED = 1; // 0x1
+ field public static final int CAMERA_DISCONNECTED = 2; // 0x2
+ field public static final int CAMERA_ERROR = 3; // 0x3
+ field public static final int CAMERA_IN_USE = 4; // 0x4
+ field public static final int CAMERA_MAX_IN_USE = 5; // 0x5
+ field public static final int CAMERA_UNAVAILABLE_DO_NOT_DISTURB = 6; // 0x6
+ field public static final int CAMERA_UNKNOWN_ERROR = 0; // 0x0
+ }
+
public final class CameraXConfig {
}
@@ -215,6 +230,12 @@
method public int getRowStride();
}
+ public class InitializationException extends java.lang.Exception {
+ ctor public InitializationException(String?);
+ ctor public InitializationException(String?, Throwable?);
+ ctor public InitializationException(Throwable?);
+ }
+
public class MeteringPoint {
method public float getSize();
}
diff --git a/camera/camera-core/src/main/java/androidx/camera/core/CameraExecutor.java b/camera/camera-core/src/main/java/androidx/camera/core/CameraExecutor.java
index 1813d25..74dc16b 100644
--- a/camera/camera-core/src/main/java/androidx/camera/core/CameraExecutor.java
+++ b/camera/camera-core/src/main/java/androidx/camera/core/CameraExecutor.java
@@ -77,7 +77,7 @@
int cameraNumber = 0;
try {
cameraNumber = cameraFactory.getAvailableCameraIds().size();
- } catch (CameraInfoUnavailableException e) {
+ } catch (CameraUnavailableException e) {
e.printStackTrace();
}
// According to the document of ThreadPoolExecutor, "If there are more than corePoolSize
diff --git a/camera/camera-core/src/main/java/androidx/camera/core/CameraUnavailableException.java b/camera/camera-core/src/main/java/androidx/camera/core/CameraUnavailableException.java
new file mode 100644
index 0000000..354c71c
--- /dev/null
+++ b/camera/camera-core/src/main/java/androidx/camera/core/CameraUnavailableException.java
@@ -0,0 +1,123 @@
+/*
+ * 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 androidx.camera.core;
+
+import android.app.NotificationManager;
+
+import androidx.annotation.IntDef;
+import androidx.annotation.Nullable;
+import androidx.annotation.RestrictTo;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * {@code CameraUnavailableException} is thrown when a camera device could not be queried or opened
+ * or if the connection to an opened camera device is no longer valid.
+ */
+public class CameraUnavailableException extends Exception {
+
+ /**
+ * Some other error occurred.
+ */
+ public static final int CAMERA_UNKNOWN_ERROR = 0;
+
+ /**
+ * The camera is disabled due to a device policy, and cannot be opened.
+ */
+ public static final int CAMERA_DISABLED = 1;
+
+ /**
+ * The camera device is removable and has been disconnected from the Android device, or the
+ * camera service has shut down the connection due to a higher-priority access request for the
+ * camera device.
+ */
+ public static final int CAMERA_DISCONNECTED = 2;
+
+ /**
+ * The camera device is currently in the error state.
+ *
+ * <p>The camera has failed to open or has failed at a later time as a result of some
+ * non-user interaction.
+ */
+ public static final int CAMERA_ERROR = 3;
+
+
+ /**
+ * The camera device is in use already.
+ */
+ public static final int CAMERA_IN_USE = 4;
+
+ /**
+ * The system-wide limit for number of open cameras or camera resources has been reached, and
+ * more camera devices cannot be opened.
+ */
+ public static final int CAMERA_MAX_IN_USE = 5;
+
+ /**
+ * The camera is unavailable due to {@link NotificationManager.Policy}. Some API 28 devices
+ * cannot access the camera when the device is in "Do Not Disturb" mode. The camera will not
+ * be accessible until "Do Not Disturb" mode is disabled.
+ *
+ * @see NotificationManager#getCurrentInterruptionFilter()
+ * @see NotificationManager#ACTION_INTERRUPTION_FILTER_CHANGED
+ */
+ public static final int CAMERA_UNAVAILABLE_DO_NOT_DISTURB = 6;
+
+ /** @hide */
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(value = {
+ CAMERA_UNKNOWN_ERROR,
+ CAMERA_DISABLED,
+ CAMERA_DISCONNECTED,
+ CAMERA_ERROR,
+ CAMERA_IN_USE,
+ CAMERA_MAX_IN_USE,
+ CAMERA_UNAVAILABLE_DO_NOT_DISTURB
+ })
+ public @interface Reason {}
+
+ private final int mReason;
+
+ public CameraUnavailableException(@Reason int reason) {
+ super();
+ mReason = reason;
+ }
+
+ public CameraUnavailableException(@Reason int reason, @Nullable String message) {
+ super(message);
+ mReason = reason;
+ }
+
+ public CameraUnavailableException(@Reason int reason, @Nullable String message,
+ @Nullable Throwable cause) {
+ super(message, cause);
+ mReason = reason;
+ }
+
+ public CameraUnavailableException(@Reason int reason, @Nullable Throwable cause) {
+ super(cause);
+ mReason = reason;
+ }
+
+ /** The reason the camera is unavailable. */
+ @Reason
+ public int getReason() {
+ return mReason;
+ }
+}
diff --git a/camera/camera-core/src/main/java/androidx/camera/core/CameraX.java b/camera/camera-core/src/main/java/androidx/camera/core/CameraX.java
index 1030110..079901d 100644
--- a/camera/camera-core/src/main/java/androidx/camera/core/CameraX.java
+++ b/camera/camera-core/src/main/java/androidx/camera/core/CameraX.java
@@ -605,7 +605,10 @@
*
* @param context to attach
* @param cameraXConfig configuration options for this application session.
- * @return A {@link ListenableFuture} representing the initialization task.
+ * @return A {@link ListenableFuture} representing the initialization task. This future may
+ * fail with an {@link InitializationException} and associated cause that can be retrieved by
+ * {@link Throwable#getCause()). The cause will be a {@link CameraUnavailableException} if it
+ * fails to access any camera during initialization.
*/
@NonNull
public static ListenableFuture<Void> initialize(@NonNull Context context,
@@ -970,16 +973,15 @@
return CallbackToFutureAdapter.getFuture(
completer -> {
cameraExecutor.execute(() -> {
- Exception e = null;
+ InitializationException initException = null;
try {
mContext = (Application) context.getApplicationContext();
CameraFactory.Provider cameraFactoryProvider =
cameraXConfig.getCameraFactoryProvider(null);
if (cameraFactoryProvider == null) {
- e = new IllegalArgumentException(
+ throw new InitializationException(new IllegalArgumentException(
"Invalid app configuration provided. Missing "
- + "CameraFactory.");
- return;
+ + "CameraFactory."));
}
CameraThreadConfig cameraThreadConfig =
@@ -992,20 +994,18 @@
CameraDeviceSurfaceManager.Provider surfaceManagerProvider =
cameraXConfig.getDeviceSurfaceManagerProvider(null);
if (surfaceManagerProvider == null) {
- e = new IllegalArgumentException(
+ throw new InitializationException(new IllegalArgumentException(
"Invalid app configuration provided. Missing "
- + "CameraDeviceSurfaceManager.");
- return;
+ + "CameraDeviceSurfaceManager."));
}
mSurfaceManager = surfaceManagerProvider.newInstance(context);
UseCaseConfigFactory.Provider configFactoryProvider =
cameraXConfig.getUseCaseConfigFactoryProvider(null);
if (configFactoryProvider == null) {
- e = new IllegalArgumentException(
+ throw new InitializationException(new IllegalArgumentException(
"Invalid app configuration provided. Missing "
- + "UseCaseConfigFactory.");
- return;
+ + "UseCaseConfigFactory."));
}
mDefaultConfigFactory = configFactoryProvider.newInstance(context);
@@ -1015,12 +1015,18 @@
}
mCameraRepository.init(mCameraFactory);
+ } catch (InitializationException e) {
+ initException = e;
+ } catch (RuntimeException e) {
+ // For any unexpected RuntimeException, catch it instead of
+ // crashing.
+ initException = new InitializationException(e);
} finally {
synchronized (mInitializeLock) {
mInitState = InternalInitState.INITIALIZED;
}
- if (e != null) {
- completer.setException(e);
+ if (initException != null) {
+ completer.setException(initException);
} else {
completer.set(null);
}
diff --git a/camera/camera-core/src/main/java/androidx/camera/core/InitializationException.java b/camera/camera-core/src/main/java/androidx/camera/core/InitializationException.java
new file mode 100644
index 0000000..a29b185
--- /dev/null
+++ b/camera/camera-core/src/main/java/androidx/camera/core/InitializationException.java
@@ -0,0 +1,38 @@
+/*
+ * 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 androidx.camera.core;
+
+import androidx.annotation.Nullable;
+
+/**
+ * {@code InitializationException} is thrown when a failure occurs during an initialization
+ * process.
+ */
+public class InitializationException extends Exception {
+
+ public InitializationException(@Nullable String message) {
+ super(message);
+ }
+
+ public InitializationException(@Nullable String message, @Nullable Throwable cause) {
+ super(message, cause);
+ }
+
+ public InitializationException(@Nullable Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/camera/camera-core/src/main/java/androidx/camera/core/impl/CameraDeviceSurfaceManager.java b/camera/camera-core/src/main/java/androidx/camera/core/impl/CameraDeviceSurfaceManager.java
index 8ab8d72..6c222e2 100644
--- a/camera/camera-core/src/main/java/androidx/camera/core/impl/CameraDeviceSurfaceManager.java
+++ b/camera/camera-core/src/main/java/androidx/camera/core/impl/CameraDeviceSurfaceManager.java
@@ -22,6 +22,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import androidx.camera.core.InitializationException;
import java.util.List;
import java.util.Map;
@@ -36,9 +37,16 @@
* Interface for deferring creation of a CameraDeviceSurfaceManager.
*/
interface Provider {
- /** Creates a new, initialized instance of a CameraDeviceSurfaceManager. */
+ /**
+ * Creates a new, initialized instance of a CameraDeviceSurfaceManager.
+ *
+ * @param context the android context
+ * @return the factory instance
+ * @throws InitializationException if it fails to create the factory
+ */
@NonNull
- CameraDeviceSurfaceManager newInstance(@NonNull Context context);
+ CameraDeviceSurfaceManager newInstance(@NonNull Context context)
+ throws InitializationException;
}
/**
diff --git a/camera/camera-core/src/main/java/androidx/camera/core/impl/CameraFactory.java b/camera/camera-core/src/main/java/androidx/camera/core/impl/CameraFactory.java
index c1ce609..2b943f8 100644
--- a/camera/camera-core/src/main/java/androidx/camera/core/impl/CameraFactory.java
+++ b/camera/camera-core/src/main/java/androidx/camera/core/impl/CameraFactory.java
@@ -19,7 +19,8 @@
import android.content.Context;
import androidx.annotation.NonNull;
-import androidx.camera.core.CameraInfoUnavailableException;
+import androidx.camera.core.CameraUnavailableException;
+import androidx.camera.core.InitializationException;
import java.util.Set;
@@ -32,9 +33,16 @@
* Interface for deferring creation of a CameraFactory.
*/
interface Provider {
- /** Creates a new, initialized instance of a CameraFactory. */
+ /**
+ * Creates a new, initialized instance of a CameraFactory.
+ *
+ * @param context the android context
+ * @param threadConfig the thread config to run the camera operations
+ * @return the factory instance
+ * @throws InitializationException if it fails to create the factory.
+ */
@NonNull CameraFactory newInstance(@NonNull Context context,
- @NonNull CameraThreadConfig threadConfig);
+ @NonNull CameraThreadConfig threadConfig) throws InitializationException;
}
/**
@@ -42,21 +50,21 @@
*
* @param cameraId the camera id to get camera with
* @return the camera object with given camera id
- * @throws CameraInfoUnavailableException if unable to access cameras, perhaps due
- * to insufficient permissions.
- * @throws IllegalArgumentException if the given camera id is not on the available
- * camera id list.
+ * @throws CameraUnavailableException if unable to access cameras, perhaps due
+ * to insufficient permissions.
+ * @throws IllegalArgumentException if the given camera id is not on the available
+ * camera id list.
*/
@NonNull
- CameraInternal getCamera(@NonNull String cameraId) throws CameraInfoUnavailableException;
+ CameraInternal getCamera(@NonNull String cameraId) throws CameraUnavailableException;
/**
* Gets the ids of all available cameras.
*
* @return the list of available cameras
- * @throws CameraInfoUnavailableException if unable to access cameras, perhaps due
- * to insufficient permissions.
+ * @throws CameraUnavailableException if unable to access cameras, perhaps due
+ * to insufficient permissions.
*/
@NonNull
- Set<String> getAvailableCameraIds() throws CameraInfoUnavailableException;
+ Set<String> getAvailableCameraIds() throws CameraUnavailableException;
}
diff --git a/camera/camera-core/src/main/java/androidx/camera/core/impl/CameraRepository.java b/camera/camera-core/src/main/java/androidx/camera/core/impl/CameraRepository.java
index 6cfd6f2..b8f33af 100644
--- a/camera/camera-core/src/main/java/androidx/camera/core/impl/CameraRepository.java
+++ b/camera/camera-core/src/main/java/androidx/camera/core/impl/CameraRepository.java
@@ -21,6 +21,8 @@
import androidx.annotation.GuardedBy;
import androidx.annotation.NonNull;
+import androidx.camera.core.CameraUnavailableException;
+import androidx.camera.core.InitializationException;
import androidx.camera.core.UseCase;
import androidx.camera.core.impl.utils.executor.CameraXExecutors;
import androidx.camera.core.impl.utils.futures.Futures;
@@ -57,7 +59,7 @@
*
* <p>All cameras queried from the {@link CameraFactory} will be added to the repository.
*/
- public void init(@NonNull CameraFactory cameraFactory) {
+ public void init(@NonNull CameraFactory cameraFactory) throws InitializationException {
synchronized (mCamerasLock) {
try {
Set<String> camerasList = cameraFactory.getAvailableCameraIds();
@@ -65,8 +67,8 @@
Log.d(TAG, "Added camera: " + id);
mCameras.put(id, cameraFactory.getCamera(id));
}
- } catch (Exception e) {
- throw new IllegalStateException("Unable to enumerate cameras", e);
+ } catch (CameraUnavailableException e) {
+ throw new InitializationException(e);
}
}
}
diff --git a/camera/camera-core/src/main/java/androidx/camera/core/impl/UseCaseConfigFactory.java b/camera/camera-core/src/main/java/androidx/camera/core/impl/UseCaseConfigFactory.java
index f2dac87..e75f881 100644
--- a/camera/camera-core/src/main/java/androidx/camera/core/impl/UseCaseConfigFactory.java
+++ b/camera/camera-core/src/main/java/androidx/camera/core/impl/UseCaseConfigFactory.java
@@ -21,6 +21,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.camera.core.CameraInfo;
+import androidx.camera.core.InitializationException;
/**
* A Repository for generating use case configurations.
@@ -31,9 +32,15 @@
* Interface for deferring creation of a UseCaseConfigFactory.
*/
interface Provider {
- /** Creates a new, initialized instance of a UseCaseConfigFactory. */
+ /**
+ * Creates a new, initialized instance of a UseCaseConfigFactory.
+ *
+ * @param context the android context
+ * @return the factory instance
+ * @throws InitializationException if it fails to create the factory
+ */
@NonNull
- UseCaseConfigFactory newInstance(@NonNull Context context);
+ UseCaseConfigFactory newInstance(@NonNull Context context) throws InitializationException;
}
/**
diff --git a/camera/camera-core/src/test/java/androidx/camera/core/impl/CameraRepositoryTest.java b/camera/camera-core/src/test/java/androidx/camera/core/impl/CameraRepositoryTest.java
index a99d6d8..8f218f4 100644
--- a/camera/camera-core/src/test/java/androidx/camera/core/impl/CameraRepositoryTest.java
+++ b/camera/camera-core/src/test/java/androidx/camera/core/impl/CameraRepositoryTest.java
@@ -21,6 +21,7 @@
import android.os.Build;
import androidx.camera.core.CameraSelector;
+import androidx.camera.core.InitializationException;
import androidx.camera.testing.fakes.FakeCamera;
import androidx.camera.testing.fakes.FakeCameraFactory;
import androidx.camera.testing.fakes.FakeCameraInfoInternal;
@@ -52,7 +53,7 @@
private CameraRepository mCameraRepository;
@Before
- public void setUp() {
+ public void setUp() throws InitializationException {
mCameraRepository = new CameraRepository();
FakeCameraFactory fakeCameraFactory = new FakeCameraFactory();
diff --git a/camera/camera-extensions/src/main/java/androidx/camera/extensions/CameraUtil.java b/camera/camera-extensions/src/main/java/androidx/camera/extensions/CameraUtil.java
index 44aeea6..71862dd 100644
--- a/camera/camera-extensions/src/main/java/androidx/camera/extensions/CameraUtil.java
+++ b/camera/camera-extensions/src/main/java/androidx/camera/extensions/CameraUtil.java
@@ -17,13 +17,13 @@
package androidx.camera.extensions;
import android.content.Context;
-import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraCharacteristics;
-import android.hardware.camera2.CameraManager;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import androidx.camera.camera2.internal.compat.CameraAccessExceptionCompat;
+import androidx.camera.camera2.internal.compat.CameraManagerCompat;
import androidx.camera.core.CameraSelector;
import androidx.camera.core.CameraX;
import androidx.core.util.Preconditions;
@@ -57,12 +57,11 @@
static CameraCharacteristics getCameraCharacteristics(String cameraId) {
Preconditions.checkNotNull(cameraId, "Invalid camera id.");
Context context = CameraX.getContext();
- CameraManager cameraManager = (CameraManager) context.getSystemService(
- Context.CAMERA_SERVICE);
+ CameraManagerCompat cameraManager = CameraManagerCompat.from(context);
CameraCharacteristics cameraCharacteristics = null;
try {
cameraCharacteristics = cameraManager.getCameraCharacteristics(cameraId);
- } catch (CameraAccessException e) {
+ } catch (CameraAccessExceptionCompat e) {
throw new IllegalArgumentException(
"Unable to retrieve info for camera with id " + cameraId + ".", e);
}
diff --git a/camera/camera-lifecycle/src/main/java/androidx/camera/lifecycle/ProcessCameraProvider.java b/camera/camera-lifecycle/src/main/java/androidx/camera/lifecycle/ProcessCameraProvider.java
index a7fd82b..57b466c 100644
--- a/camera/camera-lifecycle/src/main/java/androidx/camera/lifecycle/ProcessCameraProvider.java
+++ b/camera/camera-lifecycle/src/main/java/androidx/camera/lifecycle/ProcessCameraProvider.java
@@ -28,10 +28,12 @@
import androidx.camera.core.Camera;
import androidx.camera.core.CameraInfoUnavailableException;
import androidx.camera.core.CameraSelector;
+import androidx.camera.core.CameraUnavailableException;
import androidx.camera.core.CameraX;
import androidx.camera.core.CameraXConfig;
import androidx.camera.core.ImageAnalysis;
import androidx.camera.core.ImageCapture;
+import androidx.camera.core.InitializationException;
import androidx.camera.core.Preview;
import androidx.camera.core.UseCase;
import androidx.camera.core.UseCaseGroup;
@@ -93,7 +95,9 @@
* If no {@link CameraXConfig.Provider} is implemented, a default configuration will be used.
*
* @return A future which will contain the {@link ProcessCameraProvider}. Cancellation of
- * this future is a no-op.
+ * this future is a no-op. This future may fail with an {@link InitializationException} and
+ * associated cause that can be retrieved by {@link Throwable#getCause()). The cause will be
+ * a {@link CameraUnavailableException} if it fails to access any camera during initialization.
* @throws IllegalStateException if CameraX fails to initialize via a default provider or a
* CameraXConfig.Provider.
*/
diff --git a/compose/compose-compiler-hosted/integration-tests/src/test/java/androidx/compose/plugins/kotlin/ControlFlowTransformTests.kt b/compose/compose-compiler-hosted/integration-tests/src/test/java/androidx/compose/plugins/kotlin/ControlFlowTransformTests.kt
index 544121a..4e98ec6 100644
--- a/compose/compose-compiler-hosted/integration-tests/src/test/java/androidx/compose/plugins/kotlin/ControlFlowTransformTests.kt
+++ b/compose/compose-compiler-hosted/integration-tests/src/test/java/androidx/compose/plugins/kotlin/ControlFlowTransformTests.kt
@@ -2025,16 +2025,17 @@
%composer.startReplaceableGroup(%key)
val tmp0 = if (x > 0) {
%composer.startReplaceableGroup(<>)
- val tmp3_group =
- if (%composer.startReplaceableGroup(<>)
+ val tmp4_group =
+ val tmp3_group = if (%composer.startReplaceableGroup(<>)
val tmp1_group = B(%composer, <>, 0)
%composer.endReplaceableGroup()
tmp1_group) 1 else if (%composer.startReplaceableGroup(<>)
val tmp2_group = B(%composer, <>, 0)
%composer.endReplaceableGroup()
tmp2_group) 2 else 3
- %composer.endReplaceableGroup()
tmp3_group
+ %composer.endReplaceableGroup()
+ tmp4_group
} else {
%composer.startReplaceableGroup(<>)
%composer.endReplaceableGroup()
@@ -2045,4 +2046,254 @@
}
"""
)
+
+ @Test
+ fun testTheThing(): Unit = controlFlow(
+ """
+ @Direct
+ @Composable
+ fun Simple() {
+ // this has a composable call in it, and since we don't know the number of times the
+ // lambda will get called, we place a group around the whole call
+ run {
+ A()
+ }
+ A()
+ }
+
+ @Direct
+ @Composable
+ fun WithReturn() {
+ // this has an early return in it, so it needs to end all of the groups present.
+ run {
+ A()
+ return@WithReturn
+ }
+ A()
+ }
+
+ @Direct
+ @Composable
+ fun NoCalls() {
+ // this has no composable calls in it, so shouldn't cause any groups to get created
+ run {
+ println("hello world")
+ }
+ A()
+ }
+
+ @Direct
+ @Composable
+ fun NoCallsAfter() {
+ // this has a composable call in the lambda, but not after it, which means the
+ // group should be able to be coalesced into the group of the function
+ run {
+ A()
+ }
+ }
+ """,
+ """
+ @Direct
+ @Composable
+ fun Simple(%composer: Composer<*>?, %key: Int, %changed: Int) {
+ %composer.startReplaceableGroup(%key)
+ %composer.startReplaceableGroup(<>)
+ run {
+ A(%composer, <>, 0)
+ }
+ %composer.endReplaceableGroup()
+ A(%composer, <>, 0)
+ %composer.endReplaceableGroup()
+ }
+ @Direct
+ @Composable
+ fun WithReturn(%composer: Composer<*>?, %key: Int, %changed: Int) {
+ %composer.startReplaceableGroup(%key)
+ %composer.startReplaceableGroup(<>)
+ run {
+ A(%composer, <>, 0)
+ %composer.endReplaceableGroup()
+ %composer.endReplaceableGroup()
+ return
+ }
+ %composer.endReplaceableGroup()
+ A(%composer, <>, 0)
+ %composer.endReplaceableGroup()
+ }
+ @Direct
+ @Composable
+ fun NoCalls(%composer: Composer<*>?, %key: Int, %changed: Int) {
+ %composer.startReplaceableGroup(%key)
+ run {
+ println("hello world")
+ }
+ A(%composer, <>, 0)
+ %composer.endReplaceableGroup()
+ }
+ @Direct
+ @Composable
+ fun NoCallsAfter(%composer: Composer<*>?, %key: Int, %changed: Int) {
+ %composer.startReplaceableGroup(%key)
+ run {
+ A(%composer, <>, 0)
+ }
+ %composer.endReplaceableGroup()
+ }
+ """
+ )
+
+ @Test
+ fun testLetWithComposableCalls(): Unit = controlFlow(
+ """
+ @Composable
+ fun Example(x: Int?) {
+ x?.let {
+ if (it > 0) {
+ A()
+ }
+ A()
+ }
+ A()
+ }
+ """,
+ """
+ @Composable
+ fun Example(x: Int?, %composer: Composer<*>?, %key: Int, %changed: Int) {
+ %composer.startRestartGroup(%key)
+ val %dirty = %changed
+ if (%changed and 0b0110 === 0) {
+ %dirty = %dirty or if (%composer.changed(x)) 0b0100 else 0b0010
+ }
+ if (%dirty and 0b0011 xor 0b0010 !== 0 || !%composer.skipping) {
+ val tmp0_safe_receiver = x
+ when {
+ tmp0_safe_receiver == null -> {
+ %composer.startReplaceableGroup(<>)
+ %composer.endReplaceableGroup()
+ null
+ }
+ else -> {
+ %composer.startReplaceableGroup(<>)
+ tmp0_safe_receiver.let { it: Int ->
+ if (it > 0) {
+ %composer.startReplaceableGroup(<>)
+ A(%composer, <>, 0)
+ %composer.endReplaceableGroup()
+ } else {
+ %composer.startReplaceableGroup(<>)
+ %composer.endReplaceableGroup()
+ }
+ A(%composer, <>, 0)
+ }
+ %composer.endReplaceableGroup()
+ }
+ }
+ A(%composer, <>, 0)
+ } else {
+ %composer.skipToGroupEnd()
+ }
+ %composer.endRestartGroup()?.updateScope { %composer: Composer<*>?, %key: Int, %force: Int ->
+ Example(x, %composer, %key, %changed or 0b0001)
+ }
+ }
+ """
+ )
+
+ @Test
+ fun testLetWithoutComposableCalls(): Unit = controlFlow(
+ """
+ @Composable
+ fun Example(x: Int?) {
+ x?.let {
+ if (it > 0) {
+ NA()
+ }
+ NA()
+ }
+ A()
+ }
+ """,
+ """
+ @Composable
+ fun Example(x: Int?, %composer: Composer<*>?, %key: Int, %changed: Int) {
+ %composer.startRestartGroup(%key)
+ val %dirty = %changed
+ if (%changed and 0b0110 === 0) {
+ %dirty = %dirty or if (%composer.changed(x)) 0b0100 else 0b0010
+ }
+ if (%dirty and 0b0011 xor 0b0010 !== 0 || !%composer.skipping) {
+ x?.let { it: Int ->
+ if (it > 0) {
+ NA()
+ }
+ NA()
+ }
+ A(%composer, <>, 0)
+ } else {
+ %composer.skipToGroupEnd()
+ }
+ %composer.endRestartGroup()?.updateScope { %composer: Composer<*>?, %key: Int, %force: Int ->
+ Example(x, %composer, %key, %changed or 0b0001)
+ }
+ }
+ """
+ )
+
+ @Test
+ fun testApplyOnComposableCallResult(): Unit = controlFlow(
+ """
+ import androidx.compose.state
+ import androidx.compose.State
+
+ @Composable
+ fun <T> provided(value: T): State<T> = state { value }.apply {
+ this.value = value
+ }
+ """,
+ """
+ @Composable
+ fun <T> provided(value: T, %composer: Composer<*>?, %key: Int, %changed: Int): State<T> {
+ %composer.startReplaceableGroup(%key)
+ val tmp0 = state(null, {
+ val tmp0_return = value
+ tmp0_return
+ }, %composer, <>, 0, 0b0001).apply {
+ value = value
+ }
+ %composer.endReplaceableGroup()
+ return tmp0
+ }
+ """
+ )
+
+ @Test
+ fun testReturnInlinedExpressionWithCall(): Unit = controlFlow(
+ """
+ import androidx.compose.state
+ import androidx.compose.State
+
+ @Composable
+ fun Test(x: Int): Int {
+ return x.let {
+ A()
+ 123
+ }
+ }
+ """,
+ """
+ @Composable
+ fun Test(x: Int, %composer: Composer<*>?, %key: Int, %changed: Int): Int {
+ %composer.startReplaceableGroup(%key)
+ val tmp0 =
+ val tmp1_group = x.let { it: Int ->
+ A(%composer, <>, 0)
+ val tmp0_return = 123
+ tmp0_return
+ }
+ tmp1_group
+ %composer.endReplaceableGroup()
+ return tmp0
+ }
+ """
+ )
}
\ No newline at end of file
diff --git a/compose/compose-compiler-hosted/integration-tests/src/test/java/androidx/compose/plugins/kotlin/EmitTransformTests.kt b/compose/compose-compiler-hosted/integration-tests/src/test/java/androidx/compose/plugins/kotlin/EmitTransformTests.kt
index 35539c4..da6232a 100644
--- a/compose/compose-compiler-hosted/integration-tests/src/test/java/androidx/compose/plugins/kotlin/EmitTransformTests.kt
+++ b/compose/compose-compiler-hosted/integration-tests/src/test/java/androidx/compose/plugins/kotlin/EmitTransformTests.kt
@@ -80,19 +80,22 @@
%composer.startRestartGroup(%key)
if (%changed !== 0 || !%composer.skipping) {
val cond = state(null, {
- true
+ val tmp0_return = true
+ tmp0_return
}, %composer, <>, 0, 0b0001)
val text = if (cond.value) {
%composer.startReplaceableGroup(<>)
val tmp0_group = remember({
- "abc"
+ val tmp0_return = "abc"
+ tmp0_return
}, %composer, <>, 0)
%composer.endReplaceableGroup()
tmp0_group
} else {
%composer.startReplaceableGroup(<>)
val tmp1_group = remember({
- "def"
+ val tmp0_return = "def"
+ tmp0_return
}, %composer, <>, 0)
%composer.endReplaceableGroup()
tmp1_group
diff --git a/compose/compose-compiler-hosted/src/main/java/androidx/compose/plugins/kotlin/compiler/lower/AbstractComposeLowering.kt b/compose/compose-compiler-hosted/src/main/java/androidx/compose/plugins/kotlin/compiler/lower/AbstractComposeLowering.kt
index 36c352b..a5e109a5 100644
--- a/compose/compose-compiler-hosted/src/main/java/androidx/compose/plugins/kotlin/compiler/lower/AbstractComposeLowering.kt
+++ b/compose/compose-compiler-hosted/src/main/java/androidx/compose/plugins/kotlin/compiler/lower/AbstractComposeLowering.kt
@@ -21,6 +21,7 @@
import androidx.compose.plugins.kotlin.KtxNameConventions
import androidx.compose.plugins.kotlin.analysis.ComposeWritableSlices
import androidx.compose.plugins.kotlin.irTrace
+import androidx.compose.plugins.kotlin.isEmitInline
import androidx.compose.plugins.kotlin.isMarkedStable
import androidx.compose.plugins.kotlin.isSpecialType
import org.jetbrains.kotlin.backend.common.descriptors.isFunctionOrKFunctionType
@@ -117,12 +118,15 @@
import org.jetbrains.kotlin.ir.util.referenceFunction
import org.jetbrains.kotlin.ir.util.startOffset
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
+import org.jetbrains.kotlin.js.resolve.diagnostics.findPsi
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.resolve.BindingTrace
import org.jetbrains.kotlin.name.Name
+import org.jetbrains.kotlin.psi.KtFunctionLiteral
import org.jetbrains.kotlin.resolve.DescriptorFactory
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
+import org.jetbrains.kotlin.resolve.inline.InlineUtil
import org.jetbrains.kotlin.resolve.isInlineClassType
import org.jetbrains.kotlin.resolve.unsubstitutedUnderlyingType
import org.jetbrains.kotlin.types.KotlinType
@@ -246,6 +250,24 @@
return context.irTrace[ComposeWritableSlices.IS_SYNTHETIC_COMPOSABLE_CALL, this] == true
}
+ fun IrFunction.isInlinedLambda(): Boolean {
+ descriptor.findPsi()?.let { psi ->
+ (psi as? KtFunctionLiteral)?.let {
+ if (InlineUtil.isInlinedArgument(
+ it,
+ context.bindingContext,
+ false
+ )
+ )
+ return true
+ if (it.isEmitInline(context.bindingContext)) {
+ return true
+ }
+ }
+ }
+ return false
+ }
+
private val composableChecker = ComposableAnnotationChecker()
protected val KotlinType.isEnum
diff --git a/compose/compose-compiler-hosted/src/main/java/androidx/compose/plugins/kotlin/compiler/lower/ComposableFunctionBodyTransformer.kt b/compose/compose-compiler-hosted/src/main/java/androidx/compose/plugins/kotlin/compiler/lower/ComposableFunctionBodyTransformer.kt
index 05f057f..1764819 100644
--- a/compose/compose-compiler-hosted/src/main/java/androidx/compose/plugins/kotlin/compiler/lower/ComposableFunctionBodyTransformer.kt
+++ b/compose/compose-compiler-hosted/src/main/java/androidx/compose/plugins/kotlin/compiler/lower/ComposableFunctionBodyTransformer.kt
@@ -521,7 +521,12 @@
get() {
loop@ for (scope in scopeStack.asReversed()) {
return when (scope) {
- is Scope.FunctionScope -> scope.isComposable
+ is Scope.FunctionScope -> {
+ if (scope.isInlinedLambda) {
+ continue@loop
+ }
+ scope.isComposable
+ }
is Scope.BlockScope -> continue@loop
else -> false
}
@@ -551,6 +556,9 @@
} finally {
val popped = scopeStack.pop()
require(popped == scope) { "Unbalanced scope stack" }
+ if (scope.isInlinedLambda && !scope.isComposable && scope.hasComposableCalls) {
+ encounteredCapturedComposableCall()
+ }
}
}
@@ -1887,6 +1895,22 @@
}
}
+ private fun IrExpression.wrapDeferred(
+ before: List<IrExpression> = emptyList(),
+ after: List<IrExpression> = emptyList()
+ ): IrExpression {
+ return if (type.isNothing() || type.isUnitOrNullableUnit()) {
+ wrap(type, before, after)
+ } else {
+ val tmpVar = irTemporary(this, nameHint = "group")
+ tmpVar.wrap(
+ type,
+ before,
+ after + irGet(tmpVar)
+ )
+ }
+ }
+
private fun IrStatement.wrap(
type: IrType,
before: List<IrExpression> = emptyList(),
@@ -1916,8 +1940,7 @@
},
makeEnd = ::irEndReplaceableGroup
)
- return wrap(
- type,
+ return wrapDeferred(
listOf(before),
listOf(after)
)
@@ -1938,6 +1961,9 @@
when (scope) {
is Scope.FunctionScope -> {
scope.markComposableCall()
+ if (scope.isInlinedLambda) {
+ continue@loop
+ }
break@loop
}
is Scope.BlockScope -> {
@@ -1950,6 +1976,17 @@
}
}
+ private fun encounteredCapturedComposableCall() {
+ loop@ for (scope in scopeStack.asReversed()) {
+ when (scope) {
+ is Scope.CaptureScope -> {
+ scope.markCapturedComposableCall()
+ break@loop
+ }
+ }
+ }
+ }
+
private fun encounteredCoalescableGroup(
coalescableScope: Scope.BlockScope,
realizeGroup: () -> Unit,
@@ -1957,6 +1994,13 @@
) {
loop@ for (scope in scopeStack.asReversed()) {
when (scope) {
+ is Scope.FunctionScope -> {
+ scope.markCoalescableGroup(coalescableScope, realizeGroup, makeEnd)
+ if (scope.isInlinedLambda) {
+ continue@loop
+ }
+ break@loop
+ }
is Scope.BlockScope -> {
scope.markCoalescableGroup(coalescableScope, realizeGroup, makeEnd)
break@loop
@@ -1973,11 +2017,11 @@
loop@ for (scope in scopeStack.asReversed()) {
when (scope) {
is Scope.FunctionScope -> {
- scope.markReturn(extraEndLocation)
if (scope.function == symbol.owner) {
+ scope.markReturn(extraEndLocation)
break@loop
} else {
- TODO("Need to handle nested returns!")
+ continue@loop
}
}
is Scope.BlockScope -> {
@@ -1990,8 +2034,13 @@
private fun encounteredJump(jump: IrBreakContinue, extraEndLocation: (IrExpression) -> Unit) {
loop@ for (scope in scopeStack.asReversed()) {
when (scope) {
- is Scope.FunctionScope -> error("Unexpected Function Scope encountered")
- is Scope.ClassScope -> error("Unexpected Function Scope encountered")
+ is Scope.ClassScope -> error("Unexpected Class Scope encountered")
+ is Scope.FunctionScope -> {
+ if (scope.isInlinedLambda) {
+ continue@loop
+ }
+ error("Unexpected Function Scope encountered")
+ }
is Scope.LoopScope -> {
if (jump.loop == scope.loop) {
break@loop
@@ -2141,7 +2190,23 @@
if (expression.isTransformedComposableCall() || expression.isSyntheticComposableCall()) {
return visitComposableCall(expression)
}
- return super.visitCall(expression)
+ if (expression.symbol.owner.isInline) {
+ // if it is not a composable call but it is an inline function, then we allow
+ // composable calls to happen inside of the inlined lambdas. This means that we have
+ // some control flow analysis to handle there as well. We wrap the call in a
+ // CallScope and coalescable group if the call has any composable invocations inside
+ // of it..
+ val captureScope = withScope(Scope.CaptureScope()) {
+ expression.transformChildrenVoid()
+ }
+ return if (captureScope.hasCapturedComposableCall) {
+ expression.asCoalescableGroup(captureScope)
+ } else {
+ expression
+ }
+ } else {
+ return super.visitCall(expression)
+ }
}
private fun visitComposableCall(expression: IrCall): IrExpression {
@@ -2752,6 +2817,7 @@
) : BlockScope("fun ${function.name.asString()}") {
val remappedParams = mutableMapOf<IrValueDeclaration, IrValueDeclaration>()
val paramsToSlots = mutableMapOf<IrValueDeclaration, Int>()
+ val isInlinedLambda = with(transformer) { function.isInlinedLambda() }
private var lastTemporaryIndex: Int = 0
@@ -2916,6 +2982,14 @@
class LoopScope(val loop: IrLoop) : BlockScope("loop")
class WhenScope : BlockScope("when")
class BranchScope : BlockScope("branch")
+ class CaptureScope : BlockScope("capture") {
+ var hasCapturedComposableCall = false
+ private set
+
+ fun markCapturedComposableCall() {
+ hasCapturedComposableCall = true
+ }
+ }
}
inner class IrDefaultBitMaskValueImpl(
diff --git a/compose/compose-compiler-hosted/src/main/java/androidx/compose/plugins/kotlin/compiler/lower/ComposerParamTransformer.kt b/compose/compose-compiler-hosted/src/main/java/androidx/compose/plugins/kotlin/compiler/lower/ComposerParamTransformer.kt
index 4c256d4..929e235 100644
--- a/compose/compose-compiler-hosted/src/main/java/androidx/compose/plugins/kotlin/compiler/lower/ComposerParamTransformer.kt
+++ b/compose/compose-compiler-hosted/src/main/java/androidx/compose/plugins/kotlin/compiler/lower/ComposerParamTransformer.kt
@@ -669,24 +669,6 @@
return false
}
- fun IrFunction.isInlinedLambda(): Boolean {
- descriptor.findPsi()?.let { psi ->
- (psi as? KtFunctionLiteral)?.let {
- if (InlineUtil.isInlinedArgument(
- it,
- context.bindingContext,
- false
- )
- )
- return true
- if (it.isEmitInline(context.bindingContext)) {
- return true
- }
- }
- }
- return false
- }
-
private fun IrFunction.isEmitInlineChildrenLambda(): Boolean {
descriptor.findPsi()?.let { psi ->
(psi as? KtFunctionLiteral)?.let {
diff --git a/compose/compose-compiler-hosted/src/main/java/androidx/compose/plugins/kotlin/compiler/lower/IrSourcePrinter.kt b/compose/compose-compiler-hosted/src/main/java/androidx/compose/plugins/kotlin/compiler/lower/IrSourcePrinter.kt
index 788188f..3eef569 100644
--- a/compose/compose-compiler-hosted/src/main/java/androidx/compose/plugins/kotlin/compiler/lower/IrSourcePrinter.kt
+++ b/compose/compose-compiler-hosted/src/main/java/androidx/compose/plugins/kotlin/compiler/lower/IrSourcePrinter.kt
@@ -310,6 +310,7 @@
// no names for
"invoke", "get", "set" -> ""
"iterator", "hasNext", "next" -> name
+ "CHECK_NOT_NULL" -> "!!"
else -> error("Unhandled operator $name")
}
@@ -338,6 +339,10 @@
(expression.dispatchReceiver ?: expression.extensionReceiver)?.print()
print(opSymbol)
}
+ "CHECK_NOT_NULL" -> {
+ expression.getValueArgument(0)?.print()
+ print(opSymbol)
+ }
// invoke
"invoke" -> {
(expression.dispatchReceiver ?: expression.extensionReceiver)?.print()
diff --git a/compose/compose-runtime/src/unitTest/kotlin/androidx/compose/mock/ViewComposer.kt b/compose/compose-runtime/src/unitTest/kotlin/androidx/compose/mock/ViewComposer.kt
index 793bf17..a848ee8 100644
--- a/compose/compose-runtime/src/unitTest/kotlin/androidx/compose/mock/ViewComposer.kt
+++ b/compose/compose-runtime/src/unitTest/kotlin/androidx/compose/mock/ViewComposer.kt
@@ -114,6 +114,7 @@
}
}
+@Suppress("UNCHECKED_CAST")
@Composable
fun <P1> MockComposeScope.memoize(
key: Int,
@@ -125,7 +126,8 @@
if (!changed(p1)) {
skipToGroupEnd()
} else {
- block(p1)
+ val realFn = block as Function4<P1, Composer<*>, Int, Int, Unit>
+ realFn(p1, this, 0, 0)
}
endGroup()
}
diff --git a/core/core-ktx/src/main/java/androidx/core/net/Uri.kt b/core/core-ktx/src/main/java/androidx/core/net/Uri.kt
index 2aa1667..b27d072 100644
--- a/core/core-ktx/src/main/java/androidx/core/net/Uri.kt
+++ b/core/core-ktx/src/main/java/androidx/core/net/Uri.kt
@@ -35,7 +35,10 @@
*/
inline fun File.toUri(): Uri = Uri.fromFile(this)
-/** Creates a [File] from the given [Uri]. */
+/**
+ * Creates a [File] from the given [Uri]. Note that this will throw an
+ * [IllegalArgumentException] when invoked on a [Uri] that lacks `file` scheme.
+ */
fun Uri.toFile(): File {
require(scheme == "file") { "Uri lacks 'file' scheme: $this" }
return File(requireNotNull(path) { "Uri path is null: $this" })
diff --git a/core/core/src/main/java/androidx/core/app/ActivityCompat.java b/core/core/src/main/java/androidx/core/app/ActivityCompat.java
index ae5d7ee..432367f 100644
--- a/core/core/src/main/java/androidx/core/app/ActivityCompat.java
+++ b/core/core/src/main/java/androidx/core/app/ActivityCompat.java
@@ -435,6 +435,10 @@
* the signature of the app declaring the permissions.
* </p>
* <p>
+ * Call {@link #shouldShowRequestPermissionRationale(Activity, String)} before calling this API
+ * to check if the system recommends to show a rationale dialog before asking for a permission.
+ * </p>
+ * <p>
* If your app does not have the requested permissions the user will be presented
* with UI for accepting them. After the user has accepted or rejected the
* requested permissions you will receive a callback reporting whether the
@@ -533,21 +537,11 @@
}
/**
- * Gets whether you should show UI with rationale for requesting a permission.
- * You should do this only if you do not have the permission and the context in
- * which the permission is requested does not clearly communicate to the user
- * what would be the benefit from granting this permission.
- * <p>
- * For example, if you write a camera app, requesting the camera permission
- * would be expected by the user and no rationale for why it is requested is
- * needed. If however, the app needs location for tagging photos then a non-tech
- * savvy user may wonder how location is related to taking photos. In this case
- * you may choose to show UI with rationale of requesting this permission.
- * </p>
+ * Gets whether you should show UI with rationale before requesting a permission.
*
* @param activity The target activity.
* @param permission A permission your app wants to request.
- * @return Whether you can show permission rationale UI.
+ * @return Whether you should show permission rationale UI.
*
* @see #checkSelfPermission(android.content.Context, String)
* @see #requestPermissions(android.app.Activity, String[], int)
diff --git a/development/release-notes/AndroidXMarkdown.py b/development/release-notes/AndroidXMarkdown.py
index 332bca9..7c8f450 100644
--- a/development/release-notes/AndroidXMarkdown.py
+++ b/development/release-notes/AndroidXMarkdown.py
@@ -53,10 +53,7 @@
markdownStringSection = markdownStringSection + commitString
if markdownStringSection[-1] != '\n':
markdownStringSection += '\n'
- if markdownStringSection == "":
- markdownStringSection = "\n%s\n\n%s" % (MarkdownComment(sectionHeader), markdownStringSection)
- else:
- markdownStringSection = "\n%s\n\n%s" % (sectionHeader, markdownStringSection)
+ markdownStringSection = "\n%s\n\n%s" % (sectionHeader, markdownStringSection)
return markdownStringSection
def __str__(self):
@@ -152,14 +149,16 @@
raise RuntimeError("Tried to create Library Release Notes Header without setting " +
"the groupId or version!")
if requiresSameVersion:
- shortenedGroupId = groupId.replace("androidx.", "").capitalize()
- self.header = LibraryHeader(shortenedGroupId, version)
+ formattedGroupId = groupId.replace("androidx.", "")
+ formattedGroupId = self.capitalizeTitle(formattedGroupId)
+ self.header = LibraryHeader(formattedGroupId, version)
else:
- forrmattedArtifactIds = (" ".join(artifactIds) + " ").title()
- artifactIdTag = ""
- if len(artifactIds) == 1:
- artifactIdTag = artifactIds[0] + "-"
- self.header = LibraryHeader(forrmattedArtifactIds, version, artifactIdTag)
+ artifactIdTag = artifactIds[0] + "-" if len(artifactIds) == 1 else ""
+ formattedArtifactIds = (" ".join(artifactIds))
+ if len(artifactIds) > 3:
+ formattedArtifactIds = groupId.replace("androidx.", "")
+ formattedArtifactIds = self.capitalizeTitle(formattedArtifactIds)
+ self.header = LibraryHeader(formattedArtifactIds, version, artifactIdTag)
self.diffLogLink = getGitilesDiffLogLink(version, fromSHA, untilSHA, projectDir)
def getFormattedReleaseSummary(self):
@@ -171,15 +170,30 @@
elif numberArtifacts == 2:
if i == 0: self.summary = "`%s:%s:%s` and " % (self.groupId, currentArtifactId, self.version)
if i == 1: self.summary += "`%s:%s:%s` are released. " % (self.groupId, currentArtifactId, self.version)
- else:
+ elif numberArtifacts == 3:
if (i < numberArtifacts - 1):
self.summary += "`%s:%s:%s`, " % (self.groupId, currentArtifactId, self.version)
else:
self.summary += "and `%s:%s:%s` are released. " % (self.groupId, currentArtifactId, self.version)
-
+ else:
+ commonArtifactIdSubstring = self.artifactIds[0].split('-')[0]
+ self.summary = "`%s:%s-*:%s` is released. " % (
+ self.groupId,
+ commonArtifactIdSubstring,
+ self.version
+ )
self.summary += "%s\n" % self.diffLogLink
return self.summary
+ def capitalizeTitle(self, artifactWord):
+ artifactWord = artifactWord.title()
+ keywords = ["Animated", "Animation", "Callback", "Compat", "Drawable", "File", "Layout",
+ "Pager", "Pane", "Parcelable", "Provider", "Refresh", "SQL", "State", "TV",
+ "Target", "View", "Inflater"]
+ for keyword in keywords:
+ artifactWord = artifactWord.replace(keyword.lower(), keyword)
+ return artifactWord
+
def addCommit(self, newCommit):
for bug in newCommit.bugs:
bugsFixed.append(bug)
diff --git a/development/release-notes/generateReleaseNotes.py b/development/release-notes/generateReleaseNotes.py
index e258d79..03eb5d4 100755
--- a/development/release-notes/generateReleaseNotes.py
+++ b/development/release-notes/generateReleaseNotes.py
@@ -159,7 +159,7 @@
if commitB.sha not in commitListAShaSet:
commitListA.append(commitB)
-def commonPathPrefix(pathA, pathB):
+def getCommonPathPrefix(pathA, pathB):
pathAList = pathA.split('/')
pathBList = pathB.split('/')
@@ -235,7 +235,7 @@
)
fromSHA = artifact["fromSHA"]
untilSHA = artifact["untilSHA"]
- groupIdCommonDir = commonPathPrefix(groupIdCommonDir, artifact["path"])
+ groupIdCommonDir = getCommonPathPrefix(groupIdCommonDir, artifact["path"])
for commit in versionGroupCommitList:
if isExcludedAuthorEmail(commit.authorEmail):
versionGroupCommitList.remove(commit)
diff --git a/development/release-notes/testReleaseNotes.py b/development/release-notes/testReleaseNotes.py
index 68db266..ed634c3 100755
--- a/development/release-notes/testReleaseNotes.py
+++ b/development/release-notes/testReleaseNotes.py
@@ -802,6 +802,8 @@
self.assertEqual(releaseNotes.projectDir, "projectDir")
self.assertEqual(releaseNotes.requiresSameVersion, True)
self.assertEqual(releaseNotes.forceIncludeAllCommits, False)
+ self.assertEqual(str(releaseNotes.header),
+ "### Groupid Version version {:#version}")
self.assertEqual(str(releaseNotes.diffLogLink),
"[Version version contains" + \
" these commits.](https://android.googlesource.com/" + \
@@ -809,10 +811,10 @@
)
self.assertEqual(releaseNotes.commits, [])
self.assertEqual(str(releaseNotes.commitMarkdownList),
- "\n{# **New Features** #}\n\n" + \
- "\n{# **API Changes** #}\n\n" + \
- "\n{# **Bug Fixes** #}\n\n" + \
- "\n{# **External Contribution** #}\n\n"
+ "\n**New Features**\n\n" + \
+ "\n**API Changes**\n\n" + \
+ "\n**Bug Fixes**\n\n" + \
+ "\n**External Contribution**\n\n"
)
self.assertEqual(releaseNotes.getFormattedReleaseSummary(),
"`groupId:artifactId:version` is released." + \
@@ -821,6 +823,183 @@
)
self.assertEqual(releaseNotes.bugsFixed, [])
+ def test_markdownCorrectlyFormatsForTwoArtifactsWithFalseRequiresSameVersion(self):
+ releaseNotes = LibraryReleaseNotes(
+ groupId = "groupId",
+ artifactIds = ["artifactId1", "artifactId2"],
+ version = "version",
+ releaseDate = "01-01-1970",
+ fromSHA = "fromSHA",
+ untilSHA = "untilSHA",
+ projectDir = "projectDir",
+ requiresSameVersion = False,
+ commitList = [],
+ forceIncludeAllCommits = False
+ )
+ self.assertEqual(releaseNotes.groupId, "groupId")
+ self.assertEqual(releaseNotes.artifactIds, ["artifactId1", "artifactId2"])
+ self.assertEqual(releaseNotes.version, "version")
+ self.assertEqual(str(releaseNotes.releaseDate), "January 1, 1970")
+ self.assertEqual(releaseNotes.fromSHA, "fromSHA")
+ self.assertEqual(releaseNotes.untilSHA, "untilSHA")
+ self.assertEqual(releaseNotes.projectDir, "projectDir")
+ self.assertEqual(releaseNotes.requiresSameVersion, False)
+ self.assertEqual(releaseNotes.forceIncludeAllCommits, False)
+ self.assertEqual(str(releaseNotes.header),
+ "### Artifactid1 Artifactid2 Version version {:#version}")
+ self.assertEqual(str(releaseNotes.diffLogLink),
+ "[Version version contains" + \
+ " these commits.](https://android.googlesource.com/" + \
+ "platform/frameworks/support/+log/fromSHA..untilSHA/projectDir)"
+ )
+ self.assertEqual(releaseNotes.commits, [])
+ self.assertEqual(str(releaseNotes.commitMarkdownList),
+ "\n**New Features**\n\n" + \
+ "\n**API Changes**\n\n" + \
+ "\n**Bug Fixes**\n\n" + \
+ "\n**External Contribution**\n\n"
+ )
+ self.assertEqual(releaseNotes.getFormattedReleaseSummary(),
+ "`groupId:artifactId1:version` and `groupId:artifactId2:version` are released." + \
+ " [Version version contains these commits.](https://android.googlesource.com/" + \
+ "platform/frameworks/support/+log/fromSHA..untilSHA/projectDir)\n"
+ )
+ self.assertEqual(releaseNotes.bugsFixed, [])
+
+ def test_markdownCorrectlyFormatsForThreeArtifactsWithFalseRequiresSameVersion(self):
+ releaseNotes = LibraryReleaseNotes(
+ groupId = "groupId",
+ artifactIds = ["artifactId1", "artifactId2", "artifactId3"],
+ version = "version",
+ releaseDate = "01-01-1970",
+ fromSHA = "fromSHA",
+ untilSHA = "untilSHA",
+ projectDir = "projectDir",
+ requiresSameVersion = False,
+ commitList = [],
+ forceIncludeAllCommits = False
+ )
+ self.assertEqual(releaseNotes.groupId, "groupId")
+ self.assertEqual(releaseNotes.artifactIds,
+ ["artifactId1", "artifactId2", "artifactId3"])
+ self.assertEqual(releaseNotes.version, "version")
+ self.assertEqual(str(releaseNotes.releaseDate), "January 1, 1970")
+ self.assertEqual(releaseNotes.fromSHA, "fromSHA")
+ self.assertEqual(releaseNotes.untilSHA, "untilSHA")
+ self.assertEqual(releaseNotes.projectDir, "projectDir")
+ self.assertEqual(releaseNotes.requiresSameVersion, False)
+ self.assertEqual(releaseNotes.forceIncludeAllCommits, False)
+ self.assertEqual(str(releaseNotes.header),
+ "### Artifactid1 Artifactid2 Artifactid3 Version version {:#version}")
+ self.assertEqual(str(releaseNotes.diffLogLink),
+ "[Version version contains" + \
+ " these commits.](https://android.googlesource.com/" + \
+ "platform/frameworks/support/+log/fromSHA..untilSHA/projectDir)"
+ )
+ self.assertEqual(releaseNotes.commits, [])
+ self.assertEqual(str(releaseNotes.commitMarkdownList),
+ "\n**New Features**\n\n" + \
+ "\n**API Changes**\n\n" + \
+ "\n**Bug Fixes**\n\n" + \
+ "\n**External Contribution**\n\n"
+ )
+ self.assertEqual(releaseNotes.getFormattedReleaseSummary(),
+ "`groupId:artifactId1:version`, `groupId:artifactId2:version`, and " + \
+ "`groupId:artifactId3:version` are released. " + \
+ "[Version version contains these commits.](https://android.googlesource.com/" + \
+ "platform/frameworks/support/+log/fromSHA..untilSHA/projectDir)\n"
+ )
+ self.assertEqual(releaseNotes.bugsFixed, [])
+
+ def test_markdownCorrectlyFormatsForFiveArtifactsWithFalseRequiresSameVersion(self):
+ releaseNotes = LibraryReleaseNotes(
+ groupId = "groupId",
+ artifactIds = ["artifact-Id1", "artifact-Id2", "artifact-Id3",
+ "artifact-Id4", "artifact-Id5"],
+ version = "version",
+ releaseDate = "01-01-1970",
+ fromSHA = "fromSHA",
+ untilSHA = "untilSHA",
+ projectDir = "projectDir",
+ requiresSameVersion = False,
+ commitList = [],
+ forceIncludeAllCommits = False
+ )
+ self.assertEqual(releaseNotes.groupId, "groupId")
+ self.assertEqual(releaseNotes.artifactIds,
+ ["artifact-Id1", "artifact-Id2", "artifact-Id3",
+ "artifact-Id4", "artifact-Id5"])
+ self.assertEqual(releaseNotes.version, "version")
+ self.assertEqual(str(releaseNotes.releaseDate), "January 1, 1970")
+ self.assertEqual(releaseNotes.fromSHA, "fromSHA")
+ self.assertEqual(releaseNotes.untilSHA, "untilSHA")
+ self.assertEqual(releaseNotes.projectDir, "projectDir")
+ self.assertEqual(releaseNotes.requiresSameVersion, False)
+ self.assertEqual(releaseNotes.forceIncludeAllCommits, False)
+ self.assertEqual(str(releaseNotes.header),
+ "### Groupid Version version {:#version}")
+ self.assertEqual(str(releaseNotes.diffLogLink),
+ "[Version version contains" + \
+ " these commits.](https://android.googlesource.com/" + \
+ "platform/frameworks/support/+log/fromSHA..untilSHA/projectDir)"
+ )
+ self.assertEqual(releaseNotes.commits, [])
+ self.assertEqual(str(releaseNotes.commitMarkdownList),
+ "\n**New Features**\n\n" + \
+ "\n**API Changes**\n\n" + \
+ "\n**Bug Fixes**\n\n" + \
+ "\n**External Contribution**\n\n"
+ )
+ self.assertEqual(releaseNotes.getFormattedReleaseSummary(),
+ "`groupId:artifact-*:version` is released. " + \
+ "[Version version contains these commits.](https://android.googlesource.com/" + \
+ "platform/frameworks/support/+log/fromSHA..untilSHA/projectDir)\n"
+ )
+ self.assertEqual(releaseNotes.bugsFixed, [])
+
+ def test_markdownCorrectlyCapitalizesGroupIds(self):
+ releaseNotes = LibraryReleaseNotes(
+ groupId = "androidx.recyclerview",
+ artifactIds = ["recyclerview"],
+ version = "version",
+ releaseDate = "01-01-1970",
+ fromSHA = "fromSHA",
+ untilSHA = "untilSHA",
+ projectDir = "projectDir",
+ requiresSameVersion = False,
+ commitList = [],
+ forceIncludeAllCommits = False
+ )
+ self.assertEqual(releaseNotes.groupId, "androidx.recyclerview")
+ self.assertEqual(str(releaseNotes.header),
+ "### RecyclerView Version version {:#recyclerview-version}")
+ self.assertEqual(releaseNotes.getFormattedReleaseSummary(),
+ "`androidx.recyclerview:recyclerview:version` is released. " + \
+ "[Version version contains these commits.](https://android.googlesource.com/" + \
+ "platform/frameworks/support/+log/fromSHA..untilSHA/projectDir)\n"
+ )
+
+ releaseNotes = LibraryReleaseNotes(
+ groupId = "androidx.swiperefreshlayout",
+ artifactIds = ["swiperefreshlayout"],
+ version = "version",
+ releaseDate = "01-01-1970",
+ fromSHA = "fromSHA",
+ untilSHA = "untilSHA",
+ projectDir = "projectDir",
+ requiresSameVersion = True,
+ commitList = [],
+ forceIncludeAllCommits = False
+ )
+ self.assertEqual(releaseNotes.groupId, "androidx.swiperefreshlayout")
+ self.assertEqual(str(releaseNotes.header),
+ "### SwipeRefreshLayout Version version {:#version}")
+ self.assertEqual(releaseNotes.getFormattedReleaseSummary(),
+ "`androidx.swiperefreshlayout:swiperefreshlayout:version` is released. " + \
+ "[Version version contains these commits.](https://android.googlesource.com/" + \
+ "platform/frameworks/support/+log/fromSHA..untilSHA/projectDir)\n"
+ )
+
def test_markdownCorrectlyFormatsGittilesLinkWithNoFromSHA(self):
releaseNotes = LibraryReleaseNotes(
groupId = "groupId",
diff --git a/fragment/fragment-lint/src/main/java/androidx/fragment/lint/UseRequireInsteadOfGet.kt b/fragment/fragment-lint/src/main/java/androidx/fragment/lint/UseRequireInsteadOfGet.kt
index 9650efa..6d6c558 100644
--- a/fragment/fragment-lint/src/main/java/androidx/fragment/lint/UseRequireInsteadOfGet.kt
+++ b/fragment/fragment-lint/src/main/java/androidx/fragment/lint/UseRequireInsteadOfGet.kt
@@ -161,11 +161,17 @@
// We're a double-bang expression (!!)
val parentSourceToReplace =
nearestNonQualifiedReferenceParent.asSourceString()
- val correctMethod = correctMethod(
+ var correctMethod = correctMethod(
parentSourceToReplace,
"$targetExpression!!",
targetMethodName
)
+ if (correctMethod == parentSourceToReplace) {
+ correctMethod = parentSourceToReplace.replace(
+ "$targetExpression?",
+ "$targetExpression!!"
+ ).replaceFirstOccurrenceAfter("!!", "", "$targetExpression!!")
+ }
report(nearestNonQualifiedReferenceParent, parentSourceToReplace, correctMethod)
} else if (nearestNonQualifiedReferenceParent is UCallExpression) {
// See if we're in a "requireNotNull(...)" or similar expression
@@ -219,6 +225,13 @@
)
}
+ // Replaces the first occurrence of a substring after given String
+ private fun String.replaceFirstOccurrenceAfter(
+ oldValue: String,
+ newValue: String,
+ prefix: String
+ ): String = prefix + substringAfter(prefix).replaceFirst(oldValue, newValue)
+
private fun report(node: UElement, targetExpression: String, correctMethod: String) {
context.report(
ISSUE,
diff --git a/fragment/fragment-lint/src/test/java/androidx/fragment/lint/UseRequireInsteadOfGetTest.kt b/fragment/fragment-lint/src/test/java/androidx/fragment/lint/UseRequireInsteadOfGetTest.kt
index 7752398..9774b63 100644
--- a/fragment/fragment-lint/src/test/java/androidx/fragment/lint/UseRequireInsteadOfGetTest.kt
+++ b/fragment/fragment-lint/src/test/java/androidx/fragment/lint/UseRequireInsteadOfGetTest.kt
@@ -48,12 +48,15 @@
public void getHost() {
}
- public void getParentFragment() {
+ public Fragment getParentFragment() {
}
public void getView() {
}
+ public void requireView() {
+
+ }
}
"""
).indented()
@@ -656,6 +659,86 @@
}
@Test
+ fun `kotlin get then require`() {
+ // Note we don't import a preconditions stub here because we use kotlin's built-in
+ useRequireLint()
+ .files(
+ fragmentStub,
+ kotlin(
+ """
+ package foo
+
+ import androidx.fragment.app.Fragment
+
+ class Test : Fragment() {
+ fun test() {
+ parentFragment?.requireView()!!
+ }
+ }
+ """
+ ).indented()
+ )
+ .allowCompilationErrors(false)
+ .run()
+ .expect(
+ """
+ src/foo/Test.kt:7: Error: Use parentFragment!!.requireView() instead of parentFragment?.requireView()!! [UseRequireInsteadOfGet]
+ parentFragment?.requireView()!!
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ 1 errors, 0 warnings
+ """.trimIndent()
+ )
+ .expectFixDiffs(
+ """
+ Fix for src/foo/Test.kt line 7: Replace with parentFragment!!.requireView():
+ @@ -7 +7
+ - parentFragment?.requireView()!!
+ + parentFragment!!.requireView()
+ """.trimIndent()
+ )
+ }
+
+ @Test
+ fun `simple kotlin get non null with require`() {
+ // Note we don't import a preconditions stub here because we use kotlin's built-in
+ useRequireLint()
+ .files(
+ fragmentStub,
+ kotlin(
+ """
+ package foo
+
+ import androidx.fragment.app.Fragment
+
+ class Test : Fragment() {
+ fun test() {
+ parentFragment!!.requireView()
+ }
+ }
+ """
+ ).indented()
+ )
+ .allowCompilationErrors(false)
+ .run()
+ .expect(
+ """
+ src/foo/Test.kt:7: Error: Use requireParentFragment() instead of parentFragment!! [UseRequireInsteadOfGet]
+ parentFragment!!.requireView()
+ ~~~~~~~~~~~~~~~~
+ 1 errors, 0 warnings
+ """.trimIndent()
+ )
+ .expectFixDiffs(
+ """
+ Fix for src/foo/Test.kt line 7: Replace with requireParentFragment():
+ @@ -7 +7
+ - parentFragment!!.requireView()
+ + requireParentFragment().requireView()
+ """.trimIndent()
+ )
+ }
+
+ @Test
fun `simple kotlin checks where the code is in a fragment`() {
// Note we don't import a preconditions stub here because we use kotlin's built-in
useRequireLint()
diff --git a/fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentTestUtil.kt b/fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentTestUtil.kt
index 6490a091..1fa9530 100644
--- a/fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentTestUtil.kt
+++ b/fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentTestUtil.kt
@@ -108,27 +108,47 @@
return activity.findViewById(R.id.redSquare)
}
-fun verifyAndClearTransition(
- transition: TargetTracking,
- epicenter: Rect?,
- vararg expected: View
-) {
- if (epicenter == null) {
- assertThat(transition.capturedEpicenter).isNull()
- } else {
- assertThat(transition.capturedEpicenter).isEqualTo(epicenter)
+val View.boundsOnScreen: Rect
+ get() {
+ val loc = IntArray(2)
+ getLocationOnScreen(loc)
+ return Rect(loc[0], loc[1], loc[0] + width, loc[1] + height)
}
- assertThat(transition.trackedTargets).containsExactlyElementsIn(expected)
- transition.clearTargets()
+
+data class TransitionVerificationInfo(
+ var epicenter: Rect? = null,
+ val exitingViews: MutableList<View> = mutableListOf(),
+ val enteringViews: MutableList<View> = mutableListOf()
+)
+
+fun TargetTracking.verifyAndClearTransition(block: TransitionVerificationInfo.() -> Unit) {
+ val (epicenter, exitingViews, enteringViews) = TransitionVerificationInfo().apply { block() }
+
+ assertThat(exitingTargets).containsExactlyElementsIn(exitingViews)
+ assertThat(enteringTargets).containsExactlyElementsIn(enteringViews)
+ if (epicenter == null) {
+ assertThat(capturedEpicenter).isNull()
+ } else {
+ assertThat(capturedEpicenter).isEqualTo(epicenter)
+ }
+ clearTargets()
}
fun verifyNoOtherTransitions(fragment: TransitionFragment) {
- assertThat(fragment.enterTransition.targets.size).isEqualTo(0)
- assertThat(fragment.exitTransition.targets.size).isEqualTo(0)
- assertThat(fragment.reenterTransition.targets.size).isEqualTo(0)
- assertThat(fragment.returnTransition.targets.size).isEqualTo(0)
- assertThat(fragment.sharedElementEnter.targets.size).isEqualTo(0)
- assertThat(fragment.sharedElementReturn.targets.size).isEqualTo(0)
+ assertThat(fragment.enterTransition.enteringTargets.size).isEqualTo(0)
+ assertThat(fragment.enterTransition.exitingTargets.size).isEqualTo(0)
+ assertThat(fragment.exitTransition.enteringTargets.size).isEqualTo(0)
+ assertThat(fragment.exitTransition.exitingTargets.size).isEqualTo(0)
+
+ assertThat(fragment.reenterTransition.enteringTargets.size).isEqualTo(0)
+ assertThat(fragment.reenterTransition.exitingTargets.size).isEqualTo(0)
+ assertThat(fragment.returnTransition.enteringTargets.size).isEqualTo(0)
+ assertThat(fragment.returnTransition.exitingTargets.size).isEqualTo(0)
+
+ assertThat(fragment.sharedElementEnter.enteringTargets.size).isEqualTo(0)
+ assertThat(fragment.sharedElementEnter.exitingTargets.size).isEqualTo(0)
+ assertThat(fragment.sharedElementReturn.enteringTargets.size).isEqualTo(0)
+ assertThat(fragment.sharedElementReturn.exitingTargets.size).isEqualTo(0)
}
// Transition test methods end
diff --git a/fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentTransitionAnimTest.kt b/fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentTransitionAnimTest.kt
index afb9423..eba4c38e 100644
--- a/fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentTransitionAnimTest.kt
+++ b/fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentTransitionAnimTest.kt
@@ -75,7 +75,9 @@
val blue = withActivity { findViewById<View>(R.id.blueSquare) }
val green = withActivity { findViewById<View>(R.id.greenSquare) }
- verifyAndClearTransition(fragment.enterTransition, null, blue, green)
+ fragment.enterTransition.verifyAndClearTransition {
+ enteringViews += listOf(blue, green)
+ }
verifyNoOtherTransitions(fragment)
val changeBoundsExitTransition = ChangeBounds().apply {
@@ -126,7 +128,9 @@
val blue = withActivity { findViewById<View>(R.id.blueSquare) }
val green = withActivity { findViewById<View>(R.id.greenSquare) }
- verifyAndClearTransition(fragment.enterTransition, null, blue, green)
+ fragment.enterTransition.verifyAndClearTransition {
+ enteringViews += listOf(blue, green)
+ }
verifyNoOtherTransitions(fragment)
val changeBoundsExitTransition = ChangeBounds().apply {
@@ -177,7 +181,9 @@
val blue = withActivity { findViewById<View>(R.id.blueSquare) }
val green = withActivity { findViewById<View>(R.id.greenSquare) }
- verifyAndClearTransition(fragment.enterTransition, null, blue, green)
+ fragment.enterTransition.verifyAndClearTransition {
+ enteringViews += listOf(blue, green)
+ }
verifyNoOtherTransitions(fragment)
val changeBoundsExitTransition = ChangeBounds().apply {
@@ -227,7 +233,9 @@
val blue = withActivity { findViewById<View>(R.id.blueSquare) }
val green = withActivity { findViewById<View>(R.id.greenSquare) }
- verifyAndClearTransition(fragment.enterTransition, null, blue, green)
+ fragment.enterTransition.verifyAndClearTransition {
+ enteringViews += listOf(blue, green)
+ }
verifyNoOtherTransitions(fragment)
val changeBoundsExitTransition = ChangeBounds().apply {
diff --git a/fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentTransitionTest.kt b/fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentTransitionTest.kt
index 01fa0cf..b2aefc3 100644
--- a/fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentTransitionTest.kt
+++ b/fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentTransitionTest.kt
@@ -89,7 +89,9 @@
.commit()
fragment.waitForTransition()
- verifyAndClearTransition(fragment.exitTransition, null, green, blue)
+ fragment.exitTransition.verifyAndClearTransition {
+ exitingViews += listOf(green, blue)
+ }
verifyNoOtherTransitions(fragment)
assertThat(onBackStackChangedTimes).isEqualTo(2)
@@ -98,14 +100,18 @@
fragment.waitForTransition()
val green2 = activityRule.findGreen()
val blue2 = activityRule.findBlue()
- verifyAndClearTransition(fragment.reenterTransition, null, green2, blue2)
+ fragment.reenterTransition.verifyAndClearTransition {
+ enteringViews += listOf(green2, blue2)
+ }
verifyNoOtherTransitions(fragment)
assertThat(onBackStackChangedTimes).isEqualTo(3)
// return transition
activityRule.popBackStackImmediate()
fragment.waitForTransition()
- verifyAndClearTransition(fragment.returnTransition, null, green2, blue2)
+ fragment.returnTransition.verifyAndClearTransition {
+ exitingViews += listOf(green2, blue2)
+ }
verifyNoOtherTransitions(fragment)
assertThat(onBackStackChangedTimes).isEqualTo(4)
}
@@ -146,7 +152,9 @@
// If reorder is not allowed we will get the exit Transition and the fragment will be
// added with a different view.
fragment.waitForTransition()
- verifyAndClearTransition(fragment.exitTransition, null, green, blue)
+ fragment.exitTransition.verifyAndClearTransition {
+ exitingViews += listOf(green, blue)
+ }
assertThat(onBackStackChangedTimes).isEqualTo(3)
assertThat(fragment.requireView()).isNotEqualTo(view1)
}
@@ -167,7 +175,9 @@
fragment.waitForTransition()
val blueSquare1 = activityRule.findBlue()
val greenSquare1 = activityRule.findGreen()
- verifyAndClearTransition(fragment.enterTransition, null, blueSquare1, greenSquare1)
+ fragment.enterTransition.verifyAndClearTransition {
+ enteringViews += listOf(blueSquare1, greenSquare1)
+ }
verifyNoOtherTransitions(fragment)
// Ensure that our countdown latch has been reset for the Fragment
@@ -262,8 +272,12 @@
fragment2.waitForTransition()
val endBlue = activityRule.findBlue()
val endGreen = activityRule.findGreen()
- verifyAndClearTransition(fragment1.exitTransition, null, startBlue, startGreen)
- verifyAndClearTransition(fragment2.enterTransition, null, endBlue, endGreen)
+ fragment1.exitTransition.verifyAndClearTransition {
+ exitingViews += listOf(startBlue, startGreen)
+ }
+ fragment2.enterTransition.verifyAndClearTransition {
+ enteringViews += listOf(endBlue, endGreen)
+ }
verifyNoOtherTransitions(fragment1)
verifyNoOtherTransitions(fragment2)
@@ -275,8 +289,12 @@
fragment2.waitForTransition()
val popBlue = activityRule.findBlue()
val popGreen = activityRule.findGreen()
- verifyAndClearTransition(fragment1.reenterTransition, null, popBlue, popGreen)
- verifyAndClearTransition(fragment2.returnTransition, null, endBlue, endGreen)
+ fragment1.reenterTransition.verifyAndClearTransition {
+ enteringViews += listOf(popBlue, popGreen)
+ }
+ fragment2.returnTransition.verifyAndClearTransition {
+ exitingViews += listOf(endBlue, endGreen)
+ }
verifyNoOtherTransitions(fragment1)
verifyNoOtherTransitions(fragment2)
}
@@ -299,12 +317,16 @@
fragment1.waitForTransition()
val greenSquare1 = findViewById(fragment1, R.id.greenSquare)
val blueSquare1 = findViewById(fragment1, R.id.blueSquare)
- verifyAndClearTransition(fragment1.enterTransition, null, greenSquare1, blueSquare1)
+ fragment1.enterTransition.verifyAndClearTransition {
+ enteringViews += listOf(greenSquare1, blueSquare1)
+ }
verifyNoOtherTransitions(fragment1)
fragment2.waitForTransition()
val greenSquare2 = findViewById(fragment2, R.id.greenSquare)
val blueSquare2 = findViewById(fragment2, R.id.blueSquare)
- verifyAndClearTransition(fragment2.enterTransition, null, greenSquare2, blueSquare2)
+ fragment2.enterTransition.verifyAndClearTransition {
+ enteringViews += listOf(greenSquare2, blueSquare2)
+ }
verifyNoOtherTransitions(fragment2)
// Make sure the correct transitions are run when the target names
@@ -395,7 +417,7 @@
val startBlue = activityRule.findBlue()
val startGreen = activityRule.findGreen()
- val startGreenBounds = getBoundsOnScreen(startGreen)
+ val startGreenBounds = startGreen.boundsOnScreen
val mapOut = object : SharedElementCallback() {
override fun onMapSharedElements(
@@ -423,12 +445,13 @@
fragment2.waitForTransition()
val endBlue = activityRule.findBlue()
- val endBlueBounds = getBoundsOnScreen(endBlue)
+ val endBlueBounds = endBlue.boundsOnScreen
- verifyAndClearTransition(
- fragment2.sharedElementEnter, startGreenBounds, startGreen,
- endBlue
- )
+ fragment2.sharedElementEnter.verifyAndClearTransition {
+ epicenter = startGreenBounds
+ exitingViews += startGreen
+ enteringViews += endBlue
+ }
val mapBack = object : SharedElementCallback() {
override fun onMapSharedElements(
@@ -452,10 +475,11 @@
fragment2.waitForTransition()
val reenterGreen = activityRule.findGreen()
- verifyAndClearTransition(
- fragment2.sharedElementReturn, endBlueBounds, endBlue,
- reenterGreen
- )
+ fragment2.sharedElementReturn.verifyAndClearTransition {
+ epicenter = endBlueBounds
+ exitingViews += endBlue
+ enteringViews += reenterGreen
+ }
}
// Make sure that onMapSharedElement works to change the shared element target
@@ -467,7 +491,7 @@
val fragment2 = TransitionFragment(R.layout.scene2)
val startBlue = activityRule.findBlue()
- val startBlueBounds = getBoundsOnScreen(startBlue)
+ val startBlueBounds = startBlue.boundsOnScreen
val mapIn = object : SharedElementCallback() {
override fun onMapSharedElements(
@@ -498,12 +522,13 @@
val endGreen = activityRule.findGreen()
val endBlue = activityRule.findBlue()
- val endGreenBounds = getBoundsOnScreen(endGreen)
+ val endGreenBounds = endGreen.boundsOnScreen
- verifyAndClearTransition(
- fragment2.sharedElementEnter, startBlueBounds, startBlue,
- endGreen
- )
+ fragment2.sharedElementEnter.verifyAndClearTransition {
+ epicenter = startBlueBounds
+ exitingViews += startBlue
+ enteringViews += endGreen
+ }
val mapBack = object : SharedElementCallback() {
override fun onMapSharedElements(
@@ -525,10 +550,11 @@
fragment2.waitForTransition()
val reenterBlue = activityRule.findBlue()
- verifyAndClearTransition(
- fragment2.sharedElementReturn, endGreenBounds, endGreen,
- reenterBlue
- )
+ fragment2.sharedElementReturn.verifyAndClearTransition {
+ epicenter = endGreenBounds
+ exitingViews += endGreen
+ enteringViews += reenterBlue
+ }
}
// Ensure that shared element transitions that have targets properly target the views
@@ -541,7 +567,7 @@
val startBlue = activityRule.findBlue()
val startGreen = activityRule.findGreen()
- val startBlueBounds = getBoundsOnScreen(startBlue)
+ val startBlueBounds = startBlue.boundsOnScreen
fragmentManager.beginTransaction()
.addSharedElement(startBlue, "blueSquare")
@@ -558,16 +584,18 @@
val endBlue = activityRule.findBlue()
val endGreen = activityRule.findGreen()
- val endBlueBounds = getBoundsOnScreen(endBlue)
+ val endBlueBounds = endBlue.boundsOnScreen
- verifyAndClearTransition(
- fragment2.sharedElementEnterTransition1, startBlueBounds,
- startBlue, endBlue
- )
- verifyAndClearTransition(
- fragment2.sharedElementEnterTransition2, startBlueBounds,
- startGreen, endGreen
- )
+ fragment2.sharedElementEnterTransition1.verifyAndClearTransition {
+ epicenter = startBlueBounds
+ exitingViews += startBlue
+ enteringViews += endBlue
+ }
+ fragment2.sharedElementEnterTransition2.verifyAndClearTransition {
+ epicenter = startBlueBounds
+ exitingViews += startGreen
+ enteringViews += endGreen
+ }
// Now see if it works when popped
activityRule.popBackStackImmediate()
@@ -579,14 +607,16 @@
val reenterBlue = activityRule.findBlue()
val reenterGreen = activityRule.findGreen()
- verifyAndClearTransition(
- fragment2.sharedElementReturnTransition1, endBlueBounds,
- endBlue, reenterBlue
- )
- verifyAndClearTransition(
- fragment2.sharedElementReturnTransition2, endBlueBounds,
- endGreen, reenterGreen
- )
+ fragment2.sharedElementReturnTransition1.verifyAndClearTransition {
+ epicenter = endBlueBounds
+ exitingViews += endBlue
+ enteringViews += reenterBlue
+ }
+ fragment2.sharedElementReturnTransition2.verifyAndClearTransition {
+ epicenter = endBlueBounds
+ exitingViews += endGreen
+ enteringViews += reenterGreen
+ }
}
// Ensure that after transitions have executed that they don't have any targets or other
@@ -599,9 +629,9 @@
val fragment2 = TransitionFragment(R.layout.scene2)
verifyTransition(fragment1, fragment2, "blueSquare")
- assertThat(fragment1.exitTransition.getTargets().size).isEqualTo(0)
- assertThat(fragment2.sharedElementEnter.getTargets().size).isEqualTo(0)
- assertThat(fragment2.enterTransition.getTargets().size).isEqualTo(0)
+ assertThat(fragment1.exitTransition.targets).isEmpty()
+ assertThat(fragment2.sharedElementEnter.targets).isEmpty()
+ assertThat(fragment2.enterTransition.targets).isEmpty()
assertThat(fragment1.exitTransition.epicenterCallback).isNull()
assertThat(fragment2.enterTransition.epicenterCallback).isNull()
assertThat(fragment2.sharedElementEnter.epicenterCallback).isNull()
@@ -609,9 +639,9 @@
// Now pop the back stack
verifyPopTransition(1, fragment2, fragment1)
- assertThat(fragment2.returnTransition.getTargets().size).isEqualTo(0)
- assertThat(fragment2.sharedElementReturn.getTargets().size).isEqualTo(0)
- assertThat(fragment1.reenterTransition.getTargets().size).isEqualTo(0)
+ assertThat(fragment2.returnTransition.targets).isEmpty()
+ assertThat(fragment2.sharedElementReturn.targets).isEmpty()
+ assertThat(fragment1.reenterTransition.targets).isEmpty()
assertThat(fragment2.returnTransition.epicenterCallback).isNull()
assertThat(fragment2.sharedElementReturn.epicenterCallback).isNull()
assertThat(fragment2.reenterTransition.epicenterCallback).isNull()
@@ -654,10 +684,14 @@
assertThat(startGreen.visibility).isEqualTo(View.VISIBLE)
assertThat(startBlue.visibility).isEqualTo(View.VISIBLE)
- verifyAndClearTransition(fragment1.exitTransition, null, startGreen, startBlue)
+ fragment1.exitTransition.verifyAndClearTransition {
+ exitingViews += listOf(startGreen, startBlue)
+ }
verifyNoOtherTransitions(fragment1)
- verifyAndClearTransition(fragment2.enterTransition, null, endGreen, endBlue)
+ fragment2.enterTransition.verifyAndClearTransition {
+ enteringViews += listOf(endGreen, endBlue)
+ }
verifyNoOtherTransitions(fragment2)
activityRule.popBackStackImmediate()
@@ -666,14 +700,18 @@
fragment1.waitForTransition()
fragment2.waitForTransition()
- verifyAndClearTransition(fragment1.reenterTransition, null, startGreen, startBlue)
+ fragment1.reenterTransition.verifyAndClearTransition {
+ enteringViews += listOf(startGreen, startBlue)
+ }
verifyNoOtherTransitions(fragment1)
assertThat(fragment1.requireView().visibility).isEqualTo(View.VISIBLE)
assertThat(startGreen.visibility).isEqualTo(View.VISIBLE)
assertThat(startBlue.visibility).isEqualTo(View.VISIBLE)
- verifyAndClearTransition(fragment2.returnTransition, null, endGreen, endBlue)
+ fragment2.returnTransition.verifyAndClearTransition {
+ exitingViews += listOf(endGreen, endBlue)
+ }
verifyNoOtherTransitions(fragment2)
}
@@ -698,10 +736,14 @@
val endGreen = findViewById(fragment2, R.id.greenSquare)
val endBlue = findViewById(fragment2, R.id.blueSquare)
- verifyAndClearTransition(fragment1.exitTransition, null, startGreen, startBlue)
+ fragment1.exitTransition.verifyAndClearTransition {
+ exitingViews += listOf(startGreen, startBlue)
+ }
verifyNoOtherTransitions(fragment1)
- verifyAndClearTransition(fragment2.enterTransition, null, endGreen, endBlue)
+ fragment2.enterTransition.verifyAndClearTransition {
+ enteringViews += listOf(endGreen, endBlue)
+ }
verifyNoOtherTransitions(fragment2)
activityRule.popBackStackImmediate()
@@ -711,10 +753,14 @@
val reenterBlue = activityRule.findBlue()
val reenterGreen = activityRule.findGreen()
- verifyAndClearTransition(fragment1.reenterTransition, null, reenterGreen, reenterBlue)
+ fragment1.reenterTransition.verifyAndClearTransition {
+ enteringViews += listOf(reenterGreen, reenterBlue)
+ }
verifyNoOtherTransitions(fragment1)
- verifyAndClearTransition(fragment2.returnTransition, null, endGreen, endBlue)
+ fragment2.returnTransition.verifyAndClearTransition {
+ exitingViews += listOf(endGreen, endBlue)
+ }
verifyNoOtherTransitions(fragment2)
}
@@ -728,7 +774,7 @@
val startBlue = activityRule.findBlue()
val startGreen = activityRule.findGreen()
- val startBlueBounds = getBoundsOnScreen(startBlue)
+ val startBlueBounds = startBlue.boundsOnScreen
fragmentManager.beginTransaction()
.addSharedElement(startBlue, "fooSquare")
@@ -745,14 +791,24 @@
val endGreen = activityRule.findGreen()
if (reorderingAllowed) {
- verifyAndClearTransition(fragment1.exitTransition, null, startGreen, startBlue)
+ fragment1.exitTransition.verifyAndClearTransition {
+ exitingViews += listOf(startGreen, startBlue)
+ }
} else {
- verifyAndClearTransition(fragment1.exitTransition, startBlueBounds, startGreen)
- verifyAndClearTransition(fragment2.sharedElementEnter, startBlueBounds, startBlue)
+ fragment1.exitTransition.verifyAndClearTransition {
+ epicenter = startBlueBounds
+ exitingViews += startGreen
+ }
+ fragment2.sharedElementEnter.verifyAndClearTransition {
+ epicenter = startBlueBounds
+ exitingViews += startBlue
+ }
}
verifyNoOtherTransitions(fragment1)
- verifyAndClearTransition(fragment2.enterTransition, null, endGreen, endBlue)
+ fragment2.enterTransition.verifyAndClearTransition {
+ enteringViews += listOf(endGreen, endBlue)
+ }
verifyNoOtherTransitions(fragment2)
}
@@ -830,7 +886,7 @@
val startBlue = activityRule.findBlue()
val startGreen = activityRule.findGreen()
- val startBlueBounds = getBoundsOnScreen(startBlue)
+ val startBlueBounds = startBlue.boundsOnScreen
val fragment2 = TransitionFragment(R.layout.scene2)
@@ -845,10 +901,20 @@
fragment2.waitForTransition()
val midGreen = activityRule.findGreen()
val midBlue = activityRule.findBlue()
- val midBlueBounds = getBoundsOnScreen(midBlue)
- verifyAndClearTransition(fragment1.exitTransition, startBlueBounds, startGreen)
- verifyAndClearTransition(fragment2.sharedElementEnter, startBlueBounds, startBlue, midBlue)
- verifyAndClearTransition(fragment2.enterTransition, midBlueBounds, midGreen)
+ val midBlueBounds = midBlue.boundsOnScreen
+ fragment1.exitTransition.verifyAndClearTransition {
+ epicenter = startBlueBounds
+ exitingViews += startGreen
+ }
+ fragment2.sharedElementEnter.verifyAndClearTransition {
+ epicenter = startBlueBounds
+ exitingViews += startBlue
+ enteringViews += midBlue
+ }
+ fragment2.enterTransition.verifyAndClearTransition {
+ epicenter = midBlueBounds
+ enteringViews += midGreen
+ }
verifyNoOtherTransitions(fragment1)
verifyNoOtherTransitions(fragment2)
@@ -872,11 +938,15 @@
if (reorderingAllowed) {
// reordering allowed fragment3 to get a transition so we should wait for it to finish
fragment3.waitForTransition()
- verifyAndClearTransition(fragment2.returnTransition, null, midGreen, midBlue)
+ fragment2.returnTransition.verifyAndClearTransition {
+ exitingViews += listOf(midGreen, midBlue)
+ }
val endGreen = activityRule.findGreen()
val endBlue = activityRule.findBlue()
val endRed = activityRule.findRed()
- verifyAndClearTransition(fragment3.enterTransition, null, endGreen, endBlue, endRed!!)
+ fragment3.enterTransition.verifyAndClearTransition {
+ enteringViews += listOfNotNull(endGreen, endBlue, endRed)
+ }
verifyNoOtherTransitions(fragment2)
verifyNoOtherTransitions(fragment3)
} else {
@@ -897,7 +967,7 @@
val startBlue = activityRule.findBlue()
val startGreen = activityRule.findGreen()
- val startGreenBounds = getBoundsOnScreen(startGreen)
+ val startGreenBounds = startGreen.boundsOnScreen
val fragment2 = TransitionFragment(R.layout.scene2)
@@ -918,11 +988,21 @@
// It does not transition properly for ordered transactions, though.
if (reorderingAllowed) {
- verifyAndClearTransition(fragment1.returnTransition, null, startGreen)
+ fragment1.returnTransition.verifyAndClearTransition {
+ exitingViews += startGreen
+ }
val endGreen = activityRule.findGreen()
- verifyAndClearTransition(fragment2.enterTransition, startGreenBounds, endGreen)
- assertThat(fragment2.sharedElementEnter.targets.size).isEqualTo(2)
- fragment2.sharedElementEnter.clearTargets()
+ val endBlue = activityRule.findBlue()
+ fragment2.enterTransition.verifyAndClearTransition {
+ epicenter = startGreenBounds
+ enteringViews += endGreen
+ }
+ fragment2.sharedElementEnter.verifyAndClearTransition {
+ // In this case, we can't find an epicenter
+ epicenter = Rect()
+ exitingViews += startBlue
+ enteringViews += endBlue
+ }
verifyNoOtherTransitions(fragment1)
verifyNoOtherTransitions(fragment2)
} else {
@@ -940,7 +1020,7 @@
val startBlue = activityRule.findBlue()
val startGreen = activityRule.findGreen()
- val startGreenBounds = getBoundsOnScreen(startGreen)
+ val startGreenBounds = startGreen.boundsOnScreen
val fragment2 = TransitionFragment(R.layout.scene3)
@@ -956,19 +1036,24 @@
val midGreen = activityRule.findGreen()
val midBlue = activityRule.findBlue()
val midRed = activityRule.findRed()
- val midGreenBounds = getBoundsOnScreen(midGreen)
+ val midGreenBounds = midGreen.boundsOnScreen
if (reorderingAllowed) {
- verifyAndClearTransition(
- fragment2.sharedElementEnter, startGreenBounds, startGreen,
- midGreen
- )
+ fragment2.sharedElementEnter.verifyAndClearTransition {
+ epicenter = startGreenBounds
+ exitingViews += startGreen
+ enteringViews += midGreen
+ }
} else {
- verifyAndClearTransition(
- fragment2.sharedElementEnter, startGreenBounds, startGreen,
- midGreen, startBlue
- )
+ fragment2.sharedElementEnter.verifyAndClearTransition {
+ epicenter = startGreenBounds
+ exitingViews += listOf(startGreen, startBlue)
+ enteringViews += midGreen
+ }
}
- verifyAndClearTransition(fragment2.enterTransition, midGreenBounds, midBlue, midRed!!)
+ fragment2.enterTransition.verifyAndClearTransition {
+ epicenter = midGreenBounds
+ enteringViews += listOfNotNull(midBlue, midRed)
+ }
verifyNoOtherTransitions(fragment2)
activityRule.popBackStackImmediate()
@@ -994,7 +1079,9 @@
fragment1.waitForTransition()
val blueSquare1 = activityRule.findBlue()
val greenSquare1 = activityRule.findGreen()
- verifyAndClearTransition(fragment1.enterTransition, null, blueSquare1, greenSquare1)
+ fragment1.enterTransition.verifyAndClearTransition {
+ enteringViews += listOf(blueSquare1, greenSquare1)
+ }
verifyNoOtherTransitions(fragment1)
return fragment1
}
@@ -1013,7 +1100,7 @@
val startGreen = activityRule.findGreen()
val startRed = activityRule.findRed()
- val startBlueRect = getBoundsOnScreen(startBlue)
+ val startBlueRect = startBlue.boundsOnScreen
fragmentManager.beginTransaction()
.setReorderingAllowed(reorderingAllowed)
@@ -1029,21 +1116,24 @@
val endGreen = activityRule.findGreen()
val endBlue = activityRule.findBlue()
val endRed = activityRule.findRed()
- val endBlueRect = getBoundsOnScreen(endBlue)
+ val endBlueRect = endBlue.boundsOnScreen
- if (startRed != null) {
- verifyAndClearTransition(from.exitTransition, startBlueRect, startGreen, startRed)
- } else {
- verifyAndClearTransition(from.exitTransition, startBlueRect, startGreen)
+ from.exitTransition.verifyAndClearTransition {
+ epicenter = startBlueRect
+ exitingViews += listOfNotNull(startGreen, startRed)
}
verifyNoOtherTransitions(from)
- if (endRed != null) {
- verifyAndClearTransition(to.enterTransition, endBlueRect, endGreen, endRed)
- } else {
- verifyAndClearTransition(to.enterTransition, endBlueRect, endGreen)
+ to.enterTransition.verifyAndClearTransition {
+ epicenter = endBlueRect
+ enteringViews += listOfNotNull(endGreen, endRed)
}
- verifyAndClearTransition(to.sharedElementEnter, startBlueRect, startBlue, endBlue)
+
+ to.sharedElementEnter.verifyAndClearTransition {
+ epicenter = startBlueRect
+ exitingViews += startBlue
+ enteringViews += endBlue
+ }
verifyNoOtherTransitions(to)
}
@@ -1060,13 +1150,13 @@
val fromExit1 = findViewById(from1, R.id.greenSquare)
val fromShared1 = findViewById(from1, R.id.blueSquare)
- val fromSharedRect1 = getBoundsOnScreen(fromShared1)
+ val fromSharedRect1 = fromShared1.boundsOnScreen
val fromExitId2 = if (swapSource) R.id.blueSquare else R.id.greenSquare
val fromSharedId2 = if (swapSource) R.id.greenSquare else R.id.blueSquare
val fromExit2 = findViewById(from2, fromExitId2)
val fromShared2 = findViewById(from2, fromSharedId2)
- val fromSharedRect2 = getBoundsOnScreen(fromShared2)
+ val fromSharedRect2 = fromShared2.boundsOnScreen
val sharedElementName = if (swapSource) "blueSquare" else "greenSquare"
@@ -1095,21 +1185,41 @@
val toEnter1 = findViewById(to1, R.id.greenSquare)
val toShared1 = findViewById(to1, R.id.blueSquare)
- val toSharedRect1 = getBoundsOnScreen(toShared1)
+ val toSharedRect1 = toShared1.boundsOnScreen
val toEnter2 = findViewById(to2, fromSharedId2)
val toShared2 = findViewById(to2, fromExitId2)
- val toSharedRect2 = getBoundsOnScreen(toShared2)
+ val toSharedRect2 = toShared2.boundsOnScreen
- verifyAndClearTransition(from1.exitTransition, fromSharedRect1, fromExit1)
- verifyAndClearTransition(from2.exitTransition, fromSharedRect2, fromExit2)
+ from1.exitTransition.verifyAndClearTransition {
+ epicenter = fromSharedRect1
+ exitingViews += fromExit1
+ }
+ from2.exitTransition.verifyAndClearTransition {
+ epicenter = fromSharedRect2
+ exitingViews += fromExit2
+ }
verifyNoOtherTransitions(from1)
verifyNoOtherTransitions(from2)
- verifyAndClearTransition(to1.enterTransition, toSharedRect1, toEnter1)
- verifyAndClearTransition(to2.enterTransition, toSharedRect2, toEnter2)
- verifyAndClearTransition(to1.sharedElementEnter, fromSharedRect1, fromShared1, toShared1)
- verifyAndClearTransition(to2.sharedElementEnter, fromSharedRect2, fromShared2, toShared2)
+ to1.enterTransition.verifyAndClearTransition {
+ epicenter = toSharedRect1
+ enteringViews += toEnter1
+ }
+ to2.enterTransition.verifyAndClearTransition {
+ epicenter = toSharedRect2
+ enteringViews += toEnter2
+ }
+ to1.sharedElementEnter.verifyAndClearTransition {
+ epicenter = fromSharedRect1
+ exitingViews += fromShared1
+ enteringViews += toShared1
+ }
+ to2.sharedElementEnter.verifyAndClearTransition {
+ epicenter = fromSharedRect2
+ exitingViews += fromShared2
+ enteringViews += toShared2
+ }
verifyNoOtherTransitions(to1)
verifyNoOtherTransitions(to2)
@@ -1133,15 +1243,35 @@
val returnEnter2 = findViewById(from2, fromExitId2)
val returnShared2 = findViewById(from2, fromSharedId2)
- verifyAndClearTransition(to1.returnTransition, toSharedRect1, toEnter1)
- verifyAndClearTransition(to2.returnTransition, toSharedRect2, toEnter2)
- verifyAndClearTransition(to1.sharedElementReturn, toSharedRect1, toShared1, returnShared1)
- verifyAndClearTransition(to2.sharedElementReturn, toSharedRect2, toShared2, returnShared2)
+ to1.returnTransition.verifyAndClearTransition {
+ epicenter = toSharedRect1
+ exitingViews += toEnter1
+ }
+ to2.returnTransition.verifyAndClearTransition {
+ epicenter = toSharedRect2
+ exitingViews += toEnter2
+ }
+ to1.sharedElementReturn.verifyAndClearTransition {
+ epicenter = toSharedRect1
+ exitingViews += toShared1
+ enteringViews += returnShared1
+ }
+ to2.sharedElementReturn.verifyAndClearTransition {
+ epicenter = toSharedRect2
+ exitingViews += toShared2
+ enteringViews += returnShared2
+ }
verifyNoOtherTransitions(to1)
verifyNoOtherTransitions(to2)
- verifyAndClearTransition(from1.reenterTransition, fromSharedRect1, returnEnter1)
- verifyAndClearTransition(from2.reenterTransition, fromSharedRect2, returnEnter2)
+ from1.reenterTransition.verifyAndClearTransition {
+ epicenter = fromSharedRect1
+ enteringViews += returnEnter1
+ }
+ from2.reenterTransition.verifyAndClearTransition {
+ epicenter = fromSharedRect2
+ enteringViews += returnEnter2
+ }
verifyNoOtherTransitions(from1)
verifyNoOtherTransitions(from2)
}
@@ -1156,7 +1286,7 @@
val startBlue = activityRule.findBlue()
val startGreen = activityRule.findGreen()
val startRed = activityRule.findRed()
- val startSharedRect = getBoundsOnScreen(startBlue)
+ val startSharedRect = startBlue.boundsOnScreen
instrumentation.runOnMainSync {
for (i in 0 until numPops) {
@@ -1170,20 +1300,22 @@
val endGreen = activityRule.findGreen()
val endBlue = activityRule.findBlue()
val endRed = activityRule.findRed()
- val endSharedRect = getBoundsOnScreen(endBlue)
+ val endSharedRect = endBlue.boundsOnScreen
- if (startRed != null) {
- verifyAndClearTransition(from.returnTransition, startSharedRect, startGreen, startRed)
- } else {
- verifyAndClearTransition(from.returnTransition, startSharedRect, startGreen)
+ from.returnTransition.verifyAndClearTransition {
+ epicenter = startSharedRect
+ exitingViews += listOfNotNull(startGreen, startRed)
}
- verifyAndClearTransition(from.sharedElementReturn, startSharedRect, startBlue, endBlue)
+ from.sharedElementReturn.verifyAndClearTransition {
+ epicenter = startSharedRect
+ exitingViews += startBlue
+ enteringViews += endBlue
+ }
verifyNoOtherTransitions(from)
- if (endRed != null) {
- verifyAndClearTransition(to.reenterTransition, endSharedRect, endGreen, endRed)
- } else {
- verifyAndClearTransition(to.reenterTransition, endSharedRect, endGreen)
+ to.reenterTransition.verifyAndClearTransition {
+ epicenter = endSharedRect
+ enteringViews += listOfNotNull(endGreen, endRed)
}
verifyNoOtherTransitions(to)
@@ -1198,10 +1330,10 @@
val sharedElementReturnTransition1 = TrackingTransition()
val sharedElementReturnTransition2 = TrackingTransition()
- val sharedElementEnterTransition: TransitionSet = TransitionSet()
+ private val sharedElementEnterTransition: TransitionSet = TransitionSet()
.addTransition(sharedElementEnterTransition1)
.addTransition(sharedElementEnterTransition2)
- val sharedElementReturnTransition: TransitionSet = TransitionSet()
+ private val sharedElementReturnTransition: TransitionSet = TransitionSet()
.addTransition(sharedElementReturnTransition1)
.addTransition(sharedElementReturnTransition2)
@@ -1256,11 +1388,5 @@
fun data(): Array<Boolean> {
return arrayOf(false, true)
}
-
- private fun getBoundsOnScreen(view: View): Rect {
- val loc = IntArray(2)
- view.getLocationOnScreen(loc)
- return Rect(loc[0], loc[1], loc[0] + view.width, loc[1] + view.height)
- }
}
}
diff --git a/fragment/fragment/src/androidTest/java/androidx/fragment/app/PostponedTransitionTest.kt b/fragment/fragment/src/androidTest/java/androidx/fragment/app/PostponedTransitionTest.kt
index 03ff771..32970d6 100644
--- a/fragment/fragment/src/androidTest/java/androidx/fragment/app/PostponedTransitionTest.kt
+++ b/fragment/fragment/src/androidTest/java/androidx/fragment/app/PostponedTransitionTest.kt
@@ -15,6 +15,7 @@
*/
package androidx.fragment.app
+import android.graphics.Rect
import android.os.Build
import android.os.Bundle
import android.view.LayoutInflater
@@ -28,6 +29,7 @@
import androidx.test.filters.SdkSuppress
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.rule.ActivityTestRule
+import androidx.testutils.runOnUiThreadRethrow
import androidx.testutils.waitForExecution
import com.google.common.truth.Truth.assertThat
import com.google.common.truth.Truth.assertWithMessage
@@ -74,7 +76,12 @@
beginningFragment.startPostponedEnterTransition()
beginningFragment.waitForTransition()
- clearTargets(beginningFragment)
+ val blueSquare = activityRule.findBlue()
+ val greenSquare = activityRule.findGreen()
+ beginningFragment.enterTransition.verifyAndClearTransition {
+ enteringViews += listOf(blueSquare, greenSquare)
+ }
+ verifyNoOtherTransitions(beginningFragment)
}
// Ensure that replacing with a fragment that has a postponed transition
@@ -82,7 +89,9 @@
@Test
fun replaceTransition() {
val fm = activityRule.activity.supportFragmentManager
- val startBlue = activityRule.activity.findViewById<View>(R.id.blueSquare)
+ val startBlue = activityRule.findBlue()
+ val startGreen = activityRule.findGreen()
+ val startBlueBounds = startBlue.boundsOnScreen
val fragment = PostponedFragment2()
fm.beginTransaction()
@@ -101,7 +110,12 @@
fragment.startPostponedEnterTransition()
// make sure it ran
- assertForwardTransition(beginningFragment, fragment)
+ assertForwardTransition(startBlue, startBlueBounds, startGreen,
+ beginningFragment, fragment)
+
+ val startBlue2 = activityRule.findBlue()
+ val startGreen2 = activityRule.findGreen()
+ val startBlueBounds2 = startBlue2.boundsOnScreen
activityRule.popBackStackImmediate()
@@ -112,14 +126,17 @@
beginningFragment.startPostponedEnterTransition()
// make sure it ran
- assertBackTransition(fragment, beginningFragment)
+ assertBackTransition(startBlue2, startBlueBounds2, startGreen2,
+ fragment, beginningFragment)
}
// Ensure that replacing a fragment doesn't cause problems with the back stack nesting level
@Test
fun backStackNestingLevel() {
val fm = activityRule.activity.supportFragmentManager
- var startBlue = activityRule.activity.findViewById<View>(R.id.blueSquare)
+ val startBlue = activityRule.findBlue()
+ val startGreen = activityRule.findGreen()
+ val startBlueBounds = startBlue.boundsOnScreen
val fragment1 = TransitionFragment(R.layout.scene2)
fm.beginTransaction()
@@ -130,7 +147,12 @@
.commit()
// make sure transition ran
- assertForwardTransition(beginningFragment, fragment1)
+ assertForwardTransition(startBlue, startBlueBounds, startGreen,
+ beginningFragment, fragment1)
+
+ val endBlue = activityRule.findBlue()
+ val endGreen = activityRule.findGreen()
+ val endBlueBounds = endBlue.boundsOnScreen
activityRule.popBackStackImmediate()
@@ -141,20 +163,27 @@
beginningFragment.startPostponedEnterTransition()
// make sure it ran
- assertBackTransition(fragment1, beginningFragment)
+ assertBackTransition(endBlue, endBlueBounds, endGreen, fragment1, beginningFragment)
- startBlue = activityRule.activity.findViewById(R.id.blueSquare)
+ val startBlue2 = activityRule.findBlue()
+ val startGreen2 = activityRule.findGreen()
+ val startBlueBounds2 = startBlue2.boundsOnScreen
val fragment2 = TransitionFragment(R.layout.scene2)
fm.beginTransaction()
- .addSharedElement(startBlue, "blueSquare")
+ .addSharedElement(startBlue2, "blueSquare")
.replace(R.id.fragmentContainer, fragment2)
.addToBackStack(null)
.setReorderingAllowed(true)
.commit()
// make sure transition ran
- assertForwardTransition(beginningFragment, fragment2)
+ assertForwardTransition(startBlue2, startBlueBounds2, startGreen2,
+ beginningFragment, fragment2)
+
+ val endBlue2 = activityRule.findBlue()
+ val endGreen2 = activityRule.findGreen()
+ val endBlueBounds2 = endBlue2.boundsOnScreen
activityRule.popBackStackImmediate()
@@ -165,7 +194,7 @@
beginningFragment.startPostponedEnterTransition()
// make sure it ran
- assertBackTransition(fragment2, beginningFragment)
+ assertBackTransition(endBlue2, endBlueBounds2, endGreen2, fragment2, beginningFragment)
}
// Ensure that postponed transition is forced after another has been committed.
@@ -173,7 +202,9 @@
@Test
fun forcedTransition1() {
val fm = activityRule.activity.supportFragmentManager
- val startBlue = activityRule.activity.findViewById<View>(R.id.blueSquare)
+ val startBlue = activityRule.findBlue()
+ val startGreen = activityRule.findGreen()
+ val startBlueBounds = startBlue.boundsOnScreen
val fragment2 = PostponedFragment2()
val fragment3 = PostponedFragment1()
@@ -199,28 +230,42 @@
activityRule.waitForExecution()
// transition to fragment2 should be started
- assertForwardTransition(beginningFragment, fragment2)
+ assertForwardTransition(startBlue, startBlueBounds, startGreen,
+ beginningFragment, fragment2)
// fragment3 should be postponed, but fragment2 should be executed with no transition.
assertPostponedTransition(fragment2, fragment3, beginningFragment)
+ val startBlue2 = fragment2.requireView().findViewById<View>(R.id.blueSquare)
+ val startGreen2 = fragment2.requireView().findViewById<View>(R.id.greenSquare)
+ val startBlueBounds2 = startBlue2.boundsOnScreen
+
// start the postponed transition
fragment3.startPostponedEnterTransition()
// make sure it ran
- assertForwardTransition(fragment2, fragment3)
+ assertForwardTransition(startBlue2, startBlueBounds2, startGreen2, fragment2, fragment3)
+
+ val startBlue3 = fragment3.requireView().findViewById<View>(R.id.blueSquare)
+ val startGreen3 = fragment3.requireView().findViewById<View>(R.id.greenSquare)
+ val startBlueBounds3 = startBlue3.boundsOnScreen
activityRule.popBackStackImmediate(commit, FragmentManager.POP_BACK_STACK_INCLUSIVE)
- assertBackTransition(fragment3, fragment2)
+ assertBackTransition(startBlue3, startBlueBounds3, startGreen3, fragment3, fragment2)
assertPostponedTransition(fragment2, beginningFragment, fragment3)
+ val endBlue2 = fragment2.requireView().findViewById<View>(R.id.blueSquare)
+ val endGreen2 = fragment2.requireView().findViewById<View>(R.id.greenSquare)
+ val endBlueBounds2 = endBlue2.boundsOnScreen
+
// start the postponed transition
beginningFragment.startPostponedEnterTransition()
// make sure it ran
- assertBackTransition(fragment2, beginningFragment)
+ assertBackTransition(endBlue2, endBlueBounds2, endGreen2,
+ fragment2, beginningFragment)
}
// Ensure that postponed transition is forced after another has been committed.
@@ -228,7 +273,7 @@
@Test
fun forcedTransition2() {
val fm = activityRule.activity.supportFragmentManager
- val startBlue = activityRule.activity.findViewById<View>(R.id.blueSquare)
+ val startBlue = activityRule.findBlue()
val fragment2 = PostponedFragment2()
@@ -258,11 +303,15 @@
// fragment3 should be postponed, but fragment2 should be executed with no transition.
assertPostponedTransition(fragment2, fragment3, beginningFragment)
+ val startBlue2 = activityRule.findBlue()
+ val startGreen2 = activityRule.findGreen()
+ val startBlueBounds2 = startBlue2.boundsOnScreen
+
// start the postponed transition
fragment3.startPostponedEnterTransition()
// make sure it ran
- assertForwardTransition(fragment2, fragment3)
+ assertForwardTransition(startBlue2, startBlueBounds2, startGreen2, fragment2, fragment3)
// Pop back to fragment2, but it should be postponed
activityRule.popBackStackImmediate()
@@ -275,18 +324,25 @@
assertPostponedTransition(fragment2, beginningFragment, fragment3)
+ val endBlue2 = fragment2.requireView().findViewById<View>(R.id.blueSquare)
+ val endGreen2 = fragment2.requireView().findViewById<View>(R.id.greenSquare)
+ val endBlueBounds2 = endBlue2.boundsOnScreen
+
// start the postponed transition
beginningFragment.startPostponedEnterTransition()
// make sure it ran
- assertBackTransition(fragment2, beginningFragment)
+ assertBackTransition(endBlue2, endBlueBounds2, endGreen2,
+ fragment2, beginningFragment)
}
// Do a bunch of things to one fragment in a transaction and see if it can screw things up.
@Test
fun crazyTransition() {
val fm = activityRule.activity.supportFragmentManager
- val startBlue = activityRule.activity.findViewById<View>(R.id.blueSquare)
+ val startBlue = activityRule.findBlue()
+ val startGreen = activityRule.findGreen()
+ val startBlueBounds = startBlue.boundsOnScreen
val fragment2 = PostponedFragment2()
@@ -310,7 +366,12 @@
fragment2.startPostponedEnterTransition()
// make sure it ran
- assertForwardTransition(beginningFragment, fragment2)
+ assertForwardTransition(startBlue, startBlueBounds, startGreen,
+ beginningFragment, fragment2)
+
+ val startBlue2 = activityRule.findBlue()
+ val startGreen2 = activityRule.findGreen()
+ val startBlueBounds2 = startBlue2.boundsOnScreen
// Pop back to fragment2, but it should be postponed
activityRule.popBackStackImmediate()
@@ -321,7 +382,8 @@
beginningFragment.startPostponedEnterTransition()
// make sure it ran
- assertBackTransition(fragment2, beginningFragment)
+ assertBackTransition(startBlue2, startBlueBounds2, startGreen2,
+ fragment2, beginningFragment)
}
// Execute transactions on different containers and ensure that they don't conflict
@@ -353,6 +415,10 @@
val startBlue1 = fragment1.requireView().findViewById<View>(R.id.blueSquare)
val startBlue2 = fragment2.requireView().findViewById<View>(R.id.blueSquare)
+ val startGreen1 = fragment1.requireView().findViewById<View>(R.id.greenSquare)
+ val startGreen2 = fragment2.requireView().findViewById<View>(R.id.greenSquare)
+ val startBlueBounds1 = startBlue1.boundsOnScreen
+ val startBlueBounds2 = startBlue2.boundsOnScreen
val fragment3 = PostponedFragment2()
@@ -385,14 +451,21 @@
fragment3.startPostponedEnterTransition()
// make sure only one ran
- assertForwardTransition(fragment1, fragment3)
+ assertForwardTransition(startBlue1, startBlueBounds1, startGreen1, fragment1, fragment3)
assertPostponedTransition(fragment2, fragment4)
// start the postponed transition
fragment4.startPostponedEnterTransition()
// make sure it ran
- assertForwardTransition(fragment2, fragment4)
+ assertForwardTransition(startBlue2, startBlueBounds2, startGreen2, fragment2, fragment4)
+
+ val startBlue3 = fragment3.requireView().findViewById<View>(R.id.blueSquare)
+ val startBlue4 = fragment4.requireView().findViewById<View>(R.id.blueSquare)
+ val startGreen3 = fragment3.requireView().findViewById<View>(R.id.greenSquare)
+ val startGreen4 = fragment4.requireView().findViewById<View>(R.id.greenSquare)
+ val startBlueBounds3 = startBlue3.boundsOnScreen
+ val startBlueBounds4 = startBlue4.boundsOnScreen
// Pop back to fragment2 -- should be postponed
activityRule.popBackStackImmediate()
@@ -409,7 +482,7 @@
fragment2.startPostponedEnterTransition()
// make sure it ran
- assertBackTransition(fragment4, fragment2)
+ assertBackTransition(startBlue4, startBlueBounds4, startGreen4, fragment4, fragment2)
// but not the postponed one
assertPostponedTransition(fragment3, fragment1)
@@ -418,7 +491,7 @@
fragment1.startPostponedEnterTransition()
// make sure it ran
- assertBackTransition(fragment3, fragment1)
+ assertBackTransition(startBlue3, startBlueBounds3, startGreen3, fragment3, fragment1)
}
// Execute transactions on different containers and ensure that they don't conflict.
@@ -451,6 +524,10 @@
val startBlue1 = fragment1.requireView().findViewById<View>(R.id.blueSquare)
val startBlue2 = fragment2.requireView().findViewById<View>(R.id.blueSquare)
+ val startGreen1 = fragment1.requireView().findViewById<View>(R.id.greenSquare)
+ val startGreen2 = fragment2.requireView().findViewById<View>(R.id.greenSquare)
+ val startBlueBounds1 = startBlue1.boundsOnScreen
+ val startBlueBounds2 = startBlue2.boundsOnScreen
val fragment3 = PostponedFragment2()
@@ -483,14 +560,21 @@
fragment4.startPostponedEnterTransition()
// make sure only one ran
- assertForwardTransition(fragment2, fragment4)
+ assertForwardTransition(startBlue2, startBlueBounds2, startGreen2, fragment2, fragment4)
assertPostponedTransition(fragment1, fragment3)
// start the postponed transition
fragment3.startPostponedEnterTransition()
// make sure it ran
- assertForwardTransition(fragment1, fragment3)
+ assertForwardTransition(startBlue1, startBlueBounds1, startGreen1, fragment1, fragment3)
+
+ val startBlue3 = fragment3.requireView().findViewById<View>(R.id.blueSquare)
+ val startBlue4 = fragment4.requireView().findViewById<View>(R.id.blueSquare)
+ val startGreen3 = fragment3.requireView().findViewById<View>(R.id.greenSquare)
+ val startGreen4 = fragment4.requireView().findViewById<View>(R.id.greenSquare)
+ val startBlueBounds3 = startBlue3.boundsOnScreen
+ val startBlueBounds4 = startBlue4.boundsOnScreen
// Pop back to fragment2 -- should be postponed
activityRule.popBackStackImmediate()
@@ -507,7 +591,7 @@
fragment1.startPostponedEnterTransition()
// make sure it ran
- assertBackTransition(fragment3, fragment1)
+ assertBackTransition(startBlue3, startBlueBounds3, startGreen3, fragment3, fragment1)
// but not the postponed one
assertPostponedTransition(fragment4, fragment2)
@@ -516,7 +600,7 @@
fragment2.startPostponedEnterTransition()
// make sure it ran
- assertBackTransition(fragment4, fragment2)
+ assertBackTransition(startBlue4, startBlueBounds4, startGreen4, fragment4, fragment2)
}
// Make sure that commitNow for a transaction on a different fragment container doesn't
@@ -549,6 +633,10 @@
val startBlue1 = fragment1.requireView().findViewById<View>(R.id.blueSquare)
val startBlue2 = fragment2.requireView().findViewById<View>(R.id.blueSquare)
+ val startGreen1 = fragment1.requireView().findViewById<View>(R.id.greenSquare)
+ val startGreen2 = fragment2.requireView().findViewById<View>(R.id.greenSquare)
+ val startBlueBounds1 = startBlue1.boundsOnScreen
+ val startBlueBounds2 = startBlue2.boundsOnScreen
val fragment3 = PostponedFragment2()
val strictFragment1 = StrictFragment()
@@ -587,14 +675,14 @@
fragment4.startPostponedEnterTransition()
// make sure only one ran
- assertForwardTransition(fragment2, fragment4)
+ assertForwardTransition(startBlue2, startBlueBounds2, startGreen2, fragment2, fragment4)
assertPostponedTransition(fragment1, fragment3)
// start the postponed transition
fragment3.startPostponedEnterTransition()
// make sure it ran
- assertForwardTransition(fragment1, fragment3)
+ assertForwardTransition(startBlue1, startBlueBounds1, startGreen1, fragment1, fragment3)
}
// Make sure that commitNow for a transaction affecting a postponed fragment in the same
@@ -602,7 +690,7 @@
@Test
fun commitNowStartsPostponed() {
val fm = activityRule.activity.supportFragmentManager
- val startBlue1 = beginningFragment.requireView().findViewById<View>(R.id.blueSquare)
+ val startBlue1 = activityRule.findBlue()
val fragment2 = PostponedFragment2()
val fragment1 = PostponedFragment1()
@@ -616,6 +704,8 @@
activityRule.waitForExecution()
val startBlue2 = fragment2.requireView().findViewById<View>(R.id.blueSquare)
+ val startGreen2 = fragment2.requireView().findViewById<View>(R.id.greenSquare)
+ val startBlueBounds2 = startBlue2.boundsOnScreen
instrumentation.runOnMainSync {
fm.beginTransaction()
@@ -630,7 +720,7 @@
// start the postponed transition
fragment1.startPostponedEnterTransition()
- assertForwardTransition(fragment2, fragment1)
+ assertForwardTransition(startBlue2, startBlueBounds2, startGreen2, fragment2, fragment1)
}
// Make sure that when a transaction that removes a view is postponed that
@@ -687,7 +777,7 @@
@Test
fun popPostponedTransaction() {
val fm = activityRule.activity.supportFragmentManager
- val startBlue = beginningFragment.requireView().findViewById<View>(R.id.blueSquare)
+ val startBlue = activityRule.findBlue()
val fragment = PostponedFragment2()
@@ -706,8 +796,8 @@
fragment.waitForNoTransition()
beginningFragment.waitForNoTransition()
- assureNoTransition(fragment)
- assureNoTransition(beginningFragment)
+ verifyNoOtherTransitions(fragment)
+ verifyNoOtherTransitions(beginningFragment)
assertThat(fragment.isAdded).isFalse()
assertThat(fragment.view).isNull()
@@ -759,7 +849,7 @@
@Test
fun postponeDoesNotAllowReentrancy() {
val fm = activityRule.activity.supportFragmentManager
- val startBlue = activityRule.activity.findViewById<View>(R.id.blueSquare)
+ val startBlue = activityRule.findBlue()
val fragment = CommitNowFragment()
fm.beginTransaction()
@@ -794,7 +884,7 @@
@Test
fun testTimedPostpone() {
val fm = activityRule.activity.supportFragmentManager
- val startBlue = activityRule.activity.findViewById<View>(R.id.blueSquare)
+ val startBlue = activityRule.findBlue()
val fragment = PostponedFragment3(1000)
fm.beginTransaction()
@@ -825,7 +915,9 @@
@Test
fun testTimedPostponeStartPostponedCalledTwice() {
val fm = activityRule.activity.supportFragmentManager
- val startBlue = activityRule.activity.findViewById<View>(R.id.blueSquare)
+ val startBlue = activityRule.findBlue()
+ val startGreen = activityRule.findGreen()
+ val startBlueBounds = startBlue.boundsOnScreen
val fragment = PostponedFragment3(1000)
fm.beginTransaction()
@@ -842,7 +934,8 @@
fragment.startPostponedEnterTransition()
- assertForwardTransition(beginningFragment, fragment)
+ assertForwardTransition(startBlue, startBlueBounds, startGreen,
+ beginningFragment, fragment)
assertWithMessage("After startPostponed is called the transition should not be postponed")
.that(fragment.isPostponed).isFalse()
@@ -854,7 +947,7 @@
@Test
fun testTimedPostponeEnterPostponedCalledTwice() {
val fm = activityRule.activity.supportFragmentManager
- val startBlue = activityRule.activity.findViewById<View>(R.id.blueSquare)
+ val startBlue = activityRule.findBlue()
val fragment = PostponedFragment3(1000)
fragment.startPostponedCountDownLatch = CountDownLatch(2)
@@ -890,7 +983,7 @@
@Test
fun testTimedPostponeEnterPostponedCalledWithZero() {
val fm = activityRule.activity.supportFragmentManager
- val startBlue = activityRule.activity.findViewById<View>(R.id.blueSquare)
+ val startBlue = activityRule.findBlue()
val fragment = PostponedFragment3(0)
fm.beginTransaction()
@@ -915,7 +1008,7 @@
@Test
fun testTimedPostponeCalledInConstructor() {
val fm = activityRule.activity.supportFragmentManager
- val startBlue = activityRule.activity.findViewById<View>(R.id.blueSquare)
+ val startBlue = activityRule.findBlue()
val fragment = PostponedConstructorFragment()
fm.beginTransaction()
@@ -949,7 +1042,7 @@
) {
if (removedFragment != null) {
assertThat(removedFragment.view).isNull()
- assureNoTransition(removedFragment)
+ verifyNoOtherTransitions(removedFragment)
}
toFragment.waitForNoTransition()
@@ -960,113 +1053,118 @@
assertThat(fromFragment.requireView().visibility).isEqualTo(View.VISIBLE)
assertThat(toFragment.requireView().visibility).isEqualTo(View.VISIBLE)
assertThat(toFragment.requireView().alpha).isWithin(0f).of(0f)
- assureNoTransition(fromFragment)
- assureNoTransition(toFragment)
+ verifyNoOtherTransitions(fromFragment)
+ verifyNoOtherTransitions(toFragment)
assertThat(fromFragment.isResumed).isTrue()
assertThat(toFragment.isResumed).isFalse()
}
private fun clearTargets(fragment: TransitionFragment) {
- fragment.enterTransition.targets.clear()
- fragment.reenterTransition.targets.clear()
- fragment.exitTransition.targets.clear()
- fragment.returnTransition.targets.clear()
- fragment.sharedElementEnter.targets.clear()
- fragment.sharedElementReturn.targets.clear()
+ fragment.enterTransition.clearTargets()
+ fragment.reenterTransition.clearTargets()
+ fragment.exitTransition.clearTargets()
+ fragment.returnTransition.clearTargets()
+ fragment.sharedElementEnter.clearTargets()
+ fragment.sharedElementReturn.clearTargets()
}
- private fun assureNoTransition(fragment: TransitionFragment) {
- assertThat(fragment.enterTransition.targets.size).isEqualTo(0)
- assertThat(fragment.reenterTransition.targets.size).isEqualTo(0)
- assertThat(fragment.enterTransition.targets.size).isEqualTo(0)
- assertThat(fragment.returnTransition.targets.size).isEqualTo(0)
- assertThat(fragment.sharedElementEnter.targets.size).isEqualTo(0)
- assertThat(fragment.sharedElementReturn.targets.size).isEqualTo(0)
- }
-
- private fun assertForwardTransition(start: TransitionFragment, end: TransitionFragment) {
+ private fun assertForwardTransition(
+ sharedElement: View,
+ sharedElementBounds: Rect,
+ transitioningView: View,
+ start: TransitionFragment,
+ end: TransitionFragment
+ ) {
start.waitForTransition()
end.waitForTransition()
- assertThat(start.enterTransition.targets.size).isEqualTo(0)
- assertThat(end.enterTransition.targets.size).isEqualTo(1)
- assertThat(start.reenterTransition.targets.size).isEqualTo(0)
- assertThat(end.reenterTransition.targets.size).isEqualTo(0)
+ val endSharedElement = end.requireView().findViewById<View>(R.id.blueSquare)
+ val endTransitioningView = end.requireView().findViewById<View>(R.id.greenSquare)
+ val endSharedElementBounds = endSharedElement.boundsOnScreen
- assertThat(start.returnTransition.targets.size).isEqualTo(0)
- assertThat(end.returnTransition.targets.size).isEqualTo(0)
+ end.enterTransition.verifyAndClearTransition {
+ epicenter = endSharedElementBounds
+ enteringViews += endTransitioningView
+ }
- assertThat(start.exitTransition.targets.size).isEqualTo(1)
- assertThat(end.exitTransition.targets.size).isEqualTo(0)
+ start.exitTransition.verifyAndClearTransition {
+ epicenter = sharedElementBounds
+ exitingViews += transitioningView
+ }
- assertThat(start.sharedElementEnter.targets.size).isEqualTo(0)
- assertThat(end.sharedElementEnter.targets.size).isEqualTo(2)
-
- assertThat(start.sharedElementReturn.targets.size).isEqualTo(0)
- assertThat(end.sharedElementReturn.targets.size).isEqualTo(0)
+ end.sharedElementEnter.verifyAndClearTransition {
+ epicenter = sharedElementBounds
+ exitingViews += sharedElement
+ enteringViews += endSharedElement
+ }
// This checks need to be done on the mainThread to ensure that the shared element draw is
// complete. If these checks are not on the mainThread, there is a chance that this gets
// checked during OnShotPreDrawListener.onPreDraw, causing the name assert to fail.
activityRule.runOnUiThread {
- val blue = end.requireView().findViewById<View>(R.id.blueSquare)
- assertThat(end.sharedElementEnter.targets.contains(blue)).isTrue()
- assertThat(end.sharedElementEnter.targets[0].transitionName).isEqualTo("blueSquare")
- assertThat(end.sharedElementEnter.targets[1].transitionName).isEqualTo("blueSquare")
+ assertThat(sharedElement.transitionName).isEqualTo("blueSquare")
+ assertThat(endSharedElement.transitionName).isEqualTo("blueSquare")
}
+ verifyNoOtherTransitions(start)
+ verifyNoOtherTransitions(end)
+
assertNoTargets(start)
assertNoTargets(end)
-
- clearTargets(start)
- clearTargets(end)
}
- private fun assertBackTransition(start: TransitionFragment, end: TransitionFragment) {
+ private fun assertBackTransition(
+ sharedElement: View,
+ sharedElementBounds: Rect,
+ transitionView: View,
+ start: TransitionFragment,
+ end: TransitionFragment
+ ) {
start.waitForTransition()
end.waitForTransition()
- assertThat(end.reenterTransition.targets.size).isEqualTo(1)
- assertThat(start.reenterTransition.targets.size).isEqualTo(0)
- assertThat(end.returnTransition.targets.size).isEqualTo(0)
- assertThat(start.returnTransition.targets.size).isEqualTo(1)
+ val endSharedElement = end.requireView().findViewById<View>(R.id.blueSquare)
+ val endTransitioningView = end.requireView().findViewById<View>(R.id.greenSquare)
+ val endSharedElementBounds = endSharedElement.boundsOnScreen
- assertThat(start.enterTransition.targets.size).isEqualTo(0)
- assertThat(end.enterTransition.targets.size).isEqualTo(0)
+ end.reenterTransition.verifyAndClearTransition {
+ epicenter = endSharedElementBounds
+ enteringViews += endTransitioningView
+ }
- assertThat(start.exitTransition.targets.size).isEqualTo(0)
- assertThat(end.exitTransition.targets.size).isEqualTo(0)
+ start.returnTransition.verifyAndClearTransition {
+ epicenter = sharedElementBounds
+ exitingViews += transitionView
+ }
- assertThat(start.sharedElementEnter.targets.size).isEqualTo(0)
- assertThat(end.sharedElementEnter.targets.size).isEqualTo(0)
-
- assertThat(start.sharedElementReturn.targets.size).isEqualTo(2)
- assertThat(end.sharedElementReturn.targets.size).isEqualTo(0)
+ start.sharedElementReturn.verifyAndClearTransition {
+ epicenter = sharedElementBounds
+ exitingViews += sharedElement
+ enteringViews += endSharedElement
+ }
// This checks need to be done on the mainThread to ensure that the shared element draw is
// complete. If these checks are not on the mainThread, there is a chance that this gets
// checked during OnShotPreDrawListener.onPreDraw, causing the name assert to fail.
- activityRule.runOnUiThread {
- val blue = end.requireView().findViewById<View>(R.id.blueSquare)
- assertThat(start.sharedElementReturn.targets.contains(blue)).isTrue()
- assertThat(start.sharedElementReturn.targets[0].transitionName).isEqualTo("blueSquare")
- assertThat(start.sharedElementReturn.targets[1].transitionName).isEqualTo("blueSquare")
+ activityRule.runOnUiThreadRethrow {
+ assertThat(sharedElement.transitionName).isEqualTo("blueSquare")
+ assertThat(endSharedElement.transitionName).isEqualTo("blueSquare")
}
+ verifyNoOtherTransitions(start)
+ verifyNoOtherTransitions(end)
+
assertNoTargets(end)
assertNoTargets(start)
-
- clearTargets(start)
- clearTargets(end)
}
private fun assertNoTargets(fragment: TransitionFragment) {
- assertThat(fragment.enterTransition.getTargets().isEmpty()).isTrue()
- assertThat(fragment.reenterTransition.getTargets().isEmpty()).isTrue()
- assertThat(fragment.exitTransition.getTargets().isEmpty()).isTrue()
- assertThat(fragment.returnTransition.getTargets().isEmpty()).isTrue()
- assertThat(fragment.sharedElementEnter.getTargets().isEmpty()).isTrue()
- assertThat(fragment.sharedElementReturn.getTargets().isEmpty()).isTrue()
+ assertThat(fragment.enterTransition.targets.isEmpty()).isTrue()
+ assertThat(fragment.reenterTransition.targets.isEmpty()).isTrue()
+ assertThat(fragment.exitTransition.targets.isEmpty()).isTrue()
+ assertThat(fragment.returnTransition.targets.isEmpty()).isTrue()
+ assertThat(fragment.sharedElementEnter.targets.isEmpty()).isTrue()
+ assertThat(fragment.sharedElementReturn.targets.isEmpty()).isTrue()
}
open class PostponedFragment1 : TransitionFragment(R.layout.scene1) {
diff --git a/fragment/fragment/src/androidTest/java/androidx/fragment/app/TrackingTransition.kt b/fragment/fragment/src/androidTest/java/androidx/fragment/app/TrackingTransition.kt
index e45a428..d9ca859 100644
--- a/fragment/fragment/src/androidTest/java/androidx/fragment/app/TrackingTransition.kt
+++ b/fragment/fragment/src/androidTest/java/androidx/fragment/app/TrackingTransition.kt
@@ -21,8 +21,6 @@
import android.view.View
import android.view.ViewGroup
-import java.util.ArrayList
-
/**
* A transition that tracks which targets are applied to it.
* It will assume any target that it applies to will have differences
@@ -36,8 +34,9 @@
* is created.
*/
class TrackingTransition : Transition(), TargetTracking {
- val targets = ArrayList<View>()
- private val baseEpicenter = Rect()
+ override val enteringTargets = mutableListOf<View>()
+ override val exitingTargets = mutableListOf<View>()
+ override val capturedEpicenter: Rect = Rect()
override fun getTransitionProperties(): Array<String> {
return PROPS
@@ -57,26 +56,20 @@
endValues: TransitionValues?
) = null.also {
if (startValues != null) {
- targets.add(startValues.view)
+ exitingTargets.add(startValues.view)
}
if (endValues != null) {
- targets.add(endValues.view)
+ enteringTargets.add(endValues.view)
}
if (epicenter != null) {
- baseEpicenter.set(Rect(epicenter))
+ capturedEpicenter.set(Rect(epicenter))
}
}
- override fun getTrackedTargets(): ArrayList<View> {
- return targets
- }
-
override fun clearTargets() {
- targets.clear()
- }
-
- override fun getCapturedEpicenter(): Rect? {
- return baseEpicenter
+ enteringTargets.clear()
+ exitingTargets.clear()
+ capturedEpicenter.set(Rect())
}
companion object {
diff --git a/fragment/fragment/src/androidTest/java/androidx/fragment/app/TrackingVisibility.java b/fragment/fragment/src/androidTest/java/androidx/fragment/app/TrackingVisibility.java
index 8951f01..f10cc4a 100644
--- a/fragment/fragment/src/androidTest/java/androidx/fragment/app/TrackingVisibility.java
+++ b/fragment/fragment/src/androidTest/java/androidx/fragment/app/TrackingVisibility.java
@@ -27,6 +27,7 @@
import androidx.annotation.NonNull;
import java.util.ArrayList;
+import java.util.List;
import java.util.concurrent.CountDownLatch;
/**
@@ -34,7 +35,8 @@
* By default, this transition does no animation.
*/
public class TrackingVisibility extends Visibility implements TargetTracking {
- public final ArrayList<View> targets = new ArrayList<>();
+ private final ArrayList<View> mEnteringTargets = new ArrayList<>();
+ private final ArrayList<View> mExitingTargets = new ArrayList<>();
private final Rect[] mEpicenter = new Rect[1];
private boolean mRealTransition;
public CountDownLatch endAnimatorCountDownLatch = new CountDownLatch(1);
@@ -46,7 +48,7 @@
@Override
public Animator onAppear(ViewGroup sceneRoot, View view, TransitionValues startValues,
TransitionValues endValues) {
- targets.add(endValues.view);
+ mEnteringTargets.add(endValues.view);
Rect epicenter = getEpicenter();
if (epicenter != null) {
mEpicenter[0] = new Rect(epicenter);
@@ -59,7 +61,7 @@
@Override
public Animator onDisappear(ViewGroup sceneRoot, View view, TransitionValues startValues,
TransitionValues endValues) {
- targets.add(startValues.view);
+ mExitingTargets.add(startValues.view);
Rect epicenter = getEpicenter();
if (epicenter != null) {
mEpicenter[0] = new Rect(epicenter);
@@ -94,13 +96,21 @@
@NonNull
@Override
- public ArrayList<View> getTrackedTargets() {
- return targets;
+ public List<View> getEnteringTargets() {
+ return mEnteringTargets;
+ }
+
+ @NonNull
+ @Override
+ public List<View> getExitingTargets() {
+ return mExitingTargets;
}
@Override
public void clearTargets() {
- targets.clear();
+ mEnteringTargets.clear();
+ mExitingTargets.clear();
+ mEpicenter[0] = null;
}
@Override
diff --git a/fragment/fragment/src/main/java/androidx/fragment/app/Fragment.java b/fragment/fragment/src/main/java/androidx/fragment/app/Fragment.java
index 298c9aa..3c4d5e4 100644
--- a/fragment/fragment/src/main/java/androidx/fragment/app/Fragment.java
+++ b/fragment/fragment/src/main/java/androidx/fragment/app/Fragment.java
@@ -1483,6 +1483,10 @@
* the signature of the app declaring the permissions.
* </p>
* <p>
+ * Call {@link #shouldShowRequestPermissionRationale(String)} before calling this API to
+ * check if the system recommends to show a rationale dialog before asking for a permission.
+ * </p>
+ * <p>
* If your app does not have the requested permissions the user will be presented
* with UI for accepting them. After the user has accepted or rejected the
* requested permissions you will receive a callback on {@link
@@ -1511,29 +1515,6 @@
* can be useful if the way your app uses the data guarded by the permissions
* changes significantly.
* </p>
- * <p>
- * A sample permissions request looks like this:
- * </p>
- * <code><pre><p>
- * private void showContacts() {
- * if (getActivity().checkSelfPermission(Manifest.permission.READ_CONTACTS)
- * != PackageManager.PERMISSION_GRANTED) {
- * requestPermissions(new String[]{Manifest.permission.READ_CONTACTS},
- * PERMISSIONS_REQUEST_READ_CONTACTS);
- * } else {
- * doShowContacts();
- * }
- * }
- *
- * {@literal @}Override
- * public void onRequestPermissionsResult(int requestCode, String[] permissions,
- * int[] grantResults) {
- * if (requestCode == PERMISSIONS_REQUEST_READ_CONTACTS
- * && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
- * doShowContacts();
- * }
- * }
- * </code></pre></p>
*
* @param permissions The requested permissions.
* @param requestCode Application specific request code to match with a result reported to
@@ -1586,20 +1567,10 @@
}
/**
- * Gets whether you should show UI with rationale for requesting a permission.
- * You should do this only if you do not have the permission and the context in
- * which the permission is requested does not clearly communicate to the user
- * what would be the benefit from granting this permission.
- * <p>
- * For example, if you write a camera app, requesting the camera permission
- * would be expected by the user and no rationale for why it is requested is
- * needed. If however, the app needs location for tagging photos then a non-tech
- * savvy user may wonder how location is related to taking photos. In this case
- * you may choose to show UI with rationale of requesting this permission.
- * </p>
+ * Gets whether you should show UI with rationale before requesting a permission.
*
* @param permission A permission your app wants to request.
- * @return Whether you can show permission rationale UI.
+ * @return Whether you should show permission rationale UI.
*
* @see Context#checkSelfPermission(String)
* @see #requestPermissions(String[], int)
diff --git a/fragment/integration-tests/testapp/build.gradle b/fragment/integration-tests/testapp/build.gradle
index 1d9233d..f87c5b6 100644
--- a/fragment/integration-tests/testapp/build.gradle
+++ b/fragment/integration-tests/testapp/build.gradle
@@ -26,7 +26,8 @@
sourceSets {
main {
res.srcDirs = ['src/main/res',
- 'src/main/res/layouts/doubleTransitionBug'
+ 'src/main/res/layouts/doubleTransitionBug',
+ 'src/main/res/layouts/kittenFragmentTransitions'
]
}
}
@@ -36,6 +37,7 @@
implementation(KOTLIN_STDLIB)
implementation(project(":fragment:fragment-ktx"))
implementation 'androidx.transition:transition:1.3.0'
+ implementation 'androidx.recyclerview:recyclerview:1.1.0'
}
tasks['check'].dependsOn(tasks['connectedCheck'])
diff --git a/fragment/integration-tests/testapp/src/main/AndroidManifest.xml b/fragment/integration-tests/testapp/src/main/AndroidManifest.xml
index cef64da..460d479 100644
--- a/fragment/integration-tests/testapp/src/main/AndroidManifest.xml
+++ b/fragment/integration-tests/testapp/src/main/AndroidManifest.xml
@@ -31,6 +31,7 @@
</intent-filter>
</activity>
<activity android:name=".doubleTransitionBug.DoubleTransitionBugActivity"/>
+ <activity android:name=".kittenfragmenttransitions.KittenTransitionMainActivity"/>
</application>
</manifest>
diff --git a/fragment/integration-tests/testapp/src/main/java/androidx/fragment/testapp/TransitionTestsFragment.kt b/fragment/integration-tests/testapp/src/main/java/androidx/fragment/testapp/TransitionTestsFragment.kt
index 3ff8604..e2c8cbe 100644
--- a/fragment/integration-tests/testapp/src/main/java/androidx/fragment/testapp/TransitionTestsFragment.kt
+++ b/fragment/integration-tests/testapp/src/main/java/androidx/fragment/testapp/TransitionTestsFragment.kt
@@ -24,11 +24,13 @@
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.fragment.testapp.doubleTransitionBug.DoubleTransitionBugActivity
+import androidx.fragment.testapp.kittenfragmenttransitions.KittenTransitionMainActivity
class TransitionTestsFragment : Fragment(R.layout.transition_fragment) {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
addButton("Double Transition Bug", DoubleTransitionBugActivity::class.java)
+ addButton("Kitten Transition", KittenTransitionMainActivity::class.java)
}
}
diff --git a/fragment/integration-tests/testapp/src/main/java/androidx/fragment/testapp/kittenfragmenttransitions/DetailsFragment.kt b/fragment/integration-tests/testapp/src/main/java/androidx/fragment/testapp/kittenfragmenttransitions/DetailsFragment.kt
new file mode 100644
index 0000000..7c64d96
--- /dev/null
+++ b/fragment/integration-tests/testapp/src/main/java/androidx/fragment/testapp/kittenfragmenttransitions/DetailsFragment.kt
@@ -0,0 +1,63 @@
+/*
+ * 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 androidx.fragment.testapp.kittenfragmenttransitions
+
+import android.os.Bundle
+import android.view.View
+import android.widget.ImageView
+import androidx.annotation.IntRange
+import androidx.core.os.bundleOf
+import androidx.fragment.app.Fragment
+import androidx.fragment.testapp.R
+
+/**
+ * Display details for a given kitten
+ */
+class DetailsFragment : Fragment(R.layout.kitten_details_fragment) {
+
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ super.onViewCreated(view, savedInstanceState)
+ val image = view.findViewById<ImageView>(R.id.image)
+ val args = arguments
+ val kittenNumber = when {
+ args == null -> 0
+ args.containsKey(ARG_KITTEN_NUMBER) -> args.getInt(ARG_KITTEN_NUMBER)
+ else -> 1
+ }
+ when (kittenNumber) {
+ 1 -> image.setImageResource(R.drawable.placekitten_1)
+ 2 -> image.setImageResource(R.drawable.placekitten_2)
+ 3 -> image.setImageResource(R.drawable.placekitten_3)
+ 4 -> image.setImageResource(R.drawable.placekitten_4)
+ 5 -> image.setImageResource(R.drawable.placekitten_5)
+ 6 -> image.setImageResource(R.drawable.placekitten_6)
+ }
+ }
+
+ companion object {
+ private const val ARG_KITTEN_NUMBER = "argKittenNumber"
+ /**
+ * Create a new DetailsFragment
+ *
+ * @param kittenNumber The number (between 1 and 6) of the kitten to display
+ */
+ @JvmStatic
+ fun newInstance(@IntRange(from = 1, to = 6) kittenNumber: Int) =
+ DetailsFragment().apply {
+ arguments = bundleOf(ARG_KITTEN_NUMBER to kittenNumber)
+ }
+ }
+}
diff --git a/fragment/integration-tests/testapp/src/main/java/androidx/fragment/testapp/kittenfragmenttransitions/DetailsTransition.kt b/fragment/integration-tests/testapp/src/main/java/androidx/fragment/testapp/kittenfragmenttransitions/DetailsTransition.kt
new file mode 100644
index 0000000..ee8f55d
--- /dev/null
+++ b/fragment/integration-tests/testapp/src/main/java/androidx/fragment/testapp/kittenfragmenttransitions/DetailsTransition.kt
@@ -0,0 +1,51 @@
+/*
+ * 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 androidx.fragment.testapp.kittenfragmenttransitions
+
+import android.annotation.TargetApi
+import android.content.Context
+import android.os.Build
+import android.util.AttributeSet
+import androidx.transition.ChangeBounds
+import androidx.transition.ChangeImageTransform
+import androidx.transition.ChangeTransform
+import androidx.transition.TransitionSet
+
+/**
+ * Transition that performs almost exactly like [android.transition.AutoTransition], but has
+ * an added [ChangeImageTransform] to support properly scaling up our gorgeous kittens.
+ */
+@TargetApi(Build.VERSION_CODES.LOLLIPOP)
+class DetailsTransition : TransitionSet {
+ constructor() {
+ init()
+ }
+
+ /**
+ * This constructor allows us to use this transition in XML
+ */
+ constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
+ init()
+ }
+
+ private fun init() {
+ ordering = ORDERING_TOGETHER
+ duration = 2000
+ addTransition(ChangeBounds())
+ .addTransition(ChangeTransform())
+ .addTransition(ChangeImageTransform())
+ }
+}
diff --git a/fragment/integration-tests/testapp/src/main/java/androidx/fragment/testapp/kittenfragmenttransitions/GridFragment.kt b/fragment/integration-tests/testapp/src/main/java/androidx/fragment/testapp/kittenfragmenttransitions/GridFragment.kt
new file mode 100644
index 0000000..0787b3b
--- /dev/null
+++ b/fragment/integration-tests/testapp/src/main/java/androidx/fragment/testapp/kittenfragmenttransitions/GridFragment.kt
@@ -0,0 +1,83 @@
+/*
+ * 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 androidx.fragment.testapp.kittenfragmenttransitions
+
+import android.os.Build
+import android.os.Bundle
+import android.view.View
+import android.view.ViewGroup
+import android.widget.RadioButton
+import androidx.core.view.OneShotPreDrawListener
+import androidx.fragment.app.Fragment
+import androidx.fragment.app.commit
+import androidx.fragment.testapp.R
+import androidx.fragment.testapp.kittenfragmenttransitions.DetailsFragment.Companion.newInstance
+import androidx.recyclerview.widget.GridLayoutManager
+import androidx.recyclerview.widget.RecyclerView
+import androidx.transition.Fade
+
+/**
+ * Displays a grid of pictures
+ */
+class GridFragment : Fragment(R.layout.kitten_fragment_grid) {
+
+ override fun onViewCreated(
+ view: View,
+ savedInstanceState: Bundle?
+ ) {
+ view.findViewById<RecyclerView>(R.id.recyclerview).apply {
+ adapter = KittenGridAdapter(callback)
+ layoutManager = GridLayoutManager(context, 2)
+ }
+ // View is created so postpone the transition
+ postponeEnterTransition()
+ OneShotPreDrawListener.add(view.parent as ViewGroup) {
+ startPostponedEnterTransition()
+ }
+ }
+
+ private val callback = { holder: KittenViewHolder, position: Int ->
+ val kittenNumber = position % 6 + 1
+ val kittenDetails = newInstance(kittenNumber)
+ // Note that we need the API version check here because the actual transition
+ // classes(e.g. Fade) are not in the support library and are only available in API 21+.
+ // The methods we are calling on the Fragment ARE available in the support library
+ // (though they don't do anything on API < 21)
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ kittenDetails.sharedElementEnterTransition = DetailsTransition()
+ kittenDetails.enterTransition = Fade()
+ exitTransition = Fade()
+ kittenDetails.sharedElementReturnTransition = DetailsTransition()
+ }
+ val radioReplace = requireActivity().findViewById<RadioButton>(R.id.radioButton1)
+ if (radioReplace.isChecked) {
+ parentFragmentManager.commit {
+ setReorderingAllowed(true)
+ addSharedElement(holder.image, "kittenImage")
+ replace(R.id.container, kittenDetails)
+ addToBackStack(null)
+ }
+ } else {
+ parentFragmentManager.commit {
+ setReorderingAllowed(true)
+ addSharedElement(holder.image, "kittenImage")
+ add(R.id.container, kittenDetails)
+ hide(this@GridFragment)
+ addToBackStack(null)
+ }
+ }
+ }
+}
diff --git a/fragment/integration-tests/testapp/src/main/java/androidx/fragment/testapp/kittenfragmenttransitions/KittenGridAdapter.kt b/fragment/integration-tests/testapp/src/main/java/androidx/fragment/testapp/kittenfragmenttransitions/KittenGridAdapter.kt
new file mode 100644
index 0000000..75ec3d7
--- /dev/null
+++ b/fragment/integration-tests/testapp/src/main/java/androidx/fragment/testapp/kittenfragmenttransitions/KittenGridAdapter.kt
@@ -0,0 +1,57 @@
+/*
+ * 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 androidx.fragment.testapp.kittenfragmenttransitions
+
+import android.view.LayoutInflater
+import android.view.ViewGroup
+import androidx.core.view.ViewCompat
+import androidx.fragment.testapp.R
+import androidx.recyclerview.widget.RecyclerView
+
+/**
+ * Adapts Views containing kittens to RecyclerView cells
+ */
+class KittenGridAdapter(
+ private val listener: (holder: KittenViewHolder, position: Int) -> Unit,
+ private val size: Int = 6
+) : RecyclerView.Adapter<KittenViewHolder>() {
+
+ override fun onCreateViewHolder(container: ViewGroup, position: Int): KittenViewHolder {
+ val inflater = LayoutInflater.from(container.context)
+ val cell = inflater.inflate(R.layout.kitten_grid_item, container, false)
+ return KittenViewHolder(cell)
+ }
+
+ override fun onBindViewHolder(viewHolder: KittenViewHolder, position: Int) {
+ when (position % 6) {
+ 0 -> viewHolder.image.setImageResource(R.drawable.placekitten_1)
+ 1 -> viewHolder.image.setImageResource(R.drawable.placekitten_2)
+ 2 -> viewHolder.image.setImageResource(R.drawable.placekitten_3)
+ 3 -> viewHolder.image.setImageResource(R.drawable.placekitten_4)
+ 4 -> viewHolder.image.setImageResource(R.drawable.placekitten_5)
+ 5 -> viewHolder.image.setImageResource(R.drawable.placekitten_6)
+ }
+ // It is important that each shared element in the source screen has a unique transition
+ // name. For example, we can't just give all the images in our grid the transition name
+ // "kittenImage" because then we would have conflicting transition names. By appending
+ // "_image" to the position, we can support having multiple shared elements in each grid
+ // cell in the future.
+ ViewCompat.setTransitionName(viewHolder.image, position.toString() + "_image")
+ viewHolder.image.setOnClickListener { listener(viewHolder, position) }
+ }
+
+ override fun getItemCount() = size
+}
diff --git a/fragment/integration-tests/testapp/src/main/java/androidx/fragment/testapp/kittenfragmenttransitions/KittenTransitionMainActivity.kt b/fragment/integration-tests/testapp/src/main/java/androidx/fragment/testapp/kittenfragmenttransitions/KittenTransitionMainActivity.kt
new file mode 100644
index 0000000..bd99b1f
--- /dev/null
+++ b/fragment/integration-tests/testapp/src/main/java/androidx/fragment/testapp/kittenfragmenttransitions/KittenTransitionMainActivity.kt
@@ -0,0 +1,24 @@
+/*
+ * 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 androidx.fragment.testapp.kittenfragmenttransitions
+
+import androidx.fragment.app.FragmentActivity
+import androidx.fragment.testapp.R
+
+/**
+ * Main activity that holds our fragments
+ */
+class KittenTransitionMainActivity : FragmentActivity(R.layout.kitten_activity_main)
diff --git a/fragment/integration-tests/testapp/src/main/java/androidx/fragment/testapp/kittenfragmenttransitions/KittenViewHolder.kt b/fragment/integration-tests/testapp/src/main/java/androidx/fragment/testapp/kittenfragmenttransitions/KittenViewHolder.kt
new file mode 100644
index 0000000..49b0932
--- /dev/null
+++ b/fragment/integration-tests/testapp/src/main/java/androidx/fragment/testapp/kittenfragmenttransitions/KittenViewHolder.kt
@@ -0,0 +1,28 @@
+/*
+ * 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 androidx.fragment.testapp.kittenfragmenttransitions
+
+import android.view.View
+import android.widget.ImageView
+import androidx.fragment.testapp.R
+import androidx.recyclerview.widget.RecyclerView
+
+/**
+ * ViewHolder for kitten cells in our grid
+ */
+class KittenViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
+ var image = itemView.findViewById<ImageView>(R.id.image)!!
+}
diff --git a/fragment/integration-tests/testapp/src/main/res/layouts/kittenFragmentTransitions/drawable-hdpi/placekitten_1.jpeg b/fragment/integration-tests/testapp/src/main/res/layouts/kittenFragmentTransitions/drawable-hdpi/placekitten_1.jpeg
new file mode 100644
index 0000000..84379fe
--- /dev/null
+++ b/fragment/integration-tests/testapp/src/main/res/layouts/kittenFragmentTransitions/drawable-hdpi/placekitten_1.jpeg
Binary files differ
diff --git a/fragment/integration-tests/testapp/src/main/res/layouts/kittenFragmentTransitions/drawable-hdpi/placekitten_2.jpeg b/fragment/integration-tests/testapp/src/main/res/layouts/kittenFragmentTransitions/drawable-hdpi/placekitten_2.jpeg
new file mode 100644
index 0000000..6478594
--- /dev/null
+++ b/fragment/integration-tests/testapp/src/main/res/layouts/kittenFragmentTransitions/drawable-hdpi/placekitten_2.jpeg
Binary files differ
diff --git a/fragment/integration-tests/testapp/src/main/res/layouts/kittenFragmentTransitions/drawable-hdpi/placekitten_3.jpeg b/fragment/integration-tests/testapp/src/main/res/layouts/kittenFragmentTransitions/drawable-hdpi/placekitten_3.jpeg
new file mode 100644
index 0000000..17c3b64
--- /dev/null
+++ b/fragment/integration-tests/testapp/src/main/res/layouts/kittenFragmentTransitions/drawable-hdpi/placekitten_3.jpeg
Binary files differ
diff --git a/fragment/integration-tests/testapp/src/main/res/layouts/kittenFragmentTransitions/drawable-hdpi/placekitten_4.jpeg b/fragment/integration-tests/testapp/src/main/res/layouts/kittenFragmentTransitions/drawable-hdpi/placekitten_4.jpeg
new file mode 100644
index 0000000..962d45e
--- /dev/null
+++ b/fragment/integration-tests/testapp/src/main/res/layouts/kittenFragmentTransitions/drawable-hdpi/placekitten_4.jpeg
Binary files differ
diff --git a/fragment/integration-tests/testapp/src/main/res/layouts/kittenFragmentTransitions/drawable-hdpi/placekitten_5.jpeg b/fragment/integration-tests/testapp/src/main/res/layouts/kittenFragmentTransitions/drawable-hdpi/placekitten_5.jpeg
new file mode 100644
index 0000000..ea3b455
--- /dev/null
+++ b/fragment/integration-tests/testapp/src/main/res/layouts/kittenFragmentTransitions/drawable-hdpi/placekitten_5.jpeg
Binary files differ
diff --git a/fragment/integration-tests/testapp/src/main/res/layouts/kittenFragmentTransitions/drawable-hdpi/placekitten_6.jpeg b/fragment/integration-tests/testapp/src/main/res/layouts/kittenFragmentTransitions/drawable-hdpi/placekitten_6.jpeg
new file mode 100644
index 0000000..82880fa
--- /dev/null
+++ b/fragment/integration-tests/testapp/src/main/res/layouts/kittenFragmentTransitions/drawable-hdpi/placekitten_6.jpeg
Binary files differ
diff --git a/fragment/integration-tests/testapp/src/main/res/layouts/kittenFragmentTransitions/layout/kitten_activity_main.xml b/fragment/integration-tests/testapp/src/main/res/layouts/kittenFragmentTransitions/layout/kitten_activity_main.xml
new file mode 100644
index 0000000..b75a2ba
--- /dev/null
+++ b/fragment/integration-tests/testapp/src/main/res/layouts/kittenFragmentTransitions/layout/kitten_activity_main.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+ -->
+
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingStart="@dimen/screen_padding_sides"
+ android:paddingLeft="@dimen/screen_padding_sides">
+ <RadioGroup
+ android:id="@+id/Group1"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentStart="true"
+ android:layout_alignParentTop="true">
+
+
+ <RadioButton
+ android:id="@+id/radioButton1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:checked="true"
+ android:text="Replace" />
+
+ <RadioButton
+ android:id="@+id/radioButton2"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="add/show/hide" />
+ </RadioGroup>
+
+ <androidx.fragment.app.FragmentContainerView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:name="androidx.fragment.testapp.kittenfragmenttransitions.GridFragment"
+ android:id="@+id/container"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@+id/Group1"
+ android:paddingLeft="@dimen/screen_padding_sides"
+ android:paddingRight="@dimen/screen_padding_sides" />
+
+</RelativeLayout>
diff --git a/fragment/integration-tests/testapp/src/main/res/layouts/kittenFragmentTransitions/layout/kitten_details_fragment.xml b/fragment/integration-tests/testapp/src/main/res/layouts/kittenFragmentTransitions/layout/kitten_details_fragment.xml
new file mode 100644
index 0000000..677d915
--- /dev/null
+++ b/fragment/integration-tests/testapp/src/main/res/layouts/kittenFragmentTransitions/layout/kitten_details_fragment.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+ -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="center_horizontal">
+
+ <ImageView
+ android:id='@+id/image'
+ android:layout_width="@dimen/details_image_size"
+ android:layout_height="@dimen/details_image_size"
+ android:layout_marginTop="@dimen/details_top_spacing"
+ android:scaleType="centerCrop"
+ android:transitionName="kittenImage"
+ tools:ignore="ContentDescription,UnusedAttribute" />
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/details_title_text"/>
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/details_body_text"/>
+
+</LinearLayout>
diff --git a/fragment/integration-tests/testapp/src/main/res/layouts/kittenFragmentTransitions/layout/kitten_fragment_grid.xml b/fragment/integration-tests/testapp/src/main/res/layouts/kittenFragmentTransitions/layout/kitten_fragment_grid.xml
new file mode 100644
index 0000000..f6ec57a
--- /dev/null
+++ b/fragment/integration-tests/testapp/src/main/res/layouts/kittenFragmentTransitions/layout/kitten_fragment_grid.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+ -->
+
+<androidx.recyclerview.widget.RecyclerView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/recyclerview"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:clipChildren="false" />
diff --git a/fragment/integration-tests/testapp/src/main/res/layouts/kittenFragmentTransitions/layout/kitten_grid_item.xml b/fragment/integration-tests/testapp/src/main/res/layouts/kittenFragmentTransitions/layout/kitten_grid_item.xml
new file mode 100644
index 0000000..977a7f1
--- /dev/null
+++ b/fragment/integration-tests/testapp/src/main/res/layouts/kittenFragmentTransitions/layout/kitten_grid_item.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+ -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:padding="@dimen/kitten_preview_padding"
+ android:clipToPadding="false">
+
+ <ImageView
+ android:id="@+id/image"
+ android:layout_width="@dimen/kitten_preview_size"
+ android:layout_height="@dimen/kitten_preview_size"
+ android:scaleType="centerCrop"
+ tools:ignore="ContentDescription" />
+
+</LinearLayout>
diff --git a/fragment/integration-tests/testapp/src/main/res/layouts/kittenFragmentTransitions/values/dimens.xml b/fragment/integration-tests/testapp/src/main/res/layouts/kittenFragmentTransitions/values/dimens.xml
new file mode 100644
index 0000000..7166dad
--- /dev/null
+++ b/fragment/integration-tests/testapp/src/main/res/layouts/kittenFragmentTransitions/values/dimens.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+ -->
+
+<resources>
+ <!-- Screen margins -->
+ <dimen name="screen_padding_sides">16dp</dimen>
+
+ <!-- Preview (grid item) dimensions -->
+ <dimen name="kitten_preview_size">120dp</dimen>
+ <dimen name="kitten_preview_padding">16dp</dimen>
+
+ <!-- Details dimensions -->
+ <dimen name="details_image_size">240dp</dimen>
+ <dimen name="details_top_spacing">48dp</dimen>
+</resources>
diff --git a/fragment/integration-tests/testapp/src/main/res/layouts/kittenFragmentTransitions/values/strings.xml b/fragment/integration-tests/testapp/src/main/res/layouts/kittenFragmentTransitions/values/strings.xml
new file mode 100644
index 0000000..4c9d564
--- /dev/null
+++ b/fragment/integration-tests/testapp/src/main/res/layouts/kittenFragmentTransitions/values/strings.xml
@@ -0,0 +1,20 @@
+<!--
+ 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.
+ -->
+
+<resources>
+ <string name="details_title_text">Cupcake ipsum dolor</string>
+ <string name="details_body_text">Sit amet chocolate cake sweet macaroon chupa chups. Bear claw carrot cake chocolate bar biscuit chocolate cookie. Chocolate sesame snaps candy canes bear claw dragée tootsie roll.</string>
+</resources>
diff --git a/gradle.properties b/gradle.properties
index 8e610d2..4324c01 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -4,7 +4,7 @@
org.gradle.parallel=true
org.gradle.caching=true
android.builder.sdkDownload=false
-android.uniquePackageNames=true
+android.uniquePackageNames=false
android.enableAdditionalTestOutput=true
android.useAndroidX=true
# Run multiple kotlin compilations in parallel within the same project.
diff --git a/lifecycle/lifecycle-livedata-core/src/main/java/androidx/lifecycle/LiveData.java b/lifecycle/lifecycle-livedata-core/src/main/java/androidx/lifecycle/LiveData.java
index 719c8ed..1e72908 100644
--- a/lifecycle/lifecycle-livedata-core/src/main/java/androidx/lifecycle/LiveData.java
+++ b/lifecycle/lifecycle-livedata-core/src/main/java/androidx/lifecycle/LiveData.java
@@ -329,7 +329,7 @@
}
/**
- * Called when the number of active observers change to 1 from 0.
+ * Called when the number of active observers change from 0 to 1.
* <p>
* This callback can be used to know that this LiveData is being used thus should be kept
* up to date.
diff --git a/lifecycle/lifecycle-viewmodel-savedstate/src/main/java/androidx/lifecycle/SavedStateHandle.java b/lifecycle/lifecycle-viewmodel-savedstate/src/main/java/androidx/lifecycle/SavedStateHandle.java
index e5f903f..146eb52 100644
--- a/lifecycle/lifecycle-viewmodel-savedstate/src/main/java/androidx/lifecycle/SavedStateHandle.java
+++ b/lifecycle/lifecycle-viewmodel-savedstate/src/main/java/androidx/lifecycle/SavedStateHandle.java
@@ -174,9 +174,9 @@
* String defaultValue = ...; // nullable
* LiveData<String> liveData;
* if (defaultValue != null) {
- * liveData = savedStateHandle.get(KEY, defaultValue);
+ * liveData = savedStateHandle.getLiveData(KEY, defaultValue);
* } else {
- * liveData = savedStateHandle.get(KEY);
+ * liveData = savedStateHandle.getLiveData(KEY);
* }
* }</pre>
*
diff --git a/playground/.github/workflows/presubmit.yml b/playground/.github/workflows/presubmit.yml
deleted file mode 100644
index 98221f9..0000000
--- a/playground/.github/workflows/presubmit.yml
+++ /dev/null
@@ -1,52 +0,0 @@
-
-name: AndroidX Presubmits
-on:
- pull_request
-
-jobs:
- # This workflow contains a single job called "build"
- build:
- strategy:
- fail-fast: false
- matrix:
- os: [ubuntu-latest]
- # The type of runner that the job will run on
- runs-on: ${{ matrix.os }}
- # Steps represent a sequence of tasks that will be executed as part of the job
- steps:
- - name: Setup Java environment based on setup-java
- uses: actions/setup-java@v1
- with:
- java-version: '11'
- java-package: jdk
- architecture: x64
- # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- - uses: actions/checkout@v2
- # build cache
- - name: Cache
- uses: actions/cache@v1.1.2
- with:
- path: ~/.gradle/caches
- key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
- # An ordered list of keys to use for restoring the cache if no cache hit occurred for key
- restore-keys: |
- ${{ runner.os }}-gradle-
- - uses: actions/cache@v1.1.2
- with:
- path: ~/.gradle/wrapper
- key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}
- - uses: actions/cache@v1.1.2
- with:
- path: ~/.konan
- key: ${{ runner.os }}-konan
- # Runs a single command using the runners shell
- - name: build on server
- run: ./gradlew buildOnServer
- - name: Upload Results
- if: always()
- uses: actions/upload-artifact@v2
- with:
- name: artifacts
- path: ${{ DIST_DIR }}
-env:
- DIST_DIR: ${{GITHUB_WORKSPACE}}/dist
diff --git a/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/QueryExecutorTest.java b/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/QueryExecutorTest.java
index 0d3ddb0..c0d42f3 100644
--- a/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/QueryExecutorTest.java
+++ b/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/QueryExecutorTest.java
@@ -99,6 +99,7 @@
@After
public void tearDown() {
+ ArchTaskExecutor.getInstance().setDelegate(null);
mTestDatabase.close();
}
diff --git a/samples/Support7Demos/src/main/AndroidManifest.xml b/samples/Support7Demos/src/main/AndroidManifest.xml
index 4e19e24..83c3ef6 100644
--- a/samples/Support7Demos/src/main/AndroidManifest.xml
+++ b/samples/Support7Demos/src/main/AndroidManifest.xml
@@ -289,6 +289,15 @@
</intent-filter>
</activity>
+ <activity android:name=".app.AppCompatWidgetsToggleButtons"
+ android:label="@string/appcompat_widgets_toggle_buttons"
+ android:theme="@style/Theme.AppCompat.Light.DarkActionBar">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="com.example.android.supportv7.SAMPLE_CODE" />
+ </intent-filter>
+ </activity>
+
<activity android:name=".app.MenuItemIconTinting"
android:label="@string/menu_item_icon_tinting"
android:theme="@style/Theme.Custom.NoActionBar">
diff --git a/samples/Support7Demos/src/main/java/com/example/android/supportv7/app/AppCompatWidgetsToggleButtons.java b/samples/Support7Demos/src/main/java/com/example/android/supportv7/app/AppCompatWidgetsToggleButtons.java
new file mode 100644
index 0000000..ff796cb
--- /dev/null
+++ b/samples/Support7Demos/src/main/java/com/example/android/supportv7/app/AppCompatWidgetsToggleButtons.java
@@ -0,0 +1,34 @@
+/*
+ * 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.android.supportv7.app;
+
+import android.os.Bundle;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import com.example.android.supportv7.R;
+
+/**
+ * This demonstrates the styled {@link android.widget.ToggleButton} widgets in AppCompat.
+ */
+public class AppCompatWidgetsToggleButtons extends AppCompatActivity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.appcompat_widgets_toggle_buttons);
+ }
+}
diff --git a/samples/Support7Demos/src/main/res/color/background_tint.xml b/samples/Support7Demos/src/main/res/color/background_tint.xml
index ba4df5a..1718916 100644
--- a/samples/Support7Demos/src/main/res/color/background_tint.xml
+++ b/samples/Support7Demos/src/main/res/color/background_tint.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
- Copyright 2019 9The Android Open Source Project
+ 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.
@@ -16,6 +16,6 @@
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:color="#00E000"/>
- <item android:state_enabled="false" android:alpha="0.5" android:color="#00ff00"/>
- <item android:color="#00ff00"/>
+ <item android:state_enabled="false" android:alpha="0.5" android:color="#00FF00"/>
+ <item android:color="#00FF00"/>
</selector>
\ No newline at end of file
diff --git a/samples/Support7Demos/src/main/res/color/background_tint2.xml b/samples/Support7Demos/src/main/res/color/background_tint2.xml
new file mode 100644
index 0000000..915ac6e
--- /dev/null
+++ b/samples/Support7Demos/src/main/res/color/background_tint2.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+ -->
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:state_pressed="true" android:color="#CE897B"/>
+ <item android:state_enabled="false" android:alpha="0.5" android:color="#FFCBA4"/>
+ <item android:color="#FFCBA4"/>
+</selector>
\ No newline at end of file
diff --git a/samples/Support7Demos/src/main/res/layout/appcompat_widgets_toggle_buttons.xml b/samples/Support7Demos/src/main/res/layout/appcompat_widgets_toggle_buttons.xml
new file mode 100644
index 0000000..2808a0a
--- /dev/null
+++ b/samples/Support7Demos/src/main/res/layout/appcompat_widgets_toggle_buttons.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 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.
+-->
+
+<ScrollView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:padding="16dp">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Toggle regular"/>
+
+ <ToggleButton
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Toggle (tinted green)"/>
+
+ <ToggleButton
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ app:backgroundTint="@color/background_tint" />
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Toggle (tinted peach)"/>
+
+ <ToggleButton
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ app:backgroundTint="@color/background_tint2" />
+
+ </LinearLayout>
+
+</ScrollView>
\ No newline at end of file
diff --git a/samples/Support7Demos/src/main/res/values/strings.xml b/samples/Support7Demos/src/main/res/values/strings.xml
index 31e784e..8909901 100644
--- a/samples/Support7Demos/src/main/res/values/strings.xml
+++ b/samples/Support7Demos/src/main/res/values/strings.xml
@@ -78,6 +78,7 @@
<string name="appcompat_widgets_switches">AppCompat/Widgets/Switches</string>
<string name="appcompat_widgets_text_input">AppCompat/Widgets/Text Input</string>
<string name="appcompat_widgets_text_views">AppCompat/Widgets/Text Views</string>
+ <string name="appcompat_widgets_toggle_buttons">AppCompat/Widgets/Toggle Buttons</string>
<string name="action_bar_search">Search</string>
<string name="action_bar_add">Add</string>
diff --git a/testutils/testutils-runtime/src/main/java/androidx/fragment/app/TargetTracking.java b/testutils/testutils-runtime/src/main/java/androidx/fragment/app/TargetTracking.kt
similarity index 66%
rename from testutils/testutils-runtime/src/main/java/androidx/fragment/app/TargetTracking.java
rename to testutils/testutils-runtime/src/main/java/androidx/fragment/app/TargetTracking.kt
index e1b92e2..bb263a4 100644
--- a/testutils/testutils-runtime/src/main/java/androidx/fragment/app/TargetTracking.java
+++ b/testutils/testutils-runtime/src/main/java/androidx/fragment/app/TargetTracking.kt
@@ -13,34 +13,31 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package androidx.fragment.app;
+package androidx.fragment.app
-import android.graphics.Rect;
-import android.view.View;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-import java.util.ArrayList;
+import android.graphics.Rect
+import android.view.View
/**
* Used in testing to keep track of view Targets
*/
-public interface TargetTracking {
+interface TargetTracking {
/**
- * Return tracked targets in a list
+ * Return tracked exiting targets in a list
*/
- @NonNull
- ArrayList<View> getTrackedTargets();
+ val exitingTargets: List<View>
+ /**
+ * Return tracked entering targets in a list
+ */
+ val enteringTargets: List<View>
/**
* Clear all tracked targets
*/
- void clearTargets();
+ fun clearTargets()
/**
* Get the captured epicenter.
*/
- @Nullable
- Rect getCapturedEpicenter();
+ val capturedEpicenter: Rect?
}
diff --git a/transition/transition/src/androidTest/java/androidx/transition/FragmentTestUtil.kt b/transition/transition/src/androidTest/java/androidx/transition/FragmentTestUtil.kt
index c61dcf7..f5c9d31 100644
--- a/transition/transition/src/androidTest/java/androidx/transition/FragmentTestUtil.kt
+++ b/transition/transition/src/androidTest/java/androidx/transition/FragmentTestUtil.kt
@@ -104,27 +104,47 @@
return activity.findViewById(R.id.redSquare)
}
-fun verifyAndClearTransition(
- transition: TargetTracking,
- epicenter: Rect?,
- vararg expected: View
-) {
- if (epicenter == null) {
- assertThat(transition.capturedEpicenter).isNull()
- } else {
- assertThat(transition.capturedEpicenter).isEqualTo(epicenter)
+val View.boundsOnScreen: Rect
+ get() {
+ val loc = IntArray(2)
+ getLocationOnScreen(loc)
+ return Rect(loc[0], loc[1], loc[0] + width, loc[1] + height)
}
- assertThat(transition.trackedTargets).containsExactlyElementsIn(expected)
- transition.clearTargets()
+
+data class TransitionVerificationInfo(
+ var epicenter: Rect? = null,
+ val exitingViews: MutableList<View> = mutableListOf(),
+ val enteringViews: MutableList<View> = mutableListOf()
+)
+
+fun TargetTracking.verifyAndClearTransition(block: TransitionVerificationInfo.() -> Unit) {
+ val (epicenter, exitingViews, enteringViews) = TransitionVerificationInfo().apply { block() }
+
+ assertThat(exitingTargets).containsExactlyElementsIn(exitingViews)
+ assertThat(enteringTargets).containsExactlyElementsIn(enteringViews)
+ if (epicenter == null) {
+ assertThat(capturedEpicenter).isNull()
+ } else {
+ assertThat(capturedEpicenter).isEqualTo(epicenter)
+ }
+ clearTargets()
}
fun verifyNoOtherTransitions(fragment: TransitionFragment) {
- assertThat(fragment.enterTransition.targets.size).isEqualTo(0)
- assertThat(fragment.exitTransition.targets.size).isEqualTo(0)
- assertThat(fragment.reenterTransition.targets.size).isEqualTo(0)
- assertThat(fragment.returnTransition.targets.size).isEqualTo(0)
- assertThat(fragment.sharedElementEnter.targets.size).isEqualTo(0)
- assertThat(fragment.sharedElementReturn.targets.size).isEqualTo(0)
+ assertThat(fragment.enterTransition.enteringTargets.size).isEqualTo(0)
+ assertThat(fragment.enterTransition.exitingTargets.size).isEqualTo(0)
+ assertThat(fragment.exitTransition.enteringTargets.size).isEqualTo(0)
+ assertThat(fragment.exitTransition.exitingTargets.size).isEqualTo(0)
+
+ assertThat(fragment.reenterTransition.enteringTargets.size).isEqualTo(0)
+ assertThat(fragment.reenterTransition.exitingTargets.size).isEqualTo(0)
+ assertThat(fragment.returnTransition.enteringTargets.size).isEqualTo(0)
+ assertThat(fragment.returnTransition.exitingTargets.size).isEqualTo(0)
+
+ assertThat(fragment.sharedElementEnter.enteringTargets.size).isEqualTo(0)
+ assertThat(fragment.sharedElementEnter.exitingTargets.size).isEqualTo(0)
+ assertThat(fragment.sharedElementReturn.enteringTargets.size).isEqualTo(0)
+ assertThat(fragment.sharedElementReturn.exitingTargets.size).isEqualTo(0)
}
// Transition test methods end
diff --git a/transition/transition/src/androidTest/java/androidx/transition/FragmentTransitionTest.kt b/transition/transition/src/androidTest/java/androidx/transition/FragmentTransitionTest.kt
index 5308b34..0686fa1 100644
--- a/transition/transition/src/androidTest/java/androidx/transition/FragmentTransitionTest.kt
+++ b/transition/transition/src/androidTest/java/androidx/transition/FragmentTransitionTest.kt
@@ -30,6 +30,7 @@
import androidx.testutils.waitForExecution
import androidx.transition.test.R
import com.google.common.truth.Truth.assertThat
+import com.google.common.truth.Truth.assertWithMessage
import org.junit.After
import org.junit.Assert.fail
import org.junit.Before
@@ -87,7 +88,9 @@
.commit()
fragment.waitForTransition()
- verifyAndClearTransition(fragment.exitTransition, null, green, blue)
+ fragment.exitTransition.verifyAndClearTransition {
+ exitingViews += listOf(green, blue)
+ }
verifyNoOtherTransitions(fragment)
assertThat(onBackStackChangedTimes).isEqualTo(2)
@@ -96,14 +99,18 @@
fragment.waitForTransition()
val green2 = activityRule.findGreen()
val blue2 = activityRule.findBlue()
- verifyAndClearTransition(fragment.reenterTransition, null, green2, blue2)
+ fragment.reenterTransition.verifyAndClearTransition {
+ enteringViews += listOf(green2, blue2)
+ }
verifyNoOtherTransitions(fragment)
assertThat(onBackStackChangedTimes).isEqualTo(3)
// return transition
activityRule.popBackStackImmediate()
fragment.waitForTransition()
- verifyAndClearTransition(fragment.returnTransition, null, green2, blue2)
+ fragment.returnTransition.verifyAndClearTransition {
+ exitingViews += listOf(green2, blue2)
+ }
verifyNoOtherTransitions(fragment)
assertThat(onBackStackChangedTimes).isEqualTo(4)
}
@@ -144,7 +151,9 @@
// If reorder is not allowed we will get the exit Transition and the fragment will be
// added with a different view.
fragment.waitForTransition()
- verifyAndClearTransition(fragment.exitTransition, null, green, blue)
+ fragment.exitTransition.verifyAndClearTransition {
+ exitingViews += listOf(green, blue)
+ }
assertThat(onBackStackChangedTimes).isEqualTo(3)
assertThat(fragment.requireView()).isNotEqualTo(view1)
}
@@ -165,7 +174,9 @@
fragment.waitForTransition()
val blueSquare1 = activityRule.findBlue()
val greenSquare1 = activityRule.findGreen()
- verifyAndClearTransition(fragment.enterTransition, null, blueSquare1, greenSquare1)
+ fragment.enterTransition.verifyAndClearTransition {
+ enteringViews += listOf(blueSquare1, greenSquare1)
+ }
verifyNoOtherTransitions(fragment)
// Ensure that our countdown latch has been reset for the Fragment
@@ -177,6 +188,12 @@
.addToBackStack(null)
.commit()
activityRule.waitForExecution()
+
+ assertWithMessage("Timed out waiting for onDestroyView")
+ .that(fragment.onDestroyViewCountDownLatch.await(1, TimeUnit.SECONDS))
+ .isTrue()
+ // Ensure all transitions have been executed before onDestroyView was called
+ assertThat(fragment.transitionCountInOnDestroyView).isEqualTo(0)
}
// Test that shared elements transition from one fragment to the next
@@ -194,6 +211,23 @@
verifyPopTransition(1, fragment2, fragment1)
}
+ // Test that shared elements transition from one fragment to the next
+ // and back during pop.
+ @Suppress("DEPRECATION")
+ @Test
+ fun sharedElementWithTargetFragment() {
+ val fragment1 = setupInitialFragment()
+
+ // Now do a transition to scene2
+ val fragment2 = TransitionFragment(R.layout.fragment_scene2)
+ fragment2.setTargetFragment(fragment1, 13)
+
+ verifyTransition(fragment1, fragment2, "blueSquare")
+
+ // Now pop the back stack
+ verifyPopTransition(1, fragment2, fragment1)
+ }
+
// Test that shared element transitions through multiple fragments work together
@Test
fun intermediateFragment() {
@@ -237,8 +271,12 @@
fragment2.waitForTransition()
val endBlue = activityRule.findBlue()
val endGreen = activityRule.findGreen()
- verifyAndClearTransition(fragment1.exitTransition, null, startBlue, startGreen)
- verifyAndClearTransition(fragment2.enterTransition, null, endBlue, endGreen)
+ fragment1.exitTransition.verifyAndClearTransition {
+ exitingViews += listOf(startBlue, startGreen)
+ }
+ fragment2.enterTransition.verifyAndClearTransition {
+ enteringViews += listOf(endBlue, endGreen)
+ }
verifyNoOtherTransitions(fragment1)
verifyNoOtherTransitions(fragment2)
@@ -250,8 +288,12 @@
fragment2.waitForTransition()
val popBlue = activityRule.findBlue()
val popGreen = activityRule.findGreen()
- verifyAndClearTransition(fragment1.reenterTransition, null, popBlue, popGreen)
- verifyAndClearTransition(fragment2.returnTransition, null, endBlue, endGreen)
+ fragment1.reenterTransition.verifyAndClearTransition {
+ enteringViews += listOf(popBlue, popGreen)
+ }
+ fragment2.returnTransition.verifyAndClearTransition {
+ exitingViews += listOf(endBlue, endGreen)
+ }
verifyNoOtherTransitions(fragment1)
verifyNoOtherTransitions(fragment2)
}
@@ -274,12 +316,16 @@
fragment1.waitForTransition()
val greenSquare1 = findViewById(fragment1, R.id.greenSquare)
val blueSquare1 = findViewById(fragment1, R.id.blueSquare)
- verifyAndClearTransition(fragment1.enterTransition, null, greenSquare1, blueSquare1)
+ fragment1.enterTransition.verifyAndClearTransition {
+ enteringViews += listOf(greenSquare1, blueSquare1)
+ }
verifyNoOtherTransitions(fragment1)
fragment2.waitForTransition()
val greenSquare2 = findViewById(fragment2, R.id.greenSquare)
val blueSquare2 = findViewById(fragment2, R.id.blueSquare)
- verifyAndClearTransition(fragment2.enterTransition, null, greenSquare2, blueSquare2)
+ fragment2.enterTransition.verifyAndClearTransition {
+ enteringViews += listOf(greenSquare2, blueSquare2)
+ }
verifyNoOtherTransitions(fragment2)
// Make sure the correct transitions are run when the target names
@@ -370,7 +416,7 @@
val startBlue = activityRule.findBlue()
val startGreen = activityRule.findGreen()
- val startGreenBounds = getBoundsOnScreen(startGreen)
+ val startGreenBounds = startGreen.boundsOnScreen
val mapOut = object : SharedElementCallback() {
override fun onMapSharedElements(
@@ -398,12 +444,13 @@
fragment2.waitForTransition()
val endBlue = activityRule.findBlue()
- val endBlueBounds = getBoundsOnScreen(endBlue)
+ val endBlueBounds = endBlue.boundsOnScreen
- verifyAndClearTransition(
- fragment2.sharedElementEnter, startGreenBounds, startGreen,
- endBlue
- )
+ fragment2.sharedElementEnter.verifyAndClearTransition {
+ epicenter = startGreenBounds
+ exitingViews += startGreen
+ enteringViews += endBlue
+ }
val mapBack = object : SharedElementCallback() {
override fun onMapSharedElements(
@@ -427,8 +474,11 @@
fragment2.waitForTransition()
val reenterGreen = activityRule.findGreen()
- verifyAndClearTransition(
- fragment2.sharedElementReturn, endBlueBounds, endBlue, reenterGreen)
+ fragment2.sharedElementReturn.verifyAndClearTransition {
+ epicenter = endBlueBounds
+ exitingViews += endBlue
+ enteringViews += reenterGreen
+ }
}
// Make sure that onMapSharedElement works to change the shared element target
@@ -440,7 +490,7 @@
val fragment2 = TransitionFragment(R.layout.fragment_scene2)
val startBlue = activityRule.findBlue()
- val startBlueBounds = getBoundsOnScreen(startBlue)
+ val startBlueBounds = startBlue.boundsOnScreen
val mapIn = object : SharedElementCallback() {
override fun onMapSharedElements(
@@ -471,12 +521,13 @@
val endGreen = activityRule.findGreen()
val endBlue = activityRule.findBlue()
- val endGreenBounds = getBoundsOnScreen(endGreen)
+ val endGreenBounds = endGreen.boundsOnScreen
- verifyAndClearTransition(
- fragment2.sharedElementEnter, startBlueBounds, startBlue,
- endGreen
- )
+ fragment2.sharedElementEnter.verifyAndClearTransition {
+ epicenter = startBlueBounds
+ exitingViews += startBlue
+ enteringViews += endGreen
+ }
val mapBack = object : SharedElementCallback() {
override fun onMapSharedElements(
@@ -498,10 +549,11 @@
fragment2.waitForTransition()
val reenterBlue = activityRule.findBlue()
- verifyAndClearTransition(
- fragment2.sharedElementReturn, endGreenBounds, endGreen,
- reenterBlue
- )
+ fragment2.sharedElementReturn.verifyAndClearTransition {
+ epicenter = endGreenBounds
+ exitingViews += endGreen
+ enteringViews += reenterBlue
+ }
}
// Ensure that shared element transitions that have targets properly target the views
@@ -514,7 +566,7 @@
val startBlue = activityRule.findBlue()
val startGreen = activityRule.findGreen()
- val startBlueBounds = getBoundsOnScreen(startBlue)
+ val startBlueBounds = startBlue.boundsOnScreen
fragmentManager.beginTransaction()
.addSharedElement(startBlue, "blueSquare")
@@ -531,16 +583,18 @@
val endBlue = activityRule.findBlue()
val endGreen = activityRule.findGreen()
- val endBlueBounds = getBoundsOnScreen(endBlue)
+ val endBlueBounds = endBlue.boundsOnScreen
- verifyAndClearTransition(
- fragment2.sharedElementEnterTransition1, startBlueBounds,
- startBlue, endBlue
- )
- verifyAndClearTransition(
- fragment2.sharedElementEnterTransition2, startBlueBounds,
- startGreen, endGreen
- )
+ fragment2.sharedElementEnterTransition1.verifyAndClearTransition {
+ epicenter = startBlueBounds
+ exitingViews += startBlue
+ enteringViews += endBlue
+ }
+ fragment2.sharedElementEnterTransition2.verifyAndClearTransition {
+ epicenter = startBlueBounds
+ exitingViews += startGreen
+ enteringViews += endGreen
+ }
// Now see if it works when popped
activityRule.popBackStackImmediate()
@@ -552,14 +606,16 @@
val reenterBlue = activityRule.findBlue()
val reenterGreen = activityRule.findGreen()
- verifyAndClearTransition(
- fragment2.sharedElementReturnTransition1, endBlueBounds,
- endBlue, reenterBlue
- )
- verifyAndClearTransition(
- fragment2.sharedElementReturnTransition2, endBlueBounds,
- endGreen, reenterGreen
- )
+ fragment2.sharedElementReturnTransition1.verifyAndClearTransition {
+ epicenter = endBlueBounds
+ exitingViews += endBlue
+ enteringViews += reenterBlue
+ }
+ fragment2.sharedElementReturnTransition2.verifyAndClearTransition {
+ epicenter = endBlueBounds
+ exitingViews += endGreen
+ enteringViews += reenterGreen
+ }
}
// Ensure that after transitions have executed that they don't have any targets or other
@@ -572,9 +628,9 @@
val fragment2 = TransitionFragment(R.layout.fragment_scene2)
verifyTransition(fragment1, fragment2, "blueSquare")
- assertThat(fragment1.exitTransition.getTargets().size).isEqualTo(0)
- assertThat(fragment2.sharedElementEnter.getTargets().size).isEqualTo(0)
- assertThat(fragment2.enterTransition.getTargets().size).isEqualTo(0)
+ assertThat(fragment1.exitTransition.targets.size).isEqualTo(0)
+ assertThat(fragment2.sharedElementEnter.targets.size).isEqualTo(0)
+ assertThat(fragment2.enterTransition.targets.size).isEqualTo(0)
assertThat(fragment1.exitTransition.epicenterCallback).isNull()
assertThat(fragment2.enterTransition.epicenterCallback).isNull()
assertThat(fragment2.sharedElementEnter.epicenterCallback).isNull()
@@ -582,9 +638,9 @@
// Now pop the back stack
verifyPopTransition(1, fragment2, fragment1)
- assertThat(fragment2.returnTransition.getTargets().size).isEqualTo(0)
- assertThat(fragment2.sharedElementReturn.getTargets().size).isEqualTo(0)
- assertThat(fragment1.reenterTransition.getTargets().size).isEqualTo(0)
+ assertThat(fragment2.returnTransition.targets.size).isEqualTo(0)
+ assertThat(fragment2.sharedElementReturn.targets.size).isEqualTo(0)
+ assertThat(fragment1.reenterTransition.targets.size).isEqualTo(0)
assertThat(fragment2.returnTransition.epicenterCallback).isNull()
assertThat(fragment2.sharedElementReturn.epicenterCallback).isNull()
assertThat(fragment2.reenterTransition.epicenterCallback).isNull()
@@ -627,10 +683,14 @@
assertThat(startGreen.visibility).isEqualTo(View.VISIBLE)
assertThat(startBlue.visibility).isEqualTo(View.VISIBLE)
- verifyAndClearTransition(fragment1.exitTransition, null, startGreen, startBlue)
+ fragment1.exitTransition.verifyAndClearTransition {
+ exitingViews += listOf(startGreen, startBlue)
+ }
verifyNoOtherTransitions(fragment1)
- verifyAndClearTransition(fragment2.enterTransition, null, endGreen, endBlue)
+ fragment2.enterTransition.verifyAndClearTransition {
+ enteringViews += listOf(endGreen, endBlue)
+ }
verifyNoOtherTransitions(fragment2)
activityRule.popBackStackImmediate()
@@ -639,14 +699,18 @@
fragment1.waitForTransition()
fragment2.waitForTransition()
- verifyAndClearTransition(fragment1.reenterTransition, null, startGreen, startBlue)
+ fragment1.reenterTransition.verifyAndClearTransition {
+ enteringViews += listOf(startGreen, startBlue)
+ }
verifyNoOtherTransitions(fragment1)
assertThat(fragment1.requireView().visibility).isEqualTo(View.VISIBLE)
assertThat(startGreen.visibility).isEqualTo(View.VISIBLE)
assertThat(startBlue.visibility).isEqualTo(View.VISIBLE)
- verifyAndClearTransition(fragment2.returnTransition, null, endGreen, endBlue)
+ fragment2.returnTransition.verifyAndClearTransition {
+ exitingViews += listOf(endGreen, endBlue)
+ }
verifyNoOtherTransitions(fragment2)
}
@@ -671,10 +735,14 @@
val endGreen = findViewById(fragment2, R.id.greenSquare)
val endBlue = findViewById(fragment2, R.id.blueSquare)
- verifyAndClearTransition(fragment1.exitTransition, null, startGreen, startBlue)
+ fragment1.exitTransition.verifyAndClearTransition {
+ exitingViews += listOf(startGreen, startBlue)
+ }
verifyNoOtherTransitions(fragment1)
- verifyAndClearTransition(fragment2.enterTransition, null, endGreen, endBlue)
+ fragment2.enterTransition.verifyAndClearTransition {
+ enteringViews += listOf(endGreen, endBlue)
+ }
verifyNoOtherTransitions(fragment2)
activityRule.popBackStackImmediate()
@@ -684,10 +752,14 @@
val reenterBlue = activityRule.findBlue()
val reenterGreen = activityRule.findGreen()
- verifyAndClearTransition(fragment1.reenterTransition, null, reenterGreen, reenterBlue)
+ fragment1.reenterTransition.verifyAndClearTransition {
+ enteringViews += listOf(reenterGreen, reenterBlue)
+ }
verifyNoOtherTransitions(fragment1)
- verifyAndClearTransition(fragment2.returnTransition, null, endGreen, endBlue)
+ fragment2.returnTransition.verifyAndClearTransition {
+ exitingViews += listOf(endGreen, endBlue)
+ }
verifyNoOtherTransitions(fragment2)
}
@@ -697,11 +769,11 @@
val fragment1 = setupInitialFragment()
// Now do a transition to scene2
- val fragment2 = TransitionFragment(R.layout.fragment_scene2)
+ val fragment2 = TransitionFragment(R.layout.scene2)
val startBlue = activityRule.findBlue()
val startGreen = activityRule.findGreen()
- val startBlueBounds = getBoundsOnScreen(startBlue)
+ val startBlueBounds = startBlue.boundsOnScreen
fragmentManager.beginTransaction()
.addSharedElement(startBlue, "fooSquare")
@@ -718,14 +790,24 @@
val endGreen = activityRule.findGreen()
if (reorderingAllowed) {
- verifyAndClearTransition(fragment1.exitTransition, null, startGreen, startBlue)
+ fragment1.exitTransition.verifyAndClearTransition {
+ exitingViews += listOf(startGreen, startBlue)
+ }
} else {
- verifyAndClearTransition(fragment1.exitTransition, startBlueBounds, startGreen)
- verifyAndClearTransition(fragment2.sharedElementEnter, startBlueBounds, startBlue)
+ fragment1.exitTransition.verifyAndClearTransition {
+ epicenter = startBlueBounds
+ exitingViews += startGreen
+ }
+ fragment2.sharedElementEnter.verifyAndClearTransition {
+ epicenter = startBlueBounds
+ exitingViews += startBlue
+ }
}
verifyNoOtherTransitions(fragment1)
- verifyAndClearTransition(fragment2.enterTransition, null, endGreen, endBlue)
+ fragment2.enterTransition.verifyAndClearTransition {
+ enteringViews += listOf(endGreen, endBlue)
+ }
verifyNoOtherTransitions(fragment2)
}
@@ -803,7 +885,7 @@
val startBlue = activityRule.findBlue()
val startGreen = activityRule.findGreen()
- val startBlueBounds = getBoundsOnScreen(startBlue)
+ val startBlueBounds = startBlue.boundsOnScreen
val fragment2 = TransitionFragment(R.layout.fragment_scene2)
@@ -818,10 +900,20 @@
fragment2.waitForTransition()
val midGreen = activityRule.findGreen()
val midBlue = activityRule.findBlue()
- val midBlueBounds = getBoundsOnScreen(midBlue)
- verifyAndClearTransition(fragment1.exitTransition, startBlueBounds, startGreen)
- verifyAndClearTransition(fragment2.sharedElementEnter, startBlueBounds, startBlue, midBlue)
- verifyAndClearTransition(fragment2.enterTransition, midBlueBounds, midGreen)
+ val midBlueBounds = midBlue.boundsOnScreen
+ fragment1.exitTransition.verifyAndClearTransition {
+ epicenter = startBlueBounds
+ exitingViews += startGreen
+ }
+ fragment2.sharedElementEnter.verifyAndClearTransition {
+ epicenter = startBlueBounds
+ exitingViews += startBlue
+ enteringViews += midBlue
+ }
+ fragment2.enterTransition.verifyAndClearTransition {
+ epicenter = midBlueBounds
+ enteringViews += midGreen
+ }
verifyNoOtherTransitions(fragment1)
verifyNoOtherTransitions(fragment2)
@@ -845,11 +937,15 @@
if (reorderingAllowed) {
// reordering allowed fragment3 to get a transition so we should wait for it to finish
fragment3.waitForTransition()
- verifyAndClearTransition(fragment2.returnTransition, null, midGreen, midBlue)
+ fragment2.returnTransition.verifyAndClearTransition {
+ exitingViews += listOf(midGreen, midBlue)
+ }
val endGreen = activityRule.findGreen()
val endBlue = activityRule.findBlue()
val endRed = activityRule.findRed()
- verifyAndClearTransition(fragment3.enterTransition, null, endGreen, endBlue, endRed!!)
+ fragment3.enterTransition.verifyAndClearTransition {
+ enteringViews += listOfNotNull(endGreen, endBlue, endRed)
+ }
verifyNoOtherTransitions(fragment2)
verifyNoOtherTransitions(fragment3)
} else {
@@ -870,7 +966,7 @@
val startBlue = activityRule.findBlue()
val startGreen = activityRule.findGreen()
- val startGreenBounds = getBoundsOnScreen(startGreen)
+ val startGreenBounds = startGreen.boundsOnScreen
val fragment2 = TransitionFragment(R.layout.fragment_scene2)
@@ -891,11 +987,21 @@
// It does not transition properly for ordered transactions, though.
if (reorderingAllowed) {
- verifyAndClearTransition(fragment1.returnTransition, null, startGreen)
+ fragment1.returnTransition.verifyAndClearTransition {
+ exitingViews += startGreen
+ }
val endGreen = activityRule.findGreen()
- verifyAndClearTransition(fragment2.enterTransition, startGreenBounds, endGreen)
- assertThat(fragment2.sharedElementEnter.targets.size).isEqualTo(2)
- fragment2.sharedElementEnter.clearTargets()
+ val endBlue = activityRule.findBlue()
+ fragment2.enterTransition.verifyAndClearTransition {
+ epicenter = startGreenBounds
+ enteringViews += endGreen
+ }
+ fragment2.sharedElementEnter.verifyAndClearTransition {
+ // In this case, we can't find an epicenter
+ epicenter = Rect()
+ exitingViews += startBlue
+ enteringViews += endBlue
+ }
verifyNoOtherTransitions(fragment1)
verifyNoOtherTransitions(fragment2)
} else {
@@ -913,7 +1019,7 @@
val startBlue = activityRule.findBlue()
val startGreen = activityRule.findGreen()
- val startGreenBounds = getBoundsOnScreen(startGreen)
+ val startGreenBounds = startGreen.boundsOnScreen
val fragment2 = TransitionFragment(R.layout.fragment_scene3)
@@ -929,19 +1035,24 @@
val midGreen = activityRule.findGreen()
val midBlue = activityRule.findBlue()
val midRed = activityRule.findRed()
- val midGreenBounds = getBoundsOnScreen(midGreen)
+ val midGreenBounds = midGreen.boundsOnScreen
if (reorderingAllowed) {
- verifyAndClearTransition(
- fragment2.sharedElementEnter, startGreenBounds, startGreen,
- midGreen
- )
+ fragment2.sharedElementEnter.verifyAndClearTransition {
+ epicenter = startGreenBounds
+ exitingViews += startGreen
+ enteringViews += midGreen
+ }
} else {
- verifyAndClearTransition(
- fragment2.sharedElementEnter, startGreenBounds, startGreen,
- midGreen, startBlue
- )
+ fragment2.sharedElementEnter.verifyAndClearTransition {
+ epicenter = startGreenBounds
+ exitingViews += listOf(startGreen, startBlue)
+ enteringViews += midGreen
+ }
}
- verifyAndClearTransition(fragment2.enterTransition, midGreenBounds, midBlue, midRed!!)
+ fragment2.enterTransition.verifyAndClearTransition {
+ epicenter = midGreenBounds
+ enteringViews += listOfNotNull(midBlue, midRed)
+ }
verifyNoOtherTransitions(fragment2)
activityRule.popBackStackImmediate()
@@ -967,7 +1078,9 @@
fragment1.waitForTransition()
val blueSquare1 = activityRule.findBlue()
val greenSquare1 = activityRule.findGreen()
- verifyAndClearTransition(fragment1.enterTransition, null, blueSquare1, greenSquare1)
+ fragment1.enterTransition.verifyAndClearTransition {
+ enteringViews += listOf(blueSquare1, greenSquare1)
+ }
verifyNoOtherTransitions(fragment1)
return fragment1
}
@@ -986,7 +1099,7 @@
val startGreen = activityRule.findGreen()
val startRed = activityRule.findRed()
- val startBlueRect = getBoundsOnScreen(startBlue)
+ val startBlueRect = startBlue.boundsOnScreen
fragmentManager.beginTransaction()
.setReorderingAllowed(reorderingAllowed)
@@ -1002,21 +1115,24 @@
val endGreen = activityRule.findGreen()
val endBlue = activityRule.findBlue()
val endRed = activityRule.findRed()
- val endBlueRect = getBoundsOnScreen(endBlue)
+ val endBlueRect = endBlue.boundsOnScreen
- if (startRed != null) {
- verifyAndClearTransition(from.exitTransition, startBlueRect, startGreen, startRed)
- } else {
- verifyAndClearTransition(from.exitTransition, startBlueRect, startGreen)
+ from.exitTransition.verifyAndClearTransition {
+ epicenter = startBlueRect
+ exitingViews += listOfNotNull(startGreen, startRed)
}
verifyNoOtherTransitions(from)
- if (endRed != null) {
- verifyAndClearTransition(to.enterTransition, endBlueRect, endGreen, endRed)
- } else {
- verifyAndClearTransition(to.enterTransition, endBlueRect, endGreen)
+ to.enterTransition.verifyAndClearTransition {
+ epicenter = endBlueRect
+ enteringViews += listOfNotNull(endGreen, endRed)
}
- verifyAndClearTransition(to.sharedElementEnter, startBlueRect, startBlue, endBlue)
+
+ to.sharedElementEnter.verifyAndClearTransition {
+ epicenter = startBlueRect
+ exitingViews += startBlue
+ enteringViews += endBlue
+ }
verifyNoOtherTransitions(to)
}
@@ -1033,13 +1149,13 @@
val fromExit1 = findViewById(from1, R.id.greenSquare)
val fromShared1 = findViewById(from1, R.id.blueSquare)
- val fromSharedRect1 = getBoundsOnScreen(fromShared1)
+ val fromSharedRect1 = fromShared1.boundsOnScreen
val fromExitId2 = if (swapSource) R.id.blueSquare else R.id.greenSquare
val fromSharedId2 = if (swapSource) R.id.greenSquare else R.id.blueSquare
val fromExit2 = findViewById(from2, fromExitId2)
val fromShared2 = findViewById(from2, fromSharedId2)
- val fromSharedRect2 = getBoundsOnScreen(fromShared2)
+ val fromSharedRect2 = fromShared2.boundsOnScreen
val sharedElementName = if (swapSource) "blueSquare" else "greenSquare"
@@ -1068,21 +1184,41 @@
val toEnter1 = findViewById(to1, R.id.greenSquare)
val toShared1 = findViewById(to1, R.id.blueSquare)
- val toSharedRect1 = getBoundsOnScreen(toShared1)
+ val toSharedRect1 = toShared1.boundsOnScreen
val toEnter2 = findViewById(to2, fromSharedId2)
val toShared2 = findViewById(to2, fromExitId2)
- val toSharedRect2 = getBoundsOnScreen(toShared2)
+ val toSharedRect2 = toShared2.boundsOnScreen
- verifyAndClearTransition(from1.exitTransition, fromSharedRect1, fromExit1)
- verifyAndClearTransition(from2.exitTransition, fromSharedRect2, fromExit2)
+ from1.exitTransition.verifyAndClearTransition {
+ epicenter = fromSharedRect1
+ exitingViews += fromExit1
+ }
+ from2.exitTransition.verifyAndClearTransition {
+ epicenter = fromSharedRect2
+ exitingViews += fromExit2
+ }
verifyNoOtherTransitions(from1)
verifyNoOtherTransitions(from2)
- verifyAndClearTransition(to1.enterTransition, toSharedRect1, toEnter1)
- verifyAndClearTransition(to2.enterTransition, toSharedRect2, toEnter2)
- verifyAndClearTransition(to1.sharedElementEnter, fromSharedRect1, fromShared1, toShared1)
- verifyAndClearTransition(to2.sharedElementEnter, fromSharedRect2, fromShared2, toShared2)
+ to1.enterTransition.verifyAndClearTransition {
+ epicenter = toSharedRect1
+ enteringViews += toEnter1
+ }
+ to2.enterTransition.verifyAndClearTransition {
+ epicenter = toSharedRect2
+ enteringViews += toEnter2
+ }
+ to1.sharedElementEnter.verifyAndClearTransition {
+ epicenter = fromSharedRect1
+ exitingViews += fromShared1
+ enteringViews += toShared1
+ }
+ to2.sharedElementEnter.verifyAndClearTransition {
+ epicenter = fromSharedRect2
+ exitingViews += fromShared2
+ enteringViews += toShared2
+ }
verifyNoOtherTransitions(to1)
verifyNoOtherTransitions(to2)
@@ -1106,15 +1242,35 @@
val returnEnter2 = findViewById(from2, fromExitId2)
val returnShared2 = findViewById(from2, fromSharedId2)
- verifyAndClearTransition(to1.returnTransition, toSharedRect1, toEnter1)
- verifyAndClearTransition(to2.returnTransition, toSharedRect2, toEnter2)
- verifyAndClearTransition(to1.sharedElementReturn, toSharedRect1, toShared1, returnShared1)
- verifyAndClearTransition(to2.sharedElementReturn, toSharedRect2, toShared2, returnShared2)
+ to1.returnTransition.verifyAndClearTransition {
+ epicenter = toSharedRect1
+ exitingViews += toEnter1
+ }
+ to2.returnTransition.verifyAndClearTransition {
+ epicenter = toSharedRect2
+ exitingViews += toEnter2
+ }
+ to1.sharedElementReturn.verifyAndClearTransition {
+ epicenter = toSharedRect1
+ exitingViews += toShared1
+ enteringViews += returnShared1
+ }
+ to2.sharedElementReturn.verifyAndClearTransition {
+ epicenter = toSharedRect2
+ exitingViews += toShared2
+ enteringViews += returnShared2
+ }
verifyNoOtherTransitions(to1)
verifyNoOtherTransitions(to2)
- verifyAndClearTransition(from1.reenterTransition, fromSharedRect1, returnEnter1)
- verifyAndClearTransition(from2.reenterTransition, fromSharedRect2, returnEnter2)
+ from1.reenterTransition.verifyAndClearTransition {
+ epicenter = fromSharedRect1
+ enteringViews += returnEnter1
+ }
+ from2.reenterTransition.verifyAndClearTransition {
+ epicenter = fromSharedRect2
+ enteringViews += returnEnter2
+ }
verifyNoOtherTransitions(from1)
verifyNoOtherTransitions(from2)
}
@@ -1129,7 +1285,7 @@
val startBlue = activityRule.findBlue()
val startGreen = activityRule.findGreen()
val startRed = activityRule.findRed()
- val startSharedRect = getBoundsOnScreen(startBlue)
+ val startSharedRect = startBlue.boundsOnScreen
instrumentation.runOnMainSync {
for (i in 0 until numPops) {
@@ -1143,20 +1299,22 @@
val endGreen = activityRule.findGreen()
val endBlue = activityRule.findBlue()
val endRed = activityRule.findRed()
- val endSharedRect = getBoundsOnScreen(endBlue)
+ val endSharedRect = endBlue.boundsOnScreen
- if (startRed != null) {
- verifyAndClearTransition(from.returnTransition, startSharedRect, startGreen, startRed)
- } else {
- verifyAndClearTransition(from.returnTransition, startSharedRect, startGreen)
+ from.returnTransition.verifyAndClearTransition {
+ epicenter = startSharedRect
+ exitingViews += listOfNotNull(startGreen, startRed)
}
- verifyAndClearTransition(from.sharedElementReturn, startSharedRect, startBlue, endBlue)
+ from.sharedElementReturn.verifyAndClearTransition {
+ epicenter = startSharedRect
+ exitingViews += startBlue
+ enteringViews += endBlue
+ }
verifyNoOtherTransitions(from)
- if (endRed != null) {
- verifyAndClearTransition(to.reenterTransition, endSharedRect, endGreen, endRed)
- } else {
- verifyAndClearTransition(to.reenterTransition, endSharedRect, endGreen)
+ to.reenterTransition.verifyAndClearTransition {
+ epicenter = endSharedRect
+ enteringViews += listOfNotNull(endGreen, endRed)
}
verifyNoOtherTransitions(to)
@@ -1171,10 +1329,10 @@
val sharedElementReturnTransition1 = TrackingTransition()
val sharedElementReturnTransition2 = TrackingTransition()
- val sharedElementEnterTransition: TransitionSet = TransitionSet()
+ private val sharedElementEnterTransition: TransitionSet = TransitionSet()
.addTransition(sharedElementEnterTransition1)
.addTransition(sharedElementEnterTransition2)
- val sharedElementReturnTransition: TransitionSet = TransitionSet()
+ private val sharedElementReturnTransition: TransitionSet = TransitionSet()
.addTransition(sharedElementReturnTransition1)
.addTransition(sharedElementReturnTransition2)
@@ -1196,9 +1354,12 @@
}
class TransitionFinishFirstFragment : TransitionFragment(R.layout.fragment_scene1) {
+ var onDestroyViewCountDownLatch = CountDownLatch(1)
+ var transitionCountInOnDestroyView = 0L
+
override fun onDestroyView() {
- // Ensure all transitions have been executed before onDestroyView was called
- assertThat(endTransitionCountDownLatch.count).isEqualTo(0)
+ transitionCountInOnDestroyView = endTransitionCountDownLatch.count
+ onDestroyViewCountDownLatch.countDown()
super.onDestroyView()
}
}
@@ -1226,12 +1387,6 @@
fun data(): Array<Boolean> {
return arrayOf(false, true)
}
-
- private fun getBoundsOnScreen(view: View): Rect {
- val loc = IntArray(2)
- view.getLocationOnScreen(loc)
- return Rect(loc[0], loc[1], loc[0] + view.width, loc[1] + view.height)
- }
}
}
diff --git a/transition/transition/src/androidTest/java/androidx/transition/TrackingTransition.kt b/transition/transition/src/androidTest/java/androidx/transition/TrackingTransition.kt
index 410e1b8..018d89f 100644
--- a/transition/transition/src/androidTest/java/androidx/transition/TrackingTransition.kt
+++ b/transition/transition/src/androidTest/java/androidx/transition/TrackingTransition.kt
@@ -20,8 +20,6 @@
import android.view.ViewGroup
import androidx.fragment.app.TargetTracking
-import java.util.ArrayList
-
/**
* A transition that tracks which targets are applied to it.
* It will assume any target that it applies to will have differences
@@ -35,8 +33,9 @@
* is created.
*/
class TrackingTransition : Transition(), TargetTracking {
- val targets = ArrayList<View>()
- private val baseEpicenter = Rect()
+ override val enteringTargets = mutableListOf<View>()
+ override val exitingTargets = mutableListOf<View>()
+ override val capturedEpicenter: Rect = Rect()
override fun getTransitionProperties(): Array<String> {
return PROPS
@@ -56,26 +55,20 @@
endValues: TransitionValues?
) = null.also {
if (startValues != null) {
- targets.add(startValues.view)
+ exitingTargets.add(startValues.view)
}
if (endValues != null) {
- targets.add(endValues.view)
+ enteringTargets.add(endValues.view)
}
if (epicenter != null) {
- baseEpicenter.set(Rect(epicenter))
+ capturedEpicenter.set(Rect(epicenter))
}
}
- override fun getTrackedTargets(): ArrayList<View> {
- return targets
- }
-
override fun clearTargets() {
- targets.clear()
- }
-
- override fun getCapturedEpicenter(): Rect? {
- return baseEpicenter
+ enteringTargets.clear()
+ exitingTargets.clear()
+ capturedEpicenter.set(Rect())
}
companion object {
diff --git a/transition/transition/src/androidTest/java/androidx/transition/TrackingVisibility.java b/transition/transition/src/androidTest/java/androidx/transition/TrackingVisibility.java
index 46c421e..49d7db5 100644
--- a/transition/transition/src/androidTest/java/androidx/transition/TrackingVisibility.java
+++ b/transition/transition/src/androidTest/java/androidx/transition/TrackingVisibility.java
@@ -22,9 +22,11 @@
import android.view.View;
import android.view.ViewGroup;
+import androidx.annotation.NonNull;
import androidx.fragment.app.TargetTracking;
import java.util.ArrayList;
+import java.util.List;
import java.util.concurrent.CountDownLatch;
/**
@@ -32,7 +34,8 @@
* By default, this transition does no animation.
*/
public class TrackingVisibility extends Visibility implements TargetTracking {
- public final ArrayList<View> targets = new ArrayList<>();
+ private final ArrayList<View> mEnteringTargets = new ArrayList<>();
+ private final ArrayList<View> mExitingTargets = new ArrayList<>();
private final Rect[] mEpicenter = new Rect[1];
private boolean mRealTransition;
public CountDownLatch endAnimatorCountDownLatch = new CountDownLatch(1);
@@ -44,7 +47,7 @@
@Override
public Animator onAppear(ViewGroup sceneRoot, View view, TransitionValues startValues,
TransitionValues endValues) {
- targets.add(endValues.view);
+ mEnteringTargets.add(endValues.view);
Rect epicenter = getEpicenter();
if (epicenter != null) {
mEpicenter[0] = new Rect(epicenter);
@@ -57,7 +60,7 @@
@Override
public Animator onDisappear(ViewGroup sceneRoot, View view, TransitionValues startValues,
TransitionValues endValues) {
- targets.add(startValues.view);
+ mExitingTargets.add(startValues.view);
Rect epicenter = getEpicenter();
if (epicenter != null) {
mEpicenter[0] = new Rect(epicenter);
@@ -90,14 +93,23 @@
return null;
}
+ @NonNull
@Override
- public ArrayList<View> getTrackedTargets() {
- return targets;
+ public List<View> getEnteringTargets() {
+ return mEnteringTargets;
+ }
+
+ @NonNull
+ @Override
+ public List<View> getExitingTargets() {
+ return mExitingTargets;
}
@Override
public void clearTargets() {
- targets.clear();
+ mEnteringTargets.clear();
+ mExitingTargets.clear();
+ mEpicenter[0] = null;
}
@Override
diff --git a/ui/.idea/scopes/buildSrc.xml b/ui/.idea/scopes/buildSrc.xml
new file mode 120000
index 0000000..0bf1686
--- /dev/null
+++ b/ui/.idea/scopes/buildSrc.xml
@@ -0,0 +1 @@
+.idea/scopes/buildSrc.xml
\ No newline at end of file
diff --git a/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/SpacingBenchmark.kt b/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/SpacingBenchmark.kt
index 13ed4b7..3ca2116 100644
--- a/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/SpacingBenchmark.kt
+++ b/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/SpacingBenchmark.kt
@@ -43,7 +43,6 @@
import androidx.ui.unit.ipx
import androidx.ui.unit.isFinite
import androidx.ui.unit.min
-import androidx.ui.unit.px
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
@@ -206,7 +205,7 @@
placeable?.height ?: 0.ipx
}
layout(width, height) {
- placeable?.place(0.px, 0.px)
+ placeable?.place(0.ipx, 0.ipx)
}
}
}
diff --git a/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/text/ParagraphMethodBenchmark.kt b/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/text/ParagraphMethodBenchmark.kt
index 0c211b1..f26c660 100644
--- a/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/text/ParagraphMethodBenchmark.kt
+++ b/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/text/ParagraphMethodBenchmark.kt
@@ -21,7 +21,6 @@
import androidx.test.filters.LargeTest
import androidx.ui.unit.Density
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.px
import androidx.ui.unit.sp
import androidx.ui.integration.test.RandomTextGenerator
import androidx.ui.integration.test.TextBenchmarkTestRule
@@ -165,7 +164,7 @@
fun getOffsetForPosition() {
textBenchmarkRule.generator { generator ->
val paragraph = paragraph(generator)
- val centerPosition = PxPosition((paragraph.width / 2).px, (paragraph.height / 2).px)
+ val centerPosition = PxPosition((paragraph.width / 2), (paragraph.height / 2))
benchmarkRule.measureRepeated {
paragraph.getOffsetForPosition(centerPosition)
}
diff --git a/ui/integration-tests/demos/src/androidTest/java/androidx/ui/demos/test/DemoTest.kt b/ui/integration-tests/demos/src/androidTest/java/androidx/ui/demos/test/DemoTest.kt
index 083bf34..6ea78e1 100644
--- a/ui/integration-tests/demos/src/androidTest/java/androidx/ui/demos/test/DemoTest.kt
+++ b/ui/integration-tests/demos/src/androidTest/java/androidx/ui/demos/test/DemoTest.kt
@@ -17,6 +17,7 @@
package androidx.ui.demos.test
import androidx.test.espresso.Espresso
+import androidx.test.filters.MediumTest
import androidx.test.filters.LargeTest
import androidx.ui.demos.AllDemosCategory
import androidx.ui.demos.DemoActivity
@@ -38,23 +39,31 @@
import androidx.ui.test.hasClickAction
import androidx.ui.test.hasText
import androidx.ui.test.isDialog
+import androidx.ui.test.waitForIdle
import com.google.common.truth.Truth.assertThat
+import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
-@LargeTest
@RunWith(JUnit4::class)
class DemoTest {
@get:Rule
- val composeTestRule = AndroidComposeTestRule<DemoActivity>(disableTransitions = true)
+ val composeTestRule = AndroidComposeTestRule<DemoActivity>(disableTransitions = true).also {
+ it.clockTestRule.pauseClock()
+ }
+ @Ignore("Flaky test: 'Animation clock still has observer(s) after it is disposed.'")
+ @MediumTest
@Test
fun testFiltering() {
assertIsOnRootScreen()
// Enter filtering mode
findByTag(Tags.FilterButton).doClick()
+ waitForIdle()
+
+ composeTestRule.clockTestRule.advanceClock(5000)
// TODO: use keyboard input APIs when available to actually filter the list
val testDemo = AllDemosCategory.allLaunchableDemos()
// ActivityDemos don't set the title in the AppBar, so we can't verify if we've
@@ -65,11 +74,31 @@
// Click on the first demo
val demoTitle = testDemo.title
findByText(demoTitle).doScrollTo().doClick()
+ waitForIdle()
+
assertAppBarHasTitle(demoTitle)
Espresso.pressBack()
assertIsOnRootScreen()
+ waitForIdle()
+
+ composeTestRule.clockTestRule.advanceClock(5000)
+ waitForIdle()
}
+ @MediumTest
+ @Test
+ fun navigateThroughOneDemo() {
+ // Keep track of each demo we visit
+ val visitedDemos = mutableListOf<Demo>()
+
+ // Visit all demos, ensuring we start and end up on the root screen
+ assertIsOnRootScreen()
+ AllDemosCategory.visitFirstDemo(visitedDemos = visitedDemos,
+ path = listOf(AllDemosCategory))
+ assertIsOnRootScreen()
+ }
+
+ @LargeTest
@Test
fun navigateThroughAllDemos() {
// Keep track of each demo we visit
@@ -77,7 +106,8 @@
// Visit all demos, ensuring we start and end up on the root screen
assertIsOnRootScreen()
- AllDemosCategory.visitDemos(visitedDemos = visitedDemos, path = listOf(AllDemosCategory))
+ AllDemosCategory.visitDemos(visitedDemos = visitedDemos,
+ path = listOf(AllDemosCategory))
assertIsOnRootScreen()
// Ensure that we visited all the demos we expected to, in the order we expected to.
@@ -89,13 +119,24 @@
*
* @param path The path of categories that leads to this demo
*/
- private fun DemoCategory.visitDemos(visitedDemos: MutableList<Demo>, path: List<DemoCategory>) {
+ private fun DemoCategory.visitDemos(
+ visitedDemos: MutableList<Demo>,
+ path: List<DemoCategory>
+ ) {
demos.forEach { demo ->
visitedDemos.add(demo)
- demo.visit(visitedDemos, path)
+ demo.visit(visitedDemos, path, true)
}
}
+ private fun DemoCategory.visitFirstDemo(
+ visitedDemos: MutableList<Demo>,
+ path: List<DemoCategory>
+ ) {
+ visitedDemos.add(demos[0])
+ demos[0].visit(visitedDemos, path, false)
+ }
+
/**
* Visits a [Demo], and then navigates back up to the [DemoCategory] it was inside.
*
@@ -104,7 +145,11 @@
*
* @param path The path of categories that leads to this demo
*/
- private fun Demo.visit(visitedDemos: MutableList<Demo>, path: List<DemoCategory>) {
+ private fun Demo.visit(
+ visitedDemos: MutableList<Demo>,
+ path: List<DemoCategory>,
+ visitAll: Boolean
+ ) {
val navigationTitle = if (path.size == 1) {
path.first().title
} else {
@@ -116,18 +161,30 @@
.doScrollTo()
.doClick()
+ waitForIdle()
+ composeTestRule.clockTestRule.advanceClock(5000)
+
if (this is DemoCategory) {
- visitDemos(visitedDemos, path + this)
+ if (visitAll) {
+ visitDemos(visitedDemos, path + this)
+ } else {
+ visitFirstDemo(visitedDemos, path + this)
+ }
}
// Don't `findAll` in WebComponentActivity, it doesn't have an AndroidOwner
if (title != "WebComponent") {
while (findAll(isDialog()).isNotEmpty()) {
+ waitForIdle()
Espresso.pressBack()
}
}
+ waitForIdle()
Espresso.pressBack()
+ waitForIdle()
+
+ composeTestRule.clockTestRule.advanceClock(5000)
assertAppBarHasTitle(navigationTitle)
}
diff --git a/ui/integration-tests/demos/src/main/java/androidx/ui/demos/DemoApp.kt b/ui/integration-tests/demos/src/main/java/androidx/ui/demos/DemoApp.kt
index 19a9da0..4e4d0b0 100644
--- a/ui/integration-tests/demos/src/main/java/androidx/ui/demos/DemoApp.kt
+++ b/ui/integration-tests/demos/src/main/java/androidx/ui/demos/DemoApp.kt
@@ -22,7 +22,7 @@
import androidx.ui.animation.Crossfade
import androidx.ui.core.Alignment
import androidx.ui.core.Modifier
-import androidx.ui.core.TestTag
+import androidx.ui.core.testTag
import androidx.ui.demos.common.ActivityDemo
import androidx.ui.demos.common.ComposableDemo
import androidx.ui.demos.common.Demo
@@ -33,6 +33,7 @@
import androidx.ui.foundation.TextFieldValue
import androidx.ui.foundation.VerticalScroller
import androidx.ui.layout.fillMaxSize
+import androidx.ui.layout.padding
import androidx.ui.layout.preferredHeight
import androidx.ui.layout.wrapContentSize
import androidx.ui.material.IconButton
@@ -68,7 +69,7 @@
var filterText by savedInstanceState(saver = TextFieldValue.Saver) { TextFieldValue() }
- Scaffold(topAppBar = {
+ Scaffold(topBar = {
DemoAppBar(
title = backStackTitle,
navigationIcon = navigationIcon,
@@ -79,20 +80,22 @@
onStartFiltering = onStartFiltering,
onEndFiltering = onEndFiltering
)
- }) {
- DemoContent(currentDemo, isFiltering, filterText.text, onNavigateToDemo)
+ }) { innerPadding ->
+ val modifier = Modifier.padding(innerPadding)
+ DemoContent(modifier, currentDemo, isFiltering, filterText.text, onNavigateToDemo)
}
}
@Composable
private fun DemoContent(
+ modifier: Modifier,
currentDemo: Demo,
isFiltering: Boolean,
filterText: String,
onNavigate: (Demo) -> Unit
) {
Crossfade(isFiltering to currentDemo) { (filtering, demo) ->
- Surface(Modifier.fillMaxSize(), color = MaterialTheme.colors.background) {
+ Surface(modifier.fillMaxSize(), color = MaterialTheme.colors.background) {
if (filtering) {
DemoFilter(
launchableDemos = AllDemosCategory.allLaunchableDemos(),
@@ -157,15 +160,11 @@
} else {
TopAppBar(
title = {
- TestTag(Tags.AppBarTitle) {
- Text(title)
- }
+ Text(title, Modifier.testTag(Tags.AppBarTitle))
},
navigationIcon = navigationIcon,
actions = {
- TestTag(Tags.FilterButton) {
- AppBarIcons.Filter(onClick = onStartFiltering)
- }
+ AppBarIcons.Filter(onClick = onStartFiltering)
AppBarIcons.Settings(onClick = launchSettings)
}
)
@@ -175,7 +174,7 @@
private object AppBarIcons {
@Composable
fun Filter(onClick: () -> Unit) {
- IconButton(onClick = onClick) {
+ IconButton(modifier = Modifier.testTag(Tags.FilterButton), onClick = onClick) {
Icon(Icons.Filled.Search)
}
}
diff --git a/ui/integration-tests/src/main/java/androidx/ui/integration/test/framework/VectorAssetTestCase.kt b/ui/integration-tests/src/main/java/androidx/ui/integration/test/framework/VectorAssetTestCase.kt
index ef4c3a6..747663d 100644
--- a/ui/integration-tests/src/main/java/androidx/ui/integration/test/framework/VectorAssetTestCase.kt
+++ b/ui/integration-tests/src/main/java/androidx/ui/integration/test/framework/VectorAssetTestCase.kt
@@ -18,7 +18,7 @@
import androidx.compose.Composable
import androidx.ui.core.Modifier
-import androidx.ui.core.TestTag
+import androidx.ui.core.testTag
import androidx.ui.core.paint
import androidx.ui.foundation.Box
import androidx.ui.graphics.Color
@@ -31,7 +31,6 @@
import androidx.ui.graphics.vector.VectorPainter
import androidx.ui.layout.preferredSize
import androidx.ui.res.vectorResource
-import androidx.ui.semantics.Semantics
import androidx.ui.test.ComposeTestCase
import androidx.ui.unit.dp
@@ -46,11 +45,9 @@
@Composable
override fun emitContent() {
Box {
- TestTag(testTag) {
- Semantics(container = true) {
- Box(Modifier.preferredSize(24.dp).paint(VectorPainter(getVectorAsset())))
- }
- }
+ Box(Modifier.testTag(testTag)
+ .preferredSize(24.dp)
+ .paint(VectorPainter(getVectorAsset())))
}
}
diff --git a/ui/ui-animation/api/0.1.0-dev14.txt b/ui/ui-animation/api/0.1.0-dev14.txt
index 5f89483..2eaf1a9 100644
--- a/ui/ui-animation/api/0.1.0-dev14.txt
+++ b/ui/ui-animation/api/0.1.0-dev14.txt
@@ -66,7 +66,7 @@
method public static androidx.animation.TwoWayConverter<androidx.ui.unit.PxBounds,androidx.animation.AnimationVector4D> getPxBoundsToVectorConverter();
method public static androidx.animation.TwoWayConverter<androidx.ui.unit.PxPosition,androidx.animation.AnimationVector2D> getPxPositionToVectorConverter();
method public static androidx.animation.TwoWayConverter<androidx.ui.unit.PxSize,androidx.animation.AnimationVector2D> getPxSizeToVectorConverter();
- method public static androidx.animation.TwoWayConverter<androidx.ui.unit.Px,androidx.animation.AnimationVector1D> getPxToVectorConverter();
+ method public static androidx.animation.TwoWayConverter<java.lang.Float,androidx.animation.AnimationVector1D> getPxToVectorConverter();
method public static androidx.animation.TwoWayConverter<androidx.ui.geometry.Rect,androidx.animation.AnimationVector4D> getRectToVectorConverter();
method public static androidx.animation.TwoWayConverter<androidx.ui.geometry.Size,androidx.animation.AnimationVector2D> getSizeToVectorConverter();
}
@@ -79,12 +79,12 @@
property public androidx.animation.TwoWayConverter<androidx.ui.unit.PxPosition,androidx.animation.AnimationVector2D> typeConverter;
}
- public final class PxPropKey implements androidx.animation.PropKey<androidx.ui.unit.Px,androidx.animation.AnimationVector1D> {
+ public final class PxPropKey implements androidx.animation.PropKey<java.lang.Float,androidx.animation.AnimationVector1D> {
ctor public PxPropKey(String label);
ctor public PxPropKey();
method public String getLabel();
- method public androidx.animation.TwoWayConverter<androidx.ui.unit.Px,androidx.animation.AnimationVector1D> getTypeConverter();
- property public androidx.animation.TwoWayConverter<androidx.ui.unit.Px,androidx.animation.AnimationVector1D> typeConverter;
+ method public androidx.animation.TwoWayConverter<java.lang.Float,androidx.animation.AnimationVector1D> getTypeConverter();
+ property public androidx.animation.TwoWayConverter<java.lang.Float,androidx.animation.AnimationVector1D> typeConverter;
}
public final class RectPropKey implements androidx.animation.PropKey<androidx.ui.geometry.Rect,androidx.animation.AnimationVector4D> {
@@ -102,6 +102,9 @@
method @androidx.compose.Composable public static androidx.ui.unit.Bounds animate(androidx.ui.unit.Bounds target, androidx.animation.AnimationBuilder<androidx.ui.unit.Bounds> animBuilder = remember({
return <init>()
}), kotlin.jvm.functions.Function1<? super androidx.ui.unit.Bounds,kotlin.Unit>? endListener = null);
+ method @androidx.compose.Composable public static float animate(float target, androidx.animation.AnimationBuilder<java.lang.Float> animBuilder = remember({
+ return <init>()
+}), kotlin.jvm.functions.Function1<? super java.lang.Float,kotlin.Unit>? endListener = null);
method @androidx.compose.Composable public static androidx.ui.unit.PxSize animate(androidx.ui.unit.PxSize target, androidx.animation.AnimationBuilder<androidx.ui.unit.PxSize> animBuilder = remember({
return <init>()
}), kotlin.jvm.functions.Function1<? super androidx.ui.unit.PxSize,kotlin.Unit>? endListener = null);
@@ -132,9 +135,6 @@
method @androidx.compose.Composable public static long animate-90dr43Y(long target, androidx.animation.AnimationBuilder<androidx.ui.graphics.Color> animBuilder = remember({
return <init>()
}), kotlin.jvm.functions.Function1<? super androidx.ui.graphics.Color,kotlin.Unit>? endListener = null);
- method @androidx.compose.Composable public static float animate-aPXp8Ng(float target, androidx.animation.AnimationBuilder<androidx.ui.unit.Px> animBuilder = remember({
- return <init>()
-}), kotlin.jvm.functions.Function1<? super androidx.ui.unit.Px,kotlin.Unit>? endListener = null);
method @androidx.compose.Composable public static int animate-gxe4dkU(int target, androidx.animation.AnimationBuilder<androidx.ui.unit.IntPx> animBuilder = remember({
return <init>()
}), kotlin.jvm.functions.Function1<? super androidx.ui.unit.IntPx,kotlin.Unit>? endListener = null);
diff --git a/ui/ui-animation/api/current.txt b/ui/ui-animation/api/current.txt
index 5f89483..2eaf1a9 100644
--- a/ui/ui-animation/api/current.txt
+++ b/ui/ui-animation/api/current.txt
@@ -66,7 +66,7 @@
method public static androidx.animation.TwoWayConverter<androidx.ui.unit.PxBounds,androidx.animation.AnimationVector4D> getPxBoundsToVectorConverter();
method public static androidx.animation.TwoWayConverter<androidx.ui.unit.PxPosition,androidx.animation.AnimationVector2D> getPxPositionToVectorConverter();
method public static androidx.animation.TwoWayConverter<androidx.ui.unit.PxSize,androidx.animation.AnimationVector2D> getPxSizeToVectorConverter();
- method public static androidx.animation.TwoWayConverter<androidx.ui.unit.Px,androidx.animation.AnimationVector1D> getPxToVectorConverter();
+ method public static androidx.animation.TwoWayConverter<java.lang.Float,androidx.animation.AnimationVector1D> getPxToVectorConverter();
method public static androidx.animation.TwoWayConverter<androidx.ui.geometry.Rect,androidx.animation.AnimationVector4D> getRectToVectorConverter();
method public static androidx.animation.TwoWayConverter<androidx.ui.geometry.Size,androidx.animation.AnimationVector2D> getSizeToVectorConverter();
}
@@ -79,12 +79,12 @@
property public androidx.animation.TwoWayConverter<androidx.ui.unit.PxPosition,androidx.animation.AnimationVector2D> typeConverter;
}
- public final class PxPropKey implements androidx.animation.PropKey<androidx.ui.unit.Px,androidx.animation.AnimationVector1D> {
+ public final class PxPropKey implements androidx.animation.PropKey<java.lang.Float,androidx.animation.AnimationVector1D> {
ctor public PxPropKey(String label);
ctor public PxPropKey();
method public String getLabel();
- method public androidx.animation.TwoWayConverter<androidx.ui.unit.Px,androidx.animation.AnimationVector1D> getTypeConverter();
- property public androidx.animation.TwoWayConverter<androidx.ui.unit.Px,androidx.animation.AnimationVector1D> typeConverter;
+ method public androidx.animation.TwoWayConverter<java.lang.Float,androidx.animation.AnimationVector1D> getTypeConverter();
+ property public androidx.animation.TwoWayConverter<java.lang.Float,androidx.animation.AnimationVector1D> typeConverter;
}
public final class RectPropKey implements androidx.animation.PropKey<androidx.ui.geometry.Rect,androidx.animation.AnimationVector4D> {
@@ -102,6 +102,9 @@
method @androidx.compose.Composable public static androidx.ui.unit.Bounds animate(androidx.ui.unit.Bounds target, androidx.animation.AnimationBuilder<androidx.ui.unit.Bounds> animBuilder = remember({
return <init>()
}), kotlin.jvm.functions.Function1<? super androidx.ui.unit.Bounds,kotlin.Unit>? endListener = null);
+ method @androidx.compose.Composable public static float animate(float target, androidx.animation.AnimationBuilder<java.lang.Float> animBuilder = remember({
+ return <init>()
+}), kotlin.jvm.functions.Function1<? super java.lang.Float,kotlin.Unit>? endListener = null);
method @androidx.compose.Composable public static androidx.ui.unit.PxSize animate(androidx.ui.unit.PxSize target, androidx.animation.AnimationBuilder<androidx.ui.unit.PxSize> animBuilder = remember({
return <init>()
}), kotlin.jvm.functions.Function1<? super androidx.ui.unit.PxSize,kotlin.Unit>? endListener = null);
@@ -132,9 +135,6 @@
method @androidx.compose.Composable public static long animate-90dr43Y(long target, androidx.animation.AnimationBuilder<androidx.ui.graphics.Color> animBuilder = remember({
return <init>()
}), kotlin.jvm.functions.Function1<? super androidx.ui.graphics.Color,kotlin.Unit>? endListener = null);
- method @androidx.compose.Composable public static float animate-aPXp8Ng(float target, androidx.animation.AnimationBuilder<androidx.ui.unit.Px> animBuilder = remember({
- return <init>()
-}), kotlin.jvm.functions.Function1<? super androidx.ui.unit.Px,kotlin.Unit>? endListener = null);
method @androidx.compose.Composable public static int animate-gxe4dkU(int target, androidx.animation.AnimationBuilder<androidx.ui.unit.IntPx> animBuilder = remember({
return <init>()
}), kotlin.jvm.functions.Function1<? super androidx.ui.unit.IntPx,kotlin.Unit>? endListener = null);
diff --git a/ui/ui-animation/api/public_plus_experimental_0.1.0-dev14.txt b/ui/ui-animation/api/public_plus_experimental_0.1.0-dev14.txt
index 5f89483..2eaf1a9 100644
--- a/ui/ui-animation/api/public_plus_experimental_0.1.0-dev14.txt
+++ b/ui/ui-animation/api/public_plus_experimental_0.1.0-dev14.txt
@@ -66,7 +66,7 @@
method public static androidx.animation.TwoWayConverter<androidx.ui.unit.PxBounds,androidx.animation.AnimationVector4D> getPxBoundsToVectorConverter();
method public static androidx.animation.TwoWayConverter<androidx.ui.unit.PxPosition,androidx.animation.AnimationVector2D> getPxPositionToVectorConverter();
method public static androidx.animation.TwoWayConverter<androidx.ui.unit.PxSize,androidx.animation.AnimationVector2D> getPxSizeToVectorConverter();
- method public static androidx.animation.TwoWayConverter<androidx.ui.unit.Px,androidx.animation.AnimationVector1D> getPxToVectorConverter();
+ method public static androidx.animation.TwoWayConverter<java.lang.Float,androidx.animation.AnimationVector1D> getPxToVectorConverter();
method public static androidx.animation.TwoWayConverter<androidx.ui.geometry.Rect,androidx.animation.AnimationVector4D> getRectToVectorConverter();
method public static androidx.animation.TwoWayConverter<androidx.ui.geometry.Size,androidx.animation.AnimationVector2D> getSizeToVectorConverter();
}
@@ -79,12 +79,12 @@
property public androidx.animation.TwoWayConverter<androidx.ui.unit.PxPosition,androidx.animation.AnimationVector2D> typeConverter;
}
- public final class PxPropKey implements androidx.animation.PropKey<androidx.ui.unit.Px,androidx.animation.AnimationVector1D> {
+ public final class PxPropKey implements androidx.animation.PropKey<java.lang.Float,androidx.animation.AnimationVector1D> {
ctor public PxPropKey(String label);
ctor public PxPropKey();
method public String getLabel();
- method public androidx.animation.TwoWayConverter<androidx.ui.unit.Px,androidx.animation.AnimationVector1D> getTypeConverter();
- property public androidx.animation.TwoWayConverter<androidx.ui.unit.Px,androidx.animation.AnimationVector1D> typeConverter;
+ method public androidx.animation.TwoWayConverter<java.lang.Float,androidx.animation.AnimationVector1D> getTypeConverter();
+ property public androidx.animation.TwoWayConverter<java.lang.Float,androidx.animation.AnimationVector1D> typeConverter;
}
public final class RectPropKey implements androidx.animation.PropKey<androidx.ui.geometry.Rect,androidx.animation.AnimationVector4D> {
@@ -102,6 +102,9 @@
method @androidx.compose.Composable public static androidx.ui.unit.Bounds animate(androidx.ui.unit.Bounds target, androidx.animation.AnimationBuilder<androidx.ui.unit.Bounds> animBuilder = remember({
return <init>()
}), kotlin.jvm.functions.Function1<? super androidx.ui.unit.Bounds,kotlin.Unit>? endListener = null);
+ method @androidx.compose.Composable public static float animate(float target, androidx.animation.AnimationBuilder<java.lang.Float> animBuilder = remember({
+ return <init>()
+}), kotlin.jvm.functions.Function1<? super java.lang.Float,kotlin.Unit>? endListener = null);
method @androidx.compose.Composable public static androidx.ui.unit.PxSize animate(androidx.ui.unit.PxSize target, androidx.animation.AnimationBuilder<androidx.ui.unit.PxSize> animBuilder = remember({
return <init>()
}), kotlin.jvm.functions.Function1<? super androidx.ui.unit.PxSize,kotlin.Unit>? endListener = null);
@@ -132,9 +135,6 @@
method @androidx.compose.Composable public static long animate-90dr43Y(long target, androidx.animation.AnimationBuilder<androidx.ui.graphics.Color> animBuilder = remember({
return <init>()
}), kotlin.jvm.functions.Function1<? super androidx.ui.graphics.Color,kotlin.Unit>? endListener = null);
- method @androidx.compose.Composable public static float animate-aPXp8Ng(float target, androidx.animation.AnimationBuilder<androidx.ui.unit.Px> animBuilder = remember({
- return <init>()
-}), kotlin.jvm.functions.Function1<? super androidx.ui.unit.Px,kotlin.Unit>? endListener = null);
method @androidx.compose.Composable public static int animate-gxe4dkU(int target, androidx.animation.AnimationBuilder<androidx.ui.unit.IntPx> animBuilder = remember({
return <init>()
}), kotlin.jvm.functions.Function1<? super androidx.ui.unit.IntPx,kotlin.Unit>? endListener = null);
diff --git a/ui/ui-animation/api/public_plus_experimental_current.txt b/ui/ui-animation/api/public_plus_experimental_current.txt
index 5f89483..2eaf1a9 100644
--- a/ui/ui-animation/api/public_plus_experimental_current.txt
+++ b/ui/ui-animation/api/public_plus_experimental_current.txt
@@ -66,7 +66,7 @@
method public static androidx.animation.TwoWayConverter<androidx.ui.unit.PxBounds,androidx.animation.AnimationVector4D> getPxBoundsToVectorConverter();
method public static androidx.animation.TwoWayConverter<androidx.ui.unit.PxPosition,androidx.animation.AnimationVector2D> getPxPositionToVectorConverter();
method public static androidx.animation.TwoWayConverter<androidx.ui.unit.PxSize,androidx.animation.AnimationVector2D> getPxSizeToVectorConverter();
- method public static androidx.animation.TwoWayConverter<androidx.ui.unit.Px,androidx.animation.AnimationVector1D> getPxToVectorConverter();
+ method public static androidx.animation.TwoWayConverter<java.lang.Float,androidx.animation.AnimationVector1D> getPxToVectorConverter();
method public static androidx.animation.TwoWayConverter<androidx.ui.geometry.Rect,androidx.animation.AnimationVector4D> getRectToVectorConverter();
method public static androidx.animation.TwoWayConverter<androidx.ui.geometry.Size,androidx.animation.AnimationVector2D> getSizeToVectorConverter();
}
@@ -79,12 +79,12 @@
property public androidx.animation.TwoWayConverter<androidx.ui.unit.PxPosition,androidx.animation.AnimationVector2D> typeConverter;
}
- public final class PxPropKey implements androidx.animation.PropKey<androidx.ui.unit.Px,androidx.animation.AnimationVector1D> {
+ public final class PxPropKey implements androidx.animation.PropKey<java.lang.Float,androidx.animation.AnimationVector1D> {
ctor public PxPropKey(String label);
ctor public PxPropKey();
method public String getLabel();
- method public androidx.animation.TwoWayConverter<androidx.ui.unit.Px,androidx.animation.AnimationVector1D> getTypeConverter();
- property public androidx.animation.TwoWayConverter<androidx.ui.unit.Px,androidx.animation.AnimationVector1D> typeConverter;
+ method public androidx.animation.TwoWayConverter<java.lang.Float,androidx.animation.AnimationVector1D> getTypeConverter();
+ property public androidx.animation.TwoWayConverter<java.lang.Float,androidx.animation.AnimationVector1D> typeConverter;
}
public final class RectPropKey implements androidx.animation.PropKey<androidx.ui.geometry.Rect,androidx.animation.AnimationVector4D> {
@@ -102,6 +102,9 @@
method @androidx.compose.Composable public static androidx.ui.unit.Bounds animate(androidx.ui.unit.Bounds target, androidx.animation.AnimationBuilder<androidx.ui.unit.Bounds> animBuilder = remember({
return <init>()
}), kotlin.jvm.functions.Function1<? super androidx.ui.unit.Bounds,kotlin.Unit>? endListener = null);
+ method @androidx.compose.Composable public static float animate(float target, androidx.animation.AnimationBuilder<java.lang.Float> animBuilder = remember({
+ return <init>()
+}), kotlin.jvm.functions.Function1<? super java.lang.Float,kotlin.Unit>? endListener = null);
method @androidx.compose.Composable public static androidx.ui.unit.PxSize animate(androidx.ui.unit.PxSize target, androidx.animation.AnimationBuilder<androidx.ui.unit.PxSize> animBuilder = remember({
return <init>()
}), kotlin.jvm.functions.Function1<? super androidx.ui.unit.PxSize,kotlin.Unit>? endListener = null);
@@ -132,9 +135,6 @@
method @androidx.compose.Composable public static long animate-90dr43Y(long target, androidx.animation.AnimationBuilder<androidx.ui.graphics.Color> animBuilder = remember({
return <init>()
}), kotlin.jvm.functions.Function1<? super androidx.ui.graphics.Color,kotlin.Unit>? endListener = null);
- method @androidx.compose.Composable public static float animate-aPXp8Ng(float target, androidx.animation.AnimationBuilder<androidx.ui.unit.Px> animBuilder = remember({
- return <init>()
-}), kotlin.jvm.functions.Function1<? super androidx.ui.unit.Px,kotlin.Unit>? endListener = null);
method @androidx.compose.Composable public static int animate-gxe4dkU(int target, androidx.animation.AnimationBuilder<androidx.ui.unit.IntPx> animBuilder = remember({
return <init>()
}), kotlin.jvm.functions.Function1<? super androidx.ui.unit.IntPx,kotlin.Unit>? endListener = null);
diff --git a/ui/ui-animation/api/restricted_0.1.0-dev14.txt b/ui/ui-animation/api/restricted_0.1.0-dev14.txt
index 5f89483..2eaf1a9 100644
--- a/ui/ui-animation/api/restricted_0.1.0-dev14.txt
+++ b/ui/ui-animation/api/restricted_0.1.0-dev14.txt
@@ -66,7 +66,7 @@
method public static androidx.animation.TwoWayConverter<androidx.ui.unit.PxBounds,androidx.animation.AnimationVector4D> getPxBoundsToVectorConverter();
method public static androidx.animation.TwoWayConverter<androidx.ui.unit.PxPosition,androidx.animation.AnimationVector2D> getPxPositionToVectorConverter();
method public static androidx.animation.TwoWayConverter<androidx.ui.unit.PxSize,androidx.animation.AnimationVector2D> getPxSizeToVectorConverter();
- method public static androidx.animation.TwoWayConverter<androidx.ui.unit.Px,androidx.animation.AnimationVector1D> getPxToVectorConverter();
+ method public static androidx.animation.TwoWayConverter<java.lang.Float,androidx.animation.AnimationVector1D> getPxToVectorConverter();
method public static androidx.animation.TwoWayConverter<androidx.ui.geometry.Rect,androidx.animation.AnimationVector4D> getRectToVectorConverter();
method public static androidx.animation.TwoWayConverter<androidx.ui.geometry.Size,androidx.animation.AnimationVector2D> getSizeToVectorConverter();
}
@@ -79,12 +79,12 @@
property public androidx.animation.TwoWayConverter<androidx.ui.unit.PxPosition,androidx.animation.AnimationVector2D> typeConverter;
}
- public final class PxPropKey implements androidx.animation.PropKey<androidx.ui.unit.Px,androidx.animation.AnimationVector1D> {
+ public final class PxPropKey implements androidx.animation.PropKey<java.lang.Float,androidx.animation.AnimationVector1D> {
ctor public PxPropKey(String label);
ctor public PxPropKey();
method public String getLabel();
- method public androidx.animation.TwoWayConverter<androidx.ui.unit.Px,androidx.animation.AnimationVector1D> getTypeConverter();
- property public androidx.animation.TwoWayConverter<androidx.ui.unit.Px,androidx.animation.AnimationVector1D> typeConverter;
+ method public androidx.animation.TwoWayConverter<java.lang.Float,androidx.animation.AnimationVector1D> getTypeConverter();
+ property public androidx.animation.TwoWayConverter<java.lang.Float,androidx.animation.AnimationVector1D> typeConverter;
}
public final class RectPropKey implements androidx.animation.PropKey<androidx.ui.geometry.Rect,androidx.animation.AnimationVector4D> {
@@ -102,6 +102,9 @@
method @androidx.compose.Composable public static androidx.ui.unit.Bounds animate(androidx.ui.unit.Bounds target, androidx.animation.AnimationBuilder<androidx.ui.unit.Bounds> animBuilder = remember({
return <init>()
}), kotlin.jvm.functions.Function1<? super androidx.ui.unit.Bounds,kotlin.Unit>? endListener = null);
+ method @androidx.compose.Composable public static float animate(float target, androidx.animation.AnimationBuilder<java.lang.Float> animBuilder = remember({
+ return <init>()
+}), kotlin.jvm.functions.Function1<? super java.lang.Float,kotlin.Unit>? endListener = null);
method @androidx.compose.Composable public static androidx.ui.unit.PxSize animate(androidx.ui.unit.PxSize target, androidx.animation.AnimationBuilder<androidx.ui.unit.PxSize> animBuilder = remember({
return <init>()
}), kotlin.jvm.functions.Function1<? super androidx.ui.unit.PxSize,kotlin.Unit>? endListener = null);
@@ -132,9 +135,6 @@
method @androidx.compose.Composable public static long animate-90dr43Y(long target, androidx.animation.AnimationBuilder<androidx.ui.graphics.Color> animBuilder = remember({
return <init>()
}), kotlin.jvm.functions.Function1<? super androidx.ui.graphics.Color,kotlin.Unit>? endListener = null);
- method @androidx.compose.Composable public static float animate-aPXp8Ng(float target, androidx.animation.AnimationBuilder<androidx.ui.unit.Px> animBuilder = remember({
- return <init>()
-}), kotlin.jvm.functions.Function1<? super androidx.ui.unit.Px,kotlin.Unit>? endListener = null);
method @androidx.compose.Composable public static int animate-gxe4dkU(int target, androidx.animation.AnimationBuilder<androidx.ui.unit.IntPx> animBuilder = remember({
return <init>()
}), kotlin.jvm.functions.Function1<? super androidx.ui.unit.IntPx,kotlin.Unit>? endListener = null);
diff --git a/ui/ui-animation/api/restricted_current.txt b/ui/ui-animation/api/restricted_current.txt
index 5f89483..2eaf1a9 100644
--- a/ui/ui-animation/api/restricted_current.txt
+++ b/ui/ui-animation/api/restricted_current.txt
@@ -66,7 +66,7 @@
method public static androidx.animation.TwoWayConverter<androidx.ui.unit.PxBounds,androidx.animation.AnimationVector4D> getPxBoundsToVectorConverter();
method public static androidx.animation.TwoWayConverter<androidx.ui.unit.PxPosition,androidx.animation.AnimationVector2D> getPxPositionToVectorConverter();
method public static androidx.animation.TwoWayConverter<androidx.ui.unit.PxSize,androidx.animation.AnimationVector2D> getPxSizeToVectorConverter();
- method public static androidx.animation.TwoWayConverter<androidx.ui.unit.Px,androidx.animation.AnimationVector1D> getPxToVectorConverter();
+ method public static androidx.animation.TwoWayConverter<java.lang.Float,androidx.animation.AnimationVector1D> getPxToVectorConverter();
method public static androidx.animation.TwoWayConverter<androidx.ui.geometry.Rect,androidx.animation.AnimationVector4D> getRectToVectorConverter();
method public static androidx.animation.TwoWayConverter<androidx.ui.geometry.Size,androidx.animation.AnimationVector2D> getSizeToVectorConverter();
}
@@ -79,12 +79,12 @@
property public androidx.animation.TwoWayConverter<androidx.ui.unit.PxPosition,androidx.animation.AnimationVector2D> typeConverter;
}
- public final class PxPropKey implements androidx.animation.PropKey<androidx.ui.unit.Px,androidx.animation.AnimationVector1D> {
+ public final class PxPropKey implements androidx.animation.PropKey<java.lang.Float,androidx.animation.AnimationVector1D> {
ctor public PxPropKey(String label);
ctor public PxPropKey();
method public String getLabel();
- method public androidx.animation.TwoWayConverter<androidx.ui.unit.Px,androidx.animation.AnimationVector1D> getTypeConverter();
- property public androidx.animation.TwoWayConverter<androidx.ui.unit.Px,androidx.animation.AnimationVector1D> typeConverter;
+ method public androidx.animation.TwoWayConverter<java.lang.Float,androidx.animation.AnimationVector1D> getTypeConverter();
+ property public androidx.animation.TwoWayConverter<java.lang.Float,androidx.animation.AnimationVector1D> typeConverter;
}
public final class RectPropKey implements androidx.animation.PropKey<androidx.ui.geometry.Rect,androidx.animation.AnimationVector4D> {
@@ -102,6 +102,9 @@
method @androidx.compose.Composable public static androidx.ui.unit.Bounds animate(androidx.ui.unit.Bounds target, androidx.animation.AnimationBuilder<androidx.ui.unit.Bounds> animBuilder = remember({
return <init>()
}), kotlin.jvm.functions.Function1<? super androidx.ui.unit.Bounds,kotlin.Unit>? endListener = null);
+ method @androidx.compose.Composable public static float animate(float target, androidx.animation.AnimationBuilder<java.lang.Float> animBuilder = remember({
+ return <init>()
+}), kotlin.jvm.functions.Function1<? super java.lang.Float,kotlin.Unit>? endListener = null);
method @androidx.compose.Composable public static androidx.ui.unit.PxSize animate(androidx.ui.unit.PxSize target, androidx.animation.AnimationBuilder<androidx.ui.unit.PxSize> animBuilder = remember({
return <init>()
}), kotlin.jvm.functions.Function1<? super androidx.ui.unit.PxSize,kotlin.Unit>? endListener = null);
@@ -132,9 +135,6 @@
method @androidx.compose.Composable public static long animate-90dr43Y(long target, androidx.animation.AnimationBuilder<androidx.ui.graphics.Color> animBuilder = remember({
return <init>()
}), kotlin.jvm.functions.Function1<? super androidx.ui.graphics.Color,kotlin.Unit>? endListener = null);
- method @androidx.compose.Composable public static float animate-aPXp8Ng(float target, androidx.animation.AnimationBuilder<androidx.ui.unit.Px> animBuilder = remember({
- return <init>()
-}), kotlin.jvm.functions.Function1<? super androidx.ui.unit.Px,kotlin.Unit>? endListener = null);
method @androidx.compose.Composable public static int animate-gxe4dkU(int target, androidx.animation.AnimationBuilder<androidx.ui.unit.IntPx> animBuilder = remember({
return <init>()
}), kotlin.jvm.functions.Function1<? super androidx.ui.unit.IntPx,kotlin.Unit>? endListener = null);
diff --git a/ui/ui-animation/integration-tests/animation-demos/src/main/java/androidx/ui/animation/demos/AnimatableSeekBarDemo.kt b/ui/ui-animation/integration-tests/animation-demos/src/main/java/androidx/ui/animation/demos/AnimatableSeekBarDemo.kt
index 526b28e..3adf558 100644
--- a/ui/ui-animation/integration-tests/animation-demos/src/main/java/androidx/ui/animation/demos/AnimatableSeekBarDemo.kt
+++ b/ui/ui-animation/integration-tests/animation-demos/src/main/java/androidx/ui/animation/demos/AnimatableSeekBarDemo.kt
@@ -99,13 +99,13 @@
val dragObserver = object : DragObserver {
override fun onDrag(dragDistance: PxPosition): PxPosition {
- animValue.snapTo(animValue.targetValue + dragDistance.x.value)
+ animValue.snapTo(animValue.targetValue + dragDistance.x)
return dragDistance
}
}
val onPress: (PxPosition) -> Unit = { position ->
- animValue.animateTo(position.x.value,
+ animValue.animateTo(position.x,
TweenBuilder<Float>().apply {
duration = 400
})
diff --git a/ui/ui-animation/integration-tests/animation-demos/src/main/java/androidx/ui/animation/demos/FancyScrollingDemo.kt b/ui/ui-animation/integration-tests/animation-demos/src/main/java/androidx/ui/animation/demos/FancyScrollingDemo.kt
index b1c28da..5d4356d 100644
--- a/ui/ui-animation/integration-tests/animation-demos/src/main/java/androidx/ui/animation/demos/FancyScrollingDemo.kt
+++ b/ui/ui-animation/integration-tests/animation-demos/src/main/java/androidx/ui/animation/demos/FancyScrollingDemo.kt
@@ -55,7 +55,7 @@
val gesture = Modifier.rawDragGestureFilter(dragObserver = object : DragObserver {
override fun onDrag(dragDistance: PxPosition): PxPosition {
// Snap to new drag position
- animScroll.snapTo(animScroll.value + dragDistance.x.value)
+ animScroll.snapTo(animScroll.value + dragDistance.x)
return dragDistance
}
@@ -64,7 +64,7 @@
// Uses default decay animation to calculate where the fling will settle,
// and adjust that position as needed. The target animation will be used for
// animating to the adjusted target.
- animScroll.fling(velocity.x.value, adjustTarget = { target ->
+ animScroll.fling(velocity.x, adjustTarget = { target ->
// Adjust the target position to center align the item
val animation = PhysicsBuilder<Float>(dampingRatio = 2.0f, stiffness = 100f)
var rem = target % itemWidth.value
diff --git a/ui/ui-animation/integration-tests/animation-demos/src/main/java/androidx/ui/animation/demos/SpringBackScrollingDemo.kt b/ui/ui-animation/integration-tests/animation-demos/src/main/java/androidx/ui/animation/demos/SpringBackScrollingDemo.kt
index 4fb5d83..128778a 100644
--- a/ui/ui-animation/integration-tests/animation-demos/src/main/java/androidx/ui/animation/demos/SpringBackScrollingDemo.kt
+++ b/ui/ui-animation/integration-tests/animation-demos/src/main/java/androidx/ui/animation/demos/SpringBackScrollingDemo.kt
@@ -55,13 +55,13 @@
val isFlinging = state { false }
val gesture = Modifier.rawDragGestureFilter(dragObserver = object : DragObserver {
override fun onDrag(dragDistance: PxPosition): PxPosition {
- animScroll.snapTo(animScroll.targetValue + dragDistance.x.value)
+ animScroll.snapTo(animScroll.targetValue + dragDistance.x)
return dragDistance
}
override fun onStop(velocity: PxPosition) {
isFlinging.value = true
- animScroll.fling(velocity.x.value, onEnd = { _, _, _ ->
+ animScroll.fling(velocity.x, onEnd = { _, _, _ ->
isFlinging.value = false
})
}
diff --git a/ui/ui-animation/integration-tests/animation-demos/src/main/java/androidx/ui/animation/demos/StateBasedRippleDemo.kt b/ui/ui-animation/integration-tests/animation-demos/src/main/java/androidx/ui/animation/demos/StateBasedRippleDemo.kt
index 1218d2a..800f557 100644
--- a/ui/ui-animation/integration-tests/animation-demos/src/main/java/androidx/ui/animation/demos/StateBasedRippleDemo.kt
+++ b/ui/ui-animation/integration-tests/animation-demos/src/main/java/androidx/ui/animation/demos/StateBasedRippleDemo.kt
@@ -50,8 +50,8 @@
val toState = state { ButtonStatus.Initial }
val rippleTransDef = remember { createTransDef(radius) }
val onPress: (PxPosition) -> Unit = { position ->
- down.x = position.x.value
- down.y = position.y.value
+ down.x = position.x
+ down.y = position.y
toState.value = ButtonStatus.Pressed
}
diff --git a/ui/ui-animation/integration-tests/animation-demos/src/main/java/androidx/ui/animation/demos/SwipeToDismissDemo.kt b/ui/ui-animation/integration-tests/animation-demos/src/main/java/androidx/ui/animation/demos/SwipeToDismissDemo.kt
index 01d75cd..91df541 100644
--- a/ui/ui-animation/integration-tests/animation-demos/src/main/java/androidx/ui/animation/demos/SwipeToDismissDemo.kt
+++ b/ui/ui-animation/integration-tests/animation-demos/src/main/java/androidx/ui/animation/demos/SwipeToDismissDemo.kt
@@ -84,7 +84,7 @@
}
override fun onDrag(dragDistance: PxPosition): PxPosition {
- itemBottom.snapTo(itemBottom.targetValue + dragDistance.y.value)
+ itemBottom.snapTo(itemBottom.targetValue + dragDistance.y)
return dragDistance
}
@@ -107,9 +107,9 @@
override fun onStop(velocity: PxPosition) {
isFlinging.value = true
- itemBottom.fling(velocity.y.value,
+ itemBottom.fling(velocity.y,
ExponentialDecay(3.0f),
- adjustTarget(velocity.y.value),
+ adjustTarget(velocity.y),
onEnd = { endReason, final, _ ->
isFlinging.value = false
if (endReason != AnimationEndReason.Interrupted && final == 0f) {
diff --git a/ui/ui-animation/src/androidTest/java/androidx/ui/animation/SingleValueAnimationTest.kt b/ui/ui-animation/src/androidTest/java/androidx/ui/animation/SingleValueAnimationTest.kt
index 9b5c822..43a1252 100644
--- a/ui/ui-animation/src/androidTest/java/androidx/ui/animation/SingleValueAnimationTest.kt
+++ b/ui/ui-animation/src/androidTest/java/androidx/ui/animation/SingleValueAnimationTest.kt
@@ -39,12 +39,10 @@
import androidx.ui.unit.Bounds
import androidx.ui.unit.Dp
import androidx.ui.unit.Position
-import androidx.ui.unit.Px
import androidx.ui.unit.PxBounds
import androidx.ui.unit.PxPosition
import androidx.ui.unit.PxSize
import androidx.ui.unit.dp
-import androidx.ui.unit.px
import androidx.ui.util.lerp
import org.junit.Assert.assertEquals
@@ -62,12 +60,12 @@
@Test
fun animate1DTest() {
- val startVal: Int = 20
- val endVal: Int = 250
+ val startVal = 20f
+ val endVal = 250f
- var floatValue = startVal.toFloat()
+ var floatValue = startVal
var dpValue = startVal.dp
- var pxValue = startVal.px
+ var pxValue = startVal
val animConfig: TweenBuilder<*>.() -> Unit = {
easing = FastOutSlowInEasing
@@ -75,7 +73,7 @@
}
val children: @Composable() (Boolean) -> Unit = { enabled ->
floatValue = animate(
- if (enabled) endVal.toFloat() else startVal.toFloat(),
+ if (enabled) endVal else startVal,
TweenBuilder<Float>().apply(animConfig)
)
@@ -85,8 +83,8 @@
)
pxValue = animate(
- if (enabled) endVal.px else startVal.px,
- TweenBuilder<Px>().apply(animConfig)
+ if (enabled) endVal else startVal,
+ TweenBuilder<Float>().apply(animConfig)
)
}
@@ -98,7 +96,7 @@
)
assertEquals(value, floatValue)
assertEquals(value.dp, dpValue)
- assertEquals(value.px, pxValue)
+ assertEquals(value, pxValue)
composeTestRule.clockTestRule.advanceClock(50)
waitForIdle()
}
diff --git a/ui/ui-animation/src/main/java/androidx/ui/animation/PropertyKeys.kt b/ui/ui-animation/src/main/java/androidx/ui/animation/PropertyKeys.kt
index e985914..ab47f19 100644
--- a/ui/ui-animation/src/main/java/androidx/ui/animation/PropertyKeys.kt
+++ b/ui/ui-animation/src/main/java/androidx/ui/animation/PropertyKeys.kt
@@ -33,7 +33,6 @@
import androidx.ui.unit.IntPxPosition
import androidx.ui.unit.IntPxSize
import androidx.ui.unit.Position
-import androidx.ui.unit.Px
import androidx.ui.unit.PxBounds
import androidx.ui.unit.PxPosition
import androidx.ui.unit.PxSize
@@ -43,11 +42,11 @@
import kotlin.math.roundToInt
/**
- * Built-in property key for [Px] properties.
+ * Built-in property key for pixel properties.
*
* @param label Label for distinguishing different prop keys in Android Studio.
*/
-class PxPropKey(override val label: String = "PxPropKey") : PropKey<Px, AnimationVector1D> {
+class PxPropKey(override val label: String = "PxPropKey") : PropKey<Float, AnimationVector1D> {
override val typeConverter = PxToVectorConverter
}
@@ -171,11 +170,11 @@
)
/**
- * A type converter that converts a [Px] to a [AnimationVector1D], and vice versa.
+ * A type converter that converts a pixel to a [AnimationVector1D], and vice versa.
*/
-val PxToVectorConverter: TwoWayConverter<Px, AnimationVector1D> = TwoWayConverter(
- convertToVector = { AnimationVector1D(it.value) },
- convertFromVector = { Px(it.value) }
+val PxToVectorConverter: TwoWayConverter<Float, AnimationVector1D> = TwoWayConverter(
+ convertToVector = { AnimationVector1D(it) },
+ convertFromVector = { it.value }
)
/**
@@ -183,8 +182,8 @@
*/
val PxPositionToVectorConverter: TwoWayConverter<PxPosition, AnimationVector2D> =
TwoWayConverter(
- convertToVector = { AnimationVector2D(it.x.value, it.y.value) },
- convertFromVector = { PxPosition(it.v1.px, it.v2.px) }
+ convertToVector = { AnimationVector2D(it.x, it.y) },
+ convertFromVector = { PxPosition(it.v1, it.v2) }
)
/**
@@ -192,7 +191,7 @@
*/
val PxSizeToVectorConverter: TwoWayConverter<PxSize, AnimationVector2D> =
TwoWayConverter(
- convertToVector = { AnimationVector2D(it.width.value, it.height.value) },
+ convertToVector = { AnimationVector2D(it.width, it.height) },
convertFromVector = { PxSize(it.v1.px, it.v2.px) }
)
@@ -202,12 +201,12 @@
val PxBoundsToVectorConverter: TwoWayConverter<PxBounds, AnimationVector4D> =
TwoWayConverter(
convertToVector = {
- AnimationVector4D(it.left.value, it.top.value, it.right.value, it.bottom.value) },
- convertFromVector = { PxBounds(it.v1.px, it.v2.px, it.v3.px, it.v4.px) }
+ AnimationVector4D(it.left, it.top, it.right, it.bottom) },
+ convertFromVector = { PxBounds(it.v1, it.v2, it.v3, it.v4) }
)
/**
- * A type converter that converts a [Px] to a [AnimationVector1D], and vice versa.
+ * A type converter that converts a pixel to a [AnimationVector1D], and vice versa.
*/
val IntPxToVectorConverter: TwoWayConverter<IntPx, AnimationVector1D> = TwoWayConverter(
convertToVector = { AnimationVector1D(it.value.toFloat()) },
diff --git a/ui/ui-animation/src/main/java/androidx/ui/animation/SingleValueAnimation.kt b/ui/ui-animation/src/main/java/androidx/ui/animation/SingleValueAnimation.kt
index 14b4d78..daece9f 100644
--- a/ui/ui-animation/src/main/java/androidx/ui/animation/SingleValueAnimation.kt
+++ b/ui/ui-animation/src/main/java/androidx/ui/animation/SingleValueAnimation.kt
@@ -37,7 +37,6 @@
import androidx.ui.unit.IntPxPosition
import androidx.ui.unit.IntPxSize
import androidx.ui.unit.Position
-import androidx.ui.unit.Px
import androidx.ui.unit.PxBounds
import androidx.ui.unit.PxPosition
import androidx.ui.unit.PxSize
@@ -246,14 +245,14 @@
}
/**
- * Fire-and-forget animation [Composable] for [Px]. Once such an animation is created, it will be
+ * Fire-and-forget animation [Composable] for pixels. Once such an animation is created, it will be
* positionally memoized, like other @[Composable]s. To trigger the animation, or alter the
* course of the animation, simply supply a different [target] to the [Composable].
*
* Note, [animate] is for simple animations that cannot be canceled. For cancellable animations
* see [animatedValue].
*
- * val height : Px = animate(if (collapsed) 10.px else 20.px)
+ * val height : Float = animate(if (collapsed) 10f else 20f)
*
* @param target Target value of the animation
* @param animBuilder The animation that will be used to change the value through time. Physics
@@ -262,10 +261,10 @@
*/
@Composable
fun animate(
- target: Px,
- animBuilder: AnimationBuilder<Px> = remember { PhysicsBuilder() },
- endListener: ((Px) -> Unit)? = null
-): Px {
+ target: Float,
+ animBuilder: AnimationBuilder<Float> = remember { PhysicsBuilder() },
+ endListener: ((Float) -> Unit)? = null
+): Float {
return animate(target, PxToVectorConverter, animBuilder, PxVisibilityThreshold1D, endListener)
}
diff --git a/ui/ui-animation/src/test/java/androidx/ui/animation/ConverterTest.kt b/ui/ui-animation/src/test/java/androidx/ui/animation/ConverterTest.kt
index c3445c1..4853a3a 100644
--- a/ui/ui-animation/src/test/java/androidx/ui/animation/ConverterTest.kt
+++ b/ui/ui-animation/src/test/java/androidx/ui/animation/ConverterTest.kt
@@ -24,7 +24,6 @@
import androidx.ui.graphics.colorspace.ColorSpaces
import androidx.ui.unit.PxPosition
import androidx.ui.unit.dp
-import androidx.ui.unit.px
import junit.framework.TestCase.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
@@ -54,10 +53,10 @@
@Test
fun testPxConverter() {
val value = Random.nextFloat()
- assertEquals(PxToVectorConverter.convertFromVector(AnimationVector1D(value)), value.px)
+ assertEquals(PxToVectorConverter.convertFromVector(AnimationVector1D(value)), value)
val value2 = Random.nextFloat()
- assertEquals(PxToVectorConverter.convertToVector(value2.px), AnimationVector1D(value2))
+ assertEquals(PxToVectorConverter.convertToVector(value2), AnimationVector1D(value2))
}
@Test
@@ -73,9 +72,9 @@
fun testPxPositionConverter() {
val x = Random.nextFloat()
val y = Random.nextFloat()
- assertEquals(PxPosition(x.px, y.px),
+ assertEquals(PxPosition(x, y),
PxPositionToVectorConverter.convertFromVector(AnimationVector2D(x, y)))
assertEquals(AnimationVector2D(x, y),
- PxPositionToVectorConverter.convertToVector(PxPosition(x.px, y.px)))
+ PxPositionToVectorConverter.convertToVector(PxPosition(x, y)))
}
}
\ No newline at end of file
diff --git a/ui/ui-core/api/0.1.0-dev14.txt b/ui/ui-core/api/0.1.0-dev14.txt
index 06bbb58..617c8ce 100644
--- a/ui/ui-core/api/0.1.0-dev14.txt
+++ b/ui/ui-core/api/0.1.0-dev14.txt
@@ -685,7 +685,7 @@
}
public interface ParentDataModifier extends androidx.ui.core.Modifier.Element {
- method public default Object? modifyParentData(androidx.ui.unit.Density, Object? parentData);
+ method public Object? modifyParentData(androidx.ui.unit.Density, Object? parentData);
}
public abstract class Placeable {
@@ -710,11 +710,9 @@
method public abstract int getParentWidth();
method public final void place(androidx.ui.core.Placeable, androidx.ui.unit.IntPxPosition position);
method public final void place(androidx.ui.core.Placeable, androidx.ui.unit.PxPosition position);
- method public final void place-Guq6mTs(androidx.ui.core.Placeable, float x, float y);
method public final void place-sXe7h04(androidx.ui.core.Placeable, int x, int y);
method public final void placeAbsolute(androidx.ui.core.Placeable, androidx.ui.unit.PxPosition position);
method public final void placeAbsolute(androidx.ui.core.Placeable, androidx.ui.unit.IntPxPosition position);
- method public final void placeAbsolute-Guq6mTs(androidx.ui.core.Placeable, float x, float y);
method public final void placeAbsolute-sXe7h04(androidx.ui.core.Placeable, int x, int y);
property public abstract androidx.ui.core.LayoutDirection parentLayoutDirection;
property public abstract int parentWidth;
@@ -771,7 +769,7 @@
method public static boolean changedToUpIgnoreConsumed(androidx.ui.core.PointerInputChange);
method public static androidx.ui.core.PointerInputChange consumeAllChanges(androidx.ui.core.PointerInputChange);
method public static androidx.ui.core.PointerInputChange consumeDownChange(androidx.ui.core.PointerInputChange);
- method public static androidx.ui.core.PointerInputChange consumePositionChange-3EnrK0w(androidx.ui.core.PointerInputChange, float consumedDx, float consumedDy);
+ method public static androidx.ui.core.PointerInputChange consumePositionChange(androidx.ui.core.PointerInputChange, float consumedDx, float consumedDy);
method public static androidx.ui.unit.PxPosition positionChange(androidx.ui.core.PointerInputChange);
method public static androidx.ui.unit.PxPosition positionChangeIgnoreConsumed(androidx.ui.core.PointerInputChange);
method public static boolean positionChanged(androidx.ui.core.PointerInputChange);
@@ -800,7 +798,7 @@
}
public final class TestTagKt {
- method @androidx.compose.Composable public static void TestTag(String tag, kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @Deprecated @androidx.compose.Composable public static void TestTag(String tag, kotlin.jvm.functions.Function0<kotlin.Unit> children);
method @androidx.compose.Stable public static androidx.ui.core.Modifier testTag(androidx.ui.core.Modifier, String tag);
}
@@ -2163,10 +2161,10 @@
public static final class SemanticsActions.Companion {
method public androidx.ui.semantics.SemanticsPropertyKey<java.util.List<androidx.ui.semantics.CustomAccessibilityAction>> getCustomActions();
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> getOnClick();
- method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<androidx.ui.unit.Px,androidx.ui.unit.Px,java.lang.Boolean>>> getScrollTo();
+ method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>>> getScrollTo();
property public final androidx.ui.semantics.SemanticsPropertyKey<java.util.List<androidx.ui.semantics.CustomAccessibilityAction>> CustomActions;
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> OnClick;
- property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<androidx.ui.unit.Px,androidx.ui.unit.Px,java.lang.Boolean>>> ScrollTo;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>>> ScrollTo;
}
public final class SemanticsKt {
@@ -2192,7 +2190,7 @@
}
public final class SemanticsPropertiesKt {
- method public static void ScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function2<? super androidx.ui.unit.Px,? super androidx.ui.unit.Px,java.lang.Boolean> action);
+ method public static void ScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function2<? super java.lang.Float,? super java.lang.Float,java.lang.Boolean> action);
method public static String getAccessibilityLabel(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static String getAccessibilityValue(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static androidx.ui.semantics.AccessibilityRangeInfo getAccessibilityValueRange(androidx.ui.semantics.SemanticsPropertyReceiver);
@@ -2201,7 +2199,7 @@
method public static boolean getHidden(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> getOnClick(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static boolean getPopup(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<androidx.ui.unit.Px,androidx.ui.unit.Px,java.lang.Boolean>> getScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver);
+ method public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>> getScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static String getTestTag(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static void onClick(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function0<java.lang.Boolean> action);
method public static void setAccessibilityLabel(androidx.ui.semantics.SemanticsPropertyReceiver, String p);
@@ -2212,7 +2210,7 @@
method public static void setHidden(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
method public static void setOnClick(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> p);
method public static void setPopup(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
- method public static void setScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<androidx.ui.unit.Px,androidx.ui.unit.Px,java.lang.Boolean>> p);
+ method public static void setScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>> p);
method public static void setTestTag(androidx.ui.semantics.SemanticsPropertyReceiver, String p);
}
diff --git a/ui/ui-core/api/current.txt b/ui/ui-core/api/current.txt
index 06bbb58..617c8ce 100644
--- a/ui/ui-core/api/current.txt
+++ b/ui/ui-core/api/current.txt
@@ -685,7 +685,7 @@
}
public interface ParentDataModifier extends androidx.ui.core.Modifier.Element {
- method public default Object? modifyParentData(androidx.ui.unit.Density, Object? parentData);
+ method public Object? modifyParentData(androidx.ui.unit.Density, Object? parentData);
}
public abstract class Placeable {
@@ -710,11 +710,9 @@
method public abstract int getParentWidth();
method public final void place(androidx.ui.core.Placeable, androidx.ui.unit.IntPxPosition position);
method public final void place(androidx.ui.core.Placeable, androidx.ui.unit.PxPosition position);
- method public final void place-Guq6mTs(androidx.ui.core.Placeable, float x, float y);
method public final void place-sXe7h04(androidx.ui.core.Placeable, int x, int y);
method public final void placeAbsolute(androidx.ui.core.Placeable, androidx.ui.unit.PxPosition position);
method public final void placeAbsolute(androidx.ui.core.Placeable, androidx.ui.unit.IntPxPosition position);
- method public final void placeAbsolute-Guq6mTs(androidx.ui.core.Placeable, float x, float y);
method public final void placeAbsolute-sXe7h04(androidx.ui.core.Placeable, int x, int y);
property public abstract androidx.ui.core.LayoutDirection parentLayoutDirection;
property public abstract int parentWidth;
@@ -771,7 +769,7 @@
method public static boolean changedToUpIgnoreConsumed(androidx.ui.core.PointerInputChange);
method public static androidx.ui.core.PointerInputChange consumeAllChanges(androidx.ui.core.PointerInputChange);
method public static androidx.ui.core.PointerInputChange consumeDownChange(androidx.ui.core.PointerInputChange);
- method public static androidx.ui.core.PointerInputChange consumePositionChange-3EnrK0w(androidx.ui.core.PointerInputChange, float consumedDx, float consumedDy);
+ method public static androidx.ui.core.PointerInputChange consumePositionChange(androidx.ui.core.PointerInputChange, float consumedDx, float consumedDy);
method public static androidx.ui.unit.PxPosition positionChange(androidx.ui.core.PointerInputChange);
method public static androidx.ui.unit.PxPosition positionChangeIgnoreConsumed(androidx.ui.core.PointerInputChange);
method public static boolean positionChanged(androidx.ui.core.PointerInputChange);
@@ -800,7 +798,7 @@
}
public final class TestTagKt {
- method @androidx.compose.Composable public static void TestTag(String tag, kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @Deprecated @androidx.compose.Composable public static void TestTag(String tag, kotlin.jvm.functions.Function0<kotlin.Unit> children);
method @androidx.compose.Stable public static androidx.ui.core.Modifier testTag(androidx.ui.core.Modifier, String tag);
}
@@ -2163,10 +2161,10 @@
public static final class SemanticsActions.Companion {
method public androidx.ui.semantics.SemanticsPropertyKey<java.util.List<androidx.ui.semantics.CustomAccessibilityAction>> getCustomActions();
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> getOnClick();
- method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<androidx.ui.unit.Px,androidx.ui.unit.Px,java.lang.Boolean>>> getScrollTo();
+ method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>>> getScrollTo();
property public final androidx.ui.semantics.SemanticsPropertyKey<java.util.List<androidx.ui.semantics.CustomAccessibilityAction>> CustomActions;
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> OnClick;
- property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<androidx.ui.unit.Px,androidx.ui.unit.Px,java.lang.Boolean>>> ScrollTo;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>>> ScrollTo;
}
public final class SemanticsKt {
@@ -2192,7 +2190,7 @@
}
public final class SemanticsPropertiesKt {
- method public static void ScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function2<? super androidx.ui.unit.Px,? super androidx.ui.unit.Px,java.lang.Boolean> action);
+ method public static void ScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function2<? super java.lang.Float,? super java.lang.Float,java.lang.Boolean> action);
method public static String getAccessibilityLabel(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static String getAccessibilityValue(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static androidx.ui.semantics.AccessibilityRangeInfo getAccessibilityValueRange(androidx.ui.semantics.SemanticsPropertyReceiver);
@@ -2201,7 +2199,7 @@
method public static boolean getHidden(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> getOnClick(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static boolean getPopup(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<androidx.ui.unit.Px,androidx.ui.unit.Px,java.lang.Boolean>> getScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver);
+ method public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>> getScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static String getTestTag(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static void onClick(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function0<java.lang.Boolean> action);
method public static void setAccessibilityLabel(androidx.ui.semantics.SemanticsPropertyReceiver, String p);
@@ -2212,7 +2210,7 @@
method public static void setHidden(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
method public static void setOnClick(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> p);
method public static void setPopup(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
- method public static void setScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<androidx.ui.unit.Px,androidx.ui.unit.Px,java.lang.Boolean>> p);
+ method public static void setScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>> p);
method public static void setTestTag(androidx.ui.semantics.SemanticsPropertyReceiver, String p);
}
diff --git a/ui/ui-core/api/public_plus_experimental_0.1.0-dev14.txt b/ui/ui-core/api/public_plus_experimental_0.1.0-dev14.txt
index 9057b5d..1fa269f 100644
--- a/ui/ui-core/api/public_plus_experimental_0.1.0-dev14.txt
+++ b/ui/ui-core/api/public_plus_experimental_0.1.0-dev14.txt
@@ -687,7 +687,7 @@
}
public interface ParentDataModifier extends androidx.ui.core.Modifier.Element {
- method public default Object? modifyParentData(androidx.ui.unit.Density, Object? parentData);
+ method public Object? modifyParentData(androidx.ui.unit.Density, Object? parentData);
}
public abstract class Placeable {
@@ -712,11 +712,9 @@
method public abstract int getParentWidth();
method public final void place(androidx.ui.core.Placeable, androidx.ui.unit.IntPxPosition position);
method public final void place(androidx.ui.core.Placeable, androidx.ui.unit.PxPosition position);
- method public final void place-Guq6mTs(androidx.ui.core.Placeable, float x, float y);
method public final void place-sXe7h04(androidx.ui.core.Placeable, int x, int y);
method public final void placeAbsolute(androidx.ui.core.Placeable, androidx.ui.unit.PxPosition position);
method public final void placeAbsolute(androidx.ui.core.Placeable, androidx.ui.unit.IntPxPosition position);
- method public final void placeAbsolute-Guq6mTs(androidx.ui.core.Placeable, float x, float y);
method public final void placeAbsolute-sXe7h04(androidx.ui.core.Placeable, int x, int y);
property public abstract androidx.ui.core.LayoutDirection parentLayoutDirection;
property public abstract int parentWidth;
@@ -773,7 +771,7 @@
method public static boolean changedToUpIgnoreConsumed(androidx.ui.core.PointerInputChange);
method public static androidx.ui.core.PointerInputChange consumeAllChanges(androidx.ui.core.PointerInputChange);
method public static androidx.ui.core.PointerInputChange consumeDownChange(androidx.ui.core.PointerInputChange);
- method public static androidx.ui.core.PointerInputChange consumePositionChange-3EnrK0w(androidx.ui.core.PointerInputChange, float consumedDx, float consumedDy);
+ method public static androidx.ui.core.PointerInputChange consumePositionChange(androidx.ui.core.PointerInputChange, float consumedDx, float consumedDy);
method public static androidx.ui.unit.PxPosition positionChange(androidx.ui.core.PointerInputChange);
method public static androidx.ui.unit.PxPosition positionChangeIgnoreConsumed(androidx.ui.core.PointerInputChange);
method public static boolean positionChanged(androidx.ui.core.PointerInputChange);
@@ -802,7 +800,7 @@
}
public final class TestTagKt {
- method @androidx.compose.Composable public static void TestTag(String tag, kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @Deprecated @androidx.compose.Composable public static void TestTag(String tag, kotlin.jvm.functions.Function0<kotlin.Unit> children);
method @androidx.compose.Stable public static androidx.ui.core.Modifier testTag(androidx.ui.core.Modifier, String tag);
}
@@ -2165,10 +2163,10 @@
public static final class SemanticsActions.Companion {
method public androidx.ui.semantics.SemanticsPropertyKey<java.util.List<androidx.ui.semantics.CustomAccessibilityAction>> getCustomActions();
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> getOnClick();
- method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<androidx.ui.unit.Px,androidx.ui.unit.Px,java.lang.Boolean>>> getScrollTo();
+ method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>>> getScrollTo();
property public final androidx.ui.semantics.SemanticsPropertyKey<java.util.List<androidx.ui.semantics.CustomAccessibilityAction>> CustomActions;
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> OnClick;
- property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<androidx.ui.unit.Px,androidx.ui.unit.Px,java.lang.Boolean>>> ScrollTo;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>>> ScrollTo;
}
public final class SemanticsKt {
@@ -2194,7 +2192,7 @@
}
public final class SemanticsPropertiesKt {
- method public static void ScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function2<? super androidx.ui.unit.Px,? super androidx.ui.unit.Px,java.lang.Boolean> action);
+ method public static void ScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function2<? super java.lang.Float,? super java.lang.Float,java.lang.Boolean> action);
method public static String getAccessibilityLabel(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static String getAccessibilityValue(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static androidx.ui.semantics.AccessibilityRangeInfo getAccessibilityValueRange(androidx.ui.semantics.SemanticsPropertyReceiver);
@@ -2203,7 +2201,7 @@
method public static boolean getHidden(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> getOnClick(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static boolean getPopup(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<androidx.ui.unit.Px,androidx.ui.unit.Px,java.lang.Boolean>> getScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver);
+ method public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>> getScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static String getTestTag(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static void onClick(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function0<java.lang.Boolean> action);
method public static void setAccessibilityLabel(androidx.ui.semantics.SemanticsPropertyReceiver, String p);
@@ -2214,7 +2212,7 @@
method public static void setHidden(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
method public static void setOnClick(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> p);
method public static void setPopup(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
- method public static void setScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<androidx.ui.unit.Px,androidx.ui.unit.Px,java.lang.Boolean>> p);
+ method public static void setScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>> p);
method public static void setTestTag(androidx.ui.semantics.SemanticsPropertyReceiver, String p);
}
diff --git a/ui/ui-core/api/public_plus_experimental_current.txt b/ui/ui-core/api/public_plus_experimental_current.txt
index 9057b5d..1fa269f 100644
--- a/ui/ui-core/api/public_plus_experimental_current.txt
+++ b/ui/ui-core/api/public_plus_experimental_current.txt
@@ -687,7 +687,7 @@
}
public interface ParentDataModifier extends androidx.ui.core.Modifier.Element {
- method public default Object? modifyParentData(androidx.ui.unit.Density, Object? parentData);
+ method public Object? modifyParentData(androidx.ui.unit.Density, Object? parentData);
}
public abstract class Placeable {
@@ -712,11 +712,9 @@
method public abstract int getParentWidth();
method public final void place(androidx.ui.core.Placeable, androidx.ui.unit.IntPxPosition position);
method public final void place(androidx.ui.core.Placeable, androidx.ui.unit.PxPosition position);
- method public final void place-Guq6mTs(androidx.ui.core.Placeable, float x, float y);
method public final void place-sXe7h04(androidx.ui.core.Placeable, int x, int y);
method public final void placeAbsolute(androidx.ui.core.Placeable, androidx.ui.unit.PxPosition position);
method public final void placeAbsolute(androidx.ui.core.Placeable, androidx.ui.unit.IntPxPosition position);
- method public final void placeAbsolute-Guq6mTs(androidx.ui.core.Placeable, float x, float y);
method public final void placeAbsolute-sXe7h04(androidx.ui.core.Placeable, int x, int y);
property public abstract androidx.ui.core.LayoutDirection parentLayoutDirection;
property public abstract int parentWidth;
@@ -773,7 +771,7 @@
method public static boolean changedToUpIgnoreConsumed(androidx.ui.core.PointerInputChange);
method public static androidx.ui.core.PointerInputChange consumeAllChanges(androidx.ui.core.PointerInputChange);
method public static androidx.ui.core.PointerInputChange consumeDownChange(androidx.ui.core.PointerInputChange);
- method public static androidx.ui.core.PointerInputChange consumePositionChange-3EnrK0w(androidx.ui.core.PointerInputChange, float consumedDx, float consumedDy);
+ method public static androidx.ui.core.PointerInputChange consumePositionChange(androidx.ui.core.PointerInputChange, float consumedDx, float consumedDy);
method public static androidx.ui.unit.PxPosition positionChange(androidx.ui.core.PointerInputChange);
method public static androidx.ui.unit.PxPosition positionChangeIgnoreConsumed(androidx.ui.core.PointerInputChange);
method public static boolean positionChanged(androidx.ui.core.PointerInputChange);
@@ -802,7 +800,7 @@
}
public final class TestTagKt {
- method @androidx.compose.Composable public static void TestTag(String tag, kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @Deprecated @androidx.compose.Composable public static void TestTag(String tag, kotlin.jvm.functions.Function0<kotlin.Unit> children);
method @androidx.compose.Stable public static androidx.ui.core.Modifier testTag(androidx.ui.core.Modifier, String tag);
}
@@ -2165,10 +2163,10 @@
public static final class SemanticsActions.Companion {
method public androidx.ui.semantics.SemanticsPropertyKey<java.util.List<androidx.ui.semantics.CustomAccessibilityAction>> getCustomActions();
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> getOnClick();
- method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<androidx.ui.unit.Px,androidx.ui.unit.Px,java.lang.Boolean>>> getScrollTo();
+ method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>>> getScrollTo();
property public final androidx.ui.semantics.SemanticsPropertyKey<java.util.List<androidx.ui.semantics.CustomAccessibilityAction>> CustomActions;
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> OnClick;
- property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<androidx.ui.unit.Px,androidx.ui.unit.Px,java.lang.Boolean>>> ScrollTo;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>>> ScrollTo;
}
public final class SemanticsKt {
@@ -2194,7 +2192,7 @@
}
public final class SemanticsPropertiesKt {
- method public static void ScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function2<? super androidx.ui.unit.Px,? super androidx.ui.unit.Px,java.lang.Boolean> action);
+ method public static void ScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function2<? super java.lang.Float,? super java.lang.Float,java.lang.Boolean> action);
method public static String getAccessibilityLabel(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static String getAccessibilityValue(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static androidx.ui.semantics.AccessibilityRangeInfo getAccessibilityValueRange(androidx.ui.semantics.SemanticsPropertyReceiver);
@@ -2203,7 +2201,7 @@
method public static boolean getHidden(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> getOnClick(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static boolean getPopup(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<androidx.ui.unit.Px,androidx.ui.unit.Px,java.lang.Boolean>> getScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver);
+ method public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>> getScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static String getTestTag(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static void onClick(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function0<java.lang.Boolean> action);
method public static void setAccessibilityLabel(androidx.ui.semantics.SemanticsPropertyReceiver, String p);
@@ -2214,7 +2212,7 @@
method public static void setHidden(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
method public static void setOnClick(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> p);
method public static void setPopup(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
- method public static void setScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<androidx.ui.unit.Px,androidx.ui.unit.Px,java.lang.Boolean>> p);
+ method public static void setScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>> p);
method public static void setTestTag(androidx.ui.semantics.SemanticsPropertyReceiver, String p);
}
diff --git a/ui/ui-core/api/restricted_0.1.0-dev14.txt b/ui/ui-core/api/restricted_0.1.0-dev14.txt
index 8723f3f..e266052 100644
--- a/ui/ui-core/api/restricted_0.1.0-dev14.txt
+++ b/ui/ui-core/api/restricted_0.1.0-dev14.txt
@@ -741,7 +741,7 @@
}
public interface ParentDataModifier extends androidx.ui.core.Modifier.Element {
- method public default Object? modifyParentData(androidx.ui.unit.Density, Object? parentData);
+ method public Object? modifyParentData(androidx.ui.unit.Density, Object? parentData);
}
public abstract class Placeable {
@@ -766,11 +766,9 @@
method public abstract int getParentWidth();
method public final void place(androidx.ui.core.Placeable, androidx.ui.unit.IntPxPosition position);
method public final void place(androidx.ui.core.Placeable, androidx.ui.unit.PxPosition position);
- method public final void place-Guq6mTs(androidx.ui.core.Placeable, float x, float y);
method public final void place-sXe7h04(androidx.ui.core.Placeable, int x, int y);
method public final void placeAbsolute(androidx.ui.core.Placeable, androidx.ui.unit.PxPosition position);
method public final void placeAbsolute(androidx.ui.core.Placeable, androidx.ui.unit.IntPxPosition position);
- method public final void placeAbsolute-Guq6mTs(androidx.ui.core.Placeable, float x, float y);
method public final void placeAbsolute-sXe7h04(androidx.ui.core.Placeable, int x, int y);
property public abstract androidx.ui.core.LayoutDirection parentLayoutDirection;
property public abstract int parentWidth;
@@ -827,7 +825,7 @@
method public static boolean changedToUpIgnoreConsumed(androidx.ui.core.PointerInputChange);
method public static androidx.ui.core.PointerInputChange consumeAllChanges(androidx.ui.core.PointerInputChange);
method public static androidx.ui.core.PointerInputChange consumeDownChange(androidx.ui.core.PointerInputChange);
- method public static androidx.ui.core.PointerInputChange consumePositionChange-3EnrK0w(androidx.ui.core.PointerInputChange, float consumedDx, float consumedDy);
+ method public static androidx.ui.core.PointerInputChange consumePositionChange(androidx.ui.core.PointerInputChange, float consumedDx, float consumedDy);
method public static androidx.ui.unit.PxPosition positionChange(androidx.ui.core.PointerInputChange);
method public static androidx.ui.unit.PxPosition positionChangeIgnoreConsumed(androidx.ui.core.PointerInputChange);
method public static boolean positionChanged(androidx.ui.core.PointerInputChange);
@@ -856,7 +854,7 @@
}
public final class TestTagKt {
- method @androidx.compose.Composable public static void TestTag(String tag, kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @Deprecated @androidx.compose.Composable public static void TestTag(String tag, kotlin.jvm.functions.Function0<kotlin.Unit> children);
method @androidx.compose.Stable public static androidx.ui.core.Modifier testTag(androidx.ui.core.Modifier, String tag);
}
@@ -2228,10 +2226,10 @@
public static final class SemanticsActions.Companion {
method public androidx.ui.semantics.SemanticsPropertyKey<java.util.List<androidx.ui.semantics.CustomAccessibilityAction>> getCustomActions();
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> getOnClick();
- method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<androidx.ui.unit.Px,androidx.ui.unit.Px,java.lang.Boolean>>> getScrollTo();
+ method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>>> getScrollTo();
property public final androidx.ui.semantics.SemanticsPropertyKey<java.util.List<androidx.ui.semantics.CustomAccessibilityAction>> CustomActions;
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> OnClick;
- property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<androidx.ui.unit.Px,androidx.ui.unit.Px,java.lang.Boolean>>> ScrollTo;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>>> ScrollTo;
}
public final class SemanticsKt {
@@ -2257,7 +2255,7 @@
}
public final class SemanticsPropertiesKt {
- method public static void ScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function2<? super androidx.ui.unit.Px,? super androidx.ui.unit.Px,java.lang.Boolean> action);
+ method public static void ScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function2<? super java.lang.Float,? super java.lang.Float,java.lang.Boolean> action);
method public static String getAccessibilityLabel(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static String getAccessibilityValue(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static androidx.ui.semantics.AccessibilityRangeInfo getAccessibilityValueRange(androidx.ui.semantics.SemanticsPropertyReceiver);
@@ -2266,7 +2264,7 @@
method public static boolean getHidden(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> getOnClick(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static boolean getPopup(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<androidx.ui.unit.Px,androidx.ui.unit.Px,java.lang.Boolean>> getScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver);
+ method public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>> getScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static String getTestTag(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static void onClick(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function0<java.lang.Boolean> action);
method public static void setAccessibilityLabel(androidx.ui.semantics.SemanticsPropertyReceiver, String p);
@@ -2277,7 +2275,7 @@
method public static void setHidden(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
method public static void setOnClick(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> p);
method public static void setPopup(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
- method public static void setScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<androidx.ui.unit.Px,androidx.ui.unit.Px,java.lang.Boolean>> p);
+ method public static void setScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>> p);
method public static void setTestTag(androidx.ui.semantics.SemanticsPropertyReceiver, String p);
}
diff --git a/ui/ui-core/api/restricted_current.txt b/ui/ui-core/api/restricted_current.txt
index 8723f3f..e266052 100644
--- a/ui/ui-core/api/restricted_current.txt
+++ b/ui/ui-core/api/restricted_current.txt
@@ -741,7 +741,7 @@
}
public interface ParentDataModifier extends androidx.ui.core.Modifier.Element {
- method public default Object? modifyParentData(androidx.ui.unit.Density, Object? parentData);
+ method public Object? modifyParentData(androidx.ui.unit.Density, Object? parentData);
}
public abstract class Placeable {
@@ -766,11 +766,9 @@
method public abstract int getParentWidth();
method public final void place(androidx.ui.core.Placeable, androidx.ui.unit.IntPxPosition position);
method public final void place(androidx.ui.core.Placeable, androidx.ui.unit.PxPosition position);
- method public final void place-Guq6mTs(androidx.ui.core.Placeable, float x, float y);
method public final void place-sXe7h04(androidx.ui.core.Placeable, int x, int y);
method public final void placeAbsolute(androidx.ui.core.Placeable, androidx.ui.unit.PxPosition position);
method public final void placeAbsolute(androidx.ui.core.Placeable, androidx.ui.unit.IntPxPosition position);
- method public final void placeAbsolute-Guq6mTs(androidx.ui.core.Placeable, float x, float y);
method public final void placeAbsolute-sXe7h04(androidx.ui.core.Placeable, int x, int y);
property public abstract androidx.ui.core.LayoutDirection parentLayoutDirection;
property public abstract int parentWidth;
@@ -827,7 +825,7 @@
method public static boolean changedToUpIgnoreConsumed(androidx.ui.core.PointerInputChange);
method public static androidx.ui.core.PointerInputChange consumeAllChanges(androidx.ui.core.PointerInputChange);
method public static androidx.ui.core.PointerInputChange consumeDownChange(androidx.ui.core.PointerInputChange);
- method public static androidx.ui.core.PointerInputChange consumePositionChange-3EnrK0w(androidx.ui.core.PointerInputChange, float consumedDx, float consumedDy);
+ method public static androidx.ui.core.PointerInputChange consumePositionChange(androidx.ui.core.PointerInputChange, float consumedDx, float consumedDy);
method public static androidx.ui.unit.PxPosition positionChange(androidx.ui.core.PointerInputChange);
method public static androidx.ui.unit.PxPosition positionChangeIgnoreConsumed(androidx.ui.core.PointerInputChange);
method public static boolean positionChanged(androidx.ui.core.PointerInputChange);
@@ -856,7 +854,7 @@
}
public final class TestTagKt {
- method @androidx.compose.Composable public static void TestTag(String tag, kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @Deprecated @androidx.compose.Composable public static void TestTag(String tag, kotlin.jvm.functions.Function0<kotlin.Unit> children);
method @androidx.compose.Stable public static androidx.ui.core.Modifier testTag(androidx.ui.core.Modifier, String tag);
}
@@ -2228,10 +2226,10 @@
public static final class SemanticsActions.Companion {
method public androidx.ui.semantics.SemanticsPropertyKey<java.util.List<androidx.ui.semantics.CustomAccessibilityAction>> getCustomActions();
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> getOnClick();
- method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<androidx.ui.unit.Px,androidx.ui.unit.Px,java.lang.Boolean>>> getScrollTo();
+ method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>>> getScrollTo();
property public final androidx.ui.semantics.SemanticsPropertyKey<java.util.List<androidx.ui.semantics.CustomAccessibilityAction>> CustomActions;
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> OnClick;
- property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<androidx.ui.unit.Px,androidx.ui.unit.Px,java.lang.Boolean>>> ScrollTo;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>>> ScrollTo;
}
public final class SemanticsKt {
@@ -2257,7 +2255,7 @@
}
public final class SemanticsPropertiesKt {
- method public static void ScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function2<? super androidx.ui.unit.Px,? super androidx.ui.unit.Px,java.lang.Boolean> action);
+ method public static void ScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function2<? super java.lang.Float,? super java.lang.Float,java.lang.Boolean> action);
method public static String getAccessibilityLabel(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static String getAccessibilityValue(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static androidx.ui.semantics.AccessibilityRangeInfo getAccessibilityValueRange(androidx.ui.semantics.SemanticsPropertyReceiver);
@@ -2266,7 +2264,7 @@
method public static boolean getHidden(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> getOnClick(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static boolean getPopup(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<androidx.ui.unit.Px,androidx.ui.unit.Px,java.lang.Boolean>> getScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver);
+ method public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>> getScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static String getTestTag(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static void onClick(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function0<java.lang.Boolean> action);
method public static void setAccessibilityLabel(androidx.ui.semantics.SemanticsPropertyReceiver, String p);
@@ -2277,7 +2275,7 @@
method public static void setHidden(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
method public static void setOnClick(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> p);
method public static void setPopup(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
- method public static void setScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<androidx.ui.unit.Px,androidx.ui.unit.Px,java.lang.Boolean>> p);
+ method public static void setScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>> p);
method public static void setTestTag(androidx.ui.semantics.SemanticsPropertyReceiver, String p);
}
diff --git a/ui/ui-core/integration-tests/ui-core-demos/src/main/java/androidx/ui/core/demos/autofill/ExplicitAutofillTypesDemo.kt b/ui/ui-core/integration-tests/ui-core-demos/src/main/java/androidx/ui/core/demos/autofill/ExplicitAutofillTypesDemo.kt
index 3c1a799..bba3ab4 100644
--- a/ui/ui-core/integration-tests/ui-core-demos/src/main/java/androidx/ui/core/demos/autofill/ExplicitAutofillTypesDemo.kt
+++ b/ui/ui-core/integration-tests/ui-core-demos/src/main/java/androidx/ui/core/demos/autofill/ExplicitAutofillTypesDemo.kt
@@ -113,9 +113,9 @@
private fun LayoutCoordinates.boundingBox() = localToGlobal(PxPosition.Origin).run {
Rect(
- x.value.toInt(),
- y.value.toInt(),
- x.value.toInt() + size.width.value.toInt(),
- y.value.toInt() + size.height.value.toInt()
+ x.toInt(),
+ y.toInt(),
+ x.toInt() + size.width.value,
+ y.toInt() + size.height.value
)
}
\ No newline at end of file
diff --git a/ui/ui-core/integration-tests/ui-core-demos/src/main/java/androidx/ui/core/demos/gestures/NestedScrollingDemo.kt b/ui/ui-core/integration-tests/ui-core-demos/src/main/java/androidx/ui/core/demos/gestures/NestedScrollingDemo.kt
index 404da75..5408a9a 100644
--- a/ui/ui-core/integration-tests/ui-core-demos/src/main/java/androidx/ui/core/demos/gestures/NestedScrollingDemo.kt
+++ b/ui/ui-core/integration-tests/ui-core-demos/src/main/java/androidx/ui/core/demos/gestures/NestedScrollingDemo.kt
@@ -44,8 +44,7 @@
import androidx.ui.unit.PxPosition
import androidx.ui.unit.dp
import androidx.ui.unit.ipx
-import androidx.ui.unit.px
-import androidx.ui.unit.round
+import kotlin.math.roundToInt
/**
* Demonstration for how multiple DragGestureDetectors interact.
@@ -79,22 +78,22 @@
*/
@Composable
private fun Draggable(children: @Composable () -> Unit) {
- val offset = state { 0.px }
- val maxOffset = state { 0.px }
+ val offset = state { 0f }
+ val maxOffset = state { 0f }
val dragObserver = object : DragObserver {
override fun onDrag(dragDistance: PxPosition): PxPosition {
val resultingOffset = offset.value + dragDistance.y
val dyToConsume =
- if (resultingOffset > 0.px) {
- 0.px - offset.value
+ if (resultingOffset > 0f) {
+ 0f - offset.value
} else if (resultingOffset < maxOffset.value) {
maxOffset.value - offset.value
} else {
dragDistance.y
}
offset.value = offset.value + dyToConsume
- return PxPosition(0.px, dyToConsume)
+ return PxPosition(0f, dyToConsume)
}
}
@@ -114,10 +113,10 @@
measurables.first()
.measure(constraints.copy(minHeight = 0.ipx, maxHeight = IntPx.Infinity))
- maxOffset.value = constraints.maxHeight.value.px - placeable.height
+ maxOffset.value = (constraints.maxHeight.value - placeable.height.value).toFloat()
layout(constraints.maxWidth, constraints.maxHeight) {
- placeable.place(0.ipx, offset.value.round())
+ placeable.place(0.ipx, offset.value.roundToInt().ipx)
}
})
}
diff --git a/ui/ui-core/src/androidTest/java/androidx/ui/core/AndroidPointerInputTest.kt b/ui/ui-core/src/androidTest/java/androidx/ui/core/AndroidPointerInputTest.kt
index b2208ce..ac5ba57 100644
--- a/ui/ui-core/src/androidTest/java/androidx/ui/core/AndroidPointerInputTest.kt
+++ b/ui/ui-core/src/androidTest/java/androidx/ui/core/AndroidPointerInputTest.kt
@@ -35,7 +35,6 @@
import androidx.ui.unit.IntPxSize
import androidx.ui.unit.PxPosition
import androidx.ui.unit.ipx
-import androidx.ui.unit.px
import com.google.common.truth.Truth.assertThat
import com.nhaarman.mockitokotlin2.any
import com.nhaarman.mockitokotlin2.never
@@ -211,7 +210,7 @@
// we expect it to first remeasure and only then process
androidComposeView.dispatchTouchEvent(motionEvent)
- assertThat(consumedDownPosition).isEqualTo(PxPosition(15.px, 15.px))
+ assertThat(consumedDownPosition).isEqualTo(PxPosition(15f, 15f))
}
}
@@ -294,7 +293,10 @@
bounds: IntPxSize
) =
if (consumeMovement) {
- changes.map { it.consumePositionChange(it.positionChange().x, it.positionChange().y) }
+ changes.map { it.consumePositionChange(
+ it.positionChange().x,
+ it.positionChange().y)
+ }
} else {
changes
}
diff --git a/ui/ui-core/src/androidTest/java/androidx/ui/core/gesture/TouchSlopDragGestureFilterTest.kt b/ui/ui-core/src/androidTest/java/androidx/ui/core/gesture/TouchSlopDragGestureFilterTest.kt
index 67a5185..f26061c1 100644
--- a/ui/ui-core/src/androidTest/java/androidx/ui/core/gesture/TouchSlopDragGestureFilterTest.kt
+++ b/ui/ui-core/src/androidTest/java/androidx/ui/core/gesture/TouchSlopDragGestureFilterTest.kt
@@ -28,7 +28,6 @@
import androidx.ui.layout.Stack
import androidx.ui.unit.PxPosition
import androidx.ui.unit.ipx
-import androidx.ui.unit.px
import com.nhaarman.mockitokotlin2.any
import com.nhaarman.mockitokotlin2.inOrder
import com.nhaarman.mockitokotlin2.spy
@@ -239,7 +238,7 @@
view.dispatchTouchEvent(move)
}
- verify(dragObserver, times(2)).onDrag(PxPosition(movement.px, 0.px))
+ verify(dragObserver, times(2)).onDrag(PxPosition(movement.toFloat(), 0.0f))
}
private fun setup(startDragImmediately: Boolean) {
diff --git a/ui/ui-core/src/androidTest/java/androidx/ui/core/pointerinput/MotionEventAdapterTest.kt b/ui/ui-core/src/androidTest/java/androidx/ui/core/pointerinput/MotionEventAdapterTest.kt
index 424f045..1e59127 100644
--- a/ui/ui-core/src/androidTest/java/androidx/ui/core/pointerinput/MotionEventAdapterTest.kt
+++ b/ui/ui-core/src/androidTest/java/androidx/ui/core/pointerinput/MotionEventAdapterTest.kt
@@ -1447,6 +1447,6 @@
val pointerInputData = actual.pointerInputData
assertThat(actual.id).isEqualTo(id)
assertThat(pointerInputData.down).isEqualTo(isDown)
- assertThat(pointerInputData.position!!.x.value).isEqualTo(x)
- assertThat(pointerInputData.position!!.y.value).isEqualTo(y)
+ assertThat(pointerInputData.position!!.x).isEqualTo(x)
+ assertThat(pointerInputData.position!!.y).isEqualTo(y)
}
\ No newline at end of file
diff --git a/ui/ui-core/src/androidTest/java/androidx/ui/core/test/AndroidLayoutDrawTest.kt b/ui/ui-core/src/androidTest/java/androidx/ui/core/test/AndroidLayoutDrawTest.kt
index 68188e3..65134c0 100644
--- a/ui/ui-core/src/androidTest/java/androidx/ui/core/test/AndroidLayoutDrawTest.kt
+++ b/ui/ui-core/src/androidTest/java/androidx/ui/core/test/AndroidLayoutDrawTest.kt
@@ -1784,7 +1784,9 @@
}
}
}
- val parentDataModifier = object : ParentDataModifier {}
+ val parentDataModifier = object : ParentDataModifier {
+ override fun Density.modifyParentData(parentData: Any?) = parentData
+ }
val size = 50.ipx
val latch = CountDownLatch(2)
diff --git a/ui/ui-core/src/androidTest/java/androidx/ui/core/test/DrawLayerTest.kt b/ui/ui-core/src/androidTest/java/androidx/ui/core/test/DrawLayerTest.kt
index 0afe069..a5a6d81 100644
--- a/ui/ui-core/src/androidTest/java/androidx/ui/core/test/DrawLayerTest.kt
+++ b/ui/ui-core/src/androidTest/java/androidx/ui/core/test/DrawLayerTest.kt
@@ -33,7 +33,6 @@
import androidx.ui.unit.PxPosition
import androidx.ui.unit.height
import androidx.ui.unit.ipx
-import androidx.ui.unit.px
import androidx.ui.unit.width
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
@@ -80,15 +79,15 @@
assertTrue(positionLatch.await(1, TimeUnit.SECONDS))
activity.runOnUiThread {
- assertEquals(PxPosition(10.px, 10.px), layoutCoordinates.positionInRoot)
+ assertEquals(PxPosition(10f, 10f), layoutCoordinates.positionInRoot)
val bounds = layoutCoordinates.boundsInRoot
- assertEquals(PxBounds(10.px, 10.px, 40.px, 40.px), bounds)
+ assertEquals(PxBounds(10f, 10f, 40f, 40f), bounds)
val global = layoutCoordinates.globalBounds
val position = layoutCoordinates.globalPosition
assertEquals(position.x, global.left)
assertEquals(position.y, global.top)
- assertEquals(30.px, global.width)
- assertEquals(30.px, global.height)
+ assertEquals(30f, global.width)
+ assertEquals(30f, global.height)
}
}
@@ -109,8 +108,8 @@
assertTrue(positionLatch.await(1, TimeUnit.SECONDS))
activity.runOnUiThread {
val bounds = layoutCoordinates.boundsInRoot
- assertEquals(PxBounds(5.px, 0.px, 25.px, 30.px), bounds)
- assertEquals(PxPosition(5.px, 0.px), layoutCoordinates.positionInRoot)
+ assertEquals(PxBounds(5f, 0f, 25f, 30f), bounds)
+ assertEquals(PxPosition(5f, 0f), layoutCoordinates.positionInRoot)
}
}
@@ -131,8 +130,8 @@
assertTrue(positionLatch.await(1, TimeUnit.SECONDS))
activity.runOnUiThread {
val bounds = layoutCoordinates.boundsInRoot
- assertEquals(PxBounds(0.px, 10.px, 30.px, 20.px), bounds)
- assertEquals(PxPosition(30.px, 10.px), layoutCoordinates.positionInRoot)
+ assertEquals(PxBounds(0f, 10f, 30f, 20f), bounds)
+ assertEquals(PxPosition(30f, 10f), layoutCoordinates.positionInRoot)
}
}
@@ -154,8 +153,8 @@
assertTrue(positionLatch.await(1, TimeUnit.SECONDS))
activity.runOnUiThread {
val bounds = layoutCoordinates.boundsInRoot
- assertEquals(PxBounds(20.px, 10.px, 30.px, 20.px), bounds)
- assertEquals(PxPosition(30.px, 10.px), layoutCoordinates.positionInRoot)
+ assertEquals(PxBounds(20f, 10f, 30f, 20f), bounds)
+ assertEquals(PxPosition(30f, 10f), layoutCoordinates.positionInRoot)
}
}
@@ -177,8 +176,8 @@
assertTrue(positionLatch.await(1, TimeUnit.SECONDS))
activity.runOnUiThread {
val bounds = layoutCoordinates.boundsInRoot
- assertEquals(PxBounds(15.px, 18.px, 25.px, 28.px), bounds)
- assertEquals(PxPosition(15.px, 18.px), layoutCoordinates.positionInRoot)
+ assertEquals(PxBounds(15f, 18f, 25f, 28f), bounds)
+ assertEquals(PxPosition(15f, 18f), layoutCoordinates.positionInRoot)
}
}
@@ -201,9 +200,9 @@
assertTrue(positionLatch.await(1, TimeUnit.SECONDS))
activity.runOnUiThread {
val bounds = layoutCoordinates.boundsInRoot
- assertEquals(PxBounds(10.px, 10.px, 20.px, 20.px), bounds)
+ assertEquals(PxBounds(10f, 10f, 20f, 20f), bounds)
// Positions aren't clipped
- assertEquals(PxPosition(5.px, 10.px), layoutCoordinates.positionInRoot)
+ assertEquals(PxPosition(5f, 10f), layoutCoordinates.positionInRoot)
}
}
@@ -228,8 +227,8 @@
activity.runOnUiThread {
val bounds = layoutCoordinates.boundsInRoot
// should be completely clipped out
- assertEquals(0.px, bounds.width)
- assertEquals(0.px, bounds.height)
+ assertEquals(0f, bounds.width)
+ assertEquals(0f, bounds.height)
}
}
}
\ No newline at end of file
diff --git a/ui/ui-core/src/androidTest/java/androidx/ui/core/test/LayerTouchTransformTest.kt b/ui/ui-core/src/androidTest/java/androidx/ui/core/test/LayerTouchTransformTest.kt
index 4a7e807..b222ede 100644
--- a/ui/ui-core/src/androidTest/java/androidx/ui/core/test/LayerTouchTransformTest.kt
+++ b/ui/ui-core/src/androidTest/java/androidx/ui/core/test/LayerTouchTransformTest.kt
@@ -41,7 +41,6 @@
import androidx.ui.test.doPartialGesture
import androidx.ui.test.findByTag
import androidx.ui.test.sendDown
-import androidx.ui.unit.Px
import androidx.ui.unit.PxPosition
import androidx.ui.unit.dp
import androidx.ui.unit.ipx
@@ -123,7 +122,7 @@
// however, after transformations, this point will be within
// its bounds
- val mappedPosition = PxPosition(Px(342.0f), Px(168.0f))
+ val mappedPosition = PxPosition(342.0f, 168.0f)
val node = findByTag(testTag).doPartialGesture { sendDown(mappedPosition) }
latch = CountDownLatch(1).apply {
@@ -134,8 +133,8 @@
Assert.assertEquals(
Color.Red.toArgb(),
getPixel(
- mappedPosition.x.value.toInt(),
- mappedPosition.y.value.toInt()
+ mappedPosition.x.toInt(),
+ mappedPosition.y.toInt()
)
)
}
diff --git a/ui/ui-core/src/androidTest/java/androidx/ui/core/test/OnPositionedTest.kt b/ui/ui-core/src/androidTest/java/androidx/ui/core/test/OnPositionedTest.kt
index 6c2cb50d..77fec16 100644
--- a/ui/ui-core/src/androidTest/java/androidx/ui/core/test/OnPositionedTest.kt
+++ b/ui/ui-core/src/androidTest/java/androidx/ui/core/test/OnPositionedTest.kt
@@ -34,7 +34,6 @@
import androidx.ui.unit.PxBounds
import androidx.ui.unit.PxPosition
import androidx.ui.unit.ipx
-import androidx.ui.unit.px
import androidx.ui.unit.toPx
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
@@ -66,8 +65,8 @@
val size = 50.ipx
var index by mutableStateOf(0)
var latch = CountDownLatch(2)
- var wrap1Position = 0.px
- var wrap2Position = 0.px
+ var wrap1Position = 0f
+ var wrap2Position = 0f
rule.runOnUiThread {
activity.setContent {
SimpleRow {
@@ -96,15 +95,15 @@
}
}
assertTrue(latch.await(1, TimeUnit.SECONDS))
- assertEquals(0.px, wrap1Position)
- assertEquals(size.toPx(), wrap2Position)
+ assertEquals(0f, wrap1Position)
+ assertEquals(size.toPx().value, wrap2Position)
latch = CountDownLatch(2)
rule.runOnUiThread {
index = 1
}
assertTrue(latch.await(1, TimeUnit.SECONDS))
- assertEquals(size.toPx(), wrap1Position)
- assertEquals(0.px, wrap2Position)
+ assertEquals(size.toPx().value, wrap1Position)
+ assertEquals(0f, wrap2Position)
}
@Test
@@ -148,7 +147,7 @@
@Test
fun callbackCalledForChildWhenParentMoved() {
var position by mutableStateOf(0.ipx)
- var childGlobalPosition = PxPosition(0.px, 0.px)
+ var childGlobalPosition = PxPosition(0f, 0f)
var latch = CountDownLatch(1)
rule.runOnUiThreadIR {
activity.setContent {
@@ -185,7 +184,7 @@
}
assertTrue(latch.await(1, TimeUnit.SECONDS))
- assertEquals(PxPosition(10.px, 0.px), childGlobalPosition)
+ assertEquals(PxPosition(10f, 0f), childGlobalPosition)
}
@Test
@@ -259,7 +258,7 @@
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
rule.runOnUiThread {
- assertEquals(PxPosition(5.px, 5.px), coordinates!!.positionInParent)
+ assertEquals(PxPosition(5f, 5f), coordinates!!.positionInParent)
var root = coordinates!!
while (root.parentCoordinates != null) {
@@ -290,14 +289,14 @@
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
rule.runOnUiThread {
- assertEquals(PxBounds(5.px, 5.px, 15.px, 15.px), coordinates!!.boundsInParent)
+ assertEquals(PxBounds(5f, 5f, 15f, 15f), coordinates!!.boundsInParent)
var root = coordinates!!
while (root.parentCoordinates != null) {
root = root.parentCoordinates!!
}
- assertEquals(PxBounds(0.px, 0.px, 20.px, 20.px), root.boundsInParent)
+ assertEquals(PxBounds(0f, 0f, 20f, 20f), root.boundsInParent)
}
}
}
\ No newline at end of file
diff --git a/ui/ui-core/src/androidTest/java/androidx/ui/core/test/RootNodeLayoutTest.kt b/ui/ui-core/src/androidTest/java/androidx/ui/core/test/RootNodeLayoutTest.kt
index 64c5d88..5e5ca89 100644
--- a/ui/ui-core/src/androidTest/java/androidx/ui/core/test/RootNodeLayoutTest.kt
+++ b/ui/ui-core/src/androidTest/java/androidx/ui/core/test/RootNodeLayoutTest.kt
@@ -32,7 +32,6 @@
import androidx.ui.layout.fillMaxSize
import androidx.ui.unit.PxBounds
import androidx.ui.unit.ipx
-import androidx.ui.unit.px
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotEquals
import org.junit.Assert.assertNotNull
@@ -96,7 +95,7 @@
assertTrue(latch.await(1, TimeUnit.SECONDS))
assertNotNull(coordinates)
- assertEquals(PxBounds(left = 0.px, top = 0.px, right = 10.px, bottom = 10.px),
+ assertEquals(PxBounds(left = 0f, top = 0f, right = 10f, bottom = 10f),
coordinates!!.boundsInRoot)
}
diff --git a/ui/ui-core/src/main/java/androidx/ui/core/AndroidComposeViewAccessibilityDelegateCompat.kt b/ui/ui-core/src/main/java/androidx/ui/core/AndroidComposeViewAccessibilityDelegateCompat.kt
index df42734..51d2b3d 100644
--- a/ui/ui-core/src/main/java/androidx/ui/core/AndroidComposeViewAccessibilityDelegateCompat.kt
+++ b/ui/ui-core/src/main/java/androidx/ui/core/AndroidComposeViewAccessibilityDelegateCompat.kt
@@ -128,10 +128,10 @@
try {
info.setBoundsInScreen(
android.graphics.Rect(
- semanticsNode.globalBounds.left.value.toInt(),
- semanticsNode.globalBounds.top.value.toInt(),
- semanticsNode.globalBounds.right.value.toInt(),
- semanticsNode.globalBounds.bottom.value.toInt()
+ semanticsNode.globalBounds.left.toInt(),
+ semanticsNode.globalBounds.top.toInt(),
+ semanticsNode.globalBounds.right.toInt(),
+ semanticsNode.globalBounds.bottom.toInt()
)
)
} catch (e: IllegalStateException) {
@@ -471,8 +471,8 @@
private fun getVirtualViewAt(x: Float, y: Float): Int {
var node = view.semanticsOwner.rootSemanticsNode
- var id = findVirtualViewAt(x + node.globalBounds.left.value,
- y + node.globalBounds.top.value, node)
+ var id = findVirtualViewAt(x + node.globalBounds.left,
+ y + node.globalBounds.top, node)
if (id == node.id) {
return AccessibilityNodeProviderCompat.HOST_VIEW_ID
}
@@ -488,8 +488,8 @@
}
}
- if (node.globalBounds.left.value < x && node.globalBounds.right.value > x && node
- .globalBounds.top.value < y && node.globalBounds.bottom.value > y) {
+ if (node.globalBounds.left < x && node.globalBounds.right > x && node
+ .globalBounds.top < y && node.globalBounds.bottom > y) {
return node.id
}
diff --git a/ui/ui-core/src/main/java/androidx/ui/core/LayerWrapper.kt b/ui/ui-core/src/main/java/androidx/ui/core/LayerWrapper.kt
index 5be6042..1ec5dcc9 100644
--- a/ui/ui-core/src/main/java/androidx/ui/core/LayerWrapper.kt
+++ b/ui/ui-core/src/main/java/androidx/ui/core/LayerWrapper.kt
@@ -21,7 +21,6 @@
import androidx.ui.graphics.Canvas
import androidx.ui.unit.IntPxPosition
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.px
internal class LayerWrapper(
wrapped: LayoutNodeWrapper,
@@ -110,8 +109,8 @@
* and untransformed position.
*/
private fun mapPointsFromMatrix(matrix: Matrix, position: PxPosition): PxPosition {
- val x = position.x.value
- val y = position.y.value
+ val x = position.x
+ val y = position.y
val cache = positionCache
val point = if (cache != null) {
cache[0] = x
@@ -121,7 +120,7 @@
floatArrayOf(x, y).also { positionCache = it }
}
matrix.mapPoints(point)
- return PxPosition(point[0].px, point[1].px)
+ return PxPosition(point[0], point[1])
}
override fun rectInParent(bounds: RectF) {
diff --git a/ui/ui-core/src/main/java/androidx/ui/core/LayoutCoordinates.kt b/ui/ui-core/src/main/java/androidx/ui/core/LayoutCoordinates.kt
index 7254dfe..1a44ca0 100644
--- a/ui/ui-core/src/main/java/androidx/ui/core/LayoutCoordinates.kt
+++ b/ui/ui-core/src/main/java/androidx/ui/core/LayoutCoordinates.kt
@@ -20,8 +20,6 @@
import androidx.ui.unit.IntPxSize
import androidx.ui.unit.PxBounds
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.px
-import androidx.ui.unit.toPx
/**
* A holder of the measured bounds for the layout (MeasureBox).
@@ -112,7 +110,7 @@
*/
val LayoutCoordinates.boundsInParent: PxBounds
get() = parentCoordinates?.childBoundingBox(this)
- ?: PxBounds(0.px, 0.px, size.width.toPx(), size.height.toPx())
+ ?: PxBounds(0f, 0f, size.width.value.toFloat(), size.height.value.toFloat())
/**
* The global boundaries of this layout inside.
diff --git a/ui/ui-core/src/main/java/androidx/ui/core/LayoutNode.kt b/ui/ui-core/src/main/java/androidx/ui/core/LayoutNode.kt
index d8235d5..bcb2b78 100644
--- a/ui/ui-core/src/main/java/androidx/ui/core/LayoutNode.kt
+++ b/ui/ui-core/src/main/java/androidx/ui/core/LayoutNode.kt
@@ -32,6 +32,7 @@
import androidx.ui.unit.Density
import androidx.ui.unit.IntPx
import androidx.ui.unit.PxPosition
+import androidx.ui.unit.px
import androidx.ui.unit.round
import androidx.ui.util.fastForEach
import kotlin.math.sign
@@ -740,7 +741,7 @@
wrapper = wrapper.wrappedBy!!
}
pos = wrapper.toParentPosition(pos)
- return if (line is HorizontalAlignmentLine) pos.y.round() else pos.x.round()
+ return if (line is HorizontalAlignmentLine) pos.y.px.round() else pos.x.px.round()
}
/**
diff --git a/ui/ui-core/src/main/java/androidx/ui/core/LayoutNodeWrapper.kt b/ui/ui-core/src/main/java/androidx/ui/core/LayoutNodeWrapper.kt
index 4bf2605..0140b8a 100644
--- a/ui/ui-core/src/main/java/androidx/ui/core/LayoutNodeWrapper.kt
+++ b/ui/ui-core/src/main/java/androidx/ui/core/LayoutNodeWrapper.kt
@@ -29,7 +29,6 @@
import androidx.ui.unit.IntPxSize
import androidx.ui.unit.PxBounds
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.px
import androidx.ui.unit.toPxPosition
/**
@@ -99,10 +98,10 @@
// TODO(shepshapard): Right now globalToLocal has to traverse the tree all the way back up
// so calling this is expensive. Would be nice to cache data such that this is cheap.
val localPointerPosition = globalToLocal(globalPointerPosition)
- return localPointerPosition.x.value >= 0 &&
- localPointerPosition.x < measuredSize.width &&
- localPointerPosition.y.value >= 0 &&
- localPointerPosition.y < measuredSize.height
+ return localPointerPosition.x >= 0 &&
+ localPointerPosition.x < measuredSize.width.value &&
+ localPointerPosition.y >= 0 &&
+ localPointerPosition.y < measuredSize.height.value
}
/**
@@ -282,10 +281,10 @@
wrapper = parent
}
return PxBounds(
- left = bounds.left.px,
- top = bounds.top.px,
- right = bounds.right.px,
- bottom = bounds.bottom.px
+ left = bounds.left,
+ top = bounds.top,
+ right = bounds.right,
+ bottom = bounds.bottom
)
}
diff --git a/ui/ui-core/src/main/java/androidx/ui/core/PainterModifier.kt b/ui/ui-core/src/main/java/androidx/ui/core/PainterModifier.kt
index 64cc3cb..6b1e3c4 100644
--- a/ui/ui-core/src/main/java/androidx/ui/core/PainterModifier.kt
+++ b/ui/ui-core/src/main/java/androidx/ui/core/PainterModifier.kt
@@ -25,11 +25,11 @@
import androidx.ui.graphics.drawscope.withTransform
import androidx.ui.unit.IntPx
import androidx.ui.unit.IntPxSize
-import androidx.ui.unit.Px
import androidx.ui.unit.PxSize
-import androidx.ui.unit.ceil
-import androidx.ui.unit.max
+import androidx.ui.unit.ipx
import kotlin.math.ceil
+import kotlin.math.max
+import kotlin.math.roundToInt
/**
* Create a [DrawModifier] from this [Painter]. This modifier is memoized and re-used across
@@ -138,12 +138,13 @@
layoutDirection: LayoutDirection
): IntPx {
val constraints = Constraints(maxHeight = height)
- val layoutWidth = measurable.minIntrinsicWidth(modifyConstraints(constraints).maxHeight)
+ val layoutWidth =
+ measurable.minIntrinsicWidth(modifyConstraints(constraints).maxHeight).value
val painterIntrinsicWidth =
- Px(painter.intrinsicSize.width).takeUnless {
- !sizeToIntrinsics || it == Px.Infinity
- }?.ceil() ?: layoutWidth
- return max(painterIntrinsicWidth, layoutWidth)
+ painter.intrinsicSize.width.takeUnless {
+ !sizeToIntrinsics || it == Float.POSITIVE_INFINITY
+ }?.roundToInt() ?: layoutWidth
+ return max(painterIntrinsicWidth, layoutWidth).ipx
}
override fun IntrinsicMeasureScope.maxIntrinsicWidth(
@@ -152,12 +153,13 @@
layoutDirection: LayoutDirection
): IntPx {
val constraints = Constraints(maxHeight = height)
- val layoutWidth = measurable.maxIntrinsicWidth(modifyConstraints(constraints).maxHeight)
+ val layoutWidth =
+ measurable.maxIntrinsicWidth(modifyConstraints(constraints).maxHeight).value
val painterIntrinsicWidth =
- Px(painter.intrinsicSize.width).takeUnless {
- !sizeToIntrinsics || it == Px.Infinity
- }?.ceil() ?: layoutWidth
- return max(painterIntrinsicWidth, layoutWidth)
+ painter.intrinsicSize.width.takeUnless {
+ !sizeToIntrinsics || it == Float.POSITIVE_INFINITY
+ }?.roundToInt() ?: layoutWidth
+ return max(painterIntrinsicWidth, layoutWidth).ipx
}
override fun IntrinsicMeasureScope.minIntrinsicHeight(
@@ -166,12 +168,13 @@
layoutDirection: LayoutDirection
): IntPx {
val constraints = Constraints(maxWidth = width)
- val layoutHeight = measurable.minIntrinsicHeight(modifyConstraints(constraints).maxWidth)
+ val layoutHeight =
+ measurable.minIntrinsicHeight(modifyConstraints(constraints).maxWidth).value
val painterIntrinsicHeight =
- Px(painter.intrinsicSize.height).takeUnless {
- !sizeToIntrinsics || it == Px.Infinity
- }?.ceil() ?: layoutHeight
- return max(painterIntrinsicHeight, layoutHeight)
+ painter.intrinsicSize.height.takeUnless {
+ !sizeToIntrinsics || it == Float.POSITIVE_INFINITY
+ }?.roundToInt() ?: layoutHeight
+ return max(painterIntrinsicHeight, layoutHeight).ipx
}
override fun IntrinsicMeasureScope.maxIntrinsicHeight(
@@ -180,24 +183,25 @@
layoutDirection: LayoutDirection
): IntPx {
val constraints = Constraints(maxWidth = width)
- val layoutHeight = measurable.maxIntrinsicHeight(modifyConstraints(constraints).maxWidth)
+ val layoutHeight =
+ measurable.maxIntrinsicHeight(modifyConstraints(constraints).maxWidth).value
val painterIntrinsicHeight =
- Px(painter.intrinsicSize.height).takeUnless {
- !sizeToIntrinsics || it == Px.Infinity
- }?.ceil() ?: layoutHeight
- return max(painterIntrinsicHeight, layoutHeight)
+ painter.intrinsicSize.height.takeUnless {
+ !sizeToIntrinsics || it == Float.POSITIVE_INFINITY
+ }?.roundToInt() ?: layoutHeight
+ return max(painterIntrinsicHeight, layoutHeight).ipx
}
private fun modifyConstraints(constraints: Constraints): Constraints {
val intrinsicSize = painter.intrinsicSize
val intrinsicWidth =
- Px(intrinsicSize.width).takeUnless {
- !sizeToIntrinsics || it == Px.Infinity
- }?.ceil() ?: constraints.minWidth
+ intrinsicSize.width.takeUnless {
+ !sizeToIntrinsics || it == Float.POSITIVE_INFINITY
+ }?.roundToInt()?.ipx ?: constraints.minWidth
val intrinsicHeight =
- Px(intrinsicSize.height).takeUnless {
- !sizeToIntrinsics || it == Px.Infinity
- }?.ceil() ?: constraints.minHeight
+ intrinsicSize.height.takeUnless {
+ !sizeToIntrinsics || it == Float.POSITIVE_INFINITY
+ }?.roundToInt()?.ipx ?: constraints.minHeight
val minWidth = intrinsicWidth.coerceIn(constraints.minWidth, constraints.maxWidth)
val minHeight = intrinsicHeight.coerceIn(constraints.minHeight, constraints.maxHeight)
diff --git a/ui/ui-core/src/main/java/androidx/ui/core/ParentDataModifier.kt b/ui/ui-core/src/main/java/androidx/ui/core/ParentDataModifier.kt
index 1ce6cb2..5ba5e01 100644
--- a/ui/ui-core/src/main/java/androidx/ui/core/ParentDataModifier.kt
+++ b/ui/ui-core/src/main/java/androidx/ui/core/ParentDataModifier.kt
@@ -19,12 +19,14 @@
import androidx.ui.unit.Density
/**
- * A [Modifier.Element] that provides additional data to the parent layout which is available
- * during the measurement.
+ * A [Modifier] that provides data to the parent [Layout]. This can be read from within the
+ * the [Layout] during measurement and positioning, via [IntrinsicMeasurable.parentData].
+ * Th parent data is commonly used to inform the parent how the child [Layout] should be measured
+ * and positioned.
*/
interface ParentDataModifier : Modifier.Element {
/**
- * Provides a parentData given the [parentData] already provided through the modifier's chain.
+ * Provides a parentData, given the [parentData] already provided through the modifier's chain.
*/
- fun Density.modifyParentData(parentData: Any?): Any? = parentData
+ fun Density.modifyParentData(parentData: Any?): Any?
}
diff --git a/ui/ui-core/src/main/java/androidx/ui/core/Placeable.kt b/ui/ui-core/src/main/java/androidx/ui/core/Placeable.kt
index 60c257b..06c12a5 100644
--- a/ui/ui-core/src/main/java/androidx/ui/core/Placeable.kt
+++ b/ui/ui-core/src/main/java/androidx/ui/core/Placeable.kt
@@ -19,7 +19,6 @@
import androidx.ui.unit.IntPx
import androidx.ui.unit.IntPxPosition
import androidx.ui.unit.IntPxSize
-import androidx.ui.unit.Px
import androidx.ui.unit.PxPosition
import androidx.ui.unit.coerceIn
import androidx.ui.unit.round
@@ -148,17 +147,6 @@
fun Placeable.place(x: IntPx, y: IntPx) = placeAutoMirrored(IntPxPosition(x, y))
/**
- * Place a [Placeable] at [x], [y] in its parent's coordinate system.
- * If the layout direction is right-to-left, the given position will be horizontally
- * mirrored so that the position of the [Placeable] implicitly reacts to RTL layout
- * direction contexts.
- * If this method is used outside the [MeasureScope.layout] positioning block, the
- * automatic position mirroring will not happen and the [Placeable] will be placed at the
- * given position, similar to the [placeAbsolute] method.
- */
- fun Placeable.place(x: Px, y: Px) = placeAutoMirrored(IntPxPosition(x.round(), y.round()))
-
- /**
* Place a [Placeable] at [position] in its parent's coordinate system.
* Unlike [place], the given [position] will not implicitly react in RTL layout direction
* contexts.
@@ -173,14 +161,6 @@
fun Placeable.placeAbsolute(x: IntPx, y: IntPx) = placeAbsolute(IntPxPosition(x, y))
/**
- * Place a [Placeable] at [x], [y] in its parent's coordinate system.
- * Unlike [place], the given position will not implicitly react in RTL layout direction
- * contexts.
- */
- fun Placeable.placeAbsolute(x: Px, y: Px) =
- placeAbsolute(IntPxPosition(x.round(), y.round()))
-
- /**
* Place a [Placeable] at [position] in its parent's coordinate system.
* Unlike [place], the given [position] will not implicitly react in RTL layout direction
* contexts.
diff --git a/ui/ui-core/src/main/java/androidx/ui/core/PointerInput.kt b/ui/ui-core/src/main/java/androidx/ui/core/PointerInput.kt
index deec36c..cbf43de 100644
--- a/ui/ui-core/src/main/java/androidx/ui/core/PointerInput.kt
+++ b/ui/ui-core/src/main/java/androidx/ui/core/PointerInput.kt
@@ -19,10 +19,8 @@
import androidx.compose.Immutable
import androidx.compose.Stable
import androidx.ui.unit.IntPxSize
-import androidx.ui.unit.Px
import androidx.ui.unit.PxPosition
import androidx.ui.unit.Uptime
-import androidx.ui.unit.px
/**
* Describes a change that has occurred for a particular pointer, as well as how much of the change
@@ -213,7 +211,7 @@
val offset =
if (previousPosition == null || currentPosition == null) {
- PxPosition(0.px, 0.px)
+ PxPosition(0.0f, 0.0f)
} else {
currentPosition - previousPosition
}
@@ -231,7 +229,7 @@
* True if any of this [PointerInputChange]'s movement has been consumed.
*/
fun PointerInputChange.anyPositionChangeConsumed() =
- consumed.positionChange.x.value != 0f || consumed.positionChange.y.value != 0f
+ consumed.positionChange.x != 0f || consumed.positionChange.y != 0f
/**
* True if any aspect of this [PointerInputChange] has been consumed.
@@ -262,8 +260,8 @@
* @param consumedDy The amount of position change on the y axis to consume.
*/
fun PointerInputChange.consumePositionChange(
- consumedDx: Px,
- consumedDy: Px
+ consumedDx: Float,
+ consumedDy: Float
): PointerInputChange {
val newConsumedDx = consumedDx + consumed.positionChange.x
val newConsumedDy = consumedDy + consumed.positionChange.y
diff --git a/ui/ui-core/src/main/java/androidx/ui/core/TestTag.kt b/ui/ui-core/src/main/java/androidx/ui/core/TestTag.kt
index f48f467..ab6254c 100644
--- a/ui/ui-core/src/main/java/androidx/ui/core/TestTag.kt
+++ b/ui/ui-core/src/main/java/androidx/ui/core/TestTag.kt
@@ -27,11 +27,9 @@
* Applies a tag to allow this element to be found in tests.
*
* This is a convenience method for a [Semantics] that sets [SemanticsPropertyReceiver.testTag].
- *
- * Note that this does not, by itself, create a semantics boundary. If the element you are
- * setting this on does not already create a boundary, you will need to create one.
*/
@Composable
+@Deprecated(message = "Use Modifier.testTag instead.")
fun TestTag(tag: String, children: @Composable () -> Unit) {
Semantics(properties = { testTag = tag }, children = children)
}
@@ -40,9 +38,6 @@
* Applies a tag to allow modified element to be found in tests.
*
* This is a convenience method for a [semantics] that sets [SemanticsPropertyReceiver.testTag].
- *
- * Note that this does not, by itself, create a semantics boundary. If the element you are
- * setting this on does not already create a boundary, you will need to create one.
*/
@Stable
fun Modifier.testTag(tag: String) = semantics(
diff --git a/ui/ui-core/src/main/java/androidx/ui/core/gesture/DragSlopExceededGestureFilter.kt b/ui/ui-core/src/main/java/androidx/ui/core/gesture/DragSlopExceededGestureFilter.kt
index 5652019..c75d811 100644
--- a/ui/ui-core/src/main/java/androidx/ui/core/gesture/DragSlopExceededGestureFilter.kt
+++ b/ui/ui-core/src/main/java/androidx/ui/core/gesture/DragSlopExceededGestureFilter.kt
@@ -155,7 +155,7 @@
val sizeAsFloat = changes.size.toFloat()
// TODO(b/148980115): Once PxPosition is removed, sum will be an Offset, and this line can
// just be straight division.
- return Offset(sum.x.value / sizeAsFloat, sum.y.value / sizeAsFloat)
+ return Offset(sum.x / sizeAsFloat, sum.y / sizeAsFloat)
}
/**
diff --git a/ui/ui-core/src/main/java/androidx/ui/core/gesture/GestureUtils.kt b/ui/ui-core/src/main/java/androidx/ui/core/gesture/GestureUtils.kt
index 9269531..61b9d59 100644
--- a/ui/ui-core/src/main/java/androidx/ui/core/gesture/GestureUtils.kt
+++ b/ui/ui-core/src/main/java/androidx/ui/core/gesture/GestureUtils.kt
@@ -35,10 +35,10 @@
fun List<PointerInputChange>.anyPointersInBounds(bounds: IntPxSize) =
fastAny {
it.current.down &&
- it.current.position!!.x.value >= 0 &&
- it.current.position.x < bounds.width &&
- it.current.position.y.value >= 0 &&
- it.current.position.y < bounds.height
+ it.current.position!!.x >= 0 &&
+ it.current.position.x < bounds.width.value &&
+ it.current.position.y >= 0 &&
+ it.current.position.y < bounds.height.value
}
internal class PointerInputModifierImpl(override val pointerInputFilter: PointerInputFilter) :
diff --git a/ui/ui-core/src/main/java/androidx/ui/core/gesture/RawDragGestureFilter.kt b/ui/ui-core/src/main/java/androidx/ui/core/gesture/RawDragGestureFilter.kt
index d5f3593..4a38933 100644
--- a/ui/ui-core/src/main/java/androidx/ui/core/gesture/RawDragGestureFilter.kt
+++ b/ui/ui-core/src/main/java/androidx/ui/core/gesture/RawDragGestureFilter.kt
@@ -33,7 +33,6 @@
import androidx.ui.core.positionChange
import androidx.ui.unit.IntPxSize
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.px
import androidx.ui.util.fastAny
import androidx.ui.util.fastForEach
@@ -266,8 +265,8 @@
var totalDy = 0f
movedChanges.fastForEach {
- totalDx += it.positionChange().x.value
- totalDy += it.positionChange().y.value
+ totalDx += it.positionChange().x
+ totalDy += it.positionChange().y
}
if (totalDx != 0f || totalDy != 0f) {
@@ -284,8 +283,8 @@
val consumed = dragObserver.onDrag(
PxPosition(
- (totalDx / changesToReturn.size).px,
- (totalDy / changesToReturn.size).px
+ totalDx / changesToReturn.size,
+ totalDy / changesToReturn.size
)
)
@@ -313,8 +312,8 @@
}
private fun Iterable<PxPosition>.averagePosition(): PxPosition {
- var x = 0.px
- var y = 0.px
+ var x = 0f
+ var y = 0f
forEach {
x += it.x
y += it.y
diff --git a/ui/ui-core/src/main/java/androidx/ui/core/gesture/ScaleUtil.kt b/ui/ui-core/src/main/java/androidx/ui/core/gesture/ScaleUtil.kt
index 037721f..c7cb8ad 100644
--- a/ui/ui-core/src/main/java/androidx/ui/core/gesture/ScaleUtil.kt
+++ b/ui/ui-core/src/main/java/androidx/ui/core/gesture/ScaleUtil.kt
@@ -60,16 +60,16 @@
internal fun List<PointerInputChange>.calculateAllDimensionInformation() =
AllDimensionData(
map {
- it.previous.position!!.x.value
+ it.previous.position!!.x
}.calculateDimensionInformation(),
map {
- it.previous.position!!.y.value
+ it.previous.position!!.y
}.calculateDimensionInformation(),
map {
- it.previous.position!!.x.value + it.positionChange().x.value
+ it.previous.position!!.x + it.positionChange().x
}.calculateDimensionInformation(),
map {
- it.previous.position!!.y.value + it.positionChange().y.value
+ it.previous.position!!.y + it.positionChange().y
}.calculateDimensionInformation()
)
diff --git a/ui/ui-core/src/main/java/androidx/ui/core/gesture/util/VelocityTracker.kt b/ui/ui-core/src/main/java/androidx/ui/core/gesture/util/VelocityTracker.kt
index d634ce8..c2c45bc 100644
--- a/ui/ui-core/src/main/java/androidx/ui/core/gesture/util/VelocityTracker.kt
+++ b/ui/ui-core/src/main/java/androidx/ui/core/gesture/util/VelocityTracker.kt
@@ -21,7 +21,6 @@
import androidx.ui.unit.Uptime
import androidx.ui.unit.Velocity
import androidx.ui.unit.inMilliseconds
-import androidx.ui.unit.px
import kotlin.math.absoluteValue
private const val AssumePointerMoveStoppedMilliseconds: Int = 40
@@ -112,8 +111,8 @@
oldestSample = sample
val position: PxPosition = sample.point
- x.add(position.x.value)
- y.add(position.y.value)
+ x.add(position.x)
+ y.add(position.y)
time.add(-age)
index = (if (index == 0) HistorySize else index) - 1
@@ -133,8 +132,8 @@
return VelocityEstimate(
pixelsPerSecond = PxPosition(
// Convert from pixels/ms to pixels/s
- (xSlope * 1000).px,
- (ySlope * 1000).px
+ (xSlope * 1000),
+ (ySlope * 1000)
),
confidence = xFit.confidence * yFit.confidence,
duration = newestSample.time - oldestSample.time,
diff --git a/ui/ui-core/src/main/java/androidx/ui/core/pointerinput/MotionEventAdapter.kt b/ui/ui-core/src/main/java/androidx/ui/core/pointerinput/MotionEventAdapter.kt
index cc70698..310ecf9 100644
--- a/ui/ui-core/src/main/java/androidx/ui/core/pointerinput/MotionEventAdapter.kt
+++ b/ui/ui-core/src/main/java/androidx/ui/core/pointerinput/MotionEventAdapter.kt
@@ -28,7 +28,6 @@
import androidx.ui.unit.NanosecondsPerMillisecond
import androidx.ui.unit.PxPosition
import androidx.ui.unit.Uptime
-import androidx.ui.unit.px
/**
* Converts Android framework [MotionEvent]s into Compose [PointerInputEvent]s.
@@ -145,7 +144,7 @@
): PointerInputData {
val pointerCoords = MotionEvent.PointerCoords()
motionEvent.getPointerCoords(index, pointerCoords)
- val offset = PxPosition(pointerCoords.x.px, pointerCoords.y.px)
+ val offset = PxPosition(pointerCoords.x, pointerCoords.y)
return PointerInputData(
timestamp,
diff --git a/ui/ui-core/src/main/java/androidx/ui/core/selection/SelectionContainer.kt b/ui/ui-core/src/main/java/androidx/ui/core/selection/SelectionContainer.kt
index 8d371c3..9621cd8 100644
--- a/ui/ui-core/src/main/java/androidx/ui/core/selection/SelectionContainer.kt
+++ b/ui/ui-core/src/main/java/androidx/ui/core/selection/SelectionContainer.kt
@@ -44,6 +44,7 @@
import androidx.ui.unit.ipx
import androidx.ui.unit.isFinite
import androidx.ui.unit.max
+import androidx.ui.unit.px
import androidx.ui.unit.round
/**
@@ -133,7 +134,7 @@
} else {
if (isStartHandle) Alignment.TopStart else Alignment.TopEnd
},
- offset = IntPxPosition(offset.x.round(), offset.y.round())
+ offset = IntPxPosition(offset.x.px.round(), offset.y.px.round())
) {
val drag = Modifier.dragGestureFilter(
dragObserver = manager.handleDragObserver(isStartHandle = isStartHandle)
diff --git a/ui/ui-core/src/main/java/androidx/ui/core/selection/SelectionManager.kt b/ui/ui-core/src/main/java/androidx/ui/core/selection/SelectionManager.kt
index 3acc691..6693f76 100644
--- a/ui/ui-core/src/main/java/androidx/ui/core/selection/SelectionManager.kt
+++ b/ui/ui-core/src/main/java/androidx/ui/core/selection/SelectionManager.kt
@@ -33,11 +33,10 @@
import androidx.ui.text.AnnotatedString
import androidx.ui.text.length
import androidx.ui.text.subSequence
-import androidx.ui.unit.Px
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.max
-import androidx.ui.unit.min
import androidx.ui.unit.px
+import kotlin.math.max
+import kotlin.math.min
/**
* A bridge class between user interaction to the text composables for text selection.
@@ -310,16 +309,16 @@
var startTop = localLayoutCoordinates.childToLocal(
startLayoutCoordinates,
PxPosition(
- Px.Zero,
- selection.start.selectable.getBoundingBox(selection.start.offset).top.px
+ 0f,
+ selection.start.selectable.getBoundingBox(selection.start.offset).top
)
)
var endTop = localLayoutCoordinates.childToLocal(
endLayoutCoordinates,
PxPosition(
- Px.Zero,
- selection.end.selectable.getBoundingBox(selection.end.offset).top.px
+ 0.0f,
+ selection.end.selectable.getBoundingBox(selection.end.offset).top
)
)
@@ -327,13 +326,13 @@
endTop = localLayoutCoordinates.localToRoot(endTop)
val top = min(startTop.y, endTop.y)
- val bottom = max(startOffset.y, endOffset.y) + (HANDLE_HEIGHT.value * 4.0).px
+ val bottom = max(startOffset.y, endOffset.y) + (HANDLE_HEIGHT.value * 4.0).px.value
return Rect(
- left.value,
- top.value,
- right.value,
- bottom.value
+ left,
+ top,
+ right,
+ bottom
)
}
return Rect.zero
@@ -344,8 +343,8 @@
// Call mergeSelections with an out of boundary input to inform all text widgets to
// cancel their individual selection.
mergeSelections(
- startPosition = PxPosition((-1).px, (-1).px),
- endPosition = PxPosition((-1).px, (-1).px),
+ startPosition = PxPosition(-1f, -1f),
+ endPosition = PxPosition(-1f, -1f),
previousSelection = selection
)
if (selection != null) onSelectionChange(null)
@@ -399,7 +398,7 @@
* hit current line, move up this y coordinates by 1 pixel.
*/
private fun getAdjustedCoordinates(position: PxPosition): PxPosition {
- return PxPosition(position.x, position.y - 1.px)
+ return PxPosition(position.x, position.y - 1f)
}
fun handleDragObserver(isStartHandle: Boolean): DragObserver {
diff --git a/ui/ui-core/src/main/java/androidx/ui/node/PointerInteropUtils.kt b/ui/ui-core/src/main/java/androidx/ui/node/PointerInteropUtils.kt
index 8c2da8c..8d23589 100644
--- a/ui/ui-core/src/main/java/androidx/ui/node/PointerInteropUtils.kt
+++ b/ui/ui-core/src/main/java/androidx/ui/node/PointerInteropUtils.kt
@@ -60,9 +60,9 @@
val pointerCoords =
map {
if (it.changedToUpIgnoreConsumed()) {
- PointerCoords(it.previous.position!!.x.value, it.previous.position.y.value)
+ PointerCoords(it.previous.position!!.x, it.previous.position.y)
} else {
- PointerCoords(it.current.position!!.x.value, it.current.position.y.value)
+ PointerCoords(it.current.position!!.x, it.current.position.y)
}
}.toTypedArray()
@@ -95,9 +95,9 @@
val pointerCoords =
map {
if (it.changedToUpIgnoreConsumed()) {
- PointerCoords(it.previous.position!!.x.value, it.previous.position.y.value)
+ PointerCoords(it.previous.position!!.x, it.previous.position.y)
} else {
- PointerCoords(it.current.position!!.x.value, it.current.position.y.value)
+ PointerCoords(it.current.position!!.x, it.current.position.y)
}
}.toTypedArray()
diff --git a/ui/ui-core/src/main/java/androidx/ui/semantics/SemanticsProperties.kt b/ui/ui-core/src/main/java/androidx/ui/semantics/SemanticsProperties.kt
index 1873937..8c393f6 100644
--- a/ui/ui-core/src/main/java/androidx/ui/semantics/SemanticsProperties.kt
+++ b/ui/ui-core/src/main/java/androidx/ui/semantics/SemanticsProperties.kt
@@ -16,7 +16,6 @@
package androidx.ui.semantics
-import androidx.ui.unit.Px
import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KProperty
@@ -70,7 +69,7 @@
// action to scroll to a specified position
val ScrollTo =
- SemanticsPropertyKey<AccessibilityAction<(x: Px, y: Px) -> Boolean>>("ScrollTo")
+ SemanticsPropertyKey<AccessibilityAction<(x: Float, y: Float) -> Boolean>>("ScrollTo")
// custom actions which are defined by app developers
val CustomActions =
@@ -202,7 +201,10 @@
this[SemanticsActions.OnClick] = AccessibilityAction(label, action)
}
-fun SemanticsPropertyReceiver.ScrollTo(label: String? = null, action: (x: Px, y: Px) -> Boolean) {
+fun SemanticsPropertyReceiver.ScrollTo(
+ label: String? = null,
+ action: (x: Float, y: Float) -> Boolean
+) {
this[SemanticsActions.ScrollTo] = AccessibilityAction(label, action)
}
diff --git a/ui/ui-core/src/main/java/androidx/ui/testutils/PointerInputTestUtil.kt b/ui/ui-core/src/main/java/androidx/ui/testutils/PointerInputTestUtil.kt
index 6512c43..f6fa05c 100644
--- a/ui/ui-core/src/main/java/androidx/ui/testutils/PointerInputTestUtil.kt
+++ b/ui/ui-core/src/main/java/androidx/ui/testutils/PointerInputTestUtil.kt
@@ -28,7 +28,6 @@
import androidx.ui.unit.PxPosition
import androidx.ui.unit.Uptime
import androidx.ui.unit.ipx
-import androidx.ui.unit.px
// TODO(shepshapard): Document.
@@ -40,7 +39,7 @@
): PointerInputChange =
PointerInputChange(
PointerId(id),
- PointerInputData(Uptime.Boot + duration, PxPosition(x.px, y.px), true),
+ PointerInputData(Uptime.Boot + duration, PxPosition(x, y), true),
PointerInputData(null, null, false),
ConsumedData(PxPosition.Origin, false)
)
@@ -48,7 +47,7 @@
fun PointerInputChange.moveTo(duration: Duration, x: Float = 0f, y: Float = 0f) =
copy(
previous = current,
- current = PointerInputData(Uptime.Boot + duration, PxPosition(x.px, y.px), true),
+ current = PointerInputData(Uptime.Boot + duration, PxPosition(x, y), true),
consumed = ConsumedData()
)
@@ -57,7 +56,7 @@
previous = current,
current = PointerInputData(
current.uptime!! + duration,
- PxPosition(current.position!!.x + dx.px, current.position.y + dy.px),
+ PxPosition(current.position!!.x + dx, current.position.y + dy),
true
),
consumed = ConsumedData()
@@ -74,8 +73,8 @@
copy(
consumed = consumed.copy(
positionChange = PxPosition(
- consumed.positionChange.x + dx.px,
- consumed.positionChange.y + dy.px
+ consumed.positionChange.x + dx,
+ consumed.positionChange.y + dy
), downChange = consumed.downChange || downChange
)
)
diff --git a/ui/ui-core/src/test/java/androidx/ui/core/LayoutNodeTest.kt b/ui/ui-core/src/test/java/androidx/ui/core/LayoutNodeTest.kt
index 1874f09..977a5c9 100644
--- a/ui/ui-core/src/test/java/androidx/ui/core/LayoutNodeTest.kt
+++ b/ui/ui-core/src/test/java/androidx/ui/core/LayoutNodeTest.kt
@@ -22,8 +22,6 @@
import androidx.ui.unit.IntPxPosition
import androidx.ui.unit.PxPosition
import androidx.ui.unit.ipx
-import androidx.ui.unit.px
-import androidx.ui.unit.toPx
import com.google.common.truth.Truth.assertThat
import com.nhaarman.mockitokotlin2.anyOrNull
import com.nhaarman.mockitokotlin2.doReturn
@@ -345,10 +343,10 @@
node0.place(x0, y0)
node1.place(x1, y1)
- val globalPosition = PxPosition(250.px, 300.px)
+ val globalPosition = PxPosition(250f, 300f)
- val expectedX = globalPosition.x - x0.toPx() - x1.toPx()
- val expectedY = globalPosition.y - y0.toPx() - y1.toPx()
+ val expectedX = globalPosition.x - x0.value.toFloat() - x1.value.toFloat()
+ val expectedY = globalPosition.y - y0.value.toFloat() - y1.value.toFloat()
val expectedPosition = PxPosition(expectedX, expectedY)
val result = node1.coordinates.globalToLocal(globalPosition)
@@ -370,10 +368,10 @@
node0.place(x0, y0)
node1.place(x1, y1)
- val globalPosition = PxPosition(250.ipx, 300.ipx)
+ val globalPosition = PxPosition(250f, 300f)
- val expectedX = globalPosition.x - x0 - x1
- val expectedY = globalPosition.y - y0 - y1
+ val expectedX = globalPosition.x - x0.value.toFloat() - x1.value.toFloat()
+ val expectedY = globalPosition.y - y0.value.toFloat() - y1.value.toFloat()
val expectedPosition = PxPosition(expectedX, expectedY)
val result = node1.coordinates.globalToLocal(globalPosition)
@@ -395,10 +393,10 @@
node0.place(x0, y0)
node1.place(x1, y1)
- val localPosition = PxPosition(5.px, 15.px)
+ val localPosition = PxPosition(5f, 15f)
- val expectedX = localPosition.x + x0.toPx() + x1.toPx()
- val expectedY = localPosition.y + y0.toPx() + y1.toPx()
+ val expectedX = localPosition.x + x0.value.toFloat() + x1.value.toFloat()
+ val expectedY = localPosition.y + y0.value.toFloat() + y1.value.toFloat()
val expectedPosition = PxPosition(expectedX, expectedY)
val result = node1.coordinates.localToGlobal(localPosition)
@@ -422,8 +420,8 @@
val localPosition = PxPosition(5.ipx, 15.ipx)
- val expectedX = localPosition.x + x0 + x1
- val expectedY = localPosition.y + y0 + y1
+ val expectedX = localPosition.x + x0.value.toFloat() + x1.value.toFloat()
+ val expectedY = localPosition.y + y0.value.toFloat() + y1.value.toFloat()
val expectedPosition = PxPosition(expectedX, expectedY)
val result = node1.coordinates.localToGlobal(localPosition)
@@ -439,7 +437,7 @@
val result = node.coordinates.localToGlobal(PxPosition.Origin)
- assertEquals(PxPosition(120.px, 30.px), result)
+ assertEquals(PxPosition(120f, 30f), result)
}
@Test
@@ -465,10 +463,10 @@
node0.place(100.ipx, 10.ipx)
node1.place(x1, y1)
- val localPosition = PxPosition(5.px, 15.px)
+ val localPosition = PxPosition(5f, 15f)
- val expectedX = localPosition.x + x1.toPx()
- val expectedY = localPosition.y + y1.toPx()
+ val expectedX = localPosition.x + x1.value.toFloat()
+ val expectedY = localPosition.y + y1.value.toFloat()
val expectedPosition = PxPosition(expectedX, expectedY)
val result = node0.coordinates.childToLocal(node1.coordinates, localPosition)
@@ -487,7 +485,7 @@
thrown.expect(IllegalStateException::class.java)
- node2.coordinates.childToLocal(node1.coordinates, PxPosition(5.px, 15.px))
+ node2.coordinates.childToLocal(node1.coordinates, PxPosition(5f, 15f))
}
@Test
@@ -500,14 +498,14 @@
thrown.expect(IllegalStateException::class.java)
- node1.coordinates.childToLocal(node0.coordinates, PxPosition(5.px, 15.px))
+ node1.coordinates.childToLocal(node0.coordinates, PxPosition(5f, 15f))
}
@Test
fun testChildToLocalTheSameNode() {
val node = LayoutNode()
node.attach(mockOwner())
- val position = PxPosition(5.px, 15.px)
+ val position = PxPosition(5f, 15f)
val result = node.coordinates.childToLocal(node.coordinates, position)
@@ -552,7 +550,7 @@
val actual = parent.coordinates.childToLocal(child.coordinates, PxPosition.Origin)
- assertEquals(PxPosition(50.px, 80.px), actual)
+ assertEquals(PxPosition(50f, 80f), actual)
}
@Test
@@ -569,7 +567,7 @@
val actual = grandParent.coordinates.childToLocal(child.coordinates, PxPosition.Origin)
- assertEquals(PxPosition(20.px, -2.px), actual)
+ assertEquals(PxPosition(20f, -2f), actual)
}
// LayoutNode shouldn't allow adding beyond the count
@@ -791,9 +789,9 @@
}
val offset = when (numberOfChildrenHit) {
- 3 -> PxPosition(250.px, 250.px)
- 2 -> PxPosition(150.px, 150.px)
- 1 -> PxPosition(50.px, 50.px)
+ 3 -> PxPosition(250f, 250f)
+ 2 -> PxPosition(150f, 150f)
+ 1 -> PxPosition(50f, 50f)
else -> throw IllegalStateException()
}
@@ -879,8 +877,8 @@
attach(mockOwner())
}
- val offset1 = PxPosition(25.px, 25.px)
- val offset2 = PxPosition(75.px, 75.px)
+ val offset1 = PxPosition(25f, 25f)
+ val offset2 = PxPosition(75f, 75f)
val hit1 = mutableListOf<PointerInputFilter>()
val hit2 = mutableListOf<PointerInputFilter>()
@@ -956,9 +954,9 @@
attach(mockOwner())
}
- val offset1 = PxPosition(25.px, 25.px)
- val offset2 = PxPosition(75.px, 75.px)
- val offset3 = PxPosition(125.px, 125.px)
+ val offset1 = PxPosition(25f, 25f)
+ val offset2 = PxPosition(75f, 75f)
+ val offset3 = PxPosition(125f, 125f)
val hit1 = mutableListOf<PointerInputFilter>()
val hit2 = mutableListOf<PointerInputFilter>()
@@ -1018,9 +1016,9 @@
attach(mockOwner())
}
- val offset1 = PxPosition(50.px, 25.px)
- val offset2 = PxPosition(50.px, 75.px)
- val offset3 = PxPosition(50.px, 125.px)
+ val offset1 = PxPosition(50f, 25f)
+ val offset2 = PxPosition(50f, 75f)
+ val offset3 = PxPosition(50f, 125f)
val hit1 = mutableListOf<PointerInputFilter>()
val hit2 = mutableListOf<PointerInputFilter>()
@@ -1080,9 +1078,9 @@
attach(mockOwner())
}
- val offset1 = PxPosition(25.px, 50.px)
- val offset2 = PxPosition(75.px, 50.px)
- val offset3 = PxPosition(125.px, 50.px)
+ val offset1 = PxPosition(25f, 50f)
+ val offset2 = PxPosition(75f, 50f)
+ val offset3 = PxPosition(125f, 50f)
val hit1 = mutableListOf<PointerInputFilter>()
val hit2 = mutableListOf<PointerInputFilter>()
@@ -1166,21 +1164,21 @@
attach(mockOwner())
}
- val offsetThatHits1 = PxPosition(1.px, 1.px)
- val offsetThatHits2 = PxPosition(3.px, 1.px)
- val offsetThatHits3 = PxPosition(1.px, 3.px)
- val offsetThatHits4 = PxPosition(3.px, 3.px)
+ val offsetThatHits1 = PxPosition(1f, 1f)
+ val offsetThatHits2 = PxPosition(3f, 1f)
+ val offsetThatHits3 = PxPosition(1f, 3f)
+ val offsetThatHits4 = PxPosition(3f, 3f)
val offsetsThatMiss =
listOf(
- PxPosition(1.px, 0.px),
- PxPosition(3.px, 0.px),
- PxPosition(0.px, 1.px),
- PxPosition(4.px, 1.px),
- PxPosition(0.px, 3.px),
- PxPosition(4.px, 3.px),
- PxPosition(1.px, 4.px),
- PxPosition(3.px, 4.px)
+ PxPosition(1f, 0f),
+ PxPosition(3f, 0f),
+ PxPosition(0f, 1f),
+ PxPosition(4f, 1f),
+ PxPosition(0f, 3f),
+ PxPosition(4f, 3f),
+ PxPosition(1f, 4f),
+ PxPosition(3f, 4f)
)
val hit1 = mutableListOf<PointerInputFilter>()
@@ -1246,14 +1244,14 @@
attach(mockOwner(IntPxPosition(1.ipx, 1.ipx)))
}
- val offsetThatHits1 = PxPosition(2.px, 2.px)
- val offsetThatHits2 = PxPosition(2.px, 1.px)
- val offsetThatHits3 = PxPosition(1.px, 2.px)
+ val offsetThatHits1 = PxPosition(2f, 2f)
+ val offsetThatHits2 = PxPosition(2f, 1f)
+ val offsetThatHits3 = PxPosition(1f, 2f)
val offsetsThatMiss =
listOf(
- PxPosition(0.px, 0.px),
- PxPosition(0.px, 1.px),
- PxPosition(1.px, 0.px)
+ PxPosition(0f, 0f),
+ PxPosition(0f, 1f),
+ PxPosition(1f, 0f)
)
val hit1 = mutableListOf<PointerInputFilter>()
@@ -1305,7 +1303,7 @@
attach(mockOwner())
}
- val offset1 = PxPosition(50.px, 75.px)
+ val offset1 = PxPosition(50f, 75f)
val hit = mutableListOf<PointerInputFilter>()
@@ -1349,7 +1347,7 @@
}.apply {
attach(mockOwner())
}
- val offset1 = PxPosition(499.px, 499.px)
+ val offset1 = PxPosition(499f, 499f)
val hit = mutableListOf<PointerInputFilter>()
@@ -1404,7 +1402,7 @@
attach(mockOwner())
}
- val offset1 = PxPosition(499.px, 499.px)
+ val offset1 = PxPosition(499f, 499f)
val hit = mutableListOf<PointerInputFilter>()
@@ -1449,7 +1447,7 @@
attach(mockOwner())
}
- val offset = PxPosition(50.px, 50.px)
+ val offset = PxPosition(50f, 50f)
val hit = mutableListOf<PointerInputFilter>()
@@ -1521,7 +1519,7 @@
// Act.
- parent.hitTest(PxPosition(1.px, 1.px), hit)
+ parent.hitTest(PxPosition(1f, 1f), hit)
// Assert.
diff --git a/ui/ui-core/src/test/java/androidx/ui/core/PointerInputTest.kt b/ui/ui-core/src/test/java/androidx/ui/core/PointerInputTest.kt
index 1ae62d6..e82abb5 100644
--- a/ui/ui-core/src/test/java/androidx/ui/core/PointerInputTest.kt
+++ b/ui/ui-core/src/test/java/androidx/ui/core/PointerInputTest.kt
@@ -20,7 +20,6 @@
import androidx.ui.unit.PxPosition
import androidx.ui.unit.Uptime
import androidx.ui.unit.milliseconds
-import androidx.ui.unit.px
import org.hamcrest.CoreMatchers.`is`
import org.hamcrest.core.IsEqual.equalTo
import org.junit.Assert.assertThat
@@ -196,7 +195,7 @@
createPointerInputChange(8f, 16f, true, 2f, 4f, true, 0f, 0f, false)
assertThat(
pointerInputChange.positionChange(),
- `is`(equalTo(PxPosition(6.px, 12.px)))
+ `is`(equalTo(PxPosition(6f, 12f)))
)
}
@@ -206,7 +205,7 @@
createPointerInputChange(8f, 16f, true, 2f, 4f, true, 5f, 9f, false)
assertThat(
pointerInputChange.positionChange(),
- `is`(equalTo(PxPosition(1.px, 3.px)))
+ `is`(equalTo(PxPosition(1f, 3f)))
)
}
@@ -236,7 +235,7 @@
createPointerInputChange(8f, 16f, true, 2f, 4f, true, 0f, 0f, false)
assertThat(
pointerInputChange.positionChangeIgnoreConsumed(),
- `is`(equalTo(PxPosition(6.px, 12.px)))
+ `is`(equalTo(PxPosition(6f, 12f)))
)
}
@@ -246,7 +245,7 @@
createPointerInputChange(8f, 16f, true, 2f, 4f, true, 5f, 9f, false)
assertThat(
pointerInputChange.positionChangeIgnoreConsumed(),
- `is`(equalTo(PxPosition(6.px, 12.px)))
+ `is`(equalTo(PxPosition(6f, 12f)))
)
}
@@ -256,7 +255,7 @@
createPointerInputChange(8f, 16f, true, 2f, 4f, true, 6f, 12f, false)
assertThat(
pointerInputChange.positionChangeIgnoreConsumed(),
- `is`(equalTo(PxPosition(6.px, 12.px)))
+ `is`(equalTo(PxPosition(6f, 12f)))
)
}
@@ -419,7 +418,7 @@
val pointerInputChange1 =
createPointerInputChange(8f, 16f, true, 2f, 4f, true, 0f, 0f, false)
- val pointerInputChangeResult1 = pointerInputChange1.consumePositionChange(0.px, 0.px)
+ val pointerInputChangeResult1 = pointerInputChange1.consumePositionChange(0f, 0f)
assertThat(pointerInputChangeResult1, `is`(equalTo(pointerInputChange1)))
}
@@ -429,9 +428,9 @@
val pointerInputChange1 =
createPointerInputChange(8f, 16f, true, 2f, 4f, true, 0f, 0f, false)
- val pointerInputChangeResult1 = pointerInputChange1.consumePositionChange(5.px, 0.px)
- val pointerInputChangeResult2 = pointerInputChange1.consumePositionChange(0.px, 3.px)
- val pointerInputChangeResult3 = pointerInputChange1.consumePositionChange(5.px, 3.px)
+ val pointerInputChangeResult1 = pointerInputChange1.consumePositionChange(5f, 0f)
+ val pointerInputChangeResult2 = pointerInputChange1.consumePositionChange(0f, 3f)
+ val pointerInputChangeResult3 = pointerInputChange1.consumePositionChange(5f, 3f)
assertThat(
pointerInputChangeResult1,
@@ -452,9 +451,9 @@
val pointerInputChange1 =
createPointerInputChange(8f, 16f, true, 2f, 4f, true, 0f, 0f, false)
- val pointerInputChangeResult1 = pointerInputChange1.consumePositionChange(6.px, 0.px)
- val pointerInputChangeResult2 = pointerInputChange1.consumePositionChange(0.px, 12.px)
- val pointerInputChangeResult3 = pointerInputChange1.consumePositionChange(6.px, 12.px)
+ val pointerInputChangeResult1 = pointerInputChange1.consumePositionChange(6f, 0f)
+ val pointerInputChangeResult2 = pointerInputChange1.consumePositionChange(0f, 12f)
+ val pointerInputChangeResult3 = pointerInputChange1.consumePositionChange(6f, 12f)
assertThat(
pointerInputChangeResult1,
@@ -475,9 +474,9 @@
val pointerInputChange1 =
createPointerInputChange(8f, 16f, true, 2f, 4f, true, 1f, 5f, false)
- val pointerInputChangeResult1 = pointerInputChange1.consumePositionChange(2.px, 0.px)
- val pointerInputChangeResult2 = pointerInputChange1.consumePositionChange(0.px, 3.px)
- val pointerInputChangeResult3 = pointerInputChange1.consumePositionChange(2.px, 3.px)
+ val pointerInputChangeResult1 = pointerInputChange1.consumePositionChange(2f, 0f)
+ val pointerInputChangeResult2 = pointerInputChange1.consumePositionChange(0f, 3f)
+ val pointerInputChangeResult3 = pointerInputChange1.consumePositionChange(2f, 3f)
assertThat(
pointerInputChangeResult1,
@@ -584,15 +583,15 @@
PointerId(0),
PointerInputData(
Uptime.Boot + 100.milliseconds,
- PxPosition(currentX.px, currentY.px),
+ PxPosition(currentX, currentY),
currentDown
),
PointerInputData(
Uptime.Boot + 0.milliseconds,
- PxPosition(previousX.px, previousY.px),
+ PxPosition(previousX, previousY),
previousDown
),
- ConsumedData(PxPosition(consumedX.px, consumedY.px), consumedDown)
+ ConsumedData(PxPosition(consumedX, consumedY), consumedDown)
)
}
}
\ No newline at end of file
diff --git a/ui/ui-core/src/test/java/androidx/ui/core/gesture/DoubleTapGestureFilterTest.kt b/ui/ui-core/src/test/java/androidx/ui/core/gesture/DoubleTapGestureFilterTest.kt
index 99bc41f..f7c77ed 100644
--- a/ui/ui-core/src/test/java/androidx/ui/core/gesture/DoubleTapGestureFilterTest.kt
+++ b/ui/ui-core/src/test/java/androidx/ui/core/gesture/DoubleTapGestureFilterTest.kt
@@ -30,7 +30,6 @@
import androidx.ui.unit.PxPosition
import androidx.ui.unit.ipx
import androidx.ui.unit.milliseconds
-import androidx.ui.unit.px
import com.google.common.truth.Truth.assertThat
import com.nhaarman.mockitokotlin2.any
import com.nhaarman.mockitokotlin2.mock
@@ -543,7 +542,7 @@
filter::onPointerInput.invokeOverAllPasses(move2)
filter::onPointerInput.invokeOverAllPasses(up2)
- verify(onDoubleTap).invoke(PxPosition(3.px, 5.px))
+ verify(onDoubleTap).invoke(PxPosition(3f, 5f))
}
@Test
@@ -566,7 +565,7 @@
filter::onPointerInput.invokeOverAllPasses(up2A, move2B2)
filter::onPointerInput.invokeOverAllPasses(up2B)
- verify(onDoubleTap).invoke(PxPosition((7).px, (11).px))
+ verify(onDoubleTap).invoke(PxPosition(7f, 11f))
}
// Tests that verify correct consumption behavior
diff --git a/ui/ui-core/src/test/java/androidx/ui/core/gesture/DragSlopExceededGestureFilterTest.kt b/ui/ui-core/src/test/java/androidx/ui/core/gesture/DragSlopExceededGestureFilterTest.kt
index ae0a325..cd4a7fc 100644
--- a/ui/ui-core/src/test/java/androidx/ui/core/gesture/DragSlopExceededGestureFilterTest.kt
+++ b/ui/ui-core/src/test/java/androidx/ui/core/gesture/DragSlopExceededGestureFilterTest.kt
@@ -28,7 +28,6 @@
import androidx.ui.testutils.up
import androidx.ui.unit.Duration
import androidx.ui.unit.milliseconds
-import androidx.ui.unit.px
import com.google.common.truth.Truth.assertThat
import org.junit.Before
import org.junit.Test
@@ -786,8 +785,8 @@
// Assert
assertThat(result.consumed.downChange).isFalse()
- assertThat(result.consumed.positionChange.x).isEqualTo(0.px)
- assertThat(result.consumed.positionChange.y).isEqualTo(0.px)
+ assertThat(result.consumed.positionChange.x).isEqualTo(0f)
+ assertThat(result.consumed.positionChange.y).isEqualTo(0f)
}
@Test
@@ -802,8 +801,8 @@
// Assert
assertThat(result.consumed.downChange).isFalse()
- assertThat(result.consumed.positionChange.x).isEqualTo(0.px)
- assertThat(result.consumed.positionChange.y).isEqualTo(0.px)
+ assertThat(result.consumed.positionChange.x).isEqualTo(0f)
+ assertThat(result.consumed.positionChange.y).isEqualTo(0f)
}
@Test
@@ -821,8 +820,8 @@
// Assert
assertThat(result.consumed.downChange).isFalse()
- assertThat(result.consumed.positionChange.x).isEqualTo(0.px)
- assertThat(result.consumed.positionChange.y).isEqualTo(0.px)
+ assertThat(result.consumed.positionChange.x).isEqualTo(0f)
+ assertThat(result.consumed.positionChange.y).isEqualTo(0f)
}
@Test
@@ -838,8 +837,8 @@
// Assert
assertThat(result.consumed.downChange).isFalse()
- assertThat(result.consumed.positionChange.x).isEqualTo(0.px)
- assertThat(result.consumed.positionChange.y).isEqualTo(0.px)
+ assertThat(result.consumed.positionChange.x).isEqualTo(0f)
+ assertThat(result.consumed.positionChange.y).isEqualTo(0f)
}
@Test
@@ -858,8 +857,8 @@
// Assert
assertThat(result.consumed.downChange).isFalse()
- assertThat(result.consumed.positionChange.x).isEqualTo(0.px)
- assertThat(result.consumed.positionChange.y).isEqualTo(0.px)
+ assertThat(result.consumed.positionChange.x).isEqualTo(0f)
+ assertThat(result.consumed.positionChange.y).isEqualTo(0f)
}
// Verification that TouchSlopExceededGestureDetector resets after up correctly.
diff --git a/ui/ui-core/src/test/java/androidx/ui/core/gesture/LongPressGestureFilterTest.kt b/ui/ui-core/src/test/java/androidx/ui/core/gesture/LongPressGestureFilterTest.kt
index 909cea1..d4b6d4a 100644
--- a/ui/ui-core/src/test/java/androidx/ui/core/gesture/LongPressGestureFilterTest.kt
+++ b/ui/ui-core/src/test/java/androidx/ui/core/gesture/LongPressGestureFilterTest.kt
@@ -30,7 +30,6 @@
import androidx.ui.unit.PxPosition
import androidx.ui.unit.ipx
import androidx.ui.unit.milliseconds
-import androidx.ui.unit.px
import com.google.common.truth.Truth.assertThat
import com.nhaarman.mockitokotlin2.any
import com.nhaarman.mockitokotlin2.mock
@@ -277,7 +276,7 @@
filter::onPointerInput.invokeOverAllPasses(down)
testContext.advanceTimeBy(100, TimeUnit.MILLISECONDS)
- verify(onLongPress).invoke(PxPosition(13.px, 17.px))
+ verify(onLongPress).invoke(PxPosition(13f, 17f))
}
@Test
@@ -290,7 +289,7 @@
filter::onPointerInput.invokeOverAllPasses(move)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
- verify(onLongPress).invoke(PxPosition((7).px, 5.px))
+ verify(onLongPress).invoke(PxPosition(7f, 5f))
}
@Test
@@ -305,7 +304,7 @@
filter::onPointerInput.invokeOverAllPasses(move0, down1)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
- verify(onLongPress).invoke(PxPosition(13.px, 17.px))
+ verify(onLongPress).invoke(PxPosition(13f, 17f))
}
@Test
@@ -325,7 +324,7 @@
filter::onPointerInput.invokeOverAllPasses(up0, move1)
testContext.advanceTimeBy(25, TimeUnit.MILLISECONDS)
- verify(onLongPress).invoke(PxPosition(11.px, 19.px))
+ verify(onLongPress).invoke(PxPosition(11f, 19f))
}
@Test
@@ -340,7 +339,7 @@
filter::onPointerInput.invokeOverAllPasses(move0, down1)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
- verify(onLongPress).invoke(PxPosition(27.px, 29.px))
+ verify(onLongPress).invoke(PxPosition(27f, 29f))
}
@Test
@@ -360,7 +359,7 @@
filter::onPointerInput.invokeOverAllPasses(up0, move1)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
- verify(onLongPress).invoke(PxPosition(27.px, 23.px))
+ verify(onLongPress).invoke(PxPosition(27f, 23f))
}
// Tests that verify that consumption behavior
diff --git a/ui/ui-core/src/test/java/androidx/ui/core/gesture/PressIndicatorGestureFilterTest.kt b/ui/ui-core/src/test/java/androidx/ui/core/gesture/PressIndicatorGestureFilterTest.kt
index f5ac282..42153bb 100644
--- a/ui/ui-core/src/test/java/androidx/ui/core/gesture/PressIndicatorGestureFilterTest.kt
+++ b/ui/ui-core/src/test/java/androidx/ui/core/gesture/PressIndicatorGestureFilterTest.kt
@@ -29,7 +29,6 @@
import androidx.ui.unit.PxPosition
import androidx.ui.unit.ipx
import androidx.ui.unit.milliseconds
-import androidx.ui.unit.px
import com.nhaarman.mockitokotlin2.any
import com.nhaarman.mockitokotlin2.inOrder
import com.nhaarman.mockitokotlin2.mock
@@ -449,7 +448,7 @@
fun onPointerInput_down_downPositionIsCorrect() {
filter::onPointerInput
.invokeOverAllPasses(down(0, 0.milliseconds, x = 13f, y = 17f))
- verify(filter.onStart!!).invoke(PxPosition(13.px, 17f.px))
+ verify(filter.onStart!!).invoke(PxPosition(13f, 17f))
}
// Verification of correct consumption behavior.
diff --git a/ui/ui-core/src/test/java/androidx/ui/core/gesture/RawDragGestureFilterTest.kt b/ui/ui-core/src/test/java/androidx/ui/core/gesture/RawDragGestureFilterTest.kt
index 92c4c4e..7ef81c0 100644
--- a/ui/ui-core/src/test/java/androidx/ui/core/gesture/RawDragGestureFilterTest.kt
+++ b/ui/ui-core/src/test/java/androidx/ui/core/gesture/RawDragGestureFilterTest.kt
@@ -31,7 +31,6 @@
import androidx.ui.unit.PxPosition
import androidx.ui.unit.ipx
import androidx.ui.unit.milliseconds
-import androidx.ui.unit.px
import com.google.common.truth.Truth.assertThat
import org.junit.Before
import org.junit.Test
@@ -220,8 +219,8 @@
assertThat(onDragLog).hasSize(2)
// OnDrags get's called twice each time because RawDragGestureDetector calls it on both
// PostUp and PostDown and the distance is not consumed by PostUp.
- assertThat(onDragLog[0].pxPosition).isEqualTo(PxPosition(5.px, (-2).px))
- assertThat(onDragLog[1].pxPosition).isEqualTo(PxPosition(5.px, (-2).px))
+ assertThat(onDragLog[0].pxPosition).isEqualTo(PxPosition(5f, -2f))
+ assertThat(onDragLog[1].pxPosition).isEqualTo(PxPosition(5f, -2f))
}
@Test
@@ -240,10 +239,10 @@
change = change.moveBy(100.milliseconds, -3f, 7f)
filter::onPointerInput.invokeOverAllPasses(change)
change = change.moveBy(100.milliseconds, 11f, 13f)
- .consumePositionChange(5.px, 3.px)
+ .consumePositionChange(5f, 3f)
filter::onPointerInput.invokeOverAllPasses(change)
change = change.moveBy(100.milliseconds, -13f, -11f)
- .consumePositionChange((-3).px, (-5).px)
+ .consumePositionChange(-3f, -5f)
filter::onPointerInput.invokeOverAllPasses(change)
// Assert
@@ -252,14 +251,14 @@
assertThat(onDragLog).hasSize(8)
// OnDrags get's called twice each time because RawDragGestureDetector calls it on both
// PostUp and PostDown and the distance is not consumed by PostUp.
- assertThat(onDragLog[0].pxPosition).isEqualTo(PxPosition(3.px, (-5).px))
- assertThat(onDragLog[1].pxPosition).isEqualTo(PxPosition(3.px, (-5).px))
- assertThat(onDragLog[2].pxPosition).isEqualTo(PxPosition((-3).px, 7.px))
- assertThat(onDragLog[3].pxPosition).isEqualTo(PxPosition((-3).px, 7.px))
- assertThat(onDragLog[4].pxPosition).isEqualTo(PxPosition(6.px, 10.px))
- assertThat(onDragLog[5].pxPosition).isEqualTo(PxPosition(6.px, 10.px))
- assertThat(onDragLog[6].pxPosition).isEqualTo(PxPosition((-10).px, (-6).px))
- assertThat(onDragLog[7].pxPosition).isEqualTo(PxPosition((-10).px, (-6).px))
+ assertThat(onDragLog[0].pxPosition).isEqualTo(PxPosition(3f, -5f))
+ assertThat(onDragLog[1].pxPosition).isEqualTo(PxPosition(3f, -5f))
+ assertThat(onDragLog[2].pxPosition).isEqualTo(PxPosition(-3f, 7f))
+ assertThat(onDragLog[3].pxPosition).isEqualTo(PxPosition(-3f, 7f))
+ assertThat(onDragLog[4].pxPosition).isEqualTo(PxPosition(6f, 10f))
+ assertThat(onDragLog[5].pxPosition).isEqualTo(PxPosition(6f, 10f))
+ assertThat(onDragLog[6].pxPosition).isEqualTo(PxPosition(-10f, -6f))
+ assertThat(onDragLog[7].pxPosition).isEqualTo(PxPosition(-10f, -6f))
}
@Test
@@ -288,16 +287,10 @@
// 2 onDrags because RawDragGestureDetector calls onDrag on both PostUp and PostDown and the
// distance is never consumed.
assertThat(onDragLog[0].pxPosition).isEqualTo(
- PxPosition(
- 3.px,
- (-4).px
- )
+ PxPosition(3f, -4f)
)
assertThat(onDragLog[1].pxPosition).isEqualTo(
- PxPosition(
- 3.px,
- (-4).px
- )
+ PxPosition(3f, -4f)
)
}
@@ -398,8 +391,8 @@
val loggedStops = log.filter { it.methodName == "onStop" }
assertThat(loggedStops).hasSize(1)
val velocity = loggedStops[0].pxPosition!!
- assertThat(velocity.x.value).isWithin(.01f).of(expectedPxPerSecondDx)
- assertThat(velocity.y.value).isWithin(.01f).of(expectedPxPerSecondDy)
+ assertThat(velocity.x).isWithin(.01f).of(expectedPxPerSecondDx)
+ assertThat(velocity.y).isWithin(.01f).of(expectedPxPerSecondDy)
}
// Verification that callbacks occur in the correct order
@@ -527,8 +520,8 @@
PointerEventPass.PostDown
)
- assertThat(result.consumed.positionChange.x.value).isEqualTo(7f)
- assertThat(result.consumed.positionChange.y.value).isEqualTo(-11f)
+ assertThat(result.consumed.positionChange.x).isEqualTo(7f)
+ assertThat(result.consumed.positionChange.y).isEqualTo(-11f)
}
@Test
@@ -559,7 +552,7 @@
filter::onPointerInput.invokeOverAllPasses(move)
assertThat(log.first { it.methodName == "onStart" }.pxPosition)
- .isEqualTo(PxPosition(3.px, 4.px))
+ .isEqualTo(PxPosition(3f, 4f))
}
@Test
@@ -580,7 +573,7 @@
assertThat(log.first { it.methodName == "onStart" }.pxPosition)
// average position
- .isEqualTo(PxPosition(3.px, 4.px))
+ .isEqualTo(PxPosition(3f, 4f))
}
// Tests that verify when onCancel should not be called.
@@ -637,7 +630,7 @@
filter::onPointerInput.invokeOverAllPasses(move)
assertThat(log.first { it.methodName == "onStart" }.pxPosition)
- .isEqualTo(PxPosition(7.px, 11.px))
+ .isEqualTo(PxPosition(7f, 11f))
}
@Test
@@ -680,8 +673,8 @@
val loggedStops = log.filter { it.methodName == "onStop" }
assertThat(loggedStops).hasSize(1)
val velocity = loggedStops[0].pxPosition!!
- assertThat(velocity.x.value).isWithin(.01f).of(100f)
- assertThat(velocity.y.value).isWithin(.01f).of(100f)
+ assertThat(velocity.x).isWithin(.01f).of(100f)
+ assertThat(velocity.y).isWithin(.01f).of(100f)
}
data class LogItem(
diff --git a/ui/ui-core/src/test/java/androidx/ui/core/gesture/RawPressStartGestureFilterTest.kt b/ui/ui-core/src/test/java/androidx/ui/core/gesture/RawPressStartGestureFilterTest.kt
index bf25a8a..40cec62 100644
--- a/ui/ui-core/src/test/java/androidx/ui/core/gesture/RawPressStartGestureFilterTest.kt
+++ b/ui/ui-core/src/test/java/androidx/ui/core/gesture/RawPressStartGestureFilterTest.kt
@@ -28,7 +28,6 @@
import androidx.ui.unit.PxPosition
import androidx.ui.unit.ipx
import androidx.ui.unit.milliseconds
-import androidx.ui.unit.px
import com.nhaarman.mockitokotlin2.any
import com.nhaarman.mockitokotlin2.mock
import com.nhaarman.mockitokotlin2.never
@@ -144,7 +143,7 @@
@Test
fun onPointerInput_down_downPositionIsCorrect() {
filter::onPointerInput.invokeOverAllPasses(down(0, x = 13f, y = 17f))
- verify(filter.onPressStart).invoke(PxPosition(13.px, 17f.px))
+ verify(filter.onPressStart).invoke(PxPosition(13f, 17f))
}
// Verification of correct consumption behavior.
diff --git a/ui/ui-core/src/test/java/androidx/ui/core/gesture/RawScaleGestureFilterTest.kt b/ui/ui-core/src/test/java/androidx/ui/core/gesture/RawScaleGestureFilterTest.kt
index 5da5cfd..86cfa61 100644
--- a/ui/ui-core/src/test/java/androidx/ui/core/gesture/RawScaleGestureFilterTest.kt
+++ b/ui/ui-core/src/test/java/androidx/ui/core/gesture/RawScaleGestureFilterTest.kt
@@ -28,7 +28,6 @@
import androidx.ui.testutils.up
import androidx.ui.unit.PxPosition
import androidx.ui.unit.milliseconds
-import androidx.ui.unit.px
import com.google.common.truth.Truth.assertThat
import org.junit.Before
import org.junit.Test
@@ -665,9 +664,9 @@
// Assert
assertThat(result.first { it.id == PointerId(0) }.consumed.positionChange)
- .isEqualTo(PxPosition(-1.px, 0.px))
+ .isEqualTo(PxPosition(-1f, 0f))
assertThat(result.first { it.id == PointerId(1) }.consumed.positionChange)
- .isEqualTo(PxPosition(1.px, 0.px))
+ .isEqualTo(PxPosition(1f, 0f))
}
@Test
@@ -699,9 +698,9 @@
// Assert
assertThat(result.first { it.id == PointerId(0) }.consumed.positionChange)
- .isEqualTo(PxPosition(0.px, -1.px))
+ .isEqualTo(PxPosition(0f, -1f))
assertThat(result.first { it.id == PointerId(1) }.consumed.positionChange)
- .isEqualTo(PxPosition(0.px, 1.px))
+ .isEqualTo(PxPosition(0f, 1f))
}
@Test
@@ -717,9 +716,9 @@
val result = filter::onPointerInput.invokeOverAllPasses(change1, change2)
assertThat(result.first { it.id == PointerId(0) }.consumed.positionChange)
- .isEqualTo(PxPosition(-1.px, -1.px))
+ .isEqualTo(PxPosition(-1f, -1f))
assertThat(result.first { it.id == PointerId(1) }.consumed.positionChange)
- .isEqualTo(PxPosition(1.px, 1.px))
+ .isEqualTo(PxPosition(1f, 1f))
}
@Test
@@ -751,9 +750,9 @@
// Assert
assertThat(result.first { it.id == PointerId(0) }.consumed.positionChange)
- .isEqualTo(PxPosition(1.px, 0.px))
+ .isEqualTo(PxPosition(1f, 0f))
assertThat(result.first { it.id == PointerId(1) }.consumed.positionChange)
- .isEqualTo(PxPosition(-1.px, 0.px))
+ .isEqualTo(PxPosition(-1f, 0f))
}
@Test
@@ -785,9 +784,9 @@
// Assert
assertThat(result.first { it.id == PointerId(0) }.consumed.positionChange)
- .isEqualTo(PxPosition(0.px, 1.px))
+ .isEqualTo(PxPosition(0f, 1f))
assertThat(result.first { it.id == PointerId(1) }.consumed.positionChange)
- .isEqualTo(PxPosition(0.px, -1.px))
+ .isEqualTo(PxPosition(0f, -1f))
}
@Test
@@ -802,8 +801,8 @@
change2 = change2.moveTo(10.milliseconds, 6f, 6f)
val result = filter::onPointerInput.invokeOverAllPasses(change1, change2)
- assertThat(result[0].consumed.positionChange).isEqualTo(PxPosition(2.px, 2.px))
- assertThat(result[1].consumed.positionChange).isEqualTo(PxPosition(-2.px, -2.px))
+ assertThat(result[0].consumed.positionChange).isEqualTo(PxPosition(2f, 2f))
+ assertThat(result[1].consumed.positionChange).isEqualTo(PxPosition(-2f, -2f))
}
@Test
@@ -837,9 +836,9 @@
// Assert
assertThat(result.first { it.id == PointerId(0) }.consumed.positionChange)
- .isEqualTo(PxPosition(-1.px, 0.px))
+ .isEqualTo(PxPosition(-1f, 0f))
assertThat(result.first { it.id == PointerId(1) }.consumed.positionChange)
- .isEqualTo(PxPosition(1.px, 0.px))
+ .isEqualTo(PxPosition(1f, 0f))
}
@Test
@@ -871,9 +870,9 @@
// Assert
assertThat(result.first { it.id == PointerId(0) }.consumed.positionChange)
- .isEqualTo(PxPosition(0.px, -1.px))
+ .isEqualTo(PxPosition(0f, -1f))
assertThat(result.first { it.id == PointerId(1) }.consumed.positionChange)
- .isEqualTo(PxPosition(0.px, 1.px))
+ .isEqualTo(PxPosition(0f, 1f))
}
@Test
@@ -905,9 +904,9 @@
// Assert
assertThat(result.first { it.id == PointerId(0) }.consumed.positionChange)
- .isEqualTo(PxPosition(1.px, 0.px))
+ .isEqualTo(PxPosition(1f, 0f))
assertThat(result.first { it.id == PointerId(1) }.consumed.positionChange)
- .isEqualTo(PxPosition(-1.px, 0.px))
+ .isEqualTo(PxPosition(-1f, 0f))
}
@Test
@@ -939,9 +938,9 @@
// Assert
assertThat(result.first { it.id == PointerId(0) }.consumed.positionChange)
- .isEqualTo(PxPosition(0.px, 1.px))
+ .isEqualTo(PxPosition(0f, 1f))
assertThat(result.first { it.id == PointerId(1) }.consumed.positionChange)
- .isEqualTo(PxPosition(0.px, -1.px))
+ .isEqualTo(PxPosition(0f, -1f))
}
@Test
@@ -973,9 +972,9 @@
// Assert
assertThat(result.first { it.id == PointerId(0) }.consumed.positionChange)
- .isEqualTo(PxPosition(.5.px, -1.5.px))
+ .isEqualTo(PxPosition(.5f, -1.5f))
assertThat(result.first { it.id == PointerId(1) }.consumed.positionChange)
- .isEqualTo(PxPosition(-.5.px, 1.5.px))
+ .isEqualTo(PxPosition(-.5f, 1.5f))
}
@Test
@@ -1007,9 +1006,9 @@
// Assert
assertThat(result.first { it.id == PointerId(0) }.consumed.positionChange)
- .isEqualTo(PxPosition(2.px, -1.px))
+ .isEqualTo(PxPosition(2f, -1f))
assertThat(result.first { it.id == PointerId(1) }.consumed.positionChange)
- .isEqualTo(PxPosition(-2.px, 1.px))
+ .isEqualTo(PxPosition(-2f, 1f))
}
@Test
diff --git a/ui/ui-core/src/test/java/androidx/ui/core/gesture/TapGestureFilterTest.kt b/ui/ui-core/src/test/java/androidx/ui/core/gesture/TapGestureFilterTest.kt
index bef0477..7024b0e 100644
--- a/ui/ui-core/src/test/java/androidx/ui/core/gesture/TapGestureFilterTest.kt
+++ b/ui/ui-core/src/test/java/androidx/ui/core/gesture/TapGestureFilterTest.kt
@@ -31,7 +31,6 @@
import androidx.ui.unit.PxPosition
import androidx.ui.unit.ipx
import androidx.ui.unit.milliseconds
-import androidx.ui.unit.px
import com.nhaarman.mockitokotlin2.any
import com.nhaarman.mockitokotlin2.mock
import com.nhaarman.mockitokotlin2.never
@@ -194,7 +193,7 @@
filter::onPointerInput.invokeOverAllPasses(down)
filter::onPointerInput.invokeOverAllPasses(up)
- verify(filter.onTap).invoke(PxPosition(123.px, 456.px))
+ verify(filter.onTap).invoke(PxPosition(123f, 456f))
}
@Test
@@ -207,7 +206,7 @@
filter::onPointerInput.invokeOverAllPasses(move)
filter::onPointerInput.invokeOverAllPasses(up)
- verify(filter.onTap).invoke(PxPosition(321.px, 654.px))
+ verify(filter.onTap).invoke(PxPosition(321f, 654f))
}
@Test
@@ -227,7 +226,7 @@
filter::onPointerInput.invokeOverAllPasses(upA, moveB)
filter::onPointerInput.invokeOverAllPasses(upB)
- verify(filter.onTap).invoke(PxPosition(321.px, 654.px))
+ verify(filter.onTap).invoke(PxPosition(321f, 654f))
}
@Test
@@ -247,7 +246,7 @@
filter::onPointerInput.invokeOverAllPasses(moveA2, upB)
filter::onPointerInput.invokeOverAllPasses(upA)
- verify(filter.onTap).invoke(PxPosition(123.px, 456.px))
+ verify(filter.onTap).invoke(PxPosition(123f, 456f))
}
@Test
@@ -263,7 +262,7 @@
filter::onPointerInput.invokeOverAllPasses(up)
filter::onCustomEvent.invokeOverAllPasses(delayUpNotConsumed)
- verify(filter.onTap).invoke(PxPosition(123.px, 456.px))
+ verify(filter.onTap).invoke(PxPosition(123f, 456f))
}
@Test
@@ -286,7 +285,7 @@
filter::onPointerInput.invokeOverAllPasses(upA, moveB)
filter::onPointerInput.invokeOverAllPasses(upB)
- verify(filter.onTap).invoke(PxPosition(321.px, 654.px))
+ verify(filter.onTap).invoke(PxPosition(321f, 654f))
}
@Test
@@ -313,7 +312,7 @@
filter::onPointerInput.invokeOverAllPasses(upB)
filter::onCustomEvent.invokeOverAllPasses(delayUpNotConsumed)
- verify(filter.onTap).invoke(PxPosition(321.px, 654.px))
+ verify(filter.onTap).invoke(PxPosition(321f, 654f))
}
// Verification that the down changes should not be consumed.
diff --git a/ui/ui-core/src/test/java/androidx/ui/core/gesture/util/VelocityTrackerTest.kt b/ui/ui-core/src/test/java/androidx/ui/core/gesture/util/VelocityTrackerTest.kt
index b20ae74..2a2f421 100644
--- a/ui/ui-core/src/test/java/androidx/ui/core/gesture/util/VelocityTrackerTest.kt
+++ b/ui/ui-core/src/test/java/androidx/ui/core/gesture/util/VelocityTrackerTest.kt
@@ -17,12 +17,10 @@
package androidx.ui.core.gesture.util
import androidx.ui.core.PointerInputData
-import androidx.ui.unit.Px
import androidx.ui.unit.PxPosition
import androidx.ui.unit.Uptime
import androidx.ui.unit.Velocity
import androidx.ui.unit.milliseconds
-import androidx.ui.unit.px
import com.google.common.truth.Truth.assertThat
import org.junit.Test
import org.junit.runner.RunWith
@@ -112,8 +110,8 @@
}
private fun checkVelocity(actual: Velocity, expectedDx: Float, expectedDy: Float) {
- assertThat(actual.pixelsPerSecond.x.value).isWithin(0.1f).of(expectedDx)
- assertThat(actual.pixelsPerSecond.y.value).isWithin(0.1f).of(expectedDy)
+ assertThat(actual.pixelsPerSecond.x).isWithin(0.1f).of(expectedDx)
+ assertThat(actual.pixelsPerSecond.y).isWithin(0.1f).of(expectedDy)
}
}
@@ -121,1538 +119,1538 @@
* This extracts the inline PxPosition to a separate function so that velocityEventData
* creation doesn't make the function too long for dex.
*/
-private fun createPxPosition(width: Px, height: Px) = PxPosition(width, height)
+private fun createPxPosition(width: Float, height: Float) = PxPosition(width, height)
val velocityEventData: List<PointerInputData> = listOf(
PointerInputData(
uptime = Uptime.Boot + 216690896.milliseconds,
down = true,
- position = createPxPosition(270.px, 538.2857055664062.px)
+ position = createPxPosition(270f, 538.2857055664062f)
),
PointerInputData(
uptime = Uptime.Boot + 216690906.milliseconds,
down = true,
- position = createPxPosition(270.px, 538.2857055664062.px)
+ position = createPxPosition(270f, 538.2857055664062f)
),
PointerInputData(
uptime = Uptime.Boot + 216690951.milliseconds,
down = true,
- position = createPxPosition(270.px, 530.8571166992188.px)
+ position = createPxPosition(270f, 530.8571166992188f)
),
PointerInputData(
uptime = Uptime.Boot + 216690959.milliseconds,
down = true,
- position = createPxPosition(270.px, 526.8571166992188.px)
+ position = createPxPosition(270f, 526.8571166992188f)
),
PointerInputData(
uptime = Uptime.Boot + 216690967.milliseconds,
down = true,
- position = createPxPosition(270.px, 521.4285888671875.px)
+ position = createPxPosition(270f, 521.4285888671875f)
),
PointerInputData(
uptime = Uptime.Boot + 216690975.milliseconds,
down = true,
- position = createPxPosition(270.px, 515.4285888671875.px)
+ position = createPxPosition(270f, 515.4285888671875f)
),
PointerInputData(
uptime = Uptime.Boot + 216690983.milliseconds,
down = true,
- position = createPxPosition(270.px, 506.8571472167969.px)
+ position = createPxPosition(270f, 506.8571472167969f)
),
PointerInputData(
uptime = Uptime.Boot + 216690991.milliseconds,
down = true,
- position = createPxPosition(268.8571472167969.px, 496.px)
+ position = createPxPosition(268.8571472167969f, 496f)
),
PointerInputData(
uptime = Uptime.Boot + 216690998.milliseconds,
down = true,
- position = createPxPosition(267.4285583496094.px, 483.1428527832031.px)
+ position = createPxPosition(267.4285583496094f, 483.1428527832031f)
),
PointerInputData(
uptime = Uptime.Boot + 216691006.milliseconds,
down = true,
- position = createPxPosition(266.28570556640625.px, 469.71429443359375.px)
+ position = createPxPosition(266.28570556640625f, 469.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216691014.milliseconds,
down = true,
- position = createPxPosition(265.4285583496094.px, 456.8571472167969.px)
+ position = createPxPosition(265.4285583496094f, 456.8571472167969f)
),
PointerInputData(
uptime = Uptime.Boot + 216691021.milliseconds,
down = true,
- position = createPxPosition(264.28570556640625.px, 443.71429443359375.px)
+ position = createPxPosition(264.28570556640625f, 443.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216691029.milliseconds,
down = true,
- position = createPxPosition(264.px, 431.71429443359375.px)
+ position = createPxPosition(264f, 431.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216691036.milliseconds,
down = true,
- position = createPxPosition(263.4285583496094.px, 421.1428527832031.px)
+ position = createPxPosition(263.4285583496094f, 421.1428527832031f)
),
PointerInputData(
uptime = Uptime.Boot + 216691044.milliseconds,
down = true,
- position = createPxPosition(263.4285583496094.px, 412.5714416503906.px)
+ position = createPxPosition(263.4285583496094f, 412.5714416503906f)
),
PointerInputData(
uptime = Uptime.Boot + 216691052.milliseconds,
down = true,
- position = createPxPosition(263.4285583496094.px, 404.5714416503906.px)
+ position = createPxPosition(263.4285583496094f, 404.5714416503906f)
),
PointerInputData(
uptime = Uptime.Boot + 216691060.milliseconds,
down = true,
- position = createPxPosition(263.4285583496094.px, 396.5714416503906.px)
+ position = createPxPosition(263.4285583496094f, 396.5714416503906f)
),
PointerInputData(
uptime = Uptime.Boot + 216691068.milliseconds,
down = true,
- position = createPxPosition(264.5714416503906.px, 390.px)
+ position = createPxPosition(264.5714416503906f, 390f)
),
PointerInputData(
uptime = Uptime.Boot + 216691075.milliseconds,
down = true,
- position = createPxPosition(265.1428527832031.px, 384.8571472167969.px)
+ position = createPxPosition(265.1428527832031f, 384.8571472167969f)
),
PointerInputData(
uptime = Uptime.Boot + 216691083.milliseconds,
down = true,
- position = createPxPosition(266.px, 380.28570556640625.px)
+ position = createPxPosition(266f, 380.28570556640625f)
),
PointerInputData(
uptime = Uptime.Boot + 216691091.milliseconds,
down = true,
- position = createPxPosition(266.5714416503906.px, 376.28570556640625.px)
+ position = createPxPosition(266.5714416503906f, 376.28570556640625f)
),
PointerInputData(
uptime = Uptime.Boot + 216691098.milliseconds,
down = true,
- position = createPxPosition(267.1428527832031.px, 373.1428527832031.px)
+ position = createPxPosition(267.1428527832031f, 373.1428527832031f)
),
PointerInputData(
uptime = Uptime.Boot + 216691106.milliseconds,
down = true,
- position = createPxPosition(267.71429443359375.px, 370.28570556640625.px)
+ position = createPxPosition(267.71429443359375f, 370.28570556640625f)
),
PointerInputData(
uptime = Uptime.Boot + 216691114.milliseconds,
down = true,
- position = createPxPosition(268.28570556640625.px, 367.71429443359375.px)
+ position = createPxPosition(268.28570556640625f, 367.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216691121.milliseconds,
down = true,
- position = createPxPosition(268.5714416503906.px, 366.px)
+ position = createPxPosition(268.5714416503906f, 366f)
),
PointerInputData(
uptime = Uptime.Boot + 216691130.milliseconds,
down = true,
- position = createPxPosition(268.8571472167969.px, 364.5714416503906.px)
+ position = createPxPosition(268.8571472167969f, 364.5714416503906f)
),
PointerInputData(
uptime = Uptime.Boot + 216691137.milliseconds,
down = true,
- position = createPxPosition(269.1428527832031.px, 363.71429443359375.px)
+ position = createPxPosition(269.1428527832031f, 363.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216691145.milliseconds,
down = true,
- position = createPxPosition(269.1428527832031.px, 362.8571472167969.px)
+ position = createPxPosition(269.1428527832031f, 362.8571472167969f)
),
PointerInputData(
uptime = Uptime.Boot + 216691153.milliseconds,
down = true,
- position = createPxPosition(269.4285583496094.px, 362.8571472167969.px)
+ position = createPxPosition(269.4285583496094f, 362.8571472167969f)
),
PointerInputData(
uptime = Uptime.Boot + 216691168.milliseconds,
down = true,
- position = createPxPosition(268.5714416503906.px, 365.4285583496094.px)
+ position = createPxPosition(268.5714416503906f, 365.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216691176.milliseconds,
down = true,
- position = createPxPosition(267.1428527832031.px, 370.28570556640625.px)
+ position = createPxPosition(267.1428527832031f, 370.28570556640625f)
),
PointerInputData(
uptime = Uptime.Boot + 216691183.milliseconds,
down = true,
- position = createPxPosition(265.4285583496094.px, 376.8571472167969.px)
+ position = createPxPosition(265.4285583496094f, 376.8571472167969f)
),
PointerInputData(
uptime = Uptime.Boot + 216691191.milliseconds,
down = true,
- position = createPxPosition(263.1428527832031.px, 385.71429443359375.px)
+ position = createPxPosition(263.1428527832031f, 385.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216691199.milliseconds,
down = true,
- position = createPxPosition(261.4285583496094.px, 396.5714416503906.px)
+ position = createPxPosition(261.4285583496094f, 396.5714416503906f)
),
PointerInputData(
uptime = Uptime.Boot + 216691207.milliseconds,
down = true,
- position = createPxPosition(259.71429443359375.px, 408.5714416503906.px)
+ position = createPxPosition(259.71429443359375f, 408.5714416503906f)
),
PointerInputData(
uptime = Uptime.Boot + 216691215.milliseconds,
down = true,
- position = createPxPosition(258.28570556640625.px, 419.4285583496094.px)
+ position = createPxPosition(258.28570556640625f, 419.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216691222.milliseconds,
down = true,
- position = createPxPosition(257.4285583496094.px, 428.5714416503906.px)
+ position = createPxPosition(257.4285583496094f, 428.5714416503906f)
),
PointerInputData(
uptime = Uptime.Boot + 216691230.milliseconds,
down = true,
- position = createPxPosition(256.28570556640625.px, 436.px)
+ position = createPxPosition(256.28570556640625f, 436f)
),
PointerInputData(
uptime = Uptime.Boot + 216691238.milliseconds,
down = true,
- position = createPxPosition(255.7142791748047.px, 442.px)
+ position = createPxPosition(255.7142791748047f, 442f)
),
PointerInputData(
uptime = Uptime.Boot + 216691245.milliseconds,
down = true,
- position = createPxPosition(255.14285278320312.px, 447.71429443359375.px)
+ position = createPxPosition(255.14285278320312f, 447.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216691253.milliseconds,
down = true,
- position = createPxPosition(254.85714721679688.px, 453.1428527832031.px)
+ position = createPxPosition(254.85714721679688f, 453.1428527832031f)
),
PointerInputData(
uptime = Uptime.Boot + 216691261.milliseconds,
down = true,
- position = createPxPosition(254.57142639160156.px, 458.5714416503906.px)
+ position = createPxPosition(254.57142639160156f, 458.5714416503906f)
),
PointerInputData(
uptime = Uptime.Boot + 216691268.milliseconds,
down = true,
- position = createPxPosition(254.2857208251953.px, 463.71429443359375.px)
+ position = createPxPosition(254.2857208251953f, 463.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216691276.milliseconds,
down = true,
- position = createPxPosition(254.2857208251953.px, 470.28570556640625.px)
+ position = createPxPosition(254.2857208251953f, 470.28570556640625f)
),
PointerInputData(
uptime = Uptime.Boot + 216691284.milliseconds,
down = true,
- position = createPxPosition(254.2857208251953.px, 477.71429443359375.px)
+ position = createPxPosition(254.2857208251953f, 477.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216691292.milliseconds,
down = true,
- position = createPxPosition(255.7142791748047.px, 487.1428527832031.px)
+ position = createPxPosition(255.7142791748047f, 487.1428527832031f)
),
PointerInputData(
uptime = Uptime.Boot + 216691300.milliseconds,
down = true,
- position = createPxPosition(256.8571472167969.px, 498.5714416503906.px)
+ position = createPxPosition(256.8571472167969f, 498.5714416503906f)
),
PointerInputData(
uptime = Uptime.Boot + 216691307.milliseconds,
down = true,
- position = createPxPosition(258.28570556640625.px, 507.71429443359375.px)
+ position = createPxPosition(258.28570556640625f, 507.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216691315.milliseconds,
down = true,
- position = createPxPosition(259.4285583496094.px, 516.px)
+ position = createPxPosition(259.4285583496094f, 516f)
),
PointerInputData(
uptime = Uptime.Boot + 216691323.milliseconds,
down = true,
- position = createPxPosition(260.28570556640625.px, 521.7142944335938.px)
+ position = createPxPosition(260.28570556640625f, 521.7142944335938f)
),
PointerInputData(
uptime = Uptime.Boot + 216691338.milliseconds,
down = false,
- position = createPxPosition(260.28570556640625.px, 521.7142944335938.px)
+ position = createPxPosition(260.28570556640625f, 521.7142944335938f)
),
PointerInputData(
uptime = Uptime.Boot + 216691573.milliseconds,
down = true,
- position = createPxPosition(266.px, 327.4285583496094.px)
+ position = createPxPosition(266f, 327.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216691588.milliseconds,
down = true,
- position = createPxPosition(266.px, 327.4285583496094.px)
+ position = createPxPosition(266f, 327.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216691626.milliseconds,
down = true,
- position = createPxPosition(261.1428527832031.px, 337.1428527832031.px)
+ position = createPxPosition(261.1428527832031f, 337.1428527832031f)
),
PointerInputData(
uptime = Uptime.Boot + 216691634.milliseconds,
down = true,
- position = createPxPosition(258.28570556640625.px, 343.1428527832031.px)
+ position = createPxPosition(258.28570556640625f, 343.1428527832031f)
),
PointerInputData(
uptime = Uptime.Boot + 216691642.milliseconds,
down = true,
- position = createPxPosition(254.57142639160156.px, 354.px)
+ position = createPxPosition(254.57142639160156f, 354f)
),
PointerInputData(
uptime = Uptime.Boot + 216691650.milliseconds,
down = true,
- position = createPxPosition(250.2857208251953.px, 368.28570556640625.px)
+ position = createPxPosition(250.2857208251953f, 368.28570556640625f)
),
PointerInputData(
uptime = Uptime.Boot + 216691657.milliseconds,
down = true,
- position = createPxPosition(247.42857360839844.px, 382.8571472167969.px)
+ position = createPxPosition(247.42857360839844f, 382.8571472167969f)
),
PointerInputData(
uptime = Uptime.Boot + 216691665.milliseconds,
down = true,
- position = createPxPosition(245.14285278320312.px, 397.4285583496094.px)
+ position = createPxPosition(245.14285278320312f, 397.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216691673.milliseconds,
down = true,
- position = createPxPosition(243.14285278320312.px, 411.71429443359375.px)
+ position = createPxPosition(243.14285278320312f, 411.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216691680.milliseconds,
down = true,
- position = createPxPosition(242.2857208251953.px, 426.28570556640625.px)
+ position = createPxPosition(242.2857208251953f, 426.28570556640625f)
),
PointerInputData(
uptime = Uptime.Boot + 216691688.milliseconds,
down = true,
- position = createPxPosition(241.7142791748047.px, 440.5714416503906.px)
+ position = createPxPosition(241.7142791748047f, 440.5714416503906f)
),
PointerInputData(
uptime = Uptime.Boot + 216691696.milliseconds,
down = true,
- position = createPxPosition(241.7142791748047.px, 454.5714416503906.px)
+ position = createPxPosition(241.7142791748047f, 454.5714416503906f)
),
PointerInputData(
uptime = Uptime.Boot + 216691703.milliseconds,
down = true,
- position = createPxPosition(242.57142639160156.px, 467.71429443359375.px)
+ position = createPxPosition(242.57142639160156f, 467.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216691712.milliseconds,
down = true,
- position = createPxPosition(243.42857360839844.px, 477.4285583496094.px)
+ position = createPxPosition(243.42857360839844f, 477.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216691720.milliseconds,
down = true,
- position = createPxPosition(244.85714721679688.px, 485.71429443359375.px)
+ position = createPxPosition(244.85714721679688f, 485.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216691727.milliseconds,
down = true,
- position = createPxPosition(246.2857208251953.px, 493.1428527832031.px)
+ position = createPxPosition(246.2857208251953f, 493.1428527832031f)
),
PointerInputData(
uptime = Uptime.Boot + 216691735.milliseconds,
down = true,
- position = createPxPosition(248.px, 499.71429443359375.px)
+ position = createPxPosition(248f, 499.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216691750.milliseconds,
down = false,
- position = createPxPosition(248.px, 499.71429443359375.px)
+ position = createPxPosition(248f, 499.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216692255.milliseconds,
down = true,
- position = createPxPosition(249.42857360839844.px, 351.4285583496094.px)
+ position = createPxPosition(249.42857360839844f, 351.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216692270.milliseconds,
down = true,
- position = createPxPosition(249.42857360839844.px, 351.4285583496094.px)
+ position = createPxPosition(249.42857360839844f, 351.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216692309.milliseconds,
down = true,
- position = createPxPosition(246.2857208251953.px, 361.71429443359375.px)
+ position = createPxPosition(246.2857208251953f, 361.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216692317.milliseconds,
down = true,
- position = createPxPosition(244.px, 368.5714416503906.px)
+ position = createPxPosition(244f, 368.5714416503906f)
),
PointerInputData(
uptime = Uptime.Boot + 216692325.milliseconds,
down = true,
- position = createPxPosition(241.42857360839844.px, 377.71429443359375.px)
+ position = createPxPosition(241.42857360839844f, 377.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216692333.milliseconds,
down = true,
- position = createPxPosition(237.7142791748047.px, 391.71429443359375.px)
+ position = createPxPosition(237.7142791748047f, 391.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216692340.milliseconds,
down = true,
- position = createPxPosition(235.14285278320312.px, 406.5714416503906.px)
+ position = createPxPosition(235.14285278320312f, 406.5714416503906f)
),
PointerInputData(
uptime = Uptime.Boot + 216692348.milliseconds,
down = true,
- position = createPxPosition(232.57142639160156.px, 421.4285583496094.px)
+ position = createPxPosition(232.57142639160156f, 421.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216692356.milliseconds,
down = true,
- position = createPxPosition(230.2857208251953.px, 436.5714416503906.px)
+ position = createPxPosition(230.2857208251953f, 436.5714416503906f)
),
PointerInputData(
uptime = Uptime.Boot + 216692363.milliseconds,
down = true,
- position = createPxPosition(228.2857208251953.px, 451.71429443359375.px)
+ position = createPxPosition(228.2857208251953f, 451.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216692371.milliseconds,
down = true,
- position = createPxPosition(227.42857360839844.px, 466.px)
+ position = createPxPosition(227.42857360839844f, 466f)
),
PointerInputData(
uptime = Uptime.Boot + 216692378.milliseconds,
down = true,
- position = createPxPosition(226.2857208251953.px, 479.71429443359375.px)
+ position = createPxPosition(226.2857208251953f, 479.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216692387.milliseconds,
down = true,
- position = createPxPosition(225.7142791748047.px, 491.71429443359375.px)
+ position = createPxPosition(225.7142791748047f, 491.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216692395.milliseconds,
down = true,
- position = createPxPosition(225.14285278320312.px, 501.71429443359375.px)
+ position = createPxPosition(225.14285278320312f, 501.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216692402.milliseconds,
down = true,
- position = createPxPosition(224.85714721679688.px, 509.1428527832031.px)
+ position = createPxPosition(224.85714721679688f, 509.1428527832031f)
),
PointerInputData(
uptime = Uptime.Boot + 216692410.milliseconds,
down = true,
- position = createPxPosition(224.57142639160156.px, 514.8571166992188.px)
+ position = createPxPosition(224.57142639160156f, 514.8571166992188f)
),
PointerInputData(
uptime = Uptime.Boot + 216692418.milliseconds,
down = true,
- position = createPxPosition(224.2857208251953.px, 519.4285888671875.px)
+ position = createPxPosition(224.2857208251953f, 519.4285888671875f)
),
PointerInputData(
uptime = Uptime.Boot + 216692425.milliseconds,
down = true,
- position = createPxPosition(224.px, 523.4285888671875.px)
+ position = createPxPosition(224f, 523.4285888671875f)
),
PointerInputData(
uptime = Uptime.Boot + 216692433.milliseconds,
down = true,
- position = createPxPosition(224.px, 527.1428833007812.px)
+ position = createPxPosition(224f, 527.1428833007812f)
),
PointerInputData(
uptime = Uptime.Boot + 216692441.milliseconds,
down = true,
- position = createPxPosition(224.px, 530.5714111328125.px)
+ position = createPxPosition(224f, 530.5714111328125f)
),
PointerInputData(
uptime = Uptime.Boot + 216692448.milliseconds,
down = true,
- position = createPxPosition(224.px, 533.1428833007812.px)
+ position = createPxPosition(224f, 533.1428833007812f)
),
PointerInputData(
uptime = Uptime.Boot + 216692456.milliseconds,
down = true,
- position = createPxPosition(224.px, 535.4285888671875.px)
+ position = createPxPosition(224f, 535.4285888671875f)
),
PointerInputData(
uptime = Uptime.Boot + 216692464.milliseconds,
down = true,
- position = createPxPosition(223.7142791748047.px, 536.8571166992188.px)
+ position = createPxPosition(223.7142791748047f, 536.8571166992188f)
),
PointerInputData(
uptime = Uptime.Boot + 216692472.milliseconds,
down = true,
- position = createPxPosition(223.7142791748047.px, 538.2857055664062.px)
+ position = createPxPosition(223.7142791748047f, 538.2857055664062f)
),
PointerInputData(
uptime = Uptime.Boot + 216692487.milliseconds,
down = false,
- position = createPxPosition(223.7142791748047.px, 538.2857055664062.px)
+ position = createPxPosition(223.7142791748047f, 538.2857055664062f)
),
PointerInputData(
uptime = Uptime.Boot + 216692678.milliseconds,
down = true,
- position = createPxPosition(221.42857360839844.px, 526.2857055664062.px)
+ position = createPxPosition(221.42857360839844f, 526.2857055664062f)
),
PointerInputData(
uptime = Uptime.Boot + 216692701.milliseconds,
down = true,
- position = createPxPosition(220.57142639160156.px, 514.8571166992188.px)
+ position = createPxPosition(220.57142639160156f, 514.8571166992188f)
),
PointerInputData(
uptime = Uptime.Boot + 216692708.milliseconds,
down = true,
- position = createPxPosition(220.2857208251953.px, 508.px)
+ position = createPxPosition(220.2857208251953f, 508f)
),
PointerInputData(
uptime = Uptime.Boot + 216692716.milliseconds,
down = true,
- position = createPxPosition(220.2857208251953.px, 498.px)
+ position = createPxPosition(220.2857208251953f, 498f)
),
PointerInputData(
uptime = Uptime.Boot + 216692724.milliseconds,
down = true,
- position = createPxPosition(221.14285278320312.px, 484.28570556640625.px)
+ position = createPxPosition(221.14285278320312f, 484.28570556640625f)
),
PointerInputData(
uptime = Uptime.Boot + 216692732.milliseconds,
down = true,
- position = createPxPosition(221.7142791748047.px, 469.4285583496094.px)
+ position = createPxPosition(221.7142791748047f, 469.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216692740.milliseconds,
down = true,
- position = createPxPosition(223.42857360839844.px, 453.1428527832031.px)
+ position = createPxPosition(223.42857360839844f, 453.1428527832031f)
),
PointerInputData(
uptime = Uptime.Boot + 216692748.milliseconds,
down = true,
- position = createPxPosition(225.7142791748047.px, 436.28570556640625.px)
+ position = createPxPosition(225.7142791748047f, 436.28570556640625f)
),
PointerInputData(
uptime = Uptime.Boot + 216692755.milliseconds,
down = true,
- position = createPxPosition(229.14285278320312.px, 418.28570556640625.px)
+ position = createPxPosition(229.14285278320312f, 418.28570556640625f)
),
PointerInputData(
uptime = Uptime.Boot + 216692763.milliseconds,
down = true,
- position = createPxPosition(232.85714721679688.px, 400.28570556640625.px)
+ position = createPxPosition(232.85714721679688f, 400.28570556640625f)
),
PointerInputData(
uptime = Uptime.Boot + 216692770.milliseconds,
down = true,
- position = createPxPosition(236.85714721679688.px, 382.5714416503906.px)
+ position = createPxPosition(236.85714721679688f, 382.5714416503906f)
),
PointerInputData(
uptime = Uptime.Boot + 216692778.milliseconds,
down = true,
- position = createPxPosition(241.14285278320312.px, 366.px)
+ position = createPxPosition(241.14285278320312f, 366f)
),
PointerInputData(
uptime = Uptime.Boot + 216692786.milliseconds,
down = true,
- position = createPxPosition(244.85714721679688.px, 350.28570556640625.px)
+ position = createPxPosition(244.85714721679688f, 350.28570556640625f)
),
PointerInputData(
uptime = Uptime.Boot + 216692793.milliseconds,
down = true,
- position = createPxPosition(249.14285278320312.px, 335.4285583496094.px)
+ position = createPxPosition(249.14285278320312f, 335.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216692809.milliseconds,
down = false,
- position = createPxPosition(249.14285278320312.px, 335.4285583496094.px)
+ position = createPxPosition(249.14285278320312f, 335.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216693222.milliseconds,
down = true,
- position = createPxPosition(224.px, 545.4285888671875.px)
+ position = createPxPosition(224f, 545.4285888671875f)
),
PointerInputData(
uptime = Uptime.Boot + 216693245.milliseconds,
down = true,
- position = createPxPosition(224.px, 545.4285888671875.px)
+ position = createPxPosition(224f, 545.4285888671875f)
),
PointerInputData(
uptime = Uptime.Boot + 216693275.milliseconds,
down = true,
- position = createPxPosition(222.85714721679688.px, 535.1428833007812.px)
+ position = createPxPosition(222.85714721679688f, 535.1428833007812f)
),
PointerInputData(
uptime = Uptime.Boot + 216693284.milliseconds,
down = true,
- position = createPxPosition(222.85714721679688.px, 528.8571166992188.px)
+ position = createPxPosition(222.85714721679688f, 528.8571166992188f)
),
PointerInputData(
uptime = Uptime.Boot + 216693291.milliseconds,
down = true,
- position = createPxPosition(222.2857208251953.px, 518.5714111328125.px)
+ position = createPxPosition(222.2857208251953f, 518.5714111328125f)
),
PointerInputData(
uptime = Uptime.Boot + 216693299.milliseconds,
down = true,
- position = createPxPosition(222.px, 503.4285583496094.px)
+ position = createPxPosition(222f, 503.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216693307.milliseconds,
down = true,
- position = createPxPosition(222.px, 485.4285583496094.px)
+ position = createPxPosition(222f, 485.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216693314.milliseconds,
down = true,
- position = createPxPosition(221.7142791748047.px, 464.px)
+ position = createPxPosition(221.7142791748047f, 464f)
),
PointerInputData(
uptime = Uptime.Boot + 216693322.milliseconds,
down = true,
- position = createPxPosition(222.2857208251953.px, 440.28570556640625.px)
+ position = createPxPosition(222.2857208251953f, 440.28570556640625f)
),
PointerInputData(
uptime = Uptime.Boot + 216693337.milliseconds,
down = false,
- position = createPxPosition(222.2857208251953.px, 440.28570556640625.px)
+ position = createPxPosition(222.2857208251953f, 440.28570556640625f)
),
PointerInputData(
uptime = Uptime.Boot + 216693985.milliseconds,
down = true,
- position = createPxPosition(208.px, 544.px)
+ position = createPxPosition(208f, 544f)
),
PointerInputData(
uptime = Uptime.Boot + 216694047.milliseconds,
down = true,
- position = createPxPosition(208.57142639160156.px, 532.2857055664062.px)
+ position = createPxPosition(208.57142639160156f, 532.2857055664062f)
),
PointerInputData(
uptime = Uptime.Boot + 216694054.milliseconds,
down = true,
- position = createPxPosition(208.85714721679688.px, 525.7142944335938.px)
+ position = createPxPosition(208.85714721679688f, 525.7142944335938f)
),
PointerInputData(
uptime = Uptime.Boot + 216694062.milliseconds,
down = true,
- position = createPxPosition(208.85714721679688.px, 515.1428833007812.px)
+ position = createPxPosition(208.85714721679688f, 515.1428833007812f)
),
PointerInputData(
uptime = Uptime.Boot + 216694070.milliseconds,
down = true,
- position = createPxPosition(208.px, 501.4285583496094.px)
+ position = createPxPosition(208f, 501.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216694077.milliseconds,
down = true,
- position = createPxPosition(207.42857360839844.px, 487.1428527832031.px)
+ position = createPxPosition(207.42857360839844f, 487.1428527832031f)
),
PointerInputData(
uptime = Uptime.Boot + 216694085.milliseconds,
down = true,
- position = createPxPosition(206.57142639160156.px, 472.8571472167969.px)
+ position = createPxPosition(206.57142639160156f, 472.8571472167969f)
),
PointerInputData(
uptime = Uptime.Boot + 216694092.milliseconds,
down = true,
- position = createPxPosition(206.57142639160156.px, 458.8571472167969.px)
+ position = createPxPosition(206.57142639160156f, 458.8571472167969f)
),
PointerInputData(
uptime = Uptime.Boot + 216694100.milliseconds,
down = true,
- position = createPxPosition(206.57142639160156.px, 446.px)
+ position = createPxPosition(206.57142639160156f, 446f)
),
PointerInputData(
uptime = Uptime.Boot + 216694108.milliseconds,
down = true,
- position = createPxPosition(206.57142639160156.px, 434.28570556640625.px)
+ position = createPxPosition(206.57142639160156f, 434.28570556640625f)
),
PointerInputData(
uptime = Uptime.Boot + 216694116.milliseconds,
down = true,
- position = createPxPosition(207.14285278320312.px, 423.71429443359375.px)
+ position = createPxPosition(207.14285278320312f, 423.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216694124.milliseconds,
down = true,
- position = createPxPosition(208.57142639160156.px, 412.8571472167969.px)
+ position = createPxPosition(208.57142639160156f, 412.8571472167969f)
),
PointerInputData(
uptime = Uptime.Boot + 216694131.milliseconds,
down = true,
- position = createPxPosition(209.7142791748047.px, 402.28570556640625.px)
+ position = createPxPosition(209.7142791748047f, 402.28570556640625f)
),
PointerInputData(
uptime = Uptime.Boot + 216694139.milliseconds,
down = true,
- position = createPxPosition(211.7142791748047.px, 393.1428527832031.px)
+ position = createPxPosition(211.7142791748047f, 393.1428527832031f)
),
PointerInputData(
uptime = Uptime.Boot + 216694147.milliseconds,
down = true,
- position = createPxPosition(213.42857360839844.px, 385.1428527832031.px)
+ position = createPxPosition(213.42857360839844f, 385.1428527832031f)
),
PointerInputData(
uptime = Uptime.Boot + 216694154.milliseconds,
down = true,
- position = createPxPosition(215.42857360839844.px, 378.28570556640625.px)
+ position = createPxPosition(215.42857360839844f, 378.28570556640625f)
),
PointerInputData(
uptime = Uptime.Boot + 216694162.milliseconds,
down = true,
- position = createPxPosition(217.42857360839844.px, 371.71429443359375.px)
+ position = createPxPosition(217.42857360839844f, 371.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216694169.milliseconds,
down = true,
- position = createPxPosition(219.42857360839844.px, 366.px)
+ position = createPxPosition(219.42857360839844f, 366f)
),
PointerInputData(
uptime = Uptime.Boot + 216694177.milliseconds,
down = true,
- position = createPxPosition(221.42857360839844.px, 360.8571472167969.px)
+ position = createPxPosition(221.42857360839844f, 360.8571472167969f)
),
PointerInputData(
uptime = Uptime.Boot + 216694185.milliseconds,
down = true,
- position = createPxPosition(223.42857360839844.px, 356.5714416503906.px)
+ position = createPxPosition(223.42857360839844f, 356.5714416503906f)
),
PointerInputData(
uptime = Uptime.Boot + 216694193.milliseconds,
down = true,
- position = createPxPosition(225.14285278320312.px, 352.28570556640625.px)
+ position = createPxPosition(225.14285278320312f, 352.28570556640625f)
),
PointerInputData(
uptime = Uptime.Boot + 216694201.milliseconds,
down = true,
- position = createPxPosition(226.85714721679688.px, 348.5714416503906.px)
+ position = createPxPosition(226.85714721679688f, 348.5714416503906f)
),
PointerInputData(
uptime = Uptime.Boot + 216694209.milliseconds,
down = true,
- position = createPxPosition(228.2857208251953.px, 346.px)
+ position = createPxPosition(228.2857208251953f, 346f)
),
PointerInputData(
uptime = Uptime.Boot + 216694216.milliseconds,
down = true,
- position = createPxPosition(229.14285278320312.px, 343.71429443359375.px)
+ position = createPxPosition(229.14285278320312f, 343.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216694224.milliseconds,
down = true,
- position = createPxPosition(230.px, 342.px)
+ position = createPxPosition(230f, 342f)
),
PointerInputData(
uptime = Uptime.Boot + 216694232.milliseconds,
down = true,
- position = createPxPosition(230.57142639160156.px, 340.5714416503906.px)
+ position = createPxPosition(230.57142639160156f, 340.5714416503906f)
),
PointerInputData(
uptime = Uptime.Boot + 216694239.milliseconds,
down = true,
- position = createPxPosition(230.85714721679688.px, 339.71429443359375.px)
+ position = createPxPosition(230.85714721679688f, 339.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216694247.milliseconds,
down = true,
- position = createPxPosition(230.85714721679688.px, 339.4285583496094.px)
+ position = createPxPosition(230.85714721679688f, 339.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216694262.milliseconds,
down = true,
- position = createPxPosition(230.2857208251953.px, 342.px)
+ position = createPxPosition(230.2857208251953f, 342f)
),
PointerInputData(
uptime = Uptime.Boot + 216694270.milliseconds,
down = true,
- position = createPxPosition(228.85714721679688.px, 346.28570556640625.px)
+ position = createPxPosition(228.85714721679688f, 346.28570556640625f)
),
PointerInputData(
uptime = Uptime.Boot + 216694278.milliseconds,
down = true,
- position = createPxPosition(227.14285278320312.px, 352.5714416503906.px)
+ position = createPxPosition(227.14285278320312f, 352.5714416503906f)
),
PointerInputData(
uptime = Uptime.Boot + 216694286.milliseconds,
down = true,
- position = createPxPosition(225.42857360839844.px, 359.4285583496094.px)
+ position = createPxPosition(225.42857360839844f, 359.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216694294.milliseconds,
down = true,
- position = createPxPosition(223.7142791748047.px, 367.71429443359375.px)
+ position = createPxPosition(223.7142791748047f, 367.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216694301.milliseconds,
down = true,
- position = createPxPosition(222.57142639160156.px, 376.px)
+ position = createPxPosition(222.57142639160156f, 376f)
),
PointerInputData(
uptime = Uptime.Boot + 216694309.milliseconds,
down = true,
- position = createPxPosition(221.42857360839844.px, 384.28570556640625.px)
+ position = createPxPosition(221.42857360839844f, 384.28570556640625f)
),
PointerInputData(
uptime = Uptime.Boot + 216694317.milliseconds,
down = true,
- position = createPxPosition(220.85714721679688.px, 392.28570556640625.px)
+ position = createPxPosition(220.85714721679688f, 392.28570556640625f)
),
PointerInputData(
uptime = Uptime.Boot + 216694324.milliseconds,
down = true,
- position = createPxPosition(220.px, 400.5714416503906.px)
+ position = createPxPosition(220f, 400.5714416503906f)
),
PointerInputData(
uptime = Uptime.Boot + 216694332.milliseconds,
down = true,
- position = createPxPosition(219.14285278320312.px, 409.71429443359375.px)
+ position = createPxPosition(219.14285278320312f, 409.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216694339.milliseconds,
down = true,
- position = createPxPosition(218.85714721679688.px, 419.1428527832031.px)
+ position = createPxPosition(218.85714721679688f, 419.1428527832031f)
),
PointerInputData(
uptime = Uptime.Boot + 216694348.milliseconds,
down = true,
- position = createPxPosition(218.2857208251953.px, 428.8571472167969.px)
+ position = createPxPosition(218.2857208251953f, 428.8571472167969f)
),
PointerInputData(
uptime = Uptime.Boot + 216694356.milliseconds,
down = true,
- position = createPxPosition(218.2857208251953.px, 438.8571472167969.px)
+ position = createPxPosition(218.2857208251953f, 438.8571472167969f)
),
PointerInputData(
uptime = Uptime.Boot + 216694363.milliseconds,
down = true,
- position = createPxPosition(218.2857208251953.px, 447.71429443359375.px)
+ position = createPxPosition(218.2857208251953f, 447.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216694371.milliseconds,
down = true,
- position = createPxPosition(218.2857208251953.px, 455.71429443359375.px)
+ position = createPxPosition(218.2857208251953f, 455.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216694379.milliseconds,
down = true,
- position = createPxPosition(219.14285278320312.px, 462.8571472167969.px)
+ position = createPxPosition(219.14285278320312f, 462.8571472167969f)
),
PointerInputData(
uptime = Uptime.Boot + 216694386.milliseconds,
down = true,
- position = createPxPosition(220.px, 469.4285583496094.px)
+ position = createPxPosition(220f, 469.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216694394.milliseconds,
down = true,
- position = createPxPosition(221.14285278320312.px, 475.4285583496094.px)
+ position = createPxPosition(221.14285278320312f, 475.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216694401.milliseconds,
down = true,
- position = createPxPosition(222.px, 480.5714416503906.px)
+ position = createPxPosition(222f, 480.5714416503906f)
),
PointerInputData(
uptime = Uptime.Boot + 216694409.milliseconds,
down = true,
- position = createPxPosition(222.85714721679688.px, 485.4285583496094.px)
+ position = createPxPosition(222.85714721679688f, 485.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216694417.milliseconds,
down = true,
- position = createPxPosition(224.px, 489.71429443359375.px)
+ position = createPxPosition(224f, 489.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216694425.milliseconds,
down = true,
- position = createPxPosition(224.85714721679688.px, 492.8571472167969.px)
+ position = createPxPosition(224.85714721679688f, 492.8571472167969f)
),
PointerInputData(
uptime = Uptime.Boot + 216694433.milliseconds,
down = true,
- position = createPxPosition(225.42857360839844.px, 495.4285583496094.px)
+ position = createPxPosition(225.42857360839844f, 495.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216694440.milliseconds,
down = true,
- position = createPxPosition(226.px, 497.1428527832031.px)
+ position = createPxPosition(226f, 497.1428527832031f)
),
PointerInputData(
uptime = Uptime.Boot + 216694448.milliseconds,
down = true,
- position = createPxPosition(226.2857208251953.px, 498.28570556640625.px)
+ position = createPxPosition(226.2857208251953f, 498.28570556640625f)
),
PointerInputData(
uptime = Uptime.Boot + 216694456.milliseconds,
down = true,
- position = createPxPosition(226.2857208251953.px, 498.8571472167969.px)
+ position = createPxPosition(226.2857208251953f, 498.8571472167969f)
),
PointerInputData(
uptime = Uptime.Boot + 216694471.milliseconds,
down = true,
- position = createPxPosition(226.2857208251953.px, 498.28570556640625.px)
+ position = createPxPosition(226.2857208251953f, 498.28570556640625f)
),
PointerInputData(
uptime = Uptime.Boot + 216694479.milliseconds,
down = true,
- position = createPxPosition(226.2857208251953.px, 496.5714416503906.px)
+ position = createPxPosition(226.2857208251953f, 496.5714416503906f)
),
PointerInputData(
uptime = Uptime.Boot + 216694486.milliseconds,
down = true,
- position = createPxPosition(226.2857208251953.px, 493.71429443359375.px)
+ position = createPxPosition(226.2857208251953f, 493.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216694494.milliseconds,
down = true,
- position = createPxPosition(226.2857208251953.px, 490.px)
+ position = createPxPosition(226.2857208251953f, 490f)
),
PointerInputData(
uptime = Uptime.Boot + 216694502.milliseconds,
down = true,
- position = createPxPosition(226.2857208251953.px, 486.px)
+ position = createPxPosition(226.2857208251953f, 486f)
),
PointerInputData(
uptime = Uptime.Boot + 216694510.milliseconds,
down = true,
- position = createPxPosition(226.2857208251953.px, 480.5714416503906.px)
+ position = createPxPosition(226.2857208251953f, 480.5714416503906f)
),
PointerInputData(
uptime = Uptime.Boot + 216694518.milliseconds,
down = true,
- position = createPxPosition(226.2857208251953.px, 475.71429443359375.px)
+ position = createPxPosition(226.2857208251953f, 475.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216694525.milliseconds,
down = true,
- position = createPxPosition(226.2857208251953.px, 468.8571472167969.px)
+ position = createPxPosition(226.2857208251953f, 468.8571472167969f)
),
PointerInputData(
uptime = Uptime.Boot + 216694533.milliseconds,
down = true,
- position = createPxPosition(226.2857208251953.px, 461.4285583496094.px)
+ position = createPxPosition(226.2857208251953f, 461.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216694541.milliseconds,
down = true,
- position = createPxPosition(226.2857208251953.px, 452.5714416503906.px)
+ position = createPxPosition(226.2857208251953f, 452.5714416503906f)
),
PointerInputData(
uptime = Uptime.Boot + 216694548.milliseconds,
down = true,
- position = createPxPosition(226.57142639160156.px, 442.28570556640625.px)
+ position = createPxPosition(226.57142639160156f, 442.28570556640625f)
),
PointerInputData(
uptime = Uptime.Boot + 216694556.milliseconds,
down = true,
- position = createPxPosition(226.57142639160156.px, 432.28570556640625.px)
+ position = createPxPosition(226.57142639160156f, 432.28570556640625f)
),
PointerInputData(
uptime = Uptime.Boot + 216694564.milliseconds,
down = true,
- position = createPxPosition(226.85714721679688.px, 423.4285583496094.px)
+ position = createPxPosition(226.85714721679688f, 423.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216694571.milliseconds,
down = true,
- position = createPxPosition(227.42857360839844.px, 416.px)
+ position = createPxPosition(227.42857360839844f, 416f)
),
PointerInputData(
uptime = Uptime.Boot + 216694580.milliseconds,
down = true,
- position = createPxPosition(227.7142791748047.px, 410.px)
+ position = createPxPosition(227.7142791748047f, 410f)
),
PointerInputData(
uptime = Uptime.Boot + 216694587.milliseconds,
down = true,
- position = createPxPosition(228.2857208251953.px, 404.28570556640625.px)
+ position = createPxPosition(228.2857208251953f, 404.28570556640625f)
),
PointerInputData(
uptime = Uptime.Boot + 216694595.milliseconds,
down = true,
- position = createPxPosition(228.85714721679688.px, 399.71429443359375.px)
+ position = createPxPosition(228.85714721679688f, 399.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216694603.milliseconds,
down = true,
- position = createPxPosition(229.14285278320312.px, 395.4285583496094.px)
+ position = createPxPosition(229.14285278320312f, 395.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216694610.milliseconds,
down = true,
- position = createPxPosition(229.42857360839844.px, 392.28570556640625.px)
+ position = createPxPosition(229.42857360839844f, 392.28570556640625f)
),
PointerInputData(
uptime = Uptime.Boot + 216694618.milliseconds,
down = true,
- position = createPxPosition(229.7142791748047.px, 390.px)
+ position = createPxPosition(229.7142791748047f, 390f)
),
PointerInputData(
uptime = Uptime.Boot + 216694625.milliseconds,
down = true,
- position = createPxPosition(229.7142791748047.px, 388.px)
+ position = createPxPosition(229.7142791748047f, 388f)
),
PointerInputData(
uptime = Uptime.Boot + 216694633.milliseconds,
down = true,
- position = createPxPosition(229.7142791748047.px, 386.8571472167969.px)
+ position = createPxPosition(229.7142791748047f, 386.8571472167969f)
),
PointerInputData(
uptime = Uptime.Boot + 216694641.milliseconds,
down = true,
- position = createPxPosition(229.7142791748047.px, 386.28570556640625.px)
+ position = createPxPosition(229.7142791748047f, 386.28570556640625f)
),
PointerInputData(
uptime = Uptime.Boot + 216694648.milliseconds,
down = true,
- position = createPxPosition(229.7142791748047.px, 386.px)
+ position = createPxPosition(229.7142791748047f, 386f)
),
PointerInputData(
uptime = Uptime.Boot + 216694657.milliseconds,
down = true,
- position = createPxPosition(228.85714721679688.px, 386.px)
+ position = createPxPosition(228.85714721679688f, 386f)
),
PointerInputData(
uptime = Uptime.Boot + 216694665.milliseconds,
down = true,
- position = createPxPosition(228.px, 388.px)
+ position = createPxPosition(228f, 388f)
),
PointerInputData(
uptime = Uptime.Boot + 216694672.milliseconds,
down = true,
- position = createPxPosition(226.px, 392.5714416503906.px)
+ position = createPxPosition(226f, 392.5714416503906f)
),
PointerInputData(
uptime = Uptime.Boot + 216694680.milliseconds,
down = true,
- position = createPxPosition(224.px, 397.71429443359375.px)
+ position = createPxPosition(224f, 397.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216694688.milliseconds,
down = true,
- position = createPxPosition(222.px, 404.28570556640625.px)
+ position = createPxPosition(222f, 404.28570556640625f)
),
PointerInputData(
uptime = Uptime.Boot + 216694695.milliseconds,
down = true,
- position = createPxPosition(219.7142791748047.px, 411.1428527832031.px)
+ position = createPxPosition(219.7142791748047f, 411.1428527832031f)
),
PointerInputData(
uptime = Uptime.Boot + 216694703.milliseconds,
down = true,
- position = createPxPosition(218.2857208251953.px, 418.px)
+ position = createPxPosition(218.2857208251953f, 418f)
),
PointerInputData(
uptime = Uptime.Boot + 216694710.milliseconds,
down = true,
- position = createPxPosition(217.14285278320312.px, 425.4285583496094.px)
+ position = createPxPosition(217.14285278320312f, 425.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216694718.milliseconds,
down = true,
- position = createPxPosition(215.7142791748047.px, 433.4285583496094.px)
+ position = createPxPosition(215.7142791748047f, 433.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216694726.milliseconds,
down = true,
- position = createPxPosition(214.85714721679688.px, 442.28570556640625.px)
+ position = createPxPosition(214.85714721679688f, 442.28570556640625f)
),
PointerInputData(
uptime = Uptime.Boot + 216694734.milliseconds,
down = true,
- position = createPxPosition(214.px, 454.px)
+ position = createPxPosition(214f, 454f)
),
PointerInputData(
uptime = Uptime.Boot + 216694742.milliseconds,
down = true,
- position = createPxPosition(214.px, 469.4285583496094.px)
+ position = createPxPosition(214f, 469.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216694749.milliseconds,
down = true,
- position = createPxPosition(215.42857360839844.px, 485.4285583496094.px)
+ position = createPxPosition(215.42857360839844f, 485.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216694757.milliseconds,
down = true,
- position = createPxPosition(217.7142791748047.px, 502.8571472167969.px)
+ position = createPxPosition(217.7142791748047f, 502.8571472167969f)
),
PointerInputData(
uptime = Uptime.Boot + 216694765.milliseconds,
down = true,
- position = createPxPosition(221.14285278320312.px, 521.4285888671875.px)
+ position = createPxPosition(221.14285278320312f, 521.4285888671875f)
),
PointerInputData(
uptime = Uptime.Boot + 216694772.milliseconds,
down = true,
- position = createPxPosition(224.57142639160156.px, 541.1428833007812.px)
+ position = createPxPosition(224.57142639160156f, 541.1428833007812f)
),
PointerInputData(
uptime = Uptime.Boot + 216694780.milliseconds,
down = true,
- position = createPxPosition(229.14285278320312.px, 561.1428833007812.px)
+ position = createPxPosition(229.14285278320312f, 561.1428833007812f)
),
PointerInputData(
uptime = Uptime.Boot + 216694788.milliseconds,
down = true,
- position = createPxPosition(233.42857360839844.px, 578.8571166992188.px)
+ position = createPxPosition(233.42857360839844f, 578.8571166992188f)
),
PointerInputData(
uptime = Uptime.Boot + 216694802.milliseconds,
down = false,
- position = createPxPosition(233.42857360839844.px, 578.8571166992188.px)
+ position = createPxPosition(233.42857360839844f, 578.8571166992188f)
),
PointerInputData(
uptime = Uptime.Boot + 216695344.milliseconds,
down = true,
- position = createPxPosition(253.42857360839844.px, 310.5714416503906.px)
+ position = createPxPosition(253.42857360839844f, 310.5714416503906f)
),
PointerInputData(
uptime = Uptime.Boot + 216695352.milliseconds,
down = true,
- position = createPxPosition(253.42857360839844.px, 310.5714416503906.px)
+ position = createPxPosition(253.42857360839844f, 310.5714416503906f)
),
PointerInputData(
uptime = Uptime.Boot + 216695359.milliseconds,
down = true,
- position = createPxPosition(252.85714721679688.px, 318.px)
+ position = createPxPosition(252.85714721679688f, 318f)
),
PointerInputData(
uptime = Uptime.Boot + 216695367.milliseconds,
down = true,
- position = createPxPosition(251.14285278320312.px, 322.px)
+ position = createPxPosition(251.14285278320312f, 322f)
),
PointerInputData(
uptime = Uptime.Boot + 216695375.milliseconds,
down = true,
- position = createPxPosition(248.85714721679688.px, 327.1428527832031.px)
+ position = createPxPosition(248.85714721679688f, 327.1428527832031f)
),
PointerInputData(
uptime = Uptime.Boot + 216695382.milliseconds,
down = true,
- position = createPxPosition(246.px, 334.8571472167969.px)
+ position = createPxPosition(246f, 334.8571472167969f)
),
PointerInputData(
uptime = Uptime.Boot + 216695390.milliseconds,
down = true,
- position = createPxPosition(242.57142639160156.px, 344.5714416503906.px)
+ position = createPxPosition(242.57142639160156f, 344.5714416503906f)
),
PointerInputData(
uptime = Uptime.Boot + 216695397.milliseconds,
down = true,
- position = createPxPosition(238.85714721679688.px, 357.4285583496094.px)
+ position = createPxPosition(238.85714721679688f, 357.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216695406.milliseconds,
down = true,
- position = createPxPosition(235.7142791748047.px, 371.71429443359375.px)
+ position = createPxPosition(235.7142791748047f, 371.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216695414.milliseconds,
down = true,
- position = createPxPosition(232.2857208251953.px, 386.8571472167969.px)
+ position = createPxPosition(232.2857208251953f, 386.8571472167969f)
),
PointerInputData(
uptime = Uptime.Boot + 216695421.milliseconds,
down = true,
- position = createPxPosition(229.42857360839844.px, 402.px)
+ position = createPxPosition(229.42857360839844f, 402f)
),
PointerInputData(
uptime = Uptime.Boot + 216695429.milliseconds,
down = true,
- position = createPxPosition(227.42857360839844.px, 416.8571472167969.px)
+ position = createPxPosition(227.42857360839844f, 416.8571472167969f)
),
PointerInputData(
uptime = Uptime.Boot + 216695437.milliseconds,
down = true,
- position = createPxPosition(226.2857208251953.px, 431.4285583496094.px)
+ position = createPxPosition(226.2857208251953f, 431.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216695444.milliseconds,
down = true,
- position = createPxPosition(226.2857208251953.px, 446.px)
+ position = createPxPosition(226.2857208251953f, 446f)
),
PointerInputData(
uptime = Uptime.Boot + 216695452.milliseconds,
down = true,
- position = createPxPosition(227.7142791748047.px, 460.28570556640625.px)
+ position = createPxPosition(227.7142791748047f, 460.28570556640625f)
),
PointerInputData(
uptime = Uptime.Boot + 216695459.milliseconds,
down = true,
- position = createPxPosition(230.px, 475.1428527832031.px)
+ position = createPxPosition(230f, 475.1428527832031f)
),
PointerInputData(
uptime = Uptime.Boot + 216695467.milliseconds,
down = true,
- position = createPxPosition(232.2857208251953.px, 489.71429443359375.px)
+ position = createPxPosition(232.2857208251953f, 489.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216695475.milliseconds,
down = true,
- position = createPxPosition(235.7142791748047.px, 504.px)
+ position = createPxPosition(235.7142791748047f, 504f)
),
PointerInputData(
uptime = Uptime.Boot + 216695490.milliseconds,
down = false,
- position = createPxPosition(235.7142791748047.px, 504.px)
+ position = createPxPosition(235.7142791748047f, 504f)
),
PointerInputData(
uptime = Uptime.Boot + 216695885.milliseconds,
down = true,
- position = createPxPosition(238.85714721679688.px, 524.px)
+ position = createPxPosition(238.85714721679688f, 524f)
),
PointerInputData(
uptime = Uptime.Boot + 216695908.milliseconds,
down = true,
- position = createPxPosition(236.2857208251953.px, 515.7142944335938.px)
+ position = createPxPosition(236.2857208251953f, 515.7142944335938f)
),
PointerInputData(
uptime = Uptime.Boot + 216695916.milliseconds,
down = true,
- position = createPxPosition(234.85714721679688.px, 509.1428527832031.px)
+ position = createPxPosition(234.85714721679688f, 509.1428527832031f)
),
PointerInputData(
uptime = Uptime.Boot + 216695924.milliseconds,
down = true,
- position = createPxPosition(232.57142639160156.px, 498.5714416503906.px)
+ position = createPxPosition(232.57142639160156f, 498.5714416503906f)
),
PointerInputData(
uptime = Uptime.Boot + 216695931.milliseconds,
down = true,
- position = createPxPosition(230.57142639160156.px, 483.71429443359375.px)
+ position = createPxPosition(230.57142639160156f, 483.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216695939.milliseconds,
down = true,
- position = createPxPosition(229.14285278320312.px, 466.5714416503906.px)
+ position = createPxPosition(229.14285278320312f, 466.5714416503906f)
),
PointerInputData(
uptime = Uptime.Boot + 216695947.milliseconds,
down = true,
- position = createPxPosition(229.14285278320312.px, 446.5714416503906.px)
+ position = createPxPosition(229.14285278320312f, 446.5714416503906f)
),
PointerInputData(
uptime = Uptime.Boot + 216695955.milliseconds,
down = true,
- position = createPxPosition(230.57142639160156.px, 424.8571472167969.px)
+ position = createPxPosition(230.57142639160156f, 424.8571472167969f)
),
PointerInputData(
uptime = Uptime.Boot + 216695963.milliseconds,
down = true,
- position = createPxPosition(232.57142639160156.px, 402.28570556640625.px)
+ position = createPxPosition(232.57142639160156f, 402.28570556640625f)
),
PointerInputData(
uptime = Uptime.Boot + 216695970.milliseconds,
down = true,
- position = createPxPosition(235.14285278320312.px, 380.px)
+ position = createPxPosition(235.14285278320312f, 380f)
),
PointerInputData(
uptime = Uptime.Boot + 216695978.milliseconds,
down = true,
- position = createPxPosition(238.57142639160156.px, 359.4285583496094.px)
+ position = createPxPosition(238.57142639160156f, 359.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216695993.milliseconds,
down = false,
- position = createPxPosition(238.57142639160156.px, 359.4285583496094.px)
+ position = createPxPosition(238.57142639160156f, 359.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216696429.milliseconds,
down = true,
- position = createPxPosition(238.2857208251953.px, 568.5714111328125.px)
+ position = createPxPosition(238.2857208251953f, 568.5714111328125f)
),
PointerInputData(
uptime = Uptime.Boot + 216696459.milliseconds,
down = true,
- position = createPxPosition(234.px, 560.px)
+ position = createPxPosition(234f, 560f)
),
PointerInputData(
uptime = Uptime.Boot + 216696467.milliseconds,
down = true,
- position = createPxPosition(231.42857360839844.px, 553.1428833007812.px)
+ position = createPxPosition(231.42857360839844f, 553.1428833007812f)
),
PointerInputData(
uptime = Uptime.Boot + 216696475.milliseconds,
down = true,
- position = createPxPosition(228.2857208251953.px, 543.1428833007812.px)
+ position = createPxPosition(228.2857208251953f, 543.1428833007812f)
),
PointerInputData(
uptime = Uptime.Boot + 216696483.milliseconds,
down = true,
- position = createPxPosition(225.42857360839844.px, 528.8571166992188.px)
+ position = createPxPosition(225.42857360839844f, 528.8571166992188f)
),
PointerInputData(
uptime = Uptime.Boot + 216696491.milliseconds,
down = true,
- position = createPxPosition(223.14285278320312.px, 512.2857055664062.px)
+ position = createPxPosition(223.14285278320312f, 512.2857055664062f)
),
PointerInputData(
uptime = Uptime.Boot + 216696498.milliseconds,
down = true,
- position = createPxPosition(222.px, 495.4285583496094.px)
+ position = createPxPosition(222f, 495.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216696506.milliseconds,
down = true,
- position = createPxPosition(221.7142791748047.px, 477.4285583496094.px)
+ position = createPxPosition(221.7142791748047f, 477.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216696514.milliseconds,
down = true,
- position = createPxPosition(221.7142791748047.px, 458.28570556640625.px)
+ position = createPxPosition(221.7142791748047f, 458.28570556640625f)
),
PointerInputData(
uptime = Uptime.Boot + 216696521.milliseconds,
down = true,
- position = createPxPosition(223.14285278320312.px, 438.px)
+ position = createPxPosition(223.14285278320312f, 438f)
),
PointerInputData(
uptime = Uptime.Boot + 216696529.milliseconds,
down = true,
- position = createPxPosition(224.2857208251953.px, 416.28570556640625.px)
+ position = createPxPosition(224.2857208251953f, 416.28570556640625f)
),
PointerInputData(
uptime = Uptime.Boot + 216696544.milliseconds,
down = false,
- position = createPxPosition(224.2857208251953.px, 416.28570556640625.px)
+ position = createPxPosition(224.2857208251953f, 416.28570556640625f)
),
PointerInputData(
uptime = Uptime.Boot + 216696974.milliseconds,
down = true,
- position = createPxPosition(218.57142639160156.px, 530.5714111328125.px)
+ position = createPxPosition(218.57142639160156f, 530.5714111328125f)
),
PointerInputData(
uptime = Uptime.Boot + 216697012.milliseconds,
down = true,
- position = createPxPosition(220.2857208251953.px, 522.px)
+ position = createPxPosition(220.2857208251953f, 522f)
),
PointerInputData(
uptime = Uptime.Boot + 216697020.milliseconds,
down = true,
- position = createPxPosition(221.14285278320312.px, 517.7142944335938.px)
+ position = createPxPosition(221.14285278320312f, 517.7142944335938f)
),
PointerInputData(
uptime = Uptime.Boot + 216697028.milliseconds,
down = true,
- position = createPxPosition(222.2857208251953.px, 511.71429443359375.px)
+ position = createPxPosition(222.2857208251953f, 511.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216697036.milliseconds,
down = true,
- position = createPxPosition(224.px, 504.28570556640625.px)
+ position = createPxPosition(224f, 504.28570556640625f)
),
PointerInputData(
uptime = Uptime.Boot + 216697044.milliseconds,
down = true,
- position = createPxPosition(227.14285278320312.px, 490.5714416503906.px)
+ position = createPxPosition(227.14285278320312f, 490.5714416503906f)
),
PointerInputData(
uptime = Uptime.Boot + 216697052.milliseconds,
down = true,
- position = createPxPosition(229.42857360839844.px, 474.px)
+ position = createPxPosition(229.42857360839844f, 474f)
),
PointerInputData(
uptime = Uptime.Boot + 216697059.milliseconds,
down = true,
- position = createPxPosition(231.42857360839844.px, 454.5714416503906.px)
+ position = createPxPosition(231.42857360839844f, 454.5714416503906f)
),
PointerInputData(
uptime = Uptime.Boot + 216697067.milliseconds,
down = true,
- position = createPxPosition(233.7142791748047.px, 431.1428527832031.px)
+ position = createPxPosition(233.7142791748047f, 431.1428527832031f)
),
PointerInputData(
uptime = Uptime.Boot + 216697082.milliseconds,
down = false,
- position = createPxPosition(233.7142791748047.px, 431.1428527832031.px)
+ position = createPxPosition(233.7142791748047f, 431.1428527832031f)
),
PointerInputData(
uptime = Uptime.Boot + 216697435.milliseconds,
down = true,
- position = createPxPosition(257.1428527832031.px, 285.1428527832031.px)
+ position = createPxPosition(257.1428527832031f, 285.1428527832031f)
),
PointerInputData(
uptime = Uptime.Boot + 216697465.milliseconds,
down = true,
- position = createPxPosition(251.7142791748047.px, 296.8571472167969.px)
+ position = createPxPosition(251.7142791748047f, 296.8571472167969f)
),
PointerInputData(
uptime = Uptime.Boot + 216697473.milliseconds,
down = true,
- position = createPxPosition(248.2857208251953.px, 304.px)
+ position = createPxPosition(248.2857208251953f, 304f)
),
PointerInputData(
uptime = Uptime.Boot + 216697481.milliseconds,
down = true,
- position = createPxPosition(244.57142639160156.px, 314.8571472167969.px)
+ position = createPxPosition(244.57142639160156f, 314.8571472167969f)
),
PointerInputData(
uptime = Uptime.Boot + 216697489.milliseconds,
down = true,
- position = createPxPosition(240.2857208251953.px, 329.1428527832031.px)
+ position = createPxPosition(240.2857208251953f, 329.1428527832031f)
),
PointerInputData(
uptime = Uptime.Boot + 216697497.milliseconds,
down = true,
- position = createPxPosition(236.85714721679688.px, 345.1428527832031.px)
+ position = createPxPosition(236.85714721679688f, 345.1428527832031f)
),
PointerInputData(
uptime = Uptime.Boot + 216697505.milliseconds,
down = true,
- position = createPxPosition(233.7142791748047.px, 361.4285583496094.px)
+ position = createPxPosition(233.7142791748047f, 361.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216697512.milliseconds,
down = true,
- position = createPxPosition(231.14285278320312.px, 378.28570556640625.px)
+ position = createPxPosition(231.14285278320312f, 378.28570556640625f)
),
PointerInputData(
uptime = Uptime.Boot + 216697520.milliseconds,
down = true,
- position = createPxPosition(229.42857360839844.px, 395.4285583496094.px)
+ position = createPxPosition(229.42857360839844f, 395.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216697528.milliseconds,
down = true,
- position = createPxPosition(229.42857360839844.px, 412.8571472167969.px)
+ position = createPxPosition(229.42857360839844f, 412.8571472167969f)
),
PointerInputData(
uptime = Uptime.Boot + 216697535.milliseconds,
down = true,
- position = createPxPosition(230.85714721679688.px, 430.8571472167969.px)
+ position = createPxPosition(230.85714721679688f, 430.8571472167969f)
),
PointerInputData(
uptime = Uptime.Boot + 216697543.milliseconds,
down = true,
- position = createPxPosition(233.42857360839844.px, 449.71429443359375.px)
+ position = createPxPosition(233.42857360839844f, 449.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216697558.milliseconds,
down = false,
- position = createPxPosition(233.42857360839844.px, 449.71429443359375.px)
+ position = createPxPosition(233.42857360839844f, 449.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216697749.milliseconds,
down = true,
- position = createPxPosition(246.px, 311.4285583496094.px)
+ position = createPxPosition(246f, 311.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216697780.milliseconds,
down = true,
- position = createPxPosition(244.57142639160156.px, 318.28570556640625.px)
+ position = createPxPosition(244.57142639160156f, 318.28570556640625f)
),
PointerInputData(
uptime = Uptime.Boot + 216697787.milliseconds,
down = true,
- position = createPxPosition(243.14285278320312.px, 325.4285583496094.px)
+ position = createPxPosition(243.14285278320312f, 325.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216697795.milliseconds,
down = true,
- position = createPxPosition(241.42857360839844.px, 336.px)
+ position = createPxPosition(241.42857360839844f, 336f)
),
PointerInputData(
uptime = Uptime.Boot + 216697803.milliseconds,
down = true,
- position = createPxPosition(239.7142791748047.px, 351.1428527832031.px)
+ position = createPxPosition(239.7142791748047f, 351.1428527832031f)
),
PointerInputData(
uptime = Uptime.Boot + 216697811.milliseconds,
down = true,
- position = createPxPosition(238.2857208251953.px, 368.5714416503906.px)
+ position = createPxPosition(238.2857208251953f, 368.5714416503906f)
),
PointerInputData(
uptime = Uptime.Boot + 216697819.milliseconds,
down = true,
- position = createPxPosition(238.px, 389.4285583496094.px)
+ position = createPxPosition(238f, 389.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216697826.milliseconds,
down = true,
- position = createPxPosition(239.14285278320312.px, 412.px)
+ position = createPxPosition(239.14285278320312f, 412f)
),
PointerInputData(
uptime = Uptime.Boot + 216697834.milliseconds,
down = true,
- position = createPxPosition(242.2857208251953.px, 438.px)
+ position = createPxPosition(242.2857208251953f, 438f)
),
PointerInputData(
uptime = Uptime.Boot + 216697842.milliseconds,
down = true,
- position = createPxPosition(247.42857360839844.px, 466.8571472167969.px)
+ position = createPxPosition(247.42857360839844f, 466.8571472167969f)
),
PointerInputData(
uptime = Uptime.Boot + 216697849.milliseconds,
down = true,
- position = createPxPosition(254.2857208251953.px, 497.71429443359375.px)
+ position = createPxPosition(254.2857208251953f, 497.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216697864.milliseconds,
down = false,
- position = createPxPosition(254.2857208251953.px, 497.71429443359375.px)
+ position = createPxPosition(254.2857208251953f, 497.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216698321.milliseconds,
down = true,
- position = createPxPosition(250.px, 306.px)
+ position = createPxPosition(250f, 306f)
),
PointerInputData(
uptime = Uptime.Boot + 216698328.milliseconds,
down = true,
- position = createPxPosition(250.px, 306.px)
+ position = createPxPosition(250f, 306f)
),
PointerInputData(
uptime = Uptime.Boot + 216698344.milliseconds,
down = true,
- position = createPxPosition(249.14285278320312.px, 314.px)
+ position = createPxPosition(249.14285278320312f, 314f)
),
PointerInputData(
uptime = Uptime.Boot + 216698351.milliseconds,
down = true,
- position = createPxPosition(247.42857360839844.px, 319.4285583496094.px)
+ position = createPxPosition(247.42857360839844f, 319.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216698359.milliseconds,
down = true,
- position = createPxPosition(245.14285278320312.px, 326.8571472167969.px)
+ position = createPxPosition(245.14285278320312f, 326.8571472167969f)
),
PointerInputData(
uptime = Uptime.Boot + 216698366.milliseconds,
down = true,
- position = createPxPosition(241.7142791748047.px, 339.4285583496094.px)
+ position = createPxPosition(241.7142791748047f, 339.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216698374.milliseconds,
down = true,
- position = createPxPosition(238.57142639160156.px, 355.71429443359375.px)
+ position = createPxPosition(238.57142639160156f, 355.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + 216698382.milliseconds,
down = true,
- position = createPxPosition(236.2857208251953.px, 374.28570556640625.px)
+ position = createPxPosition(236.2857208251953f, 374.28570556640625f)
),
PointerInputData(
uptime = Uptime.Boot + 216698390.milliseconds,
down = true,
- position = createPxPosition(235.14285278320312.px, 396.5714416503906.px)
+ position = createPxPosition(235.14285278320312f, 396.5714416503906f)
),
PointerInputData(
uptime = Uptime.Boot + 216698398.milliseconds,
down = true,
- position = createPxPosition(236.57142639160156.px, 421.4285583496094.px)
+ position = createPxPosition(236.57142639160156f, 421.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216698406.milliseconds,
down = true,
- position = createPxPosition(241.14285278320312.px, 451.4285583496094.px)
+ position = createPxPosition(241.14285278320312f, 451.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216698421.milliseconds,
down = false,
- position = createPxPosition(241.14285278320312.px, 451.4285583496094.px)
+ position = createPxPosition(241.14285278320312f, 451.4285583496094f)
)
)
@@ -1660,32 +1658,32 @@
PointerInputData(
uptime = Uptime.Boot + 216698321.milliseconds,
down = true,
- position = createPxPosition(250.px, 306.px)
+ position = createPxPosition(250f, 306f)
),
PointerInputData(
uptime = Uptime.Boot + 216698328.milliseconds,
down = true,
- position = createPxPosition(250.px, 306.px)
+ position = createPxPosition(250f, 306f)
),
PointerInputData(
uptime = Uptime.Boot + 216698344.milliseconds,
down = true,
- position = createPxPosition(249.14285278320312.px, 314.px)
+ position = createPxPosition(249.14285278320312f, 314f)
),
PointerInputData(
uptime = Uptime.Boot + 216698351.milliseconds,
down = true,
- position = createPxPosition(247.42857360839844.px, 319.4285583496094.px)
+ position = createPxPosition(247.42857360839844f, 319.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + 216698359.milliseconds,
down = true,
- position = createPxPosition(245.14285278320312.px, 326.8571472167969.px)
+ position = createPxPosition(245.14285278320312f, 326.8571472167969f)
),
PointerInputData(
uptime = Uptime.Boot + 216698366.milliseconds,
down = true,
- position = createPxPosition(241.7142791748047.px, 339.4285583496094.px)
+ position = createPxPosition(241.7142791748047f, 339.4285583496094f)
),
// The pointer "stops" here because we've introduced a 40+ms gap
@@ -1695,31 +1693,31 @@
PointerInputData(
uptime = Uptime.Boot + (216698374 + 40).milliseconds,
down = true,
- position = createPxPosition(238.57142639160156.px, 355.71429443359375.px)
+ position = createPxPosition(238.57142639160156f, 355.71429443359375f)
),
PointerInputData(
uptime = Uptime.Boot + (216698382 + 40).milliseconds,
down = true,
- position = createPxPosition(236.2857208251953.px, 374.28570556640625.px)
+ position = createPxPosition(236.2857208251953f, 374.28570556640625f)
),
PointerInputData(
uptime = Uptime.Boot + (216698390 + 40).milliseconds,
down = true,
- position = createPxPosition(235.14285278320312.px, 396.5714416503906.px)
+ position = createPxPosition(235.14285278320312f, 396.5714416503906f)
),
PointerInputData(
uptime = Uptime.Boot + (216698398 + 40).milliseconds,
down = true,
- position = createPxPosition(236.57142639160156.px, 421.4285583496094.px)
+ position = createPxPosition(236.57142639160156f, 421.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + (216698406 + 40).milliseconds,
down = true,
- position = createPxPosition(241.14285278320312.px, 451.4285583496094.px)
+ position = createPxPosition(241.14285278320312f, 451.4285583496094f)
),
PointerInputData(
uptime = Uptime.Boot + (216698421 + 40).milliseconds,
down = false,
- position = createPxPosition(241.14285278320312.px, 451.4285583496094.px)
+ position = createPxPosition(241.14285278320312f, 451.4285583496094f)
)
)
\ No newline at end of file
diff --git a/ui/ui-core/src/test/java/androidx/ui/core/pointerinput/HitPathTrackerTest.kt b/ui/ui-core/src/test/java/androidx/ui/core/pointerinput/HitPathTrackerTest.kt
index 0c7d813..e2b89f1 100644
--- a/ui/ui-core/src/test/java/androidx/ui/core/pointerinput/HitPathTrackerTest.kt
+++ b/ui/ui-core/src/test/java/androidx/ui/core/pointerinput/HitPathTrackerTest.kt
@@ -35,7 +35,6 @@
import androidx.ui.unit.PxBounds
import androidx.ui.unit.PxPosition
import androidx.ui.unit.milliseconds
-import androidx.ui.unit.px
import com.google.common.truth.Truth.assertThat
import com.nhaarman.mockitokotlin2.any
import com.nhaarman.mockitokotlin2.eq
@@ -49,6 +48,7 @@
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
+import kotlin.math.roundToInt
@SmallTest
@RunWith(JUnit4::class)
@@ -569,7 +569,7 @@
PointerEventPass.PreUp -> 64f
else -> 0f
}
- it.consumePositionChange(0.px, yConsume.px)
+ it.consumePositionChange(0f, yConsume)
}
})
)
@@ -583,7 +583,7 @@
PointerEventPass.PreUp -> 32f
else -> 0f
}
- it.consumePositionChange(0.px, yConsume.px)
+ it.consumePositionChange(0f, yConsume)
}
})
)
@@ -597,7 +597,7 @@
PointerEventPass.PreUp -> 16f
else -> 0f
}
- it.consumePositionChange(0.px, yConsume.px)
+ it.consumePositionChange(0f, yConsume)
}
})
)
@@ -610,27 +610,27 @@
eq(listOf(change)), eq(PointerEventPass.InitialDown), any()
)
verify(pif2).onPointerInput(
- eq(listOf(change.consumePositionChange(0.px, 2.px))),
+ eq(listOf(change.consumePositionChange(0f, 2f))),
eq(PointerEventPass.InitialDown),
any()
)
verify(pif3).onPointerInput(
- eq(listOf(change.consumePositionChange(0.px, 6.px))), // 2 + 4
+ eq(listOf(change.consumePositionChange(0f, 6f))), // 2 + 4
eq(PointerEventPass.InitialDown),
any()
)
verify(pif3).onPointerInput(
- eq(listOf(change.consumePositionChange(0.px, 14.px))), // 2 + 4 + 8
+ eq(listOf(change.consumePositionChange(0f, 14f))), // 2 + 4 + 8
eq(PointerEventPass.PreUp),
any()
)
verify(pif2).onPointerInput(
- eq(listOf(change.consumePositionChange(0.px, 30.px))), // 2 + 4 + 8 + 16
+ eq(listOf(change.consumePositionChange(0f, 30f))), // 2 + 4 + 8 + 16
eq(PointerEventPass.PreUp),
any()
)
verify(pif1).onPointerInput(
- eq(listOf(change.consumePositionChange(0.px, 62.px))), // 2 + 4 + 8 + 16 + 32
+ eq(listOf(change.consumePositionChange(0f, 62f))), // 2 + 4 + 8 + 16 + 32
eq(PointerEventPass.PreUp),
any()
)
@@ -638,8 +638,8 @@
.isEqualTo(
listOf(
change.consumePositionChange(
- 0.px,
- 126.px
+ 0f,
+ 126f
)
)
) // 2 + 4 + 8 + 16 + 32 + 64
@@ -657,7 +657,7 @@
PointerEventPass.PreUp -> 12f
else -> 0f
}
- it.consumePositionChange(0.px, yConsume.px)
+ it.consumePositionChange(0f, yConsume)
}
})
)
@@ -671,7 +671,7 @@
PointerEventPass.PreUp -> 6f
else -> 0f
}
- it.consumePositionChange(0.px, yConsume.px)
+ it.consumePositionChange(0f, yConsume)
}
})
)
@@ -685,7 +685,7 @@
PointerEventPass.PreUp -> -12f
else -> 0f
}
- it.consumePositionChange(0.px, yConsume.px)
+ it.consumePositionChange(0f, yConsume)
}
})
)
@@ -699,7 +699,7 @@
PointerEventPass.PreUp -> -6f
else -> 0f
}
- it.consumePositionChange(0.px, yConsume.px)
+ it.consumePositionChange(0f, yConsume)
}
})
)
@@ -718,17 +718,17 @@
any()
)
verify(pif2).onPointerInput(
- eq(listOf(event1.consumePositionChange(0.px, 2.px))),
+ eq(listOf(event1.consumePositionChange(0f, 2f))),
eq(PointerEventPass.InitialDown),
any()
)
verify(pif2).onPointerInput(
- eq(listOf(event1.consumePositionChange(0.px, 5.px))),
+ eq(listOf(event1.consumePositionChange(0f, 5f))),
eq(PointerEventPass.PreUp),
any()
)
verify(pif1).onPointerInput(
- eq(listOf(event1.consumePositionChange(0.px, 11.px))),
+ eq(listOf(event1.consumePositionChange(0f, 11f))),
eq(PointerEventPass.PreUp),
any()
)
@@ -739,24 +739,24 @@
any()
)
verify(pif4).onPointerInput(
- eq(listOf(event2.consumePositionChange(0.px, (-2).px))),
+ eq(listOf(event2.consumePositionChange(0f, -2f))),
eq(PointerEventPass.InitialDown),
any()
)
verify(pif4).onPointerInput(
- eq(listOf(event2.consumePositionChange(0.px, (-5).px))),
+ eq(listOf(event2.consumePositionChange(0f, -5f))),
eq(PointerEventPass.PreUp),
any()
)
verify(pif3).onPointerInput(
- eq(listOf(event2.consumePositionChange(0.px, (-11).px))),
+ eq(listOf(event2.consumePositionChange(0f, -11f))),
eq(PointerEventPass.PreUp),
any()
)
assertThat(result).hasSize(2)
- assertThat(result).contains(event1.consumePositionChange(0.px, 23.px))
- assertThat(result).contains(event2.consumePositionChange(0.px, (-23).px))
+ assertThat(result).contains(event1.consumePositionChange(0f, 23f))
+ assertThat(result).contains(event2.consumePositionChange(0f, -23f))
}
@Test
@@ -772,8 +772,8 @@
else -> Int.MAX_VALUE
}
it.consumePositionChange(
- 0.px,
- (it.positionChange().y.value.toInt() / yConsume).px
+ 0f,
+ (it.positionChange().y.roundToInt() / yConsume).toFloat()
)
}
})
@@ -789,8 +789,8 @@
else -> Int.MAX_VALUE
}
it.consumePositionChange(
- 0.px,
- (it.positionChange().y.value.toInt() / yConsume).px
+ 0f,
+ (it.positionChange().y.roundToInt() / yConsume).toFloat()
)
}
})
@@ -806,8 +806,8 @@
else -> Int.MAX_VALUE
}
it.consumePositionChange(
- 0.px,
- (it.positionChange().y.value.toInt() / yConsume).px
+ 0f,
+ (it.positionChange().y.roundToInt() / yConsume).toFloat()
)
}
})
@@ -827,30 +827,30 @@
any()
)
verify(child1).onPointerInput(
- eq(listOf(event1.consumePositionChange(0.px, 500.px))),
+ eq(listOf(event1.consumePositionChange(0f, 500f))),
eq(PointerEventPass.InitialDown),
any()
)
verify(child2).onPointerInput(
- eq(listOf(event2.consumePositionChange(0.px, (-500).px))),
+ eq(listOf(event2.consumePositionChange(0f, -500f))),
eq(PointerEventPass.InitialDown),
any()
)
verify(child1).onPointerInput(
- eq(listOf(event1.consumePositionChange(0.px, 600.px))),
+ eq(listOf(event1.consumePositionChange(0f, 600f))),
eq(PointerEventPass.PreUp),
any()
)
verify(child2).onPointerInput(
- eq(listOf(event2.consumePositionChange(0.px, (-545).px))),
+ eq(listOf(event2.consumePositionChange(0f, -545f))),
eq(PointerEventPass.PreUp),
any()
)
verify(parent).onPointerInput(
eq(
listOf(
- event1.consumePositionChange(0.px, 657.px),
- event2.consumePositionChange(0.px, (-580).px)
+ event1.consumePositionChange(0f, 657f),
+ event2.consumePositionChange(0f, -580f)
)
),
eq(PointerEventPass.PreUp),
@@ -858,8 +858,8 @@
)
assertThat(result).hasSize(2)
- assertThat(result).contains(event1.consumePositionChange(0.px, 771.px))
- assertThat(result).contains(event2.consumePositionChange(0.px, (-720).px))
+ assertThat(result).contains(event1.consumePositionChange(0f, 771f))
+ assertThat(result).contains(event2.consumePositionChange(0f, -720f))
}
@Test
@@ -875,8 +875,8 @@
else -> Int.MAX_VALUE
}
it.consumePositionChange(
- 0.px,
- (it.positionChange().y.value.toInt() / yConsume).px
+ 0f,
+ (it.positionChange().y.roundToInt() / yConsume).toFloat()
)
}
})
@@ -892,8 +892,8 @@
else -> Int.MAX_VALUE
}
it.consumePositionChange(
- 0.px,
- (it.positionChange().y.value.toInt() / yConsume).px
+ 0f,
+ (it.positionChange().y.roundToInt() / yConsume).toFloat()
)
}
})
@@ -915,8 +915,8 @@
verify(child2).onPointerInput(
eq(
listOf(
- event1.consumePositionChange(0.px, 500.px),
- event2.consumePositionChange(0.px, (-500).px)
+ event1.consumePositionChange(0f, 500f),
+ event2.consumePositionChange(0f, -500f)
)
),
eq(PointerEventPass.InitialDown),
@@ -926,8 +926,8 @@
verify(child2).onPointerInput(
eq(
listOf(
- event1.consumePositionChange(0.px, 600.px),
- event2.consumePositionChange(0.px, (-600).px)
+ event1.consumePositionChange(0f, 600f),
+ event2.consumePositionChange(0f, -600f)
)
),
eq(PointerEventPass.PreUp),
@@ -936,8 +936,8 @@
verify(child1).onPointerInput(
eq(
listOf(
- event1.consumePositionChange(0.px, 657.px),
- event2.consumePositionChange(0.px, (-657).px)
+ event1.consumePositionChange(0f, 657f),
+ event2.consumePositionChange(0f, -657f)
)
),
eq(PointerEventPass.PreUp),
@@ -945,8 +945,8 @@
)
assertThat(result).hasSize(2)
- assertThat(result).contains(event1.consumePositionChange(0.px, 771.px))
- assertThat(result).contains(event2.consumePositionChange(0.px, (-771).px))
+ assertThat(result).contains(event1.consumePositionChange(0f, 771f))
+ assertThat(result).contains(event2.consumePositionChange(0f, -771f))
}
@Test
diff --git a/ui/ui-core/src/test/java/androidx/ui/core/pointerinput/PointerInputEventProcessorTest.kt b/ui/ui-core/src/test/java/androidx/ui/core/pointerinput/PointerInputEventProcessorTest.kt
index 949957b..dfbc831 100644
--- a/ui/ui-core/src/test/java/androidx/ui/core/pointerinput/PointerInputEventProcessorTest.kt
+++ b/ui/ui-core/src/test/java/androidx/ui/core/pointerinput/PointerInputEventProcessorTest.kt
@@ -33,7 +33,6 @@
import androidx.ui.unit.Uptime
import androidx.ui.unit.ipx
import androidx.ui.unit.milliseconds
-import androidx.ui.unit.px
import com.google.common.truth.Truth.assertThat
import com.nhaarman.mockitokotlin2.any
import com.nhaarman.mockitokotlin2.eq
@@ -104,8 +103,8 @@
root.insertAt(0, layoutNode)
- val offset = PxPosition(100.px, 200.px)
- val offset2 = PxPosition(300.px, 400.px)
+ val offset = PxPosition(100f, 200f)
+ val offset2 = PxPosition(300f, 400f)
val events = arrayOf(
PointerInputEvent(8712, Uptime.Boot + 3.milliseconds, offset, true),
@@ -165,7 +164,7 @@
// Arrange
- val childOffset = PxPosition(100.px, 200.px)
+ val childOffset = PxPosition(100f, 200f)
val pointerInputFilter: PointerInputFilter = spy()
val layoutNode = LayoutNode(
100, 200, 301, 401,
@@ -177,10 +176,10 @@
root.insertAt(0, layoutNode)
val offsets = arrayOf(
- PxPosition(100.px, 200.px),
- PxPosition(300.px, 200.px),
- PxPosition(100.px, 400.px),
- PxPosition(300.px, 400.px)
+ PxPosition(100f, 200f),
+ PxPosition(300f, 200f),
+ PxPosition(100f, 400f),
+ PxPosition(300f, 400f)
)
val events = Array(4) { index ->
@@ -240,14 +239,14 @@
root.insertAt(0, layoutNode)
val offsets = arrayOf(
- PxPosition(99.px, 200.px),
- PxPosition(99.px, 400.px),
- PxPosition(100.px, 199.px),
- PxPosition(100.px, 401.px),
- PxPosition(300.px, 199.px),
- PxPosition(300.px, 401.px),
- PxPosition(301.px, 200.px),
- PxPosition(301.px, 400.px)
+ PxPosition(99f, 200f),
+ PxPosition(99f, 400f),
+ PxPosition(100f, 199f),
+ PxPosition(100f, 401f),
+ PxPosition(300f, 199f),
+ PxPosition(300f, 401f),
+ PxPosition(301f, 200f),
+ PxPosition(301f, 400f)
)
val events = Array(8) { index ->
@@ -315,9 +314,9 @@
root.insertAt(0, parentLayoutNode)
val offset = when (numberOfChildrenHit) {
- 3 -> PxPosition(250.px, 250.px)
- 2 -> PxPosition(150.px, 150.px)
- 1 -> PxPosition(50.px, 50.px)
+ 3 -> PxPosition(250f, 250f)
+ 2 -> PxPosition(150f, 150f)
+ 1 -> PxPosition(50f, 50f)
else -> throw IllegalStateException()
}
@@ -394,21 +393,21 @@
id = PointerId(0),
current = PointerInputData(
Uptime.Boot + 5.milliseconds,
- PxPosition(100.px, 0.px),
+ PxPosition(100f, 0f),
true
),
- previous = PointerInputData(Uptime.Boot + 3.milliseconds, PxPosition(0.px, 0.px), true),
- consumed = ConsumedData(positionChange = PxPosition(0.px, 0.px))
+ previous = PointerInputData(Uptime.Boot + 3.milliseconds, PxPosition(0f, 0f), true),
+ consumed = ConsumedData(positionChange = PxPosition(0f, 0f))
)
val output = PointerInputChange(
id = PointerId(0),
current = PointerInputData(
Uptime.Boot + 5.milliseconds,
- PxPosition(100.px, 0.px),
+ PxPosition(100f, 0f),
true
),
- previous = PointerInputData(Uptime.Boot + 3.milliseconds, PxPosition(0.px, 0.px), true),
- consumed = ConsumedData(positionChange = PxPosition(13.px, 0.px))
+ previous = PointerInputData(Uptime.Boot + 3.milliseconds, PxPosition(0f, 0f), true),
+ consumed = ConsumedData(positionChange = PxPosition(13f, 0f))
)
val pointerInputFilter: PointerInputFilter =
@@ -436,13 +435,13 @@
val down = PointerInputEvent(
0,
Uptime.Boot + 3.milliseconds,
- PxPosition(0.px, 0.px),
+ PxPosition(0f, 0f),
true
)
val move = PointerInputEvent(
0,
Uptime.Boot + 5.milliseconds,
- PxPosition(100.px, 0.px),
+ PxPosition(100f, 0f),
true
)
@@ -519,14 +518,14 @@
val middlePointerInputFilter: PointerInputFilter = spy()
val parentPointerInputFilter: PointerInputFilter = spy()
- val childOffset = PxPosition(cX1.px, cY1.px)
+ val childOffset = PxPosition(cX1.toFloat(), cY1.toFloat())
val childLayoutNode = LayoutNode(
cX1, cY1, cX2, cY2,
PointerInputModifierImpl(
childPointerInputFilter
)
)
- val middleOffset = PxPosition(mX1.px, mY1.px)
+ val middleOffset = PxPosition(mX1.toFloat(), mY1.toFloat())
val middleLayoutNode: LayoutNode = LayoutNode(
mX1, mY1, mX2, mY2,
PointerInputModifierImpl(
@@ -550,7 +549,7 @@
val additionalOffset = IntPxPosition(aOX.ipx, aOY.ipx)
- val offset = PxPosition(pointerX.px, pointerY.px)
+ val offset = PxPosition(pointerX.toFloat(), pointerY.toFloat())
val down = PointerInputEvent(0, Uptime.Boot + 7.milliseconds, offset, true)
@@ -670,8 +669,8 @@
insertAt(0, childLayoutNode2)
}
- val offset1 = PxPosition(25.px, 25.px)
- val offset2 = PxPosition(75.px, 75.px)
+ val offset1 = PxPosition(25f, 25f)
+ val offset2 = PxPosition(75f, 75f)
val down = PointerInputEvent(
Uptime.Boot + 5.milliseconds,
@@ -691,7 +690,7 @@
id = PointerId(1),
current = PointerInputData(
Uptime.Boot + 5.milliseconds,
- offset2 - PxPosition(50.px, 50.px),
+ offset2 - PxPosition(50f, 50f),
true
),
previous = PointerInputData(null, null, false),
@@ -781,9 +780,9 @@
insertAt(2, childLayoutNode3)
}
- val offset1 = PxPosition(25.px, 25.px)
- val offset2 = PxPosition(75.px, 75.px)
- val offset3 = PxPosition(125.px, 125.px)
+ val offset1 = PxPosition(25f, 25f)
+ val offset2 = PxPosition(75f, 75f)
+ val offset3 = PxPosition(125f, 125f)
val down = PointerInputEvent(
Uptime.Boot + 5.milliseconds,
@@ -804,7 +803,7 @@
id = PointerId(1),
current = PointerInputData(
Uptime.Boot + 5.milliseconds,
- offset2 - PxPosition(50.px, 50.px),
+ offset2 - PxPosition(50f, 50f),
true
),
previous = PointerInputData(null, null, false),
@@ -814,7 +813,7 @@
id = PointerId(2),
current = PointerInputData(
Uptime.Boot + 5.milliseconds,
- offset3 - PxPosition(100.px, 100.px),
+ offset3 - PxPosition(100f, 100f),
true
),
previous = PointerInputData(null, null, false),
@@ -903,9 +902,9 @@
insertAt(1, childLayoutNode2)
}
- val offset1 = PxPosition(50.px, 25.px)
- val offset2 = PxPosition(50.px, 75.px)
- val offset3 = PxPosition(50.px, 125.px)
+ val offset1 = PxPosition(50f, 25f)
+ val offset2 = PxPosition(50f, 75f)
+ val offset3 = PxPosition(50f, 125f)
val down = PointerInputEvent(
Uptime.Boot + 7.milliseconds,
@@ -926,7 +925,7 @@
id = PointerId(1),
current = PointerInputData(
Uptime.Boot + 7.milliseconds,
- offset2 - PxPosition(25.px, 50.px),
+ offset2 - PxPosition(25f, 50f),
true
),
previous = PointerInputData(null, null, false),
@@ -1008,9 +1007,9 @@
insertAt(1, childLayoutNode2)
}
- val offset1 = PxPosition(25.px, 50.px)
- val offset2 = PxPosition(75.px, 50.px)
- val offset3 = PxPosition(125.px, 50.px)
+ val offset1 = PxPosition(25f, 50f)
+ val offset2 = PxPosition(75f, 50f)
+ val offset3 = PxPosition(125f, 50f)
val down = PointerInputEvent(
Uptime.Boot + 11.milliseconds,
@@ -1031,7 +1030,7 @@
id = PointerId(1),
current = PointerInputData(
Uptime.Boot + 11.milliseconds,
- offset2 - PxPosition(50.px, 25.px),
+ offset2 - PxPosition(50f, 25f),
true
),
previous = PointerInputData(null, null, false),
@@ -1141,21 +1140,21 @@
}
val offsetsThatHit =
listOf(
- PxPosition(1.px, 1.px),
- PxPosition(3.px, 1.px),
- PxPosition(1.px, 3.px),
- PxPosition(3.px, 3.px)
+ PxPosition(1f, 1f),
+ PxPosition(3f, 1f),
+ PxPosition(1f, 3f),
+ PxPosition(3f, 3f)
)
val offsetsThatMiss =
listOf(
- PxPosition(1.px, 0.px),
- PxPosition(3.px, 0.px),
- PxPosition(0.px, 1.px),
- PxPosition(4.px, 1.px),
- PxPosition(0.px, 3.px),
- PxPosition(4.px, 3.px),
- PxPosition(1.px, 4.px),
- PxPosition(3.px, 4.px)
+ PxPosition(1f, 0f),
+ PxPosition(3f, 0f),
+ PxPosition(0f, 1f),
+ PxPosition(4f, 1f),
+ PxPosition(0f, 3f),
+ PxPosition(4f, 3f),
+ PxPosition(1f, 4f),
+ PxPosition(3f, 4f)
)
val allOffsets = offsetsThatHit + offsetsThatMiss
val pointerInputEvent =
@@ -1179,8 +1178,8 @@
current = PointerInputData(
Uptime.Boot + 11.milliseconds,
PxPosition(
- if (offsetsThatHit[it].x == 1.px) 1.px else 0.px,
- if (offsetsThatHit[it].y == 1.px) 1.px else 0.px
+ if (offsetsThatHit[it].x == 1f) 1f else 0f,
+ if (offsetsThatHit[it].y == 1f) 1f else 0f
),
true
),
@@ -1268,15 +1267,15 @@
}
val offsetsThatHit =
listOf(
- PxPosition(2.px, 2.px),
- PxPosition(2.px, 1.px),
- PxPosition(1.px, 2.px)
+ PxPosition(2f, 2f),
+ PxPosition(2f, 1f),
+ PxPosition(1f, 2f)
)
val offsetsThatMiss =
listOf(
- PxPosition(0.px, 0.px),
- PxPosition(0.px, 1.px),
- PxPosition(1.px, 0.px)
+ PxPosition(0f, 0f),
+ PxPosition(0f, 1f),
+ PxPosition(1f, 0f)
)
val allOffsets = offsetsThatHit + offsetsThatMiss
val pointerInputEvent =
@@ -1300,7 +1299,7 @@
id = PointerId(it.toLong()),
current = PointerInputData(
Uptime.Boot + 11.milliseconds,
- offsetsThatHit[it] - PxPosition(1.px, 1.px),
+ offsetsThatHit[it] - PxPosition(1f, 1f),
true
),
previous = PointerInputData(null, null, false),
@@ -1342,7 +1341,7 @@
insertAt(0, layoutNode)
}
- val offset1 = PxPosition(50.px, 75.px)
+ val offset1 = PxPosition(50f, 75f)
val down = PointerInputEvent(
Uptime.Boot + 7.milliseconds,
@@ -1355,7 +1354,7 @@
id = PointerId(0),
current = PointerInputData(
Uptime.Boot + 7.milliseconds,
- offset1 - PxPosition(25.px, 50.px),
+ offset1 - PxPosition(25f, 50f),
true
),
previous = PointerInputData(null, null, false),
@@ -1422,7 +1421,7 @@
insertAt(0, layoutNode4)
}
- val offset1 = PxPosition(499.px, 499.px)
+ val offset1 = PxPosition(499f, 499f)
val downEvent = PointerInputEvent(
Uptime.Boot + 7.milliseconds,
@@ -1435,7 +1434,7 @@
id = PointerId(0),
current = PointerInputData(
Uptime.Boot + 7.milliseconds,
- offset1 - PxPosition(1.px + 2.px + 3.px + 4.px, 5.px + 6.px + 7.px + 8.px),
+ offset1 - PxPosition(1f + 2f + 3f + 4f, 5f + 6f + 7f + 8f),
true
),
previous = PointerInputData(null, null, false),
@@ -1501,7 +1500,7 @@
insertAt(0, layoutNode5)
}
- val offset1 = PxPosition(499.px, 499.px)
+ val offset1 = PxPosition(499f, 499f)
val downEvent = PointerInputEvent(
Uptime.Boot + 3.milliseconds,
@@ -1515,8 +1514,8 @@
current = PointerInputData(
Uptime.Boot + 3.milliseconds,
offset1 - PxPosition(
- 1.px + 2.px + 3.px + 4.px + 5.px,
- 6.px + 7.px + 8.px + 9.px + 10.px
+ 1f + 2f + 3f + 4f + 5f,
+ 6f + 7f + 8f + 9f + 10f
),
true
),
@@ -1528,7 +1527,7 @@
id = PointerId(0),
current = PointerInputData(
Uptime.Boot + 3.milliseconds,
- offset1 - PxPosition(3.px + 4.px + 5.px, 8.px + 9.px + 10.px),
+ offset1 - PxPosition(3f + 4f + 5f, 8f + 9f + 10f),
true
),
previous = PointerInputData(null, null, false),
@@ -1606,7 +1605,7 @@
}
val down = PointerInputEvent(
- 1, Uptime.Boot + 0.milliseconds, PxPosition(50.px, 50.px), true
+ 1, Uptime.Boot + 0.milliseconds, PxPosition(50f, 50f), true
)
// Act
@@ -1633,7 +1632,7 @@
}
val down = PointerInputEvent(
- 1, Uptime.Boot + 0.milliseconds, PxPosition(0.px, 0.px), true
+ 1, Uptime.Boot + 0.milliseconds, PxPosition(0f, 0f), true
)
// Act
@@ -1668,7 +1667,7 @@
PointerInputEvent(
7,
Uptime.Boot + 5.milliseconds,
- PxPosition(250.px, 250.px),
+ PxPosition(250f, 250f),
true
)
@@ -1677,7 +1676,7 @@
id = PointerId(7),
current = PointerInputData(
Uptime.Boot + 5.milliseconds,
- PxPosition(250.px, 250.px),
+ PxPosition(250f, 250f),
true
),
previous = PointerInputData(null, null, false),
@@ -1728,7 +1727,7 @@
PointerInputEvent(
7,
Uptime.Boot + 5.milliseconds,
- PxPosition(200.px, 200.px),
+ PxPosition(200f, 200f),
true
)
@@ -1739,13 +1738,13 @@
PointerInputEventData(
7,
Uptime.Boot + 10.milliseconds,
- PxPosition(200.px, 200.px),
+ PxPosition(200f, 200f),
true
),
PointerInputEventData(
9,
Uptime.Boot + 10.milliseconds,
- PxPosition(300.px, 300.px),
+ PxPosition(300f, 300f),
true
)
)
@@ -1757,7 +1756,7 @@
id = PointerId(7),
current = PointerInputData(
Uptime.Boot + 5.milliseconds,
- PxPosition(200.px, 200.px),
+ PxPosition(200f, 200f),
true
),
previous = PointerInputData(null, null, false),
@@ -1771,12 +1770,12 @@
id = PointerId(7),
current = PointerInputData(
Uptime.Boot + 10.milliseconds,
- PxPosition(200.px, 200.px),
+ PxPosition(200f, 200f),
true
),
previous = PointerInputData(
Uptime.Boot + 5.milliseconds,
- PxPosition(200.px, 200.px),
+ PxPosition(200f, 200f),
true
),
consumed = ConsumedData()
@@ -1785,7 +1784,7 @@
id = PointerId(9),
current = PointerInputData(
Uptime.Boot + 10.milliseconds,
- PxPosition(300.px, 300.px),
+ PxPosition(300f, 300f),
true
),
previous = PointerInputData(null, null, false),
@@ -1849,7 +1848,7 @@
PointerInputEventData(
7,
Uptime.Boot + 5.milliseconds,
- PxPosition(100.px, 100.px),
+ PxPosition(100f, 100f),
true
)
@@ -1857,7 +1856,7 @@
PointerInputEventData(
9,
Uptime.Boot + 5.milliseconds,
- PxPosition(300.px, 300.px),
+ PxPosition(300f, 300f),
true
)
@@ -1871,7 +1870,7 @@
id = PointerId(7),
current = PointerInputData(
Uptime.Boot + 5.milliseconds,
- PxPosition(100.px, 100.px),
+ PxPosition(100f, 100f),
true
),
previous = PointerInputData(null, null, false),
@@ -1883,7 +1882,7 @@
id = PointerId(9),
current = PointerInputData(
Uptime.Boot + 5.milliseconds,
- PxPosition(100.px, 100.px),
+ PxPosition(100f, 100f),
true
),
previous = PointerInputData(null, null, false),
@@ -1943,7 +1942,7 @@
PointerInputEvent(
7,
Uptime.Boot + 5.milliseconds,
- PxPosition(200.px, 200.px),
+ PxPosition(200f, 200f),
true
)
@@ -1951,7 +1950,7 @@
PointerInputEvent(
7,
Uptime.Boot + 10.milliseconds,
- PxPosition(300.px, 300.px),
+ PxPosition(300f, 300f),
true
)
@@ -1960,7 +1959,7 @@
id = PointerId(7),
current = PointerInputData(
Uptime.Boot + 5.milliseconds,
- PxPosition(200.px, 200.px),
+ PxPosition(200f, 200f),
true
),
previous = PointerInputData(null, null, false),
@@ -1972,12 +1971,12 @@
id = PointerId(7),
current = PointerInputData(
Uptime.Boot + 10.milliseconds,
- PxPosition(300.px, 300.px),
+ PxPosition(300f, 300f),
true
),
previous = PointerInputData(
Uptime.Boot + 5.milliseconds,
- PxPosition(200.px, 200.px),
+ PxPosition(200f, 200f),
true
),
consumed = ConsumedData()
@@ -2032,7 +2031,7 @@
PointerInputEvent(
7,
Uptime.Boot + 5.milliseconds,
- PxPosition(200.px, 200.px),
+ PxPosition(200f, 200f),
true
)
@@ -2041,7 +2040,7 @@
id = PointerId(7),
current = PointerInputData(
Uptime.Boot + 5.milliseconds,
- PxPosition(200.px, 200.px),
+ PxPosition(200f, 200f),
true
),
previous = PointerInputData(null, null, false),
@@ -2091,7 +2090,7 @@
PointerInputEvent(
7,
Uptime.Boot + 5.milliseconds,
- PxPosition(200.px, 200.px),
+ PxPosition(200f, 200f),
true
)
@@ -2099,7 +2098,7 @@
PointerInputEvent(
7,
Uptime.Boot + 10.milliseconds,
- PxPosition(200.px, 200.px),
+ PxPosition(200f, 200f),
true
)
@@ -2108,7 +2107,7 @@
id = PointerId(7),
current = PointerInputData(
Uptime.Boot + 5.milliseconds,
- PxPosition(200.px, 200.px),
+ PxPosition(200f, 200f),
true
),
previous = PointerInputData(null, null, false),
@@ -2120,7 +2119,7 @@
id = PointerId(7),
current = PointerInputData(
Uptime.Boot + 10.milliseconds,
- PxPosition(200.px, 200.px),
+ PxPosition(200f, 200f),
true
),
previous = PointerInputData(null, null, false),
@@ -2180,7 +2179,7 @@
root.insertAt(0, parentLayoutNode)
- val offset = PxPosition(50.px, 50.px)
+ val offset = PxPosition(50f, 50f)
val down = PointerInputEvent(0, Uptime.Boot + 7.milliseconds, offset, true)
val up = PointerInputEvent(0, Uptime.Boot + 11.milliseconds, null, false)
@@ -2246,7 +2245,7 @@
root.insertAt(0, parentLayoutNode)
val down =
- PointerInputEvent(0, Uptime.Boot + 7.milliseconds, PxPosition(50.px, 50.px), true)
+ PointerInputEvent(0, Uptime.Boot + 7.milliseconds, PxPosition(50f, 50f), true)
val up = PointerInputEvent(0, Uptime.Boot + 11.milliseconds, null, false)
@@ -2286,7 +2285,7 @@
root.insertAt(0, parentLayoutNode)
- val offset = PxPosition(50.px, 50.px)
+ val offset = PxPosition(50f, 50f)
val down = PointerInputEvent(0, Uptime.Boot + 7.milliseconds, offset, true)
val up = PointerInputEvent(0, Uptime.Boot + 11.milliseconds, null, false)
@@ -2352,7 +2351,7 @@
root.insertAt(0, parentLayoutNode)
val down =
- PointerInputEvent(0, Uptime.Boot + 7.milliseconds, PxPosition(50.px, 50.px), true)
+ PointerInputEvent(0, Uptime.Boot + 7.milliseconds, PxPosition(50f, 50f), true)
val up = PointerInputEvent(0, Uptime.Boot + 11.milliseconds, null, false)
@@ -2370,7 +2369,7 @@
@Test
fun process_downNoPointerInputModifiers_nothingInteractedWithAndNoMovementConsumed() {
val pointerInputEvent =
- PointerInputEvent(0, Uptime.Boot + 7.milliseconds, PxPosition(0.px, 0.px), true)
+ PointerInputEvent(0, Uptime.Boot + 7.milliseconds, PxPosition(0f, 0f), true)
val result: ProcessResult = pointerInputEventProcessor.process(pointerInputEvent)
@@ -2402,10 +2401,10 @@
val offsets =
listOf(
- PxPosition((-1).px, 0.px),
- PxPosition(0.px, (-1).px),
- PxPosition(1.px, 0.px),
- PxPosition(0.px, 1.px)
+ PxPosition(-1f, 0f),
+ PxPosition(0f, -1f),
+ PxPosition(1f, 0f),
+ PxPosition(0f, 1f)
)
val pointerInputEvent =
PointerInputEvent(
@@ -2443,7 +2442,7 @@
)
root.apply { insertAt(0, layoutNode) }
val pointerInputEvent =
- PointerInputEvent(0, Uptime.Boot + 11.milliseconds, PxPosition(0.px, 0.px), true)
+ PointerInputEvent(0, Uptime.Boot + 11.milliseconds, PxPosition(0f, 0f), true)
// Act
@@ -2472,9 +2471,9 @@
)
)
root.apply { insertAt(0, layoutNode) }
- val down = PointerInputEvent(0, Uptime.Boot + 11.milliseconds, PxPosition(0.px, 0.px), true)
+ val down = PointerInputEvent(0, Uptime.Boot + 11.milliseconds, PxPosition(0f, 0f), true)
pointerInputEventProcessor.process(down)
- val move = PointerInputEvent(0, Uptime.Boot + 11.milliseconds, PxPosition(1.px, 0.px), true)
+ val move = PointerInputEvent(0, Uptime.Boot + 11.milliseconds, PxPosition(1f, 0f), true)
// Act
@@ -2504,9 +2503,9 @@
)
)
root.apply { insertAt(0, layoutNode) }
- val down = PointerInputEvent(0, Uptime.Boot + 11.milliseconds, PxPosition(0.px, 0.px), true)
+ val down = PointerInputEvent(0, Uptime.Boot + 11.milliseconds, PxPosition(0f, 0f), true)
pointerInputEventProcessor.process(down)
- val move = PointerInputEvent(0, Uptime.Boot + 11.milliseconds, PxPosition(1.px, 0.px), true)
+ val move = PointerInputEvent(0, Uptime.Boot + 11.milliseconds, PxPosition(1f, 0f), true)
// Act
@@ -2531,7 +2530,7 @@
spy(
TestPointerInputFilter { changes, pass, _ ->
if (pass == PointerEventPass.InitialDown) {
- changes.map { it.consumePositionChange(1.px, 0.px) }
+ changes.map { it.consumePositionChange(1f, 0f) }
} else {
changes
}
@@ -2545,9 +2544,9 @@
)
)
root.apply { insertAt(0, layoutNode) }
- val down = PointerInputEvent(0, Uptime.Boot + 11.milliseconds, PxPosition(0.px, 0.px), true)
+ val down = PointerInputEvent(0, Uptime.Boot + 11.milliseconds, PxPosition(0f, 0f), true)
pointerInputEventProcessor.process(down)
- val move = PointerInputEvent(0, Uptime.Boot + 11.milliseconds, PxPosition(1.px, 0.px), true)
+ val move = PointerInputEvent(0, Uptime.Boot + 11.milliseconds, PxPosition(1f, 0f), true)
// Act
diff --git a/ui/ui-core/src/test/java/androidx/ui/core/selection/SelectionManagerDragTest.kt b/ui/ui-core/src/test/java/androidx/ui/core/selection/SelectionManagerDragTest.kt
index 9261cb2..87f5948 100644
--- a/ui/ui-core/src/test/java/androidx/ui/core/selection/SelectionManagerDragTest.kt
+++ b/ui/ui-core/src/test/java/androidx/ui/core/selection/SelectionManagerDragTest.kt
@@ -22,7 +22,6 @@
import androidx.ui.core.LayoutCoordinates
import androidx.ui.text.style.TextDirection
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.px
import com.google.common.truth.Truth.assertThat
import com.nhaarman.mockitokotlin2.any
import com.nhaarman.mockitokotlin2.doReturn
@@ -47,7 +46,7 @@
private val containerLayoutCoordinates = mock<LayoutCoordinates> {
on { isAttached } doReturn true
}
- private val childToLocal_result = PxPosition(300.px, 400.px)
+ private val childToLocal_result = PxPosition(300f, 400f)
private val startSelectable = mock<Selectable>()
private val endSelectable = mock<Selectable>()
@@ -151,7 +150,7 @@
@Test
fun handleDragObserver_onDrag_startHandle_reuse_endHandle_calls_getSelection_change_selection
() {
- val dragDistance = PxPosition(100.px, 100.px)
+ val dragDistance = PxPosition(100f, 100f)
selectionManager.handleDragObserver(isStartHandle = true).onStart(PxPosition.Origin)
val result = selectionManager.handleDragObserver(isStartHandle = true).onDrag(dragDistance)
@@ -178,7 +177,7 @@
@Test
fun handleDragObserver_onDrag_endHandle_resue_startHandle_calls_getSelection_change_selection
() {
- val dragDistance = PxPosition(100.px, 100.px)
+ val dragDistance = PxPosition(100f, 100f)
selectionManager.handleDragObserver(isStartHandle = false).onStart(PxPosition.Origin)
val result = selectionManager.handleDragObserver(isStartHandle = false).onDrag(dragDistance)
@@ -213,12 +212,12 @@
}
private fun getAdjustedCoordinates(position: PxPosition): PxPosition {
- return PxPosition(position.x, position.y - 1.px)
+ return PxPosition(position.x, position.y - 1f)
}
private fun verify_draggingHandle(expectedDraggingHandleValue: Boolean) {
// Verify draggingHandle is true, by verifying LongPress does nothing. Vice Versa.
- val position = PxPosition(100.px, 100.px)
+ val position = PxPosition(100f, 100f)
selectionManager.longPressDragObserver.onLongPress(position)
verify(selectable, times(if (expectedDraggingHandleValue) 0 else 1))
.getSelection(
diff --git a/ui/ui-core/src/test/java/androidx/ui/core/selection/SelectionManagerLongPressDragTest.kt b/ui/ui-core/src/test/java/androidx/ui/core/selection/SelectionManagerLongPressDragTest.kt
index 7079fb1..1c69bfc 100644
--- a/ui/ui-core/src/test/java/androidx/ui/core/selection/SelectionManagerLongPressDragTest.kt
+++ b/ui/ui-core/src/test/java/androidx/ui/core/selection/SelectionManagerLongPressDragTest.kt
@@ -22,7 +22,6 @@
import androidx.ui.core.LayoutCoordinates
import androidx.ui.text.style.TextDirection
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.px
import com.google.common.truth.Truth.assertThat
import com.nhaarman.mockitokotlin2.any
import com.nhaarman.mockitokotlin2.anyOrNull
@@ -110,7 +109,7 @@
@Test
fun longPressDragObserver_onLongPress_calls_getSelection_change_selection() {
- val position = PxPosition(100.px, 100.px)
+ val position = PxPosition(100f, 100f)
selectionManager.longPressDragObserver.onLongPress(position)
@@ -130,10 +129,10 @@
@Test
fun longPressDragObserver_onDragStart_reset_dragTotalDistance() {
// Setup. Make sure selectionManager.dragTotalDistance is not 0.
- val dragDistance1 = PxPosition(15.px, 10.px)
- val beginPosition1 = PxPosition(30.px, 20.px)
- val dragDistance2 = PxPosition(100.px, 300.px)
- val beginPosition2 = PxPosition(300.px, 200.px)
+ val dragDistance1 = PxPosition(15f, 10f)
+ val beginPosition1 = PxPosition(30f, 20f)
+ val dragDistance2 = PxPosition(100f, 300f)
+ val beginPosition2 = PxPosition(300f, 200f)
selectionManager.longPressDragObserver.onLongPress(beginPosition1)
selectionManager.longPressDragObserver.onDragStart()
selectionManager.longPressDragObserver.onDrag(dragDistance1)
@@ -163,8 +162,8 @@
@Test
fun longPressDragObserver_onDrag_calls_getSelection_change_selection() {
- val dragDistance = PxPosition(15.px, 10.px)
- val beginPosition = PxPosition(30.px, 20.px)
+ val dragDistance = PxPosition(15f, 10f)
+ val beginPosition = PxPosition(30f, 20f)
selectionManager.longPressDragObserver.onLongPress(beginPosition)
selectionManager.selection = fakeInitialSelection
selection = fakeInitialSelection
@@ -187,8 +186,8 @@
@Test
fun longPressDragObserver_onDrag_directly_not_call_getSelection_not_change_selection() {
- val dragDistance = PxPosition(15.px, 10.px)
- val beginPosition = PxPosition(30.px, 20.px)
+ val dragDistance = PxPosition(15f, 10f)
+ val beginPosition = PxPosition(30f, 20f)
selection = fakeInitialSelection
val result = selectionManager.longPressDragObserver.onDrag(dragDistance)
diff --git a/ui/ui-core/src/test/java/androidx/ui/core/selection/SelectionManagerTest.kt b/ui/ui-core/src/test/java/androidx/ui/core/selection/SelectionManagerTest.kt
index 8b7bcdf..a56b8c1 100644
--- a/ui/ui-core/src/test/java/androidx/ui/core/selection/SelectionManagerTest.kt
+++ b/ui/ui-core/src/test/java/androidx/ui/core/selection/SelectionManagerTest.kt
@@ -30,7 +30,6 @@
import androidx.ui.text.style.TextDirection
import androidx.ui.text.subSequence
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.px
import com.google.common.truth.Truth.assertThat
import com.nhaarman.mockitokotlin2.any
import com.nhaarman.mockitokotlin2.doReturn
@@ -61,8 +60,8 @@
private val middleSelectable = mock<Selectable>()
private val lastSelectable = mock<Selectable>()
- private val startCoordinates = PxPosition(3.px, 30.px)
- private val endCoordinates = PxPosition(3.px, 600.px)
+ private val startCoordinates = PxPosition(3f, 30f)
+ private val endCoordinates = PxPosition(3f, 600f)
private val fakeSelection =
Selection(
@@ -417,8 +416,8 @@
verify(selectable, times(1))
.getSelection(
- startPosition = PxPosition((-1).px, (-1).px),
- endPosition = PxPosition((-1).px, (-1).px),
+ startPosition = PxPosition(-1f, -1f),
+ endPosition = PxPosition(-1f, -1f),
containerLayoutCoordinates = selectionManager.requireContainerCoordinates(),
longPress = false,
previousSelection = fakeSelection
diff --git a/ui/ui-core/src/test/java/androidx/ui/core/selection/SelectionRegistrarImplTest.kt b/ui/ui-core/src/test/java/androidx/ui/core/selection/SelectionRegistrarImplTest.kt
index e083526..4188bb3 100644
--- a/ui/ui-core/src/test/java/androidx/ui/core/selection/SelectionRegistrarImplTest.kt
+++ b/ui/ui-core/src/test/java/androidx/ui/core/selection/SelectionRegistrarImplTest.kt
@@ -19,7 +19,6 @@
import androidx.test.filters.SmallTest
import androidx.ui.core.LayoutCoordinates
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.px
import com.google.common.truth.Truth.assertThat
import com.nhaarman.mockitokotlin2.mock
import com.nhaarman.mockitokotlin2.whenever
@@ -76,10 +75,10 @@
whenever(handler3.getLayoutCoordinates()).thenReturn(layoutCoordinates3)
// The order of the 4 handlers should be 1, 0, 3, 2.
- val relativeCoordinates0 = PxPosition(20.px, 12.px)
- val relativeCoordinates1 = PxPosition(5.px, 12.px)
- val relativeCoordinates2 = PxPosition(20.px, 24.px)
- val relativeCoordinates3 = PxPosition(5.px, 24.px)
+ val relativeCoordinates0 = PxPosition(20f, 12f)
+ val relativeCoordinates1 = PxPosition(5f, 12f)
+ val relativeCoordinates2 = PxPosition(20f, 24f)
+ val relativeCoordinates3 = PxPosition(5f, 24f)
val containerLayoutCoordinates = mock<LayoutCoordinates>()
whenever(containerLayoutCoordinates.childToLocal(layoutCoordinates0, PxPosition.Origin))
@@ -127,10 +126,10 @@
whenever(handler3.getLayoutCoordinates()).thenReturn(layoutCoordinates3)
// The order of the 4 handlers should be 1, 0, 3, 2.
- val relativeCoordinates0 = PxPosition(20.px, 12.px)
- val relativeCoordinates1 = PxPosition(5.px, 12.px)
- val relativeCoordinates2 = PxPosition(20.px, 24.px)
- val relativeCoordinates3 = PxPosition(5.px, 24.px)
+ val relativeCoordinates0 = PxPosition(20f, 12f)
+ val relativeCoordinates1 = PxPosition(5f, 12f)
+ val relativeCoordinates2 = PxPosition(20f, 24f)
+ val relativeCoordinates3 = PxPosition(5f, 24f)
val containerLayoutCoordinates = mock<LayoutCoordinates>()
whenever(containerLayoutCoordinates.childToLocal(layoutCoordinates0, PxPosition.Origin))
diff --git a/ui/ui-foundation/api/0.1.0-dev14.txt b/ui/ui-foundation/api/0.1.0-dev14.txt
index 820d93b..e34b4f1 100644
--- a/ui/ui-foundation/api/0.1.0-dev14.txt
+++ b/ui/ui-foundation/api/0.1.0-dev14.txt
@@ -49,7 +49,7 @@
}
public final class DeterminateProgressIndicatorKt {
- method @androidx.compose.Composable public static void DeterminateProgressIndicator(@FloatRange(from=0.0, to=1.0) float progress, kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @androidx.compose.Stable public static androidx.ui.core.Modifier determinateProgressIndicator(androidx.ui.core.Modifier, @FloatRange(from=0.0, to=1.0) float progress);
}
public final class DialogKt {
@@ -306,8 +306,11 @@
package androidx.ui.foundation.selection {
- public final class MutuallyExclusiveSetItemKt {
- method @androidx.compose.Composable public static void MutuallyExclusiveSetItem(boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onClick, androidx.ui.core.Modifier modifier = Modifier, kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ public final class SelectableKt {
+ method @Deprecated @androidx.compose.Composable public static void MutuallyExclusiveSetItem(boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onClick, androidx.ui.core.Modifier modifier = Modifier, kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @androidx.compose.Composable public static androidx.ui.core.Modifier selectable(androidx.ui.core.Modifier, boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onClick, boolean enabled = true, boolean inMutuallyExclusiveGroup = true, androidx.ui.foundation.InteractionState interactionState = remember({
+ return <init>()
+}), androidx.ui.foundation.Indication? indication = IndicationAmbient.invoke());
}
public final class ToggleableKt {
diff --git a/ui/ui-foundation/api/current.txt b/ui/ui-foundation/api/current.txt
index 820d93b..e34b4f1 100644
--- a/ui/ui-foundation/api/current.txt
+++ b/ui/ui-foundation/api/current.txt
@@ -49,7 +49,7 @@
}
public final class DeterminateProgressIndicatorKt {
- method @androidx.compose.Composable public static void DeterminateProgressIndicator(@FloatRange(from=0.0, to=1.0) float progress, kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @androidx.compose.Stable public static androidx.ui.core.Modifier determinateProgressIndicator(androidx.ui.core.Modifier, @FloatRange(from=0.0, to=1.0) float progress);
}
public final class DialogKt {
@@ -306,8 +306,11 @@
package androidx.ui.foundation.selection {
- public final class MutuallyExclusiveSetItemKt {
- method @androidx.compose.Composable public static void MutuallyExclusiveSetItem(boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onClick, androidx.ui.core.Modifier modifier = Modifier, kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ public final class SelectableKt {
+ method @Deprecated @androidx.compose.Composable public static void MutuallyExclusiveSetItem(boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onClick, androidx.ui.core.Modifier modifier = Modifier, kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @androidx.compose.Composable public static androidx.ui.core.Modifier selectable(androidx.ui.core.Modifier, boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onClick, boolean enabled = true, boolean inMutuallyExclusiveGroup = true, androidx.ui.foundation.InteractionState interactionState = remember({
+ return <init>()
+}), androidx.ui.foundation.Indication? indication = IndicationAmbient.invoke());
}
public final class ToggleableKt {
diff --git a/ui/ui-foundation/api/public_plus_experimental_0.1.0-dev14.txt b/ui/ui-foundation/api/public_plus_experimental_0.1.0-dev14.txt
index 820d93b..e34b4f1 100644
--- a/ui/ui-foundation/api/public_plus_experimental_0.1.0-dev14.txt
+++ b/ui/ui-foundation/api/public_plus_experimental_0.1.0-dev14.txt
@@ -49,7 +49,7 @@
}
public final class DeterminateProgressIndicatorKt {
- method @androidx.compose.Composable public static void DeterminateProgressIndicator(@FloatRange(from=0.0, to=1.0) float progress, kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @androidx.compose.Stable public static androidx.ui.core.Modifier determinateProgressIndicator(androidx.ui.core.Modifier, @FloatRange(from=0.0, to=1.0) float progress);
}
public final class DialogKt {
@@ -306,8 +306,11 @@
package androidx.ui.foundation.selection {
- public final class MutuallyExclusiveSetItemKt {
- method @androidx.compose.Composable public static void MutuallyExclusiveSetItem(boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onClick, androidx.ui.core.Modifier modifier = Modifier, kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ public final class SelectableKt {
+ method @Deprecated @androidx.compose.Composable public static void MutuallyExclusiveSetItem(boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onClick, androidx.ui.core.Modifier modifier = Modifier, kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @androidx.compose.Composable public static androidx.ui.core.Modifier selectable(androidx.ui.core.Modifier, boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onClick, boolean enabled = true, boolean inMutuallyExclusiveGroup = true, androidx.ui.foundation.InteractionState interactionState = remember({
+ return <init>()
+}), androidx.ui.foundation.Indication? indication = IndicationAmbient.invoke());
}
public final class ToggleableKt {
diff --git a/ui/ui-foundation/api/public_plus_experimental_current.txt b/ui/ui-foundation/api/public_plus_experimental_current.txt
index 820d93b..e34b4f1 100644
--- a/ui/ui-foundation/api/public_plus_experimental_current.txt
+++ b/ui/ui-foundation/api/public_plus_experimental_current.txt
@@ -49,7 +49,7 @@
}
public final class DeterminateProgressIndicatorKt {
- method @androidx.compose.Composable public static void DeterminateProgressIndicator(@FloatRange(from=0.0, to=1.0) float progress, kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @androidx.compose.Stable public static androidx.ui.core.Modifier determinateProgressIndicator(androidx.ui.core.Modifier, @FloatRange(from=0.0, to=1.0) float progress);
}
public final class DialogKt {
@@ -306,8 +306,11 @@
package androidx.ui.foundation.selection {
- public final class MutuallyExclusiveSetItemKt {
- method @androidx.compose.Composable public static void MutuallyExclusiveSetItem(boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onClick, androidx.ui.core.Modifier modifier = Modifier, kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ public final class SelectableKt {
+ method @Deprecated @androidx.compose.Composable public static void MutuallyExclusiveSetItem(boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onClick, androidx.ui.core.Modifier modifier = Modifier, kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @androidx.compose.Composable public static androidx.ui.core.Modifier selectable(androidx.ui.core.Modifier, boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onClick, boolean enabled = true, boolean inMutuallyExclusiveGroup = true, androidx.ui.foundation.InteractionState interactionState = remember({
+ return <init>()
+}), androidx.ui.foundation.Indication? indication = IndicationAmbient.invoke());
}
public final class ToggleableKt {
diff --git a/ui/ui-foundation/api/restricted_0.1.0-dev14.txt b/ui/ui-foundation/api/restricted_0.1.0-dev14.txt
index 820d93b..e34b4f1 100644
--- a/ui/ui-foundation/api/restricted_0.1.0-dev14.txt
+++ b/ui/ui-foundation/api/restricted_0.1.0-dev14.txt
@@ -49,7 +49,7 @@
}
public final class DeterminateProgressIndicatorKt {
- method @androidx.compose.Composable public static void DeterminateProgressIndicator(@FloatRange(from=0.0, to=1.0) float progress, kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @androidx.compose.Stable public static androidx.ui.core.Modifier determinateProgressIndicator(androidx.ui.core.Modifier, @FloatRange(from=0.0, to=1.0) float progress);
}
public final class DialogKt {
@@ -306,8 +306,11 @@
package androidx.ui.foundation.selection {
- public final class MutuallyExclusiveSetItemKt {
- method @androidx.compose.Composable public static void MutuallyExclusiveSetItem(boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onClick, androidx.ui.core.Modifier modifier = Modifier, kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ public final class SelectableKt {
+ method @Deprecated @androidx.compose.Composable public static void MutuallyExclusiveSetItem(boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onClick, androidx.ui.core.Modifier modifier = Modifier, kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @androidx.compose.Composable public static androidx.ui.core.Modifier selectable(androidx.ui.core.Modifier, boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onClick, boolean enabled = true, boolean inMutuallyExclusiveGroup = true, androidx.ui.foundation.InteractionState interactionState = remember({
+ return <init>()
+}), androidx.ui.foundation.Indication? indication = IndicationAmbient.invoke());
}
public final class ToggleableKt {
diff --git a/ui/ui-foundation/api/restricted_current.txt b/ui/ui-foundation/api/restricted_current.txt
index 820d93b..e34b4f1 100644
--- a/ui/ui-foundation/api/restricted_current.txt
+++ b/ui/ui-foundation/api/restricted_current.txt
@@ -49,7 +49,7 @@
}
public final class DeterminateProgressIndicatorKt {
- method @androidx.compose.Composable public static void DeterminateProgressIndicator(@FloatRange(from=0.0, to=1.0) float progress, kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @androidx.compose.Stable public static androidx.ui.core.Modifier determinateProgressIndicator(androidx.ui.core.Modifier, @FloatRange(from=0.0, to=1.0) float progress);
}
public final class DialogKt {
@@ -306,8 +306,11 @@
package androidx.ui.foundation.selection {
- public final class MutuallyExclusiveSetItemKt {
- method @androidx.compose.Composable public static void MutuallyExclusiveSetItem(boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onClick, androidx.ui.core.Modifier modifier = Modifier, kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ public final class SelectableKt {
+ method @Deprecated @androidx.compose.Composable public static void MutuallyExclusiveSetItem(boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onClick, androidx.ui.core.Modifier modifier = Modifier, kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @androidx.compose.Composable public static androidx.ui.core.Modifier selectable(androidx.ui.core.Modifier, boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onClick, boolean enabled = true, boolean inMutuallyExclusiveGroup = true, androidx.ui.foundation.InteractionState interactionState = remember({
+ return <init>()
+}), androidx.ui.foundation.Indication? indication = IndicationAmbient.invoke());
}
public final class ToggleableKt {
diff --git a/ui/ui-foundation/samples/src/main/java/androidx/ui/foundation/samples/DeterminateProgressSamples.kt b/ui/ui-foundation/samples/src/main/java/androidx/ui/foundation/samples/DeterminateProgressSamples.kt
index 113ae84..2cb96e7 100644
--- a/ui/ui-foundation/samples/src/main/java/androidx/ui/foundation/samples/DeterminateProgressSamples.kt
+++ b/ui/ui-foundation/samples/src/main/java/androidx/ui/foundation/samples/DeterminateProgressSamples.kt
@@ -20,7 +20,7 @@
import androidx.compose.Composable
import androidx.ui.core.Modifier
import androidx.ui.foundation.Box
-import androidx.ui.foundation.DeterminateProgressIndicator
+import androidx.ui.foundation.determinateProgressIndicator
import androidx.ui.foundation.drawBackground
import androidx.ui.graphics.Color
import androidx.ui.layout.preferredSize
@@ -30,7 +30,6 @@
@Composable
fun DeterminateProgressSample() {
val progress = 0.5f // emulate progress from some state
- DeterminateProgressIndicator(progress) {
- Box(Modifier.preferredSize((progress * 100).dp, 4.dp).drawBackground(Color.Cyan))
- }
+ Box(Modifier.determinateProgressIndicator(progress)
+ .preferredSize((progress * 100).dp, 4.dp).drawBackground(Color.Cyan))
}
\ No newline at end of file
diff --git a/ui/ui-foundation/samples/src/main/java/androidx/ui/foundation/samples/SelectableSamples.kt b/ui/ui-foundation/samples/src/main/java/androidx/ui/foundation/samples/SelectableSamples.kt
new file mode 100644
index 0000000..4193d7c
--- /dev/null
+++ b/ui/ui-foundation/samples/src/main/java/androidx/ui/foundation/samples/SelectableSamples.kt
@@ -0,0 +1,58 @@
+/*
+ * 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 androidx.ui.foundation.samples
+
+import androidx.annotation.Sampled
+import androidx.compose.Composable
+import androidx.compose.getValue
+import androidx.compose.setValue
+import androidx.compose.state
+import androidx.ui.core.Modifier
+import androidx.ui.foundation.Box
+import androidx.ui.foundation.Text
+import androidx.ui.foundation.drawBackground
+import androidx.ui.foundation.selection.selectable
+import androidx.ui.graphics.Color
+import androidx.ui.layout.Column
+import androidx.ui.layout.Row
+import androidx.ui.layout.size
+import androidx.ui.unit.dp
+
+@Sampled
+@Composable
+fun SelectableSample() {
+ val option1 = Color.Red
+ val option2 = Color.Blue
+ var selectedOption by state { option1 }
+ Column {
+ Text("Selected: $selectedOption")
+ Row {
+ listOf(option1, option2).forEach { color ->
+ val selected = selectedOption == color
+ Box(
+ Modifier
+ .size(100.dp)
+ .drawBackground(color)
+ .selectable(
+ selected = selected,
+ onClick = { selectedOption = color }
+ )
+ )
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/DeterminateProgressTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/DeterminateProgressTest.kt
index 924d435..7f67e6b 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/DeterminateProgressTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/DeterminateProgressTest.kt
@@ -19,7 +19,7 @@
import androidx.compose.mutableStateOf
import androidx.test.filters.MediumTest
import androidx.ui.core.Modifier
-import androidx.ui.core.TestTag
+import androidx.ui.core.testTag
import androidx.ui.graphics.Color
import androidx.ui.layout.preferredSize
import androidx.ui.semantics.AccessibilityRangeInfo
@@ -48,11 +48,11 @@
composeTestRule
.setContent {
- TestTag(tag = tag) {
- DeterminateProgressIndicator(progress = progress.value) {
- Box(Modifier.preferredSize(50.dp).drawBackground(Color.Cyan))
- }
- }
+ Box(Modifier
+ .testTag(tag)
+ .determinateProgressIndicator(progress.value)
+ .preferredSize(50.dp)
+ .drawBackground(Color.Cyan))
}
findByTag(tag)
@@ -60,6 +60,14 @@
.assertRangeInfoEquals(AccessibilityRangeInfo(0f, 0f..1f))
runOnUiThread {
+ progress.value = 0.005f
+ }
+
+ findByTag(tag)
+ .assertValueEquals("1 percent")
+ .assertRangeInfoEquals(AccessibilityRangeInfo(0.005f, 0f..1f))
+
+ runOnUiThread {
progress.value = 0.5f
}
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/DraggableTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/DraggableTest.kt
index d485b62..59e5574 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/DraggableTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/DraggableTest.kt
@@ -37,7 +37,6 @@
import androidx.ui.unit.PxPosition
import androidx.ui.unit.dp
import androidx.ui.unit.milliseconds
-import androidx.ui.unit.px
import com.google.common.truth.Truth.assertThat
import org.junit.Rule
import org.junit.Test
@@ -68,7 +67,7 @@
findByTag(draggableBoxTag).doGesture {
this.sendSwipe(
start = this.center,
- end = PxPosition(this.center.x + 100.px, this.center.y),
+ end = PxPosition(this.center.x + 100f, this.center.y),
duration = 100.milliseconds
)
}
@@ -79,7 +78,7 @@
findByTag(draggableBoxTag).doGesture {
this.sendSwipe(
start = this.center,
- end = PxPosition(this.center.x, this.center.y + 100.px),
+ end = PxPosition(this.center.x, this.center.y + 100f),
duration = 100.milliseconds
)
}
@@ -89,7 +88,7 @@
findByTag(draggableBoxTag).doGesture {
this.sendSwipe(
start = this.center,
- end = PxPosition(this.center.x - 100.px, this.center.y),
+ end = PxPosition(this.center.x - 100f, this.center.y),
duration = 100.milliseconds
)
}
@@ -113,7 +112,7 @@
findByTag(draggableBoxTag).doGesture {
this.sendSwipe(
start = this.center,
- end = PxPosition(this.center.x, this.center.y + 100.px),
+ end = PxPosition(this.center.x, this.center.y + 100f),
duration = 100.milliseconds
)
}
@@ -124,7 +123,7 @@
findByTag(draggableBoxTag).doGesture {
this.sendSwipe(
start = this.center,
- end = PxPosition(this.center.x + 100.px, this.center.y),
+ end = PxPosition(this.center.x + 100f, this.center.y),
duration = 100.milliseconds
)
}
@@ -134,7 +133,7 @@
findByTag(draggableBoxTag).doGesture {
this.sendSwipe(
start = this.center,
- end = PxPosition(this.center.x, this.center.y - 100.px),
+ end = PxPosition(this.center.x, this.center.y - 100f),
duration = 100.milliseconds
)
}
@@ -168,7 +167,7 @@
findByTag(draggableBoxTag).doGesture {
this.sendSwipe(
start = this.center,
- end = PxPosition(this.center.x + 100.px, this.center.y),
+ end = PxPosition(this.center.x + 100f, this.center.y),
duration = 100.milliseconds
)
}
@@ -195,7 +194,7 @@
findByTag(draggableBoxTag).doGesture {
this.sendSwipe(
start = this.center,
- end = PxPosition(this.center.x + 100.px, this.center.y),
+ end = PxPosition(this.center.x + 100f, this.center.y),
duration = 100.milliseconds
)
}
@@ -207,7 +206,7 @@
findByTag(draggableBoxTag).doGesture {
this.sendSwipe(
start = this.center,
- end = PxPosition(this.center.x + 100.px, this.center.y),
+ end = PxPosition(this.center.x + 100f, this.center.y),
duration = 100.milliseconds
)
}
@@ -233,7 +232,7 @@
findByTag(draggableBoxTag).doGesture {
this.sendSwipeWithVelocity(
start = this.center,
- end = PxPosition(this.center.x + 100.px, this.center.y),
+ end = PxPosition(this.center.x + 100f, this.center.y),
endVelocity = 112f,
duration = 100.milliseconds
@@ -260,7 +259,7 @@
findByTag(draggableBoxTag).doGesture {
this.sendSwipe(
start = this.center,
- end = PxPosition(this.center.x + 100.px, this.center.y),
+ end = PxPosition(this.center.x + 100f, this.center.y),
duration = 100.milliseconds
)
}
@@ -290,7 +289,7 @@
findByTag(draggableBoxTag).doGesture {
this.sendSwipe(
start = this.center,
- end = PxPosition(this.center.x + 100.px, this.center.y),
+ end = PxPosition(this.center.x + 100f, this.center.y),
duration = 100.milliseconds
)
}
@@ -333,7 +332,7 @@
findByTag(draggableBoxTag).doGesture {
this.sendSwipe(
start = this.center,
- end = PxPosition(this.center.x + 200.px, this.center.y),
+ end = PxPosition(this.center.x + 200f, this.center.y),
duration = 300.milliseconds
)
}
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/IndicationTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/IndicationTest.kt
index 54064fb..993dbb0 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/IndicationTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/IndicationTest.kt
@@ -31,7 +31,6 @@
import androidx.ui.test.sendUp
import androidx.ui.unit.PxPosition
import androidx.ui.unit.dp
-import androidx.ui.unit.px
import com.google.common.truth.Truth.assertThat
import org.junit.Ignore
import org.junit.Rule
@@ -141,7 +140,7 @@
findByTag(testTag)
.assertExists()
.doPartialGesture {
- position1 = PxPosition(center.x, center.y + 20.px)
+ position1 = PxPosition(center.x, center.y + 20f)
// pointer 1, when we have multitouch
sendDown(position1!!)
}
@@ -151,7 +150,7 @@
findByTag(testTag)
.assertExists()
.doPartialGesture {
- val position2 = PxPosition(center.x + 20.px, center.y)
+ val position2 = PxPosition(center.x + 20f, center.y)
// pointer 2, when we have multitouch
sendDown(position2)
}
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ScrollableTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ScrollableTest.kt
index ed93bdc..3ebd1a0a 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ScrollableTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ScrollableTest.kt
@@ -44,7 +44,6 @@
import androidx.ui.unit.PxPosition
import androidx.ui.unit.dp
import androidx.ui.unit.milliseconds
-import androidx.ui.unit.px
import com.google.common.truth.Truth
import com.google.common.truth.Truth.assertThat
import org.junit.Rule
@@ -84,7 +83,7 @@
findByTag(scrollableBoxTag).doGesture {
this.sendSwipe(
start = this.center,
- end = PxPosition(this.center.x + 100.px, this.center.y),
+ end = PxPosition(this.center.x + 100f, this.center.y),
duration = 100.milliseconds
)
}
@@ -97,7 +96,7 @@
findByTag(scrollableBoxTag).doGesture {
this.sendSwipe(
start = this.center,
- end = PxPosition(this.center.x, this.center.y + 100.px),
+ end = PxPosition(this.center.x, this.center.y + 100f),
duration = 100.milliseconds
)
}
@@ -109,7 +108,7 @@
findByTag(scrollableBoxTag).doGesture {
this.sendSwipe(
start = this.center,
- end = PxPosition(this.center.x - 100.px, this.center.y),
+ end = PxPosition(this.center.x - 100f, this.center.y),
duration = 100.milliseconds
)
}
@@ -140,7 +139,7 @@
findByTag(scrollableBoxTag).doGesture {
this.sendSwipe(
start = this.center,
- end = PxPosition(this.center.x, this.center.y + 100.px),
+ end = PxPosition(this.center.x, this.center.y + 100f),
duration = 100.milliseconds
)
}
@@ -153,7 +152,7 @@
findByTag(scrollableBoxTag).doGesture {
this.sendSwipe(
start = this.center,
- end = PxPosition(this.center.x + 100.px, this.center.y),
+ end = PxPosition(this.center.x + 100f, this.center.y),
duration = 100.milliseconds
)
}
@@ -165,7 +164,7 @@
findByTag(scrollableBoxTag).doGesture {
this.sendSwipe(
start = this.center,
- end = PxPosition(this.center.x, this.center.y - 100.px),
+ end = PxPosition(this.center.x, this.center.y - 100f),
duration = 100.milliseconds
)
}
@@ -204,7 +203,7 @@
findByTag(scrollableBoxTag).doGesture {
this.sendSwipe(
start = this.center,
- end = PxPosition(this.center.x + 100.px, this.center.y),
+ end = PxPosition(this.center.x + 100f, this.center.y),
duration = 100.milliseconds
)
}
@@ -244,7 +243,7 @@
findByTag(scrollableBoxTag).doGesture {
this.sendSwipe(
start = this.center,
- end = PxPosition(this.center.x + 100.px, this.center.y),
+ end = PxPosition(this.center.x + 100f, this.center.y),
duration = 100.milliseconds
)
}
@@ -257,7 +256,7 @@
findByTag(scrollableBoxTag).doGesture {
this.sendSwipe(
start = this.center,
- end = PxPosition(this.center.x + 100.px, this.center.y),
+ end = PxPosition(this.center.x + 100f, this.center.y),
duration = 100.milliseconds
)
}
@@ -292,7 +291,7 @@
findByTag(scrollableBoxTag).doGesture {
this.sendSwipeWithVelocity(
start = this.center,
- end = PxPosition(this.center.x + 100.px, this.center.y),
+ end = PxPosition(this.center.x + 100f, this.center.y),
endVelocity = 112f,
duration = 100.milliseconds
@@ -303,7 +302,7 @@
findByTag(scrollableBoxTag).doGesture {
this.sendSwipeWithVelocity(
start = this.center,
- end = PxPosition(this.center.x - 100.px, this.center.y),
+ end = PxPosition(this.center.x - 100f, this.center.y),
endVelocity = 312f,
duration = 100.milliseconds
@@ -336,7 +335,7 @@
findByTag(scrollableBoxTag).doGesture {
this.sendSwipe(
start = this.center,
- end = PxPosition(this.center.x + 100.px, this.center.y),
+ end = PxPosition(this.center.x + 100f, this.center.y),
duration = 100.milliseconds
)
}
@@ -348,7 +347,7 @@
findByTag(scrollableBoxTag).doGesture {
this.sendSwipe(
start = this.center,
- end = PxPosition(this.center.x + 114.px, this.center.y),
+ end = PxPosition(this.center.x + 114f, this.center.y),
duration = 100.milliseconds
)
}
@@ -388,7 +387,7 @@
findByTag(scrollableBoxTag).doGesture {
this.sendSwipe(
start = this.center,
- end = PxPosition(this.center.x + 100.px, this.center.y),
+ end = PxPosition(this.center.x + 100, this.center.y),
duration = 100.milliseconds
)
}
@@ -551,7 +550,7 @@
findByTag(scrollableBoxTag).doGesture {
this.sendSwipe(
start = this.center,
- end = PxPosition(this.center.x + 200.px, this.center.y),
+ end = PxPosition(this.center.x + 200f, this.center.y),
duration = 300.milliseconds
)
}
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/MutuallyExclusiveSetItemTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/SelectableTest.kt
similarity index 73%
rename from ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/MutuallyExclusiveSetItemTest.kt
rename to ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/SelectableTest.kt
index 8cf4a60..0eb86b4 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/MutuallyExclusiveSetItemTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/SelectableTest.kt
@@ -18,7 +18,8 @@
import androidx.compose.state
import androidx.test.filters.MediumTest
-import androidx.ui.foundation.selection.MutuallyExclusiveSetItem
+import androidx.ui.core.Modifier
+import androidx.ui.foundation.selection.selectable
import androidx.ui.test.assertCountEquals
import androidx.ui.test.assertIsInMutuallyExclusiveGroup
import androidx.ui.test.assertIsSelected
@@ -36,17 +37,18 @@
@MediumTest
@RunWith(JUnit4::class)
-class MutuallyExclusiveSetItemTest {
+class SelectableTest {
@get:Rule
val composeTestRule = createComposeRule()
@Test
- fun mutuallyExclusiveItem_defaultSemantics() {
+ fun selectable_defaultSemantics() {
composeTestRule.setContent {
- MutuallyExclusiveSetItem(selected = true, onClick = {}) {
- Text("Text in item")
- }
+ Text(
+ "Text in item",
+ modifier = Modifier.selectable(selected = true, onClick = {})
+ )
}
findAll(isInMutuallyExclusiveGroup())
@@ -57,12 +59,16 @@
}
@Test
- fun mutuallyExclusiveItem_defaultClicks() {
+ fun selectable_defaultClicks() {
composeTestRule.setContent {
val (selected, onSelected) = state { false }
- MutuallyExclusiveSetItem(selected, onClick = { onSelected(!selected) }) {
- Text("Text in item")
- }
+ Text(
+ "Text in item",
+ modifier = Modifier.selectable(
+ selected = selected,
+ onClick = { onSelected(!selected) }
+ )
+ )
}
find(isInMutuallyExclusiveGroup())
@@ -74,12 +80,15 @@
}
@Test
- fun mutuallyExclusiveItem_noClicksNoChanges() {
+ fun selectable_noClicksNoChanges() {
composeTestRule.setContent {
val (selected, _) = state { false }
- MutuallyExclusiveSetItem(selected, onClick = {}) {
- Text("Text in item")
- }
+ Text(
+ "Text in item",
+ modifier = Modifier.selectable(
+ selected = selected,
+ onClick = {})
+ )
}
find(isInMutuallyExclusiveGroup())
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/TextFieldOnValueChangeTextFieldValueTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/TextFieldOnValueChangeTextFieldValueTest.kt
index 9158382..150bcaa 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/TextFieldOnValueChangeTextFieldValueTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/TextFieldOnValueChangeTextFieldValueTest.kt
@@ -37,7 +37,6 @@
import androidx.ui.test.sendClick
import androidx.ui.text.TextRange
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.px
import com.google.common.truth.Truth.assertThat
import com.nhaarman.mockitokotlin2.any
import com.nhaarman.mockitokotlin2.argumentCaptor
@@ -95,7 +94,7 @@
// Perform click to focus in.
find(hasInputMethodsSupport())
- .doGesture { sendClick(PxPosition(1.px, 1.px)) }
+ .doGesture { sendClick(PxPosition(1f, 1f)) }
runOnIdleCompose {
// Verify startInput is called and capture the callback.
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/TextFieldTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/TextFieldTest.kt
index a8302e7..effbd0f 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/TextFieldTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/TextFieldTest.kt
@@ -40,6 +40,7 @@
import androidx.ui.input.TextInputService
import androidx.ui.layout.Row
import androidx.ui.layout.fillMaxSize
+import androidx.ui.layout.padding
import androidx.ui.layout.preferredSize
import androidx.ui.layout.preferredWidth
import androidx.ui.savedinstancestate.savedInstanceState
@@ -479,16 +480,21 @@
val height = 20.dp
val latch = CountDownLatch(1)
composeTestRule.setContent {
- TextField(
- value = TextFieldValue(),
- onValueChange = {},
- textStyle = TextStyle(color = Color.White, background = Color.White),
- modifier = Modifier.preferredSize(width, height).drawBackground(Color.White),
- cursorColor = Color.Red,
- onFocusChange = { focused ->
- if (focused) latch.countDown()
- }
- )
+ // The padding helps if the test is run accidentally in landscape. Landscape makes
+ // the cursor to be next to the navigation bar which affects the red color to be a bit
+ // different - possibly anti-aliasing.
+ Box(Modifier.padding(10.dp)) {
+ TextField(
+ value = TextFieldValue(),
+ onValueChange = {},
+ textStyle = TextStyle(color = Color.White, background = Color.White),
+ modifier = Modifier.preferredSize(width, height).drawBackground(Color.White),
+ cursorColor = Color.Red,
+ onFocusChange = { focused ->
+ if (focused) latch.countDown()
+ }
+ )
+ }
}
find(hasInputMethodsSupport()).doClick()
@@ -506,6 +512,11 @@
// cursor invisible during next 500 ms
composeTestRule.clockTestRule.advanceClock(700)
+
+ // TODO: There seems to be an issue on Pixel that we capture the bitmap too early and
+ // perform the assert while the cursor is still there.
+ waitForIdle()
+
find(hasInputMethodsSupport())
.captureToBitmap()
.assertShape(
diff --git a/ui/ui-foundation/src/main/java/androidx/ui/foundation/DeterminateProgressIndicator.kt b/ui/ui-foundation/src/main/java/androidx/ui/foundation/DeterminateProgressIndicator.kt
index c459dfe..25e1add 100644
--- a/ui/ui-foundation/src/main/java/androidx/ui/foundation/DeterminateProgressIndicator.kt
+++ b/ui/ui-foundation/src/main/java/androidx/ui/foundation/DeterminateProgressIndicator.kt
@@ -17,8 +17,9 @@
package androidx.ui.foundation
import androidx.annotation.FloatRange
-import androidx.ui.semantics.Semantics
-import androidx.compose.Composable
+import androidx.compose.Stable
+import androidx.ui.core.Modifier
+import androidx.ui.core.semantics.semantics
import androidx.ui.semantics.AccessibilityRangeInfo
import androidx.ui.semantics.accessibilityValue
import androidx.ui.semantics.accessibilityValueRange
@@ -32,28 +33,25 @@
*
* @param progress The progress of this progress indicator, where 0.0 represents no progress and 1.0
* represents full progress
- * @param children The progress indicator that is drawn on screen, representing [progress]
* @throws IllegalArgumentException when the progress is not within range
*/
-@Composable
-fun DeterminateProgressIndicator(
- @FloatRange(from = 0.0, to = 1.0) progress: Float,
- children: @Composable () -> Unit
-) {
+@Stable
+fun Modifier.determinateProgressIndicator(
+ @FloatRange(from = 0.0, to = 1.0) progress: Float
+): Modifier {
if (progress !in 0f..1f) {
throw IllegalArgumentException("Progress must be between 0.0 and 1.0")
}
- Semantics(container = true, properties = {
- var percent: Int
- // We only report 0% or 100% when it is exactly 0% or 100%.
- if (progress > 0 && progress < 0.01) {
- percent = 1
- } else if (progress > 0.99 && progress < 1) {
- percent = 99
- } else {
- percent = (progress * 100).roundToInt()
- }
+
+ // We only display 0% or 100% when it is exactly 0% or 100%.
+ val percent = when (progress) {
+ 0f -> 0
+ 1f -> 100
+ else -> (progress * 100).roundToInt().coerceIn(1, 99)
+ }
+
+ return semantics {
accessibilityValue = Strings.TemplatePercent.format(percent)
accessibilityValueRange = AccessibilityRangeInfo(progress, 0f..1f)
- }, children = children)
+ }
}
diff --git a/ui/ui-foundation/src/main/java/androidx/ui/foundation/Scroller.kt b/ui/ui-foundation/src/main/java/androidx/ui/foundation/Scroller.kt
index 592c12b..8ef06e3 100644
--- a/ui/ui-foundation/src/main/java/androidx/ui/foundation/Scroller.kt
+++ b/ui/ui-foundation/src/main/java/androidx/ui/foundation/Scroller.kt
@@ -285,9 +285,9 @@
// when b/156389287 is fixed, this should be proper scrollTo with reverse handling
ScrollTo(action = { x, y ->
if (isVertical) {
- scrollerPosition.scrollBy(y.value)
+ scrollerPosition.scrollBy(y)
} else {
- scrollerPosition.scrollBy(x.value)
+ scrollerPosition.scrollBy(x)
}
return@ScrollTo true
})
diff --git a/ui/ui-foundation/src/main/java/androidx/ui/foundation/gestures/DragDirection.kt b/ui/ui-foundation/src/main/java/androidx/ui/foundation/gestures/DragDirection.kt
index 1ac765d..fe7d19a 100644
--- a/ui/ui-foundation/src/main/java/androidx/ui/foundation/gestures/DragDirection.kt
+++ b/ui/ui-foundation/src/main/java/androidx/ui/foundation/gestures/DragDirection.kt
@@ -33,7 +33,7 @@
currentValue: Float
) -> Boolean
- internal open fun project(pos: PxPosition) = xProjection(pos.x.value) + yProjection(pos.y.value)
+ internal open fun project(pos: PxPosition) = xProjection(pos.x) + yProjection(pos.y)
/**
* Horizontal direction of dragging in [draggable] or [scrollable].
diff --git a/ui/ui-foundation/src/main/java/androidx/ui/foundation/gestures/Draggable.kt b/ui/ui-foundation/src/main/java/androidx/ui/foundation/gestures/Draggable.kt
index d5debc10..d929b46 100644
--- a/ui/ui-foundation/src/main/java/androidx/ui/foundation/gestures/Draggable.kt
+++ b/ui/ui-foundation/src/main/java/androidx/ui/foundation/gestures/Draggable.kt
@@ -26,7 +26,6 @@
import androidx.ui.foundation.Interaction
import androidx.ui.foundation.InteractionState
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.px
/**
* Configure touch dragging for the UI element in a single [DragDirection]. The drag distance is
@@ -89,8 +88,8 @@
dragState.value = dragState.value + consumed
val fractionConsumed = if (projected == 0f) 0f else consumed / projected
return PxPosition(
- dragDirection.xProjection(dragDistance.x.value).px * fractionConsumed,
- dragDirection.yProjection(dragDistance.y.value).px * fractionConsumed
+ dragDirection.xProjection(dragDistance.x) * fractionConsumed,
+ dragDirection.yProjection(dragDistance.y) * fractionConsumed
)
}
diff --git a/ui/ui-foundation/src/main/java/androidx/ui/foundation/gestures/Scrollable.kt b/ui/ui-foundation/src/main/java/androidx/ui/foundation/gestures/Scrollable.kt
index f65dd6b..d9c9ce6 100644
--- a/ui/ui-foundation/src/main/java/androidx/ui/foundation/gestures/Scrollable.kt
+++ b/ui/ui-foundation/src/main/java/androidx/ui/foundation/gestures/Scrollable.kt
@@ -34,7 +34,6 @@
import androidx.ui.foundation.animation.FlingConfig
import androidx.ui.foundation.animation.fling
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.px
/**
* Create [ScrollableState] for [scrollable] with default [FlingConfig] and
@@ -185,8 +184,8 @@
scrollableState.value = scrollableState.value + consumed
val fractionConsumed = if (projected == 0f) 0f else consumed / projected
return PxPosition(
- dragDirection.xProjection(dragDistance.x.value).px * fractionConsumed,
- dragDirection.yProjection(dragDistance.y.value).px * fractionConsumed
+ dragDirection.xProjection(dragDistance.x) * fractionConsumed,
+ dragDirection.yProjection(dragDistance.y) * fractionConsumed
)
}
diff --git a/ui/ui-foundation/src/main/java/androidx/ui/foundation/selection/MutuallyExclusiveSetItem.kt b/ui/ui-foundation/src/main/java/androidx/ui/foundation/selection/MutuallyExclusiveSetItem.kt
deleted file mode 100644
index 19219f7..0000000
--- a/ui/ui-foundation/src/main/java/androidx/ui/foundation/selection/MutuallyExclusiveSetItem.kt
+++ /dev/null
@@ -1,64 +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 androidx.ui.foundation.selection
-
-import androidx.compose.Composable
-import androidx.ui.core.Modifier
-import androidx.ui.core.PassThroughLayout
-import androidx.ui.core.gesture.tapGestureFilter
-import androidx.ui.foundation.Strings
-import androidx.ui.foundation.semantics.inMutuallyExclusiveGroup
-import androidx.ui.foundation.semantics.selected
-import androidx.ui.semantics.Semantics
-import androidx.ui.semantics.accessibilityValue
-import androidx.ui.semantics.onClick
-
-/**
- * Component for representing one option out of many
- * in mutually exclusion set, e.g [androidx.ui.material.RadioGroup]
- *
- * Provides click handling as well as [Semantics] for accessibility
- *
- * @param selected whether or not this item is selected in mutually exclusion set
- * @param onClick callback to invoke when this item is clicked
- * @param modifier allows to provide a modifier to be added before the gesture detector, for
- * example Ripple should be added at this point. this will be easier once we migrate this
- * function to a Modifier
- */
-@Composable
-fun MutuallyExclusiveSetItem(
- selected: Boolean,
- onClick: () -> Unit,
- modifier: Modifier = Modifier,
- children: @Composable () -> Unit
-) {
- // TODO: when semantics can be merged, we should make this use Clickable internally rather
- // than duplicating logic
- Semantics(
- container = true,
- properties = {
- inMutuallyExclusiveGroup = true
- this.selected = selected
- this.accessibilityValue = if (selected) Strings.Selected else Strings.NotSelected
- onClick(action = { onClick(); return@onClick true })
- }) {
- // TODO(b/150706555): This layout is temporary and should be removed once Semantics
- // is implemented with modifiers.
- @Suppress("DEPRECATION")
- PassThroughLayout(modifier.tapGestureFilter { onClick() }, children)
- }
-}
\ No newline at end of file
diff --git a/ui/ui-foundation/src/main/java/androidx/ui/foundation/selection/Selectable.kt b/ui/ui-foundation/src/main/java/androidx/ui/foundation/selection/Selectable.kt
new file mode 100644
index 0000000..d486d31
--- /dev/null
+++ b/ui/ui-foundation/src/main/java/androidx/ui/foundation/selection/Selectable.kt
@@ -0,0 +1,129 @@
+/*
+ * 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.ui.foundation.selection
+
+import androidx.compose.Composable
+import androidx.compose.remember
+import androidx.ui.core.Modifier
+import androidx.ui.core.PassThroughLayout
+import androidx.ui.core.composed
+import androidx.ui.core.gesture.tapGestureFilter
+import androidx.ui.core.semantics.semantics
+import androidx.ui.foundation.Indication
+import androidx.ui.foundation.IndicationAmbient
+import androidx.ui.foundation.Interaction
+import androidx.ui.foundation.InteractionState
+import androidx.ui.foundation.Strings
+import androidx.ui.foundation.clickable
+import androidx.ui.foundation.semantics.inMutuallyExclusiveGroup
+import androidx.ui.foundation.semantics.selected
+import androidx.ui.semantics.Semantics
+import androidx.ui.semantics.accessibilityValue
+import androidx.ui.semantics.onClick
+
+/**
+ * Component for representing one option out of many
+ * in mutually exclusion set, e.g [androidx.ui.material.RadioGroup]
+ *
+ * Provides click handling as well as [Semantics] for accessibility
+ *
+ * @param selected whether or not this item is selected in mutually exclusion set
+ * @param onClick callback to invoke when this item is clicked
+ * @param modifier allows to provide a modifier to be added before the gesture detector, for
+ * example Ripple should be added at this point. this will be easier once we migrate this
+ * function to a Modifier
+ *
+ * @Deprecated Use [Modifier.selectable] instead.
+ */
+@Deprecated(
+ "MutuallyExclusiveSetItem has been deprecated, use Modifier.selectable " +
+ "instead",
+ ReplaceWith(
+ "Box(modifier.selectable(" +
+ "selected = selected, " +
+ "onClick = onClick" +
+ ")," +
+ " children = children)",
+ "androidx.foundation.selectable",
+ "androidx.foundation.Box"
+ )
+)
+@Composable
+fun MutuallyExclusiveSetItem(
+ selected: Boolean,
+ onClick: () -> Unit,
+ modifier: Modifier = Modifier,
+ children: @Composable () -> Unit
+) {
+ // TODO: when semantics can be merged, we should make this use Clickable internally rather
+ // than duplicating logic
+ Semantics(
+ container = true,
+ properties = {
+ inMutuallyExclusiveGroup = true
+ this.selected = selected
+ this.accessibilityValue = if (selected) Strings.Selected else Strings.NotSelected
+ onClick(action = { onClick(); return@onClick true })
+ }) {
+ // TODO(b/150706555): This layout is temporary and should be removed once Semantics
+ // is implemented with modifiers.
+ @Suppress("DEPRECATION")
+ PassThroughLayout(modifier.tapGestureFilter { onClick() }, children)
+ }
+}
+
+/**
+ * Configure component to be selectable, usually as a part of a mutually exclusive group, where
+ * only one item can be selected at any point in time. A typical example of mutually exclusive set
+ * is [androidx.ui.material.RadioGroup]
+ *
+ * If you want to make an item support on/off capabilities without being part of a set, consider
+ * using [Modifier.toggleable]
+ *
+ * @sample androidx.ui.foundation.samples.SelectableSample
+ *
+ * @param selected whether or not this item is selected in a mutually exclusion set
+ * @param onClick callback to invoke when this item is clicked
+ * @param enabled whether or not this [selectable] will handle input events
+ * and appear enabled from a semantics perspective
+ * @param inMutuallyExclusiveGroup whether or not this item is a part of mutually exclusive
+ * group, meaning that only one of these items can be selected at any point of time
+ * @param interactionState [InteractionState] that will be updated when this element is
+ * pressed, using [Interaction.Pressed]
+ * @param indication indication to be shown when the modified element is pressed. By default,
+ * the indication from [IndicationAmbient] will be used. Set to `null` to show no indication
+ */
+@Composable
+fun Modifier.selectable(
+ selected: Boolean,
+ onClick: () -> Unit,
+ enabled: Boolean = true,
+ inMutuallyExclusiveGroup: Boolean = true,
+ interactionState: InteractionState = remember { InteractionState() },
+ indication: Indication? = IndicationAmbient.current()
+) = composed {
+ Modifier.clickable(
+ enabled = enabled,
+ interactionState = interactionState,
+ indication = indication,
+ onClick = onClick
+ ).semantics(properties = {
+ this.inMutuallyExclusiveGroup = inMutuallyExclusiveGroup
+ this.selected = selected
+ this.accessibilityValue = if (selected) Strings.Selected else Strings.NotSelected
+ })
+}
\ No newline at end of file
diff --git a/ui/ui-foundation/src/main/java/androidx/ui/foundation/shape/corner/CutCornerShape.kt b/ui/ui-foundation/src/main/java/androidx/ui/foundation/shape/corner/CutCornerShape.kt
index 04c4e2b..b05ad8f 100644
--- a/ui/ui-foundation/src/main/java/androidx/ui/foundation/shape/corner/CutCornerShape.kt
+++ b/ui/ui-foundation/src/main/java/androidx/ui/foundation/shape/corner/CutCornerShape.kt
@@ -22,7 +22,6 @@
import androidx.ui.graphics.Outline
import androidx.ui.graphics.Path
import androidx.ui.unit.Dp
-import androidx.ui.unit.Px
import androidx.ui.unit.dp
/**
@@ -97,7 +96,7 @@
/**
* Creates [CutCornerShape] with the same size applied for all four corners.
- * @param size Size in [Px] to apply.
+ * @param size Size in pixels to apply.
*/
/*inline*/ fun CutCornerShape(size: Float) = CutCornerShape(CornerSize(size))
diff --git a/ui/ui-layout/api/0.1.0-dev14.txt b/ui/ui-layout/api/0.1.0-dev14.txt
index d1db5d8..8b810dc 100644
--- a/ui/ui-layout/api/0.1.0-dev14.txt
+++ b/ui/ui-layout/api/0.1.0-dev14.txt
@@ -357,7 +357,7 @@
public final class LayoutOffsetKt {
method @androidx.compose.Stable public static androidx.ui.core.Modifier offset-qJOR85M(androidx.ui.core.Modifier, float x = 0.dp, float y = 0.dp);
- method public static androidx.ui.core.Modifier offsetPx(androidx.ui.core.Modifier, androidx.compose.State<androidx.ui.unit.Px> x = mutableStateOf(Px.Zero), androidx.compose.State<androidx.ui.unit.Px> y = mutableStateOf(Px.Zero));
+ method public static androidx.ui.core.Modifier offsetPx(androidx.ui.core.Modifier, androidx.compose.State<java.lang.Float> x = mutableStateOf(0.0), androidx.compose.State<java.lang.Float> y = mutableStateOf(0.0));
}
public final class LayoutPaddingKt {
diff --git a/ui/ui-layout/api/current.txt b/ui/ui-layout/api/current.txt
index d1db5d8..8b810dc 100644
--- a/ui/ui-layout/api/current.txt
+++ b/ui/ui-layout/api/current.txt
@@ -357,7 +357,7 @@
public final class LayoutOffsetKt {
method @androidx.compose.Stable public static androidx.ui.core.Modifier offset-qJOR85M(androidx.ui.core.Modifier, float x = 0.dp, float y = 0.dp);
- method public static androidx.ui.core.Modifier offsetPx(androidx.ui.core.Modifier, androidx.compose.State<androidx.ui.unit.Px> x = mutableStateOf(Px.Zero), androidx.compose.State<androidx.ui.unit.Px> y = mutableStateOf(Px.Zero));
+ method public static androidx.ui.core.Modifier offsetPx(androidx.ui.core.Modifier, androidx.compose.State<java.lang.Float> x = mutableStateOf(0.0), androidx.compose.State<java.lang.Float> y = mutableStateOf(0.0));
}
public final class LayoutPaddingKt {
diff --git a/ui/ui-layout/api/public_plus_experimental_0.1.0-dev14.txt b/ui/ui-layout/api/public_plus_experimental_0.1.0-dev14.txt
index d1db5d8..8b810dc 100644
--- a/ui/ui-layout/api/public_plus_experimental_0.1.0-dev14.txt
+++ b/ui/ui-layout/api/public_plus_experimental_0.1.0-dev14.txt
@@ -357,7 +357,7 @@
public final class LayoutOffsetKt {
method @androidx.compose.Stable public static androidx.ui.core.Modifier offset-qJOR85M(androidx.ui.core.Modifier, float x = 0.dp, float y = 0.dp);
- method public static androidx.ui.core.Modifier offsetPx(androidx.ui.core.Modifier, androidx.compose.State<androidx.ui.unit.Px> x = mutableStateOf(Px.Zero), androidx.compose.State<androidx.ui.unit.Px> y = mutableStateOf(Px.Zero));
+ method public static androidx.ui.core.Modifier offsetPx(androidx.ui.core.Modifier, androidx.compose.State<java.lang.Float> x = mutableStateOf(0.0), androidx.compose.State<java.lang.Float> y = mutableStateOf(0.0));
}
public final class LayoutPaddingKt {
diff --git a/ui/ui-layout/api/public_plus_experimental_current.txt b/ui/ui-layout/api/public_plus_experimental_current.txt
index d1db5d8..8b810dc 100644
--- a/ui/ui-layout/api/public_plus_experimental_current.txt
+++ b/ui/ui-layout/api/public_plus_experimental_current.txt
@@ -357,7 +357,7 @@
public final class LayoutOffsetKt {
method @androidx.compose.Stable public static androidx.ui.core.Modifier offset-qJOR85M(androidx.ui.core.Modifier, float x = 0.dp, float y = 0.dp);
- method public static androidx.ui.core.Modifier offsetPx(androidx.ui.core.Modifier, androidx.compose.State<androidx.ui.unit.Px> x = mutableStateOf(Px.Zero), androidx.compose.State<androidx.ui.unit.Px> y = mutableStateOf(Px.Zero));
+ method public static androidx.ui.core.Modifier offsetPx(androidx.ui.core.Modifier, androidx.compose.State<java.lang.Float> x = mutableStateOf(0.0), androidx.compose.State<java.lang.Float> y = mutableStateOf(0.0));
}
public final class LayoutPaddingKt {
diff --git a/ui/ui-layout/api/restricted_0.1.0-dev14.txt b/ui/ui-layout/api/restricted_0.1.0-dev14.txt
index d1db5d8..8b810dc 100644
--- a/ui/ui-layout/api/restricted_0.1.0-dev14.txt
+++ b/ui/ui-layout/api/restricted_0.1.0-dev14.txt
@@ -357,7 +357,7 @@
public final class LayoutOffsetKt {
method @androidx.compose.Stable public static androidx.ui.core.Modifier offset-qJOR85M(androidx.ui.core.Modifier, float x = 0.dp, float y = 0.dp);
- method public static androidx.ui.core.Modifier offsetPx(androidx.ui.core.Modifier, androidx.compose.State<androidx.ui.unit.Px> x = mutableStateOf(Px.Zero), androidx.compose.State<androidx.ui.unit.Px> y = mutableStateOf(Px.Zero));
+ method public static androidx.ui.core.Modifier offsetPx(androidx.ui.core.Modifier, androidx.compose.State<java.lang.Float> x = mutableStateOf(0.0), androidx.compose.State<java.lang.Float> y = mutableStateOf(0.0));
}
public final class LayoutPaddingKt {
diff --git a/ui/ui-layout/api/restricted_current.txt b/ui/ui-layout/api/restricted_current.txt
index d1db5d8..8b810dc 100644
--- a/ui/ui-layout/api/restricted_current.txt
+++ b/ui/ui-layout/api/restricted_current.txt
@@ -357,7 +357,7 @@
public final class LayoutOffsetKt {
method @androidx.compose.Stable public static androidx.ui.core.Modifier offset-qJOR85M(androidx.ui.core.Modifier, float x = 0.dp, float y = 0.dp);
- method public static androidx.ui.core.Modifier offsetPx(androidx.ui.core.Modifier, androidx.compose.State<androidx.ui.unit.Px> x = mutableStateOf(Px.Zero), androidx.compose.State<androidx.ui.unit.Px> y = mutableStateOf(Px.Zero));
+ method public static androidx.ui.core.Modifier offsetPx(androidx.ui.core.Modifier, androidx.compose.State<java.lang.Float> x = mutableStateOf(0.0), androidx.compose.State<java.lang.Float> y = mutableStateOf(0.0));
}
public final class LayoutPaddingKt {
diff --git a/ui/ui-layout/samples/src/main/java/androidx/ui/layout/samples/LayoutOffsetSample.kt b/ui/ui-layout/samples/src/main/java/androidx/ui/layout/samples/LayoutOffsetSample.kt
index 1e69347..2342975 100644
--- a/ui/ui-layout/samples/src/main/java/androidx/ui/layout/samples/LayoutOffsetSample.kt
+++ b/ui/ui-layout/samples/src/main/java/androidx/ui/layout/samples/LayoutOffsetSample.kt
@@ -28,7 +28,6 @@
import androidx.ui.layout.offsetPx
import androidx.ui.layout.wrapContentSize
import androidx.ui.unit.dp
-import androidx.ui.unit.px
@Sampled
@Composable
@@ -46,11 +45,11 @@
@Composable
fun LayoutOffsetPxModifier() {
// This text will be offset in steps of 10.dp from the top left of the available space.
- val offset = state { 0.px }
+ val offset = state { 0f }
Text(
"Layout offset modifier sample",
Modifier
- .tapGestureFilter { offset.value += 10.px }
+ .tapGestureFilter { offset.value += 10f }
.offsetPx(offset, offset)
)
}
diff --git a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/AlignmentLineTest.kt b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/AlignmentLineTest.kt
index 7e5788a..f2fddbc 100644
--- a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/AlignmentLineTest.kt
+++ b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/AlignmentLineTest.kt
@@ -88,10 +88,10 @@
Assert.assertEquals(childSize.value!!.height, parentSize.value!!.height)
Assert.assertNotNull(childPosition.value)
Assert.assertEquals(
- beforeDp.toIntPx().toPx() - lineDp.toIntPx().toPx(),
+ (beforeDp.toIntPx().toPx() - lineDp.toIntPx().toPx()).value,
childPosition.value!!.x
)
- Assert.assertEquals(0.px, childPosition.value!!.y)
+ Assert.assertEquals(0f, childPosition.value!!.y)
}
@Test
@@ -134,9 +134,9 @@
Assert.assertNotNull(parentSize.value)
Assert.assertEquals(beforeDp.toIntPx() + afterDp.toIntPx(), parentSize.value!!.height)
Assert.assertNotNull(childPosition.value)
- Assert.assertEquals(0.px, childPosition.value!!.x)
+ Assert.assertEquals(0f, childPosition.value!!.x)
Assert.assertEquals(
- beforeDp.toIntPx().toPx() - lineDp.toIntPx().toPx(),
+ (beforeDp.toIntPx().toPx() - lineDp.toIntPx().toPx()).value,
childPosition.value!!.y
)
}
@@ -171,8 +171,8 @@
Assert.assertNotNull(childSize.value)
Assert.assertEquals(childSize.value, parentSize.value)
Assert.assertNotNull(childPosition.value)
- Assert.assertEquals(0.px, childPosition.value!!.x)
- Assert.assertEquals(0.px, childPosition.value!!.y)
+ Assert.assertEquals(0f, childPosition.value!!.x)
+ Assert.assertEquals(0f, childPosition.value!!.y)
}
@Test
@@ -205,8 +205,8 @@
Assert.assertNotNull(childSize.value)
Assert.assertEquals(childSize.value, parentSize.value)
Assert.assertNotNull(childPosition.value)
- Assert.assertEquals(0.px, childPosition.value!!.x)
- Assert.assertEquals(0.px, childPosition.value!!.y)
+ Assert.assertEquals(0f, childPosition.value!!.x)
+ Assert.assertEquals(0f, childPosition.value!!.y)
}
@Test
@@ -246,8 +246,8 @@
Assert.assertNotNull(childSize.value)
Assert.assertEquals(childSize.value!!.height, parentSize.value!!.height)
Assert.assertNotNull(childPosition.value)
- Assert.assertEquals(5.px, childPosition.value!!.x)
- Assert.assertEquals(0.px, childPosition.value!!.y)
+ Assert.assertEquals(5f, childPosition.value!!.x)
+ Assert.assertEquals(0f, childPosition.value!!.y)
}
@Test
@@ -287,8 +287,8 @@
Assert.assertNotNull(parentSize.value)
Assert.assertEquals(maxHeight.toIntPx(), parentSize.value!!.height)
Assert.assertNotNull(childPosition.value)
- Assert.assertEquals(0.px, childPosition.value!!.x)
- Assert.assertEquals(5.px, childPosition.value!!.y)
+ Assert.assertEquals(0f, childPosition.value!!.x)
+ Assert.assertEquals(5f, childPosition.value!!.y)
}
@Test
diff --git a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/ContainerTest.kt b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/ContainerTest.kt
index cc62f65..381712a 100644
--- a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/ContainerTest.kt
+++ b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/ContainerTest.kt
@@ -37,7 +37,6 @@
import androidx.ui.unit.PxPosition
import androidx.ui.unit.dp
import androidx.ui.unit.ipx
-import androidx.ui.unit.px
import androidx.ui.unit.round
import androidx.ui.unit.toPx
import org.junit.Assert.assertEquals
@@ -94,7 +93,7 @@
) {
EmptyBox(width = sizeDp, height = sizeDp,
modifier = Modifier.onPositioned { coordinates ->
- childPosition.value = coordinates.localToGlobal(PxPosition(0.px, 0.px))
+ childPosition.value = coordinates.localToGlobal(PxPosition(0f, 0f))
positionedLatch.countDown()
}
)
@@ -198,7 +197,7 @@
height = sizeDp,
modifier = Modifier.onPositioned { coordinates: LayoutCoordinates ->
childSize.value = coordinates.size
- childPosition.value = coordinates.localToGlobal(PxPosition(0.px, 0.px))
+ childPosition.value = coordinates.localToGlobal(PxPosition(0f, 0f))
positionedLatch.countDown()
})
}
@@ -244,7 +243,7 @@
modifier = Modifier.onPositioned { coordinates: LayoutCoordinates ->
childSize.value = coordinates.size
childPosition.value =
- coordinates.localToGlobal(PxPosition(0.px, 0.px))
+ coordinates.localToGlobal(PxPosition(0f, 0f))
positionedLatch.countDown()
})
}
diff --git a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/IntrinsicTest.kt b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/IntrinsicTest.kt
index ade1f50..1016f91 100644
--- a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/IntrinsicTest.kt
+++ b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/IntrinsicTest.kt
@@ -35,7 +35,6 @@
import androidx.ui.unit.PxPosition
import androidx.ui.unit.dp
import androidx.ui.unit.ipx
-import androidx.ui.unit.px
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test
@@ -74,7 +73,7 @@
assertEquals(IntPxSize(10.dp.toIntPx(), 50.dp.toIntPx()), minIntrinsicWidthSize.value)
assertEquals(IntPxSize(10.dp.toIntPx(), 50.dp.toIntPx()), childSize.value)
- assertEquals(PxPosition(0.px, 0.px), childPosition.value)
+ assertEquals(PxPosition(0f, 0f), childPosition.value)
}
@Test
@@ -103,7 +102,7 @@
assertEquals(IntPxSize(20.dp.toIntPx(), 40.dp.toIntPx()), minIntrinsicHeightSize.value)
assertEquals(IntPxSize(20.dp.toIntPx(), 40.dp.toIntPx()), childSize.value)
- assertEquals(PxPosition(0.px, 0.px), childPosition.value)
+ assertEquals(PxPosition(0f, 0f), childPosition.value)
}
@Test
@@ -132,7 +131,7 @@
assertEquals(IntPxSize(30.dp.toIntPx(), 50.dp.toIntPx()), maxIntrinsicWidthSize.value)
assertEquals(IntPxSize(30.dp.toIntPx(), 50.dp.toIntPx()), childSize.value)
- assertEquals(PxPosition(0.px, 0.px), childPosition.value)
+ assertEquals(PxPosition(0f, 0f), childPosition.value)
}
@Test
@@ -161,7 +160,7 @@
assertEquals(IntPxSize(20.dp.toIntPx(), 60.dp.toIntPx()), maxIntrinsicHeightSize.value)
assertEquals(IntPxSize(20.dp.toIntPx(), 60.dp.toIntPx()), childSize.value)
- assertEquals(PxPosition(0.px, 0.px), childPosition.value)
+ assertEquals(PxPosition(0f, 0f), childPosition.value)
}
@Test
@@ -194,7 +193,7 @@
assertEquals(IntPxSize(5.dp.toIntPx(), 50.dp.toIntPx()), minIntrinsicWidthSize.value)
assertEquals(IntPxSize(5.dp.toIntPx(), 50.dp.toIntPx()), childSize.value)
- assertEquals(PxPosition(0.px, 0.px), childPosition.value)
+ assertEquals(PxPosition(0f, 0f), childPosition.value)
}
@Test
@@ -227,7 +226,7 @@
assertEquals(IntPxSize(15.dp.toIntPx(), 50.dp.toIntPx()), minIntrinsicWidthSize.value)
assertEquals(IntPxSize(15.dp.toIntPx(), 50.dp.toIntPx()), childSize.value)
- assertEquals(PxPosition(0.px, 0.px), childPosition.value)
+ assertEquals(PxPosition(0f, 0f), childPosition.value)
}
@Test
@@ -258,7 +257,7 @@
assertEquals(IntPxSize(20.dp.toIntPx(), 35.dp.toIntPx()), minIntrinsicHeightSize.value)
assertEquals(IntPxSize(20.dp.toIntPx(), 35.dp.toIntPx()), childSize.value)
- assertEquals(PxPosition(0.px, 0.px), childPosition.value)
+ assertEquals(PxPosition(0f, 0f), childPosition.value)
}
@Test
@@ -289,7 +288,7 @@
assertEquals(IntPxSize(20.dp.toIntPx(), 45.dp.toIntPx()), minIntrinsicHeightSize.value)
assertEquals(IntPxSize(20.dp.toIntPx(), 45.dp.toIntPx()), childSize.value)
- assertEquals(PxPosition(0.px, 0.px), childPosition.value)
+ assertEquals(PxPosition(0f, 0f), childPosition.value)
}
@Test
@@ -320,7 +319,7 @@
assertEquals(IntPxSize(25.dp.toIntPx(), 50.dp.toIntPx()), maxIntrinsicWidthSize.value)
assertEquals(IntPxSize(25.dp.toIntPx(), 50.dp.toIntPx()), childSize.value)
- assertEquals(PxPosition(0.px, 0.px), childPosition.value)
+ assertEquals(PxPosition(0f, 0f), childPosition.value)
}
@Test
@@ -351,7 +350,7 @@
assertEquals(IntPxSize(35.dp.toIntPx(), 50.dp.toIntPx()), maxIntrinsicWidthSize.value)
assertEquals(IntPxSize(35.dp.toIntPx(), 50.dp.toIntPx()), childSize.value)
- assertEquals(PxPosition(0.px, 0.px), childPosition.value)
+ assertEquals(PxPosition(0f, 0f), childPosition.value)
}
@Test
@@ -382,7 +381,7 @@
assertEquals(IntPxSize(20.dp.toIntPx(), 55.dp.toIntPx()), maxIntrinsicHeightSize.value)
assertEquals(IntPxSize(20.dp.toIntPx(), 55.dp.toIntPx()), childSize.value)
- assertEquals(PxPosition(0.px, 0.px), childPosition.value)
+ assertEquals(PxPosition(0f, 0f), childPosition.value)
}
@Test
@@ -413,7 +412,7 @@
assertEquals(IntPxSize(20.dp.toIntPx(), 65.dp.toIntPx()), maxIntrinsicHeightSize.value)
assertEquals(IntPxSize(20.dp.toIntPx(), 65.dp.toIntPx()), childSize.value)
- assertEquals(PxPosition(0.px, 0.px), childPosition.value)
+ assertEquals(PxPosition(0f, 0f), childPosition.value)
}
@Test
diff --git a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/LayoutAlignTest.kt b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/LayoutAlignTest.kt
index 6b23d3f..5ec5cb0 100644
--- a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/LayoutAlignTest.kt
+++ b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/LayoutAlignTest.kt
@@ -80,10 +80,10 @@
waitForDraw(root)
assertEquals(IntPxSize(root.width.ipx, root.height.ipx), alignSize.value)
- assertEquals(PxPosition(0.px, 0.px), alignPosition.value)
+ assertEquals(PxPosition(0f, 0f), alignPosition.value)
assertEquals(IntPxSize(size, size), childSize.value)
assertEquals(
- PxPosition(root.width.px - size, root.height.px - size),
+ PxPosition((root.width.px - size).value, (root.height.px - size).value),
childPosition.value
)
}
@@ -121,9 +121,9 @@
waitForDraw(root)
assertEquals(IntPxSize(root.width.ipx, root.height.ipx), alignSize.value)
- assertEquals(PxPosition(0.px, 0.px), alignPosition.value)
+ assertEquals(PxPosition(0f, 0f), alignPosition.value)
assertEquals(IntPxSize(size, root.height.ipx), childSize.value)
- assertEquals(PxPosition(root.width.px - size, 0.px), childPosition.value)
+ assertEquals(PxPosition((root.width.px - size).value, 0f), childPosition.value)
}
@Test
@@ -236,9 +236,9 @@
waitForDraw(root)
assertEquals(IntPxSize(size, size), alignSize.value)
- assertEquals(PxPosition(0.px, 0.px), alignPosition.value)
+ assertEquals(PxPosition(0f, 0f), alignPosition.value)
assertEquals(IntPxSize(size, size), childSize.value)
- assertEquals(PxPosition(0.px, 0.px), childPosition.value)
+ assertEquals(PxPosition(0f, 0f), childPosition.value)
}
@Test
diff --git a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/LayoutOffsetTest.kt b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/LayoutOffsetTest.kt
index f013db09..0c1ef72 100644
--- a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/LayoutOffsetTest.kt
+++ b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/LayoutOffsetTest.kt
@@ -22,7 +22,7 @@
import androidx.ui.core.Alignment
import androidx.ui.core.LayoutCoordinates
import androidx.ui.core.Modifier
-import androidx.ui.core.TestTag
+import androidx.ui.core.testTag
import androidx.ui.core.globalPosition
import androidx.ui.core.onPositioned
import androidx.ui.foundation.Box
@@ -47,6 +47,7 @@
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
+import kotlin.math.roundToInt
@SmallTest
@RunWith(JUnit4::class)
@@ -69,16 +70,15 @@
var positionX = 0.ipx
var positionY = 0.ipx
composeTestRule.setContent {
- TestTag("stack") {
- Stack(
- Modifier.wrapContentSize(Alignment.TopStart)
- .offset(offsetX, offsetY)
- .onPositioned { coordinates: LayoutCoordinates ->
- positionX = coordinates.globalPosition.x.round()
- positionY = coordinates.globalPosition.y.round()
- }
- ) {
- }
+ Stack(
+ Modifier.testTag("stack")
+ .wrapContentSize(Alignment.TopStart)
+ .offset(offsetX, offsetY)
+ .onPositioned { coordinates: LayoutCoordinates ->
+ positionX = coordinates.globalPosition.x.px.round()
+ positionY = coordinates.globalPosition.y.px.round()
+ }
+ ) {
}
}
@@ -98,21 +98,20 @@
var positionX = 0.ipx
var positionY = 0.ipx
composeTestRule.setContent {
- TestTag("stack") {
- Stack(
- Modifier.rtl
- .wrapContentSize(Alignment.TopEnd)
- .preferredWidth(containerWidth)
- .wrapContentSize(Alignment.TopStart)
- .offset(offsetX, offsetY)
- .onPositioned { coordinates: LayoutCoordinates ->
- positionX = coordinates.globalPosition.x.round()
- positionY = coordinates.globalPosition.y.round()
- }
- ) {
- // TODO(popam): this box should not be needed after b/154758475 is fixed.
- Box(Modifier.size(boxSize.toDp()))
- }
+ Stack(
+ Modifier.testTag("stack")
+ .rtl
+ .wrapContentSize(Alignment.TopEnd)
+ .preferredWidth(containerWidth)
+ .wrapContentSize(Alignment.TopStart)
+ .offset(offsetX, offsetY)
+ .onPositioned { coordinates: LayoutCoordinates ->
+ positionX = coordinates.globalPosition.x.px.round()
+ positionY = coordinates.globalPosition.y.px.round()
+ }
+ ) {
+ // TODO(popam): this box should not be needed after b/154758475 is fixed.
+ Box(Modifier.size(boxSize.toDp()))
}
}
@@ -125,21 +124,20 @@
@Test
fun positionIsModified_px() = with(density) {
- val offsetX = 10.px
- val offsetY = 20.px
- var positionX = 0.px
- var positionY = 0.px
+ val offsetX = 10f
+ val offsetY = 20f
+ var positionX = 0f
+ var positionY = 0f
composeTestRule.setContent {
- TestTag("stack") {
- Stack(
- Modifier.wrapContentSize(Alignment.TopStart)
- .offsetPx(state { offsetX }, state { offsetY })
- .onPositioned { coordinates: LayoutCoordinates ->
- positionX = coordinates.globalPosition.x
- positionY = coordinates.globalPosition.y
- }
- ) {
- }
+ Stack(
+ Modifier.testTag("stack")
+ .wrapContentSize(Alignment.TopStart)
+ .offsetPx(state { offsetX }, state { offsetY })
+ .onPositioned { coordinates: LayoutCoordinates ->
+ positionX = coordinates.globalPosition.x
+ positionY = coordinates.globalPosition.y
+ }
+ ) {
}
}
@@ -153,35 +151,34 @@
@Test
fun positionIsModified_px_rtl() = with(density) {
val containerWidth = 30.dp
- val boxSize = 1.ipx
- val offsetX = 10.px
- val offsetY = 20.px
- var positionX = 0.px
- var positionY = 0.px
+ val boxSize = 1f
+ val offsetX = 10f
+ val offsetY = 20f
+ var positionX = 0f
+ var positionY = 0f
composeTestRule.setContent {
- TestTag("stack") {
- Stack(
- Modifier.rtl
- .wrapContentSize(Alignment.TopEnd)
- .preferredWidth(containerWidth)
- .wrapContentSize(Alignment.TopStart)
- .offsetPx(state { offsetX }, state { offsetY })
- .onPositioned { coordinates: LayoutCoordinates ->
- positionX = coordinates.globalPosition.x
- positionY = coordinates.globalPosition.y
- }
- ) {
- // TODO(popam): this box should not be needed after b/154758475 is fixed.
- Box(Modifier.size(boxSize.toDp()))
- }
+ Stack(
+ Modifier.testTag("stack")
+ .rtl
+ .wrapContentSize(Alignment.TopEnd)
+ .preferredWidth(containerWidth)
+ .wrapContentSize(Alignment.TopStart)
+ .offsetPx(state { offsetX }, state { offsetY })
+ .onPositioned { coordinates: LayoutCoordinates ->
+ positionX = coordinates.globalPosition.x
+ positionY = coordinates.globalPosition.y
+ }
+ ) {
+ // TODO(popam): this box should not be needed after b/154758475 is fixed.
+ Box(Modifier.size(boxSize.toDp()))
}
}
findByTag("stack").assertExists()
runOnIdleCompose {
Assert.assertEquals(
- containerWidth.toIntPx() - offsetX.round() - boxSize,
- positionX.round()
+ containerWidth.toIntPx().value - offsetX.roundToInt() - boxSize,
+ positionX
)
Assert.assertEquals(offsetY, positionY)
}
diff --git a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/LayoutPaddingTest.kt b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/LayoutPaddingTest.kt
index a3e00a3..4619854 100644
--- a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/LayoutPaddingTest.kt
+++ b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/LayoutPaddingTest.kt
@@ -45,7 +45,6 @@
import androidx.ui.unit.dp
import androidx.ui.unit.ipx
import androidx.ui.unit.min
-import androidx.ui.unit.px
import androidx.ui.unit.toPx
import androidx.ui.unit.toPxSize
import org.junit.Assert
@@ -252,7 +251,7 @@
val drawLatch = CountDownLatch(3)
val childSize = Array(3) { IntPxSize(0.ipx, 0.ipx) }
- val childPosition = Array(3) { PxPosition(0.px, 0.px) }
+ val childPosition = Array(3) { PxPosition(0f, 0f) }
// ltr: P1 S P2 | S P3 | P1 S
// rtl: S P1 | P3 S | P2 S P1
@@ -263,7 +262,7 @@
.preferredSize(sizeDp, sizeDp)
.onPositioned { coordinates: LayoutCoordinates ->
childSize[0] = coordinates.size
- childPosition[0] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
+ childPosition[0] = coordinates.localToGlobal(PxPosition(0f, 0f))
drawLatch.countDown()
}
) {
@@ -274,7 +273,7 @@
.preferredSize(sizeDp, sizeDp)
.onPositioned { coordinates: LayoutCoordinates ->
childSize[1] = coordinates.size
- childPosition[1] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
+ childPosition[1] = coordinates.localToGlobal(PxPosition(0f, 0f))
drawLatch.countDown()
}
) {
@@ -285,7 +284,7 @@
.preferredSize(sizeDp, sizeDp)
.onPositioned { coordinates: LayoutCoordinates ->
childSize[2] = coordinates.size
- childPosition[2] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
+ childPosition[2] = coordinates.localToGlobal(PxPosition(0f, 0f))
drawLatch.countDown()
}
) {
@@ -366,7 +365,7 @@
val drawLatch = CountDownLatch(1)
var childSize = IntPxSize(-1.ipx, -1.ipx)
- var childPosition = PxPosition(-1.px, -1.px)
+ var childPosition = PxPosition(-1f, -1f)
show {
Stack(Modifier.fillMaxSize()) {
ConstrainedBox(
@@ -376,7 +375,7 @@
val children = @Composable {
Container(Modifier.onPositioned { coordinates: LayoutCoordinates ->
childSize = coordinates.size
- childPosition = coordinates.localToGlobal(PxPosition(0.px, 0.px))
+ childPosition = coordinates.localToGlobal(PxPosition(0f, 0f))
drawLatch.countDown()
}) {
}
@@ -395,7 +394,7 @@
val left = ((root.width.ipx - size) / 2) + paddingPx
val top = ((root.height.ipx - size) / 2) + paddingPx
assertEquals(
- PxPosition(left.toPx(), top.toPx()),
+ PxPosition(left.toPx().value, top.toPx().value),
childPosition
)
}
@@ -412,7 +411,7 @@
val drawLatch = CountDownLatch(1)
var childSize = IntPxSize(-1.ipx, -1.ipx)
- var childPosition = PxPosition(-1.px, -1.px)
+ var childPosition = PxPosition(-1f, -1f)
show {
Stack(Modifier.fillMaxSize()) {
ConstrainedBox(
@@ -422,7 +421,7 @@
val children = @Composable {
Container(Modifier.onPositioned { coordinates: LayoutCoordinates ->
childSize = coordinates.size
- childPosition = coordinates.localToGlobal(PxPosition(0.px, 0.px))
+ childPosition = coordinates.localToGlobal(PxPosition(0f, 0f))
drawLatch.countDown()
}) {
}
@@ -450,7 +449,7 @@
val viewLeft = ((root.width.ipx - size) / 2) + paddingLeft
val viewTop = ((root.height.ipx - size) / 2) + paddingTop
assertEquals(
- PxPosition(viewLeft.toPx(), viewTop.toPx()),
+ PxPosition(viewLeft.toPx().value, viewTop.toPx().value),
childPosition
)
}
@@ -465,7 +464,7 @@
val drawLatch = CountDownLatch(1)
var childSize = IntPxSize(-1.ipx, -1.ipx)
- var childPosition = PxPosition(-1.px, -1.px)
+ var childPosition = PxPosition(-1f, -1f)
show {
Stack(Modifier.fillMaxSize()) {
ConstrainedBox(
@@ -475,7 +474,7 @@
paddingContainer {
Container(Modifier.onPositioned { coordinates: LayoutCoordinates ->
childSize = coordinates.size
- childPosition = coordinates.localToGlobal(PxPosition(0.px, 0.px))
+ childPosition = coordinates.localToGlobal(PxPosition(0f, 0f))
drawLatch.countDown()
}) {
}
@@ -491,7 +490,7 @@
assertEquals(IntPxSize(0.ipx, 0.ipx), childSize)
val left = ((root.width.ipx - size) / 2) + paddingPx
val top = ((root.height.ipx - size) / 2) + paddingPx
- assertEquals(PxPosition(left.toPx(), top.toPx()), childPosition)
+ assertEquals(PxPosition(left.toPx().value, top.toPx().value), childPosition)
}
/**
diff --git a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/LayoutTest.kt b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/LayoutTest.kt
index 66abc3d..f7e2304 100644
--- a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/LayoutTest.kt
+++ b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/LayoutTest.kt
@@ -145,7 +145,7 @@
positionedLatch: CountDownLatch
): Modifier = this.onPositioned { coordinates ->
size.value = IntPxSize(coordinates.size.width, coordinates.size.height)
- position.value = coordinates.localToGlobal(PxPosition(0.px, 0.px))
+ position.value = coordinates.localToGlobal(PxPosition(0f, 0f))
positionedLatch.countDown()
}
@@ -248,21 +248,21 @@
actual as PxSize
assertEquals(
- "Expected width ${expected.width.value} but obtained ${actual.width.value}",
- expected.width.value,
- actual.width.value,
+ "Expected width ${expected.width} but obtained ${actual.width}",
+ expected.width,
+ actual.width,
0f
)
assertEquals(
- "Expected height ${expected.height.value} but obtained ${actual.height.value}",
- expected.height.value,
- actual.height.value,
+ "Expected height ${expected.height} but obtained ${actual.height}",
+ expected.height,
+ actual.height,
0f
)
- if (actual.width.value != actual.width.value.toInt().toFloat()) {
+ if (actual.width != actual.width.toInt().toFloat()) {
fail("Expected integer width")
}
- if (actual.height.value != actual.height.value.toInt().toFloat()) {
+ if (actual.height != actual.height.toInt().toFloat()) {
fail("Expected integer height")
}
}
@@ -274,21 +274,21 @@
actual as PxPosition
assertEquals(
- "Expected x ${expected.x.value} but obtained ${actual.x.value}",
- expected.x.value,
- actual.x.value,
+ "Expected x ${expected.x} but obtained ${actual.x}",
+ expected.x,
+ actual.x,
0f
)
assertEquals(
- "Expected y ${expected.y.value} but obtained ${actual.y.value}",
- expected.y.value,
- actual.y.value,
+ "Expected y ${expected.y} but obtained ${actual.y}",
+ expected.y,
+ actual.y,
0f
)
- if (actual.x.value != actual.x.value.toInt().toFloat()) {
+ if (actual.x != actual.x.toInt().toFloat()) {
fail("Expected integer x coordinate")
}
- if (actual.y.value != actual.y.value.toInt().toFloat()) {
+ if (actual.y != actual.y.toInt().toFloat()) {
fail("Expected integer y coordinate")
}
}
diff --git a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/OnPositionedTest.kt b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/OnPositionedTest.kt
index 4e2cfb2..751f701 100644
--- a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/OnPositionedTest.kt
+++ b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/OnPositionedTest.kt
@@ -37,7 +37,6 @@
import androidx.ui.layout.fillMaxSize
import androidx.ui.layout.padding
import androidx.ui.unit.Dp
-import androidx.ui.unit.Px
import androidx.ui.unit.PxPosition
import androidx.ui.unit.dp
import androidx.ui.unit.ipx
@@ -51,6 +50,7 @@
import org.junit.runners.JUnit4
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
+import kotlin.math.roundToInt
@SmallTest
@RunWith(JUnit4::class)
@@ -58,10 +58,10 @@
@Test
fun simplePadding() = with(density) {
- val paddingLeftPx = 100.px
- val paddingTopPx = 120.px
- var realLeft: Px? = null
- var realTop: Px? = null
+ val paddingLeftPx = 100.0f
+ val paddingTopPx = 120.0f
+ var realLeft: Float? = null
+ var realTop: Float? = null
val positionedLatch = CountDownLatch(1)
show {
@@ -86,8 +86,8 @@
fun simplePaddingWithChildPositioned() = with(density) {
val paddingLeftPx = 100.px
val paddingTopPx = 120.px
- var realLeft: Px? = null
- var realTop: Px? = null
+ var realLeft: Float? = null
+ var realTop: Float? = null
val positionedLatch = CountDownLatch(1)
show {
@@ -108,8 +108,8 @@
}
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
- assertThat(realLeft).isEqualTo(paddingLeftPx)
- assertThat(realTop).isEqualTo(paddingTopPx)
+ assertThat(realLeft?.px).isEqualTo(paddingLeftPx)
+ assertThat(realTop?.px).isEqualTo(paddingTopPx)
}
@Test
@@ -146,17 +146,17 @@
// global position
val gPos = childCoordinates!!.localToGlobal(PxPosition.Origin).x
- assertThat(gPos).isEqualTo(firstPaddingPx + secondPaddingPx + thirdPaddingPx)
+ assertThat(gPos).isEqualTo((firstPaddingPx + secondPaddingPx + thirdPaddingPx).value)
// Position in grandparent Px(value=50.0)
val gpPos = gpCoordinates!!.childToLocal(childCoordinates!!, PxPosition.Origin).x
- assertThat(gpPos).isEqualTo(secondPaddingPx + thirdPaddingPx)
+ assertThat(gpPos).isEqualTo((secondPaddingPx + thirdPaddingPx).value)
// local position
- assertThat(childCoordinates!!.positionInParent.x).isEqualTo(thirdPaddingPx)
+ assertThat(childCoordinates!!.positionInParent.x).isEqualTo(thirdPaddingPx.value)
}
@Test
fun childPositionedForTwoContainers() = with(density) {
- val size = 100.px
+ val size = 100.0f
val sizeDp = size.toDp()
var firstCoordinates: LayoutCoordinates? = null
var secondCoordinates: LayoutCoordinates? = null
@@ -177,7 +177,7 @@
}
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
- assertThat(0.px).isEqualTo(firstCoordinates!!.positionInParent.x)
+ assertThat(0.0f).isEqualTo(firstCoordinates!!.positionInParent.x)
assertThat(size).isEqualTo(secondCoordinates!!.positionInParent.x)
}
@@ -237,7 +237,7 @@
@Test
fun testRepositionTriggersCallback() {
val left = mutableStateOf(30.dp)
- var realLeft: Px? = null
+ var realLeft: Float? = null
var positionedLatch = CountDownLatch(1)
show {
@@ -260,7 +260,7 @@
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
with(density) {
- assertThat(realLeft).isEqualTo(40.dp.toPx().px)
+ assertThat(realLeft).isEqualTo(40.dp.toPx())
}
}
@@ -279,7 +279,7 @@
Container(width = 10.dp, height = 10.dp) {
Container(
Modifier.onPositioned {
- realLeft = it.positionInRoot.x.value
+ realLeft = it.positionInRoot.x
positionedLatch.countDown()
},
width = 10.dp,
@@ -325,7 +325,9 @@
// simple copy of Padding which doesn't recompose when the size changes
Layout(children) { measurables, constraints, _ ->
layout(constraints.maxWidth, constraints.maxHeight) {
- measurables.first().measure(constraints).place(sizeModel.value.toPx().px, 0.px)
+ measurables.first().measure(constraints).place(
+ sizeModel.value.toPx().roundToInt().ipx,
+ 0.ipx)
}
}
}
diff --git a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/RowColumnTest.kt b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/RowColumnTest.kt
index 176200a..3a8a3f5 100644
--- a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/RowColumnTest.kt
+++ b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/RowColumnTest.kt
@@ -81,7 +81,7 @@
val drawLatch = CountDownLatch(2)
val childSize = arrayOf(IntPxSize(-1.ipx, -1.ipx), IntPxSize(-1.ipx, -1.ipx))
- val childPosition = arrayOf(PxPosition(-1.px, -1.px), PxPosition(-1.px, -1.px))
+ val childPosition = arrayOf(PxPosition(-1f, -1f), PxPosition(-1f, -1f))
show {
Container(alignment = Alignment.TopStart) {
Row {
@@ -90,7 +90,7 @@
height = sizeDp,
modifier = Modifier.onPositioned { coordinates: LayoutCoordinates ->
childSize[0] = coordinates.size
- childPosition[0] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
+ childPosition[0] = coordinates.localToGlobal(PxPosition(0f, 0f))
drawLatch.countDown()
}
) {
@@ -101,7 +101,7 @@
height = (sizeDp * 2),
modifier = Modifier.onPositioned { coordinates: LayoutCoordinates ->
childSize[1] = coordinates.size
- childPosition[1] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
+ childPosition[1] = coordinates.localToGlobal(PxPosition(0f, 0f))
drawLatch.countDown()
}
) {
@@ -119,8 +119,8 @@
IntPxSize((sizeDp.toPx() * 2).roundToInt().ipx, (sizeDp.toPx() * 2).roundToInt().ipx),
childSize[1]
)
- assertEquals(PxPosition(0.px, 0.px), childPosition[0])
- assertEquals(PxPosition(size.toPx(), 0.px), childPosition[1])
+ assertEquals(PxPosition(0f, 0f), childPosition[0])
+ assertEquals(PxPosition(size.toPx().value, 0f), childPosition[1])
}
@Test
@@ -139,7 +139,7 @@
Modifier.weight(1f)
.onPositioned { coordinates: LayoutCoordinates ->
childSize[0] = coordinates.size
- childPosition[0] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
+ childPosition[0] = coordinates.localToGlobal(PxPosition(0f, 0f))
drawLatch.countDown()
},
width = width,
@@ -151,7 +151,7 @@
Modifier.weight(2f)
.onPositioned { coordinates: LayoutCoordinates ->
childSize[1] = coordinates.size
- childPosition[1] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
+ childPosition[1] = coordinates.localToGlobal(PxPosition(0f, 0f))
drawLatch.countDown()
},
width = width,
@@ -175,8 +175,8 @@
IntPxSize((rootWidth * 2 / 3).round(), childrenHeight),
childSize[1]
)
- assertEquals(PxPosition(0.px, 0.px), childPosition[0])
- assertEquals(PxPosition((rootWidth / 3).round().toPx(), 0.px), childPosition[1])
+ assertEquals(PxPosition(0f, 0f), childPosition[0])
+ assertEquals(PxPosition((rootWidth / 3).round().toPx().value, 0f), childPosition[1])
}
@Test
@@ -196,7 +196,7 @@
Modifier.weight(1f, fill = false)
.onPositioned { coordinates: LayoutCoordinates ->
childSize[0] = coordinates.size
- childPosition[0] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
+ childPosition[0] = coordinates.localToGlobal(PxPosition(0f, 0f))
drawLatch.countDown()
},
width = width,
@@ -208,7 +208,7 @@
Modifier.weight(2f, fill = false)
.onPositioned { coordinates: LayoutCoordinates ->
childSize[1] = coordinates.size
- childPosition[1] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
+ childPosition[1] = coordinates.localToGlobal(PxPosition(0f, 0f))
drawLatch.countDown()
},
width = width,
@@ -225,8 +225,8 @@
assertEquals(IntPxSize(childrenWidth, childrenHeight), childSize[0])
assertEquals(IntPxSize(childrenWidth, childrenHeight * 2), childSize[1])
- assertEquals(PxPosition(0.px, 0.px), childPosition[0])
- assertEquals(PxPosition(childrenWidth.toPx(), 0.px), childPosition[1])
+ assertEquals(PxPosition(0f, 0f), childPosition[0])
+ assertEquals(PxPosition(childrenWidth.toPx().value, 0f), childPosition[1])
}
@Test
@@ -236,7 +236,7 @@
val drawLatch = CountDownLatch(2)
val childSize = arrayOf(IntPxSize(-1.ipx, -1.ipx), IntPxSize(-1.ipx, -1.ipx))
- val childPosition = arrayOf(PxPosition(-1.px, -1.px), PxPosition(-1.px, -1.px))
+ val childPosition = arrayOf(PxPosition(-1f, -1f), PxPosition(-1f, -1f))
show {
Container(alignment = Alignment.TopStart) {
Column {
@@ -245,7 +245,7 @@
height = sizeDp,
modifier = Modifier.onPositioned { coordinates: LayoutCoordinates ->
childSize[0] = coordinates.size
- childPosition[0] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
+ childPosition[0] = coordinates.localToGlobal(PxPosition(0f, 0f))
drawLatch.countDown()
}
) {
@@ -255,7 +255,7 @@
height = (sizeDp * 2),
modifier = Modifier.onPositioned { coordinates: LayoutCoordinates ->
childSize[1] = coordinates.size
- childPosition[1] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
+ childPosition[1] = coordinates.localToGlobal(PxPosition(0f, 0f))
drawLatch.countDown()
}
) {
@@ -273,8 +273,8 @@
IntPxSize((sizeDp.toPx() * 2).roundToInt().ipx, (sizeDp.toPx() * 2).roundToInt().ipx),
childSize[1]
)
- assertEquals(PxPosition(0.px, 0.px), childPosition[0])
- assertEquals(PxPosition(0.px, size.toPx()), childPosition[1])
+ assertEquals(PxPosition(0f, 0f), childPosition[0])
+ assertEquals(PxPosition(0f, size.toPx().value), childPosition[1])
}
@Test
@@ -293,7 +293,7 @@
Modifier.weight(1f)
.onPositioned { coordinates: LayoutCoordinates ->
childSize[0] = coordinates.size
- childPosition[0] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
+ childPosition[0] = coordinates.localToGlobal(PxPosition(0f, 0f))
drawLatch.countDown()
},
width = width,
@@ -305,7 +305,7 @@
Modifier.weight(2f)
.onPositioned { coordinates: LayoutCoordinates ->
childSize[1] = coordinates.size
- childPosition[1] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
+ childPosition[1] = coordinates.localToGlobal(PxPosition(0f, 0f))
drawLatch.countDown()
},
width = width,
@@ -327,8 +327,8 @@
assertEquals(
IntPxSize(childrenWidth, (rootHeight * 2 / 3).round()), childSize[1]
)
- assertEquals(PxPosition(0.px, 0.px), childPosition[0])
- assertEquals(PxPosition(0.px, (rootHeight / 3).round().toPx()), childPosition[1])
+ assertEquals(PxPosition(0f, 0f), childPosition[0])
+ assertEquals(PxPosition(0f, (rootHeight / 3).round().toPx().value), childPosition[1])
}
@Test
@@ -348,7 +348,7 @@
Modifier.weight(1f, fill = false)
.onPositioned { coordinates: LayoutCoordinates ->
childSize[0] = coordinates.size
- childPosition[0] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
+ childPosition[0] = coordinates.localToGlobal(PxPosition(0f, 0f))
drawLatch.countDown()
},
width = width,
@@ -359,7 +359,7 @@
Modifier.weight(2f, fill = false)
.onPositioned { coordinates: LayoutCoordinates ->
childSize[1] = coordinates.size
- childPosition[1] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
+ childPosition[1] = coordinates.localToGlobal(PxPosition(0f, 0f))
drawLatch.countDown()
},
width = width,
@@ -378,8 +378,8 @@
assertEquals(
IntPxSize(childrenWidth, childrenHeight), childSize[1]
)
- assertEquals(PxPosition(0.px, 0.px), childPosition[0])
- assertEquals(PxPosition(0.px, childrenHeight.toPx()), childPosition[1])
+ assertEquals(PxPosition(0.0f, 0.0f), childPosition[0])
+ assertEquals(PxPosition(0.0f, childrenHeight.toPx().value), childPosition[1])
}
@Test
@@ -403,7 +403,7 @@
Modifier.weight(1f)
.onPositioned { coordinates: LayoutCoordinates ->
width[0] = coordinates.size.width
- x[0] = coordinates.globalPosition.x
+ x[0] = coordinates.globalPosition.x.px
latch.countDown()
}
) {
@@ -412,7 +412,7 @@
Modifier.weight(1f)
.onPositioned { coordinates: LayoutCoordinates ->
width[1] = coordinates.size.width
- x[1] = coordinates.globalPosition.x
+ x[1] = coordinates.globalPosition.x.px
latch.countDown()
}
) {
@@ -449,7 +449,7 @@
Modifier.weight(2f)
.onPositioned { coordinates: LayoutCoordinates ->
width[0] = coordinates.size.width
- x[0] = coordinates.globalPosition.x
+ x[0] = coordinates.globalPosition.x.px
latch.countDown()
}
) {
@@ -458,7 +458,7 @@
Modifier.weight(2f)
.onPositioned { coordinates: LayoutCoordinates ->
width[1] = coordinates.size.width
- x[1] = coordinates.globalPosition.x
+ x[1] = coordinates.globalPosition.x.px
latch.countDown()
}
) {
@@ -467,7 +467,7 @@
Modifier.weight(3f)
.onPositioned { coordinates: LayoutCoordinates ->
width[2] = coordinates.size.width
- x[2] = coordinates.globalPosition.x
+ x[2] = coordinates.globalPosition.x.px
latch.countDown()
}
) {
@@ -505,7 +505,7 @@
Modifier.weight(1f)
.onPositioned { coordinates: LayoutCoordinates ->
height[0] = coordinates.size.height
- y[0] = coordinates.globalPosition.y
+ y[0] = coordinates.globalPosition.y.px
latch.countDown()
}
) {
@@ -514,7 +514,7 @@
Modifier.weight(1f)
.onPositioned { coordinates: LayoutCoordinates ->
height[1] = coordinates.size.height
- y[1] = coordinates.globalPosition.y
+ y[1] = coordinates.globalPosition.y.px
latch.countDown()
}
) {
@@ -523,7 +523,7 @@
Modifier.weight(1f)
.onPositioned { coordinates: LayoutCoordinates ->
height[2] = coordinates.size.height
- y[2] = coordinates.globalPosition.y
+ y[2] = coordinates.globalPosition.y.px
latch.countDown()
}
) {
@@ -561,7 +561,7 @@
Modifier.weight(1f)
.onPositioned { coordinates: LayoutCoordinates ->
height[0] = coordinates.size.height
- y[0] = coordinates.globalPosition.y
+ y[0] = coordinates.globalPosition.y.px
latch.countDown()
}
) {
@@ -570,7 +570,7 @@
Modifier.weight(1f)
.onPositioned { coordinates: LayoutCoordinates ->
height[1] = coordinates.size.height
- y[1] = coordinates.globalPosition.y
+ y[1] = coordinates.globalPosition.y.px
latch.countDown()
}
) {
@@ -596,7 +596,7 @@
val drawLatch = CountDownLatch(2)
val childSize = arrayOf(IntPxSize(-1.ipx, -1.ipx), IntPxSize(-1.ipx, -1.ipx))
- val childPosition = arrayOf(PxPosition(-1.px, -1.px), PxPosition(-1.px, -1.px))
+ val childPosition = arrayOf(PxPosition(-1f, -1f), PxPosition(-1f, -1f))
show {
Row {
Container(
@@ -605,7 +605,7 @@
modifier = Modifier.fillMaxHeight()
.onPositioned { coordinates: LayoutCoordinates ->
childSize[0] = coordinates.size
- childPosition[0] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
+ childPosition[0] = coordinates.localToGlobal(PxPosition(0f, 0f))
drawLatch.countDown()
}
) {
@@ -617,7 +617,7 @@
modifier = Modifier.fillMaxHeight()
.onPositioned { coordinates: LayoutCoordinates ->
childSize[1] = coordinates.size
- childPosition[1] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
+ childPosition[1] = coordinates.localToGlobal(PxPosition(0f, 0f))
drawLatch.countDown()
}
) {
@@ -634,8 +634,8 @@
IntPxSize((sizeDp.toPx() * 2).roundToInt().ipx, root.height.ipx),
childSize[1]
)
- assertEquals(PxPosition(0.px, 0.px), childPosition[0])
- assertEquals(PxPosition(size.toPx(), 0.px), childPosition[1])
+ assertEquals(PxPosition(0f, 0f), childPosition[0])
+ assertEquals(PxPosition(size.toPx().value, 0f), childPosition[1])
}
@Test
@@ -689,16 +689,18 @@
val rootHeight = root.height.px
assertEquals(IntPxSize(size, size), childSize[0])
- assertEquals(PxPosition(0.px, 0.px), childPosition[0])
+ assertEquals(PxPosition(0f, 0f), childPosition[0])
assertEquals(IntPxSize(size, size), childSize[1])
assertEquals(
- PxPosition(size.toPx(), ((rootHeight - size.toPx()) / 2).round().toPx()),
+ PxPosition(size.toPx().value, ((rootHeight - size.toPx()) / 2).round().toPx().value),
childPosition[1]
)
assertEquals(IntPxSize(size, size), childSize[2])
- assertEquals(PxPosition(size.toPx() * 2, rootHeight - size.toPx()), childPosition[2])
+ assertEquals(PxPosition((size.toPx() * 2).value,
+ (rootHeight - size.toPx()).value),
+ childPosition[2])
}
@Test
@@ -753,16 +755,18 @@
val rootHeight = root.height.px
assertEquals(IntPxSize(size, size), childSize[0])
- assertEquals(PxPosition(0.px, 0.px), childPosition[0])
+ assertEquals(PxPosition(0f, 0f), childPosition[0])
assertEquals(IntPxSize(size, size), childSize[1])
assertEquals(
- PxPosition(size.toPx(), ((rootHeight - size.toPx()) / 2).round().toPx()),
+ PxPosition(size.toPx().value, ((rootHeight - size.toPx()) / 2).round().toPx().value),
childPosition[1]
)
assertEquals(IntPxSize(size, size), childSize[2])
- assertEquals(PxPosition(size.toPx() * 2, rootHeight - size.toPx()), childPosition[2])
+ assertEquals(
+ PxPosition((size.toPx() * 2).value, (rootHeight - size.toPx()).value),
+ childPosition[2])
}
@Test
@@ -830,23 +834,23 @@
assertTrue(drawLatch.await(1, TimeUnit.SECONDS))
assertEquals(IntPxSize(size, size), childSize[0])
- assertEquals(PxPosition(0.px, 0.px), childPosition[0])
+ assertEquals(PxPosition(0f, 0f), childPosition[0])
assertEquals(IntPxSize(size, size), childSize[1])
assertEquals(
- PxPosition(size.toPx(), (baseline1 - (size.toPx() / 2).round()).toPx()),
+ PxPosition(size.toPx().value, (baseline1 - (size.toPx() / 2).round()).toPx().value),
childPosition[1]
)
assertEquals(IntPxSize(size, size), childSize[2])
assertEquals(
- PxPosition(size.toPx() * 2, (baseline1 - baseline2).toPx()),
+ PxPosition((size.toPx() * 2).value, (baseline1 - baseline2).toPx().value),
childPosition[2]
)
assertEquals(IntPxSize(size, size), childSize[3])
assertEquals(
- PxPosition(size.toPx() * 3, 0.px),
+ PxPosition((size.toPx() * 3).value, 0f),
childPosition[3]
)
}
@@ -891,10 +895,13 @@
assertTrue(drawLatch.await(1, TimeUnit.SECONDS))
assertEquals(IntPxSize(size, size), childSize[0])
- assertEquals(PxPosition(0.px, 0.px), childPosition[0])
+ assertEquals(PxPosition(0f, 0f), childPosition[0])
assertEquals(size, childSize[1]!!.height)
- assertEquals(PxPosition(size.toPx(), (baseline - size / 2).toPx()), childPosition[1])
+ assertEquals(
+ PxPosition(size.toPx().value, (baseline - size / 2).toPx().value),
+ childPosition[1]
+ )
}
// endregion
@@ -906,7 +913,7 @@
val drawLatch = CountDownLatch(2)
val childSize = arrayOf(IntPxSize(-1.ipx, -1.ipx), IntPxSize(-1.ipx, -1.ipx))
- val childPosition = arrayOf(PxPosition(-1.px, -1.px), PxPosition(-1.px, -1.px))
+ val childPosition = arrayOf(PxPosition(-1f, -1f), PxPosition(-1f, -1f))
show {
Column {
Container(
@@ -915,7 +922,7 @@
modifier = Modifier.fillMaxWidth()
.onPositioned { coordinates: LayoutCoordinates ->
childSize[0] = coordinates.size
- childPosition[0] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
+ childPosition[0] = coordinates.localToGlobal(PxPosition(0f, 0f))
drawLatch.countDown()
}
) {
@@ -927,7 +934,7 @@
modifier = Modifier.fillMaxWidth()
.onPositioned { coordinates: LayoutCoordinates ->
childSize[1] = coordinates.size
- childPosition[1] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
+ childPosition[1] = coordinates.localToGlobal(PxPosition(0f, 0f))
drawLatch.countDown()
}
) {
@@ -944,8 +951,8 @@
IntPxSize(root.width.ipx, (sizeDp * 2).toIntPx()),
childSize[1]
)
- assertEquals(PxPosition(0.px, 0.px), childPosition[0])
- assertEquals(PxPosition(0.px, size.toPx()), childPosition[1])
+ assertEquals(PxPosition(0f, 0f), childPosition[0])
+ assertEquals(PxPosition(0f, size.toPx().value), childPosition[1])
}
@Test
@@ -1000,16 +1007,22 @@
val rootWidth = root.width.px
assertEquals(IntPxSize(size, size), childSize[0])
- assertEquals(PxPosition(0.px, 0.px), childPosition[0])
+ assertEquals(PxPosition(0f, 0f), childPosition[0])
assertEquals(IntPxSize(size, size), childSize[1])
assertEquals(
- PxPosition(((rootWidth - size.toPx()) / 2).round().toPx(), size.toPx()),
+ PxPosition(
+ ((rootWidth - size.toPx()) / 2).round().toPx().value,
+ size.toPx().value
+ ),
childPosition[1]
)
assertEquals(IntPxSize(size, size), childSize[2])
- assertEquals(PxPosition(rootWidth - size.toPx(), size.toPx() * 2), childPosition[2])
+ assertEquals(
+ PxPosition((rootWidth - size.toPx()).value, size.toPx().value * 2),
+ childPosition[2]
+ )
}
@Test
@@ -1063,16 +1076,22 @@
val rootWidth = root.width.px
assertEquals(IntPxSize(size, size), childSize[0])
- assertEquals(PxPosition(0.px, 0.px), childPosition[0])
+ assertEquals(PxPosition(0f, 0f), childPosition[0])
assertEquals(IntPxSize(size, size), childSize[1])
assertEquals(
- PxPosition(((rootWidth - size.toPx()) / 2).round().toPx(), size.toPx()),
+ PxPosition(
+ ((rootWidth - size.toPx()) / 2).round().toPx().value,
+ size.toPx().value
+ ),
childPosition[1]
)
assertEquals(IntPxSize(size, size), childSize[2])
- assertEquals(PxPosition(rootWidth - size.toPx(), size.toPx() * 2), childPosition[2])
+ assertEquals(
+ PxPosition((rootWidth - size.toPx()).value, size.toPx().value * 2),
+ childPosition[2]
+ )
}
@Test
@@ -1138,20 +1157,26 @@
assertTrue(drawLatch.await(1, TimeUnit.SECONDS))
assertEquals(IntPxSize(size, size), childSize[0])
- assertEquals(PxPosition(0.px, 0.px), childPosition[0])
+ assertEquals(PxPosition(0f, 0f), childPosition[0])
assertEquals(IntPxSize(size, size), childSize[1])
- assertEquals(PxPosition(size.toPx(), size.toPx()), childPosition[1])
+ assertEquals(PxPosition(size.toPx().value, size.toPx().value), childPosition[1])
assertEquals(IntPxSize(size, size), childSize[2])
assertEquals(
- PxPosition((size - firstBaseline1Dp.toIntPx()).toPx(), size.toPx() * 2),
+ PxPosition(
+ (size - firstBaseline1Dp.toIntPx()).toPx().value,
+ size.toPx().value * 2
+ ),
childPosition[2]
)
assertEquals(IntPxSize(size, size), childSize[3])
assertEquals(
- PxPosition((size - firstBaseline2Dp.toIntPx()).toPx(), size.toPx() * 3),
+ PxPosition(
+ (size - firstBaseline2Dp.toIntPx()).toPx().value,
+ size.toPx().value * 3
+ ),
childPosition[3]
)
}
@@ -1196,10 +1221,13 @@
assertTrue(drawLatch.await(1, TimeUnit.SECONDS))
assertEquals(IntPxSize(size, size), childSize[0])
- assertEquals(PxPosition(0.px, 0.px), childPosition[0])
+ assertEquals(PxPosition(0f, 0f), childPosition[0])
assertEquals(size, childSize[1]!!.width)
- assertEquals(PxPosition((baseline - (size / 2)).toPx(), size.toPx()), childPosition[1])
+ assertEquals(
+ PxPosition((baseline - (size / 2)).toPx().value, size.toPx().value),
+ childPosition[1]
+ )
}
// endregion
@@ -2108,7 +2136,7 @@
val drawLatch = CountDownLatch(4)
val childPosition = arrayOf(
- PxPosition(-1.px, -1.px), PxPosition(-1.px, -1.px), PxPosition(-1.px, -1.px)
+ PxPosition(-1f, -1f), PxPosition(-1f, -1f), PxPosition(-1f, -1f)
)
val childLayoutCoordinates = arrayOfNulls<LayoutCoordinates?>(childPosition.size)
var parentLayoutCoordinates: LayoutCoordinates? = null
@@ -2141,9 +2169,9 @@
val root = findOwnerView()
waitForDraw(root)
- assertEquals(PxPosition(0.px, 0.px), childPosition[0])
- assertEquals(PxPosition(size.toPx(), 0.px), childPosition[1])
- assertEquals(PxPosition(size.toPx() * 2, 0.px), childPosition[2])
+ assertEquals(PxPosition(0f, 0f), childPosition[0])
+ assertEquals(PxPosition(size.toPx().value, 0f), childPosition[1])
+ assertEquals(PxPosition(size.toPx().value * 2, 0f), childPosition[2])
}
@Test
@@ -2153,7 +2181,7 @@
val drawLatch = CountDownLatch(4)
val childPosition = arrayOf(
- PxPosition(-1.px, -1.px), PxPosition(-1.px, -1.px), PxPosition(-1.px, -1.px)
+ PxPosition(-1f, -1f), PxPosition(-1f, -1f), PxPosition(-1f, -1f)
)
val childLayoutCoordinates = arrayOfNulls<LayoutCoordinates?>(childPosition.size)
var parentLayoutCoordinates: LayoutCoordinates? = null
@@ -2184,9 +2212,9 @@
val root = findOwnerView()
waitForDraw(root)
- assertEquals(PxPosition(root.width.px - size.toPx() * 3, 0.px), childPosition[0])
- assertEquals(PxPosition(root.width.px - size.toPx() * 2, 0.px), childPosition[1])
- assertEquals(PxPosition(root.width.px - size.toPx(), 0.px), childPosition[2])
+ assertEquals(PxPosition((root.width.px - size.toPx() * 3).value, 0f), childPosition[0])
+ assertEquals(PxPosition((root.width.px - size.toPx() * 2).value, 0f), childPosition[1])
+ assertEquals(PxPosition((root.width.px - size.toPx()).value, 0f), childPosition[2])
}
@Test
@@ -2196,7 +2224,7 @@
val drawLatch = CountDownLatch(4)
val childPosition = arrayOf(
- PxPosition(-1.px, -1.px), PxPosition(-1.px, -1.px), PxPosition(-1.px, -1.px)
+ PxPosition(-1f, -1f), PxPosition(-1f, -1f), PxPosition(-1f, -1f)
)
val childLayoutCoordinates = arrayOfNulls<LayoutCoordinates?>(childPosition.size)
var parentLayoutCoordinates: LayoutCoordinates? = null
@@ -2228,9 +2256,18 @@
waitForDraw(root)
val extraSpace = root.width.px.round() - size * 3
- assertEquals(PxPosition((extraSpace / 2).toPx(), 0.px), childPosition[0])
- assertEquals(PxPosition((extraSpace / 2).toPx() + size.toPx(), 0.px), childPosition[1])
- assertEquals(PxPosition((extraSpace / 2).toPx() + size.toPx() * 2, 0.px), childPosition[2])
+ assertEquals(PxPosition((extraSpace / 2).toPx().value, 0f), childPosition[0])
+ assertEquals(
+ PxPosition(((extraSpace / 2).toPx() + size.toPx()).value, 0f),
+ childPosition[1]
+ )
+ assertEquals(
+ PxPosition(
+ ((extraSpace / 2).toPx() + size.toPx() * 2).value,
+ 0f
+ ),
+ childPosition[2]
+ )
}
@Test
@@ -2240,7 +2277,7 @@
val drawLatch = CountDownLatch(4)
val childPosition = arrayOf(
- PxPosition(-1.px, -1.px), PxPosition(-1.px, -1.px), PxPosition(-1.px, -1.px)
+ PxPosition(-1f, -1f), PxPosition(-1f, -1f), PxPosition(-1f, -1f)
)
val childLayoutCoordinates = arrayOfNulls<LayoutCoordinates?>(childPosition.size)
var parentLayoutCoordinates: LayoutCoordinates? = null
@@ -2272,9 +2309,15 @@
waitForDraw(root)
val gap = (root.width.px - size.toPx() * 3) / 4
- assertEquals(PxPosition(gap.round().toPx(), 0.px), childPosition[0])
- assertEquals(PxPosition((size.toPx() + gap * 2).round().toPx(), 0.px), childPosition[1])
- assertEquals(PxPosition((size.toPx() * 2 + gap * 3).round().toPx(), 0.px), childPosition[2])
+ assertEquals(PxPosition(gap.round().toPx().value, 0f), childPosition[0])
+ assertEquals(
+ PxPosition((size.toPx() + gap * 2).round().toPx().value, 0f),
+ childPosition[1]
+ )
+ assertEquals(
+ PxPosition((size.toPx() * 2 + gap * 3).round().toPx().value, 0f),
+ childPosition[2]
+ )
}
@Test
@@ -2284,7 +2327,7 @@
val drawLatch = CountDownLatch(4)
val childPosition = arrayOf(
- PxPosition(-1.px, -1.px), PxPosition(-1.px, -1.px), PxPosition(-1.px, -1.px)
+ PxPosition(-1f, -1f), PxPosition(-1f, -1f), PxPosition(-1f, -1f)
)
val childLayoutCoordinates = arrayOfNulls<LayoutCoordinates?>(childPosition.size)
var parentLayoutCoordinates: LayoutCoordinates? = null
@@ -2316,9 +2359,12 @@
waitForDraw(root)
val gap = (root.width.px - size.toPx() * 3) / 2
- assertEquals(PxPosition(0.px, 0.px), childPosition[0])
- assertEquals(PxPosition((gap + size.toPx()).round().toPx(), 0.px), childPosition[1])
- assertEquals(PxPosition((gap * 2 + size.toPx() * 2).round().toPx(), 0.px), childPosition[2])
+ assertEquals(PxPosition(0f, 0f), childPosition[0])
+ assertEquals(PxPosition((gap + size.toPx()).round().toPx().value, 0f), childPosition[1])
+ assertEquals(
+ PxPosition((gap * 2 + size.toPx() * 2).round().toPx().value, 0f),
+ childPosition[2]
+ )
}
@Test
@@ -2328,7 +2374,7 @@
val drawLatch = CountDownLatch(4)
val childPosition = arrayOf(
- PxPosition(-1.px, -1.px), PxPosition(-1.px, -1.px), PxPosition(-1.px, -1.px)
+ PxPosition(-1f, -1f), PxPosition(-1f, -1f), PxPosition(-1f, -1f)
)
val childLayoutCoordinates = arrayOfNulls<LayoutCoordinates?>(childPosition.size)
var parentLayoutCoordinates: LayoutCoordinates? = null
@@ -2363,9 +2409,15 @@
waitForDraw(root)
val gap = (root.width.px.round() - size * 3) / 3
- assertEquals(PxPosition((gap / 2).toPx(), 0.px), childPosition[0])
- assertEquals(PxPosition((gap * 3 / 2).toPx() + size.toPx(), 0.px), childPosition[1])
- assertEquals(PxPosition((gap * 5 / 2).toPx() + size.toPx() * 2, 0.px), childPosition[2])
+ assertEquals(PxPosition((gap / 2).toPx().value, 0f), childPosition[0])
+ assertEquals(
+ PxPosition(((gap * 3 / 2).toPx() + size.toPx()).value, 0f),
+ childPosition[1]
+ )
+ assertEquals(
+ PxPosition(((gap * 5 / 2).toPx() + size.toPx() * 2).value, 0f),
+ childPosition[2]
+ )
}
@Test
@@ -2407,10 +2459,13 @@
waitForDraw(root)
val step = (root.width.px - size.toPx() * 3) / 3
- assertEquals(PxPosition(0.px, 0.px), childPosition[0])
- assertEquals(PxPosition((step + size.toPx()).round().toPx(), 0.px), childPosition[1])
+ assertEquals(PxPosition(0f, 0f), childPosition[0])
assertEquals(
- PxPosition((step * 3 + size.toPx() * 2).round().toPx(), 0.px),
+ PxPosition((step + size.toPx()).round().toPx().value, 0f),
+ childPosition[1]
+ )
+ assertEquals(
+ PxPosition((step * 3 + size.toPx() * 2).round().toPx().value, 0f),
childPosition[2]
)
}
@@ -2424,7 +2479,7 @@
val drawLatch = CountDownLatch(4)
val childPosition = arrayOf(
- PxPosition(-1.px, -1.px), PxPosition(-1.px, -1.px), PxPosition(-1.px, -1.px)
+ PxPosition(-1f, -1f), PxPosition(-1f, -1f), PxPosition(-1f, -1f)
)
val childLayoutCoordinates = arrayOfNulls<LayoutCoordinates?>(childPosition.size)
var parentLayoutCoordinates: LayoutCoordinates? = null
@@ -2455,9 +2510,9 @@
val root = findOwnerView()
waitForDraw(root)
- assertEquals(PxPosition(0.px, 0.px), childPosition[0])
- assertEquals(PxPosition(0.px, size.toPx()), childPosition[1])
- assertEquals(PxPosition(0.px, size.toPx() * 2), childPosition[2])
+ assertEquals(PxPosition(0f, 0f), childPosition[0])
+ assertEquals(PxPosition(0f, size.toPx().value), childPosition[1])
+ assertEquals(PxPosition(0f, size.toPx().value * 2), childPosition[2])
}
@Test
@@ -2467,7 +2522,7 @@
val drawLatch = CountDownLatch(4)
val childPosition = arrayOf(
- PxPosition(-1.px, -1.px), PxPosition(-1.px, -1.px), PxPosition(-1.px, -1.px)
+ PxPosition(-1f, -1f), PxPosition(-1f, -1f), PxPosition(-1f, -1f)
)
val childLayoutCoordinates = arrayOfNulls<LayoutCoordinates?>(childPosition.size)
var parentLayoutCoordinates: LayoutCoordinates? = null
@@ -2498,9 +2553,9 @@
val root = findOwnerView()
waitForDraw(root)
- assertEquals(PxPosition(0.px, root.height.px - size.toPx() * 3), childPosition[0])
- assertEquals(PxPosition(0.px, root.height.px - size.toPx() * 2), childPosition[1])
- assertEquals(PxPosition(0.px, root.height.px - size.toPx()), childPosition[2])
+ assertEquals(PxPosition(0f, (root.height.px - size.toPx() * 3).value), childPosition[0])
+ assertEquals(PxPosition(0f, (root.height.px - size.toPx() * 2).value), childPosition[1])
+ assertEquals(PxPosition(0f, (root.height.px - size.toPx()).value), childPosition[2])
}
@Test
@@ -2510,7 +2565,7 @@
val drawLatch = CountDownLatch(4)
val childPosition = arrayOf(
- PxPosition(-1.px, -1.px), PxPosition(-1.px, -1.px), PxPosition(-1.px, -1.px)
+ PxPosition(-1f, -1f), PxPosition(-1f, -1f), PxPosition(-1f, -1f)
)
val childLayoutCoordinates = arrayOfNulls<LayoutCoordinates?>(childPosition.size)
var parentLayoutCoordinates: LayoutCoordinates? = null
@@ -2542,9 +2597,21 @@
waitForDraw(root)
val extraSpace = root.height.px.round() - size * 3
- assertEquals(PxPosition(0.px, (extraSpace / 2).toPx()), childPosition[0])
- assertEquals(PxPosition(0.px, (extraSpace / 2).toPx() + size.toPx()), childPosition[1])
- assertEquals(PxPosition(0.px, (extraSpace / 2).toPx() + size.toPx() * 2), childPosition[2])
+ assertEquals(
+ PxPosition(0f, (extraSpace / 2).toPx().value),
+ childPosition[0]
+ )
+ assertEquals(
+ PxPosition(0f, ((extraSpace / 2).toPx() + size.toPx()).value),
+ childPosition[1]
+ )
+ assertEquals(
+ PxPosition(
+ 0f,
+ ((extraSpace / 2).toPx() + size.toPx() * 2).value
+ ),
+ childPosition[2]
+ )
}
@Test
@@ -2554,7 +2621,7 @@
val drawLatch = CountDownLatch(4)
val childPosition = arrayOf(
- PxPosition(-1.px, -1.px), PxPosition(-1.px, -1.px), PxPosition(-1.px, -1.px)
+ PxPosition(-1f, -1f), PxPosition(-1f, -1f), PxPosition(-1f, -1f)
)
val childLayoutCoordinates = arrayOfNulls<LayoutCoordinates?>(childPosition.size)
var parentLayoutCoordinates: LayoutCoordinates? = null
@@ -2586,9 +2653,12 @@
waitForDraw(root)
val gap = (root.height.px - size.toPx() * 3) / 4
- assertEquals(PxPosition(0.px, gap.round().toPx()), childPosition[0])
- assertEquals(PxPosition(0.px, (size.toPx() + gap * 2).round().toPx()), childPosition[1])
- assertEquals(PxPosition(0.px, (size.toPx() * 2 + gap * 3).round().toPx()), childPosition[2])
+ assertEquals(PxPosition(0f, gap.round().toPx().value), childPosition[0])
+ assertEquals(PxPosition(0f, (size.toPx() + gap * 2).round().toPx().value), childPosition[1])
+ assertEquals(
+ PxPosition(0f, (size.toPx() * 2 + gap * 3).round().toPx().value),
+ childPosition[2]
+ )
}
private fun calculateChildPositions(
@@ -2598,7 +2668,7 @@
) {
for (i in childPosition.indices) {
childPosition[i] = parentLayoutCoordinates!!
- .childToLocal(childLayoutCoordinates[i]!!, PxPosition(0.px, 0.px))
+ .childToLocal(childLayoutCoordinates[i]!!, PxPosition(0f, 0f))
}
}
@@ -2609,7 +2679,7 @@
val drawLatch = CountDownLatch(4)
val childPosition = arrayOf(
- PxPosition(-1.px, -1.px), PxPosition(-1.px, -1.px), PxPosition(-1.px, -1.px)
+ PxPosition(-1f, -1f), PxPosition(-1f, -1f), PxPosition(-1f, -1f)
)
val childLayoutCoordinates = arrayOfNulls<LayoutCoordinates?>(childPosition.size)
var parentLayoutCoordinates: LayoutCoordinates? = null
@@ -2641,9 +2711,12 @@
waitForDraw(root)
val gap = (root.height.px - size.toPx() * 3) / 2
- assertEquals(PxPosition(0.px, 0.px), childPosition[0])
- assertEquals(PxPosition(0.px, (gap + size.toPx()).round().toPx()), childPosition[1])
- assertEquals(PxPosition(0.px, (gap * 2 + size.toPx() * 2).round().toPx()), childPosition[2])
+ assertEquals(PxPosition(0f, 0f), childPosition[0])
+ assertEquals(PxPosition(0f, (gap + size.toPx()).round().toPx().value), childPosition[1])
+ assertEquals(
+ PxPosition(0f, (gap * 2 + size.toPx() * 2).round().toPx().value),
+ childPosition[2]
+ )
}
@Test
@@ -2653,7 +2726,7 @@
val drawLatch = CountDownLatch(4)
val childPosition = arrayOf(
- PxPosition(-1.px, -1.px), PxPosition(-1.px, -1.px), PxPosition(-1.px, -1.px)
+ PxPosition(-1f, -1f), PxPosition(-1f, -1f), PxPosition(-1f, -1f)
)
val childLayoutCoordinates = arrayOfNulls<LayoutCoordinates?>(childPosition.size)
var parentLayoutCoordinates: LayoutCoordinates? = null
@@ -2685,13 +2758,13 @@
waitForDraw(root)
val gap = (root.height.px - size.toPx() * 3) / 3
- assertEquals(PxPosition(0.px, (gap / 2).round().toPx()), childPosition[0])
+ assertEquals(PxPosition(0f, (gap / 2).round().toPx().value), childPosition[0])
assertEquals(
- PxPosition(0.px, ((gap * 3 / 2) + size.toPx()).round().toPx()),
+ PxPosition(0f, ((gap * 3 / 2) + size.toPx()).round().toPx().value),
childPosition[1]
)
assertEquals(
- PxPosition(0.px, ((gap * 5 / 2) + size.toPx() * 2).round().toPx()),
+ PxPosition(0f, ((gap * 5 / 2) + size.toPx() * 2).round().toPx().value),
childPosition[2]
)
}
@@ -2735,10 +2808,10 @@
waitForDraw(root)
val step = (root.height.px - size.toPx() * 3) / 3
- assertEquals(PxPosition(0.px, 0.px), childPosition[0])
- assertEquals(PxPosition(0.px, (step + size.toPx()).round().toPx()), childPosition[1])
+ assertEquals(PxPosition(0f, 0f), childPosition[0])
+ assertEquals(PxPosition(0f, (step + size.toPx()).round().toPx().value), childPosition[1])
assertEquals(
- PxPosition(0.px, (step * 3 + size.toPx() * 2).round().toPx()),
+ PxPosition(0f, (step * 3 + size.toPx() * 2).round().toPx().value),
childPosition[2]
)
}
@@ -3429,7 +3502,7 @@
Row(Modifier.fillMaxWidth().rtl) {
Container(
Modifier.preferredSize(sizeDp).onPositioned { coordinates: LayoutCoordinates ->
- childPosition[0] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
+ childPosition[0] = coordinates.localToGlobal(PxPosition(0f, 0f))
drawLatch.countDown()
}
) {
@@ -3438,7 +3511,7 @@
Container(
Modifier.preferredSize(sizeDp * 2)
.onPositioned { coordinates: LayoutCoordinates ->
- childPosition[1] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
+ childPosition[1] = coordinates.localToGlobal(PxPosition(0f, 0f))
drawLatch.countDown()
}
) {
@@ -3451,9 +3524,9 @@
waitForDraw(root)
val rootWidth = root.width.px
- assertEquals(PxPosition(rootWidth - size.toPx(), 0.px), childPosition[0])
+ assertEquals(PxPosition((rootWidth - size.toPx()).value, 0f), childPosition[0])
assertEquals(
- PxPosition(rootWidth - (sizeDp.toPx() * 3).roundToInt().px, 0.px),
+ PxPosition((rootWidth - (sizeDp.toPx() * 3).roundToInt().px).value, 0f),
childPosition[1]
)
}
@@ -3471,7 +3544,7 @@
) {
Container(
Modifier.preferredSize(sizeDp).onPositioned { coordinates: LayoutCoordinates ->
- childPosition[0] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
+ childPosition[0] = coordinates.localToGlobal(PxPosition(0f, 0f))
drawLatch.countDown()
}
) {
@@ -3480,7 +3553,7 @@
Container(
Modifier.preferredSize(sizeDp * 2)
.onPositioned { coordinates: LayoutCoordinates ->
- childPosition[1] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
+ childPosition[1] = coordinates.localToGlobal(PxPosition(0f, 0f))
drawLatch.countDown()
}
) {
@@ -3490,8 +3563,14 @@
assertTrue(drawLatch.await(1, TimeUnit.SECONDS))
- assertEquals(PxPosition((sizeDp.toPx() * 2).roundToInt().px, 0.px), childPosition[0])
- assertEquals(PxPosition(0.px, 0.px), childPosition[1])
+ assertEquals(
+ PxPosition(
+ (sizeDp.toPx() * 2).roundToInt().toFloat(),
+ 0f
+ ),
+ childPosition[0]
+ )
+ assertEquals(PxPosition(0f, 0f), childPosition[1])
}
@Test
@@ -3509,7 +3588,7 @@
width = sizeDp,
height = sizeDp,
modifier = Modifier.onPositioned { coordinates: LayoutCoordinates ->
- childPosition[0] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
+ childPosition[0] = coordinates.localToGlobal(PxPosition(0f, 0f))
drawLatch.countDown()
}
) {
@@ -3519,7 +3598,7 @@
width = (sizeDp * 2),
height = (sizeDp * 2),
modifier = Modifier.onPositioned { coordinates: LayoutCoordinates ->
- childPosition[1] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
+ childPosition[1] = coordinates.localToGlobal(PxPosition(0f, 0f))
drawLatch.countDown()
}
) {
@@ -3531,8 +3610,11 @@
val root = findOwnerView()
waitForDraw(root)
- assertEquals(PxPosition((sizeDp.toPx() * 2).roundToInt().px, 0.px), childPosition[0])
- assertEquals(PxPosition(0.px, 0.px), childPosition[1])
+ assertEquals(
+ PxPosition((sizeDp.toPx() * 2).roundToInt().toFloat(), 0f),
+ childPosition[0]
+ )
+ assertEquals(PxPosition(0f, 0f), childPosition[1])
}
@Test
@@ -3546,7 +3628,7 @@
Column(Modifier.fillMaxWidth().rtl) {
Container(
Modifier.preferredSize(sizeDp).onPositioned { coordinates: LayoutCoordinates ->
- childPosition[0] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
+ childPosition[0] = coordinates.localToGlobal(PxPosition(0f, 0f))
drawLatch.countDown()
}
) {
@@ -3555,7 +3637,7 @@
Container(
Modifier.preferredSize(sizeDp * 2)
.onPositioned { coordinates: LayoutCoordinates ->
- childPosition[1] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
+ childPosition[1] = coordinates.localToGlobal(PxPosition(0f, 0f))
drawLatch.countDown()
}
) {
@@ -3568,9 +3650,12 @@
waitForDraw(root)
val rootWidth = root.width.px
- assertEquals(PxPosition(rootWidth - size.toPx(), 0.px), childPosition[0])
+ assertEquals(PxPosition((rootWidth - size.toPx()).value, 0f), childPosition[0])
assertEquals(
- PxPosition((rootWidth.value - (sizeDp * 2).toPx()).roundToInt().px, size.toPx()),
+ PxPosition(
+ (rootWidth.value - (sizeDp * 2).toPx()).roundToInt().toFloat(),
+ size.toPx().value
+ ),
childPosition[1]
)
}
@@ -3588,7 +3673,7 @@
Modifier.preferredSize(sizeDp)
.gravity(Alignment.End)
.onPositioned { coordinates: LayoutCoordinates ->
- childPosition[0] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
+ childPosition[0] = coordinates.localToGlobal(PxPosition(0f, 0f))
drawLatch.countDown()
}
) {
@@ -3598,7 +3683,7 @@
Modifier.preferredSize(sizeDp * 2)
.gravity(Alignment.End)
.onPositioned { coordinates: LayoutCoordinates ->
- childPosition[1] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
+ childPosition[1] = coordinates.localToGlobal(PxPosition(0f, 0f))
drawLatch.countDown()
}
) {
@@ -3608,8 +3693,8 @@
assertTrue(drawLatch.await(1, TimeUnit.SECONDS))
- assertEquals(PxPosition(0.px, 0.px), childPosition[0])
- assertEquals(PxPosition(0.px, size.toPx()), childPosition[1])
+ assertEquals(PxPosition(0f, 0f), childPosition[0])
+ assertEquals(PxPosition(0f, size.toPx().value), childPosition[1])
}
@Test
@@ -3625,7 +3710,7 @@
Modifier.preferredSize(sizeDp)
.alignWithSiblings { it.width }
.onPositioned { coordinates: LayoutCoordinates ->
- childPosition[0] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
+ childPosition[0] = coordinates.localToGlobal(PxPosition(0f, 0f))
drawLatch.countDown()
}
) {
@@ -3635,7 +3720,7 @@
Modifier.preferredSize(sizeDp)
.alignWithSiblings { it.width / 2 }
.onPositioned { coordinates: LayoutCoordinates ->
- childPosition[1] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
+ childPosition[1] = coordinates.localToGlobal(PxPosition(0f, 0f))
drawLatch.countDown()
}
) {
@@ -3648,9 +3733,9 @@
waitForDraw(root)
val rootWidth = root.width.px
- assertEquals(PxPosition(rootWidth - size.toPx(), 0.px), childPosition[0])
+ assertEquals(PxPosition((rootWidth - size.toPx()).value, 0f), childPosition[0])
assertEquals(
- PxPosition((rootWidth - size.toPx() * 1.5f).round().toPx(), size.toPx()),
+ PxPosition((rootWidth - size.toPx() * 1.5f).round().toPx().value, size.toPx().value),
childPosition[1]
)
}
diff --git a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/StackTest.kt b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/StackTest.kt
index f526ad5..b938841 100644
--- a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/StackTest.kt
+++ b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/StackTest.kt
@@ -36,7 +36,6 @@
import androidx.ui.unit.PxPosition
import androidx.ui.unit.dp
import androidx.ui.unit.ipx
-import androidx.ui.unit.px
import androidx.ui.unit.toPx
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
@@ -92,7 +91,7 @@
assertEquals(IntPxSize(size, size), stackSize.value)
assertEquals(IntPxSize(size, size), alignedChildSize.value)
- assertEquals(PxPosition(0.px, 0.px), alignedChildPosition.value)
+ assertEquals(PxPosition(0f, 0f), alignedChildPosition.value)
assertEquals(IntPxSize(30.dp.toIntPx(), 30.dp.toIntPx()), positionedChildSize.value)
assertEquals(PxPosition(10.dp.toIntPx(), 10.dp.toIntPx()), positionedChildPosition.value)
}
@@ -145,7 +144,7 @@
assertEquals(IntPxSize(size, size), childSize[0].value)
assertEquals(PxPosition(size, size), childPosition[0].value)
assertEquals(IntPxSize(doubleSize, doubleSize), childSize[1].value)
- assertEquals(PxPosition(0.px, 0.px), childPosition[1].value)
+ assertEquals(PxPosition(0f, 0f), childPosition[1].value)
}
@Test
@@ -215,11 +214,11 @@
assertEquals(IntPxSize(size, size), stackSize.value)
assertEquals(IntPxSize(size, size), childSize[0].value)
- assertEquals(PxPosition(0.px, 0.px), childPosition[0].value)
+ assertEquals(PxPosition(0f, 0f), childPosition[0].value)
assertEquals(IntPxSize(size - inset, size - inset), childSize[1].value)
assertEquals(PxPosition(inset, inset), childPosition[1].value)
assertEquals(IntPxSize(size - inset, size - inset), childSize[2].value)
- assertEquals(PxPosition(0.px, 0.px), childPosition[2].value)
+ assertEquals(PxPosition(0f, 0f), childPosition[2].value)
assertEquals(IntPxSize(size - inset * 2, size), childSize[3].value)
assertEquals(PxPosition(inset, 0.ipx), childPosition[3].value)
assertEquals(IntPxSize(size, size - inset * 2), childSize[4].value)
@@ -307,13 +306,19 @@
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
assertEquals(IntPxSize(tripleSize, tripleSize), stackSize.value)
- assertEquals(PxPosition((size * 2).toPx(), 0.px), childPosition[0].value)
+ assertEquals(PxPosition((size * 2).value.toFloat(), 0f), childPosition[0].value)
assertEquals(PxPosition(size, 0.ipx), childPosition[1].value)
assertEquals(PxPosition(0.ipx, 0.ipx), childPosition[2].value)
- assertEquals(PxPosition((size * 2).toPx(), size.toPx()), childPosition[3].value)
+ assertEquals(PxPosition((size * 2).toPx().value, size.toPx().value), childPosition[3].value)
assertEquals(PxPosition(size, size), childPosition[4].value)
assertEquals(PxPosition(0.ipx, size), childPosition[5].value)
- assertEquals(PxPosition((size * 2).toPx(), (size * 2).toPx()), childPosition[6].value)
+ assertEquals(
+ PxPosition(
+ (size * 2).toPx().value,
+ (size * 2).toPx().value
+ ),
+ childPosition[6].value
+ )
assertEquals(PxPosition(size, size * 2), childPosition[7].value)
assertEquals(PxPosition(0.ipx, size * 2), childPosition[8].value)
}
@@ -360,7 +365,7 @@
assertEquals(IntPxSize(size, size), stackSize.value)
assertEquals(IntPxSize(size, size), childSize[0].value)
- assertEquals(PxPosition(0.px, 0.px), childPosition[0].value)
+ assertEquals(PxPosition(0f, 0f), childPosition[0].value)
assertEquals(IntPxSize(halfSize, halfSize), childSize[1].value)
assertEquals(PxPosition(size - halfSize, size - halfSize), childPosition[1].value)
}
diff --git a/ui/ui-layout/src/main/java/androidx/ui/layout/ConstraintLayout.kt b/ui/ui-layout/src/main/java/androidx/ui/layout/ConstraintLayout.kt
index bbe666f..6dcef13 100644
--- a/ui/ui-layout/src/main/java/androidx/ui/layout/ConstraintLayout.kt
+++ b/ui/ui-layout/src/main/java/androidx/ui/layout/ConstraintLayout.kt
@@ -956,7 +956,7 @@
val measurable = child.companionWidget
if (measurable !is Measurable) continue
// TODO(popam): check if measurer's rtl support should be used instead
- placeables[measurable]?.place(IntPx(child.x), IntPx(child.y))
+ placeables[measurable]?.place(child.x.ipx, child.y.ipx)
}
}
diff --git a/ui/ui-layout/src/main/java/androidx/ui/layout/LayoutOffset.kt b/ui/ui-layout/src/main/java/androidx/ui/layout/LayoutOffset.kt
index b135c8e..11859141 100644
--- a/ui/ui-layout/src/main/java/androidx/ui/layout/LayoutOffset.kt
+++ b/ui/ui-layout/src/main/java/androidx/ui/layout/LayoutOffset.kt
@@ -26,8 +26,9 @@
import androidx.ui.core.MeasureScope
import androidx.ui.core.Modifier
import androidx.ui.unit.Dp
-import androidx.ui.unit.Px
import androidx.ui.unit.dp
+import androidx.ui.unit.ipx
+import kotlin.math.roundToInt
/**
* Offset the content by ([x] dp, [y] dp). The offsets can be positive as well as non positive.
@@ -46,8 +47,8 @@
* @sample androidx.ui.layout.samples.LayoutOffsetPxModifier
*/
fun Modifier.offsetPx(
- x: State<Px> = mutableStateOf(Px.Zero),
- y: State<Px> = mutableStateOf(Px.Zero)
+ x: State<Float> = mutableStateOf(0f),
+ y: State<Float> = mutableStateOf(0f)
) = this + OffsetPxModifier(x, y)
private data class OffsetModifier(val x: Dp, val y: Dp) : LayoutModifier {
@@ -63,7 +64,7 @@
}
}
-private data class OffsetPxModifier(val x: State<Px>, val y: State<Px>) : LayoutModifier {
+private data class OffsetPxModifier(val x: State<Float>, val y: State<Float>) : LayoutModifier {
override fun MeasureScope.measure(
measurable: Measurable,
constraints: Constraints,
@@ -71,7 +72,7 @@
): MeasureScope.MeasureResult {
val placeable = measurable.measure(constraints)
return layout(placeable.width, placeable.height) {
- placeable.place(x.value, y.value)
+ placeable.place(x.value.roundToInt().ipx, y.value.roundToInt().ipx)
}
}
}
diff --git a/ui/ui-material/api/0.1.0-dev14.txt b/ui/ui-material/api/0.1.0-dev14.txt
index 0821452..1c47c92 100644
--- a/ui/ui-material/api/0.1.0-dev14.txt
+++ b/ui/ui-material/api/0.1.0-dev14.txt
@@ -12,25 +12,11 @@
}
public final class AppBarKt {
- method @androidx.compose.Composable public static void BottomAppBar-GqrRtJg(androidx.ui.core.Modifier modifier = Modifier, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), androidx.ui.material.BottomAppBar.FabConfiguration? fabConfiguration = null, androidx.ui.graphics.Shape? cutoutShape = null, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> content);
+ method @androidx.compose.Composable public static void BottomAppBar-RAvbXkg(androidx.ui.core.Modifier modifier = Modifier, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), androidx.ui.graphics.Shape? cutoutShape = null, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> content);
method @androidx.compose.Composable public static void TopAppBar-FikZsjU(kotlin.jvm.functions.Function0<kotlin.Unit> title, androidx.ui.core.Modifier modifier = Modifier, kotlin.jvm.functions.Function0<kotlin.Unit>? navigationIcon = null, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> actions = {}, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), float elevation = androidx.ui.material.AppBarKt.TopAppBarElevation);
method @androidx.compose.Composable public static void TopAppBar-oP-1cd0(androidx.ui.core.Modifier modifier = Modifier, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), float elevation = androidx.ui.material.AppBarKt.TopAppBarElevation, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> content);
}
- public final class BottomAppBar {
- field public static final androidx.ui.material.BottomAppBar! INSTANCE;
- }
-
- @androidx.compose.Immutable public static final class BottomAppBar.FabConfiguration {
- ctor public BottomAppBar.FabConfiguration(internal androidx.ui.unit.IntPxSize fabSize, internal androidx.ui.unit.PxPosition fabTopLeftPosition, internal androidx.ui.material.BottomAppBar.FabDockedPosition fabDockedPosition);
- method @androidx.compose.Immutable public androidx.ui.material.BottomAppBar.FabConfiguration copy(androidx.ui.unit.IntPxSize fabSize, androidx.ui.unit.PxPosition fabTopLeftPosition, androidx.ui.material.BottomAppBar.FabDockedPosition fabDockedPosition);
- }
-
- public enum BottomAppBar.FabDockedPosition {
- enum_constant public static final androidx.ui.material.BottomAppBar.FabDockedPosition Center;
- enum_constant public static final androidx.ui.material.BottomAppBar.FabDockedPosition End;
- }
-
public final class BottomNavigationKt {
method @androidx.compose.Composable public static void BottomNavigation-oP-1cd0(androidx.ui.core.Modifier modifier = Modifier, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), float elevation = androidx.ui.material.BottomNavigationKt.BottomNavigationElevation, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> content);
method @androidx.compose.Composable public static void BottomNavigationItem-dOPBtLY(kotlin.jvm.functions.Function0<kotlin.Unit> icon, kotlin.jvm.functions.Function0<kotlin.Unit> text = emptyContent(), boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onSelected, androidx.ui.core.Modifier modifier = Modifier, boolean alwaysShowLabels = true, long activeColor = contentColor(), long inactiveColor = EmphasisAmbient.current.medium.applyEmphasis(activeColor));
@@ -199,26 +185,30 @@
public enum Scaffold.FabPosition {
enum_constant public static final androidx.ui.material.Scaffold.FabPosition Center;
- enum_constant public static final androidx.ui.material.Scaffold.FabPosition CenterDocked;
enum_constant public static final androidx.ui.material.Scaffold.FabPosition End;
- enum_constant public static final androidx.ui.material.Scaffold.FabPosition EndDocked;
}
public final class ScaffoldKt {
- method @androidx.compose.Composable public static void Scaffold(androidx.ui.material.ScaffoldState scaffoldState = remember({
+ method @androidx.compose.Composable public static void Scaffold-1z1vkZI(androidx.ui.material.ScaffoldState scaffoldState = remember({
return <init>()
-}), kotlin.jvm.functions.Function0<kotlin.Unit>? topAppBar = null, kotlin.jvm.functions.Function1<? super androidx.ui.material.BottomAppBar.FabConfiguration,kotlin.Unit>? bottomAppBar = null, kotlin.jvm.functions.Function0<kotlin.Unit>? floatingActionButton = null, androidx.ui.material.Scaffold.FabPosition floatingActionButtonPosition = androidx.ui.material.Scaffold.FabPosition.End, kotlin.jvm.functions.Function0<kotlin.Unit>? drawerContent = null, kotlin.jvm.functions.Function1<? super androidx.ui.core.Modifier,kotlin.Unit> bodyContent);
+}), kotlin.jvm.functions.Function0<kotlin.Unit>? topBar = null, kotlin.jvm.functions.Function0<kotlin.Unit>? bottomBar = null, kotlin.jvm.functions.Function0<kotlin.Unit>? floatingActionButton = null, androidx.ui.material.Scaffold.FabPosition floatingActionButtonPosition = androidx.ui.material.Scaffold.FabPosition.End, boolean isFloatingActionButtonDocked = false, kotlin.jvm.functions.Function0<kotlin.Unit>? drawerContent = null, androidx.ui.graphics.Shape drawerShape = large, float drawerElevation = DrawerConstants.DefaultElevation, long backgroundColor = MaterialTheme.colors.background, kotlin.jvm.functions.Function1<? super androidx.ui.layout.InnerPadding,kotlin.Unit> bodyContent);
}
@androidx.compose.Stable public final class ScaffoldState {
ctor public ScaffoldState(androidx.ui.material.DrawerState drawerState, boolean isDrawerGesturesEnabled);
ctor public ScaffoldState();
+ method public androidx.ui.unit.PxSize? getBottomBarSize();
method public androidx.ui.material.DrawerState getDrawerState();
+ method public androidx.ui.unit.PxSize? getFloatingActionButtonSize();
+ method public androidx.ui.unit.PxSize? getTopBarSize();
method public boolean isDrawerGesturesEnabled();
method public void setDrawerGesturesEnabled(boolean p);
method public void setDrawerState(androidx.ui.material.DrawerState p);
+ property public final androidx.ui.unit.PxSize? bottomBarSize;
property public final androidx.ui.material.DrawerState drawerState;
+ property public final androidx.ui.unit.PxSize? floatingActionButtonSize;
property public final boolean isDrawerGesturesEnabled;
+ property public final androidx.ui.unit.PxSize? topBarSize;
}
public final class Shapes {
diff --git a/ui/ui-material/api/current.txt b/ui/ui-material/api/current.txt
index 0821452..1c47c92 100644
--- a/ui/ui-material/api/current.txt
+++ b/ui/ui-material/api/current.txt
@@ -12,25 +12,11 @@
}
public final class AppBarKt {
- method @androidx.compose.Composable public static void BottomAppBar-GqrRtJg(androidx.ui.core.Modifier modifier = Modifier, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), androidx.ui.material.BottomAppBar.FabConfiguration? fabConfiguration = null, androidx.ui.graphics.Shape? cutoutShape = null, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> content);
+ method @androidx.compose.Composable public static void BottomAppBar-RAvbXkg(androidx.ui.core.Modifier modifier = Modifier, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), androidx.ui.graphics.Shape? cutoutShape = null, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> content);
method @androidx.compose.Composable public static void TopAppBar-FikZsjU(kotlin.jvm.functions.Function0<kotlin.Unit> title, androidx.ui.core.Modifier modifier = Modifier, kotlin.jvm.functions.Function0<kotlin.Unit>? navigationIcon = null, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> actions = {}, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), float elevation = androidx.ui.material.AppBarKt.TopAppBarElevation);
method @androidx.compose.Composable public static void TopAppBar-oP-1cd0(androidx.ui.core.Modifier modifier = Modifier, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), float elevation = androidx.ui.material.AppBarKt.TopAppBarElevation, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> content);
}
- public final class BottomAppBar {
- field public static final androidx.ui.material.BottomAppBar! INSTANCE;
- }
-
- @androidx.compose.Immutable public static final class BottomAppBar.FabConfiguration {
- ctor public BottomAppBar.FabConfiguration(internal androidx.ui.unit.IntPxSize fabSize, internal androidx.ui.unit.PxPosition fabTopLeftPosition, internal androidx.ui.material.BottomAppBar.FabDockedPosition fabDockedPosition);
- method @androidx.compose.Immutable public androidx.ui.material.BottomAppBar.FabConfiguration copy(androidx.ui.unit.IntPxSize fabSize, androidx.ui.unit.PxPosition fabTopLeftPosition, androidx.ui.material.BottomAppBar.FabDockedPosition fabDockedPosition);
- }
-
- public enum BottomAppBar.FabDockedPosition {
- enum_constant public static final androidx.ui.material.BottomAppBar.FabDockedPosition Center;
- enum_constant public static final androidx.ui.material.BottomAppBar.FabDockedPosition End;
- }
-
public final class BottomNavigationKt {
method @androidx.compose.Composable public static void BottomNavigation-oP-1cd0(androidx.ui.core.Modifier modifier = Modifier, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), float elevation = androidx.ui.material.BottomNavigationKt.BottomNavigationElevation, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> content);
method @androidx.compose.Composable public static void BottomNavigationItem-dOPBtLY(kotlin.jvm.functions.Function0<kotlin.Unit> icon, kotlin.jvm.functions.Function0<kotlin.Unit> text = emptyContent(), boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onSelected, androidx.ui.core.Modifier modifier = Modifier, boolean alwaysShowLabels = true, long activeColor = contentColor(), long inactiveColor = EmphasisAmbient.current.medium.applyEmphasis(activeColor));
@@ -199,26 +185,30 @@
public enum Scaffold.FabPosition {
enum_constant public static final androidx.ui.material.Scaffold.FabPosition Center;
- enum_constant public static final androidx.ui.material.Scaffold.FabPosition CenterDocked;
enum_constant public static final androidx.ui.material.Scaffold.FabPosition End;
- enum_constant public static final androidx.ui.material.Scaffold.FabPosition EndDocked;
}
public final class ScaffoldKt {
- method @androidx.compose.Composable public static void Scaffold(androidx.ui.material.ScaffoldState scaffoldState = remember({
+ method @androidx.compose.Composable public static void Scaffold-1z1vkZI(androidx.ui.material.ScaffoldState scaffoldState = remember({
return <init>()
-}), kotlin.jvm.functions.Function0<kotlin.Unit>? topAppBar = null, kotlin.jvm.functions.Function1<? super androidx.ui.material.BottomAppBar.FabConfiguration,kotlin.Unit>? bottomAppBar = null, kotlin.jvm.functions.Function0<kotlin.Unit>? floatingActionButton = null, androidx.ui.material.Scaffold.FabPosition floatingActionButtonPosition = androidx.ui.material.Scaffold.FabPosition.End, kotlin.jvm.functions.Function0<kotlin.Unit>? drawerContent = null, kotlin.jvm.functions.Function1<? super androidx.ui.core.Modifier,kotlin.Unit> bodyContent);
+}), kotlin.jvm.functions.Function0<kotlin.Unit>? topBar = null, kotlin.jvm.functions.Function0<kotlin.Unit>? bottomBar = null, kotlin.jvm.functions.Function0<kotlin.Unit>? floatingActionButton = null, androidx.ui.material.Scaffold.FabPosition floatingActionButtonPosition = androidx.ui.material.Scaffold.FabPosition.End, boolean isFloatingActionButtonDocked = false, kotlin.jvm.functions.Function0<kotlin.Unit>? drawerContent = null, androidx.ui.graphics.Shape drawerShape = large, float drawerElevation = DrawerConstants.DefaultElevation, long backgroundColor = MaterialTheme.colors.background, kotlin.jvm.functions.Function1<? super androidx.ui.layout.InnerPadding,kotlin.Unit> bodyContent);
}
@androidx.compose.Stable public final class ScaffoldState {
ctor public ScaffoldState(androidx.ui.material.DrawerState drawerState, boolean isDrawerGesturesEnabled);
ctor public ScaffoldState();
+ method public androidx.ui.unit.PxSize? getBottomBarSize();
method public androidx.ui.material.DrawerState getDrawerState();
+ method public androidx.ui.unit.PxSize? getFloatingActionButtonSize();
+ method public androidx.ui.unit.PxSize? getTopBarSize();
method public boolean isDrawerGesturesEnabled();
method public void setDrawerGesturesEnabled(boolean p);
method public void setDrawerState(androidx.ui.material.DrawerState p);
+ property public final androidx.ui.unit.PxSize? bottomBarSize;
property public final androidx.ui.material.DrawerState drawerState;
+ property public final androidx.ui.unit.PxSize? floatingActionButtonSize;
property public final boolean isDrawerGesturesEnabled;
+ property public final androidx.ui.unit.PxSize? topBarSize;
}
public final class Shapes {
diff --git a/ui/ui-material/api/public_plus_experimental_0.1.0-dev14.txt b/ui/ui-material/api/public_plus_experimental_0.1.0-dev14.txt
index 0821452..1c47c92 100644
--- a/ui/ui-material/api/public_plus_experimental_0.1.0-dev14.txt
+++ b/ui/ui-material/api/public_plus_experimental_0.1.0-dev14.txt
@@ -12,25 +12,11 @@
}
public final class AppBarKt {
- method @androidx.compose.Composable public static void BottomAppBar-GqrRtJg(androidx.ui.core.Modifier modifier = Modifier, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), androidx.ui.material.BottomAppBar.FabConfiguration? fabConfiguration = null, androidx.ui.graphics.Shape? cutoutShape = null, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> content);
+ method @androidx.compose.Composable public static void BottomAppBar-RAvbXkg(androidx.ui.core.Modifier modifier = Modifier, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), androidx.ui.graphics.Shape? cutoutShape = null, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> content);
method @androidx.compose.Composable public static void TopAppBar-FikZsjU(kotlin.jvm.functions.Function0<kotlin.Unit> title, androidx.ui.core.Modifier modifier = Modifier, kotlin.jvm.functions.Function0<kotlin.Unit>? navigationIcon = null, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> actions = {}, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), float elevation = androidx.ui.material.AppBarKt.TopAppBarElevation);
method @androidx.compose.Composable public static void TopAppBar-oP-1cd0(androidx.ui.core.Modifier modifier = Modifier, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), float elevation = androidx.ui.material.AppBarKt.TopAppBarElevation, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> content);
}
- public final class BottomAppBar {
- field public static final androidx.ui.material.BottomAppBar! INSTANCE;
- }
-
- @androidx.compose.Immutable public static final class BottomAppBar.FabConfiguration {
- ctor public BottomAppBar.FabConfiguration(internal androidx.ui.unit.IntPxSize fabSize, internal androidx.ui.unit.PxPosition fabTopLeftPosition, internal androidx.ui.material.BottomAppBar.FabDockedPosition fabDockedPosition);
- method @androidx.compose.Immutable public androidx.ui.material.BottomAppBar.FabConfiguration copy(androidx.ui.unit.IntPxSize fabSize, androidx.ui.unit.PxPosition fabTopLeftPosition, androidx.ui.material.BottomAppBar.FabDockedPosition fabDockedPosition);
- }
-
- public enum BottomAppBar.FabDockedPosition {
- enum_constant public static final androidx.ui.material.BottomAppBar.FabDockedPosition Center;
- enum_constant public static final androidx.ui.material.BottomAppBar.FabDockedPosition End;
- }
-
public final class BottomNavigationKt {
method @androidx.compose.Composable public static void BottomNavigation-oP-1cd0(androidx.ui.core.Modifier modifier = Modifier, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), float elevation = androidx.ui.material.BottomNavigationKt.BottomNavigationElevation, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> content);
method @androidx.compose.Composable public static void BottomNavigationItem-dOPBtLY(kotlin.jvm.functions.Function0<kotlin.Unit> icon, kotlin.jvm.functions.Function0<kotlin.Unit> text = emptyContent(), boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onSelected, androidx.ui.core.Modifier modifier = Modifier, boolean alwaysShowLabels = true, long activeColor = contentColor(), long inactiveColor = EmphasisAmbient.current.medium.applyEmphasis(activeColor));
@@ -199,26 +185,30 @@
public enum Scaffold.FabPosition {
enum_constant public static final androidx.ui.material.Scaffold.FabPosition Center;
- enum_constant public static final androidx.ui.material.Scaffold.FabPosition CenterDocked;
enum_constant public static final androidx.ui.material.Scaffold.FabPosition End;
- enum_constant public static final androidx.ui.material.Scaffold.FabPosition EndDocked;
}
public final class ScaffoldKt {
- method @androidx.compose.Composable public static void Scaffold(androidx.ui.material.ScaffoldState scaffoldState = remember({
+ method @androidx.compose.Composable public static void Scaffold-1z1vkZI(androidx.ui.material.ScaffoldState scaffoldState = remember({
return <init>()
-}), kotlin.jvm.functions.Function0<kotlin.Unit>? topAppBar = null, kotlin.jvm.functions.Function1<? super androidx.ui.material.BottomAppBar.FabConfiguration,kotlin.Unit>? bottomAppBar = null, kotlin.jvm.functions.Function0<kotlin.Unit>? floatingActionButton = null, androidx.ui.material.Scaffold.FabPosition floatingActionButtonPosition = androidx.ui.material.Scaffold.FabPosition.End, kotlin.jvm.functions.Function0<kotlin.Unit>? drawerContent = null, kotlin.jvm.functions.Function1<? super androidx.ui.core.Modifier,kotlin.Unit> bodyContent);
+}), kotlin.jvm.functions.Function0<kotlin.Unit>? topBar = null, kotlin.jvm.functions.Function0<kotlin.Unit>? bottomBar = null, kotlin.jvm.functions.Function0<kotlin.Unit>? floatingActionButton = null, androidx.ui.material.Scaffold.FabPosition floatingActionButtonPosition = androidx.ui.material.Scaffold.FabPosition.End, boolean isFloatingActionButtonDocked = false, kotlin.jvm.functions.Function0<kotlin.Unit>? drawerContent = null, androidx.ui.graphics.Shape drawerShape = large, float drawerElevation = DrawerConstants.DefaultElevation, long backgroundColor = MaterialTheme.colors.background, kotlin.jvm.functions.Function1<? super androidx.ui.layout.InnerPadding,kotlin.Unit> bodyContent);
}
@androidx.compose.Stable public final class ScaffoldState {
ctor public ScaffoldState(androidx.ui.material.DrawerState drawerState, boolean isDrawerGesturesEnabled);
ctor public ScaffoldState();
+ method public androidx.ui.unit.PxSize? getBottomBarSize();
method public androidx.ui.material.DrawerState getDrawerState();
+ method public androidx.ui.unit.PxSize? getFloatingActionButtonSize();
+ method public androidx.ui.unit.PxSize? getTopBarSize();
method public boolean isDrawerGesturesEnabled();
method public void setDrawerGesturesEnabled(boolean p);
method public void setDrawerState(androidx.ui.material.DrawerState p);
+ property public final androidx.ui.unit.PxSize? bottomBarSize;
property public final androidx.ui.material.DrawerState drawerState;
+ property public final androidx.ui.unit.PxSize? floatingActionButtonSize;
property public final boolean isDrawerGesturesEnabled;
+ property public final androidx.ui.unit.PxSize? topBarSize;
}
public final class Shapes {
diff --git a/ui/ui-material/api/public_plus_experimental_current.txt b/ui/ui-material/api/public_plus_experimental_current.txt
index 0821452..1c47c92 100644
--- a/ui/ui-material/api/public_plus_experimental_current.txt
+++ b/ui/ui-material/api/public_plus_experimental_current.txt
@@ -12,25 +12,11 @@
}
public final class AppBarKt {
- method @androidx.compose.Composable public static void BottomAppBar-GqrRtJg(androidx.ui.core.Modifier modifier = Modifier, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), androidx.ui.material.BottomAppBar.FabConfiguration? fabConfiguration = null, androidx.ui.graphics.Shape? cutoutShape = null, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> content);
+ method @androidx.compose.Composable public static void BottomAppBar-RAvbXkg(androidx.ui.core.Modifier modifier = Modifier, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), androidx.ui.graphics.Shape? cutoutShape = null, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> content);
method @androidx.compose.Composable public static void TopAppBar-FikZsjU(kotlin.jvm.functions.Function0<kotlin.Unit> title, androidx.ui.core.Modifier modifier = Modifier, kotlin.jvm.functions.Function0<kotlin.Unit>? navigationIcon = null, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> actions = {}, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), float elevation = androidx.ui.material.AppBarKt.TopAppBarElevation);
method @androidx.compose.Composable public static void TopAppBar-oP-1cd0(androidx.ui.core.Modifier modifier = Modifier, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), float elevation = androidx.ui.material.AppBarKt.TopAppBarElevation, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> content);
}
- public final class BottomAppBar {
- field public static final androidx.ui.material.BottomAppBar! INSTANCE;
- }
-
- @androidx.compose.Immutable public static final class BottomAppBar.FabConfiguration {
- ctor public BottomAppBar.FabConfiguration(internal androidx.ui.unit.IntPxSize fabSize, internal androidx.ui.unit.PxPosition fabTopLeftPosition, internal androidx.ui.material.BottomAppBar.FabDockedPosition fabDockedPosition);
- method @androidx.compose.Immutable public androidx.ui.material.BottomAppBar.FabConfiguration copy(androidx.ui.unit.IntPxSize fabSize, androidx.ui.unit.PxPosition fabTopLeftPosition, androidx.ui.material.BottomAppBar.FabDockedPosition fabDockedPosition);
- }
-
- public enum BottomAppBar.FabDockedPosition {
- enum_constant public static final androidx.ui.material.BottomAppBar.FabDockedPosition Center;
- enum_constant public static final androidx.ui.material.BottomAppBar.FabDockedPosition End;
- }
-
public final class BottomNavigationKt {
method @androidx.compose.Composable public static void BottomNavigation-oP-1cd0(androidx.ui.core.Modifier modifier = Modifier, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), float elevation = androidx.ui.material.BottomNavigationKt.BottomNavigationElevation, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> content);
method @androidx.compose.Composable public static void BottomNavigationItem-dOPBtLY(kotlin.jvm.functions.Function0<kotlin.Unit> icon, kotlin.jvm.functions.Function0<kotlin.Unit> text = emptyContent(), boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onSelected, androidx.ui.core.Modifier modifier = Modifier, boolean alwaysShowLabels = true, long activeColor = contentColor(), long inactiveColor = EmphasisAmbient.current.medium.applyEmphasis(activeColor));
@@ -199,26 +185,30 @@
public enum Scaffold.FabPosition {
enum_constant public static final androidx.ui.material.Scaffold.FabPosition Center;
- enum_constant public static final androidx.ui.material.Scaffold.FabPosition CenterDocked;
enum_constant public static final androidx.ui.material.Scaffold.FabPosition End;
- enum_constant public static final androidx.ui.material.Scaffold.FabPosition EndDocked;
}
public final class ScaffoldKt {
- method @androidx.compose.Composable public static void Scaffold(androidx.ui.material.ScaffoldState scaffoldState = remember({
+ method @androidx.compose.Composable public static void Scaffold-1z1vkZI(androidx.ui.material.ScaffoldState scaffoldState = remember({
return <init>()
-}), kotlin.jvm.functions.Function0<kotlin.Unit>? topAppBar = null, kotlin.jvm.functions.Function1<? super androidx.ui.material.BottomAppBar.FabConfiguration,kotlin.Unit>? bottomAppBar = null, kotlin.jvm.functions.Function0<kotlin.Unit>? floatingActionButton = null, androidx.ui.material.Scaffold.FabPosition floatingActionButtonPosition = androidx.ui.material.Scaffold.FabPosition.End, kotlin.jvm.functions.Function0<kotlin.Unit>? drawerContent = null, kotlin.jvm.functions.Function1<? super androidx.ui.core.Modifier,kotlin.Unit> bodyContent);
+}), kotlin.jvm.functions.Function0<kotlin.Unit>? topBar = null, kotlin.jvm.functions.Function0<kotlin.Unit>? bottomBar = null, kotlin.jvm.functions.Function0<kotlin.Unit>? floatingActionButton = null, androidx.ui.material.Scaffold.FabPosition floatingActionButtonPosition = androidx.ui.material.Scaffold.FabPosition.End, boolean isFloatingActionButtonDocked = false, kotlin.jvm.functions.Function0<kotlin.Unit>? drawerContent = null, androidx.ui.graphics.Shape drawerShape = large, float drawerElevation = DrawerConstants.DefaultElevation, long backgroundColor = MaterialTheme.colors.background, kotlin.jvm.functions.Function1<? super androidx.ui.layout.InnerPadding,kotlin.Unit> bodyContent);
}
@androidx.compose.Stable public final class ScaffoldState {
ctor public ScaffoldState(androidx.ui.material.DrawerState drawerState, boolean isDrawerGesturesEnabled);
ctor public ScaffoldState();
+ method public androidx.ui.unit.PxSize? getBottomBarSize();
method public androidx.ui.material.DrawerState getDrawerState();
+ method public androidx.ui.unit.PxSize? getFloatingActionButtonSize();
+ method public androidx.ui.unit.PxSize? getTopBarSize();
method public boolean isDrawerGesturesEnabled();
method public void setDrawerGesturesEnabled(boolean p);
method public void setDrawerState(androidx.ui.material.DrawerState p);
+ property public final androidx.ui.unit.PxSize? bottomBarSize;
property public final androidx.ui.material.DrawerState drawerState;
+ property public final androidx.ui.unit.PxSize? floatingActionButtonSize;
property public final boolean isDrawerGesturesEnabled;
+ property public final androidx.ui.unit.PxSize? topBarSize;
}
public final class Shapes {
diff --git a/ui/ui-material/api/restricted_0.1.0-dev14.txt b/ui/ui-material/api/restricted_0.1.0-dev14.txt
index 10cc7c3..863b170 100644
--- a/ui/ui-material/api/restricted_0.1.0-dev14.txt
+++ b/ui/ui-material/api/restricted_0.1.0-dev14.txt
@@ -12,25 +12,11 @@
}
public final class AppBarKt {
- method @androidx.compose.Composable public static void BottomAppBar-GqrRtJg(androidx.ui.core.Modifier modifier = Modifier, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), androidx.ui.material.BottomAppBar.FabConfiguration? fabConfiguration = null, androidx.ui.graphics.Shape? cutoutShape = null, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> content);
+ method @androidx.compose.Composable public static void BottomAppBar-RAvbXkg(androidx.ui.core.Modifier modifier = Modifier, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), androidx.ui.graphics.Shape? cutoutShape = null, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> content);
method @androidx.compose.Composable public static void TopAppBar-FikZsjU(kotlin.jvm.functions.Function0<kotlin.Unit> title, androidx.ui.core.Modifier modifier = Modifier, kotlin.jvm.functions.Function0<kotlin.Unit>? navigationIcon = null, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> actions = {}, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), float elevation = androidx.ui.material.AppBarKt.TopAppBarElevation);
method @androidx.compose.Composable public static void TopAppBar-oP-1cd0(androidx.ui.core.Modifier modifier = Modifier, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), float elevation = androidx.ui.material.AppBarKt.TopAppBarElevation, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> content);
}
- public final class BottomAppBar {
- field public static final androidx.ui.material.BottomAppBar! INSTANCE;
- }
-
- @androidx.compose.Immutable public static final class BottomAppBar.FabConfiguration {
- ctor public BottomAppBar.FabConfiguration(internal androidx.ui.unit.IntPxSize fabSize, internal androidx.ui.unit.PxPosition fabTopLeftPosition, internal androidx.ui.material.BottomAppBar.FabDockedPosition fabDockedPosition);
- method @androidx.compose.Immutable public androidx.ui.material.BottomAppBar.FabConfiguration copy(androidx.ui.unit.IntPxSize fabSize, androidx.ui.unit.PxPosition fabTopLeftPosition, androidx.ui.material.BottomAppBar.FabDockedPosition fabDockedPosition);
- }
-
- public enum BottomAppBar.FabDockedPosition {
- enum_constant public static final androidx.ui.material.BottomAppBar.FabDockedPosition Center;
- enum_constant public static final androidx.ui.material.BottomAppBar.FabDockedPosition End;
- }
-
public final class BottomNavigationKt {
method @androidx.compose.Composable public static void BottomNavigation-oP-1cd0(androidx.ui.core.Modifier modifier = Modifier, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), float elevation = androidx.ui.material.BottomNavigationKt.BottomNavigationElevation, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> content);
method @androidx.compose.Composable public static void BottomNavigationItem-dOPBtLY(kotlin.jvm.functions.Function0<kotlin.Unit> icon, kotlin.jvm.functions.Function0<kotlin.Unit> text = emptyContent(), boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onSelected, androidx.ui.core.Modifier modifier = Modifier, boolean alwaysShowLabels = true, long activeColor = contentColor(), long inactiveColor = EmphasisAmbient.current.medium.applyEmphasis(activeColor));
@@ -200,26 +186,30 @@
public enum Scaffold.FabPosition {
enum_constant public static final androidx.ui.material.Scaffold.FabPosition Center;
- enum_constant public static final androidx.ui.material.Scaffold.FabPosition CenterDocked;
enum_constant public static final androidx.ui.material.Scaffold.FabPosition End;
- enum_constant public static final androidx.ui.material.Scaffold.FabPosition EndDocked;
}
public final class ScaffoldKt {
- method @androidx.compose.Composable public static void Scaffold(androidx.ui.material.ScaffoldState scaffoldState = remember({
+ method @androidx.compose.Composable public static void Scaffold-1z1vkZI(androidx.ui.material.ScaffoldState scaffoldState = remember({
return <init>()
-}), kotlin.jvm.functions.Function0<kotlin.Unit>? topAppBar = null, kotlin.jvm.functions.Function1<? super androidx.ui.material.BottomAppBar.FabConfiguration,kotlin.Unit>? bottomAppBar = null, kotlin.jvm.functions.Function0<kotlin.Unit>? floatingActionButton = null, androidx.ui.material.Scaffold.FabPosition floatingActionButtonPosition = androidx.ui.material.Scaffold.FabPosition.End, kotlin.jvm.functions.Function0<kotlin.Unit>? drawerContent = null, kotlin.jvm.functions.Function1<? super androidx.ui.core.Modifier,kotlin.Unit> bodyContent);
+}), kotlin.jvm.functions.Function0<kotlin.Unit>? topBar = null, kotlin.jvm.functions.Function0<kotlin.Unit>? bottomBar = null, kotlin.jvm.functions.Function0<kotlin.Unit>? floatingActionButton = null, androidx.ui.material.Scaffold.FabPosition floatingActionButtonPosition = androidx.ui.material.Scaffold.FabPosition.End, boolean isFloatingActionButtonDocked = false, kotlin.jvm.functions.Function0<kotlin.Unit>? drawerContent = null, androidx.ui.graphics.Shape drawerShape = large, float drawerElevation = DrawerConstants.DefaultElevation, long backgroundColor = MaterialTheme.colors.background, kotlin.jvm.functions.Function1<? super androidx.ui.layout.InnerPadding,kotlin.Unit> bodyContent);
}
@androidx.compose.Stable public final class ScaffoldState {
ctor public ScaffoldState(androidx.ui.material.DrawerState drawerState, boolean isDrawerGesturesEnabled);
ctor public ScaffoldState();
+ method public androidx.ui.unit.PxSize? getBottomBarSize();
method public androidx.ui.material.DrawerState getDrawerState();
+ method public androidx.ui.unit.PxSize? getFloatingActionButtonSize();
+ method public androidx.ui.unit.PxSize? getTopBarSize();
method public boolean isDrawerGesturesEnabled();
method public void setDrawerGesturesEnabled(boolean p);
method public void setDrawerState(androidx.ui.material.DrawerState p);
+ property public final androidx.ui.unit.PxSize? bottomBarSize;
property public final androidx.ui.material.DrawerState drawerState;
+ property public final androidx.ui.unit.PxSize? floatingActionButtonSize;
property public final boolean isDrawerGesturesEnabled;
+ property public final androidx.ui.unit.PxSize? topBarSize;
}
public final class Shapes {
diff --git a/ui/ui-material/api/restricted_current.txt b/ui/ui-material/api/restricted_current.txt
index 10cc7c3..863b170 100644
--- a/ui/ui-material/api/restricted_current.txt
+++ b/ui/ui-material/api/restricted_current.txt
@@ -12,25 +12,11 @@
}
public final class AppBarKt {
- method @androidx.compose.Composable public static void BottomAppBar-GqrRtJg(androidx.ui.core.Modifier modifier = Modifier, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), androidx.ui.material.BottomAppBar.FabConfiguration? fabConfiguration = null, androidx.ui.graphics.Shape? cutoutShape = null, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> content);
+ method @androidx.compose.Composable public static void BottomAppBar-RAvbXkg(androidx.ui.core.Modifier modifier = Modifier, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), androidx.ui.graphics.Shape? cutoutShape = null, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> content);
method @androidx.compose.Composable public static void TopAppBar-FikZsjU(kotlin.jvm.functions.Function0<kotlin.Unit> title, androidx.ui.core.Modifier modifier = Modifier, kotlin.jvm.functions.Function0<kotlin.Unit>? navigationIcon = null, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> actions = {}, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), float elevation = androidx.ui.material.AppBarKt.TopAppBarElevation);
method @androidx.compose.Composable public static void TopAppBar-oP-1cd0(androidx.ui.core.Modifier modifier = Modifier, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), float elevation = androidx.ui.material.AppBarKt.TopAppBarElevation, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> content);
}
- public final class BottomAppBar {
- field public static final androidx.ui.material.BottomAppBar! INSTANCE;
- }
-
- @androidx.compose.Immutable public static final class BottomAppBar.FabConfiguration {
- ctor public BottomAppBar.FabConfiguration(internal androidx.ui.unit.IntPxSize fabSize, internal androidx.ui.unit.PxPosition fabTopLeftPosition, internal androidx.ui.material.BottomAppBar.FabDockedPosition fabDockedPosition);
- method @androidx.compose.Immutable public androidx.ui.material.BottomAppBar.FabConfiguration copy(androidx.ui.unit.IntPxSize fabSize, androidx.ui.unit.PxPosition fabTopLeftPosition, androidx.ui.material.BottomAppBar.FabDockedPosition fabDockedPosition);
- }
-
- public enum BottomAppBar.FabDockedPosition {
- enum_constant public static final androidx.ui.material.BottomAppBar.FabDockedPosition Center;
- enum_constant public static final androidx.ui.material.BottomAppBar.FabDockedPosition End;
- }
-
public final class BottomNavigationKt {
method @androidx.compose.Composable public static void BottomNavigation-oP-1cd0(androidx.ui.core.Modifier modifier = Modifier, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), float elevation = androidx.ui.material.BottomNavigationKt.BottomNavigationElevation, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> content);
method @androidx.compose.Composable public static void BottomNavigationItem-dOPBtLY(kotlin.jvm.functions.Function0<kotlin.Unit> icon, kotlin.jvm.functions.Function0<kotlin.Unit> text = emptyContent(), boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onSelected, androidx.ui.core.Modifier modifier = Modifier, boolean alwaysShowLabels = true, long activeColor = contentColor(), long inactiveColor = EmphasisAmbient.current.medium.applyEmphasis(activeColor));
@@ -200,26 +186,30 @@
public enum Scaffold.FabPosition {
enum_constant public static final androidx.ui.material.Scaffold.FabPosition Center;
- enum_constant public static final androidx.ui.material.Scaffold.FabPosition CenterDocked;
enum_constant public static final androidx.ui.material.Scaffold.FabPosition End;
- enum_constant public static final androidx.ui.material.Scaffold.FabPosition EndDocked;
}
public final class ScaffoldKt {
- method @androidx.compose.Composable public static void Scaffold(androidx.ui.material.ScaffoldState scaffoldState = remember({
+ method @androidx.compose.Composable public static void Scaffold-1z1vkZI(androidx.ui.material.ScaffoldState scaffoldState = remember({
return <init>()
-}), kotlin.jvm.functions.Function0<kotlin.Unit>? topAppBar = null, kotlin.jvm.functions.Function1<? super androidx.ui.material.BottomAppBar.FabConfiguration,kotlin.Unit>? bottomAppBar = null, kotlin.jvm.functions.Function0<kotlin.Unit>? floatingActionButton = null, androidx.ui.material.Scaffold.FabPosition floatingActionButtonPosition = androidx.ui.material.Scaffold.FabPosition.End, kotlin.jvm.functions.Function0<kotlin.Unit>? drawerContent = null, kotlin.jvm.functions.Function1<? super androidx.ui.core.Modifier,kotlin.Unit> bodyContent);
+}), kotlin.jvm.functions.Function0<kotlin.Unit>? topBar = null, kotlin.jvm.functions.Function0<kotlin.Unit>? bottomBar = null, kotlin.jvm.functions.Function0<kotlin.Unit>? floatingActionButton = null, androidx.ui.material.Scaffold.FabPosition floatingActionButtonPosition = androidx.ui.material.Scaffold.FabPosition.End, boolean isFloatingActionButtonDocked = false, kotlin.jvm.functions.Function0<kotlin.Unit>? drawerContent = null, androidx.ui.graphics.Shape drawerShape = large, float drawerElevation = DrawerConstants.DefaultElevation, long backgroundColor = MaterialTheme.colors.background, kotlin.jvm.functions.Function1<? super androidx.ui.layout.InnerPadding,kotlin.Unit> bodyContent);
}
@androidx.compose.Stable public final class ScaffoldState {
ctor public ScaffoldState(androidx.ui.material.DrawerState drawerState, boolean isDrawerGesturesEnabled);
ctor public ScaffoldState();
+ method public androidx.ui.unit.PxSize? getBottomBarSize();
method public androidx.ui.material.DrawerState getDrawerState();
+ method public androidx.ui.unit.PxSize? getFloatingActionButtonSize();
+ method public androidx.ui.unit.PxSize? getTopBarSize();
method public boolean isDrawerGesturesEnabled();
method public void setDrawerGesturesEnabled(boolean p);
method public void setDrawerState(androidx.ui.material.DrawerState p);
+ property public final androidx.ui.unit.PxSize? bottomBarSize;
property public final androidx.ui.material.DrawerState drawerState;
+ property public final androidx.ui.unit.PxSize? floatingActionButtonSize;
property public final boolean isDrawerGesturesEnabled;
+ property public final androidx.ui.unit.PxSize? topBarSize;
}
public final class Shapes {
diff --git a/ui/ui-material/integration-tests/material-demos/src/main/java/androidx/ui/material/demos/ColorPickerDemo.kt b/ui/ui-material/integration-tests/material-demos/src/main/java/androidx/ui/material/demos/ColorPickerDemo.kt
index c836622..23d1bfd 100644
--- a/ui/ui-material/integration-tests/material-demos/src/main/java/androidx/ui/material/demos/ColorPickerDemo.kt
+++ b/ui/ui-material/integration-tests/material-demos/src/main/java/androidx/ui/material/demos/ColorPickerDemo.kt
@@ -341,8 +341,8 @@
* or the color is partially transparent.
*/
private fun ColorWheel.colorForPosition(position: PxPosition): Color {
- val x = position.x.value.toInt().coerceAtLeast(0)
- val y = position.y.value.toInt().coerceAtLeast(0)
+ val x = position.x.toInt().coerceAtLeast(0)
+ val y = position.y.toInt().coerceAtLeast(0)
with(image.toPixelMap()) {
if (x >= width || y >= height) return Color.Unset
return this[x, y].takeIf { it.alpha == 1f } ?: Color.Unset
diff --git a/ui/ui-material/integration-tests/material-demos/src/main/java/androidx/ui/material/demos/DynamicThemeActivity.kt b/ui/ui-material/integration-tests/material-demos/src/main/java/androidx/ui/material/demos/DynamicThemeActivity.kt
index 414841b..7cb0d86 100644
--- a/ui/ui-material/integration-tests/material-demos/src/main/java/androidx/ui/material/demos/DynamicThemeActivity.kt
+++ b/ui/ui-material/integration-tests/material-demos/src/main/java/androidx/ui/material/demos/DynamicThemeActivity.kt
@@ -90,13 +90,14 @@
round((scrollerPosition.value / scrollerPosition.maxPosition) * 100) / 100
remember(fraction) { scrollFraction.value = fraction }
Scaffold(
- topAppBar = { TopAppBar({ Text("Scroll down!") }) },
- bottomAppBar = { BottomAppBar(fabConfiguration = it, cutoutShape = CircleShape) {} },
+ topBar = { TopAppBar({ Text("Scroll down!") }) },
+ bottomBar = { BottomAppBar(cutoutShape = CircleShape) {} },
floatingActionButton = { Fab(scrollFraction) },
- floatingActionButtonPosition = Scaffold.FabPosition.CenterDocked,
- bodyContent = { modifier ->
+ floatingActionButtonPosition = Scaffold.FabPosition.Center,
+ isFloatingActionButtonDocked = true,
+ bodyContent = { innerPadding ->
VerticalScroller(scrollerPosition) {
- Column(modifier) {
+ Column(Modifier.padding(innerPadding)) {
repeat(20) { index ->
Card(index)
}
diff --git a/ui/ui-material/integration-tests/material-studies/src/main/java/androidx/ui/material/studies/rally/RallyActivity.kt b/ui/ui-material/integration-tests/material-studies/src/main/java/androidx/ui/material/studies/rally/RallyActivity.kt
index d04b0fe..fed1f49 100644
--- a/ui/ui-material/integration-tests/material-studies/src/main/java/androidx/ui/material/studies/rally/RallyActivity.kt
+++ b/ui/ui-material/integration-tests/material-studies/src/main/java/androidx/ui/material/studies/rally/RallyActivity.kt
@@ -22,7 +22,10 @@
import androidx.compose.getValue
import androidx.compose.setValue
import androidx.compose.state
+import androidx.ui.core.Modifier
import androidx.ui.core.setContent
+import androidx.ui.foundation.Box
+import androidx.ui.layout.padding
import androidx.ui.material.Scaffold
/**
@@ -44,15 +47,17 @@
val allScreens = RallyScreenState.values().toList()
var currentScreen by state { RallyScreenState.Overview }
Scaffold(
- topAppBar = {
+ topBar = {
RallyTopAppBar(
allScreens = allScreens,
onTabSelected = { screen -> currentScreen = screen },
currentScreen = currentScreen
)
}
- ) {
- currentScreen.body()
+ ) { innerPadding ->
+ Box(Modifier.padding(innerPadding)) {
+ currentScreen.body()
+ }
}
}
}
\ No newline at end of file
diff --git a/ui/ui-material/integration-tests/material-studies/src/main/java/androidx/ui/material/studies/rally/TopAppBar.kt b/ui/ui-material/integration-tests/material-studies/src/main/java/androidx/ui/material/studies/rally/TopAppBar.kt
index 169f1be..9bd87d7 100644
--- a/ui/ui-material/integration-tests/material-studies/src/main/java/androidx/ui/material/studies/rally/TopAppBar.kt
+++ b/ui/ui-material/integration-tests/material-studies/src/main/java/androidx/ui/material/studies/rally/TopAppBar.kt
@@ -23,9 +23,8 @@
import androidx.ui.animation.ColorPropKey
import androidx.ui.animation.Transition
import androidx.ui.core.Modifier
-import androidx.ui.foundation.Box
import androidx.ui.foundation.Text
-import androidx.ui.foundation.selection.MutuallyExclusiveSetItem
+import androidx.ui.foundation.selection.selectable
import androidx.ui.graphics.Color
import androidx.ui.graphics.vector.VectorAsset
import androidx.ui.layout.Row
@@ -36,7 +35,7 @@
import androidx.ui.layout.preferredWidth
import androidx.ui.material.MaterialTheme
import androidx.ui.material.Surface
-import androidx.ui.material.ripple.ripple
+import androidx.ui.material.ripple.RippleIndication
import androidx.ui.unit.dp
import java.util.Locale
@@ -68,19 +67,20 @@
selected: Boolean
) {
TabTransition(selected = selected) { tabTintColor ->
- Box(Modifier.padding(16.dp).preferredHeight(TabHeight)) {
- MutuallyExclusiveSetItem(
- selected = selected,
- onClick = onSelected,
- modifier = Modifier.ripple(bounded = false)
- ) {
- Row {
- Icon(vectorImage = icon, tintColor = tabTintColor)
- if (selected) {
- Spacer(Modifier.preferredWidth(12.dp))
- Text(text, color = tabTintColor)
- }
- }
+ Row(
+ modifier = Modifier
+ .padding(16.dp)
+ .preferredHeight(TabHeight)
+ .selectable(
+ selected = selected,
+ onClick = onSelected,
+ indication = RippleIndication(bounded = false)
+ )
+ ) {
+ Icon(vectorImage = icon, tintColor = tabTintColor)
+ if (selected) {
+ Spacer(Modifier.preferredWidth(12.dp))
+ Text(text, color = tabTintColor)
}
}
}
diff --git a/ui/ui-material/samples/src/main/java/androidx/ui/material/samples/AppBarSamples.kt b/ui/ui-material/samples/src/main/java/androidx/ui/material/samples/AppBarSamples.kt
index 468153e..19f879b 100644
--- a/ui/ui-material/samples/src/main/java/androidx/ui/material/samples/AppBarSamples.kt
+++ b/ui/ui-material/samples/src/main/java/androidx/ui/material/samples/AppBarSamples.kt
@@ -21,12 +21,9 @@
import androidx.ui.core.Modifier
import androidx.ui.foundation.Icon
import androidx.ui.foundation.Text
-import androidx.ui.foundation.shape.corner.CircleShape
import androidx.ui.layout.Spacer
import androidx.ui.material.BottomAppBar
-import androidx.ui.material.ExtendedFloatingActionButton
import androidx.ui.material.IconButton
-import androidx.ui.material.Scaffold
import androidx.ui.material.TopAppBar
import androidx.ui.material.icons.Icons
import androidx.ui.material.icons.filled.Favorite
@@ -71,32 +68,3 @@
}
}
}
-
-@Sampled
-@Composable
-fun SimpleBottomAppBarCutoutWithScaffold() {
- val fabShape = CircleShape
-
- Scaffold(
- bottomAppBar = { fabConfiguration ->
- BottomAppBar(fabConfiguration = fabConfiguration, cutoutShape = fabShape) {
- IconButton(onClick = { /* doSomething() */ }) {
- Icon(Icons.Filled.Favorite)
- }
- IconButton(onClick = { /* doSomething() */ }) {
- Icon(Icons.Filled.Favorite)
- }
- }
- },
- floatingActionButton = {
- ExtendedFloatingActionButton(
- text = { Text("Click me!") },
- shape = fabShape,
- onClick = { /* doSomething() */ }
- )
- },
- floatingActionButtonPosition = Scaffold.FabPosition.EndDocked
- ) {
- Text("Your app goes here")
- }
-}
\ No newline at end of file
diff --git a/ui/ui-material/samples/src/main/java/androidx/ui/material/samples/ScaffoldSamples.kt b/ui/ui-material/samples/src/main/java/androidx/ui/material/samples/ScaffoldSamples.kt
index a186fbf..2fec38d 100644
--- a/ui/ui-material/samples/src/main/java/androidx/ui/material/samples/ScaffoldSamples.kt
+++ b/ui/ui-material/samples/src/main/java/androidx/ui/material/samples/ScaffoldSamples.kt
@@ -32,6 +32,7 @@
import androidx.ui.graphics.Color
import androidx.ui.layout.Column
import androidx.ui.layout.fillMaxWidth
+import androidx.ui.layout.padding
import androidx.ui.layout.preferredHeight
import androidx.ui.material.BottomAppBar
import androidx.ui.material.DrawerState
@@ -61,7 +62,7 @@
Scaffold(
scaffoldState = scaffoldState,
drawerContent = { Text("Drawer content") },
- topAppBar = {
+ topBar = {
TopAppBar(
title = { Text("Simple Scaffold Screen") },
navigationIcon = {
@@ -80,9 +81,9 @@
onClick = { /* fab click handler */ }
)
},
- bodyContent = { modifier ->
+ bodyContent = { innerPadding ->
VerticalScroller {
- Column(modifier) {
+ Column(Modifier.padding(innerPadding)) {
repeat(100) {
Box(
Modifier.fillMaxWidth().preferredHeight(50.dp),
@@ -130,9 +131,9 @@
Scaffold(
scaffoldState = scaffoldState,
drawerContent = { Text("Drawer content") },
- topAppBar = { TopAppBar(title = { Text("Scaffold with bottom cutout") }) },
- bottomAppBar = { fabConfiguration ->
- BottomAppBar(fabConfiguration = fabConfiguration, cutoutShape = fabShape) {
+ topBar = { TopAppBar(title = { Text("Scaffold with bottom cutout") }) },
+ bottomBar = {
+ BottomAppBar(cutoutShape = fabShape) {
IconButton(onClick = {
scaffoldState.drawerState = DrawerState.Opened
}) {
@@ -147,10 +148,11 @@
shape = fabShape
)
},
- floatingActionButtonPosition = Scaffold.FabPosition.CenterDocked,
- bodyContent = { modifier ->
+ floatingActionButtonPosition = Scaffold.FabPosition.Center,
+ isFloatingActionButtonDocked = true,
+ bodyContent = { innerPadding ->
VerticalScroller {
- Column(modifier) {
+ Column(Modifier.padding(innerPadding)) {
repeat(100) {
Box(
Modifier.fillMaxWidth().preferredHeight(50.dp),
diff --git a/ui/ui-material/samples/src/main/java/androidx/ui/material/samples/TabSamples.kt b/ui/ui-material/samples/src/main/java/androidx/ui/material/samples/TabSamples.kt
index 20b3a72..209d646 100644
--- a/ui/ui-material/samples/src/main/java/androidx/ui/material/samples/TabSamples.kt
+++ b/ui/ui-material/samples/src/main/java/androidx/ui/material/samples/TabSamples.kt
@@ -298,8 +298,8 @@
transitionDefinition {
tabPositions.forEachIndexed { index, position ->
state(index) {
- this[indicatorStart] = position.left.toPx()
- this[indicatorEnd] = position.right.toPx()
+ this[indicatorStart] = position.left.toPx().value
+ this[indicatorEnd] = position.right.toPx().value
this[indicatorColor] = colors[index % colors.size]
}
}
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/AppBarTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/AppBarTest.kt
index 5572a7c..307f43c 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/AppBarTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/AppBarTest.kt
@@ -35,7 +35,6 @@
import androidx.ui.test.findByText
import androidx.ui.text.TextStyle
import androidx.ui.unit.Density
-import androidx.ui.unit.Px
import androidx.ui.unit.dp
import androidx.ui.unit.ipx
import androidx.ui.unit.px
@@ -83,7 +82,7 @@
var navigationIconCoords: LayoutCoordinates? = null
var titleCoords: LayoutCoordinates? = null
// Position of the baseline relative to the top of the text
- var titleLastBaselineRelativePosition: Px? = null
+ var titleLastBaselineRelativePosition: Float? = null
var actionCoords: LayoutCoordinates? = null
composeTestRule.setMaterialContent {
Box(Modifier.onChildPositioned { appBarCoords = it }) {
@@ -95,7 +94,7 @@
Text("title", Modifier.onPositioned { coords: LayoutCoordinates ->
titleCoords = coords
titleLastBaselineRelativePosition =
- coords[LastBaseline]!!.toPx()
+ coords[LastBaseline]!!.toPx().value
})
},
actions = {
@@ -106,45 +105,46 @@
}
composeTestRule.runOnIdleComposeWithDensity {
- val appBarBottomEdgeY = appBarCoords!!.globalPosition.y.value +
+ val appBarBottomEdgeY = appBarCoords!!.globalPosition.y +
appBarCoords!!.size.height.value
// Navigation icon should be 4.dp from the start
val navigationIconPositionX = navigationIconCoords!!.globalPosition.x
- val navigationIconExpectedPositionX = AppBarStartAndEndPadding.toIntPx().toPx()
+ val navigationIconExpectedPositionX = AppBarStartAndEndPadding.toIntPx().toPx().value
assertThat(navigationIconPositionX).isEqualTo(navigationIconExpectedPositionX)
// Navigation icon should be 4.dp from the bottom
val navigationIconPositionY = navigationIconCoords!!.globalPosition.y
val navigationIconExpectedPositionY = (appBarBottomEdgeY -
AppBarStartAndEndPadding.toPx() - FakeIconSize.toPx()
- ).roundToInt().px
+ ).roundToInt().toFloat()
assertThat(navigationIconPositionY).isEqualTo(navigationIconExpectedPositionY)
// Title should be 72.dp from the start
val titlePositionX = titleCoords!!.globalPosition.x
// 4.dp padding for the whole app bar + 68.dp inset
- val titleExpectedPositionX = (4.dp.toIntPx() + 68.dp.toIntPx()).toPx()
+ val titleExpectedPositionX = (4.dp.toIntPx() + 68.dp.toIntPx()).value.toFloat()
assertThat(titlePositionX).isEqualTo(titleExpectedPositionX)
// Absolute position of the baseline
val titleLastBaselinePositionY = titleLastBaselineRelativePosition!! +
titleCoords!!.globalPosition.y
// Baseline should be 20.sp from the bottom of the app bar
- val titleExpectedLastBaselinePositionY = appBarBottomEdgeY.px - 20.sp.toIntPx()
- .toPx()
+ val titleExpectedLastBaselinePositionY = (appBarBottomEdgeY.px - 20.sp.toIntPx()
+ .toPx()).value
assertThat(titleLastBaselinePositionY).isEqualTo(titleExpectedLastBaselinePositionY)
// Action should be placed at the end
val actionPositionX = actionCoords!!.globalPosition.x
- val actionExpectedPositionX = expectedActionPosition(appBarCoords!!.size.width.toPx())
+ val actionExpectedPositionX =
+ expectedActionPosition(appBarCoords!!.size.width.toPx().value)
assertThat(actionPositionX).isEqualTo(actionExpectedPositionX)
// Action should be 4.dp from the bottom
val actionPositionY = actionCoords!!.globalPosition.y
val actionExpectedPositionY = (appBarBottomEdgeY - AppBarStartAndEndPadding.toPx() -
FakeIconSize.toPx()
- ).roundToInt().px
+ ).roundToInt().toFloat()
assertThat(actionPositionY).isEqualTo(actionExpectedPositionY)
}
}
@@ -172,12 +172,13 @@
// Title should now be placed 16.dp from the start, as there is no navigation icon
val titlePositionX = titleCoords!!.globalPosition.x
// 4.dp padding for the whole app bar + 12.dp inset
- val titleExpectedPositionX = (4.dp.toIntPx() + 12.dp.toIntPx()).toPx()
+ val titleExpectedPositionX = (4.dp.toIntPx() + 12.dp.toIntPx()).toPx().value
assertThat(titlePositionX).isEqualTo(titleExpectedPositionX)
// Action should still be placed at the end
val actionPositionX = actionCoords!!.globalPosition.x
- val actionExpectedPositionX = expectedActionPosition(appBarCoords!!.size.width.toPx())
+ val actionExpectedPositionX =
+ expectedActionPosition(appBarCoords!!.size.width.toPx().value)
assertThat(actionPositionX).isEqualTo(actionExpectedPositionX)
}
}
@@ -227,17 +228,17 @@
composeTestRule.runOnIdleComposeWithDensity {
// Child icon should be 4.dp from the start
val childIconPositionX = childCoords!!.globalPosition.x
- val childIconExpectedPositionX = AppBarStartAndEndPadding.toIntPx().toPx()
+ val childIconExpectedPositionX = AppBarStartAndEndPadding.toIntPx().toPx().value
assertThat(childIconPositionX).isEqualTo(childIconExpectedPositionX)
- val appBarBottomEdgeY = appBarCoords!!.globalPosition.y.value +
+ val appBarBottomEdgeY = appBarCoords!!.globalPosition.y +
appBarCoords!!.size.height.value
// Child icon should be 4.dp from the bottom
val childIconPositionY = childCoords!!.globalPosition.y
val childIconExpectedPositionY = (appBarBottomEdgeY - AppBarStartAndEndPadding.toPx() -
FakeIconSize.toPx()
- ).roundToInt().px
+ ).roundToInt().toFloat()
assertThat(childIconPositionY).isEqualTo(childIconExpectedPositionY)
}
}
@@ -251,9 +252,9 @@
}
}
- private fun Density.expectedActionPosition(appBarWidth: Px): Px {
- return appBarWidth - AppBarStartAndEndPadding.toIntPx().toPx() -
- FakeIconSize.toIntPx().toPx()
+ private fun Density.expectedActionPosition(appBarWidth: Float): Float {
+ return appBarWidth - AppBarStartAndEndPadding.toIntPx().value -
+ FakeIconSize.toIntPx().value
}
private val AppBarStartAndEndPadding = 4.dp
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/BottomNavigationTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/BottomNavigationTest.kt
index fede650..30f953e 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/BottomNavigationTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/BottomNavigationTest.kt
@@ -105,7 +105,7 @@
Truth.assertThat(coord.size.width).isEqualTo(expectedItemWidth)
Truth.assertThat(coord.size.height).isEqualTo(expectedItemHeight)
Truth.assertThat(coord.globalPosition.x)
- .isEqualTo((expectedItemWidth * index).toPx())
+ .isEqualTo((expectedItemWidth * index).value.toFloat())
}
}
}
@@ -142,14 +142,14 @@
composeTestRule.runOnIdleComposeWithDensity {
// Distance from the bottom to the text baseline and from the text baseline to the
// bottom of the icon
- val textBaseline = 12.dp.toIntPx().toPx()
+ val textBaseline = 12.dp.toIntPx().value.toFloat()
// Relative position of the baseline to the top of text
- val relativeTextBaseline = textCoords[LastBaseline]!!.toPx()
+ val relativeTextBaseline = textCoords[LastBaseline]!!.toPx().value
// Absolute y position of the text baseline
val absoluteTextBaseline = textCoords.globalPosition.y + relativeTextBaseline
- val itemBottom = itemCoords.size.height.toPx() + itemCoords.globalPosition.y
+ val itemBottom = itemCoords.size.height.toPx().value + itemCoords.globalPosition.y
// Text baseline should be 12.dp from the bottom of the item
Truth.assertThat(absoluteTextBaseline).isEqualTo(itemBottom - textBaseline)
@@ -157,9 +157,10 @@
val iconExpectedX = (itemCoords.size.width.toPx() - iconCoords.size.width.toPx()) / 2
// The bottom of the icon is 12.dp above the text baseline
val iconExpectedY =
- absoluteTextBaseline - 12.dp.toIntPx().toPx() - iconCoords.size.height
+ absoluteTextBaseline - 12.dp.toIntPx().value.toFloat() -
+ iconCoords.size.height.value
- Truth.assertThat(iconCoords.globalPosition.x.value).isWithin(1f).of(iconExpectedX.value)
+ Truth.assertThat(iconCoords.globalPosition.x).isWithin(1f).of(iconExpectedX.value)
Truth.assertThat(iconCoords.globalPosition.y).isEqualTo(iconExpectedY)
}
}
@@ -206,8 +207,8 @@
val iconExpectedX = (itemCoords.size.width.toPx() - iconCoords.size.width.toPx()) / 2
val iconExpectedY = (itemCoords.size.height - iconCoords.size.height) / 2
- Truth.assertThat(iconCoords.globalPosition.x.value).isWithin(1f).of(iconExpectedX.value)
- Truth.assertThat(iconCoords.globalPosition.y).isEqualTo(iconExpectedY.toPx())
+ Truth.assertThat(iconCoords.globalPosition.x).isWithin(1f).of(iconExpectedX.value)
+ Truth.assertThat(iconCoords.globalPosition.y).isEqualTo(iconExpectedY.toPx().value)
}
}
@@ -238,10 +239,10 @@
composeTestRule.runOnIdleComposeWithDensity {
// The icon should be centered in the item, as there is no text placeable provided
val iconExpectedX = (itemCoords.size.width.toPx() - iconCoords.size.width.toPx()) / 2
- val iconExpectedY = (itemCoords.size.height - iconCoords.size.height) / 2
+ val iconExpectedY = (itemCoords.size.height.toPx() - iconCoords.size.height.toPx()) / 2
- Truth.assertThat(iconCoords.globalPosition.x.value).isWithin(1f).of(iconExpectedX.value)
- Truth.assertThat(iconCoords.globalPosition.y).isEqualTo(iconExpectedY.toPx())
+ Truth.assertThat(iconCoords.globalPosition.x).isWithin(1f).of(iconExpectedX.value)
+ Truth.assertThat(iconCoords.globalPosition.y).isEqualTo(iconExpectedY.value)
}
}
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/ButtonTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/ButtonTest.kt
index 3480a1c..15c907b 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/ButtonTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/ButtonTest.kt
@@ -56,7 +56,6 @@
import androidx.ui.test.findByText
import androidx.ui.test.runOnIdleCompose
import androidx.ui.unit.Dp
-import androidx.ui.unit.Px
import androidx.ui.unit.PxPosition
import androidx.ui.unit.PxSize
import androidx.ui.unit.center
@@ -222,7 +221,7 @@
}
with(composeTestRule.density) {
- assertThat(realSize.height.value)
+ assertThat(realSize.height)
.isGreaterThan(36.dp.toIntPx().value.toFloat())
}
}
@@ -491,8 +490,8 @@
assertThat(contentBounds.width).isLessThan(buttonBounds.width)
assertThat(contentBounds.height).isLessThan(buttonBounds.height)
with(composeTestRule.density) {
- assertThat(contentBounds.width).isEqualTo(2.dp.toIntPx().toPx())
- assertThat(contentBounds.height).isEqualTo(2.dp.toIntPx().toPx())
+ assertThat(contentBounds.width).isEqualTo(2.dp.toIntPx().value.toFloat())
+ assertThat(contentBounds.height).isEqualTo(2.dp.toIntPx().value.toFloat())
}
assertWithinOnePixel(buttonBounds.center(), contentBounds.center())
}
@@ -554,7 +553,7 @@
val topLeft = childCoordinates!!.localToGlobal(PxPosition.Origin).x -
parentCoordinates!!.localToGlobal(PxPosition.Origin).x
val currentPadding = with(composeTestRule.density) {
- padding.toIntPx().toPx()
+ padding.toIntPx().value.toFloat()
}
assertThat(currentPadding).isEqualTo(topLeft)
}
@@ -566,7 +565,7 @@
assertWithinOnePixel(expected.y, actual.y)
}
-fun assertWithinOnePixel(expected: Px, actual: Px) {
- val diff = abs(expected.value - actual.value)
+fun assertWithinOnePixel(expected: Float, actual: Float) {
+ val diff = abs(expected - actual)
assertThat(diff).isLessThan(1.1f)
}
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/DrawerTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/DrawerTest.kt
index ed3afdc..1020729 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/DrawerTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/DrawerTest.kt
@@ -70,7 +70,7 @@
}, bodyContent = emptyContent())
}
runOnIdleCompose {
- assertThat(position!!.x.value).isEqualTo(0f)
+ assertThat(position!!.x).isEqualTo(0f)
}
}
@@ -86,7 +86,7 @@
}
val width = composeTestRule.displayMetrics.widthPixels
runOnIdleCompose {
- assertThat(position!!.x.round().value).isEqualTo(-width)
+ assertThat(position!!.x.px.round().value).isEqualTo(-width)
}
}
@@ -124,7 +124,7 @@
// temporary calculation of landscape screen
val expectedHeight = if (width > height) 0 else (height / 2f).roundToInt()
runOnIdleCompose {
- assertThat(position!!.y.round().value).isEqualTo(expectedHeight)
+ assertThat(position!!.y.px.round().value).isEqualTo(expectedHeight)
}
}
@@ -140,7 +140,7 @@
}
val height = composeTestRule.displayMetrics.heightPixels
runOnIdleCompose {
- assertThat(position!!.y.round().value).isEqualTo(height)
+ assertThat(position!!.y.px.round().value).isEqualTo(height)
}
}
@@ -157,10 +157,10 @@
Box(
Modifier.fillMaxSize().onPositioned { info: LayoutCoordinates ->
val pos = info.localToGlobal(PxPosition.Origin)
- if (pos.x == 0.px) {
+ if (pos.x == 0.0f) {
// If fully opened, mark the openedLatch if present
openedLatch?.countDown()
- } else if (-pos.x.round() == contentWidth) {
+ } else if (-pos.x.px.round() == contentWidth) {
// If fully closed, mark the closedLatch if present
closedLatch?.countDown()
}
@@ -227,8 +227,8 @@
// Click on the left-center pixel of the drawer
findByTag("Drawer").doGesture {
- val left = 1.px
- val centerY = globalBounds.height / 2
+ val left = 1.0f
+ val centerY = (globalBounds.height / 2)
sendClick(PxPosition(left, centerY))
}
@@ -251,10 +251,10 @@
drawerContent = {
Box(Modifier.fillMaxSize().onPositioned { info: LayoutCoordinates ->
val pos = info.localToGlobal(PxPosition.Origin)
- if (pos.y.round() == openedHeight) {
+ if (pos.y.px.round() == openedHeight) {
// If fully opened, mark the openedLatch if present
openedLatch?.countDown()
- } else if (pos.y.round() == contentHeight) {
+ } else if (pos.y.px.round() == contentHeight) {
// If fully closed, mark the closedLatch if present
closedLatch?.countDown()
}
@@ -327,7 +327,7 @@
findByTag("Drawer").doGesture {
val bounds = globalBounds
val centerX = bounds.width / 2
- val bottom = bounds.height - 1.px
+ val bottom = bounds.height - 1.0f
sendClick(PxPosition(centerX, bottom))
}
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/FilledTextFieldTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/FilledTextFieldTest.kt
index d95ef48..3e77456 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/FilledTextFieldTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/FilledTextFieldTest.kt
@@ -56,7 +56,6 @@
import androidx.ui.text.FirstBaseline
import androidx.ui.text.SoftwareKeyboardController
import androidx.ui.unit.IntPxSize
-import androidx.ui.unit.Px
import androidx.ui.unit.PxPosition
import androidx.ui.unit.dp
import androidx.ui.unit.ipx
@@ -200,10 +199,11 @@
assertThat(labelSize.value?.width).isGreaterThan(0.ipx)
// centered position
assertThat(labelPosition.value?.x).isEqualTo(
- ExpectedPadding.toIntPx().toPx()
+ ExpectedPadding.toIntPx().value.toFloat()
)
assertThat(labelPosition.value?.y).isEqualTo(
- ((ExpectedMinimumTextFieldHeight.toIntPx() - labelSize.value!!.height) / 2f).toPx()
+ ((ExpectedMinimumTextFieldHeight.toIntPx() - labelSize.value!!.height) / 2f)
+ .value.toFloat()
)
}
}
@@ -236,10 +236,10 @@
assertThat(labelSize.value?.width).isGreaterThan(0.ipx)
// centered position
assertThat(labelPosition.value?.x).isEqualTo(
- ExpectedPadding.toIntPx().toPx()
+ ExpectedPadding.toIntPx().value.toFloat()
)
assertThat(labelPosition.value?.y).isEqualTo(
- ((height.toIntPx() - labelSize.value!!.height) / 2f).toPx()
+ ((height.toIntPx() - labelSize.value!!.height) / 2f).value.toFloat()
)
}
}
@@ -248,7 +248,7 @@
fun testLabelPosition_whenFocused() {
val labelSize = Ref<IntPxSize>()
val labelPosition = Ref<PxPosition>()
- val baseline = Ref<Px>()
+ val baseline = Ref<Float>()
testRule.setMaterialContent {
Box {
FilledTextField(
@@ -260,7 +260,7 @@
labelPosition.value = it.globalPosition
labelSize.value = it.size
baseline.value =
- it[FirstBaseline]!!.toPx() + labelPosition.value!!.y
+ it[FirstBaseline]!!.value.toFloat() + labelPosition.value!!.y
})
}
)
@@ -277,10 +277,10 @@
assertThat(labelSize.value?.width).isGreaterThan(0.ipx)
// label's top position
assertThat(labelPosition.value?.x).isEqualTo(
- ExpectedPadding.toIntPx().toPx()
+ ExpectedPadding.toIntPx().value.toFloat()
)
assertThat(baseline.value).isEqualTo(
- ExpectedBaselineOffset.toIntPx().toPx()
+ ExpectedBaselineOffset.toIntPx().value.toFloat()
)
}
}
@@ -289,7 +289,7 @@
fun testLabelPosition_whenInput() {
val labelSize = Ref<IntPxSize>()
val labelPosition = Ref<PxPosition>()
- val baseline = Ref<Px>()
+ val baseline = Ref<Float>()
testRule.setMaterialContent {
Box {
FilledTextField(
@@ -300,7 +300,7 @@
labelPosition.value = it.globalPosition
labelSize.value = it.size
baseline.value =
- it[FirstBaseline]!!.toPx() + labelPosition.value!!.y
+ it[FirstBaseline]!!.value.toFloat() + labelPosition.value!!.y
})
}
)
@@ -314,10 +314,10 @@
assertThat(labelSize.value?.width).isGreaterThan(0.ipx)
// label's top position
assertThat(labelPosition.value?.x).isEqualTo(
- ExpectedPadding.toIntPx().toPx()
+ ExpectedPadding.toIntPx().value.toFloat()
)
assertThat(baseline.value).isEqualTo(
- ExpectedBaselineOffset.toIntPx().toPx()
+ ExpectedBaselineOffset.toIntPx().value.toFloat()
)
}
}
@@ -326,7 +326,7 @@
fun testPlaceholderPosition_withLabel() {
val placeholderSize = Ref<IntPxSize>()
val placeholderPosition = Ref<PxPosition>()
- val placeholderBaseline = Ref<Px>()
+ val placeholderBaseline = Ref<Float>()
testRule.setMaterialContent {
Box {
FilledTextField(
@@ -339,7 +339,8 @@
placeholderPosition.value = it.globalPosition
placeholderSize.value = it.size
placeholderBaseline.value =
- it[FirstBaseline]!!.toPx() + placeholderPosition.value!!.y
+ it[FirstBaseline]!!.value.toFloat() +
+ placeholderPosition.value!!.y
})
}
)
@@ -355,10 +356,10 @@
assertThat(placeholderSize.value?.width).isGreaterThan(0.ipx)
// placeholder's position
assertThat(placeholderPosition.value?.x).isEqualTo(
- ExpectedPadding.toIntPx().toPx()
+ ExpectedPadding.toIntPx().value.toFloat()
)
assertThat(placeholderBaseline.value).isEqualTo(
- ExpectedBaselineOffset.toIntPx().toPx() * 2
+ ExpectedBaselineOffset.toIntPx().value.toFloat() * 2
)
}
}
@@ -367,7 +368,7 @@
fun testPlaceholderPosition_whenNoLabel() {
val placeholderSize = Ref<IntPxSize>()
val placeholderPosition = Ref<PxPosition>()
- val placeholderBaseline = Ref<Px>()
+ val placeholderBaseline = Ref<Float>()
val height = 60.dp
testRule.setMaterialContent {
Box {
@@ -381,7 +382,8 @@
placeholderPosition.value = it.globalPosition
placeholderSize.value = it.size
placeholderBaseline.value =
- it[FirstBaseline]!!.toPx() + placeholderPosition.value!!.y
+ it[FirstBaseline]!!.value.toFloat() +
+ placeholderPosition.value!!.y
})
}
)
@@ -397,10 +399,10 @@
assertThat(placeholderSize.value?.width).isGreaterThan(0.ipx)
// centered position
assertThat(placeholderPosition.value?.x).isEqualTo(
- ExpectedPadding.toIntPx().toPx()
+ ExpectedPadding.toIntPx().value.toFloat()
)
assertThat(placeholderPosition.value?.y).isEqualTo(
- ((height.toIntPx() - placeholderSize.value!!.height) / 2f).toPx()
+ ((height.toIntPx() - placeholderSize.value!!.height) / 2f).value.toFloat()
)
}
}
@@ -490,18 +492,18 @@
testRule.runOnIdleComposeWithDensity {
// leading
assertThat(leadingSize.value).isEqualTo(IntPxSize(size.toIntPx(), size.toIntPx()))
- assertThat(leadingPosition.value?.x).isEqualTo(IconPadding.toIntPx().toPx())
+ assertThat(leadingPosition.value?.x).isEqualTo(IconPadding.toIntPx().value.toFloat())
assertThat(leadingPosition.value?.y).isEqualTo(
- ((textFieldHeight.toIntPx() - leadingSize.value!!.height) / 2f).toPx()
+ ((textFieldHeight.toIntPx() - leadingSize.value!!.height) / 2f).value.toFloat()
)
// trailing
assertThat(trailingSize.value).isEqualTo(IntPxSize(size.toIntPx(), size.toIntPx()))
assertThat(trailingPosition.value?.x).isEqualTo(
(textFieldWidth.toIntPx() - IconPadding.toIntPx() - trailingSize.value!!.width)
- .toPx()
+ .value.toFloat()
)
assertThat(trailingPosition.value?.y).isEqualTo(
- ((textFieldHeight.toIntPx() - trailingSize.value!!.height) / 2f).toPx()
+ ((textFieldHeight.toIntPx() - trailingSize.value!!.height) / 2f).value.toFloat()
)
}
}
@@ -530,7 +532,8 @@
testRule.runOnIdleComposeWithDensity {
assertThat(labelPosition.value?.x).isEqualTo(
- (ExpectedPadding.toIntPx() + IconPadding.toIntPx() + iconSize.toIntPx()).toPx()
+ (ExpectedPadding.toIntPx() + IconPadding.toIntPx() + iconSize.toIntPx()).value
+ .toFloat()
)
}
}
@@ -558,7 +561,7 @@
testRule.runOnIdleComposeWithDensity {
assertThat(labelPosition.value?.x).isEqualTo(
- ExpectedPadding.toIntPx().toPx()
+ ExpectedPadding.toIntPx().value.toFloat()
)
}
}
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/FloatingActionButtonTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/FloatingActionButtonTest.kt
index c6a59bc..efc7277 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/FloatingActionButtonTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/FloatingActionButtonTest.kt
@@ -45,7 +45,6 @@
import androidx.ui.unit.center
import androidx.ui.unit.dp
import androidx.ui.unit.height
-import androidx.ui.unit.round
import androidx.ui.unit.toPx
import androidx.ui.unit.width
import com.google.common.truth.Truth.assertThat
@@ -53,6 +52,7 @@
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
+import kotlin.math.roundToInt
@MediumTest
@RunWith(JUnit4::class)
@@ -117,8 +117,8 @@
)
}
with(composeTestRule.density) {
- assertThat(size.height.round()).isEqualTo(48.dp.toIntPx())
- assertThat(size.width.round().value).isAtLeast(48.dp.toIntPx().value)
+ assertThat(size.height.roundToInt().toFloat()).isEqualTo(48.dp.toIntPx().value)
+ assertThat(size.width.roundToInt().toFloat()).isAtLeast(48.dp.toIntPx().value)
}
}
@@ -132,8 +132,8 @@
)
}
with(composeTestRule.density) {
- assertThat(size.width.round()).isEqualTo(48.dp.toIntPx())
- assertThat(size.height.round()).isEqualTo(48.dp.toIntPx())
+ assertThat(size.width.roundToInt().toFloat()).isEqualTo(48.dp.toIntPx().value)
+ assertThat(size.height.roundToInt().toFloat()).isEqualTo(48.dp.toIntPx().value)
}
}
@@ -224,8 +224,8 @@
assertThat(contentBounds.width).isLessThan(buttonBounds.width)
assertThat(contentBounds.height).isLessThan(buttonBounds.height)
with(composeTestRule.density) {
- assertThat(contentBounds.width).isEqualTo(2.dp.toIntPx().toPx())
- assertThat(contentBounds.height).isEqualTo(2.dp.toIntPx().toPx())
+ assertThat(contentBounds.width).isEqualTo(2.dp.toIntPx().value.toFloat())
+ assertThat(contentBounds.height).isEqualTo(2.dp.toIntPx().value.toFloat())
}
assertWithinOnePixel(buttonBounds.center(), contentBounds.center())
}
@@ -255,15 +255,15 @@
assertThat(contentBounds.width).isLessThan(buttonBounds.width)
assertThat(contentBounds.height).isLessThan(buttonBounds.height)
with(composeTestRule.density) {
- assertThat(contentBounds.width).isEqualTo(2.dp.toIntPx().toPx())
- assertThat(contentBounds.height).isEqualTo(2.dp.toIntPx().toPx())
+ assertThat(contentBounds.width).isEqualTo(2.dp.toIntPx().value.toFloat())
+ assertThat(contentBounds.height).isEqualTo(2.dp.toIntPx().value.toFloat())
}
assertWithinOnePixel(buttonBounds.center(), contentBounds.center())
}
}
@Test
- fun extendedFabTextAndIconArePossitionedCorrectly() {
+ fun extendedFabTextAndIconArePositionedCorrectly() {
var buttonCoordinates: LayoutCoordinates? = null
var textCoordinates: LayoutCoordinates? = null
var iconCoordinates: LayoutCoordinates? = null
@@ -291,14 +291,14 @@
val textBounds = textCoordinates!!.boundsInRoot
val iconBounds = iconCoordinates!!.boundsInRoot
with(composeTestRule.density) {
- assertThat(textBounds.width).isEqualTo(2.dp.toIntPx().toPx())
- assertThat(textBounds.height).isEqualTo(2.dp.toIntPx().toPx())
- assertThat(iconBounds.width).isEqualTo(10.dp.toIntPx().toPx())
- assertThat(iconBounds.height).isEqualTo(10.dp.toIntPx().toPx())
+ assertThat(textBounds.width).isEqualTo(2.dp.toIntPx().value.toFloat())
+ assertThat(textBounds.height).isEqualTo(2.dp.toIntPx().value.toFloat())
+ assertThat(iconBounds.width).isEqualTo(10.dp.toIntPx().value.toFloat())
+ assertThat(iconBounds.height).isEqualTo(10.dp.toIntPx().value.toFloat())
assertWithinOnePixel(buttonBounds.center().y, iconBounds.center().y)
assertWithinOnePixel(buttonBounds.center().y, textBounds.center().y)
- val halfPadding = 6.dp.toIntPx().toPx()
+ val halfPadding = 6.dp.toIntPx().toPx().value
assertWithinOnePixel(
iconBounds.center().x + iconBounds.width / 2 + halfPadding,
textBounds.center().x - textBounds.width / 2 - halfPadding
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/IconButtonTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/IconButtonTest.kt
index 3722f51..56c5ee5 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/IconButtonTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/IconButtonTest.kt
@@ -32,7 +32,6 @@
import androidx.ui.test.find
import androidx.ui.test.isToggleable
import androidx.ui.unit.dp
-import androidx.ui.unit.toPx
import com.google.common.truth.Truth
import org.junit.Rule
import org.junit.Test
@@ -79,8 +78,8 @@
val iconX = iconCoords.positionInParent.x
val iconY = iconCoords.positionInParent.y
// Icon should be centered inside the IconButton
- Truth.assertThat(iconX).isEqualTo(12.dp.toIntPx().toPx())
- Truth.assertThat(iconY).isEqualTo(12.dp.toIntPx().toPx())
+ Truth.assertThat(iconX).isEqualTo(12.dp.toIntPx().value.toFloat())
+ Truth.assertThat(iconY).isEqualTo(12.dp.toIntPx().value.toFloat())
}
}
@@ -104,8 +103,8 @@
val iconX = iconCoords.positionInParent.x
val iconY = iconCoords.positionInParent.y
- val expectedX = ((48.dp - width) / 2).toIntPx().toPx()
- val expectedY = ((48.dp - height) / 2).toIntPx().toPx()
+ val expectedX = ((48.dp - width) / 2).toIntPx().value.toFloat()
+ val expectedY = ((48.dp - height) / 2).toIntPx().value.toFloat()
// Icon should be centered inside the IconButton
Truth.assertThat(iconX).isEqualTo(expectedX)
Truth.assertThat(iconY).isEqualTo(expectedY)
@@ -143,8 +142,8 @@
val iconX = iconCoords.positionInParent.x
val iconY = iconCoords.positionInParent.y
// Icon should be centered inside the IconButton
- Truth.assertThat(iconX).isEqualTo(12.dp.toIntPx().toPx())
- Truth.assertThat(iconY).isEqualTo(12.dp.toIntPx().toPx())
+ Truth.assertThat(iconX).isEqualTo(12.dp.toIntPx().value.toFloat())
+ Truth.assertThat(iconY).isEqualTo(12.dp.toIntPx().value.toFloat())
}
}
@@ -167,8 +166,8 @@
val iconX = iconCoords.positionInParent.x
val iconY = iconCoords.positionInParent.y
- val expectedX = ((48.dp - width) / 2).toIntPx().toPx()
- val expectedY = ((48.dp - height) / 2).toIntPx().toPx()
+ val expectedX = ((48.dp - width) / 2).toIntPx().value.toFloat()
+ val expectedY = ((48.dp - height) / 2).toIntPx().value.toFloat()
// Icon should be centered inside the IconButton
Truth.assertThat(iconX).isEqualTo(expectedX)
Truth.assertThat(iconY).isEqualTo(expectedY)
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/ListItemTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/ListItemTest.kt
index 456dd83..d35fb91 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/ListItemTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/ListItemTest.kt
@@ -29,12 +29,9 @@
import androidx.ui.test.createComposeRule
import androidx.ui.unit.Dp
import androidx.ui.unit.IntPxSize
-import androidx.ui.unit.Px
import androidx.ui.unit.PxPosition
import androidx.ui.unit.dp
import androidx.ui.unit.ipx
-import androidx.ui.unit.px
-import androidx.ui.unit.toPx
import com.google.common.truth.Truth.assertThat
import org.junit.Rule
import org.junit.Test
@@ -205,17 +202,18 @@
}
}
composeTestRule.runOnIdleComposeWithDensity {
- assertThat(textPosition.value!!.x).isEqualTo(expectedLeftPadding.toIntPx().toPx())
+ assertThat(textPosition.value!!.x).isEqualTo(expectedLeftPadding.toIntPx()
+ .value.toFloat())
assertThat(textPosition.value!!.y).isEqualTo(
- ((listItemHeight.toIntPx() - textSize.value!!.height) / 2).toPx()
+ ((listItemHeight.toIntPx() - textSize.value!!.height) / 2).value.toFloat()
)
val dm = composeTestRule.displayMetrics
assertThat(trailingPosition.value!!.x).isEqualTo(
- dm.widthPixels.px - trailingSize.value!!.width -
- expectedRightPadding.toIntPx().toPx()
+ dm.widthPixels - trailingSize.value!!.width.value -
+ expectedRightPadding.toIntPx().value.toFloat()
)
assertThat(trailingPosition.value!!.y).isEqualTo(
- ((listItemHeight.toIntPx() - trailingSize.value!!.height) / 2).toPx()
+ ((listItemHeight.toIntPx() - trailingSize.value!!.height) / 2).value.toFloat()
)
}
}
@@ -239,16 +237,19 @@
}
}
composeTestRule.runOnIdleComposeWithDensity {
- assertThat(iconPosition.value!!.x).isEqualTo(expectedLeftPadding.toIntPx().toPx())
+ assertThat(iconPosition.value!!.x).isEqualTo(
+ expectedLeftPadding.toIntPx().value.toFloat()
+ )
assertThat(iconPosition.value!!.y).isEqualTo(
- ((listItemHeight.toIntPx() - iconSize.value!!.height) / 2).toPx()
+ ((listItemHeight.toIntPx() - iconSize.value!!.height) / 2).value.toFloat()
)
assertThat(textPosition.value!!.x).isEqualTo(
- expectedLeftPadding.toIntPx().toPx() + iconSize.value!!.width +
- expectedTextLeftPadding.toIntPx().toPx()
+ expectedLeftPadding.toIntPx().value.toFloat() +
+ iconSize.value!!.width.value +
+ expectedTextLeftPadding.toIntPx().value.toFloat()
)
assertThat(textPosition.value!!.y).isEqualTo(
- ((listItemHeight.toIntPx() - textSize.value!!.height) / 2).toPx()
+ ((listItemHeight.toIntPx() - textSize.value!!.height) / 2).value.toFloat()
)
}
}
@@ -261,13 +262,13 @@
val expectedSecondaryTextBaselineOffset = 20.dp
val textPosition = Ref<PxPosition>()
- val textBaseline = Ref<Px>()
+ val textBaseline = Ref<Float>()
val textSize = Ref<IntPxSize>()
val secondaryTextPosition = Ref<PxPosition>()
- val secondaryTextBaseline = Ref<Px>()
+ val secondaryTextBaseline = Ref<Float>()
val secondaryTextSize = Ref<IntPxSize>()
val trailingPosition = Ref<PxPosition>()
- val trailingBaseline = Ref<Px>()
+ val trailingBaseline = Ref<Float>()
val trailingSize = Ref<IntPxSize>()
composeTestRule.setMaterialContent {
Box {
@@ -292,22 +293,26 @@
}
}
composeTestRule.runOnIdleComposeWithDensity {
- assertThat(textPosition.value!!.x).isEqualTo(expectedLeftPadding.toIntPx().toPx())
- assertThat(textBaseline.value!!).isEqualTo(expectedTextBaseline.toIntPx().toPx())
+ assertThat(textPosition.value!!.x).isEqualTo(
+ expectedLeftPadding.toIntPx().value.toFloat()
+ )
+ assertThat(textBaseline.value!!).isEqualTo(
+ expectedTextBaseline.toIntPx().value.toFloat()
+ )
assertThat(secondaryTextPosition.value!!.x).isEqualTo(
- expectedLeftPadding.toIntPx().toPx()
+ expectedLeftPadding.toIntPx().value.toFloat()
)
assertThat(secondaryTextBaseline.value!!).isEqualTo(
- expectedTextBaseline.toIntPx().toPx() +
- expectedSecondaryTextBaselineOffset.toIntPx().toPx()
+ expectedTextBaseline.toIntPx().value.toFloat() +
+ expectedSecondaryTextBaselineOffset.toIntPx().value.toFloat()
)
val dm = composeTestRule.displayMetrics
assertThat(trailingPosition.value!!.x).isEqualTo(
- dm.widthPixels.px - trailingSize.value!!.width -
- expectedRightPadding.toIntPx().toPx()
+ dm.widthPixels - trailingSize.value!!.width.value -
+ expectedRightPadding.toIntPx().value.toFloat()
)
assertThat(trailingBaseline.value!!).isEqualTo(
- expectedTextBaseline.toIntPx().toPx()
+ expectedTextBaseline.toIntPx().value.toFloat()
)
}
}
@@ -321,10 +326,10 @@
val expectedSecondaryTextBaselineOffset = 20.dp
val textPosition = Ref<PxPosition>()
- val textBaseline = Ref<Px>()
+ val textBaseline = Ref<Float>()
val textSize = Ref<IntPxSize>()
val secondaryTextPosition = Ref<PxPosition>()
- val secondaryTextBaseline = Ref<Px>()
+ val secondaryTextBaseline = Ref<Float>()
val secondaryTextSize = Ref<IntPxSize>()
val iconPosition = Ref<PxPosition>()
val iconSize = Ref<IntPxSize>()
@@ -352,21 +357,26 @@
}
composeTestRule.runOnIdleComposeWithDensity {
assertThat(textPosition.value!!.x).isEqualTo(
- expectedLeftPadding.toIntPx().toPx() + iconSize.value!!.width +
- expectedContentLeftPadding.toIntPx().toPx()
+ expectedLeftPadding.toIntPx().value.toFloat() + iconSize.value!!.width.value +
+ expectedContentLeftPadding.toIntPx().value.toFloat()
)
- assertThat(textBaseline.value!!).isEqualTo(expectedTextBaseline.toIntPx().toPx())
+ assertThat(textBaseline.value!!).isEqualTo(
+ expectedTextBaseline.toIntPx().value.toFloat()
+ )
assertThat(secondaryTextPosition.value!!.x).isEqualTo(
- expectedLeftPadding.toIntPx().toPx() + iconSize.value!!.width +
- expectedContentLeftPadding.toIntPx().toPx()
+ expectedLeftPadding.toIntPx().value.toFloat() +
+ iconSize.value!!.width.value +
+ expectedContentLeftPadding.toIntPx().value.toFloat()
)
assertThat(secondaryTextBaseline.value!!).isEqualTo(
- expectedTextBaseline.toIntPx().toPx() +
- expectedSecondaryTextBaselineOffset.toIntPx().toPx()
+ expectedTextBaseline.toIntPx().value.toFloat() +
+ expectedSecondaryTextBaselineOffset.toIntPx().value.toFloat()
)
- assertThat(iconPosition.value!!.x).isEqualTo(expectedLeftPadding.toIntPx().toPx())
+ assertThat(iconPosition.value!!.x).isEqualTo(
+ expectedLeftPadding.toIntPx().value.toFloat()
+ )
assertThat(iconPosition.value!!.y).isEqualTo(
- expectedIconTopPadding.toIntPx().toPx()
+ expectedIconTopPadding.toIntPx().value.toFloat()
)
}
}
@@ -382,10 +392,10 @@
val expectedRightPadding = 16.dp
val textPosition = Ref<PxPosition>()
- val textBaseline = Ref<Px>()
+ val textBaseline = Ref<Float>()
val textSize = Ref<IntPxSize>()
val secondaryTextPosition = Ref<PxPosition>()
- val secondaryTextBaseline = Ref<Px>()
+ val secondaryTextBaseline = Ref<Float>()
val secondaryTextSize = Ref<IntPxSize>()
val iconPosition = Ref<PxPosition>()
val iconSize = Ref<IntPxSize>()
@@ -418,29 +428,34 @@
}
composeTestRule.runOnIdleComposeWithDensity {
assertThat(textPosition.value!!.x).isEqualTo(
- expectedLeftPadding.toIntPx().toPx() + iconSize.value!!.width +
- expectedContentLeftPadding.toIntPx().toPx()
+ expectedLeftPadding.toIntPx().value.toFloat() + iconSize.value!!.width.value +
+ expectedContentLeftPadding.toIntPx().value.toFloat()
)
- assertThat(textBaseline.value!!).isEqualTo(expectedTextBaseline.toIntPx().toPx())
+ assertThat(textBaseline.value!!).isEqualTo(
+ expectedTextBaseline.toIntPx().value.toFloat()
+ )
assertThat(secondaryTextPosition.value!!.x).isEqualTo(
- expectedLeftPadding.toIntPx().toPx() + iconSize.value!!.width +
- expectedContentLeftPadding.toIntPx().toPx()
+ expectedLeftPadding.toIntPx().value.toFloat() +
+ iconSize.value!!.width.value +
+ expectedContentLeftPadding.toIntPx().value.toFloat()
)
assertThat(secondaryTextBaseline.value!!).isEqualTo(
- expectedTextBaseline.toIntPx().toPx() +
- expectedSecondaryTextBaselineOffset.toIntPx().toPx()
+ expectedTextBaseline.toIntPx().value.toFloat() +
+ expectedSecondaryTextBaselineOffset.toIntPx().value.toFloat()
)
- assertThat(iconPosition.value!!.x).isEqualTo(expectedLeftPadding.toIntPx().toPx())
+ assertThat(iconPosition.value!!.x).isEqualTo(
+ expectedLeftPadding.toIntPx().value.toFloat()
+ )
assertThat(iconPosition.value!!.y).isEqualTo(
- expectedIconTopPadding.toIntPx().toPx()
+ expectedIconTopPadding.toIntPx().value.toFloat()
)
val dm = composeTestRule.displayMetrics
assertThat(trailingPosition.value!!.x).isEqualTo(
- dm.widthPixels.px - trailingSize.value!!.width -
- expectedRightPadding.toIntPx().toPx()
+ dm.widthPixels - trailingSize.value!!.width.value -
+ expectedRightPadding.toIntPx().value.toFloat()
)
assertThat(trailingPosition.value!!.y).isEqualTo(
- ((listItemHeight.toIntPx() - trailingSize.value!!.height) / 2).toPx()
+ ((listItemHeight.toIntPx() - trailingSize.value!!.height) / 2).value.toFloat()
)
}
}
@@ -455,10 +470,10 @@
val expectedRightPadding = 16.dp
val textPosition = Ref<PxPosition>()
- val textBaseline = Ref<Px>()
+ val textBaseline = Ref<Float>()
val textSize = Ref<IntPxSize>()
val secondaryTextPosition = Ref<PxPosition>()
- val secondaryTextBaseline = Ref<Px>()
+ val secondaryTextBaseline = Ref<Float>()
val secondaryTextSize = Ref<IntPxSize>()
val iconPosition = Ref<PxPosition>()
val iconSize = Ref<IntPxSize>()
@@ -492,29 +507,32 @@
}
composeTestRule.runOnIdleComposeWithDensity {
assertThat(textPosition.value!!.x).isEqualTo(
- expectedLeftPadding.toIntPx().toPx() + iconSize.value!!.width +
- expectedContentLeftPadding.toIntPx().toPx()
+ expectedLeftPadding.toIntPx().value.toFloat() + iconSize.value!!.width.value +
+ expectedContentLeftPadding.toIntPx().value.toFloat()
)
- assertThat(textBaseline.value!!).isEqualTo(expectedTextBaseline.toIntPx().toPx())
+ assertThat(textBaseline.value!!).isEqualTo(
+ expectedTextBaseline.toIntPx().value.toFloat()
+ )
assertThat(secondaryTextPosition.value!!.x).isEqualTo(
- expectedLeftPadding.toIntPx().toPx() + iconSize.value!!.width +
- expectedContentLeftPadding.toIntPx().toPx()
+ expectedLeftPadding.toIntPx().value.toFloat() + iconSize.value!!.width.value +
+ expectedContentLeftPadding.toIntPx().value.toFloat()
)
assertThat(secondaryTextBaseline.value!!).isEqualTo(
- expectedTextBaseline.toIntPx().toPx() +
- expectedSecondaryTextBaselineOffset.toIntPx().toPx()
+ expectedTextBaseline.toIntPx().value.toFloat() +
+ expectedSecondaryTextBaselineOffset.toIntPx().value.toFloat()
)
- assertThat(iconPosition.value!!.x).isEqualTo(expectedLeftPadding.toIntPx().toPx())
+ assertThat(iconPosition.value!!.x).isEqualTo(expectedLeftPadding.toIntPx()
+ .value.toFloat())
assertThat(iconPosition.value!!.y).isEqualTo(
- expectedIconTopPadding.toIntPx().toPx()
+ expectedIconTopPadding.toIntPx().value.toFloat()
)
val dm = composeTestRule.displayMetrics
assertThat(trailingPosition.value!!.x).isEqualTo(
- dm.widthPixels.px - trailingSize.value!!.width -
- expectedRightPadding.toIntPx().toPx()
+ dm.widthPixels - trailingSize.value!!.width.value.toFloat() -
+ expectedRightPadding.toIntPx().value.toFloat()
)
assertThat(trailingPosition.value!!.y).isEqualTo(
- expectedIconTopPadding.toIntPx().toPx()
+ expectedIconTopPadding.toIntPx().value.toFloat()
)
}
}
@@ -530,19 +548,19 @@
val expectedRightPadding = 16.dp
val textPosition = Ref<PxPosition>()
- val textBaseline = Ref<Px>()
+ val textBaseline = Ref<Float>()
val textSize = Ref<IntPxSize>()
val overlineTextPosition = Ref<PxPosition>()
- val overlineTextBaseline = Ref<Px>()
+ val overlineTextBaseline = Ref<Float>()
val overlineTextSize = Ref<IntPxSize>()
val secondaryTextPosition = Ref<PxPosition>()
- val secondaryTextBaseline = Ref<Px>()
+ val secondaryTextBaseline = Ref<Float>()
val secondaryTextSize = Ref<IntPxSize>()
val iconPosition = Ref<PxPosition>()
val iconSize = Ref<IntPxSize>()
val trailingPosition = Ref<PxPosition>()
val trailingSize = Ref<IntPxSize>()
- val trailingBaseline = Ref<Px>()
+ val trailingBaseline = Ref<Float>()
composeTestRule.setMaterialContent {
Box {
ListItem(
@@ -590,40 +608,45 @@
}
composeTestRule.runOnIdleComposeWithDensity {
assertThat(textPosition.value!!.x).isEqualTo(
- expectedLeftPadding.toIntPx().toPx() + iconSize.value!!.width +
- expectedContentLeftPadding.toIntPx().toPx()
+ expectedLeftPadding.toIntPx().value.toFloat() +
+ iconSize.value!!.width.value +
+ expectedContentLeftPadding.toIntPx().value.toFloat()
)
assertThat(textBaseline.value!!).isEqualTo(
- expectedOverlineBaseline.toIntPx().toPx() +
- expectedTextBaselineOffset.toIntPx().toPx()
+ expectedOverlineBaseline.toIntPx().value.toFloat() +
+ expectedTextBaselineOffset.toIntPx().value.toFloat()
)
assertThat(overlineTextPosition.value!!.x).isEqualTo(
- expectedLeftPadding.toIntPx().toPx() + iconSize.value!!.width +
- expectedContentLeftPadding.toIntPx().toPx()
+ expectedLeftPadding.toIntPx().value.toFloat() +
+ iconSize.value!!.width.value +
+ expectedContentLeftPadding.toIntPx().value.toFloat()
)
assertThat(overlineTextBaseline.value!!).isEqualTo(
- expectedOverlineBaseline.toIntPx().toPx()
+ expectedOverlineBaseline.toIntPx().value.toFloat()
)
assertThat(secondaryTextPosition.value!!.x).isEqualTo(
- expectedLeftPadding.toIntPx().toPx() + iconSize.value!!.width +
- expectedContentLeftPadding.toIntPx().toPx()
+ expectedLeftPadding.toIntPx().value.toFloat() +
+ iconSize.value!!.width.value +
+ expectedContentLeftPadding.toIntPx().value.toFloat()
)
assertThat(secondaryTextBaseline.value!!).isEqualTo(
- expectedOverlineBaseline.toIntPx().toPx() +
- expectedTextBaselineOffset.toIntPx().toPx() +
- expectedSecondaryTextBaselineOffset.toIntPx().toPx()
+ expectedOverlineBaseline.toIntPx().value.toFloat() +
+ expectedTextBaselineOffset.toIntPx().value.toFloat() +
+ expectedSecondaryTextBaselineOffset.toIntPx().value.toFloat()
)
- assertThat(iconPosition.value!!.x).isEqualTo(expectedLeftPadding.toIntPx().toPx())
+ assertThat(iconPosition.value!!.x).isEqualTo(
+ expectedLeftPadding.toIntPx().value.toFloat()
+ )
assertThat(iconPosition.value!!.y).isEqualTo(
- expectedIconTopPadding.toIntPx().toPx()
+ expectedIconTopPadding.toIntPx().value.toFloat()
)
val dm = composeTestRule.displayMetrics
assertThat(trailingPosition.value!!.x).isEqualTo(
- dm.widthPixels.px - trailingSize.value!!.width -
- expectedRightPadding.toIntPx().toPx()
+ dm.widthPixels - trailingSize.value!!.width.value -
+ expectedRightPadding.toIntPx().value.toFloat()
)
assertThat(trailingBaseline.value!!).isEqualTo(
- expectedOverlineBaseline.toIntPx().toPx()
+ expectedOverlineBaseline.toIntPx().value.toFloat()
)
}
}
@@ -633,10 +656,10 @@
private fun saveLayout(
coords: Ref<PxPosition>,
size: Ref<IntPxSize>,
- baseline: Ref<Px> = Ref()
+ baseline: Ref<Float> = Ref()
): Modifier = Modifier.onPositioned { coordinates: LayoutCoordinates ->
coords.value = coordinates.localToGlobal(PxPosition.Origin)
- baseline.value = coordinates[FirstBaseline]?.toPx()?.let {
+ baseline.value = coordinates[FirstBaseline]?.value?.toFloat()?.let {
it + coords.value!!.y
}
size.value = coordinates.size
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/MenuTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/MenuTest.kt
index 47def4b..7ba6686 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/MenuTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/MenuTest.kt
@@ -26,6 +26,7 @@
import androidx.ui.core.testTag
import androidx.ui.foundation.Box
import androidx.ui.foundation.Text
+import androidx.ui.foundation.clickable
import androidx.ui.foundation.contentColor
import androidx.ui.foundation.drawBackground
import androidx.ui.graphics.Color
@@ -34,6 +35,7 @@
import androidx.ui.semantics.Semantics
import androidx.ui.semantics.testTag
import androidx.ui.test.createComposeRule
+import androidx.ui.test.doClick
import androidx.ui.test.find
import androidx.ui.test.findByTag
import androidx.ui.test.hasAnyChildThat
@@ -264,4 +266,25 @@
assertThat(enabledContentColor).isEqualTo(enabledEmphasis.applyEmphasis(onSurface))
assertThat(disabledContentColor).isEqualTo(disabledEmphasis.applyEmphasis(onSurface))
}
+
+ @Test
+ fun dropdownMenuItem_onClick() {
+ var clicked = false
+ val onClick: () -> Unit = { clicked = true }
+
+ composeTestRule.setContent {
+ DropdownMenuItem(
+ onClick,
+ modifier = Modifier.testTag("MenuItem").clickable(onClick = onClick)
+ ) {
+ Box(Modifier.size(40.dp))
+ }
+ }
+
+ findByTag("MenuItem").doClick()
+
+ runOnIdleCompose {
+ assertThat(clicked).isTrue()
+ }
+ }
}
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/ScaffoldTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/ScaffoldTest.kt
index 912101e..96945bc 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/ScaffoldTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/ScaffoldTest.kt
@@ -17,11 +17,12 @@
package androidx.ui.material
import android.os.Build
+import androidx.compose.Composable
+import androidx.compose.mutableStateOf
import androidx.test.filters.MediumTest
import androidx.test.filters.SdkSuppress
import androidx.ui.core.LayoutCoordinates
import androidx.ui.core.Modifier
-import androidx.ui.core.TestTag
import androidx.ui.core.drawShadow
import androidx.ui.core.onPositioned
import androidx.ui.core.positionInParent
@@ -33,6 +34,7 @@
import androidx.ui.foundation.drawBackground
import androidx.ui.graphics.Color
import androidx.ui.layout.DpConstraints
+import androidx.ui.layout.InnerPadding
import androidx.ui.layout.Stack
import androidx.ui.layout.fillMaxWidth
import androidx.ui.layout.preferredHeight
@@ -40,10 +42,12 @@
import androidx.ui.material.icons.Icons
import androidx.ui.material.icons.filled.Favorite
import androidx.ui.semantics.Semantics
+import androidx.ui.semantics.testTag
import androidx.ui.test.captureToBitmap
import androidx.ui.test.createComposeRule
import androidx.ui.test.doGesture
import androidx.ui.test.findByTag
+import androidx.ui.test.runOnIdleCompose
import androidx.ui.test.runOnUiThread
import androidx.ui.test.sendSwipeLeft
import androidx.ui.test.sendSwipeRight
@@ -51,6 +55,9 @@
import androidx.ui.unit.PxPosition
import androidx.ui.unit.dp
import androidx.ui.unit.px
+import androidx.ui.unit.toPxSize
+import androidx.ui.unit.toSize
+import androidx.ui.unit.width
import com.google.common.truth.Truth.assertThat
import org.junit.Ignore
import org.junit.Rule
@@ -105,7 +112,7 @@
lateinit var contentPosition: PxPosition
composeTestRule.setMaterialContent {
Scaffold(
- topAppBar = {
+ topBar = {
Box(Modifier
.onPositioned { positioned: LayoutCoordinates ->
appbarPosition = positioned.localToGlobal(PxPosition.Origin)
@@ -125,7 +132,8 @@
)
}
}
- assertThat(appbarPosition.y + appbarSize.height).isEqualTo(contentPosition.y)
+ assertThat(appbarPosition.y + appbarSize.height.value.toFloat())
+ .isEqualTo(contentPosition.y)
}
@Test
@@ -136,7 +144,7 @@
lateinit var contentSize: IntPxSize
composeTestRule.setMaterialContent {
Scaffold(
- bottomAppBar = {
+ bottomBar = {
Box(Modifier
.onPositioned { positioned: LayoutCoordinates ->
appbarPosition = positioned.positionInParent
@@ -159,8 +167,8 @@
)
}
}
- val appBarBottom = appbarPosition.y + appbarSize.height
- val contentBottom = contentPosition.y + contentSize.height
+ val appBarBottom = appbarPosition.y + appbarSize.height.value
+ val contentBottom = contentPosition.y + contentSize.height.value
assertThat(appBarBottom).isEqualTo(contentBottom)
}
@@ -170,40 +178,38 @@
lateinit var drawerChildPosition: PxPosition
val scaffoldState = ScaffoldState(isDrawerGesturesEnabled = false)
composeTestRule.setMaterialContent {
- TestTag(scaffoldTag) {
- Semantics(container = true) {
- Scaffold(
- scaffoldState = scaffoldState,
- drawerContent = {
- Box(Modifier
- .onPositioned { positioned: LayoutCoordinates ->
- drawerChildPosition = positioned.positionInParent
- }
- .fillMaxWidth()
- .preferredHeight(50.dp)
- .drawBackground(Color.Blue)
- )
- }
- ) {
- Box(
- Modifier
- .fillMaxWidth()
- .preferredHeight(50.dp)
- .drawBackground(Color.Blue)
+ Semantics(properties = { testTag = scaffoldTag }) {
+ Scaffold(
+ scaffoldState = scaffoldState,
+ drawerContent = {
+ Box(Modifier
+ .onPositioned { positioned: LayoutCoordinates ->
+ drawerChildPosition = positioned.positionInParent
+ }
+ .fillMaxWidth()
+ .preferredHeight(50.dp)
+ .drawBackground(Color.Blue)
)
}
+ ) {
+ Box(
+ Modifier
+ .fillMaxWidth()
+ .preferredHeight(50.dp)
+ .drawBackground(Color.Blue)
+ )
}
}
}
- assertThat(drawerChildPosition.x).isLessThan(0.px)
+ assertThat(drawerChildPosition.x).isLessThan(0f)
findByTag(scaffoldTag).doGesture {
sendSwipeRight()
}
- assertThat(drawerChildPosition.x).isLessThan(0.px)
+ assertThat(drawerChildPosition.x).isLessThan(0f)
findByTag(scaffoldTag).doGesture {
sendSwipeLeft()
}
- assertThat(drawerChildPosition.x).isLessThan(0.px)
+ assertThat(drawerChildPosition.x).isLessThan(0f)
runOnUiThread {
scaffoldState.isDrawerGesturesEnabled = true
@@ -212,11 +218,11 @@
findByTag(scaffoldTag).doGesture {
sendSwipeRight()
}
- assertThat(drawerChildPosition.x).isEqualTo(0.px)
+ assertThat(drawerChildPosition.x).isEqualTo(0f)
findByTag(scaffoldTag).doGesture {
sendSwipeLeft()
}
- assertThat(drawerChildPosition.x).isLessThan(0.px)
+ assertThat(drawerChildPosition.x).isLessThan(0f)
}
@Test
@@ -225,72 +231,38 @@
lateinit var drawerChildPosition: PxPosition
val scaffoldState = ScaffoldState()
composeTestRule.setMaterialContent {
- TestTag(scaffoldTag) {
- Semantics(container = true) {
- Scaffold(
- scaffoldState = scaffoldState,
- drawerContent = {
- Box(Modifier
- .onPositioned { positioned: LayoutCoordinates ->
- drawerChildPosition = positioned.positionInParent
- }
- .fillMaxWidth()
- .preferredHeight(50.dp)
- .drawBackground(Color.Blue)
- )
- }
- ) {
- Box(
- Modifier
- .fillMaxWidth()
- .preferredHeight(50.dp)
- .drawBackground(Color.Blue)
+ Semantics(properties = { testTag = scaffoldTag }) {
+ Scaffold(
+ scaffoldState = scaffoldState,
+ drawerContent = {
+ Box(Modifier
+ .onPositioned { positioned: LayoutCoordinates ->
+ drawerChildPosition = positioned.positionInParent
+ }
+ .fillMaxWidth()
+ .preferredHeight(50.dp)
+ .drawBackground(Color.Blue)
)
}
+ ) {
+ Box(
+ Modifier
+ .fillMaxWidth()
+ .preferredHeight(50.dp)
+ .drawBackground(Color.Blue)
+ )
}
}
}
- assertThat(drawerChildPosition.x).isLessThan(0.px)
+ assertThat(drawerChildPosition.x).isLessThan(0f)
runOnUiThread {
scaffoldState.drawerState = DrawerState.Opened
}
- assertThat(drawerChildPosition.x).isLessThan(0.px)
+ assertThat(drawerChildPosition.x).isLessThan(0f)
runOnUiThread {
scaffoldState.drawerState = DrawerState.Closed
}
- assertThat(drawerChildPosition.x).isLessThan(0.px)
- }
-
- @Test(expected = IllegalArgumentException::class)
- fun scaffold_centerDockedFab_withoutBottomAppBar_shouldCrash() {
- composeTestRule.setContent {
- Scaffold(
- floatingActionButton = {
- FloatingActionButton(onClick = {}) {
- Icon(Icons.Filled.Favorite)
- }
- },
- floatingActionButtonPosition = Scaffold.FabPosition.CenterDocked
- ) {
- Text("body")
- }
- }
- }
-
- @Test(expected = IllegalArgumentException::class)
- fun scaffold_endDockedFab_withoutBottomAppBar_shouldCrash() {
- composeTestRule.setContent {
- Scaffold(
- floatingActionButton = {
- FloatingActionButton(onClick = {}) {
- Icon(Icons.Filled.Favorite)
- }
- },
- floatingActionButtonPosition = Scaffold.FabPosition.EndDocked
- ) {
- Text("body")
- }
- }
+ assertThat(drawerChildPosition.x).isLessThan(0f)
}
@Test
@@ -310,8 +282,9 @@
Icon(Icons.Filled.Favorite)
}
},
- floatingActionButtonPosition = Scaffold.FabPosition.CenterDocked,
- bottomAppBar = {
+ floatingActionButtonPosition = Scaffold.FabPosition.Center,
+ isFloatingActionButtonDocked = true,
+ bottomBar = {
Box(Modifier
.onPositioned { positioned: LayoutCoordinates ->
bottomBarPosition =
@@ -326,7 +299,7 @@
Text("body")
}
}
- val expectedFabY = bottomBarPosition.y - fabSize.height / 2
+ val expectedFabY = bottomBarPosition.y - (fabSize.height / 2).value
assertThat(fabPosition.y).isEqualTo(expectedFabY)
}
@@ -348,8 +321,9 @@
Icon(Icons.Filled.Favorite)
}
},
- floatingActionButtonPosition = Scaffold.FabPosition.EndDocked,
- bottomAppBar = {
+ floatingActionButtonPosition = Scaffold.FabPosition.End,
+ isFloatingActionButtonDocked = true,
+ bottomBar = {
Box(Modifier
.onPositioned { positioned: LayoutCoordinates ->
bottomBarPosition =
@@ -364,7 +338,7 @@
Text("body")
}
}
- val expectedFabY = bottomBarPosition.y - fabSize.height / 2
+ val expectedFabY = bottomBarPosition.y - (fabSize.height / 2).value
assertThat(fabPosition.y).isEqualTo(expectedFabY)
}
@@ -372,13 +346,14 @@
@Test
fun scaffold_topAppBarIsDrawnOnTopOfContent() {
composeTestRule.setContent {
- Stack(Modifier
- .size(10.dp, 20.dp)
- .semantics(mergeAllDescendants = true)
- .testTag("Scaffold")
+ Stack(
+ Modifier
+ .size(10.dp, 20.dp)
+ .semantics(mergeAllDescendants = true)
+ .testTag("Scaffold")
) {
Scaffold(
- topAppBar = {
+ topBar = {
Box(
Modifier.size(10.dp)
.drawShadow(4.dp)
@@ -403,4 +378,177 @@
assertThat(Color(getPixel(width - 1, yPos))).isNotEqualTo(Color.White)
}
}
+
+ @Test
+ fun scaffold_geometry_fabSize() {
+ lateinit var fabSize: IntPxSize
+ val showFab = mutableStateOf(true)
+ val scaffoldState = ScaffoldState()
+ composeTestRule.setContent {
+ val fab: @Composable (() -> Unit)? = if (showFab.value) {
+ @Composable {
+ FloatingActionButton(
+ modifier = Modifier.onPositioned { positioned: LayoutCoordinates ->
+ fabSize = positioned.size
+ },
+ onClick = {}
+ ) {
+ Icon(Icons.Filled.Favorite)
+ }
+ }
+ } else {
+ null
+ }
+ Scaffold(
+ scaffoldState = scaffoldState,
+ floatingActionButton = fab,
+ floatingActionButtonPosition = Scaffold.FabPosition.End
+ ) {
+ Text("body")
+ }
+ }
+ runOnIdleCompose {
+ assertThat(scaffoldState.floatingActionButtonSize).isEqualTo(fabSize.toPxSize())
+ showFab.value = false
+ }
+
+ runOnIdleCompose {
+ assertThat(scaffoldState.floatingActionButtonSize).isEqualTo(null)
+ }
+ }
+
+ @Test
+ fun scaffold_geometry_bottomBarSize() {
+ lateinit var bottomBarSize: IntPxSize
+ val showBottom = mutableStateOf(true)
+ val scaffoldState = ScaffoldState()
+ composeTestRule.setContent {
+ val bottom: @Composable (() -> Unit)? = if (showBottom.value) {
+ @Composable {
+ Box(Modifier
+ .onPositioned { positioned: LayoutCoordinates ->
+ bottomBarSize = positioned.size
+ }
+ .fillMaxWidth()
+ .preferredHeight(100.dp)
+ .drawBackground(Color.Red)
+ )
+ }
+ } else {
+ null
+ }
+ Scaffold(
+ scaffoldState = scaffoldState,
+ bottomBar = bottom
+ ) {
+ Text("body")
+ }
+ }
+ runOnIdleCompose {
+ assertThat(scaffoldState.bottomBarSize).isEqualTo(bottomBarSize.toPxSize())
+ showBottom.value = false
+ }
+
+ runOnIdleCompose {
+ assertThat(scaffoldState.bottomBarSize).isEqualTo(null)
+ }
+ }
+
+ @Test
+ fun scaffold_geometry_topBarSize() {
+ lateinit var topBarSize: IntPxSize
+ val showTop = mutableStateOf(true)
+ val scaffoldState = ScaffoldState()
+ composeTestRule.setContent {
+ val top: @Composable (() -> Unit)? = if (showTop.value) {
+ @Composable {
+ Box(Modifier
+ .onPositioned { positioned: LayoutCoordinates ->
+ topBarSize = positioned.size
+ }
+ .fillMaxWidth()
+ .preferredHeight(100.dp)
+ .drawBackground(Color.Red)
+ )
+ }
+ } else {
+ null
+ }
+ Scaffold(
+ scaffoldState = scaffoldState,
+ topBar = top
+ ) {
+ Text("body")
+ }
+ }
+ runOnIdleCompose {
+ assertThat(scaffoldState.topBarSize).isEqualTo(topBarSize.toPxSize())
+ showTop.value = false
+ }
+
+ runOnIdleCompose {
+ assertThat(scaffoldState.topBarSize).isEqualTo(null)
+ }
+ }
+
+ @Test
+ fun scaffold_innerPadding_lambdaParam() {
+ lateinit var bottomBarSize: IntPxSize
+ lateinit var innerPadding: InnerPadding
+
+ val scaffoldState = ScaffoldState()
+ composeTestRule.setContent {
+ Scaffold(
+ scaffoldState = scaffoldState,
+ bottomBar = {
+ Box(Modifier
+ .onPositioned { positioned: LayoutCoordinates ->
+ bottomBarSize = positioned.size
+ }
+ .fillMaxWidth()
+ .preferredHeight(100.dp)
+ .drawBackground(Color.Red)
+ )
+ }
+ ) {
+ innerPadding = it
+ Text("body")
+ }
+ }
+ runOnIdleCompose {
+ with(composeTestRule.density) {
+ assertThat(innerPadding.bottom).isEqualTo(bottomBarSize.toPxSize().height.toDp())
+ }
+ }
+ }
+
+ @Test
+ fun scaffold_bottomBar_geometryPropagation() {
+ lateinit var bottomBarSize: IntPxSize
+ lateinit var geometry: ScaffoldGeometry
+
+ val scaffoldState = ScaffoldState()
+ composeTestRule.setContent {
+ Scaffold(
+ scaffoldState = scaffoldState,
+ bottomBar = {
+ geometry = ScaffoldGeometryAmbient.current
+ Box(Modifier
+ .onPositioned { positioned: LayoutCoordinates ->
+ bottomBarSize = positioned.size
+ }
+ .fillMaxWidth()
+ .preferredHeight(100.dp)
+ .drawBackground(Color.Red)
+ )
+ }
+ ) {
+ Text("body")
+ }
+ }
+ runOnIdleCompose {
+ assertThat(geometry.bottomBarBounds?.toSize()).isEqualTo(bottomBarSize.toPxSize())
+ assertThat(geometry.bottomBarBounds?.width).isNotEqualTo(0.px)
+ }
+ }
}
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/SnackbarTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/SnackbarTest.kt
index 9068ae4..246686d 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/SnackbarTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/SnackbarTest.kt
@@ -44,13 +44,13 @@
import androidx.ui.unit.IntPx
import androidx.ui.unit.PxPosition
import androidx.ui.unit.dp
-import androidx.ui.unit.round
-import androidx.ui.unit.toPx
+import androidx.ui.unit.ipx
import com.google.common.truth.Truth.assertThat
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
+import kotlin.math.roundToInt
@MediumTest
@RunWith(JUnit4::class)
@@ -110,7 +110,8 @@
assertThat(it[FirstBaseline])
.isEqualTo(it[LastBaseline])
// TODO(aelias): Remove 'parentCoordinates!!' when Semantics no longer using PassThroughLayout
- assertThat(it.parentCoordinates!!.positionInParent.y.round() + it[FirstBaseline]!!)
+ assertThat(it.parentCoordinates!!.positionInParent.y.roundToInt().ipx +
+ it[FirstBaseline]!!)
.isEqualTo(30.dp.toIntPx())
}
}
@@ -167,11 +168,11 @@
assertThat(localTextCoords[FirstBaseline]).isNotEqualTo(IntPx.Zero)
assertThat(localButtonTextCoords[FirstBaseline]).isNotEqualTo(IntPx.Zero)
assertThat(
- localTextCoords.globalPosition.y.round() +
+ localTextCoords.globalPosition.y.roundToInt().ipx +
localTextCoords[FirstBaseline]!!
).isEqualTo(30.dp.toIntPx())
assertThat(
- buttonTextPos.y.round() + localButtonTextCoords[FirstBaseline]!!
+ buttonTextPos.y.roundToInt().ipx + localButtonTextCoords[FirstBaseline]!!
).isEqualTo(30.dp.toIntPx())
}
}
@@ -201,7 +202,8 @@
assertThat(it[FirstBaseline]).isNotEqualTo(it[LastBaseline])
// TODO(aelias): Remove 'parentCoordinates!!' when Semantics no longer using PassThroughLayout
assertThat(
- it.parentCoordinates!!.positionInParent.y.round() + it[FirstBaseline]!!
+ it.parentCoordinates!!.positionInParent.y.roundToInt().ipx +
+ it[FirstBaseline]!!
).isEqualTo(30.dp.toIntPx())
}
}
@@ -246,18 +248,21 @@
val buttonPositionInSnack =
localSnackCoords.childToLocal(localButtonCoords, PxPosition.Origin)
val buttonCenter =
- buttonPositionInSnack.y + localButtonCoords.size.height / 2
+ buttonPositionInSnack.y.roundToInt() +
+ (localButtonCoords.size.height / 2).value.toFloat()
assertThat(localTextCoords[FirstBaseline]).isNotEqualTo(IntPx.Zero)
assertThat(localTextCoords[LastBaseline]).isNotEqualTo(IntPx.Zero)
assertThat(localTextCoords[FirstBaseline])
.isNotEqualTo(localTextCoords[LastBaseline])
assertThat(
- localTextCoords.globalPosition.y.round() +
+ localTextCoords.globalPosition.y.roundToInt().ipx +
localTextCoords[FirstBaseline]!!
).isEqualTo(30.dp.toIntPx())
- assertThat(buttonCenter).isEqualTo((localSnackCoords.size.height / 2).toPx())
+ assertThat(buttonCenter).isEqualTo(
+ (localSnackCoords.size.height / 2).value.toFloat()
+ )
}
}
}
@@ -303,21 +308,22 @@
localSnackCoords.childToLocal(localTextCoords, PxPosition.Origin)
assertThat(
- textPositionInSnack.y.round() + localTextCoords[FirstBaseline]!!
+ textPositionInSnack.y.roundToInt().ipx + localTextCoords[FirstBaseline]!!
).isEqualTo(30.dp.toIntPx())
assertThat(
- buttonPositionInSnack.y.round() - textPositionInSnack.y.round() -
+ buttonPositionInSnack.y.roundToInt().ipx -
+ textPositionInSnack.y.roundToInt().ipx -
localTextCoords[LastBaseline]!!
).isEqualTo(18.dp.toIntPx())
assertThat(
- localSnackCoords.size.height - buttonPositionInSnack.y.round() -
+ localSnackCoords.size.height - buttonPositionInSnack.y.roundToInt().ipx -
localButtonCoords.size.height
).isEqualTo(8.dp.toIntPx())
assertThat(
- localSnackCoords.size.width - buttonPositionInSnack.x.round() -
+ localSnackCoords.size.width - buttonPositionInSnack.x.roundToInt().ipx -
localButtonCoords.size.width
).isEqualTo(8.dp.toIntPx())
}
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/TabTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/TabTest.kt
index e8cb5a6..faf7797 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/TabTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/TabTest.kt
@@ -45,7 +45,6 @@
import androidx.ui.test.findAll
import androidx.ui.test.isInMutuallyExclusiveGroup
import androidx.ui.test.runOnIdleCompose
-import androidx.ui.unit.Px
import androidx.ui.unit.PxPosition
import androidx.ui.unit.dp
import androidx.ui.unit.toPx
@@ -147,12 +146,12 @@
val tabRowWidth = tabRowCoords.size.width
val tabRowHeight = tabRowCoords.size.height
- val indicatorPositionX = indicatorCoords.localToGlobal(PxPosition.Origin).x.value
+ val indicatorPositionX = indicatorCoords.localToGlobal(PxPosition.Origin).x
val expectedPositionX = 0.dp.toPx()
assertThat(indicatorPositionX).isEqualTo(expectedPositionX)
val indicatorPositionY = indicatorCoords.localToGlobal(PxPosition.Origin).y
- val expectedPositionY = (tabRowHeight - indicatorHeight.toIntPx()).toPx()
+ val expectedPositionY = (tabRowHeight - indicatorHeight.toIntPx()).value.toFloat()
assertThat(indicatorPositionY).isEqualTo(expectedPositionY)
tabRowWidth to tabRowHeight
@@ -166,11 +165,12 @@
runOnIdleCompose {
with(composeTestRule.density) {
val indicatorPositionX = indicatorCoords.localToGlobal(PxPosition.Origin).x
- val expectedPositionX = tabRowWidth / 2
- assertThat(indicatorPositionX).isEqualTo(expectedPositionX.toPx())
+ val expectedPositionX = (tabRowWidth / 2).value.toFloat()
+ assertThat(indicatorPositionX).isEqualTo(expectedPositionX)
val indicatorPositionY = indicatorCoords.localToGlobal(PxPosition.Origin).y
- val expectedPositionY = (tabRowHeight - indicatorHeight.toIntPx()).toPx()
+ val expectedPositionY =
+ (tabRowHeight - indicatorHeight.toIntPx()).value.toFloat()
assertThat(indicatorPositionY).isEqualTo(expectedPositionY)
}
}
@@ -180,7 +180,7 @@
fun singleLineTab_textBaseline() {
lateinit var tabRowCoords: LayoutCoordinates
lateinit var textCoords: LayoutCoordinates
- var textBaseline: Px = Px(Float.NEGATIVE_INFINITY)
+ var textBaseline = Float.NEGATIVE_INFINITY
composeTestRule.setMaterialContent {
var state by state { 0 }
@@ -196,7 +196,7 @@
text = {
Text(text, Modifier.onPositioned { coords: LayoutCoordinates ->
textCoords = coords
- textBaseline = coords[LastBaseline]!!.toPx()
+ textBaseline = coords[LastBaseline]!!.toPx().value
})
},
selected = state == index,
@@ -216,7 +216,7 @@
val textPositionY = textCoords.localToGlobal(PxPosition.Origin).y
val baselinePositionY = textPositionY + textBaseline
- val expectedPositionY = tabRowHeight.toPx() - expectedBaselineDistance
+ val expectedPositionY = (tabRowHeight.toPx() - expectedBaselineDistance).value
assertThat(baselinePositionY).isEqualTo(expectedPositionY)
}
}
@@ -225,7 +225,7 @@
fun singleLineTab_withIcon_textBaseline() {
lateinit var tabRowCoords: LayoutCoordinates
lateinit var textCoords: LayoutCoordinates
- var textBaseline: Px = Px(Float.NEGATIVE_INFINITY)
+ var textBaseline = Float.NEGATIVE_INFINITY
composeTestRule.setMaterialContent {
var state by state { 0 }
@@ -241,7 +241,7 @@
text = {
Text(text, Modifier.onPositioned { coords: LayoutCoordinates ->
textCoords = coords
- textBaseline = coords[LastBaseline]!!.toPx()
+ textBaseline = coords[LastBaseline]!!.toPx().value
})
},
icon = { Icon(Icons.Filled.Favorite) },
@@ -262,7 +262,7 @@
val textPositionY = textCoords.localToGlobal(PxPosition.Origin).y
val baselinePositionY = textPositionY + textBaseline
- val expectedPositionY = tabRowHeight.toPx() - expectedBaselineDistance
+ val expectedPositionY = (tabRowHeight.toPx() - expectedBaselineDistance).value
assertThat(baselinePositionY).isEqualTo(expectedPositionY)
}
}
@@ -271,7 +271,7 @@
fun twoLineTab_textBaseline() {
lateinit var tabRowCoords: LayoutCoordinates
lateinit var textCoords: LayoutCoordinates
- var textBaseline: Px = Px(Float.NEGATIVE_INFINITY)
+ var textBaseline = Float.NEGATIVE_INFINITY
composeTestRule.setMaterialContent {
var state by state { 0 }
@@ -287,7 +287,7 @@
text = {
Text(text, Modifier.preferredWidth(100.dp).onPositioned { coords ->
textCoords = coords
- textBaseline = coords[LastBaseline]!!.toPx()
+ textBaseline = coords[LastBaseline]!!.toPx().value
}, maxLines = 2)
},
selected = state == index,
@@ -307,7 +307,7 @@
val textPositionY = textCoords.localToGlobal(PxPosition.Origin).y
val baselinePositionY = textPositionY + textBaseline
- val expectedPositionY = tabRowHeight.toPx() - expectedBaselineDistance
+ val expectedPositionY = (tabRowHeight.toPx() - expectedBaselineDistance).value
assertThat(baselinePositionY).isEqualTo(expectedPositionY)
}
}
@@ -358,11 +358,11 @@
// Indicator should be placed in the bottom left of the first tab
val indicatorPositionX = indicatorCoords.localToGlobal(PxPosition.Origin).x
// Tabs in a scrollable tab row are offset 52.dp from each end
- val expectedPositionX = scrollableTabRowOffset.toIntPx().toPx()
+ val expectedPositionX = scrollableTabRowOffset.toIntPx().value.toFloat()
assertThat(indicatorPositionX).isEqualTo(expectedPositionX)
val indicatorPositionY = indicatorCoords.localToGlobal(PxPosition.Origin).y
- val expectedPositionY = (tabRowHeight - indicatorHeight.toIntPx()).toPx()
+ val expectedPositionY = (tabRowHeight - indicatorHeight.toIntPx()).value.toFloat()
assertThat(indicatorPositionY).isEqualTo(expectedPositionY)
tabRowHeight
@@ -375,11 +375,13 @@
// should be in the middle of the TabRow
composeTestRule.runOnIdleComposeWithDensity {
val indicatorPositionX = indicatorCoords.localToGlobal(PxPosition.Origin).x
- val expectedPositionX = (scrollableTabRowOffset + minimumTabWidth).toIntPx().toPx()
+ val expectedPositionX =
+ (scrollableTabRowOffset + minimumTabWidth).toIntPx().value.toFloat()
assertThat(indicatorPositionX).isEqualTo(expectedPositionX)
val indicatorPositionY = indicatorCoords.localToGlobal(PxPosition.Origin).y
- val expectedPositionY = (tabRowHeight - indicatorHeight.toIntPx()).toPx()
+ val expectedPositionY =
+ (tabRowHeight - indicatorHeight.toIntPx()).value.toFloat()
assertThat(indicatorPositionY).isEqualTo(expectedPositionY)
}
}
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/AppBar.kt b/ui/ui-material/src/main/java/androidx/ui/material/AppBar.kt
index 31332649..db43986 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/AppBar.kt
+++ b/ui/ui-material/src/main/java/androidx/ui/material/AppBar.kt
@@ -16,9 +16,7 @@
package androidx.ui.material
import androidx.compose.Composable
-import androidx.compose.Immutable
import androidx.ui.core.DensityAmbient
-import androidx.ui.text.LastBaseline
import androidx.ui.core.Modifier
import androidx.ui.foundation.Box
import androidx.ui.foundation.ContentGravity
@@ -41,19 +39,19 @@
import androidx.ui.layout.fillMaxHeight
import androidx.ui.layout.fillMaxSize
import androidx.ui.layout.fillMaxWidth
-import androidx.ui.layout.relativePaddingFrom
import androidx.ui.layout.padding
import androidx.ui.layout.preferredHeight
import androidx.ui.layout.preferredWidth
-import androidx.ui.material.BottomAppBar.FabConfiguration
+import androidx.ui.layout.relativePaddingFrom
import androidx.ui.semantics.Semantics
+import androidx.ui.text.LastBaseline
import androidx.ui.unit.Density
import androidx.ui.unit.Dp
-import androidx.ui.unit.IntPxSize
-import androidx.ui.unit.PxPosition
+import androidx.ui.unit.PxBounds
import androidx.ui.unit.dp
+import androidx.ui.unit.height
import androidx.ui.unit.sp
-import androidx.ui.unit.toPxSize
+import androidx.ui.unit.width
import kotlin.math.sqrt
/**
@@ -153,56 +151,6 @@
)
}
-object BottomAppBar {
- /**
- * Configuration for a [FloatingActionButton] in a [BottomAppBar].
- *
- * This is state that is usually passed down to BottomAppBar by [Scaffold] or by another
- * scaffold-like component that is aware of [FloatingActionButton] existence and its size and
- * position.
- *
- * When cutoutShape is provided in BottomAppBar, a cutout / notch will be 'carved' into the
- * BottomAppBar based on FabConfiguration provided, with some extra space on all sides.
- *
- * If you use BottomAppBar with [Scaffold], a typical cutout for
- * FAB may look like:
- *
- * @sample androidx.ui.material.samples.SimpleBottomAppBarCutoutWithScaffold
- *
- * @param fabSize the size of the FAB that will be shown on top of BottomAppBar
- * @param fabTopLeftPosition the top left coordinate of the [FloatingActionButton] on the
- * screen for BottomAppBar to carve a right cutout if desired
- * @param fabDockedPosition the docked position of the [FloatingActionButton] in the
- * [BottomAppBar]
- */
- @Immutable
- data class FabConfiguration(
- internal val fabSize: IntPxSize,
- internal val fabTopLeftPosition: PxPosition,
- internal val fabDockedPosition: FabDockedPosition
- )
-
- /**
- * The possible positions for a [FloatingActionButton] docked to a [BottomAppBar].
- *
- * The layout of icons within the [BottomAppBar] will depend on the chosen position of the
- * [FloatingActionButton].
- */
- enum class FabDockedPosition {
- /**
- * Positioned in the center of the [BottomAppBar]. A minimum of one and a maximum of two
- * additional actions can be placed on the right side of the bar, and navigation icon will
- * be placed on the left side.
- */
- Center,
- /**
- * Positioned at the end of the [BottomAppBar]. A maximum of four additional
- * actions will be shown on the left side of the bar and there should be no navigation icon.
- */
- End
- }
-}
-
/**
* A BottomAppBar displays actions relating to the current screen and is placed at the bottom of
* the screen. It can also optionally display a [FloatingActionButton], which is either overlaid
@@ -218,13 +166,10 @@
* @param contentColor The preferred content color provided by this BottomAppBar to its children.
* Defaults to either the matching `onFoo` color for [backgroundColor], or if [backgroundColor] is
* not a color from the theme, this will keep the same value set above this BottomAppBar.
- * @param fabConfiguration The [FabConfiguration] that controls where the [FloatingActionButton]
- * is placed inside the BottomAppBar. This is used both to determine the cutout position for
- * BottomAppBar (if cutoutShape is non-null) and to choose proper layout for BottomAppBar. If
- * null, BottomAppBar will show no cutout and no-FAB layout of icons.
* @param cutoutShape the shape of the cutout that will be added to the BottomAppBar - this
- * should typically be the same shape used inside the [FloatingActionButton]. This shape will be
- * drawn with an offset around all sides. If null, where will be no cutout.
+ * should typically be the same shape used inside the [FloatingActionButton], when [BottomAppBar]
+ * and [FloatingActionButton] are being used together in [Scaffold]. This shape will be drawn with
+ * an offset around all sides. If null, where will be no cutout.
* @param content the content of this BottomAppBar. The default layout here is a [Row],
* so content inside will be placed horizontally.
*/
@@ -233,19 +178,15 @@
modifier: Modifier = Modifier,
backgroundColor: Color = MaterialTheme.colors.primarySurface,
contentColor: Color = contentColorFor(backgroundColor),
- fabConfiguration: FabConfiguration? = null,
cutoutShape: Shape? = null,
content: @Composable RowScope.() -> Unit
) {
- val shape = if (cutoutShape == null || fabConfiguration == null) {
- RectangleShape
+ val scaffoldGeometry = ScaffoldGeometryAmbient.current
+ val fabBounds = scaffoldGeometry.fabBounds
+ val shape = if (cutoutShape != null && scaffoldGeometry.isFabDocked && fabBounds != null) {
+ BottomAppBarCutoutShape(cutoutShape, fabBounds)
} else {
- val pxSize = fabConfiguration.fabSize.toPxSize()
- BottomAppBarCutoutShape(
- cutoutShape,
- fabConfiguration.fabTopLeftPosition,
- Size(pxSize.width.value, pxSize.height.value)
- )
+ RectangleShape
}
AppBar(backgroundColor, contentColor, BottomAppBarElevation, shape, modifier) {
// TODO: b/150609566 clarify emphasis for children
@@ -265,8 +206,7 @@
*/
private data class BottomAppBarCutoutShape(
val cutoutShape: Shape,
- val fabPosition: PxPosition,
- val fabSize: Size
+ val fabBounds: PxBounds
) : Shape {
override fun createOutline(size: Size, density: Density): Outline {
@@ -290,11 +230,11 @@
val cutoutOffset = with(density) { BottomAppBarCutoutOffset.toPx() }
val cutoutSize = Size(
- width = fabSize.width + (cutoutOffset * 2),
- height = fabSize.height + (cutoutOffset * 2)
+ width = fabBounds.width + (cutoutOffset * 2),
+ height = fabBounds.height + (cutoutOffset * 2)
)
- val cutoutStartX = fabPosition.x.value - cutoutOffset
+ val cutoutStartX = fabBounds.left - cutoutOffset
val cutoutEndX = cutoutStartX + cutoutSize.width
val cutoutRadius = cutoutSize.height / 2f
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/BottomNavigation.kt b/ui/ui-material/src/main/java/androidx/ui/material/BottomNavigation.kt
index f0dd9af..3474e3e 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/BottomNavigation.kt
+++ b/ui/ui-material/src/main/java/androidx/ui/material/BottomNavigation.kt
@@ -24,7 +24,6 @@
import androidx.compose.emptyContent
import androidx.ui.animation.animate
import androidx.ui.core.Constraints
-import androidx.ui.text.LastBaseline
import androidx.ui.core.Layout
import androidx.ui.core.MeasureScope
import androidx.ui.core.Modifier
@@ -36,7 +35,7 @@
import androidx.ui.foundation.ContentGravity
import androidx.ui.foundation.ProvideTextStyle
import androidx.ui.foundation.contentColor
-import androidx.ui.foundation.selection.MutuallyExclusiveSetItem
+import androidx.ui.foundation.selection.selectable
import androidx.ui.graphics.Color
import androidx.ui.graphics.lerp
import androidx.ui.layout.Arrangement
@@ -44,7 +43,7 @@
import androidx.ui.layout.RowScope
import androidx.ui.layout.fillMaxWidth
import androidx.ui.layout.preferredHeight
-import androidx.ui.material.ripple.ripple
+import androidx.ui.text.LastBaseline
import androidx.ui.text.style.TextAlign
import androidx.ui.unit.Dp
import androidx.ui.unit.IntPx
@@ -141,22 +140,20 @@
val style = MaterialTheme.typography.caption.copy(textAlign = TextAlign.Center)
ProvideTextStyle(style, children = text)
}
- MutuallyExclusiveSetItem(
- selected = selected,
- onClick = onSelected,
- modifier = Modifier.ripple()
- ) {
- // TODO This composable has magic behavior within a Row; reconsider this behavior later
- Box(with(RowScope) { modifier.weight(1f) }, gravity = ContentGravity.Center) {
- BottomNavigationTransition(activeColor, inactiveColor, selected) { progress ->
- val animationProgress = if (alwaysShowLabels) 1f else progress
+ // TODO This composable has magic behavior within a Row; reconsider this behavior later
+ Box(with(RowScope) {
+ modifier
+ .selectable(selected = selected, onClick = onSelected)
+ .weight(1f)
+ }, gravity = ContentGravity.Center) {
+ BottomNavigationTransition(activeColor, inactiveColor, selected) { progress ->
+ val animationProgress = if (alwaysShowLabels) 1f else progress
- BottomNavigationItemBaselineLayout(
- icon = icon,
- text = styledText,
- iconPositionAnimationProgress = animationProgress
- )
- }
+ BottomNavigationItemBaselineLayout(
+ icon = icon,
+ text = styledText,
+ iconPositionAnimationProgress = animationProgress
+ )
}
}
}
@@ -229,7 +226,8 @@
// If the text is empty, just place the icon.
if (textPlaceable.width <= BottomNavigationItemHorizontalPadding.toIntPx() * 2 &&
- textPlaceable.height == IntPx.Zero) {
+ textPlaceable.height == IntPx.Zero
+ ) {
placeIcon(iconPlaceable, constraints)
} else {
placeTextAndIcon(
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/Drawer.kt b/ui/ui-material/src/main/java/androidx/ui/material/Drawer.kt
index 0babd2a..89f862a 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/Drawer.kt
+++ b/ui/ui-material/src/main/java/androidx/ui/material/Drawer.kt
@@ -38,10 +38,10 @@
import androidx.ui.material.internal.StateDraggable
import androidx.ui.unit.Dp
import androidx.ui.unit.IntPx
-import androidx.ui.unit.Px
import androidx.ui.unit.dp
import androidx.ui.unit.min
import androidx.ui.unit.px
+import androidx.ui.unit.round
import androidx.ui.util.lerp
/**
@@ -80,7 +80,7 @@
* @param drawerContent composable that represents content inside the drawer
* @param bodyContent content of the rest of the UI
*
- * @throws IllegalStateException when parent has [Px.Infinity] width
+ * @throws IllegalStateException when parent has [Float.POSITIVE_INFINITY] width
*/
@Composable
fun ModalDrawerLayout(
@@ -151,7 +151,7 @@
* @param drawerContent composable that represents content inside the drawer
* @param bodyContent content of the rest of the UI
*
- * @throws IllegalStateException when parent has [Px.Infinity] height
+ * @throws IllegalStateException when parent has [Float.POSITIVE_INFINITY] height
*/
@Composable
fun BottomDrawerLayout(
@@ -327,7 +327,7 @@
layout(width, height) {
val offX = xOffset?.value?.px ?: 0.px
val offY = yOffset?.value?.px ?: 0.px
- placeable?.place(offX, offY)
+ placeable?.place(offX.round(), offY.round())
}
}
}
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/ListItem.kt b/ui/ui-material/src/main/java/androidx/ui/material/ListItem.kt
index 270e4c7..63966c7 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/ListItem.kt
+++ b/ui/ui-material/src/main/java/androidx/ui/material/ListItem.kt
@@ -20,6 +20,7 @@
import androidx.ui.core.Alignment
import androidx.ui.core.Layout
import androidx.ui.core.Modifier
+import androidx.ui.core.semantics.semantics
import androidx.ui.foundation.Box
import androidx.ui.foundation.ContentGravity
import androidx.ui.foundation.Image
@@ -176,7 +177,9 @@
val indication = RippleIndication(
color = MaterialTheme.colors.onSurface.copy(alpha = RippleOpacity)
)
- Box(Modifier.clickable(onClick = onClick, indication = indication), children = item)
+ Box(Modifier
+ .semantics(mergeAllDescendants = true)
+ .clickable(onClick = onClick, indication = indication), children = item)
} else {
item()
}
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/Menu.kt b/ui/ui-material/src/main/java/androidx/ui/material/Menu.kt
index 4819e59..3e24c4ed 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/Menu.kt
+++ b/ui/ui-material/src/main/java/androidx/ui/material/Menu.kt
@@ -46,7 +46,7 @@
import androidx.ui.layout.padding
import androidx.ui.layout.preferredSizeIn
import androidx.ui.layout.preferredWidth
-import androidx.ui.material.ripple.ripple
+import androidx.ui.material.ripple.RippleIndication
import androidx.ui.unit.Density
import androidx.ui.unit.IntPxPosition
import androidx.ui.unit.IntPxSize
@@ -159,8 +159,7 @@
// TODO(popam, b/156911853): investigate replacing this Box with ListItem
Box(
modifier = modifier
- .clickable(enabled = enabled, onClick = onClick)
- .ripple(enabled = enabled)
+ .clickable(enabled = enabled, onClick = onClick, indication = RippleIndication(true))
.fillMaxWidth()
// Preferred min and max width used during the intrinsic measurement.
.preferredSizeIn(
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/ProgressIndicator.kt b/ui/ui-material/src/main/java/androidx/ui/material/ProgressIndicator.kt
index b1572e8..f599cf1 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/ProgressIndicator.kt
+++ b/ui/ui-material/src/main/java/androidx/ui/material/ProgressIndicator.kt
@@ -29,8 +29,8 @@
import androidx.ui.core.LayoutDirection
import androidx.ui.core.Modifier
import androidx.ui.foundation.Canvas
-import androidx.ui.foundation.DeterminateProgressIndicator
import androidx.ui.foundation.Strings
+import androidx.ui.foundation.determinateProgressIndicator
import androidx.ui.geometry.Offset
import androidx.ui.geometry.Size
import androidx.ui.graphics.Color
@@ -60,18 +60,18 @@
modifier: Modifier = Modifier,
color: Color = MaterialTheme.colors.primary
) {
- DeterminateProgressIndicator(progress = progress) {
- val stroke = with(DensityAmbient.current) {
- Stroke(
- width = ProgressIndicatorConstants.DefaultStrokeWidth.toPx(),
- cap = StrokeCap.butt
- )
- }
- val backgroundColor = color.copy(alpha = BackgroundOpacity)
- Canvas(modifier.preferredSize(LinearIndicatorWidth, LinearIndicatorHeight)) {
- drawLinearIndicatorBackground(backgroundColor, stroke)
- drawLinearIndicator(0f, progress, color, stroke)
- }
+ val stroke = with(DensityAmbient.current) {
+ Stroke(
+ width = ProgressIndicatorConstants.DefaultStrokeWidth.toPx(),
+ cap = StrokeCap.butt
+ )
+ }
+ val backgroundColor = color.copy(alpha = BackgroundOpacity)
+ Canvas(modifier.determinateProgressIndicator(progress)
+ .preferredSize(LinearIndicatorWidth, LinearIndicatorHeight)
+ ) {
+ drawLinearIndicatorBackground(backgroundColor, stroke)
+ drawLinearIndicator(0f, progress, color, stroke)
}
}
@@ -166,20 +166,19 @@
color: Color = MaterialTheme.colors.primary,
strokeWidth: Dp = ProgressIndicatorConstants.DefaultStrokeWidth
) {
- DeterminateProgressIndicator(progress = progress) {
- val stroke = with(DensityAmbient.current) {
- Stroke(width = strokeWidth.toPx(), cap = StrokeCap.butt)
- }
- Canvas(
- modifier
- .padding(CircularIndicatorPadding)
- .preferredSize(CircularIndicatorDiameter)
- ) {
- // Start at 12 O'clock
- val startAngle = 270f
- val sweep = progress * 360f
- drawDeterminateCircularIndicator(startAngle, sweep, color, stroke)
- }
+ val stroke = with(DensityAmbient.current) {
+ Stroke(width = strokeWidth.toPx(), cap = StrokeCap.butt)
+ }
+ Canvas(
+ modifier
+ .determinateProgressIndicator(progress)
+ .padding(CircularIndicatorPadding)
+ .preferredSize(CircularIndicatorDiameter)
+ ) {
+ // Start at 12 O'clock
+ val startAngle = 270f
+ val sweep = progress * 360f
+ drawDeterminateCircularIndicator(startAngle, sweep, color, stroke)
}
}
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/RadioButton.kt b/ui/ui-material/src/main/java/androidx/ui/material/RadioButton.kt
index ae152e1..24e3fe8 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/RadioButton.kt
+++ b/ui/ui-material/src/main/java/androidx/ui/material/RadioButton.kt
@@ -25,10 +25,11 @@
import androidx.ui.animation.Transition
import androidx.ui.core.DensityAmbient
import androidx.ui.core.Modifier
+import androidx.ui.core.semantics.semantics
import androidx.ui.foundation.Box
import androidx.ui.foundation.Canvas
import androidx.ui.foundation.Text
-import androidx.ui.foundation.selection.MutuallyExclusiveSetItem
+import androidx.ui.foundation.selection.selectable
import androidx.ui.geometry.Offset
import androidx.ui.graphics.Color
import androidx.ui.graphics.drawscope.DrawScope
@@ -39,8 +40,7 @@
import androidx.ui.layout.fillMaxWidth
import androidx.ui.layout.padding
import androidx.ui.layout.preferredSize
-import androidx.ui.material.ripple.ripple
-import androidx.ui.semantics.Semantics
+import androidx.ui.material.ripple.RippleIndication
import androidx.ui.text.TextStyle
import androidx.ui.unit.dp
@@ -135,15 +135,15 @@
modifier: Modifier = Modifier,
content: @Composable () -> Unit
) {
- Semantics(container = true, mergeAllDescendants = true) {
- Box(modifier) {
- MutuallyExclusiveSetItem(
+ Box(
+ modifier = modifier
+ .semantics(mergeAllDescendants = true)
+ .selectable(
selected = selected,
- onClick = { if (!selected) onSelect() }, children = content,
- modifier = Modifier.ripple()
- )
- }
- }
+ onClick = { if (!selected) onSelect() }
+ ),
+ children = content
+ )
}
/**
@@ -205,27 +205,28 @@
modifier: Modifier = Modifier,
color: Color = MaterialTheme.colors.secondary
) {
- Stack(modifier) {
- MutuallyExclusiveSetItem(
- selected = selected, onClick = { if (!selected) onSelect?.invoke() },
- modifier = Modifier.ripple(bounded = false)
- ) {
- val unselectedColor =
- MaterialTheme.colors.onSurface.copy(alpha = UnselectedOpacity)
- val definition = remember(color, unselectedColor) {
- generateTransitionDefinition(color, unselectedColor)
- }
- Transition(definition = definition, toState = selected) { state ->
- val radioStroke = Stroke(RadioStrokeWidth.value * DensityAmbient.current.density)
- Canvas(Modifier.padding(RadioButtonPadding).preferredSize(RadioButtonSize)) {
- drawRadio(
- state[ColorProp],
- state[OuterRadiusProp].toPx(),
- state[InnerRadiusProp].toPx(),
- state[GapProp].toPx(),
- radioStroke
- )
- }
+ Stack(
+ modifier.selectable(
+ selected = selected,
+ onClick = { if (!selected) onSelect?.invoke() },
+ indication = RippleIndication(bounded = false)
+ )
+ ) {
+ val unselectedColor =
+ MaterialTheme.colors.onSurface.copy(alpha = UnselectedOpacity)
+ val definition = remember(color, unselectedColor) {
+ generateTransitionDefinition(color, unselectedColor)
+ }
+ Transition(definition = definition, toState = selected) { state ->
+ val radioStroke = Stroke(RadioStrokeWidth.value * DensityAmbient.current.density)
+ Canvas(Modifier.padding(RadioButtonPadding).preferredSize(RadioButtonSize)) {
+ drawRadio(
+ state[ColorProp],
+ state[OuterRadiusProp].toPx(),
+ state[InnerRadiusProp].toPx(),
+ state[GapProp].toPx(),
+ radioStroke
+ )
}
}
}
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/Scaffold.kt b/ui/ui-material/src/main/java/androidx/ui/material/Scaffold.kt
index 954f11e..a73ab86 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/Scaffold.kt
+++ b/ui/ui-material/src/main/java/androidx/ui/material/Scaffold.kt
@@ -17,38 +17,46 @@
package androidx.ui.material
import androidx.compose.Composable
+import androidx.compose.Providers
import androidx.compose.Stable
+import androidx.compose.StructurallyEqual
import androidx.compose.getValue
import androidx.compose.mutableStateOf
import androidx.compose.onDispose
import androidx.compose.remember
import androidx.compose.setValue
+import androidx.compose.staticAmbientOf
import androidx.ui.core.Alignment
import androidx.ui.core.DensityAmbient
import androidx.ui.core.Layout
import androidx.ui.core.Modifier
+import androidx.ui.core.boundsInParent
import androidx.ui.core.onPositioned
import androidx.ui.core.zIndex
+import androidx.ui.graphics.Color
+import androidx.ui.graphics.Shape
import androidx.ui.layout.Column
+import androidx.ui.layout.InnerPadding
import androidx.ui.layout.Stack
import androidx.ui.layout.fillMaxSize
import androidx.ui.layout.fillMaxWidth
import androidx.ui.layout.padding
-import androidx.ui.material.BottomAppBar.FabConfiguration
-import androidx.ui.material.BottomAppBar.FabDockedPosition
import androidx.ui.material.Scaffold.FabPosition
+import androidx.ui.unit.Dp
import androidx.ui.unit.IntPx
-import androidx.ui.unit.IntPxSize
-import androidx.ui.unit.PxPosition
+import androidx.ui.unit.PxBounds
+import androidx.ui.unit.PxSize
import androidx.ui.unit.dp
+import androidx.ui.unit.height
+import androidx.ui.unit.toSize
/**
* State for [Scaffold] composable component.
*
- * Contains basic screen state, e.g. Drawer configuration.
+ * Contains basic screen state, e.g. Drawer configuration, as well as sizes of components after
+ * layout has happened
*
- * @param drawerState the state of the Drawer in [Scaffold]. Change it to open/close Drawer
- * programmatically.
+ * @param drawerState initial state of the Drawer in [Scaffold].
* @param isDrawerGesturesEnabled whether or not drawer can be interacted with via gestures
*/
@Stable
@@ -57,14 +65,53 @@
isDrawerGesturesEnabled: Boolean = true
) {
+ /**
+ * drawer state position. Change this value to programmatically open or close drawer sheet
+ * in Scaffold (if set).
+ */
var drawerState by mutableStateOf(drawerState)
+
+ /**
+ * Whether or not drawer sheet in scaffold (if set) can be interacted by gestures.
+ */
var isDrawerGesturesEnabled by mutableStateOf(isDrawerGesturesEnabled)
// TODO: add showSnackbar() method here
- internal var fabConfiguration: FabConfiguration? by mutableStateOf<FabConfiguration?>(null)
- internal var bottomBarSize: IntPxSize? by mutableStateOf<IntPxSize?>(null)
+ /**
+ * Get current size of the topBar in [Scaffold], if known. `null` if this unknown or topBar
+ * parameter in scaffold is not set
+ */
+ val topBarSize: PxSize?
+ get() = scaffoldGeometry.topBarBounds?.toSize()
+
+ /**
+ * Get current size of the bottomBar in [Scaffold], if known. `null` if this unknown or
+ * bottomBar parameter in scaffold is not set
+ */
+ val bottomBarSize: PxSize?
+ get() = scaffoldGeometry.bottomBarBounds?.toSize()
+
+ /**
+ * Get current size of the floatingActionButton in [Scaffold], if known. `null` if this unknown
+ * or floatingActionButton parameter in scaffold is not set
+ */
+ val floatingActionButtonSize: PxSize?
+ get() = scaffoldGeometry.fabBounds?.toSize()
+
+ internal val scaffoldGeometry = ScaffoldGeometry()
}
+@Stable
+internal class ScaffoldGeometry {
+ var topBarBounds by mutableStateOf<PxBounds?>(null, StructurallyEqual)
+ var bottomBarBounds by mutableStateOf<PxBounds?>(null, StructurallyEqual)
+ var fabBounds by mutableStateOf<PxBounds?>(null, StructurallyEqual)
+
+ var isFabDocked by mutableStateOf(false)
+}
+
+internal val ScaffoldGeometryAmbient = staticAmbientOf { ScaffoldGeometry() }
+
object Scaffold {
/**
* The possible positions for a [FloatingActionButton] attached to a [Scaffold].
@@ -79,17 +126,7 @@
* Position FAB at the bottom of the screen at the end, above the [BottomAppBar] (if it
* exists)
*/
- End,
- /**
- * Position FAB on the center of the screen, overlap with [BottomAppBar] (which should
- * exist if this position is used, otherwise an exception will be thrown)
- */
- CenterDocked,
- /**
- * Position FAB on the end of the screen, overlap with [BottomAppBar] (which should
- * exist if this position is used, otherwise an exception will be thrown)
- */
- EndDocked
+ End
}
}
@@ -110,36 +147,46 @@
* @sample androidx.ui.material.samples.ScaffoldWithBottomBarAndCutout
*
* @param scaffoldState state of this scaffold widget. It contains the state of the screen, e.g.
- * variables to provide manual control over the drawer behavior
- * @param topAppBar top app bar of the screen. Consider using [TopAppBar].
- * @param bottomAppBar bottom bar of the screen. Consider using [BottomAppBar]. The slot
- * Parameter [FabConfiguration] is necessary to be passed as a parameter to [BottomAppBar] in
- * order to ensure proper [FloatingActionButton] + [BottomAppBar] behavior.
+ * variables to provide manual control over the drawer behavior, sizes of components, etc
+ * @param topBar top app bar of the screen. Consider using [TopAppBar].
+ * @param bottomBar bottom bar of the screen. Consider using [BottomAppBar].
* @param floatingActionButton Main action button of your screen. Consider using
* [FloatingActionButton] for this slot.
* @param floatingActionButtonPosition position of the FAB on the screen. See [FabPosition] for
* possible options available.
+ * @param isFloatingActionButtonDocked whether [floatingActionButton] should overlap with
+ * [bottomBar] for half a height, if [bottomBar] exists. Ignored if there's no [bottomBar] or no
+ * [floatingActionButton].
* @param drawerContent content of the Drawer sheet that can be pulled from the left side (right
* for RTL).
- * @param bodyContent content of your screen. The lambda receives a Modifier that should be
- * applied to the content root to get the desired behavior. If you're using VerticalScroller,
- * apply this modifier to the child of the scroller, and not on the scroller itself.
+ * @param drawerShape shape of the drawer sheet (if set)
+ * @param drawerElevation drawer sheet elevation. This controls the size of the shadow
+ * below the drawer sheet (if set)
+ * @param bodyContent content of your screen. The lambda receives an [InnerPadding] that should be
+ * applied to the content root via [Modifier.padding] to properly offset top and bottom bars. If
+ * you're using VerticalScroller, apply this modifier to the child of the scroller, and not on
+ * the scroller itself.
*/
@Composable
fun Scaffold(
scaffoldState: ScaffoldState = remember { ScaffoldState() },
- topAppBar: @Composable (() -> Unit)? = null,
- bottomAppBar: @Composable ((FabConfiguration?) -> Unit)? = null,
+ topBar: @Composable (() -> Unit)? = null,
+ bottomBar: @Composable (() -> Unit)? = null,
floatingActionButton: @Composable (() -> Unit)? = null,
floatingActionButtonPosition: FabPosition = FabPosition.End,
+ isFloatingActionButtonDocked: Boolean = false,
drawerContent: @Composable (() -> Unit)? = null,
- bodyContent: @Composable (Modifier) -> Unit
+ drawerShape: Shape = MaterialTheme.shapes.large,
+ drawerElevation: Dp = DrawerConstants.DefaultElevation,
+ backgroundColor: Color = MaterialTheme.colors.background,
+ bodyContent: @Composable (InnerPadding) -> Unit
) {
+ scaffoldState.scaffoldGeometry.isFabDocked = isFloatingActionButtonDocked
val child = @Composable {
- Surface(color = MaterialTheme.colors.background) {
+ Surface(color = backgroundColor) {
Column(Modifier.fillMaxSize()) {
- if (topAppBar != null) {
- ScaffoldSlot(Modifier.zIndex(TopAppBarZIndex), topAppBar)
+ if (topBar != null) {
+ TopBarContainer(Modifier.zIndex(TopAppBarZIndex), scaffoldState, topBar)
}
Stack(Modifier.weight(1f, fill = true)) {
ScaffoldContent(Modifier.fillMaxSize(), scaffoldState, bodyContent)
@@ -147,8 +194,9 @@
Modifier.gravity(Alignment.BottomCenter),
scaffoldState = scaffoldState,
fabPos = floatingActionButtonPosition,
+ isFabDocked = isFloatingActionButtonDocked,
fab = floatingActionButton,
- bottomBar = bottomAppBar
+ bottomBar = bottomBar
)
}
}
@@ -161,6 +209,8 @@
onStateChange = { scaffoldState.drawerState = it },
gesturesEnabled = scaffoldState.isDrawerGesturesEnabled,
drawerContent = { ScaffoldSlot(content = drawerContent) },
+ drawerShape = drawerShape,
+ drawerElevation = drawerElevation,
bodyContent = child
)
} else {
@@ -179,14 +229,21 @@
modifier: Modifier,
scaffoldState: ScaffoldState,
fabPos: FabPosition,
+ isFabDocked: Boolean,
fab: @Composable (() -> Unit)? = null,
- bottomBar: @Composable ((FabConfiguration?) -> Unit)? = null
+ bottomBar: @Composable (() -> Unit)? = null
) {
- if (fabPos != FabPosition.CenterDocked && fabPos != FabPosition.EndDocked) {
+ if (isFabDocked && bottomBar != null && fab != null) {
+ DockedBottomBar(
+ modifier = modifier,
+ fabPosition = fabPos,
+ fab = { FabContainer(Modifier, scaffoldState, fab) },
+ bottomBar = { BottomBarContainer(scaffoldState, bottomBar) }
+ )
+ } else {
Column(modifier.fillMaxWidth()) {
if (fab != null) {
FabContainer(
- fabPos,
Modifier.gravity(fabPos.toColumnAlign())
.padding(start = FabSpacing, end = FabSpacing, bottom = FabSpacing),
scaffoldState,
@@ -197,18 +254,6 @@
BottomBarContainer(scaffoldState, bottomBar)
}
}
- } else if (bottomBar != null && fab != null) {
- DockedBottomBar(
- modifier = modifier,
- fabPosition = fabPos,
- fab = { FabContainer(fabPos, Modifier, scaffoldState, fab) },
- bottomBar = { BottomBarContainer(scaffoldState, bottomBar) }
- )
- } else {
- throw IllegalArgumentException(
- "To use ${FabPosition.CenterDocked} or ${FabPosition.EndDocked} " +
- "you need both bottomBar and FAB"
- )
}
}
@@ -239,7 +284,7 @@
val layoutHeight = appBarPlaceable.height + (fabPlaceable.height / 2)
val appBarVerticalOffset = layoutHeight - appBarPlaceable.height
- val fabPosX = if (fabPosition == FabPosition.EndDocked) {
+ val fabPosX = if (fabPosition == FabPosition.End) {
layoutWidth - fabPlaceable.width - DockedFabEndSpacing.toIntPx()
} else {
(layoutWidth - fabPlaceable.width) / 2
@@ -256,60 +301,63 @@
private fun ScaffoldContent(
modifier: Modifier,
scaffoldState: ScaffoldState,
- content: @Composable (Modifier) -> Unit
+ content: @Composable (InnerPadding) -> Unit
) {
ScaffoldSlot(modifier) {
- val bottomSpace = with(DensityAmbient.current) {
- scaffoldState.bottomBarSize?.height?.toDp() ?: 0.dp
+ val innerPadding = with(DensityAmbient.current) {
+ val bottom = scaffoldState.scaffoldGeometry.bottomBarBounds?.height?.toDp() ?: 0.dp
+ InnerPadding(bottom = bottom)
}
- content(Modifier.padding(bottom = bottomSpace))
+ content(innerPadding)
}
}
@Composable
private fun BottomBarContainer(
scaffoldState: ScaffoldState,
- bottomBar: @Composable ((FabConfiguration?) -> Unit)
+ bottomBar: @Composable () -> Unit
) {
- onDispose(callback = { scaffoldState.bottomBarSize = null })
- ScaffoldSlot(
- modifier = Modifier.onPositioned {
- if (scaffoldState.bottomBarSize != it.size) scaffoldState.bottomBarSize = it.size
- },
- content = {
- bottomBar(scaffoldState.fabConfiguration)
+ BoundsAwareScaffoldSlot(
+ Modifier,
+ { scaffoldState.scaffoldGeometry.bottomBarBounds = it },
+ slotContent = {
+ Providers(ScaffoldGeometryAmbient provides scaffoldState.scaffoldGeometry) {
+ bottomBar()
+ }
}
)
}
@Composable
private fun FabContainer(
- fabPos: FabPosition,
modifier: Modifier,
scaffoldState: ScaffoldState,
fab: @Composable () -> Unit
) {
- onDispose { scaffoldState.fabConfiguration = null }
+ BoundsAwareScaffoldSlot(modifier, { scaffoldState.scaffoldGeometry.fabBounds = it }, fab)
+}
+
+@Composable
+private fun TopBarContainer(
+ modifier: Modifier,
+ scaffoldState: ScaffoldState,
+ topBar: @Composable () -> Unit
+) {
+ BoundsAwareScaffoldSlot(modifier, { scaffoldState.scaffoldGeometry.topBarBounds = it }, topBar)
+}
+
+@Composable
+private fun BoundsAwareScaffoldSlot(
+ modifier: Modifier,
+ onBoundsKnown: (PxBounds?) -> Unit,
+ slotContent: @Composable () -> Unit
+) {
+ onDispose {
+ onBoundsKnown(null)
+ }
ScaffoldSlot(
- modifier = modifier.onPositioned { coords ->
- // TODO(mount): This should probably use bounding box rather than position/size
- val position = coords.parentCoordinates?.childToLocal(coords, PxPosition.Origin)
- ?: PxPosition.Origin
- val config =
- when (fabPos) {
- FabPosition.CenterDocked -> {
- FabConfiguration(coords.size, position, FabDockedPosition.Center)
- }
- FabPosition.EndDocked -> {
- FabConfiguration(coords.size, position, FabDockedPosition.End)
- }
- else -> {
- null
- }
- }
- if (scaffoldState.fabConfiguration != config) scaffoldState.fabConfiguration = config
- },
- content = fab
+ modifier = modifier.onPositioned { coords -> onBoundsKnown(coords.boundsInParent) },
+ content = slotContent
)
}
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/Slider.kt b/ui/ui-material/src/main/java/androidx/ui/material/Slider.kt
index 4ede707..a502104 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/Slider.kt
+++ b/ui/ui-material/src/main/java/androidx/ui/material/Slider.kt
@@ -127,7 +127,7 @@
val pressed = state { false }
val press = Modifier.pressIndicatorGestureFilter(
onStart = { pos ->
- position.holder.snapTo(pos.x.value)
+ position.holder.snapTo(pos.x)
pressed.value = true
},
onStop = {
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 0862fc6..0b7393d 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
@@ -17,6 +17,7 @@
package androidx.ui.material
import androidx.animation.FastOutSlowInEasing
+import androidx.animation.FloatPropKey
import androidx.animation.LinearEasing
import androidx.animation.transitionDefinition
import androidx.compose.Composable
@@ -27,13 +28,10 @@
import androidx.compose.setValue
import androidx.compose.state
import androidx.ui.animation.ColorPropKey
-import androidx.ui.animation.PxPropKey
import androidx.ui.animation.Transition
import androidx.ui.core.Alignment
import androidx.ui.core.Constraints
import androidx.ui.core.DensityAmbient
-import androidx.ui.text.FirstBaseline
-import androidx.ui.text.LastBaseline
import androidx.ui.core.Layout
import androidx.ui.core.Modifier
import androidx.ui.core.Placeable
@@ -47,7 +45,7 @@
import androidx.ui.foundation.ScrollerPosition
import androidx.ui.foundation.contentColor
import androidx.ui.foundation.drawBackground
-import androidx.ui.foundation.selection.MutuallyExclusiveSetItem
+import androidx.ui.foundation.selection.selectable
import androidx.ui.graphics.Color
import androidx.ui.layout.Row
import androidx.ui.layout.Stack
@@ -56,12 +54,13 @@
import androidx.ui.layout.padding
import androidx.ui.layout.preferredHeight
import androidx.ui.layout.preferredWidth
+import androidx.ui.material.TabRow.IndicatorTransition
import androidx.ui.material.TabRow.TabPosition
-import androidx.ui.material.ripple.ripple
+import androidx.ui.text.FirstBaseline
+import androidx.ui.text.LastBaseline
import androidx.ui.text.style.TextAlign
import androidx.ui.unit.Density
import androidx.ui.unit.IntPx
-import androidx.ui.unit.Px
import androidx.ui.unit.coerceAtLeast
import androidx.ui.unit.dp
import androidx.ui.unit.max
@@ -366,7 +365,7 @@
}
object TabRow {
- private val IndicatorOffset = PxPropKey()
+ private val IndicatorOffset = FloatPropKey()
/**
* Data class that contains information about a tab's position on screen
@@ -424,7 +423,7 @@
internal fun IndicatorTransition(
tabPositions: List<TabPosition>,
selectedIndex: Int,
- indicator: @Composable (indicatorOffset: Px) -> Unit
+ indicator: @Composable (indicatorOffset: Float) -> Unit
) {
val transitionDefinition = remember(tabPositions) {
transitionDefinition {
@@ -433,13 +432,13 @@
// When this is supported by transitionDefinition, we should fix this to just set a
// default or similar.
state(selectedIndex) {
- this[IndicatorOffset] = tabPositions[selectedIndex].left.toPx()
+ this[IndicatorOffset] = tabPositions[selectedIndex].left.toPx().value
}
tabPositions.forEachIndexed { index, position ->
if (index != selectedIndex) {
state(index) {
- this[IndicatorOffset] = position.left.toPx()
+ this[IndicatorOffset] = position.left.toPx().value
}
}
}
@@ -519,13 +518,13 @@
modifier: Modifier = Modifier,
content: @Composable () -> Unit
) {
- MutuallyExclusiveSetItem(
- selected = selected,
- onClick = onSelected,
- modifier = Modifier.ripple()
- ) {
- Box(modifier.fillMaxWidth(), gravity = ContentGravity.Center, children = content)
- }
+ Box(
+ modifier = modifier
+ .selectable(selected = selected, onClick = onSelected)
+ .fillMaxWidth(),
+ gravity = ContentGravity.Center,
+ children = content
+ )
}
private val TabTintColor = ColorPropKey()
@@ -635,7 +634,8 @@
lastBaseline = requireNotNull(lastBaseline) { "No text baselines found" }
)
hasIconPlaceable -> placeIcon(iconPlaceable, tabHeight)
- else -> {}
+ else -> {
+ }
}
}
}
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/ripple/DefaultRippleEffect.kt b/ui/ui-material/src/main/java/androidx/ui/material/ripple/DefaultRippleEffect.kt
index 20b689e..0318a14 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/ripple/DefaultRippleEffect.kt
+++ b/ui/ui-material/src/main/java/androidx/ui/material/ripple/DefaultRippleEffect.kt
@@ -239,7 +239,7 @@
* surface it belongs to.
*/
internal fun getRippleStartRadius(size: PxSize) =
- max(size.width.value, size.height.value) * 0.3f
+ max(size.width, size.height) * 0.3f
/**
* According to specs the ending radius
@@ -247,7 +247,8 @@
* - fits within the border of the surface it belongs to for unbounded ripples
*/
internal fun Density.getRippleEndRadius(bounded: Boolean, size: PxSize): Float {
- val radiusCoveringBounds = (PxPosition(size.width, size.height).getDistance() / 2f).value
+ val radiusCoveringBounds =
+ (PxPosition(size.width, size.height).getDistance() / 2f).value
return if (bounded) {
radiusCoveringBounds + BoundedRippleExtraRadius.toPx()
} else {
diff --git a/ui/ui-test/api/0.1.0-dev14.txt b/ui/ui-test/api/0.1.0-dev14.txt
index 5a16901..3b20f975 100644
--- a/ui/ui-test/api/0.1.0-dev14.txt
+++ b/ui/ui-test/api/0.1.0-dev14.txt
@@ -55,8 +55,8 @@
method public static void assertPixels(android.graphics.Bitmap, androidx.ui.unit.IntPxSize? expectedSize = null, kotlin.jvm.functions.Function1<? super androidx.ui.unit.IntPxPosition,androidx.ui.graphics.Color> expectedColorProvider);
method public static void assertShape--mmofgM(android.graphics.Bitmap, androidx.ui.unit.Density density, float horizontalPadding, float verticalPadding, long backgroundColor, long shapeColor, androidx.ui.graphics.Shape shape = androidx.ui.graphics.RectangleShapeKt.RectangleShape, float shapeOverlapPixelCount = 1.0f);
method public static void assertShape-t2RoSCg(android.graphics.Bitmap, androidx.ui.unit.Density density, androidx.ui.graphics.Shape shape, long shapeColor, long backgroundColor, androidx.ui.graphics.Shape backgroundShape = androidx.ui.graphics.RectangleShapeKt.RectangleShape, float sizeX = width.toFloat(), float sizeY = height.toFloat(), float shapeSizeX = sizeX, float shapeSizeY = sizeY, float centerX = width / 2.0, float centerY = height / 2.0, float shapeOverlapPixelCount = 1.0f);
- method @RequiresApi(android.os.Build.VERSION_CODES.O) public static android.graphics.Bitmap captureToBitmap(androidx.ui.test.SemanticsNodeInteraction);
- method @RequiresApi(android.os.Build.VERSION_CODES.O) public static android.graphics.Bitmap captureToBitmap(android.view.View);
+ method public static android.graphics.Bitmap captureToBitmap(androidx.ui.test.SemanticsNodeInteraction);
+ method public static android.graphics.Bitmap captureToBitmap(android.view.View);
method public static boolean contains-m3TnucA(androidx.ui.graphics.Path, long offset);
}
@@ -123,7 +123,6 @@
}
public interface ComposeTestRule extends org.junit.rules.TestRule {
- method @RequiresApi(android.os.Build.VERSION_CODES.O) public android.graphics.Bitmap captureScreenOnIdle();
method public androidx.ui.test.ComposeTestCaseSetup forGivenContent(kotlin.jvm.functions.Function0<kotlin.Unit> composable);
method public androidx.ui.test.ComposeTestCaseSetup forGivenTestCase(androidx.ui.test.ComposeTestCase testCase);
method public androidx.ui.test.AnimationClockTestRule getClockTestRule();
@@ -343,7 +342,6 @@
public final class AndroidComposeTestRule<T extends androidx.activity.ComponentActivity> implements androidx.ui.test.ComposeTestRule {
ctor public AndroidComposeTestRule(androidx.test.rule.ActivityTestRule<T> activityTestRule, androidx.compose.Recomposer? recomposer, boolean disableTransitions);
method public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description? description);
- method @RequiresApi(android.os.Build.VERSION_CODES.O) public android.graphics.Bitmap captureScreenOnIdle();
method public androidx.ui.test.ComposeTestCaseSetup forGivenContent(kotlin.jvm.functions.Function0<kotlin.Unit> composable);
method public androidx.ui.test.ComposeTestCaseSetup forGivenTestCase(androidx.ui.test.ComposeTestCase testCase);
method public androidx.test.rule.ActivityTestRule<T> getActivityTestRule();
diff --git a/ui/ui-test/api/current.txt b/ui/ui-test/api/current.txt
index 5a16901..3b20f975 100644
--- a/ui/ui-test/api/current.txt
+++ b/ui/ui-test/api/current.txt
@@ -55,8 +55,8 @@
method public static void assertPixels(android.graphics.Bitmap, androidx.ui.unit.IntPxSize? expectedSize = null, kotlin.jvm.functions.Function1<? super androidx.ui.unit.IntPxPosition,androidx.ui.graphics.Color> expectedColorProvider);
method public static void assertShape--mmofgM(android.graphics.Bitmap, androidx.ui.unit.Density density, float horizontalPadding, float verticalPadding, long backgroundColor, long shapeColor, androidx.ui.graphics.Shape shape = androidx.ui.graphics.RectangleShapeKt.RectangleShape, float shapeOverlapPixelCount = 1.0f);
method public static void assertShape-t2RoSCg(android.graphics.Bitmap, androidx.ui.unit.Density density, androidx.ui.graphics.Shape shape, long shapeColor, long backgroundColor, androidx.ui.graphics.Shape backgroundShape = androidx.ui.graphics.RectangleShapeKt.RectangleShape, float sizeX = width.toFloat(), float sizeY = height.toFloat(), float shapeSizeX = sizeX, float shapeSizeY = sizeY, float centerX = width / 2.0, float centerY = height / 2.0, float shapeOverlapPixelCount = 1.0f);
- method @RequiresApi(android.os.Build.VERSION_CODES.O) public static android.graphics.Bitmap captureToBitmap(androidx.ui.test.SemanticsNodeInteraction);
- method @RequiresApi(android.os.Build.VERSION_CODES.O) public static android.graphics.Bitmap captureToBitmap(android.view.View);
+ method public static android.graphics.Bitmap captureToBitmap(androidx.ui.test.SemanticsNodeInteraction);
+ method public static android.graphics.Bitmap captureToBitmap(android.view.View);
method public static boolean contains-m3TnucA(androidx.ui.graphics.Path, long offset);
}
@@ -123,7 +123,6 @@
}
public interface ComposeTestRule extends org.junit.rules.TestRule {
- method @RequiresApi(android.os.Build.VERSION_CODES.O) public android.graphics.Bitmap captureScreenOnIdle();
method public androidx.ui.test.ComposeTestCaseSetup forGivenContent(kotlin.jvm.functions.Function0<kotlin.Unit> composable);
method public androidx.ui.test.ComposeTestCaseSetup forGivenTestCase(androidx.ui.test.ComposeTestCase testCase);
method public androidx.ui.test.AnimationClockTestRule getClockTestRule();
@@ -343,7 +342,6 @@
public final class AndroidComposeTestRule<T extends androidx.activity.ComponentActivity> implements androidx.ui.test.ComposeTestRule {
ctor public AndroidComposeTestRule(androidx.test.rule.ActivityTestRule<T> activityTestRule, androidx.compose.Recomposer? recomposer, boolean disableTransitions);
method public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description? description);
- method @RequiresApi(android.os.Build.VERSION_CODES.O) public android.graphics.Bitmap captureScreenOnIdle();
method public androidx.ui.test.ComposeTestCaseSetup forGivenContent(kotlin.jvm.functions.Function0<kotlin.Unit> composable);
method public androidx.ui.test.ComposeTestCaseSetup forGivenTestCase(androidx.ui.test.ComposeTestCase testCase);
method public androidx.test.rule.ActivityTestRule<T> getActivityTestRule();
diff --git a/ui/ui-test/api/public_plus_experimental_0.1.0-dev14.txt b/ui/ui-test/api/public_plus_experimental_0.1.0-dev14.txt
index 5a16901..3b20f975 100644
--- a/ui/ui-test/api/public_plus_experimental_0.1.0-dev14.txt
+++ b/ui/ui-test/api/public_plus_experimental_0.1.0-dev14.txt
@@ -55,8 +55,8 @@
method public static void assertPixels(android.graphics.Bitmap, androidx.ui.unit.IntPxSize? expectedSize = null, kotlin.jvm.functions.Function1<? super androidx.ui.unit.IntPxPosition,androidx.ui.graphics.Color> expectedColorProvider);
method public static void assertShape--mmofgM(android.graphics.Bitmap, androidx.ui.unit.Density density, float horizontalPadding, float verticalPadding, long backgroundColor, long shapeColor, androidx.ui.graphics.Shape shape = androidx.ui.graphics.RectangleShapeKt.RectangleShape, float shapeOverlapPixelCount = 1.0f);
method public static void assertShape-t2RoSCg(android.graphics.Bitmap, androidx.ui.unit.Density density, androidx.ui.graphics.Shape shape, long shapeColor, long backgroundColor, androidx.ui.graphics.Shape backgroundShape = androidx.ui.graphics.RectangleShapeKt.RectangleShape, float sizeX = width.toFloat(), float sizeY = height.toFloat(), float shapeSizeX = sizeX, float shapeSizeY = sizeY, float centerX = width / 2.0, float centerY = height / 2.0, float shapeOverlapPixelCount = 1.0f);
- method @RequiresApi(android.os.Build.VERSION_CODES.O) public static android.graphics.Bitmap captureToBitmap(androidx.ui.test.SemanticsNodeInteraction);
- method @RequiresApi(android.os.Build.VERSION_CODES.O) public static android.graphics.Bitmap captureToBitmap(android.view.View);
+ method public static android.graphics.Bitmap captureToBitmap(androidx.ui.test.SemanticsNodeInteraction);
+ method public static android.graphics.Bitmap captureToBitmap(android.view.View);
method public static boolean contains-m3TnucA(androidx.ui.graphics.Path, long offset);
}
@@ -123,7 +123,6 @@
}
public interface ComposeTestRule extends org.junit.rules.TestRule {
- method @RequiresApi(android.os.Build.VERSION_CODES.O) public android.graphics.Bitmap captureScreenOnIdle();
method public androidx.ui.test.ComposeTestCaseSetup forGivenContent(kotlin.jvm.functions.Function0<kotlin.Unit> composable);
method public androidx.ui.test.ComposeTestCaseSetup forGivenTestCase(androidx.ui.test.ComposeTestCase testCase);
method public androidx.ui.test.AnimationClockTestRule getClockTestRule();
@@ -343,7 +342,6 @@
public final class AndroidComposeTestRule<T extends androidx.activity.ComponentActivity> implements androidx.ui.test.ComposeTestRule {
ctor public AndroidComposeTestRule(androidx.test.rule.ActivityTestRule<T> activityTestRule, androidx.compose.Recomposer? recomposer, boolean disableTransitions);
method public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description? description);
- method @RequiresApi(android.os.Build.VERSION_CODES.O) public android.graphics.Bitmap captureScreenOnIdle();
method public androidx.ui.test.ComposeTestCaseSetup forGivenContent(kotlin.jvm.functions.Function0<kotlin.Unit> composable);
method public androidx.ui.test.ComposeTestCaseSetup forGivenTestCase(androidx.ui.test.ComposeTestCase testCase);
method public androidx.test.rule.ActivityTestRule<T> getActivityTestRule();
diff --git a/ui/ui-test/api/public_plus_experimental_current.txt b/ui/ui-test/api/public_plus_experimental_current.txt
index 5a16901..3b20f975 100644
--- a/ui/ui-test/api/public_plus_experimental_current.txt
+++ b/ui/ui-test/api/public_plus_experimental_current.txt
@@ -55,8 +55,8 @@
method public static void assertPixels(android.graphics.Bitmap, androidx.ui.unit.IntPxSize? expectedSize = null, kotlin.jvm.functions.Function1<? super androidx.ui.unit.IntPxPosition,androidx.ui.graphics.Color> expectedColorProvider);
method public static void assertShape--mmofgM(android.graphics.Bitmap, androidx.ui.unit.Density density, float horizontalPadding, float verticalPadding, long backgroundColor, long shapeColor, androidx.ui.graphics.Shape shape = androidx.ui.graphics.RectangleShapeKt.RectangleShape, float shapeOverlapPixelCount = 1.0f);
method public static void assertShape-t2RoSCg(android.graphics.Bitmap, androidx.ui.unit.Density density, androidx.ui.graphics.Shape shape, long shapeColor, long backgroundColor, androidx.ui.graphics.Shape backgroundShape = androidx.ui.graphics.RectangleShapeKt.RectangleShape, float sizeX = width.toFloat(), float sizeY = height.toFloat(), float shapeSizeX = sizeX, float shapeSizeY = sizeY, float centerX = width / 2.0, float centerY = height / 2.0, float shapeOverlapPixelCount = 1.0f);
- method @RequiresApi(android.os.Build.VERSION_CODES.O) public static android.graphics.Bitmap captureToBitmap(androidx.ui.test.SemanticsNodeInteraction);
- method @RequiresApi(android.os.Build.VERSION_CODES.O) public static android.graphics.Bitmap captureToBitmap(android.view.View);
+ method public static android.graphics.Bitmap captureToBitmap(androidx.ui.test.SemanticsNodeInteraction);
+ method public static android.graphics.Bitmap captureToBitmap(android.view.View);
method public static boolean contains-m3TnucA(androidx.ui.graphics.Path, long offset);
}
@@ -123,7 +123,6 @@
}
public interface ComposeTestRule extends org.junit.rules.TestRule {
- method @RequiresApi(android.os.Build.VERSION_CODES.O) public android.graphics.Bitmap captureScreenOnIdle();
method public androidx.ui.test.ComposeTestCaseSetup forGivenContent(kotlin.jvm.functions.Function0<kotlin.Unit> composable);
method public androidx.ui.test.ComposeTestCaseSetup forGivenTestCase(androidx.ui.test.ComposeTestCase testCase);
method public androidx.ui.test.AnimationClockTestRule getClockTestRule();
@@ -343,7 +342,6 @@
public final class AndroidComposeTestRule<T extends androidx.activity.ComponentActivity> implements androidx.ui.test.ComposeTestRule {
ctor public AndroidComposeTestRule(androidx.test.rule.ActivityTestRule<T> activityTestRule, androidx.compose.Recomposer? recomposer, boolean disableTransitions);
method public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description? description);
- method @RequiresApi(android.os.Build.VERSION_CODES.O) public android.graphics.Bitmap captureScreenOnIdle();
method public androidx.ui.test.ComposeTestCaseSetup forGivenContent(kotlin.jvm.functions.Function0<kotlin.Unit> composable);
method public androidx.ui.test.ComposeTestCaseSetup forGivenTestCase(androidx.ui.test.ComposeTestCase testCase);
method public androidx.test.rule.ActivityTestRule<T> getActivityTestRule();
diff --git a/ui/ui-test/api/restricted_0.1.0-dev14.txt b/ui/ui-test/api/restricted_0.1.0-dev14.txt
index 5a16901..3b20f975 100644
--- a/ui/ui-test/api/restricted_0.1.0-dev14.txt
+++ b/ui/ui-test/api/restricted_0.1.0-dev14.txt
@@ -55,8 +55,8 @@
method public static void assertPixels(android.graphics.Bitmap, androidx.ui.unit.IntPxSize? expectedSize = null, kotlin.jvm.functions.Function1<? super androidx.ui.unit.IntPxPosition,androidx.ui.graphics.Color> expectedColorProvider);
method public static void assertShape--mmofgM(android.graphics.Bitmap, androidx.ui.unit.Density density, float horizontalPadding, float verticalPadding, long backgroundColor, long shapeColor, androidx.ui.graphics.Shape shape = androidx.ui.graphics.RectangleShapeKt.RectangleShape, float shapeOverlapPixelCount = 1.0f);
method public static void assertShape-t2RoSCg(android.graphics.Bitmap, androidx.ui.unit.Density density, androidx.ui.graphics.Shape shape, long shapeColor, long backgroundColor, androidx.ui.graphics.Shape backgroundShape = androidx.ui.graphics.RectangleShapeKt.RectangleShape, float sizeX = width.toFloat(), float sizeY = height.toFloat(), float shapeSizeX = sizeX, float shapeSizeY = sizeY, float centerX = width / 2.0, float centerY = height / 2.0, float shapeOverlapPixelCount = 1.0f);
- method @RequiresApi(android.os.Build.VERSION_CODES.O) public static android.graphics.Bitmap captureToBitmap(androidx.ui.test.SemanticsNodeInteraction);
- method @RequiresApi(android.os.Build.VERSION_CODES.O) public static android.graphics.Bitmap captureToBitmap(android.view.View);
+ method public static android.graphics.Bitmap captureToBitmap(androidx.ui.test.SemanticsNodeInteraction);
+ method public static android.graphics.Bitmap captureToBitmap(android.view.View);
method public static boolean contains-m3TnucA(androidx.ui.graphics.Path, long offset);
}
@@ -123,7 +123,6 @@
}
public interface ComposeTestRule extends org.junit.rules.TestRule {
- method @RequiresApi(android.os.Build.VERSION_CODES.O) public android.graphics.Bitmap captureScreenOnIdle();
method public androidx.ui.test.ComposeTestCaseSetup forGivenContent(kotlin.jvm.functions.Function0<kotlin.Unit> composable);
method public androidx.ui.test.ComposeTestCaseSetup forGivenTestCase(androidx.ui.test.ComposeTestCase testCase);
method public androidx.ui.test.AnimationClockTestRule getClockTestRule();
@@ -343,7 +342,6 @@
public final class AndroidComposeTestRule<T extends androidx.activity.ComponentActivity> implements androidx.ui.test.ComposeTestRule {
ctor public AndroidComposeTestRule(androidx.test.rule.ActivityTestRule<T> activityTestRule, androidx.compose.Recomposer? recomposer, boolean disableTransitions);
method public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description? description);
- method @RequiresApi(android.os.Build.VERSION_CODES.O) public android.graphics.Bitmap captureScreenOnIdle();
method public androidx.ui.test.ComposeTestCaseSetup forGivenContent(kotlin.jvm.functions.Function0<kotlin.Unit> composable);
method public androidx.ui.test.ComposeTestCaseSetup forGivenTestCase(androidx.ui.test.ComposeTestCase testCase);
method public androidx.test.rule.ActivityTestRule<T> getActivityTestRule();
diff --git a/ui/ui-test/api/restricted_current.txt b/ui/ui-test/api/restricted_current.txt
index 5a16901..3b20f975 100644
--- a/ui/ui-test/api/restricted_current.txt
+++ b/ui/ui-test/api/restricted_current.txt
@@ -55,8 +55,8 @@
method public static void assertPixels(android.graphics.Bitmap, androidx.ui.unit.IntPxSize? expectedSize = null, kotlin.jvm.functions.Function1<? super androidx.ui.unit.IntPxPosition,androidx.ui.graphics.Color> expectedColorProvider);
method public static void assertShape--mmofgM(android.graphics.Bitmap, androidx.ui.unit.Density density, float horizontalPadding, float verticalPadding, long backgroundColor, long shapeColor, androidx.ui.graphics.Shape shape = androidx.ui.graphics.RectangleShapeKt.RectangleShape, float shapeOverlapPixelCount = 1.0f);
method public static void assertShape-t2RoSCg(android.graphics.Bitmap, androidx.ui.unit.Density density, androidx.ui.graphics.Shape shape, long shapeColor, long backgroundColor, androidx.ui.graphics.Shape backgroundShape = androidx.ui.graphics.RectangleShapeKt.RectangleShape, float sizeX = width.toFloat(), float sizeY = height.toFloat(), float shapeSizeX = sizeX, float shapeSizeY = sizeY, float centerX = width / 2.0, float centerY = height / 2.0, float shapeOverlapPixelCount = 1.0f);
- method @RequiresApi(android.os.Build.VERSION_CODES.O) public static android.graphics.Bitmap captureToBitmap(androidx.ui.test.SemanticsNodeInteraction);
- method @RequiresApi(android.os.Build.VERSION_CODES.O) public static android.graphics.Bitmap captureToBitmap(android.view.View);
+ method public static android.graphics.Bitmap captureToBitmap(androidx.ui.test.SemanticsNodeInteraction);
+ method public static android.graphics.Bitmap captureToBitmap(android.view.View);
method public static boolean contains-m3TnucA(androidx.ui.graphics.Path, long offset);
}
@@ -123,7 +123,6 @@
}
public interface ComposeTestRule extends org.junit.rules.TestRule {
- method @RequiresApi(android.os.Build.VERSION_CODES.O) public android.graphics.Bitmap captureScreenOnIdle();
method public androidx.ui.test.ComposeTestCaseSetup forGivenContent(kotlin.jvm.functions.Function0<kotlin.Unit> composable);
method public androidx.ui.test.ComposeTestCaseSetup forGivenTestCase(androidx.ui.test.ComposeTestCase testCase);
method public androidx.ui.test.AnimationClockTestRule getClockTestRule();
@@ -343,7 +342,6 @@
public final class AndroidComposeTestRule<T extends androidx.activity.ComponentActivity> implements androidx.ui.test.ComposeTestRule {
ctor public AndroidComposeTestRule(androidx.test.rule.ActivityTestRule<T> activityTestRule, androidx.compose.Recomposer? recomposer, boolean disableTransitions);
method public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description? description);
- method @RequiresApi(android.os.Build.VERSION_CODES.O) public android.graphics.Bitmap captureScreenOnIdle();
method public androidx.ui.test.ComposeTestCaseSetup forGivenContent(kotlin.jvm.functions.Function0<kotlin.Unit> composable);
method public androidx.ui.test.ComposeTestCaseSetup forGivenTestCase(androidx.ui.test.ComposeTestCase testCase);
method public androidx.test.rule.ActivityTestRule<T> getActivityTestRule();
diff --git a/ui/ui-test/build.gradle b/ui/ui-test/build.gradle
index 4e581cb..a38c164 100644
--- a/ui/ui-test/build.gradle
+++ b/ui/ui-test/build.gradle
@@ -36,6 +36,7 @@
implementation(KOTLIN_STDLIB)
implementation(ANDROIDX_TEST_RULES)
implementation(ANDROIDX_TEST_RUNNER)
+ implementation(ANDROIDX_TEST_UIAUTOMATOR)
implementation(ESPRESSO_CORE)
implementation(JUNIT)
@@ -71,4 +72,4 @@
mavenGroup = LibraryGroups.UI
inceptionYear = "2019"
description = "AndroidX UI test framework."
-}
+}
\ No newline at end of file
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/BitmapCapturingTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/BitmapCapturingTest.kt
index 72b497c..75c4e0b5 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/BitmapCapturingTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/BitmapCapturingTest.kt
@@ -16,9 +16,9 @@
package androidx.ui.test
-import android.os.Build
+import androidx.activity.ComponentActivity
import androidx.test.filters.MediumTest
-import androidx.test.filters.SdkSuppress
+import androidx.test.rule.ActivityTestRule
import androidx.ui.core.Modifier
import androidx.ui.core.testTag
import androidx.ui.foundation.Box
@@ -27,7 +27,10 @@
import androidx.ui.layout.Column
import androidx.ui.layout.Row
import androidx.ui.layout.fillMaxSize
+import androidx.ui.layout.padding
import androidx.ui.layout.preferredSize
+import androidx.ui.test.android.AndroidComposeTestRule
+import androidx.ui.test.gesturescope.ActivityWithActionBar
import androidx.ui.unit.IntPxPosition
import androidx.ui.unit.IntPxSize
import androidx.ui.unit.ipx
@@ -35,15 +38,26 @@
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
-import org.junit.runners.JUnit4
+import org.junit.runners.Parameterized
@MediumTest
-@RunWith(JUnit4::class)
-@SdkSuppress(minSdkVersion = Build.VERSION_CODES.O)
-class BitmapCapturingTest {
+@RunWith(Parameterized::class)
+class BitmapCapturingTest(val config: TestConfig) {
+ data class TestConfig(
+ val activityClass: Class<out ComponentActivity>
+ )
+
+ companion object {
+ @JvmStatic
+ @Parameterized.Parameters(name = "{0}")
+ fun createTestSet(): List<TestConfig> = listOf(
+ TestConfig(ComponentActivity::class.java),
+ TestConfig(ActivityWithActionBar::class.java)
+ )
+ }
@get:Rule
- val composeTestRule = createComposeRule()
+ val composeTestRule = AndroidComposeTestRule(ActivityTestRule(config.activityClass))
private val rootTag = "Root"
private val tag11 = "Rect11"
@@ -101,17 +115,6 @@
}
}
- @Test
- fun captureWholeWindow_checkSizeAndColors() {
- composeCheckerboard()
-
- composeTestRule
- .captureScreenOnIdle()
- .assertPixels() {
- expectedColorProvider(it)
- }
- }
-
@Test(expected = AssertionError::class)
fun assertWrongColor_expectException() {
composeCheckerboard()
@@ -155,30 +158,32 @@
with(composeTestRule.density) {
composeTestRule.setContent {
Box(Modifier.fillMaxSize(), backgroundColor = colorBg) {
- Column(Modifier.testTag(rootTag)) {
- Row {
- Box(Modifier
- .testTag(tag11)
- .preferredSize(100.ipx.toDp(), 50.ipx.toDp())
- .drawBackground(color11)
- )
- Box(Modifier
- .testTag(tag12)
- .preferredSize(100.ipx.toDp(), 50.ipx.toDp())
- .drawBackground(color12)
- )
- }
- Row {
- Box(Modifier
- .testTag(tag21)
- .preferredSize(100.ipx.toDp(), 50.ipx.toDp())
- .drawBackground(color21)
- )
- Box(Modifier
- .testTag(tag22)
- .preferredSize(100.ipx.toDp(), 50.ipx.toDp())
- .drawBackground(color22)
- )
+ Box(Modifier.padding(top = 20.ipx.toDp()), backgroundColor = colorBg) {
+ Column(Modifier.testTag(rootTag)) {
+ Row {
+ Box(Modifier
+ .testTag(tag11)
+ .preferredSize(100.ipx.toDp(), 50.ipx.toDp())
+ .drawBackground(color11)
+ )
+ Box(Modifier
+ .testTag(tag12)
+ .preferredSize(100.ipx.toDp(), 50.ipx.toDp())
+ .drawBackground(color12)
+ )
+ }
+ Row {
+ Box(Modifier
+ .testTag(tag21)
+ .preferredSize(100.ipx.toDp(), 50.ipx.toDp())
+ .drawBackground(color21)
+ )
+ Box(Modifier
+ .testTag(tag22)
+ .preferredSize(100.ipx.toDp(), 50.ipx.toDp())
+ .drawBackground(color22)
+ )
+ }
}
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/LayoutCoordinatesHelperTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/LayoutCoordinatesHelperTest.kt
index ac1cf65..65a8f4a 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/LayoutCoordinatesHelperTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/LayoutCoordinatesHelperTest.kt
@@ -30,7 +30,6 @@
import androidx.ui.unit.PxPosition
import androidx.ui.unit.dp
import androidx.ui.unit.ipx
-import androidx.ui.unit.px
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Rule
@@ -105,7 +104,7 @@
assertTrue(latch.await(1, TimeUnit.SECONDS))
assertEquals(
- PxPosition(5.px, 0.px),
+ PxPosition(5f, 0f),
parentCoordinates!!.childToLocal(childCoordinates!!, PxPosition.Origin)
)
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/ScrollToTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/ScrollToTest.kt
index d5c0c56..d59a833 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/ScrollToTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/ScrollToTest.kt
@@ -86,8 +86,8 @@
Box(Modifier.semantics {
ScrollTo(action = { x, y ->
- currentScrollPositionY = y.value
- currentScrollPositionX = x.value
+ currentScrollPositionY = y
+ currentScrollPositionX = x
return@ScrollTo true
})
}) {
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendClickTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendClickTest.kt
index 149cac1..fe87394 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendClickTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendClickTest.kt
@@ -49,7 +49,7 @@
private const val numberOfSquares = 5
private const val first = 0
private const val last = numberOfSquares - 1
-private val squareSize = 10.0f
+private const val squareSize = 10.0f
private val center = PxPosition(squareSize / 2, squareSize / 2)
private val colors = listOf(Color.Red, Color.Yellow, Color.Blue, Color.Green, Color.Cyan)
@@ -145,11 +145,11 @@
val recordedClicks = mutableListOf<ClickData>()
composeTestRule.setContent(recordedClicks)
- // When I click each of the components
+ // When I click the first and last of these components
findByTag("$tag$first").doGesture { sendClick() }
findByTag("$tag$last").doGesture { sendClick() }
- // Then each component has registered a click
+ // Then those components have registered a click
runOnIdleCompose {
assertThat(recordedClicks).isEqualTo(
listOf(
@@ -196,11 +196,11 @@
val recordedClicks = mutableListOf<ClickData>()
composeTestRule.setContent(recordedClicks)
- // When I click each of the components
+ // When I click the first and last of these components
findByTag("$tag$first").doGesture { sendClick(config.position) }
findByTag("$tag$last").doGesture { sendClick(config.position) }
- // Then each component has registered a click
+ // Then those components have registered a click
runOnIdleCompose {
assertThat(recordedClicks).isEqualTo(
listOf(
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendDoubleClickTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendDoubleClickTest.kt
index a7c701d..25ce7fa 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendDoubleClickTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendDoubleClickTest.kt
@@ -26,10 +26,9 @@
import androidx.ui.test.runOnIdleCompose
import androidx.ui.test.sendDoubleClick
import androidx.ui.test.util.ClickableTestBox
-import androidx.ui.test.util.PointerInputRecorder
-import androidx.ui.test.util.assertTimestampsAreIncreasing
+import androidx.ui.test.util.ClickableTestBox.defaultSize
+import androidx.ui.test.util.ClickableTestBox.defaultTag
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.milliseconds
import com.google.common.truth.Truth.assertThat
import org.junit.Rule
import org.junit.Test
@@ -37,11 +36,6 @@
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
-private val width = 200.0f
-private val height = 200.0f
-private val expectedDelay = 145.milliseconds
-private const val tag = "widget"
-
@MediumTest
class SendDoubleClickWithoutArgumentsTest {
@@ -53,9 +47,8 @@
disableDispatchInRealTime = true
)
- private lateinit var recorder: PointerInputRecorder
private val recordedDoubleClicks = mutableListOf<PxPosition>()
- private val expectedClickPosition = PxPosition(width / 2, height / 2)
+ private val expectedClickPosition = PxPosition(defaultSize / 2, defaultSize / 2)
private fun recordDoubleClick(position: PxPosition) {
recordedDoubleClicks.add(position)
@@ -64,37 +57,16 @@
@Test
fun testDoubleClick() {
// Given some content
- recorder = PointerInputRecorder()
composeTestRule.setContent {
- ClickableTestBox(
- Modifier.doubleTapGestureFilter(this::recordDoubleClick).plus(recorder),
- width = width,
- height = height,
- tag = tag
- )
+ ClickableTestBox(Modifier.doubleTapGestureFilter(this::recordDoubleClick))
}
// When we inject a double click
- findByTag(tag).doGesture { sendDoubleClick() }
+ findByTag(defaultTag).doGesture { sendDoubleClick() }
runOnIdleCompose {
- // Then we record 1 double click
- assertThat(recordedDoubleClicks).hasSize(1)
- // at the expected position
- assertThat(recordedDoubleClicks.first()).isEqualTo(expectedClickPosition)
- recorder.run {
- // and with events for two clicks with an expectedDelay between them
- assertTimestampsAreIncreasing()
- assertThat(events).hasSize(4)
- assertThat(events[0].down).isTrue() // down (first click)
- assertThat(events[1].down).isFalse() // up (first click)
- assertThat(events[2].down).isTrue() // down (second click)
- assertThat(events[3].down).isFalse() // up (second click)
- assertThat(events[2].timestamp - events[1].timestamp).isEqualTo(expectedDelay)
- events.forEach {
- assertThat(it.position).isEqualTo(expectedClickPosition)
- }
- }
+ // Then we record 1 double click at the expected position
+ assertThat(recordedDoubleClicks).isEqualTo(listOf(expectedClickPosition))
}
}
}
@@ -126,7 +98,6 @@
disableDispatchInRealTime = true
)
- private val recorder = PointerInputRecorder()
private val recordedDoubleClicks = mutableListOf<PxPosition>()
private val expectedClickPosition = config.position
@@ -138,35 +109,15 @@
fun testDoubleClickOnPosition() {
// Given some content
composeTestRule.setContent {
- ClickableTestBox(
- Modifier.doubleTapGestureFilter(this::recordDoubleClick).plus(recorder),
- width = width,
- height = height,
- tag = tag
- )
+ ClickableTestBox(Modifier.doubleTapGestureFilter(this::recordDoubleClick))
}
// When we inject a double click
- findByTag(tag).doGesture { sendDoubleClick(config.position) }
+ findByTag(defaultTag).doGesture { sendDoubleClick(config.position) }
runOnIdleCompose {
- // Then we record 1 double click
- assertThat(recordedDoubleClicks).hasSize(1)
- // at the expected position
- assertThat(recordedDoubleClicks.first()).isEqualTo(expectedClickPosition)
- recorder.run {
- // and with events for two clicks with an expectedDelay between them
- assertTimestampsAreIncreasing()
- assertThat(events).hasSize(4)
- assertThat(events[0].down).isTrue() // down (first click)
- assertThat(events[1].down).isFalse() // up (first click)
- assertThat(events[2].down).isTrue() // down (second click)
- assertThat(events[3].down).isFalse() // up (second click)
- assertThat(events[2].timestamp - events[1].timestamp).isEqualTo(expectedDelay)
- events.forEach {
- assertThat(it.position).isEqualTo(expectedClickPosition)
- }
- }
+ // Then we record 1 double click at the expected position
+ assertThat(recordedDoubleClicks).isEqualTo(listOf(expectedClickPosition))
}
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendLongClickTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendLongClickTest.kt
index 6f0377e..9843083 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendLongClickTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendLongClickTest.kt
@@ -19,7 +19,6 @@
import androidx.test.filters.MediumTest
import androidx.ui.core.Alignment
import androidx.ui.core.Modifier
-import androidx.ui.core.gesture.LongPressTimeout
import androidx.ui.core.gesture.longPressGestureFilter
import androidx.ui.layout.Stack
import androidx.ui.layout.fillMaxSize
@@ -27,16 +26,12 @@
import androidx.ui.test.createComposeRule
import androidx.ui.test.doGesture
import androidx.ui.test.findByTag
-import androidx.ui.test.runOnIdleCompose
import androidx.ui.test.sendLongClick
import androidx.ui.test.util.ClickableTestBox
-import androidx.ui.test.util.PointerInputRecorder
-import androidx.ui.test.util.areAlmostEqualTo
-import androidx.ui.test.util.assertOnlyLastEventIsUp
-import androidx.ui.test.util.assertTimestampsAreIncreasing
-import androidx.ui.test.util.recordedDuration
+import androidx.ui.test.util.ClickableTestBox.defaultSize
+import androidx.ui.test.util.ClickableTestBox.defaultTag
+import androidx.ui.test.util.isAlmostEqualTo
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.milliseconds
import com.google.common.truth.Truth.assertThat
import org.junit.Rule
import org.junit.Test
@@ -44,11 +39,6 @@
import org.junit.runners.JUnit4
import org.junit.runners.Parameterized
-private const val tag = "widget"
-private val width = 100.0f
-private val height = 100.0f
-private val expectedDuration = LongPressTimeout + 100.milliseconds
-
/**
* Tests [sendLongClick] without arguments. Verifies that the click is in the middle
* of the component, that the gesture has a duration of 600 milliseconds and that all input
@@ -61,9 +51,8 @@
@get:Rule
val composeTestRule = createComposeRule(disableTransitions = true)
- private val recorder = PointerInputRecorder()
private val recordedLongClicks = mutableListOf<PxPosition>()
- private val expectedPosition = PxPosition(width / 2, height / 2)
+ private val expectedPosition = PxPosition(defaultSize / 2, defaultSize / 2)
private fun recordLongPress(position: PxPosition) {
recordedLongClicks.add(position)
@@ -74,30 +63,15 @@
// Given some content
composeTestRule.setContent {
Stack(Modifier.fillMaxSize().wrapContentSize(Alignment.BottomEnd)) {
- ClickableTestBox(
- modifier = Modifier.longPressGestureFilter(::recordLongPress).plus(recorder),
- width = width,
- height = height,
- tag = tag
- )
+ ClickableTestBox(Modifier.longPressGestureFilter(::recordLongPress))
}
}
// When we inject a long click
- findByTag(tag).doGesture { sendLongClick() }
+ findByTag(defaultTag).doGesture { sendLongClick() }
- // Then we record 1 long click
- assertThat(recordedLongClicks).hasSize(1)
-
- // And all events are at the click location
- runOnIdleCompose {
- recorder.run {
- assertTimestampsAreIncreasing()
- assertOnlyLastEventIsUp()
- events.areAlmostEqualTo(expectedPosition)
- assertThat(recordedDuration).isEqualTo(expectedDuration)
- }
- }
+ // Then we record 1 long click at the expected position
+ assertThat(recordedLongClicks).isEqualTo(listOf(expectedPosition))
}
}
@@ -118,8 +92,8 @@
@Parameterized.Parameters(name = "{0}")
fun createTestSet(): List<TestConfig> {
return mutableListOf<TestConfig>().apply {
- for (x in listOf(1.0f, width / 4)) {
- for (y in listOf(1.0f, height / 4)) {
+ for (x in listOf(1.0f, defaultSize / 4)) {
+ for (y in listOf(1.0f, defaultSize / 3)) {
add(TestConfig(PxPosition(x, y)))
}
}
@@ -130,7 +104,6 @@
@get:Rule
val composeTestRule = createComposeRule(disableTransitions = true)
- private val recorder = PointerInputRecorder()
private val recordedLongClicks = mutableListOf<PxPosition>()
private fun recordLongPress(position: PxPosition) {
@@ -142,29 +115,15 @@
// Given some content
composeTestRule.setContent {
Stack(Modifier.fillMaxSize().wrapContentSize(Alignment.BottomEnd)) {
- ClickableTestBox(
- modifier = Modifier.longPressGestureFilter(::recordLongPress).plus(recorder),
- width = width,
- height = height,
- tag = tag
- )
+ ClickableTestBox(Modifier.longPressGestureFilter(::recordLongPress))
}
}
// When we inject a long click
- findByTag(tag).doGesture { sendLongClick(config.position) }
+ findByTag(defaultTag).doGesture { sendLongClick(config.position) }
- // Then we record 1 long click
+ // Then we record 1 long click at the expected position
assertThat(recordedLongClicks).hasSize(1)
-
- // And all events are at the click location
- runOnIdleCompose {
- recorder.run {
- assertTimestampsAreIncreasing()
- assertOnlyLastEventIsUp()
- events.areAlmostEqualTo(config.position)
- assertThat(recordedDuration).isEqualTo(expectedDuration)
- }
- }
+ recordedLongClicks[0].isAlmostEqualTo(config.position)
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendPinchTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendPinchTest.kt
index 06068d2..d3900f7 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendPinchTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendPinchTest.kt
@@ -33,7 +33,6 @@
import androidx.ui.unit.PxPosition
import androidx.ui.unit.inMilliseconds
import androidx.ui.unit.milliseconds
-import androidx.ui.unit.px
import com.google.common.truth.Truth.assertThat
import org.junit.Rule
import org.junit.Test
@@ -41,11 +40,13 @@
import org.junit.runners.JUnit4
import kotlin.math.max
-private const val TAG = "PINCH"
-
@MediumTest
@RunWith(JUnit4::class)
class SendPinchTest {
+ companion object {
+ private const val TAG = "PINCH"
+ }
+
@get:Rule
val composeTestRule = createComposeRule(disableTransitions = true)
@@ -60,10 +61,10 @@
}
}
- val start0 = PxPosition(40.px, 50.px)
- val end0 = PxPosition(8.px, 50.px)
- val start1 = PxPosition(60.px, 50.px)
- val end1 = PxPosition(92.px, 50.px)
+ val start0 = PxPosition(40f, 50f)
+ val end0 = PxPosition(8f, 50f)
+ val start1 = PxPosition(60f, 50f)
+ val end1 = PxPosition(92f, 50f)
val duration = 400.milliseconds
findByTag(TAG).doGesture {
@@ -94,4 +95,4 @@
}
}
}
-}
\ No newline at end of file
+}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendSwipeTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendSwipeTest.kt
index c701ed9..3b77635 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendSwipeTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendSwipeTest.kt
@@ -45,8 +45,9 @@
@MediumTest
@RunWith(JUnit4::class)
class SendSwipeTest {
-
- private val tag = "widget"
+ companion object {
+ private const val tag = "widget"
+ }
@get:Rule
val composeTestRule = createComposeRule(disableTransitions = true)
@@ -119,7 +120,7 @@
// Last event must be above first event
assertThat(events.last().position.y).isLessThan(events.first().position.y)
// All events in between only move up
- events.map { it.position.x.value }.assertSame(tolerance = 0.001f)
+ events.map { it.position.x }.assertSame(tolerance = 0.001f)
events.map { it.position.y }.assertDecreasing()
}
@@ -129,7 +130,7 @@
// Last event must be below first event
assertThat(events.last().position.y).isGreaterThan(events.first().position.y)
// All events in between only move down
- events.map { it.position.x.value }.assertSame(tolerance = 0.001f)
+ events.map { it.position.x }.assertSame(tolerance = 0.001f)
events.map { it.position.y }.assertIncreasing()
}
@@ -140,7 +141,7 @@
assertThat(events.last().position.x).isLessThan(events.first().position.x)
// All events in between only move to the left
events.map { it.position.x }.assertDecreasing()
- events.map { it.position.y.value }.assertSame(tolerance = 0.001f)
+ events.map { it.position.y }.assertSame(tolerance = 0.001f)
}
private fun PointerInputRecorder.assertSwipeIsRight() {
@@ -150,7 +151,7 @@
assertThat(events.last().position.x).isGreaterThan(events.first().position.x)
// All events in between only move to the right
events.map { it.position.x }.assertIncreasing()
- events.map { it.position.y.value }.assertSame(tolerance = 0.001f)
+ events.map { it.position.y }.assertSame(tolerance = 0.001f)
}
private fun List<Float>.assertSame(tolerance: Float = 0f) {
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendSwipeVelocityTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendSwipeVelocityTest.kt
index 1ce3782..9474a88 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendSwipeVelocityTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendSwipeVelocityTest.kt
@@ -159,8 +159,8 @@
// Check velocity
val actualVelocity = recordedVelocity.pixelsPerSecond
- assertThat(actualVelocity.x.value).isWithin(.1f).of(expectedXVelocity)
- assertThat(actualVelocity.y.value).isWithin(.1f).of(expectedYVelocity)
+ assertThat(actualVelocity.x).isWithin(.1f).of(expectedXVelocity)
+ assertThat(actualVelocity.y).isWithin(.1f).of(expectedYVelocity)
assertThat(actualVelocity.getDistance().value)
.isWithin(velocity * 0.001f).of(velocity)
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/DelayTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/DelayTest.kt
index 98fa9b7..ae462b3 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/DelayTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/DelayTest.kt
@@ -34,8 +34,6 @@
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
-private val anyPosition = PxPosition.Origin
-
/**
* Tests if [AndroidInputDispatcher.delay] works by performing three gestures with a delay in
* between them. By varying the gestures and the delay, we test for lingering state problems.
@@ -53,7 +51,7 @@
enum class Gesture(internal val function: (InputDispatcher) -> Unit) {
Click({ it.sendClick(anyPosition) }),
- Swipe({ it.sendSwipe(anyPosition, anyPosition, 100.milliseconds) }),
+ Swipe({ it.sendSwipe(anyPosition, anyPosition, 107.milliseconds) }),
Partial({
it.sendDown(anyPosition)
it.sendMove(anyPosition)
@@ -62,12 +60,14 @@
}
companion object {
+ private val anyPosition = PxPosition.Origin
+
@JvmStatic
@Parameterized.Parameters(name = "{0}")
fun createTestSet(): List<TestConfig> {
return mutableListOf<TestConfig>().apply {
- for (delay1 in listOf(0, 10, 100)) {
- for (delay2 in listOf(0, 23, 47)) {
+ for (delay1 in listOf(0, 23)) {
+ for (delay2 in listOf(0, 47)) {
for (gesture1 in Gesture.values()) {
for (gesture2 in Gesture.values()) {
for (gesture3 in Gesture.values()) {
@@ -95,11 +95,11 @@
)
private val recorder = MotionEventRecorder()
- private val subject = AndroidInputDispatcher(recorder::sendEvent)
+ private val subject = AndroidInputDispatcher(recorder::recordEvent)
@After
fun tearDown() {
- recorder.clear()
+ recorder.disposeEvents()
}
@Test
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendCancelTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendCancelTest.kt
index 9aca8ae..7eda547 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendCancelTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendCancelTest.kt
@@ -24,7 +24,6 @@
import androidx.ui.test.util.expectError
import androidx.ui.test.util.verify
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.px
import com.google.common.truth.Truth.assertThat
import org.junit.After
import org.junit.Rule
@@ -45,7 +44,7 @@
)
companion object {
- private val downPosition = PxPosition(5.px, 5.px)
+ private val downPosition = PxPosition(5f, 5f)
@JvmStatic
@Parameterized.Parameters(name = "{0}")
@@ -54,7 +53,7 @@
listOf(0f, -10f).map { y ->
TestConfig(x, y)
}
- }.plus(TestConfig(downPosition.x.value, downPosition.y.value))
+ }.plus(TestConfig(downPosition.x, downPosition.y))
}
}
@@ -64,14 +63,14 @@
@get:Rule
val inputDispatcherRule: TestRule = dispatcherRule
- private val position = PxPosition(config.x.px, config.y.px)
+ private val position = PxPosition(config.x, config.y)
private val recorder = MotionEventRecorder()
- private val subject = AndroidInputDispatcher(recorder::sendEvent)
+ private val subject = AndroidInputDispatcher(recorder::recordEvent)
@After
fun tearDown() {
- recorder.clear()
+ recorder.disposeEvents()
}
@Test
@@ -95,8 +94,8 @@
*/
@SmallTest
class SendCancelAfterFinishedTest {
- private val downPosition = PxPosition(5.px, 5.px)
- private val position = PxPosition(1.px, 1.px)
+ private val downPosition = PxPosition(5f, 5f)
+ private val position = PxPosition(1f, 1f)
@get:Rule
val inputDispatcherRule: TestRule = AndroidInputDispatcher.TestRule(
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendClickTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendClickTest.kt
index b4b5c26..c3a199c 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendClickTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendClickTest.kt
@@ -23,7 +23,6 @@
import androidx.ui.test.util.assertHasValidEventTimes
import androidx.ui.test.util.verify
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.px
import com.google.common.truth.Truth.assertThat
import org.junit.After
import org.junit.Rule
@@ -61,14 +60,14 @@
@get:Rule
val inputDispatcherRule: TestRule = dispatcherRule
- private val position = PxPosition(config.x.px, config.y.px)
+ private val position = PxPosition(config.x, config.y)
private val recorder = MotionEventRecorder()
- private val subject = AndroidInputDispatcher(recorder::sendEvent)
+ private val subject = AndroidInputDispatcher(recorder::recordEvent)
@After
fun tearDown() {
- recorder.clear()
+ recorder.disposeEvents()
}
@Test
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendDownTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendDownTest.kt
index c29cb80..3d8a539 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendDownTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendDownTest.kt
@@ -24,7 +24,6 @@
import androidx.ui.test.util.expectError
import androidx.ui.test.util.verify
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.px
import com.google.common.truth.Truth.assertThat
import org.junit.After
import org.junit.Rule
@@ -62,14 +61,14 @@
disableDispatchInRealTime = true
)
- private val position = PxPosition(config.x.px, config.y.px)
+ private val position = PxPosition(config.x, config.y)
private val recorder = MotionEventRecorder()
- private val subject = AndroidInputDispatcher(recorder::sendEvent)
+ private val subject = AndroidInputDispatcher(recorder::recordEvent)
@After
fun tearDown() {
- recorder.clear()
+ recorder.disposeEvents()
}
@Test
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendMoveTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendMoveTest.kt
index a33bbea..bd20abe 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendMoveTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendMoveTest.kt
@@ -24,7 +24,6 @@
import androidx.ui.test.util.expectError
import androidx.ui.test.util.verify
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.px
import com.google.common.truth.Truth.assertThat
import org.junit.After
import org.junit.Rule
@@ -45,7 +44,7 @@
)
companion object {
- private val downPosition = PxPosition(5.px, 5.px)
+ private val downPosition = PxPosition(5f, 5f)
@JvmStatic
@Parameterized.Parameters(name = "{0}")
@@ -54,7 +53,7 @@
listOf(0f, -10f).map { y ->
TestConfig(x, y)
}
- }.plus(TestConfig(downPosition.x.value, downPosition.y.value))
+ }.plus(TestConfig(downPosition.x, downPosition.y))
}
}
@@ -64,14 +63,14 @@
@get:Rule
val inputDispatcherRule: TestRule = dispatcherRule
- private val position = PxPosition(config.x.px, config.y.px)
+ private val position = PxPosition(config.x, config.y)
private val recorder = MotionEventRecorder()
- private val subject = AndroidInputDispatcher(recorder::sendEvent)
+ private val subject = AndroidInputDispatcher(recorder::recordEvent)
@After
fun tearDown() {
- recorder.clear()
+ recorder.disposeEvents()
}
@Test
@@ -95,8 +94,8 @@
*/
@SmallTest
class SendMoveAfterFinishedTest {
- private val downPosition = PxPosition(5.px, 5.px)
- private val position = PxPosition(1.px, 1.px)
+ private val downPosition = PxPosition(5f, 5f)
+ private val position = PxPosition(1f, 1f)
@get:Rule
val inputDispatcherRule: TestRule = AndroidInputDispatcher.TestRule(
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendSwipeFunctionTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendSwipeFunctionTest.kt
index 44ce4c4..676a6a7 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendSwipeFunctionTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendSwipeFunctionTest.kt
@@ -33,7 +33,6 @@
import androidx.ui.unit.PxPosition
import androidx.ui.unit.inMilliseconds
import androidx.ui.unit.milliseconds
-import androidx.ui.unit.px
import com.google.common.truth.Truth.assertThat
import org.junit.After
import org.junit.Before
@@ -45,8 +44,8 @@
private val curve = { t: Long ->
PxPosition(
- t.toFloat().px,
- (-t).toFloat().px
+ t.toFloat(),
+ (-t).toFloat()
)
}
@@ -109,11 +108,11 @@
)
private val recorder = MotionEventRecorder()
- private val subject = AndroidInputDispatcher(recorder::sendEvent)
+ private val subject = AndroidInputDispatcher(recorder::recordEvent)
@After
fun tearDown() {
- recorder.clear()
+ recorder.disposeEvents()
}
@Test
@@ -189,7 +188,7 @@
)
private val recorder = MotionEventRecorder()
- private val subject = AndroidInputDispatcher(recorder::sendEvent)
+ private val subject = AndroidInputDispatcher(recorder::recordEvent)
@Before
fun setUp() {
@@ -200,7 +199,7 @@
@After
fun tearDown() {
- recorder.clear()
+ recorder.disposeEvents()
}
@Test
@@ -258,10 +257,10 @@
// pick a prime number for duration
val durationMs = 101L
// testing all possible keyTimes between 0 and 100 takes way too long,
- // only test all possible keyTimes close to the middle instead
+ // only test several combinations keyTimes close to the middle instead
val firstKeyTime = (durationMs / 2) - eventPeriod
val lastKeyTime = (durationMs / 2) + eventPeriod
- (firstKeyTime..lastKeyTime).flatMap { keyTime1 ->
+ (firstKeyTime..lastKeyTime step eventPeriod).flatMap { keyTime1 ->
(keyTime1..lastKeyTime).map { keyTime2 ->
TestConfig(
Duration(milliseconds = durationMs),
@@ -285,7 +284,7 @@
private val eventPeriod = config.eventPeriod
private val recorder = MotionEventRecorder()
- private val subject = AndroidInputDispatcher(recorder::sendEvent)
+ private val subject = AndroidInputDispatcher(recorder::recordEvent)
@Before
fun setUp() {
@@ -296,7 +295,7 @@
@After
fun tearDown() {
- recorder.clear()
+ recorder.disposeEvents()
}
@Test
@@ -317,8 +316,8 @@
// Check that coordinates are the function's value at the respective timestamps
forEach {
- assertThat(it.x).isEqualTo(curve(it.relativeTime).x.value)
- assertThat(it.y).isEqualTo(curve(it.relativeTime).y.value)
+ assertThat(it.x).isEqualTo(curve(it.relativeTime).x)
+ assertThat(it.y).isEqualTo(curve(it.relativeTime).y)
}
// The given keyTimes must occur as event timestamps
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendSwipeLineTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendSwipeLineTest.kt
index b8c67cf..ffd3ead 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendSwipeLineTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendSwipeLineTest.kt
@@ -25,10 +25,8 @@
import androidx.ui.test.util.moveEvents
import androidx.ui.test.util.splitsDurationEquallyInto
import androidx.ui.test.util.verify
-import androidx.ui.unit.Duration
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.inMilliseconds
-import androidx.ui.unit.px
+import androidx.ui.unit.milliseconds
import com.google.common.truth.Truth.assertThat
import org.junit.After
import org.junit.Rule
@@ -38,9 +36,6 @@
import org.junit.runners.Parameterized
import kotlin.math.max
-private val start = PxPosition(5f.px, 7f.px)
-private val end = PxPosition(23f.px, 29f.px)
-
/**
* Tests if the [AndroidInputDispatcher.sendSwipe] gesture works when specifying the gesture as a
* line between two positions
@@ -49,17 +44,20 @@
@RunWith(Parameterized::class)
class SendSwipeLineTest(private val config: TestConfig) {
data class TestConfig(
- val duration: Duration,
+ val duration: Long,
val eventPeriod: Long
)
companion object {
+ private val start = PxPosition(5f, 7f)
+ private val end = PxPosition(23f, 29f)
+
@JvmStatic
@Parameterized.Parameters(name = "{0}")
fun createTestSet(): List<TestConfig> {
return listOf(10L, 9L, 11L).flatMap { period ->
- (1L..100L).map { durationMs ->
- TestConfig(Duration(milliseconds = durationMs), period)
+ (1L..100L step 11).map { durationMs ->
+ TestConfig(durationMs, period)
}
}
}
@@ -75,23 +73,23 @@
private val eventPeriod = config.eventPeriod
private val recorder = MotionEventRecorder()
- private val subject = AndroidInputDispatcher(recorder::sendEvent)
+ private val subject = AndroidInputDispatcher(recorder::recordEvent)
@After
fun tearDown() {
- recorder.clear()
+ recorder.disposeEvents()
}
@Test
fun swipeByLine() {
- subject.sendSwipe(start, end, duration)
+ subject.sendSwipe(start, end, duration.milliseconds)
recorder.assertHasValidEventTimes()
recorder.events.apply {
- val expectedMoveEvents = max(1, duration.inMilliseconds() / eventPeriod).toInt()
+ val expectedMoveEvents = max(1, duration / eventPeriod).toInt()
assertThat(size).isAtLeast(2 + expectedMoveEvents) // down move+ up
// Check down and up events
- val durationMs = duration.inMilliseconds()
+ val durationMs = duration
first().verify(start, MotionEvent.ACTION_DOWN, 0)
last().verify(end, MotionEvent.ACTION_UP, durationMs)
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendUpTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendUpTest.kt
index be00dc6..a470d2d 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendUpTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendUpTest.kt
@@ -24,7 +24,6 @@
import androidx.ui.test.util.expectError
import androidx.ui.test.util.verify
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.px
import com.google.common.truth.Truth.assertThat
import org.junit.After
import org.junit.Rule
@@ -45,7 +44,7 @@
)
companion object {
- private val downPosition = PxPosition(5.px, 5.px)
+ private val downPosition = PxPosition(5f, 5f)
@JvmStatic
@Parameterized.Parameters(name = "{0}")
@@ -54,7 +53,7 @@
listOf(0f, -10f).map { y ->
TestConfig(x, y)
}
- }.plus(TestConfig(downPosition.x.value, downPosition.y.value))
+ }.plus(TestConfig(downPosition.x, downPosition.y))
}
}
@@ -64,14 +63,14 @@
@get:Rule
val inputDispatcherRule: TestRule = dispatcherRule
- private val position = PxPosition(config.x.px, config.y.px)
+ private val position = PxPosition(config.x, config.y)
private val recorder = MotionEventRecorder()
- private val subject = AndroidInputDispatcher(recorder::sendEvent)
+ private val subject = AndroidInputDispatcher(recorder::recordEvent)
@After
fun tearDown() {
- recorder.clear()
+ recorder.disposeEvents()
}
@Test
@@ -95,8 +94,8 @@
*/
@SmallTest
class SendUpAfterFinishedTest {
- private val downPosition = PxPosition(5.px, 5.px)
- private val position = PxPosition(1.px, 1.px)
+ private val downPosition = PxPosition(5f, 5f)
+ private val position = PxPosition(1f, 1f)
@get:Rule
val inputDispatcherRule: TestRule = AndroidInputDispatcher.TestRule(
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/DoPartialGestureTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/DoPartialGestureTest.kt
index 6231969..20f9298 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/DoPartialGestureTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/DoPartialGestureTest.kt
@@ -35,7 +35,6 @@
import androidx.ui.test.util.expectError
import androidx.ui.test.util.timeDiffWith
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.px
import com.google.common.truth.Truth.assertThat
import org.junit.Before
import org.junit.Rule
@@ -45,7 +44,7 @@
import org.junit.runners.Parameterized
private const val tag = "widget"
-private val anyPosition = PxPosition(1.px, 1.px)
+private val anyPosition = PxPosition(1f, 1f)
private val (PartialGestureScope.(PxPosition) -> Unit).string: String
get() = when (this) {
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendCancelTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendCancelTest.kt
index ba35892..fc43746 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendCancelTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendCancelTest.kt
@@ -28,7 +28,6 @@
import androidx.ui.test.util.PointerInputRecorder
import androidx.ui.test.util.assertTimestampsAreIncreasing
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.px
import com.google.common.truth.Truth.assertThat
import org.junit.Rule
import org.junit.Test
@@ -40,7 +39,7 @@
@RunWith(Parameterized::class)
class SendCancelTest(private val config: TestConfig) {
data class TestConfig(val cancelPosition: PxPosition?) {
- val downPosition = PxPosition(1.px, 1.px)
+ val downPosition = PxPosition(1f, 1f)
}
companion object {
@@ -50,8 +49,8 @@
@Parameterized.Parameters(name = "{0}")
fun createTestSet(): List<TestConfig> {
return mutableListOf<TestConfig>().apply {
- for (x in listOf(2.px, 99.px)) {
- for (y in listOf(3.px, 53.px)) {
+ for (x in listOf(2f, 99f)) {
+ for (y in listOf(3f, 53f)) {
add(TestConfig(PxPosition(x, y)))
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendDownTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendDownTest.kt
index 13fce7d..cab37d0 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendDownTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendDownTest.kt
@@ -27,7 +27,6 @@
import androidx.ui.test.util.PointerInputRecorder
import androidx.ui.test.util.assertTimestampsAreIncreasing
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.px
import com.google.common.truth.Truth.assertThat
import org.junit.Rule
import org.junit.Test
@@ -47,8 +46,8 @@
@Parameterized.Parameters(name = "{0}")
fun createTestSet(): List<TestConfig> {
return mutableListOf<TestConfig>().apply {
- for (x in listOf(1.px, 99.px)) {
- for (y in listOf(2.px, 53.px)) {
+ for (x in listOf(1f, 99f)) {
+ for (y in listOf(2f, 53f)) {
add(TestConfig(PxPosition(x, y)))
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveByTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveByTest.kt
index 4eed637..f9fbe33 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveByTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveByTest.kt
@@ -28,7 +28,6 @@
import androidx.ui.test.util.PointerInputRecorder
import androidx.ui.test.util.assertTimestampsAreIncreasing
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.px
import com.google.common.truth.Truth.assertThat
import org.junit.Rule
import org.junit.Test
@@ -40,7 +39,7 @@
@RunWith(Parameterized::class)
class SendMoveByTest(private val config: TestConfig) {
data class TestConfig(val moveByDelta: PxPosition) {
- val downPosition = PxPosition(1.px, 1.px)
+ val downPosition = PxPosition(1f, 1f)
}
companion object {
@@ -50,8 +49,8 @@
@Parameterized.Parameters(name = "{0}")
fun createTestSet(): List<TestConfig> {
return mutableListOf<TestConfig>().apply {
- for (x in listOf(2.px, (-100).px)) {
- for (y in listOf(3.px, (-530).px)) {
+ for (x in listOf(2f, -100f)) {
+ for (y in listOf(3f, -530f)) {
add(TestConfig(PxPosition(x, y)))
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveToTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveToTest.kt
index a616143..f4ba029 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveToTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveToTest.kt
@@ -28,7 +28,6 @@
import androidx.ui.test.util.PointerInputRecorder
import androidx.ui.test.util.assertTimestampsAreIncreasing
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.px
import com.google.common.truth.Truth.assertThat
import org.junit.Rule
import org.junit.Test
@@ -40,7 +39,7 @@
@RunWith(Parameterized::class)
class SendMoveToTest(private val config: TestConfig) {
data class TestConfig(val moveToPosition: PxPosition) {
- val downPosition = PxPosition(1.px, 1.px)
+ val downPosition = PxPosition(1f, 1f)
}
companion object {
@@ -50,8 +49,8 @@
@Parameterized.Parameters(name = "{0}")
fun createTestSet(): List<TestConfig> {
return mutableListOf<TestConfig>().apply {
- for (x in listOf(2.px, 99.px)) {
- for (y in listOf(3.px, 53.px)) {
+ for (x in listOf(2f, 99f)) {
+ for (y in listOf(3f, 53f)) {
add(TestConfig(PxPosition(x, y)))
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendUpTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendUpTest.kt
index eccbca8..95148ec 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendUpTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendUpTest.kt
@@ -28,7 +28,6 @@
import androidx.ui.test.util.PointerInputRecorder
import androidx.ui.test.util.assertTimestampsAreIncreasing
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.px
import com.google.common.truth.Truth.assertThat
import org.junit.Rule
import org.junit.Test
@@ -40,7 +39,7 @@
@RunWith(Parameterized::class)
class SendUpTest(private val config: TestConfig) {
data class TestConfig(val upPosition: PxPosition?) {
- val downPosition = PxPosition(1.px, 1.px)
+ val downPosition = PxPosition(1f, 1f)
}
companion object {
@@ -50,8 +49,8 @@
@Parameterized.Parameters(name = "{0}")
fun createTestSet(): List<TestConfig> {
return mutableListOf<TestConfig>().apply {
- for (x in listOf(2.px, 99.px)) {
- for (y in listOf(3.px, 53.px)) {
+ for (x in listOf(2f, 99f)) {
+ for (y in listOf(3f, 53f)) {
add(TestConfig(PxPosition(x, y)))
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/util/ClickableTestBox.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/util/ClickableTestBox.kt
index 7f5a188..f5cc313 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/util/ClickableTestBox.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/util/ClickableTestBox.kt
@@ -28,7 +28,7 @@
import androidx.ui.test.util.ClickableTestBox.defaultTag
object ClickableTestBox {
- val defaultSize = 100.0f
+ const val defaultSize = 100.0f
val defaultColor = Color.Yellow
const val defaultTag = "ClickableTestBox"
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/util/MotionEvents.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/util/MotionEvents.kt
index 82397aa..54e0f1e 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/util/MotionEvents.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/util/MotionEvents.kt
@@ -26,11 +26,11 @@
private val _events = mutableListOf<MotionEvent>()
val events get() = _events as List<MotionEvent>
- fun clear() {
+ fun disposeEvents() {
_events.removeAll { it.recycle(); true }
}
- fun sendEvent(event: MotionEvent) {
+ fun recordEvent(event: MotionEvent) {
_events.add(MotionEvent.obtain(event))
}
}
@@ -70,8 +70,8 @@
assertThat(relativeTime).isEqualTo(expectedRelativeTime)
// x and y can just be taken from the function. We're not testing the function, we're
// testing if the MotionEvent sampled the function at the correct point
- assertThat(x).isEqualTo(expectedPosition.x.value)
- assertThat(y).isEqualTo(expectedPosition.y.value)
+ assertThat(x).isEqualTo(expectedPosition.x)
+ assertThat(y).isEqualTo(expectedPosition.y)
}
/**
@@ -85,8 +85,8 @@
* Checks that the coordinates are progressing in a monotonous direction
*/
fun List<MotionEvent>.isMonotonicBetween(start: PxPosition, end: PxPosition) {
- map { it.x }.isMonotonicBetween(start.x.value, end.x.value, 1e-6f)
- map { it.y }.isMonotonicBetween(start.y.value, end.y.value, 1e-6f)
+ map { it.x }.isMonotonicBetween(start.x, end.x, 1e-6f)
+ map { it.y }.isMonotonicBetween(start.y, end.y, 1e-6f)
}
/**
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/util/PointerInputs.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/util/PointerInputs.kt
index c77f3f9..7434a89 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/util/PointerInputs.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/util/PointerInputs.kt
@@ -101,14 +101,6 @@
* Checks that the coordinates are progressing in a monotonous direction
*/
fun List<DataPoint>.isMonotonicBetween(start: PxPosition, end: PxPosition) {
- map { it.x.value }.isMonotonicBetween(start.x.value, end.x.value, 1e-3f)
- map { it.y.value }.isMonotonicBetween(start.y.value, end.y.value, 1e-3f)
-}
-
-/**
- * Verifies that all [DataPoint]s in the list are equal to the given position, with a tolerance
- * of 0.001
- */
-fun List<DataPoint>.areAlmostEqualTo(position: PxPosition) {
- forEach { it.position.isAlmostEqualTo(position, 1e-3f) }
+ map { it.x }.isMonotonicBetween(start.x, end.x, 1e-3f)
+ map { it.y }.isMonotonicBetween(start.y, end.y, 1e-3f)
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/util/Truth.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/util/Truth.kt
index 6aa4643..ec5d32d 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/util/Truth.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/util/Truth.kt
@@ -34,8 +34,8 @@
* tolerance is 0.001.
*/
fun PxPosition.isAlmostEqualTo(position: PxPosition, tolerance: Float = 1e-3f) {
- assertThat(x.value).isAlmostEqualTo(position.x.value, tolerance)
- assertThat(y.value).isAlmostEqualTo(position.y.value, tolerance)
+ assertThat(x).isAlmostEqualTo(position.x, tolerance)
+ assertThat(y).isAlmostEqualTo(position.y, tolerance)
}
/**
diff --git a/ui/ui-test/src/main/java/androidx/ui/test/Actions.kt b/ui/ui-test/src/main/java/androidx/ui/test/Actions.kt
index 28ab006..1f1ceb8 100644
--- a/ui/ui-test/src/main/java/androidx/ui/test/Actions.kt
+++ b/ui/ui-test/src/main/java/androidx/ui/test/Actions.kt
@@ -21,7 +21,6 @@
import androidx.ui.semantics.SemanticsActions
import androidx.ui.semantics.SemanticsPropertyKey
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.px
/**
* Performs a click action on the given component.
@@ -67,12 +66,12 @@
"No Layout Node found!"
)
- val position = layoutNode.coordinates.localToGlobal(PxPosition(0.px, 0.px))
+ val position = layoutNode.coordinates.localToGlobal(PxPosition(0.0f, 0.0f))
runOnUiThread {
scrollableSemanticsNode.config[SemanticsActions.ScrollTo].action(
- globalPosition.x - position.x,
- globalPosition.y - position.y
+ (globalPosition.x - position.x),
+ (globalPosition.y - position.y)
)
}
diff --git a/ui/ui-test/src/main/java/androidx/ui/test/Assertions.kt b/ui/ui-test/src/main/java/androidx/ui/test/Assertions.kt
index 1dd7d7d..84a8f75 100644
--- a/ui/ui-test/src/main/java/androidx/ui/test/Assertions.kt
+++ b/ui/ui-test/src/main/java/androidx/ui/test/Assertions.kt
@@ -315,12 +315,12 @@
return false
}
- return (globalRect.width > 0.px && globalRect.height > 0.px)
+ return (globalRect.width > 0f && globalRect.height > 0f)
}
private fun SemanticsNode.isInScreenBounds(): Boolean {
val nodeBounds = globalBounds
- if (nodeBounds.width == 0.px && nodeBounds.height == 0.px) {
+ if (nodeBounds.width == 0f && nodeBounds.height == 0f) {
return false
}
diff --git a/ui/ui-test/src/main/java/androidx/ui/test/BitmapHelpers.kt b/ui/ui-test/src/main/java/androidx/ui/test/BitmapHelpers.kt
index 02308fd..8d65ad2 100644
--- a/ui/ui-test/src/main/java/androidx/ui/test/BitmapHelpers.kt
+++ b/ui/ui-test/src/main/java/androidx/ui/test/BitmapHelpers.kt
@@ -16,13 +16,8 @@
package androidx.ui.test
-import android.app.Activity
-import android.content.Context
-import android.content.ContextWrapper
import android.graphics.Bitmap
-import android.os.Build
import android.view.View
-import androidx.annotation.RequiresApi
import androidx.ui.geometry.Offset
import androidx.ui.geometry.Rect
import androidx.ui.geometry.Size
@@ -45,17 +40,15 @@
import kotlin.math.roundToInt
/**
- * Captures the underlying component's surface into bitmap.
+ * Captures the screen region occupied by this component into a bitmap.
*
- * This has currently several limitations. Currently we assume that the component is hosted in
- * Activity's window. Also if there is another window covering part of the component if won't occur
- * in the bitmap as this is taken from the component's window surface.
+ * In case there is anything else (for example a popup) on top of this component, it will be also
+ * captured as part of this operation.
*/
-@RequiresApi(Build.VERSION_CODES.O)
fun SemanticsNodeInteraction.captureToBitmap(): Bitmap {
val node = fetchSemanticsNode("Failed to capture a node to bitmap.")
// TODO(pavlis): Consider doing assertIsDisplayed here. Will need to move things around.
- return captureRegionToBitmap(node.globalBounds.toRect(), node.componentNode.owner!!)
+ return captureRegionToBitmap(node.globalBounds.toRect())
}
/**
@@ -65,24 +58,13 @@
* Activity's window. Also if there is another window covering part of the component if won't occur
* in the bitmap as this is taken from the component's window surface.
*/
-@RequiresApi(Build.VERSION_CODES.O)
fun View.captureToBitmap(): Bitmap {
val locationOnScreen = intArrayOf(0, 0)
getLocationOnScreen(locationOnScreen)
val x = locationOnScreen[0].toFloat()
val y = locationOnScreen[1].toFloat()
val bounds = Rect(x, y, x + width, y + height)
-
- // Recursively search for the Activity context through (possible) ContextWrappers
- fun Context.getActivity(): Activity? {
- return when (this) {
- is Activity -> this
- is ContextWrapper -> this.baseContext.getActivity()
- else -> null
- }
- }
-
- return captureRegionToBitmap(bounds, handler, context.getActivity()!!.window)
+ return captureRegionToBitmap(bounds)
}
/**
diff --git a/ui/ui-test/src/main/java/androidx/ui/test/ComposeTestRule.kt b/ui/ui-test/src/main/java/androidx/ui/test/ComposeTestRule.kt
index b8c4f25..611728b 100644
--- a/ui/ui-test/src/main/java/androidx/ui/test/ComposeTestRule.kt
+++ b/ui/ui-test/src/main/java/androidx/ui/test/ComposeTestRule.kt
@@ -16,11 +16,8 @@
package androidx.ui.test
-import android.graphics.Bitmap
-import android.os.Build
import android.util.DisplayMetrics
import androidx.activity.ComponentActivity
-import androidx.annotation.RequiresApi
import androidx.compose.Composable
import androidx.compose.Recomposer
import androidx.ui.unit.Density
@@ -68,22 +65,6 @@
*/
fun forGivenTestCase(testCase: ComposeTestCase): ComposeTestCaseSetup
- /**
- * Takes screenshot of the Activity's window after Compose UI gets idle.
- *
- * This function blocks until complete.
- *
- * Note that this does not capture the full device screen as it has access only to the test
- * Activity's window surface. The test Activity is the one that hosts the initial composition
- * created via [setContent]. If there are windows on top of the Activity's window these won't
- * be included. It will also not include any other Activities started afterwards.
- *
- * You can also use [SemanticsNodeInteraction.captureToBitmap] to capture individual components.
- * That one does not require any specific Activity.
- */
- @RequiresApi(Build.VERSION_CODES.O)
- fun captureScreenOnIdle(): Bitmap
-
// TODO(pavlis): Provide better abstraction for host side reusability
val displayMetrics: DisplayMetrics get
}
diff --git a/ui/ui-test/src/main/java/androidx/ui/test/ErrorMessages.kt b/ui/ui-test/src/main/java/androidx/ui/test/ErrorMessages.kt
index 397761d..6014bad 100644
--- a/ui/ui-test/src/main/java/androidx/ui/test/ErrorMessages.kt
+++ b/ui/ui-test/src/main/java/androidx/ui/test/ErrorMessages.kt
@@ -235,7 +235,7 @@
}
private fun pxBoundsToShortString(bounds: PxBounds): String {
- return "LTRB(${bounds.left}, ${bounds.top}, ${bounds.right}, ${bounds.bottom})"
+ return "LTRB(${bounds.left}.px, ${bounds.top}.px, ${bounds.right}.px, ${bounds.bottom}.px)"
}
private fun StringBuilder.appendConfigInfo(config: SemanticsConfiguration) {
diff --git a/ui/ui-test/src/main/java/androidx/ui/test/GestureScope.kt b/ui/ui-test/src/main/java/androidx/ui/test/GestureScope.kt
index 79879d5..5cb47e8 100644
--- a/ui/ui-test/src/main/java/androidx/ui/test/GestureScope.kt
+++ b/ui/ui-test/src/main/java/androidx/ui/test/GestureScope.kt
@@ -25,8 +25,6 @@
import androidx.ui.unit.PxPosition
import androidx.ui.unit.inMilliseconds
import androidx.ui.unit.milliseconds
-import androidx.ui.unit.px
-import androidx.ui.unit.toPx
import androidx.ui.util.lerp
import kotlin.math.atan2
import kotlin.math.cos
@@ -289,7 +287,7 @@
// Decompose v into it's x and y components
val delta = end - start
- val theta = atan2(delta.y.value, delta.x.value)
+ val theta = atan2(delta.y, delta.x)
// VelocityTracker internally calculates px/s, not px/ms
val vx = cos(theta) * endVelocity / 1000
val vy = sin(theta) * endVelocity / 1000
@@ -305,10 +303,10 @@
// (-age, x) and (-age, y) for vx and vy respectively, which is accounted for in
// f(Long, Long, Float, Float, Float).
val durationMs = duration.inMilliseconds()
- val fx = createFunctionForVelocity(durationMs, globalStart.x.value, globalEnd.x.value, vx)
- val fy = createFunctionForVelocity(durationMs, globalStart.y.value, globalEnd.y.value, vy)
+ val fx = createFunctionForVelocity(durationMs, globalStart.x, globalEnd.x, vx)
+ val fy = createFunctionForVelocity(durationMs, globalStart.y, globalEnd.y, vy)
- inputDispatcher.sendSwipe({ t -> PxPosition(fx(t).px, fy(t).px) }, duration)
+ inputDispatcher.sendSwipe({ t -> PxPosition(fx(t), fy(t)) }, duration)
}
/**
@@ -319,9 +317,9 @@
*/
fun GestureScope.sendSwipeUp() {
val x = center.x
- val y0 = size.height * (1 - edgeFuzzFactor)
- val y1 = 0.px
- val start = PxPosition(x, y0.toPx())
+ val y0 = (size.height * (1 - edgeFuzzFactor)).value.toFloat()
+ val y1 = 0.0f
+ val start = PxPosition(x, y0)
val end = PxPosition(x, y1)
sendSwipe(start, end, 200.milliseconds)
}
@@ -334,10 +332,10 @@
*/
fun GestureScope.sendSwipeDown() {
val x = center.x
- val y0 = size.height * edgeFuzzFactor
- val y1 = size.height
- val start = PxPosition(x, y0.toPx())
- val end = PxPosition(x, y1.toPx())
+ val y0 = (size.height * edgeFuzzFactor).value.toFloat()
+ val y1 = size.height.value.toFloat()
+ val start = PxPosition(x, y0)
+ val end = PxPosition(x, y1)
sendSwipe(start, end, 200.milliseconds)
}
@@ -348,10 +346,10 @@
* Throws [AssertionError] when the component doesn't have a bounding rectangle set
*/
fun GestureScope.sendSwipeLeft() {
- val x0 = size.width * (1 - edgeFuzzFactor)
- val x1 = 0.px
+ val x0 = (size.width * (1 - edgeFuzzFactor)).value.toFloat()
+ val x1 = 0.0f
val y = center.y
- val start = PxPosition(x0.toPx(), y)
+ val start = PxPosition(x0, y)
val end = PxPosition(x1, y)
sendSwipe(start, end, 200.milliseconds)
}
@@ -363,11 +361,11 @@
* Throws [AssertionError] when the component doesn't have a bounding rectangle set
*/
fun GestureScope.sendSwipeRight() {
- val x0 = size.width * edgeFuzzFactor
- val x1 = size.width
+ val x0 = (size.width * edgeFuzzFactor).value.toFloat()
+ val x1 = size.width.value.toFloat()
val y = center.y
- val start = PxPosition(x0.toPx(), y)
- val end = PxPosition(x1.toPx(), y)
+ val start = PxPosition(x0, y)
+ val end = PxPosition(x1, y)
sendSwipe(start, end, 200.milliseconds)
}
diff --git a/ui/ui-test/src/main/java/androidx/ui/test/SizesTesting.kt b/ui/ui-test/src/main/java/androidx/ui/test/SizesTesting.kt
index bd1134a..78492a5 100644
--- a/ui/ui-test/src/main/java/androidx/ui/test/SizesTesting.kt
+++ b/ui/ui-test/src/main/java/androidx/ui/test/SizesTesting.kt
@@ -27,9 +27,9 @@
import androidx.ui.unit.IntPx
import androidx.ui.unit.PxSize
import androidx.ui.unit.dp
-import androidx.ui.unit.round
import androidx.ui.unit.toPxSize
import kotlin.math.abs
+import kotlin.math.roundToInt
/**
* Constant to emulate very big but finite constraints
@@ -96,33 +96,33 @@
fun assertWidthEqualsTo(expectedWidthPx: Density.() -> IntPx): CollectedSizes {
val widthPx = with(density) {
- expectedWidthPx()
+ expectedWidthPx().value
}
- assertSize(size.width.round(), widthPx)
+ assertSize(size.width.roundToInt(), widthPx)
return this
}
fun assertHeightEqualsTo(expectedHeightPx: Density.() -> IntPx): CollectedSizes {
val heightPx = with(density) {
- expectedHeightPx()
+ expectedHeightPx().value
}
- assertSize(size.height.round(), heightPx)
+ assertSize(size.height.roundToInt(), heightPx)
return this
}
fun assertIsSquareWithSize(expectedSquarePx: Density.() -> IntPx): CollectedSizes {
val squarePx = with(density) {
- expectedSquarePx()
+ expectedSquarePx().value
}
- assertSize(size.width.round(), squarePx)
- assertSize(size.height.round(), squarePx)
+ assertSize(size.width.roundToInt(), squarePx)
+ assertSize(size.height.roundToInt(), squarePx)
return this
}
}
-private fun assertSize(actual: IntPx, expected: IntPx) {
+private fun assertSize(actual: Int, expected: Int) {
// TODO: because if dp and ipx collision. Remove dp assertion later
- if (abs(actual.value - expected.value) > 1) {
+ if (abs(actual - expected) > 1) {
throw AssertionError("Found size: $actual pixels.\nExpected size $expected pixels")
}
}
\ No newline at end of file
diff --git a/ui/ui-test/src/main/java/androidx/ui/test/android/AndroidComposeTestRule.kt b/ui/ui-test/src/main/java/androidx/ui/test/android/AndroidComposeTestRule.kt
index 7d65436..30fa720 100644
--- a/ui/ui-test/src/main/java/androidx/ui/test/android/AndroidComposeTestRule.kt
+++ b/ui/ui-test/src/main/java/androidx/ui/test/android/AndroidComposeTestRule.kt
@@ -16,21 +16,17 @@
package androidx.ui.test.android
-import android.graphics.Bitmap
-import android.os.Build
import android.os.Handler
import android.os.Looper
import android.util.DisplayMetrics
import android.util.SparseArray
import android.view.ViewGroup
import androidx.activity.ComponentActivity
-import androidx.annotation.RequiresApi
import androidx.compose.Composable
import androidx.compose.Recomposer
import androidx.test.rule.ActivityTestRule
import androidx.ui.animation.transitionsEnabled
import androidx.ui.core.setContent
-import androidx.ui.geometry.Rect
import androidx.ui.input.textInputServiceFactory
import androidx.ui.test.AnimationClockTestRule
import androidx.ui.test.ComposeTestCase
@@ -143,20 +139,6 @@
)
}
- @RequiresApi(Build.VERSION_CODES.O)
- override fun captureScreenOnIdle(): Bitmap {
- waitForIdle()
- val contentView = activityTestRule.activity.findViewById<ViewGroup>(android.R.id.content)
-
- val screenRect = Rect.fromLTWH(
- 0f,
- 0f,
- contentView.width.toFloat(),
- contentView.height.toFloat()
- )
- return captureRegionToBitmap(screenRect, handler, activityTestRule.activity.window)
- }
-
inner class AndroidComposeStatement(
private val base: Statement
) : Statement() {
diff --git a/ui/ui-test/src/main/java/androidx/ui/test/android/AndroidInputDispatcher.kt b/ui/ui-test/src/main/java/androidx/ui/test/android/AndroidInputDispatcher.kt
index 8152411..6640653 100644
--- a/ui/ui-test/src/main/java/androidx/ui/test/android/AndroidInputDispatcher.kt
+++ b/ui/ui-test/src/main/java/androidx/ui/test/android/AndroidInputDispatcher.kt
@@ -280,8 +280,8 @@
},
Array(coordinates.size) {
MotionEvent.PointerCoords().apply {
- x = coordinates[it].x.value
- y = coordinates[it].y.value
+ x = coordinates[it].x
+ y = coordinates[it].y
}
},
0,
diff --git a/ui/ui-test/src/main/java/androidx/ui/test/android/WindowCapture.kt b/ui/ui-test/src/main/java/androidx/ui/test/android/WindowCapture.kt
index 525636e..836cad5 100644
--- a/ui/ui-test/src/main/java/androidx/ui/test/android/WindowCapture.kt
+++ b/ui/ui-test/src/main/java/androidx/ui/test/android/WindowCapture.kt
@@ -16,90 +16,15 @@
package androidx.ui.test.android
-import android.app.Activity
-import android.content.Context
-import android.content.ContextWrapper
import android.graphics.Bitmap
-import android.os.Build
-import android.os.Handler
-import android.os.Looper
-import android.view.PixelCopy
-import android.view.ViewTreeObserver
-import android.view.Window
-import androidx.annotation.RequiresApi
-import androidx.ui.core.AndroidOwner
-import androidx.ui.core.Owner
+import androidx.test.platform.app.InstrumentationRegistry
+import androidx.test.uiautomator.UiDevice
import androidx.ui.geometry.Rect
-import java.util.concurrent.CountDownLatch
-import java.util.concurrent.TimeUnit
import kotlin.math.roundToInt
-@RequiresApi(Build.VERSION_CODES.O)
internal fun captureRegionToBitmap(
- captureRect: Rect,
- owner: Owner
+ captureRect: Rect
): Bitmap {
-
- fun Context.getActivity(): Activity? {
- return when (this) {
- is Activity -> this
- is ContextWrapper -> this.baseContext.getActivity()
- else -> null
- }
- }
-
- // TODO(pavlis): Make sure that the Activity actually hosts the view. As in case of popup
- // it wouldn't. This will require us rewriting the structure how we collect the nodes.
-
- // TODO(pavlis): Add support for popups. So if we find composable hosted in popup we can
- // grab its reference to its window (need to add a hook to popup).
-
- val window = (owner as AndroidOwner).view.context.getActivity()!!.window
- val handler = Handler(Looper.getMainLooper())
- return captureRegionToBitmap(captureRect, handler, window)
-}
-
-@RequiresApi(Build.VERSION_CODES.O)
-internal fun captureRegionToBitmap(
- captureRect: Rect,
- handler: Handler,
- window: Window
-): Bitmap {
- // first we wait for the drawing to happen
- val drawLatch = CountDownLatch(1)
- val decorView = window.decorView
- handler.post {
- if (Build.VERSION.SDK_INT >= 29) {
- decorView.viewTreeObserver.registerFrameCommitCallback {
- drawLatch.countDown()
- }
- } else {
- decorView.viewTreeObserver.addOnDrawListener(object : ViewTreeObserver.OnDrawListener {
- var handled = false
- override fun onDraw() {
- if (!handled) {
- handled = true
- handler.post {
- drawLatch.countDown()
- decorView.viewTreeObserver.removeOnDrawListener(this)
- }
- }
- }
- })
- }
- decorView.invalidate()
- }
- if (!drawLatch.await(1, TimeUnit.SECONDS)) {
- throw AssertionError("Failed waiting for DecorView redraw!")
- }
-
- // and then request the pixel copy of the drawn buffer
- val destBitmap = Bitmap.createBitmap(
- captureRect.width.roundToInt(),
- captureRect.height.roundToInt(),
- Bitmap.Config.ARGB_8888
- )
-
// TODO: This could go to some Android specific extensions.
val srcRect = android.graphics.Rect(
captureRect.left.roundToInt(),
@@ -108,22 +33,12 @@
captureRect.bottom.roundToInt()
)
- val latch = CountDownLatch(1)
- var copyResult = 0
- val onCopyFinished = object : PixelCopy.OnPixelCopyFinishedListener {
- override fun onPixelCopyFinished(result: Int) {
- copyResult = result
- latch.countDown()
- }
- }
+ val device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
+ device.waitForIdle()
- PixelCopy.request(window, srcRect, destBitmap, onCopyFinished, handler)
+ val automation = InstrumentationRegistry.getInstrumentation().uiAutomation
+ val srcBitmap = automation.takeScreenshot()
- if (!latch.await(1, TimeUnit.SECONDS)) {
- throw AssertionError("Failed waiting for PixelCopy!")
- }
- if (copyResult != PixelCopy.SUCCESS) {
- throw AssertionError("PixelCopy failed!")
- }
- return destBitmap
-}
+ return Bitmap.createBitmap(srcBitmap, captureRect.left.roundToInt(),
+ captureRect.top.roundToInt(), srcRect.width(), srcRect.height())
+}
\ No newline at end of file
diff --git a/ui/ui-text-core/src/androidTest/java/androidx/ui/text/MultiParagraphIntegrationTest.kt b/ui/ui-text-core/src/androidTest/java/androidx/ui/text/MultiParagraphIntegrationTest.kt
index 0ba70c8..1b09373 100644
--- a/ui/ui-text-core/src/androidTest/java/androidx/ui/text/MultiParagraphIntegrationTest.kt
+++ b/ui/ui-text-core/src/androidTest/java/androidx/ui/text/MultiParagraphIntegrationTest.kt
@@ -32,7 +32,6 @@
import androidx.ui.unit.PxPosition
import androidx.ui.unit.TextUnit
import androidx.ui.unit.em
-import androidx.ui.unit.px
import androidx.ui.unit.sp
import com.google.common.truth.Truth.assertThat
import com.google.common.truth.Truth.assertWithMessage
@@ -224,7 +223,9 @@
val col = i % lineLength
val x = fontSizeInPx * col
- val actualOffset = paragraph.getOffsetForPosition(PxPosition(x.px, y.px))
+ val actualOffset = paragraph.getOffsetForPosition(
+ PxPosition(x.toFloat(), y.toFloat())
+ )
assertWithMessage("getOffsetForPosition($x, $y) failed")
.that(actualOffset).isEqualTo(i)
}
diff --git a/ui/ui-text-core/src/androidTest/java/androidx/ui/text/ParagraphIntegrationTest.kt b/ui/ui-text-core/src/androidTest/java/androidx/ui/text/ParagraphIntegrationTest.kt
index 6c0ed96e..7eba737 100644
--- a/ui/ui-text-core/src/androidTest/java/androidx/ui/text/ParagraphIntegrationTest.kt
+++ b/ui/ui-text-core/src/androidTest/java/androidx/ui/text/ParagraphIntegrationTest.kt
@@ -43,7 +43,6 @@
import androidx.ui.unit.Density
import androidx.ui.unit.PxPosition
import androidx.ui.unit.em
-import androidx.ui.unit.px
import androidx.ui.unit.sp
import com.google.common.truth.Truth.assertThat
import com.google.common.truth.Truth.assertWithMessage
@@ -227,7 +226,7 @@
// test positions that are 1, fontSize+1, 2fontSize+1 which maps to chars 0, 1, 2 ...
for (i in 0..text.length) {
- val position = PxPosition((i * fontSizeInPx + 1).px, (fontSizeInPx / 2).px)
+ val position = PxPosition((i * fontSizeInPx + 1), (fontSizeInPx / 2))
val offset = paragraph.getOffsetForPosition(position)
assertWithMessage("offset at index $i, position $position does not match")
.that(offset).isEqualTo(i)
@@ -249,7 +248,7 @@
// test positions that are 1, fontSize+1, 2fontSize+1 which maps to chars .., 2, 1, 0
for (i in 0..text.length) {
- val position = PxPosition((i * fontSizeInPx + 1).px, (fontSizeInPx / 2).px)
+ val position = PxPosition((i * fontSizeInPx + 1), (fontSizeInPx / 2))
val offset = paragraph.getOffsetForPosition(position)
assertWithMessage("offset at index $i, position $position does not match")
.that(offset).isEqualTo(text.length - i)
@@ -274,7 +273,7 @@
// test positions are 1, fontSize+1, 2fontSize+1 and always on the second line
// which maps to chars 3, 4, 5
for (i in 0..secondLine.length) {
- val position = PxPosition((i * fontSizeInPx + 1).px, (fontSizeInPx * 1.5f).px)
+ val position = PxPosition((i * fontSizeInPx + 1), (fontSizeInPx * 1.5f))
val offset = paragraph.getOffsetForPosition(position)
assertWithMessage(
"offset at index $i, position $position, second line does not match"
@@ -300,7 +299,7 @@
// test positions are 1, fontSize+1, 2fontSize+1 and always on the second line
// which maps to chars 5, 4, 3
for (i in 0..secondLine.length) {
- val position = PxPosition((i * fontSizeInPx + 1).px, (fontSizeInPx * 1.5f).px)
+ val position = PxPosition((i * fontSizeInPx + 1), (fontSizeInPx * 1.5f))
val offset = paragraph.getOffsetForPosition(position)
assertWithMessage(
"offset at index $i, position $position, second line does not match"
@@ -322,12 +321,12 @@
)
// greater than width
- var position = PxPosition((fontSizeInPx * text.length * 2).px, (fontSizeInPx / 2).px)
+ var position = PxPosition((fontSizeInPx * text.length * 2), (fontSizeInPx / 2))
var offset = paragraph.getOffsetForPosition(position)
assertThat(offset).isEqualTo(text.length)
// negative
- position = PxPosition((-1 * fontSizeInPx).px, (fontSizeInPx / 2).px)
+ position = PxPosition((-1 * fontSizeInPx), (fontSizeInPx / 2))
offset = paragraph.getOffsetForPosition(position)
assertThat(offset).isZero()
}
@@ -346,12 +345,12 @@
)
// greater than height
- var position = PxPosition((fontSizeInPx / 2).px, (fontSizeInPx * text.length * 2).px)
+ var position = PxPosition((fontSizeInPx / 2), (fontSizeInPx * text.length * 2))
var offset = paragraph.getOffsetForPosition(position)
assertThat(offset).isZero()
// negative
- position = PxPosition((fontSizeInPx / 2).px, (-1 * fontSizeInPx).px)
+ position = PxPosition((fontSizeInPx / 2), (-1 * fontSizeInPx))
offset = paragraph.getOffsetForPosition(position)
assertThat(offset).isZero()
}
@@ -2209,7 +2208,7 @@
)
// The position of the last character in display order.
- val position = PxPosition(("a.".length * fontSizeInPx + 1).px, (fontSizeInPx / 2).px)
+ val position = PxPosition(("a.".length * fontSizeInPx + 1), (fontSizeInPx / 2))
val charIndex = paragraph.getOffsetForPosition(position)
assertThat(charIndex).isEqualTo(2)
}
@@ -2233,7 +2232,7 @@
)
// The position of the first character in display order.
- val position = PxPosition((fontSizeInPx / 2 + 1).px, (fontSizeInPx / 2).px)
+ val position = PxPosition((fontSizeInPx / 2 + 1), (fontSizeInPx / 2))
val charIndex = paragraph.getOffsetForPosition(position)
assertThat(charIndex).isEqualTo(2)
}
@@ -2255,7 +2254,7 @@
for (i in 0..text.length) {
// The position of the i-th character in display order.
- val position = PxPosition((i * fontSizeInPx + 1).px, (fontSizeInPx / 2).px)
+ val position = PxPosition((i * fontSizeInPx + 1), (fontSizeInPx / 2))
val charIndex = paragraph.getOffsetForPosition(position)
assertThat(charIndex).isEqualTo(i)
}
@@ -2278,7 +2277,7 @@
for (i in text.indices) {
// The position of the i-th character in display order.
- val position = PxPosition((i * fontSizeInPx + 1).px, (fontSizeInPx / 2).px)
+ val position = PxPosition((i * fontSizeInPx + 1), (fontSizeInPx / 2))
val charIndex = paragraph.getOffsetForPosition(position)
assertThat(charIndex).isEqualTo(i)
}
@@ -2300,7 +2299,7 @@
)
// The first character in display order should be '.'
- val position = PxPosition((fontSizeInPx / 2 + 1).px, (fontSizeInPx / 2).px)
+ val position = PxPosition((fontSizeInPx / 2 + 1), (fontSizeInPx / 2))
val index = paragraph.getOffsetForPosition(position)
assertThat(index).isEqualTo(2)
}
@@ -3118,7 +3117,7 @@
// This position should point to the first character 'a' if indent is applied.
// Otherwise this position will point to the second character 'b'.
- val position = PxPosition((indentInPx + 1).px, (fontSizeInPx / 2).px)
+ val position = PxPosition((indentInPx + 1), (fontSizeInPx / 2))
// The offset corresponding to the position should be the first char 'a'.
assertThat(paragraph.getOffsetForPosition(position)).isZero()
}
diff --git a/ui/ui-text-core/src/androidTest/java/androidx/ui/text/TextLayoutResultIntegrationTest.kt b/ui/ui-text-core/src/androidTest/java/androidx/ui/text/TextLayoutResultIntegrationTest.kt
index 4bfd686..9052592 100644
--- a/ui/ui-text-core/src/androidTest/java/androidx/ui/text/TextLayoutResultIntegrationTest.kt
+++ b/ui/ui-text-core/src/androidTest/java/androidx/ui/text/TextLayoutResultIntegrationTest.kt
@@ -27,7 +27,6 @@
import androidx.ui.unit.Density
import androidx.ui.unit.PxPosition
import androidx.ui.unit.ipx
-import androidx.ui.unit.px
import androidx.ui.unit.sp
import com.google.common.truth.Truth.assertThat
import org.junit.Test
@@ -160,7 +159,7 @@
val layoutResult = textDelegate.layout(Constraints(), layoutDirection)
val selection = layoutResult.getOffsetForPosition(
- position = PxPosition((fontSize.toPx() * characterIndex + 1).px, 0.px)
+ position = PxPosition((fontSize.toPx() * characterIndex + 1), 0f)
)
assertThat(selection).isEqualTo(characterIndex)
diff --git a/ui/ui-text-core/src/main/java/androidx/ui/text/MultiParagraph.kt b/ui/ui-text-core/src/main/java/androidx/ui/text/MultiParagraph.kt
index 72a854c..ebe528c 100644
--- a/ui/ui-text-core/src/main/java/androidx/ui/text/MultiParagraph.kt
+++ b/ui/ui-text-core/src/main/java/androidx/ui/text/MultiParagraph.kt
@@ -268,9 +268,9 @@
/** Returns the character offset closest to the given graphical position. */
fun getOffsetForPosition(position: PxPosition): Int {
val paragraphIndex = when {
- position.y.value <= 0f -> 0
- position.y.value >= height -> paragraphInfoList.lastIndex
- else -> findParagraphByY(paragraphInfoList, position.y.value)
+ position.y <= 0f -> 0
+ position.y >= height -> paragraphInfoList.lastIndex
+ else -> findParagraphByY(paragraphInfoList, position.y)
}
return with(paragraphInfoList[paragraphIndex]) {
if (length == 0) {
@@ -698,7 +698,7 @@
* relative to the [paragraph].
*/
fun PxPosition.toLocal(): PxPosition {
- return PxPosition(x = x.value, y = y.value - top)
+ return PxPosition(x = x, y = y - top)
}
/**
diff --git a/ui/ui-text-core/src/main/java/androidx/ui/text/platform/AndroidParagraph.kt b/ui/ui-text-core/src/main/java/androidx/ui/text/platform/AndroidParagraph.kt
index c9354fd..7da4b28 100644
--- a/ui/ui-text-core/src/main/java/androidx/ui/text/platform/AndroidParagraph.kt
+++ b/ui/ui-text-core/src/main/java/androidx/ui/text/platform/AndroidParagraph.kt
@@ -206,8 +206,8 @@
get() = paragraphIntrinsics.textPaint
override fun getOffsetForPosition(position: PxPosition): Int {
- val line = layout.getLineForVertical(position.y.value.toInt())
- return layout.getOffsetForHorizontal(line, position.x.value)
+ val line = layout.getLineForVertical(position.y.toInt())
+ return layout.getOffsetForHorizontal(line, position.x)
}
/**
diff --git a/ui/ui-text/integration-tests/ui-text-compose-demos/src/main/java/androidx/ui/text/demos/ComposeVariousInputField.kt b/ui/ui-text/integration-tests/ui-text-compose-demos/src/main/java/androidx/ui/text/demos/ComposeVariousInputField.kt
index 344b198..72d93c1 100644
--- a/ui/ui-text/integration-tests/ui-text-compose-demos/src/main/java/androidx/ui/text/demos/ComposeVariousInputField.kt
+++ b/ui/ui-text/integration-tests/ui-text-compose-demos/src/main/java/androidx/ui/text/demos/ComposeVariousInputField.kt
@@ -44,7 +44,7 @@
import androidx.ui.text.TextStyle
import androidx.ui.text.toUpperCase
import androidx.ui.unit.ipx
-import androidx.ui.unit.px
+import kotlin.math.roundToInt
/**
* The offset translator used for credit card input field.
@@ -339,8 +339,8 @@
)
// Place the custom cursor aligned with center of the original cursor.
val cursorX = (cursorRect.left + cursorRect.right) / 2 -
- (cursorPlacable.width.value / 2)
- cursorPlacable.place(cursorX.px, cursorRect.top.px)
+ (cursorPlacable.width.value / 2)
+ cursorPlacable.place(cursorX.roundToInt().ipx, cursorRect.top.roundToInt().ipx)
}
}
}
diff --git a/ui/ui-text/src/androidTest/java/androidx/ui/text/TextLayoutTest.kt b/ui/ui-text/src/androidTest/java/androidx/ui/text/TextLayoutTest.kt
index 95ef159..784f8c6 100644
--- a/ui/ui-text/src/androidTest/java/androidx/ui/text/TextLayoutTest.kt
+++ b/ui/ui-text/src/androidTest/java/androidx/ui/text/TextLayoutTest.kt
@@ -37,7 +37,6 @@
import androidx.ui.unit.IntPx
import androidx.ui.unit.IntPxSize
import androidx.ui.unit.ipx
-import androidx.ui.unit.px
import com.google.common.truth.Truth.assertThat
import com.nhaarman.mockitokotlin2.any
import com.nhaarman.mockitokotlin2.mock
@@ -207,9 +206,9 @@
it.measure(constraints.copy(minWidth = 0.ipx, minHeight = 0.ipx))
}
layout(constraints.maxWidth, constraints.maxHeight) {
- var top = 0.px
+ var top = 0.ipx
placeables.forEach {
- it.place(0.px, top)
+ it.place(0.ipx, top)
top += it.height
}
}
diff --git a/ui/ui-text/src/androidTest/java/androidx/ui/text/selection/TextSelectionDelegateTest.kt b/ui/ui-text/src/androidTest/java/androidx/ui/text/selection/TextSelectionDelegateTest.kt
index 9e60b83..da8b09f 100644
--- a/ui/ui-text/src/androidTest/java/androidx/ui/text/selection/TextSelectionDelegateTest.kt
+++ b/ui/ui-text/src/androidTest/java/androidx/ui/text/selection/TextSelectionDelegateTest.kt
@@ -44,7 +44,6 @@
import androidx.ui.unit.Density
import androidx.ui.unit.PxPosition
import androidx.ui.unit.TextUnit
-import androidx.ui.unit.px
import androidx.ui.unit.sp
import com.google.common.truth.Truth.assertThat
import com.nhaarman.mockitokotlin2.mock
@@ -233,7 +232,7 @@
// Assert.
assertThat(coordinates).isEqualTo(
- PxPosition((fontSizeInPx * startOffset).px, fontSizeInPx.px)
+ PxPosition((fontSizeInPx * startOffset), fontSizeInPx)
)
}
}
@@ -287,7 +286,7 @@
// Assert.
assertThat(coordinates).isEqualTo(
- PxPosition((fontSizeInPx * startOffset).px, fontSizeInPx.px)
+ PxPosition((fontSizeInPx * startOffset), fontSizeInPx)
)
}
}
@@ -341,7 +340,7 @@
// Assert.
assertThat(coordinates).isEqualTo(
- PxPosition((fontSizeInPx * (text.length - 1 - startOffset)).px, fontSizeInPx.px)
+ PxPosition((fontSizeInPx * (text.length - 1 - startOffset)), fontSizeInPx)
)
}
}
@@ -395,7 +394,7 @@
// Assert.
assertThat(coordinates).isEqualTo(
- PxPosition((fontSizeInPx * (text.length - 1 - startOffset)).px, fontSizeInPx.px)
+ PxPosition((fontSizeInPx * (text.length - 1 - startOffset)), fontSizeInPx)
)
}
}
@@ -451,7 +450,7 @@
// Assert.
assertThat(coordinates).isEqualTo(
- PxPosition((fontSizeInPx * (text.length)).px, fontSizeInPx.px)
+ PxPosition((fontSizeInPx * (text.length)), fontSizeInPx)
)
}
}
@@ -507,7 +506,7 @@
// Assert.
assertThat(coordinates).isEqualTo(
- PxPosition((fontSizeInPx * (textLtr.length)).px, fontSizeInPx.px)
+ PxPosition((fontSizeInPx * (textLtr.length)), fontSizeInPx)
)
}
}
@@ -561,7 +560,7 @@
// Assert.
assertThat(coordinates).isEqualTo(
- PxPosition((fontSizeInPx * endOffset).px, fontSizeInPx.px)
+ PxPosition((fontSizeInPx * endOffset), fontSizeInPx)
)
}
}
@@ -615,7 +614,7 @@
// Assert.
assertThat(coordinates).isEqualTo(
- PxPosition((fontSizeInPx * endOffset).px, fontSizeInPx.px)
+ PxPosition((fontSizeInPx * endOffset), fontSizeInPx)
)
}
}
@@ -669,7 +668,7 @@
// Assert.
assertThat(coordinates).isEqualTo(
- PxPosition((fontSizeInPx * (text.length - 1 - endOffset)).px, fontSizeInPx.px)
+ PxPosition((fontSizeInPx * (text.length - 1 - endOffset)), fontSizeInPx)
)
}
}
@@ -723,7 +722,7 @@
// Assert.
assertThat(coordinates).isEqualTo(
- PxPosition((fontSizeInPx * (text.length - 1 - endOffset)).px, fontSizeInPx.px)
+ PxPosition((fontSizeInPx * (text.length - 1 - endOffset)), fontSizeInPx)
)
}
}
@@ -779,7 +778,7 @@
// Assert.
assertThat(coordinates).isEqualTo(
- PxPosition((fontSizeInPx * (textLtr.length)).px, fontSizeInPx.px)
+ PxPosition((fontSizeInPx * (textLtr.length)), fontSizeInPx)
)
}
}
@@ -835,7 +834,7 @@
// Assert.
assertThat(coordinates).isEqualTo(
- PxPosition((fontSizeInPx * (text.length)).px, fontSizeInPx.px)
+ PxPosition((fontSizeInPx * (text.length)), fontSizeInPx)
)
}
}
@@ -1010,7 +1009,7 @@
density = defaultDensity
)
- val start = PxPosition((fontSizeInPx * 2).px, (fontSizeInPx / 2).px)
+ val start = PxPosition((fontSizeInPx * 2), (fontSizeInPx / 2))
val end = start
// Act.
@@ -1049,7 +1048,7 @@
density = defaultDensity
)
- val start = PxPosition((fontSizeInPx * 2).px, (fontSizeInPx / 2).px)
+ val start = PxPosition((fontSizeInPx * 2), (fontSizeInPx / 2))
val end = start
// Act.
@@ -1090,8 +1089,8 @@
val rawStartOffset = text.indexOf('e')
val rawEndOffset = text.indexOf('r')
- val start = PxPosition((fontSizeInPx * rawStartOffset).px, (fontSizeInPx / 2).px)
- val end = PxPosition((fontSizeInPx * rawEndOffset).px, (fontSizeInPx / 2).px)
+ val start = PxPosition((fontSizeInPx * rawStartOffset), (fontSizeInPx / 2))
+ val end = PxPosition((fontSizeInPx * rawEndOffset), (fontSizeInPx / 2))
// Act.
val textSelectionInfo = getTextSelectionInfo(
@@ -1133,8 +1132,8 @@
val rawStartOffset = text.indexOf('r')
val rawEndOffset = text.indexOf('e')
- val start = PxPosition((fontSizeInPx * rawStartOffset).px, (fontSizeInPx / 2).px)
- val end = PxPosition((fontSizeInPx * rawEndOffset).px, (fontSizeInPx / 2).px)
+ val start = PxPosition((fontSizeInPx * rawStartOffset), (fontSizeInPx / 2))
+ val end = PxPosition((fontSizeInPx * rawEndOffset), (fontSizeInPx / 2))
// Act.
val textSelectionInfo = getTextSelectionInfo(
@@ -1178,8 +1177,8 @@
// "llo wor" is selected.
val startOffset = text.indexOf("l")
val endOffset = text.indexOf("r") + 1
- val start = PxPosition((fontSizeInPx * startOffset).px, (fontSizeInPx / 2).px)
- val end = PxPosition((fontSizeInPx * endOffset).px, (fontSizeInPx / 2).px)
+ val start = PxPosition((fontSizeInPx * startOffset), (fontSizeInPx / 2))
+ val end = PxPosition((fontSizeInPx * endOffset), (fontSizeInPx / 2))
// Act.
val textSelectionInfo = getTextSelectionInfo(
@@ -1223,12 +1222,12 @@
val startOffset = text.indexOf("\u05D1")
val endOffset = text.indexOf("\u05D3") + 1
val start = PxPosition(
- (fontSizeInPx * (text.length - 1 - startOffset)).px,
- (fontSizeInPx / 2).px
+ (fontSizeInPx * (text.length - 1 - startOffset)),
+ (fontSizeInPx / 2)
)
val end = PxPosition(
- (fontSizeInPx * (text.length - 1 - endOffset)).px,
- (fontSizeInPx / 2).px
+ (fontSizeInPx * (text.length - 1 - endOffset)),
+ (fontSizeInPx / 2)
)
// Act.
@@ -1275,12 +1274,12 @@
val startOffset = text.indexOf("l")
val endOffset = text.indexOf("\u05D2") + 1
val start = PxPosition(
- (fontSizeInPx * startOffset).px,
- (fontSizeInPx / 2).px
+ (fontSizeInPx * startOffset),
+ (fontSizeInPx / 2)
)
val end = PxPosition(
- (fontSizeInPx * (textLtr.length + text.length - endOffset)).px,
- (fontSizeInPx / 2).px
+ (fontSizeInPx * (textLtr.length + text.length - endOffset)),
+ (fontSizeInPx / 2)
)
// Act.
@@ -1322,8 +1321,8 @@
// "llo wor" is selected.
val startOffset = text.indexOf("r") + 1
val endOffset = text.indexOf("l")
- val start = PxPosition((fontSizeInPx * startOffset).px, (fontSizeInPx / 2).px)
- val end = PxPosition((fontSizeInPx * endOffset).px, (fontSizeInPx / 2).px)
+ val start = PxPosition((fontSizeInPx * startOffset), (fontSizeInPx / 2))
+ val end = PxPosition((fontSizeInPx * endOffset), (fontSizeInPx / 2))
// Act.
val textSelectionInfo = getTextSelectionInfo(
selectionCoordinates = Pair(start, end),
@@ -1364,12 +1363,12 @@
val startOffset = text.indexOf("\u05D3") + 1
val endOffset = text.indexOf("\u05D1")
val start = PxPosition(
- (fontSizeInPx * (text.length - 1 - startOffset)).px,
- (fontSizeInPx / 2).px
+ (fontSizeInPx * (text.length - 1 - startOffset)),
+ (fontSizeInPx / 2)
)
val end = PxPosition(
- (fontSizeInPx * (text.length - 1 - endOffset)).px,
- (fontSizeInPx / 2).px
+ (fontSizeInPx * (text.length - 1 - endOffset)),
+ (fontSizeInPx / 2)
)
// Act.
@@ -1414,12 +1413,12 @@
val startOffset = text.indexOf("\u05D2") + 1
val endOffset = text.indexOf("l")
val start = PxPosition(
- (fontSizeInPx * (textLtr.length + text.length - startOffset)).px,
- (fontSizeInPx / 2).px
+ (fontSizeInPx * (textLtr.length + text.length - startOffset)),
+ (fontSizeInPx / 2)
)
val end = PxPosition(
- (fontSizeInPx * endOffset).px,
- (fontSizeInPx / 2).px
+ (fontSizeInPx * endOffset),
+ (fontSizeInPx / 2)
)
// Act.
@@ -1476,8 +1475,8 @@
handlesCrossed = false
)
// "l" is selected.
- val start = PxPosition((fontSizeInPx * oldStartOffset).px, (fontSizeInPx / 2).px)
- val end = PxPosition((fontSizeInPx * oldStartOffset).px, (fontSizeInPx / 2).px)
+ val start = PxPosition((fontSizeInPx * oldStartOffset), (fontSizeInPx / 2))
+ val end = PxPosition((fontSizeInPx * oldStartOffset), (fontSizeInPx / 2))
// Act.
val textSelectionInfo = getTextSelectionInfo(
@@ -1533,12 +1532,12 @@
)
// "\u05D1" is selected.
val start = PxPosition(
- (fontSizeInPx * (text.length - 1 - oldStartOffset)).px,
- (fontSizeInPx / 2).px
+ (fontSizeInPx * (text.length - 1 - oldStartOffset)),
+ (fontSizeInPx / 2)
)
val end = PxPosition(
- (fontSizeInPx * (text.length - 1 - oldStartOffset)).px,
- (fontSizeInPx / 2).px
+ (fontSizeInPx * (text.length - 1 - oldStartOffset)),
+ (fontSizeInPx / 2)
)
// Act.
@@ -1594,8 +1593,8 @@
handlesCrossed = false
)
// The Space after "o" is selected.
- val start = PxPosition((fontSizeInPx * oldEndOffset).px, (fontSizeInPx / 2).px)
- val end = PxPosition((fontSizeInPx * oldEndOffset).px, (fontSizeInPx / 2).px)
+ val start = PxPosition((fontSizeInPx * oldEndOffset), (fontSizeInPx / 2))
+ val end = PxPosition((fontSizeInPx * oldEndOffset), (fontSizeInPx / 2))
// Act.
val textSelectionInfo = getTextSelectionInfo(
@@ -1651,8 +1650,8 @@
handlesCrossed = true
)
// "l" is selected.
- val start = PxPosition((fontSizeInPx * oldEndOffset).px, (fontSizeInPx / 2).px)
- val end = PxPosition((fontSizeInPx * oldEndOffset).px, (fontSizeInPx / 2).px)
+ val start = PxPosition((fontSizeInPx * oldEndOffset), (fontSizeInPx / 2))
+ val end = PxPosition((fontSizeInPx * oldEndOffset), (fontSizeInPx / 2))
// Act.
val textSelectionInfo = getTextSelectionInfo(
@@ -1708,8 +1707,8 @@
handlesCrossed = false
)
// "e" should be selected.
- val start = PxPosition((fontSizeInPx * oldEndOffset).px, (fontSizeInPx / 2).px)
- val end = PxPosition((fontSizeInPx * oldEndOffset).px, (fontSizeInPx / 2).px)
+ val start = PxPosition((fontSizeInPx * oldEndOffset), (fontSizeInPx / 2))
+ val end = PxPosition((fontSizeInPx * oldEndOffset), (fontSizeInPx / 2))
// Act.
val textSelectionInfo = getTextSelectionInfo(
@@ -1755,8 +1754,8 @@
handlesCrossed = true
)
// "e" should be selected.
- val start = PxPosition((fontSizeInPx * oldEndOffset).px, (fontSizeInPx / 2).px)
- val end = PxPosition((fontSizeInPx * oldEndOffset).px, (fontSizeInPx / 2).px)
+ val start = PxPosition((fontSizeInPx * oldEndOffset), (fontSizeInPx / 2))
+ val end = PxPosition((fontSizeInPx * oldEndOffset), (fontSizeInPx / 2))
// Act.
val textSelectionInfo = getTextSelectionInfo(
@@ -1802,10 +1801,10 @@
handlesCrossed = false
)
// "d" should be selected.
- val start = PxPosition((fontSizeInPx * oldEndOffset).px - (fontSizeInPx / 2).px,
- (fontSizeInPx / 2).px)
- val end = PxPosition((fontSizeInPx * oldEndOffset).px - 1.px,
- (fontSizeInPx / 2).px)
+ val start = PxPosition((fontSizeInPx * oldEndOffset) - (fontSizeInPx / 2),
+ (fontSizeInPx / 2))
+ val end = PxPosition((fontSizeInPx * oldEndOffset) - 1,
+ (fontSizeInPx / 2))
// Act.
val textSelectionInfo = getTextSelectionInfo(
@@ -1851,8 +1850,8 @@
handlesCrossed = true
)
// "e" should be selected.
- val start = PxPosition((fontSizeInPx * oldEndOffset).px, (fontSizeInPx / 2).px)
- val end = PxPosition((fontSizeInPx * oldEndOffset).px, (fontSizeInPx / 2).px)
+ val start = PxPosition((fontSizeInPx * oldEndOffset), (fontSizeInPx / 2))
+ val end = PxPosition((fontSizeInPx * oldEndOffset), (fontSizeInPx / 2))
// Act.
val textSelectionInfo = getTextSelectionInfo(
@@ -1898,8 +1897,8 @@
handlesCrossed = true
)
// The space after "o" is selected.
- val start = PxPosition((fontSizeInPx * oldStartOffset).px, (fontSizeInPx / 2).px)
- val end = PxPosition((fontSizeInPx * oldStartOffset).px, (fontSizeInPx / 2).px)
+ val start = PxPosition((fontSizeInPx * oldStartOffset), (fontSizeInPx / 2))
+ val end = PxPosition((fontSizeInPx * oldStartOffset), (fontSizeInPx / 2))
// Act.
val textSelectionInfo = getTextSelectionInfo(
@@ -1955,8 +1954,8 @@
handlesCrossed = false
)
// "e" should be selected.
- val start = PxPosition((fontSizeInPx * oldStartOffset).px, (fontSizeInPx / 2).px)
- val end = PxPosition((fontSizeInPx * oldStartOffset).px, (fontSizeInPx / 2).px)
+ val start = PxPosition((fontSizeInPx * oldStartOffset), (fontSizeInPx / 2))
+ val end = PxPosition((fontSizeInPx * oldStartOffset), (fontSizeInPx / 2))
// Act.
val textSelectionInfo = getTextSelectionInfo(
@@ -2002,8 +2001,8 @@
handlesCrossed = true
)
// "e" should be selected.
- val start = PxPosition((fontSizeInPx * oldStartOffset).px, (fontSizeInPx / 2).px)
- val end = PxPosition((fontSizeInPx * oldStartOffset).px, (fontSizeInPx / 2).px)
+ val start = PxPosition((fontSizeInPx * oldStartOffset), (fontSizeInPx / 2))
+ val end = PxPosition((fontSizeInPx * oldStartOffset), (fontSizeInPx / 2))
// Act.
val textSelectionInfo = getTextSelectionInfo(
@@ -2049,10 +2048,10 @@
handlesCrossed = false
)
// "h" should be selected.
- val start = PxPosition((fontSizeInPx * oldStartOffset).px,
- (fontSizeInPx / 2).px)
- val end = PxPosition((fontSizeInPx * oldStartOffset).px,
- (fontSizeInPx / 2).px)
+ val start = PxPosition((fontSizeInPx * oldStartOffset),
+ (fontSizeInPx / 2))
+ val end = PxPosition((fontSizeInPx * oldStartOffset),
+ (fontSizeInPx / 2))
// Act.
val textSelectionInfo = getTextSelectionInfo(
@@ -2098,10 +2097,10 @@
handlesCrossed = true
)
// "d" should be selected.
- val start = PxPosition((fontSizeInPx * oldStartOffset).px - 1.px,
- (fontSizeInPx / 2).px)
- val end = PxPosition((fontSizeInPx * oldStartOffset).px - 1.px,
- (fontSizeInPx / 2).px)
+ val start = PxPosition((fontSizeInPx * oldStartOffset) - 1,
+ (fontSizeInPx / 2))
+ val end = PxPosition((fontSizeInPx * oldStartOffset) - 1,
+ (fontSizeInPx / 2))
// Act.
val textSelectionInfo = getTextSelectionInfo(
@@ -2131,8 +2130,8 @@
)
// "hello w" is selected.
val endOffset = text.indexOf("w") + 1
- val start = PxPosition(-50.px, -50.px)
- val end = PxPosition((fontSizeInPx * endOffset).px, (fontSizeInPx / 2).px)
+ val start = PxPosition(-50f, -50f)
+ val end = PxPosition((fontSizeInPx * endOffset), (fontSizeInPx / 2))
// Act.
val textSelectionInfo = getTextSelectionInfo(
@@ -2171,9 +2170,9 @@
)
// "o world" is selected.
val startOffset = text.indexOf("o")
- val start = PxPosition((fontSizeInPx * startOffset).px, (fontSizeInPx / 2).px)
- val end = PxPosition((fontSizeInPx * text.length * 2).px, (fontSizeInPx * 2)
- .px)
+ val start = PxPosition((fontSizeInPx * startOffset), (fontSizeInPx / 2))
+ val end = PxPosition((fontSizeInPx * text.length * 2), (fontSizeInPx * 2)
+ )
// Act.
val textSelectionInfo = getTextSelectionInfo(
@@ -2213,8 +2212,8 @@
// "world" is selected.
val endOffset = text.indexOf("w")
val start =
- PxPosition((fontSizeInPx * text.length * 2).px, (fontSizeInPx * 2).px)
- val end = PxPosition((fontSizeInPx * endOffset).px, (fontSizeInPx / 2).px)
+ PxPosition((fontSizeInPx * text.length * 2), (fontSizeInPx * 2))
+ val end = PxPosition((fontSizeInPx * endOffset), (fontSizeInPx / 2))
// Act.
val textSelectionInfo = getTextSelectionInfo(
@@ -2255,8 +2254,8 @@
// "hell" is selected.
val startOffset = text.indexOf("o")
val start =
- PxPosition((fontSizeInPx * startOffset).px, (fontSizeInPx / 2).px)
- val end = PxPosition(-50.px, -50.px)
+ PxPosition((fontSizeInPx * startOffset), (fontSizeInPx / 2))
+ val end = PxPosition(-50f, -50f)
// Act.
val textSelectionInfo = getTextSelectionInfo(
@@ -2293,8 +2292,8 @@
fontSize = fontSize,
density = defaultDensity
)
- val start = PxPosition(-50.px, -50.px)
- val end = PxPosition(-20.px, -20.px)
+ val start = PxPosition(-50f, -50f)
+ val end = PxPosition(-20f, -20f)
// Act.
val textSelectionInfo = getTextSelectionInfo(
selectionCoordinates = Pair(start, end),
diff --git a/ui/ui-text/src/main/java/androidx/ui/text/CoreText.kt b/ui/ui-text/src/main/java/androidx/ui/text/CoreText.kt
index 9a4de2d..d5e5ccf 100644
--- a/ui/ui-text/src/main/java/androidx/ui/text/CoreText.kt
+++ b/ui/ui-text/src/main/java/androidx/ui/text/CoreText.kt
@@ -47,7 +47,6 @@
import androidx.ui.unit.ipx
import androidx.ui.unit.max
import androidx.ui.unit.min
-import androidx.ui.unit.px
import androidx.ui.util.fastForEach
import kotlin.math.floor
import kotlin.math.roundToInt
@@ -209,7 +208,7 @@
maxHeight = floor(it.height).toInt().ipx
)
),
- PxPosition(it.left.px, it.top.px)
+ PxPosition(it.left, it.top)
)
}
}
@@ -269,7 +268,7 @@
) { children, constrains, _ ->
val placeables = children.map { it.measure(constrains) }
layout(width = constrains.maxWidth, height = constrains.maxHeight) {
- placeables.fastForEach { it.place(0.px, 0.px) }
+ placeables.fastForEach { it.place(0.ipx, 0.ipx) }
}
}
}
diff --git a/ui/ui-text/src/main/java/androidx/ui/text/TextFieldDelegate.kt b/ui/ui-text/src/main/java/androidx/ui/text/TextFieldDelegate.kt
index 53f4185..e480ac7 100644
--- a/ui/ui-text/src/main/java/androidx/ui/text/TextFieldDelegate.kt
+++ b/ui/ui-text/src/main/java/androidx/ui/text/TextFieldDelegate.kt
@@ -42,7 +42,6 @@
import androidx.ui.unit.IntPx
import androidx.ui.unit.PxPosition
import androidx.ui.unit.ipx
-import androidx.ui.unit.px
import kotlin.math.ceil
import kotlin.math.roundToInt
@@ -183,13 +182,13 @@
)
Rect(0f, 0f, 1.0f, lineHeightForEmptyText.value.toFloat())
}
- val globalLT = layoutCoordinates.localToRoot(PxPosition(bbox.left.px, bbox.top.px))
+ val globalLT = layoutCoordinates.localToRoot(PxPosition(bbox.left, bbox.top))
textInputService.notifyFocusedRect(
token,
Rect.fromLTWH(
- globalLT.x.value,
- globalLT.y.value,
+ globalLT.x,
+ globalLT.y,
bbox.width,
bbox.height
)
diff --git a/ui/ui-text/src/main/java/androidx/ui/text/selection/SelectionMode.kt b/ui/ui-text/src/main/java/androidx/ui/text/selection/SelectionMode.kt
index c726621..11a5626 100644
--- a/ui/ui-text/src/main/java/androidx/ui/text/selection/SelectionMode.kt
+++ b/ui/ui-text/src/main/java/androidx/ui/text/selection/SelectionMode.kt
@@ -36,19 +36,19 @@
): Boolean {
// When the end of the selection is above the top of the composable, the composable is outside
// of the selection range.
- if (end.y.value < bounds.top) return false
+ if (end.y < bounds.top) return false
// When the end of the selection is on the left of the composable, and not below the bottom
// of composable, the composable is outside of the selection range.
- if (end.x.value < bounds.left && end.y.value < bounds.bottom) return false
+ if (end.x < bounds.left && end.y < bounds.bottom) return false
// When the start of the selection is below the bottom of the composable, the composable is
// outside of the selection range.
- if (start.y.value >= bounds.bottom) return false
+ if (start.y >= bounds.bottom) return false
// When the start of the selection is on the right of the composable, and not above the top
// of the composable, the composable is outside of the selection range.
- if (start.x.value >= bounds.right && start.y.value >= bounds.top) return false
+ if (start.x >= bounds.right && start.y >= bounds.top) return false
return true
}
@@ -58,8 +58,8 @@
start: PxPosition,
end: PxPosition
): Boolean {
- if (start.y.value >= bounds.top && start.y.value < bounds.bottom &&
- end.y.value >= bounds.top && end.y.value < bounds.bottom
+ if (start.y >= bounds.top && start.y < bounds.bottom &&
+ end.y >= bounds.top && end.y < bounds.bottom
) {
// When the start and end of the selection are in the same row of widgets, check if
// x coordinates of the start and end are crossed each other.
@@ -85,19 +85,19 @@
): Boolean {
// When the end of the selection is on the left of the composable, the composable is outside of
// the selection range.
- if (end.x.value < bounds.left) return false
+ if (end.x < bounds.left) return false
// When the end of the selection is on the top of the composable, and the not on the right
// of the composable, the composable is outside of the selection range.
- if (end.y.value < bounds.top && end.x.value < bounds.right) return false
+ if (end.y < bounds.top && end.x < bounds.right) return false
// When the start of the selection is on the right of the composable, the composable is outside
// of the selection range.
- if (start.x.value >= bounds.right) return false
+ if (start.x >= bounds.right) return false
// When the start of the selection is below the composable, and not on the left of the
// composable, the composable is outside of the selection range.
- if (start.y.value >= bounds.bottom && start.x.value >= bounds.left) return false
+ if (start.y >= bounds.bottom && start.x >= bounds.left) return false
return true
}
@@ -107,8 +107,8 @@
start: PxPosition,
end: PxPosition
): Boolean {
- if (start.x.value >= bounds.left && start.x.value < bounds.right &&
- end.x.value >= bounds.left && end.x.value < bounds.right
+ if (start.x >= bounds.left && start.x < bounds.right &&
+ end.x >= bounds.left && end.x < bounds.right
) {
// When the start and end of the selection are in the same column of widgets,
// check if y coordinates of the start and end are crossed each other.
diff --git a/ui/ui-text/src/main/java/androidx/ui/text/selection/TextSelectionDelegate.kt b/ui/ui-text/src/main/java/androidx/ui/text/selection/TextSelectionDelegate.kt
index 0a7e678..b944012 100644
--- a/ui/ui-text/src/main/java/androidx/ui/text/selection/TextSelectionDelegate.kt
+++ b/ui/ui-text/src/main/java/androidx/ui/text/selection/TextSelectionDelegate.kt
@@ -145,10 +145,10 @@
val lastOffset = textLayoutResult.layoutInput.text.text.length
val containsWholeSelectionStart =
- bounds.contains(Offset(startPosition.x.value, startPosition.y.value))
+ bounds.contains(Offset(startPosition.x, startPosition.y))
val containsWholeSelectionEnd =
- bounds.contains(Offset(endPosition.x.value, endPosition.y.value))
+ bounds.contains(Offset(endPosition.x, endPosition.y))
val rawStartOffset =
if (containsWholeSelectionStart)
diff --git a/ui/ui-text/src/test/java/androidx/ui/text/DragEventTrackerTest.kt b/ui/ui-text/src/test/java/androidx/ui/text/DragEventTrackerTest.kt
index 49fffd3..80cabf9 100644
--- a/ui/ui-text/src/test/java/androidx/ui/text/DragEventTrackerTest.kt
+++ b/ui/ui-text/src/test/java/androidx/ui/text/DragEventTrackerTest.kt
@@ -17,7 +17,6 @@
package androidx.ui.text
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.px
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
@@ -29,38 +28,38 @@
fun test_not_moving() {
val tracker = DragEventTracker()
- tracker.init(PxPosition(10.px, 20.px))
- assertEquals(PxPosition(10.px, 20.px), tracker.getPosition())
+ tracker.init(PxPosition(10f, 20f))
+ assertEquals(PxPosition(10f, 20f), tracker.getPosition())
}
@Test
fun test_drag_one_distance() {
val tracker = DragEventTracker()
- tracker.init(PxPosition(10.px, 20.px))
- tracker.onDrag(PxPosition(30.px, 40.px))
- assertEquals(PxPosition(40.px, 60.px), tracker.getPosition())
+ tracker.init(PxPosition(10f, 20f))
+ tracker.onDrag(PxPosition(30f, 40f))
+ assertEquals(PxPosition(40f, 60f), tracker.getPosition())
}
@Test
fun test_drag_two_distance() {
val tracker = DragEventTracker()
- tracker.init(PxPosition(10.px, 20.px))
- tracker.onDrag(PxPosition(30.px, 40.px))
- tracker.onDrag(PxPosition(50.px, 60.px))
- assertEquals(PxPosition(60.px, 80.px), tracker.getPosition())
+ tracker.init(PxPosition(10f, 20f))
+ tracker.onDrag(PxPosition(30f, 40f))
+ tracker.onDrag(PxPosition(50f, 60f))
+ assertEquals(PxPosition(60f, 80f), tracker.getPosition())
}
@Test
fun test_drag_twice() {
val tracker = DragEventTracker()
- tracker.init(PxPosition(10.px, 20.px))
- tracker.onDrag(PxPosition(30.px, 40.px))
+ tracker.init(PxPosition(10f, 20f))
+ tracker.onDrag(PxPosition(30f, 40f))
- tracker.init(PxPosition(50.px, 60.px))
- tracker.onDrag(PxPosition(70.px, 80.px))
- assertEquals(PxPosition(120.px, 140.px), tracker.getPosition())
+ tracker.init(PxPosition(50f, 60f))
+ tracker.onDrag(PxPosition(70f, 80f))
+ assertEquals(PxPosition(120f, 140f), tracker.getPosition())
}
}
\ No newline at end of file
diff --git a/ui/ui-text/src/test/java/androidx/ui/text/TextFieldDelegateTest.kt b/ui/ui-text/src/test/java/androidx/ui/text/TextFieldDelegateTest.kt
index 476a826..606a496 100644
--- a/ui/ui-text/src/test/java/androidx/ui/text/TextFieldDelegateTest.kt
+++ b/ui/ui-text/src/test/java/androidx/ui/text/TextFieldDelegateTest.kt
@@ -112,7 +112,7 @@
@Test
fun test_on_release() {
- val position = PxPosition(100.px, 200.px)
+ val position = PxPosition(100f, 200f)
val offset = 10
val dummyEditorState = EditorValue(text = "Hello, World", selection = TextRange(1, 1))
val dummyInputSessionToken = 10 // We are not using this value in this test. Just dummy.
@@ -147,7 +147,7 @@
@Test
fun test_on_release_do_not_place_cursor_if_focus_is_out() {
- val position = PxPosition(100.px, 200.px)
+ val position = PxPosition(100f, 200f)
val offset = 10
val dummyInputSessionToken = 10 // We are not using this value in this test. Just dummy.
@@ -231,7 +231,7 @@
fun notify_focused_rect() {
val dummyRect = Rect(0f, 1f, 2f, 3f)
whenever(textLayoutResult.getBoundingBox(any())).thenReturn(dummyRect)
- val dummyPoint = PxPosition(5.px, 6.px)
+ val dummyPoint = PxPosition(5f, 6f)
whenever(layoutCoordinates.localToRoot(any())).thenReturn(dummyPoint)
val dummyEditorState = EditorValue(text = "Hello, World", selection = TextRange(1, 1))
val dummyInputSessionToken = 10 // We are not using this value in this test. Just dummy.
@@ -269,7 +269,7 @@
fun notify_rect_tail() {
val dummyRect = Rect(0f, 1f, 2f, 3f)
whenever(textLayoutResult.getBoundingBox(any())).thenReturn(dummyRect)
- val dummyPoint = PxPosition(5.px, 6.px)
+ val dummyPoint = PxPosition(5f, 6f)
whenever(layoutCoordinates.localToRoot(any())).thenReturn(dummyPoint)
val dummyEditorState = EditorValue(text = "Hello, World", selection = TextRange(12, 12))
val dummyInputSessionToken = 10 // We are not using this value in this test. Just dummy.
@@ -316,7 +316,7 @@
@Test
fun check_notify_rect_uses_offset_map() {
val dummyRect = Rect(0f, 1f, 2f, 3f)
- val dummyPoint = PxPosition(5.px, 6.px)
+ val dummyPoint = PxPosition(5f, 6f)
val dummyEditorState = EditorValue(text = "Hello, World", selection = TextRange(1, 3))
val dummyInputSessionToken = 10 // We are not using this value in this test. Just dummy.
whenever(textLayoutResult.getBoundingBox(any())).thenReturn(dummyRect)
@@ -338,7 +338,7 @@
@Test
fun check_on_release_uses_offset_map() {
- val position = PxPosition(100.px, 200.px)
+ val position = PxPosition(100f, 200f)
val offset = 10
val dummyEditorState = EditorValue(text = "Hello, World", selection = TextRange(1, 1))
val dummyInputSessionToken = 10 // We are not using this value in this test. Just dummy.
diff --git a/ui/ui-tooling/src/androidTest/java/androidx/ui/tooling/ComposeViewAdapterTest.kt b/ui/ui-tooling/src/androidTest/java/androidx/ui/tooling/ComposeViewAdapterTest.kt
index 2d35e6a..888710b 100644
--- a/ui/ui-tooling/src/androidTest/java/androidx/ui/tooling/ComposeViewAdapterTest.kt
+++ b/ui/ui-tooling/src/androidTest/java/androidx/ui/tooling/ComposeViewAdapterTest.kt
@@ -24,6 +24,7 @@
import androidx.ui.tooling.test.R
import org.junit.Assert.assertArrayEquals
import org.junit.Assert.assertTrue
+import org.junit.Assert.fail
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@@ -56,6 +57,36 @@
}
@Test
+ fun setClockTimeWithAnimationInspection() {
+ activityTestRule.runOnUiThread {
+ composeViewAdapter.init("androidx.ui.tooling.SimpleComposablePreviewKt",
+ "SimpleComposablePreview", animationClockStartTime = 0L)
+ }
+
+ activityTestRule.runOnUiThread {
+ composeViewAdapter.setClockTime(100) // Sanity-check. The call should succeed.
+ }
+ }
+
+ @Test
+ fun setClockTimeWithoutAnimationInspection() {
+ activityTestRule.runOnUiThread {
+ composeViewAdapter.init("androidx.ui.tooling.SimpleComposablePreviewKt",
+ "SimpleComposablePreview")
+ }
+
+ activityTestRule.runOnUiThread {
+ try {
+ composeViewAdapter.setClockTime(100)
+ fail("Expected to throw an Exception")
+ } catch (e: IllegalStateException) {
+ assertTrue(e.message!!.contains("This method is expected to be called from " +
+ "Android Studio via reflection, otherwise 'clock' is expected to be null."))
+ }
+ }
+ }
+
+ @Test
fun instantiateComposeViewAdapter() {
val viewInfos = assertRendersCorrectly(
"androidx.ui.tooling.SimpleComposablePreviewKt",
diff --git a/ui/ui-tooling/src/androidTest/java/androidx/ui/tooling/ModifierInfoTest.kt b/ui/ui-tooling/src/androidTest/java/androidx/ui/tooling/ModifierInfoTest.kt
index 790ad32..e9d9588 100644
--- a/ui/ui-tooling/src/androidTest/java/androidx/ui/tooling/ModifierInfoTest.kt
+++ b/ui/ui-tooling/src/androidTest/java/androidx/ui/tooling/ModifierInfoTest.kt
@@ -31,7 +31,6 @@
import androidx.ui.layout.Column
import androidx.ui.layout.padding
import androidx.ui.layout.size
-import androidx.ui.unit.px
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test
@@ -50,8 +49,8 @@
show {
Inspectable(slotTableRecord) {
with(DensityAmbient.current) {
- val px10 = 10.px.toDp()
- val px5 = 5.px.toDp()
+ val px10 = 10f.toDp()
+ val px5 = 5f.toDp()
Box {
Column(Modifier.padding(px10).drawLayer().drawBackground(Color.Blue)) {
Box(Modifier.padding(px5).size(px5))
@@ -80,13 +79,13 @@
assertEquals(2, boxModifierInfo.size)
assertTrue("Box should only have LayoutModifiers, but the first was " +
"${boxModifierInfo[0].modifier}", boxModifierInfo[0].modifier is LayoutModifier)
- assertEquals(10.px, boxModifierInfo[0].coordinates.positionInRoot.x)
+ assertEquals(10f, boxModifierInfo[0].coordinates.positionInRoot.x)
assertTrue("Box should only have LayoutModifiers, but the second was " +
"${boxModifierInfo[1].modifier}",
boxModifierInfo[1].modifier is LayoutModifier
)
- assertEquals(15.px, boxModifierInfo[1].coordinates.positionInRoot.x)
+ assertEquals(15f, boxModifierInfo[1].coordinates.positionInRoot.x)
val columnModifierInfo = modifierInfo[1]
assertEquals(3, columnModifierInfo.size)
@@ -95,20 +94,20 @@
"but was ${columnModifierInfo[0].modifier}",
columnModifierInfo[0].modifier is LayoutModifier
)
- assertEquals(0.px, columnModifierInfo[0].coordinates.positionInRoot.x)
+ assertEquals(0f, columnModifierInfo[0].coordinates.positionInRoot.x)
assertTrue(
"The second modifier in the column should be a DrawLayerModifier" +
"but was ${columnModifierInfo[1].modifier}",
columnModifierInfo[1].modifier is DrawLayerModifier
)
assertTrue(columnModifierInfo[1].extra is OwnedLayer)
- assertEquals(10.px, columnModifierInfo[1].coordinates.positionInRoot.x)
+ assertEquals(10f, columnModifierInfo[1].coordinates.positionInRoot.x)
assertTrue(
"The third modifier in the column should be a DrawModifier" +
"but was ${columnModifierInfo[2].modifier}",
columnModifierInfo[2].modifier is DrawModifier
)
- assertEquals(10.px, columnModifierInfo[2].coordinates.positionInRoot.x)
+ assertEquals(10f, columnModifierInfo[2].coordinates.positionInRoot.x)
}
}
}
\ No newline at end of file
diff --git a/ui/ui-tooling/src/androidTest/java/androidx/ui/tooling/animation/PreviewAnimationClockTest.kt b/ui/ui-tooling/src/androidTest/java/androidx/ui/tooling/animation/PreviewAnimationClockTest.kt
new file mode 100644
index 0000000..dc097d9
--- /dev/null
+++ b/ui/ui-tooling/src/androidTest/java/androidx/ui/tooling/animation/PreviewAnimationClockTest.kt
@@ -0,0 +1,30 @@
+/*
+ * 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 androidx.ui.tooling.animation
+
+import androidx.ui.tooling.preview.animation.PreviewAnimationClock
+import org.junit.Assert.assertEquals
+import org.junit.Test
+
+class PreviewAnimationClockTest {
+ @Test
+ fun setClockTimeIsRelative() {
+ val previewAnimationClock = PreviewAnimationClock(100)
+ previewAnimationClock.setClockTime(300)
+ assertEquals(400, previewAnimationClock.clock.clockTimeMillis)
+ }
+}
\ No newline at end of file
diff --git a/ui/ui-tooling/src/main/java/androidx/ui/tooling/SlotTree.kt b/ui/ui-tooling/src/main/java/androidx/ui/tooling/SlotTree.kt
index ad408c2..a2fedcb 100644
--- a/ui/ui-tooling/src/main/java/androidx/ui/tooling/SlotTree.kt
+++ b/ui/ui-tooling/src/main/java/androidx/ui/tooling/SlotTree.kt
@@ -29,8 +29,8 @@
import androidx.ui.unit.ipx
import androidx.ui.unit.max
import androidx.ui.unit.min
-import androidx.ui.unit.round
import java.lang.reflect.Field
+import kotlin.math.roundToInt
/**
* A group in the slot table. Represents either a call or an emitted node.
@@ -180,8 +180,8 @@
}
val position = node.coordinates.globalPosition
val size = node.coordinates.size
- val left = position.x.round()
- val top = position.y.round()
+ val left = position.x.roundToInt().ipx
+ val top = position.y.roundToInt().ipx
val right = left + size.width
val bottom = top + size.height
return IntPxBounds(left = left, top = top, right = right, bottom = bottom)
diff --git a/ui/ui-tooling/src/main/java/androidx/ui/tooling/preview/ComposeViewAdapter.kt b/ui/ui-tooling/src/main/java/androidx/ui/tooling/preview/ComposeViewAdapter.kt
index 2eb18cc..68b02f1 100644
--- a/ui/ui-tooling/src/main/java/androidx/ui/tooling/preview/ComposeViewAdapter.kt
+++ b/ui/ui-tooling/src/main/java/androidx/ui/tooling/preview/ComposeViewAdapter.kt
@@ -29,6 +29,7 @@
import androidx.compose.Providers
import androidx.compose.Recomposer
import androidx.compose.currentComposer
+import androidx.ui.core.AnimationClockAmbient
import androidx.ui.core.FontLoaderAmbient
import androidx.ui.core.setContent
import androidx.ui.core.toAndroidRect
@@ -38,10 +39,10 @@
import androidx.ui.tooling.Inspectable
import androidx.ui.tooling.SlotTableRecord
import androidx.ui.tooling.asTree
+import androidx.ui.tooling.preview.animation.PreviewAnimationClock
import androidx.ui.unit.IntPx
import androidx.ui.unit.IntPxBounds
import androidx.ui.unit.PxBounds
-import androidx.ui.unit.toPx
import androidx.ui.unit.toRect
import kotlin.reflect.KClass
@@ -99,6 +100,9 @@
* for debugging purposes.
* - `tools:printViewInfos`: If true, the [ComposeViewAdapter] will log the tree of [ViewInfo]
* to logcat for debugging.
+ * - `tools:animationClockStartTime`: When set, the [AnimationClockAmbient] will provide a
+ * [PreviewAnimationClock] using this value as start time. The clock will control the animations
+ * in the [ComposeViewAdapter] context.
*
* @suppress
*/
@@ -209,10 +213,10 @@
if (it.hasBounds()) {
canvas?.apply {
val pxBounds = PxBounds(
- it.bounds.left.toPx(),
- it.bounds.top.toPx(),
- it.bounds.right.toPx(),
- it.bounds.bottom.toPx()
+ it.bounds.left.value.toFloat(),
+ it.bounds.top.value.toFloat(),
+ it.bounds.right.value.toFloat(),
+ it.bounds.bottom.value.toFloat()
)
drawRect(pxBounds.toRect().toAndroidRect(), debugBoundsPaint)
}
@@ -221,6 +225,14 @@
}
/**
+ * Clock that controls the animations defined in the context of this [ComposeViewAdapter].
+ *
+ * @suppress
+ */
+ @VisibleForTesting
+ internal lateinit var clock: PreviewAnimationClock
+
+ /**
* Wraps a given [Preview] method an does any necessary setup.
*/
@Composable
@@ -244,6 +256,8 @@
* @param debugPaintBounds if true, the view will paint the boundaries around the layout
* elements.
* @param debugViewInfos if true, it will generate the [ViewInfo] structures and will log it.
+ * @param animationClockStartTime if positive, the [AnimationClockAmbient] will provide
+ * [clock] instead of the default clock, setting this value as the clock's initial time.
*/
@VisibleForTesting
internal fun init(
@@ -252,7 +266,8 @@
parameterProvider: KClass<out PreviewParameterProvider<*>>? = null,
parameterProviderIndex: Int = 0,
debugPaintBounds: Boolean = false,
- debugViewInfos: Boolean = false
+ debugViewInfos: Boolean = false,
+ animationClockStartTime: Long = -1
) {
this.debugPaintBounds = debugPaintBounds
this.debugViewInfos = debugViewInfos
@@ -263,12 +278,25 @@
// We need to delay the reflection instantiation of the class until we are in the
// composable to ensure all the right initialization has happened and the Composable
// class loads correctly.
- invokeComposableViaReflection(
- className,
- methodName,
- composer,
- *getPreviewProviderParameters(parameterProvider, parameterProviderIndex)
- )
+ val composable = {
+ invokeComposableViaReflection(
+ className,
+ methodName,
+ composer,
+ *getPreviewProviderParameters(parameterProvider, parameterProviderIndex)
+ )
+ }
+ if (animationClockStartTime >= 0) {
+ // Provide a custom clock when animation inspection is enabled, i.e. when a
+ // valid `animationClockStartTime` is passed. This clock will control the
+ // animations defined in this `ComposeViewAdapter` from Android Studio.
+ clock = PreviewAnimationClock(animationClockStartTime)
+ Providers(AnimationClockAmbient provides clock) {
+ composable()
+ }
+ } else {
+ composable()
+ }
}
}
}
@@ -281,6 +309,23 @@
composition = null
}
+ /**
+ * Sets the relative time of the [PreviewAnimationClock] that controls inspected animations.
+ *
+ * Expected to be called via reflection from Android Studio and will fail otherwise, since
+ * [clock] will not be initialized in that case.
+ *
+ * @suppress
+ */
+ fun setClockTime(timeMs: Long) {
+ try {
+ clock.setClockTime(timeMs)
+ } catch (e: UninitializedPropertyAccessException) {
+ throw IllegalStateException("This method is expected to be called from Android Studio" +
+ " via reflection, otherwise 'clock' is expected to be null.")
+ }
+ }
+
private fun init(attrs: AttributeSet) {
val composableName = attrs.getAttributeValue(TOOLS_NS_URI, "composableName") ?: return
val className = composableName.substringBeforeLast('.')
@@ -292,6 +337,12 @@
val parameterProviderClass = attrs.getAttributeValue(TOOLS_NS_URI, "parameterProviderClass")
?.asPreviewProviderClass()
+ val animationClockStartTime = try {
+ attrs.getAttributeValue(TOOLS_NS_URI, "animationClockStartTime").toLong()
+ } catch (e: Exception) {
+ -1L
+ }
+
init(
className = className,
methodName = methodName,
@@ -306,7 +357,8 @@
TOOLS_NS_URI,
"printViewInfos",
debugViewInfos
- )
+ ),
+ animationClockStartTime = animationClockStartTime
)
}
}
diff --git a/ui/ui-tooling/src/main/java/androidx/ui/tooling/preview/animation/PreviewAnimationClock.kt b/ui/ui-tooling/src/main/java/androidx/ui/tooling/preview/animation/PreviewAnimationClock.kt
new file mode 100644
index 0000000..168df83
--- /dev/null
+++ b/ui/ui-tooling/src/main/java/androidx/ui/tooling/preview/animation/PreviewAnimationClock.kt
@@ -0,0 +1,69 @@
+/*
+ * 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 androidx.ui.tooling.preview.animation
+
+import android.util.Log
+import androidx.animation.AnimationClockObservable
+import androidx.animation.AnimationClockObserver
+import androidx.animation.ManualAnimationClock
+import androidx.annotation.VisibleForTesting
+
+/**
+ * [AnimationClockObservable] used to control animations in the context of Compose Previews. This
+ * clock is expected to be controlled by the Animation Inspector in Android Studio, and most of
+ * its methods will be called via reflection, either directly from Android Studio or through
+ * `ComposeViewAdapter`.
+ *
+ * It uses an underlying [ManualAnimationClock], as users will be able to select specific frames
+ * of subscribed animations when inspecting them in Android Studio.
+ *
+ * @suppress
+ */
+class PreviewAnimationClock(private val initialTimeMs: Long = 0L) : AnimationClockObservable {
+
+ private val TAG = "PreviewAnimationClock"
+
+ private val DEBUG = false
+
+ @VisibleForTesting
+ internal val clock = ManualAnimationClock(initialTimeMs)
+
+ override fun subscribe(observer: AnimationClockObserver) {
+ if (DEBUG) {
+ Log.d(TAG, "AnimationClockObserver $observer subscribed")
+ }
+ clock.subscribe(observer)
+ // TODO: parse observer and notify Android Studio that the observers list has been updated.
+ }
+
+ override fun unsubscribe(observer: AnimationClockObserver) {
+ if (DEBUG) {
+ Log.d(TAG, "AnimationClockObserver $observer unsubscribed")
+ }
+ clock.unsubscribe(observer)
+ // TODO: parse observer and notify Android Studio that the observers list has been updated.
+ }
+
+ /**
+ * Sets [clock] time to the given [animationTimeMs], relative to [initialTimeMs].
+ *
+ * @suppress
+ */
+ fun setClockTime(animationTimeMs: Long) {
+ clock.clockTimeMillis = initialTimeMs + animationTimeMs
+ }
+}
\ No newline at end of file
diff --git a/ui/ui-unit/api/0.1.0-dev14.txt b/ui/ui-unit/api/0.1.0-dev14.txt
index 68a02a8..14182cc 100644
--- a/ui/ui-unit/api/0.1.0-dev14.txt
+++ b/ui/ui-unit/api/0.1.0-dev14.txt
@@ -460,11 +460,12 @@
}
@androidx.compose.Immutable public final class PxBounds {
+ ctor public PxBounds(float left, float top, float right, float bottom);
method public float component1();
method public float component2();
method public float component3();
method public float component4();
- method @androidx.compose.Immutable public androidx.ui.unit.PxBounds copy-wHlpFhg(float left, float top, float right, float bottom);
+ method @androidx.compose.Immutable public androidx.ui.unit.PxBounds copy(float left, float top, float right, float bottom);
method public float getBottom();
method public float getLeft();
method public float getRight();
@@ -512,7 +513,6 @@
public final class PxKt {
method @androidx.compose.Stable public static inline androidx.ui.unit.PxBounds PxBounds(androidx.ui.unit.PxPosition topLeft, androidx.ui.unit.PxSize size);
method @androidx.compose.Stable public static inline androidx.ui.unit.PxPosition PxPosition(float x, float y);
- method @androidx.compose.Stable public static inline androidx.ui.unit.PxPosition PxPosition-qHcltEY(float x, float y);
method @androidx.compose.Stable public static inline androidx.ui.unit.PxSize PxSize(float width, float height);
method @androidx.compose.Stable public static inline androidx.ui.unit.PxSize PxSize-qHcltEY(float width, float height);
method @androidx.compose.Stable public static inline float abs-NgWp0Z8(float x);
diff --git a/ui/ui-unit/api/current.txt b/ui/ui-unit/api/current.txt
index 68a02a8..14182cc 100644
--- a/ui/ui-unit/api/current.txt
+++ b/ui/ui-unit/api/current.txt
@@ -460,11 +460,12 @@
}
@androidx.compose.Immutable public final class PxBounds {
+ ctor public PxBounds(float left, float top, float right, float bottom);
method public float component1();
method public float component2();
method public float component3();
method public float component4();
- method @androidx.compose.Immutable public androidx.ui.unit.PxBounds copy-wHlpFhg(float left, float top, float right, float bottom);
+ method @androidx.compose.Immutable public androidx.ui.unit.PxBounds copy(float left, float top, float right, float bottom);
method public float getBottom();
method public float getLeft();
method public float getRight();
@@ -512,7 +513,6 @@
public final class PxKt {
method @androidx.compose.Stable public static inline androidx.ui.unit.PxBounds PxBounds(androidx.ui.unit.PxPosition topLeft, androidx.ui.unit.PxSize size);
method @androidx.compose.Stable public static inline androidx.ui.unit.PxPosition PxPosition(float x, float y);
- method @androidx.compose.Stable public static inline androidx.ui.unit.PxPosition PxPosition-qHcltEY(float x, float y);
method @androidx.compose.Stable public static inline androidx.ui.unit.PxSize PxSize(float width, float height);
method @androidx.compose.Stable public static inline androidx.ui.unit.PxSize PxSize-qHcltEY(float width, float height);
method @androidx.compose.Stable public static inline float abs-NgWp0Z8(float x);
diff --git a/ui/ui-unit/api/public_plus_experimental_0.1.0-dev14.txt b/ui/ui-unit/api/public_plus_experimental_0.1.0-dev14.txt
index 68a02a8..14182cc 100644
--- a/ui/ui-unit/api/public_plus_experimental_0.1.0-dev14.txt
+++ b/ui/ui-unit/api/public_plus_experimental_0.1.0-dev14.txt
@@ -460,11 +460,12 @@
}
@androidx.compose.Immutable public final class PxBounds {
+ ctor public PxBounds(float left, float top, float right, float bottom);
method public float component1();
method public float component2();
method public float component3();
method public float component4();
- method @androidx.compose.Immutable public androidx.ui.unit.PxBounds copy-wHlpFhg(float left, float top, float right, float bottom);
+ method @androidx.compose.Immutable public androidx.ui.unit.PxBounds copy(float left, float top, float right, float bottom);
method public float getBottom();
method public float getLeft();
method public float getRight();
@@ -512,7 +513,6 @@
public final class PxKt {
method @androidx.compose.Stable public static inline androidx.ui.unit.PxBounds PxBounds(androidx.ui.unit.PxPosition topLeft, androidx.ui.unit.PxSize size);
method @androidx.compose.Stable public static inline androidx.ui.unit.PxPosition PxPosition(float x, float y);
- method @androidx.compose.Stable public static inline androidx.ui.unit.PxPosition PxPosition-qHcltEY(float x, float y);
method @androidx.compose.Stable public static inline androidx.ui.unit.PxSize PxSize(float width, float height);
method @androidx.compose.Stable public static inline androidx.ui.unit.PxSize PxSize-qHcltEY(float width, float height);
method @androidx.compose.Stable public static inline float abs-NgWp0Z8(float x);
diff --git a/ui/ui-unit/api/public_plus_experimental_current.txt b/ui/ui-unit/api/public_plus_experimental_current.txt
index 68a02a8..14182cc 100644
--- a/ui/ui-unit/api/public_plus_experimental_current.txt
+++ b/ui/ui-unit/api/public_plus_experimental_current.txt
@@ -460,11 +460,12 @@
}
@androidx.compose.Immutable public final class PxBounds {
+ ctor public PxBounds(float left, float top, float right, float bottom);
method public float component1();
method public float component2();
method public float component3();
method public float component4();
- method @androidx.compose.Immutable public androidx.ui.unit.PxBounds copy-wHlpFhg(float left, float top, float right, float bottom);
+ method @androidx.compose.Immutable public androidx.ui.unit.PxBounds copy(float left, float top, float right, float bottom);
method public float getBottom();
method public float getLeft();
method public float getRight();
@@ -512,7 +513,6 @@
public final class PxKt {
method @androidx.compose.Stable public static inline androidx.ui.unit.PxBounds PxBounds(androidx.ui.unit.PxPosition topLeft, androidx.ui.unit.PxSize size);
method @androidx.compose.Stable public static inline androidx.ui.unit.PxPosition PxPosition(float x, float y);
- method @androidx.compose.Stable public static inline androidx.ui.unit.PxPosition PxPosition-qHcltEY(float x, float y);
method @androidx.compose.Stable public static inline androidx.ui.unit.PxSize PxSize(float width, float height);
method @androidx.compose.Stable public static inline androidx.ui.unit.PxSize PxSize-qHcltEY(float width, float height);
method @androidx.compose.Stable public static inline float abs-NgWp0Z8(float x);
diff --git a/ui/ui-unit/api/restricted_0.1.0-dev14.txt b/ui/ui-unit/api/restricted_0.1.0-dev14.txt
index 05db857..cd7cfe1 100644
--- a/ui/ui-unit/api/restricted_0.1.0-dev14.txt
+++ b/ui/ui-unit/api/restricted_0.1.0-dev14.txt
@@ -464,11 +464,12 @@
}
@androidx.compose.Immutable public final class PxBounds {
+ ctor public PxBounds(float left, float top, float right, float bottom);
method public float component1();
method public float component2();
method public float component3();
method public float component4();
- method @androidx.compose.Immutable public androidx.ui.unit.PxBounds copy-wHlpFhg(float left, float top, float right, float bottom);
+ method @androidx.compose.Immutable public androidx.ui.unit.PxBounds copy(float left, float top, float right, float bottom);
method public float getBottom();
method public float getLeft();
method public float getRight();
@@ -516,7 +517,6 @@
public final class PxKt {
method @androidx.compose.Stable public static inline androidx.ui.unit.PxBounds PxBounds(androidx.ui.unit.PxPosition topLeft, androidx.ui.unit.PxSize size);
method @androidx.compose.Stable public static inline androidx.ui.unit.PxPosition PxPosition(float x, float y);
- method @androidx.compose.Stable public static inline androidx.ui.unit.PxPosition PxPosition-qHcltEY(float x, float y);
method @androidx.compose.Stable public static inline androidx.ui.unit.PxSize PxSize(float width, float height);
method @androidx.compose.Stable public static inline androidx.ui.unit.PxSize PxSize-qHcltEY(float width, float height);
method @androidx.compose.Stable public static inline float abs-NgWp0Z8(float x);
diff --git a/ui/ui-unit/api/restricted_current.txt b/ui/ui-unit/api/restricted_current.txt
index 05db857..cd7cfe1 100644
--- a/ui/ui-unit/api/restricted_current.txt
+++ b/ui/ui-unit/api/restricted_current.txt
@@ -464,11 +464,12 @@
}
@androidx.compose.Immutable public final class PxBounds {
+ ctor public PxBounds(float left, float top, float right, float bottom);
method public float component1();
method public float component2();
method public float component3();
method public float component4();
- method @androidx.compose.Immutable public androidx.ui.unit.PxBounds copy-wHlpFhg(float left, float top, float right, float bottom);
+ method @androidx.compose.Immutable public androidx.ui.unit.PxBounds copy(float left, float top, float right, float bottom);
method public float getBottom();
method public float getLeft();
method public float getRight();
@@ -516,7 +517,6 @@
public final class PxKt {
method @androidx.compose.Stable public static inline androidx.ui.unit.PxBounds PxBounds(androidx.ui.unit.PxPosition topLeft, androidx.ui.unit.PxSize size);
method @androidx.compose.Stable public static inline androidx.ui.unit.PxPosition PxPosition(float x, float y);
- method @androidx.compose.Stable public static inline androidx.ui.unit.PxPosition PxPosition-qHcltEY(float x, float y);
method @androidx.compose.Stable public static inline androidx.ui.unit.PxSize PxSize(float width, float height);
method @androidx.compose.Stable public static inline androidx.ui.unit.PxSize PxSize-qHcltEY(float width, float height);
method @androidx.compose.Stable public static inline float abs-NgWp0Z8(float x);
diff --git a/ui/ui-unit/src/commonMain/kotlin/androidx/ui/unit/IntPx.kt b/ui/ui-unit/src/commonMain/kotlin/androidx/ui/unit/IntPx.kt
index 1f90884..293b4a8 100644
--- a/ui/ui-unit/src/commonMain/kotlin/androidx/ui/unit/IntPx.kt
+++ b/ui/ui-unit/src/commonMain/kotlin/androidx/ui/unit/IntPx.kt
@@ -471,7 +471,8 @@
* Create a [PxPosition] from [IntPx] values.
*/
@Stable
-inline fun PxPosition(x: IntPx, y: IntPx): PxPosition = PxPosition(x = x.toPx(), y = y.toPx())
+inline fun PxPosition(x: IntPx, y: IntPx): PxPosition =
+ PxPosition(x = x.toPx().value, y = y.toPx().value)
/**
* Convert a [IntPxPosition] to a [PxPosition]
diff --git a/ui/ui-unit/src/commonMain/kotlin/androidx/ui/unit/Px.kt b/ui/ui-unit/src/commonMain/kotlin/androidx/ui/unit/Px.kt
index 753049d..de88bb7 100644
--- a/ui/ui-unit/src/commonMain/kotlin/androidx/ui/unit/Px.kt
+++ b/ui/ui-unit/src/commonMain/kotlin/androidx/ui/unit/Px.kt
@@ -28,6 +28,7 @@
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min
+import kotlin.math.roundToInt
import kotlin.math.sqrt
/**
@@ -500,15 +501,15 @@
* The horizontal aspect of the size in [Px].
*/
@Stable
- inline val width: Px
- get() = unpackFloat1(value).px
+ inline val width: Float
+ get() = unpackFloat1(value)
/**
* The vertical aspect of the size in [Px].
*/
@Stable
- inline val height: Px
- get() = unpackFloat2(value).px
+ inline val height: Float
+ get() = unpackFloat2(value)
/**
* Returns a PxSize scaled by multiplying [width] and [height] by [other]
@@ -558,13 +559,13 @@
* [PxSize] with zero values.
*/
@Stable
- val Zero = PxSize(0.px, 0.px)
+ val Zero = PxSize(0f, 0f)
/**
* Default value indicating no specified size
*/
@Stable
- val UnspecifiedSize = PxSize(Px.Infinity, Px.Infinity)
+ val UnspecifiedSize = PxSize(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY)
}
}
@@ -621,16 +622,14 @@
/**
* The horizontal aspect of the position in [Px]
*/
- @Stable
- inline val x: Px
- get() = unpackFloat1(value).px
+ inline val x: Float
+ get() = unpackFloat1(value)
/**
* The vertical aspect of the position in [Px]
*/
- @Stable
- inline val y: Px
- get() = unpackFloat2(value).px
+ inline val y: Float
+ get() = unpackFloat2(value)
/**
* Subtract a [PxPosition] from another one.
@@ -651,14 +650,14 @@
*/
@Stable
inline operator fun minus(other: IntPxPosition) =
- PxPosition(x - other.x, y - other.y)
+ PxPosition(x - other.x.value, y - other.y.value)
/**
* Add a [IntPxPosition] to this [PxPosition].
*/
@Stable
inline operator fun plus(other: IntPxPosition) =
- PxPosition(x + other.x, y + other.y)
+ PxPosition(x + other.x.value, y + other.y.value)
/**
* Returns a new PxPosition representing the negation of this point.
@@ -671,39 +670,33 @@
companion object {
@Stable
- val Origin = PxPosition(0.px, 0.px)
+ val Origin = PxPosition(0.0f, 0.0f)
}
}
/**
- * Constructs a [PxPosition] from [x] and [y] position float values.
+ * Constructs a [PxPosition] from [x] and [y] position pixel values.
*/
@Stable
inline fun PxPosition(x: Float, y: Float): PxPosition = PxPosition(packFloats(x, y))
/**
- * Constructs a [PxPosition] from [x] and [y] position [Px] values.
- */
-@Stable
-inline fun PxPosition(x: Px, y: Px): PxPosition = PxPosition(packFloats(x.value, y.value))
-
-/**
* The magnitude of the offset represented by this [PxPosition].
*/
@Stable
-fun PxPosition.getDistance(): Px = Px(sqrt(x.value * x.value + y.value * y.value))
+fun PxPosition.getDistance(): Px = Px(sqrt(x * x + y * y))
/**
* Convert a [PxPosition] to a [Offset].
*/
@Stable
-inline fun PxPosition.toOffset(): Offset = Offset(x.value, y.value)
+inline fun PxPosition.toOffset(): Offset = Offset(x, y)
/**
* Round a [PxPosition] down to the nearest [Int] coordinates.
*/
@Stable
-inline fun PxPosition.round(): IntPxPosition = IntPxPosition(x.round(), y.round())
+inline fun PxPosition.round(): IntPxPosition = IntPxPosition(x.roundToInt().ipx, y.roundToInt().ipx)
/**
* Linearly interpolate between two [PxPosition]s.
@@ -721,14 +714,14 @@
PxPosition(lerp(start.x, stop.x, fraction), lerp(start.y, stop.y, fraction))
/**
- * A four dimensional bounds using [Px] for units
+ * A four dimensional bounds using pixels for units
*/
@Immutable
data class PxBounds(
- val left: Px,
- val top: Px,
- val right: Px,
- val bottom: Px
+ val left: Float,
+ val top: Float,
+ val right: Float,
+ val bottom: Float
)
@Stable
@@ -744,13 +737,13 @@
* A width of this PxBounds in [Px].
*/
@Stable
-inline val PxBounds.width: Px get() = right - left
+inline val PxBounds.width: Float get() = right - left
/**
* A height of this PxBounds in [Px].
*/
@Stable
-inline val PxBounds.height: Px get() = bottom - top
+inline val PxBounds.height: Float get() = bottom - top
/**
* Returns the [PxPosition] of the center of the [PxBounds].
@@ -774,7 +767,7 @@
*/
@Stable
fun PxSize.toBounds(): PxBounds {
- return PxBounds(0.px, 0.px, width, height)
+ return PxBounds(0f, 0f, width, height)
}
/**
@@ -783,10 +776,10 @@
@Stable
fun PxBounds.toRect(): Rect {
return Rect(
- left.value,
- top.value,
- right.value,
- bottom.value
+ left,
+ top,
+ right,
+ bottom
)
}
@@ -795,5 +788,5 @@
*/
@Stable
fun PxSize.toRect(): Rect {
- return Rect(0f, 0f, width.value, height.value)
+ return Rect(0f, 0f, width, height)
}
\ No newline at end of file
diff --git a/ui/ui-unit/src/commonMain/kotlin/androidx/ui/unit/Velocity.kt b/ui/ui-unit/src/commonMain/kotlin/androidx/ui/unit/Velocity.kt
index b870169..d86fb0e 100644
--- a/ui/ui-unit/src/commonMain/kotlin/androidx/ui/unit/Velocity.kt
+++ b/ui/ui-unit/src/commonMain/kotlin/androidx/ui/unit/Velocity.kt
@@ -32,7 +32,7 @@
/**
* Velocity of 0 pixels per second in both x and y.
*/
- val Zero = Velocity(PxPosition(0.px, 0.px))
+ val Zero = Velocity(PxPosition(0f, 0f))
}
}
diff --git a/ui/ui-unit/src/unitTest/kotlin/androidx/ui/unit/IntPxTest.kt b/ui/ui-unit/src/unitTest/kotlin/androidx/ui/unit/IntPxTest.kt
index aeb48fe..0a19eea 100644
--- a/ui/ui-unit/src/unitTest/kotlin/androidx/ui/unit/IntPxTest.kt
+++ b/ui/ui-unit/src/unitTest/kotlin/androidx/ui/unit/IntPxTest.kt
@@ -224,12 +224,12 @@
@Test
fun createSize() {
- assertEquals(PxSize(10.px, 20.px), PxSize(10.ipx, 20.ipx))
+ assertEquals(PxSize(10f, 20f), PxSize(10.ipx, 20.ipx))
}
@Test
fun createPosition() {
- assertEquals(PxPosition(10.px, 20.px), PxPosition(10.ipx, 20.ipx))
+ assertEquals(PxPosition(10f, 20f), PxPosition(10.ipx, 20.ipx))
}
@Test
diff --git a/ui/ui-unit/src/unitTest/kotlin/androidx/ui/unit/PxTest.kt b/ui/ui-unit/src/unitTest/kotlin/androidx/ui/unit/PxTest.kt
index 19efa284..9b5173d 100644
--- a/ui/ui-unit/src/unitTest/kotlin/androidx/ui/unit/PxTest.kt
+++ b/ui/ui-unit/src/unitTest/kotlin/androidx/ui/unit/PxTest.kt
@@ -325,110 +325,110 @@
@Test
fun sizeCenter() {
val size = PxSize(width = 10.px, height = 20.px)
- assertEquals(PxPosition(5.px, 10.px), size.center())
+ assertEquals(PxPosition(5f, 10f), size.center())
}
@Test
fun positionDistance() {
- val position = PxPosition(3.px, 4.px)
+ val position = PxPosition(3f, 4f)
assertEquals(5.px, position.getDistance())
}
@Test
fun lerpPosition() {
- val a = PxPosition(3.px, 10.px)
- val b = PxPosition(5.px, 8.px)
- assertEquals(PxPosition(4.px, 9.px), lerp(a, b, 0.5f))
- assertEquals(PxPosition(3.px, 10.px), lerp(a, b, 0f))
- assertEquals(PxPosition(5.px, 8.px), lerp(a, b, 1f))
+ val a = PxPosition(3f, 10f)
+ val b = PxPosition(5f, 8f)
+ assertEquals(PxPosition(4f, 9f), lerp(a, b, 0.5f))
+ assertEquals(PxPosition(3f, 10f), lerp(a, b, 0f))
+ assertEquals(PxPosition(5f, 8f), lerp(a, b, 1f))
}
@Test
fun positionMinus() {
- val a = PxPosition(3.px, 10.px)
- val b = PxPosition(5.px, 8.px)
- assertEquals(PxPosition(-2.px, 2.px), a - b)
- assertEquals(PxPosition(2.px, -2.px), b - a)
+ val a = PxPosition(3f, 10f)
+ val b = PxPosition(5f, 8f)
+ assertEquals(PxPosition(-2f, 2f), a - b)
+ assertEquals(PxPosition(2f, -2f), b - a)
}
@Test
fun positionPlus() {
- val a = PxPosition(3.px, 10.px)
- val b = PxPosition(5.px, 8.px)
- assertEquals(PxPosition(8.px, 18.px), a + b)
- assertEquals(PxPosition(8.px, 18.px), b + a)
+ val a = PxPosition(3f, 10f)
+ val b = PxPosition(5f, 8f)
+ assertEquals(PxPosition(8f, 18f), a + b)
+ assertEquals(PxPosition(8f, 18f), b + a)
}
@Test
fun pxPositionMinusIntPxPosition() {
- val a = PxPosition(3.px, 10.px)
+ val a = PxPosition(3f, 10f)
val b = IntPxPosition(5.ipx, 8.ipx)
- assertEquals(PxPosition(-2.px, 2.px), a - b)
+ assertEquals(PxPosition(-2f, 2f), a - b)
}
@Test
fun pxPositionPlusIntPxPosition() {
- val a = PxPosition(3.px, 10.px)
+ val a = PxPosition(3f, 10f)
val b = IntPxPosition(5.ipx, 8.ipx)
- assertEquals(PxPosition(8.px, 18.px), a + b)
+ assertEquals(PxPosition(8f, 18f), a + b)
}
@Test
fun boundsWidth() {
- val bounds = PxBounds(10.px, 5.px, 25.px, 15.px)
- assertEquals(15.px, bounds.width)
+ val bounds = PxBounds(10f, 5f, 25f, 15f)
+ assertEquals(15f, bounds.width)
}
@Test
fun boundsHeight() {
- val bounds = PxBounds(10.px, 5.px, 25.px, 15.px)
- assertEquals(10.px, bounds.height)
+ val bounds = PxBounds(10f, 5f, 25f, 15f)
+ assertEquals(10f, bounds.height)
}
@Test
fun toSize() {
- val size = PxSize(15.px, 10.px)
- val bounds = PxBounds(10.px, 5.px, 25.px, 15.px)
+ val size = PxSize(15f, 10f)
+ val bounds = PxBounds(10f, 5f, 25f, 15f)
assertEquals(size, bounds.toSize())
}
@Test
fun toBounds() {
- val size = PxSize(15.px, 10.px)
- val bounds = PxBounds(0.px, 0.px, 15.px, 10.px)
+ val size = PxSize(15f, 10f)
+ val bounds = PxBounds(0f, 0f, 15f, 10f)
assertEquals(bounds, size.toBounds())
}
@Test
fun sizeTimesInt() {
- assertEquals(PxSize(10.px, 10.px), PxSize(2.5.px, 2.5.px) * 4)
- assertEquals(PxSize(10.px, 10.px), 4 * PxSize(2.5.px, 2.5.px))
+ assertEquals(PxSize(10f, 10f), PxSize(2.5f, 2.5f) * 4)
+ assertEquals(PxSize(10f, 10f), 4 * PxSize(2.5f, 2.5f))
}
@Test
fun sizeDivInt() {
- assertEquals(PxSize(10.px, 10.px), PxSize(40.px, 40.px) / 4)
+ assertEquals(PxSize(10f, 10f), PxSize(40f, 40f) / 4)
}
@Test
fun sizeTimesFloat() {
- assertEquals(PxSize(10.px, 10.px), PxSize(4.px, 4.px) * 2.5f)
- assertEquals(PxSize(10.px, 10.px), 2.5f * PxSize(4.px, 4.px))
+ assertEquals(PxSize(10f, 10f), PxSize(4f, 4f) * 2.5f)
+ assertEquals(PxSize(10f, 10f), 2.5f * PxSize(4f, 4f))
}
@Test
fun sizeDivFloat() {
- assertEquals(PxSize(10.px, 10.px), PxSize(40.px, 40.px) / 4f)
+ assertEquals(PxSize(10f, 10f), PxSize(40f, 40f) / 4f)
}
@Test
fun sizeTimesDouble() {
- assertEquals(PxSize(10.px, 10.px), PxSize(4.px, 4.px) * 2.5)
- assertEquals(PxSize(10.px, 10.px), 2.5 * PxSize(4.px, 4.px))
+ assertEquals(PxSize(10f, 10f), PxSize(4f, 4f) * 2.5)
+ assertEquals(PxSize(10f, 10f), 2.5 * PxSize(4f, 4f))
}
@Test
fun sizeDivDouble() {
- assertEquals(PxSize(10.px, 10.px), PxSize(40.px, 40.px) / 4.0)
+ assertEquals(PxSize(10f, 10f), PxSize(40f, 40f) / 4.0)
}
}
\ No newline at end of file
diff --git a/ui/ui-unit/src/unitTest/kotlin/androidx/ui/unit/VelocityTest.kt b/ui/ui-unit/src/unitTest/kotlin/androidx/ui/unit/VelocityTest.kt
index b4a3c9d..1775a0c 100644
--- a/ui/ui-unit/src/unitTest/kotlin/androidx/ui/unit/VelocityTest.kt
+++ b/ui/ui-unit/src/unitTest/kotlin/androidx/ui/unit/VelocityTest.kt
@@ -24,30 +24,30 @@
@RunWith(JUnit4::class)
class VelocityTest {
- private val velocity1 = Velocity(pixelsPerSecond = PxPosition(3.px, -7.px))
- private val velocity2 = Velocity(pixelsPerSecond = PxPosition(5.px, 13.px))
+ private val velocity1 = Velocity(pixelsPerSecond = PxPosition(3f, -7f))
+ private val velocity2 = Velocity(pixelsPerSecond = PxPosition(5f, 13f))
@Test
fun operatorUnaryMinus() {
Truth.assertThat(-velocity1)
- .isEqualTo(Velocity(pixelsPerSecond = PxPosition(-3.px, 7.px)))
+ .isEqualTo(Velocity(pixelsPerSecond = PxPosition(-3f, 7f)))
Truth.assertThat(-velocity2)
- .isEqualTo(Velocity(pixelsPerSecond = PxPosition(-5.px, (-13).px)))
+ .isEqualTo(Velocity(pixelsPerSecond = PxPosition(-5f, -13f)))
}
@Test
fun operatorPlus() {
Truth.assertThat(velocity2 + velocity1)
- .isEqualTo(Velocity(pixelsPerSecond = PxPosition(8.px, 6.px)))
+ .isEqualTo(Velocity(pixelsPerSecond = PxPosition(8f, 6f)))
Truth.assertThat(velocity1 + velocity2)
- .isEqualTo(Velocity(pixelsPerSecond = PxPosition(8.px, 6.px)))
+ .isEqualTo(Velocity(pixelsPerSecond = PxPosition(8f, 6f)))
}
@Test
fun operatorMinus() {
Truth.assertThat(velocity1 - velocity2)
- .isEqualTo(Velocity(pixelsPerSecond = PxPosition(-2.px, (-20).px)))
+ .isEqualTo(Velocity(pixelsPerSecond = PxPosition(-2f, -20f)))
Truth.assertThat(velocity2 - velocity1)
- .isEqualTo(Velocity(pixelsPerSecond = PxPosition(2.px, 20.px)))
+ .isEqualTo(Velocity(pixelsPerSecond = PxPosition(2f, 20f)))
}
}
\ No newline at end of file