Merge pull request #10249 from osmandapp/Plan-route-fix-

Plan Route Fix UI margins
This commit is contained in:
Vitaliy 2020-11-22 21:17:13 +00:00 committed by GitHub
commit a73e647d2f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 102 additions and 52 deletions

View file

@ -25,27 +25,18 @@
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:gravity="center" android:gravity="center"
android:textSize="@dimen/default_desc_text_size" android:textSize="@dimen/default_desc_text_size"
android:textColor="@drawable/radio_flat_text_selector_light"
osmand:typeface="@string/font_roboto_medium" osmand:typeface="@string/font_roboto_medium"
tools:text="@string/shared_string_left"/> tools:text="@string/shared_string_left"/>
</FrameLayout> </FrameLayout>
<FrameLayout <FrameLayout
android:id="@+id/center_button_container" android:id="@+id/buttons_divider"
android:layout_width="0dp" android:layout_width="1dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="0"
android:visibility="gone"> android:background="?attr/divider_color">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/center_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackground"
android:gravity="center"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="@string/position_on_map_center"/>
</FrameLayout> </FrameLayout>
@ -61,8 +52,9 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:gravity="center" android:gravity="center"
android:textSize="@dimen/default_desc_text_size" android:textColor="@drawable/radio_flat_text_selector_light"
osmand:typeface="@string/font_roboto_medium" osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"
tools:text="@string/shared_string_right"/> tools:text="@string/shared_string_right"/>
</FrameLayout> </FrameLayout>

View file

@ -30,20 +30,21 @@
<RelativeLayout <RelativeLayout
android:id="@+id/up_down_row" android:id="@+id/up_down_row"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/measurement_tool_up_down_row_height" android:layout_height="wrap_content"
android:minHeight="112dp"
android:background="?attr/selectableItemBackground"> android:background="?attr/selectableItemBackground">
<androidx.appcompat.widget.AppCompatImageView <androidx.appcompat.widget.AppCompatImageView
android:id="@+id/main_icon" android:id="@+id/main_icon"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" android:layout_alignParentStart="true"
android:layout_centerVertical="true" android:layout_alignParentLeft="true"
android:layout_marginEnd="@dimen/measurement_tool_text_button_padding"
android:layout_marginLeft="@dimen/measurement_tool_text_button_padding"
android:layout_marginRight="@dimen/measurement_tool_text_button_padding"
android:layout_marginStart="@dimen/measurement_tool_text_button_padding" android:layout_marginStart="@dimen/measurement_tool_text_button_padding"
android:layout_marginLeft="@dimen/measurement_tool_text_button_padding"
android:layout_marginTop="@dimen/bottom_sheet_icon_margin"
android:layout_marginEnd="@dimen/measurement_tool_text_button_padding"
android:layout_marginRight="@dimen/measurement_tool_text_button_padding"
android:background="@null" android:background="@null"
tools:src="@drawable/ic_action_ruler" /> tools:src="@drawable/ic_action_ruler" />
@ -53,7 +54,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_centerVertical="true" android:layout_marginTop="@dimen/bottom_sheet_icon_margin"
android:layout_marginEnd="@dimen/bottom_sheet_content_margin" android:layout_marginEnd="@dimen/bottom_sheet_content_margin"
android:layout_marginLeft="@dimen/bottom_sheet_content_margin" android:layout_marginLeft="@dimen/bottom_sheet_content_margin"
android:layout_marginRight="@dimen/bottom_sheet_content_margin" android:layout_marginRight="@dimen/bottom_sheet_content_margin"
@ -128,6 +129,17 @@
android:textAppearance="@style/TextAppearance.ListItemTitle" android:textAppearance="@style/TextAppearance.ListItemTitle"
android:visibility="gone" android:visibility="gone"
tools:text="@string/add_point_after"/> tools:text="@string/add_point_after"/>
<include
android:layout_width="match_parent"
android:layout_height="@dimen/measurement_tool_button_height"
android:layout_below="@id/distance_to_center_text_view"
android:layout_marginTop="@dimen/content_padding_half"
android:layout_marginBottom="@dimen/measurement_tool_content_padding_medium"
android:layout_marginStart="@dimen/content_padding"
android:layout_marginEnd="@dimen/content_padding"
layout="@layout/custom_radio_buttons" />
</RelativeLayout> </RelativeLayout>
<LinearLayout <LinearLayout
@ -137,8 +149,6 @@
android:orientation="vertical" android:orientation="vertical"
android:visibility="gone" > android:visibility="gone" >
<include layout="@layout/custom_radio_buttons" />
<View <View
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/content_padding_small" /> android:layout_height="@dimen/content_padding_small" />
@ -150,6 +160,11 @@
</LinearLayout> </LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider" />
<LinearLayout <LinearLayout
android:id="@+id/measure_mode_controls" android:id="@+id/measure_mode_controls"
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -478,7 +478,7 @@ public class UiUtilities {
endButtonText.setTextColor(activeColor); endButtonText.setTextColor(activeColor);
startButtonContainer.setBackgroundDrawable(background); startButtonContainer.setBackgroundDrawable(background);
startButtonText.setTextColor(textColor); startButtonText.setTextColor(textColor);
} else { } else if (buttonType == CustomRadioButtonType.END) {
if (isLayoutRtl) { if (isLayoutRtl) {
background.setCornerRadii(new float[]{radius, radius, 0, 0, 0, 0, radius, radius}); background.setCornerRadii(new float[]{radius, radius, 0, 0, 0, 0, radius, radius});
} else { } else {
@ -488,6 +488,11 @@ public class UiUtilities {
endButtonText.setTextColor(textColor); endButtonText.setTextColor(textColor);
startButtonContainer.setBackgroundColor(Color.TRANSPARENT); startButtonContainer.setBackgroundColor(Color.TRANSPARENT);
startButtonText.setTextColor(activeColor); startButtonText.setTextColor(activeColor);
} else if (buttonType == null) {
endButtonContainer.setBackgroundColor(Color.TRANSPARENT);
startButtonContainer.setBackgroundColor(Color.TRANSPARENT);
endButtonText.setTextColor(activeColor);
startButtonText.setTextColor(activeColor);
} }
} }

