[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [Git][tpo/applications/firefox-android][firefox-android-115.2.1-13.5-1] fixup! Add Tor integration and UI



Title: GitLab

Dan Ballard pushed to branch firefox-android-115.2.1-13.5-1 at The Tor Project / Applications / firefox-android

Commits:

  • 737cb590
    by clairehurst at 2024-05-06T15:30:26-06:00
    fixup! Add Tor integration and UI
    

2 changed files:

Changes:

  • fenix/app/src/main/java/org/mozilla/fenix/tor/TorLogsComposeFragment.kt
    ... ... @@ -8,7 +8,9 @@ import android.os.Bundle
    8 8
     import android.view.LayoutInflater
    
    9 9
     import android.view.View
    
    10 10
     import android.view.ViewGroup
    
    11
    +import androidx.compose.foundation.background
    
    11 12
     import androidx.compose.foundation.layout.Column
    
    13
    +import androidx.compose.foundation.layout.PaddingValues
    
    12 14
     import androidx.compose.foundation.layout.fillMaxSize
    
    13 15
     import androidx.compose.foundation.layout.fillMaxWidth
    
    14 16
     import androidx.compose.foundation.layout.padding
    
    ... ... @@ -16,15 +18,20 @@ import androidx.compose.foundation.rememberScrollState
    16 18
     import androidx.compose.foundation.text.selection.DisableSelection
    
    17 19
     import androidx.compose.foundation.text.selection.SelectionContainer
    
    18 20
     import androidx.compose.foundation.verticalScroll
    
    21
    +import androidx.compose.material.FloatingActionButton
    
    22
    +import androidx.compose.material.Icon
    
    23
    +import androidx.compose.material.Scaffold
    
    19 24
     import androidx.compose.material.Text
    
    20 25
     import androidx.compose.runtime.Composable
    
    21 26
     import androidx.compose.runtime.Stable
    
    22 27
     import androidx.compose.ui.Modifier
    
    23 28
     import androidx.compose.ui.platform.ComposeView
    
    29
    +import androidx.compose.ui.res.painterResource
    
    24 30
     import androidx.compose.ui.unit.dp
    
    25 31
     import androidx.fragment.app.Fragment
    
    26 32
     import androidx.fragment.app.viewModels
    
    27 33
     import mozilla.components.ui.colors.PhotonColors
    
    34
    +import org.mozilla.fenix.R
    
    28 35
     
    
    29 36
     class TorLogsComposeFragment : Fragment() {
    
    30 37
         private val viewModel: TorLogsViewModel by viewModels()
    
    ... ... @@ -36,47 +43,72 @@ class TorLogsComposeFragment : Fragment() {
    36 43
         ): View {
    
    37 44
             return ComposeView(requireContext()).apply {
    
    38 45
                 setContent {
    
    39
    -                SelectionContainer {
    
    40
    -                    Column(
    
    41
    -                        // Column instead of LazyColumn so that you can select all the logs, and not just one "screen" at a time
    
    42
    -                        // The logs won't be too big so loading them all instead of just whats visible shouldn't be a big deal
    
    43
    -                        modifier = Modifier
    
    44
    -                            .fillMaxSize()
    
    45
    -                            .verticalScroll(state = rememberScrollState(), reverseScrolling = true),
    
    46
    -                    ) {
    
    47
    -                        for (log in viewModel.torLogs) {
    
    48
    -                            LogRow(log = log)
    
    49
    -                        }
    
    50
    -                    }
    
    46
    +                Scaffold(
    
    47
    +                    floatingActionButton = { CopyLogsButton() },
    
    48
    +                    content = { TorLogs(paddingValues = it) },
    
    49
    +                )
    
    50
    +            }
    
    51
    +        }
    
    52
    +    }
    
    53
    +
    
    54
    +    @Composable
    
    55
    +    private fun TorLogs(paddingValues: PaddingValues) {
    
    56
    +        SelectionContainer {
    
    57
    +            Column(
    
    58
    +                // Column instead of LazyColumn so that you can select all the logs, and not just one "screen" at a time
    
    59
    +                // The logs won't be too big so loading them all instead of just whats visible shouldn't be a big deal
    
    60
    +                modifier = Modifier
    
    61
    +                    .fillMaxSize()
    
    62
    +                    .verticalScroll(state = rememberScrollState(), reverseScrolling = true)
    
    63
    +                    .padding(paddingValues)
    
    64
    +                    .background(PhotonColors.Ink50), // Standard background color
    
    65
    +            ) {
    
    66
    +                for (log in viewModel.torLogs) {
    
    67
    +                    LogRow(log = log)
    
    51 68
                     }
    
    52 69
                 }
    
    53 70
             }
    
    54 71
         }
    
    55
    -}
    
    56 72
     
    
    57
    -@Composable
    
    58
    -@Stable
    
    59
    -fun LogRow(log: TorLog, modifier: Modifier = Modifier) {
    
    60
    -    Column(
    
    61
    -        modifier
    
    62
    -            .fillMaxWidth()
    
    63
    -            .padding(
    
    64
    -                start = 16.dp,
    
    65
    -                end = 16.dp,
    
    66
    -                bottom = 16.dp,
    
    67
    -            ),
    
    68
    -    ) {
    
    69
    -        DisableSelection {
    
    73
    +    @Composable
    
    74
    +    @Stable
    
    75
    +    private fun LogRow(log: TorLog, modifier: Modifier = Modifier) {
    
    76
    +        Column(
    
    77
    +            modifier
    
    78
    +                .fillMaxWidth()
    
    79
    +                .padding(
    
    80
    +                    start = 16.dp,
    
    81
    +                    end = 16.dp,
    
    82
    +                    bottom = 16.dp,
    
    83
    +                ),
    
    84
    +        ) {
    
    85
    +            DisableSelection {
    
    86
    +                Text(
    
    87
    +                    text = log.timestamp.toString(),
    
    88
    +                    color = PhotonColors.LightGrey40,
    
    89
    +                    modifier = modifier
    
    90
    +                        .padding(bottom = 4.dp),
    
    91
    +                )
    
    92
    +            }
    
    70 93
                 Text(
    
    71
    -                text = log.timestamp.toString(),
    
    72
    -                color = PhotonColors.LightGrey40,
    
    73
    -                modifier = modifier
    
    74
    -                    .padding(bottom = 4.dp),
    
    94
    +                text = log.text,
    
    95
    +                color = PhotonColors.LightGrey05,
    
    75 96
                 )
    
    76 97
             }
    
    77
    -        Text(
    
    78
    -            text = log.text,
    
    79
    -            color = PhotonColors.LightGrey05,
    
    98
    +    }
    
    99
    +
    
    100
    +    @Composable
    
    101
    +    private fun CopyLogsButton() {
    
    102
    +        FloatingActionButton(
    
    103
    +            onClick = { viewModel.copyAllLogsToClipboard() },
    
    104
    +            content = {
    
    105
    +                Icon(
    
    106
    +                    painter = painterResource(id = R.drawable.ic_copy),
    
    107
    +                    contentDescription = getString(R.string.share_copy_link_to_clipboard),
    
    108
    +                )
    
    109
    +            },
    
    110
    +            backgroundColor = PhotonColors.Violet50, // Same color as connect button
    
    111
    +            contentColor = PhotonColors.LightGrey05,
    
    80 112
             )
    
    81 113
         }
    
    82 114
     }

  • fenix/app/src/main/java/org/mozilla/fenix/tor/TorLogsViewModel.kt
    ... ... @@ -63,10 +63,10 @@ class TorLogsViewModel(application: Application) : AndroidViewModel(application)
    63 63
             }
    
    64 64
         }
    
    65 65
     
    
    66
    -    fun copyAllLogsToClipboard() { // TODO add kebab menu in top right corner which includes option to "Copy all logs"
    
    66
    +    fun copyAllLogsToClipboard() {
    
    67 67
             clipboardManager.setPrimaryClip(
    
    68 68
                 ClipData.newPlainText(
    
    69
    -                "Copied Text",
    
    69
    +                getApplication<Application>().getString(R.string.preferences_tor_logs),
    
    70 70
                     getAllTorLogs(),
    
    71 71
                 ),
    
    72 72
             )
    

  • _______________________________________________
    tor-commits mailing list
    tor-commits@xxxxxxxxxxxxxxxxxxxx
    https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits