Skip to content

Commit 20c301d

Browse files
Merge pull request #1228 from session-foundation/release/1.24.1
1.24.1 into master
2 parents 12ef33f + 9576ee5 commit 20c301d

File tree

13 files changed

+170
-51
lines changed

13 files changed

+170
-51
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ configurations.configureEach {
1515
exclude module: "commons-logging"
1616
}
1717

18-
def canonicalVersionCode = 409
19-
def canonicalVersionName = "1.24.0"
18+
def canonicalVersionCode = 410
19+
def canonicalVersionName = "1.24.1"
2020

2121
def postFixSize = 10
2222
def abiPostFix = ['armeabi-v7a' : 1,

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

Lines changed: 84 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package org.thoughtcrime.securesms.preferences
22

33
import android.Manifest
4-
import android.app.Activity
54
import android.content.Context
65
import android.content.Intent
76
import android.graphics.BitmapFactory
@@ -36,7 +35,6 @@ import androidx.compose.foundation.layout.height
3635
import androidx.compose.foundation.layout.padding
3736
import androidx.compose.foundation.layout.size
3837
import androidx.compose.foundation.shape.CircleShape
39-
import androidx.compose.foundation.shape.RoundedCornerShape
4038
import androidx.compose.material3.ExperimentalMaterial3Api
4139
import androidx.compose.material3.Text
4240
import androidx.compose.material3.rememberModalBottomSheetState
@@ -90,6 +88,7 @@ import org.thoughtcrime.securesms.ScreenLockActionBarActivity
9088
import org.thoughtcrime.securesms.debugmenu.DebugActivity
9189
import org.thoughtcrime.securesms.home.PathActivity
9290
import org.thoughtcrime.securesms.messagerequests.MessageRequestsActivity
91+
import org.thoughtcrime.securesms.openUrl
9392
import org.thoughtcrime.securesms.permissions.Permissions
9493
import org.thoughtcrime.securesms.preferences.SettingsViewModel.AvatarDialogState.NoAvatar
9594
import org.thoughtcrime.securesms.preferences.SettingsViewModel.AvatarDialogState.TempAvatar
@@ -105,6 +104,7 @@ import org.thoughtcrime.securesms.ui.Divider
105104
import org.thoughtcrime.securesms.ui.GetString
106105
import org.thoughtcrime.securesms.ui.LargeItemButton
107106
import org.thoughtcrime.securesms.ui.LargeItemButtonWithDrawable
107+
import org.thoughtcrime.securesms.ui.OpenURLAlertDialog
108108
import org.thoughtcrime.securesms.ui.components.BaseBottomSheet
109109
import org.thoughtcrime.securesms.ui.components.PrimaryOutlineButton
110110
import org.thoughtcrime.securesms.ui.components.PrimaryOutlineCopyButton
@@ -120,9 +120,11 @@ import org.thoughtcrime.securesms.ui.theme.PreviewTheme
120120
import org.thoughtcrime.securesms.ui.theme.SessionColorsParameterProvider
121121
import org.thoughtcrime.securesms.ui.theme.ThemeColors
122122
import org.thoughtcrime.securesms.ui.theme.dangerButtonColors
123+
import org.thoughtcrime.securesms.ui.theme.primaryTextButtonColors
123124
import org.thoughtcrime.securesms.util.FileProviderUtil
124125
import org.thoughtcrime.securesms.util.applyCommonWindowInsetsOnViews
125126
import org.thoughtcrime.securesms.util.push
127+
import org.thoughtcrime.securesms.util.setSafeOnClickListener
126128

127129
@AndroidEntryPoint
128130
class SettingsActivity : ScreenLockActionBarActivity() {
@@ -174,10 +176,10 @@ class SettingsActivity : ScreenLockActionBarActivity() {
174176
viewModel.permanentlyHidePassword()
175177
}
176178
}
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)
181183

182184
private val bgColor by lazy { getColorFromAttr(android.R.attr.colorPrimary) }
183185
private val txtColor by lazy { getColorFromAttr(android.R.attr.textColorPrimary) }
@@ -203,12 +205,14 @@ class SettingsActivity : ScreenLockActionBarActivity() {
203205
// set the compose dialog content
204206
binding.composeLayout.setThemedContent {
205207
SettingsComposeContent(
208+
showUrlDialog = urlToOPen,
206209
showAvatarDialog = showAvatarDialog,
207210
startAvatarSelection = ::startAvatarSelection,
208211
saveAvatar = viewModel::saveAvatar,
209212
removeAvatar = viewModel::removeAvatar,
210213
showAvatarPickerOptions = showAvatarPickerOptions,
211214
showCamera = showAvatarPickerOptionCamera,
215+
hideUrlDialog = { urlToOPen = null },
212216
onSheetDismissRequest = { showAvatarPickerOptions = false },
213217
onGalleryPicked = {
214218
pickPhotoLauncher.launch(PickVisualMediaRequest(ActivityResultContracts.PickVisualMedia.ImageOnly))
@@ -265,6 +269,10 @@ class SettingsActivity : ScreenLockActionBarActivity() {
265269
}
266270
}
267271

272+
binding.sentLogoImageView.setSafeOnClickListener {
273+
urlToOPen = "https://token.getsession.org"
274+
}
275+
268276
applyCommonWindowInsetsOnViews(mainScrollView = binding.scrollView)
269277
}
270278

@@ -506,18 +514,45 @@ class SettingsActivity : ScreenLockActionBarActivity() {
506514

507515
val hasPaths by OnionRequestAPI.hasPath.collectAsState()
508516

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+
509530
Cell {
510531
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"
519540
}
541+
Divider()
520542

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 {
521556
Crossfade(if (hasPaths) R.drawable.ic_status else R.drawable.ic_path_yellow, label = "path") {
522557
LargeItemButtonWithDrawable(
523558
R.string.onionRoutingPath,
@@ -528,28 +563,6 @@ class SettingsActivity : ScreenLockActionBarActivity() {
528563
}
529564
Divider()
530565

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-
553566
// Add the token page option.
554567
// Note: We can't do this all-in-one via `annotatedStringResource` because the font sizes vary.
555568
val sessionNetworkAS = buildAnnotatedString {
@@ -573,8 +586,33 @@ class SettingsActivity : ScreenLockActionBarActivity() {
573586
annotatedStringText = sessionNetworkAS,
574587
icon = R.drawable.session_network_logo
575588
) { 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>() }
576600
Divider()
577601

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 {
578616
// Only show the recovery password option if the user has not chosen to permanently hide it
579617
if (!recoveryHidden) {
580618
LargeItemButton(
@@ -604,10 +642,12 @@ class SettingsActivity : ScreenLockActionBarActivity() {
604642

605643
@Composable
606644
fun SettingsComposeContent(
645+
showUrlDialog: String?,
607646
showAvatarDialog: Boolean,
608647
startAvatarSelection: ()->Unit,
609648
saveAvatar: ()->Unit,
610649
removeAvatar: ()->Unit,
650+
hideUrlDialog: ()->Unit,
611651
showAvatarPickerOptions: Boolean,
612652
showCamera: Boolean,
613653
onSheetDismissRequest: () -> Unit,
@@ -623,6 +663,14 @@ class SettingsActivity : ScreenLockActionBarActivity() {
623663
)
624664
}
625665

666+
// donate confirmationAdd commentMore actions
667+
if(showUrlDialog != null){
668+
OpenURLAlertDialog(
669+
url = showUrlDialog,
670+
onDismissRequest = hideUrlDialog
671+
)
672+
}
673+
626674
// bottom sheets with options for avatar: Gallery or photo
627675
if(showAvatarPickerOptions) {
628676
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: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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:fillType="evenOdd" android:pathData="M7.575,30.492C11.091,26.975 15.86,25 20.833,25C25.806,25 30.575,26.975 34.091,30.492C37.608,34.008 39.583,38.777 39.583,43.75C39.583,44.901 38.65,45.833 37.5,45.833C36.349,45.833 35.416,44.901 35.416,43.75C35.416,39.882 33.88,36.173 31.145,33.438C28.41,30.703 24.701,29.167 20.833,29.167C16.965,29.167 13.256,30.703 10.521,33.438C7.786,36.173 6.25,39.882 6.25,43.75C6.25,44.901 5.317,45.833 4.166,45.833C3.016,45.833 2.083,44.901 2.083,43.75C2.083,38.777 4.058,34.008 7.575,30.492Z"/>
4+
5+
<path android:fillColor="#000000" android:fillType="evenOdd" android:pathData="M20.833,8.333C16.231,8.333 12.5,12.064 12.5,16.667C12.5,21.269 16.231,25 20.833,25C25.435,25 29.166,21.269 29.166,16.667C29.166,12.064 25.435,8.333 20.833,8.333ZM8.333,16.667C8.333,9.763 13.929,4.167 20.833,4.167C27.737,4.167 33.333,9.763 33.333,16.667C33.333,23.57 27.737,29.167 20.833,29.167C13.929,29.167 8.333,23.57 8.333,16.667Z"/>
6+
7+
<path android:fillColor="#000000" android:fillType="evenOdd" android:pathData="M34.77,6.645C35.357,5.656 36.635,5.329 37.625,5.916C39.392,6.964 40.874,8.432 41.939,10.189C43.004,11.946 43.619,13.939 43.73,15.991C43.841,18.042 43.445,20.09 42.576,21.952C42.068,23.041 41.408,24.047 40.619,24.941C44.518,28.739 47.916,34.955 47.916,41.667C47.916,42.817 46.984,43.75 45.833,43.75C44.682,43.75 43.75,42.817 43.75,41.667C43.75,35.394 39.971,29.457 36.25,26.667C35.725,26.273 35.416,25.656 35.416,25C35.416,24.344 35.725,23.727 36.249,23.333C37.345,22.511 38.221,21.432 38.8,20.191C39.379,18.949 39.644,17.584 39.569,16.216C39.495,14.849 39.085,13.52 38.375,12.349C37.665,11.177 36.678,10.199 35.499,9.5C34.51,8.913 34.183,7.635 34.77,6.645Z"/>
8+
9+
</vector>

0 commit comments

Comments
 (0)