make size human readable

This commit is contained in:
Page Asgardius 2022-09-21 11:57:50 -07:00
parent 6729688096
commit 3682aaff4d
2 changed files with 14 additions and 2 deletions

View file

@ -12,6 +12,6 @@
</deviceKey> </deviceKey>
</Target> </Target>
</runningDeviceTargetSelectedWithDropDown> </runningDeviceTargetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2022-09-21T18:41:42.025960Z" /> <timeTargetWasSelectedWithDropDown value="2022-09-21T18:51:31.827117Z" />
</component> </component>
</project> </project>

View file

@ -35,11 +35,15 @@ public class ObjectInfo extends AppCompatActivity {
long totalSize = 0; long totalSize = 0;
int totalItems = 0; int totalItems = 0;
ListObjectsRequest orequest; ListObjectsRequest orequest;
long KiB, MiB, GiB;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_object_info); setContentView(R.layout.activity_object_info);
KiB = 1024;
MiB = 1024 * KiB;
GiB = 1024 * MiB;
simpleProgressBar = (ProgressBar) findViewById(R.id.simpleProgressBar); simpleProgressBar = (ProgressBar) findViewById(R.id.simpleProgressBar);
filesize = (TextView) findViewById(R.id.size); filesize = (TextView) findViewById(R.id.size);
filesizeinfo = (TextView) findViewById(R.id.size_info); filesizeinfo = (TextView) findViewById(R.id.size_info);
@ -103,7 +107,15 @@ public class ObjectInfo extends AppCompatActivity {
} else { } else {
filesizeinfo.setText(getResources().getString(R.string.bucket_size)); 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); simpleProgressBar.setVisibility(View.INVISIBLE);
} }
}); });