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:gravity="center"
android:textSize="@dimen/default_desc_text_size"
android:textColor="@drawable/radio_flat_text_selector_light"
osmand:typeface="@string/font_roboto_medium"
tools:text="@string/shared_string_left"/>
</FrameLayout>
<FrameLayout
android:id="@+id/center_button_container"
android:layout_width="0dp"
android:id="@+id/buttons_divider"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:visibility="gone">
<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"/>
android:layout_weight="0"
android:background="?attr/divider_color">
</FrameLayout>
@ -61,8 +52,9 @@
android:layout_height="match_parent"
android:background="?attr/selectableItemBackground"
android:gravity="center"
android:textSize="@dimen/default_desc_text_size"
android:textColor="@drawable/radio_flat_text_selector_light"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"
tools:text="@string/shared_string_right"/>
</FrameLayout>

View file

@ -30,22 +30,23 @@
<RelativeLayout
android:id="@+id/up_down_row"
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">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/main_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="@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_alignParentLeft="true"
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"
tools:src="@drawable/ic_action_ruler"/>
tools:src="@drawable/ic_action_ruler" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/up_down_button"
@ -53,7 +54,7 @@
android:layout_height="wrap_content"
android:layout_alignParentEnd="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_marginLeft="@dimen/bottom_sheet_content_margin"
android:layout_marginRight="@dimen/bottom_sheet_content_margin"
@ -128,6 +129,17 @@
android:textAppearance="@style/TextAppearance.ListItemTitle"
android:visibility="gone"
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>
<LinearLayout
@ -137,8 +149,6 @@
android:orientation="vertical"
android:visibility="gone" >
<include layout="@layout/custom_radio_buttons" />
<View
android:layout_width="match_parent"
android:layout_height="@dimen/content_padding_small" />
@ -150,6 +160,11 @@
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider" />
<LinearLayout
android:id="@+id/measure_mode_controls"
android:layout_width="match_parent"

View file

@ -478,7 +478,7 @@ public class UiUtilities {
endButtonText.setTextColor(activeColor);
startButtonContainer.setBackgroundDrawable(background);
startButtonText.setTextColor(textColor);
} else {
} else if (buttonType == CustomRadioButtonType.END) {
if (isLayoutRtl) {
background.setCornerRadii(new float[]{radius, radius, 0, 0, 0, 0, radius, radius});
} else {
@ -488,6 +488,11 @@ public class UiUtilities {
endButtonText.setTextColor(textColor);
startButtonContainer.setBackgroundColor(Color.TRANSPARENT);
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());
TextView textView = holder.buttonText;
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()) {
AndroidUtils.setBackground(holder.button, app.getUIUtilities().getPaintedIcon(
R.drawable.bg_select_icon_group_button, ContextCompat.getColor(app, activeColorResId)));

View file

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

View file

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