Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/guilhe/keyboardstateevents
LiveData notification when keyboard opens or closes, plus some handy extension functions
https://github.com/guilhe/keyboardstateevents
android androidx keyboard kotlin lifecycle livedata
Last synced: 3 months ago
JSON representation
LiveData notification when keyboard opens or closes, plus some handy extension functions
- Host: GitHub
- URL: https://github.com/guilhe/keyboardstateevents
- Owner: GuilhE
- License: apache-2.0
- Created: 2020-04-01T19:19:55.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-08-29T17:15:57.000Z (over 2 years ago)
- Last Synced: 2024-05-11T10:10:55.205Z (9 months ago)
- Topics: android, androidx, keyboard, kotlin, lifecycle, livedata
- Language: Kotlin
- Homepage: https://guilhe.github.io/KeyboardStateEvents/
- Size: 902 KB
- Stars: 149
- Watchers: 4
- Forks: 10
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# KeyboardStateEvents
[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-KeyboardStateEvents-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/8092)Get notified through LiveData when Keyboard is open or closed
## Installation
KeyboardStateEvents is distributed through [Maven Central](https://search.maven.org/artifact/com.github.guilhe/keyboard-state-events) and [Jitpack](https://jitpack.io/#GuilhE/KeyboardStateEvents).
```groovy
implementation 'com.github.guilhe:keyboard-state-events:${LATEST_VERSION}'
```
[![Maven Central](https://img.shields.io/maven-central/v/com.github.guilhe/keyboard-state-events.svg)](https://search.maven.org/search?q=g:com.github.guilhe%20AND%20keyboard-state-events)
## UsageCall `bindKeyboardStateEvents()` in you `AppCompatActivity` or `FragmentActivity` and observe `KeyboardStateLiveData.state` to get notified:
```java
class MainActivity : AppCompatActivity() {override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
...
KeyboardStateLiveData.state.observe(this, Observer {...})
bindKeyboardStateEvents()
}
}
```
Just that and you're done! 😎Also, some handy extension functions:
```java
ComponentActivity.toggleKeyboard()
ComponentActivity.dismissKeyboard()
ComponentActivity.isKeyboardOpen()
ViewGroup.isKeyboardOpen()
```
![]()
## Dependencies
- [androidx.lifecycle:lifecycle-livedata-ktx](https://developer.android.com/jetpack/androidx/releases/lifecycle)
- [androidx.activity:activity-ktx](https://developer.android.com/jetpack/androidx/releases/activity)## Bugs and Feedback
For bugs, questions and discussions please use the [Github Issues](https://github.com/GuilhE/KeyboardStateEvents/issues).
## LICENSE
Copyright (c) 2020-present GuilhE
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License atUnless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.