Is it possible to wrap default android keyboard - android

I am trying to implement extension to keyboard (input method).
I wonder if there is a defualt keyboard resourses/implementation which I can wrap. Eg if user presses 'Default kbd' block 'qwerty' is shown as default android keyboard, and i i press 'my extension' block qwerty replace with extension.
note: I looking for the way (if exists) to create custom input method without rebuilnd defualt keyboard, not the app only keyboard cover like this https://github.com/chiragjain/Emoticons-Keyboard

What you're trying to do unfortunately is not possible.
Try to find an open source keyboard implementation and build upon it.
See this GitHub repository for a working implementation of the default LatinIME, use it as your base.

You have to create your own custom keyboard to display such scenario. On your keyboard you can maintain two different layer at a time. So all you would need is KeyboardView class:
<android.inputmethodservice.KeyboardView
android:id="#+id/keyboardView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:visibility="gone"
android:keyBackground="#color/background_color"
android:keyTextColor="#37474F"
android:keyTextSize="20sp"
android:fontFamily="sans-serif"
android:background="#ECEFF1"/>
Resources to follow:
https://code.tutsplus.com/tutorials/create-a-custom-keyboard-on-android--cms-22615
http://www.fampennings.nl/maarten/android/09keyboard/index.htm
Though these examples would display example only on key representation you can easily add any xml as a keyboard layer.

You can try the next trick:
Detect the moment of the keyboard being shown.
Evaluate the bottom of your layout.
Show your UI just above the keyboard.
Hide your UI on the moment of keyboard hiding.
"2" and "3" are slightly different depending on the keyboard showing mode (adjustResiz or adjustPan).
Usefull links:
https://android-developers.googleblog.com/2009/04/updating-applications-for-on-screen.html
https://developer.android.com/training/keyboard-input/visibility.html
https://developer.android.com/guide/topics/manifest/activity-element.html#wsoft

Related

Android: How to remove customize keyboard button from keyboard?

Please find below the screenshot wherein the circular box shows the customize button option.
XMl Code:
<EditText
android:id="#+id/et_cost_per_mile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:hint="Cost Per Mile(₤)"
android:inputType="numberSigned"
/>
All I want to remove :: button from keyboard.
You have change input type like..
android:inputType="phone"
You can not. This is your android keyboard app and you cant change it. The keyboard settings can be modified in the android settings. But obviously it depends on the user, not the developer.
The only way I think it will allow you to do that is that you include in your app a fake numeric keypad as a layer (Similar to the keyboard that appears when you have to type the pin of the app of your bank). However, I don't think this is worth it. With...
android:inputType = "numberSigned"
you are already blocking the user from entering letters or other characters, even if they change their keyboard.

Stop EditText from bringing up the keyboard on Activity start?

I have an Edit Text in one of my App layouts, and I want this EditText to only open the keyboard (I believe this is called being focused on?) when it is actually touched.
As of now, the keyboard opens with the EditText whenever the app opens, which isn't what I want.
I have tried many different XML tags to fix this:
android:focusable="false" <--- Prevents keyboard from opening at all.
android:focusable="true"
android:focusableInTouchMode = "true" <--- These tags give me the same result as no tags (keybaord will open on activity start)
android:focusedByDefault = "true" <--- Only available in API >= 23
What I am asking is, why is it so hard to disable default focus on an EditText? Surely I am missing an easy way to do this.
EDIT: Adding this line to my AndroidManifest fixed the issue:
android:windowSoftInputMode="stateHidden"
However, I don't like this solution. It seems like since this is in the Manifest, it will affect more UI elements than the single EditText I need to change.
Alternatively you can set the focus to the root layout element:
android:focusable="true"
android:focusableInTouchMode="true"
Example:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:focusable="true"
android:focusableInTouchMode="true">
<EditText
android:inputType="text"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
Use android:windowSoftInputMode="stateHidden"
If you dig deep into the Theme you are using for your Activity, you will find that the default value of windowSoftInputMode is stateUnspecified|adjustPan. And from the documentation:
stateUnspecified: Not specified, use what the system thinks is best. This is the default.
So depending on the the android device you run, your results will vary. I tried reproducing your case in API-26 emulator and the keyboard doesn't show up.You can use stateHidden to ensure that when an activity starts, the soft keyboard doesn't show up when the EditText gets focused on itself.
The other way to solve this is to requestFocus to some other element in the UI, making sure the EditText is not the first UI element to get focused. In my experience this is kind of a hack and it messes up the accessibility. The safest and clean way to accomplish is actually to use stateHidden.
stateHidden: Make the soft input area hidden when normally appropriate (when the user is navigating forward to your window).
Note that this will not affect any other UI elements. You can use adjustPan also to this, based on the screen background.

