https://github.com/dofire/ScreenEasy
💎A small Android library that provides quick access to screen info without worrying about headache stuffs
https://github.com/dofire/ScreenEasy
android android-app android-application android-development android-library android-screen android-sdk android-ui dimension display kotlin kotlin-android kotlin-library orientation rotation screen utility utility-library
Last synced: 21 days ago
JSON representation
💎A small Android library that provides quick access to screen info without worrying about headache stuffs
- Host: GitHub
- URL: https://github.com/dofire/ScreenEasy
- Owner: dofire
- License: apache-2.0
- Created: 2023-07-09T04:19:55.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-07-31T13:52:15.000Z (almost 2 years ago)
- Last Synced: 2025-03-26T08:47:37.776Z (about 1 month ago)
- Topics: android, android-app, android-application, android-development, android-library, android-screen, android-sdk, android-ui, dimension, display, kotlin, kotlin-android, kotlin-library, orientation, rotation, screen, utility, utility-library
- Language: Kotlin
- Homepage:
- Size: 138 KB
- Stars: 13
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ScreenEasy 💎 ScreenEz
🔥 An Android library that provides quick access to screen attributes like: `screenSize`, `cutout`, `status/navbar`, `safeArea`, ... without worrying about headache, deprecated stuffs.
| what we want | reality |
| :-: | :-: |
||
|
[
](https://www.android.com)
[](https://android-arsenal.com/api?level=21)
[]()
[](https://www.apache.org/licenses/LICENSE-2.0)
## Table of Contents 📝
> 1. [Install](#install)
> 2. [Usage](#usage)
> 3. [Contribution guide](#contribution_guide)
> 4. [WIP Note](#note) 🚧
> 5. [License](#license)
## I. Install
Ensure your app’s minimum SDK version is 21+ and `mavenCentral()` included1. Ensure your app’s minimum SDK version is 21+. This is declared in the module-level `build.gradle` file
```gradle
android {
defaultConfig {
...
minSdk 21
}
```2. Ensure the `mavenCentral()` repository is declared in the project-level `build.gradle` or `setting.gradle` file:
build.gradle (project-level)
```gradle
allprojects {
repositories {
mavenCentral()
...
}
...
}
```
Alternative (In case "allprojects" not found). go to settings.gradle
```gradle
pluginManagement {
repositories {
...
mavenCentral()
}
}
dependencyResolutionManagement {
...
repositories {
...
mavenCentral()
}
}
```
Declare the dependencies in the module-level `build.gradle` file 🍀
```gradle
dependencies {
implementation "io.github.torrydo:screen-easy:"
}
```## II. Usage
1, Firstly, init `ScreenEz.with(context)` anywhere in your project> Optional: call `ScreenEz.refresh()` when configuration change (orientation/rotation change...)
> If you are developing a library that use `ScreenEasy` internally, please create an instance of `ScreenEasy()` instead. You can find the reason [here](https://github.com/TorryDo/ScreenEasy/issues/1)
Sample
```java
// consider using this approach instead if you are developing a library/submodule
val screenEasy = ScreenEasy()
screenEasy.with(context)
```2, That's it, no more step needed, enjoy! 💖
Java
| API | Return | Description |
| :- | :- | :- |
| `with(context)` | None | Call this function one time before any other function to setup properly. Calling multiple times is okay, but unnecessary |
| `refresh()` | None | Refresh attributes, call when configuration change, rotation, ... |
| `getNavBarPadding()` | ScreenPadding | Represent screen padding of system bar for navigation |
| `getStatusBarPadding()` | ScreenPadding | Represent screen padding of status bar. |
| `getCutoutPadding()` | ScreenPadding | Represent screen padding of cutout for the notch, or smth similar |
| `getFullWidth()` | Int | Width of the screen in pixel |
| `getFullHeight()` | Int | Height of the screen in pixel |
| `getFullSize()` | Size | Size of the screen in pixel |
| `isButtonsNavigation()` | Boolean | True if buttons navigation is being used |
| `isGestureNavigation()` | Boolean | True if gesture navigation is being used |
| `getSafeArea()` | ScreenArea | The area of the screen that is not obscured by the navigation bar, status bar, or other system UI elements. |
| `getSafeScreenPadding()` | ScreenPadding | Returns the safe screen padding |
| `getSafePaddingLeft()` | Int | Padding for LEFT edge to avoid overlap with system UI |
| `getSafePaddingRight()` | Int | Padding for RIGHT edge to avoid overlap with system UI |
| `getSafePaddingTop()` | Int | Padding for TOP edge to avoid overlap with system UI |
| `getSafePaddingBottom()` | Int | Padding for BOTTOM edge to avoid overlap with system UI |
| `getSafeWidth()` | Int | The width of the screen after subtracting the system bar on the left and right sides |
| `getSafeHeight()` | Int | The height of the screen after subtracting the system bar on the top and bottom sides |
| `getSafeSize()` | Size | The Size(width, height) of the screen after subtracting the system bar on all sides |
| `getStatusBarHeight()` | Int | status bar height (pixel unit) |
| `getNavBarHeight()` | Int | navigation bar height (both gesture and buttons in pixel unit) |
| `isPortrait()` | Boolean | True if screen is in portrait mode |
| `getScreenRotation()` | ScreenRotation | the rotation of the screen. (portrait, landscape, reversed...) |Kotlin
| API | Return | Description |
| :- | :- | :- |
| `with(context)` | None | Call this function one time before any other function to setup properly. Calling multiple times is okay, but unnecessary |
| `refresh()` | None | Refresh attributes, call when configuration change, rotation, ... |
| `navBarPadding` | ScreenPadding | Represent screen padding of system bar for navigation |
| `statusBarPadding` | ScreenPadding | Represent screen padding of status bar. |
| `cutoutPadding` | ScreenPadding | Represent screen padding of cutout for the notch, or smth similar |
| `fullWidth` | Int | Width of the screen in pixel |
| `fullHeight` | Int | Height of the screen in pixel |
| `fullSize` | Size | Size of the screen in pixel |
| `safeArea` | ScreenArea | The area of the screen that is not obscured by the navigation bar, status bar, or other system UI elements. |
| `safeScreenPadding` | ScreenPadding | Returns the safe screen padding |
| `safePaddingLeft` | Int | Padding for `LEFT` edge to avoid overlap with system UI |
| `safePaddingRight` | Int | Padding for `RIGHT` edge to avoid overlap with system UI |
| `safePaddingTop` | Int | Padding for `TOP` edge to avoid overlap with system UI |
| `safePaddingBottom` | Int | Padding for `BOTTOM` edge to avoid overlap with system UI |
| `safeWidth` | Int | The width of the screen after subtracting the system bar on the left and right sides |
| `safeHeight` | Int | The height of the screen after subtracting the system bar on the top and bottom sides |
| `safeSize` | Size | The `Size` of the screen after subtracting the system bar on all sides |
| `statusBarHeight` | Int | status bar height (pixel unit) |
| `navBarHeight` | Int | navigation bar height (both gesture and buttons in pixel unit) |
| `screenRotation` | ScreenRotation | the rotation of the screen. (portrait, landscape, reversed...) |
| `isPortrait()` | Boolean | `true` if screen is in portrait mode, `false` otherwise |
| `isButtonsNavigation()` | Boolean | `true` if buttons navigation is being used |
| `isGestureNavigation()` | Boolean | `true` if gesture navigation is being used |
Contributions are welcome! 🙌
- If you come across a bug or have an idea for a new feature, please let us know by creating an [Issue](https://github.com/TorryDo/ScreenEasy/issues) 🐞🐛💡
- If you've already fixed a bug or implemented a feature, feel free to submit a [Pull request](https://github.com/TorryDo/ScreenEasy/pulls) 🚀
- Having questions, ideas, or feedback? Don't worry, I gotchu. Simply open a [Discussion](https://github.com/TorryDo/ScreenEasy/discussions) 🔊
- Find this project useful? Don't forget to show some love by giving a star ⭐Thank you! 💖
## IV, Work in Progress 🚧
This library is still under heavy development. There is still a lot of code cleanup to do, so expect breaking API changes over time.Please refer to the following page to check out the change-log: [Releases](https://github.com/TorryDo/ScreenEasy/releases)
Everything's gonna be ok! 🍀
```
Copyright 2023 TorryDo
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 athttp://www.apache.org/licenses/LICENSE-2.0
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.```