Android Library to create picker dialogs.
Angad Singh - filepicker and Aefyr - filepicker
- Easy to Implement.
- No permissions required.
- Dark theme supported.
- Easy to use.
- Files, Directory Selection.
- Single or Multiple File selection.
- Column sort.
- RegEx filters
- Select by node.
- All dialogs support
- Library is also Available in JCenter, So just put this in your app dependencies to use it:
repositories {
...
maven { url 'https://jitpack.io' }
...
}
compile 'com.github.ndagnas:android-pickers:0.3.0'
Update AndroidManifest.xml
like this:
<application
...
android:requestLegacyExternalStorage="true"
...
>
Use same of AlertDialog.
new FilePickerDialog.Builder (this)
.setRequestCode(EXTERNAL_READ_PERMISSION_GRANT)
.setTitle("Select a File")
.setOffsetDir(FilePickerDialog.DEFAULT_DIR)
.setRootDir(FilePickerDialog.DEFAULT_DIR)
.setErrorDir(FilePickerDialog.DEFAULT_DIR)
.setSelectionMode(FilePickerDialog.FILE_SELECT)
.setOnSingleChoiceValidationListener(
new PickerInterface.OnSingleChoiceValidationListener<String>() {
@Override
public void onClick ( PickerInterface sender, String result ) {
//file is the path of file selected by the Application User.
}
})
.show();
Marshmallow and above requests for the permission on runtime. You should override onRequestPermissionsResult
in Activity/AppCompatActivity class and show the dialog only if permissions have been granted.
//Add this method to show Dialog when the required permission has been granted to the app.
@Override
public void onRequestPermissionsResult(int requestCode,@NonNull String permissions[],@NonNull int[] grantResults) {
switch (requestCode) {
case EXTERNAL_READ_PERMISSION_GRANT: {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
if(dialog!=null)
{ //Show dialog if the read permission has been granted.
dialog.show();
}
}
else {
//Permission has not been granted. Notify the user.
Toast.makeText(MainActivity.this,"Permission is Required for getting list of files",Toast.LENGTH_SHORT).show();
}
}
}
}
rootDir
,errorDir
,offsetDir
must have valid directory/file paths.patterns
must are regexes.
Copyright (C) 2021 Nicolas Dagnas
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.