diff --git a/xwords4/android/XWords4/.gitignore b/xwords4/android/XWords4/.gitignore
index b35181c70..234905006 100644
--- a/xwords4/android/XWords4/.gitignore
+++ b/xwords4/android/XWords4/.gitignore
@@ -3,7 +3,6 @@ ant_out.txt
local.properties
bin
gen
-libs
proguard.cfg
obj
res/drawable*/*gen.png
diff --git a/xwords4/android/XWords4/AndroidManifest.xml b/xwords4/android/XWords4/AndroidManifest.xml
index ec8543e96..d89e4d675 100644
--- a/xwords4/android/XWords4/AndroidManifest.xml
+++ b/xwords4/android/XWords4/AndroidManifest.xml
@@ -67,7 +67,7 @@
android:name=".XWApp"
>
-
-
+
+
+
+
+
diff --git a/xwords4/android/XWords4/res/layout/main.xml b/xwords4/android/XWords4/res/layout/main.xml
new file mode 100644
index 000000000..510c2b7d6
--- /dev/null
+++ b/xwords4/android/XWords4/res/layout/main.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml
index 2dad77ea8..afef6a98f 100644
--- a/xwords4/android/XWords4/res/values/strings.xml
+++ b/xwords4/android/XWords4/res/values/strings.xml
@@ -2265,4 +2265,7 @@
Force tablet layout
Even if my screen is too small
+
+ Single-pane
+ Dual-pane
diff --git a/xwords4/android/XWords4/res/values/styles.xml b/xwords4/android/XWords4/res/values/styles.xml
index f5514894a..054fbe2db 100644
--- a/xwords4/android/XWords4/res/values/styles.xml
+++ b/xwords4/android/XWords4/res/values/styles.xml
@@ -90,5 +90,12 @@
- 1
+
+
+
diff --git a/xwords4/android/XWords4/res_src/values-ba_CK/strings.xml b/xwords4/android/XWords4/res_src/values-ba_CK/strings.xml
index 849d19d87..8987e49b7 100644
--- a/xwords4/android/XWords4/res_src/values-ba_CK/strings.xml
+++ b/xwords4/android/XWords4/res_src/values-ba_CK/strings.xml
@@ -1937,4 +1937,6 @@
tahw\'s elbaliava.
Ecrof telbat tuoyal
Neve fi ym neercs si oot llams
+ Enap-elgnis
+ Enap-laud
diff --git a/xwords4/android/XWords4/res_src/values-ca_PS/strings.xml b/xwords4/android/XWords4/res_src/values-ca_PS/strings.xml
index 7cc0f8320..b5b2a18c0 100644
--- a/xwords4/android/XWords4/res_src/values-ca_PS/strings.xml
+++ b/xwords4/android/XWords4/res_src/values-ca_PS/strings.xml
@@ -1937,4 +1937,6 @@
WHAT\'S AVAILABLE.
FORCE TABLET LAYOUT
EVEN IF MY SCREEN IS TOO SMALL
+ SINGLE-PANE
+ DUAL-PANE
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 76dbe5511..839ce8ceb 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDelegate.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDelegate.java
@@ -81,6 +81,7 @@ public class BoardDelegate extends DelegateBase
private static final String GETDICT = "GETDICT";
private Activity m_activity;
+ private Delegator m_delegator;
private BoardView m_view;
private int m_jniGamePtr;
private GameLock m_gameLock;
@@ -309,7 +310,7 @@ public class BoardDelegate extends DelegateBase
waitCloseGame( false );
GameUtils.deleteGame( m_activity, m_rowid, false );
- finish();
+ m_delegator.finish();
}
};
ab.setNegativeButton( R.string.button_delete, lstnr );
@@ -496,6 +497,7 @@ public class BoardDelegate extends DelegateBase
{
super( delegator, savedInstanceState, R.menu.board_menu );
m_activity = delegator.getActivity();
+ m_delegator = delegator;
}
protected void init( Bundle savedInstanceState )
@@ -530,17 +532,17 @@ public class BoardDelegate extends DelegateBase
}
m_volKeysZoom = XWPrefs.getVolKeysZoom( m_activity );
- Intent intent = getIntent();
- m_rowid = intent.getLongExtra( GameUtils.INTENT_KEY_ROWID, -1 );
+ Bundle args = getArguments();
+ m_rowid = args.getLong( GameUtils.INTENT_KEY_ROWID, -1 );
DbgUtils.logf( "BoardActivity: opening rowid %d", m_rowid );
- m_haveInvited = intent.getBooleanExtra( GameUtils.INVITED, false );
+ m_haveInvited = args.getBoolean( GameUtils.INVITED, false );
m_overNotShown = true;
NFCUtils.register( m_activity, this ); // Don't seem to need to unregister...
setBackgroundColor();
setKeepScreenOn();
- } // onCreate
+ } // init
protected void onPause()
{
@@ -1206,7 +1208,7 @@ public class BoardDelegate extends DelegateBase
String msg = getString( R.string.reload_new_dict_fmt, getDict );
showToast( msg );
- finish();
+ m_delegator.finish();
GameUtils.launchGame( m_activity, m_rowid, false );
}
@@ -1899,7 +1901,7 @@ public class BoardDelegate extends DelegateBase
}
} catch ( GameUtils.NoSuchGameException nsge ) {
DbgUtils.loge( nsge );
- finish();
+ m_delegator.finish();
}
}
} // loadGame
@@ -2253,7 +2255,7 @@ public class BoardDelegate extends DelegateBase
Intent intent = GamesListActivity.makeRematchIntent( m_activity, m_gi, m_rowid );
if ( null != intent ) {
startActivity( intent );
- finish();
+ m_delegator.finish();
}
}
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardFrag.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardFrag.java
new file mode 100644
index 000000000..9c687d8d7
--- /dev/null
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardFrag.java
@@ -0,0 +1,60 @@
+/* -*- compile-command: "find-and-ant.sh debug install"; -*- */
+/*
+ * Copyright 2014 by Eric House (xwords@eehouse.org). All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+package org.eehouse.android.xw4;
+
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import org.eehouse.android.xw4.loc.LocUtils;
+
+public class BoardFrag extends XWFragment implements Delegator {
+ private BoardDelegate m_dlgt;
+
+ // public BoardFrag( FragActivity activity )
+ // {
+ // m_activity = activity;
+ // }
+
+ @Override
+ public void onCreate( Bundle savedInstanceState )
+ {
+ DbgUtils.logf( "GamesListFrag.onCreate()" );
+ m_dlgt = new BoardDelegate( this, savedInstanceState );
+ super.onCreate( m_dlgt, savedInstanceState );
+ }
+
+ @Override
+ public View onCreateView( LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState )
+ {
+ View root = inflater.inflate( R.layout.game_list, container, false );
+ LocUtils.xlateView( getActivity(), root );
+ return root;
+ }
+
+ @Override
+ public void onActivityCreated( Bundle savedInstanceState )
+ {
+ super.onActivityCreated( savedInstanceState );
+ setHasOptionsMenu( true );
+ }
+}
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 c1aed4ff3..4110263df 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DelegateBase.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DelegateBase.java
@@ -19,6 +19,7 @@
package org.eehouse.android.xw4;
+import android.view.MenuInflater;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
@@ -75,11 +76,11 @@ public class DelegateBase implements DlgDelegate.DlgClickNotify,
protected void onActivityResult( int requestCode, int resultCode,
Intent data ) {}
- public boolean onCreateOptionsMenu( Menu menu )
+ public boolean onCreateOptionsMenu( Menu menu, MenuInflater inflater )
{
boolean handled = 0 < m_optionsMenuID;
if ( handled ) {
- m_activity.getMenuInflater().inflate( m_optionsMenuID, menu );
+ inflater.inflate( m_optionsMenuID, menu );
LocUtils.xlateMenu( m_activity, menu );
} else {
Assert.fail();
@@ -88,11 +89,22 @@ public class DelegateBase implements DlgDelegate.DlgClickNotify,
return handled;
}
+ public boolean onCreateOptionsMenu( Menu menu )
+ {
+ MenuInflater inflater = m_activity.getMenuInflater();
+ return onCreateOptionsMenu( menu, inflater );
+ }
+
protected Intent getIntent()
{
return m_activity.getIntent();
}
+ protected Bundle getArguments()
+ {
+ return m_delegator.getArguments();
+ }
+
protected void setContentView( int resID )
{
m_activity.setContentView( resID );
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/Delegator.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/Delegator.java
index 33f210029..cc705e8c4 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/Delegator.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/Delegator.java
@@ -20,7 +20,10 @@
package org.eehouse.android.xw4;
import android.app.Activity;
+import android.os.Bundle;
public interface Delegator {
Activity getActivity();
+ Bundle getArguments();
+ void finish();
}
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/FragActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/FragActivity.java
new file mode 100644
index 000000000..5f1dbd529
--- /dev/null
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/FragActivity.java
@@ -0,0 +1,230 @@
+/* -*- compile-command: "find-and-ant.sh debug install"; -*- */
+/*
+ * Copyright 2014 by Eric House (xwords@eehouse.org). All rights
+ * reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+package org.eehouse.android.xw4;
+
+import android.content.res.Configuration;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentActivity;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentTransaction;
+import android.view.View;
+import android.widget.FrameLayout;
+import android.widget.LinearLayout.LayoutParams;
+import android.widget.LinearLayout;
+import android.widget.LinearLayout;
+
+import junit.framework.Assert;
+
+public class FragActivity extends FragmentActivity
+ implements FragmentManager.OnBackStackChangedListener {
+
+ public interface OrientChangeListener {
+ void orientationChanged( int orientation );
+ }
+
+ private static FragActivity s_this;
+
+ private LinearLayout m_root;
+ private int m_nextID = 0x00FFFFFF;
+ private int m_maxPanes;
+
+ @Override
+ public void onCreate( Bundle savedInstanceState )
+ {
+ s_this = this;
+ super.onCreate( savedInstanceState );
+ setContentView( R.layout.fragact );
+
+ m_root = (LinearLayout)findViewById( R.id.main_container );
+ getSupportFragmentManager().addOnBackStackChangedListener( this );
+
+ int orientation = getResources().getConfiguration().orientation;
+ m_maxPanes = maxPanes();
+
+ // Nothing to do if we're restarting
+ if (savedInstanceState == null) {
+ DbgUtils.logf( "calling new GamesListFrag()" );
+ GamesListFrag glf = new GamesListFrag();
+ DbgUtils.logf( "new GamesListFrag() done" );
+
+ // In case this activity was started with special instructions from an Intent,
+ // pass the Intent's extras to the fragment as arguments
+ glf.setArguments( getIntent().getExtras() );
+
+ DbgUtils.logf( "calling addFragment(glf)" );
+ addFragment( glf );
+ DbgUtils.logf( "addFragment(glf) DONE" );
+ }
+ }
+
+ @Override
+ public void onBackPressed()
+ {
+ DbgUtils.logf( "FragActivity.onBackPressed()" );
+ super.onBackPressed();
+ }
+
+ @Override
+ public void onConfigurationChanged( Configuration newConfig )
+ {
+ int orientation = newConfig.orientation;
+ boolean isPortrait = orientation == Configuration.ORIENTATION_PORTRAIT;
+ int maxPanes = isPortrait? 1 : 2;
+ if ( m_maxPanes != maxPanes ) {
+ m_maxPanes = maxPanes;
+ setVisiblePanes();
+ tellOrientationChanged( orientation );
+ }
+ super.onConfigurationChanged( newConfig );
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // FragmentManager.OnBackStackChangedListener
+ //////////////////////////////////////////////////////////////////////
+ public void onBackStackChanged()
+ {
+ DbgUtils.logf( "FragActivity.onBackStackChanged()" );
+ // make sure the right-most are visible
+ int fragCount = getSupportFragmentManager().getBackStackEntryCount();
+ if ( 0 == fragCount ) {
+ finish();
+ } else if ( fragCount == m_root.getChildCount() - 1 ) {
+ m_root.removeViewAt( fragCount );
+ setVisiblePanes();
+ }
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // GameListDelegate.DlgtOwner
+ //////////////////////////////////////////////////////////////////////
+ public static void launchGame( long rowid, boolean invited )
+ {
+ DbgUtils.logf( "FragActivity.launchGame(%d)", rowid );
+ Bundle args = GameUtils.makeLaunchExtras( rowid, invited );
+ BoardFrag bf = new BoardFrag();
+ bf.setArguments( args );
+ getThis().addFragment( bf );
+ }
+
+ public void launchDictFrag( Bundle args )
+ {
+ // DictBrowseFrag dbf = new DictBrowseFrag();
+ // dbf.setArguments( args );
+ // addFragment( dbf );
+ }
+
+ protected void popFragment( Fragment frag )
+ {
+ getSupportFragmentManager().popBackStack();
+ }
+
+ protected void addFragment( Fragment fragment )
+ {
+ String newName = fragment.getClass().getName();
+ boolean replace = false;
+ FragmentManager fm = getSupportFragmentManager();
+ int fragCount = fm.getBackStackEntryCount();
+ int contCount = m_root.getChildCount();
+ DbgUtils.logf( "fragCount: %d; contCount: %d", fragCount, contCount );
+ Assert.assertTrue( fragCount == contCount );
+
+ if ( 0 < contCount ) {
+ FragmentManager.BackStackEntry entry = fm.getBackStackEntryAt( fragCount - 1 );
+ String curName = entry.getName();
+ DbgUtils.logf( "name of last entry: %s", curName );
+ replace = curName.equals( newName );
+ if ( replace ) {
+ fm.popBackStack();
+ }
+ }
+
+ // Replace doesn't seem to work with generated IDs, so we'll create a
+ // new FrameLayout each time. If we're replacing, we'll replace the
+ // current rightmost FrameLayout. Otherwise we'll add a new one.
+ FrameLayout cont = new FrameLayout( this );
+ cont.setLayoutParams( new LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f) );
+ int id = --m_nextID;
+ cont.setId( id );
+ m_root.addView( cont, replace ? contCount - 1 : contCount );
+
+ if ( !replace && contCount >= m_maxPanes ) {
+ int indx = contCount - m_maxPanes;
+ m_root.getChildAt( indx ).setVisibility( View.GONE );
+ DbgUtils.logf( "hiding %dth container", indx );
+ }
+
+ fm.beginTransaction()
+ .add( id, fragment )
+ .addToBackStack( newName )
+ .commit();
+ // fm.executePendingTransactions();
+ }
+
+ private void setVisiblePanes()
+ {
+ // hide all but the right-most m_maxPanes children
+ int nPanes = m_root.getChildCount();
+ for ( int ii = 0; ii < nPanes; ++ii ) {
+ View child = m_root.getChildAt( ii );
+ boolean visible = ii >= nPanes - m_maxPanes;
+ DbgUtils.logf( "pane %d: visible=%b", ii, visible );
+ child.setVisibility( visible ? View.VISIBLE : View.GONE );
+ }
+ }
+
+ // Walk all Fragment children and if they care notify of change.
+ private void tellOrientationChanged( int orientation )
+ {
+ FragmentManager fm = getSupportFragmentManager();
+ int nPanes = m_root.getChildCount();
+ for ( int ii = 0; ii < nPanes; ++ii ) {
+ FrameLayout frame = (FrameLayout)m_root.getChildAt( ii );
+ int id = frame.getId();
+ Fragment frag = fm.findFragmentById( id );
+ if ( null == frag ) {
+ DbgUtils.logf( "tellOrienationChanged: NO FRAG at %d, id=%d", ii, id );
+ } else if ( frag instanceof OrientChangeListener ) {
+ ((OrientChangeListener)frag).orientationChanged( orientation );
+ }
+ }
+ }
+
+ private int maxPanes()
+ {
+ int result;
+ int orientation = getResources().getConfiguration().orientation;
+ if ( XWPrefs.getIsTablet( this )
+ && Configuration.ORIENTATION_LANDSCAPE == orientation ) {
+ result = 2;
+ } else {
+ result = 1;
+ }
+ return result;
+ }
+
+ private static FragActivity getThis()
+ {
+ Assert.assertNotNull( s_this );
+ return s_this;
+ }
+
+}
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java
index a4c7c011f..e8e3f472a 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java
@@ -27,6 +27,7 @@ import android.graphics.Bitmap;
import android.graphics.Rect;
import android.net.Uri;
import android.os.AsyncTask;
+import android.os.Bundle;
import android.text.Html;
import android.text.TextUtils;
@@ -710,14 +711,22 @@ public class GameUtils {
return file.endsWith( XWConstants.GAME_EXTN );
}
+ public static Bundle makeLaunchExtras( long rowid, boolean invited )
+ {
+ Bundle bundle = new Bundle();
+ bundle.putLong( INTENT_KEY_ROWID, rowid );
+ if ( invited ) {
+ bundle.putBoolean( INVITED, true );
+ }
+ return bundle;
+ }
+
public static void launchGame( Activity activity, long rowid,
boolean invited )
{
Intent intent = new Intent( activity, BoardActivity.class );
- intent.putExtra( INTENT_KEY_ROWID, rowid );
- if ( invited ) {
- intent.putExtra( INVITED, true );
- }
+ Bundle extras = makeLaunchExtras( rowid, invited );
+ intent.putExtras( extras );
activity.startActivity( intent );
}
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 9692e4f5c..4c0990a94 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListActivity.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListActivity.java
@@ -29,7 +29,7 @@ import org.eehouse.android.xw4.jni.CurGameInfo;
import junit.framework.Assert;
-public class GamesListActivity extends XWListActivity {
+public class GamesListActivity extends XWListActivity implements GamesListDelegator {
// private static final String RELAYIDS_EXTRA = "relayids";
private static final String ROWID_EXTRA = "rowid";
@@ -55,6 +55,14 @@ public class GamesListActivity extends XWListActivity {
m_dlgt.onNewIntent( intent );
}
+ //////////////////////////////////////////////////////////////////////
+ // GamesListDelegator interface
+ //////////////////////////////////////////////////////////////////////
+ public void launchGame( long rowID, boolean invited )
+ {
+ GameUtils.launchGame( this, rowID, invited );
+ }
+
public static void onGameDictDownload( Context context, Intent intent )
{
intent.setClass( context, GamesListActivity.class );
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 c597ff5a0..d8c614b00 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java
@@ -501,6 +501,7 @@ public class GamesListDelegate extends ListDelegateBase
private int m_fieldID;
private Activity m_activity;
+ private GamesListDelegator m_delegator;
private GameListAdapter m_adapter;
private Handler m_handler;
private String m_missingDict;
@@ -521,9 +522,10 @@ public class GamesListDelegate extends ListDelegateBase
private Set m_selGroupIDs;
private String m_origTitle;
- public GamesListDelegate( ListDelegator delegator, Bundle savedInstanceState )
+ public GamesListDelegate( GamesListDelegator delegator, Bundle sis )
{
- super( delegator, savedInstanceState, R.menu.games_list_menu );
+ super( delegator, sis, R.menu.games_list_menu );
+ m_delegator = delegator;
m_activity = delegator.getActivity();
}
@@ -756,8 +758,8 @@ public class GamesListDelegate extends ListDelegateBase
m_selGroupIDs = new HashSet();
getBundledData( savedInstanceState );
- setContentView( R.layout.game_list );
- ListView listview = getListView();
+ // setContentView( R.layout.game_list );
+ // ListView listview = getListView();
DBUtils.setDBChangeListener( this );
boolean isUpgrade = Utils.firstBootThisVersion( m_activity );
@@ -767,7 +769,7 @@ public class GamesListDelegate extends ListDelegateBase
}
mkListAdapter();
- listview.setOnItemLongClickListener( this );
+ getListView().setOnItemLongClickListener( this );
NetUtils.informOfDeaths( m_activity );
@@ -778,6 +780,13 @@ public class GamesListDelegate extends ListDelegateBase
m_origTitle = getTitle();
} // init
+ // protected View onCreateView( Bundle savedInstanceState )
+ // {
+ // View result = inflate( R.layout.game_list );
+ // // init( savedInstanceState );
+ // return result;
+ // }
+
// called when we're brought to the front (probably as a result of
// notification)
protected void onNewIntent( Intent intent )
@@ -899,12 +908,14 @@ public class GamesListDelegate extends ListDelegateBase
public void itemClicked( SelectableItem.LongClickHandler clicked,
GameSummary summary )
{
+ DbgUtils.logf( "GamesListDelegate.itemClicked()" );
// We need a way to let the user get back to the basic-config
// dialog in case it was dismissed. That way it to check for
// an empty room name.
if ( clicked instanceof GameListItem ) {
if ( DBUtils.ROWID_NOTFOUND == m_launchedGame ) {
long rowid = ((GameListItem)clicked).getRowID();
+ DbgUtils.logf( "GamesListDelegate.itemClicked(%d)", rowid );
showNotAgainDlgThen( R.string.not_again_newselect,
R.string.key_notagain_newselect,
Action.OPEN_GAME, rowid,
@@ -1046,7 +1057,7 @@ public class GamesListDelegate extends ListDelegateBase
@Override
public boolean onPrepareOptionsMenu( Menu menu )
{
- int nGamesSelected = m_selGames.size();
+ int nGamesSelected = m_selGames.size(); // NPE!
int nGroupsSelected = m_selGroupIDs.size();
int groupCount = m_adapter.getGroupCount();
m_menuPrepared = 0 == nGamesSelected || 0 == nGroupsSelected;
@@ -1688,7 +1699,7 @@ public class GamesListDelegate extends ListDelegateBase
long[] rowIDs = { m_missingDictRowId };
doConfirmReset( rowIDs );
} else {
- GameUtils.launchGame( m_activity, m_missingDictRowId );
+ launchGame( m_missingDictRowId );
}
m_missingDictRowId = DBUtils.ROWID_NOTFOUND;
m_missingDictMenuId = -1;
@@ -1698,9 +1709,10 @@ public class GamesListDelegate extends ListDelegateBase
private void launchGame( long rowid, boolean invited )
{
+ DbgUtils.logf( "launchGame(%d)", rowid );
if ( DBUtils.ROWID_NOTFOUND == m_launchedGame ) {
m_launchedGame = rowid;
- GameUtils.launchGame( m_activity, rowid, invited );
+ m_delegator.launchGame( rowid, invited );
}
}
@@ -1729,6 +1741,7 @@ public class GamesListDelegate extends ListDelegateBase
{
GameSummary summary = (GameSummary)params[1];
long rowid = (Long)params[0];
+ DbgUtils.logf( "GamesListDelegate.doOpenGame(%d)", rowid );
if ( summary.conType == CommsAddrRec.CommsConnType.COMMS_CONN_RELAY
&& summary.roomName.length() == 0 ) {
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegator.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegator.java
new file mode 100644
index 000000000..8a2325dec
--- /dev/null
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegator.java
@@ -0,0 +1,27 @@
+/* -*- compile-command: "find-and-ant.sh debug install"; -*- */
+/*
+ * Copyright 2014 by Eric House (xwords@eehouse.org). All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+package org.eehouse.android.xw4;
+
+import android.widget.ListAdapter;
+import android.widget.ListView;
+
+public interface GamesListDelegator extends ListDelegator {
+ void launchGame( long rowID, boolean invited );
+}
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListFrag.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListFrag.java
new file mode 100644
index 000000000..021405dae
--- /dev/null
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListFrag.java
@@ -0,0 +1,85 @@
+/* -*- compile-command: "find-and-ant.sh debug install"; -*- */
+/*
+ * Copyright 2014 by Eric House (xwords@eehouse.org). All rights
+ * reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+package org.eehouse.android.xw4;
+
+
+import android.content.Context;
+import android.os.Handler;
+import android.app.Activity;
+import android.app.ListActivity;
+import android.os.Build;
+import android.os.Bundle;
+import android.support.v4.app.ListFragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
+import android.widget.TextView;
+
+import junit.framework.Assert;
+
+import org.eehouse.android.xw4.jni.CommonPrefs;
+import org.eehouse.android.xw4.loc.LocUtils;
+
+public class GamesListFrag extends XWListFragment implements GamesListDelegator {
+
+ private GamesListDelegate m_dlgt;
+
+ // public GamesListFrag( FragActivity activity )
+ // {
+ // m_activity = activity;
+ // }
+
+ @Override
+ public void onCreate( Bundle savedInstanceState )
+ {
+ DbgUtils.logf( "GamesListFrag.onCreate()" );
+ m_dlgt = new GamesListDelegate( this, savedInstanceState );
+ super.onCreate( m_dlgt, savedInstanceState );
+ }
+
+ @Override
+ public View onCreateView( LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState )
+ {
+ View root = inflater.inflate( R.layout.game_list, container, false );
+ LocUtils.xlateView( getActivity(), root );
+ return root;
+ }
+
+ @Override
+ public void onActivityCreated( Bundle savedInstanceState )
+ {
+ super.onActivityCreated( savedInstanceState );
+ setHasOptionsMenu( true );
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // ListDelegator interface
+ //////////////////////////////////////////////////////////////////////
+ public void launchGame( long rowid, boolean invited )
+ {
+ DbgUtils.logf( "GamesListFrag.launchGame(%d)", rowid );
+ FragActivity.launchGame( rowid, invited );
+ }
+
+}
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/Main.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/Main.java
new file mode 100644
index 000000000..d79fa0d97
--- /dev/null
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/Main.java
@@ -0,0 +1,64 @@
+/* -*- compile-command: "find-and-ant.sh debug install"; -*- */
+/*
+ * Copyright 2014 by Eric House (xwords@eehouse.org). All rights
+ * reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+package org.eehouse.android.xw4;
+
+import android.content.Intent;
+import android.widget.Button;
+import android.app.Activity;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.os.Bundle;
+import android.support.v4.app.FragmentActivity;
+import android.support.v4.app.FragmentTransaction;
+
+public class Main extends Activity {
+
+ @Override
+ public void onCreate( Bundle savedInstanceState )
+ {
+ super.onCreate( savedInstanceState );
+ setContentView( R.layout.main );
+
+ DbgUtils.logf( "Main.onCreate() called" );
+
+ Button button;
+ button = (Button)findViewById( R.id.activity_button );
+ button.setOnClickListener( new OnClickListener() {
+ @Override
+ public void onClick( View v ) {
+ startActivity( GamesListActivity.class );
+ }
+ } );
+ button = (Button)findViewById( R.id.fragment_button );
+ button.setOnClickListener( new View.OnClickListener() {
+ @Override
+ public void onClick( View v ) {
+ startActivity( FragActivity.class );
+ }
+ } );
+ }
+
+ private void startActivity( Class clazz )
+ {
+ startActivity( new Intent( this, clazz ) );
+ }
+
+}
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/PrefsActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/PrefsActivity.java
index 34c6d4c1f..6440d6172 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/PrefsActivity.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/PrefsActivity.java
@@ -88,4 +88,9 @@ public class PrefsActivity extends PreferenceActivity implements Delegator {
{
return this;
}
+
+ public Bundle getArguments()
+ {
+ return getIntent().getExtras();
+ }
}
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/StudyListDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/StudyListDelegate.java
index a8e7b727d..9ad185b54 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/StudyListDelegate.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/StudyListDelegate.java
@@ -21,6 +21,7 @@ package org.eehouse.android.xw4;
import android.app.Activity;
import android.app.AlertDialog;
+import android.app.Activity;
import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
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 1240f87a1..f6227266f 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWActivity.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWActivity.java
@@ -144,4 +144,9 @@ public class XWActivity extends Activity implements Delegator {
{
return this;
}
+
+ public Bundle getArguments()
+ {
+ return getIntent().getExtras();
+ }
}
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWFragment.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWFragment.java
new file mode 100644
index 000000000..8efd33259
--- /dev/null
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWFragment.java
@@ -0,0 +1,110 @@
+/* -*- compile-command: "find-and-ant.sh debug install"; -*- */
+/*
+ * Copyright 2014 by Eric House (xwords@eehouse.org). All rights
+ * reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+package org.eehouse.android.xw4;
+
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+
+import junit.framework.Assert;
+
+public class XWFragment extends Fragment {
+
+ private DelegateBase m_dlgt;
+
+ public void onCreate( DelegateBase dlgt, Bundle savedInstanceState )
+ {
+ super.onCreate( savedInstanceState );
+ m_dlgt = dlgt;
+ }
+
+ @Override
+ public void onActivityCreated( Bundle savedInstanceState )
+ {
+ m_dlgt.init( savedInstanceState );
+ super.onActivityCreated( savedInstanceState );
+ }
+
+ @Override
+ public void onPause()
+ {
+ DbgUtils.logf( "%s.onPause() called", this.getClass().getName() );
+ m_dlgt.onPause();
+ super.onPause();
+ }
+
+ @Override
+ public void onResume()
+ {
+ super.onResume();
+ m_dlgt.onResume();
+ }
+
+ @Override
+ public void onStart()
+ {
+ DbgUtils.logf( "%s.onStart() called", this.getClass().getName() );
+ super.onStart();
+ m_dlgt.onStart();
+ }
+
+ @Override
+ public void onStop()
+ {
+ DbgUtils.logf( "%s.onStop() called", this.getClass().getName() );
+ m_dlgt.onStop();
+ super.onStop();
+ }
+
+ @Override
+ public void onDestroy()
+ {
+ m_dlgt.onDestroy();
+ super.onDestroy();
+ }
+
+ @Override
+ public void onPrepareOptionsMenu( Menu menu )
+ {
+ m_dlgt.onPrepareOptionsMenu( menu );
+ }
+
+ @Override
+ public void onCreateOptionsMenu( Menu menu, MenuInflater inflater )
+ {
+ m_dlgt.onCreateOptionsMenu( menu, inflater );
+ }
+
+ @Override
+ public boolean onOptionsItemSelected( MenuItem item )
+ {
+ return m_dlgt.onOptionsItemSelected( item );
+ }
+
+ public void finish()
+ {
+ Assert.fail();
+ }
+}
+
+
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 06e49ab9d..8477889f6 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWListActivity.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWListActivity.java
@@ -146,4 +146,8 @@ public class XWListActivity extends ListActivity implements ListDelegator {
return this;
}
+ public Bundle getArguments()
+ {
+ return getIntent().getExtras();
+ }
}
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWListFragment.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWListFragment.java
new file mode 100644
index 000000000..55e6faa18
--- /dev/null
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWListFragment.java
@@ -0,0 +1,105 @@
+/* -*- compile-command: "find-and-ant.sh debug install"; -*- */
+/*
+ * Copyright 2014 by Eric House (xwords@eehouse.org). All rights
+ * reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+package org.eehouse.android.xw4;
+
+import android.os.Bundle;
+import android.support.v4.app.ListFragment;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+
+import junit.framework.Assert;
+
+public class XWListFragment extends ListFragment {
+
+ private ListDelegateBase m_dlgt;
+
+ public void onCreate( ListDelegateBase dlgt, Bundle savedInstanceState )
+ {
+ super.onCreate( savedInstanceState );
+ m_dlgt = dlgt;
+ }
+
+ @Override
+ public void onActivityCreated( Bundle savedInstanceState )
+ {
+ m_dlgt.init( savedInstanceState );
+ super.onActivityCreated( savedInstanceState );
+ }
+
+ @Override
+ public void onPause()
+ {
+ m_dlgt.onPause();
+ super.onPause();
+ }
+
+ @Override
+ public void onResume()
+ {
+ super.onResume();
+ m_dlgt.onResume();
+ }
+
+ @Override
+ public void onStart()
+ {
+ super.onStart();
+ m_dlgt.onStart();
+ }
+
+ @Override
+ public void onStop()
+ {
+ m_dlgt.onStop();
+ super.onStop();
+ }
+
+ @Override
+ public void onDestroy()
+ {
+ m_dlgt.onDestroy();
+ super.onDestroy();
+ }
+
+ @Override
+ public void onPrepareOptionsMenu( Menu menu )
+ {
+ m_dlgt.onPrepareOptionsMenu( menu );
+ }
+
+ @Override
+ public void onCreateOptionsMenu( Menu menu, MenuInflater inflater )
+ {
+ m_dlgt.onCreateOptionsMenu( menu, inflater );
+ }
+
+ @Override
+ public boolean onOptionsItemSelected( MenuItem item )
+ {
+ return m_dlgt.onOptionsItemSelected( item );
+ }
+
+ public void finish()
+ {
+ Assert.fail();
+ }
+}
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocItemEditDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocItemEditDelegate.java
index 0874feca5..f8376cf61 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocItemEditDelegate.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocItemEditDelegate.java
@@ -42,6 +42,7 @@ import org.eehouse.android.xw4.DelegateBase;
import org.eehouse.android.xw4.Delegator;
import org.eehouse.android.xw4.R;
import org.eehouse.android.xw4.Utils;
+import org.eehouse.android.xw4.Delegator;
public class LocItemEditDelegate extends DelegateBase implements TextWatcher {
diff --git a/xwords4/android/scripts/find-and-ant.sh b/xwords4/android/scripts/find-and-ant.sh
index 3b1a665fd..dc34ad751 100755
--- a/xwords4/android/scripts/find-and-ant.sh
+++ b/xwords4/android/scripts/find-and-ant.sh
@@ -49,5 +49,5 @@ esac
ant $CMDS
if [ "$CMDS" != "${CMDS%%install}" ]; then
- adb shell am start -n org.eehouse.android.${PKG}/org.eehouse.android.${PKG}.GamesListActivity
+ adb shell am start -n org.eehouse.android.${PKG}/org.eehouse.android.${PKG}.Main
fi
diff --git a/xwords4/android/scripts/install-all.sh b/xwords4/android/scripts/install-all.sh
index 967f82e1d..4a497a932 100755
--- a/xwords4/android/scripts/install-all.sh
+++ b/xwords4/android/scripts/install-all.sh
@@ -67,7 +67,7 @@ for DEVICE in $DEVICES; do
echo $DEVICE
adb -s $DEVICE install -r $APK
adb -s $DEVICE shell am start \
- -n org.eehouse.android.${PKG}/org.eehouse.android.${PKG}.GamesListActivity
+ -n org.eehouse.android.${PKG}/org.eehouse.android.${PKG}.Main
COUNT=$((COUNT+1))
done