diff --git a/emoji-facebook/build.gradle b/emoji-facebook/build.gradle index 65a4d1a541..1c3b4e25ee 100644 --- a/emoji-facebook/build.gradle +++ b/emoji-facebook/build.gradle @@ -10,17 +10,27 @@ plugins { metalava { filename = "api/current.txt" - sourcePaths = ["src/commonMain", "src/androidMain", "src/jvmMain"] + sourcePaths = ["src/commonMain", "src/androidMain", "src/jvmMain", "src/iosMain"] } -// CocoaPods requires a version. -version = VERSION_NAME - kotlin { android("android") -// ios("ios") + ios("ios") jvm("jvm") + cocoapods { + version = VERSION_NAME + summary = "emoji-facebook" + homepage = "https://github.com/vanniktech/Emoji" + name = "EmojiFacebook" + +// framework { +// isStatic = true +// embedBitcode(BITCODE) +// export(project(":emoji")) +// } + } + sourceSets { commonMain { dependencies { @@ -43,6 +53,12 @@ kotlin { implementation libs.robolectric } + iosMain.dependencies { + } + + iosTest.dependencies { + } + jvmMain.dependencies { } diff --git a/emoji-facebook/src/iosMain/kotlin/com/vanniktech/emoji/facebook/FacebookEmojiProvider.kt b/emoji-facebook/src/iosMain/kotlin/com/vanniktech/emoji/facebook/FacebookEmojiProvider.kt new file mode 100644 index 0000000000..e601c138d1 --- /dev/null +++ b/emoji-facebook/src/iosMain/kotlin/com/vanniktech/emoji/facebook/FacebookEmojiProvider.kt @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2016 - Niklas Baudy, Ruben Gees, Mario Đanić and contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.vanniktech.emoji.facebook + +import com.vanniktech.emoji.EmojiCategory +import com.vanniktech.emoji.EmojiProvider +import com.vanniktech.emoji.facebook.category.ActivitiesCategory +import com.vanniktech.emoji.facebook.category.AnimalsAndNatureCategory +import com.vanniktech.emoji.facebook.category.FlagsCategory +import com.vanniktech.emoji.facebook.category.FoodAndDrinkCategory +import com.vanniktech.emoji.facebook.category.ObjectsCategory +import com.vanniktech.emoji.facebook.category.SmileysAndPeopleCategory +import com.vanniktech.emoji.facebook.category.SymbolsCategory +import com.vanniktech.emoji.facebook.category.TravelAndPlacesCategory + +class FacebookEmojiProvider : EmojiProvider { + override val categories: Array + get() = arrayOf( + SmileysAndPeopleCategory(), + AnimalsAndNatureCategory(), + FoodAndDrinkCategory(), + ActivitiesCategory(), + TravelAndPlacesCategory(), + ObjectsCategory(), + SymbolsCategory(), + FlagsCategory(), + ) + + override fun release() = Unit +} diff --git a/emoji-google-compat/build.gradle b/emoji-google-compat/build.gradle index 4c40ea0ae0..ba0a3d7660 100644 --- a/emoji-google-compat/build.gradle +++ b/emoji-google-compat/build.gradle @@ -10,17 +10,27 @@ plugins { metalava { filename = "api/current.txt" - sourcePaths = ["src/commonMain", "src/androidMain", "src/jvmMain"] + sourcePaths = ["src/commonMain", "src/androidMain", "src/jvmMain", "src/iosMain"] } -// CocoaPods requires a version. -version = VERSION_NAME - kotlin { android("android") -// ios("ios") + ios("ios") jvm("jvm") + cocoapods { + version = VERSION_NAME + summary = "emoji-google-compat" + homepage = "https://github.com/vanniktech/Emoji" + name = "EmojiGoogleCompat" + +// framework { +// isStatic = true +// embedBitcode(BITCODE) +// export(project(":emoji")) +// } + } + sourceSets { commonMain { dependencies { @@ -44,6 +54,12 @@ kotlin { implementation libs.robolectric } + iosMain.dependencies { + } + + iosTest.dependencies { + } + jvmMain.dependencies { } diff --git a/emoji-google-compat/src/iosMain/kotlin/com/vanniktech/emoji/googlecompat/GoogleCompatEmojiProvider.kt b/emoji-google-compat/src/iosMain/kotlin/com/vanniktech/emoji/googlecompat/GoogleCompatEmojiProvider.kt new file mode 100644 index 0000000000..7419cbba28 --- /dev/null +++ b/emoji-google-compat/src/iosMain/kotlin/com/vanniktech/emoji/googlecompat/GoogleCompatEmojiProvider.kt @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2016 - Niklas Baudy, Ruben Gees, Mario Đanić and contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.vanniktech.emoji.googlecompat + +import com.vanniktech.emoji.EmojiCategory +import com.vanniktech.emoji.EmojiProvider +import com.vanniktech.emoji.googlecompat.category.ActivitiesCategory +import com.vanniktech.emoji.googlecompat.category.AnimalsAndNatureCategory +import com.vanniktech.emoji.googlecompat.category.FlagsCategory +import com.vanniktech.emoji.googlecompat.category.FoodAndDrinkCategory +import com.vanniktech.emoji.googlecompat.category.ObjectsCategory +import com.vanniktech.emoji.googlecompat.category.SmileysAndPeopleCategory +import com.vanniktech.emoji.googlecompat.category.SymbolsCategory +import com.vanniktech.emoji.googlecompat.category.TravelAndPlacesCategory + +class GoogleCompatEmojiProvider : EmojiProvider { + override val categories: Array + get() = arrayOf( + SmileysAndPeopleCategory(), + AnimalsAndNatureCategory(), + FoodAndDrinkCategory(), + ActivitiesCategory(), + TravelAndPlacesCategory(), + ObjectsCategory(), + SymbolsCategory(), + FlagsCategory(), + ) + + override fun release() = Unit +} diff --git a/emoji-google/build.gradle b/emoji-google/build.gradle index 0ac28332bb..e51b1a0e00 100644 --- a/emoji-google/build.gradle +++ b/emoji-google/build.gradle @@ -10,17 +10,27 @@ plugins { metalava { filename = "api/current.txt" - sourcePaths = ["src/commonMain", "src/androidMain", "src/jvmMain"] + sourcePaths = ["src/commonMain", "src/androidMain", "src/jvmMain", "src/iosMain"] } -// CocoaPods requires a version. -version = VERSION_NAME - kotlin { android("android") -// ios("ios") + ios("ios") jvm("jvm") + cocoapods { + version = VERSION_NAME + summary = "emoji-google" + homepage = "https://github.com/vanniktech/Emoji" + name = "EmojiGoogle" + +// framework { +// isStatic = true +// embedBitcode(BITCODE) +// export(project(":emoji")) +// } + } + sourceSets { commonMain { dependencies { @@ -43,6 +53,12 @@ kotlin { implementation libs.robolectric } + iosMain.dependencies { + } + + iosTest.dependencies { + } + jvmMain.dependencies { } diff --git a/emoji-google/src/iosMain/kotlin/com/vanniktech/emoji/google/GoogleEmojiProvider.kt b/emoji-google/src/iosMain/kotlin/com/vanniktech/emoji/google/GoogleEmojiProvider.kt new file mode 100644 index 0000000000..c1f720da84 --- /dev/null +++ b/emoji-google/src/iosMain/kotlin/com/vanniktech/emoji/google/GoogleEmojiProvider.kt @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2016 - Niklas Baudy, Ruben Gees, Mario Đanić and contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.vanniktech.emoji.google + +import com.vanniktech.emoji.EmojiCategory +import com.vanniktech.emoji.EmojiProvider +import com.vanniktech.emoji.google.category.ActivitiesCategory +import com.vanniktech.emoji.google.category.AnimalsAndNatureCategory +import com.vanniktech.emoji.google.category.FlagsCategory +import com.vanniktech.emoji.google.category.FoodAndDrinkCategory +import com.vanniktech.emoji.google.category.ObjectsCategory +import com.vanniktech.emoji.google.category.SmileysAndPeopleCategory +import com.vanniktech.emoji.google.category.SymbolsCategory +import com.vanniktech.emoji.google.category.TravelAndPlacesCategory + +class GoogleEmojiProvider : EmojiProvider { + override val categories: Array + get() = arrayOf( + SmileysAndPeopleCategory(), + AnimalsAndNatureCategory(), + FoodAndDrinkCategory(), + ActivitiesCategory(), + TravelAndPlacesCategory(), + ObjectsCategory(), + SymbolsCategory(), + FlagsCategory(), + ) + + override fun release() = Unit +} diff --git a/emoji-ios/build.gradle b/emoji-ios/build.gradle index bcde8a542b..9da65821d7 100644 --- a/emoji-ios/build.gradle +++ b/emoji-ios/build.gradle @@ -10,17 +10,27 @@ plugins { metalava { filename = "api/current.txt" - sourcePaths = ["src/commonMain", "src/androidMain", "src/jvmMain"] + sourcePaths = ["src/commonMain", "src/androidMain", "src/jvmMain", "src/iosMain"] } -// CocoaPods requires a version. -version = VERSION_NAME - kotlin { android("android") -// ios("ios") + ios("ios") jvm("jvm") + cocoapods { + version = VERSION_NAME + summary = "emoji-ios" + homepage = "https://github.com/vanniktech/Emoji" + name = "EmojiIos" + +// framework { +// isStatic = true +// embedBitcode(BITCODE) +// export(project(":emoji")) +// } + } + sourceSets { commonMain { dependencies { @@ -43,6 +53,12 @@ kotlin { implementation libs.robolectric } + iosMain.dependencies { + } + + iosTest.dependencies { + } + jvmMain.dependencies { } diff --git a/emoji-ios/src/iosMain/kotlin/com/vanniktech/emoji/ios/IosEmojiProvider.kt b/emoji-ios/src/iosMain/kotlin/com/vanniktech/emoji/ios/IosEmojiProvider.kt new file mode 100644 index 0000000000..75e8661374 --- /dev/null +++ b/emoji-ios/src/iosMain/kotlin/com/vanniktech/emoji/ios/IosEmojiProvider.kt @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2016 - Niklas Baudy, Ruben Gees, Mario Đanić and contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.vanniktech.emoji.ios + +import com.vanniktech.emoji.EmojiCategory +import com.vanniktech.emoji.EmojiProvider +import com.vanniktech.emoji.ios.category.ActivitiesCategory +import com.vanniktech.emoji.ios.category.AnimalsAndNatureCategory +import com.vanniktech.emoji.ios.category.FlagsCategory +import com.vanniktech.emoji.ios.category.FoodAndDrinkCategory +import com.vanniktech.emoji.ios.category.ObjectsCategory +import com.vanniktech.emoji.ios.category.SmileysAndPeopleCategory +import com.vanniktech.emoji.ios.category.SymbolsCategory +import com.vanniktech.emoji.ios.category.TravelAndPlacesCategory + +class IosEmojiProvider : EmojiProvider { + override val categories: Array + get() = arrayOf( + SmileysAndPeopleCategory(), + AnimalsAndNatureCategory(), + FoodAndDrinkCategory(), + ActivitiesCategory(), + TravelAndPlacesCategory(), + ObjectsCategory(), + SymbolsCategory(), + FlagsCategory(), + ) + + override fun release() = Unit +} diff --git a/emoji-material/build.gradle b/emoji-material/build.gradle index d50770bfe8..2270bf35e9 100644 --- a/emoji-material/build.gradle +++ b/emoji-material/build.gradle @@ -13,14 +13,24 @@ metalava { sourcePaths = ["src/androidMain"] } -// CocoaPods requires a version. -version = VERSION_NAME - kotlin { android("android") -// ios("ios") + ios("ios") jvm("jvm") + cocoapods { + version = VERSION_NAME + summary = "emoji-material" + homepage = "https://github.com/vanniktech/Emoji" + name = "EmojiMaterial" + +// framework { +// isStatic = true +// embedBitcode(BITCODE) +// export(project(":emoji")) +// } + } + sourceSets { commonMain { dependencies { @@ -44,6 +54,12 @@ kotlin { implementation libs.robolectric } + iosMain.dependencies { + } + + iosTest.dependencies { + } + jvmMain.dependencies { } diff --git a/emoji-twitter/build.gradle b/emoji-twitter/build.gradle index 6529e74509..1143240d97 100644 --- a/emoji-twitter/build.gradle +++ b/emoji-twitter/build.gradle @@ -10,17 +10,27 @@ plugins { metalava { filename = "api/current.txt" - sourcePaths = ["src/commonMain", "src/androidMain", "src/jvmMain"] + sourcePaths = ["src/commonMain", "src/androidMain", "src/jvmMain", "src/iosMain"] } -// CocoaPods requires a version. -version = VERSION_NAME - kotlin { android("android") -// ios("ios") + ios("ios") jvm("jvm") + cocoapods { + version = VERSION_NAME + summary = "emoji-twitter" + homepage = "https://github.com/vanniktech/Emoji" + name = "EmojiTwitter" + +// framework { +// isStatic = true +// embedBitcode(BITCODE) +// export(project(":emoji")) +// } + } + sourceSets { commonMain { dependencies { @@ -43,6 +53,12 @@ kotlin { implementation libs.robolectric } + iosMain.dependencies { + } + + iosTest.dependencies { + } + jvmMain.dependencies { } diff --git a/emoji-twitter/src/iosMain/kotlin/com/vanniktech/emoji/twitter/TwitterEmojiProvider.kt b/emoji-twitter/src/iosMain/kotlin/com/vanniktech/emoji/twitter/TwitterEmojiProvider.kt new file mode 100644 index 0000000000..bbb0f83bc1 --- /dev/null +++ b/emoji-twitter/src/iosMain/kotlin/com/vanniktech/emoji/twitter/TwitterEmojiProvider.kt @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2016 - Niklas Baudy, Ruben Gees, Mario Đanić and contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.vanniktech.emoji.twitter + +import com.vanniktech.emoji.EmojiCategory +import com.vanniktech.emoji.EmojiProvider +import com.vanniktech.emoji.twitter.category.ActivitiesCategory +import com.vanniktech.emoji.twitter.category.AnimalsAndNatureCategory +import com.vanniktech.emoji.twitter.category.FlagsCategory +import com.vanniktech.emoji.twitter.category.FoodAndDrinkCategory +import com.vanniktech.emoji.twitter.category.ObjectsCategory +import com.vanniktech.emoji.twitter.category.SmileysAndPeopleCategory +import com.vanniktech.emoji.twitter.category.SymbolsCategory +import com.vanniktech.emoji.twitter.category.TravelAndPlacesCategory + +class TwitterEmojiProvider : EmojiProvider { + override val categories: Array + get() = arrayOf( + SmileysAndPeopleCategory(), + AnimalsAndNatureCategory(), + FoodAndDrinkCategory(), + ActivitiesCategory(), + TravelAndPlacesCategory(), + ObjectsCategory(), + SymbolsCategory(), + FlagsCategory(), + ) + + override fun release() = Unit +} diff --git a/emoji/build.gradle b/emoji/build.gradle index b39f46f265..b16759c5f8 100644 --- a/emoji/build.gradle +++ b/emoji/build.gradle @@ -13,14 +13,23 @@ metalava { sourcePaths = ["src/commonMain", "src/androidMain"] } -// CocoaPods requires a version. -version = VERSION_NAME - kotlin { android("android") -// ios("ios") + ios("ios") jvm("jvm") + cocoapods { + version = VERSION_NAME + summary = "emoji" + homepage = "https://github.com/vanniktech/Emoji" + name = "Emoji" + + // framework { + // isStatic = true + // embedBitcode(BITCODE) + // } + } + sourceSets { all { languageSettings { @@ -28,31 +37,29 @@ kotlin { } } - commonMain { - dependencies { - } + commonMain.dependencies { } - commonTest { - dependencies { - implementation libs.kotlin.test.common - implementation libs.kotlin.test.commonAnnotations - } + commonTest.dependencies { + implementation libs.kotlin.test.common + implementation libs.kotlin.test.commonAnnotations } - androidMain { - dependencies { - api libs.androidx.appcompat - api libs.androidx.cardview - api libs.androidx.recyclerview - } + androidMain.dependencies { + api libs.androidx.appcompat + api libs.androidx.cardview + api libs.androidx.recyclerview } - androidTest { - dependencies { - implementation libs.kotlin.test.junit - implementation libs.robolectric - } + androidTest.dependencies { + implementation libs.kotlin.test.junit + implementation libs.robolectric + } + + iosMain.dependencies { + } + + iosTest.dependencies { } jvmMain.dependencies { diff --git a/emoji/src/androidMain/kotlin/com/vanniktech/emoji/commonJvmAndroidApi.kt b/emoji/src/androidMain/kotlin/com/vanniktech/emoji/commonJvmAndroidApi.kt new file mode 100644 index 0000000000..ccd73af6f4 --- /dev/null +++ b/emoji/src/androidMain/kotlin/com/vanniktech/emoji/commonJvmAndroidApi.kt @@ -0,0 +1,5 @@ +package com.vanniktech.emoji + +actual typealias JvmField = kotlin.jvm.JvmField +actual typealias JvmName = kotlin.jvm.JvmName +actual typealias JvmStatic = kotlin.jvm.JvmStatic diff --git a/emoji/src/androidMain/kotlin/com/vanniktech/emoji/commonLockAndroidApi.kt b/emoji/src/androidMain/kotlin/com/vanniktech/emoji/commonLockAndroidApi.kt new file mode 100644 index 0000000000..1c7beb9027 --- /dev/null +++ b/emoji/src/androidMain/kotlin/com/vanniktech/emoji/commonLockAndroidApi.kt @@ -0,0 +1,14 @@ +package com.vanniktech.emoji + +import java.util.concurrent.locks.ReentrantLock + +actual class Lock { + private val mutex = ReentrantLock() + + actual fun lock() { + mutex.lock() + } + actual fun unlock() { + mutex.unlock() + } +} diff --git a/emoji/src/commonMain/kotlin/com/vanniktech/emoji/EmojiManager.kt b/emoji/src/commonMain/kotlin/com/vanniktech/emoji/EmojiManager.kt index 3089988ba8..65e34f466b 100644 --- a/emoji/src/commonMain/kotlin/com/vanniktech/emoji/EmojiManager.kt +++ b/emoji/src/commonMain/kotlin/com/vanniktech/emoji/EmojiManager.kt @@ -29,6 +29,8 @@ object EmojiManager { private var emojiPattern: Regex? = null internal var emojiRepetitivePattern: Regex? = null + private val LOCK = Lock() + internal fun categories(): Array { verifyInstalled() return categories!! @@ -81,7 +83,7 @@ object EmojiManager { * [provider] the provider that should be installed. */ @JvmStatic fun install(provider: EmojiProvider) { - synchronized(EmojiManager::class.java) { + LOCK.use { categories = provider.categories emojiProvider = provider emojiMap.clear() @@ -114,7 +116,7 @@ object EmojiManager { for (i in 0 until unicodesForPatternSize) { patternBuilder.append(Regex.escape(unicodesForPattern[i])).append('|') } - val regex = patternBuilder.deleteCharAt(patternBuilder.length - 1).toString() + val regex = patternBuilder.deleteAt(patternBuilder.length - 1).toString() emojiPattern = Regex(regex, RegexOption.IGNORE_CASE) emojiRepetitivePattern = Regex("($regex)+", RegexOption.IGNORE_CASE) } @@ -128,7 +130,7 @@ object EmojiManager { * @see .destroy */ @JvmStatic fun destroy() { - synchronized(EmojiManager::class.java) { + LOCK.use { release() emojiMap.clear() emojiProvider = null @@ -148,7 +150,7 @@ object EmojiManager { * @see .destroy */ @JvmStatic fun release() { - synchronized(EmojiManager::class.java) { + LOCK.use { emojiProvider?.release() } } diff --git a/emoji/src/commonMain/kotlin/com/vanniktech/emoji/commonJvmApi.kt b/emoji/src/commonMain/kotlin/com/vanniktech/emoji/commonJvmApi.kt new file mode 100644 index 0000000000..11637f9d18 --- /dev/null +++ b/emoji/src/commonMain/kotlin/com/vanniktech/emoji/commonJvmApi.kt @@ -0,0 +1,19 @@ +package com.vanniktech.emoji + +@OptIn(ExperimentalMultiplatform::class) +@OptionalExpectation +@Target(AnnotationTarget.FIELD) +@Retention(AnnotationRetention.BINARY) +expect annotation class JvmField() + +@OptIn(ExperimentalMultiplatform::class) +@OptionalExpectation +@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.FILE) +@Retention(AnnotationRetention.BINARY) +expect annotation class JvmName(val name: String) + +@OptIn(ExperimentalMultiplatform::class) +@OptionalExpectation +@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER) +@Retention(AnnotationRetention.RUNTIME) +expect annotation class JvmStatic() diff --git a/emoji/src/commonMain/kotlin/com/vanniktech/emoji/commonLockApi.kt b/emoji/src/commonMain/kotlin/com/vanniktech/emoji/commonLockApi.kt new file mode 100644 index 0000000000..e72639ac07 --- /dev/null +++ b/emoji/src/commonMain/kotlin/com/vanniktech/emoji/commonLockApi.kt @@ -0,0 +1,15 @@ +package com.vanniktech.emoji + +expect class Lock() { + fun lock() + fun unlock() +} + +internal inline fun Lock.use(block: () -> R): R { + try { + lock() + return block() + } finally { + unlock() + } +} diff --git a/emoji/src/commonMain/kotlin/com/vanniktech/emoji/search/SearchEmojiResult.kt b/emoji/src/commonMain/kotlin/com/vanniktech/emoji/search/SearchEmojiResult.kt index f1405f68a9..23163ea09e 100644 --- a/emoji/src/commonMain/kotlin/com/vanniktech/emoji/search/SearchEmojiResult.kt +++ b/emoji/src/commonMain/kotlin/com/vanniktech/emoji/search/SearchEmojiResult.kt @@ -17,6 +17,7 @@ package com.vanniktech.emoji.search import com.vanniktech.emoji.Emoji +import com.vanniktech.emoji.JvmField data class SearchEmojiResult( @JvmField val emoji: Emoji, diff --git a/emoji/src/iosMain/kotlin/com/vanniktech/emoji/commonLockIosApi.kt b/emoji/src/iosMain/kotlin/com/vanniktech/emoji/commonLockIosApi.kt new file mode 100644 index 0000000000..eb5effe9b4 --- /dev/null +++ b/emoji/src/iosMain/kotlin/com/vanniktech/emoji/commonLockIosApi.kt @@ -0,0 +1,13 @@ +package com.vanniktech.emoji + +// TODO(nik) +actual class Lock { + init { + } + + actual fun lock() { + } + + actual fun unlock() { + } +} diff --git a/emoji/src/iosMain/kotlin/com/vanniktech/emoji/commonParcelableIosApi.kt b/emoji/src/iosMain/kotlin/com/vanniktech/emoji/commonParcelableIosApi.kt new file mode 100644 index 0000000000..8e831cd7f5 --- /dev/null +++ b/emoji/src/iosMain/kotlin/com/vanniktech/emoji/commonParcelableIosApi.kt @@ -0,0 +1,4 @@ +// ktlint-disable filename +package com.vanniktech.emoji + +actual interface Parcelable diff --git a/emoji/src/jvmMain/kotlin/com/vanniktech/emoji/commonJvmJvmApi.kt b/emoji/src/jvmMain/kotlin/com/vanniktech/emoji/commonJvmJvmApi.kt new file mode 100644 index 0000000000..ccd73af6f4 --- /dev/null +++ b/emoji/src/jvmMain/kotlin/com/vanniktech/emoji/commonJvmJvmApi.kt @@ -0,0 +1,5 @@ +package com.vanniktech.emoji + +actual typealias JvmField = kotlin.jvm.JvmField +actual typealias JvmName = kotlin.jvm.JvmName +actual typealias JvmStatic = kotlin.jvm.JvmStatic diff --git a/emoji/src/jvmMain/kotlin/com/vanniktech/emoji/commonLockJvmApi.kt b/emoji/src/jvmMain/kotlin/com/vanniktech/emoji/commonLockJvmApi.kt new file mode 100644 index 0000000000..1c7beb9027 --- /dev/null +++ b/emoji/src/jvmMain/kotlin/com/vanniktech/emoji/commonLockJvmApi.kt @@ -0,0 +1,14 @@ +package com.vanniktech.emoji + +import java.util.concurrent.locks.ReentrantLock + +actual class Lock { + private val mutex = ReentrantLock() + + actual fun lock() { + mutex.lock() + } + actual fun unlock() { + mutex.unlock() + } +} diff --git a/generator/index.js b/generator/index.js index 18e1be978f..caff0ecabf 100644 --- a/generator/index.js +++ b/generator/index.js @@ -375,7 +375,7 @@ async function copyImages(map, targets, shouldOptimize) { } /** - * Generates the relevant java code and saves it to the destinations, specified by the targets. Code generated are the + * Generates the relevant code and saves it to the destinations, specified by the targets. Code generated are the * categories, the provider and the specific emoji class. * @param map The previously created map. * @param targets The targets, providing destination for the code files. @@ -391,24 +391,27 @@ async function generateCode(map, targets) { const emojiProviderAndroid = await fs.readFile("template/EmojiProviderAndroid.kt", "utf-8"); const emojiProviderCompatTemplate = await fs.readFile("template/EmojiProviderCompat.kt", "utf-8"); const emojiProviderJvm = await fs.readFile("template/EmojiProviderJvm.kt", "utf-8"); + const emojiProviderIos = await fs.readFile("template/EmojiProviderIos.kt", "utf-8"); const entries = stable([...map.entries()], (first, second) => { return categoryInfo.findIndex(it => it.name === first[0]) - categoryInfo.findIndex(it => it.name === second[0]); }); for (const target of targets) { - const srcDir = `../emoji-${target.module}/src/androidMain/kotlin/com/vanniktech/emoji/${target.package}`; - const commonSrcDir = `../emoji-${target.module}/src/commonMain/kotlin/com/vanniktech/emoji/${target.package}`; - const jvmSrcDir = `../emoji-${target.module}/src/jvmMain/kotlin/com/vanniktech/emoji/${target.package}`; + const androidMain = `../emoji-${target.module}/src/androidMain/kotlin/com/vanniktech/emoji/${target.package}`; + const commonMain = `../emoji-${target.module}/src/commonMain/kotlin/com/vanniktech/emoji/${target.package}`; + const jvmMain = `../emoji-${target.module}/src/jvmMain/kotlin/com/vanniktech/emoji/${target.package}`; + const iosMain = `../emoji-${target.module}/src/iosMain/kotlin/com/vanniktech/emoji/${target.package}`; if (target.module !== "google-compat") { - await fs.emptyDir(commonSrcDir); - await fs.mkdir(`${commonSrcDir}/category`); + await fs.emptyDir(commonMain); + await fs.mkdir(`${commonMain}/category`); } else { - await fs.emptyDir(`${commonSrcDir}/category`) + await fs.emptyDir(`${commonMain}/category`) } - await fs.emptyDir(jvmSrcDir); + await fs.emptyDir(jvmMain); + await fs.emptyDir(iosMain); let strips = 0; for (const [category, emojis] of entries) { @@ -423,7 +426,7 @@ async function generateCode(map, targets) { chunkClasses.push(chunkClass) - await fs.writeFile(`${commonSrcDir}/category/${chunkClass}.kt`, + await fs.writeFile(`${commonMain}/category/${chunkClass}.kt`, template(categoryChunkTemplate)({ package: target.package, name: target.name, @@ -434,7 +437,7 @@ async function generateCode(map, targets) { ); } - await fs.writeFile(`${commonSrcDir}/category/${category}Category.kt`, + await fs.writeFile(`${commonMain}/category/${category}Category.kt`, template(categoryTemplate)({ package: target.package, name: target.name, @@ -456,7 +459,7 @@ async function generateCode(map, targets) { }) if (target.module !== "google-compat") { - await fs.writeFile(`${srcDir}/${target.name}Provider.kt`, template(emojiProviderAndroid)({ + await fs.writeFile(`${androidMain}/${target.name}Provider.kt`, template(emojiProviderAndroid)({ package: target.package, imports: imports, name: target.name, @@ -464,7 +467,7 @@ async function generateCode(map, targets) { strips: strips, })); } else { - await fs.writeFile(`${srcDir}/${target.name}Provider.kt`, template(emojiProviderCompatTemplate)({ + await fs.writeFile(`${androidMain}/${target.name}Provider.kt`, template(emojiProviderCompatTemplate)({ package: target.package, imports: imports, name: target.name, @@ -472,7 +475,14 @@ async function generateCode(map, targets) { })); } - await fs.writeFile(`${jvmSrcDir}/${target.name}Provider.kt`, template(emojiProviderJvm)({ + await fs.writeFile(`${jvmMain}/${target.name}Provider.kt`, template(emojiProviderJvm)({ + package: target.package, + imports: imports, + name: target.name, + categories: categories, + })); + + await fs.writeFile(`${iosMain}/${target.name}Provider.kt`, template(emojiProviderIos)({ package: target.package, imports: imports, name: target.name, @@ -480,12 +490,12 @@ async function generateCode(map, targets) { })); if (target.module !== "google-compat") { - await fs.writeFile(`${commonSrcDir}/${target.name}.kt`, template(emojiTemplate)({ + await fs.writeFile(`${commonMain}/${target.name}.kt`, template(emojiTemplate)({ package: target.package, name: target.name, })); } else { - await fs.writeFile(`${commonSrcDir}/${target.name}.kt`, template(emojiCompatTemplate)({ + await fs.writeFile(`${commonMain}/${target.name}.kt`, template(emojiCompatTemplate)({ package: target.package, name: target.name, })); diff --git a/generator/template/EmojiProviderIos.kt b/generator/template/EmojiProviderIos.kt new file mode 100644 index 0000000000..f0b8a53c6f --- /dev/null +++ b/generator/template/EmojiProviderIos.kt @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2016 - Niklas Baudy, Ruben Gees, Mario Đanić and contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.vanniktech.emoji.<%= package %> + +import com.vanniktech.emoji.EmojiCategory +import com.vanniktech.emoji.EmojiProvider +<%= imports %> + +class <%= name %>Provider : EmojiProvider { + override val categories: Array + get() = arrayOf(<% categories.forEach(function(category) { %> + <%= category.name %>(),<% }); %> + ) + + override fun release() = Unit +} diff --git a/gradle.properties b/gradle.properties index 29f6ac4df9..a6e04762e7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -29,4 +29,5 @@ android.defaults.buildfeatures.renderscript=false android.defaults.buildfeatures.resvalues=false android.defaults.buildfeatures.shaders=false -kotlin.mpp.stability.nowarn=true \ No newline at end of file +kotlin.mpp.stability.nowarn=true +kotlin.native.ignoreDisabledTargets=true