mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
Merge pull request #1097 from tanvidadu/master
Hide Keypad on clicking outside the EditText
This commit is contained in:
commit
e71e1186c2
2 changed files with 22 additions and 0 deletions
|
|
@ -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);
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue