Coder Social home page Coder Social logo

flipper's Introduction

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:

       public class MainActivity extends Activity {

          private StorageManagerCompat manager;

          @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_main);
              manager = new StorageManagerCompat(this);
              Root root = manager.getRoot(StorageManagerCompat.DEF_MAIN_ROOT);
              if (root == null || !root.isAccessGranted(this)) {
                   Intent i = manager.requireExternalAccess(this);
                   startActivityForResult(i, 100);
              }
          }
       
          private void myMethod() {
               Root root = manager.getRoot(StorageManagerCompat.DEF_MAIN_ROOT);
               if (root == null)
                   return;
               DocumentFile f = root.toRootDirectory(this);
               if (f == null)
                   return;
               DocumentFile subFolder = DocumentFileCompat.peekSubFolder(f, "mysub");
               if (subFolder == null)
                   return; //directory doesn't exist yet
               DocumentFile myFile = DocumentFileCompat.peekFile(subFolder, "myfile", "image/png");
               if (myFile == null)
                   return; //file doesn't exist yet
               try {
                   InputStream is = getContentResolver().openInputStream(myFile.getUri());
               } catch (FileNotFoundException e) {
                   e.printStackTrace();
               }
          }
       
          @Override
          protected void onActivityResult(int requestCode, int resultCode, Intent data) {
               if (requestCode == 100 && resultCode == RESULT_OK) {
                   Root root = manager.addRoot(this, StorageManagerCompat.DEF_MAIN_ROOT, data);
                   if (root == null)
                       return;
                   DocumentFile f = root.toRootDirectory(this);
                   if (f == null)
                       return;
                   try {
                       DocumentFile subFolder = DocumentFileCompat.getSubFolder(f, "mysub");
                       DocumentFile myFile = DocumentFileCompat.getFile(subFolder, "myfile", "image/png");
                       try {
                           OutputStream os = getContentResolver().openOutputStream(myFile.getUri());
                       } catch (FileNotFoundException e) {
                           e.printStackTrace();
                       }
                   } catch (OperationFailedException e) {
                       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

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.