mirror of
https://git.sr.ht/~oppen/ariane
synced 2024-12-27 02:10:30 +00:00
percent encode searches
This commit is contained in:
parent
32fcd7c293
commit
b0e8f30ddf
2 changed files with 21 additions and 1 deletions
|
@ -1,7 +1,10 @@
|
||||||
package oppen
|
package oppen
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import android.os.CountDownTimer
|
import android.os.CountDownTimer
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import android.view.inputmethod.InputMethodManager
|
||||||
|
import androidx.core.content.ContextCompat.getSystemService
|
||||||
|
|
||||||
|
|
||||||
fun View.visible(visible: Boolean) = when {
|
fun View.visible(visible: Boolean) = when {
|
||||||
|
@ -14,6 +17,17 @@ fun View.visibleRetainingSpace(visible: Boolean) = when {
|
||||||
else -> this.visibility = View.INVISIBLE
|
else -> this.visibility = View.INVISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun View.hideKeyboard(){
|
||||||
|
val imm: InputMethodManager? = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager?
|
||||||
|
imm?.hideSoftInputFromWindow(windowToken, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun View.showKeyboard(){
|
||||||
|
delay(200){
|
||||||
|
this.callOnClick()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun delay(ms: Long, action: () -> Unit){
|
fun delay(ms: Long, action: () -> Unit){
|
||||||
object : CountDownTimer(ms, ms/2) {
|
object : CountDownTimer(ms, ms/2) {
|
||||||
override fun onTick(millisUntilFinished: Long) {}
|
override fun onTick(millisUntilFinished: Long) {}
|
||||||
|
|
|
@ -13,6 +13,8 @@ import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.databinding.DataBindingUtil
|
import androidx.databinding.DataBindingUtil
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
|
import oppen.hideKeyboard
|
||||||
|
import oppen.showKeyboard
|
||||||
import oppen.tva.R
|
import oppen.tva.R
|
||||||
import oppen.tva.Tva
|
import oppen.tva.Tva
|
||||||
import oppen.tva.databinding.ActivityTvaBinding
|
import oppen.tva.databinding.ActivityTvaBinding
|
||||||
|
@ -29,6 +31,7 @@ import oppen.tva.ui.modals_menus.set_home.SetHomeDialog
|
||||||
import oppen.tva.ui.modals_menus.tabs.NewTabPopup
|
import oppen.tva.ui.modals_menus.tabs.NewTabPopup
|
||||||
import oppen.tva.ui.modals_menus.tabs.TabsDialog
|
import oppen.tva.ui.modals_menus.tabs.TabsDialog
|
||||||
import oppen.visibleRetainingSpace
|
import oppen.visibleRetainingSpace
|
||||||
|
import java.net.URLEncoder
|
||||||
|
|
||||||
|
|
||||||
class TvaActivity : AppCompatActivity() {
|
class TvaActivity : AppCompatActivity() {
|
||||||
|
@ -98,9 +101,11 @@ class TvaActivity : AppCompatActivity() {
|
||||||
if(input.startsWith("gemini://")){
|
if(input.startsWith("gemini://")){
|
||||||
model.request(input)
|
model.request(input)
|
||||||
}else{
|
}else{
|
||||||
model.request("${Tva.GEMINI_USER_SEARCH_BASE}$input")
|
model.request("${Tva.GEMINI_USER_SEARCH_BASE}${URLEncoder.encode(input, "UTF-8")}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
binding.addressEdit.hideKeyboard()
|
||||||
|
|
||||||
return@setOnEditorActionListener true
|
return@setOnEditorActionListener true
|
||||||
}
|
}
|
||||||
else -> return@setOnEditorActionListener false
|
else -> return@setOnEditorActionListener false
|
||||||
|
@ -114,6 +119,7 @@ class TvaActivity : AppCompatActivity() {
|
||||||
binding.addressEdit.hint = getString(R.string.main_input_search_hint)
|
binding.addressEdit.hint = getString(R.string.main_input_search_hint)
|
||||||
binding.addressEdit.text?.clear()
|
binding.addressEdit.text?.clear()
|
||||||
binding.addressEdit.requestFocus()
|
binding.addressEdit.requestFocus()
|
||||||
|
binding.addressEdit.showKeyboard()
|
||||||
inSearch = true
|
inSearch = true
|
||||||
}
|
}
|
||||||
R.id.overflow_menu_share -> {
|
R.id.overflow_menu_share -> {
|
||||||
|
|
Loading…
Reference in a new issue