Show toot stat inline (#3413)
* Show toot stat inline * Correct elements position * Format stats and show it according to setting * inline toot statistics setting * Code formatting * Use kotlin functions * Change the statistics setting description * Use capital letters for all variants * increase the statistics margin * Merge fixes * Code review fixes * move setReblogsCount and setFavouritedCount to StatusViewHolder * code cleaning * code cleaning * import lexicographical order --------- Co-authored-by: Grigorii Ioffe <zikasaks@gmail.com> Co-authored-by: grigoriiioffe <zikasaks@icloud.com>
This commit is contained in:
parent
9087d0ecdd
commit
75e7b9f1a5
16 changed files with 146 additions and 4 deletions
|
@ -48,6 +48,7 @@ class NotificationsViewModelTestStatusDisplayOptions : NotificationsViewModelTes
|
|||
confirmFavourites = false,
|
||||
hideStats = false,
|
||||
animateEmojis = false,
|
||||
showStatsInline = false,
|
||||
showSensitiveMedia = true, // setting in NotificationsViewModelTestBase
|
||||
openSpoiler = true // setting in NotificationsViewModelTestBase
|
||||
)
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package com.keylesspalace.tusky.util
|
||||
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import kotlin.math.pow
|
||||
|
||||
class NumberUtilsTest {
|
||||
|
||||
@Test
|
||||
fun zeroShouldBeFormattedAsZero() {
|
||||
val shortNumber = shortNumber(0)
|
||||
Assert.assertEquals("0", shortNumber)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun negativeValueShouldBeFormattedToNegativeValue() {
|
||||
val shortNumber = shortNumber(-1)
|
||||
Assert.assertEquals("-1", shortNumber)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun positiveValueShouldBeFormattedToPositiveValue() {
|
||||
val shortNumber = shortNumber(1)
|
||||
Assert.assertEquals("1", shortNumber)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun bigNumbersShouldBeShortened() {
|
||||
var shortNumber = 1L
|
||||
Assert.assertEquals("1", shortNumber(shortNumber))
|
||||
for (i in shortLetters.indices) {
|
||||
if (i == 0) {
|
||||
continue
|
||||
}
|
||||
shortNumber = 1000.0.pow(i.toDouble()).toLong()
|
||||
Assert.assertEquals("1.0" + shortLetters[i], shortNumber(shortNumber))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun roundingForNegativeAndPositiveValuesShouldBeTheSame() {
|
||||
var value = 3492
|
||||
Assert.assertEquals("-3.5K", shortNumber(-value))
|
||||
Assert.assertEquals("3.5K", shortNumber(value))
|
||||
value = 1501
|
||||
Assert.assertEquals("-1.5K", shortNumber(-value))
|
||||
Assert.assertEquals("1.5K", shortNumber(value))
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue