-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for MLKit Vision Barcode API
Also improve Play Services Vision Barcode API
- Loading branch information
Showing
32 changed files
with
1,424 additions
and
284 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 microG Project Team | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
apply plugin: 'com.android.library' | ||
apply plugin: 'maven-publish' | ||
apply plugin: 'signing' | ||
|
||
android { | ||
namespace "com.google.mlkit.vision.barcode" | ||
|
||
compileSdkVersion androidCompileSdk | ||
buildToolsVersion "$androidBuildVersionTools" | ||
|
||
buildFeatures { | ||
aidl = true | ||
} | ||
|
||
defaultConfig { | ||
versionName version | ||
minSdkVersion androidMinSdk | ||
targetSdkVersion androidTargetSdk | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility = 1.8 | ||
targetCompatibility = 1.8 | ||
} | ||
} | ||
|
||
apply from: '../../gradle/publish-android.gradle' | ||
|
||
description = 'microG implementation of play-services-mlkit-barcode-scanning' | ||
|
||
dependencies { | ||
// Dependencies from play-services-mlkit-barcode-scanning:18.3.0 | ||
//api "com.google.android.datatransport:transport-api:2.2.1" | ||
//api "com.google.android.datatransport:transport-backend-cct:2.3.3" | ||
//api "com.google.android.datatransport:transport-runtime:2.2.6" | ||
api project(':play-services-base') | ||
api project(':play-services-basement') | ||
api project(':play-services-tasks') | ||
//api "com.google.android.odml:image:1.0.0-beta1" | ||
//api "com.google.firebase:firebase-components:16.1.0" | ||
//api "com.google.firebase:firebase-encoders:16.1.0" | ||
//api "com.google.firebase:firebase-encoders-json:17.1.0" | ||
//api "com.google.mlkit:barcode-scanning-common:17.0.0" | ||
//api "com.google.mlkit:common:18.9.0" | ||
//api "com.google.mlkit:vision-common:17.3.0" | ||
//api "com.google.mlkit:vision-interfaces:16.2.0" | ||
|
||
annotationProcessor project(":safe-parcel-processor") | ||
} |
9 changes: 9 additions & 0 deletions
9
play-services-mlkit/barcode-scanning/src/main/AndroidManifest.xml
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,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
~ SPDX-FileCopyrightText: 2023 microG Project Team | ||
~ SPDX-License-Identifier: Apache-2.0 | ||
--> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<application /> | ||
</manifest> |
11 changes: 11 additions & 0 deletions
11
...barcode-scanning/src/main/aidl/com/google/mlkit/vision/barcode/aidls/IBarcodeScanner.aidl
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,11 @@ | ||
package com.google.mlkit.vision.barcode.aidls; | ||
|
||
import com.google.android.gms.dynamic.IObjectWrapper; | ||
import com.google.mlkit.vision.barcode.internal.Barcode; | ||
import com.google.mlkit.vision.barcode.internal.ImageMetadata; | ||
|
||
interface IBarcodeScanner { | ||
void init() = 0; | ||
void close() = 1; | ||
List<Barcode> detect(IObjectWrapper image, in ImageMetadata metadata) = 2; | ||
} |
9 changes: 9 additions & 0 deletions
9
...-scanning/src/main/aidl/com/google/mlkit/vision/barcode/aidls/IBarcodeScannerCreator.aidl
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,9 @@ | ||
package com.google.mlkit.vision.barcode.aidls; | ||
|
||
import com.google.android.gms.dynamic.IObjectWrapper; | ||
import com.google.mlkit.vision.barcode.aidls.IBarcodeScanner; | ||
import com.google.mlkit.vision.barcode.internal.BarcodeScannerOptions; | ||
|
||
interface IBarcodeScannerCreator { | ||
IBarcodeScanner create(IObjectWrapper wrappedContext, in BarcodeScannerOptions options) = 0; | ||
} |
3 changes: 3 additions & 0 deletions
3
...lkit/barcode-scanning/src/main/aidl/com/google/mlkit/vision/barcode/internal/Barcode.aidl
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,3 @@ | ||
package com.google.mlkit.vision.barcode.internal; | ||
|
||
parcelable Barcode; |
3 changes: 3 additions & 0 deletions
3
...canning/src/main/aidl/com/google/mlkit/vision/barcode/internal/BarcodeScannerOptions.aidl
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,3 @@ | ||
package com.google.mlkit.vision.barcode.internal; | ||
|
||
parcelable BarcodeScannerOptions; |
3 changes: 3 additions & 0 deletions
3
...arcode-scanning/src/main/aidl/com/google/mlkit/vision/barcode/internal/ImageMetadata.aidl
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,3 @@ | ||
package com.google.mlkit.vision.barcode.internal; | ||
|
||
parcelable ImageMetadata; |
32 changes: 32 additions & 0 deletions
32
...lkit/barcode-scanning/src/main/java/com/google/mlkit/vision/barcode/internal/Address.java
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,32 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 microG Project Team | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.google.mlkit.vision.barcode.internal; | ||
|
||
import android.os.Parcel; | ||
import androidx.annotation.NonNull; | ||
import com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable; | ||
import com.google.android.gms.common.internal.safeparcel.SafeParcelable; | ||
import com.google.android.gms.common.internal.safeparcel.SafeParcelableCreatorAndWriter; | ||
|
||
@SafeParcelable.Class | ||
public class Address extends AbstractSafeParcelable { | ||
@Field(1) | ||
public int type; | ||
@Field(2) | ||
public String[] addressLines; | ||
|
||
// TODO: Copied from com.google.mlkit.vision.barcode.common.Barcode.Address | ||
public static final int UNKNOWN = 0; | ||
public static final int WORK = 1; | ||
public static final int HOME = 2; | ||
|
||
@Override | ||
public void writeToParcel(@NonNull Parcel dest, int flags) { | ||
CREATOR.writeToParcel(this, dest, flags); | ||
} | ||
|
||
public static final SafeParcelableCreatorAndWriter<Address> CREATOR = findCreator(Address.class); | ||
} |
85 changes: 85 additions & 0 deletions
85
...lkit/barcode-scanning/src/main/java/com/google/mlkit/vision/barcode/internal/Barcode.java
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,85 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 microG Project Team | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.google.mlkit.vision.barcode.internal; | ||
|
||
import android.graphics.Point; | ||
import android.os.Parcel; | ||
import androidx.annotation.NonNull; | ||
import com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable; | ||
import com.google.android.gms.common.internal.safeparcel.SafeParcelable; | ||
import com.google.android.gms.common.internal.safeparcel.SafeParcelableCreatorAndWriter; | ||
|
||
@SafeParcelable.Class | ||
public class Barcode extends AbstractSafeParcelable { | ||
@Field(1) | ||
public int format; | ||
@Field(2) | ||
public String displayValue; | ||
@Field(3) | ||
public String rawValue; | ||
@Field(4) | ||
public byte[] rawBytes; | ||
@Field(5) | ||
public Point[] cornerPoints; | ||
@Field(6) | ||
public int valueType; | ||
@Field(7) | ||
public Email email; | ||
@Field(8) | ||
public Phone phone; | ||
@Field(9) | ||
public Sms sms; | ||
@Field(10) | ||
public WiFi wifi; | ||
@Field(11) | ||
public UrlBookmark urlBookmark; | ||
@Field(12) | ||
public GeoPoint geoPoint; | ||
@Field(13) | ||
public CalendarEvent calendarEvent; | ||
@Field(14) | ||
public ContactInfo contactInfo; | ||
@Field(15) | ||
public DriverLicense driverLicense; | ||
|
||
// TODO: Copied from com.google.mlkit.vision.barcode.common.Barcode | ||
public static final int UNKNOWN_FORMAT = -1; | ||
public static final int ALL_FORMATS = 0; | ||
public static final int CODE_128 = 1; | ||
public static final int CODE_39 = 2; | ||
public static final int CODE_93 = 4; | ||
public static final int CODABAR = 8; | ||
public static final int DATA_MATRIX = 16; | ||
public static final int EAN_13 = 32; | ||
public static final int EAN_8 = 64; | ||
public static final int ITF = 128; | ||
public static final int QR_CODE = 256; | ||
public static final int UPC_A = 512; | ||
public static final int UPC_E = 1024; | ||
public static final int PDF417 = 2048; | ||
public static final int AZTEC = 4096; | ||
|
||
public static final int UNKNOWN_TYPE = 0; | ||
public static final int CONTACT_INFO = 1; | ||
public static final int EMAIL = 2; | ||
public static final int ISBN = 3; | ||
public static final int PHONE = 4; | ||
public static final int PRODUCT = 5; | ||
public static final int SMS = 6; | ||
public static final int TEXT = 7; | ||
public static final int URL = 8; | ||
public static final int WIFI = 9; | ||
public static final int GEO = 10; | ||
public static final int CALENDAR_EVENT = 11; | ||
public static final int DRIVER_LICENSE = 12; | ||
|
||
@Override | ||
public void writeToParcel(@NonNull Parcel dest, int flags) { | ||
CREATOR.writeToParcel(this, dest, flags); | ||
} | ||
|
||
public static final SafeParcelableCreatorAndWriter<Barcode> CREATOR = findCreator(Barcode.class); | ||
} |
27 changes: 27 additions & 0 deletions
27
...canning/src/main/java/com/google/mlkit/vision/barcode/internal/BarcodeScannerOptions.java
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,27 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 microG Project Team | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.google.mlkit.vision.barcode.internal; | ||
|
||
import android.os.Parcel; | ||
import androidx.annotation.NonNull; | ||
import com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable; | ||
import com.google.android.gms.common.internal.safeparcel.SafeParcelable; | ||
import com.google.android.gms.common.internal.safeparcel.SafeParcelableCreatorAndWriter; | ||
|
||
@SafeParcelable.Class | ||
public class BarcodeScannerOptions extends AbstractSafeParcelable { | ||
@Field(1) | ||
public int supportedFormats; | ||
@Field(2) | ||
public boolean allPotentialBarcodesEnabled; | ||
|
||
@Override | ||
public void writeToParcel(@NonNull Parcel dest, int flags) { | ||
CREATOR.writeToParcel(this, dest, flags); | ||
} | ||
|
||
public static final SafeParcelableCreatorAndWriter<BarcodeScannerOptions> CREATOR = findCreator(BarcodeScannerOptions.class); | ||
} |
41 changes: 41 additions & 0 deletions
41
...ode-scanning/src/main/java/com/google/mlkit/vision/barcode/internal/CalendarDateTime.java
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,41 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 microG Project Team | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.google.mlkit.vision.barcode.internal; | ||
|
||
import android.os.Parcel; | ||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
import com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable; | ||
import com.google.android.gms.common.internal.safeparcel.SafeParcelable; | ||
import com.google.android.gms.common.internal.safeparcel.SafeParcelableCreatorAndWriter; | ||
|
||
@SafeParcelable.Class | ||
public class CalendarDateTime extends AbstractSafeParcelable { | ||
@Field(1) | ||
public int year; | ||
@Field(2) | ||
public int month; | ||
@Field(3) | ||
public int day; | ||
@Field(4) | ||
public int hours; | ||
@Field(5) | ||
public int minutes; | ||
@Field(6) | ||
public int seconds; | ||
@Field(7) | ||
public boolean isUtc; | ||
@Field(8) | ||
@Nullable | ||
public String rawValue; | ||
|
||
@Override | ||
public void writeToParcel(@NonNull Parcel dest, int flags) { | ||
CREATOR.writeToParcel(this, dest, flags); | ||
} | ||
|
||
public static final SafeParcelableCreatorAndWriter<CalendarDateTime> CREATOR = findCreator(CalendarDateTime.class); | ||
} |
37 changes: 37 additions & 0 deletions
37
...arcode-scanning/src/main/java/com/google/mlkit/vision/barcode/internal/CalendarEvent.java
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,37 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 microG Project Team | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.google.mlkit.vision.barcode.internal; | ||
|
||
import android.os.Parcel; | ||
import androidx.annotation.NonNull; | ||
import com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable; | ||
import com.google.android.gms.common.internal.safeparcel.SafeParcelable; | ||
import com.google.android.gms.common.internal.safeparcel.SafeParcelableCreatorAndWriter; | ||
|
||
@SafeParcelable.Class | ||
public class CalendarEvent extends AbstractSafeParcelable { | ||
@Field(1) | ||
public String summary; | ||
@Field(2) | ||
public String description; | ||
@Field(3) | ||
public String location; | ||
@Field(4) | ||
public String organizer; | ||
@Field(5) | ||
public String status; | ||
@Field(6) | ||
public CalendarDateTime start; | ||
@Field(7) | ||
public CalendarDateTime end; | ||
|
||
@Override | ||
public void writeToParcel(@NonNull Parcel dest, int flags) { | ||
CREATOR.writeToParcel(this, dest, flags); | ||
} | ||
|
||
public static final SafeParcelableCreatorAndWriter<CalendarEvent> CREATOR = findCreator(CalendarEvent.class); | ||
} |
45 changes: 45 additions & 0 deletions
45
.../barcode-scanning/src/main/java/com/google/mlkit/vision/barcode/internal/ContactInfo.java
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,45 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 microG Project Team | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.google.mlkit.vision.barcode.internal; | ||
|
||
import android.os.Parcel; | ||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
import com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable; | ||
import com.google.android.gms.common.internal.safeparcel.SafeParcelable; | ||
import com.google.android.gms.common.internal.safeparcel.SafeParcelableCreatorAndWriter; | ||
|
||
@SafeParcelable.Class | ||
public class ContactInfo extends AbstractSafeParcelable { | ||
@Field(1) | ||
@Nullable | ||
public PersonName name; | ||
@Field(2) | ||
@Nullable | ||
public String organization; | ||
@Field(3) | ||
@Nullable | ||
public String title; | ||
@Field(4) | ||
@Nullable | ||
public Phone[] phones; | ||
@Field(5) | ||
@Nullable | ||
public Email[] emails; | ||
@Field(6) | ||
@Nullable | ||
public String[] urls; | ||
@Field(7) | ||
@Nullable | ||
public Address[] addresses; | ||
|
||
@Override | ||
public void writeToParcel(@NonNull Parcel dest, int flags) { | ||
CREATOR.writeToParcel(this, dest, flags); | ||
} | ||
|
||
public static final SafeParcelableCreatorAndWriter<ContactInfo> CREATOR = findCreator(ContactInfo.class); | ||
} |
Oops, something went wrong.