Skip to content

Commit

Permalink
Update to API 34.
Browse files Browse the repository at this point in the history
Update gradle.
Update to Kotlin 1.9.
Update dependencies.
Switch from Gson to kotlinx serialization.
Remove Bitcambio, Wyre, Zbg.
Fixes for Bybit, Coinsbit, Poloniex
Added Hashkey.
Add auto search for coin selection screen.
Improve coin/currency pair generation code.
  • Loading branch information
hwki committed Sep 2, 2023
1 parent 45094f6 commit a87dd1c
Show file tree
Hide file tree
Showing 41 changed files with 950 additions and 658 deletions.
2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 27 additions & 39 deletions bitcoin/build.gradle
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-parcelize'
id 'kotlin-kapt'
id 'com.google.devtools.ksp'
id 'org.jetbrains.kotlin.android'
id 'org.jetbrains.kotlin.plugin.serialization' version '1.9.0'
}

android {
compileSdk 33
compileSdk 34

defaultConfig {
applicationId "com.brentpanther.bitcoinwidget"
minSdk 23
targetSdk 33
versionCode 318
versionName "8.3.8"
targetSdk 34
versionCode 319
versionName "8.4.0"

javaCompileOptions {
annotationProcessorOptions {
arguments += ["room.schemaLocation": "$projectDir/schemas".toString()]
}
}
}

buildFeatures {
Expand All @@ -37,20 +32,16 @@ android {
}
}

testOptions {
unitTests.returnDefaultValues = true
}

kotlinOptions {
jvmTarget = "11"
jvmTarget = "17"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

sourceSets.test.resources.srcDirs += ["src/main/res"]
flavorDimensions 'distribution'
flavorDimensions = ['distribution']
productFlavors {
playstore {
dimension 'distribution'
Expand All @@ -63,40 +54,37 @@ android {
composeOptions {
kotlinCompilerExtensionVersion compose_compiler_version
}
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
}

ksp {
arg "room.schemaLocation", "$projectDir/schemas"
}

dependencies {
implementation platform('androidx.compose:compose-bom:2023.04.00')
implementation platform('androidx.compose:compose-bom:2023.08.00')

implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4'
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
implementation 'com.google.code.gson:gson:2.10.1'
implementation 'com.google.android.material:material:1.8.0'
implementation 'androidx.preference:preference-ktx:1.2.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3'
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0"
implementation 'com.squareup.okhttp3:okhttp:4.11.0'
implementation 'androidx.preference:preference-ktx:1.2.1'
implementation 'androidx.work:work-runtime-ktx:2.8.1'
implementation 'androidx.activity:activity-compose:1.7.0'
implementation 'androidx.activity:activity-ktx:1.8.0-alpha07'
implementation 'androidx.activity:activity-compose:1.7.2'
implementation "androidx.compose.ui:ui"
implementation "androidx.compose.ui:ui-tooling-preview"
implementation 'androidx.compose.material:material'
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.6.1"
implementation 'androidx.navigation:navigation-compose:2.5.3'
implementation "io.coil-kt:coil-compose:2.3.0"
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.navigation:navigation-compose:2.7.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'io.coil-kt:coil-compose:2.4.0'
implementation 'androidx.core:core-ktx:1.10.1'
testImplementation 'junit:junit:4.13.2'
testImplementation 'com.jayway.jsonpath:json-path:2.8.0'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:"
debugImplementation "androidx.compose.ui:ui-tooling:"
debugImplementation "androidx.compose.ui:ui-test-manifest:"
debugImplementation "androidx.compose.ui:ui-tooling"

def room_version = "2.5.1"
def room_version = "2.5.2"

ksp "androidx.room:room-compiler:$room_version"
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
implementation "androidx.room:room-ktx:$room_version"
}
3 changes: 2 additions & 1 deletion bitcoin/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
android:networkSecurityConfig="@xml/network_security_config"
android:supportsRtl="true"
android:theme="@style/Theme.MyApp"
android:enableOnBackInvokedCallback="true"
tools:ignore="DataExtractionRules,GoogleAppIndexingWarning"
tools:targetApi="q">
tools:targetApi="tiramisu">
<activity
android:name=".ui.MainActivity"
android:exported="true"
Expand Down
154 changes: 146 additions & 8 deletions bitcoin/src/main/java/com/brentpanther/bitcoinwidget/Coin.kt
Original file line number Diff line number Diff line change
@@ -1,15 +1,154 @@
package com.brentpanther.bitcoinwidget

import android.os.Build
import android.os.Parcelable
import com.brentpanther.bitcoinwidget.R.drawable.*
import com.brentpanther.bitcoinwidget.R.drawable.ic_1inch
import com.brentpanther.bitcoinwidget.R.drawable.ic_aave
import com.brentpanther.bitcoinwidget.R.drawable.ic_ada
import com.brentpanther.bitcoinwidget.R.drawable.ic_algo
import com.brentpanther.bitcoinwidget.R.drawable.ic_algo_white
import com.brentpanther.bitcoinwidget.R.drawable.ic_ape
import com.brentpanther.bitcoinwidget.R.drawable.ic_arrr
import com.brentpanther.bitcoinwidget.R.drawable.ic_atom
import com.brentpanther.bitcoinwidget.R.drawable.ic_ava
import com.brentpanther.bitcoinwidget.R.drawable.ic_avax
import com.brentpanther.bitcoinwidget.R.drawable.ic_avax_dark
import com.brentpanther.bitcoinwidget.R.drawable.ic_axs
import com.brentpanther.bitcoinwidget.R.drawable.ic_bal
import com.brentpanther.bitcoinwidget.R.drawable.ic_band_color
import com.brentpanther.bitcoinwidget.R.drawable.ic_bat
import com.brentpanther.bitcoinwidget.R.drawable.ic_bcd
import com.brentpanther.bitcoinwidget.R.drawable.ic_bcd_white
import com.brentpanther.bitcoinwidget.R.drawable.ic_bch
import com.brentpanther.bitcoinwidget.R.drawable.ic_bch_dark
import com.brentpanther.bitcoinwidget.R.drawable.ic_best
import com.brentpanther.bitcoinwidget.R.drawable.ic_bnb
import com.brentpanther.bitcoinwidget.R.drawable.ic_bnt
import com.brentpanther.bitcoinwidget.R.drawable.ic_bsv
import com.brentpanther.bitcoinwidget.R.drawable.ic_bsv_dark
import com.brentpanther.bitcoinwidget.R.drawable.ic_btc
import com.brentpanther.bitcoinwidget.R.drawable.ic_btc_dark
import com.brentpanther.bitcoinwidget.R.drawable.ic_btg
import com.brentpanther.bitcoinwidget.R.drawable.ic_btg_dark
import com.brentpanther.bitcoinwidget.R.drawable.ic_btm
import com.brentpanther.bitcoinwidget.R.drawable.ic_btm_gray
import com.brentpanther.bitcoinwidget.R.drawable.ic_btt
import com.brentpanther.bitcoinwidget.R.drawable.ic_cel
import com.brentpanther.bitcoinwidget.R.drawable.ic_chz
import com.brentpanther.bitcoinwidget.R.drawable.ic_comp_black
import com.brentpanther.bitcoinwidget.R.drawable.ic_comp_white
import com.brentpanther.bitcoinwidget.R.drawable.ic_cro
import com.brentpanther.bitcoinwidget.R.drawable.ic_cro_white
import com.brentpanther.bitcoinwidget.R.drawable.ic_crv
import com.brentpanther.bitcoinwidget.R.drawable.ic_cube_black
import com.brentpanther.bitcoinwidget.R.drawable.ic_cube_white
import com.brentpanther.bitcoinwidget.R.drawable.ic_dai_color
import com.brentpanther.bitcoinwidget.R.drawable.ic_dash
import com.brentpanther.bitcoinwidget.R.drawable.ic_dash_dark
import com.brentpanther.bitcoinwidget.R.drawable.ic_dcr
import com.brentpanther.bitcoinwidget.R.drawable.ic_doge
import com.brentpanther.bitcoinwidget.R.drawable.ic_dot_black
import com.brentpanther.bitcoinwidget.R.drawable.ic_dot_white
import com.brentpanther.bitcoinwidget.R.drawable.ic_egld_dark
import com.brentpanther.bitcoinwidget.R.drawable.ic_egld_white
import com.brentpanther.bitcoinwidget.R.drawable.ic_enj
import com.brentpanther.bitcoinwidget.R.drawable.ic_eos_black
import com.brentpanther.bitcoinwidget.R.drawable.ic_eos_white
import com.brentpanther.bitcoinwidget.R.drawable.ic_etc
import com.brentpanther.bitcoinwidget.R.drawable.ic_eth
import com.brentpanther.bitcoinwidget.R.drawable.ic_fil
import com.brentpanther.bitcoinwidget.R.drawable.ic_firo
import com.brentpanther.bitcoinwidget.R.drawable.ic_firo_dark
import com.brentpanther.bitcoinwidget.R.drawable.ic_ftm
import com.brentpanther.bitcoinwidget.R.drawable.ic_ftt
import com.brentpanther.bitcoinwidget.R.drawable.ic_gala
import com.brentpanther.bitcoinwidget.R.drawable.ic_gala_white
import com.brentpanther.bitcoinwidget.R.drawable.ic_gno_color
import com.brentpanther.bitcoinwidget.R.drawable.ic_gnt_blue
import com.brentpanther.bitcoinwidget.R.drawable.ic_grin_color_black
import com.brentpanther.bitcoinwidget.R.drawable.ic_grt
import com.brentpanther.bitcoinwidget.R.drawable.ic_hbar
import com.brentpanther.bitcoinwidget.R.drawable.ic_hbar_white
import com.brentpanther.bitcoinwidget.R.drawable.ic_hns
import com.brentpanther.bitcoinwidget.R.drawable.ic_hns_dark
import com.brentpanther.bitcoinwidget.R.drawable.ic_ht
import com.brentpanther.bitcoinwidget.R.drawable.ic_icx
import com.brentpanther.bitcoinwidget.R.drawable.ic_iota
import com.brentpanther.bitcoinwidget.R.drawable.ic_iota_white
import com.brentpanther.bitcoinwidget.R.drawable.ic_kava
import com.brentpanther.bitcoinwidget.R.drawable.ic_kmd
import com.brentpanther.bitcoinwidget.R.drawable.ic_knc_color
import com.brentpanther.bitcoinwidget.R.drawable.ic_ksm_black
import com.brentpanther.bitcoinwidget.R.drawable.ic_ksm_white
import com.brentpanther.bitcoinwidget.R.drawable.ic_leo
import com.brentpanther.bitcoinwidget.R.drawable.ic_link
import com.brentpanther.bitcoinwidget.R.drawable.ic_lrc
import com.brentpanther.bitcoinwidget.R.drawable.ic_lsk
import com.brentpanther.bitcoinwidget.R.drawable.ic_ltc
import com.brentpanther.bitcoinwidget.R.drawable.ic_lto
import com.brentpanther.bitcoinwidget.R.drawable.ic_luna
import com.brentpanther.bitcoinwidget.R.drawable.ic_lunc
import com.brentpanther.bitcoinwidget.R.drawable.ic_mana
import com.brentpanther.bitcoinwidget.R.drawable.ic_matic
import com.brentpanther.bitcoinwidget.R.drawable.ic_mco
import com.brentpanther.bitcoinwidget.R.drawable.ic_mco_white
import com.brentpanther.bitcoinwidget.R.drawable.ic_mkr
import com.brentpanther.bitcoinwidget.R.drawable.ic_mln
import com.brentpanther.bitcoinwidget.R.drawable.ic_nano
import com.brentpanther.bitcoinwidget.R.drawable.ic_near_black
import com.brentpanther.bitcoinwidget.R.drawable.ic_near_white
import com.brentpanther.bitcoinwidget.R.drawable.ic_neo
import com.brentpanther.bitcoinwidget.R.drawable.ic_nrg
import com.brentpanther.bitcoinwidget.R.drawable.ic_okb
import com.brentpanther.bitcoinwidget.R.drawable.ic_omg
import com.brentpanther.bitcoinwidget.R.drawable.ic_ont
import com.brentpanther.bitcoinwidget.R.drawable.ic_pax
import com.brentpanther.bitcoinwidget.R.drawable.ic_paxg_color
import com.brentpanther.bitcoinwidget.R.drawable.ic_placeholder
import com.brentpanther.bitcoinwidget.R.drawable.ic_powr_color
import com.brentpanther.bitcoinwidget.R.drawable.ic_ppc
import com.brentpanther.bitcoinwidget.R.drawable.ic_qtum
import com.brentpanther.bitcoinwidget.R.drawable.ic_rdd
import com.brentpanther.bitcoinwidget.R.drawable.ic_ren
import com.brentpanther.bitcoinwidget.R.drawable.ic_rep
import com.brentpanther.bitcoinwidget.R.drawable.ic_rune
import com.brentpanther.bitcoinwidget.R.drawable.ic_rvn
import com.brentpanther.bitcoinwidget.R.drawable.ic_sand
import com.brentpanther.bitcoinwidget.R.drawable.ic_shib
import com.brentpanther.bitcoinwidget.R.drawable.ic_snx
import com.brentpanther.bitcoinwidget.R.drawable.ic_sol
import com.brentpanther.bitcoinwidget.R.drawable.ic_storj
import com.brentpanther.bitcoinwidget.R.drawable.ic_sushi
import com.brentpanther.bitcoinwidget.R.drawable.ic_theta
import com.brentpanther.bitcoinwidget.R.drawable.ic_trx
import com.brentpanther.bitcoinwidget.R.drawable.ic_uma
import com.brentpanther.bitcoinwidget.R.drawable.ic_uni
import com.brentpanther.bitcoinwidget.R.drawable.ic_vet
import com.brentpanther.bitcoinwidget.R.drawable.ic_vtc
import com.brentpanther.bitcoinwidget.R.drawable.ic_waves
import com.brentpanther.bitcoinwidget.R.drawable.ic_wbtc
import com.brentpanther.bitcoinwidget.R.drawable.ic_xaut_color
import com.brentpanther.bitcoinwidget.R.drawable.ic_xem
import com.brentpanther.bitcoinwidget.R.drawable.ic_xem_dark_gray
import com.brentpanther.bitcoinwidget.R.drawable.ic_xlm
import com.brentpanther.bitcoinwidget.R.drawable.ic_xlm_white
import com.brentpanther.bitcoinwidget.R.drawable.ic_xmr
import com.brentpanther.bitcoinwidget.R.drawable.ic_xmr_dark
import com.brentpanther.bitcoinwidget.R.drawable.ic_xrp_black
import com.brentpanther.bitcoinwidget.R.drawable.ic_xrp_white
import com.brentpanther.bitcoinwidget.R.drawable.ic_xtz
import com.brentpanther.bitcoinwidget.R.drawable.ic_xvg
import com.brentpanther.bitcoinwidget.R.drawable.ic_xym
import com.brentpanther.bitcoinwidget.R.drawable.ic_yfi
import com.brentpanther.bitcoinwidget.R.drawable.ic_zec
import com.brentpanther.bitcoinwidget.R.drawable.ic_zec_dark
import com.brentpanther.bitcoinwidget.R.drawable.ic_zil
import com.brentpanther.bitcoinwidget.R.drawable.ic_zrx_black
import com.brentpanther.bitcoinwidget.R.drawable.ic_zrx_white
import com.brentpanther.bitcoinwidget.Theme.SOLID
import com.brentpanther.bitcoinwidget.Theme.TRANSPARENT
import kotlinx.parcelize.Parcelize
import java.util.*
import java.util.SortedSet

@Parcelize
enum class Coin(val coinName: String, val coinGeckoId: String, private vararg val themes: IconTheme) : Parcelable {
enum class Coin(val coinName: String, val coinGeckoId: String, private vararg val themes: IconTheme) {

CUSTOM("Custom", "", IconTheme(SOLID, ic_placeholder)),
ONE_INCH("1inch", "1inch", IconTheme(SOLID, ic_1inch)),
Expand Down Expand Up @@ -172,5 +311,4 @@ enum class Coin(val coinName: String, val coinGeckoId: String, private vararg va

}

@Parcelize
class CoinUnit(val text: String, val amount: Double) : Parcelable
class CoinUnit(val text: String, val amount: Double)
8 changes: 2 additions & 6 deletions bitcoin/src/main/java/com/brentpanther/bitcoinwidget/Enums.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@ package com.brentpanther.bitcoinwidget

import android.content.Context
import android.content.res.Configuration
import android.os.Parcelable
import androidx.annotation.DrawableRes
import androidx.annotation.LayoutRes
import androidx.annotation.StringRes
import kotlinx.parcelize.Parcelize

@Parcelize
enum class Theme(@LayoutRes val lightPrice: Int, @LayoutRes val darkPrice: Int,
@LayoutRes val lightValue: Int, @LayoutRes val darkValue: Int) : Parcelable {
@LayoutRes val lightValue: Int, @LayoutRes val darkValue: Int) {

SOLID(R.layout.widget_price_solid_light, R.layout.widget_price_solid_dark,
R.layout.widget_value_solid_light, R.layout.widget_value_solid_dark),
Expand All @@ -29,9 +26,8 @@ enum class Theme(@LayoutRes val lightPrice: Int, @LayoutRes val darkPrice: Int,
}
}

@Parcelize
data class IconTheme(val theme: Theme, @DrawableRes val light: Int,
@DrawableRes val dark: Int = light) : Parcelable
@DrawableRes val dark: Int = light)

enum class NightMode {
LIGHT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import com.brentpanther.bitcoinwidget.db.Widget
import com.brentpanther.bitcoinwidget.exchange.CustomExchangeData
import com.brentpanther.bitcoinwidget.exchange.ExchangeData
import com.brentpanther.bitcoinwidget.exchange.ExchangeHelper
import com.google.gson.JsonParseException
import kotlinx.serialization.SerializationException
import okhttp3.ConnectionPool
import okhttp3.OkHttpClient
import okhttp3.Request
Expand All @@ -23,8 +23,8 @@ import java.util.concurrent.TimeUnit

object Repository {

internal const val LAST_MODIFIED = "last_modified"
const val CURRENCY_FILE_NAME = "coins.json"
private const val LAST_MODIFIED = "last_modified"
private const val CURRENCY_FILE_NAME = "coins.json"
private val TAG = Repository::class.java.simpleName

fun downloadJSON() {
Expand Down Expand Up @@ -98,11 +98,11 @@ object Repository {
} else {
val data = ExchangeData(widget.coin, getJson(context))
if (data.numberExchanges == 0) {
throw JsonParseException("No exchanges found.")
throw SerializationException("No exchanges found.")
}
data
}
} catch(e: JsonParseException) {
} catch(e: SerializationException) {
Log.e("SettingsViewModel", "Error parsing JSON file, falling back to original.", e)
context.deleteFile(CURRENCY_FILE_NAME)
PreferenceManager.getDefaultSharedPreferences(context).edit {
Expand Down
Loading

0 comments on commit a87dd1c

Please sign in to comment.