Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2018-01-11 18:45:24 +01:00
commit 4c9d6b5740
15 changed files with 304 additions and 107 deletions

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<nine-patch android:src="@drawable/bg_contextmenu_shadow_top_light"/>
</item>
<item>
<shape>
<solid android:color="@color/ctx_menu_bg_dark"/>
</shape>
</item>
</layer-list>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<nine-patch android:src="@drawable/bg_contextmenu_shadow_top_light"/>
</item>
<item>
<shape>
<solid android:color="@color/route_info_bottom_view_bg_light"/>
</shape>
</item>
</layer-list>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<nine-patch android:src="@drawable/bg_shadow_bottomsheet_sides"/>
</item>
<item>
<shape>
<solid android:color="@color/ctx_menu_bg_dark"/>
</shape>
</item>
</layer-list>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<nine-patch android:src="@drawable/bg_shadow_bottomsheet_sides"/>
</item>
<item>
<shape>
<solid android:color="@color/route_info_bottom_view_bg_light"/>
</shape>
</item>
</layer-list>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<nine-patch android:src="@drawable/bg_shadow_bottomsheet_topsides"/>
</item>
<item>
<shape>
<solid android:color="@color/ctx_menu_bg_dark"/>
</shape>
</item>
</layer-list>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<nine-patch android:src="@drawable/bg_shadow_bottomsheet_topsides"/>
</item>
<item>
<shape>
<solid android:color="@color/route_info_bottom_view_bg_light"/>
</shape>
</item>
</layer-list>

View file

@ -1,36 +1,49 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/bg_color"> android:orientation="vertical">
<LinearLayout <android.support.design.widget.CoordinatorLayout
android:orientation="vertical" android:id="@+id/scroll_view_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="0dp"
android:layout_weight="1">
<LinearLayout <android.support.v4.widget.NestedScrollView
android:orientation="vertical" android:id="@+id/bottom_sheet_scroll_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingBottom="@dimen/bottom_sheet_content_padding_small"> app:behavior_hideable="true"
app:layout_behavior="net.osmand.plus.widgets.tools.ExtendedBottomSheetBehavior"
<include layout="@layout/bottom_sheet_dialog_fragment_title"/> tools:background="?attr/bg_color">
<LinearLayout <LinearLayout
android:orientation="vertical"
android:id="@+id/context_menu_items_container" android:id="@+id/context_menu_items_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
</LinearLayout> android:orientation="vertical"
android:paddingBottom="@dimen/bottom_sheet_content_padding_small"/>
</LinearLayout> </android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
<LinearLayout
android:id="@+id/cancel_row_background"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:background="?attr/bg_color">
<View <View
android:id="@+id/divider"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="1dp"
android:background="?attr/dashboard_divider"/> tools:background="?attr/dashboard_divider"/>
<FrameLayout <FrameLayout
android:id="@+id/cancel_row" android:id="@+id/cancel_row"
@ -51,4 +64,4 @@
</LinearLayout> </LinearLayout>
</android.support.v4.widget.NestedScrollView> </LinearLayout>

View file

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="@dimen/grid_menu_item_width"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:orientation="vertical"
android:paddingLeft="@dimen/bottom_sheet_content_padding_small"
android:paddingRight="@dimen/bottom_sheet_content_padding_small"
tools:background="#17171A"
tools:layout_gravity="center">
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/grid_menu_item_bottom_top_margin"
android:layout_marginLeft="@dimen/grid_menu_item_sides_margin"
android:layout_marginRight="@dimen/grid_menu_item_sides_margin"
android:layout_marginTop="@dimen/grid_menu_item_bottom_top_margin"
tools:src="@drawable/ic_action_delete_dark"
tools:tint="#808080"/>
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="center_horizontal"
android:lines="2"
android:maxLines="2"
android:textColor="@color/searchbar_text_hint_light"
tools:text="Remove POI"/>
</LinearLayout>

View file

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/bottom_sheet_content_padding_small">
<FrameLayout
android:id="@+id/first_item_container"
android:layout_width="@dimen/grid_menu_item_width"
android:layout_height="wrap_content"/>
<Space
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<FrameLayout
android:id="@+id/second_item_container"
android:layout_width="@dimen/grid_menu_item_width"
android:layout_height="wrap_content"/>
<Space
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<FrameLayout
android:id="@+id/third_item_container"
android:layout_width="@dimen/grid_menu_item_width"
android:layout_height="wrap_content"/>
</LinearLayout>

View file

@ -180,4 +180,7 @@
<dimen name="multi_selection_menu_padding_top">20dp</dimen> <dimen name="multi_selection_menu_padding_top">20dp</dimen>
<dimen name="multi_selection_menu_padding_bottom">23dp</dimen> <dimen name="multi_selection_menu_padding_bottom">23dp</dimen>
<dimen name="grid_menu_item_width">180dp</dimen>
<dimen name="grid_menu_item_bottom_top_margin">24dp</dimen>
<dimen name="grid_menu_item_sides_margin">60dp</dimen>
</resources> </resources>

View file

@ -378,4 +378,6 @@
<color name="multi_selection_menu_close_btn_light">#2f7af5</color> <color name="multi_selection_menu_close_btn_light">#2f7af5</color>
<color name="multi_selection_menu_close_btn_dark">#e69122</color> <color name="multi_selection_menu_close_btn_dark">#e69122</color>
<color name="grid_menu_icon_dark">#808080</color>
</resources> </resources>

View file

@ -252,4 +252,8 @@
<dimen name="multi_selection_menu_padding_top">13dp</dimen> <dimen name="multi_selection_menu_padding_top">13dp</dimen>
<dimen name="multi_selection_menu_padding_bottom">15dp</dimen> <dimen name="multi_selection_menu_padding_bottom">15dp</dimen>
<dimen name="grid_menu_item_width">120dp</dimen>
<dimen name="grid_menu_item_bottom_top_margin">16dp</dimen>
<dimen name="grid_menu_item_sides_margin">40dp</dimen>
</resources> </resources>

View file

