use the utility for contacts permission

This commit is contained in:
Eric House 2017-01-07 10:55:21 -08:00
parent ee81e3e6cc
commit 6203012db6
3 changed files with 13 additions and 24 deletions

View file

@ -115,7 +115,6 @@ public class DlgDelegate {
CLEAR_ACTION,
USE_IMMOBILE_ACTION,
POST_WARNING_ACTION,
RETRY_CONTACTS_ACTION,
// BT Invite
OPEN_BT_PREFS_ACTION,

View file

@ -180,10 +180,12 @@ public class Perms23 {
}
builder.asyncQuery( m_delegate.getActivity(), new PermCbck() {
public void onPermissionResult( Map<Perm, Boolean> perms ) {
if ( perms.get( m_perm ) ) {
m_cbck.onPosButton( m_action, m_params );
} else {
m_cbck.onNegButton( m_action, m_params );
if ( Action.SKIP_CALLBACK != m_action ) {
if ( perms.get( m_perm ) ) {
m_cbck.onPosButton( m_action, m_params );
} else {
m_cbck.onNegButton( m_action, m_params );
}
}
}
} );

View file

@ -92,7 +92,7 @@ public class SMSInviteDelegate extends InviteDelegate {
getSavedState();
rebuildList( true );
askContactsPermission( true );
askContactsPermission();
}
@Override
@ -190,9 +190,6 @@ public class SMSInviteDelegate extends InviteDelegate {
public void onPosButton( Action action, Object[] params )
{
switch ( action ) {
case RETRY_CONTACTS_ACTION:
askContactsPermission( false );
break;
case CLEAR_ACTION:
clearSelectedImpl();
break;
@ -334,22 +331,13 @@ public class SMSInviteDelegate extends InviteDelegate {
saveAndRebuild();
}
private void askContactsPermission( boolean showRationale )
private void askContactsPermission()
{
Perms23.Builder builder = new Perms23.Builder( Perm.READ_CONTACTS );
if ( showRationale ) {
builder.setOnShowRationale( new Perms23.OnShowRationale() {
@Override
public void onShouldShowRationale( Set<Perm> perms )
{
makeOkOnlyBuilder( R.string.contacts_rationale )
.setTitle( R.string.perms_rationale_title )
.setAction( Action.RETRY_CONTACTS_ACTION )
.show();
}
} );
}
builder.asyncQuery( m_activity );
// We want to ask, and to give the rationale, but behave the same
// regardless of the answers given. So SKIP_CALLBACK.
Perms23.tryGetPerms( this, Perm.READ_CONTACTS,
R.string.contacts_rationale,
Action.SKIP_CALLBACK, this );
}
private class PhoneRec implements InviterItem {