add special title to permissions rationale alerts

This commit is contained in:
Eric House 2016-12-31 16:27:17 -08:00
parent 8c7e1646fa
commit 59c80f8277
9 changed files with 35 additions and 23 deletions

View file

@ -5040,6 +5040,7 @@ XLATE-ME
explanation of the above explanation of the above
*/ */
public static final int peek_other_summary=0x7f05015d; public static final int peek_other_summary=0x7f05015d;
public static final int perms_rationale_title=0x7f050361;
/** /**
<string name="phone_label">Connected number[s]:</string> <string name="phone_label">Connected number[s]:</string>
@ -6887,9 +6888,7 @@ string name="str_robot_moved">O robô fez esta jogada:\u0020</string
feature is not yet supported on Android.) feature is not yet supported on Android.)
*/ */
public static final int title_tile_picker=0x7f0501b4; public static final int title_tile_picker=0x7f0501b4;
/** <string name="perms_rationale_title">Android Permissions</string> public static final int toast_no_permission=0x7f050362;
*/
public static final int toast_no_permission=0x7f050361;
/** <string name="update_dicts_fmt">Updates are available for one or more /** <string name="update_dicts_fmt">Updates are available for one or more
installed wordlists. Would you like to download the new installed wordlists. Would you like to download the new
version[s] of %1$s now?</string> version[s] of %1$s now?</string>

View file

@ -2734,9 +2734,8 @@
deny permission. deny permission.
</string> </string>
<string name="phone_lookup_rationale">Crosswords needs your phone <string name="phone_lookup_rationale">To rematch a game using SMS
number to initialize a game played via SMS, and needs your Crosswords needs permission to access your phone number.</string>
permission now in order to access it.</string>
<!-- Case where SMS is the only way the game can communicate --> <!-- Case where SMS is the only way the game can communicate -->
<string name="phone_lookup_rationale_drop">Rematching this SMS-only <string name="phone_lookup_rationale_drop">Rematching this SMS-only
@ -2755,7 +2754,7 @@
<string name="contact_not_found">Not in Contacts</string> <string name="contact_not_found">Not in Contacts</string>
<string name="sms_send_failed">SMS send failed</string> <string name="sms_send_failed">SMS send failed</string>
<!-- <string name="perms_rationale_title">Android Permissions</string> --> <string name="perms_rationale_title">Android Permissions</string>
<string name="toast_no_permission">Permission not granted</string> <string name="toast_no_permission">Permission not granted</string>
</resources> </resources>

View file

@ -2334,9 +2334,8 @@
e(.g. esuaceb uoy yap rof hcae ,)egassem ti\'s efas ot yltnenamrep e(.g. esuaceb uoy yap rof hcae ,)egassem ti\'s efas ot yltnenamrep
yned noissimrep. yned noissimrep.
</string> </string>
<string name="phone_lookup_rationale">Sdrowssorc sdeen ruoy enohp <string name="phone_lookup_rationale">Ot hctamer a emag gnisu SMS
rebmun ot ezilaitini a emag deyalp aiv ,SMs dna sdeen ruoy Sdrowssorc sdeen noissimrep ot ssecca ruoy enohp rebmun.</string>
noissimrep won ni redro ot ssecca ti.</string>
<!-- Case where SMS is the only way the game can communicate --> <!-- Case where SMS is the only way the game can communicate -->
<string name="phone_lookup_rationale_drop">Gnihctamer siht YLNo-sms <string name="phone_lookup_rationale_drop">Gnihctamer siht YLNo-sms
emag si ton elbissop tuohtiw siht noissimrep.</string> emag si ton elbissop tuohtiw siht noissimrep.</string>
@ -2351,6 +2350,6 @@
<string name="remove_sms">Evomer SMS</string> <string name="remove_sms">Evomer SMS</string>
<string name="contact_not_found">Ton ni Stcatnoc</string> <string name="contact_not_found">Ton ni Stcatnoc</string>
<string name="sms_send_failed">SMS dnes deliaf</string> <string name="sms_send_failed">SMS dnes deliaf</string>
<!-- <string name="perms_rationale_title">Android Permissions</string> --> <string name="perms_rationale_title">Diordna Snoissimrep</string>
<string name="toast_no_permission">Noissimrep ton detnarg</string> <string name="toast_no_permission">Noissimrep ton detnarg</string>
</resources> </resources>

View file

@ -2334,9 +2334,8 @@
(E.G. BECAUSE YOU PAY FOR EACH MESSAGE), IT\'S SAFE TO PERMANENTLY (E.G. BECAUSE YOU PAY FOR EACH MESSAGE), IT\'S SAFE TO PERMANENTLY
DENY PERMISSION. DENY PERMISSION.
</string> </string>
<string name="phone_lookup_rationale">CROSSWORDS NEEDS YOUR PHONE <string name="phone_lookup_rationale">TO REMATCH A GAME USING SMS
NUMBER TO INITIALIZE A GAME PLAYED VIA SMS, AND NEEDS YOUR CROSSWORDS NEEDS PERMISSION TO ACCESS YOUR PHONE NUMBER.</string>
PERMISSION NOW IN ORDER TO ACCESS IT.</string>
<!-- Case where SMS is the only way the game can communicate --> <!-- Case where SMS is the only way the game can communicate -->
<string name="phone_lookup_rationale_drop">REMATCHING THIS SMS-ONLY <string name="phone_lookup_rationale_drop">REMATCHING THIS SMS-ONLY
GAME IS NOT POSSIBLE WITHOUT THIS PERMISSION.</string> GAME IS NOT POSSIBLE WITHOUT THIS PERMISSION.</string>
@ -2351,6 +2350,6 @@
<string name="remove_sms">REMOVE SMS</string> <string name="remove_sms">REMOVE SMS</string>
<string name="contact_not_found">NOT IN CONTACTS</string> <string name="contact_not_found">NOT IN CONTACTS</string>
<string name="sms_send_failed">SMS SEND FAILED</string> <string name="sms_send_failed">SMS SEND FAILED</string>
<!-- <string name="perms_rationale_title">Android Permissions</string> --> <string name="perms_rationale_title">ANDROID PERMISSIONS</string>
<string name="toast_no_permission">PERMISSION NOT GRANTED</string> <string name="toast_no_permission">PERMISSION NOT GRANTED</string>
</resources> </resources>

View file

@ -736,6 +736,7 @@ public class BoardDelegate extends DelegateBase
public void onShouldShowRationale( Set<Perm> perms ) public void onShouldShowRationale( Set<Perm> perms )
{ {
makeOkOnlyBuilder( R.string.phone_state_rationale ) makeOkOnlyBuilder( R.string.phone_state_rationale )
.setTitle( R.string.perms_rationale_title )
.setAction( Action.RETRY_PHONE_STATE_ACTION ) .setAction( Action.RETRY_PHONE_STATE_ACTION )
.setParams( action, info ) .setParams( action, info )
.show(); .show();

View file

@ -165,6 +165,7 @@ public class DlgDelegate {
protected int m_negButton = android.R.string.cancel; protected int m_negButton = android.R.string.cancel;
protected Action m_action; protected Action m_action;
protected Object[] m_params; protected Object[] m_params;
protected int m_titleId = 0;
public DlgDelegateBuilder( String msg, Action action ) public DlgDelegateBuilder( String msg, Action action )
{ m_msgString = msg; m_action = action; } { m_msgString = msg; m_action = action; }
@ -196,11 +197,13 @@ public class DlgDelegate {
public OkOnlyBuilder(int msgId) { super( msgId, Action.SKIP_CALLBACK ); } public OkOnlyBuilder(int msgId) { super( msgId, Action.SKIP_CALLBACK ); }
public OkOnlyBuilder setAction( Action action ) public OkOnlyBuilder setAction( Action action )
{ m_action = action; return this; } { m_action = action; return this; }
public OkOnlyBuilder setTitle( int titleId )
{ m_titleId = titleId; return this; }
@Override @Override
public void show() public void show()
{ {
showOKOnlyDialogThen( m_msgString, m_action, m_params ); showOKOnlyDialogThen( m_msgString, m_action, m_params, m_titleId );
} }
} }
@ -208,11 +211,14 @@ public class DlgDelegate {
public ConfirmThenBuilder(String msg, Action action) {super(msg, action);} public ConfirmThenBuilder(String msg, Action action) {super(msg, action);}
public ConfirmThenBuilder(int msgId, Action action) {super(msgId, action);} public ConfirmThenBuilder(int msgId, Action action) {super(msgId, action);}
public ConfirmThenBuilder setTitle( int titleId )
{ m_titleId = titleId; return this; }
@Override @Override
public void show() public void show()
{ {
showConfirmThen( m_nakey, m_onNA, m_msgString, m_posButton, showConfirmThen( m_nakey, m_onNA, m_msgString, m_posButton,
m_negButton, m_action, m_params ); m_negButton, m_action, m_titleId, m_params );
} }
} }
@ -412,12 +418,13 @@ public class DlgDelegate {
} }
private void showOKOnlyDialogThen( String msg, Action action, private void showOKOnlyDialogThen( String msg, Action action,
Object[] params ) Object[] params, int titleId )
{ {
// Assert.assertNull( m_dlgStates ); // Assert.assertNull( m_dlgStates );
DlgState state = new DlgState( DlgID.DIALOG_OKONLY ) DlgState state = new DlgState( DlgID.DIALOG_OKONLY )
.setMsg( msg ) .setMsg( msg )
.setParams( params ) .setParams( params )
.setTitle( titleId )
.setAction(action); .setAction(action);
addState( state ); addState( state );
showDialog( DlgID.DIALOG_OKONLY ); showDialog( DlgID.DIALOG_OKONLY );
@ -471,8 +478,9 @@ public class DlgDelegate {
} }
} }
private void showConfirmThen( NAKey nakey, Runnable onNA, String msg, int posButton, private void showConfirmThen( NAKey nakey, Runnable onNA, String msg,
int negButton, Action action, Object[] params ) int posButton, int negButton, Action action,
int titleId, Object[] params )
{ {
if ( null != nakey ) { if ( null != nakey ) {
Assert.assertNull( onNA ); Assert.assertNull( onNA );
@ -484,6 +492,7 @@ public class DlgDelegate {
.setPosButton( posButton ) .setPosButton( posButton )
.setNegButton( negButton ) .setNegButton( negButton )
.setAction( action ) .setAction( action )
.setTitle( titleId )
.setParams( params ); .setParams( params );
addState( state ); addState( state );
showDialog( DlgID.CONFIRM_THEN ); showDialog( DlgID.CONFIRM_THEN );
@ -662,7 +671,7 @@ public class DlgDelegate {
private Dialog createOKDialog( DlgState state, DlgID dlgID ) private Dialog createOKDialog( DlgState state, DlgID dlgID )
{ {
Dialog dialog = LocUtils.makeAlertBuilder( m_activity ) Dialog dialog = LocUtils.makeAlertBuilder( m_activity )
.setTitle( R.string.info_title ) .setTitle( state.m_titleId == 0 ? R.string.info_title : state.m_titleId )
.setMessage( state.m_msg ) .setMessage( state.m_msg )
.setPositiveButton( android.R.string.ok, null ) .setPositiveButton( android.R.string.ok, null )
.create(); .create();
@ -711,7 +720,7 @@ public class DlgDelegate {
OnClickListener lstnr = mkCallbackClickListener( state, naView ); OnClickListener lstnr = mkCallbackClickListener( state, naView );
AlertDialog.Builder builder = LocUtils.makeAlertBuilder( m_activity ) AlertDialog.Builder builder = LocUtils.makeAlertBuilder( m_activity )
.setTitle( R.string.query_title ) .setTitle( state.m_titleId == 0 ? R.string.query_title : state.m_titleId )
.setView( naView ) .setView( naView )
.setPositiveButton( state.m_posButton, lstnr ) .setPositiveButton( state.m_posButton, lstnr )
.setNegativeButton( state.m_negButton, lstnr ); .setNegativeButton( state.m_negButton, lstnr );

View file

@ -37,6 +37,7 @@ public class DlgState implements Parcelable {
// These can't be serialized!!!! // These can't be serialized!!!!
public Object[] m_params; public Object[] m_params;
public Runnable m_onNAChecked; public Runnable m_onNAChecked;
public int m_titleId;
public DlgState( DlgID dlgID ) public DlgState( DlgID dlgID )
{ {
@ -59,6 +60,8 @@ public class DlgState implements Parcelable {
{ m_posButton = id; return this; } { m_posButton = id; return this; }
public DlgState setNegButton( int id ) public DlgState setNegButton( int id )
{ m_negButton = id; return this; } { m_negButton = id; return this; }
public DlgState setTitle( int id )
{ m_titleId = id; return this; }
public int describeContents() { public int describeContents() {
return 0; return 0;
@ -70,6 +73,7 @@ public class DlgState implements Parcelable {
out.writeInt( m_negButton ); out.writeInt( m_negButton );
out.writeInt( null == m_action ? -1 : m_action.ordinal() ); out.writeInt( null == m_action ? -1 : m_action.ordinal() );
out.writeInt( m_prefsKey ); out.writeInt( m_prefsKey );
out.writeInt( m_titleId );
out.writeString( m_msg ); out.writeString( m_msg );
} }
@ -82,6 +86,7 @@ public class DlgState implements Parcelable {
int tmp = in.readInt(); int tmp = in.readInt();
Action action = 0 > tmp ? null : Action.values()[tmp]; Action action = 0 > tmp ? null : Action.values()[tmp];
int prefsKey = in.readInt(); int prefsKey = in.readInt();
int titleId = in.readInt();
String msg = in.readString(); String msg = in.readString();
DlgState state = new DlgState(id) DlgState state = new DlgState(id)
.setMsg( msg ) .setMsg( msg )

View file

@ -2189,7 +2189,7 @@ public class GamesListDelegate extends ListDelegateBase
String msg = getString( R.string.phone_lookup_rationale ) String msg = getString( R.string.phone_lookup_rationale )
+ "\n\n" + getString( id ); + "\n\n" + getString( id );
makeConfirmThenBuilder( msg, Action.RETRY_REMATCH ) makeConfirmThenBuilder( msg, Action.RETRY_REMATCH )
// .setTitle( R.string.perms_rationale_title ) .setTitle( R.string.perms_rationale_title )
.setParams( gameName ) .setParams( gameName )
.show(); .show();
} }

View file

@ -338,6 +338,7 @@ public class SMSInviteDelegate extends InviteDelegate {
public void onShouldShowRationale( Set<Perm> perms ) public void onShouldShowRationale( Set<Perm> perms )
{ {
makeOkOnlyBuilder( R.string.contacts_rationale ) makeOkOnlyBuilder( R.string.contacts_rationale )
.setTitle( R.string.perms_rationale_title )
.setAction( Action.RETRY_CONTACTS_ACTION ) .setAction( Action.RETRY_CONTACTS_ACTION )
.show(); .show();
} }