# PermissionHelper **Repository Path**: baijuncheng-open-source/permission-helper ## Basic Information - **Project Name**: PermissionHelper - **Description**: 鸿蒙权限管理请求库 - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2021-03-29 - **Last Updated**: 2021-07-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # PermissionHelper Harmony Library to help you with your runtime Permissions. Demo ![record](https://images.gitee.com/uploads/images/2021/0330/095939_091df5ad_8230582.png "1.png") ![calendar](https://images.gitee.com/uploads/images/2021/0330/100004_89796c76_8230582.png "2.png") ![exchange](https://images.gitee.com/uploads/images/2021/0330/100039_208c6f1d_8230582.png "3.png") Usage ===== ### Using PermissionHelper Library in your application #### Solution 1: local source code integration, users can customize base on the source code 1.Copy permission folder to the project directory; 2.Modify project settings.gradle, add dependencies on three modules as follows: ``` include ':permission' ``` 3.Introduce the dependency of imported module in the project. Take the entry module as an example, you need to modify the dependency of imported module in the entry module build.gradle file to add dependencies: ```xml dependencies { entryImplementation project(':entry') implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) debugImplementation project(path: ':permission') } ``` #### Solution 2: local har package integration 1.Compile the project and copy the har package generated in the build directory of folder permission to the project lib folder 2.Add the following code in gradle of entry ``` implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) ``` #### Solution 3: remote maven repo integration ```xml implementation 'com.gitee.baijuncheng-open-source:PermissionHelper:1.0.0' ``` # Ask Permissions in Style _Have you wondered what will give you a higher chance of letting the user accepts your permission?_ >The answer is simple: **(Educating UI)** that explains why you need to use that particular `permission`. * By extending BasePageAbility you'll have control over (**Features**): * Permissions that being asked and their Explanation if its needed. * Each `Screen` Background color . * Each `Screen` Image Resource. * Each `Screen` Title & Message. * Each `Screen` Title & Message Text Color. * Each `Screen` Title & Message Text Size. * Each `Screen` Text & Message `FontType`, yes you heard me right, each `Screen` can have their own `FontType`. * Each `Screen` Next, Previous & Request Buttons Icon Resources. * Your Own `Theme`. > For Better Understanding, please have a look at the example code at BasePageAbility # Take Control. Your ```Ability``` should implement ```OnPermissionCallback``` which in return will give you access to ```code void onPermissionGranted(String[] permissionName); void onPermissionDeclined(String[] permissionName); void onPermissionPreGranted(String permissionName); void onPermissionReallyDeclined(String permissionName); //haromony中权限申明直接在config.json中配置 鸿蒙不需要 // void onPermissionNeedExplanation( String permissionName); // void onNoPermissionNeeded(); 鸿蒙中不需要跳页申请权限,OnActivityPermissionCallback接口不需要 // OnActivityPermissionCallback // 因为harmony中fraction无法和pagerSlider配合使用,是直接由子类传值的 BaseCallback接口不需要 // 鸿蒙官方目前不支持三方字体,不需要从资源中那问题,所以FontTypeHelper类也可以简化 to request a permission all you have to do is: - Ability ​```code permissionHelper .setForceAccepting(false)// true if you had like force reshowing the permission dialog on Deny (not recommended) PermissionModel.setForceAccepting() ``` and finally in your `Ability` ​```java onRequestPermissionsResult....) # Why this library? * Its simple to use. * Its Unique, Customizable & read back first point. * You have two choices, do it your way through `callbacks`, or let the `Library` do it for you with your look & Feel. * Minimum API is 4,. # Copyright Notice Copyright (C) 2015 Kosh. Licensed under the [Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0) license (see the LICENSE file).