Skip to content

Commit

Permalink
Merge branch 'release/1.5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
G00fY2 committed Jul 5, 2022
2 parents 80be5be + 6e8e12d commit a4b3e26
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 54 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ There are two different flavors available on `mavenCentral()`:

| Bundled | Unbundled |
| ----------------------------------- | ------------------------------------------------- |
| ML Kit model is bundled inside app (independent of Google Services) | ML Kit model will be automatically downloaded via Play Services (once while app install) |
| 2.3 MB app size increase per ABI (you should use App Bundle or ABI splitting) | 550 KB app size increase |
| V3 model is used (faster, more accurate) | currently V1 model will be downloaded
| ML Kit model is bundled inside app (independent of Google Services) | ML Kit model will be automatically downloaded via Play Services (once while installing/updating the app) |
| About 2.5 MB app size increase per ABI (you should use App Bundle or ABI splitting) | About 550 KB app size increase |
| V3 model is used (faster, more accurate) | Currently V1 model will be downloaded
```kotlin
// bundled:
implementation("io.github.g00fy2.quickie:quickie-bundled:1.4.2")
implementation("io.github.g00fy2.quickie:quickie-bundled:1.5.0")

// unbundled:
implementation("io.github.g00fy2.quickie:quickie-unbundled:1.4.2")
implementation("io.github.g00fy2.quickie:quickie-unbundled:1.5.0")
```

## Quick Start
Expand Down Expand Up @@ -58,7 +58,7 @@ The content type of the QR code detected by ML Kit is wrapped inside a subclass
Currently, supported subtypes are:
`Plain`, `Wifi`, `Url`, `Sms`, `GeoPoint`, `Email`, `Phone`, `ContactInfo`, `CalendarEvent`

