mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Hide Keypad on clicking outside the EditText
This commit is contained in:
parent
a6caa64e17
commit
dd2c5dbcb8
2 changed files with 22 additions and 0 deletions
|
|
@ -1,5 +1,6 @@
|
|||
package fr.free.nrw.commons.upload;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
|
|
@ -11,6 +12,7 @@ import android.support.annotation.NonNull;
|
|||
import android.support.v7.app.AlertDialog;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
|
|
@ -136,11 +138,29 @@ public class SingleUploadFragment extends CommonsDaggerSupportFragment {
|
|||
|
||||
titleEdit.addTextChangedListener(textWatcher);
|
||||
|
||||
titleEdit.setOnFocusChangeListener((v, hasFocus) -> {
|
||||
if (!hasFocus) {
|
||||
hideKeyboard(v);
|
||||
}
|
||||
});
|
||||
|
||||
descEdit.setOnFocusChangeListener((v, hasFocus) -> {
|
||||
if(!hasFocus){
|
||||
hideKeyboard(v);
|
||||
}
|
||||
});
|
||||
|
||||
setLicenseSummary(license);
|
||||
|
||||
return rootView;
|
||||
}
|
||||
|
||||
public void hideKeyboard(View view) {
|
||||
Log.i("hide", "hideKeyboard: ");
|
||||
InputMethodManager inputMethodManager =(InputMethodManager)getActivity().getSystemService(Activity.INPUT_METHOD_SERVICE);
|
||||
inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
titleEdit.removeTextChangedListener(textWatcher);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@
|
|||
android:paddingEnd="@dimen/standard_gap"
|
||||
android:paddingTop="@dimen/small_gap"
|
||||
android:theme="@style/DarkAppTheme"
|
||||
android:clickable="true"
|
||||
android:focusableInTouchMode="true"
|
||||
>
|
||||
|
||||
<EditText
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue