mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-22 07:28:16 +01:00
add not-again checkbox to ask-phone-permission dialog
Otherwise if you're saying "no" you keep getting asked each time you invite.
This commit is contained in:
parent
e4bc2d99ed
commit
6417236505
6 changed files with 63 additions and 19 deletions
|
@ -755,9 +755,10 @@ public class BoardDelegate extends DelegateBase
|
|||
// straight to asking for the permission.
|
||||
private void callInviteChoices( final SentInvitesInfo info )
|
||||
{
|
||||
Perms23.tryGetPerms( this, Perm.READ_PHONE_STATE,
|
||||
R.string.phone_state_rationale,
|
||||
Action.ASKED_PHONE_STATE, info );
|
||||
Perms23.tryGetPermsNA( this, Perm.READ_PHONE_STATE,
|
||||
R.string.phone_state_rationale,
|
||||
R.string.key_na_perms_phonestate,
|
||||
Action.ASKED_PHONE_STATE, info );
|
||||
}
|
||||
|
||||
private void showInviteChoicesThen( Object[] params )
|
||||
|
@ -1260,7 +1261,8 @@ public class BoardDelegate extends DelegateBase
|
|||
break;
|
||||
|
||||
default:
|
||||
handled = false;
|
||||
handled = super.onDismissed( action, params );
|
||||
break;
|
||||
}
|
||||
return handled;
|
||||
}
|
||||
|
|
|
@ -792,9 +792,20 @@ public class DelegateBase implements DlgClickNotify,
|
|||
|
||||
public boolean onDismissed( Action action, Object[] params )
|
||||
{
|
||||
Log.d( TAG, "%s.dlgDismissed(%s)", getClass().getSimpleName(),
|
||||
boolean handled = false;
|
||||
Log.d( TAG, "%s.onDismissed(%s)", getClass().getSimpleName(),
|
||||
action.toString() );
|
||||
return false;
|
||||
|
||||
switch( action ) {
|
||||
case PERMS_QUERY:
|
||||
handled = true;
|
||||
Perms23.onGotPermsAction( this, false, params );
|
||||
break;
|
||||
default:
|
||||
Log.e( TAG, "onDismissed(): not handling action %s", action );
|
||||
}
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
||||
public void inviteChoiceMade( Action action, DlgClickNotify.InviteMeans means, Object... params )
|
||||
|
|
|
@ -783,9 +783,10 @@ public class GameConfigDelegate extends DelegateBase
|
|||
private void showConnAfterCheck()
|
||||
{
|
||||
if ( null == SMSPhoneInfo.get( m_activity ) ) {
|
||||
Perms23.tryGetPerms( this, Perms23.Perm.READ_PHONE_STATE,
|
||||
R.string.phone_state_rationale,
|
||||
Action.ASKED_PHONE_STATE );
|
||||
Perms23.tryGetPermsNA( this, Perms23.Perm.READ_PHONE_STATE,
|
||||
R.string.phone_state_rationale,
|
||||
R.string.key_na_perms_phonestate,
|
||||
Action.ASKED_PHONE_STATE );
|
||||
} else {
|
||||
showDialogFragment( DlgID.CHANGE_CONN, m_conTypes );
|
||||
}
|
||||
|
|
|
@ -203,23 +203,26 @@ public class Perms23 {
|
|||
private static class QueryInfo {
|
||||
private Action m_action;
|
||||
private Perm[] m_perms;
|
||||
private int mNAKey;
|
||||
private DelegateBase m_delegate;
|
||||
private String m_rationaleMsg;
|
||||
private Object[] m_params;
|
||||
|
||||
private QueryInfo( DelegateBase delegate, Action action,
|
||||
Perm[] perms, String msg, Object[] params ) {
|
||||
Perm[] perms, String msg, int naKey,
|
||||
Object[] params ) {
|
||||
m_delegate = delegate;
|
||||
m_action = action;
|
||||
m_perms = perms;
|
||||
m_rationaleMsg = msg;
|
||||
mNAKey = naKey;
|
||||
m_params = params;
|
||||
}
|
||||
|
||||
private QueryInfo( DelegateBase delegate, Object[] params )
|
||||
{
|
||||
this( delegate, (Action)params[0], (Perm[])params[1], (String)params[2],
|
||||
(Object[])params[3] );
|
||||
0, (Object[])params[3] );
|
||||
}
|
||||
|
||||
private Object[] getParams()
|
||||
|
@ -260,6 +263,7 @@ public class Perms23 {
|
|||
.setPosButton( R.string.button_ask_again )
|
||||
.setNegButton( R.string.button_skip )
|
||||
.setParams( QueryInfo.this.getParams() )
|
||||
.setNAKey( mNAKey )
|
||||
.show();
|
||||
}
|
||||
} );
|
||||
|
@ -319,30 +323,36 @@ public class Perms23 {
|
|||
* Request permissions, giving rationale once, then call with action and
|
||||
* either positive or negative, the former if permission granted.
|
||||
*/
|
||||
private static void tryGetPermsImpl( DelegateBase delegate, Perm[] perms,
|
||||
String rationaleMsg, int naKey,
|
||||
final Action action, Object... params )
|
||||
{
|
||||
// Log.d( TAG, "tryGetPerms(%s)", perm.toString() );
|
||||
new QueryInfo( delegate, action, perms, rationaleMsg, naKey, params )
|
||||
.doIt( true );
|
||||
}
|
||||
|
||||
public static void tryGetPerms( DelegateBase delegate, Perm[] perms, int rationaleId,
|
||||
final Action action, Object... params )
|
||||
{
|
||||
// Log.d( TAG, "tryGetPerms(%s)", perm.toString() );
|
||||
Context context = XWApp.getContext();
|
||||
String msg = rationaleId == 0
|
||||
? null : LocUtils.getString( context, rationaleId );
|
||||
tryGetPerms( delegate, perms, msg, action, params );
|
||||
String msg = LocUtils.getStringOrNull( rationaleId );
|
||||
tryGetPermsImpl( delegate, perms, msg, 0, action, params );
|
||||
}
|
||||
|
||||
public static void tryGetPerms( DelegateBase delegate, Perm[] perms,
|
||||
String rationaleMsg, final Action action,
|
||||
Object... params )
|
||||
{
|
||||
// Log.d( TAG, "tryGetPerms(%s)", perm.toString() );
|
||||
new QueryInfo( delegate, action, perms, rationaleMsg, params )
|
||||
.doIt( true );
|
||||
tryGetPermsImpl( delegate, perms, rationaleMsg, 0, action, params );
|
||||
}
|
||||
|
||||
public static void tryGetPerms( DelegateBase delegate, Perm perm,
|
||||
String rationaleMsg, final Action action,
|
||||
Object... params )
|
||||
{
|
||||
tryGetPerms( delegate, new Perm[]{ perm }, rationaleMsg, action, params );
|
||||
tryGetPermsImpl( delegate, new Perm[]{ perm }, rationaleMsg, 0,
|
||||
action, params );
|
||||
}
|
||||
|
||||
public static void tryGetPerms( DelegateBase delegate, Perm perm, int rationaleId,
|
||||
|
@ -351,6 +361,15 @@ public class Perms23 {
|
|||
tryGetPerms( delegate, new Perm[]{perm}, rationaleId, action, params );
|
||||
}
|
||||
|
||||
public static void tryGetPermsNA( DelegateBase delegate, Perm perm,
|
||||
int rationaleId, int naKey,
|
||||
Action action, Object... params )
|
||||
{
|
||||
tryGetPermsImpl( delegate, new Perm[] {perm},
|
||||
LocUtils.getStringOrNull( rationaleId ), naKey,
|
||||
action, params );
|
||||
}
|
||||
|
||||
public static void onGotPermsAction( DelegateBase delegate, boolean positive,
|
||||
Object[] params )
|
||||
{
|
||||
|
|
|
@ -265,6 +265,16 @@ public class LocUtils {
|
|||
return getString( context, true, id );
|
||||
}
|
||||
|
||||
public static String getStringOrNull( int id )
|
||||
{
|
||||
String result = null;
|
||||
if ( 0 != id ) {
|
||||
Context context = XWApp.getContext();
|
||||
result = getString( context, true, id );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String getString( Context context, boolean canUseDB, int id )
|
||||
{
|
||||
String result = null;
|
||||
|
|
|
@ -145,6 +145,7 @@
|
|||
<string name="key_na_bt_badproto">key_na_bt_badproto</string>
|
||||
<string name="key_na_sms_banned">key_na_sms_banned</string>
|
||||
<string name="key_na_longtap_lookup">key_na_longtap_lookup</string>
|
||||
<string name="key_na_perms_phonestate">key_na_perms_phonestate</string>
|
||||
|
||||
<!-- Nor is my email address -->
|
||||
<string name="email_author_email">xwords@eehouse.org</string>
|
||||
|
|
Loading…
Reference in a new issue