Explorar o código

Set multi lingual resources on webviews, created resource qualifiers and help screens support language

Khubaib hai 8 meses
pai
achega
37efc7e562

+ 3 - 25
app/src/main/java/com/vpn/fastestvpnservice/screens/helpScreensAll/AboutScreen.kt

@@ -6,32 +6,19 @@ import android.util.Log
 import android.view.ViewGroup
 import android.webkit.WebView
 import android.webkit.WebViewClient
-import androidx.compose.animation.core.RepeatMode
-import androidx.compose.animation.core.animateFloatAsState
-import androidx.compose.animation.core.infiniteRepeatable
-import androidx.compose.animation.core.tween
 import androidx.compose.foundation.background
-import androidx.compose.foundation.layout.Arrangement
 import androidx.compose.foundation.layout.Box
 import androidx.compose.foundation.layout.BoxScope
-import androidx.compose.foundation.layout.Column
-import androidx.compose.foundation.layout.Row
 import androidx.compose.foundation.layout.fillMaxHeight
 import androidx.compose.foundation.layout.fillMaxSize
 import androidx.compose.foundation.layout.fillMaxWidth
 import androidx.compose.foundation.layout.height
 import androidx.compose.foundation.layout.padding
 import androidx.compose.foundation.layout.size
-import androidx.compose.foundation.layout.width
-import androidx.compose.foundation.rememberScrollState
-import androidx.compose.foundation.verticalScroll
 import androidx.compose.material.Icon
 import androidx.compose.material.IconButton
 import androidx.compose.material.Surface
 import androidx.compose.material.Text
-import androidx.compose.material.icons.Icons
-import androidx.compose.material.icons.automirrored.filled.ArrowBack
-import androidx.compose.material3.Button
 import androidx.compose.material3.CircularProgressIndicator
 import androidx.compose.material3.MaterialTheme
 import androidx.compose.runtime.Composable
@@ -40,34 +27,24 @@ import androidx.compose.runtime.getValue
 import androidx.compose.runtime.mutableFloatStateOf
 import androidx.compose.runtime.mutableStateOf
 import androidx.compose.runtime.remember
-import androidx.compose.runtime.rememberCoroutineScope
 import androidx.compose.runtime.setValue
 import androidx.compose.ui.Alignment
 import androidx.compose.ui.Modifier
-import androidx.compose.ui.draw.rotate
-import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.graphics.StrokeCap
 import androidx.compose.ui.graphics.toArgb
 import androidx.compose.ui.platform.LocalConfiguration
+import androidx.compose.ui.platform.LocalContext
 import androidx.compose.ui.platform.LocalView
 import androidx.compose.ui.res.colorResource
 import androidx.compose.ui.res.painterResource
-import androidx.compose.ui.text.TextStyle
-import androidx.compose.ui.text.font.FontWeight
-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.compose.ui.viewinterop.AndroidView
 import androidx.navigation.NavHostController
 import androidx.navigation.compose.rememberNavController
 import com.vpn.fastestvpnservice.R
 import com.vpn.fastestvpnservice.beans.isDarkTheme
 import com.vpn.fastestvpnservice.constants.AppConstant
-import com.vpn.fastestvpnservice.constants.TermsAndConditionsDesc
-import com.vpn.fastestvpnservice.sealedClass.BottomBarScreen
 import kotlinx.coroutines.delay
