Skip to content

Commit

Permalink
add before plugin install hook
Browse files Browse the repository at this point in the history
  • Loading branch information
kadekParwanta committed Aug 4, 2023
1 parent f4e0f72 commit 355b20b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
35 changes: 35 additions & 0 deletions before_plugin_install.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
var fs = require("fs");
var path = require("path");
var rootdir = process.env.PWD;
var valuesPath = "/platforms/android/app/src/main/res/values/";
var themesFile = "themes.xml";
var destFile = path.join(rootdir, valuesPath, themesFile);
var destDir = path.dirname(destFile);

module.exports = function (context) {
console.log("*************************************");
console.log(`before_plugin_install running`);
console.log("*************************************");

if (fs.existsSync(destDir)) {
if (!fs.existsSync(destFile)) {
console.log("*************************************");
console.log(`creating new ${destFile}`);
console.log("*************************************");
fs.writeFile(
destFile,
'<?xml version="1.0" encoding="utf-8"?>\n<resources>\n<style name="MyTheme" parent="android:Theme.Holo.Light">\n</style>\n</resources>',
function (err) {
if (err) {
console.error("writeFile error" + err);
}
console.log(`${themesFile} created!`);
}
);
} else {
console.log(`skipping, file ${themesFile} exists`);
}
} else {
console.log("skipping, android platform not found");
}
};
3 changes: 2 additions & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@

<!-- android -->
<platform name="android">
<hook type="before_plugin_install" src="scripts/before_plugin_install.js" />
<edit-config file="AndroidManifest.xml" target="/manifest/application" mode="merge">
<application android:requestLegacyExternalStorage="true"/>
</edit-config>
Expand Down Expand Up @@ -140,7 +141,7 @@
<resource-file src="src/android/Library/res/layout/actionbar_done_button.xml" target="res/layout/actionbar_done_button.xml"/>
<resource-file src="src/android/Library/res/layout/multiselectorgrid.xml" target="res/layout/multiselectorgrid.xml"/>
<resource-file src="src/android/Library/res/values/multiimagechooser_strings_en.xml" target="res/values/multiimagechooser_strings_en.xml"/>
<resource-file src="src/android/Library/res/values/themes.xml" target="res/values/themes.xml"/>
<!-- <resource-file src="src/android/Library/res/values/themes.xml" target="res/values/themes.xml"/> -->

<resource-file src="src/android/Library/res/values-de/multiimagechooser_strings_de.xml" target="res/values-de/multiimagechooser_strings_de.xml"/>
<resource-file src="src/android/Library/res/values-es/multiimagechooser_strings_es.xml" target="res/values-es/multiimagechooser_strings_es.xml"/>
Expand Down

0 comments on commit 355b20b

Please sign in to comment.