Skip to content

[NMA-1111] (Coinbase UI) Payment method picker + Enter Amount - #848

Merged
HashEngineering merged 13 commits into
feature-coinbase-integrationfrom
feature-coinbase-ui-buy
Dec 27, 2021
Merged

HashEngineering merged 13 commits into
feature-coinbase-integrationfrom
feature-coinbase-ui-buy

Conversation

@Syn-McJ

@Syn-McJ Syn-McJ commented Dec 25, 2021

Copy link
Copy Markdown
Member

As a part of Coinbase integration, we need a way to pick a payment method out of all provided by Coinbase API and enter the amount to buy in Dash or a chosen fiat.

Issue being fixed or feature implemented

  • Implemented a payment method picker as a separate component that can be reused in other integration modules.
  • Implemented an enter amount + currency picker component that can be reused in other modules.
  • Added a way to inject the ExchangeRatesRepository with Hilt.

AmountView and EnterAmountFragment borrow from the old EnterAmountFragment in the wallet, but I've tried to simplify it since the old one has a lot of repeating code and nested checks that are unnecessary. It's likely that I've missed some things that were considered in the old implementation, in which case we have time to ride the new one out in Coinbase and other modules and fix the bugs if there are any.

WalletDataProvider could be provided and injected with Hilt for fetching the exchange rates, but at this point, I figured we might as well inject ExchangeRatesRepository directly. The ExchangeRatesRepository doesn't need to be moved to the common module, only an interface is needed and the implementation can be provided with Hilt out of the wallet.

ExchangeRate did need to be moved to the common however, at which point I decided to convert it to Kotlin for a better null-safety. The database schema wasn't changed, so this will not affect users in any way.

Related PR's and Dependencies

Screenshots / Videos

How Has This Been Tested?

  • QA (Mobile Team)

Checklist:

  • I have performed a self-review of my own code and added comments where necessary
  • I have added or updated relevant unit/integration/functional/e2e tests

@Syn-McJ Syn-McJ self-assigned this Dec 25, 2021
return ExchangeRate(parcel)
}

data class ExchangeRate(

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old ExchangeRate class is renamed to ExchangeRateData and marked as deprecated since it's just a wrapper there is no need for it anymore.

private fun init(attributeSet: AttributeSet, defStyleAttr: Int, defStyleRes: Int) {
context.withStyledAttributes(attributeSet, R.styleable.NumericKeyboardView, defStyleAttr, defStyleRes) {
isFunctionEnabled = getBoolean(R.styleable.NumericKeyboardView_nk_functionEnabled, isFunctionEnabled)
isDecSeparatorEnabled = getBoolean(R.styleable.NumericKeyboardView_nk_decSeparatorEnabled, isDecSeparatorEnabled)

@Syn-McJ Syn-McJ Dec 25, 2021 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured it might be convenient to set isFunctionEnabled and isDecSeparatorEnabled from the layout

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/white" android:state_selected="true"/>
<item android:color="@color/steel_gray_250" android:state_selected="false"/>
</selector> No newline at end of file

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This diff doesn't make sense, rounded_ripple_transparent was deleted since rounded_ripple_background can do the same thing.

android:angle="0"
android:startColor="#FF3199DF"
android:endColor="#FF006CBD" />
</shape>

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vector gradient caused crash on API 23

android:id="@+id/connected"
style="@style/Overline"
android:textSize="10sp"
android:textColor="@color/gray_900"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The style already has the correct settings for text size and color.

</style>

<style name="TertiaryButtonTheme.Large.Red">
<item name="titleTextColor">@color/red_300</item>

@Syn-McJ Syn-McJ Dec 25, 2021 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes might cause some merge conflicts with explore-dash. I'll resolve them after one of the branches is merged with the master.

private val exchangeRatesProvider: ExchangeRatesProvider,
val config: Configuration
) : AndroidViewModel(application) {
) : ViewModel() {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't actually need a viewmodel with application. Context can be injected with Hilt if needed.

}
}

override fun currencyCodes(): LiveData<List<String>> {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currencyCodes() method wasn't used. If needed, it's better to re-add as Flow<List<String>>

dismissOffsetDialogs(supportFragmentManager)
}

private fun dismissOffsetDialogs(fragmentManager: FragmentManager) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is another problem with dismissing dialogs currently - if the user unlocked the app and then opened a dialog, activatingLockScreen can be triggered after initialization, which will lead to that dialog being dismissed immediately.

I have added an alternative method for the OffsetDialogFragment exclusively to avoid side effects, but we should consider dismissing all dialogs this way.

Comment thread .gitignore Outdated
output-metadata.json
service.properties No newline at end of file
service.properties
wallet/schemas/*/*.json No newline at end of file

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we don't need these files in our repo?

I thought these files were needed for backward compatibility with older database versions.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These files are actually generated on build. We don't need to keep them, and in some other branches, they were already excluded in .gitignore.

Right now our database is actually performing a destructive migration on every database version increment. That means everything is erased and re-created again. For keeping data when updating the database version, we need to write migrations.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-added since we still might need them for testing migrations.

@HashEngineering HashEngineering left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have questions regarding the room schema .json files

@HashEngineering
HashEngineering self-requested a review December 27, 2021 18:02

@HashEngineering HashEngineering left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved since my concerns were addressed.

@HashEngineering
HashEngineering merged commit 16e1f36 into feature-coinbase-integration Dec 27, 2021
@Syn-McJ
Syn-McJ deleted the feature-coinbase-ui-buy branch December 28, 2021 06:54
@Syn-McJ Syn-McJ mentioned this pull request Jan 23, 2022
1 of 3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants