Skip to content
Merged
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 @@ -23,7 +23,6 @@ import org.thoughtcrime.securesms.ui.AnimatedSessionProCTA
import org.thoughtcrime.securesms.ui.CTAFeature
import org.thoughtcrime.securesms.ui.OpenURLAlertDialog
import org.thoughtcrime.securesms.ui.PinProCTA
import org.thoughtcrime.securesms.ui.SessionProCTA
import org.thoughtcrime.securesms.ui.SimpleSessionProCTA
import org.thoughtcrime.securesms.ui.UserProfileModal
import org.thoughtcrime.securesms.ui.theme.SessionMaterialTheme
Expand Down
26 changes: 14 additions & 12 deletions app/src/main/java/org/thoughtcrime/securesms/home/HomeViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,16 @@ class HomeViewModel @Inject constructor(
// - subscription expired less than 30 days ago
val now = Instant.now()

var showExpiring: Boolean = false
var showExpired: Boolean = false

if(subscription.type is ProStatus.Active.Expiring
&& !prefs.hasSeenProExpiring()
){
val validUntil = subscription.type.validUntil
val show = validUntil.isBefore(now.plus(7, ChronoUnit.DAYS))
Log.d(DebugLogGroup.PRO_DATA.label, "Home: Pro active but not auto renewing (expiring). Valid until: $validUntil - Should show Expiring CTA? $show")
if (show) {
showExpiring = validUntil.isBefore(now.plus(7, ChronoUnit.DAYS))
Log.d(DebugLogGroup.PRO_DATA.label, "Home: Pro active but not auto renewing (expiring). Valid until: $validUntil - Should show Expiring CTA? $showExpiring")
if (showExpiring) {
_dialogsState.update { state ->
state.copy(
proExpiringCTA = ProExpiringCTA(
Expand All @@ -188,24 +191,23 @@ class HomeViewModel @Inject constructor(
else if(subscription.type is ProStatus.Expired
&& !prefs.hasSeenProExpired()) {
val validUntil = subscription.type.expiredAt
val show = now.isBefore(validUntil.plus(30, ChronoUnit.DAYS))
showExpired = now.isBefore(validUntil.plus(30, ChronoUnit.DAYS))

Log.d(DebugLogGroup.PRO_DATA.label, "Home: Pro expired. Expired at: $validUntil - Should show Expired CTA? $show")
Log.d(DebugLogGroup.PRO_DATA.label, "Home: Pro expired. Expired at: $validUntil - Should show Expired CTA? $showExpired")

// Check if now is within 30 days after expiry
if (show) {

if (showExpired) {
_dialogsState.update { state ->
state.copy(proExpiredCTA = true)
}
}
}
}
}

// check if we should display the donation CTA
if(donationManager.shouldShowDonationCTA()){
showDonationCTA()
// check if we should display the donation CTA - unless we have a pro CTA already
if(!showExpiring && !showExpired && donationManager.shouldShowDonationCTA()){
showDonationCTA()
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ class InAppReviewViewModel @Inject constructor(

UiState.StartPrompt -> {
when (event) {
UiCommand.PositiveButtonClicked -> UiState.PositivePrompt
// "It's Great" button clicked
UiCommand.PositiveButtonClicked -> {
// mark the app as needing to display the donation post positive review
prefs.setShowDonationCTAFromPositiveReview(true)

UiState.PositivePrompt
}
UiCommand.NegativeButtonClicked -> UiState.NegativePrompt
UiCommand.CloseButtonClicked -> {
manager.onEvent(InAppReviewManager.Event.Dismiss)
Expand All @@ -63,9 +69,6 @@ class InAppReviewViewModel @Inject constructor(
UiCommand.PositiveButtonClicked -> {
manager.onEvent(InAppReviewManager.Event.Dismiss)

// mark the app as needing to display the donation post positive review
prefs.setShowDonationCTAFromPositiveReview(true)

if (runCatching { storeReviewManager.requestReviewFlow() }.isSuccess) {
UiState.Hidden
} else {
Expand Down
15 changes: 4 additions & 11 deletions app/src/main/java/org/thoughtcrime/securesms/ui/AlertDialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -152,21 +152,14 @@ fun BasicSessionAlertDialog(
decorFitsSystemWindows = false
),
content = {
// control content size
Box(
modifier = Modifier
.fillMaxSize()
.background(blackAlpha40), // scrim
.widthIn(max = LocalDimensions.current.maxDialogWidth)
.fillMaxWidth(0.85f),
contentAlignment = Alignment.Center
) {
// control content size
Box(
modifier = Modifier
.widthIn(max = LocalDimensions.current.maxDialogWidth)
.fillMaxWidth(0.85f),
contentAlignment = Alignment.Center
) {
content()
}
content()
}
}
)
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
<item name="colorDividerBackground">@color/gray50</item>
<item name="colorPrimaryVariant">?colorPrimary</item>
<item name="bottomSheetDialogTheme">@style/Theme.Session.BottomSheet</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:backgroundDimAmount">0</item>
<item name="dialogCornerRadius">@dimen/dialog_corner_radius</item>
<item name="android:alertDialogTheme">@style/ThemeOverlay.Session.AlertDialog</item>
<item name="alertDialogTheme">@style/ThemeOverlay.Session.AlertDialog</item>
Expand Down