Skip to content

Support the latest Android and studio #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Sample/OpenALPRSample/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
compileSdkVersion 27
buildToolsVersion "28.0.3"

defaultConfig {
applicationId "com.sandro.openalprsample"
minSdkVersion 16
targetSdkVersion 23
minSdkVersion 24
targetSdkVersion 27
versionCode 1
versionName "1.1.2"
}
Expand All @@ -20,9 +20,9 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':OpenALPR')
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.google.code.gson:gson:2.5'
compile 'com.squareup.picasso:picasso:2.5.2'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':OpenALPR')
implementation 'com.android.support:appcompat-v7:27.1.+'
implementation 'com.google.code.gson:gson:2.5'
implementation 'com.squareup.picasso:picasso:2.5.2'
}
19 changes: 17 additions & 2 deletions Sample/OpenALPRSample/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
package="com.sandro.openalprsample"
xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-feature android:name="android.hardware.camera"
android:required="true" />


<application
android:hardwareAccelerated="true"
Expand All @@ -19,6 +22,18 @@
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>

<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.sandro.fileprovider"
android:exported="false"
android:grantUriPermissions="true">

<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths"></meta-data>
</provider>

</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import android.provider.MediaStore;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.FileProvider;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
Expand Down Expand Up @@ -41,6 +42,7 @@ public class MainActivity extends AppCompatActivity {

private static final int REQUEST_IMAGE = 100;
private static final int STORAGE=1;
private static final String LOGID = "MainActivity";
private String ANDROID_DATA_DIR;
private static File destination;
private TextView resultTextView;
Expand Down Expand Up @@ -80,7 +82,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
AsyncTask.execute(new Runnable() {
@Override
public void run() {
String result = OpenALPR.Factory.create(MainActivity.this, ANDROID_DATA_DIR).recognizeWithCountryRegionNConfig("us", "", destination.getAbsolutePath(), openAlprConfFile, 10);
String result = OpenALPR.Factory.create(MainActivity.this, ANDROID_DATA_DIR).recognizeWithCountryRegionNConfig("us"/*"ca"*/, "", destination.getAbsolutePath(), openAlprConfFile, 10);

Log.d("OPEN ALPR", result);

Expand Down Expand Up @@ -165,19 +167,32 @@ public String dateToString(Date date, String format) {
}

public void takePicture() {
// Use a folder to store all results
File folder = new File(Environment.getExternalStorageDirectory() + "/OpenALPR/");
if (!folder.exists()) {
folder.mkdir();
}
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

// Generate the path for the next photo
String name = dateToString(new Date(), "yyyy-MM-dd-hh-mm-ss");
destination = new File(folder, name + ".jpg");
if (intent.resolveActivity(getPackageManager()) != null) {
// Use a folder to store all results
File folder = new File(Environment.getExternalStorageDirectory() + "/OpenALPR/");
if (!folder.exists()) {
folder.mkdir();
}

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(destination));
startActivityForResult(intent, REQUEST_IMAGE);
// Generate the path for the next photo
String name = dateToString(new Date(), "yyyy-MM-dd-hh-mm-ss");
destination = new File(folder, name + ".jpg");

if(destination != null) {
Uri photoURI = FileProvider.getUriForFile(this,
"com.sandro.fileprovider",
destination);

intent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
startActivityForResult(intent, REQUEST_IMAGE);
} else {
Log.e(LOGID, "Failed creating " + name);
}
} else {
Log.e(LOGID, "No camera!");
}
}

@Override
Expand Down
4 changes: 4 additions & 0 deletions Sample/OpenALPRSample/app/src/main/res/xml/file_paths.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="alpr_images" path="OpenALPR" />
</paths>
12 changes: 10 additions & 2 deletions Sample/OpenALPRSample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -16,6 +20,10 @@ buildscript {
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Oct 21 11:34:03 PDT 2015
#Sat Mar 09 09:53:05 EST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
13 changes: 7 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ apply plugin: 'com.github.dcendents.android-maven'
group='com.github.SandroMachado'

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"

compileSdkVersion 27
buildToolsVersion '28.0.3'
defaultConfig {
minSdkVersion 16
targetSdkVersion 23
minSdkVersion 24
targetSdkVersion 27
versionCode 1
versionName "1.0.1"
}
Expand All @@ -19,8 +18,10 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
implementation fileTree(include: ['*.jar'], dir: 'libs')
}
9 changes: 6 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'

classpath 'com.android.tools.build:gradle:3.3.2'
//classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
//implementation 'com.github.SandroMachado:openalpr-android:1.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand All @@ -16,6 +18,7 @@ buildscript {
allprojects {
repositories {
jcenter()
//maven { url "https://jitpack.io" }
}
}

Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun Dec 13 20:39:31 WET 2015
#Sat Mar 09 09:22:10 EST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip