From 65c6e953148c05776c59c055607840f2bc08e8e3 Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 9 Nov 2017 19:43:32 +0200 Subject: [PATCH] Add shadow below app bar --- .../fragment_direction_indication_dialog.xml | 688 +++++++++--------- .../DirectionIndicationDialogFragment.java | 33 + 2 files changed, 385 insertions(+), 336 deletions(-) diff --git a/OsmAnd/res/layout/fragment_direction_indication_dialog.xml b/OsmAnd/res/layout/fragment_direction_indication_dialog.xml index fc1ef92b67..d8f301029f 100644 --- a/OsmAnd/res/layout/fragment_direction_indication_dialog.xml +++ b/OsmAnd/res/layout/fragment_direction_indication_dialog.xml @@ -54,347 +54,363 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + android:layout_gravity="top" + android:scaleType="fitXY" + android:src="@drawable/bg_shadow_list_bottom" + android:visibility="gone"/> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/DirectionIndicationDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/DirectionIndicationDialogFragment.java index 5cea55e080..efd3a3edf6 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/DirectionIndicationDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/DirectionIndicationDialogFragment.java @@ -23,6 +23,10 @@ import android.widget.PopupMenu.OnMenuItemClickListener; import android.widget.RadioButton; import android.widget.TextView; +import com.github.ksoichiro.android.observablescrollview.ObservableScrollView; +import com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks; +import com.github.ksoichiro.android.observablescrollview.ScrollState; + import net.osmand.plus.ApplicationMode; import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings.MapMarkersMode; @@ -40,6 +44,9 @@ public class DirectionIndicationDialogFragment extends BaseOsmAndDialogFragment private DirectionIndicationFragmentListener listener; private View mainView; + private int helpImgHeight; + private boolean shadowVisible; + public void setListener(DirectionIndicationFragmentListener listener) { this.listener = listener; } @@ -48,6 +55,7 @@ public class DirectionIndicationDialogFragment extends BaseOsmAndDialogFragment @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { final OsmandSettings settings = getSettings(); + helpImgHeight = getResources().getDimensionPixelSize(R.dimen.action_bar_image_height); mainView = inflater.inflate(R.layout.fragment_direction_indication_dialog, container); @@ -65,6 +73,31 @@ public class DirectionIndicationDialogFragment extends BaseOsmAndDialogFragment appModeTv.setText(appMode.getStringResource()); appModeTv.setCompoundDrawablesWithIntrinsicBounds(null, null, getIconsCache().getIcon(appMode.getSmallIconDark()), null); + ((ObservableScrollView) mainView.findViewById(R.id.scroll_view)).setScrollViewCallbacks(new ObservableScrollViewCallbacks() { + @Override + public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) { + if (scrollY >= helpImgHeight) { + if (!shadowVisible) { + mainView.findViewById(R.id.app_bar_shadow).setVisibility(View.VISIBLE); + shadowVisible = true; + } + } else if (shadowVisible) { + mainView.findViewById(R.id.app_bar_shadow).setVisibility(View.GONE); + shadowVisible = false; + } + } + + @Override + public void onDownMotionEvent() { + + } + + @Override + public void onUpOrCancelMotionEvent(ScrollState scrollState) { + + } + }); + updateHelpImage(); final TextView menuTv = (TextView) mainView.findViewById(R.id.active_markers_text_view);