@ -1,91 +1,79 @@
package net.osmand.plus.mapcontextmenu; package net.osmand.plus.mapcontextmenu;
import android.app.Dialog; import android.app.Activity;
import android.content.DialogInterface;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.DrawableRes; import android.support.annotation.DrawableRes;
import android.support.design.widget.BottomSheetBehavior; import android.support.annotation.NonNull;
import android.support.design.widget.BottomSheetDialog; import android.support.annotation.Nullable;
import android.support.design.widget.BottomSheetDialogFragment;
import android.support.v4.content.ContextCompat;
import android.view.ContextThemeWrapper; import android.view.ContextThemeWrapper;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import android.view.Window; import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuItem; import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.widgets.tools.ExtendedBottomSheetBehavior;
import net.osmand.plus.widgets.tools.ExtendedBottomSheetBehavior.BottomSheetCallback;
public class AdditionalActionsBottomSheetDialogFragment extends BottomSheetDialogFragment { public class AdditionalActionsBottomSheetDialogFragment extends net.osmand.plus.base.BottomSheetDialogFragment {
public static final String TAG = "AdditionalActionsBottomSheetDialogFragment"; public static final String TAG = "AdditionalActionsBottomSheetDialogFragment";
private boolean nightMode; private boolean nightMode;
private boolean portrait; private boolean portrait;
private int availableScreenH;
private ContextMenuAdapter adapter; private ContextMenuAdapter adapter;
private ContextMenuItemClickListener listener; private ContextMenuItemClickListener listener;
private View scrollView;
private View cancelRowBgView;
public void setAdapter(ContextMenuAdapter adapter, ContextMenuItemClickListener listener) { public void setAdapter(ContextMenuAdapter adapter, ContextMenuItemClickListener listener) {
this.adapter = adapter; this.adapter = adapter;
this.listener = listener; this.listener = listener;
} }
@Nullable
@Override @Override
public void setupDialog(Dialog dialog, int style) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.setupDialog(dialog, style); Activity activity = getActivity();
nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls();
if (getMyApplication().getSettings().DO_NOT_USE_ANIMATIONS.get()) { portrait = AndroidUiHelper.isOrientationPortrait(activity);
dialog.getWindow().setWindowAnimations(R.style.Animations_NoAnimation); final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
availableScreenH = AndroidUtils.getScreenHeight(activity) - AndroidUtils.getStatusBarHeight(activity);
if (portrait) {
availableScreenH -= AndroidUtils.getNavBarHeight(activity);
} }
nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls();
portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
final OsmandSettings settings = getMyApplication().getSettings();
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_context_menu_actions_bottom_sheet_dialog, null); View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_context_menu_actions_bottom_sheet_dialog, null);
scrollView = mainView.findViewById(R.id.bottom_sheet_scroll_view);
cancelRowBgView = mainView.findViewById(R.id.cancel_row_background);
AndroidUtils.setBackground(getActivity(), mainView, nightMode, updateBackground(false);
portrait ? R.drawable.bg_bottom_menu_light : R.drawable.bg_bottom_sheet_topsides_landscape_light, cancelRowBgView.setBackgroundResource(getCancelRowBgResId());
portrait ? R.drawable.bg_bottom_menu_dark : R.drawable.bg_bottom_sheet_topsides_landscape_dark); mainView.findViewById(R.id.divider).setBackgroundResource(nightMode
? R.color.route_info_bottom_view_bg_dark : R.color.route_info_divider_light);
mainView.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() { View.OnClickListener dismissOnClickListener = new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
dismiss(); dismiss();
} }
}); };
TextView headerTitle = (TextView) mainView.findViewById(R.id.header_title); mainView.findViewById(R.id.cancel_row).setOnClickListener(dismissOnClickListener);
if (nightMode) { mainView.findViewById(R.id.scroll_view_container).setOnClickListener(dismissOnClickListener);
headerTitle.setTextColor(ContextCompat.getColor(getActivity(), R.color.ctx_menu_info_text_dark));
}
headerTitle.setText(getString(R.string.additional_actions));
if (!portrait) {
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialogInterface) {
BottomSheetDialog dialog = (BottomSheetDialog) dialogInterface;
FrameLayout bottomSheet = (FrameLayout) dialog.findViewById(android.support.design.R.id.design_bottom_sheet);
BottomSheetBehavior.from(bottomSheet).setState(BottomSheetBehavior.STATE_EXPANDED);
}
});
}
View.OnClickListener onClickListener = new View.OnClickListener() { View.OnClickListener onClickListener = new View.OnClickListener() {
@Override @Override
@ -98,24 +86,52 @@ public class AdditionalActionsBottomSheetDialogFragment extends BottomSheetDialo
}; };
LinearLayout itemsLinearLayout = (LinearLayout) mainView.findViewById(R.id.context_menu_items_container); LinearLayout itemsLinearLayout = (LinearLayout) mainView.findViewById(R.id.context_menu_items_container);
LinearLayout row = (LinearLayout) View.inflate(getContext(), R.layout.grid_menu_row, null);
int itemsAdded = 0;
for (int i = 0; i < adapter.length(); i++) { for (int i = 0; i < adapter.length(); i++) {
ContextMenuItem item = adapter.getItem(i); ContextMenuItem item = adapter.getItem(i);
int layoutResId = item.getLayout(); int layoutResId = item.getLayout();
layoutResId = layoutResId != ContextMenuItem.INVALID_ID ? layoutResId : R.layout.bottom_sheet_dialog_fragment_item; layoutResId = layoutResId == ContextMenuItem.INVALID_ID ? R.layout.grid_menu_item : layoutResId;
View row = View.inflate(new ContextThemeWrapper(getContext(), themeRes), layoutResId, null); boolean dividerItem = layoutResId == R.layout.bottom_sheet_dialog_fragment_divider;
if (layoutResId != R.layout.bottom_sheet_dialog_fragment_divider) {
if (!dividerItem) {
View menuItem = View.inflate(new ContextThemeWrapper(getContext(), themeRes), layoutResId, null);
if (item.getIcon() != ContextMenuItem.INVALID_ID) { if (item.getIcon() != ContextMenuItem.INVALID_ID) {
((ImageView) row.findViewById(R.id.icon)).setImageDrawable(getContentIcon(item.getIcon())); ((ImageView) menuItem.findViewById(R.id.icon)).setImageDrawable(getContentIcon(item.getIcon()));
} }
((TextView) row.findViewById(R.id.title)).setText(item.getTitle()); ((TextView) menuItem.findViewById(R.id.title)).setText(item.getTitle());
menuItem.setTag(i);
menuItem.setOnClickListener(onClickListener);
((FrameLayout) row.findViewById(getMenuItemContainerId(itemsAdded))).addView(menuItem);
itemsAdded++;
}
if (dividerItem || itemsAdded == 3 || (i == adapter.length() - 1 && itemsAdded > 0)) {
itemsLinearLayout.addView(row);
row = (LinearLayout) View.inflate(getContext(), R.layout.grid_menu_row, null);
itemsAdded = 0;
} }
row.setTag(i);
row.setOnClickListener(onClickListener);
itemsLinearLayout.addView(row);
} }
dialog.setContentView(mainView); ExtendedBottomSheetBehavior behavior = ExtendedBottomSheetBehavior.from(scrollView);
((View) mainView.getParent()).setBackgroundResource(0); behavior.setPeekHeight(getPeekHeight());
behavior.setBottomSheetCallback(new BottomSheetCallback() {
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
if (newState == ExtendedBottomSheetBehavior.STATE_HIDDEN) {
dismiss();
} else {
updateBackground(newState == ExtendedBottomSheetBehavior.STATE_EXPANDED);
}
}
@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
}
});
return mainView;
} }
@Override @Override
@ -129,12 +145,47 @@ public class AdditionalActionsBottomSheetDialogFragment extends BottomSheetDialo
} }
} }
private OsmandApplication getMyApplication() { @Override
return ((MapActivity) getActivity()).getMyApplication(); protected Drawable getContentIcon(@DrawableRes int id) {
return getMyApplication().getIconsCache().getIcon(id, nightMode ? R.color.grid_menu_icon_dark : R.color.on_map_icon_color);
} }
private Drawable getContentIcon(@DrawableRes int id) { private int getCancelRowBgResId() {
return getMyApplication().getIconsCache().getIcon(id, nightMode ? R.color.ctx_menu_info_text_dark : R.color.on_map_icon_color); if (portrait) {
return nightMode ? R.color.ctx_menu_bg_dark : R.color.route_info_bottom_view_bg_light;
}
return nightMode ? R.drawable.bg_additional_menu_sides_dark : R.drawable.bg_additional_menu_sides_light;
}
private boolean expandedToFullScreen() {
return availableScreenH - scrollView.getHeight() - cancelRowBgView.getHeight() <= 0;
}
private void updateBackground(boolean expanded) {
int bgResId;
if (portrait) {
bgResId = expanded && expandedToFullScreen()
? (nightMode ? R.color.ctx_menu_bg_dark : R.color.route_info_bottom_view_bg_light)
: (nightMode ? R.drawable.bg_additional_menu_dark : R.drawable.bg_additional_menu_light);
} else {
bgResId = expanded && expandedToFullScreen()
? (nightMode ? R.drawable.bg_additional_menu_sides_dark : R.drawable.bg_additional_menu_sides_light)
: (nightMode ? R.drawable.bg_additional_menu_topsides_dark : R.drawable.bg_additional_menu_topsides_light);
}
scrollView.setBackgroundResource(bgResId);
}
private int getMenuItemContainerId(int itemsAdded) {
if (itemsAdded == 0) {
return R.id.first_item_container;
} else if (itemsAdded == 1) {
return R.id.second_item_container;
}
return R.id.third_item_container;
}
private int getPeekHeight() {
return (availableScreenH * 2 / 3) - getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height);
} }
public interface ContextMenuItemClickListener { public interface ContextMenuItemClickListener {

View file

@ -3,8 +3,8 @@ package net.osmand.plus.mapcontextmenu;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.widget.LinearLayout; import android.widget.LinearLayout;
@ -52,7 +52,6 @@ import net.osmand.plus.mapcontextmenu.controllers.RenderedObjectMenuController;
import net.osmand.plus.mapcontextmenu.controllers.TargetPointMenuController; import net.osmand.plus.mapcontextmenu.controllers.TargetPointMenuController;
import net.osmand.plus.mapcontextmenu.controllers.TransportRouteController; import net.osmand.plus.mapcontextmenu.controllers.TransportRouteController;
import net.osmand.plus.mapcontextmenu.controllers.TransportStopController; import net.osmand.plus.mapcontextmenu.controllers.TransportStopController;
import net.osmand.plus.transport.TransportStopRoute;
import net.osmand.plus.mapcontextmenu.controllers.WptPtMenuController; import net.osmand.plus.mapcontextmenu.controllers.WptPtMenuController;
import net.osmand.plus.mapcontextmenu.other.ShareMenu; import net.osmand.plus.mapcontextmenu.other.ShareMenu;
import net.osmand.plus.mapillary.MapillaryImage; import net.osmand.plus.mapillary.MapillaryImage;
@ -65,6 +64,7 @@ import net.osmand.plus.osmo.OsMoGroupsStorage.OsMoDevice;
import net.osmand.plus.osmo.OsMoMenuController; import net.osmand.plus.osmo.OsMoMenuController;
import net.osmand.plus.parkingpoint.ParkingPositionMenuController; import net.osmand.plus.parkingpoint.ParkingPositionMenuController;
import net.osmand.plus.resources.ResourceManager; import net.osmand.plus.resources.ResourceManager;
import net.osmand.plus.transport.TransportStopRoute;
import net.osmand.plus.views.DownloadedRegionsLayer.DownloadMapObject; import net.osmand.plus.views.DownloadedRegionsLayer.DownloadMapObject;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControllerType; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControllerType;
@ -554,42 +554,37 @@ public abstract class MenuController extends BaseMenuController {
public Drawable rightIcon; public Drawable rightIcon;
public boolean enabled = true; public boolean enabled = true;
@Nullable
public Drawable getLeftIcon() { public Drawable getLeftIcon() {
if (leftIcon != null) { return getIconDrawable(true);
return leftIcon;
}
if (leftIconId != 0) {
if (needColorizeIcon) {
return getIcon(leftIconId, getColorRes());
}
return ContextCompat.getDrawable(getMapActivity(), leftIconId);
} else {
return null;
}
} }
@Nullable
public Drawable getRightIcon() { public Drawable getRightIcon() {
if (rightIcon != null) { return getIconDrawable(false);
return rightIcon; }
@Nullable
private Drawable getIconDrawable(boolean left) {
Drawable drawable = left ? leftIcon : rightIcon;
if (drawable != null) {
return drawable;
} }
if (rightIconId != 0) { int resId = left ? leftIconId : rightIconId;
if (resId != 0) {
if (needColorizeIcon) { if (needColorizeIcon) {
return getIcon(rightIconId, getColorRes()); return getIcon(resId, getColorRes());
} }
return ContextCompat.getDrawable(getMapActivity(), rightIconId); return ContextCompat.getDrawable(getMapActivity(), resId);
} else {
return null;
} }
return null;
} }
private int getColorRes() { private int getColorRes() {
int colorRes;
if (enabled) { if (enabled) {
colorRes = isLight() ? R.color.map_widget_blue : R.color.osmand_orange; return isLight() ? R.color.map_widget_blue : R.color.osmand_orange;
} else {
colorRes = isLight() ? R.color.ctx_menu_controller_disabled_text_color_light : R.color.ctx_menu_controller_disabled_text_color_dark;
} }
return colorRes; return isLight() ? R.color.ctx_menu_controller_disabled_text_color_light : R.color.ctx_menu_controller_disabled_text_color_dark;
} }
public abstract void buttonPressed(); public abstract void buttonPressed();

View file

@ -411,14 +411,8 @@ public class ExtendedBottomSheetBehavior<V extends View> extends CoordinatorLayo
top = mParentHeight; top = mParentHeight;
targetState = STATE_HIDDEN; targetState = STATE_HIDDEN;
} else if (mLastNestedScrollDy == 0) { } else if (mLastNestedScrollDy == 0) {
int currentTop = child.getTop(); top = child.getTop();
if (Math.abs(currentTop - mMinOffset) < Math.abs(currentTop - mMaxOffset)) { targetState = STATE_MANUALLY_MOVED;
top = mMinOffset;
targetState = STATE_EXPANDED;
} else {
top = mMaxOffset;
targetState = STATE_COLLAPSED;
}
} else { } else {
if (Math.abs(getYVelocity()) > MIN_VELOCITY_FOR_SLIDE) { if (Math.abs(getYVelocity()) > MIN_VELOCITY_FOR_SLIDE) {
top = mMaxOffset; top = mMaxOffset;