From e20849e5e185e4a6f8e56a86103e1b9f505bdb94 Mon Sep 17 00:00:00 2001 From: aviran Date: Sun, 16 Jun 2019 14:49:38 +0300 Subject: [PATCH] Android X migration for Barcode Reader sample --- visionSamples/barcode-reader/app/build.gradle | 19 ++++++++++--------- .../barcodereader/BarcodeCaptureActivity.java | 8 ++++---- .../barcodereader/BarcodeGraphicTracker.java | 2 +- .../barcodereader/ui/camera/CameraSource.java | 6 +++--- .../ui/camera/CameraSourcePreview.java | 2 +- visionSamples/barcode-reader/build.gradle | 4 +++- .../barcode-reader/gradle.properties | 4 +++- .../gradle/wrapper/gradle-wrapper.properties | 4 ++-- 8 files changed, 27 insertions(+), 22 deletions(-) diff --git a/visionSamples/barcode-reader/app/build.gradle b/visionSamples/barcode-reader/app/build.gradle index 68c19a1f..265923ff 100644 --- a/visionSamples/barcode-reader/app/build.gradle +++ b/visionSamples/barcode-reader/app/build.gradle @@ -1,13 +1,13 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 24 - buildToolsVersion "24.0.1" + compileSdkVersion 28 + buildToolsVersion "28.0.3" defaultConfig { applicationId "com.google.android.gms.samples.vision.barcodereader" - minSdkVersion 9 - targetSdkVersion 24 + minSdkVersion 15 + targetSdkVersion 28 versionCode 1 versionName "1.0" } @@ -19,10 +19,11 @@ android { } } + dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:support-v4:24.2.0' - // Important - the CameraSource implementation in this project requires version 8.1 or higher. - compile 'com.google.android.gms:play-services-vision:9.4.0+' - compile 'com.android.support:design:24.2.0' + implementation 'androidx.legacy:legacy-support-v4:1.0.0' + implementation 'com.google.android.gms:play-services-vision:17.0.2' + implementation 'androidx.appcompat:appcompat:1.0.2' + implementation 'com.google.android.material:material:1.0.0' + } diff --git a/visionSamples/barcode-reader/app/src/main/java/com/google/android/gms/samples/vision/barcodereader/BarcodeCaptureActivity.java b/visionSamples/barcode-reader/app/src/main/java/com/google/android/gms/samples/vision/barcodereader/BarcodeCaptureActivity.java index 663d7ff4..15dad73f 100644 --- a/visionSamples/barcode-reader/app/src/main/java/com/google/android/gms/samples/vision/barcodereader/BarcodeCaptureActivity.java +++ b/visionSamples/barcode-reader/app/src/main/java/com/google/android/gms/samples/vision/barcodereader/BarcodeCaptureActivity.java @@ -28,10 +28,9 @@ import android.hardware.Camera; import android.os.Build; import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.design.widget.Snackbar; -import android.support.v4.app.ActivityCompat; -import android.support.v7.app.AppCompatActivity; +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; +import androidx.core.app.ActivityCompat; import android.util.Log; import android.view.GestureDetector; import android.view.MotionEvent; @@ -49,6 +48,7 @@ import com.google.android.gms.vision.MultiProcessor; import com.google.android.gms.vision.barcode.Barcode; import com.google.android.gms.vision.barcode.BarcodeDetector; +import com.google.android.material.snackbar.Snackbar; import java.io.IOException; diff --git a/visionSamples/barcode-reader/app/src/main/java/com/google/android/gms/samples/vision/barcodereader/BarcodeGraphicTracker.java b/visionSamples/barcode-reader/app/src/main/java/com/google/android/gms/samples/vision/barcodereader/BarcodeGraphicTracker.java index 5c23399d..7ce5572d 100644 --- a/visionSamples/barcode-reader/app/src/main/java/com/google/android/gms/samples/vision/barcodereader/BarcodeGraphicTracker.java +++ b/visionSamples/barcode-reader/app/src/main/java/com/google/android/gms/samples/vision/barcodereader/BarcodeGraphicTracker.java @@ -16,7 +16,7 @@ package com.google.android.gms.samples.vision.barcodereader; import android.content.Context; -import android.support.annotation.UiThread; +import androidx.annotation.UiThread; import com.google.android.gms.samples.vision.barcodereader.ui.camera.GraphicOverlay; import com.google.android.gms.vision.Detector; diff --git a/visionSamples/barcode-reader/app/src/main/java/com/google/android/gms/samples/vision/barcodereader/ui/camera/CameraSource.java b/visionSamples/barcode-reader/app/src/main/java/com/google/android/gms/samples/vision/barcodereader/ui/camera/CameraSource.java index 430fd746..17c6dbe8 100644 --- a/visionSamples/barcode-reader/app/src/main/java/com/google/android/gms/samples/vision/barcodereader/ui/camera/CameraSource.java +++ b/visionSamples/barcode-reader/app/src/main/java/com/google/android/gms/samples/vision/barcodereader/ui/camera/CameraSource.java @@ -25,9 +25,9 @@ import android.hardware.Camera.CameraInfo; import android.os.Build; import android.os.SystemClock; -import android.support.annotation.Nullable; -import android.support.annotation.RequiresPermission; -import android.support.annotation.StringDef; +import androidx.annotation.Nullable; +import androidx.annotation.RequiresPermission; +import androidx.annotation.StringDef; import android.util.Log; import android.view.Surface; import android.view.SurfaceHolder; diff --git a/visionSamples/barcode-reader/app/src/main/java/com/google/android/gms/samples/vision/barcodereader/ui/camera/CameraSourcePreview.java b/visionSamples/barcode-reader/app/src/main/java/com/google/android/gms/samples/vision/barcodereader/ui/camera/CameraSourcePreview.java index bbcc43cc..9d8d94dc 100644 --- a/visionSamples/barcode-reader/app/src/main/java/com/google/android/gms/samples/vision/barcodereader/ui/camera/CameraSourcePreview.java +++ b/visionSamples/barcode-reader/app/src/main/java/com/google/android/gms/samples/vision/barcodereader/ui/camera/CameraSourcePreview.java @@ -18,7 +18,7 @@ import android.Manifest; import android.content.Context; import android.content.res.Configuration; -import android.support.annotation.RequiresPermission; +import androidx.annotation.RequiresPermission; import android.util.AttributeSet; import android.util.Log; import android.view.SurfaceHolder; diff --git a/visionSamples/barcode-reader/build.gradle b/visionSamples/barcode-reader/build.gradle index d14039de..bd51566b 100644 --- a/visionSamples/barcode-reader/build.gradle +++ b/visionSamples/barcode-reader/build.gradle @@ -3,9 +3,10 @@ buildscript { repositories { jcenter() + google() } dependencies { - classpath 'com.android.tools.build:gradle:2.1.3' + classpath 'com.android.tools.build:gradle:3.4.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -15,5 +16,6 @@ buildscript { allprojects { repositories { jcenter() + google() } } diff --git a/visionSamples/barcode-reader/gradle.properties b/visionSamples/barcode-reader/gradle.properties index 1d3591c8..915f0e66 100644 --- a/visionSamples/barcode-reader/gradle.properties +++ b/visionSamples/barcode-reader/gradle.properties @@ -15,4 +15,6 @@ # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true \ No newline at end of file +# org.gradle.parallel=true +android.enableJetifier=true +android.useAndroidX=true \ No newline at end of file diff --git a/visionSamples/barcode-reader/gradle/wrapper/gradle-wrapper.properties b/visionSamples/barcode-reader/gradle/wrapper/gradle-wrapper.properties index 1081cc34..57bfc0f2 100644 --- a/visionSamples/barcode-reader/gradle/wrapper/gradle-wrapper.properties +++ b/visionSamples/barcode-reader/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed Apr 10 15:27:10 PDT 2013 +#Wed Jun 12 20:34:07 IDT 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip