From 8590aae9b2dd2beb776c34b3b08d4083e5488b3d Mon Sep 17 00:00:00 2001 From: Eric House Date: Wed, 15 Feb 2012 18:07:19 -0800 Subject: [PATCH 1/3] fix emacs compile-commands --- xwords4/android/XWords4/jni/anddict.c | 2 +- xwords4/android/XWords4/jni/anddict.h | 2 +- xwords4/android/XWords4/jni/andutils.c | 2 +- xwords4/android/XWords4/jni/drawwrapper.c | 2 +- xwords4/android/XWords4/jni/jniutlswrapper.c | 2 +- xwords4/android/XWords4/jni/paths.h | 2 +- xwords4/android/XWords4/jni/utilwrapper.c | 2 +- xwords4/android/XWords4/jni/xportwrapper.c | 2 +- xwords4/android/XWords4/jni/xwjni.c | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/xwords4/android/XWords4/jni/anddict.c b/xwords4/android/XWords4/jni/anddict.c index a8ce5b419..626124106 100644 --- a/xwords4/android/XWords4/jni/anddict.c +++ b/xwords4/android/XWords4/jni/anddict.c @@ -1,4 +1,4 @@ -/* -*- compile-command: "../../scripts/ndkbuild.sh"; -*- */ +/* -*- compile-command: "cd ..; ../scripts/ndkbuild.sh -j3"; -*- */ /* * Copyright © 2009 - 2011 by Eric House (xwords@eehouse.org). All rights * reserved. diff --git a/xwords4/android/XWords4/jni/anddict.h b/xwords4/android/XWords4/jni/anddict.h index 4ab9987b0..4f20b894b 100644 --- a/xwords4/android/XWords4/jni/anddict.h +++ b/xwords4/android/XWords4/jni/anddict.h @@ -1,4 +1,4 @@ -/* -*-mode: C; compile-command: "../../scripts/ndkbuild.sh"; -*- */ +/* -*-mode: C; compile-command: "cd ..; ../scripts/ndkbuild.sh -j3"; -*- */ /* * Copyright © 2009-2010 by Eric House (xwords@eehouse.org). All * rights reserved. diff --git a/xwords4/android/XWords4/jni/andutils.c b/xwords4/android/XWords4/jni/andutils.c index 925e6e9e4..5113807c6 100644 --- a/xwords4/android/XWords4/jni/andutils.c +++ b/xwords4/android/XWords4/jni/andutils.c @@ -1,4 +1,4 @@ -/* -*-mode: C; compile-command: "../../scripts/ndkbuild.sh"; -*- */ +/* -*-mode: C; compile-command: "cd ..; ../scripts/ndkbuild.sh -j3"; -*- */ /* * Copyright © 2009-2010 by Eric House (xwords@eehouse.org). All * rights reserved. diff --git a/xwords4/android/XWords4/jni/drawwrapper.c b/xwords4/android/XWords4/jni/drawwrapper.c index fe072416b..05c3ea01b 100644 --- a/xwords4/android/XWords4/jni/drawwrapper.c +++ b/xwords4/android/XWords4/jni/drawwrapper.c @@ -1,4 +1,4 @@ -/* -*-mode: C; compile-command: "../../scripts/ndkbuild.sh"; -*- */ +/* -*-mode: C; compile-command: "cd ..; ../scripts/ndkbuild.sh -j3"; -*- */ /* * Copyright 2001-2010 by Eric House (xwords@eehouse.org). All rights * reserved. diff --git a/xwords4/android/XWords4/jni/jniutlswrapper.c b/xwords4/android/XWords4/jni/jniutlswrapper.c index 0c681b369..94b52265c 100644 --- a/xwords4/android/XWords4/jni/jniutlswrapper.c +++ b/xwords4/android/XWords4/jni/jniutlswrapper.c @@ -1,4 +1,4 @@ -/* -*-mode: C; compile-command: "../../scripts/ndkbuild.sh"; -*- */ +/* -*-mode: C; compile-command: "cd ..; ../scripts/ndkbuild.sh -j3"; -*- */ /* * Copyright 2001-2010 by Eric House (xwords@eehouse.org). All rights * reserved. diff --git a/xwords4/android/XWords4/jni/paths.h b/xwords4/android/XWords4/jni/paths.h index 6c6b51037..d235aed1e 100644 --- a/xwords4/android/XWords4/jni/paths.h +++ b/xwords4/android/XWords4/jni/paths.h @@ -1,4 +1,4 @@ -/* -*-mode: C; compile-command: "../../scripts/ndkbuild.sh"; -*- */ +/* -*-mode: C; compile-command: "cd ..; ../scripts/ndkbuild.sh -j3"; -*- */ /* * Copyright © 2012 by Eric House (xwords@eehouse.org). All rights reserved. * diff --git a/xwords4/android/XWords4/jni/utilwrapper.c b/xwords4/android/XWords4/jni/utilwrapper.c index 6a2d6b82e..7aa80c71d 100644 --- a/xwords4/android/XWords4/jni/utilwrapper.c +++ b/xwords4/android/XWords4/jni/utilwrapper.c @@ -1,4 +1,4 @@ -/* -*-mode: C; compile-command: "../../scripts/ndkbuild.sh"; -*- */ +/* -*-mode: C; compile-command: "cd ..; ../scripts/ndkbuild.sh -j3"; -*- */ /* * Copyright 2001-2010 by Eric House (xwords@eehouse.org). All rights * reserved. diff --git a/xwords4/android/XWords4/jni/xportwrapper.c b/xwords4/android/XWords4/jni/xportwrapper.c index f0e0bfc65..78192a2f3 100644 --- a/xwords4/android/XWords4/jni/xportwrapper.c +++ b/xwords4/android/XWords4/jni/xportwrapper.c @@ -1,4 +1,4 @@ -/* -*-mode: C; compile-command: "../../scripts/ndkbuild.sh"; -*- */ +/* -*-mode: C; compile-command: "cd ..; ../scripts/ndkbuild.sh -j3"; -*- */ /* * Copyright 2001-2010 by Eric House (xwords@eehouse.org). All rights * reserved. diff --git a/xwords4/android/XWords4/jni/xwjni.c b/xwords4/android/XWords4/jni/xwjni.c index 2879c0ea5..916e8b670 100644 --- a/xwords4/android/XWords4/jni/xwjni.c +++ b/xwords4/android/XWords4/jni/xwjni.c @@ -1,4 +1,4 @@ -/* -*-mode: C; compile-command: "../../scripts/ndkbuild.sh"; -*- */ +/* -*-mode: C; compile-command: "cd ../; ../scripts/ndkbuild.sh -j3"; -*- */ /* * Copyright © 2009 - 2011 by Eric House (xwords@eehouse.org). All rights * reserved. From 14a3a5a7aa1387c4c7c9b366bab8b70d4eaa9b4f Mon Sep 17 00:00:00 2001 From: Eric House Date: Wed, 15 Feb 2012 18:16:46 -0800 Subject: [PATCH 2/3] Save which languages are displayed opened as an invisible preference rather than in a static so it is more persistent. --- .../XWords4/res/values/common_rsrc.xml | 3 + .../eehouse/android/xw4/DictsActivity.java | 61 +++++++++++-------- .../eehouse/android/xw4/jni/CommonPrefs.java | 18 +++++- 3 files changed, 56 insertions(+), 26 deletions(-) diff --git a/xwords4/android/XWords4/res/values/common_rsrc.xml b/xwords4/android/XWords4/res/values/common_rsrc.xml index ba9b2cbad..d5b30f772 100644 --- a/xwords4/android/XWords4/res/values/common_rsrc.xml +++ b/xwords4/android/XWords4/res/values/common_rsrc.xml @@ -57,6 +57,9 @@ key_keep_screenon key_summary_field + + key_closed_langs + key_notagain_sync key_notagain_chat key_notagain_relay 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 22439b6cc..996d75bfe 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsActivity.java @@ -1,6 +1,6 @@ /* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */ /* - * Copyright 2009 - 2011 by Eric House (xwords@eehouse.org). All + * Copyright 2009 - 2012 by Eric House (xwords@eehouse.org). All * rights reserved. * * This program is free software; you can redistribute it and/or @@ -24,32 +24,33 @@ import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; import android.app.ExpandableListActivity; +import android.content.Context; +import android.content.DialogInterface.OnClickListener; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.SharedPreferences; +import android.content.res.Resources; import android.database.DataSetObserver; +import android.net.Uri; import android.os.Bundle; import android.os.Handler; -import android.widget.Button; -import android.widget.TextView; -import android.content.Context; -import android.content.DialogInterface; -import android.content.DialogInterface.OnClickListener; -import android.content.Intent; -import android.content.res.Resources; -import android.content.SharedPreferences; -import android.view.View; -import android.view.ViewGroup; -import android.view.ContextMenu; -import android.view.MenuItem; +import android.preference.PreferenceManager; import android.view.ContextMenu.ContextMenuInfo; +import android.view.ContextMenu; import android.view.LayoutInflater; import android.view.MenuInflater; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; import android.widget.ExpandableListAdapter; -import android.widget.ExpandableListView; import android.widget.ExpandableListView.ExpandableListContextMenuInfo; +import android.widget.ExpandableListView; +import android.widget.TextView; import android.widget.Toast; -import android.preference.PreferenceManager; -import android.net.Uri; import java.util.Arrays; import java.util.HashMap; +import java.util.HashSet; import junit.framework.Assert; import org.eehouse.android.xw4.DictUtils.DictAndLoc; @@ -70,8 +71,7 @@ public class DictsActivity extends ExpandableListActivity private static final String LANG = "lang"; private static final String MOVEFROMLOC = "movefromloc"; - private static HashMap s_openStates = - new HashMap(); + private HashSet m_closedLangs; // For new callback alternative private static final int DELETE_DICT_ACTION = 1; @@ -214,10 +214,12 @@ public class DictsActivity extends ExpandableListActivity public boolean isEmpty() { return false; } public void onGroupCollapsed(int groupPosition) { - s_openStates.put( m_langs[groupPosition], false ); + m_closedLangs.add( m_langs[groupPosition] ); + saveClosed(); } public void onGroupExpanded(int groupPosition){ - s_openStates.put( m_langs[groupPosition], true ); + m_closedLangs.remove( m_langs[groupPosition] ); + saveClosed(); } public void registerDataSetObserver( DataSetObserver obs ){} public void unregisterDataSetObserver( DataSetObserver obs ){} @@ -380,6 +382,14 @@ public class DictsActivity extends ExpandableListActivity super.onCreate( savedInstanceState ); getBundledData( savedInstanceState ); + m_closedLangs = new HashSet(); + String[] closed = CommonPrefs.getClosedLangs( this ); + if ( null != closed ) { + for ( String str : closed ) { + m_closedLangs.add( str ); + } + } + Resources res = getResources(); m_locNames = res.getStringArray( R.array.loc_names ); @@ -670,15 +680,18 @@ public class DictsActivity extends ExpandableListActivity for ( int ii = 0; ii < m_langs.length; ++ii ) { boolean open = true; String lang = m_langs[ii]; - if ( s_openStates.containsKey( lang ) ) { - open = s_openStates.get( lang ); - } - if ( open ) { + if ( ! m_closedLangs.contains( lang ) ) { m_expView.expandGroup( ii ); } } } + private void saveClosed() + { + String[] asArray = m_closedLangs.toArray( new String[m_closedLangs.size()] ); + CommonPrefs.setClosedLangs( this, asArray ); + } + private static Intent mkDownloadIntent( Context context, int lang, String dict ) { 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 eb8374b23..756383337 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 @@ -22,9 +22,10 @@ package org.eehouse.android.xw4.jni; import android.content.Context; import android.content.SharedPreferences; -import android.preference.PreferenceManager; -import android.graphics.Paint; import android.content.res.Resources; +import android.graphics.Paint; +import android.preference.PreferenceManager; +import android.text.TextUtils; import junit.framework.Assert; import org.eehouse.android.xw4.R; @@ -331,6 +332,19 @@ public class CommonPrefs { return getString( context, R.string.key_summary_field ); } + public static void setClosedLangs( Context context, String[] langs ) + { + setPrefsString( context, R.string.key_closed_langs, + TextUtils.join( "\n", langs ) ); + } + + public static String[] getClosedLangs( Context context ) + { + String asStr = getString( context, R.string.key_closed_langs ); + String[] result = null == asStr ? null : TextUtils.split( asStr, "\n" ); + return result; + } + public static boolean getPrefsBoolean( Context context, int keyID, boolean defaultValue ) { From e7a5882ed95f21a48963fefeda6cfcc3739d50fd Mon Sep 17 00:00:00 2001 From: Eric House Date: Wed, 15 Feb 2012 18:17:26 -0800 Subject: [PATCH 3/3] add a state transition lack of which fired an assert -- and that's rare but consistent with others. --- xwords4/relay/states.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/xwords4/relay/states.cpp b/xwords4/relay/states.cpp index 8a416b7b1..f133edb10 100644 --- a/xwords4/relay/states.cpp +++ b/xwords4/relay/states.cpp @@ -76,6 +76,7 @@ static StateTable g_stateTable[] = { { XWS_ALLCONND, XWE_GOTONEACK, XWA_NONE, XWS_ALLCONND }, { XWS_EMPTY, XWE_PROXYMSG, XWA_PROXYMSG, XWS_SAME }, +{ XWS_WAITMORE, XWE_PROXYMSG, XWA_PROXYMSG, XWS_SAME }, { XWS_ALLCONND, XWE_PROXYMSG, XWA_PROXYMSG, XWS_SAME }, /* { XWS_WAITMORE, XWE_GAMEFULL, XWA_SENDALLHERE, XWS_ALLCONND }, */