Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
11839e2c
Commit
11839e2c
authored
Oct 08, 2012
by
Alexander Smorkalov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wating for OpenCV Manager installation added.
parent
601b87e3
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
156 additions
and
71 deletions
+156
-71
android+AsyncServiceHelper.java
...s/java/generator/src/java/android+AsyncServiceHelper.java
+92
-42
android+BaseLoaderCallback.java
...s/java/generator/src/java/android+BaseLoaderCallback.java
+42
-28
android+InstallCallbackInterface.java
.../generator/src/java/android+InstallCallbackInterface.java
+13
-0
android+LoaderCallbackInterface.java
...a/generator/src/java/android+LoaderCallbackInterface.java
+1
-1
android+android+sync.py
modules/java/generator/src/java/android+android+sync.py
+8
-0
No files found.
modules/java/generator/src/java/android+AsyncServiceHelper.java
View file @
11839e2c
...
...
@@ -33,8 +33,7 @@ class AsyncServiceHelper
}
}
protected
AsyncServiceHelper
(
String
Version
,
Context
AppContext
,
LoaderCallbackInterface
Callback
)
protected
AsyncServiceHelper
(
String
Version
,
Context
AppContext
,
LoaderCallbackInterface
Callback
)
{
mOpenCVersion
=
Version
;
mUserAppCallback
=
Callback
;
...
...
@@ -48,62 +47,109 @@ class AsyncServiceHelper
protected
String
mOpenCVersion
;
protected
Context
mAppContext
;
protected
int
mStatus
=
LoaderCallbackInterface
.
SUCCESS
;
protected
static
boolean
mServiceInstallationProgress
=
false
;
protected
static
boolean
mLibraryInstallationProgress
=
false
;
pr
ivate
static
void
InstallService
(
final
Context
AppContext
,
final
LoaderCallbackInterface
Callback
)
pr
otected
static
boolean
InstallServiceQuiet
(
Context
context
)
{
InstallCallbackInterface
InstallQuery
=
new
InstallCallbackInterface
()
{
private
Context
mAppContext
=
AppContext
;
private
LoaderCallbackInterface
mUserAppCallback
=
Callback
;
public
String
getPackageName
()
{
return
"OpenCV Manager"
;
}
public
void
install
()
{
Log
.
d
(
TAG
,
"Trying to install OpenCV Manager via Google Play"
);
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
;
}
boolean
result
=
true
;
try
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
()
{
private
LoaderCallbackInterface
mUserAppCallback
=
Callback
;
public
String
getPackageName
()
{
Intent
intent
=
new
Intent
(
Intent
.
ACTION_VIEW
,
Uri
.
parse
(
OPEN_CV_SERVICE_URL
));
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
mAppContext
.
startActivity
(
intent
);
return
"OpenCV Manager"
;
}
catch
(
Exception
e
)
{
result
=
false
;
public
void
install
()
{
Log
.
d
(
TAG
,
"Trying to install OpenCV Manager via Google Play"
);
boolean
result
=
InstallServiceQuiet
(
AppContext
);
if
(
result
)
{
mServiceInstallationProgress
=
true
;
int
Status
=
LoaderCallbackInterface
.
RESTART_REQUIRED
;
Log
.
d
(
TAG
,
"Init finished with status "
+
Status
);
Log
.
d
(
TAG
,
"Calling using callback"
);
mUserAppCallback
.
onManagerConnected
(
Status
);
}
else
{
Log
.
d
(
TAG
,
"OpenCV package was not installed!"
);
int
Status
=
LoaderCallbackInterface
.
MARKET_ERROR
;
Log
.
d
(
TAG
,
"Init finished with status "
+
Status
);
Log
.
d
(
TAG
,
"Unbind from service"
);
Log
.
d
(
TAG
,
"Calling using callback"
);
mUserAppCallback
.
onManagerConnected
(
Status
);
}
}
if
(
result
)
public
void
cancel
(
)
{
int
Status
=
LoaderCallbackInterface
.
RESTART_REQUIRED
;
Log
.
d
(
TAG
,
"OpenCV library installation was canceled"
);
int
Status
=
LoaderCallbackInterface
.
INSTALL_CANCELED
;
Log
.
d
(
TAG
,
"Init finished with status "
+
Status
);
Log
.
d
(
TAG
,
"Calling using callback"
);
mUserAppCallback
.
onManagerConnected
(
Status
);
}
else
public
void
wait_install
()
{
Log
.
e
(
TAG
,
"Instalation was not started! Nothing to wait!"
);
}
};
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
.
d
(
TAG
,
"OpenCV package was not installed!"
);
int
Status
=
LoaderCallbackInterface
.
MARKET_ERROR
;
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
,
"Unbind from service"
);
Log
.
d
(
TAG
,
"Calling using callback"
);
mUserAppCallback
.
onManagerConnected
(
Status
);
}
}
public
void
cancel
()
{
Log
.
d
(
TAG
,
"OpenCV library installation was canceled"
);
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
(
InstallQuery
);
Callback
.
onPackageInstall
(
InstallCallbackInterface
.
INSTALLATION_PROGRESS
,
WaitQuery
);
}
}
/**
* URL of OpenCV Manager page on Google Play Market.
*/
...
...
@@ -122,6 +168,7 @@ class AsyncServiceHelper
}
else
{
mServiceInstallationProgress
=
false
;
try
{
if
(
mEngineService
.
getEngineVersion
()
<
MINIMUM_ENGINE_VERSION
)
...
...
@@ -177,9 +224,12 @@ class AsyncServiceHelper
Log
.
d
(
TAG
,
"Calling using callback"
);
mUserAppCallback
.
onManagerConnected
(
mStatus
);
}
public
void
wait_install
()
{
Log
.
e
(
TAG
,
"Instalation was not started! Nothing to wait!"
);
}
};
mUserAppCallback
.
onPackageInstall
(
InstallQuery
);
mUserAppCallback
.
onPackageInstall
(
Install
CallbackInterface
.
NEW_INSTALLATION
,
Install
Query
);
return
;
}
else
...
...
@@ -218,13 +268,13 @@ class AsyncServiceHelper
}
}
}
public
void
onServiceDisconnected
(
ComponentName
className
)
{
mEngineService
=
null
;
}
};
private
boolean
loadLibrary
(
String
AbsPath
)
{
boolean
result
=
true
;
...
...
modules/java/generator/src/java/android+BaseLoaderCallback.java
View file @
11839e2c
...
...
@@ -27,18 +27,7 @@ public abstract class BaseLoaderCallback implements LoaderCallbackInterface {
/** OpenCV Manager or library package installation is in progress. Restart the application. **/
case
LoaderCallbackInterface
.
RESTART_REQUIRED
:
{
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
();
Log
.
d
(
TAG
,
"OpenCV downloading. App restart is needed!"
);
}
break
;
/** OpenCV loader can not start Google Play Market. **/
case
LoaderCallbackInterface
.
MARKET_ERROR
:
...
...
@@ -96,29 +85,54 @@ public abstract class BaseLoaderCallback implements LoaderCallbackInterface {
}
}
public
void
onPackageInstall
(
final
InstallCallbackInterface
callback
)
public
void
onPackageInstall
(
final
int
operation
,
final
InstallCallbackInterface
callback
)
{
AlertDialog
InstallMessage
=
new
AlertDialog
.
Builder
(
mAppContext
).
create
();
InstallMessage
.
setTitle
(
"Package not found"
);
InstallMessage
.
setMessage
(
callback
.
getPackageName
()
+
" package was not found! Try to install it?"
);
InstallMessage
.
setCancelable
(
false
);
// This blocks the 'BACK' button
InstallMessage
.
setButton
(
AlertDialog
.
BUTTON_POSITIVE
,
"Yes"
,
new
OnClickListener
()
switch
(
operation
)
{
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
case
InstallCallbackInterface
.
NEW_INSTALLATION
:
{
callback
.
install
();
}
});
AlertDialog
InstallMessage
=
new
AlertDialog
.
Builder
(
mAppContext
).
create
();
InstallMessage
.
setTitle
(
"Package not found"
);
InstallMessage
.
setMessage
(
callback
.
getPackageName
()
+
" package was not found! Try to install it?"
);
InstallMessage
.
setCancelable
(
false
);
// This blocks the 'BACK' button
InstallMessage
.
setButton
(
AlertDialog
.
BUTTON_POSITIVE
,
"Yes"
,
new
OnClickListener
()
{
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
callback
.
install
();
}
});
InstallMessage
.
setButton
(
AlertDialog
.
BUTTON_NEGATIVE
,
"No"
,
new
OnClickListener
()
{
InstallMessage
.
setButton
(
AlertDialog
.
BUTTON_NEGATIVE
,
"No"
,
new
OnClickListener
()
{
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
callback
.
cancel
();
}
});
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
InstallMessage
.
show
();
}
break
;
case
InstallCallbackInterface
.
INSTALLATION_PROGRESS
:
{
callback
.
cancel
();
}
});
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
();
}
});
InstallMessage
.
show
();
WaitMessage
.
show
();
}
break
;
}
}
protected
Activity
mAppContext
;
...
...
modules/java/generator/src/java/android+InstallCallbackInterface.java
View file @
11839e2c
...
...
@@ -5,6 +5,15 @@ package org.opencv.android;
*/
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.
* @return Return target package name.
...
...
@@ -18,4 +27,8 @@ public interface InstallCallbackInterface
* Installation is canceled.
*/
public
void
cancel
();
/**
* Wait for package installation.
*/
public
void
wait_install
();
};
modules/java/generator/src/java/android+LoaderCallbackInterface.java
View file @
11839e2c
...
...
@@ -40,5 +40,5 @@ public interface LoaderCallbackInterface
* Callback method, called in case the package installation is needed.
* @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
);
};
modules/java/generator/src/java/android+android+sync.py
0 → 100644
View file @
11839e2c
#!/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
));
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment