mirror of
https://github.com/nextcloud/android.git
synced 2024-11-23 13:45:35 +03:00
group change data and size together and calculate decimals based on total size see comment in PR #1090
This commit is contained in:
parent
c86e92870f
commit
607fb6f587
4 changed files with 28 additions and 8 deletions
|
@ -30,12 +30,12 @@
|
|||
android:orientation="horizontal">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="64dp"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="72dp"
|
||||
android:paddingLeft="@dimen/standard_padding"
|
||||
android:paddingBottom="@dimen/standard_padding"
|
||||
android:paddingTop="@dimen/standard_padding"
|
||||
android:paddingRight="8dp"
|
||||
android:paddingRight="4dp"
|
||||
android:focusable="false"
|
||||
android:focusableInTouchMode="false">
|
||||
|
||||
|
@ -89,14 +89,22 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="0dp"
|
||||
android:layout_marginRight="4dp"
|
||||
android:weightSum="1">
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/last_mod"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="TextView"
|
||||
android:layout_weight=".5"
|
||||
android:textColor="@color/list_item_lastmod_and_filesize_text"
|
||||
android:textSize="@dimen/two_line_secondary_text_size"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/file_separator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="right"
|
||||
android:text=", "
|
||||
android:textColor="@color/list_item_lastmod_and_filesize_text"
|
||||
android:textSize="@dimen/two_line_secondary_text_size"/>
|
||||
|
||||
|
@ -107,7 +115,6 @@
|
|||
android:gravity="right"
|
||||
android:text="TextView"
|
||||
android:textColor="@color/list_item_lastmod_and_filesize_text"
|
||||
android:layout_weight=".5"
|
||||
android:textSize="@dimen/two_line_secondary_text_size"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -192,6 +192,7 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter {
|
|||
switch (viewType){
|
||||
case LIST_ITEM:
|
||||
TextView fileSizeV = (TextView) view.findViewById(R.id.file_size);
|
||||
TextView fileSizeSeparatorV = (TextView) view.findViewById(R.id.file_separator);
|
||||
TextView lastModV = (TextView) view.findViewById(R.id.last_mod);
|
||||
ImageView checkBoxV = (ImageView) view.findViewById(R.id.custom_checkbox);
|
||||
|
||||
|
@ -200,6 +201,7 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter {
|
|||
|
||||
checkBoxV.setVisibility(View.GONE);
|
||||
|
||||
fileSizeSeparatorV.setVisibility(View.VISIBLE);
|
||||
fileSizeV.setVisibility(View.VISIBLE);
|
||||
fileSizeV.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength()));
|
||||
|
||||
|
@ -221,6 +223,7 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter {
|
|||
}
|
||||
|
||||
} else { //Folder
|
||||
fileSizeSeparatorV.setVisibility(View.INVISIBLE);
|
||||
fileSizeV.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
|
|
|
@ -111,9 +111,11 @@ public class LocalFileListAdapter extends BaseAdapter implements ListAdapter {
|
|||
fileIcon.setTag(file.hashCode());
|
||||
|
||||
TextView fileSizeV = (TextView) view.findViewById(R.id.file_size);
|
||||
TextView fileSizeSeparatorV = (TextView) view.findViewById(R.id.file_separator);
|
||||
TextView lastModV = (TextView) view.findViewById(R.id.last_mod);
|
||||
ImageView checkBoxV = (ImageView) view.findViewById(R.id.custom_checkbox);
|
||||
if (!file.isDirectory()) {
|
||||
fileSizeSeparatorV.setVisibility(View.VISIBLE);
|
||||
fileSizeV.setVisibility(View.VISIBLE);
|
||||
fileSizeV.setText(DisplayUtils.bytesToHumanReadable(file.length()));
|
||||
|
||||
|
@ -163,6 +165,7 @@ public class LocalFileListAdapter extends BaseAdapter implements ListAdapter {
|
|||
}
|
||||
|
||||
} else {
|
||||
fileSizeSeparatorV.setVisibility(View.GONE);
|
||||
fileSizeV.setVisibility(View.GONE);
|
||||
lastModV.setVisibility(View.GONE);
|
||||
checkBoxV.setVisibility(View.GONE);
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
package com.owncloud.android.utils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.net.IDN;
|
||||
import java.text.DateFormat;
|
||||
import java.util.Arrays;
|
||||
|
@ -55,6 +56,7 @@ public class DisplayUtils {
|
|||
//private static String TAG = DisplayUtils.class.getSimpleName();
|
||||
|
||||
private static final String[] sizeSuffixes = { "B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" };
|
||||
private static final int[] sizeScales = { 0, 0, 0, 1, 1, 2, 2, 2, 2 };
|
||||
|
||||
private static HashMap<String, String> mimeType2HUmanReadable;
|
||||
static {
|
||||
|
@ -114,7 +116,11 @@ public class DisplayUtils {
|
|||
|
||||
/**
|
||||
* Converts the file size in bytes to human readable output.
|
||||
*
|
||||
* <ul>
|
||||
* <li>appends a size suffix, e.g. B, KB, MB etc.</li>
|
||||
* <li>rounds the size based on the suffix to 0,1 or 2 decimals</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param bytes Input file size
|
||||
* @return Like something readable like "12 MB"
|
||||
*/
|
||||
|
@ -125,8 +131,9 @@ public class DisplayUtils {
|
|||
result /= 1024.;
|
||||
attachedsuff++;
|
||||
}
|
||||
result = ((int) (result * 100)) / 100.;
|
||||
return result + " " + sizeSuffixes[attachedsuff];
|
||||
|
||||
return new BigDecimal(result).setScale(
|
||||
sizeScales[attachedsuff], BigDecimal.ROUND_HALF_UP) + " " + sizeSuffixes[attachedsuff];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue