Skip to content

Commit

Permalink
fix android. cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
luca992 committed Dec 2, 2024
1 parent 111ebcd commit 5417669
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 32 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,4 @@ lint/tmp/
.DS_Store
.kotlin

# moko-resources-generated
moko-resources-generated.js
pack-library-resources-generated.js

18 changes: 2 additions & 16 deletions libphonenumber/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ kotlin {
}
val commonTest by getting {
dependencies {
// need to make a separate module to import the resources because moko resources doesn't commonTest
// resources yet: https://github.com/icerockdev/moko-resources/issues/193
// todo: move test resources to commonTest
implementation(project(":library-test-resources"))
implementation(kotlin("test"))
}
Expand Down Expand Up @@ -89,6 +88,7 @@ kotlin {

compose.resources {
publicResClass = true
generateResClass = always
}

android {
Expand Down Expand Up @@ -123,23 +123,9 @@ android {
}
}

// https://youtrack.jetbrains.com/issue/KT-46466
val dependsOnTasks = mutableListOf<String>()
tasks.withType<AbstractPublishToMaven>().configureEach {
dependsOnTasks.add(this.name.replace("publish", "sign").replaceAfter("Publication", ""))
dependsOn(dependsOnTasks)
}

plugins.withId("com.vanniktech.maven.publish") {
mavenPublishing {
publishToMavenCentral(SonatypeHost.S01)
signAllPublications()
}
}

//apply(from = "$rootDir/gradle/pack-library-test-resources.gradle.kts")

compose.resources {
publicResClass = true
generateResClass = always
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,21 @@
package io.michaelrocks.libphonenumber.kotlin.metadata.source;

import android.content.res.AssetManager
import dev.icerock.moko.resources.AssetResource
import io.github.luca992.libphonenumber_kotlin.libphonenumber.generated.resources.Res
import io.michaelrocks.libphonenumber.kotlin.MetadataLoader
import io.michaelrocks.libphonenumber.kotlin.io.InputStream
import io.michaelrocks.libphonenumber.kotlin.io.JavaInputStream
import kotlinx.coroutines.runBlocking
import okio.IOException

class AssetsMetadataLoader(private val assetManager: AssetManager) : MetadataLoader {
override fun loadMetadata(phoneMetadataResource: AssetResource): InputStream? {
override fun loadMetadata(phoneMetadataResource: String): InputStream? {
return try {
assetManager.open(phoneMetadataResource.path)
val path = Res.getUri(phoneMetadataResource).removePrefix("file:///android_asset/")
println(path)
JavaInputStream(assetManager.open(path))
} catch (exception: IOException) {
exception.printStackTrace()
null
} as InputStream?
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ interface MetadataLoader {
* Returns an input stream corresponding to the metadata to load. This method may be called
* concurrently so implementations must be thread-safe.
*
* @param phoneMetadataResource the moko resources AssetResource to load
* @param phoneMetadataResourceUri the path relative to the composeResources directory
* @return the input stream for the metadata file. The library will close this stream
* after it is done. Return null in case the metadata file could not be found
*/
Expand Down

0 comments on commit 5417669

Please sign in to comment.