See the ML Kit [Barcode documentation](https://developers.google.com/android/reference/com/google/mlkit/vision/barcode/Barcode#nested-class-summary) for further details.
See the ML Kit [Barcode documentation](https://developers.google.com/android/reference/com/google/mlkit/vision/barcode/common/Barcode#nested-class-summary) for further details.

### Customization
Use the `ScanCustomCode()` ActivityResultContract to create a configurable barcode scan. When launching the ActivityResultLauncher pass in a `ScannerConfig` object:
Expand Down
11 changes: 6 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.kotlin.androidGradle) apply false
alias(libs.plugins.kotlin.dokka) apply false
alias(libs.plugins.misc.detekt) apply false
alias(libs.plugins.misc.gradleVersions)
}
Expand All @@ -23,16 +24,16 @@ subprojects {
add("detektPlugins", rootProject.libs.misc.detektFormatting)
}
tasks.withType<Detekt>().configureEach {
jvmTarget = "1.8"
jvmTarget = "11"
}
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
allWarningsAsErrors = true
freeCompilerArgs = freeCompilerArgs + listOfNotNull(
"-progressive",
if (this@subprojects.name != "sample") "-Xexplicit-api=strict" else null,
"-Xexplicit-api=strict".takeIf { (this@subprojects.name != "sample") },
)
jvmTarget = "1.8"
jvmTarget = "11"
}
}
afterEvaluate {
Expand All @@ -44,8 +45,8 @@ subprojects {
targetSdk = libs.versions.androidconfig.targetSdk.get().toInt()
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ android.useAndroidX=true
# Use R8 in full mode instead of ProGuard compatibility mode.
android.enableR8.fullMode=true
# Set the build VMs heap size.
org.gradle.jvmargs=-Xmx2g -XX:+UseParallelGC
# Ensure important default jvmargs aren't overwritten. See https://github.com/gradle/gradle/issues/19750
org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC
# Enables namespacing of each library's R class so that its R class includes only the resources declared in the library
# itself and none from the library's dependencies
android.nonTransitiveRClass=true
19 changes: 9 additions & 10 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
[versions]
quickie = "1.4.2"
quickie = "1.5.0"

androidconfig-minSdk = "21"
androidconfig-compileSdk = "32"
androidconfig-targetSdk = "32"
androidconfig-buildTools = "32.0.0"

androidGradle = "7.2.0"
kotlin = "1.6.21"
androidGradle = "7.2.1"
kotlin = "1.7.0"

appcompat = "1.4.1"
appcompat = "1.4.2"

cameraX = "1.0.2"
cameraView = "1.0.0-alpha32"
cameraX = "1.1.0"

barcodeScanning = "17.0.2"
barcodeScanningGms = "18.0.0"

materialDesign = "1.6.0"
materialDesign = "1.6.1"

detekt = "1.20.0"
detekt = "1.21.0-RC2"
gradleVersions = "0.42.0"
dokka = "1.6.21"
dokka = "1.7.0"

junit = "5.8.2"

[libraries]
androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompat" }
androidx-camera = { module = "androidx.camera:camera-camera2", version.ref = "cameraX" }
androidx-cameraLifecycle = { module = "androidx.camera:camera-lifecycle", version.ref = "cameraX" }
androidx-cameraPreview = { module = "androidx.camera:camera-view", version.ref = "cameraView" }
androidx-cameraPreview = { module = "androidx.camera:camera-view", version.ref = "cameraX" }

mlkit-barcodeScanning = { module = "com.google.mlkit:barcode-scanning", version.ref = "barcodeScanning" }
mlkit-barcodeScanningGms = { module = "com.google.android.gms:play-services-mlkit-barcode-scanning", version.ref = "barcodeScanningGms" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,43 +18,43 @@ internal fun Barcode.toParcelableContentType(): Parcelable? {
return when (valueType) {
Barcode.TYPE_CONTACT_INFO -> {
ContactInfoParcelable(
addressParcelables = contactInfo?.addresses?.map { it.toParcelableAddress() } ?: emptyList(),
emailParcelables = contactInfo?.emails?.map { it.toParcelableEmail() } ?: emptyList(),
addressParcelables = contactInfo?.addresses?.map { it.toParcelableAddress() }.orEmpty(),
emailParcelables = contactInfo?.emails?.map { it.toParcelableEmail() }.orEmpty(),
nameParcelable = contactInfo?.name.toParcelablePersonName(),
organization = contactInfo?.organization ?: "",
phoneParcelables = contactInfo?.phones?.map { it.toParcelablePhone() } ?: emptyList(),
title = contactInfo?.title ?: "",
urls = contactInfo?.urls?.mapNotNull { it } ?: emptyList()
organization = contactInfo?.organization.orEmpty(),
phoneParcelables = contactInfo?.phones?.map { it.toParcelablePhone() }.orEmpty(),
title = contactInfo?.title.orEmpty(),
urls = contactInfo?.urls?.mapNotNull { it }.orEmpty()
)
}
Barcode.TYPE_EMAIL -> {
EmailParcelable(
address = email?.address ?: "",
body = email?.body ?: "",
subject = email?.subject ?: "",
address = email?.address.orEmpty(),
body = email?.body.orEmpty(),
subject = email?.subject.orEmpty(),
type = email?.type ?: 0
)
}
Barcode.TYPE_PHONE -> PhoneParcelable(number = phone?.number ?: "", type = phone?.type ?: 0)
Barcode.TYPE_SMS -> SmsParcelable(message = sms?.message ?: "", phoneNumber = sms?.phoneNumber ?: "")
Barcode.TYPE_URL -> UrlBookmarkParcelable(title = url?.title ?: "", url = url?.url ?: "")
Barcode.TYPE_PHONE -> PhoneParcelable(number = phone?.number.orEmpty(), type = phone?.type ?: 0)
Barcode.TYPE_SMS -> SmsParcelable(message = sms?.message.orEmpty(), phoneNumber = sms?.phoneNumber.orEmpty())
Barcode.TYPE_URL -> UrlBookmarkParcelable(title = url?.title.orEmpty(), url = url?.url.orEmpty())
Barcode.TYPE_WIFI -> {
WifiParcelable(
encryptionType = wifi?.encryptionType ?: 0,
password = wifi?.password ?: "",
ssid = wifi?.ssid ?: ""
password = wifi?.password.orEmpty(),
ssid = wifi?.ssid.orEmpty()
)
}
Barcode.TYPE_GEO -> GeoPointParcelable(lat = geoPoint?.lat ?: 0.0, lng = geoPoint?.lng ?: 0.0)
Barcode.TYPE_CALENDAR_EVENT -> {
CalendarEventParcelable(
description = calendarEvent?.description ?: "",
description = calendarEvent?.description.orEmpty(),
end = calendarEvent?.end.toParcelableCalendarEvent(),
location = calendarEvent?.location ?: "",
organizer = calendarEvent?.organizer ?: "",
location = calendarEvent?.location.orEmpty(),
organizer = calendarEvent?.organizer.orEmpty(),
start = calendarEvent?.start.toParcelableCalendarEvent(),
status = calendarEvent?.status ?: "",
summary = calendarEvent?.summary ?: ""
status = calendarEvent?.status.orEmpty(),
summary = calendarEvent?.summary.orEmpty()
)
}
else -> null // TYPE_TEXT, TYPE_ISBN, TYPE_PRODUCT, TYPE_DRIVER_LICENSE, TYPE_UNKNOWN
Expand All @@ -63,28 +63,29 @@ internal fun Barcode.toParcelableContentType(): Parcelable? {

private fun Barcode.Address?.toParcelableAddress() =
AddressParcelable(
addressLines = this?.addressLines?.toList()?.mapNotNull { it } ?: emptyList(),
addressLines = this?.addressLines?.toList()?.mapNotNull { it }.orEmpty(),
type = this?.type ?: 0
)

private fun Barcode.Phone?.toParcelablePhone() = PhoneParcelable(number = this?.number ?: "", type = this?.type ?: 0)
private fun Barcode.Phone?.toParcelablePhone() =
PhoneParcelable(number = this?.number.orEmpty(), type = this?.type ?: 0)

private fun Barcode.PersonName?.toParcelablePersonName() =
PersonNameParcelable(
first = this?.first ?: "",
formattedName = this?.formattedName ?: "",
last = this?.last ?: "",
middle = this?.middle ?: "",
prefix = this?.prefix ?: "",
pronunciation = this?.pronunciation ?: "",
suffix = this?.suffix ?: ""
first = this?.first.orEmpty(),
formattedName = this?.formattedName.orEmpty(),
last = this?.last.orEmpty(),
middle = this?.middle.orEmpty(),
prefix = this?.prefix.orEmpty(),
pronunciation = this?.pronunciation.orEmpty(),
suffix = this?.suffix.orEmpty()
)

private fun Barcode.Email?.toParcelableEmail() =
EmailParcelable(
address = this?.address ?: "",
body = this?.body ?: "",
subject = this?.subject ?: "",
address = this?.address.orEmpty(),
body = this?.body.orEmpty(),
subject = this?.subject.orEmpty(),
type = this?.type ?: 0
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import io.github.g00fy2.quickie.content.UrlBookmarkParcelable
import io.github.g00fy2.quickie.content.WifiParcelable

internal fun Intent?.toQuickieContentType(): QRContent {
val rawValue = this?.getStringExtra(QRScannerActivity.EXTRA_RESULT_VALUE) ?: ""
val rawValue = this?.getStringExtra(QRScannerActivity.EXTRA_RESULT_VALUE).orEmpty()
return this?.toQuickieContentType(rawValue) ?: Plain(rawValue)
}

Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ dependencyResolutionManagement {
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}

0 comments on commit a4b3e26

Please sign in to comment.