mirror of
https://github.com/revanced/Apktool.git
synced 2025-02-10 19:06:48 +01:00
add code style doc rules, adjusting stringblock to 120 margin
This commit is contained in:
parent
bdc18552d3
commit
94b90a6dd2
@ -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.
|
* [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.
|
* 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.
|
||||||
|
@ -62,8 +62,7 @@ public class StringBlock {
|
|||||||
int size = ((stylesOffset == 0) ? chunkSize : stylesOffset)
|
int size = ((stylesOffset == 0) ? chunkSize : stylesOffset)
|
||||||
- stringsOffset;
|
- stringsOffset;
|
||||||
if ((size % 4) != 0) {
|
if ((size % 4) != 0) {
|
||||||
throw new IOException("String data size is not multiple of 4 ("
|
throw new IOException("String data size is not multiple of 4 (" + size + ").");
|
||||||
+ size + ").");
|
|
||||||
}
|
}
|
||||||
block.m_strings = new byte[size];
|
block.m_strings = new byte[size];
|
||||||
reader.readFully(block.m_strings);
|
reader.readFully(block.m_strings);
|
||||||
@ -71,8 +70,7 @@ public class StringBlock {
|
|||||||
if (stylesOffset != 0) {
|
if (stylesOffset != 0) {
|
||||||
int size = (chunkSize - stylesOffset);
|
int size = (chunkSize - stylesOffset);
|
||||||
if ((size % 4) != 0) {
|
if ((size % 4) != 0) {
|
||||||
throw new IOException("Style data size is not multiple of 4 ("
|
throw new IOException("Style data size is not multiple of 4 (" + size + ").");
|
||||||
+ size + ").");
|
|
||||||
}
|
}
|
||||||
block.m_styles = reader.readIntArray(size / 4);
|
block.m_styles = reader.readIntArray(size / 4);
|
||||||
}
|
}
|
||||||
@ -151,16 +149,14 @@ public class StringBlock {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (offset <= end) {
|
if (offset <= end) {
|
||||||
html.append(ResXmlEncoders.escapeXmlChars(raw.substring(
|
html.append(ResXmlEncoders.escapeXmlChars(raw.substring(offset, end + 1)));
|
||||||
offset, end + 1)));
|
|
||||||
offset = end + 1;
|
offset = end + 1;
|
||||||
}
|
}
|
||||||
outputStyleTag(getString(style[last]), html, true);
|
outputStyleTag(getString(style[last]), html, true);
|
||||||
}
|
}
|
||||||
depth = j + 1;
|
depth = j + 1;
|
||||||
if (offset < start) {
|
if (offset < start) {
|
||||||
html.append(ResXmlEncoders.escapeXmlChars(raw.substring(offset,
|
html.append(ResXmlEncoders.escapeXmlChars(raw.substring(offset, start)));
|
||||||
start)));
|
|
||||||
offset = start;
|
offset = start;
|
||||||
}
|
}
|
||||||
if (i == -1) {
|
if (i == -1) {
|
||||||
@ -188,8 +184,7 @@ public class StringBlock {
|
|||||||
boolean loop = true;
|
boolean loop = true;
|
||||||
while (loop) {
|
while (loop) {
|
||||||
int pos2 = tag.indexOf('=', pos + 1);
|
int pos2 = tag.indexOf('=', pos + 1);
|
||||||
builder.append(' ').append(tag.substring(pos + 1, pos2))
|
builder.append(' ').append(tag.substring(pos + 1, pos2)).append("=\"");
|
||||||
.append("=\"");
|
|
||||||
pos = tag.indexOf(';', pos2 + 1);
|
pos = tag.indexOf(';', pos2 + 1);
|
||||||
|
|
||||||
String val;
|
String val;
|
||||||
@ -200,8 +195,7 @@ public class StringBlock {
|
|||||||
val = tag.substring(pos2 + 1);
|
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
|
* start index in string * third int is tag end index in string
|
||||||
*/
|
*/
|
||||||
private int[] getStyle(int index) {
|
private int[] getStyle(int index) {
|
||||||
if (m_styleOffsets == null || m_styles == null
|
if (m_styleOffsets == null || m_styles == null|| index >= m_styleOffsets.length) {
|
||||||
|| index >= m_styleOffsets.length) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
int offset = m_styleOffsets[index] / 4;
|
int offset = m_styleOffsets[index] / 4;
|
||||||
@ -335,12 +328,10 @@ public class StringBlock {
|
|||||||
private int[] m_styles;
|
private int[] m_styles;
|
||||||
private boolean m_isUTF8;
|
private boolean m_isUTF8;
|
||||||
private int[] m_stringOwns;
|
private int[] m_stringOwns;
|
||||||
private final CharsetDecoder UTF16LE_DECODER = Charset.forName(
|
|
||||||
"UTF-16LE").newDecoder();
|
private final CharsetDecoder UTF16LE_DECODER = Charset.forName("UTF-16LE").newDecoder();
|
||||||
private final CharsetDecoder UTF8_DECODER = Charset.forName("UTF-8")
|
private final CharsetDecoder UTF8_DECODER = Charset.forName("UTF-8").newDecoder();
|
||||||
.newDecoder();
|
private static final Logger LOGGER = Logger.getLogger(StringBlock.class.getName());
|
||||||
private static final Logger LOGGER = Logger.getLogger(StringBlock.class
|
|
||||||
.getName());
|
|
||||||
|
|
||||||
// ResChunk_header = header.type (0x0001) + header.headerSize (0x001C)
|
// ResChunk_header = header.type (0x0001) + header.headerSize (0x001C)
|
||||||
private static final int CHUNK_TYPE = 0x001C0001;
|
private static final int CHUNK_TYPE = 0x001C0001;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user