Remove extra settings plugin
This commit is contained in:
parent
37712a8a42
commit
f4b65ef81a
6 changed files with 293 additions and 293 deletions
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<module type="JAVA_MODULE" version="4">
|
<module type="JAVA_MODULE" version="4">
|
||||||
<component name="EclipseModuleManager" forced_jdk="true">
|
<component name="EclipseModuleManager" forced_jdk="true">
|
||||||
<varelement var="file://$OSMAND_TRUNK$/OsmAnd-java/src" kind="linksrc:" value="use" />
|
<varelement var="file://$OSMAND_TRUNK$/OsmAnd-java/src" value="linksrc:use" />
|
||||||
<conelement value="com.android.ide.eclipse.adt.DEPENDENCIES" />
|
<conelement value="com.android.ide.eclipse.adt.DEPENDENCIES" />
|
||||||
<src_description expected_position="1">
|
<src_description expected_position="1">
|
||||||
<src_folder value="file://$MODULE_DIR$/src" expected_position="0" />
|
<src_folder value="file://$MODULE_DIR$/src" expected_position="0" />
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
package net.osmand.plus;
|
package net.osmand.plus;
|
||||||
|
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
import java.util.ArrayList;
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import java.util.List;
|
import android.preference.PreferenceScreen;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import net.osmand.IProgress;
|
import net.osmand.IProgress;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.access.AccessibilityPlugin;
|
import net.osmand.access.AccessibilityPlugin;
|
||||||
|
@ -17,7 +15,6 @@ import net.osmand.plus.activities.SettingsActivity;
|
||||||
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
|
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
|
||||||
import net.osmand.plus.development.OsmandDevelopmentPlugin;
|
import net.osmand.plus.development.OsmandDevelopmentPlugin;
|
||||||
import net.osmand.plus.distancecalculator.DistanceCalculatorPlugin;
|
import net.osmand.plus.distancecalculator.DistanceCalculatorPlugin;
|
||||||
import net.osmand.plus.extrasettings.OsmandExtraSettings;
|
|
||||||
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
|
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
|
||||||
import net.osmand.plus.osmedit.OsmEditingPlugin;
|
import net.osmand.plus.osmedit.OsmEditingPlugin;
|
||||||
import net.osmand.plus.osmodroid.OsMoDroidPlugin;
|
import net.osmand.plus.osmodroid.OsMoDroidPlugin;
|
||||||
|
@ -25,12 +22,11 @@ import net.osmand.plus.parkingpoint.ParkingPositionPlugin;
|
||||||
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
|
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
|
||||||
import net.osmand.plus.srtmplugin.SRTMPlugin;
|
import net.osmand.plus.srtmplugin.SRTMPlugin;
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import android.content.Intent;
|
import java.util.ArrayList;
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import java.util.List;
|
||||||
import android.preference.PreferenceScreen;
|
import java.util.Set;
|
||||||
|
|
||||||
public abstract class OsmandPlugin {
|
public abstract class OsmandPlugin {
|
||||||
|
|
||||||
|
@ -68,7 +64,7 @@ public abstract class OsmandPlugin {
|
||||||
OsmandRasterMapsPlugin rasterMapsPlugin = new OsmandRasterMapsPlugin(app);
|
OsmandRasterMapsPlugin rasterMapsPlugin = new OsmandRasterMapsPlugin(app);
|
||||||
installedPlugins.add(rasterMapsPlugin);
|
installedPlugins.add(rasterMapsPlugin);
|
||||||
installedPlugins.add(new OsmandMonitoringPlugin(app));
|
installedPlugins.add(new OsmandMonitoringPlugin(app));
|
||||||
installedPlugins.add(new OsmandExtraSettings(app));
|
// installedPlugins.add(new OsmandExtraSettings(app));
|
||||||
installedPlugins.add(new AccessibilityPlugin(app));
|
installedPlugins.add(new AccessibilityPlugin(app));
|
||||||
if(!installPlugin(SRTM_PLUGIN_COMPONENT_PAID, SRTMPlugin.ID, app,
|
if(!installPlugin(SRTM_PLUGIN_COMPONENT_PAID, SRTMPlugin.ID, app,
|
||||||
new SRTMPlugin(app, true))) {
|
new SRTMPlugin(app, true))) {
|
||||||
|
|
|
@ -77,8 +77,6 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
|
||||||
private ContextMenuAdapter optionsMenuAdapter;
|
private ContextMenuAdapter optionsMenuAdapter;
|
||||||
private ActionMode actionMode;
|
private ActionMode actionMode;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.util.Arrays;
|
||||||
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.OsmandSettings.OsmandPreference;
|
import net.osmand.plus.OsmandSettings.OsmandPreference;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
@ -43,91 +44,13 @@ public class OsmandExtraSettings extends OsmandPlugin {
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return app.getString(R.string.extra_settings);
|
return app.getString(R.string.extra_settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerLayers(final MapActivity activity) {
|
public void registerLayers(final MapActivity activity) {
|
||||||
registerControls = true;
|
registerControls = true;
|
||||||
final OsmandMapTileView view = activity.getMapView();
|
final OsmandMapTileView view = activity.getMapView();
|
||||||
final MapInfoLayer mapInfoLayer = activity.getMapLayers().getMapInfoLayer();
|
final MapInfoLayer mapInfoLayer = activity.getMapLayers().getMapInfoLayer();
|
||||||
final MapWidgetRegistry mapInfoControls = mapInfoLayer.getMapInfoControls();
|
final MapWidgetRegistry mapInfoControls = mapInfoLayer.getMapInfoControls();
|
||||||
|
|
||||||
final OsmandPreference<Float> textSizePref = view.getSettings().MAP_TEXT_SIZE;
|
|
||||||
final MapWidgetRegInfo textSize = mapInfoControls.registerAppearanceWidget(R.drawable.widget_text_size, R.string.map_text_size,
|
|
||||||
"text_size", textSizePref);
|
|
||||||
textSize.setStateChangeListener(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
final Float[] floatValues = new Float[] {0.6f, 0.8f, 1.0f, 1.2f, 1.5f, 1.75f, 2f};
|
|
||||||
String[] entries = new String[floatValues.length];
|
|
||||||
for (int i = 0; i < floatValues.length; i++) {
|
|
||||||
entries[i] = (int) (floatValues[i] * 100) +" %";
|
|
||||||
}
|
|
||||||
Builder b = new AlertDialog.Builder(view.getContext());
|
|
||||||
b.setTitle(R.string.map_text_size);
|
|
||||||
int i = Arrays.binarySearch(floatValues, textSizePref.get());
|
|
||||||
b.setSingleChoiceItems(entries, i, new OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
textSizePref.set(floatValues[which]);
|
|
||||||
app.getResourceManager().getRenderer().clearCache();
|
|
||||||
view.refreshMap(true);
|
|
||||||
dialog.dismiss();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
b.show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
final MapWidgetRegInfo showRuler = mapInfoControls.registerAppearanceWidget(R.drawable.widget_ruler, R.string.map_widget_show_ruler,
|
|
||||||
"showRuler", view.getSettings().SHOW_RULER);
|
|
||||||
showRuler.setStateChangeListener(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
view.getSettings().SHOW_RULER.set(!view.getSettings().SHOW_RULER.get());
|
|
||||||
view.refreshMap();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
final MapWidgetRegInfo showDestinationArrow = mapInfoControls.registerAppearanceWidget(R.drawable.widget_show_destination_arrow, R.string.map_widget_show_destination_arrow,
|
|
||||||
"show_destination_arrow", view.getSettings().SHOW_DESTINATION_ARROW);
|
|
||||||
showDestinationArrow.setStateChangeListener(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
view.getSettings().SHOW_DESTINATION_ARROW.set(!view.getSettings().SHOW_DESTINATION_ARROW.get());
|
|
||||||
mapInfoLayer.recreateControls();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
final MapWidgetRegInfo transparent = mapInfoControls.registerAppearanceWidget(R.drawable.widget_transparent_skin, R.string.map_widget_transparent,
|
|
||||||
"transparent", view.getSettings().TRANSPARENT_MAP_THEME);
|
|
||||||
transparent.setStateChangeListener(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
view.getSettings().TRANSPARENT_MAP_THEME.set(!view.getSettings().TRANSPARENT_MAP_THEME.get());
|
|
||||||
mapInfoLayer.recreateControls();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// final MapInfoControlRegInfo posMap = mapInfoControls.registerAppearanceWidget(R.drawable.widget_position_marker, R.string.position_on_map,
|
|
||||||
// "position_on_map", textSizePref);
|
|
||||||
// posMap.setStateChangeListener(new Runnable() {
|
|
||||||
// @Override
|
|
||||||
// public void run() {
|
|
||||||
// String[] entries = new String[] { activity.getString(R.string.position_on_map_center), activity.getString(R.string.position_on_map_bottom) };
|
|
||||||
// final Integer[] vals = new Integer[] { OsmandSettings.CENTER_CONSTANT, OsmandSettings.BOTTOM_CONSTANT };
|
|
||||||
// Builder b = new AlertDialog.Builder(view.getContext());
|
|
||||||
// int i = Arrays.binarySearch(vals, posPref.get());
|
|
||||||
// b.setSingleChoiceItems(entries, i, new OnClickListener() {
|
|
||||||
// @Override
|
|
||||||
// public void onClick(DialogInterface dialog, int which) {
|
|
||||||
// posPref.set(vals[which]);
|
|
||||||
// activity.updateApplicationModeSettings();
|
|
||||||
// view.refreshMap(true);
|
|
||||||
// dialog.dismiss();
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// b.show();
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,52 +1,11 @@
|
||||||
package net.osmand.plus.views;
|
package net.osmand.plus.views;
|
||||||
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.LinkedHashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import net.osmand.access.AccessibleToast;
|
|
||||||
import net.osmand.plus.ApplicationMode;
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
|
||||||
import net.osmand.plus.OsmandPlugin;
|
|
||||||
import net.osmand.plus.OsmandSettings;
|
|
||||||
import net.osmand.plus.OsmandSettings.CommonPreference;
|
|
||||||
import net.osmand.plus.R;
|
|
||||||
import net.osmand.plus.activities.MapActivity;
|
|
||||||
import net.osmand.plus.activities.MapActivityActions;
|
|
||||||
import net.osmand.plus.activities.SettingsActivity;
|
|
||||||
import net.osmand.plus.extrasettings.OsmandExtraSettings;
|
|
||||||
import net.osmand.plus.routing.RoutingHelper;
|
|
||||||
import net.osmand.plus.views.mapwidgets.BaseMapWidget;
|
|
||||||
import net.osmand.plus.views.mapwidgets.ImageViewWidget;
|
|
||||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory;
|
|
||||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopTextView;
|
|
||||||
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry;
|
|
||||||
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry.MapWidgetRegInfo;
|
|
||||||
import net.osmand.plus.views.mapwidgets.NextTurnInfoWidget;
|
|
||||||
import net.osmand.plus.views.mapwidgets.RouteInfoWidgetsFactory;
|
|
||||||
import net.osmand.plus.views.mapwidgets.StackWidgetView;
|
|
||||||
import net.osmand.plus.views.mapwidgets.TextInfoWidget;
|
|
||||||
import net.osmand.plus.views.mapwidgets.UpdateableWidget;
|
|
||||||
import net.osmand.render.RenderingRuleProperty;
|
|
||||||
import net.osmand.render.RenderingRulesStorage;
|
|
||||||
import net.osmand.util.Algorithms;
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.AlertDialog.Builder;
|
import android.app.AlertDialog.Builder;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.graphics.*;
|
||||||
import android.content.DialogInterface.OnClickListener;
|
|
||||||
import android.graphics.Canvas;
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.graphics.Paint;
|
|
||||||
import android.graphics.Paint.Style;
|
import android.graphics.Paint.Style;
|
||||||
import android.graphics.Rect;
|
|
||||||
import android.graphics.RectF;
|
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
|
@ -54,20 +13,27 @@ import android.view.View;
|
||||||
import android.view.View.MeasureSpec;
|
import android.view.View.MeasureSpec;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.AdapterView;
|
import android.widget.*;
|
||||||
import android.widget.AdapterView.OnItemClickListener;
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
import android.widget.ArrayAdapter;
|
|
||||||
import android.widget.CheckBox;
|
|
||||||
import android.widget.CompoundButton;
|
|
||||||
import android.widget.ListView;
|
|
||||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||||
import android.widget.FrameLayout;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.LinearLayout.LayoutParams;
|
import android.widget.LinearLayout.LayoutParams;
|
||||||
import android.widget.ListAdapter;
|
import net.osmand.plus.ApplicationMode;
|
||||||
import android.widget.TextView;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import android.widget.Toast;
|
import net.osmand.plus.OsmandSettings;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.plus.activities.MapActivityActions;
|
||||||
|
import net.osmand.plus.routing.RoutingHelper;
|
||||||
|
import net.osmand.plus.views.mapwidgets.*;
|
||||||
|
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopTextView;
|
||||||
|
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry.MapWidgetRegInfo;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class MapInfoLayer extends OsmandMapLayer {
|
public class MapInfoLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
|
@ -100,7 +66,7 @@ public class MapInfoLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
private MonitoringInfoControl monitoringServices;
|
private MonitoringInfoControl monitoringServices;
|
||||||
|
|
||||||
private String ADDITIONAL_VECTOR_RENDERING_CATEGORY;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -117,7 +83,6 @@ public class MapInfoLayer extends OsmandMapLayer {
|
||||||
scaleCoefficient *= 1.5f;
|
scaleCoefficient *= 1.5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
ADDITIONAL_VECTOR_RENDERING_CATEGORY = map.getString(R.string.map_widget_vector_attributes);
|
|
||||||
paintText = new Paint();
|
paintText = new Paint();
|
||||||
paintText.setStyle(Style.FILL_AND_STROKE);
|
paintText.setStyle(Style.FILL_AND_STROKE);
|
||||||
paintText.setColor(Color.BLACK);
|
paintText.setColor(Color.BLACK);
|
||||||
|
@ -250,150 +215,10 @@ public class MapInfoLayer extends OsmandMapLayer {
|
||||||
"street_name", MapWidgetRegistry.MAIN_CONTROL, all, 100);
|
"street_name", MapWidgetRegistry.MAIN_CONTROL, all, 100);
|
||||||
|
|
||||||
// Register appearance widgets
|
// Register appearance widgets
|
||||||
registerAppearanceWidgets();
|
AppearanceWidgetsFactory.INSTANCE.registerAppearanceWidgets(map, this, mapInfoControls);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void registerAppearanceWidgets() {
|
|
||||||
final MapWidgetRegInfo vectorRenderer = mapInfoControls.registerAppearanceWidget(R.drawable.widget_rendering_style, R.string.map_widget_renderer,
|
|
||||||
"renderer", view.getSettings().RENDERER);
|
|
||||||
final OsmandApplication app = view.getApplication();
|
|
||||||
vectorRenderer.setStateChangeListener(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
Builder bld = new AlertDialog.Builder(view.getContext());
|
|
||||||
bld.setTitle(R.string.renderers);
|
|
||||||
Collection<String> rendererNames = app.getRendererRegistry().getRendererNames();
|
|
||||||
final String[] items = rendererNames.toArray(new String[rendererNames.size()]);
|
|
||||||
int i = -1;
|
|
||||||
for(int j = 0; j< items.length; j++) {
|
|
||||||
if(items[j].equals(app.getRendererRegistry().getCurrentSelectedRenderer().getName())) {
|
|
||||||
i = j;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bld.setSingleChoiceItems(items, i, new OnClickListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
String renderer = items[which];
|
|
||||||
RenderingRulesStorage loaded = app.getRendererRegistry().getRenderer(renderer);
|
|
||||||
if (loaded != null) {
|
|
||||||
view.getSettings().RENDERER.set(renderer);
|
|
||||||
app.getRendererRegistry().setCurrentSelectedRender(loaded);
|
|
||||||
app.getResourceManager().getRenderer().clearCache();
|
|
||||||
view.refreshMap(true);
|
|
||||||
} else {
|
|
||||||
AccessibleToast.makeText(app, R.string.renderer_load_exception, Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
createCustomRenderingProperties(loaded);
|
|
||||||
dialog.dismiss();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
bld.show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
final MapWidgetRegInfo dayNight = mapInfoControls.registerAppearanceWidget(R.drawable.widget_day_night_mode, R.string.map_widget_day_night,
|
|
||||||
"dayNight", view.getSettings().DAYNIGHT_MODE);
|
|
||||||
dayNight.setStateChangeListener(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
Builder bld = new AlertDialog.Builder(view.getContext());
|
|
||||||
bld.setTitle(R.string.daynight);
|
|
||||||
final String[] items = new String[OsmandSettings.DayNightMode.values().length];
|
|
||||||
for (int i = 0; i < items.length; i++) {
|
|
||||||
items[i] = OsmandSettings.DayNightMode.values()[i].toHumanString(map.getMyApplication());
|
|
||||||
}
|
|
||||||
int i = view.getSettings().DAYNIGHT_MODE.get().ordinal();
|
|
||||||
bld.setSingleChoiceItems(items, i, new OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
view.getSettings().DAYNIGHT_MODE.set(OsmandSettings.DayNightMode.values()[which]);
|
|
||||||
app.getResourceManager().getRenderer().clearCache();
|
|
||||||
view.refreshMap(true);
|
|
||||||
dialog.dismiss();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
bld.show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
final MapWidgetRegInfo displayViewDirections = mapInfoControls.registerAppearanceWidget(R.drawable.widget_viewing_direction, R.string.map_widget_view_direction,
|
|
||||||
"viewDirection", view.getSettings().SHOW_VIEW_ANGLE);
|
|
||||||
displayViewDirections.setStateChangeListener(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
view.getSettings().SHOW_VIEW_ANGLE.set(!view.getSettings().SHOW_VIEW_ANGLE.get());
|
|
||||||
map.getMapViewTrackingUtilities().updateSettings();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
RenderingRulesStorage renderer = app.getRendererRegistry().getCurrentSelectedRenderer();
|
|
||||||
if(renderer != null) {
|
|
||||||
createCustomRenderingProperties(renderer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createCustomRenderingProperties(RenderingRulesStorage renderer) {
|
|
||||||
String categoryName = ADDITIONAL_VECTOR_RENDERING_CATEGORY;
|
|
||||||
mapInfoControls.removeApperanceWidgets(categoryName);
|
|
||||||
final OsmandApplication app = view.getApplication();
|
|
||||||
List<RenderingRuleProperty> customRules = renderer.PROPS.getCustomRules();
|
|
||||||
for (final RenderingRuleProperty p : customRules) {
|
|
||||||
String propertyName = SettingsActivity.getStringPropertyName(view.getContext(), p.getAttrName(), p.getName());
|
|
||||||
//test old descr as title
|
|
||||||
final String propertyDescr = SettingsActivity.getStringPropertyDescription(view.getContext(), p.getAttrName(), p.getName());
|
|
||||||
if(p.isBoolean()) {
|
|
||||||
final CommonPreference<Boolean> pref = view.getApplication().getSettings().getCustomRenderBooleanProperty(p.getAttrName());
|
|
||||||
int icon = 0;
|
|
||||||
try {
|
|
||||||
Field f = R.drawable.class.getField("widget_" + p.getAttrName().toLowerCase());
|
|
||||||
icon = f.getInt(null);
|
|
||||||
} catch(Exception e){
|
|
||||||
}
|
|
||||||
MapWidgetRegInfo w = mapInfoControls.registerAppearanceWidget(icon, propertyName, "rend_"+p.getAttrName(), pref, categoryName);
|
|
||||||
w.setStateChangeListener(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
pref.set(!pref.get());
|
|
||||||
app.getResourceManager().getRenderer().clearCache();
|
|
||||||
view.refreshMap(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
} else {
|
|
||||||
final CommonPreference<String> pref = view.getApplication().getSettings().getCustomRenderProperty(p.getAttrName());
|
|
||||||
int icon = 0;
|
|
||||||
try {
|
|
||||||
Field f = R.drawable.class.getField("widget_" + p.getAttrName().toLowerCase());
|
|
||||||
icon = f.getInt(null);
|
|
||||||
} catch(Exception e){
|
|
||||||
}
|
|
||||||
MapWidgetRegInfo w = mapInfoControls.registerAppearanceWidget(icon, propertyName, "rend_"+p.getAttrName(), pref, categoryName);
|
|
||||||
w.setStateChangeListener(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
Builder b = new AlertDialog.Builder(view.getContext());
|
|
||||||
//test old descr as title
|
|
||||||
b.setTitle(propertyDescr);
|
|
||||||
int i = Arrays.asList(p.getPossibleValues()).indexOf(pref.get());
|
|
||||||
b.setSingleChoiceItems(p.getPossibleValues(), i, new OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
pref.set(p.getPossibleValues()[which]);
|
|
||||||
app.getResourceManager().getRenderer().clearCache();
|
|
||||||
view.refreshMap(true);
|
|
||||||
dialog.dismiss();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
b.show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void recreateControls(){
|
public void recreateControls(){
|
||||||
rightStack.clearAllViews();
|
rightStack.clearAllViews();
|
||||||
|
@ -482,9 +307,6 @@ public class MapInfoLayer extends OsmandMapLayer {
|
||||||
s.add(ms.getCategory());
|
s.add(ms.getCategory());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(OsmandPlugin.getEnabledPlugin(OsmandExtraSettings.class) == null){
|
|
||||||
s.remove(ADDITIONAL_VECTOR_RENDERING_CATEGORY);
|
|
||||||
}
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,261 @@
|
||||||
|
package net.osmand.plus.views.mapwidgets;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.widget.Toast;
|
||||||
|
import net.osmand.access.AccessibleToast;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.OsmandSettings;
|
||||||
|
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.OsmandMapTileView;
|
||||||
|
import net.osmand.render.RenderingRuleProperty;
|
||||||
|
import net.osmand.render.RenderingRulesStorage;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class AppearanceWidgetsFactory {
|
||||||
|
|
||||||
|
public static AppearanceWidgetsFactory INSTANCE = new AppearanceWidgetsFactory();
|
||||||
|
private String ADDITIONAL_VECTOR_RENDERING_CATEGORY;
|
||||||
|
public static boolean EXTRA_SETTINGS = true;
|
||||||
|
|
||||||
|
|
||||||
|
public void registerAppearanceWidgets(final MapActivity map, final MapInfoLayer mapInfoLayer,
|
||||||
|
final MapWidgetRegistry mapInfoControls) {
|
||||||
|
final OsmandMapTileView view = map.getMapView();
|
||||||
|
final MapWidgetRegistry.MapWidgetRegInfo vectorRenderer = mapInfoControls.registerAppearanceWidget(R.drawable.widget_rendering_style, R.string.map_widget_renderer,
|
||||||
|
"renderer", view.getSettings().RENDERER);
|
||||||
|
final OsmandApplication app = view.getApplication();
|
||||||
|
vectorRenderer.setStateChangeListener(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
AlertDialog.Builder bld = new AlertDialog.Builder(view.getContext());
|
||||||
|
bld.setTitle(R.string.renderers);
|
||||||
|
Collection<String> rendererNames = app.getRendererRegistry().getRendererNames();
|
||||||
|
final String[] items = rendererNames.toArray(new String[rendererNames.size()]);
|
||||||
|
int i = -1;
|
||||||
|
for(int j = 0; j< items.length; j++) {
|
||||||
|
if(items[j].equals(app.getRendererRegistry().getCurrentSelectedRenderer().getName())) {
|
||||||
|
i = j;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bld.setSingleChoiceItems(items, i, new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
String renderer = items[which];
|
||||||
|
RenderingRulesStorage loaded = app.getRendererRegistry().getRenderer(renderer);
|
||||||
|
if (loaded != null) {
|
||||||
|
view.getSettings().RENDERER.set(renderer);
|
||||||
|
app.getRendererRegistry().setCurrentSelectedRender(loaded);
|
||||||
|
app.getResourceManager().getRenderer().clearCache();
|
||||||
|
view.refreshMap(true);
|
||||||
|
} else {
|
||||||
|
AccessibleToast.makeText(app, R.string.renderer_load_exception, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
if(EXTRA_SETTINGS) {
|
||||||
|
createCustomRenderingProperties(loaded, map, mapInfoLayer, mapInfoControls);
|
||||||
|
}
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
bld.show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
final MapWidgetRegistry.MapWidgetRegInfo dayNight = mapInfoControls.registerAppearanceWidget(R.drawable.widget_day_night_mode, R.string.map_widget_day_night,
|
||||||
|
"dayNight", view.getSettings().DAYNIGHT_MODE);
|
||||||
|
dayNight.setStateChangeListener(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
AlertDialog.Builder bld = new AlertDialog.Builder(view.getContext());
|
||||||
|
bld.setTitle(R.string.daynight);
|
||||||
|
final String[] items = new String[OsmandSettings.DayNightMode.values().length];
|
||||||
|
for (int i = 0; i < items.length; i++) {
|
||||||
|
items[i] = OsmandSettings.DayNightMode.values()[i].toHumanString(map.getMyApplication());
|
||||||
|
}
|
||||||
|
int i = view.getSettings().DAYNIGHT_MODE.get().ordinal();
|
||||||
|
bld.setSingleChoiceItems(items, i, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
view.getSettings().DAYNIGHT_MODE.set(OsmandSettings.DayNightMode.values()[which]);
|
||||||
|
app.getResourceManager().getRenderer().clearCache();
|
||||||
|
view.refreshMap(true);
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
bld.show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
final MapWidgetRegistry.MapWidgetRegInfo displayViewDirections = mapInfoControls.registerAppearanceWidget(R.drawable.widget_viewing_direction, R.string.map_widget_view_direction,
|
||||||
|
"viewDirection", view.getSettings().SHOW_VIEW_ANGLE);
|
||||||
|
displayViewDirections.setStateChangeListener(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
view.getSettings().SHOW_VIEW_ANGLE.set(!view.getSettings().SHOW_VIEW_ANGLE.get());
|
||||||
|
map.getMapViewTrackingUtilities().updateSettings();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (EXTRA_SETTINGS) {
|
||||||
|
// previous extra settings
|
||||||
|
final OsmandSettings.OsmandPreference<Float> textSizePref = view.getSettings().MAP_TEXT_SIZE;
|
||||||
|
final MapWidgetRegistry.MapWidgetRegInfo textSize = mapInfoControls.registerAppearanceWidget(R.drawable.widget_text_size, R.string.map_text_size,
|
||||||
|
"text_size", textSizePref);
|
||||||
|
textSize.setStateChangeListener(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
final Float[] floatValues = new Float[] {0.6f, 0.8f, 1.0f, 1.2f, 1.5f, 1.75f, 2f};
|
||||||
|
String[] entries = new String[floatValues.length];
|
||||||
|
for (int i = 0; i < floatValues.length; i++) {
|
||||||
|
entries[i] = (int) (floatValues[i] * 100) +" %";
|
||||||
|
}
|
||||||
|
AlertDialog.Builder b = new AlertDialog.Builder(view.getContext());
|
||||||
|
b.setTitle(R.string.map_text_size);
|
||||||
|
int i = Arrays.binarySearch(floatValues, textSizePref.get());
|
||||||
|
b.setSingleChoiceItems(entries, i, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
textSizePref.set(floatValues[which]);
|
||||||
|
app.getResourceManager().getRenderer().clearCache();
|
||||||
|
view.refreshMap(true);
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
b.show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
final MapWidgetRegistry.MapWidgetRegInfo showRuler = mapInfoControls.registerAppearanceWidget(R.drawable.widget_ruler, R.string.map_widget_show_ruler,
|
||||||
|
"showRuler", view.getSettings().SHOW_RULER);
|
||||||
|
showRuler.setStateChangeListener(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
view.getSettings().SHOW_RULER.set(!view.getSettings().SHOW_RULER.get());
|
||||||
|
view.refreshMap();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
final MapWidgetRegistry.MapWidgetRegInfo showDestinationArrow = mapInfoControls.registerAppearanceWidget(R.drawable.widget_show_destination_arrow, R.string.map_widget_show_destination_arrow,
|
||||||
|
"show_destination_arrow", view.getSettings().SHOW_DESTINATION_ARROW);
|
||||||
|
showDestinationArrow.setStateChangeListener(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
view.getSettings().SHOW_DESTINATION_ARROW.set(!view.getSettings().SHOW_DESTINATION_ARROW.get());
|
||||||
|
mapInfoLayer.recreateControls();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
final MapWidgetRegistry.MapWidgetRegInfo transparent = mapInfoControls.registerAppearanceWidget(R.drawable.widget_transparent_skin, R.string.map_widget_transparent,
|
||||||
|
"transparent", view.getSettings().TRANSPARENT_MAP_THEME);
|
||||||
|
transparent.setStateChangeListener(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
view.getSettings().TRANSPARENT_MAP_THEME.set(!view.getSettings().TRANSPARENT_MAP_THEME.get());
|
||||||
|
mapInfoLayer.recreateControls();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// final OsmandSettings.OsmandPreference<Integer> posPref = view.getSettings().POSITION_ON_MAP;
|
||||||
|
// final MapWidgetRegistry.MapWidgetRegInfo posMap = mapInfoControls.registerAppearanceWidget(R.drawable.widget_position_marker, R.string.position_on_map,
|
||||||
|
// "position_on_map", textSizePref);
|
||||||
|
// posMap.setStateChangeListener(new Runnable() {
|
||||||
|
// @Override
|
||||||
|
// public void run() {
|
||||||
|
// String[] entries = new String[] {map.getString(R.string.position_on_map_center), map.getString(R.string.position_on_map_bottom) };
|
||||||
|
// final Integer[] vals = new Integer[] { OsmandSettings.CENTER_CONSTANT, OsmandSettings.BOTTOM_CONSTANT };
|
||||||
|
// AlertDialog.Builder b = new AlertDialog.Builder(view.getContext());
|
||||||
|
// int i = Arrays.binarySearch(vals, posPref.get());
|
||||||
|
// b.setSingleChoiceItems(entries, i, new DialogInterface.OnClickListener() {
|
||||||
|
// @Override
|
||||||
|
// public void onClick(DialogInterface dialog, int which) {
|
||||||
|
// posPref.set(vals[which]);
|
||||||
|
// map.updateApplicationModeSettings();
|
||||||
|
// view.refreshMap(true);
|
||||||
|
// dialog.dismiss();
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// b.show();
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
RenderingRulesStorage renderer = app.getRendererRegistry().getCurrentSelectedRenderer();
|
||||||
|
if(renderer != null && EXTRA_SETTINGS) {
|
||||||
|
createCustomRenderingProperties(renderer, map, mapInfoLayer, mapInfoControls);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createCustomRenderingProperties(RenderingRulesStorage renderer, final MapActivity map,
|
||||||
|
final MapInfoLayer mapInfoLayer, final MapWidgetRegistry mapInfoControls) {
|
||||||
|
final OsmandMapTileView view = map.getMapView();
|
||||||
|
if(ADDITIONAL_VECTOR_RENDERING_CATEGORY == null) {
|
||||||
|
ADDITIONAL_VECTOR_RENDERING_CATEGORY = map.getString(R.string.map_widget_vector_attributes);
|
||||||
|
}
|
||||||
|
String categoryName = ADDITIONAL_VECTOR_RENDERING_CATEGORY;
|
||||||
|
mapInfoControls.removeApperanceWidgets(categoryName);
|
||||||
|
final OsmandApplication app = view.getApplication();
|
||||||
|
List<RenderingRuleProperty> customRules = renderer.PROPS.getCustomRules();
|
||||||
|
for (final RenderingRuleProperty p : customRules) {
|
||||||
|
String propertyName = SettingsActivity.getStringPropertyName(view.getContext(), p.getAttrName(), p.getName());
|
||||||
|
//test old descr as title
|
||||||
|
final String propertyDescr = SettingsActivity.getStringPropertyDescription(view.getContext(), p.getAttrName(), p.getName());
|
||||||
|
if(p.isBoolean()) {
|
||||||
|
final OsmandSettings.CommonPreference<Boolean> pref = view.getApplication().getSettings().getCustomRenderBooleanProperty(p.getAttrName());
|
||||||
|
int icon = 0;
|
||||||
|
try {
|
||||||
|
Field f = R.drawable.class.getField("widget_" + p.getAttrName().toLowerCase());
|
||||||
|
icon = f.getInt(null);
|
||||||
|
} catch(Exception e){
|
||||||
|
}
|
||||||
|
MapWidgetRegistry.MapWidgetRegInfo w = mapInfoControls.registerAppearanceWidget(icon, propertyName, "rend_"+p.getAttrName(), pref, categoryName);
|
||||||
|
w.setStateChangeListener(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
pref.set(!pref.get());
|
||||||
|
app.getResourceManager().getRenderer().clearCache();
|
||||||
|
view.refreshMap(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
final OsmandSettings.CommonPreference<String> pref = view.getApplication().getSettings().getCustomRenderProperty(p.getAttrName());
|
||||||
|
int icon = 0;
|
||||||
|
try {
|
||||||
|
Field f = R.drawable.class.getField("widget_" + p.getAttrName().toLowerCase());
|
||||||
|
icon = f.getInt(null);
|
||||||
|
} catch(Exception e){
|
||||||
|
}
|
||||||
|
MapWidgetRegistry.MapWidgetRegInfo w = mapInfoControls.registerAppearanceWidget(icon, propertyName, "rend_"+p.getAttrName(), pref, categoryName);
|
||||||
|
w.setStateChangeListener(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
AlertDialog.Builder b = new AlertDialog.Builder(view.getContext());
|
||||||
|
//test old descr as title
|
||||||
|
b.setTitle(propertyDescr);
|
||||||
|
int i = Arrays.asList(p.getPossibleValues()).indexOf(pref.get());
|
||||||
|
b.setSingleChoiceItems(p.getPossibleValues(), i, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
pref.set(p.getPossibleValues()[which]);
|
||||||
|
app.getResourceManager().getRenderer().clearCache();
|
||||||
|
view.refreshMap(true);
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
b.show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue