Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nilsjr/Snappy
๐ธ Android CameraX Library
https://github.com/nilsjr/Snappy
android android-library camerax jetpack-compose kotlin library
Last synced: 9 days ago
JSON representation
๐ธ Android CameraX Library
- Host: GitHub
- URL: https://github.com/nilsjr/Snappy
- Owner: nilsjr
- License: mit
- Created: 2022-07-20T09:45:32.000Z (over 2 years ago)
- Default Branch: develop
- Last Pushed: 2024-03-31T10:19:09.000Z (8 months ago)
- Last Synced: 2024-03-31T11:25:56.623Z (8 months ago)
- Topics: android, android-library, camerax, jetpack-compose, kotlin, library
- Language: Kotlin
- Homepage:
- Size: 3.05 MB
- Stars: 41
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-list - nilsjr/Snappy - ๐ธ Android CameraX Library (Kotlin)
README
**Snappy** is an android camerax library for taking snapshot fast & simple. Easy to integrate, 100% Kotlin & jetpack
compose driven.- Activity Result API usage
- Android Jetpack CameraX for displaying preview
- Minimalistic ui design
- Coil for image loading
- Different modes (single image & multiple images)## Download
Available on `mavenCentral()`
[![Maven Central](https://img.shields.io/maven-central/v/de.nilsdruyen.snappy/snappy)](https://search.maven.org/search?q=g:de.nilsdruyen.snappy)
```kotlin
implementation("de.nilsdruyen.snappy:snappy:0.0.1")
```## Requirements
- AndroidX
- MinSdk 21---
โ ๏ธImportant
**File/Storage permissions should be requested by your app. Only camera permissions are requested by Snappy**
---
## Usage
To use Snappy in our app you need to add following code snippets.
Kotlin
```kotlin
import de.nilsdruyen.snappy.Snappy
import de.nilsdruyen.snappy.models.SnappyConfig
import de.nilsdruyen.snappy.models.SnappyResult// setup snappy activity result launcher
private val launcher = registerForActivityResult(Snappy()) { result ->
// do something
}// or in compose
val launcher = rememberLauncherForActivityResult(Snappy()) { result ->
when (result) {
is SnappyResult.Success -> {
// do something
}
else -> {
//
}
}
}launcher.launch(SnappyConfig(File("")))
```**SnappyConfig**
```kotlin
import de.nilsdruyen.snappy.models.SnappyConfigval config = SnappyConfig(
outputDirectory = File("path/"), // no default
once = true, // default = false
withHapticFeedback = true, // default = true
)
```**SnappyResult**
```kotlin
import de.nilsdruyen.snappy.models.SnappyResultsealed interface SnappyResult {
data class Success(val images: List) : SnappyResult
object Canceled : SnappyResult
object PermissionDenied : SnappyResult
data class Error(val exception: Exception) : SnappyResult
}
```Java
```java
import de.nilsdruyen.snappy.Snappy;
import de.nilsdruyen.snappy.models.SnappyConfig;
import de.nilsdruyen.snappy.models.SnappyResult;class Activity {
// setup snappy activity result launcher
private ActivityResultLauncher snappy = registerForActivityResult(new Snappy(), (result) -> {
if (result instanceof SnappyResult.Success) {
List images = ((SnappyResult.Success) result).component1();}
});// launch snappy activity
private void launch() {
snappy.launch(new SnappyConfig(new File("path"), true, true));
}
}
```## Screenshots
Single snapshot mode
| Single snapshot mode |
|--------------------------------------------------------------------------------------------------------------------------|
| |Multiple snapshot mode
| No images | With images | Image gallery |
| --- | --- | --- |
| | | |## Contributing
See [CONTRIBUTING](CONTRIBUTING.md)
## License
The MIT License (MIT)
Copyright (C) 2022 Nils Druyen
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.