Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class FirebasePushService : FirebaseMessagingService() {
}

override fun onMessageReceived(message: RemoteMessage) {
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")}")
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")}")
pushReceiver.onPushDataReceived(message.data)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,5 @@ object StringSubstitutionConstants {
const val MONTHLY_PRICE_KEY: StringSubKey = "monthly_price"
const val PRICE_KEY: StringSubKey = "price"
const val PERCENT_KEY: StringSubKey = "percent"
const val DEVICE_TYPE_KEY: StringSubKey = "device_type"
}
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class NotificationSettingsViewModel @AssistedInject constructor(
}

private fun formatTime(timestamp: Long): String{
return dateUtils.formatTime(timestamp, "HH:mm dd/MM/yy")
return DateUtils.formatTime(timestamp, "HH:mm dd/MM/yy")
}

private fun shouldEnableSetButton(): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,9 @@ class DebugMenuViewModel @Inject constructor(
debugSubscriptionStatuses = setOf(
DebugSubscriptionStatus.AUTO_GOOGLE,
DebugSubscriptionStatus.EXPIRING_GOOGLE,
DebugSubscriptionStatus.EXPIRED_GOOGLE, //todo PRO uncomment below once we know how to differentiate store providers
// DebugSubscriptionStatus.AUTO_APPLE,
// DebugSubscriptionStatus.EXPIRING_APPLE,
// DebugSubscriptionStatus.EXPIRED_APPLE,
DebugSubscriptionStatus.AUTO_APPLE,
DebugSubscriptionStatus.EXPIRING_APPLE,
DebugSubscriptionStatus.EXPIRED,
),
selectedDebugSubscriptionStatus = textSecurePreferences.getDebugSubscriptionType() ?: DebugSubscriptionStatus.AUTO_GOOGLE,
)
Expand Down Expand Up @@ -412,10 +411,9 @@ class DebugMenuViewModel @Inject constructor(
enum class DebugSubscriptionStatus(val label: String) {
AUTO_GOOGLE("Auto Renewing (Google, 3 months)"),
EXPIRING_GOOGLE("Expiring/Cancelled (Google, 12 months)"),
EXPIRED_GOOGLE("Expired (Google)"),
AUTO_APPLE("Auto Renewing (Apple, 1 months)"),
EXPIRING_APPLE("Expiring/Cancelled (Apple, 1 months)"),
EXPIRED_APPLE("Expired (Apple)")
EXPIRED("Expired"),
}

sealed class Commands {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ import android.view.ViewGroup.MarginLayoutParams
import android.widget.Toast
import androidx.activity.viewModels
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.ViewCompositionStrategy
import androidx.core.view.isVisible
Expand Down Expand Up @@ -216,7 +218,11 @@ class HomeActivity : ScreenLockActionBarActivity(),
Avatar(
size = LocalDimensions.current.iconMediumAvatar,
data = avatarUtils.getUIDataFromRecipient(recipient),
modifier = Modifier.clickable(onClick = ::openSettings)
modifier = Modifier.clickable(
interactionSource = remember { MutableInteractionSource() },
indication = null,
onClick = ::openSettings
)
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package org.thoughtcrime.securesms.preferences.prosettings

import androidx.annotation.DrawableRes
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
Expand All @@ -11,17 +15,22 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.systemBars
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment.Companion.Center
import androidx.compose.ui.Alignment.Companion.CenterHorizontally
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.tooling.preview.PreviewParameter
Expand All @@ -31,12 +40,16 @@ import org.thoughtcrime.securesms.ui.SessionProSettingsHeader
import org.thoughtcrime.securesms.ui.components.AccentFillButtonRect
import org.thoughtcrime.securesms.ui.components.BackAppBar
import org.thoughtcrime.securesms.ui.components.DangerFillButtonRect
import org.thoughtcrime.securesms.ui.components.annotatedStringResource
import org.thoughtcrime.securesms.ui.theme.LocalColors
import org.thoughtcrime.securesms.ui.theme.LocalDimensions
import org.thoughtcrime.securesms.ui.theme.LocalType
import org.thoughtcrime.securesms.ui.theme.PreviewTheme
import org.thoughtcrime.securesms.ui.theme.SessionColorsParameterProvider
import org.thoughtcrime.securesms.ui.theme.ThemeColors
import org.thoughtcrime.securesms.ui.theme.bold
import network.loki.messenger.R
import org.thoughtcrime.securesms.ui.DialogBg

/**
* Base structure used in most Pro Settings screen
Expand Down Expand Up @@ -92,7 +105,7 @@ fun BaseCellButtonProSettingsScreen(
buttonText: String,
dangerButton: Boolean,
onButtonClick: () -> Unit,
title: String? = null,
title: CharSequence? = null,
content: @Composable () -> Unit
) {
BaseProSettingsScreen(
Expand All @@ -104,7 +117,7 @@ fun BaseCellButtonProSettingsScreen(
if(!title.isNullOrEmpty()) {
Text(
modifier = Modifier.fillMaxWidth(),
text = title,
text = annotatedStringResource(title),
textAlign = TextAlign.Center,
style = LocalType.current.base,
color = LocalColors.current.text,
Expand All @@ -114,7 +127,14 @@ fun BaseCellButtonProSettingsScreen(

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

Cell(content = content)
Cell {
Column(
modifier = Modifier.fillMaxWidth()
.padding(LocalDimensions.current.smallSpacing)
) {
content()
}
}

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

Expand Down Expand Up @@ -159,3 +179,155 @@ private fun PreviewBaseCellButton(
)
}
}

/**
* A reusable structure for Pro Settings screens for non originating steps
*/
@Composable
fun BaseNonOriginatingProSettingsScreen(
disabled: Boolean,
onBack: () -> Unit,
buttonText: String,
dangerButton: Boolean,
onButtonClick: () -> Unit,
headerTitle: CharSequence?,
contentTitle: String?,
contentDescription: CharSequence?,
linkCellsInfo: String?,
linkCells: List<NonOriginatingLinkCellData> = emptyList(),
) {
BaseCellButtonProSettingsScreen(
disabled = disabled,
onBack = onBack,
buttonText = buttonText,
dangerButton = dangerButton,
onButtonClick = onButtonClick,
title = headerTitle,
){
if (contentTitle != null) {
Text(
text = contentTitle,
style = LocalType.current.h7,
color = LocalColors.current.text,
)
}

if (contentDescription != null) {
Spacer(Modifier.height(LocalDimensions.current.xxxsSpacing))
Text(
text = annotatedStringResource(contentDescription),
style = LocalType.current.base,
color = LocalColors.current.text,
)
}

if (linkCellsInfo != null) {
Spacer(Modifier.height(LocalDimensions.current.smallSpacing))
Text(
text = linkCellsInfo,
style = LocalType.current.base,
color = LocalColors.current.textSecondary,
)
}

Spacer(Modifier.height(LocalDimensions.current.xsSpacing))

linkCells.forEachIndexed { index, data ->
if (index > 0) {
Spacer(Modifier.height(LocalDimensions.current.xsSpacing))
}
NonOriginatingLinkCell(data)
}
}
}

@Composable
fun NonOriginatingLinkCell(
data: NonOriginatingLinkCellData
) {
DialogBg(
bgColor = LocalColors.current.backgroundTertiary
) {
Row(
modifier = Modifier.fillMaxWidth()
.padding(LocalDimensions.current.smallSpacing),
horizontalArrangement = Arrangement.spacedBy(LocalDimensions.current.smallSpacing)
) {
// icon
Box(modifier = Modifier
.background(
color = LocalColors.current.accent.copy(alpha = 0.2f),
shape = MaterialTheme.shapes.small
)
.padding(10.dp)
){
Icon(
modifier = Modifier.align(Center)
.size(LocalDimensions.current.iconMedium),
painter = painterResource(id = data.iconRes),
tint = LocalColors.current.accent,
contentDescription = null
)
}

// text content
Column(
modifier = Modifier.weight(1f)
) {
Text(
text = annotatedStringResource(data.title),
style = LocalType.current.base.bold(),
color = LocalColors.current.text,
)

Spacer(Modifier.height(LocalDimensions.current.xxxsSpacing))

Text(
text = annotatedStringResource(data.info),
style = LocalType.current.base,
color = LocalColors.current.text,
)
}
}
}
}


data class NonOriginatingLinkCellData(
val title: CharSequence,
val info: CharSequence,
@DrawableRes val iconRes: Int,
val onClick: (() -> Unit)? = null
)

@Preview
@Composable
private fun PreviewBaseNonOrig(
@PreviewParameter(SessionColorsParameterProvider::class) colors: ThemeColors
) {
PreviewTheme(colors) {
BaseNonOriginatingProSettingsScreen(
disabled = false,
onBack = {},
headerTitle = "This is a title",
buttonText = "This is a button",
dangerButton = false,
onButtonClick = {},
contentTitle = "This is a content title",
contentDescription = "This is a content description",
linkCellsInfo = "This is a link cells info",
linkCells = listOf(
NonOriginatingLinkCellData(
title = "This is a title",
info = "This is some info",
iconRes = R.drawable.ic_globe
),
NonOriginatingLinkCellData(
title = "This is another title",
info = "This is some different info",
iconRes = R.drawable.ic_phone
)
)
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package org.thoughtcrime.securesms.preferences.prosettings

Loading