From 3026e7415803279ae5506849f6bae39932b2264b Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Thu, 29 Jun 2017 17:51:30 +0300 Subject: [PATCH 1/2] Add shadow on map at Mapillary Filters --- OsmAnd/res/layout/shadow_on_map.xml | 6 ++++ .../osmand/plus/dashboard/DashboardOnMap.java | 29 +++++++++++++++++-- .../MapillaryFiltersMapShadowFragment.java | 24 +++++++++++++++ 3 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 OsmAnd/res/layout/shadow_on_map.xml create mode 100644 OsmAnd/src/net/osmand/plus/mapillary/MapillaryFiltersMapShadowFragment.java diff --git a/OsmAnd/res/layout/shadow_on_map.xml b/OsmAnd/res/layout/shadow_on_map.xml new file mode 100644 index 0000000000..2e1dc0f883 --- /dev/null +++ b/OsmAnd/res/layout/shadow_on_map.xml @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java index 72bb2f61f9..760f0b01a9 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java @@ -77,6 +77,7 @@ import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu; import net.osmand.plus.mapcontextmenu.other.RoutePreferencesMenu; import net.osmand.plus.mapcontextmenu.other.RoutePreferencesMenu.LocalRoutingParameter; import net.osmand.plus.mapillary.MapillaryFiltersFragment; +import net.osmand.plus.mapillary.MapillaryFiltersMapShadowFragment; import net.osmand.plus.mapillary.MapillaryPlugin.MapillaryFirstDialogFragment; import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin; import net.osmand.plus.routing.RoutingHelper; @@ -823,7 +824,8 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis addOrUpdateDashboardFragments(); } else { mapActivity.getSupportFragmentManager().beginTransaction() - .replace(R.id.content, new MapillaryFiltersFragment(), MapillaryFiltersFragment.TAG) + .replace(R.id.content, new MapillaryFiltersMapShadowFragment(), MapillaryFiltersMapShadowFragment.TAG) + .add(R.id.content, new MapillaryFiltersFragment(), MapillaryFiltersFragment.TAG) .commit(); } scrollView.setVisibility(View.VISIBLE); @@ -1251,11 +1253,13 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis private void removeMapillaryFiltersFragment() { FragmentManager manager = mapActivity.getSupportFragmentManager(); Fragment mapillaryFragment = manager.findFragmentByTag(MapillaryFiltersFragment.TAG); - if (mapillaryFragment != null) { + Fragment shadowOnMap = manager.findFragmentByTag(MapillaryFiltersMapShadowFragment.TAG); + if (mapillaryFragment != null && shadowOnMap != null) { OsmandSettings settings = getMyApplication().getSettings(); TransactionBuilder builder = new TransactionBuilder(manager, settings, mapActivity); builder.getFragmentTransaction() .remove(mapillaryFragment) + .remove(shadowOnMap) .commit(); } } @@ -1371,6 +1375,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis } updateColorOfToolbar(scrollY); updateTopButton(scrollY); + updateMapShadow(scrollY); } private boolean isActionButtonVisible() { @@ -1388,6 +1393,18 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis return !(visibleType == DashboardType.DASHBOARD || visibleType == DashboardType.LIST_MENU); } + private void updateMapShadow(int scrollY) { + View shadowOnMap = dashboardView.findViewById(R.id.shadow_on_map); + if (shadowOnMap != null) { + int minTop = dashboardView.findViewById(R.id.map_part_dashboard).getHeight() - toolbar.getHeight(); + if (scrollY >= minTop) { + shadowOnMap.setVisibility(View.GONE); + } else { + shadowOnMap.setVisibility(View.VISIBLE); + } + } + } + private void updateTopButton(int scrollY) { if (actionButton != null && portrait && isActionButtonVisible()) { @@ -1432,6 +1449,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis gradientToolbar.setAlpha((int) ((1 - t) * 255)); setAlpha(dashboardView, (int) (t * 128), 0); View toolbar = dashboardView.findViewById(R.id.toolbar); + updateMapShadowColor(malpha); if (t < 1) { //noinspection deprecation toolbar.setBackgroundDrawable(gradientToolbar); @@ -1441,6 +1459,13 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis } } + private void updateMapShadowColor(int alpha) { + View shadowOnMap = dashboardView.findViewById(R.id.shadow_on_map); + if (shadowOnMap != null) { + setAlpha(shadowOnMap, alpha, baseColor); + } + } + private void updateListAdapter(ArrayAdapter listAdapter, OnItemClickListener listener) { this.listAdapter = listAdapter; this.listAdapterOnClickListener = listener; diff --git a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryFiltersMapShadowFragment.java b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryFiltersMapShadowFragment.java new file mode 100644 index 0000000000..06880a2cf6 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryFiltersMapShadowFragment.java @@ -0,0 +1,24 @@ +package net.osmand.plus.mapillary; + + +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import net.osmand.plus.R; + +public class MapillaryFiltersMapShadowFragment extends Fragment { + + public static final String TAG = "MAPILLARY_FILTERS_MAP_SHADOW_FRAGMENT"; + + public MapillaryFiltersMapShadowFragment() { + // Required empty public constructor + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + return inflater.inflate(R.layout.shadow_on_map, null); + } +} \ No newline at end of file From e4f38598a125636a3b1d23b90a306361de544b8f Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Fri, 30 Jun 2017 11:48:13 +0300 Subject: [PATCH 2/2] Delete an unnecessary fragment --- .../res/layout/fragment_mapillary_filters.xml | 760 +++++++++--------- OsmAnd/res/layout/shadow_on_map.xml | 6 - .../osmand/plus/dashboard/DashboardOnMap.java | 8 +- .../mapillary/MapillaryFiltersFragment.java | 18 +- .../MapillaryFiltersMapShadowFragment.java | 24 - 5 files changed, 398 insertions(+), 418 deletions(-) delete mode 100644 OsmAnd/res/layout/shadow_on_map.xml delete mode 100644 OsmAnd/src/net/osmand/plus/mapillary/MapillaryFiltersMapShadowFragment.java diff --git a/OsmAnd/res/layout/fragment_mapillary_filters.xml b/OsmAnd/res/layout/fragment_mapillary_filters.xml index c199672912..1940bcbce1 100644 --- a/OsmAnd/res/layout/fragment_mapillary_filters.xml +++ b/OsmAnd/res/layout/fragment_mapillary_filters.xml @@ -1,414 +1,428 @@ - - - - - - - - - - - - - - - -