Skip to content

Commit

Permalink
[AAPT] Rename dollar prefix resource names - 2 REAndroid/APKEditor#51
Browse files Browse the repository at this point in the history
  • Loading branch information
REAndroid committed Aug 2, 2024
1 parent 5c208ac commit f7681c3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/main/java/com/reandroid/identifiers/Identifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.reandroid.identifiers;

import com.reandroid.arsc.coder.xml.XmlCoder;
import com.reandroid.utils.HexUtil;

import java.io.File;
Expand Down Expand Up @@ -89,6 +90,10 @@ public String toString(){
return getName() + "(" + getHexId() + ")";
}

public static boolean isAapt() {
// TODO: make separate setting
return XmlCoder.getInstance().getSetting().isAapt();
}
static final String XML_TAG_RESOURCES = "resources";
static final String XML_TAG_PUBLIC = "public";

Expand Down
15 changes: 14 additions & 1 deletion src/main/java/com/reandroid/identifiers/ResourceIdentifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,24 @@ public boolean renameSpecGenerated(){
}
public boolean renameBadSpec(){
if(hasGoodName()){
return false;
return renameDollarPrefix();
}
setName(generateUniqueName());
return renameSpec();
}
public boolean renameDollarPrefix(){
if(!Identifier.isAapt()) {
return false;
}
String name = getName();
if(name.charAt(0) != '$'){
return false;
}
name = name.substring(1);

setName(name);
return renameSpec();
}
public boolean renameSpec(){
PackageBlock packageBlock = getPackageBlock();
if(packageBlock == null){
Expand Down

0 comments on commit f7681c3

Please sign in to comment.