diff options
author | 2017-12-06 11:52:11 -0800 | |
---|---|---|
committer | 2017-12-06 14:24:54 -0800 | |
commit | f630b9d1222d4d35cef3bbc5361b653614a9f8ed (patch) | |
tree | 8a1247039c9f4c39a894b9803731f21524ec9c56 /java/src | |
parent | a3addf1187986bc5c3a80a447aa5e9dc4e1c4130 (diff) | |
parent | f99e090a5992c0081a88dbad9475d60023e69bac (diff) | |
download | latinime-f630b9d1222d4d35cef3bbc5361b653614a9f8ed.tar.gz latinime-f630b9d1222d4d35cef3bbc5361b653614a9f8ed.tar.xz latinime-f630b9d1222d4d35cef3bbc5361b653614a9f8ed.zip |
DO NOT MERGE: Merge Oreo MR1 into master
Exempt-From-Owner-Approval: Changes already landed internally
Change-Id: Ib1ef5bebfccf8eab11bb080c0e13cdf4cff9e79e
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 1764ded8c..00ed52cad 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -124,6 +124,18 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen static final long DELAY_DEALLOCATE_MEMORY_MILLIS = TimeUnit.SECONDS.toMillis(10); /** + * A broadcast intent action to hide the software keyboard. + */ + static final String ACTION_HIDE_SOFT_INPUT = + "com.android.inputmethod.latin.HIDE_SOFT_INPUT"; + + /** + * A custom permission for external apps to send {@link #ACTION_HIDE_SOFT_INPUT}. + */ + static final String PERMISSION_HIDE_SOFT_INPUT = + "com.android.inputmethod.latin.HIDE_SOFT_INPUT"; + + /** * The name of the scheme used by the Package Manager to warn of a new package installation, * replacement or removal. */ @@ -160,6 +172,25 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen private final BroadcastReceiver mDictionaryDumpBroadcastReceiver = new DictionaryDumpBroadcastReceiver(this); + final static class HideSoftInputReceiver extends BroadcastReceiver { + private final InputMethodService mIms; + + public HideSoftInputReceiver(InputMethodService ims) { + mIms = ims; + } + + @Override + public void onReceive(Context context, Intent intent) { + final String action = intent.getAction(); + if (ACTION_HIDE_SOFT_INPUT.equals(action)) { + mIms.requestHideSelf(0 /* flags */); + } else { + Log.e(TAG, "Unexpected intent " + intent); + } + } + } + final HideSoftInputReceiver mHideSoftInputReceiver = new HideSoftInputReceiver(this); + private AlertDialog mOptionsDialog; private final boolean mIsHardwareAcceleratedDrawingEnabled; @@ -595,6 +626,11 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen dictDumpFilter.addAction(DictionaryDumpBroadcastReceiver.DICTIONARY_DUMP_INTENT_ACTION); registerReceiver(mDictionaryDumpBroadcastReceiver, dictDumpFilter); + final IntentFilter hideSoftInputFilter = new IntentFilter(); + hideSoftInputFilter.addAction(ACTION_HIDE_SOFT_INPUT); + registerReceiver(mHideSoftInputReceiver, hideSoftInputFilter, PERMISSION_HIDE_SOFT_INPUT, + null /* scheduler */); + StatsUtils.onCreate(mSettings.getCurrent(), mRichImm); } @@ -699,6 +735,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen public void onDestroy() { mDictionaryFacilitator.closeDictionaries(); mSettings.onDestroy(); + unregisterReceiver(mHideSoftInputReceiver); unregisterReceiver(mRingerModeChangeReceiver); unregisterReceiver(mDictionaryPackInstallReceiver); unregisterReceiver(mDictionaryDumpBroadcastReceiver); |