add naming of game to game creation, including adding custom view to alert

This commit is contained in:
Eric House 2015-02-12 07:41:28 -08:00
parent e5957866b4
commit 1a94bab9e8
7 changed files with 100 additions and 68 deletions

View file

@ -144,7 +144,7 @@ public final class R {
public static final int divider=0x7f090023;
public static final int download_button=0x7f090071;
public static final int dwnld_message=0x7f09004e;
public static final int edit=0x7f090064;
public static final int edit=0x7f090062;
public static final int edit_blue=0x7f090019;
public static final int edit_green=0x7f090017;
public static final int edit_red=0x7f090015;
@ -209,13 +209,13 @@ public final class R {
public static final int local_player_set=0x7f090066;
public static final int manual_add_button=0x7f090074;
public static final int modtime=0x7f09004b;
public static final int msg=0x7f090062;
public static final int msg=0x7f090063;
public static final int msg_marker=0x7f090048;
public static final int name=0x7f090075;
public static final int name_edit=0x7f09001c;
public static final int name_label=0x7f090072;
public static final int nexthint_button=0x7f09007b;
public static final int not_again_check=0x7f090063;
public static final int not_again_check=0x7f090064;
public static final int nperdev_spinner=0x7f09000e;
public static final int number=0x7f090076;
public static final int other_lang=0x7f09005e;
@ -310,17 +310,18 @@ public final class R {
public static final int loc_list_item=0x7f03001a;
public static final int loc_main=0x7f03001b;
public static final int lookup=0x7f03001c;
public static final int not_again_view=0x7f03001d;
public static final int passwd_view=0x7f03001e;
public static final int player_edit=0x7f03001f;
public static final int player_list_elem=0x7f030020;
public static final int prefs_w_buttons=0x7f030021;
public static final int remote_dict_details=0x7f030022;
public static final int rename_game=0x7f030023;
public static final int smsinviter=0x7f030024;
public static final int smsinviter_item=0x7f030025;
public static final int studylist=0x7f030026;
public static final int toolbar=0x7f030027;
public static final int msg_label_and_edit=0x7f03001d;
public static final int not_again_view=0x7f03001e;
public static final int passwd_view=0x7f03001f;
public static final int player_edit=0x7f030020;
public static final int player_list_elem=0x7f030021;
public static final int prefs_w_buttons=0x7f030022;
public static final int remote_dict_details=0x7f030023;
public static final int rename_game=0x7f030024;
public static final int smsinviter=0x7f030025;
public static final int smsinviter_item=0x7f030026;
public static final int studylist=0x7f030027;
public static final int toolbar=0x7f030028;
}
public static final class menu {
public static final int board_menu=0x7f080000;
@ -518,9 +519,6 @@ public final class R {
/**
*/
public static final int bt_resend_fmt=0x7f050212;
/**
*/
public static final int btname_label=0x7f050217;
/** text of button for adding new player to game
*/
public static final int button_add_player=0x7f0500c9;
@ -875,6 +873,7 @@ public final class R {
new game
*/
public static final int default_dict=0x7f05013e;
public static final int default_game_name=0x7f05021b;
/** other
*/
public static final int default_host=0x7f05006d;
@ -912,9 +911,6 @@ public final class R {
public static final int default_update_url=0x7f050077;
public static final int delete_dicts=0x7f0502b2;
/**
*/
public static final int dft_name_fmt=0x7f05021b;
/**
<string name="sms_disabled">Playing via SMS is currently disabled.
You can enable it in Settings->Network game settings.</string>
@ -1066,7 +1062,7 @@ public final class R {
public static final int gameOver=0x7f05009d;
/**
*/
public static final int game_btname_title=0x7f050219;
public static final int game_btname_title=0x7f050217;
/** used to create default names of games (when user has not
named them.)
*/
@ -1091,10 +1087,13 @@ public final class R {
public static final int game_name_group_title=0x7f05026f;
/**
*/
public static final int game_rename_title=0x7f0500b0;
public static final int game_name_label=0x7f050219;
/**
*/
public static final int game_smsname_title=0x7f05021a;
public static final int game_name_title=0x7f050218;
/**
*/
public static final int game_rename_title=0x7f0500b0;
/** Put nothing in the summary space, so it just reads "Game 2"
*/
public static final int game_summary_field_empty=0x7f05014a;
@ -1665,6 +1664,7 @@ public final class R {
/** above is inserted in this the last time I warn
*/
public static final int nag_warn_last_fmt=0x7f0502c3;
public static final int name_copy_fmt=0x7f05021a;
public static final int name_dict_fmt=0x7f050089;
public static final int nbs_port=0x7f050078;
/** text of checkbox. If this checkbox is checked, games created
@ -2293,9 +2293,6 @@ public final class R {
*/
public static final int sms_invite_title=0x7f050216;
public static final int sms_ready_text=0x7f050284;
/**
*/
public static final int smsname_label=0x7f050218;
public static final int square_tiles=0x7f050274;
public static final int square_tiles_summary=0x7f050275;
/** Used in formatting moves and history

View file

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
>
<!-- label -->
<TextView android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/game_name_label"
/>
<EditText android:id="@+id/edit"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:scrollHorizontally="true"
android:autoText="false"
android:capitalize="none"
android:textAppearance="?android:attr/textAppearanceMedium"
android:selectAllOnFocus="true"
/>
<TextView android:id="@+id/msg"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
</LinearLayout>

View file

@ -1853,16 +1853,14 @@
<!-- Title of phone number picker during invitation to a game via SMS -->
<string name="sms_invite_title">SMS Invitation</string>
<!-- -->
<string name="btname_label">New Bluetooth game name</string>
<!-- -->
<string name="smsname_label">New SMS game name</string>
<!-- -->
<string name="game_btname_title">Bluetooth game name</string>
<!-- -->
<string name="game_smsname_title">Name your game</string>
<string name="game_name_title">Name your game</string>
<!-- -->
<string name="dft_name_fmt">Game %1$X</string>
<string name="game_name_label">New game name:</string>
<string name="name_copy_fmt">%1$s copy</string>
<string name="default_game_name">New Game</string>
<!-- -->
<string name="newgame_sms_header">New SMS Game</string>
<!-- -->

View file

@ -1589,15 +1589,13 @@
<!-- Title of phone number picker during invitation to a game via SMS -->
<string name="sms_invite_title">SMS Noitativni</string>
<!-- -->
<string name="btname_label">Wen Htooteulb emag eman</string>
<!-- -->
<string name="smsname_label">Wen SMS emag eman</string>
<!-- -->
<string name="game_btname_title">Htooteulb emag eman</string>
<!-- -->
<string name="game_smsname_title">Eman ruoy emag</string>
<string name="game_name_title">Eman ruoy emag</string>
<!-- -->
<string name="dft_name_fmt">Emag %1$X</string>
<string name="game_name_label">Wen emag eman:</string>
<string name="name_copy_fmt">%1$s ypoc</string>
<string name="default_game_name">Wen Emag</string>
<!-- -->
<string name="newgame_sms_header">Wen SMS Emag</string>
<!-- -->

View file

@ -1589,15 +1589,13 @@
<!-- Title of phone number picker during invitation to a game via SMS -->
<string name="sms_invite_title">SMS INVITATION</string>
<!-- -->
<string name="btname_label">NEW BLUETOOTH GAME NAME</string>
<!-- -->
<string name="smsname_label">NEW SMS GAME NAME</string>
<!-- -->
<string name="game_btname_title">BLUETOOTH GAME NAME</string>
<!-- -->
<string name="game_smsname_title">NAME YOUR GAME</string>
<string name="game_name_title">NAME YOUR GAME</string>
<!-- -->
<string name="dft_name_fmt">GAME %1$X</string>
<string name="game_name_label">NEW GAME NAME:</string>
<string name="name_copy_fmt">%1$s COPY</string>
<string name="default_game_name">NEW GAME</string>
<!-- -->
<string name="newgame_sms_header">NEW SMS GAME</string>
<!-- -->

View file

@ -267,6 +267,11 @@ public class GameUtils {
return result;
}
public static String makeDefaultName( Context context )
{
return LocUtils.getString( context, R.string.default_game_name );
}
public static int loadMakeGame( Context context, CurGameInfo gi,
TransportProcs tp, GameLock lock )
{

View file

@ -41,6 +41,7 @@ import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.Arrays;
@ -795,24 +796,30 @@ public class GamesListDelegate extends ListDelegateBase
break;
case GAMES_LIST_NEWGAME:
LinearLayout view = (LinearLayout)
LocUtils.inflate( m_activity, R.layout.msg_label_and_edit );
final EditText edit = (EditText)view.findViewById( R.id.edit );
lstnr = new OnClickListener() {
public void onClick( DialogInterface dlg, int item ) {
makeThenLaunchOrConfigure( true );
}
};
lstnr2 = new OnClickListener() {
public void onClick( DialogInterface dlg, int item ) {
makeThenLaunchOrConfigure( false );
makeThenLaunchOrConfigure( edit, true );
}
};
dialog = makeAlertBuilder()
.setMessage( "" ) // must have a message to change it later
ab = makeAlertBuilder()
.setView( view )
.setTitle( "foo" )// ditto, but can't be empty (!)
.setIcon( R.drawable.sologame__gen ) // same for icon
.setPositiveButton( R.string.newgame_configure_first, lstnr )
.setNegativeButton( R.string.use_defaults, lstnr2 )
.create();
.setPositiveButton( R.string.newgame_configure_first, lstnr );
if ( m_nextIsSolo || 0 < XWPrefs.getAddrTypes( m_activity ).size() ) {
lstnr2 = new OnClickListener() {
public void onClick( DialogInterface dlg, int item ) {
makeThenLaunchOrConfigure( edit, false );
}
};
ab.setNegativeButton( R.string.use_defaults, lstnr2 );
}
dialog = ab.create();
break;
default:
@ -841,7 +848,10 @@ public class GamesListDelegate extends ListDelegateBase
msg += "\n\n" + getString( R.string.new_game_message_net );
}
ad.setMessage( msg );
TextView edit = (TextView)dialog.findViewById( R.id.msg );
edit.setText( msg );
edit = (TextView)dialog.findViewById( R.id.edit );
edit.setText( GameUtils.makeDefaultName( m_activity ) );
break;
}
}
@ -1564,17 +1574,7 @@ public class GamesListDelegate extends ListDelegateBase
private void handleNewGame( boolean solo )
{
m_nextIsSolo = solo;
// force config if we don't have at least one way to communicate
boolean skipDefaults = !solo;
if ( skipDefaults ) {
skipDefaults = 0 == XWPrefs.getAddrTypes( m_activity ).size();
}
if ( skipDefaults ) {
makeThenLaunchOrConfigure( true );
} else {
showDialog( DlgID.GAMES_LIST_NEWGAME );
}
showDialog( DlgID.GAMES_LIST_NEWGAME );
}
private void handleNewGameButton( boolean solo )
@ -2083,8 +2083,9 @@ public class GamesListDelegate extends ListDelegateBase
// return adapter;
}
private void makeThenLaunchOrConfigure( boolean doConfigure )
private void makeThenLaunchOrConfigure( EditText edit, boolean doConfigure )
{
String name = edit.getText().toString();
long rowID;
long groupID = DBUtils.GROUPID_UNSPEC;
if ( m_nextIsSolo ) {
@ -2096,6 +2097,8 @@ public class GamesListDelegate extends ListDelegateBase
rowID = GameUtils.makeNewMultiGame( m_activity, inviteID );
}
DBUtils.setName( m_activity, rowID, name );
if ( doConfigure ) {
// configure it
GameConfigDelegate.editForResult( m_activity, CONFIG_GAME, rowID );