mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-02 03:40:16 +00:00
Fixes #1632: Hides keyboard on exit, shows on entry
This commit is contained in:
parent
493bab42a4
commit
d9bc4bf502
@ -4,6 +4,7 @@
|
||||
|
||||
package org.mozilla.fenix
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
@ -11,6 +12,7 @@ import android.os.Bundle
|
||||
import android.preference.PreferenceManager
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.navigation.fragment.NavHostFragment
|
||||
@ -105,6 +107,8 @@ open class HomeActivity : AppCompatActivity() {
|
||||
navHost.navController.popBackStack(R.id.browserFragment, true)
|
||||
allSessionsRemoved = false
|
||||
}
|
||||
|
||||
showSoftwareKeyboardIfNecessary()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
@ -140,6 +144,27 @@ open class HomeActivity : AppCompatActivity() {
|
||||
super.onBackPressed()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
hideSoftwareKeyboardIfNecessary()
|
||||
}
|
||||
|
||||
private fun showSoftwareKeyboardIfNecessary() {
|
||||
(getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager).apply {
|
||||
currentFocus?.also {
|
||||
this.showSoftInput(it, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun hideSoftwareKeyboardIfNecessary() {
|
||||
(getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager).apply {
|
||||
currentFocus?.also {
|
||||
this.hideSoftInputFromWindow(it.windowToken, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleCrashIfNecessary(intent: Intent?) {
|
||||
if (intent == null) { return }
|
||||
if (!Crash.isCrashIntent(intent)) { return }
|
||||
|
Loading…
Reference in New Issue
Block a user