Fix controller buttons in context menu

This commit is contained in:
PavelRatushny 2017-12-27 13:12:40 +02:00
parent d82f45f41f
commit 305d877af0
2 changed files with 34 additions and 12 deletions

View file

@ -158,7 +158,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"
@ -175,7 +175,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/ctx_menu_controller_text_color"
android:textSize="@dimen/default_desc_text_size"/>
<TextView
@ -193,7 +193,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"
@ -210,7 +210,7 @@
android:paddingLeft="@dimen/context_menu_button_padding_x"
android:paddingRight="@dimen/context_menu_button_padding_x"
android:text="@string/shared_string_delete"
android:textColor="?attr/ctx_menu_controller_text_color"
tools:textColor="?attr/ctx_menu_controller_text_color"
android:textSize="@dimen/default_desc_text_size"/>
</LinearLayout>
@ -229,7 +229,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"
@ -247,14 +247,14 @@
android:paddingLeft="@dimen/context_menu_button_padding_x"
android:paddingRight="@dimen/context_menu_button_padding_x"
android:text="@string/shared_string_download"
android:textColor="?attr/ctx_menu_controller_text_color"
tools:textColor="?attr/ctx_menu_controller_text_color"
android:textSize="@dimen/default_desc_text_size"/>
</LinearLayout>
<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"
@ -272,7 +272,7 @@
android:paddingLeft="@dimen/context_menu_button_padding_x"
android:paddingRight="@dimen/context_menu_button_padding_x"
android:text="@string/shared_string_delete"
android:textColor="?attr/ctx_menu_controller_text_color"
tools:textColor="?attr/ctx_menu_controller_text_color"
android:textSize="@dimen/default_desc_text_size"/>
</LinearLayout>
@ -296,7 +296,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"
@ -308,7 +308,7 @@
android:paddingRight="@dimen/context_menu_button_padding_x"
android:text="@string/shared_string_others"
android:textAllCaps="true"
android:textColor="?attr/ctx_menu_controller_text_color"
tools:textColor="?attr/ctx_menu_controller_text_color"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium"/>

View file

@ -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;
@ -150,8 +151,21 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
mapZoom = map.getZoom();
}
ColorStateList buttonColorStateList = new ColorStateList(
new int[][]{
new int[]{android.R.attr.state_pressed},
new int[]{}
},
new int[] {
getResources().getColor(nightMode ? R.color.ctx_menu_controller_button_text_color_dark_p : R.color.ctx_menu_controller_button_text_color_light_p),
getResources().getColor(nightMode ? R.color.ctx_menu_controller_button_text_color_dark_n : R.color.ctx_menu_controller_button_text_color_light_n)
}
);
// Left title button
final View leftTitleButtonView = view.findViewById(R.id.title_button_view);
((TextView) leftTitleButtonView.findViewById(R.id.title_button)).setTextColor(buttonColorStateList);
leftTitleButtonView.setBackgroundResource(nightMode ? R.drawable.context_menu_controller_bg_dark : R.drawable.context_menu_controller_bg_light);
leftTitleButtonView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -164,6 +178,8 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
// Right title button
final View rightTitleButtonView = view.findViewById(R.id.title_button_right_view);
((TextView) rightTitleButtonView.findViewById(R.id.title_button_right)).setTextColor(buttonColorStateList);
rightTitleButtonView.setBackgroundResource(nightMode ? R.drawable.context_menu_controller_bg_dark : R.drawable.context_menu_controller_bg_light);
rightTitleButtonView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -176,6 +192,8 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
// Left download button
final View leftDownloadButtonView = view.findViewById(R.id.download_button_left_view);
((TextView) leftDownloadButtonView.findViewById(R.id.download_button_left)).setTextColor(buttonColorStateList);
leftDownloadButtonView.setBackgroundResource(nightMode ? R.drawable.context_menu_controller_bg_dark : R.drawable.context_menu_controller_bg_light);
leftDownloadButtonView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -188,6 +206,8 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
// Right download button
final View rightDownloadButtonView = (View) view.findViewById(R.id.download_button_right_view);
((TextView) rightDownloadButtonView.findViewById(R.id.download_button_right)).setTextColor(buttonColorStateList);
rightDownloadButtonView.setBackgroundResource(nightMode ? R.drawable.context_menu_controller_bg_dark : R.drawable.context_menu_controller_bg_light);
rightDownloadButtonView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -199,8 +219,10 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
});
// Bottom title button
final View bottomTitleButton = view.findViewById(R.id.title_button_bottom_view);
bottomTitleButton.setOnClickListener(new View.OnClickListener() {
final View bottomTitleButtonView = view.findViewById(R.id.title_button_bottom_view);
((TextView) bottomTitleButtonView.findViewById(R.id.title_button_bottom)).setTextColor(buttonColorStateList);
bottomTitleButtonView.setBackgroundResource(nightMode ? R.drawable.context_menu_controller_bg_dark : R.drawable.context_menu_controller_bg_light);
bottomTitleButtonView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TitleButtonController bottomTitleButtonController = menu.getBottomTitleButtonController();