Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/dashevo/dash-wallet into …
Browse files Browse the repository at this point in the history
…dashpay
  • Loading branch information
HashEngineering committed May 31, 2024
2 parents 441ad25 + 1f48159 commit a84fd67
Show file tree
Hide file tree
Showing 142 changed files with 4,356 additions and 771 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ This project contains several sub-projects:
The Android app itself. This is probably what you're searching for. [wallet README](wallet/README.md)
* __common__:
Contains common components used by integrations.
* __integrations/uphold__
Contains the uphold integration
* __features__:
Contains features such as Explore Dash
* __market__:
App description and promo material for the Google Play app store.
* __integration-android__:
A tiny library for integrating Dash payments into your own Android app
(e.g. donations, in-app purchases).
* __integrations__
Contains the various integrations: Crowdnode, Coinbase, Uphold,
* __sample-integration-android__:
A minimal example app to demonstrate integration of digital payments into
your Android app.
Expand Down
14 changes: 9 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
buildscript {
ext {
kotlin_version = '1.8.22'
kotlin_version = '1.9.23'
coroutinesVersion = '1.6.4'
ok_http_version = '4.9.1'
dashjVersion = '20.0.2-CJ-SNAPSHOT'
hiltVersion = '2.45'
dashjVersion = '20.0.5-CJ-SNAPSHOT'
hiltVersion = '2.51'
hiltCompilerVersion = '1.2.0'
hiltWorkVersion = '1.0.0'
workRuntimeVersion='2.7.1'
firebaseVersion = '32.1.1'
roomVersion = '2.4.3'
roomVersion = '2.5.2'
jetpackVersion = '1.8.0'
appCompatVersion = '1.4.2'

// Architecture
lifecycleVersion = '2.5.1'
navigationVersion = '2.6.0'
datastoreVersion = "1.0.0"
hiltVersion = '2.45'
hiltWorkVersion = '1.0.0'
serializationVersion = '1.0.1'
preferenceVersion = '1.2.0'
Expand Down Expand Up @@ -62,6 +62,10 @@ buildscript {
}
}

plugins {
id 'com.google.devtools.ksp' version '1.9.23-1.0.19' apply false
}

allprojects {
repositories {
google()
Expand Down
19 changes: 14 additions & 5 deletions common/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.google.devtools.ksp'
apply plugin: 'kotlin-parcelize'
apply plugin: 'dagger.hilt.android.plugin'

android {

defaultConfig {
compileSdk 33
minSdkVersion 23
minSdkVersion 24
targetSdkVersion 33
vectorDrawables.useSupportLibrary = true

Expand Down Expand Up @@ -36,6 +36,10 @@ android {

buildFeatures {
viewBinding true
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.11"
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions {
Expand Down Expand Up @@ -76,9 +80,14 @@ dependencies {
implementation "androidx.room:room-ktx:$roomVersion"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:$serializationVersion"

// UI
implementation(platform("androidx.compose:compose-bom:2023.03.00"))
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.ui:ui-tooling-preview")
implementation("androidx.compose.material3:material3")
debugImplementation 'androidx.compose.ui:ui-tooling:1.0.0'

implementation "com.github.bumptech.glide:glide:$glideVersion"
kapt "com.github.bumptech.glide:compiler:$glideVersion"
ksp "com.github.bumptech.glide:compiler:$glideVersion"
implementation "io.coil-kt:coil:$coilVersion"
implementation "com.google.android.material:material:$materialVersion"
implementation "androidx.browser:browser:$browserVersion"
Expand All @@ -90,7 +99,7 @@ dependencies {

// DI
implementation "com.google.dagger:hilt-android:$hiltVersion"
kapt "com.google.dagger:hilt-compiler:$hiltVersion"
ksp "com.google.dagger:hilt-compiler:$hiltVersion"
implementation 'javax.inject:javax.inject:1'

testImplementation "junit:junit:$junitVersion"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.dash.wallet.common.data

import android.content.Context
import androidx.datastore.preferences.core.booleanPreferencesKey
import androidx.datastore.preferences.core.longPreferencesKey
import org.dash.wallet.common.WalletDataProvider
import javax.inject.Inject

class ExchangeRatesConfig
@Inject
constructor(
context: Context,
walletDataProvider: WalletDataProvider
) : BaseConfig(
context,
PREFERENCES_NAME,
walletDataProvider
) {
companion object {
private const val PREFERENCES_NAME = "exchange_rates_config"
val EXCHANGE_RATES_RETRIEVAL_TIME = longPreferencesKey("exchange_rates_retrieval_time")
val EXCHANGE_RATES_RETRIEVAL_FAILURE = booleanPreferencesKey("exchange_rates_retrieval_error")
val EXCHANGE_RATES_PREVIOUS_RETRIEVAL_TIME = longPreferencesKey("exchange_rates_previous_retrieval_time")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,25 @@ open class ExchangeRate : Parcelable {
@PrimaryKey
var currencyCode: String
var rate: String? = null
@Ignore
var retrievalTime: Long = -1L

@Ignore
private var currencyName: String? = null

@Ignore
private var currency: Currency? = null

constructor(currencyCode: String, rate: String?, retrievalTime: Long) {
this.currencyCode = currencyCode
this.rate = rate
this.retrievalTime = retrievalTime
}

constructor(currencyCode: String, rate: String?) {
this.currencyCode = currencyCode
this.rate = rate
this.retrievalTime = -1
}

protected constructor(input: Parcel) {
Expand Down Expand Up @@ -79,13 +88,16 @@ open class ExchangeRate : Parcelable {
// If the currency is not a valid ISO 4217 code, then set the
// currency name to be equal to the currency code
// exchanges often have "invalid" currency codes like USDT and CNH
currencyName = if (currencyCode.length == 3) {
try {
getCurrency().displayName
} catch (x: IllegalArgumentException) {
currencyName =
if (currencyCode.length == 3) {
try {
getCurrency().displayName
} catch (x: IllegalArgumentException) {
currencyCode
}
} else {
currencyCode
}
} else currencyCode
if (currencyCode.equals(currencyName!!, ignoreCase = true)) {
currencyName = CurrencyInfo.getOtherCurrencyName(currencyCode, context)
}
Expand All @@ -97,7 +109,10 @@ open class ExchangeRate : Parcelable {
return 0
}

override fun writeToParcel(dest: Parcel, flags: Int) {
override fun writeToParcel(
dest: Parcel,
flags: Int
) {
dest.writeString(currencyCode)
dest.writeString(rate)
dest.writeString(currencyName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ interface ExchangeRatesProvider {
fun observeExchangeRate(currencyCode: String): Flow<ExchangeRate?>
suspend fun getExchangeRate(currencyCode: String): ExchangeRate?
suspend fun cleanupObsoleteCurrencies()
fun observeStaleRates(currencyCode: String): Flow<RateRetrievalState>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright 2024 Dash Core Group.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package org.dash.wallet.common.services

data class RateRetrievalState(
val lastAttemptFailed: Boolean = false,
val staleRates: Boolean,
val volatile: Boolean
) {
val isStale = lastAttemptFailed || staleRates || volatile
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.dash.wallet.common.ui.components

import android.content.Context
import android.util.AttributeSet
import android.widget.FrameLayout
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.ComposeView

class ComposeHostFrameLayout
@JvmOverloads
constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : FrameLayout(context, attrs, defStyleAttr) {
private var composeView: ComposeView? = null

fun setContent(content: @Composable () -> Unit) {
if (composeView == null) {
composeView = ComposeView(context)
addView(composeView)
}
composeView?.setContent(content)
}

override fun removeAllViews() {
composeView = null
super.removeAllViews()
}
}
Loading

0 comments on commit a84fd67

Please sign in to comment.