Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
6 changes: 0 additions & 6 deletions src/com/owncloud/android/ui/adapter/FileListListAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.TextView;

import com.owncloud.android.R;
Expand Down Expand Up @@ -196,11 +195,6 @@ public View getView(int position, View convertView, ViewGroup parent) {
fileSizeV.setVisibility(View.VISIBLE);
fileSizeV.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength()));

if (file.isFolder()) {
fileSizeSeparatorV.setVisibility(View.GONE);
fileSizeV.setVisibility(View.GONE);
}

case GRID_ITEM:
// filename
fileName = (TextView) view.findViewById(R.id.Filename);
Expand Down
25 changes: 15 additions & 10 deletions src/com/owncloud/android/utils/DisplayUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
}

/**
Expand Down