Kotlin Multiplatform port of MichaelRocks/libphonenumber-android
Ported to Kotlin Multiplatform to be used in common code for Android and iOS, macOS, and web!
Check out the Compose Multiplatform sample
https://github.com/luca992/libphonenumber-kotlin/assets/4157455/e3fc61a3-e2bb-4993-a6c5-c04f713dcd54
While the sample apps run on all targets, this project is experimental and is a work in progress. Only the JVM target has all tests passing, native and js have failing tests that need to be addressed.
TODO: Update the rest of the readme.
Google's libphonenumber is a great library but it has to major flaws when used on Android:
Class.getResourceAsStream()
method,
which is very slow on Android.The goal of this library is to fix these two issues.
Gradle:
repositories {
mavenCentral()
// For snapshots
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
}
dependencies {
implementation("io.github.luca992.libphonenumber-kotlin:libphonenumber:0.1.1")
}
If your project is obfuscated with DexGuard you may need to add the following line to the DexGuard configuration:
-keepresourcefiles assets/io/michaelrocks/libphonenumber/android/**
This library is not fully compatible with the original libphonenumber
.
libphonenumber
class is repackaged to
io.michaelrocks.libphonenumber.android
.PhoneNumberUtil
doesn't contain a getInstance()
method so you
have to create an instance of this class with one of
PhoneNumberUtil.createInstance()
methods and store it somewhere.PhoneNumberUtil
now has a createInstance(Context)
method, which
is a default way to obtain an instance of this class on Android.Copyright 2022 Michael Rozumyanskiy
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.