Update route preparation

This commit is contained in:
Victor Shcherb 2015-04-22 23:52:02 +02:00
parent 3172aef7c5
commit f74c332d41
16 changed files with 106 additions and 77 deletions

View file

@ -5,8 +5,12 @@
android:orientation="horizontal" android:orientation="horizontal"
android:weightSum="1" > android:weightSum="1" >
<View android:layout_width="@dimen/map_route_planning_land_width"
android:layout_height="0dp"
android:id="@+id/map_route_land_left_margin"
android:layout_gravity="top|left"
android:visibility="gone" />
<!-- LEFT widgets colon --> <!-- LEFT widgets colon -->
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"

View file

@ -54,7 +54,7 @@ import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.base.FavoriteImageDrawable; import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.dialogs.DirectionsDialogs; import net.osmand.plus.dialogs.DirectionsDialogs;
import net.osmand.plus.helpers.ColorDialogs; import net.osmand.plus.helpers.ColorDialogs;
import net.osmand.plus.helpers.ScreenOrientationHelper; import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.myplaces.FavoritesActivity; import net.osmand.plus.myplaces.FavoritesActivity;
import net.osmand.util.MapUtils; import net.osmand.util.MapUtils;
@ -371,7 +371,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
} }
}); });
if (ScreenOrientationHelper.isOrientationPortrait(getActivity())) { if (AndroidUiHelper.isOrientationPortrait(getActivity())) {
menu = ((FavoritesActivity) getActivity()).getClearToolbar(true).getMenu(); menu = ((FavoritesActivity) getActivity()).getClearToolbar(true).getMenu();
} else { } else {
((FavoritesActivity) getActivity()).getClearToolbar(false); ((FavoritesActivity) getActivity()).getClearToolbar(false);

View file

@ -12,7 +12,7 @@ import android.support.v7.widget.Toolbar;
import android.view.*; import android.view.*;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.helpers.ScreenOrientationHelper; import net.osmand.plus.helpers.AndroidUiHelper;
import android.os.Bundle; import android.os.Bundle;
import android.webkit.WebView; import android.webkit.WebView;
import android.webkit.WebViewClient; import android.webkit.WebViewClient;
@ -105,7 +105,7 @@ public class HelpActivity extends OsmandActionBarActivity {
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
if (ScreenOrientationHelper.isOrientationPortrait(this)){ if (AndroidUiHelper.isOrientationPortrait(this)){
menu = getClearToolbar(true).getMenu(); menu = getClearToolbar(true).getMenu();
} else { } else {
getClearToolbar(false); getClearToolbar(false);

View file

@ -10,7 +10,7 @@ import net.osmand.plus.activities.search.SearchActivity;
import net.osmand.plus.activities.search.SearchActivity.SearchActivityChild; import net.osmand.plus.activities.search.SearchActivity.SearchActivityChild;
import net.osmand.plus.dialogs.DirectionsDialogs; import net.osmand.plus.dialogs.DirectionsDialogs;
import net.osmand.plus.dialogs.FavoriteDialogs; import net.osmand.plus.dialogs.FavoriteDialogs;
import net.osmand.plus.helpers.ScreenOrientationHelper; import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.util.MapUtils; import net.osmand.util.MapUtils;
import android.app.Dialog; import android.app.Dialog;
import android.content.Intent; import android.content.Intent;
@ -109,7 +109,7 @@ public class NavigatePointFragment extends Fragment implements SearchActivityChi
@Override @Override
public void onCreateOptionsMenu(Menu onCreate, MenuInflater inflater) { public void onCreateOptionsMenu(Menu onCreate, MenuInflater inflater) {
OsmandApplication app = (OsmandApplication) getActivity().getApplication(); OsmandApplication app = (OsmandApplication) getActivity().getApplication();
boolean portrait = ScreenOrientationHelper.isOrientationPortrait(getActivity()); boolean portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
boolean light = app.getSettings().isLightActionBar(); boolean light = app.getSettings().isLightActionBar();
Menu menu = onCreate; Menu menu = onCreate;
if(getActivity() instanceof SearchActivity) { if(getActivity() instanceof SearchActivity) {

View file

@ -11,7 +11,7 @@ import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dialogs.DirectionsDialogs; import net.osmand.plus.dialogs.DirectionsDialogs;
import net.osmand.plus.dialogs.FavoriteDialogs; import net.osmand.plus.dialogs.FavoriteDialogs;
import net.osmand.plus.helpers.FileNameTranslationHelper; import net.osmand.plus.helpers.FileNameTranslationHelper;
import net.osmand.plus.helpers.ScreenOrientationHelper; import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.resources.RegionAddressRepository; import net.osmand.plus.resources.RegionAddressRepository;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import android.app.Dialog; import android.app.Dialog;
@ -84,7 +84,7 @@ public class SearchAddressFragment extends Fragment {
@Override @Override
public void onCreateOptionsMenu(Menu onCreate, MenuInflater inflater) { public void onCreateOptionsMenu(Menu onCreate, MenuInflater inflater) {
Menu menu = onCreate; Menu menu = onCreate;
boolean portrait = ScreenOrientationHelper.isOrientationPortrait(getActivity()); boolean portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
if(getActivity() instanceof SearchActivity) { if(getActivity() instanceof SearchActivity) {
if (portrait) { if (portrait) {
menu = ((SearchActivity) getActivity()).getClearToolbar(true).getMenu(); menu = ((SearchActivity) getActivity()).getClearToolbar(true).getMenu();

View file

@ -22,7 +22,7 @@ import net.osmand.plus.development.DashSimulateFragment;
import net.osmand.plus.development.OsmandDevelopmentPlugin; import net.osmand.plus.development.OsmandDevelopmentPlugin;
import net.osmand.plus.dialogs.ConfigureMapMenu; import net.osmand.plus.dialogs.ConfigureMapMenu;
import net.osmand.plus.download.DownloadActivity; import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.helpers.ScreenOrientationHelper; import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.helpers.WaypointDialogHelper; import net.osmand.plus.helpers.WaypointDialogHelper;
import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper; import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
import net.osmand.plus.monitoring.DashTrackFragment; import net.osmand.plus.monitoring.DashTrackFragment;
@ -126,7 +126,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
public void createDashboardView() { public void createDashboardView() {
baseColor = mapActivity.getResources().getColor(R.color.osmand_orange) & 0x00ffffff; baseColor = mapActivity.getResources().getColor(R.color.osmand_orange) & 0x00ffffff;
waypointDialogHelper = new WaypointDialogHelper(mapActivity); waypointDialogHelper = new WaypointDialogHelper(mapActivity);
landscape = !ScreenOrientationHelper.isOrientationPortrait(mapActivity); landscape = !AndroidUiHelper.isOrientationPortrait(mapActivity);
dashboardView = (FrameLayout) mapActivity.findViewById(R.id.dashboard); dashboardView = (FrameLayout) mapActivity.findViewById(R.id.dashboard);
View.OnClickListener listener = new View.OnClickListener() { View.OnClickListener listener = new View.OnClickListener() {
@Override @Override
@ -138,7 +138,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
ObservableScrollView scrollView = ((ObservableScrollView) dashboardView.findViewById(R.id.main_scroll)); ObservableScrollView scrollView = ((ObservableScrollView) dashboardView.findViewById(R.id.main_scroll));
listView = (ListView) dashboardView.findViewById(R.id.dash_list_view); listView = (ListView) dashboardView.findViewById(R.id.dash_list_view);
gradientToolbar = mapActivity.getResources().getDrawable(R.drawable.gradient_toolbar).mutate(); gradientToolbar = mapActivity.getResources().getDrawable(R.drawable.gradient_toolbar).mutate();
if (ScreenOrientationHelper.isOrientationPortrait(mapActivity)) { if (AndroidUiHelper.isOrientationPortrait(mapActivity)) {
this.portrait = true; this.portrait = true;
scrollView.setScrollViewCallbacks(this); scrollView.setScrollViewCallbacks(this);
((ObservableListView) listView).setScrollViewCallbacks(this); ((ObservableListView) listView).setScrollViewCallbacks(this);

View file

@ -1,17 +1,18 @@
package net.osmand.plus.helpers; package net.osmand.plus.helpers;
import net.osmand.PlatformUtil;
import android.app.Activity; import android.app.Activity;
import android.content.Context;
import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.Log; import android.util.Log;
import android.view.Surface; import android.view.Surface;
import net.osmand.PlatformUtil; import android.view.View;
/** /**
* Created by dummy on 28.01.15. * Created by dummy on 28.01.15.
*/ */
public class ScreenOrientationHelper { public class AndroidUiHelper {
public static int getScreenOrientation(Activity activity) { public static int getScreenOrientation(Activity activity) {
int rotation = activity.getWindowManager().getDefaultDisplay().getRotation(); int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
@ -75,9 +76,26 @@ public class ScreenOrientationHelper {
return orientation; return orientation;
} }
public static boolean updateVisibility(View view, boolean visible) {
if (view != null && visible != (view.getVisibility() == View.VISIBLE)) {
if (visible) {
view.setVisibility(View.VISIBLE);
} else {
view.setVisibility(View.GONE);
}
view.invalidate();
return true;
}
return false;
}
public static boolean isLargeDevice(Activity ctx) {
return (ctx.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE;
}
public static boolean isOrientationPortrait(Activity ctx) { public static boolean isOrientationPortrait(Activity ctx) {
int orientation = ScreenOrientationHelper.getScreenOrientation(ctx); int orientation = AndroidUiHelper.getScreenOrientation(ctx);
return orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT || return orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT ||
orientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; orientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
} }

View file

@ -57,7 +57,7 @@ import net.osmand.plus.activities.SavingTrackHelper;
import net.osmand.plus.activities.TrackActivity; import net.osmand.plus.activities.TrackActivity;
import net.osmand.plus.dialogs.DirectionsDialogs; import net.osmand.plus.dialogs.DirectionsDialogs;
import net.osmand.plus.download.LocalIndexesFragment; import net.osmand.plus.download.LocalIndexesFragment;
import net.osmand.plus.helpers.ScreenOrientationHelper; import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.monitoring.OsmandMonitoringPlugin; import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
import net.osmand.plus.osmedit.OsmEditingPlugin; import net.osmand.plus.osmedit.OsmEditingPlugin;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
@ -327,7 +327,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
} }
}); });
if (ScreenOrientationHelper.isOrientationPortrait(getActivity())) { if (AndroidUiHelper.isOrientationPortrait(getActivity())) {
menu = ((FavoritesActivity) getActivity()).getClearToolbar(true).getMenu(); menu = ((FavoritesActivity) getActivity()).getClearToolbar(true).getMenu();
} else { } else {
((FavoritesActivity) getActivity()).getClearToolbar(false); ((FavoritesActivity) getActivity()).getClearToolbar(false);
@ -366,7 +366,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
final MenuItem item; final MenuItem item;
item = menu.add(0, optionsMenuAdapter.getElementId(j), j + 1, optionsMenuAdapter.getItemName(j)); item = menu.add(0, optionsMenuAdapter.getElementId(j), j + 1, optionsMenuAdapter.getItemName(j));
MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
if (ScreenOrientationHelper.isOrientationPortrait(getActivity())) { if (AndroidUiHelper.isOrientationPortrait(getActivity())) {
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override @Override
public boolean onMenuItemClick(MenuItem menuItem) { public boolean onMenuItemClick(MenuItem menuItem) {
@ -427,7 +427,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
private void enableSelectionMode(boolean selectionMode) { private void enableSelectionMode(boolean selectionMode) {
this.selectionMode = selectionMode; this.selectionMode = selectionMode;
if (ScreenOrientationHelper.isOrientationPortrait(getActivity())) { if (AndroidUiHelper.isOrientationPortrait(getActivity())) {
((FavoritesActivity) getActivity()).setToolbarVisibility(!selectionMode); ((FavoritesActivity) getActivity()).setToolbarVisibility(!selectionMode);
} }
} }

View file

@ -37,7 +37,7 @@ import net.osmand.plus.R;
import net.osmand.plus.activities.ActionBarProgressActivity; import net.osmand.plus.activities.ActionBarProgressActivity;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dialogs.DirectionsDialogs; import net.osmand.plus.dialogs.DirectionsDialogs;
import net.osmand.plus.helpers.ScreenOrientationHelper; import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.myplaces.FavoritesActivity; import net.osmand.plus.myplaces.FavoritesActivity;
import org.xmlpull.v1.XmlSerializer; import org.xmlpull.v1.XmlSerializer;
@ -123,7 +123,7 @@ public class OsmEditsFragment extends ListFragment implements OsmEditsUploadList
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
menu.clear(); menu.clear();
if (ScreenOrientationHelper.isOrientationPortrait(getActivity())) { if (AndroidUiHelper.isOrientationPortrait(getActivity())) {
menu = ((ActionBarProgressActivity) getActivity()).getClearToolbar(true).getMenu(); menu = ((ActionBarProgressActivity) getActivity()).getClearToolbar(true).getMenu();
} else { } else {
((ActionBarProgressActivity) getActivity()).getClearToolbar(false); ((ActionBarProgressActivity) getActivity()).getClearToolbar(false);

View file

@ -80,7 +80,7 @@ import net.osmand.plus.activities.OsmandExpandableListActivity;
import net.osmand.plus.activities.actions.ShareDialog; import net.osmand.plus.activities.actions.ShareDialog;
import net.osmand.plus.base.MapViewTrackingUtilities; import net.osmand.plus.base.MapViewTrackingUtilities;
import net.osmand.plus.helpers.ColorDialogs; import net.osmand.plus.helpers.ColorDialogs;
import net.osmand.plus.helpers.ScreenOrientationHelper; import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.osmo.OsMoGroups.OsMoGroupsUIListener; import net.osmand.plus.osmo.OsMoGroups.OsMoGroupsUIListener;
import net.osmand.plus.osmo.OsMoGroupsStorage.OsMoDevice; import net.osmand.plus.osmo.OsMoGroupsStorage.OsMoDevice;
import net.osmand.plus.osmo.OsMoGroupsStorage.OsMoGroup; import net.osmand.plus.osmo.OsMoGroupsStorage.OsMoGroup;
@ -451,7 +451,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
@Override @Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) { public boolean onCreateActionMode(ActionMode mode, Menu menu) {
selectedObject = o; selectedObject = o;
boolean portrait = ScreenOrientationHelper.isOrientationPortrait(OsMoGroupsActivity.this); boolean portrait = AndroidUiHelper.isOrientationPortrait(OsMoGroupsActivity.this);
if (portrait) { if (portrait) {
menu = getClearToolbar(true).getMenu(); menu = getClearToolbar(true).getMenu();
} else { } else {
@ -524,7 +524,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
public void onDestroyActionMode(ActionMode mode) { public void onDestroyActionMode(ActionMode mode) {
selectedObject = null; selectedObject = null;
refreshList(); refreshList();
if (ScreenOrientationHelper.isOrientationPortrait(OsMoGroupsActivity.this)){ if (AndroidUiHelper.isOrientationPortrait(OsMoGroupsActivity.this)){
onCreateOptionsMenu(menu); onCreateOptionsMenu(menu);
} }
} }
@ -1030,7 +1030,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
menu.clear(); menu.clear();
Menu oldMenu = menu; Menu oldMenu = menu;
boolean portrait = ScreenOrientationHelper.isOrientationPortrait(this); boolean portrait = AndroidUiHelper.isOrientationPortrait(this);
if (portrait) { if (portrait) {
menu = getClearToolbar(true).getMenu(); menu = getClearToolbar(true).getMenu();
} else { } else {

View file

@ -514,22 +514,9 @@ public class MapControlsLayer extends OsmandMapLayer {
@Override @Override
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings nightMode) { public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings nightMode) {
updateControls(tileBox, nightMode); updateControls(tileBox, nightMode);
boolean b = optionsRouteControlDialog.isDialogVisible() || mapRouteInfoControlDialog.isDialogVisible();
updateVisibility(mapActivity.findViewById(R.id.map_right_widgets_panel), !b);
} }
protected boolean updateVisibility(View view, boolean visible) {
if (view != null && visible != (view.getVisibility() == View.VISIBLE)) {
if (visible) {
view.setVisibility(View.VISIBLE);
} else {
view.setVisibility(View.GONE);
}
view.invalidate();
return true;
}
return false;
}
private void updateControls(RotatedTileBox tileBox, DrawSettings nightMode) { private void updateControls(RotatedTileBox tileBox, DrawSettings nightMode) {
boolean isNight = nightMode != null && nightMode.isNightMode(); boolean isNight = nightMode != null && nightMode.isNightMode();

View file

@ -12,7 +12,7 @@ import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dialogs.ConfigureMapMenu; import net.osmand.plus.dialogs.ConfigureMapMenu;
import net.osmand.plus.helpers.ScreenOrientationHelper; import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopTextView; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopTextView;
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry; import net.osmand.plus.views.mapwidgets.MapWidgetRegistry;
@ -193,7 +193,7 @@ public class MapInfoLayer extends OsmandMapLayer {
} }
private void updateStreetName(boolean nightMode, TextState ts) { private void updateStreetName(boolean nightMode, TextState ts) {
streetNameView.setBackgroundResource(ScreenOrientationHelper.isOrientationPortrait(map) ? ts.boxTop streetNameView.setBackgroundResource(AndroidUiHelper.isOrientationPortrait(map) ? ts.boxTop
: ts.boxFree); : ts.boxFree);
streetNameView.updateTextColor(nightMode, ts.textColor, ts.textShadowColor, ts.textBold, ts.textShadowRadius); streetNameView.updateTextColor(nightMode, ts.textColor, ts.textShadowColor, ts.textBold, ts.textShadowRadius);
} }

View file

@ -113,7 +113,9 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
private float rotate; // accumulate private float rotate; // accumulate
private int mapPosition; private int mapPosition;
private int mapPositionX;
private boolean showMapPosition = true; private boolean showMapPosition = true;
private IMapLocationListener locationListener; private IMapLocationListener locationListener;
@ -398,6 +400,10 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
public void setMapPosition(int type) { public void setMapPosition(int type) {
this.mapPosition = type; this.mapPosition = type;
} }
public void setMapPositionX(int type) {
this.mapPositionX = type;
}
public OsmandSettings getSettings() { public OsmandSettings getSettings() {
return settings; return settings;
@ -472,10 +478,13 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
return; return;
} }
final float ratioy = mapPosition == OsmandSettings.BOTTOM_CONSTANT ? 0.85f : 0.5f; final float ratioy = mapPosition == OsmandSettings.BOTTOM_CONSTANT ? 0.85f : 0.5f;
final float ratiox = mapPositionX == 0 ? 0.5f : 0.75f;
final int cy = (int) (ratioy * view.getHeight()); final int cy = (int) (ratioy * view.getHeight());
final int cx = (int) (ratiox * view.getWidth());
if (currentViewport.getPixWidth() != view.getWidth() || currentViewport.getPixHeight() != view.getHeight() || if (currentViewport.getPixWidth() != view.getWidth() || currentViewport.getPixHeight() != view.getHeight() ||
currentViewport.getCenterPixelY() != cy) { currentViewport.getCenterPixelY() != cy ||
currentViewport.setPixelDimensions(view.getWidth(), view.getHeight(), 0.5f, ratioy); currentViewport.getCenterPixelX() != cx) {
currentViewport.setPixelDimensions(view.getWidth(), view.getHeight(), ratiox, ratioy);
refreshBufferImage(drawSettings); refreshBufferImage(drawSettings);
} }
if (view instanceof SurfaceView) { if (view instanceof SurfaceView) {

View file

@ -27,7 +27,6 @@ import net.osmand.plus.activities.search.SearchAddressActivity;
import net.osmand.plus.activities.search.SearchAddressFragment; import net.osmand.plus.activities.search.SearchAddressFragment;
import net.osmand.plus.development.OsmandDevelopmentPlugin; import net.osmand.plus.development.OsmandDevelopmentPlugin;
import net.osmand.plus.dialogs.FavoriteDialogs; import net.osmand.plus.dialogs.FavoriteDialogs;
import net.osmand.plus.helpers.ScreenOrientationHelper;
import net.osmand.plus.routing.RouteDirectionInfo; import net.osmand.plus.routing.RouteDirectionInfo;
import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener; import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener;
@ -39,15 +38,8 @@ import android.content.DialogInterface;
import android.content.DialogInterface.OnDismissListener; import android.content.DialogInterface.OnDismissListener;
import android.content.Intent; import android.content.Intent;
import android.graphics.PointF; import android.graphics.PointF;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.View; import android.view.View;
import android.view.View.MeasureSpec;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener; import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
@ -543,15 +535,10 @@ public class MapRouteInfoControl implements IRouteInformationListener {
public void showDialog() { public void showDialog() {
final View ll = mapActivity.getLayoutInflater().inflate(R.layout.plan_route_info, null); final View ll = mapActivity.getLayoutInflater().inflate(R.layout.plan_route_info, null);
updateInfo(ll); updateInfo(ll);
dialog = MapRoutePreferencesControl.createDialog(mapActivity, ll); dialog = MapRoutePreferencesControl.showDialog(mapControlsLayer, mapActivity, ll, new OnDismissListener() {
final boolean switched = mapControlsLayer.switchToRoutePlanningLayout();
dialog.show();
dialog.setOnDismissListener(new OnDismissListener() {
@Override @Override
public void onDismiss(DialogInterface dlg) { public void onDismiss(DialogInterface dialog) {
if(switched) {
mapControlsLayer.switchToRouteFollowingLayout();
}
dialog = null; dialog = null;
} }
}); });

View file

@ -22,7 +22,7 @@ import net.osmand.plus.activities.SettingsBaseActivity;
import net.osmand.plus.activities.SettingsNavigationActivity; import net.osmand.plus.activities.SettingsNavigationActivity;
import net.osmand.plus.activities.actions.AppModeDialog; import net.osmand.plus.activities.actions.AppModeDialog;
import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.GpxUiHelper;
import net.osmand.plus.helpers.ScreenOrientationHelper; import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder; import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder;
import net.osmand.plus.routing.RouteProvider.RouteService; import net.osmand.plus.routing.RouteProvider.RouteService;
import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.RoutingHelper;
@ -37,11 +37,9 @@ import android.content.DialogInterface;
import android.content.DialogInterface.OnDismissListener; import android.content.DialogInterface.OnDismissListener;
import android.content.Intent; import android.content.Intent;
import android.support.v7.widget.PopupMenu; import android.support.v7.widget.PopupMenu;
import android.util.TypedValue;
import android.view.Gravity; import android.view.Gravity;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.View.MeasureSpec;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams; import android.view.ViewGroup.LayoutParams;
import android.view.ViewTreeObserver.OnGlobalLayoutListener; import android.view.ViewTreeObserver.OnGlobalLayoutListener;
@ -133,26 +131,23 @@ public class MapRoutePreferencesControl {
dialog.hide(); dialog.hide();
dialog = null; dialog = null;
} else { } else {
final boolean switched = controlsLayer.switchToRoutePlanningLayout(); dialog = showDialog(controlsLayer, mapActivity, createLayout(), new OnDismissListener() {
dialog = createDialog(mapActivity, createLayout());
dialog.show();
dialog.setOnDismissListener(new OnDismissListener() {
@Override @Override
public void onDismiss(DialogInterface dlg) { public void onDismiss(DialogInterface dialog) {
dialog = null; dialog = null;
if(switched) {
controlsLayer.switchToRouteFollowingLayout();
}
} }
}); });
} }
} }
public static Dialog createDialog(MapActivity mapActivity, final View ll) { public static Dialog showDialog(final MapControlsLayer controlsLayer, final MapActivity mapActivity, final View ll,
final OnDismissListener dismiss) {
final boolean switched = controlsLayer.switchToRoutePlanningLayout();
final Dialog dialog = new Dialog(mapActivity); final Dialog dialog = new Dialog(mapActivity);
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
final int maxHeight ; final int maxHeight ;
boolean portrait = ScreenOrientationHelper.isOrientationPortrait(mapActivity); boolean portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
if(portrait) { if(portrait) {
maxHeight = (int) mapActivity.getResources().getDimension(R.dimen.map_route_planning_max_height); maxHeight = (int) mapActivity.getResources().getDimension(R.dimen.map_route_planning_max_height);
lp.width = WindowManager.LayoutParams.MATCH_PARENT; lp.width = WindowManager.LayoutParams.MATCH_PARENT;
@ -188,8 +183,37 @@ public class MapRoutePreferencesControl {
} }
}); });
} }
if(!portrait) {
mapActivity.getMapView().setMapPositionX(1);
mapActivity.getMapView().refreshMap();
}
dialog.show();
if(!AndroidUiHelper.isLargeDevice(mapActivity)) {
AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_right_widgets_panel), false);
AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_left_widgets_panel), false);
}
if(!portrait) {
AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_route_land_left_margin), true);
}
dialog.setOnDismissListener(new OnDismissListener() {
@Override
public void onDismiss(DialogInterface dlg) {
mapActivity.getMapView().setMapPositionX(0);
mapActivity.getMapView().refreshMap();
AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_route_land_left_margin), false);
AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_right_widgets_panel), true);
AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_left_widgets_panel), true);
if(switched) {
controlsLayer.switchToRouteFollowingLayout();
}
if(dismiss != null){
dismiss.onDismiss(dialog);
}
}
});
return dialog; return dialog;
} }
private void updateGpxRoutingParameter(OtherLocalRoutingParameter gpxParam) { private void updateGpxRoutingParameter(OtherLocalRoutingParameter gpxParam) {
GPXRouteParamsBuilder rp = mapActivity.getRoutingHelper().getCurrentGPXRoute(); GPXRouteParamsBuilder rp = mapActivity.getRoutingHelper().getCurrentGPXRoute();

View file

@ -19,7 +19,7 @@ import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.TargetPointsHelper.TargetPoint; import net.osmand.plus.TargetPointsHelper.TargetPoint;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.MapViewTrackingUtilities; import net.osmand.plus.base.MapViewTrackingUtilities;
import net.osmand.plus.helpers.ScreenOrientationHelper; import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.helpers.WaypointHelper; import net.osmand.plus.helpers.WaypointHelper;
import net.osmand.plus.routing.AlarmInfo; import net.osmand.plus.routing.AlarmInfo;
import net.osmand.plus.routing.AlarmInfo.AlarmInfoType; import net.osmand.plus.routing.AlarmInfo.AlarmInfoType;
@ -734,7 +734,7 @@ public class RouteInfoWidgetsFactory {
text = (TextView) ma.findViewById(R.id.map_ruler_text); text = (TextView) ma.findViewById(R.id.map_ruler_text);
textShadow = (TextView) ma.findViewById(R.id.map_ruler_text_shadow); textShadow = (TextView) ma.findViewById(R.id.map_ruler_text_shadow);
maxWidth = ma.getResources().getDimensionPixelSize(R.dimen.map_ruler_width); maxWidth = ma.getResources().getDimensionPixelSize(R.dimen.map_ruler_width);
orientationPortrait = ScreenOrientationHelper.isOrientationPortrait(ma); orientationPortrait = AndroidUiHelper.isOrientationPortrait(ma);
} }
public void updateTextSize(boolean isNight, int textColor, int textShadowColor, int shadowRadius) { public void updateTextSize(boolean isNight, int textColor, int textShadowColor, int shadowRadius) {