remove relay-check-interval option and fix relay disable

This commit is contained in:
Eric House 2020-06-09 17:31:44 -07:00
parent 1560bf01ed
commit 63835105e4
6 changed files with 33 additions and 78 deletions

View file

@ -23,37 +23,45 @@ package org.eehouse.android.xw4;
import android.content.Context; import android.content.Context;
import android.util.AttributeSet; import android.util.AttributeSet;
import java.lang.ref.WeakReference;
import org.eehouse.android.xw4.DlgDelegate.Action; import org.eehouse.android.xw4.DlgDelegate.Action;
import org.eehouse.android.xw4.loc.LocUtils; import org.eehouse.android.xw4.loc.LocUtils;
public class RelayCheckBoxPreference extends ConfirmingCheckBoxPreference { public class RelayCheckBoxPreference extends ConfirmingCheckBoxPreference {
private static ConfirmingCheckBoxPreference s_this = null; private static final String TAG = RelayCheckBoxPreference.class.getSimpleName();
private static WeakReference<RelayCheckBoxPreference> s_this = null;
public RelayCheckBoxPreference( Context context, AttributeSet attrs ) public RelayCheckBoxPreference( Context context, AttributeSet attrs )
{ {
super( context, attrs ); super( context, attrs );
s_this = this; s_this = new WeakReference<>( this );
} }
@Override @Override
protected void checkIfConfirmed() { protected void checkIfConfirmed()
{
PrefsActivity activity = (PrefsActivity)getContext(); PrefsActivity activity = (PrefsActivity)getContext();
String msg = LocUtils.getString( activity,
R.string.warn_relay_havegames );
int count = DBUtils.getRelayGameCount( activity ); int count = DBUtils.getRelayGameCount( activity );
if ( 0 < count ) { if ( 0 < count ) {
String msg = LocUtils.getString( activity,
R.string.warn_relay_havegames );
msg += LocUtils.getQuantityString( activity, R.plurals.warn_relay_games_fmt, msg += LocUtils.getQuantityString( activity, R.plurals.warn_relay_games_fmt,
count, count ); count, count );
activity.makeConfirmThenBuilder( msg, Action.DISABLE_RELAY_DO )
.setPosButton( R.string.button_disable_relay )
.show();
} }
activity.makeConfirmThenBuilder( msg, Action.DISABLE_RELAY_DO )
.setPosButton( R.string.button_disable_relay )
.show();
} }
protected static void setChecked() protected static void setChecked()
{ {
if ( null != s_this ) { if ( null != s_this ) {
s_this.super_setChecked( true ); RelayCheckBoxPreference self = s_this.get();
if ( null != self ) {
self.super_setChecked( true );
}
} }
} }
} }

View file

