Add blob size to shared data dev options screens.

Bug: 156671006
Test: make RunSettingsRoboTests ROBOTEST_FILTER=SharedDataPreferenceControllerTest
Test: manual (visual)
Change-Id: Ia98c3d9812f6225ee834b4d1b0f12a1a73a87598
This commit is contained in:
Varun Shah
2020-06-05 21:47:29 -07:00
parent 03b20f864a
commit c920a58d5f
6 changed files with 19 additions and 1 deletions

View File

@@ -47,4 +47,11 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary"/> android:textColor="?android:attr/textColorSecondary"/>
<TextView
android:id="@+id/blob_size"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary"/>
</LinearLayout> </LinearLayout>

View File

@@ -158,6 +158,7 @@ public class BlobInfoListView extends ListActivity {
holder.blobId.setText(getString(R.string.blob_id_text, blob.getId())); holder.blobId.setText(getString(R.string.blob_id_text, blob.getId()));
holder.blobExpiry.setText(getString(R.string.blob_expires_text, holder.blobExpiry.setText(getString(R.string.blob_expires_text,
SharedDataUtils.formatTime(blob.getExpiryTimeMs()))); SharedDataUtils.formatTime(blob.getExpiryTimeMs())));
holder.blobSize.setText(SharedDataUtils.formatSize(blob.getSizeBytes()));
return convertView; return convertView;
} }
} }

View File

@@ -30,6 +30,7 @@ class BlobInfoViewHolder {
TextView blobLabel; TextView blobLabel;
TextView blobId; TextView blobId;
TextView blobExpiry; TextView blobExpiry;
TextView blobSize;
static BlobInfoViewHolder createOrRecycle(LayoutInflater inflater, View convertView) { static BlobInfoViewHolder createOrRecycle(LayoutInflater inflater, View convertView) {
if (convertView != null) { if (convertView != null) {
@@ -42,6 +43,7 @@ class BlobInfoViewHolder {
holder.blobLabel = convertView.findViewById(R.id.blob_label); holder.blobLabel = convertView.findViewById(R.id.blob_label);
holder.blobId = convertView.findViewById(R.id.blob_id); holder.blobId = convertView.findViewById(R.id.blob_id);
holder.blobExpiry = convertView.findViewById(R.id.blob_expiry); holder.blobExpiry = convertView.findViewById(R.id.blob_expiry);
holder.blobSize = convertView.findViewById(R.id.blob_size);
convertView.setTag(holder); convertView.setTag(holder);
return holder; return holder;
} }

View File

@@ -93,11 +93,13 @@ public class LeaseInfoListView extends ListActivity {
final TextView blobLabel = headerView.findViewById(R.id.blob_label); final TextView blobLabel = headerView.findViewById(R.id.blob_label);
final TextView blobId = headerView.findViewById(R.id.blob_id); final TextView blobId = headerView.findViewById(R.id.blob_id);
final TextView blobExpiry = headerView.findViewById(R.id.blob_expiry); final TextView blobExpiry = headerView.findViewById(R.id.blob_expiry);
final TextView blobSize = headerView.findViewById(R.id.blob_size);
blobLabel.setText(mBlobInfo.getLabel()); blobLabel.setText(mBlobInfo.getLabel());
blobLabel.setTypeface(Typeface.DEFAULT_BOLD); blobLabel.setTypeface(Typeface.DEFAULT_BOLD);
blobId.setText(getString(R.string.blob_id_text, mBlobInfo.getId())); blobId.setText(getString(R.string.blob_id_text, mBlobInfo.getId()));
blobExpiry.setVisibility(View.GONE); blobExpiry.setVisibility(View.GONE);
blobSize.setText(SharedDataUtils.formatSize(mBlobInfo.getSizeBytes()));
return headerView; return headerView;
} }

View File

@@ -39,4 +39,9 @@ class SharedDataUtils {
CALENDAR.setTimeInMillis(millis); CALENDAR.setTimeInMillis(millis);
return FORMATTER.format(CALENDAR.getTime()); return FORMATTER.format(CALENDAR.getTime());
} }
static String formatSize(long sizeBytes) {
final double sizeInMb = sizeBytes / (1024.0 * 1024.0);
return String.format("%.2f MB", sizeInMb);
}
} }

View File

@@ -113,7 +113,8 @@ public class SharedDataPreferenceControllerTest {
accessors.add(two); accessors.add(two);
final List<BlobInfo> tmp = new ArrayList<>(); final List<BlobInfo> tmp = new ArrayList<>();
tmp.add(new BlobInfo(10, System.currentTimeMillis(), "testing blob 1", accessors)); tmp.add(new BlobInfo(10, System.currentTimeMillis(), "testing blob 1", 54 * 1024 * 1024,
accessors));
return tmp; return tmp;
} }
} }