diff options
| author | Emīls <emils@mullvad.net> | 2020-06-22 16:34:04 +0100 |
|---|---|---|
| committer | Emīls <emils@mullvad.net> | 2020-06-25 15:21:31 +0100 |
| commit | 79c674f7f5aed9e7d48330032134a0af6d53d3cf (patch) | |
| tree | 28b06725ffaade0d9b42446eca95f0b1ef415a4d /android/src | |
| parent | 0815cb48730fdd6c8e6435dac410aa8acd36bab4 (diff) | |
| download | mullvadvpn-79c674f7f5aed9e7d48330032134a0af6d53d3cf.tar.xz mullvadvpn-79c674f7f5aed9e7d48330032134a0af6d53d3cf.zip | |
Use new version info in Android
Diffstat (limited to 'android/src')
20 files changed, 97 insertions, 97 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/AppVersionInfoCache.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/AppVersionInfoCache.kt index 4b578f9a9b..4b73f9a878 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/AppVersionInfoCache.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/AppVersionInfoCache.kt @@ -27,38 +27,14 @@ class AppVersionInfoCache( } } - val latestStable - get() = appVersionInfo?.latestStable - val latest - get() = appVersionInfo?.latest val isSupported get() = appVersionInfo?.supported ?: true - val isOutdated: Boolean - get() { - if (showBetaReleases) { - return version != null && latest != null && latest != version - } else { - return version != null && latestStable != null && latestStable != version - } - } + val isOutdated + get() = appVersionInfo?.suggestedUpgrade != null - val upgradeVersion: String? - get() { - if (showBetaReleases) { - if (version == latest) { - return null - } else { - return latest - } - } else { - if (version == latestStable) { - return null - } else { - return latestStable - } - } - } + val upgradeVersion + get() = appVersionInfo?.suggestedUpgrade var onUpdate: (() -> Unit)? = null set(value) { diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/MullvadProblemReport.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/MullvadProblemReport.kt index 97e6559bd4..4bbc29c8c3 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/MullvadProblemReport.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/MullvadProblemReport.kt @@ -63,11 +63,11 @@ class MullvadProblemReport { if (currentJob == null || currentJob.isCompleted) { currentJob = GlobalScope.async(Dispatchers.Default) { val result = (collectJob?.await() ?: false) && - sendProblemReport( - userEmail, - userMessage, - problemReportPath.await().absolutePath - ) + sendProblemReport( + userEmail, + userMessage, + problemReportPath.await().absolutePath + ) if (result) { deleteReportFile() diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/model/AppVersionInfo.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/model/AppVersionInfo.kt index a28c06a505..5f985189d5 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/model/AppVersionInfo.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/model/AppVersionInfo.kt @@ -2,7 +2,5 @@ package net.mullvad.mullvadvpn.model data class AppVersionInfo( val supported: Boolean, - val latest: String, - val latestStable: String, - val latestBeta: String + val suggestedUpgrade: String? ) diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/ConnectionProxy.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/ConnectionProxy.kt index 17099078d8..3f1efab066 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/ConnectionProxy.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/ConnectionProxy.kt @@ -116,7 +116,8 @@ class ConnectionProxy(val context: Context, val daemon: MullvadDaemon) { val currentState = uiState if (currentState is TunnelState.Disconnecting && - currentState.actionAfterDisconnect == ActionAfterDisconnect.Reconnect) { + currentState.actionAfterDisconnect == ActionAfterDisconnect.Reconnect + ) { return false } else { scheduleToResetAnticipatedState() diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/ForegroundNotificationManager.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/ForegroundNotificationManager.kt index 5312af91f9..9d76a0be52 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/ForegroundNotificationManager.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/ForegroundNotificationManager.kt @@ -35,10 +35,10 @@ class ForegroundNotificationManager( } private var tunnelStateEvents - by autoSubscribable<TunnelState>(this, TunnelState.Disconnected()) { newState -> - tunnelStateNotification.tunnelState = newState - updateNotification() - } + by autoSubscribable<TunnelState>(this, TunnelState.Disconnected()) { newState -> + tunnelStateNotification.tunnelState = newState + updateNotification() + } private var deviceIsUnlocked by observable(!keyguardManager.isDeviceLocked) { _, _, _ -> updateNotificationAction() @@ -63,10 +63,13 @@ class ForegroundNotificationManager( } service.apply { - registerReceiver(deviceLockListener, IntentFilter().apply { - addAction(Intent.ACTION_USER_PRESENT) - addAction(Intent.ACTION_SCREEN_OFF) - }) + registerReceiver( + deviceLockListener, + IntentFilter().apply { + addAction(Intent.ACTION_USER_PRESENT) + addAction(Intent.ACTION_SCREEN_OFF) + } + ) } updateNotification() diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/KeyStatusListener.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/KeyStatusListener.kt index 595c97220e..8d44be4d36 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/KeyStatusListener.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/KeyStatusListener.kt @@ -26,9 +26,11 @@ class KeyStatusListener(val daemon: MullvadDaemon) { val newStatus = daemon.generateWireguardKey() val newFailure = newStatus?.failure() if (oldStatus is KeygenEvent.NewKey && newFailure != null) { - keyStatus = KeygenEvent.NewKey(oldStatus.publicKey, - oldStatus.verified, - newFailure) + keyStatus = KeygenEvent.NewKey( + oldStatus.publicKey, + oldStatus.verified, + newFailure + ) } else { keyStatus = newStatus ?: KeygenEvent.GenerationFailure() } @@ -39,9 +41,11 @@ class KeyStatusListener(val daemon: MullvadDaemon) { // Only update verification status if the key is actually there when (val state = keyStatus) { is KeygenEvent.NewKey -> { - keyStatus = KeygenEvent.NewKey(state.publicKey, - verified, - state.replacementFailure) + keyStatus = KeygenEvent.NewKey( + state.publicKey, + verified, + state.replacementFailure + ) } } } diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt index 795f5596df..14e62091cd 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt @@ -69,9 +69,9 @@ class MullvadVpnService : TalpidVpnService() { } private var accountExpiryNotification - by observable<AccountExpiryNotification?>(null) { _, oldNotification, _ -> - oldNotification?.accountExpiry = null - } + by observable<AccountExpiryNotification?>(null) { _, oldNotification, _ -> + oldNotification?.accountExpiry = null + } private lateinit var keyguardManager: KeyguardManager private lateinit var notificationManager: ForegroundNotificationManager diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/TunnelStateNotification.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/TunnelStateNotification.kt index e91908f088..7f95cf5b39 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/TunnelStateNotification.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/TunnelStateNotification.kt @@ -59,8 +59,10 @@ class TunnelStateNotification(val context: Context) { var tunnelState by observable<TunnelState>(TunnelState.Disconnected()) { _, _, newState -> reconnecting = - (newState is TunnelState.Disconnecting && - newState.actionAfterDisconnect == ActionAfterDisconnect.Reconnect) || + ( + newState is TunnelState.Disconnecting && + newState.actionAfterDisconnect == ActionAfterDisconnect.Reconnect + ) || (newState is TunnelState.Connecting && reconnecting) update() diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/tunnelstate/Persistence.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/tunnelstate/Persistence.kt index f1366abc66..73b5c6de7e 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/tunnelstate/Persistence.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/tunnelstate/Persistence.kt @@ -12,10 +12,12 @@ private const val SHARED_PREFERENCES = "tunnel_state" private const val KEY_TUNNEL_STATE = "tunnel_state" // TODO: Maybe replace using this with actually persisting the endpoint information -private val dummyTunnelEndpoint = TunnelEndpoint(Endpoint( - InetSocketAddress.createUnresolved("dummy", 53), - TransportProtocol.Tcp -)) +private val dummyTunnelEndpoint = TunnelEndpoint( + Endpoint( + InetSocketAddress.createUnresolved("dummy", 53), + TransportProtocol.Tcp + ) +) internal class Persistence(context: Context) { val sharedPreferences = diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/AccountInput.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/AccountInput.kt index 9b46b50610..d67a878b25 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/AccountInput.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/AccountInput.kt @@ -81,13 +81,15 @@ class AccountInput( input.apply { addTextChangedListener(InputWatcher()) - setOnTouchListener(OnTouchListener { - _, event -> - if (MotionEvent.ACTION_UP == event.getAction()) { - shouldShowAccountHistory = true + setOnTouchListener( + OnTouchListener { + _, event -> + if (MotionEvent.ACTION_UP == event.getAction()) { + shouldShowAccountHistory = true + } + false } - false - }) + ) } container.apply { @@ -155,10 +157,14 @@ class AccountInput( private fun updateAccountHistory() { accountHistory?.let { history -> accountHistoryList.apply { - setAdapter(ArrayAdapter(context, - R.layout.account_history_entry, - R.id.account_history_entry_text_view, - history)) + setAdapter( + ArrayAdapter( + context, + R.layout.account_history_entry, + R.id.account_history_entry_text_view, + history + ) + ) setOnItemClickListener { _, _, idx, _ -> val accountNumber = history[idx] diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/CellSwitch.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/CellSwitch.kt index 0aba6ce947..1b8c0d7c73 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/CellSwitch.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/CellSwitch.kt @@ -167,10 +167,13 @@ class CellSwitch : LinearLayout { init { setBackground(resources.getDrawable(R.drawable.cell_switch_background, null)) - addView(knobView, LinearLayout.LayoutParams(knobSize, knobSize).apply { - gravity = Gravity.CENTER_VERTICAL - leftMargin = resources.getDimensionPixelSize(R.dimen.cell_switch_knob_margin) - }) + addView( + knobView, + LinearLayout.LayoutParams(knobSize, knobSize).apply { + gravity = Gravity.CENTER_VERTICAL + leftMargin = resources.getDimensionPixelSize(R.dimen.cell_switch_knob_margin) + } + ) } override fun onTouchEvent(event: MotionEvent): Boolean { diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/CollapsibleTitleController.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/CollapsibleTitleController.kt index ab0b01c92e..ec5a4549b1 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/CollapsibleTitleController.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/CollapsibleTitleController.kt @@ -156,9 +156,9 @@ class CollapsibleTitleController(val parentView: View) { private fun update() { val shouldUpdate = scrollOffsetUpdated || - scaleInterpolation.updated || - xOffsetInterpolation.updated || - yOffsetInterpolation.updated + scaleInterpolation.updated || + xOffsetInterpolation.updated || + yOffsetInterpolation.updated if (shouldUpdate) { val progress = maxOf(0.0f, minOf(1.0f, scrollInterpolation.progress(scrollOffset))) diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/NotificationBanner.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/NotificationBanner.kt index 82a45cb347..1aeed5e5ca 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/NotificationBanner.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/NotificationBanner.kt @@ -132,11 +132,11 @@ class NotificationBanner( null -> return false is KeygenEvent.NewKey -> return false is KeygenEvent.TooManyKeys -> { - externalLink = ExternalLink.KeyManagement - showError(R.string.wireguard_error, R.string.too_many_keys) + externalLink = ExternalLink.KeyManagement + showError(R.string.wireguard_error, R.string.too_many_keys) } is KeygenEvent.GenerationFailure -> { - showError(R.string.wireguard_error, R.string.failed_to_generate_key) + showError(R.string.wireguard_error, R.string.failed_to_generate_key) } } diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/Button.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/Button.kt index 0dbed7eb19..9c2573664f 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/Button.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/Button.kt @@ -81,8 +81,8 @@ open class Button : FrameLayout { constructor(context: Context, attributes: AttributeSet, defaultStyleAttribute: Int) : super(context, attributes, defaultStyleAttribute) { - loadAttributes(attributes) - } + loadAttributes(attributes) + } constructor( context: Context, diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/CopyableInformationView.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/CopyableInformationView.kt index ac1b7e8125..33530283cb 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/CopyableInformationView.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/CopyableInformationView.kt @@ -24,8 +24,8 @@ class CopyableInformationView : InformationView { constructor(context: Context, attributes: AttributeSet, defaultStyleAttribute: Int) : super(context, attributes, defaultStyleAttribute) { - loadAttributes(attributes) - } + loadAttributes(attributes) + } constructor( context: Context, diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/InformationView.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/InformationView.kt index 8395d6ad27..d4376cfd62 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/InformationView.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/InformationView.kt @@ -99,8 +99,8 @@ open class InformationView : LinearLayout { constructor(context: Context, attributes: AttributeSet, defaultStyleAttribute: Int) : super(context, attributes, defaultStyleAttribute) { - loadAttributes(attributes) - } + loadAttributes(attributes) + } constructor( context: Context, diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/ListenableScrollView.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/ListenableScrollView.kt index 95fdeebc63..303527c3d4 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/ListenableScrollView.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/ListenableScrollView.kt @@ -13,7 +13,7 @@ class ListenableScrollView : ScrollView { constructor(context: Context, attributes: AttributeSet, defaultStyleAttribute: Int) : super(context, attributes, defaultStyleAttribute) { - } + } constructor( context: Context, diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/UrlButton.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/UrlButton.kt index c2a7839748..8bcd6c3648 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/UrlButton.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/UrlButton.kt @@ -27,8 +27,8 @@ class UrlButton : Button { constructor(context: Context, attributes: AttributeSet, defaultStyleAttribute: Int) : super(context, attributes, defaultStyleAttribute) { - loadAttributes(attributes) - } + loadAttributes(attributes) + } constructor( context: Context, diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/util/JobTracker.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/util/JobTracker.kt index 6e279452da..0b950d9a55 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/util/JobTracker.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/util/JobTracker.kt @@ -21,13 +21,16 @@ class JobTracker { jobs.put(jobId, job) - reaperJobs.put(jobId, GlobalScope.launch(Dispatchers.Default) { - job.join() + reaperJobs.put( + jobId, + GlobalScope.launch(Dispatchers.Default) { + job.join() - synchronized(jobs) { - jobs.remove(jobId) + synchronized(jobs) { + jobs.remove(jobId) + } } - }) + ) return jobId } diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/util/SmartDeferred.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/util/SmartDeferred.kt index 09fca7908b..61050bc894 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/util/SmartDeferred.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/util/SmartDeferred.kt @@ -12,9 +12,11 @@ class SmartDeferred<T>(private val deferred: Deferred<T>) { fun awaitThen(action: T.() -> Unit): Long? { if (active) { - return jobTracker.newJob(GlobalScope.launch(Dispatchers.Default) { - deferred.await().action() - }) + return jobTracker.newJob( + GlobalScope.launch(Dispatchers.Default) { + deferred.await().action() + } + ) } else { return null } |
