Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
4c9d6b5740
15 changed files with 304 additions and 107 deletions
11
OsmAnd/res/drawable/bg_additional_menu_dark.xml
Normal file
11
OsmAnd/res/drawable/bg_additional_menu_dark.xml
Normal 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>
|
11
OsmAnd/res/drawable/bg_additional_menu_light.xml
Normal file
11
OsmAnd/res/drawable/bg_additional_menu_light.xml
Normal 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>
|
11
OsmAnd/res/drawable/bg_additional_menu_sides_dark.xml
Normal file
11
OsmAnd/res/drawable/bg_additional_menu_sides_dark.xml
Normal 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>
|
11
OsmAnd/res/drawable/bg_additional_menu_sides_light.xml
Normal file
11
OsmAnd/res/drawable/bg_additional_menu_sides_light.xml
Normal 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>
|
11
OsmAnd/res/drawable/bg_additional_menu_topsides_dark.xml
Normal file
11
OsmAnd/res/drawable/bg_additional_menu_topsides_dark.xml
Normal 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>
|
11
OsmAnd/res/drawable/bg_additional_menu_topsides_light.xml
Normal file
11
OsmAnd/res/drawable/bg_additional_menu_topsides_light.xml
Normal 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>
|
|
@ -1,36 +1,49 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.v4.widget.NestedScrollView
|
||||
<LinearLayout
|
||||
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_height="wrap_content"
|
||||
android:background="?attr/bg_color">
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
<android.support.design.widget.CoordinatorLayout
|
||||
android:id="@+id/scroll_view_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
<android.support.v4.widget.NestedScrollView
|
||||
android:id="@+id/bottom_sheet_scroll_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="@dimen/bottom_sheet_content_padding_small">
|
||||
|
||||
<include layout="@layout/bottom_sheet_dialog_fragment_title"/>
|
||||
app:behavior_hideable="true"
|
||||
app:layout_behavior="net.osmand.plus.widgets.tools.ExtendedBottomSheetBehavior"
|
||||
tools:background="?attr/bg_color">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:id="@+id/context_menu_items_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
</LinearLayout>
|
||||
android:layout_height="wrap_content"
|
||||
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
|
||||
android:id="@+id/divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
tools:background="?attr/dashboard_divider"/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/cancel_row"
|
||||
|
@ -51,4 +64,4 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
</android.support.v4.widget.NestedScrollView>
|
||||
</LinearLayout>
|
||||
|
|
36
OsmAnd/res/layout/grid_menu_item.xml
Normal file
36
OsmAnd/res/layout/grid_menu_item.xml
Normal 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>
|
33
OsmAnd/res/layout/grid_menu_row.xml
Normal file
33
OsmAnd/res/layout/grid_menu_row.xml
Normal 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>
|
|
@ -180,4 +180,7 @@
|
|||
<dimen name="multi_selection_menu_padding_top">20dp</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>
|
|
@ -378,4 +378,6 @@
|
|||
<color name="multi_selection_menu_close_btn_light">#2f7af5</color>
|
||||
<color name="multi_selection_menu_close_btn_dark">#e69122</color>
|
||||
|
||||
<color name="grid_menu_icon_dark">#808080</color>
|
||||
|
||||
</resources>
|
|
@ -252,4 +252,8 @@
|
|||
|
||||
<dimen name="multi_selection_menu_padding_top">13dp</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>
|
|
@ -1,91 +1,79 @@
|
|||
package net.osmand.plus.mapcontextmenu;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.app.Activity;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.design.widget.BottomSheetBehavior;
|
||||
import android.support.design.widget.BottomSheetDialog;
|
||||
import android.support.design.widget.BottomSheetDialogFragment;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
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";
|
||||
|
||||
private boolean nightMode;
|
||||
private boolean portrait;
|
||||
private int availableScreenH;
|
||||
|
||||
private ContextMenuAdapter adapter;
|
||||
private ContextMenuItemClickListener listener;
|
||||
|
||||
private View scrollView;
|
||||
private View cancelRowBgView;
|
||||
|
||||
public void setAdapter(ContextMenuAdapter adapter, ContextMenuItemClickListener listener) {
|
||||
this.adapter = adapter;
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public void setupDialog(Dialog dialog, int style) {
|
||||
super.setupDialog(dialog, style);
|
||||
|
||||
if (getMyApplication().getSettings().DO_NOT_USE_ANIMATIONS.get()) {
|
||||
dialog.getWindow().setWindowAnimations(R.style.Animations_NoAnimation);
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
Activity activity = getActivity();
|
||||
nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
||||
portrait = AndroidUiHelper.isOrientationPortrait(activity);
|
||||
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);
|
||||
scrollView = mainView.findViewById(R.id.bottom_sheet_scroll_view);
|
||||
cancelRowBgView = mainView.findViewById(R.id.cancel_row_background);
|
||||
|
||||
AndroidUtils.setBackground(getActivity(), mainView, nightMode,
|
||||
portrait ? R.drawable.bg_bottom_menu_light : R.drawable.bg_bottom_sheet_topsides_landscape_light,
|
||||
portrait ? R.drawable.bg_bottom_menu_dark : R.drawable.bg_bottom_sheet_topsides_landscape_dark);
|
||||
updateBackground(false);
|
||||
cancelRowBgView.setBackgroundResource(getCancelRowBgResId());
|
||||
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
|
||||
public void onClick(View view) {
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
TextView headerTitle = (TextView) mainView.findViewById(R.id.header_title);
|
||||
if (nightMode) {
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
mainView.findViewById(R.id.cancel_row).setOnClickListener(dismissOnClickListener);
|
||||
mainView.findViewById(R.id.scroll_view_container).setOnClickListener(dismissOnClickListener);
|
||||
|
||||
View.OnClickListener onClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -98,24 +86,52 @@ public class AdditionalActionsBottomSheetDialogFragment extends BottomSheetDialo
|
|||
};
|
||||
|
||||
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++) {
|
||||
ContextMenuItem item = adapter.getItem(i);
|
||||
int layoutResId = item.getLayout();
|
||||
layoutResId = layoutResId != ContextMenuItem.INVALID_ID ? layoutResId : R.layout.bottom_sheet_dialog_fragment_item;
|
||||
View row = View.inflate(new ContextThemeWrapper(getContext(), themeRes), layoutResId, null);
|
||||
if (layoutResId != R.layout.bottom_sheet_dialog_fragment_divider) {
|
||||
layoutResId = layoutResId == ContextMenuItem.INVALID_ID ? R.layout.grid_menu_item : layoutResId;
|
||||
boolean dividerItem = 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) {
|
||||
((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);
|
||||
((View) mainView.getParent()).setBackgroundResource(0);
|
||||
ExtendedBottomSheetBehavior behavior = ExtendedBottomSheetBehavior.from(scrollView);
|
||||
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
|
||||
|
@ -129,12 +145,47 @@ public class AdditionalActionsBottomSheetDialogFragment extends BottomSheetDialo
|
|||
}
|
||||
}
|
||||
|
||||
private OsmandApplication getMyApplication() {
|
||||
return ((MapActivity) getActivity()).getMyApplication();
|
||||
@Override
|
||||
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) {
|
||||
return getMyApplication().getIconsCache().getIcon(id, nightMode ? R.color.ctx_menu_info_text_dark : R.color.on_map_icon_color);
|
||||
private int getCancelRowBgResId() {
|
||||
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 {
|
||||
|
|
|
@ -3,8 +3,8 @@ package net.osmand.plus.mapcontextmenu;
|
|||
import android.graphics.drawable.Drawable;
|
||||
import android.os.AsyncTask;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
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.TransportRouteController;
|
||||
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.other.ShareMenu;
|
||||
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.parkingpoint.ParkingPositionMenuController;
|
||||
import net.osmand.plus.resources.ResourceManager;
|
||||
import net.osmand.plus.transport.TransportStopRoute;
|
||||
import net.osmand.plus.views.DownloadedRegionsLayer.DownloadMapObject;
|
||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
|
||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControllerType;
|
||||
|
@ -554,42 +554,37 @@ public abstract class MenuController extends BaseMenuController {
|
|||
public Drawable rightIcon;
|
||||
public boolean enabled = true;
|
||||
|
||||
@Nullable
|
||||
public Drawable getLeftIcon() {
|
||||
if (leftIcon != null) {
|
||||
return leftIcon;
|
||||
}
|
||||
if (leftIconId != 0) {
|
||||
if (needColorizeIcon) {
|
||||
return getIcon(leftIconId, getColorRes());
|
||||
}
|
||||
return ContextCompat.getDrawable(getMapActivity(), leftIconId);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return getIconDrawable(true);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Drawable getRightIcon() {
|
||||
if (rightIcon != null) {
|
||||
return rightIcon;
|
||||
return getIconDrawable(false);
|
||||
}
|
||||
|
||||
@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) {
|
||||
return getIcon(rightIconId, getColorRes());
|
||||
return getIcon(resId, getColorRes());
|
||||
}
|
||||
return ContextCompat.getDrawable(getMapActivity(), rightIconId);
|
||||
} else {
|
||||
return null;
|
||||
return ContextCompat.getDrawable(getMapActivity(), resId);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private int getColorRes() {
|
||||
int colorRes;
|
||||
if (enabled) {
|
||||
colorRes = 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 isLight() ? R.color.map_widget_blue : R.color.osmand_orange;
|
||||
}
|
||||
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();
|
||||
|
|
|
@ -411,14 +411,8 @@ public class ExtendedBottomSheetBehavior<V extends View> extends CoordinatorLayo
|
|||
top = mParentHeight;
|
||||
targetState = STATE_HIDDEN;
|
||||
} else if (mLastNestedScrollDy == 0) {
|
||||
int currentTop = child.getTop();
|
||||
if (Math.abs(currentTop - mMinOffset) < Math.abs(currentTop - mMaxOffset)) {
|
||||
top = mMinOffset;
|
||||
targetState = STATE_EXPANDED;
|
||||
} else {
|
||||
top = mMaxOffset;
|
||||
targetState = STATE_COLLAPSED;
|
||||
}
|
||||
top = child.getTop();
|
||||
targetState = STATE_MANUALLY_MOVED;
|
||||
} else {
|
||||
if (Math.abs(getYVelocity()) > MIN_VELOCITY_FOR_SLIDE) {
|
||||
top = mMaxOffset;
|
||||
|
|
Loading…
Reference in a new issue