DrawingActivity

Additional

Language
Kotlin
Version
2.0.8 (Jul 1, 2021)
Created
Sep 4, 2018
Updated
Aug 23, 2021 (Retired)
Owner
ChilliBits (chillibits)
Contributors
Codacy Badger (codacy-badger)
M&R Games (mrgames13)
dependabot[bot]
dependabot-preview[bot]
Marc Auberer (marcauberer)
Tim Auberer (timauberer)
6
Activity
Badge
Generate
Download
Source code

Android DrawingActivity

A lightweight android library for including a drawing experience to your Android app.

Installation

Up to now, the library is only available on JitPack. Please add this code to your build.gradle file on project level:

allprojects {
  repositories {
    ...
    maven { url 'https://jitpack.io' }
  }
}

To load the library into your project use this code in the build.gradle file within the app module:

implementation 'com.github.ChilliBits:drawing-activity:2.0.8'

Usage

To use the DrawingActivity, include this code in an event function:

DrawingActivityBuilder.getInstance(this@MainActivity)
 .draw(REQ_DRAWING)

Thus REQ_DRAWING is a constant of type integer to specify the request code of the returning intent for the onActivityResult method.

If you want to have a look onto a implemented example, view the MainActivity.kt or the MainActivity.java file.

You are able to catch the event of finishing the drawing and closing the DrawingActivty by using the onActivityResult method like that:

if(requestCode == REQ_DRAWING && resultCode == RESULT_OK && data != null) {
    val drawingPath = data.getStringExtra(DrawingActivity.DRAWING_PATH)
    Toast.makeText(this, drawingPath, Toast.LENGTH_LONG).show()
}

Replace the Toast with your own code, processing the returned image (loading the image into your app, sharing it, cropping it, etc.).

You can customize the appearance of the DrawingActivity using following arguments when building the Activity with DrawingActivityBuilder:

Method Description
enableToast(boolean enabled) Enables or disables the toast on Activity startup (You can see the toast on the animated demo above).
setTitle(String title) Sets the title in the toolbar at the top of the DrawingActivity.
setDefaultUtility(int utility) Sets the default utility which will be selected on Activity startup. You have to pass an int argument to this method. The utility constants can be accessed by using e.g. DrawingActivity.UTILITY_PENCIL or DrawingActivity.UTILITY_AIR_BRUSH.

Credits

This library uses following third party libraries:

Contributions

If you want to contribute to this library, feel free to open a pr! We're going to merge it asap.

Thank you for using the DrawingActivity!

© ChilliBits 2018-2021 (Designed and developed by Marc Auberer)