Merge branch 'android_branch' into android_invite

Conflicts:
	xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java
This commit is contained in:
Andy2 2011-07-19 18:34:39 -07:00
commit 785a64123f
8 changed files with 315 additions and 221 deletions

View file

@ -11,28 +11,32 @@
android:summary="@string/prefs_names_summary"
>
<EditTextPreference android:key="@string/key_player1_name"
android:title="@string/pref_player1_name"
android:defaultValue=""
/>
<EditTextPreference android:key="@string/key_player2_name"
android:title="@string/pref_player2_name"
android:defaultValue="ignored"
android:summary="@string/tell_unused"
android:enabled="false"
/>
<EditTextPreference android:key="@string/key_player3_name"
android:title="@string/pref_player3_name"
android:defaultValue=""
android:summary="@string/tell_unused"
android:enabled="false"
/>
<EditTextPreference android:key="@string/key_player4_name"
android:title="@string/pref_player4_name"
android:defaultValue=""
android:summary="@string/tell_unused"
android:enabled="false"
/>
<org.eehouse.android.xw4.XWEditTextPreference
android:key="@string/key_player1_name"
android:title="@string/pref_player1_name"
android:defaultValue=""
/>
<org.eehouse.android.xw4.XWEditTextPreference
android:key="@string/key_player2_name"
android:title="@string/pref_player2_name"
android:defaultValue="ignored"
android:summary="@string/tell_unused"
android:enabled="false"
/>
<org.eehouse.android.xw4.XWEditTextPreference
android:key="@string/key_player3_name"
android:title="@string/pref_player3_name"
android:defaultValue=""
android:summary="@string/tell_unused"
android:enabled="false"
/>
<org.eehouse.android.xw4.XWEditTextPreference
android:key="@string/key_player4_name"
android:title="@string/pref_player4_name"
android:defaultValue=""
android:summary="@string/tell_unused"
android:enabled="false"
/>
</PreferenceScreen>
<PreferenceScreen android:title="@string/prefs_dicts"
@ -63,30 +67,33 @@
android:defaultValue="false"
/>
<ListPreference android:key="@string/key_default_phonies"
android:title="@string/default_phonies"
android:entries="@array/phony_names"
android:entryValues="@array/phony_names"
android:defaultValue="@string/phonies_warn"
/>
<org.eehouse.android.xw4.XWListPreference
android:key="@string/key_default_phonies"
android:title="@string/default_phonies"
android:entries="@array/phony_names"
android:entryValues="@array/phony_names"
android:defaultValue="@string/phonies_warn"
/>
<CheckBoxPreference android:key="@string/key_default_timerenabled"
android:title="@string/use_timer"
android:defaultValue="false"
/>
<EditTextPreference android:key="@string/key_initial_player_minutes"
android:title="@string/initial_player_minutes"
android:defaultValue="25"
android:numeric="decimal"
/>
<org.eehouse.android.xw4.XWEditTextPreference
android:key="@string/key_initial_player_minutes"
android:title="@string/initial_player_minutes"
android:defaultValue="25"
android:numeric="decimal"
/>
<ListPreference android:key="@string/key_board_size"
android:title="@string/board_size"
android:entries="@array/board_sizes"
android:entryValues="@array/board_sizes"
android:defaultValue="15x15"
/>
<org.eehouse.android.xw4.XWListPreference
android:key="@string/key_board_size"
android:title="@string/board_size"
android:entries="@array/board_sizes"
android:entryValues="@array/board_sizes"
android:defaultValue="15x15"
/>
</PreferenceScreen>
@ -94,97 +101,97 @@
android:summary="@string/prefs_appearance_summary"
>
<!-- <CheckBoxPreference android:key="@string/key_color_tiles" -->
<!-- android:title="@string/color_tiles" -->
<!-- android:summary="@string/color_tiles_summary" -->
<!-- android:defaultValue="true" -->
<!-- /> -->
<CheckBoxPreference android:key="@string/key_hide_intro"
android:title="@string/hide_intro"
android:summary="@string/hide_intro_summary"
android:defaultValue="false"
/>
<CheckBoxPreference android:key="@string/key_hide_title"
android:title="@string/hide_title"
android:summary="@string/hide_title_summary"
android:defaultValue="true"
/>
<CheckBoxPreference android:key="@string/key_show_arrow"
android:title="@string/show_arrow"
android:summary="@string/show_arrow_summary"
android:defaultValue="true"
/>
<CheckBoxPreference android:key="@string/key_keep_screenon"
android:title="@string/keep_screenon"
android:summary="@string/keep_screenon_summary"
android:defaultValue="false"
/>
<!-- android:title="@string/color_tiles" -->
<!-- android:summary="@string/color_tiles_summary" -->
<!-- android:defaultValue="true" -->
<!-- /> -->
<CheckBoxPreference android:key="@string/key_hide_intro"
android:title="@string/hide_intro"
android:summary="@string/hide_intro_summary"
android:defaultValue="false"
/>
<CheckBoxPreference android:key="@string/key_hide_title"
android:title="@string/hide_title"
android:summary="@string/hide_title_summary"
android:defaultValue="true"
/>
<CheckBoxPreference android:key="@string/key_show_arrow"
android:title="@string/show_arrow"
android:summary="@string/show_arrow_summary"
android:defaultValue="true"
/>
<CheckBoxPreference android:key="@string/key_keep_screenon"
android:title="@string/keep_screenon"
android:summary="@string/keep_screenon_summary"
android:defaultValue="false"
/>
<PreferenceScreen android:title="@string/prefs_colors"
android:summary="@string/prefs_colors_summary"
>
<org.eehouse.android.xw4.EditColorPreference
android:key="@string/key_player0"
android:title="@string/player0"
android:defaultValue="0x000000"
/>
<org.eehouse.android.xw4.EditColorPreference
android:key="@string/key_player1"
android:title="@string/player1"
android:defaultValue="0xFF0000"
/>
<org.eehouse.android.xw4.EditColorPreference
android:key="@string/key_player2"
android:title="@string/player2"
android:defaultValue="0x0000FF"
/>
<org.eehouse.android.xw4.EditColorPreference
android:key="@string/key_player3"
android:title="@string/player3"
android:defaultValue="0x008F00"
/>
<org.eehouse.android.xw4.EditColorPreference
android:key="@string/key_bonus_l2x"
android:title="@string/bonus_l2x"
android:defaultValue="0xAFAF00"
/>
<org.eehouse.android.xw4.EditColorPreference
android:key="@string/key_bonus_l3x"
android:title="@string/bonus_l3x"
android:defaultValue="0x00AFAF"
/>
<org.eehouse.android.xw4.EditColorPreference
android:key="@string/key_bonus_w2x"
android:title="@string/bonus_w2x"
android:defaultValue="0xAF00AF"
/>
<org.eehouse.android.xw4.EditColorPreference
android:key="@string/key_bonus_w3x"
android:title="@string/bonus_w3x"
android:defaultValue="0xAFAFAF"
/>
<PreferenceScreen android:title="@string/prefs_colors"
android:summary="@string/prefs_colors_summary"
>
<org.eehouse.android.xw4.EditColorPreference
android:key="@string/key_player0"
android:title="@string/player0"
android:defaultValue="0x000000"
/>
<org.eehouse.android.xw4.EditColorPreference
android:key="@string/key_player1"
android:title="@string/player1"
android:defaultValue="0xFF0000"
/>
<org.eehouse.android.xw4.EditColorPreference
android:key="@string/key_player2"
android:title="@string/player2"
android:defaultValue="0x0000FF"
/>
<org.eehouse.android.xw4.EditColorPreference
android:key="@string/key_player3"
android:title="@string/player3"
android:defaultValue="0x008F00"
/>
<org.eehouse.android.xw4.EditColorPreference
android:key="@string/key_bonus_l2x"
android:title="@string/bonus_l2x"
android:defaultValue="0xAFAF00"
/>
<org.eehouse.android.xw4.EditColorPreference
android:key="@string/key_bonus_l3x"
android:title="@string/bonus_l3x"
android:defaultValue="0x00AFAF"
/>
<org.eehouse.android.xw4.EditColorPreference
android:key="@string/key_bonus_w2x"
android:title="@string/bonus_w2x"
android:defaultValue="0xAF00AF"
/>
<org.eehouse.android.xw4.EditColorPreference
android:key="@string/key_bonus_w3x"
android:title="@string/bonus_w3x"
android:defaultValue="0xAFAFAF"
/>
<org.eehouse.android.xw4.EditColorPreference
android:key="@string/key_clr_crosshairs"
android:title="@string/clr_crosshairs"
android:defaultValue="0x7070FF"
/>
<org.eehouse.android.xw4.EditColorPreference
android:key="@string/key_tile_back"
android:title="@string/tile_back"
android:defaultValue="0xFFFF99"
/>
<org.eehouse.android.xw4.EditColorPreference
android:key="@string/key_empty"
android:title="@string/empty"
android:defaultValue="0xFFFFFF"
/>
<org.eehouse.android.xw4.EditColorPreference
android:key="@string/key_clr_crosshairs"
android:title="@string/clr_crosshairs"
android:defaultValue="0x7070FF"
/>
<org.eehouse.android.xw4.EditColorPreference
android:key="@string/key_tile_back"
android:title="@string/tile_back"
android:defaultValue="0xFFFF99"
/>
<org.eehouse.android.xw4.EditColorPreference
android:key="@string/key_empty"
android:title="@string/empty"
android:defaultValue="0xFFFFFF"
/>
<org.eehouse.android.xw4.EditColorPreference
android:key="@string/key_background"
android:title="@string/background"
android:defaultValue="0xFFFFFF"
/>
</PreferenceScreen>
<org.eehouse.android.xw4.EditColorPreference
android:key="@string/key_background"
android:title="@string/background"
android:defaultValue="0xFFFFFF"
/>
</PreferenceScreen>
</PreferenceScreen>
@ -244,42 +251,42 @@
<PreferenceScreen android:title="@string/advanced"
android:summary="@string/advanced_summary"
>
<EditTextPreference android:key="@string/key_relay_host"
android:title="@string/relay_host"
android:defaultValue="@string/default_host"
/>
<EditTextPreference android:key="@string/key_relay_port"
android:title="@string/relay_port"
android:defaultValue="10997"
android:numeric="decimal"
/>
<EditTextPreference android:key="@string/key_proxy_port"
android:title="@string/proxy_port"
android:defaultValue="10998"
android:numeric="decimal"
/>
<EditTextPreference android:key="@string/key_redir_host"
android:title="@string/redir_host"
android:defaultValue="@string/default_host"
/>
<org.eehouse.android.xw4.XWEditTextPreference
android:key="@string/key_relay_host"
android:title="@string/relay_host"
android:defaultValue="@string/default_host"
/>
<org.eehouse.android.xw4.XWEditTextPreference
android:key="@string/key_relay_port"
android:title="@string/relay_port"
android:defaultValue="10997"
android:numeric="decimal"
/>
<org.eehouse.android.xw4.XWEditTextPreference
android:key="@string/key_proxy_port"
android:title="@string/proxy_port"
android:defaultValue="10998"
android:numeric="decimal"
/>
<org.eehouse.android.xw4.XWEditTextPreference
android:key="@string/key_redir_host"
android:title="@string/redir_host"
android:defaultValue="@string/default_host"
/>
<!-- <EditTextPreference android:key="@string/key_sms_port" -->
<!-- android:title="@string/sms_port" -->
<!-- android:defaultValue="5432" -->
<!-- android:numeric="decimal" -->
<!-- /> -->
<EditTextPreference android:key="@string/key_dict_host"
android:title="@string/dict_host"
android:defaultValue="@string/dict_url"
/>
<org.eehouse.android.xw4.XWEditTextPreference
android:key="@string/key_dict_host"
android:title="@string/dict_host"
android:defaultValue="@string/dict_url"
/>
<CheckBoxPreference android:key="@string/key_logging_on"
android:title="@string/logging_on"
android:defaultValue="false"
/>
<EditTextPreference android:title="@string/git_rev_title"
android:summary="@string/git_rev_gen"
android:enabled="false"
/>
<CheckBoxPreference android:key="@string/key_logging_on"
android:title="@string/logging_on"
android:defaultValue="false"
/>
<EditTextPreference android:title="@string/git_rev_title"
android:summary="@string/git_rev_gen"
android:enabled="false"
/>
</PreferenceScreen>
</PreferenceScreen>

