mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-05 20:45:49 +01:00
toward use of data text messages for games: don't let CDMA phone users
turn data messages on, and when checking if SMS is supported say yes for KitKat users if they've successfully turned data on.
This commit is contained in:
parent
f386cd5c1b
commit
33a83b0e2f
5 changed files with 102 additions and 69 deletions
|
@ -854,6 +854,7 @@ public final class R {
|
|||
/**
|
||||
*/
|
||||
public static final int cur_tiles_fmt=0x7f0601fc;
|
||||
public static final int data_gsm_only=0x7f0602ae;
|
||||
public static final int debug_features=0x7f06007c;
|
||||
public static final int debug_features_summary=0x7f06007d;
|
||||
/** dictionary used by default for human players when creating
|
||||
|
|
|
@ -2235,5 +2235,7 @@
|
|||
|
||||
<string name="xlations_enabled_title">Enable local translating</string>
|
||||
<string name="xlations_enabled_summary">Add option to every screen menu</string>
|
||||
|
||||
<string name="data_gsm_only">SMS Data is only available on GSM phones.</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -347,7 +347,7 @@
|
|||
<CheckBoxPreference android:key="@string/key_send_data_sms"
|
||||
android:title="@string/title_send_data_sms"
|
||||
android:summary="@string/summary_send_data_sms"
|
||||
android:defaultValue="true"
|
||||
android:defaultValue="false"
|
||||
/>
|
||||
<org.eehouse.android.xw4.XWEditTextPreference
|
||||
android:key="@string/key_relay_host"
|
||||
|
|
|
@ -42,6 +42,7 @@ public class PrefsDelegate extends DelegateBase
|
|||
private String m_keyLogging;
|
||||
private String m_smsToasting;
|
||||
private String m_smsEnable;
|
||||
private String m_smsData;
|
||||
private String m_downloadPath;
|
||||
private String m_thumbSize;
|
||||
private String m_hideTitle;
|
||||
|
@ -55,71 +56,73 @@ public class PrefsDelegate extends DelegateBase
|
|||
|
||||
protected Dialog onCreateDialog( int id )
|
||||
{
|
||||
Dialog dialog = null;
|
||||
DialogInterface.OnClickListener lstnr = null;
|
||||
int confirmID = 0;
|
||||
Dialog dialog = super.onCreateDialog( id );
|
||||
if ( null == dialog ) {
|
||||
DialogInterface.OnClickListener lstnr = null;
|
||||
int confirmID = 0;
|
||||
|
||||
switch( DlgID.values()[id] ) {
|
||||
case REVERT_COLORS:
|
||||
confirmID = R.string.confirm_revert_colors;
|
||||
lstnr = new DialogInterface.OnClickListener() {
|
||||
public void onClick( DialogInterface dlg, int item ) {
|
||||
SharedPreferences sp = getSharedPreferences();
|
||||
SharedPreferences.Editor editor = sp.edit();
|
||||
int[] colorKeys = {
|
||||
R.string.key_player0,
|
||||
R.string.key_player1,
|
||||
R.string.key_player2,
|
||||
R.string.key_player3,
|
||||
R.string.key_bonus_l2x,
|
||||
R.string.key_bonus_l3x,
|
||||
R.string.key_bonus_w2x,
|
||||
R.string.key_bonus_w3x,
|
||||
R.string.key_tile_back,
|
||||
R.string.key_clr_crosshairs,
|
||||
R.string.key_empty,
|
||||
R.string.key_background,
|
||||
R.string.key_clr_bonushint,
|
||||
};
|
||||
for ( int colorKey : colorKeys ) {
|
||||
editor.remove( getString(colorKey) );
|
||||
switch( DlgID.values()[id] ) {
|
||||
case REVERT_COLORS:
|
||||
confirmID = R.string.confirm_revert_colors;
|
||||
lstnr = new DialogInterface.OnClickListener() {
|
||||
public void onClick( DialogInterface dlg, int item ) {
|
||||
SharedPreferences sp = getSharedPreferences();
|
||||
SharedPreferences.Editor editor = sp.edit();
|
||||
int[] colorKeys = {
|
||||
R.string.key_player0,
|
||||
R.string.key_player1,
|
||||
R.string.key_player2,
|
||||
R.string.key_player3,
|
||||
R.string.key_bonus_l2x,
|
||||
R.string.key_bonus_l3x,
|
||||
R.string.key_bonus_w2x,
|
||||
R.string.key_bonus_w3x,
|
||||
R.string.key_tile_back,
|
||||
R.string.key_clr_crosshairs,
|
||||
R.string.key_empty,
|
||||
R.string.key_background,
|
||||
R.string.key_clr_bonushint,
|
||||
};
|
||||
for ( int colorKey : colorKeys ) {
|
||||
editor.remove( getString(colorKey) );
|
||||
}
|
||||
editor.commit();
|
||||
relaunch();
|
||||
}
|
||||
editor.commit();
|
||||
relaunch();
|
||||
}
|
||||
};
|
||||
break;
|
||||
case REVERT_ALL:
|
||||
confirmID = R.string.confirm_revert_all;
|
||||
lstnr = new DialogInterface.OnClickListener() {
|
||||
public void onClick( DialogInterface dlg, int item ) {
|
||||
SharedPreferences sp = getSharedPreferences();
|
||||
SharedPreferences.Editor editor = sp.edit();
|
||||
editor.clear();
|
||||
editor.commit();
|
||||
relaunch();
|
||||
}
|
||||
};
|
||||
break;
|
||||
case CONFIRM_SMS:
|
||||
dialog = SMSCheckBoxPreference.onCreateDialog( m_activity, id );
|
||||
break;
|
||||
case EXPLAIN_TITLE:
|
||||
dialog = LocUtils.makeAlertBuilder( m_activity )
|
||||
.setMessage( R.string.no_hide_titlebar )
|
||||
.setTitle( R.string.info_title )
|
||||
.setPositiveButton( R.string.button_ok, null )
|
||||
.create();
|
||||
break;
|
||||
}
|
||||
};
|
||||
break;
|
||||
case REVERT_ALL:
|
||||
confirmID = R.string.confirm_revert_all;
|
||||
lstnr = new DialogInterface.OnClickListener() {
|
||||
public void onClick( DialogInterface dlg, int item ) {
|
||||
SharedPreferences sp = getSharedPreferences();
|
||||
SharedPreferences.Editor editor = sp.edit();
|
||||
editor.clear();
|
||||
editor.commit();
|
||||
relaunch();
|
||||
}
|
||||
};
|
||||
break;
|
||||
case CONFIRM_SMS:
|
||||
dialog = SMSCheckBoxPreference.onCreateDialog( m_activity, id );
|
||||
break;
|
||||
case EXPLAIN_TITLE:
|
||||
dialog = LocUtils.makeAlertBuilder( m_activity )
|
||||
.setMessage( R.string.no_hide_titlebar )
|
||||
.setTitle( R.string.info_title )
|
||||
.setPositiveButton( R.string.button_ok, null )
|
||||
.create();
|
||||
break;
|
||||
}
|
||||
|
||||
if ( null == dialog && null != lstnr ) {
|
||||
dialog = LocUtils.makeAlertBuilder( m_activity )
|
||||
.setTitle( R.string.query_title )
|
||||
.setMessage( confirmID )
|
||||
.setPositiveButton( R.string.button_ok, lstnr )
|
||||
.setNegativeButton( R.string.button_cancel, null )
|
||||
.create();
|
||||
if ( null == dialog && null != lstnr ) {
|
||||
dialog = LocUtils.makeAlertBuilder( m_activity )
|
||||
.setTitle( R.string.query_title )
|
||||
.setMessage( confirmID )
|
||||
.setPositiveButton( R.string.button_ok, lstnr )
|
||||
.setNegativeButton( R.string.button_cancel, null )
|
||||
.create();
|
||||
}
|
||||
}
|
||||
return dialog;
|
||||
}
|
||||
|
@ -133,6 +136,7 @@ public class PrefsDelegate extends DelegateBase
|
|||
m_keyLogging = getString( R.string.key_logging_on );
|
||||
m_smsToasting = getString( R.string.key_show_sms );
|
||||
m_smsEnable = getString( R.string.key_enable_sms );
|
||||
m_smsData = getString( R.string.key_send_data_sms );
|
||||
m_downloadPath = getString( R.string.key_download_path );
|
||||
m_thumbSize = getString( R.string.key_thumbsize );
|
||||
m_hideTitle = getString( R.string.key_hide_title );
|
||||
|
@ -165,6 +169,7 @@ public class PrefsDelegate extends DelegateBase
|
|||
@Override
|
||||
public void onSharedPreferenceChanged( SharedPreferences sp, String key )
|
||||
{
|
||||
// DbgUtils.logf( "onSharedPreferenceChanged(key=%s)", key );
|
||||
if ( key.equals( m_keyLogging ) ) {
|
||||
DbgUtils.logEnable( sp.getBoolean( key, false ) );
|
||||
} else if ( key.equals( m_smsToasting ) ) {
|
||||
|
@ -176,6 +181,13 @@ public class PrefsDelegate extends DelegateBase
|
|||
SMSService.stopService( m_activity );
|
||||
XWPrefs.setHaveCheckedSMS( m_activity, false );
|
||||
}
|
||||
} else if ( key.equals( m_smsData ) ) {
|
||||
boolean turningOn = sp.getBoolean( key, true );
|
||||
if ( turningOn && !Utils.isGSMPhone( m_activity ) ) {
|
||||
showOKOnlyDialog( R.string.data_gsm_only );
|
||||
((CheckBoxPreference)(m_activity.findPreference( key )))
|
||||
.setChecked( false );
|
||||
}
|
||||
} else if ( key.equals( m_downloadPath ) ) {
|
||||
String value = sp.getString( key, null );
|
||||
if ( null != value ) {
|
||||
|
|
|
@ -97,21 +97,39 @@ public class Utils {
|
|||
return s_isFirstBootThisVersion;
|
||||
}
|
||||
|
||||
// Does the device have ability to send SMS -- e.g. is it a phone
|
||||
// and not a Kindle Fire. Not related to XWApp.SMSSUPPORTED
|
||||
public static boolean isGSMPhone( Context context )
|
||||
{
|
||||
boolean result = false;
|
||||
TelephonyManager tm = (TelephonyManager)
|
||||
context.getSystemService( Context.TELEPHONY_SERVICE );
|
||||
if ( null != tm ) {
|
||||
result = TelephonyManager.PHONE_TYPE_GSM == tm.getPhoneType();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Does the device have ability to send SMS -- e.g. is it a phone and not
|
||||
// a Kindle Fire. Not related to XWApp.SMSSUPPORTED. Note that as a
|
||||
// temporary workaround for KitKat having broken use of non-data messages,
|
||||
// we only support SMS on kitkat if data messages have been turned on (and
|
||||
// that's not allowed except on GSM phones.)
|
||||
public static boolean deviceSupportsSMS( Context context )
|
||||
{
|
||||
if ( null == s_deviceSupportSMS ) {
|
||||
boolean doesSMS = false;
|
||||
// TEMPORARY: disable SMS on KITKAT UNLESS use-text turned on
|
||||
if ( 19 > Integer.valueOf( android.os.Build.VERSION.SDK )
|
||||
|| XWPrefs.getPrefsBoolean( context, R.string.key_send_data_sms,
|
||||
false ) ) {
|
||||
boolean preKitkat = 19 > Integer.valueOf( android.os.Build.VERSION.SDK);
|
||||
boolean usingData =
|
||||
XWPrefs.getPrefsBoolean( context, R.string.key_send_data_sms,
|
||||
false );
|
||||
if ( preKitkat || usingData ) {
|
||||
TelephonyManager tm = (TelephonyManager)
|
||||
context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
if ( null != tm ) {
|
||||
int type = tm.getPhoneType();
|
||||
doesSMS = TelephonyManager.PHONE_TYPE_NONE != type;
|
||||
doesSMS = (usingData && !preKitkat)
|
||||
? TelephonyManager.PHONE_TYPE_GSM == type
|
||||
: TelephonyManager.PHONE_TYPE_NONE != type;
|
||||
}
|
||||
}
|
||||
s_deviceSupportSMS = new Boolean( doesSMS );
|
||||
|
|
Loading…
Add table
Reference in a new issue