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 8c660c8b6..19ff429b5 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 @@ -482,6 +482,20 @@ public class DictBrowseDelegate extends DelegateBase return m_stateKey; } + // We'll enable the button as soon as any row gets focus, since once one + // of them has focus one always will. + private boolean mBlankButtonEnabled = false; + private Runnable mFocusGainedProc = new Runnable() { + @Override + public void run() { + if ( !mBlankButtonEnabled ) { + mBlankButtonEnabled = true; + findViewById(R.id.button_addBlank) + .setEnabled( true ); + } + } + }; + private void findTableRows() { ViewGroup table = (ViewGroup)findViewById( R.id.config ); @@ -490,7 +504,9 @@ public class DictBrowseDelegate extends DelegateBase for ( int ii = 0; ii < count && nFound < m_rows.length; ++ii ) { View child = table.getChildAt( ii ); if ( child instanceof PatTableRow ) { - m_rows[nFound++] = (PatTableRow)child; + PatTableRow row = (PatTableRow)child; + m_rows[nFound++] = row; + row.setOnFocusGained( mFocusGainedProc ); } } Assert.assertTrueNR( nFound == m_rows.length ); @@ -576,12 +592,6 @@ public class DictBrowseDelegate extends DelegateBase for ( PatTableRow row : m_rows ) { handled = handled || row.addBlankToFocussed( "_" ); } - if ( !handled ) { - makeNotAgainBuilder( R.string.blank_button_expl, - R.string.key_na_addBlankButton ) - .setTitle(null) - .show(); - } } private void setShowConfig() diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/PatTableRow.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/PatTableRow.java index 17fead4b9..a25be18c8 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/PatTableRow.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/PatTableRow.java @@ -73,6 +73,20 @@ public class PatTableRow extends TableRow { return handled; } + void setOnFocusGained( final Runnable proc ) + { + getFields(); + mEdit.setOnFocusChangeListener( new View.OnFocusChangeListener() { + @Override + public void onFocusChange( View view, boolean hasFocus ) + { + if ( hasFocus ) { + proc.run(); + } + } + } ); + } + private void getFields() { mEdit = (EditText)Utils.getChildInstanceOf( this, EditText.class ); 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 8e8e136e5..c44b25031 100644 --- a/xwords4/android/app/src/main/res/layout/dict_browser.xml +++ b/xwords4/android/app/src/main/res/layout/dict_browser.xml @@ -102,6 +102,7 @@ android:layout_width="wrap_content" android:text="@string/button_addBlank" android:layout_span="1" + android:enabled="false" /> key_na_sms_banned key_na_longtap_lookup key_na_perms_phonestate - key_na_addBlankButton key_na_newFeatureFilter key_na_dupstatus_host diff --git a/xwords4/android/app/src/main/res/values/strings.xml b/xwords4/android/app/src/main/res/values/strings.xml index 00c6512f1..b11bd601c 100644 --- a/xwords4/android/app/src/main/res/values/strings.xml +++ b/xwords4/android/app/src/main/res/values/strings.xml @@ -1555,12 +1555,11 @@ name, e.g. Tiles for English --> Tiles for %1$s - - This button inserts a blank at - the active text field’s cursor, but there is no cursor - now. + + About Wordlist Starts with @@ -2611,6 +2610,4 @@ MQTT Invitation I’m experimenting with this as a replacement for the relay. - - About Wordlist