Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

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

Awesome Lists containing this project

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

val config = SnappyConfig(
outputDirectory = File("path/"), // no default
once = true, // default = false
withHapticFeedback = true, // default = true
)
```

**SnappyResult**

```kotlin
import de.nilsdruyen.snappy.models.SnappyResult

sealed 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 |
|--------------------------------------------------------------------------------------------------------------------------|
| drawing |

Multiple snapshot mode
| No images | With images | Image gallery |
| --- | --- | --- |
| drawing | drawing | drawing |

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