Tabnine Logo
ResXmlPatcher.loadDocument
Code IndexAdd Tabnine to your IDE (free)

How to use
loadDocument
method
in
brut.androlib.res.xml.ResXmlPatcher

Best Java code snippets using brut.androlib.res.xml.ResXmlPatcher.loadDocument (Showing top 5 results out of 315)

origin: iBotPeaches/Apktool

/**
 * Finds key in strings.xml file and returns text value
 *
 * @param directory Root directory of apk
 * @param key String reference (ie @string/foo)
 * @return String|null
 * @throws AndrolibException
 */
public static String pullValueFromStrings(File directory, String key) throws AndrolibException {
  if (key == null || ! key.contains("@")) {
    return null;
  }
  File file = new File(directory, "/res/values/strings.xml");
  key = key.replace("@string/", "");
  if (file.exists()) {
    try {
      Document doc = loadDocument(file);
      XPath xPath = XPathFactory.newInstance().newXPath();
      XPathExpression expression = xPath.compile("/resources/string[@name=" + '"' + key + "\"]/text()");
      Object result = expression.evaluate(doc, XPathConstants.STRING);
      if (result != null) {
        return (String) result;
      }
    }  catch (SAXException | ParserConfigurationException | IOException | XPathExpressionException ignored) {
    }
  }
  return null;
}
origin: iBotPeaches/Apktool

/**
 * Replaces package value with passed packageOriginal string
 *
 * @param file File for AndroidManifest.xml
 * @param packageOriginal Package name to replace
 * @throws AndrolibException
 */
public static void renameManifestPackage(File file, String packageOriginal) throws AndrolibException {
  try {
    Document doc = loadDocument(file);
    // Get the manifest line
    Node manifest = doc.getFirstChild();
    // update package attribute
    NamedNodeMap attr = manifest.getAttributes();
    Node nodeAttr = attr.getNamedItem("package");
    nodeAttr.setNodeValue(packageOriginal);
    saveDocument(file, doc);
  } catch (SAXException | ParserConfigurationException | IOException | TransformerException ignored) {
  }
}
origin: iBotPeaches/Apktool

/**
 * Removes "debug" tag from file
 *
 * @param file AndroidManifest file
 * @throws AndrolibException
 */
public static void removeApplicationDebugTag(File file) throws AndrolibException {
  if (file.exists()) {
    try {
      Document doc = loadDocument(file);
      Node application = doc.getElementsByTagName("application").item(0);
      // load attr
      NamedNodeMap attr = application.getAttributes();
      Node debugAttr = attr.getNamedItem("android:debuggable");
      // remove application:debuggable
      if (debugAttr != null) {
        attr.removeNamedItem("android:debuggable");
      }
      saveDocument(file, doc);
    } catch (SAXException | ParserConfigurationException | IOException | TransformerException ignored) {
    }
  }
}
origin: iBotPeaches/Apktool

/**
 * Removes attributes like "versionCode" and "versionName" from file.
 *
 * @param file File representing AndroidManifest.xml
 * @throws AndrolibException
 */
public static void removeManifestVersions(File file) throws AndrolibException {
  if (file.exists()) {
    try {
      Document doc = loadDocument(file);
      Node manifest = doc.getFirstChild();
      NamedNodeMap attr = manifest.getAttributes();
      Node vCode = attr.getNamedItem("android:versionCode");
      Node vName = attr.getNamedItem("android:versionName");
      if (vCode != null) {
        attr.removeNamedItem("android:versionCode");
      }
      if (vName != null) {
        attr.removeNamedItem("android:versionName");
      }
      saveDocument(file, doc);
    } catch (SAXException | ParserConfigurationException | IOException | TransformerException ignored) {
    }
  }
}
origin: iBotPeaches/Apktool

if (file.exists()) {
  try {
    Document doc = loadDocument(file);
    XPath xPath = XPathFactory.newInstance().newXPath();
    XPathExpression expression = xPath.compile("/manifest/application/provider");
brut.androlib.res.xmlResXmlPatcherloadDocument

Popular methods of ResXmlPatcher

  • pullValueFromStrings
    Finds key in strings.xml file and returns text value
  • fixingPublicAttrsInProviderAttributes
    Any @string reference in a value in AndroidManifest.xml will break on build, thus preventing the app
  • isSaved
    Checks if the replacement was properly made to a node.
  • removeApplicationDebugTag
    Removes "debug" tag from file
  • removeManifestVersions
    Removes attributes like "versionCode" and "versionName" from file.
  • renameManifestPackage
    Replaces package value with passed packageOriginal string
  • saveDocument

Popular in Java

  • Making http post requests using okhttp
  • scheduleAtFixedRate (ScheduledExecutorService)
  • onRequestPermissionsResult (Fragment)
  • startActivity (Activity)
  • VirtualMachine (com.sun.tools.attach)
    A Java virtual machine. A VirtualMachine represents a Java virtual machine to which this Java vir
  • String (java.lang)
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
  • JComboBox (javax.swing)
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now