diff --git a/OsmAnd/res/layout/dashboard_over_map.xml b/OsmAnd/res/layout/dashboard_over_map.xml index e6395e4acc..0fce4b7d39 100644 --- a/OsmAnd/res/layout/dashboard_over_map.xml +++ b/OsmAnd/res/layout/dashboard_over_map.xml @@ -10,6 +10,7 @@ + + + + + - 0dp + 100dp 0dp \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 32b27ba5bf..270d4f8e86 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -303,6 +303,9 @@ public class MapActivity extends AccessibleActivity { @Override public void onBackPressed() { + if (dashboardOnMap.isVisible()){ + dashboardOnMap.setDashboardVisibility(false); + } if (!mapActions.onBackPressed()) { super.onBackPressed(); } @@ -843,4 +846,7 @@ public class MapActivity extends AccessibleActivity { } + public DashboardOnMap getDashboard() { + return dashboardOnMap; + } } diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index eefa848c16..22a5826dd9 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -703,7 +703,7 @@ public class MapActivityActions implements DialogProvider { // Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getMainMenuActivity()); // newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // mapActivity.startActivity(newIntent); - mapActivity.setDashboardVisibility(true); + mapActivity.getDashboard().setDashboardVisibility(true); return true; } }).reg(); @@ -949,6 +949,14 @@ public class MapActivityActions implements DialogProvider { listAdapter, null)); } + public void disableDrawer(){ + mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); + } + + public void enableDrawer(){ + mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED); + } + public void openIntermediatePointsDialog(){ waypointDialogHelper.showWaypointsDialog(mapActivity, false); } diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java index 39e729d007..73b2e296bd 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java @@ -9,6 +9,7 @@ import android.util.TypedValue; import android.view.Gravity; import android.view.View; import android.view.ViewGroup; +import android.view.animation.TranslateAnimation; import android.widget.FrameLayout; import android.widget.ScrollView; @@ -20,7 +21,8 @@ import net.osmand.plus.monitoring.DashTrackFragment; import net.osmand.plus.views.controls.FloatingActionButton; /** - * Created by dummy on 03.03.15. + * Created by Denis + * on 03.03.15. */ public class DashboardOnMap { @@ -29,6 +31,7 @@ public class DashboardOnMap { FloatingActionButton fabButton; boolean floatingButtonVisible = false; private FrameLayout dashboardView; + private boolean visible = false; public DashboardOnMap(MapActivity ma) { @@ -74,23 +77,49 @@ public class DashboardOnMap { public void setDashboardVisibility(boolean visible) { + this.visible = visible; if (visible) { addDashboardFragments(); dashboardView.setVisibility(View.VISIBLE); if (floatingButtonVisible) { fabButton.showFloatingActionButton(); } + open(dashboardView.findViewById(R.id.content)); + ma.getMapActions().disableDrawer(); //View close = dashboardView.findViewById(R.id.close_dashboard); if (ScreenOrientationHelper.isOrientationPortrait(ma)) { //close.setVisibility(View.VISIBLE); } else { //close.setVisibility(View.GONE); } + ma.findViewById(R.id.MapInfoControls).setVisibility(View.GONE); + ma.findViewById(R.id.MapButtons).setVisibility(View.GONE); } else { - ma.findViewById(R.id.dashboard).setVisibility(View.GONE); + ma.getMapActions().enableDrawer(); + dashboardView.setVisibility(View.GONE); + hide(dashboardView.findViewById(R.id.content)); + ma.findViewById(R.id.MapInfoControls).setVisibility(View.VISIBLE); + ma.findViewById(R.id.MapButtons).setVisibility(View.VISIBLE); } } + // To animate view slide out from right to left + public void open(View view){ + TranslateAnimation animate = new TranslateAnimation(0,0,ma.getMapView().getHeight(),0); + animate.setDuration(500); + animate.setFillAfter(true); + view.startAnimation(animate); + view.setVisibility(View.VISIBLE); + } + + public void hide(View view){ + TranslateAnimation animate = new TranslateAnimation(0,0,0,ma.getMapView().getHeight()); + animate.setDuration(500); + animate.setFillAfter(true); + view.startAnimation(animate); + view.setVisibility(View.GONE); + } + private void addDashboardFragments(){ FragmentManager manager =ma. getSupportFragmentManager(); FragmentTransaction fragmentTransaction = manager.beginTransaction(); @@ -159,4 +188,7 @@ public class DashboardOnMap { } }; + public boolean isVisible() { + return visible; + } } diff --git a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java index c4c760ae3f..25cfa44ed8 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java @@ -81,7 +81,7 @@ public class MapControlsLayer extends OsmandMapLayer { @Override public void initLayer(final OsmandMapTileView view) { scaleCoefficient = view.getScaleCoefficient(); - FrameLayout parent = (FrameLayout) view.getParent(); + FrameLayout parent = getParent(); Handler showUIHandler = new Handler(); int rightGravity = Gravity.RIGHT | Gravity.BOTTOM; int leftGravity = Gravity.LEFT | Gravity.BOTTOM; @@ -208,19 +208,23 @@ public class MapControlsLayer extends OsmandMapLayer { RotatedTileBox tileBox, DrawSettings nightMode) { if(visibility != controls.isVisible() ){ if(visibility) { - controls.show((FrameLayout) mapActivity.getMapView().getParent()); + controls.show(getParent()); } else { - controls.hide((FrameLayout) mapActivity.getMapView().getParent()); + controls.hide(getParent()); } } if(controls.isVisible()) { controls.onDraw(canvas, tileBox, nightMode); } } - + + private FrameLayout getParent() { + return (FrameLayout) mapActivity.findViewById(R.id.MapButtons); + } + private void forceHideView(MapControls controls) { if (controls.isVisible()) { - controls.forceHide((FrameLayout) mapActivity.getMapView().getParent()); + controls.forceHide(getParent()); } } @@ -239,10 +243,10 @@ public class MapControlsLayer extends OsmandMapLayer { public boolean onTouchEvent(MotionEvent event, RotatedTileBox tileBox) { if(!mapActivity.getRoutingHelper().isRoutePlanningMode() && mapActivity.getRoutingHelper().isFollowingMode()) { if(!settings.SHOW_ZOOM_BUTTONS_NAVIGATION.get()) { - zoomControls.showWithDelay((FrameLayout) mapActivity.getMapView().getParent(), TIMEOUT_TO_SHOW_BUTTONS); - mapMenuControls.showWithDelay((FrameLayout) mapActivity.getMapView().getParent(), TIMEOUT_TO_SHOW_BUTTONS); + zoomControls.showWithDelay(getParent(), TIMEOUT_TO_SHOW_BUTTONS); + mapMenuControls.showWithDelay(getParent(), TIMEOUT_TO_SHOW_BUTTONS); } - mapRoutePlanControl.showWithDelay((FrameLayout) mapActivity.getMapView().getParent(), TIMEOUT_TO_SHOW_BUTTONS); + mapRoutePlanControl.showWithDelay(getParent(), TIMEOUT_TO_SHOW_BUTTONS); } for(MapControls m : allControls) { if(m.isVisible() && m.onTouchEvent(event, tileBox)){ @@ -318,7 +322,7 @@ public class MapControlsLayer extends OsmandMapLayer { } public void shiftLayout(int height) { - FrameLayout parent = (FrameLayout) mapActivity.getMapView().getParent(); + FrameLayout parent = getParent(); parent.requestLayout(); for(MapControls mc : allControls) { if(mc.isBottom()){ diff --git a/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java b/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java index 61509ddfb8..69090480bc 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java @@ -220,6 +220,7 @@ public class MapInfoLayer extends OsmandMapLayer { } public void createControls() { + FrameLayout parent = (FrameLayout) ((FrameLayout) view.getParent()).findViewById(R.id.MapInfoControls); // 1. Create view groups and controls statusBar.setBackgroundDrawable(view.getResources().getDrawable(R.drawable.box_top)); @@ -239,7 +240,7 @@ public class MapInfoLayer extends OsmandMapLayer { Rect statusBarPadding = new Rect(); statusBar.getBackground().getPadding(statusBarPadding); // 3. put into frame parent layout controls - FrameLayout parent = (FrameLayout) view.getParent(); + // status bar hides own top part int topMargin = statusBar.getMeasuredHeight() - statusBarPadding.top - statusBarPadding.bottom ; // we want that status bar lays over map stack controls diff --git a/OsmAnd/src/net/osmand/plus/views/controls/MapControls.java b/OsmAnd/src/net/osmand/plus/views/controls/MapControls.java index 1b29d4c103..d7403526a7 100644 --- a/OsmAnd/src/net/osmand/plus/views/controls/MapControls.java +++ b/OsmAnd/src/net/osmand/plus/views/controls/MapControls.java @@ -65,7 +65,8 @@ public abstract class MapControls { protected Button addButton(FrameLayout parent, int stringId, int resourceId) { return addButton(parent, stringId, resourceId, 0); } - protected Button addButton(FrameLayout parent, int stringId, int resourceId, int extraMargin) { + + protected Button addButton(FrameLayout parent, int stringId, int resourceId, int extraMargin) { Context ctx = mapActivity; Button button = new Button(ctx); applyAttributes(ctx, parent, button, stringId, resourceId, extraMargin);