Skip to content

Commit

Permalink
Apply updated ktfmt formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
albin-mullvad committed Aug 4, 2023
1 parent c27e788 commit bfe2a3d
Show file tree
Hide file tree
Showing 39 changed files with 91 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ private constructor(
const val ACTION = 3
const val DOUBLE_ACTION = 4
const val APPLICATION = 5

fun build(identifier: String, setUp: Builder.() -> Unit): ListItemData =
Builder(identifier).also(setUp).build()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package net.mullvad.mullvadvpn.applist
sealed class ViewIntent {
// In future we will have search intent
data class ChangeApplicationGroup(val item: ListItemData) : ViewIntent()

object ViewIsReady : ViewIntent()

data class ShowSystemApps(internal val show: Boolean) : ViewIntent()
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import net.mullvad.mullvadvpn.relaylist.RelayItem

sealed interface SelectLocationUiState {
object Loading : SelectLocationUiState

data class ShowData(val countries: List<RelayCountry>, val selectedRelay: RelayItem?) :
SelectLocationUiState

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import net.mullvad.mullvadvpn.applist.AppData

sealed interface SplitTunnelingUiState {
object Loading : SplitTunnelingUiState

data class ShowAppList(
val excludedApps: List<AppData> = emptyList(),
val includedApps: List<AppData> = emptyList(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ const val PROBLEM_REPORT_FILE = "problem_report.txt"
class MullvadProblemReport {
private sealed class Command {
class Collect() : Command()

class Load(val logs: CompletableDeferred<String>) : Command()

class Send(val result: CompletableDeferred<Boolean>) : Command()

class Delete() : Command()
}

Expand Down Expand Up @@ -128,6 +131,7 @@ class MullvadProblemReport {
}

private external fun collectReport(logDirectory: String, reportPath: String): Boolean

private external fun sendProblemReport(
userEmail: String,
userMessage: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ package net.mullvad.mullvadvpn.relaylist

sealed class GetItemResult {
data class Item(val item: RelayItem) : GetItemResult()

data class Count(val count: Int) : GetItemResult()
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ class BlockingController(val blockableView: BlockableView) {

interface BlockableView {
fun setEnabled(enabled: Boolean)

fun onClick(): Job
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import net.mullvad.mullvadvpn.util.transitionFinished

abstract class BaseFragment : Fragment {
constructor() : super()

constructor(@LayoutRes contentLayoutId: Int) : super(contentLayoutId)

protected var transitionFinishedFlow: Flow<Unit> = emptyFlow()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class PlainListItemView(context: Context) :
ListItemView(ContextThemeWrapper(context, R.style.ListItem_PlainText)) {
override val layoutRes: Int
get() = R.layout.list_item_plain_text

override val heightRes: Int? = null
private val plainText: TextView = findViewById(R.id.plain_text)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class TwoActionListItemView(context: Context) :
ActionListItemView(ContextThemeWrapper(context, R.style.ListItem_Action_Double)) {
override val layoutRes: Int
get() = R.layout.list_item_two_action

private val container: ViewGroup = findViewById(R.id.container_without_widget)

init {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ sealed class WidgetViewController<T : WidgetState>(val parent: ViewGroup) {
WidgetViewController<WidgetState.ImageState>(parent) {
override val layoutRes: Int
get() = R.layout.list_item_widget_image

private val imageView: ImageView = parent.findViewById(R.id.widgetImage)

override fun updateState(state: WidgetState.ImageState) =
imageView.setImageResource(state.imageRes)
}
Expand All @@ -30,7 +32,9 @@ sealed class WidgetViewController<T : WidgetState>(val parent: ViewGroup) {
WidgetViewController<WidgetState.SwitchState>(parent) {
override val layoutRes: Int
get() = R.layout.list_item_widget_switch

private val switch: SwitchCompat = parent.findViewById(R.id.widgetSwitch)

override fun updateState(state: WidgetState.SwitchState) {
switch.isChecked = state.isChecked
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ abstract class InAppNotification {
protected set

open fun onResume() {}

open fun onPause() {}

open fun onDestroy() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class ConnectionProxy(private val connection: Messenger, eventDispatcher: EventD

var state by onStateChange.notifiable()
private set

var uiState by onUiStateChange.notifiable()
private set

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,14 @@ class ServiceConnectionAccountDataSource(
}

fun createAccount() = connection.send(Request.CreateAccount.message)

fun login(accountToken: String) = connection.send(Request.Login(accountToken).message)

fun logout() = connection.send(Request.Logout.message)

fun fetchAccountExpiry() = connection.send(Request.FetchAccountExpiry.message)

fun fetchAccountHistory() = connection.send(Request.FetchAccountHistory.message)

fun clearAccountHistory() = connection.send(Request.ClearAccountHistory.message)
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import net.mullvad.mullvadvpn.util.ListenableScrollableView
class ListenableScrollView : ScrollView, ListenableScrollableView {
override val horizontalScrollOffset
get() = scrollX

override val verticalScrollOffset
get() = scrollY

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class NotificationBanner : FrameLayout {
private val animationListener =
object : AnimatorListener {
override fun onAnimationCancel(animation: Animator) {}

override fun onAnimationRepeat(animation: Animator) {}

override fun onAnimationStart(animation: Animator) {
Expand Down Expand Up @@ -78,6 +79,7 @@ class NotificationBanner : FrameLayout {
}

constructor(context: Context) : super(context)

constructor(context: Context, attributes: AttributeSet) : super(context, attributes)

constructor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ import androidx.annotation.DrawableRes

sealed class WidgetState {
data class ImageState(@DrawableRes val imageRes: Int) : WidgetState()

data class SwitchState(val isChecked: Boolean) : WidgetState()
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ fun Animation.transitionFinished(): Flow<Unit> =
val transitionAnimationListener =
object : Animation.AnimationListener {
override fun onAnimationStart(animation: Animation?) {}

override fun onAnimationEnd(animation: Animation?) {
safeOffer(Unit)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ import androidx.recyclerview.widget.RecyclerView.ViewHolder

sealed class HeaderOrHolder<H : ViewHolder>(itemView: View) : ViewHolder(itemView) {
class Header<H : ViewHolder>(headerView: View) : HeaderOrHolder<H>(headerView)

class Holder<H : ViewHolder>(val holder: H) : HeaderOrHolder<H>(holder.itemView)
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class AccountViewModel(
)
}
}

fun onLogoutClick() {
accountRepository.logout()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ class ChangelogViewModel(

sealed class ChangelogDialogUiState {
data class Show(val changes: List<String>) : ChangelogDialogUiState()

object Hide : ChangelogDialogUiState()
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,15 @@ class ConnectViewModel(private val serviceConnectionManager: ServiceConnectionMa
fun onDisconnectClick() {
serviceConnectionManager.connectionProxy()?.disconnect()
}

fun onReconnectClick() {
serviceConnectionManager.connectionProxy()?.reconnect()
}

fun onConnectClick() {
serviceConnectionManager.connectionProxy()?.connect()
}

fun onCancelClick() {
serviceConnectionManager.connectionProxy()?.disconnect()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,23 @@ class LoginViewModel(

sealed class LoginUiState {
object Default : LoginUiState()

object Loading : LoginUiState()

data class Success(val isOutOfTime: Boolean) : LoginUiState()

object CreatingAccount : LoginUiState()

object AccountCreated : LoginUiState()

object UnableToCreateAccountError : LoginUiState()

object InvalidAccountError : LoginUiState()

data class TooManyDevicesError(val accountToken: String) : LoginUiState()

object TooManyDevicesMissingListError : LoginUiState()

data class OtherError(val errorMessage: String) : LoginUiState()

fun isLoading(): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,9 @@ sealed interface StagedDns {

sealed class ValidationResult {
object Success : ValidationResult()

object InvalidAddress : ValidationResult()

object DuplicateAddress : ValidationResult()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class Intermittent<T> {
// resume execution. This allows performing any extra initialization before the value is made
// available for usage.
fun registerListener(id: Any, listener: (T?) -> Unit) = notifier.subscribe(id, listener)

fun unregisterListener(id: Any) = notifier.unsubscribe(id)

suspend fun await(): T {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.os.Parcelable

sealed class Message(private val messageId: Int) : Parcelable {
abstract class EventMessage : Message(1)

abstract class RequestMessage : Message(2)

protected abstract val messageKey: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package net.mullvad.mullvadvpn.model

sealed class DeviceList {
object Unavailable : DeviceList()

data class Available(val devices: List<Device>) : DeviceList()

object Error : DeviceList()
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ package net.mullvad.mullvadvpn.model

sealed class GetAccountDataResult {
class Ok(val accountData: AccountData) : GetAccountDataResult()

object InvalidAccount : GetAccountDataResult()

object RpcError : GetAccountDataResult()

object OtherError : GetAccountDataResult()
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ import kotlinx.parcelize.Parcelize
sealed class LocationConstraint : Parcelable {
@Parcelize
data class Location(val location: GeographicLocationConstraint) : LocationConstraint()

@Parcelize data class CustomList(val listId: String) : LocationConstraint()
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ package net.mullvad.mullvadvpn.model

sealed class RelaySettingsUpdate {
object CustomTunnelEndpoint : RelaySettingsUpdate()

data class Normal(var constraints: RelayConstraintsUpdate) : RelaySettingsUpdate()
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,6 @@ class ConnectivityListener {
}

private external fun notifyConnectivityChange(isConnected: Boolean, senderAddress: Long)

private external fun destroySender(senderAddress: Long)
}
Original file line number Diff line number Diff line change
Expand Up @@ -146,5 +146,6 @@ open class TalpidVpnService : VpnService() {
}

private external fun defaultTunConfig(): TunConfig

private external fun waitForTunnelUp(tunFd: Int, isIpv6Enabled: Boolean)
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import net.mullvad.mullvadvpn.lib.endpoint.ApiEndpointConfiguration
class DaemonInstance(private val vpnService: MullvadVpnService) {
sealed class Command {
data class Start(val apiEndpointConfiguration: ApiEndpointConfiguration) : Command()

object Stop : Command()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ class ForegroundNotificationManager(
) {
private sealed class UpdaterMessage {
class UpdateNotification : UpdaterMessage()

class UpdateAction : UpdaterMessage()

class NewTunnelState(val newState: TunnelState) : UpdaterMessage()
}

Expand Down
Loading

0 comments on commit bfe2a3d

Please sign in to comment.