Fix night button selector in context menu

This commit is contained in:
alex 2018-01-10 13:09:05 +02:00
parent 3268968ec2
commit 11b512b5d3
2 changed files with 19 additions and 5 deletions

View file

@ -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"
@ -192,7 +192,7 @@
android:layout_marginLeft="@dimen/context_menu_padding_margin_small"
android:layout_marginRight="@dimen/context_menu_padding_margin_small"
android:id="@+id/title_button_right_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"
@ -228,7 +228,7 @@
<LinearLayout
android:id="@+id/download_button_left_view"
android:background="?attr/ctx_menu_controller_bg"
tools:background="?attr/ctx_menu_controller_bg"
android:layout_marginLeft="@dimen/context_menu_padding_margin_small"
android:layout_marginRight="@dimen/context_menu_padding_margin_small"
android:layout_width="0dp"
@ -253,7 +253,7 @@
<LinearLayout
android:id="@+id/download_button_right_view"
android:background="?attr/ctx_menu_controller_bg"
tools:background="?attr/ctx_menu_controller_bg"
android:layout_marginLeft="@dimen/context_menu_padding_margin_small"
android:layout_marginRight="@dimen/context_menu_padding_margin_small"
android:layout_width="0dp"
@ -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">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/title_button_bottom"

View file

@ -686,6 +686,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
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);
@ -701,6 +702,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
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);
@ -728,6 +730,9 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
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);
@ -743,6 +748,9 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
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);
@ -766,6 +774,9 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
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) {
@ -783,6 +794,9 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
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);