-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create ForageVaultWrapper #144
Create ForageVaultWrapper #144
Conversation
forage-android/src/main/java/com/joinforage/forage/android/ui/ForageVaultWrapper.kt
Fixed
Show fixed
Hide fixed
forage-android/src/main/java/com/joinforage/forage/android/ui/ForageVaultWrapper.kt
Fixed
Show fixed
Hide fixed
forage-android/src/main/java/com/joinforage/forage/android/ui/ForageVaultWrapper.kt
Fixed
Show fixed
Hide fixed
@devinmorgan it seems to me that the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work so far, Danny. My understanding is that you said there's still a bit of work you wanted to do in this PR so I'll wait to approve until you take it out of Draft. Cheers!
@@ -96,7 +97,7 @@ internal class VGSVaultWrapper @JvmOverloads constructor( | |||
// up into separate focus and blur listeners. This requires | |||
// that we pass a single listener to VGS on init that uses | |||
// mutable references to listeners so that setting the focus | |||
// would not remove the blur listener and vice versea | |||
// would not remove the blur listener and vice versa |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
omg embarrassing - thank you for catching and fixing!
override fun getForageTextElement(): EditText { | ||
throw RuntimeException("Unimplemented for this vault!") | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No action required right now but the work we're doing here is surfacing that we probably have some tech debt around the relationship between VaultWrapper
and ForagePINEdiText
that we'll want to pay down at some point.
That we don't want BTVaultWrapper
or VGSVaultWrapper
to implement getForageTextElement
, indicates that we should not be making getForageTextElement
an abstract method on the VaultWrapper
class. VaultWrapper
already declares getTextElement
and getVGSEditText
as abstract methods even though they too really should not be living on VaultWrapper
since they are specific to BT / VGS wrappers. After poking around the code, it's clear that ForagePINEditText
is implemented in a way that expects all vaults expose a getTextElement
and getVGSEditText
. ForagePINEditText
s dependency on these methods means the fix won't be trivial and so we should probably defer paying this debt down to a later ticket.
One way that I can see to fix this delema is to create an abstraction over the underlying editable text field that BT, VGS, and Forage expose so that there is a unified way of calling things like:
getUnderlyingView()
clearText()
- etc
But anyhow, my next step is to make a Linear ticket to capture this and share the link here once I do. But, like a said before, I think what you're doing here is fine and won't break or block anything.
override val manager: PinElementStateManager = PinElementStateManager.forEmptyInput() | ||
|
||
init { | ||
context.obtainStyledAttributes(attrs, R.styleable.ForagePINEditText, defStyleAttr, 0) |
Check warning
Code scanning / Android Lint
Mismatched Styleable/Custom View Name Warning
override val manager: PinElementStateManager = PinElementStateManager.forEmptyInput() | ||
|
||
init { | ||
context.obtainStyledAttributes(attrs, R.styleable.ForagePINEditText, defStyleAttr, 0) |
Check warning
Code scanning / Android Lint
Mismatched Styleable/Custom View Name Warning
forage-android/src/main/java/com/joinforage/forage/android/ui/ForageVaultWrapper.kt
Dismissed
Show dismissed
Hide dismissed
|
||
fun parseStyles(context: Context, attrs: AttributeSet?): ParsedStyles { | ||
val defaultRadius = resources.getDimension(R.dimen.default_horizontal_field) | ||
val typedArray: TypedArray = context.obtainStyledAttributes(attrs, R.styleable.ForagePINEditText) |
Check warning
Code scanning / Android Lint
Mismatched Styleable/Custom View Name Warning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work on this PR Danny! Thanks for your patience with me in the review process. Exciting progress so far!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice strategy for separating the PIN validation logic from the PIN rendering logic!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Introducing the data class ParsedStyles
definitely made it easier to read the render logic inside ForageVaultWrapper
- good idea!
Curious why we put ParsedStyles
inside of VaultWrapper
instead of keeping it local to ForageVaultWrapper
? From what I can tell, this ParsedStyles
does not seem to be used by BTVaultWrapper
or VGSVaultWrapper
and wanted to better understand.
At any rate, where ParsedStyles
and it's related logic lives should not hold up merging in this me PR as it's internal code that we can revisit at any point
@dleis612 - really thoughtful concern you bring up here! You're right that we did some special handling in the past. I suspect that this will not be an issue in our case here because we're using a 👆 is just my best guess. In the worst case if we notice a similar problem, I think we can address it then. Lmk whether this is a productive response to your question though |
What
Add a 3rd
VaultWrapper
called theForageVaultWrapper
that will be used to accept PINs and interface with the Forage vault.Why
More information can be found in the ticket.
Demo
ForageVaultWrapper
VGSVaultWrapper
BTVaultWrapper