belvedere


Source link: https://github.com/zendesk/belvedere

Belvedere

Zero permissions file picker for Android.

Overview

Belvedere gives you the power to easily integrate file selection from third party apps and the camera without the need to take care of permissions, ContentProvider, Intent permissions, and so on.

Download

To use Belvedere in your own Android application, add the following Maven repository:

repositories {

  maven {
 url 'https://zendesk.artifactoryonline.com/zendesk/repo' 
}
 
}
 

And add Belvedere as a dependency:

compile ‘com.zendesk:belvedere:1.2.0.1’ 

Belvedere relies on a certain feature of the Android Manifest Merger called Placeholder support. Please make sure to provide the package name of your app as applicationId in your module specific build.gradle. For an example have a look at the sample app.

If you’re not using Gradle, or you don’t have placeholder support please add the following to your AndroidManifest.xml:

<provider
  android:name="com.zendesk.belvedere.BelvedereFileProvider"
  android:authorities="<applicationId>.belvedere.attachments"
  android:exported="false"
  android:grantUriPermissions="true">

<meta-data

android:name="android.support.FILE_PROVIDER_PATHS"

android:resource="@xml/belvedere_attachment_storage" />  </provider>

How to use Belvedere

Obtaining an instance

A Belvedere instance could be created as easily as the following:

Belvedere belvedere = Belvedere.from(context)

  .withContentType("image/*")

  .build();

The newly created instance is used to acquire images from third party apps.

Belvedere requires that you create an instance once and reuse that instance. We recommend to keep an instance in your global application class, in a headless fragment, a singleton or use your DI to take care of a Belvedere instance.

For all the available configuration options, please have a look at our Javadoc:

Display the built-in dialog

If you want to show the built-in dialog to let the user select a file, invoke the following:

belvedere.showDialog(fragmentManager);

Parsing the result

To get access to the selected files, put the following into your Fragment’s or Activity’s onActivityResult().

... protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {

  belvedere.getFilesFromActivityOnResult(requestCode, resultCode, data, new BelvedereCallback<List<BelvedereResult>>() {

@Override

public void success(final List<BelvedereResult> result) {

 // use data

}

  
}
);
 
}
 ...

All files the user selects are copied into your apps internal cache. As a result Belvedere will return you a list of BelvedereResult objects. Each of these objects represents one selected file. To get access, call BelvedereResult#getFile() or BelvedereResult#getUri(), both of which point to the internal cache, so no permissions are needed to access them.

Place a file into Belvedere’s internal storage

Moreover, it’s possible to put your own data into Belvedere’s cache. To get access to an internal file, call:

BelvedereResult file = belvedere.getFileRepresentation(“file_name.tmp”);
 

Again, you’ll get a file object and a Uri. For example, you can use the file to open a FileOutputStream.

Open or share an internal file

Files that are available through Belvedere could be opened or shared with other apps. To do that, use the Uri you get from a BelvedereResult.

Use the first code snippet to open a file and the second one to share a file:

final Intent intent = new Intent(Intent.ACTION_VIEW);
 intent.setDataAndType(uri, "image/*");
 belvedere.grantPermissionsForUri(intent, uri);
  startActivity(intent);
final Intent shareIntent = new Intent();
 shareIntent.setAction(Intent.ACTION_SEND);
 shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
 shareIntent.setType("image/*");
 belvedere.grantPermissionsForUri(shareIntent, uri);
  startActivity(shareIntent);

Contributing

Bug reports, feature requests and contributions are very welcome. Please follow these steps to contribute:

  • Submit a Pull Request with a detailed explanation of changes and screenshots (if UI is changing). Tests would be great too!
  • One of the core team members will review your changes.
  • After successful code review, you’ll receive a 👍 and the changes will be merged by one of the core members.

If you’re submitting a bug report, please try to follow these steps:

  • Search through the open and closed issues, maybe there is already an issue describing exactly the same problem.
  • Describe the issue as detailed as possible. Try to describe the expected and the actual outcome.
  • Add reproduction steps. If possible provide sample code that showcases the issue.
  • Provide a failing test.

Team

@schlan @baz8080 @brendan-fahy @a1cooke @ndobir @pmurph0

Documentation

View | Download

License

Copyright 2016 Zendesk  Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License. You may obtain a copy of the License at  http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 

Resources

Swipe detects swipe events on Android with listener and RxJava Observable.

An easy to use android color picker library.

A library which can get phone number geo location and other information from local or network (baidu, juhe or custom api).

Detects gestures on Android with listener and RxJava Observable.

AndRouter is a android framework used to map url to activities or actions.

APT processor to generate update methods for POJOs.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes