Merge branch 'android_branch' into android_browsedict

Conflicts:
	xwords4/common/dictiter.c
	xwords4/linux/linuxmain.c
This commit is contained in:
Eric House 2011-11-03 21:32:04 -07:00
commit adb9473a87
12 changed files with 111 additions and 80 deletions

View file

@ -22,7 +22,7 @@
to come from a domain that you own or have control over. --> to come from a domain that you own or have control over. -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.eehouse.android.xw4" package="org.eehouse.android.xw4"
android:versionCode="29" android:versionCode="30"
android:versionName="@string/app_version" android:versionName="@string/app_version"
> >
@ -118,7 +118,9 @@
</activity> </activity>
<activity android:name="RelayGameActivity"/> <activity android:name="RelayGameActivity"/>
<activity android:name="DictBrowseActivity"/> <activity android:name="DictBrowseActivity"
android:configChanges="keyboardHidden|orientation"
/>
<activity android:name="ChatActivity"/> <activity android:name="ChatActivity"/>
<service android:name="RelayService"/> <service android:name="RelayService"/>

View file

@ -1450,10 +1450,9 @@ Java_org_eehouse_android_xw4_jni_XwJNI_dict_1iter_1getStartsWith
XP_U16 nTiles = VSIZE(tiles); XP_U16 nTiles = VSIZE(tiles);
const char* prefix = (*env)->GetStringUTFChars( env, jprefix, NULL ); const char* prefix = (*env)->GetStringUTFChars( env, jprefix, NULL );
if ( dict_tilesForString( data->dict, prefix, tiles, &nTiles ) ) { if ( dict_tilesForString( data->dict, prefix, tiles, &nTiles ) ) {
IndexData* idata = NULL; if ( dict_findStartsWith( &data->iter, NULL, tiles, nTiles ) ) {
DictPosition pos = dict_findStartsWith( &data->iter, idata, tiles, result = dict_getPosition( &data->iter );
nTiles ); }
result = pos;
} }
(*env)->ReleaseStringUTFChars( env, jprefix, prefix ); (*env)->ReleaseStringUTFChars( env, jprefix, prefix );
} }

View file

@ -35,38 +35,47 @@
/> />
</LinearLayout> </LinearLayout>
<LinearLayout android:id="@+id/toolbar_horizontal" <HorizontalScrollView android:orientation="horizontal"
android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_height="wrap_content" >
> <LinearLayout android:id="@+id/toolbar_horizontal"
<ImageButton android:id="@+id/prevhint_button_horizontal" android:orientation="horizontal"
style="@style/toolbar_button" android:layout_width="fill_parent"
android:src="@drawable/prev_hint" android:layout_height="wrap_content"
/> >
<ImageButton android:id="@+id/nexthint_button_horizontal" <ImageButton android:id="@+id/dictlist_button_horizontal"
style="@style/toolbar_button" style="@style/toolbar_button"
android:src="@drawable/next_hint" android:src="@drawable/dicticon"
/> />
<ImageButton android:id="@+id/shuffle_button_horizontal" <ImageButton android:id="@+id/prevhint_button_horizontal"
style="@style/toolbar_button" style="@style/toolbar_button"
android:src="@drawable/shuffle" android:src="@drawable/prev_hint"
/> />
<ImageButton android:id="@+id/flip_button_horizontal" <ImageButton android:id="@+id/nexthint_button_horizontal"
style="@style/toolbar_button" style="@style/toolbar_button"
android:src="@drawable/flip" android:src="@drawable/next_hint"
/> />
<ImageButton android:id="@+id/zoom_button_horizontal" <ImageButton android:id="@+id/shuffle_button_horizontal"
style="@style/toolbar_button" style="@style/toolbar_button"
android:src="@drawable/zoom" android:src="@drawable/shuffle"
/> />
<ImageButton android:id="@+id/undo_button_horizontal" <ImageButton android:id="@+id/flip_button_horizontal"
style="@style/toolbar_button" style="@style/toolbar_button"
android:src="@drawable/undo" android:src="@drawable/flip"
/> />
<ImageButton android:id="@+id/chat_button_horizontal" <ImageButton android:id="@+id/zoom_button_horizontal"
style="@style/toolbar_button" style="@style/toolbar_button"
android:src="@drawable/stat_notify_chat" android:src="@drawable/zoom"
/> />
</LinearLayout> <ImageButton android:id="@+id/undo_button_horizontal"
style="@style/toolbar_button"
android:src="@drawable/undo"
/>
<ImageButton android:id="@+id/chat_button_horizontal"
style="@style/toolbar_button"
android:src="@drawable/stat_notify_chat"
/>
</LinearLayout>
</HorizontalScrollView>
</LinearLayout> </LinearLayout>

