Skip to content

Commit

Permalink
Merge pull request #21867 from osmandapp/fix-route-info-widget-after-…
Browse files Browse the repository at this point in the history
…ui-review

Fix "Route Information" widget after 1st UI Review
  • Loading branch information
Chumva authored Feb 7, 2025
2 parents bbd396a + 9d85bec commit edea8e9
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 18 deletions.
12 changes: 9 additions & 3 deletions OsmAnd/res/layout/widget_route_information_medium.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,21 @@
android:background="?android:listDivider" />

<!-- Secondary block -->
<LinearLayout
<FrameLayout
android:id="@+id/secondary_block"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical|end"
android:layout_marginEnd="16dp"
android:layout_marginVertical="6dp"
android:orientation="vertical">

<net.osmand.plus.widgets.TextViewEx
android:id="@+id/primary_value_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:layout_marginBottom="-1dp"
android:textColor="?android:textColorSecondary"
android:textSize="16sp"
tools:text="01:27" />
Expand All @@ -108,6 +111,7 @@
android:id="@+id/secondary_value_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textColor="?android:textColorSecondary"
android:textSize="16sp"
tools:text="9 h 23 m" />
Expand All @@ -116,10 +120,12 @@
android:id="@+id/tertiary_value_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginTop="-1dp"
android:textColor="?android:textColorSecondary"
android:textSize="16sp"
tools:text="629 km" />

</LinearLayout>
</FrameLayout>

</LinearLayout>
31 changes: 21 additions & 10 deletions OsmAnd/res/layout/widget_route_information_small_duo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@
android:orientation="horizontal">

<!-- Button with tappable area -->

<!-- Primary block -->
<FrameLayout
android:id="@+id/button_tappable_area"
android:layout_width="wrap_content"
android:layout_height="match_parent">

<FrameLayout
android:layout_width="30dp"
android:layout_height="match_parent"
android:layout_height="30dp"
android:layout_gravity="center_vertical"
android:layout_marginHorizontal="16dp"
android:layout_marginVertical="9dp">
Expand All @@ -25,11 +27,10 @@

</FrameLayout>

<!-- Primary block -->
<LinearLayout
<FrameLayout
android:id="@+id/primary_block"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_height="36dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:orientation="vertical">
Expand All @@ -38,19 +39,22 @@
android:id="@+id/primary_value_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:textColor="?android:textColorPrimary"
android:textSize="16sp"
tools:text="20:33" />

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="horizontal">

<net.osmand.plus.widgets.TextViewEx
android:id="@+id/secondary_value_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="bottom"
android:textColor="?android:textColorSecondary"
android:textSize="14sp"
tools:text="13 h 27 m" />
Expand All @@ -59,6 +63,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="4dp"
android:gravity="bottom"
android:text=""
android:textColor="?android:textColorSecondary"
android:textSize="14sp"
Expand All @@ -68,49 +73,53 @@
android:id="@+id/tertiary_value_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="bottom"
android:textColor="?android:textColorSecondary"
android:textSize="14sp"
tools:text="331 km" />

</LinearLayout>

</LinearLayout>
</FrameLayout>

<!-- Divider -->
<View
android:id="@+id/blocks_divider"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_height="30dp"
android:layout_marginHorizontal="16dp"
android:layout_marginVertical="9dp"
android:background="?android:listDivider" />

<!-- Secondary block -->
<LinearLayout
<FrameLayout
android:id="@+id/secondary_block"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_height="36dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:layout_marginEnd="16dp"
android:orientation="vertical">

<net.osmand.plus.widgets.TextViewEx
android:id="@+id/primary_value_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:textColor="?android:textColorPrimary"
android:textSize="16sp"
tools:text="01:27" />

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="horizontal">

<net.osmand.plus.widgets.TextViewEx
android:id="@+id/secondary_value_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="bottom"
android:textColor="?android:textColorSecondary"
android:textSize="14sp"
tools:text="9 h 23 m" />
Expand All @@ -119,6 +128,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="4dp"
android:gravity="bottom"
android:text=""
android:textColor="?android:textColorSecondary"
android:textSize="14sp"
Expand All @@ -128,13 +138,14 @@
android:id="@+id/tertiary_value_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="bottom"
android:textColor="?android:textColorSecondary"
android:textSize="14sp"
tools:text="629 km" />

</LinearLayout>

</LinearLayout>
</FrameLayout>


</LinearLayout>
13 changes: 9 additions & 4 deletions OsmAnd/src/net/osmand/plus/utils/OsmAndFormatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.SwissGridApproximation;
import net.osmand.plus.helpers.LocaleHelper;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.settings.backend.preferences.OsmandPreference;
Expand All @@ -42,6 +43,7 @@
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.MessageFormat;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
Expand Down Expand Up @@ -112,17 +114,20 @@ public static void setTwelveHoursFormatting(boolean setTwelveHoursFormat, @NonNu
}

public static String getFormattedDuration(long seconds, @NonNull OsmandApplication app) {
LocaleHelper localeHelper = app.getLocaleHelper();
Locale locale = localeHelper.getPreferredLocale() != null ? localeHelper.getPreferredLocale() : localeHelper.getDefaultLocale();
NumberFormat numberFormat = NumberFormat.getInstance(locale);
long hours = seconds / (60 * 60);
long minutes = (seconds / 60) % 60;
if (hours > 0) {
return hours + " "
return numberFormat.format(hours) + " "
+ app.getString(R.string.osmand_parking_hour)
+ (minutes > 0 ? " " + minutes + " "
+ (minutes > 0 ? " " + numberFormat.format(minutes) + " "
+ app.getString(R.string.shared_string_minute_lowercase) : "");
} else if (minutes > 0) {
return minutes + " " + app.getString(R.string.shared_string_minute_lowercase);
return numberFormat.format(minutes) + " " + app.getString(R.string.shared_string_minute_lowercase);
} else {
return "<1 " + app.getString(R.string.shared_string_minute_lowercase);
return "<" + numberFormat.format(1) + " " + app.getString(R.string.shared_string_minute_lowercase);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.settings.backend.preferences.OsmandPreference;
import net.osmand.plus.utils.OsmAndFormatter;
import net.osmand.plus.views.layers.base.OsmandMapLayer.DrawSettings;
import net.osmand.plus.views.mapwidgets.WidgetType;
import net.osmand.plus.views.mapwidgets.WidgetsPanel;
Expand Down

0 comments on commit edea8e9

Please sign in to comment.