Change UI for Plan Route

This commit is contained in:
Alexander Sytnyk 2017-10-05 19:04:48 +03:00
parent 8f9896dcd8
commit 74f37b6c5d
3 changed files with 242 additions and 321 deletions

View file

@ -1,53 +1,38 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:osmand="http://schemas.android.com/apk/res-auto" xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="@dimen/dashboard_land_width"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/color_transparent" android:background="@android:color/transparent"
android:clickable="true"> android:orientation="vertical">
<LinearLayout <LinearLayout
android:id="@+id/main_view" android:id="@+id/main_view"
android:layout_width="match_parent" android:layout_width="@dimen/dashboard_land_width"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_gravity="bottom" android:background="?attr/left_menu_view_bg"
android:clickable="true" android:orientation="vertical">
android:orientation="vertical"
tools:background="@drawable/bg_bottom_menu_dark">
<ProgressBar <android.support.design.widget.AppBarLayout
android:id="@+id/snap_to_road_progress_bar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="@dimen/dashboard_map_toolbar"
android:minHeight="0dp" tools:background="@color/actionbar_dark_color">
android:visibility="gone"
tools:visibility="visible"/> <android.support.v7.widget.Toolbar
android:id="@+id/plan_route_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:contentInsetLeft="54dp"
app:contentInsetStart="54dp">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:gravity="center_vertical"
<LinearLayout android:orientation="horizontal">
android:id="@+id/up_down_row"
android:layout_width="0dp"
android:layout_height="@dimen/measurement_tool_controls_height"
android:layout_weight="0.5"
android:background="?attr/selectableItemBackground">
<ImageView
android:id="@+id/up_down_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/bottom_sheet_content_margin"
android:layout_marginLeft="@dimen/bottom_sheet_content_margin"
android:layout_marginRight="@dimen/bottom_sheet_content_margin"
android:layout_marginStart="@dimen/bottom_sheet_content_margin"
android:background="@null"
tools:src="@drawable/ic_action_arrow_down"/>
<LinearLayout <LinearLayout
android:layout_width="0dp" android:layout_width="0dp"
@ -101,86 +86,49 @@
</LinearLayout> </LinearLayout>
<net.osmand.plus.widgets.TextViewEx <net.osmand.plus.widgets.TextViewEx
android:id="@+id/select_all_button" android:id="@+id/options_button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:ellipsize="end" android:ellipsize="end"
android:gravity="center_vertical" android:gravity="center_vertical"
android:maxLines="1" android:maxLines="1"
android:paddingEnd="@dimen/measurement_tool_text_button_padding_small" android:paddingLeft="16dp"
android:paddingLeft="@dimen/measurement_tool_text_button_padding" android:paddingRight="16dp"
android:paddingRight="@dimen/measurement_tool_text_button_padding_small" android:text="@string/shared_string_options"
android:paddingStart="@dimen/measurement_tool_text_button_padding" android:textAllCaps="true"
android:text="@string/shared_string_select_all" android:textColor="@color/color_white"
android:textColor="?attr/color_dialog_buttons" android:textSize="@dimen/default_list_text_size"
osmand:textAllCapsCompat="true" osmand:typeface="@string/font_roboto_regular"/>
osmand:typeface="@string/font_roboto_medium"/>
</LinearLayout> </LinearLayout>
<View </android.support.v7.widget.Toolbar>
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="?attr/dashboard_divider"/>
<LinearLayout </android.support.design.widget.AppBarLayout>
android:id="@+id/buttons_row"
android:layout_width="0dp"
android:layout_height="@dimen/measurement_tool_controls_height"
android:layout_weight="0.5">
<LinearLayout <ProgressBar
android:id="@+id/sort_button" android:id="@+id/snap_to_road_progress_bar"
android:layout_width="wrap_content" style="?android:attr/progressBarStyleHorizontal"
android:layout_height="match_parent" android:layout_width="match_parent"
android:background="?attr/selectableItemBackground"
android:paddingLeft="@dimen/bottom_sheet_content_margin"
android:paddingRight="@dimen/bottom_sheet_content_margin">
<ImageView
android:id="@+id/sort_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:minHeight="0dp"
android:background="@null" android:visibility="gone"
tools:src="@drawable/ic_action_list_sort"/> tools:visibility="visible"/>
<net.osmand.plus.widgets.TextViewEx <FrameLayout
android:layout_width="wrap_content" android:id="@+id/markers_list_container"
android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginLeft="@dimen/measurement_tool_button_margin" android:background="@color/ctx_menu_info_view_bg_dark">
android:layout_marginStart="@dimen/measurement_tool_button_margin"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:text="@string/shared_string_sort"
android:textColor="?attr/color_dialog_buttons"
osmand:textAllCapsCompat="true"
osmand:typeface="@string/font_roboto_medium"/>
</LinearLayout>
<Space <android.support.v7.widget.RecyclerView
android:layout_width="0dp" android:id="@+id/markers_recycler_view"
android:layout_height="match_parent" android:layout_width="match_parent"
android:layout_weight="1"/> android:layout_height="match_parent"/>
<Button
android:id="@+id/save_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|center_vertical"
android:layout_marginEnd="@dimen/measurement_tool_button_margin"
android:layout_marginRight="@dimen/measurement_tool_button_margin"
android:background="@drawable/btn_round_blue"
android:ellipsize="end"
android:maxLines="1"
android:minHeight="@dimen/measurement_tool_button_height"
android:text="@string/shared_string_save"
android:textColor="@color/color_white"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<include layout="@layout/card_bottom_divider"/>
</FrameLayout> </FrameLayout>
</LinearLayout>
</LinearLayout>

