From fe742b7e81ddcbf8679b4633fc4b953e48cdc3d8 Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 13 Aug 2020 13:01:49 -0700 Subject: [PATCH] move note display into menuitem to save space --- .../android/xw4/DictBrowseDelegate.java | 22 ++++++++++++++----- .../app/src/main/res/layout/dict_browser.xml | 6 ----- .../src/main/res/menu/dict_browse_menu.xml | 3 +++ .../app/src/main/res/values/strings.xml | 2 ++ 4 files changed, 21 insertions(+), 12 deletions(-) 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 3f6aeee8f..8c660c8b6 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 @@ -26,6 +26,7 @@ import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.text.TextUtils; +import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; @@ -136,6 +137,7 @@ public class DictBrowseDelegate extends DelegateBase private Spinner m_spinnerMin; private Spinner m_spinnerMax; private boolean m_newAlertShown; + private String m_desc; private class DictListAdapter extends BaseAdapter implements SectionIndexer { @@ -258,12 +260,7 @@ public class DictBrowseDelegate extends DelegateBase } ) .setExpanded( m_browseState.m_expanded ); - String desc = XwJNI.dict_getDesc( m_dict ); - if ( null != desc ) { - TextView view = (TextView)findViewById( R.id.desc ); - view.setVisibility( View.VISIBLE ); - view.setText( desc ); - } + m_desc = XwJNI.dict_getDesc( m_dict ); int[] ids = { R.id.button_useconfig, R.id.button_addBlank, }; for ( int id : ids ) { @@ -358,6 +355,14 @@ public class DictBrowseDelegate extends DelegateBase return dialog; } + @Override + public boolean onPrepareOptionsMenu( Menu menu ) + { + Utils.setItemVisible( menu, R.id.dicts_shownote, + null != m_desc ); + return true; + } + @Override public boolean onOptionsItemSelected( MenuItem item ) { @@ -370,6 +375,11 @@ public class DictBrowseDelegate extends DelegateBase case R.id.dicts_showfaq: showFaq( FAQ_PARAMS ); break; + case R.id.dicts_shownote: + makeOkOnlyBuilder( m_desc ) + .setTitle(R.string.show_note_menu) + .show(); + break; default: handled = false; } 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 f078587f0..8e8e136e5 100644 --- a/xwords4/android/app/src/main/res/layout/dict_browser.xml +++ b/xwords4/android/app/src/main/res/layout/dict_browser.xml @@ -10,12 +10,6 @@ android:layout_weight="1" > - - + diff --git a/xwords4/android/app/src/main/res/values/strings.xml b/xwords4/android/app/src/main/res/values/strings.xml index cc8abdf44..00c6512f1 100644 --- a/xwords4/android/app/src/main/res/values/strings.xml +++ b/xwords4/android/app/src/main/res/values/strings.xml @@ -2611,4 +2611,6 @@ MQTT Invitation I’m experimenting with this as a replacement for the relay. + + About Wordlist