View file

@ -77,7 +77,7 @@ public class BoardActivity extends XWActivity
private GameUtils.GameLock m_gameLock;
private CurGameInfo m_gi;
CommsTransport m_xport;
private Handler m_handler;
private Handler m_handler = null;
private TimerRunnable[] m_timers;
private Runnable m_screenTimer;
private String m_name;
@ -324,7 +324,6 @@ public class BoardActivity extends XWActivity
m_utils = new BoardUtilCtxt();
m_jniu = JNIUtilsImpl.get();
setContentView( R.layout.board );
m_handler = new Handler();
m_timers = new TimerRunnable[4]; // needs to be in sync with
// XWTimerReason
m_gi = new CurGameInfo( this );
@ -343,6 +342,7 @@ public class BoardActivity extends XWActivity
@Override
protected void onPause()
{
m_handler = null;
waitCloseGame( true );
super.onPause();
}
@ -351,6 +351,7 @@ public class BoardActivity extends XWActivity
protected void onResume()
{
super.onResume();
m_handler = new Handler();
setKeepScreenOn();
loadGame();
}
@ -558,7 +559,7 @@ public class BoardActivity extends XWActivity
public void tpmRelayConnd( final String room, final int devOrder,
final boolean allHere, final int nMissing )
{
m_handler.post( new Runnable() {
post( new Runnable() {
public void run() {
handleConndMessage( room, devOrder, allHere, nMissing );
}
@ -612,7 +613,7 @@ public class BoardActivity extends XWActivity
} else if ( dlgID >= 0 ) {
final int strIDf = strID;
final int dlgIDf = dlgID;
m_handler.post( new Runnable() {
post( new Runnable() {
public void run() {
m_dlgBytes = getString( strIDf );
m_dlgTitle = R.string.relay_alert;
@ -762,7 +763,7 @@ public class BoardActivity extends XWActivity
public void requestTime()
{
m_handler.post( new Runnable() {
post( new Runnable() {
public void run() {
if ( null != m_jniThread ) {
m_jniThread.handle( JNIThread.JNICmd.CMD_DO, false );
@ -795,7 +796,7 @@ public class BoardActivity extends XWActivity
public void setTimer( int why, int when, int handle )
{
if ( null != m_timers[why] ) {
m_handler.removeCallbacks( m_timers[why] );
removeCallbacks( m_timers[why] );
}
m_timers[why] = new TimerRunnable( why, when, handle );
@ -811,13 +812,13 @@ public class BoardActivity extends XWActivity
default:
inHowLong = 500;
}
m_handler.postDelayed( m_timers[why], inHowLong );
postDelayed( m_timers[why], inHowLong );
}
public void clearTimer( int why )
{
if ( null != m_timers[why] ) {
m_handler.removeCallbacks( m_timers[why] );
removeCallbacks( m_timers[why] );
m_timers[why] = null;
}
}
@ -852,7 +853,7 @@ public class BoardActivity extends XWActivity
public void turnChanged()
{
m_handler.post( new Runnable() {
post( new Runnable() {
public void run() {
showNotAgainDlgThen( R.string.not_again_turnchanged,
R.string.key_notagain_turnchanged,
@ -870,7 +871,7 @@ public class BoardActivity extends XWActivity
public void engineStarting( int nBlanks )
{
if ( nBlanks > 0 ) {
m_handler.post( new Runnable() {
post( new Runnable() {
// Need to keep this from running after activity dies!!
public void run() {
if ( m_isVisible ) {
@ -888,7 +889,7 @@ public class BoardActivity extends XWActivity
public void engineStopping()
{
m_handler.post( new Runnable() {
post( new Runnable() {
public void run() {
if ( null != m_progress ) {
m_progress.cancel();
@ -1037,7 +1038,7 @@ public class BoardActivity extends XWActivity
// chat-messages.
public void showChat( final String msg )
{
m_handler.post( new Runnable() {
post( new Runnable() {
public void run() {
DBUtils.appendChatHistory( BoardActivity.this,
m_name, msg, false );
@ -1235,7 +1236,7 @@ public class BoardActivity extends XWActivity
} else {
setBlockingThread();
m_handler.post( new Runnable() {
post( new Runnable() {
public void run() {
showDialog( dlgID ); // crash
m_blockingDlgPosted = true;
@ -1273,7 +1274,7 @@ public class BoardActivity extends XWActivity
}
m_dlgBytes = txt;
m_handler.post( new Runnable() {
post( new Runnable() {
public void run() {
showDialog( dlgID );
}
@ -1367,9 +1368,36 @@ public class BoardActivity extends XWActivity
}
};
}
m_handler.removeCallbacks( m_screenTimer ); // needed?
m_handler.postDelayed( m_screenTimer, SCREEN_ON_TIME );
removeCallbacks( m_screenTimer ); // needed?
postDelayed( m_screenTimer, SCREEN_ON_TIME );
}
}
private void post( Runnable runnable )
{
if ( null != m_handler ) {
m_handler.post( runnable );
} else {
Utils.logf( "post: dropping because handler null" );
}
}
private void postDelayed( Runnable runnable, int when )
{
if ( null != m_handler ) {
m_handler.postDelayed( runnable, when );
} else {
Utils.logf( "postDelayed: dropping %d because handler null", when );
}
}
private void removeCallbacks( Runnable which )
{
if ( null != m_handler ) {
m_handler.removeCallbacks( which );
} else {
Utils.logf( "removeCallbacks: dropping %h because handler null",
which );
}
}
} // class BoardActivity

View file

@ -26,7 +26,7 @@ import android.util.AttributeSet;
import junit.framework.Assert;
public class DictListPreference extends ListPreference {
public class DictListPreference extends XWListPreference {
public DictListPreference( Context context, AttributeSet attrs )
{

View file

@ -39,7 +39,6 @@ public class PrefsActivity extends PreferenceActivity
private static final int REVERT_COLORS = 1;
private static final int REVERT_ALL = 2;
private HashSet<String> m_keys;
private String m_keyEmpty;
private String m_keyLogging;
@ -114,31 +113,6 @@ public class PrefsActivity extends PreferenceActivity
// Load the preferences from an XML resource
addPreferencesFromResource( R.xml.xwprefs );
int[] textKeyIds = { R.string.key_relay_host,
R.string.key_redir_host,
R.string.key_relay_port,
R.string.key_proxy_port,
R.string.key_dict_host,
R.string.key_board_size,
R.string.key_initial_player_minutes,
R.string.key_default_dict,
R.string.key_default_robodict,
R.string.key_default_phonies,
R.string.key_player1_name,
R.string.key_player2_name,
R.string.key_player3_name,
R.string.key_player4_name,
};
SharedPreferences sp
= PreferenceManager.getDefaultSharedPreferences( this );
m_keys = new HashSet<String>( textKeyIds.length );
for ( int ii = 0; ii < textKeyIds.length; ++ii ) {
int id = textKeyIds[ii];
String key = getString( id );
setSummary( sp, key );
m_keys.add( key );
}
m_keyEmpty = getString( R.string.key_empty );
m_keyLogging = getString( R.string.key_logging_on );
}
@ -161,9 +135,6 @@ public class PrefsActivity extends PreferenceActivity
public void onSharedPreferenceChanged( SharedPreferences sp, String key )
{
if ( m_keys.contains( key ) ) {
setSummary( sp, key );
}
if ( key.equals( m_keyLogging ) ) {
Utils.logEnable( sp.getBoolean( key, false ) );
}
@ -197,18 +168,6 @@ public class PrefsActivity extends PreferenceActivity
return handled;
}
private void setSummary( SharedPreferences sp, String key )
{
Preference pref = getPreferenceScreen().findPreference( key );
String value = sp.getString( key, "" );
// if ( pref instanceof android.preference.ListPreference ) {
// Utils.logf( "%s: want to do lookup of user string here",
// key );
// }
pref.setSummary( value );
}
private void relaunch()
{
PreferenceManager.setDefaultValues( this, R.xml.xwprefs,

View file

@ -34,7 +34,7 @@ public class XWApp extends Application {
public void onCreate()
{
Utils.logEnable( this );
Utils.logf( "XWApp.onCreate()" );
Utils.logf( "XWApp.onCreate(); svn_rev=%s", getString(R.string.git_rev_gen) );
super.onCreate();
}

View file

@ -0,0 +1,48 @@
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
/*
* Copyright 2010 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.preference.EditTextPreference;
import android.content.Context;
import android.util.AttributeSet;
import junit.framework.Assert;
public class XWEditTextPreference extends EditTextPreference {
public XWEditTextPreference( Context context, AttributeSet attrs )
{
super( context, attrs );
}
protected void onAttachedToActivity()
{
super.onAttachedToActivity();
setSummary( getPersistedString( "" ) );
}
protected boolean persistString( String value )
{
setSummary( value );
return super.persistString( value );
}
}

View file

@ -0,0 +1,47 @@
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
/*
* Copyright 2010 - 2011 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.preference.ListPreference;
import android.content.Context;
import android.util.AttributeSet;
import junit.framework.Assert;
public class XWListPreference extends ListPreference {
public XWListPreference( Context context, AttributeSet attrs )
{
super( context, attrs );
}
protected void onAttachedToActivity()
{
super.onAttachedToActivity();
setSummary( getPersistedString( "" ) );
}
protected boolean persistString( String value )
{
setSummary( value );
return super.persistString( value );
}
}

View file

@ -271,7 +271,12 @@ public class JNIThread extends Thread {
if ( nextSame( JNICmd.CMD_SAVE ) ) {
continue;
}
// If server has any work to do, e.g. clean up after
// showing a remote- or robot-moved dialog, let it do
// so before saving state. In some cases it'll
// otherwise drop the move.
XwJNI.server_do( m_jniGamePtr );
XwJNI.game_getGi( m_jniGamePtr, m_gi );
GameSummary summary = new GameSummary( m_gi );
XwJNI.game_summarize( m_jniGamePtr, summary );