mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-15 15:41:24 +01:00
use the utility for contacts permission
This commit is contained in:
parent
ee81e3e6cc
commit
6203012db6
3 changed files with 13 additions and 24 deletions
|
@ -115,7 +115,6 @@ public class DlgDelegate {
|
|||
CLEAR_ACTION,
|
||||
USE_IMMOBILE_ACTION,
|
||||
POST_WARNING_ACTION,
|
||||
RETRY_CONTACTS_ACTION,
|
||||
|
||||
// BT Invite
|
||||
OPEN_BT_PREFS_ACTION,
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue