diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DictBrowseDelegate.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DictBrowseDelegate.java index be0c70e82..46f86e6d8 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DictBrowseDelegate.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DictBrowseDelegate.java @@ -334,13 +334,13 @@ public class DictBrowseDelegate extends DelegateBase private String getFindText() { - EditText edit = (EditText)findViewById( R.id.word_edit ); + EditWClear edit = (EditWClear)findViewById( R.id.word_edit ); return edit.getText().toString(); } private void setFindText( String text ) { - EditText edit = (EditText)findViewById( R.id.word_edit ); + EditWClear edit = (EditWClear)findViewById( R.id.word_edit ); edit.setText( text ); } diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/EditWClear.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/EditWClear.java new file mode 100644 index 000000000..a88a5a16d --- /dev/null +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/EditWClear.java @@ -0,0 +1,43 @@ +/* -*- compile-command: "find-and-gradle.sh inXw4dDeb"; -*- */ +/* + * Copyright 2019 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.widget.SearchView; +import android.content.Context; +import android.util.AttributeSet; + +public class EditWClear extends SearchView { + private static final String TAG = EditWClear.class.getSimpleName(); + + public EditWClear( Context context, AttributeSet as ) + { + super( context, as ); + } + + void setText( String txt ) + { + super.setQuery( txt, false ); + } + + CharSequence getText() + { + return super.getQuery(); + } +} diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameNamer.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameNamer.java index bfe3a2929..cd1c46cf0 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameNamer.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameNamer.java @@ -44,12 +44,6 @@ public class GameNamer extends LinearLayout { view.setText( label ); } - public void setKeyListener( KeyListener lstnr ) - { - EditText view = (EditText)findViewById( R.id.name_edit ); - view.setKeyListener( lstnr ); - } - public void setLabel( int id ) { setLabel( LocUtils.getString( getContext(), id ) ); @@ -57,14 +51,17 @@ public class GameNamer extends LinearLayout { public void setName( String text ) { - EditText view = (EditText)findViewById( R.id.name_edit ); - view.setText( text ); + getEdit().setText( text ); } public String getName() { - EditText view = (EditText)findViewById( R.id.name_edit ); - return view.getText().toString(); + return getEdit().getText().toString(); } + private EditWClear getEdit() + { + EditWClear view = (EditWClear)findViewById( R.id.name_edit ); + return view; + } } diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GamesListDelegate.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GamesListDelegate.java index 2c5c4efdc..f8dc4dfc6 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GamesListDelegate.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GamesListDelegate.java @@ -862,9 +862,10 @@ public class GamesListDelegate extends ListDelegateBase case GAMES_LIST_NEWGAME: { boolean solo = (Boolean)params[0]; - LinearLayout view = (LinearLayout) + final LinearLayout view = (LinearLayout) LocUtils.inflate( m_activity, R.layout.msg_label_and_edit ); - final EditText edit = (EditText)view.findViewById( R.id.edit ); + final EditWClear edit = (EditWClear)view.findViewById( R.id.edit ); + edit.setText( GameUtils.makeDefaultName( m_activity ) ); boolean canDoDefaults = solo || 0 < XWPrefs.getAddrTypes( m_activity ).size(); @@ -878,8 +879,6 @@ public class GamesListDelegate extends ListDelegateBase } TextView tmpEdit = (TextView)view.findViewById( R.id.msg ); tmpEdit.setText( msg ); - tmpEdit = (TextView)view.findViewById( R.id.edit ); - tmpEdit.setText( GameUtils.makeDefaultName( m_activity ) ); lstnr = new OnClickListener() { public void onClick( DialogInterface dlg, int item ) { @@ -907,11 +906,11 @@ public class GamesListDelegate extends ListDelegateBase break; case GAMES_LIST_NAME_REMATCH: { - LinearLayout view = (LinearLayout) + final LinearLayout view = (LinearLayout) LocUtils.inflate( m_activity, R.layout.msg_label_and_edit ); int iconResID = R.drawable.sologame__gen; if ( null != m_rematchExtras ) { - EditText edit = (EditText)view.findViewById( R.id.edit ); + EditWClear edit = (EditWClear)view.findViewById( R.id.edit ); edit.setText( m_rematchExtras.getString( REMATCH_NEWNAME_EXTRA )); boolean solo = m_rematchExtras.getBoolean( REMATCH_IS_SOLO, true ); if ( !solo ) { @@ -925,8 +924,9 @@ public class GamesListDelegate extends ListDelegateBase .setTitle( R.string.button_rematch ) .setIcon( iconResID ) .setPositiveButton( android.R.string.ok, new OnClickListener() { + @Override public void onClick( DialogInterface dlg, int item ) { - EditText edit = (EditText)((Dialog)dlg) + EditWClear edit = (EditWClear)((Dialog)dlg) .findViewById( R.id.edit ); String gameName = edit.getText().toString(); startRematchWithName( gameName, true ); diff --git a/xwords4/android/app/src/main/res/layout/dict_browser.xml b/xwords4/android/app/src/main/res/layout/dict_browser.xml index f83534566..58f1a6e30 100644 --- a/xwords4/android/app/src/main/res/layout/dict_browser.xml +++ b/xwords4/android/app/src/main/res/layout/dict_browser.xml @@ -23,15 +23,18 @@ android:layout_weight="0" android:layout_below="@id/desc" > - + +