diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-09-22 14:33:04 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-09-22 23:53:32 +0200 |
commit | dc002d77fa514eb6526516f23beb7093654c23db (patch) | |
tree | 8a25707dc38f37b754e5b4bbd3d8875336b91102 /ui/src/main/java/com/wireguard | |
parent | aaa55c0dccd14a02af7df66fecf02884d4a708b9 (diff) |
tv: begin to wire up databindings
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'ui/src/main/java/com/wireguard')
-rw-r--r-- | ui/src/main/java/com/wireguard/android/activity/TvMainActivity.kt | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/ui/src/main/java/com/wireguard/android/activity/TvMainActivity.kt b/ui/src/main/java/com/wireguard/android/activity/TvMainActivity.kt index 4b110a30..16873642 100644 --- a/ui/src/main/java/com/wireguard/android/activity/TvMainActivity.kt +++ b/ui/src/main/java/com/wireguard/android/activity/TvMainActivity.kt @@ -8,14 +8,14 @@ package com.wireguard.android.activity import android.os.Bundle import android.widget.Toast import androidx.activity.result.contract.ActivityResultContracts +import androidx.appcompat.app.AppCompatActivity import androidx.lifecycle.lifecycleScope -import com.google.android.material.button.MaterialButton -import com.wireguard.android.R -import com.wireguard.android.model.ObservableTunnel +import com.wireguard.android.Application +import com.wireguard.android.databinding.TvActivityBinding import com.wireguard.android.util.TunnelImporter import kotlinx.coroutines.launch -class TvMainActivity : BaseActivity() { +class TvMainActivity : AppCompatActivity() { private val tunnelFileImportResultLauncher = registerForActivityResult(ActivityResultContracts.GetContent()) { data -> lifecycleScope.launch { TunnelImporter.importTunnel(contentResolver, data) { @@ -24,18 +24,14 @@ class TvMainActivity : BaseActivity() { } } - override fun onSelectedTunnelChanged(oldTunnel: ObservableTunnel?, newTunnel: ObservableTunnel?) { - } - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setContentView(R.layout.tv_activity) - findViewById<MaterialButton>(R.id.import_button).setOnClickListener { + val binding = TvActivityBinding.inflate(layoutInflater) + lifecycleScope.launch { binding.tunnels = Application.getTunnelManager().getTunnels() } + binding.importButton.setOnClickListener { tunnelFileImportResultLauncher.launch("*/*") } - } - - companion object { - const val TAG = "WireGuard/TvMainActivity" + binding.executePendingBindings() + setContentView(binding.root) } } |