Updated configure settings screen
This commit is contained in:
parent
b7670d168d
commit
8554edd9ac
5 changed files with 363 additions and 238 deletions
43
OsmAnd/res/layout/map_settings_item.xml
Normal file
43
OsmAnd/res/layout/map_settings_item.xml
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp">
|
||||
<ImageButton android:id="@+id/back"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"/>
|
||||
<ImageView android:id="@+id/icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
android:layout_gravity="center_vertical"/>
|
||||
|
||||
<LinearLayout android:orientation="vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_marginTop="10dp">
|
||||
<TextView android:id="@+id/name"
|
||||
android:textSize="16sp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
<TextView android:id="@+id/descr"
|
||||
android:textSize="14sp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"/>
|
||||
</LinearLayout>
|
||||
|
||||
<CheckBox android:id="@+id/check"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</LinearLayout>
|
|
@ -9,6 +9,7 @@
|
|||
3. 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="configure_map">Configure map</string>
|
||||
<string name="search_radius">Search radius</string>
|
||||
<string name="osmo_device_not_found">Device not found</string>
|
||||
<string name="osmo_no_connection_msg">OsMo service is not available:\n- check the connection;\n- check the settings;\n- check out our Twitter: https://twitter.com/OsMomobi</string>
|
||||
|
|
|
@ -124,11 +124,11 @@ public class MapActivity extends AccessibleActivity {
|
|||
settings = app.getSettings();
|
||||
app.applyTheme(this);
|
||||
super.onCreate(savedInstanceState);
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
|
||||
|
||||
mapActions = new MapActivityActions(this);
|
||||
mapLayers = new MapActivityLayers(this);
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
// Full screen is not used here
|
||||
//getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.main);
|
||||
|
|
|
@ -98,6 +98,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
DrawerLayout mDrawerLayout;
|
||||
ListView mDrawerList;
|
||||
private WaypointDialogHelper waypointDialogHelper;
|
||||
private ConfigureSettingsMenuHelper configureSettingsMenuHelper;
|
||||
|
||||
|
||||
public MapActivityActions(MapActivity mapActivity){
|
||||
|
@ -105,6 +106,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
settings = mapActivity.getMyApplication().getSettings();
|
||||
routingHelper = mapActivity.getMyApplication().getRoutingHelper();
|
||||
waypointDialogHelper = new WaypointDialogHelper(mapActivity);
|
||||
configureSettingsMenuHelper = new ConfigureSettingsMenuHelper(mapActivity.getMyApplication());
|
||||
waypointDialogHelper.init();
|
||||
}
|
||||
|
||||
|
@ -906,7 +908,6 @@ public class MapActivityActions implements DialogProvider {
|
|||
|
||||
final List<WaypointHelper.LocationPointWrapper> deletedPoints = new ArrayList<WaypointHelper.LocationPointWrapper>();
|
||||
ArrayAdapter<Object> adapter = waypointDialogHelper.getWaypointsAdapter(app.getMapActivity(), deletedPoints);
|
||||
mDrawerList = (ListView) mapActivity.findViewById(R.id.left_drawer);
|
||||
mDrawerList.setAdapter(adapter);
|
||||
return false;
|
||||
} else {
|
||||
|
@ -922,8 +923,8 @@ public class MapActivityActions implements DialogProvider {
|
|||
.listen(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
mapActivity.startActivity(new Intent(mapActivity, ConfigureSettingsMenuHelper.class));
|
||||
return true;
|
||||
configureSettingsMenuHelper.setListView(mDrawerList);
|
||||
return false;
|
||||
//mapActivity.getMapLayers().openLayerSelectionDialog(mapView);
|
||||
}
|
||||
}).reg();
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
package net.osmand.plus.configuremap;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Build;
|
||||
import android.preference.*;
|
||||
import android.util.TypedValue;
|
||||
import android.view.KeyEvent;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListAdapter;
|
||||
import android.widget.Toast;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.*;
|
||||
import net.osmand.CallbackWithObject;
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.data.AmenityType;
|
||||
|
@ -18,9 +19,11 @@ import net.osmand.plus.activities.*;
|
|||
import net.osmand.plus.helpers.GpxUiHelper;
|
||||
import net.osmand.plus.render.RenderingIcons;
|
||||
import net.osmand.plus.views.mapwidgets.AppearanceWidgetsFactory;
|
||||
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry;
|
||||
import net.osmand.render.RenderingRuleProperty;
|
||||
import net.osmand.render.RenderingRulesStorage;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
@ -31,23 +34,29 @@ import java.util.List;
|
|||
*/
|
||||
public class ConfigureSettingsMenuHelper {
|
||||
|
||||
public static final int HEADER = 0;
|
||||
public static final int LAYER = 1;
|
||||
public static final int MAP_REDNDER = 2;
|
||||
public static final int RENDERING_ATTR = 3;
|
||||
public static final int BACK_HEADER = 0;
|
||||
public static final int HEADER = 1;
|
||||
public static final int LAYER = 2;
|
||||
public static final int MAP_REDNDER = 3;
|
||||
public static final int RENDERING_PROPERTY = 4;
|
||||
|
||||
|
||||
private ListView listView;
|
||||
private OsmandApplication app;
|
||||
|
||||
public class ConfigureMapMenuItem {
|
||||
int nameId;
|
||||
int type;
|
||||
int darkIcon = -1;
|
||||
int whiteIcon = -1;
|
||||
int lightIcon = -1;
|
||||
Object preference;
|
||||
|
||||
ConfigureMapMenuItem(int type, int darkIcon, int whiteIcon, Object preference){
|
||||
|
||||
ConfigureMapMenuItem(int type, int name, int darkIcon, int whiteIcon, Object preference) {
|
||||
this.type = type;
|
||||
this.nameId = name;
|
||||
this.darkIcon = darkIcon;
|
||||
this.whiteIcon = whiteIcon;
|
||||
this.lightIcon = whiteIcon;
|
||||
this.preference = preference;
|
||||
}
|
||||
}
|
||||
|
@ -56,22 +65,41 @@ public class ConfigureSettingsMenuHelper{
|
|||
this.app = app;
|
||||
}
|
||||
|
||||
private ArrayAdapter<ConfigureMapMenuItem> createAllCategories() {
|
||||
List<ConfigureMapMenuItem> items = new ArrayList<ConfigureMapMenuItem>();
|
||||
createLayersItems(items);
|
||||
createRenderingAttributePreferences();
|
||||
public void setListView(ListView listView){
|
||||
this.listView = listView;
|
||||
listView.setAdapter(createSettingsAdapter());
|
||||
}
|
||||
|
||||
private void createRenderingAttributePreferences() {
|
||||
PreferenceCategory renderingCategory = new PreferenceCategory(this);
|
||||
|
||||
grp.addPreference(renderingCategory);
|
||||
Preference p = new Preference(this);
|
||||
p.setTitle(R.string.map_widget_renderer);
|
||||
p.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
private ArrayAdapter<ConfigureMapMenuItem> createSettingsAdapter() {
|
||||
List<ConfigureMapMenuItem> items = new ArrayList<ConfigureMapMenuItem>();
|
||||
items.add(new ConfigureMapMenuItem(BACK_HEADER, R.string.configure_map, R.drawable.ic_action_undo_dark, R.drawable.ic_action_undo_light, null));
|
||||
createLayersItems(items);
|
||||
createRenderingAttributeItems(items);
|
||||
return new ArrayAdapter<ConfigureMapMenuItem>(app, R.layout.map_settings_item, items) {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
AlertDialog.Builder bld = new AlertDialog.Builder(getActivity());
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
if (convertView == null) {
|
||||
convertView = app.getMapActivity().getLayoutInflater().inflate(R.layout.map_settings_item, null);
|
||||
}
|
||||
ConfigureMapMenuItem item = getItem(position);
|
||||
prepareView(convertView, item);
|
||||
if (item.type == BACK_HEADER){
|
||||
((TextView) convertView.findViewById(R.id.name)).setText(item.nameId);
|
||||
ImageButton button = (ImageButton) convertView.findViewById(R.id.back);
|
||||
button.setImageResource(getIcon(item));
|
||||
} else if (item.type == HEADER) {
|
||||
((TextView) convertView.findViewById(R.id.name)).setText((String) item.preference);
|
||||
} else if (item.type == LAYER) {
|
||||
((TextView) convertView.findViewById(R.id.name)).setText(item.nameId);
|
||||
setLayersCheckBox(item, (CheckBox) convertView.findViewById(R.id.check));
|
||||
} else if (item.type == MAP_REDNDER) {
|
||||
((TextView) convertView.findViewById(R.id.name)).setText(item.nameId);
|
||||
if (item.nameId == R.string.map_widget_renderer) {
|
||||
convertView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
AlertDialog.Builder bld = new AlertDialog.Builder(app.getMapActivity());
|
||||
bld.setTitle(R.string.renderers);
|
||||
Collection<String> rendererNames = app.getRendererRegistry().getRendererNames();
|
||||
final String[] items = rendererNames.toArray(new String[rendererNames.size()]);
|
||||
|
@ -99,86 +127,71 @@ public class ConfigureSettingsMenuHelper{
|
|||
AccessibleToast.makeText(app, R.string.renderer_load_exception, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
dialog.dismiss();
|
||||
createAllCategories();
|
||||
createSettingsAdapter();
|
||||
}
|
||||
});
|
||||
bld.show();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
p = new Preference(this);
|
||||
p.setTitle(R.string.map_widget_day_night);
|
||||
p.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
} else if (item.nameId == R.string.map_widget_day_night) {
|
||||
convertView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
AlertDialog.Builder bld = new AlertDialog.Builder(getActivity());
|
||||
public void onClick(View view) {
|
||||
AlertDialog.Builder bld = new AlertDialog.Builder(app.getMapActivity());
|
||||
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(getMyApplication());
|
||||
items[i] = OsmandSettings.DayNightMode.values()[i].toHumanString(app);
|
||||
}
|
||||
int i = getMyApplication().getSettings().DAYNIGHT_MODE.get().ordinal();
|
||||
int i = app.getSettings().DAYNIGHT_MODE.get().ordinal();
|
||||
bld.setSingleChoiceItems(items, i, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
getMyApplication().getSettings().DAYNIGHT_MODE.set(OsmandSettings.DayNightMode.values()[which]);
|
||||
getMyApplication().getResourceManager().getRenderer().clearCache();
|
||||
app.getSettings().DAYNIGHT_MODE.set(OsmandSettings.DayNightMode.values()[which]);
|
||||
app.getResourceManager().getRenderer().clearCache();
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
bld.show();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
grp.addPreference(p);
|
||||
|
||||
RenderingRulesStorage renderer = getMyApplication().getRendererRegistry().getCurrentSelectedRenderer();
|
||||
if(renderer != null && AppearanceWidgetsFactory.EXTRA_SETTINGS) {
|
||||
createMapRenderingPreferences();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void createMapRenderingPreferences() {
|
||||
|
||||
RenderingRulesStorage renderer = app.getRendererRegistry().getCurrentSelectedRenderer();
|
||||
List<RenderingRuleProperty> customRules = renderer.PROPS.getCustomRules();
|
||||
for (final RenderingRuleProperty p : customRules) {
|
||||
String propertyName = SettingsActivity.getStringPropertyName(getActivity(), p.getAttrName(), p.getName());
|
||||
//test old descr as title
|
||||
final String propertyDescr = SettingsActivity.getStringPropertyDescription(getActivity(), p.getAttrName(), p.getName());
|
||||
} else if (item.type == RENDERING_PROPERTY) {
|
||||
convertView.findViewById(R.id.icon).setVisibility(View.GONE);
|
||||
final RenderingRuleProperty p = (RenderingRuleProperty) item.preference;
|
||||
String propertyName = SettingsActivity.getStringPropertyName(app, p.getAttrName(), p.getName());
|
||||
TextView header = (TextView) convertView.findViewById(R.id.name);
|
||||
header.setText(propertyName);
|
||||
header.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
|
||||
convertView.findViewById(R.id.icon).setVisibility(View.GONE);
|
||||
final String propertyDescription = SettingsActivity.getStringPropertyDescription(app, p.getAttrName(), p.getName());
|
||||
if (p.isBoolean()) {
|
||||
final OsmandSettings.CommonPreference<Boolean> pref = app.getSettings().getCustomRenderBooleanProperty(p.getAttrName());
|
||||
preference.setTitle(propertyName);
|
||||
|
||||
preference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
CheckBox ch = (CheckBox) convertView.findViewById(R.id.check);
|
||||
ch.setChecked(pref.get());
|
||||
ch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
||||
pref.set(!pref.get());
|
||||
app.getResourceManager().getRenderer().clearCache();
|
||||
return true;
|
||||
//view.refreshMap(true);
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
final OsmandSettings.CommonPreference<String> pref = getMyApplication().getSettings().getCustomRenderProperty(p.getAttrName());
|
||||
Preference preference = new Preference(getActivity());
|
||||
preference.setTitle(propertyName);
|
||||
renderingCategory.addPreference(preference);
|
||||
preference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
final OsmandSettings.CommonPreference<String> pref = app.getSettings().getCustomRenderProperty(p.getAttrName());
|
||||
convertView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
AlertDialog.Builder b = new AlertDialog.Builder(getActivity());
|
||||
public void onClick(View view) {
|
||||
AlertDialog.Builder b = new AlertDialog.Builder(app.getMapActivity());
|
||||
//test old descr as title
|
||||
b.setTitle(propertyDescr);
|
||||
b.setTitle(propertyDescription);
|
||||
|
||||
int i = Arrays.asList(p.getPossibleValues()).indexOf(pref.get());
|
||||
|
||||
String[] possibleValuesString = new String[p.getPossibleValues().length];
|
||||
|
||||
for (int j = 0; j < p.getPossibleValues().length; j++) {
|
||||
possibleValuesString[j] = SettingsActivity.getStringPropertyValue(getApplication(), p.getPossibleValues()[j]);
|
||||
possibleValuesString[j] = SettingsActivity.getStringPropertyValue(app, p.getPossibleValues()[j]);
|
||||
}
|
||||
|
||||
b.setSingleChoiceItems(possibleValuesString, i, new DialogInterface.OnClickListener() {
|
||||
|
@ -186,98 +199,169 @@ public class ConfigureSettingsMenuHelper{
|
|||
public void onClick(DialogInterface dialog, int which) {
|
||||
pref.set(p.getPossibleValues()[which]);
|
||||
app.getResourceManager().getRenderer().clearCache();
|
||||
//view.refreshMap(true);
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
b.show();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return convertView;
|
||||
}
|
||||
|
||||
//Hiding and showing items based on current item
|
||||
//setting proper visual property
|
||||
private void prepareView(View convertView, ConfigureMapMenuItem item) {
|
||||
int type = item.type;
|
||||
//setting name textview
|
||||
if (type == BACK_HEADER) {
|
||||
TextView header = (TextView) convertView.findViewById(R.id.name);
|
||||
header.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22);
|
||||
header.setTypeface(Typeface.DEFAULT_BOLD);
|
||||
} else if (type == HEADER) {
|
||||
TextView header = (TextView) convertView.findViewById(R.id.name);
|
||||
header.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
|
||||
header.setTypeface(Typeface.DEFAULT_BOLD);
|
||||
} else {
|
||||
((TextView) convertView.findViewById(R.id.name)).setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
|
||||
}
|
||||
|
||||
//setting backbutton
|
||||
if (type == BACK_HEADER) {
|
||||
convertView.findViewById(R.id.back).setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
convertView.findViewById(R.id.back).setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
//other elements
|
||||
if (type == BACK_HEADER) {
|
||||
convertView.findViewById(R.id.check).setVisibility(View.GONE);
|
||||
convertView.findViewById(R.id.descr).setVisibility(View.GONE);
|
||||
convertView.findViewById(R.id.icon).setVisibility(View.GONE);
|
||||
} else if (type == HEADER) {
|
||||
convertView.findViewById(R.id.icon).setVisibility(View.GONE);
|
||||
convertView.findViewById(R.id.check).setVisibility(View.GONE);
|
||||
convertView.findViewById(R.id.descr).setVisibility(View.GONE);
|
||||
} else if (type == LAYER) {
|
||||
((ImageView) convertView.findViewById(R.id.icon)).setImageResource(getIcon(item));
|
||||
convertView.findViewById(R.id.icon).setVisibility(View.VISIBLE);
|
||||
} else if (type == MAP_REDNDER) {
|
||||
convertView.findViewById(R.id.icon).setVisibility(View.GONE);
|
||||
convertView.findViewById(R.id.check).setVisibility(View.GONE);
|
||||
} else if (type == RENDERING_PROPERTY) {
|
||||
final RenderingRuleProperty p = (RenderingRuleProperty) item.preference;
|
||||
if (p.isBoolean()) {
|
||||
convertView.findViewById(R.id.check).setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
convertView.findViewById(R.id.check).setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private int getIcon(ConfigureMapMenuItem item) {
|
||||
if (app.getSettings().isLightContent()) {
|
||||
return item.lightIcon;
|
||||
} else {
|
||||
return item.darkIcon;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void createLayersItems(List<ConfigureMapMenuItem> items) {
|
||||
items.add(new ConfigureMapMenuItem(HEADER,-1,-1,R.string.show));
|
||||
grp.addPreference(mapLayersCategory);
|
||||
final CheckBoxPreference poi = new CheckBoxPreference(this);
|
||||
poi.setTitle(R.string.layer_poi);
|
||||
poi.setChecked(settings.SHOW_POI_OVER_MAP.get());
|
||||
addIcon(poi, R.drawable.ic_action_info_light, R.drawable.ic_action_info_dark);
|
||||
poi.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
private void setLayersCheckBox(ConfigureMapMenuItem item, CheckBox check) {
|
||||
check.setVisibility(View.VISIBLE);
|
||||
if (item.nameId == R.string.layer_poi) {
|
||||
final OsmandSettings.OsmandPreference<Boolean> pref = (OsmandSettings.OsmandPreference<Boolean>) item.preference;
|
||||
check.setChecked(pref.get());
|
||||
check.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
settings.SHOW_POI_OVER_MAP.set(!settings.SHOW_POI_OVER_MAP.get());
|
||||
if (settings.SHOW_POI_OVER_MAP.get()) {
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
||||
if (b) {
|
||||
selectPOIFilterLayer(null);
|
||||
} else {
|
||||
poi.setSummary("");
|
||||
pref.set(b);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
if (settings.SHOW_POI_OVER_MAP.get()) {
|
||||
poi.setSummary(settings.getPoiFilterForMap());
|
||||
}
|
||||
mapLayersCategory.addPreference(poi);
|
||||
CheckBoxPreference p = createCheckBoxPreference(settings.SHOW_POI_LABEL, R.string.layer_amenity_label,
|
||||
R.drawable.ic_action_text_dark, R.drawable.ic_action_text_light);
|
||||
mapLayersCategory.addPreference(p);
|
||||
|
||||
p = createCheckBoxPreference(settings.SHOW_FAVORITES, R.string.layer_favorites,
|
||||
R.drawable.ic_action_fav_dark, R.drawable.ic_action_fav_light);
|
||||
mapLayersCategory.addPreference(p);
|
||||
final CheckBoxPreference gpx = new CheckBoxPreference(this);
|
||||
gpx.setTitle(R.string.layer_gpx_layer);
|
||||
addIcon(gpx, R.drawable.ic_action_polygom_light, R.drawable.ic_action_polygom_dark);
|
||||
gpx.setChecked(getMyApplication().getSelectedGpxHelper().isShowingAnyGpxFiles());
|
||||
gpx.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
} else if (item.nameId == R.string.layer_gpx_layer) {
|
||||
check.setChecked(app.getSelectedGpxHelper().isShowingAnyGpxFiles());
|
||||
check.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
if (gpx.isChecked()){
|
||||
showGPXFileDialog(getAlreadySelectedGpx());
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
||||
if (b) {
|
||||
showGPXFileDialog(null);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
mapLayersCategory.addPreference(gpx);
|
||||
p = createCheckBoxPreference(settings.SHOW_TRANSPORT_OVER_MAP, R.string.layer_transport,
|
||||
R.drawable.ic_action_bus_dark, R.drawable.ic_action_bus_light);
|
||||
mapLayersCategory.addPreference(p);
|
||||
if (TransportRouteHelper.getInstance().routeIsCalculated()) {
|
||||
p = new CheckBoxPreference(this);
|
||||
p.setChecked(true);
|
||||
addIcon(p, R.drawable.ic_action_bus_light, R.drawable.ic_action_bus_dark);
|
||||
mapLayersCategory.addPreference(p);
|
||||
}
|
||||
}
|
||||
|
||||
public void addIcon(CheckBoxPreference p, int lightIcon, int darkIcon) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||
if (getMyApplication().getSettings().isLightContent()) {
|
||||
p.setIcon(lightIcon);
|
||||
} else if (item.nameId == R.string.layer_transport && TransportRouteHelper.getInstance().routeIsCalculated()) {
|
||||
check.setChecked(true);
|
||||
} else {
|
||||
p.setIcon(darkIcon);
|
||||
final OsmandSettings.OsmandPreference<Boolean> pref = (OsmandSettings.OsmandPreference<Boolean>) item.preference;
|
||||
check.setChecked(pref.get());
|
||||
check.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
||||
pref.set(b);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
private void createLayersItems(List<ConfigureMapMenuItem> items) {
|
||||
items.add(new ConfigureMapMenuItem(HEADER, -1, -1, -1, "Show:"));
|
||||
items.add(new ConfigureMapMenuItem(LAYER, R.string.layer_poi, R.drawable.ic_action_info_dark,
|
||||
R.drawable.ic_action_info_light, app.getSettings().SHOW_POI_OVER_MAP));
|
||||
items.add(new ConfigureMapMenuItem(LAYER, R.string.layer_amenity_label, R.drawable.ic_action_text_dark,
|
||||
R.drawable.ic_action_text_light, app.getSettings().SHOW_POI_LABEL));
|
||||
items.add(new ConfigureMapMenuItem(LAYER, R.string.layer_favorites, R.drawable.ic_action_fav_dark,
|
||||
R.drawable.ic_action_fav_light, app.getSettings().SHOW_FAVORITES));
|
||||
items.add(new ConfigureMapMenuItem(LAYER, R.string.layer_gpx_layer, R.drawable.ic_action_polygom_dark,
|
||||
R.drawable.ic_action_polygom_light, null));
|
||||
items.add(new ConfigureMapMenuItem(LAYER, R.string.layer_transport, R.drawable.ic_action_bus_dark,
|
||||
R.drawable.ic_action_bus_light, app.getSettings().SHOW_TRANSPORT_OVER_MAP));
|
||||
if (TransportRouteHelper.getInstance().routeIsCalculated()) {
|
||||
items.add(new ConfigureMapMenuItem(R.string.layer_transport, LAYER,
|
||||
R.drawable.ic_action_bus_dark, R.drawable.ic_action_bus_light, 1));
|
||||
}
|
||||
}
|
||||
|
||||
private void createRenderingAttributeItems(List<ConfigureMapMenuItem> items) {
|
||||
items.add(new ConfigureMapMenuItem(HEADER, -1, -1, -1, app.getString(R.string.map_widget_map_rendering)));
|
||||
items.add(new ConfigureMapMenuItem(MAP_REDNDER, R.string.map_widget_renderer, -1, -1, null));
|
||||
items.add(new ConfigureMapMenuItem(MAP_REDNDER, R.string.map_widget_day_night, -1, -1, null));
|
||||
|
||||
RenderingRulesStorage renderer = app.getRendererRegistry().getCurrentSelectedRenderer();
|
||||
if (renderer != null && AppearanceWidgetsFactory.EXTRA_SETTINGS) {
|
||||
createMapRenderingPreferences(items);
|
||||
}
|
||||
}
|
||||
|
||||
private void createMapRenderingPreferences(List<ConfigureMapMenuItem> items) {
|
||||
items.add(new ConfigureMapMenuItem(HEADER, -1, -1, -1, app.getString(R.string.map_widget_vector_attributes)));
|
||||
RenderingRulesStorage renderer = app.getRendererRegistry().getCurrentSelectedRenderer();
|
||||
List<RenderingRuleProperty> customRules = renderer.PROPS.getCustomRules();
|
||||
for (RenderingRuleProperty p : customRules) {
|
||||
items.add(new ConfigureMapMenuItem(RENDERING_PROPERTY, -1, -1, -1, p));
|
||||
}
|
||||
}
|
||||
|
||||
public AlertDialog selectPOIFilterLayer(final PoiFilter[] selected) {
|
||||
final List<PoiFilter> userDefined = new ArrayList<PoiFilter>();
|
||||
OsmandApplication app = (OsmandApplication) getApplication();
|
||||
final PoiFiltersHelper poiFilters = app.getPoiFilters();
|
||||
final ContextMenuAdapter adapter = new ContextMenuAdapter(this);
|
||||
final ContextMenuAdapter adapter = new ContextMenuAdapter(app.getMapActivity());
|
||||
|
||||
ContextMenuAdapter.Item is = adapter.item(getString(R.string.any_poi));
|
||||
ContextMenuAdapter.Item is = adapter.item(app.getString(R.string.any_poi));
|
||||
if (RenderingIcons.containsBigIcon("null")) {
|
||||
is.icon(RenderingIcons.getBigIconResourceId("null"));
|
||||
}
|
||||
is.reg();
|
||||
// 2nd custom
|
||||
adapter.item(getString(R.string.poi_filter_custom_filter)).icon(RenderingIcons.getBigIconResourceId("user_defined")).reg();
|
||||
adapter.item(app.getString(R.string.poi_filter_custom_filter)).icon(RenderingIcons.getBigIconResourceId("user_defined")).reg();
|
||||
|
||||
for (PoiFilter f : poiFilters.getUserDefinedPoiFilters()) {
|
||||
ContextMenuAdapter.Item it = adapter.item(f.getName());
|
||||
|
@ -291,20 +375,20 @@ public class ConfigureSettingsMenuHelper{
|
|||
}
|
||||
final AmenityType[] categories = AmenityType.getCategories();
|
||||
for (AmenityType t : categories) {
|
||||
ContextMenuAdapter.Item it = adapter.item(OsmAndFormatter.toPublicString(t, getMyApplication()));
|
||||
ContextMenuAdapter.Item it = adapter.item(OsmAndFormatter.toPublicString(t, app));
|
||||
if (RenderingIcons.containsBigIcon(t.toString().toLowerCase())) {
|
||||
it.icon(RenderingIcons.getBigIconResourceId(t.toString().toLowerCase()));
|
||||
}
|
||||
it.reg();
|
||||
}
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(app.getMapActivity());
|
||||
ListAdapter listAdapter;
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
|
||||
listAdapter =
|
||||
adapter.createListAdapter(this, R.layout.list_menu_item, app.getSettings().isLightContentMenu());
|
||||
adapter.createListAdapter(app.getMapActivity(), R.layout.list_menu_item, app.getSettings().isLightContentMenu());
|
||||
} else {
|
||||
listAdapter =
|
||||
adapter.createListAdapter(this, R.layout.list_menu_item_native, app.getSettings().isLightContentMenu());
|
||||
adapter.createListAdapter(app.getMapActivity(), R.layout.list_menu_item_native, app.getSettings().isLightContentMenu());
|
||||
}
|
||||
builder.setAdapter(listAdapter, new DialogInterface.OnClickListener() {
|
||||
|
||||
|
@ -312,12 +396,12 @@ public class ConfigureSettingsMenuHelper{
|
|||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (which == 1) {
|
||||
String filterId = PoiFilter.CUSTOM_FILTER_ID;
|
||||
getMyApplication().getSettings().setPoiFilterForMap(filterId);
|
||||
Intent newIntent = new Intent(getApplication(), EditPOIFilterActivity.class);
|
||||
app.getSettings().setPoiFilterForMap(filterId);
|
||||
Intent newIntent = new Intent(app, EditPOIFilterActivity.class);
|
||||
newIntent.putExtra(EditPOIFilterActivity.AMENITY_FILTER, filterId);
|
||||
//newIntent.putExtra(EditPOIFilterActivity.SEARCH_LAT, getMyApplication().getMapActivity().getMapView().getLatitude());
|
||||
//newIntent.putExtra(EditPOIFilterActivity.SEARCH_LON, getMyApplication().getMapActivity().getMapView().getLongitude());
|
||||
getActivity().startActivity(newIntent);
|
||||
app.getMapActivity().startActivity(newIntent);
|
||||
} else {
|
||||
String filterId;
|
||||
if (which == 0) {
|
||||
|
@ -327,7 +411,7 @@ public class ConfigureSettingsMenuHelper{
|
|||
} else {
|
||||
filterId = PoiFiltersHelper.getOsmDefinedFilterId(categories[which - userDefined.size() - 2]);
|
||||
}
|
||||
getMyApplication().getSettings().setPoiFilterForMap(filterId);
|
||||
app.getSettings().setPoiFilterForMap(filterId);
|
||||
PoiFilter f = poiFilters.getFilterById(filterId);
|
||||
if (f != null) {
|
||||
f.clearNameFilter();
|
||||
|
@ -335,7 +419,7 @@ public class ConfigureSettingsMenuHelper{
|
|||
if (selected != null && selected.length > 0) {
|
||||
selected[0] = f;
|
||||
}
|
||||
createAllCategories();
|
||||
createSettingsAdapter();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -347,8 +431,8 @@ public class ConfigureSettingsMenuHelper{
|
|||
event.getAction() == KeyEvent.ACTION_UP &&
|
||||
!event.isCanceled()) {
|
||||
dialogInterface.cancel();
|
||||
settings.SHOW_POI_OVER_MAP.set(false);
|
||||
createAllCategories();
|
||||
app.getSettings().SHOW_POI_OVER_MAP.set(false);
|
||||
createSettingsAdapter();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -357,10 +441,6 @@ public class ConfigureSettingsMenuHelper{
|
|||
return builder.show();
|
||||
}
|
||||
|
||||
private Activity getActivity() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public void showGPXFileDialog(List<String> files) {
|
||||
CallbackWithObject<GPXUtilities.GPXFile[]> callbackWithObject = new CallbackWithObject<GPXUtilities.GPXFile[]>() {
|
||||
@Override
|
||||
|
@ -368,9 +448,9 @@ public class ConfigureSettingsMenuHelper{
|
|||
GPXUtilities.WptPt locToShow = null;
|
||||
for (GPXUtilities.GPXFile g : result) {
|
||||
if (g.showCurrentTrack) {
|
||||
if (!settings.SAVE_TRACK_TO_GPX.get() && !
|
||||
settings.SAVE_GLOBAL_TRACK_TO_GPX.get()) {
|
||||
AccessibleToast.makeText(getActivity(), R.string.gpx_monitoring_disabled_warn, Toast.LENGTH_SHORT).show();
|
||||
if (!app.getSettings().SAVE_TRACK_TO_GPX.get() && !
|
||||
app.getSettings().SAVE_GLOBAL_TRACK_TO_GPX.get()) {
|
||||
AccessibleToast.makeText(app.getMapActivity(), R.string.gpx_monitoring_disabled_warn, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -378,21 +458,21 @@ public class ConfigureSettingsMenuHelper{
|
|||
locToShow = g.findPointToShow();
|
||||
}
|
||||
}
|
||||
getMyApplication().getSelectedGpxHelper().setGpxFileToDisplay(result);
|
||||
createAllCategories();
|
||||
app.getSelectedGpxHelper().setGpxFileToDisplay(result);
|
||||
createSettingsAdapter();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
if (files == null) {
|
||||
GpxUiHelper.selectGPXFile(getActivity(), true, true, callbackWithObject);
|
||||
GpxUiHelper.selectGPXFile(app.getMapActivity(), true, true, callbackWithObject);
|
||||
} else {
|
||||
GpxUiHelper.selectGPXFile(files, getActivity(), true, true, callbackWithObject);
|
||||
GpxUiHelper.selectGPXFile(files, app.getMapActivity(), true, true, callbackWithObject);
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> getAlreadySelectedGpx() {
|
||||
GpxSelectionHelper gpxSelectionHelper = getMyApplication().getSelectedGpxHelper();
|
||||
GpxSelectionHelper gpxSelectionHelper = app.getSelectedGpxHelper();
|
||||
if (gpxSelectionHelper == null) {
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue