summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2014-05-20 17:21:25 -0700
committerYorke Lee <yorkelee@google.com>2014-05-20 18:20:42 -0700
commitc7b2a0e30aba4505a041a9ad0f8889f4891d30f8 (patch)
tree632263146b6a74e7ae4e90de2e3391783ef176ff /src
parent11ca39eae2bd8ed5c3e21e8c4fa09c9b2b6bda51 (diff)
Clean up some interactions in entering/exiting searchUI
Entering/exiting the search UI should now behave as a state machine that is described as follows: * Tapping on the search box or the dialpad brings up the search UI * If back is pressed when in the search UI, one of three things happens 1) If the dialpad or IME is up and a query exists in the searchbox or the dialpad, the IME/dialpad is hidden to allow the user to scroll search results. 2) If the dialpad or IME is up and the query is empty, hide the dialpad and IME, and exit the search UI. 3) If the dialpad or IME is not up and the query is not empty, clear the search query and exit the search UI. Change-Id: I9ba21227e1f1fcba4cde1101b3516009ee55da12
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dialer/DialtactsActivity.java30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java
index d89860008..c164294c7 100644
--- a/src/com/android/dialer/DialtactsActivity.java
+++ b/src/com/android/dialer/DialtactsActivity.java
@@ -48,6 +48,7 @@ import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnDragListener;
+import android.view.View.OnTouchListener;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
@@ -305,7 +306,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN &&
TextUtils.isEmpty(mSearchView.getText().toString())) {
- onBackPressed();
+ maybeExitSearchUi();
}
return false;
}
@@ -367,6 +368,8 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
parentLayout.getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING);
parentLayout.setOnDragListener(new LayoutOnDragListener());
+ setupActivityOverlay();
+
mFloatingActionButtonContainer = findViewById(R.id.floating_action_button_container);
ViewUtil.setupFloatingActionButton(mFloatingActionButtonContainer, getResources());
@@ -379,6 +382,19 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
SmartDialPrefix.initializeNanpSettings(this);
}
+ private void setupActivityOverlay() {
+ final View activityOverlay = findViewById(R.id.activity_overlay);
+ activityOverlay.setOnTouchListener(new OnTouchListener() {
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ if (!mIsDialpadShown) {
+ maybeExitSearchUi();
+ }
+ return false;
+ }
+ });
+ }
+
@Override
protected void onResume() {
super.onResume();
@@ -865,6 +881,18 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
}
}
+ /**
+ * @return True if the search UI was exited, false otherwise
+ */
+ private boolean maybeExitSearchUi() {
+ if (isInSearchUi() && TextUtils.isEmpty(mSearchQuery)) {
+ exitSearchUi();
+ hideInputMethod(parentLayout);
+ return true;
+ }
+ return false;
+ }
+
@Override
public void onDialpadQueryChanged(String query) {
if (mSmartDialSearchFragment != null) {