View file

@ -64,6 +64,8 @@ public class HorizontalSelectionAdapter extends RecyclerView.Adapter<HorizontalS
final HorizontalSelectionItem item = items.get(holder.getAdapterPosition()); final HorizontalSelectionItem item = items.get(holder.getAdapterPosition());
TextView textView = holder.buttonText; TextView textView = holder.buttonText;
int activeColorResId = nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light; int activeColorResId = nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light;
int innerPadding = AndroidUtils.dpToPx(app, 16);
textView.setPadding(innerPadding, 0, innerPadding, 0);
if (item.equals(selectedItem) && item.isEnabled()) { if (item.equals(selectedItem) && item.isEnabled()) {
AndroidUtils.setBackground(holder.button, app.getUIUtilities().getPaintedIcon( AndroidUtils.setBackground(holder.button, app.getUIUtilities().getPaintedIcon(
R.drawable.bg_select_icon_group_button, ContextCompat.getColor(app, activeColorResId))); R.drawable.bg_select_icon_group_button, ContextCompat.getColor(app, activeColorResId)));

View file

@ -77,6 +77,10 @@ public class TrackDetailsMenu {
private boolean hidding; private boolean hidding;
private Location myLocation; private Location myLocation;
public boolean shouldShowXAxisPoints () {
return true;
}
@Nullable @Nullable
public MapActivity getMapActivity() { public MapActivity getMapActivity() {
return mapActivity; return mapActivity;
@ -518,7 +522,9 @@ public class TrackDetailsMenu {
} else { } else {
gpxItem.chartHighlightPos = -1; gpxItem.chartHighlightPos = -1;
} }
if (shouldShowXAxisPoints()) {
trackChartPoints.setXAxisPoints(getXAxisPoints(chart)); trackChartPoints.setXAxisPoints(getXAxisPoints(chart));
}
if (gpxItem.route) { if (gpxItem.route) {
mapActivity.getMapLayers().getMapInfoLayer().setTrackChartPoints(trackChartPoints); mapActivity.getMapLayers().getMapInfoLayer().setTrackChartPoints(trackChartPoints);
} else { } else {

View file

@ -127,7 +127,8 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
private Snackbar snackbar; private Snackbar snackbar;
private String fileName; private String fileName;
private AdditionalInfoType currentAdditionalInfoType; private @Nullable
AdditionalInfoType currentAdditionalInfoType;
private boolean wasCollapseButtonVisible; private boolean wasCollapseButtonVisible;
private boolean progressBarVisible; private boolean progressBarVisible;
@ -175,6 +176,11 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
protected int getFragmentHeight() { protected int getFragmentHeight() {
return mainView.getHeight(); return mainView.getHeight();
} }
@Override
public boolean shouldShowXAxisPoints() {
return false;
}
} }
private void setEditingCtx(MeasurementEditingContext editingCtx) { private void setEditingCtx(MeasurementEditingContext editingCtx) {
@ -264,6 +270,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
portrait = AndroidUiHelper.isOrientationPortrait(mapActivity); portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
pointsSt = getString(R.string.shared_string_gpx_points).toLowerCase(); pointsSt = getString(R.string.shared_string_gpx_points).toLowerCase();
int widthInPixels = getResources().getDimensionPixelOffset(R.dimen.gpx_group_button_width);
View view = UiUtilities.getInflater(getContext(), nightMode) View view = UiUtilities.getInflater(getContext(), nightMode)
.inflate(R.layout.fragment_measurement_tool, container, false); .inflate(R.layout.fragment_measurement_tool, container, false);
@ -283,6 +290,15 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
@Override @Override
public void onClick(View v) { public void onClick(View v) {
changeAdditionalInfoType(AdditionalInfoType.POINTS); changeAdditionalInfoType(AdditionalInfoType.POINTS);
int pointsCount = editingCtx.getPointsCount();
if (pointsCount == 0) {
disable(upDownBtn);
collapseAdditionalInfoView();
} else {
expandAdditionalInfoView();
additionalInfoExpanded = true;
}
updateUpDownBtn();
} }
}); });
@ -293,6 +309,8 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
@Override @Override
public void onClick(View v) { public void onClick(View v) {
changeAdditionalInfoType(AdditionalInfoType.GRAPH); changeAdditionalInfoType(AdditionalInfoType.GRAPH);
expandAdditionalInfoView();
updateUpDownBtn();
} }
}); });
} }
@ -340,6 +358,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
View applyMovePointButton = mainView.findViewById(R.id.apply_move_point_button); View applyMovePointButton = mainView.findViewById(R.id.apply_move_point_button);
UiUtilities.setupDialogButton(nightMode, applyMovePointButton, UiUtilities.DialogButtonType.PRIMARY, UiUtilities.setupDialogButton(nightMode, applyMovePointButton, UiUtilities.DialogButtonType.PRIMARY,
R.string.shared_string_apply); R.string.shared_string_apply);
applyMovePointButton.setMinimumWidth(widthInPixels);
applyMovePointButton.setOnClickListener(new OnClickListener() { applyMovePointButton.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
@ -351,6 +370,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
View applyPointBeforeAfterButton = mainView.findViewById(R.id.apply_point_before_after_point_button); View applyPointBeforeAfterButton = mainView.findViewById(R.id.apply_point_before_after_point_button);
UiUtilities.setupDialogButton(nightMode, applyPointBeforeAfterButton, UiUtilities.DialogButtonType.PRIMARY, UiUtilities.setupDialogButton(nightMode, applyPointBeforeAfterButton, UiUtilities.DialogButtonType.PRIMARY,
R.string.shared_string_apply); R.string.shared_string_apply);
applyPointBeforeAfterButton.setMinimumWidth(widthInPixels);
applyPointBeforeAfterButton.setOnClickListener(new OnClickListener() { applyPointBeforeAfterButton.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
@ -361,6 +381,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
View addPointBeforeAfterButton = mainView.findViewById(R.id.add_point_before_after_button); View addPointBeforeAfterButton = mainView.findViewById(R.id.add_point_before_after_button);
UiUtilities.setupDialogButton(nightMode, addPointBeforeAfterButton, UiUtilities.DialogButtonType.PRIMARY, UiUtilities.setupDialogButton(nightMode, addPointBeforeAfterButton, UiUtilities.DialogButtonType.PRIMARY,
R.string.shared_string_add); R.string.shared_string_add);
addPointBeforeAfterButton.setMinimumWidth(widthInPixels);
addPointBeforeAfterButton.setOnClickListener(new OnClickListener() { addPointBeforeAfterButton.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
@ -416,7 +437,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
addCenterPoint(); addCenterPoint();
} }
}); });
addPointButton.setMinimumWidth(widthInPixels);
measurementLayer.setOnSingleTapListener(new MeasurementToolLayer.OnSingleTapListener() { measurementLayer.setOnSingleTapListener(new MeasurementToolLayer.OnSingleTapListener() {
@Override @Override
public void onAddPoint() { public void onAddPoint() {
@ -425,9 +446,6 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
@Override @Override
public void onSelectPoint(int selectedPointPos) { public void onSelectPoint(int selectedPointPos) {
if (additionalInfoExpanded) {
collapseAdditionalInfoView();
}
if (selectedPointPos != -1) { if (selectedPointPos != -1) {
openSelectedPointMenu(mapActivity); openSelectedPointMenu(mapActivity);
} }
@ -529,25 +547,36 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
return view; return view;
} }
private void changeAdditionalInfoType(@NonNull AdditionalInfoType type) { private void changeAdditionalInfoType(@Nullable AdditionalInfoType type) {
if (!additionalInfoExpanded || !isCurrentAdditionalInfoType(type)) { if (!additionalInfoExpanded || !isCurrentAdditionalInfoType(type)) {
MapActivity ma = getMapActivity(); MapActivity ma = getMapActivity();
if (ma == null) return; if (ma == null) return;
OsmandApplication app = ma.getMyApplication(); OsmandApplication app = ma.getMyApplication();
View buttonsDivider = customRadioButton.findViewById(R.id.buttons_divider);
if (AdditionalInfoType.POINTS == type) { if (AdditionalInfoType.POINTS == type) {
visibleCard = pointsCard; visibleCard = pointsCard;
additionalInfoExpanded = true;
buttonsDivider.setVisibility(View.GONE);
UiUtilities.updateCustomRadioButtons(app, customRadioButton, nightMode, START); UiUtilities.updateCustomRadioButtons(app, customRadioButton, nightMode, START);
} else if (AdditionalInfoType.GRAPH == type) { } else if (AdditionalInfoType.GRAPH == type) {
visibleCard = graphsCard; visibleCard = graphsCard;
additionalInfoExpanded = true;
buttonsDivider.setVisibility(View.GONE);
UiUtilities.updateCustomRadioButtons(app, customRadioButton, nightMode, END); UiUtilities.updateCustomRadioButtons(app, customRadioButton, nightMode, END);
} else if (null == type) {
visibleCard = null;
additionalInfoExpanded = false;
buttonsDivider.setVisibility(View.VISIBLE);
UiUtilities.updateCustomRadioButtons(app, customRadioButton, nightMode, null);
} }
cardsContainer.removeAllViews(); cardsContainer.removeAllViews();
if (visibleCard != null) {
View cardView = visibleCard.getView() != null ? visibleCard.getView() : visibleCard.build(ma); View cardView = visibleCard.getView() != null ? visibleCard.getView() : visibleCard.build(ma);
cardsContainer.addView(cardView); cardsContainer.addView(cardView);
}
currentAdditionalInfoType = type; currentAdditionalInfoType = type;
additionalInfoExpanded = true;
updateUpDownBtn(); updateUpDownBtn();
} }
} }
@ -1465,9 +1494,10 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
private void collapseAdditionalInfoView() { private void collapseAdditionalInfoView() {
if (portrait) { if (portrait) {
additionalInfoExpanded = false; additionalInfoExpanded = false;
updateUpDownBtn();
additionalInfoContainer.setVisibility(View.GONE); additionalInfoContainer.setVisibility(View.GONE);
setDefaultMapPosition(); setDefaultMapPosition();
changeAdditionalInfoType(null);
updateUpDownBtn();
} }
} }