mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-04 20:46:28 +01:00
make +Blank button disabled until focus gained
This commit is contained in:
parent
fe742b7e81
commit
274ebcef2d
5 changed files with 37 additions and 16 deletions
|
@ -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()
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -102,6 +102,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:text="@string/button_addBlank"
|
||||
android:layout_span="1"
|
||||
android:enabled="false"
|
||||
/>
|
||||
</TableRow>
|
||||
<LinearLayout android:layout_height="wrap_content"
|
||||
|
|
|
@ -155,7 +155,6 @@
|
|||
<string name="key_na_sms_banned">key_na_sms_banned</string>
|
||||
<string name="key_na_longtap_lookup">key_na_longtap_lookup</string>
|
||||
<string name="key_na_perms_phonestate">key_na_perms_phonestate</string>
|
||||
<string name="key_na_addBlankButton">key_na_addBlankButton</string>
|
||||
<string name="key_na_newFeatureFilter">key_na_newFeatureFilter</string>
|
||||
|
||||
<string name="key_na_dupstatus_host">key_na_dupstatus_host</string>
|
||||
|
|
|
@ -1555,12 +1555,11 @@
|
|||
name, e.g. Tiles for English -->
|
||||
<string name="show_tiles_title_fmt">Tiles for %1$s</string>
|
||||
|
||||
<!-- Shown when user uses the +Blank button in wordlist browser
|
||||
but nothing can be done because there's not focussed text
|
||||
field -->
|
||||
<string name="blank_button_expl">This button inserts a blank at
|
||||
the active text field’s cursor, but there is no cursor
|
||||
now.</string>
|
||||
<!-- Menuitem in Wordlist browser, and title of the alert you get
|
||||
when you choose it. The alert shows the note that's part of
|
||||
the wordlist, typically telling where it comes from. If
|
||||
there's no note in a wordlist the menuitem is disabled. -->
|
||||
<string name="show_note_menu">About Wordlist</string>
|
||||
|
||||
<!-- Label for first field in wordlist browser filter -->
|
||||
<string name="pat_starts_with">Starts with</string>
|
||||
|
@ -2611,6 +2610,4 @@
|
|||
<string name="mqtt_invite_title">MQTT Invitation</string>
|
||||
<string name="not_again_comms_mqtt">I’m experimenting with this
|
||||
as a replacement for the relay.</string>
|
||||
|
||||
<string name="show_note_menu">About Wordlist</string>
|
||||
</resources>
|
||||
|
|
Loading…
Add table
Reference in a new issue