tjcsl / ionapp-android-gcmframe

The official TJHSST Intranet app, in development
https://ion.tjhsst.edu
2 stars 1 forks source link

Make menu button open sidebar menu #8

Open ezwang opened 8 years ago

ezwang commented 8 years ago

This could be accomplished by calling javascript wrapped in a try catch

http://stackoverflow.com/questions/4325639/android-calling-javascript-functions-in-webview

pefoley2 commented 8 years ago

Shouldn't this only be done on phones w/ a menu button?

ezwang commented 8 years ago

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.

pefoley2 commented 8 years ago

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

ezwang commented 8 years ago

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.

https://github.com/tjcsl/ionapp-android-gcmframe/blob/master/app/src/main/java/edu/tjhsst/ion/gcmFrame/MainActivity.java#L240

On second thought, it might be possible to implement this in pure Javascript.

http://stackoverflow.com/questions/14032214/how-to-detect-back-and-menu-button-on-android-phonegap-jquery-mobile

pefoley2 commented 8 years ago

And why does the js have to use a try-catch to see if there is a sidebar? Isn't there a cleaner way?

ezwang commented 8 years ago

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.

pefoley2 commented 8 years ago

Probably, feel free to PR or w/e :)