mirror of
https://github.com/RoboSats/robosats.git
synced 2025-09-13 00:56:22 +00:00
Fix
This commit is contained in:
@ -34,7 +34,10 @@ import androidx.core.app.ActivityCompat
|
|||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import com.robosats.models.EncryptedStorage
|
import com.robosats.models.EncryptedStorage
|
||||||
import com.robosats.models.LanguageManager
|
import com.robosats.models.LanguageManager
|
||||||
|
import com.robosats.models.LanguageManager.LANGUAGE_KEY
|
||||||
|
import com.robosats.models.LanguageManager.applyLanguage
|
||||||
import com.robosats.services.NotificationsService
|
import com.robosats.services.NotificationsService
|
||||||
|
import java.util.Locale
|
||||||
import com.robosats.tor.TorKmp
|
import com.robosats.tor.TorKmp
|
||||||
import com.robosats.tor.TorKmpManager
|
import com.robosats.tor.TorKmpManager
|
||||||
import com.robosats.tor.TorKmpManager.getTorKmpObject
|
import com.robosats.tor.TorKmpManager.getTorKmpObject
|
||||||
@ -58,6 +61,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
// Initialize language manager and apply saved language setting
|
// Initialize language manager and apply saved language setting
|
||||||
LanguageManager.init(this)
|
LanguageManager.init(this)
|
||||||
|
val languageCode = EncryptedStorage.getEncryptedStorage(LANGUAGE_KEY)
|
||||||
|
changeAppLanguage(languageCode)
|
||||||
|
|
||||||
// Lock the screen orientation to portrait mode
|
// Lock the screen orientation to portrait mode
|
||||||
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||||
@ -93,6 +98,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val intent = intent
|
val intent = intent
|
||||||
|
intentData = ""
|
||||||
if (intent != null) {
|
if (intent != null) {
|
||||||
val orderId = intent.getStringExtra("order_id")
|
val orderId = intent.getStringExtra("order_id")
|
||||||
if (orderId?.isNotEmpty() == true) {
|
if (orderId?.isNotEmpty() == true) {
|
||||||
@ -100,13 +106,14 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize Tor and setup WebView only after Tor is properly connected
|
|
||||||
initializeTor()
|
|
||||||
|
|
||||||
val settingProxy = EncryptedStorage.getEncryptedStorage("settings_use_proxy")
|
val settingProxy = EncryptedStorage.getEncryptedStorage("settings_use_proxy")
|
||||||
if (settingProxy == "false") {
|
if (settingProxy == "false") {
|
||||||
// Setup WebView to use Orbot if the user previously clicked
|
// Setup WebView to use Orbot if the user previously clicked
|
||||||
onUseOrbotButtonClicked()
|
onUseOrbotButtonClicked()
|
||||||
|
} else {
|
||||||
|
// Initialize Tor and setup WebView only after Tor is properly connected
|
||||||
|
initializeTor()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -376,11 +383,13 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val notifications = EncryptedStorage.getEncryptedStorage("settings_notifications")
|
val notifications = EncryptedStorage.getEncryptedStorage("settings_notifications")
|
||||||
if (notifications != "false") initializeNotifications()
|
if (notifications != "false") initializeNotifications()
|
||||||
|
|
||||||
webView.post {
|
if (intentData != "") {
|
||||||
try {
|
webView.post {
|
||||||
webView.evaluateJavascript("javascript:window.AndroidDataRobosats = { navigateToPage: '$intentData' }", null)
|
try {
|
||||||
} catch (e: Exception) {
|
webView.evaluateJavascript("javascript:window.AndroidDataRobosats = { navigateToPage: '$intentData' }", null)
|
||||||
Log.e("NavigateToPage", "Error evaluating JavaScript: $e")
|
} catch (e: Exception) {
|
||||||
|
Log.e("NavigateToPage", "Error evaluating JavaScript: $e")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -465,6 +474,18 @@ class MainActivity : AppCompatActivity() {
|
|||||||
webSettings.textZoom = 100
|
webSettings.textZoom = 100
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change the app's language and recreate the activity
|
||||||
|
* @param languageCode The language code to switch to (e.g., "en", "es", "fr")
|
||||||
|
*/
|
||||||
|
fun changeAppLanguage(languageCode: String) {
|
||||||
|
// Apply the language change
|
||||||
|
if (LanguageManager.applyLanguage(languageCode)) {
|
||||||
|
// Restart the activity to apply changes
|
||||||
|
recreate()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear all WebView data when activity is destroyed
|
* Clear all WebView data when activity is destroyed
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -368,7 +368,12 @@ class WebAppInterface(private val context: MainActivity, private val webView: We
|
|||||||
EncryptedStorage.setEncryptedStorage(sanitizedKey, sanitizedValue)
|
EncryptedStorage.setEncryptedStorage(sanitizedKey, sanitizedValue)
|
||||||
|
|
||||||
if (key == "garage_slots") NostrClient.refresh()
|
if (key == "garage_slots") NostrClient.refresh()
|
||||||
if (key == "settings_language") LanguageManager.applyLanguage(value)
|
if (key == "settings_language") {
|
||||||
|
context.changeAppLanguage(value)
|
||||||
|
// Return immediately as recreate() will be called
|
||||||
|
resolvePromise(uuid, key)
|
||||||
|
return
|
||||||
|
}
|
||||||
if (key == "settings_notifications") {
|
if (key == "settings_notifications") {
|
||||||
val serviceIntent = Intent(context, NotificationsService::class.java)
|
val serviceIntent = Intent(context, NotificationsService::class.java)
|
||||||
if (value == "true") {
|
if (value == "true") {
|
||||||
|
|||||||
@ -13,9 +13,6 @@ object LanguageManager {
|
|||||||
val LANGUAGE_KEY = "settings_language"
|
val LANGUAGE_KEY = "settings_language"
|
||||||
|
|
||||||
fun init(context: MainActivity) {
|
fun init(context: MainActivity) {
|
||||||
val value = EncryptedStorage.getEncryptedStorage(LANGUAGE_KEY)
|
|
||||||
applyLanguage(value)
|
|
||||||
|
|
||||||
resources = context.resources
|
resources = context.resources
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user