From c7ffc1afa8288dcd85c3acb87dc7e1c0b270bff8 Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Fri, 10 Aug 2018 11:12:29 +0300 Subject: [PATCH] Add small changes to AndroidUtils and OsmandFormatter --- .../src/net/osmand/telegram/utils/AndroidUtils.kt | 2 +- .../src/net/osmand/telegram/utils/OsmandFormatter.kt | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/OsmAnd-telegram/src/net/osmand/telegram/utils/AndroidUtils.kt b/OsmAnd-telegram/src/net/osmand/telegram/utils/AndroidUtils.kt index d9b78ae239..df73fd121a 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/utils/AndroidUtils.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/utils/AndroidUtils.kt @@ -90,7 +90,7 @@ object AndroidUtils { val paint = Paint().apply { textSize = txtSize.toFloat() } val maxTextWidth = titles.map { paint.measureText(it) }.max() if (maxTextWidth != null) { - val maxItemWidth = maxTextWidth.toInt() + AndroidUtils.dpToPx(ctx, 33f) + val maxItemWidth = maxTextWidth.toInt() + AndroidUtils.dpToPx(ctx, 34f) val minWidth = AndroidUtils.dpToPx(ctx, 100f) return maxOf(minWidth, maxItemWidth) } diff --git a/OsmAnd-telegram/src/net/osmand/telegram/utils/OsmandFormatter.kt b/OsmAnd-telegram/src/net/osmand/telegram/utils/OsmandFormatter.kt index 6b126c46f9..5a5a6192d5 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/utils/OsmandFormatter.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/utils/OsmandFormatter.kt @@ -36,6 +36,7 @@ object OsmandFormatter { fun getFormattedDuration(ctx: Context, seconds: Int, short: Boolean = false): String { val hours = seconds / (60 * 60) val minutes = seconds / 60 % 60 + val secs = seconds - minutes * 60 if (short) { return String.format(SHORT_TIME_FORMAT, hours, minutes) } @@ -47,7 +48,13 @@ object OsmandFormatter { } res } - minutes > 0 -> "$minutes ${ctx.getString(R.string.shared_string_minute_short)}" + minutes > 0 -> { + var res = "$minutes ${ctx.getString(R.string.shared_string_minute_short)}" + if (secs > 0) { + res += " $secs ${ctx.getString(R.string.shared_string_second_short)}" + } + res + } else -> "$seconds ${ctx.getString(R.string.shared_string_second_short)}" } }