From 4420da87389454d53a76a5057f480735792c1c19 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Mon, 6 Nov 2017 19:25:41 +0200 Subject: [PATCH] Fix tint on api < 21 --- .../layout-land/input_coordinate_keyboard_item.xml | 1 - OsmAnd/res/layout/input_coordinate_keyboard_item.xml | 1 - OsmAnd/res/values/attrs.xml | 1 - OsmAnd/res/values/styles.xml | 2 -- .../mapmarkers/CoordinateInputDialogFragment.java | 11 ++++++++++- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/OsmAnd/res/layout-land/input_coordinate_keyboard_item.xml b/OsmAnd/res/layout-land/input_coordinate_keyboard_item.xml index e546c02781..f2d5cf78c4 100644 --- a/OsmAnd/res/layout-land/input_coordinate_keyboard_item.xml +++ b/OsmAnd/res/layout-land/input_coordinate_keyboard_item.xml @@ -33,7 +33,6 @@ android:layout_gravity="center" android:layout_weight="1" android:scaleType="center" - android:tint="?attr/keyboard_item_icon_color" tools:src="@drawable/ic_action_backspace_fill"/> \ No newline at end of file diff --git a/OsmAnd/res/layout/input_coordinate_keyboard_item.xml b/OsmAnd/res/layout/input_coordinate_keyboard_item.xml index 2d9f7be76a..8b2f3a0f57 100644 --- a/OsmAnd/res/layout/input_coordinate_keyboard_item.xml +++ b/OsmAnd/res/layout/input_coordinate_keyboard_item.xml @@ -33,7 +33,6 @@ android:layout_gravity="center" android:layout_weight="1" android:scaleType="center" - android:tint="?attr/keyboard_item_icon_color" tools:src="@drawable/ic_action_backspace_fill"/> \ No newline at end of file diff --git a/OsmAnd/res/values/attrs.xml b/OsmAnd/res/values/attrs.xml index ebc1245b88..9690d6d7a6 100644 --- a/OsmAnd/res/values/attrs.xml +++ b/OsmAnd/res/values/attrs.xml @@ -7,7 +7,6 @@ - diff --git a/OsmAnd/res/values/styles.xml b/OsmAnd/res/values/styles.xml index d2cec0d139..37f9b8ab6c 100644 --- a/OsmAnd/res/values/styles.xml +++ b/OsmAnd/res/values/styles.xml @@ -177,7 +177,6 @@ @style/PopupMenuLight - @drawable/keyboard_item_icon_color_light @color/keyboard_item_add_button_divider_light @@ -350,7 +349,6 @@ @style/PopupMenuDark - @color/keyboard_item_divider_control_color_dark @color/keyboard_item_add_button_divider_dark diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java index 82a27a9f9a..50c34b5ca2 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java @@ -5,6 +5,7 @@ import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; import android.content.res.ColorStateList; +import android.graphics.drawable.Drawable; import android.os.Build; import android.os.Bundle; import android.support.annotation.NonNull; @@ -12,6 +13,7 @@ import android.support.annotation.Nullable; import android.support.v4.app.DialogFragment; import android.support.v4.app.Fragment; import android.support.v4.content.ContextCompat; +import android.support.v4.graphics.drawable.DrawableCompat; import android.support.v4.widget.TextViewCompat; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.PopupMenu; @@ -845,7 +847,14 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm keyboardItemBottomSpacing.setVisibility(View.GONE); keyboardItemText.setVisibility(View.GONE); keyboardItemImage.setVisibility(View.VISIBLE); - keyboardItemImage.setImageResource((Integer) item); + Drawable icon; + if (lightTheme) { + icon = DrawableCompat.wrap(getResources().getDrawable((Integer) item)); + DrawableCompat.setTintList(icon, numberColorStateList); + } else { + icon = iconsCache.getIcon((Integer) item, R.color.keyboard_item_divider_control_color_dark); + } + keyboardItemImage.setImageDrawable(icon); } return convertView;