From a3c1e42960878915b227a3b5e2972dca84eb6e24 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Mon, 27 Nov 2017 15:56:24 +0200 Subject: [PATCH 001/121] Remove fab and shadow --- .../res/layout/map_context_menu_fragment.xml | 19 ---------- .../MapContextMenuFragment.java | 35 ++----------------- 2 files changed, 2 insertions(+), 52 deletions(-) diff --git a/OsmAnd/res/layout/map_context_menu_fragment.xml b/OsmAnd/res/layout/map_context_menu_fragment.xml index bf1a78ede6..92101ccb62 100644 --- a/OsmAnd/res/layout/map_context_menu_fragment.xml +++ b/OsmAnd/res/layout/map_context_menu_fragment.xml @@ -13,14 +13,6 @@ android:layout_height="match_parent" android:orientation="vertical"> - - - - - - \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index 2ecedf2e9a..1596a3587c 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -68,7 +68,6 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo private View view; private View mainView; - private ImageView fabView; private View zoomButtonsView; private ImageButton zoomInButtonView; private ImageButton zoomOutButtonView; @@ -77,7 +76,6 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo private OnLayoutChangeListener containerLayoutListener; private int menuTopViewHeight; - private int menuTopShadowHeight; private int menuTopShadowAllHeight; private int menuTitleHeight; private int menuBottomViewHeight; @@ -345,8 +343,6 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo View topView = view.findViewById(R.id.context_menu_top_view); topView.setOnTouchListener(slideTouchListener); - View topShadowView = view.findViewById(R.id.context_menu_top_shadow); - topShadowView.setOnTouchListener(slideTouchListener); View topShadowAllView = view.findViewById(R.id.context_menu_top_shadow_all); AndroidUtils.setBackground(getMapActivity(), topShadowAllView, nightMode, R.drawable.bg_map_context_menu_light, R.drawable.bg_map_context_menu_dark); @@ -383,25 +379,6 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo AndroidUtils.setTextSecondaryColor(getMapActivity(), (TextView) view.findViewById(R.id.progressTitle), nightMode); - // FAB - fabView = (ImageView) view.findViewById(R.id.context_menu_fab_view); - if (menu.fabVisible()) { - fabView.setImageDrawable(getIcon(menu.getFabIconId(), 0)); - if (menu.isLandscapeLayout()) { - FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) fabView.getLayoutParams(); - params.setMargins(0, 0, dpToPx(28f), 0); - fabView.setLayoutParams(params); - } - fabView.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - menu.fabPressed(); - } - }); - } else { - fabView.setVisibility(View.GONE); - } - // Zoom buttons zoomButtonsView = view.findViewById(R.id.context_menu_zoom_buttons); zoomInButtonView = (ImageButton) view.findViewById(R.id.context_menu_zoom_in_button); @@ -668,11 +645,6 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo }) .start(); - fabView.animate().y(getFabY(posY)) - .setDuration(200) - .setInterpolator(new DecelerateInterpolator()) - .start(); - zoomButtonsView.animate().y(getZoomButtonsY(posY)) .setDuration(200) .setInterpolator(new DecelerateInterpolator()) @@ -997,7 +969,6 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo } int newMenuTopViewHeight = view.findViewById(R.id.context_menu_top_view).getHeight(); - menuTopShadowHeight = view.findViewById(R.id.context_menu_top_shadow).getHeight(); int newMenuTopShadowAllHeight = view.findViewById(R.id.context_menu_top_shadow_all).getHeight(); menuFullHeight = view.findViewById(R.id.context_menu_main).getHeight(); zoomButtonsHeight = zoomButtonsView.getHeight(); @@ -1061,7 +1032,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo } menuTopViewHeight = newMenuTopViewHeight; menuTopShadowAllHeight = newMenuTopShadowAllHeight; - menuTitleHeight = menuTopShadowHeight + menuTopShadowAllHeight + dy; + menuTitleHeight = menuTopShadowAllHeight + dy; menuBottomViewHeight = view.findViewById(R.id.context_menu_bottom_view).getHeight(); menuFullHeightMax = menuTitleHeight + menuBottomViewHeight; @@ -1231,7 +1202,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo posY = Math.max(posY, minHalfY); break; case MenuState.FULL_SCREEN: - posY = -menuTopShadowHeight - dpToPx(SHADOW_HEIGHT_TOP_DP); + posY = -dpToPx(SHADOW_HEIGHT_TOP_DP); posY = addStatusBarHeightIfNeeded(posY); break; default: @@ -1274,11 +1245,9 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo private void setViewY(int y, boolean animated, boolean adjustMapPos) { if (!oldAndroid()) { mainView.setY(y); - fabView.setY(getFabY(y)); zoomButtonsView.setY(getZoomButtonsY(y)); } else { mainView.setPadding(0, y, 0, 0); - fabView.setPadding(0, getFabY(y), 0, 0); zoomButtonsView.setPadding(0, getZoomButtonsY(y), 0, 0); } if (!customMapCenter) { From 92b431d643512b7bca99f21d1f08b62708183002 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Tue, 28 Nov 2017 11:15:55 +0200 Subject: [PATCH 002/121] Remove code for old android --- .../MapContextMenuFragment.java | 105 +++++++----------- 1 file changed, 38 insertions(+), 67 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index 1596a3587c..da7b8c8681 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -304,12 +304,10 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo setViewY((int) newY, false, false); menuFullHeight = view.getHeight() - (int) newY + 10; - if (!oldAndroid()) { - ViewGroup.LayoutParams lp = mainView.getLayoutParams(); - lp.height = Math.max(menuFullHeight, menuTitleHeight); - mainView.setLayoutParams(lp); - mainView.requestLayout(); - } + ViewGroup.LayoutParams lp = mainView.getLayoutParams(); + lp.height = Math.max(menuFullHeight, menuTitleHeight); + mainView.setLayoutParams(lp); + mainView.requestLayout(); velocity.addMovement(event); velocity.computeCurrentVelocity(1000); @@ -616,53 +614,41 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo updateMainViewLayout(posY); } - if (!oldAndroid()) { - mainView.animate().y(posY) - .setDuration(200) - .setInterpolator(new DecelerateInterpolator()) - .setListener(new AnimatorListenerAdapter() { + mainView.animate().y(posY) + .setDuration(200) + .setInterpolator(new DecelerateInterpolator()) + .setListener(new AnimatorListenerAdapter() { - boolean canceled = false; + boolean canceled = false; - @Override - public void onAnimationCancel(Animator animation) { - canceled = true; - } + @Override + public void onAnimationCancel(Animator animation) { + canceled = true; + } - @Override - public void onAnimationEnd(Animator animation) { - if (!canceled) { - if (needCloseMenu) { - menu.close(); - } else { - updateMainViewLayout(posY); - if (previousMenuState != 0 && newMenuState != 0 && previousMenuState != newMenuState) { - doAfterMenuStateChange(previousMenuState, newMenuState); - } + @Override + public void onAnimationEnd(Animator animation) { + if (!canceled) { + if (needCloseMenu) { + menu.close(); + } else { + updateMainViewLayout(posY); + if (previousMenuState != 0 && newMenuState != 0 && previousMenuState != newMenuState) { + doAfterMenuStateChange(previousMenuState, newMenuState); } } } - }) - .start(); + } + }) + .start(); - zoomButtonsView.animate().y(getZoomButtonsY(posY)) - .setDuration(200) - .setInterpolator(new DecelerateInterpolator()) - .start(); + zoomButtonsView.animate().y(getZoomButtonsY(posY)) + .setDuration(200) + .setInterpolator(new DecelerateInterpolator()) + .start(); - if (needMapAdjust) { - adjustMapPosition(posY, true, centered, dZoom); - } - } else { - setViewY(posY, false, needMapAdjust); - if (needCloseMenu) { - menu.close(); - } else { - updateMainViewLayout(posY); - if (previousMenuState != 0 && newMenuState != 0 && previousMenuState != newMenuState) { - doAfterMenuStateChange(previousMenuState, newMenuState); - } - } + if (needMapAdjust) { + adjustMapPosition(posY, true, centered, dZoom); } } } @@ -1225,31 +1211,20 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo private void updateMainViewLayout(int posY) { if (view != null) { menuFullHeight = view.getHeight() - posY; - if (!oldAndroid()) { - ViewGroup.LayoutParams lp = mainView.getLayoutParams(); - lp.height = Math.max(menuFullHeight, menuTitleHeight); - mainView.setLayoutParams(lp); - mainView.requestLayout(); - } + ViewGroup.LayoutParams lp = mainView.getLayoutParams(); + lp.height = Math.max(menuFullHeight, menuTitleHeight); + mainView.setLayoutParams(lp); + mainView.requestLayout(); } } private int getViewY() { - if (!oldAndroid()) { - return (int) mainView.getY(); - } else { - return mainView.getPaddingTop(); - } + return (int) mainView.getY(); } private void setViewY(int y, boolean animated, boolean adjustMapPos) { - if (!oldAndroid()) { - mainView.setY(y); - zoomButtonsView.setY(getZoomButtonsY(y)); - } else { - mainView.setPadding(0, y, 0, 0); - zoomButtonsView.setPadding(0, getZoomButtonsY(y), 0, 0); - } + mainView.setY(y); + zoomButtonsView.setY(getZoomButtonsY(y)); if (!customMapCenter) { if (adjustMapPos) { adjustMapPosition(y, animated, centered, 0); @@ -1354,10 +1329,6 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo return y - zoomButtonsHeight - fabPaddingTopPx; } - private boolean oldAndroid() { - return (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH); - } - private void doLayoutMenu() { final int posY = getPosY(); setViewY(posY, true, !initLayout || !centered); From 6dfe75cdd9a9f468e6af9cd3d92fb53d3d8af643 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Tue, 28 Nov 2017 16:36:20 +0200 Subject: [PATCH 003/121] Add bottom buttons for context menu --- .../res/layout/map_context_menu_fragment.xml | 66 +++++++++++++------ .../plus/mapcontextmenu/MapContextMenu.java | 4 +- .../MapContextMenuFragment.java | 27 +++++--- .../osmand/plus/views/MapControlsLayer.java | 4 +- 4 files changed, 68 insertions(+), 33 deletions(-) diff --git a/OsmAnd/res/layout/map_context_menu_fragment.xml b/OsmAnd/res/layout/map_context_menu_fragment.xml index 92101ccb62..5843952d84 100644 --- a/OsmAnd/res/layout/map_context_menu_fragment.xml +++ b/OsmAnd/res/layout/map_context_menu_fragment.xml @@ -5,7 +5,8 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="@android:color/transparent"> + android:background="@android:color/transparent" + xmlns:osmand="http://schemas.android.com/apk/res-auto"> - - - - - - + + + + + + + + + + 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { - navigateFab(); + navigateButton(); } else if (requestCode == REQUEST_LOCATION_FOR_ADD_DESTINATION_PERMISSION && grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { From 2fe0a745e16efb7e58fb705a9b16932376bbdec8 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Tue, 28 Nov 2017 16:42:53 +0200 Subject: [PATCH 004/121] Remove old code --- .../MapContextMenuFragment.java | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index 9dd2de7623..935f175bfa 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -107,7 +107,6 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo private int screenOrientation; private boolean created; - @TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -486,18 +485,16 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo //getMapActivity().getMapLayers().getMapControlsLayer().setControlsClickable(false); - if (Build.VERSION.SDK_INT >= 11) { - containerLayoutListener = new OnLayoutChangeListener() { - @Override - public void onLayoutChange(View view, int left, int top, int right, int bottom, - int oldLeft, int oldTop, int oldRight, int oldBottom) { - if (bottom != oldBottom) { - processScreenHeight(view.getParent()); - runLayoutListener(); - } + containerLayoutListener = new OnLayoutChangeListener() { + @Override + public void onLayoutChange(View view, int left, int top, int right, int bottom, + int oldLeft, int oldTop, int oldRight, int oldBottom) { + if (bottom != oldBottom) { + processScreenHeight(view.getParent()); + runLayoutListener(); } - }; - } + } + }; created = true; return view; @@ -528,11 +525,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo private void processScreenHeight(ViewParent parent) { View container = (View)parent; - if (Build.VERSION.SDK_INT >= 11) { - screenHeight = container.getHeight() + AndroidUtils.getStatusBarHeight(getActivity()); - } else { - screenHeight = AndroidUtils.getScreenHeight(getActivity()); - } + screenHeight = container.getHeight() + AndroidUtils.getStatusBarHeight(getActivity()); skipHalfScreenStateLimit = screenHeight * SKIP_HALF_SCREEN_STATE_KOEF; viewHeight = screenHeight - AndroidUtils.getStatusBarHeight(getMapActivity()); } From ce132996eb594c6131ddd2e092cd01e4809bbe1e Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Tue, 28 Nov 2017 17:04:19 +0200 Subject: [PATCH 005/121] Styling bottom buttons --- .../res/layout/map_context_menu_fragment.xml | 28 +++++++++---------- OsmAnd/res/values-large/sizes.xml | 3 ++ OsmAnd/res/values/sizes.xml | 3 ++ 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/OsmAnd/res/layout/map_context_menu_fragment.xml b/OsmAnd/res/layout/map_context_menu_fragment.xml index 5843952d84..6f81e18189 100644 --- a/OsmAnd/res/layout/map_context_menu_fragment.xml +++ b/OsmAnd/res/layout/map_context_menu_fragment.xml @@ -411,40 +411,40 @@ android:background="?attr/dashboard_divider"/> + android:layout_height="@dimen/context_menu_buttons_bottom" + android:paddingLeft="@dimen/context_menu_padding_medium" + android:paddingRight="@dimen/context_menu_padding_medium" + android:paddingTop="@dimen/context_menu_padding_small" + android:paddingBottom="@dimen/context_menu_padding_small"> - - diff --git a/OsmAnd/res/values-large/sizes.xml b/OsmAnd/res/values-large/sizes.xml index f8ce4c32be..e352e92b73 100644 --- a/OsmAnd/res/values-large/sizes.xml +++ b/OsmAnd/res/values-large/sizes.xml @@ -58,6 +58,9 @@ 80dp 66dp 80dp + 63dp + 12dp + 9dp 90dp 18dp diff --git a/OsmAnd/res/values/sizes.xml b/OsmAnd/res/values/sizes.xml index 76a1309b52..99035c5b7a 100644 --- a/OsmAnd/res/values/sizes.xml +++ b/OsmAnd/res/values/sizes.xml @@ -129,6 +129,9 @@ 54dp 44dp 54dp + 48dp + 8dp + 6dp 62dp 12dp From 630603c165d0366566dad3a6c261ea310284d312 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Tue, 28 Nov 2017 17:05:31 +0200 Subject: [PATCH 006/121] Move dimen to res --- OsmAnd/res/layout/map_context_menu_fragment.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/layout/map_context_menu_fragment.xml b/OsmAnd/res/layout/map_context_menu_fragment.xml index 6f81e18189..0f16aef0b0 100644 --- a/OsmAnd/res/layout/map_context_menu_fragment.xml +++ b/OsmAnd/res/layout/map_context_menu_fragment.xml @@ -442,7 +442,7 @@ android:paddingRight="@dimen/context_menu_button_padding_x" android:gravity="end|center_vertical" tools:drawableEnd="@drawable/map_directions" - android:drawablePadding="8dp" + android:drawablePadding="@dimen/context_menu_padding_medium" android:textColor="?attr/contextMenuButtonColor" android:textSize="@dimen/default_desc_text_size" android:text="@string/get_directions"/> From 71330aef6c4b9febe3be89f004e9701f4657d4cb Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Tue, 28 Nov 2017 18:15:08 +0200 Subject: [PATCH 007/121] Replace action buttons --- .../res/layout/map_context_menu_fragment.xml | 155 ++++++++++++------ OsmAnd/res/values-large/sizes.xml | 4 +- OsmAnd/res/values/sizes.xml | 4 +- OsmAnd/res/values/strings.xml | 2 + .../MapContextMenuFragment.java | 49 +++--- 5 files changed, 142 insertions(+), 72 deletions(-) diff --git a/OsmAnd/res/layout/map_context_menu_fragment.xml b/OsmAnd/res/layout/map_context_menu_fragment.xml index 0f16aef0b0..f7dcbc7426 100644 --- a/OsmAnd/res/layout/map_context_menu_fragment.xml +++ b/OsmAnd/res/layout/map_context_menu_fragment.xml @@ -5,8 +5,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="@android:color/transparent" - xmlns:osmand="http://schemas.android.com/apk/res-auto"> + android:background="@android:color/transparent"> + android:layout_height="wrap_content" + android:orientation="horizontal"> - + android:layout_height="wrap_content" + android:orientation="vertical" + android:paddingTop="@dimen/context_menu_padding_margin_medium" + android:paddingBottom="@dimen/context_menu_padding_margin_medium"> - + - + - + + + android:layout_height="wrap_content" + android:orientation="vertical" + android:paddingTop="@dimen/context_menu_padding_margin_medium" + android:paddingBottom="@dimen/context_menu_padding_margin_medium"> + + + + + + + + + + + + + + + + + + + + + + @@ -414,10 +477,10 @@ android:id="@+id/context_menu_bottom_buttons" android:layout_width="match_parent" android:layout_height="@dimen/context_menu_buttons_bottom" - android:paddingLeft="@dimen/context_menu_padding_medium" - android:paddingRight="@dimen/context_menu_padding_medium" - android:paddingTop="@dimen/context_menu_padding_small" - android:paddingBottom="@dimen/context_menu_padding_small"> + android:paddingLeft="@dimen/context_menu_padding_margin_medium" + android:paddingRight="@dimen/context_menu_padding_margin_medium" + android:paddingTop="@dimen/context_menu_padding_margin_small" + android:paddingBottom="@dimen/context_menu_padding_margin_small">