Open ezwang opened 8 years ago
Shouldn't this only be done on phones w/ a menu button?
I think you can just add an if statement on the key down listener. If the phone does not have the key, the if statement will just never trigger.
Just because you can, doesn't make it the best way to do it. Imo, using the native api to determine if a menu button is present is a lot cleaner than a js try/catch
To actually capture the event, I'm suggesting that we use the Android API. The js try/catch can be used to open the sidebar. I don't think there is another cleaner way to communicate with the page. Since pages like the login screen don't have a sidebar, the try/catch will prevent errors from being thrown.
On second thought, it might be possible to implement this in pure Javascript.
And why does the js have to use a try-catch to see if there is a sidebar? Isn't there a cleaner way?
I don't think it actually needs a try catch, since jQuery won't do anything if the element doesn't exist.
The cleaner way would probably be native JS, so it works outside of the app and is only loaded when the navbar exists.
Probably, feel free to PR or w/e :)
This could be accomplished by calling javascript wrapped in a try catch
http://stackoverflow.com/questions/4325639/android-calling-javascript-functions-in-webview