Commit 94ad42a5 authored by Waweic's avatar Waweic 💬
Browse files

Resolve conflicts

parent e364ee65
Pipeline #289903 failed with stages
in 47 seconds
......@@ -7,43 +7,45 @@ import android.view.KeyEvent
import android.view.inputmethod.InputMethodManager
import android.widget.Button
import android.widget.EditText
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.async
import java.net.URI
class MainActivity : AppCompatActivity() {
private lateinit var connection : GeminiConnection
private lateinit var renderer : GeminiRenderer
private lateinit var responseHandler : GeminiResponseHandler
private lateinit var backButton: Button
private lateinit var goButton: Button
private lateinit var uriField: EditText
private lateinit var mainContentView: TextView
private lateinit var geminiClient: GeminiClient
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
// Find UI elements
backButton = findViewById(R.id.back_button)
goButton = findViewById(R.id.go_button)
uriField = findViewById(R.id.gemini_uri)
mainContentView = findViewById(R.id.mainContentView)
// Initialize Protocol objects
connection = GeminiConnection()
renderer = GeminiRenderer(findViewById(R.id.mainContentView))
responseHandler = GeminiResponseHandler(renderer, applicationContext)
// Create handlers
geminiClient = GeminiClient(
applicationContext,
mainContentView,
uriField
)
// Create handlers
goButton.setOnClickListener {
goToPage(URI.create(uriField.text.toString()))
geminiClient.goToPage(uriField.text.toString())
// Hide keyboard
uriField.clearFocus()
val inputService = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
inputService.hideSoftInputFromWindow(uriField.windowToken, 0)
}
uriField.setOnKeyListener { _, keyCode, event ->
......@@ -54,19 +56,18 @@ class MainActivity : AppCompatActivity() {
} else false
}
goToPage(URI.create(getString(R.string.default_url)))
backButton.setOnClickListener {
geminiClient.goBack()
}
geminiClient.goToPage(getString(R.string.default_url))
}
override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
if(intent?.data != null) {
intent?.data.toString().let{goToPage(URI.create(it))}
}
intent?.data.toString().let{geminiClient.goToPage(it)}
}
fun goToPage(uri: URI) {
uriField.setText(uri.toString())
val deferredResult = GlobalScope.async { connection.request(uri) }
responseHandler.handle(deferredResult)
override fun onBackPressed() {
geminiClient.goBack()
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment