Adjustments to Tor/Orbot screens
This commit is contained in:
@@ -14,7 +14,9 @@ import androidx.compose.foundation.layout.height
|
|||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.layout.width
|
import androidx.compose.foundation.layout.width
|
||||||
|
import androidx.compose.foundation.rememberScrollState
|
||||||
import androidx.compose.foundation.shape.CircleShape
|
import androidx.compose.foundation.shape.CircleShape
|
||||||
|
import androidx.compose.foundation.verticalScroll
|
||||||
import androidx.compose.material.AlertDialog
|
import androidx.compose.material.AlertDialog
|
||||||
import androidx.compose.material.Divider
|
import androidx.compose.material.Divider
|
||||||
import androidx.compose.material.ExperimentalMaterialApi
|
import androidx.compose.material.ExperimentalMaterialApi
|
||||||
@@ -240,11 +242,11 @@ fun ListContent(
|
|||||||
val coroutineScope = rememberCoroutineScope()
|
val coroutineScope = rememberCoroutineScope()
|
||||||
var backupDialogOpen by remember { mutableStateOf(false) }
|
var backupDialogOpen by remember { mutableStateOf(false) }
|
||||||
var checked by remember { mutableStateOf(account.proxy != null) }
|
var checked by remember { mutableStateOf(account.proxy != null) }
|
||||||
val openDialog = remember { mutableStateOf(false) }
|
var disconnectTorDialog by remember { mutableStateOf(false) }
|
||||||
var conectOrbotDialogOpen by remember { mutableStateOf(false) }
|
var conectOrbotDialogOpen by remember { mutableStateOf(false) }
|
||||||
var proxyPort = remember { mutableStateOf(account.proxyPort.toString()) }
|
var proxyPort = remember { mutableStateOf(account.proxyPort.toString()) }
|
||||||
|
|
||||||
Column(modifier = modifier.fillMaxHeight()) {
|
Column(modifier = modifier.fillMaxHeight().verticalScroll(rememberScrollState())) {
|
||||||
if (accountUser != null) {
|
if (accountUser != null) {
|
||||||
NavigationRow(
|
NavigationRow(
|
||||||
title = stringResource(R.string.profile),
|
title = stringResource(R.string.profile),
|
||||||
@@ -278,10 +280,15 @@ fun ListContent(
|
|||||||
title = stringResource(R.string.backup_keys),
|
title = stringResource(R.string.backup_keys),
|
||||||
icon = R.drawable.ic_key,
|
icon = R.drawable.ic_key,
|
||||||
tint = MaterialTheme.colors.onBackground,
|
tint = MaterialTheme.colors.onBackground,
|
||||||
onClick = { backupDialogOpen = true }
|
onClick = {
|
||||||
|
coroutineScope.launch {
|
||||||
|
scaffoldState.drawerState.close()
|
||||||
|
}
|
||||||
|
backupDialogOpen = true
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
val textTorProxy = if (checked) stringResource(R.string.disconnect_from_your_orbot_setup) else stringResource(R.string.connect_via_tor)
|
val textTorProxy = if (checked) stringResource(R.string.disconnect_from_your_orbot_setup) else stringResource(R.string.connect_via_tor_short)
|
||||||
|
|
||||||
IconRow(
|
IconRow(
|
||||||
title = textTorProxy,
|
title = textTorProxy,
|
||||||
@@ -289,8 +296,11 @@ fun ListContent(
|
|||||||
tint = MaterialTheme.colors.onBackground,
|
tint = MaterialTheme.colors.onBackground,
|
||||||
onClick = {
|
onClick = {
|
||||||
if (checked) {
|
if (checked) {
|
||||||
openDialog.value = true
|
disconnectTorDialog = true
|
||||||
} else {
|
} else {
|
||||||
|
coroutineScope.launch {
|
||||||
|
scaffoldState.drawerState.close()
|
||||||
|
}
|
||||||
conectOrbotDialogOpen = true
|
conectOrbotDialogOpen = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -315,7 +325,7 @@ fun ListContent(
|
|||||||
onClose = { conectOrbotDialogOpen = false },
|
onClose = { conectOrbotDialogOpen = false },
|
||||||
onPost = {
|
onPost = {
|
||||||
conectOrbotDialogOpen = false
|
conectOrbotDialogOpen = false
|
||||||
openDialog.value = false
|
disconnectTorDialog = false
|
||||||
checked = true
|
checked = true
|
||||||
enableTor(account, true, proxyPort)
|
enableTor(account, true, proxyPort)
|
||||||
},
|
},
|
||||||
@@ -323,14 +333,21 @@ fun ListContent(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (openDialog.value) {
|
if (disconnectTorDialog) {
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
text = { Text(text = stringResource(R.string.do_you_really_want_to_disable_tor)) },
|
title = {
|
||||||
onDismissRequest = { },
|
Text(text = stringResource(R.string.do_you_really_want_to_disable_tor_title))
|
||||||
|
},
|
||||||
|
text = {
|
||||||
|
Text(text = stringResource(R.string.do_you_really_want_to_disable_tor_text))
|
||||||
|
},
|
||||||
|
onDismissRequest = {
|
||||||
|
disconnectTorDialog = false
|
||||||
|
},
|
||||||
confirmButton = {
|
confirmButton = {
|
||||||
TextButton(
|
TextButton(
|
||||||
onClick = {
|
onClick = {
|
||||||
openDialog.value = false
|
disconnectTorDialog = false
|
||||||
checked = false
|
checked = false
|
||||||
enableTor(account, false, proxyPort)
|
enableTor(account, false, proxyPort)
|
||||||
}
|
}
|
||||||
@@ -341,7 +358,7 @@ fun ListContent(
|
|||||||
dismissButton = {
|
dismissButton = {
|
||||||
TextButton(
|
TextButton(
|
||||||
onClick = {
|
onClick = {
|
||||||
openDialog.value = false
|
disconnectTorDialog = false
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
Text(text = stringResource(R.string.no))
|
Text(text = stringResource(R.string.no))
|
||||||
|
|||||||
@@ -354,9 +354,7 @@ private fun QuickActionAlertDialog(
|
|||||||
},
|
},
|
||||||
buttons = {
|
buttons = {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier.padding(all = 8.dp).fillMaxWidth(),
|
||||||
.padding(all = 8.dp)
|
|
||||||
.fillMaxWidth(),
|
|
||||||
horizontalArrangement = Arrangement.SpaceBetween
|
horizontalArrangement = Arrangement.SpaceBetween
|
||||||
) {
|
) {
|
||||||
TextButton(onClick = onClickDontShowAgain) {
|
TextButton(onClick = onClickDontShowAgain) {
|
||||||
|
|||||||
+69
-37
@@ -1,16 +1,17 @@
|
|||||||
package com.vitorpamplona.amethyst.ui.screen.loggedIn
|
package com.vitorpamplona.amethyst.ui.screen.loggedIn
|
||||||
|
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.compose.foundation.background
|
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.foundation.text.KeyboardOptions
|
import androidx.compose.foundation.text.KeyboardOptions
|
||||||
|
import androidx.compose.material.Button
|
||||||
|
import androidx.compose.material.ButtonDefaults
|
||||||
import androidx.compose.material.MaterialTheme
|
import androidx.compose.material.MaterialTheme
|
||||||
import androidx.compose.material.OutlinedTextField
|
import androidx.compose.material.OutlinedTextField
|
||||||
import androidx.compose.material.Surface
|
import androidx.compose.material.Surface
|
||||||
@@ -20,20 +21,21 @@ import androidx.compose.runtime.MutableState
|
|||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import androidx.compose.ui.text.SpanStyle
|
||||||
import androidx.compose.ui.text.input.KeyboardCapitalization
|
import androidx.compose.ui.text.input.KeyboardCapitalization
|
||||||
import androidx.compose.ui.text.input.KeyboardType
|
import androidx.compose.ui.text.input.KeyboardType
|
||||||
|
import androidx.compose.ui.text.style.TextDecoration
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.window.Dialog
|
import androidx.compose.ui.window.Dialog
|
||||||
import androidx.compose.ui.window.DialogProperties
|
import androidx.compose.ui.window.DialogProperties
|
||||||
import com.halilibo.richtext.markdown.Markdown
|
import com.halilibo.richtext.markdown.Markdown
|
||||||
import com.halilibo.richtext.ui.RichTextStyle
|
|
||||||
import com.halilibo.richtext.ui.material.MaterialRichText
|
import com.halilibo.richtext.ui.material.MaterialRichText
|
||||||
import com.halilibo.richtext.ui.resolveDefaults
|
|
||||||
import com.vitorpamplona.amethyst.R
|
import com.vitorpamplona.amethyst.R
|
||||||
import com.vitorpamplona.amethyst.ui.actions.CloseButton
|
import com.vitorpamplona.amethyst.ui.actions.CloseButton
|
||||||
import com.vitorpamplona.amethyst.ui.actions.PostButton
|
import com.vitorpamplona.amethyst.ui.components.richTextDefaults
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@@ -42,14 +44,11 @@ fun ConnectOrbotDialog(onClose: () -> Unit, onPost: () -> Unit, portNumber: Muta
|
|||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
Dialog(
|
Dialog(
|
||||||
onDismissRequest = onClose,
|
onDismissRequest = onClose,
|
||||||
properties = DialogProperties(usePlatformDefaultWidth = false)
|
properties = DialogProperties(usePlatformDefaultWidth = false, decorFitsSystemWindows = false)
|
||||||
) {
|
) {
|
||||||
Surface(modifier = Modifier.fillMaxSize()) {
|
Surface() {
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier.padding(10.dp)
|
||||||
.padding(10.dp)
|
|
||||||
.background(MaterialTheme.colors.background)
|
|
||||||
.fillMaxSize()
|
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
horizontalArrangement = Arrangement.SpaceBetween,
|
horizontalArrangement = Arrangement.SpaceBetween,
|
||||||
@@ -62,7 +61,7 @@ fun ConnectOrbotDialog(onClose: () -> Unit, onPost: () -> Unit, portNumber: Muta
|
|||||||
|
|
||||||
val toastMessage = stringResource(R.string.invalid_port_number)
|
val toastMessage = stringResource(R.string.invalid_port_number)
|
||||||
|
|
||||||
PostButton(
|
UseOrbotButton(
|
||||||
onPost = {
|
onPost = {
|
||||||
try {
|
try {
|
||||||
Integer.parseInt(portNumber.value)
|
Integer.parseInt(portNumber.value)
|
||||||
@@ -74,7 +73,7 @@ fun ConnectOrbotDialog(onClose: () -> Unit, onPost: () -> Unit, portNumber: Muta
|
|||||||
Toast.LENGTH_LONG
|
Toast.LENGTH_LONG
|
||||||
).show()
|
).show()
|
||||||
}
|
}
|
||||||
return@PostButton
|
return@UseOrbotButton
|
||||||
}
|
}
|
||||||
|
|
||||||
onPost()
|
onPost()
|
||||||
@@ -84,37 +83,70 @@ fun ConnectOrbotDialog(onClose: () -> Unit, onPost: () -> Unit, portNumber: Muta
|
|||||||
}
|
}
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier.padding(30.dp)
|
||||||
.fillMaxSize()
|
|
||||||
.padding(horizontal = 30.dp)
|
|
||||||
) {
|
) {
|
||||||
MaterialRichText(
|
val myMarkDownStyle = richTextDefaults.copy(
|
||||||
style = RichTextStyle().resolveDefaults()
|
stringStyle = richTextDefaults.stringStyle?.copy(
|
||||||
) {
|
linkStyle = SpanStyle(
|
||||||
Markdown(
|
textDecoration = TextDecoration.Underline,
|
||||||
content = stringResource(R.string.connect_through_your_orbot_setup_markdown)
|
color = MaterialTheme.colors.primary
|
||||||
|
)
|
||||||
)
|
)
|
||||||
}
|
)
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(10.dp))
|
Row() {
|
||||||
|
MaterialRichText(
|
||||||
OutlinedTextField(
|
style = myMarkDownStyle
|
||||||
value = portNumber.value,
|
) {
|
||||||
onValueChange = { portNumber.value = it },
|
Markdown(
|
||||||
keyboardOptions = KeyboardOptions.Default.copy(
|
content = stringResource(R.string.connect_through_your_orbot_setup_markdown)
|
||||||
capitalization = KeyboardCapitalization.None,
|
|
||||||
keyboardType = KeyboardType.Number
|
|
||||||
),
|
|
||||||
label = { Text(text = stringResource(R.string.orbot_socks_port)) },
|
|
||||||
placeholder = {
|
|
||||||
Text(
|
|
||||||
text = "9050",
|
|
||||||
color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
}
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.height(15.dp))
|
||||||
|
|
||||||
|
Row(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
horizontalArrangement = Arrangement.Center
|
||||||
|
) {
|
||||||
|
OutlinedTextField(
|
||||||
|
value = portNumber.value,
|
||||||
|
onValueChange = { portNumber.value = it },
|
||||||
|
keyboardOptions = KeyboardOptions.Default.copy(
|
||||||
|
capitalization = KeyboardCapitalization.None,
|
||||||
|
keyboardType = KeyboardType.Number
|
||||||
|
),
|
||||||
|
label = { Text(text = stringResource(R.string.orbot_socks_port)) },
|
||||||
|
placeholder = {
|
||||||
|
Text(
|
||||||
|
text = "9050",
|
||||||
|
color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun UseOrbotButton(onPost: () -> Unit = {}, isActive: Boolean, modifier: Modifier = Modifier) {
|
||||||
|
Button(
|
||||||
|
modifier = modifier,
|
||||||
|
onClick = {
|
||||||
|
if (isActive) {
|
||||||
|
onPost()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
shape = RoundedCornerShape(20.dp),
|
||||||
|
colors = ButtonDefaults
|
||||||
|
.buttonColors(
|
||||||
|
backgroundColor = if (isActive) MaterialTheme.colors.primary else Color.Gray
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
Text(text = stringResource(R.string.use_orbot), color = Color.White)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -296,12 +296,6 @@
|
|||||||
<string name="poll_author_no_vote">Poll authors can\'t vote in their own polls.</string>
|
<string name="poll_author_no_vote">Poll authors can\'t vote in their own polls.</string>
|
||||||
<string name="poll_hashtag" translatable="false">#zappoll</string>
|
<string name="poll_hashtag" translatable="false">#zappoll</string>
|
||||||
|
|
||||||
<string name="connect_via_tor">Connect through your Orbot setup</string>
|
|
||||||
<string name="do_you_really_want_to_disable_tor">Do you really want to disconnect from your Orbot setup?</string>
|
|
||||||
<string name="yes">Yes</string>
|
|
||||||
<string name="no">No</string>
|
|
||||||
<string name="disconnect_from_your_orbot_setup">Disconnect from your Orbot setup</string>
|
|
||||||
|
|
||||||
<string name="hash_verification_passed">Image is the same since the post</string>
|
<string name="hash_verification_passed">Image is the same since the post</string>
|
||||||
<string name="hash_verification_failed">Image has changed. The author might not have seen the change</string>
|
<string name="hash_verification_failed">Image has changed. The author might not have seen the change</string>
|
||||||
|
|
||||||
@@ -361,21 +355,31 @@
|
|||||||
<string name="upload_server_relays_nip95">Your relays (NIP-95)</string>
|
<string name="upload_server_relays_nip95">Your relays (NIP-95)</string>
|
||||||
<string name="upload_server_relays_nip95_explainer">Files are hosted by your relays. New NIP: check if they support</string>
|
<string name="upload_server_relays_nip95_explainer">Files are hosted by your relays. New NIP: check if they support</string>
|
||||||
|
|
||||||
|
<string name="connect_via_tor_short">Tor/Orbot setup</string>
|
||||||
|
<string name="connect_via_tor">Connect through your Orbot setup</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="yes">Yes</string>
|
||||||
|
<string name="no">No</string>
|
||||||
|
|
||||||
|
|
||||||
<string name="follow_list_selection">Follow List</string>
|
<string name="follow_list_selection">Follow List</string>
|
||||||
<string name="follow_list_kind3follows">All Follows</string>
|
<string name="follow_list_kind3follows">All Follows</string>
|
||||||
<string name="follow_list_global">Global</string>
|
<string name="follow_list_global">Global</string>
|
||||||
<string name="connect_through_your_orbot_setup_markdown">
|
<string name="connect_through_your_orbot_setup_markdown">
|
||||||
## Connect through your Orbot setup
|
## Connect through Tor with Orbot
|
||||||
\n\n1. Install [Orbot](https://play.google.com/store/apps/details?id=org.torproject.android)
|
\n\n1. Install [Orbot](https://play.google.com/store/apps/details?id=org.torproject.android)
|
||||||
\n2. Start Orbot
|
\n2. Start Orbot
|
||||||
\n3. In Orbot check the Socks port. By default it uses the port 9050
|
\n3. In Orbot, check the Socks port. The default uses 9050
|
||||||
\n4. If necessary change the port
|
\n4. If necessary change the port in Orbot
|
||||||
\n5. Configure the Socks port in this screen
|
\n5. Configure the Socks port in this screen
|
||||||
\n6. Press the post button to use Orbot as a proxy
|
\n6. Press the Activate button to use Orbot as a proxy
|
||||||
</string>
|
</string>
|
||||||
<string name="orbot_socks_port">Orbot Socks Port</string>
|
<string name="orbot_socks_port">Orbot Socks Port</string>
|
||||||
<string name="invalid_port_number">Invalid port number</string>
|
<string name="invalid_port_number">Invalid port number</string>
|
||||||
|
<string name="use_orbot">Use Orbot</string>
|
||||||
|
<string name="disconnect_from_your_orbot_setup">Disconnect Tor/Orbot</string>
|
||||||
|
|
||||||
<string name="app_notification_channel_id" translatable="false">DefaultChannelID</string>
|
<string name="app_notification_channel_id" translatable="false">DefaultChannelID</string>
|
||||||
<string name="app_notification_private_message" translatable="false">New notification arrived</string>
|
<string name="app_notification_private_message" translatable="false">New notification arrived</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user