Giter VIP home page Giter VIP logo

filepickerlibrary's Introduction

FilePickerLibrary

Android Arsenal

Release

Simple library that allows for picking of files and directories. This is a clean and simple way to allow your user to easily select a file. This library is inspired by Android L and the new Material Design guidelines adding to its sleekness and beauty.

![image] (images/main_framed.png)

A Quick Overview What's In

  • Compatible down to API Level 16

Include to Project

Provide the Gradle Dependency

Step 1

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

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

Step 2

Add the dependency

dependencies {
    compile 'com.github.alirezaaa:FilePickerLibrary:3.5.1'
}

Clone or Download .zip file

Clone this repository or download the compressed file, then extract to your computer. Simply import the library module to your project.

Usages

Use one of the following samples or simply compile and test the sample app provided:

Material Theme Used (with Modern Builder)

new FilePickerBuilder(this)
    .withColor(android.R.color.holo_blue_bright)
    .withRequest(Request.FILE)
    .withScope(Scope.ALL)
    .withMimeType(MimeType.JPEG)
    .useMaterialActivity(true)
    .launch(REQUEST_FILE);

image/png Mime Type

Intent filePicker = new Intent(this, FilePickerActivity.class);
filePicker.putExtra(FilePickerActivity.SCOPE, Scope.ALL);
filePicker.putExtra(FilePickerActivity.REQUEST, Request.FILE);
filePicker.putExtra(FilePickerActivity.INTENT_EXTRA_COLOR_ID, android.R.color.holo_green_dark);
filePicker.putExtra(FilePickerActivity.MIME_TYPE, MimeType.PNG);
startActivityForResult(filePicker, REQUEST_FILE);

Show as a Dialog

Intent filePickerDialogIntent = new Intent(this, FilePickerActivity.class);
filePickerDialogIntent.putExtra(FilePickerActivity.THEME_TYPE, ThemeType.DIALOG);
filePickerDialogIntent.putExtra(FilePickerActivity.REQUEST, Request.FILE);
startActivityForResult(filePickerDialogIntent, REQUEST_FILE);

Select a Directory

Intent filePickerActivity = new Intent(this, FilePickerActivity.class);
filePickerActivity.putExtra(FilePickerActivity.SCOPE, Scope.ALL);
filePickerActivity.putExtra(FilePickerActivity.REQUEST, Request.DIRECTORY);
filePickerActivity.putExtra(FilePickerActivity.INTENT_EXTRA_FAB_COLOR_ID, android.R.color.holo_green_dark);
startActivityForResult(filePickerActivity, REQUEST_DIRECTORY);

To have the result, you must override onActivityResult(int, int, Intent) method as I did below:

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if ((requestCode == REQUEST_DIRECTORY) && (resultCode == RESULT_OK)) {
        Toast.makeText(this, "Directory Selected: " + data.getStringExtra(FilePickerActivity.FILE_EXTRA_DATA_PATH), Toast.LENGTH_LONG).show();
    } else if ((requestCode == REQUEST_FILE) && (resultCode == RESULT_OK)) {
        Toast.makeText(this, "File Selected: " + data.getStringExtra(FilePickerActivity.FILE_EXTRA_DATA_PATH), Toast.LENGTH_LONG).show();
    }
}

Contributors

License

Copyright 2016 Paul T

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.

filepickerlibrary's People

Contributors

developerpaul123 avatar meness avatar fmeneuhe avatar alirezaaa avatar jasontanabe avatar mkurutin avatar psh avatar ivied avatar

Watchers

James Cloos avatar Andrey 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.