Prepare drawer menu for merge

This commit is contained in:
Victor Shcherb 2014-10-21 01:30:44 +02:00
parent 2eb10ce57d
commit b795525ade
34 changed files with 422 additions and 927 deletions

View file

@ -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="layers_category_show">Show</string>
<string name="configure_map">Configure map</string>
<string name="search_radius_proximity">In proximity of</string>
<string name="osmo_device_not_found">Device not found</string>

View file

@ -6,7 +6,7 @@ import java.util.ArrayList;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Typeface;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
@ -18,12 +18,13 @@ public class ContextMenuAdapter {
public interface OnContextMenuClick {
//boolean return type needed to desribe if drawer needed to be close or not
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog);
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked);
}
private final Context ctx;
private View anchor;
final TIntArrayList items = new TIntArrayList();
final TIntArrayList isCategory = new TIntArrayList();
final ArrayList<String> itemNames = new ArrayList<String>();
final ArrayList<OnContextMenuClick> listeners = new ArrayList<ContextMenuAdapter.OnContextMenuClick>();
final TIntArrayList selectedList = new TIntArrayList();
@ -78,6 +79,10 @@ public class ContextMenuAdapter {
}
public boolean isCategory(int pos) {
return isCategory.get(pos) > 0;
}
public Item item(String name){
Item i = new Item();
i.id = (name.hashCode() << 4) | items.size();
@ -98,6 +103,7 @@ public class ContextMenuAdapter {
int id;
String name;
int selected = -1;
boolean cat;
int pos = -1;
private OnContextMenuClick listener;
@ -141,7 +147,11 @@ public class ContextMenuAdapter {
iconList.insert(pos, icon);
iconListLight.insert(pos, lightIcon);
listeners.add(pos, listener);
isCategory.insert(pos, cat ? 1 : 0);
}
public void setCategory(boolean b) {
cat = b;
}
}
@ -157,6 +167,7 @@ public class ContextMenuAdapter {
iconList.removeAt(pos);
iconListLight.removeAt(pos);
listeners.remove(pos);
isCategory.removeAt(pos);
}
@ -183,6 +194,12 @@ public class ContextMenuAdapter {
}
tv.setCompoundDrawablePadding(padding);
if(isCategory(position)) {
tv.setTypeface(Typeface.DEFAULT_BOLD);
} else {
tv.setTypeface(null);
}
final CheckBox ch = ((CheckBox) v.findViewById(R.id.check_item));
ch.setVisibility(View.GONE);
return v;

View file

@ -159,7 +159,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
optionsMenuAdapter = new ContextMenuAdapter(getActivity());
OnContextMenuClick listener = new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(final int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(final int itemId, int pos, boolean isChecked) {
if (itemId == R.string.local_index_mi_reload) {
asyncLoader = new LoadGpxTask();
asyncLoader.execute(getActivity());
@ -214,7 +214,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
int itemId = item.getItemId();
for (int i = 0; i < optionsMenuAdapter.length(); i++) {
if (itemId == optionsMenuAdapter.getItemId(i)) {
optionsMenuAdapter.getClickAdapter(i).onContextMenuClick(itemId, i, false, null);
optionsMenuAdapter.getClickAdapter(i).onContextMenuClick(itemId, i, false);
return true;
}
}
@ -396,7 +396,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
private void basicFileOperation(final GpxInfo info, ContextMenuAdapter adapter) {
OnContextMenuClick listener = new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int resId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int resId, int pos, boolean isChecked) {
if (resId == R.string.local_index_mi_rename) {
renameFile(info);
} else if (resId == R.string.local_index_unselect_gpx_file ||
@ -479,7 +479,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
public void onClick(DialogInterface dialog, int which) {
OnContextMenuClick clk = adapter.getClickAdapter(which);
if (clk != null) {
clk.onContextMenuClick(adapter.getItemId(which), which, false, dialog);
clk.onContextMenuClick(adapter.getItemId(which), which, false);
}
}

View file

@ -176,7 +176,7 @@ public class FavouritesTreeFragment extends OsmandExpandableListFragment {
new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
editPoint(point);
return true;
}
@ -187,7 +187,7 @@ public class FavouritesTreeFragment extends OsmandExpandableListFragment {
new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
deletePoint(point);
return true;
}

View file

@ -212,7 +212,7 @@ public class MapActivity extends AccessibleActivity {
}
gpxImportHelper = new GpxImportHelper(this, getMyApplication(), getMapView());
mapActions.createOptionsMenuAsDrawer(false);
mapActions.prepareStartOptionsMenu();
}
public void addLockView(FrameLayout lockView) {

View file

@ -47,7 +47,7 @@ import net.osmand.plus.activities.actions.ShareLocation;
import net.osmand.plus.activities.actions.StartGPSStatus;
import net.osmand.plus.activities.search.SearchActivity;
import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.configuremap.ConfigureSettingsMenu;
import net.osmand.plus.configuremap.ConfigureMapMenu;
import net.osmand.plus.development.OsmandDevelopmentPlugin;
import net.osmand.plus.helpers.WaypointDialogHelper;
import net.osmand.plus.osmo.OsMoPositionLayer;
@ -98,7 +98,6 @@ public class MapActivityActions implements DialogProvider {
DrawerLayout mDrawerLayout;
ListView mDrawerList;
private WaypointDialogHelper waypointDialogHelper;
private ConfigureSettingsMenu configureSettingsMenu;
public MapActivityActions(MapActivity mapActivity){
@ -106,7 +105,6 @@ public class MapActivityActions implements DialogProvider {
settings = mapActivity.getMyApplication().getSettings();
routingHelper = mapActivity.getMyApplication().getRoutingHelper();
waypointDialogHelper = new WaypointDialogHelper(mapActivity);
configureSettingsMenu = new ConfigureSettingsMenu(mapActivity);
waypointDialogHelper.init();
}
@ -517,7 +515,7 @@ public class MapActivityActions implements DialogProvider {
int standardId = adapter.getItemId(which);
OnContextMenuClick click = adapter.getClickAdapter(which);
if (click != null) {
click.onContextMenuClick(standardId, which, false, dialog);
click.onContextMenuClick(standardId, which, false);
} else if (standardId == R.string.context_menu_item_search) {
Intent intent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getSearchActivity());
intent.putExtra(SearchActivity.SEARCH_LAT, latitude);
@ -745,18 +743,22 @@ public class MapActivityActions implements DialogProvider {
if (mDrawerLayout.isDrawerOpen(mDrawerList)){
mDrawerLayout.closeDrawer(mDrawerList);
} else {
createOptionsMenuAsDrawer(true);
prepareStartOptionsMenu();
toggleDrawer();
}
}
}
public void createOptionsMenuAsDrawer(boolean show){
final ContextMenuAdapter cm = createOptionsMenu();
public void prepareStartOptionsMenu(){
if (mDrawerLayout == null) {
mDrawerLayout = (DrawerLayout) mapActivity.findViewById(R.id.drawer_layout);
mDrawerList = (ListView) mapActivity.findViewById(R.id.left_drawer);
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
}
final ContextMenuAdapter cm = createOptionsMenu();
prepareOptionsMenu(cm);
}
public void prepareOptionsMenu(final ContextMenuAdapter cm) {
ListAdapter listAdapter;
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB){
listAdapter =
@ -778,7 +780,7 @@ public class MapActivityActions implements DialogProvider {
public void onItemClick(AdapterView<?> parent, View view, int which, long id) {
OnContextMenuClick click = cm.getClickAdapter(which);
if (click != null) {
if (click.onContextMenuClick(cm.getItemId(which), which, false, null)){
if (click.onContextMenuClick(cm.getItemId(which), which, false)){
mDrawerLayout.closeDrawer(mDrawerList);
}
} else {
@ -786,8 +788,9 @@ public class MapActivityActions implements DialogProvider {
}
}
});
}
if (show){
public void toggleDrawer() {
// toggle drawer
if (!mDrawerLayout.isDrawerOpen(mDrawerList)) {
mDrawerLayout.openDrawer(mDrawerList);
@ -795,29 +798,9 @@ public class MapActivityActions implements DialogProvider {
mDrawerLayout.closeDrawer(mDrawerList);
}
}
}
public AlertDialog openOptionsMenuAsList() {
final ContextMenuAdapter cm = createOptionsMenu();
final Builder bld = new AlertDialog.Builder(mapActivity);
ListAdapter listAdapter ;
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB){
listAdapter =
cm.createListAdapter(mapActivity, R.layout.list_menu_item, getMyApplication().getSettings().isLightContentMenu());
} else {
listAdapter =
cm.createListAdapter(mapActivity, R.layout.list_menu_item_native, getMyApplication().getSettings().isLightContentMenu());
}
bld.setAdapter(listAdapter, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
OnContextMenuClick click = cm.getClickAdapter(which);
if (click != null) {
click.onContextMenuClick(cm.getItemId(which), which, false, dialog);
}
}
});
return bld.show();
public void prepareConfigureMap() {
prepareOptionsMenu(new ConfigureMapMenu().createListAdapter(mapActivity));
}
private ContextMenuAdapter createOptionsMenu() {
@ -830,7 +813,7 @@ public class MapActivityActions implements DialogProvider {
icons(R.drawable.ic_action_gloc_dark, R.drawable.ic_action_gloc_light)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
if (getMyApplication().accessibilityEnabled()) {
whereAmIDialog();
} else {
@ -857,7 +840,7 @@ public class MapActivityActions implements DialogProvider {
optionsMenuHelper.item(t).icons(icon, iconLight)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
routingHelper.getVoiceRouter().setMute(!routingHelper.getVoiceRouter().isMute());
return true;
}
@ -868,7 +851,7 @@ public class MapActivityActions implements DialogProvider {
.icons(R.drawable.ic_action_gdirections_dark, R.drawable.ic_action_gdirections_light)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
enterRoutePlanningMode(null, null, false);
return true;
}
@ -880,7 +863,7 @@ public class MapActivityActions implements DialogProvider {
.icons(R.drawable.ic_action_gdirections_dark, R.drawable.ic_action_gdirections_light)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
if(routingHelper.isRoutePlanningMode()) {
routingHelper.setRoutePlanningMode(false);
routingHelper.setFollowingMode(true);
@ -907,7 +890,7 @@ public class MapActivityActions implements DialogProvider {
optionsMenuHelper.item(nav).icons(R.drawable.ic_action_remove_dark, R.drawable.ic_action_remove_light)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
stopNavigationActionConfirm(mapView);
OsMoPositionLayer osMoPositionLayer = mapActivity.getMapView().getLayerByClass(OsMoPositionLayer.class);
if (osMoPositionLayer != null) {
@ -921,7 +904,7 @@ public class MapActivityActions implements DialogProvider {
optionsMenuHelper.item(R.string.target_points).icons(R.drawable.ic_action_flage_dark, R.drawable.ic_action_flage_light)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
if (getMyApplication().getWaypointHelper().isRouteCalculated()) {
final List<WaypointHelper.LocationPointWrapper> deletedPoints = new ArrayList<WaypointHelper.LocationPointWrapper>();
@ -940,18 +923,16 @@ public class MapActivityActions implements DialogProvider {
optionsMenuHelper.item(R.string.configure_map).icons(R.drawable.ic_action_layers_dark, R.drawable.ic_action_layers_light)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
configureSettingsMenu.setListView(mDrawerList);
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
prepareConfigureMap();
return false;
//mapActivity.getMapLayers().openLayerSelectionDialog(mapView);
//return true;
}
}).reg();
optionsMenuHelper.item(R.string.layer_map_appearance).icons(R.drawable.ic_action_settings_dark, R.drawable.ic_action_settings_light)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
mapActivity.getMapLayers().getMapInfoLayer().openViewConfigureDialog();
return true;
}
@ -960,7 +941,7 @@ public class MapActivityActions implements DialogProvider {
optionsMenuHelper.item(R.string.settings_Button).icons(R.drawable.ic_action_settings2_dark, R.drawable.ic_action_settings2_light)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
final Intent intentSettings = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getSettingsActivity());
mapActivity.startActivity(intentSettings);
return true;
@ -970,7 +951,7 @@ public class MapActivityActions implements DialogProvider {
optionsMenuHelper.item(R.string.search_button).icons(R.drawable.ic_action_search_dark, R.drawable.ic_action_search_light)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getSearchActivity());
// causes wrong position caching: newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
LatLon loc = mapActivity.getMapLocation();
@ -985,7 +966,7 @@ public class MapActivityActions implements DialogProvider {
optionsMenuHelper.item(R.string.favorites_Button).icons( R.drawable.ic_action_fav_dark, R.drawable.ic_action_fav_light)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getFavoritesActivity());
// causes wrong position caching: newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
mapActivity.startActivity(newIntent);
@ -995,7 +976,7 @@ public class MapActivityActions implements DialogProvider {
optionsMenuHelper.item(R.string.show_point_options).icons(R.drawable.ic_action_marker_dark, R.drawable.ic_action_marker_light )
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
contextMenuPoint(mapView.getLatitude(), mapView.getLongitude());
return true;
}
@ -1006,7 +987,7 @@ public class MapActivityActions implements DialogProvider {
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
new StartGPSStatus(mapActivity).run();
return true;
}
@ -1017,7 +998,7 @@ public class MapActivityActions implements DialogProvider {
listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
if (MainMenuActivity.TIPS_AND_TRICKS) {
TipsAndTricksActivity tactivity = new TipsAndTricksActivity(mapActivity);
Dialog dlg = tactivity.getDialogToShowTips(false, true);
@ -1038,8 +1019,7 @@ public class MapActivityActions implements DialogProvider {
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked,
DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
// animate moving on route
loc.getLocationSimulation().startStopRouteAnimation(mapActivity);
return true;
@ -1052,7 +1032,7 @@ public class MapActivityActions implements DialogProvider {
optionsMenuHelper.item(R.string.exit_Button).icons(R.drawable.ic_action_quit_dark, R.drawable.ic_action_quit_light )
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
// 1. Work for almost all cases when user open apps from main menu
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getMainMenuActivity());
newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
@ -1163,7 +1143,7 @@ public class MapActivityActions implements DialogProvider {
new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
MapActivityActions.directionsToDialogAndLaunchMap(activity, location.getLatitude(), location.getLongitude(), name);
return true;
}
@ -1178,7 +1158,7 @@ public class MapActivityActions implements DialogProvider {
}
intermediate.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
addWaypointDialogAndLaunchMap(activity, location.getLatitude(), location.getLongitude(), name);
return true;
}
@ -1190,7 +1170,7 @@ public class MapActivityActions implements DialogProvider {
new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
app.getSettings().setMapLocationToShow(location.getLatitude(), location.getLongitude(), z, saveHistory ? name : null, name,
obj); //$NON-NLS-1$
MapActivity.launchMapActivityMoveToTop(activity);
@ -1203,7 +1183,7 @@ public class MapActivityActions implements DialogProvider {
addToFavorite.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
Bundle args = new Bundle();
Dialog dlg = createAddFavouriteDialog(activity, args);
dlg.show();
@ -1226,7 +1206,7 @@ public class MapActivityActions implements DialogProvider {
public void onClick(DialogInterface dialog, int which) {
OnContextMenuClick clk = qa.getClickAdapter(which);
if (clk != null) {
clk.onContextMenuClick(qa.getItemId(which), which, false, dialog);
clk.onContextMenuClick(qa.getItemId(which), which, false);
}
}
@ -1251,7 +1231,7 @@ public class MapActivityActions implements DialogProvider {
onShow.onClick(v);
}
view.dismiss();
qa.getClickAdapter(ki).onContextMenuClick(qa.getItemId(ki), ki, false, null);
qa.getClickAdapter(ki).onContextMenuClick(qa.getItemId(ki), ki, false);
}
});

View file

@ -283,196 +283,10 @@ public class MapActivityLayers {
}
}
private final class LayerMenuListener {
private final ContextMenuAdapter adapter;
private final OsmandMapTileView mapView;
private final OsmandSettings settings;
DialogInterface dialog;
private LayerMenuListener(ContextMenuAdapter adapter,
OsmandMapTileView mapView, OsmandSettings settings) {
this.adapter = adapter;
this.mapView = mapView;
this.settings = settings;
}
public void setDialog(DialogInterface dialog) {
this.dialog = dialog;
}
public void onClick(int item, boolean isChecked) {
int itemId = adapter.getItemId(item);
OnContextMenuClick clck = adapter.getClickAdapter(item);
if(clck != null) {
clck.onContextMenuClick(itemId, item, isChecked, dialog);
} else if(itemId == R.string.layer_poi){
if(isChecked){
selectPOIFilterLayer(mapView, null);
}
settings.SHOW_POI_OVER_MAP.set(isChecked);
} else if(itemId == R.string.layer_amenity_label){
settings.SHOW_POI_LABEL.set(isChecked);
} else if(itemId == R.string.layer_favorites){
settings.SHOW_FAVORITES.set(isChecked);
} else if(itemId == R.string.layer_gpx_layer){
if(getApplication().getSelectedGpxHelper().isShowingAnyGpxFiles()){
getApplication().getSelectedGpxHelper().clearAllGpxFileToShow();
} else {
dialog.dismiss();
showGPXFileLayer(getAlreadySelectedGpx(), mapView);
}
} else if(itemId == R.string.layer_transport_route){
transportInfoLayer.setVisible(isChecked);
} else if(itemId == R.string.layer_transport){
settings.SHOW_TRANSPORT_OVER_MAP.set(isChecked);
}
updateLayers(mapView);
mapView.refreshMap();
}
}
public void openLayerSelectionDialog(final OsmandMapTileView mapView){
final OsmandSettings settings = getApplication().getSettings();
final ContextMenuAdapter adapter = new ContextMenuAdapter(activity);
// String appMode = " [" + settings.getApplicationMode().toHumanString(view.getApplication()) +"] ";
adapter.item(R.string.layer_poi).selected(settings.SHOW_POI_OVER_MAP.get() ? 1 : 0)
.icons(R.drawable.ic_action_info_dark, R.drawable.ic_action_info_light).reg();
adapter.item(R.string.layer_amenity_label).selected(settings.SHOW_POI_LABEL.get() ? 1 : 0)
.icons(R.drawable.ic_action_text_dark, R.drawable.ic_action_text_light).reg();
adapter.item(R.string.layer_favorites).selected(settings.SHOW_FAVORITES.get() ? 1 : 0)
.icons(R.drawable.ic_action_fav_dark, R.drawable.ic_action_fav_light).reg();
adapter.item(R.string.layer_gpx_layer).selected(
getApplication().getSelectedGpxHelper().isShowingAnyGpxFiles()? 1 : 0)
// .icons(R.drawable.ic_action_foot_dark, R.drawable.ic_action_foot_light)
.icons(R.drawable.ic_action_polygom_dark, R.drawable.ic_action_polygom_light)
.reg();
adapter.item(R.string.layer_transport).selected( settings.SHOW_TRANSPORT_OVER_MAP.get() ? 1 : 0)
.icons(R.drawable.ic_action_bus_dark, R.drawable.ic_action_bus_light).reg();
if(TransportRouteHelper.getInstance().routeIsCalculated()){
adapter.item(R.string.layer_transport_route).selected(1)
.icons(R.drawable.ic_action_bus_dark, R.drawable.ic_action_bus_light).reg();
}
OsmandPlugin.registerLayerContextMenu(mapView, adapter, activity);
getApplication().getAppCustomization().prepareLayerContextMenu(activity, adapter);
final LayerMenuListener listener = new LayerMenuListener(adapter, mapView, settings);
Builder b = new AlertDialog.Builder(activity);
final int padding = (int) (12 * activity.getResources().getDisplayMetrics().density + 0.5f);
final boolean light = getApplication().getSettings().isLightContentMenu();
final int layout;
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB){
layout = R.layout.list_menu_item;
} else {
layout = R.layout.list_menu_item_native;
}
final ArrayAdapter<String> listAdapter = new ArrayAdapter<String>(
activity, layout, R.id.title, adapter.getItemNames()){
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
// User super class to create the View
View v = activity.getLayoutInflater().inflate(layout, null);
TextView tv = (TextView)v.findViewById(R.id.title);
tv.setText(adapter.getItemName(position));
//if it's gpx or poi layer - need to show settings icon
//need imageview and specialItemId o
final ImageView settingsImage = (ImageView) v.findViewById(R.id.icon_settings);
final int specialItemId = adapter.getItemId(position);
if ((specialItemId == R.string.layer_poi || specialItemId == R.string.layer_gpx_layer)
&& adapter.getSelection(position) > 0) {
settingsImage.setVisibility(View.VISIBLE);
//setting icon depending on theme
if(light){
settingsImage.setImageResource(R.drawable.ic_action_settings_light);
} else {
settingsImage.setImageResource(R.drawable.ic_action_settings_dark);
}
if (specialItemId == R.string.layer_poi){
settingsImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
selectPOIFilterLayer(mapView, null);
}
});
} else if (specialItemId == R.string.layer_gpx_layer) {
settingsImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (listener.dialog != null) {
listener.dialog.dismiss();
}
showGPXFileLayer(getAlreadySelectedGpx(), mapView);
}
});
}
}
//Put the image on the TextView
if(adapter.getImageId(position, light) != 0) {
tv.setCompoundDrawablesWithIntrinsicBounds(adapter.getImageId(position, light), 0, 0, 0);
} else {
tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_action_transparent, 0, 0, 0);
}
tv.setCompoundDrawablePadding(padding);
final CheckBox ch = ((CheckBox) v.findViewById(R.id.check_item));
if(adapter.getSelection(position) == -1){
ch.setVisibility(View.INVISIBLE);
} else {
ch.setOnCheckedChangeListener(null);
ch.setChecked(adapter.getSelection(position) > 0);
ch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (specialItemId == R.string.layer_poi){
if (isChecked){
settingsImage.setVisibility(View.VISIBLE);
} else {
settingsImage.setVisibility(View.GONE);
}
}
listener.onClick(position, isChecked);
}
});
}
return v;
}
};
OnClickListener onClickListener = new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int position) {
}
};
b.setAdapter(listAdapter, onClickListener);
b.setPositiveButton(R.string.default_buttons_ok, null);
final AlertDialog dlg = b.create();
listener.setDialog(dlg);
dlg.setCanceledOnTouchOutside(true);
dlg.getListView().setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if(adapter.getSelection(position) >= 0) {
listener.onClick(position, !(adapter.getSelection(position) > 0));
adapter.setSelection(position, adapter.getSelection(position) > 0 ? 0 : 1);
listAdapter.notifyDataSetInvalidated();
} else {
listener.onClick(position, adapter.getSelection(position) > 0);
}
}
});
dlg.show();
}
public void showGPXFileLayer(List<String> files, final OsmandMapTileView mapView) {
final OsmandSettings settings = getApplication().getSettings();
CallbackWithObject<GPXFile[]> callbackWithObject = new CallbackWithObject<GPXFile[]>() {
@ -509,17 +323,7 @@ public class MapActivityLayers {
}
private List<String> getAlreadySelectedGpx(){
if (gpxSelectionHelper == null){
return null;
}
List<GpxSelectionHelper.SelectedGpxFile> selectedGpxFiles = gpxSelectionHelper.getSelectedGPXFiles();
List<String> files = new ArrayList<String>();
for (GpxSelectionHelper.SelectedGpxFile file : selectedGpxFiles) {
files.add(file.getGpxFile().path);
}
return files;
}
public AlertDialog selectPOIFilterLayer(final OsmandMapTileView mapView, final PoiFilter[] selected){
@ -764,4 +568,8 @@ public class MapActivityLayers {
return poiMapLayer;
}
public TransportInfoLayer getTransportInfoLayer() {
return transportInfoLayer;
}
}

View file

@ -177,7 +177,7 @@ public class SelectedGPXFragment extends OsmandExpandableListFragment {
public void onClick(DialogInterface dialog, int which) {
OnContextMenuClick clk = adapter.getClickAdapter(which);
if (clk != null) {
clk.onContextMenuClick(adapter.getItemId(which), which, false, dialog);
clk.onContextMenuClick(adapter.getItemId(which), which, false);
}
}
@ -188,7 +188,7 @@ public class SelectedGPXFragment extends OsmandExpandableListFragment {
private void basicFileOperation(final GpxDisplayItem gpxDisplayItem, ContextMenuAdapter adapter) {
OnContextMenuClick listener = new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int resId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int resId, int pos, boolean isChecked) {
if (resId == R.string.show_gpx_route) {
OsmandSettings settings = app.getSettings();
settings.setMapLocationToShow(gpxDisplayItem.locationStart.lat, gpxDisplayItem.locationStart.lon,

View file

@ -580,7 +580,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
poiDescr.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dlg) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
// Build text(amenity)
// Find and format links
@ -607,7 +607,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
showDetails.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dlg) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
showPOIDetails(amenity, settings.usingEnglishNames());
return true;
}

View file

@ -118,7 +118,7 @@ public class AudioNotesLayer extends OsmandMapLayer implements IContextMenuProvi
final Recording r = (Recording) o;
OnContextMenuClick listener = new ContextMenuAdapter.OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
if (itemId == R.string.recording_context_menu_play ||
itemId == R.string.recording_context_menu_show) {
plugin.playRecording(view.getContext(), r);

View file

@ -414,9 +414,8 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
public void registerLayerContextMenuActions(final OsmandMapTileView mapView, ContextMenuAdapter adapter, final MapActivity mapActivity) {
OnContextMenuClick listener = new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
if (itemId == R.string.layer_recordings) {
dialog.dismiss();
SHOW_RECORDINGS.set(!SHOW_RECORDINGS.get());
updateLayers(mapView, mapActivity);
}
@ -434,7 +433,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
recordAudio(latitude, longitude, mapActivity);
return true;
}
@ -443,7 +442,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
recordVideo(latitude, longitude, mapActivity);
return true;
}
@ -451,7 +450,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
adapter.item(R.string.recording_context_menu_precord).icons(R.drawable.ic_action_photo_dark, R.drawable.ic_action_photo_light)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
takePhoto(latitude, longitude, mapActivity);
return true;
}
@ -1105,7 +1104,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
final RecordingLocalIndexInfo ri = (RecordingLocalIndexInfo) info;
OnContextMenuClick listener = new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
playRecording(la, ri.rec);
return true;
}
@ -1123,8 +1122,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
.icons(R.drawable.ic_action_marker_dark, R.drawable.ic_action_marker_light)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked,
DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
SHOW_RECORDINGS.set(true);
app.getSettings().setMapLocationToShow(ri.rec.lat, ri.rec.lon,
app.getSettings().getLastKnownMapZoom());

View file

@ -0,0 +1,289 @@
package net.osmand.plus.configuremap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import net.osmand.access.AccessibleToast;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
import net.osmand.plus.GpxSelectionHelper;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.SettingsActivity;
import net.osmand.plus.activities.TransportRouteHelper;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.render.RenderingRuleProperty;
import net.osmand.render.RenderingRulesStorage;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.widget.Toast;
public class ConfigureMapMenu {
public ContextMenuAdapter createListAdapter(final MapActivity ma) {
ContextMenuAdapter adapter = new ContextMenuAdapter(ma);
adapter.item(R.string.layers_category_show).setCategory(true);
adapter.item(R.string.configure_map).icons(R.drawable.ic_back_drawer_dark, R.drawable.ic_back_drawer_white)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
ma.getMapActions().prepareStartOptionsMenu();
return false;
}
}).reg();
createLayersItems(adapter, ma);
createRenderingAttributeItems(adapter, ma);
return adapter;
}
private final class LayerMenuListener implements OnContextMenuClick {
private MapActivity ma;
private LayerMenuListener(MapActivity ma) {
this.ma = ma;
}
private List<String> getAlreadySelectedGpx() {
GpxSelectionHelper selectedGpxHelper = ma.getMyApplication().getSelectedGpxHelper();
List<GpxSelectionHelper.SelectedGpxFile> selectedGpxFiles = selectedGpxHelper.getSelectedGPXFiles();
List<String> files = new ArrayList<String>();
for (GpxSelectionHelper.SelectedGpxFile file : selectedGpxFiles) {
files.add(file.getGpxFile().path);
}
return files;
}
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
OsmandSettings settings = ma.getMyApplication().getSettings();
if (itemId == R.string.layer_poi) {
if (isChecked) {
ma.getMapLayers().selectPOIFilterLayer(ma.getMapView(), null);
}
settings.SHOW_POI_OVER_MAP.set(isChecked);
} else if (itemId == R.string.layer_amenity_label) {
settings.SHOW_POI_LABEL.set(isChecked);
} else if (itemId == R.string.layer_favorites) {
settings.SHOW_FAVORITES.set(isChecked);
} else if (itemId == R.string.layer_gpx_layer) {
if (ma.getMyApplication().getSelectedGpxHelper().isShowingAnyGpxFiles()) {
ma.getMyApplication().getSelectedGpxHelper().clearAllGpxFileToShow();
} else {
ma.getMapLayers().showGPXFileLayer(getAlreadySelectedGpx(), ma.getMapView());
}
} else if (itemId == R.string.layer_transport_route) {
ma.getMapLayers().getTransportInfoLayer().setVisible(isChecked);
} else if (itemId == R.string.layer_transport) {
settings.SHOW_TRANSPORT_OVER_MAP.set(isChecked);
}
ma.getMapLayers().updateLayers(ma.getMapView());
ma.getMapView().refreshMap();
return true;
}
}
private void createLayersItems(ContextMenuAdapter adapter , MapActivity activity) {
OsmandApplication app = activity.getMyApplication();
OsmandSettings settings = app.getSettings();
LayerMenuListener l = new LayerMenuListener(activity);
adapter.item(R.string.layers_category_show).setCategory(true);
// String appMode = " [" + settings.getApplicationMode().toHumanString(view.getApplication()) +"] ";
adapter.item(R.string.layer_poi).selected(settings.SHOW_POI_OVER_MAP.get() ? 1 : 0)
.icons(R.drawable.ic_action_info_dark, R.drawable.ic_action_info_light).listen(l).reg();
adapter.item(R.string.layer_amenity_label).selected(settings.SHOW_POI_LABEL.get() ? 1 : 0)
.icons(R.drawable.ic_action_text_dark, R.drawable.ic_action_text_light).listen(l).reg();
adapter.item(R.string.layer_favorites).selected(settings.SHOW_FAVORITES.get() ? 1 : 0)
.icons(R.drawable.ic_action_fav_dark, R.drawable.ic_action_fav_light).listen(l).reg();
adapter.item(R.string.layer_gpx_layer).selected(
app.getSelectedGpxHelper().isShowingAnyGpxFiles()? 1 : 0)
// .icons(R.drawable.ic_action_foot_dark, R.drawable.ic_action_foot_light)
.icons(R.drawable.ic_action_polygom_dark, R.drawable.ic_action_polygom_light)
.listen(l).reg();
adapter.item(R.string.layer_transport).selected( settings.SHOW_TRANSPORT_OVER_MAP.get() ? 1 : 0)
.icons(R.drawable.ic_action_bus_dark, R.drawable.ic_action_bus_light).listen(l).reg();
if(TransportRouteHelper.getInstance().routeIsCalculated()){
adapter.item(R.string.layer_transport_route).selected(1)
.icons(R.drawable.ic_action_bus_dark, R.drawable.ic_action_bus_light).listen(l).reg();
}
OsmandPlugin.registerLayerContextMenu(activity.getMapView(), adapter, activity);
app.getAppCustomization().prepareLayerContextMenu(activity, adapter);
}
protected void refreshMapComplete(final MapActivity activity) {
activity.getMyApplication().getResourceManager().getRenderer().clearCache();
activity.getMapView().refreshMap(true);
}
private void createRenderingAttributeItems(ContextMenuAdapter adapter, final MapActivity activity) {
adapter.item(R.string.map_widget_map_rendering).setCategory(true);
adapter.item(R.string.map_widget_renderer).listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
AlertDialog.Builder bld = new AlertDialog.Builder(activity);
bld.setTitle(R.string.renderers);
final OsmandApplication app = activity.getMyApplication();
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) {
OsmandMapTileView view = activity.getMapView();
view.getSettings().RENDERER.set(renderer);
app.getRendererRegistry().setCurrentSelectedRender(loaded);
refreshMapComplete(activity);
} else {
AccessibleToast.makeText(app, R.string.renderer_load_exception, Toast.LENGTH_SHORT).show();
}
dialog.dismiss();
}
});
bld.show();
return false;
}
}).reg();
adapter.item(R.string.map_widget_day_night).listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
final OsmandMapTileView view = activity.getMapView();
AlertDialog.Builder bld = new AlertDialog.Builder(view.getContext());
bld.setTitle(R.string.daynight);
final String[] items = new String[OsmandSettings.DayNightMode.values().length];
for (int i = 0; i < items.length; i++) {
items[i] = OsmandSettings.DayNightMode.values()[i].toHumanString(activity.getMyApplication());
}
int i = view.getSettings().DAYNIGHT_MODE.get().ordinal();
bld.setSingleChoiceItems(items, i, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
view.getSettings().DAYNIGHT_MODE.set(OsmandSettings.DayNightMode.values()[which]);
refreshMapComplete(activity);
dialog.dismiss();
}
});
bld.show();
return false;
}
}).reg();
adapter.item(R.string.text_size).listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
final OsmandMapTileView view = activity.getMapView();
AlertDialog.Builder b = new AlertDialog.Builder(view.getContext());
// test old descr as title
b.setTitle(R.string.text_size);
final Float[] txtValues = new Float[] { 0.75f, 1f, 1.25f, 1.5f, 2f, 3f };
int selected = -1;
final String[] txtNames = new String[txtValues.length];
for (int i = 0; i < txtNames.length; i++) {
txtNames[i] = (int) (txtValues[i] * 100) + " %";
if (view.getSettings().TEXT_SCALE.get() == txtValues[i]) {
selected = i;
}
}
b.setSingleChoiceItems(txtNames, selected, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
view.getSettings().TEXT_SCALE.set(txtValues[which]);
refreshMapComplete(activity);
}
});
b.show();
return false;
}
}).reg();
RenderingRulesStorage renderer = activity.getMyApplication().getRendererRegistry().getCurrentSelectedRenderer();
if (renderer != null) {
createCustomRenderingProperties(renderer, adapter, activity);
}
}
private void createCustomRenderingProperties(RenderingRulesStorage renderer, ContextMenuAdapter adapter , final MapActivity activity){
final OsmandMapTileView view = activity.getMapView();
adapter.item(R.string.map_widget_vector_attributes).setCategory(true);
final OsmandApplication app = view.getApplication();
List<RenderingRuleProperty> customRules = renderer.PROPS.getCustomRules();
for (final RenderingRuleProperty p : customRules) {
String propertyName = SettingsActivity.getStringPropertyName(view.getContext(), p.getAttrName(),
p.getName());
// test old descr as title
final String propertyDescr = SettingsActivity.getStringPropertyDescription(view.getContext(),
p.getAttrName(), p.getName());
if (p.isBoolean()) {
final OsmandSettings.CommonPreference<Boolean> pref = view.getApplication().getSettings()
.getCustomRenderBooleanProperty(p.getAttrName());
adapter.item(propertyName).listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
pref.set(!pref.get());
refreshMapComplete(activity);
return false;
}
}).selected(pref.get() ? 1 : 0).reg();
} else {
final OsmandSettings.CommonPreference<String> pref = view.getApplication().getSettings()
.getCustomRenderProperty(p.getAttrName());
adapter.item(propertyName).listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
AlertDialog.Builder b = new AlertDialog.Builder(view.getContext());
// test old descr as title
b.setTitle(propertyDescr);
int i = Arrays.asList(p.getPossibleValues()).indexOf(pref.get());
String[] possibleValuesString = new String[p.getPossibleValues().length];
for (int j = 0; j < p.getPossibleValues().length; j++) {
possibleValuesString[j] = SettingsActivity.getStringPropertyValue(view.getContext(),
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 false;
}
}).reg();
}
}
}
}

