Skip to content

Commit

Permalink
use ForageVaultWrapper in ForagePINEditText
Browse files Browse the repository at this point in the history
  • Loading branch information
evanfreeze committed Jun 3, 2024
1 parent f72335d commit 21962a0
Showing 1 changed file with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import com.joinforage.forage.android.core.ui.VaultWrapper
import com.joinforage.forage.android.core.ui.element.ForageConfig
import com.joinforage.forage.android.core.ui.element.ForagePinElement
import com.joinforage.forage.android.ecom.ui.vault.bt.BTVaultWrapper
import com.joinforage.forage.android.ecom.ui.vault.vgs.VGSVaultWrapper
import com.joinforage.forage.android.ecom.ui.vault.forage.ForageVaultWrapper
import com.launchdarkly.sdk.android.LDConfig

/**
Expand Down Expand Up @@ -56,7 +56,7 @@ class ForagePINEditText @JvmOverloads constructor(
defStyleAttr: Int = R.attr.foragePanEditTextStyle
) : ForagePinElement(context, attrs, defStyleAttr) {
private val btVaultWrapper: BTVaultWrapper
private val vgsVaultWrapper: VGSVaultWrapper
private val forageVaultWrapper: ForageVaultWrapper

override fun showKeyboard() = vault.showKeyboard()

Expand All @@ -73,10 +73,10 @@ class ForagePINEditText @JvmOverloads constructor(
// and are thus able to initial LaunchDarkly and find out
// whether to use BT or VGS. So, below we are hedging.
btVaultWrapper = BTVaultWrapper(context, attrs, defStyleAttr)
vgsVaultWrapper = VGSVaultWrapper(context, attrs, defStyleAttr)
forageVaultWrapper = ForageVaultWrapper(context, attrs, defStyleAttr)
// ensure all wrappers init with the
// same typeface (or the attributes)
btVaultWrapper.typeface = vgsVaultWrapper.typeface
forageVaultWrapper.typeface = btVaultWrapper.typeface
} finally {
recycle()
}
Expand All @@ -91,21 +91,19 @@ class ForagePINEditText @JvmOverloads constructor(

// decide on a vault provider and the corresponding vault wrapper
val vaultType = LDManager.getVaultProvider(logger)
return if (vaultType == VaultType.BT_VAULT_TYPE) {
btVaultWrapper
return if (vaultType == VaultType.FORAGE_VAULT_TYPE) {
forageVaultWrapper
} else {
// TODO: Update this to the ForageVaultWrapper once it's back in this codebase
// https://linear.app/joinforage/issue/FX-1368/re-introduce-the-foragevaultwrapper-into-the-coreui-module-in-the
vgsVaultWrapper
btVaultWrapper
}
}

override var typeface: Typeface?
get() = if (vault == btVaultWrapper) btVaultWrapper.typeface else vgsVaultWrapper.typeface
get() = if (vault == btVaultWrapper) btVaultWrapper.typeface else forageVaultWrapper.typeface
set(value) {
// keep all vault providers in sync regardless of
// whether they were added to the UI
btVaultWrapper.typeface = value
vgsVaultWrapper.typeface = value
forageVaultWrapper.typeface = value
}
}

0 comments on commit 21962a0

Please sign in to comment.