Behavior - ParadiseHell/PermissionTerminator GitHub Wiki

Introducation

There are 3 kinds of behavior in ParmissionTerminator.

  • PermissionRationalBehavior
    • This behavior is used to explain why we need to ask for permissions in a common way while we requesting. And in this behavior, we can do 2 things using RationalRequest
      • Cancel to request permissions which will invoke PermissionCallabck#onDenied.
      • Do real requesting.
  • PermissionDenialBehavior
    • This behavior is used to handle such a situation when at least one permission is denied in a common way. And in this behavior, we can do 2 things using DenialRequest
      • Cancel to handle this situation which will invoke PermissionCallabck#onDenied.
      • Request again denied permissions.
  • PermissionNeverAskBehavior.
    • This behavior is used to handle such a situation when at least one permission is marked never ask again. And in this behavior, we can do 2 things using NeverAskRequest
      • Cancel to handle this situation which will invoke PermissionCallabck#onNeverAsked.
      • Launch system setting activity to let users allow permissions that are marked never ask again, after that PermissionTerminator will check whether these permissions are granted or not.

How to use

PermissionRationalBehavior

Add a custom PermissionRationalBehavior using PermissionRationalBehavior.Factory, of course we can more type of PermissionRationalBehavior.

PermissionTerminator.addRationalBehaviorFactory(factoryType, factory)

Set a default PermissionRationalBehavior to handle a common situation.

PermissionTerminator.setDefaultRationalBehaviorFactoryType(factoryType)

Use a different PermissionRationalBehavior not just default.

PermissionTerminator
	.with(this)
    .withRationalBehavior(rationalType)

Disable to use PermissionRationalBehavior.

PermissionTerminator
	.with(this)
    .disableRationalBehavior()

PermissionDenialBehavior

Add a custom PermissionDenialBehavior using PermissionDenialBehavior.Factory, of course we can more type of PermissionDenialBehavior.

PermissionTerminator.addDenialBehavior(type, factory)

Set a default PermissionDenialBehavior to handle a common situation.

PermissionTerminator.setDefaultDenialBehaviorFactoryType(factoryType)

Use a different PermissionDenialBehavior not just default.

PermissionTerminator
	.with(this)
    .withDenialBehavior(denialType)

Disable to use PermissionDenialBehavior.

PermissionTerminator
	.with(this)
    .disableDenialBehavior()

PermissionNeverAskBehavior

Add a custom PermissionNeverAskBehavior using PermissionNeverAskBehavior.Factory, of course we can more type of PermissionNeverAskBehavior.

PermissionTerminator.addNeverAskBehavior(factoryType, factory)

Set a default PermissionNeverAskBehavior to handle a common situation.

PermissionTerminator.setDefaultNeverAskBehaviorFactoryType(factoryType)

Use a different PermissionNeverAskBehavior not just default.

PermissionTerminator
	.with(this)
    .withNeverAskBehavior(neverAskType)

Disable to use PermissionNeverAskBehavior.

PermissionTerminator
	.with(this)
    .disableNeverAskBehavior()