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,9 +79,11 @@ 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 )
|
||||||
{
|
{
|
||||||
Intent intent = new Intent( activity, RelayInviteActivity.class );
|
if ( BuildConfig.RELAYINVITE_SUPPORTED ) {
|
||||||
intent.putExtra( INTENT_KEY_NMISSING, nMissing );
|
Intent intent = new Intent( activity, RelayInviteActivity.class );
|
||||||
activity.startActivityForResult( intent, requestCode.ordinal() );
|
intent.putExtra( INTENT_KEY_NMISSING, nMissing );
|
||||||
|
activity.startActivityForResult( intent, requestCode.ordinal() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public RelayInviteDelegate( Delegator delegator, Bundle savedInstanceState )
|
public RelayInviteDelegate( Delegator delegator, Bundle savedInstanceState )
|
||||||
|
@ -92,59 +94,63 @@ public class RelayInviteDelegate extends InviteDelegate {
|
||||||
|
|
||||||
protected void init( Bundle savedInstanceState )
|
protected void init( Bundle savedInstanceState )
|
||||||
{
|
{
|
||||||
String msg = getString( R.string.button_invite );
|
if ( BuildConfig.RELAYINVITE_SUPPORTED ) {
|
||||||
msg = getQuantityString( R.plurals.invite_relay_desc_fmt, m_nMissing,
|
String msg = getString( R.string.button_invite );
|
||||||
m_nMissing, msg );
|
msg = getQuantityString( R.plurals.invite_relay_desc_fmt, m_nMissing,
|
||||||
super.init( msg, R.string.empty_relay_inviter );
|
m_nMissing, msg );
|
||||||
addButtonBar( R.layout.relay_buttons, BUTTONIDS );
|
super.init( msg, R.string.empty_relay_inviter );
|
||||||
|
addButtonBar( R.layout.relay_buttons, BUTTONIDS );
|
||||||
|
|
||||||
// getBundledData( savedInstanceState );
|
// getBundledData( savedInstanceState );
|
||||||
|
|
||||||
// m_addButton = (ImageButton)findViewById( R.id.manual_add_button );
|
// m_addButton = (ImageButton)findViewById( R.id.manual_add_button );
|
||||||
// m_addButton.setOnClickListener( new View.OnClickListener() {
|
// m_addButton.setOnClickListener( new View.OnClickListener() {
|
||||||
// public void onClick( View view )
|
// public void onClick( View view )
|
||||||
// {
|
// {
|
||||||
// showDialog( DlgID.GET_NUMBER );
|
// showDialog( DlgID.GET_NUMBER );
|
||||||
// }
|
// }
|
||||||
// } );
|
// } );
|
||||||
|
|
||||||
// if ( XWPrefs.getRelayInviteToSelfEnabled( m_activity ) ) {
|
// if ( XWPrefs.getRelayInviteToSelfEnabled( m_activity ) ) {
|
||||||
// ImageButton addMe = (ImageButton)findViewById( R.id.add_self_button );
|
// ImageButton addMe = (ImageButton)findViewById( R.id.add_self_button );
|
||||||
// addMe.setVisibility( View.VISIBLE );
|
// addMe.setVisibility( View.VISIBLE );
|
||||||
// addMe.setOnClickListener( new View.OnClickListener() {
|
// addMe.setOnClickListener( new View.OnClickListener() {
|
||||||
// public void onClick( View view ) {
|
// public void onClick( View view ) {
|
||||||
// int devIDInt = DevID.getRelayDevIDInt( m_activity );
|
// int devIDInt = DevID.getRelayDevIDInt( m_activity );
|
||||||
// String devID = String.format( "%d", devIDInt );
|
// String devID = String.format( "%d", devIDInt );
|
||||||
// DevIDRec rec = new DevIDRec( "self", devID );
|
// DevIDRec rec = new DevIDRec( "self", devID );
|
||||||
// addChecked( rec );
|
// addChecked( rec );
|
||||||
// saveAndRebuild();
|
// saveAndRebuild();
|
||||||
// }
|
// }
|
||||||
// } );
|
// } );
|
||||||
// }
|
// }
|
||||||
|
|
||||||
getSavedState();
|
getSavedState();
|
||||||
rebuildList( true );
|
rebuildList( true );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onBarButtonClicked( int id )
|
protected void onBarButtonClicked( int id )
|
||||||
{
|
{
|
||||||
switch( id ) {
|
if ( BuildConfig.RELAYINVITE_SUPPORTED ) {
|
||||||
case R.id.button_relay_add:
|
switch( id ) {
|
||||||
Utils.notImpl( m_activity );
|
case R.id.button_relay_add:
|
||||||
break;
|
Utils.notImpl( m_activity );
|
||||||
case R.id.manual_add_button:
|
break;
|
||||||
showDialogFragment( DlgID.GET_NUMBER );
|
case R.id.manual_add_button:
|
||||||
break;
|
showDialogFragment( DlgID.GET_NUMBER );
|
||||||
case R.id.button_clear:
|
break;
|
||||||
int count = getChecked().size();
|
case R.id.button_clear:
|
||||||
String msg = getQuantityString( R.plurals.confirm_clear_relay_fmt,
|
int count = getChecked().size();
|
||||||
count, count );
|
String msg = getQuantityString( R.plurals.confirm_clear_relay_fmt,
|
||||||
makeConfirmThenBuilder( msg, Action.CLEAR_ACTION ).show();
|
count, count );
|
||||||
break;
|
makeConfirmThenBuilder( msg, Action.CLEAR_ACTION ).show();
|
||||||
case R.id.button_edit:
|
break;
|
||||||
showDialogFragment( DlgID.GET_NUMBER, getChecked().iterator().next() );
|
case R.id.button_edit:
|
||||||
break;
|
showDialogFragment( DlgID.GET_NUMBER, getChecked().iterator().next() );
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,52 +184,54 @@ 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;
|
||||||
DialogInterface.OnClickListener lstnr;
|
if ( BuildConfig.RELAYINVITE_SUPPORTED ) {
|
||||||
switch( alert.getDlgID() ) {
|
DialogInterface.OnClickListener lstnr;
|
||||||
case GET_NUMBER: {
|
switch( alert.getDlgID() ) {
|
||||||
final DevIDRec curRec =
|
case GET_NUMBER: {
|
||||||
1 <= params.length && params[0] instanceof DevIDRec
|
final DevIDRec curRec =
|
||||||
? (DevIDRec)params[0] : null;
|
1 <= params.length && params[0] instanceof DevIDRec
|
||||||
final View getNumView = inflate( R.layout.get_relay );
|
? (DevIDRec)params[0] : null;
|
||||||
final EditText numField = (EditText)
|
final View getNumView = inflate( R.layout.get_relay );
|
||||||
getNumView.findViewById( R.id.num_field );
|
final EditText numField = (EditText)
|
||||||
numField.setKeyListener(DigitsKeyListener.getInstance());
|
getNumView.findViewById( R.id.num_field );
|
||||||
final EditText nameField = (EditText)
|
numField.setKeyListener(DigitsKeyListener.getInstance());
|
||||||
getNumView.findViewById( R.id.name_field );
|
final EditText nameField = (EditText)
|
||||||
if ( null != curRec ) {
|
getNumView.findViewById( R.id.name_field );
|
||||||
numField.setText( curRec.m_devID );
|
if ( null != curRec ) {
|
||||||
nameField.setText( curRec.m_opponent );
|
numField.setText( curRec.m_devID );
|
||||||
}
|
nameField.setText( curRec.m_opponent );
|
||||||
lstnr = new DialogInterface.OnClickListener() {
|
}
|
||||||
public void onClick( DialogInterface dlg, int item ) {
|
lstnr = new DialogInterface.OnClickListener() {
|
||||||
String number = numField.getText().toString();
|
public void onClick( DialogInterface dlg, int item ) {
|
||||||
if ( null != number && 0 < number.length() ) {
|
String number = numField.getText().toString();
|
||||||
String name = nameField.getText().toString();
|
if ( null != number && 0 < number.length() ) {
|
||||||
if ( curRec != null ) {
|
String name = nameField.getText().toString();
|
||||||
curRec.m_opponent = name;
|
if ( curRec != null ) {
|
||||||
curRec.m_devID = number;
|
curRec.m_opponent = name;
|
||||||
} else {
|
curRec.m_devID = number;
|
||||||
DevIDRec rec = new DevIDRec( name, number );
|
} else {
|
||||||
m_devIDRecs.add( rec );
|
DevIDRec rec = new DevIDRec( name, number );
|
||||||
clearChecked();
|
m_devIDRecs.add( rec );
|
||||||
onItemChecked( rec, true );
|
clearChecked();
|
||||||
|
onItemChecked( rec, true );
|
||||||
|
}
|
||||||
|
saveAndRebuild();
|
||||||
}
|
}
|
||||||
saveAndRebuild();
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
};
|
dialog = makeAlertBuilder()
|
||||||
dialog = makeAlertBuilder()
|
.setTitle( R.string.get_sms_title )
|
||||||
.setTitle( R.string.get_sms_title )
|
.setView( getNumView )
|
||||||
.setView( getNumView )
|
.setPositiveButton( android.R.string.ok, lstnr )
|
||||||
.setPositiveButton( android.R.string.ok, lstnr )
|
.setNegativeButton( android.R.string.cancel, null )
|
||||||
.setNegativeButton( android.R.string.cancel, null )
|
.create();
|
||||||
.create();
|
}
|
||||||
}
|
break;
|
||||||
break;
|
default:
|
||||||
default:
|
dialog = super.makeDialog( alert, params );
|
||||||
dialog = super.makeDialog( alert, params );
|
break;
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
@ -322,15 +330,17 @@ public class RelayInviteDelegate extends InviteDelegate {
|
||||||
@Override
|
@Override
|
||||||
protected void tryEnable()
|
protected void tryEnable()
|
||||||
{
|
{
|
||||||
super.tryEnable();
|
if ( BuildConfig.RELAYINVITE_SUPPORTED ) {
|
||||||
|
super.tryEnable();
|
||||||
|
|
||||||
Button button = (Button)findViewById( R.id.button_clear );
|
Button button = (Button)findViewById( R.id.button_clear );
|
||||||
if ( null != button ) { // may not be there yet
|
if ( null != button ) { // may not be there yet
|
||||||
button.setEnabled( 0 < getChecked().size() );
|
button.setEnabled( 0 < getChecked().size() );
|
||||||
}
|
}
|
||||||
button = (Button)findViewById( R.id.button_edit );
|
button = (Button)findViewById( R.id.button_edit );
|
||||||
if ( null != button ) {
|
if ( null != button ) {
|
||||||
button.setEnabled( 1 == getChecked().size() );
|
button.setEnabled( 1 == getChecked().size() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,16 +349,18 @@ public class RelayInviteDelegate extends InviteDelegate {
|
||||||
public boolean onPosButton( Action action, Object[] params )
|
public boolean onPosButton( Action action, Object[] params )
|
||||||
{
|
{
|
||||||
boolean handled = true;
|
boolean handled = true;
|
||||||
switch( action ) {
|
if ( BuildConfig.RELAYINVITE_SUPPORTED ) {
|
||||||
case CLEAR_ACTION:
|
switch( action ) {
|
||||||
clearSelectedImpl();
|
case CLEAR_ACTION:
|
||||||
break;
|
clearSelectedImpl();
|
||||||
case USE_IMMOBILE_ACTION:
|
break;
|
||||||
m_immobileConfirmed = true;
|
case USE_IMMOBILE_ACTION:
|
||||||
break;
|
m_immobileConfirmed = true;
|
||||||
default:
|
break;
|
||||||
handled = super.onPosButton( action, params );
|
default:
|
||||||
break;
|
handled = super.onPosButton( action, params );
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
@ -357,13 +369,15 @@ 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 ( Action.USE_IMMOBILE_ACTION == action && m_immobileConfirmed ) {
|
if ( BuildConfig.RELAYINVITE_SUPPORTED ) {
|
||||||
makeConfirmThenBuilder( R.string.warn_unlimited,
|
if ( Action.USE_IMMOBILE_ACTION == action && m_immobileConfirmed ) {
|
||||||
Action.POST_WARNING_ACTION )
|
makeConfirmThenBuilder( R.string.warn_unlimited,
|
||||||
.setPosButton( R.string.button_yes )
|
Action.POST_WARNING_ACTION )
|
||||||
.show();
|
.setPosButton( R.string.button_yes )
|
||||||
} else {
|
.show();
|
||||||
handled = false;
|
} else {
|
||||||
|
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