From c0326e9b6b013321c44f9b1ab1a640d361379774 Mon Sep 17 00:00:00 2001 From: calderwoodra Date: Tue, 23 Jan 2018 12:50:03 -0800 Subject: Contacts recyclerview is now hidden when we don't have contacts permission. Bug: 71867982 Test: ContactsFragmentTest PiperOrigin-RevId: 182977635 Change-Id: Ibdefc49c76dd607c5f1316ae46da5e38f74c0e85 --- .../android/dialer/contactsfragment/ContactsFragment.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'java') diff --git a/java/com/android/dialer/contactsfragment/ContactsFragment.java b/java/com/android/dialer/contactsfragment/ContactsFragment.java index 714739300..ae2bd746a 100644 --- a/java/com/android/dialer/contactsfragment/ContactsFragment.java +++ b/java/com/android/dialer/contactsfragment/ContactsFragment.java @@ -46,7 +46,6 @@ import com.android.contacts.common.preference.ContactsPreferences.ChangeListener import com.android.dialer.common.Assert; import com.android.dialer.common.FragmentUtils; import com.android.dialer.common.LogUtil; -import com.android.dialer.contactsfragment.ContactsFragment.OnContactSelectedListener; import com.android.dialer.performancereport.PerformanceReport; import com.android.dialer.util.DialerUtils; import com.android.dialer.util.IntentUtil; @@ -86,7 +85,7 @@ public class ContactsFragment extends Fragment new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { - getLoaderManager().initLoader(0, null, ContactsFragment.this); + loadContacts(); } }; @@ -208,11 +207,12 @@ public class ContactsFragment extends Fragment emptyContentView.setActionClickedListener(this); if (PermissionsUtil.hasContactsReadPermissions(getContext())) { - getLoaderManager().initLoader(0, null, this); + loadContacts(); } else { emptyContentView.setDescription(R.string.permission_no_contacts); emptyContentView.setActionLabel(R.string.permission_single_turn_on); emptyContentView.setVisibility(View.VISIBLE); + recyclerView.setVisibility(View.GONE); } return view; @@ -349,12 +349,17 @@ public class ContactsFragment extends Fragment if (requestCode == READ_CONTACTS_PERMISSION_REQUEST_CODE) { if (grantResults.length >= 1 && PackageManager.PERMISSION_GRANTED == grantResults[0]) { // Force a refresh of the data since we were missing the permission before this. - emptyContentView.setVisibility(View.GONE); - getLoaderManager().initLoader(0, null, this); + PermissionsUtil.notifyPermissionGranted(getContext(), permissions[0]); } } } + private void loadContacts() { + getLoaderManager().initLoader(0, null, this); + recyclerView.setVisibility(View.VISIBLE); + emptyContentView.setVisibility(View.GONE); + } + /** Listener for contacts list scroll state. */ public interface OnContactsListScrolledListener { void onContactsListScrolled(boolean isDragging); -- cgit v1.2.3