Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-10-29 20:10:40 +01:00
commit 78666cdb6a
18 changed files with 262 additions and 159 deletions

View file

@ -81,20 +81,6 @@
android:textColor="?android:textColorSecondary" android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"/> android:textSize="@dimen/default_desc_text_size"/>
<Button
android:id="@+id/title_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:gravity="left|center_vertical"
android:text="@string/osmand_parking_delete"
android:background="?android:selectableItemBackground"
android:textColor="?attr/contextMenuButtonColor"
android:textSize="@dimen/default_desc_text_size"/>
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -107,6 +93,41 @@
</LinearLayout> </LinearLayout>
<LinearLayout
android:id="@+id/title_button_container"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="44dp"
android:layout_marginRight="2dp"
android:layout_marginTop="-16dp"
android:layout_marginBottom="4dp"
android:orientation="horizontal">
<Button
android:id="@+id/title_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?android:selectableItemBackground"
android:gravity="left|center_vertical"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="@string/osmand_parking_delete"
android:textColor="?attr/contextMenuButtonColor"
android:textSize="@dimen/default_desc_text_size"/>
<TextView
android:id="@+id/title_button_right_text"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:clickable="true"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
android:text="— 00:26"/>
</LinearLayout>
<View <View
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="1dp"

View file

@ -118,10 +118,7 @@ public class AudioNotesLayer extends OsmandMapLayer implements IContextMenuProvi
OnContextMenuClick listener = new ContextMenuAdapter.OnContextMenuClick() { OnContextMenuClick listener = new ContextMenuAdapter.OnContextMenuClick() {
@Override @Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) { public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
if (itemId == R.string.recording_context_menu_play || if (itemId == R.string.recording_context_menu_delete) {
itemId == R.string.recording_context_menu_show) {
plugin.playRecording(view.getContext(), r);
} else if (itemId == R.string.recording_context_menu_delete) {
deleteRecording(r); deleteRecording(r);
} }
return true; 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 adapter.item(R.string.recording_context_menu_delete).iconColor(R.drawable.ic_action_delete_dark
).listen(listener).reg(); ).listen(listener).reg();
} }

View file

@ -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) { private String getDuration(Context ctx) {
String additional = ""; String additional = "";
if (duration > 0) { if (duration > 0) {

View file

@ -1,6 +1,8 @@
package net.osmand.plus.mapcontextmenu; package net.osmand.plus.mapcontextmenu;
import android.app.Activity;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.util.TypedValue;
import net.osmand.plus.IconsCache; import net.osmand.plus.IconsCache;
import net.osmand.plus.R; 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); 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) { protected Drawable getIcon(int iconId, int colorLightId, int colorDarkId) {
IconsCache iconsCache = getMapActivity().getMyApplication().getIconsCache(); IconsCache iconsCache = getMapActivity().getMyApplication().getIconsCache();
return iconsCache.getIcon(iconId, isLight() ? colorLightId : colorDarkId); 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;
}
} }

View file

@ -9,6 +9,7 @@ import net.osmand.data.PointDescription;
import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.MenuController.TitleButtonController;
import net.osmand.plus.mapcontextmenu.other.ShareMenu; import net.osmand.plus.mapcontextmenu.other.ShareMenu;
import net.osmand.plus.views.ContextMenuLayer; import net.osmand.plus.views.ContextMenuLayer;
import net.osmand.plus.views.OsmandMapLayer; import net.osmand.plus.views.OsmandMapLayer;
@ -352,21 +353,11 @@ public class MapContextMenu extends MenuTitleController {
} }
} }
public boolean hasTitleButton() { public TitleButtonController getTitleButtonController() {
return menuController != null && menuController.hasTitleButton();
}
public String getTitleButtonCaption() {
if (menuController != null) { if (menuController != null) {
return menuController.getTitleButtonCaption(); return menuController.getTitleButtonController();
} else { } else {
return ""; return null;
}
}
public void titleButtonPressed() {
if (menuController != null) {
menuController.titleButtonPressed();
} }
} }
} }

View file

