fix vertical arrow alignment;
fix blocks within width 60dp-120dp
This commit is contained in:
parent
e5bf00162e
commit
63351ebf66
4 changed files with 23 additions and 12 deletions
|
@ -93,6 +93,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginTop="1sp"
|
||||
android:contentDescription="@string/show_view_angle"
|
||||
osmand:srcCompat="@drawable/ic_direction_arrow" />
|
||||
|
||||
|
|
|
@ -38,21 +38,23 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/content_padding"
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="@dimen/dash_margin"
|
||||
android:paddingBottom="@dimen/dash_margin">
|
||||
android:layout_marginTop="@dimen/dash_margin"
|
||||
android:layout_marginBottom="@dimen/dash_margin"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/direction"
|
||||
android:layout_width="@dimen/context_menu_transport_icon_size"
|
||||
android:layout_height="@dimen/context_menu_transport_icon_size"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginTop="1sp"
|
||||
osmand:srcCompat="@drawable/ic_direction_arrow" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/distance"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="@dimen/content_padding_small_half"
|
||||
android:layout_marginLeft="@dimen/content_padding_small_half"
|
||||
android:maxLines="1"
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
android:layout_height="@dimen/list_header_height"
|
||||
android:layout_marginStart="@dimen/content_padding"
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:gravity="center_vertical"
|
||||
android:gravity="start|center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
|
@ -14,14 +14,13 @@
|
|||
android:layout_height="match_parent"
|
||||
android:layout_marginEnd="@dimen/content_padding"
|
||||
android:layout_marginRight="@dimen/content_padding"
|
||||
android:gravity="center_vertical"
|
||||
android:maxWidth="@dimen/grid_menu_item_width"
|
||||
android:gravity="start|center_vertical"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:gravity="start|center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:weightSum="2">
|
||||
|
||||
|
@ -61,8 +60,10 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:ellipsize="end"
|
||||
android:gravity="start|center_vertical"
|
||||
android:lines="1"
|
||||
android:maxWidth="@dimen/grid_menu_item_width"
|
||||
android:minWidth="@dimen/map_route_buttons_width"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
tools:text="@string/distance" />
|
||||
|
|
|
@ -32,6 +32,7 @@ import net.osmand.plus.widgets.TextViewEx;
|
|||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class GpxBlockStatisticsBuilder {
|
||||
|
@ -232,12 +233,10 @@ public class GpxBlockStatisticsBuilder {
|
|||
public void onBindViewHolder(BlockStatisticsViewHolder holder, int position) {
|
||||
final StatBlock item = items.get(position);
|
||||
holder.valueText.setText(item.value);
|
||||
holder.titleText.setText(item.title);
|
||||
if (updateRunning) {
|
||||
holder.titleText.setWidth(app.getResources().getDimensionPixelSize(R.dimen.map_route_buttons_width));
|
||||
}
|
||||
holder.valueText.setTextColor(activeColor);
|
||||
holder.titleText.setText(item.title);
|
||||
holder.titleText.setTextColor(app.getResources().getColor(R.color.text_color_secondary_light));
|
||||
holder.titleText.setWidth(calculateWidthWithin(item.title, item.value));
|
||||
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
@ -271,6 +270,14 @@ public class GpxBlockStatisticsBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
public int calculateWidthWithin(String... texts) {
|
||||
int textSize = app.getResources().getDimensionPixelSize(R.dimen.default_desc_text_size);
|
||||
int textWidth = AndroidUtils.getTextMaxWidth(textSize, Arrays.asList(texts));
|
||||
int minWidth = AndroidUtils.dpToPx(app, 60);
|
||||
int maxWidth = AndroidUtils.dpToPx(app, 120);
|
||||
return Math.min(maxWidth, Math.max(minWidth, textWidth));
|
||||
}
|
||||
|
||||
private class BlockStatisticsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final TextViewEx valueText;
|
||||
|
|
Loading…
Reference in a new issue