Skip to content

Commit

Permalink
Circumvent icon setting on Android
Browse files Browse the repository at this point in the history
Apparently the Firefox on Android API doesn't support setIcon, so it
crashes basically the whole core functionality. So if we're on Android,
just skip that part. This fixes #22.

I don't have Android so I can't test this fix. Hopefully it works.
  • Loading branch information
omivore committed Feb 2, 2019
1 parent 29fc5f7 commit dd76c94
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
18 changes: 14 additions & 4 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,24 @@ function isTresspassing() {
// If result is not empty, then is tresspassing.
if (result.length > 0) {
// If tresspassing, then show so in the extension icon.
browser.browserAction.setIcon({
path: { 48: 'icons/monastery_lock.svg'},
// This doesn't work on android so adjust accordingly
browser.runtime.getPlatformInfo().then(info => {
if (info.os == "android") {

This comment has been minimized.

Copy link
@acharron

acharron Mar 6, 2019

@omivore
Hi, shouldn't it be a if (info.os != "android") instead?

Your commit message states "So if we're on Android, just skip that part.". Now the icon change happens only on Android

browser.browserAction.setIcon({
path: { 48: 'icons/monastery_lock.svg'},
});
}
});
return true;
} else {
// If not tresspassing, make sure icon is back to normal.
browser.browserAction.setIcon({
path: { 48: 'icons/monastery.svg'},
// This doesn't work on android so adjust accordingly
browser.runtime.getPlatformInfo().then(info => {
if (info.os == "android") {
browser.browserAction.setIcon({
path: { 48: 'icons/monastery.svg'},
});
}
});
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

"manifest_version": 2,
"name": "Monastery",
"version": "1.3.1",
"version": "1.3.2",
"applications": {
"gecko": {
"id": "[email protected]",
Expand Down

0 comments on commit dd76c94

Please sign in to comment.