@ -1,6 +1,6 @@
/* -*- compile-command: "find-and-gradle.sh inXw4dDeb"; -*- */ /* -*- compile-command: "find-and-gradle.sh inXw4dDeb"; -*- */
/* /*
* Copyright 2010 by Eric House (xwords@eehouse.org). All rights * Copyright 2010 - 2020 by Eric House (xwords@eehouse.org). All rights
* reserved. * reserved.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -39,7 +39,7 @@ public class RelayTimerReceiver extends BroadcastReceiver {
public static void setTimer( Context context ) public static void setTimer( Context context )
{ {
setTimer( context, 1000 * XWPrefs.getProxyIntervalSeconds( context ) ); setTimer( context, 1000 * 1800 ); // to be changed shortly
} }
public static void setTimer( Context context, long interval_millis ) public static void setTimer( Context context, long interval_millis )

View file

@ -188,18 +188,6 @@ public class XWPrefs {
return result; return result;
} }
public static long getProxyIntervalSeconds( Context context )
{
String value = getPrefsString( context, R.string.key_connect_frequency );
long result;
try {
result = Long.parseLong( value );
} catch ( Exception ex ) {
result = -1;
}
return result;
}
public static int getPrefsInt( Context context, int keyID, int defaultValue ) public static int getPrefsInt( Context context, int keyID, int defaultValue )
{ {
String key = context.getString( keyID ); String key = context.getString( keyID );

View file

@ -63,7 +63,6 @@
<string name="key_default_phonies">key_default_phonies2</string> <string name="key_default_phonies">key_default_phonies2</string>
<string name="key_relay_poll">key_relay_poll</string> <string name="key_relay_poll">key_relay_poll</string>
<string name="key_default_timerenabled">key_default_timerenabled</string> <string name="key_default_timerenabled">key_default_timerenabled</string>
<string name="key_connect_frequency">key_connect_frequency</string>
<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>
@ -193,17 +192,6 @@
<item>@string/robot_smart</item> <item>@string/robot_smart</item>
</string-array> </string-array>
<string-array name="connect_frequencies">
<item>@string/connect_never</item>
<!-- <item>@string/connect_thirty_seconds</item> -->
<item>@string/connect_five_mins</item>
<item>@string/connect_fifteen_mins</item>
<item>@string/connect_thirty_mins</item>
<item>@string/connect_one_hour</item>
<item>@string/connect_six_hours</item>
<item>@string/connect_daily</item>
</string-array>
<!-- Keep in sync with DictUtils.DictLoc enum --> <!-- Keep in sync with DictUtils.DictLoc enum -->
<string-array name="loc_names"> <string-array name="loc_names">
<item></item> <item></item>
@ -213,17 +201,6 @@
<item>@string/loc_downloads</item> <item>@string/loc_downloads</item>
</string-array> </string-array>
<string-array name="connect_frequencies_values">
<item>-1</item>
<!-- <item>60</item> -->
<item>300</item>
<item>900</item>
<item>1800</item>
<item>3600</item>
<item>21600</item>
<item>86400</item>
</string-array>
<!-- These two arrays need to be kept in sync --> <!-- These two arrays need to be kept in sync -->
<string-array name="language_names"> <string-array name="language_names">
<item>@string/lang_unknown</item> <!-- Unknown --> <item>@string/lang_unknown</item> <!-- Unknown -->

View file

@ -976,16 +976,6 @@
CrossWords wakes up periodically to check if there are any CrossWords wakes up periodically to check if there are any
new moves available and fetches them. This controls how new moves available and fetches them. This controls how
frequently that check is done. --> frequently that check is done. -->
<string name="connect_frequency">Background move check</string>
<!-- These are the possible values for the connect_frequency
setting presented as a drop-down list. -->
<string name="connect_never">Never check</string>
<string name="connect_five_mins">Every 5 minutes</string>
<string name="connect_fifteen_mins">Every 15 minutes</string>
<string name="connect_thirty_mins">Every 30 minutes</string>
<string name="connect_one_hour">Every hour</string>
<string name="connect_six_hours">Every six hours</string>
<string name="connect_daily">Once every day</string>
<!-- When one or more new moves is found, should I play a <!-- When one or more new moves is found, should I play a
notification sound --> notification sound -->
<string name="notify_sound">Play sound</string> <string name="notify_sound">Play sound</string>
@ -1839,10 +1829,14 @@
<string name="warn_relay_remove">You can enable relay play now, or <string name="warn_relay_remove">You can enable relay play now, or
remove it from this game.</string> remove it from this game.</string>
<string name="warn_relay_havegames">Are you sure you want to <string name="warn_relay_havegames">Are you sure you want to
disable play using the relay?</string> disable play using the relay (internet)?
\n\n
Most networked games exchange moves via the relay, so only do this
if you plan to play ALL games against a robot on this same
device.</string>
<plurals name="warn_relay_games_fmt"> <plurals name="warn_relay_games_fmt">
<item quantity="one">\n\n(You have one game using it.)</item> <item quantity="one">\n\n(You have one active game using the relay now.)</item>
<item quantity="other">\n\n(You have %1$d games using it.)</item> <item quantity="other">\n\n(You have %1$d active games using the relay now.)</item>
</plurals> </plurals>
<string name="button_enable_sms">Enable Data SMS</string> <string name="button_enable_sms">Enable Data SMS</string>
<string name="button_enable_bt">Enable Bluetooth</string> <string name="button_enable_bt">Enable Bluetooth</string>

View file

@ -318,25 +318,6 @@
android:defaultValue="false" android:defaultValue="false"
/> />
<PreferenceScreen android:title="@string/relay_behavior"
android:summary="@string/relay_behavior_summary"
>
<org.eehouse.android.xw4.PollListPreference
android:key="@string/key_connect_frequency"
android:title="@string/connect_frequency"
android:entries="@array/connect_frequencies"
android:entryValues="@array/connect_frequencies_values"
android:defaultValue="900"
/>
<org.eehouse.android.xw4.RelayCheckBoxPreference
android:key="@string/key_disable_relay"
android:title="@string/disable_relay"
android:summary="@string/disable_relay_summary"
android:defaultValue="false"
/>
</PreferenceScreen>
<CheckBoxPreference android:key="@string/key_notify_vibrate" <CheckBoxPreference android:key="@string/key_notify_vibrate"
android:title="@string/notify_vibrate" android:title="@string/notify_vibrate"
android:summary="@string/notify_other_summary" android:summary="@string/notify_other_summary"
@ -368,6 +349,13 @@
/> />
</PreferenceScreen> </PreferenceScreen>
<org.eehouse.android.xw4.RelayCheckBoxPreference
android:key="@string/key_disable_relay"
android:title="@string/disable_relay"
android:summary="@string/disable_relay_summary"
android:defaultValue="false"
/>
</PreferenceScreen> </PreferenceScreen>
<!-- For Debugging --> <!-- For Debugging -->