From 3a9c9d3be76d08a781447335ed100058e3b120d8 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Thu, 18 Jan 2018 13:58:20 +0200 Subject: [PATCH 01/15] Do not use StateListDrawable with API < 21 --- .../plus/mapcontextmenu/MenuController.java | 10 +++++---- .../builders/AmenityMenuBuilder.java | 4 +++- .../controllers/MapMarkerMenuController.java | 22 ++++++++++++++----- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java index 4bda4d120e..c02974f397 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java @@ -3,6 +3,7 @@ package net.osmand.plus.mapcontextmenu; import android.graphics.drawable.Drawable; import android.graphics.drawable.StateListDrawable; import android.os.AsyncTask; +import android.os.Build; import android.support.annotation.DrawableRes; import android.support.annotation.NonNull; import android.support.annotation.Nullable; @@ -594,12 +595,13 @@ public abstract class MenuController extends BaseMenuController { } public void updateStateListDrawableIcon(@DrawableRes int resId, boolean left) { + boolean useStateList = enabled && Build.VERSION.SDK_INT >= 21; if (left) { - leftIcon = enabled ? getStateListDrawable(resId) : null; - leftIconId = enabled ? 0 : resId; + leftIcon = useStateList ? getStateListDrawable(resId) : null; + leftIconId = useStateList ? 0 : resId; } else { - rightIcon = enabled ? getStateListDrawable(resId) : null; - rightIconId = enabled ? 0 : resId; + rightIcon = useStateList ? getStateListDrawable(resId) : null; + rightIconId = useStateList ? 0 : resId; } } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java index 6fec9e2f51..5d716cc754 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java @@ -5,6 +5,7 @@ import android.content.Intent; import android.content.res.ColorStateList; import android.graphics.drawable.Drawable; import android.net.Uri; +import android.os.Build; import android.support.v7.app.AlertDialog; import android.support.v7.view.ContextThemeWrapper; import android.text.Html; @@ -238,7 +239,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); 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); - 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)); llText.addView(button); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapMarkerMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapMarkerMenuController.java index 89c5474b7b..1fdd4a7a44 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapMarkerMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapMarkerMenuController.java @@ -5,6 +5,7 @@ import android.graphics.drawable.LayerDrawable; import android.graphics.drawable.ShapeDrawable; import android.graphics.drawable.StateListDrawable; import android.graphics.drawable.shapes.OvalShape; +import android.os.Build; import android.support.v4.content.ContextCompat; import net.osmand.AndroidUtils; @@ -27,6 +28,7 @@ public class MapMarkerMenuController extends MenuController { public MapMarkerMenuController(MapActivity mapActivity, PointDescription pointDescription, MapMarker mapMarker) { super(new MenuBuilder(mapActivity), pointDescription, mapActivity); final OsmandApplication app = mapActivity.getMyApplication(); + final boolean useStateList = Build.VERSION.SDK_INT >= 21; this.mapMarker = mapMarker; builder.setShowNearestWiki(true); @@ -39,7 +41,8 @@ public class MapMarkerMenuController extends MenuController { } }; leftTitleButtonController.caption = getMapActivity().getString(R.string.mark_passed); - leftTitleButtonController.leftIcon = createStateListPassedIcon(); + leftTitleButtonController.leftIcon = useStateList ? createStateListPassedIcon() + : createPassedIcon(getPassedIconBgNormalColorId(), 0); rightTitleButtonController = new TitleButtonController() { @Override @@ -54,16 +57,20 @@ public class MapMarkerMenuController extends MenuController { } }; 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() { - 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 : R.color.ctx_menu_controller_button_text_color_dark_p; int icPressed = isLight() ? R.color.ctx_menu_controller_button_text_color_light_n : 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)); } @@ -74,12 +81,15 @@ public class MapMarkerMenuController extends MenuController { 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() { - 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 : 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; - return AndroidUtils.createStateListDrawable(createShowOnTopbarIcon(bgNormal, R.color.dashboard_blue), + return AndroidUtils.createStateListDrawable(createShowOnTopbarIcon(getDeviceTopNormalColorId(), R.color.dashboard_blue), createShowOnTopbarIcon(bgPressed, icPressed)); } From f400f1b4fc4d67b0903d1b3db269d81aacac5fb7 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Thu, 18 Jan 2018 16:13:20 +0200 Subject: [PATCH 02/15] Fix night map mode colors in MapillaryContributeCard --- .../res/layout/context_menu_card_add_mapillary_images.xml | 8 +++++--- .../osmand/plus/mapillary/MapillaryContributeCard.java | 8 ++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/OsmAnd/res/layout/context_menu_card_add_mapillary_images.xml b/OsmAnd/res/layout/context_menu_card_add_mapillary_images.xml index a595029a4a..c671d89c90 100644 --- a/OsmAnd/res/layout/context_menu_card_add_mapillary_images.xml +++ b/OsmAnd/res/layout/context_menu_card_add_mapillary_images.xml @@ -4,7 +4,8 @@ android:layout_width="@dimen/context_img_card_width" android:layout_height="@dimen/context_img_card_height" 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"> @@ -38,8 +39,9 @@ android:text="@string/shared_string_add_photos"/> + tools:background="?attr/context_menu_card"/> \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryContributeCard.java b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryContributeCard.java index 7803ab52de..98b5065bf6 100644 --- a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryContributeCard.java +++ b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryContributeCard.java @@ -1,7 +1,9 @@ package net.osmand.plus.mapillary; import android.view.View; +import android.widget.TextView; +import net.osmand.AndroidUtils; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard; @@ -22,6 +24,12 @@ public class MapillaryContributeCard extends ImageCard { @Override public void update() { 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() { @Override public void onClick(View v) { From e9ba8e13474ae06bcba4915769affbcfee0fd01c Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Thu, 18 Jan 2018 16:37:50 +0200 Subject: [PATCH 03/15] Fix night map mode colors in NoImagesCard --- .../layout/context_menu_card_no_images.xml | 24 ++++++++++++------- .../builders/cards/NoImagesCard.java | 20 ++++++++++++++++ 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/OsmAnd/res/layout/context_menu_card_no_images.xml b/OsmAnd/res/layout/context_menu_card_no_images.xml index 1c357c02e3..1331423646 100644 --- a/OsmAnd/res/layout/context_menu_card_no_images.xml +++ b/OsmAnd/res/layout/context_menu_card_no_images.xml @@ -4,7 +4,8 @@ android:layout_width="@dimen/context_img_card_width" android:layout_height="@dimen/context_img_card_height" 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"> + tools:tint="?attr/primary_icon_color" + tools:src="@drawable/ic_action_sadface"/> + tools:tint="?attr/color_dialog_buttons" + tools:src="@drawable/ic_action_add_photos"/> @@ -81,8 +86,9 @@ + tools:background="?attr/context_menu_card"/> \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/NoImagesCard.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/NoImagesCard.java index 7b6f02fb70..9a0e493d10 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/NoImagesCard.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/NoImagesCard.java @@ -1,7 +1,12 @@ package net.osmand.plus.mapcontextmenu.builders.cards; +import android.support.v4.content.ContextCompat; 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.activities.MapActivity; import net.osmand.plus.mapillary.MapillaryPlugin; @@ -20,6 +25,21 @@ public class NoImagesCard extends AbstractCard { @Override public void update() { 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() { @Override public void onClick(View v) { From ce46697398e27cc6a8b58c731af45f73dca7a535 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Thu, 18 Jan 2018 16:51:31 +0200 Subject: [PATCH 04/15] Fix night map mode background in ImageCard --- OsmAnd/res/layout/context_menu_card_image.xml | 1 + .../osmand/plus/mapcontextmenu/builders/cards/ImageCard.java | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/OsmAnd/res/layout/context_menu_card_image.xml b/OsmAnd/res/layout/context_menu_card_image.xml index 5b835dcba6..fe2f2fefd7 100644 --- a/OsmAnd/res/layout/context_menu_card_image.xml +++ b/OsmAnd/res/layout/context_menu_card_image.xml @@ -80,6 +80,7 @@ android:visibility="gone"/> diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/ImageCard.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/ImageCard.java index 4e3d69b652..e4a6d2215c 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/ImageCard.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/ImageCard.java @@ -14,6 +14,7 @@ import android.widget.ProgressBar; import android.widget.TextView; import net.osmand.AndroidNetworkUtils; +import net.osmand.AndroidUtils; import net.osmand.Location; import net.osmand.data.LatLon; import net.osmand.plus.OsmandApplication; @@ -322,6 +323,10 @@ public abstract class ImageCard extends AbstractCard { ProgressBar progress = (ProgressBar) view.findViewById(R.id.progress); 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) { icon = getMyApplication().getIconsCache().getIcon(topIconId); } From c6be4b158b07192af489c0978ce4043e553140cd Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 18 Jan 2018 20:51:07 +0200 Subject: [PATCH 05/15] Do not underline links in context menu --- OsmAnd/src/net/osmand/AndroidUtils.java | 22 +++++++++++++++++++ .../builders/AmenityMenuBuilder.java | 13 ++++++----- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/OsmAnd/src/net/osmand/AndroidUtils.java b/OsmAnd/src/net/osmand/AndroidUtils.java index 37c6d0a803..04651fea6d 100644 --- a/OsmAnd/src/net/osmand/AndroidUtils.java +++ b/OsmAnd/src/net/osmand/AndroidUtils.java @@ -15,8 +15,12 @@ import android.os.IBinder; import android.support.annotation.ColorRes; import android.support.annotation.DrawableRes; 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.format.DateFormat; +import android.text.style.URLSpan; import android.util.DisplayMetrics; import android.util.TypedValue; import android.view.View; @@ -92,6 +96,24 @@ public class AndroidUtils { 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) { return DateFormat.getDateFormat(ctx).format(new Date(time)); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java index 5d716cc754..5c02c650e0 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java @@ -146,9 +146,15 @@ public class AmenityMenuBuilder extends MenuBuilder { } else { textView.setTextColor(textView.getLinkTextColors()); } - } else if (needLinks) { - textView.setAutoLinkMask(Linkify.ALL); + needLinks = false; + } + if (!textDefined) { + textView.setText(txt); + } + if (needLinks) { + Linkify.addLinks(textView, Linkify.ALL); textView.setLinksClickable(true); + AndroidUtils.removeLinkUnderline(textView); } textView.setEllipsize(TextUtils.TruncateAt.END); if (isWiki) { @@ -158,9 +164,6 @@ public class AmenityMenuBuilder extends MenuBuilder { textView.setMinLines(1); textView.setMaxLines(10); } - if (!textDefined) { - textView.setText(txt); - } if (textColor > 0) { textView.setTextColor(view.getResources().getColor(textColor)); } From 7b5d342bb411e7b1025bb33c72d0f1af8def551c Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 18 Jan 2018 22:20:42 +0200 Subject: [PATCH 06/15] Fix transport type text color --- OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java | 1 + 1 file changed, 1 insertion(+) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index cd43f295ec..0aae8670f8 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -796,6 +796,7 @@ public class MenuBuilder { LinearLayout.LayoutParams typeTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); typeTextView.setLayoutParams(typeTextParams); typeTextView.setText(route.getTypeStrRes()); + AndroidUtils.setTextSecondaryColor(getMapActivity(), typeTextView, getApplication().getDaynightHelper().isNightModeForMapControls()); typeView.addView(typeTextView); baseView.setOnClickListener(listener); From 34d2578cf622a7d212ae288d18eda64012d2af9a Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 19 Jan 2018 11:53:19 +0200 Subject: [PATCH 07/15] Fix night additional info color in parking position plugin --- .../osmand/plus/parkingpoint/ParkingPositionMenuController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionMenuController.java b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionMenuController.java index 4d1351c1ec..20313b68cd 100644 --- a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionMenuController.java +++ b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionMenuController.java @@ -74,7 +74,7 @@ public class ParkingPositionMenuController extends MenuController { @Override 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 : isLight() ? R.color.icon_color : R.color.icon_color; } @Override From b0522f2260554d387473ed9b837c7bca61ef7ef9 Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 19 Jan 2018 11:55:16 +0200 Subject: [PATCH 08/15] Remove code duplication --- .../osmand/plus/parkingpoint/ParkingPositionMenuController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionMenuController.java b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionMenuController.java index 20313b68cd..440aa9905a 100644 --- a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionMenuController.java +++ b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionMenuController.java @@ -74,7 +74,7 @@ public class ParkingPositionMenuController extends MenuController { @Override public int getAdditionalInfoColor() { - return plugin.getParkingType() ? R.color.ctx_menu_amenity_closed_text_color : isLight() ? R.color.icon_color : R.color.icon_color; + return plugin.getParkingType() ? R.color.ctx_menu_amenity_closed_text_color : R.color.icon_color; } @Override From 30da28e60c8f5c216cc2cf1a6167ede5c1b1619f Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 19 Jan 2018 12:53:25 +0200 Subject: [PATCH 09/15] Fix parking options menu color with dark map in light theme --- .../src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java index 93f6e3ac0b..fcdff4b15c 100644 --- a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java +++ b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java @@ -248,7 +248,7 @@ public class ParkingPositionPlugin extends OsmandPlugin { .setIcon(R.drawable.ic_action_time_span).setTag(2).createItem()); final AlertDialog.Builder builder = new AlertDialog.Builder(mapActivity); - boolean light = app.getSettings().isLightContent() && !app.getDaynightHelper().isNightMode(); + boolean light = app.getSettings().isLightContent(); final ArrayAdapter listAdapter = menuAdapter.createListAdapter(mapActivity, light); builder.setTitle(R.string.parking_options); builder.setAdapter(listAdapter, new DialogInterface.OnClickListener() { From afed3ebaa04acf1e0db0866537839c7eb5766693 Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 19 Jan 2018 13:43:26 +0200 Subject: [PATCH 10/15] Fix ProgressCard background color --- OsmAnd/res/layout/context_menu_card_progress.xml | 5 +++-- .../plus/mapcontextmenu/builders/cards/ProgressCard.java | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/layout/context_menu_card_progress.xml b/OsmAnd/res/layout/context_menu_card_progress.xml index 885101a93a..5786152b0b 100644 --- a/OsmAnd/res/layout/context_menu_card_progress.xml +++ b/OsmAnd/res/layout/context_menu_card_progress.xml @@ -1,11 +1,12 @@ + android:orientation="vertical" + tools:background="?attr/bg_card"> Date: Fri, 19 Jan 2018 15:21:02 +0200 Subject: [PATCH 11/15] Fix links color and underline in context menu --- .../src/net/osmand/plus/mapcontextmenu/MenuBuilder.java | 8 ++++++-- .../plus/mapcontextmenu/builders/AmenityMenuBuilder.java | 7 ++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index 0aae8670f8..45ba9a11c6 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -517,11 +517,15 @@ public class MenuBuilder { 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)); + 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) { - 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) { - textView.setAutoLinkMask(Linkify.ALL); + Linkify.addLinks(textView, Linkify.ALL); textView.setLinksClickable(true); + textView.setLinkTextColor(linkTextColor); + AndroidUtils.removeLinkUnderline(textView); } if (textLinesLimit > 0) { textView.setMinLines(1); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java index 5c02c650e0..7dfd47c68e 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java @@ -6,6 +6,7 @@ import android.content.res.ColorStateList; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Build; +import android.support.v4.content.ContextCompat; import android.support.v7.app.AlertDialog; import android.support.v7.view.ContextThemeWrapper; import android.text.Html; @@ -136,15 +137,18 @@ public class AmenityMenuBuilder extends MenuBuilder { 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)); + 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; if (isPhoneNumber || isUrl) { if (!Algorithms.isEmpty(textPrefix)) { SpannableString spannableString = new SpannableString(txt); spannableString.setSpan(new URLSpan(txt), textPrefix.length() + 2, txt.length(), 0); textView.setText(spannableString); + textView.setLinkTextColor(linkTextColor); textDefined = true; } else { - textView.setTextColor(textView.getLinkTextColors()); + textView.setTextColor(linkTextColor); } needLinks = false; } @@ -154,6 +158,7 @@ public class AmenityMenuBuilder extends MenuBuilder { if (needLinks) { Linkify.addLinks(textView, Linkify.ALL); textView.setLinksClickable(true); + textView.setLinkTextColor(linkTextColor); AndroidUtils.removeLinkUnderline(textView); } textView.setEllipsize(TextUtils.TruncateAt.END); From 595cc06819200d1f679b741423d8fef04003eb8d Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 19 Jan 2018 16:15:15 +0200 Subject: [PATCH 12/15] Fix collapse icon color in context menu --- OsmAnd/res/values/colors.xml | 2 ++ .../osmand/plus/mapcontextmenu/MenuBuilder.java | 14 +++++++++----- .../builders/AmenityMenuBuilder.java | 9 ++++----- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/OsmAnd/res/values/colors.xml b/OsmAnd/res/values/colors.xml index bc57720393..2ac3eedf22 100644 --- a/OsmAnd/res/values/colors.xml +++ b/OsmAnd/res/values/colors.xml @@ -354,6 +354,8 @@ #d28521 #b3b3b3 #666666 + #727272 + #a6a6a6 #ffffff #17191a diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index 45ba9a11c6..528df191b8 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -578,8 +578,7 @@ public class MenuBuilder { llIconCollapseParams.gravity = Gravity.CENTER_VERTICAL; iconViewCollapse.setLayoutParams(llIconCollapseParams); iconViewCollapse.setScaleType(ImageView.ScaleType.CENTER_INSIDE); - iconViewCollapse.setImageDrawable(app.getIconsCache().getIcon(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)); + iconViewCollapse.setImageDrawable(getCollapseIcon(collapsableView.getContenView().getVisibility() == View.GONE)); llIconCollapse.addView(iconViewCollapse); ll.setOnClickListener(new View.OnClickListener() { @Override @@ -587,17 +586,17 @@ public class MenuBuilder { if (collapsableView.getContenView().getVisibility() == View.VISIBLE) { collapsableView.setCollapsed(true); 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 { collapsableView.setCollapsed(false); 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()) { 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()); } @@ -738,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) { LinearLayout baseView = new LinearLayout(view.getContext()); baseView.setOrientation(LinearLayout.HORIZONTAL); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java index 7dfd47c68e..bdbcfe2335 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java @@ -194,8 +194,7 @@ public class AmenityMenuBuilder extends MenuBuilder { llIconCollapseParams.gravity = Gravity.CENTER_VERTICAL; iconViewCollapse.setLayoutParams(llIconCollapseParams); iconViewCollapse.setScaleType(ImageView.ScaleType.CENTER_INSIDE); - iconViewCollapse.setImageDrawable(app.getIconsCache().getThemedIcon(collapsableView.getContenView().getVisibility() == View.GONE ? - R.drawable.ic_action_arrow_down : R.drawable.ic_action_arrow_up)); + iconViewCollapse.setImageDrawable(getCollapseIcon(collapsableView.getContenView().getVisibility() == View.GONE)); llIconCollapse.addView(iconViewCollapse); ll.setOnClickListener(new View.OnClickListener() { @Override @@ -203,17 +202,17 @@ public class AmenityMenuBuilder extends MenuBuilder { if (collapsableView.getContenView().getVisibility() == View.VISIBLE) { collapsableView.setCollapsed(true); collapsableView.getContenView().setVisibility(View.GONE); - iconViewCollapse.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_arrow_down)); + iconViewCollapse.setImageDrawable(getCollapseIcon(true)); } else { collapsableView.setCollapsed(false); collapsableView.getContenView().setVisibility(View.VISIBLE); - iconViewCollapse.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_arrow_up)); + iconViewCollapse.setImageDrawable(getCollapseIcon(false)); } } }); if (collapsableView.isCollapsed()) { collapsableView.getContenView().setVisibility(View.GONE); - iconViewCollapse.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_arrow_down)); + iconViewCollapse.setImageDrawable(getCollapseIcon(true)); } baseView.addView(collapsableView.getContenView()); } From 8ce1f00867f44ee12db0e448b391e7ea16f833ce Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 19 Jan 2018 17:27:46 +0200 Subject: [PATCH 13/15] Capitalize first letter in weekdays --- OsmAnd-java/src/net/osmand/util/OpeningHoursParser.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd-java/src/net/osmand/util/OpeningHoursParser.java b/OsmAnd-java/src/net/osmand/util/OpeningHoursParser.java index 9bfc24476c..6a9ccbba05 100644 --- a/OsmAnd-java/src/net/osmand/util/OpeningHoursParser.java +++ b/OsmAnd-java/src/net/osmand/util/OpeningHoursParser.java @@ -59,9 +59,9 @@ public class OpeningHoursParser { for (int i = 0; i < strings.length; i++) { if (strings[i] != null) { if (strings[i].length() > 2) { - newStrings[i] = strings[i].substring(0, 2); + newStrings[i] = Algorithms.capitalizeFirstLetter(strings[i].substring(0, 2)); } else { - newStrings[i] = strings[i]; + newStrings[i] = Algorithms.capitalizeFirstLetter(strings[i]); } } } From e7ff0cdddf13377222b3e81a030d231ab92a0ae7 Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 19 Jan 2018 18:40:23 +0200 Subject: [PATCH 14/15] Add firebase event on context menu opening --- OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java | 1 + 1 file changed, 1 insertion(+) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java index 1d6bac7615..3bd73c406f 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java @@ -378,6 +378,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL @Nullable PointDescription pointDescription, @Nullable Object object) { if (init(latLon, pointDescription, object)) { + mapActivity.getMyApplication().logEvent(mapActivity, "open_context_menu"); showInternal(); } } From 1e99a52985809b40af8130e7abda84678c2ff6be Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 19 Jan 2018 19:55:07 +0200 Subject: [PATCH 15/15] Remove last divider in context menu --- OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index 528df191b8..995fd76267 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -309,7 +309,7 @@ public class MenuBuilder { buildNearestPhotosRow(view); } buildPluginRows(view); - buildAfter(view); +// buildAfter(view); } private boolean showTransportRoutes() {