Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2012-08-19 19:50:11 +02:00
commit 8865ce2d80
12 changed files with 437 additions and 214 deletions

View file

@ -1015,19 +1015,19 @@
<filter viRendered="true" tag="highway" value="motorway" maxzoom="13" color="#6666CC"/>
<!-- PALE-SCHEME filter hmRendered="true" tag="highway" value="motorway" maxzoom="13" color="#809bff"/ -->
<filter hmRendered="true" tag="highway" value="motorway" maxzoom="13" color="#809bff"/>
<filter tag="highway" value="motorway" maxzoom="13" color="#a58dff"/>
<filter tag="highway" value="motorway" maxzoom="13" color="#809bff"/>
<filter viRendered="true" tag="highway" value="motorway_link" maxzoom="13" color="#6666CC"/>
<!-- PALE-SCHEME filter hmRendered="true" tag="highway" value="motorway_link" maxzoom="13" color="#809bff"/ -->
<filter hmRendered="true" tag="highway" value="motorway_link" maxzoom="13" color="#809bff"/>
<filter tag="highway" value="motorway_link" maxzoom="13" color="#a58dff"/>
<filter tag="highway" value="motorway_link" maxzoom="13" color="#809bff"/>
<filter viRendered="true" tag="highway" value="trunk" maxzoom="13" color="#A02067"/>
<!-- PALE-SCHEME filter hmRendered="true" tag="highway" value="trunk" maxzoom="13" color="#df1346"/ -->
<filter hmRendered="true" tag="highway" value="trunk" maxzoom="13" color="#ed154b"/>
<filter tag="highway" value="trunk" maxzoom="13" color="#ffaf80"/>
<filter tag="highway" value="trunk" maxzoom="13" color="#ed154b"/>
<filter viRendered="true" tag="highway" value="trunk_link" maxzoom="13" color="#A02067"/>
<!-- PALE-SCHEME filter hmRendered="true" tag="highway" value="trunk_link" maxzoom="13" color="#df1346"/ -->
<filter hmRendered="true" tag="highway" value="trunk_link" maxzoom="13" color="#ed154b"/>
<filter tag="highway" value="trunk_link" maxzoom="13" color="#ffaf80"/>
<filter tag="highway" value="trunk_link" maxzoom="13" color="#ed154b"/>
<groupFilter cap="ROUND">
<filter minzoom="5" maxzoom="9" strokeWidth="5"/>
<filter minzoom="10" maxzoom="10" strokeWidth="6"/>
@ -1041,11 +1041,11 @@
<filter viRendered="true" tag="highway" value="primary" maxzoom="13" color="#C04D61"/>
<!-- PALE-SCHEME filter hmRendered="true" tag="highway" value="primary" maxzoom="13" color="#eb989a"/ -->
<filter hmRendered="true" tag="highway" value="primary" maxzoom="13" color="#ff80a0"/>
<filter tag="highway" value="primary" maxzoom="13" color="#eb989a"/>
<filter tag="highway" value="primary" maxzoom="13" color="#ff80a0"/>
<filter viRendered="true" tag="highway" value="primary_link" maxzoom="13" color="#C04D61"/>
<!-- PALE-SCHEME filter hmRendered="true" tag="highway" value="primary_link" maxzoom="13" color="#eb989a"/ -->
<filter hmRendered="true" tag="highway" value="primary_link" maxzoom="13" color="#ff80a0"/>
<filter tag="highway" value="primary_link" maxzoom="13" color="#eb989a"/>
<filter tag="highway" value="primary_link" maxzoom="13" color="#ff80a0"/>
<groupFilter cap="ROUND">
<filter minzoom="7" maxzoom="9" strokeWidth="4"/>
<filter minzoom="10" maxzoom="10" strokeWidth="5"/>
@ -1059,11 +1059,11 @@
<filter viRendered="true" tag="highway" value="secondary" maxzoom="13" color="#F7D131"/>
<!-- PALE-SCHEME filter hmRendered="true" tag="highway" value="secondary" maxzoom="13" color="#fdd6a4"/ -->
<filter hmRendered="true" tag="highway" value="secondary" maxzoom="13" color="#ffd080"/>
<filter tag="highway" value="secondary" maxzoom="13" color="#fdd6a4"/>
<filter tag="highway" value="secondary" maxzoom="13" color="#ffd080"/>
<filter viRendered="true" tag="highway" value="secondary_link" maxzoom="13" color="#F7D131"/>
<!-- PALE-SCHEME filter hmRendered="true" tag="highway" value="secondary_link" maxzoom="13" color="#fdd6a4"/ -->
<filter hmRendered="true" tag="highway" value="secondary_link" maxzoom="13" color="#ffd080"/>
<filter tag="highway" value="secondary_link" maxzoom="13" color="#fdd6a4"/>
<filter tag="highway" value="secondary_link" maxzoom="13" color="#ffd080"/>
<groupFilter shadowRadius="1" cap="ROUND">
<filter minzoom="9" maxzoom="9" strokeWidth="3"/>
<filter minzoom="10" maxzoom="10" strokeWidth="4"/>
@ -1077,35 +1077,35 @@
<filter viRendered="true" tag="highway" value="motorway" color="#6666CC"/>
<!-- PALE-SCHEME filter hmRendered="true" tag="highway" value="motorway" color="#809bff"/ -->
<filter hmRendered="true" tag="highway" value="motorway" color="#809bff"/>
<filter tag="highway" value="motorway" color="#a58dff"/>
<filter tag="highway" value="motorway" color="#809bff"/>
<filter viRendered="true" tag="highway" value="motorway_link" color="#6666CC"/>
<!-- PALE-SCHEME filter hmRendered="true" tag="highway" value="motorway_link" color="#809bff"/ -->
<filter hmRendered="true" tag="highway" value="motorway_link" color="#809bff"/>
<filter tag="highway" value="motorway_link" color="#a58dff"/>
<filter tag="highway" value="motorway_link" color="#809bff"/>
<filter viRendered="true" tag="highway" value="trunk" color="#A02067"/>
<!-- PALE-SCHEME filter hmRendered="true" tag="highway" value="trunk" color="#df1346"/ -->
<filter hmRendered="true" tag="highway" value="trunk" color="#ed154b"/>
<filter tag="highway" value="trunk" color="#ffaf80"/>
<filter tag="highway" value="trunk" color="#ed154b"/>
<filter viRendered="true" tag="highway" value="trunk_link" color="#A02067"/>
<!-- PALE-SCHEME filter hmRendered="true" tag="highway" value="trunk_link" color="#df1346"/ -->
<filter hmRendered="true" tag="highway" value="trunk_link" color="#ed154b"/>
<filter tag="highway" value="trunk_link" color="#ffaf80"/>
<filter tag="highway" value="trunk_link" color="#ed154b"/>
<filter viRendered="true" tag="highway" value="primary" color="#C04D61"/>
<!-- PALE-SCHEME filter hmRendered="true" tag="highway" value="primary" color="#eb989a"/ -->
<filter hmRendered="true" tag="highway" value="primary" color="#ff80a0"/>
<filter tag="highway" value="primary" color="#eb989a"/>
<filter tag="highway" value="primary" color="#ff80a0"/>
<filter viRendered="true" tag="highway" value="primary_link" color="#C04D61"/>
<!-- PALE-SCHEME filter hmRendered="true" tag="highway" value="primary_link" color="#eb989a"/ -->
<filter hmRendered="true" tag="highway" value="primary_link" color="#ff80a0"/>
<filter tag="highway" value="primary_link" color="#eb989a"/>
<filter tag="highway" value="primary_link" color="#ff80a0"/>
<filter viRendered="true" tag="highway" value="secondary" color="#F7D131"/>
<!-- PALE-SCHEME filter hmRendered="true" tag="highway" value="secondary" color="#fdd6a4"/ -->
<filter hmRendered="true" tag="highway" value="secondary" color="#ffd080"/>
<filter tag="highway" value="secondary" color="#fdd6a4"/>
<filter tag="highway" value="secondary" color="#ffd080"/>
<filter viRendered="true" tag="highway" value="secondary_link" color="#F7D131"/>
<!-- PALE-SCHEME filter hmRendered="true" tag="highway" value="secondary_link" color="#fdd6a4"/ -->
<filter hmRendered="true" tag="highway" value="secondary_link" color="#ffd080"/>
<filter tag="highway" value="secondary_link" color="#fdd6a4"/>
<filter tag="highway" value="secondary_link" color="#ffd080"/>
<groupFilter shadowRadius="1" cap="ROUND">
<filter>
@ -1132,11 +1132,11 @@
<filter viRendered="true" tag="highway" value="tertiary" color="#F0CE30"/>
<!-- PALE-SCHEME filter hmRendered="true" tag="highway" value="tertiary" color="#fefeb3"/ -->
<filter hmRendered="true" tag="highway" value="tertiary" color="#ffff80"/>
<filter tag="highway" value="tertiary" color="#fefeb3"/>
<filter tag="highway" value="tertiary" color="#ffff80"/>
<filter viRendered="true" tag="highway" value="tertiary_link" color="#F0CE30"/>
<!-- PALE-SCHEME filter hmRendered="true" tag="highway" value="tertiary_link" color="#fefeb3"/ -->
<filter hmRendered="true" tag="highway" value="tertiary_link" color="#ffff80"/>
<filter tag="highway" value="tertiary_link" color="#fefeb3"/>
<filter tag="highway" value="tertiary_link" color="#ffff80"/>
<groupFilter shadowRadius="1" cap="ROUND">
<filter minzoom="10" maxzoom="10" strokeWidth="3"/>
<filter minzoom="11" maxzoom="11" strokeWidth="4"/>

