Skip to content

Commit

Permalink
Fix #5406: Migrate keyboard hiding functionality (#5463)
Browse files Browse the repository at this point in the history
<!-- READ ME FIRST: Please fill in the explanation section below and
check off every point from the Essential Checklist! -->
## Explanation
Fixes #5406
    
Replaced deprecated InputMethodManager.SHOW_FORCED with '0' flag to
ensure compatibility with SDK 33.
    Updated the following files:
	    StateFragmentPresenter.kt
	    SurveyFragmentPresenter.kt
	    QuestionPlayerFragmentPresenter.kt
These changes ensure that the keyboard hides as expected across the app
scenarios, maintaining the intended behavior.

## Essential Checklist
<!-- Please tick the relevant boxes by putting an "x" in them. -->
- [x] The PR title and explanation each start with "Fix #bugnum: " (If
this PR fixes part of an issue, prefix the title with "Fix part of
#bugnum: ...".)
- [ ] Any changes to
[scripts/assets](https://github.com/oppia/oppia-android/tree/develop/scripts/assets)
files have their rationale included in the PR explanation.
- [x] The PR follows the [style
guide](https://github.com/oppia/oppia-android/wiki/Coding-style-guide).
- [x] The PR does not contain any unnecessary code changes from Android
Studio
([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#undo-unnecessary-changes)).
- [x] The PR is made from a branch that's **not** called "develop" and
is up-to-date with "develop".
- [x] The PR is **assigned** to the appropriate reviewers
([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#clarification-regarding-assignees-and-reviewers-section)).

---------

Co-authored-by: Mr. 17 <[email protected]>
Co-authored-by: Adhiambo Peres <[email protected]>
  • Loading branch information
3 people authored Jul 16, 2024
1 parent 6e12374 commit 436cf9e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -438,9 +438,8 @@ class StateFragmentPresenter @Inject constructor(
val inputManager: InputMethodManager =
activity.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
inputManager.hideSoftInputFromWindow(
fragment.view!!.windowToken,
@Suppress("DEPRECATION") // TODO(#5406): Use the correct constant value here.
InputMethodManager.SHOW_FORCED
fragment.requireView().windowToken,
0 // Flag value to force hide the keyboard when possible.
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,8 @@ class SurveyFragmentPresenter @Inject constructor(
val inputManager: InputMethodManager =
activity.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
inputManager.hideSoftInputFromWindow(
fragment.view!!.windowToken,
@Suppress("DEPRECATION") // TODO(#5406): Use the correct constant value here.
InputMethodManager.SHOW_FORCED
fragment.requireView().windowToken,
0 // Flag value to force hide the keyboard when possible.
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,8 @@ class QuestionPlayerFragmentPresenter @Inject constructor(
val inputManager: InputMethodManager =
activity.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
inputManager.hideSoftInputFromWindow(
fragment.view!!.windowToken,
@Suppress("DEPRECATION") // TODO(#5406): Use the correct constant value here.
InputMethodManager.SHOW_FORCED
fragment.requireView().windowToken,
0 // Flag value to force hide the keyboard when possible.
)
}

Expand Down

0 comments on commit 436cf9e

Please sign in to comment.