From c351e7a6717e1b07405674ae6eff95f1b707a986 Mon Sep 17 00:00:00 2001 From: Devin Morgan Date: Tue, 5 Dec 2023 11:11:55 -0500 Subject: [PATCH] Update sample app to show usState of PAN (#134) * Update sample app to show usState of PAN The change of adding `details` to `ElementState` by making `ElementState` generic appears to be non-breaking becasue the compiler did not complain before making this commit (i.e. before modify the sample app). * Have launch darkly block main thread for up to 1s We're noticing in production that GoPuff Android apps are not respecting dynamic feature flag values. We played around with this in dev and it appeared that LDClient was reading the default VGS flag becuase we were not giving it any time to fetch the latest feature flag values. We're trying to be a bit descrite with this change because we don't think it will cause any issues and we think GoPuff may overreact a bit if they learn we're allowing Forage to block the main thread --- .../com/joinforage/forage/android/LDManager.kt | 2 +- .../flow/tokenize/FlowTokenizeFragment.kt | 3 +++ .../main/res/layout/fragment_flow_tokenize.xml | 17 ++++++++++++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/forage-android/src/main/java/com/joinforage/forage/android/LDManager.kt b/forage-android/src/main/java/com/joinforage/forage/android/LDManager.kt index 2534429c..0703da37 100644 --- a/forage-android/src/main/java/com/joinforage/forage/android/LDManager.kt +++ b/forage-android/src/main/java/com/joinforage/forage/android/LDManager.kt @@ -49,7 +49,7 @@ internal object LDManager { internal fun initialize(app: Application, ldConfig: LDConfig) { val contextKind = ContextKind.of(LDContextKind.SERVICE) val context = LDContext.create(contextKind, LDContexts.ANDROID_CONTEXT) - client = LDClient.init(app, ldConfig, context, 0) + client = LDClient.init(app, ldConfig, context, 1) } internal fun getVaultProvider(logger: Log = Log.getSilentInstance()): VaultType { diff --git a/sample-app/src/main/java/com/joinforage/android/example/ui/complete/flow/tokenize/FlowTokenizeFragment.kt b/sample-app/src/main/java/com/joinforage/android/example/ui/complete/flow/tokenize/FlowTokenizeFragment.kt index c5925074..4fd6e1fd 100644 --- a/sample-app/src/main/java/com/joinforage/android/example/ui/complete/flow/tokenize/FlowTokenizeFragment.kt +++ b/sample-app/src/main/java/com/joinforage/android/example/ui/complete/flow/tokenize/FlowTokenizeFragment.kt @@ -60,6 +60,7 @@ class FlowTokenizeFragment : Fragment() { val isComplete: TextView = binding.isComplete val isEmpty: TextView = binding.isEmpty val isValid: TextView = binding.isValid + val usState: TextView = binding.usState fun setState() { val state = foragePanEditText.getElementState() @@ -67,6 +68,7 @@ class FlowTokenizeFragment : Fragment() { isComplete.text = "isComplete: ${state.isComplete}" isEmpty.text = "isEmpty: ${state.isEmpty}" isValid.text = "isValid: ${state.isValid}" + usState.text = "usState: ${state.derivedCardInfo.usState?.abbreviation}" } foragePanEditText.setOnFocusEventListener { setState() } @@ -77,6 +79,7 @@ class FlowTokenizeFragment : Fragment() { isComplete.text = "isComplete: ${state.isComplete}" isEmpty.text = "isEmpty: ${state.isEmpty}" isValid.text = "isValid: ${state.isValid}" + usState.text = "usState: ${state.derivedCardInfo.usState?.abbreviation}" viewModel.paymentMethod.observe(viewLifecycleOwner) { when (it == null) { diff --git a/sample-app/src/main/res/layout/fragment_flow_tokenize.xml b/sample-app/src/main/res/layout/fragment_flow_tokenize.xml index 1dc779a4..32768291 100644 --- a/sample-app/src/main/res/layout/fragment_flow_tokenize.xml +++ b/sample-app/src/main/res/layout/fragment_flow_tokenize.xml @@ -132,6 +132,21 @@ app:layout_constraintVertical_bias="0.0" tools:text="isValid: false" /> + +