Peter Cai
c0d1c29b7f
All checks were successful
/ build-debug (push) Successful in 3m45s
...however, don't do this in privileged mode because OpenEuiccService is supposed to be background, and we don't want to just randomly show up when things go wrong.
56 lines
1.6 KiB
Kotlin
56 lines
1.6 KiB
Kotlin
package im.angry.openeuicc.ui
|
|
|
|
import android.os.Bundle
|
|
import android.view.View
|
|
import android.widget.ScrollView
|
|
import android.widget.TextView
|
|
import androidx.appcompat.app.AppCompatActivity
|
|
import androidx.lifecycle.lifecycleScope
|
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
|
import im.angry.openeuicc.common.R
|
|
import im.angry.openeuicc.util.*
|
|
import kotlinx.coroutines.Dispatchers
|
|
import kotlinx.coroutines.launch
|
|
import kotlinx.coroutines.withContext
|
|
|
|
class LogsActivity : AppCompatActivity() {
|
|
private lateinit var swipeRefresh: SwipeRefreshLayout
|
|
private lateinit var scrollView: ScrollView
|
|
private lateinit var logText: TextView
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
super.onCreate(savedInstanceState)
|
|
setContentView(R.layout.activity_logs)
|
|
setSupportActionBar(findViewById(R.id.toolbar))
|
|
supportActionBar!!.setDisplayHomeAsUpEnabled(true)
|
|
|
|
swipeRefresh = findViewById(R.id.swipe_refresh)
|
|
scrollView = findViewById(R.id.scroll_view)
|
|
logText = findViewById(R.id.log_text)
|
|
|
|
swipeRefresh.setOnRefreshListener {
|
|
lifecycleScope.launch {
|
|
reload()
|
|
}
|
|
}
|
|
}
|
|
|
|
override fun onStart() {
|
|
super.onStart()
|
|
lifecycleScope.launch {
|
|
reload()
|
|
}
|
|
}
|
|
|
|
private suspend fun reload() = withContext(Dispatchers.Main) {
|
|
swipeRefresh.isRefreshing = true
|
|
|
|
logText.text = intent.extras?.getString("log") ?: readSelfLog()
|
|
|
|
swipeRefresh.isRefreshing = false
|
|
|
|
scrollView.post {
|
|
scrollView.fullScroll(View.FOCUS_DOWN)
|
|
}
|
|
}
|
|
} |