Skip to content

Commit

Permalink
Improved mobile support. Fixed #956
Browse files Browse the repository at this point in the history
  • Loading branch information
ManeraKai committed Aug 2, 2024
1 parent 15db773 commit a9ecaf4
Show file tree
Hide file tree
Showing 8 changed files with 273 additions and 219 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"start": "web-ext run",
"nightly": "web-ext run --firefox=/home/esmail/software/firefox_nightly/firefox",
"start_ar": "web-ext run --firefox=/home/esmail/software/firefox_ar/firefox",
"android": "web-ext run -t firefox-android --adb-device emulator-5554 --firefox-apk org.mozilla.fenix ",
"android": "web-ext run -t firefox-android --adb-device emulator-5554 --firefox-apk org.mozilla.firefox --adb-remove-old-artifacts",
"build": "web-ext build",
"test": "web-ext lint",
"html": "rollup -c --config-popup && rollup -c --config-options"
Expand Down
404 changes: 208 additions & 196 deletions src/pages/background/background.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/pages/components/Checkbox.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script>
export let checked
export let onChange
console.log(document.body.dir)
</script>

<input class={document.body.dir} {...$$restProps} bind:checked on:change={onChange} type="checkbox" />
Expand Down
39 changes: 29 additions & 10 deletions src/pages/options_src/General/General.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,30 @@
const unsubscribe = options.subscribe(val => (_options = val))
onDestroy(unsubscribe)
let disableBookmarks = null
browser.runtime.getPlatformInfo(r => {
switch (r.os) {
case "fuchsia":
case "ios":
case "android":
disableBookmarks = true
break
default:
disableBookmarks = false
}
if (!disableBookmarks) {
browser.permissions.contains({ permissions: ["bookmarks"] }, r => (bookmarksPermission = r))
}
})
let bookmarksPermission
browser.permissions.contains({ permissions: ["bookmarks"] }, r => (bookmarksPermission = r))
$: if (bookmarksPermission) {
browser.permissions.request({ permissions: ["bookmarks"] }, r => (bookmarksPermission = r))
} else {
browser.permissions.remove({ permissions: ["bookmarks"] })
bookmarksPermission = false
$: if (disableBookmarks !== null && disableBookmarks === false) {
if (bookmarksPermission) {
browser.permissions.request({ permissions: ["bookmarks"] }, r => (bookmarksPermission = r))
} else {
browser.permissions.remove({ permissions: ["bookmarks"] })
bookmarksPermission = false
}
}
</script>

Expand Down Expand Up @@ -68,10 +85,12 @@
/>
</Row>

<Row>
<Label>{browser.i18n.getMessage("bookmarksMenu") || "Bookmarks menu"}</Label>
<Checkbox bind:checked={bookmarksPermission} />
</Row>
{#if disableBookmarks === false}
<Row>
<Label>{browser.i18n.getMessage("bookmarksMenu") || "Bookmarks menu"}</Label>
<Checkbox bind:checked={bookmarksPermission} />
</Row>
{/if}

<Exceptions />

Expand Down
1 change: 0 additions & 1 deletion src/pages/options_src/Services/Instances.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
async function pingInstances() {
pingCache = {}
for (const instance of allInstances) {
console.log("pinging...", instance)
pingCache[instance] = { color: "lightblue", value: "pinging..." }
const time = await utils.ping(instance)
pingCache[instance] = colorTime(time)
Expand Down
10 changes: 5 additions & 5 deletions src/pages/options_src/Services/Services.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@
<div>
<Row>
<Label>
Service:
<a href={serviceConf.url} target="_blank" rel="noopener noreferrer">{serviceConf.url}</a>
<a href={serviceConf.url} style="text-decoration: underline;" target="_blank" rel="noopener noreferrer">
{browser.i18n.getMessage("service") || "Service"}
</a>
</Label>
<div dir="ltr">
<SvelteSelect
Expand Down Expand Up @@ -91,9 +92,8 @@

<Row>
<Label>
{browser.i18n.getMessage("frontend") || "Frontend"}:
<a href={frontendWebsite} target="_blank" rel="noopener noreferrer">
{frontendWebsite}
<a href={frontendWebsite} style="text-decoration: underline;" target="_blank" rel="noopener noreferrer">
{browser.i18n.getMessage("frontend") || "Frontend"}
</a>
</Label>
<div dir="ltr">
Expand Down
30 changes: 26 additions & 4 deletions src/pages/popup_src/Buttons.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,14 @@

<div class={document.body.dir}>
{#if redirect}
<Row class="interactive" on:click={() => browser.runtime.sendMessage("redirectTab")}>
<Row
class="interactive"
on:click={() => {
browser.runtime.sendMessage("redirectTab", () => {
window.close()
})
}}
>
<Label>{browser.i18n.getMessage("redirect") || "Redirect"}</Label>
<RedirectIcon />
</Row>
Expand All @@ -50,7 +57,10 @@
{#if switchInstance}
<Row
class="interactive"
on:click={async () => browser.tabs.update({ url: await servicesHelper.switchInstance(url) })}
on:click={async () =>
browser.tabs.update({ url: await servicesHelper.switchInstance(url) }, () => {
window.close()
})}
>
<Label>{browser.i18n.getMessage("switchInstance") || "Switch Instance"}</Label>
<SwitchInstanceIcon />
Expand All @@ -62,7 +72,13 @@
<Label>{browser.i18n.getMessage("copyOriginal") || "Copy Original"}</Label>
<CopyIcon />
</Row>
<Row class="interactive" on:click={() => browser.runtime.sendMessage("reverseTab")}>
<Row
class="interactive"
on:click={() =>
browser.runtime.sendMessage("reverseTab", () => {
window.close()
})}
>
<Label>{browser.i18n.getMessage("redirectToOriginal" || "Redirect to Original")}</Label>
<RedirectToOriginalIcon />
</Row>
Expand All @@ -85,7 +101,13 @@

<hr />

<Row class="interactive" on:click={() => window.open(browser.runtime.getURL("pages/options/index.html"), "_blank")}>
<Row
class="interactive"
on:click={() =>
browser.tabs.create({ url: browser.runtime.getURL("pages/options/index.html") }, () => {
window.close()
})}
>
<Label>{browser.i18n.getMessage("settings")}</Label>
<SettingsIcon />
</Row>
Expand Down
5 changes: 4 additions & 1 deletion src/pages/popup_src/components/Switch.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
<div
class="interactive"
on:keydown={null}
on:click={() => window.open(browser.runtime.getURL(_config.services[serviceKey].url), "_blank")}
on:click={() =>
browser.tabs.create({ url: browser.runtime.getURL(_config.services[serviceKey].url) }, () => {
window.close()
})}
>
<ServiceIcon details={{ value: serviceKey, label: _config.services[serviceKey].name }} />
<Label>{_config.services[serviceKey].name}</Label>
Expand Down

0 comments on commit a9ecaf4

Please sign in to comment.