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:
Victor Shcherb 2015-07-04 17:28:42 +03:00
parent 5b1aff575d
commit 5e2b0b013d
14 changed files with 47 additions and 110 deletions

View file

@ -14,11 +14,6 @@ public class AccessibilityPlugin extends OsmandPlugin {
this.app = app;
}
@Override
public boolean init(OsmandApplication app, Activity activity) {
return true;
}
@Override
public String getId() {
return ID;

View file

@ -64,9 +64,10 @@ public abstract class OsmandPlugin {
/**
* 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) {
this.active = active;

View file

@ -446,8 +446,6 @@ public class SettingsGeneralActivity extends SettingsBaseActivity {
return true;
}
private void warnAboutChangingStorage(final String newValue) {
String newDir = newValue != null ? newValue.trim() : newValue;
if(!newDir.replace('/', ' ').trim().

View file

@ -4,16 +4,11 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.SettingsActivity;
import net.osmand.plus.views.MapInfoLayer;
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.mapwidgets.TextInfoWidget;
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 {
private static final String ID = "osmand.development";
@ -25,10 +20,6 @@ public class OsmandDevelopmentPlugin extends OsmandPlugin {
//ApplicationMode.regWidget("fps", new ApplicationMode[0]);
}
@Override
public boolean init(OsmandApplication app, Activity activity) {
return true;
}
@Override
public String getId() {

View file

@ -97,8 +97,23 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
}
@Override
public boolean init(OsmandApplication app, Activity activity) {
return true;
public void updateLayers(OsmandMapTileView mapView, MapActivity activity) {
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

View file

@ -55,6 +55,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
liveMonitoringHelper = new LiveMonitoringHelper(app);
final List<ApplicationMode> am = ApplicationMode.allPossibleValues();
ApplicationMode.regWidget("monitoring", am.toArray(new ApplicationMode[am.size()]));
settings = app.getSettings();
}
@Override
@ -72,12 +73,6 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
return R.drawable.trip_recording;
}
@Override
public boolean init(OsmandApplication app, Activity activity) {
settings = app.getSettings();
return true;
}
@Override
public String getId() {
return ID;

View file

@ -63,12 +63,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
public OsmEditingPlugin(OsmandApplication app) {
this.app = app;
}
@Override
public boolean init(OsmandApplication app, Activity activity) {
settings = app.getSettings();
return true;
}
private OsmBugsLayer osmBugsLayer;

View file

@ -144,12 +144,6 @@ public class ParkingPositionPlugin extends OsmandPlugin {
return true;
}
@Override
public boolean init(OsmandApplication app, Activity activity) {
return true;
}
@Override
public String getId() {
return ID;

View file

@ -50,12 +50,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
public OsmandRasterMapsPlugin(OsmandApplication app) {
this.app = app;
}
@Override
public boolean init(OsmandApplication app, Activity activity) {
settings = app.getSettings();
return true;
}
@Override

View file

@ -190,11 +190,6 @@ public class RoutePointsPlugin extends OsmandPlugin {
return app.getString(R.string.route_plugin_name);
}
@Override
public boolean init(OsmandApplication app, Activity activity) {
return true;
}
private void registerWidget(MapActivity activity) {
MapInfoLayer mapInfoLayer = activity.getMapLayers().getMapInfoLayer();
if (mapInfoLayer != null) {

View file

@ -29,6 +29,7 @@ public class SRTMPlugin extends OsmandPlugin {
public SRTMPlugin(OsmandApplication app) {
this.app = app;
HILLSHADE = app.getSettings().registerBooleanPreference("hillshade_layer", true);
}
@Override
@ -54,7 +55,6 @@ public class SRTMPlugin extends OsmandPlugin {
@Override
public boolean init(final OsmandApplication app, Activity activity) {
HILLSHADE = app.getSettings().registerBooleanPreference("hillshade_layer", true);
OsmandSettings settings = app.getSettings();
CommonPreference<String> pref = settings.getCustomRenderProperty("contourLines");
if(pref.get().equals("")) {

View file

@ -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;
}
}

View file

@ -82,6 +82,10 @@ public class MapInfoLayer extends OsmandMapLayer {
updateReg(calculateTextState(), reg);
}
public void removeSideWidget(TextInfoWidget widget) {
mapInfoControls.removeSideWidgetInternal(widget);
}
public void registerAllControls(){
RouteInfoWidgetsFactory ric = new RouteInfoWidgetsFactory();
MapInfoWidgetsFactory mic = new MapInfoWidgetsFactory();
@ -305,4 +309,6 @@ public class MapInfoLayer extends OsmandMapLayer {
}

View file

@ -1,6 +1,7 @@
package net.osmand.plus.views.mapwidgets;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
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,
int messageId, String key, boolean left, int priorityOrder) {
MapWidgetRegInfo ii = new MapWidgetRegInfo(key, widget, drawableMenu,