Fix crash & change app theme
Conflicts: OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java OsmAnd/src/net/osmand/plus/distancecalculator/DistanceCalculatorPlugin.java
This commit is contained in:
parent
5b1aff575d
commit
5e2b0b013d
14 changed files with 47 additions and 110 deletions
|
@ -14,11 +14,6 @@ public class AccessibilityPlugin extends OsmandPlugin {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean init(OsmandApplication app, Activity activity) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return ID;
|
return ID;
|
||||||
|
|
|
@ -64,9 +64,10 @@ public abstract class OsmandPlugin {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize plugin runs just after creation
|
* Initialize plugin runs just after creation
|
||||||
* @param activity TODO
|
|
||||||
*/
|
*/
|
||||||
public abstract boolean init(OsmandApplication app, Activity activity);
|
public boolean init(OsmandApplication app, Activity activity) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public void setActive(boolean active) {
|
public void setActive(boolean active) {
|
||||||
this.active = active;
|
this.active = active;
|
||||||
|
|
|
@ -446,8 +446,6 @@ public class SettingsGeneralActivity extends SettingsBaseActivity {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void warnAboutChangingStorage(final String newValue) {
|
private void warnAboutChangingStorage(final String newValue) {
|
||||||
String newDir = newValue != null ? newValue.trim() : newValue;
|
String newDir = newValue != null ? newValue.trim() : newValue;
|
||||||
if(!newDir.replace('/', ' ').trim().
|
if(!newDir.replace('/', ' ').trim().
|
||||||
|
|
|
@ -4,16 +4,11 @@ import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.activities.SettingsActivity;
|
|
||||||
import net.osmand.plus.views.MapInfoLayer;
|
import net.osmand.plus.views.MapInfoLayer;
|
||||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
import net.osmand.plus.views.mapwidgets.TextInfoWidget;
|
import net.osmand.plus.views.mapwidgets.TextInfoWidget;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
|
||||||
import android.preference.Preference;
|
|
||||||
import android.preference.Preference.OnPreferenceClickListener;
|
|
||||||
import android.preference.PreferenceScreen;
|
|
||||||
|
|
||||||
public class OsmandDevelopmentPlugin extends OsmandPlugin {
|
public class OsmandDevelopmentPlugin extends OsmandPlugin {
|
||||||
private static final String ID = "osmand.development";
|
private static final String ID = "osmand.development";
|
||||||
|
@ -25,10 +20,6 @@ public class OsmandDevelopmentPlugin extends OsmandPlugin {
|
||||||
//ApplicationMode.regWidget("fps", new ApplicationMode[0]);
|
//ApplicationMode.regWidget("fps", new ApplicationMode[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean init(OsmandApplication app, Activity activity) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getId() {
|
public String getId() {
|
||||||
|
|
|
@ -97,8 +97,23 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean init(OsmandApplication app, Activity activity) {
|
public void updateLayers(OsmandMapTileView mapView, MapActivity activity) {
|
||||||
return true;
|
if(isActive()) {
|
||||||
|
if(!mapView.isLayerVisible(distanceCalculatorLayer)) {
|
||||||
|
activity.getMapView().addLayer(distanceCalculatorLayer, 4.5f);
|
||||||
|
}
|
||||||
|
registerWidget(activity);
|
||||||
|
} else {
|
||||||
|
MapInfoLayer mapInfoLayer = activity.getMapLayers().getMapInfoLayer();
|
||||||
|
if(distanceCalculatorLayer != null) {
|
||||||
|
activity.getMapView().removeLayer(distanceCalculatorLayer);
|
||||||
|
}
|
||||||
|
if (mapInfoLayer != null && distanceControl != null ) {
|
||||||
|
mapInfoLayer.removeSideWidget(distanceControl);
|
||||||
|
mapInfoLayer.recreateControls();
|
||||||
|
distanceControl = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -55,6 +55,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
||||||
liveMonitoringHelper = new LiveMonitoringHelper(app);
|
liveMonitoringHelper = new LiveMonitoringHelper(app);
|
||||||
final List<ApplicationMode> am = ApplicationMode.allPossibleValues();
|
final List<ApplicationMode> am = ApplicationMode.allPossibleValues();
|
||||||
ApplicationMode.regWidget("monitoring", am.toArray(new ApplicationMode[am.size()]));
|
ApplicationMode.regWidget("monitoring", am.toArray(new ApplicationMode[am.size()]));
|
||||||
|
settings = app.getSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -72,12 +73,6 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
||||||
return R.drawable.trip_recording;
|
return R.drawable.trip_recording;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean init(OsmandApplication app, Activity activity) {
|
|
||||||
settings = app.getSettings();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return ID;
|
return ID;
|
||||||
|
|
|
@ -63,12 +63,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
||||||
|
|
||||||
public OsmEditingPlugin(OsmandApplication app) {
|
public OsmEditingPlugin(OsmandApplication app) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean init(OsmandApplication app, Activity activity) {
|
|
||||||
settings = app.getSettings();
|
settings = app.getSettings();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private OsmBugsLayer osmBugsLayer;
|
private OsmBugsLayer osmBugsLayer;
|
||||||
|
|
|
@ -144,12 +144,6 @@ public class ParkingPositionPlugin extends OsmandPlugin {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean init(OsmandApplication app, Activity activity) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return ID;
|
return ID;
|
||||||
|
|
|
@ -50,12 +50,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
||||||
|
|
||||||
public OsmandRasterMapsPlugin(OsmandApplication app) {
|
public OsmandRasterMapsPlugin(OsmandApplication app) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean init(OsmandApplication app, Activity activity) {
|
|
||||||
settings = app.getSettings();
|
settings = app.getSettings();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -190,11 +190,6 @@ public class RoutePointsPlugin extends OsmandPlugin {
|
||||||
return app.getString(R.string.route_plugin_name);
|
return app.getString(R.string.route_plugin_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean init(OsmandApplication app, Activity activity) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void registerWidget(MapActivity activity) {
|
private void registerWidget(MapActivity activity) {
|
||||||
MapInfoLayer mapInfoLayer = activity.getMapLayers().getMapInfoLayer();
|
MapInfoLayer mapInfoLayer = activity.getMapLayers().getMapInfoLayer();
|
||||||
if (mapInfoLayer != null) {
|
if (mapInfoLayer != null) {
|
||||||
|
|
|
@ -29,6 +29,7 @@ public class SRTMPlugin extends OsmandPlugin {
|
||||||
|
|
||||||
public SRTMPlugin(OsmandApplication app) {
|
public SRTMPlugin(OsmandApplication app) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
|
HILLSHADE = app.getSettings().registerBooleanPreference("hillshade_layer", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -54,7 +55,6 @@ public class SRTMPlugin extends OsmandPlugin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean init(final OsmandApplication app, Activity activity) {
|
public boolean init(final OsmandApplication app, Activity activity) {
|
||||||
HILLSHADE = app.getSettings().registerBooleanPreference("hillshade_layer", true);
|
|
||||||
OsmandSettings settings = app.getSettings();
|
OsmandSettings settings = app.getSettings();
|
||||||
CommonPreference<String> pref = settings.getCustomRenderProperty("contourLines");
|
CommonPreference<String> pref = settings.getCustomRenderProperty("contourLines");
|
||||||
if(pref.get().equals("")) {
|
if(pref.get().equals("")) {
|
||||||
|
|
|
@ -1,62 +0,0 @@
|
||||||
package net.osmand.plus.touringview;
|
|
||||||
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
|
||||||
import net.osmand.plus.OsmandPlugin;
|
|
||||||
import net.osmand.plus.R;
|
|
||||||
import net.osmand.plus.render.RendererRegistry;
|
|
||||||
import android.app.Activity;
|
|
||||||
|
|
||||||
public class TouringViewPlugin extends OsmandPlugin {
|
|
||||||
|
|
||||||
public static final String ID = "touringView.plugin";
|
|
||||||
public static final String COMPONENT = "net.osmand.touringviewPlugin";
|
|
||||||
private static String previousRenderer = RendererRegistry.DEFAULT_RENDER;
|
|
||||||
private OsmandApplication app;
|
|
||||||
|
|
||||||
public TouringViewPlugin(OsmandApplication app) {
|
|
||||||
this.app = app;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDescription() {
|
|
||||||
return app.getString(net.osmand.plus.R.string.plugin_touringview_descr);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getAssetResourceName() {
|
|
||||||
return R.drawable.touring_map_view;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return app.getString(net.osmand.plus.R.string.plugin_touringview_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean init(final OsmandApplication app, final Activity activity) {
|
|
||||||
if(activity != null) {
|
|
||||||
// called from UI
|
|
||||||
previousRenderer = app.getSettings().RENDERER.get();
|
|
||||||
app.getSettings().RENDERER.set(RendererRegistry.TOURING_VIEW);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void disable(OsmandApplication app) {
|
|
||||||
super.disable(app);
|
|
||||||
if(app.getSettings().RENDERER.get().equals(RendererRegistry.TOURING_VIEW)) {
|
|
||||||
app.getSettings().RENDERER.set(previousRenderer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getId() {
|
|
||||||
return ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<? extends Activity> getSettingsActivity() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -82,6 +82,10 @@ public class MapInfoLayer extends OsmandMapLayer {
|
||||||
updateReg(calculateTextState(), reg);
|
updateReg(calculateTextState(), reg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removeSideWidget(TextInfoWidget widget) {
|
||||||
|
mapInfoControls.removeSideWidgetInternal(widget);
|
||||||
|
}
|
||||||
|
|
||||||
public void registerAllControls(){
|
public void registerAllControls(){
|
||||||
RouteInfoWidgetsFactory ric = new RouteInfoWidgetsFactory();
|
RouteInfoWidgetsFactory ric = new RouteInfoWidgetsFactory();
|
||||||
MapInfoWidgetsFactory mic = new MapInfoWidgetsFactory();
|
MapInfoWidgetsFactory mic = new MapInfoWidgetsFactory();
|
||||||
|
@ -299,6 +303,8 @@ public class MapInfoLayer extends OsmandMapLayer {
|
||||||
return defValue;
|
return defValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.osmand.plus.views.mapwidgets;
|
package net.osmand.plus.views.mapwidgets;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -89,6 +90,24 @@ public class MapWidgetRegistry {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void removeSideWidgetInternal(TextInfoWidget widget) {
|
||||||
|
Iterator<MapWidgetRegInfo> it = left.iterator();
|
||||||
|
while (it.hasNext()) {
|
||||||
|
if (it.next().widget == widget) {
|
||||||
|
it.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
it = right.iterator();
|
||||||
|
while (it.hasNext()) {
|
||||||
|
if (it.next().widget == widget) {
|
||||||
|
it.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public MapWidgetRegInfo registerSideWidgetInternal(TextInfoWidget widget, int drawableMenu,
|
public MapWidgetRegInfo registerSideWidgetInternal(TextInfoWidget widget, int drawableMenu,
|
||||||
int messageId, String key, boolean left, int priorityOrder) {
|
int messageId, String key, boolean left, int priorityOrder) {
|
||||||
MapWidgetRegInfo ii = new MapWidgetRegInfo(key, widget, drawableMenu,
|
MapWidgetRegInfo ii = new MapWidgetRegInfo(key, widget, drawableMenu,
|
||||||
|
|
Loading…
Reference in a new issue