Commit dc5c7ee6 authored by Alexander Smorkalov's avatar Alexander Smorkalov

Link to OpenCV website updated. Full Manager version added to UI. Screen orientation fixed.

parent d55e114f
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.opencv.engine" package="org.opencv.engine"
android:versionCode="14" android:versionCode="15"
android:versionName="1.4" > android:versionName="1.5" >
<uses-sdk android:minSdkVersion="8" /> <uses-sdk android:minSdkVersion="8" />
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/> <uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
...@@ -16,13 +16,16 @@ ...@@ -16,13 +16,16 @@
<action android:name="org.opencv.engine.BIND"></action> <action android:name="org.opencv.engine.BIND"></action>
</intent-filter> </intent-filter>
</service> </service>
<activity android:name="org.opencv.engine.manager.ManagerActivity" android:label="@string/app_name" > <activity
android:name="org.opencv.engine.manager.ManagerActivity"
android:label="@string/app_name"
android:screenOrientation="portrait">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
</application> </application>
</manifest> </manifest>
\ No newline at end of file
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:autoLink="web" android:autoLink="web"
android:text="OpenCV is Open Computer Vision library. OpenCV Manager provides the best version of the OpenCV for your hardware. See www.opencv.org for details." android:text="OpenCV is Open Computer Vision library. OpenCV Manager provides the best version of the OpenCV for your hardware. See opencv.org for details."
android:textAppearance="?android:attr/textAppearanceSmall" /> android:textAppearance="?android:attr/textAppearanceSmall" />
<LinearLayout <LinearLayout
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:autoLink="web" android:autoLink="web"
android:text="OpenCV library is used by other applications for image enhancement, panorama stitching, object detection, recognition and tracking and so on. OpenCV Manager provides the best version of the OpenCV for your hardware. See www.opencv.org for details." android:text="OpenCV library is used by other applications for image enhancement, panorama stitching, object detection, recognition and tracking and so on. OpenCV Manager provides the best version of the OpenCV for your hardware. See opencv.org for details."
android:textAppearance="?android:attr/textAppearanceMedium" /> android:textAppearance="?android:attr/textAppearanceMedium" />
<LinearLayout <LinearLayout
......
...@@ -17,6 +17,7 @@ import android.content.Intent; ...@@ -17,6 +17,7 @@ import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.content.ServiceConnection; import android.content.ServiceConnection;
import android.content.pm.PackageInfo; import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.IBinder; import android.os.IBinder;
...@@ -39,14 +40,23 @@ public class ManagerActivity extends Activity ...@@ -39,14 +40,23 @@ public class ManagerActivity extends Activity
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.main); setContentView(R.layout.main);
TextView OsVersionView = (TextView)findViewById(R.id.OsVersionValue); TextView OsVersionView = (TextView)findViewById(R.id.OsVersionValue);
OsVersionView.setText(Build.VERSION.CODENAME + " (" + Build.VERSION.RELEASE + "), API " + Build.VERSION.SDK_INT); OsVersionView.setText(Build.VERSION.CODENAME + " (" + Build.VERSION.RELEASE + "), API " + Build.VERSION.SDK_INT);
try {
PackageInfo packageInfo = getPackageManager().getPackageInfo(this.getPackageName(), 0);
ManagerVersion = packageInfo.versionName;
} catch (NameNotFoundException e) {
// TODO Auto-generated catch block
ManagerVersion = "N/A";
e.printStackTrace();
}
mInstalledPackageView = (ListView)findViewById(R.id.InstalledPackageList); mInstalledPackageView = (ListView)findViewById(R.id.InstalledPackageList);
mMarket = new MarketConnector(this); mMarket = new MarketConnector(this);
mInstalledPacksAdapter = new PackageListAdapter( mInstalledPacksAdapter = new PackageListAdapter(
this, this,
mListViewItems, mListViewItems,
...@@ -54,13 +64,13 @@ public class ManagerActivity extends Activity ...@@ -54,13 +64,13 @@ public class ManagerActivity extends Activity
new String[] {"Name", "Version", "Hardware", "Activity"}, new String[] {"Name", "Version", "Hardware", "Activity"},
new int[] {R.id.InfoName,R.id.InfoVersion, R.id.InfoHardware} new int[] {R.id.InfoName,R.id.InfoVersion, R.id.InfoHardware}
); );
mInstalledPackageView.setAdapter(mInstalledPacksAdapter); mInstalledPackageView.setAdapter(mInstalledPacksAdapter);
TextView HardwarePlatformView = (TextView)findViewById(R.id.HardwareValue); TextView HardwarePlatformView = (TextView)findViewById(R.id.HardwareValue);
int Platfrom = HardwareDetector.DetectKnownPlatforms(); int Platfrom = HardwareDetector.DetectKnownPlatforms();
int CpuId = HardwareDetector.GetCpuID(); int CpuId = HardwareDetector.GetCpuID();
if (HardwareDetector.PLATFORM_UNKNOWN != Platfrom) if (HardwareDetector.PLATFORM_UNKNOWN != Platfrom)
{ {
if (HardwareDetector.PLATFORM_TEGRA == Platfrom) if (HardwareDetector.PLATFORM_TEGRA == Platfrom)
...@@ -107,7 +117,7 @@ public class ManagerActivity extends Activity ...@@ -107,7 +117,7 @@ public class ManagerActivity extends Activity
HardwarePlatformView.setText("not detected"); HardwarePlatformView.setText("not detected");
} }
} }
mUpdateEngineButton = (Button)findViewById(R.id.CheckEngineUpdate); mUpdateEngineButton = (Button)findViewById(R.id.CheckEngineUpdate);
mUpdateEngineButton.setOnClickListener(new OnClickListener() { mUpdateEngineButton.setOnClickListener(new OnClickListener() {
...@@ -119,9 +129,9 @@ public class ManagerActivity extends Activity ...@@ -119,9 +129,9 @@ public class ManagerActivity extends Activity
} }
} }
}); });
mActionDialog = new AlertDialog.Builder(this).create(); mActionDialog = new AlertDialog.Builder(this).create();
mActionDialog.setTitle("Choose action"); mActionDialog.setTitle("Choose action");
mActionDialog.setButton("Update", new DialogInterface.OnClickListener() { mActionDialog.setButton("Update", new DialogInterface.OnClickListener() {
...@@ -134,7 +144,7 @@ public class ManagerActivity extends Activity ...@@ -134,7 +144,7 @@ public class ManagerActivity extends Activity
} }
} }
}); });
mActionDialog.setButton3("Remove", new DialogInterface.OnClickListener() { mActionDialog.setButton3("Remove", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
...@@ -143,67 +153,69 @@ public class ManagerActivity extends Activity ...@@ -143,67 +153,69 @@ public class ManagerActivity extends Activity
{ {
Toast toast = Toast.makeText(getApplicationContext(), "Google Play is not avaliable", Toast.LENGTH_SHORT); Toast toast = Toast.makeText(getApplicationContext(), "Google Play is not avaliable", Toast.LENGTH_SHORT);
toast.show(); toast.show();
} }
} }
}); });
mActionDialog.setButton2("Return", new DialogInterface.OnClickListener() { mActionDialog.setButton2("Return", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
// nothing // nothing
} }
}); });
mInstalledPackageView.setOnItemClickListener(new OnItemClickListener() { mInstalledPackageView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long id) { public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long id) {
mInstalledPackageView.setTag(Integer.valueOf((int)id)); mInstalledPackageView.setTag(Integer.valueOf((int)id));
mActionDialog.show(); mActionDialog.show();
} }
}); });
if (!bindService(new Intent("org.opencv.engine.BIND"), mServiceConnection, Context.BIND_AUTO_CREATE)) if (!bindService(new Intent("org.opencv.engine.BIND"), mServiceConnection, Context.BIND_AUTO_CREATE))
{ {
TextView EngineVersionView = (TextView)findViewById(R.id.EngineVersionValue); TextView EngineVersionView = (TextView)findViewById(R.id.EngineVersionValue);
EngineVersionView.setText("not avaliable"); EngineVersionView.setText("not avaliable");
} }
IntentFilter filter = new IntentFilter(); IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_PACKAGE_ADDED); filter.addAction(Intent.ACTION_PACKAGE_ADDED);
filter.addAction(Intent.ACTION_PACKAGE_CHANGED); filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
filter.addAction(Intent.ACTION_PACKAGE_INSTALL); filter.addAction(Intent.ACTION_PACKAGE_INSTALL);
filter.addAction(Intent.ACTION_PACKAGE_REMOVED); filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
filter.addAction(Intent.ACTION_PACKAGE_REPLACED); filter.addAction(Intent.ACTION_PACKAGE_REPLACED);
registerReceiver(mPackageChangeReciever, filter); registerReceiver(mPackageChangeReciever, filter);
} }
@Override @Override
protected void onDestroy() { protected void onDestroy() {
super.onDestroy(); super.onDestroy();
unregisterReceiver(mPackageChangeReciever); unregisterReceiver(mPackageChangeReciever);
} }
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
Log.d(TAG, "Filling package list on resume"); Log.d(TAG, "Filling package list on resume");
FillPackageList(); FillPackageList();
} }
protected SimpleAdapter mInstalledPacksAdapter; protected SimpleAdapter mInstalledPacksAdapter;
protected ListView mInstalledPackageView; protected ListView mInstalledPackageView;
protected Button mUpdateEngineButton; protected Button mUpdateEngineButton;
protected PackageInfo[] mInstalledPackageInfo; protected PackageInfo[] mInstalledPackageInfo;
protected final ArrayList<HashMap<String,String>> mListViewItems = new ArrayList<HashMap<String,String>>(); protected final ArrayList<HashMap<String,String>> mListViewItems = new ArrayList<HashMap<String,String>>();
protected static final String TAG = "OpenCV_Manager/Activity"; protected static final String TAG = "OpenCV_Manager/Activity";
protected MarketConnector mMarket; protected MarketConnector mMarket;
protected AlertDialog mActionDialog; protected AlertDialog mActionDialog;
protected HashMap<String,String> mActivePackageMap = new HashMap<String, String>(); protected HashMap<String,String> mActivePackageMap = new HashMap<String, String>();
protected int ManagerApiLevel = 0;
protected String ManagerVersion;
protected BroadcastReceiver mPackageChangeReciever = new BroadcastReceiver() { protected BroadcastReceiver mPackageChangeReciever = new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
Log.d("OpenCV Manager/Reciever", "Bradcast message " + intent.getAction() + " reciever"); Log.d("OpenCV Manager/Reciever", "Bradcast message " + intent.getAction() + " reciever");
...@@ -211,24 +223,25 @@ public class ManagerActivity extends Activity ...@@ -211,24 +223,25 @@ public class ManagerActivity extends Activity
FillPackageList(); FillPackageList();
} }
}; };
protected ServiceConnection mServiceConnection = new ServiceConnection() { protected ServiceConnection mServiceConnection = new ServiceConnection() {
public void onServiceDisconnected(ComponentName name) { public void onServiceDisconnected(ComponentName name) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
public void onServiceConnected(ComponentName name, IBinder service) { public void onServiceConnected(ComponentName name, IBinder service) {
TextView EngineVersionView = (TextView)findViewById(R.id.EngineVersionValue);
OpenCVEngineInterface EngineService = OpenCVEngineInterface.Stub.asInterface(service); OpenCVEngineInterface EngineService = OpenCVEngineInterface.Stub.asInterface(service);
try { try {
EngineVersionView.setText("" + EngineService.getEngineVersion()); ManagerApiLevel = EngineService.getEngineVersion();
} catch (RemoteException e) { } catch (RemoteException e) {
EngineVersionView.setText("not avaliable");
e.printStackTrace(); e.printStackTrace();
} }
TextView EngineVersionView = (TextView)findViewById(R.id.EngineVersionValue);
EngineVersionView.setText(ManagerVersion);
try { try {
String path = EngineService.getLibPathByVersion("2.4"); String path = EngineService.getLibPathByVersion("2.4");
Log.d(TAG, "2.4 -> " + path); Log.d(TAG, "2.4 -> " + path);
...@@ -253,13 +266,13 @@ public class ManagerActivity extends Activity ...@@ -253,13 +266,13 @@ public class ManagerActivity extends Activity
synchronized (mListViewItems) { synchronized (mListViewItems) {
mInstalledPackageInfo = mMarket.GetInstalledOpenCVPackages(); mInstalledPackageInfo = mMarket.GetInstalledOpenCVPackages();
mListViewItems.clear(); mListViewItems.clear();
for (int i = 0; i < mInstalledPackageInfo.length; i++) for (int i = 0; i < mInstalledPackageInfo.length; i++)
{ {
// Convert to Items for package list view // Convert to Items for package list view
HashMap<String,String> temp = new HashMap<String,String>(); HashMap<String,String> temp = new HashMap<String,String>();
String PublicName = mMarket.GetApplicationName(mInstalledPackageInfo[i].applicationInfo); String PublicName = mMarket.GetApplicationName(mInstalledPackageInfo[i].applicationInfo);
int idx = 0; int idx = 0;
String OpenCVersion = "unknown"; String OpenCVersion = "unknown";
String HardwareName = ""; String HardwareName = "";
...@@ -282,11 +295,11 @@ public class ManagerActivity extends Activity ...@@ -282,11 +295,11 @@ public class ManagerActivity extends Activity
} }
idx++; idx++;
} }
String ActivePackagePath; String ActivePackagePath;
ActivePackagePath = mActivePackageMap.get(OpenCVersion); ActivePackagePath = mActivePackageMap.get(OpenCVersion);
Log.d(TAG, OpenCVersion + " -> " + ActivePackagePath); Log.d(TAG, OpenCVersion + " -> " + ActivePackagePath);
if (null != ActivePackagePath && ActivePackagePath.indexOf(mInstalledPackageInfo[i].packageName) >= 0) if (null != ActivePackagePath && ActivePackagePath.indexOf(mInstalledPackageInfo[i].packageName) >= 0)
{ {
temp.put("Activity", "y"); temp.put("Activity", "y");
...@@ -303,29 +316,29 @@ public class ManagerActivity extends Activity ...@@ -303,29 +316,29 @@ public class ManagerActivity extends Activity
mListViewItems.add(temp); mListViewItems.add(temp);
} }
mInstalledPacksAdapter.notifyDataSetChanged(); mInstalledPacksAdapter.notifyDataSetChanged();
} }
} }
protected String NormalizeVersion(String OpenCVersion, String PackageVersion) protected String NormalizeVersion(String OpenCVersion, String PackageVersion)
{ {
int dot = PackageVersion.indexOf("."); int dot = PackageVersion.indexOf(".");
return OpenCVersion.substring(0, OpenCVersion.length()-1) + "." + return OpenCVersion.substring(0, OpenCVersion.length()-1) + "." +
OpenCVersion.toCharArray()[OpenCVersion.length()-1] + "." + OpenCVersion.toCharArray()[OpenCVersion.length()-1] + "." +
PackageVersion.substring(0, dot) + " rev " + PackageVersion.substring(dot+1); PackageVersion.substring(0, dot) + " rev " + PackageVersion.substring(dot+1);
} }
protected String ConvertPackageName(String Name, String Version) protected String ConvertPackageName(String Name, String Version)
{ {
return Name + " rev " + Version; return Name + " rev " + Version;
} }
protected String JoinIntelFeatures(int features) protected String JoinIntelFeatures(int features)
{ {
// TODO: update if package will be published // TODO: update if package will be published
return ""; return "";
} }
protected String JoinArmFeatures(int features) protected String JoinArmFeatures(int features)
{ {
// TODO: update if package will be published // TODO: update if package will be published
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment