diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/payment/PaymentDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/payment/PaymentDialog.kt index 5ce261ac03b7..a1922997a8d8 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/payment/PaymentDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/payment/PaymentDialog.kt @@ -27,6 +27,7 @@ import net.mullvad.mullvadvpn.compose.component.MullvadCircularProgressIndicator import net.mullvad.mullvadvpn.lib.payment.model.ProductId import net.mullvad.mullvadvpn.lib.theme.AppTheme import net.mullvad.mullvadvpn.lib.theme.color.AlphaDescription +import net.mullvad.mullvadvpn.ui.extension.getActivity import net.mullvad.mullvadvpn.viewmodel.PaymentUiSideEffect import net.mullvad.mullvadvpn.viewmodel.PaymentViewModel import org.koin.androidx.compose.koinViewModel @@ -222,11 +223,3 @@ fun PaymentDialog( } ) } - -private fun Context.getActivity(): Activity? { - return when (this) { - is Activity -> this - is ContextWrapper -> this.baseContext.getActivity() - else -> null - } -} diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/extension/ContextExtensions.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/extension/ContextExtensions.kt index f747ae169dd7..7b0c445972af 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/extension/ContextExtensions.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/extension/ContextExtensions.kt @@ -1,11 +1,21 @@ package net.mullvad.mullvadvpn.ui.extension +import android.app.Activity import android.content.ClipData import android.content.ClipboardManager import android.content.Context +import android.content.ContextWrapper fun Context.copyToClipboard(content: String, clipboardLabel: String) { val clipboard = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager val clipData = ClipData.newPlainText(clipboardLabel, content) clipboard.setPrimaryClip(clipData) } + +fun Context.getActivity(): Activity? { + return when (this) { + is Activity -> this + is ContextWrapper -> this.baseContext.getActivity() + else -> null + } +}