Skip to content

Commit 695c1e7

Browse files
Merge pull request #1476 from session-foundation/feature/pro-settings-non-originating
Feature/pro settings non originating
2 parents 9553315 + 461000f commit 695c1e7

File tree

20 files changed

+538
-137
lines changed

20 files changed

+538
-137
lines changed

app/src/firebaseCommon/kotlin/org/thoughtcrime/securesms/notifications/FirebasePushService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class FirebasePushService : FirebaseMessagingService() {
2424
}
2525

2626
override fun onMessageReceived(message: RemoteMessage) {
27-
Log.d(TAG, "Received a firebase push notification: $message - Priority received: ${message.priority} (Priority expected: ${message.originalPriority}) - Sent time: ${dateUtils.getLocaleFormattedDate(message.sentTime, "HH:mm:ss.SSS")}")
27+
Log.d(TAG, "Received a firebase push notification: $message - Priority received: ${message.priority} (Priority expected: ${message.originalPriority}) - Sent time: ${DateUtils.getLocaleFormattedDate(message.sentTime, "HH:mm:ss.SSS")}")
2828
pushReceiver.onPushDataReceived(message.data)
2929
}
3030
}

app/src/main/java/org/session/libsession/utilities/StringSubKeys.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ object StringSubstitutionConstants {
5050
const val APP_PRO_KEY: StringSubKey = "app_pro"
5151
const val PRO_KEY: StringSubKey = "pro"
5252
const val CURRENT_PLAN_KEY: StringSubKey = "current_plan"
53-
const val SELECTED_PLAN_KEY: StringSubKey = "selected_plan"
53+
const val SELECTED_PLAN_KEY: StringSubKey = "selected_plan"
5454
const val PLATFORM_STORE_KEY: StringSubKey = "platform_store"
5555
const val PLATFORM_ACCOUNT_KEY: StringSubKey = "platform_account"
5656
const val MONTHLY_PRICE_KEY: StringSubKey = "monthly_price"
5757
const val PRICE_KEY: StringSubKey = "price"
5858
const val PERCENT_KEY: StringSubKey = "percent"
59-
59+
const val DEVICE_TYPE_KEY: StringSubKey = "device_type"
6060
const val SESSION_FOUNDATION_KEY: StringSubKey = "session_foundation"
6161
}

app/src/main/java/org/thoughtcrime/securesms/conversation/v2/settings/notification/NotificationSettingsViewModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ class NotificationSettingsViewModel @AssistedInject constructor(
195195
}
196196

197197
private fun formatTime(timestamp: Long): String{
198-
return dateUtils.formatTime(timestamp, "HH:mm dd/MM/yy")
198+
return DateUtils.formatTime(timestamp, "HH:mm dd/MM/yy")
199199
}
200200

