android: fix change language

This commit is contained in:
Emin 2025-02-05 20:21:25 +05:00
parent 36f60c9d64
commit 2183b7a53c
5 changed files with 16 additions and 3 deletions

View file

@ -40,7 +40,7 @@ object NetworkModule {
return OkHttpClient.Builder()
.addInterceptor(
HttpLoggingInterceptor()
.setLevel(HttpLoggingInterceptor.Level.BODY)
.setLevel(HttpLoggingInterceptor.Level.BASIC)
)
.addInterceptor { chain ->
val original = chain.request()

View file

@ -13,10 +13,12 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import app.organicmaps.R
import app.organicmaps.SplashActivity
import app.tourism.ui.common.SingleChoiceCheckBoxes
import app.tourism.ui.common.VerticalSpace
import app.tourism.ui.common.nav.AppTopBar
import app.tourism.utils.changeSystemAppLanguage
import app.tourism.utils.triggerRebirth
@Composable
fun LanguageScreen(
@ -47,6 +49,7 @@ fun LanguageScreen(
val language = languages.first { it.name == name }
vm.updateLanguage(language)
changeSystemAppLanguage(context, language.code)
triggerRebirth(context, SplashActivity::class.java)
}
)
}

View file

@ -22,7 +22,7 @@ import javax.inject.Inject
@HiltViewModel
class CategoriesViewModel @Inject constructor(
@ApplicationContext context: Context,
@ApplicationContext val context: Context,
private val placesRepository: PlacesRepository,
) : ViewModel() {
private val uiChannel = Channel<UiEvent>()

View file

@ -23,7 +23,6 @@ import javax.inject.Inject
@HiltViewModel
class HomeViewModel @Inject constructor(
@ApplicationContext val context: Context,
private val placesRepository: PlacesRepository
) : ViewModel() {
private val uiChannel = Channel<UiEvent>()

View file

@ -0,0 +1,11 @@
package app.tourism.utils
import android.content.Context
import android.content.Intent
fun triggerRebirth(context: Context, myClass: Class<*>?) {
val intent = Intent(context, myClass)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
context.startActivity(intent)
Runtime.getRuntime().exit(0)
}