mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-30 08:34:16 +01:00
add BT permissions requests
This commit is contained in:
parent
43a96fb6fc
commit
8ca83ae871
6 changed files with 35 additions and 11 deletions
|
@ -41,7 +41,7 @@ public class ConnViaViewLayout extends LinearLayout {
|
|||
private static final String TAG = ConnViaViewLayout.class.getSimpleName();
|
||||
private CommsConnTypeSet m_curSet;
|
||||
private DlgDelegate.HasDlgDelegate m_dlgDlgt;
|
||||
private Activity m_activity;
|
||||
private DelegateBase mParent;
|
||||
|
||||
public interface CheckEnabledWarner {
|
||||
public void warnDisabled( CommsConnType typ );
|
||||
|
@ -57,9 +57,7 @@ public class ConnViaViewLayout extends LinearLayout {
|
|||
super( context, as );
|
||||
}
|
||||
|
||||
public void setActivity( Activity activity ) { m_activity = activity; }
|
||||
|
||||
protected void configure( CommsConnTypeSet types,
|
||||
protected void configure( DelegateBase parent, CommsConnTypeSet types,
|
||||
CheckEnabledWarner cew,
|
||||
SetEmptyWarner sew,
|
||||
DlgDelegate.HasDlgDelegate dlgDlgt )
|
||||
|
@ -71,6 +69,7 @@ public class ConnViaViewLayout extends LinearLayout {
|
|||
m_disabledWarner = cew;
|
||||
m_emptyWarner = sew;
|
||||
m_dlgDlgt = dlgDlgt;
|
||||
mParent = parent;
|
||||
}
|
||||
|
||||
protected CommsConnTypeSet getTypes()
|
||||
|
@ -83,7 +82,7 @@ public class ConnViaViewLayout extends LinearLayout {
|
|||
LinearLayout list = (LinearLayout)findViewById( R.id.conn_types );
|
||||
list.removeAllViews(); // in case being reused
|
||||
|
||||
Context context = getContext();
|
||||
final Context context = getContext();
|
||||
List<CommsConnType> supported = CommsConnTypeSet.getSupported( context );
|
||||
|
||||
for ( CommsConnType typ : supported ) {
|
||||
|
@ -101,9 +100,13 @@ public class ConnViaViewLayout extends LinearLayout {
|
|||
public void onCheckedChanged( CompoundButton buttonView,
|
||||
boolean isChecked ) {
|
||||
if ( isChecked ) {
|
||||
showNotAgainTypeTip( typf );
|
||||
enabledElseWarn( typf );
|
||||
m_curSet.add( typf );
|
||||
if ( disableUntil( context, typ ) ) {
|
||||
buttonView.setChecked( false );
|
||||
} else {
|
||||
showNotAgainTypeTip( typf );
|
||||
enabledElseWarn( typf );
|
||||
m_curSet.add( typf );
|
||||
}
|
||||
} else {
|
||||
m_curSet.remove( typf );
|
||||
if ( null != m_emptyWarner && 0 == m_curSet.size()) {
|
||||
|
@ -115,6 +118,21 @@ public class ConnViaViewLayout extends LinearLayout {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean disableUntil( Context context, CommsConnType typ )
|
||||
{
|
||||
boolean disable = false;
|
||||
if ( typ == CommsConnType.COMMS_CONN_BT
|
||||
&& ! BTUtils.havePermissions( context ) ) {
|
||||
if ( null != mParent ) {
|
||||
Perms23.tryGetPerms( mParent, BTUtils.BTPerms,
|
||||
R.string.nearbydev_rationale,
|
||||
Action.SKIP_CALLBACK );
|
||||
}
|
||||
disable = true;
|
||||
}
|
||||
return disable;
|
||||
}
|
||||
|
||||
private void enabledElseWarn( CommsConnType typ )
|
||||
{
|
||||
boolean enabled = true;
|
||||
|
|
|
@ -258,9 +258,8 @@ public class GameConfigDelegate extends DelegateBase
|
|||
LinearLayout layout = (LinearLayout)inflate( R.layout.conn_types_display );
|
||||
final ConnViaViewLayout items = (ConnViaViewLayout)
|
||||
layout.findViewById( R.id.conn_types );
|
||||
items.setActivity( m_activity );
|
||||
|
||||
items.configure( conTypes,
|
||||
items.configure( this, conTypes,
|
||||
new ConnViaViewLayout.CheckEnabledWarner() {
|
||||
public void warnDisabled( CommsConnType typ ) {
|
||||
switch( typ ) {
|
||||
|
|
|
@ -320,6 +320,8 @@ public class XWActivity extends FragmentActivity
|
|||
return m_dlgt.makeDialog( alert, params );
|
||||
}
|
||||
|
||||
protected DelegateBase getDelegate() { return m_dlgt; }
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// DlgClickNotify interface
|
||||
////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -68,7 +68,7 @@ public class XWConnAddrPreference extends DialogPreference
|
|||
View view = LocUtils.inflate( activity, R.layout.conn_types_display );
|
||||
|
||||
final ConnViaViewLayout cvl = (ConnViaViewLayout)view.findViewById( R.id.conn_types );
|
||||
cvl.configure( XWPrefs.getAddrTypes( activity ),
|
||||
cvl.configure( activity.getDelegate(), XWPrefs.getAddrTypes( activity ),
|
||||
new ConnViaViewLayout.CheckEnabledWarner() {
|
||||
@Override
|
||||
public void warnDisabled( CommsConnType typ ) {
|
||||
|
|
|
@ -462,6 +462,9 @@ public class XWPrefs {
|
|||
if ( 0 == result.size() ) {
|
||||
result.add( CommsConnType.COMMS_CONN_MQTT );
|
||||
}
|
||||
if ( !BTUtils.havePermissions( context ) ) {
|
||||
result.remove( CommsConnType.COMMS_CONN_BT );
|
||||
}
|
||||
if ( originalHash != result.hashCode() ) {
|
||||
setAddrTypes( context, result );
|
||||
}
|
||||
|
|
|
@ -2395,6 +2395,8 @@
|
|||
permission, but only the phone number of the sender will be
|
||||
displayed.
|
||||
</string>
|
||||
<string name="nearbydev_rationale">CrossWords needs permission to
|
||||
discover nearby devices in order to use Bluetooth.</string>
|
||||
<string name="move_dict_rationale">Storing a wordlist in the
|
||||
Downloads area requires Storage permission.</string>
|
||||
<string name="remove_sms">Remove SMS</string>
|
||||
|
|
Loading…
Add table
Reference in a new issue