diff --git a/xwords4/android/XWords4/AndroidManifest.xml b/xwords4/android/XWords4/AndroidManifest.xml index 80889f09f..4dd2a8874 100644 --- a/xwords4/android/XWords4/AndroidManifest.xml +++ b/xwords4/android/XWords4/AndroidManifest.xml @@ -168,7 +168,7 @@ - diff --git a/xwords4/android/XWords4/archive/R.java b/xwords4/android/XWords4/archive/R.java index 73ad7ab50..9412fac5b 100644 --- a/xwords4/android/XWords4/archive/R.java +++ b/xwords4/android/XWords4/archive/R.java @@ -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; diff --git a/xwords4/android/XWords4/res/layout/import_dict.xml b/xwords4/android/XWords4/res/layout/import_dict.xml index abe371acc..4b77c9a0f 100644 --- a/xwords4/android/XWords4/res/layout/import_dict.xml +++ b/xwords4/android/XWords4/res/layout/import_dict.xml @@ -2,23 +2,16 @@ - - diff --git a/xwords4/android/XWords4/res/layout/import_dict_item.xml b/xwords4/android/XWords4/res/layout/import_dict_item.xml new file mode 100644 index 000000000..889fef987 --- /dev/null +++ b/xwords4/android/XWords4/res/layout/import_dict_item.xml @@ -0,0 +1,23 @@ + + + + + + + + diff --git a/xwords4/android/XWords4/res/layout/remote_dicts.xml b/xwords4/android/XWords4/res/layout/remote_dicts.xml index 6e63dba2d..5b6a6afa9 100644 --- a/xwords4/android/XWords4/res/layout/remote_dicts.xml +++ b/xwords4/android/XWords4/res/layout/remote_dicts.xml @@ -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" /> 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 3851ceda4..c5a8f691b 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java @@ -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 ) { diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDelegate.java index da75df009..67dfe3cd1 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDelegate.java @@ -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 ) { diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DelegateBase.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DelegateBase.java index c6ddfb59f..71779c715 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DelegateBase.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DelegateBase.java @@ -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 ) // { diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictLangCache.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictLangCache.java index 52673f391..d596a3076 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictLangCache.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictLangCache.java @@ -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 m_langsAdapter; - private static ArrayAdapter m_dictsAdapter; + private static int s_adaptedLang = -1; + private static ArrayAdapter s_langsAdapter; + private static ArrayAdapter s_dictsAdapter; private static String s_last; private static Handler s_handler; private static Comparator 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 getLangsAdapter( Context context ) { - if ( null == m_langsAdapter ) { - m_langsAdapter = + if ( null == s_langsAdapter ) { + s_langsAdapter = new ArrayAdapter( 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 getDictsAdapter( Context context, int lang ) { - if ( lang != m_adaptedLang ) { - m_dictsAdapter = + if ( lang != s_adaptedLang ) { + s_dictsAdapter = new ArrayAdapter( 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 ) @@ -411,4 +411,4 @@ public class DictLangCache { return info; } -} \ No newline at end of file +} diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsDelegate.java index c16b92643..ba67da727 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsDelegate.java @@ -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 ) { diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictImportActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DwnldActivity.java similarity index 87% rename from xwords4/android/XWords4/src/org/eehouse/android/xw4/DictImportActivity.java rename to xwords4/android/XWords4/src/org/eehouse/android/xw4/DwnldActivity.java index 4811af22c..0e5d9769e 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictImportActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DwnldActivity.java @@ -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 ); } } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictImportDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DwnldDelegate.java similarity index 50% rename from xwords4/android/XWords4/src/org/eehouse/android/xw4/DictImportDelegate.java rename to xwords4/android/XWords4/src/org/eehouse/android/xw4/DwnldDelegate.java index b7c40fbbb..0f28263d1 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictImportDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DwnldDelegate.java @@ -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 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,98 +70,102 @@ 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 s_listeners = new HashMap(); - private class DownloadFilesTask extends AsyncTask + private class DownloadFilesTask extends AsyncTask 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() ); - URLConnection conn = jUri.toURL().openConnection(); - final int fileLen = conn.getContentLength(); - m_handler.post( new Runnable() { - public void run() { - m_progressBar.setMax( fileLen ); - } - }); - InputStream is = conn.getInputStream(); - String name = basename( uri.getPath() ); - if ( m_isApp ) { - m_appFile = saveToDownloads( is, name, this ); - } else { - m_savedDict = saveDict( is, name, this ); - } - is.close(); - } catch ( java.net.URISyntaxException use ) { - DbgUtils.loge( use ); - } catch ( java.net.MalformedURLException mue ) { - DbgUtils.loge( mue ); - } catch ( java.io.IOException ioe ) { - DbgUtils.loge( ioe ); + try { + 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() { + public void run() { + m_progressBar.setMax( fileLen ); + } + }); + InputStream is = conn.getInputStream(); + String name = basename( m_uri.getPath() ); + if ( m_isApp ) { + m_appFile = saveToDownloads( is, name, this ); + } else { + m_savedDict = saveDict( is, name, this ); } + is.close(); + } catch ( java.net.URISyntaxException use ) { + DbgUtils.loge( use ); + } catch ( java.net.MalformedURLException mue ) { + DbgUtils.loge( mue ); + } 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(); } - finish(); } // interface DictUtils.DownProgListener @@ -170,10 +180,20 @@ public class DictImportDelegate extends DelegateBase { } } // class DownloadFilesTask - protected void init( Bundle savedInstanceState ) - { - DownloadFilesTask dft = null; + 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(); + 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( 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 ); - - dft.execute( uri ); + mkListAdapter(); + + 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; } } - - diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfigActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfigActivity.java index b852413b3..241aced1c 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfigActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfigActivity.java @@ -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 ) { diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfigDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfigDelegate.java index e43b549e7..310206027 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfigDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfigDelegate.java @@ -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,126 +150,128 @@ public class GameConfigDelegate extends DelegateBase protected Dialog onCreateDialog( int id ) { - Dialog dialog = null; - DialogInterface.OnClickListener dlpos; - AlertDialog.Builder ab; + Dialog dialog = super.onCreateDialog( id ); - final DlgID dlgID = DlgID.values()[id]; - switch (dlgID) { - case PLAYER_EDIT: - View playerEditView = inflate( R.layout.player_edit ); + if ( null == dialog ) { + DialogInterface.OnClickListener dlpos; + AlertDialog.Builder ab; - dialog = makeAlertBuilder() - .setTitle(R.string.player_edit_title) - .setView(playerEditView) - .setPositiveButton( R.string.button_ok, - new DialogInterface.OnClickListener() { - public void - onClick( DialogInterface dlg, - int button ) { - getPlayerSettings( dlg ); - loadPlayersList(); - } - }) - .setNegativeButton( R.string.button_cancel, null ) - .create(); - break; - // case ROLE_EDIT_RELAY: - // case ROLE_EDIT_SMS: - // case ROLE_EDIT_BT: - // dialog = new AlertDialog.Builder( this ) - // .setTitle(titleForDlg(id)) - // .setView( LayoutInflater.from(this) - // .inflate( layoutForDlg(id), null )) - // .setPositiveButton( R.string.button_ok, - // new DialogInterface.OnClickListener() { - // public void onClick( DialogInterface dlg, - // int whichButton ) { - // getRoleSettings(); - // } - // }) - // .setNegativeButton( R.string.button_cancel, null ) - // .create(); - // break; + final DlgID dlgID = DlgID.values()[id]; + switch (dlgID) { + case PLAYER_EDIT: + View playerEditView = inflate( R.layout.player_edit ); - case FORCE_REMOTE: - dlpos = new DialogInterface.OnClickListener() { - public void onClick( DialogInterface dlg, - int whichButton ) { - loadPlayersList(); - } - }; - dialog = makeAlertBuilder() - .setTitle( R.string.force_title ) - .setView( inflate( layoutForDlg(dlgID) ) ) - .setPositiveButton( R.string.button_ok, dlpos ) - .create(); - DialogInterface.OnDismissListener dismiss = - new DialogInterface.OnDismissListener() { - @Override - public void onDismiss( DialogInterface di ) - { - if ( m_gi.forceRemoteConsistent() ) { - showToast( R.string.forced_consistent ); - loadPlayersList(); - } - } - }; - dialog.setOnDismissListener( dismiss ); - break; - case CONFIRM_CHANGE_PLAY: - case CONFIRM_CHANGE: - dlpos = new DialogInterface.OnClickListener() { - public void onClick( DialogInterface dlg, - int whichButton ) { - applyChanges( true ); - if ( DlgID.CONFIRM_CHANGE_PLAY == dlgID ) { - launchGame(); - } - } - }; - ab = makeAlertBuilder() - .setTitle( R.string.confirm_save_title ) - .setMessage( R.string.confirm_save ) - .setPositiveButton( R.string.button_save, dlpos ); - if ( DlgID.CONFIRM_CHANGE_PLAY == dlgID ) { + dialog = makeAlertBuilder() + .setTitle(R.string.player_edit_title) + .setView(playerEditView) + .setPositiveButton( R.string.button_ok, + new DialogInterface.OnClickListener() { + public void + onClick( DialogInterface dlg, + int button ) { + getPlayerSettings( dlg ); + loadPlayersList(); + } + }) + .setNegativeButton( R.string.button_cancel, null ) + .create(); + break; + // case ROLE_EDIT_RELAY: + // case ROLE_EDIT_SMS: + // case ROLE_EDIT_BT: + // dialog = new AlertDialog.Builder( this ) + // .setTitle(titleForDlg(id)) + // .setView( LayoutInflater.from(this) + // .inflate( layoutForDlg(id), null )) + // .setPositiveButton( R.string.button_ok, + // new DialogInterface.OnClickListener() { + // public void onClick( DialogInterface dlg, + // int whichButton ) { + // getRoleSettings(); + // } + // }) + // .setNegativeButton( R.string.button_cancel, null ) + // .create(); + // break; + + case FORCE_REMOTE: dlpos = new DialogInterface.OnClickListener() { public void onClick( DialogInterface dlg, int whichButton ) { - launchGame(); + loadPlayersList(); } }; - } else { - dlpos = null; + dialog = makeAlertBuilder() + .setTitle( R.string.force_title ) + .setView( inflate( layoutForDlg(dlgID) ) ) + .setPositiveButton( R.string.button_ok, dlpos ) + .create(); + DialogInterface.OnDismissListener dismiss = + new DialogInterface.OnDismissListener() { + @Override + public void onDismiss( DialogInterface di ) + { + if ( m_gi.forceRemoteConsistent() ) { + showToast( R.string.forced_consistent ); + loadPlayersList(); + } + } + }; + dialog.setOnDismissListener( dismiss ); + break; + case CONFIRM_CHANGE_PLAY: + case CONFIRM_CHANGE: + dlpos = new DialogInterface.OnClickListener() { + public void onClick( DialogInterface dlg, + int whichButton ) { + applyChanges( true ); + if ( DlgID.CONFIRM_CHANGE_PLAY == dlgID ) { + launchGame(); + } + } + }; + ab = makeAlertBuilder() + .setTitle( R.string.confirm_save_title ) + .setMessage( R.string.confirm_save ) + .setPositiveButton( R.string.button_save, dlpos ); + if ( DlgID.CONFIRM_CHANGE_PLAY == dlgID ) { + dlpos = new DialogInterface.OnClickListener() { + public void onClick( DialogInterface dlg, + int whichButton ) { + launchGame(); + } + }; + } else { + dlpos = null; + } + ab.setNegativeButton( R.string.button_discard, dlpos ); + dialog = ab.create(); + + dialog.setOnDismissListener( new DialogInterface. + OnDismissListener() { + public void onDismiss( DialogInterface di ) { + finish(); + } + }); + break; + case NO_NAME_FOUND: + String msg = getString( R.string.no_name_found_fmt, + m_gi.nPlayers, DictLangCache. + getLangName( m_activity, m_gi.dictLang ) ); + dialog = makeAlertBuilder() + .setPositiveButton( R.string.button_ok, null ) + // message added below since varies with language etc. + .setMessage( msg ) + .create(); + break; } - ab.setNegativeButton( R.string.button_discard, dlpos ); - dialog = ab.create(); - - dialog.setOnDismissListener( new DialogInterface. - OnDismissListener() { - public void onDismiss( DialogInterface di ) { - finish(); - } - }); - break; - case NO_NAME_FOUND: - String msg = getString( R.string.no_name_found_fmt, - m_gi.nPlayers, DictLangCache. - getLangName( m_activity, m_gi.dictLang ) ); - dialog = makeAlertBuilder() - .setPositiveButton( R.string.button_ok, null ) - // message added below since varies with language etc. - .setMessage( msg ) - .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; diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListActivity.java index 0096fe505..06842384d 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListActivity.java @@ -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 ) { diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java index 8760d5aee..dd2e72fc4 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java @@ -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() { 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 9b2b0a46a..de8f0f69f 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameActivity.java @@ -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 ) { diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/RemoteDictsDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/RemoteDictsDelegate.java index 4cb606952..a09570206 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/RemoteDictsDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/RemoteDictsDelegate.java @@ -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 iter = m_selDicts.iterator(); iter.hasNext(); ) { XWListItem litm = iter.next(); String langName = (String)litm.getCached(); - String url = Utils.makeDictUrl( m_activity, langName, - litm.getText() ); - DictImportDelegate.downloadDictInBack( m_activity, url ); + urls[count++] = Utils.makeDictUrl( m_activity, langName, + litm.getText() ); } + 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\"]}]}]}"; } 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 bbb08dd00..d077d32de 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSInviteActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSInviteActivity.java @@ -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 ) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/UpdateCheckReceiver.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/UpdateCheckReceiver.java index 665cadd34..5ef592c8e 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/UpdateCheckReceiver.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/UpdateCheckReceiver.java @@ -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 ); } 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 dce0d10e9..19b771ca0 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWActivity.java @@ -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 ); } } 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 e4a286d70..806b7d2cf 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWListActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWListActivity.java @@ -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 ); } }