fix(upload): hide keyboard before navigating to Media License screen

This solves keyboard opened at the License screen issue, if we proceed by pressing next at the Upload Categories screen when the keyboard is opened
This commit is contained in:
Rohit Verma 2025-09-06 22:36:53 +05:30
parent c91475df94
commit 2f0924678c
No known key found for this signature in database

View file

@ -13,6 +13,7 @@ import android.os.Build.VERSION_CODES
import android.os.Bundle import android.os.Bundle
import android.provider.Settings import android.provider.Settings
import android.view.View import android.view.View
import android.view.inputmethod.InputMethodManager
import android.widget.CheckBox import android.widget.CheckBox
import androidx.activity.OnBackPressedCallback import androidx.activity.OnBackPressedCallback
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
@ -805,6 +806,19 @@ class UploadActivity : BaseActivity(), UploadContract.View, UploadBaseFragment.C
override fun onNextButtonClicked(index: Int) { override fun onNextButtonClicked(index: Int) {
if (index < fragments!!.size - 1) { if (index < fragments!!.size - 1) {
// Hide the keyboard before navigating to Media License screen
val isUploadCategoriesFragment = fragments!!.getOrNull(index)?.let {
it is UploadCategoriesFragment
} ?: false
if (isUploadCategoriesFragment) {
val inputMethodManager = getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
currentFocus?.let { focusedView ->
inputMethodManager.hideSoftInputFromWindow(
focusedView.windowToken,
InputMethodManager.HIDE_NOT_ALWAYS
)
}
}
binding.vpUpload.setCurrentItem(index + 1, false) binding.vpUpload.setCurrentItem(index + 1, false)
fragments!![index + 1].onBecameVisible() fragments!![index + 1].onBecameVisible()
(binding.rvThumbnails.layoutManager as LinearLayoutManager) (binding.rvThumbnails.layoutManager as LinearLayoutManager)