Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2018-01-20 04:06:28 +01:00
commit 4c20ae48e6
18 changed files with 149 additions and 48 deletions

View file

@ -59,9 +59,9 @@ public class OpeningHoursParser {
for (int i = 0; i < strings.length; i++) { for (int i = 0; i < strings.length; i++) {
if (strings[i] != null) { if (strings[i] != null) {
if (strings[i].length() > 2) { if (strings[i].length() > 2) {
newStrings[i] = strings[i].substring(0, 2); newStrings[i] = Algorithms.capitalizeFirstLetter(strings[i].substring(0, 2));
} else { } else {
newStrings[i] = strings[i]; newStrings[i] = Algorithms.capitalizeFirstLetter(strings[i]);
} }
} }
} }

View file

@ -4,7 +4,8 @@
android:layout_width="@dimen/context_img_card_width" android:layout_width="@dimen/context_img_card_width"
android:layout_height="@dimen/context_img_card_height" android:layout_height="@dimen/context_img_card_height"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="?attr/bg_color" xmlns:tools="http://schemas.android.com/tools"
tools:background="?attr/bg_color"
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView
@ -17,7 +18,7 @@
android:maxLines="4" android:maxLines="4"
android:gravity="center" android:gravity="center"
android:ellipsize="end" android:ellipsize="end"
android:textColor="?android:textColorPrimary" tools:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size" android:textSize="@dimen/default_list_text_size"
android:text="@string/mapillary_action_descr"/> android:text="@string/mapillary_action_descr"/>
@ -38,8 +39,9 @@
android:text="@string/shared_string_add_photos"/> android:text="@string/shared_string_add_photos"/>
<View <View
android:id="@+id/card_background"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/context_menu_card"/> tools:background="?attr/context_menu_card"/>
</FrameLayout> </FrameLayout>

View file

@ -80,6 +80,7 @@
android:visibility="gone"/> android:visibility="gone"/>
<View <View
android:id="@+id/card_background"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/context_menu_card"/> android:background="?attr/context_menu_card"/>

View file

@ -4,7 +4,8 @@
android:layout_width="@dimen/context_img_card_width" android:layout_width="@dimen/context_img_card_width"
android:layout_height="@dimen/context_img_card_height" android:layout_height="@dimen/context_img_card_height"
xmlns:osmand="http://schemas.android.com/apk/res-auto" xmlns:osmand="http://schemas.android.com/apk/res-auto"
android:background="?attr/bg_color" xmlns:tools="http://schemas.android.com/tools"
tools:background="?attr/bg_color"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout
@ -14,11 +15,12 @@
android:orientation="horizontal"> android:orientation="horizontal">
<android.support.v7.widget.AppCompatImageView <android.support.v7.widget.AppCompatImageView
android:id="@+id/icon_sadface"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:tint="?attr/primary_icon_color" tools:tint="?attr/primary_icon_color"
android:src="@drawable/ic_action_sadface"/> tools:src="@drawable/ic_action_sadface"/>
<TextView <TextView
android:id="@+id/title" android:id="@+id/title"
@ -30,17 +32,18 @@
android:maxLines="4" android:maxLines="4"
android:gravity="center_vertical" android:gravity="center_vertical"
android:ellipsize="end" android:ellipsize="end"
android:textColor="?android:textColorPrimary" tools:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size" android:textSize="@dimen/default_list_text_size"
android:text="@string/no_photos_descr"/> android:text="@string/no_photos_descr"/>
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/button_background"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:background="?attr/ctx_menu_card_btn" tools:background="?attr/ctx_menu_card_btn"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout
@ -57,20 +60,22 @@
android:orientation="horizontal"> android:orientation="horizontal">
<android.support.v7.widget.AppCompatImageView <android.support.v7.widget.AppCompatImageView
android:id="@+id/icon_add_photos"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:tint="?attr/color_dialog_buttons" tools:tint="?attr/color_dialog_buttons"
android:src="@drawable/ic_action_add_photos"/> tools:src="@drawable/ic_action_add_photos"/>
<net.osmand.plus.widgets.TextViewEx <net.osmand.plus.widgets.TextViewEx
android:id="@+id/app_photos_text_view"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="16dp" android:layout_marginLeft="16dp"
osmand:textAllCapsCompat="true" osmand:textAllCapsCompat="true"
osmand:typeface="@string/font_roboto_medium" osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size" android:textSize="@dimen/default_desc_text_size"
android:textColor="?attr/color_dialog_buttons" tools:textColor="?attr/color_dialog_buttons"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:text="@string/shared_string_add_photos"/> android:text="@string/shared_string_add_photos"/>
@ -81,8 +86,9 @@
</LinearLayout> </LinearLayout>
<View <View
android:id="@+id/card_background"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/context_menu_card"/> tools:background="?attr/context_menu_card"/>
</FrameLayout> </FrameLayout>

View file

@ -1,11 +1,12 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="@dimen/context_img_card_width" android:layout_width="@dimen/context_img_card_width"
android:layout_height="@dimen/context_img_card_height" android:layout_height="@dimen/context_img_card_height"
android:background="?attr/bg_card"
android:gravity="center" android:gravity="center"
android:orientation="vertical"> android:orientation="vertical"
tools:background="?attr/bg_card">
<ProgressBar <ProgressBar
android:id="@+id/progress" android:id="@+id/progress"

View file

@ -354,6 +354,8 @@
<color name="ctx_menu_bottom_view_url_color_dark">#d28521</color> <color name="ctx_menu_bottom_view_url_color_dark">#d28521</color>
<color name="ctx_menu_controller_disabled_text_color_light">#b3b3b3</color> <color name="ctx_menu_controller_disabled_text_color_light">#b3b3b3</color>
<color name="ctx_menu_controller_disabled_text_color_dark">#666666</color> <color name="ctx_menu_controller_disabled_text_color_dark">#666666</color>
<color name="ctx_menu_collapse_icon_color_light">#727272</color>
<color name="ctx_menu_collapse_icon_color_dark">#a6a6a6</color>
<color name="route_info_bg_light">#ffffff</color> <color name="route_info_bg_light">#ffffff</color>
<color name="route_info_bg_dark">#17191a</color> <color name="route_info_bg_dark">#17191a</color>

View file

@ -15,8 +15,12 @@ import android.os.IBinder;
import android.support.annotation.ColorRes; import android.support.annotation.ColorRes;
import android.support.annotation.DrawableRes; import android.support.annotation.DrawableRes;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextPaint;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.format.DateFormat; import android.text.format.DateFormat;
import android.text.style.URLSpan;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.View; import android.view.View;
@ -92,6 +96,24 @@ public class AndroidUtils {
return src; return src;
} }
public static void removeLinkUnderline(TextView textView) {
Spannable s = new SpannableString(textView.getText());
for (URLSpan span : s.getSpans(0, s.length(), URLSpan.class)) {
int start = s.getSpanStart(span);
int end = s.getSpanEnd(span);
s.removeSpan(span);
span = new URLSpan(span.getURL()) {
@Override
public void updateDrawState(TextPaint ds) {
super.updateDrawState(ds);
ds.setUnderlineText(false);
}
};
s.setSpan(span, start, end, 0);
}
textView.setText(s);
}
public static String formatDate(Context ctx, long time) { public static String formatDate(Context ctx, long time) {
return DateFormat.getDateFormat(ctx).format(new Date(time)); return DateFormat.getDateFormat(ctx).format(new Date(time));
} }

