diff --git a/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/floris/KeyCode.kt b/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/floris/KeyCode.kt index cf34b4228..eccf62ebb 100644 --- a/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/floris/KeyCode.kt +++ b/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/floris/KeyCode.kt @@ -175,6 +175,12 @@ object KeyCode { const val META_LEFT = -10048 const val META_RIGHT = -10049 + + // Intents + const val SEND_INTENT_ONE = -20000 + const val SEND_INTENT_TWO = -20001 + const val SEND_INTENT_THREE = -20002 + /** to make sure a FlorisBoard code works when reading a JSON layout */ fun Int.checkAndConvertCode(): Int = if (this > 0) this else when (this) { // working @@ -190,7 +196,7 @@ object KeyCode { ACTION_NEXT, ACTION_PREVIOUS, NOT_SPECIFIED, CLIPBOARD_COPY_ALL, WORD_LEFT, WORD_RIGHT, PAGE_UP, PAGE_DOWN, META, TAB, ESCAPE, INSERT, SLEEP, MEDIA_PLAY, MEDIA_PAUSE, MEDIA_PLAY_PAUSE, MEDIA_NEXT, MEDIA_PREVIOUS, VOL_UP, VOL_DOWN, MUTE, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, BACK, - TIMESTAMP, CTRL_LEFT, CTRL_RIGHT, ALT_LEFT, ALT_RIGHT, META_LEFT, META_RIGHT + TIMESTAMP, CTRL_LEFT, CTRL_RIGHT, ALT_LEFT, ALT_RIGHT, META_LEFT, META_RIGHT, SEND_INTENT_ONE, SEND_INTENT_TWO, SEND_INTENT_THREE, -> this // conversion diff --git a/app/src/main/java/helium314/keyboard/latin/inputlogic/InputLogic.java b/app/src/main/java/helium314/keyboard/latin/inputlogic/InputLogic.java index 058ad3792..28572fa2f 100644 --- a/app/src/main/java/helium314/keyboard/latin/inputlogic/InputLogic.java +++ b/app/src/main/java/helium314/keyboard/latin/inputlogic/InputLogic.java @@ -49,6 +49,7 @@ import helium314.keyboard.latin.settings.SpacingAndPunctuations; import helium314.keyboard.latin.suggestions.SuggestionStripViewAccessor; import helium314.keyboard.latin.utils.AsyncResultHolder; import helium314.keyboard.latin.utils.InputTypeUtils; +import helium314.keyboard.latin.utils.IntentUtils; import helium314.keyboard.latin.utils.Log; import helium314.keyboard.latin.utils.RecapitalizeStatus; import helium314.keyboard.latin.utils.ScriptUtils; @@ -778,6 +779,8 @@ public final class InputLogic { case KeyCode.TIMESTAMP: mLatinIME.onTextInput(TimestampKt.getTimestamp(mLatinIME)); break; + case KeyCode.SEND_INTENT_ONE, KeyCode.SEND_INTENT_TWO, KeyCode.SEND_INTENT_THREE: + IntentUtils.handleSendIntentKey(mLatinIME, event.getMKeyCode()); case KeyCode.IME_HIDE_UI: mLatinIME.requestHideSelf(0); break; diff --git a/app/src/main/java/helium314/keyboard/latin/utils/IntentUtils.kt b/app/src/main/java/helium314/keyboard/latin/utils/IntentUtils.kt new file mode 100644 index 000000000..da1b06bd8 --- /dev/null +++ b/app/src/main/java/helium314/keyboard/latin/utils/IntentUtils.kt @@ -0,0 +1,26 @@ +package helium314.keyboard.latin.utils + +import android.content.Context +import android.content.Intent +import helium314.keyboard.keyboard.internal.keyboard_parser.floris.KeyCode +import helium314.keyboard.latin.inputlogic.InputLogic +import helium314.keyboard.latin.utils.Log.i + +object IntentUtils { + val TAG: String = InputLogic::class.java.simpleName + private val ACTION_SEND_INTENT = "helium314.keyboard.latin.ACTION_SEND_INTENT" + private val EXTRA_NUMBER = "EXTRA_NUMBER" + + @JvmStatic + fun handleSendIntentKey(context: Context, mKeyCode: Int) { + val intentNumber = (KeyCode.SEND_INTENT_ONE + 1) - mKeyCode; + + val intent: Intent = Intent(ACTION_SEND_INTENT).apply { + putExtra(EXTRA_NUMBER, intentNumber) + } + + context.sendBroadcast(intent) + i(TAG, "Sent broadcast for intent number: $intentNumber") + } +} +