├── .gitignore
├── .idea
└── vcs.xml
├── LICENSE
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── alanszlosek
│ │ └── keying
│ │ └── ApplicationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── alanszlosek
│ │ │ └── keying
│ │ │ ├── Keying.java
│ │ │ └── LatinKeyboard.java
│ └── res
│ │ ├── drawable
│ │ ├── sym_keyboard_delete.png
│ │ ├── sym_keyboard_done.png
│ │ ├── sym_keyboard_return.png
│ │ ├── sym_keyboard_search.png
│ │ ├── sym_keyboard_shift.png
│ │ └── sym_keyboard_space.png
│ │ ├── layout
│ │ └── input.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ │ └── xml
│ │ ├── method.xml
│ │ ├── qwerty.xml
│ │ └── symbols.xml
│ └── test
│ └── java
│ └── com
│ └── alanszlosek
│ └── keying
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── notes.txt
├── readme.markdown
├── screenshot.png
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
20 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.2"
6 |
7 | defaultConfig {
8 | applicationId "com.alanszlosek.keying"
9 | minSdkVersion 10
10 | targetSdkVersion 23
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | testCompile 'junit:junit:4.12'
25 | compile 'com.android.support:appcompat-v7:23.2.0'
26 | }
27 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /home/alan/Android/Sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/alanszlosek/keying/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.alanszlosek.keying;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/java/com/alanszlosek/keying/Keying.java:
--------------------------------------------------------------------------------
1 |
2 | package com.alanszlosek.keying;
3 |
4 | import android.inputmethodservice.InputMethodService;
5 | import android.inputmethodservice.Keyboard;
6 | import android.inputmethodservice.KeyboardView;
7 | import android.util.Log;
8 | import android.view.KeyEvent;
9 | import android.view.View;
10 | import android.view.inputmethod.EditorInfo;
11 | import android.view.inputmethod.InputConnection;
12 |
13 | /**
14 | * A different take on an on-screen keyboard for those whose dislike auto-correct
15 | * and have difficulty aiming their thumbs.
16 | *
17 | * Created using the android SoftKeyboard example as a starting point
18 | */
19 | public class Keying extends InputMethodService implements KeyboardView.OnKeyboardActionListener {
20 | // Starting over
21 | private long mKeyDownStart = 0;
22 | private long longPressThreshold = 150;
23 | /*
24 | SYMBOL KEYBOARD LAYOUT
25 | 7 8 9 + '[ "] @#
26 | 4 5 6 -_ () `~ $%
27 | 1 2 3 * , :; ^&
28 | 0 . = /\ ? !| D
29 | */
30 | private String mappings = new String("qwuiopasklzx'[\"]@#-_()`~$%:;^&/\\!|");
31 |
32 |
33 | private KeyboardView mInputView;
34 |
35 | private StringBuilder mComposing = new StringBuilder();
36 | private boolean mPredictionOn = false;
37 |
38 | // Not entirely certain I need LatinKeyboard class yet ... it seems to use super() a lot
39 | private LatinKeyboard mSymbolsKeyboard;
40 | private LatinKeyboard mQwertyKeyboard;
41 |
42 | // Pointer to the current keyboard being used
43 | private LatinKeyboard mCurKeyboard;
44 |
45 | private String mWordSeparators;
46 |
47 | // CALLBACKS ARE ROUGHLY IN THE ORDER I'VE SEEN THEM CALLED
48 |
49 | // Called by the system when the service is first created
50 | @Override
51 | public void onCreate() {
52 | super.onCreate();
53 | debug("onCreate");
54 |
55 | mWordSeparators = getResources().getString(R.string.word_separators);
56 | }
57 |
58 | // Initialize UI here. Called when service is first created and after config changes
59 | @Override
60 | public void onInitializeInterface() {
61 | debug("onInitializeInterface");
62 |
63 | // Re-create keyboards to reflect (possibly new) display width
64 | mQwertyKeyboard = new LatinKeyboard(this, R.xml.qwerty);
65 | mSymbolsKeyboard = new LatinKeyboard(this, R.xml.symbols);
66 | }
67 |
68 | // Upon this call you know that getCurrentInputBinding() and getCurrentInputConnection() return valid objects.
69 | @Override
70 | public void onBindInput() {
71 | debug("onBindInput");
72 |
73 | }
74 |
75 | /**
76 | * Called to inform the input method that text input has started in an editor.
77 | * You should use this callback to initialize the state of your input to match
78 | * the state of the editor given to it.
79 | */
80 | @Override public void onStartInput(EditorInfo attribute, boolean restarting) {
81 | super.onStartInput(attribute, restarting);
82 | debug("onStartInput");
83 |
84 | // Initialize based on type of text we're editing
85 | switch (attribute.inputType & EditorInfo.TYPE_MASK_CLASS) {
86 | case EditorInfo.TYPE_CLASS_NUMBER:
87 | case EditorInfo.TYPE_CLASS_DATETIME:
88 | mCurKeyboard = mSymbolsKeyboard;
89 | break;
90 |
91 | case EditorInfo.TYPE_CLASS_PHONE:
92 | mCurKeyboard = mSymbolsKeyboard;
93 | break;
94 |
95 | case EditorInfo.TYPE_CLASS_TEXT:
96 | mCurKeyboard = mQwertyKeyboard;
97 | // Check whether the keyboard should start out shifted
98 | updateShiftKeyState(attribute);
99 | break;
100 |
101 | default:
102 | mCurKeyboard = mQwertyKeyboard;
103 | updateShiftKeyState(attribute);
104 | }
105 |
106 | // Update the label on the enter key, depending on what the application
107 | // says it will do.
108 | mCurKeyboard.setImeOptions(getResources(), attribute.imeOptions);
109 | }
110 |
111 | /**
112 | * Create and return the view hierarchy used for the input area (such as a soft keyboard).
113 | * This will be called once, when the input area is first displayed
114 | */
115 | @Override
116 | public View onCreateInputView() {
117 | debug("onCreateInputView");
118 | mInputView = (KeyboardView) getLayoutInflater().inflate(R.layout.input, null);
119 | mInputView.setOnKeyboardActionListener(this);
120 | mInputView.setKeyboard(mCurKeyboard);
121 | mInputView.setPreviewEnabled(false);
122 | return mInputView;
123 | }
124 |
125 | @Override
126 | public void onStartInputView(EditorInfo attribute, boolean restarting) {
127 | super.onStartInputView(attribute, restarting);
128 | debug("onStartInputView");
129 |
130 | mInputView.closing();
131 | // Apply the selected keyboard to the input view.
132 | mInputView.setKeyboard(mCurKeyboard);
133 |
134 | // Reset composing buffer
135 | mComposing.setLength(0);
136 | }
137 |
138 | /**
139 | * Called to inform the input method that text input has finished in the last editor.
140 | * The default implementation uses the InputConnection to clear any active composing text.
141 | */
142 | @Override
143 | public void onFinishInput() {
144 | super.onFinishInput();
145 | debug("onFinishInput");
146 |
147 | // Necessary?
148 | if (mInputView != null) {
149 | mInputView.closing();
150 | }
151 | }
152 |
153 | @Override
154 | public void onFinishInputView(boolean finishingInput) {
155 | super.onFinishInputView(finishingInput);
156 | }
157 |
158 | // After this method, getCurrentInputBinding() and getCurrentInputConnection()
159 | // will no longer return valid objects.
160 | @Override
161 | public void onUnbindInput() {
162 | debug("onUnbindInput");
163 | }
164 |
165 | @Override
166 | public void onDestroy() {
167 | debug("onDestroy");
168 | }
169 |
170 | /**
171 | * Override this to intercept key down events before they are processed by the application.
172 | * If you return true, the application will not process the event itself.
173 | * If you return false, the normal application processing will occur as if the IME
174 | * had not seen the event at all.
175 | */
176 | @Override
177 | public boolean onKeyDown(int keyCode, KeyEvent event) {
178 | debug("onKeyDown");
179 | switch (keyCode) {
180 | case KeyEvent.KEYCODE_BACK:
181 | if (event.getRepeatCount() == 0 && mInputView != null) {
182 | if (mInputView.handleBack()) {
183 | return true;
184 | }
185 | }
186 | break;
187 |
188 | case KeyEvent.KEYCODE_DEL:
189 | // Special handling of the delete key: if we currently are
190 | // composing text for the user, we want to modify that instead
191 | // of let the application to the delete itself.
192 | if (mComposing.length() > 0) {
193 | //onKey(Keyboard.KEYCODE_DELETE, null);
194 | return true;
195 | }
196 | break;
197 |
198 | case KeyEvent.KEYCODE_ENTER:
199 | // Let the underlying text editor always handle these.
200 | return false;
201 |
202 | default:
203 | }
204 |
205 | return super.onKeyDown(keyCode, event);
206 | }
207 |
208 | // Sibling to onKeyDown()
209 | @Override
210 | public boolean onKeyUp(int keyCode, KeyEvent event) {
211 | debug("onKeyUp");
212 | return super.onKeyUp(keyCode, event);
213 | }
214 |
215 | /**
216 | * Helper function to commit any text being composed in to the editor.
217 | */
218 | private void commitTyped() {
219 | InputConnection inputConnection = getCurrentInputConnection();
220 | if (mComposing.length() > 0) {
221 | inputConnection.commitText(mComposing, 1);
222 | mComposing.setLength(0);
223 | }
224 | }
225 |
226 | /**
227 | * Helper to update the shift state of our keyboard based on the initial
228 | * editor state.
229 | */
230 | private void updateShiftKeyState(EditorInfo attr) {
231 | // think this is the cause of why it got stuck in caps-mode
232 | if (attr != null && mInputView != null && mQwertyKeyboard == mInputView.getKeyboard()) {
233 | int caps = 0;
234 | if (attr.inputType != EditorInfo.TYPE_NULL) {
235 | caps = getCurrentInputConnection().getCursorCapsMode(attr.inputType);
236 | }
237 | mInputView.setShifted(caps != 0);
238 | }
239 | }
240 |
241 | /**
242 | * Helper to determine if a given character code is alphabetic.
243 | */
244 | private boolean isAlphabet(int code) {
245 | if (Character.isLetter(code)) {
246 | return true;
247 | } else {
248 | return false;
249 | }
250 | }
251 |
252 | /**
253 | * Helper to send a key down / key up pair to the current editor.
254 | */
255 | private void keyDownUp(int keyEventCode) {
256 | debug("keyDownUp");
257 | getCurrentInputConnection().sendKeyEvent( new KeyEvent(KeyEvent.ACTION_DOWN, keyEventCode));
258 | getCurrentInputConnection().sendKeyEvent( new KeyEvent(KeyEvent.ACTION_UP, keyEventCode));
259 | }
260 |
261 | /**
262 | * Helper to send a character to the editor as raw key events.
263 | */
264 | private void sendKey(int keyCode) {
265 | debug(String.format("sendKey %d", keyCode));
266 | switch (keyCode) {
267 | case '\n':
268 | keyDownUp(KeyEvent.KEYCODE_ENTER);
269 | break;
270 | default:
271 | if (keyCode >= '0' && keyCode <= '9') {
272 | keyDownUp(keyCode - '0' + KeyEvent.KEYCODE_0);
273 | } else {
274 | getCurrentInputConnection().commitText(String.valueOf((char) keyCode), 1);
275 | }
276 | break;
277 | }
278 | }
279 |
280 | // should delete 2 words/second if long pressing
281 | public void handleBackspace() {
282 | final int length = mComposing.length();
283 | if (length > 0) {
284 | mComposing.delete(length - 1, length);
285 | getCurrentInputConnection().setComposingText(mComposing, 1);
286 | } else {
287 | keyDownUp(KeyEvent.KEYCODE_DEL);
288 | }
289 | // Re-build composing text
290 | updateShiftKeyState(getCurrentInputEditorInfo());
291 | }
292 |
293 | // pretty certain this logic is failing somewhere ... got stuck in caps mode
294 | private void handleShift() {
295 | debug("handleShift");
296 | if (mInputView == null) {
297 | return;
298 | }
299 |
300 | Keyboard currentKeyboard = mInputView.getKeyboard();
301 | if (currentKeyboard == mQwertyKeyboard) {
302 | debug("handleShift,qwerty");
303 | // Toggle current shift state
304 | mInputView.setShifted(!mInputView.isShifted());
305 |
306 | } else if (currentKeyboard == mSymbolsKeyboard) {
307 | debug("handleShift,symbols");
308 | //mInputView.setKeyboard(mSymbolsShiftedKeyboard);
309 |
310 | }
311 | /*
312 | else if (currentKeyboard == mSymbolsShiftedKeyboard) {
313 | debug("handleShift,symbolsShifted");
314 | mInputView.setKeyboard(mSymbolsKeyboard);
315 | }
316 | */
317 | }
318 |
319 | private void handleCharacter(int primaryCode) {
320 | debug(String.format("handleCharacter %c", (char)primaryCode));
321 | if (isInputViewShown()) {
322 | if (mInputView.isShifted()) {
323 | primaryCode = Character.toUpperCase(primaryCode);
324 | }
325 | }
326 | if (isAlphabet(primaryCode) && mPredictionOn) {
327 | mComposing.append((char) primaryCode);
328 | getCurrentInputConnection().setComposingText(mComposing, 1);
329 | // eh?
330 | updateShiftKeyState(getCurrentInputEditorInfo());
331 | } else {
332 | getCurrentInputConnection().commitText( String.valueOf((char) primaryCode), 1);
333 | }
334 | }
335 |
336 | public void handleClose() {
337 | commitTyped();
338 | requestHideSelf(0);
339 | mInputView.closing();
340 | }
341 |
342 | private String getWordSeparators() {
343 | return mWordSeparators;
344 | }
345 |
346 | public boolean isWordSeparator(int code) {
347 | String separators = getWordSeparators();
348 | return separators.contains(String.valueOf((char)code));
349 | }
350 |
351 |
352 | // OnKeyboardActionListener CALLBACKS
353 |
354 | /**
355 | * NOTE: Don't change the current keyboard during press events.
356 | * Wait until the key has been released or the app will crash.
357 | */
358 | public void onPress(int primaryCode) {
359 | debug("onPress");
360 |
361 | // Track when this key was pressed so we can determine short or long press in onRelease()
362 | mKeyDownStart = System.currentTimeMillis();
363 | }
364 |
365 | // Ignore this callback for most keys. We'll use onPress and onRelease
366 | // to handle long and short press detection.
367 | // This is still handy because it fires repeatedly when delete is held down
368 | public void onKey(int primaryCode, int[] keyCodes) {
369 | debug(String.format("onKey %c %d", (char)primaryCode, primaryCode));
370 | if (primaryCode == Keyboard.KEYCODE_DELETE) {
371 | handleBackspace();
372 |
373 | // Show a menu or somethin'
374 | } else if (primaryCode == Keyboard.KEYCODE_MODE_CHANGE && mInputView != null) {
375 | Keyboard current = mInputView.getKeyboard();
376 | if (current == mSymbolsKeyboard) {
377 | current = mQwertyKeyboard;
378 | } else {
379 | current = mSymbolsKeyboard;
380 | }
381 | mInputView.setKeyboard(current);
382 | if (current == mSymbolsKeyboard) {
383 | // shouldn't this check the input connection state?
384 | current.setShifted(false);
385 | }
386 | }
387 | return;
388 | }
389 |
390 | public void onRelease(int primaryCode) {
391 | long diff;
392 | int i;
393 | int code;
394 |
395 | if (
396 | primaryCode == Keyboard.KEYCODE_DELETE
397 | ||
398 | primaryCode == Keyboard.KEYCODE_CANCEL
399 | ||
400 | primaryCode == Keyboard.KEYCODE_MODE_CHANGE
401 | ) {
402 | // We ignore these special keys
403 | debug(String.format("onRelease code %d", primaryCode));
404 |
405 | } else if (primaryCode == Keyboard.KEYCODE_SHIFT) {
406 | handleShift();
407 |
408 | } else {
409 | // Detect long or short press here
410 | diff = System.currentTimeMillis() - mKeyDownStart;
411 | debug(String.format("onRelease after %d ms", diff));
412 | if (diff > longPressThreshold) {
413 | // Does the pressed key have more than 1 character associated with it?
414 | i = mappings.indexOf(primaryCode);
415 | if (i == -1) {
416 | // Nope, pass the character code through
417 |
418 | code = primaryCode;
419 | } else {
420 | // Yes, pass the sibling character code
421 | code = mappings.codePointAt( i+1 );
422 | }
423 | } else {
424 | code = primaryCode;
425 | }
426 |
427 |
428 | if (isWordSeparator(code)) {
429 | debug("onRelease,isWordSeparator");
430 | // Handle separator
431 | if (mComposing.length() > 0) {
432 | commitTyped();
433 | }
434 | sendKey(code);
435 | updateShiftKeyState(getCurrentInputEditorInfo());
436 | } else {
437 | handleCharacter( code );
438 | }
439 | }
440 | }
441 |
442 |
443 | // Have never seen this called
444 | public void onText(CharSequence text) {
445 | debug("onText");
446 | InputConnection ic = getCurrentInputConnection();
447 | if (ic == null) return;
448 | ic.beginBatchEdit();
449 | if (mComposing.length() > 0) {
450 | commitTyped();
451 | }
452 | ic.commitText(text, 0);
453 | ic.endBatchEdit();
454 | updateShiftKeyState(getCurrentInputEditorInfo());
455 | }
456 |
457 |
458 | @Override
459 | public void swipeRight() {
460 | debug("swipeRight");
461 | }
462 |
463 | @Override
464 | public void swipeLeft() {
465 | debug("swipeLeft");
466 | handleBackspace();
467 | }
468 |
469 | @Override
470 | public void swipeDown() {
471 | debug("swipeDown");
472 | handleClose();
473 | }
474 |
475 | @Override
476 | public void swipeUp() {
477 | }
478 |
479 |
480 | public void debug(String message) {
481 | Log.d("Keying", message);
482 | }
483 | }
484 |
--------------------------------------------------------------------------------
/app/src/main/java/com/alanszlosek/keying/LatinKeyboard.java:
--------------------------------------------------------------------------------
1 |
2 |
3 | package com.alanszlosek.keying;
4 |
5 | import android.content.Context;
6 | import android.content.res.Resources;
7 | import android.content.res.XmlResourceParser;
8 | import android.inputmethodservice.Keyboard;
9 | import android.view.inputmethod.EditorInfo;
10 |
11 | public class LatinKeyboard extends Keyboard {
12 |
13 |
14 | private Key mEnterKey;
15 |
16 | public LatinKeyboard(Context context, int xmlLayoutResId) {
17 | super(context, xmlLayoutResId);
18 | }
19 |
20 | public LatinKeyboard(Context context, int layoutTemplateResId, CharSequence characters, int columns, int horizontalPadding) {
21 | super(context, layoutTemplateResId, characters, columns, horizontalPadding);
22 | }
23 |
24 |
25 | @Override
26 | protected Key createKeyFromXml(Resources res, Row parent, int x, int y,XmlResourceParser parser) {
27 | Key key = new Key(res, parent, x, y, parser);
28 | if (key.codes[0] == 10) {
29 | mEnterKey = key;
30 | }
31 | return key;
32 | }
33 |
34 | /**
35 | * This looks at the ime options given by the current editor, to set the
36 | * appropriate label on the keyboard's enter key (if it has one).
37 | */
38 | void setImeOptions(Resources res, int options) {
39 | if (mEnterKey == null) {
40 | return;
41 | }
42 |
43 | switch (options&(EditorInfo.IME_MASK_ACTION|EditorInfo.IME_FLAG_NO_ENTER_ACTION)) {
44 | case EditorInfo.IME_ACTION_GO:
45 | mEnterKey.iconPreview = null;
46 | mEnterKey.icon = null;
47 | mEnterKey.label = res.getText(R.string.label_go_key);
48 | break;
49 | case EditorInfo.IME_ACTION_NEXT:
50 | mEnterKey.iconPreview = null;
51 | mEnterKey.icon = null;
52 | mEnterKey.label = res.getText(R.string.label_next_key);
53 | break;
54 | case EditorInfo.IME_ACTION_SEARCH:
55 | mEnterKey.icon = res.getDrawable(R.drawable.sym_keyboard_search);
56 | mEnterKey.label = null;
57 | break;
58 | case EditorInfo.IME_ACTION_SEND:
59 | mEnterKey.iconPreview = null;
60 | mEnterKey.icon = null;
61 | mEnterKey.label = res.getText(R.string.label_send_key);
62 | break;
63 | default:
64 | mEnterKey.icon = res.getDrawable(R.drawable.sym_keyboard_return);
65 | mEnterKey.label = null;
66 | break;
67 | }
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/sym_keyboard_delete.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanszlosek/android-keyboard/da164c09c71df1549577a1f2b66a1417d0b53523/app/src/main/res/drawable/sym_keyboard_delete.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/sym_keyboard_done.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanszlosek/android-keyboard/da164c09c71df1549577a1f2b66a1417d0b53523/app/src/main/res/drawable/sym_keyboard_done.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/sym_keyboard_return.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanszlosek/android-keyboard/da164c09c71df1549577a1f2b66a1417d0b53523/app/src/main/res/drawable/sym_keyboard_return.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/sym_keyboard_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanszlosek/android-keyboard/da164c09c71df1549577a1f2b66a1417d0b53523/app/src/main/res/drawable/sym_keyboard_search.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/sym_keyboard_shift.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanszlosek/android-keyboard/da164c09c71df1549577a1f2b66a1417d0b53523/app/src/main/res/drawable/sym_keyboard_shift.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/sym_keyboard_space.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanszlosek/android-keyboard/da164c09c71df1549577a1f2b66a1417d0b53523/app/src/main/res/drawable/sym_keyboard_space.png
--------------------------------------------------------------------------------
/app/src/main/res/layout/input.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanszlosek/android-keyboard/da164c09c71df1549577a1f2b66a1417d0b53523/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanszlosek/android-keyboard/da164c09c71df1549577a1f2b66a1417d0b53523/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanszlosek/android-keyboard/da164c09c71df1549577a1f2b66a1417d0b53523/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanszlosek/android-keyboard/da164c09c71df1549577a1f2b66a1417d0b53523/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanszlosek/android-keyboard/da164c09c71df1549577a1f2b66a1417d0b53523/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 | #FF000000
8 | #FFE35900
9 | #ff808080
10 | #bbffffff
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 50dip
4 | 16sp
5 | 6sp
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Keying
3 |
4 | \u0020.,;:!?\n()[]*&@{}/<>_+=|"
5 |
6 |
7 | Go
8 | Next
9 | Send
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/method.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/qwerty.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
65 |
66 |
67 |
69 |
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/symbols.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
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 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
65 |
67 |
68 |
69 |
70 |
71 |
--------------------------------------------------------------------------------
/app/src/test/java/com/alanszlosek/keying/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.alanszlosek.keying;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.1.0'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanszlosek/android-keyboard/da164c09c71df1549577a1f2b66a1417d0b53523/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/notes.txt:
--------------------------------------------------------------------------------
1 | Symfony Keyboard Layout
2 |
3 | 7 8 9 + '[ "] @#
4 | 4 5 6 -_ () `~ $%
5 | 1 2 3 * , :; ^&
6 | 0 . = /\ ? !| D
7 |
--------------------------------------------------------------------------------
/readme.markdown:
--------------------------------------------------------------------------------
1 | Why
2 | ====
3 |
4 | I'm thrifty, with an LG Optimus V in my hand. It's got a 3.2" screen which makes typing on the standard Android keyboard a frustrating process. So I'm modifying the SoftKeyboard sample project, and experimenting with ways to arrange the keys differently such that they can be made larger.
5 |
6 | View screenshot.png for a preview. Though, it's slightly out of date from what I describe below.
7 |
8 | Ideas
9 | ====
10 |
11 | The stock keyboard contains as many as 10 keys on a row. This is too many for my fingers to handle, so this project has only 7 keys per row.
12 |
13 | To do this, I've doubled up on some letters. "q" and "w" are on the same key, same for "ui", "op", "as" and "kl". Long-press those (longer than 200ms) to get the secondary letter. Also, the "#" switches to symbols.
14 |
15 | Just for the record: Also thought of having 2 spacebars, normal that obeys most logical completion, and another that ignores and leaves word as typed.
16 |
17 | To Do
18 | ====
19 |
20 | * The suggestions portion of the UI needs some major love. Copy style from built-in android keyboard
21 | * Use long-press codes as a tree of possible predictions ... to maximize effectiveness of condensed keys
22 |
23 | Done For now
24 | ====
25 |
26 | * Finish modifying layout of the symbols keys.
27 |
28 | Nah
29 | ====
30 |
31 | * Try the alternative method of accessing keys that are hidden by the right side of the screen.
32 |
33 | Bugs
34 | ====
35 |
36 | * Suggestions should backtrack to the previous word characters (regex) and them use that for suggestions, not the letter you just typed after backspacing.
37 | * Backspace should operate from current cursor position. There are edge cases where it doesn't.
38 |
39 | Building
40 | =====
41 |
42 | Follow the instructions here for existing projects:
43 |
44 | https://developer.android.com/tools/projects/projects-cmdline.html
45 |
46 | Notes
47 | ====
48 |
49 | Example project had some quirkiness. Namely regarding the caps lock key. Or maybe I introduced those bugs. Either way:
50 |
51 | Thinking that when the keyboard first shows, it should check the shift key state for the current input control (view?). I have an internal boolean for isShifted, which I should set to the cursor shift key state.
52 |
53 | License
54 | ====
55 |
56 | MIT License. See LICENSE file for more information.
57 |
--------------------------------------------------------------------------------
/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanszlosek/android-keyboard/da164c09c71df1549577a1f2b66a1417d0b53523/screenshot.png
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------