1
1
package org.thoughtcrime.securesms.preferences
2
2
3
3
import android.Manifest
4
- import android.app.Activity
5
4
import android.content.Context
6
5
import android.content.Intent
7
6
import android.graphics.BitmapFactory
@@ -36,7 +35,6 @@ import androidx.compose.foundation.layout.height
36
35
import androidx.compose.foundation.layout.padding
37
36
import androidx.compose.foundation.layout.size
38
37
import androidx.compose.foundation.shape.CircleShape
39
- import androidx.compose.foundation.shape.RoundedCornerShape
40
38
import androidx.compose.material3.ExperimentalMaterial3Api
41
39
import androidx.compose.material3.Text
42
40
import androidx.compose.material3.rememberModalBottomSheetState
@@ -90,6 +88,7 @@ import org.thoughtcrime.securesms.ScreenLockActionBarActivity
90
88
import org.thoughtcrime.securesms.debugmenu.DebugActivity
91
89
import org.thoughtcrime.securesms.home.PathActivity
92
90
import org.thoughtcrime.securesms.messagerequests.MessageRequestsActivity
91
+ import org.thoughtcrime.securesms.openUrl
93
92
import org.thoughtcrime.securesms.permissions.Permissions
94
93
import org.thoughtcrime.securesms.preferences.SettingsViewModel.AvatarDialogState.NoAvatar
95
94
import org.thoughtcrime.securesms.preferences.SettingsViewModel.AvatarDialogState.TempAvatar
@@ -105,6 +104,7 @@ import org.thoughtcrime.securesms.ui.Divider
105
104
import org.thoughtcrime.securesms.ui.GetString
106
105
import org.thoughtcrime.securesms.ui.LargeItemButton
107
106
import org.thoughtcrime.securesms.ui.LargeItemButtonWithDrawable
107
+ import org.thoughtcrime.securesms.ui.OpenURLAlertDialog
108
108
import org.thoughtcrime.securesms.ui.components.BaseBottomSheet
109
109
import org.thoughtcrime.securesms.ui.components.PrimaryOutlineButton
110
110
import org.thoughtcrime.securesms.ui.components.PrimaryOutlineCopyButton
@@ -120,9 +120,11 @@ import org.thoughtcrime.securesms.ui.theme.PreviewTheme
120
120
import org.thoughtcrime.securesms.ui.theme.SessionColorsParameterProvider
121
121
import org.thoughtcrime.securesms.ui.theme.ThemeColors
122
122
import org.thoughtcrime.securesms.ui.theme.dangerButtonColors
123
+ import org.thoughtcrime.securesms.ui.theme.primaryTextButtonColors
123
124
import org.thoughtcrime.securesms.util.FileProviderUtil
124
125
import org.thoughtcrime.securesms.util.applyCommonWindowInsetsOnViews
125
126
import org.thoughtcrime.securesms.util.push
127
+ import org.thoughtcrime.securesms.util.setSafeOnClickListener
126
128
127
129
@AndroidEntryPoint
128
130
class SettingsActivity : ScreenLockActionBarActivity () {
@@ -174,10 +176,10 @@ class SettingsActivity : ScreenLockActionBarActivity() {
174
176
viewModel.permanentlyHidePassword()
175
177
}
176
178
}
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 )
179
+ private var urlToOPen : String? by mutableStateOf( null )
180
+ private var showAvatarDialog: Boolean by mutableStateOf(false )
181
+ private var showAvatarPickerOptionCamera: Boolean by mutableStateOf(false )
182
+ private var showAvatarPickerOptions: Boolean by mutableStateOf(false )
181
183
182
184
private val bgColor by lazy { getColorFromAttr(android.R .attr.colorPrimary) }
183
185
private val txtColor by lazy { getColorFromAttr(android.R .attr.textColorPrimary) }
@@ -203,12 +205,14 @@ class SettingsActivity : ScreenLockActionBarActivity() {
203
205
// set the compose dialog content
204
206
binding.composeLayout.setThemedContent {
205
207
SettingsComposeContent (
208
+ showUrlDialog = urlToOPen,
206
209
showAvatarDialog = showAvatarDialog,
207
210
startAvatarSelection = ::startAvatarSelection,
208
211
saveAvatar = viewModel::saveAvatar,
209
212
removeAvatar = viewModel::removeAvatar,
210
213
showAvatarPickerOptions = showAvatarPickerOptions,
211
214
showCamera = showAvatarPickerOptionCamera,
215
+ hideUrlDialog = { urlToOPen = null },
212
216
onSheetDismissRequest = { showAvatarPickerOptions = false },
213
217
onGalleryPicked = {
214
218
pickPhotoLauncher.launch(PickVisualMediaRequest (ActivityResultContracts .PickVisualMedia .ImageOnly ))
@@ -265,6 +269,10 @@ class SettingsActivity : ScreenLockActionBarActivity() {
265
269
}
266
270
}
267
271
272
+ binding.sentLogoImageView.setSafeOnClickListener {
273
+ urlToOPen = " https://token.getsession.org"
274
+ }
275
+
268
276
applyCommonWindowInsetsOnViews(mainScrollView = binding.scrollView)
269
277
}
270
278
@@ -506,18 +514,45 @@ class SettingsActivity : ScreenLockActionBarActivity() {
506
514
507
515
val hasPaths by OnionRequestAPI .hasPath.collectAsState()
508
516
517
+ // Add the debug menu in non release builds
518
+ if (BuildConfig .BUILD_TYPE != " release" ) {
519
+ Cell {
520
+ LargeItemButton (
521
+ " Debug Menu" ,
522
+ R .drawable.ic_settings,
523
+ shape = getCellTopShape()
524
+ ) { push<DebugActivity >() }
525
+ }
526
+
527
+ Spacer (modifier = Modifier .height(LocalDimensions .current.xsSpacing))
528
+ }
529
+
509
530
Cell {
510
531
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 ()
532
+ // Donate
533
+ LargeItemButton (
534
+ textId = R .string.donate,
535
+ icon = R .drawable.ic_heart ,
536
+ modifier = Modifier .qaTag( R .string.qa_settings_item_donate) ,
537
+ colors = primaryTextButtonColors ()
538
+ ) {
539
+ urlToOPen = " https://session.foundation/donate#app "
519
540
}
541
+ Divider ()
520
542
543
+ // Invite a friend
544
+ LargeItemButton (
545
+ R .string.sessionInviteAFriend,
546
+ R .drawable.ic_user_round_plus,
547
+ Modifier .contentDescription(R .string.AccessibilityId_sessionInviteAFriend )
548
+ ) { sendInvitationToUseSession() }
549
+ }
550
+ }
551
+
552
+ Spacer (modifier = Modifier .height(LocalDimensions .current.xsSpacing))
553
+
554
+ Cell {
555
+ Column {
521
556
Crossfade (if (hasPaths) R .drawable.ic_status else R .drawable.ic_path_yellow, label = " path" ) {
522
557
LargeItemButtonWithDrawable (
523
558
R .string.onionRoutingPath,
@@ -528,28 +563,6 @@ class SettingsActivity : ScreenLockActionBarActivity() {
528
563
}
529
564
Divider ()
530
565
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
-
553
566
// Add the token page option.
554
567
// Note: We can't do this all-in-one via `annotatedStringResource` because the font sizes vary.
555
568
val sessionNetworkAS = buildAnnotatedString {
@@ -573,8 +586,33 @@ class SettingsActivity : ScreenLockActionBarActivity() {
573
586
annotatedStringText = sessionNetworkAS,
574
587
icon = R .drawable.session_network_logo
575
588
) { push<TokenPageActivity >() }
589
+ }
590
+ }
591
+
592
+ Spacer (modifier = Modifier .height(LocalDimensions .current.xsSpacing))
593
+
594
+ Cell {
595
+ Column {
596
+ LargeItemButton (R .string.sessionPrivacy, R .drawable.ic_lock_keyhole) { push<PrivacySettingsActivity >() }
597
+ Divider ()
598
+
599
+ LargeItemButton (R .string.sessionNotifications, R .drawable.ic_volume_2, Modifier .contentDescription(R .string.AccessibilityId_notifications )) { push<NotificationSettingsActivity >() }
576
600
Divider ()
577
601
602
+ LargeItemButton (R .string.sessionConversations, R .drawable.ic_users_round, Modifier .contentDescription(R .string.AccessibilityId_sessionConversations )) { push<ChatSettingsActivity >() }
603
+ Divider ()
604
+
605
+ LargeItemButton (R .string.sessionAppearance, R .drawable.ic_paintbrush_vertical, Modifier .contentDescription(R .string.AccessibilityId_sessionAppearance )) { push<AppearanceSettingsActivity >() }
606
+ Divider ()
607
+
608
+ LargeItemButton (R .string.sessionMessageRequests, R .drawable.ic_message_square_warning, Modifier .contentDescription(R .string.AccessibilityId_sessionMessageRequests )) { push<MessageRequestsActivity >() }
609
+ }
610
+ }
611
+
612
+ Spacer (modifier = Modifier .height(LocalDimensions .current.xsSpacing))
613
+
614
+ Cell {
615
+ Column {
578
616
// Only show the recovery password option if the user has not chosen to permanently hide it
579
617
if (! recoveryHidden) {
580
618
LargeItemButton (
@@ -604,10 +642,12 @@ class SettingsActivity : ScreenLockActionBarActivity() {
604
642
605
643
@Composable
606
644
fun SettingsComposeContent (
645
+ showUrlDialog : String? ,
607
646
showAvatarDialog : Boolean ,
608
647
startAvatarSelection : ()-> Unit ,
609
648
saveAvatar : ()-> Unit ,
610
649
removeAvatar : ()-> Unit ,
650
+ hideUrlDialog : ()-> Unit ,
611
651
showAvatarPickerOptions : Boolean ,
612
652
showCamera : Boolean ,
613
653
onSheetDismissRequest : () -> Unit ,
@@ -623,6 +663,14 @@ class SettingsActivity : ScreenLockActionBarActivity() {
623
663
)
624
664
}
625
665
666
+ // donate confirmationAdd commentMore actions
667
+ if (showUrlDialog != null ){
668
+ OpenURLAlertDialog (
669
+ url = showUrlDialog,
670
+ onDismissRequest = hideUrlDialog
671
+ )
672
+ }
673
+
626
674
// bottom sheets with options for avatar: Gallery or photo
627
675
if (showAvatarPickerOptions) {
628
676
AvatarBottomSheet (
0 commit comments