diff --git a/OsmAnd/res/drawable/context_menu_controller_text_color_dark.xml b/OsmAnd/res/color/context_menu_controller_text_color_dark.xml
similarity index 100%
rename from OsmAnd/res/drawable/context_menu_controller_text_color_dark.xml
rename to OsmAnd/res/color/context_menu_controller_text_color_dark.xml
diff --git a/OsmAnd/res/drawable/context_menu_controller_text_color_light.xml b/OsmAnd/res/color/context_menu_controller_text_color_light.xml
similarity index 100%
rename from OsmAnd/res/drawable/context_menu_controller_text_color_light.xml
rename to OsmAnd/res/color/context_menu_controller_text_color_light.xml
diff --git a/OsmAnd/res/layout/map_context_menu_fragment.xml b/OsmAnd/res/layout/map_context_menu_fragment.xml
index 4a2ad7c61d..3ed1aa6c28 100644
--- a/OsmAnd/res/layout/map_context_menu_fragment.xml
+++ b/OsmAnd/res/layout/map_context_menu_fragment.xml
@@ -157,7 +157,7 @@
android:layout_marginLeft="@dimen/context_menu_padding_margin_small"
android:layout_marginRight="@dimen/context_menu_padding_margin_small"
android:id="@+id/title_button_view"
- android:background="?attr/ctx_menu_controller_bg"
+ tools:background="?attr/ctx_menu_controller_bg"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="@dimen/context_menu_controller_height"
@@ -174,7 +174,7 @@
android:paddingRight="@dimen/context_menu_button_padding_x"
android:textAllCaps="true"
android:text="@string/recording_context_menu_play"
- android:textColor="?attr/ctx_menu_controller_text_color"
+ tools:textColor="?attr/contextMenuButtonColor"
android:textSize="@dimen/default_desc_text_size"/>
@@ -228,7 +228,7 @@
@@ -295,7 +295,7 @@
android:layout_marginLeft="@dimen/context_menu_padding_margin_small"
android:layout_marginRight="@dimen/context_menu_padding_margin_small"
android:layout_weight="1"
- android:background="?attr/ctx_menu_controller_bg">
+ tools:background="?attr/ctx_menu_controller_bg">
diff --git a/OsmAnd/res/values/attrs.xml b/OsmAnd/res/values/attrs.xml
index 229b01fd7f..ce035224d8 100644
--- a/OsmAnd/res/values/attrs.xml
+++ b/OsmAnd/res/values/attrs.xml
@@ -25,7 +25,6 @@
-
diff --git a/OsmAnd/res/values/styles.xml b/OsmAnd/res/values/styles.xml
index 324296db60..b3fe484df3 100644
--- a/OsmAnd/res/values/styles.xml
+++ b/OsmAnd/res/values/styles.xml
@@ -132,7 +132,6 @@
- @drawable/dashboard_button_light
- @color/ctx_menu_info_view_bg_light
- @drawable/context_menu_controller_bg_light
- - @drawable/context_menu_controller_text_color_light
- @color/ctx_menu_buttons_divider_light
- @color/search_background_dark
- @drawable/ic_action_mode_back
@@ -322,7 +321,6 @@
- @drawable/dashboard_button_dark
- @color/ctx_menu_info_view_bg_dark
- @drawable/context_menu_controller_bg_dark
- - @drawable/context_menu_controller_text_color_dark
- @color/ctx_menu_buttons_divider_dark
- @color/color_white
- @drawable/switch_ex_background_dark
diff --git a/OsmAnd/src/net/osmand/AndroidUtils.java b/OsmAnd/src/net/osmand/AndroidUtils.java
index 04b6e89195..e792b0113f 100644
--- a/OsmAnd/src/net/osmand/AndroidUtils.java
+++ b/OsmAnd/src/net/osmand/AndroidUtils.java
@@ -7,8 +7,12 @@ import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.PointF;
+import android.graphics.drawable.Drawable;
+import android.graphics.drawable.StateListDrawable;
import android.os.Build;
import android.os.IBinder;
+import android.support.annotation.DrawableRes;
+import android.support.v4.content.ContextCompat;
import android.text.TextUtils;
import android.text.format.DateFormat;
import android.util.DisplayMetrics;
@@ -114,6 +118,23 @@ public class AndroidUtils {
return null;
}
+ public static StateListDrawable createStateListDrawable(Context ctx, boolean night,
+ @DrawableRes int lightNormal, @DrawableRes int lightPressed,
+ @DrawableRes int darkNormal, @DrawableRes int darkPressed) {
+ return createStateListDrawable(night,
+ ContextCompat.getDrawable(ctx, lightNormal), ContextCompat.getDrawable(ctx, lightPressed),
+ ContextCompat.getDrawable(ctx, darkNormal), ContextCompat.getDrawable(ctx, darkPressed));
+ }
+
+ public static StateListDrawable createStateListDrawable(boolean night,
+ Drawable lightNormal, Drawable lightPressed,
+ Drawable darkNormal, Drawable darkPressed) {
+ StateListDrawable res = new StateListDrawable();
+ res.addState(new int[]{android.R.attr.state_pressed}, night ? darkPressed : lightPressed);
+ res.addState(new int[]{}, night ? darkNormal : lightNormal);
+ return res;
+ }
+
@SuppressLint("NewApi")
@SuppressWarnings("deprecation")
public static void setBackground(Context ctx, View view, boolean night, int lightResId, int darkResId) {
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java
index c8f78f6d9d..bed9bd0fb6 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java
@@ -3,6 +3,7 @@ package net.osmand.plus.mapcontextmenu;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.annotation.TargetApi;
+import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.Build;
@@ -683,6 +684,10 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
TitleButtonController rightDownloadButtonController = menu.getRightDownloadButtonController();
TitleProgressController titleProgressController = menu.getTitleProgressController();
+ ColorStateList textColorStateList = ContextCompat.getColorStateList(getContext(),
+ nightMode ? R.color.context_menu_controller_text_color_dark : R.color.context_menu_controller_text_color_light);
+ int buttonViewBackgroundResId = nightMode ? R.drawable.context_menu_controller_bg_dark : R.drawable.context_menu_controller_bg_light;
+
// Title buttons
boolean showTitleButtonsContainer = (leftTitleButtonController != null || rightTitleButtonController != null);
final View titleButtonsContainer = view.findViewById(R.id.title_button_container);
@@ -694,8 +699,10 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
final TextView titleButtonRightText = (TextView) view.findViewById(R.id.title_button_right_text);
if (leftTitleButtonController != null) {
leftTitleButton.setText(leftTitleButtonController.caption);
+ leftTitleButton.setTextColor(textColorStateList);
if (leftTitleButtonController.visible) {
leftTitleButtonView.setVisibility(View.VISIBLE);
+ leftTitleButtonView.setBackgroundResource(buttonViewBackgroundResId);
Drawable leftIcon = leftTitleButtonController.getLeftIcon();
if (leftIcon != null) {
leftTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
@@ -721,7 +728,11 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
final TextView rightTitleButton = (TextView) view.findViewById(R.id.title_button_right);
if (rightTitleButtonController != null) {
rightTitleButton.setText(rightTitleButtonController.caption);
+ rightTitleButton.setTextColor(textColorStateList);
rightTitleButtonView.setVisibility(rightTitleButtonController.visible ? View.VISIBLE : View.INVISIBLE);
+ if (rightTitleButtonController.visible) {
+ rightTitleButtonView.setBackgroundResource(buttonViewBackgroundResId);
+ }
Drawable leftIcon = rightTitleButtonController.getLeftIcon();
rightTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
@@ -735,7 +746,11 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
final TextView bottomTitleButton = (TextView) view.findViewById(R.id.title_button_bottom);
if (bottomTitleButtonController != null) {
bottomTitleButton.setText(bottomTitleButtonController.caption);
+ bottomTitleButton.setTextColor(textColorStateList);
bottomTitleButtonView.setVisibility(bottomTitleButtonController.visible ? View.VISIBLE : View.GONE);
+ if (bottomTitleButtonController.visible) {
+ bottomTitleButtonView.setBackgroundResource(buttonViewBackgroundResId);
+ }
Drawable leftIcon = bottomTitleButtonController.getLeftIcon();
bottomTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
@@ -757,7 +772,11 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
final TextView leftDownloadButton = (TextView) view.findViewById(R.id.download_button_left);
if (leftDownloadButtonController != null) {
leftDownloadButton.setText(leftDownloadButtonController.caption);
+ leftDownloadButton.setTextColor(textColorStateList);
leftDownloadButtonView.setVisibility(leftDownloadButtonController.visible ? View.VISIBLE : View.INVISIBLE);
+ if (leftDownloadButtonController.visible) {
+ leftDownloadButtonView.setBackgroundResource(buttonViewBackgroundResId);
+ }
Drawable leftIcon = leftDownloadButtonController.getLeftIcon();
if (leftIcon != null) {
@@ -773,7 +792,11 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
final TextView rightDownloadButton = (TextView) view.findViewById(R.id.download_button_right);
if (rightDownloadButtonController != null) {
rightDownloadButton.setText(rightDownloadButtonController.caption);
+ rightDownloadButton.setTextColor(textColorStateList);
rightDownloadButtonView.setVisibility(rightDownloadButtonController.visible ? View.VISIBLE : View.INVISIBLE);
+ if (rightDownloadButtonController.visible) {
+ rightDownloadButtonView.setBackgroundResource(buttonViewBackgroundResId);
+ }
Drawable leftIcon = rightDownloadButtonController.getLeftIcon();
rightDownloadButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);