Android EditText - changing new input style - android

I'm trying to write a simple rich text editor application. I would like to be able to press different "style" buttons (e.g. bold, italic) to make all further inputs have that style, just like I could in an office application.
I was thinking I could have every new character be selected in a SpannableString and then change its style, but I don't know how I could do that. I tried setting an OnTextChangedListener but I later found out it's probably not suitable for what I want to do. If I knew how to listen for all new inputs I could probably figure something out, but I can't find anything that does that.
Any help is appreciated.

Please have a look at this eBay Open Source Android project called the Mildly Rich Text Editor that I am currently working on. It is a rich text editing library adapted from Droid Writer that makes use of spans. It can also be imported as a library in your application.
There is a demo app included in the repository that you can build and try out.
Note that there are some limitations noted in the "issues" section of the GitHub repository (e.g. it does not currently work with custom keyboards). Please also feel free to contribute.

you can get help with https://developer.android.com/training/keyboard-input/commands.html
you can use onkeypress or onclick event and check for that key with ASCII values of keys

Related

New Android keyboard behaving unexpectedly in certain apps

I am a linguist, not a programmer, sorry. I was asked and am adapting a keyboard for a minority language in Africa. I have spent a lot of time on this and am willing to learn more and to dig deeper.
I am using the latest Android Studio in Windows 10 and am working from a code sample from Google here:
https://android.googlesource.com/platform/development/+/master/samples/SoftKeyboard?autodive=0%2F
I managed to adapt this sample to our local language and compile and install in a several different phones from our team and all the new characters in the alphabet are working fine (ǝƎ ŋŊ ɖƉ ɔƆ ɛƐ ɩƖ ʊƱ). No problems here, this is just background for those who like that.
The unexpected behaviour is sadly with several existing keys, which I have not altered: apostrophe, quotation marks, hyphen, etc. Those are characters which to me "are too active"; possibly an escaping-problem or something the like.
When using my new keyboard in WhatsApp I can type any text just fine, until I need (for example) an apostrophe. Then the apostrophe will delete any alphabet-letter backwards until it hits a "resisting character" (those are space, full stop, comma and some others) and then it will show itself. Example sentence: "Three pigs' house."
I am typing this:
Three pigs
then I hit apostrophe and am expecting this:
Three pigs'
but instead I get this:
Three '
You can see how the apostrophe has deleted "pigs" and has been stopped by the space behind "Three". The same happens for - and for " and for a few other "bad keys".
I have this unwanted behaviour in several "powerful apps" like WhatsApp and Telegram but NOT in a simple text editor like this one:
https://play.google.com/store/apps/details?id=com.maxistar.textpad
I double-checked and compiled the original sample keyboard: It shows the same bad behaviour in WhatsApp, Telegram etc. but not in Simple Text Editor.
So the Google sample SoftKeyboard is having issues. I quote their doc:
Example of writing an input method for a soft keyboard. This code is
focused on simplicity over completeness, so it should in no way be considered
to be a complete soft keyboard implementation. Its purpose is to provide
a basic example for how you would get started writing an input method, to
be fleshed out as appropriate.
I would like help please:
Is this really a problem with the keyboard, or is the fault with WhatsApp etc. for "doing too much" with the characters being sent by the keyboard?
Or how can I find out where the deleting is happening? (Since this is only an input method, the Android Studio's debugging tools do not yet work for me.)
Is there a forum, where I can get help for that specific SoftKeyboard?
Any input to help me to change my self-made keyboard so that it behaves normally in any App which needs text-input, even WhatsApp, Telegram and the like.
Or is there another working template out there, which I could use to make a working soft keyboard for our language. Since I am not a pro, I am hoping for something that I can import into Android Studio for adapting.
Please do not yell at me. Any input and any help is welcome. I can upload my files, but the behaviour can be observed from the original SoftKeyboard files (see my first link at top). If you can type your own language, please be grateful. My people would also love to write their language in WhatsApp. Thank you.
First update:
I have looked over the main Keybaord.java file and have changed
mPredictionOn = true;
to
mPredictionOn = false;
for
case InputType.TYPE_CLASS_TEXT:
This has helped to calm the unexpected behaviour but has also lost some of the functionality. And the caps state is no longer auto-undoing like it is meant to be after user hits one capital letter.

Shown emojis are different to them chosen, why?

I just implemented this library in my android app (with your help):
https://github.com/ankushsachdeva/emojicon
It looks like this now:
As you can see, the smiley I picked from the menu looks different to the one send. Its another theme or someting like that.
Is this controlled by each smartphone itself? How does this work? Does anyone know? How can I fix that?
Thanks!
I think it depends on the OS, (smartphones, computers or any devices). Emojis are just unicode characters which have to be interpreted. And i was was surprised when i managed to compile a c/c++ program with emojis as std output on my Mac (and had a custom terminal prompt with lot of emojis). But obviously i don't think I could compile that on a Linux machine.
You should do something on your TextField so that it will correctly read the emojis, and not with the default behaviour/encoding.
Hope this will help you :
http://www.unicode.org/reports/tr51/index.html
The TextView you must be creating in the xml should be EmojiconTextView instead of normal TextView. Same way make your EditText as EmojiconEditText so that it can read the emoji as well.
If you want to understand why this is happening, then the answer is, Emojis are nothing but unicodes. Your TextViews and EditTexts needs to be taught how to read them. If you use normal EditText, it will read it the Android way, if you use EmojiconEditText, it will read it the library way.

How to develop an Android tool to be used for any text in any app

I'm an Android developer and I'm trying to figure out how to build a tool/app that suggests features to the user when highlighting any text on any other application.
Is that possible? I guess it will be similar to developing the "copy and paste" feature, but I just need to know from where to begin and what do I exactly need to achieve this.
EDITED:
Can I use "The Clipboard Framework" to listen for text selection?
Is that possible?
Generally speaking, no, for security reasons.
In this specific case, you could create your own input method editor (a.k.a., soft keyboard), which the user could elect to use, and you could find out when the user selects text in an EditText. But writing a good input method editor is not simple, and it will have no effect on, say, text highlighted in a Web browser.
Can I use "The Clipboard Framework" to listen for text selection?
No.
Mmmmmh, you must do all tutorials and read theory before you start programming anything.
If you don't want to do that, you could start doing things that are already done in tutorials and manuals.
By the way, try to do THIS tutorial, to learn the basics about save content and manipulating text. Then, this summary about writing text. And then, you can start thinking about aplications.

Create an Android Keyboard Dictionary

So I would like to know how to create a dictionary, like the english/spanish ones that are included already on the phone. What I want to do is put the english and spanish one together so that users do not have to switch between them, and also add words that are products of combining english and spanish together to make a word. How could I do this? What do I need? And I want to create the dictionary used by the keyboard, not a keyboard.
Thanks in advance!
Take a look at this: http://developer.android.com/resources/articles/creating-input-method.html
For an example with support for multiple input types and text prediction you can also have a look at the LatinIME source code. The Android SDK also includes a SoftKeyboard sample too.

Include Word Suggestions in Android Keyboard

Hi I want to include word suggestions in my custom keyboard.
e.g if I write wi it should suggest me whether you want to write "winner" "winks" "wilson" etc
Please guide me.
Thanks
Here is the real answer to this question.
It was hard for me to find:
First you need to:
Add Words to Android's UserDictionary
By having the words in the dictionary, they will show up in suggestions.
If you want to exclusively show your words however, then something like the auto-complete dropdown idea is a better fit (that the other answers linked)
You can search for source code for android keyboard that are having this suggestion bars, i.e. download source for android gingerbread 2.3 keyboard source code, as android is opensource you can get the code easily.

Categories

Resources