Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,11 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener, BiometricCa
hierarchy.any { it.id == destId }

private var lastNavTime = 0L
private fun onNavDestinationSelected(item: MenuItem, navController: NavController): Boolean {
private fun onNavDestinationSelected(
item: MenuItem,
navController: NavController,
navHostFragment: NavHostFragment,
): Boolean {
val currentTime = System.currentTimeMillis()
// safeDebounce: Check if a previous tap happened within the last 400ms
if (currentTime - lastNavTime < 400) return false
Expand All @@ -755,7 +759,13 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener, BiometricCa
val destinationId = item.itemId

// Check if we are already at the selected destination
if (navController.currentDestination?.id == destinationId) return false
if (navController.currentDestination?.id == destinationId) {
if (destinationId == R.id.navigation_search) {
(navHostFragment.childFragmentManager.primaryNavigationFragment as? SearchFragment)
?.focusSearchInput()
}
return false
}

// Make all nav buttons focus on this specific view when nextFocusRightId
val targetView = when (destinationId) {
Expand Down Expand Up @@ -1704,7 +1714,8 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener, BiometricCa
setOnItemSelectedListener { item ->
onNavDestinationSelected(
item,
navController
navController,
navHostFragment
)
}

Expand Down Expand Up @@ -1732,7 +1743,8 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener, BiometricCa
setOnItemSelectedListener { item ->
onNavDestinationSelected(
item,
navController
navController,
navHostFragment
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ class SearchFragment : BaseFragment<FragmentSearchBinding>(
afterPluginsLoadedEvent -= ::reloadRepos
}

internal fun focusSearchInput() {
binding?.mainSearch?.requestFocusFromTouch()
}

var selectedSearchTypes = mutableListOf<TvType>()
var selectedApis = mutableSetOf<String>()

Expand Down