mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-30 08:34:16 +01:00
manually merge in improvements to activity/delegate interaction made
toward dual-pane effort.
This commit is contained in:
parent
bbc3d0e8e3
commit
91e2edecf4
22 changed files with 174 additions and 95 deletions
|
@ -57,14 +57,13 @@ public class BTInviteDelegate extends InviteDelegate
|
|||
|
||||
protected BTInviteDelegate( ListDelegator delegator, Bundle savedInstanceState )
|
||||
{
|
||||
super( delegator, savedInstanceState );
|
||||
super( delegator, savedInstanceState, R.layout.btinviter );
|
||||
m_activity = delegator.getActivity();
|
||||
}
|
||||
|
||||
protected void init()
|
||||
{
|
||||
super.init( R.layout.btinviter,
|
||||
R.id.button_invite, R.id.button_rescan,
|
||||
super.init( R.id.button_invite, R.id.button_rescan,
|
||||
R.id.button_clear, R.id.invite_desc,
|
||||
R.string.invite_bt_desc_fmt );
|
||||
m_firstScan = true;
|
||||
|
|
|
@ -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 );
|
||||
|
@ -494,8 +495,9 @@ public class BoardDelegate extends DelegateBase
|
|||
|
||||
public BoardDelegate( Delegator delegator, Bundle savedInstanceState )
|
||||
{
|
||||
super( delegator, savedInstanceState, R.menu.board_menu );
|
||||
super( delegator, savedInstanceState, R.layout.board, R.menu.board_menu );
|
||||
m_activity = delegator.getActivity();
|
||||
m_delegator = delegator;
|
||||
}
|
||||
|
||||
protected void init( Bundle savedInstanceState )
|
||||
|
@ -513,7 +515,6 @@ public class BoardDelegate extends DelegateBase
|
|||
|
||||
m_utils = new BoardUtilCtxt();
|
||||
m_jniu = JNIUtilsImpl.get( m_activity );
|
||||
setContentView( R.layout.board );
|
||||
m_timers = new TimerRunnable[4]; // needs to be in sync with
|
||||
// XWTimerReason
|
||||
m_view = (BoardView)findViewById( R.id.board_view );
|
||||
|
@ -530,17 +531,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()
|
||||
{
|
||||
|
@ -563,6 +564,13 @@ public class BoardDelegate extends DelegateBase
|
|||
ConnStatusHandler.setHandler( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy()
|
||||
{
|
||||
GamesListDelegate.boardDestroyed( m_rowid );
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
protected void onSaveInstanceState( Bundle outState )
|
||||
{
|
||||
outState.putInt( DLG_TITLE, m_dlgTitle );
|
||||
|
@ -1206,7 +1214,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 +1907,7 @@ public class BoardDelegate extends DelegateBase
|
|||
}
|
||||
} catch ( GameUtils.NoSuchGameException nsge ) {
|
||||
DbgUtils.loge( nsge );
|
||||
finish();
|
||||
m_delegator.finish();
|
||||
}
|
||||
}
|
||||
} // loadGame
|
||||
|
@ -2250,10 +2258,10 @@ public class BoardDelegate extends DelegateBase
|
|||
|
||||
private void doRematch()
|
||||
{
|
||||
Intent intent = GamesListActivity.makeRematchIntent( m_activity, m_gi, m_rowid );
|
||||
Intent intent = GamesListDelegate.makeRematchIntent( m_activity, m_gi, m_rowid );
|
||||
if ( null != intent ) {
|
||||
startActivity( intent );
|
||||
finish();
|
||||
m_delegator.finish();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ public class ChatDelegate extends DelegateBase
|
|||
|
||||
public ChatDelegate( Delegator delegator, Bundle savedInstanceState )
|
||||
{
|
||||
super( delegator, savedInstanceState, R.menu.chat_menu );
|
||||
super( delegator, savedInstanceState, R.layout.chat, R.menu.chat_menu );
|
||||
m_activity = delegator.getActivity();
|
||||
}
|
||||
|
||||
|
@ -48,9 +48,6 @@ public class ChatDelegate extends DelegateBase
|
|||
protected void init( Bundle savedInstanceState )
|
||||
{
|
||||
if ( BuildConstants.CHAT_SUPPORTED ) {
|
||||
|
||||
setContentView( R.layout.chat );
|
||||
|
||||
m_rowid = getIntent().getLongExtra( GameUtils.INTENT_KEY_ROWID, -1 );
|
||||
|
||||
DBUtils.HistoryPair[] pairs = DBUtils.getChatHistory( m_activity, m_rowid );
|
||||
|
|
|
@ -25,9 +25,12 @@ import android.app.Dialog;
|
|||
import android.content.DialogInterface.OnCancelListener;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import org.eehouse.android.xw4.DlgDelegate.Action;
|
||||
import org.eehouse.android.xw4.loc.LocUtils;
|
||||
|
@ -42,20 +45,23 @@ public class DelegateBase implements DlgDelegate.DlgClickNotify,
|
|||
private Delegator m_delegator;
|
||||
private Activity m_activity;
|
||||
private int m_optionsMenuID;
|
||||
private int m_layoutID;
|
||||
private View m_rootView;
|
||||
|
||||
public DelegateBase( Delegator delegator, Bundle bundle )
|
||||
public DelegateBase( Delegator delegator, Bundle bundle, int layoutID )
|
||||
{
|
||||
this( delegator, bundle, R.menu.empty );
|
||||
this( delegator, bundle, layoutID, R.menu.empty );
|
||||
}
|
||||
|
||||
public DelegateBase( Delegator delegator, Bundle bundle, int optionsMenu )
|
||||
public DelegateBase( Delegator delegator, Bundle bundle,
|
||||
int layoutID, int menuID )
|
||||
{
|
||||
Assert.assertTrue( 0 < optionsMenu );
|
||||
Assert.assertTrue( 0 < menuID );
|
||||
m_delegator = delegator;
|
||||
m_activity = delegator.getActivity();
|
||||
m_delegate = new DlgDelegate( m_activity, this, bundle );
|
||||
m_optionsMenuID = optionsMenu;
|
||||
m_delegate = new DlgDelegate( m_activity, this, this, bundle );
|
||||
m_layoutID = layoutID;
|
||||
m_optionsMenuID = menuID;
|
||||
LocUtils.xlateTitle( m_activity );
|
||||
}
|
||||
|
||||
|
@ -75,11 +81,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 +94,38 @@ 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 int getLayoutID()
|
||||
{
|
||||
return m_layoutID;
|
||||
}
|
||||
|
||||
protected Bundle getArguments()
|
||||
{
|
||||
return m_delegator.getArguments();
|
||||
}
|
||||
|
||||
protected View getContentView()
|
||||
{
|
||||
return m_rootView;
|
||||
}
|
||||
|
||||
protected void setContentView( View view )
|
||||
{
|
||||
LocUtils.xlateView( m_activity, view );
|
||||
m_rootView = view;
|
||||
}
|
||||
|
||||
protected void setContentView( int resID )
|
||||
{
|
||||
m_activity.setContentView( resID );
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -158,7 +158,7 @@ public class DictBrowseDelegate extends ListDelegateBase
|
|||
|
||||
protected DictBrowseDelegate( ListDelegator delegator, Bundle savedInstanceState )
|
||||
{
|
||||
super( delegator, savedInstanceState );
|
||||
super( delegator, savedInstanceState, R.layout.dict_browser );
|
||||
m_activity = delegator.getActivity();
|
||||
}
|
||||
|
||||
|
@ -206,8 +206,6 @@ public class DictBrowseDelegate extends ListDelegateBase
|
|||
m_browseState.m_maxShown = m_maxAvail;
|
||||
}
|
||||
|
||||
setContentView( R.layout.dict_browser );
|
||||
|
||||
Button button = (Button)findViewById( R.id.search_button );
|
||||
button.setOnClickListener( new View.OnClickListener() {
|
||||
public void onClick( View view )
|
||||
|
|
|
@ -299,7 +299,8 @@ public class DictsDelegate extends ListDelegateBase
|
|||
|
||||
protected DictsDelegate( ListDelegator delegator, Bundle savedInstanceState )
|
||||
{
|
||||
super( delegator, savedInstanceState, R.menu.dicts_menu );
|
||||
super( delegator, savedInstanceState, R.layout.dict_browse,
|
||||
R.menu.dicts_menu );
|
||||
m_activity = delegator.getActivity();
|
||||
}
|
||||
|
||||
|
@ -448,7 +449,6 @@ public class DictsDelegate extends ListDelegateBase
|
|||
m_locNames = getStringArray( R.array.loc_names );
|
||||
m_noteNone = getString( R.string.note_none );
|
||||
|
||||
setContentView( R.layout.dict_browse );
|
||||
m_listView = getListView();
|
||||
m_listView.setOnItemLongClickListener( this );
|
||||
|
||||
|
|
|
@ -118,6 +118,7 @@ public class DlgDelegate {
|
|||
}
|
||||
|
||||
private Activity m_activity;
|
||||
private DelegateBase m_dlgt;
|
||||
private DlgClickNotify m_clickCallback;
|
||||
private String m_dictName = null;
|
||||
private ProgressDialog m_progress;
|
||||
|
@ -125,10 +126,11 @@ public class DlgDelegate {
|
|||
|
||||
private HashMap<DlgID, DlgState> m_dlgStates;
|
||||
|
||||
public DlgDelegate( Activity activity, DlgClickNotify callback,
|
||||
Bundle bundle )
|
||||
public DlgDelegate( Activity activity, DelegateBase dlgt,
|
||||
DlgClickNotify callback, Bundle bundle )
|
||||
{
|
||||
m_activity = activity;
|
||||
m_dlgt = dlgt;
|
||||
m_clickCallback = callback;
|
||||
m_handler = new Handler();
|
||||
m_dlgStates = new HashMap<DlgID,DlgState>();
|
||||
|
@ -163,7 +165,8 @@ public class DlgDelegate {
|
|||
|
||||
protected void showDialog( DlgID dlgID )
|
||||
{
|
||||
m_activity.showDialog( dlgID.ordinal() );
|
||||
int id = dlgID.ordinal();
|
||||
m_activity.showDialog( id );
|
||||
}
|
||||
|
||||
public Dialog createDialog( int id )
|
||||
|
@ -212,7 +215,8 @@ public class DlgDelegate {
|
|||
|
||||
public void showOKOnlyDialog( int msgID )
|
||||
{
|
||||
showOKOnlyDialog( LocUtils.getString( m_activity, msgID ), Action.SKIP_CALLBACK );
|
||||
showOKOnlyDialog( LocUtils.getString( m_activity, msgID ),
|
||||
Action.SKIP_CALLBACK );
|
||||
}
|
||||
|
||||
public void showDictGoneFinish()
|
||||
|
@ -381,7 +385,8 @@ public class DlgDelegate {
|
|||
return true;
|
||||
}
|
||||
|
||||
public void eventOccurred( MultiService.MultiEvent event, final Object ... args )
|
||||
public void eventOccurred( MultiService.MultiEvent event,
|
||||
final Object ... args )
|
||||
{
|
||||
String msg = null;
|
||||
boolean asToast = true;
|
||||
|
|
|
@ -66,7 +66,7 @@ public class DwnldDelegate extends ListDelegateBase {
|
|||
|
||||
public DwnldDelegate( ListDelegator delegator, Bundle savedInstanceState )
|
||||
{
|
||||
super( delegator, savedInstanceState );
|
||||
super( delegator, savedInstanceState, R.layout.import_dict );
|
||||
m_activity = delegator.getActivity();
|
||||
}
|
||||
|
||||
|
@ -244,7 +244,6 @@ public class DwnldDelegate extends ListDelegateBase {
|
|||
LinearLayout item = null;
|
||||
|
||||
requestWindowFeature( Window.FEATURE_LEFT_ICON );
|
||||
setContentView( R.layout.import_dict );
|
||||
m_activity.getWindow().setFeatureDrawableResource( Window.FEATURE_LEFT_ICON,
|
||||
R.drawable.icon48x48 );
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ public class GameConfigDelegate extends DelegateBase
|
|||
|
||||
public GameConfigDelegate( Delegator delegator, Bundle savedInstanceState )
|
||||
{
|
||||
super( delegator, savedInstanceState );
|
||||
super( delegator, savedInstanceState, R.layout.game_config );
|
||||
m_activity = delegator.getActivity();
|
||||
}
|
||||
|
||||
|
@ -408,8 +408,6 @@ public class GameConfigDelegate extends DelegateBase
|
|||
m_forResult = intent.getBooleanExtra( GameUtils.INTENT_FORRESULT_ROWID,
|
||||
false );
|
||||
|
||||
setContentView( R.layout.game_config );
|
||||
|
||||
m_connectSetRelay = findViewById(R.id.connect_set_relay);
|
||||
m_connectSetSMS = findViewById(R.id.connect_set_sms);
|
||||
if ( !XWApp.SMSSUPPORTED ) {
|
||||
|
|
|
@ -501,6 +501,8 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
private int m_fieldID;
|
||||
|
||||
private Activity m_activity;
|
||||
private static GamesListDelegate s_self;
|
||||
private ListDelegator m_delegator;
|
||||
private GameListAdapter m_adapter;
|
||||
private Handler m_handler;
|
||||
private String m_missingDict;
|
||||
|
@ -515,16 +517,19 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
private String m_nameField;
|
||||
private NetLaunchInfo m_netLaunchInfo;
|
||||
private GameNamer m_namer;
|
||||
private long m_launchedGame = DBUtils.ROWID_NOTFOUND;
|
||||
private Set<Long> m_launchedGames;
|
||||
private boolean m_menuPrepared;
|
||||
private Set<Long> m_selGames;
|
||||
private Set<Long> m_selGroupIDs;
|
||||
private String m_origTitle;
|
||||
|
||||
public GamesListDelegate( ListDelegator delegator, Bundle savedInstanceState )
|
||||
public GamesListDelegate( ListDelegator delegator, Bundle sis )
|
||||
{
|
||||
super( delegator, savedInstanceState, R.menu.games_list_menu );
|
||||
super( delegator, sis, R.layout.game_list, R.menu.games_list_menu );
|
||||
m_delegator = delegator;
|
||||
m_activity = delegator.getActivity();
|
||||
m_launchedGames = new HashSet<Long>();
|
||||
s_self = this;
|
||||
}
|
||||
|
||||
protected Dialog onCreateDialog( int id )
|
||||
|
@ -756,8 +761,6 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
m_selGroupIDs = new HashSet<Long>();
|
||||
getBundledData( savedInstanceState );
|
||||
|
||||
setContentView( R.layout.game_list );
|
||||
ListView listview = getListView();
|
||||
DBUtils.setDBChangeListener( this );
|
||||
|
||||
boolean isUpgrade = Utils.firstBootThisVersion( m_activity );
|
||||
|
@ -767,7 +770,7 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
}
|
||||
|
||||
mkListAdapter();
|
||||
listview.setOnItemLongClickListener( this );
|
||||
getListView().setOnItemLongClickListener( this );
|
||||
|
||||
NetUtils.informOfDeaths( m_activity );
|
||||
|
||||
|
@ -783,7 +786,7 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
protected void onNewIntent( Intent intent )
|
||||
{
|
||||
// super.onNewIntent( intent );
|
||||
m_launchedGame = DBUtils.ROWID_NOTFOUND;
|
||||
m_launchedGames.clear();
|
||||
Assert.assertNotNull( intent );
|
||||
invalRelayIDs( intent.getStringArrayExtra( RELAYIDS_EXTRA ) );
|
||||
m_adapter.reloadGame( intent.getLongExtra( ROWID_EXTRA, -1 ) );
|
||||
|
@ -804,7 +807,7 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
protected void onDestroy()
|
||||
{
|
||||
DBUtils.clearDBChangeListener( this );
|
||||
// super.onDestroy();
|
||||
s_self = null;
|
||||
}
|
||||
|
||||
protected void onSaveInstanceState( Bundle outState )
|
||||
|
@ -846,9 +849,10 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
if ( hasFocus ) {
|
||||
updateField();
|
||||
|
||||
if ( DBUtils.ROWID_NOTFOUND != m_launchedGame ) {
|
||||
setSelGame( m_launchedGame );
|
||||
m_launchedGame = DBUtils.ROWID_NOTFOUND;
|
||||
if ( 0 != m_launchedGames.size() ) {
|
||||
long rowid = m_launchedGames.iterator().next();
|
||||
setSelGame( rowid );
|
||||
m_launchedGames.remove( rowid );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -903,8 +907,8 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
// 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();
|
||||
long rowid = ((GameListItem)clicked).getRowID();
|
||||
if ( ! m_launchedGames.contains( rowid ) ) {
|
||||
showNotAgainDlgThen( R.string.not_again_newselect,
|
||||
R.string.key_notagain_newselect,
|
||||
Action.OPEN_GAME, rowid,
|
||||
|
@ -1698,8 +1702,8 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
|
||||
private void launchGame( long rowid, boolean invited )
|
||||
{
|
||||
if ( DBUtils.ROWID_NOTFOUND == m_launchedGame ) {
|
||||
m_launchedGame = rowid;
|
||||
if ( ! m_launchedGames.contains( rowid ) ) {
|
||||
m_launchedGames.add( rowid );
|
||||
GameUtils.launchGame( m_activity, rowid, invited );
|
||||
}
|
||||
}
|
||||
|
@ -1813,6 +1817,13 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
// return adapter;
|
||||
}
|
||||
|
||||
public static void boardDestroyed( long rowid )
|
||||
{
|
||||
if ( null != s_self ) {
|
||||
s_self.m_launchedGames.remove( rowid );
|
||||
}
|
||||
}
|
||||
|
||||
public static void onGameDictDownload( Context context, Intent intent )
|
||||
{
|
||||
intent.setClass( context, GamesListActivity.class );
|
||||
|
|
|
@ -44,17 +44,16 @@ abstract class InviteDelegate extends ListDelegateBase
|
|||
protected Button m_clearButton;
|
||||
private Activity m_activity;
|
||||
|
||||
public InviteDelegate( ListDelegator delegator, Bundle savedInstanceState )
|
||||
public InviteDelegate( ListDelegator delegator, Bundle savedInstanceState,
|
||||
int layoutID )
|
||||
{
|
||||
super( delegator, savedInstanceState );
|
||||
super( delegator, savedInstanceState, layoutID, R.menu.empty );
|
||||
m_activity = delegator.getActivity();
|
||||
}
|
||||
|
||||
protected void init( int view_id, int button_invite, int button_rescan,
|
||||
protected void init( int button_invite, int button_rescan,
|
||||
int button_clear, int desc_id, int desc_strf )
|
||||
{
|
||||
setContentView( view_id );
|
||||
|
||||
Intent intent = getIntent();
|
||||
m_nMissing = intent.getIntExtra( INTENT_KEY_NMISSING, -1 );
|
||||
|
||||
|
|
|
@ -31,16 +31,15 @@ public class ListDelegateBase extends DelegateBase {
|
|||
private ListDelegator m_delegator;
|
||||
|
||||
protected ListDelegateBase( ListDelegator delegator, Bundle savedInstanceState,
|
||||
int menuID )
|
||||
int layoutID )
|
||||
{
|
||||
super( delegator, savedInstanceState, menuID );
|
||||
m_delegator = delegator;
|
||||
m_activity = delegator.getActivity();
|
||||
this( delegator, savedInstanceState, layoutID, R.menu.empty );
|
||||
}
|
||||
|
||||
protected ListDelegateBase( ListDelegator delegator, Bundle savedState )
|
||||
protected ListDelegateBase( ListDelegator delegator, Bundle savedInstanceState,
|
||||
int layoutID, int menuID )
|
||||
{
|
||||
super( delegator, savedState );
|
||||
super( delegator, savedInstanceState, layoutID, menuID );
|
||||
m_delegator = delegator;
|
||||
m_activity = delegator.getActivity();
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ public class NewGameDelegate extends DelegateBase {
|
|||
|
||||
protected NewGameDelegate( Delegator delegator, Bundle savedInstanceState )
|
||||
{
|
||||
super( delegator, savedInstanceState );
|
||||
super( delegator, savedInstanceState, R.layout.new_game );
|
||||
m_activity = delegator.getActivity();
|
||||
}
|
||||
|
||||
|
@ -80,8 +80,6 @@ public class NewGameDelegate extends DelegateBase {
|
|||
|
||||
m_groupID = getIntent().getLongExtra( GROUPID_EXTRA, -1 );
|
||||
|
||||
setContentView( R.layout.new_game );
|
||||
|
||||
TextView desc = (TextView)findViewById( R.id.newgame_local_desc );
|
||||
m_dict = CommonPrefs.getDefaultHumanDict( m_activity );
|
||||
String lang = DictLangCache.getLangName( m_activity, m_dict );
|
||||
|
@ -478,9 +476,10 @@ public class NewGameDelegate extends DelegateBase {
|
|||
|
||||
public static void startActivity( Activity parent, long groupID )
|
||||
{
|
||||
Bundle extras = new Bundle();
|
||||
extras.putLong( GROUPID_EXTRA, groupID );
|
||||
Intent intent = new Intent( parent, NewGameActivity.class );
|
||||
intent.putExtra( GROUPID_EXTRA, groupID );
|
||||
intent.putExtras( extras );
|
||||
parent.startActivity( intent );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -43,6 +43,12 @@ public class PrefsActivity extends PreferenceActivity implements Delegator {
|
|||
{
|
||||
super.onCreate( savedInstanceState );
|
||||
m_dlgt = new PrefsDelegate( this, this, savedInstanceState );
|
||||
|
||||
int layoutID = m_dlgt.getLayoutID();
|
||||
if ( 0 < layoutID ) {
|
||||
m_dlgt.setContentView( layoutID );
|
||||
}
|
||||
|
||||
m_dlgt.init( savedInstanceState );
|
||||
}
|
||||
|
||||
|
@ -88,4 +94,9 @@ public class PrefsActivity extends PreferenceActivity implements Delegator {
|
|||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
public Bundle getArguments()
|
||||
{
|
||||
return getIntent().getExtras();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public class PrefsDelegate extends DelegateBase
|
|||
public PrefsDelegate( PreferenceActivity activity, Delegator delegator,
|
||||
Bundle savedInstanceState )
|
||||
{
|
||||
super( delegator, savedInstanceState, R.menu.board_menu );
|
||||
super( delegator, savedInstanceState, R.layout.prefs_w_buttons );
|
||||
m_activity = activity;
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,6 @@ public class PrefsDelegate extends DelegateBase
|
|||
{
|
||||
// Load the preferences from an XML resource
|
||||
m_activity.addPreferencesFromResource( R.xml.xwprefs );
|
||||
setContentView( R.layout.prefs_w_buttons );
|
||||
|
||||
m_keyLogging = getString( R.string.key_logging_on );
|
||||
m_smsToasting = getString( R.string.key_show_sms );
|
||||
|
|
|
@ -49,14 +49,12 @@ public class RelayGameDelegate extends DelegateBase
|
|||
|
||||
protected RelayGameDelegate( Delegator delegator, Bundle savedInstanceState )
|
||||
{
|
||||
super( delegator, savedInstanceState );
|
||||
super( delegator, savedInstanceState, R.layout.relay_game_config );
|
||||
m_activity = delegator.getActivity();
|
||||
}
|
||||
|
||||
protected void init( Bundle savedInstanceState )
|
||||
{
|
||||
setContentView( R.layout.relay_game_config );
|
||||
|
||||
m_rowid = getIntent().getLongExtra( GameUtils.INTENT_KEY_ROWID, -1 );
|
||||
|
||||
m_playButton = (Button)findViewById( R.id.play_button );
|
||||
|
|
|
@ -67,14 +67,13 @@ public class SMSInviteDelegate extends InviteDelegate {
|
|||
|
||||
public SMSInviteDelegate( ListDelegator delegator, Bundle savedInstanceState )
|
||||
{
|
||||
super( delegator, savedInstanceState );
|
||||
super( delegator, savedInstanceState, R.layout.smsinviter );
|
||||
m_activity = delegator.getActivity();
|
||||
}
|
||||
|
||||
protected void init( Bundle savedInstanceState )
|
||||
{
|
||||
super.init( R.layout.smsinviter,
|
||||
R.id.button_invite, R.id.button_add,
|
||||
super.init( R.id.button_invite, R.id.button_add,
|
||||
R.id.button_clear, R.id.invite_desc,
|
||||
R.string.invite_sms_desc_fmt );
|
||||
getBundledData( savedInstanceState );
|
||||
|
|
|
@ -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;
|
||||
|
@ -69,13 +70,12 @@ public class StudyListDelegate extends ListDelegateBase
|
|||
|
||||
protected StudyListDelegate( ListDelegator delegator, Bundle savedInstanceState )
|
||||
{
|
||||
super( delegator, savedInstanceState, R.menu.studylist );
|
||||
super( delegator, savedInstanceState, R.layout.studylist, R.menu.studylist );
|
||||
m_activity = delegator.getActivity();
|
||||
}
|
||||
|
||||
protected void init( Bundle savedInstanceState )
|
||||
{
|
||||
setContentView( R.layout.studylist );
|
||||
m_list = (ListView)findViewById( android.R.id.list );
|
||||
|
||||
m_spinner = (Spinner)findViewById( R.id.pick_lang_spinner );
|
||||
|
@ -344,23 +344,26 @@ public class StudyListDelegate extends ListDelegateBase
|
|||
setTitleBar();
|
||||
}
|
||||
|
||||
public static void launchOrAlert( Context context, int lang,
|
||||
public static void launchOrAlert( Activity activity, int lang,
|
||||
DlgDelegate.HasDlgDelegate dlg )
|
||||
{
|
||||
String msg = null;
|
||||
if ( 0 == DBUtils.studyListLangs( context ).length ) {
|
||||
msg = LocUtils.getString( context, R.string.study_no_lists );
|
||||
if ( 0 == DBUtils.studyListLangs( activity ).length ) {
|
||||
msg = LocUtils.getString( activity, R.string.study_no_lists );
|
||||
} else if ( NO_LANG != lang &&
|
||||
0 == DBUtils.studyListWords( context, lang ).length ) {
|
||||
String langname = DictLangCache.getLangName( context, lang );
|
||||
msg = LocUtils.getString( context, R.string.study_no_lang_fmt,
|
||||
0 == DBUtils.studyListWords( activity, lang ).length ) {
|
||||
String langname = DictLangCache.getLangName( activity, lang );
|
||||
msg = LocUtils.getString( activity, R.string.study_no_lang_fmt,
|
||||
langname );
|
||||
} else {
|
||||
Intent intent = new Intent( context, StudyListActivity.class );
|
||||
Bundle bundle = new Bundle();
|
||||
if ( NO_LANG != lang ) {
|
||||
intent.putExtra( START_LANG, lang );
|
||||
bundle.putInt( START_LANG, lang );
|
||||
}
|
||||
context.startActivity( intent );
|
||||
|
||||
Intent intent = new Intent( activity, StudyListActivity.class );
|
||||
intent.putExtras( bundle );
|
||||
activity.startActivity( intent );
|
||||
}
|
||||
|
||||
if ( null != msg ) {
|
||||
|
|
|
@ -26,6 +26,8 @@ import android.os.Bundle;
|
|||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
public class XWActivity extends Activity implements Delegator {
|
||||
|
||||
private DelegateBase m_dlgt;
|
||||
|
@ -34,6 +36,12 @@ public class XWActivity extends Activity implements Delegator {
|
|||
{
|
||||
super.onCreate( savedInstanceState );
|
||||
m_dlgt = dlgt;
|
||||
|
||||
int layoutID = m_dlgt.getLayoutID();
|
||||
if ( 0 < layoutID ) {
|
||||
m_dlgt.setContentView( layoutID );
|
||||
}
|
||||
|
||||
dlgt.init( savedInstanceState );
|
||||
}
|
||||
|
||||
|
@ -117,6 +125,7 @@ public class XWActivity extends Activity implements Delegator {
|
|||
protected Dialog onCreateDialog( int id )
|
||||
{
|
||||
Dialog dialog = super.onCreateDialog( id );
|
||||
Assert.assertNull( dialog );
|
||||
if ( null == dialog ) {
|
||||
dialog = m_dlgt.onCreateDialog( id );
|
||||
}
|
||||
|
@ -144,4 +153,9 @@ public class XWActivity extends Activity implements Delegator {
|
|||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
public Bundle getArguments()
|
||||
{
|
||||
return getIntent().getExtras();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,12 @@ public class XWListActivity extends ListActivity implements ListDelegator {
|
|||
{
|
||||
super.onCreate( savedInstanceState );
|
||||
m_dlgt = dlgt;
|
||||
|
||||
int layoutID = m_dlgt.getLayoutID();
|
||||
if ( 0 < layoutID ) {
|
||||
m_dlgt.setContentView( layoutID );
|
||||
}
|
||||
|
||||
dlgt.init( savedInstanceState );
|
||||
}
|
||||
|
||||
|
@ -146,4 +152,8 @@ public class XWListActivity extends ListActivity implements ListDelegator {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Bundle getArguments()
|
||||
{
|
||||
return getIntent().getExtras();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,9 +53,8 @@ public class LocDelegate extends ListDelegateBase
|
|||
|
||||
protected LocDelegate( ListDelegator delegator, Bundle savedInstanceState )
|
||||
{
|
||||
super( delegator, savedInstanceState );
|
||||
super( delegator, savedInstanceState, R.layout.loc_main );
|
||||
m_activity = delegator.getActivity();
|
||||
init( savedInstanceState );
|
||||
}
|
||||
|
||||
protected boolean onBackPressed()
|
||||
|
@ -98,8 +97,6 @@ public class LocDelegate extends ListDelegateBase
|
|||
|
||||
protected void init( Bundle savedInstanceState )
|
||||
{
|
||||
setContentView( R.layout.loc_main );
|
||||
|
||||
m_searchButton = (ImageButton)findViewById( R.id.loc_search_button );
|
||||
m_searchButton.setOnClickListener( this );
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue