Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
0b19ab16d1
4 changed files with 185 additions and 148 deletions
|
@ -88,7 +88,6 @@ import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class MapActivity extends AccessibleActivity {
|
public class MapActivity extends AccessibleActivity {
|
||||||
|
|
||||||
private static final int SHOW_POSITION_MSG_ID = OsmAndConstants.UI_HANDLER_MAP_VIEW + 1;
|
private static final int SHOW_POSITION_MSG_ID = OsmAndConstants.UI_HANDLER_MAP_VIEW + 1;
|
||||||
private static final int LONG_KEYPRESS_MSG_ID = OsmAndConstants.UI_HANDLER_MAP_VIEW + 2;
|
private static final int LONG_KEYPRESS_MSG_ID = OsmAndConstants.UI_HANDLER_MAP_VIEW + 2;
|
||||||
private static final int LONG_KEYPRESS_DELAY = 500;
|
private static final int LONG_KEYPRESS_DELAY = 500;
|
||||||
|
@ -378,6 +377,10 @@ public class MapActivity extends AccessibleActivity {
|
||||||
if (dashboardOnMap.onBackPressed()) {
|
if (dashboardOnMap.onBackPressed()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (drawerLayout.isDrawerOpen(Gravity.LEFT)) {
|
||||||
|
closeDrawer();
|
||||||
|
return;
|
||||||
|
}
|
||||||
super.onBackPressed();
|
super.onBackPressed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -607,54 +610,6 @@ public class MapActivity extends AccessibleActivity {
|
||||||
showAndHideMapPosition();
|
showAndHideMapPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
||||||
if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER && app.accessibilityEnabled()) {
|
|
||||||
if (!uiHandler.hasMessages(LONG_KEYPRESS_MSG_ID)) {
|
|
||||||
Message msg = Message.obtain(uiHandler, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
app.getLocationProvider().emitNavigationHint();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
msg.what = LONG_KEYPRESS_MSG_ID;
|
|
||||||
uiHandler.sendMessageDelayed(msg, LONG_KEYPRESS_DELAY);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
} else if (keyCode == KeyEvent.KEYCODE_MENU && event.getRepeatCount() == 1) {
|
|
||||||
toggleDrawer();
|
|
||||||
return true;
|
|
||||||
} else if (keyCode == KeyEvent.KEYCODE_SEARCH && event.getRepeatCount() == 1) {
|
|
||||||
Intent newIntent = new Intent(MapActivity.this, getMyApplication().getAppCustomization()
|
|
||||||
.getSearchActivity());
|
|
||||||
// causes wrong position caching: newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
|
||||||
LatLon loc = getMapLocation();
|
|
||||||
newIntent.putExtra(SearchActivity.SEARCH_LAT, loc.getLatitude());
|
|
||||||
newIntent.putExtra(SearchActivity.SEARCH_LON, loc.getLongitude());
|
|
||||||
if (mapViewTrackingUtilities.isMapLinkedToLocation()) {
|
|
||||||
newIntent.putExtra(SearchActivity.SEARCH_NEARBY, true);
|
|
||||||
}
|
|
||||||
startActivity(newIntent);
|
|
||||||
newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
||||||
return true;
|
|
||||||
} else if (!app.getRoutingHelper().isFollowingMode()
|
|
||||||
&& OsmandPlugin.getEnabledPlugin(AccessibilityPlugin.class) != null) {
|
|
||||||
// Find more appropriate plugin for it?
|
|
||||||
if (keyCode == KeyEvent.KEYCODE_VOLUME_UP && event.getRepeatCount() == 0) {
|
|
||||||
if (mapView.isZooming()) {
|
|
||||||
changeZoom(+2);
|
|
||||||
} else {
|
|
||||||
changeZoom(+1);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
} else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN && event.getRepeatCount() == 0) {
|
|
||||||
changeZoom(-1);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return super.onKeyDown(keyCode, event);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMapLocation(double lat, double lon) {
|
public void setMapLocation(double lat, double lon) {
|
||||||
mapView.setLatLon(lat, lon);
|
mapView.setLatLon(lat, lon);
|
||||||
mapViewTrackingUtilities.locationChanged(lat, lon, this);
|
mapViewTrackingUtilities.locationChanged(lat, lon, this);
|
||||||
|
@ -825,6 +780,51 @@ public class MapActivity extends AccessibleActivity {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||||
|
if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER && app.accessibilityEnabled()) {
|
||||||
|
if (!uiHandler.hasMessages(LONG_KEYPRESS_MSG_ID)) {
|
||||||
|
Message msg = Message.obtain(uiHandler, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
app.getLocationProvider().emitNavigationHint();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
msg.what = LONG_KEYPRESS_MSG_ID;
|
||||||
|
uiHandler.sendMessageDelayed(msg, LONG_KEYPRESS_DELAY);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else if (keyCode == KeyEvent.KEYCODE_SEARCH && event.getRepeatCount() == 0) {
|
||||||
|
Intent newIntent = new Intent(MapActivity.this, getMyApplication().getAppCustomization()
|
||||||
|
.getSearchActivity());
|
||||||
|
// causes wrong position caching: newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||||
|
LatLon loc = getMapLocation();
|
||||||
|
newIntent.putExtra(SearchActivity.SEARCH_LAT, loc.getLatitude());
|
||||||
|
newIntent.putExtra(SearchActivity.SEARCH_LON, loc.getLongitude());
|
||||||
|
if (mapViewTrackingUtilities.isMapLinkedToLocation()) {
|
||||||
|
newIntent.putExtra(SearchActivity.SEARCH_NEARBY, true);
|
||||||
|
}
|
||||||
|
startActivity(newIntent);
|
||||||
|
newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
|
return true;
|
||||||
|
} else if (!app.getRoutingHelper().isFollowingMode()
|
||||||
|
&& OsmandPlugin.getEnabledPlugin(AccessibilityPlugin.class) != null) {
|
||||||
|
// Find more appropriate plugin for it?
|
||||||
|
if (keyCode == KeyEvent.KEYCODE_VOLUME_UP && event.getRepeatCount() == 0) {
|
||||||
|
if (mapView.isZooming()) {
|
||||||
|
changeZoom(+2);
|
||||||
|
} else {
|
||||||
|
changeZoom(+1);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN && event.getRepeatCount() == 0) {
|
||||||
|
changeZoom(-1);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.onKeyDown(keyCode, event);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
||||||
if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
|
if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
|
||||||
|
@ -835,6 +835,9 @@ public class MapActivity extends AccessibleActivity {
|
||||||
mapActions.contextMenuPoint(mapView.getLatitude(), mapView.getLongitude());
|
mapActions.contextMenuPoint(mapView.getLatitude(), mapView.getLongitude());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
} else if (keyCode == KeyEvent.KEYCODE_MENU && event.getRepeatCount() == 0) {
|
||||||
|
toggleDrawer();
|
||||||
|
return true;
|
||||||
} else if (settings.ZOOM_BY_TRACKBALL.get()) {
|
} else if (settings.ZOOM_BY_TRACKBALL.get()) {
|
||||||
// Parrot device has only dpad left and right
|
// Parrot device has only dpad left and right
|
||||||
if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) {
|
if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) {
|
||||||
|
|
|
@ -110,7 +110,7 @@ public class NotesFragment extends OsmAndListFragment {
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
items = new ArrayList<Recording>(plugin.getAllRecordings());
|
items = new ArrayList<>(plugin.getAllRecordings());
|
||||||
listAdapter = new NotesAdapter(items);
|
listAdapter = new NotesAdapter(items);
|
||||||
getListView().setAdapter(listAdapter);
|
getListView().setAdapter(listAdapter);
|
||||||
if (!AndroidUiHelper.isOrientationPortrait(getActivity())) {
|
if (!AndroidUiHelper.isOrientationPortrait(getActivity())) {
|
||||||
|
|
|
@ -82,29 +82,21 @@ public class EditPoiFragment extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(Activity activity) {
|
public void onAttach(Activity activity) {
|
||||||
super.onAttach(activity);
|
super.onAttach(activity);
|
||||||
// poiTypes = ((OsmandApplication) activity.getApplication()).getPoiTypes();
|
OsmandSettings settings = getMyApplication().getSettings();
|
||||||
// allTranslatedSubTypes = poiTypes.getAllTranslatedNames();
|
|
||||||
OsmandSettings settings = ((MapActivity) activity).getMyApplication().getSettings();
|
|
||||||
// editPoiData.isLocalEdit = true;
|
|
||||||
OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
|
OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
|
||||||
if (settings.OFFLINE_EDITION.get() || !settings.isInternetConnectionAvailable(true)) {
|
if (settings.OFFLINE_EDITION.get() || !settings.isInternetConnectionAvailable(true)) {
|
||||||
mOpenstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity);
|
mOpenstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity);
|
||||||
// openstreetmapUtilToLoad = mOpenstreetmapUtil;
|
|
||||||
} else if (!settings.isInternetConnectionAvailable(true)) {
|
} else if (!settings.isInternetConnectionAvailable(true)) {
|
||||||
mOpenstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity);
|
mOpenstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity);
|
||||||
// openstreetmapUtilToLoad = new OpenstreetmapRemoteUtil(activity);
|
|
||||||
} else {
|
} else {
|
||||||
isLocalEdit = false;
|
isLocalEdit = false;
|
||||||
mOpenstreetmapUtil = new OpenstreetmapRemoteUtil(activity);
|
mOpenstreetmapUtil = new OpenstreetmapRemoteUtil(activity);
|
||||||
// openstreetmapUtilToLoad = mOpenstreetmapUtil;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
node = (Node) getArguments().getSerializable(KEY_AMENITY_NODE);
|
node = (Node) getArguments().getSerializable(KEY_AMENITY_NODE);
|
||||||
allTranslatedSubTypes = ((OsmandApplication) activity.getApplication()).getPoiTypes()
|
allTranslatedSubTypes = getMyApplication().getPoiTypes()
|
||||||
.getAllTranslatedNames();
|
.getAllTranslatedNames();
|
||||||
// TODO implement normal name
|
|
||||||
editPoiData.amenity = (Amenity) getArguments().getSerializable(KEY_AMENITY);
|
editPoiData.amenity = (Amenity) getArguments().getSerializable(KEY_AMENITY);
|
||||||
// editPoiData.tags = new LinkedHashSet<>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||||
|
@ -194,7 +186,7 @@ public class EditPoiFragment extends Fragment {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
onlineDocumentationButton.setImageDrawable(
|
onlineDocumentationButton.setImageDrawable(
|
||||||
((MapActivity) getActivity()).getMyApplication().getIconsCache()
|
getMyApplication().getIconsCache()
|
||||||
.getPaintedContentIcon(R.drawable.ic_action_help,
|
.getPaintedContentIcon(R.drawable.ic_action_help,
|
||||||
getResources().getColor(R.color.inactive_item_orange)));
|
getResources().getColor(R.color.inactive_item_orange)));
|
||||||
final ImageButton poiTypeButton = (ImageButton) view.findViewById(R.id.poiTypeButton);
|
final ImageButton poiTypeButton = (ImageButton) view.findViewById(R.id.poiTypeButton);
|
||||||
|
@ -455,20 +447,24 @@ public class EditPoiFragment extends Fragment {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private OsmandApplication getMyApplication() {
|
||||||
|
return (OsmandApplication) getActivity().getApplication();
|
||||||
|
}
|
||||||
|
|
||||||
public static void showEditInstance(final Amenity amenity,
|
public static void showEditInstance(final Amenity amenity,
|
||||||
final MapActivity mapActivity) {
|
final AppCompatActivity activity) {
|
||||||
final OsmandSettings settings = mapActivity.getMyApplication().getSettings();
|
final OsmandSettings settings = ((OsmandApplication) activity.getApplication())
|
||||||
|
.getSettings();
|
||||||
final OpenstreetmapUtil openstreetmapUtilToLoad;
|
final OpenstreetmapUtil openstreetmapUtilToLoad;
|
||||||
if (settings.OFFLINE_EDITION.get() || !settings.isInternetConnectionAvailable(true)) {
|
if (settings.OFFLINE_EDITION.get() || !settings.isInternetConnectionAvailable(true)) {
|
||||||
OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
|
OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
|
||||||
openstreetmapUtilToLoad = new OpenstreetmapLocalUtil(plugin, mapActivity);
|
openstreetmapUtilToLoad = new OpenstreetmapLocalUtil(plugin, activity);
|
||||||
} else if (!settings.isInternetConnectionAvailable(true)) {
|
} else if (!settings.isInternetConnectionAvailable(true)) {
|
||||||
openstreetmapUtilToLoad = new OpenstreetmapRemoteUtil(mapActivity);
|
openstreetmapUtilToLoad = new OpenstreetmapRemoteUtil(activity);
|
||||||
} else {
|
} else {
|
||||||
openstreetmapUtilToLoad = new OpenstreetmapRemoteUtil(mapActivity);
|
openstreetmapUtilToLoad = new OpenstreetmapRemoteUtil(activity);
|
||||||
}
|
}
|
||||||
new AsyncTask<Void, Void, Node>() {
|
new AsyncTask<Void, Void, Node>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Node doInBackground(Void... params) {
|
protected Node doInBackground(Void... params) {
|
||||||
return openstreetmapUtilToLoad.loadNode(amenity);
|
return openstreetmapUtilToLoad.loadNode(amenity);
|
||||||
|
@ -478,18 +474,15 @@ public class EditPoiFragment extends Fragment {
|
||||||
if (n != null) {
|
if (n != null) {
|
||||||
EditPoiFragment fragment =
|
EditPoiFragment fragment =
|
||||||
EditPoiFragment.createInstance(n, amenity);
|
EditPoiFragment.createInstance(n, amenity);
|
||||||
mapActivity.getSupportFragmentManager().beginTransaction()
|
activity.getSupportFragmentManager().beginTransaction()
|
||||||
.add(R.id.fragmentContainer, fragment, "EditPoiFragment")
|
.add(R.id.fragmentContainer, fragment, "EditPoiFragment")
|
||||||
.addToBackStack(null).commit();
|
.addToBackStack(null).commit();
|
||||||
} else {
|
} else {
|
||||||
AccessibleToast.makeText(mapActivity,
|
AccessibleToast.makeText(activity,
|
||||||
mapActivity.getString(R.string.poi_error_poi_not_found),
|
activity.getString(R.string.poi_error_poi_not_found),
|
||||||
Toast.LENGTH_SHORT).show();
|
Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
;
|
|
||||||
|
|
||||||
}.execute(new Void[0]);
|
}.execute(new Void[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -536,6 +529,7 @@ public class EditPoiFragment extends Fragment {
|
||||||
public static class ShowDeleteDialogAsyncTask extends AsyncTask<Amenity, Void, Node> {
|
public static class ShowDeleteDialogAsyncTask extends AsyncTask<Amenity, Void, Node> {
|
||||||
private final OpenstreetmapUtil openstreetmapUtil;
|
private final OpenstreetmapUtil openstreetmapUtil;
|
||||||
private final AppCompatActivity activity;
|
private final AppCompatActivity activity;
|
||||||
|
|
||||||
public ShowDeleteDialogAsyncTask(AppCompatActivity activity) {
|
public ShowDeleteDialogAsyncTask(AppCompatActivity activity) {
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
OsmandSettings settings = ((OsmandApplication) activity.getApplication()).getSettings();
|
OsmandSettings settings = ((OsmandApplication) activity.getApplication()).getSettings();
|
||||||
|
@ -551,15 +545,15 @@ public class EditPoiFragment extends Fragment {
|
||||||
|
|
||||||
protected Node doInBackground(Amenity[] params) {
|
protected Node doInBackground(Amenity[] params) {
|
||||||
return openstreetmapUtil.loadNode(params[0]);
|
return openstreetmapUtil.loadNode(params[0]);
|
||||||
};
|
}
|
||||||
|
|
||||||
protected void onPostExecute(Node n) {
|
protected void onPostExecute(Node n) {
|
||||||
if(n == null){
|
if (n == null) {
|
||||||
AccessibleToast.makeText(activity, activity.getResources().getString(R.string.poi_error_poi_not_found), Toast.LENGTH_LONG).show();
|
AccessibleToast.makeText(activity, activity.getResources().getString(R.string.poi_error_poi_not_found), Toast.LENGTH_LONG).show();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
DeletePoiDialogFragment.createInstance(n).show(activity.getSupportFragmentManager(),
|
||||||
|
"DeletePoiDialogFragment");
|
||||||
}
|
}
|
||||||
DeletePoiDialogFragment.createInstance(n).show(activity.getSupportFragmentManager(),
|
}
|
||||||
"DeletePoiDialogFragment");
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -1,12 +1,15 @@
|
||||||
package net.osmand.plus.osmedit;
|
package net.osmand.plus.osmedit;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
|
import android.app.Dialog;
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.v4.app.DialogFragment;
|
||||||
import android.support.v4.view.MenuItemCompat;
|
import android.support.v4.view.MenuItemCompat;
|
||||||
import android.support.v7.view.ActionMode;
|
import android.support.v7.view.ActionMode;
|
||||||
import android.support.v7.widget.PopupMenu;
|
import android.support.v7.widget.PopupMenu;
|
||||||
|
@ -24,29 +27,6 @@ import android.widget.CheckBox;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import net.osmand.access.AccessibleToast;
|
|
||||||
import net.osmand.data.PointDescription;
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
|
||||||
import net.osmand.plus.OsmandPlugin;
|
|
||||||
import net.osmand.plus.OsmandSettings;
|
|
||||||
import net.osmand.plus.ProgressImplementation;
|
|
||||||
import net.osmand.plus.R;
|
|
||||||
import net.osmand.plus.activities.ActionBarProgressActivity;
|
|
||||||
import net.osmand.plus.activities.MapActivity;
|
|
||||||
import net.osmand.plus.activities.OsmAndListFragment;
|
|
||||||
import net.osmand.plus.activities.OsmandActionBarActivity;
|
|
||||||
import net.osmand.plus.dialogs.DirectionsDialogs;
|
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
|
||||||
import net.osmand.plus.myplaces.FavoritesActivity;
|
|
||||||
|
|
||||||
import org.xmlpull.v1.XmlSerializer;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.osmand.access.AccessibleToast;
|
import net.osmand.access.AccessibleToast;
|
||||||
import net.osmand.data.PointDescription;
|
import net.osmand.data.PointDescription;
|
||||||
|
@ -90,7 +70,6 @@ public class OsmEditsFragment extends OsmAndListFragment {
|
||||||
private final static int MODE_UPLOAD = 101;
|
private final static int MODE_UPLOAD = 101;
|
||||||
|
|
||||||
private ActionMode actionMode;
|
private ActionMode actionMode;
|
||||||
protected OsmPoint[] toUpload = new OsmPoint[0];
|
|
||||||
|
|
||||||
private ArrayList<OsmPoint> osmEditsSelected = new ArrayList<>();
|
private ArrayList<OsmPoint> osmEditsSelected = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -280,7 +259,8 @@ public class OsmEditsFragment extends OsmAndListFragment {
|
||||||
|
|
||||||
private void updateSelectionTitle(ActionMode m) {
|
private void updateSelectionTitle(ActionMode m) {
|
||||||
if (osmEditsSelected.size() > 0) {
|
if (osmEditsSelected.size() > 0) {
|
||||||
m.setTitle(osmEditsSelected.size() + " " + getMyApplication().getString(R.string.shared_string_selected_lowercase));
|
m.setTitle(osmEditsSelected.size() + " "
|
||||||
|
+ getMyApplication().getString(R.string.shared_string_selected_lowercase));
|
||||||
} else {
|
} else {
|
||||||
m.setTitle("");
|
m.setTitle("");
|
||||||
}
|
}
|
||||||
|
@ -316,28 +296,8 @@ public class OsmEditsFragment extends OsmAndListFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteItems(final ArrayList<OsmPoint> points) {
|
private void deleteItems(final ArrayList<OsmPoint> points) {
|
||||||
AlertDialog.Builder b = new AlertDialog.Builder(getActivity());
|
DeleteOsmEditsConfirmDialogFragment.createInstance(points).
|
||||||
b.setMessage(getString(R.string.local_osm_changes_delete_all_confirm, points.size()));
|
show(getChildFragmentManager(), DeleteOsmEditsConfirmDialogFragment.TAG);
|
||||||
b.setPositiveButton(R.string.shared_string_delete, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
Iterator<OsmPoint> it = points.iterator();
|
|
||||||
while (it.hasNext()) {
|
|
||||||
OsmPoint omsPoint = it.next();
|
|
||||||
if (omsPoint.getGroup() == OsmPoint.Group.POI) {
|
|
||||||
plugin.getDBPOI().deletePOI((OpenstreetmapPoint) omsPoint);
|
|
||||||
} else if (omsPoint.getGroup() == OsmPoint.Group.BUG) {
|
|
||||||
plugin.getDBBug().deleteAllBugModifications((OsmNotesPoint) omsPoint);
|
|
||||||
}
|
|
||||||
it.remove();
|
|
||||||
listAdapter.delete(omsPoint);
|
|
||||||
}
|
|
||||||
listAdapter.notifyDataSetChanged();
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
b.setNegativeButton(R.string.shared_string_cancel, null);
|
|
||||||
b.show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -402,7 +362,7 @@ public class OsmEditsFragment extends OsmAndListFragment {
|
||||||
dataPoints = dp;
|
dataPoints = dp;
|
||||||
setNotifyOnChange(false);
|
setNotifyOnChange(false);
|
||||||
clear();
|
clear();
|
||||||
for(OsmPoint pnt : dp) {
|
for (OsmPoint pnt : dp) {
|
||||||
add(pnt);
|
add(pnt);
|
||||||
}
|
}
|
||||||
setNotifyOnChange(true);
|
setNotifyOnChange(true);
|
||||||
|
@ -450,7 +410,8 @@ public class OsmEditsFragment extends OsmAndListFragment {
|
||||||
ch.setVisibility(View.GONE);
|
ch.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
((ImageView) options).setImageDrawable(getMyApplication().getIconsCache().getContentIcon(R.drawable.ic_overflow_menu_white));
|
((ImageView) options).setImageDrawable(getMyApplication().getIconsCache()
|
||||||
|
.getContentIcon(R.drawable.ic_overflow_menu_white));
|
||||||
options.setOnClickListener(new View.OnClickListener() {
|
options.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
@ -527,20 +488,11 @@ public class OsmEditsFragment extends OsmAndListFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void uploadItems(final OsmPoint[] items) {
|
private void uploadItems(final OsmPoint[] items) {
|
||||||
AlertDialog.Builder b = new AlertDialog.Builder(getActivity());
|
UploadOsmEditsConfirmDialogFragment.createInstance(items).show(getChildFragmentManager(),
|
||||||
b.setMessage(getString(R.string.local_osm_changes_upload_all_confirm, items.length));
|
UploadOsmEditsConfirmDialogFragment.TAG);
|
||||||
b.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
toUpload = items;
|
|
||||||
showUploadItemsProgressDialog();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
b.setNegativeButton(R.string.shared_string_cancel, null);
|
|
||||||
b.show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showUploadItemsProgressDialog() {
|
private void showUploadItemsProgressDialog(OsmPoint[] toUpload) {
|
||||||
ProgressDialog dialog = ProgressImplementation.createProgressDialog(
|
ProgressDialog dialog = ProgressImplementation.createProgressDialog(
|
||||||
getActivity(),
|
getActivity(),
|
||||||
getString(R.string.uploading),
|
getString(R.string.uploading),
|
||||||
|
@ -668,4 +620,92 @@ public class OsmEditsFragment extends OsmAndListFragment {
|
||||||
new PointDescription(type, name), true, osmPoint); //$NON-NLS-1$
|
new PointDescription(type, name), true, osmPoint); //$NON-NLS-1$
|
||||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void deletePoint(OsmPoint osmPoint) {
|
||||||
|
listAdapter.delete(osmPoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void notifyDataSetChanged() {
|
||||||
|
listAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class DeleteOsmEditsConfirmDialogFragment extends DialogFragment {
|
||||||
|
public static final String TAG = "DeleteOsmEditsConfirmDialogFragment";
|
||||||
|
private static final String POINTS_LIST = "points_list";
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
final OsmEditsFragment parentFragment = (OsmEditsFragment) getParentFragment();
|
||||||
|
final OsmEditingPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmEditingPlugin.class);
|
||||||
|
final ArrayList<OsmPoint> points =
|
||||||
|
(ArrayList<OsmPoint>) getArguments().getSerializable(POINTS_LIST);
|
||||||
|
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
|
builder.setMessage(getString(R.string.local_osm_changes_delete_all_confirm,
|
||||||
|
points.size()));
|
||||||
|
builder.setPositiveButton(R.string.shared_string_delete, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
Iterator<OsmPoint> it = points.iterator();
|
||||||
|
while (it.hasNext()) {
|
||||||
|
OsmPoint osmPoint = it.next();
|
||||||
|
if (osmPoint.getGroup() == OsmPoint.Group.POI) {
|
||||||
|
plugin.getDBPOI().deletePOI((OpenstreetmapPoint) osmPoint);
|
||||||
|
} else if (osmPoint.getGroup() == OsmPoint.Group.BUG) {
|
||||||
|
plugin.getDBBug().deleteAllBugModifications((OsmNotesPoint) osmPoint);
|
||||||
|
}
|
||||||
|
it.remove();
|
||||||
|
parentFragment.deletePoint(osmPoint);
|
||||||
|
}
|
||||||
|
parentFragment.notifyDataSetChanged();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.setNegativeButton(R.string.shared_string_cancel, null);
|
||||||
|
return builder.create();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DeleteOsmEditsConfirmDialogFragment createInstance(
|
||||||
|
ArrayList<OsmPoint> points) {
|
||||||
|
DeleteOsmEditsConfirmDialogFragment fragment = new DeleteOsmEditsConfirmDialogFragment();
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putSerializable(POINTS_LIST, points);
|
||||||
|
fragment.setArguments(args);
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class UploadOsmEditsConfirmDialogFragment extends DialogFragment {
|
||||||
|
public static final String TAG = "UploadOsmEditsConfirmDialogFragment";
|
||||||
|
private static final String POINTS_ARRAY = "points_list";
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
final OsmPoint[] points = (OsmPoint[]) getArguments().getSerializable(POINTS_ARRAY);
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
|
builder.setMessage(
|
||||||
|
getString(R.string.local_osm_changes_upload_all_confirm, points.length));
|
||||||
|
builder.setPositiveButton(R.string.shared_string_yes,
|
||||||
|
new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
((OsmEditsFragment) getParentFragment())
|
||||||
|
.showUploadItemsProgressDialog(points);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.setNegativeButton(R.string.shared_string_cancel, null);
|
||||||
|
return builder.create();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UploadOsmEditsConfirmDialogFragment createInstance(OsmPoint[] points) {
|
||||||
|
UploadOsmEditsConfirmDialogFragment fragment =
|
||||||
|
new UploadOsmEditsConfirmDialogFragment();
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putSerializable(POINTS_ARRAY, points);
|
||||||
|
fragment.setArguments(args);
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue