├── README.md
└── SimpleKeyboard
├── .classpath
├── .project
├── .settings
└── org.eclipse.jdt.core.prefs
├── AndroidManifest.xml
├── gen
└── com
│ └── hathy
│ └── simplekeyboard
│ ├── BuildConfig.java
│ └── R.java
├── ic_launcher-web.png
├── libs
└── android-support-v4.jar
├── proguard-project.txt
├── project.properties
├── res
├── drawable-hdpi
│ └── ic_launcher.png
├── drawable-mdpi
│ └── ic_launcher.png
├── drawable-xhdpi
│ └── ic_launcher.png
├── drawable-xxhdpi
│ └── ic_launcher.png
├── drawable
│ └── key_background.xml
├── layout
│ ├── keyboard.xml
│ └── preview.xml
├── values-v11
│ └── styles.xml
├── values-v14
│ └── styles.xml
├── values
│ ├── strings.xml
│ └── styles.xml
└── xml
│ ├── method.xml
│ └── qwerty.xml
└── src
└── com
└── hathy
└── simplekeyboard
└── SimpleIME.java
/README.md:
--------------------------------------------------------------------------------
1 | ### Tuts+ Tutorial: Create A Custom Keyboard on Android
2 |
3 | #### Instructor: Ashraff Hathibelagal
4 |
5 | If you are not satisfied with the keyboard that you are currently using, perhaps it is time for you to make one yourself. This step-by-step tutorial will show you how to create a basic, yet complete, keyboard with a custom layout for your Android device.
6 |
7 | Source files for the Tuts+ tutorial: [Create A Custom Keyboard on Android](http://code.tutsplus.com/tutorials/create-a-custom-keyboard-on-android--cms-22615)
8 |
9 | **Read this tutorial on [Tuts+](https://code.tutsplus.com)**
10 |
--------------------------------------------------------------------------------
/SimpleKeyboard/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/SimpleKeyboard/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | SimpleKeyboard
4 |
5 |
6 |
7 |
8 |
9 | com.android.ide.eclipse.adt.ResourceManagerBuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.PreCompilerBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 |
30 | com.android.ide.eclipse.adt.AndroidNature
31 | org.eclipse.jdt.core.javanature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/SimpleKeyboard/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
3 | org.eclipse.jdt.core.compiler.compliance=1.6
4 | org.eclipse.jdt.core.compiler.source=1.6
5 |
--------------------------------------------------------------------------------
/SimpleKeyboard/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
9 |
10 |
15 |
16 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/SimpleKeyboard/gen/com/hathy/simplekeyboard/BuildConfig.java:
--------------------------------------------------------------------------------
1 | /** Automatically generated file. DO NOT MODIFY */
2 | package com.hathy.simplekeyboard;
3 |
4 | public final class BuildConfig {
5 | public final static boolean DEBUG = true;
6 | }
--------------------------------------------------------------------------------
/SimpleKeyboard/gen/com/hathy/simplekeyboard/R.java:
--------------------------------------------------------------------------------
1 | /* AUTO-GENERATED FILE. DO NOT MODIFY.
2 | *
3 | * This class was automatically generated by the
4 | * aapt tool from the resource data it found. It
5 | * should not be modified by hand.
6 | */
7 |
8 | package com.hathy.simplekeyboard;
9 |
10 | public final class R {
11 | public static final class attr {
12 | }
13 | public static final class drawable {
14 | public static final int ic_launcher=0x7f020000;
15 | public static final int key_background=0x7f020001;
16 | }
17 | public static final class id {
18 | public static final int keyboard=0x7f070000;
19 | }
20 | public static final class layout {
21 | public static final int keyboard=0x7f030000;
22 | public static final int preview=0x7f030001;
23 | }
24 | public static final class string {
25 | public static final int app_name=0x7f050000;
26 | public static final int simple_ime=0x7f050001;
27 | public static final int subtype_en_US=0x7f050002;
28 | }
29 | public static final class style {
30 | /**
31 | Base application theme, dependent on API level. This theme is replaced
32 | by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
33 |
34 |
35 | Theme customizations available in newer API levels can go in
36 | res/values-vXX/styles.xml, while customizations related to
37 | backward-compatibility can go here.
38 |
39 |
40 | Base application theme for API 11+. This theme completely replaces
41 | AppBaseTheme from res/values/styles.xml on API 11+ devices.
42 |
43 | API 11 theme customizations can go here.
44 |
45 | Base application theme for API 14+. This theme completely replaces
46 | AppBaseTheme from BOTH res/values/styles.xml and
47 | res/values-v11/styles.xml on API 14+ devices.
48 |
49 | API 14 theme customizations can go here.
50 | */
51 | public static final int AppBaseTheme=0x7f060000;
52 | /** Application theme.
53 | All customizations that are NOT specific to a particular API-level can go here.
54 | */
55 | public static final int AppTheme=0x7f060001;
56 | }
57 | public static final class xml {
58 | public static final int method=0x7f040000;
59 | public static final int qwerty=0x7f040001;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/SimpleKeyboard/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tutsplus/Android-CustomKeyboard/f43f3eb6495b1ef001e41264b086a07012890409/SimpleKeyboard/ic_launcher-web.png
--------------------------------------------------------------------------------
/SimpleKeyboard/libs/android-support-v4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tutsplus/Android-CustomKeyboard/f43f3eb6495b1ef001e41264b086a07012890409/SimpleKeyboard/libs/android-support-v4.jar
--------------------------------------------------------------------------------
/SimpleKeyboard/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # To enable ProGuard in your project, edit project.properties
2 | # to define the proguard.config property as described in that file.
3 | #
4 | # Add project specific ProGuard rules here.
5 | # By default, the flags in this file are appended to flags specified
6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 | # You can edit the include path and order by changing the ProGuard
8 | # include property in project.properties.
9 | #
10 | # For more details, see
11 | # http://developer.android.com/guide/developing/tools/proguard.html
12 |
13 | # Add any project specific keep options here:
14 |
15 | # If your project uses WebView with JS, uncomment the following
16 | # and specify the fully qualified class name to the JavaScript interface
17 | # class:
18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 | # public *;
20 | #}
21 |
--------------------------------------------------------------------------------
/SimpleKeyboard/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=android-19
15 |
--------------------------------------------------------------------------------
/SimpleKeyboard/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tutsplus/Android-CustomKeyboard/f43f3eb6495b1ef001e41264b086a07012890409/SimpleKeyboard/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/SimpleKeyboard/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tutsplus/Android-CustomKeyboard/f43f3eb6495b1ef001e41264b086a07012890409/SimpleKeyboard/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/SimpleKeyboard/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tutsplus/Android-CustomKeyboard/f43f3eb6495b1ef001e41264b086a07012890409/SimpleKeyboard/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/SimpleKeyboard/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tutsplus/Android-CustomKeyboard/f43f3eb6495b1ef001e41264b086a07012890409/SimpleKeyboard/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/SimpleKeyboard/res/drawable/key_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 | -
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/SimpleKeyboard/res/layout/keyboard.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/SimpleKeyboard/res/layout/preview.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
--------------------------------------------------------------------------------
/SimpleKeyboard/res/values-v11/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/SimpleKeyboard/res/values-v14/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/SimpleKeyboard/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | SimpleKeyboard
4 | Simple IME
5 | English (US)
6 |
7 |
--------------------------------------------------------------------------------
/SimpleKeyboard/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
14 |
15 |
16 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/SimpleKeyboard/res/xml/method.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
8 |
9 |
--------------------------------------------------------------------------------
/SimpleKeyboard/res/xml/qwerty.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/SimpleKeyboard/src/com/hathy/simplekeyboard/SimpleIME.java:
--------------------------------------------------------------------------------
1 | package com.hathy.simplekeyboard;
2 | import android.inputmethodservice.InputMethodService;
3 | import android.inputmethodservice.Keyboard;
4 | import android.inputmethodservice.KeyboardView;
5 | import android.inputmethodservice.KeyboardView.OnKeyboardActionListener;
6 | import android.media.AudioManager;
7 | import android.view.KeyEvent;
8 | import android.view.View;
9 | import android.view.inputmethod.InputConnection;
10 |
11 | public class SimpleIME extends InputMethodService
12 | implements OnKeyboardActionListener{
13 |
14 | private KeyboardView kv;
15 | private Keyboard keyboard;
16 |
17 | private boolean caps = false;
18 |
19 | @Override
20 | public View onCreateInputView() {
21 | kv = (KeyboardView)getLayoutInflater().inflate(R.layout.keyboard, null);
22 | keyboard = new Keyboard(this, R.xml.qwerty);
23 | kv.setKeyboard(keyboard);
24 | kv.setOnKeyboardActionListener(this);
25 | kv.invalidateAllKeys();
26 | return kv;
27 | }
28 |
29 | @Override
30 | public void onKey(int primaryCode, int[] keyCodes) {
31 | InputConnection ic = getCurrentInputConnection();
32 | playClick(primaryCode);
33 | switch(primaryCode){
34 | case Keyboard.KEYCODE_DELETE :
35 | ic.deleteSurroundingText(1, 0);
36 | break;
37 | case Keyboard.KEYCODE_SHIFT:
38 | caps = !caps;
39 | keyboard.setShifted(caps);
40 | kv.invalidateAllKeys();
41 | break;
42 | case Keyboard.KEYCODE_DONE:
43 | ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_ENTER));
44 | break;
45 | default:
46 | char code = (char)primaryCode;
47 | if(Character.isLetter(code) && caps){
48 | code = Character.toUpperCase(code);
49 | }
50 | ic.commitText(String.valueOf(code),1);
51 | }
52 | }
53 |
54 | private void playClick(int keyCode){
55 | AudioManager am = (AudioManager)getSystemService(AUDIO_SERVICE);
56 | switch(keyCode){
57 | case 32:
58 | am.playSoundEffect(AudioManager.FX_KEYPRESS_SPACEBAR);
59 | break;
60 | case Keyboard.KEYCODE_DONE:
61 | case 10:
62 | am.playSoundEffect(AudioManager.FX_KEYPRESS_RETURN);
63 | break;
64 | case Keyboard.KEYCODE_DELETE:
65 | am.playSoundEffect(AudioManager.FX_KEYPRESS_DELETE);
66 | break;
67 | default: am.playSoundEffect(AudioManager.FX_KEYPRESS_STANDARD);
68 | }
69 | }
70 |
71 | @Override
72 | public void onPress(int primaryCode) {
73 | }
74 |
75 | @Override
76 | public void onRelease(int primaryCode) {
77 | }
78 |
79 | @Override
80 | public void onText(CharSequence text) {
81 | }
82 |
83 | @Override
84 | public void swipeDown() {
85 | }
86 |
87 | @Override
88 | public void swipeLeft() {
89 | }
90 |
91 | @Override
92 | public void swipeRight() {
93 | }
94 |
95 | @Override
96 | public void swipeUp() {
97 | }
98 | }
99 |
--------------------------------------------------------------------------------