mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-09 05:24:44 +01:00
first set of EditTexts getting 'X' clear button
I'm using SearchView for now. Would rather have a custom layout without a magnifying glass I need to hide, but this works for now.
This commit is contained in:
parent
af1ac3f779
commit
597bcebefa
8 changed files with 103 additions and 49 deletions
|
@ -334,13 +334,13 @@ public class DictBrowseDelegate extends DelegateBase
|
||||||
|
|
||||||
private String getFindText()
|
private String getFindText()
|
||||||
{
|
{
|
||||||
EditText edit = (EditText)findViewById( R.id.word_edit );
|
EditWClear edit = (EditWClear)findViewById( R.id.word_edit );
|
||||||
return edit.getText().toString();
|
return edit.getText().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setFindText( String text )
|
private void setFindText( String text )
|
||||||
{
|
{
|
||||||
EditText edit = (EditText)findViewById( R.id.word_edit );
|
EditWClear edit = (EditWClear)findViewById( R.id.word_edit );
|
||||||
edit.setText( text );
|
edit.setText( text );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
|
@ -44,12 +44,6 @@ public class GameNamer extends LinearLayout {
|
||||||
view.setText( label );
|
view.setText( label );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setKeyListener( KeyListener lstnr )
|
|
||||||
{
|
|
||||||
EditText view = (EditText)findViewById( R.id.name_edit );
|
|
||||||
view.setKeyListener( lstnr );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLabel( int id )
|
public void setLabel( int id )
|
||||||
{
|
{
|
||||||
setLabel( LocUtils.getString( getContext(), id ) );
|
setLabel( LocUtils.getString( getContext(), id ) );
|
||||||
|
@ -57,14 +51,17 @@ public class GameNamer extends LinearLayout {
|
||||||
|
|
||||||
public void setName( String text )
|
public void setName( String text )
|
||||||
{
|
{
|
||||||
EditText view = (EditText)findViewById( R.id.name_edit );
|
getEdit().setText( text );
|
||||||
view.setText( text );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
EditText view = (EditText)findViewById( R.id.name_edit );
|
return getEdit().getText().toString();
|
||||||
return view.getText().toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private EditWClear getEdit()
|
||||||
|
{
|
||||||
|
EditWClear view = (EditWClear)findViewById( R.id.name_edit );
|
||||||
|
return view;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -862,9 +862,10 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
|
|
||||||
case GAMES_LIST_NEWGAME: {
|
case GAMES_LIST_NEWGAME: {
|
||||||
boolean solo = (Boolean)params[0];
|
boolean solo = (Boolean)params[0];
|
||||||
LinearLayout view = (LinearLayout)
|
final LinearLayout view = (LinearLayout)
|
||||||
LocUtils.inflate( m_activity, R.layout.msg_label_and_edit );
|
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 ||
|
boolean canDoDefaults = solo ||
|
||||||
0 < XWPrefs.getAddrTypes( m_activity ).size();
|
0 < XWPrefs.getAddrTypes( m_activity ).size();
|
||||||
|
@ -878,8 +879,6 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
}
|
}
|
||||||
TextView tmpEdit = (TextView)view.findViewById( R.id.msg );
|
TextView tmpEdit = (TextView)view.findViewById( R.id.msg );
|
||||||
tmpEdit.setText( msg );
|
tmpEdit.setText( msg );
|
||||||
tmpEdit = (TextView)view.findViewById( R.id.edit );
|
|
||||||
tmpEdit.setText( GameUtils.makeDefaultName( m_activity ) );
|
|
||||||
|
|
||||||
lstnr = new OnClickListener() {
|
lstnr = new OnClickListener() {
|
||||||
public void onClick( DialogInterface dlg, int item ) {
|
public void onClick( DialogInterface dlg, int item ) {
|
||||||
|
@ -907,11 +906,11 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GAMES_LIST_NAME_REMATCH: {
|
case GAMES_LIST_NAME_REMATCH: {
|
||||||
LinearLayout view = (LinearLayout)
|
final LinearLayout view = (LinearLayout)
|
||||||
LocUtils.inflate( m_activity, R.layout.msg_label_and_edit );
|
LocUtils.inflate( m_activity, R.layout.msg_label_and_edit );
|
||||||
int iconResID = R.drawable.sologame__gen;
|
int iconResID = R.drawable.sologame__gen;
|
||||||
if ( null != m_rematchExtras ) {
|
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 ));
|
edit.setText( m_rematchExtras.getString( REMATCH_NEWNAME_EXTRA ));
|
||||||
boolean solo = m_rematchExtras.getBoolean( REMATCH_IS_SOLO, true );
|
boolean solo = m_rematchExtras.getBoolean( REMATCH_IS_SOLO, true );
|
||||||
if ( !solo ) {
|
if ( !solo ) {
|
||||||
|
@ -925,8 +924,9 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
.setTitle( R.string.button_rematch )
|
.setTitle( R.string.button_rematch )
|
||||||
.setIcon( iconResID )
|
.setIcon( iconResID )
|
||||||
.setPositiveButton( android.R.string.ok, new OnClickListener() {
|
.setPositiveButton( android.R.string.ok, new OnClickListener() {
|
||||||
|
@Override
|
||||||
public void onClick( DialogInterface dlg, int item ) {
|
public void onClick( DialogInterface dlg, int item ) {
|
||||||
EditText edit = (EditText)((Dialog)dlg)
|
EditWClear edit = (EditWClear)((Dialog)dlg)
|
||||||
.findViewById( R.id.edit );
|
.findViewById( R.id.edit );
|
||||||
String gameName = edit.getText().toString();
|
String gameName = edit.getText().toString();
|
||||||
startRematchWithName( gameName, true );
|
startRematchWithName( gameName, true );
|
||||||
|
|
|
@ -23,7 +23,10 @@
|
||||||
android:layout_weight="0"
|
android:layout_weight="0"
|
||||||
android:layout_below="@id/desc"
|
android:layout_below="@id/desc"
|
||||||
>
|
>
|
||||||
<EditText android:id="@+id/word_edit"
|
|
||||||
|
<org.eehouse.android.xw4.EditWClear
|
||||||
|
android:id="@+id/word_edit"
|
||||||
|
style="@style/edit_w_clear"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
|
|
|
@ -14,7 +14,9 @@
|
||||||
android:text="@string/game_name_label"
|
android:text="@string/game_name_label"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<EditText android:id="@+id/edit"
|
<org.eehouse.android.xw4.EditWClear
|
||||||
|
android:id="@+id/edit"
|
||||||
|
style="@style/edit_w_clear"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:scrollHorizontally="true"
|
android:scrollHorizontally="true"
|
||||||
|
|
|
@ -14,7 +14,9 @@
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<EditText android:id="@+id/name_edit"
|
<org.eehouse.android.xw4.EditWClear
|
||||||
|
android:id="@+id/name_edit"
|
||||||
|
style="@style/edit_w_clear"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_marginLeft="30dip"
|
android:layout_marginLeft="30dip"
|
||||||
|
@ -25,4 +27,5 @@
|
||||||
android:selectAllOnFocus="true"
|
android:selectAllOnFocus="true"
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</org.eehouse.android.xw4.GameNamer>
|
</org.eehouse.android.xw4.GameNamer>
|
||||||
|
|
|
@ -105,4 +105,10 @@
|
||||||
<item name="android:paddingLeft">20dp</item>
|
<item name="android:paddingLeft">20dp</item>
|
||||||
<item name="android:paddingRight">20dp</item>
|
<item name="android:paddingRight">20dp</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="edit_w_clear">
|
||||||
|
<item name="android:iconifiedByDefault">false</item>
|
||||||
|
<item name="android:searchIcon">@null</item>
|
||||||
|
<item name="android:searchHintIcon">@null</item>
|
||||||
|
</style>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue