mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-04 23:02:02 +01:00
break part of BoardActivity out into BoardDelegate (and make a bunch of little changes that required)
This commit is contained in:
parent
609962df58
commit
558d34bc98
11 changed files with 2363 additions and 2140 deletions
|
@ -481,7 +481,7 @@ public class BTService extends XWService {
|
||||||
host.getAddress() );
|
host.getAddress() );
|
||||||
|
|
||||||
for ( long rowid : rowids ) {
|
for ( long rowid : rowids ) {
|
||||||
if ( BoardActivity.feedMessage( gameID, buffer, addr ) ) {
|
if ( BoardDelegate.feedMessage( gameID, buffer, addr ) ) {
|
||||||
// do nothing
|
// do nothing
|
||||||
} else if ( haveGame &&
|
} else if ( haveGame &&
|
||||||
GameUtils.feedMessage( BTService.this, rowid,
|
GameUtils.feedMessage( BTService.this, rowid,
|
||||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
package org.eehouse.android.xw4;
|
package org.eehouse.android.xw4;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
|
@ -58,7 +59,7 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
|
||||||
private int m_layoutHeight;
|
private int m_layoutHeight;
|
||||||
private BoardCanvas m_canvas; // owns the bitmap
|
private BoardCanvas m_canvas; // owns the bitmap
|
||||||
private JNIThread m_jniThread;
|
private JNIThread m_jniThread;
|
||||||
private XWActivity m_parent;
|
private Activity m_parent;
|
||||||
private boolean m_measuredFromDims = false;
|
private boolean m_measuredFromDims = false;
|
||||||
private BoardDims m_dims;
|
private BoardDims m_dims;
|
||||||
private CommsAddrRec.CommsConnType m_connType =
|
private CommsAddrRec.CommsConnType m_connType =
|
||||||
|
@ -257,7 +258,7 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
|
||||||
} // layoutBoardOnce
|
} // layoutBoardOnce
|
||||||
|
|
||||||
// BoardHandler interface implementation
|
// BoardHandler interface implementation
|
||||||
public void startHandling( XWActivity parent, JNIThread thread,
|
public void startHandling( Activity parent, JNIThread thread,
|
||||||
int gamePtr, CurGameInfo gi,
|
int gamePtr, CurGameInfo gi,
|
||||||
CommsAddrRec.CommsConnType connType )
|
CommsAddrRec.CommsConnType connType )
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,7 +27,9 @@ import org.eehouse.android.xw4.DlgDelegate.Action;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
|
|
||||||
public class DelegateBase implements DlgDelegate.DlgClickNotify {
|
public class DelegateBase implements DlgDelegate.DlgClickNotify,
|
||||||
|
DlgDelegate.HasDlgDelegate,
|
||||||
|
MultiService.MultiEventListener {
|
||||||
|
|
||||||
private DlgDelegate m_delegate;
|
private DlgDelegate m_delegate;
|
||||||
|
|
||||||
|
@ -52,17 +54,27 @@ public class DelegateBase implements DlgDelegate.DlgClickNotify {
|
||||||
m_delegate.showNotAgainDlgThen( msgID, prefsKey, action, params );
|
m_delegate.showNotAgainDlgThen( msgID, prefsKey, action, params );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void showNotAgainDlgThen( int msgID, int prefsKey,
|
public void showNotAgainDlgThen( int msgID, int prefsKey, Action action )
|
||||||
Action action )
|
|
||||||
{
|
{
|
||||||
m_delegate.showNotAgainDlgThen( msgID, prefsKey, action );
|
m_delegate.showNotAgainDlgThen( msgID, prefsKey, action );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void showNotAgainDlgThen( String msg, int prefsKey,
|
||||||
|
Action action )
|
||||||
|
{
|
||||||
|
m_delegate.showNotAgainDlgThen( msg, prefsKey, action, null );
|
||||||
|
}
|
||||||
|
|
||||||
protected void showNotAgainDlg( int msgID, int prefsKey )
|
protected void showNotAgainDlg( int msgID, int prefsKey )
|
||||||
{
|
{
|
||||||
m_delegate.showNotAgainDlgThen( msgID, prefsKey );
|
m_delegate.showNotAgainDlgThen( msgID, prefsKey );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void showNotAgainDlgThen( int msgID, int prefsKey )
|
||||||
|
{
|
||||||
|
m_delegate.showNotAgainDlgThen( msgID, prefsKey );
|
||||||
|
}
|
||||||
|
|
||||||
// It sucks that these must be duplicated here and XWActivity
|
// It sucks that these must be duplicated here and XWActivity
|
||||||
protected void showAboutDialog()
|
protected void showAboutDialog()
|
||||||
{
|
{
|
||||||
|
@ -96,6 +108,11 @@ public class DelegateBase implements DlgDelegate.DlgClickNotify {
|
||||||
m_delegate.showConfirmThen( msg, posButton, action, params );
|
m_delegate.showConfirmThen( msg, posButton, action, params );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void showConfirmThen( int msgID, Action action )
|
||||||
|
{
|
||||||
|
m_delegate.showConfirmThen( msgID, action );
|
||||||
|
}
|
||||||
|
|
||||||
protected boolean post( Runnable runnable )
|
protected boolean post( Runnable runnable )
|
||||||
{
|
{
|
||||||
return m_delegate.post( runnable );
|
return m_delegate.post( runnable );
|
||||||
|
@ -116,6 +133,34 @@ public class DelegateBase implements DlgDelegate.DlgClickNotify {
|
||||||
m_delegate.launchLookup( words, lang, false );
|
m_delegate.launchLookup( words, lang, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void showInviteChoicesThen( Action action )
|
||||||
|
{
|
||||||
|
m_delegate.showInviteChoicesThen( action );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void startProgress( int id )
|
||||||
|
{
|
||||||
|
m_delegate.startProgress( id );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void stopProgress()
|
||||||
|
{
|
||||||
|
m_delegate.stopProgress();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void showDictGoneFinish()
|
||||||
|
{
|
||||||
|
m_delegate.showDictGoneFinish();
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
// MultiService.MultiEventListener interface
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
public void eventOccurred( MultiService.MultiEvent event, final Object ... args )
|
||||||
|
{
|
||||||
|
Assert.fail();
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// DlgDelegate.DlgClickNotify interface
|
// DlgDelegate.DlgClickNotify interface
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -111,6 +111,7 @@ public class DlgDelegate {
|
||||||
public interface HasDlgDelegate {
|
public interface HasDlgDelegate {
|
||||||
void showOKOnlyDialog( int msgID );
|
void showOKOnlyDialog( int msgID );
|
||||||
void showOKOnlyDialog( String msg );
|
void showOKOnlyDialog( String msg );
|
||||||
|
void showNotAgainDlgThen( int msgID, int prefsKey, Action action );
|
||||||
}
|
}
|
||||||
|
|
||||||
private Activity m_activity;
|
private Activity m_activity;
|
||||||
|
@ -270,6 +271,12 @@ public class DlgDelegate {
|
||||||
showConfirmThen( msg, R.string.button_ok, action, null );
|
showConfirmThen( msg, R.string.button_ok, action, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void showConfirmThen( int msgID, Action action )
|
||||||
|
{
|
||||||
|
showConfirmThen( m_activity.getString( msgID ),
|
||||||
|
R.string.button_ok, action, null );
|
||||||
|
}
|
||||||
|
|
||||||
public void showConfirmThen( String msg, Action action, Object[] params )
|
public void showConfirmThen( String msg, Action action, Object[] params )
|
||||||
{
|
{
|
||||||
showConfirmThen( msg, R.string.button_ok, action, params );
|
showConfirmThen( msg, R.string.button_ok, action, params );
|
||||||
|
|
|
@ -853,7 +853,7 @@ public class RelayService extends XWService
|
||||||
{
|
{
|
||||||
DbgUtils.logf( "RelayService::feedMessage: %d bytes for rowid %d",
|
DbgUtils.logf( "RelayService::feedMessage: %d bytes for rowid %d",
|
||||||
msg.length, rowid );
|
msg.length, rowid );
|
||||||
if ( BoardActivity.feedMessage( rowid, msg ) ) {
|
if ( BoardDelegate.feedMessage( rowid, msg ) ) {
|
||||||
DbgUtils.logf( "feedMessage: board ate it" );
|
DbgUtils.logf( "feedMessage: board ate it" );
|
||||||
// do nothing
|
// do nothing
|
||||||
} else {
|
} else {
|
||||||
|
@ -893,7 +893,7 @@ public class RelayService extends XWService
|
||||||
// if game has messages, open it and feed 'em to it.
|
// if game has messages, open it and feed 'em to it.
|
||||||
if ( null != forOne ) {
|
if ( null != forOne ) {
|
||||||
sink.setRowID( rowIDs[ii] );
|
sink.setRowID( rowIDs[ii] );
|
||||||
if ( BoardActivity.feedMessages( rowIDs[ii], forOne )
|
if ( BoardDelegate.feedMessages( rowIDs[ii], forOne )
|
||||||
|| GameUtils.feedMessages( this, rowIDs[ii],
|
|| GameUtils.feedMessages( this, rowIDs[ii],
|
||||||
forOne, null,
|
forOne, null,
|
||||||
sink ) ) {
|
sink ) ) {
|
||||||
|
|
|
@ -610,7 +610,7 @@ public class SMSService extends XWService {
|
||||||
sendDiedPacket( addr.sms_phone, gameID );
|
sendDiedPacket( addr.sms_phone, gameID );
|
||||||
} else {
|
} else {
|
||||||
for ( long rowid : rowids ) {
|
for ( long rowid : rowids ) {
|
||||||
if ( BoardActivity.feedMessage( gameID, msg, addr ) ) {
|
if ( BoardDelegate.feedMessage( gameID, msg, addr ) ) {
|
||||||
// do nothing
|
// do nothing
|
||||||
} else {
|
} else {
|
||||||
SMSMsgSink sink = new SMSMsgSink( this );
|
SMSMsgSink sink = new SMSMsgSink( this );
|
||||||
|
|
|
@ -29,6 +29,7 @@ import android.widget.LinearLayout;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
|
|
||||||
import org.eehouse.android.xw4.DlgDelegate.Action;
|
import org.eehouse.android.xw4.DlgDelegate.Action;
|
||||||
|
import org.eehouse.android.xw4.DlgDelegate.HasDlgDelegate;
|
||||||
import org.eehouse.android.xw4.jni.*;
|
import org.eehouse.android.xw4.jni.*;
|
||||||
|
|
||||||
public class Toolbar {
|
public class Toolbar {
|
||||||
|
@ -71,7 +72,8 @@ public class Toolbar {
|
||||||
new TBButtonInfo( R.id.values_button_horizontal ),
|
new TBButtonInfo( R.id.values_button_horizontal ),
|
||||||
};
|
};
|
||||||
|
|
||||||
private XWActivity m_activity;
|
private Activity m_activity;
|
||||||
|
private DlgDelegate.HasDlgDelegate m_dlgDlgt;
|
||||||
private View m_me;
|
private View m_me;
|
||||||
|
|
||||||
private enum ORIENTATION { ORIENT_UNKNOWN,
|
private enum ORIENTATION { ORIENT_UNKNOWN,
|
||||||
|
@ -80,9 +82,10 @@ public class Toolbar {
|
||||||
};
|
};
|
||||||
private ORIENTATION m_curOrient = ORIENTATION.ORIENT_UNKNOWN;
|
private ORIENTATION m_curOrient = ORIENTATION.ORIENT_UNKNOWN;
|
||||||
|
|
||||||
public Toolbar( XWActivity activity, int id )
|
public Toolbar( Activity activity, HasDlgDelegate dlgDlgt, int id )
|
||||||
{
|
{
|
||||||
m_activity = activity;
|
m_activity = activity;
|
||||||
|
m_dlgDlgt = dlgDlgt;
|
||||||
m_me = activity.findViewById( id );
|
m_me = activity.findViewById( id );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +125,7 @@ public class Toolbar {
|
||||||
{
|
{
|
||||||
View.OnClickListener listener = new View.OnClickListener() {
|
View.OnClickListener listener = new View.OnClickListener() {
|
||||||
public void onClick( View view ) {
|
public void onClick( View view ) {
|
||||||
m_activity.showNotAgainDlgThen( msgID, prefsKey, action );
|
m_dlgDlgt.showNotAgainDlgThen( msgID, prefsKey, action );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
setListener( index, listener );
|
setListener( index, listener );
|
||||||
|
@ -133,7 +136,7 @@ public class Toolbar {
|
||||||
{
|
{
|
||||||
View.OnLongClickListener listener = new View.OnLongClickListener() {
|
View.OnLongClickListener listener = new View.OnLongClickListener() {
|
||||||
public boolean onLongClick( View view ) {
|
public boolean onLongClick( View view ) {
|
||||||
m_activity.showNotAgainDlgThen( msgID, prefsKey, action );
|
m_dlgDlgt.showNotAgainDlgThen( msgID, prefsKey, action );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -115,8 +115,7 @@ public class XWActivity extends Activity
|
||||||
m_delegate.showNotAgainDlgThen( msg, prefsKey, action, null );
|
m_delegate.showNotAgainDlgThen( msg, prefsKey, action, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void showNotAgainDlgThen( int msgID, int prefsKey,
|
public void showNotAgainDlgThen( int msgID, int prefsKey, Action action )
|
||||||
Action action )
|
|
||||||
{
|
{
|
||||||
m_delegate.showNotAgainDlgThen( msgID, prefsKey, action );
|
m_delegate.showNotAgainDlgThen( msgID, prefsKey, action );
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,12 +20,12 @@
|
||||||
|
|
||||||
package org.eehouse.android.xw4.jni;
|
package org.eehouse.android.xw4.jni;
|
||||||
|
|
||||||
import org.eehouse.android.xw4.XWActivity;
|
import android.app.Activity;
|
||||||
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType;
|
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType;
|
||||||
|
|
||||||
public interface BoardHandler {
|
public interface BoardHandler {
|
||||||
|
|
||||||
void startHandling( XWActivity parent, JNIThread thread,
|
void startHandling( Activity parent, JNIThread thread,
|
||||||
int gamePtr, CurGameInfo gi,
|
int gamePtr, CurGameInfo gi,
|
||||||
CommsConnType connType );
|
CommsConnType connType );
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue