mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-22 07:28:16 +01:00
comment out code with RELAYINVITE_SUPPORTED
Relay-invite code may never be released, so wrap it in compile-time test that'll get it stripped.
This commit is contained in:
parent
101c2ff8f2
commit
9a394b2541
1 changed files with 225 additions and 211 deletions
|
@ -79,10 +79,12 @@ public class RelayInviteDelegate extends InviteDelegate {
|
||||||
public static void launchForResult( Activity activity, int nMissing,
|
public static void launchForResult( Activity activity, int nMissing,
|
||||||
RequestCode requestCode )
|
RequestCode requestCode )
|
||||||
{
|
{
|
||||||
|
if ( BuildConfig.RELAYINVITE_SUPPORTED ) {
|
||||||
Intent intent = new Intent( activity, RelayInviteActivity.class );
|
Intent intent = new Intent( activity, RelayInviteActivity.class );
|
||||||
intent.putExtra( INTENT_KEY_NMISSING, nMissing );
|
intent.putExtra( INTENT_KEY_NMISSING, nMissing );
|
||||||
activity.startActivityForResult( intent, requestCode.ordinal() );
|
activity.startActivityForResult( intent, requestCode.ordinal() );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public RelayInviteDelegate( Delegator delegator, Bundle savedInstanceState )
|
public RelayInviteDelegate( Delegator delegator, Bundle savedInstanceState )
|
||||||
{
|
{
|
||||||
|
@ -92,6 +94,7 @@ public class RelayInviteDelegate extends InviteDelegate {
|
||||||
|
|
||||||
protected void init( Bundle savedInstanceState )
|
protected void init( Bundle savedInstanceState )
|
||||||
{
|
{
|
||||||
|
if ( BuildConfig.RELAYINVITE_SUPPORTED ) {
|
||||||
String msg = getString( R.string.button_invite );
|
String msg = getString( R.string.button_invite );
|
||||||
msg = getQuantityString( R.plurals.invite_relay_desc_fmt, m_nMissing,
|
msg = getQuantityString( R.plurals.invite_relay_desc_fmt, m_nMissing,
|
||||||
m_nMissing, msg );
|
m_nMissing, msg );
|
||||||
|
@ -125,10 +128,12 @@ public class RelayInviteDelegate extends InviteDelegate {
|
||||||
getSavedState();
|
getSavedState();
|
||||||
rebuildList( true );
|
rebuildList( true );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onBarButtonClicked( int id )
|
protected void onBarButtonClicked( int id )
|
||||||
{
|
{
|
||||||
|
if ( BuildConfig.RELAYINVITE_SUPPORTED ) {
|
||||||
switch( id ) {
|
switch( id ) {
|
||||||
case R.id.button_relay_add:
|
case R.id.button_relay_add:
|
||||||
Utils.notImpl( m_activity );
|
Utils.notImpl( m_activity );
|
||||||
|
@ -147,6 +152,7 @@ public class RelayInviteDelegate extends InviteDelegate {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// protected void onSaveInstanceState( Bundle outState )
|
// protected void onSaveInstanceState( Bundle outState )
|
||||||
// {
|
// {
|
||||||
|
@ -178,7 +184,8 @@ public class RelayInviteDelegate extends InviteDelegate {
|
||||||
@Override
|
@Override
|
||||||
protected Dialog makeDialog( DBAlert alert, Object[] params )
|
protected Dialog makeDialog( DBAlert alert, Object[] params )
|
||||||
{
|
{
|
||||||
Dialog dialog;
|
Dialog dialog = null;
|
||||||
|
if ( BuildConfig.RELAYINVITE_SUPPORTED ) {
|
||||||
DialogInterface.OnClickListener lstnr;
|
DialogInterface.OnClickListener lstnr;
|
||||||
switch( alert.getDlgID() ) {
|
switch( alert.getDlgID() ) {
|
||||||
case GET_NUMBER: {
|
case GET_NUMBER: {
|
||||||
|
@ -225,6 +232,7 @@ public class RelayInviteDelegate extends InviteDelegate {
|
||||||
dialog = super.makeDialog( alert, params );
|
dialog = super.makeDialog( alert, params );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,6 +330,7 @@ public class RelayInviteDelegate extends InviteDelegate {
|
||||||
@Override
|
@Override
|
||||||
protected void tryEnable()
|
protected void tryEnable()
|
||||||
{
|
{
|
||||||
|
if ( BuildConfig.RELAYINVITE_SUPPORTED ) {
|
||||||
super.tryEnable();
|
super.tryEnable();
|
||||||
|
|
||||||
Button button = (Button)findViewById( R.id.button_clear );
|
Button button = (Button)findViewById( R.id.button_clear );
|
||||||
|
@ -333,12 +342,14 @@ public class RelayInviteDelegate extends InviteDelegate {
|
||||||
button.setEnabled( 1 == getChecked().size() );
|
button.setEnabled( 1 == getChecked().size() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// DlgDelegate.DlgClickNotify interface
|
// DlgDelegate.DlgClickNotify interface
|
||||||
@Override
|
@Override
|
||||||
public boolean onPosButton( Action action, Object[] params )
|
public boolean onPosButton( Action action, Object[] params )
|
||||||
{
|
{
|
||||||
boolean handled = true;
|
boolean handled = true;
|
||||||
|
if ( BuildConfig.RELAYINVITE_SUPPORTED ) {
|
||||||
switch( action ) {
|
switch( action ) {
|
||||||
case CLEAR_ACTION:
|
case CLEAR_ACTION:
|
||||||
clearSelectedImpl();
|
clearSelectedImpl();
|
||||||
|
@ -350,6 +361,7 @@ public class RelayInviteDelegate extends InviteDelegate {
|
||||||
handled = super.onPosButton( action, params );
|
handled = super.onPosButton( action, params );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -357,6 +369,7 @@ public class RelayInviteDelegate extends InviteDelegate {
|
||||||
public boolean onDismissed( Action action, Object[] params )
|
public boolean onDismissed( Action action, Object[] params )
|
||||||
{
|
{
|
||||||
boolean handled = true;
|
boolean handled = true;
|
||||||
|
if ( BuildConfig.RELAYINVITE_SUPPORTED ) {
|
||||||
if ( Action.USE_IMMOBILE_ACTION == action && m_immobileConfirmed ) {
|
if ( Action.USE_IMMOBILE_ACTION == action && m_immobileConfirmed ) {
|
||||||
makeConfirmThenBuilder( R.string.warn_unlimited,
|
makeConfirmThenBuilder( R.string.warn_unlimited,
|
||||||
Action.POST_WARNING_ACTION )
|
Action.POST_WARNING_ACTION )
|
||||||
|
@ -365,6 +378,7 @@ public class RelayInviteDelegate extends InviteDelegate {
|
||||||
} else {
|
} else {
|
||||||
handled = false;
|
handled = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -593,114 +607,114 @@ public class RelayInviteDelegate extends InviteDelegate {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
private class ListOpponentsTask extends AsyncTask<Void, Void, Set<String>> {
|
// private class ListOpponentsTask extends AsyncTask<Void, Void, Set<String>> {
|
||||||
private Context m_context;
|
// private Context m_context;
|
||||||
private String[] m_relayIDs;
|
// private String[] m_relayIDs;
|
||||||
private long[] m_rowIDs;
|
// private long[] m_rowIDs;
|
||||||
|
|
||||||
public ListOpponentsTask( Context context, String[] relayIDs, long[] rowIDs ) {
|
// public ListOpponentsTask( Context context, String[] relayIDs, long[] rowIDs ) {
|
||||||
m_context = context;
|
// m_context = context;
|
||||||
m_relayIDs = relayIDs;
|
// m_relayIDs = relayIDs;
|
||||||
m_rowIDs = rowIDs;
|
// m_rowIDs = rowIDs;
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Override protected Set<String> doInBackground( Void... unused )
|
// @Override protected Set<String> doInBackground( Void... unused )
|
||||||
{
|
// {
|
||||||
Set<String> result = null;
|
// Set<String> result = null;
|
||||||
JSONObject reply = null;
|
// JSONObject reply = null;
|
||||||
try {
|
// try {
|
||||||
startProgress( R.string.fetching_from_relay );
|
// startProgress( R.string.fetching_from_relay );
|
||||||
|
|
||||||
JSONArray ids = new JSONArray();
|
// JSONArray ids = new JSONArray();
|
||||||
for ( String id : m_relayIDs ) {
|
// for ( String id : m_relayIDs ) {
|
||||||
ids.put( id );
|
// ids.put( id );
|
||||||
}
|
// }
|
||||||
JSONObject params = new JSONObject();
|
// JSONObject params = new JSONObject();
|
||||||
params.put( "relayIDs", ids );
|
// params.put( "relayIDs", ids );
|
||||||
params.put( "me", DevID.getRelayDevIDInt( m_activity ) );
|
// params.put( "me", DevID.getRelayDevIDInt( m_activity ) );
|
||||||
Log.i( TAG, "sending to server: %s", params.toString() );
|
// Log.i( TAG, "sending to server: %s", params.toString() );
|
||||||
|
|
||||||
HttpURLConnection conn = NetUtils.makeHttpConn( m_context, "opponentIDsFor" );
|
// HttpURLConnection conn = NetUtils.makeHttpConn( m_context, "opponentIDsFor" );
|
||||||
if ( null != conn ) {
|
// if ( null != conn ) {
|
||||||
String str = NetUtils.runConn( conn, params );
|
// String str = NetUtils.runConn( conn, params );
|
||||||
Log.i( TAG, "got json from server: %s", str );
|
// Log.i( TAG, "got json from server: %s", str );
|
||||||
reply = new JSONObject( str );
|
// reply = new JSONObject( str );
|
||||||
}
|
// }
|
||||||
|
|
||||||
if ( null != reply ) {
|
// if ( null != reply ) {
|
||||||
result = new HashSet<String>();
|
// result = new HashSet<String>();
|
||||||
|
|
||||||
setProgressMsg( R.string.processing_games );
|
// setProgressMsg( R.string.processing_games );
|
||||||
|
|
||||||
JSONArray objs = reply.getJSONArray("devIDs");
|
// JSONArray objs = reply.getJSONArray("devIDs");
|
||||||
for ( int ii = 0; ii < objs.length(); ++ii ) {
|
// for ( int ii = 0; ii < objs.length(); ++ii ) {
|
||||||
JSONObject obj = objs.getJSONObject( ii );
|
// JSONObject obj = objs.getJSONObject( ii );
|
||||||
Iterator<String> keys = obj.keys();
|
// Iterator<String> keys = obj.keys();
|
||||||
Assert.assertTrue( keys.hasNext() );
|
// Assert.assertTrue( keys.hasNext() );
|
||||||
String key = keys.next();
|
// String key = keys.next();
|
||||||
Assert.assertFalse( keys.hasNext() );
|
// Assert.assertFalse( keys.hasNext() );
|
||||||
JSONArray devIDs2 = obj.getJSONArray( key );
|
// JSONArray devIDs2 = obj.getJSONArray( key );
|
||||||
for ( int jj = 0; jj < devIDs2.length(); ++jj ) {
|
// for ( int jj = 0; jj < devIDs2.length(); ++jj ) {
|
||||||
result.add( devIDs2.getString(jj) );
|
// result.add( devIDs2.getString(jj) );
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
} catch ( org.json.JSONException je ) {
|
// } catch ( org.json.JSONException je ) {
|
||||||
Log.ex( TAG, je );
|
// Log.ex( TAG, je );
|
||||||
}
|
// }
|
||||||
|
|
||||||
stopProgress();
|
// stopProgress();
|
||||||
return result;
|
// return result;
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Override protected void onPostExecute( Set<String> devIDs )
|
// @Override protected void onPostExecute( Set<String> devIDs )
|
||||||
{
|
// {
|
||||||
if ( null == devIDs ) {
|
// if ( null == devIDs ) {
|
||||||
Log.w( TAG, "onPostExecute: no results from server?" );
|
// Log.w( TAG, "onPostExecute: no results from server?" );
|
||||||
} else {
|
// } else {
|
||||||
m_devIDRecs = new ArrayList<DevIDRec>(devIDs.size());
|
// m_devIDRecs = new ArrayList<DevIDRec>(devIDs.size());
|
||||||
Iterator<String> iter = devIDs.iterator();
|
// Iterator<String> iter = devIDs.iterator();
|
||||||
while ( iter.hasNext() ) {
|
// while ( iter.hasNext() ) {
|
||||||
String devID = iter.next();
|
// String devID = iter.next();
|
||||||
DevIDRec rec = new DevIDRec( "name", devID );
|
// DevIDRec rec = new DevIDRec( "name", devID );
|
||||||
m_devIDRecs.add( rec );
|
// m_devIDRecs.add( rec );
|
||||||
}
|
// }
|
||||||
|
|
||||||
// m_adapter = new RelayDevsAdapter();
|
// // m_adapter = new RelayDevsAdapter();
|
||||||
// setListAdapter( m_adapter );
|
// // setListAdapter( m_adapter );
|
||||||
// // m_checked.clear();
|
// // // m_checked.clear();
|
||||||
// tryEnable();
|
// // tryEnable();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
private void startProgress( final int msgID )
|
// private void startProgress( final int msgID )
|
||||||
{
|
// {
|
||||||
runOnUiThread( new Runnable() {
|
// runOnUiThread( new Runnable() {
|
||||||
public void run() {
|
// public void run() {
|
||||||
RelayInviteDelegate.this
|
// RelayInviteDelegate.this
|
||||||
.startProgress( R.string.rel_invite_title, msgID );
|
// .startProgress( R.string.rel_invite_title, msgID );
|
||||||
}
|
// }
|
||||||
} );
|
// } );
|
||||||
}
|
// }
|
||||||
|
|
||||||
private void setProgressMsg( final int id )
|
// private void setProgressMsg( final int id )
|
||||||
{
|
// {
|
||||||
runOnUiThread( new Runnable() {
|
// runOnUiThread( new Runnable() {
|
||||||
public void run() {
|
// public void run() {
|
||||||
RelayInviteDelegate.this.setProgressMsg( id );
|
// RelayInviteDelegate.this.setProgressMsg( id );
|
||||||
}
|
// }
|
||||||
} );
|
// } );
|
||||||
}
|
// }
|
||||||
|
|
||||||
private void stopProgress()
|
// private void stopProgress()
|
||||||
{
|
// {
|
||||||
runOnUiThread( new Runnable() {
|
// runOnUiThread( new Runnable() {
|
||||||
public void run() {
|
// public void run() {
|
||||||
RelayInviteDelegate.this.stopProgress();
|
// RelayInviteDelegate.this.stopProgress();
|
||||||
}
|
// }
|
||||||
} );
|
// } );
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue