Skip to content

Repository files navigation

Flipper

Flipper is an android library project to help developers to use file-like interface using the storage access framework. Flipper is designed to handle the new behavior required by Android Q.

Dependencies

  • Android-X package
  • Min version to use Flipper is Android KitKat (API 19)

Set up Instructions

Set up the project dependencies. To use this library in your project:

(1) Use the GitHub source and include that as a module dependency by following these steps:

  • Clone this library into a project named SmartRecyclerView, parallel to your own application project:
git clone https://github.com/baldapps/Flipper.git
  • In the root of your application's project edit the file "settings.gradle" and add the following lines:
include ':flipper'
project(':flipper').projectDir = new File('../Flipper/flipper')
  • In your application's main module (usually called "app"), edit your build.gradle to add a new dependency:
 dependencies {
...
compile project(':flipper')
}

Now your project is ready to use this library

Main Features

Flipper provides an abstaction layer to manage files using Uri access on Android platform.

Example and how to use the library:

publicclassMainActivityextendsActivity {
privateStorageManagerCompatmanager;
@OverrideprotectedvoidonCreate(BundlesavedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
manager = newStorageManagerCompat(this);
Rootroot = manager.getRoot(StorageManagerCompat.DEF_MAIN_ROOT);
if (root == null || !root.isAccessGranted(this)) {
Intenti = manager.requireExternalAccess(this);
startActivityForResult(i, 100);
}
}
privatevoidmyMethod() {
Rootroot = manager.getRoot(StorageManagerCompat.DEF_MAIN_ROOT);
if (root == null)
return;
DocumentFilef = root.toRootDirectory(this);
if (f == null)
return;
DocumentFilesubFolder = DocumentFileCompat.peekSubFolder(f, "mysub");
if (subFolder == null)
return; //directory doesn't exist yetDocumentFilemyFile = DocumentFileCompat.peekFile(subFolder, "myfile", "image/png");
if (myFile == null)
return; //file doesn't exist yettry {
InputStreamis = getContentResolver().openInputStream(myFile.getUri());
} catch (FileNotFoundExceptione) {
e.printStackTrace();
}
}
@OverrideprotectedvoidonActivityResult(intrequestCode, intresultCode, Intentdata) {
if (requestCode == 100 && resultCode == RESULT_OK) {
Rootroot = manager.addRoot(this, StorageManagerCompat.DEF_MAIN_ROOT, data);
if (root == null)
return;
DocumentFilef = root.toRootDirectory(this);
if (f == null)
return;
try {
DocumentFilesubFolder = DocumentFileCompat.getSubFolder(f, "mysub");
DocumentFilemyFile = DocumentFileCompat.getFile(subFolder, "myfile", "image/png");
try {
OutputStreamos = getContentResolver().openOutputStream(myFile.getUri());
} catch (FileNotFoundExceptione) {
e.printStackTrace();
}
} catch (OperationFailedExceptione) {
e.printStackTrace();
}
}
}

References and how to report bugs

  • If you find any issues with this library, please open a bug here on GitHub

License

See LICENSE

Change List

1.0.0

  • First version

About

Android library for abstract file-system access required by Android Q

Topics

Resources

Stars

47 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages