Giter VIP home page Giter VIP logo

unsplash-photopicker-android's Introduction

Unsplash Photo Picker for Android

License Download

UnsplashPhotoPicker is an Android UI component that allows you to quickly search the Unsplash library for free high-quality photos with just a few lines of code.

iOS photo picker here.

Unsplash Photo Picker for Android preview

Table of Contents

Description

UnsplashPhotoPicker is a Kotlin object you use to initialize the library. You present the picker by navigating to the UnsplashPickerActivity to offer your users to select one or multiple photos from Unsplash. Once they have selected photos, the UnsplashPickerActivity returns UnsplashPhoto objects that you can use in your app.

Requirements

Installation

Gradle

To integrate UnsplashPhotoPicker into your Android Studio project using Gradle, specify in your project build.gradle file:

allprojects {
   repositories {
      maven { url  "https://dl.bintray.com/unsplash/unsplash-photopicker-android" }
   }
}

And in your app module build.gradle file:

dependencies {
   implementation 'com.unsplash.pickerandroid:photopicker:x.y.z'
}

Usage

❗️Before you get started, you need to register as a developer on our Developer portal. Once registered, create a new app to get an Access Key and a Secret Key.

Configuration

The UnsplashPhotoPicker is a Kotlin object you need to use in order to initialize the library. Add this in your custom application class onCreate method:

UnsplashPhotoPicker.init(
            this, // application
            "your access key",
            "your secret key"
            /* optional page size */
        )
Property Type Optional/Required Default
application Application Required N/A
accessKey String Required N/A
secretKey String Required N/A
pageSize Int Optional 20

Presenting

In order to access the picker screen you need to navigate to the UnsplashPickerActivity. This activity has a getStartingIntent method to create the Intent needed:

startActivityForResult(
                UnsplashPickerActivity.getStartingIntent(
                    this, // context
                    isMultipleSelection
                ), REQUEST_CODE
            )

Using the results

Your calling activity must use a startActivityForResult method to be able to retrieve the selected UnsplashPhoto:

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        if (resultCode == Activity.RESULT_OK && requestCode == REQUEST_CODE) {
            val photos: ArrayList<UnsplashPhoto>? = data?.getParcelableArrayListExtra(UnsplashPickerActivity.EXTRA_PHOTOS)
            // use your photos here
        }
}

See UnsplashPhoto.kt for more details.

License

MIT License

Copyright (c) 2019 Unsplash Inc.

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.

unsplash-photopicker-android's People

Contributors

goui avatar ocollet avatar

Watchers

 avatar

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.