diff --git a/app/src/main/java/com/github/antweb/donkey/ConnectionService.kt b/app/src/main/java/com/github/antweb/donkey/ConnectionService.kt new file mode 100644 index 0000000000000000000000000000000000000000..f46414f7ee4aa847d49a56096846abe225347800 --- /dev/null +++ b/app/src/main/java/com/github/antweb/donkey/ConnectionService.kt @@ -0,0 +1,17 @@ +package com.github.antweb.donkey + +import android.bluetooth.BluetoothDevice + +object ConnectionService { + var device: BluetoothDevice? = null + + val deviceName: String? + get() = device?.name + + val deviceAddress: String? + get() = device?.address + + fun hasDevice(): Boolean { + return device != null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/antweb/donkey/MainActivity.kt b/app/src/main/java/com/github/antweb/donkey/MainActivity.kt index 90331229980b3f19f87d06f22154c1b2199eeba1..6286afb20f59ca68fa5c9639b495e43fa8ffce7a 100644 --- a/app/src/main/java/com/github/antweb/donkey/MainActivity.kt +++ b/app/src/main/java/com/github/antweb/donkey/MainActivity.kt @@ -10,19 +10,34 @@ private const val TAG = "MainActivity" class MainActivity : AppCompatActivity() { - private lateinit var tvConnection: TextView - private lateinit var tvValue: TextView - private lateinit var buttonConnect: Button - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) - tvValue = findViewById(R.id.text_value) - tvConnection = findViewById(R.id.text_connection_status) - tvConnection.text = "STATE_DISCONNECTED" + if (ConnectionService.hasDevice()) { + showConnectedView() + } else { + showNotConnectedView() + } + } + + private fun showConnectedView() { + setContentView(R.layout.activity_main_connected) + + val buttonSend = findViewById