Rendering custom emoji through an IME - android

I am thinking about making a keyboard (for myself and a few friends) with the sprites of the 721 Pokémon in it. First, however, I need to figure out a good way to store these characters. My idea was to store these in unused Unicode characters, but I need 721 of them.
Is there a better way to have custom emoji without overwriting existing ones? If not, what are 721 characters I can use (preferably together, no breaks in between) to store the Pokémon?
As a bonus, how can I store the shiny versions of these Pokémon?
Then, how do I draw these characters using my keyboard?

Encoding
You probably want to store them in a Private Use Area (PUA) block.
There are 3 of them, I would use one of the supplementary ones, as the risk to stumble on someone's else private use is reduced.
Don't override the existing ones.
Rendering
You will need to use your own font and embed it in your application.
You will need a way to tell the text engine "hey, for characters in this range use this font". So you need some rich text format (i.e. HTML), so use a WebView.
TextView might also work, if you use a Spanned created Html.fromHtml. But I am not sure if that supports specifying an embedded font, need to try.
Input
You would need a custom keyboard... There might be some open source, data driven one. Or one in the store that allows you to customize it. Or you can add them to the dictionary, with a shortcut, but then you will need to know all the names (so that you can type p.pikachu). Or you can use a character picker.
Storage
At this point they are strings. You can store as any other text, move through the wire, on disk, etc.

Related

What is the best way to create text based Android apps?

I am working on an Android app which will store long texts, images etc. A 'guide' app in other words. But I am not sure which one would be the best way(or the most logical way) to do this. Storing the texts in strings.xml, using HTML&CSS and showing it using WebView, using databases, or something else?
That depends a bit on where the text is coming from, IMHO.
If the text is baked into the app, and it will only change via an update to the app itself, I'd use HTML/CSS and store it in assets/. They can then be loaded using loadUrl("file:///android_asset/...") in a WebView. If you wanted full-text search, you could prepare a SQLite database with an FTS table and package that with the app as well, unpacking and using it on the first run of the app.
If you plan on downloading the text, then the decision hinges more on what the server is serving, as you're probably stuck with that format. That, in turn, would influence the storage approach.
String resources (strings.xml) are fairly clunky for long bits of text.

Using large amount of gifs, images, texts in android app

I am building an android app that will ask user what they want to see. Based on that I will provide gifs, images and texts(one lines) based on time duration they choose. This would be an offline app.
I am confused about how I should proceed with storing large amount of gifs(1000), images(1000), and texts( sentences or words). After storing I would want to run them in some kind of time duration loop so that those they have seen won't be repeated.
In my opinion images, gifs or otherwise are just resources and should be stored as such. Text can be stored in another appropriate resource file.
What I'd recommend is then ensuring you have a database that provides names and links to the resources.
When the user provides you with a keyword, query your database to get a list of items that need to be provided. Your query can be used to change the order etc...
Your code should then cycle through the query response, retrieving and displaying the items as appropriate.
Remember, if you are displaying images to a user you may also need to consider screen resolution and thus may require the same image at different resolution. Equally you may wish to consider localising the text to support different languages.
Hope this helps.
(By the way, I'd recommend putting a rough plan together based on the above approach, breaking it down to ensure you know 'HOW' to do it. After you know how/what, then search to see if a library exists that allows you to do what you want to do in a simpler method. Search to see if there's a better method for handling the resources etc... the first step is always getting AN approach and then evaluating to see if it's the best approach for your needs/requirements.)

How to convert json unicoded value to other font's unicode?

I have data with local font in my database. I can extract it successfully in php (displaying the same local word in webpage). Now, I want to send this data using JSON so that it can be accessed by Android app. While encoding in JSON, is it possible to encode in different font's unicode?
After retrieving JSON encoded values, the word can be displayed in font A (but in broken format). But I want to show it using font B (so that broken stuffs are solved in this).
So, is there any way to encode using different font so that I can fix my issue ?
Thanks.
So, is there any way to encode using different font so that I can fix my issue ?
No. Unicode strings contain only plain semantic text. There are no markup constructs in it that would allow you to choose a different font; that has to be provided by a layer above text such as HTML.
the word can be displayed in font A (but in broken format). But I want to show it using font B (so that broken stuffs are solved in this).
The app that consumes the JSON and displays data from it must be altered to display using Font B.
Note that Android support for Indic scripts has historically been notoriously poor and still suffers from bugs; prior to the 4.x series you will probably be missing any kind of Font B or even correct Devenagari glyph layout.
By definition, JSON must be encoded in UTF-8.
When you talk about font, I assume you are talking about encoding - text by itself does not specify which font will be used to render it on user screen. Best option is to always store your data in UTF-8, so you don't have to recode anything. All open-source databases (PostgreSQL, MySQL, etc) provide a way to store text in UTF-8 by default. Also, Android uses UTF-8 by default for all strings (JSON, XML, etc).
If you data is encoded in some legacy encoding (like CP1250 or CP1251), your should use appropriate method to convert that encoding into UTF-8 before creating JSON. Almost every platform provides a way for such conversion. One of the popular libraries for this is iconv (it has bindings for PHP, C/C++, etc), but I am sure there are many other ways to accomplish that.

Storing line-by-line data in single database field

In MySQL database, I have a table in which there is a field named features. I have nearly 20 features to store there. I am trying to retrieve these features from my Android mobile application. In app, it has to be shown as line by line (so 20 lines in total). Is there anyway to store the 20 features in that single field by doing something like \n? Or is there anyway to get those features in new lines by doing something in my android app?
Firstly, this is almost certainly a terrible idea...by storing the features in a single field, you make it very hard to query and manage. For instance, finding all records where feature "x" is available requires you to parse the feature field in some way, which will almost certainly not make use of any indexing on the column.
If you have no choice, you have two options: store the features as some kind of string representation (XML, JSON, CSV), or store the features as a bit flag.
I strongly recommend using a structured text format - JSON is probably the most lightweight - because it's human readable, and easily parsed.
Well assuming you have the code set up to run a query and retrieve the data, you should store the data retrieved into a collection (an array or list) and loop through each item, displaying the needed data on the screen.
Displaying the data can work anyway you want, you can add a button for each record, write a line of text to a text field (which is probably good for your case), create a cell in a table etc....
I wouldn't place all of the data into the same record, it could get messy should you decide to add a field which is tailored to an individual feature. Plus, if you combine all the features into one record and decide to add or remove a feature later on, you will have to do string manipulation.
I would go with LONGTEXT. TEXT and BLOB can hold 64K of data while LONGTEXT and LONGBLOB (used primarily for binary data) can hold up to 4GB.
http://dev.mysql.com/doc/refman/5.0/en/storage-requirements.html
And yes, /n is fine for line delimiting

How to dynamically modify localization values in android app

We want to implement the following requirement for localization -
The parameter values stored in strings.xml (and other language variants) need to refreshed periodically (almost daily). This is because of some dynamic texts that needs to be displayed based on the language. The entries in the strings.xml can be added, modified or deleted. The values are fetched periodically (based on defined refresh policy) from a backend api call.
If my understanding is correct, then we cannot modify the strings.xml dynamically in the apk file.
We are comtemplating 2 possible approaches -
Make use of the device DB and load values from there (personally I dont like this approach very much as I am not able to predict the impact on performance. Any comments? )
Create a wrapper implementation to parse xml's and have these values stored in the specific xml.
Depending upon the language selected parse the corresponding xml and use that to populate the map. The values are then fetched from this maps (in place of android Resource file)
If anybody who has faced similar issues,
can you please provide your inputs and possible approach.
If there is something default in Android api that I am missing and can be used in this situation ?
Looking forward to people's input on the above.
The problem is you need to depend on Android's ability to discover the correct localization based on locale, screen size, orientation, etc. These are conditions that are outside of your ability to influence and you don't want to try to reproduce the search logic.
Perhaps you could put a tag string in each of the individual string.xml files. This tag would have a keyword, perhaps the name of a table that is filled at runtime with your translated strings.

Categories

Resources