Skip to content

Commit

Permalink
fix fall back issues
Browse files Browse the repository at this point in the history
  • Loading branch information
phillipthelen committed Jun 10, 2024
1 parent 2505bcf commit 18c106f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ abstract class HabiticaBaseApplication : Application(), Application.ActivityLife
val remoteConfig = FirebaseRemoteConfig.getInstance()
val configSettings =
FirebaseRemoteConfigSettings.Builder()
.setMinimumFetchIntervalInSeconds(if (BuildConfig.DEBUG) 0 else 3600)
.setMinimumFetchIntervalInSeconds(if (BuildConfig.DEBUG) 0 else 1800)
.build()
remoteConfig.setConfigSettingsAsync(configSettings)
remoteConfig.setDefaultsAsync(R.xml.remote_config_defaults)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ class AppConfigManager(contentRepository: ContentRepository) :
}

fun enableCustomizationShop(): Boolean {
if (BuildConfig.DEBUG) return true
return remoteConfig.getBoolean("enableCustomizationShop")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import com.habitrpg.android.habitica.extensions.addCancelButton
import com.habitrpg.android.habitica.extensions.addCloseButton
import com.habitrpg.android.habitica.extensions.getShortRemainingString
import com.habitrpg.android.habitica.helpers.Analytics
import com.habitrpg.android.habitica.helpers.AppConfigManager
import com.habitrpg.android.habitica.helpers.EventCategory
import com.habitrpg.android.habitica.helpers.HapticFeedbackManager
import com.habitrpg.android.habitica.helpers.HitType
Expand Down Expand Up @@ -74,6 +75,7 @@ class PurchaseDialog(
private val inventoryRepository: InventoryRepository
private val userRepository: UserRepository
private val soundManager: SoundManager
private val configManager: AppConfigManager

private val customHeader: View by lazy {
DialogPurchaseShopitemHeaderBinding.inflate(context.layoutInflater).root
Expand Down Expand Up @@ -176,21 +178,23 @@ class PurchaseDialog(

@EntryPoint
@InstallIn(SingletonComponent::class)
interface InsufficientGemsDialogEntryPoint {
interface PurchaseDialogEntryPoint {
fun inventoryRepository(): InventoryRepository
fun userRepository(): UserRepository
fun soundManager(): SoundManager
fun configManager(): AppConfigManager
}

init {
val hiltEntryPoint =
EntryPointAccessors.fromApplication(
context,
InsufficientGemsDialogEntryPoint::class.java,
PurchaseDialogEntryPoint::class.java,
)
inventoryRepository = hiltEntryPoint.inventoryRepository()
userRepository = hiltEntryPoint.userRepository()
soundManager = hiltEntryPoint.soundManager()
configManager = hiltEntryPoint.configManager()

findSnackBarActivity(context)?.let {
(it as? Activity)?.let { activity -> setOwnerActivity(activity) }
Expand Down Expand Up @@ -455,7 +459,11 @@ class PurchaseDialog(
} else if (shopItem.purchaseType == "background" || shopItem.purchaseType == "backgrounds") {
observable = { userRepository.unlockPath(item.unlockPath ?: "${item.pinType}.${item.key}", item.value) }
} else if (shopItem.purchaseType == "customization" || shopItem.purchaseType == "customizationSet") {
observable = { userRepository.unlockPath(item.path ?: item.unlockPath ?: "${item.pinType}.${item.key}", item.value) }
if (configManager.enableCustomizationShop()) {
observable = { userRepository.unlockPath(item.path ?: item.unlockPath ?: "${item.pinType}.${item.key}", item.value) }
} else {
observable = { userRepository.unlockPath(item.unlockPath ?: "${item.pinType}.${item.key}", item.value) }
}
} else if (shopItem.purchaseType == "debuffPotion") {
observable = { userRepository.useSkill(shopItem.key, null) }
} else if (shopItem.purchaseType == "card") {
Expand Down
2 changes: 1 addition & 1 deletion version.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
NAME=4.4
CODE=7931
CODE=7920

0 comments on commit 18c106f

Please sign in to comment.