Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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)
## Usage

Call `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()
```

Sample

## 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 at

Unless 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.