New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
shouldLoadURL event support and executeAndReturnString() #459
Comments
Comment #1 originally posted by codenameone on 2013-01-01T06:13:09.000Z: Issue 453 has been merged into this issue. |
Comment #2 originally posted by codenameone on 2013-01-01T06:13:33.000Z: <empty> |
Comment #3 originally posted by codenameone on 2013-01-01T07:28:45.000Z: Thanks for the patch. I like the general approach of the patch but there are a couple of things that I think might be confusing to users of this functionality. The first and probably worst one is the event dispatch off the EDT, this breaks a major rule we always made in Codename One where all events are sent on the EDT. I'd rather have no event. I think both can be resolved by adding an interface to the events package called: BrowserNavigationCallback, then add methods to both classes called setBrowserNavigationCallback(). The advantage here is a cleaner separation (no need to subclass) and since the interface will not use the listener API we can much more clearly document the not on the EDT behavior in the interface and in the setter method on the components. Does that make sense? |
Comment #4 originally posted by codenameone on 2013-01-01T07:57:17.000Z: I think I understand the idea, but I'm not entirely clear yet on the I know that most of the native toolkits use the delegate pattern for -Steve |
Comment #5 originally posted by codenameone on 2013-01-01T08:00:27.000Z: It should just be an interface declaring the should navigate method and returning a boolean value. |
Comment #6 originally posted by codenameone on 2013-01-01T08:07:48.000Z: OK. I see what you mean. I'll make the change in the morning and -Steve |
Comment #7 originally posted by codenameone on 2013-01-01T08:11:39.000Z: Which package would you like the BrowserNavigationCallback interface added to? |
Comment #8 originally posted by codenameone on 2013-01-01T08:12:46.000Z: Sorry... I missed it. You already said it should be added to the events package. -steve |
Comment #9 originally posted by codenameone on 2013-01-01T08:13:29.000Z: My initial thought is the events package mostly because I can't think of anything else. |
Comment #10 originally posted by codenameone on 2013-01-01T09:51:57.000Z: I have made the changes discussed and have included all of the changes in a single patch file. I have tested the changes on the Simulator, Android (Nexus 7), and iPhone 4s and they seem to work. Need to add javadocs and other documentation still, but wanted to get this in before I quit for the night. |
Comment #11 originally posted by codenameone on 2013-01-01T12:06:22.000Z: The JavascriptInterface annotation is problematic since it might fail on 2.x devices and can't compile with our current 14 level API deployment. |
Comment #12 originally posted by codenameone on 2013-01-01T12:39:38.000Z: I committed most of this and added the docs. However, I didn't commit the Android version because of the concerns of the annotations issues. Thanks. |
Comment #13 originally posted by codenameone on 2013-01-01T13:40:45.000Z: I was concerned about this too but I tested it on a 2.1 device (level 7) |
Comment #14 originally posted by codenameone on 2013-01-01T13:44:08.000Z: The annotation has to include runtime code otherwise it wouldn't work. If there is no other way to do this I will try to integrate it this way. |
Comment #15 originally posted by codenameone on 2013-01-01T14:00:47.000Z: Perhaps this explains it. Evidently an annotation doesn't need to be present at runtime and will just Apparently this annotation is only necessary in 4.x but I don't have any Steve |
Comment #16 originally posted by codenameone on 2013-01-01T14:02:15.000Z: Doesn't the nexus 7 run Jelly Bean? |
Comment #17 originally posted by codenameone on 2013-01-01T14:05:05.000Z: Which API level are you compiling against? |
Comment #18 originally posted by codenameone on 2013-01-01T14:06:48.000Z: Oops youre right. I was looking at the kernel version.... |
Comment #19 originally posted by codenameone on 2013-01-01T14:07:54.000Z: Found it, Level 17. I'm assigning to Chen to evaluate whether its practical to migrate to 17. |
Comment #20 originally posted by codenameone on 2013-01-01T14:14:19.000Z: I'm targeting minsdk version 7. I'm compiling using ADT Build: v21.0.1-543035 (think this means sdk
The docs say: "Caution: If you've set your targetSdkVersion to 17 or higher, you It also says that this class was added in API level 17. -Steve |
Comment #21 originally posted by codenameone on 2013-01-01T14:16:19.000Z: No wait... I'm an idiot. My SDK version is 17. (but minsdk was set -Steve |
Comment #22 originally posted by codenameone on 2013-01-01T14:16:57.000Z: So if I understand this correctly: as long as we are on SDK level 14 we don't need this annotation at all. Once we upgrade we MUST have it right? |
Comment #23 originally posted by codenameone on 2013-01-01T14:19:36.000Z: BTW looking here: http://www.korri.net/tutorials/android/communication-to-and-from-android-webview-with-js.html it seems there is another approach that doesn't include the expose in JavaScript stuff. |
Comment #24 originally posted by codenameone on 2013-01-01T14:45:21.000Z: After implementing the js bridge using this method I think it might be However I may try doing it by overriding the alert behavior as, apparently, This article highlights some security aspects of JavaScript interfaces And makes me think that I should have avoided it from the start. Steve |
Comment #25 originally posted by codenameone on 2013-01-01T15:22:28.000Z: So where do we stand? Should I use the current code with annotations commented out? |
Comment #26 originally posted by codenameone on 2013-01-01T17:35:05.000Z: Sorry... Fell asleep. I'm going to test it out over the next couple of Steve |
Comment #27 originally posted by codenameone on 2013-01-01T18:19:10.000Z: Ok. Yes you can just comment the annotations out and it will work. I Steve On Tuesday, January 1, 2013, Steve Hannah wrote: |
Comment #28 originally posted by codenameone on 2013-01-01T19:02:53.000Z: Thanks, I'll commit the fix soon. I'm pending on another commit that is going in right now (updating the plugin) so once that is done this will also land and I'll update the server. |
Comment #29 originally posted by codenameone on 2013-01-08T09:09:48.000Z: <empty> |
Original issue 459 created by codenameone on 2012-12-31T21:45:51.000Z:
This is related to issue # 453 (http://code.google.com/p/codenameone/issues/detail?id=453). I have implemented two mechanisms necessary to support a robust Javascript interface in a minimal way. These are:
I have added support for Android, iOS, and JavaSE, and have attached the patches for these ports all separately.
I have also created a Test application to test all of this functionality (and will hopefully grow to include tests for much more CodenameOne functionality). I have added this project to the incubator:
http://code.google.com/p/codenameone-incubator/source/browse/#svn%2Ftrunk%2Fshannah%2FCodenameOneTests
However I need to clean it up to make it easier for others to set it up and use it. This project includes a separate package, ca.weblite.codename1.js that is a full two-way Javascript bridge built on top of this functionality.
http://code.google.com/p/codenameone-incubator/source/browse/#svn%2Ftrunk%2Fshannah%2FCodenameOneTests%2Fsrc%2Fca%2Fweblite%2Fcodename1%2Fjs
I will be factoring this out into its own subproject and will post usage examples and more tests later today.
I have tested these changes on:
iPhone 4S
Android (Nexus 7)
Android (HTC Magic running Android 2.1)
JavaSE (the simulator)
I don't have a Blackberry test environment up and running yet, or I would have also provided a patch for it also.
The text was updated successfully, but these errors were encountered: