Custom Filter -> Edit Categories Bug
This commit is contained in:
parent
67ef319294
commit
6e3f1702ae
4 changed files with 400 additions and 277 deletions
|
@ -80,13 +80,13 @@ public interface OsmAndCustomizationConstants {
|
|||
String MAP_CONTEXT_MENU_MEASURE_DISTANCE = MAP_CONTEXT_MENU_ACTIONS + "measure_distance";
|
||||
String MAP_CONTEXT_MENU_EDIT_GPX_WP = MAP_CONTEXT_MENU_ACTIONS + "edit_gpx_waypoint";
|
||||
String MAP_CONTEXT_MENU_ADD_GPX_WAYPOINT = MAP_CONTEXT_MENU_ACTIONS + "add_gpx_waypoint";
|
||||
String MAP_CONTEXT_MENU_UPDATE_MAP = MAP_CONTEXT_MENU_ACTIONS + "update_map";
|
||||
String MAP_CONTEXT_MENU_DOWNLOAD_MAP = MAP_CONTEXT_MENU_ACTIONS + "download_map";
|
||||
String MAP_CONTEXT_MENU_MODIFY_POI = MAP_CONTEXT_MENU_ACTIONS + "modify_poi";
|
||||
String MAP_CONTEXT_MENU_MODIFY_OSM_CHANGE = MAP_CONTEXT_MENU_ACTIONS + "modify_osm_change";
|
||||
String MAP_CONTEXT_MENU_CREATE_POI = MAP_CONTEXT_MENU_ACTIONS + "create_poi";
|
||||
String MAP_CONTEXT_MENU_MODIFY_OSM_NOTE = MAP_CONTEXT_MENU_ACTIONS + "modify_osm_note";
|
||||
String MAP_CONTEXT_MENU_OPEN_OSM_NOTE = MAP_CONTEXT_MENU_ACTIONS + "open_osm_note";
|
||||
String MAP_CONTEXT_MENU_UPDATE_MAP = MAP_CONTEXT_MENU_ACTIONS + "update_map";
|
||||
String MAP_CONTEXT_MENU_DOWNLOAD_MAP = MAP_CONTEXT_MENU_ACTIONS + "download_map";
|
||||
String MAP_CONTEXT_MENU_MODIFY_POI = MAP_CONTEXT_MENU_ACTIONS + "modify_poi";
|
||||
String MAP_CONTEXT_MENU_MODIFY_OSM_CHANGE = MAP_CONTEXT_MENU_ACTIONS + "modify_osm_change";
|
||||
String MAP_CONTEXT_MENU_CREATE_POI = MAP_CONTEXT_MENU_ACTIONS + "create_poi";
|
||||
String MAP_CONTEXT_MENU_MODIFY_OSM_NOTE = MAP_CONTEXT_MENU_ACTIONS + "modify_osm_note";
|
||||
String MAP_CONTEXT_MENU_OPEN_OSM_NOTE = MAP_CONTEXT_MENU_ACTIONS + "open_osm_note";
|
||||
|
||||
//Plug-in's IDs:
|
||||
String PLUGIN_OSMAND_MONITOR = "osmand.monitoring";
|
||||
|
|
|
@ -104,13 +104,14 @@ import static net.osmand.plus.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_SEAR
|
|||
import static net.osmand.plus.helpers.ImportHelper.GPX_SUFFIX;
|
||||
|
||||
public class MapActivityActions implements DialogProvider {
|
||||
|
||||
private static final Log LOG = PlatformUtil.getLog(MapActivityActions.class);
|
||||
public static final String KEY_LONGITUDE = "longitude";
|
||||
public static final String KEY_LATITUDE = "latitude";
|
||||
public static final String KEY_NAME = "name";
|
||||
|
||||
public static final String KEY_ZOOM = "zoom";
|
||||
|
||||
|
||||
public static final int REQUEST_LOCATION_FOR_DIRECTIONS_NAVIGATION_PERMISSION = 203;
|
||||
|
||||
// Constants for determining the order of items in the additional actions context menu
|
||||
|
@ -144,19 +145,24 @@ public class MapActivityActions implements DialogProvider {
|
|||
settings = mapActivity.getMyApplication().getSettings();
|
||||
routingHelper = mapActivity.getMyApplication().getRoutingHelper();
|
||||
drawerLogoHeader = new ImageView(mapActivity);
|
||||
drawerLogoHeader.setPadding(-AndroidUtils.dpToPx(mapActivity, 8f), AndroidUtils.dpToPx(mapActivity, 16f), 0,0);
|
||||
drawerOsmAndFooter = mapActivity.getLayoutInflater().inflate(R.layout.powered_by_osmand_item, null);
|
||||
drawerLogoHeader
|
||||
.setPadding(-AndroidUtils.dpToPx(mapActivity, 8f), AndroidUtils.dpToPx(mapActivity, 16f), 0,
|
||||
0);
|
||||
drawerOsmAndFooter = mapActivity.getLayoutInflater()
|
||||
.inflate(R.layout.powered_by_osmand_item, null);
|
||||
}
|
||||
|
||||
public void addAsTarget(double latitude, double longitude, PointDescription pd) {
|
||||
TargetPointsHelper targets = getMyApplication().getTargetPointsHelper();
|
||||
targets.navigateToPoint(new LatLon(latitude, longitude), true, targets.getIntermediatePoints().size() + 1,
|
||||
targets.navigateToPoint(new LatLon(latitude, longitude), true,
|
||||
targets.getIntermediatePoints().size() + 1,
|
||||
pd);
|
||||
openIntermediatePointsDialog();
|
||||
}
|
||||
|
||||
|
||||
public void addMapMarker(double latitude, double longitude, PointDescription pd, @Nullable String mapObjectName) {
|
||||
public void addMapMarker(double latitude, double longitude, PointDescription pd,
|
||||
@Nullable String mapObjectName) {
|
||||
MapMarkersHelper markersHelper = getMyApplication().getMapMarkersHelper();
|
||||
markersHelper.addMapMarker(new LatLon(latitude, longitude), pd, mapObjectName);
|
||||
}
|
||||
|
@ -193,8 +199,11 @@ public class MapActivityActions implements DialogProvider {
|
|||
double longitude = args.getDouble(KEY_LONGITUDE);
|
||||
String name = editText.getText().toString();
|
||||
SavingTrackHelper savingTrackHelper = mapActivity.getMyApplication().getSavingTrackHelper();
|
||||
savingTrackHelper.insertPointData(latitude, longitude, System.currentTimeMillis(), null, name, null, 0);
|
||||
Toast.makeText(mapActivity, MessageFormat.format(getString(R.string.add_waypoint_dialog_added), name), Toast.LENGTH_SHORT)
|
||||
savingTrackHelper
|
||||
.insertPointData(latitude, longitude, System.currentTimeMillis(), null, name, null, 0);
|
||||
Toast.makeText(mapActivity,
|
||||
MessageFormat.format(getString(R.string.add_waypoint_dialog_added), name),
|
||||
Toast.LENGTH_SHORT)
|
||||
.show();
|
||||
dialog.dismiss();
|
||||
}
|
||||
|
@ -204,7 +213,8 @@ public class MapActivityActions implements DialogProvider {
|
|||
@Override
|
||||
public void onFocusChange(View v, boolean hasFocus) {
|
||||
if (hasFocus) {
|
||||
alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
|
||||
alertDialog.getWindow()
|
||||
.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -275,7 +285,8 @@ public class MapActivityActions implements DialogProvider {
|
|||
dlg.findViewById(R.id.DuplicateFileName).setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
dlg.dismiss();
|
||||
new SaveDirectionsAsyncTask(app).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, toSave);
|
||||
new SaveDirectionsAsyncTask(app)
|
||||
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, toSave);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -287,7 +298,6 @@ public class MapActivityActions implements DialogProvider {
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
return dlg;
|
||||
}
|
||||
|
||||
|
@ -304,7 +314,8 @@ public class MapActivityActions implements DialogProvider {
|
|||
if (params.length > 0) {
|
||||
File file = params[0];
|
||||
String fileName = file.getName();
|
||||
GPXFile gpx = app.getRoutingHelper().generateGPXFileWithRoute(fileName.substring(0,fileName.length()-GPX_SUFFIX.length()));
|
||||
GPXFile gpx = app.getRoutingHelper().generateGPXFileWithRoute(
|
||||
fileName.substring(0, fileName.length() - GPX_SUFFIX.length()));
|
||||
GPXUtilities.writeGpxFile(file, gpx, app);
|
||||
return app.getString(R.string.route_successfully_saved_at, file.getName());
|
||||
}
|
||||
|
@ -320,7 +331,8 @@ public class MapActivityActions implements DialogProvider {
|
|||
|
||||
}
|
||||
|
||||
public void contextMenuPoint(final double latitude, final double longitude, final ContextMenuAdapter iadapter, Object selectedObj) {
|
||||
public void contextMenuPoint(final double latitude, final double longitude,
|
||||
final ContextMenuAdapter iadapter, Object selectedObj) {
|
||||
final ContextMenuAdapter adapter = iadapter == null ? new ContextMenuAdapter() : iadapter;
|
||||
ItemBuilder itemBuilder = new ItemBuilder();
|
||||
|
||||
|
@ -341,7 +353,8 @@ public class MapActivityActions implements DialogProvider {
|
|||
|
||||
ContextMenuAdapter.ItemClickListener listener = new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int resId, int pos, boolean isChecked, int[] viewCoordinates) {
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int resId, int pos,
|
||||
boolean isChecked, int[] viewCoordinates) {
|
||||
if (resId == R.string.context_menu_item_add_waypoint) {
|
||||
mapActivity.getContextMenu().addWptPt();
|
||||
} else if (resId == R.string.context_menu_item_edit_waypoint) {
|
||||
|
@ -352,7 +365,8 @@ public class MapActivityActions implements DialogProvider {
|
|||
};
|
||||
|
||||
if (selectedObj instanceof WptPt
|
||||
&& getMyApplication().getSelectedGpxHelper().getSelectedGPXFile((WptPt) selectedObj) != null) {
|
||||
&& getMyApplication().getSelectedGpxHelper().getSelectedGPXFile((WptPt) selectedObj)
|
||||
!= null) {
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.context_menu_item_edit_waypoint, mapActivity)
|
||||
.setId(MAP_CONTEXT_MENU_EDIT_GPX_WP)
|
||||
|
@ -363,8 +377,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
|| (OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) != null)) {
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.context_menu_item_add_waypoint, mapActivity)
|
||||
.setTitle(MAP_CONTEXT_MENU_ADD_GPX_WAYPOINT)
|
||||
.setId(POINT_ADD_GPX_WAYPOINT)
|
||||
.setId(MAP_CONTEXT_MENU_ADD_GPX_WAYPOINT)
|
||||
.setIcon(R.drawable.ic_action_gnew_label_dark)
|
||||
.setOrder(ADD_GPX_WAYPOINT_ITEM_ORDER)
|
||||
.setListener(listener).createItem());
|
||||
|
@ -383,31 +396,38 @@ public class MapActivityActions implements DialogProvider {
|
|||
adapter.createListAdapter(mapActivity, getMyApplication().getSettings().isLightContent());
|
||||
|
||||
AdditionalActionsBottomSheetDialogFragment actionsBottomSheetDialogFragment = new AdditionalActionsBottomSheetDialogFragment();
|
||||
actionsBottomSheetDialogFragment.setAdapter(adapter, new AdditionalActionsBottomSheetDialogFragment.ContextMenuItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(int position) {
|
||||
ContextMenuItem item = adapter.getItem(position);
|
||||
int standardId = item.getTitleId();
|
||||
ItemClickListener click = item.getItemClickListener();
|
||||
if (click != null) {
|
||||
click.onContextMenuClick(listAdapter, standardId, position, false, null);
|
||||
} else if (standardId == R.string.context_menu_item_search) {
|
||||
mapActivity.showQuickSearch(latitude, longitude);
|
||||
} else if (standardId == R.string.context_menu_item_directions_from) {
|
||||
if (OsmAndLocationProvider.isLocationPermissionAvailable(mapActivity)) {
|
||||
enterDirectionsFromPoint(latitude, longitude);
|
||||
} else if (!ActivityCompat.shouldShowRequestPermissionRationale(mapActivity, Manifest.permission.ACCESS_FINE_LOCATION)) {
|
||||
mapActivity.getMyApplication().showToastMessage(R.string.ask_for_location_permission);
|
||||
} else {
|
||||
ActivityCompat.requestPermissions(mapActivity, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_LOCATION_FOR_DIRECTIONS_NAVIGATION_PERMISSION);
|
||||
actionsBottomSheetDialogFragment.setAdapter(adapter,
|
||||
new AdditionalActionsBottomSheetDialogFragment.ContextMenuItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(int position) {
|
||||
ContextMenuItem item = adapter.getItem(position);
|
||||
int standardId = item.getTitleId();
|
||||
ItemClickListener click = item.getItemClickListener();
|
||||
if (click != null) {
|
||||
click.onContextMenuClick(listAdapter, standardId, position, false, null);
|
||||
} else if (standardId == R.string.context_menu_item_search) {
|
||||
mapActivity.showQuickSearch(latitude, longitude);
|
||||
} else if (standardId == R.string.context_menu_item_directions_from) {
|
||||
if (OsmAndLocationProvider.isLocationPermissionAvailable(mapActivity)) {
|
||||
enterDirectionsFromPoint(latitude, longitude);
|
||||
} else if (!ActivityCompat.shouldShowRequestPermissionRationale(mapActivity,
|
||||
Manifest.permission.ACCESS_FINE_LOCATION)) {
|
||||
mapActivity.getMyApplication()
|
||||
.showToastMessage(R.string.ask_for_location_permission);
|
||||
} else {
|
||||
ActivityCompat.requestPermissions(mapActivity,
|
||||
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
|
||||
REQUEST_LOCATION_FOR_DIRECTIONS_NAVIGATION_PERMISSION);
|
||||
}
|
||||
} else if (standardId == R.string.measurement_tool) {
|
||||
mapActivity.getContextMenu().close();
|
||||
MeasurementToolFragment.showInstance(mapActivity.getSupportFragmentManager(),
|
||||
new LatLon(latitude, longitude));
|
||||
}
|
||||
}
|
||||
} else if (standardId == R.string.measurement_tool) {
|
||||
mapActivity.getContextMenu().close();
|
||||
MeasurementToolFragment.showInstance(mapActivity.getSupportFragmentManager(), new LatLon(latitude, longitude));
|
||||
}
|
||||
}
|
||||
});
|
||||
actionsBottomSheetDialogFragment.show(mapActivity.getSupportFragmentManager(), AdditionalActionsBottomSheetDialogFragment.TAG);
|
||||
});
|
||||
actionsBottomSheetDialogFragment.show(mapActivity.getSupportFragmentManager(),
|
||||
AdditionalActionsBottomSheetDialogFragment.TAG);
|
||||
}
|
||||
|
||||
public void enterDirectionsFromPoint(final double latitude, final double longitude) {
|
||||
|
@ -415,7 +435,8 @@ public class MapActivityActions implements DialogProvider {
|
|||
if (getMyApplication().getTargetPointsHelper().getPointToNavigate() == null) {
|
||||
setFirstMapMarkerAsTarget();
|
||||
}
|
||||
if (!mapActivity.getRoutingHelper().isFollowingMode() && !mapActivity.getRoutingHelper().isRoutePlanningMode()) {
|
||||
if (!mapActivity.getRoutingHelper().isFollowingMode() && !mapActivity.getRoutingHelper()
|
||||
.isRoutePlanningMode()) {
|
||||
enterRoutePlanningMode(new LatLon(latitude, longitude),
|
||||
mapActivity.getContextMenu().getPointDescription());
|
||||
} else {
|
||||
|
@ -429,8 +450,9 @@ public class MapActivityActions implements DialogProvider {
|
|||
mapActivity.getRoutingHelper().setGpxParams(null);
|
||||
settings.FOLLOW_THE_GPX_ROUTE.set(null);
|
||||
} else {
|
||||
GPXRouteParamsBuilder params = new GPXRouteParamsBuilder(result, mapActivity.getMyApplication()
|
||||
.getSettings());
|
||||
GPXRouteParamsBuilder params = new GPXRouteParamsBuilder(result,
|
||||
mapActivity.getMyApplication()
|
||||
.getSettings());
|
||||
if (result.hasRtePt() && !result.hasTrkPt()) {
|
||||
settings.GPX_CALCULATE_RTEPT.set(true);
|
||||
} else {
|
||||
|
@ -446,9 +468,11 @@ public class MapActivityActions implements DialogProvider {
|
|||
Location startLoc = ps.get(0);
|
||||
Location finishLoc = ps.get(ps.size() - 1);
|
||||
TargetPointsHelper tg = mapActivity.getMyApplication().getTargetPointsHelper();
|
||||
tg.navigateToPoint(new LatLon(finishLoc.getLatitude(), finishLoc.getLongitude()), false, -1);
|
||||
tg.navigateToPoint(new LatLon(finishLoc.getLatitude(), finishLoc.getLongitude()), false,
|
||||
-1);
|
||||
if (startLoc != finishLoc) {
|
||||
tg.setStartPoint(new LatLon(startLoc.getLatitude(), startLoc.getLongitude()), false, null);
|
||||
tg.setStartPoint(new LatLon(startLoc.getLatitude(), startLoc.getLongitude()), false,
|
||||
null);
|
||||
} else {
|
||||
tg.clearStartPoint(false);
|
||||
}
|
||||
|
@ -476,16 +500,19 @@ public class MapActivityActions implements DialogProvider {
|
|||
bld.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
enterRoutePlanningModeGivenGpx(gpxFiles.get(0), from, fromName, useIntermediatePointsByDefault, true);
|
||||
enterRoutePlanningModeGivenGpx(gpxFiles.get(0), from, fromName,
|
||||
useIntermediatePointsByDefault, true);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
bld.setTitle(R.string.navigation_over_track);
|
||||
ArrayAdapter<GPXFile> adapter = new ArrayAdapter<GPXFile>(mapActivity, R.layout.drawer_list_item, gpxFiles) {
|
||||
ArrayAdapter<GPXFile> adapter = new ArrayAdapter<GPXFile>(mapActivity,
|
||||
R.layout.drawer_list_item, gpxFiles) {
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
if (convertView == null) {
|
||||
convertView = mapActivity.getLayoutInflater().inflate(R.layout.drawer_list_item, null);
|
||||
convertView = mapActivity.getLayoutInflater()
|
||||
.inflate(R.layout.drawer_list_item, null);
|
||||
}
|
||||
String path = getItem(position).path;
|
||||
String name = path.substring(path.lastIndexOf("/") + 1, path.length());
|
||||
|
@ -498,7 +525,8 @@ public class MapActivityActions implements DialogProvider {
|
|||
bld.setAdapter(adapter, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
enterRoutePlanningModeGivenGpx(gpxFiles.get(i), from, fromName, useIntermediatePointsByDefault, true);
|
||||
enterRoutePlanningModeGivenGpx(gpxFiles.get(i), from, fromName,
|
||||
useIntermediatePointsByDefault, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -506,7 +534,8 @@ public class MapActivityActions implements DialogProvider {
|
|||
bld.setNegativeButton(R.string.shared_string_no, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
enterRoutePlanningModeGivenGpx(null, from, fromName, useIntermediatePointsByDefault, true);
|
||||
enterRoutePlanningModeGivenGpx(null, from, fromName, useIntermediatePointsByDefault,
|
||||
true);
|
||||
}
|
||||
});
|
||||
bld.show();
|
||||
|
@ -515,8 +544,9 @@ public class MapActivityActions implements DialogProvider {
|
|||
}
|
||||
}
|
||||
|
||||
public void enterRoutePlanningModeGivenGpx(GPXFile gpxFile, LatLon from, PointDescription fromName,
|
||||
boolean useIntermediatePointsByDefault, boolean showDialog) {
|
||||
public void enterRoutePlanningModeGivenGpx(GPXFile gpxFile, LatLon from,
|
||||
PointDescription fromName,
|
||||
boolean useIntermediatePointsByDefault, boolean showDialog) {
|
||||
settings.USE_INTERMEDIATE_POINTS_NAVIGATION.set(useIntermediatePointsByDefault);
|
||||
OsmandApplication app = mapActivity.getMyApplication();
|
||||
TargetPointsHelper targets = app.getTargetPointsHelper();
|
||||
|
@ -576,8 +606,10 @@ public class MapActivityActions implements DialogProvider {
|
|||
}
|
||||
|
||||
public ApplicationMode getRouteMode(LatLon from) {
|
||||
MarkersPlanRouteContext planRouteContext = mapActivity.getMyApplication().getMapMarkersHelper().getPlanRouteContext();
|
||||
if (planRouteContext.isNavigationFromMarkers() && planRouteContext.getSnappedMode() != ApplicationMode.DEFAULT) {
|
||||
MarkersPlanRouteContext planRouteContext = mapActivity.getMyApplication().getMapMarkersHelper()
|
||||
.getPlanRouteContext();
|
||||
if (planRouteContext.isNavigationFromMarkers()
|
||||
&& planRouteContext.getSnappedMode() != ApplicationMode.DEFAULT) {
|
||||
planRouteContext.setNavigationFromMarkers(false);
|
||||
return planRouteContext.getSnappedMode();
|
||||
}
|
||||
|
@ -604,37 +636,39 @@ public class MapActivityActions implements DialogProvider {
|
|||
builder.setMessage(R.string.context_menu_item_update_map_confirm);
|
||||
builder.setNegativeButton(R.string.shared_string_cancel, null);
|
||||
final OsmandMapTileView mapView = mapActivity.getMapView();
|
||||
builder.setPositiveButton(R.string.context_menu_item_update_map, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
int zoom = args.getInt(KEY_ZOOM);
|
||||
BaseMapLayer mainLayer = mapView.getMainLayer();
|
||||
if (!(mainLayer instanceof MapTileLayer) || !((MapTileLayer) mainLayer).isVisible()) {
|
||||
Toast.makeText(mapActivity, R.string.maps_could_not_be_downloaded, Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
final ITileSource mapSource = ((MapTileLayer) mainLayer).getMap();
|
||||
if (mapSource == null || !mapSource.couldBeDownloadedFromInternet()) {
|
||||
Toast.makeText(mapActivity, R.string.maps_could_not_be_downloaded, Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
final RotatedTileBox tb = mapView.getCurrentRotatedTileBox();
|
||||
final QuadRect tilesRect = tb.getTileBounds();
|
||||
int left = (int) Math.floor(tilesRect.left);
|
||||
int top = (int) Math.floor(tilesRect.top);
|
||||
int width = (int) (Math.ceil(tilesRect.right) - left);
|
||||
int height = (int) (Math.ceil(tilesRect.bottom) - top);
|
||||
for (int i = 0; i < width; i++) {
|
||||
for (int j = 0; j < height; j++) {
|
||||
((OsmandApplication) mapActivity.getApplication()).getResourceManager().
|
||||
clearTileForMap(null, mapSource, i + left, j + top, zoom);
|
||||
builder.setPositiveButton(R.string.context_menu_item_update_map,
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
int zoom = args.getInt(KEY_ZOOM);
|
||||
BaseMapLayer mainLayer = mapView.getMainLayer();
|
||||
if (!(mainLayer instanceof MapTileLayer) || !((MapTileLayer) mainLayer).isVisible()) {
|
||||
Toast.makeText(mapActivity, R.string.maps_could_not_be_downloaded, Toast.LENGTH_SHORT)
|
||||
.show();
|
||||
return;
|
||||
}
|
||||
final ITileSource mapSource = ((MapTileLayer) mainLayer).getMap();
|
||||
if (mapSource == null || !mapSource.couldBeDownloadedFromInternet()) {
|
||||
Toast.makeText(mapActivity, R.string.maps_could_not_be_downloaded, Toast.LENGTH_SHORT)
|
||||
.show();
|
||||
return;
|
||||
}
|
||||
final RotatedTileBox tb = mapView.getCurrentRotatedTileBox();
|
||||
final QuadRect tilesRect = tb.getTileBounds();
|
||||
int left = (int) Math.floor(tilesRect.left);
|
||||
int top = (int) Math.floor(tilesRect.top);
|
||||
int width = (int) (Math.ceil(tilesRect.right) - left);
|
||||
int height = (int) (Math.ceil(tilesRect.bottom) - top);
|
||||
for (int i = 0; i < width; i++) {
|
||||
for (int j = 0; j < height; j++) {
|
||||
((OsmandApplication) mapActivity.getApplication()).getResourceManager().
|
||||
clearTileForMap(null, mapSource, i + left, j + top, zoom);
|
||||
}
|
||||
}
|
||||
|
||||
mapView.refreshMap();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mapView.refreshMap();
|
||||
}
|
||||
});
|
||||
});
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
|
@ -690,11 +724,13 @@ public class MapActivityActions implements DialogProvider {
|
|||
.setIcon(R.drawable.map_dashboard)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
|
||||
int pos, boolean isChecked, int[] viewCoordinates) {
|
||||
app.logEvent(mapActivity, "drawer_dashboard_open");
|
||||
MapActivity.clearPrevActivityIntent();
|
||||
mapActivity.closeDrawer();
|
||||
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.DASHBOARD, viewCoordinates);
|
||||
mapActivity.getDashboard()
|
||||
.setDashboardVisibility(true, DashboardType.DASHBOARD, viewCoordinates);
|
||||
return true;
|
||||
}
|
||||
}).createItem());
|
||||
|
@ -704,7 +740,8 @@ public class MapActivityActions implements DialogProvider {
|
|||
.setIcon(R.drawable.ic_action_flag_dark)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
|
||||
int pos, boolean isChecked, int[] viewCoordinates) {
|
||||
app.logEvent(mapActivity, "drawer_markers_open");
|
||||
MapActivity.clearPrevActivityIntent();
|
||||
MapMarkersDialogFragment.showInstance(mapActivity);
|
||||
|
@ -712,40 +749,44 @@ public class MapActivityActions implements DialogProvider {
|
|||
}
|
||||
}).createItem());
|
||||
|
||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.shared_string_my_places, mapActivity)
|
||||
.setId(DRAWER_MY_PLACES_ID)
|
||||
.setIcon(R.drawable.ic_action_fav_dark)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
|
||||
app.logEvent(mapActivity, "drawer_myplaces_open");
|
||||
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization()
|
||||
.getFavoritesActivity());
|
||||
newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
mapActivity.startActivity(newIntent);
|
||||
return true;
|
||||
}
|
||||
}).createItem());
|
||||
optionsMenuHelper
|
||||
.addItem(new ItemBuilder().setTitleId(R.string.shared_string_my_places, mapActivity)
|
||||
.setId(DRAWER_MY_PLACES_ID)
|
||||
.setIcon(R.drawable.ic_action_fav_dark)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
|
||||
int pos, boolean isChecked, int[] viewCoordinates) {
|
||||
app.logEvent(mapActivity, "drawer_myplaces_open");
|
||||
Intent newIntent = new Intent(mapActivity,
|
||||
mapActivity.getMyApplication().getAppCustomization()
|
||||
.getFavoritesActivity());
|
||||
newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
mapActivity.startActivity(newIntent);
|
||||
return true;
|
||||
}
|
||||
}).createItem());
|
||||
|
||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.search_button, mapActivity)
|
||||
.setId(DRAWER_SEARCH_ID)
|
||||
.setIcon(R.drawable.ic_action_search_dark)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
|
||||
int pos, boolean isChecked, int[] viewCoordinates) {
|
||||
app.logEvent(mapActivity, "drawer_search_open");
|
||||
mapActivity.showQuickSearch(MapActivity.ShowQuickSearchMode.NEW_IF_EXPIRED, false);
|
||||
return true;
|
||||
}
|
||||
}).createItem());
|
||||
|
||||
|
||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.get_directions, mapActivity)
|
||||
.setId(DRAWER_DIRECTIONS_ID)
|
||||
.setIcon(R.drawable.ic_action_gdirections_dark)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
|
||||
int pos, boolean isChecked, int[] viewCoordinates) {
|
||||
app.logEvent(mapActivity, "drawer_directions_open");
|
||||
MapControlsLayer mapControlsLayer = mapActivity.getMapLayers().getMapControlsLayer();
|
||||
if (mapControlsLayer != null) {
|
||||
|
@ -768,18 +809,21 @@ public class MapActivityActions implements DialogProvider {
|
|||
}).createItem());
|
||||
*/
|
||||
|
||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.configure_map, mapActivity)
|
||||
.setId(DRAWER_CONFIGURE_MAP_ID)
|
||||
.setIcon(R.drawable.ic_action_layers_dark)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
|
||||
app.logEvent(mapActivity, "drawer_config_map_open");
|
||||
MapActivity.clearPrevActivityIntent();
|
||||
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_MAP, viewCoordinates);
|
||||
return false;
|
||||
}
|
||||
}).createItem());
|
||||
optionsMenuHelper
|
||||
.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.configure_map, mapActivity)
|
||||
.setId(DRAWER_CONFIGURE_MAP_ID)
|
||||
.setIcon(R.drawable.ic_action_layers_dark)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
|
||||
int pos, boolean isChecked, int[] viewCoordinates) {
|
||||
app.logEvent(mapActivity, "drawer_config_map_open");
|
||||
MapActivity.clearPrevActivityIntent();
|
||||
mapActivity.getDashboard()
|
||||
.setDashboardVisibility(true, DashboardType.CONFIGURE_MAP, viewCoordinates);
|
||||
return false;
|
||||
}
|
||||
}).createItem());
|
||||
|
||||
String d = getString(R.string.welmode_download_maps);
|
||||
if (app.getDownloadThread().getIndexes().isDownloadedFromInternet) {
|
||||
|
@ -793,10 +837,12 @@ public class MapActivityActions implements DialogProvider {
|
|||
.setTitle(d).setIcon(R.drawable.ic_type_archive)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
|
||||
int pos, boolean isChecked, int[] viewCoordinates) {
|
||||
app.logEvent(mapActivity, "drawer_download_maps_open");
|
||||
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization()
|
||||
.getDownloadActivity());
|
||||
Intent newIntent = new Intent(mapActivity,
|
||||
mapActivity.getMyApplication().getAppCustomization()
|
||||
.getDownloadActivity());
|
||||
newIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
mapActivity.startActivity(newIntent);
|
||||
return true;
|
||||
|
@ -809,7 +855,8 @@ public class MapActivityActions implements DialogProvider {
|
|||
.setIcon(R.drawable.ic_action_osm_live)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
|
||||
int pos, boolean isChecked, int[] viewCoordinates) {
|
||||
app.logEvent(mapActivity, "drawer_osm_live_open");
|
||||
Intent intent = new Intent(mapActivity, OsmLiveActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
|
@ -819,81 +866,94 @@ public class MapActivityActions implements DialogProvider {
|
|||
}).createItem());
|
||||
}
|
||||
|
||||
optionsMenuHelper.addItem(new ItemBuilder().setTitle(getString(R.string.shared_string_travel_guides) + " (Beta)")
|
||||
.setId(DRAWER_TRAVEL_GUIDES_ID)
|
||||
.setIcon(R.drawable.ic_action_travel)
|
||||
.setListener(new ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
|
||||
MapActivity.clearPrevActivityIntent();
|
||||
TravelDbHelper travelDbHelper = getMyApplication().getTravelDbHelper();
|
||||
travelDbHelper.initTravelBooks();
|
||||
if (travelDbHelper.getSelectedTravelBook() == null) {
|
||||
WikivoyageWelcomeDialogFragment.showInstance(mapActivity.getSupportFragmentManager());
|
||||
} else {
|
||||
Intent intent = new Intent(mapActivity, WikivoyageExploreActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
mapActivity.startActivity(intent);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}).createItem());
|
||||
optionsMenuHelper.addItem(
|
||||
new ItemBuilder().setTitle(getString(R.string.shared_string_travel_guides) + " (Beta)")
|
||||
.setId(DRAWER_TRAVEL_GUIDES_ID)
|
||||
.setIcon(R.drawable.ic_action_travel)
|
||||
.setListener(new ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
|
||||
int pos, boolean isChecked, int[] viewCoordinates) {
|
||||
MapActivity.clearPrevActivityIntent();
|
||||
TravelDbHelper travelDbHelper = getMyApplication().getTravelDbHelper();
|
||||
travelDbHelper.initTravelBooks();
|
||||
if (travelDbHelper.getSelectedTravelBook() == null) {
|
||||
WikivoyageWelcomeDialogFragment
|
||||
.showInstance(mapActivity.getSupportFragmentManager());
|
||||
} else {
|
||||
Intent intent = new Intent(mapActivity, WikivoyageExploreActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
mapActivity.startActivity(intent);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}).createItem());
|
||||
|
||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.measurement_tool, mapActivity)
|
||||
.setId(DRAWER_MEASURE_DISTANCE_ID)
|
||||
.setIcon(R.drawable.ic_action_ruler)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int position, boolean isChecked, int[] viewCoordinates) {
|
||||
MeasurementToolFragment.showInstance(mapActivity.getSupportFragmentManager());
|
||||
return true;
|
||||
}
|
||||
}).createItem());
|
||||
optionsMenuHelper.addItem(
|
||||
new ContextMenuItem.ItemBuilder().setTitleId(R.string.measurement_tool, mapActivity)
|
||||
.setId(DRAWER_MEASURE_DISTANCE_ID)
|
||||
.setIcon(R.drawable.ic_action_ruler)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
|
||||
int position, boolean isChecked, int[] viewCoordinates) {
|
||||
MeasurementToolFragment.showInstance(mapActivity.getSupportFragmentManager());
|
||||
return true;
|
||||
}
|
||||
}).createItem());
|
||||
|
||||
app.getAidlApi().registerNavDrawerItems(mapActivity, optionsMenuHelper);
|
||||
|
||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.layer_map_appearance, mapActivity)
|
||||
.setId(DRAWER_CONFIGURE_SCREEN_ID)
|
||||
.setIcon(R.drawable.ic_configure_screen_dark)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
|
||||
app.logEvent(mapActivity, "drawer_config_screen_open");
|
||||
MapActivity.clearPrevActivityIntent();
|
||||
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_SCREEN, viewCoordinates);
|
||||
return false;
|
||||
}
|
||||
}).createItem());
|
||||
optionsMenuHelper
|
||||
.addItem(new ItemBuilder().setTitleId(R.string.layer_map_appearance, mapActivity)
|
||||
.setId(DRAWER_CONFIGURE_SCREEN_ID)
|
||||
.setIcon(R.drawable.ic_configure_screen_dark)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
|
||||
int pos, boolean isChecked, int[] viewCoordinates) {
|
||||
app.logEvent(mapActivity, "drawer_config_screen_open");
|
||||
MapActivity.clearPrevActivityIntent();
|
||||
mapActivity.getDashboard()
|
||||
.setDashboardVisibility(true, DashboardType.CONFIGURE_SCREEN, viewCoordinates);
|
||||
return false;
|
||||
}
|
||||
}).createItem());
|
||||
|
||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.prefs_plugins, mapActivity)
|
||||
.setId(DRAWER_PLUGINS_ID)
|
||||
.setIcon(R.drawable.ic_extension_dark)
|
||||
.setListener(new ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
|
||||
int pos, boolean isChecked, int[] viewCoordinates) {
|
||||
app.logEvent(mapActivity, "drawer_plugins_open");
|
||||
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization()
|
||||
.getPluginsActivity());
|
||||
Intent newIntent = new Intent(mapActivity,
|
||||
mapActivity.getMyApplication().getAppCustomization()
|
||||
.getPluginsActivity());
|
||||
newIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
mapActivity.startActivity(newIntent);
|
||||
return true;
|
||||
}
|
||||
}).createItem());
|
||||
|
||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.shared_string_settings, mapActivity)
|
||||
.setId(DRAWER_SETTINGS_ID)
|
||||
.setIcon(R.drawable.ic_action_settings)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
|
||||
app.logEvent(mapActivity, "drawer_settings_open");
|
||||
final Intent settings = new Intent(mapActivity, getMyApplication().getAppCustomization()
|
||||
.getSettingsActivity());
|
||||
settings.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
mapActivity.startActivity(settings);
|
||||
return true;
|
||||
}
|
||||
}).createItem());
|
||||
optionsMenuHelper
|
||||
.addItem(new ItemBuilder().setTitleId(R.string.shared_string_settings, mapActivity)
|
||||
.setId(DRAWER_SETTINGS_ID)
|
||||
.setIcon(R.drawable.ic_action_settings)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
|
||||
int pos, boolean isChecked, int[] viewCoordinates) {
|
||||
app.logEvent(mapActivity, "drawer_settings_open");
|
||||
final Intent settings = new Intent(mapActivity,
|
||||
getMyApplication().getAppCustomization()
|
||||
.getSettingsActivity());
|
||||
settings.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
mapActivity.startActivity(settings);
|
||||
return true;
|
||||
}
|
||||
}).createItem());
|
||||
|
||||
/*
|
||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.configure_map, mapActivity)
|
||||
|
@ -913,7 +973,8 @@ public class MapActivityActions implements DialogProvider {
|
|||
.setIcon(R.drawable.ic_action_help)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
|
||||
int pos, boolean isChecked, int[] viewCoordinates) {
|
||||
app.logEvent(mapActivity, "drawer_help_open");
|
||||
Intent intent = new Intent(mapActivity, HelpActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
|
@ -958,7 +1019,8 @@ public class MapActivityActions implements DialogProvider {
|
|||
for (ApplicationMode mode : modes) {
|
||||
if (settings.FORCE_PRIVATE_ACCESS_ROUTING_ASKED.getModeValue(mode)) {
|
||||
settings.FORCE_PRIVATE_ACCESS_ROUTING_ASKED.setModeValue(mode, false);
|
||||
settings.getCustomRoutingBooleanProperty(GeneralRouter.ALLOW_PRIVATE, false).setModeValue(mode, false);
|
||||
settings.getCustomRoutingBooleanProperty(GeneralRouter.ALLOW_PRIVATE, false)
|
||||
.setModeValue(mode, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1004,37 +1066,40 @@ public class MapActivityActions implements DialogProvider {
|
|||
}
|
||||
|
||||
public void restoreOrReturnDialog(final String packageName) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(mapActivity);
|
||||
builder.setTitle("Restore OsmAnd");
|
||||
builder.setMessage("Do you want to Restore OsmAnd or get back to the Client App?");
|
||||
builder.setPositiveButton("Restore", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
restoreOsmand();
|
||||
}
|
||||
});
|
||||
builder.setNeutralButton("Return", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
executeHeadersIntent(packageName);
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton("Cancel", null);
|
||||
builder.show();
|
||||
}
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(mapActivity);
|
||||
builder.setTitle("Restore OsmAnd");
|
||||
builder.setMessage("Do you want to Restore OsmAnd or get back to the Client App?");
|
||||
builder.setPositiveButton("Restore", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
restoreOsmand();
|
||||
}
|
||||
});
|
||||
builder.setNeutralButton("Return", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
executeHeadersIntent(packageName);
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton("Cancel", null);
|
||||
builder.show();
|
||||
}
|
||||
|
||||
protected void updateDrawerMenu() {
|
||||
boolean nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
||||
final ListView menuItemsListView = (ListView) mapActivity.findViewById(R.id.menuItems);
|
||||
if (nightMode) {
|
||||
menuItemsListView.setBackgroundColor(ContextCompat.getColor(mapActivity, R.color.bg_color_dark));
|
||||
menuItemsListView
|
||||
.setBackgroundColor(ContextCompat.getColor(mapActivity, R.color.bg_color_dark));
|
||||
} else {
|
||||
menuItemsListView.setBackgroundColor(ContextCompat.getColor(mapActivity, R.color.bg_color_light));
|
||||
menuItemsListView
|
||||
.setBackgroundColor(ContextCompat.getColor(mapActivity, R.color.bg_color_light));
|
||||
}
|
||||
menuItemsListView.removeHeaderView(drawerLogoHeader);
|
||||
menuItemsListView.removeFooterView(drawerOsmAndFooter);
|
||||
Bitmap navDrawerLogo = getMyApplication().getAppCustomization().getNavDrawerLogo();
|
||||
final ArrayList<String> navDrawerLogoParams = getMyApplication().getAppCustomization().getNavDrawerLogoParams();
|
||||
final ArrayList<String> navDrawerLogoParams = getMyApplication().getAppCustomization()
|
||||
.getNavDrawerLogoParams();
|
||||
|
||||
boolean customHeader = false;
|
||||
if (navDrawerLogo != null) {
|
||||
|
@ -1045,8 +1110,9 @@ public class MapActivityActions implements DialogProvider {
|
|||
menuItemsListView.setDivider(null);
|
||||
final ContextMenuAdapter contextMenuAdapter = createMainOptionsMenu();
|
||||
contextMenuAdapter.setDefaultLayoutId(R.layout.simple_list_menu_item);
|
||||
final ArrayAdapter<ContextMenuItem> simpleListAdapter = contextMenuAdapter.createListAdapter(mapActivity,
|
||||
!nightMode);
|
||||
final ArrayAdapter<ContextMenuItem> simpleListAdapter = contextMenuAdapter
|
||||
.createListAdapter(mapActivity,
|
||||
!nightMode);
|
||||
menuItemsListView.setAdapter(simpleListAdapter);
|
||||
menuItemsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
|
@ -1054,18 +1120,22 @@ public class MapActivityActions implements DialogProvider {
|
|||
mapActivity.dismissCardDialog();
|
||||
boolean hasHeader = menuItemsListView.getHeaderViewsCount() > 0;
|
||||
boolean hasFooter = menuItemsListView.getFooterViewsCount() > 0;
|
||||
if (hasHeader && position ==0 || (hasFooter && position== menuItemsListView.getCount() - 1)) {
|
||||
if(navDrawerLogoParams!=null) executeHeadersIntent(navDrawerLogoParams.get(0));
|
||||
else restoreOsmand();
|
||||
if (hasHeader && position == 0 || (hasFooter
|
||||
&& position == menuItemsListView.getCount() - 1)) {
|
||||
if (navDrawerLogoParams != null) {
|
||||
executeHeadersIntent(navDrawerLogoParams.get(0));
|
||||
} else {
|
||||
position -= menuItemsListView.getHeaderViewsCount();
|
||||
ContextMenuItem item = contextMenuAdapter.getItem(position);
|
||||
ContextMenuAdapter.ItemClickListener click = item.getItemClickListener();
|
||||
if (click != null && click.onContextMenuClick(simpleListAdapter, item.getTitleId(),
|
||||
position, false, AndroidUtils.getCenterViewCoordinates(view))) {
|
||||
mapActivity.closeDrawer();
|
||||
}
|
||||
}
|
||||
restoreOsmand();
|
||||
}
|
||||
} else {
|
||||
position -= menuItemsListView.getHeaderViewsCount();
|
||||
ContextMenuItem item = contextMenuAdapter.getItem(position);
|
||||
ContextMenuAdapter.ItemClickListener click = item.getItemClickListener();
|
||||
if (click != null && click.onContextMenuClick(simpleListAdapter, item.getTitleId(),
|
||||
position, false, AndroidUtils.getCenterViewCoordinates(view))) {
|
||||
mapActivity.closeDrawer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -1077,8 +1147,11 @@ public class MapActivityActions implements DialogProvider {
|
|||
if (menuItemsListView.getChildCount() > 0) {
|
||||
int numItemsVisible = menuItemsListView.getLastVisiblePosition() -
|
||||
menuItemsListView.getFirstVisiblePosition();
|
||||
View lastView = menuItemsListView.getChildAt(menuItemsListView.getLastVisiblePosition());
|
||||
boolean overlapped = lastView != null && lastView.getY() + lastView.getHeight() * 2 > menuItemsListView.getHeight();
|
||||
View lastView = menuItemsListView
|
||||
.getChildAt(menuItemsListView.getLastVisiblePosition());
|
||||
boolean overlapped =
|
||||
lastView != null && lastView.getY() + lastView.getHeight() * 2 > menuItemsListView
|
||||
.getHeight();
|
||||
if (simpleListAdapter.getCount() - 1 > numItemsVisible || overlapped) {
|
||||
menuItemsListView.addFooterView(drawerOsmAndFooter);
|
||||
} else {
|
||||
|
@ -1092,10 +1165,12 @@ public class MapActivityActions implements DialogProvider {
|
|||
footerLayout.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if(navDrawerLogoParams!=null)
|
||||
if (navDrawerLogoParams != null) {
|
||||
mapActivity.closeDrawer();
|
||||
new OsmandRestoreOrExitDialog().show(mapActivity.getSupportFragmentManager(), "dialog");
|
||||
//showReturnConfirmationDialog(navDrawerLogoParams.get(0));
|
||||
}
|
||||
new OsmandRestoreOrExitDialog()
|
||||
.show(mapActivity.getSupportFragmentManager(), "dialog");
|
||||
//showReturnConfirmationDialog(navDrawerLogoParams.get(0));
|
||||
|
||||
}
|
||||
});
|
||||
|
@ -1109,16 +1184,18 @@ public class MapActivityActions implements DialogProvider {
|
|||
|
||||
private void executeHeadersIntent(String packageName) {
|
||||
Intent launchIntent = mapActivity.getPackageManager().getLaunchIntentForPackage(packageName);
|
||||
if(launchIntent!=null) mapActivity.startActivity(launchIntent);
|
||||
if (launchIntent != null) {
|
||||
mapActivity.startActivity(launchIntent);
|
||||
}
|
||||
mapActivity.closeDrawer();
|
||||
}
|
||||
|
||||
private void showReturnConfirmationDialog(String packageName) {
|
||||
restoreOrReturnDialog(packageName);
|
||||
mapActivity.closeDrawer();
|
||||
mapActivity.closeDrawer();
|
||||
}
|
||||
|
||||
private void restoreOsmand(){
|
||||
private void restoreOsmand() {
|
||||
getMyApplication().getAppCustomization().restoreOsmand();
|
||||
mapActivity.closeDrawer();
|
||||
}
|
||||
|
@ -1126,10 +1203,12 @@ public class MapActivityActions implements DialogProvider {
|
|||
|
||||
public void setFirstMapMarkerAsTarget() {
|
||||
if (getMyApplication().getMapMarkersHelper().getMapMarkers().size() > 0) {
|
||||
MapMarkersHelper.MapMarker marker = getMyApplication().getMapMarkersHelper().getMapMarkers().get(0);
|
||||
MapMarkersHelper.MapMarker marker = getMyApplication().getMapMarkersHelper().getMapMarkers()
|
||||
.get(0);
|
||||
PointDescription pointDescription = marker.getOriginalPointDescription();
|
||||
if (pointDescription.isLocation()
|
||||
&& pointDescription.getName().equals(PointDescription.getAddressNotFoundStr(mapActivity))) {
|
||||
&& pointDescription.getName()
|
||||
.equals(PointDescription.getAddressNotFoundStr(mapActivity))) {
|
||||
pointDescription = new PointDescription(PointDescription.POINT_TYPE_LOCATION, "");
|
||||
}
|
||||
TargetPointsHelper targets = getMyApplication().getTargetPointsHelper();
|
||||
|
|
|
@ -21,6 +21,7 @@ import android.widget.CompoundButton.OnCheckedChangeListener;
|
|||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import net.osmand.osm.PoiCategory;
|
||||
import net.osmand.osm.PoiType;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
|
@ -68,14 +69,15 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
|||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
boolean isLightTheme = getMyApplication().getSettings().OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME;
|
||||
boolean isLightTheme =
|
||||
getMyApplication().getSettings().OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME;
|
||||
int themeId = isLightTheme ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme;
|
||||
setStyle(STYLE_NO_FRAME, themeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
Bundle savedInstanceState) {
|
||||
final OsmandApplication app = getMyApplication();
|
||||
helper = app.getPoiFilters();
|
||||
if (getArguments() != null) {
|
||||
|
@ -136,9 +138,17 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
dismiss();
|
||||
QuickSearchDialogFragment quickSearchDialogFragment = getQuickSearchDialogFragment();
|
||||
if (quickSearchDialogFragment != null) {
|
||||
quickSearchDialogFragment.showFilter(filterId);
|
||||
if (!editMode) {
|
||||
dismiss();
|
||||
QuickSearchDialogFragment quickSearchDialogFragment = getQuickSearchDialogFragment();
|
||||
if (quickSearchDialogFragment != null) {
|
||||
quickSearchDialogFragment.showFilter(filterId);
|
||||
}
|
||||
} else {
|
||||
QuickSearchPoiFilterFragment quickSearchPoiFilterFragment = getQuickSearchPoiFilterFragment();
|
||||
if(quickSearchPoiFilterFragment!= null) {
|
||||
quickSearchPoiFilterFragment.refreshList();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -177,6 +187,15 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
|||
}
|
||||
}
|
||||
|
||||
private QuickSearchPoiFilterFragment getQuickSearchPoiFilterFragment() {
|
||||
Fragment parent = getParentFragment();
|
||||
if (parent instanceof QuickSearchPoiFilterFragment) {
|
||||
return (QuickSearchPoiFilterFragment) parent;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private int getIconId(PoiCategory category) {
|
||||
OsmandApplication app = getMyApplication();
|
||||
String id = null;
|
||||
|
@ -203,6 +222,7 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
|||
}
|
||||
|
||||
private class CategoryListAdapter extends ArrayAdapter<PoiCategory> {
|
||||
|
||||
private OsmandApplication app;
|
||||
|
||||
CategoryListAdapter(OsmandApplication app, List<PoiCategory> items) {
|
||||
|
@ -213,7 +233,8 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
|||
@NonNull
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
LayoutInflater inflater = (LayoutInflater) app.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
LayoutInflater inflater = (LayoutInflater) app
|
||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
View row = convertView;
|
||||
if (row == null) {
|
||||
row = inflater.inflate(R.layout.list_item_icon24_and_menu, parent, false);
|
||||
|
@ -221,7 +242,8 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
|||
PoiCategory category = getItem(position);
|
||||
if (category != null) {
|
||||
AppCompatImageView iconView = (AppCompatImageView) row.findViewById(R.id.icon);
|
||||
AppCompatImageView secondaryIconView = (AppCompatImageView) row.findViewById(R.id.secondary_icon);
|
||||
AppCompatImageView secondaryIconView = (AppCompatImageView) row
|
||||
.findViewById(R.id.secondary_icon);
|
||||
AppCompatTextView titleView = (AppCompatTextView) row.findViewById(R.id.title);
|
||||
AppCompatTextView descView = (AppCompatTextView) row.findViewById(R.id.description);
|
||||
SwitchCompat check = (SwitchCompat) row.findViewById(R.id.toggle_item);
|
||||
|
@ -239,7 +261,8 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
|||
iconView.setImageDrawable(null);
|
||||
}
|
||||
secondaryIconView.setImageDrawable(
|
||||
ic.getIcon(R.drawable.ic_action_additional_option, app.getSettings().isLightContent() ? R.color.icon_color_light : 0));
|
||||
ic.getIcon(R.drawable.ic_action_additional_option,
|
||||
app.getSettings().isLightContent() ? R.color.icon_color_light : 0));
|
||||
check.setOnCheckedChangeListener(null);
|
||||
check.setChecked(filter.isTypeAccepted(category));
|
||||
String textString = category.getTranslation();
|
||||
|
@ -262,7 +285,8 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
|||
} else {
|
||||
descView.setVisibility(View.GONE);
|
||||
}
|
||||
row.findViewById(R.id.divider).setVisibility(position == getCount() - 1 ? View.GONE : View.VISIBLE);
|
||||
row.findViewById(R.id.divider)
|
||||
.setVisibility(position == getCount() - 1 ? View.GONE : View.VISIBLE);
|
||||
addRowListener(category, check);
|
||||
}
|
||||
return (row);
|
||||
|
@ -291,7 +315,18 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
|||
bottomBarShadow.setVisibility(View.GONE);
|
||||
bottomBar.setVisibility(View.GONE);
|
||||
} else {
|
||||
barTitle.setText(getContext().getString(R.string.selected_categories) + ": " + filter.getAcceptedTypesCount());
|
||||
barTitle.setText(getContext().getString(R.string.selected_categories) + ": " + filter
|
||||
.getAcceptedTypesCount());
|
||||
bottomBarShadow.setVisibility(View.VISIBLE);
|
||||
bottomBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
} else {
|
||||
if (filter.isEmpty()) {
|
||||
bottomBarShadow.setVisibility(View.GONE);
|
||||
bottomBar.setVisibility(View.GONE);
|
||||
} else {
|
||||
barTitle.setText(getContext().getString(R.string.selected_categories) + ": " + filter
|
||||
.getAcceptedTypesCount());
|
||||
bottomBarShadow.setVisibility(View.VISIBLE);
|
||||
bottomBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
@ -306,11 +341,11 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
|||
final LinkedHashMap<String, String> subCategories = new LinkedHashMap<String, String>();
|
||||
Set<String> acceptedCategories = filter.getAcceptedSubtypes(poiCategory);
|
||||
if (acceptedCategories != null) {
|
||||
for(String s : acceptedCategories) {
|
||||
for (String s : acceptedCategories) {
|
||||
subCategories.put(s, Algorithms.capitalizeFirstLetterAndLowercase(s));
|
||||
}
|
||||
}
|
||||
for(PoiType pt : poiCategory.getPoiTypes()) {
|
||||
for (PoiType pt : poiCategory.getPoiTypes()) {
|
||||
subCategories.put(pt.getKeyName(), pt.getTranslation());
|
||||
}
|
||||
|
||||
|
@ -351,43 +386,46 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
|||
builder.setCustomTitle(titleView);
|
||||
|
||||
builder.setCancelable(true);
|
||||
builder.setNegativeButton(getContext().getText(R.string.shared_string_cancel), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
listAdapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton(getContext().getText(R.string.shared_string_apply), new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
LinkedHashSet<String> accepted = new LinkedHashSet<String>();
|
||||
for (int i = 0; i < selected.length; i++) {
|
||||
if(selected[i]){
|
||||
accepted.add(array[i]);
|
||||
builder.setNegativeButton(getContext().getText(R.string.shared_string_cancel),
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
listAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
if (subCategories.size() == accepted.size()) {
|
||||
filter.selectSubTypesToAccept(poiCategory, null);
|
||||
} else if(accepted.size() == 0){
|
||||
filter.setTypeToAccept(poiCategory, false);
|
||||
} else {
|
||||
filter.selectSubTypesToAccept(poiCategory, accepted);
|
||||
}
|
||||
saveFilter();
|
||||
listAdapter.notifyDataSetChanged();
|
||||
listView.setSelectionFromTop(index, top);
|
||||
}
|
||||
});
|
||||
});
|
||||
builder.setPositiveButton(getContext().getText(R.string.shared_string_apply),
|
||||
new DialogInterface.OnClickListener() {
|
||||
|
||||
builder.setMultiChoiceItems(visibleNames, selected, new DialogInterface.OnMultiChoiceClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
LinkedHashSet<String> accepted = new LinkedHashSet<String>();
|
||||
for (int i = 0; i < selected.length; i++) {
|
||||
if (selected[i]) {
|
||||
accepted.add(array[i]);
|
||||
}
|
||||
}
|
||||
if (subCategories.size() == accepted.size()) {
|
||||
filter.selectSubTypesToAccept(poiCategory, null);
|
||||
} else if (accepted.size() == 0) {
|
||||
filter.setTypeToAccept(poiCategory, false);
|
||||
} else {
|
||||
filter.selectSubTypesToAccept(poiCategory, accepted);
|
||||
}
|
||||
saveFilter();
|
||||
listAdapter.notifyDataSetChanged();
|
||||
listView.setSelectionFromTop(index, top);
|
||||
}
|
||||
});
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int item, boolean isChecked) {
|
||||
selected[item] = isChecked;
|
||||
}
|
||||
});
|
||||
builder.setMultiChoiceItems(visibleNames, selected,
|
||||
new DialogInterface.OnMultiChoiceClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int item, boolean isChecked) {
|
||||
selected[item] = isChecked;
|
||||
}
|
||||
});
|
||||
final AlertDialog dialog = builder.show();
|
||||
check.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
@Override
|
||||
|
|
|
@ -12,6 +12,7 @@ import android.support.v7.widget.Toolbar;
|
|||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
@ -405,6 +406,11 @@ public class QuickSearchPoiFilterFragment extends DialogFragment {
|
|||
}
|
||||
}
|
||||
|
||||
public void refreshList() {
|
||||
initListItems();
|
||||
updateListView();
|
||||
}
|
||||
|
||||
private void updateListView() {
|
||||
adapter.setListItems(getListItems());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue