From 5a0d132f27e74545801985ec9e6cc13ca18640fc Mon Sep 17 00:00:00 2001 From: Andrew Rogers Date: Sun, 26 Dec 2021 22:21:38 +1000 Subject: [PATCH 01/37] Save the last search term and added a button to clear text --- .../net/bible/android/view/activity/search/Search.kt | 6 ++++++ app/src/main/res/layout/search.xml | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/app/src/main/java/net/bible/android/view/activity/search/Search.kt b/app/src/main/java/net/bible/android/view/activity/search/Search.kt index edf074fd6b..9a7f37486e 100644 --- a/app/src/main/java/net/bible/android/view/activity/search/Search.kt +++ b/app/src/main/java/net/bible/android/view/activity/search/Search.kt @@ -25,6 +25,7 @@ import android.util.Log import android.view.MenuItem import android.view.View import android.view.inputmethod.EditorInfo +import android.widget.Button import android.widget.RadioButton import android.widget.RadioGroup @@ -136,6 +137,8 @@ class Search : CustomTitlebarActivityBase(R.menu.search_actionbar_menu) { if (StringUtils.isNotEmpty(text)) { binding.searchText.setText(text) } + } else { + binding.searchText.setText(CommonUtils.settings.getString("search_text", "")) } val wordsRadioGroup = findViewById(R.id.wordsGroup) as RadioGroup @@ -169,6 +172,8 @@ class Search : CustomTitlebarActivityBase(R.menu.search_actionbar_menu) { } currentBookRadioButton.text = currentBookName + binding.textClear.setOnClickListener({binding.searchText.setText("")}) + Log.i(TAG, "Finished displaying Search view") } @@ -204,6 +209,7 @@ class Search : CustomTitlebarActivityBase(R.menu.search_actionbar_menu) { var text = binding.searchText.text.toString() if (!StringUtils.isEmpty(text)) { + CommonUtils.settings.setString("search_text", text) // update current intent so search is restored if we return here via history/back // the current intent is saved by HistoryManager intent.putExtra(SEARCH_TEXT_SAVE, text) diff --git a/app/src/main/res/layout/search.xml b/app/src/main/res/layout/search.xml index 48963f68ae..a87ada12f8 100644 --- a/app/src/main/res/layout/search.xml +++ b/app/src/main/res/layout/search.xml @@ -5,6 +5,7 @@ --> + +