201201
private fun shouldEnableSetButton(): Boolean {

app/src/main/java/org/thoughtcrime/securesms/debugmenu/DebugMenuViewModel.kt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,9 @@ class DebugMenuViewModel @Inject constructor(
8585
debugSubscriptionStatuses = setOf(
8686
DebugSubscriptionStatus.AUTO_GOOGLE,
8787
DebugSubscriptionStatus.EXPIRING_GOOGLE,
88-
DebugSubscriptionStatus.EXPIRED_GOOGLE, //todo PRO uncomment below once we know how to differentiate store providers
89-
// DebugSubscriptionStatus.AUTO_APPLE,
90-
// DebugSubscriptionStatus.EXPIRING_APPLE,
91-
// DebugSubscriptionStatus.EXPIRED_APPLE,
88+
DebugSubscriptionStatus.AUTO_APPLE,
89+
DebugSubscriptionStatus.EXPIRING_APPLE,
90+
DebugSubscriptionStatus.EXPIRED,
9291
),
9392
selectedDebugSubscriptionStatus = textSecurePreferences.getDebugSubscriptionType() ?: DebugSubscriptionStatus.AUTO_GOOGLE,
9493
)
@@ -412,10 +411,9 @@ class DebugMenuViewModel @Inject constructor(
412411
enum class DebugSubscriptionStatus(val label: String) {
413412
AUTO_GOOGLE("Auto Renewing (Google, 3 months)"),
414413
EXPIRING_GOOGLE("Expiring/Cancelled (Google, 12 months)"),
415-
EXPIRED_GOOGLE("Expired (Google)"),
416414
AUTO_APPLE("Auto Renewing (Apple, 1 months)"),
417415
EXPIRING_APPLE("Expiring/Cancelled (Apple, 1 months)"),
418-
EXPIRED_APPLE("Expired (Apple)")
416+
EXPIRED("Expired"),
419417
}
420418

421419
sealed class Commands {

app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ import android.view.ViewGroup.MarginLayoutParams
1212
import android.widget.Toast
1313
import androidx.activity.viewModels
1414
import androidx.compose.foundation.clickable
15+
import androidx.compose.foundation.interaction.MutableInteractionSource
1516
import androidx.compose.runtime.collectAsState
1617
import androidx.compose.runtime.getValue
18+
import androidx.compose.runtime.remember
1719
import androidx.compose.ui.Modifier
1820
import androidx.compose.ui.platform.ViewCompositionStrategy
1921
import androidx.core.view.isVisible
@@ -216,7 +218,11 @@ class HomeActivity : ScreenLockActionBarActivity(),
216218
Avatar(
217219
size = LocalDimensions.current.iconMediumAvatar,
218220
data = avatarUtils.getUIDataFromRecipient(recipient),
219-
modifier = Modifier.clickable(onClick = ::openSettings)
221+
modifier = Modifier.clickable(
222+
interactionSource = remember { MutableInteractionSource() },
223+
indication = null,
224+
onClick = ::openSettings
225+
)
220226
)
221227
}
222228

app/src/main/java/org/thoughtcrime/securesms/preferences/prosettings/BaseProSettingsScreens.kt

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

3+
import androidx.annotation.DrawableRes
4+
import androidx.compose.foundation.background
5+
import androidx.compose.foundation.layout.Arrangement
36
import androidx.compose.foundation.layout.Box
47
import androidx.compose.foundation.layout.Column
8+
import androidx.compose.foundation.layout.Row
59
import androidx.compose.foundation.layout.Spacer
610
import androidx.compose.foundation.layout.WindowInsets
711
import androidx.compose.foundation.layout.WindowInsetsSides
@@ -11,17 +15,22 @@ import androidx.compose.foundation.layout.fillMaxWidth
1115
import androidx.compose.foundation.layout.height
1216
import androidx.compose.foundation.layout.only
1317
import androidx.compose.foundation.layout.padding
18+
import androidx.compose.foundation.layout.size
1419
import androidx.compose.foundation.layout.systemBars
1520
import androidx.compose.foundation.layout.widthIn
1621
import androidx.compose.foundation.rememberScrollState
1722
import androidx.compose.foundation.verticalScroll
1823
import androidx.compose.material3.ExperimentalMaterial3Api
24+
import androidx.compose.material3.Icon
25+
import androidx.compose.material3.MaterialTheme
1926
import androidx.compose.material3.Scaffold
2027
import androidx.compose.material3.Text
2128
import androidx.compose.runtime.Composable
29+
import androidx.compose.ui.Alignment.Companion.Center
2230
import androidx.compose.ui.Alignment.Companion.CenterHorizontally
2331
import androidx.compose.ui.Modifier
2432
import androidx.compose.ui.graphics.Color
33+
import androidx.compose.ui.res.painterResource
2534
import androidx.compose.ui.text.style.TextAlign
2635
import androidx.compose.ui.tooling.preview.Preview
2736
import androidx.compose.ui.tooling.preview.PreviewParameter
@@ -31,12 +40,16 @@ import org.thoughtcrime.securesms.ui.SessionProSettingsHeader
3140
import org.thoughtcrime.securesms.ui.components.AccentFillButtonRect
3241
import org.thoughtcrime.securesms.ui.components.BackAppBar
3342
import org.thoughtcrime.securesms.ui.components.DangerFillButtonRect
43+
import org.thoughtcrime.securesms.ui.components.annotatedStringResource
3444
import org.thoughtcrime.securesms.ui.theme.LocalColors
3545
import org.thoughtcrime.securesms.ui.theme.LocalDimensions
3646
import org.thoughtcrime.securesms.ui.theme.LocalType
3747
import org.thoughtcrime.securesms.ui.theme.PreviewTheme
3848
import org.thoughtcrime.securesms.ui.theme.SessionColorsParameterProvider
3949
import org.thoughtcrime.securesms.ui.theme.ThemeColors
50+
import org.thoughtcrime.securesms.ui.theme.bold
51+
import network.loki.messenger.R
52+
import org.thoughtcrime.securesms.ui.DialogBg
4053

4154
/**
4255
* Base structure used in most Pro Settings screen
@@ -92,7 +105,7 @@ fun BaseCellButtonProSettingsScreen(
92105
buttonText: String,
93106
dangerButton: Boolean,
94107
onButtonClick: () -> Unit,
95-
title: String? = null,
108+
title: CharSequence? = null,
96109
content: @Composable () -> Unit
97110
) {
98111
BaseProSettingsScreen(
@@ -104,7 +117,7 @@ fun BaseCellButtonProSettingsScreen(
104117
if(!title.isNullOrEmpty()) {
105118
Text(
106119
modifier = Modifier.fillMaxWidth(),
107-
text = title,
120+
text = annotatedStringResource(title),
108121
textAlign = TextAlign.Center,
109122
style = LocalType.current.base,
110123
color = LocalColors.current.text,
@@ -114,7 +127,14 @@ fun BaseCellButtonProSettingsScreen(
114127

115128
Spacer(Modifier.height(LocalDimensions.current.smallSpacing))
116129

117-
Cell(content = content)
130+
Cell {
131+
Column(
132+
modifier = Modifier.fillMaxWidth()
133+
.padding(LocalDimensions.current.smallSpacing)
134+
) {
135+
content()
136+
}
137+
}
118138

119139
Spacer(Modifier.height(LocalDimensions.current.smallSpacing))
120140

@@ -159,3 +179,155 @@ private fun PreviewBaseCellButton(
159179
)
160180
}
161181
}
182+
183+
/**
184+
* A reusable structure for Pro Settings screens for non originating steps
185+
*/
186+
@Composable
187+
fun BaseNonOriginatingProSettingsScreen(
188+
disabled: Boolean,
189+
onBack: () -> Unit,
190+
buttonText: String,
191+
dangerButton: Boolean,
192+
onButtonClick: () -> Unit,
193+
headerTitle: CharSequence?,
194+
contentTitle: String?,
195+
contentDescription: CharSequence?,
196+
linkCellsInfo: String?,
197+
linkCells: List<NonOriginatingLinkCellData> = emptyList(),
198+
) {
199+
BaseCellButtonProSettingsScreen(
200+
disabled = disabled,
201+
onBack = onBack,
202+
buttonText = buttonText,
203+
dangerButton = dangerButton,
204+
onButtonClick = onButtonClick,
205+
title = headerTitle,
206+
){
207+
if (contentTitle != null) {
208+
Text(
209+
text = contentTitle,
210+
style = LocalType.current.h7,
211+
color = LocalColors.current.text,
212+
)
213+
}
214+
215+
if (contentDescription != null) {
216+
Spacer(Modifier.height(LocalDimensions.current.xxxsSpacing))
217+
Text(
218+
text = annotatedStringResource(contentDescription),
219+
style = LocalType.current.base,
220+
color = LocalColors.current.text,
221+
)
222+
}
223+
224+
if (linkCellsInfo != null) {
225+
Spacer(Modifier.height(LocalDimensions.current.smallSpacing))
226+
Text(
227+
text = linkCellsInfo,
228+
style = LocalType.current.base,
229+
color = LocalColors.current.textSecondary,
230+
)
231+
}
232+
233+
Spacer(Modifier.height(LocalDimensions.current.xsSpacing))
234+
235+
linkCells.forEachIndexed { index, data ->
236+
if (index > 0) {
237+
Spacer(Modifier.height(LocalDimensions.current.xsSpacing))
238+
}
239+
NonOriginatingLinkCell(data)
240+
}
241+
}
242+
}
243+
244+
@Composable
245+
fun NonOriginatingLinkCell(
246+
data: NonOriginatingLinkCellData
247+
) {
248+
DialogBg(
249+
bgColor = LocalColors.current.backgroundTertiary
250+
) {
251+
Row(
252+
modifier = Modifier.fillMaxWidth()
253+
.padding(LocalDimensions.current.smallSpacing),
254+
horizontalArrangement = Arrangement.spacedBy(LocalDimensions.current.smallSpacing)
255+
) {
256+
// icon
257+
Box(modifier = Modifier
258+
.background(
259+
color = LocalColors.current.accent.copy(alpha = 0.2f),
260+
shape = MaterialTheme.shapes.small
261+
)
262+
.padding(10.dp)
263+
){
264+
Icon(
265+
modifier = Modifier.align(Center)
266+
.size(LocalDimensions.current.iconMedium),
267+
painter = painterResource(id = data.iconRes),
268+
tint = LocalColors.current.accent,
269+
contentDescription = null
270+
)
271+
}
272+
273+
// text content
274+
Column(
275+
modifier = Modifier.weight(1f)
276+
) {
277+
Text(
278+
text = annotatedStringResource(data.title),
279+
style = LocalType.current.base.bold(),
280+
color = LocalColors.current.text,
281+
)
282+
283+
Spacer(Modifier.height(LocalDimensions.current.xxxsSpacing))
284+
285+
Text(
286+
text = annotatedStringResource(data.info),
287+
style = LocalType.current.base,
288+
color = LocalColors.current.text,
289+
)
290+
}
291+
}
292+
}
293+
}
294+
295+
296+
data class NonOriginatingLinkCellData(
297+
val title: CharSequence,
298+
val info: CharSequence,
299+
@DrawableRes val iconRes: Int,
300+
val onClick: (() -> Unit)? = null
301+
)
302+
303+
@Preview
304+
@Composable
305+
private fun PreviewBaseNonOrig(
306+
@PreviewParameter(SessionColorsParameterProvider::class) colors: ThemeColors
307+
) {
308+
PreviewTheme(colors) {
309+
BaseNonOriginatingProSettingsScreen(
310+
disabled = false,
311+
onBack = {},
312+
headerTitle = "This is a title",
313+
buttonText = "This is a button",
314+
dangerButton = false,
315+
onButtonClick = {},
316+
contentTitle = "This is a content title",
317+
contentDescription = "This is a content description",
318+
linkCellsInfo = "This is a link cells info",
319+
linkCells = listOf(
320+
NonOriginatingLinkCellData(
321+
title = "This is a title",
322+
info = "This is some info",
323+
iconRes = R.drawable.ic_globe
324+
),
325+
NonOriginatingLinkCellData(
326+
title = "This is another title",
327+
info = "This is some different info",
328+
iconRes = R.drawable.ic_phone
329+
)
330+
)
331+
)
332+
}
333+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
package org.thoughtcrime.securesms.preferences.prosettings
2+

0 commit comments

Comments
 (0)