Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
73794fb3cf
24 changed files with 423 additions and 138 deletions
|
@ -68,9 +68,6 @@ import net.osmand.plus.helpers.GpxImportHelper;
|
|||
import net.osmand.plus.helpers.WakeLockHelper;
|
||||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||
import net.osmand.plus.mapcontextmenu.MapContextMenuFragment;
|
||||
import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditor;
|
||||
import net.osmand.plus.mapcontextmenu.editors.PointEditor;
|
||||
import net.osmand.plus.mapcontextmenu.other.MapMultiSelectionMenu;
|
||||
import net.osmand.plus.render.RendererRegistry;
|
||||
import net.osmand.plus.resources.ResourceManager;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
|
@ -105,7 +102,6 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents {
|
|||
|
||||
private static MapViewTrackingUtilities mapViewTrackingUtilities;
|
||||
private static MapContextMenu mapContextMenu = new MapContextMenu();
|
||||
private static MapMultiSelectionMenu mapMultiSelectionMenu;
|
||||
|
||||
private BroadcastReceiver screenOffReceiver;
|
||||
|
||||
|
@ -139,7 +135,6 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents {
|
|||
private boolean intentLocation = false;
|
||||
|
||||
private DashboardOnMap dashboardOnMap = new DashboardOnMap(this);
|
||||
private FavoritePointEditor favoritePointEditor;
|
||||
private AppInitializeListener initListener;
|
||||
private IMapDownloaderCallback downloaderCallback;
|
||||
private DrawerLayout drawerLayout;
|
||||
|
@ -172,11 +167,6 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents {
|
|||
app.applyTheme(this);
|
||||
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
|
||||
if (mapMultiSelectionMenu == null) {
|
||||
mapMultiSelectionMenu = new MapMultiSelectionMenu(this);
|
||||
} else {
|
||||
mapMultiSelectionMenu.setMapActivity(this);
|
||||
}
|
||||
mapContextMenu.setMapActivity(this);
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -998,24 +988,6 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents {
|
|||
return mapContextMenu;
|
||||
}
|
||||
|
||||
public MapMultiSelectionMenu getMultiSelectionMenu() {
|
||||
return mapMultiSelectionMenu;
|
||||
}
|
||||
|
||||
public FavoritePointEditor getFavoritePointEditor() {
|
||||
if (favoritePointEditor == null) {
|
||||
favoritePointEditor = new FavoritePointEditor(app, this);
|
||||
}
|
||||
return favoritePointEditor;
|
||||
}
|
||||
|
||||
public PointEditor getPointEditor(String tag) {
|
||||
if (favoritePointEditor != null && favoritePointEditor.getFragmentTag().equals(tag)) {
|
||||
return favoritePointEditor;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void openDrawer() {
|
||||
mapActions.updateDrawerMenu();
|
||||
drawerLayout.openDrawer(Gravity.LEFT);
|
||||
|
|
|
@ -206,7 +206,7 @@ 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(), name);
|
||||
savingTrackHelper.insertPointData(latitude, longitude, System.currentTimeMillis(), null, name, null);
|
||||
AccessibleToast.makeText(mapActivity, MessageFormat.format(getString(R.string.add_waypoint_dialog_added), name), Toast.LENGTH_SHORT)
|
||||
.show();
|
||||
dialog.dismiss();
|
||||
|
|
|
@ -33,7 +33,7 @@ import android.text.format.DateFormat;
|
|||
public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||
|
||||
public final static String DATABASE_NAME = "tracks"; //$NON-NLS-1$
|
||||
public final static int DATABASE_VERSION = 3;
|
||||
public final static int DATABASE_VERSION = 4;
|
||||
|
||||
public final static String TRACK_NAME = "track"; //$NON-NLS-1$
|
||||
public final static String TRACK_COL_DATE = "date"; //$NON-NLS-1$
|
||||
|
@ -47,6 +47,8 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
public final static String POINT_COL_DATE = "date"; //$NON-NLS-1$
|
||||
public final static String POINT_COL_LAT = "lat"; //$NON-NLS-1$
|
||||
public final static String POINT_COL_LON = "lon"; //$NON-NLS-1$
|
||||
public final static String POINT_COL_NAME = "pname"; //$NON-NLS-1$
|
||||
public final static String POINT_COL_CATEGORY = "category"; //$NON-NLS-1$
|
||||
public final static String POINT_COL_DESCRIPTION = "description"; //$NON-NLS-1$
|
||||
|
||||
public final static Log log = PlatformUtil.getLog(SavingTrackHelper.class);
|
||||
|
@ -74,7 +76,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
updateScript = "INSERT INTO " + TRACK_NAME + " (" + TRACK_COL_LAT + ", " + TRACK_COL_LON + ", "
|
||||
+ TRACK_COL_ALTITUDE + ", " + TRACK_COL_SPEED + ", " + TRACK_COL_HDOP + ", " + TRACK_COL_DATE + ")"
|
||||
+ " VALUES (?, ?, ?, ?, ?, ?)"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
updatePointsScript = "INSERT INTO " + POINT_NAME + " VALUES (?, ?, ?, ?)"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
updatePointsScript = "INSERT INTO " + POINT_NAME + " VALUES (?, ?, ?, ?, ?, ?)"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -91,8 +93,8 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
|
||||
private void createTableForPoints(SQLiteDatabase db){
|
||||
try {
|
||||
db.execSQL("CREATE TABLE " + POINT_NAME+ " ("+POINT_COL_LAT +" double, " + POINT_COL_LON+" double, " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
+ POINT_COL_DATE+" long, " + POINT_COL_DESCRIPTION+" text)" ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
db.execSQL("CREATE TABLE " + POINT_NAME + " (" + POINT_COL_LAT + " double, " + POINT_COL_LON + " double, " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
+ POINT_COL_DATE + " long, " + POINT_COL_DESCRIPTION + " text, " + POINT_COL_NAME + " text, " + POINT_COL_CATEGORY + " text" + ")"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
} catch (RuntimeException e) {
|
||||
// ignore if already exists
|
||||
}
|
||||
|
@ -106,6 +108,10 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
if(oldVersion < 3){
|
||||
db.execSQL("ALTER TABLE " + TRACK_NAME + " ADD " + TRACK_COL_HDOP + " double");
|
||||
}
|
||||
if(oldVersion < 4){
|
||||
db.execSQL("ALTER TABLE " + POINT_NAME + " ADD " + POINT_COL_NAME + " text");
|
||||
db.execSQL("ALTER TABLE " + POINT_NAME + " ADD " + POINT_COL_CATEGORY + " text");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -237,7 +243,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
|
||||
private void collectDBPoints(SQLiteDatabase db, Map<String, GPXFile> dataTracks) {
|
||||
Cursor query = db.rawQuery("SELECT " + POINT_COL_LAT + "," + POINT_COL_LON + "," + POINT_COL_DATE + "," //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
+ POINT_COL_DESCRIPTION + " FROM " + POINT_NAME+" ORDER BY " + POINT_COL_DATE +" ASC", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
+ POINT_COL_DESCRIPTION + "," + POINT_COL_NAME + "," + POINT_COL_CATEGORY + " FROM " + POINT_NAME+" ORDER BY " + POINT_COL_DATE +" ASC", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
if (query.moveToFirst()) {
|
||||
do {
|
||||
WptPt pt = new WptPt();
|
||||
|
@ -245,7 +251,10 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
pt.lon = query.getDouble(1);
|
||||
long time = query.getLong(2);
|
||||
pt.time = time;
|
||||
pt.name = query.getString(3);
|
||||
pt.desc = query.getString(3);
|
||||
pt.name = query.getString(4);
|
||||
pt.category = query.getString(5);
|
||||
|
||||
// check if name is extension (needed for audio/video plugin & josm integration)
|
||||
if(pt.name != null && pt.name.length() > 4 && pt.name.charAt(pt.name.length() - 4) == '.') {
|
||||
pt.link = pt.name;
|
||||
|
@ -394,13 +403,15 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
currentTrack.getModifiableGpxFile().modifiedTime = time;
|
||||
}
|
||||
|
||||
public void insertPointData(double lat, double lon, long time, String description) {
|
||||
public void insertPointData(double lat, double lon, long time, String description, String name, String category) {
|
||||
final WptPt pt = new WptPt(lat, lon, time, Double.NaN, 0, Double.NaN);
|
||||
pt.name = description;
|
||||
pt.name = name;
|
||||
pt.category = category;
|
||||
pt.desc = description;
|
||||
currentTrack.getModifiableGpxFile().points.add(pt);
|
||||
currentTrack.getModifiableGpxFile().modifiedTime = time;
|
||||
points++;
|
||||
execWithClose(updatePointsScript, new Object[] { lat, lon, time, description });
|
||||
execWithClose(updatePointsScript, new Object[] { lat, lon, time, description, name, category });
|
||||
}
|
||||
|
||||
private synchronized void execWithClose(String script, Object[] objects) {
|
||||
|
|
|
@ -1168,7 +1168,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
&& OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) != null) {
|
||||
String name = f.getName();
|
||||
SavingTrackHelper savingTrackHelper = app.getSavingTrackHelper();
|
||||
savingTrackHelper.insertPointData(rec.lat, rec.lon, System.currentTimeMillis(), name);
|
||||
savingTrackHelper.insertPointData(rec.lat, rec.lon, System.currentTimeMillis(), null, name, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,11 +7,17 @@ import net.osmand.data.FavouritePoint;
|
|||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.mapcontextmenu.MenuController.MenuType;
|
||||
import net.osmand.plus.mapcontextmenu.MenuController.TitleButtonController;
|
||||
import net.osmand.plus.mapcontextmenu.MenuController.TitleProgressController;
|
||||
import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditor;
|
||||
import net.osmand.plus.mapcontextmenu.editors.PointEditor;
|
||||
import net.osmand.plus.mapcontextmenu.editors.WptPtEditor;
|
||||
import net.osmand.plus.mapcontextmenu.other.MapMultiSelectionMenu;
|
||||
import net.osmand.plus.mapcontextmenu.other.ShareMenu;
|
||||
import net.osmand.plus.views.ContextMenuLayer;
|
||||
import net.osmand.plus.views.OsmandMapLayer;
|
||||
|
@ -22,6 +28,10 @@ import java.lang.ref.WeakReference;
|
|||
public class MapContextMenu extends MenuTitleController {
|
||||
|
||||
private MapActivity mapActivity;
|
||||
private MapMultiSelectionMenu mapMultiSelectionMenu;
|
||||
|
||||
private FavoritePointEditor favoritePointEditor;
|
||||
private WptPtEditor wptPtEditor;
|
||||
|
||||
private boolean active;
|
||||
private LatLon latLon;
|
||||
|
@ -45,6 +55,20 @@ public class MapContextMenu extends MenuTitleController {
|
|||
|
||||
public void setMapActivity(MapActivity mapActivity) {
|
||||
this.mapActivity = mapActivity;
|
||||
|
||||
if (mapMultiSelectionMenu == null) {
|
||||
mapMultiSelectionMenu = new MapMultiSelectionMenu(mapActivity);
|
||||
} else {
|
||||
mapMultiSelectionMenu.setMapActivity(mapActivity);
|
||||
}
|
||||
|
||||
if (favoritePointEditor != null) {
|
||||
favoritePointEditor.setMapActivity(mapActivity);
|
||||
}
|
||||
if (wptPtEditor != null) {
|
||||
wptPtEditor.setMapActivity(mapActivity);
|
||||
}
|
||||
|
||||
if (active) {
|
||||
acquireMenuController();
|
||||
if (menuController != null) {
|
||||
|
@ -55,6 +79,10 @@ public class MapContextMenu extends MenuTitleController {
|
|||
}
|
||||
}
|
||||
|
||||
public MapMultiSelectionMenu getMultiSelectionMenu() {
|
||||
return mapMultiSelectionMenu;
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return active;
|
||||
}
|
||||
|
@ -63,6 +91,29 @@ public class MapContextMenu extends MenuTitleController {
|
|||
return findMenuFragment() != null;
|
||||
}
|
||||
|
||||
public FavoritePointEditor getFavoritePointEditor() {
|
||||
if (favoritePointEditor == null) {
|
||||
favoritePointEditor = new FavoritePointEditor(mapActivity);
|
||||
}
|
||||
return favoritePointEditor;
|
||||
}
|
||||
|
||||
public WptPtEditor getWptPtPointEditor() {
|
||||
if (wptPtEditor == null) {
|
||||
wptPtEditor = new WptPtEditor(mapActivity);
|
||||
}
|
||||
return wptPtEditor;
|
||||
}
|
||||
|
||||
public PointEditor getPointEditor(String tag) {
|
||||
if (favoritePointEditor != null && favoritePointEditor.getFragmentTag().equals(tag)) {
|
||||
return favoritePointEditor;
|
||||
} else if (wptPtEditor != null && wptPtEditor.getFragmentTag().equals(tag)) {
|
||||
return wptPtEditor;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LatLon getLatLon() {
|
||||
return latLon;
|
||||
|
@ -135,12 +186,18 @@ public class MapContextMenu extends MenuTitleController {
|
|||
this.pointDescription = pointDescription;
|
||||
}
|
||||
|
||||
boolean needAcquireMenuController = menuController == null
|
||||
|| !update
|
||||
|| this.object == null && object != null
|
||||
|| this.object != null && object == null
|
||||
|| (this.object != null && object != null && !this.object.getClass().equals(object.getClass()));
|
||||
|
||||
this.latLon = latLon;
|
||||
this.object = object;
|
||||
|
||||
active = true;
|
||||
|
||||
if (menuController == null || !update) {
|
||||
if (needAcquireMenuController) {
|
||||
acquireMenuController();
|
||||
}
|
||||
initTitle();
|
||||
|
@ -302,9 +359,9 @@ public class MapContextMenu extends MenuTitleController {
|
|||
|
||||
public void buttonFavoritePressed() {
|
||||
if (object != null && object instanceof FavouritePoint) {
|
||||
mapActivity.getFavoritePointEditor().edit((FavouritePoint) object);
|
||||
getFavoritePointEditor().edit((FavouritePoint) object);
|
||||
} else {
|
||||
mapActivity.getFavoritePointEditor().add(latLon, getTitleStr());
|
||||
getFavoritePointEditor().add(latLon, getTitleStr());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -327,6 +384,18 @@ public class MapContextMenu extends MenuTitleController {
|
|||
mapActivity.getMapActions().contextMenuPoint(latLon.getLatitude(), latLon.getLongitude(), menuAdapter, object);
|
||||
}
|
||||
|
||||
public void addWptPt() {
|
||||
if (object == null || !(object instanceof WptPt)) {
|
||||
getWptPtPointEditor().add(latLon, getTitleStr());
|
||||
}
|
||||
}
|
||||
|
||||
public void editWptPt() {
|
||||
if (object != null && object instanceof WptPt) {
|
||||
getWptPtPointEditor().edit((WptPt) object);
|
||||
}
|
||||
}
|
||||
|
||||
public void setBaseFragmentVisibility(boolean visible) {
|
||||
WeakReference<MapContextMenuFragment> fragmentRef = findMenuFragment();
|
||||
if (fragmentRef != null) {
|
||||
|
|
|
@ -74,7 +74,7 @@ public class MenuBuilder {
|
|||
|
||||
protected void buildPlainMenuItems(View view) {
|
||||
for (PlainMenuItem item : plainMenuItems) {
|
||||
buildRow(view, item.getIconId(), item.getText(), 0, item.isNeedLinks());
|
||||
buildRow(view, item.getIconId(), item.getText(), 0, item.isNeedLinks(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,11 +90,11 @@ public class MenuBuilder {
|
|||
firstRow = false;
|
||||
}
|
||||
|
||||
protected void buildRow(View view, int iconId, String text, int textColor, boolean needLinks) {
|
||||
buildRow(view, getRowIcon(iconId), text, textColor, needLinks);
|
||||
protected View buildRow(View view, int iconId, String text, int textColor, boolean needLinks, int textLinesLimit) {
|
||||
return buildRow(view, getRowIcon(iconId), text, textColor, needLinks, textLinesLimit);
|
||||
}
|
||||
|
||||
protected void buildRow(final View view, Drawable icon, String text, int textColor, boolean needLinks) {
|
||||
protected View buildRow(final View view, Drawable icon, String text, int textColor, boolean needLinks, int textLinesLimit) {
|
||||
LinearLayout ll = new LinearLayout(view.getContext());
|
||||
ll.setOrientation(LinearLayout.HORIZONTAL);
|
||||
LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
|
@ -132,6 +132,10 @@ public class MenuBuilder {
|
|||
textView.setAutoLinkMask(Linkify.ALL);
|
||||
textView.setLinksClickable(true);
|
||||
}
|
||||
if (textLinesLimit > 0) {
|
||||
textView.setMinLines(1);
|
||||
textView.setMaxLines(textLinesLimit);
|
||||
}
|
||||
textView.setText(text);
|
||||
if (textColor > 0) {
|
||||
textView.setTextColor(view.getResources().getColor(textColor));
|
||||
|
@ -155,6 +159,8 @@ public class MenuBuilder {
|
|||
((LinearLayout) view).addView(horizontalLine);
|
||||
|
||||
rowBuilt();
|
||||
|
||||
return ll;
|
||||
}
|
||||
|
||||
protected void buildButtonRow(final View view, Drawable buttonIcon, String text, OnClickListener onClickListener) {
|
||||
|
|
|
@ -94,21 +94,6 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
if (textColor > 0) {
|
||||
textView.setTextColor(view.getResources().getColor(textColor));
|
||||
}
|
||||
if (isWiki) {
|
||||
textView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
POIMapLayer.showWikipediaDialog(view.getContext(), app, amenity);
|
||||
}
|
||||
});
|
||||
} else if (isText) {
|
||||
textView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
POIMapLayer.showDescriptionDialog(view.getContext(), app, text, textPrefix);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
LinearLayout.LayoutParams llTextViewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
llTextViewParams.setMargins(0, 0, dpToPx(10f), 0);
|
||||
|
@ -127,6 +112,22 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
|
||||
((LinearLayout) view).addView(horizontalLine);
|
||||
|
||||
if (isWiki) {
|
||||
ll.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
POIMapLayer.showWikipediaDialog(view.getContext(), app, amenity);
|
||||
}
|
||||
});
|
||||
} else if (isText) {
|
||||
ll.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
POIMapLayer.showDescriptionDialog(view.getContext(), app, text, textPrefix);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
rowBuilt();
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ public class AudioVideoNoteMenuBuilder extends MenuBuilder {
|
|||
DateFormat dateFormat = android.text.format.DateFormat.getMediumDateFormat(view.getContext());
|
||||
DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(view.getContext());
|
||||
Date date = new Date(recording.getFile().lastModified());
|
||||
buildRow(view, R.drawable.ic_action_data, dateFormat.format(date) + " — " + timeFormat.format(date), 0, false);
|
||||
buildRow(view, R.drawable.ic_action_data, dateFormat.format(date) + " — " + timeFormat.format(date), 0, false, 0);
|
||||
|
||||
buildPlainMenuItems(view);
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ public class FavouritePointMenuBuilder extends MenuBuilder {
|
|||
super.build(view);
|
||||
|
||||
if (!Algorithms.isEmpty(fav.getDescription())) {
|
||||
buildRow(view, R.drawable.ic_action_note_dark, fav.getDescription(), 0, true);
|
||||
buildRow(view, R.drawable.ic_action_note_dark, fav.getDescription(), 0, true, 0);
|
||||
}
|
||||
|
||||
buildPlainMenuItems(view);
|
||||
|
|
|
@ -3,11 +3,16 @@ package net.osmand.plus.mapcontextmenu.builders;
|
|||
import android.view.View;
|
||||
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||
import net.osmand.plus.views.POIMapLayer;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class WptPtMenuBuilder extends MenuBuilder {
|
||||
|
||||
private final WptPt wpt;
|
||||
|
@ -26,8 +31,35 @@ public class WptPtMenuBuilder extends MenuBuilder {
|
|||
public void build(View view) {
|
||||
super.build(view);
|
||||
|
||||
if (wpt.time > 0) {
|
||||
DateFormat dateFormat = android.text.format.DateFormat.getMediumDateFormat(view.getContext());
|
||||
DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(view.getContext());
|
||||
Date date = new Date(wpt.time);
|
||||
buildRow(view, R.drawable.ic_action_data,
|
||||
dateFormat.format(date) + " — " + timeFormat.format(date), 0, false, 0);
|
||||
}
|
||||
if (wpt.speed > 0) {
|
||||
buildRow(view, R.drawable.ic_action_speed,
|
||||
OsmAndFormatter.getFormattedSpeed((float)wpt.speed, app), 0, false, 0);
|
||||
}
|
||||
if (!Double.isNaN(wpt.ele)) {
|
||||
buildRow(view, R.drawable.ic_action_altitude,
|
||||
OsmAndFormatter.getFormattedDistance((float) wpt.ele, app), 0, false, 0);
|
||||
}
|
||||
if (!Double.isNaN(wpt.hdop)) {
|
||||
buildRow(view, R.drawable.ic_action_gps_info,
|
||||
Algorithms.capitalizeFirstLetterAndLowercase(app.getString(R.string.plugin_distance_point_hdop)) + ": "
|
||||
+ OsmAndFormatter.getFormattedDistance((float)wpt.hdop, app), 0, false, 0);
|
||||
}
|
||||
if (!Algorithms.isEmpty(wpt.desc)) {
|
||||
buildRow(view, R.drawable.ic_action_note_dark, wpt.desc, 0, true);
|
||||
final View row = buildRow(view, R.drawable.ic_action_note_dark, wpt.desc, 0, true, 10);
|
||||
row.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
POIMapLayer.showDescriptionDialog(row.getContext(), app, wpt.desc,
|
||||
row.getResources().getString(R.string.description));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
buildPlainMenuItems(view);
|
||||
|
|
|
@ -10,6 +10,7 @@ import net.osmand.plus.activities.MapActivity;
|
|||
import net.osmand.plus.base.FavoriteImageDrawable;
|
||||
import net.osmand.plus.mapcontextmenu.MenuController;
|
||||
import net.osmand.plus.mapcontextmenu.builders.WptPtMenuBuilder;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
public class WptPtMenuController extends MenuController {
|
||||
|
||||
|
@ -44,7 +45,7 @@ public class WptPtMenuController extends MenuController {
|
|||
|
||||
@Override
|
||||
public boolean needTypeStr() {
|
||||
return wpt.category != null;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -54,20 +55,21 @@ public class WptPtMenuController extends MenuController {
|
|||
|
||||
@Override
|
||||
public Drawable getLeftIcon() {
|
||||
return FavoriteImageDrawable.getOrCreate(getMapActivity().getMyApplication(), wpt.getColor(), true);
|
||||
return FavoriteImageDrawable.getOrCreate(getMapActivity().getMyApplication(),
|
||||
wpt.getColor(getMapActivity().getResources().getColor(R.color.gpx_color_point)), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable getSecondLineIcon() {
|
||||
if (wpt.category != null) {
|
||||
return getIcon(R.drawable.ic_small_group);
|
||||
} else {
|
||||
if (Algorithms.isEmpty(getTypeStr())) {
|
||||
return null;
|
||||
} else {
|
||||
return getIcon(R.drawable.ic_small_group);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeStr() {
|
||||
return wpt.category != null ? wpt.category : getMapActivity().getString(R.string.shared_string_none);
|
||||
return wpt.category != null ? wpt.category : "";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ public class EditCategoryDialogFragment extends DialogFragment {
|
|||
name = nameEdit.getText().toString().trim();
|
||||
if (!helper.groupExists(name)) {
|
||||
helper.addEmptyCategory(name, color);
|
||||
PointEditor editor = ((MapActivity) getActivity()).getPointEditor(editorTag);
|
||||
PointEditor editor = ((MapActivity) getActivity()).getContextMenu().getPointEditor(editorTag);
|
||||
if (editor != null) {
|
||||
editor.setCategory(name);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
package net.osmand.plus.mapcontextmenu.editors;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
||||
public class FavoritePointEditor extends PointEditor {
|
||||
|
@ -13,24 +9,9 @@ public class FavoritePointEditor extends PointEditor {
|
|||
private FavouritePoint favorite;
|
||||
|
||||
public static final String TAG = "FavoritePointEditorFragment";
|
||||
private static final String KEY_CTX_EDIT_FAV_OBJECT = "key_ctx_edit_fav_object";
|
||||
|
||||
public FavoritePointEditor(OsmandApplication app, MapActivity mapActivity) {
|
||||
super(app, mapActivity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveState(Bundle bundle) {
|
||||
bundle.putSerializable(KEY_CTX_EDIT_FAV_OBJECT, favorite);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreState(Bundle bundle) {
|
||||
Object object = bundle.getSerializable(KEY_CTX_EDIT_FAV_OBJECT);
|
||||
if (object != null) {
|
||||
favorite = (FavouritePoint)object;
|
||||
}
|
||||
public FavoritePointEditor(MapActivity mapActivity) {
|
||||
super(mapActivity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -61,5 +42,4 @@ public class FavoritePointEditor extends PointEditor {
|
|||
this.favorite = favorite;
|
||||
FavoritePointEditorFragment.showInstance(mapActivity);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ import android.widget.Button;
|
|||
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.FavouritesDbHelper;
|
||||
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
|
@ -38,15 +37,14 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
|
|||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
helper = getMyApplication().getFavorites();
|
||||
editor = getMapActivity().getFavoritePointEditor();
|
||||
editor = getMapActivity().getContextMenu().getFavoritePointEditor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
boolean light = getMyApplication().getSettings().isLightContent();
|
||||
defaultColor = light ? R.color.icon_color : R.color.icon_color_light;
|
||||
defaultColor = getResources().getColor(R.color.color_favorite);
|
||||
|
||||
favorite = editor.getFavorite();
|
||||
group = helper.getGroup(favorite);
|
||||
|
@ -90,8 +88,13 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
|
|||
super.setCategory(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultCategoryName() {
|
||||
return getString(R.string.shared_string_favorites);
|
||||
}
|
||||
|
||||
public static void showInstance(final MapActivity mapActivity) {
|
||||
FavoritePointEditor editor = mapActivity.getFavoritePointEditor();
|
||||
FavoritePointEditor editor = mapActivity.getContextMenu().getFavoritePointEditor();
|
||||
//int slideInAnim = editor.getSlideInAnimation();
|
||||
//int slideOutAnim = editor.getSlideOutAnimation();
|
||||
|
||||
|
@ -152,10 +155,7 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
|
|||
MapContextMenu menu = getMapActivity().getContextMenu();
|
||||
LatLon latLon = new LatLon(favorite.getLatitude(), favorite.getLongitude());
|
||||
if (menu.getLatLon().equals(latLon)) {
|
||||
PointDescription pointDescription = favorite.getPointDescription();
|
||||
pointDescription.setLat(favorite.getLatitude());
|
||||
pointDescription.setLon(favorite.getLongitude());
|
||||
menu.update(latLon, pointDescription, favorite);
|
||||
menu.update(latLon, favorite.getPointDescription(), favorite);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -196,7 +196,7 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
|
|||
|
||||
@Override
|
||||
public String getCategoryInitValue() {
|
||||
return favorite.getCategory().length() == 0 ? getString(R.string.shared_string_favorites) : favorite.getCategory();
|
||||
return favorite.getCategory().length() == 0 ? getDefaultCategoryName() : favorite.getCategory();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -215,10 +215,13 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
|
|||
|
||||
@Override
|
||||
public Drawable getCategoryIcon() {
|
||||
int color = defaultColor;
|
||||
int color = 0;
|
||||
if (group != null) {
|
||||
color = group.color;
|
||||
}
|
||||
if (color == 0) {
|
||||
color = defaultColor;
|
||||
}
|
||||
return getIcon(R.drawable.ic_action_folder_stroke, color);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,25 +7,28 @@ import net.osmand.plus.OsmandApplication;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.widgets.AutoCompleteTextViewEx;
|
||||
|
||||
public abstract class PointEditor {
|
||||
|
||||
protected OsmandApplication app;
|
||||
protected final MapActivity mapActivity;
|
||||
protected MapActivity mapActivity;
|
||||
|
||||
protected boolean isNew;
|
||||
|
||||
private boolean portraitMode;
|
||||
private boolean largeDevice;
|
||||
|
||||
public PointEditor(OsmandApplication app, MapActivity mapActivity) {
|
||||
this.app = app;
|
||||
public PointEditor(MapActivity mapActivity) {
|
||||
this.app = mapActivity.getMyApplication();
|
||||
this.mapActivity = mapActivity;
|
||||
portraitMode = AndroidUiHelper.isOrientationPortrait(mapActivity);
|
||||
largeDevice = AndroidUiHelper.isXLargeDevice(mapActivity);
|
||||
}
|
||||
|
||||
public void setMapActivity(MapActivity mapActivity) {
|
||||
this.mapActivity = mapActivity;
|
||||
}
|
||||
|
||||
public boolean isNew() {
|
||||
return isNew;
|
||||
}
|
||||
|
@ -50,9 +53,6 @@ public abstract class PointEditor {
|
|||
}
|
||||
}
|
||||
|
||||
public abstract void saveState(Bundle bundle);
|
||||
public abstract void restoreState(Bundle bundle);
|
||||
|
||||
public abstract String getFragmentTag();
|
||||
|
||||
public void hide() {
|
||||
|
|
|
@ -45,19 +45,6 @@ public abstract class PointEditorFragment extends Fragment {
|
|||
private View view;
|
||||
private int mainViewHeight;
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
getEditor().saveState(outState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (savedInstanceState != null)
|
||||
getEditor().restoreState(savedInstanceState);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
|
@ -272,12 +259,16 @@ public abstract class PointEditorFragment extends Fragment {
|
|||
|
||||
public void setCategory(String name) {
|
||||
AutoCompleteTextViewEx categoryEdit = (AutoCompleteTextViewEx) view.findViewById(R.id.category_edit);
|
||||
String n = name.length() == 0 ? getString(R.string.shared_string_favorites) : name;
|
||||
String n = name.length() == 0 ? getDefaultCategoryName() : name;
|
||||
categoryEdit.setText(n);
|
||||
ImageView categoryImage = (ImageView) view.findViewById(R.id.category_image);
|
||||
categoryImage.setImageDrawable(getCategoryIcon());
|
||||
}
|
||||
|
||||
protected String getDefaultCategoryName() {
|
||||
return getString(R.string.shared_string_none);
|
||||
}
|
||||
|
||||
protected MapActivity getMapActivity() {
|
||||
return (MapActivity)getActivity();
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ public class SelectCategoryDialogFragment extends DialogFragment {
|
|||
if (category.color != 0) {
|
||||
button.setCompoundDrawablesWithIntrinsicBounds(getIcon(getActivity(), R.drawable.ic_action_folder, category.color), null, null, null);
|
||||
} else {
|
||||
button.setCompoundDrawablesWithIntrinsicBounds(getIcon(getActivity(), R.drawable.ic_action_folder), null, null, null);
|
||||
button.setCompoundDrawablesWithIntrinsicBounds(getIcon(getActivity(), R.drawable.ic_action_folder, getResources().getColor(R.color.color_favorite)), null, null, null);
|
||||
}
|
||||
button.setCompoundDrawablePadding(dpToPx(15f));
|
||||
String name = category.name.length() == 0 ? getString(R.string.shared_string_favorites) : category.name;
|
||||
|
@ -64,7 +64,7 @@ public class SelectCategoryDialogFragment extends DialogFragment {
|
|||
button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
PointEditor editor = ((MapActivity) getActivity()).getPointEditor(editorTag);
|
||||
PointEditor editor = ((MapActivity) getActivity()).getContextMenu().getPointEditor(editorTag);
|
||||
if (editor != null) {
|
||||
editor.setCategory(category.name);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,165 @@
|
|||
package net.osmand.plus.mapcontextmenu.editors;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.SavingTrackHelper;
|
||||
import net.osmand.plus.base.FavoriteImageDrawable;
|
||||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
public class WprPtEditorFragment extends PointEditorFragment {
|
||||
private WptPtEditor editor;
|
||||
private WptPt wpt;
|
||||
private SavingTrackHelper helper;
|
||||
|
||||
private boolean saved;
|
||||
private int defaultColor;
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
helper = getMapActivity().getMyApplication().getSavingTrackHelper();
|
||||
editor = getMapActivity().getContextMenu().getWptPtPointEditor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
boolean light = getMyApplication().getSettings().isLightContent();
|
||||
defaultColor = light ? R.color.icon_color : R.color.icon_color_light;
|
||||
|
||||
wpt = editor.getWptPt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PointEditor getEditor() {
|
||||
return editor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getToolbarTitle() {
|
||||
if (editor.isNew()) {
|
||||
return getMapActivity().getResources().getString(R.string.context_menu_item_add_waypoint);
|
||||
} else {
|
||||
return getMapActivity().getResources().getString(R.string.shared_string_edit);
|
||||
}
|
||||
}
|
||||
|
||||
public static void showInstance(final MapActivity mapActivity) {
|
||||
WptPtEditor editor = mapActivity.getContextMenu().getWptPtPointEditor();
|
||||
//int slideInAnim = editor.getSlideInAnimation();
|
||||
//int slideOutAnim = editor.getSlideOutAnimation();
|
||||
|
||||
WprPtEditorFragment fragment = new WprPtEditorFragment();
|
||||
mapActivity.getSupportFragmentManager().beginTransaction()
|
||||
//.setCustomAnimations(slideInAnim, slideOutAnim, slideInAnim, slideOutAnim)
|
||||
.add(R.id.fragmentContainer, fragment, editor.getFragmentTag())
|
||||
.addToBackStack(null).commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean wasSaved() {
|
||||
return saved;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void save(final boolean needDismiss) {
|
||||
String name = Algorithms.isEmpty(getNameTextValue()) ? null : getNameTextValue();
|
||||
String category = Algorithms.isEmpty(getCategoryTextValue()) ? null : getCategoryTextValue();
|
||||
String description = Algorithms.isEmpty(getDescriptionTextValue()) ? null : getDescriptionTextValue();
|
||||
if (editor.isNew()) {
|
||||
doAddWpt(name, category, description);
|
||||
} else {
|
||||
//todo save wpt
|
||||
}
|
||||
getMapActivity().getMapView().refreshMap(true);
|
||||
if (needDismiss) {
|
||||
dismiss(false);
|
||||
}
|
||||
|
||||
MapContextMenu menu = getMapActivity().getContextMenu();
|
||||
LatLon latLon = new LatLon(wpt.getLatitude(), wpt.getLongitude());
|
||||
if (menu.getLatLon().equals(latLon)) {
|
||||
menu.update(latLon, wpt.getPointDescription(getMapActivity()), wpt);
|
||||
}
|
||||
|
||||
saved = true;
|
||||
}
|
||||
|
||||
private void doAddWpt(String name, String category, String description) {
|
||||
wpt.name = name;
|
||||
wpt.category = category;
|
||||
wpt.desc = description;
|
||||
helper.insertPointData(wpt.getLatitude(), wpt.getLongitude(), System.currentTimeMillis(), description, name, category);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void delete(final boolean needDismiss) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
builder.setMessage(getString(R.string.favourites_remove_dialog_msg, wpt.name));
|
||||
builder.setNegativeButton(R.string.shared_string_no, null);
|
||||
builder.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
//helper.deleteFavourite(wpt); todo delete wpt
|
||||
if (needDismiss) {
|
||||
dismiss(true);
|
||||
}
|
||||
getMapActivity().getMapView().refreshMap(true);
|
||||
}
|
||||
});
|
||||
builder.create().show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHeaderCaption() {
|
||||
return getMapActivity().getResources().getString(R.string.gpx_wpt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameInitValue() {
|
||||
return wpt.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCategoryInitValue() {
|
||||
return Algorithms.isEmpty(wpt.category) ? "" : wpt.category;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescriptionInitValue() {
|
||||
return wpt.desc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable getNameIcon() {
|
||||
int color = wpt.getColor(defaultColor);
|
||||
return FavoriteImageDrawable.getOrCreate(getMapActivity(), color, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable getCategoryIcon() {
|
||||
int color = defaultColor;
|
||||
return getIcon(R.drawable.ic_action_folder_stroke, color);
|
||||
}
|
||||
|
||||
public Drawable getIcon(int resId, int color) {
|
||||
OsmandApplication app = getMyApplication();
|
||||
Drawable d = app.getResources().getDrawable(resId).mutate();
|
||||
d.clearColorFilter();
|
||||
d.setColorFilter(color, PorterDuff.Mode.SRC_IN);
|
||||
return d;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package net.osmand.plus.mapcontextmenu.editors;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
||||
public class WptPtEditor extends PointEditor {
|
||||
|
||||
private WptPt wpt;
|
||||
|
||||
public static final String TAG = "WptPtEditorFragment";
|
||||
|
||||
public WptPtEditor(MapActivity mapActivity) {
|
||||
super(mapActivity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
public WptPt getWptPt() {
|
||||
return wpt;
|
||||
}
|
||||
|
||||
public void add(LatLon latLon, String title) {
|
||||
if (latLon == null) {
|
||||
return;
|
||||
}
|
||||
isNew = true;
|
||||
String name;
|
||||
PointDescription pointDescription = mapActivity.getContextMenu().getPointDescription();
|
||||
if (!pointDescription.isWpt() && !mapActivity.getContextMenu().isAddressUnknown()) {
|
||||
name = title;
|
||||
} else {
|
||||
name = "";
|
||||
}
|
||||
wpt = new WptPt(latLon.getLatitude(), latLon.getLongitude(),
|
||||
System.currentTimeMillis(), Double.NaN, 0, Double.NaN);
|
||||
wpt.name = name;
|
||||
WprPtEditorFragment.showInstance(mapActivity);
|
||||
}
|
||||
|
||||
public void edit(WptPt wpt) {
|
||||
if (wpt == null) {
|
||||
return;
|
||||
}
|
||||
isNew = false;
|
||||
this.wpt = wpt;
|
||||
WprPtEditorFragment.showInstance(mapActivity);
|
||||
}
|
||||
}
|
|
@ -41,7 +41,7 @@ public class MapMultiSelectionMenuFragment extends Fragment implements AdapterVi
|
|||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
menu = ((MapActivity) getActivity()).getMultiSelectionMenu();
|
||||
menu = ((MapActivity) getActivity()).getContextMenu().getMultiSelectionMenu();
|
||||
|
||||
view = inflater.inflate(R.layout.menu_obj_selection_fragment, container, false);
|
||||
|
||||
|
@ -72,7 +72,7 @@ public class MapMultiSelectionMenuFragment extends Fragment implements AdapterVi
|
|||
}
|
||||
|
||||
public static void showInstance(final MapActivity mapActivity) {
|
||||
MapMultiSelectionMenu menu = mapActivity.getMultiSelectionMenu();
|
||||
MapMultiSelectionMenu menu = mapActivity.getContextMenu().getMultiSelectionMenu();
|
||||
|
||||
int slideInAnim = menu.getSlideInAnimation();
|
||||
int slideOutAnim = menu.getSlideOutAnimation();
|
||||
|
|
|
@ -132,7 +132,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
|||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int resId, int pos, boolean isChecked) {
|
||||
if (resId == R.string.context_menu_item_add_waypoint) {
|
||||
mapActivity.getMapActions().addWaypoint(latitude, longitude);
|
||||
mapActivity.getContextMenu().addWptPt();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
public ContextMenuLayer(MapActivity activity){
|
||||
this.activity = activity;
|
||||
menu = activity.getContextMenu();
|
||||
multiSelectionMenu = activity.getMultiSelectionMenu();
|
||||
multiSelectionMenu = menu.getMultiSelectionMenu();
|
||||
movementListener = new GestureDetector(activity, new MenuLayerOnGestureListener());
|
||||
}
|
||||
|
||||
|
|
|
@ -411,7 +411,7 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
|
|||
if (view.getContext() instanceof MapActivity) {
|
||||
MapActivity mapActivity = (MapActivity) view.getContext();
|
||||
MapContextMenu menu = mapActivity.getContextMenu();
|
||||
MapMultiSelectionMenu multiMenu = mapActivity.getMultiSelectionMenu();
|
||||
MapMultiSelectionMenu multiMenu = menu.getMultiSelectionMenu();
|
||||
isMenuVisible = menu.isVisible() || multiMenu.isVisible();
|
||||
}
|
||||
if (!isMenuVisible) {
|
||||
|
|
|
@ -305,8 +305,8 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
|
|||
}
|
||||
}
|
||||
|
||||
public static void showDescriptionDialog(Context ctx, OsmandApplication app, String text, String textPrefix) {
|
||||
showText(ctx, app, text, textPrefix);
|
||||
public static void showDescriptionDialog(Context ctx, OsmandApplication app, String text, String title) {
|
||||
showText(ctx, app, text, title);
|
||||
}
|
||||
|
||||
static int getResIdFromAttribute(final Context ctx, final int attr) {
|
||||
|
@ -401,7 +401,7 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
|
|||
dialog.show();
|
||||
}
|
||||
|
||||
private static void showText(final Context ctx, final OsmandApplication app, final String text,String textPrefix) {
|
||||
private static void showText(final Context ctx, final OsmandApplication app, final String text, String title) {
|
||||
final Dialog dialog = new Dialog(ctx,
|
||||
app.getSettings().isLightContent() ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme);
|
||||
|
||||
|
@ -412,7 +412,7 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
|
|||
topBar.setClickable(true);
|
||||
Drawable back = app.getIconsCache().getIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
|
||||
topBar.setNavigationIcon(back);
|
||||
topBar.setTitle(textPrefix);
|
||||
topBar.setTitle(title);
|
||||
topBar.setBackgroundColor(ctx.getResources().getColor(getResIdFromAttribute(ctx, R.attr.pstsTabBackground)));
|
||||
topBar.setTitleTextColor(ctx.getResources().getColor(getResIdFromAttribute(ctx, R.attr.pstsTextColor)));
|
||||
topBar.setNavigationOnClickListener(new View.OnClickListener() {
|
||||
|
|
Loading…
Reference in a new issue