Explorar o código

Merge remote-tracking branch 'origin/QA_3.2.9-Compose-TV' into QA_3.2.9-Compose-TV

minhaj hai 6 meses
pai
achega
96981e7e09

+ 2 - 2
.idea/deploymentTargetSelector.xml

@@ -4,10 +4,10 @@
     <selectionStates>
       <SelectionState runConfigName="app">
         <option name="selectionMode" value="DROPDOWN" />
-        <DropdownSelection timestamp="2024-07-03T15:28:39.845843338Z">
+        <DropdownSelection timestamp="2024-07-06T11:53:24.301530973Z">
           <Target type="DEFAULT_BOOT">
             <handle>
-              <DeviceId pluginId="LocalEmulator" identifier="path=/home/ubuntu/.android/avd/Television_1080p_API_31.avd" />
+              <DeviceId pluginId="PhysicalDevice" identifier="serial=1C051FDF60048Z" />
             </handle>
           </Target>
         </DropdownSelection>

+ 7 - 0
app/src/main/java/com/vpn/fastestvpnservice/MainActivity.kt

@@ -12,6 +12,7 @@ import android.util.Log
 import android.view.WindowInsets
 import android.view.WindowInsetsController
 import android.view.WindowManager
+import android.widget.Toast
 import androidx.activity.compose.setContent
 import androidx.activity.viewModels
 import androidx.compose.foundation.isSystemInDarkTheme
@@ -143,6 +144,12 @@ open class MainActivity : DockActivity(), ConnectivityReceiver.ConnectivityRecei
 
     }
 
