From c041792f837f87d419632bd585241725fb04c8f6 Mon Sep 17 00:00:00 2001 From: Eric House Date: Mon, 3 Dec 2012 08:03:00 -0800 Subject: [PATCH] move methods toward better encapsualtion (no behavior change) --- .../eehouse/android/xw4/BTInviteActivity.java | 8 ++++++++ .../org/eehouse/android/xw4/BoardActivity.java | 8 ++++---- .../src/org/eehouse/android/xw4/GameUtils.java | 16 ---------------- .../org/eehouse/android/xw4/InviteActivity.java | 2 +- .../org/eehouse/android/xw4/NewGameActivity.java | 4 ++-- .../eehouse/android/xw4/SMSInviteActivity.java | 10 +++++++++- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTInviteActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTInviteActivity.java index c6a3297d3..fcfcbd51a 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTInviteActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTInviteActivity.java @@ -45,6 +45,14 @@ public class BTInviteActivity extends InviteActivity private boolean m_firstScan; private int m_checkCount; + public static void launchForResult( Activity activity, int nMissing, + int requestCode ) + { + Intent intent = new Intent( activity, BTInviteActivity.class ); + intent.putExtra( INTENT_KEY_NMISSING, nMissing ); + activity.startActivityForResult( intent, requestCode ); + } + @Override protected void onCreate( Bundle savedInstanceState ) { diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java index 7c01d39f2..64d1c775e 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java @@ -847,12 +847,12 @@ public class BoardActivity extends XWActivity doSyncMenuitem(); break; case BT_PICK_ACTION: - GameUtils.launchBTInviter( this, m_nMissingPlayers, - BT_INVITE_RESULT ); + BTInviteActivity.launchForResult( this, m_nMissingPlayers, + BT_INVITE_RESULT ); break; case SMS_PICK_ACTION: - GameUtils.launchSMSInviter( this, m_nMissingPlayers, - SMS_INVITE_RESULT ); + SMSInviteActivity.launchForResult( this, m_nMissingPlayers, + SMS_INVITE_RESULT ); break; case SMS_CONFIG_ACTION: Utils.launchSettings( 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 19317bf77..9a291d1b8 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java @@ -508,22 +508,6 @@ public class GameUtils { nPlayersH, null, gameID, isHost ); } - public static void launchBTInviter( Activity activity, int nMissing, - int requestCode ) - { - Intent intent = new Intent( activity, BTInviteActivity.class ); - intent.putExtra( BTInviteActivity.INTENT_KEY_NMISSING, nMissing ); - activity.startActivityForResult( intent, requestCode ); - } - - public static void launchSMSInviter( Activity activity, int nMissing, - int requestCode ) - { - Intent intent = new Intent( activity, SMSInviteActivity.class ); - intent.putExtra( SMSInviteActivity.INTENT_KEY_NMISSING, nMissing ); - activity.startActivityForResult( intent, requestCode ); - } - public static void launchInviteActivity( Context context, boolean choseEmail, String room, String inviteID, diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/InviteActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/InviteActivity.java index 1a5c803f0..41dd2ae7c 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/InviteActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/InviteActivity.java @@ -43,7 +43,7 @@ abstract class InviteActivity extends XWListActivity implements View.OnClickListener { public static final String DEVS = "DEVS"; - public static final String INTENT_KEY_NMISSING = "NMISSING"; + protected static final String INTENT_KEY_NMISSING = "NMISSING"; protected int m_nMissing; protected Button m_okButton; diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameActivity.java index 039aaa23d..85bbccd63 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameActivity.java @@ -357,7 +357,7 @@ public class NewGameActivity extends XWActivity { intent.putExtra( GameUtils.INTENT_FORRESULT_ROWID, true ); startActivityForResult( intent, CONFIG_FOR_BT ); } else { - GameUtils.launchBTInviter( this, 1, INVITE_FOR_BT ); + BTInviteActivity.launchForResult( this, 1, INVITE_FOR_BT ); } } @@ -378,7 +378,7 @@ public class NewGameActivity extends XWActivity { intent.putExtra( GameUtils.INTENT_FORRESULT_ROWID, true ); startActivityForResult( intent, CONFIG_FOR_SMS ); } else { - GameUtils.launchSMSInviter( this, 1, INVITE_FOR_SMS ); + SMSInviteActivity.launchForResult( this, 1, INVITE_FOR_SMS ); } } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSInviteActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSInviteActivity.java index 60a7da3dd..aa955374b 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSInviteActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSInviteActivity.java @@ -32,9 +32,9 @@ import android.os.Bundle; import android.provider.ContactsContract.CommonDataKinds.Phone; import android.provider.ContactsContract.CommonDataKinds; import android.provider.ContactsContract; -import android.text.method.DialerKeyListener; import android.text.Editable; import android.text.TextWatcher; +import android.text.method.DialerKeyListener; import android.view.View; import android.view.ViewGroup; import android.widget.CompoundButton; @@ -64,6 +64,14 @@ public class SMSInviteActivity extends InviteActivity { private String m_pendingNumber; private boolean m_immobileConfirmed; + public static void launchForResult( Activity activity, int nMissing, + int requestCode ) + { + Intent intent = new Intent( activity, SMSInviteActivity.class ); + intent.putExtra( INTENT_KEY_NMISSING, nMissing ); + activity.startActivityForResult( intent, requestCode ); + } + @Override protected void onCreate( Bundle savedInstanceState ) {