Add landscape layout
This commit is contained in:
parent
e3e28211b8
commit
3fb23779c4
3 changed files with 360 additions and 6 deletions
248
OsmAnd/res/layout-land/fragment_measurement_tool.xml
Normal file
248
OsmAnd/res/layout-land/fragment_measurement_tool.xml
Normal file
|
@ -0,0 +1,248 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/color_transparent"
|
||||
android:clickable="true">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/main_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:clickable="true"
|
||||
tools:background="@drawable/bg_bottom_menu_dark">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/up_down_row"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.4"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingBottom="14dp"
|
||||
android:paddingTop="14dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ruler_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:background="@null"
|
||||
tools:src="@drawable/ic_action_ruler"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/move_point_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:background="@null"
|
||||
android:visibility="gone"
|
||||
tools:src="@drawable/ic_action_measure_point"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/up_down_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:background="@null"
|
||||
tools:src="@drawable/ic_action_arrow_down"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/measurement_distance_text_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="4dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_toEndOf="@id/ruler_icon"
|
||||
android:layout_toRightOf="@id/ruler_icon"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||
tools:text="724 m,"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/measurement_points_text_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toEndOf="@id/measurement_distance_text_view"
|
||||
android:layout_toLeftOf="@id/up_down_button"
|
||||
android:layout_toRightOf="@id/measurement_distance_text_view"
|
||||
android:layout_toStartOf="@id/up_down_button"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
tools:text="points: 3"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/move_point_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="4dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_toEndOf="@id/move_point_icon"
|
||||
android:layout_toRightOf="@id/move_point_icon"
|
||||
android:text="@string/move_point"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||
android:visibility="gone"/>
|
||||
</RelativeLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/measure_mode_controls"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="52dp"
|
||||
android:layout_weight="0.6">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/options_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="1"
|
||||
android:paddingEnd="12dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="12dp"
|
||||
android:paddingStart="16dp"
|
||||
android:text="@string/shared_string_options"
|
||||
android:textColor="?attr/color_dialog_buttons"
|
||||
osmand:textAllCapsCompat="true"
|
||||
osmand:typeface="@string/font_roboto_medium"/>
|
||||
</FrameLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/redo_undo_container"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_horizontal">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/undo_point_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingBottom="14dp"
|
||||
android:paddingEnd="12dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="12dp"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingTop="14dp"
|
||||
tools:src="@drawable/ic_action_undo_dark"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/redo_point_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingBottom="14dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:paddingLeft="12dp"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingTop="14dp"
|
||||
tools:src="@drawable/ic_action_redo_dark"/>
|
||||
</LinearLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1">
|
||||
|
||||
<Button
|
||||
android:id="@+id/add_point_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:background="@drawable/btn_round_blue"
|
||||
android:drawableLeft="@drawable/ic_action_plus"
|
||||
android:maxLines="1"
|
||||
android:minHeight="36dp"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:text="@string/shared_string_add"
|
||||
android:textColor="@color/color_white"/>
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/move_point_mode_controls"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="52dp"
|
||||
android:layout_weight="0.6"
|
||||
android:visibility="gone">
|
||||
|
||||
<Button
|
||||
android:id="@+id/apply_point_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:background="@drawable/btn_round_blue"
|
||||
android:minHeight="36dp"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:text="@string/shared_string_apply"
|
||||
android:textColor="@color/color_white"/>
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/cancel_point_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingEnd="12dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="12dp"
|
||||
android:paddingStart="16dp"
|
||||
android:text="@string/shared_string_cancel"
|
||||
android:textColor="?attr/color_dialog_buttons"
|
||||
osmand:textAllCapsCompat="true"
|
||||
osmand:typeface="@string/font_roboto_medium"/>
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
|
@ -70,6 +70,7 @@ public class MeasurementToolFragment extends Fragment {
|
|||
public static final String TAG = "MeasurementToolFragment";
|
||||
|
||||
private final CommandManager commandManager = new CommandManager();
|
||||
private RecyclerView rv;
|
||||
private MeasurementToolBarController toolBarController;
|
||||
private MeasurementToolAdapter adapter;
|
||||
private TextView distanceTv;
|
||||
|
@ -78,6 +79,7 @@ public class MeasurementToolFragment extends Fragment {
|
|||
private Drawable upIcon;
|
||||
private Drawable downIcon;
|
||||
private View pointsListContainer;
|
||||
private View upDownRow;
|
||||
private ImageView upDownBtn;
|
||||
private ImageView undoBtn;
|
||||
private ImageView redoBtn;
|
||||
|
@ -85,6 +87,7 @@ public class MeasurementToolFragment extends Fragment {
|
|||
private boolean wasCollapseButtonVisible;
|
||||
private boolean pointsListOpened;
|
||||
private boolean saved;
|
||||
private boolean portrait;
|
||||
private int previousMapPosition;
|
||||
private NewGpxLine newGpxLine;
|
||||
|
||||
|
@ -104,6 +107,7 @@ 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);
|
||||
portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
|
||||
|
||||
upIcon = iconsCache.getThemedIcon(R.drawable.ic_action_arrow_up);
|
||||
downIcon = iconsCache.getThemedIcon(R.drawable.ic_action_arrow_down);
|
||||
|
@ -114,7 +118,9 @@ public class MeasurementToolFragment extends Fragment {
|
|||
final View mainView = view.findViewById(R.id.main_view);
|
||||
AndroidUtils.setBackground(mapActivity, mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
|
||||
pointsListContainer = view.findViewById(R.id.points_list_container);
|
||||
pointsListContainer.setBackgroundColor(backgroundColor);
|
||||
if (portrait && pointsListContainer != null) {
|
||||
pointsListContainer.setBackgroundColor(backgroundColor);
|
||||
}
|
||||
|
||||
distanceTv = (TextView) mainView.findViewById(R.id.measurement_distance_text_view);
|
||||
pointsTv = (TextView) mainView.findViewById(R.id.measurement_points_text_view);
|
||||
|
@ -135,7 +141,8 @@ public class MeasurementToolFragment extends Fragment {
|
|||
}
|
||||
});
|
||||
|
||||
mainView.findViewById(R.id.up_down_row).setOnClickListener(new View.OnClickListener() {
|
||||
upDownRow = mainView.findViewById(R.id.up_down_row);
|
||||
upDownRow.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (!pointsListOpened && measurementLayer.getPointsCount() > 0 && !measurementLayer.isInMovePointMode()) {
|
||||
|
@ -303,7 +310,11 @@ public class MeasurementToolFragment extends Fragment {
|
|||
mapActivity.showTopToolbar(toolBarController);
|
||||
|
||||
adapter = new MeasurementToolAdapter(getMapActivity(), measurementLayer.getMeasurementPoints());
|
||||
final RecyclerView rv = mainView.findViewById(R.id.measure_points_recycler_view);
|
||||
if (portrait) {
|
||||
rv = mainView.findViewById(R.id.measure_points_recycler_view);
|
||||
} else {
|
||||
rv = new RecyclerView(getActivity());
|
||||
}
|
||||
final ItemTouchHelper touchHelper = new ItemTouchHelper(new MeasurementToolItemTouchHelperCallback(adapter));
|
||||
touchHelper.attachToRecyclerView(rv);
|
||||
adapter.setAdapterListener(new MeasurementToolAdapter.MeasurementAdapterListener() {
|
||||
|
@ -450,10 +461,14 @@ public class MeasurementToolFragment extends Fragment {
|
|||
|
||||
private void showPointsList() {
|
||||
pointsListOpened = true;
|
||||
pointsListContainer.setVisibility(View.VISIBLE);
|
||||
upDownBtn.setImageDrawable(downIcon);
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
if (portrait && pointsListContainer != null) {
|
||||
pointsListContainer.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
showPointsListFragment();
|
||||
}
|
||||
OsmandMapTileView tileView = mapActivity.getMapView();
|
||||
previousMapPosition = tileView.getMapPosition();
|
||||
tileView.setMapPosition(MIDDLE_TOP_CONSTANT);
|
||||
|
@ -463,11 +478,42 @@ public class MeasurementToolFragment extends Fragment {
|
|||
|
||||
private void hidePointsList() {
|
||||
pointsListOpened = false;
|
||||
pointsListContainer.setVisibility(View.GONE);
|
||||
upDownBtn.setImageDrawable(upIcon);
|
||||
if (portrait && pointsListContainer != null) {
|
||||
pointsListContainer.setVisibility(View.GONE);
|
||||
} else {
|
||||
hidePointsListFragment();
|
||||
}
|
||||
setPreviousMapPosition();
|
||||
}
|
||||
|
||||
private void showPointsListFragment() {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
PointsListFragment fragment = new PointsListFragment();
|
||||
int screenHeight = AndroidUtils.getScreenHeight(mapActivity) - AndroidUtils.getStatusBarHeight(mapActivity);
|
||||
fragment.setRv(rv);
|
||||
fragment.setWidth(upDownRow.getWidth());
|
||||
fragment.setHeight(screenHeight - upDownRow.getHeight());
|
||||
mapActivity.getSupportFragmentManager().beginTransaction()
|
||||
.add(R.id.fragmentContainer, fragment, PointsListFragment.TAG)
|
||||
.addToBackStack(PointsListFragment.TAG)
|
||||
.commitAllowingStateLoss();
|
||||
}
|
||||
}
|
||||
|
||||
private void hidePointsListFragment() {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
try {
|
||||
mapActivity.getSupportFragmentManager()
|
||||
.popBackStackImmediate(PointsListFragment.TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setPreviousMapPosition() {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
|
@ -698,7 +744,6 @@ public class MeasurementToolFragment extends Fragment {
|
|||
measurementLayer.setInMeasurementMode(true);
|
||||
mapActivity.refreshMap();
|
||||
mapActivity.disableDrawer();
|
||||
boolean portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
|
||||
|
||||
mark(portrait ? View.INVISIBLE : View.GONE,
|
||||
R.id.map_left_widgets_panel,
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
package net.osmand.plus.measurementtool;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
||||
public class PointsListFragment extends Fragment {
|
||||
|
||||
public static final String TAG = "pointsListFragment";
|
||||
|
||||
private RecyclerView rv;
|
||||
private int height;
|
||||
private int width;
|
||||
private LinearLayout ll;
|
||||
|
||||
public void setRv(RecyclerView rv) {
|
||||
this.rv = rv;
|
||||
}
|
||||
|
||||
public void setHeight(int height) {
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public void setWidth(int width) {
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
final MapActivity mapActivity = (MapActivity) getActivity();
|
||||
final boolean nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
||||
final int backgroundColor = ContextCompat.getColor(getActivity(),
|
||||
nightMode ? R.color.ctx_menu_info_view_bg_dark : R.color.ctx_menu_info_view_bg_light);
|
||||
|
||||
ll = new LinearLayout(mapActivity);
|
||||
ll.setLayoutParams(new LinearLayout.LayoutParams(width, height));
|
||||
ll.setOrientation(LinearLayout.VERTICAL);
|
||||
ll.setBackgroundColor(backgroundColor);
|
||||
ll.addView(rv);
|
||||
|
||||
return ll;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
if (ll != null) {
|
||||
ll.removeAllViews();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue