Add support for landscape

This commit is contained in:
Alexander Sytnyk 2017-08-14 12:12:53 +03:00
parent 294215d590
commit d51254949b
3 changed files with 38 additions and 28 deletions

View file

@ -268,4 +268,9 @@
android:layout_gravity="bottom|left"
tools:visibility="visible"/>
<FrameLayout
android:id="@+id/bottomFragmentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>

View file

@ -104,7 +104,6 @@ public class MeasurementToolFragment extends Fragment {
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
final int backgroundColor = ContextCompat.getColor(getActivity(),
nightMode ? R.color.ctx_menu_info_view_bg_dark : R.color.ctx_menu_info_view_bg_light);
boolean portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
upIcon = iconsCache.getThemedIcon(R.drawable.ic_action_arrow_up);
downIcon = iconsCache.getThemedIcon(R.drawable.ic_action_arrow_down);
@ -279,31 +278,29 @@ public class MeasurementToolFragment extends Fragment {
enterMeasurementMode();
if (portrait) {
toolBarController = new MeasurementToolBarController(newGpxLine);
if (newGpxLine != null) {
toolBarController.setTitle(getString(R.string.add_line));
} else {
toolBarController.setTitle(getString(R.string.measurement_tool_action_bar));
}
toolBarController.setOnBackButtonClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showQuitDialog(false);
}
});
toolBarController.setOnSaveViewClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (measurementLayer.getPointsCount() > 0) {
saveAsNewSegment(mapActivity);
} else {
Toast.makeText(mapActivity, getString(R.string.none_point_error), Toast.LENGTH_SHORT).show();
}
}
});
mapActivity.showTopToolbar(toolBarController);
toolBarController = new MeasurementToolBarController(newGpxLine);
if (newGpxLine != null) {
toolBarController.setTitle(getString(R.string.add_line));
} else {
toolBarController.setTitle(getString(R.string.measurement_tool_action_bar));
}
toolBarController.setOnBackButtonClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showQuitDialog(false);
}
});
toolBarController.setOnSaveViewClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (measurementLayer.getPointsCount() > 0) {
saveAsNewSegment(mapActivity);
} else {
Toast.makeText(mapActivity, getString(R.string.none_point_error), Toast.LENGTH_SHORT).show();
}
}
});
mapActivity.showTopToolbar(toolBarController);
adapter = new MeasurementToolAdapter(getMapActivity(), measurementLayer.getMeasurementPoints());
final RecyclerView rv = mainView.findViewById(R.id.measure_points_recycler_view);
@ -701,8 +698,9 @@ public class MeasurementToolFragment extends Fragment {
measurementLayer.setInMeasurementMode(true);
mapActivity.refreshMap();
mapActivity.disableDrawer();
boolean portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
mark(View.INVISIBLE,
mark(portrait ? View.INVISIBLE : View.GONE,
R.id.map_left_widgets_panel,
R.id.map_right_widgets_panel,
R.id.map_center_info);
@ -837,7 +835,10 @@ public class MeasurementToolFragment extends Fragment {
@Override
public void updateToolbar(MapInfoWidgetsFactory.TopToolbarView view) {
super.updateToolbar(view);
view.getShadowView().setVisibility(View.GONE);
View shadow = view.getShadowView();
if (shadow != null) {
shadow.setVisibility(View.GONE);
}
}
}
}

View file

@ -13,6 +13,7 @@ import android.widget.ImageView;
import net.osmand.AndroidUtils;
import net.osmand.plus.R;
import net.osmand.plus.base.BottomSheetDialogFragment;
import net.osmand.plus.helpers.AndroidUiHelper;
public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment {
@ -34,9 +35,12 @@ public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final boolean nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls();
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
boolean portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_options_bottom_sheet_dialog, null);
AndroidUtils.setBackground(getActivity(), mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
if (portrait) {
AndroidUtils.setBackground(getActivity(), mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
}
((ImageView) mainView.findViewById(R.id.snap_to_road_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_snap_to_road));
((ImageView) mainView.findViewById(R.id.clear_all_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_reset_to_default_dark));