Close giphy keyboard when search button is pressed

Fixes #5807
// FREEBIE
This commit is contained in:
Moxie Marlinspike 2016-10-26 17:24:56 -07:00
parent 2bcbbb0601
commit 11dbb82bf1

View File

@ -9,11 +9,15 @@ import android.text.Editable;
import android.text.InputType;
import android.text.TextWatcher;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.TouchDelegate;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.components.AnimatingToggle;
@ -96,6 +100,18 @@ public class GiphyActivityToolbar extends Toolbar {
}
});
this.searchText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
InputMethodManager inputMethodManager = (InputMethodManager)getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(searchText.getWindowToken(), 0);
}
return false;
}
});
expandTapArea(this, action);
expandTapArea(toggleContainer, gridToggle);
}