mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-27 07:20:30 +05:30
fix keyboard remains on search
This commit is contained in:
parent
ab1576bb2b
commit
4b9f772b62
@ -1,5 +1,7 @@
|
|||||||
package com.github.libretube
|
package com.github.libretube
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.content.Context
|
||||||
import android.content.pm.ActivityInfo
|
import android.content.pm.ActivityInfo
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
@ -10,6 +12,7 @@ import android.os.Bundle
|
|||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.*
|
import android.view.*
|
||||||
|
import android.view.inputmethod.InputMethodManager
|
||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import androidx.appcompat.widget.Toolbar
|
import androidx.appcompat.widget.Toolbar
|
||||||
@ -264,4 +267,17 @@ class MainActivity : AppCompatActivity() {
|
|||||||
window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_VISIBLE or View.SYSTEM_UI_FLAG_LAYOUT_STABLE)
|
window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_VISIBLE or View.SYSTEM_UI_FLAG_LAYOUT_STABLE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
fun Fragment.hideKeyboard() {
|
||||||
|
view?.let { activity?.hideKeyboard(it) }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Activity.hideKeyboard() {
|
||||||
|
hideKeyboard(currentFocus ?: View(this))
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Context.hideKeyboard(view: View) {
|
||||||
|
val inputMethodManager = getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||||
|
inputMethodManager.hideSoftInputFromWindow(view.windowToken, 0)
|
||||||
|
}
|
@ -95,6 +95,7 @@ class PlayerFragment : Fragment() {
|
|||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
hideKeyboard()
|
||||||
videoId = videoId!!.replace("/watch?v=","")
|
videoId = videoId!!.replace("/watch?v=","")
|
||||||
relDownloadVideo = view.findViewById(R.id.relPlayer_download)
|
relDownloadVideo = view.findViewById(R.id.relPlayer_download)
|
||||||
val mainActivity = activity as MainActivity
|
val mainActivity = activity as MainActivity
|
||||||
|
@ -47,6 +47,9 @@ class SearchFragment : Fragment() {
|
|||||||
val recyclerView = view.findViewById<RecyclerView>(R.id.search_recycler)
|
val recyclerView = view.findViewById<RecyclerView>(R.id.search_recycler)
|
||||||
recyclerView.layoutManager = GridLayoutManager(view.context, 1)
|
recyclerView.layoutManager = GridLayoutManager(view.context, 1)
|
||||||
val autoTextView = view.findViewById<AutoCompleteTextView>(R.id.autoCompleteTextView)
|
val autoTextView = view.findViewById<AutoCompleteTextView>(R.id.autoCompleteTextView)
|
||||||
|
autoTextView.requestFocus()
|
||||||
|
val imm = requireContext().getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||||
|
imm!!.showSoftInput(autoTextView, InputMethodManager.SHOW_IMPLICIT)
|
||||||
autoTextView.addTextChangedListener(object : TextWatcher {
|
autoTextView.addTextChangedListener(object : TextWatcher {
|
||||||
override fun beforeTextChanged(
|
override fun beforeTextChanged(
|
||||||
s: CharSequence?,
|
s: CharSequence?,
|
||||||
@ -111,7 +114,6 @@ class SearchFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun Fragment?.runOnUiThread(action: () -> Unit) {
|
private fun Fragment?.runOnUiThread(action: () -> Unit) {
|
||||||
this ?: return
|
this ?: return
|
||||||
if (!isAdded) return // Fragment not attached to an Activity
|
if (!isAdded) return // Fragment not attached to an Activity
|
||||||
|
@ -77,7 +77,7 @@ class Settings : PreferenceFragmentCompat() {
|
|||||||
instance?.summaryProvider = Preference.SummaryProvider<ListPreference> { preference ->
|
instance?.summaryProvider = Preference.SummaryProvider<ListPreference> { preference ->
|
||||||
val text = preference.entry
|
val text = preference.entry
|
||||||
if (TextUtils.isEmpty(text)) {
|
if (TextUtils.isEmpty(text)) {
|
||||||
"Not set"
|
"kavin.rocks (Official)"
|
||||||
} else {
|
} else {
|
||||||
text
|
text
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user