Use Retrofit for direct mobileview page load
- Added new library + license info + ProGuard rules devRelease apk size difference: before: 3,812,413 bytes after: 3,852,942 bytes = +40KB
- Implemented PhpApi Retrofit service endpoint
- JsonPageLoadStrategy ApiTasks converted to use Retrofit callbacks
- New Gson POJOs for PageLead and PageRemaining
- PageLead Gson parsing had an issue with the protection field --> had to use custom JSON deserializer for the protection field due to T69054.
- pageLead request uses formatversion=2 to make handling boolean values easier. pageRemaining doesn't have any booleans, so not needed there yet (but probably wouldn't hurt).
- section: ArrayList -> List
- new Section(json) -> Section.fromJson(json)
- Retrofitted RefreshSavedPageTask functionality
- Get Main page for widget (also added slight optimization)
- SectionsFetchTaskTests -> PageLoadTests
- Removed SectionFetchTask
- Add noimages flag (have to skip sending the parameter when false since the MW API takes the mere presence of the parameter as a true value)
- Add W0 mcc-mnc enrichment header
- Add other custom headers
- Get W0 X-CS header
- Use OkHttpClient cookie handler and cache
- Cache the RestAdapter's output the service object since this is a memory intensive object. See http://stackoverflow.com/questions/20579185/is-there-a-way-to-reuse-builder-code-for-retrofit#answer-20627010
I started most of the POJO files using jsonschema2pojo.org. But manually updated them to
introduce the static inner classes, added some convenience methods; and, of course,
last but not least add the custom deserializer for the MwPageLead.Protection object.
The parts I don't like are the extra de-/serialization steps in Section.java. I think it's probably better to leave that
to use org.json.JSONObject parsing instead of using Gson since we pass the former over to the JS bridge.
Now toJSON() builds a new JSONObject just for that. Oh well.
The code is already structured so that it's easy to plug in a new way of loading page content through RESTBase.
It was a bit rough to genericize regular Retrofit interfaces which are used to generate the Retrofit endpoint functionality.
If it wasn't for that this code would have been quite a bit simpler and more standard Retrofit. Sorry, Jake.