Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2018-01-10 16:47:45 +01:00
commit 2f17aa6326
7 changed files with 54 additions and 13 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"
@ -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"/>
<TextView
@ -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"
@ -209,7 +209,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/contextMenuButtonColor"
android:textSize="@dimen/default_desc_text_size"/>
</LinearLayout>
@ -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"
@ -246,14 +246,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/contextMenuButtonColor"
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"
@ -271,7 +271,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/contextMenuButtonColor"
android:textSize="@dimen/default_desc_text_size"/>
</LinearLayout>
@ -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"
@ -307,7 +307,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/contextMenuButtonColor"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium"/>

View file

@ -25,7 +25,6 @@
<attr name="bg_point_editor_view" format="reference" />
<attr name="ctx_menu_info_view_bg" format="reference" />
<attr name="ctx_menu_controller_bg" format="reference" />
<attr name="ctx_menu_controller_text_color" format="reference" />
<attr name="ctx_menu_divider" format="reference" />
<attr name="bottom_menu_view_bg" format="reference" />
<attr name="left_menu_view_bg" format="reference" />

View file

@ -132,7 +132,6 @@
<item name="dashboard_button">@drawable/dashboard_button_light</item>
<item name="ctx_menu_info_view_bg">@color/ctx_menu_info_view_bg_light</item>
<item name="ctx_menu_controller_bg">@drawable/context_menu_controller_bg_light</item>
<item name="ctx_menu_controller_text_color">@drawable/context_menu_controller_text_color_light</item>
<item name="ctx_menu_divider">@color/ctx_menu_buttons_divider_light</item>
<item name="search_background">@color/search_background_dark</item>
<item name="actionModeCloseDrawable">@drawable/ic_action_mode_back</item>
@ -322,7 +321,6 @@
<item name="dashboard_button">@drawable/dashboard_button_dark</item>
<item name="ctx_menu_info_view_bg">@color/ctx_menu_info_view_bg_dark</item>
<item name="ctx_menu_controller_bg">@drawable/context_menu_controller_bg_dark</item>
<item name="ctx_menu_controller_text_color">@drawable/context_menu_controller_text_color_dark</item>
<item name="ctx_menu_divider">@color/ctx_menu_buttons_divider_dark</item>
<item name="search_background">@color/color_white</item>
<item name="switch_ex_background">@drawable/switch_ex_background_dark</item>

View file

@ -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) {

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;
@ -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);