All Projects → basshelal → UnsplashPhotoPicker

basshelal / UnsplashPhotoPicker

Licence: MIT license
📷 Android Library providing a photo picker to search and download photos from Unsplash

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to UnsplashPhotoPicker

Myersplash.uwp
Yet anothor simple and elegant photos & wallpaper app for all platforms.
Stars: ✭ 207 (+567.74%)
Mutual labels:  unsplash
python-unsplash
Python wrapper for the Unsplash API.
Stars: ✭ 130 (+319.35%)
Mutual labels:  unsplash
Monotone
An Unsplash Application for iOS.
Stars: ✭ 181 (+483.87%)
Mutual labels:  unsplash
Irvue Screensaver
Screensaver for macOS
Stars: ✭ 247 (+696.77%)
Mutual labels:  unsplash
Palette
Android application to get the #hexcode and rgb() values for any image
Stars: ✭ 31 (+0%)
Mutual labels:  unsplash
instant-images
Instantly upload photos from Unsplash, Pixabay and Pexels to your website without leaving WordPress.
Stars: ✭ 26 (-16.13%)
Mutual labels:  unsplash
Unsplashkit
Swift client for Unsplash
Stars: ✭ 183 (+490.32%)
Mutual labels:  unsplash
gosimac
Fetch the wallpaper from Bing, Unsplash, etc.
Stars: ✭ 22 (-29.03%)
Mutual labels:  unsplash
go-unsplash
Go Client for the Unsplash API
Stars: ✭ 70 (+125.81%)
Mutual labels:  unsplash
photo-spider-scrapy
10 photo website spiders, 10 个国外图库的 scrapy 爬虫代码
Stars: ✭ 17 (-45.16%)
Mutual labels:  unsplash
WallberryTheme
Bringing the WallberryTheme to MagicMirror²
Stars: ✭ 94 (+203.23%)
Mutual labels:  unsplash
wallup-android
Hand curated Images & 'Auto Wallpaper'
Stars: ✭ 30 (-3.23%)
Mutual labels:  unsplash
laravel-unsplash
Powerful Unsplash package for Laravel
Stars: ✭ 50 (+61.29%)
Mutual labels:  unsplash
Unsplash Photopicker Ios
📱An iOS photo picker to search and download photos from Unsplash.
Stars: ✭ 213 (+587.1%)
Mutual labels:  unsplash
MacOS-Developers-Excuses
A macOS screen saver that shows a random developer excuse over a beautiful photo background. Made with ❤
Stars: ✭ 53 (+70.97%)
Mutual labels:  unsplash
Unsplash rb
💎 Ruby wrapper for the Unsplash API.
Stars: ✭ 202 (+551.61%)
Mutual labels:  unsplash
ios-rentateam
Тестовое приложение Rentateam
Stars: ✭ 13 (-58.06%)
Mutual labels:  unsplash
ConvenientImagePicker
🏞🌅🌄🎇🌇🏙🌃🌉🌁the new iOS image picker. Beautiful, delicate, and customizable.
Stars: ✭ 44 (+41.94%)
Mutual labels:  photo-picker
strapi-plugin-zeasy-image-api
Strapi plugin to ease the process importing Unsplash image with attribution
Stars: ✭ 28 (-9.68%)
Mutual labels:  unsplash
image
mpvue-Unsplash
Stars: ✭ 31 (+0%)
Mutual labels:  unsplash

Unsplash Photo Picker

JitPack minAPI 21 Kotlin 1.3+ Android Arsenal Codacy Badge License

Unsplash Photo Picker

Unsplash Photo Picker is a modular and customizable Android View that allows you to quickly search Unsplash.com for free high-quality photos with just a few lines of code.

Based on Unsplash Photo Picker for Android by Unsplash, this library adds more flexibility, conveniences and customization than the original.

The original only launched an Activity for you which you had no control of, this provides you with a View you can use in your layouts.

Description

This library allows you to add a fully functioning photo picker which searches free high-quality photos from Unsplash.com.

You can select multiple (or one) images and you can show any image in fullscreen.

This library will also take care of following most of the Unsplash Technical API Guidelines for you, however I am not responsible or liable if you do not follow them yourself.

See the Abiding by the Unsplash API Guidelines section for more details.

Requirements

Installation

Add the JitPack repository to your root build.gradle at the end of repositories:

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

Add the dependency in your app module build.gradle file:

dependencies {
    implementation 'com.github.basshelal:UnsplashPhotoPicker:1.1.2'
}

Usage

⚠️ IMPORTANT! ⚠️

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

Remember you must keep both keys secret.

Initial Configuration

You need to call UnsplashPhotoPickerConfig.init(...) in your custom Application class's onCreate(), with the required arguments.

class App : Application() {
    
