This repository has been archived by the owner on Mar 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
13 changed files
with
396 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
kbarcode/src/main/java/uk/co/brightec/kbarcode/model/Address.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package uk.co.brightec.kbarcode.model | ||
|
||
import androidx.annotation.IntDef | ||
import com.google.firebase.ml.vision.barcode.FirebaseVisionBarcode | ||
|
||
data class Address( | ||
val addressLines: List<String>, | ||
@AddressType | ||
val type: Int | ||
) { | ||
|
||
internal constructor(fbAddress: FirebaseVisionBarcode.Address) : this( | ||
addressLines = fbAddress.addressLines.toList(), | ||
type = fbAddress.type | ||
) | ||
|
||
companion object { | ||
|
||
const val TYPE_HOME = | ||
FirebaseVisionBarcode.Address.TYPE_HOME | ||
const val TYPE_UNKNOWN = | ||
FirebaseVisionBarcode.Address.TYPE_UNKNOWN | ||
const val TYPE_WORK = | ||
FirebaseVisionBarcode.Address.TYPE_WORK | ||
|
||
@IntDef( | ||
TYPE_HOME, | ||
TYPE_UNKNOWN, | ||
TYPE_WORK | ||
) | ||
@Retention(AnnotationRetention.SOURCE) | ||
annotation class AddressType | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
kbarcode/src/main/java/uk/co/brightec/kbarcode/model/CalendarDateTime.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package uk.co.brightec.kbarcode.model | ||
|
||
import com.google.firebase.ml.vision.barcode.FirebaseVisionBarcode | ||
|
||
data class CalendarDateTime( | ||
val day: Int, | ||
val hours: Int, | ||
val minutes: Int, | ||
val month: Int, | ||
val rawValue: String?, | ||
val seconds: Int, | ||
val year: Int, | ||
val isUtc: Boolean | ||
) { | ||
|
||
internal constructor(fbDateTime: FirebaseVisionBarcode.CalendarDateTime) : this( | ||
day = fbDateTime.day, | ||
hours = fbDateTime.hours, | ||
minutes = fbDateTime.minutes, | ||
month = fbDateTime.month, | ||
rawValue = fbDateTime.rawValue, | ||
seconds = fbDateTime.seconds, | ||
year = fbDateTime.year, | ||
isUtc = fbDateTime.isUtc | ||
) | ||
} | ||
|
||
internal fun FirebaseVisionBarcode.CalendarDateTime.convert() = CalendarDateTime(this) |
26 changes: 26 additions & 0 deletions
26
kbarcode/src/main/java/uk/co/brightec/kbarcode/model/CalendarEvent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package uk.co.brightec.kbarcode.model | ||
|
||
import com.google.firebase.ml.vision.barcode.FirebaseVisionBarcode | ||
|
||
data class CalendarEvent( | ||
val description: String?, | ||
val end: CalendarDateTime?, | ||
val location: String?, | ||
val organizer: String?, | ||
val start: CalendarDateTime?, | ||
val status: String?, | ||
val summary: String? | ||
) { | ||
|
||
internal constructor(fbEvent: FirebaseVisionBarcode.CalendarEvent) : this( | ||
description = fbEvent.description, | ||
end = fbEvent.end?.convert(), | ||
location = fbEvent.location, | ||
organizer = fbEvent.organizer, | ||
start = fbEvent.start?.convert(), | ||
status = fbEvent.status, | ||
summary = fbEvent.summary | ||
) | ||
} | ||
|
||
internal fun FirebaseVisionBarcode.CalendarEvent.convert() = CalendarEvent(this) |
26 changes: 26 additions & 0 deletions
26
kbarcode/src/main/java/uk/co/brightec/kbarcode/model/ContactInfo.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package uk.co.brightec.kbarcode.model | ||
|
||
import com.google.firebase.ml.vision.barcode.FirebaseVisionBarcode | ||
|
||
data class ContactInfo( | ||
val addresses: List<Address>, | ||
val emails: List<Email>, | ||
val name: PersonName?, | ||
val organization: String?, | ||
val phones: List<Phone>, | ||
val title: String?, | ||
val urls: List<String>? | ||
) { | ||
|
||
internal constructor(fbEvent: FirebaseVisionBarcode.ContactInfo) : this( | ||
addresses = fbEvent.addresses.map { Address(it) }, | ||
emails = fbEvent.emails.map { Email(it) }, | ||
name = fbEvent.name?.convert(), | ||
organization = fbEvent.organization, | ||
phones = fbEvent.phones.map { Phone(it) }, | ||
title = fbEvent.title, | ||
urls = fbEvent.urls?.toList() | ||
) | ||
} | ||
|
||
internal fun FirebaseVisionBarcode.ContactInfo.convert() = ContactInfo(this) |
40 changes: 40 additions & 0 deletions
40
kbarcode/src/main/java/uk/co/brightec/kbarcode/model/DrivingLicense.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package uk.co.brightec.kbarcode.model | ||
|
||
import com.google.firebase.ml.vision.barcode.FirebaseVisionBarcode | ||
|
||
data class DrivingLicense( | ||
val addressCity: String?, | ||
val addressState: String?, | ||
val addressStreet: String?, | ||
val addressZip: String?, | ||
val birthDate: String?, | ||
val documentType: String?, | ||
val expiryDate: String?, | ||
val firstName: String?, | ||
val gender: String?, | ||
val issueDate: String?, | ||
val issuingCountry: String?, | ||
val lastName: String?, | ||
val licenseNumber: String?, | ||
val middleName: String? | ||
) { | ||
|
||
internal constructor(fbDrivingLicense: FirebaseVisionBarcode.DriverLicense) : this( | ||
addressCity = fbDrivingLicense.addressCity, | ||
addressState = fbDrivingLicense.addressState, | ||
addressStreet = fbDrivingLicense.addressStreet, | ||
addressZip = fbDrivingLicense.addressZip, | ||
birthDate = fbDrivingLicense.birthDate, | ||
documentType = fbDrivingLicense.documentType, | ||
expiryDate = fbDrivingLicense.expiryDate, | ||
firstName = fbDrivingLicense.firstName, | ||
gender = fbDrivingLicense.gender, | ||
issueDate = fbDrivingLicense.issueDate, | ||
issuingCountry = fbDrivingLicense.issuingCountry, | ||
lastName = fbDrivingLicense.lastName, | ||
licenseNumber = fbDrivingLicense.licenseNumber, | ||
middleName = fbDrivingLicense.middleName | ||
) | ||
} | ||
|
||
internal fun FirebaseVisionBarcode.DriverLicense.convert() = DrivingLicense(this) |
40 changes: 40 additions & 0 deletions
40
kbarcode/src/main/java/uk/co/brightec/kbarcode/model/Email.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package uk.co.brightec.kbarcode.model | ||
|
||
import androidx.annotation.IntDef | ||
import com.google.firebase.ml.vision.barcode.FirebaseVisionBarcode | ||
|
||
data class Email( | ||
val address: String?, | ||
val body: String?, | ||
val subject: String?, | ||
@EmailType | ||
val type: Int | ||
) { | ||
|
||
internal constructor(fbEmail: FirebaseVisionBarcode.Email) : this( | ||
address = fbEmail.address, | ||
body = fbEmail.body, | ||
subject = fbEmail.subject, | ||
type = fbEmail.type | ||
) | ||
|
||
companion object { | ||
|
||
const val TYPE_HOME = | ||
FirebaseVisionBarcode.Email.TYPE_HOME | ||
const val TYPE_UNKNOWN = | ||
FirebaseVisionBarcode.Email.TYPE_UNKNOWN | ||
const val TYPE_WORK = | ||
FirebaseVisionBarcode.Email.TYPE_WORK | ||
|
||
@IntDef( | ||
TYPE_HOME, | ||
TYPE_UNKNOWN, | ||
TYPE_WORK | ||
) | ||
@Retention(AnnotationRetention.SOURCE) | ||
annotation class EmailType | ||
} | ||
} | ||
|
||
internal fun FirebaseVisionBarcode.Email.convert() = Email(this) |
16 changes: 16 additions & 0 deletions
16
kbarcode/src/main/java/uk/co/brightec/kbarcode/model/GeoPoint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package uk.co.brightec.kbarcode.model | ||
|
||
import com.google.firebase.ml.vision.barcode.FirebaseVisionBarcode | ||
|
||
data class GeoPoint( | ||
val lat: Double, | ||
val lng: Double | ||
) { | ||
|
||
internal constructor(fbGeoPoint: FirebaseVisionBarcode.GeoPoint) : this( | ||
lat = fbGeoPoint.lat, | ||
lng = fbGeoPoint.lng | ||
) | ||
} | ||
|
||
internal fun FirebaseVisionBarcode.GeoPoint.convert() = GeoPoint(this) |
26 changes: 26 additions & 0 deletions
26
kbarcode/src/main/java/uk/co/brightec/kbarcode/model/PersonName.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package uk.co.brightec.kbarcode.model | ||
|
||
import com.google.firebase.ml.vision.barcode.FirebaseVisionBarcode | ||
|
||
data class PersonName( | ||
val first: String?, | ||
val formattedName: String?, | ||
val last: String?, | ||
val middle: String?, | ||
val prefix: String?, | ||
val pronunciation: String?, | ||
val suffix: String? | ||
) { | ||
|
||
internal constructor(fbPersonName: FirebaseVisionBarcode.PersonName) : this( | ||
first = fbPersonName.first, | ||
formattedName = fbPersonName.formattedName, | ||
last = fbPersonName.last, | ||
middle = fbPersonName.middle, | ||
prefix = fbPersonName.prefix, | ||
pronunciation = fbPersonName.pronunciation, | ||
suffix = fbPersonName.suffix | ||
) | ||
} | ||
|
||
internal fun FirebaseVisionBarcode.PersonName.convert() = PersonName(this) |
42 changes: 42 additions & 0 deletions
42
kbarcode/src/main/java/uk/co/brightec/kbarcode/model/Phone.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package uk.co.brightec.kbarcode.model | ||
|
||
import androidx.annotation.IntDef | ||
import com.google.firebase.ml.vision.barcode.FirebaseVisionBarcode | ||
|
||
data class Phone( | ||
val number: String?, | ||
@PhoneType | ||
val type: Int | ||
) { | ||
|
||
internal constructor(fbPhone: FirebaseVisionBarcode.Phone) : this( | ||
number = fbPhone.number, | ||
type = fbPhone.type | ||
) | ||
|
||
companion object { | ||
|
||
const val TYPE_FAX = | ||
FirebaseVisionBarcode.Phone.TYPE_FAX | ||
const val TYPE_HOME = | ||
FirebaseVisionBarcode.Phone.TYPE_HOME | ||
const val TYPE_MOBILE = | ||
FirebaseVisionBarcode.Phone.TYPE_MOBILE | ||
const val TYPE_UNKNOWN = | ||
FirebaseVisionBarcode.Phone.TYPE_UNKNOWN | ||
const val TYPE_WORK = | ||
FirebaseVisionBarcode.Phone.TYPE_WORK | ||
|
||
@IntDef( | ||
TYPE_FAX, | ||
TYPE_HOME, | ||
TYPE_MOBILE, | ||
TYPE_UNKNOWN, | ||
TYPE_WORK | ||
) | ||
@Retention(AnnotationRetention.SOURCE) | ||
annotation class PhoneType | ||
} | ||
} | ||
|
||
internal fun FirebaseVisionBarcode.Phone.convert() = Phone(this) |
16 changes: 16 additions & 0 deletions
16
kbarcode/src/main/java/uk/co/brightec/kbarcode/model/Sms.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package uk.co.brightec.kbarcode.model | ||
|
||
import com.google.firebase.ml.vision.barcode.FirebaseVisionBarcode | ||
|
||
data class Sms( | ||
val message: String?, | ||
val phoneNumber: String? | ||
) { | ||
|
||
internal constructor(fbSms: FirebaseVisionBarcode.Sms) : this( | ||
message = fbSms.message, | ||
phoneNumber = fbSms.phoneNumber | ||
) | ||
} | ||
|
||
internal fun FirebaseVisionBarcode.Sms.convert() = Sms(this) |
Oops, something went wrong.