commit
541fe9bd2e
@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||||
<component name="GradleSettings">
|
<component name="GradleSettings">
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||||
|
21
app/assets/script.html
Normal file
21
app/assets/script.html
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
|
||||||
|
|
||||||
|
<div class="bitcointodollars">
|
||||||
|
<h1>Bitcoin Price Tracker</h1>
|
||||||
|
<div id="bitcoin-price"></div>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
// Fetch the Bitcoin price from the CoinGecko API
|
||||||
|
fetch('https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd')
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
const bitcoinPrice = data['bitcoin']['usd'];
|
||||||
|
const bitcoinPriceDivided = bitcoinPrice; // Divide the Bitcoin price by 100 million
|
||||||
|
// Update the Bitcoin price on the website
|
||||||
|
const bitcoinPriceElement = document.getElementById('bitcoin-price');
|
||||||
|
bitcoinPriceElement.textContent = `1 Bitcoin = $${bitcoinPriceDivided.toFixed(2)}`; // Display the Bitcoin price
|
||||||
|
})
|
||||||
|
.catch(error => console.error(error));
|
||||||
|
</script>
|
@ -1,7 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools">
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
|
<!-- Add the internet permission here -->
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||||
@ -23,4 +25,4 @@
|
|||||||
</activity>
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
@ -2,10 +2,88 @@ package com.example.satsmonitor
|
|||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.webkit.WebView
|
||||||
|
import android.webkit.WebSettings
|
||||||
|
|
||||||
class MainActivity : AppCompatActivity() {
|
class MainActivity : AppCompatActivity() {
|
||||||
|
|
||||||
|
private lateinit var webView: WebView
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_main)
|
setContentView(R.layout.activity_main)
|
||||||
|
|
||||||
|
// Get the WebView reference from the layout
|
||||||
|
webView = findViewById(R.id.webView)
|
||||||
|
|
||||||
|
// Enable JavaScript support
|
||||||
|
val webSettings: WebSettings = webView.settings
|
||||||
|
webSettings.javaScriptEnabled = true
|
||||||
|
|
||||||
|
// Clear the WebView cache (optional)
|
||||||
|
webView.clearCache(true)
|
||||||
|
|
||||||
|
// Load the HTML content with the embedded script and CSS
|
||||||
|
val htmlContent = """<!DOCTYPE html>
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<head>
|
||||||
|
<style>
|
||||||
|
/* CSS styles for the Bitcoin Price Tracker */
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
background: #252525;
|
||||||
|
color: #ffffff;
|
||||||
|
font-family: monospace, Arial;
|
||||||
|
font-size: 12px;
|
||||||
|
font-feature-settings: normal;
|
||||||
|
overflow-x: hidden;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.bitcointodollars {
|
||||||
|
width: auto;
|
||||||
|
margin-left: 20px;
|
||||||
|
margin-right: 20px;
|
||||||
|
margin-top: 20px;
|
||||||
|
background-color: #252525;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 10px;
|
||||||
|
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
color: #ff7500;
|
||||||
|
}
|
||||||
|
#bitcoin-price {
|
||||||
|
font-size: 24px;
|
||||||
|
font-weight: bold;
|
||||||
|
text-align: center;
|
||||||
|
margin: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="bitcointodollars">
|
||||||
|
<h1>Bitcoin Price Tracker</h1>
|
||||||
|
<div id="bitcoin-price"></div>
|
||||||
|
<script>
|
||||||
|
// Fetch the Bitcoin price from the CoinGecko API
|
||||||
|
fetch('https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd')
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
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
|
||||||
|
})
|
||||||
|
.catch(error => console.error(error));
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>"""
|
||||||
|
|
||||||
|
webView.loadDataWithBaseURL(null, htmlContent, "text/html", "UTF-8", null)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -6,28 +6,11 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".MainActivity">
|
tools:context=".MainActivity">
|
||||||
|
|
||||||
<TextView
|
<WebView
|
||||||
android:id="@+id/textView2"
|
android:id="@+id/webView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:text="Hello World!"
|
tools:layout_editor_absoluteX="0dp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
tools:layout_editor_absoluteY="-356dp" />
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textView"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginStart="192dp"
|
|
||||||
android:layout_marginTop="90dp"
|
|
||||||
android:layout_marginEnd="192dp"
|
|
||||||
android:layout_marginBottom="246dp"
|
|
||||||
android:text="@string/test"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/textView2" />
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Reference in New Issue
Block a user