    override fun onCreate() {
        super.onCreate()
        
        UnsplashPhotoPickerConfig.init(
            application = this,
            accessKey = "your access key",
            secretKey = "your secret key",
            unsplashAppName = "your app's name on Unsplash",
            isLoggingEnabled = false // optional to enable full HTTP logging, defaults to false
        )
    }
}

Quick Use

Showing the photo picker takes a few lines of code, with many customization options and listeners available, see the full list in Xml Attributes and Click Listeners

Kotlin:

    UnsplashPhotoPicker.show(this /*: Context*/ ) {
        hasSearch = true
        persistentSearch = true
        longClickSelectsPhoto = false
        clickOpensPhoto = false
        onClick = { photo,_ -> selectPhoto(photo) }
        // more customization here...
    }

Xml:

<com.github.basshelal.unsplashpicker.presentation.UnsplashPhotoPicker
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

Xml Attributes

All xml attributes begin with photoPicker_.

For the full documentation, check out attributes.md or the UnsplashPhotoPicker class itself.

All public APIs in this library are well documented.

name format default value
photoPicker_pageSize integer 50
photoPicker_spanCount integer 2
photoPicker_hasSearch boolean true
photoPicker_persistentSearch boolean false
photoPicker_isMultipleSelection boolean false
photoPicker_errorDrawable drawable null
photoPicker_placeHolderDrawable drawable null
photoPicker_pickerPhotoSize photoSize small
photoPicker_showPhotoSize photoSize small
photoPicker_searchHint string "Search Unsplash Photos"
photoPicker_photoByString" string "Photo by"
photoPicker_onString string "on"
photoPicker_clickOpensPhoto boolean true
photoPicker_longClickSelectsPhoto boolean false

PhotoSize enum: thumb, small, medium, regular, large, full, raw

See the PhotoSize enum class

Click Listeners

You can listen to click events on any photo in the picker using onClickPhoto and onLongClickPhoto which are both anonymous functions (lambdas) which have the UnsplashPhoto as their first parameter and the clicked ImageView as the second parameter.

unsplashPhotoPicker.apply {
    onClickPhoto = { unsplashPhoto, imageView -> this.showPhoto(unsplashPhoto) }
    onLongClickPhoto = { unsplashPhoto, imageView -> this.selectPhoto(unsplashPhoto) }
}

Showing a Photo

You can show any UnsplashPhoto (even if you don't have an UnsplashPhotoPicker) using a couple of lines:

    PhotoShowFragment.show(
        activity /*: FragmentActivity*/,
        photo /*: UnsplashPhoto*/
    )

Internationalization (i18n)

This library is fully i18n-friendly.

Any text shown can be changed to match the language and locale with full RTL support!

Internationalization

Abiding by the Unsplash API Guidelines

⚠️ IMPORTANT! ⚠️

You must follow the Unsplash API Guidelines when using the Unsplash API in your application.

This application takes care of Technical Guidelines 1-3 for you however, I am not responsible or liable if you do not follow them yourself.

Below are the Technical guidelines and how this library follows and implements them.

  1. All API uses must use the hotlinked image URLs returned by the API under the photo.urls properties. This applies to all uses of the image and not just search results.

This is automatically done for you courtesy of the original library, do not worry about this.

  1. When your application performs something similar to a download (like when a user chooses the image to include in a blog post, set as a header, etc.), you must send a request to the download endpoint returned under the photo.links.download_location property.

When you are done with your images you must call UnsplashPhotoPicker.downloadPhotos to send the download request.

  1. When displaying a photo from Unsplash, your application must attribute Unsplash, the Unsplash photographer, and contain a link back to their Unsplash profile. All links back to Unsplash should use utm parameters in the ?utm_source=your_app_name&utm_medium=referral.

This is done for you as you provide the Unsplash app name when you call UnsplashPickerConfig.init(...). This must be the name of your app on the Unsplash developer portal.

  1. Your application’s Access Key and Secret Key must remain confidential. This means that they cannot be included in the client or made public. In most cases, this will require proxying the API through your own endpoint to sign the request with your keys.

This one's on you. I recommend you make a Keys.kt file containing 2 String const vals, one for the Access key and one for the Secret key by add the file to the .gitignore file so it doesn't get checked into Version Control. This solution has worked for me but be sure to test it yourself. Again, I am not responsible or liable if you mess up.

Download Sample App

Download by clicking or using the QR Code below on your device:

Sample App Download from QR Code

Special Thanks

Special Thanks to Unsplash for creating a beautiful free service with an easy to use API, seriously you guys are awesome.

Special Thanks again to Unsplash for the initial code that this library is based off of, they've very elegantly done the backend code used to perform network requests. This library would not be possible without them and without them making it open source and licensing it with the MIT License, open and free for all as this library is as well. Many thanks to them for all of this.

License

MIT License

Copyright (c) 2019 Bassam Helal

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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].