mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-28 09:58:30 +01:00
add preference (dialog) to set default address types. Not used yet,
and still ugly.
This commit is contained in:
parent
f2ecefd573
commit
f625332782
9 changed files with 1023 additions and 871 deletions
File diff suppressed because it is too large
Load diff
23
xwords4/android/XWords4/res/layout/conn_types_display.xml
Normal file
23
xwords4/android/XWords4/res/layout/conn_types_display.xml
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp"
|
||||
>
|
||||
<TextView android:id="@+id/invite_desc"
|
||||
android:text="@string/min_len"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:padding="8dp"
|
||||
/>
|
||||
|
||||
<LinearLayout android:id="@+id/conn_types"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
</LinearLayout>
|
|
@ -65,6 +65,7 @@
|
|||
<string name="key_summary_field">key_summary_field</string>
|
||||
<string name="key_default_loc">key_default_loc</string>
|
||||
<string name="key_force_tablet">key_force_tablet</string>
|
||||
<string name="key_addrs_pref">key_addrs_pref</string>
|
||||
|
||||
<!-- database keys whose entries aren't visible prefs -->
|
||||
<string name="key_closed_langs">key_closed_langs</string>
|
||||
|
|
|
@ -2284,4 +2284,8 @@
|
|||
|
||||
<!-- label within default wordlists in app preferences -->
|
||||
<string name="default_language">Default language</string>
|
||||
|
||||
<!-- Title of preference in which you select which addressing
|
||||
modes network games will use to communicate -->
|
||||
<string name="title_addrs_pref">Communicate via</string>
|
||||
</resources>
|
||||
|
|
|
@ -260,6 +260,11 @@
|
|||
<PreferenceScreen android:title="@string/network_behavior"
|
||||
android:summary="@string/network_behavior_summary"
|
||||
>
|
||||
<org.eehouse.android.xw4.XWConnAddrPreference
|
||||
android:key="@string/key_addrs_pref"
|
||||
android:title="@string/title_addrs_pref"
|
||||
/>
|
||||
|
||||
<org.eehouse.android.xw4.SMSCheckBoxPreference
|
||||
android:key="@string/key_enable_sms"
|
||||
android:title="@string/enable_sms"
|
||||
|
|
|
@ -1948,4 +1948,7 @@
|
|||
dna taht Sdrowssorc si dellatsni no ti.</string>
|
||||
<!-- label within default wordlists in app preferences -->
|
||||
<string name="default_language">Tluafed egaugnal</string>
|
||||
<!-- Title of preference in which you select which addressing
|
||||
modes network games will use to communicate -->
|
||||
<string name="title_addrs_pref">Etacinummoc aiv</string>
|
||||
</resources>
|
||||
|
|
|
@ -1948,4 +1948,7 @@
|
|||
AND THAT CROSSWORDS IS INSTALLED ON IT.</string>
|
||||
<!-- label within default wordlists in app preferences -->
|
||||
<string name="default_language">DEFAULT LANGUAGE</string>
|
||||
<!-- Title of preference in which you select which addressing
|
||||
modes network games will use to communicate -->
|
||||
<string name="title_addrs_pref">COMMUNICATE VIA</string>
|
||||
</resources>
|
||||
|
|
|
@ -0,0 +1,103 @@
|
|||
/* -*- compile-command: "find-and-ant.sh debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2010 - 2014 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
package org.eehouse.android.xw4;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.preference.DialogPreference;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import org.eehouse.android.xw4.loc.LocUtils;
|
||||
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType;
|
||||
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnTypeSet;
|
||||
|
||||
public class XWConnAddrPreference extends DialogPreference {
|
||||
|
||||
private int m_flags;
|
||||
private CommsConnTypeSet m_curSet;
|
||||
private Context m_context;
|
||||
// This stuff probably belongs in CommsConnType
|
||||
private static CommsConnTypeSet s_supported;
|
||||
static {
|
||||
s_supported = new CommsConnTypeSet();
|
||||
s_supported.add( CommsConnType.COMMS_CONN_RELAY );
|
||||
s_supported.add( CommsConnType.COMMS_CONN_BT );
|
||||
s_supported.add( CommsConnType.COMMS_CONN_SMS );
|
||||
}
|
||||
|
||||
public XWConnAddrPreference( Context context, AttributeSet attrs )
|
||||
{
|
||||
super( context, attrs );
|
||||
m_context = context;
|
||||
|
||||
// setWidgetLayoutResource( R.layout.conn_types_display );
|
||||
setDialogLayoutResource( R.layout.conn_types_display );
|
||||
|
||||
setNegativeButtonText( LocUtils.getString( context, R.string.button_cancel ) );
|
||||
|
||||
m_flags = XWPrefs.getPrefsInt( context, R.string.key_addrs_pref, 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBindDialogView( View view )
|
||||
{
|
||||
LocUtils.xlateView( m_context, view );
|
||||
|
||||
LinearLayout list = (LinearLayout)view.findViewById( R.id.conn_types );
|
||||
m_curSet = DBUtils.intToConnTypeSet( m_flags );
|
||||
for ( CommsConnType typ : s_supported.getTypes() ) {
|
||||
CheckBox box = (CheckBox)LocUtils.inflate( m_context, R.layout.btinviter_item );
|
||||
box.setText( typ.longName() );
|
||||
box.setChecked( m_curSet.contains( typ ) );
|
||||
list.addView( box );
|
||||
|
||||
final CommsConnType typf = typ;
|
||||
box.setOnCheckedChangeListener( new OnCheckedChangeListener() {
|
||||
public void onCheckedChanged( CompoundButton buttonView,
|
||||
boolean isChecked )
|
||||
{
|
||||
if ( isChecked ) {
|
||||
m_curSet.add( typf );
|
||||
} else {
|
||||
m_curSet.remove( typf );
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick( DialogInterface dialog, int which )
|
||||
{
|
||||
if ( AlertDialog.BUTTON_POSITIVE == which ) {
|
||||
DbgUtils.logf( "ok pressed" );
|
||||
m_flags = DBUtils.connTypeSetToInt( m_curSet );
|
||||
XWPrefs.setPrefsInt( m_context, R.string.key_addrs_pref, m_flags );
|
||||
}
|
||||
super.onClick( dialog, which );
|
||||
}
|
||||
}
|
|
@ -32,12 +32,15 @@ import org.eehouse.android.xw4.DbgUtils;
|
|||
|
||||
public class CommsAddrRec {
|
||||
|
||||
public enum CommsConnType { _COMMS_CONN_NONE,
|
||||
COMMS_CONN_IR,
|
||||
COMMS_CONN_IP_DIRECT,
|
||||
COMMS_CONN_RELAY,
|
||||
COMMS_CONN_BT,
|
||||
COMMS_CONN_SMS,
|
||||
public enum CommsConnType {
|
||||
_COMMS_CONN_NONE,
|
||||
COMMS_CONN_IR,
|
||||
COMMS_CONN_IP_DIRECT,
|
||||
COMMS_CONN_RELAY,
|
||||
COMMS_CONN_BT,
|
||||
COMMS_CONN_SMS;
|
||||
|
||||
public String longName() { return toString(); }
|
||||
};
|
||||
|
||||
public static class CommsConnTypeSet extends HashSet<CommsConnType> {
|
||||
|
|
Loading…
Reference in a new issue