Add small changes to AndroidUtils and OsmandFormatter

This commit is contained in:
Alex Sytnyk 2018-08-10 11:12:29 +03:00
parent ee0d79d59a
commit c7ffc1afa8
2 changed files with 9 additions and 2 deletions

View file

@ -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)
}

View file

@ -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)}"
}
}