Fix Android app store buttons

This commit is contained in:
Rudra Saraswat 2023-04-18 12:54:03 +05:30
parent 80c4de0637
commit e54dbe03e3
2 changed files with 19 additions and 11 deletions

View file

@ -48,8 +48,8 @@ function install_aurora_store() {
aurora_store_worker.onmessage = e => {
if (e.data == 'success') {
document.getElementById('aurora-store-btn').outerHTML =
`<button type="button btn-success" id="aurora-store-btn" onclick="install_aurora_store()"
class="btn btn-success" disabled>Installed</button>`
`<button type="button btn-success" id="aurora-store-btn" onclick="require('child_process').spawn('waydroid', ['app', 'launch', 'com.aurora.store'])"
class="btn btn-success">Open</button>`
} else if (e.data == 'failed') {
document.getElementById('aurora-store-btn').outerHTML =
`<button type="button btn-success" id="aurora-store-btn" onclick="install_aurora_store()"
@ -85,8 +85,8 @@ function install_f_droid() {
f_droid_worker.onmessage = e => {
if (e.data == 'success') {
document.getElementById('f-droid-btn').outerHTML =
`<button type="button btn-success" id="f-droid-btn" onclick="install_f_droid()"
class="btn btn-primary" disabled>Installed</button>`
`<button type="button btn-success" id="fdroid-btn" onclick="require('child_process').spawn('waydroid', ['app', 'launch', 'org.fdroid.fdroid'])"
class="btn btn-primary">Open</button>`
} else if (e.data == 'failed') {
document.getElementById('f-droid-btn').outerHTML =
`<button type="button btn-success" id="f-droid-btn" onclick="install_f_droid()"
@ -114,14 +114,22 @@ require('fs').stat('/var/lib/waydroid', (err, stat) => {
require('child_process').spawn('waydroid', ['session', 'start'])
setTimeout(() => {
if (require('child_process').spawnSync('waydroid', ['app', 'list']).stdout.includes('com.aurora.store')) {
document.getElementById('aurora-store-btn').outerHTML =
`<button type="button btn-success" id="aurora-store-btn" onclick="require('child_process').spawn('waydroid', ['app', 'launch', 'com.aurora.store'])"
class="btn btn-success">Open</button>`
} else {
document.getElementById('aurora-store-btn').outerHTML =
`<button type="button btn-success" id="aurora-store-btn" onclick="install_aurora_store()"
class="btn btn-success" disabled>Installed</button>`
class="btn btn-success">Install</button>`
}
if (require('child_process').spawnSync('waydroid', ['app', 'list']).stdout.includes('org.fdroid.fdroid')) {
document.getElementById('f-droid-btn').outerHTML =
`<button type="button btn-success" id="fdroid-btn" onclick="install_f_droid()"
class="btn btn-primary" disabled>Installed</button>`
`<button type="button btn-success" id="fdroid-btn" onclick="require('child_process').spawn('waydroid', ['app', 'launch', 'org.fdroid.fdroid'])"
class="btn btn-primary">Open</button>`
} else {
document.getElementById('f-droid-btn').outerHTML =
`<button type="button btn-success" id="f-droid-btn" onclick="install_f_droid()"
class="btn btn-primary">Install</button>`
}
}, 1000)
} else {

View file

@ -59,7 +59,7 @@
</div>
</div>
</div>
<button type="button" id="f-droid-btn" onclick="waydroid_open_settings()"
<button type="button" onclick="waydroid_open_settings()"
class="btn btn-primary">Open Settings</button>
<br><br>
<strong>Useful information</strong>