Change wiki buttons

This commit is contained in:
PavelRatushny 2017-12-11 17:03:12 +02:00
parent e82bdf6089
commit f887f434a4

View file

@ -3,6 +3,7 @@ package net.osmand.plus.mapcontextmenu;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.res.ColorStateList;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
@ -10,7 +11,6 @@ import android.net.Uri;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v7.view.ContextThemeWrapper; import android.support.v7.view.ContextThemeWrapper;
import android.support.v7.widget.AppCompatButton;
import android.text.ClipboardManager; import android.text.ClipboardManager;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.util.Linkify; import android.text.util.Linkify;
@ -685,18 +685,29 @@ public class MenuBuilder {
view.setOrientation(LinearLayout.VERTICAL); view.setOrientation(LinearLayout.VERTICAL);
view.setVisibility(collapsed ? View.GONE : View.VISIBLE); view.setVisibility(collapsed ? View.GONE : View.VISIBLE);
LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
llParams.setMargins(dpToPx(68f), 0, dpToPx(12f), dpToPx(13f)); llParams.setMargins(dpToPx(68f), 0, dpToPx(12f), 0);
view.setLayoutParams(llParams); view.setLayoutParams(llParams);
ColorStateList buttonColorStateList = new ColorStateList(
new int[][] {
new int[]{android.R.attr.state_pressed},
new int[]{}
},
new int[] {
context.getResources().getColor(light ? R.color.ctx_menu_controller_button_text_color_light_p : R.color.ctx_menu_controller_button_text_color_dark_p),
context.getResources().getColor(light ? R.color.ctx_menu_controller_button_text_color_light_n : R.color.ctx_menu_controller_button_text_color_dark_n)
}
);
for (final Amenity wiki : nearestWiki) { for (final Amenity wiki : nearestWiki) {
AppCompatButton wikiButton = new AppCompatButton( TextViewEx wikiButton = new TextViewEx(new ContextThemeWrapper(view.getContext(), light ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme));
new ContextThemeWrapper(view.getContext(), 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 = llWikiButtonParams.setMargins(0, 0, 0, dpToPx(8f));
new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
wikiButton.setLayoutParams(llWikiButtonParams); wikiButton.setLayoutParams(llWikiButtonParams);
wikiButton.setPadding(dpToPx(14f), 0, dpToPx(14f), 0); wikiButton.setTypeface(FontCache.getRobotoMedium(context));
wikiButton.setTextColor(app.getResources() wikiButton.setBackgroundResource(light ? R.drawable.context_menu_controller_bg_light : R.drawable.context_menu_controller_bg_dark);
.getColor(light ? R.color.color_dialog_buttons_light : R.color.color_dialog_buttons_dark)); int paddingSides = (int) context.getResources().getDimension(R.dimen.context_menu_button_padding_x);
wikiButton.setPadding(paddingSides, 0, paddingSides, 0);
wikiButton.setTextColor(buttonColorStateList);
wikiButton.setText(wiki.getName(preferredMapAppLang, transliterateNames)); wikiButton.setText(wiki.getName(preferredMapAppLang, transliterateNames));
wikiButton.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); wikiButton.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);