From afa9542a70dd2071eed85ecfd0d49997bd962c28 Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Thu, 5 Nov 2015 12:39:36 +0300 Subject: [PATCH] Context menu fixes (PointDescription) --- .../res/layout/map_context_menu_fragment.xml | 85 ++++++++++++++-- OsmAnd/res/values/strings.xml | 3 + .../audionotes/AudioVideoNotesPlugin.java | 9 +- .../plus/helpers/WaypointDialogHelper.java | 11 ++- .../plus/mapcontextmenu/MapContextMenu.java | 9 ++ .../MapContextMenuFragment.java | 87 +++++++++++++--- .../plus/mapcontextmenu/MenuController.java | 99 ++++++++++++------- .../mapcontextmenu/MenuTitleController.java | 1 + .../controllers/AmenityMenuController.java | 6 +- .../AudioVideoNoteMenuController.java | 23 +---- .../controllers/EditPOIMenuController.java | 8 +- .../FavouritePointMenuController.java | 7 +- .../controllers/HistoryMenuController.java | 7 +- .../controllers/MapDataMenuController.java | 29 +++++- .../controllers/MyLocationMenuController.java | 9 +- .../controllers/OsMoMenuController.java | 7 +- .../ParkingPositionMenuController.java | 6 +- .../PointDescriptionMenuController.java | 15 ++- .../TargetPointMenuController.java | 24 ++--- .../controllers/WptPtMenuController.java | 24 ++--- .../osmand/plus/osmo/OsMoPositionLayer.java | 12 ++- .../parkingpoint/ParkingPositionLayer.java | 2 +- .../parkingpoint/ParkingPositionPlugin.java | 2 +- 23 files changed, 330 insertions(+), 155 deletions(-) diff --git a/OsmAnd/res/layout/map_context_menu_fragment.xml b/OsmAnd/res/layout/map_context_menu_fragment.xml index f8246c4867..9e309300ff 100644 --- a/OsmAnd/res/layout/map_context_menu_fragment.xml +++ b/OsmAnd/res/layout/map_context_menu_fragment.xml @@ -4,7 +4,8 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="@android:color/transparent"> + android:background="@android:color/transparent" + xmlns:tools="http://schemas.android.com/tools"> @@ -131,11 +132,11 @@ @@ -155,6 +156,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + Photo %1$s + Audio %1$s + Video %1$s Upload Created OSM POI Created OSM bug diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java index b66f7c2cf4..1ceacbfb09 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java @@ -226,11 +226,14 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { if (desc != null) { return desc; } else if (this.isAudio()) { - return ctx.getResources().getString(R.string.shared_string_audio); + String time = AndroidUtils.formatDateTime(ctx, file.lastModified()); + return ctx.getString(R.string.rec_audio_description, time).trim(); } else if (this.isVideo()) { - return ctx.getResources().getString(R.string.shared_string_video); + String time = AndroidUtils.formatDateTime(ctx, file.lastModified()); + return ctx.getString(R.string.rec_video_description, time).trim(); } else if (this.isPhoto()) { - return ctx.getResources().getString(R.string.shared_string_photo); + String time = AndroidUtils.formatDateTime(ctx, file.lastModified()); + return ctx.getString(R.string.rec_photo_description, time).trim(); } return ""; } diff --git a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java index 6fabba0e23..398146e46b 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java @@ -29,6 +29,7 @@ import net.osmand.plus.activities.MapActivity; import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper; import net.osmand.plus.poi.PoiUIFilter; import net.osmand.plus.views.AnimateDraggingMapThread; +import net.osmand.util.Algorithms; import net.osmand.util.MapUtils; import java.util.ArrayList; @@ -89,7 +90,15 @@ public class WaypointDialogHelper { } else { textDist.setText(""); } - String descr = PointDescription.getSimpleName(point, app); + + String descr; + PointDescription pd = point.getPointDescription(app); + if (Algorithms.isEmpty(pd.getName())) { + descr = pd.getTypeName(); + } else { + descr = pd.getName(); + } + if(textShadow != null) { textShadow.setText(descr); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java index 7cdf5b3fc4..3c92b991f4 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java @@ -11,6 +11,7 @@ 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.other.ShareMenu; import net.osmand.plus.views.ContextMenuLayer; import net.osmand.plus.views.OsmandMapLayer; @@ -382,6 +383,14 @@ public class MapContextMenu extends MenuTitleController { } } + public TitleProgressController getTitleProgressController() { + if (menuController != null) { + return menuController.getTitleProgressController(); + } else { + return null; + } + } + public boolean fabVisible() { return menuController == null || menuController.fabVisible(); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index 284533ff75..7c11eda562 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -26,6 +26,7 @@ import android.widget.FrameLayout; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.LinearLayout; +import android.widget.ProgressBar; import android.widget.TextView; import net.osmand.data.LatLon; @@ -36,7 +37,9 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents; import net.osmand.plus.mapcontextmenu.MenuController.TitleButtonController; +import net.osmand.plus.mapcontextmenu.MenuController.TitleProgressController; import net.osmand.plus.views.AnimateDraggingMapThread; import net.osmand.plus.views.OsmandMapTileView; @@ -45,7 +48,7 @@ import static net.osmand.plus.mapcontextmenu.MenuBuilder.SHADOW_HEIGHT_BOTTOM_DP import static net.osmand.plus.mapcontextmenu.MenuBuilder.SHADOW_HEIGHT_TOP_DP; -public class MapContextMenuFragment extends Fragment { +public class MapContextMenuFragment extends Fragment implements DownloadEvents { public static final String TAG = "MapContextMenuFragment"; @@ -61,6 +64,7 @@ public class MapContextMenuFragment extends Fragment { private TitleButtonController leftTitleButtonController; private TitleButtonController rightTitleButtonController; private TitleButtonController topRightTitleButtonController; + private TitleProgressController titleProgressController; private int menuTopViewHeight; private int menuTopShadowHeight; @@ -128,6 +132,7 @@ public class MapContextMenuFragment extends Fragment { leftTitleButtonController = menu.getLeftTitleButtonController(); rightTitleButtonController = menu.getRightTitleButtonController(); topRightTitleButtonController = menu.getTopRightTitleButtonController(); + titleProgressController = menu.getTitleProgressController(); map = getMapActivity().getMapView(); RotatedTileBox box = map.getCurrentRotatedTileBox().copy(); @@ -145,19 +150,24 @@ public class MapContextMenuFragment extends Fragment { origMarkerY = box.getCenterPixelY(); } + IconsCache iconsCache = getMyApplication().getIconsCache(); + boolean light = getMyApplication().getSettings().isLightContent(); + view = inflater.inflate(R.layout.map_context_menu_fragment, container, false); mainView = view.findViewById(R.id.context_menu_main); // Title buttons + boolean showButtonsContainer = (leftTitleButtonController != null || rightTitleButtonController != null) + && (titleProgressController == null || !titleProgressController.visible); final View titleButtonsContainer = view.findViewById(R.id.title_button_container); - titleButtonsContainer.setVisibility( - leftTitleButtonController != null || rightTitleButtonController != null ? View.VISIBLE : View.GONE); + titleButtonsContainer.setVisibility(showButtonsContainer ? View.VISIBLE : View.GONE); // Left title button final Button leftTitleButton = (Button) view.findViewById(R.id.title_button); final TextView titleButtonRightText = (TextView) view.findViewById(R.id.title_button_right_text); if (leftTitleButtonController != null) { - leftTitleButton.setText(leftTitleButtonController.getCaption()); + leftTitleButton.setText(leftTitleButtonController.caption); + leftTitleButton.setVisibility(leftTitleButtonController.visible ? View.VISIBLE : View.INVISIBLE); Drawable leftIcon = leftTitleButtonController.getLeftIcon(); if (leftIcon != null) { @@ -171,8 +181,8 @@ public class MapContextMenuFragment extends Fragment { } }); - if (leftTitleButtonController.isNeedRightText()) { - titleButtonRightText.setText(leftTitleButtonController.getRightTextCaption()); + if (leftTitleButtonController.needRightText) { + titleButtonRightText.setText(leftTitleButtonController.rightTextCaption); } else { titleButtonRightText.setVisibility(View.GONE); } @@ -184,7 +194,8 @@ public class MapContextMenuFragment extends Fragment { // Right title button final Button rightTitleButton = (Button) view.findViewById(R.id.title_button_right); if (rightTitleButtonController != null) { - rightTitleButton.setText(rightTitleButtonController.getCaption()); + rightTitleButton.setText(rightTitleButtonController.caption); + rightTitleButton.setVisibility(rightTitleButtonController.visible ? View.VISIBLE : View.INVISIBLE); Drawable leftIcon = rightTitleButtonController.getLeftIcon(); if (leftIcon != null) { @@ -204,7 +215,8 @@ public class MapContextMenuFragment extends Fragment { // Top Right title button final Button topRightTitleButton = (Button) view.findViewById(R.id.title_button_top_right); if (topRightTitleButtonController != null) { - topRightTitleButton.setText(topRightTitleButtonController.getCaption()); + topRightTitleButton.setText(topRightTitleButtonController.caption); + topRightTitleButton.setVisibility(topRightTitleButtonController.visible ? View.VISIBLE : View.INVISIBLE); Drawable leftIcon = topRightTitleButtonController.getLeftIcon(); if (leftIcon != null) { @@ -221,6 +233,25 @@ public class MapContextMenuFragment extends Fragment { topRightTitleButton.setVisibility(View.GONE); } + // Progress bar + final View titleProgressContainer = view.findViewById(R.id.title_progress_container); + if (titleProgressController != null) { + + updateProgress(); + + final ImageView progressButton = (ImageView) view.findViewById(R.id.progressButton); + progressButton.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_remove_dark, + light ? R.color.icon_color : R.color.dashboard_subheader_text_dark)); + progressButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + titleProgressController.buttonPressed(); + } + }); + } else { + titleProgressContainer.setVisibility(View.GONE); + } + if (menu.isLandscapeLayout()) { mainView.setLayoutParams(new FrameLayout.LayoutParams(dpToPx(menu.getLandscapeWidthDp()), ViewGroup.LayoutParams.MATCH_PARENT)); @@ -387,9 +418,6 @@ public class MapContextMenuFragment extends Fragment { buildHeader(); - IconsCache iconsCache = getMyApplication().getIconsCache(); - boolean light = getMyApplication().getSettings().isLightContent(); - // FAB fabView = (ImageView)view.findViewById(R.id.context_menu_fab_view); if (menu.fabVisible()) { @@ -462,6 +490,27 @@ public class MapContextMenuFragment extends Fragment { menuFullHeightMax = menuTitleHeight + (menuBottomViewHeight > 0 ? menuBottomViewHeight : -dpToPx(SHADOW_HEIGHT_BOTTOM_DP)); } + private void updateProgress() { + final View titleProgressContainer = view.findViewById(R.id.title_progress_container); + titleProgressContainer.setVisibility(titleProgressController.visible ? View.VISIBLE : View.GONE); + + final ProgressBar progressBar = (ProgressBar) view.findViewById(R.id.progressBar); + final TextView progressTitle = (TextView) view.findViewById(R.id.progressTitle); + final TextView progressPercent = (TextView) view.findViewById(R.id.progressPercent); + progressTitle.setText(titleProgressController.caption); + if (titleProgressController.indeterminate) { + progressPercent.setVisibility(View.GONE); + } else { + progressPercent.setVisibility(View.VISIBLE); + progressPercent.setText(titleProgressController.progress + "%"); + } + progressBar.setIndeterminate(titleProgressController.indeterminate); + progressBar.setProgress(titleProgressController.progress); + + final ImageView progressButton = (ImageView) view.findViewById(R.id.progressButton); + progressButton.setVisibility(titleProgressController.buttonVisible ? View.VISIBLE : View.GONE); + } + private void buildHeader() { IconsCache iconsCache = getMyApplication().getIconsCache(); boolean light = getMyApplication().getSettings().isLightContent(); @@ -772,6 +821,22 @@ public class MapContextMenuFragment extends Fragment { .addToBackStack(TAG).commit(); } + //DownloadEvents + @Override + public void newDownloadIndexes() { + + } + + @Override + public void downloadInProgress() { + + } + + @Override + public void downloadHasFinished() { + + } + private MapActivity getMapActivity() { return (MapActivity)getActivity(); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java index 59d5447596..dcf6aa6803 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java @@ -47,43 +47,17 @@ public abstract class MenuController extends BaseMenuController { private MenuBuilder builder; private int currentMenuState; private MenuType menuType = MenuType.STANDARD; + private PointDescription pointDescription; protected TitleButtonController leftTitleButtonController; protected TitleButtonController rightTitleButtonController; protected TitleButtonController topRightTitleButtonController; - public abstract class TitleButtonController { + protected TitleProgressController titleProgressController; - public String caption = ""; - public int leftIconId = 0; - public boolean needRightText = false; - public String rightTextCaption = ""; - - public String getCaption() { - return caption; - } - - public boolean isNeedRightText() { - return needRightText; - } - - public String getRightTextCaption() { - return rightTextCaption; - } - - public Drawable getLeftIcon() { - if (leftIconId != 0) { - return getIcon(leftIconId, getResIdFromAttribute(R.attr.contextMenuButtonColor)); - } else { - return null; - } - } - - public abstract void buttonPressed(); - } - - public MenuController(MenuBuilder builder, MapActivity mapActivity) { + public MenuController(MenuBuilder builder, PointDescription pointDescription, MapActivity mapActivity) { super(mapActivity); + this.pointDescription = pointDescription; this.builder = builder; this.currentMenuState = getInitialMenuState(); } @@ -98,23 +72,23 @@ public abstract class MenuController extends BaseMenuController { MenuController menuController = null; if (object != null) { if (object instanceof Amenity) { - menuController = new AmenityMenuController(app, mapActivity, (Amenity) object); + menuController = new AmenityMenuController(app, mapActivity, pointDescription, (Amenity) object); } else if (object instanceof FavouritePoint) { - menuController = new FavouritePointMenuController(app, mapActivity, (FavouritePoint) object); + menuController = new FavouritePointMenuController(app, mapActivity, pointDescription, (FavouritePoint) object); } else if (object instanceof SearchHistoryHelper.HistoryEntry) { - menuController = new HistoryMenuController(app, mapActivity, (SearchHistoryHelper.HistoryEntry) object); + menuController = new HistoryMenuController(app, mapActivity, pointDescription, (SearchHistoryHelper.HistoryEntry) object); } else if (object instanceof TargetPoint) { - menuController = new TargetPointMenuController(app, mapActivity, (TargetPoint) object); + menuController = new TargetPointMenuController(app, mapActivity, pointDescription, (TargetPoint) object); } else if (object instanceof OsMoDevice) { - menuController = new OsMoMenuController(app, mapActivity, (OsMoDevice) object); + menuController = new OsMoMenuController(app, mapActivity, pointDescription, (OsMoDevice) object); } else if (object instanceof Recording) { - menuController = new AudioVideoNoteMenuController(app, mapActivity, (Recording) object); + menuController = new AudioVideoNoteMenuController(app, mapActivity, pointDescription, (Recording) object); } else if (object instanceof OsmPoint) { menuController = new EditPOIMenuController(app, mapActivity, pointDescription, (OsmPoint) object); } else if (object instanceof WptPt) { - menuController = new WptPtMenuController(app, mapActivity, (WptPt) object); + menuController = new WptPtMenuController(app, mapActivity, pointDescription, (WptPt) object); } else if (object instanceof BinaryMapDataObject) { - menuController = new MapDataMenuController(app, mapActivity, (BinaryMapDataObject) object); + menuController = new MapDataMenuController(app, mapActivity, pointDescription, (BinaryMapDataObject) object); } else if (object instanceof LatLon) { if (pointDescription.isParking()) { menuController = new ParkingPositionMenuController(app, mapActivity, pointDescription); @@ -146,6 +120,10 @@ public abstract class MenuController extends BaseMenuController { } } + public PointDescription getPointDescription() { + return pointDescription; + } + public int getInitialMenuState() { if (isLandscapeLayout()) { return MenuState.FULL_SCREEN; @@ -218,6 +196,10 @@ public abstract class MenuController extends BaseMenuController { return topRightTitleButtonController; } + public TitleProgressController getTitleProgressController() { + return titleProgressController; + } + public boolean fabVisible() { return true; } @@ -257,4 +239,45 @@ public abstract class MenuController extends BaseMenuController { public void share(LatLon latLon, String title) { ShareMenu.show(latLon, title, getMapActivity()); } + + + public abstract class TitleButtonController { + public String caption = ""; + public int leftIconId = 0; + public boolean needRightText = false; + public String rightTextCaption = ""; + public boolean visible = true; + + public Drawable getLeftIcon() { + if (leftIconId != 0) { + return getIcon(leftIconId, getResIdFromAttribute(R.attr.contextMenuButtonColor)); + } else { + return null; + } + } + + public abstract void buttonPressed(); + } + + public abstract class TitleProgressController { + public String caption = ""; + public int progress; + public boolean indeterminate; + public boolean visible; + public boolean buttonVisible; + + public void setIndexesDownloadMode() { + progress = 0; + caption = getMapActivity().getString(R.string.downloading_list_indexes); + indeterminate = true; + buttonVisible = false; + } + + public void setMapDownloadMode() { + indeterminate = false; + buttonVisible = true; + } + + public abstract void buttonPressed(); + } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuTitleController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuTitleController.java index 046c4f02b0..97fc3d1580 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuTitleController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuTitleController.java @@ -151,6 +151,7 @@ public abstract class MenuTitleController { nameStr = streetStr; addressUnknown = false; streetStr = ""; + getPointDescription().setName(nameStr); } getMapActivity().runOnUiThread(new Runnable() { public void run() { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java index be236ecfb7..06e5564701 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java @@ -17,8 +17,8 @@ public class AmenityMenuController extends MenuController { private final Amenity amenity; - public AmenityMenuController(OsmandApplication app, MapActivity mapActivity, final Amenity amenity) { - super(new AmenityMenuBuilder(app, amenity), mapActivity); + public AmenityMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, final Amenity amenity) { + super(new AmenityMenuBuilder(app, amenity), pointDescription, mapActivity); this.amenity = amenity; } @@ -78,6 +78,6 @@ public class AmenityMenuController extends MenuController { @Override public String getNameStr() { - return amenity.getName(getMapActivity().getMyApplication().getSettings().MAP_PREFERRED_LOCALE.get()); + return getPointDescription().getName(); } } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AudioVideoNoteMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AudioVideoNoteMenuController.java index c4b036bba2..1671cd1e15 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AudioVideoNoteMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AudioVideoNoteMenuController.java @@ -7,6 +7,7 @@ import android.net.Uri; import net.osmand.access.AccessibleAlertBuilder; import net.osmand.data.LatLon; +import net.osmand.data.PointDescription; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; @@ -16,23 +17,15 @@ import net.osmand.plus.audionotes.AudioVideoNotesPlugin.Recording; import net.osmand.plus.mapcontextmenu.MenuController; import net.osmand.plus.mapcontextmenu.builders.AudioVideoNoteMenuBuilder; -import java.io.File; -import java.text.DateFormat; -import java.util.Date; - public class AudioVideoNoteMenuController extends MenuController { private Recording recording; - private DateFormat dateFormat; - private DateFormat timeFormat; private AudioVideoNotesPlugin plugin; - public AudioVideoNoteMenuController(OsmandApplication app, MapActivity mapActivity, final Recording recording) { - super(new AudioVideoNoteMenuBuilder(app, recording), mapActivity); + public AudioVideoNoteMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, final Recording recording) { + super(new AudioVideoNoteMenuBuilder(app, recording), pointDescription, mapActivity); this.recording = recording; plugin = OsmandPlugin.getPlugin(AudioVideoNotesPlugin.class); - dateFormat = android.text.format.DateFormat.getMediumDateFormat(mapActivity); - timeFormat = android.text.format.DateFormat.getTimeFormat(mapActivity); leftTitleButtonController = new TitleButtonController() { @Override @@ -94,15 +87,7 @@ public class AudioVideoNoteMenuController extends MenuController { @Override public String getNameStr() { - File file = recording.getFile(); - String recType = recording.getType(getMapActivity()); - String recName = recording.getName(getMapActivity()); - if (file != null && recType.equals(recName)) { - Date date = new Date(recording.getFile().lastModified()); - return dateFormat.format(date) + " " + timeFormat.format(date); - } else { - return recording.getName(getMapActivity()); - } + return getPointDescription().getName(); } @Override diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/EditPOIMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/EditPOIMenuController.java index 144fd1b8ce..819992824f 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/EditPOIMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/EditPOIMenuController.java @@ -30,14 +30,12 @@ import java.util.Map; public class EditPOIMenuController extends MenuController { - private PointDescription pointDescription; private OsmEditingPlugin plugin; private String pointTypeStr; private ProgressDialogPoiUploader poiUploader; - public EditPOIMenuController(OsmandApplication app, final MapActivity mapActivity, final PointDescription pointDescription, final OsmPoint osmPoint) { - super(new EditPOIMenuBuilder(app, osmPoint), mapActivity); - this.pointDescription = pointDescription; + public EditPOIMenuController(OsmandApplication app, final MapActivity mapActivity, PointDescription pointDescription, final OsmPoint osmPoint) { + super(new EditPOIMenuBuilder(app, osmPoint), pointDescription, mapActivity); plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class); poiUploader = new ProgressDialogPoiUploader() { @@ -138,7 +136,7 @@ public class EditPOIMenuController extends MenuController { @Override public String getNameStr() { - return pointDescription.getSimpleName(getMapActivity(), false); + return getPointDescription().getName(); } @Override diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java index 7a9866d665..61a6178074 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java @@ -4,6 +4,7 @@ import android.graphics.drawable.Drawable; import android.support.v4.app.Fragment; import net.osmand.data.FavouritePoint; +import net.osmand.data.PointDescription; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; @@ -17,8 +18,8 @@ public class FavouritePointMenuController extends MenuController { private FavouritePoint fav; - public FavouritePointMenuController(OsmandApplication app, MapActivity mapActivity, final FavouritePoint fav) { - super(new FavouritePointMenuBuilder(app, fav), mapActivity); + public FavouritePointMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, final FavouritePoint fav) { + super(new FavouritePointMenuBuilder(app, fav), pointDescription, mapActivity); this.fav = fav; } @@ -70,6 +71,6 @@ public class FavouritePointMenuController extends MenuController { @Override public String getNameStr() { - return fav.getName(); + return getPointDescription().getName(); } } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/HistoryMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/HistoryMenuController.java index ade5247e0b..0a8167d7c9 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/HistoryMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/HistoryMenuController.java @@ -2,6 +2,7 @@ package net.osmand.plus.mapcontextmenu.controllers; import android.graphics.drawable.Drawable; +import net.osmand.data.PointDescription; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; @@ -14,8 +15,8 @@ public class HistoryMenuController extends MenuController { private HistoryEntry entry; - public HistoryMenuController(OsmandApplication app, MapActivity mapActivity, final HistoryEntry entry) { - super(new MenuBuilder(app), mapActivity); + public HistoryMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, final HistoryEntry entry) { + super(new MenuBuilder(app), pointDescription, mapActivity); this.entry = entry; } @@ -46,7 +47,7 @@ public class HistoryMenuController extends MenuController { @Override public String getNameStr() { - return entry.getName().getSimpleName(getMapActivity(), false); + return getPointDescription().getName(); } @Override diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java index 7103aca0ab..0f58594fbb 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java @@ -12,6 +12,8 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.download.DownloadActivity; +import net.osmand.plus.download.DownloadIndexesThread; +import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents; import net.osmand.plus.mapcontextmenu.MenuBuilder; import net.osmand.plus.mapcontextmenu.MenuController; @@ -19,8 +21,8 @@ public class MapDataMenuController extends MenuController { private WorldRegion region; private String regionName; - public MapDataMenuController(OsmandApplication app, MapActivity mapActivity, final BinaryMapDataObject dataObject) { - super(new MenuBuilder(app), mapActivity); + public MapDataMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, final BinaryMapDataObject dataObject) { + super(new MenuBuilder(app), pointDescription, mapActivity); OsmandRegions osmandRegions = app.getRegions(); String fullName = osmandRegions.getFullName(dataObject); final WorldRegion region = osmandRegions.getRegionData(fullName); @@ -31,6 +33,9 @@ public class MapDataMenuController extends MenuController { regionName = dataObject.getName(); } + boolean hasIndexes = app.getDownloadThread().getIndexes().isDownloadedFromInternet; + boolean isDownloading = false; //todo + leftTitleButtonController = new TitleButtonController() { @Override public void buttonPressed() { @@ -62,8 +67,26 @@ public class MapDataMenuController extends MenuController { // todo other maps } }; - topRightTitleButtonController.caption = getMapActivity().getString(R.string.shared_string_others); + topRightTitleButtonController.caption = getMapActivity().getString(R.string.download_select_map_types); + topRightTitleButtonController.visible = hasIndexes && !isDownloading; + titleProgressController = new TitleProgressController() { + @Override + public void buttonPressed() { + // todo cancel download + } + }; + if (!hasIndexes) { + titleProgressController.setIndexesDownloadMode(); + titleProgressController.visible = true; + getMapActivity().getMyApplication().getDownloadThread().runReloadIndexFiles(); + } else if (isDownloading) { + titleProgressController.setMapDownloadMode(); + titleProgressController.caption = "Downloading..."; // todo + titleProgressController.visible = true; + } else { + titleProgressController.visible = false; + } } @Override diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MyLocationMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MyLocationMenuController.java index 5f808a567a..d904897594 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MyLocationMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MyLocationMenuController.java @@ -11,11 +11,8 @@ import net.osmand.plus.mapcontextmenu.MenuController; public class MyLocationMenuController extends MenuController { - private PointDescription pointDescription; - - public MyLocationMenuController(OsmandApplication app, MapActivity mapActivity, final PointDescription pointDescription) { - super(new MenuBuilder(app), mapActivity); - this.pointDescription = pointDescription; + public MyLocationMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription) { + super(new MenuBuilder(app), pointDescription, mapActivity); } @Override @@ -31,6 +28,6 @@ public class MyLocationMenuController extends MenuController { @Override public String getNameStr() { - return pointDescription.getTypeName(); + return getPointDescription().getName(); } } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/OsMoMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/OsMoMenuController.java index a0e7a2ce68..fee2e7232b 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/OsMoMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/OsMoMenuController.java @@ -3,6 +3,7 @@ package net.osmand.plus.mapcontextmenu.controllers; import android.graphics.drawable.Drawable; import net.osmand.Location; +import net.osmand.data.PointDescription; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; @@ -15,8 +16,8 @@ public class OsMoMenuController extends MenuController { private OsMoDevice device; - public OsMoMenuController(OsmandApplication app, MapActivity mapActivity, final OsMoDevice device) { - super(new MenuBuilder(app), mapActivity); + public OsMoMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, final OsMoDevice device) { + super(new MenuBuilder(app), pointDescription, mapActivity); this.device = device; } @@ -41,7 +42,7 @@ public class OsMoMenuController extends MenuController { @Override public String getNameStr() { - return device.getVisibleName(); + return getPointDescription().getName(); } @Override diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/ParkingPositionMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/ParkingPositionMenuController.java index d901221df1..9f9886a4ae 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/ParkingPositionMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/ParkingPositionMenuController.java @@ -14,13 +14,11 @@ import net.osmand.util.Algorithms; public class ParkingPositionMenuController extends MenuController { - private PointDescription pointDescription; private ParkingPositionPlugin plugin; private String parkingDescription = ""; public ParkingPositionMenuController(OsmandApplication app, MapActivity mapActivity, final PointDescription pointDescription) { - super(new MenuBuilder(app), mapActivity); - this.pointDescription = pointDescription; + super(new MenuBuilder(app), pointDescription, mapActivity); plugin = OsmandPlugin.getPlugin(ParkingPositionPlugin.class); if (plugin != null) { StringBuilder sb = new StringBuilder(); @@ -60,7 +58,7 @@ public class ParkingPositionMenuController extends MenuController { @Override public String getNameStr() { - return pointDescription.getTypeName(); + return getPointDescription().getName(); } @Override diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/PointDescriptionMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/PointDescriptionMenuController.java index 48aff6acf5..773f52532b 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/PointDescriptionMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/PointDescriptionMenuController.java @@ -13,11 +13,8 @@ import net.osmand.util.Algorithms; public class PointDescriptionMenuController extends MenuController { - private PointDescription pointDescription; - public PointDescriptionMenuController(OsmandApplication app, MapActivity mapActivity, final PointDescription pointDescription) { - super(new MenuBuilder(app), mapActivity); - this.pointDescription = pointDescription; + super(new MenuBuilder(app), pointDescription, mapActivity); } @Override @@ -27,7 +24,7 @@ public class PointDescriptionMenuController extends MenuController { @Override public boolean needTypeStr() { - String typeName = pointDescription.getTypeName(); + String typeName = getPointDescription().getTypeName(); return (typeName != null && !Algorithms.isEmpty(typeName)); } @@ -38,7 +35,7 @@ public class PointDescriptionMenuController extends MenuController { @Override public Drawable getLeftIcon() { - return getIcon(SearchHistoryFragment.getItemIcon(pointDescription)); + return getIcon(SearchHistoryFragment.getItemIcon(getPointDescription())); } @Override @@ -52,13 +49,13 @@ public class PointDescriptionMenuController extends MenuController { @Override public String getNameStr() { - return pointDescription.getSimpleName(getMapActivity(), false); + return getPointDescription().getName(); } @Override public String getTypeStr() { if (needTypeStr()) { - return pointDescription.getTypeName(); + return getPointDescription().getTypeName(); } else { return ""; } @@ -66,6 +63,6 @@ public class PointDescriptionMenuController extends MenuController { @Override public boolean needStreetName() { - return !pointDescription.isAddress(); + return !getPointDescription().isAddress(); } } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TargetPointMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TargetPointMenuController.java index ddc0b534d5..a2d44d4db5 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TargetPointMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TargetPointMenuController.java @@ -1,7 +1,9 @@ package net.osmand.plus.mapcontextmenu.controllers; import android.graphics.drawable.Drawable; +import android.util.Log; +import net.osmand.data.PointDescription; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.TargetPointsHelper; @@ -15,8 +17,8 @@ public class TargetPointMenuController extends MenuController { private TargetPoint targetPoint; - public TargetPointMenuController(OsmandApplication app, MapActivity mapActivity, final TargetPoint targetPoint) { - super(new MenuBuilder(app), mapActivity); + public TargetPointMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, final TargetPoint targetPoint) { + super(new MenuBuilder(app), pointDescription, mapActivity); this.targetPoint = targetPoint; leftTitleButtonController = new TitleButtonController() { @Override @@ -41,7 +43,7 @@ public class TargetPointMenuController extends MenuController { @Override public boolean needTypeStr() { - return true; + return !Algorithms.isEmpty(getNameStr()); } @Override @@ -63,14 +65,7 @@ public class TargetPointMenuController extends MenuController { @Override public String getNameStr() { - String name = ""; - if (targetPoint.getOriginalPointDescription() != null) { - name = targetPoint.getOriginalPointDescription().getSimpleName(getMapActivity(), false); - } - if (Algorithms.isEmpty(name)) { - name = getTypeStr(); - } - return name; + return getPointDescription().getName(); } @Override @@ -78,13 +73,8 @@ public class TargetPointMenuController extends MenuController { return targetPoint.getPointDescription(getMapActivity()).getTypeName(); } - @Override - public boolean displayStreetNameinTitle() { - return true; - } - @Override public boolean needStreetName() { - return Algorithms.isEmpty(targetPoint.getOnlyName()); + return !needTypeStr(); } } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java index c454d173e6..979452d794 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java @@ -2,22 +2,21 @@ package net.osmand.plus.mapcontextmenu.controllers; import android.graphics.drawable.Drawable; +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.base.FavoriteImageDrawable; import net.osmand.plus.mapcontextmenu.MenuController; -import net.osmand.plus.mapcontextmenu.builders.FavouritePointMenuBuilder; import net.osmand.plus.mapcontextmenu.builders.WptPtMenuBuilder; -import net.osmand.util.Algorithms; public class WptPtMenuController extends MenuController { private WptPt wpt; - public WptPtMenuController(OsmandApplication app, MapActivity mapActivity, final WptPt wpt) { - super(new WptPtMenuBuilder(app, wpt), mapActivity); + public WptPtMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, final WptPt wpt) { + super(new WptPtMenuBuilder(app, wpt), pointDescription, mapActivity); this.wpt = wpt; } @@ -45,7 +44,7 @@ public class WptPtMenuController extends MenuController { @Override public boolean needTypeStr() { - return true; + return wpt.category != null; } @Override @@ -55,16 +54,13 @@ public class WptPtMenuController extends MenuController { @Override public Drawable getSecondLineIcon() { - return getIcon(R.drawable.ic_small_group); + if (wpt.category != null) { + return getIcon(R.drawable.ic_small_group); + } else { + return null; + } } -/* - @Override - public int getFavActionIconId() { - return R.drawable.ic_action_edit_dark; - } -*/ - @Override public String getTypeStr() { return wpt.category != null ? wpt.category : getMapActivity().getString(R.string.shared_string_none); @@ -72,6 +68,6 @@ public class WptPtMenuController extends MenuController { @Override public String getNameStr() { - return wpt.name != null ? wpt.name : getMapActivity().getString(R.string.gpx_wpt); + return getPointDescription().getName(); } } diff --git a/OsmAnd/src/net/osmand/plus/osmo/OsMoPositionLayer.java b/OsmAnd/src/net/osmand/plus/osmo/OsMoPositionLayer.java index 3f65bcc4b2..2b0cf6f233 100644 --- a/OsmAnd/src/net/osmand/plus/osmo/OsMoPositionLayer.java +++ b/OsmAnd/src/net/osmand/plus/osmo/OsMoPositionLayer.java @@ -241,11 +241,13 @@ public class OsMoPositionLayer extends OsmandMapLayer implements ContextMenuLaye @Override public PointDescription getObjectName(Object o) { -// if(o instanceof OsMoDevice) { -// return map.getString(R.string.osmo_user_name) + " " + ((OsMoDevice) o).getVisibleName(); -// } - String desc = getObjectDescription(o); - return desc == null ? null : new PointDescription(PointDescription.POINT_TYPE_MARKER, desc); + if(o instanceof OsMoDevice) { + return new PointDescription(PointDescription.POINT_TYPE_MARKER, map.getString(R.string.osmo_user_name) + " " + ((OsMoDevice) o).getVisibleName()); + } else { + return null; + } + //String desc = getObjectDescription(o); + //return desc == null ? null : new PointDescription(PointDescription.POINT_TYPE_MARKER, desc); } public void refresh() { diff --git a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionLayer.java b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionLayer.java index 406e676ca1..9e650951aa 100644 --- a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionLayer.java +++ b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionLayer.java @@ -139,7 +139,7 @@ public class ParkingPositionLayer extends OsmandMapLayer implements ContextMenuL @Override public PointDescription getObjectName(Object o) { return new PointDescription(PointDescription.POINT_TYPE_PARKING_MARKER, - view.getContext().getString(R.string.osmand_parking_position_name), ""); + view.getContext().getString(R.string.osmand_parking_position_name)); } public void refresh() { diff --git a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java index 0cddf2ae78..0a03bfd886 100644 --- a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java +++ b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java @@ -334,7 +334,7 @@ public class ParkingPositionPlugin extends OsmandPlugin { private boolean mIgnoreEvent = false; private Calendar cal = Calendar.getInstance(); - + @Override public void onTimeChanged(TimePicker timePicker, int hourOfDay, int minute) { if (mIgnoreEvent) {