diff --git a/app/src/main/java/org/mian/gitnex/adapters/FilesAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/FilesAdapter.java index d8c731f4..c2fa1c53 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/FilesAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/FilesAdapter.java @@ -13,6 +13,7 @@ import androidx.recyclerview.widget.RecyclerView; import org.mian.gitnex.R; import org.mian.gitnex.helpers.Toasty; import org.mian.gitnex.models.Files; +import org.mian.gitnex.util.AppUtil; import java.util.ArrayList; import java.util.List; @@ -38,6 +39,7 @@ public class FilesAdapter extends RecyclerView.Adapter 1 ) { repoSize = dec.format(t).concat(" TB"); - } else if ( g > 1 ) { + } + else if ( g > 1 ) { repoSize = dec.format(g).concat(" GB"); - } else if ( m > 1 ) { + } + else if ( m > 1 ) { repoSize = dec.format(m).concat(" MB"); - } else if ( k > 1 ) { - repoSize = dec.format(k).concat(" KB"); + } + else if ( (double) size > 1 ) { + repoSize = dec.format((double) size).concat(" KB"); } return repoSize; } + public static String formatFileSizeInDetail(long size) { + + String fileSize = null; + + double k = size/1024.0; + double m = ((size/1024.0)/1024.0); + double g = (((size/1024.0)/1024.0)/1024.0); + double t = ((((size/1024.0)/1024.0)/1024.0)/1024.0); + + DecimalFormat dec = new DecimalFormat("0.00"); + + if ( t > 1 ) { + fileSize = dec.format(t).concat(" TB"); + } + else if ( g > 1 ) { + fileSize = dec.format(g).concat(" GB"); + } + else if ( m > 1 ) { + fileSize = dec.format(m).concat(" MB"); + } + else if ( k > 1 ) { + fileSize = dec.format(k).concat(" KB"); + } + else if ( (double) size > 1 ) { + fileSize = dec.format((double) size).concat(" B"); + } + + return fileSize; + + } + public static String customDateFormat(String customDate) { String[] parts = customDate.split("-"); diff --git a/app/src/main/res/layout/files_list.xml b/app/src/main/res/layout/files_list.xml index bfbb5b69..7cdc9208 100644 --- a/app/src/main/res/layout/files_list.xml +++ b/app/src/main/res/layout/files_list.xml @@ -43,10 +43,21 @@ android:textColor="?attr/primaryTextColor" android:textSize="16sp" /> + + File is saved to Download directory This file type is not supported in file viewer. Download it instead from the three dotted menu? + Size Share Issue Share Repository