diff options
author | 2017-09-03 08:10:13 +0000 | |
---|---|---|
committer | 2017-09-03 08:10:13 +0000 | |
commit | 88a27c772b8dc37a1146fdd6b75894ebc6954051 (patch) | |
tree | 9a55d6a8488c740042ac63dbb467bf198b68b9d8 /java/src/com/android/inputmethod/latin/LatinIME.java | |
parent | 7b9e6d976cd0214b507d42cfc041d38bdf2354c1 (diff) | |
parent | 53049393813f998f55db8e6ea51e163825860241 (diff) | |
download | latinime-88a27c772b8dc37a1146fdd6b75894ebc6954051.tar.gz latinime-88a27c772b8dc37a1146fdd6b75894ebc6954051.tar.xz latinime-88a27c772b8dc37a1146fdd6b75894ebc6954051.zip |
release-request-b4448e78-a682-4bc1-b691-b70e74fef19f-for-git_pi-release-4314474 snap-temp-L95500000099150132
Change-Id: I6ab8fd3a2d02e71c7739de3058c495512c6be5ea
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-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); |