View file

@ -1,385 +0,0 @@
package net.osmand.plus.configuremap;
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.view.View;
import android.view.ViewGroup;
import android.widget.*;
import net.osmand.CallbackWithObject;
import net.osmand.access.AccessibleToast;
import net.osmand.data.AmenityType;
import net.osmand.plus.*;
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;
import java.util.List;
/**
* Created by Denis on 14.10.2014.
*/
public class ConfigureSettingsMenu {
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 OsmandApplication app;
private MapActivity mapActivity;
private ListView listView;
List<ConfigureMapMenuItem> items = new ArrayList<ConfigureMapMenuItem>();
public class ConfigureMapMenuItem {
int nameId;
int type;
int darkIcon = -1;
int lightIcon = -1;
Object preference;
ConfigureMapMenuItem(int type, int name, int darkIcon, int whiteIcon, Object preference) {
this.type = type;
this.nameId = name;
this.darkIcon = darkIcon;
this.lightIcon = whiteIcon;
this.preference = preference;
}
}
public ConfigureSettingsMenu(MapActivity mapActivity) {
this.mapActivity = mapActivity;
this.app = mapActivity.getMyApplication();
}
public void setListView(ListView list) {
this.listView = list;
listView.setAdapter(createSettingsAdapter());
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int pos, long l) {
onMenuItemClick(items.get(pos), (CheckBox) view.findViewById(R.id.check));
}
});
}
//checkBox should be set only if u have checkBox preference
private void onMenuItemClick(ConfigureMapMenuItem item, CheckBox ch) {
if (item.type == BACK_HEADER){
app.getMapActivity().getMapActions().createOptionsMenuAsDrawer(false);
} else if (item.type == LAYER) {
if (ch != null){
ch.setChecked(!ch.isChecked());
}
if (item.nameId == R.string.layer_poi) {
final OsmandSettings.OsmandPreference<Boolean> pref = (OsmandSettings.OsmandPreference<Boolean>) item.preference;
boolean value = !pref.get();
if (value) {
mapActivity.getMapLayers().selectPOIFilterLayer(mapActivity.getMapView(), null);
}
pref.set(!pref.get());
} else if (item.nameId == R.string.layer_gpx_layer) {
if(app.getSelectedGpxHelper().isShowingAnyGpxFiles()){
app.getSelectedGpxHelper().clearAllGpxFileToShow();
} else {
mapActivity.getMapLayers().showGPXFileLayer(null, mapActivity.getMapView());
}
} else {
final OsmandSettings.OsmandPreference<Boolean> pref = (OsmandSettings.OsmandPreference<Boolean>) item.preference;
pref.set(!pref.get());
}
} else if (item.type == MAP_REDNDER) {
if (item.nameId == R.string.map_widget_renderer) {
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()]);
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();
listView.setAdapter(createSettingsAdapter());
} 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) {
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();
}
} else if (item.type == RENDERING_PROPERTY) {
if (ch != null){
ch.setChecked(!ch.isChecked());
}
final RenderingRuleProperty p = (RenderingRuleProperty) item.preference;
final String propertyDescription = SettingsActivity.getStringPropertyDescription(app, p.getAttrName(), p.getName());
if (p.isBoolean()) {
final OsmandSettings.CommonPreference<Boolean> pref = app.getSettings().getCustomRenderBooleanProperty(p.getAttrName());
pref.set(!pref.get());
app.getResourceManager().getRenderer().clearCache();
} else {
final OsmandSettings.CommonPreference<String> pref = app.getSettings().getCustomRenderProperty(p.getAttrName());
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();
dialog.dismiss();
}
});
b.show();
}
}
app.getMapActivity().getMapLayers().updateLayers(app.getMapActivity().getMapView());
app.getMapActivity().getMapView().refreshMap();
}
private ArrayAdapter<ConfigureMapMenuItem> createSettingsAdapter() {
items.clear();
items.add(new ConfigureMapMenuItem(BACK_HEADER, R.string.configure_map, R.drawable.ic_back_drawer_dark, R.drawable.ic_back_drawer_white, null));
createLayersItems(items);
createRenderingAttributeItems(items);
return new ArrayAdapter<ConfigureMapMenuItem>(app, R.layout.map_settings_item, items) {
@Override
public View getView(int position,View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = app.getMapActivity().getLayoutInflater().inflate(R.layout.map_settings_item, null);
}
final 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));
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
app.getMapActivity().getMapActions().createOptionsMenuAsDrawer(false);
}
});
} 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);
final CheckBox ch = (CheckBox) convertView.findViewById(R.id.check);
ch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
onMenuItemClick(item, null);
}
});
if (item.nameId == R.string.layer_gpx_layer){
ch.setChecked(app.getSelectedGpxHelper().isShowingAnyGpxFiles());
} else {
OsmandSettings.OsmandPreference<Boolean> pref = (OsmandSettings.OsmandPreference<Boolean>) item.preference;
ch.setChecked(pref.get());
}
} else if (item.type == MAP_REDNDER) {
((TextView) convertView.findViewById(R.id.name)).setText(item.nameId);
if (item.nameId == R.string.map_widget_renderer) {
((TextView) convertView.findViewById(R.id.descr)).setText(app.getSettings().RENDERER.get());
} else if (item.nameId == R.string.map_widget_day_night) {
((TextView) convertView.findViewById(R.id.descr)).setText(app.getSettings().DAYNIGHT_MODE.get().toHumanString(app));
}
} 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()) {
OsmandSettings.CommonPreference<Boolean> pref = app.getSettings().getCustomRenderBooleanProperty(p.getAttrName());
final CheckBox ch = (CheckBox) convertView.findViewById(R.id.check);
ch.setChecked(pref.get());
ch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
onMenuItemClick(item, null);
}
});
}
}
return convertView;
}
//Hiding and showing items based on current item
//setting proper visual property
private void prepareView(View convertView, ConfigureMapMenuItem item) {
((TextView) convertView.findViewById(R.id.descr)).setTypeface(null, Typeface.ITALIC);
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 header = ((TextView) convertView.findViewById(R.id.name));
header.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
header.setTypeface(Typeface.DEFAULT);
}
//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);
convertView.findViewById(R.id.check).setVisibility(View.VISIBLE);
} else if (type == MAP_REDNDER) {
convertView.findViewById(R.id.icon).setVisibility(View.GONE);
convertView.findViewById(R.id.check).setVisibility(View.GONE);
convertView.findViewById(R.id.descr).setVisibility(View.VISIBLE);
} 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, -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));
}
// FIXME !!!
// OsmandPlugin.registerLayerContextMenu(mapView, adapter, activity);
// getApplication().getAppCustomization().prepareLayerContextMenu(activity, adapter);
}
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));
}
}
}

View file

@ -584,7 +584,7 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
OnContextMenuClick listener = new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
if (itemId == R.string.delete_point) {
for (int i = 0; i < measurementPoints.size(); i++) {
Iterator<WptPt> it = measurementPoints.get(i).iterator();

View file

@ -146,7 +146,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
public void onClick(DialogInterface dialog, int which) {
OnContextMenuClick clk = adapter.getClickAdapter(which);
if (clk != null) {
clk.onContextMenuClick(adapter.getItemId(which), which, false, dialog);
clk.onContextMenuClick(adapter.getItemId(which), which, false);
}
}
@ -158,7 +158,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
private void basicFileOperation(final LocalIndexInfo info, ContextMenuAdapter adapter) {
OnContextMenuClick listener = new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int resId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int resId, int pos, boolean isChecked) {
if (resId == R.string.local_index_mi_rename) {
renameFile(info);
} else if (resId == R.string.local_index_mi_restore) {
@ -476,7 +476,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
optionsMenuAdapter = new ContextMenuAdapter(getDownloadActivity());
OnContextMenuClick listener = new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
localOptionsMenu(itemId);
return true;
}
@ -531,7 +531,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
int itemId = item.getItemId();
for (int i = 0; i < optionsMenuAdapter.length(); i++) {
if (itemId == optionsMenuAdapter.getItemId(i)) {
optionsMenuAdapter.getClickAdapter(i).onContextMenuClick(itemId, i, false, null);
optionsMenuAdapter.getClickAdapter(i).onContextMenuClick(itemId, i, false);
return true;
}
}

View file

@ -115,7 +115,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin implements MonitoringIn
ContextMenuAdapter adapter, Object selectedObj) {
OnContextMenuClick listener = new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int resId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int resId, int pos, boolean isChecked) {
if (resId == R.string.context_menu_item_add_waypoint) {
mapActivity.getMapActions().addWaypoint(latitude, longitude);
}
@ -448,7 +448,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin implements MonitoringIn
int draw = !bgoff ? R.drawable.monitoring_rec_big : R.drawable.monitoring_rec_inactive;
qa.item(msgId).icon(draw).listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
if (view.getApplication().getNavigationService() == null) {
final ValueHolder<Integer> vs = new ValueHolder<Integer>();
final ValueHolder<Boolean> choice = new ValueHolder<Boolean>();

View file

@ -495,7 +495,7 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
OnContextMenuClick listener = new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
if (itemId == R.string.osb_comment_menu_item) {
commentBug(bug);
} else if (itemId == R.string.osb_close_menu_item) {

View file

@ -122,7 +122,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
final Object selectedObj) {
OnContextMenuClick listener = new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int resId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int resId, int pos, boolean isChecked) {
if (resId == R.string.context_menu_item_create_poi) {
getPoiActions(mapActivity).showCreateDialog(latitude, longitude);
} else if (resId == R.string.context_menu_item_open_bug) {
@ -157,7 +157,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
.icons(R.drawable.ic_action_bug_dark, R.drawable.ic_action_bug_light).listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
if (itemId == R.string.layer_osm_bugs) {
settings.SHOW_OSM_BUGS.set(isChecked);
}
@ -180,7 +180,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
sendGPXFiles(la, (AvailableGPXFragment) fragment, (GpxInfo) info);
return true;
}
@ -197,7 +197,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
f.openSelectionMode(R.string.local_index_mi_upload_gpx, R.drawable.ic_action_gup_dark,
R.drawable.ic_action_gup_light, new OnClickListener() {
@Override

View file

@ -41,7 +41,6 @@ import org.apache.commons.logging.Log;
import org.json.JSONException;
import org.json.JSONObject;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
@ -136,7 +135,7 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer
R.drawable.ic_action_gloc_light).listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
OsMoDevice o = (OsMoDevice) selectedObj;
double lat = o.getLastLocation() == null ? latitude : o.getLastLocation().getLatitude();
double lon = o.getLastLocation() == null ? longitude : o.getLastLocation().getLongitude();
@ -151,8 +150,7 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer
R.drawable.ic_action_close_light).listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked,
DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
OsMoPositionLayer.setFollowDestination(null);
return true;
}
@ -163,7 +161,7 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer
R.drawable.ic_action_flag_light).listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
OsMoDevice o = (OsMoDevice) selectedObj;
if(o.getLastLocation() != null) {
TargetPointsHelper targets = mapActivity.getMyApplication().getTargetPointsHelper();
@ -294,7 +292,7 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
final double lat = view.getLatitude();
final double lon = view.getLongitude();
tracker.sendCoordinate(lat, lon);
@ -325,7 +323,7 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer
helper.item(R.string.osmo_groups).icons(R.drawable.ic_action_eye_dark, R.drawable.ic_action_eye_light).position(6)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
Intent intent = new Intent(mapActivity, OsMoGroupsActivity.class);
mapActivity.startActivity(intent);
return true;

View file

@ -201,7 +201,7 @@ public class ParkingPositionPlugin extends OsmandPlugin {
OnContextMenuClick removeListener = new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int resId, int pos,
boolean isChecked, DialogInterface dialog) {
boolean isChecked) {
if ((resId == R.string.context_menu_item_delete_parking_point)) {
showDeleteDialog(mapActivity);
}
@ -215,7 +215,7 @@ public class ParkingPositionPlugin extends OsmandPlugin {
OnContextMenuClick addListener = new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int resId, int pos,
boolean isChecked, DialogInterface dialog) {
boolean isChecked) {
if (resId == R.string.context_menu_item_add_parking_point) {
showAddParkingDialog(mapActivity, latitude, longitude);
}
@ -421,7 +421,7 @@ public class ParkingPositionPlugin extends OsmandPlugin {
helper.item(R.string.osmand_parking_delete)
.icons(R.drawable.ic_action_remove_dark, R.drawable.ic_action_remove_light).listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
showDeleteDialog(mapActivity);
return true;
}

View file

@ -36,7 +36,6 @@ import android.os.AsyncTask;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceScreen;
import android.support.v4.app.DialogFragment;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
@ -186,9 +185,8 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
final MapActivityLayers layers = mapActivity.getMapLayers();
OnContextMenuClick listener = new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
if (itemId == R.string.layer_map) {
dialog.dismiss();
layers.selectMapLayer(mapView);
} else if(itemId == R.string.layer_overlay){
if(overlayLayer.getMap() != null){
@ -196,7 +194,6 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
updateMapLayers(mapView, null, layers);
layers.getMapControlsLayer().hideTransparencyBar(settings.MAP_OVERLAY_TRANSPARENCY);
} else {
dialog.dismiss();
selectMapOverlayLayer(mapView, settings.MAP_OVERLAY, settings.MAP_OVERLAY_TRANSPARENCY, mapActivity);
}
} else if(itemId == R.string.layer_underlay){
@ -205,7 +202,6 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
updateMapLayers(mapView, null, layers);
layers.getMapControlsLayer().hideTransparencyBar(settings.MAP_TRANSPARENCY);
} else {
dialog.dismiss();
selectMapOverlayLayer(mapView, settings.MAP_UNDERLAY,settings.MAP_TRANSPARENCY,
mapActivity);
}
@ -229,7 +225,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
if (mapView.getMainLayer() instanceof MapTileLayer) {
OnContextMenuClick listener = new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int resId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int resId, int pos, boolean isChecked) {
if (resId == R.string.context_menu_item_update_map) {
mapActivity.getMapActions().reloadTile(mapView.getZoom(), latitude, longitude);
} else if (resId == R.string.context_menu_item_download_map) {

View file

@ -23,7 +23,7 @@ public class RendererRegistry {
private final static Log log = PlatformUtil.getLog(RendererRegistry.class);
public final static String DEFAULT_RENDER = "default"; //$NON-NLS-1$
public final static String DEFAULT_RENDER = "OsmAnd"; //$NON-NLS-1$
private RenderingRulesStorage defaultRender = null;
private RenderingRulesStorage currentSelectedRender = null;

View file

@ -1,6 +1,5 @@
package net.osmand.plus.routepointsnavigation;
import android.content.DialogInterface;
import android.graphics.Canvas;
import android.graphics.PointF;
import android.os.AsyncTask;
@ -75,7 +74,7 @@ public class RoutePointsLayer extends OsmandMapLayer implements ContextMenuLaye
final GPXUtilities.WptPt point = (GPXUtilities.WptPt) o;
ContextMenuAdapter.OnContextMenuClick listener = new ContextMenuAdapter.OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
if (itemId == R.string.mark_as_not_visited){
plugin.getCurrentRoute().markPoint(point,false);
plugin.saveCurrentRoute();

View file

@ -513,7 +513,7 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
adapter.item(R.string.show_waypoint_information).icons(R.drawable.ic_action_info_dark, R.drawable.ic_action_info_light ).position(0)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
showFavoriteDialog(mapActivity, selectedStage, sf);
return true;
}
@ -565,7 +565,7 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
R.drawable.ic_action_gremove_dark, R.drawable.ic_action_gremove_light)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
app.getSettings().SHOW_POI_OVER_MAP.set(false);
mapActivity.getMapLayers().updateLayers(mapActivity.getMapView());
return true;
@ -575,7 +575,7 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
adapter.item(R.string.poi).icons(R.drawable.ic_action_layers_dark, R.drawable.ic_action_layers_light)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
mapActivity.getMapLayers().selectPOIFilterLayer(mapActivity.getMapView(), null);
app.getSettings().SHOW_POI_OVER_MAP.set(true);
mapActivity.getMapLayers().updateLayers(mapActivity.getMapView());
@ -587,7 +587,7 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
adapter.item(R.string.sherpafy_tour_info_txt).icons(R.drawable.ic_action_info_dark, R.drawable.ic_action_info_light)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
Intent newIntent = new Intent(mapActivity, TourViewActivity.class);
// newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
mapActivity.startActivity(newIntent);
@ -601,7 +601,7 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
.icons(R.drawable.ic_action_finish_flag_dark, R.drawable.ic_action_finish_flag_light)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
markStageAsCompleted(stage);
showCompleteStageFragment(mapActivity, stage, false);
return true;
@ -612,7 +612,7 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
adapter.item(R.string.context_menu_item_share_location).icons(
R.drawable.ic_action_gshare_dark, R.drawable.ic_action_gshare_light).listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
if (app.getLocationProvider().getLastKnownLocation() != null) {
new ShareLocation(mapActivity).run();
} else {

View file

@ -10,7 +10,6 @@ import net.osmand.plus.OsmandSettings.CommonPreference;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.views.OsmandMapTileView;
import android.content.DialogInterface;
public class SRTMPlugin extends OsmandPlugin {
@ -95,7 +94,7 @@ public class SRTMPlugin extends OsmandPlugin {
public void registerLayerContextMenuActions(final OsmandMapTileView mapView, ContextMenuAdapter adapter, final MapActivity mapActivity) {
OnContextMenuClick listener = new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
if (itemId == R.string.layer_hillshade) {
HILLSHADE.set(!HILLSHADE.get());
updateLayers(mapView, mapActivity);

View file

@ -198,7 +198,7 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
final FavouritePoint a = (FavouritePoint) o;
OnContextMenuClick listener = new ContextMenuAdapter.OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
if (itemId == R.string.favourites_context_menu_delete) {
final Resources resources = view.getContext().getResources();
Builder builder = new AlertDialog.Builder(view.getContext());

View file

@ -640,8 +640,8 @@ public class MapInfoLayer extends OsmandMapLayer {
layers.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
map.getMapLayers().openLayerSelectionDialog(view);
//map.getMapLayers().selectMapLayer(view);
map.getMapActions().prepareConfigureMap();
map.getMapActions().toggleDrawer();
}
});
return layers;

View file

@ -89,7 +89,7 @@ public class MonitoringInfoControl {
ai.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ca.getClickAdapter(ij).onContextMenuClick(ca.getItemId(ij), ij, false, null);
ca.getClickAdapter(ij).onContextMenuClick(ca.getItemId(ij), ij, false);
qa.dismiss();
}
});

View file

@ -27,7 +27,6 @@ import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener;
import net.osmand.plus.views.MapTextLayer.MapTextProvider;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Canvas;
@ -256,7 +255,7 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
final Amenity a = (Amenity) o;
OnContextMenuClick listener = new ContextMenuAdapter.OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
if (itemId == R.string.poi_context_menu_call) {
try {
Intent intent = new Intent(Intent.ACTION_VIEW);

View file

@ -12,7 +12,6 @@ import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.TargetPointsHelper.TargetPoint;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.views.ContextMenuLayer.IContextMenuProvider;
import android.content.DialogInterface;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
@ -220,7 +219,7 @@ public class PointNavigationLayer extends OsmandMapLayer implements IContextMenu
final TargetPoint a = (TargetPoint) o;
OnContextMenuClick listener = new ContextMenuAdapter.OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
if (itemId == R.string.delete_target_point) {
TargetPointsHelper targetPointsHelper = map.getMyApplication().getTargetPointsHelper();
if(a.intermediate) {

View file

@ -15,7 +15,6 @@ import net.osmand.plus.resources.TransportIndexRepository;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PointF;
@ -216,7 +215,7 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa
final TransportStop a = (TransportStop) o;
OnContextMenuClick listener = new ContextMenuAdapter.OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
showDescriptionDialog(a);
return true;
}

View file

@ -39,7 +39,8 @@ public class MapMenuControls extends MapControls {
// double lat = activity.getMapView().getLatitude();
// double lon = activity.getMapView().getLongitude();
// MainMenuActivity.backToMainMenuDialog(activity, new LatLon(lat, lon));
mapActivity.getMapActions().createOptionsMenuAsDrawer(true);
mapActivity.getMapActions().prepareStartOptionsMenu();
mapActivity.getMapActions().toggleDrawer();
notifyClicked();
}
});

View file

@ -26,8 +26,8 @@ public class SmallMapMenuControls extends MapControls {
@Override
public void onClick(View v) {
notifyClicked();
//mapActivity.getMapActions().openOptionsMenuAsDrawer();
mapActivity.getMapActions().createOptionsMenuAsDrawer(true);
mapActivity.getMapActions().prepareStartOptionsMenu();
mapActivity.getMapActions().toggleDrawer();
}
});
}

View file

@ -1,31 +1,13 @@
package net.osmand.plus.views.mapwidgets;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import net.osmand.access.AccessibleToast;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.SettingsActivity;
import net.osmand.plus.views.MapInfoLayer;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.render.RenderingRuleProperty;
import net.osmand.render.RenderingRulesStorage;
import net.osmand.util.Algorithms;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.preference.PreferenceGroup;
import android.widget.Toast;
public class AppearanceWidgetsFactory {
public static AppearanceWidgetsFactory INSTANCE = new AppearanceWidgetsFactory();
private String ADDITIONAL_VECTOR_RENDERING_CATEGORY;
public static boolean EXTRA_SETTINGS = true;
public static boolean POSITION_ON_THE_MAP = false;
@ -44,7 +26,6 @@ public class AppearanceWidgetsFactory {
// }
// });
if (EXTRA_SETTINGS) {
final MapWidgetRegistry.MapWidgetRegInfo showRuler = mapInfoControls.registerAppearanceWidget(R.drawable.widget_ruler, R.string.map_widget_show_ruler,
"showRuler", view.getSettings().SHOW_RULER);
showRuler.setStateChangeListener(new Runnable() {
@ -54,36 +35,6 @@ public class AppearanceWidgetsFactory {
view.refreshMap();
}
});
MapWidgetRegistry.MapWidgetRegInfo w = mapInfoControls.registerAppearanceWidget(R.drawable.widget_no_icon,
R.string.text_size, "text_size", view.getSettings().TEXT_SCALE);
w.setStateChangeListener(new Runnable() {
@Override
public void run() {
AlertDialog.Builder b = new AlertDialog.Builder(view.getContext());
//test old descr as title
b.setTitle(R.string.text_size);
final Float[] txtValues = new Float[] {0.75f, 1f, 1.25f, 1.5f, 2f, 3f} ;
int selected = -1;
final String[] txtNames = new String[txtValues.length];
for (int i = 0; i < txtNames.length; i++) {
txtNames[i] = (int) (txtValues[i] * 100) + " %";
if (view.getSettings().TEXT_SCALE.get() == txtValues[i]) {
selected = i;
}
}
b.setSingleChoiceItems(txtNames, selected, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
view.getSettings().TEXT_SCALE.set(txtValues[which]);
view.getApplication().getResourceManager().getRenderer().clearCache();
view.refreshMap(true);
dialog.dismiss();
}
});
b.show();
}
});
final MapWidgetRegistry.MapWidgetRegInfo showDestinationArrow = mapInfoControls.registerAppearanceWidget(R.drawable.widget_show_destination_arrow, R.string.map_widget_show_destination_arrow,
"show_destination_arrow", view.getSettings().SHOW_DESTINATION_ARROW);
showDestinationArrow.setStateChangeListener(new Runnable() {
@ -117,159 +68,5 @@ public class AppearanceWidgetsFactory {
});
}
final MapWidgetRegistry.MapWidgetRegInfo vectorRenderer = mapInfoControls.registerAppearanceWidget(R.drawable.widget_rendering_style, map.getString(R.string.map_widget_renderer),
"renderer", view.getSettings().RENDERER, map.getString(R.string.map_widget_map_rendering));
final OsmandApplication app = view.getApplication();
vectorRenderer.setStateChangeListener(new Runnable() {
@Override
public void run() {
AlertDialog.Builder bld = new AlertDialog.Builder(view.getContext());
bld.setTitle(R.string.renderers);
Collection<String> rendererNames = app.getRendererRegistry().getRendererNames();
final String[] items = rendererNames.toArray(new String[rendererNames.size()]);
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) {
view.getSettings().RENDERER.set(renderer);
app.getRendererRegistry().setCurrentSelectedRender(loaded);
app.getResourceManager().getRenderer().clearCache();
view.refreshMap(true);
} else {
AccessibleToast.makeText(app, R.string.renderer_load_exception, Toast.LENGTH_SHORT).show();
}
if(EXTRA_SETTINGS) {
createCustomRenderingProperties(loaded, map, mapInfoLayer, mapInfoControls);
}
dialog.dismiss();
}
});
bld.show();
}
});
final MapWidgetRegistry.MapWidgetRegInfo dayNight = mapInfoControls.registerAppearanceWidget(R.drawable.widget_day_night_mode, map.getString(R.string.map_widget_day_night),
"dayNight", view.getSettings().DAYNIGHT_MODE, map.getString(R.string.map_widget_map_rendering));
dayNight.setStateChangeListener(new Runnable() {
@Override
public void run() {
AlertDialog.Builder bld = new AlertDialog.Builder(view.getContext());
bld.setTitle(R.string.daynight);
final String[] items = new String[OsmandSettings.DayNightMode.values().length];
for (int i = 0; i < items.length; i++) {
items[i] = OsmandSettings.DayNightMode.values()[i].toHumanString(map.getMyApplication());
}
int i = view.getSettings().DAYNIGHT_MODE.get().ordinal();
bld.setSingleChoiceItems(items, i, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
view.getSettings().DAYNIGHT_MODE.set(OsmandSettings.DayNightMode.values()[which]);
app.getResourceManager().getRenderer().clearCache();
view.refreshMap(true);
dialog.dismiss();
}
});
bld.show();
}
});
RenderingRulesStorage renderer = app.getRendererRegistry().getCurrentSelectedRenderer();
if(renderer != null && EXTRA_SETTINGS) {
createCustomRenderingProperties(renderer, map, mapInfoLayer, mapInfoControls);
}
}
private void createCustomRenderingProperties(RenderingRulesStorage renderer, final MapActivity map,
final MapInfoLayer mapInfoLayer, final MapWidgetRegistry mapInfoControls) {
final OsmandMapTileView view = map.getMapView();
if(ADDITIONAL_VECTOR_RENDERING_CATEGORY == null) {
ADDITIONAL_VECTOR_RENDERING_CATEGORY = map.getString(R.string.map_widget_vector_attributes);
}
String categoryName = ADDITIONAL_VECTOR_RENDERING_CATEGORY;
mapInfoControls.removeApperanceWidgets(categoryName);
final OsmandApplication app = view.getApplication();
List<RenderingRuleProperty> customRules = renderer.PROPS.getCustomRules();
for (final RenderingRuleProperty p : customRules) {
String propertyName = SettingsActivity.getStringPropertyName(view.getContext(), p.getAttrName(), p.getName());
//test old descr as title
final String propertyDescr = SettingsActivity.getStringPropertyDescription(view.getContext(), p.getAttrName(), p.getName());
if(p.isBoolean()) {
final OsmandSettings.CommonPreference<Boolean> pref = view.getApplication().getSettings().getCustomRenderBooleanProperty(p.getAttrName());
int icon = 0;
try {
Field f = R.drawable.class.getField("widget_" + p.getAttrName().toLowerCase());
icon = f.getInt(null);
} catch(Exception e){
try {
Field f = R.drawable.class.getField("widget_no_icon");
icon = f.getInt(null);
} catch(Exception e0){
}
}
MapWidgetRegistry.MapWidgetRegInfo w = mapInfoControls.registerAppearanceWidget(icon, propertyName, "rend_"+p.getAttrName(), pref, categoryName);
w.setStateChangeListener(new Runnable() {
@Override
public void run() {
pref.set(!pref.get());
app.getResourceManager().getRenderer().clearCache();
view.refreshMap(true);
}
});
} else {
final OsmandSettings.CommonPreference<String> pref = view.getApplication().getSettings().getCustomRenderProperty(p.getAttrName());
int icon = 0;
try {
Field f = R.drawable.class.getField("widget_" + p.getAttrName().toLowerCase());
icon = f.getInt(null);
} catch(Exception e){
try {
Field f = R.drawable.class.getField("widget_no_icon");
icon = f.getInt(null);
} catch(Exception e0){
}
}
MapWidgetRegistry.MapWidgetRegInfo w = mapInfoControls.registerAppearanceWidget(icon, propertyName, "rend_"+p.getAttrName(), pref, categoryName);
w.setStateChangeListener(new Runnable() {
@Override
public void run() {
AlertDialog.Builder b = new AlertDialog.Builder(view.getContext());
//test old descr as title
b.setTitle(propertyDescr);
int i = Arrays.asList(p.getPossibleValues()).indexOf(pref.get());
String[] possibleValuesString = new String[p.getPossibleValues().length];
for (int j = 0; j < p.getPossibleValues().length; j++) {
possibleValuesString[j] = SettingsActivity.getStringPropertyValue(view.getContext(), 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();
}
});
}
}
}
}