Detecting the user-agent target after compilation for cache-manifest

17 views
Skip to first unread message

Evan Ruff

unread,
Jun 16, 2011, 9:02:15 PM6/16/11
to google-we...@googlegroups.com
Hello,

Hey guys!

I'm trying to integrate GWT into an offline HTML application for Android and iPhone. In order to do this, I need to compile a MANIFEST file to direct the browser to cache files. I've got it working now with a servlet that returns a text/cache-manifest file with a list of the contents of my /app directory (the module is rename-to app). While this works, I'm forcing the mobile browser to download ALL permutations of the GWT compiled units because I can't determine the which version is for the mobile-webkit.

Is there any easy way to determine which file maps to which user agent?

In case there isn't, my alternative plan looks something like this:
1. Create an interface widget called UserAgentDetector, one method String getUserAgentName()
2. Create multiple classes implementing UserAgentDetector that return a single, static, unique string of the user agent. (ex. return "EvansUniqueMozillaAgentString";)
3. Append my gwt.xml file to map each class to the various user agent using replace:
<replace-with class="com.evan.agent.MozillaUserAgentDetector">
<when-type-is class="com.evan.agent.UserAgentDetector" />
<any>
<when-property-is name="user.agent" value="gecko"/>
<when-property-is name="user.agent" value="gecko1_8" />
</any>
</replace-with>
4. Toss some .create binding command in my EntryModule
5. Create a post-compiler step to text search each of the files, matching up the unique agent string (EvansUniqueMozillaAgentString) with the js file name.
6. Output the matches to a .properties file, which I can then feed into my cache-manifest servlet generator

The idea being that each permutation will include ONLY the UserAgentDetector that is relevent to the target. By making a ~nonsense user agent string, I can deduce which agent the file is targeting by the presence of that string. Will this work? It seems convoluted.

Can anyone suggest a better way?

Thanks!

Evan
Reply all
Reply to author
Forward
0 new messages