mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-18 22:26:30 +01:00
add bt-in-background preference
And clear it from a button in the alert that's posted when the foreground service notification is selected.
This commit is contained in:
parent
f8e15bd3a0
commit
eb6831ea12
7 changed files with 33 additions and 3 deletions
|
@ -351,7 +351,9 @@ public class BTService extends XWService {
|
||||||
Log.d( TAG, "startService(%s)", intent );
|
Log.d( TAG, "startService(%s)", intent );
|
||||||
|
|
||||||
if ( ! sInForeground && canRunForegroundService() ) {
|
if ( ! sInForeground && canRunForegroundService() ) {
|
||||||
context.startForegroundService( intent );
|
if ( XWPrefs.getBTBackgroundEnabled( context ) ) {
|
||||||
|
context.startForegroundService( intent );
|
||||||
|
}
|
||||||
} else if ( sInForeground || Build.VERSION.SDK_INT < Build.VERSION_CODES.O ) {
|
} else if ( sInForeground || Build.VERSION.SDK_INT < Build.VERSION_CODES.O ) {
|
||||||
context.startService( intent );
|
context.startService( intent );
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,7 @@ public class DlgDelegate {
|
||||||
SET_HIDE_NEWGAME_BUTTONS,
|
SET_HIDE_NEWGAME_BUTTONS,
|
||||||
DWNLD_LOC_DICT,
|
DWNLD_LOC_DICT,
|
||||||
NEW_GAME_DFLT_NAME,
|
NEW_GAME_DFLT_NAME,
|
||||||
|
DISABLE_BT_BACK,
|
||||||
|
|
||||||
// BoardDelegate
|
// BoardDelegate
|
||||||
UNDO_LAST_ACTION,
|
UNDO_LAST_ACTION,
|
||||||
|
|
|
@ -1360,6 +1360,10 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
true );
|
true );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case DISABLE_BT_BACK:
|
||||||
|
XWPrefs.setBTBackgroundEnabled( m_activity, false );
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
handled = super.onPosButton( action, params );
|
handled = super.onPosButton( action, params );
|
||||||
}
|
}
|
||||||
|
@ -2271,9 +2275,11 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
private void tryBackgroundIntent( Intent intent )
|
private void tryBackgroundIntent( Intent intent )
|
||||||
{
|
{
|
||||||
if ( intent.getBooleanExtra( BACKGROUND_EXTRA, false ) ) {
|
if ( intent.getBooleanExtra( BACKGROUND_EXTRA, false ) ) {
|
||||||
|
ActionPair pair = new ActionPair( Action.DISABLE_BT_BACK,
|
||||||
|
R.string.disable_bt_back );
|
||||||
makeNotAgainBuilder( R.string.not_again_btservice,
|
makeNotAgainBuilder( R.string.not_again_btservice,
|
||||||
R.string.key_notagain_btservice,
|
R.string.key_notagain_btservice )
|
||||||
Action.OPEN_GAME )
|
.setActionPair( pair )
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,16 @@ public class XWPrefs {
|
||||||
setPrefsBoolean( context, R.string.key_enable_sms, enabled );
|
setPrefsBoolean( context, R.string.key_enable_sms, enabled );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setBTBackgroundEnabled( Context context, boolean enabled )
|
||||||
|
{
|
||||||
|
setPrefsBoolean( context, R.string.key_btback_enabled, enabled );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean getBTBackgroundEnabled( Context context )
|
||||||
|
{
|
||||||
|
return getPrefsBoolean( context, R.string.key_btback_enabled, true );
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean getDebugEnabled( Context context )
|
public static boolean getDebugEnabled( Context context )
|
||||||
{
|
{
|
||||||
return getPrefsBoolean( context, R.string.key_enable_debug, false );
|
return getPrefsBoolean( context, R.string.key_enable_debug, false );
|
||||||
|
|
|
@ -61,6 +61,7 @@
|
||||||
<string name="key_notify_sound">key_notify_sound</string>
|
<string name="key_notify_sound">key_notify_sound</string>
|
||||||
<string name="key_disable_relay">key_disable_relay</string>
|
<string name="key_disable_relay">key_disable_relay</string>
|
||||||
<string name="key_notify_vibrate">key_notify_vibrate</string>
|
<string name="key_notify_vibrate">key_notify_vibrate</string>
|
||||||
|
<string name="key_btback_enabled">key_btback_enabled</string>
|
||||||
<string name="key_enable_sms">key_enable_sms</string>
|
<string name="key_enable_sms">key_enable_sms</string>
|
||||||
<string name="key_enable_p2p">key_enable_p2p</string>
|
<string name="key_enable_p2p">key_enable_p2p</string>
|
||||||
<string name="key_network_behavior">key_network_behavior</string>
|
<string name="key_network_behavior">key_network_behavior</string>
|
||||||
|
|
|
@ -2026,6 +2026,9 @@
|
||||||
<string name="title_enable_p2p">Enable WiFi Direct</string>
|
<string name="title_enable_p2p">Enable WiFi Direct</string>
|
||||||
<string name="summary_enable_p2p">Experimental, uses lots of battery</string>
|
<string name="summary_enable_p2p">Experimental, uses lots of battery</string>
|
||||||
|
|
||||||
|
<string name="title_btback_enabled">Enable background Bluetooth</string>
|
||||||
|
<string name="summary_btback_enabled">Always listen for Bluetooth messages</string>
|
||||||
|
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<string name="confirm_sms_title">Confirm your SMS plan</string>
|
<string name="confirm_sms_title">Confirm your SMS plan</string>
|
||||||
<!-- -->
|
<!-- -->
|
||||||
|
@ -2649,6 +2652,8 @@
|
||||||
Bluetooth moves and invitations while in the foreground, but any
|
Bluetooth moves and invitations while in the foreground, but any
|
||||||
sent while it\'s in the background will be lost.</string>
|
sent while it\'s in the background will be lost.</string>
|
||||||
|
|
||||||
|
<string name="disable_bt_back">Disable Background</string>
|
||||||
|
|
||||||
<string name="no_invites">This game has sent no invitations</string>
|
<string name="no_invites">This game has sent no invitations</string>
|
||||||
|
|
||||||
<string name="disable_dualpane">Disable side-by-side</string>
|
<string name="disable_dualpane">Disable side-by-side</string>
|
||||||
|
|
|
@ -335,6 +335,11 @@
|
||||||
android:summary="@string/notify_other_summary"
|
android:summary="@string/notify_other_summary"
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
/>
|
/>
|
||||||
|
<CheckBoxPreference android:key="@string/key_btback_enabled"
|
||||||
|
android:title="@string/title_btback_enabled"
|
||||||
|
android:summary="@string/summary_btback_enabled"
|
||||||
|
android:defaultValue="true"
|
||||||
|
/>
|
||||||
<CheckBoxPreference android:key="@string/key_enable_p2p"
|
<CheckBoxPreference android:key="@string/key_enable_p2p"
|
||||||
android:title="@string/title_enable_p2p"
|
android:title="@string/title_enable_p2p"
|
||||||
android:summary="@string/summary_enable_p2p"
|
android:summary="@string/summary_enable_p2p"
|
||||||
|
|
Loading…
Reference in a new issue