Rationale


Source link: https://github.com/KingsMentor/Rationale

Rationale

Android permission Rationale Helper. Similar to WhatsApp Permission Rationale Dialog that manages permission request .

How it Works.

  1. Init with a list of Permission called SmoothPermissions
  2. Rationale runs a check on all SmoothPermissions to determine which Permission to show a message for
  3. if the list is empty, it returns success with empty list
  4. if there is any permission to be granted, it shows the appropraite rationale to the user
  5. returns permissions to be requested for based on user interaction

Adding Rationale to your Project

Step 1 Add it in your root build.gradle at the end of repositories:

allprojects {

repositories {

 ...

 maven {
 url 'https://jitpack.io' 
}

}

  
}
 

Step 2 Add the dependency

dependencies {

 compile 'com.github.KingsMentor:Rationale:v1.0'
  
}

Using Rationale

Using in an Activity

private final int PERM = 2017;  final PermissionDetails smsPermissionDetails = new PermissionDetails().getPermissionDetails(this, Manifest.permission.READ_SMS, R.drawable.ic_sms_white_24dp);

Rationale.withActivity(this)

  .requestCode(PERM)

  .addSmoothPermission(new SmoothPermission(smsPermissionDetails))

  .includeStyle(R.style.Beliv_RationaleStyle).build(true);

Using in a Fragment*


  Rationale.withFragment(this)

  .requestCode(PERM)

  .addSmoothPermission(new SmoothPermission(smsPermissionDetails))

  .includeStyle(R.style.Beliv_RationaleStyle).build(true);
  • requestCode - request code to track response from onActivityResult
  • includeStyle - styling the Rationale Dialog. more details on styling is found below
  • SmoothPermissions - List of Permission to run Rationale Dialog on
  • build - takes true for Rationale Dialog to show Permission that has not been granted. false to only show rationale for permission permanently denied.
PermissionDetails

Build permission with :

  • Permission name
  • Permission Icon
  • rationaleMessage
  • deniedMessage - message to display when Permission is permanently denied by the user
  • description - System Permission Description
  • protectionLevel - Protection level of permission

Response from Rationale

Rationale returns response via onActivityResult. Here is a snippet on handling response from Rationale.

@Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {

if (Rationale.isResultFromRationale(requestCode, PERM)) {

 RationaleResponse rationaleResponse = Rationale.getRationaleResponse(data);

 if (rationaleResponse.shouldRequestForPermissions()) {

  // a list of permission to be requested for

  ArrayList<SmoothPermission> smoothPermissions = rationaleResponse.getSmoothPermissions();

// request for permissions

 
}
 else if (rationaleResponse.userDecline()) {

  Toast.makeText(this, "user does not want to do this now", Toast.LENGTH_LONG).show();

 
}
 else {

  Toast.makeText(this, "permission is accepted", Toast.LENGTH_LONG).show();

 
}

}

}

Styling Rationale

Rationale dialog can be placing this in styles.xml changing the values to suite your need and including it when initialising Rationale with includeStyle(styleRes)

 <style name="Beliv.RationaleStyle" parent="Theme.AppCompat">

<!-- Customize your theme here. -->

<item name="bv_primary">@color/primary_color</item>

<item name="bv_secondary">@color/secondary_color</item>

<item name="bv_rationale_state_visibility">true</item>

<item name="bv_rationale_state_ignore_color">@color/ignore_state</item>

<item name="bv_rationale_state_deny_color">@color/deny_state</item>

<item name="bv_rationale_text_color_deny">@color/grey</item>

<item name="bv_rationale_text_color_ignore">@color/ignore_state</item>

<item name="bv_card_corner_radius">@dimen/card_corner</item>

<item name="bv_rationale_text_size">@dimen/rationale_text_size</item>

<item name="bv_rationale_text_font">@string/rationale_font</item>

</style>

#License The MIT License (MIT). Please see the License File for more information.

Resources

Project is inspired by ig-json-parser. It basically do the same thing as ig-json-parser, but the differences are:

  • do not use annotations to generate the parsers. but use Scala raw value
  • including a class JsonToSpec which can generate the spec from a folder of json samples. so you not even need to write the spec if you have a working backend. but most of time you will want to customize the result by editing the result spec
  • you can write converter code to convert between types
  • it is dead simple

Great set of colors from http://flatuicolors.com and converted into Android colors.xml

You can easily access the top of the screen in Android. Like a iPhone 6 & 6 Plus.

android-resource-navigator is a a Google Chrome Extension providing enhanced resource navigation for GitHub hosted Android projects.

A custom view that displays an error image, a title, and a subtitle given an HTTP status code. It can be used for various other purposes like displaying other kinds of errors, or just messages with images.

Easier creation of Dagger ObjectGraph scopes with Retrofit and Butterknife niceties

What is Scopes?

Have you ever tried to set up scoped ObjectGraphs with Dagger and failed miserably? Scopes a compile time annotation processor that is here to help!

What does Scopes do? It allows to separate portions of your Application in logical "flows". It generates "BaseActivitys" that contain common dependencies that other Activities that are part of the same flow could use.

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