Updated dashboard on map view

This commit is contained in:
Bars107 2015-03-03 17:15:49 +02:00
parent ba81c700bd
commit a3838eab74
9 changed files with 77 additions and 15 deletions

View file

@ -10,6 +10,7 @@
<LinearLayout android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_gravity="center"
android:layout_height="match_parent">
<net.osmand.plus.dashboard.NotifyingScrollView xmlns:android="http://schemas.android.com/apk/res/android"

View file

@ -33,12 +33,21 @@
android:contentDescription="@string/map_view"
android:visibility="gone"/>
<FrameLayout android:id="@+id/MapInfoControls"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<LinearLayout
android:id="@+id/dialog_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="horizontal"/>
<FrameLayout android:id="@+id/MapButtons"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</FrameLayout>
<ListView

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="dashboard_map_top_padding">0dp</dimen>
<dimen name="dashboard_map_top_padding">100dp</dimen>
<dimen name="dashboard_map_bottom_padding">0dp</dimen>
</resources>

View file

@ -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;
}
}

View file

@ -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);
}

View file

@ -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;
}
}

View file

@ -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,9 +208,9 @@ 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()) {
@ -218,9 +218,13 @@ public class MapControlsLayer extends OsmandMapLayer {
}
}
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()){

View file

@ -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

View file

@ -65,6 +65,7 @@ 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) {
Context ctx = mapActivity;
Button button = new Button(ctx);