@ -29,6 +29,7 @@ import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.data.QuadPoint; import net.osmand.data.QuadPoint;
import net.osmand.data.RotatedTileBox; import net.osmand.data.RotatedTileBox;
import net.osmand.plus.IconsCache; import net.osmand.plus.IconsCache;
@ -36,6 +37,7 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.MenuController.TitleButtonController;
import net.osmand.plus.views.AnimateDraggingMapThread; import net.osmand.plus.views.AnimateDraggingMapThread;
import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.OsmandMapTileView;
@ -56,7 +58,8 @@ public class MapContextMenuFragment extends Fragment {
private View mainView; private View mainView;
ImageView fabView; ImageView fabView;
MapContextMenu menu; private MapContextMenu menu;
private TitleButtonController titleButtonController;
private int menuTopViewHeight; private int menuTopViewHeight;
private int menuTopShadowHeight; private int menuTopShadowHeight;
@ -121,6 +124,7 @@ public class MapContextMenuFragment extends Fragment {
markerPaddingXPx = dpToPx(MARKER_PADDING_X_DP); markerPaddingXPx = dpToPx(MARKER_PADDING_X_DP);
menu = getMapActivity().getContextMenu(); menu = getMapActivity().getContextMenu();
titleButtonController = menu.getTitleButtonController();
map = getMapActivity().getMapView(); map = getMapActivity().getMapView();
RotatedTileBox box = map.getCurrentRotatedTileBox().copy(); RotatedTileBox box = map.getCurrentRotatedTileBox().copy();
@ -141,17 +145,35 @@ public class MapContextMenuFragment extends Fragment {
view = inflater.inflate(R.layout.map_context_menu_fragment, container, false); view = inflater.inflate(R.layout.map_context_menu_fragment, container, false);
mainView = view.findViewById(R.id.context_menu_main); mainView = view.findViewById(R.id.context_menu_main);
Button titleButton = (Button) view.findViewById(R.id.title_button); // Title button
titleButton.setVisibility(menu.hasTitleButton() ? View.VISIBLE : View.GONE); final View titleButtonContainer = view.findViewById(R.id.title_button_container);
if (menu.hasTitleButton()) { if (titleButtonController != null) {
titleButton.setText(menu.getTitleButtonCaption()); 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() { titleButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { 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()) { if (menu.isLandscapeLayout()) {
mainView.setLayoutParams(new FrameLayout.LayoutParams(dpToPx(menu.getLandscapeWidthDp()), mainView.setLayoutParams(new FrameLayout.LayoutParams(dpToPx(menu.getLandscapeWidthDp()),

View file

@ -11,16 +11,17 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper.TargetPoint; import net.osmand.plus.TargetPointsHelper.TargetPoint;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.audionotes.AudioVideoNotesPlugin.Recording;
import net.osmand.plus.helpers.SearchHistoryHelper; import net.osmand.plus.helpers.SearchHistoryHelper;
import net.osmand.plus.mapcontextmenu.details.AmenityMenuController; import net.osmand.plus.mapcontextmenu.controllers.AmenityMenuController;
import net.osmand.plus.mapcontextmenu.details.FavouritePointMenuController; import net.osmand.plus.mapcontextmenu.controllers.FavouritePointMenuController;
import net.osmand.plus.mapcontextmenu.details.HistoryMenuController; import net.osmand.plus.mapcontextmenu.controllers.HistoryMenuController;
import net.osmand.plus.mapcontextmenu.details.MyLocationMenuController; import net.osmand.plus.mapcontextmenu.controllers.MyLocationMenuController;
import net.osmand.plus.mapcontextmenu.details.OsMoMenuController; import net.osmand.plus.mapcontextmenu.controllers.OsMoMenuController;
import net.osmand.plus.mapcontextmenu.details.ParkingPositionMenuController; import net.osmand.plus.mapcontextmenu.controllers.ParkingPositionMenuController;
import net.osmand.plus.mapcontextmenu.details.PointDescriptionMenuController; import net.osmand.plus.mapcontextmenu.controllers.PointDescriptionMenuController;
import net.osmand.plus.mapcontextmenu.details.TargetPointMenuController; import net.osmand.plus.mapcontextmenu.controllers.RecordingItemMenuController;
import net.osmand.plus.osmo.OsMoGroupsStorage; import net.osmand.plus.mapcontextmenu.controllers.TargetPointMenuController;
import net.osmand.plus.osmo.OsMoGroupsStorage.OsMoDevice; import net.osmand.plus.osmo.OsMoGroupsStorage.OsMoDevice;
public abstract class MenuController extends BaseMenuController { public abstract class MenuController extends BaseMenuController {
@ -34,6 +35,38 @@ public abstract class MenuController extends BaseMenuController {
private MenuBuilder builder; private MenuBuilder builder;
private int currentMenuState; 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) { public MenuController(MenuBuilder builder, MapActivity mapActivity) {
super(mapActivity); super(mapActivity);
this.builder = builder; this.builder = builder;
@ -59,6 +92,8 @@ public abstract class MenuController extends BaseMenuController {
menuController = new TargetPointMenuController(app, mapActivity, (TargetPoint) object); menuController = new TargetPointMenuController(app, mapActivity, (TargetPoint) object);
} else if (object instanceof OsMoDevice) { } else if (object instanceof OsMoDevice) {
menuController = new OsMoMenuController(app, mapActivity, (OsMoDevice) object); menuController = new OsMoMenuController(app, mapActivity, (OsMoDevice) object);
} else if (object instanceof Recording) {
menuController = new RecordingItemMenuController(app, mapActivity, (Recording) object);
} else if (object instanceof LatLon) { } else if (object instanceof LatLon) {
if (pointDescription.isParking()) { if (pointDescription.isParking()) {
menuController = new ParkingPositionMenuController(app, mapActivity, pointDescription); menuController = new ParkingPositionMenuController(app, mapActivity, pointDescription);
@ -143,15 +178,8 @@ public abstract class MenuController extends BaseMenuController {
this.currentMenuState = currentMenuState; this.currentMenuState = currentMenuState;
} }
public boolean hasTitleButton() { public TitleButtonController getTitleButtonController() {
return false; return titleButtonController;
}
public String getTitleButtonCaption() {
return "";
}
public void titleButtonPressed() {
} }
public boolean shouldShowButtons() { public boolean shouldShowButtons() {

View file

@ -1,4 +1,4 @@
package net.osmand.plus.mapcontextmenu.details; package net.osmand.plus.mapcontextmenu.builders;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.text.Html; import android.text.Html;

View file

@ -1,4 +1,4 @@
package net.osmand.plus.mapcontextmenu.details; package net.osmand.plus.mapcontextmenu.builders;
import android.view.View; import android.view.View;

View file

@ -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.Amenity;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
@ -9,6 +9,7 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.MenuController; import net.osmand.plus.mapcontextmenu.MenuController;
import net.osmand.plus.mapcontextmenu.builders.AmenityMenuBuilder;
import net.osmand.plus.render.RenderingIcons; import net.osmand.plus.render.RenderingIcons;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
@ -21,11 +22,6 @@ public class AmenityMenuController extends MenuController {
this.amenity = amenity; this.amenity = amenity;
} }
@Override
protected int getInitialMenuStatePortrait() {
return MenuState.HEADER_ONLY;
}
@Override @Override
protected int getSupportedMenuStatesPortrait() { protected int getSupportedMenuStatesPortrait() {
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN; return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN;

View file

@ -1,4 +1,4 @@
package net.osmand.plus.mapcontextmenu.details; package net.osmand.plus.mapcontextmenu.controllers;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.support.v4.app.Fragment; 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.activities.MapActivity;
import net.osmand.plus.base.FavoriteImageDrawable; import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.mapcontextmenu.MenuController; 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.FavoritePointEditor;
import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditorFragment; import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditorFragment;
@ -21,11 +22,6 @@ public class FavouritePointMenuController extends MenuController {
this.fav = fav; this.fav = fav;
} }
@Override
protected int getInitialMenuStatePortrait() {
return MenuState.HEADER_ONLY;
}
@Override @Override
protected int getSupportedMenuStatesPortrait() { protected int getSupportedMenuStatesPortrait() {
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN; return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN;

View file

@ -1,4 +1,4 @@
package net.osmand.plus.mapcontextmenu.details; package net.osmand.plus.mapcontextmenu.controllers;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
@ -19,11 +19,6 @@ public class HistoryMenuController extends MenuController {
this.entry = entry; this.entry = entry;
} }
@Override
protected int getInitialMenuStatePortrait() {
return MenuState.HEADER_ONLY;
}
@Override @Override
protected int getSupportedMenuStatesPortrait() { protected int getSupportedMenuStatesPortrait() {
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN; return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN;

View file

@ -1,4 +1,4 @@
package net.osmand.plus.mapcontextmenu.details; package net.osmand.plus.mapcontextmenu.controllers;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
@ -18,11 +18,6 @@ public class MyLocationMenuController extends MenuController {
this.pointDescription = pointDescription; this.pointDescription = pointDescription;
} }
@Override
protected int getInitialMenuStatePortrait() {
return MenuState.HEADER_ONLY;
}
@Override @Override
protected int getSupportedMenuStatesPortrait() { protected int getSupportedMenuStatesPortrait() {
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN; return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN;

View file

@ -1,4 +1,4 @@
package net.osmand.plus.mapcontextmenu.details; package net.osmand.plus.mapcontextmenu.controllers;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
@ -20,11 +20,6 @@ public class OsMoMenuController extends MenuController {
this.device = device; this.device = device;
} }
@Override
protected int getInitialMenuStatePortrait() {
return MenuState.HEADER_ONLY;
}
@Override @Override
protected int getSupportedMenuStatesPortrait() { protected int getSupportedMenuStatesPortrait() {
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN; return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN;

View file

@ -1,4 +1,4 @@
package net.osmand.plus.mapcontextmenu.details; package net.osmand.plus.mapcontextmenu.controllers;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
@ -31,11 +31,15 @@ public class ParkingPositionMenuController extends MenuController {
} }
parkingDescription = sb.toString(); parkingDescription = sb.toString();
} }
} titleButtonController = new TitleButtonController() {
@Override @Override
protected int getInitialMenuStatePortrait() { public void buttonPressed() {
return MenuState.HEADER_ONLY; if (plugin != null) {
plugin.showDeleteDialog(getMapActivity());
}
}
};
titleButtonController.caption = getMapActivity().getString(R.string.osmand_parking_delete);
} }
@Override @Override
@ -63,23 +67,6 @@ public class ParkingPositionMenuController extends MenuController {
return parkingDescription; 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 @Override
public boolean needStreetName() { public boolean needStreetName() {
return false; return false;

View file

@ -1,4 +1,4 @@
package net.osmand.plus.mapcontextmenu.details; package net.osmand.plus.mapcontextmenu.controllers;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
@ -19,11 +19,6 @@ public class PointDescriptionMenuController extends MenuController {
this.pointDescription = pointDescription; this.pointDescription = pointDescription;
} }
@Override
protected int getInitialMenuStatePortrait() {
return MenuState.HEADER_ONLY;
}
@Override @Override
protected int getSupportedMenuStatesPortrait() { protected int getSupportedMenuStatesPortrait() {
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN; return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN;

View file

@ -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;
}
}

View file

@ -1,4 +1,4 @@
package net.osmand.plus.mapcontextmenu.details; package net.osmand.plus.mapcontextmenu.controllers;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
@ -17,11 +17,19 @@ public class TargetPointMenuController extends MenuController {
public TargetPointMenuController(OsmandApplication app, MapActivity mapActivity, final TargetPoint targetPoint) { public TargetPointMenuController(OsmandApplication app, MapActivity mapActivity, final TargetPoint targetPoint) {
super(new MenuBuilder(app), mapActivity); super(new MenuBuilder(app), mapActivity);
this.targetPoint = targetPoint; this.targetPoint = targetPoint;
} titleButtonController = new TitleButtonController() {
@Override @Override
protected int getInitialMenuStatePortrait() { public void buttonPressed() {
return MenuState.HEADER_ONLY; 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 @Override
@ -70,27 +78,6 @@ public class TargetPointMenuController extends MenuController {
return true; 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 @Override
public boolean needStreetName() { public boolean needStreetName() {
return true; return true;