Skip to content

Commit

Permalink
Minor bug fix.
Browse files Browse the repository at this point in the history
Refreshed coin list.
Removed CoinBene.
  • Loading branch information
hwki committed Dec 16, 2021
1 parent a25012e commit 3f74248
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 65 deletions.
1 change: 0 additions & 1 deletion .idea/inspectionProfiles/Project_Default.xml

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

22 changes: 1 addition & 21 deletions SimpleBitcoinWidget.iml
Original file line number Diff line number Diff line change
@@ -1,22 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="SimpleBitcoinWidget" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="java-gradle" name="Java-Gradle">
<configuration>
<option name="BUILDABLE" value="false" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager">
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
<excludeFolder url="file://$MODULE_DIR$/.idea/libraries" />
<excludeFolder url="file://$MODULE_DIR$/.idea/modules" />
<excludeFolder url="file://$MODULE_DIR$/build" />
<excludeFolder url="file://$MODULE_DIR$/release" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
<module external.linked.project.id="SimpleBitcoinWidget" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4" />
14 changes: 7 additions & 7 deletions bitcoin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
applicationId "com.brentpanther.bitcoinwidget"
minSdk 23
targetSdk 31
versionCode 287
versionName "8.1.7"
versionCode 289
versionName "8.1.9"

