add ability to invite more than one player per device. This is mostly

for testing and needs to be hidden by an "advanced" pref so folks
don't stumble onto it. Works for BT (SMS will crash), but needs
cleaning up.
This commit is contained in:
Eric House 2014-12-31 06:54:31 -08:00
parent d46c7a39f1
commit a7cc96c697
11 changed files with 310 additions and 222 deletions

View file

@ -80,202 +80,204 @@ public final class R {
}
public static final class id {
public static final int about_xlator=0x7f090001;
public static final int add_player=0x7f09002d;
public static final int advertise_new_room_check=0x7f090034;
public static final int blessed_label=0x7f090055;
public static final int board_menu_chat=0x7f09009b;
public static final int board_menu_dict=0x7f090097;
public static final int board_menu_done=0x7f090082;
public static final int board_menu_file_about=0x7f090090;
public static final int board_menu_file_prefs=0x7f09008f;
public static final int board_menu_flip=0x7f090099;
public static final int board_menu_game_counts=0x7f090088;
public static final int board_menu_game_history=0x7f09008a;
public static final int board_menu_game_left=0x7f090089;
public static final int board_menu_game_netstats=0x7f090091;
public static final int board_menu_game_resend=0x7f09008c;
public static final int board_menu_game_resign=0x7f09008b;
public static final int board_menu_hint_next=0x7f090095;
public static final int board_menu_hint_prev=0x7f090094;
public static final int board_menu_invite=0x7f090081;
public static final int board_menu_juggle=0x7f090098;
public static final int board_menu_toggle=0x7f09009c;
public static final int board_menu_trade=0x7f090083;
public static final int board_menu_trade_cancel=0x7f090084;
public static final int board_menu_trade_commit=0x7f090085;
public static final int board_menu_tray=0x7f090087;
public static final int board_menu_undo_current=0x7f090096;
public static final int board_menu_undo_last=0x7f090086;
public static final int board_menu_zoom=0x7f09009a;
public static final int add_player=0x7f09002f;
public static final int advertise_new_room_check=0x7f090036;
public static final int blessed_label=0x7f090057;
public static final int board_menu_chat=0x7f09009d;
public static final int board_menu_dict=0x7f090099;
public static final int board_menu_done=0x7f090084;
public static final int board_menu_file_about=0x7f090092;
public static final int board_menu_file_prefs=0x7f090091;
public static final int board_menu_flip=0x7f09009b;
public static final int board_menu_game_counts=0x7f09008a;
public static final int board_menu_game_history=0x7f09008c;
public static final int board_menu_game_left=0x7f09008b;
public static final int board_menu_game_netstats=0x7f090093;
public static final int board_menu_game_resend=0x7f09008e;
public static final int board_menu_game_resign=0x7f09008d;
public static final int board_menu_hint_next=0x7f090097;
public static final int board_menu_hint_prev=0x7f090096;
public static final int board_menu_invite=0x7f090083;
public static final int board_menu_juggle=0x7f09009a;
public static final int board_menu_toggle=0x7f09009e;
public static final int board_menu_trade=0x7f090085;
public static final int board_menu_trade_cancel=0x7f090086;
public static final int board_menu_trade_commit=0x7f090087;
public static final int board_menu_tray=0x7f090089;
public static final int board_menu_undo_current=0x7f090098;
public static final int board_menu_undo_last=0x7f090088;
public static final int board_menu_zoom=0x7f09009c;
public static final int board_root=0x7f090002;
public static final int board_view=0x7f090003;
public static final int boardsize_spinner=0x7f090041;
public static final int button_add=0x7f090070;
public static final int boardsize_spinner=0x7f090043;
public static final int button_add=0x7f090072;
public static final int button_clear=0x7f09000b;
public static final int button_done=0x7f090060;
public static final int button_done=0x7f090062;
public static final int button_invite=0x7f09000c;
public static final int button_newgame_multi=0x7f090043;
public static final int button_newgame_solo=0x7f090042;
public static final int button_newgame_multi=0x7f090045;
public static final int button_newgame_solo=0x7f090044;
public static final int button_rescan=0x7f09000a;
public static final int button_study=0x7f09005f;
public static final int chat_button=0x7f09007c;
public static final int chat_edit=0x7f09000e;
public static final int chat_history=0x7f09000d;
public static final int chat_menu_clear=0x7f09009d;
public static final int checkbox=0x7f09004f;
public static final int color_display_sample=0x7f090010;
public static final int color_edit_sample=0x7f090011;
public static final int confirm_sms_reasons=0x7f090018;
public static final int conn_types=0x7f090019;
public static final int connect_set_relay=0x7f09002f;
public static final int connect_set_sms=0x7f090038;
public static final int conns_label=0x7f090030;
public static final int del=0x7f090052;
public static final int desc=0x7f09001c;
public static final int details=0x7f09006d;
public static final int dict_label=0x7f090065;
public static final int dict_spinner=0x7f09002a;
public static final int dictlist_button=0x7f09007b;
public static final int dicts_delete=0x7f0900a0;
public static final int dicts_deselect_all=0x7f09009f;
public static final int dicts_download=0x7f09009e;
public static final int dicts_move=0x7f0900a1;
public static final int dicts_select=0x7f0900a2;
public static final int divider=0x7f090021;
public static final int download_button=0x7f09006e;
public static final int dwnld_message=0x7f09004d;
public static final int edit=0x7f090061;
public static final int edit_blue=0x7f090017;
public static final int edit_green=0x7f090015;
public static final int edit_red=0x7f090013;
public static final int english_label=0x7f090053;
public static final int english_view=0x7f090054;
public static final int button_study=0x7f090061;
public static final int chat_button=0x7f09007e;
public static final int chat_edit=0x7f090010;
public static final int chat_history=0x7f09000f;
public static final int chat_menu_clear=0x7f09009f;
public static final int checkbox=0x7f090051;
public static final int color_display_sample=0x7f090012;
public static final int color_edit_sample=0x7f090013;
public static final int confirm_sms_reasons=0x7f09001a;
public static final int conn_types=0x7f09001b;
public static final int connect_set_relay=0x7f090031;
public static final int connect_set_sms=0x7f09003a;
public static final int conns_label=0x7f090032;
public static final int del=0x7f090054;
public static final int desc=0x7f09001e;
public static final int details=0x7f09006f;
public static final int dict_label=0x7f090067;
public static final int dict_spinner=0x7f09002c;
public static final int dictlist_button=0x7f09007d;
public static final int dicts_delete=0x7f0900a2;
public static final int dicts_deselect_all=0x7f0900a1;
public static final int dicts_download=0x7f0900a0;
public static final int dicts_move=0x7f0900a3;
public static final int dicts_select=0x7f0900a4;
public static final int divider=0x7f090023;
public static final int download_button=0x7f090070;
public static final int dwnld_message=0x7f09004f;
public static final int edit=0x7f090063;
public static final int edit_blue=0x7f090019;
public static final int edit_green=0x7f090017;
public static final int edit_red=0x7f090015;
public static final int english_label=0x7f090055;
public static final int english_view=0x7f090056;
public static final int exchange_buttons=0x7f090004;
public static final int exchange_cancel=0x7f090006;
public static final int exchange_commit=0x7f090005;
public static final int expander=0x7f090023;
public static final int filters=0x7f09005a;
public static final int flip_button=0x7f09007e;
public static final int game_locked_check=0x7f090025;
public static final int game_name=0x7f090044;
public static final int gamel_menu_checkmoves=0x7f09008e;
public static final int games_game_config=0x7f0900ae;
public static final int games_game_copy=0x7f0900b3;
public static final int games_game_delete=0x7f0900ad;
public static final int games_game_move=0x7f0900af;
public static final int games_game_new_from=0x7f0900b1;
public static final int games_game_rename=0x7f0900b2;
public static final int games_game_reset=0x7f0900b0;
public static final int games_group_default=0x7f0900b7;
public static final int games_group_delete=0x7f0900b6;
public static final int games_group_movedown=0x7f0900b5;
public static final int games_group_moveup=0x7f0900b4;
public static final int games_group_rename=0x7f0900b8;
public static final int games_menu_about=0x7f0900aa;
public static final int games_menu_checkmoves=0x7f0900ac;
public static final int games_menu_checkupdates=0x7f0900b9;
public static final int games_menu_dicts=0x7f0900a8;
public static final int games_menu_email=0x7f0900a9;
public static final int games_menu_loaddb=0x7f0900bb;
public static final int games_menu_newgame_net=0x7f0900a4;
public static final int games_menu_newgame_solo=0x7f0900a3;
public static final int games_menu_newgroup=0x7f0900a5;
public static final int games_menu_prefs=0x7f0900a6;
public static final int games_menu_rateme=0x7f0900a7;
public static final int games_menu_resend=0x7f0900ab;
public static final int games_menu_storedb=0x7f0900ba;
public static final int games_menu_study=0x7f09008d;
public static final int group_done=0x7f090080;
public static final int group_exchange=0x7f090092;
public static final int group_hint=0x7f090093;
public static final int hideable=0x7f090049;
public static final int hints_allowed=0x7f09003a;
public static final int expander=0x7f090025;
public static final int filters=0x7f09005c;
public static final int flip_button=0x7f090080;
public static final int game_locked_check=0x7f090027;
public static final int game_name=0x7f090046;
public static final int gamel_menu_checkmoves=0x7f090090;
public static final int games_game_config=0x7f0900b0;
public static final int games_game_copy=0x7f0900b5;
public static final int games_game_delete=0x7f0900af;
public static final int games_game_move=0x7f0900b1;
public static final int games_game_new_from=0x7f0900b3;
public static final int games_game_rename=0x7f0900b4;
public static final int games_game_reset=0x7f0900b2;
public static final int games_group_default=0x7f0900b9;
public static final int games_group_delete=0x7f0900b8;
public static final int games_group_movedown=0x7f0900b7;
public static final int games_group_moveup=0x7f0900b6;
public static final int games_group_rename=0x7f0900ba;
public static final int games_menu_about=0x7f0900ac;
public static final int games_menu_checkmoves=0x7f0900ae;
public static final int games_menu_checkupdates=0x7f0900bb;
public static final int games_menu_dicts=0x7f0900aa;
public static final int games_menu_email=0x7f0900ab;
public static final int games_menu_loaddb=0x7f0900bd;
public static final int games_menu_newgame_net=0x7f0900a6;
public static final int games_menu_newgame_solo=0x7f0900a5;
public static final int games_menu_newgroup=0x7f0900a7;
public static final int games_menu_prefs=0x7f0900a8;
public static final int games_menu_rateme=0x7f0900a9;
public static final int games_menu_resend=0x7f0900ad;
public static final int games_menu_storedb=0x7f0900bc;
public static final int games_menu_study=0x7f09008f;
public static final int group_done=0x7f090082;
public static final int group_exchange=0x7f090094;
public static final int group_hint=0x7f090095;
public static final int hideable=0x7f09004b;
public static final int hints_allowed=0x7f09003c;
public static final int invite_desc=0x7f090009;
public static final int item_name=0x7f090069;
public static final int item_score=0x7f09006a;
public static final int join_public_room_check=0x7f090031;
public static final int juggle_players=0x7f09002e;
public static final int label=0x7f090022;
public static final int lang_separator=0x7f090028;
public static final int lang_spinner=0x7f090029;
public static final int loc_item_check=0x7f0900bd;
public static final int loc_item_clear=0x7f0900bc;
public static final int loc_item_copy_bless=0x7f0900bf;
public static final int loc_item_copy_eng=0x7f0900be;
public static final int loc_search_button=0x7f09005c;
public static final int loc_search_field=0x7f09005b;
public static final int local_label=0x7f090057;
public static final int local_player_set=0x7f090063;
public static final int manual_add_button=0x7f090071;
public static final int modtime=0x7f09004a;
public static final int msg_marker=0x7f090047;
public static final int name=0x7f090072;
public static final int name_edit=0x7f09001a;
public static final int name_label=0x7f09006f;
public static final int nexthint_button=0x7f090078;
public static final int number=0x7f090073;
public static final int other_lang=0x7f09005d;
public static final int password_edit=0x7f090068;
public static final int password_set=0x7f090067;
public static final int phonies_spinner=0x7f09003f;
public static final int pick_faceup=0x7f090040;
public static final int pick_lang=0x7f090074;
public static final int pick_lang_spinner=0x7f090075;
public static final int play_button=0x7f090026;
public static final int player_list=0x7f09002c;
public static final int player_name_edit=0x7f090064;
public static final int players=0x7f090024;
public static final int players_label=0x7f09002b;
public static final int prevhint_button=0x7f090077;
public static final int private_rooms_set=0x7f090032;
public static final int progress_bar=0x7f09004e;
public static final int public_rooms_set=0x7f090035;
public static final int refresh_button=0x7f090037;
public static final int remote_check=0x7f090062;
public static final int revert_all=0x7f09006c;
public static final int revert_colors=0x7f09006b;
public static final int robot_check=0x7f090066;
public static final int role=0x7f09004c;
public static final int room_edit=0x7f090033;
public static final int room_spinner=0x7f090036;
public static final int screen=0x7f090027;
public static final int search_button=0x7f09001e;
public static final int seek_blue=0x7f090016;
public static final int seek_green=0x7f090014;
public static final int seek_red=0x7f090012;
public static final int send_button=0x7f09000f;
public static final int show_remote=0x7f09001b;
public static final int shuffle_button=0x7f090079;
public static final int slmenu_clear_sel=0x7f0900c4;
public static final int slmenu_copy_sel=0x7f0900c3;
public static final int slmenu_deselect_all=0x7f0900c2;
public static final int slmenu_lookup_sel=0x7f0900c0;
public static final int slmenu_select_all=0x7f0900c1;
public static final int smart_robot=0x7f09003e;
public static final int sms_phones=0x7f090039;
public static final int state=0x7f09004b;
public static final int summary=0x7f09005e;
public static final int inviter_check=0x7f09000d;
public static final int item_name=0x7f09006b;
public static final int item_score=0x7f09006c;
public static final int join_public_room_check=0x7f090033;
public static final int juggle_players=0x7f090030;
public static final int label=0x7f090024;
public static final int lang_separator=0x7f09002a;
public static final int lang_spinner=0x7f09002b;
public static final int loc_item_check=0x7f0900bf;
public static final int loc_item_clear=0x7f0900be;
public static final int loc_item_copy_bless=0x7f0900c1;
public static final int loc_item_copy_eng=0x7f0900c0;
public static final int loc_search_button=0x7f09005e;
public static final int loc_search_field=0x7f09005d;
public static final int local_label=0x7f090059;
public static final int local_player_set=0x7f090065;
public static final int manual_add_button=0x7f090073;
public static final int modtime=0x7f09004c;
public static final int msg_marker=0x7f090049;
public static final int name=0x7f090074;
public static final int name_edit=0x7f09001c;
public static final int name_label=0x7f090071;
public static final int nexthint_button=0x7f09007a;
public static final int nperdev_spinner=0x7f09000e;
public static final int number=0x7f090075;
public static final int other_lang=0x7f09005f;
public static final int password_edit=0x7f09006a;
public static final int password_set=0x7f090069;
public static final int phonies_spinner=0x7f090041;
public static final int pick_faceup=0x7f090042;
public static final int pick_lang=0x7f090076;
public static final int pick_lang_spinner=0x7f090077;
public static final int play_button=0x7f090028;
public static final int player_list=0x7f09002e;
public static final int player_name_edit=0x7f090066;
public static final int players=0x7f090026;
public static final int players_label=0x7f09002d;
public static final int prevhint_button=0x7f090079;
public static final int private_rooms_set=0x7f090034;
public static final int progress_bar=0x7f090050;
public static final int public_rooms_set=0x7f090037;
public static final int refresh_button=0x7f090039;
public static final int remote_check=0x7f090064;
public static final int revert_all=0x7f09006e;
public static final int revert_colors=0x7f09006d;
public static final int robot_check=0x7f090068;
public static final int role=0x7f09004e;
public static final int room_edit=0x7f090035;
public static final int room_spinner=0x7f090038;
public static final int screen=0x7f090029;
public static final int search_button=0x7f090020;
public static final int seek_blue=0x7f090018;
public static final int seek_green=0x7f090016;
public static final int seek_red=0x7f090014;
public static final int send_button=0x7f090011;
public static final int show_remote=0x7f09001d;
public static final int shuffle_button=0x7f09007b;
public static final int slmenu_clear_sel=0x7f0900c6;
public static final int slmenu_copy_sel=0x7f0900c5;
public static final int slmenu_deselect_all=0x7f0900c4;
public static final int slmenu_lookup_sel=0x7f0900c2;
public static final int slmenu_select_all=0x7f0900c3;
public static final int smart_robot=0x7f090040;
public static final int sms_phones=0x7f09003b;
public static final int state=0x7f09004d;
public static final int summary=0x7f090060;
public static final int tbar_parent_hor=0x7f090007;
public static final int tbar_parent_vert=0x7f090008;
public static final int text_item=0x7f090050;
public static final int text_item2=0x7f090051;
public static final int thumbnail=0x7f090048;
public static final int timer_minutes_edit=0x7f09003d;
public static final int timer_set=0x7f09003c;
public static final int toolbar=0x7f090076;
public static final int undo_button=0x7f09007a;
public static final int use_timer=0x7f09003b;
public static final int values_button=0x7f09007d;
public static final int text_item=0x7f090052;
public static final int text_item2=0x7f090053;
public static final int thumbnail=0x7f09004a;
public static final int timer_minutes_edit=0x7f09003f;
public static final int timer_set=0x7f09003e;
public static final int toolbar=0x7f090078;
public static final int undo_button=0x7f09007c;
public static final int use_timer=0x7f09003d;
public static final int values_button=0x7f09007f;
public static final int version_string=0x7f090000;
public static final int view_loaded=0x7f090046;
public static final int view_unloaded=0x7f090045;
public static final int word_edit=0x7f09001d;
public static final int wordlen_max=0x7f090020;
public static final int wordlen_min=0x7f09001f;
public static final int xlated_view=0x7f090059;
public static final int xlated_view_blessed=0x7f090056;
public static final int xlated_view_local=0x7f090058;
public static final int zoom_button=0x7f09007f;
public static final int view_loaded=0x7f090048;
public static final int view_unloaded=0x7f090047;
public static final int word_edit=0x7f09001f;
public static final int wordlen_max=0x7f090022;
public static final int wordlen_min=0x7f090021;
public static final int xlated_view=0x7f09005b;
public static final int xlated_view_blessed=0x7f090058;
public static final int xlated_view_local=0x7f09005a;
public static final int zoom_button=0x7f090081;
}
public static final class layout {
public static final int about_dlg=0x7f030000;
@ -1952,6 +1954,8 @@ public final class R {
device
*/
public static final int notify_vibrate=0x7f050177;
public static final int nplayers_fmt=0x7f0502ce;
public static final int nplayers_prompt=0x7f0502cd;
/** text of label identifying the field where human players can
enter an option password. The label and field disappear when
the robot player checkbox is checked because it makes no

View file

@ -1,6 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<CheckBox xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<CheckBox android:id="@+id/inviter_check"
style="@style/evenly_spaced_horizontal"
/>
<Spinner android:id="@+id/nperdev_spinner"
style="@style/evenly_spaced_horizontal"
android:prompt="@string/nplayers_prompt"
android:drawSelectorOnTop="true"
android:visibility="gone"
/>
</LinearLayout>

View file

@ -2269,4 +2269,7 @@
<string name="use_defaults">Use defaults</string>
<string name="nplayers_prompt">Number of players</string>
<string name="nplayers_fmt">%1$d player[s]</string>
</resources>

View file

@ -1929,4 +1929,6 @@
<string name="new_game_message_net">uOy( lliw evah a ecnahc ot
etivni rehto sreyalp retfa ti si detaerc.)</string>
<string name="use_defaults">Esu stluafed</string>
<string name="nplayers_prompt">Rebmun fo sreyalp</string>
<string name="nplayers_fmt">%1$d ]s[reyalp</string>
</resources>

View file

@ -1929,4 +1929,6 @@
<string name="new_game_message_net">(YOU WILL HAVE A CHANCE TO
INVITE OTHER PLAYERS AFTER IT IS CREATED.)</string>
<string name="use_defaults">USE DEFAULTS</string>
<string name="nplayers_prompt">NUMBER OF PLAYERS</string>
<string name="nplayers_fmt">%1$d PLAYER[S]</string>
</resources>

View file

@ -31,18 +31,22 @@ import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.Spinner;
import android.widget.TextView;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.Iterator;
import junit.framework.Assert;
@ -52,6 +56,7 @@ public class BTInviteDelegate extends InviteDelegate {
private Activity m_activity;
private Set<Integer> m_checked;
private Map<Integer, Integer> m_counts;
private boolean m_setChecked;
private BTDevsAdapter m_adapter;
@ -73,6 +78,7 @@ public class BTInviteDelegate extends InviteDelegate {
protected void init( Bundle savedInstanceState )
{
m_checked = new HashSet<Integer>();
m_counts = new HashMap<Integer, Integer>();
String msg = getString( R.string.bt_pick_addall_button );
msg = getString( R.string.invite_bt_desc_fmt, m_nMissing, msg );
@ -131,32 +137,49 @@ public class BTInviteDelegate extends InviteDelegate {
protected void clearSelected()
{
BTService.clearDevices( m_activity, listSelected() );
String[][] selected = new String[1][];
listSelected( selected, null );
BTService.clearDevices( m_activity, selected[0] );
}
protected String[] listSelected()
protected void listSelected( String[][] devsP, int[][] countsP )
{
ListView list = (ListView)findViewById( android.R.id.list );
String[] result = new String[m_checked.size()];
int count = list.getChildCount();
int size = m_checked.size();
String[] devs = new String[size];
int[] counts = new int[size];
int index = 0;
for ( int ii = 0; ii < count; ++ii ) {
CheckBox box = (CheckBox)list.getChildAt( ii );
if ( box.isChecked() ) {
String btAddr = m_adapter.getBTAddr( box );
String btName = m_adapter.getBTName( box );
Assert.assertTrue( box.getText().toString().equals( btName ) );
result[index++] = btAddr;
}
for ( Iterator<Integer> iter = m_checked.iterator();
iter.hasNext(); ) {
int position = iter.next();
LinearLayout layout = (LinearLayout)list.getChildAt( position );
CheckBox box = (CheckBox)layout.findViewById( R.id.inviter_check );
Assert.assertTrue( box.isChecked() );
String btAddr = m_adapter.getBTAddr( box );
String btName = m_adapter.getBTName( box );
Assert.assertTrue( box.getText().toString().equals( btName ) );
devs[index] = btAddr;
counts[index] = m_counts.get( position );
++index;
}
devsP[0] = devs;
if ( null != countsP ) {
countsP[0] = counts;
}
return result;
}
protected void tryEnable()
{
int size = m_checked.size();
m_okButton.setEnabled( size == m_nMissing );
m_clearButton.setEnabled( 0 < size );
m_clearButton.setEnabled( 0 < m_checked.size() );
int count = 0;
for ( Iterator<Integer> iter = m_checked.iterator();
iter.hasNext(); ) {
int position = iter.next();
count += m_counts.get( position );
}
m_okButton.setEnabled( 0 < count && count <= m_nMissing );
}
private class BTDevsAdapter extends XWListAdapter {
@ -174,10 +197,38 @@ public class BTInviteDelegate extends InviteDelegate {
public Object getItem( int position) { return m_devNames[position]; }
public View getView( final int position, View convertView,
ViewGroup parent ) {
CheckBox box = (CheckBox)inflate( R.layout.btinviter_item );
LinearLayout layout = (LinearLayout)inflate( R.layout.btinviter_item );
CheckBox box = (CheckBox)layout.findViewById( R.id.inviter_check );
box.setText( m_devNames[position] );
m_boxAddrs.put( box, m_devAddrs[position] );
if ( 1 < m_nMissing ) {
Spinner spinner = (Spinner)
layout.findViewById(R.id.nperdev_spinner);
ArrayAdapter<String> adapter =
new ArrayAdapter<String>( m_activity, android.R.layout
.simple_spinner_item );
for ( int ii = 1; ii <= m_nMissing; ++ii ) {
String str = getString( R.string.nplayers_fmt, ii );
adapter.add( str );
}
spinner.setAdapter( adapter );
spinner.setVisibility( View.VISIBLE );
spinner.setOnItemSelectedListener( new OnItemSelectedListener() {
public void onItemSelected( AdapterView<?> parent,
View view, int pos,
long id )
{
DbgUtils.logf( "setting count for %d to %d", position, 1 + pos );
m_counts.put( position, 1 + pos );
tryEnable();
}
public void onNothingSelected( AdapterView<?> parent ) {}
} );
m_counts.put( position, 1 );
}
CompoundButton.OnCheckedChangeListener listener =
new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged( CompoundButton buttonView,
@ -198,7 +249,7 @@ public class BTInviteDelegate extends InviteDelegate {
if ( m_setChecked ) {
box.setChecked( true );
}
return box;
return layout;
}
public String getBTAddr( CheckBox box ) { return m_boxAddrs.get(box); }

View file

@ -107,6 +107,7 @@ public class BoardDelegate extends DelegateBase
private String[] m_texts;
private CommsConnTypeSet m_connTypes = null;
private String[] m_missingDevs;
private int[] m_missingCounts;
private InviteMeans m_missingMeans = null;
private boolean m_progressShown = false;
private String m_curTiles;
@ -628,16 +629,16 @@ public class BoardDelegate extends DelegateBase
}
break;
case BT_INVITE_RESULT:
// onActivityResult is called immediately *before*
// onResume -- meaning m_gi etc are still null.
m_missingDevs = data.getStringArrayExtra( BTInviteDelegate.DEVS );
m_missingMeans = InviteMeans.BLUETOOTH;
break;
case SMS_INVITE_RESULT:
// onActivityResult is called immediately *before*
// onResume -- meaning m_gi etc are still null.
m_missingDevs = data.getStringArrayExtra( SMSInviteDelegate.DEVS );
m_missingMeans = InviteMeans.SMS;
m_missingDevs = data.getStringArrayExtra( InviteDelegate.DEVS );
m_missingCounts = data.getIntArrayExtra( InviteDelegate.COUNTS );
if ( BT_INVITE_RESULT == requestCode ) {
m_missingMeans = InviteMeans.BLUETOOTH;
} else {
m_missingMeans = InviteMeans.SMS;
}
break;
}
}
@ -2206,8 +2207,9 @@ public class BoardDelegate extends DelegateBase
m_invitesPending = m_missingDevs.length;
for ( int ii = 0; ii < m_missingDevs.length; ++ii ) {
String dev = m_missingDevs[ii];
NetLaunchInfo nli = new NetLaunchInfo( m_summary, m_gi, 1,
1 + ii );
int nPlayers = m_missingCounts[ii];
NetLaunchInfo nli = new NetLaunchInfo( m_summary, m_gi,
nPlayers, 1 + ii );
switch ( m_missingMeans ) {
case BLUETOOTH:
String progMsg = BTService.nameForAddr( dev );
@ -2230,6 +2232,7 @@ public class BoardDelegate extends DelegateBase
}
}
m_missingDevs = null;
m_missingCounts = null;
m_missingMeans = null;
}
}

View file

@ -465,7 +465,7 @@ public class GameUtils {
return makeNewMultiGame( context, sink, DBUtils.GROUPID_UNSPEC, addr,
new int[] {nli.lang}, new String[] { nli.dict },
nli.nPlayersT, 1, nli.forceChannel,
nli.nPlayersT, nli.nPlayersH, nli.forceChannel,
nli.inviteID(), nli.gameID, false );
}

View file

@ -36,6 +36,7 @@ abstract class InviteDelegate extends ListDelegateBase
implements View.OnClickListener {
public static final String DEVS = "DEVS";
public static final String COUNTS = "COUNTS";
protected static final String INTENT_KEY_NMISSING = "NMISSING";
protected int m_nMissing;
@ -73,8 +74,11 @@ abstract class InviteDelegate extends ListDelegateBase
{
if ( m_okButton == view ) {
Intent intent = new Intent();
String[] devs = listSelected();
intent.putExtra( DEVS, devs );
String[][] devs = new String[1][];
int[][] counts = new int[1][];
listSelected( devs, counts );
intent.putExtra( DEVS, devs[0] );
intent.putExtra( COUNTS, counts[0] );
setResult( Activity.RESULT_OK, intent );
finish();
} else if ( m_rescanButton == view ) {
@ -85,7 +89,7 @@ abstract class InviteDelegate extends ListDelegateBase
}
abstract void tryEnable() ;
abstract String[] listSelected();
abstract void listSelected( String[][] devsP, int[][] countsP );
abstract void scan();
abstract void clearSelected();
}

View file

@ -41,6 +41,8 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import junit.framework.Assert;
import org.eehouse.android.xw4.DlgDelegate.Action;
public class SMSInviteDelegate extends InviteDelegate {
@ -167,7 +169,7 @@ public class SMSInviteDelegate extends InviteDelegate {
showConfirmThen( R.string.confirm_clear, Action.CLEAR_ACTION );
}
protected String[] listSelected()
protected void listSelected( String[][] devsP, int[][] countsP )
{
int count = m_adapter.getCount();
String[] result = new String[countChecks()];
@ -179,7 +181,8 @@ public class SMSInviteDelegate extends InviteDelegate {
((SMSListItem)m_adapter.getItem(ii)).getNumber();
}
}
return result;
Assert.fail(); // not setting countsP
devsP[0] = result;
}
@Override

View file

@ -69,7 +69,9 @@ public class XWConnAddrPreference extends DialogPreference {
LinearLayout list = (LinearLayout)view.findViewById( R.id.conn_types );
for ( CommsConnType typ : s_supported.getTypes() ) {
CheckBox box = (CheckBox)LocUtils.inflate( m_context, R.layout.btinviter_item );
LinearLayout layout = (LinearLayout)LocUtils
.inflate( m_context, R.layout.btinviter_item );
CheckBox box = (CheckBox)layout.findViewById( R.id.inviter_check );
box.setText( typ.longName( m_context ) );
box.setChecked( m_curSet.contains( typ ) );
list.addView( box );