use of android.widget.TableLayout.LayoutParams in project MifareClassicTool by ikarus23.
the class AccessConditionDecoder method addBlockAC.
/**
* Add full access condition information of the 3 data blocks to the table.
* @param acMatrix A matrix of access conditions bits as generated by
* {@link Common#acBytesToACMatrix(byte[])}.
* @param hasMoreThan4Blocks True for the last 8 sectors
* of a MIFARE Classic 4K tag, False otherwise.
*/
private void addBlockAC(byte[][] acMatrix, boolean hasMoreThan4Blocks) {
boolean isKeyBReadable = Common.isKeyBReadable(acMatrix[0][3], acMatrix[1][3], acMatrix[2][3]);
for (int i = 0; i < 3; i++) {
byte c1 = acMatrix[0][i];
byte c2 = acMatrix[1][i];
byte c3 = acMatrix[2][i];
// Create row and header.
TableRow tr = new TableRow(this);
String blockHeader;
if (hasMoreThan4Blocks) {
blockHeader = getString(R.string.text_block) + ": " + (i * 4 + i) + "-" + (i * 4 + 4 + i);
} else {
blockHeader = getString(R.string.text_block) + ": " + i;
}
tr.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
// Create cells.
TextView location = new TextView(this);
location.setText(blockHeader);
TextView read = new TextView(this);
TextView write = new TextView(this);
TextView incr = new TextView(this);
TextView decr = new TextView(this);
// Set cell texts to colored permissions.
read.setText(getColoredPermissionText(c1, c2, c3, Operations.Read, false, isKeyBReadable));
write.setText(getColoredPermissionText(c1, c2, c3, Operations.Write, false, isKeyBReadable));
incr.setText(getColoredPermissionText(c1, c2, c3, Operations.Increment, false, isKeyBReadable));
decr.setText(getColoredPermissionText(c1, c2, c3, Operations.DecTransRest, false, isKeyBReadable));
// Add cells to row.
tr.addView(location);
tr.addView(read);
tr.addView(write);
tr.addView(incr);
tr.addView(decr);
// Add row to layout.
mLayout.addView(tr, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
}
}
Aggregations