Merge pull request #10249 from osmandapp/Plan-route-fix-
Plan Route Fix UI margins
This commit is contained in:
commit
a73e647d2f
6 changed files with 102 additions and 52 deletions
|
@ -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>
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -141,7 +141,7 @@ public class UiUtilities {
|
|||
}
|
||||
|
||||
public Drawable getLayeredIcon(@DrawableRes int bgIconId, @DrawableRes int foregroundIconId,
|
||||
@ColorRes int bgColorId, @ColorRes int foregroundColorId) {
|
||||
@ColorRes int bgColorId, @ColorRes int foregroundColorId) {
|
||||
Drawable background = getDrawable(bgIconId, bgColorId);
|
||||
Drawable foreground = getDrawable(foregroundIconId, foregroundColorId);
|
||||
return getLayeredIcon(background, foreground);
|
||||
|
@ -272,11 +272,11 @@ public class UiUtilities {
|
|||
}
|
||||
|
||||
public void updateLocationView(UpdateLocationViewCache cache, ImageView arrow, TextView txt,
|
||||
double toLat, double toLon) {
|
||||
double toLat, double toLon) {
|
||||
updateLocationView(cache, arrow, txt, new LatLon(toLat, toLon));
|
||||
}
|
||||
public void updateLocationView(UpdateLocationViewCache cache, ImageView arrow, TextView txt,
|
||||
LatLon toLoc) {
|
||||
LatLon toLoc) {
|
||||
float[] mes = new float[2];
|
||||
boolean stale = false;
|
||||
LatLon fromLoc = cache == null ? null : cache.specialFrom;
|
||||
|
@ -390,7 +390,7 @@ public class UiUtilities {
|
|||
}
|
||||
|
||||
public static void setupSnackbar(Snackbar snackbar, boolean nightMode, @ColorRes Integer backgroundColor,
|
||||
@ColorRes Integer messageColor, @ColorRes Integer actionColor, Integer maxLines) {
|
||||
@ColorRes Integer messageColor, @ColorRes Integer actionColor, Integer maxLines) {
|
||||
if (snackbar == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -451,7 +451,7 @@ public class UiUtilities {
|
|||
|
||||
|
||||
public static void updateCustomRadioButtons(Context app, View buttonsView, boolean nightMode,
|
||||
CustomRadioButtonType buttonType) {
|
||||
CustomRadioButtonType buttonType) {
|
||||
int activeColor = ContextCompat.getColor(app, nightMode
|
||||
? R.color.active_color_primary_dark
|
||||
: R.color.active_color_primary_light);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -502,10 +507,10 @@ public class UiUtilities {
|
|||
}
|
||||
|
||||
public static void setupCompoundButton(boolean nightMode, @ColorInt int activeColor, CompoundButton compoundButton) {
|
||||
if (compoundButton == null) {
|
||||
return;
|
||||
}
|
||||
Context ctx = compoundButton.getContext();
|
||||
if (compoundButton == null) {
|
||||
return;
|
||||
}
|
||||
Context ctx = compoundButton.getContext();
|
||||
int inactiveColorPrimary = ContextCompat.getColor(ctx, nightMode ? R.color.icon_color_default_dark : R.color.icon_color_secondary_light);
|
||||
int inactiveColorSecondary = getColorWithAlpha(inactiveColorPrimary, 0.45f);
|
||||
setupCompoundButton(compoundButton, activeColor, inactiveColorPrimary, inactiveColorSecondary);
|
||||
|
@ -584,7 +589,7 @@ public class UiUtilities {
|
|||
}
|
||||
|
||||
public static void setupSlider(Slider slider, boolean nightMode,
|
||||
@ColorInt Integer activeColor, boolean showTicks) {
|
||||
@ColorInt Integer activeColor, boolean showTicks) {
|
||||
Context ctx = slider.getContext();
|
||||
if (ctx == null) {
|
||||
return;
|
||||
|
@ -770,9 +775,9 @@ public class UiUtilities {
|
|||
}
|
||||
|
||||
public static ListPopupWindow createListPopupWindow(Context themedCtx,
|
||||
View v, int minWidth,
|
||||
List<SimplePopUpMenuItem> items,
|
||||
final AdapterView.OnItemClickListener listener) {
|
||||
View v, int minWidth,
|
||||
List<SimplePopUpMenuItem> items,
|
||||
final AdapterView.OnItemClickListener listener) {
|
||||
int contentPadding = themedCtx.getResources().getDimensionPixelSize(R.dimen.content_padding);
|
||||
int contentPaddingHalf = themedCtx.getResources().getDimensionPixelSize(R.dimen.content_padding_half);
|
||||
int defaultListTextSize = themedCtx.getResources().getDimensionPixelSize(R.dimen.default_list_text_size);
|
||||
|
|
|
@ -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)));
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
trackChartPoints.setXAxisPoints(getXAxisPoints(chart));
|
||||
if (shouldShowXAxisPoints()) {
|
||||
trackChartPoints.setXAxisPoints(getXAxisPoints(chart));
|
||||
}
|
||||
if (gpxItem.route) {
|
||||
mapActivity.getMapLayers().getMapInfoLayer().setTrackChartPoints(trackChartPoints);
|
||||
} else {
|
||||
|
|
|
@ -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();
|
||||
View cardView = visibleCard.getView() != null ? visibleCard.getView() : visibleCard.build(ma);
|
||||
cardsContainer.addView(cardView);
|
||||
if (visibleCard != null) {
|
||||
View cardView = visibleCard.getView() != null ? visibleCard.getView() : visibleCard.build(ma);
|
||||
cardsContainer.addView(cardView);
|
||||
}
|
||||
|
||||
currentAdditionalInfoType = type;
|
||||
additionalInfoExpanded = true;
|
||||
updateUpDownBtn();
|
||||
}
|
||||
}
|
||||
|
@ -1030,7 +1059,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
|||
|
||||
@Override
|
||||
public void onChangeApplicationMode(ApplicationMode mode, RouteBetweenPointsDialogType dialogType,
|
||||
RouteBetweenPointsDialogMode dialogMode) {
|
||||
RouteBetweenPointsDialogMode dialogMode) {
|
||||
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
||||
if (measurementLayer != null) {
|
||||
ChangeRouteType changeRouteType = ChangeRouteType.NEXT_SEGMENT;
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1866,7 +1896,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
|||
}
|
||||
|
||||
public static boolean showInstance(FragmentManager fragmentManager, MeasurementEditingContext editingCtx,
|
||||
boolean followTrackMode) {
|
||||
boolean followTrackMode) {
|
||||
MeasurementToolFragment fragment = new MeasurementToolFragment();
|
||||
fragment.setEditingCtx(editingCtx);
|
||||
fragment.setMode(FOLLOW_TRACK_MODE, followTrackMode);
|
||||
|
|
Loading…
Reference in a new issue