From 3682aaff4dd6861a9245032f0017d91f844b5211 Mon Sep 17 00:00:00 2001 From: Page Asgardius Date: Wed, 21 Sep 2022 11:57:50 -0700 Subject: [PATCH] make size human readable --- .idea/deploymentTargetDropDown.xml | 2 +- .../java/asgardius/page/s3manager/ObjectInfo.java | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml index 14de87e..63cbf65 100644 --- a/.idea/deploymentTargetDropDown.xml +++ b/.idea/deploymentTargetDropDown.xml @@ -12,6 +12,6 @@ - + \ No newline at end of file diff --git a/app/src/main/java/asgardius/page/s3manager/ObjectInfo.java b/app/src/main/java/asgardius/page/s3manager/ObjectInfo.java index 64c2c80..ac1c11e 100644 --- a/app/src/main/java/asgardius/page/s3manager/ObjectInfo.java +++ b/app/src/main/java/asgardius/page/s3manager/ObjectInfo.java @@ -35,11 +35,15 @@ public class ObjectInfo extends AppCompatActivity { long totalSize = 0; int totalItems = 0; ListObjectsRequest orequest; + long KiB, MiB, GiB; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_object_info); + KiB = 1024; + MiB = 1024 * KiB; + GiB = 1024 * MiB; simpleProgressBar = (ProgressBar) findViewById(R.id.simpleProgressBar); filesize = (TextView) findViewById(R.id.size); filesizeinfo = (TextView) findViewById(R.id.size_info); @@ -103,7 +107,15 @@ public class ObjectInfo extends AppCompatActivity { } else { filesizeinfo.setText(getResources().getString(R.string.bucket_size)); } - filesize.setText(Long.toString(totalSize)); + if (totalSize >= GiB) { + filesize.setText(Long.toString(totalSize/GiB)+" GiB"); + } else if (totalSize >= MiB) { + filesize.setText(Long.toString(totalSize/MiB)+" MiB"); + } else if (totalSize >= KiB) { + filesize.setText(Long.toString(totalSize/KiB)+" KiB"); + } else { + filesize.setText(Long.toString(totalSize)+" Bytes"); + } simpleProgressBar.setVisibility(View.INVISIBLE); } });