-import kotlinx.coroutines.launch
 
 @Composable
 fun About(navHostController: NavHostController) {
@@ -163,6 +140,7 @@ fun About(navHostController: NavHostController) {
 
 @Composable
 fun BoxScope.ShowHeaderAbout(navHostController: NavHostController) {
+    val context = LocalContext.current
     IconButton(
         onClick = {
             navHostController.popBackStack()
@@ -190,7 +168,7 @@ fun BoxScope.ShowHeaderAbout(navHostController: NavHostController) {
             .padding(5.dp),
         color = colorResource(id = R.color.transparent)
     ) {
-        Text(text = "About Fastest VPN",
+        Text(text = context.getString(R.string.about_fastest_vpn),
             color = MaterialTheme.colorScheme.primary,
             style = MaterialTheme.typography.bodyMedium,
             modifier = Modifier.fillMaxHeight()

+ 2 - 1
app/src/main/java/com/vpn/fastestvpnservice/screens/helpScreensAll/CustomerSupportScreen.kt

@@ -234,6 +234,7 @@ fun handleURI(uri: String?) {
 
 @Composable
 fun BoxScope.ShowHeaderCS(navHostController: NavHostController) {
+    val context = LocalContext.current
     IconButton(
         onClick = {
             navHostController.popBackStack()
@@ -261,7 +262,7 @@ fun BoxScope.ShowHeaderCS(navHostController: NavHostController) {
             .padding(5.dp),
         color = colorResource(id = R.color.transparent)
     ) {
-        Text(text = "Customer Support",
+        Text(text = context.getString(R.string.customer_support),
             color = colorResource(id = R.color.dark_blue_gray_text),
             style = MaterialTheme.typography.bodyMedium,
             modifier = Modifier.fillMaxHeight()

+ 6 - 3
app/src/main/java/com/vpn/fastestvpnservice/screens/helpScreensAll/EmailUsScreen.kt

@@ -42,6 +42,7 @@ import androidx.compose.ui.Alignment
 import androidx.compose.ui.Modifier
 import androidx.compose.ui.graphics.Color
 import androidx.compose.ui.graphics.toArgb
+import androidx.compose.ui.platform.LocalContext
 import androidx.compose.ui.platform.LocalFocusManager
 import androidx.compose.ui.platform.LocalSoftwareKeyboardController
 import androidx.compose.ui.platform.LocalView
@@ -70,6 +71,7 @@ fun EmailUsScreen(navHostController: NavHostController) {
     val snackBarState = remember { SnackbarHostState() }
     val snackBarStateRed = remember { SnackbarHostState() }
     var isShowLoader by remember { mutableStateOf(false) }
+    val context = LocalContext.current
 
     Box(
         modifier = Modifier
@@ -129,7 +131,7 @@ fun EmailUsScreen(navHostController: NavHostController) {
                 textChanged = it
             }
 
-            Text(text = "Your message:",
+            Text(text = "${context.getString(R.string.your_message)}:",
                 color = MaterialTheme.colorScheme.primary,
                 style = MaterialTheme.typography.bodyMedium,
                 modifier = Modifier
@@ -189,6 +191,7 @@ fun ColumnScope.ShowHeaderEU(
     isShowLoader: (Boolean) -> Unit,
     textChanged: (String) -> Unit,
 ) {
+    val context = LocalContext.current
     Log.d("emailUs: ","EU :: message = $message")
     val helpViewModel: HelpViewModel = viewModel()
     val coroutineScope = rememberCoroutineScope()
@@ -222,7 +225,7 @@ fun ColumnScope.ShowHeaderEU(
                 .padding(5.dp),
             color = colorResource(id = R.color.transparent)
         ) {
-            Text(text = "Email Us",
+            Text(text = context.getString(R.string.email_us),
                 color = MaterialTheme.colorScheme.primary,
                 style = MaterialTheme.typography.bodyMedium,
                 modifier = Modifier.fillMaxHeight()
@@ -238,7 +241,7 @@ fun ColumnScope.ShowHeaderEU(
                     helpViewModel.emailUs(message)
                 } else {
                     coroutineScope.launch {
-                        snackBarStateRed.showSnackbar("The message field is required.")
+                        snackBarStateRed.showSnackbar(context.getString(R.string.message_field_req))
                     }
                 }
             },

+ 3 - 1
app/src/main/java/com/vpn/fastestvpnservice/screens/helpScreensAll/FAQScreen.kt

@@ -64,6 +64,7 @@ import androidx.compose.ui.graphics.drawscope.Stroke
 import androidx.compose.ui.graphics.toArgb
 import androidx.compose.ui.input.pointer.pointerInput
 import androidx.compose.ui.platform.LocalConfiguration
+import androidx.compose.ui.platform.LocalContext
 import androidx.compose.ui.platform.LocalView
 import androidx.compose.ui.res.colorResource
 import androidx.compose.ui.res.painterResource
@@ -181,6 +182,7 @@ fun FAQ(navHostController: NavHostController) {
 fun BoxScope.ShowExpandList(
     navHostController: NavHostController
 ) {
+    val context = LocalContext.current
     IconButton(
         onClick = {
 
@@ -209,7 +211,7 @@ fun BoxScope.ShowExpandList(
             .padding(5.dp),
         color = colorResource(id = R.color.transparent)
     ) {
-        Text(text = "FAQ",
+        Text(text = context.getString(R.string.faq),
             color = MaterialTheme.colorScheme.primary,
             style = MaterialTheme.typography.bodyMedium,
             modifier = Modifier.fillMaxHeight()

+ 3 - 1
app/src/main/java/com/vpn/fastestvpnservice/screens/helpScreensAll/PrivacyPolicyScreen.kt

@@ -41,6 +41,7 @@ import androidx.compose.ui.Modifier
 import androidx.compose.ui.graphics.Color
 import androidx.compose.ui.graphics.toArgb
 import androidx.compose.ui.platform.LocalConfiguration
+import androidx.compose.ui.platform.LocalContext
 import androidx.compose.ui.platform.LocalView
 import androidx.compose.ui.res.colorResource
 import androidx.compose.ui.res.painterResource
@@ -155,6 +156,7 @@ fun PrivacyPolicy(navHostController: NavHostController){
 
 @Composable
 fun BoxScope.ShowHeaderPP(navHostController: NavHostController) {
+    val context = LocalContext.current
     IconButton(
         onClick = {
             navHostController.popBackStack()
@@ -182,7 +184,7 @@ fun BoxScope.ShowHeaderPP(navHostController: NavHostController) {
             .padding(5.dp),
         color = colorResource(id = R.color.transparent)
     ) {
-        Text(text = "Privacy Policy",
+        Text(text = context.getString(R.string.privacy_policy),
             color = MaterialTheme.colorScheme.primary,
             style = MaterialTheme.typography.bodyMedium,
             modifier = Modifier.fillMaxHeight()

+ 3 - 1
app/src/main/java/com/vpn/fastestvpnservice/screens/helpScreensAll/TermsAndConditionsScreen.kt

@@ -42,6 +42,7 @@ import androidx.compose.ui.Modifier
 import androidx.compose.ui.graphics.Color
 import androidx.compose.ui.graphics.toArgb
 import androidx.compose.ui.platform.LocalConfiguration
+import androidx.compose.ui.platform.LocalContext
 import androidx.compose.ui.platform.LocalView
 import androidx.compose.ui.res.colorResource
 import androidx.compose.ui.res.painterResource
@@ -160,6 +161,7 @@ fun BoxScope.ShowHeaderTnC(
     navHostController: NavHostController,
     isFromSignUpScreen: Boolean
 ) {
+    val context = LocalContext.current
     Log.d("test_tnc", "ShowHeaderTnC")
     IconButton(
         onClick = {
@@ -193,7 +195,7 @@ fun BoxScope.ShowHeaderTnC(
             .padding(5.dp),
         color = colorResource(id = R.color.transparent)
     ) {
-        Text(text = "Terms and Conditions",
+        Text(text = context.getString(R.string.terms_conditions),
             color = MaterialTheme.colorScheme.primary,
             style = MaterialTheme.typography.bodyMedium,
             modifier = Modifier.fillMaxHeight()

+ 2 - 0
app/src/main/res/values-de/strings.xml

@@ -32,6 +32,8 @@
     <string name="about_fastest_vpn">Über FastestVPN</string>
     <string name="customer_support">Kundensupport</string>
     <string name="email_us">Senden Sie uns eine E-Mail</string>
+    <string name="your_message">Ihre Nachricht</string>
+    <string name="message_field_req">Das Nachrichtenfeld ist erforderlich.</string>
 
     <!-- Account Screen -->
     <string name="account">Konto</string>

+ 2 - 0
app/src/main/res/values/strings.xml

@@ -548,6 +548,8 @@
     <string name="about_fastest_vpn">About Fastest VPN</string>
     <string name="customer_support">Customer Support</string>
     <string name="email_us">Email Us</string>
+    <string name="your_message">Your message</string>
+    <string name="message_field_req">The message field is required.</string>
 
     <!-- Account Screen -->
     <string name="account">Account</string>