Nammu


Source link: https://github.com/tajchert/Nammu

Nammu - Runtime Permission Helper

Speed up your work with new Runtime Permissions introduced in Android 6.0 Marshmallow. This lib allows you to monitor permissions, check them in background and as well ask for a permission in easy way (callback).

What are Runtime Permissions?

Google docs is here. TLDR: like old-loved permissions that were ask during installation but this time they are more dynamic (should be ask only when they are needed) and can be revoked by user at any time.

Why should I care?

Because your user can revoke most essential part of your app and quite probably there will be a lot of app crashes. Current solution you can see here - Google sample basically there is a lot that happens with Activity that is used to check and grant permissions. Also permissions rights are checked many times in the code.

Monitor permissions

To keep track of access to particular permissions, all you need is init Nammu Nammu.init(Context); (pass Application Context, not Activity Context) and call permissionCompare(PermissionListener) to compare lists of granted permissions with previous method call. If you want only to update granted permission lists (without checking if anything changed) use refreshMonitoredList(). PermissionListener offers a callback when permissions was changed, removed, or added. It is recommended to do on app start to check if user didn't removed any permissions and open our app again.

Also you can add Permission to ignored list to ignore its changes in access - use ignorePermission(String permission).

Easy asking for permissions

It removes a bit of boiler plate to keep request id, and thus simplify your code inside Activity class. call Nammu.askForPermission(Activity, PermissionString , PermissionCallback) which offers a nice callback with either success or fail method. To use this only thing you need to add is in your Activity that you are using.

@Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {

  Nammu.onRequestPermissionsResult(requestCode, permissions, grantResults);
 
}

Extras

You can get list of monitored Permissions - Nammu.getPrevPermissions(), list of currently granted permissions - getGrantedPermissions(), and few less important.

How to import it?

It is available on jitpack.io by adding this to your build.gradle:

repositories {

  maven {

url "https://jitpack.io"
  
}
 
}
  dependencies {

  compile 'com.github.tajchert:nammu:1.2.0' 
}

Resources

An extension for Google's AutoValue that omits @IgnoreHashEquals field values from hashCode() and equals().

A script which synchronizes all of the artifacts in your local Android SDK to a remote Maven artifact host.

ColorTextView allows to mark some phrase with colors.

Fan Layout Manager for Android by Cleveroad.

Minimalist set of classes that offers you to group a set of variables in a type safe way like java Pair does it with two variables

The library offers classes to group 3 to 10 items in the way, Java Pair does it.

It's a layout to show current data loading status (loading, load success, load error).

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes