diff options
| author | David Göransson <david.goransson90@gmail.com> | 2023-09-11 15:59:09 +0200 |
|---|---|---|
| committer | David Göransson <david.goransson90@gmail.com> | 2023-09-12 11:22:16 +0200 |
| commit | d63db4ab40c71b07368f7778d8fb0f23392352e2 (patch) | |
| tree | a9392bfc7a24f5fa6f595b9d35cfd8c97951d142 /android | |
| parent | fa733200f25e9ef89f138f848af2b0be9eba2e2b (diff) | |
| download | mullvadvpn-d63db4ab40c71b07368f7778d8fb0f23392352e2.tar.xz mullvadvpn-d63db4ab40c71b07368f7778d8fb0f23392352e2.zip | |
Perform AS Code Cleanup
Diffstat (limited to 'android')
22 files changed, 91 insertions, 93 deletions
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/util/RememberPrevious.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/util/RememberPrevious.kt index ef47f61472..6782e0ab55 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/util/RememberPrevious.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/util/RememberPrevious.kt @@ -31,7 +31,7 @@ fun <T> rememberPrevious( private fun <T> rememberRef(): MutableState<T?> { // for some reason it always recreated the value with vararg keys, // leaving out the keys as a parameter for remember for now - return remember() { + return remember { object : MutableState<T?> { override var value: T? = null diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/MullvadProblemReport.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/MullvadProblemReport.kt index 7104deb686..27b1eb694d 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/MullvadProblemReport.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/MullvadProblemReport.kt @@ -15,13 +15,13 @@ const val PROBLEM_REPORT_FILE = "problem_report.txt" class MullvadProblemReport { private sealed class Command { - class Collect() : Command() + data object Collect : Command() class Load(val logs: CompletableDeferred<String>) : Command() class Send(val result: CompletableDeferred<Boolean>) : Command() - class Delete() : Command() + data object Delete : Command() } val logDirectory = CompletableDeferred<File>() @@ -44,7 +44,7 @@ class MullvadProblemReport { } fun collect() { - commandChannel.trySendBlocking(Command.Collect()) + commandChannel.trySendBlocking(Command.Collect) } suspend fun load(): String { @@ -64,7 +64,7 @@ class MullvadProblemReport { } fun deleteReportFile() { - commandChannel.trySendBlocking(Command.Delete()) + commandChannel.trySendBlocking(Command.Delete) } private fun spawnActor() = diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/BlockingController.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/BlockingController.kt index 4dd53fa937..3305418a48 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/BlockingController.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/BlockingController.kt @@ -10,7 +10,7 @@ class BlockingController(val blockableView: BlockableView) { var innerJob: Job? = null fun action() { - if (!(job?.isActive ?: false)) { + if (job?.isActive != true) { job = GlobalScope.launch(Dispatchers.Main) { blockableView.setEnabled(false) diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/CollapsibleTitleController.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/CollapsibleTitleController.kt index 658fd3fed3..1c37945602 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/CollapsibleTitleController.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/CollapsibleTitleController.kt @@ -46,16 +46,15 @@ class CollapsibleTitleController(val parentView: View, scrollAreaId: Int = R.id. private val xOffsetInterpolation = LinearInterpolation() private val yOffsetInterpolation = LinearInterpolation() - private val collapsedTitleLayoutListener: LayoutListener = - LayoutListener() { collapsedTitle -> - val (x, y) = calculateViewCoordinates(collapsedTitle) + private val collapsedTitleLayoutListener: LayoutListener = LayoutListener { collapsedTitle -> + val (x, y) = calculateViewCoordinates(collapsedTitle) - collapsedTitleHeight = collapsedTitle.height.toFloat() + collapsedTitleHeight = collapsedTitle.height.toFloat() - scaleInterpolation.end = collapsedTitleHeight / maxOf(1.0f, titleHeight) - xOffsetInterpolation.end = x - yOffsetInterpolation.end = y - } + scaleInterpolation.end = collapsedTitleHeight / maxOf(1.0f, titleHeight) + xOffsetInterpolation.end = x + yOffsetInterpolation.end = y + } private val collapsedTitleView = parentView.findViewById<View>(R.id.collapsed_title).apply { @@ -63,37 +62,35 @@ class CollapsibleTitleController(val parentView: View, scrollAreaId: Int = R.id. visibility = View.INVISIBLE } - private val expandedTitleLayoutListener: LayoutListener = - LayoutListener() { expandedTitle -> - val (x, y) = calculateViewCoordinates(expandedTitle) + private val expandedTitleLayoutListener: LayoutListener = LayoutListener { expandedTitle -> + val (x, y) = calculateViewCoordinates(expandedTitle) - val expandedTitleMarginTop = - when (val layoutParams = expandedTitle.layoutParams) { - is MarginLayoutParams -> layoutParams.topMargin - else -> 0 - } + val expandedTitleMarginTop = + when (val layoutParams = expandedTitle.layoutParams) { + is MarginLayoutParams -> layoutParams.topMargin + else -> 0 + } - expandedTitleHeight = expandedTitle.height.toFloat() + expandedTitleHeight = expandedTitle.height.toFloat() - scaleInterpolation.start = expandedTitleHeight / maxOf(1.0f, titleHeight) - xOffsetInterpolation.start = x - yOffsetInterpolation.start = y + scaleInterpolation.start = expandedTitleHeight / maxOf(1.0f, titleHeight) + xOffsetInterpolation.start = x + yOffsetInterpolation.start = y - scrollInterpolation.end = expandedTitleHeight + expandedTitleMarginTop - } + scrollInterpolation.end = expandedTitleHeight + expandedTitleMarginTop + } - private val titleLayoutListener: LayoutListener = - LayoutListener() { title -> - val (x, y) = calculateViewCoordinates(title) + private val titleLayoutListener: LayoutListener = LayoutListener { title -> + val (x, y) = calculateViewCoordinates(title) - titleWidth = title.width.toFloat() - titleHeight = title.height.toFloat() + titleWidth = title.width.toFloat() + titleHeight = title.height.toFloat() - scaleInterpolation.start = expandedTitleHeight / maxOf(1.0f, titleHeight) - scaleInterpolation.end = collapsedTitleHeight / maxOf(1.0f, titleHeight) - xOffsetInterpolation.reference = x - yOffsetInterpolation.reference = y - } + scaleInterpolation.start = expandedTitleHeight / maxOf(1.0f, titleHeight) + scaleInterpolation.end = collapsedTitleHeight / maxOf(1.0f, titleHeight) + xOffsetInterpolation.reference = x + yOffsetInterpolation.reference = y + } private val titleView = parentView.findViewById<View>(R.id.title).apply { @@ -104,8 +101,9 @@ class CollapsibleTitleController(val parentView: View, scrollAreaId: Int = R.id. pivotY = 0.0f } - private val scrollAreaLayoutListener: LayoutListener = - LayoutListener() { scrollOffset = scrollArea.verticalScrollOffset.toFloat() } + private val scrollAreaLayoutListener: LayoutListener = LayoutListener { + scrollOffset = scrollArea.verticalScrollOffset.toFloat() + } private val scrollArea = parentView.findViewById<View>(scrollAreaId).let { view -> diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/CustomTransformationMethod.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/CustomTransformationMethod.kt index 083258c62d..451c51fa3f 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/CustomTransformationMethod.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/CustomTransformationMethod.kt @@ -10,7 +10,7 @@ private const val DOT_CHAR = '\u2022' private const val EMPTY_STRING = "" private const val SPACE_CHAR = ' ' -class GroupedTransformationMethod() : TransformationMethod { +class GroupedTransformationMethod : TransformationMethod { override fun getTransformation(source: CharSequence?, view: View?): CharSequence { return source?.groupWithSpaces() ?: EMPTY_STRING } @@ -26,7 +26,7 @@ class GroupedTransformationMethod() : TransformationMethod { } } -class GroupedPasswordTransformationMethod() : PasswordTransformationMethod() { +class GroupedPasswordTransformationMethod : PasswordTransformationMethod() { override fun getTransformation(source: CharSequence?, view: View?): CharSequence { return if (source != null && view != null) { super.getTransformation(source, view) diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/LoginFragment.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/LoginFragment.kt index c02ed0b652..7e298e3f73 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/LoginFragment.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/LoginFragment.kt @@ -272,7 +272,7 @@ class LoginFragment : BaseFragment(), NavigationBarPainter { private fun loginFailure(description: String? = "") { title.setText(R.string.login_fail_title) - subtitle.setText(description) + subtitle.text = description loggingInStatus.visibility = View.GONE loginFailStatus.visibility = View.VISIBLE diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/OutOfTimeFragment.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/OutOfTimeFragment.kt index 9b5eb395ad..1a59f19ff7 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/OutOfTimeFragment.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/OutOfTimeFragment.kt @@ -96,11 +96,11 @@ class OutOfTimeFragment : BaseFragment() { newAccount = false setOnClickAction("openAccountPageInBrowser", jobTracker) { - setEnabled(false) + isEnabled = false serviceConnectionManager.authTokenCache()?.fetchAuthToken()?.let { token -> context.openAccountPageInBrowser(token) } - setEnabled(true) + isEnabled = true } isEnabled = true @@ -170,10 +170,10 @@ class OutOfTimeFragment : BaseFragment() { disconnectButton.apply { if (showButton) { - setEnabled(true) + isEnabled = true visibility = View.VISIBLE } else { - setEnabled(false) + isEnabled = false visibility = View.GONE } } @@ -182,17 +182,17 @@ class OutOfTimeFragment : BaseFragment() { private fun updateBuyButtons() { val currentState = tunnelState val hasConnectivity = currentState is TunnelState.Disconnected - sitePaymentButton.setEnabled(hasConnectivity) + sitePaymentButton.isEnabled = hasConnectivity val isOffline = currentState is TunnelState.Error && currentState.errorState.cause is ErrorStateCause.IsOffline - redeemButton.setEnabled(!isOffline) + redeemButton.isEnabled = !isOffline } private fun checkExpiry(maybeExpiry: DateTime?) { maybeExpiry?.let { expiry -> - if (expiry.isAfterNow()) { + if (expiry.isAfterNow) { jobTracker.newUiJob("advanceToConnectScreen") { advanceToConnectScreen() } } } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/ProblemReportFragment.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/ProblemReportFragment.kt index 4d5ca3c9b5..b30b5713fb 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/ProblemReportFragment.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/ProblemReportFragment.kt @@ -280,7 +280,7 @@ class ProblemReportFragment : BaseFragment() { } private fun setSendButtonEnabled(enabled: Boolean) { - sendButton.setEnabled(enabled) + sendButton.isEnabled = enabled sendButton.alpha = if (enabled) 1.0F else 0.5F } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/RedeemVoucherDialogFragment.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/RedeemVoucherDialogFragment.kt index 59318a8268..46472ea6cc 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/RedeemVoucherDialogFragment.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/RedeemVoucherDialogFragment.kt @@ -88,7 +88,7 @@ class RedeemVoucherDialogFragment : DialogFragment() { redeemButton = view.findViewById<Button>(R.id.redeem).apply { - setEnabled(false) + isEnabled = false setOnClickAction("action", jobTracker) { submitVoucher() } } @@ -130,7 +130,7 @@ class RedeemVoucherDialogFragment : DialogFragment() { } private fun updateRedeemButton() { - redeemButton?.setEnabled(voucherInputIsValid && voucherRedeemer != null) + redeemButton?.isEnabled = voucherInputIsValid && voucherRedeemer != null } private suspend fun submitVoucher() { diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AccountInput.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AccountInput.kt index 32e81a25e4..11759d469e 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AccountInput.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AccountInput.kt @@ -120,8 +120,8 @@ class AccountInput : LinearLayout { private fun initialState() { input.apply { setTextColor(enabledTextColor) - setEnabled(true) - setFocusableInTouchMode(true) + isEnabled = true + isFocusableInTouchMode = true visibility = View.VISIBLE } @@ -132,8 +132,8 @@ class AccountInput : LinearLayout { private fun loggingInState() { input.apply { setTextColor(disabledTextColor) - setEnabled(false) - setFocusable(false) + isEnabled = false + isFocusable = false visibility = View.VISIBLE } @@ -144,8 +144,8 @@ class AccountInput : LinearLayout { private fun successState() { input.apply { setTextColor(disabledTextColor) - setEnabled(false) - setFocusable(false) + isEnabled = false + isFocusable = false visibility = View.VISIBLE } @@ -159,8 +159,8 @@ class AccountInput : LinearLayout { input.apply { setTextColor(errorTextColor) - setEnabled(true) - setFocusableInTouchMode(true) + isEnabled = true + isFocusableInTouchMode = true visibility = View.VISIBLE requestFocus() } @@ -168,10 +168,10 @@ class AccountInput : LinearLayout { private fun setButtonEnabled(enabled: Boolean) { button.apply { - if (enabled != isEnabled()) { - setEnabled(enabled) - setClickable(enabled) - setFocusable(enabled) + if (enabled != isEnabled) { + isEnabled = enabled + isClickable = enabled + isFocusable = enabled } } } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/BackButton.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/BackButton.kt index 7cb3626084..efa2d6f5a6 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/BackButton.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/BackButton.kt @@ -19,7 +19,7 @@ class BackButton : LinearLayout { private val label = container.findViewById<TextView>(R.id.label) - constructor(context: Context) : super(context) {} + constructor(context: Context) : super(context) constructor(context: Context, attributes: AttributeSet) : super(context, attributes) { loadAttributes(attributes) @@ -43,7 +43,7 @@ class BackButton : LinearLayout { } init { - setFocusable(true) + isFocusable = true isClickable = true gravity = Gravity.CENTER_VERTICAL or Gravity.START orientation = HORIZONTAL diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/Button.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/Button.kt index c2a5f3510b..e6c266683b 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/Button.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/Button.kt @@ -80,7 +80,7 @@ open class Button : FrameLayout { var showSpinner = false - constructor(context: Context) : super(context) {} + constructor(context: Context) : super(context) constructor(context: Context, attributes: AttributeSet) : super(context, attributes) { loadAttributes(attributes) @@ -105,7 +105,7 @@ open class Button : FrameLayout { override fun setEnabled(enabled: Boolean) { super.setEnabled(enabled) - button.setEnabled(enabled) + button.isEnabled = enabled if (enabled) { alpha = 1.0f @@ -117,7 +117,7 @@ open class Button : FrameLayout { init { button.setOnClickListener { jobTracker?.newUiJob(clickJobName!!) { - setEnabled(false) + isEnabled = false if (showSpinner) { image.visibility = GONE @@ -132,7 +132,7 @@ open class Button : FrameLayout { image.visibility = VISIBLE } - setEnabled(true) + isEnabled = true } } } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/util/SegmentedInputFormatter.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/util/SegmentedInputFormatter.kt index 4dd6b7bc1b..6d3a3e5cc8 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/util/SegmentedInputFormatter.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/util/SegmentedInputFormatter.kt @@ -3,6 +3,7 @@ package net.mullvad.mullvadvpn.util import android.text.Editable import android.text.TextWatcher import android.widget.EditText +import java.util.Locale class SegmentedInputFormatter(val input: EditText, var separator: Char) : TextWatcher { private var editing = false @@ -114,7 +115,11 @@ class SegmentedInputFormatter(val input: EditText, var separator: Char) : TextWa val character = input[index] if (allCaps && character >= 'a' && character <= 'z') { - input.replace(index, index + 1, character.toString().toUpperCase()) + input.replace( + index, + index + 1, + character.toString().uppercase(Locale.getDefault()) + ) } else if (!isValidInputCharacter(character)) { input.delete(index, index + 1) } else { diff --git a/android/lib/ipc/src/main/kotlin/net/mullvad/mullvadvpn/lib/ipc/Event.kt b/android/lib/ipc/src/main/kotlin/net/mullvad/mullvadvpn/lib/ipc/Event.kt index 9ce1ccc698..c5ede20327 100644 --- a/android/lib/ipc/src/main/kotlin/net/mullvad/mullvadvpn/lib/ipc/Event.kt +++ b/android/lib/ipc/src/main/kotlin/net/mullvad/mullvadvpn/lib/ipc/Event.kt @@ -18,7 +18,7 @@ import net.mullvad.mullvadvpn.model.VoucherSubmissionResult // Events that can be sent from the service sealed class Event : Message.EventMessage() { - protected override val messageKey = MESSAGE_KEY + override val messageKey = MESSAGE_KEY @Parcelize data class AccountCreationEvent(val result: AccountCreationResult) : Event() diff --git a/android/lib/ipc/src/main/kotlin/net/mullvad/mullvadvpn/lib/ipc/Request.kt b/android/lib/ipc/src/main/kotlin/net/mullvad/mullvadvpn/lib/ipc/Request.kt index ad91632cbf..2a8636fa95 100644 --- a/android/lib/ipc/src/main/kotlin/net/mullvad/mullvadvpn/lib/ipc/Request.kt +++ b/android/lib/ipc/src/main/kotlin/net/mullvad/mullvadvpn/lib/ipc/Request.kt @@ -12,7 +12,7 @@ import net.mullvad.mullvadvpn.model.WireguardConstraints // Requests that the service can handle sealed class Request : Message.RequestMessage() { - protected override val messageKey = MESSAGE_KEY + override val messageKey = MESSAGE_KEY @Parcelize @Deprecated("Use SetDnsOptions") diff --git a/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/model/Constraint.kt b/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/model/Constraint.kt index c6dc2bb091..d9ca22b164 100644 --- a/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/model/Constraint.kt +++ b/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/model/Constraint.kt @@ -3,10 +3,8 @@ package net.mullvad.mullvadvpn.model import android.os.Parcelable import kotlinx.parcelize.Parcelize -sealed class Constraint<T>() : Parcelable { - @Parcelize - @Suppress("PARCELABLE_PRIMARY_CONSTRUCTOR_IS_EMPTY") - class Any<T>() : Constraint<T>() +sealed class Constraint<T> : Parcelable { + @Parcelize @Suppress("PARCELABLE_PRIMARY_CONSTRUCTOR_IS_EMPTY") class Any<T> : Constraint<T>() @Parcelize data class Only<T : Parcelable>(val value: T) : Constraint<T>() } diff --git a/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/model/CustomTunnelEndpoint.kt b/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/model/CustomTunnelEndpoint.kt index 05dd38a80b..72276c65e4 100644 --- a/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/model/CustomTunnelEndpoint.kt +++ b/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/model/CustomTunnelEndpoint.kt @@ -1,3 +1,3 @@ package net.mullvad.mullvadvpn.model -class CustomTunnelEndpoint() +class CustomTunnelEndpoint diff --git a/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/model/Device.kt b/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/model/Device.kt index 92f0621e6e..4918ee0832 100644 --- a/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/model/Device.kt +++ b/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/model/Device.kt @@ -15,9 +15,7 @@ data class Device(val id: String, val name: String, val pubkey: ByteArray, val c if (id != other.id) return false if (name != other.name) return false - if (!pubkey.contentEquals(other.pubkey)) return false - - return true + return pubkey.contentEquals(other.pubkey) } // Generated by Android Studio diff --git a/android/lib/talpid/src/main/kotlin/net/mullvad/talpid/TalpidVpnService.kt b/android/lib/talpid/src/main/kotlin/net/mullvad/talpid/TalpidVpnService.kt index caa8f11447..1d43b6f9f9 100644 --- a/android/lib/talpid/src/main/kotlin/net/mullvad/talpid/TalpidVpnService.kt +++ b/android/lib/talpid/src/main/kotlin/net/mullvad/talpid/TalpidVpnService.kt @@ -82,7 +82,7 @@ open class TalpidVpnService : VpnService() { } private fun createTun(config: TunConfig): CreateTunResult { - if (VpnService.prepare(this) != null) { + if (prepare(this) != null) { // VPN permission wasn't granted return CreateTunResult.PermissionDenied } @@ -126,7 +126,7 @@ open class TalpidVpnService : VpnService() { waitForTunnelUp(tunFd, config.routes.any { route -> route.isIpv6 }) - if (!invalidDnsServerAddresses.isEmpty()) { + if (invalidDnsServerAddresses.isNotEmpty()) { return CreateTunResult.InvalidDnsServers(invalidDnsServerAddresses, tunFd) } @@ -138,9 +138,9 @@ open class TalpidVpnService : VpnService() { } private fun prefixForAddress(address: InetAddress): Int { - when (address) { - is Inet4Address -> return 32 - is Inet6Address -> return 128 + return when (address) { + is Inet4Address -> 32 + is Inet6Address -> 128 else -> throw RuntimeException("Invalid IP address (not IPv4 nor IPv6)") } } diff --git a/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt b/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt index 9024eaad18..6f148beea0 100644 --- a/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt +++ b/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt @@ -4,7 +4,6 @@ import android.annotation.SuppressLint import android.app.KeyguardManager import android.content.Context import android.content.Intent -import android.net.VpnService import android.os.IBinder import android.os.Looper import android.util.Log @@ -138,7 +137,7 @@ class MullvadVpnService : TalpidVpnService() { if (!keyguardManager.isDeviceLocked) { val action = intent?.action - if (action == VpnService.SERVICE_INTERFACE || action == KEY_CONNECT_ACTION) { + if (action == SERVICE_INTERFACE || action == KEY_CONNECT_ACTION) { pendingAction = PendingAction.Connect } else if (action == KEY_DISCONNECT_ACTION) { pendingAction = PendingAction.Disconnect diff --git a/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/AccountExpiryNotification.kt b/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/AccountExpiryNotification.kt index dcc97e8b11..e07f1725d7 100644 --- a/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/AccountExpiryNotification.kt +++ b/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/AccountExpiryNotification.kt @@ -108,8 +108,8 @@ class AccountExpiryNotification( if (BuildTypes.RELEASE == BuildConfig.BUILD_TYPE) { Intent().apply { setClassName(MULLVAD_PACKAGE_NAME, MAIN_ACTIVITY_CLASS) - setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP) - setAction(Intent.ACTION_MAIN) + flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP + action = Intent.ACTION_MAIN } } else { Intent(Intent.ACTION_VIEW, url) diff --git a/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/TunnelStateNotification.kt b/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/TunnelStateNotification.kt index b9691b6fa9..f79d55a1d0 100644 --- a/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/TunnelStateNotification.kt +++ b/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/TunnelStateNotification.kt @@ -116,8 +116,8 @@ class TunnelStateNotification(val context: Context) { val intent = Intent().apply { setClassName(MULLVAD_PACKAGE_NAME, MAIN_ACTIVITY_CLASS) - setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP) - setAction(Intent.ACTION_MAIN) + flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP + action = Intent.ACTION_MAIN } val pendingIntent = PendingIntent.getActivity(context, 1, intent, SdkUtils.getSupportedPendingIntentFlags()) |
