Merge "Adds content description for the Seekbar in a SeekBarPreference" into androidx-master-dev
diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml
index 48d79af..c80cea4 100644
--- a/.github/ISSUE_TEMPLATE/config.yml
+++ b/.github/ISSUE_TEMPLATE/config.yml
@@ -1,5 +1,14 @@
blank_issues_enabled: false
contact_links:
+ - name: Activity
+ url: https://issuetracker.google.com/issues/new?component=527362&template=1189829
+ about: File a bug or feature request for Activity
+ - name: Fragment
+ url: https://issuetracker.google.com/issues/new?component=460964&template=1182267
+ about: File a bug or feature request for Fragment
+ - name: Navigation
+ url: https://issuetracker.google.com/issues/new?component=409828&template=1093757
+ about: File a bug or feature request for Navigation
- name: Paging
url: https://issuetracker.google.com/issues/new?component=413106&template=1096385
about: File a bug or feature request for Paging
diff --git a/.github/workflows/presubmit.yml b/.github/workflows/presubmit.yml
index 8bc8c2d..dc39336 100644
--- a/.github/workflows/presubmit.yml
+++ b/.github/workflows/presubmit.yml
@@ -67,9 +67,12 @@
run: echo $DIST_DIR && ls $HOME/Library/Android/sdk
- name: build on server
run: |
- cd paging && ./gradlew :buildOnServer && \
- cd ../room && ./gradlew :buildOnServer && \
- cd ../work && ./gradlew :buildOnServer
+ cd activity && ./gradlew :buildOnServer && \
+ cd ../fragment && ./gradlew :buildOnServer && \
+ cd ../navigation && ./gradlew :buildOnServer && \
+ cd ../paging && ./gradlew :buildOnServer && \
+ cd ../room && ./gradlew :buildOnServer && \
+ cd ../work && ./gradlew :buildOnServer
id: gradlew_bos
- name: Upload Results
if: always()
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index b390ac1..8046f2f 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -9,6 +9,9 @@
### What can you contribute to?
You can start contributing to any of the following library groups from GitHub:
+ - [Activity](https://developer.android.com/guide/components/activities/intro-activities)
+ - [Fragment](https://developer.android.com/guide/components/fragments)
+ - [Navigation](https://developer.android.com/guide/navigation)
- [Paging](https://developer.android.com/topic/libraries/architecture/paging)
- [Room](https://developer.android.com/topic/libraries/architecture/room)
- [WorkManager](https://developer.android.com/topic/libraries/architecture/workmanager)
diff --git a/README.md b/README.md
index 1cc495d..924bb1b 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,13 @@
For contributions via GitHub, see the [GitHub Contribution Guide](CONTRIBUTING.md).
-Note: The contributions workflow via GitHub is currently experimental - only contributions to [Paging](paging), [Room](room) and [WorkManager](work) are being accepted at this time.
+Note: The contributions workflow via GitHub is currently experimental - only contributions to the following projects are being accepted at this time:
+* [Activity](activity)
+* [Fragment](fragment)
+* [Navigation](navigation)
+* [Paging](paging)
+* [Room](room)
+* [WorkManager](work)
## Code Review Etiquette
When contributing to Jetpack, follow the [code review etiquette](code-review.md).
diff --git a/activity/.idea/codeStyles/Project.xml b/activity/.idea/codeStyles/Project.xml
new file mode 120000
index 0000000..b52b28c
--- /dev/null
+++ b/activity/.idea/codeStyles/Project.xml
@@ -0,0 +1 @@
+../../../.idea/codeStyles/Project.xml
\ No newline at end of file
diff --git a/activity/.idea/codeStyles/codeStyleConfig.xml b/activity/.idea/codeStyles/codeStyleConfig.xml
new file mode 120000
index 0000000..19c4848
--- /dev/null
+++ b/activity/.idea/codeStyles/codeStyleConfig.xml
@@ -0,0 +1 @@
+../../../.idea/codeStyles/codeStyleConfig.xml
\ No newline at end of file
diff --git a/activity/.idea/copyright/AndroidCopyright.xml b/activity/.idea/copyright/AndroidCopyright.xml
new file mode 120000
index 0000000..afbbd04
--- /dev/null
+++ b/activity/.idea/copyright/AndroidCopyright.xml
@@ -0,0 +1 @@
+../../../.idea/copyright/AndroidCopyright.xml
\ No newline at end of file
diff --git a/activity/.idea/copyright/profiles_settings.xml b/activity/.idea/copyright/profiles_settings.xml
new file mode 120000
index 0000000..5996ccd
--- /dev/null
+++ b/activity/.idea/copyright/profiles_settings.xml
@@ -0,0 +1 @@
+../../../.idea/copyright/profiles_settings.xml
\ No newline at end of file
diff --git a/activity/.idea/inspectionProfiles/Project_Default.xml b/activity/.idea/inspectionProfiles/Project_Default.xml
new file mode 120000
index 0000000..a7481f4
--- /dev/null
+++ b/activity/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1 @@
+../../../.idea/inspectionProfiles/Project_Default.xml
\ No newline at end of file
diff --git a/activity/.idea/scopes/Ignore_API_Files.xml b/activity/.idea/scopes/Ignore_API_Files.xml
new file mode 120000
index 0000000..3361ee1
--- /dev/null
+++ b/activity/.idea/scopes/Ignore_API_Files.xml
@@ -0,0 +1 @@
+../../../.idea/scopes/Ignore_API_Files.xml
\ No newline at end of file
diff --git a/activity/.idea/scopes/buildSrc.xml b/activity/.idea/scopes/buildSrc.xml
new file mode 120000
index 0000000..25b7d3b
--- /dev/null
+++ b/activity/.idea/scopes/buildSrc.xml
@@ -0,0 +1 @@
+../../../.idea/scopes/buildSrc.xml
\ No newline at end of file
diff --git a/activity/activity-ktx/build.gradle b/activity/activity-ktx/build.gradle
index 0fb2f0d..4175155 100644
--- a/activity/activity-ktx/build.gradle
+++ b/activity/activity-ktx/build.gradle
@@ -30,16 +30,16 @@
api("androidx.core:core-ktx:1.1.0") {
because 'Mirror activity dependency graph for -ktx artifacts'
}
- api(project(":lifecycle:lifecycle-runtime-ktx")) {
+ api(projectOrArtifact(":lifecycle:lifecycle-runtime-ktx")) {
because 'Mirror activity dependency graph for -ktx artifacts'
}
- api(project(":lifecycle:lifecycle-viewmodel-ktx"))
- api(project(":savedstate:savedstate-ktx")) {
+ api(projectOrArtifact(":lifecycle:lifecycle-viewmodel-ktx"))
+ api(projectOrArtifact(":savedstate:savedstate-ktx")) {
because 'Mirror activity dependency graph for -ktx artifacts'
}
api(KOTLIN_STDLIB)
- androidTestImplementation(project(":lifecycle:lifecycle-runtime-testing"))
+ androidTestImplementation(projectOrArtifact(":lifecycle:lifecycle-runtime-testing"))
androidTestImplementation(JUNIT)
androidTestImplementation(TRUTH)
androidTestImplementation(ANDROIDX_TEST_EXT_JUNIT)
diff --git a/activity/activity/build.gradle b/activity/activity/build.gradle
index ed1b9d8..e683bb6 100644
--- a/activity/activity/build.gradle
+++ b/activity/activity/build.gradle
@@ -23,12 +23,12 @@
api("androidx.annotation:annotation:1.1.0")
implementation("androidx.collection:collection:1.0.0")
api("androidx.core:core:1.1.0")
- api(project(":lifecycle:lifecycle-runtime"))
- api(project(":lifecycle:lifecycle-viewmodel"))
- api(project(":savedstate:savedstate"))
- api(project(":lifecycle:lifecycle-viewmodel-savedstate"))
+ api(projectOrArtifact(":lifecycle:lifecycle-runtime"))
+ api(projectOrArtifact(":lifecycle:lifecycle-viewmodel"))
+ api(projectOrArtifact(":savedstate:savedstate"))
+ api(projectOrArtifact(":lifecycle:lifecycle-viewmodel-savedstate"))
- androidTestImplementation(project(":lifecycle:lifecycle-runtime-testing"))
+ androidTestImplementation(projectOrArtifact(":lifecycle:lifecycle-runtime-testing"))
androidTestImplementation(KOTLIN_STDLIB)
androidTestImplementation(LEAKCANARY)
androidTestImplementation(LEAKCANARY_INSTRUMENTATION)
diff --git a/activity/gradle b/activity/gradle
new file mode 120000
index 0000000..1c936b3
--- /dev/null
+++ b/activity/gradle
@@ -0,0 +1 @@
+../playground-common/gradle
\ No newline at end of file
diff --git a/activity/gradle.properties b/activity/gradle.properties
new file mode 120000
index 0000000..d952fb0
--- /dev/null
+++ b/activity/gradle.properties
@@ -0,0 +1 @@
+../playground-common/androidx-shared.properties
\ No newline at end of file
diff --git a/activity/gradlew b/activity/gradlew
new file mode 120000
index 0000000..05b75179
--- /dev/null
+++ b/activity/gradlew
@@ -0,0 +1 @@
+../playground-common/gradlew
\ No newline at end of file
diff --git a/activity/gradlew.bat b/activity/gradlew.bat
new file mode 120000
index 0000000..b20877e
--- /dev/null
+++ b/activity/gradlew.bat
@@ -0,0 +1 @@
+../playground-common/gradlew.bat
\ No newline at end of file
diff --git a/activity/settings.gradle b/activity/settings.gradle
new file mode 100644
index 0000000..d9432af
--- /dev/null
+++ b/activity/settings.gradle
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+
+// see ../playground-common/README.md for details on how this works
+rootProject.name = "paging-playground"
+apply from: "../playground-common/playground-include-settings.gradle"
+setupPlayground(this, "..")
+selectProjectsFromAndroidX({ name ->
+ if (name.startsWith(":activity")) return true
+ if (name.startsWith(":internal-testutils-runtime")) return true
+ return false
+})
+
diff --git a/benchmark/benchmark-macro-runtime/build.gradle b/benchmark/benchmark-macro-runtime/build.gradle
new file mode 100644
index 0000000..c0d02a2
--- /dev/null
+++ b/benchmark/benchmark-macro-runtime/build.gradle
@@ -0,0 +1,67 @@
+/*
+ * 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.
+ */
+
+import static androidx.build.dependencies.DependenciesKt.*
+import androidx.build.LibraryGroups
+import androidx.build.Publish
+
+plugins {
+ id("AndroidXPlugin")
+ id("com.android.library")
+ id("kotlin-android")
+}
+
+android {
+ defaultConfig {
+ minSdkVersion 28
+ multiDexEnabled true
+ }
+}
+
+dependencies {
+ api(JUNIT)
+ api(KOTLIN_STDLIB)
+ api("androidx.annotation:annotation:1.1.0")
+ implementation(GUAVA_ANDROID)
+ implementation(ANDROIDX_TEST_EXT_JUNIT)
+ implementation(ANDROIDX_TEST_UIAUTOMATOR)
+
+ androidTestImplementation("com.android:collector-device-lib:0.1.0")
+ // Get rid of this dependency eventually
+ androidTestImplementation("com.android:collector-device-lib-platform:0.1.0")
+ androidTestImplementation("com.android:collector-helper-utilities:0.1.0")
+ androidTestImplementation("com.android:jank-helper:0.1.0")
+ androidTestImplementation("com.android:memory-helper:0.1.0")
+ androidTestImplementation("com.android:perfetto-helper:0.1.0")
+ androidTestImplementation("com.android:platform-test-composers:0.1.0")
+ androidTestImplementation("com.android:power-helper:0.1.0")
+ androidTestImplementation("com.android:simpleperf-helper:0.1.0")
+ androidTestImplementation("com.android:statsd-helper:0.1.0")
+ androidTestImplementation("com.android:system-metric-helper:0.1.0")
+ androidTestImplementation("com.android:test-composers:0.1.0")
+ androidTestImplementation("com.android:platform-test-rules:0.1.0")
+ androidTestImplementation("com.android:microbenchmark-device-lib:0.1.0")
+ androidTestImplementation("androidx.test:rules:1.3.0")
+ androidTestImplementation("androidx.test:runner:1.3.0")
+}
+
+androidx {
+ name = "Android Benchmark - Macrobenchmark Runtime"
+ publish = Publish.NONE
+ mavenGroup = LibraryGroups.BENCHMARK
+ inceptionYear = "2020"
+ description = "Android Benchmark - Macrobenchmark Runtime"
+}
diff --git a/benchmark/benchmark-macro-runtime/src/main/AndroidManifest.xml b/benchmark/benchmark-macro-runtime/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..e156320
--- /dev/null
+++ b/benchmark/benchmark-macro-runtime/src/main/AndroidManifest.xml
@@ -0,0 +1,17 @@
+<?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.
+ -->
+<manifest package="androidx.benchmark.macro.runtime"/>
diff --git a/benchmark/common/lint-baseline.xml b/benchmark/common/lint-baseline.xml
index d51639b..2f099a3 100644
--- a/benchmark/common/lint-baseline.xml
+++ b/benchmark/common/lint-baseline.xml
@@ -52,7 +52,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/androidx/benchmark/Errors.kt"
- line="198"
+ line="199"
column="73"/>
</issue>
@@ -63,7 +63,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/androidx/benchmark/IsolationActivity.kt"
- line="162"
+ line="165"
column="30"/>
</issue>
@@ -74,7 +74,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/androidx/benchmark/IsolationActivity.kt"
- line="171"
+ line="174"
column="37"/>
</issue>
@@ -85,7 +85,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/androidx/benchmark/IsolationActivity.kt"
- line="178"
+ line="181"
column="37"/>
</issue>
@@ -96,7 +96,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/androidx/benchmark/IsolationActivity.kt"
- line="179"
+ line="182"
column="30"/>
</issue>
@@ -107,7 +107,7 @@
errorLine2=" ~~~~~~~~~~~~~~~">
<location
file="src/main/java/androidx/benchmark/IsolationActivity.kt"
- line="180"
+ line="183"
column="30"/>
</issue>
diff --git a/benchmark/gradle-plugin/src/main/resources/scripts/lockClocks.sh b/benchmark/gradle-plugin/src/main/resources/scripts/lockClocks.sh
index a2ca833..df929f4 100755
--- a/benchmark/gradle-plugin/src/main/resources/scripts/lockClocks.sh
+++ b/benchmark/gradle-plugin/src/main/resources/scripts/lockClocks.sh
@@ -110,7 +110,11 @@
enableIndices=''
disableIndices=''
cpu=0
- while [ -d ${CPU_BASE}/cpu${cpu}/cpufreq ]; do
+
+ # Loop through all available cores; We have to check by the parent folder
+ # "cpu#" instead of cpu#/online or cpu#/cpufreq directly, since they may
+ # not be accessible yet.
+ while [ -d ${CPU_BASE}/cpu${cpu} ]; do
# Try to enable core, so we can find its frequencies.
# Note: In cases where the online file is inaccessible, it represents a
# core which cannot be turned off, so we simply assume it is enabled if
diff --git a/benchmark/macro/build.gradle b/benchmark/macro/build.gradle
index 4e98692..fea976d 100644
--- a/benchmark/macro/build.gradle
+++ b/benchmark/macro/build.gradle
@@ -48,12 +48,12 @@
// testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
// Listener List
testInstrumentationRunnerArgument 'listener',
- //'android.device.collectors.CpuUsageListener,' +
+ 'android.device.collectors.CpuUsageListener,' +
'android.device.collectors.ProcLoadListener,' +
'android.device.collectors.PerfettoListener,' +
- // 'android.device.collectors.AppStartupListener,' +
+ 'android.device.collectors.AppStartupListener,' +
'android.device.collectors.JankListener,' +
- // 'android.device.collectors.CrashListener,' +
+ 'android.device.collectors.CrashListener,' +
'android.device.collectors.ScreenshotOnFailureCollector,' +
'android.device.collectors.LogcatOnFailureCollector,' +
'android.device.collectors.IncidentReportListener,' +
@@ -83,19 +83,18 @@
api(JUNIT)
api(KOTLIN_STDLIB)
api("androidx.annotation:annotation:1.1.0")
-
// TODO: remove, once we remove the minor usages in CrystalBall
implementation(GUAVA_ANDROID)
androidTestImplementation("com.android:collector-device-lib:0.1.0")
+ androidTestImplementation("com.android:collector-device-lib-platform:0.1.0")
androidTestImplementation("com.android:collector-helper-utilities:0.1.0")
androidTestImplementation("com.android:jank-helper:0.1.0")
androidTestImplementation("com.android:memory-helper:0.1.0")
androidTestImplementation("com.android:perfetto-helper:0.1.0")
- // androidTestImplementation("com.android:platform-test-composers:0.1.0")
+ androidTestImplementation("com.android:platform-test-composers:0.1.0")
androidTestImplementation("com.android:power-helper:0.1.0")
androidTestImplementation("com.android:simpleperf-helper:0.1.0")
- // statsd-helper seems to cause a failure to resolve `android.content.Intent`
- // androidTestImplementation("com.android:statsd-helper:0.1.0") b/169700662
+ androidTestImplementation("com.android:statsd-helper:0.1.0")
androidTestImplementation("com.android:system-metric-helper:0.1.0")
androidTestImplementation("com.android:test-composers:0.1.0")
androidTestImplementation("com.android:platform-test-rules:0.1.0")
diff --git a/benchmark/macro/src/scripts/copy_crystalball_prebuilts.py b/benchmark/macro/src/scripts/copy_crystalball_prebuilts.py
new file mode 100755
index 0000000..1102366
--- /dev/null
+++ b/benchmark/macro/src/scripts/copy_crystalball_prebuilts.py
@@ -0,0 +1,77 @@
+#!/usr/bin/python3
+
+import argparse
+import os
+import shutil
+
+
+
+SOONG_SUFFIX = '/android_common/javac'
+VERSION = '0.1.0'
+
+
+def main():
+ parser = argparse.ArgumentParser(description='Copy Crystalball Prebuilts')
+ parser.add_argument('soong_path', action="store", help='Looks like "/usr/local/google/home/rahulrav/Workspace/internal_android/out/soong/.intermediates"')
+ parser.add_argument('prebuilts_directory', action="store", help='Looks like "/mnt/Android/Flatfoot/androidx_master/prebuilts/androidx/external/com/android/"')
+ parser.add_argument('--verbose', action="store_true", default=False)
+ parse_result = parser.parse_args()
+
+ soong_path = parse_result.soong_path
+ soong_output_directory = f'{soong_path}/platform_testing/libraries/'
+ prebuilts_directory = parse_result.prebuilts_directory
+
+ mapping = dict([
+ # Device Collectors
+ (f'{soong_output_directory}/device-collectors/src/main/collector-device-lib/{SOONG_SUFFIX}/collector-device-lib.jar', f'{prebuilts_directory}/collector-device-lib/{VERSION}/collector-device-lib-{VERSION}.jar'),
+ # Collectors Device Lib Platform
+ (f'{soong_output_directory}/device-collectors/src/main/platform-collectors/collector-device-lib-platform/{SOONG_SUFFIX}/collector-device-lib-platform.jar', f'{prebuilts_directory}/collector-device-lib-platform/{VERSION}/collector-device-lib-platform-{VERSION}.jar'),
+ # Collector Helpers
+ (f'{soong_output_directory}/collectors-helper/utilities/collector-helper-utilities/{SOONG_SUFFIX}/collector-helper-utilities.jar', f'{prebuilts_directory}/collector-helper-utilities/{VERSION}/collector-helper-utilities-{VERSION}.jar'),
+ (f'{soong_output_directory}/collectors-helper/jank/jank-helper/{SOONG_SUFFIX}/jank-helper.jar', f'{prebuilts_directory}/jank-helper/{VERSION}/jank-helper-{VERSION}.jar'),
+ (f'{soong_output_directory}/collectors-helper/memory/memory-helper/{SOONG_SUFFIX}/memory-helper.jar', f'{prebuilts_directory}/memory-helper/{VERSION}/memory-helper-{VERSION}.jar'),
+ # Microbenchmarks
+ (f'{soong_output_directory}/health/runners/microbenchmark/microbenchmark-device-lib/{SOONG_SUFFIX}/microbenchmark-device-lib.jar', f'{prebuilts_directory}/microbenchmark-device-lib/{VERSION}/microbenchmark-device-lib-{VERSION}.jar'),
+ # Perfetto Helper
+ (f'{soong_output_directory}/collectors-helper/perfetto/perfetto-helper/{SOONG_SUFFIX}/perfetto-helper.jar', f'{prebuilts_directory}/perfetto-helper/{VERSION}/perfetto-helper-{VERSION}.jar'),
+ # Platform Protos
+ (f'{soong_path}/frameworks/base/platformprotoslite/{SOONG_SUFFIX}/platformprotoslite.jar', f'{prebuilts_directory}/platformprotoslite/{VERSION}/platformprotoslite-{VERSION}.jar'),
+ (f'{soong_path}/frameworks/base/platformprotosnano/{SOONG_SUFFIX}/platformprotosnano.jar', f'{prebuilts_directory}/platformprotosnano/{VERSION}/platformprotosnano-{VERSION}.jar'),
+ # Platform Test Composers
+ (f'{soong_output_directory}/health/composers/platform/platform-test-composers/{SOONG_SUFFIX}/platform-test-composers.jar', f'{prebuilts_directory}/platform-test-composers/{VERSION}/platform-test-composers-{VERSION}.jar'),
+ # Platform Test Rules
+ (f'{soong_output_directory}/health/rules/platform-test-rules/{SOONG_SUFFIX}/platform-test-rules.jar', f'{prebuilts_directory}/platform-test-rules/{VERSION}/platform-test-rules-{VERSION}.jar'),
+ # Power Helper
+ (f'{soong_output_directory}/collectors-helper/power/power-helper/{SOONG_SUFFIX}/power-helper.jar', f'{prebuilts_directory}/power-helper/{VERSION}/power-helper-{VERSION}.jar'),
+ # Simple Perf Helper
+ (f'{soong_output_directory}/collectors-helper/simpleperf/simpleperf-helper/{SOONG_SUFFIX}/simpleperf-helper.jar', f'{prebuilts_directory}/simpleperf-helper/{VERSION}/simpleperf-helper-{VERSION}.jar'),
+ # Statsd Helper
+ (f'{soong_output_directory}/collectors-helper/statsd/statsd-helper/{SOONG_SUFFIX}/statsd-helper.jar', f'{prebuilts_directory}/statsd-helper/{VERSION}/statsd-helper-{VERSION}.jar'),
+ # Statsd Protos
+ (f'{soong_path}/frameworks/base/cmds/statsd/statsdprotonano/{SOONG_SUFFIX}/statsdprotonano.jar', f'{prebuilts_directory}/statsdprotonano/{VERSION}/statsdprotonano-{VERSION}.jar'),
+ # System Metric Helpers
+ (f'{soong_output_directory}/collectors-helper/system/system-metric-helper/{SOONG_SUFFIX}/system-metric-helper.jar', f'{prebuilts_directory}/system-metric-helper/{VERSION}/system-metric-helper-{VERSION}.jar'),
+ # Test Composers
+ (f'{soong_output_directory}/health/composers/host/test-composers/{SOONG_SUFFIX}/test-composers.jar', f'{prebuilts_directory}/test-composers/{VERSION}/test-composers-{VERSION}.jar'),
+ ])
+
+ size = len(mapping)
+ if parse_result.verbose:
+ print(f'Total number of entries = {size}')
+
+ for key in mapping:
+ if not os.path.exists(key):
+ print(f'Artifact at {key} does not exist. You may have forgotten to build the necessary artifacts.')
+
+ if os.path.exists(mapping[key]) and parse_result.verbose:
+ print(f'Artifact at {mapping[key]} will be overwritten')
+
+ shutil.copyfile(key, mapping[key])
+
+ if parse_result.verbose:
+ print(f'Copied from {key} to {mapping[key]}\n')
+
+ print('All done.')
+
+if __name__ == "__main__":
+ main()
diff --git a/buildSrc/src/main/kotlin/androidx/build/AndroidXPlugin.kt b/buildSrc/src/main/kotlin/androidx/build/AndroidXPlugin.kt
index f843aa7..7744dab 100644
--- a/buildSrc/src/main/kotlin/androidx/build/AndroidXPlugin.kt
+++ b/buildSrc/src/main/kotlin/androidx/build/AndroidXPlugin.kt
@@ -36,6 +36,7 @@
import androidx.build.checkapi.configureProjectForApiTasks
import androidx.build.studio.StudioTask
import com.android.build.api.artifact.ArtifactType
+import com.android.build.api.artifact.Artifacts
import com.android.build.api.dsl.ApplicationExtension
import com.android.build.api.dsl.CommonExtension
import com.android.build.gradle.AppExtension
@@ -269,13 +270,67 @@
configureAndroidCommonOptions(project, androidXExtension)
configureAndroidLibraryOptions(project, androidXExtension)
}
- libraryExtension.onVariants.withBuildType("release") {
- // Disable unit test for release build type
- unitTest {
- @Suppress("UnstableApiUsage")
- enabled = false
- }
+
+ try {
+ val libraryAndroidComponentsExtensionType =
+ Class.forName("com.android.build.api.extension.LibraryAndroidComponentsExtension")
+ val androidComponentsExtension =
+ project.extensions.getByType(libraryAndroidComponentsExtensionType)
+ val selectorType = Class.forName("com.android.build.api.extension.VariantSelector")
+ val selector = libraryAndroidComponentsExtensionType.getMethod("selector")
+ .invoke(androidComponentsExtension)
+ libraryAndroidComponentsExtensionType
+ .getMethod("beforeUnitTest", selectorType, Function1::class.java)
+ .invoke(
+ androidComponentsExtension,
+ selectorType.getMethod("withBuildType", String::class.java)
+ .invoke(selector, "release"),
+ { unitTest: Any ->
+ unitTest.javaClass.getMethod("setEnabled", Boolean::class.java)
+ .invoke(unitTest, false)
+ }
+ )
+ } catch (cnfe: ClassNotFoundException) {
+ // old iteration of the new API.
+ val allVariants = libraryExtension.javaClass.getMethod("getOnVariants")
+ .invoke(libraryExtension)
+
+ allVariants.javaClass.getMethod(
+ "withBuildType",
+ String::class.java,
+ Function1::class.java
+ ).invoke(
+ allVariants,
+ "release",
+ { variant: Any ->
+ variant.javaClass.getMethod(
+ "unitTest",
+ Function1::class.java
+ ).invoke(
+ variant,
+ { unitTest: Any ->
+ unitTest.javaClass.getMethod(
+ "setEnabled",
+ Boolean::class.java
+ ).invoke(
+ unitTest,
+ false
+ )
+ }
+ )
+ }
+ )
}
+
+ // switch to this code once 4.2.0-beta1 can be used.
+
+ // project.extensions.getByType<LibraryAndroidComponentsExtension>().apply {
+ // beforeUnitTest(selector().withBuildType("release")) {
+ // // Disable unit test for release build type
+ // @Suppress("UnstableApiUsage")
+ // enabled = false
+ // }
+ // }
libraryExtension.packagingOptions {
// TODO: Replace this with a per-variant packagingOption for androidTest specifically
// once b/69953968 is resolved.
@@ -486,7 +541,40 @@
val commonExtension = project.extensions.getByType(CommonExtension::class.java)
if (hasAndroidTestSourceCode(project, this)) {
- commonExtension.configureTestConfigGeneration(project)
+ try {
+ val androidComponentsExtensionType =
+ Class.forName("com.android.build.api.extension.AndroidComponentsExtension")
+ val androidComponentsExtension =
+ project.extensions.getByType(androidComponentsExtensionType)
+ val selectorType = Class.forName("com.android.build.api.extension.VariantSelector")
+ val selector = androidComponentsExtensionType.getMethod("selector")
+ .invoke(androidComponentsExtension)
+ androidComponentsExtension.javaClass.getMethod(
+ "androidTest",
+ selectorType,
+ Function1::class.java
+ ).invoke(
+ androidComponentsExtension,
+ selector.javaClass.getMethod("all").invoke(selector),
+ { androidTest: Any ->
+ createTestConfigurationGenerationTask(
+ project,
+ androidTest.javaClass.getMethod(
+ "getName"
+ ).invoke(
+ androidTest
+ ) as String,
+ androidTest.javaClass.getMethod(
+ "getArtifacts"
+ ).invoke(
+ androidTest
+ ) as Artifacts
+ )
+ }
+ )
+ } catch (cnfe: ClassNotFoundException) {
+ commonExtension.configureTestConfigGeneration(project)
+ }
}
val buildTestApksTask = project.rootProject.tasks.named(BUILD_TEST_APKS_TASK)
@@ -500,36 +588,72 @@
private fun CommonExtension<*, *, *, *, *, *, *, *>
.configureTestConfigGeneration(project: Project) {
- onVariants {
- val variant = this
- androidTestProperties {
- val generateTestConfigurationTask = project.tasks.register(
- "${project.name}${GENERATE_TEST_CONFIGURATION_TASK}${variant.name}",
- GenerateTestConfigurationTask::class.java
- ) {
- it.testFolder.set(artifacts.get(ArtifactType.APK))
- it.testLoader.set(artifacts.getBuiltArtifactsLoader())
- it.outputXml.fileValue(
- File(
- project.getTestConfigDirectory(),
- "${project.asFilenamePrefix()}${variant.name}AndroidTest.xml"
- )
+ // old iteration of the new API.
+ javaClass.getMethod("onVariants", Function1::class.java)
+ .invoke(
+ this,
+ { variant: Any ->
+ variant.javaClass.getMethod(
+ "androidTestProperties",
+ Function1::class.java
+ ).invoke(
+ variant,
+ { androidTest: Any ->
+ createTestConfigurationGenerationTask(
+ project,
+ androidTest.javaClass.getMethod(
+ "getName"
+ ).invoke(androidTest) as String,
+ androidTest.javaClass.getMethod(
+ "getArtifacts"
+ ).invoke(androidTest) as Artifacts
+ )
+ }
)
- }
- project.rootProject.tasks.findByName(ZIP_TEST_CONFIGS_WITH_APKS_TASK)!!
- .dependsOn(generateTestConfigurationTask)
- }
+ } as Function1<Any, Any>
+ )
+ }
+
+ private fun createTestConfigurationGenerationTask(
+ project: Project,
+ variantName: String,
+ artifacts: Artifacts
+ ) {
+ val generateTestConfigurationTask = project.tasks.register(
+ "${project.name}${GENERATE_TEST_CONFIGURATION_TASK}$variantName",
+ GenerateTestConfigurationTask::class.java
+ ) {
+ it.testFolder.set(artifacts.get(ArtifactType.APK))
+ it.testLoader.set(artifacts.getBuiltArtifactsLoader())
+ it.outputXml.fileValue(
+ File(
+ project.getTestConfigDirectory(),
+ "${project.asFilenamePrefix()}${variantName}AndroidTest.xml"
+ )
+ )
}
+ project.rootProject.tasks.findByName(ZIP_TEST_CONFIGS_WITH_APKS_TASK)!!
+ .dependsOn(generateTestConfigurationTask)
}
private fun ApplicationExtension<*, *, *, *, *>
.addAppApkToTestConfigGeneration(project: Project) {
- onVariantProperties.withBuildType("debug") {
- project.tasks.withType(GenerateTestConfigurationTask::class.java) {
- it.appFolder.set(artifacts.get(ArtifactType.APK))
- it.appLoader.set(artifacts.getBuiltArtifactsLoader())
- }
- }
+ val allVariants = javaClass.getMethod("getOnVariantProperties")
+ .invoke(this)
+
+ allVariants.javaClass.getMethod("withBuildType", String::class.java, Function1::class.java)
+ .invoke(
+ allVariants,
+ "debug",
+ { debugVariant: Any ->
+ val artifacts = debugVariant.javaClass.getMethod("getArtifacts")
+ .invoke(debugVariant) as Artifacts
+ project.tasks.withType(GenerateTestConfigurationTask::class.java) {
+ it.appFolder.set(artifacts.get(ArtifactType.APK))
+ it.appLoader.set(artifacts.getBuiltArtifactsLoader())
+ }
+ }
+ )
}
private fun hasAndroidTestSourceCode(project: Project, extension: TestedExtension): Boolean {
@@ -664,8 +788,38 @@
}
}
- val applicationExtension = project.extensions.getByType(ApplicationExtension::class.java)
- applicationExtension.addAppApkToTestConfigGeneration(project)
+ try {
+ val androidComponentsExtensionType = Class.forName(
+ "com.android.build.api.extension.ApplicationAndroidComponentsExtension"
+ )
+ val androidComponentsExtension =
+ project.extensions.getByType(androidComponentsExtensionType)
+ val selectorType = Class.forName(
+ "com.android.build.api.extension.VariantSelector"
+ )
+ val selector = androidComponentsExtensionType.getMethod("selector")
+ .invoke(androidComponentsExtension)
+ androidComponentsExtensionType
+ .getMethod("onVariants", selectorType, Function1::class.java)
+ .invoke(
+ androidComponentsExtension,
+ selectorType.getMethod("withBuildType", String::class.java)
+ .invoke(selector, "debug"),
+ { debugVariant: Any ->
+ val artifacts = debugVariant.javaClass.getMethod("getArtifacts")
+ .invoke(debugVariant) as Artifacts
+ project.tasks.withType(GenerateTestConfigurationTask::class.java) {
+ it.appFolder.set(artifacts.get(ArtifactType.APK))
+ it.appLoader.set(artifacts.getBuiltArtifactsLoader())
+ }
+ }
+ )
+ } catch (cnfe: ClassNotFoundException) {
+ val applicationExtension = project.extensions.getByType(
+ ApplicationExtension::class.java
+ )
+ applicationExtension.addAppApkToTestConfigGeneration(project)
+ }
val buildTestApksTask = project.rootProject.tasks.named(BUILD_TEST_APKS_TASK)
applicationVariants.all { variant ->
diff --git a/buildSrc/src/main/kotlin/androidx/build/GenerateTestConfigurationTask.kt b/buildSrc/src/main/kotlin/androidx/build/GenerateTestConfigurationTask.kt
index 3e9d969..7d6d100 100644
--- a/buildSrc/src/main/kotlin/androidx/build/GenerateTestConfigurationTask.kt
+++ b/buildSrc/src/main/kotlin/androidx/build/GenerateTestConfigurationTask.kt
@@ -45,6 +45,7 @@
<option name="test-suite-tag" value="androidx_unit_tests" />
<option name="config-descriptor:metadata" key="applicationId" value="APPLICATION_ID" />
<option name="wifi:disable" value="true" />
+ <option name="check-min-sdk" value="true" />
<include name="google/unbundled/common/setup" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
@@ -74,6 +75,7 @@
<option name="test-suite-tag" value="androidx_unit_tests" />
<option name="config-descriptor:metadata" key="applicationId" value="APPLICATION_ID" />
<option name="wifi:disable" value="true" />
+ <option name="check-min-sdk" value="true" />
<include name="google/unbundled/common/setup" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
diff --git a/buildSrc/src/main/kotlin/androidx/build/LibraryVersions.kt b/buildSrc/src/main/kotlin/androidx/build/LibraryVersions.kt
index 6cb3dd3..5449e64 100644
--- a/buildSrc/src/main/kotlin/androidx/build/LibraryVersions.kt
+++ b/buildSrc/src/main/kotlin/androidx/build/LibraryVersions.kt
@@ -62,7 +62,7 @@
val EMOJI = Version("1.2.0-alpha03")
val ENTERPRISE = Version("1.1.0-beta01")
val EXIFINTERFACE = Version("1.4.0-alpha01")
- val FRAGMENT = Version("1.3.0-beta01")
+ val FRAGMENT = Version("1.3.0-beta02")
val FUTURES = Version("1.2.0-alpha01")
val GRIDLAYOUT = Version("1.1.0-alpha01")
val HEIFWRITER = Version("1.1.0-alpha01")
diff --git a/buildSrc/src/main/kotlin/androidx/build/PublishDocsRules.kt b/buildSrc/src/main/kotlin/androidx/build/PublishDocsRules.kt
index f5d683c..a3c9d4a 100644
--- a/buildSrc/src/main/kotlin/androidx/build/PublishDocsRules.kt
+++ b/buildSrc/src/main/kotlin/androidx/build/PublishDocsRules.kt
@@ -41,6 +41,7 @@
prebuilts(LibraryGroups.AUTOFILL, "1.1.0-beta01")
ignore(LibraryGroups.BENCHMARK.group, "benchmark-gradle-plugin")
ignore(LibraryGroups.BENCHMARK.group, "benchmark-macro")
+ ignore(LibraryGroups.BENCHMARK.group, "benchmark-macro-runtime")
ignore(LibraryGroups.BENCHMARK.group, "benchmark-perfetto")
prebuilts(LibraryGroups.BENCHMARK, "1.1.0-alpha01")
prebuilts(LibraryGroups.BIOMETRIC, "biometric", "1.1.0-beta01")
diff --git a/buildSrc/src/main/kotlin/androidx/build/Release.kt b/buildSrc/src/main/kotlin/androidx/build/Release.kt
index ce6f81b..305bfa7 100644
--- a/buildSrc/src/main/kotlin/androidx/build/Release.kt
+++ b/buildSrc/src/main/kotlin/androidx/build/Release.kt
@@ -174,15 +174,10 @@
}
val version = project.version
- var zipTasks: MutableList<TaskProvider<GMavenZipTask>> = mutableListOf()
- if (!extension.mavenGroup!!.requireSameVersion) {
- zipTasks.add(getProjectZipTask(project))
- }
- zipTasks.addAll(
- listOf(
- getGroupReleaseZipTask(project, mavenGroup),
- getGlobalFullZipTask(project)
- )
+ var zipTasks = listOf(
+ getProjectZipTask(project),
+ getGroupReleaseZipTask(project, mavenGroup),
+ getGlobalFullZipTask(project)
)
val artifact = Artifact(
mavenGroup = mavenGroup,
diff --git a/busytown/androidx_host_tests.sh b/busytown/androidx_host_tests.sh
index be0529e..403173b 100755
--- a/busytown/androidx_host_tests.sh
+++ b/busytown/androidx_host_tests.sh
@@ -10,6 +10,7 @@
-Pandroidx.ignoreTestFailures \
-Pandroidx.displayTestOutput=false \
-Pandroidx.coverageEnabled=true \
+ -Pandroidx.validateNoUnrecognizedMessages \
-Pandroidx.allWarningsAsErrors "$@"
python3 impl/merge_outputs.py mergeExecutionData
diff --git a/camera/camera-view/src/main/java/androidx/camera/view/CameraController.java b/camera/camera-view/src/main/java/androidx/camera/view/CameraController.java
index d95ea9e..93821b5 100644
--- a/camera/camera-view/src/main/java/androidx/camera/view/CameraController.java
+++ b/camera/camera-view/src/main/java/androidx/camera/view/CameraController.java
@@ -187,7 +187,7 @@
ProcessCameraProvider.getInstance(mAppContext),
provider -> {
mCameraProvider = provider;
- startCamera();
+ startCameraAndTrackStates();
return null;
}, CameraXExecutors.mainThreadExecutor());
@@ -245,7 +245,7 @@
private void checkUseCasesAttachedToCamera() {
Preconditions.checkState(isCameraInitialized(), CAMERA_NOT_INITIALIZED);
- Preconditions.checkState(isCameraAttached(), PREVIEW_VIEW_NOT_ATTACHED);
+ Preconditions.checkState(isCameraAttached(), CAMERA_NOT_ATTACHED);
}
// ------------------
diff --git a/camera/camera-view/src/main/java/androidx/camera/view/PreviewView.java b/camera/camera-view/src/main/java/androidx/camera/view/PreviewView.java
index 53c43d6..4fda9d1 100644
--- a/camera/camera-view/src/main/java/androidx/camera/view/PreviewView.java
+++ b/camera/camera-view/src/main/java/androidx/camera/view/PreviewView.java
@@ -91,7 +91,7 @@
* {@link View} visible, or initially hiding the {@link View} by setting its
* {@linkplain View#setAlpha(float) opacity} to 0, then setting it to 1.0F to show it.
*/
-public class PreviewView extends FrameLayout {
+public final class PreviewView extends FrameLayout {
private static final String TAG = "PreviewView";
@@ -341,10 +341,14 @@
/**
* Applies a {@link ScaleType} to the preview.
- * <p>
- * Note that the {@link ScaleType#FILL_CENTER} is applied to the preview by default.
+ *
+ * <p> Once applied, the transformation will take immediate effect. This value can also be set
+ * in the layout XML file via the {@code app:scaleType} attribute.
+ *
+ * <p> The default value is {@link ScaleType#FILL_CENTER}.
*
* @param scaleType A {@link ScaleType} to apply to the preview.
+ * @attr name app:scaleType
*/
@UiThread
public void setScaleType(@NonNull final ScaleType scaleType) {
@@ -354,8 +358,8 @@
/**
* Returns the {@link ScaleType} currently applied to the preview.
- * <p>
- * By default, {@link ScaleType#FILL_CENTER} is applied to the preview.
+ *
+ * <p> The default value is {@link ScaleType#FILL_CENTER}.
*
* @return The {@link ScaleType} currently applied to the preview.
*/
@@ -409,7 +413,6 @@
* state with {@link LiveData#getValue()}, or register an observer with
* {@link LiveData#observe} .
*/
- @UiThread
@NonNull
public LiveData<StreamState> getPreviewStreamState() {
return mPreviewStreamStateLiveData;
@@ -426,6 +429,10 @@
* ({@link View#onDraw(Canvas)} for instance).
* <p>
* If an error occurs during the copy, an empty {@link Bitmap} will be returned.
+ * <p>
+ * If the preview hasn't started yet, the method may return null or an empty {@link Bitmap}. Use
+ * {@link #getPreviewStreamState()} to get the {@link StreamState} and wait for
+ * {@link StreamState#STREAMING} to make sure the preview is started.
*
* @return A {@link Bitmap.Config#ARGB_8888} {@link Bitmap} representing the content
* displayed on the {@link PreviewView}, or null if the camera preview hasn't started yet.
@@ -444,6 +451,7 @@
* the {@link UseCase}s in the {@link UseCaseGroup} will have the same output image that also
* matches the aspect ratio of the {@link PreviewView}.
*
+ * @return null if the view is not currently attached or the view's width/height is zero.
* @see ViewPort
* @see UseCaseGroup
*/
@@ -493,6 +501,7 @@
* {@link Surface#ROTATION_0}, {@link Surface#ROTATION_90},
* {@link Surface#ROTATION_180}, or
* {@link Surface#ROTATION_270}.
+ * @return null if the view's width/height is zero.
* @see ImplementationMode
*/
@UiThread
@@ -644,7 +653,8 @@
* Scale the preview, maintaining the source aspect ratio, so it is entirely contained
* within the {@link PreviewView}, and align it to the start of the view, which is the
* top left corner in a left-to-right (LTR) layout, or the top right corner in a
- * right-to-left (RTL) layout.
+ * right-to-left (RTL) layout. The background area not covered by the preview stream
+ * will be black or the background of the {@link PreviewView}
* <p>
* Both dimensions of the preview will be equal or less than the corresponding dimensions
* of its container {@link PreviewView}.
@@ -652,7 +662,8 @@
FIT_START(3),
/**
* Scale the preview, maintaining the source aspect ratio, so it is entirely contained
- * within the {@link PreviewView}, and center it inside the view.
+ * within the {@link PreviewView}, and center it inside the view. The background area not
+ * covered by the preview stream will be black or the background of the {@link PreviewView}.
* <p>
* Both dimensions of the preview will be equal or less than the corresponding dimensions
* of its container {@link PreviewView}.
@@ -662,7 +673,8 @@
* Scale the preview, maintaining the source aspect ratio, so it is entirely contained
* within the {@link PreviewView}, and align it to the end of the view, which is the
* bottom right corner in a left-to-right (LTR) layout, or the bottom left corner in a
- * right-to-left (RTL) layout.
+ * right-to-left (RTL) layout. The background area not covered by the preview stream
+ * will be black or the background of the {@link PreviewView}.
* <p>
* Both dimensions of the preview will be equal or less than the corresponding dimensions
* of its container {@link PreviewView}.
@@ -702,7 +714,7 @@
* {@link ImplementationMode#COMPATIBLE}. When in {@link ImplementationMode#PERFORMANCE}
* mode, it is possible that the preview becomes visible slightly after the state has
* changed. For apps requiring a precise signal for when the preview starts, please set
- * {@link ImplementationMode#PERFORMANCE} mode via {@link #setImplementationMode}.
+ * {@link ImplementationMode#COMPATIBLE} mode via {@link #setImplementationMode}.
*/
STREAMING
}
diff --git a/camera/integration-tests/viewtestapp/src/androidTest/java/androidx/camera/integration/view/CameraControllerFragmentTest.kt b/camera/integration-tests/viewtestapp/src/androidTest/java/androidx/camera/integration/view/CameraControllerFragmentTest.kt
index 97fdada..3fc2256 100644
--- a/camera/integration-tests/viewtestapp/src/androidTest/java/androidx/camera/integration/view/CameraControllerFragmentTest.kt
+++ b/camera/integration-tests/viewtestapp/src/androidTest/java/androidx/camera/integration/view/CameraControllerFragmentTest.kt
@@ -409,7 +409,7 @@
)
}
- private fun createFragmentScenario(): FragmentScenario<CameraControllerFragment?> {
+ private fun createFragmentScenario(): FragmentScenario<CameraControllerFragment> {
return FragmentScenario.launchInContainer(
CameraControllerFragment::class.java, null, R.style.AppTheme,
null
@@ -419,7 +419,7 @@
}
}
- private fun FragmentScenario<CameraControllerFragment?>.getFragment():
+ private fun FragmentScenario<CameraControllerFragment>.getFragment():
CameraControllerFragment {
var fragment: CameraControllerFragment? = null
this.onFragment { newValue: CameraControllerFragment -> fragment = newValue }
diff --git a/camera/integration-tests/viewtestapp/src/androidTest/java/androidx/camera/integration/view/PreviewViewFragmentTest.java b/camera/integration-tests/viewtestapp/src/androidTest/java/androidx/camera/integration/view/PreviewViewFragmentTest.java
index f9ebfd4..f6e9765 100644
--- a/camera/integration-tests/viewtestapp/src/androidTest/java/androidx/camera/integration/view/PreviewViewFragmentTest.java
+++ b/camera/integration-tests/viewtestapp/src/androidTest/java/androidx/camera/integration/view/PreviewViewFragmentTest.java
@@ -29,6 +29,7 @@
import androidx.camera.testing.CameraUtil;
import androidx.camera.testing.CoreAppTestUtil;
import androidx.camera.view.PreviewView;
+import androidx.fragment.app.FragmentFactory;
import androidx.fragment.app.testing.FragmentScenario;
import androidx.lifecycle.Lifecycle;
import androidx.test.ext.junit.runners.AndroidJUnit4;
@@ -217,7 +218,7 @@
@NonNull
private FragmentScenario<PreviewViewFragment> createScenario() {
return FragmentScenario.launchInContainer(PreviewViewFragment.class, null, R.style.AppTheme,
- null);
+ new FragmentFactory());
}
private void assertPreviewUpdating(@NonNull FragmentScenario<PreviewViewFragment> scenario) {
diff --git a/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/KtxCrossModuleTests.kt b/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/KtxCrossModuleTests.kt
index ecd7e7e..a63f6f7 100644
--- a/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/KtxCrossModuleTests.kt
+++ b/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/KtxCrossModuleTests.kt
@@ -830,6 +830,45 @@
}
}
+ /**
+ * Test for b/169071070
+ */
+ @Test
+ fun testCrossModule_ComposableInterfaceFunctionWithInlineClasses(): Unit = ensureSetup {
+ compile(
+ mapOf(
+ "library module" to mapOf (
+ "x/Library.kt" to """
+ package x
+
+ import androidx.compose.runtime.Composable
+
+ inline class InlineClass(val value: Float)
+
+ interface Foo {
+ @Composable
+ fun apply(value: InlineClass)
+ }
+ """.trimIndent()
+ ),
+ "Main" to mapOf(
+ "y/Impl.kt" to """
+ package y
+
+ import androidx.compose.runtime.Composable
+ import x.Foo
+ import x.InlineClass
+
+ object Bar : Foo {
+ @Composable
+ override fun apply(value: InlineClass) {}
+ }
+ """.trimIndent()
+ )
+ )
+ )
+ }
+
fun compile(
modules: Map<String, Map<String, String>>,
dumpClasses: Boolean = false,
diff --git a/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/ComposerParamTransformer.kt b/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/ComposerParamTransformer.kt
index 43aef7b..f8bf938 100644
--- a/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/ComposerParamTransformer.kt
+++ b/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/ComposerParamTransformer.kt
@@ -500,7 +500,10 @@
type = newType, varargElementType = param.varargElementType,
isCrossinline = param.isCrossinline,
isNoinline = param.isNoinline
- ).also { it.defaultValue = param.defaultValue }
+ ).also {
+ it.defaultValue = param.defaultValue
+ it.parent = param.parent
+ }
}
val valueParametersMapping = explicitParameters
diff --git a/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/LayoutSizeTest.kt b/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/LayoutSizeTest.kt
index 1ab40a2..dee2483 100644
--- a/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/LayoutSizeTest.kt
+++ b/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/LayoutSizeTest.kt
@@ -1118,29 +1118,20 @@
@Test
fun testInspectableParameter() {
- checkModifier(
- Modifier.width(200.0.dp), "width", 200.0.dp,
- listOf(ValueElement("width", 200.0.dp))
- )
- checkModifier(
- Modifier.height(300.0.dp), "height", 300.0.dp,
- listOf(ValueElement("height", 300.0.dp))
- )
- checkModifier(
- Modifier.size(400.0.dp), "size", 400.0.dp,
- listOf(ValueElement("size", 400.0.dp))
- )
+ checkModifier(Modifier.width(200.0.dp), "width", 200.0.dp, listOf())
+ checkModifier(Modifier.height(300.0.dp), "height", 300.0.dp, listOf())
+ checkModifier(Modifier.size(400.0.dp), "size", 400.0.dp, listOf())
checkModifier(
Modifier.size(100.0.dp, 200.0.dp), "size", null,
listOf(ValueElement("width", 100.0.dp), ValueElement("height", 200.0.dp))
)
checkModifier(
Modifier.widthIn(100.0.dp, 200.0.dp), "widthIn", null,
- listOf(ValueElement("minWidth", 100.0.dp), ValueElement("maxWidth", 200.0.dp))
+ listOf(ValueElement("min", 100.0.dp), ValueElement("max", 200.0.dp))
)
checkModifier(
Modifier.heightIn(10.0.dp, 200.0.dp), "heightIn", null,
- listOf(ValueElement("minHeight", 10.0.dp), ValueElement("maxHeight", 200.0.dp))
+ listOf(ValueElement("min", 10.0.dp), ValueElement("max", 200.0.dp))
)
checkModifier(
Modifier.sizeIn(10.dp, 20.dp, 30.dp, 40.dp), "sizeIn", null,
@@ -1149,29 +1140,20 @@
ValueElement("maxWidth", 30.dp), ValueElement("maxHeight", 40.dp)
)
)
- checkModifier(
- Modifier.preferredWidth(200.0.dp), "preferredWidth", 200.0.dp,
- listOf(ValueElement("width", 200.0.dp))
- )
- checkModifier(
- Modifier.preferredHeight(300.0.dp), "preferredHeight", 300.0.dp,
- listOf(ValueElement("height", 300.0.dp))
- )
- checkModifier(
- Modifier.preferredSize(400.0.dp), "preferredSize", 400.0.dp,
- listOf(ValueElement("size", 400.0.dp))
- )
+ checkModifier(Modifier.preferredWidth(200.0.dp), "preferredWidth", 200.0.dp, listOf())
+ checkModifier(Modifier.preferredHeight(300.0.dp), "preferredHeight", 300.0.dp, listOf())
+ checkModifier(Modifier.preferredSize(400.0.dp), "preferredSize", 400.0.dp, listOf())
checkModifier(
Modifier.preferredSize(100.0.dp, 200.0.dp), "preferredSize", null,
listOf(ValueElement("width", 100.0.dp), ValueElement("height", 200.0.dp))
)
checkModifier(
Modifier.preferredWidthIn(100.0.dp, 200.0.dp), "preferredWidthIn", null,
- listOf(ValueElement("minWidth", 100.0.dp), ValueElement("maxWidth", 200.0.dp))
+ listOf(ValueElement("min", 100.0.dp), ValueElement("max", 200.0.dp))
)
checkModifier(
Modifier.preferredHeightIn(10.0.dp, 200.0.dp), "preferredHeightIn", null,
- listOf(ValueElement("minHeight", 10.0.dp), ValueElement("maxHeight", 200.0.dp))
+ listOf(ValueElement("min", 10.0.dp), ValueElement("max", 200.0.dp))
)
checkModifier(
Modifier.preferredSizeIn(10.dp, 20.dp, 30.dp, 40.dp), "preferredSizeIn", null,
@@ -1181,21 +1163,72 @@
)
)
- checkModifier(Modifier.fillMaxWidth(), "fillMaxWidth", null, listOf())
- checkModifier(Modifier.fillMaxHeight(), "fillMaxHeight", null, listOf())
- checkModifier(Modifier.fillMaxSize(), "fillMaxSize", null, listOf())
+ checkModifier(
+ Modifier.fillMaxWidth(), "fillMaxWidth", null,
+ listOf(ValueElement("fraction", 1.0f))
+ )
+ checkModifier(
+ Modifier.fillMaxWidth(0.7f), "fillMaxWidth", null,
+ listOf(ValueElement("fraction", 0.7f))
+ )
+ checkModifier(
+ Modifier.fillMaxHeight(), "fillMaxHeight", null,
+ listOf(ValueElement("fraction", 1.0f))
+ )
+ checkModifier(
+ Modifier.fillMaxHeight(0.15f), "fillMaxHeight", null,
+ listOf(ValueElement("fraction", 0.15f))
+ )
+ checkModifier(
+ Modifier.fillMaxSize(), "fillMaxSize", null,
+ listOf(ValueElement("fraction", 1.0f))
+ )
+ checkModifier(
+ Modifier.fillMaxSize(0.25f), "fillMaxSize", null,
+ listOf(ValueElement("fraction", 0.25f))
+ )
checkModifier(
Modifier.wrapContentWidth(), "wrapContentWidth", null,
- listOf(ValueElement("alignment", Alignment.CenterHorizontally))
+ listOf(
+ ValueElement("align", Alignment.CenterHorizontally),
+ ValueElement("unbounded", false)
+ )
+ )
+ checkModifier(
+ Modifier.wrapContentWidth(Alignment.End, true), "wrapContentWidth", null,
+ listOf(
+ ValueElement("align", Alignment.End),
+ ValueElement("unbounded", true)
+ )
)
checkModifier(
Modifier.wrapContentHeight(), "wrapContentHeight", null,
- listOf(ValueElement("alignment", Alignment.CenterVertically))
+ listOf(
+ ValueElement("align", Alignment.CenterVertically),
+ ValueElement("unbounded", false)
+ )
+ )
+ checkModifier(
+ Modifier.wrapContentHeight(Alignment.Bottom, true), "wrapContentHeight", null,
+ listOf(
+ ValueElement("align", Alignment.Bottom),
+ ValueElement("unbounded", true)
+ )
)
checkModifier(
Modifier.wrapContentSize(), "wrapContentSize", null,
- listOf(ValueElement("alignment", Alignment.Center))
+ listOf(
+ ValueElement("align", Alignment.Center),
+ ValueElement("unbounded", false)
+ )
+ )
+ checkModifier(
+ Modifier.wrapContentSize(Alignment.BottomCenter, true), "wrapContentSize", null,
+ listOf(
+ ValueElement("align", Alignment.BottomCenter),
+ ValueElement("unbounded", true)
+ )
)
checkModifier(
diff --git a/compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/LayoutSize.kt b/compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/LayoutSize.kt
index 77edd9d..d5c9d38 100644
--- a/compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/LayoutSize.kt
+++ b/compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/LayoutSize.kt
@@ -24,8 +24,9 @@
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.IntrinsicMeasurable
import androidx.compose.ui.layout.IntrinsicMeasureScope
-import androidx.compose.ui.platform.InspectableValue
-import androidx.compose.ui.platform.ValueElement
+import androidx.compose.ui.platform.InspectorInfo
+import androidx.compose.ui.platform.InspectorValueInfo
+import androidx.compose.ui.platform.debugInspectorInfo
import androidx.compose.ui.unit.Constraints
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.Dp
@@ -50,7 +51,17 @@
* @sample androidx.compose.foundation.layout.samples.SimplePreferredWidthModifier
*/
@Stable
-fun Modifier.preferredWidth(width: Dp) = preferredSizeIn(minWidth = width, maxWidth = width)
+fun Modifier.preferredWidth(width: Dp) = this.then(
+ SizeModifier(
+ minWidth = width,
+ maxWidth = width,
+ enforceIncoming = true,
+ inspectorInfo = debugInspectorInfo {
+ name = "preferredWidth"
+ value = width
+ }
+ )
+)
/**
* Declare the preferred height of the content to be exactly [height]dp. The incoming measurement
@@ -64,7 +75,17 @@
* @sample androidx.compose.foundation.layout.samples.SimplePreferredHeightModifier
*/
@Stable
-fun Modifier.preferredHeight(height: Dp) = preferredSizeIn(minHeight = height, maxHeight = height)
+fun Modifier.preferredHeight(height: Dp) = this.then(
+ SizeModifier(
+ minHeight = height,
+ maxHeight = height,
+ enforceIncoming = true,
+ inspectorInfo = debugInspectorInfo {
+ name = "preferredHeight"
+ value = height
+ }
+ )
+)
/**
* Declare the preferred size of the content to be exactly [size]dp square. The incoming measurement
@@ -78,7 +99,19 @@
* @sample androidx.compose.foundation.layout.samples.SimplePreferredSizeModifier
*/
@Stable
-fun Modifier.preferredSize(size: Dp) = preferredSizeIn(size, size, size, size)
+fun Modifier.preferredSize(size: Dp) = this.then(
+ SizeModifier(
+ minWidth = size,
+ maxWidth = size,
+ minHeight = size,
+ maxHeight = size,
+ enforceIncoming = true,
+ inspectorInfo = debugInspectorInfo {
+ name = "preferredSize"
+ value = size
+ }
+ )
+)
/**
* Declare the preferred size of the content to be exactly [width]dp by [height]dp. The incoming
@@ -93,11 +126,19 @@
* @sample androidx.compose.foundation.layout.samples.SimplePreferredSizeModifier
*/
@Stable
-fun Modifier.preferredSize(width: Dp, height: Dp) = preferredSizeIn(
- minWidth = width,
- maxWidth = width,
- minHeight = height,
- maxHeight = height
+fun Modifier.preferredSize(width: Dp, height: Dp) = this.then(
+ SizeModifier(
+ minWidth = width,
+ maxWidth = width,
+ minHeight = height,
+ maxHeight = height,
+ enforceIncoming = true,
+ inspectorInfo = debugInspectorInfo {
+ name = "preferredSize"
+ properties["width"] = width
+ properties["height"] = height
+ }
+ )
)
/**
@@ -110,7 +151,18 @@
fun Modifier.preferredWidthIn(
min: Dp = Dp.Unspecified,
max: Dp = Dp.Unspecified
-) = preferredSizeIn(minWidth = min, maxWidth = max)
+) = this.then(
+ SizeModifier(
+ minWidth = min,
+ maxWidth = max,
+ enforceIncoming = true,
+ inspectorInfo = debugInspectorInfo {
+ name = "preferredWidthIn"
+ properties["min"] = min
+ properties["max"] = max
+ }
+ )
+)
/**
* Constrain the height of the content to be between [min]dp and [max]dp as permitted
@@ -122,7 +174,18 @@
fun Modifier.preferredHeightIn(
min: Dp = Dp.Unspecified,
max: Dp = Dp.Unspecified
-) = preferredSizeIn(minHeight = min, maxHeight = max)
+) = this.then(
+ SizeModifier(
+ minHeight = min,
+ maxHeight = max,
+ enforceIncoming = true,
+ inspectorInfo = debugInspectorInfo {
+ name = "preferredHeightIn"
+ properties["min"] = min
+ properties["max"] = max
+ }
+ )
+)
/**
* Constrain the size of the content to be within [constraints] as permitted by the incoming
@@ -155,7 +218,22 @@
minHeight: Dp = Dp.Unspecified,
maxWidth: Dp = Dp.Unspecified,
maxHeight: Dp = Dp.Unspecified
-) = this.then(SizeModifier(minWidth, minHeight, maxWidth, maxHeight, true))
+) = this.then(
+ SizeModifier(
+ minWidth = minWidth,
+ minHeight = minHeight,
+ maxWidth = maxWidth,
+ maxHeight = maxHeight,
+ enforceIncoming = true,
+ inspectorInfo = debugInspectorInfo {
+ name = "preferredSizeIn"
+ properties["minWidth"] = minWidth
+ properties["minHeight"] = minHeight
+ properties["maxWidth"] = maxWidth
+ properties["maxHeight"] = maxHeight
+ }
+ )
+)
/**
* Declare the width of the content to be exactly [width]dp. The incoming measurement
@@ -173,7 +251,17 @@
* @sample androidx.compose.foundation.layout.samples.SimpleWidthModifier
*/
@Stable
-fun Modifier.width(width: Dp) = sizeIn(minWidth = width, maxWidth = width)
+fun Modifier.width(width: Dp) = this.then(
+ SizeModifier(
+ minWidth = width,
+ maxWidth = width,
+ enforceIncoming = false,
+ inspectorInfo = debugInspectorInfo {
+ name = "width"
+ value = width
+ }
+ )
+)
/**
* Declare the height of the content to be exactly [height]dp. The incoming measurement
@@ -191,7 +279,17 @@
* @sample androidx.compose.foundation.layout.samples.SimpleHeightModifier
*/
@Stable
-fun Modifier.height(height: Dp) = sizeIn(minHeight = height, maxHeight = height)
+fun Modifier.height(height: Dp) = this.then(
+ SizeModifier(
+ minHeight = height,
+ maxHeight = height,
+ enforceIncoming = false,
+ inspectorInfo = debugInspectorInfo {
+ name = "height"
+ value = height
+ }
+ )
+)
/**
* Declare the size of the content to be exactly [size]dp width and height. The incoming measurement
@@ -209,7 +307,19 @@
* @sample androidx.compose.foundation.layout.samples.SimpleSizeModifier
*/
@Stable
-fun Modifier.size(size: Dp) = sizeIn(size, size, size, size)
+fun Modifier.size(size: Dp) = this.then(
+ SizeModifier(
+ minWidth = size,
+ maxWidth = size,
+ minHeight = size,
+ maxHeight = size,
+ enforceIncoming = false,
+ inspectorInfo = debugInspectorInfo {
+ name = "size"
+ value = size
+ }
+ )
+)
/**
* Declare the size of the content to be exactly [width]dp and [height]dp. The incoming measurement
@@ -227,11 +337,19 @@
* @sample androidx.compose.foundation.layout.samples.SimpleWidthModifier
*/
@Stable
-fun Modifier.size(width: Dp, height: Dp) = sizeIn(
- minWidth = width,
- maxWidth = width,
- minHeight = height,
- maxHeight = height
+fun Modifier.size(width: Dp, height: Dp) = this.then(
+ SizeModifier(
+ minWidth = width,
+ maxWidth = width,
+ minHeight = height,
+ maxHeight = height,
+ enforceIncoming = false,
+ inspectorInfo = debugInspectorInfo {
+ name = "size"
+ properties["width"] = width
+ properties["height"] = height
+ }
+ )
)
/**
@@ -245,7 +363,18 @@
fun Modifier.widthIn(
min: Dp = Dp.Unspecified,
max: Dp = Dp.Unspecified
-) = sizeIn(minWidth = min, maxWidth = max)
+) = this.then(
+ SizeModifier(
+ minWidth = min,
+ maxWidth = max,
+ enforceIncoming = false,
+ inspectorInfo = debugInspectorInfo {
+ name = "widthIn"
+ properties["min"] = min
+ properties["max"] = max
+ }
+ )
+)
/**
* Constrain the height of the content to be between [min]dp and [max]dp.
@@ -258,7 +387,18 @@
fun Modifier.heightIn(
min: Dp = Dp.Unspecified,
max: Dp = Dp.Unspecified
-) = sizeIn(minHeight = min, maxHeight = max)
+) = this.then(
+ SizeModifier(
+ minHeight = min,
+ maxHeight = max,
+ enforceIncoming = false,
+ inspectorInfo = debugInspectorInfo {
+ name = "heightIn"
+ properties["min"] = min
+ properties["max"] = max
+ }
+ )
+)
/**
* Constrain the size of the content to be within [constraints].
@@ -294,7 +434,22 @@
minHeight: Dp = Dp.Unspecified,
maxWidth: Dp = Dp.Unspecified,
maxHeight: Dp = Dp.Unspecified
-) = this.then(SizeModifier(minWidth, minHeight, maxWidth, maxHeight, false))
+) = this.then(
+ SizeModifier(
+ minWidth = minWidth,
+ minHeight = minHeight,
+ maxWidth = maxWidth,
+ maxHeight = maxHeight,
+ enforceIncoming = false,
+ inspectorInfo = debugInspectorInfo {
+ name = "sizeIn"
+ properties["minWidth"] = minWidth
+ properties["minHeight"] = minHeight
+ properties["maxWidth"] = maxWidth
+ properties["maxHeight"] = maxHeight
+ }
+ )
+)
/**
* Have the content fill (possibly only partially) the [Constraints.maxWidth] of the incoming
@@ -310,7 +465,16 @@
*/
@Stable
fun Modifier.fillMaxWidth(@FloatRange(from = 0.0, to = 1.0) fraction: Float = 1f) =
- this.then(FillModifier(Direction.Horizontal, fraction))
+ this.then(
+ FillModifier(
+ direction = Direction.Horizontal,
+ scale = fraction,
+ inspectorInfo = debugInspectorInfo {
+ name = "fillMaxWidth"
+ properties["fraction"] = fraction
+ }
+ )
+ )
/**
* Have the content fill (possibly only partially) the [Constraints.maxHeight] of the incoming
@@ -326,7 +490,16 @@
*/
@Stable
fun Modifier.fillMaxHeight(@FloatRange(from = 0.0, to = 1.0) fraction: Float = 1f) =
- this.then(FillModifier(Direction.Vertical, fraction))
+ this.then(
+ FillModifier(
+ direction = Direction.Vertical,
+ scale = fraction,
+ inspectorInfo = debugInspectorInfo {
+ name = "fillMaxHeight"
+ properties["fraction"] = fraction
+ }
+ )
+ )
/**
* Have the content fill (possibly only partially) the [Constraints.maxWidth] and
@@ -346,7 +519,16 @@
*/
@Stable
fun Modifier.fillMaxSize(@FloatRange(from = 0.0, to = 1.0) fraction: Float = 1f) =
- this.then(FillModifier(Direction.Both, fraction))
+ this.then(
+ FillModifier(
+ direction = Direction.Both,
+ scale = fraction,
+ inspectorInfo = debugInspectorInfo {
+ name = "fillMaxSize"
+ properties["fraction"] = fraction
+ }
+ )
+ )
/**
* Allow the content to measure at its desired width without regard for the incoming measurement
@@ -366,9 +548,18 @@
align: Alignment.Horizontal = Alignment.CenterHorizontally,
unbounded: Boolean = false
) = this.then(
- WrapContentModifier(Direction.Horizontal, align, unbounded) { size, layoutDirection ->
- IntOffset(align.align(size.width, layoutDirection), 0)
- }
+ WrapContentModifier(
+ direction = Direction.Horizontal,
+ unbounded = unbounded,
+ alignmentCallback = { size, layoutDirection ->
+ IntOffset(align.align(size.width, layoutDirection), 0)
+ },
+ inspectorInfo = debugInspectorInfo {
+ name = "wrapContentWidth"
+ properties["align"] = align
+ properties["unbounded"] = unbounded
+ }
+ )
)
/**
@@ -388,9 +579,18 @@
align: Alignment.Vertical = Alignment.CenterVertically,
unbounded: Boolean = false
) = this.then(
- WrapContentModifier(Direction.Vertical, align, unbounded) { size, _ ->
- IntOffset(0, align.align(size.height))
- }
+ WrapContentModifier(
+ direction = Direction.Vertical,
+ unbounded = unbounded,
+ alignmentCallback = { size, _ ->
+ IntOffset(0, align.align(size.height))
+ },
+ inspectorInfo = debugInspectorInfo {
+ name = "wrapContentHeight"
+ properties["align"] = align
+ properties["unbounded"] = unbounded
+ }
+ )
)
/**
@@ -409,9 +609,18 @@
align: Alignment = Alignment.Center,
unbounded: Boolean = false
) = this.then(
- WrapContentModifier(Direction.Both, align, unbounded) { size, layoutDirection ->
- align.align(size, layoutDirection)
- }
+ WrapContentModifier(
+ direction = Direction.Both,
+ unbounded = unbounded,
+ alignmentCallback = { size, layoutDirection ->
+ align.align(size, layoutDirection)
+ },
+ inspectorInfo = debugInspectorInfo {
+ name = "wrapContentSize"
+ properties["align"] = align
+ properties["unbounded"] = unbounded
+ }
+ )
)
/**
@@ -428,12 +637,23 @@
fun Modifier.defaultMinSizeConstraints(
minWidth: Dp = Dp.Unspecified,
minHeight: Dp = Dp.Unspecified
-) = this.then(UnspecifiedConstraintsModifier(minWidth, minHeight))
+) = this.then(
+ UnspecifiedConstraintsModifier(
+ minWidth = minWidth,
+ minHeight = minHeight,
+ inspectorInfo = debugInspectorInfo {
+ name = "defaultMinSizeConstraints"
+ properties["minWidth"] = minWidth
+ properties["minHeight"] = minHeight
+ }
+ )
+)
-private data class FillModifier(
+private class FillModifier(
private val direction: Direction,
- private val scale: Float
-) : LayoutModifier, InspectableValue {
+ private val scale: Float,
+ inspectorInfo: InspectorInfo.() -> Unit
+) : LayoutModifier, InspectorValueInfo(inspectorInfo) {
override fun MeasureScope.measure(
measurable: Measurable,
constraints: Constraints
@@ -468,24 +688,16 @@
placeable.placeRelative(0, 0)
}
}
-
- override val nameFallback: String =
- when (direction) {
- Direction.Vertical -> "fillMaxHeight"
- Direction.Horizontal -> "fillMaxWidth"
- Direction.Both -> "fillMaxSize"
- }
-
- override val inspectableElements: Sequence<ValueElement> = emptySequence()
}
-private data class SizeModifier(
+private class SizeModifier(
private val minWidth: Dp = Dp.Unspecified,
private val minHeight: Dp = Dp.Unspecified,
private val maxWidth: Dp = Dp.Unspecified,
private val maxHeight: Dp = Dp.Unspecified,
- private val enforceIncoming: Boolean
-) : LayoutModifier, InspectableValue {
+ private val enforceIncoming: Boolean,
+ inspectorInfo: InspectorInfo.() -> Unit
+) : LayoutModifier, InspectorValueInfo(inspectorInfo) {
private val Density.targetConstraints
get() = Constraints(
minWidth = if (minWidth != Dp.Unspecified) minWidth.toIntPx() else 0,
@@ -571,70 +783,14 @@
val constraints = targetConstraints
constraints.constrainHeight(it)
}
-
- override val nameFallback: String
- get() {
- val name = simpleName
- return if (enforceIncoming) "preferred${simpleName.capitalize()}" else name
- }
-
- override val valueOverride: Any?
- get() = when (simpleName) {
- "width" -> minWidth
- "height" -> minHeight
- "size" -> if (minWidth == minHeight) minWidth else null
- else -> null
- }
-
- override val inspectableElements: Sequence<ValueElement>
- get() = when (simpleName) {
- "width" -> sequenceOf(ValueElement("width", minWidth))
- "height" -> sequenceOf(ValueElement("height", minHeight))
- "size" ->
- if (minWidth == minHeight) {
- sequenceOf(ValueElement("size", minWidth))
- } else sequenceOf(
- ValueElement("width", minWidth),
- ValueElement("height", minHeight)
- )
- "widthIn" -> sequenceOf(
- ValueElement("minWidth", minWidth),
- ValueElement("maxWidth", maxWidth)
- )
- "heightIn" -> sequenceOf(
- ValueElement("minHeight", minHeight),
- ValueElement("maxHeight", maxHeight)
- )
- else -> sequenceOf(
- ValueElement("minWidth", minWidth),
- ValueElement("minHeight", minHeight),
- ValueElement("maxWidth", maxWidth),
- ValueElement("maxHeight", maxHeight)
- )
- }
-
- private val simpleName: String =
- if (minWidth == maxWidth && minHeight == maxHeight) {
- when {
- minHeight == Dp.Unspecified -> "width"
- minWidth == Dp.Unspecified -> "height"
- else -> "size"
- }
- } else {
- when {
- minHeight == Dp.Unspecified && maxHeight == Dp.Unspecified -> "widthIn"
- minWidth == Dp.Unspecified && maxWidth == Dp.Unspecified -> "heightIn"
- else -> "sizeIn"
- }
- }
}
-private data class WrapContentModifier(
+private class WrapContentModifier(
private val direction: Direction,
- private val alignment: Any,
private val unbounded: Boolean,
- private val alignmentCallback: (IntSize, LayoutDirection) -> IntOffset
-) : LayoutModifier, InspectableValue {
+ private val alignmentCallback: (IntSize, LayoutDirection) -> IntOffset,
+ inspectorInfo: InspectorInfo.() -> Unit
+) : LayoutModifier, InspectorValueInfo(inspectorInfo) {
override fun MeasureScope.measure(
measurable: Measurable,
constraints: Constraints
@@ -667,22 +823,13 @@
placeable.place(position)
}
}
-
- override val nameFallback: String =
- when (direction) {
- Direction.Vertical -> "wrapContentHeight"
- Direction.Horizontal -> "wrapContentWidth"
- Direction.Both -> "wrapContentSize"
- }
-
- override val inspectableElements: Sequence<ValueElement>
- get() = sequenceOf(ValueElement("alignment", alignment))
}
-private data class UnspecifiedConstraintsModifier(
+private class UnspecifiedConstraintsModifier(
val minWidth: Dp = Dp.Unspecified,
- val minHeight: Dp = Dp.Unspecified
-) : LayoutModifier, InspectableValue {
+ val minHeight: Dp = Dp.Unspecified,
+ inspectorInfo: InspectorInfo.() -> Unit
+) : LayoutModifier, InspectorValueInfo(inspectorInfo) {
override fun MeasureScope.measure(
measurable: Measurable,
constraints: Constraints
@@ -734,14 +881,6 @@
) = measurable.maxIntrinsicHeight(width).coerceAtLeast(
if (minHeight != Dp.Unspecified) minHeight.toIntPx() else 0
)
-
- override val nameFallback = "defaultMinSizeConstraints"
-
- override val inspectableElements: Sequence<ValueElement>
- get() = sequenceOf(
- ValueElement("minWidth", minWidth),
- ValueElement("minHeight", minHeight)
- )
}
internal enum class Direction {
diff --git a/compose/foundation/foundation-text/api/current.txt b/compose/foundation/foundation-text/api/current.txt
index 4084b44..cebd21a 100644
--- a/compose/foundation/foundation-text/api/current.txt
+++ b/compose/foundation/foundation-text/api/current.txt
@@ -2,7 +2,7 @@
package androidx.compose.foundation.text {
public final class CoreTextFieldKt {
- method @androidx.compose.runtime.Composable public static void CoreTextField-5rHpvpc(androidx.compose.ui.text.input.TextFieldValue value, optional androidx.compose.ui.Modifier modifier, kotlin.jvm.functions.Function1<? super androidx.compose.ui.text.input.TextFieldValue,kotlin.Unit> onValueChange, optional androidx.compose.ui.text.TextStyle textStyle, optional androidx.compose.ui.text.input.KeyboardType keyboardType, optional androidx.compose.ui.text.input.ImeAction imeAction, optional kotlin.jvm.functions.Function1<? super androidx.compose.ui.text.input.ImeAction,kotlin.Unit> onImeActionPerformed, optional androidx.compose.ui.text.input.VisualTransformation visualTransformation, optional kotlin.jvm.functions.Function1<? super androidx.compose.ui.text.TextLayoutResult,kotlin.Unit> onTextLayout, optional kotlin.jvm.functions.Function1<? super androidx.compose.ui.text.SoftwareKeyboardController,kotlin.Unit> onTextInputStarted, optional long cursorColor);
+ method @androidx.compose.runtime.Composable public static void CoreTextField-2qr7l3g(androidx.compose.ui.text.input.TextFieldValue value, optional androidx.compose.ui.Modifier modifier, kotlin.jvm.functions.Function1<? super androidx.compose.ui.text.input.TextFieldValue,kotlin.Unit> onValueChange, optional androidx.compose.ui.text.TextStyle textStyle, optional androidx.compose.ui.text.input.KeyboardType keyboardType, optional androidx.compose.ui.text.input.ImeAction imeAction, optional kotlin.jvm.functions.Function1<? super androidx.compose.ui.text.input.ImeAction,kotlin.Unit> onImeActionPerformed, optional androidx.compose.ui.text.input.VisualTransformation visualTransformation, optional kotlin.jvm.functions.Function1<? super androidx.compose.ui.text.TextLayoutResult,kotlin.Unit> onTextLayout, optional kotlin.jvm.functions.Function1<? super androidx.compose.ui.text.SoftwareKeyboardController,kotlin.Unit> onTextInputStarted, optional long cursorColor, optional boolean softWrap);
method @VisibleForTesting public static void setBlinkingCursorEnabled(boolean p);
}
diff --git a/compose/foundation/foundation-text/api/public_plus_experimental_current.txt b/compose/foundation/foundation-text/api/public_plus_experimental_current.txt
index 4084b44..cebd21a 100644
--- a/compose/foundation/foundation-text/api/public_plus_experimental_current.txt
+++ b/compose/foundation/foundation-text/api/public_plus_experimental_current.txt
@@ -2,7 +2,7 @@
package androidx.compose.foundation.text {
public final class CoreTextFieldKt {
- method @androidx.compose.runtime.Composable public static void CoreTextField-5rHpvpc(androidx.compose.ui.text.input.TextFieldValue value, optional androidx.compose.ui.Modifier modifier, kotlin.jvm.functions.Function1<? super androidx.compose.ui.text.input.TextFieldValue,kotlin.Unit> onValueChange, optional androidx.compose.ui.text.TextStyle textStyle, optional androidx.compose.ui.text.input.KeyboardType keyboardType, optional androidx.compose.ui.text.input.ImeAction imeAction, optional kotlin.jvm.functions.Function1<? super androidx.compose.ui.text.input.ImeAction,kotlin.Unit> onImeActionPerformed, optional androidx.compose.ui.text.input.VisualTransformation visualTransformation, optional kotlin.jvm.functions.Function1<? super androidx.compose.ui.text.TextLayoutResult,kotlin.Unit> onTextLayout, optional kotlin.jvm.functions.Function1<? super androidx.compose.ui.text.SoftwareKeyboardController,kotlin.Unit> onTextInputStarted, optional long cursorColor);
+ method @androidx.compose.runtime.Composable public static void CoreTextField-2qr7l3g(androidx.compose.ui.text.input.TextFieldValue value, optional androidx.compose.ui.Modifier modifier, kotlin.jvm.functions.Function1<? super androidx.compose.ui.text.input.TextFieldValue,kotlin.Unit> onValueChange, optional androidx.compose.ui.text.TextStyle textStyle, optional androidx.compose.ui.text.input.KeyboardType keyboardType, optional androidx.compose.ui.text.input.ImeAction imeAction, optional kotlin.jvm.functions.Function1<? super androidx.compose.ui.text.input.ImeAction,kotlin.Unit> onImeActionPerformed, optional androidx.compose.ui.text.input.VisualTransformation visualTransformation, optional kotlin.jvm.functions.Function1<? super androidx.compose.ui.text.TextLayoutResult,kotlin.Unit> onTextLayout, optional kotlin.jvm.functions.Function1<? super androidx.compose.ui.text.SoftwareKeyboardController,kotlin.Unit> onTextInputStarted, optional long cursorColor, optional boolean softWrap);
method @VisibleForTesting public static void setBlinkingCursorEnabled(boolean p);
}
diff --git a/compose/foundation/foundation-text/api/restricted_current.txt b/compose/foundation/foundation-text/api/restricted_current.txt
index 4084b44..cebd21a 100644
--- a/compose/foundation/foundation-text/api/restricted_current.txt
+++ b/compose/foundation/foundation-text/api/restricted_current.txt
@@ -2,7 +2,7 @@
package androidx.compose.foundation.text {
public final class CoreTextFieldKt {
- method @androidx.compose.runtime.Composable public static void CoreTextField-5rHpvpc(androidx.compose.ui.text.input.TextFieldValue value, optional androidx.compose.ui.Modifier modifier, kotlin.jvm.functions.Function1<? super androidx.compose.ui.text.input.TextFieldValue,kotlin.Unit> onValueChange, optional androidx.compose.ui.text.TextStyle textStyle, optional androidx.compose.ui.text.input.KeyboardType keyboardType, optional androidx.compose.ui.text.input.ImeAction imeAction, optional kotlin.jvm.functions.Function1<? super androidx.compose.ui.text.input.ImeAction,kotlin.Unit> onImeActionPerformed, optional androidx.compose.ui.text.input.VisualTransformation visualTransformation, optional kotlin.jvm.functions.Function1<? super androidx.compose.ui.text.TextLayoutResult,kotlin.Unit> onTextLayout, optional kotlin.jvm.functions.Function1<? super androidx.compose.ui.text.SoftwareKeyboardController,kotlin.Unit> onTextInputStarted, optional long cursorColor);
+ method @androidx.compose.runtime.Composable public static void CoreTextField-2qr7l3g(androidx.compose.ui.text.input.TextFieldValue value, optional androidx.compose.ui.Modifier modifier, kotlin.jvm.functions.Function1<? super androidx.compose.ui.text.input.TextFieldValue,kotlin.Unit> onValueChange, optional androidx.compose.ui.text.TextStyle textStyle, optional androidx.compose.ui.text.input.KeyboardType keyboardType, optional androidx.compose.ui.text.input.ImeAction imeAction, optional kotlin.jvm.functions.Function1<? super androidx.compose.ui.text.input.ImeAction,kotlin.Unit> onImeActionPerformed, optional androidx.compose.ui.text.input.VisualTransformation visualTransformation, optional kotlin.jvm.functions.Function1<? super androidx.compose.ui.text.TextLayoutResult,kotlin.Unit> onTextLayout, optional kotlin.jvm.functions.Function1<? super androidx.compose.ui.text.SoftwareKeyboardController,kotlin.Unit> onTextInputStarted, optional long cursorColor, optional boolean softWrap);
method @VisibleForTesting public static void setBlinkingCursorEnabled(boolean p);
}
diff --git a/compose/foundation/foundation-text/integration-tests/ui-text-compose-demos/src/main/java/androidx/compose/foundation/text/demos/ComposeInputFieldSoftWrap.kt b/compose/foundation/foundation-text/integration-tests/ui-text-compose-demos/src/main/java/androidx/compose/foundation/text/demos/ComposeInputFieldSoftWrap.kt
new file mode 100644
index 0000000..9b8e4d6
--- /dev/null
+++ b/compose/foundation/foundation-text/integration-tests/ui-text-compose-demos/src/main/java/androidx/compose/foundation/text/demos/ComposeInputFieldSoftWrap.kt
@@ -0,0 +1,52 @@
+/*
+ * 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.compose.foundation.text.demos
+
+import androidx.compose.foundation.ExperimentalFoundationApi
+import androidx.compose.foundation.ScrollableColumn
+import androidx.compose.foundation.layout.defaultMinSizeConstraints
+import androidx.compose.foundation.text.CoreTextField
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.savedinstancestate.savedInstanceState
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.text.TextStyle
+import androidx.compose.ui.text.input.TextFieldValue
+import androidx.compose.ui.unit.dp
+
+@Composable
+fun SoftWrapDemo() {
+ ScrollableColumn {
+ CoreTextFieldWithWrap(false)
+ CoreTextFieldWithWrap(true)
+ }
+}
+
+@Composable
+@OptIn(ExperimentalFoundationApi::class)
+private fun CoreTextFieldWithWrap(softWrap: Boolean) {
+ val state = savedInstanceState(saver = TextFieldValue.Saver) {
+ TextFieldValue("abc ".repeat(20))
+ }
+ CoreTextField(
+ modifier = demoTextFieldModifiers.defaultMinSizeConstraints(100.dp),
+ value = state.value,
+ softWrap = softWrap,
+ onValueChange = { state.value = it },
+ textStyle = TextStyle(fontSize = fontSize8),
+ cursorColor = Color.Red
+ )
+}
\ No newline at end of file
diff --git a/compose/foundation/foundation-text/integration-tests/ui-text-compose-demos/src/main/java/androidx/compose/foundation/text/demos/TextDemos.kt b/compose/foundation/foundation-text/integration-tests/ui-text-compose-demos/src/main/java/androidx/compose/foundation/text/demos/TextDemos.kt
index d1679a3..dfba227 100644
--- a/compose/foundation/foundation-text/integration-tests/ui-text-compose-demos/src/main/java/androidx/compose/foundation/text/demos/TextDemos.kt
+++ b/compose/foundation/foundation-text/integration-tests/ui-text-compose-demos/src/main/java/androidx/compose/foundation/text/demos/TextDemos.kt
@@ -35,7 +35,8 @@
ComposableDemo("Tricky input field") { InputFieldTrickyUseCase() },
ComposableDemo("Focus transition") { TextFieldFocusTransition() },
ComposableDemo("Tail Following Text Field") { TailFollowingTextFieldDemo() },
- ComposableDemo("TextField in Scroller") { TextFieldWithScrollerDemo() }
+ ComposableDemo("TextField in Scroller") { TextFieldWithScrollerDemo() },
+ ComposableDemo("Soft Wrap") { SoftWrapDemo() },
)
),
ComposableDemo("Text Accessibility") { TextAccessibilityDemo() }
diff --git a/compose/foundation/foundation-text/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/CoreTextFieldSoftWrapTest.kt b/compose/foundation/foundation-text/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/CoreTextFieldSoftWrapTest.kt
new file mode 100644
index 0000000..63178d1
--- /dev/null
+++ b/compose/foundation/foundation-text/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/CoreTextFieldSoftWrapTest.kt
@@ -0,0 +1,127 @@
+/*
+ * 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.compose.foundation.text
+
+import androidx.compose.foundation.layout.width
+import androidx.compose.runtime.Providers
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.onGloballyPositioned
+import androidx.compose.ui.platform.DensityAmbient
+import androidx.compose.ui.text.TextLayoutResult
+import androidx.compose.ui.text.TextStyle
+import androidx.compose.ui.text.font.FontStyle
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.text.font.ResourceFont
+import androidx.compose.ui.text.font.asFontFamily
+import androidx.compose.ui.text.input.TextFieldValue
+import androidx.compose.ui.unit.sp
+import androidx.test.filters.LargeTest
+import androidx.ui.test.createComposeRule
+import com.google.common.truth.Truth.assertThat
+import org.junit.Rule
+import org.junit.Test
+import androidx.compose.ui.text.font.test.R
+import androidx.compose.ui.unit.Density
+import androidx.compose.ui.unit.dp
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+
+@LargeTest
+@RunWith(JUnit4::class)
+class CoreTextFieldSoftWrapTest {
+
+ private val fontFamily = ResourceFont(
+ resId = R.font.sample_font,
+ weight = FontWeight.Normal,
+ style = FontStyle.Normal
+ ).asFontFamily()
+
+ @get:Rule
+ val rule = createComposeRule()
+
+ @Test
+ fun textField_softWrapFalse_returnsSizeForMaxIntrinsicWidth() {
+ val density = Density(density = 1f, fontScale = 1f)
+ val fontSize = 100.sp
+ val composableWidth = 50.dp
+ val textStyle = TextStyle(fontFamily = fontFamily, fontSize = fontSize)
+ val string = "a".repeat(20)
+
+ var textLayout: TextLayoutResult? = null
+ var width: Int? = null
+
+ rule.setContent {
+ Providers(DensityAmbient provides density) {
+ CoreTextField(
+ value = TextFieldValue(string),
+ onValueChange = {},
+ textStyle = textStyle,
+ softWrap = false,
+ onTextLayout = { textLayout = it },
+ modifier = Modifier.width(composableWidth)
+ .onGloballyPositioned {
+ width = it.size.width
+ }
+ )
+ }
+ }
+
+ with(density) {
+ assertThat(textLayout).isNotNull()
+ assertThat(width).isNotNull()
+ assertThat(width).isEqualTo(composableWidth.toIntPx())
+ assertThat(textLayout?.lineCount).isEqualTo(1)
+ }
+ }
+
+ @Test
+ fun textField_softWrapTrue_respectsTheGivenMaxWidth() {
+ val density = Density(density = 1f, fontScale = 1f)
+ val fontSize = 100.sp
+ val composableWidth = 100.dp
+ val textStyle = TextStyle(fontFamily = fontFamily, fontSize = fontSize)
+ val string = "a".repeat(20)
+
+ var textLayout: TextLayoutResult? = null
+ var width: Int? = null
+
+ rule.setContent {
+ Providers(DensityAmbient provides density) {
+ CoreTextField(
+ value = TextFieldValue(string),
+ onValueChange = {},
+ textStyle = textStyle,
+ softWrap = true,
+ onTextLayout = { textLayout = it },
+ modifier = Modifier.width(composableWidth)
+ .onGloballyPositioned {
+ width = it.size.width
+ }
+ )
+ }
+ }
+
+ with(density) {
+ assertThat(textLayout).isNotNull()
+ assertThat(width).isNotNull()
+ assertThat(width).isEqualTo(composableWidth.toIntPx())
+ // each character has the same width as composable width
+ // therefore the string.length is the line count
+ assertThat(textLayout?.lineCount).isEqualTo(string.length)
+ }
+ }
+}
\ No newline at end of file
diff --git a/compose/foundation/foundation-text/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/TextFieldDelegateIntegrationTest.kt b/compose/foundation/foundation-text/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/TextFieldDelegateIntegrationTest.kt
index fe6de38..25895bc 100644
--- a/compose/foundation/foundation-text/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/TextFieldDelegateIntegrationTest.kt
+++ b/compose/foundation/foundation-text/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/TextFieldDelegateIntegrationTest.kt
@@ -32,7 +32,6 @@
import androidx.compose.ui.text.font.ResourceFont
import androidx.compose.ui.text.input.OffsetMap
import androidx.compose.ui.text.input.TextFieldValue
-import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.Constraints
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.LayoutDirection
@@ -100,49 +99,6 @@
}
@Test
- fun layout_width_constraint_min_width() {
- val textDelegate = TextDelegate(
- text = AnnotatedString("Hello, World"),
- style = TextStyle.Default,
- maxLines = 2,
- density = density,
- resourceLoader = resourceLoader
- )
- val layoutResult = textDelegate.layout(Constraints.fixedWidth(1024), layoutDirection)
- val requestWidth = layoutResult.size.width / 2
-
- val (width, _, _) = TextFieldDelegate.layout(
- textDelegate,
- Constraints.fixedWidth(requestWidth),
- layoutDirection
- )
-
- assertThat(width).isEqualTo(requestWidth)
- }
-
- @Test
- fun layout_width_constraint_max_width() {
- val textDelegate = TextDelegate(
- text = AnnotatedString("Hello, World"),
- style = TextStyle.Default,
- overflow = TextOverflow.Clip,
- softWrap = false,
- density = density,
- resourceLoader = resourceLoader
- )
- val layoutResult = textDelegate.layout(Constraints.fixedWidth(1024), layoutDirection)
- val requestWidth = layoutResult.size.width / 2
-
- val (width, _, _) = TextFieldDelegate.layout(
- textDelegate,
- Constraints.fixedWidth(requestWidth),
- layoutDirection
- )
-
- assertThat(width).isEqualTo(requestWidth)
- }
-
- @Test
fun layout_height_constraint_max_height() {
val textDelegate = TextDelegate(
text = AnnotatedString("Hello, World"),
@@ -183,117 +139,6 @@
assertThat(height).isEqualTo(requestHeight)
}
-
- @Test
- fun layout_empty_text_height_constraint_min_height() {
- val textDelegate = TextDelegate(
- text = AnnotatedString(""),
- style = TextStyle.Default,
- density = density,
- resourceLoader = resourceLoader
- )
- val layoutResult = textDelegate.layout(Constraints.fixedWidth(1024), layoutDirection)
- val requestHeight = layoutResult.size.height * 2
-
- val (_, height, _) = TextFieldDelegate.layout(
- textDelegate,
- Constraints.fixedHeight(requestHeight),
- layoutDirection
- )
-
- assertThat(height).isEqualTo(requestHeight)
- }
-
- @Test
- fun layout_empty_text_height_constraint_max_height() {
- val textDelegate = TextDelegate(
- text = AnnotatedString(""),
- style = TextStyle.Default,
- density = density,
- resourceLoader = resourceLoader
- )
- val layoutResult = textDelegate.layout(Constraints.fixedWidth(1024), layoutDirection)
- val requestHeight = layoutResult.size.height / 2
-
- val (_, height, _) = TextFieldDelegate.layout(
- textDelegate,
- Constraints.fixedHeight(requestHeight),
- layoutDirection
- )
-
- assertThat(height).isEqualTo(requestHeight)
- }
-
- @Test
- fun overflow_none_width_overflow() {
- val textDelegate = TextDelegate(
- text = AnnotatedString("Hello, World"),
- style = TextStyle.Default,
- overflow = TextOverflow.None,
- softWrap = false,
- density = density,
- resourceLoader = resourceLoader
- )
- val layoutResult = textDelegate.layout(Constraints.fixedWidth(1024), layoutDirection)
- val requestWidth = layoutResult.size.width / 2
-
- val (width, height, _) = TextFieldDelegate.layout(
- textDelegate,
- Constraints.fixedWidth(requestWidth),
- layoutDirection
- )
-
- // When overflow is None, TextFieldDelegate will report its actual size.
- assertThat(width).isEqualTo(layoutResult.size.width)
- assertThat(height).isEqualTo(layoutResult.size.height)
- }
-
- @Test
- fun overflow_none_height_overflow() {
- val textDelegate = TextDelegate(
- text = AnnotatedString("Hello, World"),
- style = TextStyle.Default,
- overflow = TextOverflow.None,
- density = density,
- resourceLoader = resourceLoader
- )
- val layoutResult = textDelegate.layout(Constraints.fixedWidth(1024), layoutDirection)
- val requestHeight = layoutResult.size.height / 2
-
- val (width, height, _) = TextFieldDelegate.layout(
- textDelegate,
- Constraints.fixedHeight(requestHeight),
- layoutDirection
- )
-
- // When overflow is None, TextFieldDelegate will report its actual size.
- assertThat(width).isEqualTo(layoutResult.size.width)
- assertThat(height).isEqualTo(layoutResult.size.height)
- }
-
- @Test
- fun overflow_none_empty_text_height_overflow() {
- val textDelegate = TextDelegate(
- text = AnnotatedString(""),
- style = TextStyle.Default,
- overflow = TextOverflow.None,
- density = density,
- resourceLoader = resourceLoader
- )
-
- val layoutResult = textDelegate.layout(Constraints.fixedWidth(1024), layoutDirection)
- val requestHeight = layoutResult.size.height / 2
-
- val (width, height, _) = TextFieldDelegate.layout(
- textDelegate,
- Constraints.fixedHeight(requestHeight),
- layoutDirection
- )
-
- // When overflow is None, TextFieldDelegate will report its actual size.
- assertThat(width).isEqualTo(layoutResult.size.width)
- assertThat(height).isEqualTo(layoutResult.size.height)
- }
}
private fun TextLayoutResult.toBitmap() = Bitmap.createBitmap(
diff --git a/compose/foundation/foundation-text/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/selection/SelectionContainerTest.kt b/compose/foundation/foundation-text/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/selection/SelectionContainerTest.kt
index f3de6db..54af8c0 100644
--- a/compose/foundation/foundation-text/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/selection/SelectionContainerTest.kt
+++ b/compose/foundation/foundation-text/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/selection/SelectionContainerTest.kt
@@ -20,6 +20,7 @@
import android.view.View
import android.view.ViewGroup
import androidx.activity.ComponentActivity
+import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.text.CoreText
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Providers
@@ -28,7 +29,6 @@
import androidx.compose.ui.Layout
import androidx.compose.ui.Modifier
import androidx.compose.ui.composed
-import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.hapticfeedback.HapticFeedback
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
import androidx.compose.ui.input.pointer.PointerEvent
@@ -37,9 +37,6 @@
import androidx.compose.ui.input.pointer.PointerInputFilter
import androidx.compose.ui.input.pointer.PointerInputModifier
import androidx.compose.ui.input.pointer.changedToUp
-import androidx.compose.ui.layout.LayoutCoordinates
-import androidx.compose.ui.node.Ref
-import androidx.compose.ui.onGloballyPositioned
import androidx.compose.ui.platform.HapticFeedBackAmbient
import androidx.compose.ui.selection.Selection
import androidx.compose.ui.selection.SelectionContainer
@@ -92,10 +89,6 @@
private val hapticFeedback = mock<HapticFeedback>()
- // Variables used to store position and size of the CoreText.
- private val textPosition = Ref<Offset>()
- private val textSize = Ref<IntSize>()
-
@Before
fun setup() {
rule.setContent {
@@ -112,7 +105,7 @@
) {
CoreText(
AnnotatedString(textContent),
- modifier = saveLayout(textPosition, textSize),
+ Modifier.fillMaxSize(),
style = TextStyle(fontFamily = fontFamily, fontSize = fontSize),
softWrap = true,
overflow = TextOverflow.Clip,
@@ -133,18 +126,15 @@
@SdkSuppress(minSdkVersion = 27)
fun press_to_cancel() {
// Setup. Long press to create a selection.
- // The long press position.
- // positionX is 50 pixels to the right of the CoreText's left edge.
- // positionY is the middle of the CoreText.
- val positionX = textPosition.value!!.x + 50f
- val positionY = textPosition.value!!.y + textSize.value!!.height / 2
- longPress(x = positionX, y = positionY)
+ // A reasonable number.
+ val position = 50f
+ longPress(x = position, y = position)
rule.runOnIdle {
assertThat(selection.value).isNotNull()
}
// Act.
- press(x = positionX, y = positionY)
+ press(x = position, y = position)
// Assert.
rule.runOnIdle {
@@ -160,17 +150,14 @@
@SdkSuppress(minSdkVersion = 27)
fun tapToCancelDoesNotBlockUp() {
// Setup. Long press to create a selection.
- // The long press position.
- // positionX is 50 pixels to the right of the CoreText's left edge.
- // positionY is the middle of the CoreText.
- val positionX = textPosition.value!!.x + 50f
- val positionY = textPosition.value!!.y + textSize.value!!.height / 2
- longPress(x = positionX, y = positionY)
+ // A reasonable number.
+ val position = 50f
+ longPress(x = position, y = position)
log.entries.clear()
// Act.
- press(x = positionX, y = positionY)
+ press(x = position, y = position)
// Assert.
rule.runOnIdle {
@@ -290,14 +277,6 @@
val pass: PointerEventPass
)
-private fun saveLayout(
- coords: Ref<Offset>,
- size: Ref<IntSize>
-): Modifier = Modifier.onGloballyPositioned { coordinates: LayoutCoordinates ->
- coords.value = coordinates.localToRoot(Offset.Zero)
- size.value = coordinates.size
-}
-
private fun Modifier.gestureSpy(
onPointerInput: (PointerEvent, PointerEventPass) -> Unit
): Modifier = composed {
diff --git a/compose/foundation/foundation-text/src/commonMain/kotlin/androidx/compose/foundation/text/CoreText.kt b/compose/foundation/foundation-text/src/commonMain/kotlin/androidx/compose/foundation/text/CoreText.kt
index bf00df8..d1d98d6 100644
--- a/compose/foundation/foundation-text/src/commonMain/kotlin/androidx/compose/foundation/text/CoreText.kt
+++ b/compose/foundation/foundation-text/src/commonMain/kotlin/androidx/compose/foundation/text/CoreText.kt
@@ -82,13 +82,6 @@
* [androidx.compose.foundation.Text], which is a higher level Text element that contains semantics and
* consumes style information from a theme.
*
- * During the measurement, CoreText tends to shrink its size and reports the minimal needed size
- * to its parent. It will ignore the minWidth and minHeight except when [TextAlign] is
- * [TextAlign.Justify]. When [TextAlign.Justify] is specified and [text] is short enough that
- * doesn't exceed minWidth, CoreText will justify the [text] to fill the given minWidth.
- * When input [text] is too long and exceeds the maxWidth/maxHeight constrains, it will determine
- * its size based on the [overflow] option.
- *
* @param text AnnotatedString encoding a styled text.
* @param modifier Modifier to apply to this layout node.
* @param style Style configuration for the text such as color, font, line height etc.
diff --git a/compose/foundation/foundation-text/src/commonMain/kotlin/androidx/compose/foundation/text/CoreTextField.kt b/compose/foundation/foundation-text/src/commonMain/kotlin/androidx/compose/foundation/text/CoreTextField.kt
index 0d7659d..2e23228 100644
--- a/compose/foundation/foundation-text/src/commonMain/kotlin/androidx/compose/foundation/text/CoreTextField.kt
+++ b/compose/foundation/foundation-text/src/commonMain/kotlin/androidx/compose/foundation/text/CoreTextField.kt
@@ -37,7 +37,6 @@
import androidx.compose.runtime.onDispose
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
-import androidx.compose.runtime.state
import androidx.compose.runtime.structuralEqualityPolicy
import androidx.compose.ui.Layout
import androidx.compose.ui.Modifier
@@ -96,9 +95,9 @@
import androidx.compose.ui.text.input.OffsetMap
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.text.input.VisualTransformation
+import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.dp
import androidx.compose.ui.util.annotation.VisibleForTesting
-import androidx.compose.ui.unit.Density
import kotlin.math.max
import kotlin.math.roundToInt
@@ -145,6 +144,8 @@
* [SoftwareKeyboardController] instance which can be used for requesting input show/hide software
* keyboard.
* @param cursorColor Color of the cursor. If [Color.Unspecified], there will be no cursor drawn
+ * @param softWrap Whether the text should break at soft line breaks. If false, the glyphs in the
+ * text will be positioned as if there was unlimited horizontal space.
*/
@Composable
@OptIn(
@@ -162,7 +163,8 @@
visualTransformation: VisualTransformation = VisualTransformation.None,
onTextLayout: (TextLayoutResult) -> Unit = {},
onTextInputStarted: (SoftwareKeyboardController) -> Unit = {},
- cursorColor: Color = Color.Unspecified
+ cursorColor: Color = Color.Unspecified,
+ softWrap: Boolean = true
) {
// If developer doesn't pass new value to TextField, recompose won't happen but internal state
// and IME may think it is updated. To fix this inconsistent state, enforce recompose.
@@ -186,6 +188,7 @@
TextDelegate(
text = visualText,
style = textStyle,
+ softWrap = softWrap,
density = density,
resourceLoader = resourceLoader
)
@@ -194,6 +197,7 @@
state.update(
visualText,
textStyle,
+ softWrap,
density,
resourceLoader,
onValueChange,
@@ -537,6 +541,7 @@
fun update(
visualText: AnnotatedString,
textStyle: TextStyle,
+ softWrap: Boolean,
density: Density,
resourceLoader: Font.ResourceLoader,
onValueChange: (TextFieldValue) -> Unit,
@@ -549,6 +554,7 @@
current = textDelegate,
text = visualText,
style = textStyle,
+ softWrap = softWrap,
density = density,
resourceLoader = resourceLoader,
placeholders = emptyList()
diff --git a/compose/foundation/foundation-text/src/commonMain/kotlin/androidx/compose/foundation/text/TextFieldDelegate.kt b/compose/foundation/foundation-text/src/commonMain/kotlin/androidx/compose/foundation/text/TextFieldDelegate.kt
index 5d93aee..0a48ef2a 100644
--- a/compose/foundation/foundation-text/src/commonMain/kotlin/androidx/compose/foundation/text/TextFieldDelegate.kt
+++ b/compose/foundation/foundation-text/src/commonMain/kotlin/androidx/compose/foundation/text/TextFieldDelegate.kt
@@ -47,7 +47,6 @@
import androidx.compose.ui.text.input.TransformedText
import androidx.compose.ui.text.resolveDefaults
import androidx.compose.ui.text.style.TextDecoration
-import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.Constraints
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.LayoutDirection
@@ -105,12 +104,7 @@
layoutDirection: LayoutDirection,
prevResultText: TextLayoutResult? = null
): Triple<Int, Int, TextLayoutResult> {
- val layoutResult = textDelegate.layout(
- constraints = constraints,
- layoutDirection = layoutDirection,
- prevResult = prevResultText,
- respectMinConstraints = true
- )
+ val layoutResult = textDelegate.layout(constraints, layoutDirection, prevResultText)
val isEmptyText = textDelegate.text.text.isEmpty()
val height = if (isEmptyText) {
@@ -119,12 +113,7 @@
density = textDelegate.density,
resourceLoader = textDelegate.resourceLoader
)
- when (textDelegate.overflow) {
- TextOverflow.None ->
- singleLineHeight.coerceAtLeast(constraints.minHeight)
- TextOverflow.Clip, TextOverflow.Ellipsis ->
- constraints.constrainHeight(singleLineHeight)
- }
+ constraints.constrainHeight(singleLineHeight)
} else {
layoutResult.size.height
}
diff --git a/compose/foundation/foundation-text/src/test/kotlin/androidx/compose/foundation/text/TextFieldDelegateTest.kt b/compose/foundation/foundation-text/src/test/kotlin/androidx/compose/foundation/text/TextFieldDelegateTest.kt
index 5583123..d8f4d2b 100644
--- a/compose/foundation/foundation-text/src/test/kotlin/androidx/compose/foundation/text/TextFieldDelegateTest.kt
+++ b/compose/foundation/foundation-text/src/test/kotlin/androidx/compose/foundation/text/TextFieldDelegateTest.kt
@@ -303,7 +303,7 @@
whenever(mDelegate.style).thenReturn(TextStyle())
whenever(mDelegate.density).thenReturn(Density(1.0f))
whenever(mDelegate.resourceLoader).thenReturn(mock())
- whenever(mDelegate.layout(Constraints(anyLong()), any(), eq(null), eq(true)))
+ whenever(mDelegate.layout(Constraints(anyLong()), any(), eq(null)))
.thenReturn(textLayoutResult)
val (width, height, layoutResult) = TextFieldDelegate.layout(
diff --git a/compose/foundation/foundation/api/current.txt b/compose/foundation/foundation/api/current.txt
index a670f46..a799ead 100644
--- a/compose/foundation/foundation/api/current.txt
+++ b/compose/foundation/foundation/api/current.txt
@@ -143,12 +143,12 @@
method @androidx.compose.runtime.Composable public static void ScrollableColumn(optional androidx.compose.ui.Modifier modifier, optional androidx.compose.foundation.ScrollState scrollState, optional androidx.compose.foundation.layout.Arrangement.Vertical verticalArrangement, optional androidx.compose.ui.Alignment.Horizontal horizontalAlignment, optional boolean reverseScrollDirection, optional boolean isScrollEnabled, optional androidx.compose.foundation.layout.PaddingValues contentPadding, kotlin.jvm.functions.Function1<? super androidx.compose.foundation.layout.ColumnScope,kotlin.Unit> children);
method @androidx.compose.runtime.Composable public static void ScrollableRow(optional androidx.compose.ui.Modifier modifier, optional androidx.compose.foundation.ScrollState scrollState, optional androidx.compose.foundation.layout.Arrangement.Horizontal horizontalArrangement, optional androidx.compose.ui.Alignment.Vertical verticalAlignment, optional boolean reverseScrollDirection, optional boolean isScrollEnabled, optional androidx.compose.foundation.layout.PaddingValues contentPadding, kotlin.jvm.functions.Function1<? super androidx.compose.foundation.layout.RowScope,kotlin.Unit> children);
method public static androidx.compose.ui.Modifier horizontalScroll(androidx.compose.ui.Modifier, androidx.compose.foundation.ScrollState state, optional boolean enabled, optional boolean reverseScrolling);
- method @androidx.compose.runtime.Composable public static androidx.compose.foundation.ScrollState rememberScrollState(optional float initial);
+ method @androidx.compose.runtime.Composable public static androidx.compose.foundation.ScrollState rememberScrollState(optional float initial, optional androidx.compose.foundation.InteractionState? interactionState);
method public static androidx.compose.ui.Modifier verticalScroll(androidx.compose.ui.Modifier, androidx.compose.foundation.ScrollState state, optional boolean enabled, optional boolean reverseScrolling);
}
@androidx.compose.runtime.Stable public final class ScrollState {
- ctor public ScrollState(float initial, internal androidx.compose.foundation.animation.FlingConfig flingConfig, androidx.compose.animation.core.AnimationClockObservable animationClock);
+ ctor public ScrollState(float initial, internal androidx.compose.foundation.animation.FlingConfig flingConfig, androidx.compose.animation.core.AnimationClockObservable animationClock, androidx.compose.foundation.InteractionState? interactionState);
method public float getMaxValue();
method public float getValue();
method public boolean isAnimationRunning();
@@ -164,7 +164,7 @@
}
public static final class ScrollState.Companion {
- method public androidx.compose.runtime.savedinstancestate.Saver<androidx.compose.foundation.ScrollState,?> Saver(androidx.compose.foundation.animation.FlingConfig flingConfig, androidx.compose.animation.core.AnimationClockObservable animationClock);
+ method public androidx.compose.runtime.savedinstancestate.Saver<androidx.compose.foundation.ScrollState,?> Saver(androidx.compose.foundation.animation.FlingConfig flingConfig, androidx.compose.animation.core.AnimationClockObservable animationClock, androidx.compose.foundation.InteractionState? interactionState);
}
public final class Strings {
@@ -245,19 +245,15 @@
}
public final class ScrollableController {
- ctor public ScrollableController(kotlin.jvm.functions.Function1<? super java.lang.Float,java.lang.Float> consumeScrollDelta, androidx.compose.foundation.animation.FlingConfig flingConfig, androidx.compose.animation.core.AnimationClockObservable animationClock);
- method public kotlin.jvm.functions.Function1<java.lang.Float,java.lang.Float> getConsumeScrollDelta();
- method public androidx.compose.foundation.animation.FlingConfig getFlingConfig();
+ ctor public ScrollableController(internal kotlin.jvm.functions.Function1<? super java.lang.Float,java.lang.Float> consumeScrollDelta, internal androidx.compose.foundation.animation.FlingConfig flingConfig, androidx.compose.animation.core.AnimationClockObservable animationClock, internal androidx.compose.foundation.InteractionState? interactionState);
method public boolean isAnimationRunning();
method public void smoothScrollBy(float value, optional androidx.compose.animation.core.AnimationSpec<java.lang.Float> spec, optional kotlin.jvm.functions.Function2<? super androidx.compose.animation.core.AnimationEndReason,? super java.lang.Float,kotlin.Unit> onEnd);
method public void stopAnimation();
- property public final kotlin.jvm.functions.Function1<java.lang.Float,java.lang.Float> consumeScrollDelta;
- property public final androidx.compose.foundation.animation.FlingConfig flingConfig;
property public final boolean isAnimationRunning;
}
public final class ScrollableKt {
- method @androidx.compose.runtime.Composable public static androidx.compose.foundation.gestures.ScrollableController rememberScrollableController(kotlin.jvm.functions.Function1<? super java.lang.Float,java.lang.Float> consumeScrollDelta);
+ method @androidx.compose.runtime.Composable public static androidx.compose.foundation.gestures.ScrollableController rememberScrollableController(optional androidx.compose.foundation.InteractionState? interactionState, kotlin.jvm.functions.Function1<? super java.lang.Float,java.lang.Float> consumeScrollDelta);
method public static androidx.compose.ui.Modifier scrollable(androidx.compose.ui.Modifier, androidx.compose.ui.gesture.scrollorientationlocking.Orientation orientation, androidx.compose.foundation.gestures.ScrollableController controller, optional boolean enabled, optional boolean reverseDirection, optional kotlin.jvm.functions.Function1<? super androidx.compose.ui.gesture.Direction,java.lang.Boolean> canScroll, optional kotlin.jvm.functions.Function1<? super androidx.compose.ui.geometry.Offset,kotlin.Unit> onScrollStarted, optional kotlin.jvm.functions.Function1<? super java.lang.Float,kotlin.Unit> onScrollStopped);
}
@@ -315,20 +311,22 @@
}
@androidx.compose.runtime.Stable public final class LazyListState {
- ctor public LazyListState(int firstVisibleItemIndex, int firstVisibleItemScrollOffset, androidx.compose.foundation.animation.FlingConfig flingConfig, androidx.compose.animation.core.AnimationClockObservable animationClock);
+ ctor public LazyListState(int firstVisibleItemIndex, int firstVisibleItemScrollOffset, androidx.compose.foundation.InteractionState? interactionState, androidx.compose.foundation.animation.FlingConfig flingConfig, androidx.compose.animation.core.AnimationClockObservable animationClock);
method public int getFirstVisibleItemIndex();
method public int getFirstVisibleItemScrollOffset();
+ method public boolean isAnimationRunning();
property public final int firstVisibleItemIndex;
property public final int firstVisibleItemScrollOffset;
+ property public final boolean isAnimationRunning;
field public static final androidx.compose.foundation.lazy.LazyListState.Companion Companion;
}
public static final class LazyListState.Companion {
- method public androidx.compose.runtime.savedinstancestate.Saver<androidx.compose.foundation.lazy.LazyListState,?> Saver(androidx.compose.foundation.animation.FlingConfig flingConfig, androidx.compose.animation.core.AnimationClockObservable animationClock);
+ method public androidx.compose.runtime.savedinstancestate.Saver<androidx.compose.foundation.lazy.LazyListState,?> Saver(androidx.compose.foundation.animation.FlingConfig flingConfig, androidx.compose.animation.core.AnimationClockObservable animationClock, androidx.compose.foundation.InteractionState? interactionState);
}
public final class LazyListStateKt {
- method @androidx.compose.runtime.Composable public static androidx.compose.foundation.lazy.LazyListState rememberLazyListState(optional int initialFirstVisibleItemIndex, optional int initialFirstVisibleItemScrollOffset);
+ method @androidx.compose.runtime.Composable public static androidx.compose.foundation.lazy.LazyListState rememberLazyListState(optional int initialFirstVisibleItemIndex, optional int initialFirstVisibleItemScrollOffset, optional androidx.compose.foundation.InteractionState? interactionState);
}
}
diff --git a/compose/foundation/foundation/api/public_plus_experimental_current.txt b/compose/foundation/foundation/api/public_plus_experimental_current.txt
index a670f46..a799ead 100644
--- a/compose/foundation/foundation/api/public_plus_experimental_current.txt
+++ b/compose/foundation/foundation/api/public_plus_experimental_current.txt
@@ -143,12 +143,12 @@
method @androidx.compose.runtime.Composable public static void ScrollableColumn(optional androidx.compose.ui.Modifier modifier, optional androidx.compose.foundation.ScrollState scrollState, optional androidx.compose.foundation.layout.Arrangement.Vertical verticalArrangement, optional androidx.compose.ui.Alignment.Horizontal horizontalAlignment, optional boolean reverseScrollDirection, optional boolean isScrollEnabled, optional androidx.compose.foundation.layout.PaddingValues contentPadding, kotlin.jvm.functions.Function1<? super androidx.compose.foundation.layout.ColumnScope,kotlin.Unit> children);
method @androidx.compose.runtime.Composable public static void ScrollableRow(optional androidx.compose.ui.Modifier modifier, optional androidx.compose.foundation.ScrollState scrollState, optional androidx.compose.foundation.layout.Arrangement.Horizontal horizontalArrangement, optional androidx.compose.ui.Alignment.Vertical verticalAlignment, optional boolean reverseScrollDirection, optional boolean isScrollEnabled, optional androidx.compose.foundation.layout.PaddingValues contentPadding, kotlin.jvm.functions.Function1<? super androidx.compose.foundation.layout.RowScope,kotlin.Unit> children);
method public static androidx.compose.ui.Modifier horizontalScroll(androidx.compose.ui.Modifier, androidx.compose.foundation.ScrollState state, optional boolean enabled, optional boolean reverseScrolling);
- method @androidx.compose.runtime.Composable public static androidx.compose.foundation.ScrollState rememberScrollState(optional float initial);
+ method @androidx.compose.runtime.Composable public static androidx.compose.foundation.ScrollState rememberScrollState(optional float initial, optional androidx.compose.foundation.InteractionState? interactionState);
method public static androidx.compose.ui.Modifier verticalScroll(androidx.compose.ui.Modifier, androidx.compose.foundation.ScrollState state, optional boolean enabled, optional boolean reverseScrolling);
}
@androidx.compose.runtime.Stable public final class ScrollState {
- ctor public ScrollState(float initial, internal androidx.compose.foundation.animation.FlingConfig flingConfig, androidx.compose.animation.core.AnimationClockObservable animationClock);
+ ctor public ScrollState(float initial, internal androidx.compose.foundation.animation.FlingConfig flingConfig, androidx.compose.animation.core.AnimationClockObservable animationClock, androidx.compose.foundation.InteractionState? interactionState);
method public float getMaxValue();
method public float getValue();
method public boolean isAnimationRunning();
@@ -164,7 +164,7 @@
}
public static final class ScrollState.Companion {
- method public androidx.compose.runtime.savedinstancestate.Saver<androidx.compose.foundation.ScrollState,?> Saver(androidx.compose.foundation.animation.FlingConfig flingConfig, androidx.compose.animation.core.AnimationClockObservable animationClock);
+ method public androidx.compose.runtime.savedinstancestate.Saver<androidx.compose.foundation.ScrollState,?> Saver(androidx.compose.foundation.animation.FlingConfig flingConfig, androidx.compose.animation.core.AnimationClockObservable animationClock, androidx.compose.foundation.InteractionState? interactionState);
}
public final class Strings {
@@ -245,19 +245,15 @@
}
public final class ScrollableController {
- ctor public ScrollableController(kotlin.jvm.functions.Function1<? super java.lang.Float,java.lang.Float> consumeScrollDelta, androidx.compose.foundation.animation.FlingConfig flingConfig, androidx.compose.animation.core.AnimationClockObservable animationClock);
- method public kotlin.jvm.functions.Function1<java.lang.Float,java.lang.Float> getConsumeScrollDelta();
- method public androidx.compose.foundation.animation.FlingConfig getFlingConfig();
+ ctor public ScrollableController(internal kotlin.jvm.functions.Function1<? super java.lang.Float,java.lang.Float> consumeScrollDelta, internal androidx.compose.foundation.animation.FlingConfig flingConfig, androidx.compose.animation.core.AnimationClockObservable animationClock, internal androidx.compose.foundation.InteractionState? interactionState);
method public boolean isAnimationRunning();
method public void smoothScrollBy(float value, optional androidx.compose.animation.core.AnimationSpec<java.lang.Float> spec, optional kotlin.jvm.functions.Function2<? super androidx.compose.animation.core.AnimationEndReason,? super java.lang.Float,kotlin.Unit> onEnd);
method public void stopAnimation();
- property public final kotlin.jvm.functions.Function1<java.lang.Float,java.lang.Float> consumeScrollDelta;
- property public final androidx.compose.foundation.animation.FlingConfig flingConfig;
property public final boolean isAnimationRunning;
}
public final class ScrollableKt {
- method @androidx.compose.runtime.Composable public static androidx.compose.foundation.gestures.ScrollableController rememberScrollableController(kotlin.jvm.functions.Function1<? super java.lang.Float,java.lang.Float> consumeScrollDelta);
+ method @androidx.compose.runtime.Composable public static androidx.compose.foundation.gestures.ScrollableController rememberScrollableController(optional androidx.compose.foundation.InteractionState? interactionState, kotlin.jvm.functions.Function1<? super java.lang.Float,java.lang.Float> consumeScrollDelta);
method public static androidx.compose.ui.Modifier scrollable(androidx.compose.ui.Modifier, androidx.compose.ui.gesture.scrollorientationlocking.Orientation orientation, androidx.compose.foundation.gestures.ScrollableController controller, optional boolean enabled, optional boolean reverseDirection, optional kotlin.jvm.functions.Function1<? super androidx.compose.ui.gesture.Direction,java.lang.Boolean> canScroll, optional kotlin.jvm.functions.Function1<? super androidx.compose.ui.geometry.Offset,kotlin.Unit> onScrollStarted, optional kotlin.jvm.functions.Function1<? super java.lang.Float,kotlin.Unit> onScrollStopped);
}
@@ -315,20 +311,22 @@
}
@androidx.compose.runtime.Stable public final class LazyListState {
- ctor public LazyListState(int firstVisibleItemIndex, int firstVisibleItemScrollOffset, androidx.compose.foundation.animation.FlingConfig flingConfig, androidx.compose.animation.core.AnimationClockObservable animationClock);
+ ctor public LazyListState(int firstVisibleItemIndex, int firstVisibleItemScrollOffset, androidx.compose.foundation.InteractionState? interactionState, androidx.compose.foundation.animation.FlingConfig flingConfig, androidx.compose.animation.core.AnimationClockObservable animationClock);
method public int getFirstVisibleItemIndex();
method public int getFirstVisibleItemScrollOffset();
+ method public boolean isAnimationRunning();
property public final int firstVisibleItemIndex;
property public final int firstVisibleItemScrollOffset;
+ property public final boolean isAnimationRunning;
field public static final androidx.compose.foundation.lazy.LazyListState.Companion Companion;
}
public static final class LazyListState.Companion {
- method public androidx.compose.runtime.savedinstancestate.Saver<androidx.compose.foundation.lazy.LazyListState,?> Saver(androidx.compose.foundation.animation.FlingConfig flingConfig, androidx.compose.animation.core.AnimationClockObservable animationClock);
+ method public androidx.compose.runtime.savedinstancestate.Saver<androidx.compose.foundation.lazy.LazyListState,?> Saver(androidx.compose.foundation.animation.FlingConfig flingConfig, androidx.compose.animation.core.AnimationClockObservable animationClock, androidx.compose.foundation.InteractionState? interactionState);
}
public final class LazyListStateKt {
- method @androidx.compose.runtime.Composable public static androidx.compose.foundation.lazy.LazyListState rememberLazyListState(optional int initialFirstVisibleItemIndex, optional int initialFirstVisibleItemScrollOffset);
+ method @androidx.compose.runtime.Composable public static androidx.compose.foundation.lazy.LazyListState rememberLazyListState(optional int initialFirstVisibleItemIndex, optional int initialFirstVisibleItemScrollOffset, optional androidx.compose.foundation.InteractionState? interactionState);
}
}
diff --git a/compose/foundation/foundation/api/restricted_current.txt b/compose/foundation/foundation/api/restricted_current.txt
index a670f46..a799ead 100644
--- a/compose/foundation/foundation/api/restricted_current.txt
+++ b/compose/foundation/foundation/api/restricted_current.txt
@@ -143,12 +143,12 @@
method @androidx.compose.runtime.Composable public static void ScrollableColumn(optional androidx.compose.ui.Modifier modifier, optional androidx.compose.foundation.ScrollState scrollState, optional androidx.compose.foundation.layout.Arrangement.Vertical verticalArrangement, optional androidx.compose.ui.Alignment.Horizontal horizontalAlignment, optional boolean reverseScrollDirection, optional boolean isScrollEnabled, optional androidx.compose.foundation.layout.PaddingValues contentPadding, kotlin.jvm.functions.Function1<? super androidx.compose.foundation.layout.ColumnScope,kotlin.Unit> children);
method @androidx.compose.runtime.Composable public static void ScrollableRow(optional androidx.compose.ui.Modifier modifier, optional androidx.compose.foundation.ScrollState scrollState, optional androidx.compose.foundation.layout.Arrangement.Horizontal horizontalArrangement, optional androidx.compose.ui.Alignment.Vertical verticalAlignment, optional boolean reverseScrollDirection, optional boolean isScrollEnabled, optional androidx.compose.foundation.layout.PaddingValues contentPadding, kotlin.jvm.functions.Function1<? super androidx.compose.foundation.layout.RowScope,kotlin.Unit> children);
method public static androidx.compose.ui.Modifier horizontalScroll(androidx.compose.ui.Modifier, androidx.compose.foundation.ScrollState state, optional boolean enabled, optional boolean reverseScrolling);
- method @androidx.compose.runtime.Composable public static androidx.compose.foundation.ScrollState rememberScrollState(optional float initial);
+ method @androidx.compose.runtime.Composable public static androidx.compose.foundation.ScrollState rememberScrollState(optional float initial, optional androidx.compose.foundation.InteractionState? interactionState);
method public static androidx.compose.ui.Modifier verticalScroll(androidx.compose.ui.Modifier, androidx.compose.foundation.ScrollState state, optional boolean enabled, optional boolean reverseScrolling);
}
@androidx.compose.runtime.Stable public final class ScrollState {
- ctor public ScrollState(float initial, internal androidx.compose.foundation.animation.FlingConfig flingConfig, androidx.compose.animation.core.AnimationClockObservable animationClock);
+ ctor public ScrollState(float initial, internal androidx.compose.foundation.animation.FlingConfig flingConfig, androidx.compose.animation.core.AnimationClockObservable animationClock, androidx.compose.foundation.InteractionState? interactionState);
method public float getMaxValue();
method public float getValue();
method public boolean isAnimationRunning();
@@ -164,7 +164,7 @@
}
public static final class ScrollState.Companion {
- method public androidx.compose.runtime.savedinstancestate.Saver<androidx.compose.foundation.ScrollState,?> Saver(androidx.compose.foundation.animation.FlingConfig flingConfig, androidx.compose.animation.core.AnimationClockObservable animationClock);
+ method public androidx.compose.runtime.savedinstancestate.Saver<androidx.compose.foundation.ScrollState,?> Saver(androidx.compose.foundation.animation.FlingConfig flingConfig, androidx.compose.animation.core.AnimationClockObservable animationClock, androidx.compose.foundation.InteractionState? interactionState);
}
public final class Strings {
@@ -245,19 +245,15 @@
}
public final class ScrollableController {
- ctor public ScrollableController(kotlin.jvm.functions.Function1<? super java.lang.Float,java.lang.Float> consumeScrollDelta, androidx.compose.foundation.animation.FlingConfig flingConfig, androidx.compose.animation.core.AnimationClockObservable animationClock);
- method public kotlin.jvm.functions.Function1<java.lang.Float,java.lang.Float> getConsumeScrollDelta();
- method public androidx.compose.foundation.animation.FlingConfig getFlingConfig();
+ ctor public ScrollableController(internal kotlin.jvm.functions.Function1<? super java.lang.Float,java.lang.Float> consumeScrollDelta, internal androidx.compose.foundation.animation.FlingConfig flingConfig, androidx.compose.animation.core.AnimationClockObservable animationClock, internal androidx.compose.foundation.InteractionState? interactionState);
method public boolean isAnimationRunning();
method public void smoothScrollBy(float value, optional androidx.compose.animation.core.AnimationSpec<java.lang.Float> spec, optional kotlin.jvm.functions.Function2<? super androidx.compose.animation.core.AnimationEndReason,? super java.lang.Float,kotlin.Unit> onEnd);
method public void stopAnimation();
- property public final kotlin.jvm.functions.Function1<java.lang.Float,java.lang.Float> consumeScrollDelta;
- property public final androidx.compose.foundation.animation.FlingConfig flingConfig;
property public final boolean isAnimationRunning;
}
public final class ScrollableKt {
- method @androidx.compose.runtime.Composable public static androidx.compose.foundation.gestures.ScrollableController rememberScrollableController(kotlin.jvm.functions.Function1<? super java.lang.Float,java.lang.Float> consumeScrollDelta);
+ method @androidx.compose.runtime.Composable public static androidx.compose.foundation.gestures.ScrollableController rememberScrollableController(optional androidx.compose.foundation.InteractionState? interactionState, kotlin.jvm.functions.Function1<? super java.lang.Float,java.lang.Float> consumeScrollDelta);
method public static androidx.compose.ui.Modifier scrollable(androidx.compose.ui.Modifier, androidx.compose.ui.gesture.scrollorientationlocking.Orientation orientation, androidx.compose.foundation.gestures.ScrollableController controller, optional boolean enabled, optional boolean reverseDirection, optional kotlin.jvm.functions.Function1<? super androidx.compose.ui.gesture.Direction,java.lang.Boolean> canScroll, optional kotlin.jvm.functions.Function1<? super androidx.compose.ui.geometry.Offset,kotlin.Unit> onScrollStarted, optional kotlin.jvm.functions.Function1<? super java.lang.Float,kotlin.Unit> onScrollStopped);
}
@@ -315,20 +311,22 @@
}
@androidx.compose.runtime.Stable public final class LazyListState {
- ctor public LazyListState(int firstVisibleItemIndex, int firstVisibleItemScrollOffset, androidx.compose.foundation.animation.FlingConfig flingConfig, androidx.compose.animation.core.AnimationClockObservable animationClock);
+ ctor public LazyListState(int firstVisibleItemIndex, int firstVisibleItemScrollOffset, androidx.compose.foundation.InteractionState? interactionState, androidx.compose.foundation.animation.FlingConfig flingConfig, androidx.compose.animation.core.AnimationClockObservable animationClock);
method public int getFirstVisibleItemIndex();
method public int getFirstVisibleItemScrollOffset();
+ method public boolean isAnimationRunning();
property public final int firstVisibleItemIndex;
property public final int firstVisibleItemScrollOffset;
+ property public final boolean isAnimationRunning;
field public static final androidx.compose.foundation.lazy.LazyListState.Companion Companion;
}
public static final class LazyListState.Companion {
- method public androidx.compose.runtime.savedinstancestate.Saver<androidx.compose.foundation.lazy.LazyListState,?> Saver(androidx.compose.foundation.animation.FlingConfig flingConfig, androidx.compose.animation.core.AnimationClockObservable animationClock);
+ method public androidx.compose.runtime.savedinstancestate.Saver<androidx.compose.foundation.lazy.LazyListState,?> Saver(androidx.compose.foundation.animation.FlingConfig flingConfig, androidx.compose.animation.core.AnimationClockObservable animationClock, androidx.compose.foundation.InteractionState? interactionState);
}
public final class LazyListStateKt {
- method @androidx.compose.runtime.Composable public static androidx.compose.foundation.lazy.LazyListState rememberLazyListState(optional int initialFirstVisibleItemIndex, optional int initialFirstVisibleItemScrollOffset);
+ method @androidx.compose.runtime.Composable public static androidx.compose.foundation.lazy.LazyListState rememberLazyListState(optional int initialFirstVisibleItemIndex, optional int initialFirstVisibleItemScrollOffset, optional androidx.compose.foundation.InteractionState? interactionState);
}
}
diff --git a/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/ListDemos.kt b/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/ListDemos.kt
index c36dddf..16cca1f 100644
--- a/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/ListDemos.kt
+++ b/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/ListDemos.kt
@@ -19,12 +19,13 @@
import androidx.compose.foundation.Text
import androidx.compose.foundation.AmbientContentColor
import androidx.compose.foundation.AmbientTextStyle
+import androidx.compose.foundation.Interaction
+import androidx.compose.foundation.InteractionState
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ExperimentalLayout
-import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
@@ -111,14 +112,15 @@
@OptIn(ExperimentalLayout::class)
@Composable
private fun ListHoistedStateDemo() {
- val state = rememberLazyListState()
+ val interactionState = remember { InteractionState() }
+ val state = rememberLazyListState(interactionState = interactionState)
Column {
- FlowRow {
- Text(
- "First item: ${state.firstVisibleItemIndex}",
- style = AmbientTextStyle.current.copy(fontSize = 30.sp)
- )
- }
+ Text(
+ "First item: ${state.firstVisibleItemIndex}",
+ fontSize = 30.sp
+ )
+ Text("Dragging: ${interactionState.contains(Interaction.Dragged)}", fontSize = 30.sp)
+ Text("Flinging: ${state.isAnimationRunning}", fontSize = 30.sp)
LazyColumnFor(
(0..1000).toList(),
Modifier.fillMaxWidth(),
diff --git a/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/ScrollerSamples.kt b/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/ScrollerSamples.kt
index 4c36c07..92af623 100644
--- a/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/ScrollerSamples.kt
+++ b/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/ScrollerSamples.kt
@@ -17,13 +17,13 @@
package androidx.compose.foundation.samples
import androidx.annotation.Sampled
-import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.ScrollableColumn
import androidx.compose.foundation.ScrollableRow
import androidx.compose.foundation.Text
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.horizontalScroll
+import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ScrollableTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ScrollableTest.kt
index 92f95d6..07ad2cf 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ScrollableTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ScrollableTest.kt
@@ -40,12 +40,15 @@
import androidx.ui.test.TestUiDispatcher
import androidx.ui.test.center
import androidx.ui.test.createComposeRule
+import androidx.ui.test.down
import androidx.ui.test.monotonicFrameAnimationClockOf
+import androidx.ui.test.moveBy
import androidx.ui.test.onNodeWithTag
import androidx.ui.test.performGesture
import androidx.ui.test.runBlockingWithManualClock
import androidx.ui.test.swipe
import androidx.ui.test.swipeWithVelocity
+import androidx.ui.test.up
import com.google.common.truth.Truth.assertThat
import com.google.common.truth.Truth.assertWithMessage
import kotlinx.coroutines.withContext
@@ -540,6 +543,108 @@
}
}
+ @Test
+ @OptIn(ExperimentalTesting::class)
+ fun scrollable_interactionState() = runBlockingWithManualClock { clock ->
+ val interactionState = InteractionState()
+ var total = 0f
+ val controller = ScrollableController(
+ consumeScrollDelta = {
+ total += it
+ it
+ },
+ flingConfig = FlingConfig(decayAnimation = ExponentialDecay()),
+ animationClock = monotonicFrameAnimationClockOf(coroutineContext, clock),
+ interactionState = interactionState
+ )
+
+ setScrollableContent {
+ Modifier.scrollable(
+ Orientation.Horizontal,
+ controller = controller
+ ) {}
+ }
+
+ rule.runOnIdle {
+ assertThat(interactionState.value).doesNotContain(Interaction.Dragged)
+ }
+
+ rule.onNodeWithTag(scrollableBoxTag)
+ .performGesture {
+ down(Offset(visibleSize.width / 4f, visibleSize.height / 2f))
+ moveBy(Offset(visibleSize.width / 2f, 0f))
+ }
+
+ rule.runOnIdle {
+ assertThat(interactionState.value).contains(Interaction.Dragged)
+ }
+
+ rule.onNodeWithTag(scrollableBoxTag)
+ .performGesture {
+ up()
+ }
+
+ rule.runOnIdle {
+ assertThat(interactionState.value).doesNotContain(Interaction.Dragged)
+ }
+ }
+
+ @Test
+ @OptIn(ExperimentalTesting::class)
+ fun scrollable_interactionState_resetWhenDisposed() = runBlockingWithManualClock { clock ->
+ val interactionState = InteractionState()
+ var emitScrollableBox by mutableStateOf(true)
+ var total = 0f
+ val controller = ScrollableController(
+ consumeScrollDelta = {
+ total += it
+ it
+ },
+ flingConfig = FlingConfig(decayAnimation = ExponentialDecay()),
+ animationClock = monotonicFrameAnimationClockOf(coroutineContext, clock),
+ interactionState = interactionState
+ )
+
+ rule.setContent {
+ Box {
+ if (emitScrollableBox) {
+ Box(
+ modifier = Modifier
+ .testTag(scrollableBoxTag)
+ .preferredSize(100.dp)
+ .scrollable(
+ orientation = Orientation.Horizontal,
+ controller = controller
+ ) {}
+ )
+ }
+ }
+ }
+
+ rule.runOnIdle {
+ assertThat(interactionState.value).doesNotContain(Interaction.Dragged)
+ }
+
+ rule.onNodeWithTag(scrollableBoxTag)
+ .performGesture {
+ down(Offset(visibleSize.width / 4f, visibleSize.height / 2f))
+ moveBy(Offset(visibleSize.width / 2f, 0f))
+ }
+
+ rule.runOnIdle {
+ assertThat(interactionState.value).contains(Interaction.Dragged)
+ }
+
+ // Dispose scrollable
+ rule.runOnIdle {
+ emitScrollableBox = false
+ }
+
+ rule.runOnIdle {
+ assertThat(interactionState.value).doesNotContain(Interaction.Dragged)
+ }
+ }
+
private fun setScrollableContent(scrollableModifierFactory: @Composable () -> Modifier) {
rule.setContent {
Box {
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyColumnForTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyColumnForTest.kt
index 6905ad4..96940b0 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyColumnForTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyColumnForTest.kt
@@ -16,7 +16,10 @@
package androidx.compose.foundation.lazy
+import androidx.compose.animation.core.ExponentialDecay
+import androidx.compose.animation.core.ManualAnimationClock
import androidx.compose.foundation.Text
+import androidx.compose.foundation.animation.FlingConfig
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
@@ -54,6 +57,7 @@
import androidx.ui.test.assertTopPositionInRootIsEqualTo
import androidx.ui.test.assertWidthIsEqualTo
import androidx.ui.test.center
+import androidx.ui.test.click
import androidx.ui.test.createComposeRule
import androidx.ui.test.getUnclippedBoundsInRoot
import androidx.ui.test.onChildren
@@ -789,6 +793,47 @@
}
@Test
+ fun isAnimationRunningUpdate() {
+ val items by mutableStateOf((1..20).toList())
+ val clock = ManualAnimationClock(0L)
+ val state = LazyListState(
+ flingConfig = FlingConfig(ExponentialDecay()),
+ animationClock = clock
+ )
+ rule.setContent {
+ LazyColumnFor(
+ items = items,
+ modifier = Modifier.size(100.dp).testTag(LazyColumnForTag),
+ state = state
+ ) {
+ Spacer(Modifier.size(20.dp).testTag("$it"))
+ }
+ }
+
+ rule.runOnIdle {
+ assertThat(state.firstVisibleItemIndex).isEqualTo(0)
+ assertThat(state.isAnimationRunning).isEqualTo(false)
+ }
+
+ rule.onNodeWithTag(LazyColumnForTag)
+ .performGesture { swipeUp() }
+
+ rule.runOnIdle {
+ clock.clockTimeMillis += 100
+ assertThat(state.firstVisibleItemIndex).isNotEqualTo(0)
+ assertThat(state.isAnimationRunning).isEqualTo(true)
+ }
+
+ // TODO (jelle): this should be down, and not click to be 100% fair
+ rule.onNodeWithTag(LazyColumnForTag)
+ .performGesture { click() }
+
+ rule.runOnIdle {
+ assertThat(state.isAnimationRunning).isEqualTo(false)
+ }
+ }
+
+ @Test
fun stateUpdatedAfterScrollWithinTheSameItem() {
val items by mutableStateOf((1..20).toList())
lateinit var state: LazyListState
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyForIndexedTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyForIndexedTest.kt
index 8a91674..b84316d 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyForIndexedTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyForIndexedTest.kt
@@ -16,18 +16,17 @@
package androidx.compose.foundation.lazy
-import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.Text
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.preferredHeight
import androidx.compose.foundation.layout.preferredWidth
import androidx.compose.foundation.layout.width
import androidx.compose.ui.Modifier
-import androidx.compose.ui.platform.testTag
import androidx.compose.ui.unit.dp
import androidx.ui.test.assertLeftPositionInRootIsEqualTo
import androidx.ui.test.assertTopPositionInRootIsEqualTo
import androidx.ui.test.createComposeRule
-import androidx.ui.test.onNodeWithTag
+import androidx.ui.test.onNodeWithText
import org.junit.Rule
import org.junit.Test
@@ -42,14 +41,14 @@
rule.setContent {
LazyColumnForIndexed(items, Modifier.preferredHeight(200.dp)) { index, item ->
- Spacer(Modifier.fillParentMaxWidth().height(100.dp).testTag("${index}x$item"))
+ Text("${index}x$item", Modifier.fillParentMaxWidth().height(100.dp))
}
}
- rule.onNodeWithTag("0x0")
+ rule.onNodeWithText("0x0")
.assertTopPositionInRootIsEqualTo(0.dp)
- rule.onNodeWithTag("1x1")
+ rule.onNodeWithText("1x1")
.assertTopPositionInRootIsEqualTo(100.dp)
}
@@ -59,14 +58,14 @@
rule.setContent {
LazyRowForIndexed(items, Modifier.preferredWidth(200.dp)) { index, item ->
- Spacer(Modifier.fillParentMaxHeight().width(100.dp).testTag("${index}x$item"))
+ Text("${index}x$item", Modifier.fillParentMaxHeight().width(100.dp))
}
}
- rule.onNodeWithTag("0x0")
+ rule.onNodeWithText("0x0")
.assertLeftPositionInRootIsEqualTo(0.dp)
- rule.onNodeWithTag("1x1")
+ rule.onNodeWithText("1x1")
.assertLeftPositionInRootIsEqualTo(100.dp)
}
}
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Scroll.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Scroll.kt
index 3fe57e7..168de8f 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Scroll.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Scroll.kt
@@ -71,19 +71,26 @@
* @sample androidx.compose.foundation.samples.ControlledScrollableRowSample
*
* @param initial initial scroller position to start with
+ * @param interactionState [InteractionState] that will be updated when the element with this
+ * state is being scrolled by dragging, using [Interaction.Dragged]. If you want to know whether
+ * the fling (or smooth scroll) is in progress, use [ScrollState.isAnimationRunning].
*/
@Composable
-fun rememberScrollState(initial: Float = 0f): ScrollState {
+fun rememberScrollState(
+ initial: Float = 0f,
+ interactionState: InteractionState? = null
+): ScrollState {
val clock = AnimationClockAmbient.current.asDisposableClock()
val config = defaultFlingConfig()
return rememberSavedInstanceState(
- clock, config,
- saver = ScrollState.Saver(config, clock)
+ clock, config, interactionState,
+ saver = ScrollState.Saver(config, clock, interactionState)
) {
ScrollState(
flingConfig = config,
initial = initial,
- animationClock = clock
+ animationClock = clock,
+ interactionState = interactionState
)
}
}
@@ -102,12 +109,16 @@
* @param initial value of the scroll
* @param flingConfig fling configuration to use for flinging
* @param animationClock animation clock to run flinging and smooth scrolling on
+ * @param interactionState [InteractionState] that will be updated when the element with this
+ * state is being scrolled by dragging, using [Interaction.Dragged]. If you want to know whether
+ * the fling (or smooth scroll) is in progress, use [ScrollState.isAnimationRunning].
*/
@Stable
class ScrollState(
initial: Float,
internal val flingConfig: FlingConfig,
- animationClock: AnimationClockObservable
+ animationClock: AnimationClockObservable,
+ interactionState: InteractionState? = null
) {
/**
@@ -141,7 +152,8 @@
val consumed = newValue - value
value += consumed
consumed
- }
+ },
+ interactionState = interactionState
)
/**
@@ -212,10 +224,11 @@
*/
fun Saver(
flingConfig: FlingConfig,
- animationClock: AnimationClockObservable
+ animationClock: AnimationClockObservable,
+ interactionState: InteractionState?
): Saver<ScrollState, *> = Saver<ScrollState, Float>(
save = { it.value },
- restore = { ScrollState(it, flingConfig, animationClock) }
+ restore = { ScrollState(it, flingConfig, animationClock, interactionState) }
)
}
}
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Text.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Text.kt
index 55d4056..42445ed 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Text.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Text.kt
@@ -60,13 +60,6 @@
* [AmbientContentColor] will be used - this allows this [Text] or element containing this [Text] to
* adapt to different background colors and still maintain contrast and accessibility.
*
- * During the measurement, CoreText tends to shrink its size and reports the minimal needed size
- * to its parent. It will ignore the minWidth and minHeight except when [TextAlign] is
- * [TextAlign.Justify]. When [TextAlign.Justify] is specified and [text] is short enough that
- * doesn't exceed minWidth, CoreText will justify the [text] to fill the given minWidth.
- * When input [text] is too long and exceeds the maxWidth/maxHeight constrains, it will determine
- * its size based on the [overflow] option.
- *
* @param text The text to be displayed.
* @param modifier [Modifier] to apply to this layout node.
* @param color [Color] to apply to the text. If [Color.Unspecified], and [style] has no color set,
@@ -153,13 +146,6 @@
* [AmbientContentColor] will be used - this allows this [Text] or element containing this [Text] to
* adapt to different background colors and still maintain contrast and accessibility.
*
- * During the measurement, CoreText tends to shrink its size and reports the minimal needed size
- * to its parent. It will ignore the minWidth and minHeight except when [TextAlign] is
- * [TextAlign.Justify]. When [TextAlign.Justify] is specified and [text] is short enough that
- * doesn't exceed minWidth, CoreText will justify the [text] to fill the given minWidth.
- * When input [text] is too long and exceeds the maxWidth/maxHeight constrains, it will determine
- * its size based on the [overflow] option.
- *
* @param text The text to be displayed.
* @param modifier [Modifier] to apply to this layout node.
* @param color [Color] to apply to the text. If [Color.Unspecified], and [style] has no color set,
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/Scrollable.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/Scrollable.kt
index 863dda5..99778c4 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/Scrollable.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/Scrollable.kt
@@ -24,6 +24,8 @@
import androidx.compose.animation.core.AnimationSpec
import androidx.compose.animation.core.Spring
import androidx.compose.animation.core.SpringSpec
+import androidx.compose.foundation.Interaction
+import androidx.compose.foundation.InteractionState
import androidx.compose.foundation.animation.FlingConfig
import androidx.compose.foundation.animation.defaultFlingConfig
import androidx.compose.foundation.animation.fling
@@ -43,18 +45,22 @@
* Create and remember [ScrollableController] for [scrollable] with default [FlingConfig] and
* [AnimationClockObservable]
*
+ * @param interactionState [InteractionState] that will be updated when this scrollable is
+ * being scrolled by dragging, using [Interaction.Dragged]. If you want to know whether the fling
+ * (or smooth scroll) is in progress, use [ScrollableController.isAnimationRunning].
* @param consumeScrollDelta callback invoked when scrollable drag/fling/smooth scrolling occurs.
* The callback receives the delta in pixels. Callers should update their state in this lambda
* and return amount of delta consumed
*/
@Composable
fun rememberScrollableController(
+ interactionState: InteractionState? = null,
consumeScrollDelta: (Float) -> Float
): ScrollableController {
val clocks = AnimationClockAmbient.current.asDisposableClock()
val flingConfig = defaultFlingConfig()
- return remember(clocks, flingConfig) {
- ScrollableController(consumeScrollDelta, flingConfig, clocks)
+ return remember(clocks, flingConfig, interactionState) {
+ ScrollableController(consumeScrollDelta, flingConfig, clocks, interactionState)
}
}
@@ -67,11 +73,15 @@
* return the amount of delta consumed
* @param flingConfig fling configuration to use for flinging
* @param animationClock animation clock to run flinging and smooth scrolling on
+ * @param interactionState [InteractionState] that will be updated when this scrollable is
+ * being scrolled by dragging, using [Interaction.Dragged]. If you want to know whether the fling
+ * (or smooth scroll) is in progress, use [ScrollableController.isAnimationRunning].
*/
class ScrollableController(
- val consumeScrollDelta: (Float) -> Float,
- val flingConfig: FlingConfig,
- animationClock: AnimationClockObservable
+ internal val consumeScrollDelta: (Float) -> Float,
+ internal val flingConfig: FlingConfig,
+ animationClock: AnimationClockObservable,
+ internal val interactionState: InteractionState? = null
) {
/**
* Smooth scroll by [value] amount of pixels
@@ -177,6 +187,7 @@
): Modifier = composed {
onDispose {
controller.stopAnimation()
+ controller.interactionState?.removeInteraction(Interaction.Dragged)
}
val scrollCallback = object : ScrollCallback {
@@ -184,6 +195,7 @@
override fun onStart(downPosition: Offset) {
if (enabled) {
controller.stopAnimation()
+ controller.interactionState?.addInteraction(Interaction.Dragged)
onScrollStarted(downPosition)
}
}
@@ -198,10 +210,14 @@
}
override fun onCancel() {
- if (enabled) onScrollStopped(0f)
+ controller.interactionState?.removeInteraction(Interaction.Dragged)
+ if (enabled) {
+ onScrollStopped(0f)
+ }
}
override fun onStop(velocity: Float) {
+ controller.interactionState?.removeInteraction(Interaction.Dragged)
if (enabled) {
controller.fling(
velocity = if (reverseDirection) velocity * -1 else velocity,
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyListState.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyListState.kt
index 565ffbe..a08b0da 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyListState.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyListState.kt
@@ -18,6 +18,8 @@
import androidx.compose.animation.asDisposableClock
import androidx.compose.animation.core.AnimationClockObservable
+import androidx.compose.foundation.Interaction
+import androidx.compose.foundation.InteractionState
import androidx.compose.foundation.animation.FlingConfig
import androidx.compose.foundation.animation.defaultFlingConfig
import androidx.compose.foundation.assertNotNestingScrollableContainers
@@ -67,24 +69,29 @@
* @param initialFirstVisibleItemIndex the initial value for [LazyListState.firstVisibleItemIndex]
* @param initialFirstVisibleItemScrollOffset the initial value for
* [LazyListState.firstVisibleItemScrollOffset]
+ * @param interactionState [InteractionState] that will be updated when the element with this
+ * state is being scrolled by dragging, using [Interaction.Dragged]. If you want to know whether
+ * the fling (or smooth scroll) is in progress, use [LazyListState.isAnimationRunning].
*/
@Composable
fun rememberLazyListState(
initialFirstVisibleItemIndex: Int = 0,
- initialFirstVisibleItemScrollOffset: Int = 0
+ initialFirstVisibleItemScrollOffset: Int = 0,
+ interactionState: InteractionState? = null
): LazyListState {
val clock = AnimationClockAmbient.current.asDisposableClock()
val config = defaultFlingConfig()
// Avoid creating a new instance every invocation
- val saver = remember(config, clock) {
- LazyListState.Saver(config, clock)
+ val saver = remember(config, clock, interactionState) {
+ LazyListState.Saver(config, clock, interactionState)
}
- return rememberSavedInstanceState(config, clock, saver = saver) {
+ return rememberSavedInstanceState(config, clock, interactionState, saver = saver) {
LazyListState(
initialFirstVisibleItemIndex,
initialFirstVisibleItemScrollOffset,
+ interactionState,
config,
clock
)
@@ -96,11 +103,20 @@
* A state object that can be hoisted to control and observe scrolling
*
* In most cases, this will be created via [rememberLazyListState].
+ *
+ * @param firstVisibleItemIndex the initial value for [LazyListState.firstVisibleItemIndex]
+ * @param firstVisibleItemScrollOffset the initial value for
+ * @param interactionState [InteractionState] that will be updated when the element with this
+ * state is being scrolled by dragging, using [Interaction.Dragged]. If you want to know whether
+ * the fling (or smooth scroll) is in progress, use [LazyListState.isAnimationRunning].
+ * @param flingConfig fling configuration to use for flinging
+ * @param animationClock animation clock to run flinging and smooth scrolling on
*/
@Stable
class LazyListState constructor(
firstVisibleItemIndex: Int = 0,
firstVisibleItemScrollOffset: Int = 0,
+ interactionState: InteractionState? = null,
flingConfig: FlingConfig,
animationClock: AnimationClockObservable
) {
@@ -122,6 +138,12 @@
val firstVisibleItemScrollOffset: Int get() = scrollPosition.observableScrollOffset
/**
+ * whether the Lazy list with this state is currently animating/flinging
+ */
+ val isAnimationRunning
+ get() = scrollableController.isAnimationRunning
+
+ /**
* The amount of scroll to be consumed in the next layout pass. Scrolling forward is negative
* - that is, it is the amount that the items are offset in y
*/
@@ -135,7 +157,8 @@
ScrollableController(
flingConfig = flingConfig,
animationClock = animationClock,
- consumeScrollDelta = { onScroll(it) }
+ consumeScrollDelta = { onScroll(it) },
+ interactionState = interactionState
)
/**
@@ -389,7 +412,8 @@
*/
fun Saver(
flingConfig: FlingConfig,
- animationClock: AnimationClockObservable
+ animationClock: AnimationClockObservable,
+ interactionState: InteractionState?
): Saver<LazyListState, *> = listSaver(
save = { listOf(it.firstVisibleItemIndex, it.firstVisibleItemScrollOffset) },
restore = {
@@ -397,7 +421,8 @@
firstVisibleItemIndex = it[0],
firstVisibleItemScrollOffset = it[1],
flingConfig = flingConfig,
- animationClock = animationClock
+ animationClock = animationClock,
+ interactionState = interactionState
)
}
)
diff --git a/compose/integration-tests/demos/lint-baseline.xml b/compose/integration-tests/demos/lint-baseline.xml
index 88bfc59..da9ae23 100644
--- a/compose/integration-tests/demos/lint-baseline.xml
+++ b/compose/integration-tests/demos/lint-baseline.xml
@@ -47,7 +47,7 @@
errorLine2=" ~~~~~~~~~">
<location
file="src/main/java/androidx/compose/integration/demos/DemoActivity.kt"
- line="76"
+ line="78"
column="13"/>
</issue>
@@ -58,7 +58,7 @@
errorLine2=" ~~~~~~~~~~~~">
<location
file="src/main/java/androidx/compose/integration/demos/DemoActivity.kt"
- line="151"
+ line="153"
column="13"/>
</issue>
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/ListItem.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/ListItem.kt
index a854c50..249ae34 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/ListItem.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/ListItem.kt
@@ -345,14 +345,10 @@
content: @Composable () -> Unit
) {
Layout(content, modifier) { measurables, constraints ->
- val childConstraints = constraints.copy(
- minWidth = 0,
- minHeight = 0,
- maxHeight = Constraints.Infinity
- )
+ val childConstraints = constraints.copy(minHeight = 0, maxHeight = Constraints.Infinity)
val placeables = measurables.map { it.measure(childConstraints) }
- val containerWidth = placeables.fold(constraints.minWidth) { maxWidth, placeable ->
+ val containerWidth = placeables.fold(0) { maxWidth, placeable ->
max(maxWidth, placeable.width)
}
val y = Array(placeables.size) { 0 }
diff --git a/compose/ui/ui-text-android/lint-baseline.xml b/compose/ui/ui-text-android/lint-baseline.xml
index 31fbebd..705f8a4 100644
--- a/compose/ui/ui-text-android/lint-baseline.xml
+++ b/compose/ui/ui-text-android/lint-baseline.xml
@@ -8,7 +8,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/androidx/compose/ui/text/android/style/FontSpan.kt"
- line="52"
+ line="46"
column="25"/>
</issue>
diff --git a/compose/ui/ui-text/api/current.txt b/compose/ui/ui-text/api/current.txt
index 5749445..d0156749 100644
--- a/compose/ui/ui-text/api/current.txt
+++ b/compose/ui/ui-text/api/current.txt
@@ -1132,7 +1132,6 @@
public enum TextOverflow {
enum_constant public static final androidx.compose.ui.text.style.TextOverflow Clip;
enum_constant public static final androidx.compose.ui.text.style.TextOverflow Ellipsis;
- enum_constant public static final androidx.compose.ui.text.style.TextOverflow None;
}
}
diff --git a/compose/ui/ui-text/api/public_plus_experimental_current.txt b/compose/ui/ui-text/api/public_plus_experimental_current.txt
index 5749445..d0156749 100644
--- a/compose/ui/ui-text/api/public_plus_experimental_current.txt
+++ b/compose/ui/ui-text/api/public_plus_experimental_current.txt
@@ -1132,7 +1132,6 @@
public enum TextOverflow {
enum_constant public static final androidx.compose.ui.text.style.TextOverflow Clip;
enum_constant public static final androidx.compose.ui.text.style.TextOverflow Ellipsis;
- enum_constant public static final androidx.compose.ui.text.style.TextOverflow None;
}
}
diff --git a/compose/ui/ui-text/api/restricted_current.txt b/compose/ui/ui-text/api/restricted_current.txt
index 5749445..d0156749 100644
--- a/compose/ui/ui-text/api/restricted_current.txt
+++ b/compose/ui/ui-text/api/restricted_current.txt
@@ -1132,7 +1132,6 @@
public enum TextOverflow {
enum_constant public static final androidx.compose.ui.text.style.TextOverflow Clip;
enum_constant public static final androidx.compose.ui.text.style.TextOverflow Ellipsis;
- enum_constant public static final androidx.compose.ui.text.style.TextOverflow None;
}
}
diff --git a/compose/ui/ui-text/lint-baseline.xml b/compose/ui/ui-text/lint-baseline.xml
index 9f6fc74..53bc744 100644
--- a/compose/ui/ui-text/lint-baseline.xml
+++ b/compose/ui/ui-text/lint-baseline.xml
@@ -8,7 +8,7 @@
errorLine2=" ~~~~~~">
<location
file="src/androidMain/kotlin/androidx/compose/ui/text/platform/AndroidDefaultTypeface.kt"
- line="43"
+ line="44"
column="22"/>
</issue>
@@ -19,7 +19,7 @@
errorLine2=" ~~~~~~">
<location
file="src/androidMain/kotlin/androidx/compose/ui/text/platform/AndroidGenericFontFamilyTypeface.kt"
- line="73"
+ line="75"
column="22"/>
</issue>
@@ -52,7 +52,7 @@
errorLine2=" ~~~~~~~~~~~">
<location
file="src/androidMain/kotlin/androidx/compose/ui/text/platform/extensions/TextPaintExtensions.kt"
- line="62"
+ line="58"
column="13"/>
</issue>
diff --git a/compose/ui/ui-text/src/androidAndroidTest/kotlin/androidx/compose/ui/text/TextDelegateIntegrationTest.kt b/compose/ui/ui-text/src/androidAndroidTest/kotlin/androidx/compose/ui/text/TextDelegateIntegrationTest.kt
index 0c9a0d2..3d7a03d 100644
--- a/compose/ui/ui-text/src/androidAndroidTest/kotlin/androidx/compose/ui/text/TextDelegateIntegrationTest.kt
+++ b/compose/ui/ui-text/src/androidAndroidTest/kotlin/androidx/compose/ui/text/TextDelegateIntegrationTest.kt
@@ -24,7 +24,6 @@
import androidx.compose.ui.text.FontTestData.Companion.BASIC_MEASURE_FONT
import androidx.compose.ui.text.font.asFontFamily
import androidx.compose.ui.text.matchers.assertThat
-import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.Constraints
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.LayoutDirection
@@ -390,7 +389,7 @@
val constraintsFirstLayout = Constraints.fixed(width, heightFirstLayout)
val resultFirstLayout = textDelegate.layout(constraintsFirstLayout, LayoutDirection.Ltr)
- assertThat(resultFirstLayout.size.height).isLessThan(heightFirstLayout)
+ assertThat(resultFirstLayout.size.height).isEqualTo(heightFirstLayout)
val constraintsSecondLayout = Constraints.fixed(width, heightSecondLayout)
val resultSecondLayout = textDelegate.layout(
@@ -398,199 +397,8 @@
LayoutDirection.Ltr,
resultFirstLayout
)
- assertThat(resultSecondLayout.size.height).isEqualTo(resultFirstLayout.size.height)
+ assertThat(resultSecondLayout.size.height).isEqualTo(heightSecondLayout)
}
-
- @Test
- fun textReportSize_minWidth_largerThanNeeded() {
- for (overflow in TextOverflow.values()) {
- val textDelegate = TextDelegate(
- text = AnnotatedString(text = "Hello World!"),
- style = TextStyle.Default,
- overflow = overflow,
- density = density,
- resourceLoader = resourceLoader
- )
- textDelegate.layoutIntrinsics(LayoutDirection.Ltr)
- val intrinsicWidth = textDelegate.maxIntrinsicWidth
- val width = 2 * intrinsicWidth
- val textLayoutResult = textDelegate.layout(
- Constraints(minWidth = width),
- LayoutDirection.Ltr
- )
-
- assertThat(textLayoutResult.size.width).isEqualTo(intrinsicWidth)
- }
- }
-
- @Test
- fun textReportSize_minHeight_largerThanNeeded() {
- for (overflow in TextOverflow.values()) {
- val text = "Hello World!"
- val textDelegate = TextDelegate(
- text = AnnotatedString(text),
- style = TextStyle.Default,
- density = density,
- resourceLoader = resourceLoader
- )
-
- val intrinsicHeight = computeIntrinsicHeight(textDelegate)
- val height = intrinsicHeight * 2
- val textLayoutResult = textDelegate.layout(
- constraints = Constraints(minHeight = height),
- LayoutDirection.Ltr
- )
- assertThat(textLayoutResult.size.height).isEqualTo(intrinsicHeight)
- }
- }
-
- @Test
- fun textOverflow_clip_maxWidth_smallerThanNeeded() {
- val textDelegate = TextDelegate(
- text = AnnotatedString(text = "Hello World!"),
- style = TextStyle.Default,
- overflow = TextOverflow.Clip,
- density = density,
- resourceLoader = resourceLoader
- )
- textDelegate.layoutIntrinsics(LayoutDirection.Ltr)
- val intrinsicWidth = textDelegate.maxIntrinsicWidth
- val width = intrinsicWidth / 2
- val textLayoutResult = textDelegate.layout(
- constraints = Constraints(maxWidth = width),
- LayoutDirection.Ltr
- )
-
- assertThat(textLayoutResult.size.width).isEqualTo(width)
- }
-
- @Test
- fun textOverflow_ellipsis_maxWidth_smallerThanNeeded() {
- val textDelegate = TextDelegate(
- text = AnnotatedString(text = "Hello World!"),
- style = TextStyle.Default,
- overflow = TextOverflow.Ellipsis,
- softWrap = false,
- density = density,
- resourceLoader = resourceLoader
- )
- textDelegate.layoutIntrinsics(LayoutDirection.Ltr)
- val intrinsicWidth = textDelegate.maxIntrinsicWidth
- val width = intrinsicWidth / 2
- val textLayoutResult = textDelegate.layout(
- constraints = Constraints(maxWidth = width),
- LayoutDirection.Ltr
- )
-
- assertThat(textLayoutResult.size.width).isEqualTo(width)
- }
-
- @Test
- fun textOverflow_null_maxWidth_smallerThanNeeded() {
- val textDelegate = TextDelegate(
- text = AnnotatedString(text = "Hello World!"),
- style = TextStyle.Default,
- overflow = TextOverflow.None,
- softWrap = false,
- density = density,
- resourceLoader = resourceLoader
- )
- textDelegate.layoutIntrinsics(LayoutDirection.Ltr)
- val intrinsicWidth = textDelegate.maxIntrinsicWidth
- val width = intrinsicWidth / 2
- val textLayoutResult = textDelegate.layout(
- constraints = Constraints(maxWidth = width),
- LayoutDirection.Ltr
- )
-
- assertThat(textLayoutResult.size.width).isEqualTo(intrinsicWidth)
- }
-
- @Test
- fun textOverflow_clip_maxHeight_smallerThanNeeded() {
- val text = "Hello World!"
- val textDelegate = TextDelegate(
- text = AnnotatedString(text),
- style = TextStyle.Default,
- overflow = TextOverflow.Clip,
- density = density,
- resourceLoader = resourceLoader
- )
-
- val intrinsicHeight = computeIntrinsicHeight(textDelegate)
- val height = intrinsicHeight / 2
- val textLayoutResult = textDelegate.layout(
- constraints = Constraints(maxHeight = height),
- LayoutDirection.Ltr
- )
- assertThat(textLayoutResult.size.height).isEqualTo(height)
- }
-
- @Test
- fun textOverflow_ellipsis_maxHeight_smallerThanNeeded() {
- val text = "Hello World!"
- val maxLines = 2
- val textDelegate = TextDelegate(
- text = AnnotatedString(text),
- style = TextStyle.Default,
- overflow = TextOverflow.Ellipsis,
- maxLines = maxLines,
- density = density,
- resourceLoader = resourceLoader
- )
-
- textDelegate.layoutIntrinsics(LayoutDirection.Ltr)
- // Set the width so that text exceeds maxLines.
- val width = textDelegate.maxIntrinsicWidth / (maxLines + 1)
-
- // Height is only enough for 1 line.
- val height = computeIntrinsicHeight(textDelegate)
- // In this case, ellipsis is applied and there will be only 2 lines.
- // But maxHeight constraints it to be 1 line only.
- // Text should still be clipped as the fallback behavior of "ellipsis by height".
- val textLayoutResult = textDelegate.layout(
- constraints = Constraints(maxWidth = width, maxHeight = height),
- LayoutDirection.Ltr
- )
-
- // Gut check that the last line is ellipsized.
- assertThat(textLayoutResult.isLineEllipsized(maxLines - 1)).isTrue()
- assertThat(textLayoutResult.size.height).isEqualTo(height)
- }
-
- @Test
- fun textOverflow_null_maxHeight_smallerThanNeeded() {
- val text = "Hello World!"
- val textDelegate = TextDelegate(
- text = AnnotatedString(text),
- style = TextStyle.Default,
- overflow = TextOverflow.None,
- density = density,
- resourceLoader = resourceLoader
- )
-
- val intrinsicHeight = computeIntrinsicHeight(textDelegate)
- val height = intrinsicHeight / 2
- val textLayoutResult = textDelegate.layout(
- constraints = Constraints(maxHeight = height),
- LayoutDirection.Ltr
- )
- assertThat(textLayoutResult.size.height).isEqualTo(intrinsicHeight)
- }
-}
-
-@OptIn(InternalTextApi::class)
-private fun computeIntrinsicHeight(
- textDelegate: TextDelegate,
- width: Float = Float.MAX_VALUE
-): Int {
- return Paragraph(
- text = textDelegate.text.text,
- style = resolveDefaults(textDelegate.style, LayoutDirection.Ltr),
- width = width,
- density = textDelegate.density,
- resourceLoader = textDelegate.resourceLoader
- ).height.toInt()
}
private fun TextLayoutResult.toBitmap() = Bitmap.createBitmap(
diff --git a/compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/TextDelegate.kt b/compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/TextDelegate.kt
index a782889..497b31e 100644
--- a/compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/TextDelegate.kt
+++ b/compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/TextDelegate.kt
@@ -27,6 +27,7 @@
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.IntSize
import androidx.compose.ui.unit.LayoutDirection
+import androidx.compose.ui.unit.constrain
import androidx.compose.ui.util.annotation.VisibleForTesting
import kotlin.math.ceil
@@ -131,7 +132,7 @@
* Computes the visual position of the glyphs for painting the text.
*
* The text will layout with a width that's as close to its max intrinsic width as possible
- * while still being greater than or equal to [minWidth] and less than or equal to [maxWidth].
+ * while still being greater than or equal to `minWidth` and less than or equal to `maxWidth`.
*/
private fun layoutText(minWidth: Float, maxWidth: Float, layoutDirection: LayoutDirection):
MultiParagraph {
@@ -162,25 +163,9 @@
fun layout(
constraints: Constraints,
layoutDirection: LayoutDirection,
- prevResult: TextLayoutResult? = null,
- respectMinConstraints: Boolean = false
+ prevResult: TextLayoutResult? = null
): TextLayoutResult {
- /**
- * minWidth is only respected if it's required, where respectMinConstraints is true, or
- * [TextAlign.Justify] is specified.
- * In the other cases, minWidth will be ignored so that CoreText can report its actual
- * size to the parent node. This tells the parent that the input text is too short, and
- * CoreText is not able to meet the minWidth requirement.
- * Notice that respectMinConstraints == true is reserved for TextField, where minWidth acts
- * like a placeholder. This is especially useful when TextField is empty.
- * TODO(haoyuchang): Consider break down this method into pieces and separate the
- * measurement logic for TextField from TextDelegate.
- */
- val minWidth = if (respectMinConstraints || style.textAlign == TextAlign.Justify) {
- constraints.minWidth.toFloat()
- } else {
- 0f
- }
+ val minWidth = constraints.minWidth.toFloat()
val widthMatters = softWrap || overflow == TextOverflow.Ellipsis
val maxWidth = if (widthMatters && constraints.hasBoundedWidth) {
constraints.maxWidth.toFloat()
@@ -199,7 +184,12 @@
style = style,
constraints = constraints
),
- size = computeLayoutSize(constraints, multiParagraph, respectMinConstraints)
+ size = constraints.constrain(
+ IntSize(
+ ceil(multiParagraph.width).toInt(),
+ ceil(multiParagraph.height).toInt()
+ )
+ )
)
}
}
@@ -210,7 +200,13 @@
layoutDirection
)
- val size = computeLayoutSize(constraints, multiParagraph, respectMinConstraints)
+ val size = constraints.constrain(
+ IntSize(
+ ceil(multiParagraph.width).toInt(),
+ ceil(multiParagraph.height).toInt()
+ )
+ )
+
return TextLayoutResult(
TextLayoutInput(
text,
@@ -229,47 +225,6 @@
)
}
- /**
- * Determine the size of the Layout based on the input [constraints], [multiParagraph] size and
- * [TextOverflow] settings.
- */
- private fun computeLayoutSize(
- constraints: Constraints,
- multiParagraph: MultiParagraph,
- respectMinConstraints: Boolean
- ): IntSize {
- val width = ceil(multiParagraph.width).toInt().let {
- if (respectMinConstraints) {
- it.coerceAtLeast(constraints.minWidth)
- } else {
- it
- }
- }
- val height = ceil(multiParagraph.height).toInt().let {
- if (respectMinConstraints) {
- it.coerceAtLeast(constraints.minHeight)
- } else {
- it
- }
- }
- return when (overflow) {
- // CoreText won't handle overflow. Layout will determine how to handle it.
- TextOverflow.None ->
- IntSize(width, height)
- // When overflow is clip: CoreText will clip the CoreText to be the max available size.
- // When overflow is ellipsis: If line count doesn't exceed maxLines but height
- // exceeds the maxHeight, it will also clip.
- // TODO(haoyuchang): support ellipsis with height, or its fallback behavior that
- // only cuts the exceeding lines but doesn't show '...'.
- TextOverflow.Clip, TextOverflow.Ellipsis -> {
- IntSize(
- width.coerceAtMost(constraints.maxWidth),
- height.coerceAtMost(constraints.maxHeight)
- )
- }
- }
- }
-
companion object {
/**
* Paints the text onto the given canvas.
diff --git a/compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/TextLayoutHelper.kt b/compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/TextLayoutHelper.kt
index 8d08a2e..4d31915 100644
--- a/compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/TextLayoutHelper.kt
+++ b/compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/TextLayoutHelper.kt
@@ -64,12 +64,10 @@
}
// Check the given constraints can produces the same result.
- if (constraints.minWidth != layoutInput.constraints.minWidth) {
- return false
- }
+ if (constraints.minWidth != layoutInput.constraints.minWidth) return false
if (!(softWrap || overflow == TextOverflow.Ellipsis)) {
- // If width does not matter, we can result the same layout.
+ // If width does not mattter, we can result the same layout.
return true
}
return constraints.maxWidth == layoutInput.constraints.maxWidth
diff --git a/compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/style/TextOverflow.kt b/compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/style/TextOverflow.kt
index 9f116a1..8061c84 100644
--- a/compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/style/TextOverflow.kt
+++ b/compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/style/TextOverflow.kt
@@ -18,9 +18,6 @@
/** How overflowing text should be handled. */
enum class TextOverflow {
- /** Won't handle overflow, and report the needed size to the parent. **/
- None,
-
/** Clip the overflowing text to fix its container. */
Clip,
diff --git a/compose/ui/ui/lint-baseline.xml b/compose/ui/ui/lint-baseline.xml
index 24412c1..af65ba6 100644
--- a/compose/ui/ui/lint-baseline.xml
+++ b/compose/ui/ui/lint-baseline.xml
@@ -8,7 +8,7 @@
errorLine2="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/androidMain/kotlin/androidx/compose/ui/platform/AndroidComposeView.kt"
- line="122"
+ line="98"
column="1"/>
</issue>
@@ -103,7 +103,7 @@
<issue
id="UnsafeNewApiCall"
message="This call is to a method from API 23, the call containing class androidx.compose.ui.autofill.AndroidAutofillKt is not annotated with @RequiresApi(x) where x is at least 23. Either annotate the containing class with at least @RequiresApi(23) or move the call to a static method in a wrapper class annotated with at least @RequiresApi(23)."
- errorLine1=" setDimens(left, top, 0, 0, width(), height()) }"
+ errorLine1=" setDimens(left, top, 0, 0, width(), height())"
errorLine2=" ~~~~~~~~~">
<location
file="src/androidMain/kotlin/androidx/compose/ui/autofill/AndroidAutofill.kt"
@@ -118,7 +118,7 @@
errorLine2=" ~~~~~~">
<location
file="src/androidMain/kotlin/androidx/compose/ui/autofill/AndroidAutofill.kt"
- line="104"
+ line="105"
column="19"/>
</issue>
@@ -129,7 +129,7 @@
errorLine2=" ~~~~~~~~~">
<location
file="src/androidMain/kotlin/androidx/compose/ui/autofill/AndroidAutofill.kt"
- line="104"
+ line="105"
column="72"/>
</issue>
@@ -140,7 +140,7 @@
errorLine2=" ~~~~~~">
<location
file="src/androidMain/kotlin/androidx/compose/ui/autofill/AndroidAutofill.kt"
- line="105"
+ line="106"
column="19"/>
</issue>
@@ -151,7 +151,7 @@
errorLine2=" ~~~~~~">
<location
file="src/androidMain/kotlin/androidx/compose/ui/autofill/AndroidAutofill.kt"
- line="106"
+ line="107"
column="19"/>
</issue>
@@ -162,7 +162,7 @@
errorLine2=" ~~~~~~~~">
<location
file="src/androidMain/kotlin/androidx/compose/ui/autofill/AndroidAutofill.kt"
- line="107"
+ line="108"
column="19"/>
</issue>
@@ -195,7 +195,7 @@
errorLine2=" ~~~~~~~~~">
<location
file="src/androidMain/kotlin/androidx/compose/ui/platform/AndroidComposeView.kt"
- line="238"
+ line="226"
column="13"/>
</issue>
@@ -206,7 +206,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/androidMain/kotlin/androidx/compose/ui/platform/AndroidComposeView.kt"
- line="240"
+ line="228"
column="13"/>
</issue>
@@ -217,7 +217,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~">
<location
file="src/androidMain/kotlin/androidx/compose/ui/platform/AndroidComposeViewAccessibilityDelegateCompat.kt"
- line="278"
+ line="351"
column="27"/>
</issue>
@@ -228,7 +228,7 @@
errorLine2=" ~~~~~~~~~~~~~~~">
<location
file="src/androidMain/kotlin/androidx/compose/ui/platform/AndroidTextToolbar.kt"
- line="52"
+ line="53"
column="31"/>
</issue>
@@ -261,19 +261,19 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/androidMain/kotlin/androidx/compose/ui/platform/RenderNodeLayer.kt"
- line="160"
+ line="164"
column="31"/>
</issue>
<issue
id="UnsafeNewApiCall"
message="This call is to a method from API 29, the call containing class androidx.compose.ui.platform.WrapperKt is not annotated with @RequiresApi(x) where x is at least 29. Either annotate the containing class with at least @RequiresApi(29) or move the call to a static method in a wrapper class annotated with at least @RequiresApi(29)."
- errorLine1=" owner.view.attributeSourceResourceMap.isNotEmpty()"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ errorLine1=" owner.view.attributeSourceResourceMap.isNotEmpty()"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/androidMain/kotlin/androidx/compose/ui/platform/Wrapper.kt"
- line="355"
- column="24"/>
+ line="319"
+ column="20"/>
</issue>
</issues>
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AndroidAccessibilityTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AndroidAccessibilityTest.kt
index 5fa8eb6..5e41547 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AndroidAccessibilityTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AndroidAccessibilityTest.kt
@@ -56,7 +56,7 @@
import androidx.core.os.BuildCompat
import androidx.core.view.ViewCompat
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat
-import androidx.test.filters.MediumTest
+import androidx.test.filters.LargeTest
import androidx.test.filters.SdkSuppress
import androidx.test.platform.app.InstrumentationRegistry
import androidx.ui.test.SemanticsMatcher
@@ -91,7 +91,7 @@
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
-@MediumTest
+@LargeTest
@RunWith(JUnit4::class)
@OptIn(
ExperimentalFoundationApi::class,
@@ -275,7 +275,7 @@
textFieldSelectionOneLatch = CountDownLatch(1)
provider.performAction(textFieldNode.id, ACTION_SET_SELECTION, argument)
}
- if (!textFieldSelectionOneLatch.await(1, TimeUnit.SECONDS)) {
+ if (!textFieldSelectionOneLatch.await(5, TimeUnit.SECONDS)) {
throw AssertionError("Failed to wait for text selection change.")
}
rule.onNodeWithTag(TextFieldTag)
@@ -302,7 +302,7 @@
argument
)
}
- if (!textFieldSelectionZeroLatch.await(1, TimeUnit.SECONDS)) {
+ if (!textFieldSelectionZeroLatch.await(5, TimeUnit.SECONDS)) {
throw AssertionError("Failed to wait for text selection change.")
}
rule.onNodeWithTag(TextFieldTag)
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/PointerInteropFilterTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/PointerInteropFilterTest.kt
index bf78f93..eb19be8 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/PointerInteropFilterTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/PointerInteropFilterTest.kt
@@ -667,7 +667,7 @@
val aMove2 = aMove1.moveTo(13.milliseconds, 3f, 4f)
val bUpConsumed = bDown.up(13.milliseconds).apply { consumeDownChange() }
- val expected: MotionEvent =
+ val expected =
MotionEvent(
13,
ACTION_CANCEL,
@@ -1496,7 +1496,7 @@
}
@Test
- fun onPointerEvent_downThenMoveViewRetsFalseThenMoveThenUp_noDispatchAfterRetFalse() {
+ fun onPointerEvent_downThenMoveViewRetsFalseThenMove_moveDispatched() {
val down = down(1, 2.milliseconds, 3f, 4f)
val motionEvent1 =
MotionEvent(
@@ -1530,17 +1530,6 @@
arrayOf(PointerCoords(11f, 12f))
)
- val up = move2.up(15.milliseconds)
- val motionEvent4 =
- MotionEvent(
- 15,
- ACTION_UP,
- 1,
- 0,
- arrayOf(PointerProperties(0)),
- arrayOf(PointerCoords(11f, 12f))
- )
-
pointerInteropFilter.pointerInputFilter::onPointerEvent.invokeOverAllPasses(
pointerEventOf(down, motionEvent = motionEvent1)
)
@@ -1552,15 +1541,235 @@
pointerInteropFilter.pointerInputFilter::onPointerEvent.invokeOverAllPasses(
pointerEventOf(move2, motionEvent = motionEvent3)
)
- pointerInteropFilter.pointerInputFilter::onPointerEvent.invokeOverAllPasses(
- pointerEventOf(up, motionEvent = motionEvent4)
- )
- assertThat(dispatchedMotionEvents).hasSize(0)
+ assertThat(dispatchedMotionEvents).hasSize(1)
+ assertThat(dispatchedMotionEvents[0]).isSameInstanceAs(motionEvent3)
}
@Test
- fun onPointerEvent_down1ThenDown2ViewRetsFalseThenMoveThenUp1ThenUp2_noDispatchAfterRetFalse() {
+ fun onPointerEvent_downThenMoveViewRetsFalseThenUp_upDispatched() {
+ val down = down(1, 2.milliseconds, 3f, 4f)
+ val motionEvent1 =
+ MotionEvent(
+ 2,
+ ACTION_DOWN,
+ 1,
+ 0,
+ arrayOf(PointerProperties(0)),
+ arrayOf(PointerCoords(3f, 4f))
+ )
+
+ val move1 = down.moveTo(5.milliseconds, 6f, 7f)
+ val motionEvent2 =
+ MotionEvent(
+ 5,
+ ACTION_MOVE,
+ 1,
+ 0,
+ arrayOf(PointerProperties(0)),
+ arrayOf(PointerCoords(6f, 47f))
+ )
+
+ val up = move1.up(10.milliseconds)
+ val motionEvent3 =
+ MotionEvent(
+ 10,
+ ACTION_UP,
+ 1,
+ 0,
+ arrayOf(PointerProperties(0)),
+ arrayOf(PointerCoords(6f, 47f))
+ )
+
+ pointerInteropFilter.pointerInputFilter::onPointerEvent.invokeOverAllPasses(
+ pointerEventOf(down, motionEvent = motionEvent1)
+ )
+ retVal = false
+ pointerInteropFilter.pointerInputFilter::onPointerEvent.invokeOverAllPasses(
+ pointerEventOf(move1, motionEvent = motionEvent2)
+ )
+ dispatchedMotionEvents.clear()
+ pointerInteropFilter.pointerInputFilter::onPointerEvent.invokeOverAllPasses(
+ pointerEventOf(up, motionEvent = motionEvent3)
+ )
+
+ assertThat(dispatchedMotionEvents).hasSize(1)
+ assertThat(dispatchedMotionEvents[0]).isSameInstanceAs(motionEvent3)
+ }
+
+ @Test
+ fun onPointerEvent_down1ThenDown2ViewRetsFalseThenMove_moveIsDispatched() {
+ // Arrange
+
+ val aDown = down(1, 2.milliseconds, 3f, 4f)
+ val motionEvent1 =
+ MotionEvent(
+ 2,
+ ACTION_DOWN,
+ 1,
+ 0,
+ arrayOf(PointerProperties(0)),
+ arrayOf(PointerCoords(3f, 4f))
+ )
+
+ val aMove1 = aDown.moveTo(11.milliseconds, 3f, 4f)
+ val bDown = down(21, 11.milliseconds, 23f, 24f)
+ val motionEvent2 =
+ MotionEvent(
+ 11,
+ ACTION_POINTER_DOWN,
+ 2,
+ 2,
+ arrayOf(PointerProperties(0), PointerProperties(1)),
+ arrayOf(PointerCoords(3f, 4f), PointerCoords(23f, 24f))
+ )
+
+ val aMove2 = aMove1.moveTo(21.milliseconds, 31f, 32f)
+ val bMove = bDown.moveTo(21.milliseconds, 33f, 34f)
+ val motionEvent3 =
+ MotionEvent(
+ 21,
+ ACTION_MOVE,
+ 2,
+ 0,
+ arrayOf(PointerProperties(0), PointerProperties(1)),
+ arrayOf(PointerCoords(31f, 32f), PointerCoords(33f, 34f))
+ )
+
+ // Act
+ pointerInteropFilter.pointerInputFilter::onPointerEvent.invokeOverAllPasses(
+ pointerEventOf(aDown, motionEvent = motionEvent1)
+ )
+ retVal = false
+ pointerInteropFilter.pointerInputFilter::onPointerEvent.invokeOverAllPasses(
+ pointerEventOf(aMove1, bDown, motionEvent = motionEvent2)
+ )
+ dispatchedMotionEvents.clear()
+ pointerInteropFilter.pointerInputFilter::onPointerEvent.invokeOverAllPasses(
+ pointerEventOf(aMove2, bMove, motionEvent = motionEvent3)
+ )
+
+ // Assert
+ assertThat(dispatchedMotionEvents).hasSize(1)
+ assertThat(dispatchedMotionEvents[0]).isSameInstanceAs(motionEvent3)
+ }
+
+ @Test
+ fun onPointerEvent_down1ThenDown2ViewRetsFalseThenUp1_up1IsDispatched() {
+ // Arrange
+
+ val aDown = down(1, 2.milliseconds, 3f, 4f)
+ val motionEvent1 =
+ MotionEvent(
+ 2,
+ ACTION_DOWN,
+ 1,
+ 0,
+ arrayOf(PointerProperties(0)),
+ arrayOf(PointerCoords(3f, 4f))
+ )
+
+ val aMove1 = aDown.moveTo(11.milliseconds, 3f, 4f)
+ val bDown = down(21, 11.milliseconds, 23f, 24f)
+ val motionEvent2 =
+ MotionEvent(
+ 11,
+ ACTION_POINTER_DOWN,
+ 2,
+ 2,
+ arrayOf(PointerProperties(0), PointerProperties(1)),
+ arrayOf(PointerCoords(3f, 4f), PointerCoords(23f, 24f))
+ )
+
+ val aMove2 = aMove1.moveTo(21.milliseconds, 3f, 4f)
+ val bUp = bDown.up(21.milliseconds)
+ val motionEvent3 =
+ MotionEvent(
+ 21,
+ ACTION_POINTER_UP,
+ 2,
+ 1,
+ arrayOf(PointerProperties(0), PointerProperties(1)),
+ arrayOf(PointerCoords(3f, 4f), PointerCoords(23f, 24f))
+ )
+
+ // Act
+ pointerInteropFilter.pointerInputFilter::onPointerEvent.invokeOverAllPasses(
+ pointerEventOf(aDown, motionEvent = motionEvent1)
+ )
+ retVal = false
+ pointerInteropFilter.pointerInputFilter::onPointerEvent.invokeOverAllPasses(
+ pointerEventOf(aMove1, bDown, motionEvent = motionEvent2)
+ )
+ dispatchedMotionEvents.clear()
+ pointerInteropFilter.pointerInputFilter::onPointerEvent.invokeOverAllPasses(
+ pointerEventOf(aMove2, bUp, motionEvent = motionEvent3)
+ )
+
+ // Assert
+ assertThat(dispatchedMotionEvents).hasSize(1)
+ assertThat(dispatchedMotionEvents[0]).isSameInstanceAs(motionEvent3)
+ }
+
+ @Test
+ fun onPointerEvent_down1ThenDown2ViewRetsFalseThenUp2_up2Dispatched() {
+ // Arrange
+
+ val aDown = down(1, 2.milliseconds, 3f, 4f)
+ val motionEvent1 =
+ MotionEvent(
+ 2,
+ ACTION_DOWN,
+ 1,
+ 0,
+ arrayOf(PointerProperties(0)),
+ arrayOf(PointerCoords(3f, 4f))
+ )
+
+ val aMove1 = aDown.moveTo(11.milliseconds, 3f, 4f)
+ val bDown = down(21, 11.milliseconds, 23f, 24f)
+ val motionEvent2 =
+ MotionEvent(
+ 11,
+ ACTION_POINTER_DOWN,
+ 2,
+ 2,
+ arrayOf(PointerProperties(0), PointerProperties(1)),
+ arrayOf(PointerCoords(3f, 4f), PointerCoords(23f, 24f))
+ )
+
+ val aUp = aMove1.up(31.milliseconds)
+ val bMove = bDown.moveTo(31.milliseconds)
+ val motionEvent3 =
+ MotionEvent(
+ 31,
+ ACTION_POINTER_UP,
+ 2,
+ 0,
+ arrayOf(PointerProperties(0), PointerProperties(1)),
+ arrayOf(PointerCoords(3f, 4f), PointerCoords(23f, 24f))
+ )
+
+ // Act
+ pointerInteropFilter.pointerInputFilter::onPointerEvent.invokeOverAllPasses(
+ pointerEventOf(aDown, motionEvent = motionEvent1)
+ )
+ retVal = false
+ pointerInteropFilter.pointerInputFilter::onPointerEvent.invokeOverAllPasses(
+ pointerEventOf(aMove1, bDown, motionEvent = motionEvent2)
+ )
+ dispatchedMotionEvents.clear()
+ pointerInteropFilter.pointerInputFilter::onPointerEvent.invokeOverAllPasses(
+ pointerEventOf(aUp, bMove, motionEvent = motionEvent3)
+ )
+
+ // Assert
+ assertThat(dispatchedMotionEvents).hasSize(1)
+ assertThat(dispatchedMotionEvents[0]).isSameInstanceAs(motionEvent3)
+ }
+
+ @Test
+ fun onPointerEvent_down1ThenDown2ViewRetsFalseThenMoveThenUp1ThenUp2_allFollowingDispatched() {
// Arrange
val aDown = down(1, 2.milliseconds, 3f, 4f)
@@ -1641,7 +1850,10 @@
)
// Assert
- assertThat(dispatchedMotionEvents).hasSize(0)
+ assertThat(dispatchedMotionEvents).hasSize(3)
+ assertThat(dispatchedMotionEvents[0]).isSameInstanceAs(motionEvent3)
+ assertThat(dispatchedMotionEvents[1]).isSameInstanceAs(motionEvent4)
+ assertThat(dispatchedMotionEvents[2]).isSameInstanceAs(motionEvent5)
}
@Test
@@ -1836,7 +2048,7 @@
}
@Test
- fun onPointerEvent_1PointerUpViewRetsFalse_nothingConsumed() {
+ fun onPointerEvent_1PointerUpViewRetsFalse_everythingConsumed() {
val down = down(1, 2.milliseconds, 3f, 4f)
val motionEvent1 =
MotionEvent(
@@ -1848,7 +2060,6 @@
arrayOf(PointerCoords(3f, 4f))
)
val upActual = down.up(5.milliseconds)
- val upExpected = upActual.deepCopy()
val motionEvent2 =
MotionEvent(
5,
@@ -1862,6 +2073,7 @@
pointerInteropFilter.pointerInputFilter::onPointerEvent.invokeOverAllPasses(
pointerEventOf(down, motionEvent = motionEvent1)
)
+ val upExpected = upActual.deepCopy().apply { consumeAllChanges() }
retVal = false
pointerInteropFilter.pointerInputFilter::onPointerEvent.invokeOverAllPasses(
@@ -1908,7 +2120,7 @@
}
@Test
- fun onPointerEvent_2PointersDownViewRetsFalse_nothingConsumed() {
+ fun onPointerEvent_2PointersDownViewRetsFalse_everythingConsumed() {
// Arrange
@@ -1937,7 +2149,10 @@
retVal = true
- val expected = listOf(aMove.deepCopy(), bDown.deepCopy())
+ val expected = listOf(
+ aMove.deepCopy().apply { consumeAllChanges() },
+ bDown.deepCopy().apply { consumeAllChanges() }
+ )
pointerInteropFilter.pointerInputFilter::onPointerEvent.invokeOverAllPasses(
pointerEventOf(aDown, motionEvent = motionEvent1)
@@ -2007,7 +2222,7 @@
}
@Test
- fun onPointerEvent_2Pointers1UpViewRetsFalse_nothingConsumed() {
+ fun onPointerEvent_2Pointers1UpViewRetsFalse_everythingConsumed() {
// Arrange
@@ -2048,7 +2263,10 @@
retVal = true
- val expected = listOf(aMove2.deepCopy(), bUp.deepCopy())
+ val expected = listOf(
+ aMove2.deepCopy().apply { consumeAllChanges() },
+ bUp.deepCopy().apply { consumeAllChanges() }
+ )
pointerInteropFilter.pointerInputFilter::onPointerEvent.invokeOverAllPasses(
pointerEventOf(aDown, motionEvent = motionEvent1)
@@ -2135,7 +2353,7 @@
}
@Test
- fun onPointerEvent_1PointerMoveViewRetsFalse_nothingConsumed() {
+ fun onPointerEvent_1PointerMoveViewRetsFalse_everythingConsumed() {
val down = down(1, 2.milliseconds, 3f, 4f)
val motionEvent1 =
MotionEvent(
@@ -2147,7 +2365,7 @@
arrayOf(PointerCoords(3f, 4f))
)
val move = down.moveTo(7.milliseconds, 8f, 9f)
- val expected = move.deepCopy()
+ val expected = move.deepCopy().apply { consumeAllChanges() }
val motionEvent2 =
MotionEvent(
7,
@@ -2206,7 +2424,7 @@
}
@Test
- fun onPointerEvent_2PointersMoveViewRetsFalse_nothingConsumed() {
+ fun onPointerEvent_2PointersMoveViewRetsFalse_everythingConsumed() {
// Arrange
@@ -2259,7 +2477,11 @@
retVal = true
- val expected = listOf(aMove2.deepCopy(), bMove1.deepCopy())
+ val expected =
+ listOf(
+ aMove2.deepCopy().apply { consumeAllChanges() },
+ bMove1.deepCopy().apply { consumeAllChanges() }
+ )
pointerInteropFilter.pointerInputFilter::onPointerEvent.invokeOverAllPasses(
pointerEventOf(aDown, motionEvent = motionEvent1)
@@ -3034,7 +3256,7 @@
}
@Test
- fun onPointerEvent_down1ViewRetsFalseThenViewRestsTrueDown2ThenUp1ThenDown3_down3NotConsumed() {
+ fun onPointerEvent_down1ViewRetsFalseThenViewRetsTrueDown2ThenUp1ThenDown3_down3NotConsumed() {
val aDown = down(1, 2.milliseconds, 3f, 4f)
val motionEvent1 =
MotionEvent(
@@ -3103,220 +3325,6 @@
assertThat(listOf(bMove2, cDown)).isEqualTo(expected)
}
- @Test
- fun onPointerEvent_downThenMoveViewRetsFalseThenViewRetsTrueMove_moveNotConsumed() {
- val down = down(1, 2.milliseconds, 3f, 4f)
- val motionEvent1 =
- MotionEvent(
- 2,
- ACTION_DOWN,
- 1,
- 0,
- arrayOf(PointerProperties(0)),
- arrayOf(PointerCoords(3f, 4f))
- )
- val move1 = down.moveTo(5.milliseconds, 6f, 7f)
- val motionEvent2 =
- MotionEvent(
- 5,
- ACTION_MOVE,
- 1,
- 0,
- arrayOf(PointerProperties(0)),
- arrayOf(PointerCoords(6f, 47f))
- )
- val move2 = move1.moveTo(10.milliseconds, 11f, 12f)
- val motionEvent3 =
- MotionEvent(
- 10,
- ACTION_MOVE,
- 1,
- 0,
- arrayOf(PointerProperties(0)),
- arrayOf(PointerCoords(11f, 12f))
- )
- val expected = move2.deepCopy()
-
- pointerInteropFilter.pointerInputFilter::onPointerEvent.invokeOverAllPasses(
- pointerEventOf(down, motionEvent = motionEvent1)
- )
- retVal = false
- pointerInteropFilter.pointerInputFilter::onPointerEvent.invokeOverAllPasses(
- pointerEventOf(move1, motionEvent = motionEvent2)
- )
- retVal = true
- pointerInteropFilter.pointerInputFilter::onPointerEvent.invokeOverAllPasses(
- pointerEventOf(move2, motionEvent = motionEvent3)
- )
-
- assertThat(move2).isEqualTo(expected)
- }
-
- @Test
- fun onPointerEvent_downThenMoveViewRetsFalseThenViewRetsTrueThenUp_UpNotConsumed() {
- val down = down(1, 2.milliseconds, 3f, 4f)
- val motionEvent1 =
- MotionEvent(
- 2,
- ACTION_DOWN,
- 1,
- 0,
- arrayOf(PointerProperties(0)),
- arrayOf(PointerCoords(3f, 4f))
- )
- val move1 = down.moveTo(5.milliseconds, 6f, 7f)
- val motionEvent2 =
- MotionEvent(
- 5,
- ACTION_MOVE,
- 1,
- 0,
- arrayOf(PointerProperties(0)),
- arrayOf(PointerCoords(6f, 47f))
- )
- val up = move1.up(10.milliseconds)
- val motionEvent3 =
- MotionEvent(
- 10,
- ACTION_UP,
- 1,
- 0,
- arrayOf(PointerProperties(0)),
- arrayOf(PointerCoords(6f, 47f))
- )
- val expected = up.deepCopy()
-
- pointerInteropFilter.pointerInputFilter::onPointerEvent.invokeOverAllPasses(
- pointerEventOf(down, motionEvent = motionEvent1)
- )
- retVal = false
- pointerInteropFilter.pointerInputFilter::onPointerEvent.invokeOverAllPasses(
- pointerEventOf(move1, motionEvent = motionEvent2)
- )
- retVal = true
- pointerInteropFilter.pointerInputFilter::onPointerEvent.invokeOverAllPasses(
- pointerEventOf(up, motionEvent = motionEvent3)
- )
-
- assertThat(up).isEqualTo(expected)
- }
-
- @Test
- fun onPointerEvent_down1ThenDown2ViewRetsFalseThenViewRetsTrueMove_moveNotConsumed() {
- // Arrange
-
- val aDown = down(1, 2.milliseconds, 3f, 4f)
- val motionEvent1 =
- MotionEvent(
- 2,
- ACTION_DOWN,
- 1,
- 0,
- arrayOf(PointerProperties(0)),
- arrayOf(PointerCoords(3f, 4f))
- )
-
- val aMove1 = aDown.moveTo(11.milliseconds, 3f, 4f)
- val bDown = down(21, 11.milliseconds, 23f, 24f)
- val motionEvent2 =
- MotionEvent(
- 11,
- ACTION_POINTER_DOWN,
- 2,
- 2,
- arrayOf(PointerProperties(0), PointerProperties(1)),
- arrayOf(PointerCoords(3f, 4f), PointerCoords(23f, 24f))
- )
-
- val aMove2 = aMove1.moveTo(31.milliseconds, 31f, 32f)
- val bMove = bDown.moveTo(31.milliseconds, 33f, 34f)
- val motionEvent3 =
- MotionEvent(
- 31,
- ACTION_MOVE,
- 2,
- 0,
- arrayOf(PointerProperties(0), PointerProperties(1)),
- arrayOf(PointerCoords(31f, 32f), PointerCoords(33f, 34f))
- )
-
- val expected = listOf(aMove2.deepCopy(), bMove.deepCopy())
-
- // Act
- pointerInteropFilter.pointerInputFilter::onPointerEvent.invokeOverAllPasses(
- pointerEventOf(aDown, motionEvent = motionEvent1)
- )
- retVal = false
- pointerInteropFilter.pointerInputFilter::onPointerEvent.invokeOverAllPasses(
- pointerEventOf(aMove1, bDown, motionEvent = motionEvent2)
- )
- retVal = true
- pointerInteropFilter.pointerInputFilter::onPointerEvent.invokeOverAllPasses(
- pointerEventOf(aMove2, bMove, motionEvent = motionEvent3)
- )
-
- // Assert
- assertThat(listOf(aMove2, bMove)).isEqualTo(expected)
- }
-
- @Test
- fun onPointerEvent_down1ThenDown2ViewRetsFalseThenViewRetsTrueUp2_moveNotConsumed() {
- // Arrange
-
- val aDown = down(1, 2.milliseconds, 3f, 4f)
- val motionEvent1 =
- MotionEvent(
- 2,
- ACTION_DOWN,
- 1,
- 0,
- arrayOf(PointerProperties(0)),
- arrayOf(PointerCoords(3f, 4f))
- )
-
- val aMove1 = aDown.moveTo(11.milliseconds, 3f, 4f)
- val bDown = down(21, 11.milliseconds, 23f, 24f)
- val motionEvent2 =
- MotionEvent(
- 11,
- ACTION_POINTER_DOWN,
- 2,
- 2,
- arrayOf(PointerProperties(0), PointerProperties(1)),
- arrayOf(PointerCoords(3f, 4f), PointerCoords(23f, 24f))
- )
-
- val aMove2 = aMove1.moveTo(31.milliseconds, 31f, 32f)
- val bUp = bDown.up(31.milliseconds)
- val motionEvent3 =
- MotionEvent(
- 31,
- ACTION_POINTER_UP,
- 2,
- 2,
- arrayOf(PointerProperties(0), PointerProperties(1)),
- arrayOf(PointerCoords(3f, 4f), PointerCoords(23f, 24f))
- )
-
- val expected = listOf(aMove2.deepCopy(), bUp.deepCopy())
-
- // Act
- pointerInteropFilter.pointerInputFilter::onPointerEvent.invokeOverAllPasses(
- pointerEventOf(aDown, motionEvent = motionEvent1)
- )
- retVal = false
- pointerInteropFilter.pointerInputFilter::onPointerEvent.invokeOverAllPasses(
- pointerEventOf(aMove1, bDown, motionEvent = motionEvent2)
- )
- retVal = true
- pointerInteropFilter.pointerInputFilter::onPointerEvent.invokeOverAllPasses(
- pointerEventOf(aMove2, bUp, motionEvent = motionEvent3)
- )
-
- // Assert
- assertThat(listOf(aMove2, bUp)).isEqualTo(expected)
- }
-
// Verification of correct passes being used
@Test
diff --git a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/input/pointer/PointerInteropFilter.kt b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/input/pointer/PointerInteropFilter.kt
index d642399..6e1811f 100644
--- a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/input/pointer/PointerInteropFilter.kt
+++ b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/input/pointer/PointerInteropFilter.kt
@@ -260,10 +260,18 @@
this.layoutCoordinates?.localToRoot(Offset.Zero)
?: error("layoutCoordinates not set")
) { motionEvent ->
- state = if (onTouchEvent(motionEvent)) {
- DispatchToViewState.Dispatching
+ if (motionEvent.actionMasked == MotionEvent.ACTION_DOWN) {
+ // If the action is ACTION_DOWN, we care about the return value of
+ // onTouchEvent and use it to set our initial dispatching state.
+ state = if (onTouchEvent(motionEvent)) {
+ DispatchToViewState.Dispatching
+ } else {
+ DispatchToViewState.NotDispatching
+ }
} else {
- DispatchToViewState.NotDispatching
+ // Otherwise, we don't care about the return value. This is intended
+ // to be in accordance with how the Android View system works.
+ onTouchEvent(motionEvent)
}
}
if (state === DispatchToViewState.Dispatching) {
diff --git a/core/core-ktx/build.gradle b/core/core-ktx/build.gradle
index 188f249..3a4be30 100644
--- a/core/core-ktx/build.gradle
+++ b/core/core-ktx/build.gradle
@@ -30,5 +30,4 @@
mavenGroup = LibraryGroups.CORE
inceptionYear = "2018"
description = "Kotlin extensions for 'core' artifact"
- legacyDisableKotlinStrictApiMode = true
}
diff --git a/core/core-ktx/src/main/java/androidx/core/animation/Animator.kt b/core/core-ktx/src/main/java/androidx/core/animation/Animator.kt
index cc26fa5..5aa9cd2 100644
--- a/core/core-ktx/src/main/java/androidx/core/animation/Animator.kt
+++ b/core/core-ktx/src/main/java/androidx/core/animation/Animator.kt
@@ -25,7 +25,9 @@
* @return the [Animator.AnimatorListener] added to the Animator
* @see Animator.end
*/
-inline fun Animator.doOnEnd(crossinline action: (animator: Animator) -> Unit) =
+public inline fun Animator.doOnEnd(
+ crossinline action: (animator: Animator) -> Unit
+): Animator.AnimatorListener =
addListener(onEnd = action)
/**
@@ -34,7 +36,9 @@
* @return the [Animator.AnimatorListener] added to the Animator
* @see Animator.start
*/
-inline fun Animator.doOnStart(crossinline action: (animator: Animator) -> Unit) =
+public inline fun Animator.doOnStart(
+ crossinline action: (animator: Animator) -> Unit
+): Animator.AnimatorListener =
addListener(onStart = action)
/**
@@ -43,7 +47,9 @@
* @return the [Animator.AnimatorListener] added to the Animator
* @see Animator.cancel
*/
-inline fun Animator.doOnCancel(crossinline action: (animator: Animator) -> Unit) =
+public inline fun Animator.doOnCancel(
+ crossinline action: (animator: Animator) -> Unit
+): Animator.AnimatorListener =
addListener(onCancel = action)
/**
@@ -51,7 +57,9 @@
*
* @return the [Animator.AnimatorListener] added to the Animator
*/
-inline fun Animator.doOnRepeat(crossinline action: (animator: Animator) -> Unit) =
+public inline fun Animator.doOnRepeat(
+ crossinline action: (animator: Animator) -> Unit
+): Animator.AnimatorListener =
addListener(onRepeat = action)
/**
@@ -61,7 +69,9 @@
* @see Animator.resume
*/
@RequiresApi(19)
-inline fun Animator.doOnResume(crossinline action: (animator: Animator) -> Unit) =
+public inline fun Animator.doOnResume(
+ crossinline action: (animator: Animator) -> Unit
+): Animator.AnimatorPauseListener =
addPauseListener(onResume = action)
/**
@@ -71,7 +81,9 @@
* @see Animator.pause
*/
@RequiresApi(19)
-inline fun Animator.doOnPause(crossinline action: (animator: Animator) -> Unit) =
+public inline fun Animator.doOnPause(
+ crossinline action: (animator: Animator) -> Unit
+): Animator.AnimatorPauseListener =
addPauseListener(onPause = action)
/**
@@ -79,7 +91,7 @@
*
* @return the [Animator.AnimatorListener] added to the Animator
*/
-inline fun Animator.addListener(
+public inline fun Animator.addListener(
crossinline onEnd: (animator: Animator) -> Unit = {},
crossinline onStart: (animator: Animator) -> Unit = {},
crossinline onCancel: (animator: Animator) -> Unit = {},
@@ -101,7 +113,7 @@
* @return the [Animator.AnimatorPauseListener] added to the Animator
*/
@RequiresApi(19)
-inline fun Animator.addPauseListener(
+public inline fun Animator.addPauseListener(
crossinline onResume: (animator: Animator) -> Unit = {},
crossinline onPause: (animator: Animator) -> Unit = {}
): Animator.AnimatorPauseListener {
diff --git a/core/core-ktx/src/main/java/androidx/core/content/ContentValues.kt b/core/core-ktx/src/main/java/androidx/core/content/ContentValues.kt
index e1a0d01..bf79247 100644
--- a/core/core-ktx/src/main/java/androidx/core/content/ContentValues.kt
+++ b/core/core-ktx/src/main/java/androidx/core/content/ContentValues.kt
@@ -23,7 +23,9 @@
*
* @throws IllegalArgumentException When a value is not a supported type of [ContentValues].
*/
-fun contentValuesOf(vararg pairs: Pair<String, Any?>) = ContentValues(pairs.size).apply {
+public fun contentValuesOf(
+ vararg pairs: Pair<String, Any?>
+): ContentValues = ContentValues(pairs.size).apply {
for ((key, value) in pairs) {
when (value) {
null -> putNull(key)
diff --git a/core/core-ktx/src/main/java/androidx/core/content/Context.kt b/core/core-ktx/src/main/java/androidx/core/content/Context.kt
index 7aaea2b..2300153 100644
--- a/core/core-ktx/src/main/java/androidx/core/content/Context.kt
+++ b/core/core-ktx/src/main/java/androidx/core/content/Context.kt
@@ -27,7 +27,7 @@
*
* @see ContextCompat.getSystemService
*/
-inline fun <reified T : Any> Context.getSystemService(): T? =
+public inline fun <reified T : Any> Context.getSystemService(): T? =
ContextCompat.getSystemService(this, T::class.java)
/**
@@ -49,7 +49,7 @@
* @see Context.obtainStyledAttributes
* @see android.content.res.Resources.Theme.obtainStyledAttributes
*/
-inline fun Context.withStyledAttributes(
+public inline fun Context.withStyledAttributes(
set: AttributeSet? = null,
attrs: IntArray,
@AttrRes defStyleAttr: Int = 0,
@@ -68,7 +68,7 @@
* @see Context.obtainStyledAttributes
* @see android.content.res.Resources.Theme.obtainStyledAttributes
*/
-inline fun Context.withStyledAttributes(
+public inline fun Context.withStyledAttributes(
@StyleRes resourceId: Int,
attrs: IntArray,
block: TypedArray.() -> Unit
diff --git a/core/core-ktx/src/main/java/androidx/core/content/SharedPreferences.kt b/core/core-ktx/src/main/java/androidx/core/content/SharedPreferences.kt
index c4677ea..f75387f 100644
--- a/core/core-ktx/src/main/java/androidx/core/content/SharedPreferences.kt
+++ b/core/core-ktx/src/main/java/androidx/core/content/SharedPreferences.kt
@@ -36,7 +36,7 @@
* ```
*/
@SuppressLint("ApplySharedPref")
-inline fun SharedPreferences.edit(
+public inline fun SharedPreferences.edit(
commit: Boolean = false,
action: SharedPreferences.Editor.() -> Unit
) {
diff --git a/core/core-ktx/src/main/java/androidx/core/content/res/TypedArray.kt b/core/core-ktx/src/main/java/androidx/core/content/res/TypedArray.kt
index 5c3d1a0..8f73a8f 100644
--- a/core/core-ktx/src/main/java/androidx/core/content/res/TypedArray.kt
+++ b/core/core-ktx/src/main/java/androidx/core/content/res/TypedArray.kt
@@ -39,7 +39,7 @@
* @see TypedArray.hasValue
* @see TypedArray.getBoolean
*/
-fun TypedArray.getBooleanOrThrow(@StyleableRes index: Int): Boolean {
+public fun TypedArray.getBooleanOrThrow(@StyleableRes index: Int): Boolean {
checkAttribute(index)
return getBoolean(index, false)
}
@@ -52,7 +52,7 @@
* @see TypedArray.getColor
*/
@ColorInt
-fun TypedArray.getColorOrThrow(@StyleableRes index: Int): Int {
+public fun TypedArray.getColorOrThrow(@StyleableRes index: Int): Int {
checkAttribute(index)
return getColor(index, 0)
}
@@ -64,7 +64,7 @@
* @see TypedArray.hasValue
* @see TypedArray.getColorStateList
*/
-fun TypedArray.getColorStateListOrThrow(@StyleableRes index: Int): ColorStateList {
+public fun TypedArray.getColorStateListOrThrow(@StyleableRes index: Int): ColorStateList {
checkAttribute(index)
return checkNotNull(getColorStateList(index)) {
"Attribute value was not a color or color state list."
@@ -78,7 +78,7 @@
* @see TypedArray.hasValue
* @see TypedArray.getDimension
*/
-fun TypedArray.getDimensionOrThrow(@StyleableRes index: Int): Float {
+public fun TypedArray.getDimensionOrThrow(@StyleableRes index: Int): Float {
checkAttribute(index)
return getDimension(index, 0f)
}
@@ -91,7 +91,7 @@
* @see TypedArray.getDimensionPixelOffset
*/
@Dimension
-fun TypedArray.getDimensionPixelOffsetOrThrow(@StyleableRes index: Int): Int {
+public fun TypedArray.getDimensionPixelOffsetOrThrow(@StyleableRes index: Int): Int {
checkAttribute(index)
return getDimensionPixelOffset(index, 0)
}
@@ -104,7 +104,7 @@
* @see TypedArray.getDimensionPixelSize
*/
@Dimension
-fun TypedArray.getDimensionPixelSizeOrThrow(@StyleableRes index: Int): Int {
+public fun TypedArray.getDimensionPixelSizeOrThrow(@StyleableRes index: Int): Int {
checkAttribute(index)
return getDimensionPixelSize(index, 0)
}
@@ -116,7 +116,7 @@
* @see TypedArray.hasValue
* @see TypedArray.getDrawable
*/
-fun TypedArray.getDrawableOrThrow(@StyleableRes index: Int): Drawable {
+public fun TypedArray.getDrawableOrThrow(@StyleableRes index: Int): Drawable {
checkAttribute(index)
return getDrawable(index)!!
}
@@ -128,7 +128,7 @@
* @see TypedArray.hasValue
* @see TypedArray.getFloat
*/
-fun TypedArray.getFloatOrThrow(@StyleableRes index: Int): Float {
+public fun TypedArray.getFloatOrThrow(@StyleableRes index: Int): Float {
checkAttribute(index)
return getFloat(index, 0f)
}
@@ -141,7 +141,7 @@
* @see TypedArray.getFont
*/
@RequiresApi(26)
-fun TypedArray.getFontOrThrow(@StyleableRes index: Int): Typeface {
+public fun TypedArray.getFontOrThrow(@StyleableRes index: Int): Typeface {
checkAttribute(index)
return getFont(index)!!
}
@@ -153,7 +153,7 @@
* @see TypedArray.hasValue
* @see TypedArray.getInt
*/
-fun TypedArray.getIntOrThrow(@StyleableRes index: Int): Int {
+public fun TypedArray.getIntOrThrow(@StyleableRes index: Int): Int {
checkAttribute(index)
return getInt(index, 0)
}
@@ -165,7 +165,7 @@
* @see TypedArray.hasValue
* @see TypedArray.getInteger
*/
-fun TypedArray.getIntegerOrThrow(@StyleableRes index: Int): Int {
+public fun TypedArray.getIntegerOrThrow(@StyleableRes index: Int): Int {
checkAttribute(index)
return getInteger(index, 0)
}
@@ -178,7 +178,7 @@
* @see TypedArray.getResourceId
*/
@AnyRes
-fun TypedArray.getResourceIdOrThrow(@StyleableRes index: Int): Int {
+public fun TypedArray.getResourceIdOrThrow(@StyleableRes index: Int): Int {
checkAttribute(index)
return getResourceId(index, 0)
}
@@ -190,7 +190,7 @@
* @see TypedArray.hasValue
* @see TypedArray.getString
*/
-fun TypedArray.getStringOrThrow(@StyleableRes index: Int): String {
+public fun TypedArray.getStringOrThrow(@StyleableRes index: Int): String {
checkAttribute(index)
return checkNotNull(getString(index)) {
"Attribute value could not be coerced to String."
@@ -204,7 +204,7 @@
* @see TypedArray.hasValue
* @see TypedArray.getText
*/
-fun TypedArray.getTextOrThrow(@StyleableRes index: Int): CharSequence {
+public fun TypedArray.getTextOrThrow(@StyleableRes index: Int): CharSequence {
checkAttribute(index)
return checkNotNull(getText(index)) {
"Attribute value could not be coerced to CharSequence."
@@ -218,7 +218,7 @@
* @see TypedArray.hasValue
* @see TypedArray.getTextArray
*/
-fun TypedArray.getTextArrayOrThrow(@StyleableRes index: Int): Array<CharSequence> {
+public fun TypedArray.getTextArrayOrThrow(@StyleableRes index: Int): Array<CharSequence> {
checkAttribute(index)
return getTextArray(index)
}
@@ -228,7 +228,7 @@
*
* @see kotlin.io.use
*/
-inline fun <R> TypedArray.use(block: (TypedArray) -> R): R {
+public inline fun <R> TypedArray.use(block: (TypedArray) -> R): R {
return block(this).also {
recycle()
}
diff --git a/core/core-ktx/src/main/java/androidx/core/database/Cursor.kt b/core/core-ktx/src/main/java/androidx/core/database/Cursor.kt
index 0132b2d..650de49 100644
--- a/core/core-ktx/src/main/java/androidx/core/database/Cursor.kt
+++ b/core/core-ktx/src/main/java/androidx/core/database/Cursor.kt
@@ -29,7 +29,9 @@
* @see Cursor.isNull
* @see Cursor.getBlob
*/
-inline fun Cursor.getBlobOrNull(index: Int) = if (isNull(index)) null else getBlob(index)
+public inline fun Cursor.getBlobOrNull(
+ index: Int
+): ByteArray? = if (isNull(index)) null else getBlob(index)
/**
* Returns the value of the requested column as a nullable double.
@@ -40,7 +42,9 @@
* @see Cursor.isNull
* @see Cursor.getDouble
*/
-inline fun Cursor.getDoubleOrNull(index: Int) = if (isNull(index)) null else getDouble(index)
+public inline fun Cursor.getDoubleOrNull(
+ index: Int
+): Double? = if (isNull(index)) null else getDouble(index)
/**
* Returns the value of the requested column as a nullable float.
@@ -51,7 +55,9 @@
* @see Cursor.isNull
* @see Cursor.getFloat
*/
-inline fun Cursor.getFloatOrNull(index: Int) = if (isNull(index)) null else getFloat(index)
+public inline fun Cursor.getFloatOrNull(
+ index: Int
+): Float? = if (isNull(index)) null else getFloat(index)
/**
* Returns the value of the requested column as a nullable integer.
@@ -62,7 +68,9 @@
* @see Cursor.isNull
* @see Cursor.getInt
*/
-inline fun Cursor.getIntOrNull(index: Int) = if (isNull(index)) null else getInt(index)
+public inline fun Cursor.getIntOrNull(
+ index: Int
+): Int? = if (isNull(index)) null else getInt(index)
/**
* Returns the value of the requested column as a nullable long.
@@ -73,7 +81,9 @@
* @see Cursor.isNull
* @see Cursor.getLong
*/
-inline fun Cursor.getLongOrNull(index: Int) = if (isNull(index)) null else getLong(index)
+public inline fun Cursor.getLongOrNull(
+ index: Int
+): Long? = if (isNull(index)) null else getLong(index)
/**
* Returns the value of the requested column as a nullable short.
@@ -84,7 +94,9 @@
* @see Cursor.isNull
* @see Cursor.getShort
*/
-inline fun Cursor.getShortOrNull(index: Int) = if (isNull(index)) null else getShort(index)
+public inline fun Cursor.getShortOrNull(
+ index: Int
+): Short? = if (isNull(index)) null else getShort(index)
/**
* Returns the value of the requested column as a nullable string.
@@ -95,4 +107,6 @@
* @see Cursor.isNull
* @see Cursor.getString
*/
-inline fun Cursor.getStringOrNull(index: Int) = if (isNull(index)) null else getString(index)
+public inline fun Cursor.getStringOrNull(
+ index: Int
+): String? = if (isNull(index)) null else getString(index)
diff --git a/core/core-ktx/src/main/java/androidx/core/database/sqlite/SQLiteDatabase.kt b/core/core-ktx/src/main/java/androidx/core/database/sqlite/SQLiteDatabase.kt
index bdbd94e..aa4203f 100644
--- a/core/core-ktx/src/main/java/androidx/core/database/sqlite/SQLiteDatabase.kt
+++ b/core/core-ktx/src/main/java/androidx/core/database/sqlite/SQLiteDatabase.kt
@@ -23,7 +23,7 @@
*
* @param exclusive Run in `EXCLUSIVE` mode when true, `IMMEDIATE` mode otherwise.
*/
-inline fun <T> SQLiteDatabase.transaction(
+public inline fun <T> SQLiteDatabase.transaction(
exclusive: Boolean = true,
body: SQLiteDatabase.() -> T
): T {
diff --git a/core/core-ktx/src/main/java/androidx/core/graphics/Bitmap.kt b/core/core-ktx/src/main/java/androidx/core/graphics/Bitmap.kt
index d9d054f..f5cfa22 100644
--- a/core/core-ktx/src/main/java/androidx/core/graphics/Bitmap.kt
+++ b/core/core-ktx/src/main/java/androidx/core/graphics/Bitmap.kt
@@ -38,7 +38,7 @@
* }
* ```
*/
-inline fun Bitmap.applyCanvas(block: Canvas.() -> Unit): Bitmap {
+public inline fun Bitmap.applyCanvas(block: Canvas.() -> Unit): Bitmap {
val c = Canvas(this)
c.block()
return this
@@ -48,14 +48,18 @@
* Returns the value of the pixel at the specified location. The returned value
* is a [color int][android.graphics.Color] in the sRGB color space.
*/
-inline operator fun Bitmap.get(x: Int, y: Int) = getPixel(x, y)
+public inline operator fun Bitmap.get(x: Int, y: Int): Int = getPixel(x, y)
/**
* Writes the specified [color int][android.graphics.Color] into the bitmap
* (assuming it is mutable) at the specified `(x, y)` coordinate. The specified
* color is converted from sRGB to the bitmap's color space if needed.
*/
-inline operator fun Bitmap.set(x: Int, y: Int, @ColorInt color: Int) = setPixel(x, y, color)
+public inline operator fun Bitmap.set(
+ x: Int,
+ y: Int,
+ @ColorInt color: Int
+): Unit = setPixel(x, y, color)
/**
* Creates a new bitmap, scaled from this bitmap, when possible. If the specified
@@ -68,7 +72,7 @@
*
* @return The new scaled bitmap or the source bitmap if no scaling is required.
*/
-inline fun Bitmap.scale(width: Int, height: Int, filter: Boolean = true): Bitmap {
+public inline fun Bitmap.scale(width: Int, height: Int, filter: Boolean = true): Bitmap {
return Bitmap.createScaledBitmap(this, width, height, filter)
}
@@ -82,7 +86,7 @@
*
* @return A new bitmap with the specified dimensions and config
*/
-inline fun createBitmap(
+public inline fun createBitmap(
width: Int,
height: Int,
config: Bitmap.Config = Bitmap.Config.ARGB_8888
@@ -104,7 +108,7 @@
* @return A new bitmap with the specified dimensions and config
*/
@RequiresApi(26)
-inline fun createBitmap(
+public inline fun createBitmap(
width: Int,
height: Int,
config: Bitmap.Config = Bitmap.Config.ARGB_8888,
@@ -119,11 +123,15 @@
* A point is contained if: 0 <= x < width and 0 <= y < height.
* An empty bitmap never contains any point.
*/
-inline operator fun Bitmap.contains(p: Point) = p.x >= 0 && p.x < width && p.y >= 0 && p.y < height
+public inline operator fun Bitmap.contains(
+ p: Point
+): Boolean = p.x >= 0 && p.x < width && p.y >= 0 && p.y < height
/**
* Returns true if the specified point is inside the bitmap.
* A point is contained if: 0 <= x < width and 0 <= y < height.
* An empty bitmap never contains any point.
*/
-inline operator fun Bitmap.contains(p: PointF) = p.x >= 0 && p.x < width && p.y >= 0 && p.y < height
+public inline operator fun Bitmap.contains(
+ p: PointF
+): Boolean = p.x >= 0 && p.x < width && p.y >= 0 && p.y < height
diff --git a/core/core-ktx/src/main/java/androidx/core/graphics/Canvas.kt b/core/core-ktx/src/main/java/androidx/core/graphics/Canvas.kt
index 254ea34..a3a068c 100644
--- a/core/core-ktx/src/main/java/androidx/core/graphics/Canvas.kt
+++ b/core/core-ktx/src/main/java/androidx/core/graphics/Canvas.kt
@@ -26,7 +26,7 @@
* Wrap the specified [block] in calls to [Canvas.save]
* and [Canvas.restoreToCount].
*/
-inline fun Canvas.withSave(block: Canvas.() -> Unit) {
+public inline fun Canvas.withSave(block: Canvas.() -> Unit) {
val checkpoint = save()
try {
block()
@@ -39,7 +39,7 @@
* Wrap the specified [block] in calls to [Canvas.save]/[Canvas.translate]
* and [Canvas.restoreToCount].
*/
-inline fun Canvas.withTranslation(
+public inline fun Canvas.withTranslation(
x: Float = 0.0f,
y: Float = 0.0f,
block: Canvas.() -> Unit
@@ -57,7 +57,7 @@
* Wrap the specified [block] in calls to [Canvas.save]/[Canvas.rotate]
* and [Canvas.restoreToCount].
*/
-inline fun Canvas.withRotation(
+public inline fun Canvas.withRotation(
degrees: Float = 0.0f,
pivotX: Float = 0.0f,
pivotY: Float = 0.0f,
@@ -76,7 +76,7 @@
* Wrap the specified [block] in calls to [Canvas.save]/[Canvas.scale]
* and [Canvas.restoreToCount].
*/
-inline fun Canvas.withScale(
+public inline fun Canvas.withScale(
x: Float = 1.0f,
y: Float = 1.0f,
pivotX: Float = 0.0f,
@@ -96,7 +96,7 @@
* Wrap the specified [block] in calls to [Canvas.save]/[Canvas.skew]
* and [Canvas.restoreToCount].
*/
-inline fun Canvas.withSkew(
+public inline fun Canvas.withSkew(
x: Float = 0.0f,
y: Float = 0.0f,
block: Canvas.() -> Unit
@@ -114,7 +114,7 @@
* Wrap the specified [block] in calls to [Canvas.save]/[Canvas.concat]
* and [Canvas.restoreToCount].
*/
-inline fun Canvas.withMatrix(
+public inline fun Canvas.withMatrix(
matrix: Matrix = Matrix(),
block: Canvas.() -> Unit
) {
@@ -131,7 +131,7 @@
* Wrap the specified [block] in calls to [Canvas.save]/[Canvas.clipRect]
* and [Canvas.restoreToCount].
*/
-inline fun Canvas.withClip(
+public inline fun Canvas.withClip(
clipRect: Rect,
block: Canvas.() -> Unit
) {
@@ -148,7 +148,7 @@
* Wrap the specified [block] in calls to [Canvas.save]/[Canvas.clipRect]
* and [Canvas.restoreToCount].
*/
-inline fun Canvas.withClip(
+public inline fun Canvas.withClip(
clipRect: RectF,
block: Canvas.() -> Unit
) {
@@ -165,7 +165,7 @@
* Wrap the specified [block] in calls to [Canvas.save]/[Canvas.clipRect]
* and [Canvas.restoreToCount].
*/
-inline fun Canvas.withClip(
+public inline fun Canvas.withClip(
left: Int,
top: Int,
right: Int,
@@ -185,7 +185,7 @@
* Wrap the specified [block] in calls to [Canvas.save]/[Canvas.clipRect]
* and [Canvas.restoreToCount].
*/
-inline fun Canvas.withClip(
+public inline fun Canvas.withClip(
left: Float,
top: Float,
right: Float,
@@ -205,7 +205,7 @@
* Wrap the specified [block] in calls to [Canvas.save]/[Canvas.clipPath]
* and [Canvas.restoreToCount].
*/
-inline fun Canvas.withClip(
+public inline fun Canvas.withClip(
clipPath: Path,
block: Canvas.() -> Unit
) {
diff --git a/core/core-ktx/src/main/java/androidx/core/graphics/Color.kt b/core/core-ktx/src/main/java/androidx/core/graphics/Color.kt
index ef5e0432..5a18b8c 100644
--- a/core/core-ktx/src/main/java/androidx/core/graphics/Color.kt
+++ b/core/core-ktx/src/main/java/androidx/core/graphics/Color.kt
@@ -36,7 +36,7 @@
* ```
*/
@RequiresApi(26)
-inline operator fun Color.component1() = getComponent(0)
+public inline operator fun Color.component1(): Float = getComponent(0)
/**
* Returns the second component of the color. For instance, when the color model
@@ -50,7 +50,7 @@
* ```
*/
@RequiresApi(26)
-inline operator fun Color.component2() = getComponent(1)
+public inline operator fun Color.component2(): Float = getComponent(1)
/**
* Returns the third component of the color. For instance, when the color model
@@ -64,7 +64,7 @@
* ```
*/
@RequiresApi(26)
-inline operator fun Color.component3() = getComponent(2)
+public inline operator fun Color.component3(): Float = getComponent(2)
/**
* Returns the fourth component of the color. For instance, when the color model
@@ -78,7 +78,7 @@
* ```
*/
@RequiresApi(26)
-inline operator fun Color.component4() = getComponent(3)
+public inline operator fun Color.component4(): Float = getComponent(3)
/**
* Composites two translucent colors together. More specifically, adds two colors using
@@ -100,7 +100,7 @@
* of the colors do not match
*/
@RequiresApi(26)
-operator fun Color.plus(c: Color): Color = ColorUtils.compositeColors(c, this)
+public operator fun Color.plus(c: Color): Color = ColorUtils.compositeColors(c, this)
/**
* Return the alpha component of a color int. This is equivalent to calling:
@@ -108,7 +108,7 @@
* Color.alpha(myInt)
* ```
*/
-inline val @receiver:ColorInt Int.alpha get() = (this shr 24) and 0xff
+public inline val @receiver:ColorInt Int.alpha: Int get() = (this shr 24) and 0xff
/**
* Return the red component of a color int. This is equivalent to calling:
@@ -116,7 +116,7 @@
* Color.red(myInt)
* ```
*/
-inline val @receiver:ColorInt Int.red get() = (this shr 16) and 0xff
+public inline val @receiver:ColorInt Int.red: Int get() = (this shr 16) and 0xff
/**
* Return the green component of a color int. This is equivalent to calling:
@@ -124,7 +124,7 @@
* Color.green(myInt)
* ```
*/
-inline val @receiver:ColorInt Int.green get() = (this shr 8) and 0xff
+public inline val @receiver:ColorInt Int.green: Int get() = (this shr 8) and 0xff
/**
* Return the blue component of a color int. This is equivalent to calling:
@@ -132,7 +132,7 @@
* Color.blue(myInt)
* ```
*/
-inline val @receiver:ColorInt Int.blue get() = this and 0xff
+public inline val @receiver:ColorInt Int.blue: Int get() = this and 0xff
/**
* Return the alpha component of a color int. This is equivalent to calling:
@@ -146,7 +146,7 @@
* val (alpha, red, green, blue) = myColor
* ```
*/
-inline operator fun @receiver:ColorInt Int.component1() = (this shr 24) and 0xff
+public inline operator fun @receiver:ColorInt Int.component1(): Int = (this shr 24) and 0xff
/**
* Return the red component of a color int. This is equivalent to calling:
@@ -160,7 +160,7 @@
* val (alpha, red, green, blue) = myColor
* ```
*/
-inline operator fun @receiver:ColorInt Int.component2() = (this shr 16) and 0xff
+public inline operator fun @receiver:ColorInt Int.component2(): Int = (this shr 16) and 0xff
/**
* Return the green component of a color int. This is equivalent to calling:
@@ -174,7 +174,7 @@
* val (alpha, red, green, blue) = myColor
* ```
*/
-inline operator fun @receiver:ColorInt Int.component3() = (this shr 8) and 0xff
+public inline operator fun @receiver:ColorInt Int.component3(): Int = (this shr 8) and 0xff
/**
* Return the blue component of a color int. This is equivalent to calling:
@@ -188,7 +188,7 @@
* val (alpha, red, green, blue) = myColor
* ```
*/
-inline operator fun @receiver:ColorInt Int.component4() = this and 0xff
+public inline operator fun @receiver:ColorInt Int.component4(): Int = this and 0xff
/**
* Returns the relative luminance of a color int, assuming sRGB encoding.
@@ -196,14 +196,15 @@
* W3C Recommendation 11 December 2008.
*/
@get:RequiresApi(26)
-inline val @receiver:ColorInt Int.luminance get() = Color.luminance(this)
+public inline val @receiver:ColorInt Int.luminance: Float
+ get() = Color.luminance(this)
/**
* Creates a new [Color] instance from a color int. The resulting color
* is in the [sRGB][android.graphics.ColorSpace.Named.SRGB] color space.
*/
@RequiresApi(26)
-inline fun @receiver:ColorInt Int.toColor(): Color = Color.valueOf(this)
+public inline fun @receiver:ColorInt Int.toColor(): Color = Color.valueOf(this)
/**
* Converts the specified ARGB [color int][Color] to an RGBA [color long][Color]
@@ -211,7 +212,7 @@
*/
@RequiresApi(26)
@ColorLong
-inline fun @receiver:ColorInt Int.toColorLong() = Color.pack(this)
+public inline fun @receiver:ColorInt Int.toColorLong(): Long = Color.pack(this)
/**
* Returns the first component of the color. For instance, when the color model
@@ -225,7 +226,7 @@
* ```
*/
@RequiresApi(26)
-inline operator fun @receiver:ColorLong Long.component1() = Color.red(this)
+public inline operator fun @receiver:ColorLong Long.component1(): Float = Color.red(this)
/**
* Returns the second component of the color. For instance, when the color model
@@ -239,7 +240,7 @@
* ```
*/
@RequiresApi(26)
-inline operator fun @receiver:ColorLong Long.component2() = Color.green(this)
+public inline operator fun @receiver:ColorLong Long.component2(): Float = Color.green(this)
/**
* Returns the third component of the color. For instance, when the color model
@@ -253,7 +254,7 @@
* ```
*/
@RequiresApi(26)
-inline operator fun @receiver:ColorLong Long.component3() = Color.blue(this)
+public inline operator fun @receiver:ColorLong Long.component3(): Float = Color.blue(this)
/**
* Returns the fourth component of the color. For instance, when the color model
@@ -267,7 +268,7 @@
* ```
*/
@RequiresApi(26)
-inline operator fun @receiver:ColorLong Long.component4() = Color.alpha(this)
+public inline operator fun @receiver:ColorLong Long.component4(): Float = Color.alpha(this)
/**
* Return the alpha component of a color long. This is equivalent to calling:
@@ -276,7 +277,8 @@
* ```
*/
@get:RequiresApi(26)
-inline val @receiver:ColorLong Long.alpha get() = Color.alpha(this)
+public inline val @receiver:ColorLong Long.alpha: Float
+ get() = Color.alpha(this)
/**
* Return the red component of a color long. This is equivalent to calling:
@@ -285,7 +287,8 @@
* ```
*/
@get:RequiresApi(26)
-inline val @receiver:ColorLong Long.red get() = Color.red(this)
+public inline val @receiver:ColorLong Long.red: Float
+ get() = Color.red(this)
/**
* Return the green component of a color long. This is equivalent to calling:
@@ -294,7 +297,8 @@
* ```
*/
@get:RequiresApi(26)
-inline val @receiver:ColorLong Long.green get() = Color.green(this)
+public inline val @receiver:ColorLong Long.green: Float
+ get() = Color.green(this)
/**
* Return the blue component of a color long. This is equivalent to calling:
@@ -303,46 +307,50 @@
* ```
*/
@get:RequiresApi(26)
-inline val @receiver:ColorLong Long.blue get() = Color.blue(this)
+public inline val @receiver:ColorLong Long.blue: Float
+ get() = Color.blue(this)
/**
* Returns the relative luminance of a color. Based on the formula for
* relative luminance defined in WCAG 2.0, W3C Recommendation 11 December 2008.
*/
@get:RequiresApi(26)
-inline val @receiver:ColorLong Long.luminance get() = Color.luminance(this)
+public inline val @receiver:ColorLong Long.luminance: Float
+ get() = Color.luminance(this)
/**
* Creates a new [Color] instance from a [color long][Color].
*/
@RequiresApi(26)
-inline fun @receiver:ColorLong Long.toColor(): Color = Color.valueOf(this)
+public inline fun @receiver:ColorLong Long.toColor(): Color = Color.valueOf(this)
/**
* Converts the specified [color long][Color] to an ARGB [color int][Color].
*/
@RequiresApi(26)
@ColorInt
-inline fun @receiver:ColorLong Long.toColorInt() = Color.toArgb(this)
+public inline fun @receiver:ColorLong Long.toColorInt(): Int = Color.toArgb(this)
/**
* Indicates whether the color is in the [sRGB][android.graphics.ColorSpace.Named.SRGB]
* color space.
*/
@get:RequiresApi(26)
-inline val @receiver:ColorLong Long.isSrgb get() = Color.isSrgb(this)
+public inline val @receiver:ColorLong Long.isSrgb: Boolean
+ get() = Color.isSrgb(this)
/**
* Indicates whether the color is in a [wide-gamut][android.graphics.ColorSpace] color space.
*/
@get:RequiresApi(26)
-inline val @receiver:ColorLong Long.isWideGamut get() = Color.isWideGamut(this)
+public inline val @receiver:ColorLong Long.isWideGamut: Boolean
+ get() = Color.isWideGamut(this)
/**
* Returns the color space encoded in the specified color long.
*/
@get:RequiresApi(26)
-inline val @receiver:ColorLong Long.colorSpace: ColorSpace get() = Color.colorSpace(this)
+public inline val @receiver:ColorLong Long.colorSpace: ColorSpace get() = Color.colorSpace(this)
/**
* Converts the color int receiver to a color long in the specified color space. This is
@@ -353,7 +361,7 @@
*/
@RequiresApi(26)
@ColorLong
-inline infix fun @receiver:ColorInt Int.convertTo(colorSpace: ColorSpace.Named) =
+public inline infix fun @receiver:ColorInt Int.convertTo(colorSpace: ColorSpace.Named): Long =
Color.convert(this, ColorSpace.get(colorSpace))
/**
@@ -365,7 +373,7 @@
*/
@RequiresApi(26)
@ColorLong
-inline infix fun @receiver:ColorInt Int.convertTo(colorSpace: ColorSpace) =
+public inline infix fun @receiver:ColorInt Int.convertTo(colorSpace: ColorSpace): Long =
Color.convert(this, colorSpace)
/**
@@ -377,7 +385,7 @@
*/
@RequiresApi(26)
@ColorLong
-inline infix fun @receiver:ColorLong Long.convertTo(colorSpace: ColorSpace.Named) =
+public inline infix fun @receiver:ColorLong Long.convertTo(colorSpace: ColorSpace.Named): Long =
Color.convert(this, ColorSpace.get(colorSpace))
/**
@@ -389,7 +397,7 @@
*/
@RequiresApi(26)
@ColorLong
-inline infix fun @receiver:ColorLong Long.convertTo(colorSpace: ColorSpace) =
+public inline infix fun @receiver:ColorLong Long.convertTo(colorSpace: ColorSpace): Long =
Color.convert(this, colorSpace)
/**
@@ -400,7 +408,8 @@
* ```
*/
@RequiresApi(26)
-inline infix fun Color.convertTo(colorSpace: ColorSpace.Named) = convert(ColorSpace.get(colorSpace))
+public inline infix fun Color.convertTo(colorSpace: ColorSpace.Named): Color =
+ convert(ColorSpace.get(colorSpace))
/**
* Converts the color receiver to a color in the specified color space. This is
@@ -410,7 +419,7 @@
* ```
*/
@RequiresApi(26)
-inline infix fun Color.convertTo(colorSpace: ColorSpace) = convert(colorSpace)
+public inline infix fun Color.convertTo(colorSpace: ColorSpace): Color = convert(colorSpace)
/**
* Return a corresponding [Int] color of this [String].
@@ -429,4 +438,4 @@
* @throws IllegalArgumentException if this [String] cannot be parsed.
*/
@ColorInt
-inline fun String.toColorInt(): Int = Color.parseColor(this)
+public inline fun String.toColorInt(): Int = Color.parseColor(this)
diff --git a/core/core-ktx/src/main/java/androidx/core/graphics/ImageDecoder.kt b/core/core-ktx/src/main/java/androidx/core/graphics/ImageDecoder.kt
index e1802ff..a5895aa 100644
--- a/core/core-ktx/src/main/java/androidx/core/graphics/ImageDecoder.kt
+++ b/core/core-ktx/src/main/java/androidx/core/graphics/ImageDecoder.kt
@@ -29,7 +29,7 @@
* @see ImageDecoder.decodeBitmap
*/
@RequiresApi(28)
-inline fun ImageDecoder.Source.decodeBitmap(
+public inline fun ImageDecoder.Source.decodeBitmap(
crossinline action: ImageDecoder.(info: ImageInfo, source: Source) -> Unit
): Bitmap {
return ImageDecoder.decodeBitmap(this) { decoder, info, source ->
@@ -43,7 +43,7 @@
* @see ImageDecoder.decodeDrawable
*/
@RequiresApi(28)
-inline fun ImageDecoder.Source.decodeDrawable(
+public inline fun ImageDecoder.Source.decodeDrawable(
crossinline action: ImageDecoder.(info: ImageInfo, source: Source) -> Unit
): Drawable {
return ImageDecoder.decodeDrawable(this) { decoder, info, source ->
diff --git a/core/core-ktx/src/main/java/androidx/core/graphics/Matrix.kt b/core/core-ktx/src/main/java/androidx/core/graphics/Matrix.kt
index 5cb0cdf..99f3e31 100644
--- a/core/core-ktx/src/main/java/androidx/core/graphics/Matrix.kt
+++ b/core/core-ktx/src/main/java/androidx/core/graphics/Matrix.kt
@@ -24,28 +24,30 @@
* Multiplies this [Matrix] by another matrix and returns the result as
* a new matrix.
*/
-inline operator fun Matrix.times(m: Matrix) = Matrix(this).apply { preConcat(m) }
+public inline operator fun Matrix.times(m: Matrix): Matrix = Matrix(this).apply { preConcat(m) }
/**
* Returns the 9 values of this [Matrix] as a new array of floats.
*/
-inline fun Matrix.values() = FloatArray(9).apply { getValues(this) }
+public inline fun Matrix.values(): FloatArray = FloatArray(9).apply { getValues(this) }
/**
* Creates a translation matrix with the translation amounts [tx] and [ty]
* respectively on the `x` and `y` axis.
*/
-fun translationMatrix(tx: Float = 0.0f, ty: Float = 0.0f) = Matrix().apply { setTranslate(tx, ty) }
+public fun translationMatrix(tx: Float = 0.0f, ty: Float = 0.0f): Matrix =
+ Matrix().apply { setTranslate(tx, ty) }
/**
* Creates a scale matrix with the scale factor [sx] and [sy] respectively on the
* `x` and `y` axis.
*/
-fun scaleMatrix(sx: Float = 1.0f, sy: Float = 1.0f) = Matrix().apply { setScale(sx, sy) }
+public fun scaleMatrix(sx: Float = 1.0f, sy: Float = 1.0f): Matrix =
+ Matrix().apply { setScale(sx, sy) }
/**
* Creates a rotation matrix, defined by a rotation angle in degrees around the pivot
* point located at the coordinates ([px], [py]).
*/
-fun rotationMatrix(degrees: Float, px: Float = 0.0f, py: Float = 0.0f) =
+public fun rotationMatrix(degrees: Float, px: Float = 0.0f, py: Float = 0.0f): Matrix =
Matrix().apply { setRotate(degrees, px, py) }
diff --git a/core/core-ktx/src/main/java/androidx/core/graphics/Paint.kt b/core/core-ktx/src/main/java/androidx/core/graphics/Paint.kt
index 530cbf3..441cb8b 100644
--- a/core/core-ktx/src/main/java/androidx/core/graphics/Paint.kt
+++ b/core/core-ktx/src/main/java/androidx/core/graphics/Paint.kt
@@ -25,6 +25,6 @@
* compatible way. This method is a no-op for BlendModes that have no equivalent
* on older API levels
*/
-inline fun Paint.setBlendMode(blendModeCompat: BlendModeCompat?): Boolean {
+public inline fun Paint.setBlendMode(blendModeCompat: BlendModeCompat?): Boolean {
return PaintCompat.setBlendMode(this, blendModeCompat)
}
\ No newline at end of file
diff --git a/core/core-ktx/src/main/java/androidx/core/graphics/Path.kt b/core/core-ktx/src/main/java/androidx/core/graphics/Path.kt
index 1fe88cd..95888bb 100644
--- a/core/core-ktx/src/main/java/androidx/core/graphics/Path.kt
+++ b/core/core-ktx/src/main/java/androidx/core/graphics/Path.kt
@@ -31,13 +31,14 @@
* @see Path.approximate
*/
@RequiresApi(26)
-fun Path.flatten(error: Float = 0.5f): Iterable<PathSegment> = PathUtils.flatten(this, error)
+public fun Path.flatten(error: Float = 0.5f): Iterable<PathSegment> =
+ PathUtils.flatten(this, error)
/**
* Returns the union of two paths as a new [Path].
*/
@RequiresApi(19)
-inline operator fun Path.plus(p: Path): Path {
+public inline operator fun Path.plus(p: Path): Path {
return Path(this).apply {
op(p, Path.Op.UNION)
}
@@ -47,7 +48,7 @@
* Returns the difference of two paths as a new [Path].
*/
@RequiresApi(19)
-inline operator fun Path.minus(p: Path): Path {
+public inline operator fun Path.minus(p: Path): Path {
return Path(this).apply {
op(p, Path.Op.DIFFERENCE)
}
@@ -57,14 +58,14 @@
* Returns the union of two paths as a new [Path].
*/
@RequiresApi(19)
-inline infix fun Path.or(p: Path) = this + p
+public inline infix fun Path.or(p: Path): Path = this + p
/**
* Returns the intersection of two paths as a new [Path].
* If the paths do not intersect, returns an empty path.
*/
@RequiresApi(19)
-inline infix fun Path.and(p: Path): Path {
+public inline infix fun Path.and(p: Path): Path {
return Path().apply {
op(this@and, p, Path.Op.INTERSECT)
}
@@ -74,7 +75,7 @@
* Returns the union minus the intersection of two paths as a new [Path].
*/
@RequiresApi(19)
-inline infix fun Path.xor(p: Path): Path {
+public inline infix fun Path.xor(p: Path): Path {
return Path(this).apply {
op(p, Path.Op.XOR)
}
diff --git a/core/core-ktx/src/main/java/androidx/core/graphics/Picture.kt b/core/core-ktx/src/main/java/androidx/core/graphics/Picture.kt
index d1e8c99..0518584 100644
--- a/core/core-ktx/src/main/java/androidx/core/graphics/Picture.kt
+++ b/core/core-ktx/src/main/java/androidx/core/graphics/Picture.kt
@@ -32,7 +32,7 @@
* }
* ```
*/
-inline fun Picture.record(width: Int, height: Int, block: Canvas.() -> Unit): Picture {
+public inline fun Picture.record(width: Int, height: Int, block: Canvas.() -> Unit): Picture {
val c = beginRecording(width, height)
try {
c.block()
diff --git a/core/core-ktx/src/main/java/androidx/core/graphics/Point.kt b/core/core-ktx/src/main/java/androidx/core/graphics/Point.kt
index b6e35e6..eb598ff 100644
--- a/core/core-ktx/src/main/java/androidx/core/graphics/Point.kt
+++ b/core/core-ktx/src/main/java/androidx/core/graphics/Point.kt
@@ -30,7 +30,7 @@
* val (x, y) = myPoint
* ```
*/
-inline operator fun Point.component1() = this.x
+public inline operator fun Point.component1(): Int = this.x
/**
* Returns the y coordinate of this point.
@@ -41,7 +41,7 @@
* val (x, y) = myPoint
* ```
*/
-inline operator fun Point.component2() = this.y
+public inline operator fun Point.component2(): Int = this.y
/**
* Returns the x coordinate of this point.
@@ -52,7 +52,7 @@
* val (x, y) = myPoint
* ```
*/
-inline operator fun PointF.component1() = this.x
+public inline operator fun PointF.component1(): Float = this.x
/**
* Returns the y coordinate of this point.
@@ -63,12 +63,12 @@
* val (x, y) = myPoint
* ```
*/
-inline operator fun PointF.component2() = this.y
+public inline operator fun PointF.component2(): Float = this.y
/**
* Offsets this point by the specified point and returns the result as a new point.
*/
-inline operator fun Point.plus(p: Point): Point {
+public inline operator fun Point.plus(p: Point): Point {
return Point(x, y).apply {
offset(p.x, p.y)
}
@@ -77,7 +77,7 @@
/**
* Offsets this point by the specified point and returns the result as a new point.
*/
-inline operator fun PointF.plus(p: PointF): PointF {
+public inline operator fun PointF.plus(p: PointF): PointF {
return PointF(x, y).apply {
offset(p.x, p.y)
}
@@ -87,7 +87,7 @@
* Offsets this point by the specified amount on both X and Y axis and returns the
* result as a new point.
*/
-inline operator fun Point.plus(xy: Int): Point {
+public inline operator fun Point.plus(xy: Int): Point {
return Point(x, y).apply {
offset(xy, xy)
}
@@ -97,7 +97,7 @@
* Offsets this point by the specified amount on both X and Y axis and returns the
* result as a new point.
*/
-inline operator fun PointF.plus(xy: Float): PointF {
+public inline operator fun PointF.plus(xy: Float): PointF {
return PointF(x, y).apply {
offset(xy, xy)
}
@@ -107,7 +107,7 @@
* Offsets this point by the negation of the specified point and returns the result
* as a new point.
*/
-inline operator fun Point.minus(p: Point): Point {
+public inline operator fun Point.minus(p: Point): Point {
return Point(x, y).apply {
offset(-p.x, -p.y)
}
@@ -117,7 +117,7 @@
* Offsets this point by the negation of the specified point and returns the result
* as a new point.
*/
-inline operator fun PointF.minus(p: PointF): PointF {
+public inline operator fun PointF.minus(p: PointF): PointF {
return PointF(x, y).apply {
offset(-p.x, -p.y)
}
@@ -127,7 +127,7 @@
* Offsets this point by the negation of the specified amount on both X and Y axis and
* returns the result as a new point.
*/
-inline operator fun Point.minus(xy: Int): Point {
+public inline operator fun Point.minus(xy: Int): Point {
return Point(x, y).apply {
offset(-xy, -xy)
}
@@ -137,7 +137,7 @@
* Offsets this point by the negation of the specified amount on both X and Y axis and
* returns the result as a new point.
*/
-inline operator fun PointF.minus(xy: Float): PointF {
+public inline operator fun PointF.minus(xy: Float): PointF {
return PointF(x, y).apply {
offset(-xy, -xy)
}
@@ -146,19 +146,19 @@
/**
* Returns a new point representing the negation of this point.
*/
-inline operator fun Point.unaryMinus() = Point(-x, -y)
+public inline operator fun Point.unaryMinus(): Point = Point(-x, -y)
/**
* Returns a new point representing the negation of this point.
*/
-inline operator fun PointF.unaryMinus() = PointF(-x, -y)
+public inline operator fun PointF.unaryMinus(): PointF = PointF(-x, -y)
/**
* Returns a [PointF] representation of this point.
*/
-inline fun Point.toPointF() = PointF(this)
+public inline fun Point.toPointF(): PointF = PointF(this)
/**
* Returns a [Point] representation of this point.
*/
-inline fun PointF.toPoint() = Point(x.toInt(), y.toInt())
+public inline fun PointF.toPoint(): Point = Point(x.toInt(), y.toInt())
diff --git a/core/core-ktx/src/main/java/androidx/core/graphics/PorterDuff.kt b/core/core-ktx/src/main/java/androidx/core/graphics/PorterDuff.kt
index a34d6f9..a9bedc5 100644
--- a/core/core-ktx/src/main/java/androidx/core/graphics/PorterDuff.kt
+++ b/core/core-ktx/src/main/java/androidx/core/graphics/PorterDuff.kt
@@ -26,10 +26,11 @@
* Creates a new [PorterDuffXfermode] that uses this [PorterDuff.Mode] as the
* alpha compositing or blending mode.
*/
-inline fun PorterDuff.Mode.toXfermode() = PorterDuffXfermode(this)
+public inline fun PorterDuff.Mode.toXfermode(): PorterDuffXfermode = PorterDuffXfermode(this)
/**
* Creates a new [PorterDuffColorFilter] that uses this [PorterDuff.Mode] as the
* alpha compositing or blending mode, and the specified [color].
*/
-inline fun PorterDuff.Mode.toColorFilter(color: Int) = PorterDuffColorFilter(color, this)
+public inline fun PorterDuff.Mode.toColorFilter(color: Int): PorterDuffColorFilter =
+ PorterDuffColorFilter(color, this)
diff --git a/core/core-ktx/src/main/java/androidx/core/graphics/Rect.kt b/core/core-ktx/src/main/java/androidx/core/graphics/Rect.kt
index 7b1cf01..2a73233 100644
--- a/core/core-ktx/src/main/java/androidx/core/graphics/Rect.kt
+++ b/core/core-ktx/src/main/java/androidx/core/graphics/Rect.kt
@@ -35,7 +35,7 @@
* val (left, top, right, bottom) = myRectangle
* ```
*/
-inline operator fun Rect.component1() = this.left
+public inline operator fun Rect.component1(): Int = this.left
/**
* Returns "top", the second component of the rectangle.
@@ -46,7 +46,7 @@
* val (left, top, right, bottom) = myRectangle
* ```
*/
-inline operator fun Rect.component2() = this.top
+public inline operator fun Rect.component2(): Int = this.top
/**
* Returns "right", the third component of the rectangle.
@@ -57,7 +57,7 @@
* val (left, top, right, bottom) = myRectangle
* ```
*/
-inline operator fun Rect.component3() = this.right
+public inline operator fun Rect.component3(): Int = this.right
/**
* Returns "bottom", the fourth component of the rectangle.
@@ -68,7 +68,7 @@
* val (left, top, right, bottom) = myRectangle
* ```
*/
-inline operator fun Rect.component4() = this.bottom
+public inline operator fun Rect.component4(): Int = this.bottom
/**
* Returns "left", the first component of the rectangle.
@@ -79,7 +79,7 @@
* val (left, top, right, bottom) = myRectangle
* ```
*/
-inline operator fun RectF.component1() = this.left
+public inline operator fun RectF.component1(): Float = this.left
/**
* Returns "top", the second component of the rectangle.
@@ -90,7 +90,7 @@
* val (left, top, right, bottom) = myRectangle
* ```
*/
-inline operator fun RectF.component2() = this.top
+public inline operator fun RectF.component2(): Float = this.top
/**
* Returns "right", the third component of the rectangle.
@@ -101,7 +101,7 @@
* val (left, top, right, bottom) = myRectangle
* ```
*/
-inline operator fun RectF.component3() = this.right
+public inline operator fun RectF.component3(): Float = this.right
/**
* Returns "bottom", the fourth component of the rectangle.
@@ -112,13 +112,13 @@
* val (left, top, right, bottom) = myRectangle
* ```
*/
-inline operator fun RectF.component4() = this.bottom
+public inline operator fun RectF.component4(): Float = this.bottom
/**
* Performs the union of this rectangle and the specified rectangle and returns
* the result as a new rectangle.
*/
-inline operator fun Rect.plus(r: Rect): Rect {
+public inline operator fun Rect.plus(r: Rect): Rect {
return Rect(this).apply {
union(r)
}
@@ -128,7 +128,7 @@
* Performs the union of this rectangle and the specified rectangle and returns
* the result as a new rectangle.
*/
-inline operator fun RectF.plus(r: RectF): RectF {
+public inline operator fun RectF.plus(r: RectF): RectF {
return RectF(this).apply {
union(r)
}
@@ -138,7 +138,7 @@
* Returns a new rectangle representing this rectangle offset by the specified
* amount on both X and Y axis.
*/
-inline operator fun Rect.plus(xy: Int): Rect {
+public inline operator fun Rect.plus(xy: Int): Rect {
return Rect(this).apply {
offset(xy, xy)
}
@@ -148,7 +148,7 @@
* Returns a new rectangle representing this rectangle offset by the specified
* amount on both X and Y axis.
*/
-inline operator fun RectF.plus(xy: Float): RectF {
+public inline operator fun RectF.plus(xy: Float): RectF {
return RectF(this).apply {
offset(xy, xy)
}
@@ -158,7 +158,7 @@
* Returns a new rectangle representing this rectangle offset by the specified
* point.
*/
-inline operator fun Rect.plus(xy: Point): Rect {
+public inline operator fun Rect.plus(xy: Point): Rect {
return Rect(this).apply {
offset(xy.x, xy.y)
}
@@ -168,7 +168,7 @@
* Returns a new rectangle representing this rectangle offset by the specified
* point.
*/
-inline operator fun RectF.plus(xy: PointF): RectF {
+public inline operator fun RectF.plus(xy: PointF): RectF {
return RectF(this).apply {
offset(xy.x, xy.y)
}
@@ -177,7 +177,7 @@
/**
* Returns the difference of this rectangle and the specified rectangle as a new region.
*/
-inline operator fun Rect.minus(r: Rect): Region {
+public inline operator fun Rect.minus(r: Rect): Region {
return Region(this).apply {
op(r, Region.Op.DIFFERENCE)
}
@@ -187,7 +187,7 @@
* Returns the difference of this rectangle and the specified rectangle as a new region.
* This rectangle is first converted to a [Rect] using [RectF.toRect].
*/
-inline operator fun RectF.minus(r: RectF): Region {
+public inline operator fun RectF.minus(r: RectF): Region {
return Region(this.toRect()).apply {
op(r.toRect(), Region.Op.DIFFERENCE)
}
@@ -197,7 +197,7 @@
* Returns a new rectangle representing this rectangle offset by the negation
* of the specified amount on both X and Y axis.
*/
-inline operator fun Rect.minus(xy: Int): Rect {
+public inline operator fun Rect.minus(xy: Int): Rect {
return Rect(this).apply {
offset(-xy, -xy)
}
@@ -207,7 +207,7 @@
* Returns a new rectangle representing this rectangle offset by the negation
* of the specified amount on both X and Y axis.
*/
-inline operator fun RectF.minus(xy: Float): RectF {
+public inline operator fun RectF.minus(xy: Float): RectF {
return RectF(this).apply {
offset(-xy, -xy)
}
@@ -217,7 +217,7 @@
* Returns a new rectangle representing this rectangle offset by the negation of
* the specified point.
*/
-inline operator fun Rect.minus(xy: Point): Rect {
+public inline operator fun Rect.minus(xy: Point): Rect {
return Rect(this).apply {
offset(-xy.x, -xy.y)
}
@@ -227,7 +227,7 @@
* Returns a new rectangle representing this rectangle offset by the negation of
* the specified point.
*/
-inline operator fun RectF.minus(xy: PointF): RectF {
+public inline operator fun RectF.minus(xy: PointF): RectF {
return RectF(this).apply {
offset(-xy.x, -xy.y)
}
@@ -236,7 +236,7 @@
/**
* Returns a new rectangle representing this rectangle's components each scaled by [factor].
*/
-inline operator fun Rect.times(factor: Int): Rect {
+public inline operator fun Rect.times(factor: Int): Rect {
return Rect(this).apply {
top *= factor
left *= factor
@@ -248,12 +248,12 @@
/**
* Returns a new rectangle representing this rectangle's components each scaled by [factor].
*/
-inline operator fun RectF.times(factor: Int): RectF = times(factor.toFloat())
+public inline operator fun RectF.times(factor: Int): RectF = times(factor.toFloat())
/**
* Returns a new rectangle representing this rectangle's components each scaled by [factor].
*/
-inline operator fun RectF.times(factor: Float): RectF {
+public inline operator fun RectF.times(factor: Float): RectF {
return RectF(this).apply {
top *= factor
left *= factor
@@ -265,12 +265,12 @@
/**
* Returns the union of two rectangles as a new rectangle.
*/
-inline infix fun Rect.or(r: Rect) = this + r
+public inline infix fun Rect.or(r: Rect): Rect = this + r
/**
* Returns the union of two rectangles as a new rectangle.
*/
-inline infix fun RectF.or(r: RectF) = this + r
+public inline infix fun RectF.or(r: RectF): RectF = this + r
/**
* Returns the intersection of two rectangles as a new rectangle.
@@ -278,7 +278,7 @@
* rectangle.
*/
@SuppressLint("CheckResult")
-inline infix fun Rect.and(r: Rect): Rect {
+public inline infix fun Rect.and(r: Rect): Rect {
return Rect(this).apply {
intersect(r)
}
@@ -290,7 +290,7 @@
* rectangle.
*/
@SuppressLint("CheckResult")
-inline infix fun RectF.and(r: RectF): RectF {
+public inline infix fun RectF.and(r: RectF): RectF {
return RectF(this).apply {
intersect(r)
}
@@ -299,7 +299,7 @@
/**
* Returns the union minus the intersection of two rectangles as a new region.
*/
-inline infix fun Rect.xor(r: Rect): Region {
+public inline infix fun Rect.xor(r: Rect): Region {
return Region(this).apply {
op(r, Region.Op.XOR)
}
@@ -309,7 +309,7 @@
* Returns the union minus the intersection of two rectangles as a new region.
* The two rectangles are first converted to [Rect] using [RectF.toRect].
*/
-inline infix fun RectF.xor(r: RectF): Region {
+public inline infix fun RectF.xor(r: RectF): Region {
return Region(this.toRect()).apply {
op(r.toRect(), Region.Op.XOR)
}
@@ -321,7 +321,7 @@
* This means that for a point to be contained: left <= x < right and top <= y < bottom.
* An empty rectangle never contains any point.
*/
-inline operator fun Rect.contains(p: Point) = contains(p.x, p.y)
+public inline operator fun Rect.contains(p: Point): Boolean = contains(p.x, p.y)
/**
* Returns true if the specified point is inside the rectangle.
@@ -329,18 +329,18 @@
* This means that for a point to be contained: left <= x < right and top <= y < bottom.
* An empty rectangle never contains any point.
*/
-inline operator fun RectF.contains(p: PointF) = contains(p.x, p.y)
+public inline operator fun RectF.contains(p: PointF): Boolean = contains(p.x, p.y)
/**
* Returns a [RectF] representation of this rectangle.
*/
-inline fun Rect.toRectF(): RectF = RectF(this)
+public inline fun Rect.toRectF(): RectF = RectF(this)
/**
* Returns a [Rect] representation of this rectangle. The resulting rect will be sized such
* that this rect can fit within it.
*/
-inline fun RectF.toRect(): Rect {
+public inline fun RectF.toRect(): Rect {
val r = Rect()
roundOut(r)
return r
@@ -349,16 +349,16 @@
/**
* Returns a [Region] representation of this rectangle.
*/
-inline fun Rect.toRegion() = Region(this)
+public inline fun Rect.toRegion(): Region = Region(this)
/**
* Returns a [Region] representation of this rectangle. The resulting rect will be sized such
* that this rect can fit within it.
*/
-inline fun RectF.toRegion() = Region(this.toRect())
+public inline fun RectF.toRegion(): Region = Region(this.toRect())
/**
* Transform this rectangle in place using the supplied [Matrix] and returns
* this rectangle.
*/
-inline fun RectF.transform(m: Matrix) = apply { m.mapRect(this@transform) }
+public inline fun RectF.transform(m: Matrix): RectF = apply { m.mapRect(this@transform) }
diff --git a/core/core-ktx/src/main/java/androidx/core/graphics/Region.kt b/core/core-ktx/src/main/java/androidx/core/graphics/Region.kt
index 06469ba..d3c6d32 100644
--- a/core/core-ktx/src/main/java/androidx/core/graphics/Region.kt
+++ b/core/core-ktx/src/main/java/androidx/core/graphics/Region.kt
@@ -26,12 +26,12 @@
/**
* Return true if the region contains the specified [Point].
*/
-inline operator fun Region.contains(p: Point) = contains(p.x, p.y)
+public inline operator fun Region.contains(p: Point): Boolean = contains(p.x, p.y)
/**
* Return the union of this region and the specified [Rect] as a new region.
*/
-inline operator fun Region.plus(r: Rect): Region {
+public inline operator fun Region.plus(r: Rect): Region {
return Region(this).apply {
union(r)
}
@@ -40,7 +40,7 @@
/**
* Return the union of this region and the specified region as a new region.
*/
-inline operator fun Region.plus(r: Region): Region {
+public inline operator fun Region.plus(r: Region): Region {
return Region(this).apply {
op(r, Region.Op.UNION)
}
@@ -49,7 +49,7 @@
/**
* Return the difference of this region and the specified [Rect] as a new region.
*/
-inline operator fun Region.minus(r: Rect): Region {
+public inline operator fun Region.minus(r: Rect): Region {
return Region(this).apply {
op(r, Region.Op.DIFFERENCE)
}
@@ -58,7 +58,7 @@
/**
* Return the difference of this region and the specified region as a new region.
*/
-inline operator fun Region.minus(r: Region): Region {
+public inline operator fun Region.minus(r: Region): Region {
return Region(this).apply {
op(r, Region.Op.DIFFERENCE)
}
@@ -67,7 +67,7 @@
/**
* Returns the negation of this region as a new region.
*/
-inline operator fun Region.unaryMinus(): Region {
+public inline operator fun Region.unaryMinus(): Region {
return Region(bounds).apply {
op(this@unaryMinus, Region.Op.DIFFERENCE)
}
@@ -76,22 +76,22 @@
/**
* Returns the negation of this region as a new region.
*/
-inline operator fun Region.not() = -this
+public inline operator fun Region.not(): Region = -this
/**
* Return the union of this region and the specified [Rect] as a new region.
*/
-inline infix fun Region.or(r: Rect) = this + r
+public inline infix fun Region.or(r: Rect): Region = this + r
/**
* Return the union of this region and the specified region as a new region.
*/
-inline infix fun Region.or(r: Region) = this + r
+public inline infix fun Region.or(r: Region): Region = this + r
/**
* Return the intersection of this region and the specified [Rect] as a new region.
*/
-inline infix fun Region.and(r: Rect): Region {
+public inline infix fun Region.and(r: Rect): Region {
return Region(this).apply {
op(r, Region.Op.INTERSECT)
}
@@ -100,7 +100,7 @@
/**
* Return the intersection of this region and the specified region as a new region.
*/
-inline infix fun Region.and(r: Region): Region {
+public inline infix fun Region.and(r: Region): Region {
return Region(this).apply {
op(r, Region.Op.INTERSECT)
}
@@ -110,7 +110,7 @@
* Return the union minus the intersection of this region and the specified [Rect]
* as a new region.
*/
-inline infix fun Region.xor(r: Rect): Region {
+public inline infix fun Region.xor(r: Rect): Region {
return Region(this).apply {
op(r, Region.Op.XOR)
}
@@ -120,14 +120,14 @@
* Return the union minus the intersection of this region and the specified region
* as a new region.
*/
-inline infix fun Region.xor(r: Region): Region {
+public inline infix fun Region.xor(r: Region): Region {
return Region(this).apply {
op(r, Region.Op.XOR)
}
}
/** Performs the given action on each rect in this region. */
-inline fun Region.forEach(action: (rect: Rect) -> Unit) {
+public inline fun Region.forEach(action: (rect: Rect) -> Unit) {
val iterator = RegionIterator(this)
while (true) {
val r = Rect()
@@ -139,7 +139,7 @@
}
/** Returns an [Iterator] over the rects in this region. */
-operator fun Region.iterator() = object : Iterator<Rect> {
+public operator fun Region.iterator(): Iterator<Rect> = object : Iterator<Rect> {
private val iterator = RegionIterator(this@iterator)
private val rect = Rect()
private var hasMore = iterator.next(rect)
diff --git a/core/core-ktx/src/main/java/androidx/core/graphics/Shader.kt b/core/core-ktx/src/main/java/androidx/core/graphics/Shader.kt
index 0fb93cb..4751363 100644
--- a/core/core-ktx/src/main/java/androidx/core/graphics/Shader.kt
+++ b/core/core-ktx/src/main/java/androidx/core/graphics/Shader.kt
@@ -22,7 +22,7 @@
/**
* Wrap the specified [block] in calls to [Shader.getLocalMatrix] and [Shader.setLocalMatrix].
*/
-inline fun Shader.transform(block: Matrix.() -> Unit) {
+public inline fun Shader.transform(block: Matrix.() -> Unit) {
val matrix = Matrix()
getLocalMatrix(matrix)
block(matrix)
diff --git a/core/core-ktx/src/main/java/androidx/core/graphics/drawable/BitmapDrawable.kt b/core/core-ktx/src/main/java/androidx/core/graphics/drawable/BitmapDrawable.kt
index 4a96aab..fc58f3f 100644
--- a/core/core-ktx/src/main/java/androidx/core/graphics/drawable/BitmapDrawable.kt
+++ b/core/core-ktx/src/main/java/androidx/core/graphics/drawable/BitmapDrawable.kt
@@ -23,4 +23,6 @@
import android.graphics.drawable.BitmapDrawable
/** Create a [BitmapDrawable] from this [Bitmap]. */
-inline fun Bitmap.toDrawable(resources: Resources) = BitmapDrawable(resources, this)
+public inline fun Bitmap.toDrawable(
+ resources: Resources
+): BitmapDrawable = BitmapDrawable(resources, this)
diff --git a/core/core-ktx/src/main/java/androidx/core/graphics/drawable/ColorDrawable.kt b/core/core-ktx/src/main/java/androidx/core/graphics/drawable/ColorDrawable.kt
index bef04df..476e06b 100644
--- a/core/core-ktx/src/main/java/androidx/core/graphics/drawable/ColorDrawable.kt
+++ b/core/core-ktx/src/main/java/androidx/core/graphics/drawable/ColorDrawable.kt
@@ -24,8 +24,8 @@
import androidx.annotation.RequiresApi
/** Create a [ColorDrawable] from this color value. */
-inline fun @receiver:ColorInt Int.toDrawable() = ColorDrawable(this)
+public inline fun @receiver:ColorInt Int.toDrawable(): ColorDrawable = ColorDrawable(this)
/** Create a [ColorDrawable] from this [Color] (via [Color.toArgb]). */
@RequiresApi(26)
-inline fun Color.toDrawable() = ColorDrawable(toArgb())
+public inline fun Color.toDrawable(): ColorDrawable = ColorDrawable(toArgb())
diff --git a/core/core-ktx/src/main/java/androidx/core/graphics/drawable/Drawable.kt b/core/core-ktx/src/main/java/androidx/core/graphics/drawable/Drawable.kt
index 9e63bbd..bb9a42b 100644
--- a/core/core-ktx/src/main/java/androidx/core/graphics/drawable/Drawable.kt
+++ b/core/core-ktx/src/main/java/androidx/core/graphics/drawable/Drawable.kt
@@ -39,7 +39,7 @@
* @param config Bitmap config of the desired bitmap. Null attempts to use the native config, if
* any. Defaults to [Config.ARGB_8888] otherwise.
*/
-fun Drawable.toBitmap(
+public fun Drawable.toBitmap(
@Px width: Int = intrinsicWidth,
@Px height: Int = intrinsicHeight,
config: Config? = null
@@ -71,7 +71,7 @@
*
* @see Drawable.setBounds
*/
-fun Drawable.updateBounds(
+public fun Drawable.updateBounds(
@Px left: Int = bounds.left,
@Px top: Int = bounds.top,
@Px right: Int = bounds.right,
diff --git a/core/core-ktx/src/main/java/androidx/core/graphics/drawable/Icon.kt b/core/core-ktx/src/main/java/androidx/core/graphics/drawable/Icon.kt
index a9077e2..f2be051 100644
--- a/core/core-ktx/src/main/java/androidx/core/graphics/drawable/Icon.kt
+++ b/core/core-ktx/src/main/java/androidx/core/graphics/drawable/Icon.kt
@@ -29,7 +29,7 @@
* @see Icon.createWithAdaptiveBitmap
*/
@RequiresApi(26)
-inline fun Bitmap.toAdaptiveIcon(): Icon = Icon.createWithAdaptiveBitmap(this)
+public inline fun Bitmap.toAdaptiveIcon(): Icon = Icon.createWithAdaptiveBitmap(this)
/**
* Create an [Icon] from this [Bitmap].
@@ -37,7 +37,7 @@
* @see Icon.createWithBitmap
*/
@RequiresApi(26)
-inline fun Bitmap.toIcon(): Icon = Icon.createWithBitmap(this)
+public inline fun Bitmap.toIcon(): Icon = Icon.createWithBitmap(this)
/**
* Create an [Icon] from this [Uri].
@@ -45,7 +45,7 @@
* @see Icon.createWithContentUri
*/
@RequiresApi(26)
-inline fun Uri.toIcon(): Icon = Icon.createWithContentUri(this)
+public inline fun Uri.toIcon(): Icon = Icon.createWithContentUri(this)
/**
* Create an [Icon] from this [ByteArray].
@@ -53,4 +53,4 @@
* @see Icon.createWithData
*/
@RequiresApi(26)
-inline fun ByteArray.toIcon(): Icon = Icon.createWithData(this, 0, size)
+public inline fun ByteArray.toIcon(): Icon = Icon.createWithData(this, 0, size)
diff --git a/core/core-ktx/src/main/java/androidx/core/location/Location.kt b/core/core-ktx/src/main/java/androidx/core/location/Location.kt
index fe48322..73ab0dc 100644
--- a/core/core-ktx/src/main/java/androidx/core/location/Location.kt
+++ b/core/core-ktx/src/main/java/androidx/core/location/Location.kt
@@ -29,7 +29,7 @@
* val (lat, lon) = myLocation
* ```
*/
-inline operator fun Location.component1() = this.latitude
+public inline operator fun Location.component1(): Double = this.latitude
/**
* Returns the longitude of this [Location].
@@ -40,4 +40,4 @@
* val (lat, lon) = myLocation
* ```
*/
-inline operator fun Location.component2() = this.longitude
+public inline operator fun Location.component2(): Double = this.longitude
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 b27d072..a4c3f89 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
@@ -26,20 +26,20 @@
*
* @see Uri.parse
*/
-inline fun String.toUri(): Uri = Uri.parse(this)
+public inline fun String.toUri(): Uri = Uri.parse(this)
/**
* Creates a Uri from the given file.
*
* @see Uri.fromFile
*/
-inline fun File.toUri(): Uri = Uri.fromFile(this)
+public inline fun File.toUri(): Uri = Uri.fromFile(this)
/**
* 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 {
+public 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-ktx/src/main/java/androidx/core/os/Bundle.kt b/core/core-ktx/src/main/java/androidx/core/os/Bundle.kt
index 3d26f30..94612e9 100644
--- a/core/core-ktx/src/main/java/androidx/core/os/Bundle.kt
+++ b/core/core-ktx/src/main/java/androidx/core/os/Bundle.kt
@@ -29,7 +29,7 @@
*
* @throws IllegalArgumentException When a value is not a supported type of [Bundle].
*/
-fun bundleOf(vararg pairs: Pair<String, Any?>) = Bundle(pairs.size).apply {
+public fun bundleOf(vararg pairs: Pair<String, Any?>): Bundle = Bundle(pairs.size).apply {
for ((key, value) in pairs) {
when (value) {
null -> putString(key, null) // Any nullable type will suffice.
diff --git a/core/core-ktx/src/main/java/androidx/core/os/Handler.kt b/core/core-ktx/src/main/java/androidx/core/os/Handler.kt
index de09a9b..bbe8ff6 100644
--- a/core/core-ktx/src/main/java/androidx/core/os/Handler.kt
+++ b/core/core-ktx/src/main/java/androidx/core/os/Handler.kt
@@ -30,7 +30,7 @@
*
* @return the created Runnable
*/
-inline fun Handler.postDelayed(
+public inline fun Handler.postDelayed(
delayInMillis: Long,
token: Any? = null,
crossinline action: () -> Unit
@@ -57,7 +57,7 @@
* @param token An optional object with which the posted message will be associated.
* @return the created Runnable
*/
-inline fun Handler.postAtTime(
+public inline fun Handler.postAtTime(
uptimeMillis: Long,
token: Any? = null,
crossinline action: () -> Unit
diff --git a/core/core-ktx/src/main/java/androidx/core/os/PersistableBundle.kt b/core/core-ktx/src/main/java/androidx/core/os/PersistableBundle.kt
index 04856d8..fd9665b 100644
--- a/core/core-ktx/src/main/java/androidx/core/os/PersistableBundle.kt
+++ b/core/core-ktx/src/main/java/androidx/core/os/PersistableBundle.kt
@@ -26,7 +26,9 @@
* @throws IllegalArgumentException When a value is not a supported type of [PersistableBundle].
*/
@RequiresApi(21)
-fun persistableBundleOf(vararg pairs: Pair<String, Any?>) = PersistableBundle(pairs.size).apply {
+public fun persistableBundleOf(
+ vararg pairs: Pair<String, Any?>
+): PersistableBundle = PersistableBundle(pairs.size).apply {
for ((key, value) in pairs) {
when (value) {
null -> putString(key, null) // Any nullable type will suffice.
diff --git a/core/core-ktx/src/main/java/androidx/core/os/Trace.kt b/core/core-ktx/src/main/java/androidx/core/os/Trace.kt
index cb381ee..f7f9462 100644
--- a/core/core-ktx/src/main/java/androidx/core/os/Trace.kt
+++ b/core/core-ktx/src/main/java/androidx/core/os/Trace.kt
@@ -30,7 +30,7 @@
)
)
@Suppress("DEPRECATION")
-inline fun <T> trace(sectionName: String, block: () -> T): T {
+public inline fun <T> trace(sectionName: String, block: () -> T): T {
TraceCompat.beginSection(sectionName)
try {
return block()
diff --git a/core/core-ktx/src/main/java/androidx/core/text/CharSequence.kt b/core/core-ktx/src/main/java/androidx/core/text/CharSequence.kt
index d41aed2..43be3d5 100644
--- a/core/core-ktx/src/main/java/androidx/core/text/CharSequence.kt
+++ b/core/core-ktx/src/main/java/androidx/core/text/CharSequence.kt
@@ -25,7 +25,7 @@
*
* @see TextUtils.isDigitsOnly
*/
-inline fun CharSequence.isDigitsOnly() = TextUtils.isDigitsOnly(this)
+public inline fun CharSequence.isDigitsOnly(): Boolean = TextUtils.isDigitsOnly(this)
/**
* Returns the length that the specified [CharSequence] would have if spaces and ASCII control
@@ -33,4 +33,4 @@
*
* @see TextUtils.getTrimmedLength
*/
-inline fun CharSequence.trimmedLength() = TextUtils.getTrimmedLength(this)
+public inline fun CharSequence.trimmedLength(): Int = TextUtils.getTrimmedLength(this)
diff --git a/core/core-ktx/src/main/java/androidx/core/text/Html.kt b/core/core-ktx/src/main/java/androidx/core/text/Html.kt
index 6aa3940..adb0017 100644
--- a/core/core-ktx/src/main/java/androidx/core/text/Html.kt
+++ b/core/core-ktx/src/main/java/androidx/core/text/Html.kt
@@ -36,7 +36,7 @@
*
* @see Html.fromHtml
*/
-inline fun String.parseAsHtml(
+public inline fun String.parseAsHtml(
flags: Int = FROM_HTML_MODE_LEGACY,
imageGetter: ImageGetter? = null,
tagHandler: TagHandler? = null
@@ -47,6 +47,6 @@
*
* @see Html.toHtml
*/
-inline fun Spanned.toHtml(
+public inline fun Spanned.toHtml(
option: Int = TO_HTML_PARAGRAPH_LINES_CONSECUTIVE
): String = HtmlCompat.toHtml(this, option)
diff --git a/core/core-ktx/src/main/java/androidx/core/text/Locale.kt b/core/core-ktx/src/main/java/androidx/core/text/Locale.kt
index d1f3fc9..e67d513 100644
--- a/core/core-ktx/src/main/java/androidx/core/text/Locale.kt
+++ b/core/core-ktx/src/main/java/androidx/core/text/Locale.kt
@@ -25,6 +25,6 @@
*
* @see TextUtils.getLayoutDirectionFromLocale
*/
-inline val Locale.layoutDirection: Int
+public inline val Locale.layoutDirection: Int
@RequiresApi(17)
get() = TextUtils.getLayoutDirectionFromLocale(this)
diff --git a/core/core-ktx/src/main/java/androidx/core/text/SpannableString.kt b/core/core-ktx/src/main/java/androidx/core/text/SpannableString.kt
index 745dbf1..df53a46 100644
--- a/core/core-ktx/src/main/java/androidx/core/text/SpannableString.kt
+++ b/core/core-ktx/src/main/java/androidx/core/text/SpannableString.kt
@@ -27,11 +27,11 @@
* Returns a new [Spannable] from [CharSequence],
* or the source itself if it is already an instance of [SpannableString].
*/
-inline fun CharSequence.toSpannable(): Spannable = SpannableString.valueOf(this)
+public inline fun CharSequence.toSpannable(): Spannable = SpannableString.valueOf(this)
/** Clear all spans from this text. */
@SuppressLint("SyntheticAccessor") // TODO remove https://issuetracker.google.com/issues/110243369
-inline fun Spannable.clearSpans() = getSpans<Any>().forEach { removeSpan(it) }
+public inline fun Spannable.clearSpans(): Unit = getSpans<Any>().forEach { removeSpan(it) }
/**
* Add [span] to the range [start]…[end] of the text.
@@ -45,7 +45,7 @@
*
* @see Spannable.setSpan
*/
-inline operator fun Spannable.set(start: Int, end: Int, span: Any) {
+public inline operator fun Spannable.set(start: Int, end: Int, span: Any) {
setSpan(span, start, end, SPAN_INCLUSIVE_EXCLUSIVE)
}
@@ -61,7 +61,7 @@
*
* @see Spannable.setSpan
*/
-inline operator fun Spannable.set(range: IntRange, span: Any) {
+public inline operator fun Spannable.set(range: IntRange, span: Any) {
// This looks weird, but endInclusive is just the exact upper value.
setSpan(span, range.start, range.endInclusive, SPAN_INCLUSIVE_EXCLUSIVE)
}
diff --git a/core/core-ktx/src/main/java/androidx/core/text/SpannableStringBuilder.kt b/core/core-ktx/src/main/java/androidx/core/text/SpannableStringBuilder.kt
index e49ccd2..ac4a890 100644
--- a/core/core-ktx/src/main/java/androidx/core/text/SpannableStringBuilder.kt
+++ b/core/core-ktx/src/main/java/androidx/core/text/SpannableStringBuilder.kt
@@ -35,7 +35,9 @@
* Builds new string by populating a newly created [SpannableStringBuilder] using the provided
* [builderAction] and then converting it to [SpannedString].
*/
-inline fun buildSpannedString(builderAction: SpannableStringBuilder.() -> Unit): SpannedString {
+public inline fun buildSpannedString(
+ builderAction: SpannableStringBuilder.() -> Unit
+): SpannedString {
val builder = SpannableStringBuilder()
builder.builderAction()
return SpannedString(builder)
@@ -48,7 +50,7 @@
* replaces text. Inserting, deleting, or clearing the text will cause the span to be placed at
* an incorrect position.
*/
-inline fun SpannableStringBuilder.inSpans(
+public inline fun SpannableStringBuilder.inSpans(
vararg spans: Any,
builderAction: SpannableStringBuilder.() -> Unit
): SpannableStringBuilder {
@@ -65,7 +67,7 @@
* replaces text. Inserting, deleting, or clearing the text will cause the span to be placed at
* an incorrect position.
*/
-inline fun SpannableStringBuilder.inSpans(
+public inline fun SpannableStringBuilder.inSpans(
span: Any,
builderAction: SpannableStringBuilder.() -> Unit
): SpannableStringBuilder {
@@ -80,75 +82,81 @@
*
* @see SpannableStringBuilder.inSpans
*/
-inline fun SpannableStringBuilder.bold(builderAction: SpannableStringBuilder.() -> Unit) =
- inSpans(StyleSpan(BOLD), builderAction = builderAction)
+public inline fun SpannableStringBuilder.bold(
+ builderAction: SpannableStringBuilder.() -> Unit
+): SpannableStringBuilder = inSpans(StyleSpan(BOLD), builderAction = builderAction)
/**
* Wrap appended text in [builderAction] in an italic [StyleSpan].
*
* @see SpannableStringBuilder.inSpans
*/
-inline fun SpannableStringBuilder.italic(builderAction: SpannableStringBuilder.() -> Unit) =
- inSpans(StyleSpan(ITALIC), builderAction = builderAction)
+public inline fun SpannableStringBuilder.italic(
+ builderAction: SpannableStringBuilder.() -> Unit
+): SpannableStringBuilder = inSpans(StyleSpan(ITALIC), builderAction = builderAction)
/**
* Wrap appended text in [builderAction] in an [UnderlineSpan].
*
* @see SpannableStringBuilder.inSpans
*/
-inline fun SpannableStringBuilder.underline(builderAction: SpannableStringBuilder.() -> Unit) =
- inSpans(UnderlineSpan(), builderAction = builderAction)
+public inline fun SpannableStringBuilder.underline(
+ builderAction: SpannableStringBuilder.() -> Unit
+): SpannableStringBuilder = inSpans(UnderlineSpan(), builderAction = builderAction)
/**
* Wrap appended text in [builderAction] in a [ForegroundColorSpan].
*
* @see SpannableStringBuilder.inSpans
*/
-inline fun SpannableStringBuilder.color(
+public inline fun SpannableStringBuilder.color(
@ColorInt color: Int,
builderAction: SpannableStringBuilder.() -> Unit
-) = inSpans(ForegroundColorSpan(color), builderAction = builderAction)
+): SpannableStringBuilder = inSpans(ForegroundColorSpan(color), builderAction = builderAction)
/**
* Wrap appended text in [builderAction] in a [BackgroundColorSpan].
*
* @see SpannableStringBuilder.inSpans
*/
-inline fun SpannableStringBuilder.backgroundColor(
+public inline fun SpannableStringBuilder.backgroundColor(
@ColorInt color: Int,
builderAction: SpannableStringBuilder.() -> Unit
-) = inSpans(BackgroundColorSpan(color), builderAction = builderAction)
+): SpannableStringBuilder = inSpans(BackgroundColorSpan(color), builderAction = builderAction)
/**
* Wrap appended text in [builderAction] in a [StrikethroughSpan].
*
* @see SpannableStringBuilder.inSpans
*/
-inline fun SpannableStringBuilder.strikeThrough(builderAction: SpannableStringBuilder.() -> Unit) =
- inSpans(StrikethroughSpan(), builderAction = builderAction)
+public inline fun SpannableStringBuilder.strikeThrough(
+ builderAction: SpannableStringBuilder.() -> Unit
+): SpannableStringBuilder = inSpans(StrikethroughSpan(), builderAction = builderAction)
/**
* Wrap appended text in [builderAction] in a [RelativeSizeSpan].
*
* @see SpannableStringBuilder.inSpans
*/
-inline fun SpannableStringBuilder.scale(
+public inline fun SpannableStringBuilder.scale(
proportion: Float,
builderAction: SpannableStringBuilder.() -> Unit
-) = inSpans(RelativeSizeSpan(proportion), builderAction = builderAction)
+): SpannableStringBuilder = inSpans(RelativeSizeSpan(proportion), builderAction = builderAction)
/**
* Wrap appended text in [builderAction] in a [SuperscriptSpan].
*
* @see SpannableStringBuilder.inSpans
*/
-inline fun SpannableStringBuilder.superscript(builderAction: SpannableStringBuilder.() -> Unit) =
- inSpans(SuperscriptSpan(), builderAction = builderAction)
+public inline fun SpannableStringBuilder.superscript(
+ builderAction: SpannableStringBuilder.() -> Unit
+): SpannableStringBuilder = inSpans(SuperscriptSpan(), builderAction = builderAction)
/**
* Wrap appended text in [builderAction] in a [SubscriptSpan].
*
* @see SpannableStringBuilder.inSpans
*/
-inline fun SpannableStringBuilder.subscript(builderAction: SpannableStringBuilder.() -> Unit) =
- inSpans(SubscriptSpan(), builderAction = builderAction)
+public inline fun SpannableStringBuilder.subscript(
+ builderAction: SpannableStringBuilder.() -> Unit
+): SpannableStringBuilder = inSpans(SubscriptSpan(), builderAction = builderAction)
diff --git a/core/core-ktx/src/main/java/androidx/core/text/SpannedString.kt b/core/core-ktx/src/main/java/androidx/core/text/SpannedString.kt
index db27511..5879d14 100644
--- a/core/core-ktx/src/main/java/androidx/core/text/SpannedString.kt
+++ b/core/core-ktx/src/main/java/androidx/core/text/SpannedString.kt
@@ -25,8 +25,10 @@
* Returns a new [Spanned] from [CharSequence],
* or the source itself if it is already an instance of [SpannedString].
*/
-inline fun CharSequence.toSpanned(): Spanned = SpannedString.valueOf(this)
+public inline fun CharSequence.toSpanned(): Spanned = SpannedString.valueOf(this)
/** Get all spans that are instance of [T]. */
-inline fun <reified T : Any> Spanned.getSpans(start: Int = 0, end: Int = length): Array<out T> =
- getSpans(start, end, T::class.java)
+public inline fun <reified T : Any> Spanned.getSpans(
+ start: Int = 0,
+ end: Int = length
+): Array<out T> = getSpans(start, end, T::class.java)
diff --git a/core/core-ktx/src/main/java/androidx/core/text/String.kt b/core/core-ktx/src/main/java/androidx/core/text/String.kt
index 8bffdd0..bb731e6 100644
--- a/core/core-ktx/src/main/java/androidx/core/text/String.kt
+++ b/core/core-ktx/src/main/java/androidx/core/text/String.kt
@@ -25,4 +25,4 @@
*
* @see TextUtils.htmlEncode
*/
-inline fun String.htmlEncode(): String = TextUtils.htmlEncode(this)
+public inline fun String.htmlEncode(): String = TextUtils.htmlEncode(this)
diff --git a/core/core-ktx/src/main/java/androidx/core/transition/Transition.kt b/core/core-ktx/src/main/java/androidx/core/transition/Transition.kt
index ee8d269..604f0f1 100644
--- a/core/core-ktx/src/main/java/androidx/core/transition/Transition.kt
+++ b/core/core-ktx/src/main/java/androidx/core/transition/Transition.kt
@@ -23,42 +23,47 @@
* Add an action which will be invoked when this transition has ended.
*/
@RequiresApi(19)
-inline fun Transition.doOnEnd(crossinline action: (transition: Transition) -> Unit) =
- addListener(onEnd = action)
+public inline fun Transition.doOnEnd(
+ crossinline action: (transition: Transition) -> Unit
+): Transition.TransitionListener = addListener(onEnd = action)
/**
* Add an action which will be invoked when this transition has started.
*/
@RequiresApi(19)
-inline fun Transition.doOnStart(crossinline action: (transition: Transition) -> Unit) =
- addListener(onStart = action)
+public inline fun Transition.doOnStart(
+ crossinline action: (transition: Transition) -> Unit
+): Transition.TransitionListener = addListener(onStart = action)
/**
* Add an action which will be invoked when this transition has been cancelled.
*/
@RequiresApi(19)
-inline fun Transition.doOnCancel(crossinline action: (transition: Transition) -> Unit) =
- addListener(onCancel = action)
+public inline fun Transition.doOnCancel(
+ crossinline action: (transition: Transition) -> Unit
+): Transition.TransitionListener = addListener(onCancel = action)
/**
* Add an action which will be invoked when this transition has resumed after a pause.
*/
@RequiresApi(19)
-inline fun Transition.doOnResume(crossinline action: (transition: Transition) -> Unit) =
- addListener(onResume = action)
+public inline fun Transition.doOnResume(
+ crossinline action: (transition: Transition) -> Unit
+): Transition.TransitionListener = addListener(onResume = action)
/**
* Add an action which will be invoked when this transition has been paused.
*/
@RequiresApi(19)
-inline fun Transition.doOnPause(crossinline action: (transition: Transition) -> Unit) =
- addListener(onPause = action)
+public inline fun Transition.doOnPause(
+ crossinline action: (transition: Transition) -> Unit
+): Transition.TransitionListener = addListener(onPause = action)
/**
* Add a listener to this Transition using the provided actions.
*/
@RequiresApi(19)
-inline fun Transition.addListener(
+public inline fun Transition.addListener(
crossinline onEnd: (transition: Transition) -> Unit = {},
crossinline onStart: (transition: Transition) -> Unit = {},
crossinline onCancel: (transition: Transition) -> Unit = {},
diff --git a/core/core-ktx/src/main/java/androidx/core/util/AtomicFile.kt b/core/core-ktx/src/main/java/androidx/core/util/AtomicFile.kt
index b8fbba7..89e26e8 100644
--- a/core/core-ktx/src/main/java/androidx/core/util/AtomicFile.kt
+++ b/core/core-ktx/src/main/java/androidx/core/util/AtomicFile.kt
@@ -28,7 +28,7 @@
* write will be failed. Otherwise the write will be applied atomically to the file.
*/
@RequiresApi(17)
-inline fun AtomicFile.tryWrite(block: (out: FileOutputStream) -> Unit) {
+public inline fun AtomicFile.tryWrite(block: (out: FileOutputStream) -> Unit) {
val stream = startWrite()
var success = false
try {
@@ -47,7 +47,7 @@
* Sets the content of this file as an [array] of bytes.
*/
@RequiresApi(17)
-fun AtomicFile.writeBytes(array: ByteArray) {
+public fun AtomicFile.writeBytes(array: ByteArray) {
tryWrite {
it.write(array)
}
@@ -58,7 +58,7 @@
* If this file exists, it becomes overwritten.
*/
@RequiresApi(17)
-fun AtomicFile.writeText(text: String, charset: Charset = Charsets.UTF_8) {
+public fun AtomicFile.writeText(text: String, charset: Charset = Charsets.UTF_8) {
writeBytes(text.toByteArray(charset))
}
@@ -68,7 +68,7 @@
* This method is not recommended on huge files. It has an internal limitation of 2 GB file size.
*/
@RequiresApi(17)
-inline fun AtomicFile.readBytes(): ByteArray = readFully()
+public inline fun AtomicFile.readBytes(): ByteArray = readFully()
/**
* Gets the entire content of this file as a String using UTF-8 or specified [charset].
@@ -76,6 +76,6 @@
* This method is not recommended on huge files. It has an internal limitation of 2 GB file size.
*/
@RequiresApi(17)
-fun AtomicFile.readText(charset: Charset = Charsets.UTF_8): String {
+public fun AtomicFile.readText(charset: Charset = Charsets.UTF_8): String {
return readFully().toString(charset)
}
diff --git a/core/core-ktx/src/main/java/androidx/core/util/Half.kt b/core/core-ktx/src/main/java/androidx/core/util/Half.kt
index 409c01e..8a335f9 100644
--- a/core/core-ktx/src/main/java/androidx/core/util/Half.kt
+++ b/core/core-ktx/src/main/java/androidx/core/util/Half.kt
@@ -30,7 +30,7 @@
// TODO https://youtrack.jetbrains.com/issue/KT-21696
@Suppress("WRONG_ANNOTATION_TARGET_WITH_USE_SITE_TARGET_ON_TYPE")
@RequiresApi(26)
-inline fun @receiver:HalfFloat Short.toHalf(): Half = Half.valueOf(this)
+public inline fun @receiver:HalfFloat Short.toHalf(): Half = Half.valueOf(this)
/**
* Returns a [Half] instance representing given [Float].
@@ -38,7 +38,7 @@
* @see Half.valueOf
*/
@RequiresApi(26)
-inline fun Float.toHalf(): Half = Half.valueOf(this)
+public inline fun Float.toHalf(): Half = Half.valueOf(this)
/**
* Returns a [Half] instance representing given [Double].
@@ -46,7 +46,7 @@
* @see Half.valueOf
*/
@RequiresApi(26)
-inline fun Double.toHalf(): Half = toFloat().toHalf()
+public inline fun Double.toHalf(): Half = toFloat().toHalf()
/**
* Returns a [Half] instance representing given [String].
@@ -54,4 +54,4 @@
* @see Half.valueOf
*/
@RequiresApi(26)
-inline fun String.toHalf(): Half = Half.valueOf(this)
+public inline fun String.toHalf(): Half = Half.valueOf(this)
diff --git a/core/core-ktx/src/main/java/androidx/core/util/LongSparseArray.kt b/core/core-ktx/src/main/java/androidx/core/util/LongSparseArray.kt
index 3fe3e7f..accebab 100644
--- a/core/core-ktx/src/main/java/androidx/core/util/LongSparseArray.kt
+++ b/core/core-ktx/src/main/java/androidx/core/util/LongSparseArray.kt
@@ -23,19 +23,20 @@
/** Returns the number of key/value pairs in the collection. */
@get:RequiresApi(16)
-inline val <T> LongSparseArray<T>.size get() = size()
+public inline val <T> LongSparseArray<T>.size: Int get() = size()
/** Returns true if the collection contains [key]. */
@RequiresApi(16)
-inline operator fun <T> LongSparseArray<T>.contains(key: Long) = indexOfKey(key) >= 0
+public inline operator fun <T> LongSparseArray<T>.contains(key: Long): Boolean =
+ indexOfKey(key) >= 0
/** Allows the use of the index operator for storing values in the collection. */
@RequiresApi(16)
-inline operator fun <T> LongSparseArray<T>.set(key: Long, value: T) = put(key, value)
+public inline operator fun <T> LongSparseArray<T>.set(key: Long, value: T): Unit = put(key, value)
/** Creates a new collection by adding or replacing entries from [other]. */
@RequiresApi(16)
-operator fun <T> LongSparseArray<T>.plus(other: LongSparseArray<T>): LongSparseArray<T> {
+public operator fun <T> LongSparseArray<T>.plus(other: LongSparseArray<T>): LongSparseArray<T> {
val new = LongSparseArray<T>(size() + other.size())
new.putAll(this)
new.putAll(other)
@@ -44,33 +45,34 @@
/** Returns true if the collection contains [key]. */
@RequiresApi(16)
-inline fun <T> LongSparseArray<T>.containsKey(key: Long) = indexOfKey(key) >= 0
+public inline fun <T> LongSparseArray<T>.containsKey(key: Long): Boolean = indexOfKey(key) >= 0
/** Returns true if the collection contains [value]. */
@RequiresApi(16)
-inline fun <T> LongSparseArray<T>.containsValue(value: T) = indexOfValue(value) >= 0
+public inline fun <T> LongSparseArray<T>.containsValue(value: T): Boolean =
+ indexOfValue(value) >= 0
/** Return the value corresponding to [key], or [defaultValue] when not present. */
@RequiresApi(16)
-inline fun <T> LongSparseArray<T>.getOrDefault(key: Long, defaultValue: T) =
+public inline fun <T> LongSparseArray<T>.getOrDefault(key: Long, defaultValue: T): T =
get(key) ?: defaultValue
/** Return the value corresponding to [key], or from [defaultValue] when not present. */
@RequiresApi(16)
-inline fun <T> LongSparseArray<T>.getOrElse(key: Long, defaultValue: () -> T) =
+public inline fun <T> LongSparseArray<T>.getOrElse(key: Long, defaultValue: () -> T): T =
get(key) ?: defaultValue()
/** Return true when the collection contains no elements. */
@RequiresApi(16)
-inline fun <T> LongSparseArray<T>.isEmpty() = size() == 0
+public inline fun <T> LongSparseArray<T>.isEmpty(): Boolean = size() == 0
/** Return true when the collection contains elements. */
@RequiresApi(16)
-inline fun <T> LongSparseArray<T>.isNotEmpty() = size() != 0
+public inline fun <T> LongSparseArray<T>.isNotEmpty(): Boolean = size() != 0
/** Removes the entry for [key] only if it is mapped to [value]. */
@RequiresApi(16)
-fun <T> LongSparseArray<T>.remove(key: Long, value: T): Boolean {
+public fun <T> LongSparseArray<T>.remove(key: Long, value: T): Boolean {
val index = indexOfKey(key)
if (index >= 0 && value == valueAt(index)) {
removeAt(index)
@@ -81,11 +83,11 @@
/** Update this collection by adding or replacing entries from [other]. */
@RequiresApi(16)
-fun <T> LongSparseArray<T>.putAll(other: LongSparseArray<T>) = other.forEach(::put)
+public fun <T> LongSparseArray<T>.putAll(other: LongSparseArray<T>): Unit = other.forEach(::put)
/** Performs the given [action] for each key/value entry. */
@RequiresApi(16)
-inline fun <T> LongSparseArray<T>.forEach(action: (key: Long, value: T) -> Unit) {
+public inline fun <T> LongSparseArray<T>.forEach(action: (key: Long, value: T) -> Unit) {
for (index in 0 until size()) {
action(keyAt(index), valueAt(index))
}
@@ -93,7 +95,7 @@
/** Return an iterator over the collection's keys. */
@RequiresApi(16)
-fun <T> LongSparseArray<T>.keyIterator(): LongIterator = object : LongIterator() {
+public fun <T> LongSparseArray<T>.keyIterator(): LongIterator = object : LongIterator() {
var index = 0
override fun hasNext() = index < size()
override fun nextLong() = keyAt(index++)
@@ -101,7 +103,7 @@
/** Return an iterator over the collection's values. */
@RequiresApi(16)
-fun <T> LongSparseArray<T>.valueIterator(): Iterator<T> = object : Iterator<T> {
+public fun <T> LongSparseArray<T>.valueIterator(): Iterator<T> = object : Iterator<T> {
var index = 0
override fun hasNext() = index < size()
override fun next() = valueAt(index++)
diff --git a/core/core-ktx/src/main/java/androidx/core/util/LruCache.kt b/core/core-ktx/src/main/java/androidx/core/util/LruCache.kt
index 44c2f8d..818b032 100644
--- a/core/core-ktx/src/main/java/androidx/core/util/LruCache.kt
+++ b/core/core-ktx/src/main/java/androidx/core/util/LruCache.kt
@@ -35,7 +35,7 @@
* @see LruCache.create
* @see LruCache.entryRemoved
*/
-inline fun <K : Any, V : Any> lruCache(
+public inline fun <K : Any, V : Any> lruCache(
maxSize: Int,
crossinline sizeOf: (key: K, value: V) -> Int = { _, _ -> 1 },
@Suppress("USELESS_CAST") // https://youtrack.jetbrains.com/issue/KT-21946
diff --git a/core/core-ktx/src/main/java/androidx/core/util/Pair.kt b/core/core-ktx/src/main/java/androidx/core/util/Pair.kt
index be0d1ec..f3dac47 100644
--- a/core/core-ktx/src/main/java/androidx/core/util/Pair.kt
+++ b/core/core-ktx/src/main/java/androidx/core/util/Pair.kt
@@ -32,7 +32,7 @@
*/
@SuppressLint("UnknownNullness")
@Suppress("HasPlatformType") // Intentionally propagating platform type with unknown nullability.
-inline operator fun <F, S> Pair<F, S>.component1() = first
+public inline operator fun <F, S> Pair<F, S>.component1(): F = first
/**
* Returns the second component of the pair.
@@ -44,14 +44,14 @@
*/
@SuppressLint("UnknownNullness")
@Suppress("HasPlatformType") // Intentionally propagating platform type with unknown nullability.
-inline operator fun <F, S> Pair<F, S>.component2() = second
+public inline operator fun <F, S> Pair<F, S>.component2(): S = second
/** Returns this [AndroidX `Pair`][Pair] as a [Kotlin `Pair`][KotlinPair]. */
-inline fun <F, S> Pair<F, S>.toKotlinPair() = KotlinPair(first, second)
+public inline fun <F, S> Pair<F, S>.toKotlinPair(): kotlin.Pair<F, S> = KotlinPair(first, second)
/** Returns this [Kotlin `Pair`][KotlinPair] as an [AndroidX `Pair`][Pair]. */
// Note: the return type is explicitly specified here to prevent always seeing platform types.
-inline fun <F, S> KotlinPair<F, S>.toAndroidXPair(): Pair<F, S> = Pair(first, second)
+public inline fun <F, S> KotlinPair<F, S>.toAndroidXPair(): Pair<F, S> = Pair(first, second)
/**
* Returns the first component of the pair.
@@ -63,7 +63,7 @@
*/
@SuppressLint("UnknownNullness")
@Suppress("HasPlatformType") // Intentionally propagating platform type with unknown nullability.
-inline operator fun <F, S> AndroidPair<F, S>.component1() = first
+public inline operator fun <F, S> AndroidPair<F, S>.component1(): F = first
/**
* Returns the second component of the pair.
@@ -75,11 +75,13 @@
*/
@SuppressLint("UnknownNullness")
@Suppress("HasPlatformType") // Intentionally propagating platform type with unknown nullability.
-inline operator fun <F, S> AndroidPair<F, S>.component2() = second
+public inline operator fun <F, S> AndroidPair<F, S>.component2(): S = second
/** Returns this [Android `Pair`][AndroidPair] as a [Kotlin `Pair`][KotlinPair]. */
-inline fun <F, S> AndroidPair<F, S>.toKotlinPair() = KotlinPair(first, second)
+public inline fun <F, S> AndroidPair<F, S>.toKotlinPair(): kotlin.Pair<F, S> =
+ KotlinPair(first, second)
/** Returns this [Kotlin `Pair`][KotlinPair] as an [Android `Pair`][AndroidPair]. */
// Note: the return type is explicitly specified here to prevent always seeing platform types.
-inline fun <F, S> KotlinPair<F, S>.toAndroidPair(): AndroidPair<F, S> = AndroidPair(first, second)
+public inline fun <F, S> KotlinPair<F, S>.toAndroidPair(): AndroidPair<F, S> =
+ AndroidPair(first, second)
diff --git a/core/core-ktx/src/main/java/androidx/core/util/Range.kt b/core/core-ktx/src/main/java/androidx/core/util/Range.kt
index b5f7eb6..48a82232 100644
--- a/core/core-ktx/src/main/java/androidx/core/util/Range.kt
+++ b/core/core-ktx/src/main/java/androidx/core/util/Range.kt
@@ -27,15 +27,16 @@
* @throws IllegalArgumentException if this value is comparatively smaller than [that].
*/
@RequiresApi(21)
-inline infix fun <T : Comparable<T>> T.rangeTo(that: T): Range<T> = Range(this, that)
+public inline infix fun <T : Comparable<T>> T.rangeTo(that: T): Range<T> = Range(this, that)
/** Return the smallest range that includes this and [value]. */
@RequiresApi(21)
-inline operator fun <T : Comparable<T>> Range<T>.plus(value: T): Range<T> = extend(value)
+public inline operator fun <T : Comparable<T>> Range<T>.plus(value: T): Range<T> = extend(value)
/** Return the smallest range that includes this and [other]. */
@RequiresApi(21)
-inline operator fun <T : Comparable<T>> Range<T>.plus(other: Range<T>): Range<T> = extend(other)
+public inline operator fun <T : Comparable<T>> Range<T>.plus(other: Range<T>): Range<T> =
+ extend(other)
/**
* Return the intersection of this range and [other].
@@ -43,15 +44,16 @@
* @throws IllegalArgumentException if this is disjoint from [other].
*/
@RequiresApi(21)
-inline infix fun <T : Comparable<T>> Range<T>.and(other: Range<T>): Range<T> = intersect(other)
+public inline infix fun <T : Comparable<T>> Range<T>.and(other: Range<T>): Range<T> =
+ intersect(other)
/** Returns this [Range] as a [ClosedRange]. */
@RequiresApi(21)
-fun <T : Comparable<T>> Range<T>.toClosedRange(): ClosedRange<T> = object : ClosedRange<T> {
+public fun <T : Comparable<T>> Range<T>.toClosedRange(): ClosedRange<T> = object : ClosedRange<T> {
override val endInclusive get() = upper
override val start get() = lower
}
/** Returns this [ClosedRange] as a [Range]. */
@RequiresApi(21)
-fun <T : Comparable<T>> ClosedRange<T>.toRange(): Range<T> = Range(start, endInclusive)
+public fun <T : Comparable<T>> ClosedRange<T>.toRange(): Range<T> = Range(start, endInclusive)
diff --git a/core/core-ktx/src/main/java/androidx/core/util/Size.kt b/core/core-ktx/src/main/java/androidx/core/util/Size.kt
index 34f68546..ed149a5 100644
--- a/core/core-ktx/src/main/java/androidx/core/util/Size.kt
+++ b/core/core-ktx/src/main/java/androidx/core/util/Size.kt
@@ -32,7 +32,7 @@
* ```
*/
@RequiresApi(21)
-inline operator fun Size.component1() = width
+public inline operator fun Size.component1(): Int = width
/**
* Returns "height", the second component of this [Size].
@@ -44,7 +44,7 @@
* ```
*/
@RequiresApi(21)
-inline operator fun Size.component2() = height
+public inline operator fun Size.component2(): Int = height
/**
* Returns "width", the first component of this [SizeF].
@@ -56,7 +56,7 @@
* ```
*/
@RequiresApi(21)
-inline operator fun SizeF.component1() = width
+public inline operator fun SizeF.component1(): Float = width
/**
* Returns "height", the second component of this [SizeF].
@@ -68,4 +68,4 @@
* ```
*/
@RequiresApi(21)
-inline operator fun SizeF.component2() = height
+public inline operator fun SizeF.component2(): Float = height
diff --git a/core/core-ktx/src/main/java/androidx/core/util/SparseArray.kt b/core/core-ktx/src/main/java/androidx/core/util/SparseArray.kt
index f379be8..f2f373e 100644
--- a/core/core-ktx/src/main/java/androidx/core/util/SparseArray.kt
+++ b/core/core-ktx/src/main/java/androidx/core/util/SparseArray.kt
@@ -21,17 +21,17 @@
import android.util.SparseArray
/** Returns the number of key/value pairs in the collection. */
-inline val <T> SparseArray<T>.size get() = size()
+public inline val <T> SparseArray<T>.size: Int get() = size()
/** Returns true if the collection contains [key]. */
@Suppress("EXTENSION_SHADOWED_BY_MEMBER") /* contains() added in R */
-inline operator fun <T> SparseArray<T>.contains(key: Int) = indexOfKey(key) >= 0
+public inline operator fun <T> SparseArray<T>.contains(key: Int): Boolean = indexOfKey(key) >= 0
/** Allows the use of the index operator for storing values in the collection. */
-inline operator fun <T> SparseArray<T>.set(key: Int, value: T) = put(key, value)
+public inline operator fun <T> SparseArray<T>.set(key: Int, value: T): Unit = put(key, value)
/** Creates a new collection by adding or replacing entries from [other]. */
-operator fun <T> SparseArray<T>.plus(other: SparseArray<T>): SparseArray<T> {
+public operator fun <T> SparseArray<T>.plus(other: SparseArray<T>): SparseArray<T> {
val new = SparseArray<T>(size() + other.size())
new.putAll(this)
new.putAll(other)
@@ -39,26 +39,27 @@
}
/** Returns true if the collection contains [key]. */
-inline fun <T> SparseArray<T>.containsKey(key: Int) = indexOfKey(key) >= 0
+public inline fun <T> SparseArray<T>.containsKey(key: Int): Boolean = indexOfKey(key) >= 0
/** Returns true if the collection contains [value]. */
-inline fun <T> SparseArray<T>.containsValue(value: T) = indexOfValue(value) >= 0
+public inline fun <T> SparseArray<T>.containsValue(value: T): Boolean = indexOfValue(value) >= 0
/** Return the value corresponding to [key], or [defaultValue] when not present. */
-inline fun <T> SparseArray<T>.getOrDefault(key: Int, defaultValue: T) = get(key) ?: defaultValue
+public inline fun <T> SparseArray<T>.getOrDefault(key: Int, defaultValue: T): T =
+ get(key) ?: defaultValue
/** Return the value corresponding to [key], or from [defaultValue] when not present. */
-inline fun <T> SparseArray<T>.getOrElse(key: Int, defaultValue: () -> T) =
+public inline fun <T> SparseArray<T>.getOrElse(key: Int, defaultValue: () -> T): T =
get(key) ?: defaultValue()
/** Return true when the collection contains no elements. */
-inline fun <T> SparseArray<T>.isEmpty() = size() == 0
+public inline fun <T> SparseArray<T>.isEmpty(): Boolean = size() == 0
/** Return true when the collection contains elements. */
-inline fun <T> SparseArray<T>.isNotEmpty() = size() != 0
+public inline fun <T> SparseArray<T>.isNotEmpty(): Boolean = size() != 0
/** Removes the entry for [key] only if it is mapped to [value]. */
-fun <T> SparseArray<T>.remove(key: Int, value: T): Boolean {
+public fun <T> SparseArray<T>.remove(key: Int, value: T): Boolean {
val index = indexOfKey(key)
if (index >= 0 && value == valueAt(index)) {
removeAt(index)
@@ -68,24 +69,24 @@
}
/** Update this collection by adding or replacing entries from [other]. */
-fun <T> SparseArray<T>.putAll(other: SparseArray<T>) = other.forEach(::put)
+public fun <T> SparseArray<T>.putAll(other: SparseArray<T>): Unit = other.forEach(::put)
/** Performs the given [action] for each key/value entry. */
-inline fun <T> SparseArray<T>.forEach(action: (key: Int, value: T) -> Unit) {
+public inline fun <T> SparseArray<T>.forEach(action: (key: Int, value: T) -> Unit) {
for (index in 0 until size()) {
action(keyAt(index), valueAt(index))
}
}
/** Return an iterator over the collection's keys. */
-fun <T> SparseArray<T>.keyIterator(): IntIterator = object : IntIterator() {
+public fun <T> SparseArray<T>.keyIterator(): IntIterator = object : IntIterator() {
var index = 0
override fun hasNext() = index < size()
override fun nextInt() = keyAt(index++)
}
/** Return an iterator over the collection's values. */
-fun <T> SparseArray<T>.valueIterator(): Iterator<T> = object : Iterator<T> {
+public fun <T> SparseArray<T>.valueIterator(): Iterator<T> = object : Iterator<T> {
var index = 0
override fun hasNext() = index < size()
override fun next() = valueAt(index++)
diff --git a/core/core-ktx/src/main/java/androidx/core/util/SparseBooleanArray.kt b/core/core-ktx/src/main/java/androidx/core/util/SparseBooleanArray.kt
index 184dd42..94386d9 100644
--- a/core/core-ktx/src/main/java/androidx/core/util/SparseBooleanArray.kt
+++ b/core/core-ktx/src/main/java/androidx/core/util/SparseBooleanArray.kt
@@ -21,16 +21,16 @@
import android.util.SparseBooleanArray
/** Returns the number of key/value pairs in the collection. */
-inline val SparseBooleanArray.size get() = size()
+public inline val SparseBooleanArray.size: Int get() = size()
/** Returns true if the collection contains [key]. */
-inline operator fun SparseBooleanArray.contains(key: Int) = indexOfKey(key) >= 0
+public inline operator fun SparseBooleanArray.contains(key: Int): Boolean = indexOfKey(key) >= 0
/** Allows the use of the index operator for storing values in the collection. */
-inline operator fun SparseBooleanArray.set(key: Int, value: Boolean) = put(key, value)
+public inline operator fun SparseBooleanArray.set(key: Int, value: Boolean): Unit = put(key, value)
/** Creates a new collection by adding or replacing entries from [other]. */
-operator fun SparseBooleanArray.plus(other: SparseBooleanArray): SparseBooleanArray {
+public operator fun SparseBooleanArray.plus(other: SparseBooleanArray): SparseBooleanArray {
val new = SparseBooleanArray(size() + other.size())
new.putAll(this)
new.putAll(other)
@@ -38,26 +38,28 @@
}
/** Returns true if the collection contains [key]. */
-inline fun SparseBooleanArray.containsKey(key: Int) = indexOfKey(key) >= 0
+public inline fun SparseBooleanArray.containsKey(key: Int): Boolean = indexOfKey(key) >= 0
/** Returns true if the collection contains [value]. */
-inline fun SparseBooleanArray.containsValue(value: Boolean) = indexOfValue(value) >= 0
+public inline fun SparseBooleanArray.containsValue(value: Boolean): Boolean =
+ indexOfValue(value) >= 0
/** Return the value corresponding to [key], or [defaultValue] when not present. */
-inline fun SparseBooleanArray.getOrDefault(key: Int, defaultValue: Boolean) = get(key, defaultValue)
+public inline fun SparseBooleanArray.getOrDefault(key: Int, defaultValue: Boolean): Boolean =
+ get(key, defaultValue)
/** Return the value corresponding to [key], or from [defaultValue] when not present. */
-inline fun SparseBooleanArray.getOrElse(key: Int, defaultValue: () -> Boolean) =
+public inline fun SparseBooleanArray.getOrElse(key: Int, defaultValue: () -> Boolean): Boolean =
indexOfKey(key).let { if (it >= 0) valueAt(it) else defaultValue() }
/** Return true when the collection contains no elements. */
-inline fun SparseBooleanArray.isEmpty() = size() == 0
+public inline fun SparseBooleanArray.isEmpty(): Boolean = size() == 0
/** Return true when the collection contains elements. */
-inline fun SparseBooleanArray.isNotEmpty() = size() != 0
+public inline fun SparseBooleanArray.isNotEmpty(): Boolean = size() != 0
/** Removes the entry for [key] only if it is mapped to [value]. */
-fun SparseBooleanArray.remove(key: Int, value: Boolean): Boolean {
+public fun SparseBooleanArray.remove(key: Int, value: Boolean): Boolean {
val index = indexOfKey(key)
if (index >= 0 && value == valueAt(index)) {
// Delete by key because of https://issuetracker.google.com/issues/70934959.
@@ -68,24 +70,24 @@
}
/** Update this collection by adding or replacing entries from [other]. */
-fun SparseBooleanArray.putAll(other: SparseBooleanArray) = other.forEach(::put)
+public fun SparseBooleanArray.putAll(other: SparseBooleanArray): Unit = other.forEach(::put)
/** Performs the given [action] for each key/value entry. */
-inline fun SparseBooleanArray.forEach(action: (key: Int, value: Boolean) -> Unit) {
+public inline fun SparseBooleanArray.forEach(action: (key: Int, value: Boolean) -> Unit) {
for (index in 0 until size()) {
action(keyAt(index), valueAt(index))
}
}
/** Return an iterator over the collection's keys. */
-fun SparseBooleanArray.keyIterator(): IntIterator = object : IntIterator() {
+public fun SparseBooleanArray.keyIterator(): IntIterator = object : IntIterator() {
var index = 0
override fun hasNext() = index < size()
override fun nextInt() = keyAt(index++)
}
/** Return an iterator over the collection's values. */
-fun SparseBooleanArray.valueIterator(): BooleanIterator = object : BooleanIterator() {
+public fun SparseBooleanArray.valueIterator(): BooleanIterator = object : BooleanIterator() {
var index = 0
override fun hasNext() = index < size()
override fun nextBoolean() = valueAt(index++)
diff --git a/core/core-ktx/src/main/java/androidx/core/util/SparseIntArray.kt b/core/core-ktx/src/main/java/androidx/core/util/SparseIntArray.kt
index edf1d5c..0b80b87 100644
--- a/core/core-ktx/src/main/java/androidx/core/util/SparseIntArray.kt
+++ b/core/core-ktx/src/main/java/androidx/core/util/SparseIntArray.kt
@@ -21,16 +21,16 @@
import android.util.SparseIntArray
/** Returns the number of key/value pairs in the collection. */
-inline val SparseIntArray.size get() = size()
+public inline val SparseIntArray.size: Int get() = size()
/** Returns true if the collection contains [key]. */
-inline operator fun SparseIntArray.contains(key: Int) = indexOfKey(key) >= 0
+public inline operator fun SparseIntArray.contains(key: Int): Boolean = indexOfKey(key) >= 0
/** Allows the use of the index operator for storing values in the collection. */
-inline operator fun SparseIntArray.set(key: Int, value: Int) = put(key, value)
+public inline operator fun SparseIntArray.set(key: Int, value: Int): Unit = put(key, value)
/** Creates a new collection by adding or replacing entries from [other]. */
-operator fun SparseIntArray.plus(other: SparseIntArray): SparseIntArray {
+public operator fun SparseIntArray.plus(other: SparseIntArray): SparseIntArray {
val new = SparseIntArray(size() + other.size())
new.putAll(this)
new.putAll(other)
@@ -38,26 +38,27 @@
}
/** Returns true if the collection contains [key]. */
-inline fun SparseIntArray.containsKey(key: Int) = indexOfKey(key) >= 0
+public inline fun SparseIntArray.containsKey(key: Int): Boolean = indexOfKey(key) >= 0
/** Returns true if the collection contains [value]. */
-inline fun SparseIntArray.containsValue(value: Int) = indexOfValue(value) >= 0
+public inline fun SparseIntArray.containsValue(value: Int): Boolean = indexOfValue(value) >= 0
/** Return the value corresponding to [key], or [defaultValue] when not present. */
-inline fun SparseIntArray.getOrDefault(key: Int, defaultValue: Int) = get(key, defaultValue)
+public inline fun SparseIntArray.getOrDefault(key: Int, defaultValue: Int): Int =
+ get(key, defaultValue)
/** Return the value corresponding to [key], or from [defaultValue] when not present. */
-inline fun SparseIntArray.getOrElse(key: Int, defaultValue: () -> Int) =
+public inline fun SparseIntArray.getOrElse(key: Int, defaultValue: () -> Int): Int =
indexOfKey(key).let { if (it >= 0) valueAt(it) else defaultValue() }
/** Return true when the collection contains no elements. */
-inline fun SparseIntArray.isEmpty() = size() == 0
+public inline fun SparseIntArray.isEmpty(): Boolean = size() == 0
/** Return true when the collection contains elements. */
-inline fun SparseIntArray.isNotEmpty() = size() != 0
+public inline fun SparseIntArray.isNotEmpty(): Boolean = size() != 0
/** Removes the entry for [key] only if it is mapped to [value]. */
-fun SparseIntArray.remove(key: Int, value: Int): Boolean {
+public fun SparseIntArray.remove(key: Int, value: Int): Boolean {
val index = indexOfKey(key)
if (index >= 0 && value == valueAt(index)) {
removeAt(index)
@@ -67,24 +68,24 @@
}
/** Update this collection by adding or replacing entries from [other]. */
-fun SparseIntArray.putAll(other: SparseIntArray) = other.forEach(::put)
+public fun SparseIntArray.putAll(other: SparseIntArray): Unit = other.forEach(::put)
/** Performs the given [action] for each key/value entry. */
-inline fun SparseIntArray.forEach(action: (key: Int, value: Int) -> Unit) {
+public inline fun SparseIntArray.forEach(action: (key: Int, value: Int) -> Unit) {
for (index in 0 until size()) {
action(keyAt(index), valueAt(index))
}
}
/** Return an iterator over the collection's keys. */
-fun SparseIntArray.keyIterator(): IntIterator = object : IntIterator() {
+public fun SparseIntArray.keyIterator(): IntIterator = object : IntIterator() {
var index = 0
override fun hasNext() = index < size()
override fun nextInt() = keyAt(index++)
}
/** Return an iterator over the collection's values. */
-fun SparseIntArray.valueIterator(): IntIterator = object : IntIterator() {
+public fun SparseIntArray.valueIterator(): IntIterator = object : IntIterator() {
var index = 0
override fun hasNext() = index < size()
override fun nextInt() = valueAt(index++)
diff --git a/core/core-ktx/src/main/java/androidx/core/util/SparseLongArray.kt b/core/core-ktx/src/main/java/androidx/core/util/SparseLongArray.kt
index 40aabdd..9324384b2 100644
--- a/core/core-ktx/src/main/java/androidx/core/util/SparseLongArray.kt
+++ b/core/core-ktx/src/main/java/androidx/core/util/SparseLongArray.kt
@@ -23,19 +23,19 @@
/** Returns the number of key/value entries in the collection. */
@get:RequiresApi(18)
-inline val SparseLongArray.size get() = size()
+public inline val SparseLongArray.size: Int get() = size()
/** Returns true if the collection contains [key]. */
@RequiresApi(18)
-inline operator fun SparseLongArray.contains(key: Int) = indexOfKey(key) >= 0
+public inline operator fun SparseLongArray.contains(key: Int): Boolean = indexOfKey(key) >= 0
/** Allows the use of the index operator for storing values in the collection. */
@RequiresApi(18)
-inline operator fun SparseLongArray.set(key: Int, value: Long) = put(key, value)
+public inline operator fun SparseLongArray.set(key: Int, value: Long): Unit = put(key, value)
/** Creates a new collection by adding or replacing entries from [other]. */
@RequiresApi(18)
-operator fun SparseLongArray.plus(other: SparseLongArray): SparseLongArray {
+public operator fun SparseLongArray.plus(other: SparseLongArray): SparseLongArray {
val new = SparseLongArray(size() + other.size())
new.putAll(this)
new.putAll(other)
@@ -44,32 +44,33 @@
/** Returns true if the collection contains [key]. */
@RequiresApi(18)
-inline fun SparseLongArray.containsKey(key: Int) = indexOfKey(key) >= 0
+public inline fun SparseLongArray.containsKey(key: Int): Boolean = indexOfKey(key) >= 0
/** Returns true if the collection contains [value]. */
@RequiresApi(18)
-inline fun SparseLongArray.containsValue(value: Long) = indexOfValue(value) >= 0
+public inline fun SparseLongArray.containsValue(value: Long): Boolean = indexOfValue(value) >= 0
/** Return the value corresponding to [key], or [defaultValue] when not present. */
@RequiresApi(18)
-inline fun SparseLongArray.getOrDefault(key: Int, defaultValue: Long) = get(key, defaultValue)
+public inline fun SparseLongArray.getOrDefault(key: Int, defaultValue: Long): Long =
+ get(key, defaultValue)
/** Return the value corresponding to [key], or from [defaultValue] when not present. */
@RequiresApi(18)
-inline fun SparseLongArray.getOrElse(key: Int, defaultValue: () -> Long) =
+public inline fun SparseLongArray.getOrElse(key: Int, defaultValue: () -> Long): Long =
indexOfKey(key).let { if (it >= 0) valueAt(it) else defaultValue() }
/** Return true when the collection contains no elements. */
@RequiresApi(18)
-inline fun SparseLongArray.isEmpty() = size() == 0
+public inline fun SparseLongArray.isEmpty(): Boolean = size() == 0
/** Return true when the collection contains elements. */
@RequiresApi(18)
-inline fun SparseLongArray.isNotEmpty() = size() != 0
+public inline fun SparseLongArray.isNotEmpty(): Boolean = size() != 0
/** Removes the entry for [key] only if it is set to [value]. */
@RequiresApi(18)
-fun SparseLongArray.remove(key: Int, value: Long): Boolean {
+public fun SparseLongArray.remove(key: Int, value: Long): Boolean {
val index = indexOfKey(key)
if (index >= 0 && value == valueAt(index)) {
removeAt(index)
@@ -80,11 +81,11 @@
/** Update this collection by adding or replacing entries from [other]. */
@RequiresApi(18)
-fun SparseLongArray.putAll(other: SparseLongArray) = other.forEach(::put)
+public fun SparseLongArray.putAll(other: SparseLongArray): Unit = other.forEach(::put)
/** Performs the given [action] for each key/value entry. */
@RequiresApi(18)
-inline fun SparseLongArray.forEach(action: (key: Int, value: Long) -> Unit) {
+public inline fun SparseLongArray.forEach(action: (key: Int, value: Long) -> Unit) {
for (index in 0 until size()) {
action(keyAt(index), valueAt(index))
}
@@ -92,7 +93,7 @@
/** Return an iterator over the collection's keys. */
@RequiresApi(18)
-fun SparseLongArray.keyIterator(): IntIterator = object : IntIterator() {
+public fun SparseLongArray.keyIterator(): IntIterator = object : IntIterator() {
var index = 0
override fun hasNext() = index < size()
override fun nextInt() = keyAt(index++)
@@ -100,7 +101,7 @@
/** Return an iterator over the collection's values. */
@RequiresApi(18)
-fun SparseLongArray.valueIterator(): LongIterator = object : LongIterator() {
+public fun SparseLongArray.valueIterator(): LongIterator = object : LongIterator() {
var index = 0
override fun hasNext() = index < size()
override fun nextLong() = valueAt(index++)
diff --git a/core/core-ktx/src/main/java/androidx/core/view/Menu.kt b/core/core-ktx/src/main/java/androidx/core/view/Menu.kt
index 069e61d..bb4b9d2 100644
--- a/core/core-ktx/src/main/java/androidx/core/view/Menu.kt
+++ b/core/core-ktx/src/main/java/androidx/core/view/Menu.kt
@@ -26,10 +26,10 @@
*
* @throws IndexOutOfBoundsException if index is less than 0 or greater than or equal to the count.
*/
-inline operator fun Menu.get(index: Int): MenuItem = getItem(index)
+public inline operator fun Menu.get(index: Int): MenuItem = getItem(index)
/** Returns `true` if [item] is found in this menu. */
-operator fun Menu.contains(item: MenuItem): Boolean {
+public operator fun Menu.contains(item: MenuItem): Boolean {
@Suppress("LoopToCallChain")
for (index in 0 until size()) {
if (getItem(index) == item) {
@@ -40,33 +40,34 @@
}
/** Removes [item] from this menu. */
-inline operator fun Menu.minusAssign(item: MenuItem) = removeItem(item.itemId)
+public inline operator fun Menu.minusAssign(item: MenuItem): Unit = removeItem(item.itemId)
/** Returns the number of items in this menu. */
-inline val Menu.size get() = size()
+public inline val Menu.size: Int get() = size()
/** Returns true if this menu contains no items. */
-inline fun Menu.isEmpty() = size() == 0
+public inline fun Menu.isEmpty(): Boolean = size() == 0
/** Returns true if this menu contains one or more items. */
-inline fun Menu.isNotEmpty() = size() != 0
+public inline fun Menu.isNotEmpty(): Boolean = size() != 0
/** Performs the given action on each item in this menu. */
-inline fun Menu.forEach(action: (item: MenuItem) -> Unit) {
+public inline fun Menu.forEach(action: (item: MenuItem) -> Unit) {
for (index in 0 until size()) {
action(getItem(index))
}
}
/** Performs the given action on each item in this menu, providing its sequential index. */
-inline fun Menu.forEachIndexed(action: (index: Int, item: MenuItem) -> Unit) {
+public inline fun Menu.forEachIndexed(action: (index: Int, item: MenuItem) -> Unit) {
for (index in 0 until size()) {
action(index, getItem(index))
}
}
/** Returns a [MutableIterator] over the items in this menu. */
-operator fun Menu.iterator() = object : MutableIterator<MenuItem> {
+public operator fun Menu.iterator(
+): MutableIterator<MenuItem> = object : MutableIterator<MenuItem> {
private var index = 0
override fun hasNext() = index < size()
override fun next() = getItem(index++) ?: throw IndexOutOfBoundsException()
@@ -74,7 +75,7 @@
}
/** Returns a [Sequence] over the items in this menu. */
-val Menu.children: Sequence<MenuItem>
+public val Menu.children: Sequence<MenuItem>
get() = object : Sequence<MenuItem> {
override fun iterator() = [email protected]()
}
diff --git a/core/core-ktx/src/main/java/androidx/core/view/View.kt b/core/core-ktx/src/main/java/androidx/core/view/View.kt
index 7d4cd46..4a8432ce 100644
--- a/core/core-ktx/src/main/java/androidx/core/view/View.kt
+++ b/core/core-ktx/src/main/java/androidx/core/view/View.kt
@@ -34,7 +34,7 @@
*
* @see doOnLayout
*/
-inline fun View.doOnNextLayout(crossinline action: (view: View) -> Unit) {
+public inline fun View.doOnNextLayout(crossinline action: (view: View) -> Unit) {
addOnLayoutChangeListener(object : View.OnLayoutChangeListener {
override fun onLayoutChange(
view: View,
@@ -62,7 +62,7 @@
*
* @see doOnNextLayout
*/
-inline fun View.doOnLayout(crossinline action: (view: View) -> Unit) {
+public inline fun View.doOnLayout(crossinline action: (view: View) -> Unit) {
if (ViewCompat.isLaidOut(this) && !isLayoutRequested) {
action(this)
} else {
@@ -77,9 +77,9 @@
*
* The action will only be invoked once prior to the next draw and then removed.
*/
-inline fun View.doOnPreDraw(crossinline action: (view: View) -> Unit): OneShotPreDrawListener {
- return OneShotPreDrawListener.add(this) { action(this) }
-}
+public inline fun View.doOnPreDraw(
+ crossinline action: (view: View) -> Unit
+): OneShotPreDrawListener = OneShotPreDrawListener.add(this) { action(this) }
/**
* Performs the given action when this view is attached to a window. If the view is already
@@ -90,7 +90,7 @@
*
* @see doOnDetach
*/
-inline fun View.doOnAttach(crossinline action: (view: View) -> Unit) {
+public inline fun View.doOnAttach(crossinline action: (view: View) -> Unit) {
if (ViewCompat.isAttachedToWindow(this)) {
action(this)
} else {
@@ -114,7 +114,7 @@
*
* @see doOnAttach
*/
-inline fun View.doOnDetach(crossinline action: (view: View) -> Unit) {
+public inline fun View.doOnDetach(crossinline action: (view: View) -> Unit) {
if (!ViewCompat.isAttachedToWindow(this)) {
action(this)
} else {
@@ -136,7 +136,7 @@
* @see View.setPaddingRelative
*/
@RequiresApi(17)
-inline fun View.updatePaddingRelative(
+public inline fun View.updatePaddingRelative(
@Px start: Int = paddingStart,
@Px top: Int = paddingTop,
@Px end: Int = paddingEnd,
@@ -151,7 +151,7 @@
*
* @see View.setPadding
*/
-inline fun View.updatePadding(
+public inline fun View.updatePadding(
@Px left: Int = paddingLeft,
@Px top: Int = paddingTop,
@Px right: Int = paddingRight,
@@ -165,7 +165,7 @@
*
* @see View.setPadding
*/
-inline fun View.setPadding(@Px size: Int) {
+public inline fun View.setPadding(@Px size: Int) {
setPadding(size, size, size, size)
}
@@ -181,7 +181,7 @@
*
* @return the created Runnable
*/
-inline fun View.postDelayed(delayInMillis: Long, crossinline action: () -> Unit): Runnable {
+public inline fun View.postDelayed(delayInMillis: Long, crossinline action: () -> Unit): Runnable {
val runnable = Runnable { action() }
postDelayed(runnable, delayInMillis)
return runnable
@@ -200,7 +200,7 @@
* @return the created Runnable
*/
@RequiresApi(16)
-inline fun View.postOnAnimationDelayed(
+public inline fun View.postOnAnimationDelayed(
delayInMillis: Long,
crossinline action: () -> Unit
): Runnable {
@@ -223,7 +223,7 @@
*
* @param config Bitmap config of the desired bitmap. Defaults to [Bitmap.Config.ARGB_8888].
*/
-fun View.drawToBitmap(config: Bitmap.Config = Bitmap.Config.ARGB_8888): Bitmap {
+public fun View.drawToBitmap(config: Bitmap.Config = Bitmap.Config.ARGB_8888): Bitmap {
if (!ViewCompat.isLaidOut(this)) {
throw IllegalStateException("View needs to be laid out before calling drawToBitmap()")
}
@@ -248,7 +248,7 @@
* view.isVisible = true
* ```
*/
-inline var View.isVisible: Boolean
+public inline var View.isVisible: Boolean
get() = visibility == View.VISIBLE
set(value) {
visibility = if (value) View.VISIBLE else View.GONE
@@ -269,7 +269,7 @@
* view.isInvisible = true
* ```
*/
-inline var View.isInvisible: Boolean
+public inline var View.isInvisible: Boolean
get() = visibility == View.INVISIBLE
set(value) {
visibility = if (value) View.INVISIBLE else View.VISIBLE
@@ -290,7 +290,7 @@
* view.isGone = true
* ```
*/
-inline var View.isGone: Boolean
+public inline var View.isGone: Boolean
get() = visibility == View.GONE
set(value) {
visibility = if (value) View.GONE else View.VISIBLE
@@ -303,7 +303,7 @@
* @see View.getLayoutParams
* @see View.setLayoutParams
**/
-inline fun View.updateLayoutParams(block: ViewGroup.LayoutParams.() -> Unit) {
+public inline fun View.updateLayoutParams(block: ViewGroup.LayoutParams.() -> Unit) {
updateLayoutParams<ViewGroup.LayoutParams>(block)
}
@@ -315,7 +315,9 @@
* @see View.setLayoutParams
**/
@JvmName("updateLayoutParamsTyped")
-inline fun <reified T : ViewGroup.LayoutParams> View.updateLayoutParams(block: T.() -> Unit) {
+public inline fun <reified T : ViewGroup.LayoutParams> View.updateLayoutParams(
+ block: T.() -> Unit
+) {
val params = layoutParams as T
block(params)
layoutParams = params
@@ -327,7 +329,7 @@
*
* @see ViewGroup.MarginLayoutParams
*/
-inline val View.marginLeft: Int
+public inline val View.marginLeft: Int
get() = (layoutParams as? MarginLayoutParams)?.leftMargin ?: 0
/**
@@ -336,7 +338,7 @@
*
* @see ViewGroup.MarginLayoutParams
*/
-inline val View.marginTop: Int
+public inline val View.marginTop: Int
get() = (layoutParams as? MarginLayoutParams)?.topMargin ?: 0
/**
@@ -345,7 +347,7 @@
*
* @see ViewGroup.MarginLayoutParams
*/
-inline val View.marginRight: Int
+public inline val View.marginRight: Int
get() = (layoutParams as? MarginLayoutParams)?.rightMargin ?: 0
/**
@@ -354,7 +356,7 @@
*
* @see ViewGroup.MarginLayoutParams
*/
-inline val View.marginBottom: Int
+public inline val View.marginBottom: Int
get() = (layoutParams as? MarginLayoutParams)?.bottomMargin ?: 0
/**
@@ -364,7 +366,7 @@
* @see ViewGroup.MarginLayoutParams
* @see MarginLayoutParamsCompat.getMarginStart
*/
-inline val View.marginStart: Int
+public inline val View.marginStart: Int
get() {
val lp = layoutParams
return if (lp is MarginLayoutParams) MarginLayoutParamsCompat.getMarginStart(lp) else 0
@@ -377,7 +379,7 @@
* @see ViewGroup.MarginLayoutParams
* @see MarginLayoutParamsCompat.getMarginEnd
*/
-inline val View.marginEnd: Int
+public inline val View.marginEnd: Int
get() {
val lp = layoutParams
return if (lp is MarginLayoutParams) MarginLayoutParamsCompat.getMarginEnd(lp) else 0
@@ -389,7 +391,7 @@
*
* @see ViewGroup.descendants
*/
-val View.ancestors: Sequence<ViewParent>
+public val View.ancestors: Sequence<ViewParent>
get() = generateSequence(parent, ViewParent::getParent)
/**
@@ -399,7 +401,7 @@
*
* @see ViewGroup.descendants
*/
-val View.allViews: Sequence<View>
+public val View.allViews: Sequence<View>
get() = sequence {
yield(this@allViews)
if (this@allViews is ViewGroup) {
diff --git a/core/core-ktx/src/main/java/androidx/core/view/ViewGroup.kt b/core/core-ktx/src/main/java/androidx/core/view/ViewGroup.kt
index 3c337cd..11c043f 100644
--- a/core/core-ktx/src/main/java/androidx/core/view/ViewGroup.kt
+++ b/core/core-ktx/src/main/java/androidx/core/view/ViewGroup.kt
@@ -28,43 +28,43 @@
*
* @throws IndexOutOfBoundsException if index is less than 0 or greater than or equal to the count.
*/
-operator fun ViewGroup.get(index: Int) =
+public operator fun ViewGroup.get(index: Int): View =
getChildAt(index) ?: throw IndexOutOfBoundsException("Index: $index, Size: $childCount")
/** Returns `true` if [view] is found in this view group. */
-inline operator fun ViewGroup.contains(view: View) = indexOfChild(view) != -1
+public inline operator fun ViewGroup.contains(view: View): Boolean = indexOfChild(view) != -1
/** Adds [view] to this view group. */
-inline operator fun ViewGroup.plusAssign(view: View) = addView(view)
+public inline operator fun ViewGroup.plusAssign(view: View): Unit = addView(view)
/** Removes [view] from this view group. */
-inline operator fun ViewGroup.minusAssign(view: View) = removeView(view)
+public inline operator fun ViewGroup.minusAssign(view: View): Unit = removeView(view)
/** Returns the number of views in this view group. */
-inline val ViewGroup.size get() = childCount
+public inline val ViewGroup.size: Int get() = childCount
/** Returns true if this view group contains no views. */
-inline fun ViewGroup.isEmpty() = childCount == 0
+public inline fun ViewGroup.isEmpty(): Boolean = childCount == 0
/** Returns true if this view group contains one or more views. */
-inline fun ViewGroup.isNotEmpty() = childCount != 0
+public inline fun ViewGroup.isNotEmpty(): Boolean = childCount != 0
/** Performs the given action on each view in this view group. */
-inline fun ViewGroup.forEach(action: (view: View) -> Unit) {
+public inline fun ViewGroup.forEach(action: (view: View) -> Unit) {
for (index in 0 until childCount) {
action(getChildAt(index))
}
}
/** Performs the given action on each view in this view group, providing its sequential index. */
-inline fun ViewGroup.forEachIndexed(action: (index: Int, view: View) -> Unit) {
+public inline fun ViewGroup.forEachIndexed(action: (index: Int, view: View) -> Unit) {
for (index in 0 until childCount) {
action(index, getChildAt(index))
}
}
/** Returns a [MutableIterator] over the views in this view group. */
-operator fun ViewGroup.iterator() = object : MutableIterator<View> {
+public operator fun ViewGroup.iterator(): MutableIterator<View> = object : MutableIterator<View> {
private var index = 0
override fun hasNext() = index < childCount
override fun next() = getChildAt(index++) ?: throw IndexOutOfBoundsException()
@@ -77,7 +77,7 @@
* @see View.allViews
* @see ViewGroup.descendants
*/
-val ViewGroup.children: Sequence<View>
+public val ViewGroup.children: Sequence<View>
get() = object : Sequence<View> {
override fun iterator() = [email protected]()
}
@@ -91,7 +91,7 @@
* @see ViewGroup.children
* @see View.ancestors
*/
-val ViewGroup.descendants: Sequence<View>
+public val ViewGroup.descendants: Sequence<View>
get() = sequence {
forEach { child ->
yield(child)
@@ -107,7 +107,7 @@
*
* @see ViewGroup.MarginLayoutParams.setMargins
*/
-inline fun ViewGroup.MarginLayoutParams.setMargins(@Px size: Int) {
+public inline fun ViewGroup.MarginLayoutParams.setMargins(@Px size: Int) {
setMargins(size, size, size, size)
}
@@ -117,7 +117,7 @@
*
* @see ViewGroup.MarginLayoutParams.setMargins
*/
-inline fun ViewGroup.MarginLayoutParams.updateMargins(
+public inline fun ViewGroup.MarginLayoutParams.updateMargins(
@Px left: Int = leftMargin,
@Px top: Int = topMargin,
@Px right: Int = rightMargin,
@@ -133,7 +133,7 @@
* @see ViewGroup.MarginLayoutParams.setMargins
*/
@RequiresApi(17)
-inline fun ViewGroup.MarginLayoutParams.updateMarginsRelative(
+public inline fun ViewGroup.MarginLayoutParams.updateMarginsRelative(
@Px start: Int = marginStart,
@Px top: Int = topMargin,
@Px end: Int = marginEnd,
diff --git a/core/core-ktx/src/main/java/androidx/core/widget/TextView.kt b/core/core-ktx/src/main/java/androidx/core/widget/TextView.kt
index a66380a..d4f5e9d 100644
--- a/core/core-ktx/src/main/java/androidx/core/widget/TextView.kt
+++ b/core/core-ktx/src/main/java/androidx/core/widget/TextView.kt
@@ -25,44 +25,44 @@
*
* @return the [TextWatcher] added to the TextView
*/
-inline fun TextView.doBeforeTextChanged(
+public inline fun TextView.doBeforeTextChanged(
crossinline action: (
text: CharSequence?,
start: Int,
count: Int,
after: Int
) -> Unit
-) = addTextChangedListener(beforeTextChanged = action)
+): TextWatcher = addTextChangedListener(beforeTextChanged = action)
/**
* Add an action which will be invoked when the text is changing.
*
* @return the [TextWatcher] added to the TextView
*/
-inline fun TextView.doOnTextChanged(
+public inline fun TextView.doOnTextChanged(
crossinline action: (
text: CharSequence?,
start: Int,
before: Int,
count: Int
) -> Unit
-) = addTextChangedListener(onTextChanged = action)
+): TextWatcher = addTextChangedListener(onTextChanged = action)
/**
* Add an action which will be invoked after the text changed.
*
* @return the [TextWatcher] added to the TextView
*/
-inline fun TextView.doAfterTextChanged(
+public inline fun TextView.doAfterTextChanged(
crossinline action: (text: Editable?) -> Unit
-) = addTextChangedListener(afterTextChanged = action)
+): TextWatcher = addTextChangedListener(afterTextChanged = action)
/**
* Add a text changed listener to this TextView using the provided actions
*
* @return the [TextWatcher] added to the TextView
*/
-inline fun TextView.addTextChangedListener(
+public inline fun TextView.addTextChangedListener(
crossinline beforeTextChanged: (
text: CharSequence?,
start: Int,
diff --git a/development/build_log_simplifier/messages.ignore b/development/build_log_simplifier/messages.ignore
index d9fb129..7e3eaaa 100644
--- a/development/build_log_simplifier/messages.ignore
+++ b/development/build_log_simplifier/messages.ignore
@@ -1200,6 +1200,10 @@
# > Task :wear:wear-input:compileDebugUnitTestJavaWithJavac
Note: \$SUPPORT/wear/wear\-input/src/test/java/androidx/wear/input/WearableButtonsTest\.java uses or overrides a deprecated API\.
# > Task :lifecycle:integration-tests:incrementality:compileTestKotlin
+\$OUT_DIR\/\.gradle\/wrapper\/dists\/gradle\-[0-9]+\.[0-9]+\.[0-9]+\-bin\/[0-9]+jxfl[0-9]+bpr[0-9]+n[0-9]+ie[0-9]+t[0-9]+mbogjj\/gradle\-[0-9]+\.[0-9]+\.[0-9]+\/lib\/kotlin\-stdlib\-[0-9]+\.[0-9]+\.[0-9]+\.jar \(version [0-9]+\.[0-9]+\)
+\$OUT_DIR\/\.gradle\/wrapper\/dists\/gradle\-[0-9]+\.[0-9]+\.[0-9]+\-bin\/[0-9]+jxfl[0-9]+bpr[0-9]+n[0-9]+ie[0-9]+t[0-9]+mbogjj\/gradle\-[0-9]+\.[0-9]+\.[0-9]+\/lib\/kotlin\-stdlib\-common\-[0-9]+\.[0-9]+\.[0-9]+\.jar \(version [0-9]+\.[0-9]+\)
+\$OUT_DIR\/\.gradle\/wrapper\/dists\/gradle\-[0-9]+\.[0-9]+\.[0-9]+\-bin\/[0-9]+jxfl[0-9]+bpr[0-9]+n[0-9]+ie[0-9]+t[0-9]+mbogjj\/gradle\-[0-9]+\.[0-9]+\.[0-9]+\/lib\/kotlin\-stdlib\-jdk[0-9]+\-[0-9]+\.[0-9]+\.[0-9]+\.jar \(version [0-9]+\.[0-9]+\)
+\$OUT_DIR\/\.gradle\/wrapper\/dists\/gradle\-[0-9]+\.[0-9]+\.[0-9]+\-bin\/[0-9]+jxfl[0-9]+bpr[0-9]+n[0-9]+ie[0-9]+t[0-9]+mbogjj\/gradle\-[0-9]+\.[0-9]+\.[0-9]+\/lib\/kotlin\-reflect\-[0-9]+\.[0-9]+\.[0-9]+\.jar \(version [0-9]+\.[0-9]+\)
\$OUT_DIR\/\.gradle\/wrapper\/dists\/gradle\-[0-9]+\.[0-9]+\.[0-9]+\-bin\/[0-9]+hg[0-9]+cwdjis[0-9]+evrsfeibqx[0-9]+\/gradle\-[0-9]+\.[0-9]+\.[0-9]+\/lib\/kotlin\-stdlib\-[0-9]+\.[0-9]+\.[0-9]+\.jar \(version [0-9]+\.[0-9]+\)
\$OUT_DIR\/\.gradle\/wrapper\/dists\/gradle\-[0-9]+\.[0-9]+\.[0-9]+\-bin\/[0-9]+hg[0-9]+cwdjis[0-9]+evrsfeibqx[0-9]+\/gradle\-[0-9]+\.[0-9]+\.[0-9]+\/lib\/kotlin\-stdlib\-common\-[0-9]+\.[0-9]+\.[0-9]+\.jar \(version [0-9]+\.[0-9]+\)
\$OUT_DIR\/\.gradle\/wrapper\/dists\/gradle\-[0-9]+\.[0-9]+\.[0-9]+\-bin\/[0-9]+hg[0-9]+cwdjis[0-9]+evrsfeibqx[0-9]+\/gradle\-[0-9]+\.[0-9]+\.[0-9]+\/lib\/kotlin\-stdlib\-jdk[0-9]+\-[0-9]+\.[0-9]+\.[0-9]+\.jar \(version [0-9]+\.[0-9]+\)
@@ -1225,4 +1229,9 @@
Note\: \$SUPPORT\/wear\/wear\-watchface\-complications\-rendering\/src\/test\/java\/androidx\/wear\/watchface\/complications\/rendering\/RoundedDrawableTest\.java uses or overrides a deprecated API\.
# > Task :wear:wear-watchface:testDebugUnitTest
System\.logW\: A resource was acquired at attached stack trace but never released\. See java\.io\.Closeable for information on avoiding resource leaks\.java\.lang\.Throwable\: Explicit termination method \'dispose\' not called
-System\.logW\: A resource was acquired at attached stack trace but never released\. See java\.io\.Closeable for information on avoiding resource leaks\.java\.lang\.Throwable\: Explicit termination method \'release\' not called
\ No newline at end of file
+System\.logW\: A resource was acquired at attached stack trace but never released\. See java\.io\.Closeable for information on avoiding resource leaks\.java\.lang\.Throwable\: Explicit termination method \'release\' not called
+# > Task :compose:animation:animation-core:testDebugUnitTest
+androidx\.compose\.animation\.core\.AnimationClockTest \> testSubscriptionDuringFrameCallback FAILED
+kotlin\.UninitializedPropertyAccessException at AnimationClockTest\.kt\:[0-9]+
+[0-9]+ tests completed\, [0-9]+ failed
+There were failing tests\. See the report at\: file\:\/\/\$OUT_DIR\/ui\/compose\/animation\/animation\-core\/build\/reports\/tests\/testDebugUnitTest\/index\.html
\ No newline at end of file
diff --git a/emoji/core/api/current.txt b/emoji/core/api/current.txt
index 726d9b5..c472e4e 100644
--- a/emoji/core/api/current.txt
+++ b/emoji/core/api/current.txt
@@ -36,6 +36,7 @@
method public androidx.emoji.text.EmojiCompat.Config! registerInitCallback(androidx.emoji.text.EmojiCompat.InitCallback);
method public androidx.emoji.text.EmojiCompat.Config! setEmojiSpanIndicatorColor(@ColorInt int);
method public androidx.emoji.text.EmojiCompat.Config! setEmojiSpanIndicatorEnabled(boolean);
+ method public androidx.emoji.text.EmojiCompat.Config setGlyphChecker(androidx.emoji.text.EmojiCompat.GlyphChecker);
method public androidx.emoji.text.EmojiCompat.Config! setMetadataLoadStrategy(int);
method public androidx.emoji.text.EmojiCompat.Config! setReplaceAll(boolean);
method public androidx.emoji.text.EmojiCompat.Config! setUseEmojiAsDefaultStyle(boolean);
@@ -43,6 +44,10 @@
method public androidx.emoji.text.EmojiCompat.Config! unregisterInitCallback(androidx.emoji.text.EmojiCompat.InitCallback);
}
+ public static interface EmojiCompat.GlyphChecker {
+ method public boolean hasGlyph(CharSequence, @IntRange(from=0) int, @IntRange(from=0) int, @IntRange(from=0) int);
+ }
+
public abstract static class EmojiCompat.InitCallback {
ctor public EmojiCompat.InitCallback();
method public void onFailed(Throwable?);
diff --git a/emoji/core/api/public_plus_experimental_current.txt b/emoji/core/api/public_plus_experimental_current.txt
index 726d9b5..c472e4e 100644
--- a/emoji/core/api/public_plus_experimental_current.txt
+++ b/emoji/core/api/public_plus_experimental_current.txt
@@ -36,6 +36,7 @@
method public androidx.emoji.text.EmojiCompat.Config! registerInitCallback(androidx.emoji.text.EmojiCompat.InitCallback);
method public androidx.emoji.text.EmojiCompat.Config! setEmojiSpanIndicatorColor(@ColorInt int);
method public androidx.emoji.text.EmojiCompat.Config! setEmojiSpanIndicatorEnabled(boolean);
+ method public androidx.emoji.text.EmojiCompat.Config setGlyphChecker(androidx.emoji.text.EmojiCompat.GlyphChecker);
method public androidx.emoji.text.EmojiCompat.Config! setMetadataLoadStrategy(int);
method public androidx.emoji.text.EmojiCompat.Config! setReplaceAll(boolean);
method public androidx.emoji.text.EmojiCompat.Config! setUseEmojiAsDefaultStyle(boolean);
@@ -43,6 +44,10 @@
method public androidx.emoji.text.EmojiCompat.Config! unregisterInitCallback(androidx.emoji.text.EmojiCompat.InitCallback);
}
+ public static interface EmojiCompat.GlyphChecker {
+ method public boolean hasGlyph(CharSequence, @IntRange(from=0) int, @IntRange(from=0) int, @IntRange(from=0) int);
+ }
+
public abstract static class EmojiCompat.InitCallback {
ctor public EmojiCompat.InitCallback();
method public void onFailed(Throwable?);
diff --git a/emoji/core/api/restricted_current.txt b/emoji/core/api/restricted_current.txt
index 06dadfa..95072c9 100644
--- a/emoji/core/api/restricted_current.txt
+++ b/emoji/core/api/restricted_current.txt
@@ -39,6 +39,7 @@
method public androidx.emoji.text.EmojiCompat.Config! registerInitCallback(androidx.emoji.text.EmojiCompat.InitCallback);
method public androidx.emoji.text.EmojiCompat.Config! setEmojiSpanIndicatorColor(@ColorInt int);
method public androidx.emoji.text.EmojiCompat.Config! setEmojiSpanIndicatorEnabled(boolean);
+ method public androidx.emoji.text.EmojiCompat.Config setGlyphChecker(androidx.emoji.text.EmojiCompat.GlyphChecker);
method public androidx.emoji.text.EmojiCompat.Config! setMetadataLoadStrategy(@androidx.emoji.text.EmojiCompat.LoadStrategy int);
method public androidx.emoji.text.EmojiCompat.Config! setReplaceAll(boolean);
method public androidx.emoji.text.EmojiCompat.Config! setUseEmojiAsDefaultStyle(boolean);
@@ -46,6 +47,10 @@
method public androidx.emoji.text.EmojiCompat.Config! unregisterInitCallback(androidx.emoji.text.EmojiCompat.InitCallback);
}
+ public static interface EmojiCompat.GlyphChecker {
+ method public boolean hasGlyph(CharSequence, @IntRange(from=0) int, @IntRange(from=0) int, @IntRange(from=0) int);
+ }
+
public abstract static class EmojiCompat.InitCallback {
ctor public EmojiCompat.InitCallback();
method public void onFailed(Throwable?);
diff --git a/emoji/core/src/androidTest/java/androidx/emoji/text/ConfigTest.java b/emoji/core/src/androidTest/java/androidx/emoji/text/ConfigTest.java
index 156b207..73ac123 100644
--- a/emoji/core/src/androidTest/java/androidx/emoji/text/ConfigTest.java
+++ b/emoji/core/src/androidTest/java/androidx/emoji/text/ConfigTest.java
@@ -19,16 +19,19 @@
import static androidx.emoji.util.EmojiMatcher.hasEmoji;
import static androidx.emoji.util.EmojiMatcher.hasEmojiCount;
+import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
import android.content.Context;
import android.graphics.Color;
@@ -162,6 +165,47 @@
assertEquals(EmojiCompat.LOAD_STATE_DEFAULT, EmojiCompat.get().getLoadState());
}
+ @Test
+ @SdkSuppress(minSdkVersion = 19)
+ public void testGlyphCheckerInstance_EmojiSpan_isNotAdded_whenHasGlyph_returnsTrue() {
+ final EmojiCompat.GlyphChecker glyphChecker = mock(EmojiCompat.GlyphChecker.class);
+ when(glyphChecker.hasGlyph(any(CharSequence.class), anyInt(), anyInt(), anyInt()))
+ .thenReturn(true);
+
+ final EmojiCompat.Config config = TestConfigBuilder.freshConfig()
+ .setReplaceAll(false)
+ .setGlyphChecker(glyphChecker);
+ EmojiCompat.reset(config);
+
+ final String original = new TestString(EMOJI_SINGLE_CODEPOINT).toString();
+ CharSequence processed = EmojiCompat.get().process(original, 0, original.length());
+
+ verify(glyphChecker, times(1))
+ .hasGlyph(any(CharSequence.class), anyInt(), anyInt(), anyInt());
+ assertThat(processed, not(hasEmoji()));
+ }
+
+ @Test
+ @SdkSuppress(minSdkVersion = 19)
+ public void testGlyphCheckerInstance_EmojiSpan_isAdded_whenHasGlyph_returnsFalse() {
+ final EmojiCompat.GlyphChecker glyphChecker = mock(EmojiCompat.GlyphChecker.class);
+ when(glyphChecker.hasGlyph(any(CharSequence.class), anyInt(), anyInt(), anyInt()))
+ .thenReturn(false);
+
+ final EmojiCompat.Config config = TestConfigBuilder.freshConfig()
+ .setReplaceAll(false)
+ .setGlyphChecker(glyphChecker);
+ EmojiCompat.reset(config);
+
+ final String original = new TestString(EMOJI_SINGLE_CODEPOINT).toString();
+
+ CharSequence processed = EmojiCompat.get().process(original, 0, original.length());
+
+ verify(glyphChecker, times(1))
+ .hasGlyph(any(CharSequence.class), anyInt(), anyInt(), anyInt());
+ assertThat(processed, hasEmoji());
+ }
+
private static class ValidTestConfig extends EmojiCompat.Config {
ValidTestConfig() {
super(new TestConfigBuilder.TestEmojiDataLoader());
diff --git a/emoji/core/src/androidTest/java/androidx/emoji/text/EmojiCompatTest.java b/emoji/core/src/androidTest/java/androidx/emoji/text/EmojiCompatTest.java
index 452c041..08a8cd7 100644
--- a/emoji/core/src/androidTest/java/androidx/emoji/text/EmojiCompatTest.java
+++ b/emoji/core/src/androidTest/java/androidx/emoji/text/EmojiCompatTest.java
@@ -502,12 +502,14 @@
@Test
@SdkSuppress(minSdkVersion = 19)
public void testProcess_withReplaceNonExistent_callsGlyphChecker() {
- final EmojiCompat.Config config = TestConfigBuilder.config().setReplaceAll(true);
+ final EmojiCompat.GlyphChecker glyphChecker = mock(EmojiCompat.GlyphChecker.class);
+ final EmojiCompat.Config config = TestConfigBuilder.freshConfig()
+ .setReplaceAll(true)
+ .setGlyphChecker(glyphChecker);
EmojiCompat.reset(config);
- final EmojiProcessor.GlyphChecker glyphChecker = mock(EmojiProcessor.GlyphChecker.class);
- when(glyphChecker.hasGlyph(any(CharSequence.class), anyInt(), anyInt())).thenReturn(true);
- EmojiCompat.get().setGlyphChecker(glyphChecker);
+ when(glyphChecker.hasGlyph(any(CharSequence.class), anyInt(), anyInt(), anyInt()))
+ .thenReturn(true);
final String original = new TestString(EMOJI_SINGLE_CODEPOINT).toString();
@@ -515,7 +517,8 @@
Integer.MAX_VALUE /*maxEmojiCount*/, EmojiCompat.REPLACE_STRATEGY_NON_EXISTENT);
// when function overrides config level replaceAll, a call to GlyphChecker is expected.
- verify(glyphChecker, times(1)).hasGlyph(any(CharSequence.class), anyInt(), anyInt());
+ verify(glyphChecker, times(1))
+ .hasGlyph(any(CharSequence.class), anyInt(), anyInt(), anyInt());
// since replaceAll is false, there should be no EmojiSpans
assertThat(processed, not(hasEmoji()));
@@ -524,12 +527,14 @@
@Test
@SdkSuppress(minSdkVersion = 19)
public void testProcess_withReplaceDefault_doesNotCallGlyphChecker() {
- final EmojiCompat.Config config = TestConfigBuilder.config().setReplaceAll(true);
+ final EmojiCompat.GlyphChecker glyphChecker = mock(EmojiCompat.GlyphChecker.class);
+ final EmojiCompat.Config config = TestConfigBuilder.freshConfig()
+ .setReplaceAll(true)
+ .setGlyphChecker(glyphChecker);
EmojiCompat.reset(config);
- final EmojiProcessor.GlyphChecker glyphChecker = mock(EmojiProcessor.GlyphChecker.class);
- when(glyphChecker.hasGlyph(any(CharSequence.class), anyInt(), anyInt())).thenReturn(true);
- EmojiCompat.get().setGlyphChecker(glyphChecker);
+ when(glyphChecker.hasGlyph(any(CharSequence.class), anyInt(), anyInt(), anyInt()))
+ .thenReturn(true);
final String original = new TestString(EMOJI_SINGLE_CODEPOINT).toString();
// call without replaceAll, config value (true) should be used
@@ -537,7 +542,8 @@
Integer.MAX_VALUE /*maxEmojiCount*/, EmojiCompat.REPLACE_STRATEGY_DEFAULT);
// replaceAll=true should not call hasGlyph
- verify(glyphChecker, times(0)).hasGlyph(any(CharSequence.class), anyInt(), anyInt());
+ verify(glyphChecker, times(0))
+ .hasGlyph(any(CharSequence.class), anyInt(), anyInt(), anyInt());
assertThat(processed, hasEmojiCount(1));
assertThat(processed, hasEmoji(EMOJI_SINGLE_CODEPOINT));
@@ -546,9 +552,15 @@
@Test
@SdkSuppress(minSdkVersion = 19)
public void testProcess_withSpanned_replaceNonExistent() {
- final EmojiCompat.Config config = TestConfigBuilder.config().setReplaceAll(false);
+ final EmojiCompat.GlyphChecker glyphChecker = mock(EmojiCompat.GlyphChecker.class);
+ final EmojiCompat.Config config = TestConfigBuilder.freshConfig()
+ .setReplaceAll(false)
+ .setGlyphChecker(glyphChecker);
EmojiCompat.reset(config);
+ when(glyphChecker.hasGlyph(any(CharSequence.class), anyInt(), anyInt(), anyInt()))
+ .thenReturn(false);
+
final String string = new TestString(EMOJI_SINGLE_CODEPOINT).append(
EMOJI_SINGLE_CODEPOINT).toString();
CharSequence processed = EmojiCompat.get().process(string, 0, string.length(),
@@ -557,10 +569,9 @@
final SpannedString spanned = new SpannedString(processed);
assertThat(spanned, hasEmojiCount(2));
- // mock GlyphChecker so that we can return true for hasGlyph
- final EmojiProcessor.GlyphChecker glyphChecker = mock(EmojiProcessor.GlyphChecker.class);
- when(glyphChecker.hasGlyph(any(CharSequence.class), anyInt(), anyInt())).thenReturn(true);
- EmojiCompat.get().setGlyphChecker(glyphChecker);
+ // change glyphChecker to return true so that no emoji will be added
+ when(glyphChecker.hasGlyph(any(CharSequence.class), anyInt(), anyInt(), anyInt()))
+ .thenReturn(true);
processed = EmojiCompat.get().process(spanned, 0, spanned.length(),
Integer.MAX_VALUE, EmojiCompat.REPLACE_STRATEGY_NON_EXISTENT);
@@ -803,7 +814,7 @@
public void testUpdateEditorInfoAttrs_setsKeysIfInitialized() {
final EditorInfo editorInfo = new EditorInfo();
editorInfo.extras = new Bundle();
- EmojiCompat.Config config = new TestConfigBuilder.TestConfig().setReplaceAll(false);
+ EmojiCompat.Config config = TestConfigBuilder.config().setReplaceAll(false);
EmojiCompat.reset(config);
EmojiCompat.get().updateEditorInfoAttrs(editorInfo);
@@ -857,7 +868,7 @@
@Test
@SdkSuppress(minSdkVersion = 19)
public void testUseEmojiAsDefaultStyle_whenEmojiInTheMiddle() {
- final EmojiCompat.Config config = new TestConfigBuilder.TestConfig().setReplaceAll(true);
+ final EmojiCompat.Config config = TestConfigBuilder.config().setReplaceAll(true);
EmojiCompat.reset(config);
String s = new TestString(0x0061, CHAR_DEFAULT_TEXT_STYLE, 0x0062).toString();
// no span should be added as the emoji is text style presented by default
@@ -870,7 +881,7 @@
@Test
@SdkSuppress(minSdkVersion = 19)
public void testUseEmojiAsDefaultStyle_whenEmojiAtTheEnd() {
- final EmojiCompat.Config config = new TestConfigBuilder.TestConfig().setReplaceAll(true);
+ final EmojiCompat.Config config = TestConfigBuilder.config().setReplaceAll(true);
EmojiCompat.reset(config);
String s = new TestString(0x0061, CHAR_DEFAULT_TEXT_STYLE).toString();
// no span should be added as the emoji is text style presented by default
@@ -886,7 +897,7 @@
final String s = new TestString(CHAR_DEFAULT_TEXT_STYLE).toString();
final List<Integer> exceptions =
Arrays.asList(CHAR_DEFAULT_TEXT_STYLE + 1, CHAR_DEFAULT_TEXT_STYLE);
- final EmojiCompat.Config config = new TestConfigBuilder.TestConfig().setReplaceAll(true)
+ final EmojiCompat.Config config = TestConfigBuilder.config().setReplaceAll(true)
.setUseEmojiAsDefaultStyle(true, exceptions);
EmojiCompat.reset(config);
// no span should be added as the text style codepoint is marked as exception
@@ -899,7 +910,7 @@
final String s = new TestString(CHAR_DEFAULT_TEXT_STYLE).toString();
final List<Integer> exceptions =
Arrays.asList(CHAR_DEFAULT_TEXT_STYLE - 1, CHAR_DEFAULT_TEXT_STYLE + 1);
- final EmojiCompat.Config config = new TestConfigBuilder.TestConfig().setReplaceAll(true)
+ final EmojiCompat.Config config = TestConfigBuilder.config().setReplaceAll(true)
.setUseEmojiAsDefaultStyle(true, exceptions);
EmojiCompat.reset(config);
// a span should be added as the codepoint is not included in the set of exceptions
diff --git a/emoji/core/src/androidTest/java/androidx/emoji/text/TestConfigBuilder.java b/emoji/core/src/androidTest/java/androidx/emoji/text/TestConfigBuilder.java
index 944e929..d5b93ff 100644
--- a/emoji/core/src/androidTest/java/androidx/emoji/text/TestConfigBuilder.java
+++ b/emoji/core/src/androidTest/java/androidx/emoji/text/TestConfigBuilder.java
@@ -17,6 +17,7 @@
import static org.junit.Assert.fail;
+import android.content.Context;
import android.content.res.AssetManager;
import androidx.annotation.GuardedBy;
@@ -26,10 +27,23 @@
import java.util.concurrent.CountDownLatch;
public class TestConfigBuilder {
+ private static final String FONT_FILE = "NotoColorEmojiCompat.ttf";
+
+ private TestConfigBuilder() { }
+
public static EmojiCompat.Config config() {
return new TestConfig().setReplaceAll(true);
}
+ /**
+ * Forces the creation of Metadata instead of relying on cached metadata. If GlyphChecker is
+ * mocked, a new metadata has to be used instead of the statically cached metadata since the
+ * result of GlyphChecker on the same device might effect other tests.
+ */
+ public static EmojiCompat.Config freshConfig() {
+ return new TestConfig(new ResettingTestDataLoader()).setReplaceAll(true);
+ }
+
public static class TestConfig extends EmojiCompat.Config {
TestConfig() {
super(new TestEmojiDataLoader());
@@ -100,10 +114,9 @@
synchronized (sMetadataRepoLock) {
if (sMetadataRepo == null) {
try {
- final AssetManager assetManager =
- ApplicationProvider.getApplicationContext().getAssets();
- sMetadataRepo = MetadataRepo.create(assetManager,
- "NotoColorEmojiCompat.ttf");
+ final Context context = ApplicationProvider.getApplicationContext();
+ final AssetManager assetManager = context.getAssets();
+ sMetadataRepo = MetadataRepo.create(assetManager, FONT_FILE);
} catch (Throwable e) {
loaderCallback.onFailed(e);
throw new RuntimeException(e);
@@ -116,4 +129,27 @@
}
}
+ public static class ResettingTestDataLoader implements EmojiCompat.MetadataRepoLoader {
+ private MetadataRepo mMetadataRepo;
+
+ ResettingTestDataLoader() {
+ }
+
+ @Override
+ public void load(@NonNull EmojiCompat.MetadataRepoLoaderCallback loaderCallback) {
+ if (mMetadataRepo == null) {
+ try {
+ final Context context = ApplicationProvider.getApplicationContext();
+ final AssetManager assetManager = context.getAssets();
+ mMetadataRepo = MetadataRepo.create(assetManager, FONT_FILE);
+ } catch (Throwable e) {
+ loaderCallback.onFailed(e);
+ throw new RuntimeException(e);
+ }
+ }
+
+ loaderCallback.onLoaded(mMetadataRepo);
+ }
+ }
+
}
diff --git a/emoji/core/src/main/java/androidx/emoji/text/EmojiCompat.java b/emoji/core/src/main/java/androidx/emoji/text/EmojiCompat.java
index 4dc534d..93b5a75 100644
--- a/emoji/core/src/main/java/androidx/emoji/text/EmojiCompat.java
+++ b/emoji/core/src/main/java/androidx/emoji/text/EmojiCompat.java
@@ -18,6 +18,7 @@
import static androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX;
import android.graphics.Color;
+import android.graphics.Paint;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
@@ -257,6 +258,12 @@
@LoadStrategy private final int mMetadataLoadStrategy;
/**
+ * @see Config#setGlyphChecker(GlyphChecker)
+ */
+ @SuppressWarnings("WeakerAccess") /* synthetic access */
+ private final GlyphChecker mGlyphChecker;
+
+ /**
* Private constructor for singleton instance.
*
* @see #init(Config)
@@ -271,6 +278,7 @@
mEmojiSpanIndicatorColor = config.mEmojiSpanIndicatorColor;
mMetadataLoader = config.mMetadataLoader;
mMetadataLoadStrategy = config.mMetadataLoadStrategy;
+ mGlyphChecker = config.mGlyphChecker;
mMainHandler = new Handler(Looper.getMainLooper());
mInitCallbacks = new ArraySet<>();
if (config.mInitCallbacks != null && !config.mInitCallbacks.isEmpty()) {
@@ -334,17 +342,6 @@
}
/**
- * Used by the tests to set GlyphChecker for EmojiProcessor.
- *
- * @hide
- */
- @RestrictTo(LIBRARY_GROUP_PREFIX)
- @VisibleForTesting
- void setGlyphChecker(@NonNull final EmojiProcessor.GlyphChecker glyphChecker) {
- mHelper.setGlyphChecker(glyphChecker);
- }
-
- /**
* Return singleton EmojiCompat instance. Should be called after
* {@link #init(EmojiCompat.Config)} is called to initialize the singleton instance.
*
@@ -866,6 +863,74 @@
}
/**
+ * Interface to check if a given emoji exists on the system.
+ */
+ public interface GlyphChecker {
+ /**
+ * Return {@code true} if the emoji that is in {@code charSequence} between
+ * {@code start}(inclusive) and {@code end}(exclusive) can be rendered on the system
+ * using the default Typeface.
+ *
+ * This function is called after an emoji is identified in the given {@code charSequence}
+ * and EmojiCompat wants to know if that emoji can be rendered on the system. The result
+ * of this call will be cached and the same emoji sequence won't be asked for the same
+ * EmojiCompat instance.
+ *
+ * When the function returns {@code true}, it will mean that the system can render the
+ * emoji. In that case if {@link Config#setReplaceAll} is set to {@code false}, then no
+ * {@link EmojiSpan} will be added in the final emoji processing result.
+ *
+ * When the function returns {@code false}, it will mean that the system cannot render
+ * the given emoji, therefore an {@link EmojiSpan} will be added to the final emoji
+ * processing result.
+ *
+ * The default implementation of this class uses
+ * {@link androidx.core.graphics.PaintCompat#hasGlyph(Paint, String)} function to check
+ * if the emoji can be rendered on the system. This is required even if EmojiCompat
+ * knows about the SDK Version that the emoji was added on AOSP. Just the {@code sdkAdded}
+ * information is not enough to reliably decide if emoji can be rendered since this
+ * information may not be consistent across all the OEMs and all the Android versions.
+ *
+ * With this interface you can apply your own heuristics to check if the emoji can be
+ * rendered on the system. For example, if you'd like to rely on the {@code sdkAdded}
+ * information, and some predefined OEMs, it is possible to write the following code
+ * snippet.
+ * <pre>
+ * <code>
+ * class MyGlyphChecker implements EmojiGlyphChecker {
+ * public boolean hasGlyph(
+ * CharSequence charSequence,
+ * int start,
+ * int end,
+ * int sdkAdded
+ * ) {
+ * if(isOnDeviceX()) {
+ * return sdkAdded < Build.VERSION.SDK_INT;
+ * } else {
+ * val string = constructString(charSequence, start, end)
+ * return PaintCompat.hasGlyph(getTextPaint(), string);
+ * }
+ * }
+ * }
+ * </code>
+ * </pre>
+ *
+ * @param charSequence the CharSequence that is being processed
+ * @param start the inclusive starting offset for the emoji in the {@code charSequence}
+ * @param end the exclusive end offset for the emoji in the {@code charSequence}
+ * @param sdkAdded the API version that the emoji was added in AOSP
+ *
+ * @return true if the given sequence can be rendered as a single glyph, otherwise false.
+ */
+ boolean hasGlyph(
+ @NonNull CharSequence charSequence,
+ @IntRange(from = 0) int start,
+ @IntRange(from = 0) int end,
+ @IntRange(from = 0) int sdkAdded
+ );
+ }
+
+ /**
* Callback to inform EmojiCompat about the state of the metadata load. Passed to
* MetadataRepoLoader during {@link MetadataRepoLoader#load(MetadataRepoLoaderCallback)} call.
*/
@@ -908,6 +973,8 @@
int mEmojiSpanIndicatorColor = Color.GREEN;
@SuppressWarnings("WeakerAccess") /* synthetic access */
@LoadStrategy int mMetadataLoadStrategy = LOAD_STRATEGY_DEFAULT;
+ @SuppressWarnings("WeakerAccess") /* synthetic access */
+ GlyphChecker mGlyphChecker = new EmojiProcessor.DefaultGlyphChecker();
/**
* Default constructor.
@@ -1082,6 +1149,19 @@
}
/**
+ * The interface that is used by EmojiCompat in order to check if a given emoji can be
+ * rendered by the system.
+ *
+ * @param glyphChecker {@link GlyphChecker} instance to be used.
+ */
+ @NonNull
+ public Config setGlyphChecker(@NonNull GlyphChecker glyphChecker) {
+ Preconditions.checkNotNull(glyphChecker, "GlyphChecker cannot be null");
+ mGlyphChecker = glyphChecker;
+ return this;
+ }
+
+ /**
* Returns the {@link MetadataRepoLoader}.
*/
protected final MetadataRepoLoader getMetadataRepoLoader() {
@@ -1173,10 +1253,6 @@
// Does not add any EditorInfo attributes.
}
- void setGlyphChecker(@NonNull EmojiProcessor.GlyphChecker glyphChecker) {
- // intentionally empty
- }
-
String getAssetSignature() {
return "";
}
@@ -1220,7 +1296,7 @@
}
}
- @SuppressWarnings("WeakerAccess") /* synthetic access */
+ @SuppressWarnings("SyntheticAccessor")
void onMetadataLoadSuccess(@NonNull final MetadataRepo metadataRepo) {
//noinspection ConstantConditions
if (metadataRepo == null) {
@@ -1230,7 +1306,10 @@
}
mMetadataRepo = metadataRepo;
- mProcessor = new EmojiProcessor(mMetadataRepo, new SpanFactory(),
+ mProcessor = new EmojiProcessor(
+ mMetadataRepo,
+ new SpanFactory(),
+ mEmojiCompat.mGlyphChecker,
mEmojiCompat.mUseEmojiAsDefaultStyle,
mEmojiCompat.mEmojiAsDefaultStyleExceptions);
@@ -1261,11 +1340,6 @@
}
@Override
- void setGlyphChecker(@NonNull EmojiProcessor.GlyphChecker glyphChecker) {
- mProcessor.setGlyphChecker(glyphChecker);
- }
-
- @Override
String getAssetSignature() {
final String sha = mMetadataRepo.getMetadataList().sourceSha();
return sha == null ? "" : sha;
diff --git a/emoji/core/src/main/java/androidx/emoji/text/EmojiProcessor.java b/emoji/core/src/main/java/androidx/emoji/text/EmojiProcessor.java
index 51dcc116..1ed58a9 100644
--- a/emoji/core/src/main/java/androidx/emoji/text/EmojiProcessor.java
+++ b/emoji/core/src/main/java/androidx/emoji/text/EmojiProcessor.java
@@ -37,7 +37,6 @@
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.core.graphics.PaintCompat;
-import androidx.core.util.Preconditions;
import androidx.emoji.widget.SpannableBuilder;
import java.lang.annotation.Retention;
@@ -92,7 +91,7 @@
/**
* Utility class that checks if the system can render a given glyph.
*/
- private GlyphChecker mGlyphChecker = new GlyphChecker();
+ private EmojiCompat.GlyphChecker mGlyphChecker;
/**
* @see EmojiCompat.Config#setUseEmojiAsDefaultStyle(boolean)
@@ -104,12 +103,16 @@
*/
private final int[] mEmojiAsDefaultStyleExceptions;
- EmojiProcessor(@NonNull final MetadataRepo metadataRepo,
+ EmojiProcessor(
+ @NonNull final MetadataRepo metadataRepo,
@NonNull final EmojiCompat.SpanFactory spanFactory,
+ @NonNull final EmojiCompat.GlyphChecker glyphChecker,
final boolean useEmojiAsDefaultStyle,
- @Nullable final int[] emojiAsDefaultStyleExceptions) {
+ @Nullable final int[] emojiAsDefaultStyleExceptions
+ ) {
mSpanFactory = spanFactory;
mMetadataRepo = metadataRepo;
+ mGlyphChecker = glyphChecker;
mUseEmojiAsDefaultStyle = useEmojiAsDefaultStyle;
mEmojiAsDefaultStyleExceptions = emojiAsDefaultStyleExceptions;
}
@@ -452,16 +455,10 @@
*/
private boolean hasGlyph(final CharSequence charSequence, int start, final int end,
final EmojiMetadata metadata) {
- // For pre M devices, heuristic in PaintCompat can result in false positives. we are
- // adding another heuristic using the sdkAdded field. if the emoji was added to OS
- // at a later version we assume that the system probably cannot render it.
- if (Build.VERSION.SDK_INT < 23 && metadata.getSdkAdded() > Build.VERSION.SDK_INT) {
- return false;
- }
-
// if the existence is not calculated yet
if (metadata.getHasGlyph() == EmojiMetadata.HAS_GLYPH_UNKNOWN) {
- final boolean hasGlyph = mGlyphChecker.hasGlyph(charSequence, start, end);
+ final boolean hasGlyph = mGlyphChecker.hasGlyph(charSequence, start, end,
+ metadata.getSdkAdded());
metadata.setHasGlyph(hasGlyph);
}
@@ -469,14 +466,6 @@
}
/**
- * Set the GlyphChecker instance used by EmojiProcessor. Used for testing.
- */
- void setGlyphChecker(@NonNull final GlyphChecker glyphChecker) {
- Preconditions.checkNotNull(glyphChecker);
- mGlyphChecker = glyphChecker;
- }
-
- /**
* State machine for walking over the metadata trie.
*/
static final class ProcessorSm {
@@ -788,7 +777,7 @@
*/
@AnyThread
@RestrictTo(LIBRARY_GROUP_PREFIX)
- public static class GlyphChecker {
+ public static class DefaultGlyphChecker implements EmojiCompat.GlyphChecker {
/**
* Default text size for {@link #mTextPaint}.
*/
@@ -805,21 +794,25 @@
*/
private final TextPaint mTextPaint;
- GlyphChecker() {
+ DefaultGlyphChecker() {
mTextPaint = new TextPaint();
mTextPaint.setTextSize(PAINT_TEXT_SIZE);
}
- /**
- * Returns whether the system can render an emoji.
- *
- * @param charSequence the CharSequence that the emoji is in
- * @param start start index of the emoji in the CharSequence
- * @param end end index of the emoji in the CharSequence
- *
- * @return {@code true} if the OS can render emoji, {@code false} otherwise
- */
- public boolean hasGlyph(final CharSequence charSequence, int start, final int end) {
+ @Override
+ public boolean hasGlyph(
+ @NonNull CharSequence charSequence,
+ int start,
+ int end,
+ int sdkAdded
+ ) {
+ // For pre M devices, heuristic in PaintCompat can result in false positives. we are
+ // adding another heuristic using the sdkAdded field. if the emoji was added to OS
+ // at a later version we assume that the system probably cannot render it.
+ if (Build.VERSION.SDK_INT < 23 && sdkAdded > Build.VERSION.SDK_INT) {
+ return false;
+ }
+
final StringBuilder builder = getStringBuilder();
builder.setLength(0);
@@ -837,6 +830,5 @@
}
return sStringBuilder.get();
}
-
}
}
diff --git a/fragment/.idea/codeStyles/Project.xml b/fragment/.idea/codeStyles/Project.xml
new file mode 120000
index 0000000..b52b28c
--- /dev/null
+++ b/fragment/.idea/codeStyles/Project.xml
@@ -0,0 +1 @@
+../../../.idea/codeStyles/Project.xml
\ No newline at end of file
diff --git a/fragment/.idea/codeStyles/codeStyleConfig.xml b/fragment/.idea/codeStyles/codeStyleConfig.xml
new file mode 120000
index 0000000..19c4848
--- /dev/null
+++ b/fragment/.idea/codeStyles/codeStyleConfig.xml
@@ -0,0 +1 @@
+../../../.idea/codeStyles/codeStyleConfig.xml
\ No newline at end of file
diff --git a/fragment/.idea/copyright/AndroidCopyright.xml b/fragment/.idea/copyright/AndroidCopyright.xml
new file mode 120000
index 0000000..afbbd04
--- /dev/null
+++ b/fragment/.idea/copyright/AndroidCopyright.xml
@@ -0,0 +1 @@
+../../../.idea/copyright/AndroidCopyright.xml
\ No newline at end of file
diff --git a/fragment/.idea/copyright/profiles_settings.xml b/fragment/.idea/copyright/profiles_settings.xml
new file mode 120000
index 0000000..5996ccd
--- /dev/null
+++ b/fragment/.idea/copyright/profiles_settings.xml
@@ -0,0 +1 @@
+../../../.idea/copyright/profiles_settings.xml
\ No newline at end of file
diff --git a/fragment/.idea/inspectionProfiles/Project_Default.xml b/fragment/.idea/inspectionProfiles/Project_Default.xml
new file mode 120000
index 0000000..a7481f4
--- /dev/null
+++ b/fragment/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1 @@
+../../../.idea/inspectionProfiles/Project_Default.xml
\ No newline at end of file
diff --git a/fragment/.idea/scopes/Ignore_API_Files.xml b/fragment/.idea/scopes/Ignore_API_Files.xml
new file mode 120000
index 0000000..3361ee1
--- /dev/null
+++ b/fragment/.idea/scopes/Ignore_API_Files.xml
@@ -0,0 +1 @@
+../../../.idea/scopes/Ignore_API_Files.xml
\ No newline at end of file
diff --git a/fragment/.idea/scopes/buildSrc.xml b/fragment/.idea/scopes/buildSrc.xml
new file mode 120000
index 0000000..25b7d3b
--- /dev/null
+++ b/fragment/.idea/scopes/buildSrc.xml
@@ -0,0 +1 @@
+../../../.idea/scopes/buildSrc.xml
\ No newline at end of file
diff --git a/fragment/fragment-ktx/api/1.3.0-beta02.txt b/fragment/fragment-ktx/api/1.3.0-beta02.txt
new file mode 100644
index 0000000..64ef804
--- /dev/null
+++ b/fragment/fragment-ktx/api/1.3.0-beta02.txt
@@ -0,0 +1,34 @@
+// Signature format: 4.0
+package androidx.fragment.app {
+
+ public final class FragmentKt {
+ method public static void clearFragmentResult(androidx.fragment.app.Fragment, String requestKey);
+ method public static void clearFragmentResultListener(androidx.fragment.app.Fragment, String requestKey);
+ method public static void setFragmentResult(androidx.fragment.app.Fragment, String requestKey, android.os.Bundle result);
+ method public static void setFragmentResultListener(androidx.fragment.app.Fragment, String requestKey, kotlin.jvm.functions.Function2<? super java.lang.String,? super android.os.Bundle,kotlin.Unit> listener);
+ }
+
+ public final class FragmentManagerKt {
+ method public static inline void commit(androidx.fragment.app.FragmentManager, optional boolean allowStateLoss, kotlin.jvm.functions.Function1<? super androidx.fragment.app.FragmentTransaction,kotlin.Unit> body);
+ method public static inline void commitNow(androidx.fragment.app.FragmentManager, optional boolean allowStateLoss, kotlin.jvm.functions.Function1<? super androidx.fragment.app.FragmentTransaction,kotlin.Unit> body);
+ method @Deprecated public static inline void transaction(androidx.fragment.app.FragmentManager, optional boolean now, optional boolean allowStateLoss, kotlin.jvm.functions.Function1<? super androidx.fragment.app.FragmentTransaction,kotlin.Unit> body);
+ }
+
+ public final class FragmentTransactionKt {
+ method public static inline <reified F extends androidx.fragment.app.Fragment> androidx.fragment.app.FragmentTransaction! add(androidx.fragment.app.FragmentTransaction, @IdRes int containerViewId, optional String tag, optional android.os.Bundle? args);
+ method public static inline <reified F extends androidx.fragment.app.Fragment> androidx.fragment.app.FragmentTransaction! add(androidx.fragment.app.FragmentTransaction, String tag, optional android.os.Bundle? args);
+ method public static inline <reified F extends androidx.fragment.app.Fragment> androidx.fragment.app.FragmentTransaction! replace(androidx.fragment.app.FragmentTransaction, @IdRes int containerViewId, optional String tag, optional android.os.Bundle? args);
+ }
+
+ public final class FragmentViewModelLazyKt {
+ method @MainThread public static inline <reified VM extends androidx.lifecycle.ViewModel> kotlin.Lazy<? extends VM>! activityViewModels(androidx.fragment.app.Fragment, optional kotlin.jvm.functions.Function0<? extends androidx.lifecycle.ViewModelProvider.Factory>? factoryProducer);
+ method @MainThread public static <VM extends androidx.lifecycle.ViewModel> kotlin.Lazy<VM> createViewModelLazy(androidx.fragment.app.Fragment, kotlin.reflect.KClass<VM> viewModelClass, kotlin.jvm.functions.Function0<? extends androidx.lifecycle.ViewModelStore> storeProducer, optional kotlin.jvm.functions.Function0<? extends androidx.lifecycle.ViewModelProvider.Factory>? factoryProducer);
+ method @MainThread public static inline <reified VM extends androidx.lifecycle.ViewModel> kotlin.Lazy<? extends VM>! viewModels(androidx.fragment.app.Fragment, optional kotlin.jvm.functions.Function0<? extends androidx.lifecycle.ViewModelStoreOwner> ownerProducer, optional kotlin.jvm.functions.Function0<? extends androidx.lifecycle.ViewModelProvider.Factory>? factoryProducer);
+ }
+
+ public final class ViewKt {
+ method public static <F extends androidx.fragment.app.Fragment> F findFragment(android.view.View);
+ }
+
+}
+
diff --git a/fragment/fragment-ktx/api/public_plus_experimental_1.3.0-beta02.txt b/fragment/fragment-ktx/api/public_plus_experimental_1.3.0-beta02.txt
new file mode 100644
index 0000000..64ef804
--- /dev/null
+++ b/fragment/fragment-ktx/api/public_plus_experimental_1.3.0-beta02.txt
@@ -0,0 +1,34 @@
+// Signature format: 4.0
+package androidx.fragment.app {
+
+ public final class FragmentKt {
+ method public static void clearFragmentResult(androidx.fragment.app.Fragment, String requestKey);
+ method public static void clearFragmentResultListener(androidx.fragment.app.Fragment, String requestKey);
+ method public static void setFragmentResult(androidx.fragment.app.Fragment, String requestKey, android.os.Bundle result);
+ method public static void setFragmentResultListener(androidx.fragment.app.Fragment, String requestKey, kotlin.jvm.functions.Function2<? super java.lang.String,? super android.os.Bundle,kotlin.Unit> listener);
+ }
+
+ public final class FragmentManagerKt {
+ method public static inline void commit(androidx.fragment.app.FragmentManager, optional boolean allowStateLoss, kotlin.jvm.functions.Function1<? super androidx.fragment.app.FragmentTransaction,kotlin.Unit> body);
+ method public static inline void commitNow(androidx.fragment.app.FragmentManager, optional boolean allowStateLoss, kotlin.jvm.functions.Function1<? super androidx.fragment.app.FragmentTransaction,kotlin.Unit> body);
+ method @Deprecated public static inline void transaction(androidx.fragment.app.FragmentManager, optional boolean now, optional boolean allowStateLoss, kotlin.jvm.functions.Function1<? super androidx.fragment.app.FragmentTransaction,kotlin.Unit> body);
+ }
+
+ public final class FragmentTransactionKt {
+ method public static inline <reified F extends androidx.fragment.app.Fragment> androidx.fragment.app.FragmentTransaction! add(androidx.fragment.app.FragmentTransaction, @IdRes int containerViewId, optional String tag, optional android.os.Bundle? args);
+ method public static inline <reified F extends androidx.fragment.app.Fragment> androidx.fragment.app.FragmentTransaction! add(androidx.fragment.app.FragmentTransaction, String tag, optional android.os.Bundle? args);
+ method public static inline <reified F extends androidx.fragment.app.Fragment> androidx.fragment.app.FragmentTransaction! replace(androidx.fragment.app.FragmentTransaction, @IdRes int containerViewId, optional String tag, optional android.os.Bundle? args);
+ }
+
+ public final class FragmentViewModelLazyKt {
+ method @MainThread public static inline <reified VM extends androidx.lifecycle.ViewModel> kotlin.Lazy<? extends VM>! activityViewModels(androidx.fragment.app.Fragment, optional kotlin.jvm.functions.Function0<? extends androidx.lifecycle.ViewModelProvider.Factory>? factoryProducer);
+ method @MainThread public static <VM extends androidx.lifecycle.ViewModel> kotlin.Lazy<VM> createViewModelLazy(androidx.fragment.app.Fragment, kotlin.reflect.KClass<VM> viewModelClass, kotlin.jvm.functions.Function0<? extends androidx.lifecycle.ViewModelStore> storeProducer, optional kotlin.jvm.functions.Function0<? extends androidx.lifecycle.ViewModelProvider.Factory>? factoryProducer);
+ method @MainThread public static inline <reified VM extends androidx.lifecycle.ViewModel> kotlin.Lazy<? extends VM>! viewModels(androidx.fragment.app.Fragment, optional kotlin.jvm.functions.Function0<? extends androidx.lifecycle.ViewModelStoreOwner> ownerProducer, optional kotlin.jvm.functions.Function0<? extends androidx.lifecycle.ViewModelProvider.Factory>? factoryProducer);
+ }
+
+ public final class ViewKt {
+ method public static <F extends androidx.fragment.app.Fragment> F findFragment(android.view.View);
+ }
+
+}
+
diff --git a/fragment/fragment-ktx/api/res-1.3.0-beta02.txt b/fragment/fragment-ktx/api/res-1.3.0-beta02.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/fragment/fragment-ktx/api/res-1.3.0-beta02.txt
diff --git a/fragment/fragment-ktx/api/restricted_1.3.0-beta02.txt b/fragment/fragment-ktx/api/restricted_1.3.0-beta02.txt
new file mode 100644
index 0000000..64ef804
--- /dev/null
+++ b/fragment/fragment-ktx/api/restricted_1.3.0-beta02.txt
@@ -0,0 +1,34 @@
+// Signature format: 4.0
+package androidx.fragment.app {
+
+ public final class FragmentKt {
+ method public static void clearFragmentResult(androidx.fragment.app.Fragment, String requestKey);
+ method public static void clearFragmentResultListener(androidx.fragment.app.Fragment, String requestKey);
+ method public static void setFragmentResult(androidx.fragment.app.Fragment, String requestKey, android.os.Bundle result);
+ method public static void setFragmentResultListener(androidx.fragment.app.Fragment, String requestKey, kotlin.jvm.functions.Function2<? super java.lang.String,? super android.os.Bundle,kotlin.Unit> listener);
+ }
+
+ public final class FragmentManagerKt {
+ method public static inline void commit(androidx.fragment.app.FragmentManager, optional boolean allowStateLoss, kotlin.jvm.functions.Function1<? super androidx.fragment.app.FragmentTransaction,kotlin.Unit> body);
+ method public static inline void commitNow(androidx.fragment.app.FragmentManager, optional boolean allowStateLoss, kotlin.jvm.functions.Function1<? super androidx.fragment.app.FragmentTransaction,kotlin.Unit> body);
+ method @Deprecated public static inline void transaction(androidx.fragment.app.FragmentManager, optional boolean now, optional boolean allowStateLoss, kotlin.jvm.functions.Function1<? super androidx.fragment.app.FragmentTransaction,kotlin.Unit> body);
+ }
+
+ public final class FragmentTransactionKt {
+ method public static inline <reified F extends androidx.fragment.app.Fragment> androidx.fragment.app.FragmentTransaction! add(androidx.fragment.app.FragmentTransaction, @IdRes int containerViewId, optional String tag, optional android.os.Bundle? args);
+ method public static inline <reified F extends androidx.fragment.app.Fragment> androidx.fragment.app.FragmentTransaction! add(androidx.fragment.app.FragmentTransaction, String tag, optional android.os.Bundle? args);
+ method public static inline <reified F extends androidx.fragment.app.Fragment> androidx.fragment.app.FragmentTransaction! replace(androidx.fragment.app.FragmentTransaction, @IdRes int containerViewId, optional String tag, optional android.os.Bundle? args);
+ }
+
+ public final class FragmentViewModelLazyKt {
+ method @MainThread public static inline <reified VM extends androidx.lifecycle.ViewModel> kotlin.Lazy<? extends VM>! activityViewModels(androidx.fragment.app.Fragment, optional kotlin.jvm.functions.Function0<? extends androidx.lifecycle.ViewModelProvider.Factory>? factoryProducer);
+ method @MainThread public static <VM extends androidx.lifecycle.ViewModel> kotlin.Lazy<VM> createViewModelLazy(androidx.fragment.app.Fragment, kotlin.reflect.KClass<VM> viewModelClass, kotlin.jvm.functions.Function0<? extends androidx.lifecycle.ViewModelStore> storeProducer, optional kotlin.jvm.functions.Function0<? extends androidx.lifecycle.ViewModelProvider.Factory>? factoryProducer);
+ method @MainThread public static inline <reified VM extends androidx.lifecycle.ViewModel> kotlin.Lazy<? extends VM>! viewModels(androidx.fragment.app.Fragment, optional kotlin.jvm.functions.Function0<? extends androidx.lifecycle.ViewModelStoreOwner> ownerProducer, optional kotlin.jvm.functions.Function0<? extends androidx.lifecycle.ViewModelProvider.Factory>? factoryProducer);
+ }
+
+ public final class ViewKt {
+ method public static <F extends androidx.fragment.app.Fragment> F findFragment(android.view.View);
+ }
+
+}
+
diff --git a/fragment/fragment-ktx/build.gradle b/fragment/fragment-ktx/build.gradle
index 9932a5c..88435eb 100644
--- a/fragment/fragment-ktx/build.gradle
+++ b/fragment/fragment-ktx/build.gradle
@@ -27,7 +27,7 @@
dependencies {
api(project(":fragment:fragment"))
- api(project(":activity:activity-ktx")) {
+ api(projectOrArtifact(":activity:activity-ktx")) {
because 'Mirror fragment dependency graph for -ktx artifacts'
}
api("androidx.core:core-ktx:1.1.0") {
@@ -36,11 +36,11 @@
api("androidx.collection:collection-ktx:1.1.0") {
because 'Mirror fragment dependency graph for -ktx artifacts'
}
- api(project(":lifecycle:lifecycle-livedata-core-ktx")) {
+ api(projectOrArtifact(":lifecycle:lifecycle-livedata-core-ktx")) {
because 'Mirror fragment dependency graph for -ktx artifacts'
}
- api(project(":lifecycle:lifecycle-viewmodel-ktx"))
- api(project(":savedstate:savedstate-ktx")) {
+ api(projectOrArtifact(":lifecycle:lifecycle-viewmodel-ktx"))
+ api(projectOrArtifact(":savedstate:savedstate-ktx")) {
because 'Mirror fragment dependency graph for -ktx artifacts'
}
api(KOTLIN_STDLIB)
diff --git a/fragment/fragment-testing/api/1.3.0-beta02.txt b/fragment/fragment-testing/api/1.3.0-beta02.txt
new file mode 100644
index 0000000..4838040
--- /dev/null
+++ b/fragment/fragment-testing/api/1.3.0-beta02.txt
@@ -0,0 +1,59 @@
+// Signature format: 4.0
+package androidx.fragment.app.testing {
+
+ public final class FragmentScenario<F extends androidx.fragment.app.Fragment> {
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, androidx.fragment.app.FragmentFactory? factory);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, @StyleRes int themeResId, androidx.fragment.app.FragmentFactory? factory);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState, optional androidx.fragment.app.FragmentFactory? factory);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, androidx.fragment.app.FragmentFactory? factory);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, @StyleRes int themeResId, androidx.fragment.app.FragmentFactory? factory);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState, optional androidx.fragment.app.FragmentFactory? factory);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass);
+ method public androidx.fragment.app.testing.FragmentScenario<F> moveToState(androidx.lifecycle.Lifecycle.State newState);
+ method public androidx.fragment.app.testing.FragmentScenario<F> onFragment(androidx.fragment.app.testing.FragmentScenario.FragmentAction<F> action);
+ method public androidx.fragment.app.testing.FragmentScenario<F> recreate();
+ field public static final androidx.fragment.app.testing.FragmentScenario.Companion Companion;
+ }
+
+ public static final class FragmentScenario.Companion {
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, androidx.fragment.app.FragmentFactory? factory);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, @StyleRes int themeResId, androidx.fragment.app.FragmentFactory? factory);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState, optional androidx.fragment.app.FragmentFactory? factory);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, androidx.fragment.app.FragmentFactory? factory);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, @StyleRes int themeResId, androidx.fragment.app.FragmentFactory? factory);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState, optional androidx.fragment.app.FragmentFactory? factory);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass);
+ }
+
+ public static fun interface FragmentScenario.FragmentAction<F extends androidx.fragment.app.Fragment> {
+ method public void perform(F fragment);
+ }
+
+ public final class FragmentScenarioKt {
+ method public static inline <reified F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F>! launchFragment(optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.fragment.app.FragmentFactory? factory);
+ method public static inline <reified F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F>! launchFragment(optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, kotlin.jvm.functions.Function0<? extends F> instantiate);
+ method public static inline <reified F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F>! launchFragment(optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState, optional androidx.fragment.app.FragmentFactory? factory);
+ method public static inline <reified F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F>! launchFragment(optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState, kotlin.jvm.functions.Function0<? extends F> instantiate);
+ method public static inline <reified F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F>! launchFragmentInContainer(optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.fragment.app.FragmentFactory? factory);
+ method public static inline <reified F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F>! launchFragmentInContainer(optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, kotlin.jvm.functions.Function0<? extends F> instantiate);
+ method public static inline <reified F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F>! launchFragmentInContainer(optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState, optional androidx.fragment.app.FragmentFactory? factory);
+ method public static inline <reified F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F>! launchFragmentInContainer(optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState, kotlin.jvm.functions.Function0<? extends F> instantiate);
+ method public static inline <reified F extends androidx.fragment.app.Fragment, T> T! withFragment(androidx.fragment.app.testing.FragmentScenario<F>, kotlin.jvm.functions.Function1<? super F,? extends T> block);
+ }
+
+}
+
diff --git a/fragment/fragment-testing/api/current.ignore b/fragment/fragment-testing/api/current.ignore
new file mode 100644
index 0000000..aff4f36
--- /dev/null
+++ b/fragment/fragment-testing/api/current.ignore
@@ -0,0 +1,27 @@
+// Baseline format: 1.0
+ChangedType: androidx.fragment.app.testing.FragmentScenario#launch(Class<F>):
+ Method androidx.fragment.app.testing.FragmentScenario.launch has changed return type from androidx.fragment.app.testing.FragmentScenario<F!> to androidx.fragment.app.testing.FragmentScenario<F>
+ChangedType: androidx.fragment.app.testing.FragmentScenario#launch(Class<F>, android.os.Bundle):
+ Method androidx.fragment.app.testing.FragmentScenario.launch has changed return type from androidx.fragment.app.testing.FragmentScenario<F!> to androidx.fragment.app.testing.FragmentScenario<F>
+ChangedType: androidx.fragment.app.testing.FragmentScenario#launch(Class<F>, android.os.Bundle, androidx.fragment.app.FragmentFactory):
+ Method androidx.fragment.app.testing.FragmentScenario.launch has changed return type from androidx.fragment.app.testing.FragmentScenario<F!> to androidx.fragment.app.testing.FragmentScenario<F>
+ChangedType: androidx.fragment.app.testing.FragmentScenario#launch(Class<F>, android.os.Bundle, int, androidx.fragment.app.FragmentFactory):
+ Method androidx.fragment.app.testing.FragmentScenario.launch has changed return type from androidx.fragment.app.testing.FragmentScenario<F!> to androidx.fragment.app.testing.FragmentScenario<F>
+ChangedType: androidx.fragment.app.testing.FragmentScenario#launch(Class<F>, android.os.Bundle, int, androidx.lifecycle.Lifecycle.State, androidx.fragment.app.FragmentFactory):
+ Method androidx.fragment.app.testing.FragmentScenario.launch has changed return type from androidx.fragment.app.testing.FragmentScenario<F!> to androidx.fragment.app.testing.FragmentScenario<F>
+ChangedType: androidx.fragment.app.testing.FragmentScenario#launchInContainer(Class<F>):
+ Method androidx.fragment.app.testing.FragmentScenario.launchInContainer has changed return type from androidx.fragment.app.testing.FragmentScenario<F!> to androidx.fragment.app.testing.FragmentScenario<F>
+ChangedType: androidx.fragment.app.testing.FragmentScenario#launchInContainer(Class<F>, android.os.Bundle):
+ Method androidx.fragment.app.testing.FragmentScenario.launchInContainer has changed return type from androidx.fragment.app.testing.FragmentScenario<F!> to androidx.fragment.app.testing.FragmentScenario<F>
+ChangedType: androidx.fragment.app.testing.FragmentScenario#launchInContainer(Class<F>, android.os.Bundle, androidx.fragment.app.FragmentFactory):
+ Method androidx.fragment.app.testing.FragmentScenario.launchInContainer has changed return type from androidx.fragment.app.testing.FragmentScenario<F!> to androidx.fragment.app.testing.FragmentScenario<F>
+ChangedType: androidx.fragment.app.testing.FragmentScenario#launchInContainer(Class<F>, android.os.Bundle, int, androidx.fragment.app.FragmentFactory):
+ Method androidx.fragment.app.testing.FragmentScenario.launchInContainer has changed return type from androidx.fragment.app.testing.FragmentScenario<F!> to androidx.fragment.app.testing.FragmentScenario<F>
+ChangedType: androidx.fragment.app.testing.FragmentScenario#launchInContainer(Class<F>, android.os.Bundle, int, androidx.lifecycle.Lifecycle.State, androidx.fragment.app.FragmentFactory):
+ Method androidx.fragment.app.testing.FragmentScenario.launchInContainer has changed return type from androidx.fragment.app.testing.FragmentScenario<F!> to androidx.fragment.app.testing.FragmentScenario<F>
+ChangedType: androidx.fragment.app.testing.FragmentScenario#moveToState(androidx.lifecycle.Lifecycle.State):
+ Method androidx.fragment.app.testing.FragmentScenario.moveToState has changed return type from androidx.fragment.app.testing.FragmentScenario<F!> to androidx.fragment.app.testing.FragmentScenario<F>
+ChangedType: androidx.fragment.app.testing.FragmentScenario#onFragment(androidx.fragment.app.testing.FragmentScenario.FragmentAction<F>):
+ Method androidx.fragment.app.testing.FragmentScenario.onFragment has changed return type from androidx.fragment.app.testing.FragmentScenario<F!> to androidx.fragment.app.testing.FragmentScenario<F>
+ChangedType: androidx.fragment.app.testing.FragmentScenario#recreate():
+ Method androidx.fragment.app.testing.FragmentScenario.recreate has changed return type from androidx.fragment.app.testing.FragmentScenario<F!> to androidx.fragment.app.testing.FragmentScenario<F>
diff --git a/fragment/fragment-testing/api/current.txt b/fragment/fragment-testing/api/current.txt
index 5486858..4838040 100644
--- a/fragment/fragment-testing/api/current.txt
+++ b/fragment/fragment-testing/api/current.txt
@@ -2,23 +2,45 @@
package androidx.fragment.app.testing {
public final class FragmentScenario<F extends androidx.fragment.app.Fragment> {
- method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F!> launch(Class<F!>);
- method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F!> launch(Class<F!>, android.os.Bundle?);
- method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F!> launch(Class<F!>, android.os.Bundle?, androidx.fragment.app.FragmentFactory?);
- method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F!> launch(Class<F!>, android.os.Bundle?, @StyleRes int, androidx.fragment.app.FragmentFactory?);
- method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F!> launch(Class<F!>, android.os.Bundle?, @StyleRes int, androidx.lifecycle.Lifecycle.State, androidx.fragment.app.FragmentFactory?);
- method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F!> launchInContainer(Class<F!>);
- method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F!> launchInContainer(Class<F!>, android.os.Bundle?);
- method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F!> launchInContainer(Class<F!>, android.os.Bundle?, androidx.fragment.app.FragmentFactory?);
- method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F!> launchInContainer(Class<F!>, android.os.Bundle?, @StyleRes int, androidx.fragment.app.FragmentFactory?);
- method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F!> launchInContainer(Class<F!>, android.os.Bundle?, @StyleRes int, androidx.lifecycle.Lifecycle.State, androidx.fragment.app.FragmentFactory?);
- method public androidx.fragment.app.testing.FragmentScenario<F!> moveToState(androidx.lifecycle.Lifecycle.State);
- method public androidx.fragment.app.testing.FragmentScenario<F!> onFragment(androidx.fragment.app.testing.FragmentScenario.FragmentAction<F!>);
- method public androidx.fragment.app.testing.FragmentScenario<F!> recreate();
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, androidx.fragment.app.FragmentFactory? factory);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, @StyleRes int themeResId, androidx.fragment.app.FragmentFactory? factory);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState, optional androidx.fragment.app.FragmentFactory? factory);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, androidx.fragment.app.FragmentFactory? factory);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, @StyleRes int themeResId, androidx.fragment.app.FragmentFactory? factory);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState, optional androidx.fragment.app.FragmentFactory? factory);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass);
+ method public androidx.fragment.app.testing.FragmentScenario<F> moveToState(androidx.lifecycle.Lifecycle.State newState);
+ method public androidx.fragment.app.testing.FragmentScenario<F> onFragment(androidx.fragment.app.testing.FragmentScenario.FragmentAction<F> action);
+ method public androidx.fragment.app.testing.FragmentScenario<F> recreate();
+ field public static final androidx.fragment.app.testing.FragmentScenario.Companion Companion;
}
- public static interface FragmentScenario.FragmentAction<F extends androidx.fragment.app.Fragment> {
- method public void perform(F);
+ public static final class FragmentScenario.Companion {
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, androidx.fragment.app.FragmentFactory? factory);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, @StyleRes int themeResId, androidx.fragment.app.FragmentFactory? factory);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState, optional androidx.fragment.app.FragmentFactory? factory);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, androidx.fragment.app.FragmentFactory? factory);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, @StyleRes int themeResId, androidx.fragment.app.FragmentFactory? factory);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState, optional androidx.fragment.app.FragmentFactory? factory);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass);
+ }
+
+ public static fun interface FragmentScenario.FragmentAction<F extends androidx.fragment.app.Fragment> {
+ method public void perform(F fragment);
}
public final class FragmentScenarioKt {
diff --git a/fragment/fragment-testing/api/public_plus_experimental_1.3.0-beta02.txt b/fragment/fragment-testing/api/public_plus_experimental_1.3.0-beta02.txt
new file mode 100644
index 0000000..4838040
--- /dev/null
+++ b/fragment/fragment-testing/api/public_plus_experimental_1.3.0-beta02.txt
@@ -0,0 +1,59 @@
+// Signature format: 4.0
+package androidx.fragment.app.testing {
+
+ public final class FragmentScenario<F extends androidx.fragment.app.Fragment> {
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, androidx.fragment.app.FragmentFactory? factory);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, @StyleRes int themeResId, androidx.fragment.app.FragmentFactory? factory);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState, optional androidx.fragment.app.FragmentFactory? factory);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, androidx.fragment.app.FragmentFactory? factory);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, @StyleRes int themeResId, androidx.fragment.app.FragmentFactory? factory);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState, optional androidx.fragment.app.FragmentFactory? factory);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass);
+ method public androidx.fragment.app.testing.FragmentScenario<F> moveToState(androidx.lifecycle.Lifecycle.State newState);
+ method public androidx.fragment.app.testing.FragmentScenario<F> onFragment(androidx.fragment.app.testing.FragmentScenario.FragmentAction<F> action);
+ method public androidx.fragment.app.testing.FragmentScenario<F> recreate();
+ field public static final androidx.fragment.app.testing.FragmentScenario.Companion Companion;
+ }
+
+ public static final class FragmentScenario.Companion {
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, androidx.fragment.app.FragmentFactory? factory);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, @StyleRes int themeResId, androidx.fragment.app.FragmentFactory? factory);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState, optional androidx.fragment.app.FragmentFactory? factory);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, androidx.fragment.app.FragmentFactory? factory);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, @StyleRes int themeResId, androidx.fragment.app.FragmentFactory? factory);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState, optional androidx.fragment.app.FragmentFactory? factory);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass);
+ }
+
+ public static fun interface FragmentScenario.FragmentAction<F extends androidx.fragment.app.Fragment> {
+ method public void perform(F fragment);
+ }
+
+ public final class FragmentScenarioKt {
+ method public static inline <reified F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F>! launchFragment(optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.fragment.app.FragmentFactory? factory);
+ method public static inline <reified F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F>! launchFragment(optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, kotlin.jvm.functions.Function0<? extends F> instantiate);
+ method public static inline <reified F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F>! launchFragment(optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState, optional androidx.fragment.app.FragmentFactory? factory);
+ method public static inline <reified F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F>! launchFragment(optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState, kotlin.jvm.functions.Function0<? extends F> instantiate);
+ method public static inline <reified F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F>! launchFragmentInContainer(optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.fragment.app.FragmentFactory? factory);
+ method public static inline <reified F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F>! launchFragmentInContainer(optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, kotlin.jvm.functions.Function0<? extends F> instantiate);
+ method public static inline <reified F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F>! launchFragmentInContainer(optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState, optional androidx.fragment.app.FragmentFactory? factory);
+ method public static inline <reified F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F>! launchFragmentInContainer(optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState, kotlin.jvm.functions.Function0<? extends F> instantiate);
+ method public static inline <reified F extends androidx.fragment.app.Fragment, T> T! withFragment(androidx.fragment.app.testing.FragmentScenario<F>, kotlin.jvm.functions.Function1<? super F,? extends T> block);
+ }
+
+}
+
diff --git a/fragment/fragment-testing/api/public_plus_experimental_current.txt b/fragment/fragment-testing/api/public_plus_experimental_current.txt
index 5486858..4838040 100644
--- a/fragment/fragment-testing/api/public_plus_experimental_current.txt
+++ b/fragment/fragment-testing/api/public_plus_experimental_current.txt
@@ -2,23 +2,45 @@
package androidx.fragment.app.testing {
public final class FragmentScenario<F extends androidx.fragment.app.Fragment> {
- method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F!> launch(Class<F!>);
- method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F!> launch(Class<F!>, android.os.Bundle?);
- method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F!> launch(Class<F!>, android.os.Bundle?, androidx.fragment.app.FragmentFactory?);
- method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F!> launch(Class<F!>, android.os.Bundle?, @StyleRes int, androidx.fragment.app.FragmentFactory?);
- method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F!> launch(Class<F!>, android.os.Bundle?, @StyleRes int, androidx.lifecycle.Lifecycle.State, androidx.fragment.app.FragmentFactory?);
- method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F!> launchInContainer(Class<F!>);
- method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F!> launchInContainer(Class<F!>, android.os.Bundle?);
- method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F!> launchInContainer(Class<F!>, android.os.Bundle?, androidx.fragment.app.FragmentFactory?);
- method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F!> launchInContainer(Class<F!>, android.os.Bundle?, @StyleRes int, androidx.fragment.app.FragmentFactory?);
- method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F!> launchInContainer(Class<F!>, android.os.Bundle?, @StyleRes int, androidx.lifecycle.Lifecycle.State, androidx.fragment.app.FragmentFactory?);
- method public androidx.fragment.app.testing.FragmentScenario<F!> moveToState(androidx.lifecycle.Lifecycle.State);
- method public androidx.fragment.app.testing.FragmentScenario<F!> onFragment(androidx.fragment.app.testing.FragmentScenario.FragmentAction<F!>);
- method public androidx.fragment.app.testing.FragmentScenario<F!> recreate();
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, androidx.fragment.app.FragmentFactory? factory);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, @StyleRes int themeResId, androidx.fragment.app.FragmentFactory? factory);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState, optional androidx.fragment.app.FragmentFactory? factory);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, androidx.fragment.app.FragmentFactory? factory);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, @StyleRes int themeResId, androidx.fragment.app.FragmentFactory? factory);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState, optional androidx.fragment.app.FragmentFactory? factory);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass);
+ method public androidx.fragment.app.testing.FragmentScenario<F> moveToState(androidx.lifecycle.Lifecycle.State newState);
+ method public androidx.fragment.app.testing.FragmentScenario<F> onFragment(androidx.fragment.app.testing.FragmentScenario.FragmentAction<F> action);
+ method public androidx.fragment.app.testing.FragmentScenario<F> recreate();
+ field public static final androidx.fragment.app.testing.FragmentScenario.Companion Companion;
}
- public static interface FragmentScenario.FragmentAction<F extends androidx.fragment.app.Fragment> {
- method public void perform(F);
+ public static final class FragmentScenario.Companion {
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, androidx.fragment.app.FragmentFactory? factory);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, @StyleRes int themeResId, androidx.fragment.app.FragmentFactory? factory);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState, optional androidx.fragment.app.FragmentFactory? factory);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, androidx.fragment.app.FragmentFactory? factory);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, @StyleRes int themeResId, androidx.fragment.app.FragmentFactory? factory);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState, optional androidx.fragment.app.FragmentFactory? factory);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass);
+ }
+
+ public static fun interface FragmentScenario.FragmentAction<F extends androidx.fragment.app.Fragment> {
+ method public void perform(F fragment);
}
public final class FragmentScenarioKt {
diff --git a/fragment/fragment-testing/api/res-1.3.0-beta02.txt b/fragment/fragment-testing/api/res-1.3.0-beta02.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/fragment/fragment-testing/api/res-1.3.0-beta02.txt
diff --git a/fragment/fragment-testing/api/restricted_1.3.0-beta02.txt b/fragment/fragment-testing/api/restricted_1.3.0-beta02.txt
new file mode 100644
index 0000000..4838040
--- /dev/null
+++ b/fragment/fragment-testing/api/restricted_1.3.0-beta02.txt
@@ -0,0 +1,59 @@
+// Signature format: 4.0
+package androidx.fragment.app.testing {
+
+ public final class FragmentScenario<F extends androidx.fragment.app.Fragment> {
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, androidx.fragment.app.FragmentFactory? factory);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, @StyleRes int themeResId, androidx.fragment.app.FragmentFactory? factory);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState, optional androidx.fragment.app.FragmentFactory? factory);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, androidx.fragment.app.FragmentFactory? factory);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, @StyleRes int themeResId, androidx.fragment.app.FragmentFactory? factory);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState, optional androidx.fragment.app.FragmentFactory? factory);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass);
+ method public androidx.fragment.app.testing.FragmentScenario<F> moveToState(androidx.lifecycle.Lifecycle.State newState);
+ method public androidx.fragment.app.testing.FragmentScenario<F> onFragment(androidx.fragment.app.testing.FragmentScenario.FragmentAction<F> action);
+ method public androidx.fragment.app.testing.FragmentScenario<F> recreate();
+ field public static final androidx.fragment.app.testing.FragmentScenario.Companion Companion;
+ }
+
+ public static final class FragmentScenario.Companion {
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, androidx.fragment.app.FragmentFactory? factory);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, @StyleRes int themeResId, androidx.fragment.app.FragmentFactory? factory);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState, optional androidx.fragment.app.FragmentFactory? factory);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, androidx.fragment.app.FragmentFactory? factory);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, @StyleRes int themeResId, androidx.fragment.app.FragmentFactory? factory);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState, optional androidx.fragment.app.FragmentFactory? factory);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass);
+ }
+
+ public static fun interface FragmentScenario.FragmentAction<F extends androidx.fragment.app.Fragment> {
+ method public void perform(F fragment);
+ }
+
+ public final class FragmentScenarioKt {
+ method public static inline <reified F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F>! launchFragment(optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.fragment.app.FragmentFactory? factory);
+ method public static inline <reified F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F>! launchFragment(optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, kotlin.jvm.functions.Function0<? extends F> instantiate);
+ method public static inline <reified F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F>! launchFragment(optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState, optional androidx.fragment.app.FragmentFactory? factory);
+ method public static inline <reified F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F>! launchFragment(optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState, kotlin.jvm.functions.Function0<? extends F> instantiate);
+ method public static inline <reified F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F>! launchFragmentInContainer(optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.fragment.app.FragmentFactory? factory);
+ method public static inline <reified F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F>! launchFragmentInContainer(optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, kotlin.jvm.functions.Function0<? extends F> instantiate);
+ method public static inline <reified F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F>! launchFragmentInContainer(optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState, optional androidx.fragment.app.FragmentFactory? factory);
+ method public static inline <reified F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F>! launchFragmentInContainer(optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState, kotlin.jvm.functions.Function0<? extends F> instantiate);
+ method public static inline <reified F extends androidx.fragment.app.Fragment, T> T! withFragment(androidx.fragment.app.testing.FragmentScenario<F>, kotlin.jvm.functions.Function1<? super F,? extends T> block);
+ }
+
+}
+
diff --git a/fragment/fragment-testing/api/restricted_current.ignore b/fragment/fragment-testing/api/restricted_current.ignore
new file mode 100644
index 0000000..aff4f36
--- /dev/null
+++ b/fragment/fragment-testing/api/restricted_current.ignore
@@ -0,0 +1,27 @@
+// Baseline format: 1.0
+ChangedType: androidx.fragment.app.testing.FragmentScenario#launch(Class<F>):
+ Method androidx.fragment.app.testing.FragmentScenario.launch has changed return type from androidx.fragment.app.testing.FragmentScenario<F!> to androidx.fragment.app.testing.FragmentScenario<F>
+ChangedType: androidx.fragment.app.testing.FragmentScenario#launch(Class<F>, android.os.Bundle):
+ Method androidx.fragment.app.testing.FragmentScenario.launch has changed return type from androidx.fragment.app.testing.FragmentScenario<F!> to androidx.fragment.app.testing.FragmentScenario<F>
+ChangedType: androidx.fragment.app.testing.FragmentScenario#launch(Class<F>, android.os.Bundle, androidx.fragment.app.FragmentFactory):
+ Method androidx.fragment.app.testing.FragmentScenario.launch has changed return type from androidx.fragment.app.testing.FragmentScenario<F!> to androidx.fragment.app.testing.FragmentScenario<F>
+ChangedType: androidx.fragment.app.testing.FragmentScenario#launch(Class<F>, android.os.Bundle, int, androidx.fragment.app.FragmentFactory):
+ Method androidx.fragment.app.testing.FragmentScenario.launch has changed return type from androidx.fragment.app.testing.FragmentScenario<F!> to androidx.fragment.app.testing.FragmentScenario<F>
+ChangedType: androidx.fragment.app.testing.FragmentScenario#launch(Class<F>, android.os.Bundle, int, androidx.lifecycle.Lifecycle.State, androidx.fragment.app.FragmentFactory):
+ Method androidx.fragment.app.testing.FragmentScenario.launch has changed return type from androidx.fragment.app.testing.FragmentScenario<F!> to androidx.fragment.app.testing.FragmentScenario<F>
+ChangedType: androidx.fragment.app.testing.FragmentScenario#launchInContainer(Class<F>):
+ Method androidx.fragment.app.testing.FragmentScenario.launchInContainer has changed return type from androidx.fragment.app.testing.FragmentScenario<F!> to androidx.fragment.app.testing.FragmentScenario<F>
+ChangedType: androidx.fragment.app.testing.FragmentScenario#launchInContainer(Class<F>, android.os.Bundle):
+ Method androidx.fragment.app.testing.FragmentScenario.launchInContainer has changed return type from androidx.fragment.app.testing.FragmentScenario<F!> to androidx.fragment.app.testing.FragmentScenario<F>
+ChangedType: androidx.fragment.app.testing.FragmentScenario#launchInContainer(Class<F>, android.os.Bundle, androidx.fragment.app.FragmentFactory):
+ Method androidx.fragment.app.testing.FragmentScenario.launchInContainer has changed return type from androidx.fragment.app.testing.FragmentScenario<F!> to androidx.fragment.app.testing.FragmentScenario<F>
+ChangedType: androidx.fragment.app.testing.FragmentScenario#launchInContainer(Class<F>, android.os.Bundle, int, androidx.fragment.app.FragmentFactory):
+ Method androidx.fragment.app.testing.FragmentScenario.launchInContainer has changed return type from androidx.fragment.app.testing.FragmentScenario<F!> to androidx.fragment.app.testing.FragmentScenario<F>
+ChangedType: androidx.fragment.app.testing.FragmentScenario#launchInContainer(Class<F>, android.os.Bundle, int, androidx.lifecycle.Lifecycle.State, androidx.fragment.app.FragmentFactory):
+ Method androidx.fragment.app.testing.FragmentScenario.launchInContainer has changed return type from androidx.fragment.app.testing.FragmentScenario<F!> to androidx.fragment.app.testing.FragmentScenario<F>
+ChangedType: androidx.fragment.app.testing.FragmentScenario#moveToState(androidx.lifecycle.Lifecycle.State):
+ Method androidx.fragment.app.testing.FragmentScenario.moveToState has changed return type from androidx.fragment.app.testing.FragmentScenario<F!> to androidx.fragment.app.testing.FragmentScenario<F>
+ChangedType: androidx.fragment.app.testing.FragmentScenario#onFragment(androidx.fragment.app.testing.FragmentScenario.FragmentAction<F>):
+ Method androidx.fragment.app.testing.FragmentScenario.onFragment has changed return type from androidx.fragment.app.testing.FragmentScenario<F!> to androidx.fragment.app.testing.FragmentScenario<F>
+ChangedType: androidx.fragment.app.testing.FragmentScenario#recreate():
+ Method androidx.fragment.app.testing.FragmentScenario.recreate has changed return type from androidx.fragment.app.testing.FragmentScenario<F!> to androidx.fragment.app.testing.FragmentScenario<F>
diff --git a/fragment/fragment-testing/api/restricted_current.txt b/fragment/fragment-testing/api/restricted_current.txt
index 5486858..4838040 100644
--- a/fragment/fragment-testing/api/restricted_current.txt
+++ b/fragment/fragment-testing/api/restricted_current.txt
@@ -2,23 +2,45 @@
package androidx.fragment.app.testing {
public final class FragmentScenario<F extends androidx.fragment.app.Fragment> {
- method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F!> launch(Class<F!>);
- method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F!> launch(Class<F!>, android.os.Bundle?);
- method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F!> launch(Class<F!>, android.os.Bundle?, androidx.fragment.app.FragmentFactory?);
- method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F!> launch(Class<F!>, android.os.Bundle?, @StyleRes int, androidx.fragment.app.FragmentFactory?);
- method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F!> launch(Class<F!>, android.os.Bundle?, @StyleRes int, androidx.lifecycle.Lifecycle.State, androidx.fragment.app.FragmentFactory?);
- method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F!> launchInContainer(Class<F!>);
- method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F!> launchInContainer(Class<F!>, android.os.Bundle?);
- method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F!> launchInContainer(Class<F!>, android.os.Bundle?, androidx.fragment.app.FragmentFactory?);
- method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F!> launchInContainer(Class<F!>, android.os.Bundle?, @StyleRes int, androidx.fragment.app.FragmentFactory?);
- method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F!> launchInContainer(Class<F!>, android.os.Bundle?, @StyleRes int, androidx.lifecycle.Lifecycle.State, androidx.fragment.app.FragmentFactory?);
- method public androidx.fragment.app.testing.FragmentScenario<F!> moveToState(androidx.lifecycle.Lifecycle.State);
- method public androidx.fragment.app.testing.FragmentScenario<F!> onFragment(androidx.fragment.app.testing.FragmentScenario.FragmentAction<F!>);
- method public androidx.fragment.app.testing.FragmentScenario<F!> recreate();
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, androidx.fragment.app.FragmentFactory? factory);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, @StyleRes int themeResId, androidx.fragment.app.FragmentFactory? factory);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState, optional androidx.fragment.app.FragmentFactory? factory);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, androidx.fragment.app.FragmentFactory? factory);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, @StyleRes int themeResId, androidx.fragment.app.FragmentFactory? factory);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState, optional androidx.fragment.app.FragmentFactory? factory);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs);
+ method public static <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass);
+ method public androidx.fragment.app.testing.FragmentScenario<F> moveToState(androidx.lifecycle.Lifecycle.State newState);
+ method public androidx.fragment.app.testing.FragmentScenario<F> onFragment(androidx.fragment.app.testing.FragmentScenario.FragmentAction<F> action);
+ method public androidx.fragment.app.testing.FragmentScenario<F> recreate();
+ field public static final androidx.fragment.app.testing.FragmentScenario.Companion Companion;
}
- public static interface FragmentScenario.FragmentAction<F extends androidx.fragment.app.Fragment> {
- method public void perform(F);
+ public static final class FragmentScenario.Companion {
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, androidx.fragment.app.FragmentFactory? factory);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, @StyleRes int themeResId, androidx.fragment.app.FragmentFactory? factory);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState, optional androidx.fragment.app.FragmentFactory? factory);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launch(Class<F> fragmentClass);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, androidx.fragment.app.FragmentFactory? factory);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, android.os.Bundle? fragmentArgs, @StyleRes int themeResId, androidx.fragment.app.FragmentFactory? factory);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState, optional androidx.fragment.app.FragmentFactory? factory);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId, optional androidx.lifecycle.Lifecycle.State initialState);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs, optional @StyleRes int themeResId);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass, optional android.os.Bundle? fragmentArgs);
+ method public <F extends androidx.fragment.app.Fragment> androidx.fragment.app.testing.FragmentScenario<F> launchInContainer(Class<F> fragmentClass);
+ }
+
+ public static fun interface FragmentScenario.FragmentAction<F extends androidx.fragment.app.Fragment> {
+ method public void perform(F fragment);
}
public final class FragmentScenarioKt {
diff --git a/fragment/fragment-testing/src/main/java/androidx/fragment/app/testing/FragmentScenario.java b/fragment/fragment-testing/src/main/java/androidx/fragment/app/testing/FragmentScenario.java
deleted file mode 100644
index 64ff90b..0000000
--- a/fragment/fragment-testing/src/main/java/androidx/fragment/app/testing/FragmentScenario.java
+++ /dev/null
@@ -1,464 +0,0 @@
-/*
- * 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.
- * 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.app.testing;
-
-import static androidx.annotation.RestrictTo.Scope.LIBRARY;
-import static androidx.core.util.Preconditions.checkNotNull;
-import static androidx.core.util.Preconditions.checkState;
-import static androidx.test.core.app.ApplicationProvider.getApplicationContext;
-
-import android.annotation.SuppressLint;
-import android.content.ComponentName;
-import android.content.Intent;
-import android.os.Bundle;
-
-import androidx.annotation.IdRes;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.annotation.RestrictTo;
-import androidx.annotation.StyleRes;
-import androidx.core.util.Preconditions;
-import androidx.fragment.app.Fragment;
-import androidx.fragment.app.FragmentActivity;
-import androidx.fragment.app.FragmentFactory;
-import androidx.fragment.testing.R;
-import androidx.lifecycle.Lifecycle;
-import androidx.lifecycle.Lifecycle.State;
-import androidx.lifecycle.ViewModel;
-import androidx.lifecycle.ViewModelProvider;
-import androidx.test.core.app.ActivityScenario;
-
-/**
- * FragmentScenario provides API to start and drive a Fragment's lifecycle state for testing. It
- * works with arbitrary fragments and works consistently across different versions of the Android
- * framework.
- * <p>
- * FragmentScenario only supports {@link Fragment androidx.fragment.app.Fragment}. If you are using
- * a deprecated fragment class such as {@code android.support.v4.app.Fragment} or
- * {@link android.app.Fragment android.app.Fragment}, please update your code to
- * {@link Fragment androidx.fragment.app.Fragment}.
- * <p>
- * If your testing Fragment has a dependency to specific theme such as {@code Theme.AppCompat},
- * use the theme ID parameter in {@link #launch} method.
- *
- * @param <F> The Fragment class being tested
- *
- * @see ActivityScenario a scenario API for Activity
- */
-public final class FragmentScenario<F extends Fragment> {
-
- private static final String FRAGMENT_TAG = "FragmentScenario_Fragment_Tag";
- @SuppressWarnings("WeakerAccess") /* synthetic access */
- final Class<F> mFragmentClass;
- private final ActivityScenario<EmptyFragmentActivity> mActivityScenario;
-
- /**
- * An empty activity inheriting FragmentActivity. This Activity is used to host Fragment in
- * FragmentScenario.
- *
- * @hide
- */
- @RestrictTo(LIBRARY)
- public static class EmptyFragmentActivity extends FragmentActivity {
-
- @NonNull
- public static final String THEME_EXTRAS_BUNDLE_KEY =
- "androidx.fragment.app.testing.FragmentScenario.EmptyFragmentActivity"
- + ".THEME_EXTRAS_BUNDLE_KEY";
-
- @Override
- @SuppressLint("RestrictedApi")
- protected void onCreate(@Nullable Bundle savedInstanceState) {
- setTheme(getIntent().getIntExtra(THEME_EXTRAS_BUNDLE_KEY,
- R.style.FragmentScenarioEmptyFragmentActivityTheme));
-
- // Checks if we have a custom FragmentFactory and set it.
- FragmentFactory factory = FragmentFactoryHolderViewModel.getInstance(this)
- .getFragmentFactory();
- if (factory != null) {
- getSupportFragmentManager().setFragmentFactory(factory);
- }
-
- // FragmentFactory needs to be set before calling the super.onCreate, otherwise the
- // Activity crashes when it is recreating and there is a fragment which has no
- // default constructor.
- super.onCreate(savedInstanceState);
- }
- }
-
- /**
- * A view-model to hold a fragment factory.
- *
- * @hide
- */
- @RestrictTo(LIBRARY)
- public static class FragmentFactoryHolderViewModel extends ViewModel {
-
- private static final ViewModelProvider.Factory FACTORY = new ViewModelProvider.Factory() {
- @NonNull
- @Override
- @SuppressWarnings("unchecked")
- public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
- FragmentFactoryHolderViewModel viewModel = new FragmentFactoryHolderViewModel();
- return (T) viewModel;
- }
- };
-
- @NonNull
- static FragmentFactoryHolderViewModel getInstance(@NonNull FragmentActivity activity) {
- ViewModelProvider viewModelProvider = new ViewModelProvider(activity, FACTORY);
- return viewModelProvider.get(FragmentFactoryHolderViewModel.class);
- }
-
- @Nullable private FragmentFactory mFragmentFactory;
-
- void setFragmentFactory(@Nullable FragmentFactory factory) {
- mFragmentFactory = factory;
- }
-
- @Nullable
- FragmentFactory getFragmentFactory() {
- return mFragmentFactory;
- }
-
- @Override
- protected void onCleared() {
- super.onCleared();
- mFragmentFactory = null;
- }
- }
-
- private FragmentScenario(
- @NonNull Class<F> fragmentClass,
- @NonNull ActivityScenario<EmptyFragmentActivity> activityScenario) {
- this.mFragmentClass = fragmentClass;
- this.mActivityScenario = activityScenario;
- }
-
- /**
- * Launches a Fragment hosted by an empty {@link FragmentActivity} and waits for it to reach
- * the resumed state.
- *
- * @param fragmentClass a fragment class to instantiate
- */
- @NonNull
- public static <F extends Fragment> FragmentScenario<F> launch(
- @NonNull Class<F> fragmentClass) {
- return launch(fragmentClass, /*fragmentArgs=*/ null);
- }
-
- /**
- * Launches a Fragment with given arguments hosted by an empty {@link FragmentActivity} and
- * waits for it to reach the resumed state.
- * <p>
- * This method cannot be called from the main thread.
- *
- * @param fragmentClass a fragment class to instantiate
- * @param fragmentArgs a bundle to passed into fragment
- */
- @NonNull
- public static <F extends Fragment> FragmentScenario<F> launch(
- @NonNull Class<F> fragmentClass, @Nullable Bundle fragmentArgs) {
- return launch(fragmentClass, fragmentArgs, /*factory=*/null);
- }
-
- /**
- * Launches a Fragment with given arguments hosted by an empty {@link FragmentActivity} using
- * the given {@link FragmentFactory} and waits for it to reach the resumed state.
- * <p>
- * This method cannot be called from the main thread.
- *
- * @param fragmentClass a fragment class to instantiate
- * @param fragmentArgs a bundle to passed into fragment
- * @param factory a fragment factory to use or null to use default factory
- */
- @NonNull
- public static <F extends Fragment> FragmentScenario<F> launch(
- @NonNull Class<F> fragmentClass, @Nullable Bundle fragmentArgs,
- @Nullable FragmentFactory factory) {
- return launch(fragmentClass, fragmentArgs,
- R.style.FragmentScenarioEmptyFragmentActivityTheme, factory);
- }
-
- /**
- * Launches a Fragment with given arguments hosted by an empty {@link FragmentActivity} themed
- * by {@code themeResId}, using the given {@link FragmentFactory} and waits for it to reach the
- * resumed state.
- * <p>
- * This method cannot be called from the main thread.
- *
- * @param fragmentClass a fragment class to instantiate
- * @param fragmentArgs a bundle to passed into fragment
- * @param themeResId a style resource id to be set to the host activity's theme
- * @param factory a fragment factory to use or null to use default factory
- */
- @NonNull
- public static <F extends Fragment> FragmentScenario<F> launch(
- @NonNull Class<F> fragmentClass, @Nullable Bundle fragmentArgs,
- @StyleRes int themeResId, @Nullable FragmentFactory factory) {
- return launch(fragmentClass, fragmentArgs, themeResId, Lifecycle.State.RESUMED,
- factory);
- }
-
- /**
- * Launches a Fragment with given arguments hosted by an empty {@link FragmentActivity} themed
- * by {@code themeResId}, using the given {@link FragmentFactory} and waits for it to reach
- * {@code initialState}.
- * <p>
- * This method cannot be called from the main thread.
- *
- * @param fragmentClass a fragment class to instantiate
- * @param fragmentArgs a bundle to passed into fragment
- * @param themeResId a style resource id to be set to the host activity's theme
- * @param initialState The initial {@link Lifecycle.State}. This must be one of
- * {@link State#CREATED CREATED}, {@link State#STARTED STARTED}, and
- * {@link State#RESUMED RESUMED}.
- * @param factory a fragment factory to use or null to use default factory
- */
- @NonNull
- public static <F extends Fragment> FragmentScenario<F> launch(
- @NonNull Class<F> fragmentClass, @Nullable Bundle fragmentArgs,
- @StyleRes int themeResId, @NonNull Lifecycle.State initialState,
- @Nullable FragmentFactory factory) {
- return internalLaunch(fragmentClass, fragmentArgs, themeResId, initialState, factory,
- /*containerViewId=*/ 0);
- }
-
- /**
- * Launches a Fragment in the Activity's root view container {@code android.R.id.content},
- * hosted by an empty {@link FragmentActivity} and waits for it to reach the resumed state.
- * <p>
- * This method cannot be called from the main thread.
- *
- * @param fragmentClass a fragment class to instantiate
- */
- @NonNull
- public static <F extends Fragment> FragmentScenario<F> launchInContainer(
- @NonNull Class<F> fragmentClass) {
- return launchInContainer(fragmentClass, /*fragmentArgs=*/ null);
- }
-
- /**
- * Launches a Fragment in the Activity's root view container {@code android.R.id.content}, with
- * given arguments hosted by an empty {@link FragmentActivity} and waits for it to reach the
- * resumed state.
- * <p>
- * This method cannot be called from the main thread.
- *
- * @param fragmentClass a fragment class to instantiate
- * @param fragmentArgs a bundle to passed into fragment
- */
- @NonNull
- public static <F extends Fragment> FragmentScenario<F> launchInContainer(
- @NonNull Class<F> fragmentClass, @Nullable Bundle fragmentArgs) {
- return launchInContainer(fragmentClass, fragmentArgs, /*factory=*/null);
- }
-
- /**
- * Launches a Fragment in the Activity's root view container {@code android.R.id.content}, with
- * given arguments hosted by an empty {@link FragmentActivity} using the given
- * {@link FragmentFactory} and waits for it to reach the resumed state.
- * <p>
- * This method cannot be called from the main thread.
- *
- * @param fragmentClass a fragment class to instantiate
- * @param fragmentArgs a bundle to passed into fragment
- * @param factory a fragment factory to use or null to use default factory
- */
- @NonNull
- public static <F extends Fragment> FragmentScenario<F> launchInContainer(
- @NonNull Class<F> fragmentClass, @Nullable Bundle fragmentArgs,
- @Nullable FragmentFactory factory) {
- return launchInContainer(fragmentClass, fragmentArgs,
- R.style.FragmentScenarioEmptyFragmentActivityTheme, factory);
- }
-
- /**
- * Launches a Fragment in the Activity's root view container {@code android.R.id.content}, with
- * given arguments hosted by an empty {@link FragmentActivity} themed by {@code themeResId},
- * using the given {@link FragmentFactory} and waits for it to reach the resumed state.
- * <p>
- * This method cannot be called from the main thread.
- *
- * @param fragmentClass a fragment class to instantiate
- * @param fragmentArgs a bundle to passed into fragment
- * @param themeResId a style resource id to be set to the host activity's theme
- * @param factory a fragment factory to use or null to use default factory
- */
- @NonNull
- public static <F extends Fragment> FragmentScenario<F> launchInContainer(
- @NonNull Class<F> fragmentClass, @Nullable Bundle fragmentArgs,
- @StyleRes int themeResId, @Nullable FragmentFactory factory) {
- return launchInContainer(fragmentClass, fragmentArgs, themeResId, Lifecycle.State.RESUMED,
- factory);
- }
-
- /**
- * Launches a Fragment in the Activity's root view container {@code android.R.id.content}, with
- * given arguments hosted by an empty {@link FragmentActivity} themed by {@code themeResId},
- * using the given {@link FragmentFactory} and waits for it to reach {@code initialState}.
- * <p>
- * This method cannot be called from the main thread.
- *
- * @param fragmentClass a fragment class to instantiate
- * @param fragmentArgs a bundle to passed into fragment
- * @param themeResId a style resource id to be set to the host activity's theme
- * @param initialState The initial {@link Lifecycle.State}. This must be one of
- * {@link State#CREATED CREATED}, {@link State#STARTED STARTED}, and
- * {@link State#RESUMED RESUMED}.
- * @param factory a fragment factory to use or null to use default factory
- */
- @NonNull
- public static <F extends Fragment> FragmentScenario<F> launchInContainer(
- @NonNull Class<F> fragmentClass, @Nullable Bundle fragmentArgs,
- @StyleRes int themeResId, @NonNull Lifecycle.State initialState,
- @Nullable FragmentFactory factory) {
- return internalLaunch(
- fragmentClass, fragmentArgs, themeResId, initialState, factory,
- android.R.id.content);
- }
-
- @NonNull
- @SuppressLint("RestrictedApi")
- private static <F extends Fragment> FragmentScenario<F> internalLaunch(
- @NonNull final Class<F> fragmentClass, final @Nullable Bundle fragmentArgs,
- @StyleRes int themeResId, @NonNull Lifecycle.State initialState,
- @Nullable final FragmentFactory factory,
- @IdRes final int containerViewId) {
- Intent startActivityIntent =
- Intent.makeMainActivity(
- new ComponentName(getApplicationContext(),
- EmptyFragmentActivity.class))
- .putExtra(EmptyFragmentActivity.THEME_EXTRAS_BUNDLE_KEY, themeResId);
- FragmentScenario<F> scenario = new FragmentScenario<>(
- fragmentClass,
- ActivityScenario.launch(startActivityIntent));
- scenario.mActivityScenario.onActivity(activity -> {
- if (factory != null) {
- FragmentFactoryHolderViewModel.getInstance(activity)
- .setFragmentFactory(factory);
- activity.getSupportFragmentManager().setFragmentFactory(factory);
- }
- Fragment fragment = activity.getSupportFragmentManager()
- .getFragmentFactory().instantiate(
- Preconditions.checkNotNull(fragmentClass.getClassLoader()),
- fragmentClass.getName());
- fragment.setArguments(fragmentArgs);
- activity.getSupportFragmentManager()
- .beginTransaction()
- .add(containerViewId, fragment, FRAGMENT_TAG)
- .setMaxLifecycle(fragment, initialState)
- .commitNow();
- });
- return scenario;
- }
-
- /**
- * Moves Fragment state to a new state.
- * <p> If a new state and current state are the same, this method does nothing. It accepts
- * {@link State#CREATED CREATED}, {@link State#STARTED STARTED}, {@link State#RESUMED RESUMED},
- * and {@link State#DESTROYED DESTROYED}. {@link State#DESTROYED DESTROYED} is a terminal state.
- * You cannot move to any other state after the Fragment reaches that state.
- * <p> This method cannot be called from the main thread.
- */
- @NonNull
- public FragmentScenario<F> moveToState(@NonNull State newState) {
- if (newState == State.DESTROYED) {
- mActivityScenario.onActivity(activity -> {
- Fragment fragment =
- activity.getSupportFragmentManager().findFragmentByTag(
- FRAGMENT_TAG);
- // Null means the fragment has been destroyed already.
- if (fragment != null) {
- activity
- .getSupportFragmentManager()
- .beginTransaction()
- .remove(fragment)
- .commitNow();
- }
- });
- } else {
- mActivityScenario.onActivity(activity -> {
- Fragment fragment =
- activity.getSupportFragmentManager().findFragmentByTag(
- FRAGMENT_TAG);
- checkNotNull(fragment,
- "The fragment has been removed from FragmentManager already.");
- activity.getSupportFragmentManager()
- .beginTransaction()
- .setMaxLifecycle(fragment, newState)
- .commitNow();
- });
- }
- return this;
- }
-
- /**
- * Recreates the host Activity.
- * <p>
- * After this method call, it is ensured that the Fragment state goes back to the same state
- * as its previous state.
- * <p>
- * This method cannot be called from the main thread.
- */
- @NonNull
- public FragmentScenario<F> recreate() {
- mActivityScenario.recreate();
- return this;
- }
-
- /**
- * FragmentAction interface should be implemented by any class whose instances are intended to
- * be executed by the main thread. A Fragment that is instrumented by the FragmentScenario is
- * passed to {@link FragmentAction#perform} method.
- * <p>
- * You should never keep the Fragment reference as it will lead to unpredictable behaviour.
- * It should only be accessed in {@link FragmentAction#perform} scope.
- */
- public interface FragmentAction<F extends Fragment> {
- /**
- * This method is invoked on the main thread with the reference to the Fragment.
- *
- * @param fragment a Fragment instrumented by the FragmentScenario.
- */
- void perform(@NonNull F fragment);
- }
-
- /**
- * Runs a given {@code action} on the current Activity's main thread.
- * <p>
- * Note that you should never keep Fragment reference passed into your {@code action}
- * because it can be recreated at anytime during state transitions.
- * <p>
- * Throwing an exception from {@code action} makes the host Activity crash. You can
- * inspect the exception in logcat outputs.
- * <p>
- * This method cannot be called from the main thread.
- */
- @NonNull
- public FragmentScenario<F> onFragment(@NonNull final FragmentAction<F> action) {
- mActivityScenario.onActivity(activity -> {
- Fragment fragment = activity.getSupportFragmentManager().findFragmentByTag(
- FRAGMENT_TAG);
- checkNotNull(fragment,
- "The fragment has been removed from FragmentManager already.");
- checkState(mFragmentClass.isInstance(fragment));
- action.perform(Preconditions.checkNotNull(mFragmentClass.cast(fragment)));
- });
- return this;
- }
-}
diff --git a/fragment/fragment-testing/src/main/java/androidx/fragment/app/testing/FragmentScenario.kt b/fragment/fragment-testing/src/main/java/androidx/fragment/app/testing/FragmentScenario.kt
index d8694ad..89eeee7 100644
--- a/fragment/fragment-testing/src/main/java/androidx/fragment/app/testing/FragmentScenario.kt
+++ b/fragment/fragment-testing/src/main/java/androidx/fragment/app/testing/FragmentScenario.kt
@@ -16,13 +16,25 @@
package androidx.fragment.app.testing
+import android.annotation.SuppressLint
+import android.content.ComponentName
+import android.content.Intent
import android.os.Bundle
+import androidx.activity.viewModels
+import androidx.annotation.IdRes
+import androidx.annotation.RestrictTo
import androidx.annotation.StyleRes
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.fragment.app.FragmentFactory
+import androidx.fragment.app.commitNow
+import androidx.fragment.app.testing.FragmentScenario.Companion.launch
import androidx.fragment.testing.R
import androidx.lifecycle.Lifecycle
+import androidx.lifecycle.ViewModel
+import androidx.lifecycle.ViewModelProvider
+import androidx.test.core.app.ActivityScenario
+import androidx.test.core.app.ApplicationProvider
@Deprecated(
"Superseded by launchFragment that takes an initialState",
@@ -91,7 +103,7 @@
@StyleRes themeResId: Int = R.style.FragmentScenarioEmptyFragmentActivityTheme,
initialState: Lifecycle.State = Lifecycle.State.RESUMED,
factory: FragmentFactory? = null
-): FragmentScenario<F> = FragmentScenario.launch(
+): FragmentScenario<F> = launch(
F::class.java, fragmentArgs, themeResId, initialState,
factory
)
@@ -113,7 +125,7 @@
@StyleRes themeResId: Int = R.style.FragmentScenarioEmptyFragmentActivityTheme,
initialState: Lifecycle.State = Lifecycle.State.RESUMED,
crossinline instantiate: () -> F
-): FragmentScenario<F> = FragmentScenario.launch(
+): FragmentScenario<F> = launch(
F::class.java, fragmentArgs, themeResId, initialState,
object : FragmentFactory() {
override fun instantiate(
@@ -202,3 +214,392 @@
err?.let { throw it }
return value
}
+
+/**
+ * FragmentScenario provides API to start and drive a Fragment's lifecycle state for testing. It
+ * works with arbitrary fragments and works consistently across different versions of the Android
+ * framework.
+ *
+ * FragmentScenario only supports [androidx.fragment.app.Fragment][Fragment]. If you are using
+ * a deprecated fragment class such as `android.support.v4.app.Fragment` or
+ * [android.app.Fragment], please update your code to
+ * [androidx.fragment.app.Fragment][Fragment].
+ *
+ * If your testing Fragment has a dependency to specific theme such as `Theme.AppCompat`,
+ * use the theme ID parameter in [launch] method.
+ *
+ * @param <F> The Fragment class being tested
+ *
+ * @see ActivityScenario a scenario API for Activity
+ */
+public class FragmentScenario<F : Fragment> private constructor(
+ @Suppress("MemberVisibilityCanBePrivate") /* synthetic access */
+ internal val fragmentClass: Class<F>,
+ private val activityScenario: ActivityScenario<EmptyFragmentActivity>
+) {
+
+ /**
+ * An empty activity inheriting FragmentActivity. This Activity is used to host Fragment in
+ * FragmentScenario.
+ *
+ * @hide
+ */
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ internal class EmptyFragmentActivity : FragmentActivity() {
+ @SuppressLint("RestrictedApi")
+ override fun onCreate(savedInstanceState: Bundle?) {
+ setTheme(
+ intent.getIntExtra(
+ THEME_EXTRAS_BUNDLE_KEY,
+ R.style.FragmentScenarioEmptyFragmentActivityTheme
+ )
+ )
+
+ // Checks if we have a custom FragmentFactory and set it.
+ val factory = FragmentFactoryHolderViewModel.getInstance(this).fragmentFactory
+ if (factory != null) {
+ supportFragmentManager.fragmentFactory = factory
+ }
+
+ // FragmentFactory needs to be set before calling the super.onCreate, otherwise the
+ // Activity crashes when it is recreating and there is a fragment which has no
+ // default constructor.
+ super.onCreate(savedInstanceState)
+ }
+
+ companion object {
+ const val THEME_EXTRAS_BUNDLE_KEY = "androidx.fragment.app.testing.FragmentScenario" +
+ ".EmptyFragmentActivity.THEME_EXTRAS_BUNDLE_KEY"
+ }
+ }
+
+ /**
+ * A view-model to hold a fragment factory.
+ *
+ * @hide
+ */
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ internal class FragmentFactoryHolderViewModel : ViewModel() {
+ var fragmentFactory: FragmentFactory? = null
+
+ override fun onCleared() {
+ super.onCleared()
+ fragmentFactory = null
+ }
+
+ companion object {
+ @Suppress("MemberVisibilityCanBePrivate")
+ internal val FACTORY: ViewModelProvider.Factory =
+ object : ViewModelProvider.Factory {
+ @Suppress("UNCHECKED_CAST")
+ override fun <T : ViewModel?> create(modelClass: Class<T>): T {
+ val viewModel =
+ FragmentFactoryHolderViewModel()
+ return viewModel as T
+ }
+ }
+
+ fun getInstance(activity: FragmentActivity): FragmentFactoryHolderViewModel {
+ val viewModel: FragmentFactoryHolderViewModel by activity.viewModels { FACTORY }
+ return viewModel
+ }
+ }
+ }
+
+ /**
+ * Moves Fragment state to a new state.
+ *
+ * If a new state and current state are the same, this method does nothing. It accepts
+ * [CREATED][Lifecycle.State.CREATED], [STARTED][Lifecycle.State.STARTED],
+ * [RESUMED][Lifecycle.State.RESUMED], and [DESTROYED][Lifecycle.State.DESTROYED].
+ * [DESTROYED][Lifecycle.State.DESTROYED] is a terminal state.
+ * You cannot move to any other state after the Fragment reaches that state.
+ *
+ * This method cannot be called from the main thread.
+ */
+ public fun moveToState(newState: Lifecycle.State): FragmentScenario<F> {
+ if (newState == Lifecycle.State.DESTROYED) {
+ activityScenario.onActivity { activity ->
+ val fragment = activity.supportFragmentManager
+ .findFragmentByTag(FRAGMENT_TAG)
+ // Null means the fragment has been destroyed already.
+ if (fragment != null) {
+ activity.supportFragmentManager.commitNow {
+ remove(fragment)
+ }
+ }
+ }
+ } else {
+ activityScenario.onActivity { activity ->
+ val fragment = requireNotNull(
+ activity.supportFragmentManager.findFragmentByTag(FRAGMENT_TAG)
+ ) {
+ "The fragment has been removed from the FragmentManager already."
+ }
+ activity.supportFragmentManager.commitNow {
+ setMaxLifecycle(fragment, newState)
+ }
+ }
+ }
+ return this
+ }
+
+ /**
+ * Recreates the host Activity.
+ *
+ * After this method call, it is ensured that the Fragment state goes back to the same state
+ * as its previous state.
+ *
+ * This method cannot be called from the main thread.
+ */
+ public fun recreate(): FragmentScenario<F> {
+ activityScenario.recreate()
+ return this
+ }
+
+ /**
+ * FragmentAction interface should be implemented by any class whose instances are intended to
+ * be executed by the main thread. A Fragment that is instrumented by the FragmentScenario is
+ * passed to [FragmentAction.perform] method.
+ *
+ * You should never keep the Fragment reference as it will lead to unpredictable behaviour.
+ * It should only be accessed in [FragmentAction.perform] scope.
+ */
+ public fun interface FragmentAction<F : Fragment> {
+ /**
+ * This method is invoked on the main thread with the reference to the Fragment.
+ *
+ * @param fragment a Fragment instrumented by the FragmentScenario.
+ */
+ public fun perform(fragment: F)
+ }
+
+ /**
+ * Runs a given [action] on the current Activity's main thread.
+ *
+ * Note that you should never keep Fragment reference passed into your [action]
+ * because it can be recreated at anytime during state transitions.
+ *
+ * Throwing an exception from [action] makes the host Activity crash. You can
+ * inspect the exception in logcat outputs.
+ *
+ * This method cannot be called from the main thread.
+ */
+ public fun onFragment(action: FragmentAction<F>): FragmentScenario<F> {
+ activityScenario.onActivity { activity ->
+ val fragment = requireNotNull(
+ activity.supportFragmentManager.findFragmentByTag(FRAGMENT_TAG)
+ ) {
+ "The fragment has been removed from the FragmentManager already."
+ }
+ check(fragmentClass.isInstance(fragment))
+ action.perform(requireNotNull(fragmentClass.cast(fragment)))
+ }
+ return this
+ }
+
+ public companion object {
+ private const val FRAGMENT_TAG = "FragmentScenario_Fragment_Tag"
+
+ /**
+ * Launches a Fragment with given arguments hosted by an empty [FragmentActivity] using
+ * the given [FragmentFactory] and waits for it to reach the resumed state.
+ *
+ *
+ * This method cannot be called from the main thread.
+ *
+ * @param fragmentClass a fragment class to instantiate
+ * @param fragmentArgs a bundle to passed into fragment
+ * @param factory a fragment factory to use or null to use default factory
+ */
+ @JvmStatic
+ public fun <F : Fragment> launch(
+ fragmentClass: Class<F>,
+ fragmentArgs: Bundle?,
+ factory: FragmentFactory?
+ ): FragmentScenario<F> = launch(
+ fragmentClass,
+ fragmentArgs,
+ R.style.FragmentScenarioEmptyFragmentActivityTheme,
+ Lifecycle.State.RESUMED,
+ factory
+ )
+
+ /**
+ * Launches a Fragment with given arguments hosted by an empty [FragmentActivity] themed
+ * by [themeResId], using the given [FragmentFactory] and waits for it to reach the
+ * resumed state.
+ *
+ * This method cannot be called from the main thread.
+ *
+ * @param fragmentClass a fragment class to instantiate
+ * @param fragmentArgs a bundle to passed into fragment
+ * @param themeResId a style resource id to be set to the host activity's theme
+ * @param factory a fragment factory to use or null to use default factory
+ */
+ @JvmStatic
+ public fun <F : Fragment> launch(
+ fragmentClass: Class<F>,
+ fragmentArgs: Bundle?,
+ @StyleRes themeResId: Int,
+ factory: FragmentFactory?
+ ): FragmentScenario<F> = launch(
+ fragmentClass,
+ fragmentArgs,
+ themeResId,
+ Lifecycle.State.RESUMED,
+ factory
+ )
+
+ /**
+ * Launches a Fragment with given arguments hosted by an empty [FragmentActivity] themed
+ * by [themeResId], using the given [FragmentFactory] and waits for it to reach
+ * [initialState].
+ *
+ * This method cannot be called from the main thread.
+ *
+ * @param fragmentClass a fragment class to instantiate
+ * @param fragmentArgs a bundle to passed into fragment
+ * @param themeResId a style resource id to be set to the host activity's theme
+ * @param initialState The initial [Lifecycle.State]. This must be one of
+ * [CREATED][Lifecycle.State.CREATED], [STARTED][Lifecycle.State.STARTED], and
+ * [RESUMED][Lifecycle.State.RESUMED].
+ * @param factory a fragment factory to use or null to use default factory
+ */
+ @JvmOverloads
+ @JvmStatic
+ public fun <F : Fragment> launch(
+ fragmentClass: Class<F>,
+ fragmentArgs: Bundle? = null,
+ @StyleRes themeResId: Int = R.style.FragmentScenarioEmptyFragmentActivityTheme,
+ initialState: Lifecycle.State = Lifecycle.State.RESUMED,
+ factory: FragmentFactory? = null
+ ): FragmentScenario<F> = internalLaunch(
+ fragmentClass,
+ fragmentArgs,
+ themeResId,
+ initialState,
+ factory,
+ 0 /*containerViewId=*/
+ )
+
+ /**
+ * Launches a Fragment in the Activity's root view container `android.R.id.content`, with
+ * given arguments hosted by an empty [FragmentActivity] using the given
+ * [FragmentFactory] and waits for it to reach the resumed state.
+ *
+ * This method cannot be called from the main thread.
+ *
+ * @param fragmentClass a fragment class to instantiate
+ * @param fragmentArgs a bundle to passed into fragment
+ * @param factory a fragment factory to use or null to use default factory
+ */
+ @JvmStatic
+ public fun <F : Fragment> launchInContainer(
+ fragmentClass: Class<F>,
+ fragmentArgs: Bundle?,
+ factory: FragmentFactory?
+ ): FragmentScenario<F> = launchInContainer(
+ fragmentClass,
+ fragmentArgs,
+ R.style.FragmentScenarioEmptyFragmentActivityTheme,
+ Lifecycle.State.RESUMED,
+ factory
+ )
+
+ /**
+ * Launches a Fragment in the Activity's root view container `android.R.id.content`, with
+ * given arguments hosted by an empty [FragmentActivity] themed by [themeResId],
+ * using the given [FragmentFactory] and waits for it to reach the resumed state.
+ *
+ * This method cannot be called from the main thread.
+ *
+ * @param fragmentClass a fragment class to instantiate
+ * @param fragmentArgs a bundle to passed into fragment
+ * @param themeResId a style resource id to be set to the host activity's theme
+ * @param factory a fragment factory to use or null to use default factory
+ */
+ @JvmStatic
+ public fun <F : Fragment> launchInContainer(
+ fragmentClass: Class<F>,
+ fragmentArgs: Bundle?,
+ @StyleRes themeResId: Int,
+ factory: FragmentFactory?
+ ): FragmentScenario<F> = launchInContainer(
+ fragmentClass,
+ fragmentArgs,
+ themeResId,
+ Lifecycle.State.RESUMED,
+ factory
+ )
+
+ /**
+ * Launches a Fragment in the Activity's root view container `android.R.id.content`, with
+ * given arguments hosted by an empty [FragmentActivity] themed by [themeResId],
+ * using the given [FragmentFactory] and waits for it to reach [initialState].
+ *
+ * This method cannot be called from the main thread.
+ *
+ * @param fragmentClass a fragment class to instantiate
+ * @param fragmentArgs a bundle to passed into fragment
+ * @param themeResId a style resource id to be set to the host activity's theme
+ * @param initialState The initial [Lifecycle.State]. This must be one of
+ * [CREATED][Lifecycle.State.CREATED], [STARTED][Lifecycle.State.STARTED], and
+ * [RESUMED][Lifecycle.State.RESUMED].
+ * @param factory a fragment factory to use or null to use default factory
+ */
+ @JvmOverloads
+ @JvmStatic
+ public fun <F : Fragment> launchInContainer(
+ fragmentClass: Class<F>,
+ fragmentArgs: Bundle? = null,
+ @StyleRes themeResId: Int = R.style.FragmentScenarioEmptyFragmentActivityTheme,
+ initialState: Lifecycle.State = Lifecycle.State.RESUMED,
+ factory: FragmentFactory? = null
+ ): FragmentScenario<F> = internalLaunch(
+ fragmentClass,
+ fragmentArgs,
+ themeResId,
+ initialState,
+ factory,
+ android.R.id.content
+ )
+
+ @SuppressLint("RestrictedApi")
+ internal fun <F : Fragment> internalLaunch(
+ fragmentClass: Class<F>,
+ fragmentArgs: Bundle?,
+ @StyleRes themeResId: Int,
+ initialState: Lifecycle.State,
+ factory: FragmentFactory?,
+ @IdRes containerViewId: Int
+ ): FragmentScenario<F> {
+ val componentName = ComponentName(
+ ApplicationProvider.getApplicationContext(),
+ EmptyFragmentActivity::class.java
+ )
+ val startActivityIntent = Intent.makeMainActivity(componentName)
+ .putExtra(EmptyFragmentActivity.THEME_EXTRAS_BUNDLE_KEY, themeResId)
+ val scenario = FragmentScenario(
+ fragmentClass,
+ ActivityScenario.launch(
+ startActivityIntent
+ )
+ )
+ scenario.activityScenario.onActivity { activity ->
+ if (factory != null) {
+ FragmentFactoryHolderViewModel.getInstance(activity).fragmentFactory = factory
+ activity.supportFragmentManager.fragmentFactory = factory
+ }
+ val fragment = activity.supportFragmentManager.fragmentFactory
+ .instantiate(requireNotNull(fragmentClass.classLoader), fragmentClass.name)
+ fragment.arguments = fragmentArgs
+ activity.supportFragmentManager.commitNow {
+ add(containerViewId, fragment, FRAGMENT_TAG)
+ setMaxLifecycle(fragment, initialState)
+ }
+ }
+ return scenario
+ }
+ }
+}
diff --git a/fragment/fragment/api/1.3.0-beta02.txt b/fragment/fragment/api/1.3.0-beta02.txt
new file mode 100644
index 0000000..83e3c66
--- /dev/null
+++ b/fragment/fragment/api/1.3.0-beta02.txt
@@ -0,0 +1,450 @@
+// Signature format: 4.0
+package androidx.fragment.app {
+
+ public class DialogFragment extends androidx.fragment.app.Fragment implements android.content.DialogInterface.OnCancelListener android.content.DialogInterface.OnDismissListener {
+ ctor public DialogFragment();
+ ctor public DialogFragment(@LayoutRes int);
+ method public void dismiss();
+ method public void dismissAllowingStateLoss();
+ method public android.app.Dialog? getDialog();
+ method public boolean getShowsDialog();
+ method @StyleRes public int getTheme();
+ method public boolean isCancelable();
+ method public void onCancel(android.content.DialogInterface);
+ method @MainThread public android.app.Dialog onCreateDialog(android.os.Bundle?);
+ method public void onDismiss(android.content.DialogInterface);
+ method public final android.app.Dialog requireDialog();
+ method public void setCancelable(boolean);
+ method public void setShowsDialog(boolean);
+ method public void setStyle(int, @StyleRes int);
+ method public void show(androidx.fragment.app.FragmentManager, String?);
+ method public int show(androidx.fragment.app.FragmentTransaction, String?);
+ method public void showNow(androidx.fragment.app.FragmentManager, String?);
+ field public static final int STYLE_NORMAL = 0; // 0x0
+ field public static final int STYLE_NO_FRAME = 2; // 0x2
+ field public static final int STYLE_NO_INPUT = 3; // 0x3
+ field public static final int STYLE_NO_TITLE = 1; // 0x1
+ }
+
+ public class Fragment implements androidx.activity.result.ActivityResultCaller android.content.ComponentCallbacks androidx.lifecycle.HasDefaultViewModelProviderFactory androidx.lifecycle.LifecycleOwner androidx.savedstate.SavedStateRegistryOwner android.view.View.OnCreateContextMenuListener androidx.lifecycle.ViewModelStoreOwner {
+ ctor public Fragment();
+ ctor @ContentView public Fragment(@LayoutRes int);
+ method public void dump(String, java.io.FileDescriptor?, java.io.PrintWriter, String![]?);
+ method public final boolean equals(Object?);
+ method public final androidx.fragment.app.FragmentActivity? getActivity();
+ method public boolean getAllowEnterTransitionOverlap();
+ method public boolean getAllowReturnTransitionOverlap();
+ method public final android.os.Bundle? getArguments();
+ method public final androidx.fragment.app.FragmentManager getChildFragmentManager();
+ method public android.content.Context? getContext();
+ method public androidx.lifecycle.ViewModelProvider.Factory getDefaultViewModelProviderFactory();
+ method public Object? getEnterTransition();
+ method public Object? getExitTransition();
+ method @Deprecated public final androidx.fragment.app.FragmentManager? getFragmentManager();
+ method public final Object? getHost();
+ method public final int getId();
+ method public final android.view.LayoutInflater getLayoutInflater();
+ method public androidx.lifecycle.Lifecycle getLifecycle();
+ method @Deprecated public androidx.loader.app.LoaderManager getLoaderManager();
+ method public final androidx.fragment.app.Fragment? getParentFragment();
+ method public final androidx.fragment.app.FragmentManager getParentFragmentManager();
+ method public Object? getReenterTransition();
+ method public final android.content.res.Resources getResources();
+ method @Deprecated public final boolean getRetainInstance();
+ method public Object? getReturnTransition();
+ method public final androidx.savedstate.SavedStateRegistry getSavedStateRegistry();
+ method public Object? getSharedElementEnterTransition();
+ method public Object? getSharedElementReturnTransition();
+ method public final String getString(@StringRes int);
+ method public final String getString(@StringRes int, java.lang.Object!...);
+ method public final String? getTag();
+ method @Deprecated public final androidx.fragment.app.Fragment? getTargetFragment();
+ method @Deprecated public final int getTargetRequestCode();
+ method public final CharSequence getText(@StringRes int);
+ method @Deprecated public boolean getUserVisibleHint();
+ method public android.view.View? getView();
+ method @MainThread public androidx.lifecycle.LifecycleOwner getViewLifecycleOwner();
+ method public androidx.lifecycle.LiveData<androidx.lifecycle.LifecycleOwner!> getViewLifecycleOwnerLiveData();
+ method public androidx.lifecycle.ViewModelStore getViewModelStore();
+ method public final int hashCode();
+ method @Deprecated public static androidx.fragment.app.Fragment instantiate(android.content.Context, String);
+ method @Deprecated public static androidx.fragment.app.Fragment instantiate(android.content.Context, String, android.os.Bundle?);
+ method public final boolean isAdded();
+ method public final boolean isDetached();
+ method public final boolean isHidden();
+ method public final boolean isInLayout();
+ method public final boolean isRemoving();
+ method public final boolean isResumed();
+ method public final boolean isStateSaved();
+ method public final boolean isVisible();
+ method @Deprecated @CallSuper @MainThread public void onActivityCreated(android.os.Bundle?);
+ method @Deprecated public void onActivityResult(int, int, android.content.Intent?);
+ method @CallSuper @MainThread public void onAttach(android.content.Context);
+ method @Deprecated @CallSuper @MainThread public void onAttach(android.app.Activity);
+ method @Deprecated @MainThread public void onAttachFragment(androidx.fragment.app.Fragment);
+ method @CallSuper public void onConfigurationChanged(android.content.res.Configuration);
+ method @MainThread public boolean onContextItemSelected(android.view.MenuItem);
+ method @CallSuper @MainThread public void onCreate(android.os.Bundle?);
+ method @MainThread public android.view.animation.Animation? onCreateAnimation(int, boolean, int);
+ method @MainThread public android.animation.Animator? onCreateAnimator(int, boolean, int);
+ method @MainThread public void onCreateContextMenu(android.view.ContextMenu, android.view.View, android.view.ContextMenu.ContextMenuInfo?);
+ method @MainThread public void onCreateOptionsMenu(android.view.Menu, android.view.MenuInflater);
+ method @MainThread public android.view.View? onCreateView(android.view.LayoutInflater, android.view.ViewGroup?, android.os.Bundle?);
+ method @CallSuper @MainThread public void onDestroy();
+ method @MainThread public void onDestroyOptionsMenu();
+ method @CallSuper @MainThread public void onDestroyView();
+ method @CallSuper @MainThread public void onDetach();
+ method public android.view.LayoutInflater onGetLayoutInflater(android.os.Bundle?);
+ method @MainThread public void onHiddenChanged(boolean);
+ method @CallSuper @UiThread public void onInflate(android.content.Context, android.util.AttributeSet, android.os.Bundle?);
+ method @Deprecated @CallSuper @UiThread public void onInflate(android.app.Activity, android.util.AttributeSet, android.os.Bundle?);
+ method @CallSuper @MainThread public void onLowMemory();
+ method public void onMultiWindowModeChanged(boolean);
+ method @MainThread public boolean onOptionsItemSelected(android.view.MenuItem);
+ method @MainThread public void onOptionsMenuClosed(android.view.Menu);
+ method @CallSuper @MainThread public void onPause();
+ method public void onPictureInPictureModeChanged(boolean);
+ method @MainThread public void onPrepareOptionsMenu(android.view.Menu);
+ method @MainThread public void onPrimaryNavigationFragmentChanged(boolean);
+ method @Deprecated public void onRequestPermissionsResult(int, String![], int[]);
+ method @CallSuper @MainThread public void onResume();
+ method @MainThread public void onSaveInstanceState(android.os.Bundle);
+ method @CallSuper @MainThread public void onStart();
+ method @CallSuper @MainThread public void onStop();
+ method @MainThread public void onViewCreated(android.view.View, android.os.Bundle?);
+ method @CallSuper @MainThread public void onViewStateRestored(android.os.Bundle?);
+ method public void postponeEnterTransition();
+ method public final void postponeEnterTransition(long, java.util.concurrent.TimeUnit);
+ method @MainThread public final <I, O> androidx.activity.result.ActivityResultLauncher<I!> registerForActivityResult(androidx.activity.result.contract.ActivityResultContract<I!,O!>, androidx.activity.result.ActivityResultCallback<O!>);
+ method @MainThread public final <I, O> androidx.activity.result.ActivityResultLauncher<I!> registerForActivityResult(androidx.activity.result.contract.ActivityResultContract<I!,O!>, androidx.activity.result.ActivityResultRegistry, androidx.activity.result.ActivityResultCallback<O!>);
+ method public void registerForContextMenu(android.view.View);
+ method @Deprecated public final void requestPermissions(String![], int);
+ method public final androidx.fragment.app.FragmentActivity requireActivity();
+ method public final android.os.Bundle requireArguments();
+ method public final android.content.Context requireContext();
+ method @Deprecated public final androidx.fragment.app.FragmentManager requireFragmentManager();
+ method public final Object requireHost();
+ method public final androidx.fragment.app.Fragment requireParentFragment();
+ method public final android.view.View requireView();
+ method public void setAllowEnterTransitionOverlap(boolean);
+ method public void setAllowReturnTransitionOverlap(boolean);
+ method public void setArguments(android.os.Bundle?);
+ method public void setEnterSharedElementCallback(androidx.core.app.SharedElementCallback?);
+ method public void setEnterTransition(Object?);
+ method public void setExitSharedElementCallback(androidx.core.app.SharedElementCallback?);
+ method public void setExitTransition(Object?);
+ method public void setHasOptionsMenu(boolean);
+ method public void setInitialSavedState(androidx.fragment.app.Fragment.SavedState?);
+ method public void setMenuVisibility(boolean);
+ method public void setReenterTransition(Object?);
+ method @Deprecated public void setRetainInstance(boolean);
+ method public void setReturnTransition(Object?);
+ method public void setSharedElementEnterTransition(Object?);
+ method public void setSharedElementReturnTransition(Object?);
+ method @Deprecated public void setTargetFragment(androidx.fragment.app.Fragment?, int);
+ method @Deprecated public void setUserVisibleHint(boolean);
+ method public boolean shouldShowRequestPermissionRationale(String);
+ method public void startActivity(android.content.Intent!);
+ method public void startActivity(android.content.Intent!, android.os.Bundle?);
+ method @Deprecated public void startActivityForResult(android.content.Intent!, int);
+ method @Deprecated public void startActivityForResult(android.content.Intent!, int, android.os.Bundle?);
+ method @Deprecated public void startIntentSenderForResult(android.content.IntentSender!, int, android.content.Intent?, int, int, int, android.os.Bundle?) throws android.content.IntentSender.SendIntentException;
+ method public void startPostponedEnterTransition();
+ method public void unregisterForContextMenu(android.view.View);
+ }
+
+ public static class Fragment.InstantiationException extends java.lang.RuntimeException {
+ ctor public Fragment.InstantiationException(String, Exception?);
+ }
+
+ public static class Fragment.SavedState implements android.os.Parcelable {
+ method public int describeContents();
+ method public void writeToParcel(android.os.Parcel, int);
+ field public static final android.os.Parcelable.Creator<androidx.fragment.app.Fragment.SavedState!> CREATOR;
+ }
+
+ public class FragmentActivity extends androidx.activity.ComponentActivity implements androidx.core.app.ActivityCompat.OnRequestPermissionsResultCallback androidx.lifecycle.LifecycleOwner {
+ ctor public FragmentActivity();
+ ctor @ContentView public FragmentActivity(@LayoutRes int);
+ method public androidx.fragment.app.FragmentManager getSupportFragmentManager();
+ method @Deprecated public androidx.loader.app.LoaderManager getSupportLoaderManager();
+ method @Deprecated @MainThread public void onAttachFragment(androidx.fragment.app.Fragment);
+ method @CallSuper public void onMultiWindowModeChanged(boolean);
+ method @CallSuper public void onPictureInPictureModeChanged(boolean);
+ method protected void onResumeFragments();
+ method public void onStateNotSaved();
+ method public void setEnterSharedElementCallback(androidx.core.app.SharedElementCallback?);
+ method public void setExitSharedElementCallback(androidx.core.app.SharedElementCallback?);
+ method public void startActivityFromFragment(androidx.fragment.app.Fragment, android.content.Intent!, int);
+ method public void startActivityFromFragment(androidx.fragment.app.Fragment, android.content.Intent!, int, android.os.Bundle?);
+ method @Deprecated public void startIntentSenderFromFragment(androidx.fragment.app.Fragment, android.content.IntentSender!, int, android.content.Intent?, int, int, int, android.os.Bundle?) throws android.content.IntentSender.SendIntentException;
+ method public void supportFinishAfterTransition();
+ method @Deprecated public void supportInvalidateOptionsMenu();
+ method public void supportPostponeEnterTransition();
+ method public void supportStartPostponedEnterTransition();
+ method @Deprecated public final void validateRequestPermissionsRequestCode(int);
+ }
+
+ public abstract class FragmentContainer {
+ ctor public FragmentContainer();
+ method @Deprecated public androidx.fragment.app.Fragment instantiate(android.content.Context, String, android.os.Bundle?);
+ method public abstract android.view.View? onFindViewById(@IdRes int);
+ method public abstract boolean onHasView();
+ }
+
+ public final class FragmentContainerView extends android.widget.FrameLayout {
+ ctor public FragmentContainerView(android.content.Context);
+ ctor public FragmentContainerView(android.content.Context, android.util.AttributeSet?);
+ ctor public FragmentContainerView(android.content.Context, android.util.AttributeSet?, int);
+ }
+
+ public class FragmentController {
+ method public void attachHost(androidx.fragment.app.Fragment?);
+ method public static androidx.fragment.app.FragmentController createController(androidx.fragment.app.FragmentHostCallback<?>);
+ method public void dispatchActivityCreated();
+ method public void dispatchConfigurationChanged(android.content.res.Configuration);
+ method public boolean dispatchContextItemSelected(android.view.MenuItem);
+ method public void dispatchCreate();
+ method public boolean dispatchCreateOptionsMenu(android.view.Menu, android.view.MenuInflater);
+ method public void dispatchDestroy();
+ method public void dispatchDestroyView();
+ method public void dispatchLowMemory();
+ method public void dispatchMultiWindowModeChanged(boolean);
+ method public boolean dispatchOptionsItemSelected(android.view.MenuItem);
+ method public void dispatchOptionsMenuClosed(android.view.Menu);
+ method public void dispatchPause();
+ method public void dispatchPictureInPictureModeChanged(boolean);
+ method public boolean dispatchPrepareOptionsMenu(android.view.Menu);
+ method @Deprecated public void dispatchReallyStop();
+ method public void dispatchResume();
+ method public void dispatchStart();
+ method public void dispatchStop();
+ method @Deprecated public void doLoaderDestroy();
+ method @Deprecated public void doLoaderRetain();
+ method @Deprecated public void doLoaderStart();
+ method @Deprecated public void doLoaderStop(boolean);
+ method @Deprecated public void dumpLoaders(String, java.io.FileDescriptor?, java.io.PrintWriter, String![]?);
+ method public boolean execPendingActions();
+ method public androidx.fragment.app.Fragment? findFragmentByWho(String);
+ method public java.util.List<androidx.fragment.app.Fragment!> getActiveFragments(java.util.List<androidx.fragment.app.Fragment!>!);
+ method public int getActiveFragmentsCount();
+ method public androidx.fragment.app.FragmentManager getSupportFragmentManager();
+ method @Deprecated public androidx.loader.app.LoaderManager! getSupportLoaderManager();
+ method public void noteStateNotSaved();
+ method public android.view.View? onCreateView(android.view.View?, String, android.content.Context, android.util.AttributeSet);
+ method @Deprecated public void reportLoaderStart();
+ method @Deprecated public void restoreAllState(android.os.Parcelable?, java.util.List<androidx.fragment.app.Fragment!>?);
+ method @Deprecated public void restoreAllState(android.os.Parcelable?, androidx.fragment.app.FragmentManagerNonConfig?);
+ method @Deprecated public void restoreLoaderNonConfig(androidx.collection.SimpleArrayMap<java.lang.String!,androidx.loader.app.LoaderManager!>!);
+ method public void restoreSaveState(android.os.Parcelable?);
+ method @Deprecated public androidx.collection.SimpleArrayMap<java.lang.String!,androidx.loader.app.LoaderManager!>? retainLoaderNonConfig();
+ method @Deprecated public androidx.fragment.app.FragmentManagerNonConfig? retainNestedNonConfig();
+ method @Deprecated public java.util.List<androidx.fragment.app.Fragment!>? retainNonConfig();
+ method public android.os.Parcelable? saveAllState();
+ }
+
+ public class FragmentFactory {
+ ctor public FragmentFactory();
+ method public androidx.fragment.app.Fragment instantiate(ClassLoader, String);
+ method public static Class<? extends androidx.fragment.app.Fragment> loadFragmentClass(ClassLoader, String);
+ }
+
+ public abstract class FragmentHostCallback<E> extends androidx.fragment.app.FragmentContainer {
+ ctor public FragmentHostCallback(android.content.Context, android.os.Handler, int);
+ method public void onDump(String, java.io.FileDescriptor?, java.io.PrintWriter, String![]?);
+ method public android.view.View? onFindViewById(int);
+ method public abstract E? onGetHost();
+ method public android.view.LayoutInflater onGetLayoutInflater();
+ method public int onGetWindowAnimations();
+ method public boolean onHasView();
+ method public boolean onHasWindowAnimations();
+ method @Deprecated public void onRequestPermissionsFromFragment(androidx.fragment.app.Fragment, String![], int);
+ method public boolean onShouldSaveFragmentState(androidx.fragment.app.Fragment);
+ method public boolean onShouldShowRequestPermissionRationale(String);
+ method public void onStartActivityFromFragment(androidx.fragment.app.Fragment, android.content.Intent!, int);
+ method public void onStartActivityFromFragment(androidx.fragment.app.Fragment, android.content.Intent!, int, android.os.Bundle?);
+ method @Deprecated public void onStartIntentSenderFromFragment(androidx.fragment.app.Fragment, android.content.IntentSender!, int, android.content.Intent?, int, int, int, android.os.Bundle?) throws android.content.IntentSender.SendIntentException;
+ method public void onSupportInvalidateOptionsMenu();
+ }
+
+ public abstract class FragmentManager implements androidx.fragment.app.FragmentResultOwner {
+ ctor public FragmentManager();
+ method public void addFragmentOnAttachListener(androidx.fragment.app.FragmentOnAttachListener);
+ method public void addOnBackStackChangedListener(androidx.fragment.app.FragmentManager.OnBackStackChangedListener);
+ method public androidx.fragment.app.FragmentTransaction beginTransaction();
+ method public final void clearFragmentResult(String);
+ method public final void clearFragmentResultListener(String);
+ method public void dump(String, java.io.FileDescriptor?, java.io.PrintWriter, String![]?);
+ method @Deprecated public static void enableDebugLogging(boolean);
+ method public boolean executePendingTransactions();
+ method public static <F extends androidx.fragment.app.Fragment> F findFragment(android.view.View);
+ method public androidx.fragment.app.Fragment? findFragmentById(@IdRes int);
+ method public androidx.fragment.app.Fragment? findFragmentByTag(String?);
+ method public androidx.fragment.app.FragmentManager.BackStackEntry getBackStackEntryAt(int);
+ method public int getBackStackEntryCount();
+ method public androidx.fragment.app.Fragment? getFragment(android.os.Bundle, String);
+ method public androidx.fragment.app.FragmentFactory getFragmentFactory();
+ method public java.util.List<androidx.fragment.app.Fragment!> getFragments();
+ method public androidx.fragment.app.Fragment? getPrimaryNavigationFragment();
+ method public boolean isDestroyed();
+ method public boolean isStateSaved();
+ method public void popBackStack();
+ method public void popBackStack(String?, int);
+ method public void popBackStack(int, int);
+ method public boolean popBackStackImmediate();
+ method public boolean popBackStackImmediate(String?, int);
+ method public boolean popBackStackImmediate(int, int);
+ method public void putFragment(android.os.Bundle, String, androidx.fragment.app.Fragment);
+ method public void registerFragmentLifecycleCallbacks(androidx.fragment.app.FragmentManager.FragmentLifecycleCallbacks, boolean);
+ method public void removeFragmentOnAttachListener(androidx.fragment.app.FragmentOnAttachListener);
+ method public void removeOnBackStackChangedListener(androidx.fragment.app.FragmentManager.OnBackStackChangedListener);
+ method public androidx.fragment.app.Fragment.SavedState? saveFragmentInstanceState(androidx.fragment.app.Fragment);
+ method public void setFragmentFactory(androidx.fragment.app.FragmentFactory);
+ method public final void setFragmentResult(String, android.os.Bundle);
+ method public final void setFragmentResultListener(String, androidx.lifecycle.LifecycleOwner, androidx.fragment.app.FragmentResultListener);
+ method public void unregisterFragmentLifecycleCallbacks(androidx.fragment.app.FragmentManager.FragmentLifecycleCallbacks);
+ field public static final int POP_BACK_STACK_INCLUSIVE = 1; // 0x1
+ }
+
+ public static interface FragmentManager.BackStackEntry {
+ method @Deprecated public CharSequence? getBreadCrumbShortTitle();
+ method @Deprecated @StringRes public int getBreadCrumbShortTitleRes();
+ method @Deprecated public CharSequence? getBreadCrumbTitle();
+ method @Deprecated @StringRes public int getBreadCrumbTitleRes();
+ method public int getId();
+ method public String? getName();
+ }
+
+ public abstract static class FragmentManager.FragmentLifecycleCallbacks {
+ ctor public FragmentManager.FragmentLifecycleCallbacks();
+ method @Deprecated public void onFragmentActivityCreated(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment, android.os.Bundle?);
+ method public void onFragmentAttached(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment, android.content.Context);
+ method public void onFragmentCreated(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment, android.os.Bundle?);
+ method public void onFragmentDestroyed(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment);
+ method public void onFragmentDetached(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment);
+ method public void onFragmentPaused(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment);
+ method public void onFragmentPreAttached(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment, android.content.Context);
+ method public void onFragmentPreCreated(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment, android.os.Bundle?);
+ method public void onFragmentResumed(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment);
+ method public void onFragmentSaveInstanceState(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment, android.os.Bundle);
+ method public void onFragmentStarted(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment);
+ method public void onFragmentStopped(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment);
+ method public void onFragmentViewCreated(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment, android.view.View, android.os.Bundle?);
+ method public void onFragmentViewDestroyed(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment);
+ }
+
+ public static interface FragmentManager.OnBackStackChangedListener {
+ method @MainThread public void onBackStackChanged();
+ }
+
+ @Deprecated public class FragmentManagerNonConfig {
+ }
+
+ public interface FragmentOnAttachListener {
+ method @MainThread public void onAttachFragment(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment);
+ }
+
+ @Deprecated public abstract class FragmentPagerAdapter extends androidx.viewpager.widget.PagerAdapter {
+ ctor @Deprecated public FragmentPagerAdapter(androidx.fragment.app.FragmentManager);
+ ctor @Deprecated public FragmentPagerAdapter(androidx.fragment.app.FragmentManager, int);
+ method @Deprecated public abstract androidx.fragment.app.Fragment getItem(int);
+ method @Deprecated public long getItemId(int);
+ method @Deprecated public boolean isViewFromObject(android.view.View, Object);
+ field @Deprecated public static final int BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT = 1; // 0x1
+ field @Deprecated public static final int BEHAVIOR_SET_USER_VISIBLE_HINT = 0; // 0x0
+ }
+
+ public interface FragmentResultListener {
+ method public void onFragmentResult(String, android.os.Bundle);
+ }
+
+ public interface FragmentResultOwner {
+ method public void clearFragmentResult(String);
+ method public void clearFragmentResultListener(String);
+ method public void setFragmentResult(String, android.os.Bundle);
+ method public void setFragmentResultListener(String, androidx.lifecycle.LifecycleOwner, androidx.fragment.app.FragmentResultListener);
+ }
+
+ @Deprecated public abstract class FragmentStatePagerAdapter extends androidx.viewpager.widget.PagerAdapter {
+ ctor @Deprecated public FragmentStatePagerAdapter(androidx.fragment.app.FragmentManager);
+ ctor @Deprecated public FragmentStatePagerAdapter(androidx.fragment.app.FragmentManager, int);
+ method @Deprecated public abstract androidx.fragment.app.Fragment getItem(int);
+ method @Deprecated public boolean isViewFromObject(android.view.View, Object);
+ field @Deprecated public static final int BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT = 1; // 0x1
+ field @Deprecated public static final int BEHAVIOR_SET_USER_VISIBLE_HINT = 0; // 0x0
+ }
+
+ @Deprecated public class FragmentTabHost extends android.widget.TabHost implements android.widget.TabHost.OnTabChangeListener {
+ ctor @Deprecated public FragmentTabHost(android.content.Context);
+ ctor @Deprecated public FragmentTabHost(android.content.Context, android.util.AttributeSet?);
+ method @Deprecated public void addTab(android.widget.TabHost.TabSpec, Class<?>, android.os.Bundle?);
+ method @Deprecated public void onTabChanged(String?);
+ method @Deprecated public void setup(android.content.Context, androidx.fragment.app.FragmentManager);
+ method @Deprecated public void setup(android.content.Context, androidx.fragment.app.FragmentManager, int);
+ }
+
+ public abstract class FragmentTransaction {
+ ctor @Deprecated public FragmentTransaction();
+ method public final androidx.fragment.app.FragmentTransaction add(Class<? extends androidx.fragment.app.Fragment>, android.os.Bundle?, String?);
+ method public androidx.fragment.app.FragmentTransaction add(androidx.fragment.app.Fragment, String?);
+ method public final androidx.fragment.app.FragmentTransaction add(@IdRes int, Class<? extends androidx.fragment.app.Fragment>, android.os.Bundle?);
+ method public androidx.fragment.app.FragmentTransaction add(@IdRes int, androidx.fragment.app.Fragment);
+ method public final androidx.fragment.app.FragmentTransaction add(@IdRes int, Class<? extends androidx.fragment.app.Fragment>, android.os.Bundle?, String?);
+ method public androidx.fragment.app.FragmentTransaction add(@IdRes int, androidx.fragment.app.Fragment, String?);
+ method public androidx.fragment.app.FragmentTransaction addSharedElement(android.view.View, String);
+ method public androidx.fragment.app.FragmentTransaction addToBackStack(String?);
+ method public androidx.fragment.app.FragmentTransaction attach(androidx.fragment.app.Fragment);
+ method public abstract int commit();
+ method public abstract int commitAllowingStateLoss();
+ method public abstract void commitNow();
+ method public abstract void commitNowAllowingStateLoss();
+ method public androidx.fragment.app.FragmentTransaction detach(androidx.fragment.app.Fragment);
+ method public androidx.fragment.app.FragmentTransaction disallowAddToBackStack();
+ method public androidx.fragment.app.FragmentTransaction hide(androidx.fragment.app.Fragment);
+ method public boolean isAddToBackStackAllowed();
+ method public boolean isEmpty();
+ method public androidx.fragment.app.FragmentTransaction remove(androidx.fragment.app.Fragment);
+ method public final androidx.fragment.app.FragmentTransaction replace(@IdRes int, Class<? extends androidx.fragment.app.Fragment>, android.os.Bundle?);
+ method public androidx.fragment.app.FragmentTransaction replace(@IdRes int, androidx.fragment.app.Fragment);
+ method public final androidx.fragment.app.FragmentTransaction replace(@IdRes int, Class<? extends androidx.fragment.app.Fragment>, android.os.Bundle?, String?);
+ method public androidx.fragment.app.FragmentTransaction replace(@IdRes int, androidx.fragment.app.Fragment, String?);
+ method public androidx.fragment.app.FragmentTransaction runOnCommit(Runnable);
+ method @Deprecated public androidx.fragment.app.FragmentTransaction setAllowOptimization(boolean);
+ method @Deprecated public androidx.fragment.app.FragmentTransaction setBreadCrumbShortTitle(@StringRes int);
+ method @Deprecated public androidx.fragment.app.FragmentTransaction setBreadCrumbShortTitle(CharSequence?);
+ method @Deprecated public androidx.fragment.app.FragmentTransaction setBreadCrumbTitle(@StringRes int);
+ method @Deprecated public androidx.fragment.app.FragmentTransaction setBreadCrumbTitle(CharSequence?);
+ method public androidx.fragment.app.FragmentTransaction setCustomAnimations(@AnimRes @AnimatorRes int, @AnimRes @AnimatorRes int);
+ method public androidx.fragment.app.FragmentTransaction setCustomAnimations(@AnimRes @AnimatorRes int, @AnimRes @AnimatorRes int, @AnimRes @AnimatorRes int, @AnimRes @AnimatorRes int);
+ method public androidx.fragment.app.FragmentTransaction setMaxLifecycle(androidx.fragment.app.Fragment, androidx.lifecycle.Lifecycle.State);
+ method public androidx.fragment.app.FragmentTransaction setPrimaryNavigationFragment(androidx.fragment.app.Fragment?);
+ method public androidx.fragment.app.FragmentTransaction setReorderingAllowed(boolean);
+ method public androidx.fragment.app.FragmentTransaction setTransition(int);
+ method @Deprecated public androidx.fragment.app.FragmentTransaction setTransitionStyle(@StyleRes int);
+ method public androidx.fragment.app.FragmentTransaction show(androidx.fragment.app.Fragment);
+ field public static final int TRANSIT_ENTER_MASK = 4096; // 0x1000
+ field public static final int TRANSIT_EXIT_MASK = 8192; // 0x2000
+ field public static final int TRANSIT_FRAGMENT_CLOSE = 8194; // 0x2002
+ field public static final int TRANSIT_FRAGMENT_FADE = 4099; // 0x1003
+ field public static final int TRANSIT_FRAGMENT_OPEN = 4097; // 0x1001
+ field public static final int TRANSIT_NONE = 0; // 0x0
+ field public static final int TRANSIT_UNSET = -1; // 0xffffffff
+ }
+
+ public class ListFragment extends androidx.fragment.app.Fragment {
+ ctor public ListFragment();
+ method public android.widget.ListAdapter? getListAdapter();
+ method public android.widget.ListView getListView();
+ method public long getSelectedItemId();
+ method public int getSelectedItemPosition();
+ method public void onListItemClick(android.widget.ListView, android.view.View, int, long);
+ method public final android.widget.ListAdapter requireListAdapter();
+ method public void setEmptyText(CharSequence?);
+ method public void setListAdapter(android.widget.ListAdapter?);
+ method public void setListShown(boolean);
+ method public void setListShownNoAnimation(boolean);
+ method public void setSelection(int);
+ }
+
+}
+
diff --git a/fragment/fragment/api/public_plus_experimental_1.3.0-beta02.txt b/fragment/fragment/api/public_plus_experimental_1.3.0-beta02.txt
new file mode 100644
index 0000000..4644e32
--- /dev/null
+++ b/fragment/fragment/api/public_plus_experimental_1.3.0-beta02.txt
@@ -0,0 +1,454 @@
+// Signature format: 4.0
+package androidx.fragment.app {
+
+ public class DialogFragment extends androidx.fragment.app.Fragment implements android.content.DialogInterface.OnCancelListener android.content.DialogInterface.OnDismissListener {
+ ctor public DialogFragment();
+ ctor public DialogFragment(@LayoutRes int);
+ method public void dismiss();
+ method public void dismissAllowingStateLoss();
+ method public android.app.Dialog? getDialog();
+ method public boolean getShowsDialog();
+ method @StyleRes public int getTheme();
+ method public boolean isCancelable();
+ method public void onCancel(android.content.DialogInterface);
+ method @MainThread public android.app.Dialog onCreateDialog(android.os.Bundle?);
+ method public void onDismiss(android.content.DialogInterface);
+ method public final android.app.Dialog requireDialog();
+ method public void setCancelable(boolean);
+ method public void setShowsDialog(boolean);
+ method public void setStyle(int, @StyleRes int);
+ method public void show(androidx.fragment.app.FragmentManager, String?);
+ method public int show(androidx.fragment.app.FragmentTransaction, String?);
+ method public void showNow(androidx.fragment.app.FragmentManager, String?);
+ field public static final int STYLE_NORMAL = 0; // 0x0
+ field public static final int STYLE_NO_FRAME = 2; // 0x2
+ field public static final int STYLE_NO_INPUT = 3; // 0x3
+ field public static final int STYLE_NO_TITLE = 1; // 0x1
+ }
+
+ public class Fragment implements androidx.activity.result.ActivityResultCaller android.content.ComponentCallbacks androidx.lifecycle.HasDefaultViewModelProviderFactory androidx.lifecycle.LifecycleOwner androidx.savedstate.SavedStateRegistryOwner android.view.View.OnCreateContextMenuListener androidx.lifecycle.ViewModelStoreOwner {
+ ctor public Fragment();
+ ctor @ContentView public Fragment(@LayoutRes int);
+ method public void dump(String, java.io.FileDescriptor?, java.io.PrintWriter, String![]?);
+ method public final boolean equals(Object?);
+ method public final androidx.fragment.app.FragmentActivity? getActivity();
+ method public boolean getAllowEnterTransitionOverlap();
+ method public boolean getAllowReturnTransitionOverlap();
+ method public final android.os.Bundle? getArguments();
+ method public final androidx.fragment.app.FragmentManager getChildFragmentManager();
+ method public android.content.Context? getContext();
+ method public androidx.lifecycle.ViewModelProvider.Factory getDefaultViewModelProviderFactory();
+ method public Object? getEnterTransition();
+ method public Object? getExitTransition();
+ method @Deprecated public final androidx.fragment.app.FragmentManager? getFragmentManager();
+ method public final Object? getHost();
+ method public final int getId();
+ method public final android.view.LayoutInflater getLayoutInflater();
+ method public androidx.lifecycle.Lifecycle getLifecycle();
+ method @Deprecated public androidx.loader.app.LoaderManager getLoaderManager();
+ method public final androidx.fragment.app.Fragment? getParentFragment();
+ method public final androidx.fragment.app.FragmentManager getParentFragmentManager();
+ method public Object? getReenterTransition();
+ method public final android.content.res.Resources getResources();
+ method @Deprecated public final boolean getRetainInstance();
+ method public Object? getReturnTransition();
+ method public final androidx.savedstate.SavedStateRegistry getSavedStateRegistry();
+ method public Object? getSharedElementEnterTransition();
+ method public Object? getSharedElementReturnTransition();
+ method public final String getString(@StringRes int);
+ method public final String getString(@StringRes int, java.lang.Object!...);
+ method public final String? getTag();
+ method @Deprecated public final androidx.fragment.app.Fragment? getTargetFragment();
+ method @Deprecated public final int getTargetRequestCode();
+ method public final CharSequence getText(@StringRes int);
+ method @Deprecated public boolean getUserVisibleHint();
+ method public android.view.View? getView();
+ method @MainThread public androidx.lifecycle.LifecycleOwner getViewLifecycleOwner();
+ method public androidx.lifecycle.LiveData<androidx.lifecycle.LifecycleOwner!> getViewLifecycleOwnerLiveData();
+ method public androidx.lifecycle.ViewModelStore getViewModelStore();
+ method public final int hashCode();
+ method @Deprecated public static androidx.fragment.app.Fragment instantiate(android.content.Context, String);
+ method @Deprecated public static androidx.fragment.app.Fragment instantiate(android.content.Context, String, android.os.Bundle?);
+ method public final boolean isAdded();
+ method public final boolean isDetached();
+ method public final boolean isHidden();
+ method public final boolean isInLayout();
+ method public final boolean isRemoving();
+ method public final boolean isResumed();
+ method public final boolean isStateSaved();
+ method public final boolean isVisible();
+ method @Deprecated @CallSuper @MainThread public void onActivityCreated(android.os.Bundle?);
+ method @Deprecated public void onActivityResult(int, int, android.content.Intent?);
+ method @CallSuper @MainThread public void onAttach(android.content.Context);
+ method @Deprecated @CallSuper @MainThread public void onAttach(android.app.Activity);
+ method @Deprecated @MainThread public void onAttachFragment(androidx.fragment.app.Fragment);
+ method @CallSuper public void onConfigurationChanged(android.content.res.Configuration);
+ method @MainThread public boolean onContextItemSelected(android.view.MenuItem);
+ method @CallSuper @MainThread public void onCreate(android.os.Bundle?);
+ method @MainThread public android.view.animation.Animation? onCreateAnimation(int, boolean, int);
+ method @MainThread public android.animation.Animator? onCreateAnimator(int, boolean, int);
+ method @MainThread public void onCreateContextMenu(android.view.ContextMenu, android.view.View, android.view.ContextMenu.ContextMenuInfo?);
+ method @MainThread public void onCreateOptionsMenu(android.view.Menu, android.view.MenuInflater);
+ method @MainThread public android.view.View? onCreateView(android.view.LayoutInflater, android.view.ViewGroup?, android.os.Bundle?);
+ method @CallSuper @MainThread public void onDestroy();
+ method @MainThread public void onDestroyOptionsMenu();
+ method @CallSuper @MainThread public void onDestroyView();
+ method @CallSuper @MainThread public void onDetach();
+ method public android.view.LayoutInflater onGetLayoutInflater(android.os.Bundle?);
+ method @MainThread public void onHiddenChanged(boolean);
+ method @CallSuper @UiThread public void onInflate(android.content.Context, android.util.AttributeSet, android.os.Bundle?);
+ method @Deprecated @CallSuper @UiThread public void onInflate(android.app.Activity, android.util.AttributeSet, android.os.Bundle?);
+ method @CallSuper @MainThread public void onLowMemory();
+ method public void onMultiWindowModeChanged(boolean);
+ method @MainThread public boolean onOptionsItemSelected(android.view.MenuItem);
+ method @MainThread public void onOptionsMenuClosed(android.view.Menu);
+ method @CallSuper @MainThread public void onPause();
+ method public void onPictureInPictureModeChanged(boolean);
+ method @MainThread public void onPrepareOptionsMenu(android.view.Menu);
+ method @MainThread public void onPrimaryNavigationFragmentChanged(boolean);
+ method @Deprecated public void onRequestPermissionsResult(int, String![], int[]);
+ method @CallSuper @MainThread public void onResume();
+ method @MainThread public void onSaveInstanceState(android.os.Bundle);
+ method @CallSuper @MainThread public void onStart();
+ method @CallSuper @MainThread public void onStop();
+ method @MainThread public void onViewCreated(android.view.View, android.os.Bundle?);
+ method @CallSuper @MainThread public void onViewStateRestored(android.os.Bundle?);
+ method public void postponeEnterTransition();
+ method public final void postponeEnterTransition(long, java.util.concurrent.TimeUnit);
+ method @MainThread public final <I, O> androidx.activity.result.ActivityResultLauncher<I!> registerForActivityResult(androidx.activity.result.contract.ActivityResultContract<I!,O!>, androidx.activity.result.ActivityResultCallback<O!>);
+ method @MainThread public final <I, O> androidx.activity.result.ActivityResultLauncher<I!> registerForActivityResult(androidx.activity.result.contract.ActivityResultContract<I!,O!>, androidx.activity.result.ActivityResultRegistry, androidx.activity.result.ActivityResultCallback<O!>);
+ method public void registerForContextMenu(android.view.View);
+ method @Deprecated public final void requestPermissions(String![], int);
+ method public final androidx.fragment.app.FragmentActivity requireActivity();
+ method public final android.os.Bundle requireArguments();
+ method public final android.content.Context requireContext();
+ method @Deprecated public final androidx.fragment.app.FragmentManager requireFragmentManager();
+ method public final Object requireHost();
+ method public final androidx.fragment.app.Fragment requireParentFragment();
+ method public final android.view.View requireView();
+ method public void setAllowEnterTransitionOverlap(boolean);
+ method public void setAllowReturnTransitionOverlap(boolean);
+ method public void setArguments(android.os.Bundle?);
+ method public void setEnterSharedElementCallback(androidx.core.app.SharedElementCallback?);
+ method public void setEnterTransition(Object?);
+ method public void setExitSharedElementCallback(androidx.core.app.SharedElementCallback?);
+ method public void setExitTransition(Object?);
+ method public void setHasOptionsMenu(boolean);
+ method public void setInitialSavedState(androidx.fragment.app.Fragment.SavedState?);
+ method public void setMenuVisibility(boolean);
+ method public void setReenterTransition(Object?);
+ method @Deprecated public void setRetainInstance(boolean);
+ method public void setReturnTransition(Object?);
+ method public void setSharedElementEnterTransition(Object?);
+ method public void setSharedElementReturnTransition(Object?);
+ method @Deprecated public void setTargetFragment(androidx.fragment.app.Fragment?, int);
+ method @Deprecated public void setUserVisibleHint(boolean);
+ method public boolean shouldShowRequestPermissionRationale(String);
+ method public void startActivity(android.content.Intent!);
+ method public void startActivity(android.content.Intent!, android.os.Bundle?);
+ method @Deprecated public void startActivityForResult(android.content.Intent!, int);
+ method @Deprecated public void startActivityForResult(android.content.Intent!, int, android.os.Bundle?);
+ method @Deprecated public void startIntentSenderForResult(android.content.IntentSender!, int, android.content.Intent?, int, int, int, android.os.Bundle?) throws android.content.IntentSender.SendIntentException;
+ method public void startPostponedEnterTransition();
+ method public void unregisterForContextMenu(android.view.View);
+ }
+
+ public static class Fragment.InstantiationException extends java.lang.RuntimeException {
+ ctor public Fragment.InstantiationException(String, Exception?);
+ }
+
+ public static class Fragment.SavedState implements android.os.Parcelable {
+ method public int describeContents();
+ method public void writeToParcel(android.os.Parcel, int);
+ field public static final android.os.Parcelable.Creator<androidx.fragment.app.Fragment.SavedState!> CREATOR;
+ }
+
+ public class FragmentActivity extends androidx.activity.ComponentActivity implements androidx.core.app.ActivityCompat.OnRequestPermissionsResultCallback androidx.core.app.ActivityCompat.RequestPermissionsRequestCodeValidator {
+ ctor public FragmentActivity();
+ ctor @ContentView public FragmentActivity(@LayoutRes int);
+ method public androidx.fragment.app.FragmentManager getSupportFragmentManager();
+ method @Deprecated public androidx.loader.app.LoaderManager getSupportLoaderManager();
+ method @Deprecated @MainThread public void onAttachFragment(androidx.fragment.app.Fragment);
+ method @CallSuper public void onMultiWindowModeChanged(boolean);
+ method @CallSuper public void onPictureInPictureModeChanged(boolean);
+ method protected void onResumeFragments();
+ method public void onStateNotSaved();
+ method public void setEnterSharedElementCallback(androidx.core.app.SharedElementCallback?);
+ method public void setExitSharedElementCallback(androidx.core.app.SharedElementCallback?);
+ method public void startActivityFromFragment(androidx.fragment.app.Fragment, android.content.Intent!, int);
+ method public void startActivityFromFragment(androidx.fragment.app.Fragment, android.content.Intent!, int, android.os.Bundle?);
+ method @Deprecated public void startIntentSenderFromFragment(androidx.fragment.app.Fragment, android.content.IntentSender!, int, android.content.Intent?, int, int, int, android.os.Bundle?) throws android.content.IntentSender.SendIntentException;
+ method public void supportFinishAfterTransition();
+ method @Deprecated public void supportInvalidateOptionsMenu();
+ method public void supportPostponeEnterTransition();
+ method public void supportStartPostponedEnterTransition();
+ method @Deprecated public final void validateRequestPermissionsRequestCode(int);
+ }
+
+ public abstract class FragmentContainer {
+ ctor public FragmentContainer();
+ method @Deprecated public androidx.fragment.app.Fragment instantiate(android.content.Context, String, android.os.Bundle?);
+ method public abstract android.view.View? onFindViewById(@IdRes int);
+ method public abstract boolean onHasView();
+ }
+
+ public final class FragmentContainerView extends android.widget.FrameLayout {
+ ctor public FragmentContainerView(android.content.Context);
+ ctor public FragmentContainerView(android.content.Context, android.util.AttributeSet?);
+ ctor public FragmentContainerView(android.content.Context, android.util.AttributeSet?, int);
+ }
+
+ public class FragmentController {
+ method public void attachHost(androidx.fragment.app.Fragment?);
+ method public static androidx.fragment.app.FragmentController createController(androidx.fragment.app.FragmentHostCallback<?>);
+ method public void dispatchActivityCreated();
+ method public void dispatchConfigurationChanged(android.content.res.Configuration);
+ method public boolean dispatchContextItemSelected(android.view.MenuItem);
+ method public void dispatchCreate();
+ method public boolean dispatchCreateOptionsMenu(android.view.Menu, android.view.MenuInflater);
+ method public void dispatchDestroy();
+ method public void dispatchDestroyView();
+ method public void dispatchLowMemory();
+ method public void dispatchMultiWindowModeChanged(boolean);
+ method public boolean dispatchOptionsItemSelected(android.view.MenuItem);
+ method public void dispatchOptionsMenuClosed(android.view.Menu);
+ method public void dispatchPause();
+ method public void dispatchPictureInPictureModeChanged(boolean);
+ method public boolean dispatchPrepareOptionsMenu(android.view.Menu);
+ method @Deprecated public void dispatchReallyStop();
+ method public void dispatchResume();
+ method public void dispatchStart();
+ method public void dispatchStop();
+ method @Deprecated public void doLoaderDestroy();
+ method @Deprecated public void doLoaderRetain();
+ method @Deprecated public void doLoaderStart();
+ method @Deprecated public void doLoaderStop(boolean);
+ method @Deprecated public void dumpLoaders(String, java.io.FileDescriptor?, java.io.PrintWriter, String![]?);
+ method public boolean execPendingActions();
+ method public androidx.fragment.app.Fragment? findFragmentByWho(String);
+ method public java.util.List<androidx.fragment.app.Fragment!> getActiveFragments(java.util.List<androidx.fragment.app.Fragment!>!);
+ method public int getActiveFragmentsCount();
+ method public androidx.fragment.app.FragmentManager getSupportFragmentManager();
+ method @Deprecated public androidx.loader.app.LoaderManager! getSupportLoaderManager();
+ method public void noteStateNotSaved();
+ method public android.view.View? onCreateView(android.view.View?, String, android.content.Context, android.util.AttributeSet);
+ method @Deprecated public void reportLoaderStart();
+ method @Deprecated public void restoreAllState(android.os.Parcelable?, java.util.List<androidx.fragment.app.Fragment!>?);
+ method @Deprecated public void restoreAllState(android.os.Parcelable?, androidx.fragment.app.FragmentManagerNonConfig?);
+ method @Deprecated public void restoreLoaderNonConfig(androidx.collection.SimpleArrayMap<java.lang.String!,androidx.loader.app.LoaderManager!>!);
+ method public void restoreSaveState(android.os.Parcelable?);
+ method @Deprecated public androidx.collection.SimpleArrayMap<java.lang.String!,androidx.loader.app.LoaderManager!>? retainLoaderNonConfig();
+ method @Deprecated public androidx.fragment.app.FragmentManagerNonConfig? retainNestedNonConfig();
+ method @Deprecated public java.util.List<androidx.fragment.app.Fragment!>? retainNonConfig();
+ method public android.os.Parcelable? saveAllState();
+ }
+
+ public class FragmentFactory {
+ ctor public FragmentFactory();
+ method public androidx.fragment.app.Fragment instantiate(ClassLoader, String);
+ method public static Class<? extends androidx.fragment.app.Fragment> loadFragmentClass(ClassLoader, String);
+ }
+
+ public abstract class FragmentHostCallback<E> extends androidx.fragment.app.FragmentContainer {
+ ctor public FragmentHostCallback(android.content.Context, android.os.Handler, int);
+ method public void onDump(String, java.io.FileDescriptor?, java.io.PrintWriter, String![]?);
+ method public android.view.View? onFindViewById(int);
+ method public abstract E? onGetHost();
+ method public android.view.LayoutInflater onGetLayoutInflater();
+ method public int onGetWindowAnimations();
+ method public boolean onHasView();
+ method public boolean onHasWindowAnimations();
+ method @Deprecated public void onRequestPermissionsFromFragment(androidx.fragment.app.Fragment, String![], int);
+ method public boolean onShouldSaveFragmentState(androidx.fragment.app.Fragment);
+ method public boolean onShouldShowRequestPermissionRationale(String);
+ method public void onStartActivityFromFragment(androidx.fragment.app.Fragment, android.content.Intent!, int);
+ method public void onStartActivityFromFragment(androidx.fragment.app.Fragment, android.content.Intent!, int, android.os.Bundle?);
+ method @Deprecated public void onStartIntentSenderFromFragment(androidx.fragment.app.Fragment, android.content.IntentSender!, int, android.content.Intent?, int, int, int, android.os.Bundle?) throws android.content.IntentSender.SendIntentException;
+ method public void onSupportInvalidateOptionsMenu();
+ }
+
+ public abstract class FragmentManager implements androidx.fragment.app.FragmentResultOwner {
+ ctor public FragmentManager();
+ method public void addFragmentOnAttachListener(androidx.fragment.app.FragmentOnAttachListener);
+ method public void addOnBackStackChangedListener(androidx.fragment.app.FragmentManager.OnBackStackChangedListener);
+ method public androidx.fragment.app.FragmentTransaction beginTransaction();
+ method public final void clearFragmentResult(String);
+ method public final void clearFragmentResultListener(String);
+ method public void dump(String, java.io.FileDescriptor?, java.io.PrintWriter, String![]?);
+ method @Deprecated public static void enableDebugLogging(boolean);
+ method @androidx.fragment.app.FragmentStateManagerControl public static void enableNewStateManager(boolean);
+ method public boolean executePendingTransactions();
+ method public static <F extends androidx.fragment.app.Fragment> F findFragment(android.view.View);
+ method public androidx.fragment.app.Fragment? findFragmentById(@IdRes int);
+ method public androidx.fragment.app.Fragment? findFragmentByTag(String?);
+ method public androidx.fragment.app.FragmentManager.BackStackEntry getBackStackEntryAt(int);
+ method public int getBackStackEntryCount();
+ method public androidx.fragment.app.Fragment? getFragment(android.os.Bundle, String);
+ method public androidx.fragment.app.FragmentFactory getFragmentFactory();
+ method public java.util.List<androidx.fragment.app.Fragment!> getFragments();
+ method public androidx.fragment.app.Fragment? getPrimaryNavigationFragment();
+ method public boolean isDestroyed();
+ method public boolean isStateSaved();
+ method public void popBackStack();
+ method public void popBackStack(String?, int);
+ method public void popBackStack(int, int);
+ method public boolean popBackStackImmediate();
+ method public boolean popBackStackImmediate(String?, int);
+ method public boolean popBackStackImmediate(int, int);
+ method public void putFragment(android.os.Bundle, String, androidx.fragment.app.Fragment);
+ method public void registerFragmentLifecycleCallbacks(androidx.fragment.app.FragmentManager.FragmentLifecycleCallbacks, boolean);
+ method public void removeFragmentOnAttachListener(androidx.fragment.app.FragmentOnAttachListener);
+ method public void removeOnBackStackChangedListener(androidx.fragment.app.FragmentManager.OnBackStackChangedListener);
+ method public androidx.fragment.app.Fragment.SavedState? saveFragmentInstanceState(androidx.fragment.app.Fragment);
+ method public void setFragmentFactory(androidx.fragment.app.FragmentFactory);
+ method public final void setFragmentResult(String, android.os.Bundle);
+ method public final void setFragmentResultListener(String, androidx.lifecycle.LifecycleOwner, androidx.fragment.app.FragmentResultListener);
+ method public void unregisterFragmentLifecycleCallbacks(androidx.fragment.app.FragmentManager.FragmentLifecycleCallbacks);
+ field public static final int POP_BACK_STACK_INCLUSIVE = 1; // 0x1
+ }
+
+ public static interface FragmentManager.BackStackEntry {
+ method @Deprecated public CharSequence? getBreadCrumbShortTitle();
+ method @Deprecated @StringRes public int getBreadCrumbShortTitleRes();
+ method @Deprecated public CharSequence? getBreadCrumbTitle();
+ method @Deprecated @StringRes public int getBreadCrumbTitleRes();
+ method public int getId();
+ method public String? getName();
+ }
+
+ public abstract static class FragmentManager.FragmentLifecycleCallbacks {
+ ctor public FragmentManager.FragmentLifecycleCallbacks();
+ method @Deprecated public void onFragmentActivityCreated(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment, android.os.Bundle?);
+ method public void onFragmentAttached(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment, android.content.Context);
+ method public void onFragmentCreated(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment, android.os.Bundle?);
+ method public void onFragmentDestroyed(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment);
+ method public void onFragmentDetached(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment);
+ method public void onFragmentPaused(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment);
+ method public void onFragmentPreAttached(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment, android.content.Context);
+ method public void onFragmentPreCreated(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment, android.os.Bundle?);
+ method public void onFragmentResumed(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment);
+ method public void onFragmentSaveInstanceState(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment, android.os.Bundle);
+ method public void onFragmentStarted(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment);
+ method public void onFragmentStopped(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment);
+ method public void onFragmentViewCreated(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment, android.view.View, android.os.Bundle?);
+ method public void onFragmentViewDestroyed(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment);
+ }
+
+ public static interface FragmentManager.OnBackStackChangedListener {
+ method @MainThread public void onBackStackChanged();
+ }
+
+ @Deprecated public class FragmentManagerNonConfig {
+ }
+
+ public interface FragmentOnAttachListener {
+ method @MainThread public void onAttachFragment(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment);
+ }
+
+ @Deprecated public abstract class FragmentPagerAdapter extends androidx.viewpager.widget.PagerAdapter {
+ ctor @Deprecated public FragmentPagerAdapter(androidx.fragment.app.FragmentManager);
+ ctor @Deprecated public FragmentPagerAdapter(androidx.fragment.app.FragmentManager, int);
+ method @Deprecated public abstract androidx.fragment.app.Fragment getItem(int);
+ method @Deprecated public long getItemId(int);
+ method @Deprecated public boolean isViewFromObject(android.view.View, Object);
+ field @Deprecated public static final int BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT = 1; // 0x1
+ field @Deprecated public static final int BEHAVIOR_SET_USER_VISIBLE_HINT = 0; // 0x0
+ }
+
+ public interface FragmentResultListener {
+ method public void onFragmentResult(String, android.os.Bundle);
+ }
+
+ public interface FragmentResultOwner {
+ method public void clearFragmentResult(String);
+ method public void clearFragmentResultListener(String);
+ method public void setFragmentResult(String, android.os.Bundle);
+ method public void setFragmentResultListener(String, androidx.lifecycle.LifecycleOwner, androidx.fragment.app.FragmentResultListener);
+ }
+
+ @experimental.Experimental(level=androidx.annotation.experimental.Experimental.Level.WARNING) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD}) public @interface FragmentStateManagerControl {
+ }
+
+ @Deprecated public abstract class FragmentStatePagerAdapter extends androidx.viewpager.widget.PagerAdapter {
+ ctor @Deprecated public FragmentStatePagerAdapter(androidx.fragment.app.FragmentManager);
+ ctor @Deprecated public FragmentStatePagerAdapter(androidx.fragment.app.FragmentManager, int);
+ method @Deprecated public abstract androidx.fragment.app.Fragment getItem(int);
+ method @Deprecated public boolean isViewFromObject(android.view.View, Object);
+ field @Deprecated public static final int BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT = 1; // 0x1
+ field @Deprecated public static final int BEHAVIOR_SET_USER_VISIBLE_HINT = 0; // 0x0
+ }
+
+ @Deprecated public class FragmentTabHost extends android.widget.TabHost implements android.widget.TabHost.OnTabChangeListener {
+ ctor @Deprecated public FragmentTabHost(android.content.Context);
+ ctor @Deprecated public FragmentTabHost(android.content.Context, android.util.AttributeSet?);
+ method @Deprecated public void addTab(android.widget.TabHost.TabSpec, Class<?>, android.os.Bundle?);
+ method @Deprecated public void onTabChanged(String?);
+ method @Deprecated public void setup(android.content.Context, androidx.fragment.app.FragmentManager);
+ method @Deprecated public void setup(android.content.Context, androidx.fragment.app.FragmentManager, int);
+ }
+
+ public abstract class FragmentTransaction {
+ ctor @Deprecated public FragmentTransaction();
+ method public final androidx.fragment.app.FragmentTransaction add(Class<? extends androidx.fragment.app.Fragment>, android.os.Bundle?, String?);
+ method public androidx.fragment.app.FragmentTransaction add(androidx.fragment.app.Fragment, String?);
+ method public final androidx.fragment.app.FragmentTransaction add(@IdRes int, Class<? extends androidx.fragment.app.Fragment>, android.os.Bundle?);
+ method public androidx.fragment.app.FragmentTransaction add(@IdRes int, androidx.fragment.app.Fragment);
+ method public final androidx.fragment.app.FragmentTransaction add(@IdRes int, Class<? extends androidx.fragment.app.Fragment>, android.os.Bundle?, String?);
+ method public androidx.fragment.app.FragmentTransaction add(@IdRes int, androidx.fragment.app.Fragment, String?);
+ method public androidx.fragment.app.FragmentTransaction addSharedElement(android.view.View, String);
+ method public androidx.fragment.app.FragmentTransaction addToBackStack(String?);
+ method public androidx.fragment.app.FragmentTransaction attach(androidx.fragment.app.Fragment);
+ method public abstract int commit();
+ method public abstract int commitAllowingStateLoss();
+ method public abstract void commitNow();
+ method public abstract void commitNowAllowingStateLoss();
+ method public androidx.fragment.app.FragmentTransaction detach(androidx.fragment.app.Fragment);
+ method public androidx.fragment.app.FragmentTransaction disallowAddToBackStack();
+ method public androidx.fragment.app.FragmentTransaction hide(androidx.fragment.app.Fragment);
+ method public boolean isAddToBackStackAllowed();
+ method public boolean isEmpty();
+ method public androidx.fragment.app.FragmentTransaction remove(androidx.fragment.app.Fragment);
+ method public final androidx.fragment.app.FragmentTransaction replace(@IdRes int, Class<? extends androidx.fragment.app.Fragment>, android.os.Bundle?);
+ method public androidx.fragment.app.FragmentTransaction replace(@IdRes int, androidx.fragment.app.Fragment);
+ method public final androidx.fragment.app.FragmentTransaction replace(@IdRes int, Class<? extends androidx.fragment.app.Fragment>, android.os.Bundle?, String?);
+ method public androidx.fragment.app.FragmentTransaction replace(@IdRes int, androidx.fragment.app.Fragment, String?);
+ method public androidx.fragment.app.FragmentTransaction runOnCommit(Runnable);
+ method @Deprecated public androidx.fragment.app.FragmentTransaction setAllowOptimization(boolean);
+ method @Deprecated public androidx.fragment.app.FragmentTransaction setBreadCrumbShortTitle(@StringRes int);
+ method @Deprecated public androidx.fragment.app.FragmentTransaction setBreadCrumbShortTitle(CharSequence?);
+ method @Deprecated public androidx.fragment.app.FragmentTransaction setBreadCrumbTitle(@StringRes int);
+ method @Deprecated public androidx.fragment.app.FragmentTransaction setBreadCrumbTitle(CharSequence?);
+ method public androidx.fragment.app.FragmentTransaction setCustomAnimations(@AnimRes @AnimatorRes int, @AnimRes @AnimatorRes int);
+ method public androidx.fragment.app.FragmentTransaction setCustomAnimations(@AnimRes @AnimatorRes int, @AnimRes @AnimatorRes int, @AnimRes @AnimatorRes int, @AnimRes @AnimatorRes int);
+ method public androidx.fragment.app.FragmentTransaction setMaxLifecycle(androidx.fragment.app.Fragment, androidx.lifecycle.Lifecycle.State);
+ method public androidx.fragment.app.FragmentTransaction setPrimaryNavigationFragment(androidx.fragment.app.Fragment?);
+ method public androidx.fragment.app.FragmentTransaction setReorderingAllowed(boolean);
+ method public androidx.fragment.app.FragmentTransaction setTransition(int);
+ method @Deprecated public androidx.fragment.app.FragmentTransaction setTransitionStyle(@StyleRes int);
+ method public androidx.fragment.app.FragmentTransaction show(androidx.fragment.app.Fragment);
+ field public static final int TRANSIT_ENTER_MASK = 4096; // 0x1000
+ field public static final int TRANSIT_EXIT_MASK = 8192; // 0x2000
+ field public static final int TRANSIT_FRAGMENT_CLOSE = 8194; // 0x2002
+ field public static final int TRANSIT_FRAGMENT_FADE = 4099; // 0x1003
+ field public static final int TRANSIT_FRAGMENT_OPEN = 4097; // 0x1001
+ field public static final int TRANSIT_NONE = 0; // 0x0
+ field public static final int TRANSIT_UNSET = -1; // 0xffffffff
+ }
+
+ public class ListFragment extends androidx.fragment.app.Fragment {
+ ctor public ListFragment();
+ method public android.widget.ListAdapter? getListAdapter();
+ method public android.widget.ListView getListView();
+ method public long getSelectedItemId();
+ method public int getSelectedItemPosition();
+ method public void onListItemClick(android.widget.ListView, android.view.View, int, long);
+ method public final android.widget.ListAdapter requireListAdapter();
+ method public void setEmptyText(CharSequence?);
+ method public void setListAdapter(android.widget.ListAdapter?);
+ method public void setListShown(boolean);
+ method public void setListShownNoAnimation(boolean);
+ method public void setSelection(int);
+ }
+
+}
+
diff --git a/fragment/fragment/api/res-1.3.0-beta02.txt b/fragment/fragment/api/res-1.3.0-beta02.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/fragment/fragment/api/res-1.3.0-beta02.txt
diff --git a/fragment/fragment/api/restricted_1.3.0-beta02.txt b/fragment/fragment/api/restricted_1.3.0-beta02.txt
new file mode 100644
index 0000000..afa0e61
--- /dev/null
+++ b/fragment/fragment/api/restricted_1.3.0-beta02.txt
@@ -0,0 +1,480 @@
+// Signature format: 4.0
+package androidx.fragment.app {
+
+ public class DialogFragment extends androidx.fragment.app.Fragment implements android.content.DialogInterface.OnCancelListener android.content.DialogInterface.OnDismissListener {
+ ctor public DialogFragment();
+ ctor public DialogFragment(@LayoutRes int);
+ method public void dismiss();
+ method public void dismissAllowingStateLoss();
+ method public android.app.Dialog? getDialog();
+ method public boolean getShowsDialog();
+ method @StyleRes public int getTheme();
+ method public boolean isCancelable();
+ method public void onCancel(android.content.DialogInterface);
+ method @MainThread public android.app.Dialog onCreateDialog(android.os.Bundle?);
+ method public void onDismiss(android.content.DialogInterface);
+ method public final android.app.Dialog requireDialog();
+ method public void setCancelable(boolean);
+ method public void setShowsDialog(boolean);
+ method public void setStyle(int, @StyleRes int);
+ method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setupDialog(android.app.Dialog, int);
+ method public void show(androidx.fragment.app.FragmentManager, String?);
+ method public int show(androidx.fragment.app.FragmentTransaction, String?);
+ method public void showNow(androidx.fragment.app.FragmentManager, String?);
+ field public static final int STYLE_NORMAL = 0; // 0x0
+ field public static final int STYLE_NO_FRAME = 2; // 0x2
+ field public static final int STYLE_NO_INPUT = 3; // 0x3
+ field public static final int STYLE_NO_TITLE = 1; // 0x1
+ }
+
+ public class Fragment implements androidx.activity.result.ActivityResultCaller android.content.ComponentCallbacks androidx.lifecycle.HasDefaultViewModelProviderFactory androidx.lifecycle.LifecycleOwner androidx.savedstate.SavedStateRegistryOwner android.view.View.OnCreateContextMenuListener androidx.lifecycle.ViewModelStoreOwner {
+ ctor public Fragment();
+ ctor @ContentView public Fragment(@LayoutRes int);
+ method public void dump(String, java.io.FileDescriptor?, java.io.PrintWriter, String![]?);
+ method public final boolean equals(Object?);
+ method public final androidx.fragment.app.FragmentActivity? getActivity();
+ method public boolean getAllowEnterTransitionOverlap();
+ method public boolean getAllowReturnTransitionOverlap();
+ method public final android.os.Bundle? getArguments();
+ method public final androidx.fragment.app.FragmentManager getChildFragmentManager();
+ method public android.content.Context? getContext();
+ method public androidx.lifecycle.ViewModelProvider.Factory getDefaultViewModelProviderFactory();
+ method public Object? getEnterTransition();
+ method public Object? getExitTransition();
+ method @Deprecated public final androidx.fragment.app.FragmentManager? getFragmentManager();
+ method public final Object? getHost();
+ method public final int getId();
+ method public final android.view.LayoutInflater getLayoutInflater();
+ method @Deprecated @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.view.LayoutInflater getLayoutInflater(android.os.Bundle?);
+ method public androidx.lifecycle.Lifecycle getLifecycle();
+ method @Deprecated public androidx.loader.app.LoaderManager getLoaderManager();
+ method public final androidx.fragment.app.Fragment? getParentFragment();
+ method public final androidx.fragment.app.FragmentManager getParentFragmentManager();
+ method public Object? getReenterTransition();
+ method public final android.content.res.Resources getResources();
+ method @Deprecated public final boolean getRetainInstance();
+ method public Object? getReturnTransition();
+ method public final androidx.savedstate.SavedStateRegistry getSavedStateRegistry();
+ method public Object? getSharedElementEnterTransition();
+ method public Object? getSharedElementReturnTransition();
+ method public final String getString(@StringRes int);
+ method public final String getString(@StringRes int, java.lang.Object!...);
+ method public final String? getTag();
+ method @Deprecated public final androidx.fragment.app.Fragment? getTargetFragment();
+ method @Deprecated public final int getTargetRequestCode();
+ method public final CharSequence getText(@StringRes int);
+ method @Deprecated public boolean getUserVisibleHint();
+ method public android.view.View? getView();
+ method @MainThread public androidx.lifecycle.LifecycleOwner getViewLifecycleOwner();
+ method public androidx.lifecycle.LiveData<androidx.lifecycle.LifecycleOwner!> getViewLifecycleOwnerLiveData();
+ method public androidx.lifecycle.ViewModelStore getViewModelStore();
+ method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public final boolean hasOptionsMenu();
+ method public final int hashCode();
+ method @Deprecated public static androidx.fragment.app.Fragment instantiate(android.content.Context, String);
+ method @Deprecated public static androidx.fragment.app.Fragment instantiate(android.content.Context, String, android.os.Bundle?);
+ method public final boolean isAdded();
+ method public final boolean isDetached();
+ method public final boolean isHidden();
+ method public final boolean isInLayout();
+ method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public final boolean isMenuVisible();
+ method public final boolean isRemoving();
+ method public final boolean isResumed();
+ method public final boolean isStateSaved();
+ method public final boolean isVisible();
+ method @Deprecated @CallSuper @MainThread public void onActivityCreated(android.os.Bundle?);
+ method @Deprecated public void onActivityResult(int, int, android.content.Intent?);
+ method @CallSuper @MainThread public void onAttach(android.content.Context);
+ method @Deprecated @CallSuper @MainThread public void onAttach(android.app.Activity);
+ method @Deprecated @MainThread public void onAttachFragment(androidx.fragment.app.Fragment);
+ method @CallSuper public void onConfigurationChanged(android.content.res.Configuration);
+ method @MainThread public boolean onContextItemSelected(android.view.MenuItem);
+ method @CallSuper @MainThread public void onCreate(android.os.Bundle?);
+ method @MainThread public android.view.animation.Animation? onCreateAnimation(int, boolean, int);
+ method @MainThread public android.animation.Animator? onCreateAnimator(int, boolean, int);
+ method @MainThread public void onCreateContextMenu(android.view.ContextMenu, android.view.View, android.view.ContextMenu.ContextMenuInfo?);
+ method @MainThread public void onCreateOptionsMenu(android.view.Menu, android.view.MenuInflater);
+ method @MainThread public android.view.View? onCreateView(android.view.LayoutInflater, android.view.ViewGroup?, android.os.Bundle?);
+ method @CallSuper @MainThread public void onDestroy();
+ method @MainThread public void onDestroyOptionsMenu();
+ method @CallSuper @MainThread public void onDestroyView();
+ method @CallSuper @MainThread public void onDetach();
+ method public android.view.LayoutInflater onGetLayoutInflater(android.os.Bundle?);
+ method @MainThread public void onHiddenChanged(boolean);
+ method @CallSuper @UiThread public void onInflate(android.content.Context, android.util.AttributeSet, android.os.Bundle?);
+ method @Deprecated @CallSuper @UiThread public void onInflate(android.app.Activity, android.util.AttributeSet, android.os.Bundle?);
+ method @CallSuper @MainThread public void onLowMemory();
+ method public void onMultiWindowModeChanged(boolean);
+ method @MainThread public boolean onOptionsItemSelected(android.view.MenuItem);
+ method @MainThread public void onOptionsMenuClosed(android.view.Menu);
+ method @CallSuper @MainThread public void onPause();
+ method public void onPictureInPictureModeChanged(boolean);
+ method @MainThread public void onPrepareOptionsMenu(android.view.Menu);
+ method @MainThread public void onPrimaryNavigationFragmentChanged(boolean);
+ method @Deprecated public void onRequestPermissionsResult(int, String![], int[]);
+ method @CallSuper @MainThread public void onResume();
+ method @MainThread public void onSaveInstanceState(android.os.Bundle);
+ method @CallSuper @MainThread public void onStart();
+ method @CallSuper @MainThread public void onStop();
+ method @MainThread public void onViewCreated(android.view.View, android.os.Bundle?);
+ method @CallSuper @MainThread public void onViewStateRestored(android.os.Bundle?);
+ method public void postponeEnterTransition();
+ method public final void postponeEnterTransition(long, java.util.concurrent.TimeUnit);
+ method @MainThread public final <I, O> androidx.activity.result.ActivityResultLauncher<I!> registerForActivityResult(androidx.activity.result.contract.ActivityResultContract<I!,O!>, androidx.activity.result.ActivityResultCallback<O!>);
+ method @MainThread public final <I, O> androidx.activity.result.ActivityResultLauncher<I!> registerForActivityResult(androidx.activity.result.contract.ActivityResultContract<I!,O!>, androidx.activity.result.ActivityResultRegistry, androidx.activity.result.ActivityResultCallback<O!>);
+ method public void registerForContextMenu(android.view.View);
+ method @Deprecated public final void requestPermissions(String![], int);
+ method public final androidx.fragment.app.FragmentActivity requireActivity();
+ method public final android.os.Bundle requireArguments();
+ method public final android.content.Context requireContext();
+ method @Deprecated public final androidx.fragment.app.FragmentManager requireFragmentManager();
+ method public final Object requireHost();
+ method public final androidx.fragment.app.Fragment requireParentFragment();
+ method public final android.view.View requireView();
+ method public void setAllowEnterTransitionOverlap(boolean);
+ method public void setAllowReturnTransitionOverlap(boolean);
+ method public void setArguments(android.os.Bundle?);
+ method public void setEnterSharedElementCallback(androidx.core.app.SharedElementCallback?);
+ method public void setEnterTransition(Object?);
+ method public void setExitSharedElementCallback(androidx.core.app.SharedElementCallback?);
+ method public void setExitTransition(Object?);
+ method public void setHasOptionsMenu(boolean);
+ method public void setInitialSavedState(androidx.fragment.app.Fragment.SavedState?);
+ method public void setMenuVisibility(boolean);
+ method public void setReenterTransition(Object?);
+ method @Deprecated public void setRetainInstance(boolean);
+ method public void setReturnTransition(Object?);
+ method public void setSharedElementEnterTransition(Object?);
+ method public void setSharedElementReturnTransition(Object?);
+ method @Deprecated public void setTargetFragment(androidx.fragment.app.Fragment?, int);
+ method @Deprecated public void setUserVisibleHint(boolean);
+ method public boolean shouldShowRequestPermissionRationale(String);
+ method public void startActivity(android.content.Intent!);
+ method public void startActivity(android.content.Intent!, android.os.Bundle?);
+ method @Deprecated public void startActivityForResult(android.content.Intent!, int);
+ method @Deprecated public void startActivityForResult(android.content.Intent!, int, android.os.Bundle?);
+ method @Deprecated public void startIntentSenderForResult(android.content.IntentSender!, int, android.content.Intent?, int, int, int, android.os.Bundle?) throws android.content.IntentSender.SendIntentException;
+ method public void startPostponedEnterTransition();
+ method public void unregisterForContextMenu(android.view.View);
+ }
+
+ public static class Fragment.InstantiationException extends java.lang.RuntimeException {
+ ctor public Fragment.InstantiationException(String, Exception?);
+ }
+
+ public static class Fragment.SavedState implements android.os.Parcelable {
+ method public int describeContents();
+ method public void writeToParcel(android.os.Parcel, int);
+ field public static final android.os.Parcelable.Creator<androidx.fragment.app.Fragment.SavedState!> CREATOR;
+ }
+
+ public class FragmentActivity extends androidx.activity.ComponentActivity implements androidx.core.app.ActivityCompat.OnRequestPermissionsResultCallback androidx.core.app.ActivityCompat.RequestPermissionsRequestCodeValidator {
+ ctor public FragmentActivity();
+ ctor @ContentView public FragmentActivity(@LayoutRes int);
+ method public androidx.fragment.app.FragmentManager getSupportFragmentManager();
+ method @Deprecated public androidx.loader.app.LoaderManager getSupportLoaderManager();
+ method @Deprecated @MainThread public void onAttachFragment(androidx.fragment.app.Fragment);
+ method @CallSuper public void onMultiWindowModeChanged(boolean);
+ method @CallSuper public void onPictureInPictureModeChanged(boolean);
+ method @Deprecated @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) protected boolean onPrepareOptionsPanel(android.view.View?, android.view.Menu);
+ method protected void onResumeFragments();
+ method public void onStateNotSaved();
+ method public void setEnterSharedElementCallback(androidx.core.app.SharedElementCallback?);
+ method public void setExitSharedElementCallback(androidx.core.app.SharedElementCallback?);
+ method public void startActivityFromFragment(androidx.fragment.app.Fragment, android.content.Intent!, int);
+ method public void startActivityFromFragment(androidx.fragment.app.Fragment, android.content.Intent!, int, android.os.Bundle?);
+ method @Deprecated public void startIntentSenderFromFragment(androidx.fragment.app.Fragment, android.content.IntentSender!, int, android.content.Intent?, int, int, int, android.os.Bundle?) throws android.content.IntentSender.SendIntentException;
+ method public void supportFinishAfterTransition();
+ method @Deprecated public void supportInvalidateOptionsMenu();
+ method public void supportPostponeEnterTransition();
+ method public void supportStartPostponedEnterTransition();
+ method @Deprecated public final void validateRequestPermissionsRequestCode(int);
+ }
+
+ public abstract class FragmentContainer {
+ ctor public FragmentContainer();
+ method @Deprecated public androidx.fragment.app.Fragment instantiate(android.content.Context, String, android.os.Bundle?);
+ method public abstract android.view.View? onFindViewById(@IdRes int);
+ method public abstract boolean onHasView();
+ }
+
+ public final class FragmentContainerView extends android.widget.FrameLayout {
+ ctor public FragmentContainerView(android.content.Context);
+ ctor public FragmentContainerView(android.content.Context, android.util.AttributeSet?);
+ ctor public FragmentContainerView(android.content.Context, android.util.AttributeSet?, int);
+ }
+
+ public class FragmentController {
+ method public void attachHost(androidx.fragment.app.Fragment?);
+ method public static androidx.fragment.app.FragmentController createController(androidx.fragment.app.FragmentHostCallback<?>);
+ method public void dispatchActivityCreated();
+ method public void dispatchConfigurationChanged(android.content.res.Configuration);
+ method public boolean dispatchContextItemSelected(android.view.MenuItem);
+ method public void dispatchCreate();
+ method public boolean dispatchCreateOptionsMenu(android.view.Menu, android.view.MenuInflater);
+ method public void dispatchDestroy();
+ method public void dispatchDestroyView();
+ method public void dispatchLowMemory();
+ method public void dispatchMultiWindowModeChanged(boolean);
+ method public boolean dispatchOptionsItemSelected(android.view.MenuItem);
+ method public void dispatchOptionsMenuClosed(android.view.Menu);
+ method public void dispatchPause();
+ method public void dispatchPictureInPictureModeChanged(boolean);
+ method public boolean dispatchPrepareOptionsMenu(android.view.Menu);
+ method @Deprecated public void dispatchReallyStop();
+ method public void dispatchResume();
+ method public void dispatchStart();
+ method public void dispatchStop();
+ method @Deprecated public void doLoaderDestroy();
+ method @Deprecated public void doLoaderRetain();
+ method @Deprecated public void doLoaderStart();
+ method @Deprecated public void doLoaderStop(boolean);
+ method @Deprecated public void dumpLoaders(String, java.io.FileDescriptor?, java.io.PrintWriter, String![]?);
+ method public boolean execPendingActions();
+ method public androidx.fragment.app.Fragment? findFragmentByWho(String);
+ method public java.util.List<androidx.fragment.app.Fragment!> getActiveFragments(java.util.List<androidx.fragment.app.Fragment!>!);
+ method public int getActiveFragmentsCount();
+ method public androidx.fragment.app.FragmentManager getSupportFragmentManager();
+ method @Deprecated public androidx.loader.app.LoaderManager! getSupportLoaderManager();
+ method public void noteStateNotSaved();
+ method public android.view.View? onCreateView(android.view.View?, String, android.content.Context, android.util.AttributeSet);
+ method @Deprecated public void reportLoaderStart();
+ method @Deprecated public void restoreAllState(android.os.Parcelable?, java.util.List<androidx.fragment.app.Fragment!>?);
+ method @Deprecated public void restoreAllState(android.os.Parcelable?, androidx.fragment.app.FragmentManagerNonConfig?);
+ method @Deprecated public void restoreLoaderNonConfig(androidx.collection.SimpleArrayMap<java.lang.String!,androidx.loader.app.LoaderManager!>!);
+ method public void restoreSaveState(android.os.Parcelable?);
+ method @Deprecated public androidx.collection.SimpleArrayMap<java.lang.String!,androidx.loader.app.LoaderManager!>? retainLoaderNonConfig();
+ method @Deprecated public androidx.fragment.app.FragmentManagerNonConfig? retainNestedNonConfig();
+ method @Deprecated public java.util.List<androidx.fragment.app.Fragment!>? retainNonConfig();
+ method public android.os.Parcelable? saveAllState();
+ }
+
+ public class FragmentFactory {
+ ctor public FragmentFactory();
+ method public androidx.fragment.app.Fragment instantiate(ClassLoader, String);
+ method public static Class<? extends androidx.fragment.app.Fragment> loadFragmentClass(ClassLoader, String);
+ }
+
+ public abstract class FragmentHostCallback<E> extends androidx.fragment.app.FragmentContainer {
+ ctor public FragmentHostCallback(android.content.Context, android.os.Handler, int);
+ method public void onDump(String, java.io.FileDescriptor?, java.io.PrintWriter, String![]?);
+ method public android.view.View? onFindViewById(int);
+ method public abstract E? onGetHost();
+ method public android.view.LayoutInflater onGetLayoutInflater();
+ method public int onGetWindowAnimations();
+ method public boolean onHasView();
+ method public boolean onHasWindowAnimations();
+ method @Deprecated public void onRequestPermissionsFromFragment(androidx.fragment.app.Fragment, String![], int);
+ method public boolean onShouldSaveFragmentState(androidx.fragment.app.Fragment);
+ method public boolean onShouldShowRequestPermissionRationale(String);
+ method public void onStartActivityFromFragment(androidx.fragment.app.Fragment, android.content.Intent!, int);
+ method public void onStartActivityFromFragment(androidx.fragment.app.Fragment, android.content.Intent!, int, android.os.Bundle?);
+ method @Deprecated public void onStartIntentSenderFromFragment(androidx.fragment.app.Fragment, android.content.IntentSender!, int, android.content.Intent?, int, int, int, android.os.Bundle?) throws android.content.IntentSender.SendIntentException;
+ method public void onSupportInvalidateOptionsMenu();
+ }
+
+ public abstract class FragmentManager implements androidx.fragment.app.FragmentResultOwner {
+ ctor public FragmentManager();
+ method public void addFragmentOnAttachListener(androidx.fragment.app.FragmentOnAttachListener);
+ method public void addOnBackStackChangedListener(androidx.fragment.app.FragmentManager.OnBackStackChangedListener);
+ method public androidx.fragment.app.FragmentTransaction beginTransaction();
+ method public final void clearFragmentResult(String);
+ method public final void clearFragmentResultListener(String);
+ method public void dump(String, java.io.FileDescriptor?, java.io.PrintWriter, String![]?);
+ method @Deprecated public static void enableDebugLogging(boolean);
+ method public boolean executePendingTransactions();
+ method public static <F extends androidx.fragment.app.Fragment> F findFragment(android.view.View);
+ method public androidx.fragment.app.Fragment? findFragmentById(@IdRes int);
+ method public androidx.fragment.app.Fragment? findFragmentByTag(String?);
+ method public androidx.fragment.app.FragmentManager.BackStackEntry getBackStackEntryAt(int);
+ method public int getBackStackEntryCount();
+ method public androidx.fragment.app.Fragment? getFragment(android.os.Bundle, String);
+ method public androidx.fragment.app.FragmentFactory getFragmentFactory();
+ method public java.util.List<androidx.fragment.app.Fragment!> getFragments();
+ method public androidx.fragment.app.Fragment? getPrimaryNavigationFragment();
+ method public boolean isDestroyed();
+ method public boolean isStateSaved();
+ method @Deprecated @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public androidx.fragment.app.FragmentTransaction openTransaction();
+ method public void popBackStack();
+ method public void popBackStack(String?, int);
+ method public void popBackStack(int, int);
+ method public boolean popBackStackImmediate();
+ method public boolean popBackStackImmediate(String?, int);
+ method public boolean popBackStackImmediate(int, int);
+ method public void putFragment(android.os.Bundle, String, androidx.fragment.app.Fragment);
+ method public void registerFragmentLifecycleCallbacks(androidx.fragment.app.FragmentManager.FragmentLifecycleCallbacks, boolean);
+ method public void removeFragmentOnAttachListener(androidx.fragment.app.FragmentOnAttachListener);
+ method public void removeOnBackStackChangedListener(androidx.fragment.app.FragmentManager.OnBackStackChangedListener);
+ method public androidx.fragment.app.Fragment.SavedState? saveFragmentInstanceState(androidx.fragment.app.Fragment);
+ method public void setFragmentFactory(androidx.fragment.app.FragmentFactory);
+ method public final void setFragmentResult(String, android.os.Bundle);
+ method public final void setFragmentResultListener(String, androidx.lifecycle.LifecycleOwner, androidx.fragment.app.FragmentResultListener);
+ method public void unregisterFragmentLifecycleCallbacks(androidx.fragment.app.FragmentManager.FragmentLifecycleCallbacks);
+ field public static final int POP_BACK_STACK_INCLUSIVE = 1; // 0x1
+ }
+
+ public static interface FragmentManager.BackStackEntry {
+ method @Deprecated public CharSequence? getBreadCrumbShortTitle();
+ method @Deprecated @StringRes public int getBreadCrumbShortTitleRes();
+ method @Deprecated public CharSequence? getBreadCrumbTitle();
+ method @Deprecated @StringRes public int getBreadCrumbTitleRes();
+ method public int getId();
+ method public String? getName();
+ }
+
+ public abstract static class FragmentManager.FragmentLifecycleCallbacks {
+ ctor public FragmentManager.FragmentLifecycleCallbacks();
+ method @Deprecated public void onFragmentActivityCreated(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment, android.os.Bundle?);
+ method public void onFragmentAttached(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment, android.content.Context);
+ method public void onFragmentCreated(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment, android.os.Bundle?);
+ method public void onFragmentDestroyed(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment);
+ method public void onFragmentDetached(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment);
+ method public void onFragmentPaused(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment);
+ method public void onFragmentPreAttached(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment, android.content.Context);
+ method public void onFragmentPreCreated(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment, android.os.Bundle?);
+ method public void onFragmentResumed(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment);
+ method public void onFragmentSaveInstanceState(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment, android.os.Bundle);
+ method public void onFragmentStarted(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment);
+ method public void onFragmentStopped(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment);
+ method public void onFragmentViewCreated(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment, android.view.View, android.os.Bundle?);
+ method public void onFragmentViewDestroyed(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment);
+ }
+
+ public static interface FragmentManager.OnBackStackChangedListener {
+ method @MainThread public void onBackStackChanged();
+ }
+
+ @Deprecated public class FragmentManagerNonConfig {
+ }
+
+ public interface FragmentOnAttachListener {
+ method @MainThread public void onAttachFragment(androidx.fragment.app.FragmentManager, androidx.fragment.app.Fragment);
+ }
+
+ @Deprecated public abstract class FragmentPagerAdapter extends androidx.viewpager.widget.PagerAdapter {
+ ctor @Deprecated public FragmentPagerAdapter(androidx.fragment.app.FragmentManager);
+ ctor @Deprecated public FragmentPagerAdapter(androidx.fragment.app.FragmentManager, int);
+ method @Deprecated public abstract androidx.fragment.app.Fragment getItem(int);
+ method @Deprecated public long getItemId(int);
+ method @Deprecated public boolean isViewFromObject(android.view.View, Object);
+ field @Deprecated public static final int BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT = 1; // 0x1
+ field @Deprecated public static final int BEHAVIOR_SET_USER_VISIBLE_HINT = 0; // 0x0
+ }
+
+ public interface FragmentResultListener {
+ method public void onFragmentResult(String, android.os.Bundle);
+ }
+
+ public interface FragmentResultOwner {
+ method public void clearFragmentResult(String);
+ method public void clearFragmentResultListener(String);
+ method public void setFragmentResult(String, android.os.Bundle);
+ method public void setFragmentResultListener(String, androidx.lifecycle.LifecycleOwner, androidx.fragment.app.FragmentResultListener);
+ }
+
+ @Deprecated public abstract class FragmentStatePagerAdapter extends androidx.viewpager.widget.PagerAdapter {
+ ctor @Deprecated public FragmentStatePagerAdapter(androidx.fragment.app.FragmentManager);
+ ctor @Deprecated public FragmentStatePagerAdapter(androidx.fragment.app.FragmentManager, int);
+ method @Deprecated public abstract androidx.fragment.app.Fragment getItem(int);
+ method @Deprecated public boolean isViewFromObject(android.view.View, Object);
+ field @Deprecated public static final int BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT = 1; // 0x1
+ field @Deprecated public static final int BEHAVIOR_SET_USER_VISIBLE_HINT = 0; // 0x0
+ }
+
+ @Deprecated public class FragmentTabHost extends android.widget.TabHost implements android.widget.TabHost.OnTabChangeListener {
+ ctor @Deprecated public FragmentTabHost(android.content.Context);
+ ctor @Deprecated public FragmentTabHost(android.content.Context, android.util.AttributeSet?);
+ method @Deprecated public void addTab(android.widget.TabHost.TabSpec, Class<?>, android.os.Bundle?);
+ method @Deprecated public void onTabChanged(String?);
+ method @Deprecated public void setup(android.content.Context, androidx.fragment.app.FragmentManager);
+ method @Deprecated public void setup(android.content.Context, androidx.fragment.app.FragmentManager, int);
+ }
+
+ public abstract class FragmentTransaction {
+ ctor @Deprecated public FragmentTransaction();
+ method public final androidx.fragment.app.FragmentTransaction add(Class<? extends androidx.fragment.app.Fragment>, android.os.Bundle?, String?);
+ method public androidx.fragment.app.FragmentTransaction add(androidx.fragment.app.Fragment, String?);
+ method public final androidx.fragment.app.FragmentTransaction add(@IdRes int, Class<? extends androidx.fragment.app.Fragment>, android.os.Bundle?);
+ method public androidx.fragment.app.FragmentTransaction add(@IdRes int, androidx.fragment.app.Fragment);
+ method public final androidx.fragment.app.FragmentTransaction add(@IdRes int, Class<? extends androidx.fragment.app.Fragment>, android.os.Bundle?, String?);
+ method public androidx.fragment.app.FragmentTransaction add(@IdRes int, androidx.fragment.app.Fragment, String?);
+ method public androidx.fragment.app.FragmentTransaction addSharedElement(android.view.View, String);
+ method public androidx.fragment.app.FragmentTransaction addToBackStack(String?);
+ method public androidx.fragment.app.FragmentTransaction attach(androidx.fragment.app.Fragment);
+ method public abstract int commit();
+ method public abstract int commitAllowingStateLoss();
+ method public abstract void commitNow();
+ method public abstract void commitNowAllowingStateLoss();
+ method public androidx.fragment.app.FragmentTransaction detach(androidx.fragment.app.Fragment);
+ method public androidx.fragment.app.FragmentTransaction disallowAddToBackStack();
+ method public androidx.fragment.app.FragmentTransaction hide(androidx.fragment.app.Fragment);
+ method public boolean isAddToBackStackAllowed();
+ method public boolean isEmpty();
+ method public androidx.fragment.app.FragmentTransaction remove(androidx.fragment.app.Fragment);
+ method public final androidx.fragment.app.FragmentTransaction replace(@IdRes int, Class<? extends androidx.fragment.app.Fragment>, android.os.Bundle?);
+ method public androidx.fragment.app.FragmentTransaction replace(@IdRes int, androidx.fragment.app.Fragment);
+ method public final androidx.fragment.app.FragmentTransaction replace(@IdRes int, Class<? extends androidx.fragment.app.Fragment>, android.os.Bundle?, String?);
+ method public androidx.fragment.app.FragmentTransaction replace(@IdRes int, androidx.fragment.app.Fragment, String?);
+ method public androidx.fragment.app.FragmentTransaction runOnCommit(Runnable);
+ method @Deprecated public androidx.fragment.app.FragmentTransaction setAllowOptimization(boolean);
+ method @Deprecated public androidx.fragment.app.FragmentTransaction setBreadCrumbShortTitle(@StringRes int);
+ method @Deprecated public androidx.fragment.app.FragmentTransaction setBreadCrumbShortTitle(CharSequence?);
+ method @Deprecated public androidx.fragment.app.FragmentTransaction setBreadCrumbTitle(@StringRes int);
+ method @Deprecated public androidx.fragment.app.FragmentTransaction setBreadCrumbTitle(CharSequence?);
+ method public androidx.fragment.app.FragmentTransaction setCustomAnimations(@AnimRes @AnimatorRes int, @AnimRes @AnimatorRes int);
+ method public androidx.fragment.app.FragmentTransaction setCustomAnimations(@AnimRes @AnimatorRes int, @AnimRes @AnimatorRes int, @AnimRes @AnimatorRes int, @AnimRes @AnimatorRes int);
+ method public androidx.fragment.app.FragmentTransaction setMaxLifecycle(androidx.fragment.app.Fragment, androidx.lifecycle.Lifecycle.State);
+ method public androidx.fragment.app.FragmentTransaction setPrimaryNavigationFragment(androidx.fragment.app.Fragment?);
+ method public androidx.fragment.app.FragmentTransaction setReorderingAllowed(boolean);
+ method public androidx.fragment.app.FragmentTransaction setTransition(int);
+ method @Deprecated public androidx.fragment.app.FragmentTransaction setTransitionStyle(@StyleRes int);
+ method public androidx.fragment.app.FragmentTransaction show(androidx.fragment.app.Fragment);
+ field public static final int TRANSIT_ENTER_MASK = 4096; // 0x1000
+ field public static final int TRANSIT_EXIT_MASK = 8192; // 0x2000
+ field public static final int TRANSIT_FRAGMENT_CLOSE = 8194; // 0x2002
+ field public static final int TRANSIT_FRAGMENT_FADE = 4099; // 0x1003
+ field public static final int TRANSIT_FRAGMENT_OPEN = 4097; // 0x1001
+ field public static final int TRANSIT_NONE = 0; // 0x0
+ field public static final int TRANSIT_UNSET = -1; // 0xffffffff
+ }
+
+ @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public abstract class FragmentTransitionImpl {
+ ctor public FragmentTransitionImpl();
+ method public abstract void addTarget(Object!, android.view.View!);
+ method public abstract void addTargets(Object!, java.util.ArrayList<android.view.View!>!);
+ method public abstract void beginDelayedTransition(android.view.ViewGroup!, Object!);
+ method protected static void bfsAddViewChildren(java.util.List<android.view.View!>!, android.view.View!);
+ method public abstract boolean canHandle(Object!);
+ method public abstract Object! cloneTransition(Object!);
+ method protected void getBoundsOnScreen(android.view.View!, android.graphics.Rect!);
+ method protected static boolean isNullOrEmpty(java.util.List!);
+ method public abstract Object! mergeTransitionsInSequence(Object!, Object!, Object!);
+ method public abstract Object! mergeTransitionsTogether(Object!, Object!, Object!);
+ method public abstract void removeTarget(Object!, android.view.View!);
+ method public abstract void replaceTargets(Object!, java.util.ArrayList<android.view.View!>!, java.util.ArrayList<android.view.View!>!);
+ method public abstract void scheduleHideFragmentView(Object!, android.view.View!, java.util.ArrayList<android.view.View!>!);
+ method public abstract void scheduleRemoveTargets(Object!, Object!, java.util.ArrayList<android.view.View!>!, Object!, java.util.ArrayList<android.view.View!>!, Object!, java.util.ArrayList<android.view.View!>!);
+ method public abstract void setEpicenter(Object!, android.view.View!);
+ method public abstract void setEpicenter(Object!, android.graphics.Rect!);
+ method public void setListenerForTransitionEnd(androidx.fragment.app.Fragment, Object, androidx.core.os.CancellationSignal, Runnable);
+ method public abstract void setSharedElementTargets(Object!, android.view.View!, java.util.ArrayList<android.view.View!>!);
+ method public abstract void swapSharedElementTargets(Object!, java.util.ArrayList<android.view.View!>!, java.util.ArrayList<android.view.View!>!);
+ method public abstract Object! wrapTransitionInSet(Object!);
+ }
+
+ public class ListFragment extends androidx.fragment.app.Fragment {
+ ctor public ListFragment();
+ method public android.widget.ListAdapter? getListAdapter();
+ method public android.widget.ListView getListView();
+ method public long getSelectedItemId();
+ method public int getSelectedItemPosition();
+ method public void onListItemClick(android.widget.ListView, android.view.View, int, long);
+ method public final android.widget.ListAdapter requireListAdapter();
+ method public void setEmptyText(CharSequence?);
+ method public void setListAdapter(android.widget.ListAdapter?);
+ method public void setListShown(boolean);
+ method public void setListShownNoAnimation(boolean);
+ method public void setSelection(int);
+ }
+
+}
+
diff --git a/fragment/fragment/build.gradle b/fragment/fragment/build.gradle
index 83e2701..a6c2996 100644
--- a/fragment/fragment/build.gradle
+++ b/fragment/fragment/build.gradle
@@ -37,11 +37,11 @@
api("androidx.collection:collection:1.1.0")
api("androidx.viewpager:viewpager:1.0.0")
api("androidx.loader:loader:1.0.0")
- api(project(":activity:activity"))
- api(project(":lifecycle:lifecycle-livedata-core"))
- api(project(":lifecycle:lifecycle-viewmodel"))
- api(project(":lifecycle:lifecycle-viewmodel-savedstate"))
- api(project(":savedstate:savedstate"))
+ api(projectOrArtifact(":activity:activity"))
+ api(projectOrArtifact(":lifecycle:lifecycle-livedata-core"))
+ api(projectOrArtifact(":lifecycle:lifecycle-viewmodel"))
+ api(projectOrArtifact(":lifecycle:lifecycle-viewmodel-savedstate"))
+ api(projectOrArtifact(":savedstate:savedstate"))
api("androidx.annotation:annotation-experimental:1.0.0")
androidTestImplementation("androidx.appcompat:appcompat:1.1.0", {
diff --git a/fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentAnimatorTest.kt b/fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentAnimatorTest.kt
index 9967219..0e89bd8b 100644
--- a/fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentAnimatorTest.kt
+++ b/fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentAnimatorTest.kt
@@ -71,6 +71,44 @@
assertEnterPopExit(fragment)
}
+ // Ensure Fragments using default transits make it to resumed
+ @Test
+ fun defaultTransitionAddReorderedTrue() {
+ val fm = activityRule.activity.supportFragmentManager
+
+ val fragment = AnimatorFragment()
+ fm.beginTransaction()
+ .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
+ .add(R.id.fragmentContainer, fragment)
+ .addToBackStack(null)
+ .setReorderingAllowed(true)
+ .commit()
+ activityRule.waitForExecution()
+
+ assertThat(fragment.resumeLatch.await(1000, TimeUnit.MILLISECONDS)).isTrue()
+ assertThat(fragment.mView.visibility).isEqualTo(View.VISIBLE)
+ assertThat(fragment.mView.alpha).isEqualTo(1f)
+ }
+
+ // Ensure Fragments using default transits make it to resumed
+ @Test
+ fun defaultTransitionAddReorderedFalse() {
+ val fm = activityRule.activity.supportFragmentManager
+
+ val fragment = AnimatorFragment()
+ fm.beginTransaction()
+ .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
+ .add(R.id.fragmentContainer, fragment)
+ .addToBackStack(null)
+ .setReorderingAllowed(false)
+ .commit()
+ activityRule.waitForExecution()
+
+ assertThat(fragment.resumeLatch.await(1000, TimeUnit.MILLISECONDS)).isTrue()
+ assertThat(fragment.mView.visibility).isEqualTo(View.VISIBLE)
+ assertThat(fragment.mView.alpha).isEqualTo(1f)
+ }
+
// Ensure that removing and popping a Fragment uses the exit and popEnter animators
@Test
fun removeAnimators() {
@@ -650,6 +688,7 @@
var wasStarted: Boolean = false
lateinit var cancelLatch: CountDownLatch
lateinit var endLatch: CountDownLatch
+ var resumeLatch = CountDownLatch(1)
var initialized: Boolean = false
override fun onCreateAnimator(
@@ -682,6 +721,11 @@
baseAnimator = this
initialized = true
}
+
+ override fun onResume() {
+ super.onResume()
+ resumeLatch.countDown()
+ }
}
companion object {
diff --git a/fragment/gradle b/fragment/gradle
new file mode 120000
index 0000000..1c936b3
--- /dev/null
+++ b/fragment/gradle
@@ -0,0 +1 @@
+../playground-common/gradle
\ No newline at end of file
diff --git a/fragment/gradle.properties b/fragment/gradle.properties
new file mode 120000
index 0000000..d952fb0
--- /dev/null
+++ b/fragment/gradle.properties
@@ -0,0 +1 @@
+../playground-common/androidx-shared.properties
\ No newline at end of file
diff --git a/fragment/gradlew b/fragment/gradlew
new file mode 120000
index 0000000..05b75179
--- /dev/null
+++ b/fragment/gradlew
@@ -0,0 +1 @@
+../playground-common/gradlew
\ No newline at end of file
diff --git a/fragment/gradlew.bat b/fragment/gradlew.bat
new file mode 120000
index 0000000..b20877e
--- /dev/null
+++ b/fragment/gradlew.bat
@@ -0,0 +1 @@
+../playground-common/gradlew.bat
\ No newline at end of file
diff --git a/fragment/settings.gradle b/fragment/settings.gradle
new file mode 100644
index 0000000..c70eef1
--- /dev/null
+++ b/fragment/settings.gradle
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+
+// see ../playground-common/README.md for details on how this works
+rootProject.name = "paging-playground"
+apply from: "../playground-common/playground-include-settings.gradle"
+setupPlayground(this, "..")
+selectProjectsFromAndroidX({ name ->
+ if (name.startsWith(":fragment")) return true
+ if (name.startsWith(":internal-testutils-runtime")) return true
+ if (name.startsWith(":internal-testutils-truth")) return true
+ return false
+})
diff --git a/media/media/api/current.txt b/media/media/api/current.txt
index 5826322..a898f72 100644
--- a/media/media/api/current.txt
+++ b/media/media/api/current.txt
@@ -709,6 +709,8 @@
package androidx.media.utils {
public final class MediaConstants {
+ field public static final String BROWSER_ROOT_HINTS_KEY_ROOT_CHILDREN_LIMIT = "androidx.media.MediaBrowserCompat.Extras.KEY_ROOT_CHILDREN_LIMIT";
+ field public static final String BROWSER_ROOT_HINTS_KEY_ROOT_CHILDREN_SUPPORTED_FLAGS = "androidx.media.MediaBrowserCompat.Extras.KEY_ROOT_CHILDREN_SUPPORTED_FLAGS";
field public static final String METADATA_KEY_CONTENT_ID = "androidx.media.MediaMetadatCompat.METADATA_KEY_CONTENT_ID";
field public static final String PLAYBACK_STATE_EXTRAS_KEY_MEDIA_ID = "androidx.media.PlaybackStateCompat.Extras.KEY_MEDIA_ID";
field public static final String SESSION_EXTRAS_KEY_ACCOUNT_NAME = "androidx.media.MediaSessionCompat.Extras.KEY_ACCOUNT_NAME";
diff --git a/media/media/api/public_plus_experimental_current.txt b/media/media/api/public_plus_experimental_current.txt
index 33eca6b..e38ab5e 100644
--- a/media/media/api/public_plus_experimental_current.txt
+++ b/media/media/api/public_plus_experimental_current.txt
@@ -709,6 +709,8 @@
package androidx.media.utils {
public final class MediaConstants {
+ field public static final String BROWSER_ROOT_HINTS_KEY_ROOT_CHILDREN_LIMIT = "androidx.media.MediaBrowserCompat.Extras.KEY_ROOT_CHILDREN_LIMIT";
+ field public static final String BROWSER_ROOT_HINTS_KEY_ROOT_CHILDREN_SUPPORTED_FLAGS = "androidx.media.MediaBrowserCompat.Extras.KEY_ROOT_CHILDREN_SUPPORTED_FLAGS";
field public static final String METADATA_KEY_CONTENT_ID = "androidx.media.MediaMetadatCompat.METADATA_KEY_CONTENT_ID";
field public static final String PLAYBACK_STATE_EXTRAS_KEY_MEDIA_ID = "androidx.media.PlaybackStateCompat.Extras.KEY_MEDIA_ID";
field public static final String SESSION_EXTRAS_KEY_ACCOUNT_NAME = "androidx.media.MediaSessionCompat.Extras.KEY_ACCOUNT_NAME";
diff --git a/media/media/api/restricted_current.txt b/media/media/api/restricted_current.txt
index 9d6f904..dc43398 100644
--- a/media/media/api/restricted_current.txt
+++ b/media/media/api/restricted_current.txt
@@ -741,6 +741,8 @@
package androidx.media.utils {
public final class MediaConstants {
+ field public static final String BROWSER_ROOT_HINTS_KEY_ROOT_CHILDREN_LIMIT = "androidx.media.MediaBrowserCompat.Extras.KEY_ROOT_CHILDREN_LIMIT";
+ field public static final String BROWSER_ROOT_HINTS_KEY_ROOT_CHILDREN_SUPPORTED_FLAGS = "androidx.media.MediaBrowserCompat.Extras.KEY_ROOT_CHILDREN_SUPPORTED_FLAGS";
field public static final String METADATA_KEY_CONTENT_ID = "androidx.media.MediaMetadatCompat.METADATA_KEY_CONTENT_ID";
field public static final String PLAYBACK_STATE_EXTRAS_KEY_MEDIA_ID = "androidx.media.PlaybackStateCompat.Extras.KEY_MEDIA_ID";
field public static final String SESSION_EXTRAS_KEY_ACCOUNT_NAME = "androidx.media.MediaSessionCompat.Extras.KEY_ACCOUNT_NAME";
diff --git a/media/media/src/main/java/androidx/media/utils/MediaConstants.java b/media/media/src/main/java/androidx/media/utils/MediaConstants.java
index 55275d9..a5e88a5 100644
--- a/media/media/src/main/java/androidx/media/utils/MediaConstants.java
+++ b/media/media/src/main/java/androidx/media/utils/MediaConstants.java
@@ -19,21 +19,25 @@
import static androidx.annotation.RestrictTo.Scope.LIBRARY;
import android.annotation.SuppressLint;
+import android.content.ComponentName;
+import android.content.Context;
+import android.os.Bundle;
+import android.support.v4.media.MediaBrowserCompat;
+import android.support.v4.media.MediaBrowserCompat.ConnectionCallback;
import android.support.v4.media.MediaMetadataCompat;
import android.support.v4.media.session.MediaControllerCompat;
import android.support.v4.media.session.MediaSessionCompat;
import android.support.v4.media.session.PlaybackStateCompat;
import androidx.annotation.RestrictTo;
+import androidx.media.MediaBrowserServiceCompat;
-/**
- * Media constants for sharing constants between media provider and consumer apps
- */
+/** Media constants for sharing constants between media provider and consumer apps */
public final class MediaConstants {
/**
* Bundle key used for the account name in {@link MediaSessionCompat session} extras.
*
- * <p>TYPE: String</p>
+ * <p>TYPE: String
*
* @see MediaControllerCompat#getExtras
* @see MediaSessionCompat#setExtras
@@ -42,10 +46,10 @@
public static final String SESSION_EXTRAS_KEY_ACCOUNT_NAME =
"androidx.media.MediaSessionCompat.Extras.KEY_ACCOUNT_NAME";
/**
- * Bundle key used for the account type in {@link MediaSessionCompat session} extras.
- * The value would vary across media applications.
+ * Bundle key used for the account type in {@link MediaSessionCompat session} extras. The value
+ * would vary across media applications.
*
- * <p>TYPE: String</p>
+ * <p>TYPE: String
*
* @see MediaControllerCompat#getExtras
* @see MediaSessionCompat#setExtras
@@ -55,10 +59,9 @@
"androidx.media.MediaSessionCompat.Extras.KEY_ACCOUNT_TYPE";
/**
* Bundle key used for the account auth token value in {@link MediaSessionCompat session}
- * extras.
- * The value would vary across media applications.
+ * extras. The value would vary across media applications.
*
- * <p>TYPE: byte[]</p>
+ * <p>TYPE: byte[]
*
* @see MediaControllerCompat#getExtras
* @see MediaSessionCompat#setExtras
@@ -74,7 +77,7 @@
* for associating the playback state with the media being played so the value is expected to be
* same with {@link MediaMetadataCompat#METADATA_KEY_MEDIA_ID media id} of the current metadata.
*
- * <p>TYPE: String</p>
+ * <p>TYPE: String
*
* @see PlaybackStateCompat#getExtras
* @see PlaybackStateCompat.Builder#setExtras
@@ -86,10 +89,10 @@
/**
* Bundle key used for media content id in {@link MediaMetadataCompat metadata}, should contain
* the same ID provided to Media Actions Catalog in reference to this title (e.g., episode,
- * movie). Google uses this information to allow users to resume watching this title on your
- * app across the supported surfaces (e.g., Android TV's Play Next row)
+ * movie). Google uses this information to allow users to resume watching this title on your app
+ * across the supported surfaces (e.g., Android TV's Play Next row)
*
- * <p>TYPE: String</p>
+ * <p>TYPE: String
*
* @see MediaMetadataCompat
*/
@@ -97,5 +100,40 @@
public static final String METADATA_KEY_CONTENT_ID =
"androidx.media.MediaMetadatCompat.METADATA_KEY_CONTENT_ID";
+ /**
+ * Bundle key passed through root hints to the {@link MediaBrowserServiceCompat} to indicate the
+ * maximum number of children of the root node that can be supported by the hosting {@link
+ * MediaBrowserCompat}. Excess root children may be omitted or made less discoverable by the
+ * host.
+ *
+ * <p>TYPE: int
+ *
+ * @see MediaBrowserServiceCompat#onGetRoot(String, int, Bundle)
+ * @see MediaBrowserServiceCompat#getBrowserRootHints()
+ * @see MediaBrowserCompat#MediaBrowserCompat(Context,ComponentName,ConnectionCallback,Bundle)
+ */
+ @SuppressLint("IntentName")
+ public static final String BROWSER_ROOT_HINTS_KEY_ROOT_CHILDREN_LIMIT =
+ "androidx.media.MediaBrowserCompat.Extras.KEY_ROOT_CHILDREN_LIMIT";
+
+ /**
+ * Bundle key passed through root hints to the {@link MediaBrowserServiceCompat} to indicate
+ * which flags exposed by {@link MediaBrowserCompat.MediaItem#getFlags()} from children of the
+ * root node are supported by the hosting {@link MediaBrowserCompat}. Root children with
+ * unsupported flags may be omitted or made less discoverable by the host.
+ *
+ * <p>TYPE: int, a bit field which can be used as a mask. For example, if the value masked
+ * (using bitwise AND) with {@link MediaBrowserCompat.MediaItem#FLAG_BROWSABLE} is nonzero, then
+ * the host supports browsable root children. Conversely, if the masked result is zero, then the
+ * host does not support them.
+ *
+ * @see MediaBrowserServiceCompat#onGetRoot(String, int, Bundle)
+ * @see MediaBrowserServiceCompat#getBrowserRootHints()
+ * @see MediaBrowserCompat#MediaBrowserCompat(Context,ComponentName,ConnectionCallback,Bundle)
+ */
+ @SuppressLint("IntentName")
+ public static final String BROWSER_ROOT_HINTS_KEY_ROOT_CHILDREN_SUPPORTED_FLAGS =
+ "androidx.media.MediaBrowserCompat.Extras.KEY_ROOT_CHILDREN_SUPPORTED_FLAGS";
+
private MediaConstants() {}
}
diff --git a/navigation/.idea/codeStyles/Project.xml b/navigation/.idea/codeStyles/Project.xml
new file mode 120000
index 0000000..b52b28c
--- /dev/null
+++ b/navigation/.idea/codeStyles/Project.xml
@@ -0,0 +1 @@
+../../../.idea/codeStyles/Project.xml
\ No newline at end of file
diff --git a/navigation/.idea/codeStyles/codeStyleConfig.xml b/navigation/.idea/codeStyles/codeStyleConfig.xml
new file mode 120000
index 0000000..19c4848
--- /dev/null
+++ b/navigation/.idea/codeStyles/codeStyleConfig.xml
@@ -0,0 +1 @@
+../../../.idea/codeStyles/codeStyleConfig.xml
\ No newline at end of file
diff --git a/navigation/.idea/copyright/AndroidCopyright.xml b/navigation/.idea/copyright/AndroidCopyright.xml
new file mode 120000
index 0000000..afbbd04
--- /dev/null
+++ b/navigation/.idea/copyright/AndroidCopyright.xml
@@ -0,0 +1 @@
+../../../.idea/copyright/AndroidCopyright.xml
\ No newline at end of file
diff --git a/navigation/.idea/copyright/profiles_settings.xml b/navigation/.idea/copyright/profiles_settings.xml
new file mode 120000
index 0000000..5996ccd
--- /dev/null
+++ b/navigation/.idea/copyright/profiles_settings.xml
@@ -0,0 +1 @@
+../../../.idea/copyright/profiles_settings.xml
\ No newline at end of file
diff --git a/navigation/.idea/inspectionProfiles/Project_Default.xml b/navigation/.idea/inspectionProfiles/Project_Default.xml
new file mode 120000
index 0000000..a7481f4
--- /dev/null
+++ b/navigation/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1 @@
+../../../.idea/inspectionProfiles/Project_Default.xml
\ No newline at end of file
diff --git a/navigation/.idea/scopes/Ignore_API_Files.xml b/navigation/.idea/scopes/Ignore_API_Files.xml
new file mode 120000
index 0000000..3361ee1
--- /dev/null
+++ b/navigation/.idea/scopes/Ignore_API_Files.xml
@@ -0,0 +1 @@
+../../../.idea/scopes/Ignore_API_Files.xml
\ No newline at end of file
diff --git a/navigation/.idea/scopes/buildSrc.xml b/navigation/.idea/scopes/buildSrc.xml
new file mode 120000
index 0000000..25b7d3b
--- /dev/null
+++ b/navigation/.idea/scopes/buildSrc.xml
@@ -0,0 +1 @@
+../../../.idea/scopes/buildSrc.xml
\ No newline at end of file
diff --git a/navigation/benchmark/build.gradle b/navigation/benchmark/build.gradle
index 556e758..1bf4bf51 100644
--- a/navigation/benchmark/build.gradle
+++ b/navigation/benchmark/build.gradle
@@ -26,7 +26,7 @@
}
dependencies {
- androidTestImplementation(project(":benchmark:benchmark-junit4"))
+ androidTestImplementation(projectOrArtifact(":benchmark:benchmark-junit4"))
androidTestImplementation(project(":navigation:navigation-runtime"))
androidTestImplementation(project(":internal-testutils-navigation"))
androidTestImplementation(JUNIT)
diff --git a/navigation/gradle b/navigation/gradle
new file mode 120000
index 0000000..1c936b3
--- /dev/null
+++ b/navigation/gradle
@@ -0,0 +1 @@
+../playground-common/gradle
\ No newline at end of file
diff --git a/navigation/gradle.properties b/navigation/gradle.properties
new file mode 120000
index 0000000..d952fb0
--- /dev/null
+++ b/navigation/gradle.properties
@@ -0,0 +1 @@
+../playground-common/androidx-shared.properties
\ No newline at end of file
diff --git a/navigation/gradlew b/navigation/gradlew
new file mode 120000
index 0000000..05b75179
--- /dev/null
+++ b/navigation/gradlew
@@ -0,0 +1 @@
+../playground-common/gradlew
\ No newline at end of file
diff --git a/navigation/gradlew.bat b/navigation/gradlew.bat
new file mode 120000
index 0000000..b20877e
--- /dev/null
+++ b/navigation/gradlew.bat
@@ -0,0 +1 @@
+../playground-common/gradlew.bat
\ No newline at end of file
diff --git a/navigation/navigation-fragment-ktx/build.gradle b/navigation/navigation-fragment-ktx/build.gradle
index d7c0ce4..545ac3e 100644
--- a/navigation/navigation-fragment-ktx/build.gradle
+++ b/navigation/navigation-fragment-ktx/build.gradle
@@ -33,7 +33,7 @@
api("androidx.fragment:fragment-ktx:1.2.4")
api("androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0")
api(KOTLIN_STDLIB)
- androidTestImplementation(project(":fragment:fragment-testing"))
+ androidTestImplementation(projectOrArtifact(":fragment:fragment-testing"))
androidTestImplementation(ANDROIDX_TEST_EXT_JUNIT)
androidTestImplementation(ANDROIDX_TEST_CORE)
androidTestImplementation(ANDROIDX_TEST_RUNNER)
diff --git a/navigation/navigation-runtime/build.gradle b/navigation/navigation-runtime/build.gradle
index 92fb7b6..718f4f9 100644
--- a/navigation/navigation-runtime/build.gradle
+++ b/navigation/navigation-runtime/build.gradle
@@ -34,7 +34,7 @@
api("androidx.savedstate:savedstate:1.0.0")
api("androidx.lifecycle:lifecycle-viewmodel-savedstate:2.2.0")
- androidTestImplementation(project(":lifecycle:lifecycle-runtime-testing"))
+ androidTestImplementation(projectOrArtifact(":lifecycle:lifecycle-runtime-testing"))
androidTestImplementation(project(":internal-testutils-navigation"))
androidTestImplementation(ANDROIDX_TEST_EXT_JUNIT)
androidTestImplementation(ANDROIDX_TEST_CORE)
diff --git a/navigation/settings.gradle b/navigation/settings.gradle
new file mode 100644
index 0000000..fdeeda2
--- /dev/null
+++ b/navigation/settings.gradle
@@ -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.
+ */
+
+// see ../playground-common/README.md for details on how this works
+rootProject.name = "navigation-playground"
+apply from: "../playground-common/playground-include-settings.gradle"
+setupPlayground(this, "..")
+selectProjectsFromAndroidX({ name ->
+ if (name.startsWith(":navigation")) return true
+ if (name.startsWith(":internal-testutils-navigation")) return true
+ if (name.startsWith(":internal-testutils-runtime")) return true
+ if (name.startsWith(":internal-testutils-truth")) return true
+ return false
+})
+
diff --git a/paging/common/api/current.txt b/paging/common/api/current.txt
index 950aedc..78711c6 100644
--- a/paging/common/api/current.txt
+++ b/paging/common/api/current.txt
@@ -27,13 +27,11 @@
public abstract class DataSource<Key, Value> {
method @AnyThread public void addInvalidatedCallback(androidx.paging.DataSource.InvalidatedCallback onInvalidatedCallback);
- method @AnyThread public final void addInvalidatedCallback(kotlin.jvm.functions.Function0<kotlin.Unit> onInvalidatedCallback);
method @AnyThread public void invalidate();
method @WorkerThread public boolean isInvalid();
method public <ToValue> androidx.paging.DataSource<Key,ToValue> map(androidx.arch.core.util.Function<Value,ToValue> function);
method public <ToValue> androidx.paging.DataSource<Key,ToValue> mapByPage(androidx.arch.core.util.Function<java.util.List<Value>,java.util.List<ToValue>> function);
method @AnyThread public void removeInvalidatedCallback(androidx.paging.DataSource.InvalidatedCallback onInvalidatedCallback);
- method @AnyThread public final void removeInvalidatedCallback(kotlin.jvm.functions.Function0<kotlin.Unit> onInvalidatedCallback);
property @WorkerThread public boolean isInvalid;
}
@@ -46,7 +44,7 @@
method public <ToValue> androidx.paging.DataSource.Factory<Key,ToValue> mapByPage(androidx.arch.core.util.Function<java.util.List<Value>,java.util.List<ToValue>> function);
}
- public static interface DataSource.InvalidatedCallback {
+ public static fun interface DataSource.InvalidatedCallback {
method @AnyThread public void onInvalidated();
}
diff --git a/paging/common/api/public_plus_experimental_current.txt b/paging/common/api/public_plus_experimental_current.txt
index 04016dc..2e65713 100644
--- a/paging/common/api/public_plus_experimental_current.txt
+++ b/paging/common/api/public_plus_experimental_current.txt
@@ -28,13 +28,11 @@
public abstract class DataSource<Key, Value> {
method @AnyThread public void addInvalidatedCallback(androidx.paging.DataSource.InvalidatedCallback onInvalidatedCallback);
- method @AnyThread public final void addInvalidatedCallback(kotlin.jvm.functions.Function0<kotlin.Unit> onInvalidatedCallback);
method @AnyThread public void invalidate();
method @WorkerThread public boolean isInvalid();
method public <ToValue> androidx.paging.DataSource<Key,ToValue> map(androidx.arch.core.util.Function<Value,ToValue> function);
method public <ToValue> androidx.paging.DataSource<Key,ToValue> mapByPage(androidx.arch.core.util.Function<java.util.List<Value>,java.util.List<ToValue>> function);
method @AnyThread public void removeInvalidatedCallback(androidx.paging.DataSource.InvalidatedCallback onInvalidatedCallback);
- method @AnyThread public final void removeInvalidatedCallback(kotlin.jvm.functions.Function0<kotlin.Unit> onInvalidatedCallback);
property @WorkerThread public boolean isInvalid;
}
@@ -47,7 +45,7 @@
method public <ToValue> androidx.paging.DataSource.Factory<Key,ToValue> mapByPage(androidx.arch.core.util.Function<java.util.List<Value>,java.util.List<ToValue>> function);
}
- public static interface DataSource.InvalidatedCallback {
+ public static fun interface DataSource.InvalidatedCallback {
method @AnyThread public void onInvalidated();
}
diff --git a/paging/common/api/restricted_current.txt b/paging/common/api/restricted_current.txt
index 950aedc..78711c6 100644
--- a/paging/common/api/restricted_current.txt
+++ b/paging/common/api/restricted_current.txt
@@ -27,13 +27,11 @@
public abstract class DataSource<Key, Value> {
method @AnyThread public void addInvalidatedCallback(androidx.paging.DataSource.InvalidatedCallback onInvalidatedCallback);
- method @AnyThread public final void addInvalidatedCallback(kotlin.jvm.functions.Function0<kotlin.Unit> onInvalidatedCallback);
method @AnyThread public void invalidate();
method @WorkerThread public boolean isInvalid();
method public <ToValue> androidx.paging.DataSource<Key,ToValue> map(androidx.arch.core.util.Function<Value,ToValue> function);
method public <ToValue> androidx.paging.DataSource<Key,ToValue> mapByPage(androidx.arch.core.util.Function<java.util.List<Value>,java.util.List<ToValue>> function);
method @AnyThread public void removeInvalidatedCallback(androidx.paging.DataSource.InvalidatedCallback onInvalidatedCallback);
- method @AnyThread public final void removeInvalidatedCallback(kotlin.jvm.functions.Function0<kotlin.Unit> onInvalidatedCallback);
property @WorkerThread public boolean isInvalid;
}
@@ -46,7 +44,7 @@
method public <ToValue> androidx.paging.DataSource.Factory<Key,ToValue> mapByPage(androidx.arch.core.util.Function<java.util.List<Value>,java.util.List<ToValue>> function);
}
- public static interface DataSource.InvalidatedCallback {
+ public static fun interface DataSource.InvalidatedCallback {
method @AnyThread public void onInvalidated();
}
diff --git a/paging/common/src/main/kotlin/androidx/paging/DataSource.kt b/paging/common/src/main/kotlin/androidx/paging/DataSource.kt
index 830542d..26e0270 100644
--- a/paging/common/src/main/kotlin/androidx/paging/DataSource.kt
+++ b/paging/common/src/main/kotlin/androidx/paging/DataSource.kt
@@ -329,7 +329,7 @@
* Used to signal when a [DataSource] a data source has become invalid, and that a new data
* source is needed to continue loading data.
*/
- interface InvalidatedCallback {
+ fun interface InvalidatedCallback {
/**
* Called when the data backing the list has become invalid. This callback is typically used
* to signal that a new data source is needed.
@@ -343,14 +343,6 @@
}
/**
- * Wrapper for invalidation callback which holds a reference to allow removal by referential
- * equality of Kotlin functions within [removeInvalidatedCallback].
- */
- private class OnInvalidatedWrapper(val callback: () -> Unit) : InvalidatedCallback {
- override fun onInvalidated() = callback()
- }
-
- /**
* Add a callback to invoke when the DataSource is first invalidated.
*
* Once invalidated, a data source will not become valid again.
@@ -368,25 +360,6 @@
}
/**
- * Add a callback to invoke when the DataSource is first invalidated.
- *
- * Once invalidated, a data source will not become valid again.
- *
- * A data source will only invoke its callbacks once - the first time [invalidate] is called, on
- * that thread.
- *
- * This is a redundant override of [addInvalidatedCallback], which accepts Kotlin functions.
- *
- * @param onInvalidatedCallback The callback, will be invoked on thread that invalidates the
- * [DataSource].
- */
- @AnyThread
- @Suppress("RegistrationName")
- fun addInvalidatedCallback(onInvalidatedCallback: () -> Unit) {
- onInvalidatedCallbacks.add(OnInvalidatedWrapper(onInvalidatedCallback))
- }
-
- /**
* Remove a previously added invalidate callback.
*
* @param onInvalidatedCallback The previously added callback.
@@ -398,21 +371,6 @@
}
/**
- * Remove a previously added invalidate callback.
- *
- * This is a redundant override of [removeInvalidatedCallback], which accepts Kotlin functions.
- *
- * @param onInvalidatedCallback The previously added callback.
- */
- @AnyThread
- @Suppress("RegistrationName")
- fun removeInvalidatedCallback(onInvalidatedCallback: () -> Unit) {
- onInvalidatedCallbacks.removeAll {
- it is OnInvalidatedWrapper && it.callback === onInvalidatedCallback
- }
- }
-
- /**
* Signal the data source to stop loading, and notify its callback.
*
* If invalidate has already been called, this method does nothing.
diff --git a/paging/common/src/main/kotlin/androidx/paging/WrapperPageKeyedDataSource.kt b/paging/common/src/main/kotlin/androidx/paging/WrapperPageKeyedDataSource.kt
index a886b56..b79fd11 100644
--- a/paging/common/src/main/kotlin/androidx/paging/WrapperPageKeyedDataSource.kt
+++ b/paging/common/src/main/kotlin/androidx/paging/WrapperPageKeyedDataSource.kt
@@ -26,11 +26,13 @@
override val isInvalid
get() = source.isInvalid
- override fun addInvalidatedCallback(onInvalidatedCallback: InvalidatedCallback) =
+ override fun addInvalidatedCallback(onInvalidatedCallback: InvalidatedCallback) {
source.addInvalidatedCallback(onInvalidatedCallback)
+ }
- override fun removeInvalidatedCallback(onInvalidatedCallback: InvalidatedCallback) =
+ override fun removeInvalidatedCallback(onInvalidatedCallback: InvalidatedCallback) {
source.removeInvalidatedCallback(onInvalidatedCallback)
+ }
override fun invalidate() = source.invalidate()
diff --git a/paging/common/src/main/kotlin/androidx/paging/WrapperPositionalDataSource.kt b/paging/common/src/main/kotlin/androidx/paging/WrapperPositionalDataSource.kt
index 799f51c..83be3a6 100644
--- a/paging/common/src/main/kotlin/androidx/paging/WrapperPositionalDataSource.kt
+++ b/paging/common/src/main/kotlin/androidx/paging/WrapperPositionalDataSource.kt
@@ -26,11 +26,13 @@
override val isInvalid
get() = source.isInvalid
- override fun addInvalidatedCallback(onInvalidatedCallback: InvalidatedCallback) =
+ override fun addInvalidatedCallback(onInvalidatedCallback: InvalidatedCallback) {
source.addInvalidatedCallback(onInvalidatedCallback)
+ }
- override fun removeInvalidatedCallback(onInvalidatedCallback: InvalidatedCallback) =
+ override fun removeInvalidatedCallback(onInvalidatedCallback: InvalidatedCallback) {
source.removeInvalidatedCallback(onInvalidatedCallback)
+ }
override fun invalidate() = source.invalidate()
diff --git a/paging/common/src/test/kotlin/androidx/paging/LegacyPagingSourceTest.kt b/paging/common/src/test/kotlin/androidx/paging/LegacyPagingSourceTest.kt
index 06a6f25..65a648b 100644
--- a/paging/common/src/test/kotlin/androidx/paging/LegacyPagingSourceTest.kt
+++ b/paging/common/src/test/kotlin/androidx/paging/LegacyPagingSourceTest.kt
@@ -192,6 +192,17 @@
val pagingSource = LegacyPagingSource { createTestPositionalDataSource() }
val dataSource = pagingSource.dataSource
+ var kotlinInvalidated = false
+ dataSource.addInvalidatedCallback {
+ kotlinInvalidated = true
+ }
+ var javaInvalidated = false
+ dataSource.addInvalidatedCallback(object : DataSource.InvalidatedCallback {
+ override fun onInvalidated() {
+ javaInvalidated = true
+ }
+ })
+
assertFalse { pagingSource.invalid }
assertFalse { dataSource.isInvalid }
@@ -199,6 +210,8 @@
assertTrue { pagingSource.invalid }
assertTrue { dataSource.isInvalid }
+ assertTrue { kotlinInvalidated }
+ assertTrue { javaInvalidated }
}
@Test
@@ -206,6 +219,17 @@
val pagingSource = LegacyPagingSource { createTestPositionalDataSource() }
val dataSource = pagingSource.dataSource
+ var kotlinInvalidated = false
+ dataSource.addInvalidatedCallback {
+ kotlinInvalidated = true
+ }
+ var javaInvalidated = false
+ dataSource.addInvalidatedCallback(object : DataSource.InvalidatedCallback {
+ override fun onInvalidated() {
+ javaInvalidated = true
+ }
+ })
+
assertFalse { pagingSource.invalid }
assertFalse { dataSource.isInvalid }
@@ -213,6 +237,8 @@
assertTrue { pagingSource.invalid }
assertTrue { dataSource.isInvalid }
+ assertTrue { kotlinInvalidated }
+ assertTrue { javaInvalidated }
}
@Test
diff --git a/paging/common/src/test/kotlin/androidx/paging/PagedListTest.kt b/paging/common/src/test/kotlin/androidx/paging/PagedListTest.kt
index a889369d..29888d2 100644
--- a/paging/common/src/test/kotlin/androidx/paging/PagedListTest.kt
+++ b/paging/common/src/test/kotlin/androidx/paging/PagedListTest.kt
@@ -52,7 +52,7 @@
@Test
fun createLegacy() {
@Suppress("DEPRECATION")
- val pagedList = PagedList.Builder(ListDataSource(ITEMS), 100)
+ val pagedList = PagedList.Builder(TestPositionalDataSource(ITEMS), 100)
.setNotifyExecutor(TestExecutor())
.setFetchExecutor(TestExecutor())
.build()
diff --git a/paging/common/src/test/kotlin/androidx/paging/WrappedItemKeyedDataSourceTest.kt b/paging/common/src/test/kotlin/androidx/paging/WrappedItemKeyedDataSourceTest.kt
new file mode 100644
index 0000000..2c90329
--- /dev/null
+++ b/paging/common/src/test/kotlin/androidx/paging/WrappedItemKeyedDataSourceTest.kt
@@ -0,0 +1,48 @@
+/*
+ * 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.paging
+
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+import kotlin.test.assertTrue
+
+@OptIn(ExperimentalPagingApi::class)
+@RunWith(JUnit4::class)
+class WrappedItemKeyedDataSourceTest {
+
+ @Test
+ fun propagatesInvalidation() {
+ val dataSource = WrapperItemKeyedDataSource(TestItemKeyedDataSource(listOf(0))) { it }
+
+ var kotlinInvalidated = false
+ dataSource.addInvalidatedCallback {
+ kotlinInvalidated = true
+ }
+ var javaInvalidated = false
+ dataSource.addInvalidatedCallback(object : DataSource.InvalidatedCallback {
+ override fun onInvalidated() {
+ javaInvalidated = true
+ }
+ })
+
+ dataSource.invalidate()
+ assertTrue { dataSource.isInvalid }
+ assertTrue { kotlinInvalidated }
+ assertTrue { javaInvalidated }
+ }
+}
diff --git a/paging/common/src/test/kotlin/androidx/paging/WrappedPageKeyedDataSourceTest.kt b/paging/common/src/test/kotlin/androidx/paging/WrappedPageKeyedDataSourceTest.kt
new file mode 100644
index 0000000..129cd3f
--- /dev/null
+++ b/paging/common/src/test/kotlin/androidx/paging/WrappedPageKeyedDataSourceTest.kt
@@ -0,0 +1,48 @@
+/*
+ * 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.paging
+
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+import kotlin.test.assertTrue
+
+@OptIn(ExperimentalPagingApi::class)
+@RunWith(JUnit4::class)
+class WrappedPageKeyedDataSourceTest {
+
+ @Test
+ fun propagatesInvalidation() {
+ val dataSource = WrapperPageKeyedDataSource(TestPageKeyedDataSource(listOf(0))) { it }
+
+ var kotlinInvalidated = false
+ dataSource.addInvalidatedCallback {
+ kotlinInvalidated = true
+ }
+ var javaInvalidated = false
+ dataSource.addInvalidatedCallback(object : DataSource.InvalidatedCallback {
+ override fun onInvalidated() {
+ javaInvalidated = true
+ }
+ })
+
+ dataSource.invalidate()
+ assertTrue { dataSource.isInvalid }
+ assertTrue { kotlinInvalidated }
+ assertTrue { javaInvalidated }
+ }
+}
diff --git a/paging/common/src/test/kotlin/androidx/paging/WrappedPositionalDataSourceTest.kt b/paging/common/src/test/kotlin/androidx/paging/WrappedPositionalDataSourceTest.kt
new file mode 100644
index 0000000..cc02f84
--- /dev/null
+++ b/paging/common/src/test/kotlin/androidx/paging/WrappedPositionalDataSourceTest.kt
@@ -0,0 +1,48 @@
+/*
+ * 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.paging
+
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+import kotlin.test.assertTrue
+
+@OptIn(ExperimentalPagingApi::class)
+@RunWith(JUnit4::class)
+class WrappedPositionalDataSourceTest {
+
+ @Test
+ fun propagatesInvalidation() {
+ val dataSource = WrapperPositionalDataSource(TestPositionalDataSource(listOf(0))) { it }
+
+ var kotlinInvalidated = false
+ dataSource.addInvalidatedCallback {
+ kotlinInvalidated = true
+ }
+ var javaInvalidated = false
+ dataSource.addInvalidatedCallback(object : DataSource.InvalidatedCallback {
+ override fun onInvalidated() {
+ javaInvalidated = true
+ }
+ })
+
+ dataSource.invalidate()
+ assertTrue { dataSource.isInvalid }
+ assertTrue { kotlinInvalidated }
+ assertTrue { javaInvalidated }
+ }
+}
diff --git a/paging/runtime/src/androidTest/java/androidx/paging/AsyncPagedListDifferTest.kt b/paging/runtime/src/androidTest/java/androidx/paging/AsyncPagedListDifferTest.kt
index b41d1a3..54d235e 100644
--- a/paging/runtime/src/androidTest/java/androidx/paging/AsyncPagedListDifferTest.kt
+++ b/paging/runtime/src/androidTest/java/androidx/paging/AsyncPagedListDifferTest.kt
@@ -65,7 +65,7 @@
data: List<V>,
initialKey: Int
): PagedList<V> {
- return PagedList.Builder(ListDataSource(data), config)
+ return PagedList.Builder(TestPositionalDataSource(data), config)
.setInitialKey(initialKey)
.setNotifyExecutor(mainThread)
.setFetchExecutor(pageLoadingThread)
diff --git a/paging/rxjava2/src/test/java/androidx/paging/RxPagedListBuilderTest.kt b/paging/rxjava2/src/test/java/androidx/paging/RxPagedListBuilderTest.kt
index 8708e51..4a1e45b 100644
--- a/paging/rxjava2/src/test/java/androidx/paging/RxPagedListBuilderTest.kt
+++ b/paging/rxjava2/src/test/java/androidx/paging/RxPagedListBuilderTest.kt
@@ -45,7 +45,7 @@
override fun create(): DataSource<Int, String> {
val currentList = localData.first()
localData = localData.drop(1)
- return ListDataSource(currentList)
+ return TestPositionalDataSource(currentList)
}
}
}
diff --git a/settings.gradle b/settings.gradle
index 66066f8..c5a0424 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -90,6 +90,7 @@
includeProject(":benchmark:benchmark-gradle-plugin", "benchmark/gradle-plugin")
includeProject(":benchmark:benchmark-junit4", "benchmark/junit4")
includeProject(":benchmark:benchmark-macro", "benchmark/macro")
+includeProject(":benchmark:benchmark-macro-runtime", "benchmark/benchmark-macro-runtime")
includeProject(":benchmark:benchmark-perfetto", "benchmark/perfetto")
includeProject(":benchmark:integration-tests:dry-run-benchmark", "benchmark/integration-tests/dry-run-benchmark")
includeProject(":benchmark:integration-tests:startup-benchmark", "benchmark/integration-tests/startup-benchmark")
diff --git a/testutils/testutils-paging/src/main/java/androidx/paging/TestItemKeyedDataSource.kt b/testutils/testutils-paging/src/main/java/androidx/paging/TestItemKeyedDataSource.kt
new file mode 100644
index 0000000..1c63702
--- /dev/null
+++ b/testutils/testutils-paging/src/main/java/androidx/paging/TestItemKeyedDataSource.kt
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.paging
+
+import java.util.ArrayList
+
+@Suppress("DEPRECATION")
+class TestItemKeyedDataSource<T : Any>(list: List<T>) : ItemKeyedDataSource<Int, T>() {
+ private val list: List<T> = ArrayList(list)
+
+ override fun loadInitial(params: LoadInitialParams<Int>, callback: LoadInitialCallback<T>) {
+ val totalCount = list.size
+ val key = params.requestedInitialKey ?: 0
+ val sublist = list.subList(key, minOf(key + params.requestedLoadSize, totalCount))
+ callback.onResult(sublist)
+ }
+
+ override fun loadAfter(params: LoadParams<Int>, callback: LoadCallback<T>) {
+ callback.onResult(list.subList(params.key, params.key + params.requestedLoadSize))
+ }
+
+ override fun loadBefore(params: LoadParams<Int>, callback: LoadCallback<T>) {
+ callback.onResult(list.subList(params.key - params.requestedLoadSize + 1, params.key + 1))
+ }
+
+ override fun getKey(item: T): Int {
+ return list.indexOf(item)
+ }
+}
diff --git a/testutils/testutils-paging/src/main/java/androidx/paging/TestPageKeyedDataSource.kt b/testutils/testutils-paging/src/main/java/androidx/paging/TestPageKeyedDataSource.kt
new file mode 100644
index 0000000..7905ef1
--- /dev/null
+++ b/testutils/testutils-paging/src/main/java/androidx/paging/TestPageKeyedDataSource.kt
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.paging
+
+import java.util.ArrayList
+
+@Suppress("DEPRECATION")
+class TestPageKeyedDataSource<T : Any>(list: List<T>) : PageKeyedDataSource<Int, T>() {
+ private val list: List<T> = ArrayList(list)
+
+ override fun loadInitial(
+ params: LoadInitialParams<Int>,
+ callback: LoadInitialCallback<Int, T>
+ ) {
+ val totalCount = list.size
+ val sublist = list.subList(0, minOf(params.requestedLoadSize, totalCount))
+ callback.onResult(sublist, null, params.requestedLoadSize)
+ }
+
+ override fun loadBefore(params: LoadParams<Int>, callback: LoadCallback<Int, T>) {
+ callback.onResult(
+ list.subList(params.key - params.requestedLoadSize + 1, params.key + 1),
+ params.key - 1
+ )
+ }
+
+ override fun loadAfter(params: LoadParams<Int>, callback: LoadCallback<Int, T>) {
+ callback.onResult(
+ list.subList(params.key, params.key + params.requestedLoadSize),
+ params.key + params.requestedLoadSize
+ )
+ }
+}
diff --git a/testutils/testutils-paging/src/main/java/androidx/paging/ListDataSource.kt b/testutils/testutils-paging/src/main/java/androidx/paging/TestPositionalDataSource.kt
similarity index 94%
rename from testutils/testutils-paging/src/main/java/androidx/paging/ListDataSource.kt
rename to testutils/testutils-paging/src/main/java/androidx/paging/TestPositionalDataSource.kt
index 5b9aa35..bbf019d 100644
--- a/testutils/testutils-paging/src/main/java/androidx/paging/ListDataSource.kt
+++ b/testutils/testutils-paging/src/main/java/androidx/paging/TestPositionalDataSource.kt
@@ -19,7 +19,7 @@
import java.util.ArrayList
@Suppress("DEPRECATION")
-class ListDataSource<T : Any>(list: List<T>) : PositionalDataSource<T>() {
+class TestPositionalDataSource<T : Any>(list: List<T>) : PositionalDataSource<T>() {
private val list: List<T> = ArrayList(list)
override fun loadInitial(params: LoadInitialParams, callback: LoadInitialCallback<T>) {
diff --git a/ui/ui-tooling/src/androidTest/java/androidx/ui/tooling/inspector/ParameterFactoryTest.kt b/ui/ui-tooling/src/androidTest/java/androidx/ui/tooling/inspector/ParameterFactoryTest.kt
index 6000d3a..dbbd2a5 100644
--- a/ui/ui-tooling/src/androidTest/java/androidx/ui/tooling/inspector/ParameterFactoryTest.kt
+++ b/ui/ui-tooling/src/androidTest/java/androidx/ui/tooling/inspector/ParameterFactoryTest.kt
@@ -405,13 +405,14 @@
parameter("width", ParameterType.DimensionDp, 5.0f)
}
parameter("padding", ParameterType.DimensionDp, 2.0f)
- parameter("fillMaxWidth", ParameterType.String, "")
+ parameter("fillMaxWidth", ParameterType.String, "") {
+ parameter("fraction", ParameterType.Float, 1.0f)
+ }
parameter("wrapContentHeight", ParameterType.String, "") {
- parameter("alignment", ParameterType.String, "Bottom")
+ parameter("align", ParameterType.String, "Bottom")
+ parameter("unbounded", ParameterType.Boolean, false)
}
- parameter("preferredWidth", ParameterType.DimensionDp, 30.0f) {
- parameter("width", ParameterType.DimensionDp, 30.0f)
- }
+ parameter("preferredWidth", ParameterType.DimensionDp, 30.0f)
parameter("paint", ParameterType.String, "") {
parameter("alignment", ParameterType.String, "Center")
parameter("alpha", ParameterType.Float, 1.0f)