All Projects → vanniktech → Rxpermission

vanniktech / Rxpermission

Licence: apache-2.0
Reactive permissions for Android

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Rxpermission

Kpermissions
A Kotlin library which helps to request runtime permissions in Android.
Stars: ✭ 253 (+39.01%)
Mutual labels:  rxjava, rxjava2, permissions
Dagger2
Kotlin Dagger2 example project
Stars: ✭ 145 (-20.33%)
Mutual labels:  rxjava, rxjava2
Android Clean Architecture Boilerplate
Apply clean architecture on Android
Stars: ✭ 141 (-22.53%)
Mutual labels:  rxjava, rxjava2
Disposer
Easily dispose rxJava streams with Android's Lifecycle
Stars: ✭ 176 (-3.3%)
Mutual labels:  rxjava, rxjava2
Rxlifecycle
Rx binding of stock Android Activities & Fragment Lifecycle, avoiding memory leak
Stars: ✭ 131 (-28.02%)
Mutual labels:  rxjava, rxjava2
Vertx Rx
Reactive Extensions for Vert.x
Stars: ✭ 137 (-24.73%)
Mutual labels:  rxjava, rxjava2
Jd Mall Master
一款高仿京东商城的UI,基于MVP的Retrofit2(okhttp3)+rxjava+dagger2+greendao+glide。该项目系仿京东商城,属于独立开发者作品,仅供参考学习,拒绝做一切商业用途,如有侵权,请告知删除
Stars: ✭ 151 (-17.03%)
Mutual labels:  rxjava, rxjava2
Mvpframes
整合大量主流开源项目并且可高度配置化的 Android MVP 快速集成框架,支持 AndroidX
Stars: ✭ 100 (-45.05%)
Mutual labels:  rxjava, rxjava2
Rxwear
⌚️ Reactive Wearable API Library for Android and RxJava
Stars: ✭ 163 (-10.44%)
Mutual labels:  rxjava, rxjava2
Fountain
Android Kotlin paged endpoints made easy
Stars: ✭ 175 (-3.85%)
Mutual labels:  rxjava, rxjava2
Httprequest
基于Retrofit2+RxJava2+OkHttp3的网络请求框架,可以完美的应用到组件化、MVP模式等项目中
Stars: ✭ 181 (-0.55%)
Mutual labels:  rxjava, rxjava2
Okhttp Okgo
OkGo - 3.0 震撼来袭,该库是基于 Http 协议,封装了 OkHttp 的网络请求框架,比 Retrofit 更简单易用,支持 RxJava,RxJava2,支持自定义缓存,支持批量断点下载管理和批量上传管理功能
Stars: ✭ 10,407 (+5618.13%)
Mutual labels:  rxjava, rxjava2
Vertx Mqtt
Vert.x MQTT
Stars: ✭ 117 (-35.71%)
Mutual labels:  rxjava, rxjava2
Rxjavapriorityscheduler
RxPS - RxJavaPriorityScheduler - A RxJava Priority Scheduler library for Android and Java applications
Stars: ✭ 138 (-24.18%)
Mutual labels:  rxjava, rxjava2
Featureadapter
FeatureAdapter (FA) is an Android Library providing an optimized way to display complex screens on Android.
Stars: ✭ 112 (-38.46%)
Mutual labels:  rxjava, rxjava2
Android Developer Roadmap
Android Developer Roadmap - A complete roadmap to learn Android App Development
Stars: ✭ 2,170 (+1092.31%)
Mutual labels:  rxjava, rxjava2
Reactivebeacons
Android library scanning BLE beacons nearby with RxJava
Stars: ✭ 171 (-6.04%)
Mutual labels:  rxjava, rxjava2
Freesound Android
Unofficial Android client for the Freesound Project
Stars: ✭ 81 (-55.49%)
Mutual labels:  rxjava, rxjava2
Rxlife
使用Jetpack、Kotlin实现的RxJava自动注销库,你值得拥有!
Stars: ✭ 92 (-49.45%)
Mutual labels:  rxjava, rxjava2
Reactivesensors
Android library monitoring device hardware sensors with RxJava
Stars: ✭ 161 (-11.54%)
Mutual labels:  rxjava, rxjava2

RxPermission

This library wraps the Android Runtime Permissions with RxJava 2. It's based on the RxPermissions library and was adjusted with simplicity in mind. Here are a few things that are different:

  • API is really small and focused
  • Uses a shadowing Activity to request the permission which allows you to use the library within Services, Broadcastreceiver etc.
  • Supports the 'Never ask again' case

Download

implementation 'com.vanniktech:rxpermission:0.7.0'
implementation 'com.vanniktech:rxpermission:0.8.0-SNAPSHOT'

Usage

The core functionality is provided via an interface:

public interface RxPermission {
  /** Requests a single permission. */
  Single<Permission> request(String permission);

  /** Requests multiple permissions. */
  Observable<Permission> requestEach(String... permissions);

  /** Returns true when the given permission is granted. */
  boolean isGranted(String permission);

  /** Returns true when the given permission is revoked by a policy. */
  boolean isRevokedByPolicy(String permission);
}

And the Permission class:

public class Permission {
  /** The name of the permission. For instance android.permission.CAMERA */
  @NonNull public String name();

  /** The state of the permission. */
  @NonNull public State state();

  public enum State {
    /** Permission has been granted. */
    GRANTED,

    /** Permission has been denied. */
    DENIED,

    /**
     * Permission is denied.
     * Previously the requested permission was denied and never ask again was selected.
     * This means that the user hasn't seen the permission dialog.
     * The only way to let the user grant the permission is via the settings now.
     */
    DENIED_NOT_SHOWN,

    /** Permission has been revoked by a policy. */
    REVOKED_BY_POLICY
  }
}

Production

For your Android application you can get an instance of the interface via RealRxPermission.getInstance(application) and then simply use the above mentioned methods to your needs.

RealRxPermission.getInstance(application)
    .request(Manifest.permission.CAMERA)
    .subscribe();

Testing

In addition the library offers you a MockRxPermission that can be used for testing. The constructor takes a vararg of Permissions.

new MockRxPermission(Permission.denied(Manifest.permission.CAMERA))
    .request(Manifest.permission.CAMERA)
    .test()
    .assertResult(Permission.denied(Manifest.permission.CAMERA));

The Permission class provides you a few static factory methods:

/** This will create a granted Camera Permission instance. */
Permission.granted(Manifest.permission.CAMERA)

/** This will create a denied Camera Permission instance. */
Permission.denied(Manifest.permission.CAMERA)

/** This will create a denied not shown Camera Permission instance. */
Permission.deniedNotShown(Manifest.permission.CAMERA)

/** This will create a revoked by policy Camera Permission instance. */
Permission.revokedByPolicy(Manifest.permission.CAMERA)

Sample

Also checkout the sample app that shows you how to use the library.

License

Copyright (C) 2017 Vanniktech - Niklas Baudy

Licensed under the Apache License, Version 2.0

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].