Skip to content

Commit

Permalink
Add copy to clipboard action
Browse files Browse the repository at this point in the history
  • Loading branch information
Rawa authored and Pururun committed Nov 27, 2023
1 parent 9fd6dbd commit 90689b3
Showing 4 changed files with 33 additions and 12 deletions.
15 changes: 6 additions & 9 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -90,15 +90,12 @@
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
</service>

<provider
android:name="net.mullvad.mullvadvpn.provider.MullvadFileProvider"
android:authorities="net.mullvad.mullvadvpn.FileProvider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
<provider android:name="net.mullvad.mullvadvpn.provider.MullvadFileProvider"
android:authorities="net.mullvad.mullvadvpn.FileProvider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
</provider>
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package net.mullvad.mullvadvpn.compose.screen

import android.content.Context
import android.content.Intent
import android.net.Uri
import android.util.Log
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
@@ -17,20 +14,26 @@ import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import kotlinx.coroutines.launch
import net.mullvad.mullvadvpn.R
import net.mullvad.mullvadvpn.compose.component.MullvadCircularProgressIndicatorMedium
import net.mullvad.mullvadvpn.compose.component.MullvadMediumTopBar
import net.mullvad.mullvadvpn.compose.component.MullvadSnackbar
import net.mullvad.mullvadvpn.compose.component.NavigateBackIconButton
import net.mullvad.mullvadvpn.compose.component.drawVerticalScrollbar
import net.mullvad.mullvadvpn.compose.util.createCopyToClipboardHandle
import net.mullvad.mullvadvpn.lib.theme.AppTheme
import net.mullvad.mullvadvpn.lib.theme.Dimens
import net.mullvad.mullvadvpn.lib.theme.color.AlphaScrollbar
@@ -57,13 +60,30 @@ fun ViewLogsScreen(
) {
val context = LocalContext.current

val snackbarHostState = remember { SnackbarHostState() }
val scope = rememberCoroutineScope()
val clipboardHandle = createCopyToClipboardHandle(snackbarHostState = snackbarHostState)
Scaffold(
snackbarHost = {
SnackbarHost(
snackbarHostState,
snackbar = { snackbarData -> MullvadSnackbar(snackbarData = snackbarData) }
)
},
topBar = {
MullvadMediumTopBar(
title = stringResource(id = R.string.view_logs),
navigationIcon = { NavigateBackIconButton(onBackClick) },
actions = {
val clipboardToastMessage = stringResource(R.string.copied_logs_to_clipboard)
IconButton(
onClick = { clipboardHandle(uiState.text(), clipboardToastMessage) }
) {
Icon(
painter = painterResource(id = R.drawable.icon_copy),
contentDescription = null
)
}
IconButton(onClick = { scope.launch { shareText(context, uiState.text()) } }) {
Icon(imageVector = Icons.Default.Share, contentDescription = null)
}
1 change: 1 addition & 0 deletions android/lib/resource/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -243,4 +243,5 @@
<string name="payment_pending_dialog_message">We are currently verifying your purchase, this might take some time. Your time will be added if the verification is successful.</string>
<string name="loading_connecting">Connecting...</string>
<string name="loading_verifying">Verifying purchase...</string>
<string name="copied_logs_to_clipboard">Copied logs to clipboard</string>
</resources>
3 changes: 3 additions & 0 deletions gui/locales/messages.pot
Original file line number Diff line number Diff line change
@@ -1711,6 +1711,9 @@ msgstr ""
msgid "Copied Mullvad account number to clipboard"
msgstr ""

msgid "Copied logs to clipboard"
msgstr ""

msgid "Copied to clipboard"
msgstr ""

0 comments on commit 90689b3

Please sign in to comment.