I developed a simple Firefox extension that fully works on Firefox for desktop computers. The extension uses a few SDK elements which are incompatible with Firefox for Android, likePanel, making it incompatible on Android.
I created two separate versions of the extension - one for desktop computers, and another one without the incompatible SDK elements which is compatible with Android. Everything works, however when I came to submit both extensions to the Mozilla AMO they were rejected and I was asked to consolidate them into a single extension.
How can I create a Firefox extension which uses desktop-only SDK elements on desktop Firefox and does not use them on Firefox for Android?
I ended up researching the issue and decided to write a blog post about the solution: http://blog.danielmittelman.com/2014/12/developing-firefox-add-ons-with-desktop-and-android-compatibility/
Here's the gist of it: There are SDK elements like panel or ui which are explicitly incompatible with Android. Ensuring compatibility with Android requires 3 steps:
1) Using only necessary Android-incompatible SDK elements (what you don't need - don't use)
2) Identifying the platform and using conditional statements to enable or disable potentially incompatible code
3) Creating and/or running the add-on using the --force-mobile flag of cfx
Given that you already have completely different versions for desktop and Android, you should be able to use the use the [flags] in your chrome.manifest to provide a different directory for the content, or other type of entry, based on the application ID using the application=app-ID flag. The application ID is different for Firefox for Android and Desktop Firefox.
The flags are explicitly there for you to be able to have different content based on the application (e.g. desktop/Android), the version of the application, the OS, the OS version, etc.
Example chrome.manifest entries would be:
content myAddon chrome/content-desktop/ application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
content myAddon chrome/content-android/ application={aa3c5121-dab2-40e2-81ca-7ea25febc110}
In the above example the URLs referencing chrome://myAddon/content would come from the chrome/content-desktop/ directory for desktop Firefox and the chrome/content-android/ for Firefox on Android.
If you have content that is shared between applications, you could have an entry like:
content myAddonShared chrome/content-shared/
Because you are using the Add-on SDK, you may have a bit more trouble doing this. I suspect that there is no way to set cfx up to provide such entries, and that you will have to make them manually.
Related
How do I make a single component (say MainContent.js) that branches off according to the Platform to start scanning for beacons, with the kontaktio ios api, on an iphone, but with the kontaktio android api on an android phone?
The scanning is configured and callbacks are set up, in componentDidMount(), and also the scanning itself is started in componentDidMount().
But the ios kontaktio api uses NativeEmitter and has a very different api from the android kontaktio api which uses DeviceEmitter and has very different events, methods, and structures, (for example using connect() instead of init()).
I cannot do this in one code file, because I need to import different things and set different constants for each platform. But the results are the same. I identify a beacon nearby and set some state. (for example through Redux).
There's probably a simple way to do it, and this is most likely a stupid question, but somehow I cannot think of a way to do this since the components are not visual and there is no "render".
OK. From these answers here: Can I require a module specifically for iOS in React Native? I learned to make an AppMain.ios.js and an AppMain.android.js and automatically react native chooses the correct one.
I had to uninstall the latest app on my device, and then did a gradlew clean in the android directory, and then ran on device as usual and everythings ok. Similarly for the iphone.
I have a very simple HTML5 app written with trigger.io that fails running under Android 4.4 with errors stating that local content cannot be accessed. Example:
E/AndroidProtocolHandler( 2236): Unable to open content URL: content:////io.trigger.forge9aee7db8338b11e4b77d1231392b77b0/src/images/connect4.jpg
The same code works find under Android 4.3. This applies to all local content including images, CSS and JavaScript. All resources are referenced with relative paths such as "images/image.jpg".
My best guess is that there is an access policy change in newer versions of Android OS but I cannot figure out the details. I have made sure that nowhere in the code attempts to access external resources.
Antoine van Gelder was incredibly helpful on this. His diagnosis was absolutely correct that jQuery Mobile is rewriting the URLs for resources which causes newer versions of Android's Chrome Webview to fail when accessing resources. The generated URLs contain quadruple slashes after the protocol like this:
content:////io.trigger.forge9aee7db8338b11e4b77d1231392b77b0/src/resource.png
The extra slashes cause Webview to fail. Possibly some excessive checking for correctness or a security implication?
Antoine's suggestions of using older versions of jQuery Mobile or building a custom jQuery Mobile without Base Tag will probably work in some circumstances though neither was quite sufficient in my case. Particularly, removing Base Tag also removes some other functionality I needed.
An alternative approach is to make a minor hack to jQuery Mobile. For version 1.4.3 I did the following:
Edited an un-minified version of jQuery Mobile's javascript
Modified the getLocation function:
Save the return value to a temporary variable
Modify the temporary variable by removing quadruple slashes.
I used something very specific and restricted to the "content" protocol: "retVal = retVal.replace("content:////","content://");"
Return the fixed temporary variable
It looks like, starting with v1.3, jQuery Mobile are rewriting the URL's in your document which breaks the Chrome Webview's access to files in the app sandbox.
You could try filing a bug report with the jQuery Mobile devs but to sort this out in the short term your best options are probably one of:
1) Fall back to jQuery Mobile 1.2.1
2) Build a custom version of jQuery Mobile which excludes some navigation features. (Go to download builder (http://jquerymobile.com/download-builder/), scroll down to "Navigation" and de-select the "Base Tag" module)
This should be fixed in JqueryMobile 1.4.4.
I am .NET developer and currently working with WPF and ASP.NET MVC 4. The next project I should start will be a web application with good chance to later create clients for desktop/mobile/tablets. In other words, this application could be used from the web browser but also from native applications on Android, iOS, WinPhone8 and Windows Desktop (WPF). I have very limited experience with iOS development and none with Android dev.
One of the features I plan to have in this product is ability for users to select a language on which they want to use GUI, be it in web browser or any other client. Thus I need to create localization solution that would work with all platforms I plan to support. Since I am starting this project with first creating the web app in ASP.NET MVC I am not interested in using Microsoft's default support for localization via resources files (.resx) since that wouldn't be portable.
What are different options out there for creating multi-language support in apps deployed for various platforms? The first idea is to use XML files but I am also interested in exploring other possible solutions that might already exist out there. Any ideas on how to approach this problem are welcome.
First of all I'm not sure if your question should be addressed to the Android and iOs developers (using the iOs and Android tags) because if the client loads content provided by the server then the most common way to do this localization (i encountered very often) is to provide different URL's for different languages, probably with a parameter in the url, something like wwww.yourserver.com/en_us/otherstuffhere where en_us should be the country code and in this way the client can change the URL that will use for the following requests.
Of course it's rely hard to localize all the app using a server content, especially UI components such as button titles, placeholders etc. for these there are proper ways to localize them using iOS and Android OS features for localization.
P.S I have no idea how Windows phone OS works.
As far as I know, there is nothing really out there that would do what you want.
Most systems work well with JSON.
What you could do, is use any of the .resx to JSON solutions that are out there and just store all your localization strings in resx and then automatically convert them to JSON for other platforms.
Forget about one solution, just use whatever format the plattform offers and use a tool like Trados or Transifex to manually convert the different formats.
I'd recommend to use whatever format given platform has native, otherwise you will cause you lot of extra troubles.
You can then either use some tools to convert and merge these formats (translate-toolkit is great in this) or use some translation platform which will allow you to translate all of them in one interface. Transifex (service), Crowdin (service) or Weblate (service or instalable) should be able to do this.
Weblate can help you also with keeping them in sync, I don't think others have such feature (I'm author of Weblate).
We wanted to develop a web search app for Android 2.2+, and the language we're dealing with is Arabic script (RTL) based. We are using WebView as the rendering view.
So far only devices with Android 4.0+ (and some Sony phones whith 2.3) displayed the text correctly. But Android 2.x devices still consists a large part of our web users, we needed the same Arabic RTL support in Android 4.0 be availabe with our app.
To be clear, the mentioned Arabic support is not only the direction:rtl (which can be achieved with CSS), but more importantly a letter joining problem: most letters automatically change accroting to the previous and next letter when displayed.
On Windows, since 2000 version, there is a system shared library USP10.dll to handle the process. And applications have the file in their folder, would have the same support even on older Windows 98 systems.
Based on my research on the web, on android there are libicuuc.so and framework.jar to do the similar job.
My question is:
Since Android 4.0+ has the ability to hanlde the letter joining, is it possible to package the corresponding library with the apk to support Arabic in WebView?
If so, how (e.g where to put the file, and any code to add to activity)?
Many thanks in advance.
You can't add newer library for old sdk's. Old sdk's depend upon old java libraries.
I render a local web page in Android and include locally referenced webfonts in woff, ttf and svg format (not fetched via HTTP). However, these are not rendered at all on two different devices (API 2.2 and 2.3) and the console log keeps empty. Of course the fonts work just as they should on any webfonts-capable browser and even old WebKit versions that are older (529.x) than the WebKit version used on Android (533.1). Any clues what piece I am missing in the puzzle?
Ok, seems as if this is a long-standing Android bug, where the Webview pokes on a local() source reference and discards the other sources. This gives you a more detailed response how to define your fonts cross-platform, so that they even work on IE.