pull/8/head
geeksville 2020-01-22 14:48:06 -08:00
rodzic bb39bab1c1
commit 151c9e59bc
3 zmienionych plików z 36 dodań i 18 usunięć

Wyświetl plik

@ -1,6 +1,6 @@
* make frontend using https://developer.android.com/jetpack/compose/tutorial
* use https://codelabs.developers.google.com/codelabs/jetpack-compose-basics/#4 to show service state
*fix bluetooth
# Medium priority
@ -23,3 +23,5 @@ Don't leave device discoverable. Don't let unpaired users do thing with device
* assert() is apparently a noop - change to use my version of assert
* DONE add crash reporting
* DONE add analytics (make them optional)
* make frontend using https://developer.android.com/jetpack/compose/tutorial

Wyświetl plik

@ -26,7 +26,7 @@ android {
buildFeatures {
// Enables Jetpack Compose for this module
compose false // FIXME, if true main app crashes
compose true // NOTE, if true main app crashes if you use regular view layout functions
}
// Set both the Java and Kotlin compilers to target Java 8.

Wyświetl plik

@ -13,12 +13,19 @@ import androidx.appcompat.app.AppCompatActivity
import android.view.Menu
import android.view.MenuItem
import android.widget.Toast
import androidx.compose.Composable
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.ui.core.Text
import androidx.ui.core.dp
import androidx.ui.core.setContent
import androidx.ui.layout.Column
import androidx.ui.layout.Spacing
import androidx.ui.material.Button
import androidx.ui.material.MaterialTheme
import androidx.ui.tooling.preview.Preview
import com.geeksville.android.Logging
import kotlinx.android.synthetic.main.activity_main.*
import java.util.*
class MainActivity : AppCompatActivity(), Logging {
@ -66,22 +73,31 @@ class MainActivity : AppCompatActivity(), Logging {
}
}
@Composable
fun composeView() {
MaterialTheme {
Column {
Text(text = "MeshUtil Ugly UI", modifier = Spacing(16.dp))
Button(text = "Start scan",
onClick = {
if (bluetoothAdapter != null) {
SoftwareUpdateService.enqueueWork(this@MainActivity, SoftwareUpdateService.scanDevicesIntent)
}
})
}
}}
@Preview
@Composable
fun defaultPreview() {
composeView()
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
setSupportActionBar(toolbar)
fab.setOnClickListener { _ ->
/* Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show() */
// test crash reporting
// logAssert(false)
// throw NotImplementedError("I like crap")
if(bluetoothAdapter != null) {
SoftwareUpdateService.enqueueWork(this, SoftwareUpdateService.scanDevicesIntent)
}
setContent {
composeView()
}
// Ensures Bluetooth is available on the device and it is enabled. If not,