Fix dashboard

This commit is contained in:
Victor Shcherb 2015-03-03 18:34:48 +02:00
parent 5dd241e8d5
commit 5891c80c95
4 changed files with 73 additions and 38 deletions

View file

@ -384,31 +384,7 @@ public class MapActivity extends AccessibleActivity {
checkExternalStorage();
showAndHideMapPosition();
LatLon cur = new LatLon(mapView.getLatitude(), mapView.getLongitude());
LatLon latLonToShow = settings.getAndClearMapLocationToShow();
PointDescription mapLabelToShow = settings.getAndClearMapLabelToShow();
Object toShow = settings.getAndClearObjectToShow();
int status = settings.isRouteToPointNavigateAndClear();
if(status != 0){
// always enable and follow and let calculate it (i.e.GPS is not accessible in a garage)
Location loc = new Location("map");
loc.setLatitude(mapView.getLatitude());
loc.setLongitude(mapView.getLongitude());
getMapActions().enterRoutePlanningMode(null, null, status == OsmandSettings.NAVIGATE_CURRENT_GPX);
}
if(mapLabelToShow != null && latLonToShow != null){
mapLayers.getContextMenuLayer().setSelectedObject(toShow);
mapLayers.getContextMenuLayer().setLocation(latLonToShow, mapLabelToShow.getFullPlainName(this,
latLonToShow.getLatitude(), latLonToShow.getLongitude()));
}
if (latLonToShow != null && !latLonToShow.equals(cur)) {
mapView.getAnimatedDraggingThread().startMoving(latLonToShow.getLatitude(), latLonToShow.getLongitude(),
settings.getMapZoomToShow(), true);
}
if(latLonToShow != null) {
// remember if map should come back to isMapLinkedToLocation=true
mapViewTrackingUtilities.setMapLinkedToLocation(false);
}
readLocationToShow();
final Intent intent = getIntent();
if (intent != null) {
@ -458,6 +434,34 @@ public class MapActivity extends AccessibleActivity {
getMyApplication().getAppCustomization().resumeActivity(MapActivity.class, this);
}
public void readLocationToShow() {
LatLon cur = new LatLon(mapView.getLatitude(), mapView.getLongitude());
LatLon latLonToShow = settings.getAndClearMapLocationToShow();
PointDescription mapLabelToShow = settings.getAndClearMapLabelToShow();
Object toShow = settings.getAndClearObjectToShow();
int status = settings.isRouteToPointNavigateAndClear();
if(status != 0){
// always enable and follow and let calculate it (i.e.GPS is not accessible in a garage)
Location loc = new Location("map");
loc.setLatitude(mapView.getLatitude());
loc.setLongitude(mapView.getLongitude());
getMapActions().enterRoutePlanningMode(null, null, status == OsmandSettings.NAVIGATE_CURRENT_GPX);
}
if(mapLabelToShow != null && latLonToShow != null){
mapLayers.getContextMenuLayer().setSelectedObject(toShow);
mapLayers.getContextMenuLayer().setLocation(latLonToShow, mapLabelToShow.getFullPlainName(this,
latLonToShow.getLatitude(), latLonToShow.getLongitude()));
}
if (latLonToShow != null && !latLonToShow.equals(cur)) {
mapView.getAnimatedDraggingThread().startMoving(latLonToShow.getLatitude(), latLonToShow.getLongitude(),
settings.getMapZoomToShow(), true);
}
if(latLonToShow != null) {
// remember if map should come back to isMapLinkedToLocation=true
mapViewTrackingUtilities.setMapLinkedToLocation(false);
}
}
public OsmandApplication getMyApplication() {
return ((OsmandApplication) getApplication());
@ -835,9 +839,14 @@ public class MapActivity extends AccessibleActivity {
public static void launchMapActivityMoveToTop(Context activity){
Intent newIntent = new Intent(activity, ((OsmandApplication) activity.getApplicationContext()).getAppCustomization().getMapActivity());
newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
activity.startActivity(newIntent);
if(activity instanceof MapActivity) {
((MapActivity) activity).getDashboard().setDashboardVisibility(false);
((MapActivity) activity).readLocationToShow();
} else {
Intent newIntent = new Intent(activity, ((OsmandApplication) activity.getApplicationContext()).getAppCustomization().getMapActivity());
newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
activity.startActivity(newIntent);
}
}

View file

@ -1,5 +1,11 @@
package net.osmand.plus.dashboard;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.audionotes.DashAudioVideoNotesFragment;
import net.osmand.plus.helpers.ScreenOrientationHelper;
import net.osmand.plus.monitoring.DashTrackFragment;
import net.osmand.plus.views.controls.FloatingActionButton;
import android.content.res.Resources;
import android.graphics.Color;
import android.os.Build;
@ -9,17 +15,12 @@ import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.TranslateAnimation;
import android.widget.FrameLayout;
import android.widget.ScrollView;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.audionotes.DashAudioVideoNotesFragment;
import net.osmand.plus.helpers.ScreenOrientationHelper;
import net.osmand.plus.monitoring.DashTrackFragment;
import net.osmand.plus.views.controls.FloatingActionButton;
/**
* Created by Denis
* on 03.03.15.
@ -90,10 +91,10 @@ public class DashboardOnMap {
ma.findViewById(R.id.MapButtons).setVisibility(View.GONE);
} else {
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);
fabButton.hideFloatingActionButton();
}
}
@ -106,13 +107,31 @@ public class DashboardOnMap {
view.setVisibility(View.VISIBLE);
}
public void hide(View view){
TranslateAnimation animate = new TranslateAnimation(0,0,0,ma.getMapView().getHeight());
public void hide(View view) {
TranslateAnimation animate = new TranslateAnimation(0, 0, 0, ma.getMapView().getHeight());
animate.setDuration(500);
animate.setFillAfter(true);
animate.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
dashboardView.setVisibility(View.GONE);
}
});
view.startAnimation(animate);
view.setVisibility(View.GONE);
}
private void addDashboardFragments(){
FragmentManager manager =ma. getSupportFragmentManager();

View file

@ -58,6 +58,9 @@ public class MapMenuControls extends MapControls {
@Override
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings nightMode) {
if(mapActivity.findViewById(R.id.MapButtons).getVisibility() == View.GONE) {
return;
}
drawApplicationMode(canvas, nightMode != null && nightMode.isNightMode());
}

View file

@ -13,6 +13,7 @@ import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.text.TextPaint;
import android.view.View;
import android.widget.FrameLayout;
public class RulerControl extends MapControls {
@ -60,6 +61,9 @@ public class RulerControl extends MapControls {
if( (zoomControls.isVisible() && zoomControls.isShowZoomLevel()) || !mapActivity.getMyApplication().getSettings().SHOW_RULER.get()){
return;
}
if(mapActivity.findViewById(R.id.MapButtons).getVisibility() == View.GONE) {
return;
}
OsmandMapTileView view = mapActivity.getMapView();
boolean isNight = nightMode == null ? false : nightMode.isNightMode();
// update cache