From 8816e590f2215004036fd46fe22fe4898cc25ea1 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Mon, 14 Oct 2013 19:01:51 -0700
Subject: [PATCH 001/240] copy gmail app's selection color
---
xwords4/android/XWords4/src/org/eehouse/android/xw4/XWApp.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWApp.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWApp.java
index aa8c20eaa..7d046bd29 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWApp.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWApp.java
@@ -43,7 +43,7 @@ public class XWApp extends Application {
public static final String SMS_PUBLIC_HEADER = "-XW4";
public static final int MAX_TRAY_TILES = 7; // comtypes.h
- public static final int SEL_COLOR = Color.argb( 255, 127, 127, 255 );
+ public static final int SEL_COLOR = Color.argb( 0xFF, 0xCF, 0XE9, 0XF3 );
private static UUID s_UUID = null;
private static Boolean s_onEmulator = null;
From c2605344e0b8fba0be34455ec39668de2c401d40 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Tue, 15 Oct 2013 07:33:24 -0700
Subject: [PATCH 002/240] remove padding that was causing redraw after
unselected
---
xwords4/android/XWords4/res/layout/game_list_item.xml | 3 ---
1 file changed, 3 deletions(-)
diff --git a/xwords4/android/XWords4/res/layout/game_list_item.xml b/xwords4/android/XWords4/res/layout/game_list_item.xml
index 056db650d..fafdd705a 100644
--- a/xwords4/android/XWords4/res/layout/game_list_item.xml
+++ b/xwords4/android/XWords4/res/layout/game_list_item.xml
@@ -1,7 +1,6 @@
-
From 4af68196a665f12f64fa84995dfacfdaed2e6fef Mon Sep 17 00:00:00 2001
From: Eric House
Date: Tue, 15 Oct 2013 07:37:31 -0700
Subject: [PATCH 003/240] use same icon for both add menuitems
---
xwords4/android/XWords4/res/menu/games_list_menu.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/xwords4/android/XWords4/res/menu/games_list_menu.xml b/xwords4/android/XWords4/res/menu/games_list_menu.xml
index ab8d25f22..69f78fb5c 100644
--- a/xwords4/android/XWords4/res/menu/games_list_menu.xml
+++ b/xwords4/android/XWords4/res/menu/games_list_menu.xml
@@ -8,7 +8,7 @@
/>
Date: Tue, 15 Oct 2013 18:44:10 -0700
Subject: [PATCH 004/240] new newbie message (not yet used)
---
xwords4/android/XWords4/res/values/common_rsrc.xml | 1 +
xwords4/android/XWords4/res/values/strings.xml | 5 +++++
2 files changed, 6 insertions(+)
diff --git a/xwords4/android/XWords4/res/values/common_rsrc.xml b/xwords4/android/XWords4/res/values/common_rsrc.xml
index 59c42355f..636b10376 100644
--- a/xwords4/android/XWords4/res/values/common_rsrc.xml
+++ b/xwords4/android/XWords4/res/values/common_rsrc.xml
@@ -80,6 +80,7 @@
key_udp_intervalkey_notagain_sync
+ key_notagain_newselectkey_notagain_chatkey_notagain_relaykey_notagain_hintprev
diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml
index 322fdbdb1..df7ce966e 100644
--- a/xwords4/android/XWords4/res/values/strings.xml
+++ b/xwords4/android/XWords4/res/values/strings.xml
@@ -2174,4 +2174,9 @@
Wordlist browserMessage from relay
+
+ Tapping a game opens it.\n\nYou
+ can instead tap the icon at the left to select or deselect games,
+ then act on selected games, e.g. to delete them, using the menu or
+ \"Actionbar.\"
From 2ec0a7ba8d406c7028d3cc444e42229f9cd2dbb2 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Tue, 15 Oct 2013 18:48:02 -0700
Subject: [PATCH 005/240] new param to interface to allow passing closure to
delayed dialog handling. Unused, so no behavior change yet.
---
.../org/eehouse/android/xw4/BoardActivity.java | 6 +++---
.../eehouse/android/xw4/DictBrowseActivity.java | 2 +-
.../org/eehouse/android/xw4/DictsActivity.java | 2 +-
.../src/org/eehouse/android/xw4/DlgDelegate.java | 15 +++++++++------
.../src/org/eehouse/android/xw4/DlgState.java | 1 +
.../src/org/eehouse/android/xw4/GameConfig.java | 2 +-
.../src/org/eehouse/android/xw4/GamesList.java | 2 +-
.../org/eehouse/android/xw4/NewGameActivity.java | 2 +-
.../eehouse/android/xw4/SMSInviteActivity.java | 2 +-
.../src/org/eehouse/android/xw4/XWActivity.java | 2 +-
.../android/xw4/XWExpandableListActivity.java | 2 +-
.../org/eehouse/android/xw4/XWListActivity.java | 2 +-
12 files changed, 22 insertions(+), 18 deletions(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java
index d1cbd979a..24ba752d4 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java
@@ -785,7 +785,7 @@ public class BoardActivity extends XWActivity
showNotAgainDlgThen( R.string.not_again_done,
R.string.key_notagain_done, COMMIT_ACTION );
} else {
- dlgButtonClicked( COMMIT_ACTION, AlertDialog.BUTTON_POSITIVE );
+ dlgButtonClicked( COMMIT_ACTION, AlertDialog.BUTTON_POSITIVE, null );
}
break;
@@ -891,7 +891,7 @@ public class BoardActivity extends XWActivity
// DlgDelegate.DlgClickNotify interface
//////////////////////////////////////////////////
@Override
- public void dlgButtonClicked( int id, int which )
+ public void dlgButtonClicked( int id, int which, Object[] params )
{
if ( LAUNCH_INVITE_ACTION == id ) {
if ( DlgDelegate.DISMISS_BUTTON != which ) {
@@ -1302,7 +1302,7 @@ public class BoardActivity extends XWActivity
m_toastStr = toastStr;
if ( naMsg == 0 ) {
dlgButtonClicked( SHOW_EXPL_ACTION,
- AlertDialog.BUTTON_POSITIVE );
+ AlertDialog.BUTTON_POSITIVE, null );
} else {
showNotAgainDlgThen( naMsg, naKey, SHOW_EXPL_ACTION );
}
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictBrowseActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictBrowseActivity.java
index 8ede3dbd3..e982d6271 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictBrowseActivity.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictBrowseActivity.java
@@ -301,7 +301,7 @@ public class DictBrowseActivity extends XWListActivity
// DlgDelegate.DlgClickNotify interface
//////////////////////////////////////////////////
@Override
- public void dlgButtonClicked( int id, int which )
+ public void dlgButtonClicked( int id, int which, Object[] params )
{
Assert.assertTrue( FINISH_ACTION == id );
finish();
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsActivity.java
index cb931e8d4..d26ad7a4c 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsActivity.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsActivity.java
@@ -644,7 +644,7 @@ public class DictsActivity extends XWExpandableListActivity
}
// DlgDelegate.DlgClickNotify interface
- public void dlgButtonClicked( int id, int which )
+ public void dlgButtonClicked( int id, int which, Object[] params )
{
switch( id ) {
case DELETE_DICT_ACTION:
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java
index aaff02f2d..69be7993a 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java
@@ -56,7 +56,7 @@ public class DlgDelegate {
private static final String STATE_KEYF = "STATE_%d";
public interface DlgClickNotify {
- void dlgButtonClicked( int id, int button );
+ void dlgButtonClicked( int id, int button, Object[] params );
}
private Activity m_activity;
@@ -164,7 +164,8 @@ public class DlgDelegate {
// dialog
if ( SKIP_CALLBACK != callbackID ) {
m_clickCallback.dlgButtonClicked( callbackID,
- AlertDialog.BUTTON_POSITIVE );
+ AlertDialog.BUTTON_POSITIVE,
+ null );
}
} else {
String msg = m_activity.getString( msgID );
@@ -202,7 +203,7 @@ public class DlgDelegate {
} else {
post( new Runnable() {
public void run() {
- m_clickCallback.dlgButtonClicked( callbackID, EMAIL_BTN );
+ m_clickCallback.dlgButtonClicked( callbackID, EMAIL_BTN, null );
}
});
}
@@ -345,7 +346,7 @@ public class DlgDelegate {
if ( SKIP_CALLBACK != state.m_cbckID ) {
m_clickCallback.
dlgButtonClicked( state.m_cbckID,
- AlertDialog.BUTTON_POSITIVE );
+ AlertDialog.BUTTON_POSITIVE, null );
}
}
};
@@ -411,7 +412,8 @@ public class DlgDelegate {
public void onClick( DialogInterface dlg, int button ) {
if ( SKIP_CALLBACK != state.m_cbckID ) {
m_clickCallback.dlgButtonClicked( state.m_cbckID,
- button );
+ button,
+ state.m_params );
}
}
};
@@ -428,7 +430,8 @@ public class DlgDelegate {
dropState( state );
if ( SKIP_CALLBACK != state.m_cbckID ) {
m_clickCallback.dlgButtonClicked( state.m_cbckID,
- DISMISS_BUTTON );
+ DISMISS_BUTTON,
+ state.m_params );
}
m_activity.removeDialog( id );
}
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgState.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgState.java
index c4f14648f..b0c6dfbf9 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgState.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgState.java
@@ -29,6 +29,7 @@ public class DlgState implements Parcelable {
public int m_posButton;
public int m_cbckID = 0;
public int m_prefsKey;
+ public Object[] m_params;
public DlgState( int id, String msg, int cbckID )
{
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfig.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfig.java
index c35139e61..58bf16be4 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfig.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfig.java
@@ -600,7 +600,7 @@ public class GameConfig extends XWActivity
}
@Override
- public void dlgButtonClicked( int id, int button )
+ public void dlgButtonClicked( int id, int button, Object[] params )
{
switch( id ) {
case LOCKED_CHANGE_ACTION:
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
index 0c06c746b..0c7d27eab 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
@@ -552,7 +552,7 @@ public class GamesList extends XWExpandableListActivity
// DlgDelegate.DlgClickNotify interface
@Override
- public void dlgButtonClicked( int id, int which )
+ public void dlgButtonClicked( int id, int which, Object[] params )
{
if ( AlertDialog.BUTTON_POSITIVE == which ) {
switch( id ) {
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameActivity.java
index d1b90148a..6ed4e6b3a 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameActivity.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameActivity.java
@@ -149,7 +149,7 @@ public class NewGameActivity extends XWActivity {
// DlgDelegate.DlgClickNotify interface
@Override
- public void dlgButtonClicked( int id, int which )
+ public void dlgButtonClicked( int id, int which, Object[] params )
{
switch( id ) {
case NEW_GAME_ACTION:
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSInviteActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSInviteActivity.java
index 36d1619f7..b15e75e5b 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSInviteActivity.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSInviteActivity.java
@@ -190,7 +190,7 @@ public class SMSInviteActivity extends InviteActivity {
// DlgDelegate.DlgClickNotify interface
@Override
- public void dlgButtonClicked( int id, int which )
+ public void dlgButtonClicked( int id, int which, Object[] params )
{
switch( which ) {
case AlertDialog.BUTTON_POSITIVE:
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWActivity.java
index 358cfa50b..c176454a7 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWActivity.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWActivity.java
@@ -178,7 +178,7 @@ public class XWActivity extends Activity
}
// DlgDelegate.DlgClickNotify interface
- public void dlgButtonClicked( int id, int which )
+ public void dlgButtonClicked( int id, int which, Object[] params )
{
Assert.fail();
}
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWExpandableListActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWExpandableListActivity.java
index 26138c66f..3d8ed8ef0 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWExpandableListActivity.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWExpandableListActivity.java
@@ -127,7 +127,7 @@ public class XWExpandableListActivity extends ExpandableListActivity
}
// DlgDelegate.DlgClickNotify interface
- public void dlgButtonClicked( int id, int which )
+ public void dlgButtonClicked( int id, int which, Object[] params )
{
Assert.fail();
}
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWListActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWListActivity.java
index e93f3f926..3e54da2fd 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWListActivity.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWListActivity.java
@@ -163,7 +163,7 @@ public class XWListActivity extends ListActivity
}
// DlgDelegate.DlgClickNotify interface
- public void dlgButtonClicked( int id, int which )
+ public void dlgButtonClicked( int id, int which, Object[] params )
{
Assert.fail();
}
From 4bc554bc4065922cf28af89eee0b44a7ea88cb6b Mon Sep 17 00:00:00 2001
From: Eric House
Date: Tue, 15 Oct 2013 19:04:58 -0700
Subject: [PATCH 006/240] use new params-passing DlgDelegate to add hint about
new selecting feature.
---
.../android/XWords4/res/values/strings.xml | 2 +-
.../org/eehouse/android/xw4/DlgDelegate.java | 13 +++--
.../src/org/eehouse/android/xw4/DlgState.java | 7 +++
.../org/eehouse/android/xw4/GamesList.java | 49 ++++++++++++-------
.../android/xw4/XWExpandableListActivity.java | 6 +++
5 files changed, 56 insertions(+), 21 deletions(-)
diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml
index df7ce966e..e4c2a4586 100644
--- a/xwords4/android/XWords4/res/values/strings.xml
+++ b/xwords4/android/XWords4/res/values/strings.xml
@@ -2176,7 +2176,7 @@
Message from relayTapping a game opens it.\n\nYou
- can instead tap the icon at the left to select or deselect games,
+ can instead tap the icons at the left to select or deselect games,
then act on selected games, e.g. to delete them, using the menu or
\"Actionbar.\"
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java
index 69be7993a..5854d8602 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java
@@ -157,7 +157,7 @@ public class DlgDelegate {
}
public void showNotAgainDlgThen( int msgID, int prefsKey,
- int callbackID )
+ int callbackID, Object[] params )
{
if ( XWPrefs.getPrefsBoolean( m_activity, prefsKey, false ) ) {
// If it's set, do the action without bothering with the
@@ -165,17 +165,24 @@ public class DlgDelegate {
if ( SKIP_CALLBACK != callbackID ) {
m_clickCallback.dlgButtonClicked( callbackID,
AlertDialog.BUTTON_POSITIVE,
- null );
+ params );
}
} else {
String msg = m_activity.getString( msgID );
DlgState state =
- new DlgState( DIALOG_NOTAGAIN, msg, callbackID, prefsKey );
+ new DlgState( DIALOG_NOTAGAIN, msg, callbackID, prefsKey,
+ params );
addState( state );
m_activity.showDialog( DIALOG_NOTAGAIN );
}
}
+ public void showNotAgainDlgThen( int msgID, int prefsKey,
+ int callbackID )
+ {
+ showNotAgainDlgThen( msgID, prefsKey, callbackID, null );
+ }
+
public void showNotAgainDlgThen( int msgID, int prefsKey )
{
showNotAgainDlgThen( msgID, prefsKey, SKIP_CALLBACK );
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgState.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgState.java
index b0c6dfbf9..315fc6d33 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgState.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgState.java
@@ -41,6 +41,13 @@ public class DlgState implements Parcelable {
this( id, msg, R.string.button_ok, cbckID, prefsKey );
}
+ public DlgState( int id, String msg, int cbckID, int prefsKey,
+ Object[] params )
+ {
+ this( id, msg, R.string.button_ok, cbckID, prefsKey );
+ m_params = params;
+ }
+
public DlgState( int id, String msg, int posButton,
int cbckID, int prefsKey )
{
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
index 0c7d27eab..5ecc46f34 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
@@ -90,6 +90,7 @@ public class GamesList extends XWExpandableListActivity
private static final int NEW_FROM_ACTION = 5;
private static final int DELETE_GROUP_ACTION = 6;
private static final int DELETE_SELGAMES_ACTION = 7;
+ private static final int OPEN_GAME_ACTION = 8;
private static final int[] DEBUGITEMS = { R.id.gamel_menu_loaddb
, R.id.gamel_menu_storedb
, R.id.gamel_menu_checkupdates
@@ -494,23 +495,9 @@ public class GamesList extends XWExpandableListActivity
// dialog in case it was dismissed. That way it to check for
// an empty room name.
if ( !m_gameLaunched ) {
- if ( summary.conType == CommsAddrRec.CommsConnType.COMMS_CONN_RELAY
- && summary.roomName.length() == 0 ) {
- // If it's unconfigured and of the type RelayGameActivity
- // can handle send it there, otherwise use the full-on
- // config.
- Class clazz;
- if ( RelayGameActivity.isSimpleGame( summary ) ) {
- clazz = RelayGameActivity.class;
- } else {
- clazz = GameConfig.class;
- }
- GameUtils.doConfig( this, rowid, clazz );
- } else {
- if ( checkWarnNoDict( rowid ) ) {
- launchGame( rowid );
- }
- }
+ showNotAgainDlgThen( R.string.not_again_newselect,
+ R.string.key_notagain_newselect,
+ OPEN_GAME_ACTION, rowid, summary );
}
}
@@ -585,6 +572,9 @@ public class GamesList extends XWExpandableListActivity
case DELETE_SELGAMES_ACTION:
deleteSelected();
break;
+ case OPEN_GAME_ACTION:
+ doOpenGame( params );
+ break;
default:
Assert.fail();
}
@@ -1186,6 +1176,31 @@ public class GamesList extends XWExpandableListActivity
tryAlert( intent );
}
+ private void doOpenGame( Object[] params )
+ {
+ GameSummary summary = (GameSummary)params[1];
+ long rowid = (Long)params[0];
+
+ if ( summary.conType == CommsAddrRec.CommsConnType.COMMS_CONN_RELAY
+ && summary.roomName.length() == 0 ) {
+ // If it's unconfigured and of the type RelayGameActivity
+ // can handle send it there, otherwise use the full-on
+ // config.
+ Class clazz;
+
+ if ( RelayGameActivity.isSimpleGame( summary ) ) {
+ clazz = RelayGameActivity.class;
+ } else {
+ clazz = GameConfig.class;
+ }
+ GameUtils.doConfig( this, rowid, clazz );
+ } else {
+ if ( checkWarnNoDict( rowid ) ) {
+ launchGame( rowid );
+ }
+ }
+ }
+
public static void onGameDictDownload( Context context, Intent intent )
{
intent.setClass( context, GamesList.class );
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWExpandableListActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWExpandableListActivity.java
index 3d8ed8ef0..87e9d02ea 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWExpandableListActivity.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWExpandableListActivity.java
@@ -84,6 +84,12 @@ public class XWExpandableListActivity extends ExpandableListActivity
m_delegate.doSyncMenuitem();
}
+ protected void showNotAgainDlgThen( int msgID, int prefsKey,
+ int action, Object... params )
+ {
+ m_delegate.showNotAgainDlgThen( msgID, prefsKey, action, params );
+ }
+
protected void showNotAgainDlgThen( int msgID, int prefsKey,
int action )
{
From 27fa9bf203bfdf764ccd453c4dac1ed3d6d0de24 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Tue, 15 Oct 2013 19:14:49 -0700
Subject: [PATCH 007/240] deprecate delete context menu item
---
.../org/eehouse/android/xw4/GamesList.java | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
index 5ecc46f34..b48397817 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
@@ -85,12 +85,11 @@ public class GamesList extends XWExpandableListActivity
private static final int NEW_NET_GAME_ACTION = 1;
private static final int RESET_GAME_ACTION = 2;
- private static final int DELETE_GAME_ACTION = 3;
- private static final int SYNC_MENU_ACTION = 4;
- private static final int NEW_FROM_ACTION = 5;
- private static final int DELETE_GROUP_ACTION = 6;
- private static final int DELETE_SELGAMES_ACTION = 7;
- private static final int OPEN_GAME_ACTION = 8;
+ private static final int SYNC_MENU_ACTION = 3;
+ private static final int NEW_FROM_ACTION = 4;
+ private static final int DELETE_GROUP_ACTION = 5;
+ private static final int DELETE_SELGAMES_ACTION = 6;
+ private static final int OPEN_GAME_ACTION = 7;
private static final int[] DEBUGITEMS = { R.id.gamel_menu_loaddb
, R.id.gamel_menu_storedb
, R.id.gamel_menu_checkupdates
@@ -552,9 +551,6 @@ public class GamesList extends XWExpandableListActivity
GameUtils.resetGame( this, m_rowid );
onContentChanged(); // required because position may change
break;
- case DELETE_GAME_ACTION:
- GameUtils.deleteGame( this, m_rowid, true );
- break;
case SYNC_MENU_ACTION:
doSyncMenuitem();
break;
@@ -780,8 +776,9 @@ public class GamesList extends XWExpandableListActivity
m_rowid = rowid;
if ( R.id.list_item_delete == menuID ) {
- showConfirmThen( R.string.confirm_delete, R.string.button_delete,
- DELETE_GAME_ACTION );
+ showOKOnlyDialog( "This menu is going away soon. To delete games, "
+ + "select them by tapping the left icon then use "
+ + "action bar or screen menu's new delete item." );
} else {
if ( checkWarnNoDict( m_rowid ) ) {
switch ( menuID ) {
From f30203bb22adb7191f541548a5ce7860f9877bbb Mon Sep 17 00:00:00 2001
From: Eric House
Date: Tue, 15 Oct 2013 21:15:44 -0700
Subject: [PATCH 008/240] fix NPE when choosing not to see new hint dialog
again
---
.../XWords4/src/org/eehouse/android/xw4/DlgDelegate.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java
index 5854d8602..29381b03a 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java
@@ -353,7 +353,8 @@ public class DlgDelegate {
if ( SKIP_CALLBACK != state.m_cbckID ) {
m_clickCallback.
dlgButtonClicked( state.m_cbckID,
- AlertDialog.BUTTON_POSITIVE, null );
+ AlertDialog.BUTTON_POSITIVE,
+ state.m_params );
}
}
};
From 44bae9246b07efb5a885852977095a6781c78a8d Mon Sep 17 00:00:00 2001
From: Eric House
Date: Tue, 15 Oct 2013 21:17:34 -0700
Subject: [PATCH 009/240] use enum instead of a bunch of constants
---
.../org/eehouse/android/xw4/GamesList.java | 48 ++++++++++---------
1 file changed, 26 insertions(+), 22 deletions(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
index b48397817..4e769e7c6 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
@@ -83,13 +83,14 @@ public class GamesList extends XWExpandableListActivity
private static final String REMATCH_ROWID_EXTRA = "rowid_rm";
private static final String ALERT_MSG = "alert_msg";
- private static final int NEW_NET_GAME_ACTION = 1;
- private static final int RESET_GAME_ACTION = 2;
- private static final int SYNC_MENU_ACTION = 3;
- private static final int NEW_FROM_ACTION = 4;
- private static final int DELETE_GROUP_ACTION = 5;
- private static final int DELETE_SELGAMES_ACTION = 6;
- private static final int OPEN_GAME_ACTION = 7;
+ private static enum GamesActions { NEW_NET_GAME,
+ RESET_GAME,
+ SYNC_MENU,
+ NEW_FROM,
+ DELETE_GROUP,
+ DELETE_SELGAMES,
+ OPEN_GAME
+ };
private static final int[] DEBUGITEMS = { R.id.gamel_menu_loaddb
, R.id.gamel_menu_storedb
, R.id.gamel_menu_checkupdates
@@ -496,7 +497,8 @@ public class GamesList extends XWExpandableListActivity
if ( !m_gameLaunched ) {
showNotAgainDlgThen( R.string.not_again_newselect,
R.string.key_notagain_newselect,
- OPEN_GAME_ACTION, rowid, summary );
+ GamesActions.OPEN_GAME.ordinal(),
+ rowid, summary );
}
}
@@ -541,34 +543,35 @@ public class GamesList extends XWExpandableListActivity
public void dlgButtonClicked( int id, int which, Object[] params )
{
if ( AlertDialog.BUTTON_POSITIVE == which ) {
- switch( id ) {
- case NEW_NET_GAME_ACTION:
+ GamesActions action = GamesActions.values()[id];
+ switch( action ) {
+ case NEW_NET_GAME:
if ( checkWarnNoDict( m_netLaunchInfo ) ) {
makeNewNetGameIf();
}
break;
- case RESET_GAME_ACTION:
+ case RESET_GAME:
GameUtils.resetGame( this, m_rowid );
onContentChanged(); // required because position may change
break;
- case SYNC_MENU_ACTION:
+ case SYNC_MENU:
doSyncMenuitem();
break;
- case NEW_FROM_ACTION:
+ case NEW_FROM:
long newid = GameUtils.dupeGame( GamesList.this, m_rowid );
if ( null != m_adapter ) {
m_adapter.inval( newid );
}
break;
- case DELETE_GROUP_ACTION:
+ case DELETE_GROUP:
GameUtils.deleteGroup( this, m_groupid );
onContentChanged();
break;
- case DELETE_SELGAMES_ACTION:
+ case DELETE_SELGAMES:
deleteSelected();
break;
- case OPEN_GAME_ACTION:
+ case OPEN_GAME:
doOpenGame( params );
break;
default:
@@ -703,7 +706,7 @@ public class GamesList extends XWExpandableListActivity
case R.id.gamel_menu_delete:
showConfirmThen( R.string.confirm_seldeletes, R.string.button_delete,
- DELETE_SELGAMES_ACTION );
+ GamesActions.DELETE_SELGAMES.ordinal() );
break;
case R.id.gamel_menu_dicts:
@@ -713,7 +716,7 @@ public class GamesList extends XWExpandableListActivity
case R.id.gamel_menu_checkmoves:
showNotAgainDlgThen( R.string.not_again_sync,
R.string.key_notagain_sync,
- SYNC_MENU_ACTION );
+ GamesActions.SYNC_MENU.ordinal() );
break;
case R.id.gamel_menu_checkupdates:
@@ -784,7 +787,8 @@ public class GamesList extends XWExpandableListActivity
switch ( menuID ) {
case R.id.list_item_reset:
showConfirmThen( R.string.confirm_reset,
- R.string.button_reset, RESET_GAME_ACTION );
+ R.string.button_reset,
+ GamesActions.RESET_GAME.ordinal() );
break;
case R.id.list_item_config:
GameUtils.doConfig( this, m_rowid, GameConfig.class );
@@ -802,7 +806,7 @@ public class GamesList extends XWExpandableListActivity
case R.id.list_item_new_from:
showNotAgainDlgThen( R.string.not_again_newfrom,
R.string.key_notagain_newfrom,
- NEW_FROM_ACTION );
+ GamesActions.NEW_FROM.ordinal() );
break;
case R.id.list_item_copy:
@@ -850,7 +854,7 @@ public class GamesList extends XWExpandableListActivity
if ( 0 < nGames ) {
msg += getString( R.string.group_confirm_delf, nGames );
}
- showConfirmThen( msg, DELETE_GROUP_ACTION );
+ showConfirmThen( msg, GamesActions.DELETE_GROUP.ordinal() );
}
break;
case R.id.list_group_rename:
@@ -1014,7 +1018,7 @@ public class GamesList extends XWExpandableListActivity
String msg = getString( R.string.dup_game_queryf,
create.toString() );
m_netLaunchInfo = nli;
- showConfirmThen( msg, NEW_NET_GAME_ACTION );
+ showConfirmThen( msg, GamesActions.NEW_NET_GAME.ordinal() );
}
} // startNewNetGame
From bfea8dad496e5b4c6f205c0ccc1287293cd6e3f4 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Tue, 15 Oct 2013 22:03:14 -0700
Subject: [PATCH 010/240] fix NPE. I think it's a bug that null appears there,
but better not to crash.
---
.../XWords4/src/org/eehouse/android/xw4/GameListAdapter.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java
index 603615833..ebca22600 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java
@@ -369,7 +369,9 @@ public class GameListAdapter implements ExpandableListAdapter {
GameListItem[] items = new GameListItem[rowids.size()];
getGameItemsFor( rowids, items );
for ( GameListItem item : items ) {
- item.setSelected( false );
+ if ( null != item ) {
+ item.setSelected( false );
+ }
}
}
From 972629db8e6f0181240a253ca2769b6e2efe15af Mon Sep 17 00:00:00 2001
From: Eric House
Date: Tue, 15 Oct 2013 22:04:33 -0700
Subject: [PATCH 011/240] string tweaks, including calling Exchange "Trade"
because it's smaller.
---
xwords4/android/XWords4/res/values/strings.xml | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml
index e4c2a4586..d3d9e536f 100644
--- a/xwords4/android/XWords4/res/values/strings.xml
+++ b/xwords4/android/XWords4/res/values/strings.xml
@@ -105,7 +105,7 @@
Wordlists
- Settings
+ App Settings...
- %s settings
+ Settings for %s%s settings (networked)
@@ -527,8 +527,8 @@
- Commit exchange
- Cancel exchange
+ Commit trade
+ Cancel tradeTap tiles to select...
@@ -653,7 +653,7 @@
- Exchange tiles
+ Trade
- Crosswords settings
+ Crosswords Settings
diff --git a/xwords4/android/XWords4/res/menu/games_list_menu.xml b/xwords4/android/XWords4/res/menu/games_list_menu.xml
index 69f78fb5c..ee7917d74 100644
--- a/xwords4/android/XWords4/res/menu/games_list_menu.xml
+++ b/xwords4/android/XWords4/res/menu/games_list_menu.xml
@@ -6,15 +6,20 @@
android:icon="@drawable/content_new"
android:showAsAction="ifRoom"
/>
-
+
+
Date: Tue, 15 Oct 2013 22:12:49 -0700
Subject: [PATCH 014/240] add pencil/edit actionbar icons
---
.../XWords4/res/drawable-hdpi/content_edit.png | Bin 0 -> 1875 bytes
.../XWords4/res/drawable-mdpi/content_edit.png | Bin 0 -> 1490 bytes
.../XWords4/res/drawable-xhdpi/content_edit.png | Bin 0 -> 2382 bytes
3 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 xwords4/android/XWords4/res/drawable-hdpi/content_edit.png
create mode 100644 xwords4/android/XWords4/res/drawable-mdpi/content_edit.png
create mode 100644 xwords4/android/XWords4/res/drawable-xhdpi/content_edit.png
diff --git a/xwords4/android/XWords4/res/drawable-hdpi/content_edit.png b/xwords4/android/XWords4/res/drawable-hdpi/content_edit.png
new file mode 100644
index 0000000000000000000000000000000000000000..3eb5190fb44de54efc5a1675090aeedb25b1d0c6
GIT binary patch
literal 1875
zcmaJ?Yfuwc6b?iLf}jIZq6J*yyFjuV5+NZ`LKY%wXe3bq6$!~A2__q}izE~a6;ROf
zXnj#}tS_tzMnoP}5CpACE22&DiB1rO4p>1E3p#2yDz-ngyR&=mJ#)VAeCM&Vd6Gzx
zGi5S`L?Ssy%!i|h6|_DMV~O`N+mTJgG6@fh#-(T?o+{TPB!Lo5K!6C1d^Hk<$d$&m
zEeMZ9B2QDvqVZ_)BCZ0}(B)PixymGzI6=2&L~*(C9wUYO(iaA_~SZ$aM^e4q8(hbrg&L-&Lde;Emx?
z$iI3&N{q>jI)o90U}%b7K{PILsx_33E7T)$9M#KEbj@fLB}pibVo9hD5K7r}2oTE^
zDy`M>79kdMBeWPU*D8<*m`@`(=qiWSRgape)NMT
zDPK;#*mmny@y?d+=~d^!#Scnb>|IAP$5(b{EsY&?HBPDi*62G0j#IPXX}ijY<3q*Y
zyC?WDPUN-P!*SP(PjD{wo8BDxsf)L+hSSC=!)_eMuB_jKT^Y(S^))>1YbdzWGkA(S
zsJl4kJaNN0nGHqGThCHu&NnRD)f0+b>f}6DM2JUH_7~N9Eef&Y
zZTRA6@`0@NwNl#)LZ6O}u?E{Z!23mL9xRJF|FFqvWpLZ$x^t>3$F@`86=vX==S=|y
z$C*AcG`i{vZ(UXsbMBi}jc$=PuY-q4n|;nbjWa!d?i*yYGJaym_FTIO_I5>7N1MKs
zoxVB7*Atfh24dnv2_4k>7|eH{%jO4yFOwVH3;e3Qca)i)#CG$4?eW+qzHBNXkKE3|
zwk<%9<}P;|FpAVZ!Cl8*X14T{R;(OZKhH1QT(RUxwP#%L%E;Qp^u4)RlJZwg4rxv?
zPd9e;d?U%PUAlip_KpzuiGr-n!N<+Ex7GC-R7QuSe7y8jhvivb`I!qZ`@q4jEx2v+
zjod9oPhMA^7C7B{60la3-%nX3m(J?B_hvS*7%K7Y%BVFDr+K;cbM9`ZI*Iny#?{{R
zBzr*(XMB{sLylMNnM3unT`$xw$!z(IoH8-}s3xP*WlF+VVua3LZEKgs~
z(@_sCf5Fru2i=aU>eYqC^xIS;O>mF-u&G_=RV929ayr)QdQR`w?+)$Y9ICO1QaoLE
zGv~@|PPV%{bX3&GlFd~?t%s$TgA>wc`D{DbAU>MFxjAqtIEHdeN-3>ON;+Or*SM_n
z{>x1sQspxnYW$7deAuD2MwZ{CezAvAs&5~n&&)?#$-;K$K6PG3Z2~WD<2}h?S$L%g
z4eSo7l3^w)^1&PVosU-?Y
zsp*+{wo31J?^jaDOtDo8H}y5}EpSfF$n>ZxN)4{^3rViZPPR-@vbR&PsjvbXkegbP
zs8ErclUHn2VXFi-*9yo63F|8hm3bwJ6}oxF$}kgLQj3#|G7CyF^YauyCMG83
zmzLNn0bL65LT&-v*t}wBFaZNhzap_f-%!s00+w{G(#^lGsVi)#n8yb&DhM;$-vFf(ACh=#L&{!#L3yw
z&D7A`#K{n**Cju>G&eP`1g19yq1POzUQlAlEdbi=l3J8mmYU*Ll%J~r_Ow+dZnv1=
zG!Lpb1-DyFaq86vIz}H9wMbD769T3m5EGtofgE_!Pt60S_ab1z_Wk-jmVtrE#nZ(x
zq~g|_>;4{793_r_jQzaU#aB6UiL;|u(u8WxMI1br98Pqc2vG9jR7_P|@#4b51q%Xf
zL}hpVSRR}ik)Zj^_0zK4_6r692CITwB4=KE^-J~#=jt8nc75J8oy|^X_Z#c;dyLQj
zKC|aufyEoo6z@+eJ5*~JPU?Nz%dNhVGhZO)oqwEo(Sh#8J6h+?ILtF|A!BeJe}euy
zW%m6a{5Nmlox5Y%{WZ@Wv`#&AW?lDKJ;
!pRabe
znGG&i%dqZf(6(q1fAwFe?!d+W?YaC1eBLMCIV@arH1q4-RS(qE%QV>I^mpA-NtDql
z6yy8$K=W7u(@qH|=1mt`-g^J;P_JN+H*DhjF|mbRs^w=~8~+LSV?}?D2;V7@IkMp0
z7hSGIxwmE|huYKL^j*7N^~!-^>yO1sn=i=N-dFp){G-s-ivIiCzBOeWwB^c^+kX2;
zllzZ7K_9k;9h%zYzKthz_j9xI!&lkLL;mi&d5d@Z1EVa1om~$Ur#`5Qe$IF~bK9zL
z59`=95B6^3Q+atSO#U&?t%;e&6>C&ALOACJ)~>&<_;`kq^_tgb*W8Kl{}5puuA_ZR8UB6G*-uI~#`?F)!(!!@9H7+O9uGMd@aqnMs+dBH-V%`TKM+CD()?aA-
z*ju50WBrrY7k_
literal 0
HcmV?d00001
diff --git a/xwords4/android/XWords4/res/drawable-xhdpi/content_edit.png b/xwords4/android/XWords4/res/drawable-xhdpi/content_edit.png
new file mode 100644
index 0000000000000000000000000000000000000000..4215579aedd5edf6f5314de15e7b9175eb5acff2
GIT binary patch
literal 2382
zcmaJ@c{r478y_msW+`JSOd}taSAy59GBp8L9gzx#JT_wSE4)5mM)+EvD@
zKp@as4|kHEa&=a{ni|UQ6$W=mxflt^!2*AFj39~113)g(>?i=@!KBgwKY$u7;&uQI
zAkeZcjDTQ4Fl9HM#%98)svNkG$x)&~AO|NQhf0eB1du3z&R`Ls@>@+%2qT&R-Gikd
zDI6jY%WzNT0shHe0kq^e8ZH{@UPyp`;l(TWsxSfy`H~`t
zBS8Na6-@Dg5ZOEcf`ubtG^8yGVvB*JFi0E*XAMCkQAh*|jX>JLP)I!14v$1ZzCKW8
zHC}WK-jC$=wU+WkfW`_096SP%l#~QdvVpUCbOZ{A!y%Ap1R4!fX2AF&mVhdRvH0do
z3?zV0<1sh_2Ac&@F;b)02?7FCsr2s_n4E94EdJMPQeGHBNaY|AmRWBKY-6p;L((Wi!oP~;^2uqfGS|~0@&>MrCaogWeeE+ST+Yj
z^vA+c5DJyXV5uTs5EKgDgT)t6Sv0_dM1U$e;0#7Io=mhSy4Yh;SXZPQ3PncYFen@u
z<4SaK!=mgkuBas}iA_sj0xZE2Hu@hd`ny<_8JHYpWfH(+Bm&WHJT?>ZrD;6lyIL@A
z-{t#?jsCtC2wEr6QQb_3^)%Kflm4|QE2UtqK^OVL0Z+vkT1X|JTL2?NY
z_D>Y1h;xAr8N)9I6Q2k22W`809*31bozx2g`|212&|dw9P~YC8+14&r16Ak-9a3!K
zRHb;b3UD({7$K_c<%-J&b;lG@>gtOJ
zHRZ?IogwL5DVLl7r@{T-!p*OcOC?s%#3j7-Wq}SJlDXH4wm=IvvDZyk!PU!}aM
zpJH3)cgNL8Ec0$){VJ~LO*V=I$L2#8+qAcg
z^}}xly-e@jseAX?GAVAhE^{VZcvkElhQ)Xcx_BQN6X#2PU58rIj?3=R{WRz!BAZXd
zAJWWlt=WV1(g^RzHRF}y*)q$!eUrlN8YC-`S+!jI7|JkpgysSA%FQE)@)K?!V}@NTGjQD*T2GPGc%y~=Rf(%BKOSsoI-AOYnnc=Y
zRTNi+?418>X*-X-)1&^xXAC@|aL?9wF#Ffh+?t>Yxn-Z3^9>`?$?HjNy4f^h&&JJ_
zGIK^ao$Bb(_z=uF(GavbT_ieZ=&AneaN4epHGk~xxh1nPDh)R7YEEHfn!KG#(Cobz
z?o{Y_&hoPEtLHPBzZ;kLX?;E&mU6h20_(~dsd=6=-W90N?Oq7U8$^KZrm9B|uFDSF
z&}wUwbt5yIolP=wLVxU?
z@hm!N>CoP(7L@&N3yN$NvP`7YGOnQ7IGX7q3tEqN$u9AjdY5Y5PZ3JB)x64KAD)f>
z&`=9J8n$UXBv+(r^|X{pE!RQs+h>G&v(CS@!*zU!$@kt5%avsmEQ`0o6;_Kc}%S+GpxDk$Hc}F0p29y7D~}=8KoxZL=!rCWAcp(?!{(X1f1rkO&7z
z3+Y8Vn%%O;E3F^!jA@nC)Qg0P8pWV(d1UG8p6Tt)M)27QLQ%WyS(W^LpLABEYd(JY
z4f&g_j-IFO-RcQ7ZDZV&;3;y!6<5!79{_oi99`7M{qdwbM0Yt
z?N+Mkt4>O~zZG@F{-I>O#M{2+eLXtljRrJmjyXn;K*Z7KeG|7AgA87$E#N!V_FTL=
qU3zhwdcg9_nm)R(gyEl8BSBe5&$GOXn2%I{I38p#QiW^eq5lF9AN}zF
literal 0
HcmV?d00001
From 0c3057f75ceef3f18d9f25c784a4385e466b6d3e Mon Sep 17 00:00:00 2001
From: Eric House
Date: Tue, 15 Oct 2013 22:20:59 -0700
Subject: [PATCH 015/240] use different icon
---
xwords4/android/XWords4/res/menu/games_list_menu.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/xwords4/android/XWords4/res/menu/games_list_menu.xml b/xwords4/android/XWords4/res/menu/games_list_menu.xml
index ee7917d74..98eaa3b55 100644
--- a/xwords4/android/XWords4/res/menu/games_list_menu.xml
+++ b/xwords4/android/XWords4/res/menu/games_list_menu.xml
@@ -13,7 +13,7 @@
/>
Date: Wed, 16 Oct 2013 06:13:10 -0700
Subject: [PATCH 016/240] tap on selected item deselects rather than opening
game
---
.../XWords4/src/org/eehouse/android/xw4/GameListItem.java | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java
index 62f0c71ec..34a710ea8 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java
@@ -223,7 +223,12 @@ public class GameListItem extends LinearLayout
setOnClickListener( new View.OnClickListener() {
@Override
public void onClick( View v ) {
- m_cb.itemClicked( m_rowid, summary );
+ // if selected, just un-select
+ if ( null != m_origDrawable ) {
+ toggleSelected();
+ } else {
+ m_cb.itemClicked( m_rowid, summary );
+ }
}
} );
From dab8ba88e5af18aa279f0c875d7cb87775fa2774 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Wed, 16 Oct 2013 06:20:01 -0700
Subject: [PATCH 017/240] use darker selection color from alarm clock app,
which has a similar dark theme.
---
xwords4/android/XWords4/src/org/eehouse/android/xw4/XWApp.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWApp.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWApp.java
index 7d046bd29..27fba48bf 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWApp.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWApp.java
@@ -43,7 +43,7 @@ public class XWApp extends Application {
public static final String SMS_PUBLIC_HEADER = "-XW4";
public static final int MAX_TRAY_TILES = 7; // comtypes.h
- public static final int SEL_COLOR = Color.argb( 0xFF, 0xCF, 0XE9, 0XF3 );
+ public static final int SEL_COLOR = Color.argb( 0xFF, 0x09, 0x70, 0x93 );
private static UUID s_UUID = null;
private static Boolean s_onEmulator = null;
From b6aa0e19a6007bc8fd74ca5bf73c4d9cb1042997 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Wed, 16 Oct 2013 06:20:10 -0700
Subject: [PATCH 018/240] tweak text
---
.../XWords4/src/org/eehouse/android/xw4/GamesList.java | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
index c5e51d23f..d2f161cf6 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
@@ -786,9 +786,10 @@ public class GamesList extends XWExpandableListActivity
if ( R.id.list_item_delete == menuID
|| R.id.list_item_config == menuID ) {
- showOKOnlyDialog( "This menu is going away soon. Please select games"
- + " by tapping the left icons then use action bar"
- + " or the screen menu to operate on the selection.");
+ showOKOnlyDialog( "This menu item is going away soon. Please select"
+ + " games by tapping the left icons then use"
+ + " action bar icons or the screen menu to operate"
+ + " on the selection." );
} else {
if ( checkWarnNoDict( m_rowid ) ) {
switch ( menuID ) {
From 9d6facce8410336ae1dff0e185cfd93648b7138d Mon Sep 17 00:00:00 2001
From: Eric House
Date: Wed, 16 Oct 2013 07:21:34 -0700
Subject: [PATCH 019/240] name the number of selected games in delete confirm
dialog
---
xwords4/android/XWords4/res/values/strings.xml | 4 ++--
.../XWords4/src/org/eehouse/android/xw4/GamesList.java | 4 +++-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml
index d3d9e536f..32482c8d8 100644
--- a/xwords4/android/XWords4/res/values/strings.xml
+++ b/xwords4/android/XWords4/res/values/strings.xml
@@ -179,8 +179,8 @@
Are you sure you want to delete this
game?
- Are you sure you want to delete
- all selected games? This action cannot be undone.
+ Are you sure you want to delete
+ the %d selected game[s]? This action cannot be undone.
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
index d2f161cf6..286f30c8c 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
@@ -711,7 +711,9 @@ public class GamesList extends XWExpandableListActivity
break;
case R.id.gamel_menu_delete:
- showConfirmThen( R.string.confirm_seldeletes, R.string.button_delete,
+ String msg = Utils.format( this, R.string.confirm_seldeletesf,
+ m_selected.size() );
+ showConfirmThen( msg, R.string.button_delete,
GamesActions.DELETE_SELGAMES.ordinal() );
break;
From f4160c178dc168d525ac596102eef91e0949ffef Mon Sep 17 00:00:00 2001
From: Eric House
Date: Wed, 16 Oct 2013 07:36:36 -0700
Subject: [PATCH 020/240] hide Add button/menuitem when there's a selection
---
.../android/XWords4/src/org/eehouse/android/xw4/GamesList.java | 2 ++
1 file changed, 2 insertions(+)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
index 286f30c8c..5ae2b65a2 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
@@ -686,6 +686,8 @@ public class GamesList extends XWExpandableListActivity
}
int nSelected = m_selected.size();
+
+ Utils.setItemVisible( menu, R.id.gamel_menu_newgame, 0 == nSelected );
Utils.setItemVisible( menu, R.id.gamel_menu_delete, 0 < nSelected );
Utils.setItemVisible( menu, R.id.listl_item_config, 1 == nSelected );
From 85382c982c3e8327ad2ac12dc6c939fe79f7e665 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Wed, 16 Oct 2013 08:13:18 -0700
Subject: [PATCH 021/240] remove words from main games list. People don't read
them, and now there's a '+' in the menubar.
---
.../android/XWords4/res/layout/game_list.xml | 48 -------------------
.../XWords4/res/values/common_rsrc.xml | 1 -
.../android/XWords4/res/values/strings.xml | 19 +-------
xwords4/android/XWords4/res/xml/xwprefs.xml | 5 --
.../org/eehouse/android/xw4/GamesList.java | 43 -----------------
.../eehouse/android/xw4/jni/CommonPrefs.java | 5 --
6 files changed, 1 insertion(+), 120 deletions(-)
diff --git a/xwords4/android/XWords4/res/layout/game_list.xml b/xwords4/android/XWords4/res/layout/game_list.xml
index a5f0b947e..e04e62741 100644
--- a/xwords4/android/XWords4/res/layout/game_list.xml
+++ b/xwords4/android/XWords4/res/layout/game_list.xml
@@ -5,29 +5,6 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
-
-
-
-
-
-
-
-
-
-
-
diff --git a/xwords4/android/XWords4/res/values/common_rsrc.xml b/xwords4/android/XWords4/res/values/common_rsrc.xml
index 636b10376..983cbb3a0 100644
--- a/xwords4/android/XWords4/res/values/common_rsrc.xml
+++ b/xwords4/android/XWords4/res/values/common_rsrc.xml
@@ -56,7 +56,6 @@
key_notify_soundkey_notify_vibratekey_enable_sms
- key_hide_introkey_keep_screenonkey_summary_fieldkey_default_loc
diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml
index 32482c8d8..6791b3226 100644
--- a/xwords4/android/XWords4/res/values/strings.xml
+++ b/xwords4/android/XWords4/res/values/strings.xml
@@ -13,28 +13,11 @@
# This is the first screen you see when you launch Crosswords
############################################################
-->
-
- Use the button below to create a
- game. Tap an existing game to play it or long-tap it for other
- options.
-
- You can hide this and the buttons
- below in the Appearance section of Settings (accessed via your
- device\'s menu key.)
-
+
Add gameAdd group
-
- Use the menu key to add a
- game.
-
-
diff --git a/xwords4/android/XWords4/res/raw/changes b/xwords4/android/XWords4/res/raw/changes
index 9c71b364a..028192dc8 100644
--- a/xwords4/android/XWords4/res/raw/changes
+++ b/xwords4/android/XWords4/res/raw/changes
@@ -5,7 +5,7 @@
-Crosswords 4.4 beta 69 release
+Crosswords 4.4 beta 70 release
This release features a major upgrade to how the app communicates
with the relay, in essence switching from each game communicating
@@ -18,8 +18,7 @@
New with this release
-
Fix relay registration problem (Thanks DS!)
-
Show Turn done/Pass in actionbar where possible
+
Work around bug in 2.3.x Android (Thanks O!)
Next up
diff --git a/xwords4/android/XWords4/res/values/app_name.xml b/xwords4/android/XWords4/res/values/app_name.xml
index c8959bb72..8f4532ad6 100644
--- a/xwords4/android/XWords4/res/values/app_name.xml
+++ b/xwords4/android/XWords4/res/values/app_name.xml
@@ -1,5 +1,5 @@
- 4.4 beta 69
+ 4.4 beta 70
From 59795667727524fc6aa3e58c5b78973c853f2631 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Thu, 17 Oct 2013 06:12:04 -0700
Subject: [PATCH 025/240] hide title bar by default for pre-ICS devices but not
for those where I'm using the action bar.
---
.../src/org/eehouse/android/xw4/jni/CommonPrefs.java | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/CommonPrefs.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/CommonPrefs.java
index 28f4c868c..a3f228802 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/CommonPrefs.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/CommonPrefs.java
@@ -24,7 +24,9 @@ import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.Paint;
+import android.os.Build;
import android.preference.PreferenceManager;
+
import junit.framework.Assert;
import org.eehouse.android.xw4.XWPrefs;
@@ -239,7 +241,9 @@ public class CommonPrefs extends XWPrefs {
public static boolean getHideTitleBar( Context context )
{
- return getPrefsBoolean( context, R.string.key_hide_title, false );
+ boolean hideByDefault = 11 > Integer.valueOf( Build.VERSION.SDK );
+ return getPrefsBoolean( context, R.string.key_hide_title,
+ hideByDefault );
}
public static boolean getSoundNotify( Context context )
From 055b4ce04ea7f708114660e24aaf095f2d723cbd Mon Sep 17 00:00:00 2001
From: Eric House
Date: Thu, 17 Oct 2013 06:12:37 -0700
Subject: [PATCH 026/240] don't try to hide whole submenu -- crashes on 2.3
devices
---
xwords4/android/XWords4/res/menu/board_menu.xml | 3 +--
.../XWords4/src/org/eehouse/android/xw4/BoardActivity.java | 1 -
2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/xwords4/android/XWords4/res/menu/board_menu.xml b/xwords4/android/XWords4/res/menu/board_menu.xml
index 5a881899d..d31d54535 100644
--- a/xwords4/android/XWords4/res/menu/board_menu.xml
+++ b/xwords4/android/XWords4/res/menu/board_menu.xml
@@ -22,8 +22,7 @@
-
+
New with this release
From bf13046d985de819e35ffbfd6c9432728ef33baf Mon Sep 17 00:00:00 2001
From: Eric House
Date: Thu, 17 Oct 2013 06:13:47 -0700
Subject: [PATCH 028/240] add -> to submenu title to indicate it's a submenu
---
xwords4/android/XWords4/res/values/strings.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml
index 1991df4df..ce423646e 100644
--- a/xwords4/android/XWords4/res/values/strings.xml
+++ b/xwords4/android/XWords4/res/values/strings.xml
@@ -666,7 +666,7 @@
Undo last
- Game
+ Game ->
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/xwords4/android/XWords4/res/menu/games_list_menu.xml b/xwords4/android/XWords4/res/menu/games_list_menu.xml
index 98eaa3b55..7f1ac84dc 100644
--- a/xwords4/android/XWords4/res/menu/games_list_menu.xml
+++ b/xwords4/android/XWords4/res/menu/games_list_menu.xml
@@ -11,6 +11,13 @@
android:icon="@drawable/ic_action_delete"
android:showAsAction="ifRoom"
/>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/ExpiringTextView.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/ExpiringTextView.java
index a122ee817..cee016a6d 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/ExpiringTextView.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/ExpiringTextView.java
@@ -21,6 +21,7 @@ package org.eehouse.android.xw4;
import android.content.Context;
import android.graphics.Canvas;
+import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.util.AttributeSet;
import android.widget.TextView;
@@ -28,6 +29,8 @@ import android.widget.TextView;
class ExpiringTextView extends TextView {
private ExpiringDelegate m_delegate = null;
private Context m_context;
+ private Drawable m_origDrawable;
+ protected boolean m_selected = false;
public ExpiringTextView( Context context, AttributeSet attrs )
{
@@ -52,6 +55,17 @@ class ExpiringTextView extends TextView {
}
}
+ protected void toggleSelected()
+ {
+ m_selected = !m_selected;
+ if ( m_selected ) {
+ m_origDrawable = getBackground();
+ setBackgroundColor( XWApp.SEL_COLOR );
+ } else {
+ setBackgroundDrawable( m_origDrawable );
+ }
+ }
+
@Override
protected void onDraw( Canvas canvas )
{
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java
index ebca22600..c301fb25e 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java
@@ -49,11 +49,15 @@ public class GameListAdapter implements ExpandableListAdapter {
private long[] m_positions;
public interface LoadItemCB {
- public void itemClicked( long rowid, GameSummary summary );
- public void itemToggled( long rowid, boolean selected );
+ public void itemClicked( Object clicked, GameSummary summary );
+ public void itemToggled( Object toggled, boolean selected );
public boolean getSelected( long rowid );
}
+ public interface ClickHandler {
+ public void longClicked();
+ }
+
public GameListAdapter( Context context, ExpandableListView list,
Handler handler, LoadItemCB cb, long[] positions,
String fieldName )
@@ -152,9 +156,14 @@ public class GameListAdapter implements ExpandableListAdapter {
return ggi.m_name;
}
- public void clearSelected( Set rowids )
+ public void clearSelectedRows( Set rowids )
{
- deselect( rowids );
+ deselectRows( rowids );
+ }
+
+ public void clearSelectedGroups( HashSet groups )
+ {
+ deselectGroups( groups );
}
//////////////////////////////////////////////////////////////////////////
@@ -182,7 +191,7 @@ public class GameListAdapter implements ExpandableListAdapter {
for ( long rowid : rowids ) {
asSet.add( rowid );
}
- deselect( asSet );
+ deselectRows( asSet );
}
public void onGroupExpanded( int groupPosition )
@@ -232,9 +241,8 @@ public class GameListAdapter implements ExpandableListAdapter {
// if ( null != convertView ) {
// DbgUtils.logf( "getGroupView gave non-null convertView" );
// }
- GameListGroup view = (GameListGroup)
- Utils.inflate(m_context, R.layout.game_list_group );
- view.setGroupPosition( groupPosition );
+ GameListGroup view =
+ GameListGroup.makeForPosition( m_context, groupPosition, m_cb );
if ( !isExpanded ) {
GameGroupInfo ggi = getInfoForGroup( groupPosition );
@@ -364,7 +372,7 @@ public class GameListAdapter implements ExpandableListAdapter {
return gameInfo().get( getPositions()[groupPosition] );
}
- private void deselect( Set rowids )
+ private void deselectRows( Set rowids )
{
GameListItem[] items = new GameListItem[rowids.size()];
getGameItemsFor( rowids, items );
@@ -375,6 +383,16 @@ public class GameListAdapter implements ExpandableListAdapter {
}
}
+ private void deselectGroups( HashSet groups )
+ {
+ groups = (HashSet)groups.clone();
+ for ( Iteratoriter = groups.iterator();
+ iter.hasNext(); ) {
+ GameListGroup group = getGroupItemFor( iter.next() );
+ group.setSelected( false );
+ }
+ }
+
private void getGameItemsFor( Set rowids, GameListItem[] items )
{
int next = 0;
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListGroup.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListGroup.java
index 90b5827a2..1ce963098 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListGroup.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListGroup.java
@@ -23,11 +23,27 @@ package org.eehouse.android.xw4;
import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
+import android.view.View;
import org.eehouse.android.xw4.DBUtils.GameGroupInfo;
-public class GameListGroup extends ExpiringTextView {
+public class GameListGroup extends ExpiringTextView
+ implements GameListAdapter.ClickHandler
+{
private int m_groupPosition;
+ private boolean m_expanded;
+ private GameListAdapter.LoadItemCB m_cb;
+
+ public static GameListGroup makeForPosition( Context context,
+ int groupPosition,
+ GameListAdapter.LoadItemCB cb )
+ {
+ GameListGroup result =
+ (GameListGroup)Utils.inflate( context, R.layout.game_list_group );
+ result.m_cb = cb;
+ result.m_groupPosition = groupPosition;
+ return result;
+ }
public GameListGroup( Context cx, AttributeSet as )
{
@@ -43,4 +59,25 @@ public class GameListGroup extends ExpiringTextView {
{
return m_groupPosition;
}
+
+ public void setSelected( boolean selected )
+ {
+ // If new value and state not in sync, force change in state
+ if ( selected != m_selected ) {
+ toggleSelected();
+ }
+ }
+
+ // GameListAdapter.ClickHandler interface
+ public void longClicked()
+ {
+ toggleSelected();
+ }
+
+ protected void toggleSelected()
+ {
+ super.toggleSelected();
+ m_cb.itemToggled( this, m_selected );
+ }
+
}
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java
index 34a710ea8..5a59909b0 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java
@@ -43,7 +43,7 @@ import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType;
import org.eehouse.android.xw4.jni.GameSummary;
public class GameListItem extends LinearLayout
- implements View.OnClickListener {
+ implements View.OnClickListener, GameListAdapter.ClickHandler {
private static HashSet s_invalRows = new HashSet();
@@ -62,6 +62,7 @@ public class GameListItem extends LinearLayout
private int m_loadingCount;
private int m_groupPosition;
private Drawable m_origDrawable;
+ private boolean m_selected = false;
public GameListItem( Context cx, AttributeSet as )
{
@@ -71,6 +72,18 @@ public class GameListItem extends LinearLayout
m_rowid = DBUtils.ROWID_NOTFOUND;
m_lastMoveTime = 0;
m_loadingCount = 0;
+
+ setOnClickListener( new View.OnClickListener() {
+ @Override
+ public void onClick( View v ) {
+ // if selected, just un-select
+ if ( m_selected ) {
+ toggleSelected();
+ } else if ( null != m_summary ) {
+ m_cb.itemClicked( this, m_summary );
+ }
+ }
+ } );
}
private void init( Handler handler, long rowid, int groupPosition,
@@ -105,7 +118,7 @@ public class GameListItem extends LinearLayout
public void setSelected( boolean selected )
{
// If new value and state not in sync, force change in state
- if ( selected != (null != m_origDrawable) ) {
+ if ( selected != m_selected ) {
toggleSelected();
}
}
@@ -214,24 +227,12 @@ public class GameListItem extends LinearLayout
return state;
}
- private void setData( final GameSummary summary )
+ private void setData( GameSummary summary )
{
if ( null != summary ) {
TextView tview;
String state = setName();
- setOnClickListener( new View.OnClickListener() {
- @Override
- public void onClick( View v ) {
- // if selected, just un-select
- if ( null != m_origDrawable ) {
- toggleSelected();
- } else {
- m_cb.itemClicked( m_rowid, summary );
- }
- }
- } );
-
LinearLayout list =
(LinearLayout)findViewById( R.id.player_list );
list.removeAllViews();
@@ -305,14 +306,14 @@ public class GameListItem extends LinearLayout
private void toggleSelected()
{
- if ( null == m_origDrawable ) {
+ m_selected = !m_selected;
+ if ( m_selected ) {
m_origDrawable = getBackground();
setBackgroundColor( XWApp.SEL_COLOR );
} else {
setBackgroundDrawable( m_origDrawable );
- m_origDrawable = null;
}
- m_cb.itemToggled( m_rowid, null != m_origDrawable );
+ m_cb.itemToggled( this, m_selected );
}
private class LoadItemTask extends AsyncTask {
@@ -334,7 +335,7 @@ public class GameListItem extends LinearLayout
}
}
- if ( m_cb.getSelected( m_rowid ) && null != m_origDrawable ) {
+ if ( m_cb.getSelected( m_rowid ) && m_selected ) {
toggleSelected();
}
}
@@ -372,5 +373,11 @@ public class GameListItem extends LinearLayout
// }
// return TextUtils.join(",", strs );
// }
+ // GameListAdapter.ClickHandler interface
+
+ public void longClicked()
+ {
+ toggleSelected();
+ }
}
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
index 4db3ffd6f..cc4a09eec 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
@@ -32,16 +32,15 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.preference.PreferenceManager;
-import android.view.ContextMenu.ContextMenuInfo;
-import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
+import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
-import android.widget.ExpandableListView.ExpandableListContextMenuInfo;
+// import android.widget.ExpandableListView.ExpandableListContextMenuInfo;
import android.widget.ExpandableListView;
import android.widget.LinearLayout;
import android.widget.ListView;
@@ -59,7 +58,8 @@ import junit.framework.Assert;
import org.eehouse.android.xw4.jni.*;
public class GamesList extends XWExpandableListActivity
- implements DBUtils.DBChangeListener,
+ implements OnItemLongClickListener,
+ DBUtils.DBChangeListener,
GameListAdapter.LoadItemCB,
DictImportActivity.DownloadFinishedListener {
@@ -91,9 +91,32 @@ public class GamesList extends XWExpandableListActivity
DELETE_SELGAMES,
OPEN_GAME
};
- private static final int[] DEBUGITEMS = { R.id.gamel_menu_loaddb
- , R.id.gamel_menu_storedb
- , R.id.gamel_menu_checkupdates
+ private static final int[] DEBUGITEMS = {
+ R.id.gamel_menu_loaddb
+ , R.id.gamel_menu_storedb
+ , R.id.gamel_menu_checkupdates
+ };
+ private static final int[] NOSEL_ITEMS = {
+ R.id.gamel_menu_newgame
+ ,R.id.gamel_menu_newgroup
+ ,R.id.gamel_menu_prefs
+ ,R.id.gamel_menu_dicts
+ ,R.id.gamel_menu_about
+ ,R.id.gamel_menu_email
+ ,R.id.gamel_menu_checkmoves
+ };
+ private static final int[] ONEGAME_ITEMS = {
+ R.id.listl_item_config
+ ,R.id.list_item_rename
+ ,R.id.list_item_new_from
+ ,R.id.list_item_copy
+ };
+
+ private static final int[] ONEGROUP_ITEMS = {
+ R.id.list_group_default
+ ,R.id.list_group_rename
+ ,R.id.list_group_moveup
+ ,R.id.list_group_movedown
};
private static boolean s_firstShown = false;
@@ -110,7 +133,8 @@ public class GamesList extends XWExpandableListActivity
private NetLaunchInfo m_netLaunchInfo;
private GameNamer m_namer;
private boolean m_gameLaunched = false;
- private HashSet m_selected;
+ private HashSet m_selectedRows;
+ private HashSet m_selectedGroups;
@Override
protected Dialog onCreateDialog( int id )
@@ -339,10 +363,11 @@ public class GamesList extends XWExpandableListActivity
getBundledData( savedInstanceState );
- m_selected = new HashSet();
+ m_selectedRows = new HashSet();
+ m_selectedGroups = new HashSet();
setContentView(R.layout.game_list);
- registerForContextMenu( getExpandableListView() );
+ ExpandableListView listview = getExpandableListView();
DBUtils.setDBChangeListener( this );
boolean isUpgrade = Utils.firstBootThisVersion( this );
@@ -354,11 +379,12 @@ public class GamesList extends XWExpandableListActivity
String field = CommonPrefs.getSummaryField( this );
long[] positions = XWPrefs.getGroupPositions( this );
- m_adapter = new GameListAdapter( this, getExpandableListView(),
- new Handler(), this, positions,
- field );
+ m_adapter = new GameListAdapter( this, listview, new Handler(),
+ this, positions, field );
setListAdapter( m_adapter );
- m_adapter.expandGroups( getExpandableListView() );
+ listview.setOnItemLongClickListener( this );
+
+ m_adapter.expandGroups( listview );
NetUtils.informOfDeaths( this );
@@ -431,6 +457,16 @@ public class GamesList extends XWExpandableListActivity
}
}
+ // OnItemLongClickListener interface
+ public boolean onItemLongClick( AdapterView> parent, View view,
+ int position, long id ) {
+ boolean success = view instanceof GameListAdapter.ClickHandler;
+ if ( success ) {
+ ((GameListAdapter.ClickHandler)view).longClicked();
+ }
+ return success;
+ }
+
// DBUtils.DBChangeListener interface
public void gameSaved( final long rowid, final boolean countChanged )
{
@@ -446,33 +482,47 @@ public class GamesList extends XWExpandableListActivity
}
// GameListAdapter.LoadItemCB interface
- public void itemClicked( long rowid, GameSummary summary )
+ public void itemClicked( Object clicked, GameSummary summary )
{
// We need a way to let the user get back to the basic-config
// dialog in case it was dismissed. That way it to check for
// an empty room name.
- if ( !m_gameLaunched ) {
- showNotAgainDlgThen( R.string.not_again_newselect,
- R.string.key_notagain_newselect,
- GamesActions.OPEN_GAME.ordinal(),
- rowid, summary );
+ if ( clicked instanceof GameListItem ) {
+ if ( !m_gameLaunched ) {
+ long rowid = ((GameListItem)clicked).getRowID();
+ showNotAgainDlgThen( R.string.not_again_newselect,
+ R.string.key_notagain_newselect,
+ GamesActions.OPEN_GAME.ordinal(),
+ rowid, summary );
+ }
}
}
- public void itemToggled( long rowid, boolean selected )
+ public void itemToggled( Object toggled, boolean selected )
{
- int countBefore = m_selected.size();
- if ( selected ) {
- m_selected.add( rowid );
- } else {
- m_selected.remove( rowid );
+ if ( toggled instanceof GameListItem ) {
+ long rowid = ((GameListItem)toggled).getRowID();
+ if ( selected ) {
+ m_selectedRows.add( rowid );
+ clearSelectedGroups();
+ } else {
+ m_selectedRows.remove( rowid );
+ }
+ } else if ( toggled instanceof GameListGroup ) {
+ int position = ((GameListGroup)toggled).getGroupPosition();
+ if ( selected ) {
+ m_selectedGroups.add( position );
+ clearSelectedRows();
+ } else {
+ m_selectedGroups.remove( position );
+ }
}
Utils.invalidateOptionsMenuIf( this );
}
public boolean getSelected( long rowid )
{
- return m_selected.contains( rowid );
+ return m_selectedRows.contains( rowid );
}
// BTService.MultiEventListener interface
@@ -548,77 +598,13 @@ public class GamesList extends XWExpandableListActivity
@Override
public void onBackPressed() {
- if ( 0 == m_selected.size() ) {
+ if ( 0 == m_selectedRows.size() ) {
super.onBackPressed();
} else {
- clearSelected();
+ clearSelectedRows();
}
}
- @Override
- public void onCreateContextMenu( ContextMenu menu, View view,
- ContextMenuInfo menuInfo )
- {
- ExpandableListView.ExpandableListContextMenuInfo info
- = (ExpandableListView.ExpandableListContextMenuInfo)menuInfo;
- long packedPos = info.packedPosition;
- int childPos = ExpandableListView.getPackedPositionChild( packedPos );
-
- String name;
- if ( 0 <= childPos ) { // game case
- MenuInflater inflater = getMenuInflater();
- inflater.inflate( R.menu.games_list_item_menu, menu );
-
- long rowid = m_adapter.getRowIDFor( packedPos );
- name = GameUtils.getName( this, rowid );
- } else { // group case
- MenuInflater inflater = getMenuInflater();
- inflater.inflate( R.menu.games_list_group_menu, menu );
-
- int pos = ExpandableListView.getPackedPositionGroup( packedPos );
- name = m_adapter.groupNames()[pos];
-
- if ( 0 == pos ) {
- Utils.setItemEnabled( menu, R.id.list_group_moveup, false );
- }
- if ( pos + 1 == m_adapter.getGroupCount() ) {
- Utils.setItemEnabled( menu, R.id.list_group_movedown, false );
- }
- if ( XWPrefs.getDefaultNewGameGroup( this )
- == m_adapter.getGroupIDFor( pos ) ) {
- Utils.setItemEnabled( menu, R.id.list_group_default, false );
- Utils.setItemEnabled( menu, R.id.list_group_delete, false );
- }
- }
- menu.setHeaderTitle( getString( R.string.game_item_menu_titlef,
- name ) );
- }
-
- @Override
- public boolean onContextItemSelected( MenuItem item )
- {
- ExpandableListContextMenuInfo info;
- try {
- info = (ExpandableListContextMenuInfo)item.getMenuInfo();
- } catch (ClassCastException cce) {
- DbgUtils.loge( cce );
- return false;
- }
-
- long packedPos = info.packedPosition;
- int childPos = ExpandableListView.getPackedPositionChild( packedPos );
- int groupPos = ExpandableListView.getPackedPositionGroup(packedPos);
- int menuID = item.getItemId();
- boolean handled;
- if ( 0 <= childPos ) {
- long rowid = m_adapter.getRowIDFor( groupPos, childPos );
- handled = handleGameMenuItem( menuID, rowid );
- } else {
- handled = handleGroupMenuItem( menuID, groupPos );
- }
- return handled;
- } // onContextItemSelected
-
@Override
public boolean onCreateOptionsMenu( Menu menu )
{
@@ -631,22 +617,38 @@ public class GamesList extends XWExpandableListActivity
@Override
public boolean onPrepareOptionsMenu( Menu menu )
{
+ int nGamesSelected = m_selectedRows.size();
+ int nGroupsSelected = m_selectedGroups.size();
+ boolean nothingSelected = 0 == (nGroupsSelected + nGamesSelected);
+ Assert.assertTrue( 0 == nGamesSelected || 0 == nGroupsSelected );
+
boolean visible = XWPrefs.getDebugEnabled( this );
for ( int id : DEBUGITEMS ) {
- MenuItem item = menu.findItem( id );
- item.setVisible( visible );
+ Utils.setItemVisible( menu, id, nothingSelected && visible );
}
if ( visible && !DBUtils.gameDBExists( this ) ) {
- MenuItem item = menu.findItem( R.id.gamel_menu_loaddb );
- item.setVisible( false );
+ Utils.setItemVisible( menu, R.id.gamel_menu_loaddb, false );
}
- int nSelected = m_selected.size();
+ for ( int id : NOSEL_ITEMS ) {
+ Utils.setItemVisible( menu, id, nothingSelected );
+ }
+ for ( int id : ONEGAME_ITEMS ) {
+ Utils.setItemVisible( menu, id, 1 == nGamesSelected );
+ }
+ for ( int id : ONEGROUP_ITEMS ) {
+ Utils.setItemVisible( menu, id, 1 == nGroupsSelected );
+ }
- Utils.setItemVisible( menu, R.id.gamel_menu_newgame, 0 == nSelected );
- Utils.setItemVisible( menu, R.id.gamel_menu_delete, 0 < nSelected );
- Utils.setItemVisible( menu, R.id.listl_item_config, 1 == nSelected );
+ // Multiples can be deleted
+ Utils.setItemVisible( menu, R.id.gamel_menu_delete,
+ 0 < nGamesSelected );
+ Utils.setItemVisible( menu, R.id.list_group_delete,
+ 0 < nGroupsSelected );
+ // multiple games can be regrouped/reset
+ Utils.setItemVisible( menu, R.id.list_item_move, 0 < nGroupsSelected );
+ Utils.setItemVisible( menu, R.id.list_item_reset, 0 < nGroupsSelected );
return super.onPrepareOptionsMenu( menu );
}
@@ -665,13 +667,13 @@ public class GamesList extends XWExpandableListActivity
break;
case R.id.listl_item_config:
- long rowid = m_selected.iterator().next();
+ long rowid = m_selectedRows.iterator().next();
GameUtils.doConfig( this, rowid, GameConfig.class );
break;
case R.id.gamel_menu_delete:
String msg = Utils.format( this, R.string.confirm_seldeletesf,
- m_selected.size() );
+ m_selectedRows.size() );
showConfirmThen( msg, R.string.button_delete,
GamesActions.DELETE_SELGAMES.ordinal() );
break;
@@ -745,61 +747,53 @@ public class GamesList extends XWExpandableListActivity
m_rowid = rowid;
- if ( R.id.list_item_delete == menuID
- || R.id.list_item_config == menuID ) {
- showOKOnlyDialog( "This menu item is going away soon. Please select"
- + " games by tapping the left icons then use"
- + " action bar icons or the screen menu to operate"
- + " on the selection." );
- } else {
- if ( checkWarnNoDict( m_rowid ) ) {
- switch ( menuID ) {
- case R.id.list_item_reset:
- showConfirmThen( R.string.confirm_reset,
- R.string.button_reset,
- GamesActions.RESET_GAME.ordinal() );
- break;
- case R.id.list_item_rename:
- showDialog( RENAME_GAME );
- break;
- case R.id.list_item_move:
- if ( 1 >= m_adapter.getGroupCount() ) {
- showOKOnlyDialog( R.string.no_move_onegroup );
- } else {
- showDialog( CHANGE_GROUP );
- }
- break;
- case R.id.list_item_new_from:
- showNotAgainDlgThen( R.string.not_again_newfrom,
- R.string.key_notagain_newfrom,
- GamesActions.NEW_FROM.ordinal() );
- break;
-
- case R.id.list_item_copy:
- GameSummary summary = DBUtils.getSummary( this, m_rowid );
- if ( summary.inNetworkGame() ) {
- showOKOnlyDialog( R.string.no_copy_network );
- } else {
- byte[] stream = GameUtils.savedGame( this, m_rowid );
- GameLock lock = GameUtils.saveNewGame( this, stream );
- DBUtils.saveSummary( this, lock, summary );
- lock.unlock();
- }
- break;
-
- // These require some notion of predictable sort order.
- // Maybe put off until I'm using a db?
- // case R.id.list_item_hide:
- // case R.id.list_item_move_up:
- // case R.id.list_item_move_down:
- // case R.id.list_item_move_to_top:
- // case R.id.list_item_move_to_bottom:
- // Utils.notImpl( this );
- // break;
- default:
- handled = false;
- break;
+ if ( checkWarnNoDict( m_rowid ) ) {
+ switch ( menuID ) {
+ case R.id.list_item_reset:
+ showConfirmThen( R.string.confirm_reset,
+ R.string.button_reset,
+ GamesActions.RESET_GAME.ordinal() );
+ break;
+ case R.id.list_item_rename:
+ showDialog( RENAME_GAME );
+ break;
+ case R.id.list_item_move:
+ if ( 1 >= m_adapter.getGroupCount() ) {
+ showOKOnlyDialog( R.string.no_move_onegroup );
+ } else {
+ showDialog( CHANGE_GROUP );
}
+ break;
+ case R.id.list_item_new_from:
+ showNotAgainDlgThen( R.string.not_again_newfrom,
+ R.string.key_notagain_newfrom,
+ GamesActions.NEW_FROM.ordinal() );
+ break;
+
+ case R.id.list_item_copy:
+ GameSummary summary = DBUtils.getSummary( this, m_rowid );
+ if ( summary.inNetworkGame() ) {
+ showOKOnlyDialog( R.string.no_copy_network );
+ } else {
+ byte[] stream = GameUtils.savedGame( this, m_rowid );
+ GameLock lock = GameUtils.saveNewGame( this, stream );
+ DBUtils.saveSummary( this, lock, summary );
+ lock.unlock();
+ }
+ break;
+
+ // These require some notion of predictable sort order.
+ // Maybe put off until I'm using a db?
+ // case R.id.list_item_hide:
+ // case R.id.list_item_move_up:
+ // case R.id.list_item_move_down:
+ // case R.id.list_item_move_to_top:
+ // case R.id.list_item_move_to_bottom:
+ // Utils.notImpl( this );
+ // break;
+ default:
+ handled = false;
+ break;
}
}
@@ -1076,11 +1070,11 @@ public class GamesList extends XWExpandableListActivity
private void deleteSelected()
{
- for ( Iterator iter = m_selected.iterator(); iter.hasNext(); ) {
+ for ( Iterator iter = m_selectedRows.iterator(); iter.hasNext(); ) {
long rowid = iter.next();
GameUtils.deleteGame( this, rowid, false );
}
- m_selected.clear();
+ m_selectedRows.clear();
Utils.invalidateOptionsMenuIf( this );
NetUtils.informOfDeaths( this );
}
@@ -1095,12 +1089,21 @@ public class GamesList extends XWExpandableListActivity
return madeGame;
}
- private void clearSelected()
+ private void clearSelectedRows()
{
// clear any selection
- if ( 0 < m_selected.size() ) {
- m_adapter.clearSelected( m_selected );
- m_selected.clear();
+ if ( 0 < m_selectedRows.size() ) {
+ m_adapter.clearSelectedRows( m_selectedRows );
+ m_selectedRows.clear();
+ }
+ }
+
+ private void clearSelectedGroups()
+ {
+ // clear any selection
+ if ( 0 < m_selectedGroups.size() ) {
+ m_adapter.clearSelectedGroups( m_selectedGroups );
+ m_selectedGroups.clear();
}
}
@@ -1119,7 +1122,7 @@ public class GamesList extends XWExpandableListActivity
if ( !m_gameLaunched ) {
m_gameLaunched = true;
GameUtils.launchGame( this, rowid, invited );
- clearSelected();
+ clearSelectedRows();
}
}
From 4fe402e6365d73a310f4dc8ca45de7da3672eb7d Mon Sep 17 00:00:00 2001
From: Eric House
Date: Fri, 18 Oct 2013 21:33:33 -0700
Subject: [PATCH 030/240] pass parent, not self
---
.../XWords4/src/org/eehouse/android/xw4/GameListItem.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java
index 5a59909b0..60b8038a9 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java
@@ -80,7 +80,7 @@ public class GameListItem extends LinearLayout
if ( m_selected ) {
toggleSelected();
} else if ( null != m_summary ) {
- m_cb.itemClicked( this, m_summary );
+ m_cb.itemClicked( GameListItem.this, m_summary );
}
}
} );
From 07bfc3de374eee000eb7f2af8413229b7575bc6d Mon Sep 17 00:00:00 2001
From: Eric House
Date: Fri, 18 Oct 2013 21:37:13 -0700
Subject: [PATCH 031/240] snapshot: handle more menus. (Add game seems broken,
though)
---
.../org/eehouse/android/xw4/GamesList.java | 215 +++++++++---------
1 file changed, 106 insertions(+), 109 deletions(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
index cc4a09eec..1f4e1e7f6 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
@@ -565,7 +565,8 @@ public class GamesList extends XWExpandableListActivity
doSyncMenuitem();
break;
case NEW_FROM:
- long newid = GameUtils.dupeGame( GamesList.this, m_rowid );
+ long curID = (Long)params[0];
+ long newid = GameUtils.dupeGame( GamesList.this, curID );
if ( null != m_adapter ) {
m_adapter.inval( newid );
}
@@ -646,9 +647,10 @@ public class GamesList extends XWExpandableListActivity
0 < nGamesSelected );
Utils.setItemVisible( menu, R.id.list_group_delete,
0 < nGroupsSelected );
- // multiple games can be regrouped/reset
- Utils.setItemVisible( menu, R.id.list_item_move, 0 < nGroupsSelected );
- Utils.setItemVisible( menu, R.id.list_item_reset, 0 < nGroupsSelected );
+
+ // multiple games can be regrouped/reset. (Later....)
+ Utils.setItemVisible( menu, R.id.list_item_move, 1 == nGamesSelected );
+ Utils.setItemVisible( menu, R.id.list_item_reset, 1 == nGamesSelected );
return super.onPrepareOptionsMenu( menu );
}
@@ -656,8 +658,18 @@ public class GamesList extends XWExpandableListActivity
public boolean onOptionsItemSelected( MenuItem item )
{
boolean handled = true;
+ int groupPos = getSelGroupPos();
+ long groupID = -1;
+ if ( 0 <= groupPos ) {
+ m_adapter.getGroupIDFor( groupPos );
+ }
+ long selRowID = getSelRowID();
- switch (item.getItemId()) {
+ if ( 0 <= selRowID && !checkWarnNoDict( selRowID ) ) {
+ return true; // FIX THIS!!!
+ }
+
+ switch ( item.getItemId() ) {
case R.id.gamel_menu_newgame:
startNewGameActivity();
break;
@@ -712,10 +724,78 @@ public class GamesList extends XWExpandableListActivity
DBUtils.saveDB( this );
break;
- // case R.id.gamel_menu_view_hidden:
- // Utils.notImpl( this );
- // break;
+ // Game menus
+ case R.id.list_item_move:
+ if ( 1 >= m_adapter.getGroupCount() ) {
+ showOKOnlyDialog( R.string.no_move_onegroup );
+ } else {
+ m_rowid = selRowID;
+ showDialog( CHANGE_GROUP );
+ }
+ break;
+ case R.id.list_item_new_from:
+ showNotAgainDlgThen( R.string.not_again_newfrom,
+ R.string.key_notagain_newfrom,
+ GamesActions.NEW_FROM.ordinal(), selRowID );
+ break;
+ case R.id.list_item_copy:
+ GameSummary summary = DBUtils.getSummary( this, selRowID );
+ if ( summary.inNetworkGame() ) {
+ showOKOnlyDialog( R.string.no_copy_network );
+ } else {
+ byte[] stream = GameUtils.savedGame( this, selRowID );
+ GameLock lock = GameUtils.saveNewGame( this, stream );
+ DBUtils.saveSummary( this, lock, summary );
+ lock.unlock();
+ }
+ break;
+
+ case R.id.list_item_reset:
+ m_rowid = selRowID;
+ showConfirmThen( R.string.confirm_reset,
+ R.string.button_reset,
+ GamesActions.RESET_GAME.ordinal() );
+ break;
+
+ case R.id.list_item_rename:
+ m_rowid = selRowID;
+ showDialog( RENAME_GAME );
+ break;
+
+ // Group menus
+ case R.id.list_group_delete:
+ m_groupid = groupID;
+ if ( groupID == XWPrefs.getDefaultNewGameGroup( this ) ) {
+ showOKOnlyDialog( R.string.cannot_delete_default_group );
+ } else {
+ msg = getString( R.string.group_confirm_del );
+ int nGames = m_adapter.getChildrenCount( groupPos );
+ if ( 0 < nGames ) {
+ msg += getString( R.string.group_confirm_delf, nGames );
+ }
+ showConfirmThen( msg, GamesActions.DELETE_GROUP.ordinal() );
+ }
+ break;
+ case R.id.list_group_default:
+ XWPrefs.setDefaultNewGameGroup( this, groupID );
+ break;
+ case R.id.list_group_rename:
+ m_groupid = groupID;
+ showDialog( RENAME_GROUP );
+ break;
+ case R.id.list_group_moveup:
+ if ( m_adapter.moveGroup( groupID, -1 ) ) {
+ onContentChanged();
+ }
+ break;
+ case R.id.list_group_movedown:
+ if ( m_adapter.moveGroup( groupID, 1 ) ) {
+ onContentChanged();
+ }
+ break;
+
default:
+ Assert.fail();
handled = false;
}
@@ -740,107 +820,6 @@ public class GamesList extends XWExpandableListActivity
} );
}
- private boolean handleGameMenuItem( int menuID, long rowid )
- {
- boolean handled = true;
- DialogInterface.OnClickListener lstnr;
-
- m_rowid = rowid;
-
- if ( checkWarnNoDict( m_rowid ) ) {
- switch ( menuID ) {
- case R.id.list_item_reset:
- showConfirmThen( R.string.confirm_reset,
- R.string.button_reset,
- GamesActions.RESET_GAME.ordinal() );
- break;
- case R.id.list_item_rename:
- showDialog( RENAME_GAME );
- break;
- case R.id.list_item_move:
- if ( 1 >= m_adapter.getGroupCount() ) {
- showOKOnlyDialog( R.string.no_move_onegroup );
- } else {
- showDialog( CHANGE_GROUP );
- }
- break;
- case R.id.list_item_new_from:
- showNotAgainDlgThen( R.string.not_again_newfrom,
- R.string.key_notagain_newfrom,
- GamesActions.NEW_FROM.ordinal() );
- break;
-
- case R.id.list_item_copy:
- GameSummary summary = DBUtils.getSummary( this, m_rowid );
- if ( summary.inNetworkGame() ) {
- showOKOnlyDialog( R.string.no_copy_network );
- } else {
- byte[] stream = GameUtils.savedGame( this, m_rowid );
- GameLock lock = GameUtils.saveNewGame( this, stream );
- DBUtils.saveSummary( this, lock, summary );
- lock.unlock();
- }
- break;
-
- // These require some notion of predictable sort order.
- // Maybe put off until I'm using a db?
- // case R.id.list_item_hide:
- // case R.id.list_item_move_up:
- // case R.id.list_item_move_down:
- // case R.id.list_item_move_to_top:
- // case R.id.list_item_move_to_bottom:
- // Utils.notImpl( this );
- // break;
- default:
- handled = false;
- break;
- }
- }
-
- return handled;
- } // handleGameMenuItem
-
- private boolean handleGroupMenuItem( int menuID, int groupPos )
- {
- boolean handled = true;
- m_groupid = m_adapter.getGroupIDFor( groupPos );
- switch ( menuID ) {
- case R.id.list_group_delete:
- if ( m_groupid == XWPrefs.getDefaultNewGameGroup( this ) ) {
- showOKOnlyDialog( R.string.cannot_delete_default_group );
- } else {
- String msg = getString( R.string.group_confirm_del );
- int nGames = m_adapter.getChildrenCount( groupPos );
- if ( 0 < nGames ) {
- msg += getString( R.string.group_confirm_delf, nGames );
- }
- showConfirmThen( msg, GamesActions.DELETE_GROUP.ordinal() );
- }
- break;
- case R.id.list_group_rename:
- showDialog( RENAME_GROUP );
- break;
- case R.id.list_group_default:
- XWPrefs.setDefaultNewGameGroup( this, m_groupid );
- break;
-
- case R.id.list_group_moveup:
- if ( m_adapter.moveGroup( m_groupid, -1 ) ) {
- onContentChanged();
- }
- break;
- case R.id.list_group_movedown:
- if ( m_adapter.moveGroup( m_groupid, 1 ) ) {
- onContentChanged();
- }
- break;
-
- default:
- handled = false;
- }
- return handled;
- }
-
private boolean checkWarnNoDict( NetLaunchInfo nli )
{
// check that we have the dict required
@@ -1171,6 +1150,24 @@ public class GamesList extends XWExpandableListActivity
}
}
+ private long getSelRowID()
+ {
+ long result = -1;
+ if ( 1 == m_selectedRows.size() ) {
+ result = m_selectedRows.iterator().next();
+ }
+ return result;
+ }
+
+ private int getSelGroupPos()
+ {
+ int result = -1;
+ if ( 1 == m_selectedGroups.size() ) {
+ result = m_selectedGroups.iterator().next();
+ }
+ return result;
+ }
+
public static void onGameDictDownload( Context context, Intent intent )
{
intent.setClass( context, GamesList.class );
From d838151c0c824dfdd24e0389c1b3f0d9d95971ab Mon Sep 17 00:00:00 2001
From: Eric House
Date: Fri, 18 Oct 2013 22:36:45 -0700
Subject: [PATCH 032/240] modify build system to generate .png files from .svg
files, with one .svg as an example.
---
xwords4/android/XWords4/.gitignore | 1 +
xwords4/android/XWords4/build.xml | 6 ++++
xwords4/android/XWords4/img_src/new_group.svg | 20 +++++++++++
.../XWords4/res/menu/games_list_menu.xml | 3 +-
xwords4/android/scripts/images.mk | 20 +++++++++++
xwords4/android/scripts/mkimages.sh | 34 +++++++++++++++++++
6 files changed, 83 insertions(+), 1 deletion(-)
create mode 100644 xwords4/android/XWords4/img_src/new_group.svg
create mode 100644 xwords4/android/scripts/images.mk
create mode 100755 xwords4/android/scripts/mkimages.sh
diff --git a/xwords4/android/XWords4/.gitignore b/xwords4/android/XWords4/.gitignore
index 76f8d9fe4..b35181c70 100644
--- a/xwords4/android/XWords4/.gitignore
+++ b/xwords4/android/XWords4/.gitignore
@@ -6,3 +6,4 @@ gen
libs
proguard.cfg
obj
+res/drawable*/*gen.png
diff --git a/xwords4/android/XWords4/build.xml b/xwords4/android/XWords4/build.xml
index 7344cfb12..66a05bf24 100644
--- a/xwords4/android/XWords4/build.xml
+++ b/xwords4/android/XWords4/build.xml
@@ -54,6 +54,10 @@
+
+
+
+
@@ -65,6 +69,8 @@
+
+
+
+
diff --git a/xwords4/android/XWords4/res/menu/games_list_menu.xml b/xwords4/android/XWords4/res/menu/games_list_menu.xml
index 7f1ac84dc..f11324876 100644
--- a/xwords4/android/XWords4/res/menu/games_list_menu.xml
+++ b/xwords4/android/XWords4/res/menu/games_list_menu.xml
@@ -25,7 +25,8 @@
/>
Date: Fri, 18 Oct 2013 22:40:53 -0700
Subject: [PATCH 033/240] replace checked-in images with another generated
---
xwords4/android/XWords4/img_src/content_new.svg | 11 +++++++++++
.../XWords4/res/drawable-hdpi/content_new.png | Bin 1142 -> 0 bytes
.../XWords4/res/drawable-mdpi/content_new.png | Bin 1090 -> 0 bytes
.../XWords4/res/drawable-xhdpi/content_new.png | Bin 1221 -> 0 bytes
.../android/XWords4/res/menu/games_list_menu.xml | 2 +-
5 files changed, 12 insertions(+), 1 deletion(-)
create mode 100644 xwords4/android/XWords4/img_src/content_new.svg
delete mode 100644 xwords4/android/XWords4/res/drawable-hdpi/content_new.png
delete mode 100644 xwords4/android/XWords4/res/drawable-mdpi/content_new.png
delete mode 100644 xwords4/android/XWords4/res/drawable-xhdpi/content_new.png
diff --git a/xwords4/android/XWords4/img_src/content_new.svg b/xwords4/android/XWords4/img_src/content_new.svg
new file mode 100644
index 000000000..2ad13b330
--- /dev/null
+++ b/xwords4/android/XWords4/img_src/content_new.svg
@@ -0,0 +1,11 @@
+
+
+
diff --git a/xwords4/android/XWords4/res/drawable-hdpi/content_new.png b/xwords4/android/XWords4/res/drawable-hdpi/content_new.png
deleted file mode 100644
index ad8ada6bdfa0d08e96c96ef2e8fc6656efc31f34..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 1142
zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpTC$r9IylHmNblJdl&R0hYC{G?O`
z&)mfH)S%SFl*+=BsWuD@%qp275hW46K32*3xq68pHF_1f1wh>l3^w)^1&PVosU-?Y
zsp*+{wo31J?^jaDOtDo8H}y5}EpSfF$n>ZxN)4{^3rViZPPR-@vbR&PsjvbXkegbP
zs8ErclUHn2VXFi-*9yo63F|8hm3bwJ6}oxF$}kgLQj3#|G7CyF^YauyCMG83
zmzLNn0bL65LT&-v*t}wBFaZNhzap_f-%!s00+w{G(#^lGsViy(A34k#nsr<$-vFf(ACh=#L&{!#L3yw
z&D7A`#K{n**Cju>G&eP`1g19yq1ObbUQlAlEdbi=l3J8mmYU*Ll%J~r_Ow+dZnqfX
zG!Lpb1-Dy_aO%|uIz}H9wMbD769T3m5EGtofgE_!Pt60S_ab1z4q0f*3(OQRJY5_^
zDsH`*smOQ8K%~vwiGeZv-~+WZOSZ=B1v}ZkA5bcg&|!bTpuiCPPfc~@%_GO8r_|{G
zoD{$H=e4|Q-{R*n(~6#QC^RrIg@$%jp0M7yea4df9|g;jBtNOTHZI@cdUHutO?01w6Wim;H*=-YJSF-6)vTXc4;gaVh((-iXfZZqW+vo+u8V
zBVlX)f0A7h-RPgQQ0YmtMO4nhGu#pz1)d)`lqGk1{e=6U^-ld^7jR%;WC0UGRzbha
uDrBCXJI|cEda|~f-cO)#)FnCz_QqW8&^GYqz4zz;`~83ak9Vf8
zx4W*Uv4&xox>S#xraSOfbtV0~#o|x8Z6}E=>Bqw)uR4f{>Uao&l&OxOG*b2P{rfkEPKZeOOA%$<j@
z^LZ}6pTo`w4@FVrg&-dc2B=5C9k+;D2w3i}5`&Cf%`t3ZU<-JR>JT0y5tb_blY(il
z(OT|mnP|cIf@<@S6TFm4j*9YsSJPbcc1aqo>-{IOn;EwepGGbob2Qqx;ay%RTZ%hK
zCD_See5_Q(z8ogl&0!nF`@s
zOUuihPr5ejIqj>wx@l(KH_-K|>gm9j#>cTqe|Blr0qHF4)vzWG;HqqD
zqVvGwmW%!Yd3y81t{2s)w*FStmj!&PX`yEReb>^-2^BmSXTCMaTaw^j_vC%M@47G9
zT34UGGFWk8hj0G!t%i!vJw2y{53_rtJKs6J+HlLg*HgK-KC0lFQr&V^Jikcta~K>v
lH-F>k;f_ny-P3+%!$xNJBes5e+wwl|Ri_fY^6l8*)Nc=SU$6iG
diff --git a/xwords4/android/XWords4/res/drawable-xhdpi/content_new.png b/xwords4/android/XWords4/res/drawable-xhdpi/content_new.png
deleted file mode 100644
index 23b9a1c1857791d618ce961f019585acf47ed1c5..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 1221
zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=k|nMYCBgY=CFO}lsSJ)O`AMk?
zp1FzXsX?iUDV2pMQ*9U+m{l@EB1$5BeXNr6bM+EIYV;~{3xK*A7;Nk-3KEmEQ%e+*
zQqwc@Y?a>c-mj#PnPRIHZt82`Ti~3Uk?B!Ylp0*+7m{3+ootz+WN)WnQ(*-(AUCxn
zQK2F?C$HG5!d3}vt`(3C64qBz04piUwpD^SD#ABF!8yMuRl!uxKsVXI%uvD1M9IxIyg#@@$ndN=gc>^!3Zj
z%k|2Q_413-^$jg8E%gnI^o@*kfhu&1EAvVcD|GXUm0>2hq!uR^WfqiV=I1GZOiWD5
zFD$Tv3bSNU;+l1ennz|zM-B0$V)JVzP|XC=H|jx7ncO3BHWAB;NpiyW)Z+ZoqGVvir744~DzI`cN=+=uFAB-e&w+(vKt_H^esM;Afr4|esh**NZ(?$0
z9!LbN!`Ii!Gq1QLF)umQ)5TT^Xog;9W{Q=Yp{a|7i;J77lYyI|p{t>#iJ_&diIcOV
zo2j9>iIX8ruSMv>2~2MaT(7GEPQ9SSkXrz>*(J3ovn(~mttdZN0qkk3Ox$j9
z!D${;ZwgMgxVYlfs}FRHJ}7FDq8cUyOg|tdJmCU4@T8xb2Tbopz=Z9QHRk~X1Eaa8
zi(^Q|tv9!Qxegf!v_0$$aeO>+Pjj{Ty#t#&%nKghv#wC7|G@s3W%Gt0l?z)0Kk?Oc
zi)nuKlsdgd>iL{0F`)bj1}}DNopmzix@~^e@3RJL!XnFzoEvtTX|sy^CY}h?tI7Py
zaKcE4S#u9eJu>}kRr-^C=T>+9>B)~>oeO=2&+p+?Fi3E>pdO#jmsf{h^)Sw@nwUb}i8V
z%C7wR$ZLlyN)pD*a+Cf|4880>&wa#)f(I4n0Oe1ucaK-UG2dP67+QSb6Mw<&;$U2b(L5E
diff --git a/xwords4/android/XWords4/res/menu/games_list_menu.xml b/xwords4/android/XWords4/res/menu/games_list_menu.xml
index f11324876..612100976 100644
--- a/xwords4/android/XWords4/res/menu/games_list_menu.xml
+++ b/xwords4/android/XWords4/res/menu/games_list_menu.xml
@@ -3,7 +3,7 @@
-
+
@@ -69,7 +70,9 @@
-
+
Date: Mon, 21 Oct 2013 18:52:12 -0700
Subject: [PATCH 044/240] move .o files into an obj directory
---
xwords4/relay/Makefile | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/xwords4/relay/Makefile b/xwords4/relay/Makefile
index 397e485f5..f2eab8ee0 100644
--- a/xwords4/relay/Makefile
+++ b/xwords4/relay/Makefile
@@ -43,7 +43,7 @@ SRC = \
GITINFO = gitversion.txt
HASH=$(shell git describe)
-OBJ = $(patsubst %.cpp,%.o,$(SRC))
+OBJ = $(patsubst %.cpp,obj/%.o,$(SRC))
#LDFLAGS += -pthread -g -lmcheck $(STATIC)
LDFLAGS += -pthread -g $(STATIC)
LDFLAGS += -L$(shell pg_config --libdir)
@@ -68,6 +68,10 @@ memdebug all: xwrelay rq
xwrelay: $(OBJ)
$(CXX) $(CPPFLAGS) -o $@ $^ -lpq $(LDFLAGS)
+obj/%.o: %.cpp
+ @mkdir -p obj
+ $(CXX) -c $(CPPFLAGS) -o $@ $^
+
rq: rq.c
clean:
From d96b092b42e65ad6d7035a394dfa27035bc50c76 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Mon, 21 Oct 2013 20:38:07 -0700
Subject: [PATCH 045/240] fix crash on tiny-screen devices: rename menu to
match change on other devices' menu
---
xwords4/android/XWords4/res/menu-small/board_menu.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/xwords4/android/XWords4/res/menu-small/board_menu.xml b/xwords4/android/XWords4/res/menu-small/board_menu.xml
index d5fe70b11..66746f946 100644
--- a/xwords4/android/XWords4/res/menu-small/board_menu.xml
+++ b/xwords4/android/XWords4/res/menu-small/board_menu.xml
@@ -70,7 +70,7 @@
android:title="@string/board_menu_game_left" />
-
From bd902bfc12e1834d510908e4773ac4d3d54bfd3d Mon Sep 17 00:00:00 2001
From: Eric House
Date: Mon, 21 Oct 2013 20:39:21 -0700
Subject: [PATCH 046/240] ignore dawg exporting files
---
xwords4/dawg/.gitignore | 2 ++
1 file changed, 2 insertions(+)
diff --git a/xwords4/dawg/.gitignore b/xwords4/dawg/.gitignore
index 4935774d4..4f72876de 100644
--- a/xwords4/dawg/.gitignore
+++ b/xwords4/dawg/.gitignore
@@ -5,3 +5,5 @@
*.dict
*.dict.gz
dict2dawg
+byodfiles.tar
+byodfiles.tgz
From 1bb0c49c711b623b71febf2aec24bd133aebc7f7 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Mon, 21 Oct 2013 20:44:47 -0700
Subject: [PATCH 047/240] assert that we don't use an unprepared menu.
---
.../src/org/eehouse/android/xw4/GamesList.java | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
index fb557bd40..41ef46f3a 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
@@ -129,6 +129,7 @@ public class GamesList extends XWExpandableListActivity
private NetLaunchInfo m_netLaunchInfo;
private GameNamer m_namer;
private boolean m_gameLaunched = false;
+ private boolean m_menuPrepared;
private HashSet m_selectedGames;
private HashSet m_selectedGroups;
@@ -617,14 +618,10 @@ public class GamesList extends XWExpandableListActivity
@Override
public boolean onPrepareOptionsMenu( Menu menu )
{
- boolean show;
-
int nGamesSelected = m_selectedGames.size();
int nGroupsSelected = m_selectedGroups.size();
- if ( 0 < nGamesSelected && 0 < nGroupsSelected ) {
- DbgUtils.logf( "onPrepareOptionsMenu: incomplete so bailing" );
- show = false;
- } else {
+ m_menuPrepared = 0 == nGamesSelected || 0 == nGroupsSelected;
+ if ( m_menuPrepared ) {
boolean nothingSelected = 0 == (nGroupsSelected + nGamesSelected);
boolean visible = XWPrefs.getDebugEnabled( this );
@@ -681,13 +678,17 @@ public class GamesList extends XWExpandableListActivity
Utils.setItemVisible( menu, R.id.list_item_move, 1 == nGamesSelected );
Utils.setItemVisible( menu, R.id.list_item_reset, 1 == nGamesSelected );
- show = super.onPrepareOptionsMenu( menu );
+ m_menuPrepared = super.onPrepareOptionsMenu( menu );
+ } else {
+ DbgUtils.logf( "onPrepareOptionsMenu: incomplete so bailing" );
}
- return show;
+ return m_menuPrepared;
}
public boolean onOptionsItemSelected( MenuItem item )
{
+ Assert.assertTrue( m_menuPrepared );
+
boolean handled = true;
int groupPos = getSelGroupPos();
long groupID = -1;
From 8f8fd22c7fb35e45a94ec41720c43eb13be39a66 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Tue, 22 Oct 2013 07:00:36 -0700
Subject: [PATCH 048/240] make strings consistent
---
xwords4/android/XWords4/res/values/strings.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml
index 77cd644b2..94a440cae 100644
--- a/xwords4/android/XWords4/res/values/strings.xml
+++ b/xwords4/android/XWords4/res/values/strings.xml
@@ -2128,9 +2128,9 @@
New gamesAre you sure you want to delete
- this group?
+ the selected group?
Are you sure you want to delete
- these groups?
+ the selected groups?
\u0020(It contains %d game[s],
which will also be deleted.)\u0020(They contains %d game[s],
From 8c5cd9ebe37f8da48fa17128791304c49e180e21 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Tue, 22 Oct 2013 07:02:49 -0700
Subject: [PATCH 049/240] store selected groups by id rather than position,
fixing problems like clearing the selection after moving a group
---
.../eehouse/android/xw4/GameListAdapter.java | 17 ++++---
.../eehouse/android/xw4/GameListGroup.java | 10 +++-
.../org/eehouse/android/xw4/GamesList.java | 51 ++++++++++---------
3 files changed, 46 insertions(+), 32 deletions(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java
index 78f2cd2ab..c2e006612 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java
@@ -161,9 +161,9 @@ public class GameListAdapter implements ExpandableListAdapter {
deselectRows( rowids );
}
- public void clearSelectedGroups( HashSet groups )
+ public void clearSelectedGroups( HashSet groupIDs )
{
- deselectGroups( groups );
+ deselectGroups( groupIDs );
}
//////////////////////////////////////////////////////////////////////////
@@ -241,8 +241,10 @@ public class GameListAdapter implements ExpandableListAdapter {
// if ( null != convertView ) {
// DbgUtils.logf( "getGroupView gave non-null convertView" );
// }
+ long groupID = getGroupIDFor( groupPosition );
GameListGroup view =
- GameListGroup.makeForPosition( m_context, groupPosition, m_cb );
+ GameListGroup.makeForPosition( m_context, groupPosition, groupID,
+ m_cb );
if ( !isExpanded ) {
GameGroupInfo ggi = getInfoForGroup( groupPosition );
@@ -388,12 +390,13 @@ public class GameListAdapter implements ExpandableListAdapter {
}
}
- private void deselectGroups( HashSet groups )
+ private void deselectGroups( HashSet groupids )
{
- groups = (HashSet)groups.clone();
- for ( Iteratoriter = groups.iterator();
+ groupids = (HashSet)groupids.clone();
+ for ( Iteratoriter = groupids.iterator();
iter.hasNext(); ) {
- GameListGroup group = getGroupItemFor( iter.next() );
+ int pos = getGroupPosition( iter.next() );
+ GameListGroup group = getGroupItemFor( pos );
group.setSelected( false );
}
}
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListGroup.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListGroup.java
index 1ce963098..1521048fd 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListGroup.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListGroup.java
@@ -31,17 +31,20 @@ public class GameListGroup extends ExpiringTextView
implements GameListAdapter.ClickHandler
{
private int m_groupPosition;
+ private long m_groupID;
private boolean m_expanded;
private GameListAdapter.LoadItemCB m_cb;
public static GameListGroup makeForPosition( Context context,
- int groupPosition,
+ int groupPosition,
+ long groupID,
GameListAdapter.LoadItemCB cb )
{
GameListGroup result =
(GameListGroup)Utils.inflate( context, R.layout.game_list_group );
result.m_cb = cb;
result.m_groupPosition = groupPosition;
+ result.m_groupID = groupID;
return result;
}
@@ -60,6 +63,11 @@ public class GameListGroup extends ExpiringTextView
return m_groupPosition;
}
+ public long getGroupID()
+ {
+ return m_groupID;
+ }
+
public void setSelected( boolean selected )
{
// If new value and state not in sync, force change in state
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
index 41ef46f3a..4a2bfb35a 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
@@ -87,8 +87,8 @@ public class GamesList extends XWExpandableListActivity
RESET_GAME,
SYNC_MENU,
NEW_FROM,
- DELETE_GROUPS,
DELETE_GAMES,
+ DELETE_GROUPS,
OPEN_GAME
};
private static final int[] DEBUGITEMS = {
@@ -131,7 +131,7 @@ public class GamesList extends XWExpandableListActivity
private boolean m_gameLaunched = false;
private boolean m_menuPrepared;
private HashSet m_selectedGames;
- private HashSet m_selectedGroups;
+ private HashSet m_selectedGroupIDs;
@Override
protected Dialog onCreateDialog( int id )
@@ -361,7 +361,7 @@ public class GamesList extends XWExpandableListActivity
getBundledData( savedInstanceState );
m_selectedGames = new HashSet();
- m_selectedGroups = new HashSet();
+ m_selectedGroupIDs = new HashSet();
setContentView(R.layout.game_list);
ExpandableListView listview = getExpandableListView();
@@ -506,12 +506,12 @@ public class GamesList extends XWExpandableListActivity
m_selectedGames.remove( rowid );
}
} else if ( toggled instanceof GameListGroup ) {
- int position = ((GameListGroup)toggled).getGroupPosition();
+ long id = ((GameListGroup)toggled).getGroupID();
if ( selected ) {
- m_selectedGroups.add( position );
+ m_selectedGroupIDs.add( id );
clearSelectedGames();
} else {
- m_selectedGroups.remove( position );
+ m_selectedGroupIDs.remove( id );
}
}
Utils.invalidateOptionsMenuIf( this );
@@ -619,7 +619,7 @@ public class GamesList extends XWExpandableListActivity
public boolean onPrepareOptionsMenu( Menu menu )
{
int nGamesSelected = m_selectedGames.size();
- int nGroupsSelected = m_selectedGroups.size();
+ int nGroupsSelected = m_selectedGroupIDs.size();
m_menuPrepared = 0 == nGamesSelected || 0 == nGroupsSelected;
if ( m_menuPrepared ) {
boolean nothingSelected = 0 == (nGroupsSelected + nGamesSelected);
@@ -645,7 +645,8 @@ public class GamesList extends XWExpandableListActivity
int selGroupPos = -1;
if ( 1 == nGroupsSelected ) {
- selGroupPos = m_selectedGroups.iterator().next();
+ long id = m_selectedGroupIDs.iterator().next();
+ selGroupPos = m_adapter.getGroupPosition( id );
}
// You can't delete the default group, nor make it the default
@@ -690,6 +691,7 @@ public class GamesList extends XWExpandableListActivity
Assert.assertTrue( m_menuPrepared );
boolean handled = true;
+ boolean changeContent = false;
int groupPos = getSelGroupPos();
long groupID = -1;
if ( 0 <= groupPos ) {
@@ -750,7 +752,7 @@ public class GamesList extends XWExpandableListActivity
case R.id.gamel_menu_loaddb:
DBUtils.loadDB( this );
- onContentChanged();
+ changeContent = true;
break;
case R.id.gamel_menu_storedb:
DBUtils.saveDB( this );
@@ -800,6 +802,7 @@ public class GamesList extends XWExpandableListActivity
showOKOnlyDialog( R.string.cannot_delete_default_group );
} else {
long[] groupIDs = getSelGroupIDs();
+ Assert.assertTrue( 0 < groupIDs.length );
msg = getString( 1 == groupIDs.length ? R.string.group_confirm_del
: R.string.groups_confirm_del );
int nGames = 0;
@@ -823,14 +826,10 @@ public class GamesList extends XWExpandableListActivity
showDialog( RENAME_GROUP );
break;
case R.id.list_group_moveup:
- if ( m_adapter.moveGroup( groupID, -1 ) ) {
- onContentChanged();
- }
+ changeContent = m_adapter.moveGroup( groupID, -1 );
break;
case R.id.list_group_movedown:
- if ( m_adapter.moveGroup( groupID, 1 ) ) {
- onContentChanged();
- }
+ changeContent = m_adapter.moveGroup( groupID, 1 );
break;
default:
@@ -841,6 +840,9 @@ public class GamesList extends XWExpandableListActivity
if ( handled ) {
clearSelections();
}
+ if ( changeContent ) {
+ onContentChanged();
+ }
return handled;
}
@@ -1121,7 +1123,7 @@ public class GamesList extends XWExpandableListActivity
if ( clearSelectedGroups() ) {
inval = true;
}
- if ( !inval ) {
+ if ( inval ) {
Utils.invalidateOptionsMenuIf( this );
}
}
@@ -1141,10 +1143,10 @@ public class GamesList extends XWExpandableListActivity
private boolean clearSelectedGroups()
{
// clear any selection
- boolean needsClear = 0 < m_selectedGroups.size();
+ boolean needsClear = 0 < m_selectedGroupIDs.size();
if ( needsClear ) {
- m_adapter.clearSelectedGroups( m_selectedGroups );
- m_selectedGroups.clear();
+ m_adapter.clearSelectedGroups( m_selectedGroupIDs );
+ m_selectedGroupIDs.clear();
}
return needsClear;
}
@@ -1227,19 +1229,20 @@ public class GamesList extends XWExpandableListActivity
private int getSelGroupPos()
{
int result = -1;
- if ( 1 == m_selectedGroups.size() ) {
- result = m_selectedGroups.iterator().next();
+ if ( 1 == m_selectedGroupIDs.size() ) {
+ long id = m_selectedGroupIDs.iterator().next();
+ result = m_adapter.getGroupPosition( id );
}
return result;
}
private long[] getSelGroupIDs()
{
- long[] result = new long[m_selectedGroups.size()];
+ long[] result = new long[m_selectedGroupIDs.size()];
int ii = 0;
- for ( Iterator iter = m_selectedGroups.iterator();
+ for ( Iterator iter = m_selectedGroupIDs.iterator();
iter.hasNext(); ) {
- result[ii++] = m_adapter.getGroupIDFor( iter.next() );
+ result[ii++] = iter.next();
}
return result;
}
From 9997c43298f24ba75d4a17931461f3d556e0bfb8 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Tue, 22 Oct 2013 07:06:54 -0700
Subject: [PATCH 050/240] start new groups out expanded
---
.../android/XWords4/src/org/eehouse/android/xw4/DBUtils.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java
index afe74f862..62befe4f7 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java
@@ -1087,7 +1087,7 @@ public class DBUtils {
if ( null == gameInfo.get( name ) ) {
ContentValues values = new ContentValues();
values.put( DBHelper.GROUPNAME, name );
- values.put( DBHelper.EXPANDED, 0 );
+ values.put( DBHelper.EXPANDED, 1 );
initDB( context );
synchronized( s_dbHelper ) {
From 9ed1c21cf8555cd65437f4655eb451df5d60cf00 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Tue, 22 Oct 2013 07:40:46 -0700
Subject: [PATCH 051/240] honor selected group when creating net and sms games
too
---
.../org/eehouse/android/xw4/GameUtils.java | 66 +++++++++++++------
.../org/eehouse/android/xw4/GamesList.java | 4 +-
.../eehouse/android/xw4/NewGameActivity.java | 42 ++++++------
3 files changed, 68 insertions(+), 44 deletions(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java
index ec940e85b..30fbc9c07 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java
@@ -46,6 +46,8 @@ public class GameUtils {
public static final String INTENT_KEY_ROWID = "rowid";
public static final String INTENT_FORRESULT_ROWID = "forresult";
+ private static final long GROUPID_UNSPEC = -1;
+
public static class NoSuchGameException extends RuntimeException {
public NoSuchGameException() {
super(); // superfluous
@@ -320,12 +322,15 @@ public class GameUtils {
public static long saveNew( Context context, CurGameInfo gi )
{
- long groupID = XWPrefs.getDefaultNewGameGroup( context );
- return saveNew( context, gi, groupID );
+ return saveNew( context, gi, GROUPID_UNSPEC );
}
public static long saveNew( Context context, CurGameInfo gi, long groupID )
{
+ if ( GROUPID_UNSPEC == groupID ) {
+ groupID = XWPrefs.getDefaultNewGameGroup( context );
+ }
+
long rowid = DBUtils.ROWID_NOTFOUND;
byte[] bytes = XwJNI.gi_to_stream( gi );
if ( null != bytes ) {
@@ -336,7 +341,8 @@ public class GameUtils {
return rowid;
}
- private static long makeNewMultiGame( Context context, CommsAddrRec addr,
+ private static long makeNewMultiGame( Context context, long groupID,
+ CommsAddrRec addr,
int[] lang, String[] dict,
int nPlayersT, int nPlayersH,
String inviteID, int gameID,
@@ -359,7 +365,7 @@ public class GameUtils {
// Will need to add a setNPlayers() method to gi to make this
// work
Assert.assertTrue( gi.nPlayers == nPlayersT );
- rowid = saveNew( context, gi );
+ rowid = saveNew( context, gi, groupID );
if ( DBUtils.ROWID_NOTFOUND != rowid ) {
GameLock lock = new GameLock( rowid, true ).lock();
@@ -370,8 +376,8 @@ public class GameUtils {
return rowid;
}
- public static long makeNewNetGame( Context context, String room,
- String inviteID, int[] lang,
+ public static long makeNewNetGame( Context context, long groupID,
+ String room, String inviteID, int[] lang,
String[] dict, int nPlayersT,
int nPlayersH )
{
@@ -381,29 +387,38 @@ public class GameUtils {
CommsAddrRec addr = new CommsAddrRec( relayName, relayPort );
addr.ip_relay_invite = room;
- return makeNewMultiGame( context, addr, lang, dict, nPlayersT,
- nPlayersH, inviteID, 0, false );
+ return makeNewMultiGame( context, groupID, addr, lang, dict,
+ nPlayersT, nPlayersH, inviteID, 0, false );
}
- public static long makeNewNetGame( Context context, String room,
- String inviteID, int lang, String dict,
- int nPlayers )
+ public static long makeNewNetGame( Context context, long groupID,
+ String room, String inviteID, int lang,
+ String dict, int nPlayers )
{
int[] langarr = { lang };
String[] dictArr = { dict };
- return makeNewNetGame( context, room, inviteID, langarr, dictArr,
- nPlayers, 1 );
+ return makeNewNetGame( context, groupID, room, inviteID, langarr,
+ dictArr, nPlayers, 1 );
}
public static long makeNewNetGame( Context context, NetLaunchInfo info )
{
- return makeNewNetGame( context, info.room, info.inviteID, info.lang,
- info.dict, info.nPlayersT );
+ return makeNewNetGame( context, GROUPID_UNSPEC, info.room,
+ info.inviteID, info.lang, info.dict,
+ info.nPlayersT );
}
public static long makeNewBTGame( Context context, int gameID,
CommsAddrRec addr, int lang,
int nPlayersT, int nPlayersH )
+ {
+ return makeNewBTGame( context, GROUPID_UNSPEC, gameID, addr, lang,
+ nPlayersT, nPlayersH );
+ }
+
+ public static long makeNewBTGame( Context context, long groupID,
+ int gameID, CommsAddrRec addr, int lang,
+ int nPlayersT, int nPlayersH )
{
long rowid = -1;
int[] langa = { lang };
@@ -411,13 +426,22 @@ public class GameUtils {
if ( isHost ) {
addr = new CommsAddrRec( null, null );
}
- return makeNewMultiGame( context, addr, langa, null, nPlayersT,
- nPlayersH, null, gameID, isHost );
+ return makeNewMultiGame( context, groupID, addr, langa, null,
+ nPlayersT, nPlayersH, null, gameID, isHost );
}
public static long makeNewSMSGame( Context context, int gameID,
- CommsAddrRec addr, int lang,
- String dict, int nPlayersT,
+ CommsAddrRec addr,
+ int lang, String dict, int nPlayersT,
+ int nPlayersH )
+ {
+ return makeNewSMSGame( context, GROUPID_UNSPEC, gameID, addr,
+ lang, dict, nPlayersT, nPlayersH );
+ }
+
+ public static long makeNewSMSGame( Context context, long groupID,
+ int gameID, CommsAddrRec addr,
+ int lang, String dict, int nPlayersT,
int nPlayersH )
{
long rowid = -1;
@@ -427,8 +451,8 @@ public class GameUtils {
if ( isHost ) {
addr = new CommsAddrRec(CommsAddrRec.CommsConnType.COMMS_CONN_SMS);
}
- return makeNewMultiGame( context, addr, langa, dicta, nPlayersT,
- nPlayersH, null, gameID, isHost );
+ return makeNewMultiGame( context, groupID, addr, langa, dicta,
+ nPlayersT, nPlayersH, null, gameID, isHost );
}
public static void launchInviteActivity( Context context,
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
index 4a2bfb35a..715b96245 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
@@ -91,6 +91,7 @@ public class GamesList extends XWExpandableListActivity
DELETE_GROUPS,
OPEN_GAME
};
+
private static final int[] DEBUGITEMS = {
R.id.gamel_menu_loaddb,
R.id.gamel_menu_storedb,
@@ -987,9 +988,6 @@ public class GamesList extends XWExpandableListActivity
private void startNewGameActivity( long groupID )
{
- if ( 0 > groupID ) {
- groupID = XWPrefs.getDefaultNewGameGroup( this );
- }
NewGameActivity.startActivity( this, groupID );
}
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameActivity.java
index 16aba7711..8e865c560 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameActivity.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameActivity.java
@@ -236,8 +236,8 @@ public class NewGameActivity extends XWActivity {
m_gameID, m_gameName,
m_lang, m_dict, 2, 1 );
long rowid = GameUtils.
- makeNewSMSGame( thiz, m_gameID, null,
- m_lang, m_dict, 2, 1 );
+ makeNewSMSGame( thiz, m_groupID, m_gameID,
+ null, m_lang, m_dict, 2, 1 );
DBUtils.setName( thiz, rowid, m_gameName );
GameUtils.launchGame( thiz, rowid, true );
finish();
@@ -289,8 +289,8 @@ public class NewGameActivity extends XWActivity {
public void run() {
long rowid =
GameUtils.makeNewBTGame( NewGameActivity.this,
- gameID, null, m_lang,
- 2, 1 );
+ m_groupID, gameID, null,
+ m_lang, 2, 1 );
DBUtils.setName( NewGameActivity.this,
rowid, m_gameName );
GameUtils.launchGame( NewGameActivity.this,
@@ -328,8 +328,8 @@ public class NewGameActivity extends XWActivity {
if ( networked ) {
room = GameUtils.makeRandomID();
inviteID = GameUtils.makeRandomID();
- rowid = GameUtils.makeNewNetGame( this, room, inviteID, lang,
- dict, nPlayers, 1 );
+ rowid = GameUtils.makeNewNetGame( this, m_groupID, room, inviteID,
+ lang, dict, nPlayers, 1 );
} else {
rowid = GameUtils.saveNew( this, new CurGameInfo( this ), m_groupID );
}
@@ -350,18 +350,20 @@ public class NewGameActivity extends XWActivity {
private void makeNewBTGame( boolean useDefaults )
{
- int gameID = GameUtils.newGameID();
- if ( !useDefaults ) {
- m_newRowID = GameUtils.makeNewBTGame( NewGameActivity.this,
- gameID, null, m_lang,
- 2, 1 ); // initial defaults
- Intent intent = new Intent( this, GameConfig.class );
- intent.setAction( Intent.ACTION_EDIT );
- intent.putExtra( GameUtils.INTENT_KEY_ROWID, m_newRowID );
- intent.putExtra( GameUtils.INTENT_FORRESULT_ROWID, true );
- startActivityForResult( intent, CONFIG_FOR_BT );
- } else {
- BTInviteActivity.launchForResult( this, 1, INVITE_FOR_BT );
+ if ( XWApp.BTSUPPORTED ) {
+ int gameID = GameUtils.newGameID();
+ if ( !useDefaults ) {
+ m_newRowID = GameUtils.makeNewBTGame( NewGameActivity.this,
+ m_groupID, gameID, null,
+ m_lang, 2, 1 );
+ Intent intent = new Intent( this, GameConfig.class );
+ intent.setAction( Intent.ACTION_EDIT );
+ intent.putExtra( GameUtils.INTENT_KEY_ROWID, m_newRowID );
+ intent.putExtra( GameUtils.INTENT_FORRESULT_ROWID, true );
+ startActivityForResult( intent, CONFIG_FOR_BT );
+ } else {
+ BTInviteActivity.launchForResult( this, 1, INVITE_FOR_BT );
+ }
}
}
@@ -370,8 +372,8 @@ public class NewGameActivity extends XWActivity {
int gameID = GameUtils.newGameID();
if ( !useDefaults ) {
m_newRowID = GameUtils.makeNewSMSGame( NewGameActivity.this,
- gameID, null, m_lang,
- m_dict, 2, 1 );
+ m_groupID, gameID, null,
+ m_lang, m_dict, 2, 1 );
String name = Utils.format( this, R.string.dft_sms_namef,
gameID & 0xFFFF );
DBUtils.setName( this, m_newRowID, name );
From 3af3e4052fffb28a3cd421eaa2edb16f25b42a05 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Tue, 22 Oct 2013 08:02:38 -0700
Subject: [PATCH 052/240] rename method
---
.../org/eehouse/android/xw4/GameListAdapter.java | 16 ++++++++--------
.../src/org/eehouse/android/xw4/GamesList.java | 5 +++--
2 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java
index c2e006612..78aaa2bc1 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java
@@ -71,7 +71,7 @@ public class GameListAdapter implements ExpandableListAdapter {
m_fieldID = fieldToID( fieldName );
}
- public long[] getPositions()
+ public long[] getGroupPositions()
{
Set keys = gameInfo().keySet(); // do not modify!!!!
if ( null == m_positions || m_positions.length != keys.size() ) {
@@ -103,7 +103,7 @@ public class GameListAdapter implements ExpandableListAdapter {
{
int src = getGroupPosition( groupid );
int dest = src + moveBy;
- long[] positions = getPositions();
+ long[] positions = getGroupPositions();
boolean success = 0 <= dest && dest < positions.length;
if ( success ) {
long tmp = positions[src];
@@ -127,7 +127,7 @@ public class GameListAdapter implements ExpandableListAdapter {
public long getRowIDFor( int group, int child )
{
long rowid = DBUtils.ROWID_NOTFOUND;
- long[] rows = getRows( getPositions()[group] );
+ long[] rows = getRows( getGroupPositions()[group] );
if ( child < rows.length ) {
rowid = rows[child];
}
@@ -145,7 +145,7 @@ public class GameListAdapter implements ExpandableListAdapter {
public long getGroupIDFor( int groupPos )
{
- long id = getPositions()[groupPos];
+ long id = getGroupPositions()[groupPos];
return id;
}
@@ -284,7 +284,7 @@ public class GameListAdapter implements ExpandableListAdapter {
public int getChildrenCount( int groupPosition )
{
- return getChildrenCount( getPositions()[groupPosition] );
+ return getChildrenCount( getGroupPositions()[groupPosition] );
}
public int getChildrenCount( long groupID )
@@ -336,7 +336,7 @@ public class GameListAdapter implements ExpandableListAdapter {
public String[] groupNames()
{
HashMap info = gameInfo();
- long[] positions = getPositions();
+ long[] positions = getGroupPositions();
String[] names = new String[ positions.length ];
for ( int ii = 0; ii < names.length; ++ii ) {
names[ii] = info.get(positions[ii]).m_name;
@@ -347,7 +347,7 @@ public class GameListAdapter implements ExpandableListAdapter {
public int getGroupPosition( long groupid )
{
int result = -1;
- long[] positions = getPositions();
+ long[] positions = getGroupPositions();
for ( int pos = 0; pos < positions.length; ++pos ) {
if ( positions[pos] == groupid ) {
result = pos;
@@ -376,7 +376,7 @@ public class GameListAdapter implements ExpandableListAdapter {
private GameGroupInfo getInfoForGroup( int groupPosition )
{
- return gameInfo().get( getPositions()[groupPosition] );
+ return gameInfo().get( getGroupPositions()[groupPosition] );
}
private void deselectRows( long[] rowids )
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
index 715b96245..1125571b9 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
@@ -411,7 +411,7 @@ public class GamesList extends XWExpandableListActivity
// (TelephonyManager)getSystemService( Context.TELEPHONY_SERVICE );
// mgr.listen( m_phoneStateListener, PhoneStateListener.LISTEN_NONE );
// m_phoneStateListener = null;
- long[] positions = m_adapter.getPositions();
+ long[] positions = m_adapter.getGroupPositions();
XWPrefs.setGroupPositions( this, positions );
super.onStop();
}
@@ -771,7 +771,8 @@ public class GamesList extends XWExpandableListActivity
case R.id.list_item_new_from:
showNotAgainDlgThen( R.string.not_again_newfrom,
R.string.key_notagain_newfrom,
- GamesActions.NEW_FROM.ordinal(), selRowIDs[0] );
+ GamesActions.NEW_FROM.ordinal(),
+ selRowIDs[0] );
break;
case R.id.list_item_copy:
GameSummary summary = DBUtils.getSummary( this, selRowIDs[0] );
From 001445435b44898e1dd3626e06501bfc80037b85 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Wed, 23 Oct 2013 06:18:43 -0700
Subject: [PATCH 053/240] fix formatting
---
.../android/XWords4/src/org/eehouse/android/xw4/GameLock.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameLock.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameLock.java
index 12c080c23..210089bf7 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameLock.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameLock.java
@@ -91,7 +91,8 @@ public class GameLock {
long sleptTime = 0;
if ( XWApp.DEBUG_LOCKS ) {
- DbgUtils.logf( "lock %H (rowid:%d, maxMillis=%d)", this, m_rowid, maxMillis );
+ DbgUtils.logf( "lock %H (rowid:%d, maxMillis=%d)", this, m_rowid,
+ maxMillis );
}
for ( ; ; ) {
From 5658d9c3aec6dc0d1ca7822a745cac20103d1935 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Wed, 23 Oct 2013 06:31:03 -0700
Subject: [PATCH 054/240] make New From create dup in same group as source game
---
.../XWords4/src/org/eehouse/android/xw4/GameUtils.java | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java
index 30fbc9c07..ed8fc4793 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java
@@ -116,7 +116,8 @@ public class GameUtils {
}
if ( null == lockDest ) {
- long rowid = saveNewGame( context, gamePtr, gi );
+ long groupID = DBUtils.getGroupForGame( context, lockSrc.getRowid() );
+ long rowid = saveNewGame( context, gamePtr, gi, groupID );
lockDest = new GameLock( rowid, true ).lock();
} else {
saveGame( context, gamePtr, gi, lockDest, true );
@@ -300,10 +301,10 @@ public class GameUtils {
}
public static long saveNewGame( Context context, int gamePtr,
- CurGameInfo gi )
+ CurGameInfo gi, long groupID )
{
byte[] stream = XwJNI.game_saveToStream( gamePtr, gi );
- GameLock lock = DBUtils.saveNewGame( context, stream );
+ GameLock lock = DBUtils.saveNewGame( context, stream, groupID );
long rowid = lock.getRowid();
lock.unlock();
return rowid;
From bf15f12fe47218322333f8755b50d8bc17faf583 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Wed, 23 Oct 2013 06:38:37 -0700
Subject: [PATCH 055/240] shorten a couple of variable names
---
.../org/eehouse/android/xw4/GamesList.java | 50 +++++++++----------
1 file changed, 25 insertions(+), 25 deletions(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
index 1125571b9..2118d4068 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
@@ -131,8 +131,8 @@ public class GamesList extends XWExpandableListActivity
private GameNamer m_namer;
private boolean m_gameLaunched = false;
private boolean m_menuPrepared;
- private HashSet m_selectedGames;
- private HashSet m_selectedGroupIDs;
+ private HashSet m_selGames;
+ private HashSet m_selGroupIDs;
@Override
protected Dialog onCreateDialog( int id )
@@ -361,8 +361,8 @@ public class GamesList extends XWExpandableListActivity
getBundledData( savedInstanceState );
- m_selectedGames = new HashSet();
- m_selectedGroupIDs = new HashSet();
+ m_selGames = new HashSet();
+ m_selGroupIDs = new HashSet();
setContentView(R.layout.game_list);
ExpandableListView listview = getExpandableListView();
@@ -501,18 +501,18 @@ public class GamesList extends XWExpandableListActivity
if ( toggled instanceof GameListItem ) {
long rowid = ((GameListItem)toggled).getRowID();
if ( selected ) {
- m_selectedGames.add( rowid );
+ m_selGames.add( rowid );
clearSelectedGroups();
} else {
- m_selectedGames.remove( rowid );
+ m_selGames.remove( rowid );
}
} else if ( toggled instanceof GameListGroup ) {
long id = ((GameListGroup)toggled).getGroupID();
if ( selected ) {
- m_selectedGroupIDs.add( id );
+ m_selGroupIDs.add( id );
clearSelectedGames();
} else {
- m_selectedGroupIDs.remove( id );
+ m_selGroupIDs.remove( id );
}
}
Utils.invalidateOptionsMenuIf( this );
@@ -520,7 +520,7 @@ public class GamesList extends XWExpandableListActivity
public boolean getSelected( long rowid )
{
- return m_selectedGames.contains( rowid );
+ return m_selGames.contains( rowid );
}
// BTService.MultiEventListener interface
@@ -600,7 +600,7 @@ public class GamesList extends XWExpandableListActivity
@Override
public void onBackPressed() {
- if ( 0 == m_selectedGames.size() ) {
+ if ( 0 == m_selGames.size() ) {
super.onBackPressed();
} else {
clearSelections();
@@ -619,8 +619,8 @@ public class GamesList extends XWExpandableListActivity
@Override
public boolean onPrepareOptionsMenu( Menu menu )
{
- int nGamesSelected = m_selectedGames.size();
- int nGroupsSelected = m_selectedGroupIDs.size();
+ int nGamesSelected = m_selGames.size();
+ int nGroupsSelected = m_selGroupIDs.size();
m_menuPrepared = 0 == nGamesSelected || 0 == nGroupsSelected;
if ( m_menuPrepared ) {
boolean nothingSelected = 0 == (nGroupsSelected + nGamesSelected);
@@ -646,7 +646,7 @@ public class GamesList extends XWExpandableListActivity
int selGroupPos = -1;
if ( 1 == nGroupsSelected ) {
- long id = m_selectedGroupIDs.iterator().next();
+ long id = m_selGroupIDs.iterator().next();
selGroupPos = m_adapter.getGroupPosition( id );
}
@@ -714,7 +714,7 @@ public class GamesList extends XWExpandableListActivity
break;
case R.id.listl_item_config:
- long rowid = m_selectedGames.iterator().next();
+ long rowid = m_selGames.iterator().next();
GameUtils.doConfig( this, rowid, GameConfig.class );
break;
@@ -1130,10 +1130,10 @@ public class GamesList extends XWExpandableListActivity
private boolean clearSelectedGames()
{
// clear any selection
- boolean needsClear = 0 < m_selectedGames.size();
+ boolean needsClear = 0 < m_selGames.size();
if ( needsClear ) {
long[] rowIDs = getSelRowIDs();
- m_selectedGames.clear();
+ m_selGames.clear();
m_adapter.clearSelectedGames( rowIDs );
}
return needsClear;
@@ -1142,10 +1142,10 @@ public class GamesList extends XWExpandableListActivity
private boolean clearSelectedGroups()
{
// clear any selection
- boolean needsClear = 0 < m_selectedGroupIDs.size();
+ boolean needsClear = 0 < m_selGroupIDs.size();
if ( needsClear ) {
- m_adapter.clearSelectedGroups( m_selectedGroupIDs );
- m_selectedGroupIDs.clear();
+ m_adapter.clearSelectedGroups( m_selGroupIDs );
+ m_selGroupIDs.clear();
}
return needsClear;
}
@@ -1216,9 +1216,9 @@ public class GamesList extends XWExpandableListActivity
private long[] getSelRowIDs()
{
- long[] result = new long[m_selectedGames.size()];
+ long[] result = new long[m_selGames.size()];
int ii = 0;
- for ( Iterator iter = m_selectedGames.iterator();
+ for ( Iterator iter = m_selGames.iterator();
iter.hasNext(); ) {
result[ii++] = iter.next();
}
@@ -1228,8 +1228,8 @@ public class GamesList extends XWExpandableListActivity
private int getSelGroupPos()
{
int result = -1;
- if ( 1 == m_selectedGroupIDs.size() ) {
- long id = m_selectedGroupIDs.iterator().next();
+ if ( 1 == m_selGroupIDs.size() ) {
+ long id = m_selGroupIDs.iterator().next();
result = m_adapter.getGroupPosition( id );
}
return result;
@@ -1237,9 +1237,9 @@ public class GamesList extends XWExpandableListActivity
private long[] getSelGroupIDs()
{
- long[] result = new long[m_selectedGroupIDs.size()];
+ long[] result = new long[m_selGroupIDs.size()];
int ii = 0;
- for ( Iterator iter = m_selectedGroupIDs.iterator();
+ for ( Iterator iter = m_selGroupIDs.iterator();
iter.hasNext(); ) {
result[ii++] = iter.next();
}
From 2c63be81e8b06a77df8cb7ad31144681d9749545 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Wed, 23 Oct 2013 06:46:33 -0700
Subject: [PATCH 056/240] don't delete selected groups if one is the default
---
.../android/XWords4/src/org/eehouse/android/xw4/GamesList.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
index 2118d4068..b90227543 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
@@ -800,7 +800,8 @@ public class GamesList extends XWExpandableListActivity
// Group menus
case R.id.list_group_delete:
- if ( groupID == XWPrefs.getDefaultNewGameGroup( this ) ) {
+ if ( m_selGroupIDs
+ .contains( XWPrefs.getDefaultNewGameGroup( this ) ) ) {
showOKOnlyDialog( R.string.cannot_delete_default_group );
} else {
long[] groupIDs = getSelGroupIDs();
From ab3209ca7076ba4437e858584a9dee5e740a7a22 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Wed, 23 Oct 2013 07:15:09 -0700
Subject: [PATCH 057/240] When there's a selection change title bar text to
show count
---
.../android/XWords4/res/values/strings.xml | 3 +++
.../org/eehouse/android/xw4/GamesList.java | 25 +++++++++++++++++++
2 files changed, 28 insertions(+)
diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml
index 94a440cae..70fe5e4a2 100644
--- a/xwords4/android/XWords4/res/values/strings.xml
+++ b/xwords4/android/XWords4/res/values/strings.xml
@@ -2166,4 +2166,7 @@
can instead tap the icons at the left to select or deselect games,
then act on selected games, e.g. to delete them, using the menu or
\"Actionbar.\"
+
+ Games: %d"
+ Groups: %d"
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
index b90227543..536098cfc 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
@@ -133,6 +133,7 @@ public class GamesList extends XWExpandableListActivity
private boolean m_menuPrepared;
private HashSet m_selGames;
private HashSet m_selGroupIDs;
+ private CharSequence m_origTitle;
@Override
protected Dialog onCreateDialog( int id )
@@ -389,6 +390,8 @@ public class GamesList extends XWExpandableListActivity
tryStartsFromIntent( getIntent() );
askDefaultNameIf();
+
+ m_origTitle = getTitle();
} // onCreate
@Override
@@ -516,6 +519,7 @@ public class GamesList extends XWExpandableListActivity
}
}
Utils.invalidateOptionsMenuIf( this );
+ setTitleBar();
}
public boolean getSelected( long rowid )
@@ -868,6 +872,26 @@ public class GamesList extends XWExpandableListActivity
} );
}
+ private void setTitleBar()
+ {
+ int fmt = 0;
+ int nSels = m_selGames.size();
+ if ( 0 < nSels ) {
+ fmt = R.string.sel_gamesf;
+ } else {
+ nSels = m_selGroupIDs.size();
+ if ( 0 < nSels ) {
+ fmt = R.string.sel_groupsf;
+ }
+ }
+
+ if ( 0 == fmt ) {
+ setTitle( m_origTitle );
+ } else {
+ setTitle( getString( fmt, nSels ) );
+ }
+ }
+
private boolean checkWarnNoDict( NetLaunchInfo nli )
{
// check that we have the dict required
@@ -1125,6 +1149,7 @@ public class GamesList extends XWExpandableListActivity
}
if ( inval ) {
Utils.invalidateOptionsMenuIf( this );
+ setTitleBar();
}
}
From 6759a5af959ec62da3c0d13273b01353436113e4 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Wed, 23 Oct 2013 07:45:57 -0700
Subject: [PATCH 058/240] support moving multiple groups
---
.../org/eehouse/android/xw4/GamesList.java | 28 +++++++++++++------
1 file changed, 20 insertions(+), 8 deletions(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
index 536098cfc..c7e2cc959 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
@@ -74,6 +74,7 @@ public class GamesList extends XWExpandableListActivity
private static final int WARN_NODICT_NEW = WARN_NODICT + 8;
private static final String SAVE_ROWID = "SAVE_ROWID";
+ private static final String SAVE_ROWIDS = "SAVE_ROWIDS";
private static final String SAVE_GROUPID = "SAVE_GROUPID";
private static final String SAVE_DICTNAMES = "SAVE_DICTNAMES";
@@ -125,6 +126,7 @@ public class GamesList extends XWExpandableListActivity
private String[] m_sameLangDicts;
private int m_missingDictLang;
private long m_rowid;
+ private long[] m_rowids;
private long m_groupid;
private String m_nameField;
private NetLaunchInfo m_netLaunchInfo;
@@ -275,7 +277,8 @@ public class GamesList extends XWExpandableListActivity
break;
case CHANGE_GROUP:
- final long startGroup = DBUtils.getGroupForGame( this, m_rowid );
+ final long startGroup = ( 1 == m_rowids.length )
+ ? DBUtils.getGroupForGame( this, m_rowids[0] ) : -1;
final int[] selItem = {-1}; // hack!!!!
lstnr = new DialogInterface.OnClickListener() {
public void onClick( DialogInterface dlgi, int item ) {
@@ -283,23 +286,28 @@ public class GamesList extends XWExpandableListActivity
AlertDialog dlg = (AlertDialog)dlgi;
Button btn =
dlg.getButton( AlertDialog.BUTTON_POSITIVE );
- long newGroup = m_adapter.getGroupIDFor( item );
- btn.setEnabled( newGroup != startGroup );
+ boolean enabled = startGroup == -1;
+ if ( !enabled ) {
+ long newGroup = m_adapter.getGroupIDFor( item );
+ enabled = newGroup != startGroup;
+ }
+ btn.setEnabled( enabled );
}
};
lstnr2 = new DialogInterface.OnClickListener() {
public void onClick( DialogInterface dlg, int item ) {
Assert.assertTrue( -1 != selItem[0] );
long gid = m_adapter.getGroupIDFor( selItem[0] );
- DBUtils.moveGame( GamesList.this, m_rowid, gid );
+ for ( long rowid : m_rowids ) {
+ DBUtils.moveGame( GamesList.this, rowid, gid );
+ }
onContentChanged();
}
};
String[] groups = m_adapter.groupNames();
int curGroupPos = m_adapter.getGroupPosition( startGroup );
- String name = GameUtils.getName( this, m_rowid );
dialog = new AlertDialog.Builder( this )
- .setTitle( getString( R.string.change_groupf, name ) )
+ .setTitle( getString( R.string.change_group ) )
.setSingleChoiceItems( groups, curGroupPos, lstnr )
.setPositiveButton( R.string.button_move, lstnr2 )
.setNegativeButton( R.string.button_cancel, null )
@@ -431,6 +439,7 @@ public class GamesList extends XWExpandableListActivity
{
super.onSaveInstanceState( outState );
outState.putLong( SAVE_ROWID, m_rowid );
+ outState.putLongArray( SAVE_ROWIDS, m_rowids );
outState.putLong( SAVE_GROUPID, m_groupid );
outState.putString( SAVE_DICTNAMES, m_missingDictName );
if ( null != m_netLaunchInfo ) {
@@ -442,6 +451,7 @@ public class GamesList extends XWExpandableListActivity
{
if ( null != bundle ) {
m_rowid = bundle.getLong( SAVE_ROWID );
+ m_rowids = bundle.getLongArray( SAVE_ROWIDS );
m_groupid = bundle.getLong( SAVE_GROUPID );
m_netLaunchInfo = new NetLaunchInfo( bundle );
m_missingDictName = bundle.getString( SAVE_DICTNAMES );
@@ -681,7 +691,9 @@ public class GamesList extends XWExpandableListActivity
0 < nGroupsSelected );
// multiple games can be regrouped/reset. (Later....)
- Utils.setItemVisible( menu, R.id.list_item_move, 1 == nGamesSelected );
+ Utils.setItemVisible( menu, R.id.list_item_move,
+ (1 < m_adapter.getGroupCount()
+ && 0 < nGamesSelected) );
Utils.setItemVisible( menu, R.id.list_item_reset, 1 == nGamesSelected );
m_menuPrepared = super.onPrepareOptionsMenu( menu );
@@ -768,7 +780,7 @@ public class GamesList extends XWExpandableListActivity
if ( 1 >= m_adapter.getGroupCount() ) {
showOKOnlyDialog( R.string.no_move_onegroup );
} else {
- m_rowid = selRowIDs[0];
+ m_rowids = selRowIDs;
showDialog( CHANGE_GROUP );
}
break;
From 76bbdafadd1a478d9af8a3243ff46e64d1fec0eb Mon Sep 17 00:00:00 2001
From: Eric House
Date: Wed, 23 Oct 2013 07:55:59 -0700
Subject: [PATCH 059/240] add varargs option to another showConfirmThen variant
---
.../org/eehouse/android/xw4/XWExpandableListActivity.java | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWExpandableListActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWExpandableListActivity.java
index a6e78ee4c..1d2e82728 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWExpandableListActivity.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWExpandableListActivity.java
@@ -128,9 +128,10 @@ public class XWExpandableListActivity extends ExpandableListActivity
m_delegate.showConfirmThen( msg, posButton, action, params );
}
- protected void showConfirmThen( int msg, int posButton, int action )
+ protected void showConfirmThen( int msg, int posButton, int action,
+ Object... params )
{
- m_delegate.showConfirmThen( getString(msg), posButton, action );
+ m_delegate.showConfirmThen( getString(msg), posButton, action, params );
}
// DlgDelegate.DlgClickNotify interface
From ea4a2ea6092d6b1d9ccf7d3672436bad18c03784 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Wed, 23 Oct 2013 07:56:36 -0700
Subject: [PATCH 060/240] support reset of multiple games
---
xwords4/android/XWords4/res/values/strings.xml | 8 ++++----
.../src/org/eehouse/android/xw4/GamesList.java | 17 +++++++++--------
2 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml
index 70fe5e4a2..9199a8ef1 100644
--- a/xwords4/android/XWords4/res/values/strings.xml
+++ b/xwords4/android/XWords4/res/values/strings.xml
@@ -167,9 +167,9 @@
- Are you sure you want to reset this
- game? Resetting erases all moves and any connection
- information.
+ Are you sure you want to reset the
+ selected game[s]? (Resetting erases all moves and any connection
+ information.)http://eehouse.org/and_wordlists
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java
index 3401492cf..b70bde5f9 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java
@@ -462,6 +462,7 @@ public class GameListAdapter implements ExpandableListAdapter {
,R.string.game_summary_field_language
,R.string.game_summary_field_opponents
,R.string.game_summary_field_state
+ ,R.string.game_summary_field_rowid
};
int result = -1;
for ( int id : ids ) {
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java
index 79f6df793..1cf8c3257 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java
@@ -201,6 +201,9 @@ public class GameListItem extends LinearLayout
switch ( m_fieldID ) {
case R.string.game_summary_field_empty:
break;
+ case R.string.game_summary_field_rowid:
+ value = String.format( "%d", m_rowid );
+ break;
case R.string.game_summary_field_language:
value =
DictLangCache.getLangName( m_context,
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWListPreference.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWListPreference.java
index 9a3754e87..34c4f940c 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWListPreference.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWListPreference.java
@@ -27,16 +27,32 @@ import android.util.AttributeSet;
import junit.framework.Assert;
public class XWListPreference extends ListPreference {
+ private Context m_context;
public XWListPreference( Context context, AttributeSet attrs )
{
super( context, attrs );
+ m_context = context;
}
protected void onAttachedToActivity()
{
super.onAttachedToActivity();
setSummary( getPersistedString( "" ) );
+
+ if ( XWPrefs.getDebugEnabled( m_context ) ) {
+ CharSequence[] entries = getEntries();
+ String lastRow
+ = m_context.getString( R.string.game_summary_field_rowid );
+ if ( !entries[entries.length - 1].equals( lastRow ) ) {
+ CharSequence[] newEntries = new CharSequence[1 + entries.length];
+ System.arraycopy( entries, 0, newEntries, 0, entries.length );
+ newEntries[entries.length] = lastRow;
+ setEntries( newEntries );
+
+ setEntryValues( newEntries );
+ }
+ }
}
protected boolean persistString( String value )
From 788542c874ef368a6eabdff099321e5296a365a9 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Wed, 23 Oct 2013 20:45:14 -0700
Subject: [PATCH 066/240] When games moved, the destination group is opened and
the games that were moved stay selected.
---
.../XWords4/src/org/eehouse/android/xw4/GameListAdapter.java | 1 +
.../XWords4/src/org/eehouse/android/xw4/GameListItem.java | 4 ----
.../XWords4/src/org/eehouse/android/xw4/GamesList.java | 5 ++++-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java
index b70bde5f9..4efe62dd0 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java
@@ -234,6 +234,7 @@ public class GameListAdapter implements ExpandableListAdapter {
GameListItem result =
GameListItem.makeForRow( m_context, rowid, m_handler,
groupPosition, m_fieldID, m_cb );
+ result.setSelected( m_cb.getSelected( result ) );
return result;
}
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java
index 1cf8c3257..bc65afdb2 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java
@@ -337,10 +337,6 @@ public class GameListItem extends LinearLayout
s_invalRows.remove( m_rowid );
}
}
-
- if ( m_cb.getSelected( GameListItem.this ) && m_selected ) {
- toggleSelected();
- }
}
} // class LoadItemTask
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
index 5f6170f03..50235adcf 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
@@ -301,6 +301,8 @@ public class GamesList extends XWExpandableListActivity
for ( long rowid : m_rowids ) {
DBUtils.moveGame( GamesList.this, rowid, gid );
}
+ DBUtils.setGroupExpanded( GamesList.this, gid,
+ true );
onContentChanged();
}
};
@@ -631,7 +633,7 @@ public class GamesList extends XWExpandableListActivity
@Override
public void onBackPressed() {
- if ( 0 == m_selGames.size() ) {
+ if ( 0 == m_selGames.size() && 0 == m_selGroupIDs.size() ) {
super.onBackPressed();
} else {
clearSelections();
@@ -796,6 +798,7 @@ public class GamesList extends XWExpandableListActivity
// Game menus
case R.id.list_item_move:
+ keepSels = true;
if ( 1 >= m_adapter.getGroupCount() ) {
showOKOnlyDialog( R.string.no_move_onegroup );
} else {
From c605368cba41ff308b58ab5f091b7fe63074455b Mon Sep 17 00:00:00 2001
From: Eric House
Date: Wed, 23 Oct 2013 20:58:58 -0700
Subject: [PATCH 067/240] make the group up/down arrows just plain arrows
---
xwords4/android/XWords4/img_src/down.svg | 60 ++++++++++++++++++++----
xwords4/android/XWords4/img_src/up.svg | 60 ++++++++++++++++++++----
2 files changed, 102 insertions(+), 18 deletions(-)
diff --git a/xwords4/android/XWords4/img_src/down.svg b/xwords4/android/XWords4/img_src/down.svg
index 44ef4f259..b57838e12 100644
--- a/xwords4/android/XWords4/img_src/down.svg
+++ b/xwords4/android/XWords4/img_src/down.svg
@@ -1,11 +1,53 @@
-
-
-
\ No newline at end of file
diff --git a/xwords4/android/XWords4/img_src/up.svg b/xwords4/android/XWords4/img_src/up.svg
index 4d165509a..d68bc337c 100644
--- a/xwords4/android/XWords4/img_src/up.svg
+++ b/xwords4/android/XWords4/img_src/up.svg
@@ -1,11 +1,53 @@
-
-
-
+
+image/svg+xml
-
-
+ id="g12"
+ transform="matrix(-1.25,0,0,1.25,116.39005,-0.58771313)">
+
+
-
+
\ No newline at end of file
From 60ae8b97c293f940b73c6ae6ef438521689c0c42 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Wed, 23 Oct 2013 21:07:38 -0700
Subject: [PATCH 068/240] try giving the generated pngs transparent backgrounds
---
xwords4/android/scripts/images.mk | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/xwords4/android/scripts/images.mk b/xwords4/android/scripts/images.mk
index 080899aa2..f8532b720 100644
--- a/xwords4/android/scripts/images.mk
+++ b/xwords4/android/scripts/images.mk
@@ -2,6 +2,7 @@
IMG_SRC = ./img_src
IMG_DEST = res
+PARAMS = -transparent white -negate
# $(IMG_DEST)/drawable/%_gen.png:
# pwd
@@ -11,10 +12,10 @@ IMG_DEST = res
# convert -extent 48x48 $< $@
$(IMG_DEST)/drawable-xhdpi/%__gen.png: $(IMG_SRC)/%.svg
- convert -negate -scale 64x64 $< $@
+ convert $(PARAMS) -scale 64x64 $< $@
$(IMG_DEST)/drawable-mdpi/%__gen.png: $(IMG_SRC)/%.svg
- convert -negate -scale 32x32 $< $@
+ convert $(PARAMS) -scale 32x32 $< $@
$(IMG_DEST)/drawable-hdpi/%__gen.png: $(IMG_SRC)/%.svg
- convert -negate -scale 48x48 $< $@
+ convert $(PARAMS) -scale 48x48 $< $@
From 479bb0b23694144cced453754bb948b5827b010e Mon Sep 17 00:00:00 2001
From: Eric House
Date: Thu, 24 Oct 2013 06:16:08 -0700
Subject: [PATCH 069/240] thinner up icon; leave down thicker pending opinions
---
xwords4/android/XWords4/img_src/up.svg | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/xwords4/android/XWords4/img_src/up.svg b/xwords4/android/XWords4/img_src/up.svg
index d68bc337c..2853a8598 100644
--- a/xwords4/android/XWords4/img_src/up.svg
+++ b/xwords4/android/XWords4/img_src/up.svg
@@ -31,23 +31,22 @@
id="namedview7"
showgrid="false"
inkscape:zoom="1.9666667"
- inkscape:cx="60.000001"
- inkscape:cy="60.000001"
+ inkscape:cx="60"
+ inkscape:cy="60"
inkscape:window-x="0"
inkscape:window-y="24"
inkscape:window-maximized="0"
inkscape:current-layer="svg2" />
+ transform="matrix(0,-1.25,-1.25,0,119.99375,119.99375)">
+ transform="translate(49.96,79.76)"
+ id="g1580">
+ d="m 0,0 -5.498,-5.502 22.368,-22.368 -52.57,0 0,-7.78 52.57,0 L -5.498,-58.02 0,-63.52 31.77,-31.77 0,0 z"
+ id="path1582"
+ inkscape:connector-curvature="0" />
\ No newline at end of file
From 6827350f7a613e2e80f4124f5a9d98af09f66b5d Mon Sep 17 00:00:00 2001
From: Eric House
Date: Thu, 24 Oct 2013 06:33:33 -0700
Subject: [PATCH 070/240] rearrange menus and add some new icons
---
xwords4/android/XWords4/img_src/dict.svg | 9 +++
xwords4/android/XWords4/img_src/email.svg | 13 ++++
xwords4/android/XWords4/img_src/prefs.svg | 13 ++++
xwords4/android/XWords4/img_src/relabel.svg | 18 +++++
.../XWords4/res/menu/games_list_menu.xml | 65 ++++++++++---------
5 files changed, 86 insertions(+), 32 deletions(-)
create mode 100644 xwords4/android/XWords4/img_src/dict.svg
create mode 100644 xwords4/android/XWords4/img_src/email.svg
create mode 100644 xwords4/android/XWords4/img_src/prefs.svg
create mode 100644 xwords4/android/XWords4/img_src/relabel.svg
diff --git a/xwords4/android/XWords4/img_src/dict.svg b/xwords4/android/XWords4/img_src/dict.svg
new file mode 100644
index 000000000..6a13c659c
--- /dev/null
+++ b/xwords4/android/XWords4/img_src/dict.svg
@@ -0,0 +1,9 @@
+
+
+
+
+
+
diff --git a/xwords4/android/XWords4/img_src/email.svg b/xwords4/android/XWords4/img_src/email.svg
new file mode 100644
index 000000000..a05eb3b65
--- /dev/null
+++ b/xwords4/android/XWords4/img_src/email.svg
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/xwords4/android/XWords4/img_src/prefs.svg b/xwords4/android/XWords4/img_src/prefs.svg
new file mode 100644
index 000000000..508ace0a8
--- /dev/null
+++ b/xwords4/android/XWords4/img_src/prefs.svg
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/xwords4/android/XWords4/img_src/relabel.svg b/xwords4/android/XWords4/img_src/relabel.svg
new file mode 100644
index 000000000..7a9ab3a95
--- /dev/null
+++ b/xwords4/android/XWords4/img_src/relabel.svg
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/xwords4/android/XWords4/res/menu/games_list_menu.xml b/xwords4/android/XWords4/res/menu/games_list_menu.xml
index 04605844e..5ecbfc357 100644
--- a/xwords4/android/XWords4/res/menu/games_list_menu.xml
+++ b/xwords4/android/XWords4/res/menu/games_list_menu.xml
@@ -6,23 +6,6 @@
android:icon="@drawable/content_new__gen"
android:showAsAction="ifRoom"
/>
-
-
-
-
-
+
-
-
-
-
+
-
+
+
@@ -71,13 +67,18 @@
+
Date: Thu, 24 Oct 2013 06:40:20 -0700
Subject: [PATCH 071/240] remove unused images
---
.../res/drawable-hdpi/ic_action_delete.png | Bin 3053 -> 0 bytes
.../res/drawable-mdpi/ic_action_delete.png | Bin 3011 -> 0 bytes
.../res/drawable-xhdpi/ic_action_delete.png | Bin 3128 -> 0 bytes
3 files changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 xwords4/android/XWords4/res/drawable-hdpi/ic_action_delete.png
delete mode 100644 xwords4/android/XWords4/res/drawable-mdpi/ic_action_delete.png
delete mode 100644 xwords4/android/XWords4/res/drawable-xhdpi/ic_action_delete.png
diff --git a/xwords4/android/XWords4/res/drawable-hdpi/ic_action_delete.png b/xwords4/android/XWords4/res/drawable-hdpi/ic_action_delete.png
deleted file mode 100644
index 572df98ef958f1bce85b9d94a172dd025025d0df..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 3053
zcmb_e_dgW=AAgJNm5d~P>=n+I&7Hl+$r)ukl8z`LI(vSMWOpLjBazctoxRV>JR>XN
zgHJ}Mtgp}i@O?cV&)4&p=i~KwJ)b{4ybME&*v~!NVwG|
zyBcZn5NZ^Mer<%ZWTWP>geIa{(}cu$X_yV;cnfFQEZVQ>=umL=6~vJzC!>?tEX3&(
zXlJO_c;6*Q7R4nDoGgbFc~7;Fz7L-_Osj8H9boE5sPNSEnfkI8@@V>U=I8?XNvKN&as0iM82R|lx+fs{pDv?!nm0Zx7V
z{LevD4q(;Yw^99hr-pe$>@umGI#ry2l1{iiwS*s)jg91O5rP579aaVBE6%x^k{v-g
zoHF5ZOy3TM04PXfyL5YS_ME_2Lm((5V;LPKw!Tna@VU6Gp0AHo`f38O91u2kE)J=`
ziB_RR`<%ZM+@(eE-Wvr!W;aJG;KNHe=WYwRaw{2|Y)4
zIO1*29{mneJtZA|Yg-Wrm$@IVM{)eEW9ZPh_}0iPnkbj~?+
z80)G9i(j&KZqk8FF<(6Nm1wu%_=VfblK2U^`jR}TeW*?rk|t4h-cuR`F6TfCxs}eKvxHp8A|JhzV*aOv?>BB5;I)OE#?IIs>v;fxA2Tf_hppqu>Q=b
z=F9ZQnL58+q$Qk&LaUGZx-;)w9GOc3fBPaTpw_TrtB~gHw3p1xvUNo<@Np5X$3xTT35dj4++iFXOo-Aa`w!Mv;a*%A!M!_4oi}T#+i(bR5b*{;-ajo(0+tXrPH2vNmTdjy#4m>pETxVXFTc>o-meH~<%C%f5
zD}-N@PqBkm7h)|xSj3iHmwTG4G#trpU{qZFE@R@RCx<7=>%)(LrfUlsw@tG~ZN>*T
z^?qdiAU_PGXNX~o?2SW;aOT~hx`E^jyzwF1xP)^ek+T;rr6|3fy^+I|gR(}5VZ~ms
zr47(#7-k4%aEU?S<~c6acu
z$jr(_RO(k+RO)TFD%9+hVoF+dnr%^nr>Q|KZWe9{fX_zmN#%;V}==xbdw3^?+;zZ^V%gvqPV>)0tH
ze%Mvm_1cY{e>)`iRy5yM)_=6K5BAMseN2PyZHAQhQdO84%q$$)u)z;;g{0Y3PuDgU
z2Ud`r_c+vlsXuwUs=lhKxG1w|>o}x{Z|rLvH0wm=J4P?TUh-eKT?Ai@fl{;}8In9c
zTr1rE%E@u?3*Ilu8p=fXUv;xPT1f>sEjF!`i0X*-_G(_wzJF4yc}W}DgfxN|W3+kL
zkEu~A=kLymoniFC(Xr7sF&fFfafq8^(pmC>WAiZoCG9`jnc9naNNF>r4-$s*V(Jx=
z4^`(Bo8+1_dL%t;hb9pigux@DTS}5*H42X(wJn|Q9K^0*R_InkII}3GYNk6
zPg;w7kU+O=vG_VJO1M0=#hAf(Ax}A4(V>=@ntxEKq<2_|IYBvQ2hWg
zRq@T<+lw8R4wmIt*y0!?8wqa2_tvV1N_DD!K}6bBwySqy?on2$eonxO`AnKs?$~72
zgtZC)OZPtQ9R1QELb8TM
zh|Q5$7_R7x>gN{s(tg6QiU#~W{1E;JuCP14(BM3M{CI4aE2QO@+&_~<`xerfdVd?y
zn#|f{(qq#7#Nec!q)`)Jv3Z<%;&Z>+)W>h9mwcT3jEbKTJB|A~$vv(Hw@jJ3v#rP2
z`&ZjJW-m~JL4m>g?>9Xw{Jz>jYnvpRCDLsM<+*1`Ayvy%6MsG9Mshz0Gf$b8B!8
z-niZ1)`k!d(k55FB4OdMHRvb%#nfcJlG;M+K`@HcO*&d)UkH05d`1{-o(&YzMn{gEryZp*!LFv{qzuL|#BAr^Raa74
z(RgyUd0Gk^aT^iJ=Qw|NK3K!S4hcJ++@2SwB_^}A7d$UTE
zFb$QGy`P#FH`z&%-$;(DeI`Yav%Oye4})lxFY&!)X_g|gVQ0~sXuih~-X|fQT@0n#G9}Oz_w=pEES16YR>5qfJi6Ch^$F
zuqH5%Gc1a{N{)OTm(YDM7y8;~w2`{pcU(87vr@5xukB|bF|uZuDA}lBSxaG;&V7sQ
zZ0nd?l+(j8i}?di#@bsV_m4zrz<#)vmh@#3!zV!VXqbf&kSuda@)u)IIM!gZZQ`P@0J>1%
z+9fLb2t;KAZli6a)=%jw&K1aMQrR_HL@{+koFk)b00R;!cS(wD$|udO>UPF0M^COL
zIGbM)r_Awfrx$?yRGw3}J4cVm>{Vp4YBGV{MRx5o{mEr__l4u7{&Igk0OkV22ajc-
zwE|d8daUp9EAdS_@0%?752%S=H5__%Ab)idx#Ryg8^eO9#EFTe#l>;6HkhMZH!|!P
z-Qq$*9^L&Nu60P=`}S#G45#RfGp5`B*3!FcQFyWc8B>(|)N+dPVLi*qq0sQ-e_UuZ#_|VC%`B|9*TAf)HP<=;-CNx#H#My)Pm$@V-Dv&f!
z1z@`Y)BIJ6krwM6IoBU_vZZ@uoG%WrUZ&3i0Jv!&CWq**)$L?FJ;8h&q*`BaxA}q$
ziT+~q*{NohLs!)(m{?m2j1$Iu3w!aN>y?TKm{d$(wGhM=`c+RznPlS~ljhGZ*JA&H
zUE81Ij~ioNvs5FFiB7+Z@w}VJWE_oq0!lQQkuN)XU!>WDjw?}2_)8qO&1Lgc6%z&9
z1cb1?iO{z8y)){uPDUS7HM@Xf#9>UMvBGm)jg9tK);c(`L`@*d=oQPrtw4pG6yE&Y
zfqU--w3Ac|RtCzwIVMwd;GOcM?-v-9+V0BBb+p3XU6o-<^XPeZxq`L4L!kP41#Lt8
zo=5+?AUZCbA&E(qE(j*f8lEkNHOy9jh3~>z^4f)xMuF90=Dw_z1rhS>b
zch?Jevu`&qW!rtnjDLx9NqLFhGfPq5{&kM+
zbV&i?oJz_KSY-jh_N`59$$8}mIqH3pyr$-bm9Nr=1-$vZskh&L5Bzv;I{lJW<^Xc2
zXVv(7=6BlNAXc^*p2*HPv=o2t1%?Y~{-6tQvn-1EhZFfb5%OvZ>sc$=9N8Fq6odeI
z%#+&9oNksbkuC^z?3L^mN}0Z9l-rl#udUk&+M!D|
zOJd8=B^ZS6n{bDtczTCci&ks+8=L%hE(?tv!Ym&AwU1;(eAvok9^h2kB;NH+Jbnmi
z$T|{gNYpMXEl`ImnJFP_ZFin~=`t*21?;~Fv|?J3D$d*qPnhA}x-x%7ut?d0sNm`3
zQJu
zxiX(Z!GZ>ZpwE8An^}3EZesH+FvT;$O)GychCz=IN4|fG_l#Ll^tG&F^b}U|1+8|K
z0F0Ipw3G7F2JYOd2QPF>cgviMN+k|zy&f_8*N7wOc8Ak~*n)3|Z^vs1dI=E;bIUc$
z%^X`xV$qc%O$$wn&c5EhSAC<|D!JMUV~Q)eE4gF2v-Pew9^H^3ln_36n$|4dD00{&
zH2Ou~Pp<s_ut>+*0`=QlS6*7sTiWW(NBq}j96-}6!Gr*@w8Hex{^gsCEsR`
zz83y{bb!Ha*)6d(oK-S9HX0eDo9rKl5*Sp-R0$fKg5RGt_+yY^Fq4Z`uvUL7Yo-Fx
zDU-XSHL3Pd`J--!oR>rI2nvrfy=#6^T@F&E>Ua0k?BT{v>^y#+Wg(O=3){$Y-ff17Kw$mT3g^8hY95
zVNZo;bj@+QUt&G;R@8(b}1bI%BcG3H2FA=GkH#U1q;t$<((^8(LV>6q*E62oT>9>+%g`
zW>t8TM2Mvi?q+j$L~|XD&pL}e^HOx!`qbElvo#9pFk9#LCk8L5!xNuS#ZBSMeUeA()L#(}SMrIl~MMknnM?Gb}0J7J9Ybwp@L8)2I=D!p#Z
z-ucg`WBgW-ESoBu{l70d=0*Jtf)`h*OtaKWY#NgflR_)z7>56OD1;V*-ht(8=NRSM
zi$`#t4Kc|{0a
z@gUFM;lONthKYw(e|r(U4O`
zbn+o?hBVcMdQn#e^VG=GyG_AAc~3@1^3=7bn|4Al)OPCLEbnyqJ;@_-Ps2ozMFqt(M=c>k?_i9EjJSI0e7e7w-`{gL%C@?h3rLFRU5+GpR#g-2_ob^f=Mj+Tx~
zpT0a&Qn-8*$_2OgUCsHTgzu)cI4HO@w@u#Jo(9ve?9C|3pQvN=l
z9wxSy0ECDGfQSYB7p#TDcK1pD-5el=i%+R)fA*dLUFUoPIGh$xCC|`I|ywjYB!};W*k6
YKq%ZI3Qld3r>g){Lo0(Sm}|uU0Qe=hzyJUM
diff --git a/xwords4/android/XWords4/res/drawable-xhdpi/ic_action_delete.png b/xwords4/android/XWords4/res/drawable-xhdpi/ic_action_delete.png
deleted file mode 100644
index ead332270d6cbb5f44fd00a833236dddcd77c8eb..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 3128
zcmb_f_dnE+AAgICGn0{3_PB7iZ0_tmPIp$eBgrf)9J0&I?nGtJ$mv4P7C9mFjO-9T
z8J)7e`X9cp$K&~W{_=dh9*@`a`OE8-WNxZQ58?y?06=e`uWfnBn*Tsee%UcC(LXPV
z#!ufS5CCYI|AB05KJpX*KxSSrn7O&9Z;)@Gr>`Hc0Sw0L7vSsR^}rnfLS`{mD7e)o
zn;L215Nec&eqrQm$x6*@2~9z>WC(-#XqXHW`ATM3Ejq91=umJC6ep6WrlOy*T8Psn
zgQlrg`Cg~SzDZ0TJXs2V<2~6%S|2`do>JeaIlwfHP~oZRa`a^_F}=InEC!1MFV#v62;M
z0KC`T6SVybSl456(^{q6KzK=;ZKD?NZu4B7_i@FQE6D`O1{oo4#6lbtrZhLSRLSU#P5EN3e42}|89h4XRE-owQYa`Wum%%LsMUI|}
zLz+0zDwJrS^VdSV6rT5Jiyx6vJQ^7_n}OoZS;T?gKW}tO(s460Ypbi%hCNU_=Rrio
zIjYMMk2rhqCsOs4boBkxvS74~L$n^n@%OGThsLGcBbhW$UFO!)^iEr7FHU*J`Fjjp
za7ZxAiUqTOs&>J%1DR6(Bxt5suh7_q+w!9L3Ay^BJkW4ooh&>^ibcyh1RT#Y&{&?+A
z&kYwD=>(*{xWFWH+I0w1cp|JvQII(aCL@ANzhdz2Eqsi5On2;|rNE|mWucrtr$E-{
zSvT)SDy0|VytfD9RxzvHtFo(Ht9<)*AdHKq|J!4$Wl_t)`-U8AOlxv$l5Be*}HJHlKadH1{iF
zY-m&ONA3^u!(cl4c-GkdM3g8;;SH)AD30J8^?Al+9OEe*{ctHo>FvCYe8zlVYa|#8
ze!`kD2+B6h7S84ZL*SKFWmOARwAKgKL-4f9dsY#3y4JE*E0r|ga;mMXFy`A;9o+G-d^fM?(>-*Nv2Xc8X#2)r?g+>k{LJTX`H>zSlCp_TkdjD8xS`rB
z@9(S11L-IJvVb{sYr;yMvz>F7o@U@iRo_hLKG$V@=GAAvBDmty=hOE_m{OQe*vMqd
zWVgW51Xm_jredsO+&}zf`1SB)zI>sY^pwm-;YQ(9;bM!EZHTQnwgUUX-Jo&Rw#;T1
z+x9TdR>`ImX>IG!q+5%r6`E|VZ7si6jx)_NtuC5GbvOLNe#Ta|a5St*7>;$y_~Gc_vugc*iv9$TKs!1n7N?Q>vFRln1L<
zN#0kTRs1OTQKL`N!{*Bb5`#2&V8pE?39eIk_~6sx>CQpIGG>`}C7eAEGT`7BT0-bL
zj4NlWlw=lH&e1eZG`;iUKP@J31=};B{p-O(si4p}^aT;b1zG=Fz4>k$Q
z{F%`vA1c@@TPnVWdn!_y-eyd1JYT3>#8&W_*GEQ8xm`LoGb7y}TE%CQg+*U+icW#48d2^DkB;G_L8YAPqT9neUz!Gq
z>54D+UR~@kcQG$zVoT$V5E4Ad_4b($%wcPVRBKO|$pJ`-luJBZx6
z$adi{6YuDIor5u*&1Bx&wAP@txQOk!sT~J1B*bR1+4*lghD)6_DY=e?$ezm@H7z<9
zvc{F*JJ^vw_u_qJbq~&M#AD23bA3Ug$c`bWDtA4X;UWFZ?0fpfyYF|7e(Mk+xx=Ew
z)>teI_ohSjLz{c~XTq?G2K+7j5dIggusb&2>^yb+aCDa|yzRH#&k3Sk8|h5_^CzM;
znYGD;$AtTd!ATQIqb{jx^El_k$D!8L$A71ve2n~zN`L`7h5I(aGo}W&Oq;yDt;f)R
z>(e=AFIa+Jf!_N0%f4j+Kkd-fO%lx_=_bAM?Bi$QHA__Ew;uDLcp&$o1^WfMg;oV8
zb}n`w&AzCQPHruPo$3*9F}{>jwFxymfPeOy-HaK}LhX+{!(?M3A|?OKIT2rD!#7+B
zi}x9Q_dYTOEsg11q-?0PsSxb1dH{J~BY$j4;$X6D+b@+h*40
zc&NFfH3OSZn9#60pPSyBi@J{wE^CUPZ37*MoV({bF(^po|K+#;kP;JiG5vtH$Qz2
zk(Iu8c=u$dGk7kTXYb7-quJ^c-YC%v&p+>utiG0?WN~C=T~Ltc9h|z#N)RvaOUhOS!SCZq;j{xm{0lM9-z1==
z*TH!E$>9d=>KJ5iud>Rx!Krk|^;=%t{T=I!6rE~#9d?DQFkx`SK?hZ!*g8nYi)p%3ljhJL}gb_1;#>C^L}QtqAA4tUryfC4kHYuP|)X-@QUf8zg>(j`qcoAzAt;
zwXHetPYO
Date: Thu, 24 Oct 2013 06:47:54 -0700
Subject: [PATCH 072/240] add reset (rewind) icon
---
xwords4/android/XWords4/img_src/reset.svg | 11 +++++++++++
xwords4/android/XWords4/res/menu/games_list_menu.xml | 8 +++++---
2 files changed, 16 insertions(+), 3 deletions(-)
create mode 100644 xwords4/android/XWords4/img_src/reset.svg
diff --git a/xwords4/android/XWords4/img_src/reset.svg b/xwords4/android/XWords4/img_src/reset.svg
new file mode 100644
index 000000000..bf5967a90
--- /dev/null
+++ b/xwords4/android/XWords4/img_src/reset.svg
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
diff --git a/xwords4/android/XWords4/res/menu/games_list_menu.xml b/xwords4/android/XWords4/res/menu/games_list_menu.xml
index 5ecbfc357..8a8a84349 100644
--- a/xwords4/android/XWords4/res/menu/games_list_menu.xml
+++ b/xwords4/android/XWords4/res/menu/games_list_menu.xml
@@ -51,15 +51,17 @@
android:icon="@drawable/relabel__gen"
android:showAsAction="ifRoom"
/>
+
-
From 3ff063a490c51b27724cab3cd15d41b39175d7ac Mon Sep 17 00:00:00 2001
From: Eric House
Date: Thu, 24 Oct 2013 07:30:39 -0700
Subject: [PATCH 073/240] up version strings and start changelist
---
xwords4/android/XWords4/AndroidManifest.xml | 2 +-
xwords4/android/XWords4/res/raw/changes | 25 +++++++++++--------
.../android/XWords4/res/values/app_name.xml | 2 +-
3 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/xwords4/android/XWords4/AndroidManifest.xml b/xwords4/android/XWords4/AndroidManifest.xml
index 86be1d430..40bdb2184 100644
--- a/xwords4/android/XWords4/AndroidManifest.xml
+++ b/xwords4/android/XWords4/AndroidManifest.xml
@@ -22,7 +22,7 @@
to come from a domain that you own or have control over. -->
diff --git a/xwords4/android/XWords4/res/raw/changes b/xwords4/android/XWords4/res/raw/changes
index e5150a753..f18d2c4b3 100644
--- a/xwords4/android/XWords4/res/raw/changes
+++ b/xwords4/android/XWords4/res/raw/changes
@@ -5,24 +5,29 @@
-Crosswords 4.4 beta 70 release
+Crosswords 4.4 beta 71 release
-
Recent releases feature a major upgrade to how the app communicates
- with the relay, in essence switching from each game communicating
- individually (and only when open) to the app communicating on behalf
- of all games. You should notice only that moves are transmitted
- more reliably. But this being new code you may also notice bugs.
- If you don't tell me about
- them they will not get fixed.
+
For this release I've redone how you work with games and groups of
+ games in the main Games List screen. Now you select one or more
+ games, and then the screen's main menu (including the right of the
+ action bar for newer devices) changes based on the
+ selection. Long-tap to select. "Context menus" are gone.
+
+
Please let me know what you think of this. Suggest tweaks. Should I
+ redo the rest of the screens in this style; or, to the contrary, put
+ things back the way they were? As always, you
+ can email me here.
New with this release
-
Work around bug in 2.3.x Android (Thanks O!)
+
Catch up with Android UI 4.0: make interaction with games and
+ groups selection-based
+
Fix bug on tiny-screen phones (Thanks O!)
Next up
-
Take advantage of newer Android UI features, e.g. Action Bar
+
Use Actionbar and select/act pattern on more screens
Offer "Rematch" when game's over
diff --git a/xwords4/android/XWords4/res/values/app_name.xml b/xwords4/android/XWords4/res/values/app_name.xml
index 8f4532ad6..28b83facd 100644
--- a/xwords4/android/XWords4/res/values/app_name.xml
+++ b/xwords4/android/XWords4/res/values/app_name.xml
@@ -1,5 +1,5 @@
- 4.4 beta 70
+ 4.4 beta 71
From 266cd6fe852229d34141cbc798e09f3f765f8de3 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Thu, 24 Oct 2013 18:51:55 -0700
Subject: [PATCH 074/240] add newbie hint for new back-button-clear-selection
behavior
---
.../XWords4/res/values/common_rsrc.xml | 1 +
.../android/XWords4/res/values/strings.xml | 4 ++++
.../org/eehouse/android/xw4/GamesList.java | 22 ++++++++++++-------
3 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/xwords4/android/XWords4/res/values/common_rsrc.xml b/xwords4/android/XWords4/res/values/common_rsrc.xml
index ed105a95d..f7af55629 100644
--- a/xwords4/android/XWords4/res/values/common_rsrc.xml
+++ b/xwords4/android/XWords4/res/values/common_rsrc.xml
@@ -80,6 +80,7 @@
key_notagain_synckey_notagain_newselect
+ key_notagain_backclearskey_notagain_chatkey_notagain_relaykey_notagain_hintprev
diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml
index 9199a8ef1..6a147a98c 100644
--- a/xwords4/android/XWords4/res/values/strings.xml
+++ b/xwords4/android/XWords4/res/values/strings.xml
@@ -2167,6 +2167,10 @@
then act on selected games, e.g. to delete them, using the menu or
\"Actionbar.\"
+ New feature: The back button
+ now clears any selection instead of exiting. Hit it again to exit
+ the app.
+
Games: %d"Groups: %d"
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
index 50235adcf..cbac7fb8a 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
@@ -84,13 +84,14 @@ public class GamesList extends XWExpandableListActivity
private static final String REMATCH_ROWID_EXTRA = "rowid_rm";
private static final String ALERT_MSG = "alert_msg";
- private static enum GamesActions { NEW_NET_GAME,
- RESET_GAMES,
- SYNC_MENU,
- NEW_FROM,
- DELETE_GAMES,
- DELETE_GROUPS,
- OPEN_GAME
+ private static enum GamesActions { NEW_NET_GAME
+ ,RESET_GAMES
+ ,SYNC_MENU
+ ,NEW_FROM
+ ,DELETE_GAMES
+ ,DELETE_GROUPS
+ ,OPEN_GAME
+ ,CLEAR_SELS
};
private static final int[] DEBUGITEMS = {
@@ -616,6 +617,9 @@ public class GamesList extends XWExpandableListActivity
case OPEN_GAME:
doOpenGame( params );
break;
+ case CLEAR_SELS:
+ clearSelections();
+ break;
default:
Assert.fail();
}
@@ -636,7 +640,9 @@ public class GamesList extends XWExpandableListActivity
if ( 0 == m_selGames.size() && 0 == m_selGroupIDs.size() ) {
super.onBackPressed();
} else {
- clearSelections();
+ showNotAgainDlgThen( R.string.not_again_backclears,
+ R.string.key_notagain_backclears,
+ GamesActions.CLEAR_SELS.ordinal() );
}
}
From 33252c929c175ee8506ff302bda07564bafa6f9f Mon Sep 17 00:00:00 2001
From: Eric House
Date: Thu, 24 Oct 2013 19:18:42 -0700
Subject: [PATCH 075/240] fix showNotAgainDlgThen(): when the pref is set to
skip the hint, we still can't call the callback directly because then
showNotAgainDlgThen() is synchronous only in that case. For consistency,
post the callback call to a handler.
---
.../org/eehouse/android/xw4/DlgDelegate.java | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java
index feb90ca39..82e1435df 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java
@@ -157,15 +157,21 @@ public class DlgDelegate {
}
public void showNotAgainDlgThen( int msgID, int prefsKey,
- int callbackID, Object[] params )
+ final int callbackID,
+ final Object[] params )
{
if ( XWPrefs.getPrefsBoolean( m_activity, prefsKey, false ) ) {
// If it's set, do the action without bothering with the
// dialog
if ( SKIP_CALLBACK != callbackID ) {
- m_clickCallback.dlgButtonClicked( callbackID,
- AlertDialog.BUTTON_POSITIVE,
- params );
+ post( new Runnable() {
+ public void run() {
+ m_clickCallback
+ .dlgButtonClicked( callbackID,
+ AlertDialog.BUTTON_POSITIVE,
+ params );
+ }
+ });
}
} else {
String msg = m_activity.getString( msgID );
@@ -221,7 +227,8 @@ public class DlgDelegate {
} else {
post( new Runnable() {
public void run() {
- m_clickCallback.dlgButtonClicked( callbackID, EMAIL_BTN, null );
+ m_clickCallback.dlgButtonClicked( callbackID, EMAIL_BTN,
+ null );
}
});
}
From 73e1ac0a932271f25d7de15685c27222069ef5ce Mon Sep 17 00:00:00 2001
From: Eric House
Date: Thu, 24 Oct 2013 19:20:20 -0700
Subject: [PATCH 076/240] make newFrom highlight the new game; make reset
preserve the selection
---
.../android/XWords4/src/org/eehouse/android/xw4/GamesList.java | 2 ++
1 file changed, 2 insertions(+)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
index cbac7fb8a..ac3e65752 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
@@ -598,6 +598,7 @@ public class GamesList extends XWExpandableListActivity
case NEW_FROM:
long curID = (Long)params[0];
long newid = GameUtils.dupeGame( GamesList.this, curID );
+ m_selGames.add( newid );
if ( null != m_adapter ) {
m_adapter.inval( newid );
}
@@ -831,6 +832,7 @@ public class GamesList extends XWExpandableListActivity
break;
case R.id.list_item_reset:
+ keepSels = true;
showConfirmThen( R.string.confirm_reset, R.string.button_reset,
GamesActions.RESET_GAMES.ordinal(), selRowIDs );
break;
From 521f0e3cf39a4f89c33a7a1788a3d9274d683981 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Thu, 24 Oct 2013 19:58:21 -0700
Subject: [PATCH 077/240] more tweaks, e.g. name the group that's preventing
deletion, and select newly created game copy
---
xwords4/android/XWords4/res/values/strings.xml | 2 +-
.../XWords4/src/org/eehouse/android/xw4/GamesList.java | 10 +++++++---
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml
index 6a147a98c..d1c4972e8 100644
--- a/xwords4/android/XWords4/res/values/strings.xml
+++ b/xwords4/android/XWords4/res/values/strings.xml
@@ -2139,7 +2139,7 @@
Change the name of this group to:Name group
- The group for new games
+ The group for new games, %s,
cannot be deleted.Moving is impossible until there
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
index ac3e65752..0913df362 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
@@ -827,6 +827,7 @@ public class GamesList extends XWExpandableListActivity
byte[] stream = GameUtils.savedGame( this, selRowIDs[0] );
GameLock lock = GameUtils.saveNewGame( this, stream );
DBUtils.saveSummary( this, lock, summary );
+ m_selGames.add( lock.getRowid() );
lock.unlock();
}
break;
@@ -838,6 +839,7 @@ public class GamesList extends XWExpandableListActivity
break;
case R.id.list_item_rename:
+ keepSels = true;
m_rowid = selRowIDs[0];
showDialog( RENAME_GAME );
break;
@@ -845,9 +847,11 @@ public class GamesList extends XWExpandableListActivity
// Group menus
case R.id.list_group_delete:
keepSels = true;
- if ( m_selGroupIDs
- .contains( XWPrefs.getDefaultNewGameGroup( this ) ) ) {
- showOKOnlyDialog( R.string.cannot_delete_default_group );
+ long dftGroup = XWPrefs.getDefaultNewGameGroup( this );
+ if ( m_selGroupIDs.contains( dftGroup ) ) {
+ msg = getString( R.string.cannot_delete_default_groupf,
+ m_adapter.groupName( dftGroup ) );
+ showOKOnlyDialog( msg );
} else {
long[] groupIDs = getSelGroupIDs();
Assert.assertTrue( 0 < groupIDs.length );
From 256d6eed902e7055c6793cba960564d5334b54f4 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Thu, 24 Oct 2013 19:58:43 -0700
Subject: [PATCH 078/240] remove unused strings
---
.../android/XWords4/res/values-pt/strings.xml | 20 -------------------
1 file changed, 20 deletions(-)
diff --git a/xwords4/android/XWords4/res/values-pt/strings.xml b/xwords4/android/XWords4/res/values-pt/strings.xml
index 1ecf9e755..bcaf8da78 100644
--- a/xwords4/android/XWords4/res/values-pt/strings.xml
+++ b/xwords4/android/XWords4/res/values-pt/strings.xml
@@ -13,15 +13,6 @@
# This is the first screen you see when you launch Crosswords
############################################################
-->
-
- Use o botão abaixo para criar um novo
- jogo. Selecione um jogo existente para continuá-lo ou dê um toque
- longo para outras opções.
-
- Você pode esconder essa mensagem
- e os botões abaixo na seção Aparência das Configurações (acessada
- através do botão menu do seu dispositivo.)
- Use a tecla menu para adicionar um
- jogo.
-
-
- (not here yet...)
+ (not here yet…)
- Wordlists
+ Wordlists…
- App Settings...
+ App Settings…Checking relay for moves
- etc...
+ etc…
@@ -109,7 +109,7 @@
Delete all
- About Crosswords
+ About Crosswords…
- Game settings...
+ Game settings…
- Rename...
+ Rename…
- Move to group...
+ Move to group…Delete
@@ -185,7 +185,7 @@
- Download more...
+ Download more…
- Counts and values
+ Counts and values…
- Tiles remaining
+ Tiles remaining…
- Game history
+ Game history…
- Not used yet...
+ Not used yet…Wordlists
@@ -911,7 +911,7 @@
Hide main-page hintIt\'s useful only when you\'re
- starting out...
+ starting out…
@@ -1414,7 +1414,7 @@
Guest wordlists; Host wins.
- Downloading %s...
+ Downloading %s…
- FYI...
+ FYI…
@@ -1579,7 +1579,7 @@
- A question...
+ A question…Scanning for Crosswords on paired devices
- Sending new game info...
+ Sending new game info…Waiting for connection[s]
@@ -2007,7 +2007,7 @@
Browse wordlist
- Loading game summary...
+ Loading game summary…This is a standalone game. There is
@@ -2107,7 +2107,7 @@
wordlist?Decline
- Downloading %s...
+ Downloading %s…Download finishedDownload unsuccessful
From 3067b5f9c1bea737d8a14a82ae9f059086097858 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Fri, 25 Oct 2013 07:15:43 -0700
Subject: [PATCH 084/240] make menu id names more consistent
---
.../XWords4/res/menu/games_list_menu.xml | 44 ++++-----
.../org/eehouse/android/xw4/GamesList.java | 98 +++++++++----------
2 files changed, 71 insertions(+), 71 deletions(-)
diff --git a/xwords4/android/XWords4/res/menu/games_list_menu.xml b/xwords4/android/XWords4/res/menu/games_list_menu.xml
index 8a8a84349..d3d0cc658 100644
--- a/xwords4/android/XWords4/res/menu/games_list_menu.xml
+++ b/xwords4/android/XWords4/res/menu/games_list_menu.xml
@@ -1,102 +1,102 @@
- \u0020É a única lista de
- palavras em %s instalada. Um ou mais jogos não poderão ser abertos
- sem ela.
+
+
+
- Para que jogadores essa lista
- de palavras deve ser a padrão para novos jogos? (o idioma %s será
- padrão para ambos.)
+
+
+
Are you sure you want to
- delete %s?
+ delete the wordlist[s] %s?
- \u0020It is the only %s
+ %1$s is the only %2$s
wordlist installed. One or more games will be unopenable
without it.
- For what players should this
- wordlist be the default for new games? (The language %s will be
- the default for both.)
+ For what players should the
+ wordlist %1$s be the default for new games? (The language %2$s will be
+ the default for both.)
diff --git a/xwords4/android/XWords4/res/xml/xwprefs.xml b/xwords4/android/XWords4/res/xml/xwprefs.xml
index fb690b6e7..c384a57dc 100644
--- a/xwords4/android/XWords4/res/xml/xwprefs.xml
+++ b/xwords4/android/XWords4/res/xml/xwprefs.xml
@@ -299,6 +299,11 @@
android:summary="Menuitems etc."
android:defaultValue="false"
/>
+
diff --git a/xwords4/android/XWords4/res/raw/changes b/xwords4/android/XWords4/res/raw/changes
index 9cd34abd2..58ac03818 100644
--- a/xwords4/android/XWords4/res/raw/changes
+++ b/xwords4/android/XWords4/res/raw/changes
@@ -5,43 +5,19 @@
-Crosswords 4.4 beta 71 release
+Crosswords 4.4 beta 72 release
-
For this release I've redone how you work with games and groups of
- games in the main Games List screen. Now you select one or more
- games, and then the screen's main menu (including the right of the
- action bar for newer devices) changes based on the
- selection. Long-tap to select. "Context menus" are gone.
+
This release is for the new x86-processor-based Android devices
+ just coming out. Otherwise identical to beta 71, it replaces a
+ library for ARM processors with one for x86. Google Play Store
+ claims it will only let you download this release if you have a
+ compatible device, so here's hoping they got it right!
-
Please let me know what you think of this. Suggest tweaks. Should I
- redo the rest of the screens in this style; or, to the contrary, put
- things back the way they were? As always, you
- can email me here.
+
Thanks to Brendan Le Foll for the patches!
New with this release
-
More closely follow Android UI guidelines for main Games List
- screen
-
Show count of selected games or groups in title bar
-
Long-tap on games and groups selects or deselects rather
- than bringing up a menu
-
Tap on icon at left of game row selects or deselects
-
Tap on selected game deselects
-
Selecting any group deselects all games, and vice versa
-
Back button clears any selection, or exits if there is
- none
-
Most common actions now have icons for the action bar
-
A new game created when a group is selected is placed in
- that group
-
Clear selected games inside collapsing group
-
-
-
Add a couple of menu items to action bar for Board screen, as
- text for now pending getting icons
-
-
Remove introductory verbiage from main Games List screen
-
-
Fix bug on tiny-screen phones (Thanks O!)
+
Replace arm processor support with support for x86 processors.
This release is for the new x86-processor-based Android devices
- just coming out. Otherwise identical to beta 71, it replaces a
- library for ARM processors with one for x86. Google Play Store
- claims it will only let you download this release if you have a
- compatible device, so here's hoping they got it right!
+ just coming out. Otherwise identical to beta 71, it adds support for
+ x86 processors to existing support for ARM (which has been
+ 99.9% of the market until now.)
Thanks to Brendan Le Foll for the patches!
New with this release
-
Replace arm processor support with support for x86 processors.
+
Add support for x86 processors.
Next up
+
Add thumbnail of board to main screen
Use Actionbar and select/act pattern on more screens
Offer "Rematch" when game's over
From f1f02df355f885aeefbbb840166572a5d52d7f33 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Mon, 4 Nov 2013 19:19:09 -0800
Subject: [PATCH 130/240] remove file to be generated by build system
---
xwords4/android/XWords4/jni/.gitignore | 1 +
xwords4/android/XWords4/jni/Application.mk | 1 -
2 files changed, 1 insertion(+), 1 deletion(-)
create mode 100644 xwords4/android/XWords4/jni/.gitignore
delete mode 100644 xwords4/android/XWords4/jni/Application.mk
diff --git a/xwords4/android/XWords4/jni/.gitignore b/xwords4/android/XWords4/jni/.gitignore
new file mode 100644
index 000000000..fa22cd019
--- /dev/null
+++ b/xwords4/android/XWords4/jni/.gitignore
@@ -0,0 +1 @@
+Application.mk
diff --git a/xwords4/android/XWords4/jni/Application.mk b/xwords4/android/XWords4/jni/Application.mk
deleted file mode 100644
index 7a1599bb9..000000000
--- a/xwords4/android/XWords4/jni/Application.mk
+++ /dev/null
@@ -1 +0,0 @@
-APP_ABI := armeabi x86
From f0bfbedfb9ec90fb60370e2b713a3adbaf8472d4 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Mon, 4 Nov 2013 19:23:47 -0800
Subject: [PATCH 131/240] call script from build.xml to generate Application.mk
---
xwords4/android/XWords4/build.xml | 7 +++++++
xwords4/android/scripts/ndksetup.sh | 16 ++++++++++++++++
2 files changed, 23 insertions(+)
create mode 100755 xwords4/android/scripts/ndksetup.sh
diff --git a/xwords4/android/XWords4/build.xml b/xwords4/android/XWords4/build.xml
index 9fd5842ec..77ee42d42 100644
--- a/xwords4/android/XWords4/build.xml
+++ b/xwords4/android/XWords4/build.xml
@@ -51,6 +51,9 @@
+
+
+
@@ -62,6 +65,10 @@
+
+
+
+
diff --git a/xwords4/android/scripts/ndksetup.sh b/xwords4/android/scripts/ndksetup.sh
new file mode 100755
index 000000000..304255284
--- /dev/null
+++ b/xwords4/android/scripts/ndksetup.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+set -u -e
+
+APPMK=./jni/Application.mk
+XWORDS_DEBUG_ARMONLY=${XWORDS_DEBUG_ARMONLY:-""}
+
+echo "# Generated by $0; do not edit!!!" > $APPMK
+
+if [ "$1" = "release" ]; then
+ echo "APP_ABI := armeabi x86" >> $APPMK
+elif [ -n "$XWORDS_DEBUG_ARMONLY" ]; then
+ echo "APP_ABI := armeabi" >> $APPMK
+else
+ echo "APP_ABI := armeabi x86" >> $APPMK
+fi
From de284588f7bc31b06cddca373ddae95f6bff3fe3 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Tue, 5 Nov 2013 06:36:16 -0800
Subject: [PATCH 132/240] test for X86 developers too
---
xwords4/android/scripts/ndksetup.sh | 3 +++
1 file changed, 3 insertions(+)
diff --git a/xwords4/android/scripts/ndksetup.sh b/xwords4/android/scripts/ndksetup.sh
index 304255284..873f914bd 100755
--- a/xwords4/android/scripts/ndksetup.sh
+++ b/xwords4/android/scripts/ndksetup.sh
@@ -4,6 +4,7 @@ set -u -e
APPMK=./jni/Application.mk
XWORDS_DEBUG_ARMONLY=${XWORDS_DEBUG_ARMONLY:-""}
+XWORDS_DEBUG_X86ONLY=${XWORDS_DEBUG_X86ONLYx:-""}
echo "# Generated by $0; do not edit!!!" > $APPMK
@@ -11,6 +12,8 @@ if [ "$1" = "release" ]; then
echo "APP_ABI := armeabi x86" >> $APPMK
elif [ -n "$XWORDS_DEBUG_ARMONLY" ]; then
echo "APP_ABI := armeabi" >> $APPMK
+elif [ -n "$XWORDS_DEBUG_X86ONLY" ]; then
+ echo "APP_ABI := x86" >> $APPMK
else
echo "APP_ABI := armeabi x86" >> $APPMK
fi
From 499e07d84b3dcb49a53daf5ef107bef1f11a19f5 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Tue, 5 Nov 2013 06:38:48 -0800
Subject: [PATCH 133/240] follow convention: width usually comes before height
---
xwords4/android/XWords4/jni/xwjni.c | 4 ++--
.../XWords4/src/org/eehouse/android/xw4/jni/XwJNI.java | 2 +-
xwords4/common/board.c | 2 +-
xwords4/common/board.h | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/xwords4/android/XWords4/jni/xwjni.c b/xwords4/android/XWords4/jni/xwjni.c
index bd23cb024..8ad4546e5 100644
--- a/xwords4/android/XWords4/jni/xwjni.c
+++ b/xwords4/android/XWords4/jni/xwjni.c
@@ -635,7 +635,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1draw
JNIEXPORT void JNICALL
Java_org_eehouse_android_xw4_jni_XwJNI_board_1figureLayout
( JNIEnv* env, jclass C, jint gamePtr, jobject jgi,
- jint scorePct, jint trayPct, jint fontHt, jint fontWidth,
+ jint scorePct, jint trayPct, jint fontWidth, jint fontHt,
jboolean squareTiles, jobject jbounds, jobject jdims )
{
LOG_FUNC();
@@ -650,7 +650,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1figureLayout
BoardDims dims;
board_figureLayout( state->game.board, gi, scorePct, trayPct,
- fontHt, fontWidth, squareTiles, &bounds,
+ fontWidth, fontHt, squareTiles, &bounds,
((!!jdims) ? &dims : NULL) );
destroyGI( MPPARM(mpool) &gi );
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/XwJNI.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/XwJNI.java
index 7ccb00b1d..f9755a60b 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/XwJNI.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/XwJNI.java
@@ -152,7 +152,7 @@ public class XwJNI {
// Only if COMMON_LAYOUT defined
public static native void board_figureLayout( int gamePtr, CurGameInfo gi,
int scorePct, int trayPct,
- int fontHt, int fontWidth,
+ int fontWidth, int fontHt,
boolean squareTiles,
Rect bounds, BoardDims dims );
// Only if COMMON_LAYOUT defined
diff --git a/xwords4/common/board.c b/xwords4/common/board.c
index e7ac8a8de..413f597c6 100644
--- a/xwords4/common/board.c
+++ b/xwords4/common/board.c
@@ -393,7 +393,7 @@ board_reset( BoardCtxt* board )
void
board_figureLayout( BoardCtxt* board, const CurGameInfo* gi,
XP_U16 scorePct, XP_U16 trayPct,
- XP_U16 fontHt, XP_U16 fontWidth, XP_Bool squareTiles,
+ XP_U16 fontWidth, XP_U16 fontHt, XP_Bool squareTiles,
const XP_Rect* bounds, BoardDims* dimsp )
{
BoardDims ldims;
diff --git a/xwords4/common/board.h b/xwords4/common/board.h
index 111df3f54..27527b91d 100644
--- a/xwords4/common/board.h
+++ b/xwords4/common/board.h
@@ -87,7 +87,7 @@ typedef struct _BoardDims {
void board_figureLayout( BoardCtxt* board, const CurGameInfo* gi,
XP_U16 scorePct, XP_U16 trayPct,
- XP_U16 fontHt, XP_U16 fontWidth,
+ XP_U16 fontWidth, XP_U16 fontHt,
XP_Bool squareTiles, const XP_Rect* bounds,
/* out */ BoardDims* dims );
void board_applyLayout( BoardCtxt* board, const BoardDims* dims );
From 7c47c27ceed0a43c02f94419f1ec7d39853f6c37 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Mon, 4 Nov 2013 07:33:12 -0800
Subject: [PATCH 134/240] dispose any existing draw ctxt before setting
another.
---
xwords4/android/XWords4/jni/xwjni.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/xwords4/android/XWords4/jni/xwjni.c b/xwords4/android/XWords4/jni/xwjni.c
index 8ad4546e5..45ee90dd2 100644
--- a/xwords4/android/XWords4/jni/xwjni.c
+++ b/xwords4/android/XWords4/jni/xwjni.c
@@ -604,9 +604,13 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1setDraw
{
LOG_FUNC();
XWJNI_START_GLOBALS();
- XP_ASSERT( !globals->dctx );
- globals->dctx = makeDraw( MPPARM(mpool) &state->env, jdraw );
- board_setDraw( state->game.board, globals->dctx );
+
+ DrawCtx* newDraw = makeDraw( MPPARM(mpool) &state->env, jdraw );
+ board_setDraw( state->game.board, newDraw );
+
+ destroyDraw( &globals->dctx );
+ globals->dctx = newDraw;
+
XWJNI_END();
LOG_RETURN_VOID();
}
From 272fc6e8129cd7a9798236736c4e6d4c6ff933a4 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Wed, 6 Nov 2013 06:49:27 -0800
Subject: [PATCH 135/240] Move board_layout call onto jni thread, and change
order in which it's done to make that work. This is a snapshot: not all
boards draw completely, and there's other debugging to be done.
---
xwords4/android/XWords4/jni/xwjni.c | 32 +--
.../XWords4/res/values/common_rsrc.xml | 1 -
xwords4/android/XWords4/res/xml/xwprefs.xml | 5 -
.../org/eehouse/android/xw4/BoardCanvas.java | 56 +++--
.../org/eehouse/android/xw4/BoardView.java | 228 +++++-------------
.../eehouse/android/xw4/jni/JNIThread.java | 69 +++---
.../eehouse/android/xw4/jni/SyncedDraw.java | 2 +
.../org/eehouse/android/xw4/jni/XwJNI.java | 28 +--
8 files changed, 170 insertions(+), 251 deletions(-)
diff --git a/xwords4/android/XWords4/jni/xwjni.c b/xwords4/android/XWords4/jni/xwjni.c
index 45ee90dd2..69b2c0860 100644
--- a/xwords4/android/XWords4/jni/xwjni.c
+++ b/xwords4/android/XWords4/jni/xwjni.c
@@ -676,7 +676,8 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1applyLayout
board_applyLayout( state->game.board, &dims );
XWJNI_END();
}
-#endif
+
+#else
JNIEXPORT void JNICALL
Java_org_eehouse_android_xw4_jni_XwJNI_board_1setPos
@@ -689,20 +690,6 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1setPos
XWJNI_END();
}
-JNIEXPORT jboolean JNICALL
-Java_org_eehouse_android_xw4_jni_XwJNI_board_1zoom
-( JNIEnv* env, jclass C, jint gamePtr, jint zoomBy, jbooleanArray jCanZoom )
-{
- jboolean result;
- XWJNI_START();
- XP_Bool canInOut[2];
- result = board_zoom( state->game.board, zoomBy, canInOut );
- jboolean canZoom[2] = { canInOut[0], canInOut[1] };
- setBoolArray( env, jCanZoom, VSIZE(canZoom), canZoom );
- XWJNI_END();
- return result;
-}
-
JNIEXPORT void JNICALL
Java_org_eehouse_android_xw4_jni_XwJNI_board_1setScoreboardLoc
( JNIEnv *env, jclass C, jint gamePtr, jint left, jint top,
@@ -737,6 +724,21 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1setTrayLoc
minDividerWidth );
XWJNI_END();
}
+#endif
+
+JNIEXPORT jboolean JNICALL
+Java_org_eehouse_android_xw4_jni_XwJNI_board_1zoom
+( JNIEnv* env, jclass C, jint gamePtr, jint zoomBy, jbooleanArray jCanZoom )
+{
+ jboolean result;
+ XWJNI_START();
+ XP_Bool canInOut[2];
+ result = board_zoom( state->game.board, zoomBy, canInOut );
+ jboolean canZoom[2] = { canInOut[0], canInOut[1] };
+ setBoolArray( env, jCanZoom, VSIZE(canZoom), canZoom );
+ XWJNI_END();
+ return result;
+}
JNIEXPORT jboolean JNICALL
Java_org_eehouse_android_xw4_jni_XwJNI_board_1handlePenDown
diff --git a/xwords4/android/XWords4/res/values/common_rsrc.xml b/xwords4/android/XWords4/res/values/common_rsrc.xml
index f89799cb7..f7af55629 100644
--- a/xwords4/android/XWords4/res/values/common_rsrc.xml
+++ b/xwords4/android/XWords4/res/values/common_rsrc.xml
@@ -103,7 +103,6 @@
key_na_browseallkey_na_valueskey_enable_debug
- key_enable_commlaytkey_download_path
diff --git a/xwords4/android/XWords4/res/xml/xwprefs.xml b/xwords4/android/XWords4/res/xml/xwprefs.xml
index c384a57dc..fb690b6e7 100644
--- a/xwords4/android/XWords4/res/xml/xwprefs.xml
+++ b/xwords4/android/XWords4/res/xml/xwprefs.xml
@@ -299,11 +299,6 @@
android:summary="Menuitems etc."
android:defaultValue="false"
/>
- (If relevant, please include the
version: \"%s\"; and make/model of your phone or
- tablet.)"
+ tablet.)
Turn Bluetooth on
@@ -2154,8 +2154,17 @@
now clears any selection instead of exiting. Hit it again to exit
the app.
- Games: %d"
- Groups: %d"
+ Games: %d
+ Groups: %dThumbnail size
- Wordlists: %d"
+ Wordlists: %d
+
+ Thumb disabled
+ Summayr thumb disbled
+ thumb_useactive
+ summary_thumb_useactive
+
+ Thumbnail prefs
+ prefs_thumb_summary
+
diff --git a/xwords4/android/XWords4/res/xml/xwprefs.xml b/xwords4/android/XWords4/res/xml/xwprefs.xml
index e2a2ca483..3e2c3affe 100644
--- a/xwords4/android/XWords4/res/xml/xwprefs.xml
+++ b/xwords4/android/XWords4/res/xml/xwprefs.xml
@@ -138,13 +138,29 @@
android:defaultValue="false"
/>
-
+
+
+
+
+
+
+ = 0 );
db.close();
+
+ notifyListeners( rowid, false );
}
}
}
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java
index a94394242..8233c4435 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java
@@ -188,7 +188,9 @@ public class GameListItem extends LinearLayout
R.drawable.expander_ic_minimized);
m_hideable.setVisibility( m_expanded? View.VISIBLE : View.GONE );
if ( GitVersion.THUMBNAIL_SUPPORTED ) {
- m_thumb.setVisibility( m_expanded ? View.VISIBLE : View.GONE );
+ int vis = m_expanded && XWPrefs.getThumbEnabled( m_context )
+ ? View.VISIBLE : View.GONE;
+ m_thumb.setVisibility( vis );
}
m_name.setBackgroundColor( android.R.color.transparent );
@@ -299,12 +301,7 @@ public class GameListItem extends LinearLayout
if ( GitVersion.THUMBNAIL_SUPPORTED ) {
m_thumb = (ImageView)findViewById( R.id.thumbnail );
- Bitmap bmp = summary.getThumbnail();
- if ( null == bmp ) {
- m_thumb.setVisibility( View.GONE );
- } else {
- m_thumb.setImageBitmap( bmp );
- }
+ m_thumb.setImageBitmap( summary.getThumbnail() );
}
tview = (TextView)findViewById( R.id.role );
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWPrefs.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWPrefs.java
index ac2e48a51..05b3bf62d 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWPrefs.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWPrefs.java
@@ -328,13 +328,16 @@ public class XWPrefs {
return posns;
}
+ public static boolean getThumbEnabled( Context context )
+ {
+ return !getPrefsBoolean( context, R.string.key_thumb_disabled, false );
+ }
+
public static int getThumbScale( Context context )
{
String scale = getPrefsString( context, R.string.key_thumbsize );
int result = -1;
- if ( context.getString(R.string.game_thumb_off).equals(scale) ) {
- result = 0;
- } else if ( context.getString(R.string.game_thumb_third).equals(scale) ) {
+ if ( context.getString(R.string.game_thumb_third).equals(scale) ) {
result = 3;
} else if ( context.getString(R.string.game_thumb_quarter).equals(scale) ) {
result = 4;
From e780b536f9b75a31445a0ab3d2dd3f5271f975aa Mon Sep 17 00:00:00 2001
From: Eric House
Date: Thu, 7 Nov 2013 19:28:00 -0800
Subject: [PATCH 143/240] obey thumb size preference. Currently "1/3" means
1/3 the size of the smaller screen dimension. There may be a better scale.
---
.../XWords4/res/values/common_rsrc.xml | 2 ++
.../android/XWords4/res/values/strings.xml | 2 +-
.../eehouse/android/xw4/BoardActivity.java | 8 ++++++-
.../src/org/eehouse/android/xw4/XWPrefs.java | 21 ++++++++++++-------
4 files changed, 23 insertions(+), 10 deletions(-)
diff --git a/xwords4/android/XWords4/res/values/common_rsrc.xml b/xwords4/android/XWords4/res/values/common_rsrc.xml
index 39b7847fa..a7dd9bebb 100644
--- a/xwords4/android/XWords4/res/values/common_rsrc.xml
+++ b/xwords4/android/XWords4/res/values/common_rsrc.xml
@@ -139,6 +139,7 @@
Write DB to SD cardLoad DB from SD card
+ 1/21/31/41/5
@@ -291,6 +292,7 @@
+ @string/game_thumb_half@string/game_thumb_third@string/game_thumb_quarter@string/game_thumb_fifth
diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml
index 0c738c21f..86d7c9587 100644
--- a/xwords4/android/XWords4/res/values/strings.xml
+++ b/xwords4/android/XWords4/res/values/strings.xml
@@ -2160,7 +2160,7 @@
Wordlists: %dThumb disabled
- Summayr thumb disbled
+ Summary thumb disbledthumb_useactivesummary_thumb_useactive
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java
index eccdd44ae..a26c17120 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java
@@ -20,6 +20,7 @@
package org.eehouse.android.xw4;
+import android.view.Display;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
@@ -2062,7 +2063,12 @@ public class BoardActivity extends XWActivity
if ( XWPrefs.getThumbEnabled( this ) ) {
int scale = XWPrefs.getThumbScale( this );
Assert.assertTrue( 0 < scale );
- final int size = 15 * (9 + scale);
+
+ Display display = getWindowManager().getDefaultDisplay();
+ int width = display.getWidth();
+ int height = display.getHeight();
+ int dim = Math.min( width, height ) / scale;
+ int size = dim - (dim % 15);
thumb = Bitmap.createBitmap( size, size, Bitmap.Config.ARGB_8888 );
Rect bounds = new Rect( 0, 0, size, size );
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWPrefs.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWPrefs.java
index 05b3bf62d..f85e71743 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWPrefs.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWPrefs.java
@@ -337,14 +337,19 @@ public class XWPrefs {
{
String scale = getPrefsString( context, R.string.key_thumbsize );
int result = -1;
- if ( context.getString(R.string.game_thumb_third).equals(scale) ) {
- result = 3;
- } else if ( context.getString(R.string.game_thumb_quarter).equals(scale) ) {
- result = 4;
- } else if ( context.getString(R.string.game_thumb_fifth).equals(scale) ) {
- result = 5;
- } else if ( context.getString(R.string.game_thumb_sixth).equals(scale) ) {
- result = 6;
+ final int[][] data = {
+ { R.string.game_thumb_half, 2 }
+ ,{ R.string.game_thumb_third, 3 }
+ ,{ R.string.game_thumb_quarter, 4 }
+ ,{ R.string.game_thumb_fifth, 5 }
+ ,{ R.string.game_thumb_sixth, 6 }
+ };
+
+ for ( int[] datum : data ) {
+ if ( context.getString(datum[0]).equals(scale) ) {
+ result = datum[1];
+ break;
+ }
}
return result;
}
From 71d83e188ec4d064148983254b359f0b8b93a0a8 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Thu, 7 Nov 2013 19:54:13 -0800
Subject: [PATCH 144/240] null param ok for board_getActiveRect in jni
---
xwords4/android/XWords4/jni/xwjni.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/xwords4/android/XWords4/jni/xwjni.c b/xwords4/android/XWords4/jni/xwjni.c
index 826459e9b..21aca5e06 100644
--- a/xwords4/android/XWords4/jni/xwjni.c
+++ b/xwords4/android/XWords4/jni/xwjni.c
@@ -755,8 +755,10 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1getActiveRect
setInt( env, jrect, "top", rect.top );
setInt( env, jrect, "right", rect.left + rect.width );
setInt( env, jrect, "bottom", rect.top + rect.height );
- setIntInArray( env, dims, 0, nCols );
- setIntInArray( env, dims, 1, nRows );
+ if ( !!dims ) {
+ setIntInArray( env, dims, 0, nCols );
+ setIntInArray( env, dims, 1, nRows );
+ }
}
XWJNI_END();
return result;
From 9e87a5ee927a5f8a24c9ed0b0762d69a90ba38ed Mon Sep 17 00:00:00 2001
From: Eric House
Date: Thu, 7 Nov 2013 19:55:01 -0800
Subject: [PATCH 145/240] implement getting active rect when that pref is set
---
.../eehouse/android/xw4/BoardActivity.java | 32 ++++++++++++++++---
.../src/org/eehouse/android/xw4/XWPrefs.java | 5 +++
2 files changed, 33 insertions(+), 4 deletions(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java
index a26c17120..bd4dfebb6 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java
@@ -20,7 +20,6 @@
package org.eehouse.android.xw4;
-import android.view.Display;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
@@ -40,6 +39,7 @@ import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
+import android.view.Display;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuInflater;
@@ -2061,6 +2061,7 @@ public class BoardActivity extends XWActivity
if ( GitVersion.THUMBNAIL_SUPPORTED ) {
Bitmap thumb = null;
if ( XWPrefs.getThumbEnabled( this ) ) {
+ int nCols = m_gi.boardSize;
int scale = XWPrefs.getThumbScale( this );
Assert.assertTrue( 0 < scale );
@@ -2068,7 +2069,22 @@ public class BoardActivity extends XWActivity
int width = display.getWidth();
int height = display.getHeight();
int dim = Math.min( width, height ) / scale;
- int size = dim - (dim % 15);
+ int size = dim - (dim % nCols);
+
+ // If user wants active rect, we try to make it as
+ // large as possible while still not exceeding the
+ // scale. Since we're only using a fraction of the
+ // board, the board we draw before clipping may be
+ // huge.
+ int[] dims = new int[2];
+ Rect activeRect =
+ XWPrefs.getUseActiveRect( this ) ? new Rect() : null;
+ if ( null != activeRect ) {
+ dims = new int[2];
+ XwJNI.board_getActiveRect( m_jniGamePtr, activeRect, dims );
+ int numCells = Math.max( dims[0], dims[1] );
+ size = size * nCols / numCells;
+ }
thumb = Bitmap.createBitmap( size, size, Bitmap.Config.ARGB_8888 );
Rect bounds = new Rect( 0, 0, size, size );
@@ -2077,8 +2093,16 @@ public class BoardActivity extends XWActivity
ThumbCanvas canvas = new ThumbCanvas( this, thumb );
XwJNI.board_setDraw( m_jniGamePtr, canvas );
- XwJNI.board_invalAll( m_jniGamePtr );
- XwJNI.board_draw( m_jniGamePtr );
+ XwJNI.board_invalAll( m_jniGamePtr );
+ XwJNI.board_draw( m_jniGamePtr );
+
+ if ( null != activeRect ) {
+ XwJNI.board_getActiveRect( m_jniGamePtr, activeRect, null );
+ thumb = Bitmap.createBitmap( thumb, activeRect.left,
+ activeRect.top,
+ activeRect.width(),
+ activeRect.height() );
+ }
}
DBUtils.saveThumbnail( this, m_gameLock, thumb );
}
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWPrefs.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWPrefs.java
index f85e71743..bb768e55b 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWPrefs.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWPrefs.java
@@ -333,6 +333,11 @@ public class XWPrefs {
return !getPrefsBoolean( context, R.string.key_thumb_disabled, false );
}
+ public static boolean getUseActiveRect( Context context )
+ {
+ return getPrefsBoolean( context, R.string.key_thumb_useactive, false );
+ }
+
public static int getThumbScale( Context context )
{
String scale = getPrefsString( context, R.string.key_thumbsize );
From ecb225a6a818972d685591cf08141282d5bfc1a5 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Thu, 7 Nov 2013 20:06:51 -0800
Subject: [PATCH 146/240] try larger font size on high-res screens
---
.../XWords4/src/org/eehouse/android/xw4/BoardActivity.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java
index bd4dfebb6..1d0eb400c 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java
@@ -2088,7 +2088,7 @@ public class BoardActivity extends XWActivity
thumb = Bitmap.createBitmap( size, size, Bitmap.Config.ARGB_8888 );
Rect bounds = new Rect( 0, 0, size, size );
- XwJNI.board_figureLayout( m_jniGamePtr, m_gi, 0, 0, 5, 5, false,
+ XwJNI.board_figureLayout( m_jniGamePtr, m_gi, 0, 0, 20, 20, false,
bounds, null );
ThumbCanvas canvas = new ThumbCanvas( this, thumb );
From b2f864c7ce6c32df864a49bcf31e48380a10a4f9 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Fri, 8 Nov 2013 05:44:16 -0800
Subject: [PATCH 147/240] frame thumbnail in grey; tweak defaults
---
xwords4/android/XWords4/res/layout/game_list_item.xml | 5 ++---
xwords4/android/XWords4/res/xml/xwprefs.xml | 4 ++--
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/xwords4/android/XWords4/res/layout/game_list_item.xml b/xwords4/android/XWords4/res/layout/game_list_item.xml
index a396420af..a0b283286 100644
--- a/xwords4/android/XWords4/res/layout/game_list_item.xml
+++ b/xwords4/android/XWords4/res/layout/game_list_item.xml
@@ -42,9 +42,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
- android:paddingRight="2dip"
- android:paddingTop="2dip"
- android:paddingBottom="2dip"
+ android:padding="2dip"
+ android:background="#FF7F7F7F"
/>
- Loading game summary…
+ Building game summary…This is a standalone game. There is
From 8099b77e521a69a5d6eea25e3265556b92a3a7c1 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Mon, 11 Nov 2013 20:44:08 -0800
Subject: [PATCH 176/240] refuse to a create second game from an invitation
unless a debug pref is set.
---
xwords4/android/XWords4/res/values/common_rsrc.xml | 4 ++++
xwords4/android/XWords4/res/values/strings.xml | 2 +-
xwords4/android/XWords4/res/xml/xwprefs.xml | 6 ++++++
.../XWords4/src/org/eehouse/android/xw4/GamesList.java | 4 +++-
.../XWords4/src/org/eehouse/android/xw4/XWPrefs.java | 5 +++++
5 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/xwords4/android/XWords4/res/values/common_rsrc.xml b/xwords4/android/XWords4/res/values/common_rsrc.xml
index fe8db7947..2f4f07742 100644
--- a/xwords4/android/XWords4/res/values/common_rsrc.xml
+++ b/xwords4/android/XWords4/res/values/common_rsrc.xml
@@ -107,6 +107,7 @@
key_na_browseallkey_na_valueskey_enable_debug
+ key_enable_dup_invitekey_download_path
@@ -138,6 +139,9 @@
%1$s/%2$sWrite DB to SD cardLoad DB from SD card
+ Accept duplicate invites
+ Accept invitations more than once
+
1/21/3
diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml
index 4a07092f8..081b9237b 100644
--- a/xwords4/android/XWords4/res/values/strings.xml
+++ b/xwords4/android/XWords4/res/values/strings.xml
@@ -2166,5 +2166,5 @@
ThumbnailsSetting for game snapshots
-
+ Invitation ignored: already used
diff --git a/xwords4/android/XWords4/res/xml/xwprefs.xml b/xwords4/android/XWords4/res/xml/xwprefs.xml
index 7f99e9a11..b049b7e26 100644
--- a/xwords4/android/XWords4/res/xml/xwprefs.xml
+++ b/xwords4/android/XWords4/res/xml/xwprefs.xml
@@ -325,6 +325,12 @@
android:defaultValue="false"
/>
+
+
-
+
+
+
+
+
+
+
+
+
+
SMS/TextEmail
+ NFC
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java
index 493ecc706..eb860b9cf 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java
@@ -905,8 +905,7 @@ public class BoardActivity extends XWActivity
{
if ( LAUNCH_INVITE_ACTION == id ) {
if ( DlgDelegate.DISMISS_BUTTON != which ) {
- GameUtils.launchInviteActivity( BoardActivity.this,
- DlgDelegate.EMAIL_BTN == which,
+ GameUtils.launchInviteActivity( this, which,
m_room, null, m_gi.dictLang,
m_gi.dictName, m_gi.nPlayers );
}
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java
index 82e1435df..94f68bbf1 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java
@@ -49,6 +49,7 @@ public class DlgDelegate {
public static final int SMS_BTN = AlertDialog.BUTTON_POSITIVE;
public static final int EMAIL_BTN = AlertDialog.BUTTON_NEGATIVE;
+ public static final int NFC_BTN = AlertDialog.BUTTON_NEUTRAL;
public static final int DISMISS_BUTTON = 0;
public static final int SKIP_CALLBACK = -1;
@@ -404,12 +405,16 @@ public class DlgDelegate {
private Dialog createHtmlThenDialog( DlgState state, int id )
{
OnClickListener lstnr = mkCallbackClickListener( state );
- Dialog dialog = new AlertDialog.Builder( m_activity )
+ AlertDialog.Builder builder = new AlertDialog.Builder( m_activity )
.setTitle( R.string.query_title )
.setMessage( R.string.sms_or_email )
.setPositiveButton( R.string.button_text, lstnr )
- .setNegativeButton( R.string.button_html, lstnr )
- .create();
+ .setNegativeButton( R.string.button_html, lstnr );
+
+ if ( XWApp.NFC_ENABLED ) {
+ builder.setNeutralButton( R.string.button_nfc, lstnr );
+ }
+ Dialog dialog = builder.create();
return setCallbackDismissListener( dialog, state, id );
}
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java
index b8b32be5d..03be71b10 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java
@@ -26,11 +26,17 @@ import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Rect;
import android.net.Uri;
+
+import android.nfc.NdefMessage;
+import android.nfc.NdefRecord;
+import android.nfc.NfcAdapter;
+
import android.text.Html;
import android.text.TextUtils;
import android.view.Display;
import java.io.File;
import java.io.FileOutputStream;
+import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
@@ -534,8 +540,7 @@ public class GameUtils {
nPlayersT, nPlayersH, null, gameID, isHost );
}
- public static void launchInviteActivity( Context context,
- boolean choseEmail,
+ public static void launchInviteActivity( Activity activity, int chosen,
String room, String inviteID,
int lang, String dict,
int nPlayers )
@@ -543,51 +548,67 @@ public class GameUtils {
if ( null == inviteID ) {
inviteID = makeRandomID();
}
- Uri gameUri = NetLaunchInfo.makeLaunchUri( context, room, inviteID,
+ Uri gameUri = NetLaunchInfo.makeLaunchUri( activity, room, inviteID,
lang, dict, nPlayers );
-
if ( null != gameUri ) {
- int fmtId = choseEmail? R.string.invite_htmf : R.string.invite_txtf;
- int choiceID;
- String message = context.getString( fmtId, gameUri.toString() );
-
- Intent intent = new Intent();
- if ( choseEmail ) {
- intent.setAction( Intent.ACTION_SEND );
- String subject =
- Utils.format( context, R.string.invite_subjectf, room );
- intent.putExtra( Intent.EXTRA_SUBJECT, subject );
- intent.putExtra( Intent.EXTRA_TEXT, Html.fromHtml(message) );
-
- File attach = null;
- File tmpdir = XWApp.ATTACH_SUPPORTED ?
- DictUtils.getDownloadDir( context ) : null;
- if ( null != tmpdir ) { // no attachment
- attach = makeJsonFor( tmpdir, room, inviteID, lang,
- dict, nPlayers );
- }
-
- if ( null == attach ) { // no attachment
- intent.setType( "message/rfc822");
- } else {
- String mime = context.getString( R.string.invite_mime );
- intent.setType( mime );
- Uri uri = Uri.fromFile( attach );
- intent.putExtra( Intent.EXTRA_STREAM, uri );
- }
-
- choiceID = R.string.invite_chooser_email;
+ if ( DlgDelegate.NFC_BTN == chosen ) {
+ DbgUtils.logf( "wants to launch NFC" );
+ NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter( activity );
+ NdefMessage msg = new NdefMessage( new NdefRecord[] {
+ new NdefRecord(NdefRecord.TNF_MIME_MEDIA,
+ "application/org.eehouse.android.xw4"
+ .getBytes(Charset.forName("US-ASCII")),
+ new byte[0], "Beam me up, Android!"
+ .getBytes(Charset.forName("US-ASCII")))
+ ,NdefRecord.createApplicationRecord("org.eehouse.android.xw4")
+ });
+ nfcAdapter.setNdefPushMessage( msg, activity );
+ Utils.showToast( activity, "Tap the receiving device now" );
} else {
- intent.setAction( Intent.ACTION_VIEW );
- intent.setType( "vnd.android-dir/mms-sms" );
- intent.putExtra( "sms_body", message );
- choiceID = R.string.invite_chooser_sms;
- }
+ boolean choseEmail = DlgDelegate.EMAIL_BTN == chosen;
- String choiceType = context.getString( choiceID );
- String chooserMsg =
- Utils.format( context, R.string.invite_chooserf, choiceType );
- context.startActivity( Intent.createChooser( intent, chooserMsg ) );
+ int fmtId = choseEmail? R.string.invite_htmf : R.string.invite_txtf;
+ int choiceID;
+ String message = activity.getString( fmtId, gameUri.toString() );
+
+ Intent intent = new Intent();
+ if ( choseEmail ) {
+ intent.setAction( Intent.ACTION_SEND );
+ String subject =
+ Utils.format( activity, R.string.invite_subjectf, room );
+ intent.putExtra( Intent.EXTRA_SUBJECT, subject );
+ intent.putExtra( Intent.EXTRA_TEXT, Html.fromHtml(message) );
+
+ File attach = null;
+ File tmpdir = XWApp.ATTACH_SUPPORTED ?
+ DictUtils.getDownloadDir( activity ) : null;
+ if ( null != tmpdir ) { // no attachment
+ attach = makeJsonFor( tmpdir, room, inviteID, lang,
+ dict, nPlayers );
+ }
+
+ if ( null == attach ) { // no attachment
+ intent.setType( "message/rfc822");
+ } else {
+ String mime = activity.getString( R.string.invite_mime );
+ intent.setType( mime );
+ Uri uri = Uri.fromFile( attach );
+ intent.putExtra( Intent.EXTRA_STREAM, uri );
+ }
+
+ choiceID = R.string.invite_chooser_email;
+ } else {
+ intent.setAction( Intent.ACTION_VIEW );
+ intent.setType( "vnd.android-dir/mms-sms" );
+ intent.putExtra( "sms_body", message );
+ choiceID = R.string.invite_chooser_sms;
+ }
+
+ String choiceType = activity.getString( choiceID );
+ String chooserMsg =
+ Utils.format( activity, R.string.invite_chooserf, choiceType );
+ activity.startActivity( Intent.createChooser( intent, chooserMsg ) );
+ }
}
}
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
index 065c527c8..59d3e815d 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
@@ -28,9 +28,13 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
+import android.nfc.NdefMessage;
+import android.nfc.NfcAdapter;
+
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
+import android.os.Parcelable;
import android.preference.PreferenceManager;
import android.view.Menu;
import android.view.MenuInflater;
@@ -1123,6 +1127,19 @@ public class GamesList extends XWExpandableListActivity
}
}
+ private void tryNFCIntent( Intent intent )
+ {
+ if ( NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction()) ) {
+ Parcelable[] rawMsgs =
+ intent.getParcelableArrayExtra( NfcAdapter.EXTRA_NDEF_MESSAGES );
+ // only one message sent during the beam
+ NdefMessage msg = (NdefMessage) rawMsgs[0];
+ // record 0 contains the MIME type, record 1 is the AAR, if present
+ String txt = new String( msg.getRecords()[0].getPayload() );
+ DbgUtils.logf( "got message: %s", txt );
+ }
+ }
+
private void askDefaultNameIf()
{
if ( null == CommonPrefs.getDefaultPlayerName( this, 0, false ) ) {
@@ -1253,6 +1270,7 @@ public class GamesList extends XWExpandableListActivity
startHasGameID( intent );
startHasRowID( intent );
tryAlert( intent );
+ tryNFCIntent( intent );
}
private void doOpenGame( Object[] params )
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameActivity.java
index 8e865c560..e1abb8a82 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameActivity.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameActivity.java
@@ -158,7 +158,7 @@ public class NewGameActivity extends XWActivity {
switch( id ) {
case NEW_GAME_ACTION:
if ( DlgDelegate.DISMISS_BUTTON != which ) {
- makeNewGame( true, true, DlgDelegate.EMAIL_BTN == which );
+ makeNewGame( true, true, which );
}
break;
default:
@@ -311,12 +311,12 @@ public class NewGameActivity extends XWActivity {
// Let 'em cancel before we make the game
showEmailOrSMSThen( NEW_GAME_ACTION );
} else {
- makeNewGame( networked, launch, false );
+ makeNewGame( networked, launch, DlgDelegate.SMS_BTN );
}
}
private void makeNewGame( boolean networked, boolean launch,
- boolean choseEmail )
+ int chosen )
{
String room = null;
String inviteID = null;
@@ -337,7 +337,7 @@ public class NewGameActivity extends XWActivity {
if ( launch ) {
GameUtils.launchGame( this, rowid, networked );
if ( networked ) {
- GameUtils.launchInviteActivity( this, choseEmail, room,
+ GameUtils.launchInviteActivity( this, chosen, room,
inviteID, lang[0], dict[0],
nPlayers );
}
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWApp.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWApp.java
index 27fba48bf..bdb9588a8 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWApp.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWApp.java
@@ -40,6 +40,7 @@ public class XWApp extends Application {
public static final boolean DEBUG_EXP_TIMERS = false && DEBUG;
public static final boolean GCM_IGNORED = false;
public static final boolean UDP_ENABLED = true;
+ public static final boolean NFC_ENABLED = true;
public static final String SMS_PUBLIC_HEADER = "-XW4";
public static final int MAX_TRAY_TILES = 7; // comtypes.h
From d0313d3c4b96c51530ad3ec2ee747dd887f27a01 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Mon, 11 Nov 2013 22:06:28 -0800
Subject: [PATCH 179/240] package game-start data into a json and send it via
nfc, then open it on the other end. Works to start a game!
---
.../org/eehouse/android/xw4/GameUtils.java | 24 ++++++++-----
.../org/eehouse/android/xw4/GamesList.java | 8 +++--
.../eehouse/android/xw4/NetLaunchInfo.java | 34 +++++++++++++++++++
3 files changed, 56 insertions(+), 10 deletions(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java
index 03be71b10..59e482470 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java
@@ -548,19 +548,27 @@ public class GameUtils {
if ( null == inviteID ) {
inviteID = makeRandomID();
}
- Uri gameUri = NetLaunchInfo.makeLaunchUri( activity, room, inviteID,
- lang, dict, nPlayers );
- if ( null != gameUri ) {
+ String msgString;
+ if ( DlgDelegate.NFC_BTN == chosen ) {
+ msgString = NetLaunchInfo.makeLaunchJSON( activity, room, inviteID,
+ lang, dict, nPlayers );
+ } else {
+ Uri gameUri = NetLaunchInfo.makeLaunchUri( activity, room, inviteID,
+ lang, dict, nPlayers );
+ msgString = null == gameUri ? null : gameUri.toString();
+ }
+
+ if ( null != msgString ) {
if ( DlgDelegate.NFC_BTN == chosen ) {
- DbgUtils.logf( "wants to launch NFC" );
NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter( activity );
NdefMessage msg = new NdefMessage( new NdefRecord[] {
new NdefRecord(NdefRecord.TNF_MIME_MEDIA,
"application/org.eehouse.android.xw4"
.getBytes(Charset.forName("US-ASCII")),
- new byte[0], "Beam me up, Android!"
- .getBytes(Charset.forName("US-ASCII")))
- ,NdefRecord.createApplicationRecord("org.eehouse.android.xw4")
+ new byte[0], msgString.
+ getBytes(Charset.forName("US-ASCII")))
+ ,NdefRecord.
+ createApplicationRecord("org.eehouse.android.xw4")
});
nfcAdapter.setNdefPushMessage( msg, activity );
Utils.showToast( activity, "Tap the receiving device now" );
@@ -569,7 +577,7 @@ public class GameUtils {
int fmtId = choseEmail? R.string.invite_htmf : R.string.invite_txtf;
int choiceID;
- String message = activity.getString( fmtId, gameUri.toString() );
+ String message = activity.getString( fmtId, msgString );
Intent intent = new Intent();
if ( choseEmail ) {
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
index 59d3e815d..bbc802f6d 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
@@ -1135,8 +1135,12 @@ public class GamesList extends XWExpandableListActivity
// only one message sent during the beam
NdefMessage msg = (NdefMessage) rawMsgs[0];
// record 0 contains the MIME type, record 1 is the AAR, if present
- String txt = new String( msg.getRecords()[0].getPayload() );
- DbgUtils.logf( "got message: %s", txt );
+ String data = new String( msg.getRecords()[0].getPayload() );
+
+ NetLaunchInfo nli = new NetLaunchInfo( data );
+ if ( nli.isValid() ) {
+ startNewNetGame( nli );
+ }
}
}
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NetLaunchInfo.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NetLaunchInfo.java
index 878316cf1..df416e93a 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NetLaunchInfo.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NetLaunchInfo.java
@@ -57,6 +57,21 @@ public class NetLaunchInfo {
bundle.putBoolean( VALID, m_valid );
}
+ public NetLaunchInfo( String data )
+ {
+ try {
+ JSONObject json = new JSONObject( data );
+ room = json.getString( MultiService.ROOM );
+ inviteID = json.getString( MultiService.INVITEID );
+ lang = json.getInt( MultiService.LANG );
+ dict = json.getString( MultiService.DICT );
+ nPlayersT = json.getInt( MultiService.NPLAYERST );
+ m_valid = true;
+ } catch ( org.json.JSONException jse ) {
+ m_valid = false;
+ }
+ }
+
public NetLaunchInfo( Bundle bundle )
{
lang = bundle.getInt( LANG );
@@ -134,6 +149,25 @@ public class NetLaunchInfo {
return ub.build();
}
+ public static String makeLaunchJSON( Context context, String room,
+ String inviteID, int lang,
+ String dict, int nPlayersT )
+ {
+ String result = null;
+ try {
+ result = new JSONObject()
+ .put( MultiService.ROOM, room )
+ .put( MultiService.INVITEID, inviteID )
+ .put( MultiService.LANG, lang )
+ .put( MultiService.DICT, dict )
+ .put( MultiService.NPLAYERST, nPlayersT )
+ .toString();
+ } catch ( org.json.JSONException jse ) {
+ DbgUtils.loge( jse );
+ }
+ return result;
+ }
+
public boolean isValid()
{
return m_valid;
From 282b32396ffeae675a6e5ae1a3e6ab824c54a537 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Mon, 11 Nov 2013 21:35:42 -0800
Subject: [PATCH 180/240] don't log the one command that's supposed to get
posted post-stop
---
.../XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java
index 0ecf35c09..279b79a98 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java
@@ -651,7 +651,7 @@ public class JNIThread extends Thread {
{
QueueElem elem = new QueueElem( cmd, true, args );
m_queue.add( elem );
- if ( m_stopped ) {
+ if ( m_stopped && ! JNICmd.CMD_NONE.equals(cmd) ) {
DbgUtils.logf( "WARNING: adding %s to stopped thread!!!",
cmd.toString() );
DbgUtils.printStack();
From f14be36bbc0492069f1a9523f6ddb3811ef56fe6 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Tue, 12 Nov 2013 06:34:56 -0800
Subject: [PATCH 181/240] eliminate flicker on opening board: don't start
drawing tile if can't finish
---
.../org/eehouse/android/xw4/BoardCanvas.java | 118 +++++++++---------
1 file changed, 58 insertions(+), 60 deletions(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardCanvas.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardCanvas.java
index eeb509387..bc38efcea 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardCanvas.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardCanvas.java
@@ -549,43 +549,45 @@ public class BoardCanvas extends Canvas implements DrawCtx {
private boolean drawTileImpl( Rect rect, String text, int val,
int flags, boolean clearBack )
{
- boolean drew = true;
- // boolean valHidden = (flags & CELL_VALHIDDEN) != 0;
- boolean notEmpty = (flags & CELL_ISEMPTY) == 0;
- boolean isCursor = (flags & CELL_ISCURSOR) != 0;
+ boolean canDraw = figureFontDims();
+ if ( canDraw ) {
+ // boolean valHidden = (flags & CELL_VALHIDDEN) != 0;
+ boolean notEmpty = (flags & CELL_ISEMPTY) == 0;
+ boolean isCursor = (flags & CELL_ISCURSOR) != 0;
- save( Canvas.CLIP_SAVE_FLAG );
- rect.top += 1;
- clipRect( rect );
+ save( Canvas.CLIP_SAVE_FLAG );
+ rect.top += 1;
+ clipRect( rect );
- if ( clearBack ) {
- fillRectOther( rect, CommonPrefs.COLOR_BACKGRND );
- }
-
- if ( isCursor || notEmpty ) {
- int color = m_otherColors[isCursor? CommonPrefs.COLOR_FOCUS
- : CommonPrefs.COLOR_TILE_BACK];
- if ( !clearBack ) {
- color &= 0x7FFFFFFF; // translucent if being dragged.
+ if ( clearBack ) {
+ fillRectOther( rect, CommonPrefs.COLOR_BACKGRND );
}
- fillRect( rect, color );
- m_fillPaint.setColor( m_playerColors[m_trayOwner] );
+ if ( isCursor || notEmpty ) {
+ int color = m_otherColors[isCursor? CommonPrefs.COLOR_FOCUS
+ : CommonPrefs.COLOR_TILE_BACK];
+ if ( !clearBack ) {
+ color &= 0x7FFFFFFF; // translucent if being dragged.
+ }
+ fillRect( rect, color );
- if ( notEmpty ) {
- drew = positionDrawTile( rect, text, val );
+ m_fillPaint.setColor( m_playerColors[m_trayOwner] );
- Paint paint = getTileStrokePaint( rect );
- drawRect( rect, paint ); // frame
- if ( 0 != (flags & CELL_HIGHLIGHT) ) {
- int width = (int)paint.getStrokeWidth();
- rect.inset( width, width );
+ if ( notEmpty ) {
+ positionDrawTile( rect, text, val );
+
+ Paint paint = getTileStrokePaint( rect );
drawRect( rect, paint ); // frame
+ if ( 0 != (flags & CELL_HIGHLIGHT) ) {
+ int width = (int)paint.getStrokeWidth();
+ rect.inset( width, width );
+ drawRect( rect, paint ); // frame
+ }
}
}
+ restoreToCount(1); // in case new canvas....
}
- restoreToCount(1); // in case new canvas....
- return drew;
+ return canDraw;
} // drawTileImpl
private void drawCrosshairs( final Rect rect, final int flags )
@@ -662,43 +664,39 @@ public class BoardCanvas extends Canvas implements DrawCtx {
drawBitmap( bitmap, null, rect, m_drawPaint );
}
- private boolean positionDrawTile( final Rect rect, String text, int val )
+ private void positionDrawTile( final Rect rect, String text, int val )
{
- boolean canDraw = figureFontDims();
- if ( canDraw ) {
- final int offset = 2;
- if ( null != text ) {
- if ( null == m_letterRect ) {
- m_letterRect = new Rect( 0, 0, rect.width() - offset,
- rect.height() * 3 / 4 );
- }
- m_letterRect.offsetTo( rect.left + offset, rect.top + offset );
- drawIn( text, m_letterRect, m_fontDims, Paint.Align.LEFT );
- if ( FRAME_TRAY_RECTS ) {
- drawRect( m_letterRect, m_strokePaint );
- }
+ final int offset = 2;
+ if ( null != text ) {
+ if ( null == m_letterRect ) {
+ m_letterRect = new Rect( 0, 0, rect.width() - offset,
+ rect.height() * 3 / 4 );
}
-
- if ( val >= 0 ) {
- int divisor = m_hasSmallScreen ? 3 : 4;
- if ( null == m_valRect ) {
- m_valRect = new Rect( 0, 0, rect.width() / divisor,
- rect.height() / divisor );
- m_valRect.inset( offset, offset );
- }
- m_valRect.offsetTo( rect.right - (rect.width() / divisor),
- rect.bottom - (rect.height() / divisor) );
- text = String.format( "%d", val );
- m_fillPaint.setTextSize( m_valRect.height() );
- m_fillPaint.setTextAlign( Paint.Align.RIGHT );
- drawText( text, m_valRect.right, m_valRect.bottom,
- m_fillPaint );
- if ( FRAME_TRAY_RECTS ) {
- drawRect( m_valRect, m_strokePaint );
- }
+ m_letterRect.offsetTo( rect.left + offset, rect.top + offset );
+ drawIn( text, m_letterRect, m_fontDims, Paint.Align.LEFT );
+ if ( FRAME_TRAY_RECTS ) {
+ drawRect( m_letterRect, m_strokePaint );
+ }
+ }
+
+ if ( val >= 0 ) {
+ int divisor = m_hasSmallScreen ? 3 : 4;
+ if ( null == m_valRect ) {
+ m_valRect = new Rect( 0, 0, rect.width() / divisor,
+ rect.height() / divisor );
+ m_valRect.inset( offset, offset );
+ }
+ m_valRect.offsetTo( rect.right - (rect.width() / divisor),
+ rect.bottom - (rect.height() / divisor) );
+ text = String.format( "%d", val );
+ m_fillPaint.setTextSize( m_valRect.height() );
+ m_fillPaint.setTextAlign( Paint.Align.RIGHT );
+ drawText( text, m_valRect.right, m_valRect.bottom,
+ m_fillPaint );
+ if ( FRAME_TRAY_RECTS ) {
+ drawRect( m_valRect, m_strokePaint );
}
}
- return canDraw;
}
private void fillRectOther( Rect rect, int index )
From e2aea4a39eae44405c52269ef1f523332a16c2a8 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Tue, 12 Nov 2013 06:40:40 -0800
Subject: [PATCH 182/240] call through to canvas for current score to correctly
update menu
---
.../XWords4/src/org/eehouse/android/xw4/BoardCanvas.java | 5 +++++
.../XWords4/src/org/eehouse/android/xw4/BoardView.java | 3 +--
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardCanvas.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardCanvas.java
index bc38efcea..faf80aee5 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardCanvas.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardCanvas.java
@@ -176,6 +176,11 @@ public class BoardCanvas extends Canvas implements DrawCtx {
return m_trayOwner;
}
+ public int curPending()
+ {
+ return m_pendingScore;
+ }
+
public void setInTrade( boolean inTrade )
{
if ( m_inTrade != inTrade ) {
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java
index 6c570e67f..c060b46c5 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java
@@ -60,7 +60,6 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
private JNIThread m_jniThread;
private XWActivity m_parent;
private Rect m_boundsScratch;
- private int m_pendingScore;
private boolean m_measuredFromDims = false;
private BoardDims m_dims;
private CommsAddrRec.CommsConnType m_connType =
@@ -337,7 +336,7 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
public int curPending()
{
- return m_pendingScore;
+ return null == m_canvas? 0 : m_canvas.curPending();
}
private int getSpacing( MotionEvent event )
From 148da01fdc9dcd0895fb0770532792b1015728d7 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Tue, 12 Nov 2013 06:43:56 -0800
Subject: [PATCH 183/240] use save icon for commit/trade too
---
xwords4/android/XWords4/res/menu/board_menu.xml | 1 +
1 file changed, 1 insertion(+)
diff --git a/xwords4/android/XWords4/res/menu/board_menu.xml b/xwords4/android/XWords4/res/menu/board_menu.xml
index 9c1093c7c..b3be4cf3e 100644
--- a/xwords4/android/XWords4/res/menu/board_menu.xml
+++ b/xwords4/android/XWords4/res/menu/board_menu.xml
@@ -7,6 +7,7 @@
Date: Tue, 12 Nov 2013 07:05:37 -0800
Subject: [PATCH 184/240] Mark the current player's wordlist in wordlists popup
---
xwords4/android/XWords4/res/values/strings.xml | 2 ++
.../XWords4/src/org/eehouse/android/xw4/DictsActivity.java | 4 +++-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml
index 081b9237b..4273a5df5 100644
--- a/xwords4/android/XWords4/res/values/strings.xml
+++ b/xwords4/android/XWords4/res/values/strings.xml
@@ -2167,4 +2167,6 @@
ThumbnailsSetting for game snapshotsInvitation ignored: already used
+ %1$s (yours)
+
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsActivity.java
index 0c3dc9e70..c2bf31dc0 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsActivity.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsActivity.java
@@ -873,7 +873,9 @@ public class DictsActivity extends XWExpandableListActivity
.setOnMenuItemClickListener( listener );
// Add at top but save until have dal info
- MenuItem curItem = menu.add( curDict );
+ MenuItem curItem =
+ menu.add( context.getString( R.string.cur_menu_markerf,
+ curDict ) );
DictAndLoc[] dals = DictUtils.dictList( context );
for ( DictAndLoc dal : dals ) {
From 67197041174ff9cb1284c28f3a7810e6af77b29c Mon Sep 17 00:00:00 2001
From: Eric House
Date: Tue, 12 Nov 2013 08:02:14 -0800
Subject: [PATCH 185/240] remove excessive logging
---
.../XWords4/src/org/eehouse/android/xw4/BoardView.java | 6 ------
1 file changed, 6 deletions(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java
index c060b46c5..a4dac1b38 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java
@@ -199,7 +199,6 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
{
synchronized( this ) {
if ( layoutBoardOnce() && m_measuredFromDims ) {
- DbgUtils.logf( "BoardCanvas.onDraw() copying bitmap" );
canvas.drawBitmap( s_bitmap, 0, 0, m_drawPaint );
ConnStatusHandler.draw( m_context, canvas, getResources(),
0, 0, m_connType );
@@ -211,7 +210,6 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
private boolean layoutBoardOnce()
{
- DbgUtils.logf( "layoutBoardOnce()" );
final int width = getWidth();
final int height = getHeight();
boolean layoutDone = width == m_layoutWidth && height == m_layoutHeight;
@@ -243,13 +241,10 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
}
if ( null == s_bitmap ) {
- DbgUtils.logf( "making %dx%d static bitmap", bmWidth, bmHeight );
s_bitmap = Bitmap.createBitmap( bmWidth, bmHeight,
Bitmap.Config.ARGB_8888 );
}
if ( null == m_canvas ) {
- DbgUtils.logf( "layoutBoardOnce: allocating canvas for %d, %d",
- bmWidth, bmHeight );
m_canvas = new BoardCanvas( m_parent, s_bitmap, m_jniThread,
m_dims );
} else {
@@ -263,7 +258,6 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
m_layoutHeight = height;
layoutDone = true;
}
- DbgUtils.logf( "layoutBoardOnce()=>%b", layoutDone );
return layoutDone;
} // layoutBoardOnce
From e040aa388b9ce5bf18003e56fb9a38e08ae20fe4 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Tue, 12 Nov 2013 08:08:30 -0800
Subject: [PATCH 186/240] don't try to save to read-only lock; check for
non-existant games when summarizing: together these fix crash when deleting
after opening game whose remote partner has been deleted.
---
.../XWords4/src/org/eehouse/android/xw4/DBUtils.java | 2 +-
.../XWords4/src/org/eehouse/android/xw4/GameUtils.java | 7 +++++--
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java
index 4a4b32ca7..e77420fae 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java
@@ -256,7 +256,7 @@ public class DBUtils {
db.close();
}
- if ( null == summary ) {
+ if ( null == summary && lock.canWrite() ) {
summary = GameUtils.summarize( context, lock );
saveSummary( context, lock, summary );
}
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java
index b8b32be5d..0eb7f6eb1 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java
@@ -187,10 +187,13 @@ public class GameUtils {
public static GameSummary summarize( Context context, GameLock lock )
{
+ GameSummary result = null;
CurGameInfo gi = new CurGameInfo( context );
int gamePtr = loadMakeGame( context, gi, lock );
-
- return summarizeAndClose( context, lock, gamePtr, gi );
+ if ( 0 < gamePtr ) {
+ result = summarizeAndClose( context, lock, gamePtr, gi );
+ }
+ return result;
}
public static long dupeGame( Context context, long rowidIn )
From 8704efd38ec275f6c233568888459ba053ef959b Mon Sep 17 00:00:00 2001
From: Eric House
Date: Tue, 12 Nov 2013 18:39:13 -0800
Subject: [PATCH 187/240] add send-invites menuitem that's at top of board menu
but only visible when game's unconnected
---
xwords4/android/XWords4/img_src/send.svg | 11 +++++++++++
xwords4/android/XWords4/res/menu/board_menu.xml | 7 +++++++
xwords4/android/XWords4/res/values/strings.xml | 2 +-
.../src/org/eehouse/android/xw4/BoardActivity.java | 6 +++++-
4 files changed, 24 insertions(+), 2 deletions(-)
create mode 100644 xwords4/android/XWords4/img_src/send.svg
diff --git a/xwords4/android/XWords4/img_src/send.svg b/xwords4/android/XWords4/img_src/send.svg
new file mode 100644
index 000000000..1488968ee
--- /dev/null
+++ b/xwords4/android/XWords4/img_src/send.svg
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
diff --git a/xwords4/android/XWords4/res/menu/board_menu.xml b/xwords4/android/XWords4/res/menu/board_menu.xml
index b3be4cf3e..9bc13f55f 100644
--- a/xwords4/android/XWords4/res/menu/board_menu.xml
+++ b/xwords4/android/XWords4/res/menu/board_menu.xml
@@ -4,11 +4,18 @@
+
+
+
Setting for game snapshotsInvitation ignored: already used%1$s (yours)
-
+ Invite
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java
index 493ecc706..96c070fa1 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java
@@ -744,6 +744,7 @@ public class BoardActivity extends XWActivity
item.setTitle( strId );
}
+ Utils.setItemVisible( menu, R.id.board_menu_invite, 0 < m_missing );
Utils.setItemVisible( menu, R.id.board_menu_undo_last, !inTrade );
Utils.setItemVisible( menu, R.id.board_menu_tray, !inTrade );
@@ -843,7 +844,9 @@ public class BoardActivity extends XWActivity
case R.id.board_menu_undo_last:
showConfirmThen( R.string.confirm_undo_last, UNDO_LAST_ACTION );
break;
-
+ case R.id.board_menu_invite:
+ showDialog( DLG_INVITE );
+ break;
// small devices only
case R.id.board_menu_dict:
String dictName = m_gi.dictName( m_view.getCurPlayer() );
@@ -1295,6 +1298,7 @@ public class BoardActivity extends XWActivity
m_room = room;
m_missing = nMissing;
showDialog( DLG_INVITE );
+ Utils.invalidateOptionsMenuIf( this );
} else {
toastStr = getString( R.string.msg_relay_waiting, devOrder,
room, nMissing );
From f291ef7377947ebbe06615c4fc776cbb141cac5a Mon Sep 17 00:00:00 2001
From: Eric House
Date: Tue, 12 Nov 2013 18:58:13 -0800
Subject: [PATCH 188/240] remove dup import
---
xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java | 1 -
1 file changed, 1 deletion(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java
index 9a04d9de9..dc1151715 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java
@@ -28,7 +28,6 @@ import android.app.PendingIntent;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
-import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences.Editor;
import android.content.SharedPreferences;
From b3bc738cae19af347ebeca24285b40dbcc1c9ad5 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Tue, 12 Nov 2013 19:06:26 -0800
Subject: [PATCH 189/240] move nfc stuff into separate utility class, and check
API version for whether to support it. Oddly the app runs on 2.1 emulator
without classnotfound error -- I was expecting to have to use the interface
trick.
---
.../org/eehouse/android/xw4/DlgDelegate.java | 2 +-
.../org/eehouse/android/xw4/GameUtils.java | 17 +----
.../org/eehouse/android/xw4/GamesList.java | 13 +---
.../src/org/eehouse/android/xw4/NFCUtils.java | 70 +++++++++++++++++++
.../src/org/eehouse/android/xw4/XWApp.java | 1 -
5 files changed, 74 insertions(+), 29 deletions(-)
create mode 100644 xwords4/android/XWords4/src/org/eehouse/android/xw4/NFCUtils.java
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java
index 94f68bbf1..e209dcf4b 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java
@@ -411,7 +411,7 @@ public class DlgDelegate {
.setPositiveButton( R.string.button_text, lstnr )
.setNegativeButton( R.string.button_html, lstnr );
- if ( XWApp.NFC_ENABLED ) {
+ if ( NFCUtils.nfcAvail() ) {
builder.setNeutralButton( R.string.button_nfc, lstnr );
}
Dialog dialog = builder.create();
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java
index b6e3606cb..e2f89a64b 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java
@@ -27,16 +27,11 @@ import android.graphics.Bitmap;
import android.graphics.Rect;
import android.net.Uri;
-import android.nfc.NdefMessage;
-import android.nfc.NdefRecord;
-import android.nfc.NfcAdapter;
-
import android.text.Html;
import android.text.TextUtils;
import android.view.Display;
import java.io.File;
import java.io.FileOutputStream;
-import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
@@ -563,17 +558,7 @@ public class GameUtils {
if ( null != msgString ) {
if ( DlgDelegate.NFC_BTN == chosen ) {
- NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter( activity );
- NdefMessage msg = new NdefMessage( new NdefRecord[] {
- new NdefRecord(NdefRecord.TNF_MIME_MEDIA,
- "application/org.eehouse.android.xw4"
- .getBytes(Charset.forName("US-ASCII")),
- new byte[0], msgString.
- getBytes(Charset.forName("US-ASCII")))
- ,NdefRecord.
- createApplicationRecord("org.eehouse.android.xw4")
- });
- nfcAdapter.setNdefPushMessage( msg, activity );
+ NFCUtils.buildAndPush( activity, msgString );
Utils.showToast( activity, "Tap the receiving device now" );
} else {
boolean choseEmail = DlgDelegate.EMAIL_BTN == chosen;
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
index bbc802f6d..0342b8907 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
@@ -28,13 +28,10 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
-import android.nfc.NdefMessage;
-import android.nfc.NfcAdapter;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
-import android.os.Parcelable;
import android.preference.PreferenceManager;
import android.view.Menu;
import android.view.MenuInflater;
@@ -1129,14 +1126,8 @@ public class GamesList extends XWExpandableListActivity
private void tryNFCIntent( Intent intent )
{
- if ( NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction()) ) {
- Parcelable[] rawMsgs =
- intent.getParcelableArrayExtra( NfcAdapter.EXTRA_NDEF_MESSAGES );
- // only one message sent during the beam
- NdefMessage msg = (NdefMessage) rawMsgs[0];
- // record 0 contains the MIME type, record 1 is the AAR, if present
- String data = new String( msg.getRecords()[0].getPayload() );
-
+ String data = NFCUtils.getFromIntent( intent );
+ if ( null != data ) {
NetLaunchInfo nli = new NetLaunchInfo( data );
if ( nli.isValid() ) {
startNewNetGame( nli );
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NFCUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NFCUtils.java
new file mode 100644
index 000000000..8f4ba702a
--- /dev/null
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NFCUtils.java
@@ -0,0 +1,70 @@
+/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
+/*
+ * Copyright 2013 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.Activity;
+import android.content.Intent;
+import android.nfc.NdefMessage;
+import android.nfc.NdefRecord;
+import android.nfc.NfcAdapter;
+import android.os.Parcelable;
+import java.nio.charset.Charset;
+
+public class NFCUtils {
+ private static boolean s_inSDK =
+ 14 <= Integer.valueOf( android.os.Build.VERSION.SDK );
+
+ public static boolean nfcAvail()
+ {
+ return s_inSDK /*&& turnedOn*/;
+ }
+
+ public static void buildAndPush( Activity activity, String data )
+ {
+ NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter( activity );
+ NdefMessage msg = new NdefMessage( new NdefRecord[] {
+ new NdefRecord(NdefRecord.TNF_MIME_MEDIA,
+ "application/org.eehouse.android.xw4"
+ .getBytes(Charset.forName("US-ASCII")),
+ new byte[0],
+ data.getBytes(Charset.forName("US-ASCII")))
+ ,NdefRecord.
+ createApplicationRecord("org.eehouse.android.xw4")
+ });
+ nfcAdapter.setNdefPushMessage( msg, activity );
+ }
+
+ public static String getFromIntent( Intent intent )
+ {
+ String result = null;
+
+ if ( NfcAdapter.ACTION_NDEF_DISCOVERED.equals( intent.getAction() ) ) {
+ Parcelable[] rawMsgs =
+ intent.getParcelableArrayExtra( NfcAdapter.EXTRA_NDEF_MESSAGES );
+ // only one message sent during the beam
+ NdefMessage msg = (NdefMessage)rawMsgs[0];
+ // record 0 contains the MIME type, record 1 is the AAR, if present
+ result = new String( msg.getRecords()[0].getPayload() );
+ }
+
+ return result;
+ }
+}
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWApp.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWApp.java
index bdb9588a8..27fba48bf 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWApp.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWApp.java
@@ -40,7 +40,6 @@ public class XWApp extends Application {
public static final boolean DEBUG_EXP_TIMERS = false && DEBUG;
public static final boolean GCM_IGNORED = false;
public static final boolean UDP_ENABLED = true;
- public static final boolean NFC_ENABLED = true;
public static final String SMS_PUBLIC_HEADER = "-XW4";
public static final int MAX_TRAY_TILES = 7; // comtypes.h
From b7d756957c22e9ca5435c4b7b90ab0b549e01b0a Mon Sep 17 00:00:00 2001
From: Eric House
Date: Tue, 12 Nov 2013 19:12:47 -0800
Subject: [PATCH 190/240] test also whether NFC turned on
---
.../src/org/eehouse/android/xw4/DlgDelegate.java | 2 +-
.../src/org/eehouse/android/xw4/NFCUtils.java | 13 +++++++++++--
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java
index e209dcf4b..e672f361d 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java
@@ -411,7 +411,7 @@ public class DlgDelegate {
.setPositiveButton( R.string.button_text, lstnr )
.setNegativeButton( R.string.button_html, lstnr );
- if ( NFCUtils.nfcAvail() ) {
+ if ( NFCUtils.nfcAvail( m_activity ) ) {
builder.setNeutralButton( R.string.button_nfc, lstnr );
}
Dialog dialog = builder.create();
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NFCUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NFCUtils.java
index 8f4ba702a..e9316c9e8 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NFCUtils.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NFCUtils.java
@@ -21,10 +21,12 @@
package org.eehouse.android.xw4;
import android.app.Activity;
+import android.content.Context;
import android.content.Intent;
import android.nfc.NdefMessage;
import android.nfc.NdefRecord;
import android.nfc.NfcAdapter;
+import android.nfc.NfcManager;
import android.os.Parcelable;
import java.nio.charset.Charset;
@@ -32,9 +34,16 @@ public class NFCUtils {
private static boolean s_inSDK =
14 <= Integer.valueOf( android.os.Build.VERSION.SDK );
- public static boolean nfcAvail()
+ public static boolean nfcAvail( Context context )
{
- return s_inSDK /*&& turnedOn*/;
+ boolean result = s_inSDK;
+ if ( result ) {
+ NfcManager manager =
+ (NfcManager)context.getSystemService( Context.NFC_SERVICE );
+ NfcAdapter adapter = manager.getDefaultAdapter();
+ result = null != adapter && adapter.isEnabled();
+ }
+ return result;
}
public static void buildAndPush( Activity activity, String data )
From 735e42cd9028e45847eb1757dbd85a6fe0b6c755 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Wed, 13 Nov 2013 06:50:30 -0800
Subject: [PATCH 191/240] launch on tap even if selected
---
.../XWords4/src/org/eehouse/android/xw4/GameListItem.java | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java
index d1cf0cb14..3508f8e99 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java
@@ -84,9 +84,7 @@ public class GameListItem extends LinearLayout
@Override
public void onClick( View v ) {
// if selected, just un-select
- if ( m_selected ) {
- toggleSelected();
- } else if ( null != m_summary ) {
+ if ( null != m_summary ) {
m_cb.itemClicked( GameListItem.this, m_summary );
}
}
From d119033333112f17c48cacea0509c64346306d59 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Wed, 13 Nov 2013 06:51:36 -0800
Subject: [PATCH 192/240] use resource strings and apis rather than quoted
strings for nfc constants
---
xwords4/android/XWords4/AndroidManifest.xml | 2 +-
xwords4/android/XWords4/res/values/common_rsrc.xml | 2 +-
.../XWords4/src/org/eehouse/android/xw4/NFCUtils.java | 6 +++---
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/xwords4/android/XWords4/AndroidManifest.xml b/xwords4/android/XWords4/AndroidManifest.xml
index 24c504600..e1a19061a 100644
--- a/xwords4/android/XWords4/AndroidManifest.xml
+++ b/xwords4/android/XWords4/AndroidManifest.xml
@@ -80,7 +80,7 @@
-
+
diff --git a/xwords4/android/XWords4/res/values/common_rsrc.xml b/xwords4/android/XWords4/res/values/common_rsrc.xml
index 2f4f07742..69e7a3651 100644
--- a/xwords4/android/XWords4/res/values/common_rsrc.xml
+++ b/xwords4/android/XWords4/res/values/common_rsrc.xml
@@ -115,7 +115,7 @@
eehouse.org
-
+ application/org.eehouse.android.xw4eehouse.org/and/application/x-xwordsinvite
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NFCUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NFCUtils.java
index e9316c9e8..c50290151 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NFCUtils.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NFCUtils.java
@@ -49,14 +49,14 @@ public class NFCUtils {
public static void buildAndPush( Activity activity, String data )
{
NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter( activity );
+ String mimeType = activity.getString( R.string.xwords_nfc_mime );
NdefMessage msg = new NdefMessage( new NdefRecord[] {
- new NdefRecord(NdefRecord.TNF_MIME_MEDIA,
- "application/org.eehouse.android.xw4"
+ new NdefRecord(NdefRecord.TNF_MIME_MEDIA, mimeType
.getBytes(Charset.forName("US-ASCII")),
new byte[0],
data.getBytes(Charset.forName("US-ASCII")))
,NdefRecord.
- createApplicationRecord("org.eehouse.android.xw4")
+ createApplicationRecord( activity.getPackageName() )
});
nfcAdapter.setNdefPushMessage( msg, activity );
}
From 3b3746d2e533da3a9e975271cfc808cb047546b1 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Wed, 13 Nov 2013 06:52:45 -0800
Subject: [PATCH 193/240] fix invites dialog to show the right buttons for all
cases.
---
.../android/XWords4/res/values/strings.xml | 4 ++
.../eehouse/android/xw4/BoardActivity.java | 2 +-
.../org/eehouse/android/xw4/DlgDelegate.java | 40 +++++++++++++------
.../eehouse/android/xw4/NewGameActivity.java | 2 +-
.../org/eehouse/android/xw4/XWActivity.java | 4 +-
5 files changed, 35 insertions(+), 17 deletions(-)
diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml
index 0cb18c1eb..886dac74f 100644
--- a/xwords4/android/XWords4/res/values/strings.xml
+++ b/xwords4/android/XWords4/res/values/strings.xml
@@ -1181,6 +1181,10 @@
explanation/guidance. -->
Send invitation using SMS (texting) or
via email?
+ Send invitation using NFC (Android
+ beaming – NEW) or via email?
+ Send invitation using SMS
+ (texting) or NFC (Android beaming – NEW) or via email?You are entering tile-exchange
- mode. Tap tiles to add/remove them from the set to be
- exchanged. Use the buttons to commit your turn or exit exchange
- mode.
+ mode.\n\nTap tiles to add/remove them from the set to be
+ exchanged.\n\n
+
+ Use the buttons to
+ commit your turn or exit exchange mode.
+ Use the menu or action bar
+ to commit your turn or exit exchange mode.
@@ -1713,7 +1717,7 @@
another players turn. The idea is to give a hint about how to
find out about recent moves. -->
The player whose turn it is
- is drawn large in the scoreboard. Hold your finger on a name in
+ is drawn large in the scoreboard.\n\nHold your finger on a name in
the scoreboard to get details about that player\'s most recent
move.
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java
index b11733a2f..ed9b69066 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java
@@ -828,8 +828,11 @@ public class BoardActivity extends XWActivity
break;
case R.id.board_menu_trade:
- showNotAgainDlgThen( R.string.not_again_trading,
- R.string.key_notagain_trading,
+ String msg = getString( R.string.not_again_trading );
+ int strID = ABUtils.haveActionBar() ? R.string.not_again_trading_menu
+ : R.string. not_again_trading_buttons;
+ msg += getString( strID );
+ showNotAgainDlgThen( msg, R.string.key_notagain_trading,
START_TRADE_ACTION );
break;
@@ -2258,7 +2261,7 @@ public class BoardActivity extends XWActivity
Button button = (Button)findViewById( id );
if ( null != button ) {
if ( ABUtils.haveActionBar() ) {
- button.setVisibility( View.GONE );
+ button.setVisibility( View.INVISIBLE );
} else {
button.setOnClickListener( this );
}
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java
index 5c4dff16a..1259826d0 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java
@@ -160,6 +160,14 @@ public class DlgDelegate {
public void showNotAgainDlgThen( int msgID, int prefsKey,
final int callbackID,
final Object[] params )
+ {
+ showNotAgainDlgThen( m_activity.getString( msgID ), prefsKey,
+ callbackID, params );
+ }
+
+ public void showNotAgainDlgThen( String msg, int prefsKey,
+ final int callbackID,
+ final Object[] params )
{
if ( XWPrefs.getPrefsBoolean( m_activity, prefsKey, false ) ) {
// If it's set, do the action without bothering with the
@@ -175,7 +183,6 @@ public class DlgDelegate {
});
}
} else {
- String msg = m_activity.getString( msgID );
DlgState state =
new DlgState( DIALOG_NOTAGAIN, msg, callbackID, prefsKey,
params );
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWActivity.java
index 92c73e616..96a9ffc05 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWActivity.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWActivity.java
@@ -106,6 +106,12 @@ public class XWActivity extends Activity
m_delegate.showAboutDialog();
}
+ protected void showNotAgainDlgThen( String msg, int prefsKey,
+ int action )
+ {
+ m_delegate.showNotAgainDlgThen( msg, prefsKey, action, null );
+ }
+
protected void showNotAgainDlgThen( int msgID, int prefsKey,
int action )
{
From c0f6f6a95902d74dd7ea4574ef4479178b23a9bf Mon Sep 17 00:00:00 2001
From: Eric House
Date: Fri, 15 Nov 2013 19:14:51 -0800
Subject: [PATCH 216/240] don't enable delete menu when default group is among
those selected
---
.../android/XWords4/src/org/eehouse/android/xw4/GamesList.java | 2 --
1 file changed, 2 deletions(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
index de8875885..62672291c 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
@@ -704,8 +704,6 @@ public class GamesList extends XWExpandableListActivity
// Multiples can be deleted
Utils.setItemVisible( menu, R.id.games_game_delete,
0 < nGamesSelected );
- Utils.setItemVisible( menu, R.id.games_group_delete,
- 0 < nGroupsSelected );
// multiple games can be regrouped/reset.
Utils.setItemVisible( menu, R.id.games_game_move,
From 088dd1bd75e205a77b03b8fd9a081f73ffdc063b Mon Sep 17 00:00:00 2001
From: Eric House
Date: Fri, 15 Nov 2013 20:46:22 -0800
Subject: [PATCH 217/240] center board when it must be narrower than screen
---
xwords4/android/XWords4/jni/xwjni.c | 1 +
.../src/org/eehouse/android/xw4/BoardDims.java | 2 +-
xwords4/common/board.c | 15 ++++++++-------
xwords4/common/board.h | 7 ++++++-
4 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/xwords4/android/XWords4/jni/xwjni.c b/xwords4/android/XWords4/jni/xwjni.c
index f415ebba0..35a6ec7e9 100644
--- a/xwords4/android/XWords4/jni/xwjni.c
+++ b/xwords4/android/XWords4/jni/xwjni.c
@@ -166,6 +166,7 @@ static const SetInfo bd_ints[] = {
,ARR_MEMBER( BoardDims, height )
,ARR_MEMBER( BoardDims, scoreHt )
,ARR_MEMBER( BoardDims, scoreWidth )
+ ,ARR_MEMBER( BoardDims, boardWidth )
,ARR_MEMBER( BoardDims, boardHt )
,ARR_MEMBER( BoardDims, trayTop )
,ARR_MEMBER( BoardDims, trayHt )
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDims.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDims.java
index 6fcdc3f2c..be320f098 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDims.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDims.java
@@ -26,7 +26,7 @@ public class BoardDims {
public int left, top;
public int width, height; // of the bitmap
public int scoreWidth, scoreHt;
- public int boardHt;
+ public int boardWidth, boardHt;
public int trayTop, trayHt;
public int cellSize, maxCellSize;
public int timerWidth;
diff --git a/xwords4/common/board.c b/xwords4/common/board.c
index 87efba701..15c716608 100644
--- a/xwords4/common/board.c
+++ b/xwords4/common/board.c
@@ -410,14 +410,14 @@ board_figureLayout( BoardCtxt* board, const CurGameInfo* gi,
ldims.left = bLeft;
ldims.top = bTop;
+ ldims.width = bWidth;
+ ldims.boardWidth = bWidth;
for ( firstPass = XP_TRUE; ; ) {
- ldims.width = bWidth;
-
- XP_U16 cellSize = bWidth / nCells;
+ XP_U16 cellSize = ldims.boardWidth / nCells;
if ( cellSize > maxCellSize ) {
cellSize = maxCellSize;
- ldims.width = nCells * cellSize;
+ ldims.boardWidth = nCells * cellSize;
}
ldims.maxCellSize = maxCellSize;
@@ -437,7 +437,7 @@ board_figureLayout( BoardCtxt* board, const CurGameInfo* gi,
int cellWidth = 2 * (bHeight / ( 4 + 3 + (2*nCells)));
if ( firstPass && cellWidth >= fontHt ) {
firstPass = XP_FALSE;
- bWidth = nCells * cellWidth;
+ ldims.boardWidth = nCells * cellWidth;
continue;
} else {
nToScroll = nCells -
@@ -491,8 +491,9 @@ board_figureLayout( BoardCtxt* board, const CurGameInfo* gi,
void
board_applyLayout( BoardCtxt* board, const BoardDims* dims )
{
- board_setPos( board, dims->left, dims->top + dims->scoreHt,
- dims->width, dims->top + dims->scoreHt + dims->boardHt,
+ XP_U16 margin = (dims->width - dims->boardWidth) / 2;
+ board_setPos( board, dims->left + margin, dims->top + dims->scoreHt,
+ dims->boardWidth, dims->top + dims->scoreHt + dims->boardHt,
dims->maxCellSize, XP_FALSE );
board_setScoreboardLoc( board, dims->left, dims->top,
diff --git a/xwords4/common/board.h b/xwords4/common/board.h
index d0e84c8de..e278b6d54 100644
--- a/xwords4/common/board.h
+++ b/xwords4/common/board.h
@@ -76,11 +76,16 @@ void board_reset( BoardCtxt* board );
#ifdef COMMON_LAYOUT
typedef struct _BoardDims {
+ /* The whole board */
XP_U16 left, top;
XP_U16 width, height;
+ /* scoreboard (full width) */
XP_U16 scoreWidth, scoreHt;
- XP_U16 boardHt;
+ /* board */
+ XP_U16 boardWidth, boardHt;
+ /* tray (full width) */
XP_U16 trayTop, trayHt;
+ /* other */
XP_U16 cellSize, maxCellSize;
XP_U16 timerWidth;
} BoardDims;
From f303fa26534fc983e53d2dda36bd76ff7409e3c5 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Fri, 15 Nov 2013 20:52:05 -0800
Subject: [PATCH 218/240] debug features and logging are always on/available
for debug builds
---
xwords4/android/XWords4/res/values/common_rsrc.xml | 5 +++++
xwords4/android/XWords4/res/xml/xwprefs.xml | 5 +++--
.../XWords4/src/org/eehouse/android/xw4/GamesList.java | 3 ++-
.../src/org/eehouse/android/xw4/XWSumListPreference.java | 3 ++-
4 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/xwords4/android/XWords4/res/values/common_rsrc.xml b/xwords4/android/XWords4/res/values/common_rsrc.xml
index 37bcc7b44..92435ae75 100644
--- a/xwords4/android/XWords4/res/values/common_rsrc.xml
+++ b/xwords4/android/XWords4/res/values/common_rsrc.xml
@@ -132,6 +132,11 @@
Invite redirect hostWordlist download URLEnable logging
+ (release builds only)
+ Enable debug features
+ Menuitems etc. (release builds
+ only)
+
Source version idRelay game portRelay device port
diff --git a/xwords4/android/XWords4/res/xml/xwprefs.xml b/xwords4/android/XWords4/res/xml/xwprefs.xml
index 1c1ff0c02..db162f36f 100644
--- a/xwords4/android/XWords4/res/xml/xwprefs.xml
+++ b/xwords4/android/XWords4/res/xml/xwprefs.xml
@@ -311,11 +311,12 @@
/>
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
index 62672291c..86f0859ea 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
@@ -665,7 +665,8 @@ public class GamesList extends XWExpandableListActivity
if ( m_menuPrepared ) {
boolean nothingSelected = 0 == (nGroupsSelected + nGamesSelected);
- boolean showDbg = XWPrefs.getDebugEnabled( this );
+ boolean showDbg = BuildConstants.IS_DEBUG_BUILD
+ || XWPrefs.getDebugEnabled( this );
showItemsIf( DEBUG_ITEMS, menu, nothingSelected && showDbg );
Utils.setItemVisible( menu, R.id.games_menu_loaddb,
showDbg && !DBUtils.gameDBExists( this ) );
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWSumListPreference.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWSumListPreference.java
index 8bfa356d4..b744af7c9 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWSumListPreference.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWSumListPreference.java
@@ -35,7 +35,8 @@ public class XWSumListPreference extends XWListPreference {
{
super.onAttachedToActivity();
- if ( XWPrefs.getDebugEnabled( m_context ) ) {
+ if ( BuildConstants.IS_DEBUG_BUILD ||
+ XWPrefs.getDebugEnabled( m_context ) ) {
CharSequence[] entries = getEntries();
String lastRow
= m_context.getString( R.string.game_summary_field_rowid );
From deff81cfd1c4e62839fa5c7096714e22f79c1117 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Sat, 16 Nov 2013 06:30:34 -0800
Subject: [PATCH 219/240] move query setup outside of synchronized blocks where
possible
---
.../src/org/eehouse/android/xw4/DBUtils.java | 365 +++++++++---------
1 file changed, 185 insertions(+), 180 deletions(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java
index fe8508f85..4935ec7a3 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java
@@ -124,24 +124,23 @@ public class DBUtils {
{
initDB( context );
GameSummary summary = null;
+ String[] columns = { ROW_ID,
+ DBHelper.NUM_MOVES, DBHelper.NUM_PLAYERS,
+ DBHelper.MISSINGPLYRS,
+ DBHelper.GAME_OVER, DBHelper.PLAYERS,
+ DBHelper.TURN, DBHelper.GIFLAGS,
+ DBHelper.CONTYPE, DBHelper.SERVERROLE,
+ DBHelper.ROOMNAME, DBHelper.RELAYID,
+ /*DBHelper.SMSPHONE,*/ DBHelper.SEED,
+ DBHelper.DICTLANG, DBHelper.GAMEID,
+ DBHelper.SCORES, DBHelper.HASMSGS,
+ DBHelper.LASTPLAY_TIME, DBHelper.REMOTEDEVS,
+ DBHelper.LASTMOVE, DBHelper.THUMBNAIL
+ };
+ String selection = String.format( ROW_ID_FMT, lock.getRowid() );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
- String[] columns = { ROW_ID,
- DBHelper.NUM_MOVES, DBHelper.NUM_PLAYERS,
- DBHelper.MISSINGPLYRS,
- DBHelper.GAME_OVER, DBHelper.PLAYERS,
- DBHelper.TURN, DBHelper.GIFLAGS,
- DBHelper.CONTYPE, DBHelper.SERVERROLE,
- DBHelper.ROOMNAME, DBHelper.RELAYID,
- /*DBHelper.SMSPHONE,*/ DBHelper.SEED,
- DBHelper.DICTLANG, DBHelper.GAMEID,
- DBHelper.SCORES, DBHelper.HASMSGS,
- DBHelper.LASTPLAY_TIME, DBHelper.REMOTEDEVS,
- DBHelper.LASTMOVE, DBHelper.THUMBNAIL
- };
- String selection = String.format( ROW_ID_FMT, lock.getRowid() );
-
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, null, null, null, null );
if ( 1 == cursor.getCount() && cursor.moveToFirst() ) {
@@ -277,6 +276,56 @@ public class DBUtils {
long rowid = lock.getRowid();
String selection = String.format( ROW_ID_FMT, rowid );
+ ContentValues values = null;
+ if ( null != summary ) {
+ values = new ContentValues();
+ values.put( DBHelper.NUM_MOVES, summary.nMoves );
+ values.put( DBHelper.NUM_PLAYERS, summary.nPlayers );
+ values.put( DBHelper.MISSINGPLYRS, summary.missingPlayers );
+ values.put( DBHelper.TURN, summary.turn );
+ values.put( DBHelper.GIFLAGS, summary.giflags() );
+ values.put( DBHelper.PLAYERS,
+ summary.summarizePlayers() );
+ values.put( DBHelper.DICTLANG, summary.dictLang );
+ values.put( DBHelper.GAMEID, summary.gameID );
+ values.put( DBHelper.GAME_OVER, summary.gameOver? 1 : 0 );
+ values.put( DBHelper.LASTMOVE, summary.lastMoveTime );
+
+ values.put( DBHelper.DICTLIST, summary.dictNames(DICTS_SEP) );
+ values.put( DBHelper.HASMSGS, summary.pendingMsgLevel );
+ if ( null != inviteID ) {
+ values.put( DBHelper.INVITEID, inviteID );
+ }
+
+ if ( null != summary.scores ) {
+ StringBuffer sb = new StringBuffer();
+ for ( int score : summary.scores ) {
+ sb.append( String.format( "%d ", score ) );
+ }
+ values.put( DBHelper.SCORES, sb.toString() );
+ }
+
+ if ( null != summary.conType ) {
+ values.put( DBHelper.CONTYPE, summary.conType.ordinal() );
+ values.put( DBHelper.SEED, summary.seed );
+ switch( summary.conType ) {
+ case COMMS_CONN_RELAY:
+ values.put( DBHelper.ROOMNAME, summary.roomName );
+ values.put( DBHelper.RELAYID, summary.relayID );
+ break;
+ case COMMS_CONN_BT:
+ case COMMS_CONN_SMS:
+ values.put( DBHelper.REMOTEDEVS,
+ summary.summarizeDevs() );
+ break;
+ }
+ }
+
+ values.put( DBHelper.SERVERROLE, summary.serverRole.ordinal() );
+
+ addThumb( summary.getThumbnail(), values );
+ }
+
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getWritableDatabase();
@@ -284,53 +333,6 @@ public class DBUtils {
if ( null == summary ) {
db.delete( DBHelper.TABLE_NAME_SUM, selection, null );
} else {
- ContentValues values = new ContentValues();
- values.put( DBHelper.NUM_MOVES, summary.nMoves );
- values.put( DBHelper.NUM_PLAYERS, summary.nPlayers );
- values.put( DBHelper.MISSINGPLYRS, summary.missingPlayers );
- values.put( DBHelper.TURN, summary.turn );
- values.put( DBHelper.GIFLAGS, summary.giflags() );
- values.put( DBHelper.PLAYERS,
- summary.summarizePlayers() );
- values.put( DBHelper.DICTLANG, summary.dictLang );
- values.put( DBHelper.GAMEID, summary.gameID );
- values.put( DBHelper.GAME_OVER, summary.gameOver? 1 : 0 );
- values.put( DBHelper.LASTMOVE, summary.lastMoveTime );
-
- values.put( DBHelper.DICTLIST, summary.dictNames(DICTS_SEP) );
- values.put( DBHelper.HASMSGS, summary.pendingMsgLevel );
- if ( null != inviteID ) {
- values.put( DBHelper.INVITEID, inviteID );
- }
-
- if ( null != summary.scores ) {
- StringBuffer sb = new StringBuffer();
- for ( int score : summary.scores ) {
- sb.append( String.format( "%d ", score ) );
- }
- values.put( DBHelper.SCORES, sb.toString() );
- }
-
- if ( null != summary.conType ) {
- values.put( DBHelper.CONTYPE, summary.conType.ordinal() );
- values.put( DBHelper.SEED, summary.seed );
- switch( summary.conType ) {
- case COMMS_CONN_RELAY:
- values.put( DBHelper.ROOMNAME, summary.roomName );
- values.put( DBHelper.RELAYID, summary.relayID );
- break;
- case COMMS_CONN_BT:
- case COMMS_CONN_SMS:
- values.put( DBHelper.REMOTEDEVS,
- summary.summarizeDevs() );
- break;
- }
- }
-
- values.put( DBHelper.SERVERROLE, summary.serverRole.ordinal() );
-
- addThumb( summary.getThumbnail(), values );
-
long result = db.update( DBHelper.TABLE_NAME_SUM,
values, selection, null );
Assert.assertTrue( result >= 0 );
@@ -344,13 +346,13 @@ public class DBUtils {
public static int countGamesUsingLang( Context context, int lang )
{
int result = 0;
+ String selection = String.format( "%s = %d", DBHelper.DICTLANG,
+ lang );
+ // null for columns will return whole rows: bad
+ String[] columns = { DBHelper.DICTLANG };
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
- String selection = String.format( "%s = %d", DBHelper.DICTLANG,
- lang );
- // null for columns will return whole rows: bad
- String[] columns = { DBHelper.DICTLANG };
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, null, null, null, null );
@@ -364,16 +366,16 @@ public class DBUtils {
public static int countGamesUsingDict( Context context, String dict )
{
int result = 0;
+ String pattern = String.format( "%%%s%s%s%%",
+ DICTS_SEP, dict, DICTS_SEP );
+ String selection = String.format( "%s LIKE '%s'",
+ DBHelper.DICTLIST, pattern );
+ // null for columns will return whole rows: bad. But
+ // might as well make it an int for speed
+ String[] columns = { DBHelper.DICTLANG };
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
- String pattern = String.format( "%%%s%s%s%%",
- DICTS_SEP, dict, DICTS_SEP );
- String selection = String.format( "%s LIKE '%s'",
- DBHelper.DICTLIST, pattern );
- // null for columns will return whole rows: bad. But
- // might as well make it an int for speed
- String[] columns = { DBHelper.DICTLANG };
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, null, null, null, null );
result = cursor.getCount();
@@ -405,11 +407,11 @@ public class DBUtils {
int dflt )
{
int result = dflt;
+ String selection = String.format( ROW_ID_FMT, rowid );
+ String[] columns = { column };
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
- String selection = String.format( ROW_ID_FMT, rowid );
- String[] columns = { column };
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, null, null, null, null );
if ( 1 == cursor.getCount() && cursor.moveToFirst() ) {
@@ -442,14 +444,13 @@ public class DBUtils {
Bitmap thumb )
{
if ( BuildConstants.THUMBNAIL_SUPPORTED ) {
+ long rowid = lock.getRowid();
+ String selection = String.format( ROW_ID_FMT, rowid );
+ ContentValues values = new ContentValues();
+ addThumb( thumb, values );
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getWritableDatabase();
- ContentValues values = new ContentValues();
- long rowid = lock.getRowid();
- String selection = String.format( ROW_ID_FMT, rowid );
-
- addThumb( thumb, values );
long result = db.update( DBHelper.TABLE_NAME_SUM,
values, selection, null );
@@ -465,11 +466,11 @@ public class DBUtils {
public static void clearThumbnails( Context context )
{
if ( BuildConstants.THUMBNAIL_SUPPORTED ) {
+ ContentValues values = new ContentValues();
+ values.putNull( DBHelper.THUMBNAIL );
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getWritableDatabase();
- ContentValues values = new ContentValues();
- values.putNull( DBHelper.THUMBNAIL );
long result = db.update( DBHelper.TABLE_NAME_SUM,
values, null, null );
db.close();
@@ -482,11 +483,11 @@ public class DBUtils {
public static String getRelayID( Context context, long rowid )
{
String result = null;
+ String[] columns = { DBHelper.RELAYID };
+ String selection = String.format( ROW_ID_FMT, rowid );
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
- String[] columns = { DBHelper.RELAYID };
- String selection = String.format( ROW_ID_FMT, rowid );
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, null, null, null, null );
if ( 1 == cursor.getCount() && cursor.moveToFirst() ) {
@@ -502,11 +503,11 @@ public class DBUtils {
public static long[] getRowIDsFor( Context context, String relayID )
{
long[] result = null;
+ String[] columns = { ROW_ID };
+ String selection = DBHelper.RELAYID + "='" + relayID + "'";
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
- String[] columns = { ROW_ID };
- String selection = DBHelper.RELAYID + "='" + relayID + "'";
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, null, null, null, null );
result = new long[cursor.getCount()];
@@ -522,11 +523,11 @@ public class DBUtils {
public static long[] getRowIDsFor( Context context, int gameID )
{
long[] result = null;
+ String[] columns = { ROW_ID };
+ String selection = String.format( DBHelper.GAMEID + "=%d", gameID );
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
- String[] columns = { ROW_ID };
- String selection = String.format( DBHelper.GAMEID + "=%d", gameID );
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, null, null, null, null );
result = new long[cursor.getCount()];
@@ -546,11 +547,11 @@ public class DBUtils {
public static boolean haveGame( Context context, long rowid )
{
boolean result = false;
+ String[] columns = { ROW_ID };
+ String selection = String.format( ROW_ID + "=%d", rowid );
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
- String[] columns = { ROW_ID };
- String selection = String.format( ROW_ID + "=%d", rowid );
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, null, null, null, null );
Assert.assertTrue( 1 >= cursor.getCount() );
@@ -616,16 +617,16 @@ public class DBUtils {
NetLaunchInfo nli )
{
Date result = null;
+ String[] columns = { DBHelper.CREATE_TIME };
+ String selection =
+ String.format( "%s='%s' AND %s='%s' AND %s=%d AND %s=%d",
+ DBHelper.ROOMNAME, nli.room,
+ DBHelper.INVITEID, nli.inviteID,
+ DBHelper.DICTLANG, nli.lang,
+ DBHelper.NUM_PLAYERS, nli.nPlayersT );
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
- String[] columns = { DBHelper.CREATE_TIME };
- String selection =
- String.format( "%s='%s' AND %s='%s' AND %s=%d AND %s=%d",
- DBHelper.ROOMNAME, nli.room,
- DBHelper.INVITEID, nli.inviteID,
- DBHelper.DICTLANG, nli.lang,
- DBHelper.NUM_PLAYERS, nli.nPlayersT );
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, null, null, null,
DBHelper.CREATE_TIME + " DESC" ); // order by
@@ -652,13 +653,13 @@ public class DBUtils {
public static String[] getRelayIDs( Context context, long[][] rowIDs )
{
String[] result = null;
- initDB( context );
+ String[] columns = { ROW_ID, DBHelper.RELAYID };
+ String selection = DBHelper.RELAYID + " NOT null";
ArrayList ids = new ArrayList();
+ initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
- String[] columns = { ROW_ID, DBHelper.RELAYID };
- String selection = DBHelper.RELAYID + " NOT null";
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, null, null, null, null );
@@ -688,14 +689,14 @@ public class DBUtils {
public static void addDeceased( Context context, String relayID,
int seed )
{
+ ContentValues values = new ContentValues();
+ values.put( DBHelper.RELAYID, relayID );
+ values.put( DBHelper.SEED, seed );
+
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getWritableDatabase();
- ContentValues values = new ContentValues();
- values.put( DBHelper.RELAYID, relayID );
- values.put( DBHelper.SEED, seed );
-
try {
long result = db.replaceOrThrow( DBHelper.TABLE_NAME_OBITS,
"", values );
@@ -710,11 +711,11 @@ public class DBUtils {
{
Obit[] result = null;
ArrayList al = new ArrayList();
+ String[] columns = { DBHelper.RELAYID, DBHelper.SEED };
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
- String[] columns = { DBHelper.RELAYID, DBHelper.SEED };
Cursor cursor = db.query( DBHelper.TABLE_NAME_OBITS, columns,
null, null, null, null, null );
if ( 0 < cursor.getCount() ) {
@@ -761,20 +762,21 @@ public class DBUtils {
Assert.assertTrue( GROUPID_UNSPEC != groupID );
GameLock lock = null;
+ ContentValues values = new ContentValues();
+ values.put( DBHelper.SNAPSHOT, bytes );
+
+ long timestamp = new Date().getTime();
+ values.put( DBHelper.CREATE_TIME, timestamp );
+ values.put( DBHelper.LASTPLAY_TIME, timestamp );
+ values.put( DBHelper.GROUPID, groupID );
+
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getWritableDatabase();
-
- ContentValues values = new ContentValues();
- values.put( DBHelper.SNAPSHOT, bytes );
-
- long timestamp = new Date().getTime();
- values.put( DBHelper.CREATE_TIME, timestamp );
- values.put( DBHelper.LASTPLAY_TIME, timestamp );
- values.put( DBHelper.GROUPID, groupID );
values.put( DBHelper.VISID, maxVISID( db ) );
long rowid = db.insert( DBHelper.TABLE_NAME_SUM, null, values );
+ db.close();
setCached( rowid, null ); // force reread
@@ -816,12 +818,12 @@ public class DBUtils {
Assert.assertTrue( ROWID_NOTFOUND != rowid );
byte[] result = getCached( rowid );
if ( null == result ) {
+ String[] columns = { DBHelper.SNAPSHOT };
+ String selection = String.format( ROW_ID_FMT, rowid );
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
- String[] columns = { DBHelper.SNAPSHOT };
- String selection = String.format( ROW_ID_FMT, rowid );
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, null, null, null, null );
if ( 1 == cursor.getCount() && cursor.moveToFirst() ) {
@@ -853,10 +855,10 @@ public class DBUtils {
public static void deleteGame( Context context, GameLock lock )
{
Assert.assertTrue( lock.canWrite() );
+ String selection = String.format( ROW_ID_FMT, lock.getRowid() );
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getWritableDatabase();
- String selection = String.format( ROW_ID_FMT, lock.getRowid() );
db.delete( DBHelper.TABLE_NAME_SUM, selection, null );
db.close();
}
@@ -866,12 +868,12 @@ public class DBUtils {
public static int getVisID( Context context, long rowid )
{
int result = ROWID_NOTFOUND;
+ String[] columns = { DBHelper.VISID };
+ String selection = String.format( ROW_ID_FMT, rowid );
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
- String[] columns = { DBHelper.VISID };
- String selection = String.format( ROW_ID_FMT, rowid );
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, null, null, null, null );
if ( 1 == cursor.getCount() && cursor.moveToFirst() ) {
@@ -889,12 +891,12 @@ public class DBUtils {
public static String getName( Context context, long rowid )
{
String result = null;
+ String[] columns = { DBHelper.GAME_NAME };
+ String selection = String.format( ROW_ID_FMT, rowid );
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
- String[] columns = { DBHelper.GAME_NAME };
- String selection = String.format( ROW_ID_FMT, rowid );
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, null, null, null, null );
if ( 1 == cursor.getCount() && cursor.moveToFirst() ) {
@@ -1097,9 +1099,9 @@ public class DBUtils {
initDB( context );
String[] columns = { ROW_ID };
String selection = String.format( "%s=%d", DBHelper.GROUPID, groupID );
+ String orderBy = DBHelper.CREATE_TIME + " DESC";
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
- String orderBy = DBHelper.CREATE_TIME + " DESC";
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, // selection
null, // args
@@ -1191,17 +1193,17 @@ public class DBUtils {
public static void deleteGroup( Context context, long groupid )
{
+ // Nuke games having this group id
+ String selection =
+ String.format( "%s=%d", DBHelper.GROUPID, groupid );
+
+ // And nuke the group record itself
+ selection = String.format( ROW_ID_FMT, groupid );
+
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getWritableDatabase();
-
- // Nuke games having this group id
- String selection =
- String.format( "%s=%d", DBHelper.GROUPID, groupid );
db.delete( DBHelper.TABLE_NAME_SUM, selection, null );
-
- // And nuke the group record itself
- selection = String.format( ROW_ID_FMT, groupid );
db.delete( DBHelper.TABLE_NAME_GROUPS, selection, null );
db.close();
@@ -1240,12 +1242,12 @@ public class DBUtils {
{
String result = null;
if ( BuildConstants.CHAT_SUPPORTED ) {
+ String[] columns = { DBHelper.CHAT_HISTORY };
+ String selection = String.format( ROW_ID_FMT, rowid );
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
- String[] columns = { DBHelper.CHAT_HISTORY };
- String selection = String.format( ROW_ID_FMT, rowid );
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, null, null, null, null );
if ( 1 == cursor.getCount() && cursor.moveToFirst() ) {
@@ -1341,15 +1343,15 @@ public class DBUtils {
{
Assert.assertTrue( DictLoc.UNKNOWN != loc );
DictBrowseState result = null;
+ String[] columns = { DBHelper.ITERPOS, DBHelper.ITERTOP,
+ DBHelper.ITERMIN, DBHelper.ITERMAX,
+ DBHelper.WORDCOUNTS, DBHelper.ITERPREFIX };
+ String selection =
+ String.format( NAMELOC_FMT, DBHelper.DICTNAME,
+ name, DBHelper.LOC, loc.ordinal() );
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
- String[] columns = { DBHelper.ITERPOS, DBHelper.ITERTOP,
- DBHelper.ITERMIN, DBHelper.ITERMAX,
- DBHelper.WORDCOUNTS, DBHelper.ITERPREFIX };
- String selection =
- String.format( NAMELOC_FMT, DBHelper.DICTNAME,
- name, DBHelper.LOC, loc.ordinal() );
Cursor cursor = db.query( DBHelper.TABLE_NAME_DICTBROWSE, columns,
selection, null, null, null, null );
if ( 1 >= cursor.getCount() && cursor.moveToFirst() ) {
@@ -1388,25 +1390,26 @@ public class DBUtils {
DictLoc loc, DictBrowseState state )
{
Assert.assertTrue( DictLoc.UNKNOWN != loc );
+ String selection =
+ String.format( NAMELOC_FMT, DBHelper.DICTNAME,
+ name, DBHelper.LOC, loc.ordinal() );
+ ContentValues values = new ContentValues();
+ values.put( DBHelper.ITERPOS, state.m_pos );
+ values.put( DBHelper.ITERTOP, state.m_top );
+ values.put( DBHelper.ITERMIN, state.m_minShown );
+ values.put( DBHelper.ITERMAX, state.m_maxShown );
+ values.put( DBHelper.ITERPREFIX, state.m_prefix );
+ if ( null != state.m_counts ) {
+ String[] nums = new String[state.m_counts.length];
+ for ( int ii = 0; ii < nums.length; ++ii ) {
+ nums[ii] = String.format( "%d", state.m_counts[ii] );
+ }
+ values.put( DBHelper.WORDCOUNTS, TextUtils.join( ":", nums ) );
+ }
+
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getWritableDatabase();
- String selection =
- String.format( NAMELOC_FMT, DBHelper.DICTNAME,
- name, DBHelper.LOC, loc.ordinal() );
- ContentValues values = new ContentValues();
- values.put( DBHelper.ITERPOS, state.m_pos );
- values.put( DBHelper.ITERTOP, state.m_top );
- values.put( DBHelper.ITERMIN, state.m_minShown );
- values.put( DBHelper.ITERMAX, state.m_maxShown );
- values.put( DBHelper.ITERPREFIX, state.m_prefix );
- if ( null != state.m_counts ) {
- String[] nums = new String[state.m_counts.length];
- for ( int ii = 0; ii < nums.length; ++ii ) {
- nums[ii] = String.format( "%d", state.m_counts[ii] );
- }
- values.put( DBHelper.WORDCOUNTS, TextUtils.join( ":", nums ) );
- }
int result = db.update( DBHelper.TABLE_NAME_DICTBROWSE,
values, selection, null );
if ( 0 == result ) {
@@ -1429,12 +1432,12 @@ public class DBUtils {
// Called from jni
public static void dictsSetMD5Sum( Context context, String name, String sum )
{
+ String selection = String.format( NAME_FMT, DBHelper.DICTNAME, name );
+ ContentValues values = new ContentValues();
+ values.put( DBHelper.MD5SUM, sum );
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getWritableDatabase();
- String selection = String.format( NAME_FMT, DBHelper.DICTNAME, name );
- ContentValues values = new ContentValues();
- values.put( DBHelper.MD5SUM, sum );
int result = db.update( DBHelper.TABLE_NAME_DICTINFO,
values, selection, null );
if ( 0 == result ) {
@@ -1448,14 +1451,14 @@ public class DBUtils {
public static DictInfo dictsGetInfo( Context context, String name )
{
DictInfo result = null;
+ String[] columns = { DBHelper.LANGCODE,
+ DBHelper.WORDCOUNT,
+ DBHelper.MD5SUM,
+ DBHelper.LOC };
+ String selection = String.format( NAME_FMT, DBHelper.DICTNAME, name );
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
- String[] columns = { DBHelper.LANGCODE,
- DBHelper.WORDCOUNT,
- DBHelper.MD5SUM,
- DBHelper.LOC };
- String selection = String.format( NAME_FMT, DBHelper.DICTNAME, name );
Cursor cursor = db.query( DBHelper.TABLE_NAME_DICTINFO, columns,
selection, null, null, null, null );
if ( 1 == cursor.getCount() && cursor.moveToFirst() ) {
@@ -1477,18 +1480,18 @@ public class DBUtils {
public static void dictsSetInfo( Context context, DictUtils.DictAndLoc dal,
DictInfo info )
{
+ String selection =
+ String.format( NAME_FMT, DBHelper.DICTNAME, dal.name );
+ ContentValues values = new ContentValues();
+
+ values.put( DBHelper.LANGCODE, info.langCode );
+ values.put( DBHelper.WORDCOUNT, info.wordCount );
+ values.put( DBHelper.MD5SUM, info.md5Sum );
+ values.put( DBHelper.LOC, dal.loc.ordinal() );
+
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getWritableDatabase();
- String selection =
- String.format( NAME_FMT, DBHelper.DICTNAME, dal.name );
- ContentValues values = new ContentValues();
-
- values.put( DBHelper.LANGCODE, info.langCode );
- values.put( DBHelper.WORDCOUNT, info.wordCount );
- values.put( DBHelper.MD5SUM, info.md5Sum );
- values.put( DBHelper.LOC, dal.loc.ordinal() );
-
int result = db.update( DBHelper.TABLE_NAME_DICTINFO,
values, selection, null );
if ( 0 == result ) {
@@ -1502,16 +1505,17 @@ public class DBUtils {
public static void dictsMoveInfo( Context context, String name,
DictLoc fromLoc, DictLoc toLoc )
{
+ String selection =
+ String.format( NAMELOC_FMT, DBHelper.DICTNAME,
+ name, DBHelper.LOC, fromLoc.ordinal() );
+ ContentValues values = new ContentValues();
+ values.put( DBHelper.LOC, toLoc.ordinal() );
+
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getWritableDatabase();
- String selection =
- String.format( NAMELOC_FMT, DBHelper.DICTNAME,
- name, DBHelper.LOC, fromLoc.ordinal() );
- ContentValues values = new ContentValues();
- values.put( DBHelper.LOC, toLoc.ordinal() );
db.update( DBHelper.TABLE_NAME_DICTINFO, values, selection, null );
- db.update( DBHelper.TABLE_NAME_DICTBROWSE, values, selection, null);
+ db.update( DBHelper.TABLE_NAME_DICTBROWSE, values, selection, null );
db.close();
}
}
@@ -1519,12 +1523,13 @@ public class DBUtils {
public static void dictsRemoveInfo( Context context,
DictUtils.DictAndLoc dal )
{
+ String selection =
+ String.format( NAMELOC_FMT, DBHelper.DICTNAME,
+ dal.name, DBHelper.LOC, dal.loc.ordinal() );
+
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getWritableDatabase();
- String selection =
- String.format( NAMELOC_FMT, DBHelper.DICTNAME,
- dal.name, DBHelper.LOC, dal.loc.ordinal() );
db.delete( DBHelper.TABLE_NAME_DICTINFO, selection, null );
db.delete( DBHelper.TABLE_NAME_DICTBROWSE, selection, null );
db.close();
@@ -1595,12 +1600,12 @@ public class DBUtils {
private static void updateRow( Context context, String table,
long rowid, ContentValues values )
{
+ String selection = String.format( ROW_ID_FMT, rowid );
+
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getWritableDatabase();
- String selection = String.format( ROW_ID_FMT, rowid );
-
int result = db.update( table, values, selection, null );
db.close();
if ( 0 == result ) {
From 0bf28c133d6875499394b418b90dc53230b09444 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Sat, 16 Nov 2013 09:02:52 -0800
Subject: [PATCH 220/240] always have board ready to send invite via NFC
---
.../eehouse/android/xw4/BoardActivity.java | 19 ++++++++++++++-
.../org/eehouse/android/xw4/GameUtils.java | 1 -
.../src/org/eehouse/android/xw4/NFCUtils.java | 23 ++++++++++---------
3 files changed, 30 insertions(+), 13 deletions(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java
index ed9b69066..cdf380240 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java
@@ -65,7 +65,8 @@ import org.eehouse.android.xw4.jni.JNIThread.*;
public class BoardActivity extends XWActivity
implements TransportProcs.TPMsgHandler, View.OnClickListener,
DictImportActivity.DownloadFinishedListener,
- ConnStatusHandler.ConnStatusCBacks {
+ ConnStatusHandler.ConnStatusCBacks,
+ NFCUtils.NFCActor {
public static final String INTENT_KEY_CHAT = "chat";
@@ -1158,6 +1159,22 @@ public class BoardActivity extends XWActivity
}
}
+ //////////////////////////////////////////////////
+ // NFCUtils.NFCActor
+ //////////////////////////////////////////////////
+
+ public String makeNFCMessage()
+ {
+ String data = null;
+ if ( 0 < m_missing ) { // Isn't there a better test??
+ String inviteID = GameUtils.makeRandomID();
+ data = NetLaunchInfo.makeLaunchJSON( this, m_room, inviteID,
+ m_gi.dictLang,
+ m_gi.dictName, m_gi.nPlayers );
+ }
+ return data;
+ }
+
//////////////////////////////////////////////////
// ConnStatusHandler.ConnStatusCBacks
//////////////////////////////////////////////////
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java
index d8373ccb9..4fe31f9f0 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java
@@ -536,7 +536,6 @@ public class GameUtils {
if ( null != msgString ) {
if ( DlgDelegate.NFC_BTN == chosen ) {
- NFCUtils.buildAndPush( activity, msgString );
Utils.showToast( activity, "Tap the receiving device now" );
} else {
boolean choseEmail = DlgDelegate.EMAIL_BTN == chosen;
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NFCUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NFCUtils.java
index 8ff5f9c4a..54be61c25 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NFCUtils.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NFCUtils.java
@@ -30,7 +30,14 @@ import android.nfc.NfcEvent;
import android.nfc.NfcManager;
import android.os.Parcelable;
+import junit.framework.Assert;
+
public class NFCUtils {
+
+ public interface NFCActor {
+ String makeNFCMessage();
+ }
+
private static boolean s_inSDK;
private static SafeNFC s_safeNFC;
static {
@@ -39,7 +46,6 @@ public class NFCUtils {
s_safeNFC = new SafeNFCImpl();
}
}
- private static String s_data = null;
private static interface SafeNFC {
public void register( Activity activity );
@@ -48,12 +54,15 @@ public class NFCUtils {
private static class SafeNFCImpl implements SafeNFC {
public void register( final Activity activity )
{
+ Assert.assertTrue( activity instanceof NFCActor );
+ final NFCActor actor = (NFCActor)activity;
NfcAdapter.CreateNdefMessageCallback cb =
new NfcAdapter.CreateNdefMessageCallback() {
public NdefMessage createNdefMessage( NfcEvent event ) {
NdefMessage msg = null;
- if ( null != s_data ) {
- msg = makeMessage( activity, s_data );
+ String data = actor.makeNFCMessage();
+ if ( null != data ) {
+ msg = makeMessage( activity, data );
}
return msg;
}
@@ -78,14 +87,6 @@ public class NFCUtils {
return result;
}
- public static void buildAndPush( Activity activity, String data )
- {
- s_data = data;
- // NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter( activity );
- // NdefMessage msg = makeMessage( activity, data );
- // nfcAdapter.setNdefPushMessage( msg, activity );
- }
-
public static String getFromIntent( Intent intent )
{
String result = null;
From 46a5f83bb1ca344ae55683beb97155a6ad161516 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Sat, 16 Nov 2013 18:25:09 -0800
Subject: [PATCH 221/240] shrink "netstat rect" to reasonable size
---
xwords4/linux/gtkboard.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/xwords4/linux/gtkboard.c b/xwords4/linux/gtkboard.c
index 8690fd663..27efe7209 100644
--- a/xwords4/linux/gtkboard.c
+++ b/xwords4/linux/gtkboard.c
@@ -621,7 +621,7 @@ configure_event( GtkWidget* widget, GdkEventConfigure* XP_UNUSED(event),
#else
0, 0,
#endif
- bdWidth-100, 16, 16,
+ bdWidth-25, 16, 16,
XP_FALSE, &dims );
board_applyLayout( board, &dims );
From 14c7b7370a4e686129325743c5fad76ae9a47e59 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Sat, 16 Nov 2013 18:31:14 -0800
Subject: [PATCH 222/240] fix layout bug where board overlapped tray
---
xwords4/common/board.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/xwords4/common/board.c b/xwords4/common/board.c
index 15c716608..f67f54194 100644
--- a/xwords4/common/board.c
+++ b/xwords4/common/board.c
@@ -470,7 +470,7 @@ board_figureLayout( BoardCtxt* board, const CurGameInfo* gi,
ldims.scoreWidth = scoreWidth;
ldims.boardHt = cellSize * nCells;
- ldims.trayTop = scoreHt + (cellSize * (nCells-nToScroll));
+ ldims.trayTop = ldims.top + scoreHt + (cellSize * (nCells-nToScroll));
ldims.height = heightUsed;
ldims.cellSize = cellSize;
@@ -493,7 +493,7 @@ board_applyLayout( BoardCtxt* board, const BoardDims* dims )
{
XP_U16 margin = (dims->width - dims->boardWidth) / 2;
board_setPos( board, dims->left + margin, dims->top + dims->scoreHt,
- dims->boardWidth, dims->top + dims->scoreHt + dims->boardHt,
+ dims->boardWidth, dims->boardHt,
dims->maxCellSize, XP_FALSE );
board_setScoreboardLoc( board, dims->left, dims->top,
From cae89a60a829cc87057c517667b5a58effc0a278 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Sat, 16 Nov 2013 18:31:32 -0800
Subject: [PATCH 223/240] include hint in subtitle
---
xwords4/android/XWords4/res/values/strings.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml
index c8c4cd4b8..ef1de9be3 100644
--- a/xwords4/android/XWords4/res/values/strings.xml
+++ b/xwords4/android/XWords4/res/values/strings.xml
@@ -301,7 +301,7 @@
- Players
+ Players (tap to edit)http://eehouse.org/and_wordlists
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java
index 15f91c5c8..4b675d619 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java
@@ -443,11 +443,12 @@ public class GameListAdapter implements ExpandableListAdapter {
private int fieldToID( String fieldName )
{
int[] ids = {
- R.string.game_summary_field_empty
- ,R.string.game_summary_field_language
- ,R.string.game_summary_field_opponents
- ,R.string.game_summary_field_state
- ,R.string.game_summary_field_rowid
+ R.string.game_summary_field_empty,
+ R.string.game_summary_field_language,
+ R.string.game_summary_field_opponents,
+ R.string.game_summary_field_state,
+ R.string.game_summary_field_rowid,
+ R.string.game_summary_field_gameid,
};
int result = -1;
for ( int id : ids ) {
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java
index 163ca3f67..4b136b6f4 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java
@@ -211,6 +211,9 @@ public class GameListItem extends LinearLayout
switch ( m_fieldID ) {
case R.string.game_summary_field_empty:
break;
+ case R.string.game_summary_field_gameid:
+ value = String.format( "%d", m_summary.gameID );
+ break;
case R.string.game_summary_field_rowid:
value = String.format( "%d", m_rowid );
break;
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWSumListPreference.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWSumListPreference.java
index b744af7c9..e6964e799 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWSumListPreference.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWSumListPreference.java
@@ -25,12 +25,17 @@ import android.util.AttributeSet;
public class XWSumListPreference extends XWListPreference {
+ private static final int[] s_ADDROWS = {
+ R.string.game_summary_field_rowid,
+ R.string.game_summary_field_gameid,
+ };
+
public XWSumListPreference( Context context, AttributeSet attrs )
{
super( context, attrs );
}
- // Why I exist: insert the rowid line if debug is on
+ // Why I exist: insert the rowid and gameid lines if debug is on
protected void onAttachedToActivity()
{
super.onAttachedToActivity();
@@ -38,14 +43,23 @@ public class XWSumListPreference extends XWListPreference {
if ( BuildConstants.IS_DEBUG_BUILD ||
XWPrefs.getDebugEnabled( m_context ) ) {
CharSequence[] entries = getEntries();
- String lastRow
- = m_context.getString( R.string.game_summary_field_rowid );
- if ( !entries[entries.length - 1].equals( lastRow ) ) {
+ CharSequence lastRow = entries[entries.length - 1];
+ boolean done = false;
+
+ String[] addRows = new String[s_ADDROWS.length];
+ for ( int ii = 0; !done && ii < s_ADDROWS.length; ++ii ) {
+ String addRow = m_context.getString( s_ADDROWS[ii] );
+ done = lastRow.equals( addRow );
+ addRows[ii] = addRow;
+ }
+
+ if ( !done ) {
CharSequence[] newEntries =
- new CharSequence[1 + entries.length];
+ new CharSequence[entries.length + addRows.length];
System.arraycopy( entries, 0, newEntries, 0,
entries.length );
- newEntries[entries.length] = lastRow;
+ System.arraycopy( addRows, 0, newEntries, entries.length,
+ addRows.length );
setEntries( newEntries );
setEntryValues( newEntries );
From 45fcd19e6e1e3cd090f76f4709f79872eaf6102b Mon Sep 17 00:00:00 2001
From: Eric House
Date: Mon, 18 Nov 2013 21:38:59 -0800
Subject: [PATCH 232/240] use gameID as inviteID, so that all devices in a game
will be using the same gameID -- and use that to reject as duplicates
attempts to use the same invitation more than once.
---
xwords4/android/XWords4/res/values/strings.xml | 3 ++-
.../src/org/eehouse/android/xw4/BoardActivity.java | 10 ++++++++--
.../XWords4/src/org/eehouse/android/xw4/GameUtils.java | 3 ++-
.../XWords4/src/org/eehouse/android/xw4/GamesList.java | 8 ++++----
.../src/org/eehouse/android/xw4/jni/CurGameInfo.java | 10 ++++++++--
5 files changed, 24 insertions(+), 10 deletions(-)
diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml
index 01c15916f..4fae56116 100644
--- a/xwords4/android/XWords4/res/values/strings.xml
+++ b/xwords4/android/XWords4/res/values/strings.xml
@@ -2173,7 +2173,8 @@
ThumbnailsSetting for game snapshots
- Invitation ignored: already used
+ Invitation received but ignored: it
+ has already been used to create a game.%1$s (yours)Invite
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java
index 1d23159fa..572895e40 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java
@@ -128,6 +128,7 @@ public class BoardActivity extends XWActivity
private int m_jniGamePtr;
private GameLock m_gameLock;
private CurGameInfo m_gi;
+ private GameSummary m_summary;
private CommsTransport m_xport;
private Handler m_handler = null;
private TimerRunnable[] m_timers;
@@ -1197,8 +1198,10 @@ public class BoardActivity extends XWActivity
{
String data = null;
if ( 0 < m_missing ) { // Isn't there a better test??
- String inviteID = GameUtils.makeRandomID();
- data = NetLaunchInfo.makeLaunchJSON( this, m_room, inviteID,
+ String inviteID = String.format( "%X", m_gi.gameID );
+ String room = m_summary.roomName;
+ Assert.assertNotNull( room );
+ data = NetLaunchInfo.makeLaunchJSON( this, room, inviteID,
m_gi.dictLang,
m_gi.dictName, m_gi.nPlayers );
}
@@ -1844,6 +1847,9 @@ public class BoardActivity extends XWActivity
pairs.m_paths, langName );
}
+ m_summary = new GameSummary( this, m_gi );
+ XwJNI.game_summarize( m_jniGamePtr, m_summary );
+
Handler handler = new Handler() {
public void handleMessage( Message msg ) {
switch( msg.what ) {
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java
index 4fe31f9f0..ea157dfd6 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java
@@ -411,7 +411,8 @@ public class GameUtils {
{
long rowid = -1;
- CurGameInfo gi = new CurGameInfo( context, true );
+ Assert.assertNotNull( inviteID );
+ CurGameInfo gi = new CurGameInfo( context, inviteID );
gi.setLang( lang[0], dict[0] );
lang[0] = gi.dictLang;
dict[0] = gi.dictName;
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
index 86f0859ea..8b9eac30d 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
@@ -1068,9 +1068,9 @@ public class GamesList extends XWExpandableListActivity
String msg = getString( R.string.dup_game_queryf,
create.toString() );
m_netLaunchInfo = nli;
- showConfirmThen( msg, GamesActions.NEW_NET_GAME.ordinal() );
+ showConfirmThen( msg, GamesActions.NEW_NET_GAME.ordinal(), nli );
} else {
- Utils.showToast( this, R.string.dropped_dupe );
+ showOKOnlyDialog( R.string.dropped_dupe );
}
} // startNewNetGame
@@ -1252,9 +1252,9 @@ public class GamesList extends XWExpandableListActivity
launchGame( rowid, false );
}
- private void makeNewNetGame( NetLaunchInfo info )
+ private void makeNewNetGame( NetLaunchInfo nli )
{
- long rowid = GameUtils.makeNewNetGame( this, info );
+ long rowid = GameUtils.makeNewNetGame( this, nli );
launchGame( rowid, true );
}
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/CurGameInfo.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/CurGameInfo.java
index ea68e4f58..9753055c3 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/CurGameInfo.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/CurGameInfo.java
@@ -60,11 +60,12 @@ public class CurGameInfo {
public CurGameInfo( Context context )
{
- this( context, false );
+ this( context, (String)null );
}
- public CurGameInfo( Context context, boolean isNetworked )
+ public CurGameInfo( Context context, String inviteID )
{
+ boolean isNetworked = null != inviteID;
m_context = context;
nPlayers = 2;
gameSeconds = 60 * nPlayers *
@@ -81,6 +82,11 @@ public class CurGameInfo {
allowHintRect = false;
m_smartness = 0; // needs to be set from players
+ try {
+ gameID = (null == inviteID) ? 0 : Integer.parseInt( inviteID, 16 );
+ } catch ( Exception ex ) {
+ }
+
// Always create MAX_NUM_PLAYERS so jni code doesn't ever have
// to cons up a LocalPlayer instance.
for ( int ii = 0; ii < MAX_NUM_PLAYERS; ++ii ) {
From 9fa715f096685f3e7076ea12eab12e5e5fffa84c Mon Sep 17 00:00:00 2001
From: Eric House
Date: Tue, 19 Nov 2013 05:42:00 -0800
Subject: [PATCH 233/240] add German to what thefreedictionary.com can look up
---
xwords4/android/XWords4/res/values/common_rsrc.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/xwords4/android/XWords4/res/values/common_rsrc.xml b/xwords4/android/XWords4/res/values/common_rsrc.xml
index 4f4a8f98f..6658df2e8 100644
--- a/xwords4/android/XWords4/res/values/common_rsrc.xml
+++ b/xwords4/android/XWords4/res/values/common_rsrc.xml
@@ -259,7 +259,7 @@
http://dictionary.com/browse/%2$s -->
TheFreeDictionary.com
- :en:es:
+ :en:es:de:http://%1$s.thefreedictionary.com/_/dict.aspx?word=%2$sLarousse.com
From 0cef5fce508e10bc3e373b626a40ae7f35fc025b Mon Sep 17 00:00:00 2001
From: Eric House
Date: Tue, 19 Nov 2013 06:26:07 -0800
Subject: [PATCH 234/240] display gameid as hex
---
.../XWords4/src/org/eehouse/android/xw4/GameListItem.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java
index 4b136b6f4..54287260b 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java
@@ -212,7 +212,7 @@ public class GameListItem extends LinearLayout
case R.string.game_summary_field_empty:
break;
case R.string.game_summary_field_gameid:
- value = String.format( "%d", m_summary.gameID );
+ value = String.format( "%X", m_summary.gameID );
break;
case R.string.game_summary_field_rowid:
value = String.format( "%d", m_rowid );
From 63ba7d45d3c79a2b89ca3af6e51772a415ff1ae1 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Tue, 19 Nov 2013 06:37:39 -0800
Subject: [PATCH 235/240] use gameID as inviteID for non-NFC invites too
---
.../src/org/eehouse/android/xw4/BoardActivity.java | 8 +++++---
.../src/org/eehouse/android/xw4/GameUtils.java | 14 ++++++++++----
2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java
index 572895e40..9069f7d03 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java
@@ -940,9 +940,11 @@ public class BoardActivity extends XWActivity
&& !NFCUtils.nfcAvail( this )[1] ) {
showDialog( ENABLE_NFC );
} else {
- GameUtils.launchInviteActivity( this, which,
- m_room, null, m_gi.dictLang,
- m_gi.dictName, m_gi.nPlayers );
+ String inviteID = GameUtils.formatGameID( m_gi.gameID );
+ GameUtils.launchInviteActivity( this, which, m_room,
+ inviteID, m_gi.dictLang,
+ m_gi.dictName,
+ m_gi.nPlayers );
}
}
} else if ( AlertDialog.BUTTON_POSITIVE == which ) {
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java
index ea157dfd6..b542ca4b9 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java
@@ -522,9 +522,8 @@ public class GameUtils {
int lang, String dict,
int nPlayers )
{
- if ( null == inviteID ) {
- inviteID = makeRandomID();
- }
+ Assert.assertNotNull( inviteID );
+
String msgString;
if ( DlgDelegate.NFC_BTN == chosen ) {
msgString = NetLaunchInfo.makeLaunchJSON( activity, room, inviteID,
@@ -870,10 +869,17 @@ public class GameUtils {
activity.startActivity( intent );
}
+ public static String formatGameID( int gameID )
+ {
+ Assert.assertTrue( 0 != gameID );
+ // substring: Keep it short so fits in SMS better
+ return String.format( "%X", gameID ).substring( 0, 4 );
+ }
+
public static String makeRandomID()
{
int rint = newGameID();
- return String.format( "%X", rint ).substring( 0, 4 );
+ return formatGameID( rint );
}
public static int newGameID()
From 51a561077c9036cf793934fefcdf1b7c221ce73e Mon Sep 17 00:00:00 2001
From: Eric House
Date: Tue, 19 Nov 2013 07:22:14 -0800
Subject: [PATCH 236/240] when action-bar-equipped device tries to hide title
bar warn and then disable pref.
---
.../android/XWords4/res/values/strings.xml | 3 +++
.../eehouse/android/xw4/PrefsActivity.java | 24 +++++++++++++++++--
2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml
index 4fae56116..1074cabd5 100644
--- a/xwords4/android/XWords4/res/values/strings.xml
+++ b/xwords4/android/XWords4/res/values/strings.xml
@@ -2181,4 +2181,7 @@
NFC is turned off on this device. Use
the Android Settings app to turn it on .Launch Settings
+
+ This setting is ignored on devices
+ like yours that depend on the \"Action bar\".
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/PrefsActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/PrefsActivity.java
index 484c9b077..7bed3b2cb 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/PrefsActivity.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/PrefsActivity.java
@@ -19,13 +19,15 @@
*/
package org.eehouse.android.xw4;
+
import android.app.AlertDialog;
import android.app.Dialog;
-import android.preference.PreferenceActivity;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
+import android.preference.CheckBoxPreference;
+import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;
import android.view.View;
import android.widget.Button;
@@ -37,6 +39,7 @@ public class PrefsActivity extends PreferenceActivity
private static final int REVERT_COLORS = 1;
private static final int REVERT_ALL = 2;
public static final int CONFIRM_SMS = 3;
+ public static final int EXPLAIN_TITLE = 4;
private String m_keyLogging;
private String m_smsToasting;
@@ -44,6 +47,7 @@ public class PrefsActivity extends PreferenceActivity
private String m_downloadPath;
private String m_thumbEnabled;
private String m_thumbSize;
+ private String m_hideTitle;
@Override
@@ -100,6 +104,13 @@ public class PrefsActivity extends PreferenceActivity
case CONFIRM_SMS:
dialog = SMSCheckBoxPreference.onCreateDialog( this, id );
break;
+ case EXPLAIN_TITLE:
+ dialog = new AlertDialog.Builder( this )
+ .setMessage( R.string.no_hide_titlebar )
+ .setTitle( R.string.info_title )
+ .setPositiveButton( R.string.button_ok, null )
+ .create();
+ break;
}
if ( null == dialog && null != lstnr ) {
@@ -128,6 +139,7 @@ public class PrefsActivity extends PreferenceActivity
m_downloadPath = getString( R.string.key_download_path );
m_thumbEnabled = getString( R.string.key_thumb_enabled );
m_thumbSize = getString( R.string.key_thumbsize );
+ m_hideTitle = getString( R.string.key_hide_title );
Button button = (Button)findViewById( R.id.revert_colors );
button.setOnClickListener( new View.OnClickListener() {
@@ -193,7 +205,15 @@ public class PrefsActivity extends PreferenceActivity
} else if ( key.equals( m_thumbEnabled )
|| key.equals( m_thumbSize ) ) {
DBUtils.clearThumbnails( this );
- }
+ } else if ( key.equals( m_hideTitle ) ) {
+ if ( sp.getBoolean( key, false ) && ABUtils.haveActionBar() ) {
+ CheckBoxPreference pref
+ = (CheckBoxPreference)findPreference(key);
+ pref.setChecked( false );
+ pref.setEnabled( false );
+ showDialog( EXPLAIN_TITLE );
+ }
+ }
}
private void relaunch()
From b1ae563ae67c4ef6d379776ba45e3507636a2022 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Wed, 20 Nov 2013 06:54:51 -0800
Subject: [PATCH 237/240] fix NPE when installed with existing SMS invites in
inbox
---
xwords4/android/XWords4/res/values/strings.xml | 2 ++
.../src/org/eehouse/android/xw4/GameUtils.java | 18 +++++++-----------
2 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml
index 1074cabd5..7900c63d6 100644
--- a/xwords4/android/XWords4/res/values/strings.xml
+++ b/xwords4/android/XWords4/res/values/strings.xml
@@ -2184,4 +2184,6 @@
This setting is ignored on devices
like yours that depend on the \"Action bar\".
+
+ Tap the receiving device now
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java
index b542ca4b9..2fbd4e466 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java
@@ -411,7 +411,7 @@ public class GameUtils {
{
long rowid = -1;
- Assert.assertNotNull( inviteID );
+ Assert.assertNotNull( inviteID ); // firing
CurGameInfo gi = new CurGameInfo( context, inviteID );
gi.setLang( lang[0], dict[0] );
lang[0] = gi.dictLang;
@@ -513,8 +513,10 @@ public class GameUtils {
if ( isHost ) {
addr = new CommsAddrRec(CommsAddrRec.CommsConnType.COMMS_CONN_SMS);
}
+ String inviteID = GameUtils.formatGameID( gameID );
return makeNewMultiGame( context, groupID, addr, langa, dicta,
- nPlayersT, nPlayersH, null, gameID, isHost );
+ nPlayersT, nPlayersH, inviteID, gameID,
+ isHost );
}
public static void launchInviteActivity( Activity activity, int chosen,
@@ -524,20 +526,14 @@ public class GameUtils {
{
Assert.assertNotNull( inviteID );
- String msgString;
if ( DlgDelegate.NFC_BTN == chosen ) {
- msgString = NetLaunchInfo.makeLaunchJSON( activity, room, inviteID,
- lang, dict, nPlayers );
+ Utils.showToast( activity, R.string.sms_ready_text );
} else {
Uri gameUri = NetLaunchInfo.makeLaunchUri( activity, room, inviteID,
lang, dict, nPlayers );
- msgString = null == gameUri ? null : gameUri.toString();
- }
+ String msgString = null == gameUri ? null : gameUri.toString();
- if ( null != msgString ) {
- if ( DlgDelegate.NFC_BTN == chosen ) {
- Utils.showToast( activity, "Tap the receiving device now" );
- } else {
+ if ( null != msgString ) {
boolean choseEmail = DlgDelegate.EMAIL_BTN == chosen;
int fmtId = choseEmail? R.string.invite_htmf : R.string.invite_txtf;
From 5f7242f01b80997dd6d50ca047726b88eb19cdac Mon Sep 17 00:00:00 2001
From: Eric House
Date: Wed, 20 Nov 2013 07:34:11 -0800
Subject: [PATCH 238/240] tweak string
---
xwords4/android/XWords4/res/values/strings.xml | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml
index 7900c63d6..38310652e 100644
--- a/xwords4/android/XWords4/res/values/strings.xml
+++ b/xwords4/android/XWords4/res/values/strings.xml
@@ -2178,12 +2178,13 @@
%1$s (yours)Invite
- NFC is turned off on this device. Use
- the Android Settings app to turn it on .
+ NFC is turned off on this device. You
+ can use the Android Settings app to turn it on .
+
Launch Settings
- This setting is ignored on devices
- like yours that depend on the \"Action bar\".
+ This setting is ignored on devices
+ like yours that depend on the \"Action bar.\"
- Tap the receiving device now
+ Tap the receiving device now
From 2e5e10ef6d407be87189c78de1ef8e824ec75979 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Wed, 20 Nov 2013 07:56:05 -0800
Subject: [PATCH 239/240] move dialog asking to enable NFC into NFCUtils, and
use it when creating a new game to be invited via (disabled) NFC
---
.../android/XWords4/res/layout/new_game.xml | 2 +-
.../eehouse/android/xw4/BoardActivity.java | 14 +----
.../src/org/eehouse/android/xw4/NFCUtils.java | 23 +++++++
.../eehouse/android/xw4/NewGameActivity.java | 62 +++++++++++--------
4 files changed, 61 insertions(+), 40 deletions(-)
diff --git a/xwords4/android/XWords4/res/layout/new_game.xml b/xwords4/android/XWords4/res/layout/new_game.xml
index b884b8863..a83f5efee 100644
--- a/xwords4/android/XWords4/res/layout/new_game.xml
+++ b/xwords4/android/XWords4/res/layout/new_game.xml
@@ -88,7 +88,7 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
-
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java
index 9069f7d03..0679da3ae 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java
@@ -515,19 +515,7 @@ public class BoardActivity extends XWActivity
break;
case ENABLE_NFC:
- lstnr = new DialogInterface.OnClickListener() {
- public void onClick( DialogInterface dialog,
- int item ) {
- startActivity( new Intent("android.settings"
- + ".NFC_SETTINGS" ) );
- }
- };
- dialog = new AlertDialog.Builder( this )
- .setTitle( R.string.info_title )
- .setMessage( R.string.enable_nfc )
- .setPositiveButton( R.string.button_cancel, null )
- .setNegativeButton( R.string.button_go_settings, lstnr )
- .create();
+ dialog = NFCUtils.makeEnableNFCDialog( this );
break;
default:
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NFCUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NFCUtils.java
index 41981bcaf..b9f3a8700 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NFCUtils.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NFCUtils.java
@@ -21,7 +21,11 @@
package org.eehouse.android.xw4;
import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Dialog;
import android.content.Context;
+import android.content.DialogInterface.OnClickListener;
+import android.content.DialogInterface;
import android.content.Intent;
import android.nfc.NdefMessage;
import android.nfc.NdefRecord;
@@ -116,6 +120,25 @@ public class NFCUtils {
}
}
+ public static Dialog makeEnableNFCDialog( final Activity activity )
+ {
+ DialogInterface.OnClickListener lstnr
+ = new DialogInterface.OnClickListener() {
+ public void onClick( DialogInterface dialog,
+ int item ) {
+ activity.
+ startActivity( new Intent("android.settings"
+ + ".NFC_SETTINGS" ) );
+ }
+ };
+ return new AlertDialog.Builder( activity )
+ .setTitle( R.string.info_title )
+ .setMessage( R.string.enable_nfc )
+ .setPositiveButton( R.string.button_cancel, null )
+ .setNegativeButton( R.string.button_go_settings, lstnr )
+ .create();
+ }
+
private static NdefMessage makeMessage( Activity activity, String data )
{
String mimeType = activity.getString( R.string.xwords_nfc_mime );
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameActivity.java
index c45bd58bb..7061cf3ec 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameActivity.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameActivity.java
@@ -1,6 +1,6 @@
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
/*
- * Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
+ * Copyright 2009 - 2013 by Eric House (xwords@eehouse.org). All
* rights reserved.
*
* This program is free software; you can redistribute it and/or
@@ -59,7 +59,8 @@ public class NewGameActivity extends XWActivity {
// Dialogs
private static final int NAME_GAME = DlgDelegate.DIALOG_LAST + 1;
-
+ private static final int ENABLE_NFC = DlgDelegate.DIALOG_LAST + 2;
+
private boolean m_showsOn;
private boolean m_nameForBT;
private boolean m_firingPrefs = false;
@@ -103,7 +104,7 @@ public class NewGameActivity extends XWActivity {
}
} );
- button = (Button)findViewById( R.id.newgame_invite );
+ button = (Button)findViewById( R.id.newgame_invite_net );
button.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick( View v ) {
@@ -254,6 +255,9 @@ public class NewGameActivity extends XWActivity {
.create();
Utils.setRemoveOnDismiss( this, dialog, id );
+ break;
+ case ENABLE_NFC:
+ dialog = NFCUtils.makeEnableNFCDialog( this );
break;
}
}
@@ -318,34 +322,40 @@ public class NewGameActivity extends XWActivity {
private void makeNewGame( boolean networked, boolean launch,
int chosen )
{
- String room = null;
- String inviteID = null;
- long rowid;
- int[] lang = {0};
- String[] dict = {null};
- final int nPlayers = 2; // hard-coded for no-configure case
-
- if ( networked ) {
- room = GameUtils.makeRandomID();
- inviteID = GameUtils.makeRandomID();
- rowid = GameUtils.makeNewNetGame( this, m_groupID, room, inviteID,
- lang, dict, nPlayers, 1 );
+ if ( DlgDelegate.NFC_BTN == chosen
+ && !NFCUtils.nfcAvail( this )[1] ) {
+ showDialog( ENABLE_NFC );
} else {
- rowid = GameUtils.saveNew( this, new CurGameInfo( this ), m_groupID );
- }
+ String room = null;
+ String inviteID = null;
+ long rowid;
+ int[] lang = {0};
+ String[] dict = {null};
+ final int nPlayers = 2; // hard-coded for no-configure case
- if ( launch ) {
- GameUtils.launchGame( this, rowid, networked );
if ( networked ) {
- GameUtils.launchInviteActivity( this, chosen, room,
- inviteID, lang[0], dict[0],
- nPlayers );
+ room = GameUtils.makeRandomID();
+ inviteID = GameUtils.makeRandomID();
+ rowid = GameUtils.makeNewNetGame( this, m_groupID, room, inviteID,
+ lang, dict, nPlayers, 1 );
+ } else {
+ rowid = GameUtils.saveNew( this, new CurGameInfo( this ),
+ m_groupID );
}
- } else {
- GameUtils.doConfig( this, rowid, GameConfig.class );
- }
- finish();
+ if ( launch ) {
+ GameUtils.launchGame( this, rowid, networked );
+ if ( networked ) {
+ GameUtils.launchInviteActivity( this, chosen, room,
+ inviteID, lang[0], dict[0],
+ nPlayers );
+ }
+ } else {
+ GameUtils.doConfig( this, rowid, GameConfig.class );
+ }
+
+ finish();
+ }
}
private void makeNewBTGame( boolean useDefaults )
From 24e015f259802debdb9d38a0e634d8cba98edcf8 Mon Sep 17 00:00:00 2001
From: Eric House
Date: Wed, 20 Nov 2013 08:15:18 -0800
Subject: [PATCH 240/240] don't make snapshots for non-expanded game list
items; make when first expanded instead.
---
.../org/eehouse/android/xw4/GameListItem.java | 27 ++++++++++++-------
1 file changed, 17 insertions(+), 10 deletions(-)
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java
index 54287260b..6b621e357 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java
@@ -169,6 +169,9 @@ public class GameListItem extends LinearLayout
public void onClick( View view ) {
m_expanded = !m_expanded;
DBUtils.setExpanded( m_rowid, m_expanded );
+
+ makeThumbnailIf( m_expanded );
+
showHide();
}
@@ -243,7 +246,7 @@ public class GameListItem extends LinearLayout
return state;
}
- private void setData( GameSummary summary )
+ private void setData( GameSummary summary, boolean expanded )
{
if ( null != summary ) {
TextView tview;
@@ -318,8 +321,6 @@ public class GameListItem extends LinearLayout
tview.setVisibility( View.GONE );
}
- boolean expanded = DBUtils.getExpanded( m_context, m_rowid );
-
update( expanded, summary.lastMoveTime, haveATurn,
haveALocalTurn );
}
@@ -337,6 +338,16 @@ public class GameListItem extends LinearLayout
m_cb.itemToggled( this, m_selected );
}
+ private void makeThumbnailIf( boolean expanded )
+ {
+ if ( expanded && null != m_activity && null != m_summary
+ && null == m_summary.getThumbnail()
+ && XWPrefs.getThumbEnabled( m_context ) ) {
+ m_summary.setThumbnail( GameUtils.loadMakeBitmap( m_activity,
+ m_rowid ) );
+ }
+ }
+
private class LoadItemTask extends AsyncTask {
@Override
protected GameSummary doInBackground( Void... unused )
@@ -349,15 +360,11 @@ public class GameListItem extends LinearLayout
{
if ( 0 == --m_loadingCount ) {
m_summary = summary;
+ boolean expanded = DBUtils.getExpanded( m_context, m_rowid );
- if ( null != m_activity && null != summary
- && null == summary.getThumbnail()
- && XWPrefs.getThumbEnabled( m_context ) ) {
- summary.setThumbnail( GameUtils.loadMakeBitmap( m_activity,
- m_rowid ) );
- }
+ makeThumbnailIf( expanded );
- setData( summary );
+ setData( summary, expanded );
setLoaded( null != m_summary );
synchronized( s_invalRows ) {
s_invalRows.remove( m_rowid );