diff options
Diffstat (limited to 'java/com/android/dialer/searchfragment')
-rw-r--r-- | java/com/android/dialer/searchfragment/list/NewSearchFragment.java | 10 | ||||
-rw-r--r-- | java/com/android/dialer/searchfragment/list/SearchAdapter.java | 2 |
2 files changed, 9 insertions, 3 deletions
diff --git a/java/com/android/dialer/searchfragment/list/NewSearchFragment.java b/java/com/android/dialer/searchfragment/list/NewSearchFragment.java index 393b07a6b..6115c2f1c 100644 --- a/java/com/android/dialer/searchfragment/list/NewSearchFragment.java +++ b/java/com/android/dialer/searchfragment/list/NewSearchFragment.java @@ -345,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 && isRegularSearch()) { + if (adapter != null && isRegularSearch() && !hasBeenDismissed()) { adapter.showLocationPermissionRequest( v -> requestLocationPermission(), v -> dismissLocationPermission()); } @@ -372,7 +372,8 @@ public final class NewSearchFragment extends Fragment requestPermissions(deniedPermissions, LOCATION_PERMISSION_REQUEST_CODE); } - private void dismissLocationPermission() { + @VisibleForTesting + public void dismissLocationPermission() { PreferenceManager.getDefaultSharedPreferences(getContext()) .edit() .putBoolean(KEY_LOCATION_PROMPT_DISMISSED, true) @@ -380,6 +381,11 @@ public final class NewSearchFragment extends Fragment adapter.hideLocationPermissionRequest(); } + private boolean hasBeenDismissed() { + return PreferenceManager.getDefaultSharedPreferences(getContext()) + .getBoolean(KEY_LOCATION_PROMPT_DISMISSED, false); + } + @Override public void onResume() { super.onResume(); diff --git a/java/com/android/dialer/searchfragment/list/SearchAdapter.java b/java/com/android/dialer/searchfragment/list/SearchAdapter.java index 29e4e2320..949c2a2c5 100644 --- a/java/com/android/dialer/searchfragment/list/SearchAdapter.java +++ b/java/com/android/dialer/searchfragment/list/SearchAdapter.java @@ -187,7 +187,7 @@ public final class SearchAdapter extends RecyclerView.Adapter<ViewHolder> this.allowClickListener = Assert.isNotNull(allowClickListener); this.dismissClickListener = Assert.isNotNull(dismissClickListener); if (searchCursorManager.showLocationPermissionRequest(true)) { - notifyItemRemoved(0); + notifyItemInserted(0); } } |