View file

@ -25,6 +25,7 @@ import net.osmand.plus.OsmandSettings.MapMarkersOrderByMode;
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.activities.TrackActivity; import net.osmand.plus.activities.TrackActivity;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.mapmarkers.OptionsBottomSheetDialogFragment.MarkerOptionsFragmentListener; import net.osmand.plus.mapmarkers.OptionsBottomSheetDialogFragment.MarkerOptionsFragmentListener;
import net.osmand.plus.mapmarkers.OrderByBottomSheetDialogFragment.OrderByFragmentListener; import net.osmand.plus.mapmarkers.OrderByBottomSheetDialogFragment.OrderByFragmentListener;
import net.osmand.plus.mapmarkers.SaveAsTrackBottomSheetDialogFragment.MarkerSaveAsTrackFragmentListener; import net.osmand.plus.mapmarkers.SaveAsTrackBottomSheetDialogFragment.MarkerSaveAsTrackFragmentListener;
@ -209,7 +210,7 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
@Override @Override
public void buildRouteOnClick() { public void buildRouteOnClick() {
PlanRouteFragment.showInstance(mapActivity.getSupportFragmentManager()); PlanRouteFragment.showInstance(mapActivity.getSupportFragmentManager(), AndroidUiHelper.isOrientationPortrait(mapActivity));
dismiss(); dismiss();
} }

View file

@ -12,6 +12,7 @@ import android.support.v4.app.FragmentManager;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.support.v7.widget.helper.ItemTouchHelper; import android.support.v7.widget.helper.ItemTouchHelper;
import android.util.Pair; import android.util.Pair;
import android.view.ContextThemeWrapper; import android.view.ContextThemeWrapper;
@ -45,7 +46,6 @@ import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.mapmarkers.PlanRouteOptionsBottomSheetDialogFragment.PlanRouteOptionsFragmentListener; import net.osmand.plus.mapmarkers.PlanRouteOptionsBottomSheetDialogFragment.PlanRouteOptionsFragmentListener;
import net.osmand.plus.mapmarkers.adapters.MapMarkersItemTouchHelperCallback; import net.osmand.plus.mapmarkers.adapters.MapMarkersItemTouchHelperCallback;
import net.osmand.plus.mapmarkers.adapters.MapMarkersListAdapter; import net.osmand.plus.mapmarkers.adapters.MapMarkersListAdapter;
import net.osmand.plus.measurementtool.RecyclerViewFragment;
import net.osmand.plus.measurementtool.SnapToRoadBottomSheetDialogFragment; import net.osmand.plus.measurementtool.SnapToRoadBottomSheetDialogFragment;
import net.osmand.plus.measurementtool.SnapToRoadBottomSheetDialogFragment.SnapToRoadFragmentListener; import net.osmand.plus.measurementtool.SnapToRoadBottomSheetDialogFragment.SnapToRoadFragmentListener;
import net.osmand.plus.routing.RouteCalculationParams; import net.osmand.plus.routing.RouteCalculationParams;
@ -65,8 +65,6 @@ import java.util.Map;
import java.util.Queue; import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentLinkedQueue;
import static net.osmand.plus.OsmandSettings.LANDSCAPE_MIDDLE_RIGHT_CONSTANT;
public class PlanRouteFragment extends Fragment { public class PlanRouteFragment extends Fragment {
public static final String TAG = "PlanRouteFragment"; public static final String TAG = "PlanRouteFragment";
@ -89,7 +87,6 @@ public class PlanRouteFragment extends Fragment {
private View mainView; private View mainView;
private RecyclerView markersRv; private RecyclerView markersRv;
private ImageView upDownIconIv;
private TextView distanceTv; private TextView distanceTv;
private TextView timeTv; private TextView timeTv;
private TextView countTv; private TextView countTv;
@ -118,11 +115,6 @@ public class PlanRouteFragment extends Fragment {
if (sortByFragment != null) { if (sortByFragment != null) {
((PlanRouteOptionsBottomSheetDialogFragment) sortByFragment).setListener(createOptionsFragmentListener()); ((PlanRouteOptionsBottomSheetDialogFragment) sortByFragment).setListener(createOptionsFragmentListener());
} }
// If rotate the screen from landscape to portrait when the list of markers is displayed then
// the RecyclerViewFragment will exist without view. This is necessary to remove it.
if (!portrait) {
hideMarkersListFragment();
}
toolbarHeight = mapActivity.getResources().getDimensionPixelSize(R.dimen.dashboard_map_toolbar); toolbarHeight = mapActivity.getResources().getDimensionPixelSize(R.dimen.dashboard_map_toolbar);
@ -136,7 +128,9 @@ public class PlanRouteFragment extends Fragment {
View view = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_plan_route, null); View view = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_plan_route, null);
mainView = view.findViewById(R.id.main_view); mainView = view.findViewById(R.id.main_view);
if (portrait) {
AndroidUtils.setBackground(mapActivity, mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark); AndroidUtils.setBackground(mapActivity, mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
}
distanceTv = (TextView) mainView.findViewById(R.id.markers_distance_text_view); distanceTv = (TextView) mainView.findViewById(R.id.markers_distance_text_view);
timeTv = (TextView) mainView.findViewById(R.id.markers_time_text_view); timeTv = (TextView) mainView.findViewById(R.id.markers_time_text_view);
@ -145,12 +139,12 @@ public class PlanRouteFragment extends Fragment {
enterPlanRouteMode(); enterPlanRouteMode();
View markersListContainer = mainView.findViewById(R.id.markers_list_container); View markersListContainer = mainView.findViewById(R.id.markers_list_container);
if (portrait && markersListContainer != null) { if (markersListContainer != null) {
markersListContainer.setBackgroundColor(backgroundColor); markersListContainer.setBackgroundColor(backgroundColor);
} }
upDownIconIv = (ImageView) mainView.findViewById(R.id.up_down_icon); if (portrait) {
upDownIconIv.setImageDrawable(getContentIcon(R.drawable.ic_action_arrow_up)); ((ImageView) mainView.findViewById(R.id.up_down_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_arrow_up));
mainView.findViewById(R.id.up_down_row).setOnClickListener(new View.OnClickListener() { mainView.findViewById(R.id.up_down_row).setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -199,18 +193,59 @@ public class PlanRouteFragment extends Fragment {
toolbarController.setOnSaveViewClickListener(new View.OnClickListener() { toolbarController.setOnSaveViewClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
PlanRouteOptionsBottomSheetDialogFragment fragment = new PlanRouteOptionsBottomSheetDialogFragment(); optionsOnClick();
fragment.setListener(createOptionsFragmentListener());
fragment.show(mapActivity.getSupportFragmentManager(), PlanRouteOptionsBottomSheetDialogFragment.TAG);
} }
}); });
mapActivity.showTopToolbar(toolbarController); mapActivity.showTopToolbar(toolbarController);
if (portrait) { final int screenH = AndroidUtils.getScreenHeight(mapActivity);
markersRv = mainView.findViewById(R.id.markers_recycler_view); final int statusBarH = AndroidUtils.getStatusBarHeight(mapActivity);
final int navBarH = AndroidUtils.getNavBarHeight(mapActivity);
final int availableHeight = (screenH - statusBarH - navBarH) / 2;
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
int upDownRowH = mainView.findViewById(R.id.up_down_row).getHeight();
int listContainerH = availableHeight - upDownRowH;
View listContainer = mainView.findViewById(R.id.markers_list_container);
listContainer.getLayoutParams().height = listContainerH;
listContainer.requestLayout();
showMarkersList();
ViewTreeObserver obs = mainView.getViewTreeObserver();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
obs.removeOnGlobalLayoutListener(this);
} else { } else {
markersRv = new RecyclerView(mapActivity); obs.removeGlobalOnLayoutListener(this);
} }
}
});
} else {
Toolbar toolbar = (Toolbar) mainView.findViewById(R.id.plan_route_toolbar);
if (nightMode) {
toolbar.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.actionbar_dark_color));
}
toolbar.setNavigationIcon(iconsCache.getIcon(R.drawable.ic_arrow_back));
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (quit(false)) {
MapMarkersDialogFragment.showInstance(mapActivity);
}
}
});
mainView.findViewById(R.id.options_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
optionsOnClick();
}
});
}
markersRv = mainView.findViewById(R.id.markers_recycler_view);
adapter = new MapMarkersListAdapter(mapActivity); adapter = new MapMarkersListAdapter(mapActivity);
adapter.setHasStableIds(true); adapter.setHasStableIds(true);
@ -272,39 +307,6 @@ public class PlanRouteFragment extends Fragment {
markersRv.setClipToPadding(false); markersRv.setClipToPadding(false);
markersRv.setLayoutManager(new LinearLayoutManager(getContext())); markersRv.setLayoutManager(new LinearLayoutManager(getContext()));
markersRv.setAdapter(adapter); markersRv.setAdapter(adapter);
markersRv.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
}
});
final int screenH = AndroidUtils.getScreenHeight(mapActivity);
final int statusBarH = AndroidUtils.getStatusBarHeight(mapActivity);
final int navBarH = AndroidUtils.getNavBarHeight(mapActivity);
final int availableHeight = (screenH - statusBarH - navBarH) / 2;
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
if (portrait) {
int upDownRowH = mainView.findViewById(R.id.up_down_row).getHeight();
int listContainerH = availableHeight - upDownRowH;
View listContainer = mainView.findViewById(R.id.markers_list_container);
listContainer.getLayoutParams().height = listContainerH;
listContainer.requestLayout();
}
showMarkersList();
ViewTreeObserver obs = mainView.getViewTreeObserver();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
obs.removeOnGlobalLayoutListener(this);
} else {
obs.removeGlobalOnLayoutListener(this);
}
}
});
if (progressBarVisible) { if (progressBarVisible) {
showProgressBar(); showProgressBar();
@ -313,6 +315,15 @@ public class PlanRouteFragment extends Fragment {
return view; return view;
} }
private void optionsOnClick() {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
PlanRouteOptionsBottomSheetDialogFragment fragment = new PlanRouteOptionsBottomSheetDialogFragment();
fragment.setListener(createOptionsFragmentListener());
fragment.show(mapActivity.getSupportFragmentManager(), PlanRouteOptionsBottomSheetDialogFragment.TAG);
}
}
@Override @Override
public void onDestroyView() { public void onDestroyView() {
super.onDestroyView(); super.onDestroyView();
@ -523,12 +534,14 @@ public class PlanRouteFragment extends Fragment {
} }
private void updateSelectButton() { private void updateSelectButton() {
if (portrait) {
if (selectedCount == markersHelper.getMapMarkers().size() && markersHelper.isStartFromMyLocation()) { if (selectedCount == markersHelper.getMapMarkers().size() && markersHelper.isStartFromMyLocation()) {
((TextView) mainView.findViewById(R.id.select_all_button)).setText(getString(R.string.shared_string_deselect_all)); ((TextView) mainView.findViewById(R.id.select_all_button)).setText(getString(R.string.shared_string_deselect_all));
} else { } else {
((TextView) mainView.findViewById(R.id.select_all_button)).setText(getString(R.string.shared_string_select_all)); ((TextView) mainView.findViewById(R.id.select_all_button)).setText(getString(R.string.shared_string_select_all));
} }
} }
}
private void mark(int status, int... widgets) { private void mark(int status, int... widgets) {
MapActivity mapActivity = getMapActivity(); MapActivity mapActivity = getMapActivity();
@ -542,70 +555,29 @@ public class PlanRouteFragment extends Fragment {
} }
} }
//todo create one method
private void showMarkersList() { private void showMarkersList() {
MapActivity mapActivity = getMapActivity(); MapActivity mapActivity = getMapActivity();
MapMarkersLayer markersLayer = getMapMarkersLayer(); MapMarkersLayer markersLayer = getMapMarkersLayer();
if (mapActivity != null && markersLayer != null) { if (mapActivity != null && markersLayer != null && portrait) {
markersListOpened = true; markersListOpened = true;
upDownIconIv.setImageDrawable(getContentIcon(R.drawable.ic_action_arrow_down)); ((ImageView) mainView.findViewById(R.id.up_down_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_arrow_down));
View listContainer = mainView.findViewById(R.id.markers_list_container); View listContainer = mainView.findViewById(R.id.markers_list_container);
if (portrait && listContainer != null) { if (listContainer != null) {
listContainer.setVisibility(View.VISIBLE); listContainer.setVisibility(View.VISIBLE);
} else {
showMarkersListFragment();
} }
OsmandMapTileView tileView = mapActivity.getMapView();
previousMapPosition = tileView.getMapPosition();
if (!portrait) {
tileView.setMapPosition(LANDSCAPE_MIDDLE_RIGHT_CONSTANT);
}
mapActivity.refreshMap();
} }
} }
private void hideMarkersList() { private void hideMarkersList() {
MapActivity mapActivity = getMapActivity(); MapActivity mapActivity = getMapActivity();
MapMarkersLayer markersLayer = getMapMarkersLayer(); MapMarkersLayer markersLayer = getMapMarkersLayer();
if (mapActivity != null && markersLayer != null) { if (mapActivity != null && markersLayer != null && portrait) {
markersListOpened = false; markersListOpened = false;
upDownIconIv.setImageDrawable(getContentIcon(R.drawable.ic_action_arrow_up)); ((ImageView) mainView.findViewById(R.id.up_down_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_arrow_up));
View listContainer = mainView.findViewById(R.id.markers_list_container); View listContainer = mainView.findViewById(R.id.markers_list_container);
if (portrait && listContainer != null) { if (listContainer != null) {
listContainer.setVisibility(View.GONE); listContainer.setVisibility(View.GONE);
} else {
hideMarkersListFragment();
}
mapActivity.getMapView().setMapPosition(previousMapPosition);
mapActivity.refreshMap();
}
}
private void showMarkersListFragment() {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
View upDownRow = mainView.findViewById(R.id.up_down_row);
int screenHeight = AndroidUtils.getScreenHeight(mapActivity) - AndroidUtils.getStatusBarHeight(mapActivity);
RecyclerViewFragment fragment = new RecyclerViewFragment();
fragment.setRecyclerView(markersRv);
fragment.setWidth(upDownRow.getWidth());
fragment.setHeight(screenHeight - upDownRow.getHeight());
mapActivity.getSupportFragmentManager().beginTransaction()
.add(R.id.fragmentContainer, fragment, RecyclerViewFragment.TAG)
.commitAllowingStateLoss();
}
}
private void hideMarkersListFragment() {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
try {
FragmentManager manager = mapActivity.getSupportFragmentManager();
Fragment fragment = manager.findFragmentByTag(RecyclerViewFragment.TAG);
if (fragment != null) {
manager.beginTransaction().remove(fragment).commitNowAllowingStateLoss();
}
} catch (Exception e) {
// ignore
} }
} }
} }
@ -654,7 +626,7 @@ public class PlanRouteFragment extends Fragment {
if (portrait) { if (portrait) {
tileBoxHeightPx = 3 * (tb.getPixHeight() - mainView.getHeight() - toolbarHeight) / 4; tileBoxHeightPx = 3 * (tb.getPixHeight() - mainView.getHeight() - toolbarHeight) / 4;
} else { } else {
tileBoxWidthPx = tb.getPixWidth() - mainView.findViewById(R.id.up_down_row).getWidth(); tileBoxWidthPx = tb.getPixWidth() - mapActivity.getResources().getDimensionPixelSize(R.dimen.dashboard_land_width);
} }
mapView.fitRectToMap(left, right, top, bottom, tileBoxWidthPx, tileBoxHeightPx, toolbarHeight * 3 / 2); mapView.fitRectToMap(left, right, top, bottom, tileBoxWidthPx, tileBoxHeightPx, toolbarHeight * 3 / 2);
} }
@ -677,12 +649,12 @@ public class PlanRouteFragment extends Fragment {
activity.getSupportFragmentManager().beginTransaction().remove(this).commitAllowingStateLoss(); activity.getSupportFragmentManager().beginTransaction().remove(this).commitAllowingStateLoss();
} }
public static boolean showInstance(FragmentManager fragmentManager) { public static boolean showInstance(FragmentManager fragmentManager, boolean portrait) {
try { try {
PlanRouteFragment fragment = new PlanRouteFragment(); PlanRouteFragment fragment = new PlanRouteFragment();
fragment.setRetainInstance(true); fragment.setRetainInstance(true);
fragmentManager.beginTransaction() fragmentManager.beginTransaction()
.add(R.id.bottomFragmentContainer, fragment, PlanRouteFragment.TAG) .add(portrait ? R.id.bottomFragmentContainer : R.id.topFragmentContainer, fragment, PlanRouteFragment.TAG)
.commitAllowingStateLoss(); .commitAllowingStateLoss();
return true; return true;
} catch (Exception e) { } catch (Exception e) {