Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
2f17aa6326
7 changed files with 54 additions and 13 deletions
|
@ -157,7 +157,7 @@
|
||||||
android:layout_marginLeft="@dimen/context_menu_padding_margin_small"
|
android:layout_marginLeft="@dimen/context_menu_padding_margin_small"
|
||||||
android:layout_marginRight="@dimen/context_menu_padding_margin_small"
|
android:layout_marginRight="@dimen/context_menu_padding_margin_small"
|
||||||
android:id="@+id/title_button_view"
|
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_width="0dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:layout_height="@dimen/context_menu_controller_height"
|
android:layout_height="@dimen/context_menu_controller_height"
|
||||||
|
@ -174,7 +174,7 @@
|
||||||
android:paddingRight="@dimen/context_menu_button_padding_x"
|
android:paddingRight="@dimen/context_menu_button_padding_x"
|
||||||
android:textAllCaps="true"
|
android:textAllCaps="true"
|
||||||
android:text="@string/recording_context_menu_play"
|
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"/>
|
android:textSize="@dimen/default_desc_text_size"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -192,7 +192,7 @@
|
||||||
android:layout_marginLeft="@dimen/context_menu_padding_margin_small"
|
android:layout_marginLeft="@dimen/context_menu_padding_margin_small"
|
||||||
android:layout_marginRight="@dimen/context_menu_padding_margin_small"
|
android:layout_marginRight="@dimen/context_menu_padding_margin_small"
|
||||||
android:id="@+id/title_button_right_view"
|
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_width="0dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:layout_height="@dimen/context_menu_controller_height"
|
android:layout_height="@dimen/context_menu_controller_height"
|
||||||
|
@ -209,7 +209,7 @@
|
||||||
android:paddingLeft="@dimen/context_menu_button_padding_x"
|
android:paddingLeft="@dimen/context_menu_button_padding_x"
|
||||||
android:paddingRight="@dimen/context_menu_button_padding_x"
|
android:paddingRight="@dimen/context_menu_button_padding_x"
|
||||||
android:text="@string/shared_string_delete"
|
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"/>
|
android:textSize="@dimen/default_desc_text_size"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -228,7 +228,7 @@
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/download_button_left_view"
|
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_marginLeft="@dimen/context_menu_padding_margin_small"
|
||||||
android:layout_marginRight="@dimen/context_menu_padding_margin_small"
|
android:layout_marginRight="@dimen/context_menu_padding_margin_small"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -246,14 +246,14 @@
|
||||||
android:paddingLeft="@dimen/context_menu_button_padding_x"
|
android:paddingLeft="@dimen/context_menu_button_padding_x"
|
||||||
android:paddingRight="@dimen/context_menu_button_padding_x"
|
android:paddingRight="@dimen/context_menu_button_padding_x"
|
||||||
android:text="@string/shared_string_download"
|
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"/>
|
android:textSize="@dimen/default_desc_text_size"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/download_button_right_view"
|
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_marginLeft="@dimen/context_menu_padding_margin_small"
|
||||||
android:layout_marginRight="@dimen/context_menu_padding_margin_small"
|
android:layout_marginRight="@dimen/context_menu_padding_margin_small"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -271,7 +271,7 @@
|
||||||
android:paddingLeft="@dimen/context_menu_button_padding_x"
|
android:paddingLeft="@dimen/context_menu_button_padding_x"
|
||||||
android:paddingRight="@dimen/context_menu_button_padding_x"
|
android:paddingRight="@dimen/context_menu_button_padding_x"
|
||||||
android:text="@string/shared_string_delete"
|
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"/>
|
android:textSize="@dimen/default_desc_text_size"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -295,7 +295,7 @@
|
||||||
android:layout_marginLeft="@dimen/context_menu_padding_margin_small"
|
android:layout_marginLeft="@dimen/context_menu_padding_margin_small"
|
||||||
android:layout_marginRight="@dimen/context_menu_padding_margin_small"
|
android:layout_marginRight="@dimen/context_menu_padding_margin_small"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:background="?attr/ctx_menu_controller_bg">
|
tools:background="?attr/ctx_menu_controller_bg">
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
android:id="@+id/title_button_bottom"
|
android:id="@+id/title_button_bottom"
|
||||||
|
@ -307,7 +307,7 @@
|
||||||
android:paddingRight="@dimen/context_menu_button_padding_x"
|
android:paddingRight="@dimen/context_menu_button_padding_x"
|
||||||
android:text="@string/shared_string_others"
|
android:text="@string/shared_string_others"
|
||||||
android:textAllCaps="true"
|
android:textAllCaps="true"
|
||||||
android:textColor="?attr/ctx_menu_controller_text_color"
|
tools:textColor="?attr/contextMenuButtonColor"
|
||||||
android:textSize="@dimen/default_desc_text_size"
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
osmand:typeface="@string/font_roboto_medium"/>
|
osmand:typeface="@string/font_roboto_medium"/>
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
<attr name="bg_point_editor_view" format="reference" />
|
<attr name="bg_point_editor_view" format="reference" />
|
||||||
<attr name="ctx_menu_info_view_bg" format="reference" />
|
<attr name="ctx_menu_info_view_bg" format="reference" />
|
||||||
<attr name="ctx_menu_controller_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="ctx_menu_divider" format="reference" />
|
||||||
<attr name="bottom_menu_view_bg" format="reference" />
|
<attr name="bottom_menu_view_bg" format="reference" />
|
||||||
<attr name="left_menu_view_bg" format="reference" />
|
<attr name="left_menu_view_bg" format="reference" />
|
||||||
|
|
|
@ -132,7 +132,6 @@
|
||||||
<item name="dashboard_button">@drawable/dashboard_button_light</item>
|
<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_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_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="ctx_menu_divider">@color/ctx_menu_buttons_divider_light</item>
|
||||||
<item name="search_background">@color/search_background_dark</item>
|
<item name="search_background">@color/search_background_dark</item>
|
||||||
<item name="actionModeCloseDrawable">@drawable/ic_action_mode_back</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="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_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_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="ctx_menu_divider">@color/ctx_menu_buttons_divider_dark</item>
|
||||||
<item name="search_background">@color/color_white</item>
|
<item name="search_background">@color/color_white</item>
|
||||||
<item name="switch_ex_background">@drawable/switch_ex_background_dark</item>
|
<item name="switch_ex_background">@drawable/switch_ex_background_dark</item>
|
||||||
|
|
|
@ -7,8 +7,12 @@ import android.content.Context;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.graphics.drawable.StateListDrawable;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
import android.support.annotation.DrawableRes;
|
||||||
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.text.format.DateFormat;
|
import android.text.format.DateFormat;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
|
@ -114,6 +118,23 @@ public class AndroidUtils {
|
||||||
return null;
|
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")
|
@SuppressLint("NewApi")
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public static void setBackground(Context ctx, View view, boolean night, int lightResId, int darkResId) {
|
public static void setBackground(Context ctx, View view, boolean night, int lightResId, int darkResId) {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package net.osmand.plus.mapcontextmenu;
|
||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
import android.animation.AnimatorListenerAdapter;
|
import android.animation.AnimatorListenerAdapter;
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
|
import android.content.res.ColorStateList;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
@ -683,6 +684,10 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
||||||
TitleButtonController rightDownloadButtonController = menu.getRightDownloadButtonController();
|
TitleButtonController rightDownloadButtonController = menu.getRightDownloadButtonController();
|
||||||
TitleProgressController titleProgressController = menu.getTitleProgressController();
|
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
|
// Title buttons
|
||||||
boolean showTitleButtonsContainer = (leftTitleButtonController != null || rightTitleButtonController != null);
|
boolean showTitleButtonsContainer = (leftTitleButtonController != null || rightTitleButtonController != null);
|
||||||
final View titleButtonsContainer = view.findViewById(R.id.title_button_container);
|
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);
|
final TextView titleButtonRightText = (TextView) view.findViewById(R.id.title_button_right_text);
|
||||||
if (leftTitleButtonController != null) {
|
if (leftTitleButtonController != null) {
|
||||||
leftTitleButton.setText(leftTitleButtonController.caption);
|
leftTitleButton.setText(leftTitleButtonController.caption);
|
||||||
|
leftTitleButton.setTextColor(textColorStateList);
|
||||||
if (leftTitleButtonController.visible) {
|
if (leftTitleButtonController.visible) {
|
||||||
leftTitleButtonView.setVisibility(View.VISIBLE);
|
leftTitleButtonView.setVisibility(View.VISIBLE);
|
||||||
|
leftTitleButtonView.setBackgroundResource(buttonViewBackgroundResId);
|
||||||
Drawable leftIcon = leftTitleButtonController.getLeftIcon();
|
Drawable leftIcon = leftTitleButtonController.getLeftIcon();
|
||||||
if (leftIcon != null) {
|
if (leftIcon != null) {
|
||||||
leftTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, 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);
|
final TextView rightTitleButton = (TextView) view.findViewById(R.id.title_button_right);
|
||||||
if (rightTitleButtonController != null) {
|
if (rightTitleButtonController != null) {
|
||||||
rightTitleButton.setText(rightTitleButtonController.caption);
|
rightTitleButton.setText(rightTitleButtonController.caption);
|
||||||
|
rightTitleButton.setTextColor(textColorStateList);
|
||||||
rightTitleButtonView.setVisibility(rightTitleButtonController.visible ? View.VISIBLE : View.INVISIBLE);
|
rightTitleButtonView.setVisibility(rightTitleButtonController.visible ? View.VISIBLE : View.INVISIBLE);
|
||||||
|
if (rightTitleButtonController.visible) {
|
||||||
|
rightTitleButtonView.setBackgroundResource(buttonViewBackgroundResId);
|
||||||
|
}
|
||||||
|
|
||||||
Drawable leftIcon = rightTitleButtonController.getLeftIcon();
|
Drawable leftIcon = rightTitleButtonController.getLeftIcon();
|
||||||
rightTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
|
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);
|
final TextView bottomTitleButton = (TextView) view.findViewById(R.id.title_button_bottom);
|
||||||
if (bottomTitleButtonController != null) {
|
if (bottomTitleButtonController != null) {
|
||||||
bottomTitleButton.setText(bottomTitleButtonController.caption);
|
bottomTitleButton.setText(bottomTitleButtonController.caption);
|
||||||
|
bottomTitleButton.setTextColor(textColorStateList);
|
||||||
bottomTitleButtonView.setVisibility(bottomTitleButtonController.visible ? View.VISIBLE : View.GONE);
|
bottomTitleButtonView.setVisibility(bottomTitleButtonController.visible ? View.VISIBLE : View.GONE);
|
||||||
|
if (bottomTitleButtonController.visible) {
|
||||||
|
bottomTitleButtonView.setBackgroundResource(buttonViewBackgroundResId);
|
||||||
|
}
|
||||||
|
|
||||||
Drawable leftIcon = bottomTitleButtonController.getLeftIcon();
|
Drawable leftIcon = bottomTitleButtonController.getLeftIcon();
|
||||||
bottomTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
|
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);
|
final TextView leftDownloadButton = (TextView) view.findViewById(R.id.download_button_left);
|
||||||
if (leftDownloadButtonController != null) {
|
if (leftDownloadButtonController != null) {
|
||||||
leftDownloadButton.setText(leftDownloadButtonController.caption);
|
leftDownloadButton.setText(leftDownloadButtonController.caption);
|
||||||
|
leftDownloadButton.setTextColor(textColorStateList);
|
||||||
leftDownloadButtonView.setVisibility(leftDownloadButtonController.visible ? View.VISIBLE : View.INVISIBLE);
|
leftDownloadButtonView.setVisibility(leftDownloadButtonController.visible ? View.VISIBLE : View.INVISIBLE);
|
||||||
|
if (leftDownloadButtonController.visible) {
|
||||||
|
leftDownloadButtonView.setBackgroundResource(buttonViewBackgroundResId);
|
||||||
|
}
|
||||||
|
|
||||||
Drawable leftIcon = leftDownloadButtonController.getLeftIcon();
|
Drawable leftIcon = leftDownloadButtonController.getLeftIcon();
|
||||||
if (leftIcon != null) {
|
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);
|
final TextView rightDownloadButton = (TextView) view.findViewById(R.id.download_button_right);
|
||||||
if (rightDownloadButtonController != null) {
|
if (rightDownloadButtonController != null) {
|
||||||
rightDownloadButton.setText(rightDownloadButtonController.caption);
|
rightDownloadButton.setText(rightDownloadButtonController.caption);
|
||||||
|
rightDownloadButton.setTextColor(textColorStateList);
|
||||||
rightDownloadButtonView.setVisibility(rightDownloadButtonController.visible ? View.VISIBLE : View.INVISIBLE);
|
rightDownloadButtonView.setVisibility(rightDownloadButtonController.visible ? View.VISIBLE : View.INVISIBLE);
|
||||||
|
if (rightDownloadButtonController.visible) {
|
||||||
|
rightDownloadButtonView.setBackgroundResource(buttonViewBackgroundResId);
|
||||||
|
}
|
||||||
|
|
||||||
Drawable leftIcon = rightDownloadButtonController.getLeftIcon();
|
Drawable leftIcon = rightDownloadButtonController.getLeftIcon();
|
||||||
rightDownloadButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
|
rightDownloadButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
|
||||||
|
|
Loading…
Reference in a new issue