mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-31 19:57:06 +01:00
move remaining non-jni prefs stuff from CommonPrefs to XWPrefs. No
other changes.
This commit is contained in:
parent
81d7903aa3
commit
6226efe8d6
18 changed files with 184 additions and 208 deletions
|
@ -47,7 +47,6 @@ import java.util.concurrent.TimeUnit;
|
||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
|
|
||||||
import org.eehouse.android.xw4.MultiService.MultiEvent;
|
import org.eehouse.android.xw4.MultiService.MultiEvent;
|
||||||
import org.eehouse.android.xw4.jni.CommonPrefs;
|
|
||||||
import org.eehouse.android.xw4.jni.CommsAddrRec;
|
import org.eehouse.android.xw4.jni.CommsAddrRec;
|
||||||
|
|
||||||
public class BTService extends Service {
|
public class BTService extends Service {
|
||||||
|
@ -877,9 +876,9 @@ public class BTService extends Service {
|
||||||
{
|
{
|
||||||
m_names = new HashMap<String, String>();
|
m_names = new HashMap<String, String>();
|
||||||
|
|
||||||
String[] names = CommonPrefs.getBTNames( this );
|
String[] names = XWPrefs.getBTNames( this );
|
||||||
if ( null != names ) {
|
if ( null != names ) {
|
||||||
String[] addrs = CommonPrefs.getBTAddresses( this );
|
String[] addrs = XWPrefs.getBTAddresses( this );
|
||||||
if ( null != addrs && names.length == addrs.length ) {
|
if ( null != addrs && names.length == addrs.length ) {
|
||||||
for ( int ii = 0; ii < names.length; ++ii ) {
|
for ( int ii = 0; ii < names.length; ++ii ) {
|
||||||
m_names.put( names[ii], addrs[ii] );
|
m_names.put( names[ii], addrs[ii] );
|
||||||
|
@ -905,8 +904,8 @@ public class BTService extends Service {
|
||||||
addrs[ii] = entry.getValue();
|
addrs[ii] = entry.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
CommonPrefs.setBTNames( this, names );
|
XWPrefs.setBTNames( this, names );
|
||||||
CommonPrefs.setBTAddresses( this, addrs );
|
XWPrefs.setBTAddresses( this, addrs );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startListener()
|
private void startListener()
|
||||||
|
|
|
@ -463,7 +463,7 @@ public class BoardActivity extends XWActivity
|
||||||
if ( null != m_exchCancelButton ) {
|
if ( null != m_exchCancelButton ) {
|
||||||
m_exchCancelButton.setOnClickListener( this );
|
m_exchCancelButton.setOnClickListener( this );
|
||||||
}
|
}
|
||||||
m_volKeysZoom = CommonPrefs.getVolKeysZoom( this );
|
m_volKeysZoom = XWPrefs.getVolKeysZoom( this );
|
||||||
|
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
m_rowid = intent.getLongExtra( GameUtils.INTENT_KEY_ROWID, -1 );
|
m_rowid = intent.getLongExtra( GameUtils.INTENT_KEY_ROWID, -1 );
|
||||||
|
@ -560,7 +560,7 @@ public class BoardActivity extends XWActivity
|
||||||
if ( hasFocus ) {
|
if ( hasFocus ) {
|
||||||
if ( m_firingPrefs ) {
|
if ( m_firingPrefs ) {
|
||||||
m_firingPrefs = false;
|
m_firingPrefs = false;
|
||||||
m_volKeysZoom = CommonPrefs.getVolKeysZoom( this );
|
m_volKeysZoom = XWPrefs.getVolKeysZoom( this );
|
||||||
if ( null != m_jniThread ) {
|
if ( null != m_jniThread ) {
|
||||||
m_jniThread.handle( JNIThread.JNICmd.CMD_PREFS_CHANGE );
|
m_jniThread.handle( JNIThread.JNICmd.CMD_PREFS_CHANGE );
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,6 @@ import java.io.ObjectOutputStream;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
|
|
||||||
import org.eehouse.android.xw4.jni.CommonPrefs;
|
|
||||||
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType;
|
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType;
|
||||||
import org.eehouse.android.xw4.jni.XwJNI;
|
import org.eehouse.android.xw4.jni.XwJNI;
|
||||||
|
|
||||||
|
@ -324,8 +323,8 @@ public class ConnStatusHandler {
|
||||||
public static void loadState( Context context )
|
public static void loadState( Context context )
|
||||||
{
|
{
|
||||||
synchronized( s_lockObj ) {
|
synchronized( s_lockObj ) {
|
||||||
String as64 = CommonPrefs.getPrefsString( context,
|
String as64 = XWPrefs.getPrefsString( context,
|
||||||
R.string.key_connstat_data );
|
R.string.key_connstat_data );
|
||||||
if ( null != as64 && 0 < as64.length() ) {
|
if ( null != as64 && 0 < as64.length() ) {
|
||||||
byte[] bytes = XwJNI.base64Decode( as64 );
|
byte[] bytes = XwJNI.base64Decode( as64 );
|
||||||
try {
|
try {
|
||||||
|
@ -451,10 +450,8 @@ public class ConnStatusHandler {
|
||||||
out.flush();
|
out.flush();
|
||||||
String as64 =
|
String as64 =
|
||||||
XwJNI.base64Encode( bas.toByteArray() );
|
XwJNI.base64Encode( bas.toByteArray() );
|
||||||
CommonPrefs.
|
XWPrefs.setPrefsString( context, R.string.key_connstat_data,
|
||||||
setPrefsString( context,
|
as64 );
|
||||||
R.string.key_connstat_data,
|
|
||||||
as64 );
|
|
||||||
} catch ( java.io.IOException ioe ) {
|
} catch ( java.io.IOException ioe ) {
|
||||||
DbgUtils.logf( "loadState: %s",
|
DbgUtils.logf( "loadState: %s",
|
||||||
ioe.toString() );
|
ioe.toString() );
|
||||||
|
|
|
@ -56,7 +56,6 @@ import junit.framework.Assert;
|
||||||
import org.eehouse.android.xw4.DictUtils.DictAndLoc;
|
import org.eehouse.android.xw4.DictUtils.DictAndLoc;
|
||||||
import org.eehouse.android.xw4.jni.XwJNI;
|
import org.eehouse.android.xw4.jni.XwJNI;
|
||||||
import org.eehouse.android.xw4.jni.JNIUtilsImpl;
|
import org.eehouse.android.xw4.jni.JNIUtilsImpl;
|
||||||
import org.eehouse.android.xw4.jni.CommonPrefs;
|
|
||||||
|
|
||||||
public class DictsActivity extends ExpandableListActivity
|
public class DictsActivity extends ExpandableListActivity
|
||||||
implements View.OnClickListener, XWListItem.DeleteCallback,
|
implements View.OnClickListener, XWListItem.DeleteCallback,
|
||||||
|
@ -383,7 +382,7 @@ public class DictsActivity extends ExpandableListActivity
|
||||||
getBundledData( savedInstanceState );
|
getBundledData( savedInstanceState );
|
||||||
|
|
||||||
m_closedLangs = new HashSet<String>();
|
m_closedLangs = new HashSet<String>();
|
||||||
String[] closed = CommonPrefs.getClosedLangs( this );
|
String[] closed = XWPrefs.getClosedLangs( this );
|
||||||
if ( null != closed ) {
|
if ( null != closed ) {
|
||||||
for ( String str : closed ) {
|
for ( String str : closed ) {
|
||||||
m_closedLangs.add( str );
|
m_closedLangs.add( str );
|
||||||
|
@ -716,7 +715,7 @@ public class DictsActivity extends ExpandableListActivity
|
||||||
private void saveClosed()
|
private void saveClosed()
|
||||||
{
|
{
|
||||||
String[] asArray = m_closedLangs.toArray( new String[m_closedLangs.size()] );
|
String[] asArray = m_closedLangs.toArray( new String[m_closedLangs.size()] );
|
||||||
CommonPrefs.setClosedLangs( this, asArray );
|
XWPrefs.setClosedLangs( this, asArray );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Intent mkDownloadIntent( Context context, String dict_url )
|
private static Intent mkDownloadIntent( Context context, String dict_url )
|
||||||
|
@ -730,7 +729,7 @@ public class DictsActivity extends ExpandableListActivity
|
||||||
private static Intent mkDownloadIntent( Context context,
|
private static Intent mkDownloadIntent( Context context,
|
||||||
int lang, String dict )
|
int lang, String dict )
|
||||||
{
|
{
|
||||||
String dict_url = CommonPrefs.getDefaultDictURL( context );
|
String dict_url = XWPrefs.getDefaultDictURL( context );
|
||||||
if ( 0 != lang ) {
|
if ( 0 != lang ) {
|
||||||
dict_url += "/" + DictLangCache.getLangName( context, lang );
|
dict_url += "/" + DictLangCache.getLangName( context, lang );
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,6 @@ import android.os.Bundle;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
|
|
||||||
import org.eehouse.android.xw4.jni.CommonPrefs;
|
|
||||||
|
|
||||||
public class DispatchNotify extends Activity {
|
public class DispatchNotify extends Activity {
|
||||||
|
|
||||||
public static final String RELAYIDS_EXTRA = "relayids";
|
public static final String RELAYIDS_EXTRA = "relayids";
|
||||||
|
|
|
@ -34,8 +34,6 @@ import android.widget.Toast;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
|
|
||||||
import org.eehouse.android.xw4.jni.CommonPrefs;
|
|
||||||
|
|
||||||
|
|
||||||
public class DlgDelegate {
|
public class DlgDelegate {
|
||||||
|
|
||||||
|
@ -180,7 +178,7 @@ public class DlgDelegate {
|
||||||
public void showNotAgainDlgThen( int msgID, int prefsKey,
|
public void showNotAgainDlgThen( int msgID, int prefsKey,
|
||||||
int callbackID )
|
int callbackID )
|
||||||
{
|
{
|
||||||
boolean set = CommonPrefs.getPrefsBoolean( m_activity, prefsKey, false );
|
boolean set = XWPrefs.getPrefsBoolean( m_activity, prefsKey, false );
|
||||||
if ( set || 0 != m_cbckID ) {
|
if ( set || 0 != m_cbckID ) {
|
||||||
// If it's set, do the action without bothering with the
|
// If it's set, do the action without bothering with the
|
||||||
// dialog
|
// dialog
|
||||||
|
@ -364,8 +362,7 @@ public class DlgDelegate {
|
||||||
DialogInterface.OnClickListener lstnr_n =
|
DialogInterface.OnClickListener lstnr_n =
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
public void onClick( DialogInterface dlg, int item ) {
|
public void onClick( DialogInterface dlg, int item ) {
|
||||||
CommonPrefs.setPrefsBoolean( m_activity, m_prefsKey,
|
XWPrefs.setPrefsBoolean( m_activity, m_prefsKey, true );
|
||||||
true );
|
|
||||||
if ( SKIP_CALLBACK != m_cbckID ) {
|
if ( SKIP_CALLBACK != m_cbckID ) {
|
||||||
m_clickCallback.
|
m_clickCallback.
|
||||||
dlgButtonClicked( m_cbckID,
|
dlgButtonClicked( m_cbckID,
|
||||||
|
|
|
@ -489,8 +489,8 @@ public class GameConfig extends XWActivity
|
||||||
XwJNI.comms_getAddr( gamePtr, m_carOrig );
|
XwJNI.comms_getAddr( gamePtr, m_carOrig );
|
||||||
m_remoteAddrs = XwJNI.comms_getAddrs( gamePtr );
|
m_remoteAddrs = XwJNI.comms_getAddrs( gamePtr );
|
||||||
} else if (DeviceRole.SERVER_STANDALONE != m_giOrig.serverRole){
|
} else if (DeviceRole.SERVER_STANDALONE != m_giOrig.serverRole){
|
||||||
String relayName = CommonPrefs.getDefaultRelayHost( this );
|
String relayName = XWPrefs.getDefaultRelayHost( this );
|
||||||
int relayPort = CommonPrefs.getDefaultRelayPort( this );
|
int relayPort = XWPrefs.getDefaultRelayPort( this );
|
||||||
XwJNI.comms_getInitialAddr( m_carOrig, relayName, relayPort );
|
XwJNI.comms_getInitialAddr( m_carOrig, relayName, relayPort );
|
||||||
}
|
}
|
||||||
m_conType = m_carOrig.conType;
|
m_conType = m_carOrig.conType;
|
||||||
|
|
|
@ -214,8 +214,8 @@ public class GameUtils {
|
||||||
addr = new CommsAddrRec();
|
addr = new CommsAddrRec();
|
||||||
XwJNI.comms_getAddr( gamePtr, addr );
|
XwJNI.comms_getAddr( gamePtr, addr );
|
||||||
if ( CommsAddrRec.CommsConnType.COMMS_CONN_NONE == addr.conType ) {
|
if ( CommsAddrRec.CommsConnType.COMMS_CONN_NONE == addr.conType ) {
|
||||||
String relayName = CommonPrefs.getDefaultRelayHost( context );
|
String relayName = XWPrefs.getDefaultRelayHost( context );
|
||||||
int relayPort = CommonPrefs.getDefaultRelayPort( context );
|
int relayPort = XWPrefs.getDefaultRelayPort( context );
|
||||||
XwJNI.comms_getInitialAddr( addr, relayName, relayPort );
|
XwJNI.comms_getInitialAddr( addr, relayName, relayPort );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -453,8 +453,8 @@ public class GameUtils {
|
||||||
int nPlayersT, int nPlayersH )
|
int nPlayersT, int nPlayersH )
|
||||||
{
|
{
|
||||||
long rowid = -1;
|
long rowid = -1;
|
||||||
String relayName = CommonPrefs.getDefaultRelayHost( context );
|
String relayName = XWPrefs.getDefaultRelayHost( context );
|
||||||
int relayPort = CommonPrefs.getDefaultRelayPort( context );
|
int relayPort = XWPrefs.getDefaultRelayPort( context );
|
||||||
CommsAddrRec addr = new CommsAddrRec( relayName, relayPort );
|
CommsAddrRec addr = new CommsAddrRec( relayName, relayPort );
|
||||||
addr.ip_relay_invite = room;
|
addr.ip_relay_invite = room;
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,6 @@ import android.net.Uri.Builder;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
|
|
||||||
import org.eehouse.android.xw4.jni.CommonPrefs;
|
|
||||||
|
|
||||||
|
|
||||||
public class NetLaunchInfo {
|
public class NetLaunchInfo {
|
||||||
public String room;
|
public String room;
|
||||||
|
@ -85,8 +83,8 @@ public class NetLaunchInfo {
|
||||||
Builder ub = new Builder();
|
Builder ub = new Builder();
|
||||||
ub.scheme( "http" );
|
ub.scheme( "http" );
|
||||||
String format = context.getString( R.string.game_url_pathf );
|
String format = context.getString( R.string.game_url_pathf );
|
||||||
ub.path( String.format( format,
|
ub.path( String.format( format,
|
||||||
CommonPrefs.getDefaultRedirHost( context ) ) );
|
XWPrefs.getDefaultRedirHost( context ) ) );
|
||||||
|
|
||||||
ub.appendQueryParameter( "lang", String.format("%d", lang ) );
|
ub.appendQueryParameter( "lang", String.format("%d", lang ) );
|
||||||
ub.appendQueryParameter( "np", String.format( "%d", nPlayers ) );
|
ub.appendQueryParameter( "np", String.format( "%d", nPlayers ) );
|
||||||
|
|
|
@ -34,9 +34,6 @@ import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import javax.net.SocketFactory;
|
import javax.net.SocketFactory;
|
||||||
|
|
||||||
|
|
||||||
import org.eehouse.android.xw4.jni.CommonPrefs;
|
|
||||||
|
|
||||||
public class NetUtils {
|
public class NetUtils {
|
||||||
|
|
||||||
private static final int MAX_SEND = 1024;
|
private static final int MAX_SEND = 1024;
|
||||||
|
@ -55,8 +52,8 @@ public class NetUtils {
|
||||||
{
|
{
|
||||||
Socket socket = null;
|
Socket socket = null;
|
||||||
try {
|
try {
|
||||||
int port = CommonPrefs.getDefaultProxyPort( context );
|
int port = XWPrefs.getDefaultProxyPort( context );
|
||||||
String host = CommonPrefs.getDefaultRelayHost( context );
|
String host = XWPrefs.getDefaultRelayHost( context );
|
||||||
|
|
||||||
SocketFactory factory = SocketFactory.getDefault();
|
SocketFactory factory = SocketFactory.getDefault();
|
||||||
InetAddress addr = InetAddress.getByName( host );
|
InetAddress addr = InetAddress.getByName( host );
|
||||||
|
|
|
@ -28,8 +28,6 @@ import android.content.Intent;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import org.eehouse.android.xw4.jni.CommonPrefs;
|
|
||||||
|
|
||||||
public class RelayReceiver extends BroadcastReceiver {
|
public class RelayReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -51,7 +49,7 @@ public class RelayReceiver extends BroadcastReceiver {
|
||||||
public static void RestartTimer( Context context, boolean force )
|
public static void RestartTimer( Context context, boolean force )
|
||||||
{
|
{
|
||||||
RestartTimer( context,
|
RestartTimer( context,
|
||||||
1000 * CommonPrefs.getProxyInterval( context ), force );
|
1000 * XWPrefs.getProxyInterval( context ), force );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void RestartTimer( Context context )
|
public static void RestartTimer( Context context )
|
||||||
|
|
|
@ -34,7 +34,6 @@ import java.io.DataOutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.eehouse.android.xw4.jni.GameSummary;
|
import org.eehouse.android.xw4.jni.GameSummary;
|
||||||
import org.eehouse.android.xw4.jni.CommonPrefs;
|
|
||||||
|
|
||||||
public class RelayService extends Service {
|
public class RelayService extends Service {
|
||||||
|
|
||||||
|
|
|
@ -46,8 +46,6 @@ import java.util.Comparator;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
|
|
||||||
import org.eehouse.android.xw4.jni.CommonPrefs;
|
|
||||||
|
|
||||||
public class SMSInviteActivity extends InviteActivity {
|
public class SMSInviteActivity extends InviteActivity {
|
||||||
|
|
||||||
private static final int GET_CONTACT = 1;
|
private static final int GET_CONTACT = 1;
|
||||||
|
@ -281,7 +279,7 @@ public class SMSInviteActivity extends InviteActivity {
|
||||||
|
|
||||||
private void getSavedState()
|
private void getSavedState()
|
||||||
{
|
{
|
||||||
String[] phones = CommonPrefs.getSMSPhones( this );
|
String[] phones = XWPrefs.getSMSPhones( this );
|
||||||
|
|
||||||
m_phoneRecs = new ArrayList<PhoneRec>(phones.length);
|
m_phoneRecs = new ArrayList<PhoneRec>(phones.length);
|
||||||
for ( String phone : phones ) {
|
for ( String phone : phones ) {
|
||||||
|
@ -298,7 +296,7 @@ public class SMSInviteActivity extends InviteActivity {
|
||||||
PhoneRec rec = iter.next();
|
PhoneRec rec = iter.next();
|
||||||
phones[ii] = rec.m_phone;
|
phones[ii] = rec.m_phone;
|
||||||
}
|
}
|
||||||
CommonPrefs.setSMSPhones( this, phones );
|
XWPrefs.setSMSPhones( this, phones );
|
||||||
|
|
||||||
rebuildList( false );
|
rebuildList( false );
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,6 @@ import junit.framework.Assert;
|
||||||
import org.eehouse.android.xw4.MultiService.MultiEvent;
|
import org.eehouse.android.xw4.MultiService.MultiEvent;
|
||||||
import org.eehouse.android.xw4.jni.CommsAddrRec;
|
import org.eehouse.android.xw4.jni.CommsAddrRec;
|
||||||
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType;
|
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType;
|
||||||
import org.eehouse.android.xw4.jni.CommonPrefs;
|
|
||||||
import org.eehouse.android.xw4.jni.XwJNI;
|
import org.eehouse.android.xw4.jni.XwJNI;
|
||||||
|
|
||||||
public class SMSService extends Service {
|
public class SMSService extends Service {
|
||||||
|
|
|
@ -30,8 +30,6 @@ import android.view.View;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
|
|
||||||
import org.eehouse.android.xw4.jni.CommonPrefs;
|
|
||||||
|
|
||||||
public class XWActivity extends Activity
|
public class XWActivity extends Activity
|
||||||
implements DlgDelegate.DlgClickNotify, MultiService.BTEventListener {
|
implements DlgDelegate.DlgClickNotify, MultiService.BTEventListener {
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,6 @@ import android.os.Bundle;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
|
|
||||||
import org.eehouse.android.xw4.jni.CommonPrefs;
|
|
||||||
|
|
||||||
public class XWListActivity extends ListActivity
|
public class XWListActivity extends ListActivity
|
||||||
implements DlgDelegate.DlgClickNotify, MultiService.BTEventListener {
|
implements DlgDelegate.DlgClickNotify, MultiService.BTEventListener {
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,9 @@ package org.eehouse.android.xw4;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class XWPrefs {
|
public class XWPrefs {
|
||||||
|
|
||||||
|
@ -36,6 +39,74 @@ public class XWPrefs {
|
||||||
return getPrefsBoolean( context, R.string.key_enable_debug, false );
|
return getPrefsBoolean( context, R.string.key_enable_debug, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getDefaultRelayHost( Context context )
|
||||||
|
{
|
||||||
|
return getPrefsString( context, R.string.key_relay_host );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getDefaultRedirHost( Context context )
|
||||||
|
{
|
||||||
|
return getPrefsString( context, R.string.key_redir_host );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getDefaultRelayPort( Context context )
|
||||||
|
{
|
||||||
|
String val = getPrefsString( context, R.string.key_relay_port );
|
||||||
|
int result = 0;
|
||||||
|
try {
|
||||||
|
result = Integer.parseInt( val );
|
||||||
|
} catch ( Exception ex ) {
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getDefaultProxyPort( Context context )
|
||||||
|
{
|
||||||
|
String val = getPrefsString( context, R.string.key_proxy_port );
|
||||||
|
int result = 0;
|
||||||
|
try {
|
||||||
|
result = Integer.parseInt( val );
|
||||||
|
} catch ( Exception ex ) {
|
||||||
|
}
|
||||||
|
// DbgUtils.logf( "getDefaultProxyPort=>%d", result );
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getDefaultDictURL( Context context )
|
||||||
|
{
|
||||||
|
return getPrefsString( context, R.string.key_dict_host );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean getVolKeysZoom( Context context )
|
||||||
|
{
|
||||||
|
return getPrefsBoolean( context, R.string.key_ringer_zoom, false );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getDefaultPlayerMinutes( Context context )
|
||||||
|
{
|
||||||
|
String value =
|
||||||
|
getPrefsString( context, R.string.key_initial_player_minutes );
|
||||||
|
int result;
|
||||||
|
try {
|
||||||
|
result = Integer.parseInt( value );
|
||||||
|
} catch ( Exception ex ) {
|
||||||
|
result = 25;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long getProxyInterval( 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 boolean getPrefsBoolean( Context context, int keyID,
|
public static boolean getPrefsBoolean( Context context, int keyID,
|
||||||
boolean defaultValue )
|
boolean defaultValue )
|
||||||
{
|
{
|
||||||
|
@ -56,4 +127,89 @@ public class XWPrefs {
|
||||||
editor.commit();
|
editor.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setClosedLangs( Context context, String[] langs )
|
||||||
|
{
|
||||||
|
setPrefsString( context, R.string.key_closed_langs,
|
||||||
|
TextUtils.join( "\n", langs ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String[] getClosedLangs( Context context )
|
||||||
|
{
|
||||||
|
return getPrefsStringArray( context, R.string.key_closed_langs );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setBTNames( Context context, String[] names )
|
||||||
|
{
|
||||||
|
setPrefsStringArray( context, R.string.key_bt_names, names );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setSMSPhones( Context context, String[] names )
|
||||||
|
{
|
||||||
|
setPrefsStringArray( context, R.string.key_sms_phones, names );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String[] getBTNames( Context context )
|
||||||
|
{
|
||||||
|
return getPrefsStringArray( context, R.string.key_bt_names );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String[] getSMSPhones( Context context )
|
||||||
|
{
|
||||||
|
return getPrefsStringArray( context, R.string.key_sms_phones );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setBTAddresses( Context context, String[] addrs )
|
||||||
|
{
|
||||||
|
setPrefsStringArray( context, R.string.key_bt_addrs, addrs );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String[] getBTAddresses( Context context )
|
||||||
|
{
|
||||||
|
return getPrefsStringArray( context, R.string.key_bt_addrs );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static String getPrefsString( Context context, int keyID )
|
||||||
|
{
|
||||||
|
String key = context.getString( keyID );
|
||||||
|
SharedPreferences sp = PreferenceManager
|
||||||
|
.getDefaultSharedPreferences( context );
|
||||||
|
return sp.getString( key, "" );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static void setPrefsString( Context context, int keyID,
|
||||||
|
String newValue )
|
||||||
|
{
|
||||||
|
SharedPreferences sp = PreferenceManager
|
||||||
|
.getDefaultSharedPreferences( context );
|
||||||
|
SharedPreferences.Editor editor = sp.edit();
|
||||||
|
String key = context.getString( keyID );
|
||||||
|
editor.putString( key, newValue );
|
||||||
|
editor.commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static String[] getPrefsStringArray( Context context, int keyID )
|
||||||
|
{
|
||||||
|
String asStr = getPrefsString( context, keyID );
|
||||||
|
String[] result = null == asStr ? null : TextUtils.split( asStr, "\n" );
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static ArrayList<String> getPrefsStringArrayList( Context context,
|
||||||
|
int keyID )
|
||||||
|
{
|
||||||
|
ArrayList<String> list = new ArrayList<String>();
|
||||||
|
String[] strs = getPrefsStringArray( context, keyID );
|
||||||
|
if ( null != strs ) {
|
||||||
|
for ( int ii = 0; ii < strs.length; ++ii ) {
|
||||||
|
list.add( strs[ii] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static void setPrefsStringArray( Context context, int keyID,
|
||||||
|
String[] value )
|
||||||
|
{
|
||||||
|
setPrefsString( context, keyID, TextUtils.join( "\n", value ) );
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -25,8 +25,6 @@ import android.content.SharedPreferences;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.text.TextUtils;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
|
|
||||||
import org.eehouse.android.xw4.XWPrefs;
|
import org.eehouse.android.xw4.XWPrefs;
|
||||||
|
@ -140,49 +138,6 @@ public class CommonPrefs extends XWPrefs {
|
||||||
return s_cp.refresh( context );
|
return s_cp.refresh( context );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getDefaultRelayHost( Context context )
|
|
||||||
{
|
|
||||||
return getPrefsString( context, R.string.key_relay_host );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getDefaultRedirHost( Context context )
|
|
||||||
{
|
|
||||||
return getPrefsString( context, R.string.key_redir_host );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getDefaultRelayPort( Context context )
|
|
||||||
{
|
|
||||||
String val = getPrefsString( context, R.string.key_relay_port );
|
|
||||||
int result = 0;
|
|
||||||
try {
|
|
||||||
result = Integer.parseInt( val );
|
|
||||||
} catch ( Exception ex ) {
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getDefaultProxyPort( Context context )
|
|
||||||
{
|
|
||||||
String val = getPrefsString( context, R.string.key_proxy_port );
|
|
||||||
int result = 0;
|
|
||||||
try {
|
|
||||||
result = Integer.parseInt( val );
|
|
||||||
} catch ( Exception ex ) {
|
|
||||||
}
|
|
||||||
// DbgUtils.logf( "getDefaultProxyPort=>%d", result );
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getDefaultDictURL( Context context )
|
|
||||||
{
|
|
||||||
return getPrefsString( context, R.string.key_dict_host );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean getVolKeysZoom( Context context )
|
|
||||||
{
|
|
||||||
return getPrefsBoolean( context, R.string.key_ringer_zoom, false );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getDefaultBoardSize( Context context )
|
public static int getDefaultBoardSize( Context context )
|
||||||
{
|
{
|
||||||
String value = getPrefsString( context, R.string.key_board_size );
|
String value = getPrefsString( context, R.string.key_board_size );
|
||||||
|
@ -195,31 +150,6 @@ public class CommonPrefs extends XWPrefs {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getDefaultPlayerMinutes( Context context )
|
|
||||||
{
|
|
||||||
String value =
|
|
||||||
getPrefsString( context, R.string.key_initial_player_minutes );
|
|
||||||
int result;
|
|
||||||
try {
|
|
||||||
result = Integer.parseInt( value );
|
|
||||||
} catch ( Exception ex ) {
|
|
||||||
result = 25;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static long getProxyInterval( 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 String getDefaultHumanDict( Context context )
|
public static String getDefaultHumanDict( Context context )
|
||||||
{
|
{
|
||||||
String value = getPrefsString( context, R.string.key_default_dict );
|
String value = getPrefsString( context, R.string.key_default_dict );
|
||||||
|
@ -337,89 +267,4 @@ public class CommonPrefs extends XWPrefs {
|
||||||
return getPrefsString( context, R.string.key_summary_field );
|
return getPrefsString( context, R.string.key_summary_field );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setClosedLangs( Context context, String[] langs )
|
|
||||||
{
|
|
||||||
setPrefsString( context, R.string.key_closed_langs,
|
|
||||||
TextUtils.join( "\n", langs ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String[] getClosedLangs( Context context )
|
|
||||||
{
|
|
||||||
return getPrefsStringArray( context, R.string.key_closed_langs );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setBTNames( Context context, String[] names )
|
|
||||||
{
|
|
||||||
setPrefsStringArray( context, R.string.key_bt_names, names );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setSMSPhones( Context context, String[] names )
|
|
||||||
{
|
|
||||||
setPrefsStringArray( context, R.string.key_sms_phones, names );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String[] getBTNames( Context context )
|
|
||||||
{
|
|
||||||
return getPrefsStringArray( context, R.string.key_bt_names );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String[] getSMSPhones( Context context )
|
|
||||||
{
|
|
||||||
return getPrefsStringArray( context, R.string.key_sms_phones );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setBTAddresses( Context context, String[] addrs )
|
|
||||||
{
|
|
||||||
setPrefsStringArray( context, R.string.key_bt_addrs, addrs );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String[] getBTAddresses( Context context )
|
|
||||||
{
|
|
||||||
return getPrefsStringArray( context, R.string.key_bt_addrs );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getPrefsString( Context context, int keyID )
|
|
||||||
{
|
|
||||||
String key = context.getString( keyID );
|
|
||||||
SharedPreferences sp = PreferenceManager
|
|
||||||
.getDefaultSharedPreferences( context );
|
|
||||||
return sp.getString( key, "" );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setPrefsString( Context context, int keyID,
|
|
||||||
String newValue )
|
|
||||||
{
|
|
||||||
SharedPreferences sp = PreferenceManager
|
|
||||||
.getDefaultSharedPreferences( context );
|
|
||||||
SharedPreferences.Editor editor = sp.edit();
|
|
||||||
String key = context.getString( keyID );
|
|
||||||
editor.putString( key, newValue );
|
|
||||||
editor.commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String[] getPrefsStringArray( Context context, int keyID )
|
|
||||||
{
|
|
||||||
String asStr = getPrefsString( context, keyID );
|
|
||||||
String[] result = null == asStr ? null : TextUtils.split( asStr, "\n" );
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ArrayList<String> getPrefsStringArrayList( Context context,
|
|
||||||
int keyID )
|
|
||||||
{
|
|
||||||
ArrayList<String> list = new ArrayList<String>();
|
|
||||||
String[] strs = getPrefsStringArray( context, keyID );
|
|
||||||
if ( null != strs ) {
|
|
||||||
for ( int ii = 0; ii < strs.length; ++ii ) {
|
|
||||||
list.add( strs[ii] );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void setPrefsStringArray( Context context, int keyID,
|
|
||||||
String[] value )
|
|
||||||
{
|
|
||||||
setPrefsString( context, keyID, TextUtils.join( "\n", value ) );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue