Contact access permission: Display "You didn't allow Riot to access your local contacts" instead of "No local contacts" when the user has denied the phonebook permission

This commit is contained in:
manuroe 2017-06-07 15:34:11 +02:00
parent 71d5131837
commit 4ab0751e56
2 changed files with 25 additions and 1 deletions

View file

@ -160,6 +160,8 @@
"contacts_address_book_section" = "LOCAL CONTACTS";
"contacts_address_book_matrix_users_toggle" = "Matrix users only";
"contacts_address_book_no_contact" = "No local contacts";
"contacts_address_book_permission_required" = "Permission required to access local contacts";
"contacts_address_book_permission_denied" = "You didn't allow Riot to access your local contacts";
"contacts_matrix_users_section" = "KNOWN CONTACTS";
// Chat participants

View file

@ -529,7 +529,29 @@
}
else if (indexPath.section == filteredLocalContactsSection)
{
tableViewCell.textLabel.text = NSLocalizedStringFromTable(@"contacts_address_book_no_contact", @"Vector", nil);
tableViewCell.textLabel.numberOfLines = 0;
// Indicate to the user why there is no contacts
switch (ABAddressBookGetAuthorizationStatus())
{
case kABAuthorizationStatusAuthorized:
// Because there is no contacts on the device
tableViewCell.textLabel.text = NSLocalizedStringFromTable(@"contacts_address_book_no_contact", @"Vector", nil);
break;
case kABAuthorizationStatusNotDetermined:
// Because the user have not granted the permission yet
// (The permission request popup is displayed at the same time)
tableViewCell.textLabel.text = NSLocalizedStringFromTable(@"contacts_address_book_permission_required", @"Vector", nil);
break;
default:
{
// Because the user didn't allow the app to access local contacts
tableViewCell.textLabel.text = NSLocalizedStringFromTable(@"contacts_address_book_permission_denied", @"Vector", nil);
break;
}
}
}
return tableViewCell;
}