Merge pull request #1097 from tanvidadu/master

Hide Keypad on clicking outside the EditText
This commit is contained in:
neslihanturan 2018-01-24 20:54:00 +03:00 committed by GitHub
commit e71e1186c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 0 deletions

View file

@ -1,5 +1,6 @@
package fr.free.nrw.commons.upload; package fr.free.nrw.commons.upload;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
@ -11,6 +12,7 @@ import android.support.annotation.NonNull;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.text.Editable; import android.text.Editable;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
@ -136,11 +138,29 @@ public class SingleUploadFragment extends CommonsDaggerSupportFragment {
titleEdit.addTextChangedListener(textWatcher); titleEdit.addTextChangedListener(textWatcher);
titleEdit.setOnFocusChangeListener((v, hasFocus) -> {
if (!hasFocus) {
hideKeyboard(v);
}
});
descEdit.setOnFocusChangeListener((v, hasFocus) -> {
if(!hasFocus){
hideKeyboard(v);
}
});
setLicenseSummary(license); setLicenseSummary(license);
return rootView; 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 @Override
public void onDestroyView() { public void onDestroyView() {
titleEdit.removeTextChangedListener(textWatcher); titleEdit.removeTextChangedListener(textWatcher);

View file

@ -12,6 +12,8 @@
android:paddingEnd="@dimen/standard_gap" android:paddingEnd="@dimen/standard_gap"
android:paddingTop="@dimen/small_gap" android:paddingTop="@dimen/small_gap"
android:theme="@style/DarkAppTheme" android:theme="@style/DarkAppTheme"
android:clickable="true"
android:focusableInTouchMode="true"
> >
<EditText <EditText