ui-material to MPP
Test: ./gradlew buildOnSrever
Change-Id: I971e56a36bfbe5771e5cf0dbd0ce694aa742603b
Relnote: N/A
diff --git a/ui/ui-desktop/samples/src/jvmMain/kotlin/androidx/ui/desktop/examples/example1/Main.kt b/ui/ui-desktop/samples/src/jvmMain/kotlin/androidx/ui/desktop/examples/example1/Main.kt
index 654d3da..976bba3 100644
--- a/ui/ui-desktop/samples/src/jvmMain/kotlin/androidx/ui/desktop/examples/example1/Main.kt
+++ b/ui/ui-desktop/samples/src/jvmMain/kotlin/androidx/ui/desktop/examples/example1/Main.kt
@@ -27,6 +27,7 @@
import androidx.ui.graphics.Color
import androidx.ui.graphics.ImageAsset
import androidx.ui.graphics.asImageAsset
+import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
diff --git a/ui/ui-graphics/api/0.1.0-dev16.txt b/ui/ui-graphics/api/0.1.0-dev16.txt
index e014534..652ec98 100644
--- a/ui/ui-graphics/api/0.1.0-dev16.txt
+++ b/ui/ui-graphics/api/0.1.0-dev16.txt
@@ -111,6 +111,10 @@
method public static androidx.ui.graphics.Path asComposePath(android.graphics.Path);
}
+ public final class AndroidPathMeasureKt {
+ method public static androidx.ui.graphics.PathMeasure PathMeasure();
+ }
+
public final class AndroidShaderKt {
}
@@ -520,6 +524,13 @@
enum_constant public static final androidx.ui.graphics.PathFillType nonZero;
}
+ public interface PathMeasure {
+ method public float getLength();
+ method public boolean getSegment(float startDistance, float stopDistance, androidx.ui.graphics.Path path, boolean startWithMoveTo);
+ method public void setPath(androidx.ui.graphics.Path path, boolean forceClosed);
+ property public abstract float length;
+ }
+
public enum PathOperation {
method public static androidx.ui.graphics.PathOperation valueOf(String name) throws java.lang.IllegalArgumentException;
method public static androidx.ui.graphics.PathOperation[] values();
diff --git a/ui/ui-graphics/api/current.txt b/ui/ui-graphics/api/current.txt
index e014534..652ec98 100644
--- a/ui/ui-graphics/api/current.txt
+++ b/ui/ui-graphics/api/current.txt
@@ -111,6 +111,10 @@
method public static androidx.ui.graphics.Path asComposePath(android.graphics.Path);
}
+ public final class AndroidPathMeasureKt {
+ method public static androidx.ui.graphics.PathMeasure PathMeasure();
+ }
+
public final class AndroidShaderKt {
}
@@ -520,6 +524,13 @@
enum_constant public static final androidx.ui.graphics.PathFillType nonZero;
}
+ public interface PathMeasure {
+ method public float getLength();
+ method public boolean getSegment(float startDistance, float stopDistance, androidx.ui.graphics.Path path, boolean startWithMoveTo);
+ method public void setPath(androidx.ui.graphics.Path path, boolean forceClosed);
+ property public abstract float length;
+ }
+
public enum PathOperation {
method public static androidx.ui.graphics.PathOperation valueOf(String name) throws java.lang.IllegalArgumentException;
method public static androidx.ui.graphics.PathOperation[] values();
diff --git a/ui/ui-graphics/api/public_plus_experimental_0.1.0-dev16.txt b/ui/ui-graphics/api/public_plus_experimental_0.1.0-dev16.txt
index e014534..652ec98 100644
--- a/ui/ui-graphics/api/public_plus_experimental_0.1.0-dev16.txt
+++ b/ui/ui-graphics/api/public_plus_experimental_0.1.0-dev16.txt
@@ -111,6 +111,10 @@
method public static androidx.ui.graphics.Path asComposePath(android.graphics.Path);
}
+ public final class AndroidPathMeasureKt {
+ method public static androidx.ui.graphics.PathMeasure PathMeasure();
+ }
+
public final class AndroidShaderKt {
}
@@ -520,6 +524,13 @@
enum_constant public static final androidx.ui.graphics.PathFillType nonZero;
}
+ public interface PathMeasure {
+ method public float getLength();
+ method public boolean getSegment(float startDistance, float stopDistance, androidx.ui.graphics.Path path, boolean startWithMoveTo);
+ method public void setPath(androidx.ui.graphics.Path path, boolean forceClosed);
+ property public abstract float length;
+ }
+
public enum PathOperation {
method public static androidx.ui.graphics.PathOperation valueOf(String name) throws java.lang.IllegalArgumentException;
method public static androidx.ui.graphics.PathOperation[] values();
diff --git a/ui/ui-graphics/api/public_plus_experimental_current.txt b/ui/ui-graphics/api/public_plus_experimental_current.txt
index e014534..652ec98 100644
--- a/ui/ui-graphics/api/public_plus_experimental_current.txt
+++ b/ui/ui-graphics/api/public_plus_experimental_current.txt
@@ -111,6 +111,10 @@
method public static androidx.ui.graphics.Path asComposePath(android.graphics.Path);
}
+ public final class AndroidPathMeasureKt {
+ method public static androidx.ui.graphics.PathMeasure PathMeasure();
+ }
+
public final class AndroidShaderKt {
}
@@ -520,6 +524,13 @@
enum_constant public static final androidx.ui.graphics.PathFillType nonZero;
}
+ public interface PathMeasure {
+ method public float getLength();
+ method public boolean getSegment(float startDistance, float stopDistance, androidx.ui.graphics.Path path, boolean startWithMoveTo);
+ method public void setPath(androidx.ui.graphics.Path path, boolean forceClosed);
+ property public abstract float length;
+ }
+
public enum PathOperation {
method public static androidx.ui.graphics.PathOperation valueOf(String name) throws java.lang.IllegalArgumentException;
method public static androidx.ui.graphics.PathOperation[] values();
diff --git a/ui/ui-graphics/api/restricted_0.1.0-dev16.txt b/ui/ui-graphics/api/restricted_0.1.0-dev16.txt
index 3942120..5b534f2 100644
--- a/ui/ui-graphics/api/restricted_0.1.0-dev16.txt
+++ b/ui/ui-graphics/api/restricted_0.1.0-dev16.txt
@@ -143,6 +143,10 @@
method public static androidx.ui.graphics.Path asComposePath(android.graphics.Path);
}
+ public final class AndroidPathMeasureKt {
+ method public static androidx.ui.graphics.PathMeasure PathMeasure();
+ }
+
public final class AndroidShaderKt {
}
@@ -553,6 +557,13 @@
enum_constant public static final androidx.ui.graphics.PathFillType nonZero;
}
+ public interface PathMeasure {
+ method public float getLength();
+ method public boolean getSegment(float startDistance, float stopDistance, androidx.ui.graphics.Path path, boolean startWithMoveTo);
+ method public void setPath(androidx.ui.graphics.Path path, boolean forceClosed);
+ property public abstract float length;
+ }
+
public enum PathOperation {
method public static androidx.ui.graphics.PathOperation valueOf(String name) throws java.lang.IllegalArgumentException;
method public static androidx.ui.graphics.PathOperation[] values();
diff --git a/ui/ui-graphics/api/restricted_current.txt b/ui/ui-graphics/api/restricted_current.txt
index 3942120..5b534f2 100644
--- a/ui/ui-graphics/api/restricted_current.txt
+++ b/ui/ui-graphics/api/restricted_current.txt
@@ -143,6 +143,10 @@
method public static androidx.ui.graphics.Path asComposePath(android.graphics.Path);
}
+ public final class AndroidPathMeasureKt {
+ method public static androidx.ui.graphics.PathMeasure PathMeasure();
+ }
+
public final class AndroidShaderKt {
}
@@ -553,6 +557,13 @@
enum_constant public static final androidx.ui.graphics.PathFillType nonZero;
}
+ public interface PathMeasure {
+ method public float getLength();
+ method public boolean getSegment(float startDistance, float stopDistance, androidx.ui.graphics.Path path, boolean startWithMoveTo);
+ method public void setPath(androidx.ui.graphics.Path path, boolean forceClosed);
+ property public abstract float length;
+ }
+
public enum PathOperation {
method public static androidx.ui.graphics.PathOperation valueOf(String name) throws java.lang.IllegalArgumentException;
method public static androidx.ui.graphics.PathOperation[] values();
diff --git a/ui/ui-graphics/src/androidMain/kotlin/androidx/ui/graphics/AndroidPathMeasure.kt b/ui/ui-graphics/src/androidMain/kotlin/androidx/ui/graphics/AndroidPathMeasure.kt
new file mode 100644
index 0000000..21003fe
--- /dev/null
+++ b/ui/ui-graphics/src/androidMain/kotlin/androidx/ui/graphics/AndroidPathMeasure.kt
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.ui.graphics
+
+internal class AndroidPathMeasure() : PathMeasure {
+ private val measure = android.graphics.PathMeasure()
+
+ override fun setPath(path: Path, forceClosed: Boolean) {
+ measure.setPath(path.asAndroidPath(), forceClosed)
+ }
+
+ override fun getSegment(
+ startDistance: Float,
+ stopDistance: Float,
+ path: Path,
+ startWithMoveTo: Boolean
+ ): Boolean =
+ measure.getSegment(startDistance, stopDistance, path.asAndroidPath(), startWithMoveTo)
+
+ override val length: Float
+ get() = measure.length
+}
+
+actual fun PathMeasure(): PathMeasure = AndroidPathMeasure()
\ No newline at end of file
diff --git a/ui/ui-graphics/src/commonMain/kotlin/androidx/ui/graphics/PathMeasure.kt b/ui/ui-graphics/src/commonMain/kotlin/androidx/ui/graphics/PathMeasure.kt
new file mode 100644
index 0000000..3c246e0
--- /dev/null
+++ b/ui/ui-graphics/src/commonMain/kotlin/androidx/ui/graphics/PathMeasure.kt
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.ui.graphics
+
+interface PathMeasure {
+ val length: Float
+ fun setPath(path: Path, forceClosed: Boolean)
+ fun getSegment(
+ startDistance: Float,
+ stopDistance: Float,
+ path: Path,
+ startWithMoveTo: Boolean
+ ): Boolean
+}
+
+expect fun PathMeasure(): PathMeasure
\ No newline at end of file
diff --git a/ui/ui-material/build.gradle b/ui/ui-material/build.gradle
index 8b1b759..532428b2 100644
--- a/ui/ui-material/build.gradle
+++ b/ui/ui-material/build.gradle
@@ -25,45 +25,57 @@
id("AndroidXPlugin")
id("com.android.library")
id("AndroidXUiPlugin")
- id("org.jetbrains.kotlin.android")
+ id("kotlin-multiplatform")
}
dependencies {
kotlinPlugin project(path: ":compose:compose-compiler")
+}
- implementation(KOTLIN_STDLIB)
+kotlin {
+ android()
+ sourceSets {
+ commonMain.dependencies {
+ implementation(KOTLIN_STDLIB_COMMON)
+ api project(":compose:runtime:runtime")
+ implementation project(":compose:ui:ui-util")
+ api project(":compose:ui:ui")
+ api project(":compose:foundation:foundation")
+ api project(":compose:material:material-icons-core")
+ api project(":compose:ui:ui-text")
+ api project(":compose:foundation:foundation-text")
+ api project(":compose:animation:animation-core")
- api "androidx.annotation:annotation:1.1.0"
+ implementation project(":compose:foundation:foundation-layout")
+ implementation project(":compose:animation:animation")
+ }
- api project(":compose:runtime:runtime")
- implementation project(":compose:ui:ui-util")
- api project(":compose:ui:ui")
- api project(":compose:foundation:foundation")
- api project(":compose:material:material-icons-core")
- api project(":compose:ui:ui-text")
- api project(":compose:foundation:foundation-text")
- api project(":compose:animation:animation-core")
+ androidMain.dependencies {
+ api "androidx.annotation:annotation:1.1.0"
+ }
- implementation project(":compose:foundation:foundation-layout")
- implementation project(":compose:animation:animation")
+ test.dependencies {
+ implementation(ANDROIDX_TEST_RULES)
+ implementation(ANDROIDX_TEST_RUNNER)
+ implementation(JUNIT)
+ implementation(TRUTH)
+ }
- testImplementation(ANDROIDX_TEST_RULES)
- testImplementation(ANDROIDX_TEST_RUNNER)
- testImplementation(JUNIT)
- testImplementation(TRUTH)
+ androidAndroidTest.dependencies {
+ implementation project(":compose:material:material:samples")
+ implementation project(":ui:ui-test")
+ implementation project(":test-screenshot")
- androidTestImplementation project(":compose:material:material:samples")
- androidTestImplementation project(":ui:ui-test")
- androidTestImplementation project(":test-screenshot")
-
- androidTestImplementation(ANDROIDX_TEST_RULES)
- androidTestImplementation(ANDROIDX_TEST_RUNNER)
- androidTestImplementation(JUNIT)
- androidTestImplementation(TRUTH)
- androidTestImplementation(DEXMAKER_MOCKITO, libs.exclude_bytebuddy) // DexMaker has it"s own MockMaker
- androidTestImplementation(MOCKITO_CORE, libs.exclude_bytebuddy) // DexMaker has it"s own MockMaker
- androidTestImplementation MOCKITO_KOTLIN, {
- exclude group: 'org.mockito' // to keep control on the mockito version
+ implementation(ANDROIDX_TEST_RULES)
+ implementation(ANDROIDX_TEST_RUNNER)
+ implementation(JUNIT)
+ implementation(TRUTH)
+ implementation(DEXMAKER_MOCKITO, libs.exclude_bytebuddy) // DexMaker has it"s own MockMaker
+ implementation(MOCKITO_CORE, libs.exclude_bytebuddy) // DexMaker has it"s own MockMaker
+ implementation MOCKITO_KOTLIN, {
+ exclude group: 'org.mockito' // to keep control on the mockito version
+ }
+ }
}
}
diff --git a/ui/ui-material/icons/core/build.gradle b/ui/ui-material/icons/core/build.gradle
index 024dae1..740f4d5 100644
--- a/ui/ui-material/icons/core/build.gradle
+++ b/ui/ui-material/icons/core/build.gradle
@@ -26,16 +26,24 @@
id("AndroidXPlugin")
id("com.android.library")
id("AndroidXUiPlugin")
- id("org.jetbrains.kotlin.android")
+ id("kotlin-multiplatform")
}
-dependencies {
- implementation(KOTLIN_STDLIB)
+kotlin {
+ android()
+ sourceSets {
+ commonMain.dependencies {
+ implementation(KOTLIN_STDLIB_COMMON)
+ api project(":compose:ui:ui")
+ }
- api project(":compose:ui:ui")
+ androidMain.dependencies {
+ implementation(KOTLIN_STDLIB)
+ }
+ }
}
-IconGenerationTask.registerCoreIconProject(project, android)
+IconGenerationTask.registerCoreIconProject(project)
androidx {
name = "AndroidX Core Material Icons"
diff --git a/ui/ui-material/icons/core/src/main/AndroidManifest.xml b/ui/ui-material/icons/core/src/androidMain/AndroidManifest.xml
similarity index 100%
rename from ui/ui-material/icons/core/src/main/AndroidManifest.xml
rename to ui/ui-material/icons/core/src/androidMain/AndroidManifest.xml
diff --git a/ui/ui-material/icons/core/src/main/java/androidx/ui/material/icons/Icons.kt b/ui/ui-material/icons/core/src/commonMain/kotlin/androidx/ui/material/icons/Icons.kt
similarity index 100%
rename from ui/ui-material/icons/core/src/main/java/androidx/ui/material/icons/Icons.kt
rename to ui/ui-material/icons/core/src/commonMain/kotlin/androidx/ui/material/icons/Icons.kt
diff --git a/ui/ui-material/icons/extended/build.gradle b/ui/ui-material/icons/extended/build.gradle
index 8f774c6..7efed7e 100644
--- a/ui/ui-material/icons/extended/build.gradle
+++ b/ui/ui-material/icons/extended/build.gradle
@@ -26,29 +26,37 @@
id("AndroidXPlugin")
id("com.android.library")
id("AndroidXUiPlugin")
- id("org.jetbrains.kotlin.android")
+ id("kotlin-multiplatform")
}
dependencies {
kotlinPlugin project(path: ":compose:compose-compiler")
- implementation(KOTLIN_STDLIB)
-
- api project(":compose:material:material-icons-core")
- implementation project(":compose:runtime:runtime")
-
- androidTestImplementation project(":compose:foundation:foundation")
- androidTestImplementation project(":compose:foundation:foundation-layout")
- androidTestImplementation project(":compose:ui:ui")
- androidTestImplementation project(":ui:ui-test")
- androidTestImplementation project(":test-screenshot")
-
- androidTestImplementation(ANDROIDX_TEST_RULES)
- androidTestImplementation(ANDROIDX_TEST_RUNNER)
- androidTestImplementation(JUNIT)
- androidTestImplementation(KOTLIN_REFLECT)
- androidTestImplementation(TRUTH)
}
+kotlin {
+ android()
+ sourceSets {
+ commonMain.dependencies {
+ implementation(KOTLIN_STDLIB_COMMON)
+ api project(":compose:material:material-icons-core")
+ implementation project(":compose:runtime:runtime")
+ }
+
+ androidTest.dependencies {
+ implementation project(":compose:foundation:foundation")
+ implementation project(":compose:foundation:foundation-layout")
+ implementation project(":compose:ui:ui")
+ implementation project(":ui:ui-test")
+ implementation project(":test-screenshot")
+
+ implementation(ANDROIDX_TEST_RULES)
+ implementation(ANDROIDX_TEST_RUNNER)
+ implementation(JUNIT)
+ implementation(KOTLIN_REFLECT)
+ implementation(TRUTH)
+ }
+ }
+}
android.buildTypes.all {
// Jacoco hangs intermittently due to the large number of files
testCoverageEnabled = false
diff --git a/ui/ui-material/icons/extended/src/androidTest/AndroidManifest.xml b/ui/ui-material/icons/extended/src/androidAndroidTest/AndroidManifest.xml
similarity index 100%
rename from ui/ui-material/icons/extended/src/androidTest/AndroidManifest.xml
rename to ui/ui-material/icons/extended/src/androidAndroidTest/AndroidManifest.xml
diff --git a/ui/ui-material/icons/extended/src/androidTest/java/androidx/ui/material/icons/test/IconComparisonTest.kt b/ui/ui-material/icons/extended/src/androidAndroidTest/kotlin/androidx/ui/material/icons/test/IconComparisonTest.kt
similarity index 100%
rename from ui/ui-material/icons/extended/src/androidTest/java/androidx/ui/material/icons/test/IconComparisonTest.kt
rename to ui/ui-material/icons/extended/src/androidAndroidTest/kotlin/androidx/ui/material/icons/test/IconComparisonTest.kt
diff --git a/ui/ui-material/icons/extended/src/androidTest/AndroidManifest.xml b/ui/ui-material/icons/extended/src/androidMain/AndroidManifest.xml
similarity index 100%
copy from ui/ui-material/icons/extended/src/androidTest/AndroidManifest.xml
copy to ui/ui-material/icons/extended/src/androidMain/AndroidManifest.xml
diff --git a/ui/ui-material/icons/extended/src/main/AndroidManifest.xml b/ui/ui-material/icons/extended/src/main/AndroidManifest.xml
deleted file mode 100644
index 88c6032..0000000
--- a/ui/ui-material/icons/extended/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright 2020 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-<manifest package="androidx.ui.material.icons" />
diff --git a/ui/ui-material/icons/generator/build.gradle b/ui/ui-material/icons/generator/build.gradle
index 286a7a6..9158245 100644
--- a/ui/ui-material/icons/generator/build.gradle
+++ b/ui/ui-material/icons/generator/build.gradle
@@ -30,6 +30,7 @@
implementation(AGP_STABLE)
implementation(GUAVA)
+ implementation(KOTLIN_GRADLE_PLUGIN)
implementation(KOTLIN_STDLIB)
implementation(KOTLINPOET)
implementation(XMLPULL)
diff --git a/ui/ui-material/icons/generator/src/main/kotlin/androidx/ui/material/icons/generator/tasks/IconGenerationTask.kt b/ui/ui-material/icons/generator/src/main/kotlin/androidx/ui/material/icons/generator/tasks/IconGenerationTask.kt
index 6fe7284..d55750b 100644
--- a/ui/ui-material/icons/generator/src/main/kotlin/androidx/ui/material/icons/generator/tasks/IconGenerationTask.kt
+++ b/ui/ui-material/icons/generator/src/main/kotlin/androidx/ui/material/icons/generator/tasks/IconGenerationTask.kt
@@ -27,6 +27,8 @@
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.TaskAction
+import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
+import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
import java.io.File
/**
@@ -70,11 +72,11 @@
@get:OutputDirectory
val generatedSrcMainDirectory: File
- get() = buildDirectory.resolve("src/main/kotlin")
+ get() = buildDirectory.resolve("src/commonMain/kotlin")
@get:OutputDirectory
val generatedSrcAndroidTestDirectory: File
- get() = buildDirectory.resolve("src/androidTest/kotlin")
+ get() = buildDirectory.resolve("src/androidAndroidTest/kotlin")
@get:OutputDirectory
val generatedResourceDirectory: File
@@ -92,10 +94,8 @@
* [androidx.ui.material.icons.generator.CoreIcons], and no tests.
*/
@JvmStatic
- fun registerCoreIconProject(project: Project, libraryExtension: LibraryExtension) {
- libraryExtension.libraryVariants.all { variant ->
- CoreIconGenerationTask.register(project, variant)
- }
+ fun registerCoreIconProject(project: Project) {
+ CoreIconGenerationTask.register(project)
}
/**
@@ -105,9 +105,7 @@
*/
@JvmStatic
fun registerExtendedIconProject(project: Project, libraryExtension: LibraryExtension) {
- libraryExtension.libraryVariants.all { variant ->
- ExtendedIconGenerationTask.register(project, variant)
- }
+ ExtendedIconGenerationTask.register(project)
libraryExtension.testVariants.all { variant ->
IconTestingGenerationTask.register(project, variant)
@@ -123,14 +121,28 @@
* Registers a new [T] in [this], and sets [IconGenerationTask.buildDirectory] depending on
* [variant].
*
+ * @param variant the [BaseVariant] to associate this task with, or `null` if this task does not
+ * change between variants.
* @return the created [T] of [IconGenerationTask]
*/
+@Suppress("DefaultLocale")
fun <T : IconGenerationTask> Project.createGenerationTask(
taskName: String,
- variant: BaseVariant,
- taskClass: Class<T>
+ taskClass: Class<T>,
+ variant: BaseVariant? = null
): T {
- return tasks.create("$taskName${variant.name.capitalize()}", taskClass) {
- it.buildDirectory = project.buildDir.resolve("generatedIcons/${variant.name}")
+ val variantName = variant?.name ?: "allVariants"
+ return tasks.create("$taskName${variantName.capitalize()}", taskClass) {
+ it.buildDirectory = project.buildDir.resolve("generatedIcons/$variantName")
}
}
+
+fun Project.getMultiplatformSourceSet(name: String): KotlinSourceSet {
+ val sourceSet = project.multiplatformExtension!!.sourceSets.find { it.name == name }
+ return requireNotNull(sourceSet) {
+ "No source sets found matching $name"
+ }
+}
+
+private val Project.multiplatformExtension
+ get() = extensions.findByType(KotlinMultiplatformExtension::class.java)
diff --git a/ui/ui-material/icons/generator/src/main/kotlin/androidx/ui/material/icons/generator/tasks/IconSourceTasks.kt b/ui/ui-material/icons/generator/src/main/kotlin/androidx/ui/material/icons/generator/tasks/IconSourceTasks.kt
index 2601163..439a7dc 100644
--- a/ui/ui-material/icons/generator/src/main/kotlin/androidx/ui/material/icons/generator/tasks/IconSourceTasks.kt
+++ b/ui/ui-material/icons/generator/src/main/kotlin/androidx/ui/material/icons/generator/tasks/IconSourceTasks.kt
@@ -18,8 +18,8 @@
import androidx.ui.material.icons.generator.CoreIcons
import androidx.ui.material.icons.generator.IconWriter
-import com.android.build.gradle.api.BaseVariant
import org.gradle.api.Project
+import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
/**
* Task responsible for converting core icons from xml to a programmatic representation.
@@ -30,15 +30,14 @@
companion object {
/**
- * Registers [CoreIconGenerationTask] in [project] for [variant].
+ * Registers [CoreIconGenerationTask] in [project].
*/
- fun register(project: Project, variant: BaseVariant) {
+ fun register(project: Project) {
val task = project.createGenerationTask(
"generateCoreIcons",
- variant,
CoreIconGenerationTask::class.java
)
- variant.registerIconGenerationTask(project, task)
+ registerIconGenerationTask(project, task)
}
}
}
@@ -52,28 +51,25 @@
companion object {
/**
- * Registers [ExtendedIconGenerationTask] in [project] for [variant].
+ * Registers [ExtendedIconGenerationTask] in [project].
*/
- fun register(project: Project, variant: BaseVariant) {
+ fun register(project: Project) {
val task = project.createGenerationTask(
"generateExtendedIcons",
- variant,
ExtendedIconGenerationTask::class.java
)
- variant.registerIconGenerationTask(project, task)
+ registerIconGenerationTask(project, task)
}
}
}
/**
- * Helper to register [task] as the java source generating task for [project].
+ * Helper to register [task] as the Kotlin source generating task for [project].
*/
-private fun BaseVariant.registerIconGenerationTask(
+private fun registerIconGenerationTask(
project: Project,
task: IconGenerationTask
) {
- registerJavaGeneratingTask(task, task.generatedSrcMainDirectory)
- // TODO: b/144249620 - fixed in AGP 4.0.0 alpha 4 +
- javaCompileProvider.configure { it.enabled = false }
- project.tasks.named("runErrorProne").configure { it.enabled = false }
+ val sourceSet = project.getMultiplatformSourceSet(KotlinSourceSet.COMMON_MAIN_SOURCE_SET_NAME)
+ sourceSet.kotlin.srcDir(project.files(task.generatedSrcMainDirectory).builtBy(task))
}
diff --git a/ui/ui-material/icons/generator/src/main/kotlin/androidx/ui/material/icons/generator/tasks/IconTestingGenerationTask.kt b/ui/ui-material/icons/generator/src/main/kotlin/androidx/ui/material/icons/generator/tasks/IconTestingGenerationTask.kt
index ac01c44..3227b371 100644
--- a/ui/ui-material/icons/generator/src/main/kotlin/androidx/ui/material/icons/generator/tasks/IconTestingGenerationTask.kt
+++ b/ui/ui-material/icons/generator/src/main/kotlin/androidx/ui/material/icons/generator/tasks/IconTestingGenerationTask.kt
@@ -58,13 +58,15 @@
fun register(project: Project, variant: BaseVariant) {
val task = project.createGenerationTask(
"generateTestFiles",
- variant,
- IconTestingGenerationTask::class.java
+ IconTestingGenerationTask::class.java,
+ variant
)
variant.registerGeneratedResFolders(
project.files(task.generatedResourceDirectory).builtBy(task)
)
- variant.registerJavaGeneratingTask(task, task.generatedSrcAndroidTestDirectory)
+ val sourceSet = project.getMultiplatformSourceSet("androidAndroidTest")
+ sourceSet.kotlin
+ .srcDir(project.files(task.generatedSrcAndroidTestDirectory).builtBy(task))
}
}
}
diff --git a/ui/ui-material/src/androidTest/AndroidManifest.xml b/ui/ui-material/src/androidAndroidTest/AndroidManifest.xml
similarity index 100%
rename from ui/ui-material/src/androidTest/AndroidManifest.xml
rename to ui/ui-material/src/androidAndroidTest/AndroidManifest.xml
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/AppBarTest.kt b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/AppBarTest.kt
similarity index 100%
rename from ui/ui-material/src/androidTest/java/androidx/ui/material/AppBarTest.kt
rename to ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/AppBarTest.kt
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/BottomNavigationTest.kt b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/BottomNavigationTest.kt
similarity index 100%
rename from ui/ui-material/src/androidTest/java/androidx/ui/material/BottomNavigationTest.kt
rename to ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/BottomNavigationTest.kt
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/ButtonScreenshotTest.kt b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/ButtonScreenshotTest.kt
similarity index 100%
rename from ui/ui-material/src/androidTest/java/androidx/ui/material/ButtonScreenshotTest.kt
rename to ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/ButtonScreenshotTest.kt
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/ButtonTest.kt b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/ButtonTest.kt
similarity index 100%
rename from ui/ui-material/src/androidTest/java/androidx/ui/material/ButtonTest.kt
rename to ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/ButtonTest.kt
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/CardTest.kt b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/CardTest.kt
similarity index 100%
rename from ui/ui-material/src/androidTest/java/androidx/ui/material/CardTest.kt
rename to ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/CardTest.kt
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/CheckboxScreenshotTest.kt b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/CheckboxScreenshotTest.kt
similarity index 100%
rename from ui/ui-material/src/androidTest/java/androidx/ui/material/CheckboxScreenshotTest.kt
rename to ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/CheckboxScreenshotTest.kt
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/CheckboxUiTest.kt b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/CheckboxUiTest.kt
similarity index 100%
rename from ui/ui-material/src/androidTest/java/androidx/ui/material/CheckboxUiTest.kt
rename to ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/CheckboxUiTest.kt
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/DividerUiTest.kt b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/DividerUiTest.kt
similarity index 100%
rename from ui/ui-material/src/androidTest/java/androidx/ui/material/DividerUiTest.kt
rename to ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/DividerUiTest.kt
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/DrawerScreenshotTest.kt b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/DrawerScreenshotTest.kt
similarity index 100%
rename from ui/ui-material/src/androidTest/java/androidx/ui/material/DrawerScreenshotTest.kt
rename to ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/DrawerScreenshotTest.kt
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/DrawerTest.kt b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/DrawerTest.kt
similarity index 100%
rename from ui/ui-material/src/androidTest/java/androidx/ui/material/DrawerTest.kt
rename to ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/DrawerTest.kt
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/ElevationOverlayTest.kt b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/ElevationOverlayTest.kt
similarity index 100%
rename from ui/ui-material/src/androidTest/java/androidx/ui/material/ElevationOverlayTest.kt
rename to ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/ElevationOverlayTest.kt
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/EmphasisTest.kt b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/EmphasisTest.kt
similarity index 100%
rename from ui/ui-material/src/androidTest/java/androidx/ui/material/EmphasisTest.kt
rename to ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/EmphasisTest.kt
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/FloatingActionButtonTest.kt b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/FloatingActionButtonTest.kt
similarity index 100%
rename from ui/ui-material/src/androidTest/java/androidx/ui/material/FloatingActionButtonTest.kt
rename to ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/FloatingActionButtonTest.kt
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/GoldenCommon.kt b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/GoldenCommon.kt
similarity index 100%
rename from ui/ui-material/src/androidTest/java/androidx/ui/material/GoldenCommon.kt
rename to ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/GoldenCommon.kt
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/IconButtonTest.kt b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/IconButtonTest.kt
similarity index 100%
rename from ui/ui-material/src/androidTest/java/androidx/ui/material/IconButtonTest.kt
rename to ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/IconButtonTest.kt
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/IconTest.kt b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/IconTest.kt
similarity index 100%
rename from ui/ui-material/src/androidTest/java/androidx/ui/material/IconTest.kt
rename to ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/IconTest.kt
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/ListItemTest.kt b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/ListItemTest.kt
similarity index 100%
rename from ui/ui-material/src/androidTest/java/androidx/ui/material/ListItemTest.kt
rename to ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/ListItemTest.kt
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/MaterialTest.kt b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/MaterialTest.kt
similarity index 100%
rename from ui/ui-material/src/androidTest/java/androidx/ui/material/MaterialTest.kt
rename to ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/MaterialTest.kt
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/MenuTest.kt b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/MenuTest.kt
similarity index 100%
rename from ui/ui-material/src/androidTest/java/androidx/ui/material/MenuTest.kt
rename to ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/MenuTest.kt
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/ProgressIndicatorTest.kt b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/ProgressIndicatorTest.kt
similarity index 100%
rename from ui/ui-material/src/androidTest/java/androidx/ui/material/ProgressIndicatorTest.kt
rename to ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/ProgressIndicatorTest.kt
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/RadioButtonScreenshotTest.kt b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/RadioButtonScreenshotTest.kt
similarity index 100%
rename from ui/ui-material/src/androidTest/java/androidx/ui/material/RadioButtonScreenshotTest.kt
rename to ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/RadioButtonScreenshotTest.kt
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/RadioButtonTest.kt b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/RadioButtonTest.kt
similarity index 100%
rename from ui/ui-material/src/androidTest/java/androidx/ui/material/RadioButtonTest.kt
rename to ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/RadioButtonTest.kt
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/ScaffoldTest.kt b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/ScaffoldTest.kt
similarity index 100%
rename from ui/ui-material/src/androidTest/java/androidx/ui/material/ScaffoldTest.kt
rename to ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/ScaffoldTest.kt
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/SliderTest.kt b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/SliderTest.kt
similarity index 100%
rename from ui/ui-material/src/androidTest/java/androidx/ui/material/SliderTest.kt
rename to ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/SliderTest.kt
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/SnackbarTest.kt b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/SnackbarTest.kt
similarity index 100%
rename from ui/ui-material/src/androidTest/java/androidx/ui/material/SnackbarTest.kt
rename to ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/SnackbarTest.kt
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/SurfaceContentColorTest.kt b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/SurfaceContentColorTest.kt
similarity index 100%
rename from ui/ui-material/src/androidTest/java/androidx/ui/material/SurfaceContentColorTest.kt
rename to ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/SurfaceContentColorTest.kt
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/SurfaceTest.kt b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/SurfaceTest.kt
similarity index 100%
rename from ui/ui-material/src/androidTest/java/androidx/ui/material/SurfaceTest.kt
rename to ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/SurfaceTest.kt
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/SwitchScreenshotTest.kt b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/SwitchScreenshotTest.kt
similarity index 100%
rename from ui/ui-material/src/androidTest/java/androidx/ui/material/SwitchScreenshotTest.kt
rename to ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/SwitchScreenshotTest.kt
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/SwitchTest.kt b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/SwitchTest.kt
similarity index 100%
rename from ui/ui-material/src/androidTest/java/androidx/ui/material/SwitchTest.kt
rename to ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/SwitchTest.kt
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/TabTest.kt b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/TabTest.kt
similarity index 100%
rename from ui/ui-material/src/androidTest/java/androidx/ui/material/TabTest.kt
rename to ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/TabTest.kt
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/ripple/RippleIndicationTest.kt b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/ripple/RippleIndicationTest.kt
similarity index 100%
rename from ui/ui-material/src/androidTest/java/androidx/ui/material/ripple/RippleIndicationTest.kt
rename to ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/ripple/RippleIndicationTest.kt
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/FilledTextFieldTest.kt b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/textfield/FilledTextFieldTest.kt
similarity index 100%
rename from ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/FilledTextFieldTest.kt
rename to ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/textfield/FilledTextFieldTest.kt
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/OutlinedTextFieldTest.kt b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/textfield/OutlinedTextFieldTest.kt
similarity index 100%
rename from ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/OutlinedTextFieldTest.kt
rename to ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/textfield/OutlinedTextFieldTest.kt
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/TextFieldScreenshotTest.kt b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/textfield/TextFieldScreenshotTest.kt
similarity index 100%
rename from ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/TextFieldScreenshotTest.kt
rename to ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/textfield/TextFieldScreenshotTest.kt
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/TextFieldTest.kt b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/textfield/TextFieldTest.kt
similarity index 100%
rename from ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/TextFieldTest.kt
rename to ui/ui-material/src/androidAndroidTest/kotlin/androidx/ui/material/textfield/TextFieldTest.kt
diff --git a/ui/ui-material/src/main/AndroidManifest.xml b/ui/ui-material/src/androidMain/AndroidManifest.xml
similarity index 100%
rename from ui/ui-material/src/main/AndroidManifest.xml
rename to ui/ui-material/src/androidMain/AndroidManifest.xml
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/AlertDialog.kt b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/AlertDialog.kt
similarity index 100%
rename from ui/ui-material/src/main/java/androidx/ui/material/AlertDialog.kt
rename to ui/ui-material/src/commonMain/kotlin/androidx/ui/material/AlertDialog.kt
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/AppBar.kt b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/AppBar.kt
similarity index 100%
rename from ui/ui-material/src/main/java/androidx/ui/material/AppBar.kt
rename to ui/ui-material/src/commonMain/kotlin/androidx/ui/material/AppBar.kt
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/BottomNavigation.kt b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/BottomNavigation.kt
similarity index 99%
rename from ui/ui-material/src/main/java/androidx/ui/material/BottomNavigation.kt
rename to ui/ui-material/src/commonMain/kotlin/androidx/ui/material/BottomNavigation.kt
index c83aa35..c6b91f3 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/BottomNavigation.kt
+++ b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/BottomNavigation.kt
@@ -19,7 +19,6 @@
import androidx.compose.animation.core.VectorizedAnimationSpec
import androidx.compose.animation.core.FastOutSlowInEasing
import androidx.compose.animation.core.TweenSpec
-import androidx.annotation.FloatRange
import androidx.compose.Composable
import androidx.compose.Providers
import androidx.compose.emptyContent
@@ -49,6 +48,7 @@
import androidx.compose.ui.text.style.TextAlign
import androidx.ui.unit.Dp
import androidx.ui.unit.dp
+import androidx.ui.util.annotation.FloatRange
import kotlin.math.max
import kotlin.math.roundToInt
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/Button.kt b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/Button.kt
similarity index 100%
rename from ui/ui-material/src/main/java/androidx/ui/material/Button.kt
rename to ui/ui-material/src/commonMain/kotlin/androidx/ui/material/Button.kt
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/Card.kt b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/Card.kt
similarity index 100%
rename from ui/ui-material/src/main/java/androidx/ui/material/Card.kt
rename to ui/ui-material/src/commonMain/kotlin/androidx/ui/material/Card.kt
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/Checkbox.kt b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/Checkbox.kt
similarity index 97%
rename from ui/ui-material/src/main/java/androidx/ui/material/Checkbox.kt
rename to ui/ui-material/src/commonMain/kotlin/androidx/ui/material/Checkbox.kt
index f432076b..e60365185 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/Checkbox.kt
+++ b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/Checkbox.kt
@@ -16,7 +16,6 @@
package androidx.ui.material
-import android.graphics.PathMeasure
import androidx.compose.animation.core.FloatPropKey
import androidx.compose.animation.core.TransitionSpec
import androidx.compose.animation.core.keyframes
@@ -38,8 +37,8 @@
import androidx.ui.geometry.Size
import androidx.ui.graphics.Color
import androidx.ui.graphics.Path
+import androidx.ui.graphics.PathMeasure
import androidx.ui.graphics.StrokeCap
-import androidx.ui.graphics.asAndroidPath
import androidx.ui.graphics.drawscope.DrawScope
import androidx.ui.graphics.drawscope.Fill
import androidx.ui.graphics.drawscope.Stroke
@@ -251,10 +250,10 @@
checkPath.lineTo(width * gravitatedCrossX, width * gravitatedCrossY)
checkPath.lineTo(width * rightX, width * gravitatedRightY)
// TODO: replace with proper declarative non-android alternative when ready (b/158188351)
- pathMeasure.setPath(checkPath.asAndroidPath(), false)
+ pathMeasure.setPath(checkPath, false)
pathToDraw.reset()
pathMeasure.getSegment(
- 0f, pathMeasure.length * checkFraction, pathToDraw.asAndroidPath(), true
+ 0f, pathMeasure.length * checkFraction, pathToDraw, true
)
}
drawPath(drawingCache.pathToDraw, checkColor, style = stroke)
@@ -279,7 +278,7 @@
private val CheckAnimationDuration = 100
private fun generateTransitionDefinition(color: Color, unselectedColor: Color) =
- transitionDefinition {
+ transitionDefinition<ToggleableState> {
state(ToggleableState.On) {
this[CheckDrawFraction] = 1f
this[BoxOpacityFraction] = 1f
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/Color.kt b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/Color.kt
similarity index 100%
rename from ui/ui-material/src/main/java/androidx/ui/material/Color.kt
rename to ui/ui-material/src/commonMain/kotlin/androidx/ui/material/Color.kt
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/Divider.kt b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/Divider.kt
similarity index 100%
rename from ui/ui-material/src/main/java/androidx/ui/material/Divider.kt
rename to ui/ui-material/src/commonMain/kotlin/androidx/ui/material/Divider.kt
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/Drawer.kt b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/Drawer.kt
similarity index 100%
rename from ui/ui-material/src/main/java/androidx/ui/material/Drawer.kt
rename to ui/ui-material/src/commonMain/kotlin/androidx/ui/material/Drawer.kt
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/Emphasis.kt b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/Emphasis.kt
similarity index 99%
rename from ui/ui-material/src/main/java/androidx/ui/material/Emphasis.kt
rename to ui/ui-material/src/commonMain/kotlin/androidx/ui/material/Emphasis.kt
index b93a46f..7f93d56 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/Emphasis.kt
+++ b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/Emphasis.kt
@@ -16,7 +16,6 @@
package androidx.ui.material
-import androidx.annotation.FloatRange
import androidx.compose.Ambient
import androidx.compose.Composable
import androidx.compose.Immutable
@@ -26,6 +25,7 @@
import androidx.compose.foundation.contentColor
import androidx.ui.graphics.Color
import androidx.ui.graphics.luminance
+import androidx.ui.util.annotation.FloatRange
/**
* Emphasis allows certain parts of a component to be accentuated, or shown with lower contrast
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/ExperimentalMaterialApi.kt b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/ExperimentalMaterialApi.kt
similarity index 100%
rename from ui/ui-material/src/main/java/androidx/ui/material/ExperimentalMaterialApi.kt
rename to ui/ui-material/src/commonMain/kotlin/androidx/ui/material/ExperimentalMaterialApi.kt
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/FloatingActionButton.kt b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/FloatingActionButton.kt
similarity index 100%
rename from ui/ui-material/src/main/java/androidx/ui/material/FloatingActionButton.kt
rename to ui/ui-material/src/commonMain/kotlin/androidx/ui/material/FloatingActionButton.kt
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/IconButton.kt b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/IconButton.kt
similarity index 100%
rename from ui/ui-material/src/main/java/androidx/ui/material/IconButton.kt
rename to ui/ui-material/src/commonMain/kotlin/androidx/ui/material/IconButton.kt
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/ListItem.kt b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/ListItem.kt
similarity index 100%
rename from ui/ui-material/src/main/java/androidx/ui/material/ListItem.kt
rename to ui/ui-material/src/commonMain/kotlin/androidx/ui/material/ListItem.kt
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/MaterialTheme.kt b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/MaterialTheme.kt
similarity index 100%
rename from ui/ui-material/src/main/java/androidx/ui/material/MaterialTheme.kt
rename to ui/ui-material/src/commonMain/kotlin/androidx/ui/material/MaterialTheme.kt
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/Menu.kt b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/Menu.kt
similarity index 100%
rename from ui/ui-material/src/main/java/androidx/ui/material/Menu.kt
rename to ui/ui-material/src/commonMain/kotlin/androidx/ui/material/Menu.kt
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/OutlinedTextField.kt b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/OutlinedTextField.kt
similarity index 100%
rename from ui/ui-material/src/main/java/androidx/ui/material/OutlinedTextField.kt
rename to ui/ui-material/src/commonMain/kotlin/androidx/ui/material/OutlinedTextField.kt
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/ProgressIndicator.kt b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/ProgressIndicator.kt
similarity index 99%
rename from ui/ui-material/src/main/java/androidx/ui/material/ProgressIndicator.kt
rename to ui/ui-material/src/commonMain/kotlin/androidx/ui/material/ProgressIndicator.kt
index 183f295..34ce6c4 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/ProgressIndicator.kt
+++ b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/ProgressIndicator.kt
@@ -25,7 +25,6 @@
import androidx.compose.animation.core.repeatable
import androidx.compose.animation.core.transitionDefinition
import androidx.compose.animation.core.tween
-import androidx.annotation.FloatRange
import androidx.compose.Composable
import androidx.compose.animation.transition
import androidx.ui.core.DensityAmbient
@@ -47,6 +46,7 @@
import androidx.ui.semantics.accessibilityValue
import androidx.ui.unit.Dp
import androidx.ui.unit.dp
+import androidx.ui.util.annotation.FloatRange
import kotlin.math.abs
import kotlin.math.max
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/RadioButton.kt b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/RadioButton.kt
similarity index 100%
rename from ui/ui-material/src/main/java/androidx/ui/material/RadioButton.kt
rename to ui/ui-material/src/commonMain/kotlin/androidx/ui/material/RadioButton.kt
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/Scaffold.kt b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/Scaffold.kt
similarity index 100%
rename from ui/ui-material/src/main/java/androidx/ui/material/Scaffold.kt
rename to ui/ui-material/src/commonMain/kotlin/androidx/ui/material/Scaffold.kt
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/Shapes.kt b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/Shapes.kt
similarity index 100%
rename from ui/ui-material/src/main/java/androidx/ui/material/Shapes.kt
rename to ui/ui-material/src/commonMain/kotlin/androidx/ui/material/Shapes.kt
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/Slider.kt b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/Slider.kt
similarity index 98%
rename from ui/ui-material/src/main/java/androidx/ui/material/Slider.kt
rename to ui/ui-material/src/commonMain/kotlin/androidx/ui/material/Slider.kt
index a30dfda..6d9b74d 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/Slider.kt
+++ b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/Slider.kt
@@ -16,13 +16,11 @@
package androidx.ui.material
-import android.annotation.SuppressLint
import androidx.compose.animation.core.AnimatedFloat
import androidx.compose.animation.core.AnimationClockObservable
import androidx.compose.animation.core.AnimationEndReason
import androidx.compose.animation.core.TargetAnimation
import androidx.compose.animation.core.TweenSpec
-import androidx.annotation.IntRange
import androidx.compose.Composable
import androidx.compose.remember
import androidx.compose.animation.asDisposableClock
@@ -66,7 +64,9 @@
import androidx.ui.semantics.scrollForward
import androidx.ui.semantics.setProgress
import androidx.ui.unit.dp
+import androidx.ui.util.format
import androidx.ui.util.lerp
+import androidx.ui.util.annotation.IntRange
import kotlin.math.abs
import kotlin.math.roundToInt
@@ -428,7 +428,7 @@
internal var anchorsPx: List<Float> = emptyList()
private set
- @SuppressLint("UnnecessaryLambdaCreation")
+ @Suppress("UnnecessaryLambdaCreation")
internal val holder =
CallbackBasedAnimatedFloat(
scale(startValue, endValue, initial, startPx, endPx),
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/Snackbar.kt b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/Snackbar.kt
similarity index 100%
rename from ui/ui-material/src/main/java/androidx/ui/material/Snackbar.kt
rename to ui/ui-material/src/commonMain/kotlin/androidx/ui/material/Snackbar.kt
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/Surface.kt b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/Surface.kt
similarity index 100%
rename from ui/ui-material/src/main/java/androidx/ui/material/Surface.kt
rename to ui/ui-material/src/commonMain/kotlin/androidx/ui/material/Surface.kt
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/Switch.kt b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/Switch.kt
similarity index 100%
rename from ui/ui-material/src/main/java/androidx/ui/material/Switch.kt
rename to ui/ui-material/src/commonMain/kotlin/androidx/ui/material/Switch.kt
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/Tab.kt b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/Tab.kt
similarity index 100%
rename from ui/ui-material/src/main/java/androidx/ui/material/Tab.kt
rename to ui/ui-material/src/commonMain/kotlin/androidx/ui/material/Tab.kt
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/TextField.kt b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/TextField.kt
similarity index 100%
rename from ui/ui-material/src/main/java/androidx/ui/material/TextField.kt
rename to ui/ui-material/src/commonMain/kotlin/androidx/ui/material/TextField.kt
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/TextFieldImpl.kt b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/TextFieldImpl.kt
similarity index 99%
rename from ui/ui-material/src/main/java/androidx/ui/material/TextFieldImpl.kt
rename to ui/ui-material/src/commonMain/kotlin/androidx/ui/material/TextFieldImpl.kt
index bcbc048..dae7b49 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/TextFieldImpl.kt
+++ b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/TextFieldImpl.kt
@@ -23,7 +23,6 @@
import androidx.compose.animation.core.TransitionSpec
import androidx.compose.animation.core.transitionDefinition
import androidx.compose.animation.core.tween
-import androidx.annotation.VisibleForTesting
import androidx.compose.Composable
import androidx.compose.Providers
import androidx.compose.Stable
@@ -75,6 +74,7 @@
import androidx.compose.ui.text.lerp
import androidx.ui.unit.Dp
import androidx.ui.unit.dp
+import androidx.ui.util.annotation.VisibleForTesting
import kotlin.math.min
import kotlin.math.roundToInt
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/Typography.kt b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/Typography.kt
similarity index 100%
rename from ui/ui-material/src/main/java/androidx/ui/material/Typography.kt
rename to ui/ui-material/src/commonMain/kotlin/androidx/ui/material/Typography.kt
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/internal/StateDraggable.kt b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/internal/StateDraggable.kt
similarity index 99%
rename from ui/ui-material/src/main/java/androidx/ui/material/internal/StateDraggable.kt
rename to ui/ui-material/src/commonMain/kotlin/androidx/ui/material/internal/StateDraggable.kt
index bf8202c..6f16100 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/internal/StateDraggable.kt
+++ b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/internal/StateDraggable.kt
@@ -24,7 +24,6 @@
import androidx.compose.animation.core.OnAnimationEnd
import androidx.compose.animation.core.Spring
import androidx.compose.animation.core.TargetAnimation
-import androidx.annotation.FloatRange
import androidx.compose.onCommit
import androidx.compose.remember
import androidx.compose.state
@@ -39,6 +38,7 @@
import androidx.compose.foundation.gestures.draggable
import androidx.ui.util.fastFirstOrNull
import androidx.ui.util.lerp
+import androidx.ui.util.annotation.FloatRange
import kotlin.math.sign
/**
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/ripple/RippleAnimation.kt b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/ripple/RippleAnimation.kt
similarity index 99%
rename from ui/ui-material/src/main/java/androidx/ui/material/ripple/RippleAnimation.kt
rename to ui/ui-material/src/commonMain/kotlin/androidx/ui/material/ripple/RippleAnimation.kt
index 87cafc5..39c7803 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/ripple/RippleAnimation.kt
+++ b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/ripple/RippleAnimation.kt
@@ -158,7 +158,7 @@
endRadius: Float,
startCenter: Offset,
endCenter: Offset
- ) = transitionDefinition {
+ ) = transitionDefinition<State> {
state(State.Initial) {
this[Alpha] = 0f
this[Radius] = startRadius
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/ripple/RippleIndication.kt b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/ripple/RippleIndication.kt
similarity index 98%
rename from ui/ui-material/src/main/java/androidx/ui/material/ripple/RippleIndication.kt
rename to ui/ui-material/src/commonMain/kotlin/androidx/ui/material/ripple/RippleIndication.kt
index efa3282..4dfcd78 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/ripple/RippleIndication.kt
+++ b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/ripple/RippleIndication.kt
@@ -45,6 +45,7 @@
import androidx.ui.material.MaterialTheme
import androidx.ui.unit.Dp
import androidx.ui.util.fastForEach
+import androidx.ui.util.nativeClass
/**
* Material implementation of [IndicationInstance] that expresses indication via ripples. This
@@ -118,7 +119,7 @@
// making this class to be "data class"
override fun equals(other: Any?): Boolean {
if (this === other) return true
- if (javaClass != other?.javaClass) return false
+ if (this.nativeClass() != other?.nativeClass()) return false
other as RippleIndication
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/ripple/RippleTheme.kt b/ui/ui-material/src/commonMain/kotlin/androidx/ui/material/ripple/RippleTheme.kt
similarity index 100%
rename from ui/ui-material/src/main/java/androidx/ui/material/ripple/RippleTheme.kt
rename to ui/ui-material/src/commonMain/kotlin/androidx/ui/material/ripple/RippleTheme.kt
diff --git a/ui/ui-material/src/test/java/androidx/ui/material/BottomAppBarRoundedEdgesTest.kt b/ui/ui-material/src/test/kotlin/androidx/ui/material/BottomAppBarRoundedEdgesTest.kt
similarity index 100%
rename from ui/ui-material/src/test/java/androidx/ui/material/BottomAppBarRoundedEdgesTest.kt
rename to ui/ui-material/src/test/kotlin/androidx/ui/material/BottomAppBarRoundedEdgesTest.kt
diff --git a/ui/ui-material/src/test/java/androidx/ui/material/ripple/RippleAnimationTest.kt b/ui/ui-material/src/test/kotlin/androidx/ui/material/ripple/RippleAnimationTest.kt
similarity index 100%
rename from ui/ui-material/src/test/java/androidx/ui/material/ripple/RippleAnimationTest.kt
rename to ui/ui-material/src/test/kotlin/androidx/ui/material/ripple/RippleAnimationTest.kt