Update payment flow to work

This commit is contained in:
Aleksandras Kostarevas 2024-04-29 15:19:43 -04:00
parent 41b44d434e
commit 147f711138
4 changed files with 33 additions and 17 deletions

View File

@ -126,6 +126,8 @@ android {
buildConfigField "boolean", "IS_PLAYSTORE_BUILD", "false"
buildConfigField "boolean", "UPDATE_CHECKING", "true"
getIsDefault().set(true)
buildConfigField "String", "PAYMENT_URL", "\"\""
}
playstore {
dimension "buildType"
@ -134,6 +136,8 @@ android {
buildConfigField "boolean", "IS_PLAYSTORE_BUILD", "true"
buildConfigField "boolean", "UPDATE_CHECKING", "false"
buildConfigField "String", "PAYMENT_URL", "\"\""
}
}

View File

@ -72,4 +72,6 @@
<string name="payment">Payment</string>
<string name="license_check_failed">Failed to verify license. If you believe this to be an error, please contact us.</string>
<string name="thank_you_for_using_paid">Thank you for using the paid version of FUTO Keyboard!</string>
<string name="payment_text_3">Note: If you already paid for either FUTO Keyboard or FUTO Voice Input in the past, feel free to tap I already paid.</string>
<string name="payment_processing_note">If you just paid, your payment may still be processing, you should get an email with more information.</string>
</resources>

View File

@ -95,12 +95,7 @@ class PaymentCompleteActivity : ComponentActivity() {
val targetData = intent.dataString
if((targetData?.startsWith("futo-keyboard://license/") == true) || (targetData?.startsWith("futo-voice-input://license/") == true)) {
/*if(StatePayment.instance.setPaymentLicenseUrl(targetData)) {
onPaid(targetData)
} else {
onInvalidKey()
}*/
TODO()
onPaid("activate")
} else {
Log.e("PaymentCompleteActivity", "futo-keyboard launched with invalid targetData $targetData")
finish()

View File

@ -3,11 +3,15 @@ package org.futo.inputmethod.latin.uix.settings.pages
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.widget.Toast
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
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.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
@ -117,7 +121,7 @@ fun ParagraphText(it: String, modifier: Modifier = Modifier) {
}
@Composable
fun PaymentText() {
fun PaymentText(verbose: Boolean) {
val numDaysInstalled = useNumberOfDaysInstalled()
// Doesn't make sense to say "You've been using for ... days" if it's less than seven days
@ -128,6 +132,10 @@ fun PaymentText() {
}
ParagraphText(stringResource(R.string.payment_text_2))
if(verbose) {
ParagraphText(stringResource(R.string.payment_text_3))
}
}
suspend fun pushNoticeReminderTime(context: Context, days: Float) {
@ -194,13 +202,15 @@ fun ConditionalUnpaidNoticeInVoiceInputWindow(onClose: (() -> Unit)? = null) {
@Composable
@Preview
fun UnpaidNotice(onPay: () -> Unit = { }, onAlreadyPaid: () -> Unit = { }) {
fun UnpaidNotice(openMenu: () -> Unit = { }) {
Surface(
color = MaterialTheme.colorScheme.surfaceVariant, modifier = Modifier
.clickable { openMenu() }
.fillMaxWidth()
.padding(24.dp, 8.dp), shape = RoundedCornerShape(4.dp)
.padding(24.dp, 8.dp), shape = RoundedCornerShape(24.dp)
) {
Column(modifier = Modifier.padding(8.dp, 0.dp)) {
Spacer(modifier = Modifier.height(8.dp))
Text(
stringResource(R.string.unpaid_title),
modifier = Modifier.padding(8.dp),
@ -208,7 +218,7 @@ fun UnpaidNotice(onPay: () -> Unit = { }, onAlreadyPaid: () -> Unit = { }) {
color = MaterialTheme.colorScheme.onBackground
)
PaymentText()
PaymentText(false)
Row(
modifier = Modifier
@ -217,14 +227,14 @@ fun UnpaidNotice(onPay: () -> Unit = { }, onAlreadyPaid: () -> Unit = { }) {
) {
Box(modifier = Modifier.weight(1.0f)) {
Button(onClick = onPay, modifier = Modifier.align(Center)) {
Button(onClick = openMenu, modifier = Modifier.align(Center)) {
Text(stringResource(R.string.pay_now))
}
}
Box(modifier = Modifier.weight(1.0f)) {
Button(
onClick = onAlreadyPaid, colors = ButtonDefaults.buttonColors(
onClick = openMenu, colors = ButtonDefaults.buttonColors(
containerColor = MaterialTheme.colorScheme.secondary,
contentColor = MaterialTheme.colorScheme.onSecondary
), modifier = Modifier.align(Center)
@ -242,9 +252,7 @@ fun UnpaidNotice(onPay: () -> Unit = { }, onAlreadyPaid: () -> Unit = { }) {
@Preview
fun ConditionalUnpaidNoticeWithNav(navController: NavController = rememberNavController()) {
UnpaidNoticeCondition {
UnpaidNotice(onPay = {
navController.navigate("payment")
}, onAlreadyPaid = {
UnpaidNotice(openMenu = {
navController.navigate("payment")
})
}
@ -271,6 +279,8 @@ fun PaymentThankYouScreen(onExit: () -> Unit = { }) {
}
ParagraphText(stringResource(R.string.purchase_will_help_body))
ParagraphText(stringResource(R.string.payment_processing_note))
Box(modifier = Modifier
.fillMaxWidth()
.padding(16.dp, 8.dp)) {
@ -355,14 +365,19 @@ fun PaymentScreen(
ScrollableList {
ScreenTitle(stringResource(R.string.payment_title), showBack = true, navController = navController)
PaymentText()
PaymentText(true)
val context = LocalContext.current
Column(modifier = Modifier.fillMaxWidth()) {
Row(modifier = Modifier.padding(8.dp, 0.dp)) {
Button(
onClick = {
TODO()
if(BuildConfig.PAYMENT_URL.isNotBlank()) {
context.openURI(BuildConfig.PAYMENT_URL)
} else {
val toast = Toast.makeText(context, "Payment is unsupported on this build", Toast.LENGTH_SHORT)
toast.show()
}
}, modifier = Modifier
.weight(1.0f)
.padding(8.dp)