Adjusts Login and Sign up screens for the new Tor Settings

This commit is contained in:
Vitor Pamplona
2024-09-26 15:23:39 -04:00
parent c7b7ad78b7
commit 8810cfde37
4 changed files with 56 additions and 52 deletions

View File

@@ -295,24 +295,22 @@ fun LoginPage(
} }
Spacer(modifier = Modifier.height(10.dp)) Spacer(modifier = Modifier.height(10.dp))
if (PackageUtils.isOrbotInstalled(context)) { TorSettingsSetup(
OrbotCheckBox( torSettings = torSettings.value,
torSettings = torSettings.value, onCheckedChange = {
onCheckedChange = { torSettings.value = it
torSettings.value = it },
}, onError = {
onError = { scope.launch {
scope.launch { Toast
Toast .makeText(
.makeText( context,
context, it,
it, Toast.LENGTH_LONG,
Toast.LENGTH_LONG, ).show()
).show() }
} },
}, )
)
}
if (isNFCOrQR.value) { if (isNFCOrQR.value) {
OfferTemporaryAccount( OfferTemporaryAccount(

View File

@@ -60,7 +60,6 @@ import androidx.lifecycle.viewmodel.compose.viewModel
import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.R
import com.vitorpamplona.amethyst.commons.hashtags.Amethyst import com.vitorpamplona.amethyst.commons.hashtags.Amethyst
import com.vitorpamplona.amethyst.commons.hashtags.CustomHashTagIcons import com.vitorpamplona.amethyst.commons.hashtags.CustomHashTagIcons
import com.vitorpamplona.amethyst.service.PackageUtils
import com.vitorpamplona.amethyst.ui.screen.AccountStateViewModel import com.vitorpamplona.amethyst.ui.screen.AccountStateViewModel
import com.vitorpamplona.amethyst.ui.stringRes import com.vitorpamplona.amethyst.ui.stringRes
import com.vitorpamplona.amethyst.ui.theme.Size10dp import com.vitorpamplona.amethyst.ui.theme.Size10dp
@@ -181,24 +180,22 @@ fun SignUpPage(
) )
} }
if (PackageUtils.isOrbotInstalled(context)) { TorSettingsSetup(
OrbotCheckBox( torSettings = torSettings.value,
torSettings = torSettings.value, onCheckedChange = {
onCheckedChange = { torSettings.value = it
torSettings.value = it },
}, onError = {
onError = { scope.launch {
scope.launch { Toast
Toast .makeText(
.makeText( context,
context, it,
it, Toast.LENGTH_LONG,
Toast.LENGTH_LONG, ).show()
).show() }
} },
}, )
)
}
Spacer(modifier = Modifier.height(Size10dp)) Spacer(modifier = Modifier.height(Size10dp))

View File

@@ -20,23 +20,27 @@
*/ */
package com.vitorpamplona.amethyst.ui.screen.loggedOff package com.vitorpamplona.amethyst.ui.screen.loggedOff
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Checkbox import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.withStyle
import androidx.compose.ui.unit.dp
import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.R
import com.vitorpamplona.amethyst.ui.components.ClickableText
import com.vitorpamplona.amethyst.ui.stringRes import com.vitorpamplona.amethyst.ui.stringRes
import com.vitorpamplona.amethyst.ui.tor.ConnectTorDialog import com.vitorpamplona.amethyst.ui.tor.ConnectTorDialog
import com.vitorpamplona.amethyst.ui.tor.TorSettings import com.vitorpamplona.amethyst.ui.tor.TorSettings
import com.vitorpamplona.amethyst.ui.tor.TorType import com.vitorpamplona.amethyst.ui.tor.TorType
@Composable @Composable
fun OrbotCheckBox( fun TorSettingsSetup(
torSettings: TorSettings, torSettings: TorSettings,
onCheckedChange: (TorSettings) -> Unit, onCheckedChange: (TorSettings) -> Unit,
onError: (String) -> Unit, onError: (String) -> Unit,
@@ -44,17 +48,19 @@ fun OrbotCheckBox(
var connectOrbotDialogOpen by remember { mutableStateOf(false) } var connectOrbotDialogOpen by remember { mutableStateOf(false) }
var activeTor by remember { mutableStateOf(false) } var activeTor by remember { mutableStateOf(false) }
Row(verticalAlignment = Alignment.CenterVertically) { val text =
Checkbox( buildAnnotatedString {
checked = activeTor, append(stringRes(R.string.connect_via_tor1) + " ")
onCheckedChange = { withStyle(SpanStyle(color = MaterialTheme.colorScheme.primary)) {
if (it) { append(stringRes(R.string.connect_via_tor2))
connectOrbotDialogOpen = true }
} }
},
)
Text(stringRes(R.string.connect_via_tor)) ClickableText(
text = text,
modifier = Modifier.padding(vertical = 10.dp),
) {
connectOrbotDialogOpen = true
} }
if (connectOrbotDialogOpen) { if (connectOrbotDialogOpen) {

View File

@@ -404,6 +404,9 @@
<string name="connect_via_tor_short">Tor/Orbot setup</string> <string name="connect_via_tor_short">Tor/Orbot setup</string>
<string name="connect_via_tor">Connect through your Orbot setup</string> <string name="connect_via_tor">Connect through your Orbot setup</string>
<string name="connect_via_tor1">Adjust</string>
<string name="connect_via_tor2">Tor Settings</string>
<string name="do_you_really_want_to_disable_tor_title">Disconnect from your Orbot/Tor?</string> <string name="do_you_really_want_to_disable_tor_title">Disconnect from your Orbot/Tor?</string>
<string name="do_you_really_want_to_disable_tor_text">Your data will be immediately transferred in the regular network</string> <string name="do_you_really_want_to_disable_tor_text">Your data will be immediately transferred in the regular network</string>
<string name="yes">Yes</string> <string name="yes">Yes</string>