@Override protected String encodeAsResXml() throws AndrolibException { if (isNull()) { return "@null"; } ResResSpec spec = getReferent(); if (spec == null) { return "@null"; } boolean newId = spec.hasDefaultResource() && spec.getDefaultResource().getValue() instanceof ResIdValue; // generate the beginning to fix @android String mStart = (mTheme ? '?' : '@') + (newId ? "+" : ""); return mStart + spec.getFullName(mPackage, mTheme && spec.getType().getName().equals("attr")); }
public void removeResSpec(ResResSpec spec) throws AndrolibException { mResSpecs.remove(spec.getId()); }
public void addResource(ResResource res) throws AndrolibException { addResource(res, false); }
public String getFullName(ResPackage relativeToPackage, boolean excludeType) { return getFullName(getPackage().equals(relativeToPackage), excludeType); }
public String getFullName(boolean excludePackage, boolean excludeType) { return (excludePackage ? "" : getPackage().getName() + ":") + (excludeType ? "" : getType().getName() + "/") + getName(); }
ResResource res) throws IOException, AndrolibException { serializer.startTag(null, "style"); serializer.attribute(null, "name", res.getResSpec().getName()); if (!mParent.isNull() && !mParent.referentIsNull()) { serializer.attribute(null, "parent", mParent.encodeAsResXmlAttr()); } else if (res.getResSpec().getName().indexOf('.') != -1) { serializer.attribute(null, "parent", ""); String value = null; ResValue resource = spec.getDefaultResource().getValue(); if (resource instanceof ResReferenceValue) { continue; ResAttr attr = (ResAttr) resource; value = attr.convertToResXmlFormat(mItems[i].m2); name = spec.getFullName(res.getResSpec().getPackage(), true); } else { name = "@" + spec.getFullName(res.getResSpec().getPackage(), false);
private void generatePublicXml(ResPackage pkg, Directory out, XmlSerializer serial) throws AndrolibException { try { OutputStream outStream = out.getFileOutput("values/public.xml"); serial.setOutput(outStream, null); serial.startDocument(null, null); serial.startTag(null, "resources"); for (ResResSpec spec : pkg.listResSpecs()) { serial.startTag(null, "public"); serial.attribute(null, "type", spec.getType().getName()); serial.attribute(null, "name", spec.getName()); serial.attribute(null, "id", String.format("0x%08x", spec.getId().id)); serial.endTag(null, "public"); } serial.endTag(null, "resources"); serial.endDocument(); serial.flush(); outStream.close(); } catch (IOException | DirectoryException ex) { throw new AndrolibException("Could not generate public.xml file", ex); } }
spec = mPkg.getResSpec(resId); if (spec.isDummyResSpec()) { removeResSpec(spec); spec = new ResResSpec(resId, mSpecNames.getString(specNamesId), mPkg, mTypeSpec); mPkg.addResSpec(spec); mTypeSpec.addResSpec(spec); spec = new ResResSpec(resId, mSpecNames.getString(specNamesId), mPkg, mTypeSpec); mPkg.addResSpec(spec); mTypeSpec.addResSpec(spec); spec.addResource(res); } catch (AndrolibException ex) { if (mKeepBroken) { mType.addResource(res, true); spec.addResource(res, true); LOGGER.warning(String.format("Duplicate Resource Detected. Ignoring duplicate: %s", res.toString())); } else {
public void removeResSpec(ResResSpec spec) throws AndrolibException { mResSpecs.remove(spec.getName()); }
public String getFullName() { return getFullName(false, false); }
public Collection<ResValuesFile> listValuesFiles() { Map<Duo<ResTypeSpec, ResType>, ResValuesFile> ret = new HashMap<Duo<ResTypeSpec, ResType>, ResValuesFile>(); for (ResResSpec spec : mResSpecs.values()) { for (ResResource res : spec.listResources()) { if (res.getValue() instanceof ResValuesXmlSerializable) { ResTypeSpec type = res.getResSpec().getType(); ResType config = res.getConfig(); Duo<ResTypeSpec, ResType> key = new Duo<ResTypeSpec, ResType>(type, config); ResValuesFile values = ret.get(key); if (values == null) { values = new ResValuesFile(this, type, config); ret.put(key, values); } values.addResource(res); } } } return ret.values(); }
private void addMissingResSpecs() throws AndrolibException { int resId = mResId & 0xffff0000; for (int i = 0; i < mMissingResSpecs.length; i++) { if (!mMissingResSpecs[i]) { continue; } ResResSpec spec = new ResResSpec(new ResID(resId | i), "APKTOOL_DUMMY_" + Integer.toHexString(i), mPkg, mTypeSpec); // If we already have this resID dont add it again. if (! mPkg.hasResSpec(new ResID(resId | i))) { mPkg.addResSpec(spec); mTypeSpec.addResSpec(spec); if (mType == null) { mType = mPkg.getOrCreateConfig(new ResConfigFlags()); } ResValue value = new ResBoolValue(false, 0, null); ResResource res = new ResResource(mType, spec, value); mPkg.addResource(res); mType.addResource(res); spec.addResource(res); } } }
public ResResource getDefaultResource() throws AndrolibException { return getResource(new ResConfigFlags()); }
public ResValue getValue(String package_, String type, String name) throws AndrolibException { return getPackage(package_).getType(type).getResSpec(name).getDefaultResource().getValue(); }
String inFileName = fileValue.getStrippedPath(); String outResName = res.getFilePath(); String typeName = res.getResSpec().getType().getName();
@Override public void serializeToResValuesXml(XmlSerializer serializer, ResResource res) throws IOException, AndrolibException { serializer.startTag(null, "item"); serializer .attribute(null, "type", res.getResSpec().getType().getName()); serializer.attribute(null, "name", res.getResSpec().getName()); serializer.endTag(null, "item"); } }
public boolean isDummyResSpec() { return getName().startsWith("APKTOOL_DUMMY_"); }
ResResSpec spec = resTable.getResSpec(resID); out.println(String.format(RES_NAME_FORMAT, spec.getFullName())); } catch (UndefinedResObject ex) { if (!R_FILE_PATTERN.matcher(fileName).matches()) {
public ResResource getResource(ResType config) throws AndrolibException { return getResource(config.getFlags()); }