Isn't windowsoftinputmode = adjustResize supposed to move ALL the activity window to make room for the keyboard?

I'm working on a chat feature for an app an stumbled across the following issue.
I have an activity with android:windowsotinputmode = "stateHidden|adjustResize" (when the activity starts, the keyboard doesn't pop automatically up but waits until the user taps on the editText to type his message and after, the whole activity screen should slide up and make room for the soft keyboard).
However...
I noticed that the activity only slides up until the keyboard is right below the editText, covering the 'random view' at the bottom of the activity.
Is there a way to override this and make the screen move up completely and make visible the whole activity?
[EDIT] I should also mention that setting any paddingBottom/marginBottom to the editText gets ignored as well as the view.
You could go through this link and the code,could help you:
http://android-developers.blogspot.in/2009/04/updating-applications-for-on-screen.html
<EditText android:id="#+id/edtInput"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:inputType="textShortMessage|textAutoCorrect|textCapSentences|textMultiLine"
android:imeOptions="actionSend|flagNoEnterAction"
android:maxLines="4"
android:maxLength="2000"
android:hint="#string/compose_hint"/>

MultiAutoCompleteTextView not showing keyboard suggestions

I'm using MultiAutoCompleteTextView in my app. It's an awesome control in Android API. But there are a few issues I'm facing. One, the most annoying is, that on my Nexus 5, it doesnot shows keyboard suggestions. On Xperia Z, shows keyboard suggestions though. Unable to find the cause. Can anybody help/guide me about it? Here the XML of my MultiAutoCompleteTextView.
<MultiAutoCompleteTextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:hint="Post a question, idea or update"
android:gravity="top"
android:textColorHint="#9e9e9e"
android:textColor="#000000"
android:textSize="15sp"
android:padding="10dp"
android:background="#null" />
I have looked into the source code and found this in AutoCompleteTextView
// Always turn on the auto complete input type flag, since it
// makes no sense to use this widget without it.
int inputType = getInputType();
if ((inputType&EditorInfo.TYPE_MASK_CLASS)
== EditorInfo.TYPE_CLASS_TEXT) {
inputType |= EditorInfo.TYPE_TEXT_FLAG_AUTO_COMPLETE;
setRawInputType(inputType);
}
And in the javaDoc page of the InputType, TYPE_TEXT_FLAG_AUTO_COMPLETE defined as.
Flag for TYPE_CLASS_TEXT: the text editor (which means the application) is performing auto-completion of the text being entered based on its own semantics, which it will present to the user as they type.
It means that you have your own semantics for completion, which means that it is logical for the keyboard to disable its suggestions.
I think when you change the inputType with setInputType() method programatically you can disable this behaviour and get the keyboard suggestions.
You can try this:
mAutoCompletetextView.setInputType(EditText.TYPE_CLASS_TEXT | EditText.TYPE_TEXT_FLAG_AUTO_CORRECT);

How can I add one extra row of key to the default android keyboard?

I have been messing around with custom keyboards but cannot achieve what I want.
I tried to follow various tutorials (like this one How can I implement special soft keyboard) but could not build my own keyboard since there is always missing some part.
I also tried the sample SoftKeyboard that comes with the API 10 samples but the layout did not suit my app.
Now, all I want to have is a the default android 4.3 softkeyboard, that instead of giving the option to switch to the numeric view in the bottom left corner (I am referring to the ?123button) , adds another row of keys to the top. That row should hold the keys '0' to '9'.
Can someone help me out here? I would really appreciate it!
Adding extra row to the android default keyboard is not possible for this you have to go to the custom keyboard..Custom keyboard is not much difficult to understand here is the best example of android custom keyboards..
1.Custom keyboard example-1
2.Custom keyboard example-2
Once go to the xml file in the res/xml folder and define keys whatever you want..and no of rows and columns for keyboard..
In your layout definig the keyboardview set android:keyBackground="#drawable/keyboardview_selector" color whatever you want..
<android.inputmethodservice.KeyboardView
android:id="#+id/keyboardview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10dp"
android:background="#android:color/transparent"
android:focusable="true"
android:focusableInTouchMode="true"
android:keyBackground="#drawable/keyboardview_selector" />

Categories

Resources