From 13221d724c9f26b8ff94c38d0911bbdcabdcb169 Mon Sep 17 00:00:00 2001 From: calderwoodra Date: Wed, 20 Sep 2017 16:08:29 -0700 Subject: Added dismiss button to location permission request. This change adds a dismiss button to the location permission prompt shown in the search UI. A few other minor changes: - Permission prompt is always the first element in the list - Adjusted a few dimensions and strings screenshot: http://screen/9CkRPUQ5dwh Bug: 65858857 Test: SAT, NSFT PiperOrigin-RevId: 169466585 Change-Id: I8177c23fe3f635fec5fdcdbe6675428cebb19f5d --- .../dialer/searchfragment/list/SearchAdapter.java | 31 +++++++++++++++------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'java/com/android/dialer/searchfragment/list/SearchAdapter.java') diff --git a/java/com/android/dialer/searchfragment/list/SearchAdapter.java b/java/com/android/dialer/searchfragment/list/SearchAdapter.java index 358a59a41..22bfa6dbd 100644 --- a/java/com/android/dialer/searchfragment/list/SearchAdapter.java +++ b/java/com/android/dialer/searchfragment/list/SearchAdapter.java @@ -56,7 +56,8 @@ public final class SearchAdapter extends RecyclerView.Adapter private boolean showZeroSuggest; private String query; private CallInitiationType.Type callInitiationType = CallInitiationType.Type.UNKNOWN_INITIATION; - private OnClickListener locationRequestClickListener; + private OnClickListener allowClickListener; + private OnClickListener dismissClickListener; @VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE) public SearchAdapter(Activity activity, SearchCursorManager searchCursorManager) { @@ -87,7 +88,8 @@ public final class SearchAdapter extends RecyclerView.Adapter case RowType.LOCATION_REQUEST: return new LocationPermissionViewHolder( LayoutInflater.from(activity).inflate(R.layout.location_permission_row, root, false), - locationRequestClickListener); + allowClickListener, + dismissClickListener); case RowType.INVALID: default: throw Assert.createIllegalStateFailException("Invalid RowType: " + rowType); @@ -178,10 +180,12 @@ public final class SearchAdapter extends RecyclerView.Adapter * Updates the adapter to show the location request row element. If the element was previously * hidden, the adapter will call {@link #notifyDataSetChanged()}. */ - public void showLocationPermissionRequest(OnClickListener clickListener) { - Assert.isNotNull(locationRequestClickListener = clickListener); + public void showLocationPermissionRequest( + OnClickListener allowClickListener, OnClickListener dismissClickListener) { + this.allowClickListener = Assert.isNotNull(allowClickListener); + this.dismissClickListener = Assert.isNotNull(dismissClickListener); if (searchCursorManager.showLocationPermissionRequest(true)) { - notifyDataSetChanged(); + notifyItemRemoved(0); } } @@ -190,9 +194,10 @@ public final class SearchAdapter extends RecyclerView.Adapter * visible, the adapter will call {@link #notifyDataSetChanged()}. */ void hideLocationPermissionRequest() { - locationRequestClickListener = null; + allowClickListener = null; + dismissClickListener = null; if (searchCursorManager.showLocationPermissionRequest(false)) { - notifyDataSetChanged(); + notifyItemRemoved(0); } } @@ -242,13 +247,19 @@ public final class SearchAdapter extends RecyclerView.Adapter /** Viewholder for R.layout.location_permission_row that requests the location permission. */ private static class LocationPermissionViewHolder extends RecyclerView.ViewHolder { - LocationPermissionViewHolder(View itemView, OnClickListener locationRequestClickListener) { + LocationPermissionViewHolder( + View itemView, OnClickListener allowClickListener, OnClickListener dismissClickListener) { super(itemView); - Assert.isNotNull(locationRequestClickListener); + Assert.isNotNull(allowClickListener); + Assert.isNotNull(dismissClickListener); itemView .findViewById( com.android.dialer.searchfragment.nearbyplaces.R.id.location_permission_allow) - .setOnClickListener(locationRequestClickListener); + .setOnClickListener(allowClickListener); + itemView + .findViewById( + com.android.dialer.searchfragment.nearbyplaces.R.id.location_permission_dismiss) + .setOnClickListener(dismissClickListener); } } } -- cgit v1.2.3