aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreuxane2024-09-18 23:41:13 +0200
committereuxane2024-09-18 23:41:13 +0200
commit4f6dc804176b038f84ef83550b774cb8dccd31c4 (patch)
treef1896327b261763d042f49e18c6326a4b476a36f
parentb39b80dc58b75ee5e2b32f4c8d112bb242074ecd (diff)
downloadtincapp-4f6dc804176b038f84ef83550b774cb8dccd31c4.tar.gz
activities: remove usage of kotlin view synthetics
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt14
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/start/ConnectionStarter.kt13
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/start/StartActivity.kt8
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/status/StatusActivity.kt8
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/viewlog/ViewLogActivity.kt21
5 files changed, 32 insertions, 32 deletions
diff --git a/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt b/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt
index f92c111..18787a8 100644
--- a/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt
+++ b/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt
@@ -20,27 +20,26 @@ package org.pacien.tincapp.activities
20 20
21import android.content.Intent 21import android.content.Intent
22import android.os.Bundle 22import android.os.Bundle
23import androidx.annotation.LayoutRes
24import androidx.annotation.StringRes 23import androidx.annotation.StringRes
25import com.google.android.material.snackbar.Snackbar 24import com.google.android.material.snackbar.Snackbar
26import androidx.appcompat.app.AlertDialog 25import androidx.appcompat.app.AlertDialog
27import androidx.appcompat.app.AppCompatActivity 26import androidx.appcompat.app.AppCompatActivity
28import android.view.* 27import android.view.*
29import kotlinx.android.synthetic.main.base_activity.*
30import org.pacien.tincapp.R 28import org.pacien.tincapp.R
31import org.pacien.tincapp.context.App 29import org.pacien.tincapp.context.App
32import org.pacien.tincapp.context.AppInfo 30import org.pacien.tincapp.context.AppInfo
31import org.pacien.tincapp.databinding.BaseActivityBinding
33 32
34/** 33/**
35 * @author euxane 34 * @author euxane
36 */ 35 */
37abstract class BaseActivity : AppCompatActivity() { 36abstract class BaseActivity : AppCompatActivity() {
38 private val rootView by lazy { base_activity_frame!! } 37 val rootView by lazy { BaseActivityBinding.inflate(layoutInflater).root }
39 private var active = false 38 private var active = false
40 39
41 override fun onCreate(savedInstanceState: Bundle?) { 40 override fun onCreate(savedInstanceState: Bundle?) {
42 super.onCreate(savedInstanceState) 41 super.onCreate(savedInstanceState)
43 super.setContentView(R.layout.base_activity) 42 super.setContentView(rootView)
44 } 43 }
45 44
46 override fun onCreateOptionsMenu(m: Menu): Boolean { 45 override fun onCreateOptionsMenu(m: Menu): Boolean {
@@ -96,11 +95,8 @@ abstract class BaseActivity : AppCompatActivity() {
96 if (active) super.runOnUiThread(action) 95 if (active) super.runOnUiThread(action)
97 } 96 }
98 97
99 fun inflate(@LayoutRes layout: Int) = layoutInflater.inflate(layout, rootView, false)!! 98 fun notify(@StringRes msg: Int) = Snackbar.make(rootView, msg, Snackbar.LENGTH_LONG).show()
100 fun inflate(inflateFunc: (LayoutInflater, ViewGroup?, Boolean) -> View) = inflateFunc(layoutInflater, rootView, false) 99 fun notify(msg: String) = Snackbar.make(rootView, msg, Snackbar.LENGTH_LONG).show()
101
102 fun notify(@StringRes msg: Int) = Snackbar.make(base_activity_frame, msg, Snackbar.LENGTH_LONG).show()
103 fun notify(msg: String) = Snackbar.make(base_activity_frame, msg, Snackbar.LENGTH_LONG).show()
104 100
105 fun showErrorDialog(msg: String): AlertDialog = AlertDialog.Builder(this) 101 fun showErrorDialog(msg: String): AlertDialog = AlertDialog.Builder(this)
106 .setTitle(R.string.generic_title_error).setMessage(msg) 102 .setTitle(R.string.generic_title_error).setMessage(msg)
diff --git a/app/src/main/java/org/pacien/tincapp/activities/start/ConnectionStarter.kt b/app/src/main/java/org/pacien/tincapp/activities/start/ConnectionStarter.kt
index 6ae3954..05df357 100644
--- a/app/src/main/java/org/pacien/tincapp/activities/start/ConnectionStarter.kt
+++ b/app/src/main/java/org/pacien/tincapp/activities/start/ConnectionStarter.kt
@@ -21,9 +21,8 @@ package org.pacien.tincapp.activities.start
21import android.net.VpnService 21import android.net.VpnService
22import androidx.appcompat.app.AlertDialog 22import androidx.appcompat.app.AlertDialog
23import android.view.inputmethod.EditorInfo 23import android.view.inputmethod.EditorInfo
24import kotlinx.android.synthetic.main.base_activity.*
25import kotlinx.android.synthetic.main.dialog_decrypt_keys.view.*
26import org.pacien.tincapp.R 24import org.pacien.tincapp.R
25import org.pacien.tincapp.databinding.DialogDecryptKeysBinding
27import org.pacien.tincapp.service.TincVpnService 26import org.pacien.tincapp.service.TincVpnService
28import org.pacien.tincapp.utils.TincKeyring 27import org.pacien.tincapp.utils.TincKeyring
29import org.pacien.tincapp.extensions.View.on 28import org.pacien.tincapp.extensions.View.on
@@ -54,18 +53,18 @@ class ConnectionStarter(private val parentActivity: StartActivity) {
54 } 53 }
55 54
56 private fun askForPassphrase() { 55 private fun askForPassphrase() {
57 val dialogView = parentActivity.layoutInflater.inflate(R.layout.dialog_decrypt_keys, parentActivity.base_activity_frame, false) 56 val dialogViewBinding = DialogDecryptKeysBinding.inflate(parentActivity.layoutInflater, parentActivity.rootView, false)
58 57
59 val dialog = AlertDialog.Builder(parentActivity) 58 val dialog = AlertDialog.Builder(parentActivity)
60 .setTitle(R.string.decrypt_key_modal_title) 59 .setTitle(R.string.decrypt_key_modal_title)
61 .setView(dialogView) 60 .setView(dialogViewBinding.root)
62 .setPositiveButton(R.string.decrypt_key_modal_action_unlock) { _, _ -> tryStart(passphrase = dialogView.passphrase.text.toString()) } 61 .setPositiveButton(R.string.decrypt_key_modal_action_unlock) { _, _ -> tryStart(passphrase = dialogViewBinding.passphrase.text.toString()) }
63 .setNegativeButton(R.string.decrypt_key_modal_action_cancel) { _, _ -> Unit } 62 .setNegativeButton(R.string.decrypt_key_modal_action_cancel) { _, _ -> Unit }
64 .create() 63 .create()
65 64
66 dialogView.passphrase.on(EditorInfo.IME_ACTION_DONE) { 65 dialogViewBinding.passphrase.on(EditorInfo.IME_ACTION_DONE) {
67 dialog.dismiss() 66 dialog.dismiss()
68 tryStart(passphrase = dialogView.passphrase.text.toString()) 67 tryStart(passphrase = dialogViewBinding.passphrase.text.toString())
69 } 68 }
70 69
71 dialog.show() 70 dialog.show()
diff --git a/app/src/main/java/org/pacien/tincapp/activities/start/StartActivity.kt b/app/src/main/java/org/pacien/tincapp/activities/start/StartActivity.kt
index 300c106..8194cdb 100644
--- a/app/src/main/java/org/pacien/tincapp/activities/start/StartActivity.kt
+++ b/app/src/main/java/org/pacien/tincapp/activities/start/StartActivity.kt
@@ -24,7 +24,6 @@ import android.os.Bundle
24import androidx.appcompat.app.AlertDialog 24import androidx.appcompat.app.AlertDialog
25import android.view.Menu 25import android.view.Menu
26import android.view.MenuItem 26import android.view.MenuItem
27import kotlinx.android.synthetic.main.start_activity.*
28import org.pacien.tincapp.R 27import org.pacien.tincapp.R
29import org.pacien.tincapp.activities.BaseActivity 28import org.pacien.tincapp.activities.BaseActivity
30import org.pacien.tincapp.activities.common.ProgressModal 29import org.pacien.tincapp.activities.common.ProgressModal
@@ -32,6 +31,7 @@ import org.pacien.tincapp.activities.common.RecentCrashHandler
32import org.pacien.tincapp.activities.configure.ConfigureActivity 31import org.pacien.tincapp.activities.configure.ConfigureActivity
33import org.pacien.tincapp.activities.status.StatusActivity 32import org.pacien.tincapp.activities.status.StatusActivity
34import org.pacien.tincapp.context.App 33import org.pacien.tincapp.context.App
34import org.pacien.tincapp.databinding.StartActivityBinding
35import org.pacien.tincapp.intent.Actions 35import org.pacien.tincapp.intent.Actions
36import org.pacien.tincapp.intent.BroadcastMapper 36import org.pacien.tincapp.intent.BroadcastMapper
37import org.pacien.tincapp.service.TincVpnService 37import org.pacien.tincapp.service.TincVpnService
@@ -48,11 +48,13 @@ class StartActivity : BaseActivity() {
48 Actions.EVENT_ABORTED to this::onVpnStartError 48 Actions.EVENT_ABORTED to this::onVpnStartError
49 )) 49 ))
50 50
51 private val startActivityBinding by lazy { StartActivityBinding.inflate(layoutInflater) }
52
51 private var connectDialog: AlertDialog? = null 53 private var connectDialog: AlertDialog? = null
52 54
53 override fun onCreate(savedInstanceState: Bundle?) { 55 override fun onCreate(savedInstanceState: Bundle?) {
54 super.onCreate(savedInstanceState) 56 super.onCreate(savedInstanceState)
55 setContentView(R.layout.start_activity) 57 setContentView(startActivityBinding.root)
56 initNetworkListFragment() 58 initNetworkListFragment()
57 59
58 if (intent.action == Actions.ACTION_CONNECT && intent.data?.schemeSpecificPart != null) 60 if (intent.action == Actions.ACTION_CONNECT && intent.data?.schemeSpecificPart != null)
@@ -60,7 +62,7 @@ class StartActivity : BaseActivity() {
60 } 62 }
61 63
62 private fun initNetworkListFragment() { 64 private fun initNetworkListFragment() {
63 val fragment = start_activity_network_list_fragment as NetworkListFragment 65 val fragment = supportFragmentManager.findFragmentById(R.id.start_activity_network_list_fragment) as NetworkListFragment
64 fragment.connectToNetworkAction = { netName -> connectToNetworkAction(netName) } 66 fragment.connectToNetworkAction = { netName -> connectToNetworkAction(netName) }
65 } 67 }
66 68
diff --git a/app/src/main/java/org/pacien/tincapp/activities/status/StatusActivity.kt b/app/src/main/java/org/pacien/tincapp/activities/status/StatusActivity.kt
index 40a3974..9104c6e 100644
--- a/app/src/main/java/org/pacien/tincapp/activities/status/StatusActivity.kt
+++ b/app/src/main/java/org/pacien/tincapp/activities/status/StatusActivity.kt
@@ -23,7 +23,6 @@ import android.os.Bundle
23import androidx.appcompat.app.AlertDialog 23import androidx.appcompat.app.AlertDialog
24import android.view.Menu 24import android.view.Menu
25import android.view.MenuItem 25import android.view.MenuItem
26import kotlinx.android.synthetic.main.status_activity.*
27import org.pacien.tincapp.R 26import org.pacien.tincapp.R
28import org.pacien.tincapp.activities.BaseActivity 27import org.pacien.tincapp.activities.BaseActivity
29import org.pacien.tincapp.activities.common.FragmentListPagerAdapter 28import org.pacien.tincapp.activities.common.FragmentListPagerAdapter
@@ -34,6 +33,7 @@ import org.pacien.tincapp.activities.status.networkinfo.NetworkInfoFragment
34import org.pacien.tincapp.activities.status.nodes.NodeListFragment 33import org.pacien.tincapp.activities.status.nodes.NodeListFragment
35import org.pacien.tincapp.activities.status.subnets.SubnetListFragment 34import org.pacien.tincapp.activities.status.subnets.SubnetListFragment
36import org.pacien.tincapp.activities.viewlog.ViewLogActivity 35import org.pacien.tincapp.activities.viewlog.ViewLogActivity
36import org.pacien.tincapp.databinding.StatusActivityBinding
37import org.pacien.tincapp.intent.Actions 37import org.pacien.tincapp.intent.Actions
38import org.pacien.tincapp.intent.BroadcastMapper 38import org.pacien.tincapp.intent.BroadcastMapper
39import org.pacien.tincapp.service.TincVpnService 39import org.pacien.tincapp.service.TincVpnService
@@ -53,13 +53,15 @@ class StatusActivity : BaseActivity() {
53 R.string.status_activity_title_subnet_list to SubnetListFragment() 53 R.string.status_activity_title_subnet_list to SubnetListFragment()