Update plugins
This commit is contained in:
parent
f3dbfcd64f
commit
6c406fcedc
18 changed files with 262 additions and 193 deletions
|
@ -14,7 +14,7 @@
|
|||
<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 -blackberry -free_version -amazon</string>
|
||||
<string name="versionFeatures">+play_market -amazon -blackberry</string>
|
||||
<string name="next_tips_and_tricks_not_translate"></string>
|
||||
<string name="openstreetmap_copyright"><a href="http://www.openstreetmap.org/copyright">© OpenStreetMap</a></string>
|
||||
<string name="about_content">Data is powered by OpenStreetMap ODbL, © <a href="http://www.openstreetmap.org/copyright">http://www.openstreetmap.org/copyright</a>.
|
||||
|
|
|
@ -18,15 +18,17 @@ import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
|
|||
import net.osmand.plus.development.OsmandDevelopmentPlugin;
|
||||
import net.osmand.plus.distancecalculator.DistanceCalculatorPlugin;
|
||||
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
|
||||
import net.osmand.plus.openseamapsplugin.OpenSeaMapsPlugin;
|
||||
import net.osmand.plus.osmedit.OsmEditingPlugin;
|
||||
import net.osmand.plus.osmo.OsMoPlugin;
|
||||
import net.osmand.plus.parkingpoint.ParkingPositionPlugin;
|
||||
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
|
||||
import net.osmand.plus.routepointsnavigation.RoutePointsPlugin;
|
||||
import net.osmand.plus.skimapsplugin.SkiMapsPlugin;
|
||||
import net.osmand.plus.srtmplugin.SRTMPlugin;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -34,13 +36,13 @@ import java.util.Set;
|
|||
|
||||
public abstract class OsmandPlugin {
|
||||
|
||||
private static List<OsmandPlugin> installedPlugins = new ArrayList<OsmandPlugin>();
|
||||
private static List<OsmandPlugin> activePlugins = new ArrayList<OsmandPlugin>();
|
||||
private static List<OsmandPlugin> allPlugins = new ArrayList<OsmandPlugin>();
|
||||
private static final Log LOG = PlatformUtil.getLog(OsmandPlugin.class);
|
||||
|
||||
private static final String PARKING_PLUGIN_COMPONENT = "net.osmand.parkingPlugin"; //$NON-NLS-1$
|
||||
private static final String SRTM_PLUGIN_COMPONENT_PAID = "net.osmand.srtmPlugin.paid"; //$NON-NLS-1$
|
||||
private static final String SRTM_PLUGIN_COMPONENT = "net.osmand.srtmPlugin"; //$NON-NLS-1$
|
||||
private static final String SRTM_PLUGIN_COMPONENT = "net.osmand.srtmPlugin";
|
||||
private boolean active;
|
||||
private String installURL = null;
|
||||
|
||||
public abstract String getId();
|
||||
|
||||
|
@ -63,45 +65,49 @@ public abstract class OsmandPlugin {
|
|||
*/
|
||||
public abstract boolean init(OsmandApplication app);
|
||||
|
||||
public void setActive(boolean active) {
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
public boolean couldBeActivated() {
|
||||
return installURL != null;
|
||||
}
|
||||
|
||||
public void setInstallURL(String installURL) {
|
||||
this.installURL = installURL;
|
||||
}
|
||||
|
||||
public void disable(OsmandApplication app) {};
|
||||
|
||||
|
||||
public static void initPlugins(OsmandApplication app) {
|
||||
OsmandSettings settings = app.getSettings();
|
||||
OsmandRasterMapsPlugin rasterMapsPlugin = new OsmandRasterMapsPlugin(app);
|
||||
installedPlugins.add(rasterMapsPlugin);
|
||||
installedPlugins.add(new OsmandMonitoringPlugin(app));
|
||||
installedPlugins.add(new OsMoPlugin(app));
|
||||
installedPlugins.add(new AudioVideoNotesPlugin(app));
|
||||
installedPlugins.add(new DistanceCalculatorPlugin(app));
|
||||
installedPlugins.add(new AccessibilityPlugin(app));
|
||||
if(!installPlugin(SRTM_PLUGIN_COMPONENT_PAID, SRTMPlugin.ID, app,
|
||||
new SRTMPlugin(app, true))) {
|
||||
installPlugin(SRTM_PLUGIN_COMPONENT, SRTMPlugin.FREE_ID, app,
|
||||
new SRTMPlugin(app, false));
|
||||
}
|
||||
final ParkingPositionPlugin parking = new ParkingPositionPlugin(app);
|
||||
boolean f = installPlugin(PARKING_PLUGIN_COMPONENT, ParkingPositionPlugin.ID, app, parking);
|
||||
if(!f && Version.isParkingPluginInlined(app)) {
|
||||
installedPlugins.add(parking);
|
||||
}
|
||||
Set<String> enabledPlugins = settings.getEnabledPlugins();
|
||||
if(Version.isRouteNavPluginInlined(app)) {
|
||||
RoutePointsPlugin routePointsPlugin = new RoutePointsPlugin(app);
|
||||
installedPlugins.add(routePointsPlugin);
|
||||
enabledPlugins.add(routePointsPlugin.getId());
|
||||
}
|
||||
|
||||
// osmodroid disabled
|
||||
// installPlugin(OSMODROID_PLUGIN_COMPONENT, OsMoDroidPlugin.ID, app, new OsMoDroidPlugin(app));
|
||||
installedPlugins.add(new OsmEditingPlugin(app));
|
||||
installedPlugins.add(new OsmandDevelopmentPlugin(app));
|
||||
allPlugins.add(rasterMapsPlugin);
|
||||
allPlugins.add(new OsmandMonitoringPlugin(app));
|
||||
allPlugins.add(new OsMoPlugin(app));
|
||||
|
||||
for (OsmandPlugin plugin : installedPlugins) {
|
||||
if (enabledPlugins.contains(plugin.getId())) {
|
||||
checkMarketPlugin(app, new SRTMPlugin(app), true, SRTM_PLUGIN_COMPONENT_PAID, SRTM_PLUGIN_COMPONENT);
|
||||
checkMarketPlugin(app, new ParkingPositionPlugin(app), false, ParkingPositionPlugin.PARKING_PLUGIN_COMPONENT, null);
|
||||
allPlugins.add(new AudioVideoNotesPlugin(app));
|
||||
checkMarketPlugin(app, new RoutePointsPlugin(app), false /*FIXME*/, RoutePointsPlugin.ROUTE_POINTS_PLUGIN_COMPONENT, null);
|
||||
checkMarketPlugin(app, new OpenSeaMapsPlugin(app), false, OpenSeaMapsPlugin.COMPONENT, null);
|
||||
checkMarketPlugin(app, new SkiMapsPlugin(app), false, SkiMapsPlugin.COMPONENT, null);
|
||||
allPlugins.add(new DistanceCalculatorPlugin(app));
|
||||
allPlugins.add(new AccessibilityPlugin(app));
|
||||
allPlugins.add(new OsmEditingPlugin(app));
|
||||
allPlugins.add(new OsmandDevelopmentPlugin(app));
|
||||
|
||||
for (OsmandPlugin plugin : allPlugins) {
|
||||
if (enabledPlugins.contains(plugin.getId()) || plugin.isActive()) {
|
||||
try {
|
||||
if (plugin.init(app)) {
|
||||
activePlugins.add(plugin);
|
||||
plugin.setActive(true);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.error("Plugin initialization failed " + plugin.getId(), e);
|
||||
|
@ -109,16 +115,39 @@ public abstract class OsmandPlugin {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkMarketPlugin(OsmandApplication app, OsmandPlugin srtm, boolean paid, String id, String id2) {
|
||||
boolean marketEnabled = Version.isMarketEnabled(app);
|
||||
boolean pckg = isPackageInstalled(id, app) ||
|
||||
isPackageInstalled(id2, app);
|
||||
if(Version.isDeveloperVersion(app) && !paid) {
|
||||
// for test reasons
|
||||
marketEnabled = false;
|
||||
}
|
||||
if(pckg || (!marketEnabled && !paid)) {
|
||||
if(pckg && !app.getSettings().getPlugins().contains("-"+srtm.getId())) {
|
||||
srtm.setActive(true);
|
||||
}
|
||||
allPlugins.add(srtm);
|
||||
} else {
|
||||
if(marketEnabled) {
|
||||
srtm.setInstallURL(Version.marketPrefix(app) + id);
|
||||
allPlugins.add(srtm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean enablePlugin(OsmandApplication app, OsmandPlugin plugin, boolean enable) {
|
||||
if (enable) {
|
||||
if (!plugin.init(app)) {
|
||||
plugin.setActive(false);
|
||||
return false;
|
||||
} else {
|
||||
plugin.setActive(true);
|
||||
}
|
||||
activePlugins.add(plugin);
|
||||
} else {
|
||||
plugin.disable(app);
|
||||
activePlugins.remove(plugin);
|
||||
plugin.setActive(false);
|
||||
}
|
||||
app.getSettings().enablePlugin(plugin.getId(), enable);
|
||||
return true;
|
||||
|
@ -170,22 +199,28 @@ public abstract class OsmandPlugin {
|
|||
}
|
||||
|
||||
public static void refreshLayers(OsmandMapTileView mapView, MapActivity activity) {
|
||||
for (OsmandPlugin plugin : activePlugins) {
|
||||
for (OsmandPlugin plugin : getEnabledPlugins()) {
|
||||
plugin.updateLayers(mapView, activity);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<OsmandPlugin> getAvailablePlugins(){
|
||||
return installedPlugins;
|
||||
return allPlugins;
|
||||
}
|
||||
|
||||
public static List<OsmandPlugin> getEnabledPlugins(){
|
||||
return activePlugins;
|
||||
public static Iterable<OsmandPlugin> getEnabledPlugins(){
|
||||
ArrayList<OsmandPlugin> lst = new ArrayList<OsmandPlugin>(allPlugins.size());
|
||||
for(OsmandPlugin p : allPlugins) {
|
||||
if(p.isActive()) {
|
||||
lst.add(p);
|
||||
}
|
||||
}
|
||||
return lst;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends OsmandPlugin> T getEnabledPlugin(Class<T> clz) {
|
||||
for(OsmandPlugin lr : activePlugins) {
|
||||
for(OsmandPlugin lr : getEnabledPlugins()) {
|
||||
if(clz.isInstance(lr)){
|
||||
return (T) lr;
|
||||
}
|
||||
|
@ -195,7 +230,7 @@ public abstract class OsmandPlugin {
|
|||
|
||||
public static List<String> onIndexingFiles(IProgress progress) {
|
||||
List<String> l = new ArrayList<String>();
|
||||
for (OsmandPlugin plugin : activePlugins) {
|
||||
for (OsmandPlugin plugin : getEnabledPlugins()) {
|
||||
List<String> ls = plugin.indexingFiles(progress);
|
||||
if(ls != null && ls.size() > 0) {
|
||||
l.addAll(ls);
|
||||
|
@ -207,45 +242,45 @@ public abstract class OsmandPlugin {
|
|||
|
||||
|
||||
public static void onMapActivityCreate(MapActivity activity) {
|
||||
for (OsmandPlugin plugin : activePlugins) {
|
||||
for (OsmandPlugin plugin : getEnabledPlugins()) {
|
||||
plugin.mapActivityCreate(activity);
|
||||
}
|
||||
}
|
||||
|
||||
public static void onMapActivityResume(MapActivity activity) {
|
||||
for (OsmandPlugin plugin : activePlugins) {
|
||||
for (OsmandPlugin plugin : getEnabledPlugins()) {
|
||||
plugin.mapActivityResume(activity);
|
||||
}
|
||||
}
|
||||
|
||||
public static void onMapActivityPause(MapActivity activity) {
|
||||
for (OsmandPlugin plugin : activePlugins) {
|
||||
for (OsmandPlugin plugin : getEnabledPlugins()) {
|
||||
plugin.mapActivityPause(activity);
|
||||
}
|
||||
}
|
||||
|
||||
public static void onMapActivityDestroy(MapActivity activity) {
|
||||
for (OsmandPlugin plugin : activePlugins) {
|
||||
for (OsmandPlugin plugin : getEnabledPlugins()) {
|
||||
plugin.mapActivityDestroy(activity);
|
||||
}
|
||||
}
|
||||
|
||||
public static void onMapActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
for (OsmandPlugin plugin : activePlugins) {
|
||||
for (OsmandPlugin plugin : getEnabledPlugins()) {
|
||||
plugin.onMapActivityExternalResult(requestCode, resultCode, data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void onSettingsActivityCreate(SettingsActivity activity, PreferenceScreen screen) {
|
||||
for (OsmandPlugin plugin : activePlugins) {
|
||||
for (OsmandPlugin plugin : getEnabledPlugins()) {
|
||||
plugin.settingsActivityCreate(activity, screen);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean onDestinationReached() {
|
||||
boolean b = true;
|
||||
for (OsmandPlugin plugin : activePlugins) {
|
||||
for (OsmandPlugin plugin : getEnabledPlugins()) {
|
||||
if(!plugin.destinationReached()){
|
||||
b = false;
|
||||
}
|
||||
|
@ -255,80 +290,70 @@ public abstract class OsmandPlugin {
|
|||
|
||||
|
||||
public static void createLayers(OsmandMapTileView mapView, MapActivity activity) {
|
||||
for (OsmandPlugin plugin : activePlugins) {
|
||||
for (OsmandPlugin plugin : getEnabledPlugins()) {
|
||||
plugin.registerLayers(activity);
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerMapContextMenu(MapActivity map, double latitude, double longitude, ContextMenuAdapter adapter, Object selectedObj) {
|
||||
for (OsmandPlugin plugin : activePlugins) {
|
||||
for (OsmandPlugin plugin : getEnabledPlugins()) {
|
||||
plugin.registerMapContextMenuActions(map, latitude, longitude, adapter, selectedObj);
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerLayerContextMenu(OsmandMapTileView mapView, ContextMenuAdapter adapter, MapActivity mapActivity) {
|
||||
for (OsmandPlugin plugin : activePlugins) {
|
||||
for (OsmandPlugin plugin : getEnabledPlugins()) {
|
||||
plugin.registerLayerContextMenuActions(mapView, adapter, mapActivity);
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerOptionsMenu(MapActivity map, ContextMenuAdapter helper) {
|
||||
for (OsmandPlugin plugin : activePlugins) {
|
||||
for (OsmandPlugin plugin : getEnabledPlugins()) {
|
||||
plugin.registerOptionsMenuItems(map, helper);
|
||||
}
|
||||
}
|
||||
public static void onUpdateLocalIndexDescription(LocalIndexInfo info) {
|
||||
for (OsmandPlugin plugin : activePlugins) {
|
||||
for (OsmandPlugin plugin : getEnabledPlugins()) {
|
||||
plugin.updateLocalIndexDescription(info);
|
||||
}
|
||||
}
|
||||
|
||||
public static void onLoadLocalIndexes(List<LocalIndexInfo> result, LoadLocalIndexTask loadTask) {
|
||||
for (OsmandPlugin plugin : activePlugins) {
|
||||
for (OsmandPlugin plugin : getEnabledPlugins()) {
|
||||
plugin.loadLocalIndexes(result, loadTask);
|
||||
}
|
||||
}
|
||||
|
||||
public static void onContextMenuActivity(Activity activity, Fragment fragment, Object info, ContextMenuAdapter adapter) {
|
||||
for (OsmandPlugin plugin : activePlugins) {
|
||||
for (OsmandPlugin plugin : getEnabledPlugins()) {
|
||||
plugin.contextMenuLocalIndexes(activity, fragment, info, adapter);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void onOptionsMenuActivity(Activity activity, Fragment fragment, ContextMenuAdapter optionsMenuAdapter) {
|
||||
for (OsmandPlugin plugin : activePlugins) {
|
||||
for (OsmandPlugin plugin : getEnabledPlugins()) {
|
||||
plugin.optionsMenuLocalIndexes(activity, fragment, optionsMenuAdapter);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static boolean installPlugin(String packageInfo,
|
||||
String pluginId, OsmandApplication app, OsmandPlugin plugin) {
|
||||
private static boolean isPackageInstalled(String packageInfo,
|
||||
OsmandApplication app) {
|
||||
if(packageInfo == null) {
|
||||
return false;
|
||||
}
|
||||
boolean installed = false;
|
||||
try{
|
||||
installed = app.getPackageManager().getPackageInfo(packageInfo, 0) != null;
|
||||
} catch ( NameNotFoundException e){
|
||||
}
|
||||
|
||||
|
||||
if(installed) {
|
||||
installedPlugins.add(plugin);
|
||||
if(!app.getSettings().getPlugins().contains("-"+pluginId)) {
|
||||
app.getSettings().enablePlugin(pluginId, true);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
if(app.getSettings().getPlugins().contains(pluginId)) {
|
||||
app.getSettings().enablePlugin(pluginId, false);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return installed;
|
||||
}
|
||||
|
||||
public static boolean onMapActivityKeyUp(MapActivity mapActivity, int keyCode) {
|
||||
for(OsmandPlugin p : installedPlugins){
|
||||
for(OsmandPlugin p : getEnabledPlugins()){
|
||||
if(p.mapActivityKeyUp(mapActivity, keyCode))
|
||||
return true;
|
||||
}
|
||||
|
@ -336,7 +361,7 @@ public abstract class OsmandPlugin {
|
|||
}
|
||||
|
||||
public static void updateLocationPlugins(net.osmand.Location location) {
|
||||
for(OsmandPlugin p : installedPlugins){
|
||||
for(OsmandPlugin p : getEnabledPlugins()){
|
||||
p.updateLocation(location);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ public class Version {
|
|||
|
||||
|
||||
public static boolean isGpsStatusEnabled(OsmandApplication ctx) {
|
||||
return ctx.getString(R.string.versionFeatures).contains("+gps_status") && !isBlackberry(ctx);
|
||||
return isGooglePlayEnabled(ctx) && !isBlackberry(ctx);
|
||||
}
|
||||
|
||||
public static boolean isBlackberry(OsmandApplication ctx) {
|
||||
|
@ -41,18 +41,6 @@ public class Version {
|
|||
return ctx.getString(R.string.versionFeatures).contains("+play_market");
|
||||
}
|
||||
|
||||
public static boolean isFreeVersionEnabled(OsmandApplication ctx) {
|
||||
return ctx.getString(R.string.versionFeatures).contains("+free_version");
|
||||
}
|
||||
|
||||
public static boolean isParkingPluginInlined(OsmandApplication ctx) {
|
||||
return ctx.getString(R.string.versionFeatures).contains("+parking_plugin");
|
||||
}
|
||||
|
||||
public static boolean isRouteNavPluginInlined(OsmandApplication ctx) {
|
||||
return ctx.getString(R.string.versionFeatures).contains("+route_nav");
|
||||
}
|
||||
|
||||
public static boolean isSherpafy(OsmandApplication ctx) {
|
||||
return ctx.getPackageName().equals(SHERPAFY_VERSION_NAME);
|
||||
}
|
||||
|
@ -103,7 +91,7 @@ public class Version {
|
|||
}
|
||||
|
||||
public static boolean isFreeVersion(OsmandApplication ctx){
|
||||
return ctx.getPackageName().equals(FREE_VERSION_NAME) || isFreeVersionEnabled(ctx);
|
||||
return ctx.getPackageName().equals(FREE_VERSION_NAME);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,6 @@ public class PluginActivity extends OsmandActionBarActivity {
|
|||
finish();
|
||||
return;
|
||||
}
|
||||
boolean isEnabled = OsmandPlugin.getEnabledPlugins().contains(plugin);
|
||||
|
||||
setContentView(R.layout.plugin);
|
||||
getSupportActionBar().setTitle(plugin.getName());
|
||||
|
@ -64,7 +63,7 @@ public class PluginActivity extends OsmandActionBarActivity {
|
|||
if (settingsActivity == null) {
|
||||
settingsButton.setVisibility(View.GONE);
|
||||
} else {
|
||||
settingsButton.setEnabled(isEnabled);
|
||||
settingsButton.setEnabled(plugin.isActive());
|
||||
settingsButton.setVisibility(View.VISIBLE);
|
||||
settingsButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -76,13 +75,12 @@ public class PluginActivity extends OsmandActionBarActivity {
|
|||
|
||||
CompoundButton enableDisableButton = (CompoundButton)findViewById(
|
||||
R.id.plugin_enable_disable);
|
||||
enableDisableButton.setChecked(isEnabled);
|
||||
enableDisableButton.setChecked(plugin.isActive());
|
||||
enableDisableButton.setOnCheckedChangeListener(
|
||||
new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
boolean isEnabled = OsmandPlugin.getEnabledPlugins().contains(plugin);
|
||||
if (isEnabled == isChecked) {
|
||||
if (plugin.isActive() == isChecked) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -99,8 +97,7 @@ public class PluginActivity extends OsmandActionBarActivity {
|
|||
|
||||
CompoundButton enableDisableButton = (CompoundButton)findViewById(
|
||||
R.id.plugin_enable_disable);
|
||||
boolean isEnabled = OsmandPlugin.getEnabledPlugins().contains(plugin);
|
||||
enableDisableButton.setChecked(isEnabled);
|
||||
enableDisableButton.setChecked(plugin.isActive());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -77,7 +77,6 @@ public class PluginsActivity extends OsmandListActivity {
|
|||
}
|
||||
|
||||
final OsmandPlugin plugin = getItem(position);
|
||||
final boolean isEnabled = OsmandPlugin.getEnabledPlugins().contains(plugin);
|
||||
|
||||
view.setTag(plugin);
|
||||
|
||||
|
@ -86,7 +85,7 @@ public class PluginsActivity extends OsmandListActivity {
|
|||
|
||||
TextView pluginName = (TextView)view.findViewById(R.id.plugin_name);
|
||||
pluginName.setText(plugin.getName());
|
||||
pluginName.setContentDescription(plugin.getName() + " " + getString(isEnabled
|
||||
pluginName.setContentDescription(plugin.getName() + " " + getString(plugin.isActive()
|
||||
? R.string.item_checked
|
||||
: R.string.item_unchecked));
|
||||
|
||||
|
@ -94,7 +93,7 @@ public class PluginsActivity extends OsmandListActivity {
|
|||
pluginDescription.setText(plugin.getDescription());
|
||||
|
||||
View pluginIsEnabled = view.findViewById(R.id.plugin_is_enabled);
|
||||
pluginIsEnabled.setVisibility(isEnabled ? View.VISIBLE : View.INVISIBLE);
|
||||
pluginIsEnabled.setVisibility(plugin.isActive() ? View.VISIBLE : View.INVISIBLE);
|
||||
|
||||
View pluginOptions = view.findViewById(R.id.plugin_options);
|
||||
pluginOptions.setOnClickListener(new View.OnClickListener() {
|
||||
|
@ -109,18 +108,17 @@ public class PluginsActivity extends OsmandListActivity {
|
|||
}
|
||||
|
||||
private void showOptionsMenu(View v, final OsmandPlugin plugin) {
|
||||
final boolean isEnabled = OsmandPlugin.getEnabledPlugins().contains(plugin);
|
||||
final Class<? extends Activity> settingsActivity = plugin.getSettingsActivity();
|
||||
|
||||
final PopupMenu optionsMenu = new PopupMenu(this, v);
|
||||
|
||||
MenuItem enableDisableItem = optionsMenu.getMenu().add(isEnabled
|
||||
MenuItem enableDisableItem = optionsMenu.getMenu().add(plugin.isActive()
|
||||
? R.string.disable_plugin
|
||||
: R.string.enable_plugin);
|
||||
enableDisableItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
enableDisablePlugin(plugin, !isEnabled);
|
||||
enableDisablePlugin(plugin, !plugin.isActive());
|
||||
optionsMenu.dismiss();
|
||||
return true;
|
||||
}
|
||||
|
@ -136,7 +134,7 @@ public class PluginsActivity extends OsmandListActivity {
|
|||
return true;
|
||||
}
|
||||
});
|
||||
settingsItem.setEnabled(isEnabled);
|
||||
settingsItem.setEnabled(plugin.isActive());
|
||||
}
|
||||
|
||||
optionsMenu.show();
|
||||
|
|
|
@ -1,21 +1,25 @@
|
|||
package net.osmand.plus.dashboard;
|
||||
package net.osmand.plus.audionotes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.OsmandActionBarActivity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.view.*;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.OsmandActionBarActivity;
|
||||
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by Denis
|
|
@ -1,5 +1,13 @@
|
|||
package net.osmand.plus.dashboard;
|
||||
package net.osmand.plus.audionotes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.dashboard.DashBaseFragment;
|
||||
import net.osmand.plus.helpers.FontCache;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
@ -14,15 +22,6 @@ import android.widget.ImageView;
|
|||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
|
||||
import net.osmand.plus.helpers.FontCache;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by Denis
|
||||
* on 15.12.2014.
|
|
@ -6,7 +6,6 @@ import net.osmand.plus.OsmandPlugin;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.PluginActivity;
|
||||
import net.osmand.plus.development.OsmandDevelopmentPlugin;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
@ -28,12 +27,9 @@ public class DashPluginsFragment extends DashBaseFragment {
|
|||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
OsmandPlugin plugin = (OsmandPlugin)buttonView.getTag();
|
||||
boolean isEnabled = OsmandPlugin.getEnabledPlugins().contains(plugin);
|
||||
|
||||
if (isEnabled == isChecked) {
|
||||
if (plugin.isActive() == isChecked) {
|
||||
return;
|
||||
}
|
||||
|
||||
OsmandPlugin.enablePlugin(getMyApplication(), plugin, isChecked);
|
||||
}
|
||||
};
|
||||
|
@ -72,7 +68,7 @@ public class DashPluginsFragment extends DashBaseFragment {
|
|||
});
|
||||
|
||||
LinearLayout pluginsContainer = (LinearLayout) contentView.findViewById(R.id.plugins);
|
||||
List<OsmandPlugin> enabledPlugins = OsmandPlugin.getEnabledPlugins();
|
||||
List<OsmandPlugin> enabledPlugins = OsmandPlugin.getAvailablePlugins();
|
||||
for(OsmandPlugin plugin : enabledPlugins) {
|
||||
if (plugin instanceof OsmandDevelopmentPlugin) {
|
||||
continue;
|
||||
|
@ -107,11 +103,10 @@ public class DashPluginsFragment extends DashBaseFragment {
|
|||
}
|
||||
LinearLayout pluginsContainer = (LinearLayout) contentView.findViewById(R.id.plugins);
|
||||
|
||||
List<OsmandPlugin> enabledPlugins = OsmandPlugin.getEnabledPlugins();
|
||||
for (int pluginIndex = 0; pluginIndex < pluginsContainer.getChildCount(); pluginIndex++) {
|
||||
View pluginView = pluginsContainer.getChildAt(pluginIndex);
|
||||
OsmandPlugin plugin = (OsmandPlugin)pluginView.getTag();
|
||||
boolean isEnabled = enabledPlugins.contains(plugin);
|
||||
boolean isEnabled = plugin.isActive();
|
||||
|
||||
CompoundButton enableDisableButton = (CompoundButton) pluginView.findViewById(
|
||||
R.id.check_item);
|
||||
|
@ -121,7 +116,6 @@ public class DashPluginsFragment extends DashBaseFragment {
|
|||
|
||||
private void inflatePluginView(LayoutInflater inflater, ViewGroup container,
|
||||
OsmandPlugin plugin) {
|
||||
boolean isEnabled = OsmandPlugin.getEnabledPlugins().contains(plugin);
|
||||
|
||||
View view = inflater.inflate(R.layout.dash_plugin_item, container, false);
|
||||
view.setTag(plugin);
|
||||
|
@ -143,7 +137,7 @@ public class DashPluginsFragment extends DashBaseFragment {
|
|||
|
||||
CompoundButton enableDisableButton = (CompoundButton)view.findViewById(R.id.check_item);
|
||||
enableDisableButton.setTag(plugin);
|
||||
enableDisableButton.setChecked(isEnabled);
|
||||
enableDisableButton.setChecked(plugin.isActive());
|
||||
enableDisableButton.setOnCheckedChangeListener(enableDisableListener);
|
||||
|
||||
container.addView(view);
|
||||
|
|
|
@ -305,7 +305,6 @@ public class DownloadIndexFragment extends OsmandExpandableListFragment {
|
|||
public void categorizationFinished(List<IndexItem> filtered, List<IndexItemCategory> cats) {
|
||||
Map<String, String> indexActivatedFileNames = getDownloadActivity().getIndexActivatedFileNames();
|
||||
Map<String, String> indexFileNames = getDownloadActivity().getIndexFileNames();
|
||||
DownloadActivityType type = getDownloadActivity().getDownloadType();
|
||||
DownloadIndexAdapter a = ((DownloadIndexAdapter) getExpandableListAdapter());
|
||||
if (a == null){
|
||||
return;
|
||||
|
@ -314,25 +313,5 @@ public class DownloadIndexFragment extends OsmandExpandableListFragment {
|
|||
a.setIndexFiles(filtered, cats);
|
||||
a.notifyDataSetChanged();
|
||||
a.getFilter().filter(getFilterText());
|
||||
if ((type == DownloadActivityType.SRTM_COUNTRY_FILE || type == DownloadActivityType.HILLSHADE_FILE)
|
||||
&& OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) instanceof SRTMPlugin
|
||||
&& !OsmandPlugin.getEnabledPlugin(SRTMPlugin.class).isPaid()) {
|
||||
AlertDialog.Builder msg = new AlertDialog.Builder(getDownloadActivity());
|
||||
msg.setTitle(R.string.srtm_paid_version_title);
|
||||
msg.setMessage(R.string.srtm_paid_version_msg);
|
||||
msg.setNegativeButton(R.string.button_upgrade_osmandplus, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pname:net.osmand.srtmPlugin.paid"));
|
||||
try {
|
||||
getDownloadActivity().startActivity(intent);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
}
|
||||
}
|
||||
});
|
||||
msg.setPositiveButton(R.string.default_buttons_ok, null);
|
||||
msg.show();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,15 @@
|
|||
package net.osmand.plus.dashboard;
|
||||
package net.osmand.plus.monitoring;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.OsmAndAppCustomization;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.dashboard.DashBaseFragment;
|
||||
import net.osmand.plus.helpers.FontCache;
|
||||
import net.osmand.plus.helpers.GpxUiHelper;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
|
@ -10,15 +20,6 @@ import android.view.ViewGroup;
|
|||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.OsmAndAppCustomization;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.helpers.FontCache;
|
||||
import net.osmand.plus.helpers.GpxUiHelper;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by Denis
|
|
@ -0,0 +1,45 @@
|
|||
package net.osmand.plus.openseamapsplugin;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import android.app.Activity;
|
||||
|
||||
public class OpenSeaMapsPlugin extends OsmandPlugin {
|
||||
|
||||
public static final String ID = "openseamaps.plugin";
|
||||
public static final String COMPONENT = "net.osmand.openseamapsPlugin";
|
||||
private OsmandApplication app;
|
||||
|
||||
|
||||
public OpenSeaMapsPlugin(OsmandApplication app) {
|
||||
this.app = app;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "This will be a plugin enabling openseamaps (TODO)";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Open Sea Maps";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean init(final OsmandApplication app) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class<? extends Activity> getSettingsActivity() {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,9 @@
|
|||
package net.osmand.plus.dashboard;
|
||||
package net.osmand.plus.osmedit;
|
||||
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.dashboard.DashBaseFragment;
|
||||
import net.osmand.plus.helpers.FontCache;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -7,10 +11,6 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.helpers.FontCache;
|
||||
import net.osmand.plus.osmedit.OsmEditingPlugin;
|
||||
|
||||
/**
|
||||
* Created by Denis
|
|
@ -1,5 +1,9 @@
|
|||
package net.osmand.plus.dashboard;
|
||||
package net.osmand.plus.osmo;
|
||||
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.dashboard.DashBaseFragment;
|
||||
import net.osmand.plus.helpers.FontCache;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -7,10 +11,6 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.helpers.FontCache;
|
||||
import net.osmand.plus.osmo.OsMoPlugin;
|
||||
|
||||
/**
|
||||
* Created by Denis
|
|
@ -1,4 +1,4 @@
|
|||
package net.osmand.plus.dashboard;
|
||||
package net.osmand.plus.parkingpoint;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
|
@ -15,8 +15,8 @@ import net.osmand.data.LatLon;
|
|||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.dashboard.DashLocationFragment;
|
||||
import net.osmand.plus.helpers.FontCache;
|
||||
import net.osmand.plus.parkingpoint.ParkingPositionPlugin;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
/**
|
|
@ -43,6 +43,7 @@ import android.widget.TimePicker;
|
|||
public class ParkingPositionPlugin extends OsmandPlugin {
|
||||
|
||||
public static final String ID = "osmand.parking.position";
|
||||
public static final String PARKING_PLUGIN_COMPONENT = "net.osmand.parkingPlugin"; //$NON-NLS-1$
|
||||
public final static String PARKING_POINT_LAT = "parking_point_lat"; //$NON-NLS-1$
|
||||
public final static String PARKING_POINT_LON = "parking_point_lon"; //$NON-NLS-1$
|
||||
public final static String PARKING_TYPE = "parking_type"; //$NON-NLS-1$
|
||||
|
|
|
@ -35,7 +35,7 @@ import android.view.View;
|
|||
public class RoutePointsPlugin extends OsmandPlugin {
|
||||
|
||||
public static final String ID = "osmand.route.stepsPlugin";
|
||||
|
||||
public static final String ROUTE_POINTS_PLUGIN_COMPONENT = "net.osmand.routePointsPlugin";
|
||||
private static final String VISITED_KEY = "VISITED_KEY";
|
||||
private static final String DELIVERED_KEY = "DELIVERED_KEY";
|
||||
|
||||
|
|
43
OsmAnd/src/net/osmand/plus/skimapsplugin/SkiMapsPlugin.java
Normal file
43
OsmAnd/src/net/osmand/plus/skimapsplugin/SkiMapsPlugin.java
Normal file
|
@ -0,0 +1,43 @@
|
|||
package net.osmand.plus.skimapsplugin;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import android.app.Activity;
|
||||
|
||||
public class SkiMapsPlugin extends OsmandPlugin {
|
||||
|
||||
public static final String ID = "skimaps.plugin";
|
||||
public static final String COMPONENT = "net.osmand.skimapsPlugin";
|
||||
private OsmandApplication app;
|
||||
|
||||
public SkiMapsPlugin(OsmandApplication app) {
|
||||
this.app = app;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "This will be a plugin enabling ski maps (TODO)";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Ski Maps";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean init(final OsmandApplication app) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class<? extends Activity> getSettingsActivity() {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -27,24 +27,10 @@ public class SRTMPlugin extends OsmandPlugin {
|
|||
return paid ? ID : FREE_ID;
|
||||
}
|
||||
|
||||
public SRTMPlugin(OsmandApplication app, boolean paid) {
|
||||
public SRTMPlugin(OsmandApplication app) {
|
||||
this.app = app;
|
||||
this.paid = paid;
|
||||
OsmandSettings settings = app.getSettings();
|
||||
CommonPreference<String> pref = settings.getCustomRenderProperty("contourLines");
|
||||
if(pref.get().equals("")) {
|
||||
for(ApplicationMode m : ApplicationMode.allPossibleValues()) {
|
||||
if(pref.getModeValue(m).equals("")) {
|
||||
pref.setModeValue(m, "13");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean isPaid() {
|
||||
return paid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
|
@ -59,6 +45,15 @@ public class SRTMPlugin extends OsmandPlugin {
|
|||
@Override
|
||||
public boolean init(final OsmandApplication app) {
|
||||
HILLSHADE = app.getSettings().registerBooleanPreference("hillshade_layer", true);
|
||||
OsmandSettings settings = app.getSettings();
|
||||
CommonPreference<String> pref = settings.getCustomRenderProperty("contourLines");
|
||||
if(pref.get().equals("")) {
|
||||
for(ApplicationMode m : ApplicationMode.allPossibleValues()) {
|
||||
if(pref.getModeValue(m).equals("")) {
|
||||
pref.setModeValue(m, "13");
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue