Compare commits

..

No commits in common. "804592872cc5f198fab16cbcf8a684c48f910cc4" and "f7505e8ac576a893d238becfa29c78f76a35fdec" have entirely different histories.

3 changed files with 2 additions and 51 deletions

View File

@ -12,7 +12,7 @@ android {
minSdk = 24
targetSdk = 33
versionCode = 7
versionName = "0.2.0"
versionName = "0.1.7"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

View File

@ -13,23 +13,10 @@ function updateBitcoinPrice(selectedCurrency) {
function handleThemeChange() {
var selectedTheme = document.getElementById("theme-select").value;
document.documentElement.setAttribute("data-theme", selectedTheme);
savePreference("theme", selectedTheme);
}
function handleCurrencyChange() {
var selectedCurrency = document.getElementById("currency-select").value;
savePreference("currency", selectedCurrency);
}
function savePreference(key, value) {
if (typeof Android !== 'undefined' && Android !== null) {
Android.savePreference(key, value);
}
}
// Event listener for theme select change
document.getElementById("theme-select").addEventListener("change", handleThemeChange);
document.getElementById("currency-select").addEventListener("change", handleCurrencyChange);
document.getElementById("theme-select").addEventListener("change", handleThemeChange);
//function refreshBitcoinPrice(selectedCurrency) {
@ -94,20 +81,6 @@ document.addEventListener('DOMContentLoaded', () => {
updateSatsToDollarsConversion(selectedCurrency);
updateFiatToSatsConversion(selectedCurrency)
});
const savedTheme = (typeof Android !== 'undefined' && Android !== null) ? Android.getPreference("theme") : null;
if (savedTheme) {
document.getElementById("theme-select").value = savedTheme;
document.documentElement.setAttribute("data-theme", savedTheme);
}
const savedCurrency = (typeof Android !== 'undefined' && Android !== null) ? Android.getPreference("currency") : null;
if (savedCurrency) {
document.getElementById("currency-select").value = savedCurrency;
updateBitcoinPrice(savedCurrency);
updateFiatToSatsConversion(savedCurrency);
updateSatsToDollarsConversion(savedCurrency);
}
});

View File

@ -6,8 +6,6 @@ import android.os.Bundle
import android.webkit.WebView
import android.webkit.WebSettings
import java.io.IOException
import android.content.Context
import android.webkit.JavascriptInterface
class MainActivity : AppCompatActivity() {
@ -25,9 +23,6 @@ class MainActivity : AppCompatActivity() {
val webSettings: WebSettings = webView.settings
webSettings.javaScriptEnabled = true
// Add JavaScript interface
webView.addJavascriptInterface(WebAppInterface(this), "Android")
// Clear the WebView cache (optional)
webView.clearCache(true)
@ -89,20 +84,3 @@ class MainActivity : AppCompatActivity() {
webView.loadDataWithBaseURL(null, finalHtmlContent, "text/html", "UTF-8", null)
}
}
class WebAppInterface(private val context: Context) {
private val sharedPreferences = context.getSharedPreferences("AppPrefs", Context.MODE_PRIVATE)
@JavascriptInterface
fun savePreference(key: String, value: String) {
with(sharedPreferences.edit()) {
putString(key, value)
apply()
}
}
@JavascriptInterface
fun getPreference(key: String): String? {
return sharedPreferences.getString(key, null)
}
}