mirror of
https://github.com/nextcloud/android.git
synced 2024-11-26 15:15:51 +03:00
Added 'Pending' placeholder for still-unknown size of incoming federated folders
This commit is contained in:
parent
ad673921eb
commit
70e8f62581
2 changed files with 16 additions and 10 deletions
|
@ -104,6 +104,7 @@
|
|||
<string name="common_loading">Loading …</string>
|
||||
<string name="common_unknown">unknown</string>
|
||||
<string name="common_error_unknown">Unknown error</string>
|
||||
<string name="common_pending">Pending</string>
|
||||
<string name="about_title">About</string>
|
||||
<string name="change_password">Change password</string>
|
||||
<string name="delete_account">Remove account</string>
|
||||
|
|
|
@ -96,19 +96,24 @@ public class DisplayUtils {
|
|||
* <li>rounds the size based on the suffix to 0,1 or 2 decimals</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param bytes Input file size
|
||||
* @return something readable like "12 MB"
|
||||
* @param bytes Input file size
|
||||
* @return something readable like "12 MB", {@link com.owncloud.android.R.string#common_pending} for negative
|
||||
* byte values
|
||||
*/
|
||||
public static String bytesToHumanReadable(long bytes) {
|
||||
double result = bytes;
|
||||
int suffixIndex = 0;
|
||||
while (result > 1024 && suffixIndex < sizeSuffixes.length) {
|
||||
result /= 1024.;
|
||||
suffixIndex++;
|
||||
}
|
||||
if (bytes < 0) {
|
||||
return MainApp.getAppContext().getString(R.string.common_pending);
|
||||
} else {
|
||||
double result = bytes;
|
||||
int suffixIndex = 0;
|
||||
while (result > 1024 && suffixIndex < sizeSuffixes.length) {
|
||||
result /= 1024.;
|
||||
suffixIndex++;
|
||||
}
|
||||
|
||||
return new BigDecimal(result).setScale(
|
||||
sizeScales[suffixIndex], BigDecimal.ROUND_HALF_UP) + " " + sizeSuffixes[suffixIndex];
|
||||
return new BigDecimal(result).setScale(
|
||||
sizeScales[suffixIndex], BigDecimal.ROUND_HALF_UP) + " " + sizeSuffixes[suffixIndex];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue