Merge remote branch 'origin/android_localize' into android_localize

This commit is contained in:
Eric House 2014-06-07 17:51:07 -07:00
commit f790b9dfda
22 changed files with 380 additions and 322 deletions

View file

@ -168,7 +168,7 @@
</activity>
<!-- downloading dicts -->
<activity android:name=".DictImportActivity"
<activity android:name=".DwnldActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.Dialog">
<intent-filter>

View file

@ -309,23 +309,24 @@ public final class R {
public static final int game_list_group=0x7f030011;
public static final int game_list_item=0x7f030012;
public static final int import_dict=0x7f030013;
public static final int list_group=0x7f030014;
public static final int list_item=0x7f030015;
public static final int loc_item_edit=0x7f030016;
public static final int loc_list_item=0x7f030017;
public static final int loc_main=0x7f030018;
public static final int lookup=0x7f030019;
public static final int new_game=0x7f03001a;
public static final int passwd_view=0x7f03001b;
public static final int player_edit=0x7f03001c;
public static final int player_list_elem=0x7f03001d;
public static final int prefs_w_buttons=0x7f03001e;
public static final int relay_game_config=0x7f03001f;
public static final int remote_dicts=0x7f030020;
public static final int rename_game=0x7f030021;
public static final int smsinviter=0x7f030022;
public static final int smsinviter_item=0x7f030023;
public static final int studylist=0x7f030024;
public static final int import_dict_item=0x7f030014;
public static final int list_group=0x7f030015;
public static final int list_item=0x7f030016;
public static final int loc_item_edit=0x7f030017;
public static final int loc_list_item=0x7f030018;
public static final int loc_main=0x7f030019;
public static final int lookup=0x7f03001a;
public static final int new_game=0x7f03001b;
public static final int passwd_view=0x7f03001c;
public static final int player_edit=0x7f03001d;
public static final int player_list_elem=0x7f03001e;
public static final int prefs_w_buttons=0x7f03001f;
public static final int relay_game_config=0x7f030020;
public static final int remote_dicts=0x7f030021;
public static final int rename_game=0x7f030022;
public static final int smsinviter=0x7f030023;
public static final int smsinviter_item=0x7f030024;
public static final int studylist=0x7f030025;
}
public static final class menu {
public static final int board_menu=0x7f090000;

View file

@ -2,23 +2,16 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="10sp"
>
<TextView android:id="@+id/dwnld_message"
<ListView android:id="@id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal"
android:layout_height="fill_parent"
android:layout_weight="1"
android:drawSelectorOnTop="false"
/>
<ProgressBar android:id="@+id/progress_bar"
style="@android:style/Widget.ProgressBar.Horizontal"
android:indeterminate="false"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_margin="5sp"
/>
</LinearLayout>

View file

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="10sp"
android:layout_weight="1"
>
<TextView android:id="@+id/dwnld_message"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<ProgressBar android:id="@+id/progress_bar"
style="@android:style/Widget.ProgressBar.Horizontal"
android:indeterminate="false"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5sp"
/>
</LinearLayout>

View file

@ -18,6 +18,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/remote_empty"
android:gravity="center_vertical|center_horizontal"
/>
</LinearLayout>

View file

@ -42,13 +42,6 @@ public class BoardActivity extends XWActivity {
}
} // onCreate
@Override
protected void onSaveInstanceState( Bundle outState )
{
super.onSaveInstanceState( outState );
m_dlgt.onSaveInstanceState( outState );
}
@Override
protected void onActivityResult( int requestCode, int resultCode, Intent data )
{

View file

@ -64,7 +64,7 @@ import org.eehouse.android.xw4.jni.JNIThread.*;
public class BoardDelegate extends DelegateBase
implements TransportProcs.TPMsgHandler, View.OnClickListener,
DictImportDelegate.DownloadFinishedListener,
DwnldDelegate.DownloadFinishedListener,
ConnStatusHandler.ConnStatusCBacks,
NFCUtils.NFCActor {
@ -288,7 +288,7 @@ public class BoardDelegate extends DelegateBase
if ( DlgID.DLG_USEDICT == dlgID ) {
setGotGameDict( m_getDict );
} else {
DictImportDelegate
DwnldDelegate
.downloadDictInBack( m_activity,
m_gi.dictLang,
m_getDict,
@ -481,10 +481,9 @@ public class BoardDelegate extends DelegateBase
return dialog;
} // onCreateDialog
protected void prepareDialog( int id, Dialog dialog )
@Override
protected void prepareDialog( DlgID dlgID, Dialog dialog )
{
DbgUtils.logf( "BoardActivity:onPrepareDialog(id=%d)", id );
DlgID dlgID = DlgID.values()[id];
switch( dlgID ) {
case DLG_INVITE:
AlertDialog ad = (AlertDialog)dialog;
@ -1137,7 +1136,7 @@ public class BoardDelegate extends DelegateBase
}
//////////////////////////////////////////////////
// DictImportActivity.DownloadFinishedListener interface
// DwnldActivity.DownloadFinishedListener interface
//////////////////////////////////////////////////
public void downloadFinished( final String name, final boolean success )
{

View file

@ -58,6 +58,7 @@ public class DelegateBase implements DlgDelegate.DlgClickNotify,
// Does nothing unless overridden. These belong in an interface.
protected void init( Bundle savedInstanceState ) { Assert.fail(); }
protected void onSaveInstanceState( Bundle outState ) {}
public boolean onPrepareOptionsMenu( Menu menu ) { return false; }
public boolean onOptionsItemSelected( MenuItem item ) { return false; }
protected void onStart() {}
@ -66,7 +67,7 @@ public class DelegateBase implements DlgDelegate.DlgClickNotify,
protected void onStop() {}
protected void onDestroy() {}
protected boolean onBackPressed() { return false; }
protected void prepareDialog( int id, Dialog dialog ) {}
protected void prepareDialog( DlgID dlgID, Dialog dialog ) {}
// public boolean onOptionsItemSelected( MenuItem item )
// {

View file

@ -42,9 +42,9 @@ import org.eehouse.android.xw4.jni.CommonPrefs;
public class DictLangCache {
private static String[] s_langNames;
private static int m_adaptedLang = -1;
private static ArrayAdapter<String> m_langsAdapter;
private static ArrayAdapter<String> m_dictsAdapter;
private static int s_adaptedLang = -1;
private static ArrayAdapter<String> s_langsAdapter;
private static ArrayAdapter<String> s_dictsAdapter;
private static String s_last;
private static Handler s_handler;
private static Comparator<String> KeepLast =
@ -257,14 +257,14 @@ public class DictLangCache {
if ( null != s_handler ) {
s_handler.post( new Runnable() {
public void run() {
if ( null != m_dictsAdapter ) {
rebuildAdapter( m_dictsAdapter,
if ( null != s_dictsAdapter ) {
rebuildAdapter( s_dictsAdapter,
DictLangCache.
getHaveLang( context,
m_adaptedLang ) );
s_adaptedLang ) );
}
if ( null != m_langsAdapter ) {
rebuildAdapter( m_langsAdapter,
if ( null != s_langsAdapter ) {
rebuildAdapter( s_langsAdapter,
DictLangCache.listLangs( context ) );
}
}
@ -326,26 +326,26 @@ public class DictLangCache {
public static ArrayAdapter<String> getLangsAdapter( Context context )
{
if ( null == m_langsAdapter ) {
m_langsAdapter =
if ( null == s_langsAdapter ) {
s_langsAdapter =
new ArrayAdapter<String>( context,
android.R.layout.simple_spinner_item );
rebuildAdapter( m_langsAdapter, listLangs( context ) );
rebuildAdapter( s_langsAdapter, listLangs( context ) );
}
return m_langsAdapter;
return s_langsAdapter;
}
public static ArrayAdapter<String> getDictsAdapter( Context context,
int lang )
{
if ( lang != m_adaptedLang ) {
m_dictsAdapter =
if ( lang != s_adaptedLang ) {
s_dictsAdapter =
new ArrayAdapter<String>( context,
android.R.layout.simple_spinner_item );
rebuildAdapter( m_dictsAdapter, getHaveLang( context, lang ) );
m_adaptedLang = lang;
rebuildAdapter( s_dictsAdapter, getHaveLang( context, lang ) );
s_adaptedLang = lang;
}
return m_dictsAdapter;
return s_dictsAdapter;
}
public static String[] getLangNames( Context context )

View file

@ -65,7 +65,7 @@ public class DictsDelegate extends ListDelegateBase
implements View.OnClickListener, AdapterView.OnItemLongClickListener,
SelectableItem, MountEventReceiver.SDCardNotifiee,
DlgDelegate.DlgClickNotify, GroupStateListener,
DictImportDelegate.DownloadFinishedListener {
DwnldDelegate.DownloadFinishedListener {
protected static final String DICT_DOLAUNCH = "do_launch";
protected static final String DICT_LANG_EXTRA = "use_lang";
@ -261,7 +261,7 @@ public class DictsDelegate extends ListDelegateBase
int lang = intent.getIntExtra( MultiService.LANG, -1 );
String name = intent.getStringExtra( MultiService.DICT );
m_launchedForMissing = true;
DictImportDelegate
DwnldDelegate
.downloadDictInBack( m_activity, lang,
name, DictsDelegate.this );
}
@ -289,9 +289,10 @@ public class DictsDelegate extends ListDelegateBase
return dialog;
} // onCreateDialog
protected void prepareDialog( int id, Dialog dialog )
@Override
protected void prepareDialog( DlgID dlgID, Dialog dialog )
{
if ( DlgID.MOVE_DICT.ordinal() == id ) {
if ( DlgID.MOVE_DICT == dlgID ) {
// The move button should always start out disabled
// because the selected location should be where it
// currently is.
@ -430,7 +431,7 @@ public class DictsDelegate extends ListDelegateBase
if ( 0 < loci ) {
String url =
intent.getStringExtra( UpdateCheckReceiver.NEW_DICT_URL );
DictImportDelegate.downloadDictInBack( m_activity, url );
DwnldDelegate.downloadDictInBack( m_activity, url, null );
finish();
}
}
@ -734,7 +735,7 @@ public class DictsDelegate extends ListDelegateBase
launchAndDownload( activity, 0, null );
}
// DictImportActivity.DownloadFinishedListener interface
// DwnldActivity.DownloadFinishedListener interface
public void downloadFinished( String name, final boolean success )
{
if ( m_launchedForMissing ) {

View file

@ -23,13 +23,13 @@ package org.eehouse.android.xw4;
import android.app.Activity;
import android.os.Bundle;
public class DictImportActivity extends XWActivity {
public class DwnldActivity extends XWListActivity {
@Override
protected void onCreate( Bundle savedInstanceState )
{
DictImportDelegate dlgt =
new DictImportDelegate( this, savedInstanceState );
DwnldDelegate dlgt =
new DwnldDelegate( this, savedInstanceState );
super.onCreate( savedInstanceState, dlgt );
}
}

View file

@ -21,13 +21,18 @@
package org.eehouse.android.xw4;
import android.app.Activity;
import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
@ -38,25 +43,26 @@ import java.io.InputStream;
import java.net.URI;
import java.net.URLConnection;
import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.HashMap;
import junit.framework.Assert;
public class DictImportDelegate extends DelegateBase {
public class DwnldDelegate extends ListDelegateBase {
// URIs coming in in intents
private static final String APK_EXTRA = "APK";
private static final String DICT_EXTRA = "XWD";
private static final String DICTS_EXTRA = "XWDS";
private Activity m_activity;
private ProgressBar m_progressBar;
private ListActivity m_activity;
private Handler m_handler;
private ArrayList<LinearLayout> m_views;
public interface DownloadFinishedListener {
void downloadFinished( String name, boolean success );
}
public DictImportDelegate( Activity activity, Bundle savedInstanceState )
public DwnldDelegate( ListActivity activity, Bundle savedInstanceState )
{
super( activity, savedInstanceState );
m_activity = activity;
@ -64,53 +70,53 @@ public class DictImportDelegate extends DelegateBase {
// Track callbacks for downloads.
private static class ListenerData {
public ListenerData( String dictName, DownloadFinishedListener lstnr )
public ListenerData( String name, DownloadFinishedListener lstnr )
{
m_dictName = dictName;
m_name = name;
m_lstnr = lstnr;
}
public String m_dictName;
public String m_name;
public DownloadFinishedListener m_lstnr;
}
private static HashMap<String,ListenerData> s_listeners =
new HashMap<String,ListenerData>();
private class DownloadFilesTask extends AsyncTask<Uri, Integer, Long>
private class DownloadFilesTask extends AsyncTask<Void, Void, Void>
implements DictUtils.DownProgListener {
private String m_savedDict = null;
private String m_url = null;
private Uri m_uri = null;
private boolean m_isApp = false;
private File m_appFile = null;
private int m_totalRead = 0;
private LinearLayout m_listItem;
private ProgressBar m_progressBar;
public DownloadFilesTask( boolean isApp )
public DownloadFilesTask( Uri uri, LinearLayout item, boolean isApp )
{
super();
m_uri = uri;
m_isApp = isApp;
m_listItem = item;
m_progressBar = (ProgressBar)
item.findViewById( R.id.progress_bar );
}
public DownloadFilesTask( String url, boolean isApp )
public void setLabel( String text )
{
this( isApp );
m_url = url;
TextView tv = (TextView)m_listItem.findViewById( R.id.dwnld_message );
tv.setText( text );
}
@Override
protected Long doInBackground( Uri... uris )
protected Void doInBackground( Void... unused )
{
m_savedDict = null;
m_appFile = null;
int count = uris.length;
Assert.assertTrue( 1 == count );
for ( int ii = 0; ii < count; ii++ ) {
Uri uri = uris[ii];
DbgUtils.logf( "trying %s", uri );
try {
URI jUri = new URI( uri.getScheme(),
uri.getSchemeSpecificPart(),
uri.getFragment() );
URI jUri = new URI( m_uri.getScheme(),
m_uri.getSchemeSpecificPart(),
m_uri.getFragment() );
URLConnection conn = jUri.toURL().openConnection();
final int fileLen = conn.getContentLength();
m_handler.post( new Runnable() {
@ -119,7 +125,7 @@ public class DictImportDelegate extends DelegateBase {
}
});
InputStream is = conn.getInputStream();
String name = basename( uri.getPath() );
String name = basename( m_uri.getPath() );
if ( m_isApp ) {
m_appFile = saveToDownloads( is, name, this );
} else {
@ -133,29 +139,33 @@ public class DictImportDelegate extends DelegateBase {
} catch ( java.io.IOException ioe ) {
DbgUtils.loge( ioe );
}
}
return new Long(0);
return null;
}
@Override
protected void onPostExecute( Long result )
protected void onPostExecute( Void unused )
{
DbgUtils.logf( "onPostExecute passed %d", result );
if ( null != m_savedDict ) {
DictUtils.DictLoc loc =
XWPrefs.getDefaultLoc( m_activity );
DictLangCache.inval( m_activity, m_savedDict,
loc, true );
callListener( m_url, true );
callListener( m_uri, true );
} else if ( null != m_appFile ) {
// launch the installer
Intent intent = Utils.makeInstallIntent( m_appFile );
startActivity( intent );
} else {
// we failed at something....
callListener( m_url, false );
callListener( m_uri, false );
}
if ( 1 >= m_views.size() ) {
finish();
} else {
m_views.remove( m_listItem );
mkListAdapter();
}
}
// interface DictUtils.DownProgListener
@ -170,10 +180,20 @@ public class DictImportDelegate extends DelegateBase {
}
} // class DownloadFilesTask
private class ImportListAdapter extends XWListAdapter {
public ImportListAdapter() { super( m_views.size() ); }
public View getView( int position, View convertView, ViewGroup parent )
{
return m_views.get( position );
}
}
protected void init( Bundle savedInstanceState )
{
DownloadFilesTask[] dfts = null;
DownloadFilesTask dft = null;
String[] urls = null;
LinearLayout item = null;
m_handler = new Handler();
requestWindowFeature( Window.FEATURE_LEFT_ICON );
@ -181,40 +201,62 @@ public class DictImportDelegate extends DelegateBase {
m_activity.getWindow().setFeatureDrawableResource( Window.FEATURE_LEFT_ICON,
R.drawable.icon48x48 );
m_progressBar = (ProgressBar)findViewById( R.id.progress_bar );
Intent intent = getIntent();
Uri uri = intent.getData();
Uri uri = intent.getData(); // launched from Manifest case
if ( null == uri ) {
String url = intent.getStringExtra( APK_EXTRA );
boolean isApp = null != url;
if ( !isApp ) {
url = intent.getStringExtra( DICT_EXTRA );
String appUrl = intent.getStringExtra( APK_EXTRA );
boolean isApp = null != appUrl;
if ( isApp ) {
urls = new String[] { appUrl };
} else {
urls = intent.getStringArrayExtra( DICTS_EXTRA );
}
if ( null != url ) {
dft = new DownloadFilesTask( url, isApp );
uri = Uri.parse( url );
if ( null != urls ) {
dfts = new DownloadFilesTask[urls.length];
m_views = new ArrayList<LinearLayout>();
for ( int ii = 0; ii < dfts.length; ++ii ) {
item = (LinearLayout)inflate( R.layout.import_dict_item );
dfts[ii] = new DownloadFilesTask( Uri.parse( urls[ii] ), item,
isApp );
m_views.add( item );
}
} else if ( null != intent.getType()
&& intent.getType().equals( "application/x-xwordsdict" ) ) {
dft = new DownloadFilesTask( false );
} else if ( uri.toString().endsWith( XWConstants.DICT_EXTN ) ) {
dft = new DownloadFilesTask( uri.toString(), false );
}
} else if ( (null != intent.getType()
&& intent.getType().equals( "application/x-xwordsdict" ))
|| uri.toString().endsWith( XWConstants.DICT_EXTN ) ) {
item = (LinearLayout)inflate( R.layout.import_dict_item );
dft = new DownloadFilesTask( uri, item, false );
}
if ( null == dft ) {
if ( null != dft ) {
Assert.assertNull( dfts );
dfts = new DownloadFilesTask[] { dft };
m_views = new ArrayList<LinearLayout>( 1 );
m_views.add( item );
dft = null;
}
if ( null == dfts ) {
finish();
} else {
String showName = basename( uri.getPath() );
showName = DictUtils.removeDictExtn( showName );
String msg = getString( R.string.downloading_dict_fmt, showName );
TextView view = (TextView)findViewById( R.id.dwnld_message );
view.setText( msg );
mkListAdapter();
dft.execute( uri );
for ( int ii = 0; ii < dfts.length; ++ii ) {
String showName = basename( Uri.parse( urls[ii] ).getPath() );
showName = DictUtils.removeDictExtn( showName );
String msg =
getString( R.string.downloading_dict_fmt, showName );
dfts[ii].setLabel( msg );
dfts[ii].execute();
}
}
} // init
private void mkListAdapter()
{
setListAdapter( new ImportListAdapter() );
}
private File saveToDownloads( InputStream is, String name,
DictUtils.DownProgListener dpl )
{
@ -268,9 +310,18 @@ public class DictImportDelegate extends DelegateBase {
}
}
private static void callListener( String url, boolean success )
private static void rememberListener( String url, DownloadFinishedListener lstnr )
{
if ( null != url ) {
ListenerData ld = new ListenerData( url, lstnr );
synchronized( s_listeners ) {
s_listeners.put( url, ld );
}
}
private static void callListener( Uri uri, boolean success )
{
if ( null != uri ) {
String url = uri.toString();
ListenerData ld;
synchronized( s_listeners ) {
ld = s_listeners.get( url );
@ -278,9 +329,11 @@ public class DictImportDelegate extends DelegateBase {
s_listeners.remove( url );
}
}
if ( null != ld ) {
ld.m_lstnr.downloadFinished( ld.m_dictName, success );
String name = ld.m_name;
if ( null == name ) {
name = uri.toString();
}
ld.m_lstnr.downloadFinished( name, success );
}
}
@ -289,26 +342,38 @@ public class DictImportDelegate extends DelegateBase {
DownloadFinishedListener lstnr )
{
String url = Utils.makeDictUrl( context, lang, name );
if ( null != lstnr ) {
rememberListener( url, name, lstnr );
}
downloadDictInBack( context, url );
// if ( null != lstnr ) {
// rememberListener( url, name, lstnr );
// }
downloadDictInBack( context, url, lstnr );
}
public static void downloadDictInBack( Context context, String url )
public static void downloadDictsInBack( Context context, String[] urls,
DownloadFinishedListener lstnr )
{
Intent intent = new Intent( context, DictImportActivity.class );
intent.putExtra( DICT_EXTRA, url );
if ( null != lstnr ) {
for ( String url : urls ) {
rememberListener( url, lstnr );
}
}
Intent intent = new Intent( context, DwnldActivity.class );
intent.putExtra( DICTS_EXTRA, urls );
context.startActivity( intent );
}
public static void downloadDictInBack( Context context, String url,
DownloadFinishedListener lstnr )
{
String[] urls = new String[] { url };
downloadDictsInBack( context, urls, lstnr );
}
public static Intent makeAppDownloadIntent( Context context, String url )
{
Intent intent = new Intent( context, DictImportActivity.class );
Intent intent = new Intent( context, DwnldActivity.class );
intent.putExtra( APK_EXTRA, url );
return intent;
}
}

View file

@ -35,13 +35,6 @@ public class GameConfigActivity extends XWActivity {
super.onCreate( savedInstanceState, m_dlgt );
} // onCreate
@Override
protected void onSaveInstanceState( Bundle outState )
{
super.onSaveInstanceState( outState );
m_dlgt.onSaveInstanceState( outState );
}
@Override
public boolean onKeyDown( int keyCode, KeyEvent event )
{

View file

@ -26,9 +26,6 @@ import android.os.Bundle;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
@ -41,16 +38,13 @@ import android.content.DialogInterface;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageButton;
import android.view.MenuInflater;
import android.view.KeyEvent;
import android.widget.Spinner;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ListAdapter;
import android.widget.SpinnerAdapter;
import android.widget.Toast;
import android.database.DataSetObserver;
import junit.framework.Assert;
import org.eehouse.android.xw4.DlgDelegate.Action;
@ -126,7 +120,7 @@ public class GameConfigDelegate extends DelegateBase
public GameConfigDelegate( Activity activity, Bundle savedInstanceState )
{
super( activity, savedInstanceState, R.menu.board_menu );
super( activity, savedInstanceState );
m_activity = activity;
}
@ -156,7 +150,9 @@ public class GameConfigDelegate extends DelegateBase
protected Dialog onCreateDialog( int id )
{
Dialog dialog = null;
Dialog dialog = super.onCreateDialog( id );
if ( null == dialog ) {
DialogInterface.OnClickListener dlpos;
AlertDialog.Builder ab;
@ -269,13 +265,13 @@ public class GameConfigDelegate extends DelegateBase
.create();
break;
}
}
return dialog;
} // onCreateDialog
protected void onPrepareDialog( int id, Dialog dialog )
@Override
protected void prepareDialog( DlgID dlgID, Dialog dialog )
{
DlgID dlgID = DlgID.values()[id];
switch ( dlgID ) {
case PLAYER_EDIT:
setPlayerSettings( dialog );
@ -373,7 +369,7 @@ public class GameConfigDelegate extends DelegateBase
int position = spinner.getSelectedItemPosition();
SpinnerAdapter adapter = spinner.getAdapter();
if ( position < adapter.getCount() ) {
if ( null != adapter && position < adapter.getCount() ) {
String name = (String)adapter.getItem( position );
if ( ! name.equals( m_browseText ) ) {
lp.dictName = name;

View file

@ -55,13 +55,6 @@ public class GamesListActivity extends XWListActivity {
m_dlgt.onNewIntent( intent );
}
@Override
protected void onSaveInstanceState( Bundle outState )
{
super.onSaveInstanceState( outState );
m_dlgt.onSaveInstanceState( outState );
}
@Override
public void onWindowFocusChanged( boolean hasFocus )
{

View file

@ -50,7 +50,7 @@ import org.eehouse.android.xw4.jni.*;
public class GamesListDelegate extends ListDelegateBase
implements OnItemLongClickListener,
DBUtils.DBChangeListener, SelectableItem,
DictImportDelegate.DownloadFinishedListener,
DwnldDelegate.DownloadFinishedListener,
DlgDelegate.HasDlgDelegate {
private static final String SAVE_ROWID = "SAVE_ROWID";
@ -135,7 +135,7 @@ public class GamesListDelegate extends ListDelegateBase
.launchAndDownload( m_activity,
m_missingDictLang );
} else {
DictImportDelegate
DwnldDelegate
.downloadDictInBack( m_activity,
m_missingDictLang,
m_missingDictName,
@ -323,9 +323,9 @@ public class GamesListDelegate extends ListDelegateBase
return dialog;
} // onCreateDialog
protected void prepareDialog( int id, Dialog dialog )
protected void prepareDialog( DlgID dlgID, Dialog dialog )
{
if ( DlgID.CHANGE_GROUP.ordinal() == id ) {
if ( DlgID.CHANGE_GROUP == dlgID ) {
((AlertDialog)dialog).getButton( AlertDialog.BUTTON_POSITIVE )
.setEnabled( false );
}
@ -879,7 +879,7 @@ public class GamesListDelegate extends ListDelegateBase
return handled;// || super.onOptionsItemSelected( item );
}
// DictImportActivity.DownloadFinishedListener interface
// DwnldActivity.DownloadFinishedListener interface
public void downloadFinished( String name, final boolean success )
{
post( new Runnable() {

View file

@ -35,13 +35,6 @@ public class NewGameActivity extends XWActivity {
super.onCreate( savedInstanceState, m_dlgt );
}
@Override
protected void onSaveInstanceState( Bundle outState )
{
super.onSaveInstanceState( outState );
m_dlgt.onSaveInstanceState( outState );
}
@Override
public void onWindowFocusChanged( boolean hasFocus )
{

View file

@ -44,7 +44,7 @@ import org.eehouse.android.xw4.jni.GameSummary;
public class RemoteDictsDelegate extends ListDelegateBase
implements GroupStateListener, SelectableItem,
DictImportDelegate.DownloadFinishedListener {
DwnldDelegate.DownloadFinishedListener {
private ListActivity m_activity;
private ListView m_listView;
private boolean[] m_expanded;
@ -90,14 +90,16 @@ public class RemoteDictsDelegate extends ListDelegateBase
clearSelection();
break;
case R.id.remote_dicts_download:
String[] urls = new String[m_selDicts.size()];
int count = 0;
for ( Iterator<XWListItem> iter = m_selDicts.iterator();
iter.hasNext(); ) {
XWListItem litm = iter.next();
String langName = (String)litm.getCached();
String url = Utils.makeDictUrl( m_activity, langName,
urls[count++] = Utils.makeDictUrl( m_activity, langName,
litm.getText() );
DictImportDelegate.downloadDictInBack( m_activity, url );
}
DwnldDelegate.downloadDictsInBack( m_activity, urls, this );
break;
default:
handled = false;
@ -334,7 +336,4 @@ public class RemoteDictsDelegate extends ListDelegateBase
return result;
}
}
// For debugging when network is down
// private static final String s_fakeData = "{\"langs\": [{\"lang\": \"Swedish\", \"dicts\": [{\"xwd\": \"Swedish_2to8.xwd\", \"md5sums\": [\"f3d235de4aa92a0c975361330c076ce6\", \"9e30bb5807204a61560fa9cae3bc4d37\"]}, {\"xwd\": \"Swedish_2to9.xwd\", \"md5sums\": [\"3e0f00e971d4a8dffb3476e512d37a98\", \"6b391ad2a06d94a757728cb187858e7b\"]}, {\"xwd\": \"Swedish_2to15.xwd\", \"md5sums\": [\"813eecdff13792007ee8b0c9c5e1f98b\", \"91a82698db86ff5a9892fe2021b4fd9f\"]}]}, {\"lang\": \"Portuguese\", \"dicts\": [{\"xwd\": \"PortuguesePT_2to8.xwd\", \"md5sums\": [\"0ac9278f5139a546c29b27ba4a0e21a5\", \"1ee181c1a6a4da71a08ebf1b7fb45520\"]}, {\"xwd\": \"PortugueseBR_2to8.xwd\", \"md5sums\": [\"a39ea7048ae74b75b6b20b2df580e864\", \"38db4fc25ef1613a79571c7c44c489e3\"]}, {\"xwd\": \"PortuguesePT_2to15.xwd\", \"md5sums\": [\"16495e0067d8a55652936ebda4982920\", \"f6d39b6f8d7737bfe57334b1f5d0e8f2\"]}, {\"xwd\": \"PortuguesePT_2to9.xwd\", \"md5sums\": [\"1470782527fe74608ad0fd6f5c15f74e\", \"abc7a0b722bb40a102bc1c5e15ada4e8\"]}, {\"xwd\": \"PortugueseBR_2to15.xwd\", \"md5sums\": [\"652105dd662d46b0d6c49b0f8cbb71f5\", \"e3335663d54a0461dccaf20df1e29515\"]}, {\"xwd\": \"PortugueseBR_2to9.xwd\", \"md5sums\": [\"bb32932c0a74fde156d839194eeb4834\", \"90e87b6577d70c90fe674032a2abf42d\"]}]}, {\"lang\": \"Danish\", \"dicts\": [{\"xwd\": \"Danish_2to8.xwd\", \"md5sums\": [\"ba41631091474d717faa4d47f25737f1\", \"a0aa9f4874e9e4d18b0bdf40cb3386af\"]}, {\"xwd\": \"Danish_2to15.xwd\", \"md5sums\": [\"565ed922d9a68760ae03d6ddd590e454\", \"613d6a9cae033487c7c946bbb88135d4\"]}, {\"xwd\": \"Danish_2to9.xwd\", \"md5sums\": [\"bb8150cadc8db778cef69e7593cfb513\", \"e25137525e2e437e0591df13c5d0440f\"]}]}, {\"lang\": \"Czech\", \"dicts\": [{\"xwd\": \"Czech_2to9.xwd\", \"md5sums\": [\"00794634cb13316e31412847cda3be99\", \"9de228bc6bc0d37f7fc341d0cd456668\"]}, {\"xwd\": \"Czech_2to15.xwd\", \"md5sums\": [\"bb5cc7654feadc39357bc9e6d21dc858\", \"193b9ca06feded3e6bf195cb5df12c69\"]}, {\"xwd\": \"Czech_2to8.xwd\", \"md5sums\": [\"823cdf4890c8a79ee36e622c1a76ba7b\", \"43567b60c9c5afb74c99fd0b367411e3\"]}]}, {\"lang\": \"Dutch\", \"dicts\": [{\"xwd\": \"Dutch_2to15.xwd\", \"md5sums\": [\"b8dcfab7b7a2b068803b400714217888\", \"ddca280eba4d734a8da852e1687291bf\"]}, {\"xwd\": \"Dutch_2to8.xwd\", \"md5sums\": [\"41a3e9f6bbf197c296e8f3ff98bfc101\", \"25ac0d3eca10bd714284f7a7784841eb\"]}, {\"xwd\": \"Dutch_2to9.xwd\", \"md5sums\": [\"74399839d815b0736e596b331090f2ac\", \"124e6070d6f58d4c38ee24f4a08408d1\"]}]}, {\"lang\": \"Hex\", \"dicts\": [{\"xwd\": \"Hex_2to8.xwd\", \"md5sums\": [\"eef9480c25aa4908e47d1e2bff090d67\", \"c8a007804476018ec78f77ea845cd4c9\"]}]}, {\"lang\": \"French\", \"dicts\": [{\"xwd\": \"ODS5_2to8.xwd\", \"md5sums\": [\"577c9d0c76d062829937cd51a1b0d333\", \"90a908584be4a40341ce0415d45ffea1\"]}, {\"xwd\": \"ODS5_2to15.xwd\", \"md5sums\": [\"aeaad6084faaba9635a70b0b87ba653f\", \"dcabd23fed80cee70b71c91a08fbab7a\"]}, {\"xwd\": \"ODS5_2to9.xwd\", \"md5sums\": [\"6ec776ff3f407db47cb319c98f8076c1\", \"818628c0607f78ac6aa95ea38fedb9f8\"]}]}, {\"lang\": \"German\", \"dicts\": [{\"xwd\": \"Deutsch_2to8.xwd\", \"md5sums\": [\"1102bff3b6d6bddee52b5f76ddcb898e\", \"2a9638946ff0008ff8309d391e817c2b\"]}, {\"xwd\": \"German_2to15.xwd\", \"md5sums\": [\"566563d5fcb1c8b1ebbb6f0c02336938\", \"41c9188c76e5c99751224d8ff704a4c7\"]}, {\"xwd\": \"Deutsch_2to15.xwd\", \"md5sums\": [\"60fca5f327a461e08e2ac33b7017f0c2\", \"71bbb856294742b58543d8b5ba8fee3f\"]}, {\"xwd\": \"Deutsch_2to9.xwd\", \"md5sums\": [\"6013767144d5d3450eb85e95a292f05e\", \"a659d44c20e80f9fa571e93cdad219b0\"]}, {\"xwd\": \"German_2to8.xwd\", \"md5sums\": [\"c188988fb4386edfd69c5e65624bbc38\", \"1a26bc3a505acb49e64eedcd38454af3\"]}, {\"xwd\": \"German_2to9.xwd\", \"md5sums\": [\"5ff32483a60ef0bb141ecd5fed078981\", \"1306f0c0f39094006532d609740f81d0\"]}]}]}";
}

View file

@ -35,13 +35,6 @@ public class SMSInviteActivity extends InviteActivity {
super.onCreate( savedInstanceState, m_dlgt );
}
@Override
protected void onSaveInstanceState( Bundle outState )
{
super.onSaveInstanceState( outState );
m_dlgt.onSaveInstanceState( outState );
}
@Override
protected void onActivityResult( int requestCode, int resultCode,
Intent data )

View file

@ -356,7 +356,7 @@ public class UpdateCheckReceiver extends BroadcastReceiver {
intent = new Intent( Intent.ACTION_VIEW,
Uri.parse(url) );
} else {
intent = DictImportDelegate
intent = DwnldDelegate
.makeAppDownloadIntent( m_context, url );
}

View file

@ -37,6 +37,13 @@ public class XWActivity extends Activity {
dlgt.init( savedInstanceState );
}
@Override
protected void onSaveInstanceState( Bundle outState )
{
super.onSaveInstanceState( outState );
m_dlgt.onSaveInstanceState( outState );
}
@Override
protected void onPause()
{
@ -114,6 +121,6 @@ public class XWActivity extends Activity {
public void onPrepareDialog( int id, Dialog dialog )
{
super.onPrepareDialog( id, dialog );
m_dlgt.prepareDialog( id, dialog );
m_dlgt.prepareDialog( DlgID.values()[id], dialog );
}
}

View file

@ -37,6 +37,13 @@ public class XWListActivity extends ListActivity {
dlgt.init( savedInstanceState );
}
@Override
protected void onSaveInstanceState( Bundle outState )
{
super.onSaveInstanceState( outState );
m_dlgt.onSaveInstanceState( outState );
}
@Override
protected void onPause()
{
@ -114,6 +121,6 @@ public class XWListActivity extends ListActivity {
public void onPrepareDialog( int id, Dialog dialog )
{
super.onPrepareDialog( id, dialog );
m_dlgt.prepareDialog( id, dialog );
m_dlgt.prepareDialog( DlgID.values()[id], dialog );
}
}