View file

@ -378,6 +378,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
@Nullable PointDescription pointDescription, @Nullable PointDescription pointDescription,
@Nullable Object object) { @Nullable Object object) {
if (init(latLon, pointDescription, object)) { if (init(latLon, pointDescription, object)) {
mapActivity.getMyApplication().logEvent(mapActivity, "open_context_menu");
showInternal(); showInternal();
} }
} }

View file

@ -309,7 +309,7 @@ public class MenuBuilder {
buildNearestPhotosRow(view); buildNearestPhotosRow(view);
} }
buildPluginRows(view); buildPluginRows(view);
buildAfter(view); // buildAfter(view);
} }
private boolean showTransportRoutes() { private boolean showTransportRoutes() {
@ -517,11 +517,15 @@ public class MenuBuilder {
textView.setTextSize(16); textView.setTextSize(16);
textView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_bottom_view_text_color_light : R.color.ctx_menu_bottom_view_text_color_dark)); textView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_bottom_view_text_color_light : R.color.ctx_menu_bottom_view_text_color_dark));
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);
if (isUrl) { if (isUrl) {
textView.setTextColor(ContextCompat.getColor(view.getContext(), light ? R.color.ctx_menu_bottom_view_url_color_light : R.color.ctx_menu_bottom_view_url_color_dark)); textView.setTextColor(linkTextColor);
} else if (needLinks) { } else if (needLinks) {
textView.setAutoLinkMask(Linkify.ALL); Linkify.addLinks(textView, Linkify.ALL);
textView.setLinksClickable(true); textView.setLinksClickable(true);
textView.setLinkTextColor(linkTextColor);
AndroidUtils.removeLinkUnderline(textView);
} }
if (textLinesLimit > 0) { if (textLinesLimit > 0) {
textView.setMinLines(1); textView.setMinLines(1);
@ -574,8 +578,7 @@ public class MenuBuilder {
llIconCollapseParams.gravity = Gravity.CENTER_VERTICAL; llIconCollapseParams.gravity = Gravity.CENTER_VERTICAL;
iconViewCollapse.setLayoutParams(llIconCollapseParams); iconViewCollapse.setLayoutParams(llIconCollapseParams);
iconViewCollapse.setScaleType(ImageView.ScaleType.CENTER_INSIDE); iconViewCollapse.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
iconViewCollapse.setImageDrawable(app.getIconsCache().getIcon(collapsableView.getContenView().getVisibility() == View.GONE ? iconViewCollapse.setImageDrawable(getCollapseIcon(collapsableView.getContenView().getVisibility() == View.GONE));
R.drawable.ic_action_arrow_down : R.drawable.ic_action_arrow_up, light ? R.color.ctx_menu_bottom_view_icon_light : R.color.ctx_menu_bottom_view_icon_dark));
llIconCollapse.addView(iconViewCollapse); llIconCollapse.addView(iconViewCollapse);
ll.setOnClickListener(new View.OnClickListener() { ll.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -583,17 +586,17 @@ public class MenuBuilder {
if (collapsableView.getContenView().getVisibility() == View.VISIBLE) { if (collapsableView.getContenView().getVisibility() == View.VISIBLE) {
collapsableView.setCollapsed(true); collapsableView.setCollapsed(true);
collapsableView.getContenView().setVisibility(View.GONE); collapsableView.getContenView().setVisibility(View.GONE);
iconViewCollapse.setImageDrawable(app.getIconsCache().getIcon(R.drawable.ic_action_arrow_down, light ? R.color.ctx_menu_bottom_view_icon_light : R.color.ctx_menu_bottom_view_icon_dark)); iconViewCollapse.setImageDrawable(getCollapseIcon(true));
} else { } else {
collapsableView.setCollapsed(false); collapsableView.setCollapsed(false);
collapsableView.getContenView().setVisibility(View.VISIBLE); collapsableView.getContenView().setVisibility(View.VISIBLE);
iconViewCollapse.setImageDrawable(app.getIconsCache().getIcon(R.drawable.ic_action_arrow_up, light ? R.color.ctx_menu_bottom_view_icon_light : R.color.ctx_menu_bottom_view_icon_dark)); iconViewCollapse.setImageDrawable(getCollapseIcon(false));
} }
} }
}); });
if (collapsableView.isCollapsed()) { if (collapsableView.isCollapsed()) {
collapsableView.getContenView().setVisibility(View.GONE); collapsableView.getContenView().setVisibility(View.GONE);
iconViewCollapse.setImageDrawable(app.getIconsCache().getIcon(R.drawable.ic_action_arrow_down, light ? R.color.ctx_menu_bottom_view_icon_light : R.color.ctx_menu_bottom_view_icon_dark)); iconViewCollapse.setImageDrawable(getCollapseIcon(true));
} }
baseView.addView(collapsableView.getContenView()); baseView.addView(collapsableView.getContenView());
} }
@ -734,6 +737,11 @@ public class MenuBuilder {
); );
} }
public Drawable getCollapseIcon(boolean collapsed) {
return app.getIconsCache().getIcon(collapsed ? R.drawable.ic_action_arrow_down : R.drawable.ic_action_arrow_up,
light ? R.color.ctx_menu_collapse_icon_color_light : R.color.ctx_menu_collapse_icon_color_dark);
}
private View buildTransportRowItem(View view, TransportStopRoute route, OnClickListener listener) { private View buildTransportRowItem(View view, TransportStopRoute route, OnClickListener listener) {
LinearLayout baseView = new LinearLayout(view.getContext()); LinearLayout baseView = new LinearLayout(view.getContext());
baseView.setOrientation(LinearLayout.HORIZONTAL); baseView.setOrientation(LinearLayout.HORIZONTAL);
@ -796,6 +804,7 @@ public class MenuBuilder {
LinearLayout.LayoutParams typeTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); LinearLayout.LayoutParams typeTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
typeTextView.setLayoutParams(typeTextParams); typeTextView.setLayoutParams(typeTextParams);
typeTextView.setText(route.getTypeStrRes()); typeTextView.setText(route.getTypeStrRes());
AndroidUtils.setTextSecondaryColor(getMapActivity(), typeTextView, getApplication().getDaynightHelper().isNightModeForMapControls());
typeView.addView(typeTextView); typeView.addView(typeTextView);
baseView.setOnClickListener(listener); baseView.setOnClickListener(listener);

View file

@ -3,6 +3,7 @@ package net.osmand.plus.mapcontextmenu;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.graphics.drawable.StateListDrawable; import android.graphics.drawable.StateListDrawable;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Build;
import android.support.annotation.DrawableRes; import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
@ -594,12 +595,13 @@ public abstract class MenuController extends BaseMenuController {
} }
public void updateStateListDrawableIcon(@DrawableRes int resId, boolean left) { public void updateStateListDrawableIcon(@DrawableRes int resId, boolean left) {
boolean useStateList = enabled && Build.VERSION.SDK_INT >= 21;
if (left) { if (left) {
leftIcon = enabled ? getStateListDrawable(resId) : null; leftIcon = useStateList ? getStateListDrawable(resId) : null;
leftIconId = enabled ? 0 : resId; leftIconId = useStateList ? 0 : resId;
} else { } else {
rightIcon = enabled ? getStateListDrawable(resId) : null; rightIcon = useStateList ? getStateListDrawable(resId) : null;
rightIconId = enabled ? 0 : resId; rightIconId = useStateList ? 0 : resId;
} }
} }

View file

@ -5,6 +5,8 @@ import android.content.Intent;
import android.content.res.ColorStateList; 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.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.support.v7.view.ContextThemeWrapper; import android.support.v7.view.ContextThemeWrapper;
import android.text.Html; import android.text.Html;
@ -135,19 +137,29 @@ public class AmenityMenuBuilder extends MenuBuilder {
textView.setTextSize(16); textView.setTextSize(16);
textView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_bottom_view_text_color_light : R.color.ctx_menu_bottom_view_text_color_dark)); textView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_bottom_view_text_color_light : R.color.ctx_menu_bottom_view_text_color_dark));
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);
boolean textDefined = false; boolean textDefined = false;
if (isPhoneNumber || isUrl) { if (isPhoneNumber || isUrl) {
if (!Algorithms.isEmpty(textPrefix)) { if (!Algorithms.isEmpty(textPrefix)) {
SpannableString spannableString = new SpannableString(txt); SpannableString spannableString = new SpannableString(txt);
spannableString.setSpan(new URLSpan(txt), textPrefix.length() + 2, txt.length(), 0); spannableString.setSpan(new URLSpan(txt), textPrefix.length() + 2, txt.length(), 0);
textView.setText(spannableString); textView.setText(spannableString);
textView.setLinkTextColor(linkTextColor);
textDefined = true; textDefined = true;
} else { } else {
textView.setTextColor(textView.getLinkTextColors()); textView.setTextColor(linkTextColor);
} }
} else if (needLinks) { needLinks = false;
textView.setAutoLinkMask(Linkify.ALL); }
if (!textDefined) {
textView.setText(txt);
}
if (needLinks) {
Linkify.addLinks(textView, Linkify.ALL);
textView.setLinksClickable(true); textView.setLinksClickable(true);
textView.setLinkTextColor(linkTextColor);
AndroidUtils.removeLinkUnderline(textView);
} }
textView.setEllipsize(TextUtils.TruncateAt.END); textView.setEllipsize(TextUtils.TruncateAt.END);
if (isWiki) { if (isWiki) {
@ -157,9 +169,6 @@ public class AmenityMenuBuilder extends MenuBuilder {
textView.setMinLines(1); textView.setMinLines(1);
textView.setMaxLines(10); textView.setMaxLines(10);
} }
if (!textDefined) {
textView.setText(txt);
}
if (textColor > 0) { if (textColor > 0) {
textView.setTextColor(view.getResources().getColor(textColor)); textView.setTextColor(view.getResources().getColor(textColor));
} }
@ -185,8 +194,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
llIconCollapseParams.gravity = Gravity.CENTER_VERTICAL; llIconCollapseParams.gravity = Gravity.CENTER_VERTICAL;
iconViewCollapse.setLayoutParams(llIconCollapseParams); iconViewCollapse.setLayoutParams(llIconCollapseParams);
iconViewCollapse.setScaleType(ImageView.ScaleType.CENTER_INSIDE); iconViewCollapse.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
iconViewCollapse.setImageDrawable(app.getIconsCache().getThemedIcon(collapsableView.getContenView().getVisibility() == View.GONE ? iconViewCollapse.setImageDrawable(getCollapseIcon(collapsableView.getContenView().getVisibility() == View.GONE));
R.drawable.ic_action_arrow_down : R.drawable.ic_action_arrow_up));
llIconCollapse.addView(iconViewCollapse); llIconCollapse.addView(iconViewCollapse);
ll.setOnClickListener(new View.OnClickListener() { ll.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -194,17 +202,17 @@ public class AmenityMenuBuilder extends MenuBuilder {
if (collapsableView.getContenView().getVisibility() == View.VISIBLE) { if (collapsableView.getContenView().getVisibility() == View.VISIBLE) {
collapsableView.setCollapsed(true); collapsableView.setCollapsed(true);
collapsableView.getContenView().setVisibility(View.GONE); collapsableView.getContenView().setVisibility(View.GONE);
iconViewCollapse.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_arrow_down)); iconViewCollapse.setImageDrawable(getCollapseIcon(true));
} else { } else {
collapsableView.setCollapsed(false); collapsableView.setCollapsed(false);
collapsableView.getContenView().setVisibility(View.VISIBLE); collapsableView.getContenView().setVisibility(View.VISIBLE);
iconViewCollapse.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_arrow_up)); iconViewCollapse.setImageDrawable(getCollapseIcon(false));
} }
} }
}); });
if (collapsableView.isCollapsed()) { if (collapsableView.isCollapsed()) {
collapsableView.getContenView().setVisibility(View.GONE); collapsableView.getContenView().setVisibility(View.GONE);
iconViewCollapse.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_arrow_down)); iconViewCollapse.setImageDrawable(getCollapseIcon(true));
} }
baseView.addView(collapsableView.getContenView()); baseView.addView(collapsableView.getContenView());
} }
@ -238,7 +246,8 @@ public class AmenityMenuBuilder extends MenuBuilder {
light ? R.color.ctx_menu_controller_button_text_color_light_n : R.color.ctx_menu_controller_button_text_color_dark_n); light ? R.color.ctx_menu_controller_button_text_color_light_n : R.color.ctx_menu_controller_button_text_color_dark_n);
Drawable pressed = app.getIconsCache().getIcon(R.drawable.ic_action_read_text, Drawable pressed = app.getIconsCache().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); light ? R.color.ctx_menu_controller_button_text_color_light_p : R.color.ctx_menu_controller_button_text_color_dark_p);
button.setCompoundDrawablesWithIntrinsicBounds(AndroidUtils.createStateListDrawable(normal, pressed), null, null, null); button.setCompoundDrawablesWithIntrinsicBounds(Build.VERSION.SDK_INT >= 21
? AndroidUtils.createStateListDrawable(normal, pressed) : normal, null, null, null);
button.setCompoundDrawablePadding(dpToPx(8f)); button.setCompoundDrawablePadding(dpToPx(8f));
llText.addView(button); llText.addView(button);
} }

