viktorthang / mgwt

Automatically exported from code.google.com/p/mgwt
Other
0 stars 0 forks source link

Android Nexus 7 Nav Bar shows in Portrait mode unexpectedly #307

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Open the mgwt show case on a Nexus 7, 7inch tablet. In Portrait mode 
navigate to the Forms section. Put the cursor in any input field so that the 
virtual keyboard would show up.
2. The left navigation bar which was hidden will now show up as if you are in 
landscape mode.

What is the expected output? What do you see instead?
The left nav should not show up. 

What version of the product are you using? On what operating system?
mgwt 1.1.2 Nexus 7 latest version.

Please provide any additional information below.

The problem happens because of this code 
Class
com.googlecode.mgwt.ui.client.MGWT 

 private native static boolean orientationSupport()/*-{
var ua = window.navigator.userAgent.toLowerCase();
if (ua.indexOf('android') != -1) {
return false;
}
if (ua.indexOf('iphone') != -1) {
return true;
}
if (ua.indexOf('ipad') != -1) {
return true;
}

return false;
  }-*/;

In here if the device is android orientation is disabled. This method is used 
in two places, getOrientation which returns the current orientation and 
maybeSetupOrientation which setup the event. 

We need to replace this method with two different methods 
orientationEventSupported which will only be called from the 
mayBeSetupOrientation 
The orientationEventSupported code should be 
return  "onorientationchange" in $wnd;

The other method will be orientationSupport which will be called from the 
getOrientation
The correct implemenation for this method is 
return  "orientation" in $wnd;

This was found after many jsbin tests on older devices running Android 2.3 and 
above the older android versions don't have onorientationchange event but fires 
a resize event. But they still do have a window.orientation property that can 
be checked.

The newer versions, newer than 3.0 have both properties. that is why the 
implementation above is completely wrong.

To fix that what we will do is the MGWT class should have the correct 
getOrientation and maybeSetupOrientation. 

Another option is to allow other implementation by having GWT.create for the 
Orientation Handler which would allow the users of mgwt to embed their own 
implementation.

Original issue reported on code.google.com by sam.gabr...@gmail.com on 5 Jul 2013 at 5:33

GoogleCodeExporter commented 8 years ago
I was able to make a fix by changing the MGWT and refactoring the 
OrientationHandler functionality. 
Please see the attached patch file. 

Original comment by sam.gabr...@gmail.com on 5 Jul 2013 at 10:11

Attachments:

GoogleCodeExporter commented 8 years ago
There is still an issue with the mgwt showcase on Android after many hours of 
debuggging the nav div shows up when the virtual keyboard is displayed empty. 
The reason is the OrientationChangeEvent is not occurring but the browser still 
mistakenly use the main css and not the one from the @media only screen and 
(orientation:portrait) 

I believe the showcase will have to be changed so that the 
OrientationChangeHandler will add a special css to the elements instead of 
relying on the Android Browser's buggy implementation of the media queries.

Original comment by sam.gabr...@gmail.com on 5 Jul 2013 at 10:17

GoogleCodeExporter commented 8 years ago
I have created a pull request https://github.com/dankurka/mgwt/pull/41 #41 to 
be merged to the main mgwt trunk this will enable us to work of the main mgwt 
instead of the branch.
Looking forward to see this pull request merged into the main code.
Thank you

Original comment by sam.gabr...@gmail.com on 20 Jan 2014 at 4:53

GoogleCodeExporter commented 8 years ago
This issue was closed by revision 1cbdc9161b48.

Original comment by kurka.da...@gmail.com on 22 Jan 2014 at 5:05