Browse Source

Changed setting of locale, app will have same language even logout or login app and does not removing LANGUAGE key from shared prefs upon logout

Khubaib 10 months ago
parent
commit
237d424399

+ 1 - 1
.idea/deploymentTargetSelector.xml

@@ -4,7 +4,7 @@
     <selectionStates>
       <SelectionState runConfigName="app">
         <option name="selectionMode" value="DROPDOWN" />
-        <DropdownSelection timestamp="2024-09-10T14:40:56.666833887Z">
+        <DropdownSelection timestamp="2024-09-11T11:33:27.739232601Z">
           <Target type="DEFAULT_BOOT">
             <handle>
               <DeviceId pluginId="PhysicalDevice" identifier="serial=1C051FDF60048Z" />

+ 1 - 1
app/src/main/java/com/vpn/fastestvpnservice/helpers/BasePreferenceHelper.kt

@@ -51,7 +51,7 @@ class BasePreferenceHelper(private val context: Context) : PreferencesHelper() {
         removePreference(context, KEY_FILENAME, KEY_RECENTLY_SERVERS)
         removePreference(context, KEY_FILENAME, KEY_FEEDBACK)
         removePreference(context, KEY_FILENAME, KEY_LAUNCH)
-        removePreference(context, KEY_FILENAME, LANGUAGE)
+//        removePreference(context, KEY_FILENAME, LANGUAGE)
     }
 
     fun clearServerObject() {

+ 1 - 1
app/src/main/java/com/vpn/fastestvpnservice/retrofit/WebServiceFactory.java

@@ -24,7 +24,7 @@ public class WebServiceFactory {
     private static final String KEY_HEADER_AUTHORIZATION = "Authorization";
     private static final String X_PLATFORM = "X-PLATFORM";
     private static final String X_PLATFORM_TOKEN = "X-PLATFORM-TOKEN";
-    private static final String X_LOCALE = "X-Locale";
+    private static final String X_LOCALE = "Content-Language";
     private static final String PLATFORM = "platform";
     private static final String VERSION = "version";
 

+ 1 - 10
app/src/main/java/com/vpn/fastestvpnservice/screens/LoginScreen.kt

@@ -1,16 +1,11 @@
 package com.vpn.fastestvpnservice.screens
 
 import android.app.Activity
-import android.app.LocaleManager
 import android.content.Context
 import android.content.Intent
 import android.content.res.Configuration
 import android.location.Location
-import android.os.Build
-import android.os.LocaleList
 import android.util.Log
-import android.widget.Toast
-import androidx.appcompat.app.AppCompatDelegate
 import androidx.compose.foundation.Image
 import androidx.compose.foundation.background
 import androidx.compose.foundation.border
@@ -24,7 +19,6 @@ import androidx.compose.foundation.layout.Row
 import androidx.compose.foundation.layout.RowScope
 import androidx.compose.foundation.layout.Spacer
 import androidx.compose.foundation.layout.WindowInsets
-import androidx.compose.foundation.layout.fillMaxHeight
 import androidx.compose.foundation.layout.fillMaxSize
 import androidx.compose.foundation.layout.fillMaxWidth
 import androidx.compose.foundation.layout.height
@@ -86,7 +80,6 @@ import androidx.compose.ui.text.style.TextAlign
 import androidx.compose.ui.tooling.preview.Preview
 import androidx.compose.ui.unit.dp
 import androidx.compose.ui.unit.sp
-import androidx.core.os.LocaleListCompat
 import androidx.lifecycle.viewmodel.compose.viewModel
 import androidx.navigation.NavHostController
 import androidx.navigation.compose.rememberNavController
@@ -105,11 +98,9 @@ import com.vpn.fastestvpnservice.viewmodels.ServerListViewModel
 import com.vpn.fastestvpnservice.viewmodels.SplashViewModel
 import com.vpn.fastestvpnservice.views.CustomValidation
 import com.vpn.fastestvpnservice.views.ShowCustomSnackBar
-import com.vpn.fastestvpnservice.views.setCustomLocale
 import com.vpn.fastestvpnservice.widgets.SimpleAppWidget
 import kotlinx.coroutines.delay
 import kotlinx.coroutines.launch
-import java.util.Locale
 import kotlin.random.Random
 
 @OptIn(ExperimentalComposeUiApi::class)
@@ -716,7 +707,7 @@ fun ColumnScope.SignInButton(
 
                     }
 
-                    setCustomLocale(context)
+//                    setCustomLocale(context)
 
                     splashViewModelSplash = viewModel {
                         SplashViewModel(context)

+ 1 - 11
app/src/main/java/com/vpn/fastestvpnservice/screens/SignUpScreen.kt

@@ -1,15 +1,10 @@
 package com.vpn.fastestvpnservice.screens
 
 import android.app.Activity
-import android.app.LocaleManager
-import android.content.Context
 import android.content.Intent
 import android.content.res.Configuration
 import android.location.Location
-import android.os.Build
-import android.os.LocaleList
 import android.util.Log
-import androidx.appcompat.app.AppCompatDelegate
 import androidx.compose.foundation.Image
 import androidx.compose.foundation.background
 import androidx.compose.foundation.border
@@ -21,7 +16,6 @@ import androidx.compose.foundation.layout.ColumnScope
 import androidx.compose.foundation.layout.Row
 import androidx.compose.foundation.layout.Spacer
 import androidx.compose.foundation.layout.WindowInsets
-import androidx.compose.foundation.layout.fillMaxHeight
 import androidx.compose.foundation.layout.fillMaxSize
 import androidx.compose.foundation.layout.fillMaxWidth
 import androidx.compose.foundation.layout.height
@@ -84,10 +78,8 @@ import androidx.compose.ui.text.style.TextAlign
 import androidx.compose.ui.tooling.preview.Preview
 import androidx.compose.ui.unit.dp
 import androidx.compose.ui.unit.sp
-import androidx.core.os.LocaleListCompat
 import androidx.lifecycle.viewmodel.compose.viewModel
 import androidx.navigation.NavHostController
-import androidx.navigation.compose.rememberNavController
 import com.vpn.fastestvpnservice.R
 import com.vpn.fastestvpnservice.beans.Server
 import com.vpn.fastestvpnservice.beans.filterList
@@ -104,11 +96,9 @@ import com.vpn.fastestvpnservice.viewmodels.SignUpViewModel
 import com.vpn.fastestvpnservice.viewmodels.SplashViewModel
 import com.vpn.fastestvpnservice.views.CustomValidation
 import com.vpn.fastestvpnservice.views.ShowCustomSnackBar
-import com.vpn.fastestvpnservice.views.setCustomLocale
 import com.vpn.fastestvpnservice.widgets.SimpleAppWidget
 import kotlinx.coroutines.delay
 import kotlinx.coroutines.launch
-import java.util.Locale
 
 @OptIn(ExperimentalComposeUiApi::class)
 @Composable
@@ -843,7 +833,7 @@ fun ColumnScope.SignUpButton(
 
                 }
 
-                setCustomLocale(context)
+//                setCustomLocale(context)
 
                 splashViewModelSplash = viewModel {
                     SplashViewModel(context)

+ 3 - 4
app/src/main/java/com/vpn/fastestvpnservice/screens/bottomNavBarScreens/AccountScreen.kt

@@ -79,7 +79,6 @@ import com.vpn.fastestvpnservice.utils.VPNConnectionsUtil
 import com.vpn.fastestvpnservice.utils.isTablet
 import com.vpn.fastestvpnservice.viewmodels.AccountViewModel
 import com.vpn.fastestvpnservice.viewmodels.HomeViewModel
-import com.vpn.fastestvpnservice.views.setCustomLocale
 import com.vpn.fastestvpnservice.widgets.SimpleAppWidget
 import de.blinkt.openvpn.core.App
 import kotlinx.coroutines.delay
@@ -113,7 +112,7 @@ fun Account(navHostController: NavHostController,
         if (!it.status) {
             basePreferenceHelper.setLoggedInState(false)
             basePreferenceHelper.clearAllData()
-            setCustomLocale(context)
+//            setCustomLocale(context)
             settingsNavHostController.popBackStack()
             settingsNavHostController.navigate(Screen.Started.route)
         }
@@ -286,7 +285,7 @@ fun Account(navHostController: NavHostController,
                     Log.d("test_api_response","Logout live: $logoutResponse")
                     basePreferenceHelper.setLoggedInState(false)
                     basePreferenceHelper.clearAllData()
-                    setCustomLocale(context)
+//                    setCustomLocale(context)
                     settingsNavHostController.popBackStack()
                     settingsNavHostController.navigate(Screen.Started.route)
 
@@ -309,7 +308,7 @@ fun Account(navHostController: NavHostController,
                     Log.d("test_api_response","Delete live: ${deleteResponse.status}")
                     basePreferenceHelper.setLoggedInState(false)
                     basePreferenceHelper.clearAllData()
-                    setCustomLocale(context)
+//                    setCustomLocale(context)
                     settingsNavHostController.popBackStack()
                     settingsNavHostController.navigate(Screen.Started.route)
                 }

+ 1 - 4
app/src/main/java/com/vpn/fastestvpnservice/screens/bottomNavBarScreens/HomeScreen.kt

@@ -6,10 +6,8 @@ import android.content.Intent
 import android.content.res.Configuration
 import android.os.Handler
 import android.util.Log
-import android.widget.Toast
 import androidx.activity.ComponentActivity
 import androidx.compose.animation.animateColorAsState
-import androidx.compose.animation.core.animateSizeAsState
 import androidx.compose.foundation.BorderStroke
 import androidx.compose.foundation.Image
 import androidx.compose.foundation.background
@@ -112,7 +110,6 @@ import com.vpn.fastestvpnservice.utils.VPNConnectionsUtil
 import com.vpn.fastestvpnservice.utils.isTablet
 import com.vpn.fastestvpnservice.viewmodels.HomeViewModel
 import com.vpn.fastestvpnservice.viewmodels.ServerListViewModel
-import com.vpn.fastestvpnservice.views.setCustomLocale
 import com.vpn.fastestvpnservice.widgets.SimpleAppWidget
 import com.wireguard.android.backend.GoBackend
 import de.blinkt.openvpn.core.App
@@ -369,7 +366,7 @@ fun Home(
         if (!it.status) {
             basePreferenceHelper.setLoggedInState(false)
             basePreferenceHelper.clearAllData()
-            setCustomLocale(context)
+//            setCustomLocale(context)
             settingsNavHostController.popBackStack()
             settingsNavHostController.navigate(Screen.Started.route)
         }

+ 2 - 3
app/src/main/java/com/vpn/fastestvpnservice/screensTV/AccountScreenTV.kt

@@ -86,7 +86,6 @@ import com.vpn.fastestvpnservice.utils.VPNConnectionsUtil
 import com.vpn.fastestvpnservice.utils.isTablet
 import com.vpn.fastestvpnservice.viewmodels.AccountViewModel
 import com.vpn.fastestvpnservice.viewmodels.HomeViewModel
-import com.vpn.fastestvpnservice.views.setCustomLocale
 import com.vpn.fastestvpnservice.widgets.SimpleAppWidget
 import de.blinkt.openvpn.core.App
 import kotlinx.coroutines.delay
@@ -290,7 +289,7 @@ fun AccountTV(navHostController: NavHostController,
                     Log.d("test_api_response","Logout live: $logoutResponse")
                     basePreferenceHelper.setLoggedInState(false)
                     basePreferenceHelper.clearAllData()
-                    setCustomLocale(context)
+//                    setCustomLocale(context)
                     settingsNavHostController.popBackStack()
                     settingsNavHostController.navigate(ScreenTV.LoginTV.route)
 
@@ -317,7 +316,7 @@ fun AccountTV(navHostController: NavHostController,
                     Log.d("test_api_response","Delete live: ${deleteResponse.status}")
                     basePreferenceHelper.setLoggedInState(false)
                     basePreferenceHelper.clearAllData()
-                    setCustomLocale(context)
+//                    setCustomLocale(context)
                     settingsNavHostController.popBackStack()
                     settingsNavHostController.navigate(ScreenTV.LoginTV.route)
                 }

+ 1 - 2
app/src/main/java/com/vpn/fastestvpnservice/screensTV/HomeScreenTV.kt

@@ -124,7 +124,6 @@ import com.vpn.fastestvpnservice.utils.VPNConnectionsUtil
 import com.vpn.fastestvpnservice.utils.isTablet
 import com.vpn.fastestvpnservice.viewmodels.HomeViewModel
 import com.vpn.fastestvpnservice.viewmodels.ServerListViewModel
-import com.vpn.fastestvpnservice.views.setCustomLocale
 import com.wireguard.android.backend.GoBackend
 import de.blinkt.openvpn.core.App
 import kotlinx.coroutines.delay
@@ -346,7 +345,7 @@ fun HomeTV(
         if (!it.status) {
             basePreferenceHelper.setLoggedInState(false)
             basePreferenceHelper.clearAllData()
-            setCustomLocale(context)
+//            setCustomLocale(context)
             settingsNavHostController.popBackStack()
             settingsNavHostController.navigate(ScreenTV.LoginTV.route)
         }