Skip to content

Commit

Permalink
Merge branch 'release/3.1.11'
Browse files Browse the repository at this point in the history
  • Loading branch information
benoitletondor committed Mar 10, 2024
2 parents 4547fb7 + d81caeb commit f983cb5
Show file tree
Hide file tree
Showing 18 changed files with 119 additions and 73 deletions.
14 changes: 7 additions & 7 deletions Android/EasyBudget/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ android {
compileSdk = 34
minSdk = 23
targetSdk = 34
versionCode = 130
versionName = "3.1.10"
versionCode = 131
versionName = "3.1.11"
vectorDrawables.useSupportLibrary = true
}

Expand Down Expand Up @@ -148,15 +148,15 @@ dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.0")

implementation(platform("com.google.firebase:firebase-bom:32.7.2"))
implementation(platform("com.google.firebase:firebase-bom:32.7.4"))
implementation("com.google.firebase:firebase-messaging-ktx")
implementation("com.google.firebase:firebase-storage")
implementation("com.google.firebase:firebase-crashlytics")
implementation("com.google.firebase:firebase-analytics-ktx")
implementation("com.google.firebase:firebase-firestore-ktx")
implementation("com.firebaseui:firebase-ui-auth:8.0.2")

val composeBom = platform("androidx.compose:compose-bom:2024.02.01")
val composeBom = platform("androidx.compose:compose-bom:2024.02.02")
implementation(composeBom)
androidTestImplementation(composeBom)
debugImplementation("androidx.compose.ui:ui-tooling")
Expand All @@ -167,14 +167,14 @@ dependencies {
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.7.0")
implementation("com.google.accompanist:accompanist-themeadapter-material3:0.34.0")

implementation("com.android.billingclient:billing-ktx:6.1.0")
implementation("com.android.billingclient:billing-ktx:6.2.0")

implementation("me.relex:circleindicator:2.1.6@aar")
implementation("com.batch.android:batch-sdk:1.21.1")

implementation("com.google.dagger:hilt-android:$hiltVersion")
implementation("androidx.hilt:hilt-work:1.1.0")
ksp("androidx.hilt:hilt-compiler:1.1.0")
implementation("androidx.hilt:hilt-work:1.2.0")
ksp("androidx.hilt:hilt-compiler:1.2.0")
ksp("com.google.dagger:hilt-compiler:$hiltVersion")

ksp("androidx.room:room-compiler:2.6.1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,34 @@ package com.benoitletondor.easybudgetapp.db.cacheimpl

import com.benoitletondor.easybudgetapp.db.onlineimpl.Account
import com.benoitletondor.easybudgetapp.db.onlineimpl.OnlineDB
import com.benoitletondor.easybudgetapp.helper.Logger
import com.benoitletondor.easybudgetapp.model.DataForMonth
import kotlinx.coroutines.cancel
import java.time.YearMonth

class CachedOnlineDBImpl(
private val wrappedDB: OnlineDB,
) : OnlineDB, CachedDBImpl(wrappedDB) {
private var isClosed = false

override val account: Account
get() = wrappedDB.account

override suspend fun deleteAllEntries() {
wrappedDB.deleteAllEntries()
}

override suspend fun getDataForMonth(yearMonth: YearMonth): DataForMonth {
if (isClosed) {
Logger.error("Trying to access closed online DB for account: ${account.id}", IllegalStateException("DB is closed"))
return DataForMonth(yearMonth, emptyMap())
}

return super.getDataForMonth(yearMonth)
}

override fun close() {
isClosed = true
cancel()
wrappedDB.close()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ class OnlineDBImpl(
.filter { it is UpdatedRealm }
.debounce(500)
.collect {
onChangeMutableFlow.emit(Unit)
if (!realm.isClosed()) {
onChangeMutableFlow.emit(Unit)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,10 @@ class RecurringExpenseEntity() : RealmObject {
continue
}

cal.addExceptionFromExpense(expense.copy(checked = true), expense.date)
cal.addExceptionFromExpense(
expense = expense.copy(checked = true),
originalOccurrenceDate = expense.associatedRecurringExpense?.originalDate ?: expense.date,
)
}

iCalRepresentation = cal.write()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ fun Activity.setStatusBarColor(@ColorRes colorRes: Int) {
}
}

fun Activity.setNavigationBarColor(@ColorRes colorRes: Int) {
fun Activity.setNavigationBarColored() {
var flags = window.decorView.systemUiVisibility
flags = flags and View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR.inv()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ interface Iab {
suspend fun isUserPremium(): Boolean
suspend fun isUserPro(): Boolean
fun updateIAPStatusIfNeeded()
suspend fun fetchPricing(): Pricing
suspend fun fetchPricingOrDefault(): Pricing
suspend fun launchPremiumSubscriptionFlow(activity: Activity): PurchaseFlowResult
suspend fun launchProSubscriptionFlow(activity: Activity): PurchaseFlowResult
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import android.content.Intent
import androidx.localbroadcastmanager.content.LocalBroadcastManager
import com.android.billingclient.api.*
import com.android.billingclient.api.BillingFlowParams.SubscriptionUpdateParams
import com.benoitletondor.easybudgetapp.R
import com.benoitletondor.easybudgetapp.helper.Logger
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.MutableSharedFlow
Expand Down Expand Up @@ -161,62 +162,74 @@ class IabImpl(
}
}

override suspend fun fetchPricing(): Pricing {
if(iabStatusMutableFlow.value == PremiumCheckStatus.INITIALIZING || iabStatusMutableFlow.value == PremiumCheckStatus.ERROR) {
throw IllegalStateException("IAB is not setup")
}
override suspend fun fetchPricingOrDefault(): Pricing {
try {
if(iabStatusMutableFlow.value == PremiumCheckStatus.INITIALIZING || iabStatusMutableFlow.value == PremiumCheckStatus.ERROR) {
throw IllegalStateException("IAB is not setup")
}

val skuList = listOf(
SKU_PREMIUM_SUBSCRIPTION,
SKU_PRO_SUBSCRIPTION,
)
val skuList = listOf(
SKU_PREMIUM_SUBSCRIPTION,
SKU_PRO_SUBSCRIPTION,
)

val productList = skuList.map { productId ->
QueryProductDetailsParams.Product
.newBuilder()
.setProductId(productId)
.setProductType(BillingClient.ProductType.SUBS)
.build()
}
val productList = skuList.map { productId ->
QueryProductDetailsParams.Product
.newBuilder()
.setProductId(productId)
.setProductType(BillingClient.ProductType.SUBS)
.build()
}

val (billingResult, skuDetailsList) = billingClient.queryProductDetails(
QueryProductDetailsParams.newBuilder()
.setProductList(productList)
.build()
)
val (billingResult, skuDetailsList) = billingClient.queryProductDetails(
QueryProductDetailsParams.newBuilder()
.setProductList(productList)
.build()
)

if (billingResult.responseCode != BillingClient.BillingResponseCode.OK) {
throw IllegalStateException("Unable to connect to reach PlayStore (response code: " + billingResult.responseCode + "). Please restart the app and try again")
}
if (billingResult.responseCode != BillingClient.BillingResponseCode.OK) {
throw IllegalStateException("Unable to connect to reach PlayStore (response code: " + billingResult.responseCode + "). Please restart the app and try again")
}

if(skuDetailsList == null) {
throw IllegalStateException("Unable to get details from PlayStore. Please restart the app and try again")
if(skuDetailsList == null) {
throw IllegalStateException("Unable to get details from PlayStore. Please restart the app and try again")
}

val premiumSubscriptionPrice = skuDetailsList
.first { it.productId == SKU_PREMIUM_SUBSCRIPTION }
.subscriptionOfferDetails
?.first()
?.pricingPhases
?.pricingPhaseList
?.first()
?.formattedPrice
?: throw IllegalArgumentException("No price for premium subscription")

val proSubscriptionPrice = skuDetailsList
.first { it.productId == SKU_PRO_SUBSCRIPTION }
.subscriptionOfferDetails
?.first()
?.pricingPhases
?.pricingPhaseList
?.first()
?.formattedPrice
?: throw IllegalArgumentException("No price for pro subscription")

return Pricing(
premiumPricing = premiumSubscriptionPrice,
proPricing = proSubscriptionPrice,
)
} catch (e: Exception) {
if (e is CancellationException) throw e

Logger.error("Error while fetching pricing, returning default", e)

return Pricing(
premiumPricing = appContext.getString(R.string.premium_subscription_price),
proPricing = appContext.getString(R.string.pro_subscription_price),
)
}

val premiumSubscriptionPrice = skuDetailsList
.first { it.productId == SKU_PREMIUM_SUBSCRIPTION }
.subscriptionOfferDetails
?.first()
?.pricingPhases
?.pricingPhaseList
?.first()
?.formattedPrice
?: throw IllegalArgumentException("No price for premium subscription")

val proSubscriptionPrice = skuDetailsList
.first { it.productId == SKU_PRO_SUBSCRIPTION }
.subscriptionOfferDetails
?.first()
?.pricingPhases
?.pricingPhaseList
?.first()
?.formattedPrice
?: throw IllegalArgumentException("No price for pro subscription")

return Pricing(
premiumPricing = premiumSubscriptionPrice,
proPricing = proSubscriptionPrice,
)
}

private fun queryPurchases() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import androidx.compose.ui.Modifier
import androidx.lifecycle.lifecycleScope
import com.benoitletondor.easybudgetapp.R
import com.benoitletondor.easybudgetapp.helper.launchCollect
import com.benoitletondor.easybudgetapp.helper.setNavigationBarColor
import com.benoitletondor.easybudgetapp.helper.setNavigationBarColored
import com.benoitletondor.easybudgetapp.helper.setStatusBarColor
import com.benoitletondor.easybudgetapp.iab.PurchaseFlowResult
import com.benoitletondor.easybudgetapp.theme.AppTheme
Expand Down Expand Up @@ -90,7 +90,7 @@ class PremiumActivity : AppCompatActivity() {
}

setStatusBarColor(R.color.easy_budget_green)
setNavigationBarColor(R.color.easy_budget_green)
setNavigationBarColored()

collectViewModelEvents()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class PremiumViewModel @Inject constructor(
val eventFlow: Flow<Event> = eventMutableSharedFlow

@OptIn(ExperimentalCoroutinesApi::class)
val userSubscriptionStatus: Flow<SubscriptionStatus> = flow { emit(iab.fetchPricing()) }
val userSubscriptionStatus: Flow<SubscriptionStatus> = flow { emit(iab.fetchPricingOrDefault()) }
.flatMapLatest { pricing ->
iab.iabStatusFlow
.map { iabStatus ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import android.view.ViewAnimationUtils

import com.benoitletondor.easybudgetapp.databinding.ActivityWelcomeBinding
import com.benoitletondor.easybudgetapp.helper.BaseActivity
import com.benoitletondor.easybudgetapp.helper.setNavigationBarColored
import com.benoitletondor.easybudgetapp.helper.setStatusBarColor
import com.benoitletondor.easybudgetapp.parameters.Parameters
import dagger.hilt.android.AndroidEntryPoint
Expand Down Expand Up @@ -165,10 +166,7 @@ class WelcomeActivity : BaseActivity<ActivityWelcomeBinding>() {
setStatusBarColor(fragment.statusBarColor)
}

var flags = window.decorView.systemUiVisibility
flags = flags and View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR.inv()

window.decorView.systemUiVisibility = flags
setNavigationBarColored()
}

override fun onDestroy() {
Expand Down
2 changes: 2 additions & 0 deletions Android/EasyBudget/app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -463,4 +463,6 @@
<string name="premium_popup_become_go_back">Zurück</string>
<string name="calendar_month_loading_error_title">Daten können nicht geladen werden</string>
<string name="calendar_month_loading_error_description">Beim Laden der Kalenderdaten ist ein Fehler aufgetreten. Bitte versuchen Sie es erneut.\n(%s)</string>
<string name="premium_subscription_price">1,99€</string>
<string name="pro_subscription_price">4,99€</string>
</resources>
2 changes: 2 additions & 0 deletions Android/EasyBudget/app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -463,4 +463,6 @@
<string name="premium_popup_become_go_back">Atrás</string>
<string name="calendar_month_loading_error_title">No se pueden cargar datos</string>
<string name="calendar_month_loading_error_description">Se produjo un error al cargar los datos del calendario. Por favor, inténtalo de nuevo.\n(%s)</string>
<string name="premium_subscription_price">1,99€</string>
<string name="pro_subscription_price">4,99€</string>
</resources>
2 changes: 2 additions & 0 deletions Android/EasyBudget/app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -463,4 +463,6 @@
<string name="premium_popup_become_go_back">Retour</string>
<string name="calendar_month_loading_error_title">Impossible de charger les données</string>
<string name="calendar_month_loading_error_description">Une erreur est survenue lors du chargement des données du calendrier. Veuillez réessayer.\n(%s)</string>
<string name="premium_subscription_price">1,99€</string>
<string name="pro_subscription_price">4,99€</string>
</resources>
2 changes: 2 additions & 0 deletions Android/EasyBudget/app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -463,4 +463,6 @@
<string name="premium_popup_become_go_back">Indietro</string>
<string name="calendar_month_loading_error_title">Impossibile caricare i dati</string>
<string name="calendar_month_loading_error_description">Si è verificato un errore durante il caricamento dei dati del calendario. Per favore riprova.\n(%s)</string>
<string name="premium_subscription_price">1,99€</string>
<string name="pro_subscription_price">4,99€</string>
</resources>
2 changes: 2 additions & 0 deletions Android/EasyBudget/app/src/main/res/values-pt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -463,4 +463,6 @@
<string name="premium_popup_become_go_back">Voltar</string>
<string name="calendar_month_loading_error_title">Não foi possível carregar os dados</string>
<string name="calendar_month_loading_error_description">Ocorreu um erro ao carregar os dados do calendário. Por favor, tente novamente.\n(%s)</string>
<string name="premium_subscription_price">1,99€</string>
<string name="pro_subscription_price">4,99€</string>
</resources>
2 changes: 2 additions & 0 deletions Android/EasyBudget/app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -465,4 +465,6 @@
<string name="premium_popup_become_go_back">Назад</string>
<string name="calendar_month_loading_error_title">Невозможно загрузить данные</string>
<string name="calendar_month_loading_error_description">Произошла ошибка при загрузке данных календаря. Пожалуйста, попробуйте еще раз.\n(%s)</string>
<string name="premium_subscription_price">$1.99</string>
<string name="pro_subscription_price">$4.99</string>
</resources>
3 changes: 3 additions & 0 deletions Android/EasyBudget/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,9 @@
<string name="calendar_month_loading_error_title">Unable to load data</string>
<string name="calendar_month_loading_error_description">An error occurred while loading calendar data. Please try again.\n(%s)</string>

<string name="premium_subscription_price">$1.99</string>
<string name="pro_subscription_price">$4.99</string>

<!-- Keys, not for translations. -->
<string name="setting_category_bug_report_send_button_key" translatable="false">send_bug_report</string>
<string name="setting_category_show_welcome_screen_button_key" translatable="false">show_welcome_screen</string>
Expand Down
12 changes: 6 additions & 6 deletions Android/EasyBudget/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
* limitations under the License.
*/
val kotlinVersion by extra("1.9.22") // Change in the plugins below too
val hiltVersion by extra("2.50") // Change in the plugins below too
val realmVersion by extra("1.13.0") // Change in the plugins below too
val hiltVersion by extra("2.51") // Change in the plugins below too
val realmVersion by extra("1.14.0") // Change in the plugins below too

plugins {
id("com.android.application") version "8.2.2" apply false
id("com.android.library") version "8.2.2" apply false
id("com.android.application") version "8.3.0" apply false
id("com.android.library") version "8.3.0" apply false
id("com.google.firebase.crashlytics") version "2.9.9" apply false
id("com.google.gms.google-services") version "4.4.1" apply false
id("org.jetbrains.kotlin.android") version "1.9.22" apply false
id("com.google.dagger.hilt.android") version "2.50" apply false
id("com.google.dagger.hilt.android") version "2.51" apply false
id("com.google.devtools.ksp") version "1.9.22-1.0.17" apply false
id("io.realm.kotlin") version "1.13.0" apply false
id("io.realm.kotlin") version "1.14.0" apply false
}

0 comments on commit f983cb5

Please sign in to comment.