From 1e112bc6efbd3d946672efcfea83de805d08caf6 Mon Sep 17 00:00:00 2001 From: Alexandros Schillings Date: Mon, 10 Mar 2014 18:45:45 +0000 Subject: [PATCH] Expanded the details screen --- .../btlescan/activities/DetailsActivity.java | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/src/uk/co/alt236/btlescan/activities/DetailsActivity.java b/src/uk/co/alt236/btlescan/activities/DetailsActivity.java index a66c805..8755539 100644 --- a/src/uk/co/alt236/btlescan/activities/DetailsActivity.java +++ b/src/uk/co/alt236/btlescan/activities/DetailsActivity.java @@ -19,6 +19,18 @@ public class DetailsActivity extends Activity{ private BluetoothLeDevice mDevice; + private void append(StringBuilder sb, byte[] value){ + append(sb, AdRecordUtils.byteArrayToHexString(value), null); + } + + private void append(StringBuilder sb, String label, String value){ + if(value != null){ + sb.append("\u2022" + label +":\t" + value + "\n"); + } else { + sb.append(label + "\n"); + } + } + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -43,6 +55,11 @@ public class DetailsActivity extends Activity{ append(sb, "Device Class", device.getBluetoothDeviceClassName()); append(sb, "Bonding State", device.getBluetoothDeviceBondState()); + append(sb, "", null); + append(sb, "Scan Record", null); + append(sb, "-----------------", null); + append(sb, device.getScanRecord()); + append(sb, "", null); append(sb, "Ad Records", null); append(sb, "-----------------", null); @@ -50,29 +67,13 @@ public class DetailsActivity extends Activity{ final Collection adRecords = device.getAdRecordStore().getRecordsAsCollection(); - for(AdRecord record : adRecords){ - append(sb, - "Record Id'" +record.getType()+ "' - " + record.getHumanReadableType(), AdRecordUtils.getRecordDataAsString(record)); + for(final AdRecord record : adRecords){ + append(sb, "#" +record.getType() + " " + record.getHumanReadableType(), null); + append(sb, AdRecordUtils.getRecordDataAsString(record), null); + append(sb, "", null); } } mTvDetails.setText(sb.toString()); } - - - private void append(StringBuilder sb, String label, boolean value){ - append(sb, label, String.valueOf(value)); - } - - private void append(StringBuilder sb, String label, long value){ - append(sb, label, String.valueOf(value)); - } - - private void append(StringBuilder sb, String label, String value){ - if(value != null){ - sb.append("#" + label +":\t" + value + "\n"); - } else { - sb.append(label + "\n"); - } - } }