|
| 1 | +package org.wordpress.aztec |
| 2 | + |
| 3 | +import android.os.Build |
| 4 | +import android.os.Bundle |
| 5 | +import android.os.Handler |
| 6 | +import android.view.KeyEvent |
| 7 | +import android.view.inputmethod.CompletionInfo |
| 8 | +import android.view.inputmethod.CorrectionInfo |
| 9 | +import android.view.inputmethod.ExtractedText |
| 10 | +import android.view.inputmethod.ExtractedTextRequest |
| 11 | +import android.view.inputmethod.InputConnection |
| 12 | +import android.view.inputmethod.InputContentInfo |
| 13 | +import androidx.annotation.RequiresApi |
| 14 | + |
| 15 | +/** |
| 16 | + * Wrapper around proprietary Samsung InputConnection. Forwards all the calls to it, except for getExtractedText and |
| 17 | + * some custom logic in commitText |
| 18 | + */ |
| 19 | +abstract class InputConnectionWrapper(private val inputConnection: InputConnection) : InputConnection { |
| 20 | + override fun beginBatchEdit(): Boolean { |
| 21 | + return inputConnection.beginBatchEdit() |
| 22 | + } |
| 23 | + |
| 24 | + override fun endBatchEdit(): Boolean { |
| 25 | + return inputConnection.endBatchEdit() |
| 26 | + } |
| 27 | + |
| 28 | + override fun clearMetaKeyStates(states: Int): Boolean { |
| 29 | + return inputConnection.clearMetaKeyStates(states) |
| 30 | + } |
| 31 | + |
| 32 | + override fun sendKeyEvent(event: KeyEvent?): Boolean { |
| 33 | + return inputConnection.sendKeyEvent(event) |
| 34 | + } |
| 35 | + |
| 36 | + override fun commitCompletion(text: CompletionInfo?): Boolean { |
| 37 | + return inputConnection.commitCompletion(text) |
| 38 | + } |
| 39 | + |
| 40 | + override fun commitCorrection(correctionInfo: CorrectionInfo?): Boolean { |
| 41 | + return inputConnection.commitCorrection(correctionInfo) |
| 42 | + } |
| 43 | + |
| 44 | + override fun performEditorAction(actionCode: Int): Boolean { |
| 45 | + return inputConnection.performEditorAction(actionCode) |
| 46 | + } |
| 47 | + |
| 48 | + override fun performContextMenuAction(id: Int): Boolean { |
| 49 | + return inputConnection.performContextMenuAction(id) |
| 50 | + } |
| 51 | + |
| 52 | + override fun getExtractedText(request: ExtractedTextRequest?, flags: Int): ExtractedText? { |
| 53 | + return inputConnection.getExtractedText(request, flags) |
| 54 | + } |
| 55 | + |
| 56 | + override fun performPrivateCommand(action: String?, data: Bundle?): Boolean { |
| 57 | + return inputConnection.performPrivateCommand(action, data) |
| 58 | + } |
| 59 | + |
| 60 | + override fun setComposingText(text: CharSequence?, newCursorPosition: Int): Boolean { |
| 61 | + return inputConnection.setComposingText(text, newCursorPosition) |
| 62 | + } |
| 63 | + |
| 64 | + override fun commitText(text: CharSequence?, newCursorPosition: Int): Boolean { |
| 65 | + return inputConnection.commitText(text, newCursorPosition) |
| 66 | + } |
| 67 | + |
| 68 | + @RequiresApi(Build.VERSION_CODES.N_MR1) |
| 69 | + override fun commitContent(inputContentInfo: InputContentInfo, flags: Int, opts: Bundle?): Boolean { |
| 70 | + return inputConnection.commitContent(inputContentInfo, flags, opts) |
| 71 | + } |
| 72 | + |
| 73 | + override fun deleteSurroundingText(beforeLength: Int, afterLength: Int): Boolean { |
| 74 | + return inputConnection.deleteSurroundingText(beforeLength, afterLength) |
| 75 | + } |
| 76 | + |
| 77 | + override fun requestCursorUpdates(cursorUpdateMode: Int): Boolean { |
| 78 | + return inputConnection.requestCursorUpdates(cursorUpdateMode) |
| 79 | + } |
| 80 | + |
| 81 | + override fun reportFullscreenMode(enabled: Boolean): Boolean { |
| 82 | + return inputConnection.reportFullscreenMode(enabled) |
| 83 | + } |
| 84 | + |
| 85 | + override fun setSelection(start: Int, end: Int): Boolean { |
| 86 | + return inputConnection.setSelection(start, end) |
| 87 | + } |
| 88 | + |
| 89 | + override fun finishComposingText(): Boolean { |
| 90 | + return inputConnection.finishComposingText() |
| 91 | + } |
| 92 | + |
| 93 | + override fun setComposingRegion(start: Int, end: Int): Boolean { |
| 94 | + return inputConnection.setComposingRegion(start, end) |
| 95 | + } |
| 96 | + |
| 97 | + override fun deleteSurroundingTextInCodePoints(beforeLength: Int, afterLength: Int): Boolean { |
| 98 | + return inputConnection.deleteSurroundingTextInCodePoints(beforeLength, afterLength) |
| 99 | + } |
| 100 | + |
| 101 | + override fun getCursorCapsMode(reqModes: Int): Int { |
| 102 | + return inputConnection.getCursorCapsMode(reqModes) |
| 103 | + } |
| 104 | + |
| 105 | + override fun getSelectedText(flags: Int): CharSequence? { |
| 106 | + return inputConnection.getSelectedText(flags) |
| 107 | + } |
| 108 | + |
| 109 | + override fun getTextAfterCursor(length: Int, flags: Int): CharSequence { |
| 110 | + return inputConnection.getTextAfterCursor(length, flags) |
| 111 | + } |
| 112 | + |
| 113 | + override fun getTextBeforeCursor(length: Int, flags: Int): CharSequence { |
| 114 | + return inputConnection.getTextBeforeCursor(length, flags) |
| 115 | + } |
| 116 | + |
| 117 | + override fun getHandler(): Handler? { |
| 118 | + return inputConnection.handler |
| 119 | + } |
| 120 | + |
| 121 | + override fun closeConnection() { |
| 122 | + inputConnection.closeConnection() |
| 123 | + } |
| 124 | +} |
0 commit comments