+    override fun onBackPressed() {
+        super.onBackPressed()
+        Toast.makeText(
+            baseContext, "onBackPressed()", Toast.LENGTH_SHORT
+        ).show()
+    }
     fun hideSystemUI() {
 
         //Hides the ugly action bar at the top

+ 7 - 4
app/src/main/java/com/vpn/fastestvpnservice/screensTV/AccountScreenTV.kt

@@ -93,10 +93,6 @@ fun AccountTV(navHostController: NavHostController,
     val accountViewModel: AccountViewModel = viewModel()
     val focusRequester1 = remember { FocusRequester() }
 
-    LaunchedEffect(key1 = Unit) {
-        focusRequester1.requestFocus()
-    }
-
     CompositionLocalProvider(
         LocalOverscrollConfiguration provides null
     ) {
@@ -114,6 +110,13 @@ fun AccountTV(navHostController: NavHostController,
             window.statusBarColor = Color.Transparent.toArgb()
             window.navigationBarColor = Color.Transparent.toArgb()
 
+            if (isAccountScreenPressed.value) {
+                LaunchedEffect(key1 = Unit) {
+                    focusRequester1.requestFocus()
+                }
+                isAccountScreenPressed.value = false
+            }
+
             Column(
                 verticalArrangement = Arrangement.Top,
                 horizontalAlignment = Alignment.Start,

+ 197 - 99
app/src/main/java/com/vpn/fastestvpnservice/screensTV/BottomBarMainScreenTV.kt

@@ -1,11 +1,12 @@
 package com.vpn.fastestvpnservice.screensTV
 
 import android.util.Log
+import android.widget.Toast
 import androidx.activity.ComponentActivity
 import androidx.compose.foundation.background
-import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.clickable
+import androidx.compose.foundation.focusable
 import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.Column
 import androidx.compose.foundation.layout.RowScope
 import androidx.compose.foundation.layout.fillMaxSize
 import androidx.compose.foundation.layout.fillMaxWidth
@@ -15,12 +16,12 @@ import androidx.compose.foundation.layout.size
 import androidx.compose.material.BottomNavigation
 import androidx.compose.material.BottomNavigationItem
 import androidx.compose.material3.Icon
-import androidx.compose.material3.MaterialTheme
 import androidx.compose.material3.Scaffold
-import androidx.compose.material3.Text
 import androidx.compose.runtime.Composable
 import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.MutableState
 import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableIntStateOf
 import androidx.compose.runtime.mutableStateOf
 import androidx.compose.runtime.remember
 import androidx.compose.runtime.setValue
@@ -31,11 +32,13 @@ import androidx.compose.ui.focus.FocusRequester
 import androidx.compose.ui.focus.focusRequester
 import androidx.compose.ui.focus.onFocusChanged
 import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.input.key.Key
+import androidx.compose.ui.input.key.key
+import androidx.compose.ui.input.key.onKeyEvent
 import androidx.compose.ui.platform.LocalContext
 import androidx.compose.ui.res.colorResource
 import androidx.compose.ui.res.painterResource
 import androidx.compose.ui.unit.dp
-import androidx.compose.ui.unit.sp
 import androidx.navigation.NavDestination
 import androidx.navigation.NavDestination.Companion.hierarchy
 import androidx.navigation.NavGraph.Companion.findStartDestination
@@ -44,23 +47,33 @@ import androidx.navigation.compose.currentBackStackEntryAsState
 import androidx.navigation.compose.rememberNavController
 import com.vpn.fastestvpnservice.R
 import com.vpn.fastestvpnservice.navigation.BottomBarNavGraphTV
+import com.vpn.fastestvpnservice.navigation.customNavigation
 import com.vpn.fastestvpnservice.sealedClass.BottomBarScreen
-import com.vpn.fastestvpnservice.ui.theme.customTypography2
 import com.vpn.fastestvpnservice.utils.StaticMethods
 import com.vpn.fastestvpnservice.utils.isTablet
 
+val screens = listOf(
+    BottomBarScreen.Home,
+    BottomBarScreen.Settings,
+    BottomBarScreen.Help,
+    BottomBarScreen.Account
+)
 val focusRequesterNav1 = FocusRequester()
+val focusRequesterSettings1 = FocusRequester()
+
+var isHomeScreenPressed: MutableState<Boolean> = mutableStateOf(true)
+var isSettingsScreenPressed: MutableState<Boolean> = mutableStateOf(false)
+var isHelpScreenPressed: MutableState<Boolean> = mutableStateOf(false)
+var isAccountScreenPressed: MutableState<Boolean> = mutableStateOf(false)
+
+
 @Composable
 fun BottomBarMainScreenTV(navHostController: NavHostController, activity: ComponentActivity) {
     val navController1 = rememberNavController()
     var isBottomBarVisible by remember { mutableStateOf(true) }
-
-    val screens = listOf(
-        BottomBarScreen.Home,
-        BottomBarScreen.Settings,
-        BottomBarScreen.Help,
-        BottomBarScreen.Account
-    )
+    var focusRequesterSettings = remember { FocusRequester() }
+    var selectedItemIndex by remember { mutableIntStateOf(0) }
+    var focusRequestersList = remember { List(screens.size) { FocusRequester() } }
 
     navController1.addOnDestinationChangedListener { _,_,_ ->
         isBottomBarVisible = navController1.currentDestination?.route in listOf(
@@ -71,7 +84,13 @@ fun BottomBarMainScreenTV(navHostController: NavHostController, activity: Compon
         modifier = Modifier.fillMaxSize(),
         bottomBar = {
             if (isBottomBarVisible) {
-                BottomBarTV(navController1, screens)
+                BottomBarTV(
+                    navController1,
+                    screens,
+                    focusRequestersList[selectedItemIndex],
+                    selectedItemIndex,
+                    focusRequestersList
+                )
             }
         },
         content = { padding ->
@@ -94,17 +113,24 @@ fun BottomBarMainScreenTV(navHostController: NavHostController, activity: Compon
 }
 
 @Composable
-fun BottomBarTV(navHostController: NavHostController, screens: List<BottomBarScreen>) {
+fun BottomBarTV(
+    navHostController: NavHostController,
+    screens: List<BottomBarScreen>,
+    focusRequester: FocusRequester,
+    selectedItemIndex: Int,
+    focusRequestersList: List<FocusRequester>
+) {
 
     val context = LocalContext.current
     val navBackStackEntry = navHostController.currentBackStackEntryAsState()
-    val currentDestination = navBackStackEntry.value?.destination
-    Log.d("currentRoute -> BB ", currentDestination.toString())
+    var currentDestination = navBackStackEntry.value?.destination
+    Log.d("currentRoute -> BB ", currentDestination?.route.toString())
 
-    Column(
-        modifier = Modifier,
-        verticalArrangement = Arrangement.Center,
-        horizontalAlignment = Alignment.CenterHorizontally
+    Box(
+        modifier = Modifier
+            .fillMaxWidth()
+            .background(colorResource(id = R.color.background_color_gray)),
+        contentAlignment = Alignment.Center
     ) {
         BottomNavigation (
 //        backgroundColor = MaterialTheme.colorScheme.onBackground,
@@ -113,32 +139,46 @@ fun BottomBarTV(navHostController: NavHostController, screens: List<BottomBarScr
 //        contentColor = Color.Gray,
             modifier = Modifier
                 .height(if (StaticMethods.isTV(context)) 60.dp else if (isTablet()) 150.dp else 110.dp)
-                .fillMaxWidth(fraction = 1f)
-//                .background(Color.LightGray)
+                .fillMaxWidth(fraction = 0.5f)
+                .background(Color.LightGray)
 
         ) {
-            screens.forEach { screen ->
+            screens.forEachIndexed { index, screen ->
                 AddItemTV(
                     screen = screen,
                     currentDestination = currentDestination,
-                    navHostController = navHostController
+                    navHostController = navHostController,
+                    index,
+                    focusRequester,
+                    selectedItemIndex
                 )
             }
         }
     }
+
+
+    LaunchedEffect(key1 = Unit) {
+//    focusRequesterNav1.requestFocus()
+//        focusRequestersList[selectedItemIndex].requestFocus()
+    }
 }
 
+
+
 @Composable
 fun RowScope.AddItemTV(
     screen: BottomBarScreen,
     currentDestination: NavDestination?,
-    navHostController: NavHostController
+    navHostController: NavHostController,
+    index: Int,
+    focusRequester: FocusRequester,
+    selectedItemIndex: Int
 ) {
     var isClicked by remember { mutableStateOf(false) }
     var isFocused by remember { mutableStateOf(false) }
     val route = currentRouteTV(navController = navHostController)
     val context = LocalContext.current
-    Log.d("currentRoute -> ", route.toString())
+//    Log.d("currentRoute -> ", route.toString())
 
     if (isClicked) {
         Log.d("test_bottom_navbar",
@@ -151,95 +191,153 @@ fun RowScope.AddItemTV(
             )
 
             LaunchedEffect(Unit) {
-                navHostController.navigate(screen.route) {
+                navHostController.navigate(screen.route)
+                {
                     popUpTo(
                         navHostController.graph
                             .findStartDestination().id) {
-                        saveState = false
+                        saveState = true
                     }
-                    launchSingleTop = false
+                    launchSingleTop = true
                 }
             }
         }
         isClicked = false
     }
-    BottomNavigationItem(
-        modifier = Modifier
+        BottomNavigationItem(
+            modifier = Modifier
 //            .focusRequester(focusRequesterNav1)
-            .onFocusChanged {
-                isFocused = it.isFocused
-//                isClicked = it.isFocused
-                Log.d("test_bottom_navbar", "onFocusChanged {}")
-            }
-            .background(if (isFocused) Color.LightGray else Color.White)
-        ,
-//        label = {
-//            if (currentDestination?.route == screen.route) {
-//                Text(
-//                    text = screen.title,
-//                    style = MaterialTheme.typography.customTypography2.bodyLarge.copy(
-//                        fontSize = if (isTablet()) 15.sp else 11.sp
-//                    ),
-////                    color = MaterialTheme.colorScheme.tertiary,
-//                    color = colorResource(id = R.color.blue_text),
-//                    )
-//            }
-//            else {
-//                Text(text = screen.title,
-//                    style = MaterialTheme.typography.customTypography2.bodyLarge.copy(
-//                        fontSize = if (isTablet()) 15.sp else 11.sp
-//                    ),
-////                    color = MaterialTheme.colorScheme.onTertiary,
-//                    color = colorResource(id = R.color.dark_blue_gray_text),
-//                    modifier = Modifier.alpha(0.5F)
-//                )
+                .focusRequester(focusRequester)
+//            .onKeyEvent {
+//                if (currentDestination?.route == BottomBarScreen.Home.route) {
+//                    when (it.key) {
+//                        Key.DirectionLeft -> {
+//                            Log.d("test_bottombar", "DirectionLeft from ")
+//                            if (currentDestination?.route == BottomBarScreen.Help.route) {
+//                                Toast
+//                                    .makeText(
+//                                        context, "DirectionLeft from Help", Toast.LENGTH_SHORT
+//                                    )
+//                                    .show()
+////                            screen.route = BottomBarScreen.Settings.route
+//                            }
+//                            true
+//                        }
+//                        else -> { true }
+//                    }
+//                }
+//                false
 //            }
-//        },
-//        alwaysShowLabel = true,
-        selected = currentDestination?.hierarchy?.any{
-                    it.route == screen.route
-        } == true,
-        onClick = {
-            isClicked = true
-            Log.d("test_bottom_navbar", "onCLick = ${screen.route
-            }")
-
-            /* First time currentDestination is different when on BottomBar Item */
+                .onFocusChanged {
+                        isClicked = it.isFocused
+                        isFocused = it.isFocused
 
-        },
-        icon = {
-            val iconWidth = if (StaticMethods.isTV(context)) 55.dp else if (isTablet()) 50.dp else 45.dp
-            val iconHeight = if (StaticMethods.isTV(context)) 55.dp else if (isTablet()) 44.dp else 39.dp
-            if (currentDestination?.route == screen.route) {
-                Icon(
-                    painter = painterResource(id = screen.icon),
-                    contentDescription = "Navigation Icon",
-//                    tint = MaterialTheme.colorScheme.tertiary,
-                    tint = colorResource(id = R.color.blue_text),
-                    modifier = Modifier
-                        .size(iconWidth, iconHeight)
-                        .padding(top = 9.dp, bottom = if (isTablet()) 6.dp else 4.dp)
+//                    Toast
+//                        .makeText(
+//                            context, "index = $index", Toast.LENGTH_SHORT
+//                        )
+//                        .show()
+                    Log.d(
+                        "test_bottom_navbar",
+                        "onFocusChanged: ${currentDestination?.route} ${screen.route}"
+                    )
+//                if (currentDestination?.route == BottomBarScreen.Home.route) {
+//                    when (screen.route) {
+//                            BottomBarScreen.Home.route -> {
+//                                isFocused = it.isFocused
+//                                if (isFocused) {
+//                                    Toast.makeText(
+//                                        context, screen.route, Toast.LENGTH_SHORT
+//                                    ).show()
+//                                }
+//                            }
+////                            BottomBarScreen.Settings.route -> {
+////                                if (isFocused) {
+////                                    Toast.makeText(
+////                                        context, screen.route, Toast.LENGTH_SHORT
+////                                    ).show()
+////                                }
+////                            }
+////                            BottomBarScreen.Help.route -> {
+////                                if (isFocused) {
+////                                    Toast.makeText(
+////                                        context, screen.route, Toast.LENGTH_SHORT
+////                                    ).show()
+////                                }
+////                            }
+////                            BottomBarScreen.Account.route -> {
+////                                if (isFocused) {
+////                                    Toast.makeText(
+////                                        context, screen.route, Toast.LENGTH_SHORT
+////                                    ).show()
+////                                }
+////                            }
+//                        }
+//                }
+//                else {
+//                    isFocused = it.isFocused
+//                }
+                }
+                .focusable()
+                .background(if (isFocused) Color.LightGray else colorResource(id = R.color.background_color_gray)),
+            selected = currentDestination?.hierarchy?.any {
+                it.route == screen.route
+            } == true,
+            onClick = {
+//                isClicked = true
+//                selectedItemIndex = index
 
-                )
-            }
-            else {
-                Icon(
-                    painter = painterResource(id = screen.icon),
-                    contentDescription = "Navigation Icon",
+                when (index) {
+                    0 -> {
+                        isHomeScreenPressed.value = true
+                    }
+                    1 -> {
+                        isSettingsScreenPressed.value = true
+                    }
+                    2 -> {
+                        isHelpScreenPressed.value = true
+                    }
+                    3 -> {
+                        isAccountScreenPressed.value = true
+                    }
+                }
+                /* First time currentDestination is different when on BottomBar Item */
+            },
+            icon = {
+                val iconWidth =
+                    if (StaticMethods.isTV(context)) 55.dp else if (isTablet()) 50.dp else 45.dp
+                val iconHeight =
+                    if (StaticMethods.isTV(context)) 55.dp else if (isTablet()) 44.dp else 39.dp
+                if (currentDestination?.route == screen.route) {
+                    Icon(
+                        painter = painterResource(id = screen.icon),
+                        contentDescription = "Navigation Icon",
+//                    tint = MaterialTheme.colorScheme.tertiary,
+                        tint = colorResource(id = R.color.blue_text),
+                        modifier = Modifier
+                            .size(iconWidth, iconHeight)
+                            .padding(top = 9.dp, bottom = if (isTablet()) 6.dp else 4.dp)
+                    )
+                } else {
+                    Icon(
+                        painter = painterResource(id = screen.icon),
+                        contentDescription = "Navigation Icon",
 //                    tint = MaterialTheme.colorScheme.onTertiary,
-                    tint = colorResource(id = R.color.dark_blue_gray_text),
-                    modifier = Modifier
-                        .size(iconWidth, iconHeight)
-                        .padding(top = 9.dp, bottom = if (isTablet()) 6.dp else 4.dp)
-                        .alpha(0.5F))
-            }
+                        tint = colorResource(id = R.color.dark_blue_gray_text),
+                        modifier = Modifier
+                            .size(iconWidth, iconHeight)
+                            .padding(top = 9.dp, bottom = if (isTablet()) 6.dp else 4.dp)
+                            .alpha(0.5F)
+                    )
+                }
 
-        },
+            },
 //        unselectedContentColor = MaterialTheme.colorScheme.onBackground,
 //        selectedContentColor = MaterialTheme.colorScheme.onBackground
-        unselectedContentColor = colorResource(id = R.color.white),
-        selectedContentColor = colorResource(id = R.color.white),
-    )
+            unselectedContentColor = colorResource(id = R.color.white),
+            selectedContentColor = colorResource(id = R.color.white),
+        )
+
 }
 
 @Composable

+ 16 - 17
app/src/main/java/com/vpn/fastestvpnservice/screensTV/HelpScreenTV.kt

@@ -65,10 +65,7 @@ import com.vpn.fastestvpnservice.sealedClass.Screen
 fun HelpTV(navHostController: NavHostController) {
     val focusRequester1 = remember { FocusRequester() }
     val focusRequester2 = remember { FocusRequester() }
-
-    LaunchedEffect(key1 = Unit) {
-        focusRequester1.requestFocus()
-    }
+    val context = LocalContext.current
 
     CompositionLocalProvider(
         LocalOverscrollConfiguration provides null
@@ -87,6 +84,13 @@ fun HelpTV(navHostController: NavHostController) {
             window.navigationBarColor = Color.Transparent.toArgb()
             WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = !isDarkTheme.value
 
+            if (isHelpScreenPressed.value) {
+                LaunchedEffect(Unit) {
+                    focusRequester1.requestFocus()
+                }
+                isHelpScreenPressed.value = false
+            }
+
             Column(
                 verticalArrangement = Arrangement.Top,
                 horizontalAlignment = Alignment.Start,
@@ -101,7 +105,8 @@ fun HelpTV(navHostController: NavHostController) {
                     color = MaterialTheme.colorScheme.inversePrimary
                 )
                 Spacer(modifier = Modifier.height(22.dp))
-                AddRowTV(icon = R.drawable.faq3x,
+                AddRowTV(
+                    icon = R.drawable.faq3x,
                     text = "FAQ", navHostController = navHostController,
                     topPadding = 22.dp,
                     focusRequester1 = focusRequester1,
@@ -191,19 +196,13 @@ fun ColumnScope.AddRowTV(
                 isRowFocused = it.isFocused
             }
             .focusable()
-//            .pointerInput(Unit) {
-//                detectTapGestures {
-//                    Log.d("test_row", "Clicked Row ${onClick().toString()}")
-//                    onClick()
-//                }
+//            .clickable {
+//                Log.d("test_row", "Clicked Row ${onClick.toString()}")
+//                Toast.makeText(
+//                    context, text, Toast.LENGTH_SHORT
+//                ).show()
+////                onClick()
 //            }
-            .clickable {
-                Log.d("test_row", "Clicked Row ${onClick.toString()}")
-                Toast.makeText(
-                    context, text, Toast.LENGTH_SHORT
-                ).show()
-//                onClick()
-            }
         ,
         horizontalArrangement = Arrangement.Start,
         verticalAlignment = Alignment.CenterVertically

+ 83 - 30
app/src/main/java/com/vpn/fastestvpnservice/screensTV/HomeScreenTV.kt

@@ -4,6 +4,7 @@ import android.content.Context
 import android.content.Intent
 import android.util.Log
 import android.widget.Toast
+import androidx.activity.compose.BackHandler
 import androidx.compose.foundation.BorderStroke
 import androidx.compose.foundation.Image
 import androidx.compose.foundation.background
@@ -54,8 +55,10 @@ import androidx.compose.ui.graphics.Color
 import androidx.compose.ui.graphics.ColorFilter
 import androidx.compose.ui.graphics.painter.Painter
 import androidx.compose.ui.input.key.Key
+import androidx.compose.ui.input.key.KeyEventType
 import androidx.compose.ui.input.key.key
 import androidx.compose.ui.input.key.onKeyEvent
+import androidx.compose.ui.input.key.type
 import androidx.compose.ui.input.pointer.pointerInput
 import androidx.compose.ui.layout.ContentScale
 import androidx.compose.ui.platform.LocalContext
@@ -108,10 +111,19 @@ fun HomeTV(navHostController: NavHostController) {
     val focusRequester3 = remember { FocusRequester() }
     var isButtonFocused by remember { mutableStateOf(false) }
 
-    LaunchedEffect(key1 = Unit) {
-        focusRequester1.requestFocus()
+    if (isHomeScreenPressed.value) {
+        LaunchedEffect(key1 = Unit) {
+            focusRequester1.requestFocus()
+        }
+        isHomeScreenPressed.value = false
     }
 
+//    BackHandler {
+//        Toast.makeText(
+//            context, "BackHandler Home TV", Toast.LENGTH_SHORT
+//        ).show()
+//    }
+
     Column(
         modifier = Modifier
             .background(colorResource(id = R.color.background_color_gray))
@@ -345,14 +357,26 @@ fun HomeTV(navHostController: NavHostController) {
                         .onKeyEvent {
                             when (it.key) {
                                 Key.DirectionDown -> {
-                                    Log.d("test_settings_keys","DirectionDown")
-                                    Toast.makeText(
-                                        context, "DirectionDown", Toast.LENGTH_SHORT
-                                    ).show()
-                                    focusRequester2.requestFocus()
+                                    Log.d("test_settings_keys", "DirectionDown")
+                                    Toast
+                                        .makeText(
+                                            context, "DirectionDown", Toast.LENGTH_SHORT
+                                        )
+                                        .show()
+                                    if (it.type == KeyEventType.KeyDown) {
+                                        Toast
+                                            .makeText(
+                                                context, "KeyDown", Toast.LENGTH_SHORT
+                                            )
+                                            .show()
+                                        focusRequester2.requestFocus()
+                                    }
+                                    true
+                                }
+
+                                else -> {
                                     true
                                 }
-                                else -> { false }
                             }
                         }
                         .focusRequester(focusRequester1)
@@ -532,23 +556,35 @@ fun HomeTV(navHostController: NavHostController) {
                         .padding(horizontal = 20.dp, vertical = 5.dp)
                         .padding(top = 0.dp)
                         .height(60.dp)
-                        .onKeyEvent {
-                            when (it.key) {
-                                Key.DirectionDown -> {
-                                    Log.d("test_settings_keys", "DirectionDown")
-                                    Toast
-                                        .makeText(
-                                            context, "DirectionDown", Toast.LENGTH_SHORT
-                                        )
-                                        .show()
-//                                    focusRequesterNav1.requestFocus()
-                                    true
-                                }
-                                else -> {
-                                    false
-                                }
-                            }
-                        }
+//                        .onKeyEvent {
+////                            when (it.key) {
+////                                Key.DirectionDown -> {
+////                                    Log.d("test_settings_keys", "DirectionDown")
+////                                    Toast
+////                                        .makeText(
+////                                            context, "DirectionDown", Toast.LENGTH_SHORT
+////                                        )
+////                                        .show()
+////                                    customNavigation(navHostController, BottomBarScreen.Settings)
+//////                                    focusRequesterNav1.requestFocus()
+////                                    true
+////                                }
+////                                Key.DirectionRight -> { true}
+////                                Key.DirectionLeft -> { true}
+////                                else -> { false }
+////                            }
+//                                if (it.type == KeyEventType.KeyDown && it.key == Key.DirectionDown) {
+//                                    Toast
+//                                        .makeText(
+//                                            context, "KeyDown & DirectionDown", Toast.LENGTH_SHORT
+//                                        )
+//                                        .show()
+////                                    customNavigation(navHostController, BottomBarScreen.Home)
+////                                    focusRequesterNav1.requestFocus()
+////                                    focusRequestersList[selectedItemIndex.value].requestFocus()
+//                                    true
+//                                } else { true }
+//                        }
                         .onFocusChanged {
                             isLayoutFocused = it.isFocused
                         }
@@ -557,8 +593,10 @@ fun HomeTV(navHostController: NavHostController) {
                         .clickable(
                             indication = null,
                             interactionSource = remember { MutableInteractionSource() }
-                            ) {
-                            Toast.makeText(context, "See All Pressed", Toast.LENGTH_SHORT).show()
+                        ) {
+                            Toast
+                                .makeText(context, "See All Pressed", Toast.LENGTH_SHORT)
+                                .show()
                         }
                         .border(
                             border = BorderStroke(2.dp, color),
@@ -682,14 +720,29 @@ fun BoxScope.AddRowSmartTV(
         ) {
             ClickableText(
                 modifier = Modifier
+//                    .onKeyEvent {
+//                        when (it.key) {
+//                            Key.DirectionLeft -> {
+//                                Log.d("test_settings_keys","DirectionDown")
+//                                Toast.makeText(
+//                                    context, "DirectionLeft", Toast.LENGTH_SHORT
+//                                ).show()
+////                                focusRequester2.requestFocus()
+//                                true
+//                            }
+//                            else -> { true }
+//                        }
+//                    }
                     .focusRequester(focusRequester2)
                     .onFocusChanged {
                         isButtonFocused = it.isFocused
                     }
                     .clickable {
-                        Toast.makeText(
-                            context, "Change Pressed()", Toast.LENGTH_SHORT
-                        ).show()
+                        Toast
+                            .makeText(
+                                context, "Change Pressed()", Toast.LENGTH_SHORT
+                            )
+                            .show()
                     }
                     .focusable()
                 ,

+ 28 - 13
app/src/main/java/com/vpn/fastestvpnservice/screensTV/SettingsScreenTV.kt

@@ -8,6 +8,7 @@ import android.os.Bundle
 import android.os.Handler
 import android.util.Log
 import android.widget.Toast
+import androidx.activity.compose.BackHandler
 import androidx.compose.foundation.ExperimentalFoundationApi
 import androidx.compose.foundation.Image
 import androidx.compose.foundation.LocalOverscrollConfiguration
@@ -85,6 +86,7 @@ import androidx.compose.ui.unit.sp
 import androidx.core.content.ContextCompat
 import androidx.lifecycle.viewmodel.compose.viewModel
 import androidx.navigation.NavHostController
+import androidx.navigation.compose.currentBackStackEntryAsState
 import com.vpn.fastestvpnservice.R
 import com.vpn.fastestvpnservice.beans.isDarkTheme
 import com.vpn.fastestvpnservice.beans.themesList
@@ -114,6 +116,21 @@ fun SettingsTV(navHostController: NavHostController) {
     val focusRequester4 = remember { FocusRequester() }
     val focusRequester5 = remember { FocusRequester() }
 
+    if (isSettingsScreenPressed.value) {
+        LaunchedEffect(Unit) {
+            focusRequester1.requestFocus()
+        }
+        isSettingsScreenPressed.value = false
+    }
+    val navBackStackEntry = navHostController.currentBackStackEntryAsState()
+
+    BackHandler {
+        Toast.makeText(
+            context, "BackHandler Settings TV", Toast.LENGTH_SHORT
+        ).show()
+//        customNavigation(navHostController, BottomBarScreen.Settings)
+    }
+
     CompositionLocalProvider(
         LocalOverscrollConfiguration provides null
     ) {
@@ -129,9 +146,7 @@ fun SettingsTV(navHostController: NavHostController) {
             window.statusBarColor = Color.Transparent.toArgb()
             window.navigationBarColor = Color.Transparent.toArgb()
 
-            LaunchedEffect(Unit) {
-                focusRequester1.requestFocus()
-            }
+
 
             Column(
                 verticalArrangement = Arrangement.Top,
@@ -475,16 +490,16 @@ fun ColumnScope.AddRowSettingsColumnTV(
                         focusRequester2.requestFocus()
                         true
                     }
-//                    Key.DirectionLeft -> {
-//                        Log.d("test_settings_keys", "DirectionLeft")
-//                        Toast
-//                            .makeText(
-//                                context, "DirectionUp", Toast.LENGTH_SHORT
-//                            )
-//                            .show()
-//                        customNavigation(navHostController = navHostController, screen = BottomBarScreen.Home)
-//                        true
-//                    }
+                    Key.DirectionLeft -> {
+                        Log.d("test_settings_keys", "DirectionLeft")
+                        Toast
+                            .makeText(
+                                context, "DirectionLeft", Toast.LENGTH_SHORT
+                            )
+                            .show()
+                        customNavigation(navHostController = navHostController, screen = BottomBarScreen.Settings)
+                        true
+                    }
 //
 //                    Key.DirectionRight -> {
 //                        Log.d("test_settings_keys", "DirectionRight")

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

@@ -85,11 +85,11 @@ fun SplashTV(navHostController: NavHostController) {
 //                        serverListViewModelSplash.setCountryData()
 //                        splashViewModel.serverDataApi()
                 navHostController.popBackStack()
-                navHostController.navigate(ScreenTV.LoginTV.route)
+                navHostController.navigate(ScreenTV.BottomBarTV.route)
             } else {
 //            Toast.makeText(context, "else $isLoggedIn", Toast.LENGTH_SHORT).show()
                 navHostController.popBackStack()
-                navHostController.navigate(ScreenTV.LoginTV.route)
+                navHostController.navigate(ScreenTV.BottomBarTV.route)
             }
 
         }

+ 1 - 1
app/src/main/java/com/vpn/fastestvpnservice/sealedClass/BottomBarScreen.kt

@@ -12,7 +12,7 @@ import androidx.compose.ui.res.painterResource
 import com.vpn.fastestvpnservice.R
 
 sealed class BottomBarScreen(
-    val route: String,
+    var route: String,
     val title: String,
     val icon: Int,
     var isTrue: Boolean = false