Add small changes to AndroidUtils and OsmandFormatter
This commit is contained in:
parent
ee0d79d59a
commit
c7ffc1afa8
2 changed files with 9 additions and 2 deletions
|
@ -90,7 +90,7 @@ object AndroidUtils {
|
||||||
val paint = Paint().apply { textSize = txtSize.toFloat() }
|
val paint = Paint().apply { textSize = txtSize.toFloat() }
|
||||||
val maxTextWidth = titles.map { paint.measureText(it) }.max()
|
val maxTextWidth = titles.map { paint.measureText(it) }.max()
|
||||||
if (maxTextWidth != null) {
|
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)
|
val minWidth = AndroidUtils.dpToPx(ctx, 100f)
|
||||||
return maxOf(minWidth, maxItemWidth)
|
return maxOf(minWidth, maxItemWidth)
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ object OsmandFormatter {
|
||||||
fun getFormattedDuration(ctx: Context, seconds: Int, short: Boolean = false): String {
|
fun getFormattedDuration(ctx: Context, seconds: Int, short: Boolean = false): String {
|
||||||
val hours = seconds / (60 * 60)
|
val hours = seconds / (60 * 60)
|
||||||
val minutes = seconds / 60 % 60
|
val minutes = seconds / 60 % 60
|
||||||
|
val secs = seconds - minutes * 60
|
||||||
if (short) {
|
if (short) {
|
||||||
return String.format(SHORT_TIME_FORMAT, hours, minutes)
|
return String.format(SHORT_TIME_FORMAT, hours, minutes)
|
||||||
}
|
}
|
||||||
|
@ -47,7 +48,13 @@ object OsmandFormatter {
|
||||||
}
|
}
|
||||||
res
|
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)}"
|
else -> "$seconds ${ctx.getString(R.string.shared_string_second_short)}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue