├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── ci-gradle.properties ├── pull_request_template.md └── workflows │ ├── check.yml │ ├── release.yml │ └── scheduled.yml ├── .gitignore ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md ├── README_ZH.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── qifan │ │ │ └── powerpermission │ │ │ ├── MainActivity.kt │ │ │ ├── activity │ │ │ └── ExampleActivity.kt │ │ │ ├── childfragment │ │ │ ├── ExampleChildContainerFragment.kt │ │ │ └── ExampleChildFragment.kt │ │ │ ├── coroutines │ │ │ └── CoroutinesActivity.kt │ │ │ ├── fragment │ │ │ └── ExampleFragment.kt │ │ │ ├── livedata │ │ │ └── LiveDataActivity.kt │ │ │ └── rx │ │ │ ├── RxJava2Activity.kt │ │ │ └── RxJava3Activity.kt │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ ├── activity_coroutines_exmaple.xml │ │ ├── activity_example.xml │ │ ├── activity_live_data.xml │ │ ├── activity_main.xml │ │ ├── activity_rx2_exmaple.xml │ │ ├── activity_rx3_exmaple.xml │ │ ├── fragment_child_container_example.xml │ │ ├── fragment_child_example.xml │ │ └── fragment_example.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── qifan │ └── powerpermission │ └── ExampleUnitTest.kt ├── build.gradle ├── dependencies.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── powerpermission-coroutines ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ ├── main │ ├── AndroidManifest.xml │ └── java │ │ └── com │ │ └── qifan │ │ └── powerpermission │ │ └── coroutines │ │ ├── CheckOnMainThread.kt │ │ └── PowerPermissionCoroutines.kt │ └── test │ └── java │ └── com │ └── qifan │ └── powerpermission │ └── coroutines │ └── ExampleUnitTest.kt ├── powerpermission-livedata ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ └── com │ └── qifan │ └── powerpermission │ └── livedata │ └── PowerPermissionLiveData.kt ├── powerpermission-rxjava2 ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ └── com │ └── qifan │ └── powerpermission │ └── rx2 │ ├── CheckOnMainThreadRx2.kt │ └── PowerPermissionRx2.kt ├── powerpermission-rxjava3 ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ └── com │ └── qifan │ └── powerpermission │ └── rx3 │ ├── CheckOnMainThreadRx3.kt │ └── PowerPermissionRx3.kt ├── powerpermission ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ ├── main │ ├── AndroidManifest.xml │ └── java │ │ └── com │ │ └── qifan │ │ └── powerpermission │ │ ├── Activities.kt │ │ ├── Fragments.kt │ │ ├── PowerPermission.kt │ │ ├── core │ │ ├── PermissionFragment.kt │ │ ├── PermissionRequestParams.kt │ │ ├── PowerPermissionManager.kt │ │ └── extension │ │ │ ├── FragmentExt.kt │ │ │ ├── LoggingExt.kt │ │ │ └── PermissionExt.kt │ │ ├── data │ │ ├── Configuration.kt │ │ ├── GrantResult.kt │ │ ├── PermissionResult.kt │ │ └── RationaleData.kt │ │ └── rationale │ │ ├── DialogRationale.kt │ │ └── delegate │ │ ├── RationaleActionCallback.kt │ │ ├── RationaleDelegate.kt │ │ └── dialog │ │ └── DialogRationaleDelegate.kt │ └── test │ └── java │ └── com │ └── qifan │ └── powerpermission │ ├── PowerPermissionManager.kt │ └── data │ ├── GrantResultTest.kt │ ├── PermissionResultTest.kt │ └── RationaleDataTest.kt ├── publish-module.gradle ├── publish-root.gradle ├── settings.gradle ├── spotless ├── copyright.java ├── copyright.kt └── spotless.gradle └── version_plugin_config.gradle /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/ci-gradle.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2020 Qifan YANG (@underwindfall) 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | org.gradle.daemon=false 18 | org.gradle.parallel=true 19 | org.gradle.jvmargs=-Xmx5120m 20 | org.gradle.workers.max=2 21 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ### Guidelines 2 | 3 | 1. You must run the `spotlessApply` task before commiting, either through Android Studio or with `./gradlew spotlessApply`. 4 | 2. A PR should be focused and contained. If you are changing multiple unrelated things, they should be in separate PRs. 5 | 3. A PR should fix a bug or solve a problem - something that only you would use is not necessarily something that should be published. 6 | 4. Give your PR a detailed title and description - look over your code one last time before actually creating the PR. Give it a self-review. 7 | 8 | **If you do not follow the guidelines, your PR will be rejected.** -------------------------------------------------------------------------------- /.github/workflows/check.yml: -------------------------------------------------------------------------------- 1 | name: Android Check CI 2 | on: [push] 3 | 4 | jobs: 5 | build: 6 | 7 | runs-on: ubuntu-latest 8 | 9 | steps: 10 | - name: Checkout code 11 | uses: actions/checkout@v2 12 | 13 | - name: Use Java11 14 | uses: actions/setup-java@v2 15 | with: 16 | distribution: adopt 17 | java-version: 11 18 | 19 | - name: Build with Gradle 20 | run: ./gradlew build check 21 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release And Update 2 | on: 3 | push: 4 | tags: 5 | - "v*" 6 | 7 | jobs: 8 | publish: 9 | name: Release APK 10 | runs-on: ubuntu-latest 11 | steps: 12 | 13 | - name: Checkout code 14 | uses: actions/checkout@v2 15 | 16 | - name: Use Java11 17 | uses: actions/setup-java@v2 18 | with: 19 | distribution: adopt 20 | java-version: 11 21 | 22 | - name: Generate Debug APK 23 | run: ./gradlew clean assembleDebug 24 | 25 | - name: Upload APK 26 | uses: actions/upload-artifact@v1 27 | with: 28 | name: apk 29 | path: app/build/outputs/apk/debug/app-debug.apk 30 | 31 | - name: Get the version 32 | id: get_version 33 | run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} 34 | 35 | - name: Create Release and Upload debug APK 36 | uses: underwindfall/create-release-with-debugapk@v1.2.4 37 | env: 38 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 39 | with: 40 | tag_name: ${{ steps.get_version.outputs.VERSION }} 41 | release_name: Release ${{ steps.get_version.outputs.VERSION }} 42 | asset_path: app/build/outputs/apk/debug/app-debug.apk 43 | asset_name: Example.apk 44 | asset_content_type: application/zip 45 | draft: false 46 | prerelease: false 47 | 48 | - name: Release build 49 | run: ./gradlew assembleRelease 50 | 51 | # Generates other artifacts (javadocJar is optional) 52 | - name: Source jar and dokka 53 | run: ./gradlew androidSourcesJar javadocJar 54 | 55 | - name: Publish Library MavenCenteral 56 | run: ./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1 closeAndReleaseSonatypeStagingRepository 57 | env: 58 | OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} 59 | OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} 60 | SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} 61 | SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} 62 | SIGNING_KEY: ${{ secrets.SIGNING_KEY }} 63 | SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} 64 | 65 | 66 | - name: Notification Slack 67 | uses: homoluctus/slatify@v2.1.2 68 | if: always() 69 | with: 70 | type: ${{ job.status }} 71 | job_name: 'Deployment Notification' 72 | mention: 'here' 73 | mention_if: 'failure' 74 | icon_emoji: ':rocket:' 75 | channel: '#android-apps-website' 76 | url: ${{ secrets.SLACK_WEBHOOK_URL }} 77 | commit: true 78 | token: ${{ secrets.CI_LIB_TOKEN }} 79 | 80 | -------------------------------------------------------------------------------- /.github/workflows/scheduled.yml: -------------------------------------------------------------------------------- 1 | name: Nightly tasks 2 | 3 | on: 4 | schedule: 5 | - cron: '0 0 * * *' 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | timeout-minutes: 20 11 | 12 | env: 13 | TERM: dumb 14 | 15 | steps: 16 | - uses: actions/checkout@v2 17 | 18 | - name: set up JDK 19 | uses: actions/setup-java@v1 20 | with: 21 | java-version: 11 22 | 23 | - name: Copy CI gradle.properties 24 | run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties 25 | 26 | - name: Check dependency updates 27 | run: ./gradlew dependencyUpdates 28 | 29 | - name: Upload dependency updates report 30 | uses: actions/upload-artifact@v1 31 | with: 32 | name: dependency-updates 33 | path: build/dependencyUpdates 34 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/android,androidstudio 3 | # Edit at https://www.gitignore.io/?templates=android,androidstudio 4 | 5 | ### Android ### 6 | # Built application files 7 | *.apk 8 | *.ap_ 9 | *.aab 10 | 11 | # Files for the ART/Dalvik VM 12 | *.dex 13 | 14 | # Java class files 15 | *.class 16 | 17 | # Generated files 18 | bin/ 19 | gen/ 20 | out/ 21 | release/ 22 | 23 | # Gradle files 24 | .gradle/ 25 | build/ 26 | 27 | # Local configuration file (sdk path, etc) 28 | local.properties 29 | 30 | # Proguard folder generated by Eclipse 31 | proguard/ 32 | 33 | # Log Files 34 | *.log 35 | 36 | # Android Studio Navigation editor temp files 37 | .navigation/ 38 | 39 | # Android Studio captures folder 40 | captures/ 41 | 42 | # IntelliJ 43 | *.iml 44 | .idea/workspace.xml 45 | .idea/tasks.xml 46 | .idea/gradle.xml 47 | .idea/assetWizardSettings.xml 48 | .idea/dictionaries 49 | .idea/libraries 50 | # Android Studio 3 in .gitignore file. 51 | .idea/caches 52 | .idea/modules.xml 53 | # Comment next line if keeping position of elements in Navigation Editor is relevant for you 54 | .idea/navEditor.xml 55 | 56 | # Keystore files 57 | # Uncomment the following lines if you do not want to check your keystore files in. 58 | #*.jks 59 | #*.keystore 60 | 61 | # External native build folder generated in Android Studio 2.2 and later 62 | .externalNativeBuild 63 | 64 | # Google Services (e.g. APIs or Firebase) 65 | # google-services.json 66 | 67 | # Freeline 68 | freeline.py 69 | freeline/ 70 | freeline_project_description.json 71 | 72 | # fastlane 73 | fastlane/report.xml 74 | fastlane/Preview.html 75 | fastlane/screenshots 76 | fastlane/test_output 77 | fastlane/readme.md 78 | 79 | # Version control 80 | vcs.xml 81 | 82 | # lint 83 | lint/intermediates/ 84 | lint/generated/ 85 | lint/outputs/ 86 | lint/tmp/ 87 | # lint/reports/ 88 | 89 | ### Android Patch ### 90 | gen-external-apklibs 91 | output.json 92 | 93 | # Replacement of .externalNativeBuild directories introduced 94 | # with Android Studio 3.5. 95 | .cxx/ 96 | 97 | ### AndroidStudio ### 98 | # Covers files to be ignored for android development using Android Studio. 99 | 100 | # Built application files 101 | 102 | # Files for the ART/Dalvik VM 103 | 104 | # Java class files 105 | 106 | # Generated files 107 | 108 | # Gradle files 109 | .gradle 110 | 111 | # Signing files 112 | .signing/ 113 | 114 | # Local configuration file (sdk path, etc) 115 | 116 | # Proguard folder generated by Eclipse 117 | 118 | # Log Files 119 | 120 | # Android Studio 121 | /*/build/ 122 | /*/local.properties 123 | /*/out 124 | /*/*/build 125 | /*/*/production 126 | *.ipr 127 | *~ 128 | *.swp 129 | 130 | # Android Patch 131 | 132 | # External native build folder generated in Android Studio 2.2 and later 133 | 134 | # NDK 135 | obj/ 136 | 137 | # IntelliJ IDEA 138 | *.iws 139 | /out/ 140 | 141 | # User-specific configurations 142 | .idea/caches/ 143 | .idea/libraries/ 144 | .idea/shelf/ 145 | .idea/.name 146 | .idea/compiler.xml 147 | .idea/copyright/profiles_settings.xml 148 | .idea/encodings.xml 149 | .idea/misc.xml 150 | .idea/scopes/scope_settings.xml 151 | .idea/vcs.xml 152 | .idea/jsLibraryMappings.xml 153 | .idea/datasources.xml 154 | .idea/dataSources.ids 155 | .idea/sqlDataSources.xml 156 | .idea/dynamic.xml 157 | .idea/uiDesigner.xml 158 | .idea/* 159 | 160 | # OS-specific files 161 | .DS_Store 162 | .DS_Store? 163 | ._* 164 | .Spotlight-V100 165 | .Trashes 166 | ehthumbs.db 167 | Thumbs.db 168 | 169 | # Legacy Eclipse project files 170 | .classpath 171 | .project 172 | .cproject 173 | .settings/ 174 | 175 | # Mobile Tools for Java (J2ME) 176 | .mtj.tmp/ 177 | 178 | # Package Files # 179 | *.war 180 | *.ear 181 | 182 | # virtual machine crash logs (Reference: http://www.java.com/en/download/help/error_hotspot.xml) 183 | hs_err_pid* 184 | 185 | ## Plugin-specific files: 186 | 187 | # mpeltonen/sbt-idea plugin 188 | .idea_modules/ 189 | 190 | # JIRA plugin 191 | atlassian-ide-plugin.xml 192 | 193 | # Mongo Explorer plugin 194 | .idea/mongoSettings.xml 195 | 196 | # Crashlytics plugin (for Android Studio and IntelliJ) 197 | com_crashlytics_export_strings.xml 198 | crashlytics.properties 199 | crashlytics-build.properties 200 | fabric.properties 201 | 202 | ### AndroidStudio Patch ### 203 | 204 | !/gradle/wrapper/gradle-wrapper.jar 205 | 206 | # End of https://www.gitignore.io/api/android,androidstudio -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # ChangeLog 2 | 3 | ## v1.5.0 4 | * [CHANGE] Updated Deps and move target sdk to 31 5 | * [BREAK] From this version, we no longer support `Jcenter`, move to `mavenCentral` 6 | 7 | 8 | ## v1.4.0 9 | * fix kotlin migration potential issue [Wrong arguments execution order in calls with named vararg](https://youtrack.jetbrains.com/issue/KT-17691) 10 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at yangqifan02@gmail.com. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | https://www.contributor-covenant.org/faq 77 | -------------------------------------------------------------------------------- /README_ZH.md: -------------------------------------------------------------------------------- 1 | # PowerPermission 2 | [ ![jCenter](https://api.bintray.com/packages/qifan/maven/powerpermission/images/download.svg) ](https://api.bintray.com/packages/qifan/maven/powerpermission/_latestVersion) 3 | [![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg?style=flat-square)](https://www.apache.org/licenses/LICENSE-2.0.html) 4 | ![Android Check CI](https://github.com/underwindfall/PowerPermission/workflows/Android%20Check%20CI/badge.svg) 5 | #### [English Documentation](https://github.com/underwindfall/PowerPermission) | 中文文档 6 | 7 | ## 目录 8 | - [PowerPermission](#powerpermission) 9 | * [目录](#--) 10 | * [简介](#--) 11 | * [配置方法](#----) 12 | + [基础库](#---) 13 | + [不同的其他接口配置](#---------) 14 | + [总结](#--) 15 | * [使用方法](#----) 16 | + [基础方法](#----) 17 | - [调用单例模式](#------) 18 | - [Extension 模式](#extension---) 19 | + [RxJava/RxKotlin 使用方法](#rxjava-rxkotlin-----) 20 | - [基础用法](#----) 21 | - [结合RxBinding使用](#--rxbinding--) 22 | + [Coroutine 使用方法](#coroutine-----) 23 | + [Livedata 使用方法](#livedata-----) 24 | + [Rationale Interface](#rationale-interface) 25 | - [自定义解释界面](#-------) 26 | - [Choose those permissions are rational](#choose-those-permissions-are-rational) 27 | * [License](#license) 28 | 29 | ## 简介 30 | `PowerPermission` 主要针对 `Android` 开发者在面对请求[RuntimePermission](https://developer.android.com/reference/java/lang/RuntimePermission)时的复杂流程的使用进行简化,来提高代码的便携效率。 31 | > 在这个Repo已经有个示例的`application`或者你可以通过这个[链接](https://github.com/underwindfall/PowerPermission/releases)直接下载APK. 32 | 它和其他的第三方请求库不同的有以下几点: 33 | - 可在 `AppCompatActivity` 和 `Fragment(包括ChildFragment)` 中请求 34 | - 不固定了用户拒绝权限后的说明内容表现形式,可自行化定制 35 | - 可自主选择那些权限再次显示解释界面 36 | - 支持多种接口配置(RxJava2和RxJava3,Coroutines,LiveData) 37 | 38 |
39 | 40 |
41 | 42 | ## 配置方法 43 | ### 基础库 44 | ```groovy 45 | implementation "com.qifan.powerpermission:powerpermission:1.5.0" 46 | ``` 47 | ### 不同的其他接口配置 48 | ```groovy 49 | implementation "com.qifan.powerpermission:powerpermission-rxjava2:1.5.0" 50 | implementation "com.qifan.powerpermission:powerpermission-rxjava3:1.5.0" 51 | implementation "com.qifan.powerpermission:powerpermission-coroutines:1.5.0" 52 | implementation "com.qifan.powerpermission:powerpermission-livedata:1.5.0" 53 | ``` 54 | ### 总结 55 | | Package Name | Role | Usage | 56 | | ------------- |-------------|-------------| 57 | | powerpermission | Basic core package | implementation "com.qifan.powerpermission:powerpermission:1.5.0" | 58 | | powerpermission-rxjava2 | Support RxJava2 | implementation "com.qifan.powerpermission:powerpermission-rxjava2:1.5.0" | 59 | | powerpermission-rxjava3 | Support RxJava3 | implementation "com.qifan.powerpermission:powerpermission-rxjava3:1.5.0" | 60 | | powerpermission-coroutines | Support Kotlin Coroutine | implementation "com.qifan.powerpermission:powerpermission-coroutines:1.5.0" | 61 | | powerpermission-livedata | Support Android LiveData | implementation "com.qifan.powerpermission:powerpermission-livedata:1.5.0" | 62 | 63 | ## 使用方法 64 | 65 | ### 基础方法 66 | #### 调用单例模式 67 | ```kotlin 68 | PowerPermission.init() 69 | .requestPermissions( 70 | context = this@ExampleActivity, 71 | permissions = *arrayOf( 72 | Manifest.permission.CAMERA 73 | ) 74 | ) { permissionResult -> 75 | when { 76 | permissionResult.hasAllGranted() -> { 77 | doPermissionAllGrantedWork(permissionResult.granted()) 78 | } 79 | permissionResult.hasRational() -> { 80 | doPermissionReasonWork(permissionResult.rational()) 81 | } 82 | permissionResult.hasPermanentDenied() -> { 83 | doPermissionPermanentWork(permissionResult.permanentDenied()) 84 | } 85 | } 86 | } 87 | ``` 88 | #### Extension 模式 89 | - 在Activity请求 90 | ```kotlin 91 | askPermissions( 92 | Manifest.permission.CAMERA, 93 | Manifest.permission.READ_CALENDAR 94 | ) { permissionResult -> 95 | //do whatever you want 96 | } 97 | ``` 98 | - 在Fragment请求 99 | ```kotlin 100 | askPermissions( 101 | Manifest.permission.CAMERA, 102 | Manifest.permission.READ_CALENDAR 103 | ) { permissionResult -> 104 | //do whatever you want 105 | } 106 | ``` 107 | - 在ChildFragment中请求 108 | ```kotlin 109 | askPermissions( 110 | Manifest.permission.CAMERA, 111 | Manifest.permission.READ_CALENDAR 112 | ) { permissionResult -> 113 | //do whatever you want 114 | } 115 | ``` 116 | ### RxJava/RxKotlin 使用方法 117 | #### 基础用法 118 | ```kotlin 119 | simpleRequestButton.setOnClickListener { 120 | askPermissionsRx(Manifest.permission.CAMERA) 121 | } 122 | ``` 123 | #### 结合RxBinding使用 124 | ```kotlin 125 | rxBindingRequestButton.clicks() 126 | .throttleFirst(1L, TimeUnit.SECONDS) 127 | .flatMap { 128 | askPermissionsRx(Manifest.permission.CAMERA) 129 | } 130 | ``` 131 | 132 | ### Coroutine 使用方法 133 | ```kotlin 134 | simpleRequestButton.setOnClickListener { 135 | launch { 136 | val result = awaitAskPermissions( 137 | Manifest.permission.CAMERA, 138 | rationaleDelegate = dialogRationaleDelegate 139 | ) 140 | //do something for this permission result 141 | // handlePermissionRequest(result) 142 | } 143 | } 144 | ``` 145 | 146 | ### Livedata 使用方法 147 | ```kotlin 148 | simpleRequestButton.setOnClickListener { 149 | observeAskPermissions( 150 | Manifest.permission.CAMERA, 151 | rationaleDelegate = dialogRationaleDelegate 152 | ).observe(this, Observer{ result-> 153 | //do something for this permission result 154 | // handlePermissionRequest(result) 155 | }) 156 | } 157 | ``` 158 | ### Rationale Interface 159 | #### 自定义解释界面 160 | 在 `PowerPermission` 中它包含了一个 `interface` 叫做`RationaleDelegate`, 你可以把它当作一个桥梁来创造你的`Custom view`。 161 | 它提供了两个公开的方法, 162 | - displayRationale 163 | ```kotlin 164 | //aims to display a view to explain reason to user why request permissions 165 | fun displayRationale( 166 | vararg permission: Permission, 167 | message: String, 168 | actionCallback: RationaleActionCallback 169 | ) 170 | ``` 171 | - onDismissView 172 | ```kotlin 173 | //aims to simply disappear view and do some clean work etc. 174 | fun onDismissView() 175 | ``` 176 | PS: `PowerPermission` 内置一个默认的 `DialogRationaleDelegate.kt` 来展示android经典的dialog界面向用户解释为什么我们需要这个`permission`的原因。 177 | 178 | #### Choose those permissions are rational 179 | - RationaleData 180 | 此外他还有个`data class`被用于向用户选择那些`permission`请求应该显示界面和相应的解释信息是什么。 181 | example: 182 | ```kotlin 183 | RationaleData( 184 | rationalPermission = Manifest.permission.CAMERA, 185 | message = message 186 | ) 187 | RationaleData( 188 | rationalPermissions = listOf(Manifest.permission.CAMERA), 189 | message = message 190 | ) 191 | ``` 192 | 193 | ## License 194 | Copyright (C) 2020 Qifan Yang 195 | Licensed under the Apache License, Version 2.0 (the "License"); 196 | you may not use this file except in compliance with the License. 197 | You may obtain a copy of the License at 198 | 199 | http://www.apache.org/licenses/LICENSE-2.0 200 | 201 | Unless required by applicable law or agreed to in writing, software 202 | distributed under the License is distributed on an "AS IS" BASIS, 203 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 204 | See the License for the specific language governing permissions and 205 | limitations under the License. 206 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "com.android.application" 2 | apply plugin: "kotlin-android" 3 | 4 | android { 5 | compileSdkVersion androidCompileSdkVersion 6 | 7 | defaultConfig { 8 | applicationId "com.qifan.powerpermission" 9 | minSdkVersion androidMinSdkVersion 10 | targetSdkVersion androidTargetSdkVersion 11 | versionCode 1 12 | versionName "1.0" 13 | 14 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 15 | } 16 | 17 | compileOptions { 18 | sourceCompatibility JavaVersion.VERSION_11 19 | targetCompatibility JavaVersion.VERSION_11 20 | } 21 | 22 | buildTypes { 23 | release { 24 | minifyEnabled false 25 | proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" 26 | } 27 | } 28 | 29 | buildFeatures { 30 | viewBinding = true 31 | } 32 | } 33 | 34 | dependencies { 35 | implementation fileTree(dir: "libs", include: ["*.jar"]) 36 | implementation project(":powerpermission") 37 | implementation project(":powerpermission-rxjava2") 38 | implementation project(":powerpermission-rxjava3") 39 | implementation project(":powerpermission-coroutines") 40 | implementation project(":powerpermission-livedata") 41 | implementation kotlinStdlib 42 | implementation androidXAppCompat 43 | implementation constraintLayout 44 | implementation "com.jakewharton.rxbinding3:rxbinding:3.1.0" 45 | testImplementation "junit:junit:4.13.2" 46 | androidTestImplementation "androidx.test.ext:junit:1.1.3" 47 | androidTestImplementation "androidx.test.espresso:espresso-core:3.4.0" 48 | } 49 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /app/src/main/java/com/qifan/powerpermission/MainActivity.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2020 by Qifan YANG (@underwindfall) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.qifan.powerpermission 17 | 18 | import android.content.Intent 19 | import android.os.Bundle 20 | import android.view.View 21 | import androidx.appcompat.app.AppCompatActivity 22 | import com.qifan.powerpermission.activity.ExampleActivity 23 | import com.qifan.powerpermission.childfragment.ExampleChildContainerFragment 24 | import com.qifan.powerpermission.coroutines.CoroutinesActivity 25 | import com.qifan.powerpermission.databinding.ActivityMainBinding 26 | import com.qifan.powerpermission.fragment.ExampleFragment 27 | import com.qifan.powerpermission.livedata.LiveDataActivity 28 | import com.qifan.powerpermission.rx.RxJava2Activity 29 | import com.qifan.powerpermission.rx.RxJava3Activity 30 | 31 | class MainActivity : AppCompatActivity() { 32 | private lateinit var binding: ActivityMainBinding 33 | private val requestActivityButton get() = binding.requestActivity 34 | private val requestFragmentButton get() = binding.requestFragment 35 | private val requestChildFragmentButton get() = binding.requestChildFragment 36 | private val requestRxJava2Button get() = binding.requestRxjava2Activity 37 | private val requestRxJava3Button get() = binding.requestRxjava3Activity 38 | private val requestCoroutineButton get() = binding.requestCoroutineActivity 39 | private val requestLiveDataButton get() = binding.requestLivedataActivity 40 | private val requestFragmentContainer get() = binding.exampleFragmentContainer 41 | 42 | override fun onCreate(savedInstanceState: Bundle?) { 43 | super.onCreate(savedInstanceState) 44 | binding = ActivityMainBinding.inflate(layoutInflater) 45 | setContentView(binding.root) 46 | requestActivityButton.setOnClickListener { navigateToRequestActivity() } 47 | requestFragmentButton.setOnClickListener { navigateToRequestFragment() } 48 | requestChildFragmentButton.setOnClickListener { navigateToRequestChildFragment() } 49 | requestRxJava2Button.setOnClickListener { navigateToRxJava2Activity() } 50 | requestRxJava3Button.setOnClickListener { navigateToRxJava3Activity() } 51 | requestCoroutineButton.setOnClickListener { navigateToCoroutineActivity() } 52 | requestLiveDataButton.setOnClickListener { navigateToLiveDataActivity() } 53 | } 54 | 55 | private fun navigateToLiveDataActivity() { 56 | Intent(this@MainActivity, LiveDataActivity::class.java).apply { 57 | startActivity(this) 58 | } 59 | } 60 | 61 | private fun navigateToCoroutineActivity() { 62 | Intent(this@MainActivity, CoroutinesActivity::class.java).apply { 63 | startActivity(this) 64 | } 65 | } 66 | 67 | private fun navigateToRxJava3Activity() { 68 | Intent(this@MainActivity, RxJava3Activity::class.java).apply { 69 | startActivity(this) 70 | } 71 | } 72 | 73 | private fun navigateToRxJava2Activity() { 74 | Intent(this@MainActivity, RxJava2Activity::class.java).apply { 75 | startActivity(this) 76 | } 77 | } 78 | 79 | private fun navigateToRequestActivity() { 80 | Intent(this@MainActivity, ExampleActivity::class.java).apply { 81 | startActivity(this) 82 | } 83 | } 84 | 85 | private fun navigateToRequestFragment() { 86 | displayFragment(show = true) 87 | supportFragmentManager.beginTransaction() 88 | .add(R.id.example_fragment_container, ExampleFragment()) 89 | .addToBackStack("RequestFragment") 90 | .commit() 91 | } 92 | 93 | private fun navigateToRequestChildFragment() { 94 | displayFragment(show = true) 95 | supportFragmentManager.beginTransaction() 96 | .add(R.id.example_fragment_container, ExampleChildContainerFragment()) 97 | .addToBackStack("RequestChildFragment") 98 | .commit() 99 | } 100 | 101 | private fun displayFragment(show: Boolean) { 102 | if (show) { 103 | requestFragmentContainer.visibility = View.VISIBLE 104 | requestActivityButton.visibility = View.GONE 105 | requestFragmentButton.visibility = View.GONE 106 | requestChildFragmentButton.visibility = View.GONE 107 | requestRxJava2Button.visibility = View.GONE 108 | requestRxJava3Button.visibility = View.GONE 109 | requestCoroutineButton.visibility = View.GONE 110 | requestLiveDataButton.visibility = View.GONE 111 | } else { 112 | requestFragmentContainer.visibility = View.GONE 113 | requestActivityButton.visibility = View.VISIBLE 114 | requestFragmentButton.visibility = View.VISIBLE 115 | requestChildFragmentButton.visibility = View.VISIBLE 116 | requestRxJava2Button.visibility = View.VISIBLE 117 | requestRxJava3Button.visibility = View.VISIBLE 118 | requestCoroutineButton.visibility = View.VISIBLE 119 | requestLiveDataButton.visibility = View.VISIBLE 120 | supportActionBar?.setTitle(R.string.app_name) 121 | } 122 | } 123 | 124 | override fun onBackPressed() { 125 | if (supportFragmentManager.fragments.isNotEmpty()) { 126 | displayFragment(show = false) 127 | supportFragmentManager.popBackStack() 128 | } else { 129 | super.onBackPressed() 130 | } 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /app/src/main/java/com/qifan/powerpermission/activity/ExampleActivity.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2020 by Qifan YANG (@underwindfall) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.qifan.powerpermission.activity 17 | 18 | import android.Manifest 19 | import android.os.Bundle 20 | import androidx.appcompat.app.AppCompatActivity 21 | import com.qifan.powerpermission.Permission 22 | import com.qifan.powerpermission.PowerPermission 23 | import com.qifan.powerpermission.R 24 | import com.qifan.powerpermission.data.granted 25 | import com.qifan.powerpermission.data.hasAllGranted 26 | import com.qifan.powerpermission.data.hasPermanentDenied 27 | import com.qifan.powerpermission.data.hasRational 28 | import com.qifan.powerpermission.data.permanentDenied 29 | import com.qifan.powerpermission.data.rational 30 | import com.qifan.powerpermission.databinding.ActivityExampleBinding 31 | 32 | class ExampleActivity : AppCompatActivity() { 33 | private lateinit var binding: ActivityExampleBinding 34 | private val requestButton get() = binding.request 35 | private val resultText get() = binding.result 36 | 37 | override fun onCreate(savedInstanceState: Bundle?) { 38 | super.onCreate(savedInstanceState) 39 | binding = ActivityExampleBinding.inflate(layoutInflater) 40 | setContentView(binding.root) 41 | requestButton.setOnClickListener { requestPermissions() } 42 | supportActionBar?.setTitle(R.string.button_request_activity) 43 | } 44 | 45 | private fun requestPermissions() { 46 | PowerPermission.init() 47 | .requestPermissions( 48 | context = this@ExampleActivity, 49 | callback = { permissionResult -> 50 | when { 51 | permissionResult.hasAllGranted() -> { 52 | doPermissionAllGrantedWork(permissionResult.granted()) 53 | } 54 | permissionResult.hasRational() -> { 55 | doPermissionReasonWork(permissionResult.rational()) 56 | } 57 | permissionResult.hasPermanentDenied() -> { 58 | doPermissionPermanentWork(permissionResult.permanentDenied()) 59 | } 60 | } 61 | }, 62 | permissions = arrayOf( 63 | Manifest.permission.CAMERA 64 | ) 65 | ) 66 | } 67 | 68 | private fun doPermissionPermanentWork(permanentDenied: List) { 69 | resultText.text = getString(R.string.permission_denied, permanentDenied) 70 | } 71 | 72 | private fun doPermissionReasonWork(rational: List) { 73 | resultText.text = getString(R.string.permission_rational, rational) 74 | } 75 | 76 | private fun doPermissionAllGrantedWork(permissions: List) { 77 | resultText.text = getString(R.string.permission_all_granted, permissions) 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /app/src/main/java/com/qifan/powerpermission/childfragment/ExampleChildContainerFragment.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2020 by Qifan YANG (@underwindfall) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.qifan.powerpermission.childfragment 17 | 18 | import android.os.Bundle 19 | import android.view.LayoutInflater 20 | import android.view.View 21 | import android.view.ViewGroup 22 | import androidx.fragment.app.Fragment 23 | import com.qifan.powerpermission.R 24 | import com.qifan.powerpermission.databinding.FragmentChildContainerExampleBinding 25 | 26 | class ExampleChildContainerFragment : Fragment() { 27 | private lateinit var binding: FragmentChildContainerExampleBinding 28 | 29 | override fun onCreateView( 30 | inflater: LayoutInflater, 31 | container: ViewGroup?, 32 | savedInstanceState: Bundle? 33 | ): View? { 34 | binding = FragmentChildContainerExampleBinding.inflate(inflater, container, false) 35 | return binding.root 36 | } 37 | 38 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 39 | super.onViewCreated(view, savedInstanceState) 40 | childFragmentManager.beginTransaction() 41 | .add(R.id.child_container, ExampleChildFragment()) 42 | .commit() 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app/src/main/java/com/qifan/powerpermission/childfragment/ExampleChildFragment.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2020 by Qifan YANG (@underwindfall) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.qifan.powerpermission.childfragment 17 | 18 | import android.Manifest 19 | import android.os.Bundle 20 | import android.view.LayoutInflater 21 | import android.view.View 22 | import android.view.ViewGroup 23 | import androidx.appcompat.app.AppCompatActivity 24 | import androidx.fragment.app.Fragment 25 | import com.qifan.powerpermission.Permission 26 | import com.qifan.powerpermission.R 27 | import com.qifan.powerpermission.askPermissions 28 | import com.qifan.powerpermission.data.granted 29 | import com.qifan.powerpermission.data.hasAllGranted 30 | import com.qifan.powerpermission.data.hasPermanentDenied 31 | import com.qifan.powerpermission.data.hasRational 32 | import com.qifan.powerpermission.data.permanentDenied 33 | import com.qifan.powerpermission.data.rational 34 | import com.qifan.powerpermission.databinding.FragmentChildExampleBinding 35 | import com.qifan.powerpermission.rationale.createDialogRationale 36 | import com.qifan.powerpermission.rationale.delegate.RationaleDelegate 37 | 38 | class ExampleChildFragment : Fragment() { 39 | private lateinit var binding: FragmentChildExampleBinding 40 | private val requestButton get() = binding.request 41 | private val resultText get() = binding.result 42 | private val dialogRationaleDelegate: RationaleDelegate by lazy { 43 | createDialogRationale( 44 | R.string.rational_title, 45 | Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION, 46 | getString( 47 | R.string.permission_rational, 48 | arrayOf( 49 | Manifest.permission.ACCESS_COARSE_LOCATION, 50 | Manifest.permission.ACCESS_FINE_LOCATION 51 | ) 52 | ) 53 | ) 54 | } 55 | 56 | override fun onCreateView( 57 | inflater: LayoutInflater, 58 | container: ViewGroup?, 59 | savedInstanceState: Bundle? 60 | ): View? { 61 | binding = FragmentChildExampleBinding.inflate(inflater, container, false) 62 | return binding.root 63 | } 64 | 65 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 66 | super.onViewCreated(view, savedInstanceState) 67 | requestButton.setOnClickListener { requestPermissions() } 68 | (activity as AppCompatActivity?)?.supportActionBar?.setTitle(R.string.button_request_child_fragment) 69 | } 70 | 71 | private fun requestPermissions() { 72 | askPermissions( 73 | Manifest.permission.ACCESS_COARSE_LOCATION, 74 | Manifest.permission.ACCESS_FINE_LOCATION, 75 | rationaleDelegate = dialogRationaleDelegate 76 | ) { permissionResult -> 77 | when { 78 | permissionResult.hasAllGranted() -> { 79 | doPermissionAllGrantedWork(permissionResult.granted()) 80 | } 81 | permissionResult.hasRational() -> { 82 | doPermissionReasonWork(permissionResult.rational()) 83 | } 84 | permissionResult.hasPermanentDenied() -> { 85 | doPermissionPermanentWork(permissionResult.permanentDenied()) 86 | } 87 | } 88 | } 89 | } 90 | 91 | private fun doPermissionPermanentWork(permanentDenied: List) { 92 | resultText.text = getString(R.string.permission_denied, permanentDenied) 93 | } 94 | 95 | private fun doPermissionReasonWork(rational: List) { 96 | resultText.text = getString(R.string.permission_rational, rational) 97 | } 98 | 99 | private fun doPermissionAllGrantedWork(permissions: List) { 100 | resultText.text = getString(R.string.permission_all_granted, permissions) 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /app/src/main/java/com/qifan/powerpermission/coroutines/CoroutinesActivity.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2020 by Qifan YANG (@underwindfall) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.qifan.powerpermission.coroutines 17 | 18 | import android.Manifest 19 | import android.os.Bundle 20 | import androidx.appcompat.app.AppCompatActivity 21 | import com.qifan.powerpermission.Permission 22 | import com.qifan.powerpermission.R 23 | import com.qifan.powerpermission.data.PermissionResult 24 | import com.qifan.powerpermission.data.granted 25 | import com.qifan.powerpermission.data.hasAllGranted 26 | import com.qifan.powerpermission.data.hasPermanentDenied 27 | import com.qifan.powerpermission.data.hasRational 28 | import com.qifan.powerpermission.data.permanentDenied 29 | import com.qifan.powerpermission.data.rational 30 | import com.qifan.powerpermission.databinding.ActivityCoroutinesExmapleBinding 31 | import com.qifan.powerpermission.rationale.createDialogRationale 32 | import com.qifan.powerpermission.rationale.delegate.RationaleDelegate 33 | import kotlinx.coroutines.CoroutineScope 34 | import kotlinx.coroutines.MainScope 35 | import kotlinx.coroutines.cancel 36 | import kotlinx.coroutines.launch 37 | 38 | class CoroutinesActivity : AppCompatActivity(), CoroutineScope by MainScope() { 39 | private lateinit var binding: ActivityCoroutinesExmapleBinding 40 | private val simpleRequestButton get() = binding.simpleRequest 41 | private val resultText get() = binding.result 42 | private val dialogRationaleDelegate: RationaleDelegate by lazy { 43 | createDialogRationale( 44 | R.string.rational_title, 45 | Manifest.permission.CAMERA, 46 | getString(R.string.permission_rational, Manifest.permission.CAMERA) 47 | ) 48 | } 49 | 50 | override fun onCreate(savedInstanceState: Bundle?) { 51 | super.onCreate(savedInstanceState) 52 | binding = ActivityCoroutinesExmapleBinding.inflate(layoutInflater) 53 | setContentView(binding.root) 54 | supportActionBar?.setTitle(R.string.button_request_coroutines) 55 | setupRequestButton() 56 | } 57 | 58 | private fun setupRequestButton() { 59 | simpleRequestButton.setOnClickListener { 60 | launch { 61 | val result = awaitAskPermissions( 62 | Manifest.permission.CAMERA, 63 | rationaleDelegate = dialogRationaleDelegate 64 | ) 65 | handlePermissionRequest(result) 66 | } 67 | } 68 | } 69 | 70 | private fun handlePermissionRequest(permissionResult: PermissionResult) { 71 | when { 72 | permissionResult.hasAllGranted() -> { 73 | doPermissionAllGrantedWork(permissionResult.granted()) 74 | } 75 | permissionResult.hasRational() -> { 76 | doPermissionReasonWork(permissionResult.rational()) 77 | } 78 | permissionResult.hasPermanentDenied() -> { 79 | doPermissionPermanentWork(permissionResult.permanentDenied()) 80 | } 81 | } 82 | } 83 | 84 | private fun doPermissionPermanentWork(permanentDenied: List) { 85 | resultText.text = getString(R.string.permission_denied, permanentDenied) 86 | } 87 | 88 | private fun doPermissionReasonWork(rational: List) { 89 | resultText.text = getString(R.string.permission_rational, rational) 90 | } 91 | 92 | private fun doPermissionAllGrantedWork(permissions: List) { 93 | resultText.text = getString(R.string.permission_all_granted, permissions) 94 | } 95 | 96 | override fun onDestroy() { 97 | super.onDestroy() 98 | cancel() 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /app/src/main/java/com/qifan/powerpermission/fragment/ExampleFragment.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2020 by Qifan YANG (@underwindfall) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.qifan.powerpermission.fragment 17 | 18 | import android.Manifest 19 | import android.os.Bundle 20 | import android.view.LayoutInflater 21 | import android.view.View 22 | import android.view.ViewGroup 23 | import androidx.appcompat.app.AppCompatActivity 24 | import androidx.fragment.app.Fragment 25 | import com.qifan.powerpermission.Permission 26 | import com.qifan.powerpermission.R 27 | import com.qifan.powerpermission.askPermissions 28 | import com.qifan.powerpermission.data.granted 29 | import com.qifan.powerpermission.data.hasAllGranted 30 | import com.qifan.powerpermission.data.hasPermanentDenied 31 | import com.qifan.powerpermission.data.hasRational 32 | import com.qifan.powerpermission.data.permanentDenied 33 | import com.qifan.powerpermission.data.rational 34 | import com.qifan.powerpermission.databinding.FragmentExampleBinding 35 | import com.qifan.powerpermission.rationale.createDialogRationale 36 | import com.qifan.powerpermission.rationale.delegate.RationaleDelegate 37 | 38 | class ExampleFragment : Fragment() { 39 | private lateinit var binding: FragmentExampleBinding 40 | private val requestButton get() = binding.request 41 | private val resultText get() = binding.result 42 | private val dialogRationaleDelegate: RationaleDelegate by lazy { 43 | createDialogRationale( 44 | R.string.rational_title, 45 | Manifest.permission.CALL_PHONE, 46 | getString(R.string.permission_rational, Manifest.permission.CALL_PHONE) 47 | ) 48 | } 49 | 50 | override fun onCreateView( 51 | inflater: LayoutInflater, 52 | container: ViewGroup?, 53 | savedInstanceState: Bundle? 54 | ): View? { 55 | binding = FragmentExampleBinding.inflate(inflater, container, false) 56 | return binding.root 57 | } 58 | 59 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 60 | super.onViewCreated(view, savedInstanceState) 61 | requestButton.setOnClickListener { requestPermissions() } 62 | (activity as AppCompatActivity?)?.supportActionBar?.setTitle(R.string.button_request_fragment) 63 | } 64 | 65 | private fun requestPermissions() { 66 | askPermissions( 67 | Manifest.permission.CAMERA, 68 | Manifest.permission.READ_CALENDAR, 69 | rationaleDelegate = dialogRationaleDelegate 70 | ) { permissionResult -> 71 | when { 72 | permissionResult.hasAllGranted() -> { 73 | doPermissionAllGrantedWork(permissionResult.granted()) 74 | } 75 | permissionResult.hasRational() -> { 76 | doPermissionReasonWork(permissionResult.rational()) 77 | } 78 | permissionResult.hasPermanentDenied() -> { 79 | doPermissionPermanentWork(permissionResult.permanentDenied()) 80 | } 81 | } 82 | } 83 | } 84 | 85 | private fun doPermissionPermanentWork(permanentDenied: List) { 86 | resultText.text = getString(R.string.permission_denied, permanentDenied) 87 | } 88 | 89 | private fun doPermissionReasonWork(rational: List) { 90 | resultText.text = getString(R.string.permission_rational, rational) 91 | } 92 | 93 | private fun doPermissionAllGrantedWork(permissions: List) { 94 | resultText.text = getString(R.string.permission_all_granted, permissions) 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /app/src/main/java/com/qifan/powerpermission/livedata/LiveDataActivity.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2020 by Qifan YANG (@underwindfall) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.qifan.powerpermission.livedata 17 | 18 | import android.Manifest 19 | import android.os.Bundle 20 | import androidx.appcompat.app.AppCompatActivity 21 | import androidx.lifecycle.Observer 22 | import com.qifan.powerpermission.Permission 23 | import com.qifan.powerpermission.R 24 | import com.qifan.powerpermission.data.PermissionResult 25 | import com.qifan.powerpermission.data.granted 26 | import com.qifan.powerpermission.data.hasAllGranted 27 | import com.qifan.powerpermission.data.hasPermanentDenied 28 | import com.qifan.powerpermission.data.hasRational 29 | import com.qifan.powerpermission.data.permanentDenied 30 | import com.qifan.powerpermission.data.rational 31 | import com.qifan.powerpermission.databinding.ActivityLiveDataBinding 32 | import com.qifan.powerpermission.rationale.createDialogRationale 33 | import com.qifan.powerpermission.rationale.delegate.RationaleDelegate 34 | 35 | class LiveDataActivity : AppCompatActivity() { 36 | private lateinit var binding: ActivityLiveDataBinding 37 | private val simpleRequestButton get() = binding.simpleRequest 38 | private val resultText get() = binding.result 39 | private val dialogRationaleDelegate: RationaleDelegate by lazy { 40 | createDialogRationale( 41 | R.string.rational_title, 42 | Manifest.permission.CAMERA, 43 | getString(R.string.permission_rational, Manifest.permission.CAMERA) 44 | ) 45 | } 46 | 47 | override fun onCreate(savedInstanceState: Bundle?) { 48 | super.onCreate(savedInstanceState) 49 | binding = ActivityLiveDataBinding.inflate(layoutInflater) 50 | setContentView(binding.root) 51 | supportActionBar?.setTitle(R.string.button_request_livedata) 52 | setupRequestButton() 53 | } 54 | 55 | private fun setupRequestButton() { 56 | simpleRequestButton.setOnClickListener { 57 | observeAskPermissions( 58 | Manifest.permission.CAMERA, 59 | rationaleDelegate = dialogRationaleDelegate 60 | ).observe(this, Observer(::handlePermissionRequest)) 61 | } 62 | } 63 | 64 | private fun handlePermissionRequest(permissionResult: PermissionResult) { 65 | when { 66 | permissionResult.hasAllGranted() -> { 67 | doPermissionAllGrantedWork(permissionResult.granted()) 68 | } 69 | permissionResult.hasRational() -> { 70 | doPermissionReasonWork(permissionResult.rational()) 71 | } 72 | permissionResult.hasPermanentDenied() -> { 73 | doPermissionPermanentWork(permissionResult.permanentDenied()) 74 | } 75 | } 76 | } 77 | 78 | private fun doPermissionPermanentWork(permanentDenied: List) { 79 | resultText.text = getString(R.string.permission_denied, permanentDenied) 80 | } 81 | 82 | private fun doPermissionReasonWork(rational: List) { 83 | resultText.text = getString(R.string.permission_rational, rational) 84 | } 85 | 86 | private fun doPermissionAllGrantedWork(permissions: List) { 87 | resultText.text = getString(R.string.permission_all_granted, permissions) 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /app/src/main/java/com/qifan/powerpermission/rx/RxJava2Activity.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2020 by Qifan YANG (@underwindfall) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.qifan.powerpermission.rx 17 | 18 | import android.Manifest 19 | import android.os.Bundle 20 | import android.util.Log 21 | import androidx.appcompat.app.AppCompatActivity 22 | import com.jakewharton.rxbinding3.view.clicks 23 | import com.qifan.powerpermission.Permission 24 | import com.qifan.powerpermission.R 25 | import com.qifan.powerpermission.data.PermissionResult 26 | import com.qifan.powerpermission.data.granted 27 | import com.qifan.powerpermission.data.hasAllGranted 28 | import com.qifan.powerpermission.data.hasPermanentDenied 29 | import com.qifan.powerpermission.data.hasRational 30 | import com.qifan.powerpermission.data.permanentDenied 31 | import com.qifan.powerpermission.data.rational 32 | import com.qifan.powerpermission.databinding.ActivityRx2ExmapleBinding 33 | import com.qifan.powerpermission.rationale.createDialogRationale 34 | import com.qifan.powerpermission.rationale.delegate.RationaleDelegate 35 | import com.qifan.powerpermission.rx2.askPermissionsRx 36 | import io.reactivex.Completable 37 | import io.reactivex.disposables.CompositeDisposable 38 | import io.reactivex.disposables.Disposable 39 | import java.util.concurrent.TimeUnit 40 | 41 | class RxJava2Activity : AppCompatActivity() { 42 | private lateinit var binding: ActivityRx2ExmapleBinding 43 | private val simpleRequestButton get() = binding.simpleRequest 44 | private val rxBindingRequestButton get() = binding.requestRxBinding 45 | private val resultText get() = binding.result 46 | 47 | private val compositeDisposable: CompositeDisposable by lazy { CompositeDisposable() } 48 | 49 | private val dialogRationaleDelegate: RationaleDelegate by lazy { 50 | createDialogRationale( 51 | R.string.rational_title, 52 | Manifest.permission.CAMERA, 53 | getString(R.string.permission_rational, Manifest.permission.CAMERA) 54 | ) 55 | } 56 | 57 | override fun onCreate(savedInstanceState: Bundle?) { 58 | super.onCreate(savedInstanceState) 59 | binding = ActivityRx2ExmapleBinding.inflate(layoutInflater) 60 | setContentView(binding.root) 61 | setUpSimpleRequestClick() 62 | setUpRxBindingClick() 63 | supportActionBar?.setTitle(R.string.button_request_rxjava2) 64 | } 65 | 66 | private fun setUpSimpleRequestClick() { 67 | simpleRequestButton.setOnClickListener { 68 | askPermissionsRx( 69 | Manifest.permission.CAMERA, 70 | rationaleDelegate = dialogRationaleDelegate 71 | ) 72 | .switchMapCompletable(::handlePermissionRequest) 73 | .subscribeAndLogError() 74 | .let(compositeDisposable::add) 75 | } 76 | } 77 | 78 | private fun setUpRxBindingClick() { 79 | rxBindingRequestButton.clicks() 80 | .throttleFirst(1L, TimeUnit.SECONDS) 81 | .flatMap { 82 | askPermissionsRx( 83 | Manifest.permission.CAMERA, 84 | rationaleDelegate = dialogRationaleDelegate 85 | ) 86 | } 87 | .switchMapCompletable(::handlePermissionRequest) 88 | .subscribeAndLogError() 89 | .let(compositeDisposable::add) 90 | } 91 | 92 | override fun onDestroy() { 93 | super.onDestroy() 94 | compositeDisposable.clear() 95 | } 96 | 97 | private fun handlePermissionRequest(permissionResult: PermissionResult): Completable { 98 | return Completable.fromCallable { 99 | when { 100 | permissionResult.hasAllGranted() -> { 101 | doPermissionAllGrantedWork(permissionResult.granted()) 102 | } 103 | permissionResult.hasRational() -> { 104 | doPermissionReasonWork(permissionResult.rational()) 105 | } 106 | permissionResult.hasPermanentDenied() -> { 107 | doPermissionPermanentWork(permissionResult.permanentDenied()) 108 | } 109 | } 110 | } 111 | } 112 | 113 | private fun doPermissionPermanentWork(permanentDenied: List) { 114 | resultText.text = getString(R.string.permission_denied, permanentDenied) 115 | } 116 | 117 | private fun doPermissionReasonWork(rational: List) { 118 | resultText.text = getString(R.string.permission_rational, rational) 119 | } 120 | 121 | private fun doPermissionAllGrantedWork(permissions: List) { 122 | resultText.text = getString(R.string.permission_all_granted, permissions) 123 | } 124 | 125 | private fun logStreamError(exception: Throwable) { 126 | Log.e(RxJava2Activity::class.java.simpleName, exception.message, exception) 127 | } 128 | 129 | private fun Completable.subscribeAndLogError(): Disposable = subscribe({}, ::logStreamError) 130 | } 131 | -------------------------------------------------------------------------------- /app/src/main/java/com/qifan/powerpermission/rx/RxJava3Activity.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2020 by Qifan YANG (@underwindfall) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.qifan.powerpermission.rx 17 | 18 | import android.Manifest 19 | import android.os.Bundle 20 | import android.util.Log 21 | import androidx.appcompat.app.AppCompatActivity 22 | import com.qifan.powerpermission.Permission 23 | import com.qifan.powerpermission.R 24 | import com.qifan.powerpermission.data.PermissionResult 25 | import com.qifan.powerpermission.data.granted 26 | import com.qifan.powerpermission.data.hasAllGranted 27 | import com.qifan.powerpermission.data.hasPermanentDenied 28 | import com.qifan.powerpermission.data.hasRational 29 | import com.qifan.powerpermission.data.permanentDenied 30 | import com.qifan.powerpermission.data.rational 31 | import com.qifan.powerpermission.databinding.ActivityRx3ExmapleBinding 32 | import com.qifan.powerpermission.rationale.createDialogRationale 33 | import com.qifan.powerpermission.rationale.delegate.RationaleDelegate 34 | import com.qifan.powerpermission.rx3.askPermissionsRx 35 | import io.reactivex.rxjava3.core.Completable 36 | import io.reactivex.rxjava3.disposables.CompositeDisposable 37 | import io.reactivex.rxjava3.disposables.Disposable 38 | 39 | class RxJava3Activity : AppCompatActivity() { 40 | private lateinit var binding: ActivityRx3ExmapleBinding 41 | private val simpleRequestButton get() = binding.simpleRequest 42 | private val resultText get() = binding.result 43 | 44 | private val compositeDisposable: CompositeDisposable by lazy { CompositeDisposable() } 45 | 46 | private val dialogRationaleDelegate: RationaleDelegate by lazy { 47 | createDialogRationale( 48 | R.string.rational_title, 49 | Manifest.permission.CAMERA, 50 | getString(R.string.permission_rational, Manifest.permission.CAMERA) 51 | ) 52 | } 53 | 54 | override fun onCreate(savedInstanceState: Bundle?) { 55 | super.onCreate(savedInstanceState) 56 | binding = ActivityRx3ExmapleBinding.inflate(layoutInflater) 57 | setContentView(binding.root) 58 | setUpSimpleRequestClick() 59 | supportActionBar?.setTitle(R.string.button_request_rxjava3) 60 | } 61 | 62 | private fun setUpSimpleRequestClick() { 63 | simpleRequestButton.setOnClickListener { 64 | askPermissionsRx( 65 | Manifest.permission.CAMERA, 66 | rationaleDelegate = dialogRationaleDelegate 67 | ) 68 | .switchMapCompletable(::handlePermissionRequest) 69 | .subscribeAndLogError() 70 | .let(compositeDisposable::add) 71 | } 72 | } 73 | 74 | private fun handlePermissionRequest(permissionResult: PermissionResult): Completable { 75 | return Completable.fromCallable { 76 | when { 77 | permissionResult.hasAllGranted() -> { 78 | doPermissionAllGrantedWork(permissionResult.granted()) 79 | } 80 | permissionResult.hasRational() -> { 81 | doPermissionReasonWork(permissionResult.rational()) 82 | } 83 | permissionResult.hasPermanentDenied() -> { 84 | doPermissionPermanentWork(permissionResult.permanentDenied()) 85 | } 86 | } 87 | } 88 | } 89 | 90 | private fun doPermissionPermanentWork(permanentDenied: List) { 91 | resultText.text = getString(R.string.permission_denied, permanentDenied) 92 | } 93 | 94 | private fun doPermissionReasonWork(rational: List) { 95 | resultText.text = getString(R.string.permission_rational, rational) 96 | } 97 | 98 | private fun doPermissionAllGrantedWork(permissions: List) { 99 | resultText.text = getString(R.string.permission_all_granted, permissions) 100 | } 101 | 102 | private fun logStreamError(exception: Throwable) { 103 | Log.e(RxJava2Activity::class.java.simpleName, exception.message, exception) 104 | } 105 | 106 | private fun Completable.subscribeAndLogError(): Disposable = subscribe({}, ::logStreamError) 107 | 108 | override fun onDestroy() { 109 | super.onDestroy() 110 | compositeDisposable.clear() 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | 17 | 21 | 25 | 26 | 27 | 28 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 12 | 18 | 24 | 30 | 36 | 42 | 48 | 54 | 60 | 66 | 72 | 78 | 84 | 90 | 96 | 102 | 108 | 114 | 120 | 126 | 132 | 138 | 144 | 150 | 156 | 162 | 168 | 174 | 180 | 186 | 192 | 198 | 204 | 205 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_coroutines_exmaple.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 |