summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Lee <anwlee@google.com>2014-05-15 14:18:50 -0700
committerAndrew Lee <anwlee@google.com>2014-05-15 14:37:45 -0700
commit99a570c40193320e8640f91a2eb4693e46153703 (patch)
treedacec5cfe1bccde2a562c5bd0c7de76bef84c5bd
parent437858ccdf5257760310d90004030a597e514f3e (diff)
Don't exit search ui if query string is empty.
Bug: 14900155 Change-Id: Ic0c353d04491288428663c5350abffe514f96149
-rw-r--r--src/com/android/dialer/DialtactsActivity.java117
1 files changed, 49 insertions, 68 deletions
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java
index 571787577..63a31a0ee 100644
--- a/src/com/android/dialer/DialtactsActivity.java
+++ b/src/com/android/dialer/DialtactsActivity.java
@@ -99,7 +99,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
DialpadFragment.HostInterface,
ListsFragment.HostInterface,
SpeedDialFragment.HostInterface,
- OnDragDropListener, View.OnLongClickListener,
+ OnDragDropListener,
OnPhoneNumberPickerActionListener,
ViewPager.OnPageChangeListener {
private static final String TAG = "DialtactsActivity";
@@ -243,55 +243,51 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
* Listener used to send search queries to the phone search fragment.
*/
private final TextWatcher mPhoneSearchQueryTextListener = new TextWatcher() {
- @Override
- public void beforeTextChanged(CharSequence s, int start, int count, int after) {
- }
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+ }
- @Override
- public void onTextChanged(CharSequence s, int start, int before, int count) {
- final String newText = s.toString();
- if (newText.equals(mSearchQuery)) {
- // If the query hasn't changed (perhaps due to activity being destroyed
- // and restored, or user launching the same DIAL intent twice), then there is
- // no need to do anything here.
- return;
- }
- mSearchQuery = newText;
- if (DEBUG) {
- Log.d(TAG, "onTextChange for mSearchView called with new query: " + newText);
- }
- final boolean dialpadSearch = mIsDialpadShown;
-
- // Show search result with non-empty text. Show a bare list otherwise.
- if (TextUtils.isEmpty(newText) && getInSearchUi()) {
- exitSearchUi();
- mSearchViewCloseButton.setVisibility(View.GONE);
- mVoiceSearchButton.setVisibility(View.VISIBLE);
- return;
- } else if (!TextUtils.isEmpty(newText)) {
- final boolean sameSearchMode = (dialpadSearch && mInDialpadSearch) ||
- (!dialpadSearch && mInRegularSearch);
- if (!sameSearchMode) {
- // call enterSearchUi only if we are switching search modes, or entering
- // search ui for the first time
- enterSearchUi(dialpadSearch, newText);
- }
-
- if (dialpadSearch && mSmartDialSearchFragment != null) {
- mSmartDialSearchFragment.setQueryString(newText, false);
- } else if (mRegularSearchFragment != null) {
- mRegularSearchFragment.setQueryString(newText, false);
- }
- mSearchViewCloseButton.setVisibility(View.VISIBLE);
- mVoiceSearchButton.setVisibility(View.GONE);
- return;
- }
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ final String newText = s.toString();
+ if (newText.equals(mSearchQuery)) {
+ // If the query hasn't changed (perhaps due to activity being destroyed
+ // and restored, or user launching the same DIAL intent twice), then there is
+ // no need to do anything here.
return;
}
+ mSearchQuery = newText;
+ if (DEBUG) {
+ Log.d(TAG, "onTextChange for mSearchView called with new query: " + newText);
+ }
+
+ // Show search result with non-empty text. Show a bare list otherwise.
+ final boolean sameSearchMode = (mIsDialpadShown && mInDialpadSearch) ||
+ (!mIsDialpadShown && mInRegularSearch);
+ if (!sameSearchMode) {
+ // call enterSearchUi only if we are switching search modes, or entering
+ // search ui for the first time
+ enterSearchUi(mIsDialpadShown, newText);
+ }
+
+ if (mIsDialpadShown && mSmartDialSearchFragment != null) {
+ mSmartDialSearchFragment.setQueryString(newText, false /* delaySelection */);
+ } else if (mRegularSearchFragment != null) {
+ mRegularSearchFragment.setQueryString(newText, false /* delaySelection */);
+ }
- @Override
- public void afterTextChanged(Editable s) {
+ if (TextUtils.isEmpty(newText)) {
+ mSearchViewCloseButton.setVisibility(View.GONE);
+ mVoiceSearchButton.setVisibility(View.VISIBLE);
+ } else {
+ mSearchViewCloseButton.setVisibility(View.VISIBLE);
+ mVoiceSearchButton.setVisibility(View.GONE);
}
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {
+ }
};
@Override
@@ -397,12 +393,14 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
} else if (fragment instanceof SmartDialSearchFragment) {
mSmartDialSearchFragment = (SmartDialSearchFragment) fragment;
mSmartDialSearchFragment.setOnPhoneNumberPickerActionListener(this);
+ mSmartDialSearchFragment.setShowEmptyListForNullQuery(true);
if (mFragmentsFrame != null) {
mFragmentsFrame.setAlpha(1.0f);
}
} else if (fragment instanceof SearchFragment) {
mRegularSearchFragment = (RegularSearchFragment) fragment;
mRegularSearchFragment.setOnPhoneNumberPickerActionListener(this);
+ mRegularSearchFragment.setShowEmptyListForNullQuery(true);
if (mFragmentsFrame != null) {
mFragmentsFrame.setAlpha(1.0f);
}
@@ -493,22 +491,6 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
}
@Override
- public boolean onLongClick(View view) {
- switch (view.getId()) {
- case R.id.floating_action_button:
- if (mIsDialpadShown) {
- // Dial button was pressed; tell the Dialpad fragment
- mDialpadFragment.dialButtonPressed();
- return true; // Consume the event
- }
- default:
- Log.wtf(TAG, "Unexpected onClick event from " + view);
- break;
- }
- return false;
- }
-
- @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == ACTIVITY_REQUEST_CODE_VOICE_SEARCH) {
if (resultCode == RESULT_OK) {
@@ -775,8 +757,6 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
}
final FragmentTransaction transaction = getFragmentManager().beginTransaction();
-
- SearchFragment fragment;
if (mInDialpadSearch && mSmartDialSearchFragment != null) {
transaction.remove(mSmartDialSearchFragment);
} else if (mInRegularSearch && mRegularSearchFragment != null) {
@@ -792,7 +772,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
mInDialpadSearch = smartDialSearch;
mInRegularSearch = !smartDialSearch;
- fragment = (SearchFragment) getFragmentManager().findFragmentByTag(tag);
+ SearchFragment fragment = (SearchFragment) getFragmentManager().findFragmentByTag(tag);
if (fragment == null) {
if (smartDialSearch) {
fragment = new SmartDialSearchFragment();
@@ -804,7 +784,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
fragment.setHasOptionsMenu(false);
transaction.replace(R.id.dialtacts_frame, fragment, tag);
transaction.addToBackStack(null);
- fragment.setQueryString(query, false);
+ fragment.setQueryString(query, false /* delaySelection */);
transaction.commit();
}
@@ -841,6 +821,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
} else if (getInSearchUi()) {
mSearchView.setText(null);
mDialpadFragment.clearDialpad();
+ exitSearchUi();
} else {
super.onBackPressed();
}
@@ -883,7 +864,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
@Override
public void onListFragmentScroll(int firstVisibleItem, int visibleItemCount,
- int totalItemCount) {
+ int totalItemCount) {
// TODO: No-op for now. This should eventually show/hide the actionBar based on
// interactions with the ListsFragments.
}
@@ -962,7 +943,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
// Specify call-origin so that users will see the previous tab instead of
// CallLog screen (search UI will be automatically exited).
PhoneNumberInteraction.startInteractionForPhoneCall(
- DialtactsActivity.this, dataUri, getCallOrigin());
+ DialtactsActivity.this, dataUri, getCallOrigin());
mClearSearchOnPause = true;
}
@@ -1059,4 +1040,4 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
public void onAnimationRepeat(Animation animation) {
}
}
-}
+} \ No newline at end of file