Change wikipedia in bottom view
This commit is contained in:
parent
79436d2759
commit
0a138db9a6
3 changed files with 60 additions and 34 deletions
|
@ -9,6 +9,7 @@
|
|||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||
-->
|
||||
<string name="context_menu_read_full_article">Read full article</string>
|
||||
<string name="context_menu_read_article">Read article</string>
|
||||
<string name="context_menu_points_of_group">All points of group</string>
|
||||
<string name="opened_from">Opened from</string>
|
||||
|
|
|
@ -79,7 +79,7 @@ public class MenuBuilder {
|
|||
protected OsmandApplication app;
|
||||
protected LinkedList<PlainMenuItem> plainMenuItems;
|
||||
private boolean firstRow;
|
||||
private boolean matchWidthDivider;
|
||||
protected boolean matchWidthDivider;
|
||||
protected boolean light;
|
||||
private long objectId;
|
||||
private LatLon latLon;
|
||||
|
@ -933,7 +933,7 @@ public class MenuBuilder {
|
|||
|
||||
protected TextViewEx buildButtonInCollapsableView(Context context, boolean selected, boolean showAll) {
|
||||
TextViewEx button = new TextViewEx(new ContextThemeWrapper(context, light ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme));
|
||||
LinearLayout.LayoutParams llWikiButtonParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) context.getResources().getDimension(R.dimen.context_menu_controller_height));
|
||||
LinearLayout.LayoutParams llWikiButtonParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dpToPx(36f));
|
||||
llWikiButtonParams.setMargins(0, 0, 0, dpToPx(8f));
|
||||
button.setLayoutParams(llWikiButtonParams);
|
||||
button.setTypeface(FontCache.getRobotoRegular(context));
|
||||
|
@ -947,7 +947,7 @@ public class MenuBuilder {
|
|||
}
|
||||
button.setBackgroundResource(bg);
|
||||
button.setTextSize(14);
|
||||
int paddingSides = (int) context.getResources().getDimension(R.dimen.context_menu_button_padding_x);
|
||||
int paddingSides = dpToPx(10f);
|
||||
button.setPadding(paddingSides, 0, paddingSides, 0);
|
||||
if (!selected) {
|
||||
ColorStateList buttonColorStateList = new ColorStateList(
|
||||
|
|
|
@ -2,11 +2,11 @@ package net.osmand.plus.mapcontextmenu.builders;
|
|||
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.AppCompatButton;
|
||||
import android.support.v7.view.ContextThemeWrapper;
|
||||
import android.text.Html;
|
||||
import android.text.SpannableString;
|
||||
import android.text.TextUtils;
|
||||
|
@ -29,9 +29,11 @@ import net.osmand.plus.OsmandPlugin;
|
|||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.helpers.FontCache;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||
import net.osmand.plus.osmedit.OsmEditingPlugin;
|
||||
import net.osmand.plus.views.POIMapLayer;
|
||||
import net.osmand.plus.widgets.TextViewEx;
|
||||
import net.osmand.util.Algorithms;
|
||||
import net.osmand.util.OpeningHoursParser;
|
||||
|
||||
|
@ -61,7 +63,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
boolean collapsable, final CollapsableView collapsableView,
|
||||
int textColor, boolean isWiki, boolean isText, boolean needLinks,
|
||||
boolean isPhoneNumber, boolean isUrl) {
|
||||
buildRow(view, getRowIcon(iconId), text, textPrefix, collapsable, collapsableView, textColor,
|
||||
buildRow(view, iconId == 0 ? null : getRowIcon(iconId), text, textPrefix, collapsable, collapsableView, textColor,
|
||||
isWiki, isText, needLinks, isPhoneNumber, isUrl);
|
||||
}
|
||||
|
||||
|
@ -102,20 +104,22 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
baseView.addView(ll);
|
||||
|
||||
// Icon
|
||||
LinearLayout llIcon = new LinearLayout(view.getContext());
|
||||
llIcon.setOrientation(LinearLayout.HORIZONTAL);
|
||||
llIcon.setLayoutParams(new LinearLayout.LayoutParams(dpToPx(64f), dpToPx(48f)));
|
||||
llIcon.setGravity(Gravity.CENTER_VERTICAL);
|
||||
ll.addView(llIcon);
|
||||
if (icon != null) {
|
||||
LinearLayout llIcon = new LinearLayout(view.getContext());
|
||||
llIcon.setOrientation(LinearLayout.HORIZONTAL);
|
||||
llIcon.setLayoutParams(new LinearLayout.LayoutParams(dpToPx(64f), dpToPx(48f)));
|
||||
llIcon.setGravity(Gravity.CENTER_VERTICAL);
|
||||
ll.addView(llIcon);
|
||||
|
||||
ImageView iconView = new ImageView(view.getContext());
|
||||
LinearLayout.LayoutParams llIconParams = new LinearLayout.LayoutParams(dpToPx(24f), dpToPx(24f));
|
||||
llIconParams.setMargins(dpToPx(16f), dpToPx(12f), dpToPx(24f), dpToPx(12f));
|
||||
llIconParams.gravity = Gravity.CENTER_VERTICAL;
|
||||
iconView.setLayoutParams(llIconParams);
|
||||
iconView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
||||
iconView.setImageDrawable(icon);
|
||||
llIcon.addView(iconView);
|
||||
ImageView iconView = new ImageView(view.getContext());
|
||||
LinearLayout.LayoutParams llIconParams = new LinearLayout.LayoutParams(dpToPx(24f), dpToPx(24f));
|
||||
llIconParams.setMargins(dpToPx(16f), dpToPx(12f), dpToPx(24f), dpToPx(12f));
|
||||
llIconParams.gravity = Gravity.CENTER_VERTICAL;
|
||||
iconView.setLayoutParams(llIconParams);
|
||||
iconView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
||||
iconView.setImageDrawable(icon);
|
||||
llIcon.addView(iconView);
|
||||
}
|
||||
|
||||
// Text
|
||||
LinearLayout llText = new LinearLayout(view.getContext());
|
||||
|
@ -124,7 +128,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
|
||||
TextView textView = new TextView(view.getContext());
|
||||
LinearLayout.LayoutParams llTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
llTextParams.setMargins(0, collapsable ? dpToPx(13f) : dpToPx(8f), 0, collapsable ? dpToPx(13f) : dpToPx(8f));
|
||||
llTextParams.setMargins(icon == null ? dpToPx(16f) : 0, collapsable ? dpToPx(13f) : dpToPx(8f), 0, collapsable ? dpToPx(13f) : 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));
|
||||
|
@ -204,21 +208,43 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
}
|
||||
|
||||
if (isWiki) {
|
||||
AppCompatButton wikiButton = new AppCompatButton(view.getContext());
|
||||
LinearLayout.LayoutParams llWikiButtonParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
llWikiButtonParams.setMargins(0, dpToPx(10f), dpToPx(2f), dpToPx(10f));
|
||||
wikiButton.setLayoutParams(llWikiButtonParams);
|
||||
wikiButton.setPadding(dpToPx(14f), 0, dpToPx(14f), 0);
|
||||
wikiButton.setBackgroundResource(R.drawable.blue_button_drawable);
|
||||
wikiButton.setTextColor(Color.WHITE);
|
||||
wikiButton.setText(app.getString(R.string.read_more));
|
||||
wikiButton.setOnClickListener(new View.OnClickListener() {
|
||||
TextViewEx button = new TextViewEx(new ContextThemeWrapper(view.getContext(), light ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme));
|
||||
LinearLayout.LayoutParams llWikiButtonParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, dpToPx(36f));
|
||||
llWikiButtonParams.setMargins(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 = new ColorStateList(
|
||||
new int[][] {
|
||||
new int[]{android.R.attr.state_pressed},
|
||||
new int[]{}
|
||||
},
|
||||
new int[] {
|
||||
view.getResources().getColor(light ? R.color.ctx_menu_controller_button_text_color_light_p : R.color.ctx_menu_controller_button_text_color_dark_p),
|
||||
view.getResources().getColor(light ? R.color.ctx_menu_controller_button_text_color_light_n : R.color.ctx_menu_controller_button_text_color_dark_n)
|
||||
}
|
||||
);
|
||||
button.setTextColor(buttonColorStateList);
|
||||
button.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
|
||||
button.setSingleLine(true);
|
||||
button.setEllipsize(TextUtils.TruncateAt.END);
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
public void onClick(View view) {
|
||||
POIMapLayer.showWikipediaDialog(view.getContext(), app, amenity);
|
||||
}
|
||||
});
|
||||
llText.addView(wikiButton);
|
||||
button.setAllCaps(true);
|
||||
button.setText(R.string.context_menu_read_full_article);
|
||||
Drawable compoundDrawable = app.getIconsCache().getIcon(R.drawable.ic_action_note_dark, light ? R.color.ctx_menu_controller_button_text_color_light_n : R.color.ctx_menu_controller_button_text_color_dark_n);
|
||||
button.setCompoundDrawablesWithIntrinsicBounds(compoundDrawable, null, null, null);
|
||||
button.setCompoundDrawablePadding(dpToPx(8f));
|
||||
llText.addView(button);
|
||||
|
||||
matchWidthDivider = true;
|
||||
}
|
||||
|
||||
((LinearLayout) view).addView(baseView);
|
||||
|
@ -284,7 +310,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
List<AmenityInfoRow> descriptions = new LinkedList<>();
|
||||
|
||||
for (Map.Entry<String, String> e : amenity.getAdditionalInfo().entrySet()) {
|
||||
int iconId;
|
||||
int iconId = 0;
|
||||
Drawable icon = null;
|
||||
int textColor = 0;
|
||||
String key = e.getKey();
|
||||
|
@ -322,7 +348,6 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
|
||||
if (amenity.getType().isWiki()) {
|
||||
if (!hasWiki) {
|
||||
iconId = R.drawable.ic_action_note_dark;
|
||||
String lng = amenity.getContentLanguage("content", preferredLang, "en");
|
||||
if (Algorithms.isEmpty(lng)) {
|
||||
lng = "en";
|
||||
|
@ -507,7 +532,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
if (info.icon != null) {
|
||||
buildRow(view, info.icon, info.text, info.textPrefix, info.collapsable, info.collapsableView,
|
||||
info.textColor, info.isWiki, info.isText, info.needLinks, info.isPhoneNumber, info.isUrl);
|
||||
} else if (info.iconId != 0) {
|
||||
} else {
|
||||
buildRow(view, info.iconId, info.text, info.textPrefix, info.collapsable, info.collapsableView,
|
||||
info.textColor, info.isWiki, info.isText, info.needLinks, info.isPhoneNumber, info.isUrl);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue