Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: dismiss keyboard at back press on search page #5828

Merged
merged 1 commit into from
Mar 28, 2024
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.github.libretube.extensions

import android.view.View
import android.view.ViewGroup
import androidx.core.view.children

fun View.anyChildFocused(): Boolean {
if (isFocused) return true

if (this is ViewGroup) {
return children.any { it.anyChildFocused() }
}

return false
}

Check failure on line 15 in app/src/main/java/com/github/libretube/extensions/AnyChildFocused.kt

View workflow job for this annotation

GitHub Actions / Check Code Quality

[ktlint] reported by reviewdog 🐶 File must end with a newline (\n) Raw Output: app/src/main/java/com/github/libretube/extensions/AnyChildFocused.kt:15:1: error: File must end with a newline (\n) (standard:final-newline)
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.github.libretube.constants.IntentData
import com.github.libretube.constants.PreferenceKeys
import com.github.libretube.databinding.ActivityMainBinding
import com.github.libretube.extensions.anyChildFocused
import com.github.libretube.extensions.toID
import com.github.libretube.helpers.NavBarHelper
import com.github.libretube.helpers.NavigationHelper
Expand Down Expand Up @@ -170,6 +171,11 @@
onUserLeaveHint()
}

R.id.searchFragment -> {
if (searchView.anyChildFocused()) searchView.clearFocus()

Check failure on line 175 in app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt

View workflow job for this annotation

GitHub Actions / Check Code Quality

[ktlint] reported by reviewdog 🐶 Expected a newline Raw Output: app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt:175:55: error: Expected a newline (standard:if-else-wrapping)

Check failure on line 175 in app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt

View workflow job for this annotation

GitHub Actions / Check Code Quality

[ktlint] reported by reviewdog 🐶 Missing { ... } Raw Output: app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt:175:55: error: Missing { ... } (standard:multiline-if-else)
else navController.popBackStack()

Check failure on line 176 in app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt

View workflow job for this annotation

GitHub Actions / Check Code Quality

[ktlint] reported by reviewdog 🐶 Expected a newline Raw Output: app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt:176:26: error: Expected a newline (standard:if-else-wrapping)

Check failure on line 176 in app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt

View workflow job for this annotation

GitHub Actions / Check Code Quality

[ktlint] reported by reviewdog 🐶 Missing { ... } Raw Output: app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt:176:26: error: Missing { ... } (standard:multiline-if-else)
}

R.id.searchResultFragment -> {
navController.popBackStack(R.id.searchFragment, true) ||
navController.popBackStack()
Expand Down
Loading