viktorthang / mgwt

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

Optional mgwt.os permutations for Mobile Firefox Android #314

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1. com/googlecode/mgwt/dom/DOM.gwt.xml contains 
>>
    <set-property name="mgwt.os" value="desktop" >
      <none>
        <when-property-is name="user.agent" value="safari" />
      </none>
    </set-property>
<<

2. Therefore Mobile Firefox on Android always shows the desktop version only.

What is the expected output? What do you see instead?

Mobile Firefox should also show a mobile version of a web app. 

I understand that this is not a high priority for you. It would be great 
however if this would be optional, because I don't see a way to undo this 
limitation. 

Also it has the effect that the value (mgwt.os) provided by property-provider 
and the actual value are inconsistent, which gives problems of incomplete 
permutations when defining additional properties.

Original issue reported on code.google.com by robert.h...@gmail.com on 10 Nov 2013 at 4:26

GoogleCodeExporter commented 8 years ago
Actually not even the fallback 'desktop' version works on Firefox for Android 
because of inconsistent permutations:

1) Firefox mobile has the ua string: Mozilla/5.0 (Android; Mobile; rv:13.0) 
Gecko/13.0 Firefox/13.0

2) The property-provider for mgwt.os (com/googlecode/mgwt/dom/DOM.gwt.xml) thus 
returns: "android"

3) This mgwt.os is then however overwritten (in 
com/googlecode/mgwt/dom/DOM.gwt.xml) with 
>>
<set-property name="mgwt.os" value="desktop" >
      <none>
        <when-property-is name="user.agent" value="safari" />
      </none>
    </set-property>
<<

4) And this leads to an inconsistent "*.nocache.js" file:
>>
      ...
      unflattenKeylistIntoAnswers(['retina', 'yes', 'safari'], 'HASHASH');
      unflattenKeylistIntoAnswers(['ipad_retina', 'yes', 'safari'], 'HASHASH');
      unflattenKeylistIntoAnswers(['blackberry', 'no', 'safari'], 'HASHASH');
      unflattenKeylistIntoAnswers(['android', 'yes', 'safari'], 'HASHASH');
      strongName = answers[computePropValue('mgwt.os')][computePropValue('phonegap.env')][computePropValue('user.agent')];
<<

which fails at the last line in this snippet because 
computePropValue('mgwt.os') gives "android" but no android/phonegap/gecko 
permutation was created.

Workaround:

To me it seems the inconsistency problem is actually a gwt issue. 

in any case, the workaround I found is to redefine the property-provider for 
mgwt.os to make it consistent with the set-property rule:
>>
    <property-provider name="mgwt.os"><![CDATA[
    {
      var mgwt_os = (function(){
        var ua = window.navigator.userAgent.toLowerCase();

        //!!! ADDED TO MAKE CONSISTENT WITH set-property rule ('non-safari -> desktop')
        if(ua.indexOf("safari")<0) return "desktop";

        if(ua.indexOf('android') != -1) {
          if(ua.indexOf('mobile') != -1) {
            return "android";
          } else {
            return "android_tablet";
          }
        }
...
<<

Original comment by robert.h...@gmail.com on 11 Nov 2013 at 12:57

GoogleCodeExporter commented 8 years ago
just for reference, I have opened a GWT issue too - 
https://code.google.com/p/google-web-toolkit/issues/detail?id=8427

Original comment by robert.h...@gmail.com on 11 Nov 2013 at 1:22

GoogleCodeExporter commented 8 years ago
WIth mgwt 2.0 we added a more generic way of permutations per device, so we do 
not need to list any device explicitly anymore.

Original comment by kurka.da...@gmail.com on 13 Jul 2014 at 5:13