Skip to content
This repository has been archived by the owner on Dec 22, 2020. It is now read-only.
/ Mediator Public archive

Mediator is a tool that helps with Android permissions at run time.

License

Notifications You must be signed in to change notification settings

willwexler/Mediator

Repository files navigation

Mediator

Codacy Badge API CircleCI

Mediator is a tool that helps with Android permissions at run time.

1. Getting Started

The repo has been uploaded to jcenter().

1.1 Gradle

dependencies {
    compile 'com.dobbby.mediator:mediator:0.0.4'
}

1.2 Maven

<dependency>
    <groupId>com.dobbby.mediator</groupId>
    <artifactId>mediator</artifactId>
    <version>0.0.4</version>
    <type>pom</type>
</dependency>

2. Java

Simply add this to your Application's onCreate() method:

Mediator.init(this);
Mediator.setDefaultOnRejected(new Mediator.OnRejected() {
    @Override
    public void onRejected() {
        // custom notifications when permission denied.
    }
});

And request permissions at run time can be easy as pie:

Mediator.request(Manifest.permission.WRITE_EXTERNAL_STORAGE)
        .onPerform(new Mediator.OnPerform() {
            @Override
            public void onPerform() {
                saveSomeFiles();
            }
        })
        .onRejected(new Mediator.OnRejected() {
            @Override
            public void onRejected() {
                Log.i(TAG, "Permission denied");
            }
        })
        .delegate();

3. Kotlin

Simply add this to your Application's onCreate() method:

Mediator.init(this)
Mediator.setDefaultOnRejected { toast("Rejected") }

And request permissions at run time can be easy as pie:

Mediator.request(Manifest.permission.WRITE_EXTERNAL_STORAGE)
        .onPerform { saveSomeFiles() }
        .onRejected { toast("Rejected") }
        .delegate()

About

Mediator is a tool that helps with Android permissions at run time.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages