Skip to content

Commit

Permalink
- add device language detection for both platforms and usage on app …
Browse files Browse the repository at this point in the history
…init (#139)

- remove bisqapps folder with its dead code
  • Loading branch information
rodvar authored Dec 24, 2024
1 parent 896d1c9 commit 64ebdc2
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 178 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import androidx.compose.ui.graphics.asImageBitmap
import com.russhwolf.settings.Settings
import kotlinx.serialization.Serializable
import java.io.ByteArrayOutputStream
import java.util.Locale

actual fun getDeviceLanguageCode(): String {
return Locale.getDefault().language
}

actual fun getPlatformSettings(): Settings {
return Settings()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ interface PlatformInfo {
val name: String
}

expect fun getDeviceLanguageCode(): String

expect fun getPlatformInfo(): PlatformInfo

@Serializable(with = PlatformImageSerializer::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import com.russhwolf.settings.Settings
import kotlinx.cinterop.*
import kotlinx.serialization.Serializable
import platform.Foundation.NSData
import platform.Foundation.*
import platform.UIKit.UIDevice
import platform.UIKit.UIImage
import platform.Foundation.create
import platform.UIKit.UIImagePNGRepresentation

import platform.UIKit.UIDevice
import platform.posix.memcpy

@OptIn(ExperimentalSettingsImplementation::class)
Expand All @@ -22,7 +23,11 @@ actual fun getPlatformSettings(): Settings {
return KeychainSettings("Settings")
}

class IOSPlatformInfo: PlatformInfo {
actual fun getDeviceLanguageCode(): String {
return NSLocale.currentLocale.languageCode ?: "en"
}

class IOSPlatformInfo : PlatformInfo {
override val name: String = UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ package network.bisq.mobile.presentation

import androidx.annotation.CallSuper
import androidx.navigation.NavHostController
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.launch
import network.bisq.mobile.android.node.BuildNodeConfig
import network.bisq.mobile.client.shared.BuildConfig
import network.bisq.mobile.domain.data.BackgroundDispatcher
import network.bisq.mobile.domain.getDeviceLanguageCode
import network.bisq.mobile.domain.getPlatformInfo
import network.bisq.mobile.domain.service.controller.NotificationServiceController
import network.bisq.mobile.presentation.ui.AppPresenter
Expand Down Expand Up @@ -45,10 +44,12 @@ open class MainPresenter(private val notificationServiceController: Notification
// override val greetingText: StateFlow<String> = _greetingText

init {
val localeCode = getDeviceLanguageCode()
log.i { "Shared Version: ${BuildConfig.SHARED_LIBS_VERSION}" }
log.i { "iOS Client Version: ${BuildConfig.IOS_APP_VERSION}" }
log.i { "Android Client Version: ${BuildConfig.IOS_APP_VERSION}" }
log.i { "Android Node Version: ${BuildNodeConfig.APP_VERSION}" }
log.i { "Device language code: $localeCode"}
}

@CallSuper
Expand Down

0 comments on commit 64ebdc2

Please sign in to comment.