use tryGetPerms to replace a bunch of Perms23 crud -- again

This commit is contained in:
Eric House 2017-01-07 12:45:26 -08:00
parent a453676456
commit 734549668c
6 changed files with 53 additions and 66 deletions

View file

@ -2047,7 +2047,8 @@
<string name="connstat_net_noaddr">This networked game has no way
to connect and cannot be played.\n\n(It was probably created from
an invitation that didn\'t specify any way of connecting that your
device supports.)</string>
device supports, or you may have recently removed its last way of
connecting.)</string>
<!-- -->
<string name="connstat_net_fmt">Network status for game connected via
%1$s:</string>
@ -2741,13 +2742,14 @@
previously stored any there.
</string>
<string name="phone_state_rationale">Some phones can exchange SMS
\"data\" messages. Crosswords would like to offer you this option
but needs to ask your device about itself first (to learn if it\'s a
phone and if so what type.)\n\nIf your device can\'t send SMS
(e.g. because it isn\'t a phone) or you don\'t ever want to play via
SMS (e.g. because you pay for each message), it\'s safe to
permanently deny permission.
<string name="phone_state_rationale">
Some phones can exchange SMS \"data\" messages. Crosswords would
like to offer you this option but needs to ask your device about
itself first (to learn if it\'s a phone and if so what
type.)\n\nIf your device can\'t send data SMS (e.g. because it
isn\'t a phone) or you don\'t ever want to play via SMS
(e.g. because you pay for each message), it\'s safe to permanently
deny permission.
</string>
<string name="phone_lookup_rationale">

View file

@ -1768,7 +1768,8 @@
<string name="connstat_net_noaddr">Siht dekrowten emag sah on yaw
ot tcennoc dna tonnac eb deyalp.\n\ntI( saw ylbaborp detaerc morf
na noitativni taht ndid\'t yficeps yna yaw fo gnitcennoc taht ruoy
ecived stroppus.)</string>
ecived ,stroppus ro uoy yam evah yltnecer devomer sti tsal yaw fo
gnitcennoc.)</string>
<!-- -->
<string name="connstat_net_fmt">Krowten sutats rof emag detcennoc aiv
%1$s:</string>
@ -2339,13 +2340,14 @@
daolnwod stsildrow tpecxe morf edisni Sdrowssorc dna evah ton
ylsuoiverp derots yna ereht.
</string>
<string name="phone_state_rationale">Emos senohp nac egnahcxe SMS
\"atad\" segassem. Sdrowssorc dluow ekil ot reffo uoy siht noitpo
tub sdeen ot ksa ruoy ecived tuoba flesti tsrif ot( nrael fi ti\'s a
enohp dna fi os tahw epyt.)\n\nFi ruoy ecived nac\'t dnes SMS
e(.g. esuaceb ti nsi\'t a )enohp ro uoy nod\'t reve tnaw ot yalp aiv
SMS e(.g. esuaceb uoy yap rof hcae ,)egassem ti\'s efas ot
yltnenamrep yned noissimrep.
<string name="phone_state_rationale">
Emos senohp nac egnahcxe SMS \"atad\" segassem. Sdrowssorc dluow
ekil ot reffo uoy siht noitpo tub sdeen ot ksa ruoy ecived tuoba
flesti tsrif ot( nrael fi ti\'s a enohp dna fi os tahw
epyt.)\n\nFi ruoy ecived nac\'t dnes atad SMS e(.g. esuaceb ti
nsi\'t a )enohp ro uoy nod\'t reve tnaw ot yalp aiv SMS
e(.g. esuaceb uoy yap rof hcae ,)egassem ti\'s efas ot yltnenamrep
yned noissimrep.
</string>
<string name="phone_lookup_rationale">
Ot hctamer a emag taht sesu SMS Sdrowssorc sdeen noissimrep ot
@ -2356,7 +2358,8 @@
emag si ton elbissop tuohtiw siht noissimrep.</string>
<!-- Case where SMS is NOT the only way the game can communicate -->
<string name="phone_lookup_rationale_others">Tuohtiw siht noissimrep
gnihctamer lliw etaerc a emag taht tonnac ton yalp aiv SMS.</string>
gnihctamer lliw eunitnoc tub lliw etaerc a emag taht tonnac ton yalp
aiv SMS.</string>
<string name="contacts_rationale">
Sdrowssorc tnaw ssecca ot ruoy stcatnoc ni redro ot tup a eman ot
enohp srebmun taht dnes uoy snoitativni aiv SMS. Uoy\'ll llits eb

View file

@ -1768,7 +1768,8 @@
<string name="connstat_net_noaddr">THIS NETWORKED GAME HAS NO WAY
TO CONNECT AND CANNOT BE PLAYED.\n\n(IT WAS PROBABLY CREATED FROM
AN INVITATION THAT DIDN\'T SPECIFY ANY WAY OF CONNECTING THAT YOUR
DEVICE SUPPORTS.)</string>
DEVICE SUPPORTS, OR YOU MAY HAVE RECENTLY REMOVED ITS LAST WAY OF
CONNECTING.)</string>
<!-- -->
<string name="connstat_net_fmt">NETWORK STATUS FOR GAME CONNECTED VIA
%1$s:</string>
@ -2339,13 +2340,14 @@
DOWNLOAD WORDLISTS EXCEPT FROM INSIDE CROSSWORDS AND HAVE NOT
PREVIOUSLY STORED ANY THERE.
</string>
<string name="phone_state_rationale">SOME PHONES CAN EXCHANGE SMS
\"DATA\" MESSAGES. CROSSWORDS WOULD LIKE TO OFFER YOU THIS OPTION
BUT NEEDS TO ASK YOUR DEVICE ABOUT ITSELF FIRST (TO LEARN IF IT\'S A
PHONE AND IF SO WHAT TYPE.)\n\nIF YOUR DEVICE CAN\'T SEND SMS
(E.G. BECAUSE IT ISN\'T A PHONE) OR YOU DON\'T EVER WANT TO PLAY VIA
SMS (E.G. BECAUSE YOU PAY FOR EACH MESSAGE), IT\'S SAFE TO
PERMANENTLY DENY PERMISSION.
<string name="phone_state_rationale">
SOME PHONES CAN EXCHANGE SMS \"DATA\" MESSAGES. CROSSWORDS WOULD
LIKE TO OFFER YOU THIS OPTION BUT NEEDS TO ASK YOUR DEVICE ABOUT
ITSELF FIRST (TO LEARN IF IT\'S A PHONE AND IF SO WHAT
TYPE.)\n\nIF YOUR DEVICE CAN\'T SEND DATA SMS (E.G. BECAUSE IT
ISN\'T A PHONE) OR YOU DON\'T EVER WANT TO PLAY VIA SMS
(E.G. BECAUSE YOU PAY FOR EACH MESSAGE), IT\'S SAFE TO PERMANENTLY
DENY PERMISSION.
</string>
<string name="phone_lookup_rationale">
TO REMATCH A GAME THAT USES SMS CROSSWORDS NEEDS PERMISSION TO
@ -2356,7 +2358,8 @@
GAME IS NOT POSSIBLE WITHOUT THIS PERMISSION.</string>
<!-- Case where SMS is NOT the only way the game can communicate -->
<string name="phone_lookup_rationale_others">WITHOUT THIS PERMISSION
REMATCHING WILL CREATE A GAME THAT CANNOT NOT PLAY VIA SMS.</string>
REMATCHING WILL CONTINUE BUT WILL CREATE A GAME THAT CANNOT NOT PLAY
VIA SMS.</string>
<string name="contacts_rationale">
CROSSWORDS WANT ACCESS TO YOUR CONTACTS IN ORDER TO PUT A NAME TO
PHONE NUMBERS THAT SEND YOU INVITATIONS VIA SMS. YOU\'LL STILL BE

View file

@ -407,8 +407,7 @@ public class BoardDelegate extends DelegateBase
if ( self.m_summary.hasRematchInfo() ) {
self.tryRematchInvites( true );
} else {
self.callInviteChoices( Action.LAUNCH_INVITE_ACTION,
self.m_sentInfo, true );
self.callInviteChoices( self.m_sentInfo );
}
} else {
self.askDropRelay();
@ -723,37 +722,17 @@ public class BoardDelegate extends DelegateBase
// loop of showing the rationale over and over. Android will always tell
// us to show the rationale, but if we've done it already we need to go
// straight to asking for the permission.
private void callInviteChoices( final Action action,
final DBUtils.SentInvitesInfo info,
boolean showRationale )
private void callInviteChoices( final SentInvitesInfo info )
{
Perms23.Builder builder =
new Perms23.Builder( Perm.READ_PHONE_STATE );
if ( showRationale ) {
builder.setOnShowRationale( new Perms23.OnShowRationale() {
@Override
public void onShouldShowRationale( Set<Perm> perms )
{
makeOkOnlyBuilder( R.string.phone_state_rationale )
.setTitle( R.string.perms_rationale_title )
.setAction( Action.RETRY_PHONE_STATE_ACTION )
.setParams( action, info )
.show();
}
} );
Perms23.tryGetPerms( this, Perm.READ_PHONE_STATE,
R.string.phone_state_rationale,
Action.ASKED_PHONE_STATE, this, info );
}
builder.asyncQuery( m_activity, new Perms23.PermCbck() {
@Override
public void onPermissionResult( Map<Perm,
Boolean> perms )
private void showInviteChoicesThen( Object[] params )
{
// Do the work regardless of result; just won't have
// SMS option
showInviteChoicesThen( action, info );
}
});
SentInvitesInfo info = (SentInvitesInfo)params[0];
showInviteChoicesThen( Action.LAUNCH_INVITE_ACTION, info );
}
@Override
@ -1035,12 +1014,6 @@ public class BoardDelegate extends DelegateBase
case ENABLE_RELAY_DO_OR:
RelayService.setEnabled( m_activity, true );
break;
case RETRY_PHONE_STATE_ACTION:
Action stateAction = (Action)params[0];
SentInvitesInfo info = (SentInvitesInfo)params[1];
callInviteChoices( stateAction, info, false );
break;
case UNDO_LAST_ACTION:
cmd = JNICmd.CMD_UNDO_LAST;
break;
@ -1110,11 +1083,15 @@ public class BoardDelegate extends DelegateBase
case INVITE_SMS:
int nMissing = (Integer)params[0];
info = (SentInvitesInfo)params[1];
SentInvitesInfo info = (SentInvitesInfo)params[1];
SMSInviteDelegate.launchForResult( m_activity, nMissing, info,
RequestCode.SMS_INVITE_RESULT );
break;
case ASKED_PHONE_STATE:
showInviteChoicesThen( params );
break;
case ENABLE_SMS_DO:
post( new Runnable() {
public void run() {
@ -1144,6 +1121,9 @@ public class BoardDelegate extends DelegateBase
case DELETE_AND_EXIT:
finish();
break;
case ASKED_PHONE_STATE:
showInviteChoicesThen( params );
break;
default:
super.onNegButton( action, params );
}

View file

@ -94,7 +94,6 @@ public class DlgDelegate {
DROP_RELAY_ACTION,
DROP_SMS_ACTION,
INVITE_SMS,
RETRY_PHONE_STATE_ACTION,
// Dict Browser
FINISH_ACTION,

View file

@ -789,7 +789,7 @@ public class GameConfigDelegate extends DelegateBase
R.string.phone_state_rationale,
Action.ASKED_PHONE_STATE, this );
} else {
onPosButton( Action.ASKED_PHONE_STATE, null );
showDialog( DlgID.CHANGE_CONN );
}
}