Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: Resolve keyboard visibility issue #587

Merged
merged 1 commit into from
Dec 29, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/src/main/java/org/fossasia/badgemagic/ui/DrawerActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -160,6 +161,7 @@ class DrawerActivity : BaseActivity(), NavigationView.OnNavigationItemSelectedLi
}

override fun onDrawerOpened(drawerView: View) {
hideKeyboard()
}
})

Expand All @@ -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
Expand Down