Posts

Showing posts from February, 2019

Available Resources for iOS

I'll be adding to this as I go along. Limitations Some articles discussing the limitations of keyboards on iOS. limitations-of-custom-ios-keyboards The Trials and Tribulations... Keyboards available on Github Keyboards that work well on iPhone. You can check out their source code on Github. Lisu Keyboard Tasty Imitation Keyboard I'll be adding to this as I go along.

Lessons in iOS

Building a keyboard in iOS certainly has its challenges. Below I'll be listing some of the lessons I've learned while building my keyboard. Height It turns out that doing something simple like changing the height is quite complicated for iOS keyboards. These links were useful for me: Stack Overflow Some blog Methods we can override So it turns out that  textDidChange  is called when the selection changes and  textDidChange  is never called - go figure! More details here . I'll keep adding here as I go along.

Getting started - iOS

You'll probably want to start with Apple's Custom Keyboard guide .

Settings in Android

I'm not going to teach you how to writing an activity for settings here - that's kind of obvious. Instead I'm going to highlight a couple of interesting things you can do with settings on an Android Keyboard. Opening your settings page We want to be able to open our settings page from two places. From the launcher. Add LAUNCHER to AndroidManifest.xml , like so: <activity android:name=".MainActivity">     <intent-filter>         <action android:name="android.intent.action.MAIN" />         <category android:name="android.intent.category.LAUNCHER" />     </intent-filter> </activity> <service     android:name=".MyInputMethodService"     android:label="Konjugator Keyboard"     android:permission="android.permission.BIND_INPUT_METHOD"     >     <meta-data android:name="android.view.im" android:resource="@layout/method"/>     <intent-filter>

Using React Native in an Android Custom Keyboard

Disclaimer: I'm not very experienced with Android Java. If I've made a mistake, let me know. In this post, I'll show you how I got React Native working in a custom system keyboard in Android. React Native View Let's start with the Create a new file called xml/popup.xml . mReactRootView = new ReactRootView(this); mReactInstanceManager = ReactInstanceManager.builder()         .setApplication(getApplication())         .setBundleAssetName("index.android.bundle")         .setJSMainModulePath("index")         .addPackage(new MainReactPackage())         .setUseDeveloperSupport(BuildConfig.DEBUG)         .setInitialLifecycleState(LifecycleState.RESUMED)         .build(); mReactRootView.startReactApplication(mReactInstanceManager, "MyReactNativeApp", null); Custom Keyboards in Java Structure of your Java: Your service will extend InputMethodService . Your service will return a KeyboardView in onCreateInputView . You create this by inf

Popup Keyboard for Special Characters in Android

Popup Keyboard for Special Characters in Android It turns out that when you hold down a key, Android gives you the option of popping up another keyboard. I figured out many of the details from Stack Overflow . Step 1 Create a new file called xml/popup.xml . <?xml version="1.0" encoding="utf-8"?> <Keyboard xmlns:android="http://schemas.android.com/apk/res/android"     android:keyWidth="10%p"     android:horizontalGap="0px"     android:verticalGap="0px"     android:keyHeight="60dp"     > </Keyboard> Step 2 Replace the correct line in xml/keys_layout.xml . <Key android:codes="101" android:keyLabel="e" android:popupKeyboard="@xml/popup" android:popupCharacters="éèêë"/> Step 3 Add the following code to your Java. <Key android:codes="101" android:keyLabel="e" android:popupKeyboard="@xml/popup" android:popupChar

Suggestions in Android

One of the first things you may choose to add to your project is suggestions. There are probably many ways to do this. Here's how I did it. State I chose to store my state in some variables, alongside 'caps'. private boolean caps = false; private String composingText = ""; private String[] suggestions = {" ", " ", " "}; I'm not sure if this is the best way, but it's how I chose to proceed. Note that I chose the blank suggestions to consist of a single space, rather than an empty string, because if you set a Key's label to be an empty string, turning on caps/shift will cause the Android system to throw an error. setComposingText When we set up our project, we made use of Android Authority's tutorial. They use inputConnection's commitText, but inputConnection also has setComposingText. We're going to use both of these frequently, so let's create a useful method. private void setComposingText(St

Shift Keys on Android

Shift Keys on Android When you press the CAPS button, a little green dot appears. At this point, you might be wondering: why? Source code Diving into the Keyboard.java source code , we find the following: @Override public void onCreateInputView() { public static final int KEYCODE_SHIFT = -1; ... public boolean setShifted(boolean shiftState) {     for (Key shiftKey : mShiftKeys) {         if (shiftKey != null) {             shiftKey.on = shiftState;         }       }       if (mShifted != shiftState) {         mShifted = shiftState;         return true;     }       return false; } ... if (key.codes[0] == KEYCODE_SHIFT) {     // Find available shift key slot and put this shift key in it     for (int i = 0; i < mShiftKeys.length; i++) {         if (mShiftKeys[i] == null) {             mShiftKeys[i] = key;               mShiftKeyIndices[i] = mKeys.size()-1;             break;         }     }     mModifierKeys.add(key); } else if (key.codes[0] == KEYCODE_ALT) {     mModifierKeys.

Available Resources for Android

Available Resources for Android I wasn't able to find many good tutorials. As I mentioned on another post, you can start with Android Authority's blog or a copy of the source code . I learned about composing text from this article . Below are some other references you might find useful. Android Docs An obvious place to start, but a lot of details are missing. Keyboard KeyboardView InputMethodService Input Connection Keyboard.Key (xml) Keyboard.Row (xml) Other documentation from Android A working code example direct from Android - very useful !  Android Developer tutorial - pretty much the same as all the others Android Developer blog - again, not much new here Stack Overflow Popup Keyboard - useful for special characters Custom Theme Showing and hiding rows (also see my post) Links to code repos AnySoftKeyboard GaroKeypad SquareKeyboard Blogs Chris Black - lots of good links Let me know if you find anything else that adds to som