Upgrade robolectric to version 4.16 (#5923)
* Update dependency org.robolectric:robolectric to v4.16 * Fix file size formatter output on API 26+ * Use more realistic value for maxUploadSize * Update screenshots * Fix test issue: "java.security.KeyStoreException: AndroidKeyStore not found" * Add exceptions. --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: ElementBot <android@element.io>
This commit is contained in:
commit
2a9765ad33
11 changed files with 127 additions and 30 deletions
|
|
@ -24,12 +24,15 @@ class AndroidFileSizeFormatter(
|
|||
override fun format(fileSize: Long, useShortFormat: Boolean): String {
|
||||
// Since Android O, the system considers that 1kB = 1000 bytes instead of 1024 bytes.
|
||||
// We want to avoid that.
|
||||
// Sadly we do not have access to the flags values Formatter.FLAG_IEC_UNITS and Formatter.FLAG_SHORTER
|
||||
// nor the method Formatter.formatFileSize with the flags parameter.
|
||||
// So for Android 0 and more, first convert the fileSize to MB/GB/TB ourselves
|
||||
val normalizedSize = if (sdkIntProvider.get() <= Build.VERSION_CODES.N) {
|
||||
fileSize
|
||||
} else {
|
||||
// First convert the size
|
||||
when {
|
||||
fileSize < 1024 -> fileSize
|
||||
fileSize <= 1 -> fileSize
|
||||
fileSize < 1024 * 1024 -> fileSize * 1000 / 1024
|
||||
fileSize < 1024 * 1024 * 1024 -> fileSize * 1000 / 1024 * 1000 / 1024
|
||||
else -> fileSize * 1000 / 1024 * 1000 / 1024 * 1000 / 1024
|
||||
|
|
@ -40,6 +43,6 @@ class AndroidFileSizeFormatter(
|
|||
Formatter.formatShortFileSize(context, normalizedSize)
|
||||
} else {
|
||||
Formatter.formatFileSize(context, normalizedSize)
|
||||
}
|
||||
}.replace("kB", "KB")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue