Search in sources :

Example 1 with LayoutParams

use of android.widget.TableLayout.LayoutParams in project MifareClassicTool by ikarus23.

the class ValueBlocksToInt method addPosInfoRow.

/**
 * Add a row with position information to the layout table.
 * This row shows the user where the value block is located (sector, block).
 * @param value The position information (e.g. "Sector: 1, Block: 2").
 */
private void addPosInfoRow(String value) {
    TextView header = new TextView(this);
    header.setText(Common.colorString(value, getResources().getColor(R.color.blue)), BufferType.SPANNABLE);
    TableRow tr = new TableRow(this);
    tr.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    tr.addView(header);
    mLayout.addView(tr, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
}
Also used : LayoutParams(android.widget.TableLayout.LayoutParams) TableRow(android.widget.TableRow) TextView(android.widget.TextView)

Example 2 with LayoutParams

use of android.widget.TableLayout.LayoutParams in project MifareClassicTool by ikarus23.

the class AccessConditionDecoder method addSectorAC.

/**
 * Add full access condition information about one sector to the layout
 * table. (This method will trigger
 * {@link #addBlockAC(byte[][], boolean)} and
 * {@link #addSectorTrailerAC(byte[][])}
 * @param acMatrix Matrix of access conditions bits (C1-C3) where the first
 * dimension is the "C" parameter (C1-C3, Index 0-2) and the second
 * dimension is the block number
 * (Block0-Block2 + Sector Trailer, Index 0-3).
 * @param sectorHeader The sector header to display (e.g. "Sector: 0").
 * @param hasMoreThan4Blocks True for the last 8 sectors
 * of a MIFARE Classic 4K tag.
 * @see #addBlockAC(byte[][], boolean)
 * @see #addSectorTrailerAC(byte[][])
 */
private void addSectorAC(byte[][] acMatrix, String sectorHeader, boolean hasMoreThan4Blocks) {
    // Add sector header.
    TextView header = new TextView(this);
    header.setText(Common.colorString(sectorHeader, getResources().getColor(R.color.blue)), BufferType.SPANNABLE);
    TableRow tr = new TableRow(this);
    tr.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    tr.addView(header);
    mLayout.addView(tr, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    // Add Block 0-2.
    addBlockAC(acMatrix, hasMoreThan4Blocks);
    // Add Sector Trailer.
    addSectorTrailerAC(acMatrix);
}
Also used : LayoutParams(android.widget.TableLayout.LayoutParams) TableRow(android.widget.TableRow) TextView(android.widget.TextView)

Example 3 with LayoutParams

use of android.widget.TableLayout.LayoutParams in project MarkyMark-Android by M2Mobi.

the class ListDisplayItem method createLayout.

private LinearLayout createLayout(final MarkDownList pMarkDownItem, final InlineConverter<Spanned> pInlineConverter) {
    LinearLayout layout = new LinearLayout(mContext);
    layout.setLayoutParams(new LayoutParams(MATCH_PARENT, WRAP_CONTENT));
    layout.setOrientation(LinearLayout.VERTICAL);
    final List<ListItem> items = pMarkDownItem.getListItems();
    for (int i = 0; i < items.size(); i++) {
        final ListItem item = items.get(i);
        final View view = getTextView(pMarkDownItem, pInlineConverter.convert(item.getText()), i);
        layout.addView(view);
        if (item.hasChild()) {
            for (MarkDownList list : item.getChild()) {
                final LinearLayout nestedLayout = createLayout(list, pInlineConverter);
                LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
                params.setMargins(mIndentationSpacingPixels, 0, 0, 0);
                nestedLayout.setLayoutParams(params);
                layout.addView(nestedLayout);
            }
        }
    }
    return layout;
}
Also used : LayoutParams(android.widget.TableLayout.LayoutParams) MarkDownList(com.m2mobi.markymarkcommon.markdownitems.MarkDownList) ListItem(com.m2mobi.markymarkcommon.markdownitems.ListItem) TextView(android.widget.TextView) View(android.view.View) LinearLayout(android.widget.LinearLayout)

Example 4 with LayoutParams

use of android.widget.TableLayout.LayoutParams 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));
}
Also used : LayoutParams(android.widget.TableLayout.LayoutParams) TableRow(android.widget.TableRow) TextView(android.widget.TextView) ByteBuffer(java.nio.ByteBuffer)

Example 5 with LayoutParams

use of android.widget.TableLayout.LayoutParams 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));
    }
}
Also used : LayoutParams(android.widget.TableLayout.LayoutParams) TableRow(android.widget.TableRow) TextView(android.widget.TextView) SpannableString(android.text.SpannableString)

Aggregations

LayoutParams (android.widget.TableLayout.LayoutParams)6 TextView (android.widget.TextView)6 TableRow (android.widget.TableRow)5 SpannableString (android.text.SpannableString)2 View (android.view.View)1 LinearLayout (android.widget.LinearLayout)1 ListItem (com.m2mobi.markymarkcommon.markdownitems.ListItem)1 MarkDownList (com.m2mobi.markymarkcommon.markdownitems.MarkDownList)1 ByteBuffer (java.nio.ByteBuffer)1