javaCompileOptions {
annotationProcessorOptions {
Expand Down Expand Up @@ -66,23 +66,23 @@ dependencies {
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2'
implementation "androidx.recyclerview:recyclerview:1.2.1"
implementation "androidx.core:core-ktx:1.7.0"
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
implementation 'androidx.preference:preference-ktx:1.1.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.0'
implementation 'androidx.fragment:fragment-ktx:1.3.6'
implementation 'androidx.fragment:fragment-ktx:1.4.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
implementation 'com.squareup.okhttp3:okhttp:4.9.1'
implementation 'com.google.code.gson:gson:2.8.8'
implementation 'com.google.code.gson:gson:2.8.9'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.work:work-runtime-ktx:2.7.0'
implementation 'androidx.work:work-runtime-ktx:2.7.1'
testImplementation 'junit:junit:4.13.2'
testImplementation 'com.jayway.jsonpath:json-path:2.6.0'

def room_version = "2.3.0"
def room_version = "2.4.0-rc01"

implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class CustomExchangeData(coinEntry: CoinEntry, json: InputStream) : ExchangeData

init {
val exchanges = obj?.exchanges?.first { it.name == Exchange.COINGECKO.name }
val currencies = exchanges?.coins?.first()?.currencies?.plus(exchanges.all) ?: listOf()
val currencies = exchanges?.coins?.first()?.currencies?.plus(exchanges.all ?: listOf()) ?: listOf()
currencyExchange = currencies
.associateWith { mutableListOf(Exchange.COINGECKO.name) }
.toMutableMap()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,19 +262,6 @@ enum class Exchange(val exchangeName: String, shortName: String? = null) {
return getJsonObject(url).get("price").asString
}
},
COINBENE("CoinBene") {
override fun getValue(coin: String, currency: String): String? {
val url = "https://openapi-exchange.coinbene.com/api/spot/market/summary"
val array = getJsonArray(url)
for (jsonElement in array) {
val obj = jsonElement as JsonObject
if (obj.get("trading_pairs").asString == "${coin}_$currency") {
return obj.get("last_price").asString
}
}
return null
}
},
COINDESK("Coindesk") {

override fun getValue(coin: String, currency: String): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ open class ExchangeData(val coinEntry: CoinEntry, json: InputStream) {
var currencyOverrides: Map<String, String>? = null
@SerializedName("c_ovr")
var coinOverrides: Map<String, String>? = null
var all: List<String> = listOf()
var all: List<String>? = null

fun loadExchange(coin: String): List<String> {
return coins.firstOrNull { it.name == coin}?.currencies?.plus(all) ?: listOf()
return coins.firstOrNull { it.name == coin}?.currencies?.plus(all ?: listOf()) ?: listOf()
}
}

Expand Down
2 changes: 1 addition & 1 deletion bitcoin/src/main/res/raw/cryptowidgetcoins_v2.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bitcoin/src/main/res/raw/othercoins.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bitcoin/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
<item>ISO</item>
<item>NONE</item>
</string-array>
<string name="json_last_modified" translatable="false">Sun, 14 Nov 2021 18:25:48 GMT</string>
<string name="json_last_modified" translatable="false">Thu, 16 Dec 2021 23:01:06 GMT</string>
<string name="json_url" translatable="false">https://www.brentpanther.com/cryptowidgetcoins_v2.json</string>

<string name="settings_updating_data">Updating coin data…</string>
Expand Down
1 change: 1 addition & 0 deletions bitcoin/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<item name="appWidgetTextStyle">@style/SolidWidgetText.Transparent</item>
<item name="appWidgetSecondaryTextStyle">@style/SolidWidgetText.Transparent</item>
<item name="appWidgetHorizontalPadding">0dp</item>
<item name="appWidgetLoadingColor">#fff</item>
</style>

<style name="Theme.MyApp.WidgetContainer.Dark">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class GeneratePartiallySupportedCoins {
private val dataUrl = "https://api.coingecko.com/api/v3/coins/"
private val dataUrl2 = "?localization=false&tickers=false&market_data=false&community_data=false&developer_data=false"
private val scoreLimit = 3
private val exceptions = setOf("refugees-token")

@Test
fun generate() {
Expand All @@ -53,7 +54,7 @@ class GeneratePartiallySupportedCoins {
continue
}
getCoin(obj)?.let {
if (it.second) {
if (it.second || exceptions.contains(it.first.id)) {
existing[it.first.id] = it.first
}
} ?: failed.add(obj)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.jayway.jsonpath.JsonPath
import okhttp3.OkHttpClient
import okhttp3.Request
import org.junit.Test
import java.util.*

class GenerateSupportedCoinsJson {

Expand All @@ -17,19 +18,19 @@ class GenerateSupportedCoinsJson {
"XDG" to "DOGE", "MIOTA" to "IOTA", "STR" to "XLM", "DSH" to "DASH", "IOT" to "IOTA",
"BAB" to "BCH", "ALG" to "ALGO", "ATO" to "ATOM", "QTM" to "QTUM", "DRK" to "DASH", "NEM" to "XEM",
"XZC" to "FIRO")
private val allCurrencyOverrides = mapOf("USDT" to "USD", "TUSD" to "USD", "TL" to "TRY", "NIS" to "ILS").plus(allCoinOverrides)
private val allCurrencyOverrides = mapOf("USDT" to "USD", "TUSD" to "USD", "USDC" to "USD", "TL" to "TRY", "NIS" to "ILS").plus(allCoinOverrides)

@Test
fun generate() {
allCurrencies = (json.read("$..ccy.*") as List<String>).toSortedSet()

allCurrencies = Currency.getAvailableCurrencies().asSequence().map { it.currencyCode }.plus(allCoins).plus(allCoinOverrides.keys).toSet()
System.err.println("all currencies: $allCurrencies")
val exchanges =
listOf(this::abucoins, this::ascendex, this::bibox, this::bigone, this::binance, this::binance_us, this::bit2c,
this::bitbank, this::bitbay, this::bitcambio, this::bitclude,
this::bitcoinde, this::bitfinex, this::bitflyer, this::bithumb, this::bithumbpro, this::bitmex,
this::bitpanda, this::bitpay, this::bitso, this::bitstamp, this::bittrex, this::bitrue, this::bitvavo, this::bleutrade,
this::btcbox, this::btcmarkets, this::btcturk, this::bybit, this::cexio,
this::chilebit, this::coinbase, this::coinbasepro, this::coinbene, this::coindesk, this::coingecko,
this::chilebit, this::coinbase, this::coinbasepro, this::coindesk, this::coingecko,
this::coinjar, this::coinmate, this::coinone, this::coinsbit, this::coinsph, this::cointree,
this::cryptocom, this::deversifi, this::exmo, this::ftx, this::ftx_us, this::foxbit, this::gateio, this::gemini, this::hitbtc,
this::huobi, this::independent_reserve, this::indodax, this::itbit, this::korbit, this::kraken, this::kucoin,
Expand All @@ -48,7 +49,7 @@ class GenerateSupportedCoinsJson {
val currencyOverrides = mutableMapOf<String, String>()
val existing = getExistingPairs(name.name)
var pairs = extractOverrides(normalize(exchange.invoke()), coinOverrides, currencyOverrides)
val removed = existing.minus(pairs).sorted()
val removed = existing.minus(pairs.toSet()).sorted()
if (removed.isNotEmpty()) {
System.err.println("$name: Removed: ${removed.joinToString()}")
}
Expand Down Expand Up @@ -88,7 +89,7 @@ class GenerateSupportedCoinsJson {
continue
}
// remove any currencies in all that are not in this coin
allCurrencies.removeAll { !currencies.contains(it) || coinMap["name"] as String == it }
allCurrencies.removeAll { !currencies.contains(it) }
}
if (allCurrencies != null) {
exchangeMap["all"] = allCurrencies
Expand Down Expand Up @@ -375,10 +376,6 @@ class GenerateSupportedCoinsJson {
return parse("https://api.pro.coinbase.com/products", "$[*].id")
}

private fun coinbene() : List<String> {
return parse("https://openapi-exchange.coinbene.com/api/spot/market/summary", "$[*].trading_pairs")
}

private fun coindesk(): List<String> {
val currencies = parse("https://api.coindesk.com/v1/bpi/supported-currencies.json", "$[*].currency")
return currencies.map { "BTC_$it" }
Expand Down Expand Up @@ -502,10 +499,6 @@ class GenerateSupportedCoinsJson {
return parse("https://api.liquid.com/products", "$[?(@.disabled==false)].currency_pair_code")
}

private fun livecoin(): List<String> {
return parse("https://api.livecoin.net/exchange/ticker", "$[*].symbol")
}

private fun luno(): List<String> {
return parse("https://api.luno.com/api/1/tickers", "$.tickers[*].pair")
}
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.5.31'
ext.kotlin_version = '1.6.10'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.3'
classpath 'com.android.tools.build:gradle:7.0.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand Down
3 changes: 3 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/289.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Minor bug fix.
Refreshed coin list.
Removed CoinBene.

0 comments on commit 3f74248

Please sign in to comment.