Skip to content

Commit

Permalink
* prepared for f-droid debut!
Browse files Browse the repository at this point in the history
* changed license to GPLv3
* better handling of OpenCV Manager download
  • Loading branch information
allgood committed Feb 23, 2016
1 parent 7ca91fb commit b9f1ceb
Show file tree
Hide file tree
Showing 7 changed files with 731 additions and 363 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Change Log
==========

version 1.0.10 - a.k.a. f-droid debut
-------------------------------------

* removed unnecessary maven references
* changed license to GPLv3
* enhancements on downloading OpenCV binaries


version 1.0.9
-------------

Expand Down
339 changes: 0 additions & 339 deletions GPLv2.TXT

This file was deleted.

674 changes: 674 additions & 0 deletions GPLv3.TXT

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Copyright 2016 - Claudemir Todo Bom

Software licensed under the GPL version 2 available in GPLv2.TXT and
online on http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
Software licensed under the GPL version 3 available in GPLv3.TXT and
online on http://www.gnu.org/licenses/gpl.txt.

Use parts from other developers, sometimes with small changes,
references on autorship and specific licenses are on individual
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ Requirements

Because of the version of OpenCV that is used in the project it needs to run on Android 5.0 (lollipop) or newer.

In order to capture and manipulate images Open Note Scanner depends on having the OpenCV Manager application installed. If not installed Open Note Scanner will ask to download it from https://github.com/ctodobom/OpenCV-3.1.0-Android or from Google Play Store.


How to Install
--------------

It is possible to install it directly from Google Play Store through [this link](https://play.google.com/store/apps/details?id=com.todobom.opennotescanner).

Binary APK file is available in the [releases section](https://github.com/ctodobom/OpenNoteScanner/releases) of the project. If you install the binary manually you will need also the OpenCV Manager. The best way on doing this manually is downloading the [OpenCV SDK for Android](http://sourceforge.net/projects/opencvlibrary/files/opencv-android/3.1.0/OpenCV-3.1.0-android-sdk.zip/download) on a computer, unzip it and pick the correct APK for your device in the ```apk``` folder. Normally for phone devices, the armeabi-v7a is the correct one. If you have Play Store access, Open Note Scanner will direct you to it in order to download OpenCV Manager if it is not found in the device.
Binary APK file is available in the [releases section](https://github.com/ctodobom/OpenNoteScanner/releases) of the project.


Instructions for building
Expand Down Expand Up @@ -101,8 +103,8 @@ License

Copyright 2016 - Claudemir Todo Bom

Software licensed under the GPL version 2 available in GPLv2.TXT and
online on http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
Software licensed under the GPL version 2 available in GPLv3.TXT and
online on http://www.gnu.org/licenses/gpl.txt.

Use parts from other developers, sometimes with small changes,
references on autorship and specific licenses are on individual
Expand Down
11 changes: 2 additions & 9 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "com.todobom.opennotescanner"
minSdkVersion 21
targetSdkVersion 23
versionCode 9
versionName '1.0.9'
versionCode 10
versionName '1.0.10'
}
buildTypes {
release {
Expand All @@ -21,21 +21,14 @@ android {
}

repositories {
mavenCentral()
maven {
url 'https://raw.github.com/embarkmobile/zxing-android-minimal/mvn-repo/maven-repository/'
}
maven { url "https://jitpack.io" }

}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.embarkmobile:zxing-android-minimal:2.0.0@aar'
compile 'com.embarkmobile:zxing-android-integration:2.0.0@aar'
compile 'com.google.zxing:core:3.0.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.github.ctodobom:OpenCV-3.1.0-Android:-SNAPSHOT'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.todobom.opennotescanner.helpers;

import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DownloadManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
Expand Down Expand Up @@ -40,6 +41,26 @@ public void onServiceDisconnected(ComponentName name) {
}
};
private static long myDownloadReference;
private static LoaderCallbackInterface Callback;
private static String Version;


public static boolean isFDroidInstalled(Context context) {
PackageManager pm = context.getPackageManager();
boolean app_installed = false;
try
{
PackageInfo info = pm.getPackageInfo("org.fdroid.fdroid", PackageManager.GET_ACTIVITIES);
String label = (String) info.applicationInfo.loadLabel(pm);
app_installed = (label != null);
}
catch (PackageManager.NameNotFoundException e)
{
app_installed = false;
}
return app_installed;
}



public static boolean isGooglePlayInstalled(Context context) {
Expand Down Expand Up @@ -112,6 +133,8 @@ public void onReceive(Context ctxt, Intent intent) {
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.setDataAndType(dm.getUriForDownloadedFile(id),
dm.getMimeTypeForDownloadedFile(id));

waitOpenCVDialog.dismiss();
AppContext.startActivity(intent);
AppContext.unregisterReceiver(onComplete);
break;
Expand All @@ -134,12 +157,17 @@ public void onReceive(Context ctxt, Intent intent) {
}
};

static AlertDialog.Builder cancelInstallOpenCV;
static AlertDialog.Builder waitInstallOpenCV;
static Dialog waitOpenCVDialog;


public static boolean initAsync(String version, final Context AppContext, LoaderCallbackInterface callback) {

public static boolean initAsync(String Version, final Context AppContext, LoaderCallbackInterface Callback) {
Version = version;
Callback = callback;

// if don't have google play, check for OpenCV before trying to init
if (!isOpenCVInstalled(Version,AppContext) && !isGooglePlayInstalled(AppContext)) {
if (!isOpenCVInstalled(Version,AppContext) && ( isFDroidInstalled(AppContext) || !isGooglePlayInstalled(AppContext))) {

AlertDialog.Builder askInstallOpenCV = new AlertDialog.Builder(AppContext);

Expand All @@ -165,13 +193,13 @@ public void onClick(DialogInterface dialog, int which) {

dialog.dismiss();

cancelInstallOpenCV = new AlertDialog.Builder(AppContext);
waitInstallOpenCV = new AlertDialog.Builder(AppContext);

cancelInstallOpenCV.setTitle(AppContext.getString(R.string.downloading));
cancelInstallOpenCV.setMessage(AppContext.getString(R.string.downloading_opencv));
waitInstallOpenCV.setTitle(AppContext.getString(R.string.downloading));
waitInstallOpenCV.setMessage(AppContext.getString(R.string.downloading_opencv));

cancelInstallOpenCV.setCancelable(false);
cancelInstallOpenCV.setOnCancelListener( new DialogInterface.OnCancelListener() {
waitInstallOpenCV.setCancelable(false);
waitInstallOpenCV.setOnCancelListener(new DialogInterface.OnCancelListener() {

@Override
public void onCancel(DialogInterface dialog) {
Expand All @@ -181,7 +209,7 @@ public void onCancel(DialogInterface dialog) {
}
});

cancelInstallOpenCV.setNegativeButton(AppContext.getString(R.string.answer_cancel), new DialogInterface.OnClickListener() {
waitInstallOpenCV.setNegativeButton(AppContext.getString(R.string.answer_cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dm.remove(myDownloadReference);
Expand All @@ -190,7 +218,8 @@ public void onClick(DialogInterface dialog, int which) {
}
});

cancelInstallOpenCV.create().show();
waitOpenCVDialog = waitInstallOpenCV.create();
waitOpenCVDialog.show();

}

Expand All @@ -201,6 +230,7 @@ public void onClick(DialogInterface dialog, int which) {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
OpenCVLoader.initAsync(Version, AppContext, Callback);
}
});

Expand Down

0 comments on commit b9f1ceb

Please sign in to comment.