diff options
| -rw-r--r-- | base/build.gradle | 2 | ||||
| -rw-r--r-- | build.gradle | 2 | ||||
| -rw-r--r-- | jnidictionaryv1/build.gradle | 2 | ||||
| -rw-r--r-- | jnidictionaryv2/build.gradle | 2 | ||||
| -rw-r--r-- | nextword/build.gradle | 2 | ||||
| -rw-r--r-- | src/main/java/com/anysoftkeyboard/AnySoftKeyboard.java | 40 | ||||
| -rw-r--r-- | src/main/java/com/anysoftkeyboard/devicespecific/Clipboard.java | 2 | ||||
| -rw-r--r-- | src/main/java/com/anysoftkeyboard/devicespecific/ClipboardV11.java | 7 | ||||
| -rw-r--r-- | src/main/java/com/anysoftkeyboard/devicespecific/ClipboardV3.java | 4 | ||||
| -rw-r--r-- | src/main/res/xml/ext_kbd_utility_utility.xml | 19 |
10 files changed, 55 insertions, 27 deletions
diff --git a/base/build.gradle b/base/build.gradle index 5a0fc4996..629cbf20d 100644 --- a/base/build.gradle +++ b/base/build.gradle @@ -17,6 +17,6 @@ dependencies { mavenCentral() maven { url "https://jitpack.io" } } - compile 'com.github.AnySoftKeyboard:AnySoftKeyboard-API:1.2.7' + compile 'com.github.AnySoftKeyboard:AnySoftKeyboard-API:-SNAPSHOT' compile 'com.android.support:support-annotations:23.1.0' } diff --git a/build.gradle b/build.gradle index 78316acd1..83d6d4bbf 100644 --- a/build.gradle +++ b/build.gradle @@ -177,7 +177,7 @@ dependencies { compile project(':jnidictionaryv1') compile project(':jnidictionaryv2') - compile 'com.github.AnySoftKeyboard:AnySoftKeyboard-API:1.2.7' + compile 'com.github.AnySoftKeyboard:AnySoftKeyboard-API:-SNAPSHOT' compile 'com.github.menny:FrankenRobot:1.1.5' compile 'com.android.support:appcompat-v7:23.1.0' compile 'com.android.support:recyclerview-v7:23.1.0' diff --git a/jnidictionaryv1/build.gradle b/jnidictionaryv1/build.gradle index 223529ee4..885019219 100644 --- a/jnidictionaryv1/build.gradle +++ b/jnidictionaryv1/build.gradle @@ -20,6 +20,6 @@ dependencies { mavenCentral() maven { url "https://jitpack.io" } } - compile 'com.github.AnySoftKeyboard:AnySoftKeyboard-API:1.2.7' + compile 'com.github.AnySoftKeyboard:AnySoftKeyboard-API:-SNAPSHOT' compile project(':base') } diff --git a/jnidictionaryv2/build.gradle b/jnidictionaryv2/build.gradle index 77a077482..409d7b32e 100644 --- a/jnidictionaryv2/build.gradle +++ b/jnidictionaryv2/build.gradle @@ -20,6 +20,6 @@ dependencies { mavenCentral() maven { url "https://jitpack.io" } } - compile 'com.github.AnySoftKeyboard:AnySoftKeyboard-API:1.2.7' + compile 'com.github.AnySoftKeyboard:AnySoftKeyboard-API:-SNAPSHOT' compile project(':base') } diff --git a/nextword/build.gradle b/nextword/build.gradle index b8df3af7e..9521fc7c7 100644 --- a/nextword/build.gradle +++ b/nextword/build.gradle @@ -20,6 +20,6 @@ dependencies { mavenCentral() maven { url "https://jitpack.io" } } - compile 'com.github.AnySoftKeyboard:AnySoftKeyboard-API:1.2.7' + compile 'com.github.AnySoftKeyboard:AnySoftKeyboard-API:-SNAPSHOT' compile project(':base') } diff --git a/src/main/java/com/anysoftkeyboard/AnySoftKeyboard.java b/src/main/java/com/anysoftkeyboard/AnySoftKeyboard.java index 92d27d61c..d92a4a527 100644 --- a/src/main/java/com/anysoftkeyboard/AnySoftKeyboard.java +++ b/src/main/java/com/anysoftkeyboard/AnySoftKeyboard.java @@ -1641,13 +1641,10 @@ public class AnySoftKeyboard extends InputMethodService implements nextKeyboard(getCurrentInputEditorInfo(), NextKeyboardType.OtherMode); break; - case KeyCodes.CLIPBOARD: - Clipboard cp = AnyApplication.getFrankenRobot().embody( - new Clipboard.ClipboardDiagram(getApplicationContext())); - CharSequence clipboardText = cp.getText(); - if (!TextUtils.isEmpty(clipboardText)) { - onText(key, clipboardText); - } + case KeyCodes.CLIPBOARD_COPY: + case KeyCodes.CLIPBOARD_PASTE: + case KeyCodes.CLIPBOARD_CUT: + handleClipboardOperation(key, primaryCode); break; case KeyCodes.TAB: sendTab(); @@ -1687,6 +1684,35 @@ public class AnySoftKeyboard extends InputMethodService implements } } + private void handleClipboardOperation(final Key key, final int primaryCode) { + Clipboard clipboard = AnyApplication.getFrankenRobot().embody(new Clipboard.ClipboardDiagram(getApplicationContext())); + switch (primaryCode) { + case KeyCodes.CLIPBOARD_PASTE: + CharSequence clipboardText = clipboard.getText(); + if (!TextUtils.isEmpty(clipboardText)) { + onText(key, clipboardText); + } + break; + case KeyCodes.CLIPBOARD_CUT: + case KeyCodes.CLIPBOARD_COPY: + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { + InputConnection ic = getCurrentInputConnection(); + if (ic != null) { + CharSequence selectedText = ic.getSelectedText(InputConnection.GET_TEXT_WITH_STYLES); + if (!TextUtils.isEmpty(selectedText)) { + clipboard.setText(selectedText); + if (primaryCode == KeyCodes.CLIPBOARD_CUT) { + //sending a DEL key will delete the selected text + sendDownUpKeyEvents(KeyEvent.KEYCODE_DEL); + } + } + } + } + break; + } + + } + private void openQuickTextPopup(Key key) { if (mInputView != null) { mInputView.showQuickKeysView(key); diff --git a/src/main/java/com/anysoftkeyboard/devicespecific/Clipboard.java b/src/main/java/com/anysoftkeyboard/devicespecific/Clipboard.java index 0caf353e8..dfb0b0b65 100644 --- a/src/main/java/com/anysoftkeyboard/devicespecific/Clipboard.java +++ b/src/main/java/com/anysoftkeyboard/devicespecific/Clipboard.java @@ -24,7 +24,7 @@ import net.evendanan.frankenrobot.Diagram; @IndirectlyInstantiated public interface Clipboard { - public static class ClipboardDiagram extends Diagram<Clipboard> { + class ClipboardDiagram extends Diagram<Clipboard> { private final Context mContext; public ClipboardDiagram(Context context) { diff --git a/src/main/java/com/anysoftkeyboard/devicespecific/ClipboardV11.java b/src/main/java/com/anysoftkeyboard/devicespecific/ClipboardV11.java index 6b6f51bda..81bb2b9a8 100644 --- a/src/main/java/com/anysoftkeyboard/devicespecific/ClipboardV11.java +++ b/src/main/java/com/anysoftkeyboard/devicespecific/ClipboardV11.java @@ -26,14 +26,13 @@ import com.anysoftkeyboard.IndirectlyInstantiated; @TargetApi(11) @IndirectlyInstantiated -final class ClipboardV11 implements Clipboard { +public class ClipboardV11 implements Clipboard { private final ClipboardManager cbV11; private final Context mAppContext; - ClipboardV11(ClipboardDiagram diagram) { + public ClipboardV11(ClipboardDiagram diagram) { mAppContext = diagram.getContext(); - cbV11 = (ClipboardManager) mAppContext - .getSystemService(Context.CLIPBOARD_SERVICE); + cbV11 = (ClipboardManager) mAppContext.getSystemService(Context.CLIPBOARD_SERVICE); } public void setText(CharSequence text) { diff --git a/src/main/java/com/anysoftkeyboard/devicespecific/ClipboardV3.java b/src/main/java/com/anysoftkeyboard/devicespecific/ClipboardV3.java index e7766346e..3a2407ce8 100644 --- a/src/main/java/com/anysoftkeyboard/devicespecific/ClipboardV3.java +++ b/src/main/java/com/anysoftkeyboard/devicespecific/ClipboardV3.java @@ -25,10 +25,10 @@ import com.anysoftkeyboard.IndirectlyInstantiated; @SuppressWarnings("deprecation") @TargetApi(3) @IndirectlyInstantiated -final class ClipboardV3 implements Clipboard { +public class ClipboardV3 implements Clipboard { private final ClipboardManager cbV3; - ClipboardV3(ClipboardDiagram diagram) { + public ClipboardV3(ClipboardDiagram diagram) { cbV3 = (android.text.ClipboardManager) diagram.getContext() .getSystemService(Context.CLIPBOARD_SERVICE); } diff --git a/src/main/res/xml/ext_kbd_utility_utility.xml b/src/main/res/xml/ext_kbd_utility_utility.xml index d7281cb36..e190afbec 100644 --- a/src/main/res/xml/ext_kbd_utility_utility.xml +++ b/src/main/res/xml/ext_kbd_utility_utility.xml @@ -3,7 +3,7 @@ /* ** ** Copyright 2008, The Android Open Source Project -** Copyright 2011, AnySoftKeyboard +** Copyright 2015, AnySoftKeyboard ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. @@ -23,16 +23,20 @@ android:keyWidth="15%p" android:keyHeight="@integer/key_normal_height"> <Row android:rowEdgeFlags="top"> - <Key android:codes="@integer/key_code_move_home"/> - <Key android:isRepeatable="true" android:codes="@integer/key_code_arrow_up"/> - <Key android:codes="@integer/key_code_move_end"/> + <Key android:codes="@integer/key_code_clipboard_copy" android:keyEdgeFlags="left"/> + <Key android:codes="@integer/key_code_clipboard_cut"/> + <Key android:codes="@integer/key_code_clipboard_paste"/> <Key android:keyWidth="10%p" android:horizontalGap="10%p" android:codes="@integer/key_code_voice_input"/> <Key android:keyWidth="10%p" android:horizontalGap="10%p" android:codes="@integer/key_code_settings"/> - <Key android:keyWidth="10%p" android:codes="@integer/key_code_cancel" - android:keyEdgeFlags="right"/> + <Key android:keyWidth="10%p" android:codes="@integer/key_code_cancel" android:keyEdgeFlags="right"/> + </Row> + <Row> + <Key android:codes="@integer/key_code_move_home" android:keyEdgeFlags="left"/> + <Key android:isRepeatable="true" android:codes="@integer/key_code_arrow_up"/> + <Key android:codes="@integer/key_code_move_end" android:keyEdgeFlags="right"/> </Row> <Row android:rowEdgeFlags="bottom"> <Key android:codes="@integer/key_code_arrow_left" android:isRepeatable="true" android:keyEdgeFlags="left"/> @@ -42,7 +46,6 @@ <Key android:keyWidth="10%p" android:codes="@integer/key_code_merge_layout" android:horizontalGap="10%p"/> <Key android:keyWidth="10%p" android:codes="@integer/key_code_split_layout"/> <Key android:keyWidth="10%p" android:codes="@integer/key_code_compact_layout_to_left" /> - <Key android:keyWidth="10%p" android:codes="@integer/key_code_compact_layout_to_right" - android:keyEdgeFlags="right"/> + <Key android:keyWidth="10%p" android:codes="@integer/key_code_compact_layout_to_right" android:keyEdgeFlags="right"/> </Row> </Keyboard> |
