Skip to content

Commit 88f9442

Browse files
authored
Add gitbook hook on CI(#565)
1 parent 6ae5846 commit 88f9442

File tree

9 files changed

+182
-139
lines changed

9 files changed

+182
-139
lines changed

.travis.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ env:
44
global:
55
- secure: "KY2ZIqFr6RCbZvFpCGo1CXtnmvbGq+uEw/haDOeva7V86A5K+2IzzoCdBTyIcGWo4MfAlfwvtr2z/5JTLQQ9XE2h0N1oVTqJCBPTmorXDFv7CNHxortje9Ra0jrQZY69pXCJePlI9XQ4QOS2pHMujucYt7RFTV/TmU3yI+xBd6PVVTt54mRCSrIAbl5YWGK9lHUWygBn+rLspmAxamSOccqjJlmotzqFp60gedgbrcGOPhLRcuESDn8w45fP0I1owXEhvnIOlMlTavoDc+qeMLckR9xyCYFqxt0jTPaQViR0+JPm7P9Qwho4r9dBcoK+ojqg56fyqQ89sckZ22jXqjmWrKViQdCEB5Oul/n2R2fgH+OfZ1eUffaNTKRAz8a7JgwmPC+X7BiQKxY+GGeZ7tlMxlSyGQGr5EDsAypr9R7r+6WuHtlM7wfSdWNWgMY+CnViJH0f1pl5nftqBzE2PJArU4w1r5tPdkVnGzUHgDrksTGU9WRQ4q/HP+8xZkQjsY1hRuXJlXm+SvMPNyJRn1yxyu2zeetdOmnEUHVN1TgGol3k/sHCUtqF6N4cskpCTFTdXNSZPd3uZs0JLhQR4ygJ6Es+yfPM6pae8jKmUNsUJpl9ctOpwvyZYIsc3rqtLjBWN47v6S/wtOmdJhh1uxz79K7vcPh1Z3pcfGgoVUs="
66
- secure: "ucfbFyzFVzzmGivT3MrH7CbW1Wjs2B2gFIc/iqsJ/jF+1vh0ki2wwmE8pFFGo/4iKF59yCnj0NtxnInX3YVRtLOKD1bqS0yAPOskLlx3XhH5gg4owJ6vo9vuKoizcRabT/ss8SjlFkv7PDHmFWVyUtZmgjkwZbuQbTnMBQv1qzDo+AfS8cuDQAXvWzfMF1R9wEpc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ahjtRe5+Jp2lH9qiBgjt6/IgiXpI4C6H+8rsfz4N7pssmymM7+0hQuSevWaJnhCt9kPdiwHzHJ3lUm/ud1WGZvQQUFH/pTQJXOYqxmDRivQlzWSWQ="
8+
- secure: "znN56WtufsW5EYRWCbc5sJOkuVnZw8J2nhGTGCtLwXOrQhYZvVHlxhNmwkWctBF/kJHNtxGWnq3bcsD3wOm7a/BSdZDCS+JoL0MN75QY93a2xoEoBSO4Wr0oW2s2HFc/+Ik9O8EeeH4YImYUYoQ+LVuFJ6twr+8vQDjrt7S2cndiBdX9cXnMbz5hh98rSy5NFawafp0p+lby8eKV8HjdwDkyHyZGtg2BU1s01ef45iOAXmZtvuRffASIoRTvF8qTanqv90ZUzm50Pl3UcLEx7A5tR+/hExeK1pY5RiRGjrZEWawVIyBjOuQtvjFaLlfmVnIt44fwF7luuVWI6slxyDp/RsXAazOmaaB5vVt8KlhwTUxgQ2NGFXjVaC//C9AiMnnU4ZrBF/D33VkcyHBvtTATtlLbIQliG3x119UGWAjTzJwSAIc/YgEowKK/MR/qHfRSxz+HTR73KV8DA1/yaRAhLPUY9iJ4Kmn0uVKc4WxSJpq+bPyXf4FGmc1AOt4VkSYpwsBxB8kZiqq2er1z+u2lYf2LZFhZ1rtZxvccrQurDE30LSyg2oZAI75/x7o97CLciTu342CM4c1FayRUV4CxIHwOEPenb7DfYvEyiexPDG3/DACcMGVUsYa4oFw3dftufJK9fWkI308uG19L4wqcVvMqAXqpn1NbQU0Akxk="
79

810
android:
911
components:
@@ -24,14 +26,11 @@ before_install:
2426
- mkdir "$ANDROID_HOME/licenses" || true
2527
- cp ./android-sdk-licenses/* "$ANDROID_HOME/licenses/"
2628

27-
branches:
28-
except:
29-
- gh-pages
30-
3129
script: ./gradlew clean check --stacktrace
3230

3331
after_success:
34-
- "./scripts/deploy_snapshot.sh"
32+
- ./scripts/deploy_snapshot.sh
33+
- ./scripts/push-to-github-io.sh
3534

3635
deploy:
3736
skip_cleanup: true
@@ -40,3 +39,10 @@ deploy:
4039
on:
4140
tags: true
4241
repo: permissions-dispatcher/PermissionsDispatcher
42+
43+
cache:
44+
directories:
45+
- $HOME/.m2
46+
- $HOME/.gradle/caches/
47+
- $HOME/.gradle/wrapper/
48+
- $HOME/.android/build-cache

.travis/deploy_key.enc

1.83 KB
Binary file not shown.

README.md

Lines changed: 15 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,118 +1,18 @@
11
# PermissionsDispatcher [![Build Status](https://travis-ci.org/permissions-dispatcher/PermissionsDispatcher.svg?branch=master)](https://travis-ci.org/permissions-dispatcher/PermissionsDispatcher)
22

3-
- [**Fully Kotlin support**](https://github.com/hotchemi/PermissionsDispatcher/blob/master/doc/kotlin_support.md)
3+
- [**Kotlin support**](https://github.com/hotchemi/PermissionsDispatcher/blob/master/doc/kotlin_support.md)
44
- [**Special Permissions support**](https://github.com/hotchemi/PermissionsDispatcher/blob/master/doc/special_permissions.md)
55
- **100% reflection-free**
66

77
PermissionsDispatcher provides a simple annotation-based API to handle runtime permissions.
88

99
This library lifts the burden that comes with writing a bunch of check statements whether a permission has been granted or not from you, in order to keep your code clean and safe.
1010

11-
## Usage
12-
13-
- If you're using Kotlin check [**Kotlin ver**](https://github.com/hotchemi/PermissionsDispatcher/blob/master/doc/kotlin_support.md) first of all.
14-
15-
Here's a minimum example, in which you register a `MainActivity` which requires `Manifest.permission.CAMERA`.
16-
17-
### 0. Prepare AndroidManifest
18-
19-
Add the following line to `AndroidManifest.xml`:
20-
21-
`<uses-permission android:name="android.permission.CAMERA" />`
22-
23-
### 1. Attach annotations
24-
25-
PermissionsDispatcher introduces only a few annotations, keeping its general API concise:
26-
27-
> NOTE: Annotated methods must not be `private`.
28-
29-
|Annotation|Required|Description|
30-
|---|---|---|
31-
|`@RuntimePermissions`|****|Register an `Activity` or `Fragment`(we support both) to handle permissions|
32-
|`@NeedsPermission`|****|Annotate a method which performs the action that requires one or more permissions|
33-
|`@OnShowRationale`||Annotate a method which explains why the permission/s is/are needed. It passes in a `PermissionRequest` object which can be used to continue or abort the current permission request upon user input|
34-
|`@OnPermissionDenied`||Annotate a method which is invoked if the user doesn't grant the permissions|
35-
|`@OnNeverAskAgain`||Annotate a method which is invoked if the user chose to have the device "never ask again" about a permission|
36-
37-
```java
38-
@RuntimePermissions
39-
public class MainActivity extends AppCompatActivity {
40-
41-
@NeedsPermission(Manifest.permission.CAMERA)
42-
void showCamera() {
43-
getSupportFragmentManager().beginTransaction()
44-
.replace(R.id.sample_content_fragment, CameraPreviewFragment.newInstance())
45-
.addToBackStack("camera")
46-
.commitAllowingStateLoss();
47-
}
48-
49-
@OnShowRationale(Manifest.permission.CAMERA)
50-
void showRationaleForCamera(final PermissionRequest request) {
51-
new AlertDialog.Builder(this)
52-
.setMessage(R.string.permission_camera_rationale)
53-
.setPositiveButton(R.string.button_allow, (dialog, button) -> request.proceed())
54-
.setNegativeButton(R.string.button_deny, (dialog, button) -> request.cancel())
55-
.show();
56-
}
57-
58-
@OnPermissionDenied(Manifest.permission.CAMERA)
59-
void showDeniedForCamera() {
60-
Toast.makeText(this, R.string.permission_camera_denied, Toast.LENGTH_SHORT).show();
61-
}
62-
63-
@OnNeverAskAgain(Manifest.permission.CAMERA)
64-
void showNeverAskForCamera() {
65-
Toast.makeText(this, R.string.permission_camera_neverask, Toast.LENGTH_SHORT).show();
66-
}
67-
}
68-
```
69-
70-
### 2. Delegate to generated class
71-
72-
Upon compilation, PermissionsDispatcher generates a class for `MainActivityPermissionsDispatcher`([Activity Name] + PermissionsDispatcher), which you can use to safely access these permission-protected methods.
73-
74-
The only step you have to do is delegating the work to this helper class:
75-
76-
```java
77-
@Override
78-
protected void onCreate(Bundle savedInstanceState) {
79-
super.onCreate(savedInstanceState);
80-
setContentView(R.layout.activity_main);
81-
findViewById(R.id.button_camera).setOnClickListener(v -> {
82-
// NOTE: delegate the permission handling to generated method
83-
MainActivityPermissionsDispatcher.showCameraWithPermissionCheck(this);
84-
});
85-
}
86-
87-
@Override
88-
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
89-
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
90-
// NOTE: delegate the permission handling to generated method
91-
MainActivityPermissionsDispatcher.onRequestPermissionsResult(this, requestCode, grantResults);
92-
}
93-
```
94-
95-
Check out the [sample](https://github.com/hotchemi/PermissionsDispatcher/tree/master/sample) for more details.
96-
97-
## Other features
98-
99-
- [Getting Special Permissions](https://github.com/hotchemi/PermissionsDispatcher/blob/master/doc/special_permissions.md)
100-
- [maxSdkVersion](https://github.com/hotchemi/PermissionsDispatcher/blob/master/doc/maxsdkversion.md)
101-
- [IntelliJ plugin](https://github.com/shiraji/permissions-dispatcher-plugin)
102-
- AndroidAnnotations plugin
103-
- If you use [AndroidAnnotations](http://androidannotations.org/), you need to add [AndroidAnnotationsPermissionsDispatcherPlugin](https://github.com/AleksanderMielczarek/AndroidAnnotationsPermissionsDispatcherPlugin).
104-
105-
### Known issues
106-
107-
If you're in trouble check known issues [list](https://github.com/hotchemi/PermissionsDispatcher/blob/master/doc/known_issues.md) before filing an issue.
108-
109-
### Users
110-
111-
Thankfully we've got hundreds of [users](https://github.com/hotchemi/PermissionsDispatcher/blob/master/doc/users.md) around the world!
11+
For more information please see [the website](https://permissions-dispatcher.github.io/).
11212

11313
## Download
11414

115-
NOTE: 4.x only supports [Jetpack](https://developer.android.com/jetpack/). If you use appcompat 3.x which is almost stable is the way to go.
15+
NOTE: 4.x only supports [Jetpack](https://developer.android.com/jetpack/). If you still use appcompat 3.x is the way to go.
11616

11717
To add PermissionsDispatcher to your project, include the following in your **app module** `build.gradle` file:
11818

@@ -125,6 +25,17 @@ dependencies {
12525
}
12626
```
12727

28+
With Kotlin:
29+
30+
```groovy
31+
apply plugin: 'kotlin-kapt'
32+
33+
dependencies {
34+
implementation "com.github.hotchemi:permissionsdispatcher:${latest.version}"
35+
kapt "com.github.hotchemi:permissionsdispatcher-processor:${latest.version}"
36+
}
37+
```
38+
12839
Snapshots of the development version are available in [JFrog's snapshots repository](https://oss.jfrog.org/oss-snapshot-local/).
12940
Add the repo below to download `SNAPSHOT` releases.
13041

@@ -135,13 +46,7 @@ repositories {
13546
}
13647
```
13748

138-
### Misc
139-
140-
- If you include [Jitpack.io](https://jitpack.io/) dependencies in your project, it is important to review the order of the repositories available to your app module
141-
- Because of the library's artifact ID, Jitpack might be tempted to resolve the dependency on its own, which could lead to an error during Gradle's configuration time
142-
- If you're going to bump up the major version number we recommend to refer to [migration guide](https://github.com/hotchemi/PermissionsDispatcher/blob/master/doc/migration_guide.md)
143-
144-
## Licence
49+
## License
14550

14651
```
14752
Copyright 2016 Shintaro Katafuchi, Marcel Schnelle, Yoshinori Isogai

SUMMARY.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Summary
2+
3+
- [Introduction](README.md)
4+
5+
## Getting Started
6+
7+
- [Java](doc/java_usage.md)
8+
- [Kotlin](doc/kotlin_usage.md)
9+
10+
## Features
11+
12+
- [Special Permissions](doc/special_permissions.md)
13+
- [maxSdkVersion](doc/maxsdkversion.md)
14+
15+
## Plugins
16+
17+
- [IntelliJ plugin](https://github.com/shiraji/permissions-dispatcher-plugin)
18+
- [AndroidAnnotations plugin](https://github.com/permissions-dispatcher/AndroidAnnotationsPermissionsDispatcherPlugin)
19+
20+
## Others
21+
22+
- [Changelog](CHANGELOG.md)
23+
- [Users](doc/users.md)
24+
- [Migration Guide](doc/migration_guide.md)

doc/java_usage.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
## Usage with Java
2+
3+
Here's a minimum example, in which you register a `MainActivity` which requires `Manifest.permission.CAMERA`.
4+
5+
### 0. Prepare AndroidManifest
6+
7+
Add the following line to `AndroidManifest.xml`:
8+
9+
`<uses-permission android:name="android.permission.CAMERA" />`
10+
11+
### 1. Attach annotations
12+
13+
PermissionsDispatcher introduces only a few annotations, keeping its general API concise:
14+
15+
> NOTE: Annotated methods must not be `private`.
16+
17+
|Annotation|Required|Description|
18+
|---|---|---|
19+
|`@RuntimePermissions`|****|Register an `Activity` or `Fragment`(we support both) to handle permissions|
20+
|`@NeedsPermission`|****|Annotate a method which performs the action that requires one or more permissions|
21+
|`@OnShowRationale`||Annotate a method which explains why the permission/s is/are needed. It passes in a `PermissionRequest` object which can be used to continue or abort the current permission request upon user input|
22+
|`@OnPermissionDenied`||Annotate a method which is invoked if the user doesn't grant the permissions|
23+
|`@OnNeverAskAgain`||Annotate a method which is invoked if the user chose to have the device "never ask again" about a permission|
24+
25+
```java
26+
@RuntimePermissions
27+
public class MainActivity extends AppCompatActivity {
28+
29+
@NeedsPermission(Manifest.permission.CAMERA)
30+
void showCamera() {
31+
getSupportFragmentManager().beginTransaction()
32+
.replace(R.id.sample_content_fragment, CameraPreviewFragment.newInstance())
33+
.addToBackStack("camera")
34+
.commitAllowingStateLoss();
35+
}
36+
37+
@OnShowRationale(Manifest.permission.CAMERA)
38+
void showRationaleForCamera(final PermissionRequest request) {
39+
new AlertDialog.Builder(this)
40+
.setMessage(R.string.permission_camera_rationale)
41+
.setPositiveButton(R.string.button_allow, (dialog, button) -> request.proceed())
42+
.setNegativeButton(R.string.button_deny, (dialog, button) -> request.cancel())
43+
.show();
44+
}
45+
46+
@OnPermissionDenied(Manifest.permission.CAMERA)
47+
void showDeniedForCamera() {
48+
Toast.makeText(this, R.string.permission_camera_denied, Toast.LENGTH_SHORT).show();
49+
}
50+
51+
@OnNeverAskAgain(Manifest.permission.CAMERA)
52+
void showNeverAskForCamera() {
53+
Toast.makeText(this, R.string.permission_camera_neverask, Toast.LENGTH_SHORT).show();
54+
}
55+
}
56+
```
57+
58+
### 2. Delegate to generated class
59+
60+
Upon compilation, PermissionsDispatcher generates a class for `MainActivityPermissionsDispatcher`([Activity Name] + PermissionsDispatcher), which you can use to safely access these permission-protected methods.
61+
62+
The only step you have to do is delegating the work to this helper class:
63+
64+
```java
65+
@Override
66+
protected void onCreate(Bundle savedInstanceState) {
67+
super.onCreate(savedInstanceState);
68+
setContentView(R.layout.activity_main);
69+
findViewById(R.id.button_camera).setOnClickListener(v -> {
70+
// NOTE: delegate the permission handling to generated method
71+
MainActivityPermissionsDispatcher.showCameraWithPermissionCheck(this);
72+
});
73+
}
74+
75+
@Override
76+
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
77+
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
78+
// NOTE: delegate the permission handling to generated method
79+
MainActivityPermissionsDispatcher.onRequestPermissionsResult(this, requestCode, grantResults);
80+
}
81+
```
82+
83+
Check out the [sample](https://github.com/hotchemi/PermissionsDispatcher/tree/master/sample) for more details.

doc/known_issues.md

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,13 @@
1-
## Fully Kotlin support
1+
## Usage with Kotlin
22

3-
From 3.0.0 we started support `.kt` file generation.
4-
5-
Let's think about the same example as described in `README.md`.
3+
Here's a minimum example, in which you register a `MainActivity` which requires `Manifest.permission.CAMERA`.
64

75
### 0. Preparation
86

97
Add the following line to `AndroidManifest.xml`:
108

119
`<uses-permission android:name="android.permission.CAMERA" />`
1210

13-
Include the following in your **app module** `build.gradle` file:
14-
15-
`${latest.version}` is [![Download](https://api.bintray.com/packages/hotchemi/maven/permissionsdispatcher/images/download.svg)](https://bintray.com/hotchemi/maven/permissionsdispatcher/_latestVersion)
16-
17-
```groovy
18-
apply plugin: 'kotlin-kapt'
19-
20-
dependencies {
21-
implementation "com.github.hotchemi:permissionsdispatcher:${latest.version}"
22-
kapt "com.github.hotchemi:permissionsdispatcher-processor:${latest.version}"
23-
}
24-
```
25-
2611
### 1. Attach annotations
2712

2813
> NOTE: Annotated methods must not be `private`.

doc/special_permissions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Getting Special Permissions
1+
## Special Permissions
22

33
PermissionsDispatcher takes care of special permissions `Manifest.permission.SYSTEM_ALERT_WINDOW` and `Manifest.permission.WRITE_SETTINGS`.
44

scripts/push-to-github-io.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
3+
declare repoName="permissions-dispatcher.github.io"
4+
declare repoUrl="[email protected]:permissions-dispatcher/${repoName}.git"
5+
declare distDir="_book"
6+
declare branch="master"
7+
declare commitMessage="Update content from TravisCI."
8+
9+
commit_and_push_changes() {
10+
git config --global user.email "$GH_USER_EMAIL" \
11+
&& git config --global user.name "$GH_USER_NAME" \
12+
&& git add -A \
13+
&& git commit --message "$2" \
14+
&& git push --quiet --force "${repoUrl}" "$1"
15+
}
16+
17+
if [ "$TRAVIS_BRANCH" != "master" ] || [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
18+
echo "Skip updating gitbook: branch is not master or the build was triggered by pull request."
19+
exit 0;
20+
fi
21+
22+
echo "Decrypt deploy key"
23+
openssl aes-256-cbc -K $encrypted_786b61619ad8_key -iv $encrypted_786b61619ad8_iv -in .travis/deploy_key.enc -out deploy_key -d
24+
chmod 600 deploy_key
25+
eval `ssh-agent -s`
26+
ssh-add deploy_key
27+
28+
echo "Clone repo"
29+
rm -rf ${repoName}
30+
git clone ${repoUrl} ${repoName}
31+
32+
echo "Install Node and dependencies"
33+
. $HOME/.nvm/nvm.sh
34+
nvm install stable
35+
nvm use stable
36+
npm install -g gitbook-cli
37+
38+
echo "Build HTML"
39+
gitbook build
40+
41+
echo "Copy files"
42+
cp -Rf "${distDir}/doc"* "${distDir}/gitbook"* "${distDir}/*.html" "${distDir}/search_index.json" "${repoName}"
43+
44+
echo "Commit and push"
45+
cd "${repoName}"
46+
commit_and_push_changes "${branch}" "${commitMessage}"

0 commit comments

Comments
 (0)