Wating for OpenCV Manager installation added.
This commit is contained in:
@@ -33,8 +33,7 @@ class AsyncServiceHelper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AsyncServiceHelper(String Version, Context AppContext,
|
protected AsyncServiceHelper(String Version, Context AppContext, LoaderCallbackInterface Callback)
|
||||||
LoaderCallbackInterface Callback)
|
|
||||||
{
|
{
|
||||||
mOpenCVersion = Version;
|
mOpenCVersion = Version;
|
||||||
mUserAppCallback = Callback;
|
mUserAppCallback = Callback;
|
||||||
@@ -48,11 +47,32 @@ class AsyncServiceHelper
|
|||||||
protected String mOpenCVersion;
|
protected String mOpenCVersion;
|
||||||
protected Context mAppContext;
|
protected Context mAppContext;
|
||||||
protected int mStatus = LoaderCallbackInterface.SUCCESS;
|
protected int mStatus = LoaderCallbackInterface.SUCCESS;
|
||||||
|
protected static boolean mServiceInstallationProgress = false;
|
||||||
|
protected static boolean mLibraryInstallationProgress = false;
|
||||||
|
|
||||||
private static void InstallService(final Context AppContext, final LoaderCallbackInterface Callback)
|
protected static boolean InstallServiceQuiet(Context context)
|
||||||
{
|
{
|
||||||
|
boolean result = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(OPEN_CV_SERVICE_URL));
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
context.startActivity(intent);
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static void InstallService(final Context AppContext, final LoaderCallbackInterface Callback)
|
||||||
|
{
|
||||||
|
if (!mServiceInstallationProgress)
|
||||||
|
{
|
||||||
|
Log.d(TAG, "Request new service installation");
|
||||||
InstallCallbackInterface InstallQuery = new InstallCallbackInterface() {
|
InstallCallbackInterface InstallQuery = new InstallCallbackInterface() {
|
||||||
private Context mAppContext = AppContext;
|
|
||||||
private LoaderCallbackInterface mUserAppCallback = Callback;
|
private LoaderCallbackInterface mUserAppCallback = Callback;
|
||||||
public String getPackageName()
|
public String getPackageName()
|
||||||
{
|
{
|
||||||
@@ -61,20 +81,10 @@ class AsyncServiceHelper
|
|||||||
public void install() {
|
public void install() {
|
||||||
Log.d(TAG, "Trying to install OpenCV Manager via Google Play");
|
Log.d(TAG, "Trying to install OpenCV Manager via Google Play");
|
||||||
|
|
||||||
boolean result = true;
|
boolean result = InstallServiceQuiet(AppContext);
|
||||||
try
|
|
||||||
{
|
|
||||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(OPEN_CV_SERVICE_URL));
|
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
mAppContext.startActivity(intent);
|
|
||||||
}
|
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
result = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
|
mServiceInstallationProgress = true;
|
||||||
int Status = LoaderCallbackInterface.RESTART_REQUIRED;
|
int Status = LoaderCallbackInterface.RESTART_REQUIRED;
|
||||||
Log.d(TAG, "Init finished with status " + Status);
|
Log.d(TAG, "Init finished with status " + Status);
|
||||||
Log.d(TAG, "Calling using callback");
|
Log.d(TAG, "Calling using callback");
|
||||||
@@ -99,9 +109,45 @@ class AsyncServiceHelper
|
|||||||
Log.d(TAG, "Calling using callback");
|
Log.d(TAG, "Calling using callback");
|
||||||
mUserAppCallback.onManagerConnected(Status);
|
mUserAppCallback.onManagerConnected(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void wait_install()
|
||||||
|
{
|
||||||
|
Log.e(TAG, "Instalation was not started! Nothing to wait!");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Callback.onPackageInstall(InstallQuery);
|
Callback.onPackageInstall(InstallCallbackInterface.NEW_INSTALLATION, InstallQuery);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log.d(TAG, "Wating current installation process");
|
||||||
|
InstallCallbackInterface WaitQuery = new InstallCallbackInterface() {
|
||||||
|
private LoaderCallbackInterface mUserAppCallback = Callback;
|
||||||
|
public String getPackageName()
|
||||||
|
{
|
||||||
|
return "OpenCV Manager";
|
||||||
|
}
|
||||||
|
public void install()
|
||||||
|
{
|
||||||
|
Log.e(TAG, "Nothing to install we just wait current installation");
|
||||||
|
}
|
||||||
|
public void cancel()
|
||||||
|
{
|
||||||
|
Log.d(TAG, "Wating for OpenCV canceled by user");
|
||||||
|
mServiceInstallationProgress = false;
|
||||||
|
int Status = LoaderCallbackInterface.INSTALL_CANCELED;
|
||||||
|
Log.d(TAG, "Init finished with status " + Status);
|
||||||
|
Log.d(TAG, "Calling using callback");
|
||||||
|
mUserAppCallback.onManagerConnected(Status);
|
||||||
|
}
|
||||||
|
public void wait_install()
|
||||||
|
{
|
||||||
|
InstallServiceQuiet(AppContext);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Callback.onPackageInstall(InstallCallbackInterface.INSTALLATION_PROGRESS, WaitQuery);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -122,6 +168,7 @@ class AsyncServiceHelper
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
mServiceInstallationProgress = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (mEngineService.getEngineVersion() < MINIMUM_ENGINE_VERSION)
|
if (mEngineService.getEngineVersion() < MINIMUM_ENGINE_VERSION)
|
||||||
@@ -177,9 +224,12 @@ class AsyncServiceHelper
|
|||||||
Log.d(TAG, "Calling using callback");
|
Log.d(TAG, "Calling using callback");
|
||||||
mUserAppCallback.onManagerConnected(mStatus);
|
mUserAppCallback.onManagerConnected(mStatus);
|
||||||
}
|
}
|
||||||
|
public void wait_install() {
|
||||||
|
Log.e(TAG, "Instalation was not started! Nothing to wait!");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
mUserAppCallback.onPackageInstall(InstallQuery);
|
mUserAppCallback.onPackageInstall(InstallCallbackInterface.NEW_INSTALLATION, InstallQuery);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -28,17 +28,6 @@ public abstract class BaseLoaderCallback implements LoaderCallbackInterface {
|
|||||||
case LoaderCallbackInterface.RESTART_REQUIRED:
|
case LoaderCallbackInterface.RESTART_REQUIRED:
|
||||||
{
|
{
|
||||||
Log.d(TAG, "OpenCV downloading. App restart is needed!");
|
Log.d(TAG, "OpenCV downloading. App restart is needed!");
|
||||||
AlertDialog RestartMessage = new AlertDialog.Builder(mAppContext).create();
|
|
||||||
RestartMessage.setTitle("App restart is required");
|
|
||||||
RestartMessage.setMessage("Application will be closed now. Start it when installation will be finished!");
|
|
||||||
RestartMessage.setCancelable(false); // This blocks the 'BACK' button
|
|
||||||
RestartMessage.setButton(AlertDialog.BUTTON_POSITIVE, "OK", new OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
mAppContext.finish();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
RestartMessage.show();
|
|
||||||
} break;
|
} break;
|
||||||
/** OpenCV loader can not start Google Play Market. **/
|
/** OpenCV loader can not start Google Play Market. **/
|
||||||
case LoaderCallbackInterface.MARKET_ERROR:
|
case LoaderCallbackInterface.MARKET_ERROR:
|
||||||
@@ -96,7 +85,11 @@ public abstract class BaseLoaderCallback implements LoaderCallbackInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPackageInstall(final InstallCallbackInterface callback)
|
public void onPackageInstall(final int operation, final InstallCallbackInterface callback)
|
||||||
|
{
|
||||||
|
switch (operation)
|
||||||
|
{
|
||||||
|
case InstallCallbackInterface.NEW_INSTALLATION:
|
||||||
{
|
{
|
||||||
AlertDialog InstallMessage = new AlertDialog.Builder(mAppContext).create();
|
AlertDialog InstallMessage = new AlertDialog.Builder(mAppContext).create();
|
||||||
InstallMessage.setTitle("Package not found");
|
InstallMessage.setTitle("Package not found");
|
||||||
@@ -119,6 +112,27 @@ public abstract class BaseLoaderCallback implements LoaderCallbackInterface {
|
|||||||
});
|
});
|
||||||
|
|
||||||
InstallMessage.show();
|
InstallMessage.show();
|
||||||
|
} break;
|
||||||
|
case InstallCallbackInterface.INSTALLATION_PROGRESS:
|
||||||
|
{
|
||||||
|
AlertDialog WaitMessage = new AlertDialog.Builder(mAppContext).create();
|
||||||
|
WaitMessage.setTitle("OpenCV is not ready");
|
||||||
|
WaitMessage.setMessage("Installation is in progeress. Wait or exit?");
|
||||||
|
WaitMessage.setCancelable(false); // This blocks the 'BACK' button
|
||||||
|
WaitMessage.setButton(AlertDialog.BUTTON_POSITIVE, "Wait", new OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
callback.wait_install();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
WaitMessage.setButton(AlertDialog.BUTTON_NEGATIVE, "Exit", new OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
callback.cancel();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
WaitMessage.show();
|
||||||
|
} break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Activity mAppContext;
|
protected Activity mAppContext;
|
||||||
|
@@ -5,6 +5,15 @@ package org.opencv.android;
|
|||||||
*/
|
*/
|
||||||
public interface InstallCallbackInterface
|
public interface InstallCallbackInterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* New package installation is required.
|
||||||
|
*/
|
||||||
|
static final int NEW_INSTALLATION = 0;
|
||||||
|
/**
|
||||||
|
* Current package installation is in progress.
|
||||||
|
*/
|
||||||
|
static final int INSTALLATION_PROGRESS = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Target package name.
|
* Target package name.
|
||||||
* @return Return target package name.
|
* @return Return target package name.
|
||||||
@@ -18,4 +27,8 @@ public interface InstallCallbackInterface
|
|||||||
* Installation is canceled.
|
* Installation is canceled.
|
||||||
*/
|
*/
|
||||||
public void cancel();
|
public void cancel();
|
||||||
|
/**
|
||||||
|
* Wait for package installation.
|
||||||
|
*/
|
||||||
|
public void wait_install();
|
||||||
};
|
};
|
||||||
|
@@ -40,5 +40,5 @@ public interface LoaderCallbackInterface
|
|||||||
* Callback method, called in case the package installation is needed.
|
* Callback method, called in case the package installation is needed.
|
||||||
* @param callback answer object with approve and cancel methods and the package description.
|
* @param callback answer object with approve and cancel methods and the package description.
|
||||||
*/
|
*/
|
||||||
public void onPackageInstall(InstallCallbackInterface callback);
|
public void onPackageInstall(final int operation, InstallCallbackInterface callback);
|
||||||
};
|
};
|
||||||
|
7
modules/java/generator/src/java/android+android+sync.py
Normal file
7
modules/java/generator/src/java/android+android+sync.py
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
for f in os.listdir("."):
|
||||||
|
shutil.copyfile(f, os.path.join("../../../../../../modules/java/generator/src/java/", "android+" + f));
|
Reference in New Issue
Block a user