Merge branch 'r3.9'
This commit is contained in:
commit
0bf7a587af
6 changed files with 190 additions and 71 deletions
|
@ -74,6 +74,7 @@ import net.osmand.plus.views.layers.POIMapLayer;
|
||||||
import net.osmand.plus.views.layers.TransportStopsLayer;
|
import net.osmand.plus.views.layers.TransportStopsLayer;
|
||||||
import net.osmand.plus.widgets.TextViewEx;
|
import net.osmand.plus.widgets.TextViewEx;
|
||||||
import net.osmand.plus.widgets.tools.ClickableSpanTouchListener;
|
import net.osmand.plus.widgets.tools.ClickableSpanTouchListener;
|
||||||
|
import net.osmand.plus.wikipedia.WikiArticleHelper;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
|
|
||||||
|
@ -801,18 +802,98 @@ public class MenuBuilder {
|
||||||
return ll;
|
return ll;
|
||||||
}
|
}
|
||||||
|
|
||||||
public View buildDescriptionRow(final View view, final String textPrefix, final String description, int textColor,
|
public View buildDescriptionRow(final View view, final String description) {
|
||||||
int textLinesLimit, boolean matchWidthDivider) {
|
|
||||||
OnClickListener clickListener = new OnClickListener() {
|
final String descriptionLabel = app.getString(R.string.shared_string_description);
|
||||||
|
View.OnClickListener onClickListener = new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
POIMapLayer.showDescriptionDialog(view.getContext(), app, description, textPrefix);
|
POIMapLayer.showHtmlDescriptionDialog(view.getContext(), app, description, descriptionLabel);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return buildRow(view, null, null, textPrefix, description, textColor,
|
if (!isFirstRow()) {
|
||||||
null, false, null, true, textLinesLimit,
|
buildRowDivider(view);
|
||||||
false, false, false, clickListener, matchWidthDivider);
|
}
|
||||||
|
|
||||||
|
LinearLayout baseView = new LinearLayout(view.getContext());
|
||||||
|
baseView.setOrientation(LinearLayout.VERTICAL);
|
||||||
|
LinearLayout.LayoutParams llBaseViewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||||
|
baseView.setLayoutParams(llBaseViewParams);
|
||||||
|
|
||||||
|
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);
|
||||||
|
ll.setBackgroundResource(AndroidUtils.resolveAttribute(view.getContext(), android.R.attr.selectableItemBackground));
|
||||||
|
ll.setOnLongClickListener(new View.OnLongClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onLongClick(View v) {
|
||||||
|
copyToClipboard(description, view.getContext());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
baseView.addView(ll);
|
||||||
|
|
||||||
|
// Text
|
||||||
|
LinearLayout llText = new LinearLayout(view.getContext());
|
||||||
|
llText.setOrientation(LinearLayout.VERTICAL);
|
||||||
|
LinearLayout.LayoutParams llTextViewParams = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||||
|
llTextViewParams.weight = 1f;
|
||||||
|
AndroidUtils.setMargins(llTextViewParams, 0, 0, dpToPx(10f), 0);
|
||||||
|
llTextViewParams.gravity = Gravity.CENTER_VERTICAL;
|
||||||
|
llText.setLayoutParams(llTextViewParams);
|
||||||
|
ll.addView(llText);
|
||||||
|
|
||||||
|
// Description label
|
||||||
|
TextViewEx textPrefixView = new TextViewEx(view.getContext());
|
||||||
|
LinearLayout.LayoutParams llTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||||
|
AndroidUtils.setMargins(llTextParams, dpToPx(16f), dpToPx(8f), 0, 0);
|
||||||
|
textPrefixView.setLayoutParams(llTextParams);
|
||||||
|
textPrefixView.setTypeface(FontCache.getRobotoRegular(view.getContext()));
|
||||||
|
textPrefixView.setTextSize(12);
|
||||||
|
textPrefixView.setTextColor(app.getResources().getColor(light ? R.color.text_color_secondary_light : R.color.text_color_secondary_dark));
|
||||||
|
textPrefixView.setMinLines(1);
|
||||||
|
textPrefixView.setMaxLines(1);
|
||||||
|
textPrefixView.setText(descriptionLabel);
|
||||||
|
llText.addView(textPrefixView);
|
||||||
|
|
||||||
|
// Description
|
||||||
|
TextViewEx textView = new TextViewEx(view.getContext());
|
||||||
|
LinearLayout.LayoutParams llDescriptionParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||||
|
AndroidUtils.setMargins(llDescriptionParams, dpToPx(16f), dpToPx(2f), 0, dpToPx(8f));
|
||||||
|
textView.setLayoutParams(llDescriptionParams);
|
||||||
|
textView.setTypeface(FontCache.getRobotoRegular(view.getContext()));
|
||||||
|
textView.setTextSize(16);
|
||||||
|
textView.setTextColor(app.getResources().getColor(light ? R.color.text_color_primary_light : R.color.text_color_primary_dark));
|
||||||
|
textView.setText(WikiArticleHelper.getPartialContent(description));
|
||||||
|
|
||||||
|
if (Linkify.addLinks(textView, Linkify.ALL)) {
|
||||||
|
textView.setMovementMethod(null);
|
||||||
|
int linkTextColor = ContextCompat.getColor(view.getContext(), light ?
|
||||||
|
R.color.ctx_menu_bottom_view_url_color_light : R.color.ctx_menu_bottom_view_url_color_dark);
|
||||||
|
textView.setLinkTextColor(linkTextColor);
|
||||||
|
textView.setOnTouchListener(new ClickableSpanTouchListener());
|
||||||
|
AndroidUtils.removeLinkUnderline(textView);
|
||||||
|
}
|
||||||
|
textView.setMinLines(1);
|
||||||
|
textView.setMaxLines(10);
|
||||||
|
textView.setEllipsize(TextUtils.TruncateAt.END);
|
||||||
|
llText.addView(textView);
|
||||||
|
|
||||||
|
// Read Full button
|
||||||
|
buildReadFullButton(llText, app.getString(R.string.context_menu_read_full), onClickListener);
|
||||||
|
|
||||||
|
if (onClickListener != null) {
|
||||||
|
ll.setOnClickListener(onClickListener);
|
||||||
|
}
|
||||||
|
((LinearLayout) view).addView(baseView);
|
||||||
|
|
||||||
|
rowBuilt();
|
||||||
|
setDividerWidth(true);
|
||||||
|
|
||||||
|
return ll;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void showDialog(String text, final String actionType, final String dataPrefix, final View v) {
|
protected void showDialog(String text, final String actionType, final String dataPrefix, final View v) {
|
||||||
|
@ -908,6 +989,38 @@ public class MenuBuilder {
|
||||||
((LinearLayout) view).addView(horizontalLine);
|
((LinearLayout) view).addView(horizontalLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void buildReadFullButton(LinearLayout container, String btnText, View.OnClickListener onClickListener) {
|
||||||
|
Context ctx = container.getContext();
|
||||||
|
|
||||||
|
TextViewEx button = new TextViewEx(new ContextThemeWrapper(ctx, light ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme));
|
||||||
|
LinearLayout.LayoutParams llButtonParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, dpToPx(36f));
|
||||||
|
AndroidUtils.setMargins(llButtonParams, dpToPx(16f), 0, 0, dpToPx(16f));
|
||||||
|
button.setLayoutParams(llButtonParams);
|
||||||
|
button.setTypeface(FontCache.getRobotoMedium(app));
|
||||||
|
button.setBackgroundResource(light ? R.drawable.context_menu_controller_bg_light : R.drawable.context_menu_controller_bg_dark);
|
||||||
|
button.setTextSize(14);
|
||||||
|
int paddingSides = dpToPx(10f);
|
||||||
|
button.setPadding(paddingSides, 0, paddingSides, 0);
|
||||||
|
ColorStateList buttonColorStateList = AndroidUtils.createPressedColorStateList(ctx, !light,
|
||||||
|
R.color.ctx_menu_controller_button_text_color_light_n, R.color.ctx_menu_controller_button_text_color_light_p,
|
||||||
|
R.color.ctx_menu_controller_button_text_color_dark_n, R.color.ctx_menu_controller_button_text_color_dark_p);
|
||||||
|
button.setTextColor(buttonColorStateList);
|
||||||
|
button.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
|
||||||
|
button.setSingleLine(true);
|
||||||
|
button.setEllipsize(TextUtils.TruncateAt.END);
|
||||||
|
button.setOnClickListener(onClickListener);
|
||||||
|
button.setAllCaps(true);
|
||||||
|
button.setText(btnText);
|
||||||
|
Drawable normal = app.getUIUtilities().getIcon(R.drawable.ic_action_read_text,
|
||||||
|
light ? R.color.ctx_menu_controller_button_text_color_light_n : R.color.ctx_menu_controller_button_text_color_dark_n);
|
||||||
|
Drawable pressed = app.getUIUtilities().getIcon(R.drawable.ic_action_read_text,
|
||||||
|
light ? R.color.ctx_menu_controller_button_text_color_light_p : R.color.ctx_menu_controller_button_text_color_dark_p);
|
||||||
|
AndroidUtils.setCompoundDrawablesWithIntrinsicBounds(button, Build.VERSION.SDK_INT >= 21
|
||||||
|
? AndroidUtils.createPressedStateListDrawable(normal, pressed) : normal, null, null, null);
|
||||||
|
button.setCompoundDrawablePadding(dpToPx(8f));
|
||||||
|
container.addView(button);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasCustomAddressLine() {
|
public boolean hasCustomAddressLine() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,8 @@ package net.osmand.plus.mapcontextmenu.builders;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.ColorStateList;
|
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.text.util.Linkify;
|
import android.text.util.Linkify;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
|
@ -15,10 +13,6 @@ import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.appcompat.view.ContextThemeWrapper;
|
|
||||||
import androidx.core.content.ContextCompat;
|
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.data.Amenity;
|
import net.osmand.data.Amenity;
|
||||||
|
@ -31,7 +25,6 @@ import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.Version;
|
import net.osmand.plus.Version;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.helpers.FontCache;
|
|
||||||
import net.osmand.plus.helpers.enums.MetricsConstants;
|
import net.osmand.plus.helpers.enums.MetricsConstants;
|
||||||
import net.osmand.plus.mapcontextmenu.CollapsableView;
|
import net.osmand.plus.mapcontextmenu.CollapsableView;
|
||||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||||
|
@ -67,6 +60,9 @@ import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
public class AmenityMenuBuilder extends MenuBuilder {
|
public class AmenityMenuBuilder extends MenuBuilder {
|
||||||
|
|
||||||
private static final String WIKI_LINK = ".wikipedia.org/w";
|
private static final String WIKI_LINK = ".wikipedia.org/w";
|
||||||
|
@ -259,38 +255,12 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isWiki) {
|
if (isWiki) {
|
||||||
TextViewEx button = new TextViewEx(new ContextThemeWrapper(view.getContext(), light ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme));
|
buildReadFullButton(llText, app.getString(R.string.context_menu_read_full_article), new View.OnClickListener() {
|
||||||
LinearLayout.LayoutParams llWikiButtonParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, dpToPx(36f));
|
|
||||||
AndroidUtils.setMargins(llWikiButtonParams, dpToPx(16f), 0, 0, dpToPx(16f));
|
|
||||||
button.setLayoutParams(llWikiButtonParams);
|
|
||||||
button.setTypeface(FontCache.getRobotoMedium(app));
|
|
||||||
button.setBackgroundResource(light ? R.drawable.context_menu_controller_bg_light : R.drawable.context_menu_controller_bg_dark);
|
|
||||||
button.setTextSize(14);
|
|
||||||
int paddingSides = dpToPx(10f);
|
|
||||||
button.setPadding(paddingSides, 0, paddingSides, 0);
|
|
||||||
ColorStateList buttonColorStateList = AndroidUtils.createPressedColorStateList(view.getContext(), !light,
|
|
||||||
R.color.ctx_menu_controller_button_text_color_light_n, R.color.ctx_menu_controller_button_text_color_light_p,
|
|
||||||
R.color.ctx_menu_controller_button_text_color_dark_n, R.color.ctx_menu_controller_button_text_color_dark_p);
|
|
||||||
button.setTextColor(buttonColorStateList);
|
|
||||||
button.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
|
|
||||||
button.setSingleLine(true);
|
|
||||||
button.setEllipsize(TextUtils.TruncateAt.END);
|
|
||||||
button.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
WikipediaDialogFragment.showInstance(mapActivity, amenity);
|
WikipediaDialogFragment.showInstance(mapActivity, amenity);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
button.setAllCaps(true);
|
|
||||||
button.setText(R.string.context_menu_read_full_article);
|
|
||||||
Drawable normal = app.getUIUtilities().getIcon(R.drawable.ic_action_read_text,
|
|
||||||
light ? R.color.ctx_menu_controller_button_text_color_light_n : R.color.ctx_menu_controller_button_text_color_dark_n);
|
|
||||||
Drawable pressed = app.getUIUtilities().getIcon(R.drawable.ic_action_read_text,
|
|
||||||
light ? R.color.ctx_menu_controller_button_text_color_light_p : R.color.ctx_menu_controller_button_text_color_dark_p);
|
|
||||||
AndroidUtils.setCompoundDrawablesWithIntrinsicBounds(button, Build.VERSION.SDK_INT >= 21
|
|
||||||
? AndroidUtils.createPressedStateListDrawable(normal, pressed) : normal, null, null, null);
|
|
||||||
button.setCompoundDrawablePadding(dpToPx(8f));
|
|
||||||
llText.addView(button);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
((LinearLayout) view).addView(baseView);
|
((LinearLayout) view).addView(baseView);
|
||||||
|
|
|
@ -4,8 +4,6 @@ import android.content.Context;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.ResultMatcher;
|
import net.osmand.ResultMatcher;
|
||||||
import net.osmand.binary.BinaryMapIndexReader;
|
import net.osmand.binary.BinaryMapIndexReader;
|
||||||
|
@ -19,8 +17,8 @@ import net.osmand.osm.PoiCategory;
|
||||||
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
|
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
|
||||||
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.MenuBuilder;
|
|
||||||
import net.osmand.plus.mapcontextmenu.CollapsableView;
|
import net.osmand.plus.mapcontextmenu.CollapsableView;
|
||||||
|
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||||
import net.osmand.plus.myplaces.FavoritesActivity;
|
import net.osmand.plus.myplaces.FavoritesActivity;
|
||||||
import net.osmand.plus.widgets.TextViewEx;
|
import net.osmand.plus.widgets.TextViewEx;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
@ -29,6 +27,8 @@ import net.osmand.util.MapUtils;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
public class FavouritePointMenuBuilder extends MenuBuilder {
|
public class FavouritePointMenuBuilder extends MenuBuilder {
|
||||||
|
|
||||||
private static final org.apache.commons.logging.Log LOG = PlatformUtil.getLog(FavouritePointMenuBuilder.class);
|
private static final org.apache.commons.logging.Log LOG = PlatformUtil.getLog(FavouritePointMenuBuilder.class);
|
||||||
|
@ -85,7 +85,7 @@ public class FavouritePointMenuBuilder extends MenuBuilder {
|
||||||
protected void buildDescription(View view) {
|
protected void buildDescription(View view) {
|
||||||
String desc = fav.getDescription();
|
String desc = fav.getDescription();
|
||||||
if (!Algorithms.isEmpty(desc)) {
|
if (!Algorithms.isEmpty(desc)) {
|
||||||
buildDescriptionRow(view, app.getString(R.string.shared_string_description), desc, 0, 10, true);
|
buildDescriptionRow(view, desc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,6 @@ import android.content.Context;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
import androidx.annotation.ColorInt;
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.core.content.ContextCompat;
|
|
||||||
|
|
||||||
import net.osmand.GPXUtilities;
|
import net.osmand.GPXUtilities;
|
||||||
import net.osmand.GPXUtilities.WptPt;
|
import net.osmand.GPXUtilities.WptPt;
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
|
@ -30,6 +26,10 @@ import java.text.DateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import androidx.annotation.ColorInt;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
public class WptPtMenuBuilder extends MenuBuilder {
|
public class WptPtMenuBuilder extends MenuBuilder {
|
||||||
|
|
||||||
private final WptPt wpt;
|
private final WptPt wpt;
|
||||||
|
@ -52,10 +52,22 @@ public class WptPtMenuBuilder extends MenuBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void buildDescription(View view) {
|
protected void buildDescription(final View view) {
|
||||||
if (!Algorithms.isEmpty(wpt.desc)) {
|
if (Algorithms.isEmpty(wpt.desc)) {
|
||||||
buildDescriptionRow(view, app.getString(R.string.shared_string_description), wpt.desc, 0, 10, true);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final String textPrefix = app.getString(R.string.shared_string_description);
|
||||||
|
View.OnClickListener clickListener = new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
POIMapLayer.showDescriptionDialog(view.getContext(), app, wpt.desc, textPrefix);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
buildRow(view, null, null, textPrefix, wpt.desc, 0,
|
||||||
|
null, false, null, true, 10,
|
||||||
|
false, false, false, clickListener, matchWidthDivider);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -3,9 +3,11 @@ package net.osmand.plus.views.layers;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.text.util.Linkify;
|
import android.text.util.Linkify;
|
||||||
|
import android.util.Base64;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -41,6 +43,7 @@ import net.osmand.plus.routing.RoutingHelper;
|
||||||
import net.osmand.plus.views.OsmandMapLayer;
|
import net.osmand.plus.views.OsmandMapLayer;
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
import net.osmand.plus.views.layers.MapTextLayer.MapTextProvider;
|
import net.osmand.plus.views.layers.MapTextLayer.MapTextProvider;
|
||||||
|
import net.osmand.plus.widgets.WebViewEx;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -272,7 +275,39 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showDescriptionDialog(Context ctx, OsmandApplication app, String text, String title) {
|
public static void showDescriptionDialog(Context ctx, OsmandApplication app, String text, String title) {
|
||||||
showText(ctx, app, text, title);
|
final TextView textView = new TextView(ctx);
|
||||||
|
LinearLayout.LayoutParams llTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||||
|
int textMargin = dpToPx(app, 10f);
|
||||||
|
boolean light = app.getSettings().isLightContent();
|
||||||
|
textView.setLayoutParams(llTextParams);
|
||||||
|
textView.setPadding(textMargin, textMargin, textMargin, textMargin);
|
||||||
|
textView.setTextSize(16);
|
||||||
|
textView.setTextColor(ContextCompat.getColor(app, light ? R.color.text_color_primary_light : R.color.text_color_primary_dark));
|
||||||
|
textView.setAutoLinkMask(Linkify.ALL);
|
||||||
|
textView.setLinksClickable(true);
|
||||||
|
textView.setText(text);
|
||||||
|
|
||||||
|
showText(ctx, app, textView, title);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void showHtmlDescriptionDialog(Context ctx, OsmandApplication app, String html, String title) {
|
||||||
|
final WebViewEx webView = new WebViewEx(ctx);
|
||||||
|
LinearLayout.LayoutParams llTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||||
|
webView.setLayoutParams(llTextParams);
|
||||||
|
int margin = dpToPx(app, 10f);
|
||||||
|
webView.setPadding(margin, margin, margin, margin);
|
||||||
|
webView.setScrollbarFadingEnabled(true);
|
||||||
|
webView.setVerticalScrollBarEnabled(false);
|
||||||
|
webView.setBackgroundColor(Color.TRANSPARENT);
|
||||||
|
webView.getSettings().setTextZoom((int) (app.getResources().getConfiguration().fontScale * 100f));
|
||||||
|
boolean light = app.getSettings().isLightContent();
|
||||||
|
int textColor = ContextCompat.getColor(app, light ? R.color.text_color_primary_light : R.color.text_color_primary_dark);
|
||||||
|
String rgbHex = Algorithms.colorToString(textColor);
|
||||||
|
html = "<body style=\"color:" + rgbHex + ";\">" + html + "</body>";
|
||||||
|
String encoded = Base64.encodeToString(html.getBytes(), Base64.NO_PADDING);
|
||||||
|
webView.loadData(encoded, "text/html", "base64");
|
||||||
|
|
||||||
|
showText(ctx, app, webView, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int getResIdFromAttribute(final Context ctx, final int attr) {
|
static int getResIdFromAttribute(final Context ctx, final int attr) {
|
||||||
|
@ -284,7 +319,7 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
|
||||||
return typedvalueattr.resourceId;
|
return typedvalueattr.resourceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void showText(final Context ctx, final OsmandApplication app, final String text, String title) {
|
private static void showText(final Context ctx, final OsmandApplication app, final View view, String title) {
|
||||||
final Dialog dialog = new Dialog(ctx,
|
final Dialog dialog = new Dialog(ctx,
|
||||||
app.getSettings().isLightContent() ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme);
|
app.getSettings().isLightContent() ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme);
|
||||||
|
|
||||||
|
@ -306,24 +341,12 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final TextView textView = new TextView(ctx);
|
|
||||||
LinearLayout.LayoutParams llTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
||||||
int textMargin = dpToPx(app, 10f);
|
|
||||||
boolean light = app.getSettings().isLightContent();
|
|
||||||
textView.setLayoutParams(llTextParams);
|
|
||||||
textView.setPadding(textMargin, textMargin, textMargin, textMargin);
|
|
||||||
textView.setTextSize(16);
|
|
||||||
textView.setTextColor(ContextCompat.getColor(app, light ? R.color.text_color_primary_light : R.color.text_color_primary_dark));
|
|
||||||
textView.setAutoLinkMask(Linkify.ALL);
|
|
||||||
textView.setLinksClickable(true);
|
|
||||||
textView.setText(text);
|
|
||||||
|
|
||||||
ScrollView scrollView = new ScrollView(ctx);
|
ScrollView scrollView = new ScrollView(ctx);
|
||||||
ll.addView(topBar);
|
ll.addView(topBar);
|
||||||
LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 0);
|
LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 0);
|
||||||
lp.weight = 1;
|
lp.weight = 1;
|
||||||
ll.addView(scrollView, lp);
|
ll.addView(scrollView, lp);
|
||||||
scrollView.addView(textView);
|
scrollView.addView(view);
|
||||||
|
|
||||||
dialog.setContentView(ll);
|
dialog.setContentView(ll);
|
||||||
dialog.setCancelable(true);
|
dialog.setCancelable(true);
|
||||||
|
|
|
@ -2,8 +2,6 @@ package net.osmand.plus.wikivoyage.menu;
|
||||||
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
import net.osmand.GPXUtilities.WptPt;
|
import net.osmand.GPXUtilities.WptPt;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
@ -12,6 +10,8 @@ import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
public class WikivoyageWptPtMenuBuilder extends WptPtMenuBuilder {
|
public class WikivoyageWptPtMenuBuilder extends WptPtMenuBuilder {
|
||||||
|
|
||||||
private final static String KEY_PHONE = "Phone: ";
|
private final static String KEY_PHONE = "Phone: ";
|
||||||
|
@ -30,12 +30,13 @@ public class WikivoyageWptPtMenuBuilder extends WptPtMenuBuilder {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void buildDescription(View view) {
|
protected void buildDescription(View view) {
|
||||||
final String desc = descTokens.get(KEY_DESCRIPTION);
|
String desc = descTokens.get(KEY_DESCRIPTION);
|
||||||
if (!Algorithms.isEmpty(desc)) {
|
if (!Algorithms.isEmpty(desc)) {
|
||||||
buildDescriptionRow(view, app.getString(R.string.shared_string_description), desc, 0, 10, true);
|
buildDescriptionRow(view, desc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void prepareDescription(final WptPt wpt, View view) {
|
protected void prepareDescription(final WptPt wpt, View view) {
|
||||||
String phones = descTokens.get(KEY_PHONE);
|
String phones = descTokens.get(KEY_PHONE);
|
||||||
|
|
Loading…
Reference in a new issue