Add version features

This commit is contained in:
Victor Shcherb 2012-08-09 23:41:12 +02:00
parent 65580ff610
commit 7a4d41f3f3
4 changed files with 54 additions and 25 deletions

View file

@ -128,6 +128,14 @@
<exclude name="**/*.java" />
</fileset>
</copy>
<if>
<condition>
<isset property="versionFeatures" />
</condition>
<then>
<replaceregexp file="res/values/no_translate.xml" match='versionFeatures"&gt;(.*)&lt;' replace='versionFeatures"&gt;${versionFeatures}&lt;' byline="true" />
</then>
</if>
<if>
<condition>
<isset property="net.osmand" />

View file

@ -6,5 +6,5 @@
<string name="ga_api_key">UA-28342846-2</string>
<string name="ga_dispatchPeriod">10</string>
<string name="ga_debug">true</string>
<string name="versionFeatures">+play_market +gps_status -parking_plugin</string>
</resources>

View file

@ -12,6 +12,19 @@ public class Version {
private final String appName;
private final static String FREE_VERSION_NAME = "net.osmand";
public static boolean isGpsStatusEnabled(Context ctx) {
return ctx.getString(R.string.versionFeatures).contains("+gps_status");
}
public static boolean isGooglePlayEnabled(Context ctx) {
return ctx.getString(R.string.versionFeatures).contains("+play_market");
}
public static boolean isParkingPluginInlined(Context ctx) {
return ctx.getString(R.string.versionFeatures).contains("+parking_plugin");
}
private Version(Context ctx) {
appVersion = ctx.getString(R.string.app_version);
appName = ctx.getString(R.string.app_name);

View file

@ -15,6 +15,7 @@ import net.osmand.FavouritePoint;
import net.osmand.GPXUtilities;
import net.osmand.GPXUtilities.GPXFile;
import net.osmand.LogUtil;
import net.osmand.Version;
import net.osmand.access.AccessibleAlertBuilder;
import net.osmand.access.AccessibleToast;
import net.osmand.data.Amenity;
@ -972,16 +973,20 @@ public class MapActivityActions implements DialogProvider {
return true;
}
});
optionsMenuHelper.registerOptionsMenuItem(R.string.show_gps_status, R.string.show_gps_status, android.R.drawable.ic_menu_compass, new OnOptionsMenuClick() {
@Override
public void prepareOptionsMenu(Menu menu, MenuItem item) {
}
@Override
public boolean onClick(MenuItem item) {
startGpsStatusIntent();
return false;
}
});
if (Version.isGpsStatusEnabled(mapActivity)) {
optionsMenuHelper.registerOptionsMenuItem(R.string.show_gps_status, R.string.show_gps_status,
android.R.drawable.ic_menu_compass, new OnOptionsMenuClick() {
@Override
public void prepareOptionsMenu(Menu menu, MenuItem item) {
}
@Override
public boolean onClick(MenuItem item) {
startGpsStatusIntent();
return false;
}
});
}
optionsMenuHelper.registerOptionsMenuItem(R.string.show_point_options, R.string.show_point_options, new OnOptionsMenuClick() {
@Override
public void prepareOptionsMenu(Menu menu, MenuItem item) {
@ -1015,21 +1020,24 @@ public class MapActivityActions implements DialogProvider {
if (resolved != null) {
mapActivity.startActivity(intent);
} else {
AlertDialog.Builder builder = new AccessibleAlertBuilder(mapActivity);
builder.setMessage(getString(R.string.gps_status_app_not_found));
builder.setPositiveButton(getString(R.string.default_buttons_yes), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pname:" + GPS_STATUS_COMPONENT));
try {
mapActivity.startActivity(intent);
} catch (ActivityNotFoundException e) {
if (Version.isGooglePlayEnabled(mapActivity)) {
AlertDialog.Builder builder = new AccessibleAlertBuilder(mapActivity);
builder.setMessage(getString(R.string.gps_status_app_not_found));
builder.setPositiveButton(getString(R.string.default_buttons_yes), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pname:" + GPS_STATUS_COMPONENT));
try {
mapActivity.startActivity(intent);
} catch (ActivityNotFoundException e) {
}
}
}
});
builder.setNegativeButton(
getString(R.string.default_buttons_no), null);
builder.show();
});
builder.setNegativeButton(getString(R.string.default_buttons_no), null);
builder.show();
} else {
Toast.makeText(mapActivity, R.string.gps_status_app_not_found, Toast.LENGTH_LONG).show();
}
}
}