Skip to content

Commit 517fddb

Browse files
Chester Hufacebook-github-bot
authored andcommitted
Adding keyboard dismissal when prompt sent (#6238)
Summary: Pull Request resolved: #6238 Dismiss the keyboard when sending the message Reviewed By: cmodi-meta Differential Revision: D64413153 fbshipit-source-id: 6f8edb42910c2bac1c0b648814a1856f92a440da
1 parent 708c6b6 commit 517fddb

File tree

1 file changed

+7
-0
lines changed
  • examples/demo-apps/android/LlamaDemo/app/src/main/java/com/example/executorchllamademo

1 file changed

+7
-0
lines changed

examples/demo-apps/android/LlamaDemo/app/src/main/java/com/example/executorchllamademo/MainActivity.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import android.system.Os;
2727
import android.util.Log;
2828
import android.view.View;
29+
import android.view.inputmethod.InputMethodManager;
2930
import android.widget.EditText;
3031
import android.widget.ImageButton;
3132
import android.widget.ImageView;
@@ -662,6 +663,12 @@ private void onModelRunStopped() {
662663
mSendButton.setImageResource(R.drawable.baseline_send_24);
663664
mSendButton.setOnClickListener(
664665
view -> {
666+
try {
667+
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
668+
imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
669+
} catch (Exception e) {
670+
ETLogging.getInstance().log("Keyboard dismissal error: " + e.getMessage());
671+
}
665672
addSelectedImagesToChatThread(mSelectedImageUri);
666673
String finalPrompt;
667674
String rawPrompt = mEditTextMessage.getText().toString();

0 commit comments

Comments
 (0)