-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new unknown resource id encoding #18
- Loading branch information
Showing
5 changed files
with
154 additions
and
91 deletions.
There are no files selected for viewing
90 changes: 0 additions & 90 deletions
90
src/main/java/com/reandroid/apk/xmlencoder/XMLEncodeSource.java
This file was deleted.
Oops, something went wrong.
51 changes: 51 additions & 0 deletions
51
src/main/java/com/reandroid/arsc/coder/CoderUnknownAttributeId.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright (C) 2022 github.com/REAndroid | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.reandroid.arsc.coder; | ||
|
||
import com.reandroid.arsc.value.ValueType; | ||
import com.reandroid.utils.HexUtil; | ||
|
||
public class CoderUnknownAttributeId extends Coder{ | ||
@Override | ||
public EncodeResult encode(String text) { | ||
if(text == null || text.length() != LENGTH || !text.startsWith(PREFIX)){ | ||
return null; | ||
} | ||
Integer value = parseHex(text.substring(1)); | ||
if(value != null){ | ||
return new EncodeResult(getValueType(), value); | ||
} | ||
return null; | ||
} | ||
@Override | ||
public String decode(int data) { | ||
return HexUtil.toHex8(PREFIX, data); | ||
} | ||
@Override | ||
public ValueType getValueType() { | ||
return ValueType.ATTRIBUTE; | ||
} | ||
@Override | ||
boolean canStartWith(char first) { | ||
return first == PREFIX_CHAR; | ||
} | ||
|
||
public static final CoderUnknownAttributeId INS = new CoderUnknownAttributeId(); | ||
|
||
private static final char PREFIX_CHAR = '?'; | ||
private static final String PREFIX = "?0x"; | ||
private static final int LENGTH = 3 + 8; | ||
} |
51 changes: 51 additions & 0 deletions
51
src/main/java/com/reandroid/arsc/coder/CoderUnknownNameId.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright (C) 2022 github.com/REAndroid | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.reandroid.arsc.coder; | ||
|
||
import com.reandroid.arsc.value.ValueType; | ||
import com.reandroid.utils.HexUtil; | ||
|
||
public class CoderUnknownNameId extends Coder{ | ||
@Override | ||
public EncodeResult encode(String text) { | ||
if(text == null || text.length() != LENGTH || !text.startsWith(PREFIX)){ | ||
return null; | ||
} | ||
Integer value = parseHex(text.substring(1)); | ||
if(value != null){ | ||
return new EncodeResult(getValueType(), value); | ||
} | ||
return null; | ||
} | ||
@Override | ||
public String decode(int data) { | ||
return HexUtil.toHex8(PREFIX, data); | ||
} | ||
@Override | ||
public ValueType getValueType() { | ||
return ValueType.REFERENCE; | ||
} | ||
@Override | ||
boolean canStartWith(char first) { | ||
return first == PREFIX_CHAR; | ||
} | ||
|
||
public static final CoderUnknownNameId INS = new CoderUnknownNameId(); | ||
|
||
private static final char PREFIX_CHAR = 'r'; | ||
private static final String PREFIX = "r0x"; | ||
private static final int LENGTH = 3 + 8; | ||
} |
51 changes: 51 additions & 0 deletions
51
src/main/java/com/reandroid/arsc/coder/CoderUnknownReferenceId.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright (C) 2022 github.com/REAndroid | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.reandroid.arsc.coder; | ||
|
||
import com.reandroid.arsc.value.ValueType; | ||
import com.reandroid.utils.HexUtil; | ||
|
||
public class CoderUnknownReferenceId extends Coder{ | ||
@Override | ||
public EncodeResult encode(String text) { | ||
if(text == null || text.length() != LENGTH || !text.startsWith(PREFIX)){ | ||
return null; | ||
} | ||
Integer value = parseHex(text.substring(1)); | ||
if(value != null){ | ||
return new EncodeResult(getValueType(), value); | ||
} | ||
return null; | ||
} | ||
@Override | ||
public String decode(int data) { | ||
return HexUtil.toHex8(PREFIX, data); | ||
} | ||
@Override | ||
public ValueType getValueType() { | ||
return ValueType.REFERENCE; | ||
} | ||
@Override | ||
boolean canStartWith(char first) { | ||
return first == PREFIX_CHAR; | ||
} | ||
|
||
public static final CoderUnknownReferenceId INS = new CoderUnknownReferenceId(); | ||
|
||
private static final char PREFIX_CHAR = '@'; | ||
private static final String PREFIX = "@0x"; | ||
private static final int LENGTH = 3 + 8; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters