|
1 | 1 | package fr.free.nrw.commons.nearby.fragments; |
2 | 2 |
|
3 | 3 | import android.Manifest; |
| 4 | +import android.app.Activity; |
4 | 5 | import android.app.AlertDialog; |
5 | 6 | import android.content.BroadcastReceiver; |
6 | 7 | import android.content.Context; |
7 | 8 | import android.content.Intent; |
8 | 9 | import android.content.IntentFilter; |
9 | 10 | import android.content.res.Configuration; |
10 | 11 | import android.os.Bundle; |
| 12 | +import android.os.IBinder; |
11 | 13 | import android.util.Log; |
12 | 14 | import android.view.Gravity; |
13 | 15 | import android.view.LayoutInflater; |
14 | 16 | import android.view.View; |
15 | 17 | import android.view.ViewGroup; |
16 | 18 | import android.view.animation.Animation; |
17 | 19 | import android.view.animation.AnimationUtils; |
| 20 | +import android.view.inputmethod.InputMethodManager; |
18 | 21 | import android.widget.Button; |
19 | 22 | import android.widget.FrameLayout; |
20 | 23 | import android.widget.ImageView; |
@@ -491,6 +494,20 @@ public void centerMapToPlace(Place place) { |
491 | 494 | } |
492 | 495 | } |
493 | 496 |
|
| 497 | + /** |
| 498 | + * Hides the keyboard in case the tab is switched |
| 499 | + */ |
| 500 | + public void hideKeyboard(){ |
| 501 | + if(!searchView.isIconified()) { |
| 502 | + searchView.clearFocus(); |
| 503 | + InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Activity.INPUT_METHOD_SERVICE); |
| 504 | + final IBinder windowToken = this.getView().getRootView().getWindowToken(); |
| 505 | + if (view != null) { |
| 506 | + imm.hideSoftInputFromWindow(windowToken, InputMethodManager.HIDE_NOT_ALWAYS); |
| 507 | + } |
| 508 | + } |
| 509 | + } |
| 510 | + |
494 | 511 |
|
495 | 512 | /** |
496 | 513 | * Thanks to this method we make sure NearbyMapFragment is ready and attached. So that we can |
|
0 commit comments