GithubHelp home page GithubHelp logo

wuyi166 / storage-chooser Goto Github PK

View Code? Open in Web Editor NEW

This project forked from codekidx/storage-chooser

0.0 1.0 0.0 326 KB

Lets user choose between internal or external storage with just few lines of code.

License: Mozilla Public License 2.0

Java 100.00%

storage-chooser's Introduction

Storage Chooser

GitHub issues demo javadoc

A pretty and simple directory chooser and file picker library for 4.4+ devices. This library was created to be included in OpenGApps App. There are too many storage chooser out there but this one is too materially ๐Ÿ˜› . Easy to implement and does not take a lot of your valueable time in setting-up all the other necessary things that every developer seeks, like

  • saving path to sharedPreference
  • event when path is selected and act upon that path
  • and much more.

There are also some really nice features that I thought would come in handy:

  • You show a quick overview of the storages present and their memory available before choosing so that users know which storage to choose.
  • you can choose between sheet and sleek layouts.
  • Inline create folder view (not another dialog to handle)
  • Full localization. I mean literally every strings can be localized to your desired language.
  • Memory thresholding - a restriction or a toast that it shows when user's memory is less than your defined memory for operations.
  • and more will be added soon.

Preview

SC Features

Installation

Add this to your root build.gradle file under repositories:

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

Add this to your app level build.gradle as dependency:

com.github.codekidX:storage-chooser:1.0.34

Notes

Before you implement this library here are some notes that you can follow to avoid errors.

Confirm:

  • You have asked for Runtime Permission from the user in the past to avoid read errors.
  • Permissions with "READ_EXTERNAL_STORAGE" and "WRITE_EXTERNAL_STORAGE" is enough for this library to work.
  • This library follows same color scheme as that of the parent app to maintain the aesthetic of the parent app. See the color scheme section below

Implementation

Simple Type

  • Let's you toggle between inernal/external root directory.
// ~

// Initialize Builder
StorageChooser chooser = new StorageChooser.Builder()
.withActivity(MainActivity.this)
.withFragmentManager(getSupportFragmentManager())
.withMemoryBar(true) 
.build();

// Show dialog whenever you want by
chooser.show();

// get path that the user has chosen
chooser.setOnSelectListener(new StorageChooser.OnSelectListener() {
    @Override
    public void onSelect(String path) {
        Log.e("SELECTED_PATH", path);
    }
});

OUTPUT: /storage/emulated/0

Pre-defined Type

  • Let's you append a specific path to the root of internal or external directory.
// --- ADD --
.withPredefinedPath(STATIC_PATH)

OUTPUT: /storage/emulated/0/Downloads/CodekidLabs

Custom Type

  • Let's your user choose custom directory/file.

Directory Chooser

// --- ADD ---
.allowCustomPath(true)
.setType(StorageChooser.DIRECTORY_CHOOSER)

File Picker

NOTE: File Picker is still --> WIP

// --- ADD ---
.allowCustomPath(true)
.setType(StorageChooser.FILE_PICKER)

Save directly to preference

// --- ADD ---
.actionSave(true)
.withPreference(sharedPreferences)

Get path from preference

String path = sharedPreferences.getString(DiskUtil.SC_PREFERENCE_KEY,"");

Localization

A seperate localization wiki is posted here

Color Scheme

  • Overview header color -> @colorPrimary
  • Memory bar color -> @colorAccent
  • Memory available text -> @colorPrimaryDark
  • Address bar background -> @colorPrimary
  • Select button label color -> @colorPrimaryDark

For custom color scheme, read Wiki

LICENSE

This project is licensed with the Mozilla Public License v2.

In practice, you can use this library as-is, with a notification of it being used. If you make any changes, you are required to publish your changes under a compatible license.

Support Storage Chooser

This is a community based project so help fixing bugs by adding your fixes to it by clicking Create pull request

storage-chooser's People

Contributors

codekidx avatar fennifith avatar mfonville avatar theandroidmaster avatar tolriq avatar beatbrot 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.