aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorYohei Yukawa <yukawa@google.com>2017-09-01 20:02:23 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-09-01 20:02:23 +0000
commit53049393813f998f55db8e6ea51e163825860241 (patch)
tree9a55d6a8488c740042ac63dbb467bf198b68b9d8 /java/src
parentfdb54c41a9295286afaea240623312cd40e5b709 (diff)
parent9f14e616abb361e7c5d5e03a4a0e5ae03c04b422 (diff)
downloadlatinime-53049393813f998f55db8e6ea51e163825860241.tar.gz
latinime-53049393813f998f55db8e6ea51e163825860241.tar.xz
latinime-53049393813f998f55db8e6ea51e163825860241.zip
Introduce a custom intent action to close software keyboard am: fdfc55d3db
am: 9f14e616ab Change-Id: I5c63edc64d2086e57de27f66297a51138ec56182
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java37
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);