Fix some context menu title issues
This commit is contained in:
parent
0e6a01fd75
commit
5f4bbda4f7
8 changed files with 55 additions and 14 deletions
|
@ -235,6 +235,18 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
return "";
|
||||
}
|
||||
|
||||
public String getType(Context ctx) {
|
||||
if (this.isAudio()) {
|
||||
return ctx.getResources().getString(R.string.shared_string_audio);
|
||||
} else if (this.isVideo()) {
|
||||
return ctx.getResources().getString(R.string.shared_string_video);
|
||||
} else if (this.isPhoto()) {
|
||||
return ctx.getResources().getString(R.string.shared_string_photo);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public String getSearchHistoryType() {
|
||||
if (isPhoto()) {
|
||||
return PointDescription.POINT_TYPE_PHOTO_NOTE;
|
||||
|
|
|
@ -9,6 +9,7 @@ import net.osmand.data.PointDescription;
|
|||
import net.osmand.plus.ContextMenuAdapter;
|
||||
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.other.ShareMenu;
|
||||
import net.osmand.plus.views.ContextMenuLayer;
|
||||
|
@ -211,7 +212,7 @@ public class MapContextMenu extends MenuTitleController {
|
|||
}
|
||||
|
||||
private void acquireMenuController() {
|
||||
menuController = MenuController.getMenuController(mapActivity, pointDescription, object);
|
||||
menuController = MenuController.getMenuController(mapActivity, pointDescription, object, MenuType.STANDARD);
|
||||
}
|
||||
|
||||
public void onSingleTapOnMap() {
|
||||
|
|
|
@ -7,7 +7,6 @@ import net.osmand.data.Amenity;
|
|||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
|
@ -16,6 +15,7 @@ import net.osmand.plus.activities.MapActivity;
|
|||
import net.osmand.plus.audionotes.AudioVideoNotesPlugin.Recording;
|
||||
import net.osmand.plus.helpers.SearchHistoryHelper;
|
||||
import net.osmand.plus.mapcontextmenu.controllers.AmenityMenuController;
|
||||
import net.osmand.plus.mapcontextmenu.controllers.AudioVideoNoteMenuController;
|
||||
import net.osmand.plus.mapcontextmenu.controllers.EditPOIMenuController;
|
||||
import net.osmand.plus.mapcontextmenu.controllers.FavouritePointMenuController;
|
||||
import net.osmand.plus.mapcontextmenu.controllers.HistoryMenuController;
|
||||
|
@ -23,7 +23,6 @@ import net.osmand.plus.mapcontextmenu.controllers.MyLocationMenuController;
|
|||
import net.osmand.plus.mapcontextmenu.controllers.OsMoMenuController;
|
||||
import net.osmand.plus.mapcontextmenu.controllers.ParkingPositionMenuController;
|
||||
import net.osmand.plus.mapcontextmenu.controllers.PointDescriptionMenuController;
|
||||
import net.osmand.plus.mapcontextmenu.controllers.AudioVideoNoteMenuController;
|
||||
import net.osmand.plus.mapcontextmenu.controllers.TargetPointMenuController;
|
||||
import net.osmand.plus.mapcontextmenu.controllers.WptPtMenuController;
|
||||
import net.osmand.plus.mapcontextmenu.other.ShareMenu;
|
||||
|
@ -38,8 +37,14 @@ public abstract class MenuController extends BaseMenuController {
|
|||
public static final int FULL_SCREEN = 4;
|
||||
}
|
||||
|
||||
public enum MenuType {
|
||||
STANDARD,
|
||||
MULTI_LINE
|
||||
}
|
||||
|
||||
private MenuBuilder builder;
|
||||
private int currentMenuState;
|
||||
private MenuType menuType = MenuType.STANDARD;
|
||||
|
||||
protected TitleButtonController titleButtonController;
|
||||
|
||||
|
@ -84,7 +89,7 @@ public abstract class MenuController extends BaseMenuController {
|
|||
}
|
||||
|
||||
public static MenuController getMenuController(MapActivity mapActivity,
|
||||
PointDescription pointDescription, Object object) {
|
||||
PointDescription pointDescription, Object object, MenuType menuType) {
|
||||
OsmandApplication app = mapActivity.getMyApplication();
|
||||
MenuController menuController = null;
|
||||
if (object != null) {
|
||||
|
@ -114,6 +119,9 @@ public abstract class MenuController extends BaseMenuController {
|
|||
} else {
|
||||
menuController = new PointDescriptionMenuController(app, mapActivity, pointDescription);
|
||||
}
|
||||
if (menuController != null) {
|
||||
menuController.menuType = menuType;
|
||||
}
|
||||
return menuController;
|
||||
}
|
||||
|
||||
|
@ -160,6 +168,10 @@ public abstract class MenuController extends BaseMenuController {
|
|||
return currentMenuState;
|
||||
}
|
||||
|
||||
public MenuType getMenuType() {
|
||||
return menuType;
|
||||
}
|
||||
|
||||
public boolean slideUp() {
|
||||
int v = currentMenuState;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
|
@ -205,7 +217,7 @@ public abstract class MenuController extends BaseMenuController {
|
|||
}
|
||||
|
||||
public boolean needTypeStr() {
|
||||
return false;
|
||||
return menuType != MenuType.STANDARD;
|
||||
}
|
||||
|
||||
public boolean displayStreetNameinTitle() {
|
||||
|
|
|
@ -121,7 +121,9 @@ public abstract class MenuTitleController {
|
|||
if (Algorithms.isEmpty(nameStr)) {
|
||||
if (!Algorithms.isEmpty(typeStr)) {
|
||||
nameStr = typeStr;
|
||||
typeStr = "";
|
||||
if (menuController == null || menuController.getMenuType() == MenuController.MenuType.STANDARD) {
|
||||
typeStr = "";
|
||||
}
|
||||
} else {
|
||||
nameStr = getMapActivity().getString(R.string.address_unknown);
|
||||
addressUnknown = true;
|
||||
|
|
|
@ -67,7 +67,9 @@ public class AudioVideoNoteMenuController extends MenuController {
|
|||
@Override
|
||||
public String getNameStr() {
|
||||
File file = recording.getFile();
|
||||
if (file != null) {
|
||||
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);
|
||||
} else {
|
||||
|
@ -75,6 +77,11 @@ public class AudioVideoNoteMenuController extends MenuController {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeStr() {
|
||||
return recording.getType(getMapActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needStreetName() {
|
||||
return false;
|
||||
|
|
|
@ -9,6 +9,7 @@ import net.osmand.plus.TargetPointsHelper.TargetPoint;
|
|||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||
import net.osmand.plus.mapcontextmenu.MenuController;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
public class TargetPointMenuController extends MenuController {
|
||||
|
||||
|
@ -61,16 +62,19 @@ public class TargetPointMenuController extends MenuController {
|
|||
|
||||
@Override
|
||||
public String getNameStr() {
|
||||
String name = "";
|
||||
if (targetPoint.getOriginalPointDescription() != null) {
|
||||
return targetPoint.getOriginalPointDescription().getSimpleName(getMapActivity(), false);
|
||||
} else {
|
||||
return targetPoint.getOnlyName();
|
||||
name = targetPoint.getOriginalPointDescription().getSimpleName(getMapActivity(), false);
|
||||
}
|
||||
if (Algorithms.isEmpty(name)) {
|
||||
name = getTypeStr();
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeStr() {
|
||||
return targetPoint.getOnlyName();
|
||||
return targetPoint.getPointDescription(getMapActivity()).getTypeName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -80,6 +84,6 @@ public class TargetPointMenuController extends MenuController {
|
|||
|
||||
@Override
|
||||
public boolean needStreetName() {
|
||||
return true;
|
||||
return Algorithms.isEmpty(targetPoint.getOnlyName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import net.osmand.data.PointDescription;
|
|||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.mapcontextmenu.BaseMenuController;
|
||||
import net.osmand.plus.mapcontextmenu.MenuController;
|
||||
import net.osmand.plus.mapcontextmenu.MenuController.MenuType;
|
||||
import net.osmand.plus.mapcontextmenu.MenuTitleController;
|
||||
import net.osmand.plus.views.ContextMenuLayer;
|
||||
import net.osmand.plus.views.ContextMenuLayer.IContextMenuProvider;
|
||||
|
@ -47,7 +48,7 @@ public class ObjectSelectionMenu extends BaseMenuController {
|
|||
}
|
||||
|
||||
protected void init() {
|
||||
controller = MenuController.getMenuController(mapActivity, pointDescription, object);
|
||||
controller = MenuController.getMenuController(mapActivity, pointDescription, object, MenuType.MULTI_LINE);
|
||||
initTitle();
|
||||
}
|
||||
|
||||
|
|
|
@ -551,7 +551,9 @@ public class ParkingPositionPlugin extends OsmandPlugin {
|
|||
timeStringBuilder.append(ctx.getString(R.string.osmand_parking_hour));
|
||||
}
|
||||
|
||||
timeStringBuilder.append(" ");
|
||||
if (timeStringBuilder.length() > 0) {
|
||||
timeStringBuilder.append(" ");
|
||||
}
|
||||
timeStringBuilder.append(minutes);
|
||||
timeStringBuilder.append(" ");
|
||||
timeStringBuilder.append(ctx.getString(R.string.osmand_parking_minute));
|
||||
|
|
Loading…
Reference in a new issue