Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
5a0061f224
19 changed files with 351 additions and 325 deletions
|
@ -81,6 +81,19 @@
|
|||
android:textColor="?android:textColorSecondary"
|
||||
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="20dp"
|
||||
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>
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ public class PointDescription implements Serializable {
|
|||
public static final String POINT_TYPE_ADDRESS = "address";
|
||||
public static final String POINT_TYPE_OSM_NOTE= "osm_note";
|
||||
public static final String POINT_TYPE_MARKER = "marker";
|
||||
public static final String POINT_TYPE_PARKING_MARKER = "parking_marker";
|
||||
public static final String POINT_TYPE_AUDIO_NOTE = "audionote";
|
||||
public static final String POINT_TYPE_VIDEO_NOTE = "videonote";
|
||||
public static final String POINT_TYPE_PHOTO_NOTE = "photonote";
|
||||
|
@ -183,6 +184,10 @@ public class PointDescription implements Serializable {
|
|||
return POINT_TYPE_TARGET.equals(type);
|
||||
}
|
||||
|
||||
public boolean isParking() {
|
||||
return POINT_TYPE_PARKING_MARKER.equals(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
|
|
|
@ -21,7 +21,7 @@ import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
|
|||
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.MenuController;
|
||||
import net.osmand.plus.mapcontextmenu.details.ParkingPositionController;
|
||||
import net.osmand.plus.mapcontextmenu.details.PointDescriptionMenuController;
|
||||
import net.osmand.plus.mapcontextmenu.other.ShareMenu;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
|
@ -222,7 +222,11 @@ public class MapContextMenu {
|
|||
menuController = new HistoryMenuController(app, mapActivity, (HistoryEntry) object);
|
||||
}
|
||||
} else {
|
||||
menuController = new PointDescriptionMenuController(app, mapActivity, pointDescription, latLon);
|
||||
if (pointDescription.isParking()) {
|
||||
menuController = new ParkingPositionController(app, mapActivity, pointDescription, latLon);
|
||||
} else {
|
||||
menuController = new PointDescriptionMenuController(app, mapActivity, pointDescription, latLon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -370,10 +374,6 @@ public class MapContextMenu {
|
|||
});
|
||||
}
|
||||
|
||||
public int getFabIconId() {
|
||||
return mapActivity.getMapActions().getRouteMode(latLon).getSmallIconDark();
|
||||
}
|
||||
|
||||
public void fabPressed() {
|
||||
mapActivity.getMapActions().directionTo(latLon.getLatitude(), latLon.getLongitude());
|
||||
hide();
|
||||
|
@ -527,4 +527,19 @@ public class MapContextMenu {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean hasTitleButton() {
|
||||
return menuController != null && menuController.hasTitleButton();
|
||||
}
|
||||
|
||||
public String getTitleButtonCaption() {
|
||||
if (menuController != null) {
|
||||
return menuController.getTitleButtonCaption();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public void titleButtonPressed() {
|
||||
|
||||
}
|
||||
}
|
|
@ -21,6 +21,7 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.widget.Button;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
|
@ -35,13 +36,12 @@ 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.details.MenuController;
|
||||
import net.osmand.plus.views.AnimateDraggingMapThread;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
|
||||
import static android.util.TypedValue.COMPLEX_UNIT_DIP;
|
||||
import static net.osmand.plus.mapcontextmenu.details.MenuBuilder.SHADOW_HEIGHT_BOTTOM_DP;
|
||||
import static net.osmand.plus.mapcontextmenu.details.MenuBuilder.SHADOW_HEIGHT_TOP_DP;
|
||||
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 {
|
||||
|
@ -150,6 +150,18 @@ 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());
|
||||
titleButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
menu.titleButtonPressed();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (menu.isLandscapeLayout()) {
|
||||
mainView.setLayoutParams(new FrameLayout.LayoutParams(dpToPx(menu.getLandscapeWidthDp()),
|
||||
ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
|
|
161
OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java
Normal file
161
OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java
Normal file
|
@ -0,0 +1,161 @@
|
|||
package net.osmand.plus.mapcontextmenu;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.util.Linkify;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.render.RenderingIcons;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import static android.util.TypedValue.COMPLEX_UNIT_DIP;
|
||||
|
||||
public abstract class MenuBuilder {
|
||||
|
||||
public static final float SHADOW_HEIGHT_TOP_DP = 16f;
|
||||
public static final float SHADOW_HEIGHT_BOTTOM_DP = 6f;
|
||||
|
||||
protected OsmandApplication app;
|
||||
protected LinkedList<PlainMenuItem> plainMenuItems;
|
||||
private boolean firstRow;
|
||||
private boolean light;
|
||||
|
||||
public class PlainMenuItem {
|
||||
private int iconId;
|
||||
private String text;
|
||||
|
||||
public PlainMenuItem(int iconId, String text) {
|
||||
this.iconId = iconId;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public int getIconId() {
|
||||
return iconId;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
public MenuBuilder(OsmandApplication app) {
|
||||
this.app = app;
|
||||
plainMenuItems = new LinkedList<>();
|
||||
light = app.getSettings().isLightContent();
|
||||
}
|
||||
|
||||
public void build(View view) {
|
||||
firstRow = true;
|
||||
}
|
||||
|
||||
protected boolean isFirstRow() {
|
||||
return firstRow;
|
||||
}
|
||||
|
||||
protected void rowBuilt() {
|
||||
firstRow = false;
|
||||
}
|
||||
|
||||
protected void buildRow(final View view, Drawable icon, String text, int textColor) {
|
||||
LinearLayout ll = new LinearLayout(view.getContext());
|
||||
ll.setOrientation(LinearLayout.HORIZONTAL);
|
||||
LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
ll.setLayoutParams(llParams);
|
||||
|
||||
// Icon
|
||||
LinearLayout llIcon = new LinearLayout(view.getContext());
|
||||
llIcon.setOrientation(LinearLayout.HORIZONTAL);
|
||||
llIcon.setLayoutParams(new LinearLayout.LayoutParams(dpToPx(72f), isFirstRow() ? dpToPx(48f) - dpToPx(SHADOW_HEIGHT_BOTTOM_DP) : dpToPx(48f)));
|
||||
llIcon.setGravity(Gravity.CENTER_VERTICAL);
|
||||
ll.addView(llIcon);
|
||||
|
||||
ImageView iconView = new ImageView(view.getContext());
|
||||
LinearLayout.LayoutParams llIconParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
llIconParams.setMargins(dpToPx(16f), isFirstRow() ? dpToPx(12f) - dpToPx(SHADOW_HEIGHT_BOTTOM_DP / 2f) : dpToPx(12f), dpToPx(32f), dpToPx(12f));
|
||||
llIconParams.gravity = Gravity.CENTER_VERTICAL;
|
||||
iconView.setLayoutParams(llIconParams);
|
||||
iconView.setScaleType(ImageView.ScaleType.CENTER);
|
||||
iconView.setImageDrawable(icon);
|
||||
llIcon.addView(iconView);
|
||||
|
||||
// Text
|
||||
LinearLayout llText = new LinearLayout(view.getContext());
|
||||
llText.setOrientation(LinearLayout.VERTICAL);
|
||||
ll.addView(llText);
|
||||
|
||||
TextView textView = new TextView(view.getContext());
|
||||
LinearLayout.LayoutParams llTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
llTextParams.setMargins(0, isFirstRow() ? dpToPx(8f) - dpToPx(SHADOW_HEIGHT_BOTTOM_DP) : dpToPx(8f), 0, dpToPx(8f));
|
||||
textView.setLayoutParams(llTextParams);
|
||||
textView.setTextSize(16);
|
||||
textView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_info_text_light : R.color.ctx_menu_info_text_dark));
|
||||
|
||||
textView.setAutoLinkMask(Linkify.ALL);
|
||||
textView.setLinksClickable(true);
|
||||
textView.setText(text);
|
||||
if (textColor > 0) {
|
||||
textView.setTextColor(view.getResources().getColor(textColor));
|
||||
}
|
||||
|
||||
LinearLayout.LayoutParams llTextViewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
llTextViewParams.setMargins(0, 0, dpToPx(10f), 0);
|
||||
llTextViewParams.gravity = Gravity.CENTER_VERTICAL;
|
||||
llText.setLayoutParams(llTextViewParams);
|
||||
llText.addView(textView);
|
||||
|
||||
((LinearLayout) view).addView(ll);
|
||||
|
||||
View horizontalLine = new View(view.getContext());
|
||||
LinearLayout.LayoutParams llHorLineParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dpToPx(1f));
|
||||
llHorLineParams.gravity = Gravity.BOTTOM;
|
||||
horizontalLine.setLayoutParams(llHorLineParams);
|
||||
|
||||
horizontalLine.setBackgroundColor(app.getResources().getColor(light ? R.color.ctx_menu_info_divider_light : R.color.ctx_menu_info_divider_dark));
|
||||
|
||||
((LinearLayout) view).addView(horizontalLine);
|
||||
|
||||
rowBuilt();
|
||||
}
|
||||
|
||||
public void addPlainMenuItem(int iconId, String text) {
|
||||
plainMenuItems.add(new PlainMenuItem(iconId, text));
|
||||
}
|
||||
|
||||
public Drawable getRowIcon(int iconId) {
|
||||
IconsCache iconsCache = app.getIconsCache();
|
||||
boolean light = app.getSettings().isLightContent();
|
||||
return iconsCache.getIcon(iconId,
|
||||
light ? R.color.icon_color : R.color.icon_color_light);
|
||||
}
|
||||
|
||||
public Drawable getRowIcon(Context ctx, String fileName) {
|
||||
Bitmap iconBitmap = RenderingIcons.getIcon(ctx, fileName, false);
|
||||
if (iconBitmap != null) {
|
||||
return new BitmapDrawable(ctx.getResources(), iconBitmap);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public int dpToPx(float dp) {
|
||||
Resources r = app.getResources();
|
||||
return (int) TypedValue.applyDimension(
|
||||
COMPLEX_UNIT_DIP,
|
||||
dp,
|
||||
r.getDisplayMetrics()
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package net.osmand.plus.mapcontextmenu.details;
|
||||
package net.osmand.plus.mapcontextmenu;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
|
@ -25,12 +25,14 @@ public abstract class MenuController {
|
|||
private int currentMenuState;
|
||||
private boolean portraitMode;
|
||||
private boolean largeDevice;
|
||||
private boolean light;
|
||||
|
||||
public MenuController(MenuBuilder builder, MapActivity mapActivity) {
|
||||
this.builder = builder;
|
||||
this.mapActivity = mapActivity;
|
||||
portraitMode = AndroidUiHelper.isOrientationPortrait(mapActivity);
|
||||
largeDevice = AndroidUiHelper.isXLargeDevice(mapActivity);
|
||||
light = mapActivity.getMyApplication().getSettings().isLightContent();
|
||||
this.currentMenuState = getInitialMenuState();
|
||||
}
|
||||
|
||||
|
@ -134,10 +136,21 @@ public abstract class MenuController {
|
|||
}
|
||||
|
||||
protected Drawable getIcon(int iconId) {
|
||||
return getIcon(iconId, R.color.icon_color, R.color.icon_color_light);
|
||||
}
|
||||
|
||||
protected Drawable getIcon(int iconId, int colorLightId, int colorDarkId) {
|
||||
IconsCache iconsCache = mapActivity.getMyApplication().getIconsCache();
|
||||
boolean light = mapActivity.getMyApplication().getSettings().isLightContent();
|
||||
return iconsCache.getIcon(iconId,
|
||||
light ? R.color.icon_color : R.color.icon_color_light);
|
||||
light ? colorLightId : colorDarkId);
|
||||
}
|
||||
|
||||
public boolean hasTitleButton() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getTitleButtonCaption() {
|
||||
return "";
|
||||
}
|
||||
|
||||
public boolean shouldShowButtons() {
|
|
@ -1,11 +1,9 @@
|
|||
package net.osmand.plus.mapcontextmenu.details;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.Html;
|
||||
import android.text.TextUtils;
|
||||
import android.text.util.Linkify;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -19,6 +17,7 @@ import net.osmand.osm.MapPoiTypes;
|
|||
import net.osmand.osm.PoiType;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||
import net.osmand.plus.views.POIMapLayer;
|
||||
import net.osmand.util.Algorithms;
|
||||
import net.osmand.util.OpeningHoursParser;
|
||||
|
@ -26,8 +25,6 @@ import net.osmand.util.OpeningHoursParser;
|
|||
import java.util.Calendar;
|
||||
import java.util.Map;
|
||||
|
||||
import static android.util.TypedValue.COMPLEX_UNIT_DIP;
|
||||
|
||||
public class AmenityMenuBuilder extends MenuBuilder {
|
||||
|
||||
private final Amenity amenity;
|
||||
|
@ -41,7 +38,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
buildRow(view, getRowIcon(iconId), text, textColor, isWiki);
|
||||
}
|
||||
|
||||
private void buildRow(final View view, Drawable icon, String text, int textColor, final boolean isWiki) {
|
||||
protected void buildRow(final View view, Drawable icon, String text, int textColor, final boolean isWiki) {
|
||||
boolean light = app.getSettings().isLightContent();
|
||||
|
||||
LinearLayout ll = new LinearLayout(view.getContext());
|
||||
|
|
|
@ -9,6 +9,7 @@ import net.osmand.osm.PoiType;
|
|||
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.render.RenderingIcons;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
|
|
|
@ -1,17 +1,11 @@
|
|||
package net.osmand.plus.mapcontextmenu.details;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.util.Linkify;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
public class FavouritePointMenuBuilder extends MenuBuilder {
|
||||
|
@ -27,69 +21,6 @@ public class FavouritePointMenuBuilder extends MenuBuilder {
|
|||
buildRow(view, getRowIcon(iconId), text, textColor);
|
||||
}
|
||||
|
||||
private void buildRow(final View view, Drawable icon, String text, int textColor) {
|
||||
boolean light = app.getSettings().isLightContent();
|
||||
|
||||
LinearLayout ll = new LinearLayout(view.getContext());
|
||||
ll.setOrientation(LinearLayout.HORIZONTAL);
|
||||
LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
ll.setLayoutParams(llParams);
|
||||
|
||||
// Icon
|
||||
LinearLayout llIcon = new LinearLayout(view.getContext());
|
||||
llIcon.setOrientation(LinearLayout.HORIZONTAL);
|
||||
llIcon.setLayoutParams(new LinearLayout.LayoutParams(dpToPx(72f), isFirstRow() ? dpToPx(48f) - dpToPx(SHADOW_HEIGHT_BOTTOM_DP) : dpToPx(48f)));
|
||||
llIcon.setGravity(Gravity.CENTER_VERTICAL);
|
||||
ll.addView(llIcon);
|
||||
|
||||
ImageView iconView = new ImageView(view.getContext());
|
||||
LinearLayout.LayoutParams llIconParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
llIconParams.setMargins(dpToPx(16f), isFirstRow() ? dpToPx(12f) - dpToPx(SHADOW_HEIGHT_BOTTOM_DP / 2f) : dpToPx(12f), dpToPx(32f), dpToPx(12f));
|
||||
llIconParams.gravity = Gravity.CENTER_VERTICAL;
|
||||
iconView.setLayoutParams(llIconParams);
|
||||
iconView.setScaleType(ImageView.ScaleType.CENTER);
|
||||
iconView.setImageDrawable(icon);
|
||||
llIcon.addView(iconView);
|
||||
|
||||
// Text
|
||||
LinearLayout llText = new LinearLayout(view.getContext());
|
||||
llText.setOrientation(LinearLayout.VERTICAL);
|
||||
ll.addView(llText);
|
||||
|
||||
TextView textView = new TextView(view.getContext());
|
||||
LinearLayout.LayoutParams llTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
llTextParams.setMargins(0, isFirstRow() ? dpToPx(8f) - dpToPx(SHADOW_HEIGHT_BOTTOM_DP) : dpToPx(8f), 0, dpToPx(8f));
|
||||
textView.setLayoutParams(llTextParams);
|
||||
textView.setTextSize(16);
|
||||
textView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_info_text_light : R.color.ctx_menu_info_text_dark));
|
||||
|
||||
textView.setAutoLinkMask(Linkify.ALL);
|
||||
textView.setLinksClickable(true);
|
||||
textView.setText(text);
|
||||
if (textColor > 0) {
|
||||
textView.setTextColor(view.getResources().getColor(textColor));
|
||||
}
|
||||
|
||||
LinearLayout.LayoutParams llTextViewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
llTextViewParams.setMargins(0, 0, dpToPx(10f), 0);
|
||||
llTextViewParams.gravity = Gravity.CENTER_VERTICAL;
|
||||
llText.setLayoutParams(llTextViewParams);
|
||||
llText.addView(textView);
|
||||
|
||||
((LinearLayout) view).addView(ll);
|
||||
|
||||
View horizontalLine = new View(view.getContext());
|
||||
LinearLayout.LayoutParams llHorLineParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dpToPx(1f));
|
||||
llHorLineParams.gravity = Gravity.BOTTOM;
|
||||
horizontalLine.setLayoutParams(llHorLineParams);
|
||||
|
||||
horizontalLine.setBackgroundColor(app.getResources().getColor(light ? R.color.ctx_menu_info_divider_light : R.color.ctx_menu_info_divider_dark));
|
||||
|
||||
((LinearLayout) view).addView(horizontalLine);
|
||||
|
||||
rowBuilt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(View view) {
|
||||
super.build(view);
|
||||
|
|
|
@ -10,6 +10,7 @@ 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.editors.FavoritePointEditor;
|
||||
import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditorFragment;
|
||||
|
||||
|
|
|
@ -1,17 +1,10 @@
|
|||
package net.osmand.plus.mapcontextmenu.details;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.util.Linkify;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||
|
||||
public class HistoryMenuBuilder extends MenuBuilder {
|
||||
private final HistoryEntry entry;
|
||||
|
@ -25,69 +18,6 @@ public class HistoryMenuBuilder extends MenuBuilder {
|
|||
buildRow(view, getRowIcon(iconId), text, textColor);
|
||||
}
|
||||
|
||||
private void buildRow(final View view, Drawable icon, String text, int textColor) {
|
||||
boolean light = app.getSettings().isLightContent();
|
||||
|
||||
LinearLayout ll = new LinearLayout(view.getContext());
|
||||
ll.setOrientation(LinearLayout.HORIZONTAL);
|
||||
LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
ll.setLayoutParams(llParams);
|
||||
|
||||
// Icon
|
||||
LinearLayout llIcon = new LinearLayout(view.getContext());
|
||||
llIcon.setOrientation(LinearLayout.HORIZONTAL);
|
||||
llIcon.setLayoutParams(new LinearLayout.LayoutParams(dpToPx(72f), isFirstRow() ? dpToPx(48f) - dpToPx(SHADOW_HEIGHT_BOTTOM_DP) : dpToPx(48f)));
|
||||
llIcon.setGravity(Gravity.CENTER_VERTICAL);
|
||||
ll.addView(llIcon);
|
||||
|
||||
ImageView iconView = new ImageView(view.getContext());
|
||||
LinearLayout.LayoutParams llIconParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
llIconParams.setMargins(dpToPx(16f), isFirstRow() ? dpToPx(12f) - dpToPx(SHADOW_HEIGHT_BOTTOM_DP / 2f) : dpToPx(12f), dpToPx(32f), dpToPx(12f));
|
||||
llIconParams.gravity = Gravity.CENTER_VERTICAL;
|
||||
iconView.setLayoutParams(llIconParams);
|
||||
iconView.setScaleType(ImageView.ScaleType.CENTER);
|
||||
iconView.setImageDrawable(icon);
|
||||
llIcon.addView(iconView);
|
||||
|
||||
// Text
|
||||
LinearLayout llText = new LinearLayout(view.getContext());
|
||||
llText.setOrientation(LinearLayout.VERTICAL);
|
||||
ll.addView(llText);
|
||||
|
||||
TextView textView = new TextView(view.getContext());
|
||||
LinearLayout.LayoutParams llTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
llTextParams.setMargins(0, isFirstRow() ? dpToPx(8f) - dpToPx(SHADOW_HEIGHT_BOTTOM_DP) : dpToPx(8f), 0, dpToPx(8f));
|
||||
textView.setLayoutParams(llTextParams);
|
||||
textView.setTextSize(16);
|
||||
textView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_info_text_light : R.color.ctx_menu_info_text_dark));
|
||||
|
||||
textView.setAutoLinkMask(Linkify.ALL);
|
||||
textView.setLinksClickable(true);
|
||||
textView.setText(text);
|
||||
if (textColor > 0) {
|
||||
textView.setTextColor(view.getResources().getColor(textColor));
|
||||
}
|
||||
|
||||
LinearLayout.LayoutParams llTextViewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
llTextViewParams.setMargins(0, 0, dpToPx(10f), 0);
|
||||
llTextViewParams.gravity = Gravity.CENTER_VERTICAL;
|
||||
llText.setLayoutParams(llTextViewParams);
|
||||
llText.addView(textView);
|
||||
|
||||
((LinearLayout) view).addView(ll);
|
||||
|
||||
View horizontalLine = new View(view.getContext());
|
||||
LinearLayout.LayoutParams llHorLineParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dpToPx(1f));
|
||||
llHorLineParams.gravity = Gravity.BOTTOM;
|
||||
horizontalLine.setLayoutParams(llHorLineParams);
|
||||
|
||||
horizontalLine.setBackgroundColor(app.getResources().getColor(light ? R.color.ctx_menu_info_divider_light : R.color.ctx_menu_info_divider_dark));
|
||||
|
||||
((LinearLayout) view).addView(horizontalLine);
|
||||
|
||||
rowBuilt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(View view) {
|
||||
super.build(view);
|
||||
|
|
|
@ -9,6 +9,7 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.search.SearchHistoryFragment;
|
||||
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
|
||||
import net.osmand.plus.mapcontextmenu.MenuController;
|
||||
|
||||
public class HistoryMenuController extends MenuController {
|
||||
|
||||
|
|
|
@ -1,92 +0,0 @@
|
|||
package net.osmand.plus.mapcontextmenu.details;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.render.RenderingIcons;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import static android.util.TypedValue.COMPLEX_UNIT_DIP;
|
||||
|
||||
public abstract class MenuBuilder {
|
||||
|
||||
public class PlainMenuItem {
|
||||
private int iconId;
|
||||
private String text;
|
||||
|
||||
public PlainMenuItem(int iconId, String text) {
|
||||
this.iconId = iconId;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public int getIconId() {
|
||||
return iconId;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
public static final float SHADOW_HEIGHT_TOP_DP = 16f;
|
||||
public static final float SHADOW_HEIGHT_BOTTOM_DP = 6f;
|
||||
|
||||
protected OsmandApplication app;
|
||||
protected LinkedList<PlainMenuItem> plainMenuItems;
|
||||
private boolean firstRow;
|
||||
|
||||
public MenuBuilder(OsmandApplication app) {
|
||||
this.app = app;
|
||||
plainMenuItems = new LinkedList<>();
|
||||
}
|
||||
|
||||
public void build(View view) {
|
||||
firstRow = true;
|
||||
}
|
||||
|
||||
protected boolean isFirstRow() {
|
||||
return firstRow;
|
||||
}
|
||||
|
||||
protected void rowBuilt() {
|
||||
firstRow = false;
|
||||
}
|
||||
|
||||
public void addPlainMenuItem(int iconId, String text) {
|
||||
plainMenuItems.add(new PlainMenuItem(iconId, text));
|
||||
}
|
||||
|
||||
public Drawable getRowIcon(int iconId) {
|
||||
IconsCache iconsCache = app.getIconsCache();
|
||||
boolean light = app.getSettings().isLightContent();
|
||||
return iconsCache.getIcon(iconId,
|
||||
light ? R.color.icon_color : R.color.icon_color_light);
|
||||
}
|
||||
|
||||
public Drawable getRowIcon(Context ctx, String fileName) {
|
||||
Bitmap iconBitmap = RenderingIcons.getIcon(ctx, fileName, false);
|
||||
if (iconBitmap != null) {
|
||||
return new BitmapDrawable(ctx.getResources(), iconBitmap);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public int dpToPx(float dp) {
|
||||
Resources r = app.getResources();
|
||||
return (int) TypedValue.applyDimension(
|
||||
COMPLEX_UNIT_DIP,
|
||||
dp,
|
||||
r.getDisplayMetrics()
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package net.osmand.plus.mapcontextmenu.details;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||
|
||||
public class ParkingPositionBuilder extends MenuBuilder {
|
||||
|
||||
public ParkingPositionBuilder(OsmandApplication app) {
|
||||
super(app);
|
||||
}
|
||||
|
||||
private void buildRow(View view, int iconId, String text, int textColor) {
|
||||
buildRow(view, getRowIcon(iconId), text, textColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(View view) {
|
||||
super.build(view);
|
||||
|
||||
for (PlainMenuItem item : plainMenuItems) {
|
||||
buildRow(view, item.getIconId(), item.getText(), 0);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
package net.osmand.plus.mapcontextmenu.details;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.search.SearchHistoryFragment;
|
||||
import net.osmand.plus.mapcontextmenu.MenuController;
|
||||
|
||||
public class ParkingPositionController extends MenuController {
|
||||
|
||||
private PointDescription pointDescription;
|
||||
private LatLon latLon;
|
||||
|
||||
public ParkingPositionController(OsmandApplication app, MapActivity mapActivity, final PointDescription pointDescription, LatLon latLon) {
|
||||
super(new ParkingPositionBuilder(app), mapActivity);
|
||||
this.pointDescription = pointDescription;
|
||||
this.latLon = latLon;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getInitialMenuStatePortrait() {
|
||||
return MenuState.HEADER_ONLY;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSupportedMenuStatesPortrait() {
|
||||
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needTypeStr() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable getLeftIcon() {
|
||||
return getIcon(R.drawable.ic_action_parking_dark, R.color.map_widget_blue, R.color.osmand_orange);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameStr() {
|
||||
return pointDescription.getTypeName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeStr() {
|
||||
return "Parked at 10:23";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTitleButton() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitleButtonCaption() {
|
||||
return getMapActivity().getText(R.string.osmand_parking_delete).toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needStreetName() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPlainMenuItems(String typeStr, PointDescription pointDescription) {
|
||||
if (pointDescription != null) {
|
||||
addPlainMenuItem(R.drawable.map_my_location, PointDescription.getLocationName(getMapActivity(),
|
||||
latLon.getLatitude(), latLon.getLongitude(), true).replaceAll("\n", ""));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveEntityState(Bundle bundle, String key) {
|
||||
}
|
||||
}
|
|
@ -1,17 +1,10 @@
|
|||
package net.osmand.plus.mapcontextmenu.details;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.util.Linkify;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||
|
||||
public class PointDescriptionMenuBuilder extends MenuBuilder {
|
||||
private final PointDescription pointDescription;
|
||||
|
@ -25,69 +18,6 @@ public class PointDescriptionMenuBuilder extends MenuBuilder {
|
|||
buildRow(view, getRowIcon(iconId), text, textColor);
|
||||
}
|
||||
|
||||
private void buildRow(final View view, Drawable icon, String text, int textColor) {
|
||||
boolean light = app.getSettings().isLightContent();
|
||||
|
||||
LinearLayout ll = new LinearLayout(view.getContext());
|
||||
ll.setOrientation(LinearLayout.HORIZONTAL);
|
||||
LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
ll.setLayoutParams(llParams);
|
||||
|
||||
// Icon
|
||||
LinearLayout llIcon = new LinearLayout(view.getContext());
|
||||
llIcon.setOrientation(LinearLayout.HORIZONTAL);
|
||||
llIcon.setLayoutParams(new LinearLayout.LayoutParams(dpToPx(72f), isFirstRow() ? dpToPx(48f) - dpToPx(SHADOW_HEIGHT_BOTTOM_DP) : dpToPx(48f)));
|
||||
llIcon.setGravity(Gravity.CENTER_VERTICAL);
|
||||
ll.addView(llIcon);
|
||||
|
||||
ImageView iconView = new ImageView(view.getContext());
|
||||
LinearLayout.LayoutParams llIconParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
llIconParams.setMargins(dpToPx(16f), isFirstRow() ? dpToPx(12f) - dpToPx(SHADOW_HEIGHT_BOTTOM_DP / 2f) : dpToPx(12f), dpToPx(32f), dpToPx(12f));
|
||||
llIconParams.gravity = Gravity.CENTER_VERTICAL;
|
||||
iconView.setLayoutParams(llIconParams);
|
||||
iconView.setScaleType(ImageView.ScaleType.CENTER);
|
||||
iconView.setImageDrawable(icon);
|
||||
llIcon.addView(iconView);
|
||||
|
||||
// Text
|
||||
LinearLayout llText = new LinearLayout(view.getContext());
|
||||
llText.setOrientation(LinearLayout.VERTICAL);
|
||||
ll.addView(llText);
|
||||
|
||||
TextView textView = new TextView(view.getContext());
|
||||
LinearLayout.LayoutParams llTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
llTextParams.setMargins(0, isFirstRow() ? dpToPx(8f) - dpToPx(SHADOW_HEIGHT_BOTTOM_DP) : dpToPx(8f), 0, dpToPx(8f));
|
||||
textView.setLayoutParams(llTextParams);
|
||||
textView.setTextSize(16);
|
||||
textView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_info_text_light : R.color.ctx_menu_info_text_dark));
|
||||
|
||||
textView.setAutoLinkMask(Linkify.ALL);
|
||||
textView.setLinksClickable(true);
|
||||
textView.setText(text);
|
||||
if (textColor > 0) {
|
||||
textView.setTextColor(view.getResources().getColor(textColor));
|
||||
}
|
||||
|
||||
LinearLayout.LayoutParams llTextViewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
llTextViewParams.setMargins(0, 0, dpToPx(10f), 0);
|
||||
llTextViewParams.gravity = Gravity.CENTER_VERTICAL;
|
||||
llText.setLayoutParams(llTextViewParams);
|
||||
llText.addView(textView);
|
||||
|
||||
((LinearLayout) view).addView(ll);
|
||||
|
||||
View horizontalLine = new View(view.getContext());
|
||||
LinearLayout.LayoutParams llHorLineParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dpToPx(1f));
|
||||
llHorLineParams.gravity = Gravity.BOTTOM;
|
||||
horizontalLine.setLayoutParams(llHorLineParams);
|
||||
|
||||
horizontalLine.setBackgroundColor(app.getResources().getColor(light ? R.color.ctx_menu_info_divider_light : R.color.ctx_menu_info_divider_dark));
|
||||
|
||||
((LinearLayout) view).addView(horizontalLine);
|
||||
|
||||
rowBuilt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(View view) {
|
||||
super.build(view);
|
||||
|
|
|
@ -9,6 +9,7 @@ import net.osmand.plus.OsmandApplication;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.search.SearchHistoryFragment;
|
||||
import net.osmand.plus.mapcontextmenu.MenuController;
|
||||
|
||||
public class PointDescriptionMenuController extends MenuController {
|
||||
|
||||
|
|
|
@ -29,9 +29,9 @@ public class ShareMenu {
|
|||
|
||||
public enum ShareItem {
|
||||
MESSAGE(R.drawable.ic_action_export, R.string.shared_string_send),
|
||||
CLIPBOARD(R.drawable.ic_action_export, R.string.shared_string_copy),
|
||||
GEO(R.drawable.ic_action_export, R.string.share_geo),
|
||||
QR_CODE(R.drawable.ic_action_export, R.string.share_qr_code);
|
||||
CLIPBOARD(R.drawable.ic_action_copy, R.string.shared_string_copy),
|
||||
GEO(R.drawable.ic_world_globe_dark, R.string.share_geo),
|
||||
QR_CODE(R.drawable.ic_action_qrcode, R.string.share_qr_code);
|
||||
|
||||
final int iconResourceId;
|
||||
final int titleResourceId;
|
||||
|
|
|
@ -138,7 +138,7 @@ public class ParkingPositionLayer extends OsmandMapLayer implements ContextMenuL
|
|||
|
||||
@Override
|
||||
public PointDescription getObjectName(Object o) {
|
||||
return new PointDescription(PointDescription.POINT_TYPE_MARKER,
|
||||
return new PointDescription(PointDescription.POINT_TYPE_PARKING_MARKER,
|
||||
view.getContext().getString(R.string.osmand_parking_position_name), "");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue