Skip to content

Commit 847eee9

Browse files
Merge pull request #1227 from session-foundation/fixes/1.24.1
Fixes/1.24.1
2 parents c2e4d77 + 98aec7d commit 847eee9

File tree

11 files changed

+159
-47
lines changed

11 files changed

+159
-47
lines changed

app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt

Lines changed: 84 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ import org.thoughtcrime.securesms.ScreenLockActionBarActivity
9090
import org.thoughtcrime.securesms.debugmenu.DebugActivity
9191
import org.thoughtcrime.securesms.home.PathActivity
9292
import org.thoughtcrime.securesms.messagerequests.MessageRequestsActivity
93+
import org.thoughtcrime.securesms.openUrl
9394
import org.thoughtcrime.securesms.permissions.Permissions
9495
import org.thoughtcrime.securesms.preferences.SettingsViewModel.AvatarDialogState.NoAvatar
9596
import org.thoughtcrime.securesms.preferences.SettingsViewModel.AvatarDialogState.TempAvatar
@@ -105,6 +106,7 @@ import org.thoughtcrime.securesms.ui.Divider
105106
import org.thoughtcrime.securesms.ui.GetString
106107
import org.thoughtcrime.securesms.ui.LargeItemButton
107108
import org.thoughtcrime.securesms.ui.LargeItemButtonWithDrawable
109+
import org.thoughtcrime.securesms.ui.OpenURLAlertDialog
108110
import org.thoughtcrime.securesms.ui.components.BaseBottomSheet
109111
import org.thoughtcrime.securesms.ui.components.PrimaryOutlineButton
110112
import org.thoughtcrime.securesms.ui.components.PrimaryOutlineCopyButton
@@ -120,9 +122,11 @@ import org.thoughtcrime.securesms.ui.theme.PreviewTheme
120122
import org.thoughtcrime.securesms.ui.theme.SessionColorsParameterProvider
121123
import org.thoughtcrime.securesms.ui.theme.ThemeColors
122124
import org.thoughtcrime.securesms.ui.theme.dangerButtonColors
125+
import org.thoughtcrime.securesms.ui.theme.primaryTextButtonColors
123126
import org.thoughtcrime.securesms.util.FileProviderUtil
124127
import org.thoughtcrime.securesms.util.applyCommonWindowInsetsOnViews
125128
import org.thoughtcrime.securesms.util.push
129+
import org.thoughtcrime.securesms.util.setSafeOnClickListener
126130

127131
@AndroidEntryPoint
128132
class SettingsActivity : ScreenLockActionBarActivity() {
@@ -174,10 +178,10 @@ class SettingsActivity : ScreenLockActionBarActivity() {
174178
viewModel.permanentlyHidePassword()
175179
}
176180
}
177-
178-
private var showAvatarDialog: Boolean by mutableStateOf(false)
179-
private var showAvatarPickerOptionCamera: Boolean by mutableStateOf(false)
180-
private var showAvatarPickerOptions: Boolean by mutableStateOf(false)
181+
private var showDonateDialog: Boolean by mutableStateOf(false)
182+
private var showAvatarDialog: Boolean by mutableStateOf(false)
183+
private var showAvatarPickerOptionCamera: Boolean by mutableStateOf(false)
184+
private var showAvatarPickerOptions: Boolean by mutableStateOf(false)
181185

182186
private val bgColor by lazy { getColorFromAttr(android.R.attr.colorPrimary) }
183187
private val txtColor by lazy { getColorFromAttr(android.R.attr.textColorPrimary) }
@@ -203,12 +207,14 @@ class SettingsActivity : ScreenLockActionBarActivity() {
203207
// set the compose dialog content
204208
binding.composeLayout.setThemedContent {
205209
SettingsComposeContent(
210+
showDonateDialog = showDonateDialog,
206211
showAvatarDialog = showAvatarDialog,
207212
startAvatarSelection = ::startAvatarSelection,
208213
saveAvatar = viewModel::saveAvatar,
209214
removeAvatar = viewModel::removeAvatar,
210215
showAvatarPickerOptions = showAvatarPickerOptions,
211216
showCamera = showAvatarPickerOptionCamera,
217+
hideDonateDialog = { showDonateDialog = false },
212218
onSheetDismissRequest = { showAvatarPickerOptions = false },
213219
onGalleryPicked = {
214220
pickPhotoLauncher.launch(PickVisualMediaRequest(ActivityResultContracts.PickVisualMedia.ImageOnly))
@@ -265,6 +271,10 @@ class SettingsActivity : ScreenLockActionBarActivity() {
265271
}
266272
}
267273

274+
binding.sentLogoImageView.setSafeOnClickListener {
275+
openUrl("https://token.getsession.org")
276+
}
277+
268278
applyCommonWindowInsetsOnViews(mainScrollView = binding.scrollView)
269279
}
270280

@@ -506,18 +516,45 @@ class SettingsActivity : ScreenLockActionBarActivity() {
506516

507517
val hasPaths by OnionRequestAPI.hasPath.collectAsState()
508518

519+
// Add the debug menu in non release builds
520+
if (BuildConfig.BUILD_TYPE != "release") {
521+
Cell{
522+
LargeItemButton(
523+
"Debug Menu",
524+
R.drawable.ic_settings,
525+
shape = getCellTopShape()
526+
) { push<DebugActivity>() }
527+
}
528+
529+
Spacer(modifier = Modifier.height(LocalDimensions.current.xsSpacing))
530+
}
531+
509532
Cell {
510533
Column {
511-
// Add the debug menu in non release builds
512-
if (BuildConfig.BUILD_TYPE != "release") {
513-
LargeItemButton(
514-
"Debug Menu",
515-
R.drawable.ic_settings,
516-
shape = getCellTopShape()
517-
) { push<DebugActivity>() }
518-
Divider()
534+
// Donate
535+
LargeItemButton(
536+
textId = R.string.donate,
537+
icon = R.drawable.ic_heart,
538+
modifier = Modifier.qaTag(R.string.qa_settings_item_donate),
539+
colors = primaryTextButtonColors()
540+
) {
541+
showDonateDialog = true
519542
}
543+
Divider()
544+
545+
// Invite a friend
546+
LargeItemButton(
547+
R.string.sessionInviteAFriend,
548+
R.drawable.ic_user_round_plus,
549+
Modifier.contentDescription(R.string.AccessibilityId_sessionInviteAFriend)
550+
) { sendInvitationToUseSession() }
551+
}
552+
}
553+
554+
Spacer(modifier = Modifier.height(LocalDimensions.current.xsSpacing))
520555

556+
Cell {
557+
Column {
521558
Crossfade(if (hasPaths) R.drawable.ic_status else R.drawable.ic_path_yellow, label = "path") {
522559
LargeItemButtonWithDrawable(
523560
R.string.onionRoutingPath,
@@ -528,28 +565,6 @@ class SettingsActivity : ScreenLockActionBarActivity() {
528565
}
529566
Divider()
530567

531-
LargeItemButton(R.string.sessionPrivacy, R.drawable.ic_lock_keyhole) { push<PrivacySettingsActivity>() }
532-
Divider()
533-
534-
LargeItemButton(R.string.sessionNotifications, R.drawable.ic_volume_2, Modifier.contentDescription(R.string.AccessibilityId_notifications)) { push<NotificationSettingsActivity>() }
535-
Divider()
536-
537-
LargeItemButton(R.string.sessionConversations, R.drawable.ic_message_square, Modifier.contentDescription(R.string.AccessibilityId_sessionConversations)) { push<ChatSettingsActivity>() }
538-
Divider()
539-
540-
LargeItemButton(R.string.sessionMessageRequests, R.drawable.ic_message_square_warning, Modifier.contentDescription(R.string.AccessibilityId_sessionMessageRequests)) { push<MessageRequestsActivity>() }
541-
Divider()
542-
543-
LargeItemButton(R.string.sessionAppearance, R.drawable.ic_paintbrush_vertical, Modifier.contentDescription(R.string.AccessibilityId_sessionAppearance)) { push<AppearanceSettingsActivity>() }
544-
Divider()
545-
546-
LargeItemButton(
547-
R.string.sessionInviteAFriend,
548-
R.drawable.ic_user_round_plus,
549-
Modifier.contentDescription(R.string.AccessibilityId_sessionInviteAFriend)
550-
) { sendInvitationToUseSession() }
551-
Divider()
552-
553568
// Add the token page option.
554569
// Note: We can't do this all-in-one via `annotatedStringResource` because the font sizes vary.
555570
val sessionNetworkAS = buildAnnotatedString {
@@ -573,8 +588,33 @@ class SettingsActivity : ScreenLockActionBarActivity() {
573588
annotatedStringText = sessionNetworkAS,
574589
icon = R.drawable.session_network_logo
575590
) { push<TokenPageActivity>() }
591+
}
592+
}
593+
594+
Spacer(modifier = Modifier.height(LocalDimensions.current.xsSpacing))
595+
596+
Cell {
597+
Column {
598+
LargeItemButton(R.string.sessionPrivacy, R.drawable.ic_lock_keyhole) { push<PrivacySettingsActivity>() }
576599
Divider()
577600

601+
LargeItemButton(R.string.sessionNotifications, R.drawable.ic_volume_2, Modifier.contentDescription(R.string.AccessibilityId_notifications)) { push<NotificationSettingsActivity>() }
602+
Divider()
603+
604+
LargeItemButton(R.string.sessionConversations, R.drawable.ic_message_square, Modifier.contentDescription(R.string.AccessibilityId_sessionConversations)) { push<ChatSettingsActivity>() }
605+
Divider()
606+
607+
LargeItemButton(R.string.sessionAppearance, R.drawable.ic_paintbrush_vertical, Modifier.contentDescription(R.string.AccessibilityId_sessionAppearance)) { push<AppearanceSettingsActivity>() }
608+
Divider()
609+
610+
LargeItemButton(R.string.sessionMessageRequests, R.drawable.ic_message_square_warning, Modifier.contentDescription(R.string.AccessibilityId_sessionMessageRequests)) { push<MessageRequestsActivity>() }
611+
}
612+
}
613+
614+
Spacer(modifier = Modifier.height(LocalDimensions.current.xsSpacing))
615+
616+
Cell {
617+
Column {
578618
// Only show the recovery password option if the user has not chosen to permanently hide it
579619
if (!recoveryHidden) {
580620
LargeItemButton(
@@ -604,10 +644,12 @@ class SettingsActivity : ScreenLockActionBarActivity() {
604644

605645
@Composable
606646
fun SettingsComposeContent(
647+
showDonateDialog: Boolean,
607648
showAvatarDialog: Boolean,
608649
startAvatarSelection: ()->Unit,
609650
saveAvatar: ()->Unit,
610651
removeAvatar: ()->Unit,
652+
hideDonateDialog: ()->Unit,
611653
showAvatarPickerOptions: Boolean,
612654
showCamera: Boolean,
613655
onSheetDismissRequest: () -> Unit,
@@ -623,6 +665,14 @@ class SettingsActivity : ScreenLockActionBarActivity() {
623665
)
624666
}
625667

668+
// donate confirmationAdd commentMore actions
669+
if(showDonateDialog){
670+
OpenURLAlertDialog(
671+
url = "https://session.foundation/donate#app",
672+
onDismissRequest = hideDonateDialog
673+
)
674+
}
675+
626676
// bottom sheets with options for avatar: Gallery or photo
627677
if(showAvatarPickerOptions) {
628678
AvatarBottomSheet(

app/src/main/java/org/thoughtcrime/securesms/tokenpage/TokenDataManager.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ class TokenDataManager @Inject constructor(
4040
textSecurePreferences.watchLocalNumber()
4141
.map { it != null }
4242
.distinctUntilChanged()
43-
.collect {
44-
fetchInfoResponse()
43+
.collect { logged ->
44+
if(logged) fetchInfoResponse()
4545
}
4646
}
4747
}

app/src/main/java/org/thoughtcrime/securesms/tokenpage/TokenPageActivity.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ import androidx.activity.viewModels
55
import androidx.compose.runtime.Composable
66
import dagger.hilt.android.AndroidEntryPoint
77
import org.thoughtcrime.securesms.FullComposeActivity
8+
import org.thoughtcrime.securesms.FullComposeScreenLockActivity
89
import org.thoughtcrime.securesms.ScreenLockActionBarActivity
910
import org.thoughtcrime.securesms.ui.setComposeContent
1011

1112
@AndroidEntryPoint
12-
class TokenPageActivity : FullComposeActivity() {
13+
class TokenPageActivity : FullComposeScreenLockActivity() {
1314
private val viewModel: TokenPageViewModel by viewModels()
1415

1516
@Composable

app/src/main/java/org/thoughtcrime/securesms/tokenpage/TokenPageViewModel.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,10 @@ class TokenPageViewModel @Inject constructor(
237237
// Note: We pass this in to the token page so we can call it when we refresh the page.
238238
private suspend fun getNodeData() {
239239
withContext(Dispatchers.Default) {
240-
val myPublicKey = getLocalNumber(context)
240+
val myPublicKey = prefs.getLocalNumber() ?: return@withContext
241+
241242
val getSwarmSetPromise: Promise<Set<Snode>, Exception> =
242-
SnodeAPI.getSwarm(myPublicKey!!)
243+
SnodeAPI.getSwarm(myPublicKey)
243244

244245
val numSessionNodesInOurSwarm = try {
245246
// Get the count of Session nodes in our swarm (technically in the range 1..10, but

app/src/main/java/org/thoughtcrime/securesms/ui/theme/ThemeColors.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ fun dangerButtonColors() = ButtonDefaults.buttonColors(
9898
contentColor = LocalColors.current.danger
9999
)
100100

101+
@Composable
102+
fun primaryTextButtonColors() = ButtonDefaults.buttonColors(
103+
containerColor = Color.Transparent,
104+
contentColor = LocalColors.current.primaryText
105+
)
106+
101107
// Our themes
102108
data class ClassicDark(override val primary: Color = primaryGreen) : ThemeColors {
103109
override val isLight = false
-13.2 KB
Binary file not shown.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:autoMirrored="true" android:height="24dp" android:viewportHeight="50" android:viewportWidth="50" android:width="24dp">
2+
3+
<path android:fillColor="#000000" android:pathData="M43.75,17.708C43.75,15.222 42.762,12.838 41.003,11.08C39.245,9.322 36.861,8.333 34.375,8.333C32.75,8.333 31.486,8.562 30.316,9.072C29.133,9.587 27.917,10.446 26.473,11.889C25.659,12.703 24.34,12.703 23.527,11.889C22.083,10.446 20.867,9.587 19.684,9.072C18.514,8.562 17.25,8.333 15.625,8.333C13.139,8.333 10.755,9.322 8.997,11.08C7.238,12.838 6.25,15.222 6.25,17.708C6.25,21.075 8.166,23.871 10.73,26.534L25,40.804L38.125,27.679L39.26,26.532C41.824,23.846 43.75,21.055 43.75,17.708ZM47.917,17.708C47.917,23.416 44.151,27.601 41.054,30.637L41.056,30.639L26.473,45.223C25.659,46.036 24.34,46.036 23.527,45.223L8.968,30.664L7.772,29.472C4.953,26.56 2.083,22.727 2.083,17.708C2.083,14.117 3.509,10.671 6.049,8.132C8.588,5.592 12.033,4.167 15.625,4.167C17.667,4.167 19.528,4.458 21.348,5.251C22.625,5.807 23.816,6.586 25,7.587C26.184,6.586 27.374,5.807 28.652,5.251C30.472,4.458 32.333,4.167 34.375,4.167C37.966,4.167 41.412,5.592 43.951,8.132C46.491,10.671 47.917,14.117 47.917,17.708Z"/>
4+
5+
</vector>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="430dp"
3+
android:height="48dp"
4+
android:viewportWidth="430"
5+
android:viewportHeight="48">
6+
<path
7+
android:pathData="M274.05,11.4H302.66V13.35H289.46V36.83H287.25V13.35H274.05V11.39L274.05,11.4Z"
8+
android:fillColor="#000000"/>
9+
<path
10+
android:pathData="M35.53,24.1L41.39,18.23C43.39,16.23 44.47,13.57 44.43,10.73C44.39,7.97 43.25,5.39 41.23,3.46C39.24,1.56 36.63,0.51 33.87,0.51H11.07C8.32,0.51 5.7,1.56 3.71,3.46C1.69,5.39 0.55,7.97 0.51,10.73C0.47,13.57 1.55,16.23 3.55,18.23L9.39,24.07L3.55,29.91C1.55,31.91 0.47,34.58 0.51,37.41C0.55,40.17 1.69,42.76 3.71,44.69C5.7,46.59 8.32,47.63 11.07,47.63H22.43V47.64H33.84C36.59,47.64 39.2,46.6 41.19,44.7C43.21,42.77 44.35,40.18 44.39,37.42C44.43,34.59 43.35,31.92 41.35,29.92L35.53,24.1V24.1ZM7.02,14.76C5.97,13.7 5.4,12.3 5.42,10.81C5.47,7.84 8,5.42 11.07,5.42H33.87C36.94,5.42 39.48,7.84 39.52,10.81C39.54,12.3 38.97,13.7 37.92,14.76L32.05,20.63L30.17,18.74C28.05,16.62 25.26,15.56 22.47,15.54C22.46,15.54 22.46,15.54 22.45,15.54C22.45,15.54 22.44,15.54 22.43,15.54C19.64,15.55 16.85,16.62 14.72,18.75L12.87,20.6L12.87,20.59L12.86,20.6L7.02,14.76V14.76ZM16.34,24.06L16.35,24.07L18.19,22.22C19.37,21.05 20.91,20.46 22.45,20.45C23.99,20.46 25.53,21.05 26.7,22.22L28.58,24.1L26.75,25.93C25.57,27.11 24.02,27.7 22.48,27.7C20.93,27.7 19.38,27.11 18.2,25.94L16.34,24.07L16.34,24.06L16.34,24.06ZM33.84,42.73H22.47V42.72H11.07C8,42.72 5.47,40.31 5.42,37.34C5.4,35.84 5.97,34.44 7.02,33.38L12.86,27.54L14.73,29.41C16.87,31.54 19.67,32.61 22.48,32.61C25.28,32.61 28.09,31.54 30.22,29.41L32.06,27.57L37.88,33.39C38.94,34.45 39.5,35.85 39.48,37.35C39.44,40.32 36.9,42.73 33.84,42.73Z"
11+
android:fillColor="#000000"/>
12+
<path
13+
android:pathData="M302.62,24.09C302.62,15.99 308.84,10.71 318.72,10.71C328.59,10.71 334.81,16.02 334.81,24.09C334.81,32.16 328.59,37.55 318.72,37.55C308.84,37.55 302.62,32.23 302.62,24.09ZM318.72,35.59C327.36,35.59 332.54,30.82 332.54,24.09C332.54,17.37 327.4,12.66 318.72,12.66C310.03,12.66 304.9,17.37 304.9,24.09C304.9,30.82 310.07,35.59 318.72,35.59Z"
14+
android:fillColor="#000000"/>
15+
<path
16+
android:pathData="M338.79,11.4H340.99V27.75L363.13,11.4H366.57L352.39,21.92L366.57,36.82H363.74L350.68,23.19L340.99,30.39V36.83H338.79V11.4Z"
17+
android:fillColor="#000000"/>
18+
<path
19+
android:pathData="M370.85,11.4H395.13V13.24H373.06V23.22H394.4V25H373.06V34.98H395.13V36.82H370.85V11.4Z"
20+
android:fillColor="#000000"/>
21+
<path
22+
android:pathData="M399.73,11.4H402.95L426.68,34.84V11.4H428.89V36.83H425.67L401.94,13.39V36.83H399.73V11.4Z"
23+
android:fillColor="#000000"/>
24+
<path
25+
android:pathData="M54.76,28.4H61.31C61.31,31.51 63.99,32.94 70.79,32.94C77.04,32.94 79.09,31.98 79.09,29.65C79.09,27.33 77.48,26.86 70.46,26.44L69.11,26.33C59.2,25.76 55.34,23.54 55.34,18.24C55.34,12.95 60.56,10.73 69.43,10.73C79.26,10.73 84.34,13.7 84.59,19.5H78.01C78.01,16.39 75,15.39 69.17,15.39C63.7,15.39 61.92,16.28 61.92,18.24C61.92,20.53 63.56,21.1 70.04,21.53L71.5,21.64C80.41,22.32 85.66,23.14 85.66,29.44C85.66,35.73 80.12,37.59 70.93,37.59C60.63,37.59 54.98,35.23 54.77,28.4H54.76Z"
26+
android:fillColor="#000000"/>
27+
<path
28+
android:pathData="M89.85,11.38H115.34V16.21H96.17V21.89H114.62V26.32H96.17V32.04H115.34V36.87H89.85V11.38Z"
29+
android:fillColor="#000000"/>
30+
<path
31+
android:pathData="M119.24,28.4H125.78C125.78,31.51 128.46,32.94 135.26,32.94C141.52,32.94 143.56,31.98 143.56,29.65C143.56,27.33 141.95,26.86 134.94,26.44L133.58,26.33C123.67,25.76 119.81,23.54 119.81,18.24C119.81,12.95 125.03,10.73 133.9,10.73C143.74,10.73 148.82,13.7 149.07,19.5H142.49C142.49,16.39 139.48,15.39 133.65,15.39C128.18,15.39 126.39,16.28 126.39,18.24C126.39,20.53 128.04,21.1 134.51,21.53L135.98,21.64C144.88,22.32 150.14,23.14 150.14,29.44C150.14,35.73 144.6,37.59 135.4,37.59C125.1,37.59 119.46,35.23 119.24,28.4Z"
32+
android:fillColor="#000000"/>
33+
<path
34+
android:pathData="M153.61,28.4H160.15C160.15,31.51 162.83,32.94 169.63,32.94C175.89,32.94 177.93,31.98 177.93,29.65C177.93,27.33 176.32,26.86 169.31,26.44L167.95,26.33C158.04,25.76 154.18,23.54 154.18,18.24C154.18,12.95 159.4,10.73 168.27,10.73C178.11,10.73 183.18,13.7 183.43,19.5H176.86C176.86,16.39 173.85,15.39 168.02,15.39C162.55,15.39 160.76,16.28 160.76,18.24C160.76,20.53 162.4,21.1 168.88,21.53L170.35,21.64C179.25,22.32 184.51,23.14 184.51,29.44C184.51,35.73 178.97,37.59 169.77,37.59C159.47,37.59 153.82,35.23 153.61,28.4Z"
35+
android:fillColor="#000000"/>
36+
<path
37+
android:pathData="M188.33,11.38H194.66V36.88H188.33V11.38Z"
38+
android:fillColor="#000000"/>
39+
<path
40+
android:pathData="M198.67,24.11C198.67,16.03 205.43,10.74 215.94,10.74C226.45,10.74 233.28,16.03 233.28,24.11C233.28,32.2 226.52,37.59 215.94,37.59C205.36,37.59 198.67,32.3 198.67,24.11ZM215.94,32.23C222.59,32.23 226.71,28.94 226.71,24.11C226.71,19.28 222.59,16.1 215.94,16.1C209.29,16.1 205.25,19.32 205.25,24.11C205.25,28.91 209.36,32.23 215.94,32.23Z"
41+
android:fillColor="#000000"/>
42+
<path
43+
android:pathData="M236.4,11.38H245.73L262.33,31.05V11.38H268.66V36.88H259.29L242.73,17.21V36.88H236.4V11.38H236.4Z"
44+
android:fillColor="#000000"/>
45+
</vector>

0 commit comments

Comments
 (0)