Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.tolriq:storage-chooser:1.0.32'
}
dependencies {
implementation("com.github.tolriq:storage-chooser:1.0.32")
}
<dependency>
<groupId>com.github.tolriq</groupId>
<artifactId>storage-chooser</artifactId>
<version>1.0.32</version>
</dependency>
libraryDependencies += "com.github.tolriq" % "storage-chooser" % "1.0.32"
:dependencies [[com.github.tolriq/storage-chooser "1.0.32"]]
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 :stuck_out_tongue: . 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
There are also some really nice features that I thought would come in handy:
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.31
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
// ~
// 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
// --- ADD --
.withPredefinedPath(STATIC_PATH)
OUTPUT: /storage/emulated/0/Downloads/CodekidLabs
// --- ADD ---
.allowCustomPath(true)
.setType(StorageChooser.DIRECTORY_CHOOSER)
NOTE: File Picker is still --> WIP
// --- ADD ---
.allowCustomPath(true)
.setType(StorageChooser.FILE_PICKER)
// --- ADD ---
.actionSave(true)
.withPreference(sharedPreferences)
String path = sharedPreferences.getString(DiskUtil.SC_PREFERENCE_KEY,"");
A seperate localization wiki is posted here
- 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
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.
This is a community based project so help fixing bugs by adding your fixes to it by clicking Create pull request