mirror of https://git.sr.ht/~oppen/ariane
search implemented...
This commit is contained in:
parent
42013a5fd6
commit
32fcd7c293
|
@ -6,5 +6,6 @@ class Tva: Application() {
|
||||||
|
|
||||||
companion object{
|
companion object{
|
||||||
const val DEFAULT_HOME_CAPSULE = "gemini://gemini.circumlunar.space/~oppen/tva/index.gmi"
|
const val DEFAULT_HOME_CAPSULE = "gemini://gemini.circumlunar.space/~oppen/tva/index.gmi"
|
||||||
|
const val GEMINI_USER_SEARCH_BASE = "gemini://gus.guru/search/2?"
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -33,6 +33,8 @@ import oppen.visibleRetainingSpace
|
||||||
|
|
||||||
class TvaActivity : AppCompatActivity() {
|
class TvaActivity : AppCompatActivity() {
|
||||||
|
|
||||||
|
private var inSearch = false
|
||||||
|
|
||||||
private val model by viewModels<TvaViewModel>()
|
private val model by viewModels<TvaViewModel>()
|
||||||
private lateinit var binding: ActivityTvaBinding
|
private lateinit var binding: ActivityTvaBinding
|
||||||
private lateinit var history: HistoryInterface
|
private lateinit var history: HistoryInterface
|
||||||
|
@ -46,6 +48,11 @@ class TvaActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
//Reset input text hint after user has been searching
|
||||||
|
if(inSearch) {
|
||||||
|
binding.addressEdit.hint = getString(R.string.main_input_hint)
|
||||||
|
inSearch = false
|
||||||
|
}
|
||||||
model.request(uri)
|
model.request(uri)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,7 +71,9 @@ class TvaActivity : AppCompatActivity() {
|
||||||
model.initialise(TabHistoryInterface.default(this)){ state ->
|
model.initialise(TabHistoryInterface.default(this)){ state ->
|
||||||
when(state){
|
when(state){
|
||||||
is TvaState.AppQuery -> runOnUiThread{ showAlert("App backdoor/query not implemented yet") }
|
is TvaState.AppQuery -> runOnUiThread{ showAlert("App backdoor/query not implemented yet") }
|
||||||
is TvaState.ResponseInput -> runOnUiThread { InputDialog.show(this, state){ queryAddress ->
|
is TvaState.ResponseInput -> runOnUiThread {
|
||||||
|
loadingView(false)
|
||||||
|
InputDialog.show(this, state){ queryAddress ->
|
||||||
model.request(queryAddress)
|
model.request(queryAddress)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,7 +93,14 @@ class TvaActivity : AppCompatActivity() {
|
||||||
binding.addressEdit.setOnEditorActionListener { _, actionId, _ ->
|
binding.addressEdit.setOnEditorActionListener { _, actionId, _ ->
|
||||||
when (actionId) {
|
when (actionId) {
|
||||||
EditorInfo.IME_ACTION_GO -> {
|
EditorInfo.IME_ACTION_GO -> {
|
||||||
model.request(binding.addressEdit.text.toString())
|
val input = binding.addressEdit.text.toString()
|
||||||
|
|
||||||
|
if(input.startsWith("gemini://")){
|
||||||
|
model.request(input)
|
||||||
|
}else{
|
||||||
|
model.request("${Tva.GEMINI_USER_SEARCH_BASE}$input")
|
||||||
|
}
|
||||||
|
|
||||||
return@setOnEditorActionListener true
|
return@setOnEditorActionListener true
|
||||||
}
|
}
|
||||||
else -> return@setOnEditorActionListener false
|
else -> return@setOnEditorActionListener false
|
||||||
|
@ -94,6 +110,12 @@ class TvaActivity : AppCompatActivity() {
|
||||||
binding.more.setOnClickListener {
|
binding.more.setOnClickListener {
|
||||||
OverflowPopup.show(binding.more){menuId ->
|
OverflowPopup.show(binding.more){menuId ->
|
||||||
when (menuId) {
|
when (menuId) {
|
||||||
|
R.id.overflow_menu_search -> {
|
||||||
|
binding.addressEdit.hint = getString(R.string.main_input_search_hint)
|
||||||
|
binding.addressEdit.text?.clear()
|
||||||
|
binding.addressEdit.requestFocus()
|
||||||
|
inSearch = true
|
||||||
|
}
|
||||||
R.id.overflow_menu_share -> {
|
R.id.overflow_menu_share -> {
|
||||||
Intent().apply {
|
Intent().apply {
|
||||||
action = Intent.ACTION_SEND
|
action = Intent.ACTION_SEND
|
||||||
|
|
|
@ -1,11 +1,31 @@
|
||||||
package oppen.tva.ui.modals_menus.input
|
package oppen.tva.ui.modals_menus.input
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.view.View
|
||||||
|
import androidx.appcompat.app.AppCompatDialog
|
||||||
|
import kotlinx.android.synthetic.main.dialog_input_query.view.*
|
||||||
|
import oppen.tva.R
|
||||||
import oppen.tva.io.TvaState
|
import oppen.tva.io.TvaState
|
||||||
import oppen.tva.ui.TvaActivity
|
|
||||||
|
|
||||||
object InputDialog {
|
object InputDialog {
|
||||||
|
|
||||||
fun show(tvaActivity: TvaActivity, state: TvaState.ResponseInput, onQuery: (queryAddress: String) -> Unit) {
|
fun show(context: Context, state: TvaState.ResponseInput, onQuery: (queryAddress: String) -> Unit) {
|
||||||
|
val dialog = AppCompatDialog(context, R.style.AppTheme)
|
||||||
|
|
||||||
|
val view = View.inflate(context, R.layout.dialog_input_query, null)
|
||||||
|
dialog.setContentView(view)
|
||||||
|
|
||||||
|
view.close_input_query_dialog.setOnClickListener {
|
||||||
|
dialog.dismiss()
|
||||||
|
}
|
||||||
|
|
||||||
|
view.query_text.text = state.header.meta
|
||||||
|
|
||||||
|
view.query_submit_button.setOnClickListener {
|
||||||
|
onQuery("${state.uri}?${view.query_input.text.toString()}")
|
||||||
|
dialog.dismiss()
|
||||||
|
}
|
||||||
|
|
||||||
|
dialog.show()
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -56,7 +56,7 @@
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:imeOptions="actionGo"
|
android:imeOptions="actionGo"
|
||||||
android:hint="@string/gemini_protocol"/>
|
android:hint="@string/main_input_hint"/>
|
||||||
|
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
|
||||||
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/header"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingTop="@dimen/default_margin">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatImageButton
|
||||||
|
android:id="@+id/close_input_query_dialog"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_margin="@dimen/button_margin"
|
||||||
|
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||||
|
android:src="@drawable/vector_close" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
<androidx.core.widget.NestedScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@+id/header">
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingLeft="@dimen/default_margin_big"
|
||||||
|
android:paddingRight="@dimen/default_margin_big"
|
||||||
|
android:paddingBottom="@dimen/default_margin_big"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
|
android:id="@+id/query_text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingBottom="@dimen/default_margin"
|
||||||
|
tools:text="Type your query"/>
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatEditText
|
||||||
|
android:id="@+id/query_input"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingBottom="@dimen/default_margin"/>
|
||||||
|
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatButton
|
||||||
|
android:id="@+id/query_submit_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="end"
|
||||||
|
android:text="@string/submit"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</androidx.core.widget.NestedScrollView>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
|
@ -1,6 +1,9 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<group android:id="@+id/app" >
|
<group android:id="@+id/app" >
|
||||||
|
<item
|
||||||
|
android:id="@+id/overflow_menu_search"
|
||||||
|
android:title="@string/search" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/overflow_menu_share"
|
android:id="@+id/overflow_menu_share"
|
||||||
android:title="@string/share" />
|
android:title="@string/share" />
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">Två</string>
|
<string name="app_name">Två</string>
|
||||||
<string name="gemini_protocol">gemini://</string>
|
<string name="gemini_protocol">gemini://</string>
|
||||||
|
<string name="main_input_hint">Enter gemini:// address</string>
|
||||||
|
<string name="main_input_search_hint">Enter search term</string>
|
||||||
<string name="open_in_new_tab">Open in new tab</string>
|
<string name="open_in_new_tab">Open in new tab</string>
|
||||||
<string name="copy_address">Copy address</string>
|
<string name="copy_address">Copy address</string>
|
||||||
<string name="about">About</string>
|
<string name="about">About</string>
|
||||||
|
@ -20,4 +22,6 @@
|
||||||
<string name="history">History</string>
|
<string name="history">History</string>
|
||||||
<string name="clear_history">Clear history</string>
|
<string name="clear_history">Clear history</string>
|
||||||
<string name="reload">Reload</string>
|
<string name="reload">Reload</string>
|
||||||
|
<string name="submit">Submit</string>
|
||||||
|
<string name="search">Search</string>
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in New Issue