From 734549668c5ff22946dc5abd21f2cc7ce797df33 Mon Sep 17 00:00:00 2001 From: Eric House Date: Sat, 7 Jan 2017 12:45:26 -0800 Subject: [PATCH] use tryGetPerms to replace a bunch of Perms23 crud -- again --- .../android/XWords4/res/values/strings.xml | 18 +++--- .../XWords4/res_src/values-ba_CK/strings.xml | 21 ++++--- .../XWords4/res_src/values-ca_PS/strings.xml | 21 ++++--- .../eehouse/android/xw4/BoardDelegate.java | 56 ++++++------------- .../org/eehouse/android/xw4/DlgDelegate.java | 1 - .../android/xw4/GameConfigDelegate.java | 2 +- 6 files changed, 53 insertions(+), 66 deletions(-) diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml index d8d4e3f48..2d7c46b51 100644 --- a/xwords4/android/XWords4/res/values/strings.xml +++ b/xwords4/android/XWords4/res/values/strings.xml @@ -2047,7 +2047,8 @@ 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.) + device supports, or you may have recently removed its last way of + connecting.) Network status for game connected via %1$s: @@ -2741,13 +2742,14 @@ previously stored any there. - 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. + + 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. diff --git a/xwords4/android/XWords4/res_src/values-ba_CK/strings.xml b/xwords4/android/XWords4/res_src/values-ba_CK/strings.xml index e31ac38e0..3cf927757 100644 --- a/xwords4/android/XWords4/res_src/values-ba_CK/strings.xml +++ b/xwords4/android/XWords4/res_src/values-ba_CK/strings.xml @@ -1768,7 +1768,8 @@ 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.) + ecived ,stroppus ro uoy yam evah yltnecer devomer sti tsal yaw fo + gnitcennoc.) Krowten sutats rof emag detcennoc aiv %1$s: @@ -2339,13 +2340,14 @@ daolnwod stsildrow tpecxe morf edisni Sdrowssorc dna evah ton ylsuoiverp derots yna ereht. - 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. + + 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. Ot hctamer a emag taht sesu SMS Sdrowssorc sdeen noissimrep ot @@ -2356,7 +2358,8 @@ emag si ton elbissop tuohtiw siht noissimrep. Tuohtiw siht noissimrep - gnihctamer lliw etaerc a emag taht tonnac ton yalp aiv SMS. + gnihctamer lliw eunitnoc tub lliw etaerc a emag taht tonnac ton yalp + aiv SMS. 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 diff --git a/xwords4/android/XWords4/res_src/values-ca_PS/strings.xml b/xwords4/android/XWords4/res_src/values-ca_PS/strings.xml index bedcf455b..77c263174 100644 --- a/xwords4/android/XWords4/res_src/values-ca_PS/strings.xml +++ b/xwords4/android/XWords4/res_src/values-ca_PS/strings.xml @@ -1768,7 +1768,8 @@ 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.) + DEVICE SUPPORTS, OR YOU MAY HAVE RECENTLY REMOVED ITS LAST WAY OF + CONNECTING.) NETWORK STATUS FOR GAME CONNECTED VIA %1$s: @@ -2339,13 +2340,14 @@ DOWNLOAD WORDLISTS EXCEPT FROM INSIDE CROSSWORDS AND HAVE NOT PREVIOUSLY STORED ANY THERE. - 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. + + 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. TO REMATCH A GAME THAT USES SMS CROSSWORDS NEEDS PERMISSION TO @@ -2356,7 +2358,8 @@ GAME IS NOT POSSIBLE WITHOUT THIS PERMISSION. WITHOUT THIS PERMISSION - REMATCHING WILL CREATE A GAME THAT CANNOT NOT PLAY VIA SMS. + REMATCHING WILL CONTINUE BUT WILL CREATE A GAME THAT CANNOT NOT PLAY + VIA SMS. 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 diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDelegate.java index 53695a112..05a9fd926 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDelegate.java @@ -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 ); + Perms23.tryGetPerms( this, Perm.READ_PHONE_STATE, + R.string.phone_state_rationale, + Action.ASKED_PHONE_STATE, this, info ); + } - if ( showRationale ) { - builder.setOnShowRationale( new Perms23.OnShowRationale() { - @Override - public void onShouldShowRationale( Set perms ) - { - makeOkOnlyBuilder( R.string.phone_state_rationale ) - .setTitle( R.string.perms_rationale_title ) - .setAction( Action.RETRY_PHONE_STATE_ACTION ) - .setParams( action, info ) - .show(); - } - } ); - } - - builder.asyncQuery( m_activity, new Perms23.PermCbck() { - @Override - public void onPermissionResult( Map perms ) - { - // Do the work regardless of result; just won't have - // SMS option - showInviteChoicesThen( action, info ); - } - }); + private void showInviteChoicesThen( Object[] params ) + { + 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 ); } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java index 75c5fd3a7..dd05d4b2d 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java @@ -94,7 +94,6 @@ public class DlgDelegate { DROP_RELAY_ACTION, DROP_SMS_ACTION, INVITE_SMS, - RETRY_PHONE_STATE_ACTION, // Dict Browser FINISH_ACTION, diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfigDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfigDelegate.java index fc29d366e..40aaf1d85 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfigDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfigDelegate.java @@ -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 ); } }