diff --git a/OsmAnd/res/layout/map_context_menu_fragment.xml b/OsmAnd/res/layout/map_context_menu_fragment.xml
index 54f4357735..5d5f9e06d8 100644
--- a/OsmAnd/res/layout/map_context_menu_fragment.xml
+++ b/OsmAnd/res/layout/map_context_menu_fragment.xml
@@ -81,20 +81,6 @@
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"/>
-
-
+
+
+
+
+
+
+
+
-
+
diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioNotesLayer.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioNotesLayer.java
index 34ba95e6aa..6d200d8ef8 100644
--- a/OsmAnd/src/net/osmand/plus/audionotes/AudioNotesLayer.java
+++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioNotesLayer.java
@@ -118,10 +118,7 @@ public class AudioNotesLayer extends OsmandMapLayer implements IContextMenuProvi
OnContextMenuClick listener = new ContextMenuAdapter.OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter> adapter, int itemId, int pos, boolean isChecked) {
- if (itemId == R.string.recording_context_menu_play ||
- itemId == R.string.recording_context_menu_show) {
- plugin.playRecording(view.getContext(), r);
- } else if (itemId == R.string.recording_context_menu_delete) {
+ if (itemId == R.string.recording_context_menu_delete) {
deleteRecording(r);
}
return true;
@@ -129,13 +126,6 @@ public class AudioNotesLayer extends OsmandMapLayer implements IContextMenuProvi
};
- if(r.isPhoto()) {
- adapter.item(R.string.recording_context_menu_show).iconColor(
- R.drawable.ic_action_view).listen(listener).reg();
- } else {
- adapter.item(R.string.recording_context_menu_play).iconColor(
- R.drawable.ic_action_play_dark).listen(listener).reg();
- }
adapter.item(R.string.recording_context_menu_delete).iconColor(R.drawable.ic_action_delete_dark
).listen(listener).reg();
}
diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java
index 6fd3d11bcd..ad1557f9b5 100644
--- a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java
+++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java
@@ -361,6 +361,16 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
}
+ public String getPlainDuration() {
+ updateInternalDescription();
+ if (duration > 0) {
+ int d = (int) (duration / 1000);
+ return Algorithms.formatDuration(d);
+ } else {
+ return "";
+ }
+ }
+
private String getDuration(Context ctx) {
String additional = "";
if (duration > 0) {
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/BaseMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/BaseMenuController.java
index 12ba5a0d22..2b9a044c7c 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/BaseMenuController.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/BaseMenuController.java
@@ -1,6 +1,8 @@
package net.osmand.plus.mapcontextmenu;
+import android.app.Activity;
import android.graphics.drawable.Drawable;
+import android.util.TypedValue;
import net.osmand.plus.IconsCache;
import net.osmand.plus.R;
@@ -68,8 +70,22 @@ public abstract class BaseMenuController {
return getIcon(iconId, R.color.icon_color, R.color.icon_color_light);
}
+ protected Drawable getIcon(int iconId, int colorId) {
+ IconsCache iconsCache = getMapActivity().getMyApplication().getIconsCache();
+ return iconsCache.getIcon(iconId, colorId);
+ }
+
protected Drawable getIcon(int iconId, int colorLightId, int colorDarkId) {
IconsCache iconsCache = getMapActivity().getMyApplication().getIconsCache();
return iconsCache.getIcon(iconId, isLight() ? colorLightId : colorDarkId);
}
+
+ protected int getResIdFromAttribute(final int attr) {
+ if (attr == 0)
+ return 0;
+ final TypedValue typedvalueattr = new TypedValue();
+ getMapActivity().getTheme().resolveAttribute(attr, typedvalueattr, true);
+ return typedvalueattr.resourceId;
+ }
+
}
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java
index a2fda07fa9..e31cc6dd31 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java
@@ -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.TitleButtonController;
import net.osmand.plus.mapcontextmenu.other.ShareMenu;
import net.osmand.plus.views.ContextMenuLayer;
import net.osmand.plus.views.OsmandMapLayer;
@@ -352,21 +353,11 @@ public class MapContextMenu extends MenuTitleController {
}
}
- public boolean hasTitleButton() {
- return menuController != null && menuController.hasTitleButton();
- }
-
- public String getTitleButtonCaption() {
+ public TitleButtonController getTitleButtonController() {
if (menuController != null) {
- return menuController.getTitleButtonCaption();
+ return menuController.getTitleButtonController();
} else {
- return "";
- }
- }
-
- public void titleButtonPressed() {
- if (menuController != null) {
- menuController.titleButtonPressed();
+ return null;
}
}
}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java
index a5e4cbf139..ba423fa1fa 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java
@@ -29,6 +29,7 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import net.osmand.data.LatLon;
+import net.osmand.data.PointDescription;
import net.osmand.data.QuadPoint;
import net.osmand.data.RotatedTileBox;
import net.osmand.plus.IconsCache;
@@ -36,6 +37,7 @@ 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.mapcontextmenu.MenuController.TitleButtonController;
import net.osmand.plus.views.AnimateDraggingMapThread;
import net.osmand.plus.views.OsmandMapTileView;
@@ -56,7 +58,8 @@ public class MapContextMenuFragment extends Fragment {
private View mainView;
ImageView fabView;
- MapContextMenu menu;
+ private MapContextMenu menu;
+ private TitleButtonController titleButtonController;
private int menuTopViewHeight;
private int menuTopShadowHeight;
@@ -121,6 +124,7 @@ public class MapContextMenuFragment extends Fragment {
markerPaddingXPx = dpToPx(MARKER_PADDING_X_DP);
menu = getMapActivity().getContextMenu();
+ titleButtonController = menu.getTitleButtonController();
map = getMapActivity().getMapView();
RotatedTileBox box = map.getCurrentRotatedTileBox().copy();
@@ -141,18 +145,36 @@ public class MapContextMenuFragment extends Fragment {
view = inflater.inflate(R.layout.map_context_menu_fragment, container, false);
mainView = view.findViewById(R.id.context_menu_main);
- Button titleButton = (Button) view.findViewById(R.id.title_button);
- titleButton.setVisibility(menu.hasTitleButton() ? View.VISIBLE : View.GONE);
- if (menu.hasTitleButton()) {
- titleButton.setText(menu.getTitleButtonCaption());
+ // Title button
+ final View titleButtonContainer = view.findViewById(R.id.title_button_container);
+ if (titleButtonController != null) {
+ titleButtonContainer.setVisibility(View.VISIBLE);
+
+ final Button titleButton = (Button) view.findViewById(R.id.title_button);
+ titleButton.setText(titleButtonController.getCaption());
+
+ Drawable leftIcon = titleButtonController.getLeftIcon();
+ if (leftIcon != null) {
+ titleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
+ titleButton.setCompoundDrawablePadding(dpToPx(8f));
+ }
titleButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- menu.titleButtonPressed();
+ titleButtonController.buttonPressed();
}
});
+
+ final TextView titleButtonRightText = (TextView) view.findViewById(R.id.title_button_right_text);
+ titleButtonRightText.setVisibility(titleButtonController.isNeedRightText() ? View.VISIBLE : View.GONE);
+ if (titleButtonController.isNeedRightText()) {
+ titleButtonRightText.setText(titleButtonController.getRightTextCaption());
+ }
+ } else {
+ titleButtonContainer.setVisibility(View.GONE);
}
+
if (menu.isLandscapeLayout()) {
mainView.setLayoutParams(new FrameLayout.LayoutParams(dpToPx(menu.getLandscapeWidthDp()),
ViewGroup.LayoutParams.MATCH_PARENT));
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java
index 11096b555d..f360266bf8 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java
@@ -11,16 +11,17 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper.TargetPoint;
import net.osmand.plus.activities.MapActivity;
+import net.osmand.plus.audionotes.AudioVideoNotesPlugin.Recording;
import net.osmand.plus.helpers.SearchHistoryHelper;
-import net.osmand.plus.mapcontextmenu.details.AmenityMenuController;
-import net.osmand.plus.mapcontextmenu.details.FavouritePointMenuController;
-import net.osmand.plus.mapcontextmenu.details.HistoryMenuController;
-import net.osmand.plus.mapcontextmenu.details.MyLocationMenuController;
-import net.osmand.plus.mapcontextmenu.details.OsMoMenuController;
-import net.osmand.plus.mapcontextmenu.details.ParkingPositionMenuController;
-import net.osmand.plus.mapcontextmenu.details.PointDescriptionMenuController;
-import net.osmand.plus.mapcontextmenu.details.TargetPointMenuController;
-import net.osmand.plus.osmo.OsMoGroupsStorage;
+import net.osmand.plus.mapcontextmenu.controllers.AmenityMenuController;
+import net.osmand.plus.mapcontextmenu.controllers.FavouritePointMenuController;
+import net.osmand.plus.mapcontextmenu.controllers.HistoryMenuController;
+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.RecordingItemMenuController;
+import net.osmand.plus.mapcontextmenu.controllers.TargetPointMenuController;
import net.osmand.plus.osmo.OsMoGroupsStorage.OsMoDevice;
public abstract class MenuController extends BaseMenuController {
@@ -34,6 +35,38 @@ public abstract class MenuController extends BaseMenuController {
private MenuBuilder builder;
private int currentMenuState;
+ protected TitleButtonController titleButtonController;
+
+ public abstract class TitleButtonController {
+
+ 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) {
super(mapActivity);
this.builder = builder;
@@ -59,6 +92,8 @@ public abstract class MenuController extends BaseMenuController {
menuController = new TargetPointMenuController(app, mapActivity, (TargetPoint) object);
} else if (object instanceof OsMoDevice) {
menuController = new OsMoMenuController(app, mapActivity, (OsMoDevice) object);
+ } else if (object instanceof Recording) {
+ menuController = new RecordingItemMenuController(app, mapActivity, (Recording) object);
} else if (object instanceof LatLon) {
if (pointDescription.isParking()) {
menuController = new ParkingPositionMenuController(app, mapActivity, pointDescription);
@@ -143,15 +178,8 @@ public abstract class MenuController extends BaseMenuController {
this.currentMenuState = currentMenuState;
}
- public boolean hasTitleButton() {
- return false;
- }
-
- public String getTitleButtonCaption() {
- return "";
- }
-
- public void titleButtonPressed() {
+ public TitleButtonController getTitleButtonController() {
+ return titleButtonController;
}
public boolean shouldShowButtons() {
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/details/AmenityMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java
similarity index 99%
rename from OsmAnd/src/net/osmand/plus/mapcontextmenu/details/AmenityMenuBuilder.java
rename to OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java
index 65bfdf7532..0cb53dc06f 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/details/AmenityMenuBuilder.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java
@@ -1,4 +1,4 @@
-package net.osmand.plus.mapcontextmenu.details;
+package net.osmand.plus.mapcontextmenu.builders;
import android.graphics.drawable.Drawable;
import android.text.Html;
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/details/FavouritePointMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/FavouritePointMenuBuilder.java
similarity index 94%
rename from OsmAnd/src/net/osmand/plus/mapcontextmenu/details/FavouritePointMenuBuilder.java
rename to OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/FavouritePointMenuBuilder.java
index 5c0c6cfdd5..5dde0ec160 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/details/FavouritePointMenuBuilder.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/FavouritePointMenuBuilder.java
@@ -1,4 +1,4 @@
-package net.osmand.plus.mapcontextmenu.details;
+package net.osmand.plus.mapcontextmenu.builders;
import android.view.View;
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/details/AmenityMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java
similarity index 94%
rename from OsmAnd/src/net/osmand/plus/mapcontextmenu/details/AmenityMenuController.java
rename to OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java
index 8561f182db..be236ecfb7 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/details/AmenityMenuController.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java
@@ -1,4 +1,4 @@
-package net.osmand.plus.mapcontextmenu.details;
+package net.osmand.plus.mapcontextmenu.controllers;
import net.osmand.data.Amenity;
import net.osmand.data.LatLon;
@@ -9,6 +9,7 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.MenuController;
+import net.osmand.plus.mapcontextmenu.builders.AmenityMenuBuilder;
import net.osmand.plus.render.RenderingIcons;
import net.osmand.util.Algorithms;
@@ -21,11 +22,6 @@ public class AmenityMenuController extends MenuController {
this.amenity = amenity;
}
- @Override
- protected int getInitialMenuStatePortrait() {
- return MenuState.HEADER_ONLY;
- }
-
@Override
protected int getSupportedMenuStatesPortrait() {
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN;
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/details/FavouritePointMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java
similarity index 93%
rename from OsmAnd/src/net/osmand/plus/mapcontextmenu/details/FavouritePointMenuController.java
rename to OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java
index 3f2162fde2..7a9866d665 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/details/FavouritePointMenuController.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java
@@ -1,4 +1,4 @@
-package net.osmand.plus.mapcontextmenu.details;
+package net.osmand.plus.mapcontextmenu.controllers;
import android.graphics.drawable.Drawable;
import android.support.v4.app.Fragment;
@@ -9,6 +9,7 @@ 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.editors.FavoritePointEditor;
import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditorFragment;
@@ -21,11 +22,6 @@ public class FavouritePointMenuController extends MenuController {
this.fav = fav;
}
- @Override
- protected int getInitialMenuStatePortrait() {
- return MenuState.HEADER_ONLY;
- }
-
@Override
protected int getSupportedMenuStatesPortrait() {
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN;
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/details/HistoryMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/HistoryMenuController.java
similarity index 91%
rename from OsmAnd/src/net/osmand/plus/mapcontextmenu/details/HistoryMenuController.java
rename to OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/HistoryMenuController.java
index 8fe296e777..ade5247e0b 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/details/HistoryMenuController.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/HistoryMenuController.java
@@ -1,4 +1,4 @@
-package net.osmand.plus.mapcontextmenu.details;
+package net.osmand.plus.mapcontextmenu.controllers;
import android.graphics.drawable.Drawable;
@@ -19,11 +19,6 @@ public class HistoryMenuController extends MenuController {
this.entry = entry;
}
- @Override
- protected int getInitialMenuStatePortrait() {
- return MenuState.HEADER_ONLY;
- }
-
@Override
protected int getSupportedMenuStatesPortrait() {
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN;
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/details/MyLocationMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MyLocationMenuController.java
similarity index 88%
rename from OsmAnd/src/net/osmand/plus/mapcontextmenu/details/MyLocationMenuController.java
rename to OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MyLocationMenuController.java
index dc3325a0e5..5f808a567a 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/details/MyLocationMenuController.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MyLocationMenuController.java
@@ -1,4 +1,4 @@
-package net.osmand.plus.mapcontextmenu.details;
+package net.osmand.plus.mapcontextmenu.controllers;
import android.graphics.drawable.Drawable;
@@ -18,11 +18,6 @@ public class MyLocationMenuController extends MenuController {
this.pointDescription = pointDescription;
}
- @Override
- protected int getInitialMenuStatePortrait() {
- return MenuState.HEADER_ONLY;
- }
-
@Override
protected int getSupportedMenuStatesPortrait() {
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN;
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/details/OsMoMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/OsMoMenuController.java
similarity index 92%
rename from OsmAnd/src/net/osmand/plus/mapcontextmenu/details/OsMoMenuController.java
rename to OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/OsMoMenuController.java
index 67896c93f3..a0e7a2ce68 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/details/OsMoMenuController.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/OsMoMenuController.java
@@ -1,4 +1,4 @@
-package net.osmand.plus.mapcontextmenu.details;
+package net.osmand.plus.mapcontextmenu.controllers;
import android.graphics.drawable.Drawable;
@@ -20,11 +20,6 @@ public class OsMoMenuController extends MenuController {
this.device = device;
}
- @Override
- protected int getInitialMenuStatePortrait() {
- return MenuState.HEADER_ONLY;
- }
-
@Override
protected int getSupportedMenuStatesPortrait() {
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN;
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/details/ParkingPositionMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/ParkingPositionMenuController.java
similarity index 79%
rename from OsmAnd/src/net/osmand/plus/mapcontextmenu/details/ParkingPositionMenuController.java
rename to OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/ParkingPositionMenuController.java
index 9d6487a772..904bf9b913 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/details/ParkingPositionMenuController.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/ParkingPositionMenuController.java
@@ -1,4 +1,4 @@
-package net.osmand.plus.mapcontextmenu.details;
+package net.osmand.plus.mapcontextmenu.controllers;
import android.graphics.drawable.Drawable;
@@ -31,11 +31,15 @@ public class ParkingPositionMenuController extends MenuController {
}
parkingDescription = sb.toString();
}
- }
-
- @Override
- protected int getInitialMenuStatePortrait() {
- return MenuState.HEADER_ONLY;
+ titleButtonController = new TitleButtonController() {
+ @Override
+ public void buttonPressed() {
+ if (plugin != null) {
+ plugin.showDeleteDialog(getMapActivity());
+ }
+ }
+ };
+ titleButtonController.caption = getMapActivity().getString(R.string.osmand_parking_delete);
}
@Override
@@ -63,23 +67,6 @@ public class ParkingPositionMenuController extends MenuController {
return parkingDescription;
}
- @Override
- public boolean hasTitleButton() {
- return true;
- }
-
- @Override
- public String getTitleButtonCaption() {
- return getMapActivity().getString(R.string.osmand_parking_delete);
- }
-
- @Override
- public void titleButtonPressed() {
- if (plugin != null) {
- plugin.showDeleteDialog(getMapActivity());
- }
- }
-
@Override
public boolean needStreetName() {
return false;
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/details/PointDescriptionMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/PointDescriptionMenuController.java
similarity index 92%
rename from OsmAnd/src/net/osmand/plus/mapcontextmenu/details/PointDescriptionMenuController.java
rename to OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/PointDescriptionMenuController.java
index c856e28d57..3ab9b0b6c9 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/details/PointDescriptionMenuController.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/PointDescriptionMenuController.java
@@ -1,4 +1,4 @@
-package net.osmand.plus.mapcontextmenu.details;
+package net.osmand.plus.mapcontextmenu.controllers;
import android.graphics.drawable.Drawable;
@@ -19,11 +19,6 @@ public class PointDescriptionMenuController extends MenuController {
this.pointDescription = pointDescription;
}
- @Override
- protected int getInitialMenuStatePortrait() {
- return MenuState.HEADER_ONLY;
- }
-
@Override
protected int getSupportedMenuStatesPortrait() {
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN;
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/RecordingItemMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/RecordingItemMenuController.java
new file mode 100644
index 0000000000..83789c1cfa
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/RecordingItemMenuController.java
@@ -0,0 +1,79 @@
+package net.osmand.plus.mapcontextmenu.controllers;
+
+import android.graphics.drawable.Drawable;
+
+import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.OsmandPlugin;
+import net.osmand.plus.R;
+import net.osmand.plus.activities.MapActivity;
+import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
+import net.osmand.plus.audionotes.AudioVideoNotesPlugin.Recording;
+import net.osmand.plus.mapcontextmenu.MenuBuilder;
+import net.osmand.plus.mapcontextmenu.MenuController;
+
+import java.io.File;
+import java.text.DateFormat;
+import java.util.Date;
+
+public class RecordingItemMenuController extends MenuController {
+ private Recording recording;
+
+ private DateFormat dateFormat;
+ private AudioVideoNotesPlugin plugin;
+
+ public RecordingItemMenuController(OsmandApplication app, MapActivity mapActivity, final Recording recording) {
+ super(new MenuBuilder(app), mapActivity);
+ this.recording = recording;
+ plugin = OsmandPlugin.getPlugin(AudioVideoNotesPlugin.class);
+ dateFormat = android.text.format.DateFormat.getMediumDateFormat(mapActivity);
+ titleButtonController = new TitleButtonController() {
+ @Override
+ public void buttonPressed() {
+ if (plugin != null) {
+ plugin.playRecording(getMapActivity(), recording);
+ }
+ }
+ };
+ if (!recording.isPhoto()) {
+ titleButtonController.caption = getMapActivity().getString(R.string.recording_context_menu_play);
+ titleButtonController.leftIconId = R.drawable.ic_play_dark;
+ String durationStr = recording.getPlainDuration();
+ titleButtonController.needRightText = true;
+ titleButtonController.rightTextCaption = "— " + durationStr;
+ } else {
+ titleButtonController.caption = getMapActivity().getString(R.string.recording_context_menu_show);
+ }
+ }
+
+ @Override
+ protected int getSupportedMenuStatesPortrait() {
+ return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN;
+ }
+
+ @Override
+ public Drawable getLeftIcon() {
+ if (recording.isPhoto()) {
+ return getIcon(R.drawable.ic_action_photo_dark, R.color.osmand_orange_dark, R.color.osmand_orange);
+ } else if (recording.isAudio()) {
+ return getIcon(R.drawable.ic_action_micro_dark, R.color.osmand_orange_dark, R.color.osmand_orange);
+ } else {
+ return getIcon(R.drawable.ic_action_video_dark, R.color.osmand_orange_dark, R.color.osmand_orange);
+ }
+ }
+
+ @Override
+ public String getNameStr() {
+ File file = recording.getFile();
+ if (file != null) {
+ Date date = new Date(recording.getFile().lastModified());
+ return dateFormat.format(date);
+ } else {
+ return recording.getName(getMapActivity());
+ }
+ }
+
+ @Override
+ public boolean needStreetName() {
+ return false;
+ }
+}
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/details/TargetPointMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TargetPointMenuController.java
similarity index 71%
rename from OsmAnd/src/net/osmand/plus/mapcontextmenu/details/TargetPointMenuController.java
rename to OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TargetPointMenuController.java
index 289df7cb65..86084e52e2 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/details/TargetPointMenuController.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TargetPointMenuController.java
@@ -1,4 +1,4 @@
-package net.osmand.plus.mapcontextmenu.details;
+package net.osmand.plus.mapcontextmenu.controllers;
import android.graphics.drawable.Drawable;
@@ -17,11 +17,19 @@ public class TargetPointMenuController extends MenuController {
public TargetPointMenuController(OsmandApplication app, MapActivity mapActivity, final TargetPoint targetPoint) {
super(new MenuBuilder(app), mapActivity);
this.targetPoint = targetPoint;
- }
-
- @Override
- protected int getInitialMenuStatePortrait() {
- return MenuState.HEADER_ONLY;
+ titleButtonController = new TitleButtonController() {
+ @Override
+ public void buttonPressed() {
+ TargetPointsHelper targetPointsHelper = getMapActivity().getMyApplication().getTargetPointsHelper();
+ if(targetPoint.intermediate) {
+ targetPointsHelper.removeWayPoint(true, targetPoint.index);
+ } else {
+ targetPointsHelper.removeWayPoint(true, -1);
+ }
+ getMapActivity().getContextMenu().close();
+ }
+ };
+ titleButtonController.caption = getMapActivity().getString(R.string.delete_target_point);
}
@Override
@@ -70,27 +78,6 @@ public class TargetPointMenuController extends MenuController {
return true;
}
- @Override
- public boolean hasTitleButton() {
- return true;
- }
-
- @Override
- public String getTitleButtonCaption() {
- return getMapActivity().getString(R.string.delete_target_point);
- }
-
- @Override
- public void titleButtonPressed() {
- TargetPointsHelper targetPointsHelper = getMapActivity().getMyApplication().getTargetPointsHelper();
- if(targetPoint.intermediate) {
- targetPointsHelper.removeWayPoint(true, targetPoint.index);
- } else {
- targetPointsHelper.removeWayPoint(true, -1);
- }
- getMapActivity().getContextMenu().close();
- }
-
@Override
public boolean needStreetName() {
return true;