Skip to content

Commit 11d8758

Browse files
authored
Merge pull request #200 from Resgrid/develop
RU-T46 Native PPT Android fix
2 parents 5c7c8de + fe3f24c commit 11d8758

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

plugins/withMediaButtonModule.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,18 @@ const withMediaButtonModule = (config) => {
481481

482482
// Check if MediaButtonPackage is already imported/added
483483
if (!mainApplication.contents.includes('MediaButtonPackage')) {
484+
// Get the package name from the first line of the file
485+
const packageMatch = mainApplication.contents.match(/^package\s+([^\s]+)/);
486+
const packageName = packageMatch ? packageMatch[1] : 'com.resgrid.unit';
487+
488+
// Add import statement for MediaButtonPackage after the package declaration
489+
const importStatement = `import ${packageName}.MediaButtonPackage`;
490+
if (!mainApplication.contents.includes(importStatement)) {
491+
// Add import after the package declaration line
492+
mainApplication.contents = mainApplication.contents.replace(/^(package\s+[^\n]+\n)/, `$1${importStatement}\n`);
493+
console.log('[withMediaButtonModule] Added MediaButtonPackage import');
494+
}
495+
484496
// Add the package to getPackages()
485497
// Find the packages list and add our package
486498
const packagesPattern = /val packages = PackageList\(this\)\.packages(\.toMutableList\(\))?/;

0 commit comments

Comments
 (0)