diff options
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 | ||
21 | import android.content.Intent | 21 | import android.content.Intent |
22 | import android.os.Bundle | 22 | import android.os.Bundle |
23 | import androidx.annotation.LayoutRes | ||
24 | import androidx.annotation.StringRes | 23 | import androidx.annotation.StringRes |
25 | import com.google.android.material.snackbar.Snackbar | 24 | import com.google.android.material.snackbar.Snackbar |
26 | import androidx.appcompat.app.AlertDialog | 25 | import androidx.appcompat.app.AlertDialog |
27 | import androidx.appcompat.app.AppCompatActivity | 26 | import androidx.appcompat.app.AppCompatActivity |
28 | import android.view.* | 27 | import android.view.* |
29 | import kotlinx.android.synthetic.main.base_activity.* | ||
30 | import org.pacien.tincapp.R | 28 | import org.pacien.tincapp.R |
31 | import org.pacien.tincapp.context.App | 29 | import org.pacien.tincapp.context.App |
32 | import org.pacien.tincapp.context.AppInfo | 30 | import org.pacien.tincapp.context.AppInfo |
31 | import org.pacien.tincapp.databinding.BaseActivityBinding | ||
33 | 32 | ||
34 | /** | 33 | /** |
35 | * @author euxane | 34 | * @author euxane |
36 | */ | 35 | */ |
37 | abstract class BaseActivity : AppCompatActivity() { | 36 | abstract 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 | |||
21 | import android.net.VpnService | 21 | import android.net.VpnService |
22 | import androidx.appcompat.app.AlertDialog | 22 | import androidx.appcompat.app.AlertDialog |
23 | import android.view.inputmethod.EditorInfo | 23 | import android.view.inputmethod.EditorInfo |
24 | import kotlinx.android.synthetic.main.base_activity.* | ||
25 | import kotlinx.android.synthetic.main.dialog_decrypt_keys.view.* | ||
26 | import org.pacien.tincapp.R | 24 | import org.pacien.tincapp.R |
25 | import org.pacien.tincapp.databinding.DialogDecryptKeysBinding | ||
27 | import org.pacien.tincapp.service.TincVpnService | 26 | import org.pacien.tincapp.service.TincVpnService |
28 | import org.pacien.tincapp.utils.TincKeyring | 27 | import org.pacien.tincapp.utils.TincKeyring |
29 | import org.pacien.tincapp.extensions.View.on | 28 | import 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 | |||
24 | import androidx.appcompat.app.AlertDialog | 24 | import androidx.appcompat.app.AlertDialog |
25 | import android.view.Menu | 25 | import android.view.Menu |
26 | import android.view.MenuItem | 26 | import android.view.MenuItem |
27 | import kotlinx.android.synthetic.main.start_activity.* | ||
28 | import org.pacien.tincapp.R | 27 | import org.pacien.tincapp.R |
29 | import org.pacien.tincapp.activities.BaseActivity | 28 | import org.pacien.tincapp.activities.BaseActivity |
30 | import org.pacien.tincapp.activities.common.ProgressModal | 29 | import org.pacien.tincapp.activities.common.ProgressModal |
@@ -32,6 +31,7 @@ import org.pacien.tincapp.activities.common.RecentCrashHandler | |||
32 | import org.pacien.tincapp.activities.configure.ConfigureActivity | 31 | import org.pacien.tincapp.activities.configure.ConfigureActivity |
33 | import org.pacien.tincapp.activities.status.StatusActivity | 32 | import org.pacien.tincapp.activities.status.StatusActivity |
34 | import org.pacien.tincapp.context.App | 33 | import org.pacien.tincapp.context.App |
34 | import org.pacien.tincapp.databinding.StartActivityBinding | ||
35 | import org.pacien.tincapp.intent.Actions | 35 | import org.pacien.tincapp.intent.Actions |
36 | import org.pacien.tincapp.intent.BroadcastMapper | 36 | import org.pacien.tincapp.intent.BroadcastMapper |
37 | import org.pacien.tincapp.service.TincVpnService | 37 | import 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 | |||
23 | import androidx.appcompat.app.AlertDialog | 23 | import androidx.appcompat.app.AlertDialog |
24 | import android.view.Menu | 24 | import android.view.Menu |
25 | import android.view.MenuItem | 25 | import android.view.MenuItem |
26 | import kotlinx.android.synthetic.main.status_activity.* | ||
27 | import org.pacien.tincapp.R | 26 | import org.pacien.tincapp.R |
28 | import org.pacien.tincapp.activities.BaseActivity | 27 | import org.pacien.tincapp.activities.BaseActivity |
29 | import org.pacien.tincapp.activities.common.FragmentListPagerAdapter | 28 | import org.pacien.tincapp.activities.common.FragmentListPagerAdapter |
@@ -34,6 +33,7 @@ import org.pacien.tincapp.activities.status.networkinfo.NetworkInfoFragment | |||
34 | import org.pacien.tincapp.activities.status.nodes.NodeListFragment | 33 | import org.pacien.tincapp.activities.status.nodes.NodeListFragment |
35 | import org.pacien.tincapp.activities.status.subnets.SubnetListFragment | 34 | import org.pacien.tincapp.activities.status.subnets.SubnetListFragment |
36 | import org.pacien.tincapp.activities.viewlog.ViewLogActivity | 35 | import org.pacien.tincapp.activities.viewlog.ViewLogActivity |
36 | import org.pacien.tincapp.databinding.StatusActivityBinding | ||
37 | import org.pacien.tincapp.intent.Actions | 37 | import org.pacien.tincapp.intent.Actions |
38 | import org.pacien.tincapp.intent.BroadcastMapper | 38 | import org.pacien.tincapp.intent.BroadcastMapper |
39 | import org.pacien.tincapp.service.TincVpnService | 39 | import 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() |
54 | ) | 54 | ) |