Hide keyboard when next key is pressed

Also move some shared utility methods to DialerUtils

Bug: 16542561
Change-Id: Ibc574c24919bdcd11b0786fb9d22d29ff9c21bf1
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java
index 249e0c1..3d06a8e 100644
--- a/src/com/android/dialer/DialtactsActivity.java
+++ b/src/com/android/dialer/DialtactsActivity.java
@@ -731,14 +731,6 @@
         }
     }
 
-    private void hideInputMethod(View view) {
-        final InputMethodManager imm = (InputMethodManager) getSystemService(
-                Context.INPUT_METHOD_SERVICE);
-        if (imm != null && view != null) {
-            imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
-        }
-    }
-
     private void prepareVoiceSearchButton() {
         final Intent voiceIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
         if (canIntentBeHandled(voiceIntent)) {
@@ -940,7 +932,7 @@
             hideDialpadFragment(true, false);
         } else if (isInSearchUi()) {
             exitSearchUi();
-            hideInputMethod(parentLayout);
+            DialerUtils.hideInputMethod(parentLayout);
         } else {
             super.onBackPressed();
         }
@@ -952,7 +944,7 @@
     private boolean maybeExitSearchUi() {
         if (isInSearchUi() && TextUtils.isEmpty(mSearchQuery)) {
             exitSearchUi();
-            hideInputMethod(parentLayout);
+            DialerUtils.hideInputMethod(parentLayout);
             return true;
         }
         return false;
@@ -989,7 +981,7 @@
     public void onListFragmentScrollStateChange(int scrollState) {
         if (scrollState == OnScrollListener.SCROLL_STATE_TOUCH_SCROLL) {
             hideDialpadFragment(true, false);
-            hideInputMethod(getCurrentFocus());
+            DialerUtils.hideInputMethod(getCurrentFocus());
         }
     }