sinkuri256 / android-scripting

Automatically exported from code.google.com/p/android-scripting
0 stars 0 forks source link

Menus fail to appear in WebView, and events fail to activate #507

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What device(s) are you experiencing the problem on?
Android Emulator
Google Nexus One

What firmware version are you running on the device?
V2.2.1 (Build FRG83D) on Nexus One, V2.2 in Emulator

What steps will reproduce the problem?
1. Copy attached HTML files and BugDemo.py script to /mnt/sdcard/sl4a/scripts/ 
dir
2. Run BugDemo.py from Sl4a interface
3. Observe the Toast message "BodyLoaded" (from a body onload event) and 
accompanying line in console. This shows both scripts in html are running and 
event was received by python script.
4. When Webview appears, push "Menu" button to see the options menu appear
5. Click link in webpage to "page 2" and attempt to bring up options menu 
again.
6. Note Toast message "LinkClicked" and similar in console when clicking on 
page2 link.
7. Note that options menu does not appear.
8. Click back to page1. Note that LinkClicked event does not occur. Note that 
options menu fails to appear.

What is the expected output? What do you see instead?
See steps above.

What version of the product are you using? On what operating system?
SL4a R3 on Google Nexus One and Ubuntu 10.04

Please provide any additional information below.
Both the events buffer and main buffer logcat are attached below. Logcat was 
cleared prior to running test.

Note that killing the script is the only way to close it when menu has 
disappeared.

Original issue reported on code.google.com by james.bu...@gmail.com on 19 Jan 2011 at 3:24

Attachments:

GoogleCodeExporter commented 9 years ago
I was trying to debug this, and realized the logcat -d > filename method only 
dumps the last few lines of the logs when using the emulator (not sure about 
the phone). Using adb logcat > filename logs as the emulator/script is running, 
so you get data for the beginning (which, it turns out, is important, oops). 
Might be a nice fact to put on the logcat instructions.

At any rate, the attached logcat (I included events log too), shows that when 
the link is clicked and a new page loaded, a new activity is started, and the 
Android() variable in the JavaScript on each page cannot be initialized, so the 
events cannot be posted at that point. I don't think JS supports making that 
kind of variable persistence across pages, so there's no obvious workaround to 
me, except by somehow modifying the page without causing new activities to be 
started.

This explains why the events do not work, but not quite why the menus 
disappear, since the menu is persistent the first time you move from one page 
to the next, but not afterwards. Possibly for the same reason the Android() 
variable cannot be initialized on the second page?

Any help would be appreciated! Thanks!

Original comment by james.bu...@gmail.com on 29 Jan 2011 at 5:47

Attachments:

GoogleCodeExporter commented 9 years ago
I have modified two files to address my specific problem. The source code is 
attached. I leave it up the maintainers to determine whether my approach makes 
sense in the greater scheme of the codebase. See discussion post for summary of 
changes.

Original comment by james.bu...@gmail.com on 1 Feb 2011 at 2:02

Attachments:

GoogleCodeExporter commented 9 years ago
Changes have been added and are available here:
http://www.mithril.com.au/android/sl4a_r4x.apk 
Not tested by me. Feedback appreciated.

NB: This also has the 'installable on sdcard' option set. Which may not work on 
devices below 2.2 (Froyo) (Api 8). Feedback on this would also be appreciated.

Original comment by rjmatthews62 on 2 Feb 2011 at 1:18

GoogleCodeExporter commented 9 years ago

Original comment by rjmatthews62 on 5 Mar 2011 at 2:10