View file

@ -9,7 +9,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:paddingLeft="10dp"
android:src="@drawable/expandable_category_unpushed" />
/>
<TextView android:id="@+id/local_openstreetmap_category_name" android:gravity="center_vertical" android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textSize="21sp" android:layout_marginLeft="10dp"></TextView>

View file

@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version='1.0' encoding='utf-8'?>
<resources><string name="show_warnings_title">Mostra els missatges d\'avís…</string>
<string name="map_widget_fluorescent">Rutes amb fluorescència</string>
<string name="map_widget_show_ruler">Mostra el regle</string>
@ -18,7 +18,7 @@
<string name="update_downlod_list">Torna a carregar la llista</string>
<string name="starting_point_too_far">El punt d\'inici és massa lluny de la carretera més propera.</string>
<string name="osmand_parking_time_limit_title">Indica el temps límit d\'aparcament</string>
<string name="osmand_parking_choose_type">Tria el tipus d'aparcament</string>
<string name="osmand_parking_choose_type">Tria el tipus d\'aparcament</string>
<string name="avoid_unpaved">Evita les carreteres no pavimentades</string>
<string name="avoid_in_routing_title">Evita…</string>
<string name="monitoring_mode_on">Atura\n l\'enregistrament en GPX</string>
@ -200,8 +200,8 @@
<string name="use_transparent_map_theme">Tema transparent</string>
<string name="map_widget_appearance">Miscel·lània</string>
<string name="gps_wakeup_interval">Interval de despertament del GPS: %s</string>
<string name="osmand_parking_event">Treu el cotxe de l'aparcament</string>
<string name="rendering_attr_appMode_description">Optimització del mapa per cada Perfil d'usuari</string>
<string name="osmand_parking_event">Treu el cotxe de l\'aparcament</string>
<string name="rendering_attr_appMode_description">Optimització del mapa per cada Perfil d\'usuari</string>
<string name="play_commands_of_currently_selected_voice">Reprodueix instruccions de la veu seleccionada</string>
<string name="scroll_map_by_gestures_descr">Desplaçament del mapa per gests a la pantalla tàctil</string>
<string name="scroll_map_by_gestures">Desplaçament natural del mapa</string>
@ -209,6 +209,6 @@
<string name="zoom_by_trackball">Utilitza el ratolí de bola per controlar el zoom</string>
<string name="use_short_object_names">Utilitza els noms dels objectes</string>
<string name="local_openstreetmap_were_uploaded">{0} PDI/errors van ser penjats</string>
<string name="local_openstreetmap_settings">PDI/errors d'OSM desats localment</string>
<string name="local_openstreetmap_settings_descr">Mostra i gestiona els PDI/errors d'OSM de les bases de dades locals</string>
<string name="local_openstreetmap_settings">PDI/errors d\'OSM desats localment</string>
<string name="local_openstreetmap_settings_descr">Mostra i gestiona els PDI/errors d\'OSM de les bases de dades locals</string>
</resources>

View file

@ -9,8 +9,12 @@
1. All your modified/created strings are in the top of the file (to make easier find what's translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
-->
<string name="map_widget_vector_attributes">Rendering attributes:</string>
<string name="map_widget_renderer">Rendering style</string>
<string name="live_monitoring_mode_off">Start\n live tracking</string>
<string name="live_monitoring_mode_on">Stop\n live tracking</string>
<string name="position_on_map_descr">Choose location of position marker on the map</string>
<string name="position_on_map">Position marker</string>
<string name="layer_map_appearance">Configure screen&#8230;</string>
<string name="show_lanes">Show lanes</string>
<string name="avoid_unpaved">Avoid unpaved roads</string>

View file

@ -5,20 +5,18 @@
<PreferenceCategory android:title="@string/profile_settings" android:key="profile_dep_cat">
<ListPreference android:summary="@string/settings_preset_descr" android:title="@string/settings_preset" android:key="application_mode"></ListPreference>
<!--
<PreferenceScreen android:key="appearance_settings" android:title="@string/map_settings" android:summary="@string/map_settings_descr">
<ListPreference android:key="rotate_map" android:title="@string/rotate_map_to_bearing" android:summary="@string/rotate_map_to_bearing_descr"></ListPreference>
<ListPreference android:key="daynight_mode" android:title="@string/daynight" android:summary="@string/daynight_descr"></ListPreference>
<PreferenceCategory android:title="@string/pref_vector_map">
<ListPreference android:key="renderer" android:title="@string/renderers" android:summary="@string/renderers_descr"></ListPreference>
<ListPreference android:key="map_text_size" android:title="@string/map_text_size" android:summary="@string/map_text_size_descr"/>
</PreferenceCategory>
</PreferenceScreen>
-->
<PreferenceScreen android:key="routing_settings" android:title="@string/routing_settings" android:summary="@string/routing_settings_descr">
<ListPreference android:title="@string/router_service" android:key="router_service" android:summary="@string/router_service_descr"></ListPreference>
<CheckBoxPreference android:summary="@string/fast_route_mode_descr" android:title="@string/fast_route_mode"
android:key="fast_route_mode"></CheckBoxPreference>
<ListPreference android:title="@string/voice_provider" android:key="voice_provider" android:summary="@string/voice_provider_descr"></ListPreference>
<ListPreference android:key="daynight_mode" android:title="@string/daynight" android:summary="@string/daynight_descr"></ListPreference>
<ListPreference android:key="auto_follow_route" android:title="@string/choose_auto_follow_route"
android:summary="@string/choose_auto_follow_route_descr"></ListPreference>
<CheckBoxPreference android:title="@string/auto_zoom_map" android:summary="@string/auto_zoom_map_descr" android:key="auto_zoom_map"></CheckBoxPreference>

View file

@ -61,6 +61,8 @@ public class OsmandSettings {
T getModeValue(ApplicationMode m);
String getId();
void resetToDefault();
}
// These settings are stored in SharedPreferences
@ -120,6 +122,11 @@ public class OsmandSettings {
throw new UnsupportedOperationException();
}
@Override
public void resetToDefault() {
set(ApplicationMode.DEFAULT);
};
@Override
public boolean set(ApplicationMode val) {
ApplicationMode oldMode = currentMode;
@ -293,6 +300,11 @@ public class OsmandSettings {
return id;
}
@Override
public void resetToDefault(){
set(getDefaultValue());
}
@Override
public boolean set(T obj) {
SharedPreferences prefs = getPreferences();
@ -1195,9 +1207,7 @@ public class OsmandSettings {
}
RenderingRulesStorage loaded = ctx.getRendererRegistry().getRenderer(val);
if (loaded != null) {
ctx.getRendererRegistry().setCurrentSelectedRender(loaded);
super.setValue(prefs, val);
ctx.getResourceManager().getRenderer().clearCache();
return true;
}
return false;
@ -1208,7 +1218,7 @@ public class OsmandSettings {
Map<String, CommonPreference<String>> customRendersProps = new LinkedHashMap<String, OsmandSettings.CommonPreference<String>>();
public CommonPreference<String> getCustomRenderProperty(String attrName){
if(!customRendersProps.containsKey(attrName)){
customRendersProps.put(attrName, new StringPreference("renderer_"+attrName, "").makeProfile());
customRendersProps.put(attrName, new StringPreference("nrenderer_"+attrName, "").makeProfile());
}
return customRendersProps.get(attrName);
}
@ -1219,6 +1229,14 @@ public class OsmandSettings {
pref.setModeDefaultValue(ApplicationMode.BICYCLE, "bicycle");
}
Map<String, CommonPreference<Boolean>> customBooleanRendersProps = new LinkedHashMap<String, OsmandSettings.CommonPreference<Boolean>>();
public CommonPreference<Boolean> getCustomRenderBooleanProperty(String attrName){
if(!customRendersProps.containsKey(attrName)){
customBooleanRendersProps.put(attrName, new BooleanPreference("nrenderer_"+attrName, false).makeProfile());
}
return customBooleanRendersProps.get(attrName);
}
public final OsmandPreference<Boolean> VOICE_MUTE = new BooleanPreference("voice_mute", false).makeGlobal();
// for background service

View file

@ -3,7 +3,6 @@ package net.osmand.plus.activities;
import java.io.File;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
@ -19,7 +18,6 @@ import net.osmand.map.TileSourceManager.TileSourceTemplate;
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.OsmandSettings.DayNightMode;
import net.osmand.plus.OsmandSettings.MetricsConstants;
import net.osmand.plus.OsmandSettings.OsmandPreference;
@ -30,12 +28,12 @@ import net.osmand.plus.activities.CustomTitleBar.CustomTitleBarView;
import net.osmand.plus.render.NativeOsmandLibrary;
import net.osmand.plus.routing.RouteProvider.RouteService;
import net.osmand.plus.views.SeekBarPreference;
import net.osmand.render.RenderingRuleProperty;
import net.osmand.render.RenderingRulesStorage;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.DialogInterface.OnMultiChoiceClickListener;
@ -117,12 +115,12 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
seekBarPreferences.put(b.getId(), b);
}
public String getStringPropertyName(String propertyName, String defValue) {
public static String getStringPropertyName(Context ctx, String propertyName, String defValue) {
try {
Field f = R.string.class.getField("rendering_attr_" + propertyName + "_name");
if (f != null) {
Integer in = (Integer) f.get(null);
return getString(in);
return ctx.getString(in);
}
} catch (Exception e) {
System.err.println(e.getMessage());
@ -298,9 +296,9 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
// List preferences
registerListPreference(osmandSettings.ROTATE_MAP, screen,
new String[]{getString(R.string.rotate_map_none_opt), getString(R.string.rotate_map_bearing_opt), getString(R.string.rotate_map_compass_opt)},
new Integer[]{OsmandSettings.ROTATE_MAP_NONE, OsmandSettings.ROTATE_MAP_BEARING, OsmandSettings.ROTATE_MAP_COMPASS});
// registerListPreference(osmandSettings.ROTATE_MAP, screen,
// new String[]{getString(R.string.rotate_map_none_opt), getString(R.string.rotate_map_bearing_opt), getString(R.string.rotate_map_compass_opt)},
// new Integer[]{OsmandSettings.ROTATE_MAP_NONE, OsmandSettings.ROTATE_MAP_BEARING, OsmandSettings.ROTATE_MAP_COMPASS});
registerListPreference(osmandSettings.MAP_SCREEN_ORIENTATION, screen,
new String[] {getString(R.string.map_orientation_portrait), getString(R.string.map_orientation_landscape), getString(R.string.map_orientation_default)},
@ -344,33 +342,18 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
}
registerListPreference(osmandSettings.AUTO_FOLLOW_ROUTE, screen, entries, intValues);
Float[] floatValues = new Float[] {0.6f, 0.8f, 1.0f, 1.2f, 1.5f};
entries = new String[floatValues.length];
for (int i = 0; i < floatValues.length; i++) {
entries[i] = (int) (floatValues[i] * 100) +" %";
}
registerListPreference(osmandSettings.MAP_TEXT_SIZE, screen, entries, floatValues);
entries = new String[RouteService.values().length];
for(int i=0; i<entries.length; i++){
entries[i] = RouteService.values()[i].getName();
}
registerListPreference(osmandSettings.ROUTER_SERVICE, screen, entries, RouteService.values());
entries = new String[ApplicationMode.values().length];
for(int i=0; i<entries.length; i++){
entries[i] = ApplicationMode.values()[i].toHumanString(this);
}
registerListPreference(osmandSettings.APPLICATION_MODE, screen, entries, ApplicationMode.values());
Collection<String> rendererNames = getMyApplication().getRendererRegistry().getRendererNames();
entries = (String[]) rendererNames.toArray(new String[rendererNames.size()]);
registerListPreference(osmandSettings.RENDERER, screen, entries, entries);
createCustomRenderingProperties(false);
applicationModePreference = (ListPreference) screen.findPreference(osmandSettings.APPLICATION_MODE.getId());
applicationModePreference.setOnPreferenceChangeListener(this);
@ -411,38 +394,6 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
}
}
private void createCustomRenderingProperties(boolean update) {
RenderingRulesStorage renderer = getMyApplication().getRendererRegistry().getCurrentSelectedRenderer();
PreferenceCategory cat = (PreferenceCategory) findPreference("custom_vector_rendering");
if (cat != null) {
cat.removeAll();
if (renderer != null) {
for (RenderingRuleProperty p : renderer.PROPS.getCustomRules()) {
CommonPreference<String> custom = getMyApplication().getSettings().getCustomRenderProperty(p.getAttrName());
ListPreference lp = new ListPreference(this);
lp.setOnPreferenceChangeListener(this);
lp.setKey(custom.getId());
lp.setTitle(getStringPropertyName(p.getAttrName(), p.getName()));
lp.setSummary(getStringPropertyDescription(p.getAttrName(), p.getDescription()));
cat.addPreference(lp);
LinkedHashMap<String, Object> vals = new LinkedHashMap<String, Object>();
screenPreferences.put(custom.getId(), lp);
listPreferences.put(custom.getId(), custom);
listPrefValues.put(custom.getId(), vals);
String[] names = p.getPossibleValues();
for (int i = 0; i < names.length; i++) {
vals.put(names[i], names[i]);
}
}
if (update) {
updateAllSettings();
}
}
}
}
private void reloadVoiceListPreference(PreferenceScreen screen) {
String[] entries;
@ -583,14 +534,6 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
+ osmandSettings.DAYNIGHT_MODE.get().toHumanString(this) + "]");
}
}
if (listPref.getId().equals(osmandSettings.RENDERER.getId())) {
if (changed) {
AccessibleToast.makeText(this, R.string.renderer_load_sucess, Toast.LENGTH_SHORT).show();
} else {
AccessibleToast.makeText(this, R.string.renderer_load_exception, Toast.LENGTH_SHORT).show();
}
createCustomRenderingProperties(true);
}
} else if (preference == applicationDir) {
warnAboutChangingStorage((String) newValue);
return false;

View file

@ -1,19 +1,26 @@
package net.osmand.plus.extrasettings;
import java.util.Arrays;
import net.osmand.Version;
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.OsmandSettings.OsmandPreference;
import net.osmand.plus.R;
import net.osmand.plus.activities.ApplicationMode;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.SettingsActivity;
import net.osmand.plus.views.MapInfoControls;
import net.osmand.plus.views.MapInfoControls.MapInfoControlRegInfo;
import net.osmand.plus.views.MapInfoLayer;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.MapInfoControls.MapInfoControlRegInfo;
import net.osmand.plus.voice.CommandPlayer;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.media.AudioManager;
import android.preference.ListPreference;
import android.preference.Preference;
@ -50,17 +57,52 @@ public class OsmandExtraSettings extends OsmandPlugin {
return app.getString(R.string.extra_settings);
}
@Override
public void registerLayers(MapActivity activity) {
public void registerLayers(final MapActivity activity) {
registerControls = true;
final OsmandMapTileView view = activity.getMapView();
final MapInfoLayer mapInfoLayer = activity.getMapLayers().getMapInfoLayer();
final MapInfoControls mapInfoControls = mapInfoLayer.getMapInfoControls();
final OsmandPreference<Float> textSizePref = view.getSettings().MAP_TEXT_SIZE;
final MapInfoControlRegInfo textSize = mapInfoControls.registerAppearanceWidget(0, 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};
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());
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 MapInfoControlRegInfo showRuler = mapInfoControls.registerAppearanceWidget(0, 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 MapInfoControlRegInfo transparent = mapInfoControls.registerAppearanceWidget(0, R.string.map_widget_transparent,
"transparent", view.getSettings().TRANSPARENT_MAP_THEME);
transparent.setStateChangeListener(new Runnable() {
@Override
public void run() {
ApplicationMode am = view.getSettings().getApplicationMode();
view.getSettings().TRANSPARENT_MAP_THEME.set(!view.getSettings().TRANSPARENT_MAP_THEME.get());
mapInfoLayer.recreateControls();
}
@ -71,11 +113,33 @@ public class OsmandExtraSettings extends OsmandPlugin {
fluorescent.setStateChangeListener(new Runnable() {
@Override
public void run() {
ApplicationMode am = view.getSettings().getApplicationMode();
view.getSettings().FLUORESCENT_OVERLAYS.set(!view.getSettings().FLUORESCENT_OVERLAYS.get());
view.refreshMap();
}
});
final CommonPreference<Integer> posPref = view.getSettings().POSITION_ON_MAP;
final MapInfoControlRegInfo posMap = mapInfoControls.registerAppearanceWidget(0, 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
@ -124,11 +188,13 @@ public class OsmandExtraSettings extends OsmandPlugin {
}
PreferenceScreen appearance = (PreferenceScreen) screen.findPreference("appearance_settings");
PreferenceCategory vectorSettings = new PreferenceCategory(app);
vectorSettings.setTitle(R.string.pref_vector_rendering);
vectorSettings.setKey("custom_vector_rendering");
appearance.addPreference(vectorSettings);
// cat = new PreferenceCategory(app);
// cat.setTitle(R.string.extra_settings);
// PreferenceScreen routing = (PreferenceScreen) screen.findPreference(SettingsActivity.SCREEN_ID_NAVIGATION_SETTINGS);
// routing.addPreference(cat);
// cat.addPreference(activity.createListPreference(settings.POSITION_ON_MAP,
// new String[] { activity.getString(R.string.position_on_map_center), activity.getString(R.string.position_on_map_bottom) },
// new Integer[] { OsmandSettings.CENTER_CONSTANT, OsmandSettings.BOTTOM_CONSTANT }, R.string.position_on_map,
// R.string.position_on_map_descr));
}
}

View file

@ -29,7 +29,6 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.ExpandableListContextMenuInfo;
import android.widget.TextView;
@ -188,9 +187,7 @@ public class LocalOpenstreetmapActivity extends OsmandExpandableListActivity {
private boolean interruptUploading = false;
public UploadOpenstreetmapPointAsyncTask(ProgressDialog progress,
OpenstreetmapRemoteUtil remotepoi,
OsmBugsRemoteUtil remotebug,
public UploadOpenstreetmapPointAsyncTask(ProgressDialog progress, OpenstreetmapRemoteUtil remotepoi, OsmBugsRemoteUtil remotebug,
int listSize) {
this.progress = progress;
this.remotepoi = remotepoi;
@ -203,7 +200,8 @@ public class LocalOpenstreetmapActivity extends OsmandExpandableListActivity {
int uploaded = 0;
for (OsmPoint point : points) {
if (interruptUploading) break;
if (interruptUploading)
break;
if (point.getGroup() == OsmPoint.Group.POI) {
OpenstreetmapPoint p = (OpenstreetmapPoint) point;
@ -214,10 +212,11 @@ public class LocalOpenstreetmapActivity extends OsmandExpandableListActivity {
Node n;
if ((n = remotepoi.commitNodeImpl(p.getAction(), p.getEntity(), entityInfo, p.getComment())) != null) {
if (point.getId() != n.getId()) {
//change all category points...
// change all category points...
listAdapter.categoryIdChanged(point.getId(), n.getId());
}
remotepoi.updateNodeInIndexes(LocalOpenstreetmapActivity.this, p.getAction(), n, p.getEntity());
dbpoi.deleteOpenstreetmap(p);
publishProgress(p);
uploaded++;
}
@ -225,10 +224,13 @@ public class LocalOpenstreetmapActivity extends OsmandExpandableListActivity {
OsmbugsPoint p = (OsmbugsPoint) point;
if (p.getAction() == OsmPoint.Action.CREATE) {
remotebug.createNewBug(p.getLatitude(), p.getLongitude(), p.getText(), p.getAuthor());
dbbug.deleteOsmbugs(p);
} else if (p.getAction() == OsmPoint.Action.MODIFY) {
remotebug.addingComment(p.getId(), p.getText(), p.getAuthor());
dbbug.deleteOsmbugs(p);
} else if (p.getAction() == OsmPoint.Action.DELETE) {
remotebug.closingBug(p.getId());
dbbug.deleteOsmbugs(p);
}
publishProgress(p);
uploaded++;
@ -256,8 +258,10 @@ public class LocalOpenstreetmapActivity extends OsmandExpandableListActivity {
@Override
protected void onPostExecute(Integer result) {
listAdapter.notifyDataSetChanged();
if(result != null){
AccessibleToast.makeText(LocalOpenstreetmapActivity.this, MessageFormat.format(getString(R.string.local_openstreetmap_were_uploaded), result.intValue()), Toast.LENGTH_LONG).show();
if (result != null) {
AccessibleToast.makeText(LocalOpenstreetmapActivity.this,
MessageFormat.format(getString(R.string.local_openstreetmap_were_uploaded), result.intValue()), Toast.LENGTH_LONG)
.show();
}
removeDialog(DIALOG_PROGRESS_UPLOAD);
}

View file

@ -486,6 +486,10 @@ public class MapRenderRepositories {
RenderingRuleSearchRequest renderingReq = new RenderingRuleSearchRequest(storage);
renderingReq.setBooleanFilter(renderingReq.ALL.R_NIGHT_MODE, nightMode);
for (RenderingRuleProperty customProp : storage.PROPS.getCustomRules()) {
if (customProp.isBoolean()) {
CommonPreference<Boolean> pref = prefs.getCustomRenderBooleanProperty(customProp.getAttrName());
renderingReq.setBooleanFilter(customProp, pref.get());
} else {
CommonPreference<String> settings = prefs.getCustomRenderProperty(customProp.getAttrName());
String res = settings.get();
if (!Algoritms.isEmpty(res)) {
@ -502,6 +506,7 @@ public class MapRenderRepositories {
}
}
}
}
renderingReq.saveState();
NativeOsmandLibrary nativeLib = prefs.NATIVE_RENDERING.get() ? NativeOsmandLibrary.getLibrary(storage) : null;

View file

@ -2,14 +2,17 @@ package net.osmand.plus.views;
import java.util.Comparator;
import java.util.EnumSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import net.osmand.Algoritms;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.CommonPreference;
import net.osmand.plus.OsmandSettings.OsmandPreference;
import net.osmand.plus.activities.ApplicationMode;
import android.view.View;
import android.view.ViewGroup;
@ -68,12 +71,12 @@ public class MapInfoControls {
}
public MapInfoControlRegInfo registerAppearanceWidget(int drawable, int messageId, String key,
CommonPreference<Boolean> pref) {
OsmandPreference<?> pref) {
MapInfoControlRegInfo ii = new MapInfoControlRegInfo();
ii.defaultModes = EnumSet.noneOf(ApplicationMode.class);
ii.defaultCollapsible = null;
ii.key = key;
ii.blPreference = pref;
ii.preference = pref;
ii.visibleModes = EnumSet.noneOf(ApplicationMode.class);
ii.visibleCollapsible = null;
ii.drawable = drawable;
@ -82,6 +85,32 @@ public class MapInfoControls {
return ii;
}
public void removeApperanceWidgets(String category) {
Iterator<MapInfoControlRegInfo> it = appearanceWidgets.iterator();
while(it.hasNext()) {
if(Algoritms.objectEquals(it.next().category, category)) {
it.remove();
}
}
}
public MapInfoControlRegInfo registerAppearanceWidget(int drawable, String message, String key,
CommonPreference<?> pref, String subcategory) {
MapInfoControlRegInfo ii = new MapInfoControlRegInfo();
ii.defaultModes = EnumSet.noneOf(ApplicationMode.class);
ii.defaultCollapsible = null;
ii.key = key;
ii.category = subcategory;
ii.preference = pref;
ii.visibleModes = EnumSet.noneOf(ApplicationMode.class);
ii.visibleCollapsible = null;
ii.drawable = drawable;
ii.messageId = message.hashCode();
ii.message = message;
this.appearanceWidgets.add(ii);
return ii;
}
public MapInfoControlRegInfo registerTopWidget(View m, int drawable, int messageId, String key, int left,
EnumSet<ApplicationMode> appDefaultModes, int priorityOrder) {
MapInfoControlRegInfo ii = new MapInfoControlRegInfo();
@ -93,8 +122,12 @@ public class MapInfoControls {
for(ApplicationMode ms : ApplicationMode.values() ) {
boolean def = appDefaultModes.contains(ms);
Set<String> set = visibleElements.get(ms);
if(set != null) {
def = set.contains(key);
if (set != null) {
if (set.contains(key)) {
def = true;
} else if (set.contains("-" + key)) {
def = false;
}
}
if(def){
ii.visibleModes.add(ms);
@ -124,8 +157,13 @@ public class MapInfoControls {
boolean def = appDefaultModes.contains(ms);
Set<String> set = visibleElements.get(ms);
if(set != null) {
def = set.contains(key);
collapse = set.contains("+"+key);
if (set.contains(key)) {
def = true;
} else if (set.contains("-" + key)) {
def = false;
} else if(set.contains("+"+key)){
collapse = true;
}
}
if(def){
ii.visibleModes.add(ms);
@ -145,45 +183,58 @@ public class MapInfoControls {
}
private void restoreModes(Set<String> set, Set<MapInfoControlRegInfo> mi, ApplicationMode mode) {
for(MapInfoControlRegInfo m : mi){
if(m.visibleModes.contains(mode)) {
set.add(m.key) ;
} else if(m.visibleCollapsible != null && m.visibleCollapsible.contains(mode)) {
set.add("+"+m.key) ;
for (MapInfoControlRegInfo m : mi) {
if (m.preference == null) {
if (m.visibleModes.contains(mode)) {
set.add(m.key);
} else if (m.visibleCollapsible != null && m.visibleCollapsible.contains(mode)) {
set.add("+" + m.key);
} else {
set.add("-" + m.key);
}
}
}
}
public void changeVisibility(MapInfoControlRegInfo m, boolean visible, boolean collapse) {
public void changeVisibility(MapInfoControlRegInfo m) {
boolean selecteable = m.selecteable();
if (selecteable) {
ApplicationMode mode = settings.APPLICATION_MODE.get();
if(this.visibleElements.get(mode) == null){
boolean visible = m.visible(mode);
boolean collapseEnabled = m.collapseEnabled(mode);
boolean collapse = m.visibleCollapsed(mode);
if (this.visibleElements.get(mode) == null) {
LinkedHashSet<String> set = new LinkedHashSet<String>();
restoreModes(set, left, mode);
restoreModes(set, right, mode);
restoreModes(set, top, mode);
this.visibleElements.put(mode, set);
}
// clear everything
this.visibleElements.get(mode).remove(m.key);
this.visibleElements.get(mode).remove("+" + m.key);
this.visibleElements.get(mode).remove("-" + m.key);
m.visibleModes.remove(mode);
if(m.visibleCollapsible != null) {
if (m.visibleCollapsible != null) {
m.visibleCollapsible.remove(mode);
}
if(visible) {
if(collapse && m.visibleCollapsible != null) {
if (visible || collapse) {
if (collapseEnabled && !collapse) {
m.visibleCollapsible.add(mode);
this.visibleElements.get(mode).add("+" + m.key);
} else {
m.visibleModes.add(mode);
this.visibleElements.get(mode).add(m.key);
this.visibleElements.get(mode).add("-" + m.key);
}
} else {
m.visibleModes.add(mode);
this.visibleElements.get(mode).add("" + m.key);
}
StringBuilder bs = new StringBuilder();
for(String ks : this.visibleElements.get(mode)){
for (String ks : this.visibleElements.get(mode)) {
bs.append(ks).append(";");
}
settings.MAP_INFO_CONTROLS.set(bs.toString());
}
if(m.stateChangeListener != null) {
m.stateChangeListener.run();
}
@ -233,24 +284,29 @@ public class MapInfoControls {
private void resetDefault(ApplicationMode mode, Set<MapInfoControlRegInfo> set ){
for(MapInfoControlRegInfo ri : set) {
if(ri.visibleCollapsible != null) {
if(ri.preference != null) {
ri.preference.resetToDefault();
} else {
if (ri.visibleCollapsible != null) {
ri.visibleCollapsible.remove(mode);
}
ri.visibleModes.remove(mode);
if(ri.defaultCollapsible != null && ri.defaultCollapsible.contains(mode)) {
if (ri.defaultCollapsible != null && ri.defaultCollapsible.contains(mode)) {
ri.visibleCollapsible.add(mode);
}
if(ri.defaultModes.contains(mode)) {
if (ri.defaultModes.contains(mode)) {
ri.visibleModes.add(mode);
}
}
}
}
public void resetToDefault() {
ApplicationMode appMode = settings.getApplicationMode();
resetDefault(appMode, left);
resetDefault(appMode, right);
resetDefault(appMode, top);
resetDefault(appMode, appearanceWidgets);
this.visibleElements.put(appMode, null);
settings.MAP_INFO_CONTROLS.set("");
}
@ -267,27 +323,41 @@ public class MapInfoControls {
public View m;
public int drawable;
public int messageId;
public String message;
private String key;
private int position;
private String category;
private EnumSet<ApplicationMode> defaultModes;
private EnumSet<ApplicationMode> defaultCollapsible;
private EnumSet<ApplicationMode> visibleModes;
private EnumSet<ApplicationMode> visibleCollapsible;
private CommonPreference<Boolean> blPreference = null;
private OsmandPreference<?> preference = null;
private Runnable stateChangeListener = null;
public int priorityOrder;
public boolean visibleCollapsed(ApplicationMode mode){
return blPreference == null && visibleCollapsible != null && visibleCollapsible.contains(mode);
return preference == null && visibleCollapsible != null && visibleCollapsible.contains(mode);
}
public boolean collapseEnabled(ApplicationMode mode){
return visibleCollapsible != null && blPreference == null;
return visibleCollapsible != null && preference == null;
}
public String getCategory() {
return category;
}
public boolean selecteable(){
return preference == null || (preference.get() instanceof Boolean);
}
public boolean visible(ApplicationMode mode){
if(blPreference != null) {
return blPreference.getModeValue(mode);
if(preference != null) {
Object value = preference.getModeValue(mode);
if(value instanceof Boolean) {
return ((Boolean) value).booleanValue();
}
return true;
}
return visibleModes.contains(mode);
}
@ -300,7 +370,7 @@ public class MapInfoControls {
}
public void setPreference(CommonPreference<Boolean> blPreference) {
this.blPreference = blPreference;
this.preference = blPreference;
}

View file

@ -2,19 +2,33 @@ package net.osmand.plus.views;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.EnumSet;
import java.util.LinkedHashSet;
import java.util.Set;
import net.osmand.Algoritms;
import net.osmand.access.AccessibleToast;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.OsmandSettings.CommonPreference;
import net.osmand.plus.activities.ApplicationMode;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.SettingsActivity;
import net.osmand.plus.extrasettings.OsmandExtraSettings;
import net.osmand.plus.routing.RouteDirectionInfo;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.views.MapInfoControls.MapInfoControlRegInfo;
import net.osmand.render.RenderingRuleProperty;
import net.osmand.render.RenderingRulesStorage;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
@ -34,6 +48,7 @@ import android.view.WindowManager;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.Toast;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.FrameLayout;
import android.widget.ImageView;
@ -73,6 +88,8 @@ public class MapInfoLayer extends OsmandMapLayer {
private LockInfoControl lockInfoControl;
private String ADDITIONAL_VECTOR_RENDERING_CATEGORY;
public MapInfoLayer(MapActivity map, RouteLayer layer){
this.map = map;
this.routeLayer = layer;
@ -86,6 +103,7 @@ public class MapInfoLayer extends OsmandMapLayer {
scaleCoefficient *= 1.5f;
}
ADDITIONAL_VECTOR_RENDERING_CATEGORY = map.getString(R.string.map_widget_vector_attributes);
paintText = new Paint();
paintText.setStyle(Style.FILL_AND_STROKE);
paintText.setColor(Color.BLACK);
@ -232,28 +250,91 @@ public class MapInfoLayer extends OsmandMapLayer {
private void registerAppearanceWidgets() {
final MapInfoControlRegInfo showRuler = mapInfoControls.registerAppearanceWidget(0, R.string.map_widget_show_ruler,
"showRuler", view.getSettings().SHOW_RULER);
showRuler.setStateChangeListener(new Runnable() {
final MapInfoControlRegInfo vectorRenderer = mapInfoControls.registerAppearanceWidget(0, R.string.map_widget_renderer,
"renderer", view.getSettings().RENDERER);
final OsmandApplication app = view.getApplication();
vectorRenderer.setStateChangeListener(new Runnable() {
@Override
public void run() {
ApplicationMode am = view.getSettings().getApplicationMode();
view.getSettings().SHOW_RULER.set(!view.getSettings().SHOW_RULER.get());
view.refreshMap();
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()]);
bld.setItems(items, 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);
}
});
bld.show();
}
});
final MapInfoControlRegInfo displayViewDirections = mapInfoControls.registerAppearanceWidget(0, R.string.map_widget_view_direction,
"viewDirection", view.getSettings().SHOW_VIEW_ANGLE);
displayViewDirections.setStateChangeListener(new Runnable() {
@Override
public void run() {
ApplicationMode am = view.getSettings().getApplicationMode();
view.getSettings().SHOW_VIEW_ANGLE.set(!view.getSettings().SHOW_VIEW_ANGLE.get());
map.updateApplicationModeSettings();
}
});
createCustomRenderingProperties(app.getRendererRegistry().getCurrentSelectedRenderer());
}
private void createCustomRenderingProperties(RenderingRulesStorage renderer) {
String categoryName = ADDITIONAL_VECTOR_RENDERING_CATEGORY;
mapInfoControls.removeApperanceWidgets(categoryName);
final OsmandApplication app = view.getApplication();
for (final RenderingRuleProperty p : renderer.PROPS.getCustomRules()) {
String propertyName = SettingsActivity.getStringPropertyName(view.getContext(), p.getAttrName(), p.getName());
if(p.isBoolean()) {
final CommonPreference<Boolean> pref = view.getApplication().getSettings().getCustomRenderBooleanProperty(p.getAttrName());
MapInfoControlRegInfo w = mapInfoControls.registerAppearanceWidget(0, 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());
MapInfoControlRegInfo w = mapInfoControls.registerAppearanceWidget(0, propertyName, "rend_"+p.getAttrName(), pref, categoryName);
w.setStateChangeListener(new Runnable() {
@Override
public void run() {
Builder b = new AlertDialog.Builder(view.getContext());
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();
}
});
}
}
}
@ -337,6 +418,27 @@ public class MapInfoLayer extends OsmandMapLayer {
recreateControls();
}
public Set<String> getSpecificVisibleCategories(Set<MapInfoControlRegInfo> m) {
Set<String> s = new LinkedHashSet<String>();
for(MapInfoControlRegInfo ms : m){
if(ms.getCategory() != null) {
s.add(ms.getCategory());
}
}
if(OsmandPlugin.getEnabledPlugin(OsmandExtraSettings.class) == null){
s.remove(ADDITIONAL_VECTOR_RENDERING_CATEGORY);
}
return s;
}
public void fillAppearanceWidgets(Set<MapInfoControlRegInfo> widgets, String category, ArrayList<Object> registry) {
for(MapInfoControlRegInfo w : widgets ) {
if(Algoritms.objectEquals(w.getCategory(), category)) {
registry.add(w);
}
}
}
public void openViewConfigureDialog() {
final OsmandSettings settings = view.getSettings();
@ -348,8 +450,15 @@ public class MapInfoLayer extends OsmandMapLayer {
list.addAll(mapInfoControls.getRight());
list.add(map.getString(R.string.map_widget_left_stack));
list.addAll(mapInfoControls.getLeft());
Set<MapInfoControlRegInfo> widgets = mapInfoControls.getAppearanceWidgets();
Set<String> cats = getSpecificVisibleCategories(widgets);
list.add(map.getString(R.string.map_widget_appearance));
list.addAll(mapInfoControls.getAppearanceWidgets());
fillAppearanceWidgets(widgets, null, list);
for(String cat : cats) {
list.add(cat);
fillAppearanceWidgets(widgets, cat, list);
}
// final LayerMenuListener listener = new LayerMenuListener(adapter, mapView, settings);
@ -367,8 +476,13 @@ public class MapInfoLayer extends OsmandMapLayer {
Object o = list.get(position);
if(o instanceof MapInfoControlRegInfo) {
final MapInfoControlRegInfo mi = (MapInfoControlRegInfo) o;
String s = mi.visibleCollapsed(mode)? " - " : " ";
if(mi.message != null) {
tv.setText(s +mi.message +s);
} else {
tv.setText(s +map.getString(mi.messageId) +s);
}
// Put the image on the TextView
if (mi.drawable != 0) {
tv.setPadding((int) (12 *scaleCoefficient), 0, 0, 0);
@ -377,29 +491,31 @@ public class MapInfoLayer extends OsmandMapLayer {
tv.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
tv.setPadding((int) (30 *scaleCoefficient), 0, 0, 0);
}
boolean check = mi.visibleCollapsed(mode) || mi.visible(mode);
final boolean selecteable = mi.selecteable();
ch.setOnCheckedChangeListener(null);
if(!mi.selecteable()) {
ch.setVisibility(View.INVISIBLE);
} else {
boolean check = mi.visibleCollapsed(mode) || mi.visible(mode);
ch.setChecked(check);
ch.setVisibility(View.VISIBLE);
}
ch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(!isChecked) {
if(mi.visible(mode) && mi.collapseEnabled(mode)) {
mapInfoControls.changeVisibility(mi, true, true);
ch.setChecked(true);
} else {
mapInfoControls.changeVisibility(mi, false, false);
}
} else {
mapInfoControls.changeVisibility(mi, true, false);
mapInfoControls.changeVisibility(mi);
if (selecteable) {
ch.setChecked(mi.visible(mode) || mi.visibleCollapsed(mode));
}
String s = mi.visibleCollapsed(mode) ? " - " : " ";
tv.setText(s + map.getString(mi.messageId) + s);
if(mi.message != null) {
tv.setText(s +mi.message +s);
} else {
tv.setText(s +map.getString(mi.messageId) +s);
}
recreateControls();
}
});
ch.setVisibility(View.VISIBLE);
} else {
tv.setText(o.toString());
tv.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
@ -417,11 +533,10 @@ public class MapInfoLayer extends OsmandMapLayer {
Object o = list.get(position);
if (o instanceof MapInfoControlRegInfo) {
final MapInfoControlRegInfo mi = (MapInfoControlRegInfo) o;
final boolean selecteable = mi.selecteable();
boolean check = mi.visibleCollapsed(mode) || mi.visible(mode);
if (check) {
mapInfoControls.changeVisibility(mi, false, false);
} else {
mapInfoControls.changeVisibility(mi, true, false);
if (check || selecteable) {
mapInfoControls.changeVisibility(mi);
}
recreateControls();
} else if(o.toString().equals(map.getString(R.string.map_widget_reset))) {