======= android ======= .. module:: android .. function:: setViewModel(data[, sessionId = "0"]) Imports to be used for layout bindings associated by session. :param object data: See |AppViewModel| :param string sessionId: (optional) Names a session to be used for storage Usage:: squared.parseDocument(() => { android.setViewModel( { import: ["java.util.Map"], variable: [{ name: "map", type: "Map<String, String>" }] }, squared.latest() ); }); .. function:: setViewModelByProject(data[, projectId = "_"]) Imports to be used for layout bindings associated by project. :param object data: See |AppViewModel| :param string projectId: (optional) |projectId| Usage:: android.setViewModelByProject( { import: ["java.util.Map"], variable: [{ name: "map", type: "Map<String, String>" }] }, "project-1" ); await squared.parseDocument({ element: document.body, projectId: "project-1" }); .. function:: addDependency(group, name[, version, type]) Include a dependency by group and name to an existing or newly created ``build.gradle``. Uses the default project "_" for storage. Any existing dependency with the same group and name will be overwritten. :param string group: Namespace of library :param string name: Componenent name in library :param string version: (:sub:`optional (type)`) Exact version requested :param number type: (optional) Dependency namespace method in Gradle :returns: string :requirements: - **createBuildDependencies** = *true* Usage:: android.addDependency("androidx.core", "core", "1.12.0"); // Default is "implementation" squared.copyTo("/path/project", { dependencyScopes: true }); // Will also include first-level sub-dependencies (optional) Alternate:: android.addDependency("androidx.core", "core", DEPENDENCY_TYPE.COMPILE_ONLY, true); // Uses latest Maven published release squared.copyTo("/path/project", { dependencyScopes: "snapshot" }); .. function:: addDependencyByProject(projectId, group, name[, version, type]) Include a dependency to a project by group and name of an existing or newly created ``build.gradle``. Any existing dependency in the project with the same group and name will be overwritten. :param string projectId: |projectId| :param string group: Namespace of library :param string name: Componenent name in library :param string version: (:sub:`optional (type)`) Exact version requested :param number type: (optional) Dependency namespace method in Gradle :returns: string :requirements: - **createBuildDependencies** = *true* Usage:: android.addDependencyByProject("project-1", "androidx.core", "core", "1.12.0"); // Default is "implementation" squared.copyTo("/path/project", { projectId: "project-1", dependencyScopes: true }); // Will also include first-level sub-dependencies (optional) Alternate:: android.addDependencyByProject("project-1", "androidx.core", "core", DEPENDENCY_TYPE.COMPILE_ONLY, true); // Uses latest Maven published release squared.copyTo("/path/project", { projectId: "project-1", dependencyScopes: "snapshot" }); .. function:: addFontProvider(authority, package, certs, webFonts) Add additional `Web fonts `_ that can be searched for when resolving first available font family. `Google Fonts `_ is already included. :param string authority: Class of font provider library :param string package: Namespace of font provider :param array certs: List of certificates the font provider is signed with :param string webFonts: Web font service URL :returns: boolean | Promise :requirements: - **targetAPI** >= *26* - **createDownloadableFonts** = *true* Usage:: await android.addFontProvider( "com.google.android.gms.fonts", "com.google.android.gms", ["MIIEqDCCA5CgAwIBAgIJANWFuGx9007...", "MIIEQzCCAyugAwIBAgIJAMLgh0Zk..."], "https://www.googleapis.com/webfonts/v1/webfonts?key=1234567890" // Pre-built JSON object is synchronous ); .. function:: addXmlNs(name, uri) Aliases of global namespaces for third-party controls used when resolving layout attributes. :param string name: Prefix to be used with attribute :param string uri: Full URL namespace of schema Usage:: android.addXmlNs("tools", "http://schemas.android.com/tools"); // https://developer.android.com/studio/write/tool-attributes android.customize(16 /* Jelly Bean */, "ImageView", { tools: { ignore: "ContentDescription", targetApi: "16" } }); Output: .. code-block:: xml .. function:: customize(api, widget, options) Global attributes to be applied to every qualifying layout control possibly overwriting any auto-generated attributes. :param number api: Android SDK build API version :param string widget: Namespace of layout control :param object options: Attributes to be applied to control :returns: Record | undefined :requirements: - **customizationsBaseAPI** >= *0* - **customizationsOverwritePrivilege** = *true* Usage:: android.customize(BUILD_VERSION.ALL /* 0 */, "Button", { android: { minWidth: "35px", minHeight: "25px" }, "_": { // Non-namespaced attributes style: "@style/Widget.Material3.Button.TextButton" } }); Output: .. code-block:: xml