summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/searchfragment
diff options
context:
space:
mode:
authorcalderwoodra <calderwoodra@google.com>2017-10-13 16:36:17 -0700
committerEric Erfanian <erfanian@google.com>2017-10-13 18:02:38 -0700
commitc37701295f8a4552f5d92437c8bbcf481495b06b (patch)
tree65811cedf7eabf44e94d8f6f4f96162182f2d4bd /java/com/android/dialer/searchfragment
parent65aa3b3677537974f2136c702828d70a60fe6361 (diff)
Bug fixes for new search ui w/ Dialpad.
- Dialpad now hides if user tries to scroll w/ a search query. - Search now closes if the user touches the blank area w/o a search query. - Since we don't even show location results in dialpad search, we no longer request location permission in it. Bug: 67657783,67656915 Test: tba PiperOrigin-RevId: 172162620 Change-Id: I33a814797a053600e56fb163fd55b0c43e00a9c6
Diffstat (limited to 'java/com/android/dialer/searchfragment')
-rw-r--r--java/com/android/dialer/searchfragment/list/NewSearchFragment.java30
1 files changed, 28 insertions, 2 deletions
diff --git a/java/com/android/dialer/searchfragment/list/NewSearchFragment.java b/java/com/android/dialer/searchfragment/list/NewSearchFragment.java
index b06f9c3ad..393b07a6b 100644
--- a/java/com/android/dialer/searchfragment/list/NewSearchFragment.java
+++ b/java/com/android/dialer/searchfragment/list/NewSearchFragment.java
@@ -33,7 +33,9 @@ import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
+import android.view.MotionEvent;
import android.view.View;
+import android.view.View.OnTouchListener;
import android.view.ViewGroup;
import android.view.animation.Interpolator;
import android.widget.FrameLayout;
@@ -42,6 +44,7 @@ import com.android.contacts.common.extensions.PhoneDirectoryExtenderAccessor;
import com.android.dialer.animation.AnimUtils;
import com.android.dialer.callintent.CallInitiationType;
import com.android.dialer.common.Assert;
+import com.android.dialer.common.FragmentUtils;
import com.android.dialer.common.LogUtil;
import com.android.dialer.common.concurrent.ThreadUtil;
import com.android.dialer.enrichedcall.EnrichedCallComponent;
@@ -68,7 +71,8 @@ import java.util.List;
public final class NewSearchFragment extends Fragment
implements LoaderCallbacks<Cursor>,
OnEmptyViewActionButtonClickedListener,
- CapabilitiesListener {
+ CapabilitiesListener,
+ OnTouchListener {
// Since some of our queries can generate network requests, we should delay them until the user
// stops typing to prevent generating too much network traffic.
@@ -127,6 +131,7 @@ public final class NewSearchFragment extends Fragment
emptyContentView = view.findViewById(R.id.empty_view);
recyclerView = view.findViewById(R.id.recycler_view);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
+ recyclerView.setOnTouchListener(this);
recyclerView.setAdapter(adapter);
if (!PermissionsUtil.hasContactsReadPermissions(getContext())) {
@@ -340,7 +345,7 @@ public final class NewSearchFragment extends Fragment
if (!PermissionsUtil.hasLocationPermissions(getContext())
&& !DialerUtils.getDefaultSharedPreferenceForDeviceProtectedStorageContext(getContext())
.getBoolean(KEY_LOCATION_PROMPT_DISMISSED, false)) {
- if (adapter != null) {
+ if (adapter != null && isRegularSearch()) {
adapter.showLocationPermissionRequest(
v -> requestLocationPermission(), v -> dismissLocationPermission());
}
@@ -427,7 +432,28 @@ public final class NewSearchFragment extends Fragment
return actions;
}
+ // Returns true if currently in Regular Search (as opposed to Dialpad Search).
private boolean isRegularSearch() {
return callInitiationType == CallInitiationType.Type.REGULAR_SEARCH;
}
+
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ if (event.getAction() == MotionEvent.ACTION_UP) {
+ v.performClick();
+ }
+ return FragmentUtils.getParentUnsafe(this, SearchFragmentListTouchListener.class)
+ .onSearchListTouch(event);
+ }
+
+ /** Callback to {@link NewSearchFragment}'s parent to notify when the list is touched. */
+ public interface SearchFragmentListTouchListener {
+
+ /**
+ * Called when the list view in {@link NewSearchFragment} is touched.
+ *
+ * @see OnTouchListener#onTouch(View, MotionEvent)
+ */
+ boolean onSearchListTouch(MotionEvent event);
+ }
}