Skip to content

Commit

Permalink
Merge pull request #1025 from hyperskill/hotfix/1.56.1
Browse files Browse the repository at this point in the history
Hotfix 1.56.1
  • Loading branch information
ivan-magda authored May 2, 2024
2 parents fbd7a62 + e95d6cc commit 3fe273e
Show file tree
Hide file tree
Showing 26 changed files with 341 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ private class LazyLoggerProvider(private val tag: String) : Lazy<Logger> {

private var logger: Logger? = null
override val value: Logger
get() = logger ?: HyperskillApp.graph().loggerComponent.logger.withTag(tag)
get() {
if (logger == null) {
logger = HyperskillApp.graph().loggerComponent.logger.withTag(tag)
}
return logger!!
}

override fun isInitialized(): Boolean =
logger != null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import org.hyperskill.app.android.core.view.ui.widget.compose.HyperskillTheme
@Composable
fun PaywallContent(
buyButtonText: String,
priceText: String?,
isContinueWithLimitsButtonVisible: Boolean,
onTermsOfServiceClick: () -> Unit,
onBuySubscriptionClick: () -> Unit,
Expand All @@ -48,7 +49,6 @@ fun PaywallContent(
.padding(PaywallDefaults.ContentPadding + padding)
) {
Column(
verticalArrangement = Arrangement.spacedBy(24.dp),
modifier = Modifier.weight(1f)
) {
Image(
Expand All @@ -57,12 +57,18 @@ fun PaywallContent(
modifier = Modifier
.align(Alignment.CenterHorizontally)
)
Spacer(modifier = Modifier.height(24.dp))
Text(
text = stringResource(id = R.string.paywall_mobile_only_title),
style = MaterialTheme.typography.h5,
fontWeight = FontWeight.Medium
)
Spacer(modifier = Modifier.height(24.dp))
SubscriptionDetails()
Spacer(modifier = Modifier.height(32.dp))
if (priceText != null) {
SubscriptionPrice(priceText)
}
}
Column {
HyperskillButton(
Expand All @@ -73,25 +79,10 @@ fun PaywallContent(
}
Spacer(modifier = Modifier.height(8.dp))
if (isContinueWithLimitsButtonVisible) {
HyperskillButton(
onClick = onContinueWithLimitsClick,
colors = HyperskillButtonDefaults.buttonColors(colorResource(id = R.color.layer_1)),
border = BorderStroke(1.dp, colorResource(id = R.color.button_tertiary)),
modifier = Modifier.fillMaxWidth()
) {
Text(
text = stringResource(id = R.string.paywall_mobile_only_continue_btn),
color = colorResource(id = R.color.button_tertiary)
)
}
ContinueButton(onClick = onContinueWithLimitsClick)
}
Spacer(modifier = Modifier.height(20.dp))

Text(
text = stringResource(id = R.string.paywall_tos_and_privacy_bth),
fontSize = 12.sp,
color = colorResource(id = R.color.color_on_surface_alpha_60),
textAlign = TextAlign.Center,
TermsOfService(
modifier = Modifier
.align(Alignment.CenterHorizontally)
.clickable(onClick = onTermsOfServiceClick)
Expand All @@ -100,13 +91,66 @@ fun PaywallContent(
}
}

@Composable
private fun SubscriptionPrice(
priceText: String,
modifier: Modifier = Modifier
) {
Column(
modifier = modifier,
verticalArrangement = Arrangement.spacedBy(8.dp)
) {
Text(
text = stringResource(id = R.string.paywall_android_subscription_duration),
style = MaterialTheme.typography.subtitle1,
fontWeight = FontWeight.Medium
)
Text(
text = priceText,
style = MaterialTheme.typography.body2
)
}
}

@Composable
private fun ContinueButton(
onClick: () -> Unit,
modifier: Modifier = Modifier
) {
HyperskillButton(
onClick = onClick,
colors = HyperskillButtonDefaults.buttonColors(colorResource(id = R.color.layer_1)),
border = BorderStroke(1.dp, colorResource(id = R.color.button_tertiary)),
modifier = modifier.fillMaxWidth()
) {
Text(
text = stringResource(id = R.string.paywall_mobile_only_continue_btn),
color = colorResource(id = R.color.button_tertiary)
)
}
}

@Composable
private fun TermsOfService(
modifier: Modifier = Modifier
) {
Text(
text = stringResource(id = R.string.paywall_tos_and_privacy_bth),
fontSize = 12.sp,
color = colorResource(id = R.color.color_on_surface_alpha_60),
textAlign = TextAlign.Center,
modifier = modifier
)
}

@Preview
@Composable
fun PaywallContentPreview() {
HyperskillTheme {
PaywallContent(
buyButtonText = PaywallPreviewDefaults.BUY_BUTTON_TEXT,
isContinueWithLimitsButtonVisible = true,
priceText = PaywallPreviewDefaults.PRICE_TEXT,
onTermsOfServiceClick = {},
onBuySubscriptionClick = {},
onContinueWithLimitsClick = {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.hyperskill.app.android.paywall.ui

object PaywallPreviewDefaults {
const val BUY_BUTTON_TEXT = "Subscribe for $12.00/month"
const val BUY_BUTTON_TEXT = "Subscribe"
const val PRICE_TEXT = "$11.99 / month"
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ fun PaywallScreen(
PaywallContent(
buyButtonText = contentState.buyButtonText,
isContinueWithLimitsButtonVisible = contentState.isContinueWithLimitsButtonVisible,
priceText = contentState.priceText,
onBuySubscriptionClick = onBuySubscriptionClick,
onContinueWithLimitsClick = onContinueWithLimitsClick,
onTermsOfServiceClick = onTermsOfServiceClick,
Expand All @@ -132,14 +133,16 @@ private class PaywallPreviewProvider : PreviewParameterProvider<ViewState> {
isToolbarVisible = true,
contentState = ViewStateContent.Content(
buyButtonText = PaywallPreviewDefaults.BUY_BUTTON_TEXT,
isContinueWithLimitsButtonVisible = false
isContinueWithLimitsButtonVisible = false,
priceText = "$11.99 / month"
)
),
ViewState(
isToolbarVisible = false,
contentState = ViewStateContent.Content(
buyButtonText = PaywallPreviewDefaults.BUY_BUTTON_TEXT,
isContinueWithLimitsButtonVisible = true
isContinueWithLimitsButtonVisible = true,
priceText = PaywallPreviewDefaults.PRICE_TEXT
)
),
ViewState(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ import org.hyperskill.app.android.core.view.ui.widget.compose.HyperskillTheme
import org.hyperskill.app.R as SharedR

@Composable
fun SubscriptionDetails(modifier: Modifier = Modifier) {
fun SubscriptionDetails(
modifier: Modifier = Modifier
) {
Column(
modifier = modifier,
verticalArrangement = Arrangement.spacedBy(6.dp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class AppFeatureStateSerializationTest {
AppFeature.State.Ready(
isAuthorized = true,
isMobileLeaderboardsEnabled = true,
isMobileOnlySubscriptionEnabled = true
isMobileOnlySubscriptionEnabled = true,
canMakePayments = true
)
else -> throw IllegalStateException("Unknown state class: $stateClass. Please add it to the test.")
}
Expand Down
4 changes: 2 additions & 2 deletions gradle/app.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
minSdk = '24'
targetSdk = '33'
compileSdk = '33'
versionName = '1.56'
versionCode = '408'
versionName = '1.56.1'
versionCode = '418'
4 changes: 2 additions & 2 deletions iosHyperskillApp/NotificationServiceExtension/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleVersion</key>
<string>429</string>
<string>431</string>
<key>CFBundleShortVersionString</key>
<string>1.56</string>
<string>1.56.1</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleExecutable</key>
Expand Down
16 changes: 8 additions & 8 deletions iosHyperskillApp/iosHyperskillApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -5253,7 +5253,7 @@
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 429;
CURRENT_PROJECT_VERSION = 431;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = UJ4KC2QN7B;
GENERATE_INFOPLIST_FILE = NO;
Expand All @@ -5274,7 +5274,7 @@
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 429;
CURRENT_PROJECT_VERSION = 431;
DEVELOPMENT_TEAM = UJ4KC2QN7B;
GENERATE_INFOPLIST_FILE = NO;
INFOPLIST_FILE = iosHyperskillAppUITests/Info.plist;
Expand All @@ -5295,7 +5295,7 @@
BUNDLE_LOADER = "$(TEST_HOST)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 429;
CURRENT_PROJECT_VERSION = 431;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = UJ4KC2QN7B;
INFOPLIST_FILE = iosHyperskillAppTests/Info.plist;
Expand All @@ -5316,7 +5316,7 @@
BUNDLE_LOADER = "$(TEST_HOST)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 429;
CURRENT_PROJECT_VERSION = 431;
DEVELOPMENT_TEAM = UJ4KC2QN7B;
INFOPLIST_FILE = iosHyperskillAppTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
Expand All @@ -5337,7 +5337,7 @@
CODE_SIGN_ENTITLEMENTS = NotificationServiceExtension/NotificationServiceExtension.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 429;
CURRENT_PROJECT_VERSION = 431;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = UJ4KC2QN7B;
INFOPLIST_FILE = NotificationServiceExtension/Info.plist;
Expand Down Expand Up @@ -5366,7 +5366,7 @@
CODE_SIGN_ENTITLEMENTS = NotificationServiceExtension/NotificationServiceExtension.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 429;
CURRENT_PROJECT_VERSION = 431;
DEVELOPMENT_TEAM = UJ4KC2QN7B;
INFOPLIST_FILE = NotificationServiceExtension/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
Expand Down Expand Up @@ -5512,7 +5512,7 @@
CODE_SIGN_ENTITLEMENTS = iosHyperskillApp/iosHyperskillApp.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 429;
CURRENT_PROJECT_VERSION = 431;
DEVELOPMENT_ASSET_PATHS = "\"iosHyperskillApp/Preview Content\"";
DEVELOPMENT_TEAM = UJ4KC2QN7B;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -5548,7 +5548,7 @@
CODE_SIGN_ENTITLEMENTS = iosHyperskillApp/iosHyperskillApp.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 429;
CURRENT_PROJECT_VERSION = 431;
DEVELOPMENT_ASSET_PATHS = "\"iosHyperskillApp/Preview Content\"";
DEVELOPMENT_TEAM = UJ4KC2QN7B;
ENABLE_PREVIEWS = YES;
Expand Down
4 changes: 2 additions & 2 deletions iosHyperskillApp/iosHyperskillApp/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.56</string>
<string>1.56.1</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
Expand All @@ -34,7 +34,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>429</string>
<string>431</string>
<key>FirebaseAppDelegateProxyEnabled</key>
<false/>
<key>FirebaseMessagingAutoInitEnabled</key>
Expand Down
4 changes: 2 additions & 2 deletions iosHyperskillApp/iosHyperskillAppTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.56</string>
<string>1.56.1</string>
<key>CFBundleVersion</key>
<string>429</string>
<string>431</string>
</dict>
</plist>
4 changes: 2 additions & 2 deletions iosHyperskillApp/iosHyperskillAppUITests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.56</string>
<string>1.56.1</string>
<key>CFBundleVersion</key>
<string>429</string>
<string>431</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import com.revenuecat.purchases.awaitGetProducts
import com.revenuecat.purchases.awaitLogIn
import com.revenuecat.purchases.awaitPurchase
import com.revenuecat.purchases.models.StoreProduct
import kotlin.coroutines.resume
import kotlin.coroutines.resumeWithException
import kotlin.coroutines.suspendCoroutine
import org.hyperskill.app.BuildConfig
import org.hyperskill.app.purchases.domain.model.PlatformPurchaseParams
import org.hyperskill.app.purchases.domain.model.PurchaseManager
Expand Down Expand Up @@ -45,6 +48,20 @@ class AndroidPurchaseManager(
Purchases.sharedInstance.awaitLogIn(userId.toString())
}

@Suppress("TooGenericExceptionCaught")
override suspend fun canMakePayments(): Result<Boolean> =
runCatching {
suspendCoroutine { continuation ->
try {
Purchases.canMakePayments(application) { result ->
continuation.resume(result)
}
} catch (e: Exception) {
continuation.resumeWithException(e)
}
}
}

override suspend fun purchase(
productId: String,
platformPurchaseParams: PlatformPurchaseParams
Expand Down
Loading

0 comments on commit 3fe273e

Please sign in to comment.