use of android.widget.TableRow in project MifareClassicTool by ikarus23.
the class ValueBlocksToInt method addValueBlock.
/**
* Add full value block information (original
* and integer format) to the layout table (two rows).
* @param hexValueBlock The value block as hex string (32 chars.).
*/
private void addValueBlock(String hexValueBlock) {
TableRow tr = new TableRow(this);
TextView what = new TextView(this);
TextView value = new TextView(this);
// Original.
tr.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
what.setText(R.string.text_vb_orig);
value.setText(Common.colorString(hexValueBlock.substring(0, 8), getResources().getColor(R.color.yellow)));
tr.addView(what);
tr.addView(value);
mLayout.addView(tr, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
// Resolved to int.
tr = new TableRow(this);
tr.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
what = new TextView(this);
what.setText(R.string.text_vb_as_int_decoded);
value = new TextView(this);
byte[] asBytes = Common.hexStringToByteArray(hexValueBlock.substring(0, 8));
Common.reverseByteArrayInPlace(asBytes);
ByteBuffer bb = ByteBuffer.wrap(asBytes);
int i = bb.getInt();
String asInt = "" + i;
value.setText(Common.colorString(asInt, getResources().getColor(R.color.light_green)));
tr.addView(what);
tr.addView(value);
mLayout.addView(tr, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
}
use of android.widget.TableRow in project MifareClassicTool by ikarus23.
the class AccessConditionDecoder method addSectorTrailerAC.
/**
* Add full access condition information of the sector trailer (last block)
* to the table.
* @param acMatrix A matrix of access conditions bits as generated by
* {@link Common#acBytesToACMatrix(byte[])}.
* (Block0-Block2 + Sector Trailer, Index 0-3).
*/
private void addSectorTrailerAC(byte[][] acMatrix) {
byte c1 = acMatrix[0][3];
byte c2 = acMatrix[1][3];
byte c3 = acMatrix[2][3];
// Create rows.
TextView[] read = new TextView[3];
TextView[] write = new TextView[3];
for (int i = 0; i < 3; i++) {
read[i] = new TextView(this);
write[i] = new TextView(this);
}
// Set row texts to colored permissions.
read[0].setText(getColoredPermissionText(c1, c2, c3, Operations.ReadKeyA, true, false));
write[0].setText(getColoredPermissionText(c1, c2, c3, Operations.WriteKeyA, true, false));
read[1].setText(getColoredPermissionText(c1, c2, c3, Operations.ReadAC, true, false));
write[1].setText(getColoredPermissionText(c1, c2, c3, Operations.WriteAC, true, false));
read[2].setText(getColoredPermissionText(c1, c2, c3, Operations.ReadKeyB, true, false));
write[2].setText(getColoredPermissionText(c1, c2, c3, Operations.WriteKeyB, true, false));
// Add rows to layout.
String[] headers = new String[] { "Key A:", "AC Bits:", "Key B:" };
for (int i = 0; i < 3; i++) {
TableRow tr = new TableRow(this);
tr.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
TextView location = new TextView(this);
location.setText(headers[i]);
tr.addView(location);
tr.addView(read[i]);
tr.addView(write[i]);
mLayout.addView(tr, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
}
}
use of android.widget.TableRow 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));
}
}
use of android.widget.TableRow in project pictureapp by EyeSeeTea.
the class DynamicTabAdapter method showOrHideChildren.
/**
* Hide or show the childen question from a given question, if is necessary it reloads the
* children questions values or refreshing the children questions answer component
*
* this code will be delete when DynamicTabAdapter refactoring will be completed
*
* @param question is the parent question
*/
private void showOrHideChildren(Question question) {
if (!question.hasChildren()) {
return;
}
for (int i = 0, j = tableLayout.getChildCount(); i < j; i++) {
View view = tableLayout.getChildAt(i);
if (view instanceof TableRow) {
TableRow row = (TableRow) view;
View targetView = row.getChildAt(0);
if (targetView instanceof IMultiQuestionView || targetView instanceof IQuestionView) {
Question rowQuestion = (Question) targetView.getTag();
if (rowQuestion == null) {
continue;
}
List<Question> questionChildren = question.getChildren();
if (questionChildren != null && questionChildren.size() > 0) {
for (Question childQuestion : questionChildren) {
// if the table row question is child of the modified question...
toggleChild(row, rowQuestion, childQuestion);
}
}
}
}
}
}
use of android.widget.TableRow in project pictureapp by EyeSeeTea.
the class AQuestionAnswerChangedListener method showOrHideChildren.
/**
* Hide or show the children question from a given question, if is necessary it reloads the
* children questions values or refreshing the children questions answer component
*
* TODO: Duplicate code in DynamicTabAdapter line 1094
* code in DynamicTabAdapter will be delete when DynamicTabAdapter refactoring will be
* completed
*
* @param question is the parent question
*/
protected void showOrHideChildren(Question question) {
if (!question.hasChildren()) {
return;
}
for (int i = 0, j = mTableLayout.getChildCount(); i < j; i++) {
View view = mTableLayout.getChildAt(i);
if (view instanceof TableRow) {
TableRow row = (TableRow) view;
View answerView = view.findViewById(R.id.answer);
if (answerView == null) {
continue;
}
Question rowQuestion = (Question) answerView.getTag();
if (rowQuestion == null) {
continue;
}
List<Question> questionChildren = question.getChildren();
if (questionChildren != null && questionChildren.size() > 0) {
for (Question childQuestion : questionChildren) {
// if the table row question is child of the modified question...
toggleChild(row, rowQuestion, childQuestion);
}
}
}
}
}
Aggregations