diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/TopBar.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/TopBar.kt index 8130e71963f6..bd50d45c8621 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/TopBar.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/TopBar.kt @@ -216,7 +216,8 @@ fun MullvadMediumTopBar( scrollBehavior = scrollBehavior, colors = TopAppBarDefaults.mediumTopAppBarColors( - containerColor = MaterialTheme.colorScheme.background + containerColor = MaterialTheme.colorScheme.background, + actionIconContentColor = MaterialTheme.colorScheme.onPrimary.copy(AlphaTopBar), ), actions = actions ) diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ViewLogsScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ViewLogsScreen.kt index 1329132591b7..9e9f53788fd6 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ViewLogsScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ViewLogsScreen.kt @@ -1,19 +1,24 @@ package net.mullvad.mullvadvpn.compose.screen +import android.content.Intent import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.rememberLazyListState -import androidx.compose.foundation.rememberScrollState +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.Share import androidx.compose.material3.Card import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Scaffold import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import net.mullvad.mullvadvpn.R @@ -44,12 +49,29 @@ fun ViewLogsScreen( uiState: ViewLogsUiState, onBackClick: () -> Unit = {}, ) { + val context = LocalContext.current + val shareLogs: (logs: String) -> Unit = { + val sendIntent: Intent = + Intent().apply { + action = Intent.ACTION_SEND + putExtra(Intent.EXTRA_TEXT, uiState.allLines.joinToString("\n")) + type = "text/plain" + } + val shareIntent = Intent.createChooser(sendIntent, null) + + context.startActivity(shareIntent) + } Scaffold( topBar = { MullvadMediumTopBar( title = stringResource(id = R.string.view_logs), - navigationIcon = { NavigateBackIconButton(onBackClick) } + navigationIcon = { NavigateBackIconButton(onBackClick) }, + actions = { + IconButton(onClick = { shareLogs(uiState.allLines.joinToString("\n")) }) { + Icon(imageVector = Icons.Default.Share, contentDescription = null) + } + } ) } ) { @@ -70,7 +92,6 @@ fun ViewLogsScreen( color = MaterialTheme.colorScheme.primary ) } else { - val scrollState = rememberScrollState() val state = rememberLazyListState() LazyColumn( state = state, diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/textfield/CustomTextField.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/textfield/CustomTextField.kt index 5a490af717ab..82a98dc3101b 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/textfield/CustomTextField.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/textfield/CustomTextField.kt @@ -20,9 +20,8 @@ import androidx.compose.ui.text.input.TextFieldValue import androidx.compose.ui.text.input.VisualTransformation import kotlinx.coroutines.delay import kotlinx.coroutines.launch - -private const val EMPTY_STRING = "" -private const val NEWLINE_STRING = "\n" +import net.mullvad.mullvadvpn.constant.EMPTY_STRING +import net.mullvad.mullvadvpn.constant.NEWLINE_STRING @Composable fun CustomTextField( diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/constant/StringConstant.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/constant/StringConstant.kt new file mode 100644 index 000000000000..472f1477324c --- /dev/null +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/constant/StringConstant.kt @@ -0,0 +1,4 @@ +package net.mullvad.mullvadvpn.constant + +const val EMPTY_STRING = "" +const val NEWLINE_STRING = "\n" diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/ViewLogsViewModel.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/ViewLogsViewModel.kt index 50e5a702779c..618536eaa2d2 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/ViewLogsViewModel.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/ViewLogsViewModel.kt @@ -6,9 +6,15 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.update import kotlinx.coroutines.launch +import net.mullvad.mullvadvpn.constant.NEWLINE_STRING import net.mullvad.mullvadvpn.dataproxy.MullvadProblemReport -data class ViewLogsUiState(val allLines: List = emptyList(), val isLoading: Boolean = true) +data class ViewLogsUiState( + val allLines: List = emptyList(), + val isLoading: Boolean = true +) { + fun text() = allLines.joinToString(NEWLINE_STRING) +} class ViewLogsViewModel(private val mullvadProblemReporter: MullvadProblemReport) : ViewModel() {