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