1
0
Fork 0

Fixes #430 - Hides software keyboard when you background the app

master
Jeff Boek 2019-02-12 16:17:08 -08:00
parent 5addcca524
commit f37250127a
1 changed files with 15 additions and 0 deletions

View File

@ -4,10 +4,12 @@
package org.mozilla.fenix
import android.app.Activity
import android.content.Context
import android.os.Bundle
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
@ -67,6 +69,19 @@ open class HomeActivity : AppCompatActivity() {
super.onBackPressed()
}
override fun onPause() {
super.onPause()
hideSoftwareKeyboard()
}
private fun hideSoftwareKeyboard() {
(getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager).apply {
currentFocus?.also {
this.hideSoftInputFromWindow(it.windowToken, 0)
}
}
}
private fun openToBrowser() {
val sessionId = SafeIntent(intent).getStringExtra(IntentProcessor.ACTIVE_SESSION_ID)
val host = supportFragmentManager.findFragmentById(R.id.container) as NavHostFragment