Skip to content

Commit

Permalink
Modify sample app to show all three vault elements
Browse files Browse the repository at this point in the history
This is the easiest way to confirm that the styling changes work. The
plan is to make another branch on top of this that uses these same
modifications to show what it would have looked like before the fix gets
applied
  • Loading branch information
devinmorgan committed Jun 18, 2024
1 parent c984bdc commit bd7e89d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import com.joinforage.forage.android.core.ui.element.ForagePinElement
import com.joinforage.forage.android.core.ui.getLogoImageViewLayout
import com.joinforage.forage.android.ecom.ui.vault.bt.BTVaultWrapper
import com.joinforage.forage.android.ecom.ui.vault.forage.RosettaPinElement
import com.joinforage.forage.android.ecom.ui.vault.vgs.VGSVaultWrapper
import com.launchdarkly.sdk.android.LDConfig

/**
Expand Down Expand Up @@ -62,6 +63,7 @@ class ForagePINEditText @JvmOverloads constructor(
) : ForagePinElement(context, attrs, defStyleAttr), DynamicEnvElement {
private val btVaultWrapper: BTVaultWrapper
private val rosettaPinElement: RosettaPinElement
private val vgsVaultWrapper: VGSVaultWrapper

/**
* The `vault` property acts as an abstraction for the actual code
Expand Down Expand Up @@ -102,11 +104,16 @@ class ForagePINEditText @JvmOverloads constructor(
// Then, within setForageConfig, once we know the environment
// and are thus able to initial LaunchDarkly and find out
// whether to use BT or Forage. So, below we are hedging.
vgsVaultWrapper = VGSVaultWrapper(context, attrs, defStyleAttr)
btVaultWrapper = BTVaultWrapper(context, attrs, defStyleAttr)
rosettaPinElement = RosettaPinElement(context, attrs, defStyleAttr)
// ensure all wrappers init with the
// same typeface (or the attributes)
btVaultWrapper.typeface = rosettaPinElement.typeface

_linearLayout.addView(rosettaPinElement.getTextElement())
_linearLayout.addView(btVaultWrapper.getTextElement())
_linearLayout.addView(vgsVaultWrapper.getTextElement())
} finally {
recycle()
}
Expand All @@ -126,7 +133,7 @@ class ForagePINEditText @JvmOverloads constructor(
// it to the parent view
_SET_ONLY_vault = determineBackingVault(forageConfig, logger)

_linearLayout.addView(vault.getTextElement())
// _linearLayout.addView(vault.getTextElement())
_linearLayout.addView(getLogoImageViewLayout(context))
addView(_linearLayout)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,13 @@ class CatalogFragment : Fragment() {
merchantId = "0123456"
)

binding.firstForageEditText.setForageConfig(forageConfig)
binding.secondEditText.setForageConfig(forageConfig)
binding.thirdEditText.setForageConfig(forageConfig)
binding.fourthEditText.setForageConfig(forageConfig)
binding.foragePinEditText.setForageConfig(forageConfig)
binding.secondForagePINEditText.setForageConfig(forageConfig)
binding.thirdForagePINEditText.setForageConfig(forageConfig)

// NOTE: we call setForageConfig a second time here so that
// the CI tests always confirm that running setForageConfig
// more than once is OK and does not cause a crash. So,
// these duplicate calls are intentional here
binding.firstForageEditText.setForageConfig(forageConfig)
binding.secondEditText.setForageConfig(forageConfig)
binding.thirdEditText.setForageConfig(forageConfig)
binding.fourthEditText.setForageConfig(forageConfig)
binding.foragePinEditText.setForageConfig(forageConfig)
binding.secondForagePINEditText.setForageConfig(forageConfig)
binding.thirdForagePINEditText.setForageConfig(forageConfig)

return root
}
Expand Down
95 changes: 7 additions & 88 deletions sample-app/src/main/res/layout/fragment_catalog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,96 +7,15 @@
android:layout_marginBottom="100dp"
tools:context=".ui.catalog.CatalogFragment">

<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
<com.joinforage.forage.android.ecom.ui.element.ForagePINEditText
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<com.joinforage.forage.android.ecom.ui.element.ForagePANEditText
android:id="@+id/firstForageEditText"
style="?attr/catalogFirstForagePanEditTextStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />

<com.joinforage.forage.android.ecom.ui.element.ForagePANEditText
android:id="@+id/secondEditText"
style="?catalogSecondForagePanEditTextStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/firstForageEditText" />

<com.joinforage.forage.android.ecom.ui.element.ForagePANEditText
android:id="@+id/thirdEditText"
style="?catalogThirdForagePanEditTextStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/secondEditText" />

<com.joinforage.forage.android.ecom.ui.element.ForagePANEditText
android:id="@+id/fourthEditText"
style="?catalogFourthForagePanEditTextStyle"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_margin="16dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/thirdEditText" />

<com.joinforage.forage.android.ecom.ui.element.ForagePINEditText
android:id="@+id/foragePinEditText"
style="@style/ForagePINEditTextStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:inputWidth="200dp"
app:inputHeight="60dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/fourthEditText" />

<com.joinforage.forage.android.ecom.ui.element.ForagePINEditText
android:id="@+id/secondForagePINEditText"
style="@style/SecondForagePINEditTextStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:elementWidth="150dp"
app:elementHeight="70dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/foragePinEditText" />

<com.joinforage.forage.android.ecom.ui.element.ForagePINEditText
android:id="@+id/thirdForagePINEditText"
style="@style/ThirdForagePINEditTextStyle"
android:layout_width="80dp"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/secondForagePINEditText" />

</androidx.constraintlayout.widget.ConstraintLayout>

</ScrollView>
android:id="@+id/foragePinEditText"
style="@style/ForagePINEditTextStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>

</androidx.constraintlayout.widget.ConstraintLayout>

0 comments on commit bd7e89d

Please sign in to comment.