View file

@ -14,6 +14,7 @@ import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.AndroidNetworkUtils; import net.osmand.AndroidNetworkUtils;
import net.osmand.AndroidUtils;
import net.osmand.Location; import net.osmand.Location;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
@ -322,6 +323,10 @@ public abstract class ImageCard extends AbstractCard {
ProgressBar progress = (ProgressBar) view.findViewById(R.id.progress); ProgressBar progress = (ProgressBar) view.findViewById(R.id.progress);
AppCompatButton button = (AppCompatButton) view.findViewById(R.id.button); AppCompatButton button = (AppCompatButton) view.findViewById(R.id.button);
boolean night = getMyApplication().getDaynightHelper().isNightModeForMapControls();
AndroidUtils.setBackground(getMapActivity(), view.findViewById(R.id.card_background), night,
R.drawable.context_menu_card_light, R.drawable.context_menu_card_dark);
if (icon == null && topIconId != 0) { if (icon == null && topIconId != 0) {
icon = getMyApplication().getIconsCache().getIcon(topIconId); icon = getMyApplication().getIconsCache().getIcon(topIconId);
} }

View file

@ -1,7 +1,12 @@
package net.osmand.plus.mapcontextmenu.builders.cards; package net.osmand.plus.mapcontextmenu.builders.cards;
import android.support.v4.content.ContextCompat;
import android.view.View; import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.plus.IconsCache;
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.mapillary.MapillaryPlugin; import net.osmand.plus.mapillary.MapillaryPlugin;
@ -20,6 +25,21 @@ public class NoImagesCard extends AbstractCard {
@Override @Override
public void update() { public void update() {
if (view != null) { if (view != null) {
IconsCache ic = getMyApplication().getIconsCache();
boolean night = getMyApplication().getDaynightHelper().isNightModeForMapControls();
MapActivity ctx = getMapActivity();
AndroidUtils.setBackgroundColor(ctx, view, night, R.color.bg_color_light, R.color.bg_color_dark);
((ImageView) view.findViewById(R.id.icon_sadface)).setImageDrawable(ic.getIcon(R.drawable.ic_action_sadface,
night ? R.color.color_white : R.color.icon_color));
AndroidUtils.setTextPrimaryColor(ctx, (TextView) view.findViewById(R.id.title), night);
AndroidUtils.setBackgroundColor(ctx, view.findViewById(R.id.button_background), night,
R.color.ctx_menu_card_btn_light, R.color.ctx_menu_card_btn_dark);
((ImageView) view.findViewById(R.id.icon_add_photos)).setImageDrawable(ic.getIcon(R.drawable.ic_action_add_photos,
night ? R.color.color_dialog_buttons_dark : R.color.color_dialog_buttons_light));
((TextView) view.findViewById(R.id.app_photos_text_view)).setTextColor(ContextCompat.getColor(ctx,
night ? R.color.color_dialog_buttons_dark : R.color.color_dialog_buttons_light));
AndroidUtils.setBackground(ctx, view.findViewById(R.id.card_background), night,
R.drawable.context_menu_card_light, R.drawable.context_menu_card_dark);
view.findViewById(R.id.button).setOnClickListener(new View.OnClickListener() { view.findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {

View file

@ -1,5 +1,6 @@
package net.osmand.plus.mapcontextmenu.builders.cards; package net.osmand.plus.mapcontextmenu.builders.cards;
import net.osmand.AndroidUtils;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
@ -16,5 +17,7 @@ public class ProgressCard extends AbstractCard {
@Override @Override
public void update() { public void update() {
boolean night = getMyApplication().getDaynightHelper().isNightModeForMapControls();
AndroidUtils.setBackgroundColor(getMapActivity(), view, night, R.color.bg_color_light, R.color.bg_color_dark);
} }
} }

View file

@ -5,6 +5,7 @@ import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.ShapeDrawable; import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.StateListDrawable; import android.graphics.drawable.StateListDrawable;
import android.graphics.drawable.shapes.OvalShape; import android.graphics.drawable.shapes.OvalShape;
import android.os.Build;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
@ -27,6 +28,7 @@ public class MapMarkerMenuController extends MenuController {
public MapMarkerMenuController(MapActivity mapActivity, PointDescription pointDescription, MapMarker mapMarker) { public MapMarkerMenuController(MapActivity mapActivity, PointDescription pointDescription, MapMarker mapMarker) {
super(new MenuBuilder(mapActivity), pointDescription, mapActivity); super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
final OsmandApplication app = mapActivity.getMyApplication(); final OsmandApplication app = mapActivity.getMyApplication();
final boolean useStateList = Build.VERSION.SDK_INT >= 21;
this.mapMarker = mapMarker; this.mapMarker = mapMarker;
builder.setShowNearestWiki(true); builder.setShowNearestWiki(true);
@ -39,7 +41,8 @@ public class MapMarkerMenuController extends MenuController {
} }
}; };
leftTitleButtonController.caption = getMapActivity().getString(R.string.mark_passed); leftTitleButtonController.caption = getMapActivity().getString(R.string.mark_passed);
leftTitleButtonController.leftIcon = createStateListPassedIcon(); leftTitleButtonController.leftIcon = useStateList ? createStateListPassedIcon()
: createPassedIcon(getPassedIconBgNormalColorId(), 0);
rightTitleButtonController = new TitleButtonController() { rightTitleButtonController = new TitleButtonController() {
@Override @Override
@ -54,16 +57,20 @@ public class MapMarkerMenuController extends MenuController {
} }
}; };
rightTitleButtonController.caption = getMapActivity().getString(R.string.make_active); rightTitleButtonController.caption = getMapActivity().getString(R.string.make_active);
rightTitleButtonController.leftIcon = createStateListShowOnTopbarIcon(); rightTitleButtonController.leftIcon = useStateList ? createStateListShowOnTopbarIcon()
: createShowOnTopbarIcon(getDeviceTopNormalColorId(), R.color.dashboard_blue);
}
private int getPassedIconBgNormalColorId() {
return isLight() ? R.color.map_widget_blue : R.color.osmand_orange;
} }
private StateListDrawable createStateListPassedIcon() { private StateListDrawable createStateListPassedIcon() {
int bgNormal = isLight() ? R.color.map_widget_blue : R.color.osmand_orange;
int bgPressed = isLight() ? R.color.ctx_menu_controller_button_text_color_light_p int bgPressed = isLight() ? R.color.ctx_menu_controller_button_text_color_light_p
: R.color.ctx_menu_controller_button_text_color_dark_p; : R.color.ctx_menu_controller_button_text_color_dark_p;
int icPressed = isLight() ? R.color.ctx_menu_controller_button_text_color_light_n int icPressed = isLight() ? R.color.ctx_menu_controller_button_text_color_light_n
: R.color.ctx_menu_controller_button_bg_color_dark_p; : R.color.ctx_menu_controller_button_bg_color_dark_p;
return AndroidUtils.createStateListDrawable(createPassedIcon(bgNormal, 0), return AndroidUtils.createStateListDrawable(createPassedIcon(getPassedIconBgNormalColorId(), 0),
createPassedIcon(bgPressed, icPressed)); createPassedIcon(bgPressed, icPressed));
} }
@ -74,12 +81,15 @@ public class MapMarkerMenuController extends MenuController {
return new LayerDrawable(new Drawable[]{bg, ic}); return new LayerDrawable(new Drawable[]{bg, ic});
} }
private int getDeviceTopNormalColorId() {
return isLight() ? R.color.on_map_icon_color : R.color.ctx_menu_info_text_dark;
}
private StateListDrawable createStateListShowOnTopbarIcon() { private StateListDrawable createStateListShowOnTopbarIcon() {
int bgNormal = isLight() ? R.color.on_map_icon_color : R.color.ctx_menu_info_text_dark;
int bgPressed = isLight() ? R.color.ctx_menu_controller_button_text_color_light_p int bgPressed = isLight() ? R.color.ctx_menu_controller_button_text_color_light_p
: R.color.ctx_menu_controller_button_text_color_dark_p; : R.color.ctx_menu_controller_button_text_color_dark_p;
int icPressed = isLight() ? R.color.osmand_orange : R.color.route_info_go_btn_bg_dark_p; int icPressed = isLight() ? R.color.osmand_orange : R.color.route_info_go_btn_bg_dark_p;
return AndroidUtils.createStateListDrawable(createShowOnTopbarIcon(bgNormal, R.color.dashboard_blue), return AndroidUtils.createStateListDrawable(createShowOnTopbarIcon(getDeviceTopNormalColorId(), R.color.dashboard_blue),
createShowOnTopbarIcon(bgPressed, icPressed)); createShowOnTopbarIcon(bgPressed, icPressed));
} }

View file

@ -1,7 +1,9 @@
package net.osmand.plus.mapillary; package net.osmand.plus.mapillary;
import android.view.View; import android.view.View;
import android.widget.TextView;
import net.osmand.AndroidUtils;
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.builders.cards.ImageCard; import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard;
@ -22,6 +24,12 @@ public class MapillaryContributeCard extends ImageCard {
@Override @Override
public void update() { public void update() {
if (view != null) { if (view != null) {
boolean night = getMyApplication().getDaynightHelper().isNightModeForMapControls();
MapActivity ctx = getMapActivity();
AndroidUtils.setBackgroundColor(ctx, view, night, R.color.bg_color_light, R.color.bg_color_dark);
AndroidUtils.setTextPrimaryColor(ctx, (TextView) view.findViewById(R.id.title), night);
AndroidUtils.setBackground(ctx, view.findViewById(R.id.card_background), night,
R.drawable.context_menu_card_light, R.drawable.context_menu_card_dark);
view.findViewById(R.id.button).setOnClickListener(new View.OnClickListener() { view.findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {

View file

@ -74,7 +74,7 @@ public class ParkingPositionMenuController extends MenuController {
@Override @Override
public int getAdditionalInfoColor() { public int getAdditionalInfoColor() {
return plugin.getParkingType() ? R.color.ctx_menu_amenity_closed_text_color : isLight() ? R.color.icon_color : R.color.dash_search_icon_dark; return plugin.getParkingType() ? R.color.ctx_menu_amenity_closed_text_color : R.color.icon_color;
} }
@Override @Override

View file

@ -248,7 +248,7 @@ public class ParkingPositionPlugin extends OsmandPlugin {
.setIcon(R.drawable.ic_action_time_span).setTag(2).createItem()); .setIcon(R.drawable.ic_action_time_span).setTag(2).createItem());
final AlertDialog.Builder builder = new AlertDialog.Builder(mapActivity); final AlertDialog.Builder builder = new AlertDialog.Builder(mapActivity);
boolean light = app.getSettings().isLightContent() && !app.getDaynightHelper().isNightMode(); boolean light = app.getSettings().isLightContent();
final ArrayAdapter<ContextMenuItem> listAdapter = menuAdapter.createListAdapter(mapActivity, light); final ArrayAdapter<ContextMenuItem> listAdapter = menuAdapter.createListAdapter(mapActivity, light);
builder.setTitle(R.string.parking_options); builder.setTitle(R.string.parking_options);
builder.setAdapter(listAdapter, new DialogInterface.OnClickListener() { builder.setAdapter(listAdapter, new DialogInterface.OnClickListener() {