View file

@ -6,17 +6,29 @@
</head> </head>
<body> <body>
<b>Crosswords 4.4 beta 37 release</b> <b>Crosswords 4.4 beta 38 release</b>
<ul> <ul>
<li>Added a wordlist browser, which you can get to by tapping a
wordlist in the Wordlist screen, or by using the wordlist
button at the bottom of the game board. Eventually you'll be
able to filter based on length, chosen tiles, etc. Right now
you can scroll through all the words (even 2.7 million of them
if you're playing in Polish.)</li>
<li>Extend ability to look up words to include those already on the <li>Added the "download directory" to locations I search for
board. Hold your finger on any played tile to look up any of the wordlists. This means that if you're using a browser like
words that use it. </li> Opera that doesn't respect apps' registering for certain types
of data you can still use a wordlist you've downloaded.</li>
<li>Fix password dialog crashes</li> <li>Added "Pick tiles face up" option, settable when you create a
game. This is primarily useful if you want to populate a
board to match a game that already exists, say in a newspaper
puzzle or online wordgame.</li>
<li>Show wordlist along with player name in Game Config screen, and <!--
move below Language since it changes when language changes.</li> TODO: test various bogus dicts in downloads/
test that opera-downloaded dicts openable/moveable
-->
</ul> </ul>

View file

@ -3,7 +3,7 @@
<!-- Resources in this file do not require localization --> <!-- Resources in this file do not require localization -->
<resources> <resources>
<string name="app_version">4.4 beta 37</string> <string name="app_version">4.4 beta 38</string>
<!-- prefs keys --> <!-- prefs keys -->
<string name="key_color_tiles">key_color_tiles</string> <string name="key_color_tiles">key_color_tiles</string>
@ -75,6 +75,7 @@
<string name="key_notagain_newfrom">key_notagain_newfrom</string> <string name="key_notagain_newfrom">key_notagain_newfrom</string>
<string name="key_notagain_trading">key_notagain_trading</string> <string name="key_notagain_trading">key_notagain_trading</string>
<string name="key_na_lookup">key_na_lookup</string> <string name="key_na_lookup">key_na_lookup</string>
<string name="key_na_browse">key_na_browse</string>
<!-- Name is not localized --> <!-- Name is not localized -->
<string name="app_name">Crosswords</string> <string name="app_name">Crosswords</string>

View file

@ -1787,6 +1787,7 @@
<string name="dict_browse_titlef">%1$s (%2$d words)</string> <string name="dict_browse_titlef">%1$s (%2$d words)</string>
<string name="dict_browse_nowordsf">No word in %1$s starts with <string name="dict_browse_nowordsf">No word in %1$s starts with
%2$s.</string> %2$s.</string>
<string name="not_again_browse">This button opens the wordlist
browser on the current player\'s wordlist.</string>
</resources> </resources>

View file

@ -92,6 +92,7 @@ public class BoardActivity extends XWActivity
private static final int CHAT_ACTION = 12; private static final int CHAT_ACTION = 12;
private static final int START_TRADE_ACTION = 13; private static final int START_TRADE_ACTION = 13;
private static final int LOOKUP_ACTION = 14; private static final int LOOKUP_ACTION = 14;
private static final int BUTTON_BROWSE_ACTION = 15;
private static final String DLG_TITLE = "DLG_TITLE"; private static final String DLG_TITLE = "DLG_TITLE";
private static final String DLG_TITLESTR = "DLG_TITLESTR"; private static final String DLG_TITLESTR = "DLG_TITLESTR";
@ -620,6 +621,7 @@ public class BoardActivity extends XWActivity
m_jniThread.handle( JNIThread.JNICmd.CMD_REMAINING, m_jniThread.handle( JNIThread.JNICmd.CMD_REMAINING,
R.string.tiles_left_title ); R.string.tiles_left_title );
break; break;
case R.id.board_menu_game_history: case R.id.board_menu_game_history:
m_jniThread.handle( JNIThread.JNICmd.CMD_HISTORY, m_jniThread.handle( JNIThread.JNICmd.CMD_HISTORY,
R.string.history_title ); R.string.history_title );
@ -691,6 +693,10 @@ public class BoardActivity extends XWActivity
Toast.LENGTH_SHORT).show(); Toast.LENGTH_SHORT).show();
m_toastStr = null; m_toastStr = null;
break; break;
case BUTTON_BROWSE_ACTION:
String dictName = m_gi.dictName( m_view.getCurPlayer() );
DictBrowseActivity.launch( this, dictName );
break;
case PREV_HINT_ACTION: case PREV_HINT_ACTION:
cmd = JNIThread.JNICmd.CMD_PREV_HINT; cmd = JNIThread.JNICmd.CMD_PREV_HINT;
break; break;
@ -1410,6 +1416,10 @@ public class BoardActivity extends XWActivity
private void populateToolbar() private void populateToolbar()
{ {
m_toolbar.setListener( Toolbar.BUTTON_BROWSE_DICT,
R.string.not_again_browse,
R.string.key_na_browse,
BUTTON_BROWSE_ACTION );
m_toolbar.setListener( Toolbar.BUTTON_HINT_PREV, m_toolbar.setListener( Toolbar.BUTTON_HINT_PREV,
R.string.not_again_hintprev, R.string.not_again_hintprev,
R.string.key_notagain_hintprev, R.string.key_notagain_hintprev,

View file

@ -338,6 +338,11 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
m_jniThread.handle( JNIThread.JNICmd.CMD_INVALALL ); m_jniThread.handle( JNIThread.JNICmd.CMD_INVALALL );
} }
public int getCurPlayer()
{
return m_trayOwner;
}
public int curPending() public int curPending()
{ {
return m_pendingScore; return m_pendingScore;

View file

@ -20,6 +20,7 @@
package org.eehouse.android.xw4; package org.eehouse.android.xw4;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.database.DataSetObserver; import android.database.DataSetObserver;
import android.os.Bundle; import android.os.Bundle;
@ -48,6 +49,7 @@ public class DictBrowseActivity extends XWListActivity
private int m_lang; private int m_lang;
private String m_name; private String m_name;
private int m_nWords; private int m_nWords;
private float m_textSize;
// - Steps to reproduce the problem: // - Steps to reproduce the problem:
// Create ListView, set custom adapter which implements ListAdapter and // Create ListView, set custom adapter which implements ListAdapter and
@ -68,7 +70,7 @@ public class DictBrowseActivity extends XWListActivity
if ( null != str ) { if ( null != str ) {
text.setText( str ); text.setText( str );
text.setOnClickListener( DictBrowseActivity.this ); text.setOnClickListener( DictBrowseActivity.this );
text.setTextSize( text.getTextSize() + 2.0f ); text.setTextSize( m_textSize );
} }
return text; return text;
} }
@ -123,6 +125,8 @@ public class DictBrowseActivity extends XWListActivity
m_name = name; m_name = name;
m_lang = DictLangCache.getDictLangCode( this, name ); m_lang = DictLangCache.getDictLangCode( this, name );
m_textSize = 2.0f + new TextView( this ).getTextSize();
String[] names = { name }; String[] names = { name };
DictUtils.DictPairs pairs = DictUtils.openDicts( this, names ); DictUtils.DictPairs pairs = DictUtils.openDicts( this, names );
m_dictClosure = XwJNI.dict_iter_init( pairs.m_bytes[0], m_dictClosure = XwJNI.dict_iter_init( pairs.m_bytes[0],
@ -197,4 +201,11 @@ public class DictBrowseActivity extends XWListActivity
} }
} }
} }
public static void launch( Context caller, String name )
{
Intent intent = new Intent( caller, DictBrowseActivity.class );
intent.putExtra( DICT_NAME, name );
caller.startActivity( intent );
}
} }

View file

@ -462,9 +462,7 @@ public class DictsActivity extends ExpandableListActivity
askStartDownload( 0, null ); askStartDownload( 0, null );
} else { } else {
XWListItem item = (XWListItem)view; XWListItem item = (XWListItem)view;
Intent intent = new Intent( this, DictBrowseActivity.class ); DictBrowseActivity.launch( this, item.getText() );
intent.putExtra( DictBrowseActivity.DICT_NAME, item.getText() );
startActivity( intent );
} }
} }

View file

@ -39,15 +39,18 @@ public class Toolbar {
public int m_id; public int m_id;
} }
public static final int BUTTON_HINT_PREV = 0; public static final int BUTTON_BROWSE_DICT = 0;
public static final int BUTTON_HINT_NEXT = 1; public static final int BUTTON_HINT_PREV = 1;
public static final int BUTTON_FLIP = 2; public static final int BUTTON_HINT_NEXT = 2;
public static final int BUTTON_JUGGLE = 3; public static final int BUTTON_FLIP = 3;
public static final int BUTTON_ZOOM = 4; public static final int BUTTON_JUGGLE = 4;
public static final int BUTTON_UNDO = 5; public static final int BUTTON_ZOOM = 5;
public static final int BUTTON_CHAT = 6; public static final int BUTTON_UNDO = 6;
public static final int BUTTON_CHAT = 7;
private static TBButtonInfo[] s_buttonInfo = { private static TBButtonInfo[] s_buttonInfo = {
// BUTTON_BROWSE_DICT
new TBButtonInfo(R.id.dictlist_button_horizontal ),
// BUTTON_HINT_PREV // BUTTON_HINT_PREV
new TBButtonInfo(R.id.prevhint_button_horizontal ), new TBButtonInfo(R.id.prevhint_button_horizontal ),
// BUTTON_HINT_NEXT // BUTTON_HINT_NEXT

View file

@ -951,26 +951,6 @@ walk_dict_test( const LaunchParams* params, const DictionaryCtxt* dict,
long jj; long jj;
XP_Bool gotOne; XP_Bool gotOne;
/* XP_U32 count = dict_getWordCount( dict ); */
/* XP_ASSERT( count > 0 ); */
/* char** words = g_malloc( count * sizeof(char*) ); */
/* XP_ASSERT( !!words ); */
/* // # define PRINT_ALL */
/* /\* if ( dict_firstWord( dict, &word ) *\/ */
/* /\* && dict_getNextWord( dict, &word ) *\/ */
/* /\* && dict_getPrevWord( dict, &word ) ) { *\/ */
/* /\* fprintf( stderr, "yay!: dict_getPrevWord returned\n" ); *\/ */
/* /\* } *\/ */
/* /\* exit( 0 ); *\/ */
/* dict_initIter( dict, &iter ); */
/* for ( jj = 0, gotOne = dict_firstWord( &iter ); */
/* gotOne; */
/* ++jj, gotOne = dict_getNextWord( &iter ) ) { */
/* XP_ASSERT( dict_getPosition( &iter ) == jj ); */
/* XP_UCHAR buf[64]; */
/* dict_wordToString( &iter, buf, VSIZE(buf) ); */
XP_U16 min, max; XP_U16 min, max;
if ( !testMinMax || !parsePair( testMinMax, &min, &max ) ) { if ( !testMinMax || !parsePair( testMinMax, &min, &max ) ) {
min = 0; min = 0;