diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DlgID.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DlgID.java index 0cb5f6c08..8e321818a 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DlgID.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DlgID.java @@ -42,7 +42,6 @@ public enum DlgID { , MOVE_DICT , NAME_GAME , NEW_GROUP - , NO_NAME_FOUND , PLAYER_EDIT , ENABLE_SMS , QUERY_ENDGAME diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameConfigDelegate.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameConfigDelegate.java index 6d413c7c2..6ce9abc75 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameConfigDelegate.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameConfigDelegate.java @@ -60,9 +60,7 @@ import org.eehouse.android.xw4.jni.LocalPlayer; import org.eehouse.android.xw4.jni.XwJNI; public class GameConfigDelegate extends DelegateBase - implements View.OnClickListener - ,XWListItem.DeleteCallback - ,RefreshNamesTask.NoNameFound { + implements View.OnClickListener, XWListItem.DeleteCallback { private static final String TAG = GameConfigDelegate.class.getSimpleName(); private static final String INTENT_FORRESULT_NEWGAME = "newgame"; @@ -73,31 +71,22 @@ public class GameConfigDelegate extends DelegateBase private static final String DIS_MAP = "DIS_MAP"; private Activity m_activity; - private CheckBox m_joinPublicCheck; private CheckBox m_gameLockedCheck; private boolean m_isLocked; private boolean m_haveClosed; - private LinearLayout m_publicRoomsSet; - private LinearLayout m_privateRoomsSet; private CommsConnTypeSet m_conTypes; private Button m_addPlayerButton; private Button m_changeConnButton; private Button m_jugglePlayersButton; - private ImageButton m_refreshRoomsButton; - private View m_connectSetRelay; private Spinner m_dictSpinner; private Spinner m_playerDictSpinner; - private Spinner m_roomChoose; - // private Button m_configureButton; private long m_rowid; private boolean m_isNewGame; private CurGameInfo m_gi; private CurGameInfo m_giOrig; private JNIThread m_jniThread; private int m_whichPlayer; - // private Spinner m_roleSpinner; - // private Spinner m_connectSpinner; private Spinner m_phoniesSpinner; private Spinner m_boardsizeSpinner; private Spinner m_traysizeSpinner; @@ -118,11 +107,6 @@ public class GameConfigDelegate extends DelegateBase R.id.add_player, R.id.lang_spinner, R.id.dict_spinner, - R.id.join_public_room_check, - R.id.room_edit, - R.id.advertise_new_room_check, - R.id.room_spinner, - R.id.refresh_button, R.id.hints_allowed, R.id.duplicate_check, R.id.pick_faceup, @@ -262,18 +246,6 @@ public class GameConfigDelegate extends DelegateBase } ); } break; - case NO_NAME_FOUND: { - String langName = DictLangCache.getLangName( m_activity, - m_gi.dictLang ); - String msg = getString( R.string.no_name_found_fmt, - m_gi.nPlayers, xlateLang( langName ) ); - dialog = makeAlertBuilder() - .setPositiveButton( android.R.string.ok, null ) - // message added below since varies with language etc. - .setMessage( msg ) - .create(); - } - break; case CHANGE_CONN: { CommsConnTypeSet conTypes = (CommsConnTypeSet)params[0]; LinearLayout layout = (LinearLayout)inflate( R.layout.conn_types_display ); @@ -331,8 +303,6 @@ public class GameConfigDelegate extends DelegateBase m_car.populate( m_activity, m_conTypes ); setConnLabel(); - setupRelayStuffIf(); - showHideRelayStuff(); setDisableds(); } }; @@ -510,8 +480,6 @@ public class GameConfigDelegate extends DelegateBase Assert.assertTrue( DBUtils.ROWID_NOTFOUND != m_rowid ); m_isNewGame = args.getBoolean( INTENT_FORRESULT_NEWGAME, false ); - m_connectSetRelay = findViewById( R.id.connect_set_relay ); - m_addPlayerButton = (Button)findViewById(R.id.add_player); m_addPlayerButton.setOnClickListener( this ); m_changeConnButton = (Button)findViewById( R.id.change_connection ); @@ -670,7 +638,6 @@ public class GameConfigDelegate extends DelegateBase } setConnLabel(); - setupRelayStuffIf(); loadPlayersList(); configLangSpinner(); @@ -783,6 +750,7 @@ public class GameConfigDelegate extends DelegateBase } // DeleteCallback interface + @Override public void deleteCalled( XWListItem item ) { if ( m_gi.delete( item.getPosition() ) ) { @@ -790,12 +758,6 @@ public class GameConfigDelegate extends DelegateBase } } - // NoNameFound interface - public void NoNameFound() - { - showDialogFragment( DlgID.NO_NAME_FOUND ); - } - @Override public boolean onPosButton( Action action, Object[] params ) { @@ -859,18 +821,12 @@ public class GameConfigDelegate extends DelegateBase m_gi.juggle(); loadPlayersList(); break; - case R.id.join_public_room_check: - adjustConnectStuff(); - break; case R.id.game_locked_check: makeNotAgainBuilder( R.string.not_again_unlock, R.string.key_notagain_unlock, Action.LOCKED_CHANGE_ACTION ) .show(); break; - case R.id.refresh_button: - refreshNames(); - break; case R.id.change_connection: showConnAfterCheck(); break; @@ -1024,8 +980,6 @@ public class GameConfigDelegate extends DelegateBase .setVisibility( names.length <= 1 ? View.GONE : View.VISIBLE ); - showHideRelayStuff(); - if ( ! localOnlyGame() && ((0 == m_gi.remoteCount() ) || (m_gi.nPlayers == m_gi.remoteCount()) ) ) { @@ -1243,20 +1197,6 @@ public class GameConfigDelegate extends DelegateBase ((TextView)findViewById( R.id.players_label )).setText( label ); } - private void adjustConnectStuff() - { - if ( XWPrefs.getPublicRoomsEnabled( m_activity ) ) { - if ( m_joinPublicCheck.isChecked() ) { - refreshNames(); - m_privateRoomsSet.setVisibility( View.GONE ); - m_publicRoomsSet.setVisibility( View.VISIBLE ); - } else { - m_privateRoomsSet.setVisibility( View.VISIBLE ); - m_publicRoomsSet.setVisibility( View.GONE ); - } - } - } - // User's toggling whether everything's locked. That should mean // we enable/disable a bunch of widgits. And if we're going from // unlocked to locked we need to confirm that everything can be @@ -1329,23 +1269,6 @@ public class GameConfigDelegate extends DelegateBase m_gi.boardSize = positionToSize( position ); m_gi.traySize = Integer.parseInt( m_traysizeSpinner.getSelectedItem().toString() ); - if ( m_conTypes.contains( CommsConnType.COMMS_CONN_RELAY ) ) { - m_car.ip_relay_seeksPublicRoom = m_joinPublicCheck.isChecked(); - m_car.ip_relay_advertiseRoom = - getChecked( R.id.advertise_new_room_check ); - if ( m_car.ip_relay_seeksPublicRoom ) { - SpinnerAdapter adapter = m_roomChoose.getAdapter(); - if ( null != adapter ) { - int pos = m_roomChoose.getSelectedItemPosition(); - if ( pos >= 0 && pos < adapter.getCount() ) { - m_car.ip_relay_invite = (String)adapter.getItem(pos); - } - } - } else { - m_car.ip_relay_invite = getText( R.id.room_edit ).trim(); - } - } - m_car.conTypes = m_conTypes; } // saveChanges @@ -1381,13 +1304,13 @@ public class GameConfigDelegate extends DelegateBase } } - private void refreshNames() - { - if ( !m_isLocked ) { - new RefreshNamesTask( m_activity, this, m_gi.dictLang, - m_gi.nPlayers, m_roomChoose ).execute(); - } - } + // private void refreshNames() + // { + // if ( !m_isLocked ) { + // new RefreshNamesTask( m_activity, this, m_gi.dictLang, + // m_gi.nPlayers, m_roomChoose ).execute(); + // } + // } @Override protected void setTitle() @@ -1432,48 +1355,4 @@ public class GameConfigDelegate extends DelegateBase findViewById( R.id.pick_faceup ).setVisibility( View.GONE ); } } - - private void setupRelayStuffIf() - { - if ( m_conTypes.contains( CommsConnType.COMMS_CONN_RELAY ) ) { - boolean publicEnabled = XWPrefs.getPublicRoomsEnabled( m_activity ); - int vis = publicEnabled ? View.VISIBLE : View.GONE; - if ( null == m_joinPublicCheck ) { - m_joinPublicCheck = - (CheckBox)findViewById(R.id.join_public_room_check); - m_joinPublicCheck.setVisibility( vis ); - - CheckBox advertise = (CheckBox) - findViewById( R.id.advertise_new_room_check ); - advertise.setVisibility( vis ); - if ( publicEnabled ) { - m_joinPublicCheck.setOnClickListener( this ); - m_joinPublicCheck.setChecked( m_car.ip_relay_seeksPublicRoom ); - advertise.setChecked( m_car.ip_relay_advertiseRoom ); - m_publicRoomsSet = - (LinearLayout)findViewById(R.id.public_rooms_set ); - m_privateRoomsSet = - (LinearLayout)findViewById(R.id.private_rooms_set ); - } - - setText( R.id.room_edit, m_car.ip_relay_invite ); - - m_roomChoose = (Spinner)findViewById( R.id.room_spinner ); - m_roomChoose.setVisibility( vis ); - - m_refreshRoomsButton = - (ImageButton)findViewById( R.id.refresh_button ); - m_refreshRoomsButton.setVisibility( vis ); - m_refreshRoomsButton.setOnClickListener( this ); - - adjustConnectStuff(); - } - } - } - - private void showHideRelayStuff() - { - boolean show = m_conTypes.contains( CommsConnType.COMMS_CONN_RELAY ); - m_connectSetRelay.setVisibility( show ? View.VISIBLE : View.GONE ); - } } diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/RefreshNamesTask.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/RefreshNamesTask.java deleted file mode 100644 index 97124b2e6..000000000 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/RefreshNamesTask.java +++ /dev/null @@ -1,143 +0,0 @@ -/* -*- compile-command: "find-and-gradle.sh inXw4dDeb"; -*- */ -/* - * Copyright 2009 - 2012 by Eric House (xwords@eehouse.org). All - * rights reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package org.eehouse.android.xw4; - -import android.app.ProgressDialog; -import android.content.Context; -import android.os.AsyncTask; -import android.widget.ArrayAdapter; -import android.widget.Spinner; - -import org.eehouse.android.xw4.loc.LocUtils; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.net.Socket; -import java.util.ArrayList; - -public class RefreshNamesTask extends AsyncTask { - private static final String TAG = RefreshNamesTask.class.getSimpleName(); - - public interface NoNameFound { - public void NoNameFound(); - }; - - private Context m_context; - private Spinner m_resultSpinner; - private int m_lang; - private int m_nInGame; - private ProgressDialog m_progress; - private NoNameFound m_nnf; - - public RefreshNamesTask( Context context, NoNameFound nnf, - int lang, int nInGame, - Spinner getsResults ) - { - super(); - m_context = context; - m_nnf = nnf; - m_resultSpinner = getsResults; - m_lang = lang; - m_nInGame = nInGame; - - String langName = DictLangCache.getLangName( context, lang ); - langName = LocUtils.xlateLang( context, langName ); - String msg = LocUtils.getString( context, R.string.public_names_progress_fmt, - nInGame, langName ); - m_progress = ProgressDialog.show( context, msg, null, true, true ); - } - - @Override - protected String[] doInBackground( Void...unused ) - { - ArrayList names = new ArrayList<>(); - Log.i( TAG, "doInBackground()" ); - - try { - Socket socket = NetUtils.makeProxySocket( m_context, 15000 ); - if ( null != socket ) { - DataOutputStream outStream = - new DataOutputStream( socket.getOutputStream() ); - - outStream.writeShort( 4 ); // total packet length - outStream.writeByte( NetUtils.PROTOCOL_VERSION ); - outStream.writeByte( NetUtils.PRX_PUB_ROOMS ); - outStream.writeByte( (byte)m_lang ); - outStream.writeByte( (byte)m_nInGame ); - outStream.flush(); - - // read result -- will block - DataInputStream dis = - new DataInputStream(socket.getInputStream()); - short len = dis.readShort(); - short nRooms = dis.readShort(); - Log.i( TAG, "doInBackground(): got %d rooms", nRooms ); - - // Can't figure out how to read a null-terminated string - // from DataInputStream so parse it myself. - byte[] bytes = new byte[len]; - dis.readFully( bytes ); - - int index = -1; - for ( int ii = 0; ii < nRooms; ++ii ) { - int lastIndex = ++index; // skip the null - while ( bytes[index] != '\n' ) { - ++index; - } - String name = new String( bytes, lastIndex, index - lastIndex ); - Log.i( TAG, "got public room name: %s", name ); - int indx = name.lastIndexOf( "/" ); - indx = name.lastIndexOf( "/", indx-1 ); - names.add( name.substring(0, indx ) ); - } - } - } catch ( java.io.IOException ioe ) { - Log.ex( TAG, ioe ); - } - Log.i( TAG, "doInBackground() returning" ); - return names.toArray( new String[names.size()] ); - } - - // protected void onProgressUpdate(Integer... progress) { - // setProgressPercent(progress[0]); - // } - - @Override - protected void onPostExecute( String[] result ) - { - Log.i( TAG, "onPostExecute()" ); - ArrayAdapter adapter = - new ArrayAdapter<>( m_context, - android.R.layout.simple_spinner_item, - result ); - int resID = android.R.layout.simple_spinner_dropdown_item; - adapter.setDropDownViewResource( resID ); - m_resultSpinner.setAdapter( adapter ); - - m_progress.cancel(); - - if ( result.length == 0 ) { - m_nnf.NoNameFound(); - } - - Log.i( TAG, "onPostExecute() done" ); - } -} diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWPrefs.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWPrefs.java index 71087fe65..a6d7da8f5 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWPrefs.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWPrefs.java @@ -103,11 +103,6 @@ public class XWPrefs { false ); } - public static boolean getPublicRoomsEnabled( Context context ) - { - return getPrefsBoolean( context, R.string.key_enable_pubroom, false ); - } - public static void setHideNewgameButtons( Context context, boolean set ) { setPrefsBoolean( context, R.string.key_hide_newgames, set ); diff --git a/xwords4/android/app/src/main/res/layout/game_config.xml b/xwords4/android/app/src/main/res/layout/game_config.xml index e766a6456..f252f9960 100644 --- a/xwords4/android/app/src/main/res/layout/game_config.xml +++ b/xwords4/android/app/src/main/res/layout/game_config.xml @@ -105,81 +105,6 @@ android:layout_marginTop="15dp" /> - - - - - - - - - - - - - - - - - - - - - -