diff options
author | calderwoodra <calderwoodra@google.com> | 2018-01-23 12:50:03 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-01-23 13:10:14 -0800 |
commit | c0326e9b6b013321c44f9b1ab1a640d361379774 (patch) | |
tree | 614a2f754bab300afd9b10eea9cb503531d98f22 | |
parent | 8d06ecde0ec7040d00efec6bff367bedee426fc6 (diff) |
Contacts recyclerview is now hidden when we don't have contacts permission.
Bug: 71867982
Test: ContactsFragmentTest
PiperOrigin-RevId: 182977635
Change-Id: Ibdefc49c76dd607c5f1316ae46da5e38f74c0e85
-rw-r--r-- | java/com/android/dialer/contactsfragment/ContactsFragment.java | 15 |
1 files changed, 10 insertions, 5 deletions
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); |