Merge branch 'fix_beta_53' into android_branch

This commit is contained in:
Eric House 2012-11-05 05:43:33 -08:00
commit 0376e25c26
14 changed files with 103 additions and 61 deletions

View file

@ -22,7 +22,7 @@
to come from a domain that you own or have control over. -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.eehouse.android.xw4"
android:versionCode="45"
android:versionCode="46"
android:versionName="@string/app_version"
>

View file

@ -5,36 +5,17 @@
</style>
</head>
<body>
<b>Crosswords 4.4 beta 53 release</b>
<b>Crosswords 4.4 beta 54 release</b>
<ul>
<li>Add a second way devices can play: via SMS. If you and your
friends have unlimited texting plans (ONLY IF!!) this is the way to
go: connecting is easier, moves get transmitted more quickly, and
less battery is required. <a
href="http://xwords.sf.net/and_faq.php">See the FAQ</a></li>
<li>In the main games-list screen, replace green highlighting of the
player whose turn it is with green transitioning to red over three
days. That way you can see how long it's been that person's turn.
Nothing happens -- yet -- when the three days is up. Maybe later
that'll force a resignation.</li>
<li>Download wordlists without using the browser when possible</li>
<li>Warn when you join a network game with a different wordlist from
the host's, and give a chance to download and switch.</li>
<li>Don't allow networked games to have different wordlist for each
player. That feature is for local games only now.</li>
<li>There's now a preference for where downloaded wordlists are
stored instead of a question asked each time.</li>
<li>Recast game-over feature as "resigning".</li>
<li>Don't try to access directory OS says is for downloads when it
doesn't actually exist</li>
</ul>
<p>(The full changelog
is <a href="http://xwords.sf.net/and_changes.php">here</a>.)</p>
<p>Please remember that this is beta software. Please let me know (at
eehouse@eehouse.org) what's broken and what features you'd most like
to see.</p>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_version">4.4 beta 53</string>
<string name="app_version">4.4 beta 54</string>
</resources>

View file

@ -92,6 +92,7 @@
<string name="key_na_browse">key_na_browse</string>
<string name="key_na_values">key_na_values</string>
<string name="key_enable_debug">key_enable_debug</string>
<string name="key_download_path">key_download_path</string>
<!-- Nor is my email address -->
<string name="email_author_email">xwords@eehouse.org</string>

View file

@ -2123,5 +2123,5 @@
<string name="default_loc">Store wordlists internally</string>
<string name="default_loc_summary">(Not in external/sdcard memory)</string>
<string name="sms_searching_toast">Searching SMS messages...</string>
<string name="download_path_title">Downloads Directory</string>
</resources>

View file

@ -299,6 +299,10 @@
android:summary="Menuitems etc."
android:defaultValue="false"
/>
<org.eehouse.android.xw4.XWEditTextPreference
android:key="@string/key_download_path"
android:title="@string/download_path_title"
/>
<CheckBoxPreference android:key="@string/key_show_sms"
android:title="Show SMS sends, receives"
android:defaultValue="false"

View file

@ -33,6 +33,7 @@ import java.util.Comparator;
import junit.framework.Assert;
import org.eehouse.android.xw4.DictUtils.DictAndLoc;
import org.eehouse.android.xw4.DictUtils.DictLoc;
import org.eehouse.android.xw4.jni.JNIUtilsImpl;
import org.eehouse.android.xw4.jni.XwJNI;
import org.eehouse.android.xw4.jni.DictInfo;
@ -244,7 +245,7 @@ public class DictLangCache {
// May be called from background thread
public static void inval( final Context context, String name,
DictUtils.DictLoc loc, boolean added )
DictLoc loc, boolean added )
{
DictAndLoc dal = new DictAndLoc( name, loc );
DBUtils.dictsRemoveInfo( context, dal );
@ -372,7 +373,7 @@ public class DictLangCache {
{
DictInfo result = DBUtils.dictsGetInfo( context, name );
if ( null == result ) {
DictUtils.DictLoc loc = DictUtils.getDictLoc( context, name );
DictLoc loc = DictUtils.getDictLoc( context, name );
result = getInfo( context, new DictAndLoc( name, loc ) );
}
return result;
@ -397,7 +398,7 @@ public class DictLangCache {
if ( XwJNI.dict_getInfo( pairs.m_bytes[0], dal.name,
pairs.m_paths[0],
JNIUtilsImpl.get( context ),
DictUtils.DictLoc.DOWNLOAD == dal.loc,
DictLoc.DOWNLOAD == dal.loc,
info ) ) {
info.name = dal.name;

View file

@ -149,7 +149,8 @@ public class DictUtils {
}
tryDir( context, getSDDir( context ), false, DictLoc.EXTERNAL, al );
tryDir( context, getDownloadDir(), true, DictLoc.DOWNLOAD, al );
tryDir( context, getDownloadDir( context ), true,
DictLoc.DOWNLOAD, al );
s_dictListCache =
al.toArray( new DictUtils.DictAndLoc[al.size()] );
@ -248,7 +249,7 @@ public class DictUtils {
File path = null;
switch( loc ) {
case DOWNLOAD:
path = getDownloadsPathFor( name );
path = getDownloadsPathFor( context, name );
break;
case EXTERNAL:
path = getSDPathFor( context, name );
@ -305,7 +306,7 @@ public class DictUtils {
FileInputStream fis = null;
if ( null == fis ) {
if ( loc == DictLoc.UNKNOWN || loc == DictLoc.DOWNLOAD ) {
File path = getDownloadsPathFor( name );
File path = getDownloadsPathFor( context, name );
if ( null != path && path.exists() ) {
DbgUtils.logf( "loading %s from Download", name );
fis = new FileInputStream( path );
@ -365,7 +366,7 @@ public class DictUtils {
File path;
switch ( to ) {
case DOWNLOAD:
path = getDownloadsPathFor( name );
path = getDownloadsPathFor( context, name );
break;
case EXTERNAL:
path = getSDPathFor( context, name );
@ -560,25 +561,36 @@ public class DictUtils {
return result;
}
private static File getDownloadDir()
public static boolean haveDownloadDir( Context context )
{
return null != getDownloadDir( context );
}
private static File getDownloadDir( Context context )
{
File result = null;
if ( haveWriteableSD() ) {
File storage = Environment.getExternalStorageDirectory();
if ( null != storage ) {
result = new File( storage.getPath(), "download/" );
if ( !result.exists() ) {
result = null;
File file = null;
String myPath = XWPrefs.getMyDownloadDir( context );
if ( null != myPath && 0 < myPath.length() ) {
file = new File( myPath );
} else {
file = Environment.getExternalStorageDirectory();
if ( null != file ) {
file = new File( file, "download/" );
}
}
if ( null != file && file.exists() && file.isDirectory() ) {
result = file;
}
}
return result;
}
private static File getDownloadsPathFor( String name )
private static File getDownloadsPathFor( Context context, String name )
{
File result = null;
File dir = getDownloadDir();
File dir = getDownloadDir( context );
if ( dir != null ) {
result = new File( dir, name );
}

View file

@ -263,15 +263,6 @@ public class DictsActivity extends ExpandableListActivity
message = Utils.format( this, R.string.move_dictf,
m_adapter.getSelChildView().getText() );
String[] items = new String[3];
for ( int ii = 0; ii < 3; ++ii ) {
DictLoc loc = itemToRealLoc(ii);
if ( loc.equals( m_moveFromLoc ) ) {
m_moveFromItem = ii;
}
items[ii] = m_locNames[loc.ordinal()];
}
OnClickListener newSelLstnr =
new OnClickListener() {
public void onClick( DialogInterface dlgi, int item ) {
@ -307,7 +298,8 @@ public class DictsActivity extends ExpandableListActivity
dialog = new AlertDialog.Builder( this )
.setTitle( message )
.setSingleChoiceItems( items, m_moveFromItem, newSelLstnr )
.setSingleChoiceItems( makeDictDirItems(), m_moveFromItem,
newSelLstnr )
.setPositiveButton( R.string.button_move, lstnr )
.setNegativeButton( R.string.button_cancel, null )
.create();
@ -716,6 +708,26 @@ public class DictsActivity extends ExpandableListActivity
XWPrefs.setClosedLangs( this, asArray );
}
private String[] makeDictDirItems()
{
boolean showDownload = DictUtils.haveDownloadDir( this );
int nItems = showDownload ? 3 : 2;
int nextI = 0;
String[] items = new String[nItems];
for ( int ii = 0; ii < 3; ++ii ) {
DictLoc loc = itemToRealLoc(ii);
if ( !showDownload && DictLoc.DOWNLOAD == loc ) {
continue;
}
if ( loc.equals( m_moveFromLoc ) ) {
m_moveFromItem = nextI;
}
items[nextI++] = m_locNames[loc.ordinal()];
}
return items;
}
private static Intent mkDownloadIntent( Context context, String dict_url )
{
Uri uri = Uri.parse( dict_url );

View file

@ -208,13 +208,21 @@ public class DlgDelegate {
public void showConfirmThen( String msg, int posButton, int callbackID )
{
// FIX ME!! Need to store data per message rather than have
// assertions failing or messages dropped.
if ( 0 != m_cbckID ) {
DbgUtils.logf( "showConfirmThen: busy with another message; "
+ "dropping \"%s\" in favor of \"%s\"",
msg, m_msg );
} else {
m_msg = msg;
m_posButton = posButton;
Assert.assertTrue( 0 != callbackID );
Assert.assertTrue( 0 == m_cbckID );
m_cbckID = callbackID;
m_activity.showDialog( CONFIRM_THEN );
}
}
public void showEmailOrSMSThen( final int callbackID )
{

View file

@ -730,7 +730,6 @@ public class GameUtils {
}
lock.unlock();
}
DbgUtils.logf( "feedMessages=>%b", draw );
return draw;
} // feedMessages

View file

@ -29,6 +29,7 @@ import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.View;
import android.widget.Button;
import java.io.File;
public class PrefsActivity extends PreferenceActivity
implements SharedPreferences.OnSharedPreferenceChangeListener {
@ -40,6 +41,7 @@ public class PrefsActivity extends PreferenceActivity
private String m_keyLogging;
private String m_smsToasting;
private String m_smsEnable;
private String m_downloadPath;
@Override
protected Dialog onCreateDialog( int id )
@ -120,6 +122,7 @@ public class PrefsActivity extends PreferenceActivity
m_keyLogging = getString( R.string.key_logging_on );
m_smsToasting = getString( R.string.key_show_sms );
m_smsEnable = getString( R.string.key_enable_sms );
m_downloadPath = getString( R.string.key_download_path );
Button button = (Button)findViewById( R.id.revert_colors );
button.setOnClickListener( new View.OnClickListener() {
@ -164,6 +167,23 @@ public class PrefsActivity extends PreferenceActivity
} else {
XWPrefs.setHaveCheckedSMS( this, false );
}
} else if ( key.equals( m_downloadPath ) ) {
String value = sp.getString( key, null );
if ( null != value ) {
File dir = new File( value );
String msg = null;
if ( !dir.exists() ) {
msg = String.format( "%s does not exist", value );
} else if ( !dir.isDirectory() ) {
msg = String.format( "%s is not a directory", value );
} else if ( !dir.canWrite() ) {
msg = String.format( "Cannot write to %s", value );
}
if ( null != msg ) {
Utils.showToast( this, msg );
}
}
DictUtils.invalDictList();
}
}

View file

@ -232,7 +232,6 @@ public class SMSService extends Service {
switch( cmd ) {
case CHECK_MSGDB:
if ( ! XWPrefs.getHaveCheckedSMS( this ) ) {
Utils.showToast( this, R.string.sms_searching_toast );
XWPrefs.setHaveCheckedSMS( this, true );
new Thread( new Runnable() {
public void run() {

View file

@ -207,6 +207,11 @@ public class XWPrefs {
return result;
}
public static String getMyDownloadDir( Context context )
{
return getPrefsString( context, R.string.key_download_path );
}
protected static String getPrefsString( Context context, int keyID )
{
String key = context.getString( keyID );