Skip to content

Commit

Permalink
Fixes to recent PRs (#3278 and #3279)
Browse files Browse the repository at this point in the history
  • Loading branch information
tuomas2 committed Aug 1, 2024
1 parent 6653458 commit 190d08f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ class BibleView(val mainBibleActivity: MainBibleActivity,
return true
}
R.id.web_search -> {
if (currentSelectionText != null) { openWebSearch(mainBibleActivity, currentSelectionText) }
if (currentSelectionText != null) { openWebSearch(mainBibleActivity, currentSelectionText!!) }
return true
}
R.id.search -> {
Expand Down Expand Up @@ -428,12 +428,11 @@ class BibleView(val mainBibleActivity: MainBibleActivity,

fun openWebSearch(context: Context, query: String) {
try {
//var intent : Intent? = null
val intent = Intent(Intent.ACTION_WEB_SEARCH)
intent.putExtra(SearchManager.QUERY, query)
context.startActivity(intent)
} catch (e: Exception) {
Log.e(context.getClass().getName(), "Browser app not available to search: " + query)
Log.e(TAG, "Browser app not available to search: " + query)
}
}

Expand Down Expand Up @@ -545,7 +544,12 @@ class BibleView(val mainBibleActivity: MainBibleActivity,
if(ref == null && currentSelectionText != null) {
val item = menu.findItem(R.id.search)
item.isVisible = true
item.title = if(currentSelectionText?.length < 16) context.getString(R.string.search_what, currentSelectionText) else context.getString(R.string.search)
item.title = if(currentSelectionText!!.length < 16) context.getString(R.string.search_what, currentSelectionText) else context.getString(R.string.search)
}
if (currentSelectionText != null) {
menu.findItem(R.id.web_search).apply {
isVisible = true
}
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && currentSelectionText != null) {
var menuItemOrder = 100
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/res/menu/bibleview_selection.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@
android:visible="false"
app:showAsAction="always"
/>
<item android:id="@+id/web_search"
android:title="@string/web_search"
android:orderInCategory="2"
app:showAsAction="always"
android:visible="false"
/>
<item android:id="@+id/search"
android:title="@string/search"
android:orderInCategory="2"
Expand All @@ -71,5 +65,11 @@
app:showAsAction="always"
android:visible="false"
/>
<item android:id="@+id/web_search"
android:title="@string/web_search"
android:orderInCategory="2"
app:showAsAction="always"
android:visible="false"
/>
</group>
</menu>

0 comments on commit 190d08f

Please sign in to comment.