GithubHelp home page GithubHelp logo

chillibits / drawing-activity Goto Github PK

View Code? Open in Web Editor NEW
67.0 8.0 14.0 20.64 MB

Android library for getting lightweight DrawingActivity into your Android app

License: MIT License

Kotlin 91.99% Java 8.01%
android drawing draw android-library chillibits

drawing-activity's Introduction

Android DrawingActivity

Codacy Badge Android CI Android Arsenal API PRs Welcome

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

1 2 3

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.