File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package com .nmc .android .utils ;
2+
3+ import android .app .Activity ;
4+ import android .content .Context ;
5+ import android .view .View ;
6+ import android .view .inputmethod .InputMethodManager ;
7+
8+ public class KeyboardUtils {
9+
10+ public static void showSoftKeyboard (Context context , View view ) {
11+ view .requestFocus ();
12+ InputMethodManager imm = (InputMethodManager ) context .getSystemService (Context .INPUT_METHOD_SERVICE );
13+ imm .showSoftInput (view , InputMethodManager .SHOW_IMPLICIT );
14+ }
15+
16+ public static void hideKeyboardFrom (Context context , View view ) {
17+ view .clearFocus ();
18+ InputMethodManager imm = (InputMethodManager ) context .getSystemService (Activity .INPUT_METHOD_SERVICE );
19+ imm .hideSoftInputFromWindow (view .getWindowToken (), 0 );
20+ }
21+ }
Original file line number Diff line number Diff line change 135135import com .owncloud .android .utils .MimeTypeUtil ;
136136import com .owncloud .android .utils .PermissionUtil ;
137137import com .owncloud .android .utils .PushUtils ;
138+ import com .nmc .android .utils .KeyboardUtils ;
138139import com .owncloud .android .utils .StringUtils ;
139140import com .owncloud .android .utils .theme .CapabilityUtils ;
140141
@@ -1037,6 +1038,8 @@ private void popBack() {
10371038 // pop back fragment
10381039 binding .fabMain .setImageResource (R .drawable .ic_plus );
10391040 resetScrolling (true );
1041+ // hide the keyboard on back press if showing
1042+ KeyboardUtils .hideKeyboardFrom (this , binding .getRoot ());
10401043 popSortListGroupVisibility ();
10411044 super .onBackPressed ();
10421045 }
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ import com.nextcloud.client.account.CurrentAccountProvider
3939import com.nextcloud.client.core.AsyncRunner
4040import com.nextcloud.client.di.Injectable
4141import com.nextcloud.client.di.ViewModelFactory
42+ import com.nmc.android.utils.KeyboardUtils
4243import com.nextcloud.client.network.ClientFactory
4344import com.owncloud.android.R
4445import com.owncloud.android.databinding.ListFragmentBinding
@@ -221,6 +222,8 @@ class UnifiedSearchFragment :
221222 private fun showFile (file : OCFile , showFileActions : Boolean ) {
222223 activity.let {
223224 if (activity is FileDisplayActivity ) {
225+ // NMC: hide keyboard when user taps on any file to view
226+ KeyboardUtils .hideKeyboardFrom(requireContext(), binding.root)
224227 val fda = activity as FileDisplayActivity
225228 fda.file = file
226229
@@ -280,6 +283,7 @@ class UnifiedSearchFragment :
280283 }
281284
282285 override fun onQueryTextSubmit (query : String ): Boolean {
286+ KeyboardUtils .hideKeyboardFrom(requireContext(), binding.root)
283287 vm.setQuery(query)
284288 vm.initialQuery()
285289 return true
You can’t perform that action at this time.
0 commit comments