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).
|
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
|
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="search_radius">Search radius</string>
|
||||||
<string name="osmo_device_not_found">Device not found</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>
|
<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();
|
settings = app.getSettings();
|
||||||
app.applyTheme(this);
|
app.applyTheme(this);
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
|
|
||||||
|
|
||||||
mapActions = new MapActivityActions(this);
|
mapActions = new MapActivityActions(this);
|
||||||
mapLayers = new MapActivityLayers(this);
|
mapLayers = new MapActivityLayers(this);
|
||||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
|
||||||
// Full screen is not used here
|
// Full screen is not used here
|
||||||
//getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
//getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||||
setContentView(R.layout.main);
|
setContentView(R.layout.main);
|
||||||
|
|
|
@ -98,6 +98,7 @@ public class MapActivityActions implements DialogProvider {
|
||||||
DrawerLayout mDrawerLayout;
|
DrawerLayout mDrawerLayout;
|
||||||
ListView mDrawerList;
|
ListView mDrawerList;
|
||||||
private WaypointDialogHelper waypointDialogHelper;
|
private WaypointDialogHelper waypointDialogHelper;
|
||||||
|
private ConfigureSettingsMenuHelper configureSettingsMenuHelper;
|
||||||
|
|
||||||
|
|
||||||
public MapActivityActions(MapActivity mapActivity){
|
public MapActivityActions(MapActivity mapActivity){
|
||||||
|
@ -105,6 +106,7 @@ public class MapActivityActions implements DialogProvider {
|
||||||
settings = mapActivity.getMyApplication().getSettings();
|
settings = mapActivity.getMyApplication().getSettings();
|
||||||
routingHelper = mapActivity.getMyApplication().getRoutingHelper();
|
routingHelper = mapActivity.getMyApplication().getRoutingHelper();
|
||||||
waypointDialogHelper = new WaypointDialogHelper(mapActivity);
|
waypointDialogHelper = new WaypointDialogHelper(mapActivity);
|
||||||
|
configureSettingsMenuHelper = new ConfigureSettingsMenuHelper(mapActivity.getMyApplication());
|
||||||
waypointDialogHelper.init();
|
waypointDialogHelper.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -906,7 +908,6 @@ public class MapActivityActions implements DialogProvider {
|
||||||
|
|
||||||
final List<WaypointHelper.LocationPointWrapper> deletedPoints = new ArrayList<WaypointHelper.LocationPointWrapper>();
|
final List<WaypointHelper.LocationPointWrapper> deletedPoints = new ArrayList<WaypointHelper.LocationPointWrapper>();
|
||||||
ArrayAdapter<Object> adapter = waypointDialogHelper.getWaypointsAdapter(app.getMapActivity(), deletedPoints);
|
ArrayAdapter<Object> adapter = waypointDialogHelper.getWaypointsAdapter(app.getMapActivity(), deletedPoints);
|
||||||
mDrawerList = (ListView) mapActivity.findViewById(R.id.left_drawer);
|
|
||||||
mDrawerList.setAdapter(adapter);
|
mDrawerList.setAdapter(adapter);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -922,8 +923,8 @@ public class MapActivityActions implements DialogProvider {
|
||||||
.listen(new OnContextMenuClick() {
|
.listen(new OnContextMenuClick() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||||
mapActivity.startActivity(new Intent(mapActivity, ConfigureSettingsMenuHelper.class));
|
configureSettingsMenuHelper.setListView(mDrawerList);
|
||||||
return true;
|
return false;
|
||||||
//mapActivity.getMapLayers().openLayerSelectionDialog(mapView);
|
//mapActivity.getMapLayers().openLayerSelectionDialog(mapView);
|
||||||
}
|
}
|
||||||
}).reg();
|
}).reg();
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
package net.osmand.plus.configuremap;
|
package net.osmand.plus.configuremap;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.graphics.Typeface;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.preference.*;
|
import android.preference.*;
|
||||||
|
import android.util.TypedValue;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.widget.ArrayAdapter;
|
import android.view.View;
|
||||||
import android.widget.ListAdapter;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Toast;
|
import android.widget.*;
|
||||||
import net.osmand.CallbackWithObject;
|
import net.osmand.CallbackWithObject;
|
||||||
import net.osmand.access.AccessibleToast;
|
import net.osmand.access.AccessibleToast;
|
||||||
import net.osmand.data.AmenityType;
|
import net.osmand.data.AmenityType;
|
||||||
|
@ -18,9 +19,11 @@ import net.osmand.plus.activities.*;
|
||||||
import net.osmand.plus.helpers.GpxUiHelper;
|
import net.osmand.plus.helpers.GpxUiHelper;
|
||||||
import net.osmand.plus.render.RenderingIcons;
|
import net.osmand.plus.render.RenderingIcons;
|
||||||
import net.osmand.plus.views.mapwidgets.AppearanceWidgetsFactory;
|
import net.osmand.plus.views.mapwidgets.AppearanceWidgetsFactory;
|
||||||
|
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry;
|
||||||
import net.osmand.render.RenderingRuleProperty;
|
import net.osmand.render.RenderingRuleProperty;
|
||||||
import net.osmand.render.RenderingRulesStorage;
|
import net.osmand.render.RenderingRulesStorage;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -29,255 +32,336 @@ import java.util.List;
|
||||||
/**
|
/**
|
||||||
* Created by Denis on 14.10.2014.
|
* Created by Denis on 14.10.2014.
|
||||||
*/
|
*/
|
||||||
public class ConfigureSettingsMenuHelper{
|
public class ConfigureSettingsMenuHelper {
|
||||||
|
|
||||||
public static final int HEADER = 0;
|
public static final int BACK_HEADER = 0;
|
||||||
public static final int LAYER = 1;
|
public static final int HEADER = 1;
|
||||||
public static final int MAP_REDNDER = 2;
|
public static final int LAYER = 2;
|
||||||
public static final int RENDERING_ATTR = 3;
|
public static final int MAP_REDNDER = 3;
|
||||||
|
public static final int RENDERING_PROPERTY = 4;
|
||||||
|
|
||||||
|
|
||||||
|
private ListView listView;
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
|
|
||||||
public class ConfigureMapMenuItem{
|
public class ConfigureMapMenuItem {
|
||||||
|
int nameId;
|
||||||
int type;
|
int type;
|
||||||
int darkIcon = -1;
|
int darkIcon = -1;
|
||||||
int whiteIcon = -1;
|
int lightIcon = -1;
|
||||||
Object preference;
|
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.type = type;
|
||||||
|
this.nameId = name;
|
||||||
this.darkIcon = darkIcon;
|
this.darkIcon = darkIcon;
|
||||||
this.whiteIcon = whiteIcon;
|
this.lightIcon = whiteIcon;
|
||||||
this.preference = preference;
|
this.preference = preference;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfigureSettingsMenuHelper(OsmandApplication app){
|
public ConfigureSettingsMenuHelper(OsmandApplication app) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArrayAdapter<ConfigureMapMenuItem> createAllCategories() {
|
public void setListView(ListView listView){
|
||||||
|
this.listView = listView;
|
||||||
|
listView.setAdapter(createSettingsAdapter());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private ArrayAdapter<ConfigureMapMenuItem> createSettingsAdapter() {
|
||||||
List<ConfigureMapMenuItem> items = new ArrayList<ConfigureMapMenuItem>();
|
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);
|
createLayersItems(items);
|
||||||
createRenderingAttributePreferences();
|
createRenderingAttributeItems(items);
|
||||||
}
|
return new ArrayAdapter<ConfigureMapMenuItem>(app, R.layout.map_settings_item, items) {
|
||||||
|
|
||||||
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() {
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
AlertDialog.Builder bld = new AlertDialog.Builder(getActivity());
|
if (convertView == null) {
|
||||||
bld.setTitle(R.string.renderers);
|
convertView = app.getMapActivity().getLayoutInflater().inflate(R.layout.map_settings_item, null);
|
||||||
Collection<String> rendererNames = app.getRendererRegistry().getRendererNames();
|
|
||||||
final String[] items = rendererNames.toArray(new String[rendererNames.size()]);
|
|
||||||
final String[] visibleNames = new String[items.length];
|
|
||||||
int selected = -1;
|
|
||||||
final String selectedName = app.getRendererRegistry().getCurrentSelectedRenderer().getName();
|
|
||||||
for (int j = 0; j < items.length; j++) {
|
|
||||||
if (items[j].equals(selectedName)) {
|
|
||||||
selected = j;
|
|
||||||
}
|
|
||||||
visibleNames[j] = items[j].replace('_', ' ').replace(
|
|
||||||
'-', ' ');
|
|
||||||
}
|
}
|
||||||
bld.setSingleChoiceItems(visibleNames, selected, new DialogInterface.OnClickListener() {
|
ConfigureMapMenuItem item = getItem(position);
|
||||||
|
prepareView(convertView, item);
|
||||||
@Override
|
if (item.type == BACK_HEADER){
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
((TextView) convertView.findViewById(R.id.name)).setText(item.nameId);
|
||||||
String renderer = items[which];
|
ImageButton button = (ImageButton) convertView.findViewById(R.id.back);
|
||||||
RenderingRulesStorage loaded = app.getRendererRegistry().getRenderer(renderer);
|
button.setImageResource(getIcon(item));
|
||||||
if (loaded != null) {
|
} else if (item.type == HEADER) {
|
||||||
app.getSettings().RENDERER.set(renderer);
|
((TextView) convertView.findViewById(R.id.name)).setText((String) item.preference);
|
||||||
app.getRendererRegistry().setCurrentSelectedRender(loaded);
|
} else if (item.type == LAYER) {
|
||||||
app.getResourceManager().getRenderer().clearCache();
|
((TextView) convertView.findViewById(R.id.name)).setText(item.nameId);
|
||||||
} else {
|
setLayersCheckBox(item, (CheckBox) convertView.findViewById(R.id.check));
|
||||||
AccessibleToast.makeText(app, R.string.renderer_load_exception, Toast.LENGTH_SHORT).show();
|
} else if (item.type == MAP_REDNDER) {
|
||||||
}
|
((TextView) convertView.findViewById(R.id.name)).setText(item.nameId);
|
||||||
dialog.dismiss();
|
if (item.nameId == R.string.map_widget_renderer) {
|
||||||
createAllCategories();
|
convertView.setOnClickListener(new View.OnClickListener() {
|
||||||
}
|
|
||||||
});
|
|
||||||
bld.show();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
p = new Preference(this);
|
|
||||||
p.setTitle(R.string.map_widget_day_night);
|
|
||||||
p.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
|
||||||
AlertDialog.Builder bld = new AlertDialog.Builder(getActivity());
|
|
||||||
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());
|
|
||||||
}
|
|
||||||
int i = getMyApplication().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();
|
|
||||||
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());
|
|
||||||
if(p.isBoolean()) {
|
|
||||||
final OsmandSettings.CommonPreference<Boolean> pref = app.getSettings().getCustomRenderBooleanProperty(p.getAttrName());
|
|
||||||
preference.setTitle(propertyName);
|
|
||||||
|
|
||||||
preference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
|
||||||
pref.set(!pref.get());
|
|
||||||
app.getResourceManager().getRenderer().clearCache();
|
|
||||||
return 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() {
|
|
||||||
@Override
|
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
|
||||||
AlertDialog.Builder b = new AlertDialog.Builder(getActivity());
|
|
||||||
//test old descr as title
|
|
||||||
b.setTitle(propertyDescr);
|
|
||||||
|
|
||||||
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]);
|
|
||||||
}
|
|
||||||
|
|
||||||
b.setSingleChoiceItems(possibleValuesString, i, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(View view) {
|
||||||
pref.set(p.getPossibleValues()[which]);
|
AlertDialog.Builder bld = new AlertDialog.Builder(app.getMapActivity());
|
||||||
app.getResourceManager().getRenderer().clearCache();
|
bld.setTitle(R.string.renderers);
|
||||||
dialog.dismiss();
|
Collection<String> rendererNames = app.getRendererRegistry().getRendererNames();
|
||||||
|
final String[] items = rendererNames.toArray(new String[rendererNames.size()]);
|
||||||
|
final String[] visibleNames = new String[items.length];
|
||||||
|
int selected = -1;
|
||||||
|
final String selectedName = app.getRendererRegistry().getCurrentSelectedRenderer().getName();
|
||||||
|
for (int j = 0; j < items.length; j++) {
|
||||||
|
if (items[j].equals(selectedName)) {
|
||||||
|
selected = j;
|
||||||
|
}
|
||||||
|
visibleNames[j] = items[j].replace('_', ' ').replace(
|
||||||
|
'-', ' ');
|
||||||
|
}
|
||||||
|
bld.setSingleChoiceItems(visibleNames, selected, new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
String renderer = items[which];
|
||||||
|
RenderingRulesStorage loaded = app.getRendererRegistry().getRenderer(renderer);
|
||||||
|
if (loaded != null) {
|
||||||
|
app.getSettings().RENDERER.set(renderer);
|
||||||
|
app.getRendererRegistry().setCurrentSelectedRender(loaded);
|
||||||
|
app.getResourceManager().getRenderer().clearCache();
|
||||||
|
} else {
|
||||||
|
AccessibleToast.makeText(app, R.string.renderer_load_exception, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
dialog.dismiss();
|
||||||
|
createSettingsAdapter();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
bld.show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (item.nameId == R.string.map_widget_day_night) {
|
||||||
|
convertView.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
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(app);
|
||||||
|
}
|
||||||
|
int i = app.getSettings().DAYNIGHT_MODE.get().ordinal();
|
||||||
|
bld.setSingleChoiceItems(items, i, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
app.getSettings().DAYNIGHT_MODE.set(OsmandSettings.DayNightMode.values()[which]);
|
||||||
|
app.getResourceManager().getRenderer().clearCache();
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
bld.show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
b.show();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
});
|
} 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());
|
||||||
|
CheckBox ch = (CheckBox) convertView.findViewById(R.id.check);
|
||||||
|
ch.setChecked(pref.get());
|
||||||
|
ch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
||||||
|
pref.set(!pref.get());
|
||||||
|
app.getResourceManager().getRenderer().clearCache();
|
||||||
|
//view.refreshMap(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
final OsmandSettings.CommonPreference<String> pref = app.getSettings().getCustomRenderProperty(p.getAttrName());
|
||||||
|
convertView.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
AlertDialog.Builder b = new AlertDialog.Builder(app.getMapActivity());
|
||||||
|
//test old descr as title
|
||||||
|
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(app, p.getPossibleValues()[j]);
|
||||||
|
}
|
||||||
|
|
||||||
|
b.setSingleChoiceItems(possibleValuesString, 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();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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 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 void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
||||||
|
if (b) {
|
||||||
|
selectPOIFilterLayer(null);
|
||||||
|
} else {
|
||||||
|
pref.set(b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (item.nameId == R.string.layer_gpx_layer) {
|
||||||
|
check.setChecked(app.getSelectedGpxHelper().isShowingAnyGpxFiles());
|
||||||
|
check.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
||||||
|
if (b) {
|
||||||
|
showGPXFileDialog(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (item.nameId == R.string.layer_transport && TransportRouteHelper.getInstance().routeIsCalculated()) {
|
||||||
|
check.setChecked(true);
|
||||||
|
} else {
|
||||||
|
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) {
|
private void createLayersItems(List<ConfigureMapMenuItem> items) {
|
||||||
items.add(new ConfigureMapMenuItem(HEADER,-1,-1,R.string.show));
|
items.add(new ConfigureMapMenuItem(HEADER, -1, -1, -1, "Show:"));
|
||||||
grp.addPreference(mapLayersCategory);
|
items.add(new ConfigureMapMenuItem(LAYER, R.string.layer_poi, R.drawable.ic_action_info_dark,
|
||||||
final CheckBoxPreference poi = new CheckBoxPreference(this);
|
R.drawable.ic_action_info_light, app.getSettings().SHOW_POI_OVER_MAP));
|
||||||
poi.setTitle(R.string.layer_poi);
|
items.add(new ConfigureMapMenuItem(LAYER, R.string.layer_amenity_label, R.drawable.ic_action_text_dark,
|
||||||
poi.setChecked(settings.SHOW_POI_OVER_MAP.get());
|
R.drawable.ic_action_text_light, app.getSettings().SHOW_POI_LABEL));
|
||||||
addIcon(poi, R.drawable.ic_action_info_light, R.drawable.ic_action_info_dark);
|
items.add(new ConfigureMapMenuItem(LAYER, R.string.layer_favorites, R.drawable.ic_action_fav_dark,
|
||||||
poi.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
R.drawable.ic_action_fav_light, app.getSettings().SHOW_FAVORITES));
|
||||||
@Override
|
items.add(new ConfigureMapMenuItem(LAYER, R.string.layer_gpx_layer, R.drawable.ic_action_polygom_dark,
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
R.drawable.ic_action_polygom_light, null));
|
||||||
settings.SHOW_POI_OVER_MAP.set(!settings.SHOW_POI_OVER_MAP.get());
|
items.add(new ConfigureMapMenuItem(LAYER, R.string.layer_transport, R.drawable.ic_action_bus_dark,
|
||||||
if (settings.SHOW_POI_OVER_MAP.get()) {
|
R.drawable.ic_action_bus_light, app.getSettings().SHOW_TRANSPORT_OVER_MAP));
|
||||||
selectPOIFilterLayer(null);
|
|
||||||
} else {
|
|
||||||
poi.setSummary("");
|
|
||||||
}
|
|
||||||
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() {
|
|
||||||
@Override
|
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
|
||||||
if (gpx.isChecked()){
|
|
||||||
showGPXFileDialog(getAlreadySelectedGpx());
|
|
||||||
}
|
|
||||||
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()) {
|
if (TransportRouteHelper.getInstance().routeIsCalculated()) {
|
||||||
p = new CheckBoxPreference(this);
|
items.add(new ConfigureMapMenuItem(R.string.layer_transport, LAYER,
|
||||||
p.setChecked(true);
|
R.drawable.ic_action_bus_dark, R.drawable.ic_action_bus_light, 1));
|
||||||
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) {
|
private void createRenderingAttributeItems(List<ConfigureMapMenuItem> items) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
items.add(new ConfigureMapMenuItem(HEADER, -1, -1, -1, app.getString(R.string.map_widget_map_rendering)));
|
||||||
if (getMyApplication().getSettings().isLightContent()) {
|
items.add(new ConfigureMapMenuItem(MAP_REDNDER, R.string.map_widget_renderer, -1, -1, null));
|
||||||
p.setIcon(lightIcon);
|
items.add(new ConfigureMapMenuItem(MAP_REDNDER, R.string.map_widget_day_night, -1, -1, null));
|
||||||
} else {
|
|
||||||
p.setIcon(darkIcon);
|
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) {
|
public AlertDialog selectPOIFilterLayer(final PoiFilter[] selected) {
|
||||||
final List<PoiFilter> userDefined = new ArrayList<PoiFilter>();
|
final List<PoiFilter> userDefined = new ArrayList<PoiFilter>();
|
||||||
OsmandApplication app = (OsmandApplication) getApplication();
|
|
||||||
final PoiFiltersHelper poiFilters = app.getPoiFilters();
|
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")) {
|
if (RenderingIcons.containsBigIcon("null")) {
|
||||||
is.icon(RenderingIcons.getBigIconResourceId("null"));
|
is.icon(RenderingIcons.getBigIconResourceId("null"));
|
||||||
}
|
}
|
||||||
is.reg();
|
is.reg();
|
||||||
// 2nd custom
|
// 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()) {
|
for (PoiFilter f : poiFilters.getUserDefinedPoiFilters()) {
|
||||||
ContextMenuAdapter.Item it = adapter.item(f.getName());
|
ContextMenuAdapter.Item it = adapter.item(f.getName());
|
||||||
|
@ -291,20 +375,20 @@ public class ConfigureSettingsMenuHelper{
|
||||||
}
|
}
|
||||||
final AmenityType[] categories = AmenityType.getCategories();
|
final AmenityType[] categories = AmenityType.getCategories();
|
||||||
for (AmenityType t : categories) {
|
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())) {
|
if (RenderingIcons.containsBigIcon(t.toString().toLowerCase())) {
|
||||||
it.icon(RenderingIcons.getBigIconResourceId(t.toString().toLowerCase()));
|
it.icon(RenderingIcons.getBigIconResourceId(t.toString().toLowerCase()));
|
||||||
}
|
}
|
||||||
it.reg();
|
it.reg();
|
||||||
}
|
}
|
||||||
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
final AlertDialog.Builder builder = new AlertDialog.Builder(app.getMapActivity());
|
||||||
ListAdapter listAdapter;
|
ListAdapter listAdapter;
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
|
||||||
listAdapter =
|
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 {
|
} else {
|
||||||
listAdapter =
|
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() {
|
builder.setAdapter(listAdapter, new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
|
@ -312,12 +396,12 @@ public class ConfigureSettingsMenuHelper{
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
if (which == 1) {
|
if (which == 1) {
|
||||||
String filterId = PoiFilter.CUSTOM_FILTER_ID;
|
String filterId = PoiFilter.CUSTOM_FILTER_ID;
|
||||||
getMyApplication().getSettings().setPoiFilterForMap(filterId);
|
app.getSettings().setPoiFilterForMap(filterId);
|
||||||
Intent newIntent = new Intent(getApplication(), EditPOIFilterActivity.class);
|
Intent newIntent = new Intent(app, EditPOIFilterActivity.class);
|
||||||
newIntent.putExtra(EditPOIFilterActivity.AMENITY_FILTER, filterId);
|
newIntent.putExtra(EditPOIFilterActivity.AMENITY_FILTER, filterId);
|
||||||
//newIntent.putExtra(EditPOIFilterActivity.SEARCH_LAT, getMyApplication().getMapActivity().getMapView().getLatitude());
|
//newIntent.putExtra(EditPOIFilterActivity.SEARCH_LAT, getMyApplication().getMapActivity().getMapView().getLatitude());
|
||||||
//newIntent.putExtra(EditPOIFilterActivity.SEARCH_LON, getMyApplication().getMapActivity().getMapView().getLongitude());
|
//newIntent.putExtra(EditPOIFilterActivity.SEARCH_LON, getMyApplication().getMapActivity().getMapView().getLongitude());
|
||||||
getActivity().startActivity(newIntent);
|
app.getMapActivity().startActivity(newIntent);
|
||||||
} else {
|
} else {
|
||||||
String filterId;
|
String filterId;
|
||||||
if (which == 0) {
|
if (which == 0) {
|
||||||
|
@ -327,7 +411,7 @@ public class ConfigureSettingsMenuHelper{
|
||||||
} else {
|
} else {
|
||||||
filterId = PoiFiltersHelper.getOsmDefinedFilterId(categories[which - userDefined.size() - 2]);
|
filterId = PoiFiltersHelper.getOsmDefinedFilterId(categories[which - userDefined.size() - 2]);
|
||||||
}
|
}
|
||||||
getMyApplication().getSettings().setPoiFilterForMap(filterId);
|
app.getSettings().setPoiFilterForMap(filterId);
|
||||||
PoiFilter f = poiFilters.getFilterById(filterId);
|
PoiFilter f = poiFilters.getFilterById(filterId);
|
||||||
if (f != null) {
|
if (f != null) {
|
||||||
f.clearNameFilter();
|
f.clearNameFilter();
|
||||||
|
@ -335,7 +419,7 @@ public class ConfigureSettingsMenuHelper{
|
||||||
if (selected != null && selected.length > 0) {
|
if (selected != null && selected.length > 0) {
|
||||||
selected[0] = f;
|
selected[0] = f;
|
||||||
}
|
}
|
||||||
createAllCategories();
|
createSettingsAdapter();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -347,8 +431,8 @@ public class ConfigureSettingsMenuHelper{
|
||||||
event.getAction() == KeyEvent.ACTION_UP &&
|
event.getAction() == KeyEvent.ACTION_UP &&
|
||||||
!event.isCanceled()) {
|
!event.isCanceled()) {
|
||||||
dialogInterface.cancel();
|
dialogInterface.cancel();
|
||||||
settings.SHOW_POI_OVER_MAP.set(false);
|
app.getSettings().SHOW_POI_OVER_MAP.set(false);
|
||||||
createAllCategories();
|
createSettingsAdapter();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -357,10 +441,6 @@ public class ConfigureSettingsMenuHelper{
|
||||||
return builder.show();
|
return builder.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Activity getActivity() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void showGPXFileDialog(List<String> files) {
|
public void showGPXFileDialog(List<String> files) {
|
||||||
CallbackWithObject<GPXUtilities.GPXFile[]> callbackWithObject = new CallbackWithObject<GPXUtilities.GPXFile[]>() {
|
CallbackWithObject<GPXUtilities.GPXFile[]> callbackWithObject = new CallbackWithObject<GPXUtilities.GPXFile[]>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -368,9 +448,9 @@ public class ConfigureSettingsMenuHelper{
|
||||||
GPXUtilities.WptPt locToShow = null;
|
GPXUtilities.WptPt locToShow = null;
|
||||||
for (GPXUtilities.GPXFile g : result) {
|
for (GPXUtilities.GPXFile g : result) {
|
||||||
if (g.showCurrentTrack) {
|
if (g.showCurrentTrack) {
|
||||||
if (!settings.SAVE_TRACK_TO_GPX.get() && !
|
if (!app.getSettings().SAVE_TRACK_TO_GPX.get() && !
|
||||||
settings.SAVE_GLOBAL_TRACK_TO_GPX.get()) {
|
app.getSettings().SAVE_GLOBAL_TRACK_TO_GPX.get()) {
|
||||||
AccessibleToast.makeText(getActivity(), R.string.gpx_monitoring_disabled_warn, Toast.LENGTH_SHORT).show();
|
AccessibleToast.makeText(app.getMapActivity(), R.string.gpx_monitoring_disabled_warn, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -378,22 +458,22 @@ public class ConfigureSettingsMenuHelper{
|
||||||
locToShow = g.findPointToShow();
|
locToShow = g.findPointToShow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getMyApplication().getSelectedGpxHelper().setGpxFileToDisplay(result);
|
app.getSelectedGpxHelper().setGpxFileToDisplay(result);
|
||||||
createAllCategories();
|
createSettingsAdapter();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (files == null) {
|
if (files == null) {
|
||||||
GpxUiHelper.selectGPXFile(getActivity(), true, true, callbackWithObject);
|
GpxUiHelper.selectGPXFile(app.getMapActivity(), true, true, callbackWithObject);
|
||||||
} else {
|
} else {
|
||||||
GpxUiHelper.selectGPXFile(files, getActivity(), true, true, callbackWithObject);
|
GpxUiHelper.selectGPXFile(files, app.getMapActivity(), true, true, callbackWithObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> getAlreadySelectedGpx(){
|
private List<String> getAlreadySelectedGpx() {
|
||||||
GpxSelectionHelper gpxSelectionHelper = getMyApplication().getSelectedGpxHelper();
|
GpxSelectionHelper gpxSelectionHelper = app.getSelectedGpxHelper();
|
||||||
if (gpxSelectionHelper == null){
|
if (gpxSelectionHelper == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
List<GpxSelectionHelper.SelectedGpxFile> selectedGpxFiles = gpxSelectionHelper.getSelectedGPXFiles();
|
List<GpxSelectionHelper.SelectedGpxFile> selectedGpxFiles = gpxSelectionHelper.getSelectedGPXFiles();
|
||||||
|
|
Loading…
Reference in a new issue