Merge pull request #747 from rilaby/master

#AND-128: 'AndroiTS GPS Test' app added to 'Show GPS Status' menu option
This commit is contained in:
vshcherb 2014-07-14 20:55:09 +02:00
commit 5a83441819

View file

@ -31,27 +31,38 @@ import android.widget.Toast;
public class StartGPSStatus extends OsmAndAction { public class StartGPSStatus extends OsmAndAction {
public enum GpsStatusApps { public enum GpsStatusApps {
GPS_STATUS("GPS Status & Toolbox", "com.eclipsim.gpsstatus2", "com.eclipsim.gpsstatus2.GPSStatus"), GPS_STATUS("GPS Status & Toolbox", "com.eclipsim.gpsstatus2", "", "com.eclipsim.gpsstatus2.GPSStatus"),
GPS_TEST("GPS Test", "com.chartcross.gpstest", ""), GPS_TEST("GPS Test", "com.chartcross.gpstest", "com.chartcross.gpstestplus", ""),
INVIU_GPS("inViu GPS-details ", "de.enaikoon.android.inviu.gpsdetails", ""), INVIU_GPS("inViu GPS-details ", "de.enaikoon.android.inviu.gpsdetails", "", ""),
SAT_STAT("SatStat (F-droid)", "com.vonglasow.michael.satstat", ""); ANDROI_TS_GPS_TEST("AndroiTS GPS Test", "com.androits.gps.test.free", "com.androits.gps.test.pro", "");
public final String stringRes; public final String stringRes;
public final String activity;
public final String appName; public final String appName;
public final String paidAppName;
public final String activity;
GpsStatusApps(String res, String appName, String activity) { GpsStatusApps(String res, String appName, String paidAppName, String activity) {
this.stringRes = res; this.stringRes = res;
this.appName = appName; this.appName = appName;
this.paidAppName = paidAppName;
this.activity = activity; this.activity = activity;
} }
public boolean installed(Activity a) { public boolean installed(Activity a) {
return installed(a, appName, paidAppName);
}
public boolean installed(Activity a, String... appName) {
boolean installed = false; boolean installed = false;
try{ PackageManager packageManager = a.getPackageManager();
installed = a.getPackageManager().getPackageInfo(appName, 0) != null; for (String app: appName) {
} catch ( NameNotFoundException e){ try{
} installed = packageManager.getPackageInfo(app, 0) != null;
break;
} catch ( NameNotFoundException e){
installed = false;
}
}
return installed; return installed;
} }
} }
@ -145,7 +156,9 @@ public class StartGPSStatus extends OsmAndAction {
// if (g.activity.length() == 0) { // if (g.activity.length() == 0) {
PackageManager pm = mapActivity.getPackageManager(); PackageManager pm = mapActivity.getPackageManager();
try { try {
intent = pm.getLaunchIntentForPackage(g.appName); String appName = !g.paidAppName.isEmpty() &&
g.installed(mapActivity, g.paidAppName) ? g.paidAppName : g.appName;
intent = pm.getLaunchIntentForPackage(appName);
} catch (RuntimeException e) { } catch (RuntimeException e) {
} }
// } else { // } else {