diff --git a/app/src/main/java/org/fossasia/badgemagic/ui/DrawerActivity.kt b/app/src/main/java/org/fossasia/badgemagic/ui/DrawerActivity.kt index 972cc2a18..ba4d3aafd 100644 --- a/app/src/main/java/org/fossasia/badgemagic/ui/DrawerActivity.kt +++ b/app/src/main/java/org/fossasia/badgemagic/ui/DrawerActivity.kt @@ -12,6 +12,7 @@ import android.os.Bundle import android.view.Menu import android.view.MenuItem import android.view.View +import android.view.inputmethod.InputMethodManager import android.widget.Toast import androidx.appcompat.app.ActionBarDrawerToggle import androidx.core.app.ActivityCompat @@ -160,6 +161,7 @@ class DrawerActivity : BaseActivity(), NavigationView.OnNavigationItemSelectedLi } override fun onDrawerOpened(drawerView: View) { + hideKeyboard() } }) @@ -183,6 +185,14 @@ class DrawerActivity : BaseActivity(), NavigationView.OnNavigationItemSelectedLi } } + private fun hideKeyboard() { + val view = this.currentFocus + view?.let { v -> + val imm = getSystemService(Activity.INPUT_METHOD_SERVICE) as? InputMethodManager + imm?.hideSoftInputFromWindow(v.windowToken, 0) + } + } + fun switchToDrawLayout() { drawerCheckedID = R.id.draw viewModel.swappingOrientation = true