From 39ca1e5eb1d8820aee0f16682643ca0006d73a09 Mon Sep 17 00:00:00 2001 From: 0ceanSlim <89587889+0ceanSlim@users.noreply.github.com> Date: Sun, 30 Jul 2023 11:30:38 -0400 Subject: [PATCH] logo showing! --- app/src/main/assets/index.html | 7 +++-- app/src/main/assets/{images => }/logo.png | Bin app/src/main/assets/script.js | 18 ++++++++++-- app/src/main/assets/style.css | 27 +++++++++++++++++- .../com/example/satsmonitor/MainActivity.kt | 3 ++ 5 files changed, 50 insertions(+), 5 deletions(-) rename app/src/main/assets/{images => }/logo.png (100%) diff --git a/app/src/main/assets/index.html b/app/src/main/assets/index.html index 5781fde..1065388 100644 --- a/app/src/main/assets/index.html +++ b/app/src/main/assets/index.html @@ -6,9 +6,12 @@ -
-

Bitcoin Price Tracker

+
+
+
diff --git a/app/src/main/assets/images/logo.png b/app/src/main/assets/logo.png similarity index 100% rename from app/src/main/assets/images/logo.png rename to app/src/main/assets/logo.png diff --git a/app/src/main/assets/script.js b/app/src/main/assets/script.js index b2cb2c0..58ca5c2 100644 --- a/app/src/main/assets/script.js +++ b/app/src/main/assets/script.js @@ -5,6 +5,20 @@ fetch('https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=u const bitcoinPrice = data['bitcoin']['usd']; // Update the Bitcoin price on the website const bitcoinPriceElement = document.getElementById('bitcoin-price'); - bitcoinPriceElement.textContent = '1 BTC = $' + bitcoinPrice.toFixed(2); // Display the Bitcoin price + + // Format the Bitcoin price with a comma after every three digits and no decimals + const formattedPrice = '$' + bitcoinPrice.toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: 0 }); + + bitcoinPriceElement.textContent = formattedPrice; // Display the formatted Bitcoin price + + // Calculate dollars to sats + const dollarsToSatsElement = document.getElementById('dollars-to-sats'); + const satsConversionFactor = 100000000; // 1 bitcoin = 100 million sats + + // Calculate how many sats you can get for 1 dollar based on the fetched Bitcoin price + const dollars = 1; + const sats = (1 / bitcoinPrice) * satsConversionFactor; + + dollarsToSatsElement.textContent = `$1.00 = ${sats.toFixed(0)} sats`; // Display the result }) - .catch(error => console.error(error)); + .catch(error => console.error(error)); \ No newline at end of file diff --git a/app/src/main/assets/style.css b/app/src/main/assets/style.css index 0d95482..6ba98d0 100644 --- a/app/src/main/assets/style.css +++ b/app/src/main/assets/style.css @@ -11,7 +11,7 @@ body { text-align: center; } -.bitcointodollars { +.container { width: auto; margin-left: 20px; margin-right: 20px; @@ -28,6 +28,31 @@ h1 { } #bitcoin-price { + display: flex; + align-items: center; + justify-content: center; + font-size: 24px; + font-weight: bold; + text-align: center; + margin: 10px; +} + +.bitcoin-logo { + height: 28px; + /* Adjust this to match the font size of the Bitcoin price */ + width: 28px; + margin-right: 5px; + /* Add some space between the logo and the price */ +} + +.bitcoin-logo img { + height: 36px; + /* Adjust this to match the font size of the Bitcoin price */ + width: 36px; + /* Add some space between the logo and the price */ +} + +#dollars-to-sats { font-size: 24px; font-weight: bold; text-align: center; diff --git a/app/src/main/java/com/example/satsmonitor/MainActivity.kt b/app/src/main/java/com/example/satsmonitor/MainActivity.kt index 040ca3f..a1d5867 100644 --- a/app/src/main/java/com/example/satsmonitor/MainActivity.kt +++ b/app/src/main/java/com/example/satsmonitor/MainActivity.kt @@ -65,6 +65,9 @@ val finalHtmlContent = """ """.trimIndent() +// Define the base URL for resolving relative paths (e.g., image source) + val baseUrl = "file:///android_asset/" + webView.loadDataWithBaseURL(null, finalHtmlContent, "text/html", "UTF-8", null) } } \ No newline at end of file