Added 'Pending' placeholder for still-unknown size of incoming federated folders

This commit is contained in:
Andy Scherzinger 2016-09-01 14:42:55 +02:00
parent ad673921eb
commit 70e8f62581
2 changed files with 16 additions and 10 deletions

View file

@ -104,6 +104,7 @@
<string name="common_loading">Loading &#8230;</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>

View file

@ -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];
}
}
/**