summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2014-07-24 11:31:13 -0700
committerYorke Lee <yorkelee@google.com>2014-07-24 11:31:34 -0700
commitf543baadd1119bad7cd9ff7ed39e5598c6fc50d6 (patch)
tree83995705de8ea2c3c6039f978aeab15f1ca0813e /src
parenta396b7a4d2f9074b57abd6ebdc6e1654d84383e1 (diff)
Hide keyboard when next key is pressed
Also move some shared utility methods to DialerUtils Bug: 16542561 Change-Id: Ibc574c24919bdcd11b0786fb9d22d29ff9c21bf1
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dialer/DialtactsActivity.java14
-rw-r--r--src/com/android/dialer/util/DialerUtils.java17
-rw-r--r--src/com/android/dialer/widget/SearchEditTextLayout.java15
3 files changed, 24 insertions, 22 deletions
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java
index 249e0c1aa..3d06a8e70 100644
--- a/src/com/android/dialer/DialtactsActivity.java
+++ b/src/com/android/dialer/DialtactsActivity.java
@@ -731,14 +731,6 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
}
}
- 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 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
hideDialpadFragment(true, false);
} else if (isInSearchUi()) {
exitSearchUi();
- hideInputMethod(parentLayout);
+ DialerUtils.hideInputMethod(parentLayout);
} else {
super.onBackPressed();
}
@@ -952,7 +944,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
private boolean maybeExitSearchUi() {
if (isInSearchUi() && TextUtils.isEmpty(mSearchQuery)) {
exitSearchUi();
- hideInputMethod(parentLayout);
+ DialerUtils.hideInputMethod(parentLayout);
return true;
}
return false;
@@ -989,7 +981,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
public void onListFragmentScrollStateChange(int scrollState) {
if (scrollState == OnScrollListener.SCROLL_STATE_TOUCH_SCROLL) {
hideDialpadFragment(true, false);
- hideInputMethod(getCurrentFocus());
+ DialerUtils.hideInputMethod(getCurrentFocus());
}
}
diff --git a/src/com/android/dialer/util/DialerUtils.java b/src/com/android/dialer/util/DialerUtils.java
index 07a330e6c..bd1813354 100644
--- a/src/com/android/dialer/util/DialerUtils.java
+++ b/src/com/android/dialer/util/DialerUtils.java
@@ -26,6 +26,7 @@ import android.net.Uri;
import android.provider.Telephony;
import android.text.TextUtils;
import android.view.View;
+import android.view.inputmethod.InputMethodManager;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
@@ -147,4 +148,20 @@ public class DialerUtils {
return TextUtils.getLayoutDirectionFromLocale(Locale.getDefault()) ==
View.LAYOUT_DIRECTION_RTL;
}
+
+ public static void showInputMethod(View view) {
+ final InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(
+ Context.INPUT_METHOD_SERVICE);
+ if (imm != null) {
+ imm.showSoftInput(view, 0);
+ }
+ }
+
+ public static void hideInputMethod(View view) {
+ final InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(
+ Context.INPUT_METHOD_SERVICE);
+ if (imm != null) {
+ imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
+ }
+ }
}
diff --git a/src/com/android/dialer/widget/SearchEditTextLayout.java b/src/com/android/dialer/widget/SearchEditTextLayout.java
index 36e578953..919f65c3c 100644
--- a/src/com/android/dialer/widget/SearchEditTextLayout.java
+++ b/src/com/android/dialer/widget/SearchEditTextLayout.java
@@ -19,15 +19,14 @@ package com.android.dialer.widget;
import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.content.Context;
-import android.graphics.Color;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.View;
-import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.FrameLayout;
import com.android.dialer.R;
+import com.android.dialer.util.DialerUtils;
import com.android.phone.common.animation.AnimUtils;
public class SearchEditTextLayout extends FrameLayout {
@@ -106,7 +105,9 @@ public class SearchEditTextLayout extends FrameLayout {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
- showInputMethod(v);
+ DialerUtils.showInputMethod(v);
+ } else {
+ DialerUtils.hideInputMethod(v);
}
}
});
@@ -261,14 +262,6 @@ public class SearchEditTextLayout extends FrameLayout {
return mIsFadedOut;
}
- private void showInputMethod(View view) {
- final InputMethodManager imm = (InputMethodManager) getContext().getSystemService(
- Context.INPUT_METHOD_SERVICE);
- if (imm != null) {
- imm.showSoftInput(view, 0);
- }
- }
-
/**
* Assigns margins to the search box as a fraction of its maximum margin size
*