Add show direction menu to configure screen
(cherry picked from commit f9bf198
)
This commit is contained in:
parent
da81464597
commit
8ac26dc322
2 changed files with 13 additions and 22 deletions
|
@ -282,6 +282,10 @@ public class ShowDirectionBottomSheetDialogFragment extends BottomSheetDialogFra
|
||||||
showDirectionEnabled = false;
|
showDirectionEnabled = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
MapActivity mapActivity = getMapActivity();
|
||||||
|
if (mapActivity != null) {
|
||||||
|
mapActivity.refreshMap();
|
||||||
|
}
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
listener.onMapMarkersModeChanged(showDirectionEnabled);
|
listener.onMapMarkersModeChanged(showDirectionEnabled);
|
||||||
}
|
}
|
||||||
|
@ -289,7 +293,7 @@ public class ShowDirectionBottomSheetDialogFragment extends BottomSheetDialogFra
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
interface ShowDirectionFragmentListener {
|
public interface ShowDirectionFragmentListener {
|
||||||
void onMapMarkersModeChanged(boolean showDirectionEnabled);
|
void onMapMarkersModeChanged(boolean showDirectionEnabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
package net.osmand.plus.views.mapwidgets;
|
package net.osmand.plus.views.mapwidgets;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.support.annotation.DrawableRes;
|
import android.support.annotation.DrawableRes;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.StringRes;
|
import android.support.annotation.StringRes;
|
||||||
import android.support.v7.app.AlertDialog;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
@ -19,16 +17,15 @@ import net.osmand.plus.ContextMenuItem;
|
||||||
import net.osmand.plus.IconsCache;
|
import net.osmand.plus.IconsCache;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.OsmandSettings.MapMarkersMode;
|
|
||||||
import net.osmand.plus.OsmandSettings.OsmandPreference;
|
import net.osmand.plus.OsmandSettings.OsmandPreference;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.dialogs.ConfigureMapMenu;
|
import net.osmand.plus.dialogs.ConfigureMapMenu;
|
||||||
|
import net.osmand.plus.mapmarkers.ShowDirectionBottomSheetDialogFragment;
|
||||||
import net.osmand.plus.quickaction.QuickActionListFragment;
|
import net.osmand.plus.quickaction.QuickActionListFragment;
|
||||||
import net.osmand.plus.views.MapInfoLayer;
|
import net.osmand.plus.views.MapInfoLayer;
|
||||||
import net.osmand.plus.views.MapQuickActionLayer;
|
import net.osmand.plus.views.MapQuickActionLayer;
|
||||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
|
||||||
import net.osmand.plus.widgets.IconPopupMenu;
|
import net.osmand.plus.widgets.IconPopupMenu;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -329,27 +326,17 @@ public class MapWidgetRegistry {
|
||||||
.setDescription(settings.MAP_MARKERS_MODE.get().toHumanString(map))
|
.setDescription(settings.MAP_MARKERS_MODE.get().toHumanString(map))
|
||||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> ad,
|
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> adapter, int itemId, final int position, boolean isChecked) {
|
||||||
int itemId, final int pos, boolean isChecked) {
|
ShowDirectionBottomSheetDialogFragment fragment = new ShowDirectionBottomSheetDialogFragment();
|
||||||
final OsmandMapTileView view = map.getMapView();
|
fragment.setListener(new ShowDirectionBottomSheetDialogFragment.ShowDirectionFragmentListener() {
|
||||||
AlertDialog.Builder bld = new AlertDialog.Builder(view.getContext());
|
|
||||||
bld.setTitle(R.string.map_markers);
|
|
||||||
final String[] items = new String[MapMarkersMode.values().length];
|
|
||||||
for (int i = 0; i < items.length; i++) {
|
|
||||||
items[i] = MapMarkersMode.values()[i].toHumanString(map);
|
|
||||||
}
|
|
||||||
int i = settings.MAP_MARKERS_MODE.get().ordinal();
|
|
||||||
bld.setSingleChoiceItems(items, i, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onMapMarkersModeChanged(boolean showDirectionEnabled) {
|
||||||
settings.MAP_MARKERS_MODE.set(MapMarkersMode.values()[which]);
|
|
||||||
updateMapMarkersMode(map);
|
updateMapMarkersMode(map);
|
||||||
dialog.dismiss();
|
cm.getItem(position).setDescription(settings.MAP_MARKERS_MODE.get().toHumanString(map));
|
||||||
cm.getItem(pos).setDescription(settings.MAP_MARKERS_MODE.get().toHumanString(map));
|
adapter.notifyDataSetChanged();
|
||||||
ad.notifyDataSetChanged();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
bld.show();
|
fragment.show(map.getSupportFragmentManager(), ShowDirectionBottomSheetDialogFragment.TAG);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}).setLayout(R.layout.list_item_text_button).createItem());
|
}).setLayout(R.layout.list_item_text_button).createItem());
|
||||||
|
|
Loading…
Reference in a new issue