From 94b90a6dd299ede635b4f3c47b21c31bdf8f2d9c Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Sun, 9 Feb 2014 19:23:25 -0600 Subject: [PATCH] add code style doc rules, adjusting stringblock to 120 margin --- CONTRIBUTING.md | 10 ++++-- .../androlib/res/decoder/StringBlock.java | 31 +++++++------------ 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b4cece56..16b68a09 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -11,8 +11,12 @@ A couple of quick tips to ease the submission process. * [Building](http://code.google.com/p/android-apktool/wiki/BuildApktool) via Gradle will automatically run unit-tests. The build will end if any test fails. - * A tab counts as 4 spaces and we use 4 spaces. - - * [IntelliJ IDEA](http://www.jetbrains.com/idea/) is our IDE of choice. It has built in debugger support along with Gradle integration + * [IntelliJ IDEA](http://www.jetbrains.com/idea/) is our IDE of choice. It has built in debugger support along with Gradle integration. * For changes to smali/baksmali please see their [page](http://code.google.com/p/smali/) for more information. + + +## Code Styles + * A rough guideline based on [AOSP Guidelines](https://source.android.com/source/code-style.html). + * A tab counts as 4 spaces and we use 4 spaces. + * Our right margin is 120 characters long. diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/StringBlock.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/StringBlock.java index 887a5f8b..ebe18d72 100644 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/StringBlock.java +++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/StringBlock.java @@ -62,8 +62,7 @@ public class StringBlock { int size = ((stylesOffset == 0) ? chunkSize : stylesOffset) - stringsOffset; if ((size % 4) != 0) { - throw new IOException("String data size is not multiple of 4 (" - + size + ")."); + throw new IOException("String data size is not multiple of 4 (" + size + ")."); } block.m_strings = new byte[size]; reader.readFully(block.m_strings); @@ -71,8 +70,7 @@ public class StringBlock { if (stylesOffset != 0) { int size = (chunkSize - stylesOffset); if ((size % 4) != 0) { - throw new IOException("Style data size is not multiple of 4 (" - + size + ")."); + throw new IOException("Style data size is not multiple of 4 (" + size + ")."); } block.m_styles = reader.readIntArray(size / 4); } @@ -151,16 +149,14 @@ public class StringBlock { break; } if (offset <= end) { - html.append(ResXmlEncoders.escapeXmlChars(raw.substring( - offset, end + 1))); + html.append(ResXmlEncoders.escapeXmlChars(raw.substring(offset, end + 1))); offset = end + 1; } outputStyleTag(getString(style[last]), html, true); } depth = j + 1; if (offset < start) { - html.append(ResXmlEncoders.escapeXmlChars(raw.substring(offset, - start))); + html.append(ResXmlEncoders.escapeXmlChars(raw.substring(offset, start))); offset = start; } if (i == -1) { @@ -188,8 +184,7 @@ public class StringBlock { boolean loop = true; while (loop) { int pos2 = tag.indexOf('=', pos + 1); - builder.append(' ').append(tag.substring(pos + 1, pos2)) - .append("=\""); + builder.append(' ').append(tag.substring(pos + 1, pos2)).append("=\""); pos = tag.indexOf(';', pos2 + 1); String val; @@ -200,8 +195,7 @@ public class StringBlock { val = tag.substring(pos2 + 1); } - builder.append(ResXmlEncoders.escapeXmlChars(val)).append( - '"'); + builder.append(ResXmlEncoders.escapeXmlChars(val)).append('"'); } } } @@ -245,8 +239,7 @@ public class StringBlock { * start index in string * third int is tag end index in string */ private int[] getStyle(int index) { - if (m_styleOffsets == null || m_styles == null - || index >= m_styleOffsets.length) { + if (m_styleOffsets == null || m_styles == null|| index >= m_styleOffsets.length) { return null; } int offset = m_styleOffsets[index] / 4; @@ -335,12 +328,10 @@ public class StringBlock { private int[] m_styles; private boolean m_isUTF8; private int[] m_stringOwns; - private final CharsetDecoder UTF16LE_DECODER = Charset.forName( - "UTF-16LE").newDecoder(); - private final CharsetDecoder UTF8_DECODER = Charset.forName("UTF-8") - .newDecoder(); - private static final Logger LOGGER = Logger.getLogger(StringBlock.class - .getName()); + + private final CharsetDecoder UTF16LE_DECODER = Charset.forName("UTF-16LE").newDecoder(); + private final CharsetDecoder UTF8_DECODER = Charset.forName("UTF-8").newDecoder(); + private static final Logger LOGGER = Logger.getLogger(StringBlock.class.getName()); // ResChunk_header = header.type (0x0001) + header.headerSize (0x001C) private static final int CHUNK_TYPE = 0x001C0001;