mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-16 15:41:16 +01:00
rename GamesList -> GamesListActivity, then move most of it into GamesListDelegate. This is part of exploring what it'll take to separate Activity-ness from the rest that can then also be used, say, from a Fragment.
This commit is contained in:
parent
5ff5074180
commit
6c8cedf5bb
13 changed files with 657 additions and 367 deletions
|
@ -67,7 +67,7 @@
|
|||
android:name=".XWApp"
|
||||
>
|
||||
|
||||
<activity android:name="GamesList"
|
||||
<activity android:name="GamesListActivity"
|
||||
android:label="@string/app_name"
|
||||
android:launchMode="standard"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||
|
|
|
@ -968,7 +968,7 @@ public class BTService extends XWService {
|
|||
private void postNotification( int gameID, int title, String body,
|
||||
long rowid )
|
||||
{
|
||||
Intent intent = GamesList.makeGameIDIntent( this, gameID );
|
||||
Intent intent = GamesListActivity.makeGameIDIntent( this, gameID );
|
||||
Utils.postNotification( this, intent, R.string.new_btmove_title,
|
||||
body, (int)rowid );
|
||||
}
|
||||
|
|
|
@ -2263,7 +2263,7 @@ public class BoardActivity extends XWActivity
|
|||
|
||||
private void doRematch()
|
||||
{
|
||||
Intent intent = GamesList.makeRematchIntent( this, m_gi, m_rowid );
|
||||
Intent intent = GamesListActivity.makeRematchIntent( this, m_gi, m_rowid );
|
||||
if ( null != intent ) {
|
||||
startActivity( intent );
|
||||
finish();
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
/* -*- 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.app.Activity;
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.eehouse.android.xw4.DlgDelegate.Action;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
public class DelegateBase implements DlgDelegate.DlgClickNotify {
|
||||
|
||||
private DlgDelegate m_delegate;
|
||||
|
||||
public DelegateBase( Activity activity, Bundle bundle )
|
||||
{
|
||||
m_delegate = new DlgDelegate( activity, this, bundle );
|
||||
}
|
||||
|
||||
protected void showNotAgainDlgThen( int msgID, int prefsKey,
|
||||
Action action, Object... params )
|
||||
{
|
||||
m_delegate.showNotAgainDlgThen( msgID, prefsKey, action, params );
|
||||
}
|
||||
|
||||
protected void showNotAgainDlgThen( int msgID, int prefsKey,
|
||||
Action action )
|
||||
{
|
||||
m_delegate.showNotAgainDlgThen( msgID, prefsKey, action );
|
||||
}
|
||||
|
||||
protected void showNotAgainDlg( int msgID, int prefsKey )
|
||||
{
|
||||
m_delegate.showNotAgainDlgThen( msgID, prefsKey );
|
||||
}
|
||||
|
||||
// It sucks that these must be duplicated here and XWActivity
|
||||
protected void showAboutDialog()
|
||||
{
|
||||
m_delegate.showAboutDialog();
|
||||
}
|
||||
|
||||
public void showOKOnlyDialog( int msgID )
|
||||
{
|
||||
m_delegate.showOKOnlyDialog( msgID );
|
||||
}
|
||||
|
||||
public void showOKOnlyDialog( String msg )
|
||||
{
|
||||
m_delegate.showOKOnlyDialog( msg );
|
||||
}
|
||||
|
||||
protected void showConfirmThen( String msg, Action action, Object... params )
|
||||
{
|
||||
m_delegate.showConfirmThen( msg, action, params );
|
||||
}
|
||||
|
||||
protected void showConfirmThen( String msg, int posButton, Action action,
|
||||
Object... params )
|
||||
{
|
||||
m_delegate.showConfirmThen( msg, posButton, action, params );
|
||||
}
|
||||
|
||||
protected void showConfirmThen( int msg, int posButton, Action action,
|
||||
Object... params )
|
||||
{
|
||||
m_delegate.showConfirmThen( msg, posButton, action, params );
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// DlgDelegate.DlgClickNotify interface
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
public void dlgButtonClicked( Action action, int button, Object[] params )
|
||||
{
|
||||
Assert.fail();
|
||||
}
|
||||
|
||||
}
|
|
@ -40,7 +40,7 @@ public class DispatchNotify extends Activity {
|
|||
|
||||
Uri data = getIntent().getData();
|
||||
if ( null != data ) { // relay invite redirected URL case
|
||||
GamesList.openGame( this, data );
|
||||
GamesListActivity.openGame( this, data );
|
||||
}
|
||||
|
||||
finish();
|
||||
|
|
|
@ -0,0 +1,203 @@
|
|||
/* -*- compile-command: "find-and-ant.sh debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009 - 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.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.app.ExpandableListActivity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import org.eehouse.android.xw4.jni.CurGameInfo;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
public class GamesListActivity extends XWExpandableListActivity {
|
||||
|
||||
// private static final String RELAYIDS_EXTRA = "relayids";
|
||||
private static final String ROWID_EXTRA = "rowid";
|
||||
private static final String GAMEID_EXTRA = "gameid";
|
||||
private static final String REMATCH_ROWID_EXTRA = "rowid_rm";
|
||||
private static final String ALERT_MSG = "alert_msg";
|
||||
|
||||
private GamesListDelegate m_dlgt;
|
||||
|
||||
@Override
|
||||
protected Dialog onCreateDialog( int id )
|
||||
{
|
||||
Dialog dialog = super.onCreateDialog( id );
|
||||
if ( null == dialog ) {
|
||||
dialog = m_dlgt.createDialog( id );
|
||||
}
|
||||
return dialog;
|
||||
} // onCreateDialog
|
||||
|
||||
@Override
|
||||
protected void onPrepareDialog( int id, Dialog dialog )
|
||||
{
|
||||
super.onPrepareDialog( id, dialog );
|
||||
m_dlgt.prepareDialog( id, dialog );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate( Bundle savedInstanceState )
|
||||
{
|
||||
super.onCreate( savedInstanceState );
|
||||
m_dlgt = new GamesListDelegate( this, savedInstanceState );
|
||||
} // onCreate
|
||||
|
||||
// called when we're brought to the front (probably as a result of
|
||||
// notification)
|
||||
@Override
|
||||
protected void onNewIntent( Intent intent )
|
||||
{
|
||||
super.onNewIntent( intent );
|
||||
m_dlgt.onNewIntent( intent );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop()
|
||||
{
|
||||
m_dlgt.onStop();
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy()
|
||||
{
|
||||
m_dlgt.onDestroy();
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState( Bundle outState )
|
||||
{
|
||||
super.onSaveInstanceState( outState );
|
||||
m_dlgt.onSaveInstanceState( outState );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWindowFocusChanged( boolean hasFocus )
|
||||
{
|
||||
super.onWindowFocusChanged( hasFocus );
|
||||
m_dlgt.onWindowFocusChanged( hasFocus );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContentChanged()
|
||||
{
|
||||
super.onContentChanged();
|
||||
if ( null != m_dlgt ) {
|
||||
m_dlgt.onContentChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if ( !m_dlgt.onBackPressed() ) {
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu( Menu menu )
|
||||
{
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate( R.menu.games_list_menu, menu );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu( Menu menu )
|
||||
{
|
||||
return m_dlgt.onPrepareOptionsMenu( menu )
|
||||
|| super.onPrepareOptionsMenu( menu );
|
||||
}
|
||||
|
||||
public boolean onOptionsItemSelected( MenuItem item )
|
||||
{
|
||||
return m_dlgt.onOptionsItemSelected( item )
|
||||
|| super.onOptionsItemSelected( item );
|
||||
}
|
||||
|
||||
public static void onGameDictDownload( Context context, Intent intent )
|
||||
{
|
||||
intent.setClass( context, GamesListActivity.class );
|
||||
context.startActivity( intent );
|
||||
}
|
||||
|
||||
private static Intent makeSelfIntent( Context context )
|
||||
{
|
||||
Intent intent = new Intent( context, GamesListActivity.class );
|
||||
intent.setFlags( Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||
| Intent.FLAG_ACTIVITY_NEW_TASK );
|
||||
return intent;
|
||||
}
|
||||
|
||||
public static Intent makeRowidIntent( Context context, long rowid )
|
||||
{
|
||||
Intent intent = makeSelfIntent( context );
|
||||
intent.putExtra( ROWID_EXTRA, rowid );
|
||||
return intent;
|
||||
}
|
||||
|
||||
public static Intent makeGameIDIntent( Context context, int gameID )
|
||||
{
|
||||
Intent intent = makeSelfIntent( context );
|
||||
intent.putExtra( GAMEID_EXTRA, gameID );
|
||||
return intent;
|
||||
}
|
||||
|
||||
public static Intent makeRematchIntent( Context context, CurGameInfo gi,
|
||||
long rowid )
|
||||
{
|
||||
Intent intent = null;
|
||||
|
||||
if ( CurGameInfo.DeviceRole.SERVER_STANDALONE == gi.serverRole ) {
|
||||
intent = makeSelfIntent( context )
|
||||
.putExtra( REMATCH_ROWID_EXTRA, rowid );
|
||||
} else {
|
||||
Utils.notImpl( context );
|
||||
}
|
||||
|
||||
return intent;
|
||||
}
|
||||
|
||||
public static Intent makeAlertIntent( Context context, String msg )
|
||||
{
|
||||
Intent intent = makeSelfIntent( context );
|
||||
intent.putExtra( ALERT_MSG, msg );
|
||||
return intent;
|
||||
}
|
||||
|
||||
public static void openGame( Context context, Uri data )
|
||||
{
|
||||
Intent intent = makeSelfIntent( context );
|
||||
intent.setData( data );
|
||||
context.startActivity( intent );
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -170,7 +170,7 @@ public class MultiService {
|
|||
SMSService.onGameDictDownload( context, intent );
|
||||
break;
|
||||
case OWNER_RELAY:
|
||||
GamesList.onGameDictDownload( context, intent );
|
||||
GamesListActivity.onGameDictDownload( context, intent );
|
||||
break;
|
||||
default:
|
||||
DbgUtils.logf( "unexpected OWNER" );
|
||||
|
@ -180,4 +180,4 @@ public class MultiService {
|
|||
return downloaded;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -378,7 +378,7 @@ public class RelayService extends XWService
|
|||
|
||||
private void setupNotification( long rowid )
|
||||
{
|
||||
Intent intent = GamesList.makeRowidIntent( this, rowid );
|
||||
Intent intent = GamesListActivity.makeRowidIntent( this, rowid );
|
||||
String msg = Utils.format( this, R.string.notify_bodyf,
|
||||
GameUtils.getName( this, rowid ) );
|
||||
Utils.postNotification( this, intent, R.string.notify_title,
|
||||
|
@ -579,7 +579,7 @@ public class RelayService extends XWService
|
|||
break;
|
||||
case XWPDEV_ALERT:
|
||||
str = getVLIString( dis );
|
||||
Intent intent = GamesList.makeAlertIntent( this, str );
|
||||
Intent intent = GamesListActivity.makeAlertIntent( this, str );
|
||||
Utils.postNotification( this, intent,
|
||||
R.string.relay_alert_title,
|
||||
str, str.hashCode() );
|
||||
|
|
|
@ -628,7 +628,7 @@ public class SMSService extends XWService {
|
|||
private void postNotification( int gameID, int title, String body,
|
||||
long rowid )
|
||||
{
|
||||
Intent intent = GamesList.makeGameIDIntent( this, gameID );
|
||||
Intent intent = GamesListActivity.makeGameIDIntent( this, gameID );
|
||||
Utils.postNotification( this, intent, title, body, (int)rowid );
|
||||
}
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ public class XWExpandableListActivity extends ExpandableListActivity
|
|||
protected void showConfirmThen( int msg, int posButton, Action action,
|
||||
Object... params )
|
||||
{
|
||||
m_delegate.showConfirmThen( getString(msg), posButton, action, params );
|
||||
m_delegate.showConfirmThen( msg, posButton, action, params );
|
||||
}
|
||||
|
||||
// DlgDelegate.DlgClickNotify interface
|
||||
|
|
|
@ -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}.GamesList
|
||||
adb shell am start -n org.eehouse.android.${PKG}/org.eehouse.android.${PKG}.GamesListActivity
|
||||
fi
|
||||
|
|
|
@ -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}.GamesList
|
||||
-n org.eehouse.android.${PKG}/org.eehouse.android.${PKG}.GamesListActivity
|
||||
COUNT=$((COUNT+1))
|
||||
done
|
||||
|
||||
|
|
Loading…
Reference in a new issue