├── .github └── pull_request_template.md ├── .gitignore ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle.kts ├── proguard-rules.pro └── src │ ├── androidTest │ └── kotlin │ │ └── com │ │ └── fernandocejas │ │ └── sample │ │ └── AcceptanceTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── kotlin │ │ └── com │ │ │ └── fernandocejas │ │ │ └── sample │ │ │ ├── AndroidApplication.kt │ │ │ ├── MainActivity.kt │ │ │ ├── MainFragment.kt │ │ │ └── core │ │ │ ├── extension │ │ │ ├── Context.kt │ │ │ ├── Fragment.kt │ │ │ ├── String.kt │ │ │ └── View.kt │ │ │ ├── flags │ │ │ ├── FeatureFlag.kt │ │ │ └── Flag.kt │ │ │ └── platform │ │ │ ├── BaseActivity.kt │ │ │ └── BaseFragment.kt │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ ├── activity_layout.xml │ │ ├── fragment_main.xml │ │ └── toolbar.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-night │ │ └── themes.xml │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── themes.xml │ └── test │ └── kotlin │ └── com │ └── fernandocejas │ └── sample │ ├── AndroidAssertions.kt │ ├── AndroidTest.kt │ ├── InjectMocksRule.kt │ ├── UnitTest.kt │ └── core │ └── flags │ └── FeatureFlagTest.kt ├── build.gradle.kts ├── buildSrc ├── build.gradle.kts ├── settings.gradle.kts └── src │ └── main │ └── kotlin │ ├── Dependencies.kt │ ├── FeatureFlags.kt │ └── scripts │ ├── compilation.gradle.kts │ ├── infrastructure.gradle.kts │ ├── quality.gradle.kts │ └── variants.gradle.kts ├── config └── detekt │ └── detekt.yml ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle.kts /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ## Why? 2 | ## How? 3 | ## Testing? 4 | ## Screenshots (optional) 5 | ## Anything Else? 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows thumbnail db 2 | Thumbs.db 3 | 4 | # OSX files 5 | .DS_Store 6 | 7 | 8 | # Built application files 9 | *.apk 10 | *.aar 11 | *.ap_ 12 | *.aab 13 | 14 | # Files for the ART/Dalvik VM 15 | *.dex 16 | 17 | # Java class files 18 | *.class 19 | 20 | # Generated files 21 | bin/ 22 | gen/ 23 | out/ 24 | # Uncomment the following line in case you need and you don't have the release build type files in your app 25 | # release/ 26 | 27 | # Gradle files 28 | .gradle/ 29 | build/ 30 | 31 | # Local configuration file (sdk path, etc) 32 | local.properties 33 | 34 | # Proguard folder generated by Eclipse 35 | proguard/ 36 | 37 | # Log Files 38 | *.log 39 | 40 | # Android Studio Navigation editor temp files 41 | .navigation/ 42 | 43 | # Android Studio captures folder 44 | captures/ 45 | 46 | # IntelliJ 47 | .idea/ 48 | *.iml 49 | .idea/workspace.xml 50 | .idea/tasks.xml 51 | .idea/gradle.xml 52 | .idea/assetWizardSettings.xml 53 | .idea/dictionaries 54 | .idea/libraries 55 | # Android Studio 3 in .gitignore file. 56 | .idea/caches 57 | .idea/modules.xml 58 | # Comment next line if keeping position of elements in Navigation Editor is relevant for you 59 | .idea/navEditor.xml 60 | 61 | # Keystore files 62 | # Uncomment the following lines if you do not want to check your keystore files in. 63 | #*.jks 64 | #*.keystore 65 | 66 | # External native build folder generated in Android Studio 2.2 and later 67 | .externalNativeBuild 68 | .cxx/ 69 | 70 | # Google Services (e.g. APIs or Firebase) 71 | # google-services.json 72 | 73 | # Freeline 74 | freeline.py 75 | freeline/ 76 | freeline_project_description.json 77 | 78 | # fastlane 79 | fastlane/report.xml 80 | fastlane/Preview.html 81 | fastlane/screenshots 82 | fastlane/test_output 83 | fastlane/readme.md 84 | 85 | # Version control 86 | vcs.xml 87 | 88 | # lint 89 | lint/intermediates/ 90 | lint/generated/ 91 | lint/outputs/ 92 | lint/tmp/ 93 | # lint/reports/ 94 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # android-trinity 2 | This is tiny framework with much of the scaffolding code (with some nice utilities and prepared source code) required to start a new **Android Application.** 3 | 4 | ## Background 📦 5 | 6 | Yes, android studio might create a project for you, but there are missing parts, which I **ALWAYS** end up adding to every single project I create. This tiny Framework (I would say still scaffolding code) aims to solve this by making easy and fast to create an android project with the fundamental building blocks. Check the **TODO** section below for more information on the evolution and progress. 7 | 8 | ## What does android-trinity provide? 🎨 9 | 10 | **Freedom.** It uses standard tools but organized in such a way that facilitates android development. You can refactor or change anything but the idea is to have a robust starting point. All the wiring is done for you with the flexibility of being modified according to your needs. 11 | 12 | - `Kotlin DSL` by default at Gradle build system leve. 13 | - Static Analisis Code Report (Detekt). 14 | - Code Coverage Report (Jacoco). 15 | - Base Classes: [`BaseActivity`](https://github.com/android10/android-trinity/blob/main/app/src/main/kotlin/com/fernandocejas/sample/core/platform/BaseActivity.kt) and [`BaseFragments`](https://github.com/android10/android-trinity/blob/main/app/src/main/kotlin/com/fernandocejas/sample/core/platform/BaseFragment.kt). 16 | - Toolbar with styles pre-defined. 17 | - Pre-setup Test clases: [`UnitTest`](https://github.com/android10/android-trinity/blob/main/app/src/test/kotlin/com/fernandocejas/sample/UnitTest.kt), [`AndroidTest`](https://github.com/android10/android-trinity/blob/main/app/src/test/kotlin/com/fernandocejas/sample/AndroidTest.kt), [`AcceptanceTest`](https://github.com/android10/android-trinity/blob/main/app/src/androidTest/kotlin/com/fernandocejas/sample/AcceptanceTest.kt). 18 | - Pre-compiled Gradle Scripts (`buildScr` folder) organized by aspects: 19 | - [`compilation.gradle.kts`](https://github.com/android10/android-trinity/blob/main/buildSrc/src/main/kotlin/scripts/compilation.gradle.kts) 20 | - [`infrastructure.gradle.kts`](https://github.com/android10/android-trinity/blob/main/buildSrc/src/main/kotlin/scripts/infrastructure.gradle.kts) 21 | - [`quality.gradle.kts`](https://github.com/android10/android-trinity/blob/main/buildSrc/src/main/kotlin/scripts/quality.gradle.kts) 22 | - [`variants.gradle.kts`](https://github.com/android10/android-trinity/blob/main/buildSrc/src/main/kotlin/scripts/variants.gradle.kts) 23 | - Dependencies Management in one place: [`Dependencies.kt`](https://github.com/android10/android-trinity/blob/main/buildSrc/src/main/kotlin/Dependencies.kt) 24 | - LeakCanary for leaks detection. 25 | - Pre-defined Build Variants (check [`variants.gradle.kts`](https://github.com/android10/android-trinity/blob/main/buildSrc/src/main/kotlin/scripts/variants.gradle.kts) file) 26 | - Build Types: 27 | - `DEBUG` 28 | - `RELEASE` 29 | - Product Flavors: 30 | - `DEV` 31 | - `INTERNAL` 32 | - `PUBLIC` 33 | - Kotlin Coroutines 34 | - A [Compact Feature Flags Framework](https://github.com/android10/android-trinity/pull/1) 35 | 36 | ## What does android-trinity NOT INCLUDE? (likely to change if necessary in future versions) 37 | 38 | - DI. You should choose your Dependency Injection Framework. 39 | - NO Navigation Framework. 40 | - NO `LiveData` and `ViewModel` libraries since some Engineers might use other approaches at UI level like MVI, MVP, etc. 41 | - NO Kotlin Flow. 42 | - NO UI Layouts for Tablet or Android TV support. 43 | 44 | ## Pre-defined Gradle Tasks 45 | 46 | - `./gradlew runStaticAnalysis` 47 | - `./gradlew runTestCoverage` 48 | - `./gradlew runUnitTests` 49 | - `./gradlew runAcceptanceTests` 50 | - `./gradlew compileApp` 51 | - `./gradlew runApp` 52 | 53 | ## How to use it 👣 54 | 55 | At the time being there are a couple of manual steps involved since we are at a very early stage. But we believe in sofware evolution right? So stay tuned and check both the **How to Contribute** and **TODO List** sections. 56 | 57 | - **STEP 1:** Click on [![Use this template](https://img.shields.io/badge/-Use%20this%20template-brightgreen)](https://github.com/android10/android-trinity/generate) to create a new repo. 58 | - **STEP 2:** Import the project in Android Studio 59 | - **STEP 3:** Rename packages according to your needs. `com.fernandocejas.sample` by default. 60 | 61 | ## Using Test Helpers 62 | 63 | Let's say you want to write tests (and you should **ALWAYS** do), As mentioned there are 3 classes which come into play and here examples of their usage: 64 | 65 | - `UnitTest.kt`: Unit Test base class which setup mocks for you (You only use the `@Mockk` annotation) 66 | 67 | ```kotlin 68 | class FeatureFlagTest : UnitTest() { 69 | 70 | @Mockk prival val yourMock 71 | 72 | @Test 73 | fun `given a feature flag, when it is activated, then executes given logic block`() { 74 | val activeFlag = ActiveFeatureFlag() 75 | val fakeNavigator = mockk(relaxed = true) 76 | 77 | activeFlag whenActivated { 78 | fakeNavigator.doSomething() 79 | fakeNavigator.navigateToActiveFeature() 80 | fakeNavigator.doSomething() 81 | } 82 | 83 | verify(exactly = 1) { fakeNavigator.navigateToActiveFeature() } 84 | verify(exactly = 2) { fakeNavigator.doSomething() } 85 | } 86 | ``` 87 | 88 | - `AndroidTest.kt`: Integration Test base class which setup mocks for you (You only use the `@Mockk` annotation). You might use this classes when they are Android Components involved. It is backed up by [Robolectric](https://github.com/robolectric/robolectric). 89 | 90 | ```kotlin 91 | class YourTestClass : AndroidTest() { 92 | 93 | @Mockk prival val yourMock 94 | 95 | @Test 96 | fun `given something, when something happens, then do something`() { 97 | TODO() 98 | } 99 | ``` 100 | 101 | - `AcceptanceTest.kt`: UI Test base class which setup [Espresso](https://developer.android.com/training/testing/espresso) for you 102 | 103 | ```kotlin 104 | class MainActivityTest: AcceptanceTest(MainActivity::class.java) { 105 | 106 | @Test 107 | fun checkToolBarTest() { 108 | onView(withId(R.id.toolbar)).check(matches(isDisplayed())) 109 | } 110 | } 111 | ``` 112 | 113 | ## Feature Flags 114 | 115 | Android-trinity includes a simple offline feature flags framework with a very simple api generated at compile time. 116 | If you want more information, refer to the [introduced pull request](https://github.com/android10/android-trinity/pull/1). (TODO: Add more documentation) 117 | 118 | Example of its usage: 119 | ```kotlin 120 | Flag.Hello whenActivated { displayGreeting(R.string.hello) } 121 | ``` 122 | 123 | 124 | ## Quality Reports: Static Analysis 125 | 126 | - The tool chosen here is [Detekt](https://github.com/detekt/detekt) due to its nature for Kotlin. 127 | - The gradlew task and its configuration could be found inside [`quality.gradle.kts`](https://github.com/android10/android-trinity/blob/main/buildSrc/src/main/kotlin/scripts/quality.gradle.kts) file. 128 | - cconfiguration Rules are in [config/detekt/detekt.yml](https://github.com/android10/android-trinity/blob/main/config/detekt/detekt.yml). 129 | 130 | ## Quality Reports: Code Coverage 131 | 132 | - The tool chosen here is [Jacoco](https://github.com/jacoco/jacoco) due to its nature and popularity in the community. 133 | - The gradlew task and its configuration could be found inside [`quality.gradle.kts`](https://github.com/android10/android-trinity/blob/main/buildSrc/src/main/kotlin/scripts/quality.gradle.kts) file. 134 | 135 | ## TODO List 136 | 137 | - [ ] Gradle Tasks for Publishing to Google Play: [App Bundles](https://developer.android.com/guide/app-bundle). 138 | - [ ] Automate the process from **How to Use** section: Idea: `./gradlew setupProject` 139 | - [X] Local Feature Flags. 140 | - [ ] Rename default packages to `io.android-trinity` or `io.android.trinity`. 141 | - [ ] ??? 142 | - [ ] ??? 143 | 144 | ## How to Contribute 145 | 146 | Nothing is set in stone here and things can change and evolve based on the community work and requirements. So if you want to contribute, feel free to open an [issue](https://github.com/android10/android-trinity/issues) and label it properly: **Bug**, **Enhancement**, etc.. or send a [PR](https://github.com/android10/android-trinity/pulls). Please both with a good descriptions of the intention, in order to facilitate review 147 | 148 | ## License 149 | 150 | Copyright 2021 Fernando Cejas 151 | 152 | Licensed under the Apache License, Version 2.0 (the "License"); 153 | you may not use this file except in compliance with the License. 154 | You may obtain a copy of the License at 155 | 156 | http://www.apache.org/licenses/LICENSE-2.0 157 | 158 | Unless required by applicable law or agreed to in writing, software 159 | distributed under the License is distributed on an "AS IS" BASIS, 160 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 161 | See the License for the specific language governing permissions and 162 | limitations under the License. 163 | 164 | 165 | ![http://www.fernandocejas.com](https://github.com/android10/Sample-Data/blob/master/android10/android10_logo_big.png) 166 | 167 | Buy Me A Coffee 168 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | // Application Specific Plugins 3 | id(BuildPlugins.androidApplication) 4 | id(BuildPlugins.kotlinAndroid) 5 | id(BuildPlugins.kotlinAndroidExtensions) 6 | 7 | // Internal Script plugins 8 | id(ScriptPlugins.variants) 9 | id(ScriptPlugins.quality) 10 | id(ScriptPlugins.compilation) 11 | } 12 | 13 | android { 14 | compileSdkVersion(AndroidSdk.compile) 15 | 16 | defaultConfig { 17 | minSdkVersion(AndroidSdk.min) 18 | targetSdkVersion(AndroidSdk.target) 19 | 20 | applicationId = AndroidClient.appId 21 | versionCode = AndroidClient.versionCode 22 | versionName = AndroidClient.versionName 23 | testInstrumentationRunner = AndroidClient.testRunner 24 | } 25 | 26 | sourceSets { 27 | map { it.java.srcDir("src/${it.name}/kotlin") } 28 | } 29 | } 30 | 31 | dependencies { 32 | // Application dependencies 33 | implementation(Libraries.kotlinStdLib) 34 | implementation(Libraries.kotlinCoroutines) 35 | implementation(Libraries.kotlinCoroutinesAndroid) 36 | implementation(Libraries.ktxCore) 37 | implementation(Libraries.appCompat) 38 | implementation(Libraries.fragment) 39 | implementation(Libraries.material) 40 | implementation(Libraries.constraintLayout) 41 | 42 | // Unit/Android tests dependencies 43 | testImplementation(TestLibraries.junit4) 44 | testImplementation(TestLibraries.mockk) 45 | testImplementation(TestLibraries.kluent) 46 | testImplementation(TestLibraries.robolectric) 47 | 48 | // Acceptance tests dependencies 49 | androidTestImplementation(TestLibraries.testRunner) 50 | androidTestImplementation(TestLibraries.espressoCore) 51 | androidTestImplementation(TestLibraries.testExtJunit) 52 | androidTestImplementation(TestLibraries.testRules) 53 | androidTestImplementation(TestLibraries.espressoIntents) 54 | 55 | // Development dependencies 56 | debugImplementation(DevLibraries.leakCanary) 57 | } 58 | -------------------------------------------------------------------------------- /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/androidTest/kotlin/com/fernandocejas/sample/AcceptanceTest.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2020 Fernando Cejas Open Source Project 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.fernandocejas.sample 17 | 18 | import android.app.Activity 19 | import androidx.test.ext.junit.runners.AndroidJUnit4 20 | import androidx.test.filters.LargeTest 21 | import androidx.test.rule.ActivityTestRule 22 | import org.junit.Rule 23 | import org.junit.runner.RunWith 24 | 25 | /** 26 | * Base class for Acceptance tests. Inherit from it to create test cases which 27 | * contain android ui. The framework used is Espresso. 28 | */ 29 | @LargeTest 30 | @RunWith(AndroidJUnit4::class) 31 | abstract class AcceptanceTest(clazz: Class) { 32 | 33 | @get:Rule 34 | val activityRule = ActivityTestRule(clazz) 35 | } 36 | 37 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/fernandocejas/sample/AndroidApplication.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2020 Fernando Cejas Open Source Project 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.fernandocejas.sample 17 | 18 | import android.app.Application 19 | 20 | class AndroidApplication : Application() 21 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/fernandocejas/sample/MainActivity.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2020 Fernando Cejas Open Source Project 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.fernandocejas.sample 17 | 18 | import com.fernandocejas.sample.core.platform.BaseActivity 19 | 20 | class MainActivity : BaseActivity() { 21 | override fun fragment() = MainFragment() 22 | } 23 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/fernandocejas/sample/MainFragment.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2020 Fernando Cejas Open Source Project 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.fernandocejas.sample 17 | 18 | import android.os.Bundle 19 | import android.view.View 20 | import androidx.annotation.StringRes 21 | import com.fernandocejas.sample.core.flags.Flag 22 | import com.fernandocejas.sample.core.platform.BaseFragment 23 | import kotlinx.android.synthetic.main.fragment_main.* 24 | 25 | class MainFragment : BaseFragment(R.layout.fragment_main) { 26 | 27 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 28 | super.onViewCreated(view, savedInstanceState) 29 | 30 | //Example code of how Feature Flags can be used. 31 | Flag.Hello whenActivated { displayGreeting(R.string.hello) } 32 | } 33 | 34 | private fun displayGreeting(@StringRes resId: Int) { 35 | tv_greeting.text = getString(resId) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/fernandocejas/sample/core/extension/Context.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2020 Fernando Cejas Open Source Project 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.fernandocejas.sample.core.extension 17 | 18 | import android.content.Context 19 | import android.net.ConnectivityManager 20 | 21 | val Context.connectivityManager: ConnectivityManager get() = 22 | this.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager -------------------------------------------------------------------------------- /app/src/main/kotlin/com/fernandocejas/sample/core/extension/Fragment.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2020 Fernando Cejas Open Source Project 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.fernandocejas.sample.core.extension 17 | 18 | import android.content.Context 19 | import com.fernandocejas.sample.core.platform.BaseFragment 20 | 21 | val BaseFragment.appContext: Context get() = activity?.applicationContext!! 22 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/fernandocejas/sample/core/extension/String.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2020 Fernando Cejas Open Source Project 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.fernandocejas.sample.core.extension 17 | 18 | fun String.Companion.empty() = "" 19 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/fernandocejas/sample/core/extension/View.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2020 Fernando Cejas Open Source Project 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.fernandocejas.sample.core.extension 17 | 18 | import android.view.LayoutInflater 19 | import android.view.View 20 | import android.view.ViewGroup 21 | import androidx.annotation.LayoutRes 22 | 23 | fun View.isVisible() = this.visibility == View.VISIBLE 24 | 25 | fun View.visible() { this.visibility = View.VISIBLE } 26 | 27 | fun View.invisible() { this.visibility = View.GONE } 28 | 29 | fun ViewGroup.inflate(@LayoutRes layoutRes: Int): View = 30 | LayoutInflater.from(context).inflate(layoutRes, this, false) 31 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/fernandocejas/sample/core/flags/FeatureFlag.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2020 Fernando Cejas Open Source Project 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.fernandocejas.sample.core.flags 17 | 18 | internal open class FeatureFlag(private val enabled: Boolean) { 19 | 20 | infix fun whenActivated(fnFeatureEnabled: () -> Unit): Condition { 21 | if (enabled) fnFeatureEnabled.invoke(); return Condition(enabled) 22 | } 23 | 24 | inner class Condition(private val expression: Boolean) { 25 | infix fun otherwise(otherwise: () -> Unit) { 26 | if (!expression) otherwise.invoke() 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/fernandocejas/sample/core/flags/Flag.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2020 Fernando Cejas Open Source Project 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.fernandocejas.sample.core.flags 17 | 18 | import com.fernandocejas.sample.BuildConfig 19 | 20 | /** 21 | * Feature flags states (activated/deactivated) can be used as conditionals. 22 | * 23 | * ### Example: 24 | * 25 | * ```Flag.Conversations whenActivated { fn } otherwise { fn }``` 26 | */ 27 | internal sealed class Flag(enabled: Boolean) : FeatureFlag(enabled) { 28 | 29 | /** 30 | * Defined Feature Flags. 31 | * @see "FeatureFlags.kt" file for compile-time feature definition. 32 | */ 33 | object Hello : Flag(BuildConfig.FEATURE_HELLO) 34 | object Bye : Flag(BuildConfig.FEATURE_BYE) 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/fernandocejas/sample/core/platform/BaseActivity.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2020 Fernando Cejas Open Source Project 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.fernandocejas.sample.core.platform 17 | 18 | import android.os.Bundle 19 | import android.view.View 20 | import androidx.appcompat.app.AppCompatActivity 21 | import androidx.appcompat.widget.Toolbar 22 | import androidx.fragment.app.commit 23 | import com.fernandocejas.sample.R 24 | 25 | 26 | abstract class BaseActivity : AppCompatActivity(R.layout.activity_layout) { 27 | 28 | override fun onCreate(savedInstanceState: Bundle?) { 29 | super.onCreate(savedInstanceState) 30 | setupToolbar() 31 | addFragment(savedInstanceState) 32 | } 33 | 34 | private fun setupToolbar() { 35 | val toolbar = findViewById(R.id.toolbar) as Toolbar 36 | toolbar.title = getString(R.string.app_name) 37 | setSupportActionBar(toolbar) 38 | } 39 | 40 | private fun addFragment(savedInstanceState: Bundle?) { 41 | if (firstTimeCreated(savedInstanceState)) { 42 | supportFragmentManager.commit { 43 | setReorderingAllowed(true) 44 | add(R.id.fragment_container_view, fragment()) 45 | } 46 | } 47 | } 48 | 49 | private fun firstTimeCreated(savedInstanceState: Bundle?) = savedInstanceState == null 50 | 51 | abstract fun fragment(): BaseFragment 52 | } 53 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/fernandocejas/sample/core/platform/BaseFragment.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2020 Fernando Cejas Open Source Project 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.fernandocejas.sample.core.platform 17 | 18 | import androidx.fragment.app.Fragment 19 | 20 | abstract class BaseFragment(layoutId: Int) : Fragment(layoutId) { 21 | val actionBar = activity?.actionBar 22 | } 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | 31 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/res/layout/toolbar.xml: -------------------------------------------------------------------------------- 1 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/android10/android-trinity/4196049469825ba38270d9bffd6b18826e168443/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/android10/android-trinity/4196049469825ba38270d9bffd6b18826e168443/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/android10/android-trinity/4196049469825ba38270d9bffd6b18826e168443/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/android10/android-trinity/4196049469825ba38270d9bffd6b18826e168443/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/android10/android-trinity/4196049469825ba38270d9bffd6b18826e168443/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/android10/android-trinity/4196049469825ba38270d9bffd6b18826e168443/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/android10/android-trinity/4196049469825ba38270d9bffd6b18826e168443/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/android10/android-trinity/4196049469825ba38270d9bffd6b18826e168443/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/android10/android-trinity/4196049469825ba38270d9bffd6b18826e168443/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/android10/android-trinity/4196049469825ba38270d9bffd6b18826e168443/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values-night/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Android Trinity 3 | 4 | Hello World!!! 5 | Hello World!!! 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 17 | 18 | 36 | 37 | 38 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /app/src/test/kotlin/com/fernandocejas/sample/AndroidAssertions.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2020 Fernando Cejas Open Source Project 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 | @file:JvmName("AndroidAssertions") 17 | @file:JvmMultifileClass 18 | 19 | package com.fernandocejas.sample 20 | 21 | import androidx.appcompat.app.AppCompatActivity 22 | import org.amshove.kluent.shouldEqual 23 | import org.robolectric.Robolectric 24 | import org.robolectric.Shadows 25 | import kotlin.reflect.KClass 26 | 27 | infix fun KClass.shouldNavigateTo(nextActivity: KClass): () -> Unit = { 28 | val originActivity = Robolectric.buildActivity(this.java).get() 29 | val shadowActivity = Shadows.shadowOf(originActivity) 30 | val nextIntent = shadowActivity.peekNextStartedActivity() 31 | 32 | nextIntent.component?.className shouldEqual nextActivity.java.canonicalName 33 | } -------------------------------------------------------------------------------- /app/src/test/kotlin/com/fernandocejas/sample/AndroidTest.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2020 Fernando Cejas Open Source Project 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.fernandocejas.sample 17 | 18 | import android.app.Application 19 | import android.content.Context 20 | import android.os.Build 21 | import org.junit.Rule 22 | import org.junit.runner.RunWith 23 | import org.robolectric.RobolectricTestRunner 24 | import org.robolectric.RuntimeEnvironment 25 | import org.robolectric.annotation.Config 26 | 27 | /** 28 | * Base class for Android tests. Inherit from it to create test cases which contain android 29 | * framework dependencies or components. 30 | * 31 | * @see UnitTest 32 | */ 33 | @RunWith(RobolectricTestRunner::class) 34 | @Config(application = AndroidTest.ApplicationStub::class, 35 | manifest = Config.NONE, 36 | sdk = [Build.VERSION_CODES.O_MR1]) 37 | abstract class AndroidTest { 38 | 39 | @Suppress("LeakingThis") 40 | @Rule @JvmField val injectMocks = InjectMocksRule.create(this@AndroidTest) 41 | 42 | fun context(): Context = RuntimeEnvironment.systemContext 43 | 44 | internal class ApplicationStub : Application() 45 | } 46 | -------------------------------------------------------------------------------- /app/src/test/kotlin/com/fernandocejas/sample/InjectMocksRule.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2020 Fernando Cejas Open Source Project 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.fernandocejas.sample 17 | 18 | import io.mockk.MockKAnnotations 19 | import org.junit.rules.TestRule 20 | 21 | object InjectMocksRule { 22 | fun create(testClass: Any) = TestRule { statement, _ -> 23 | MockKAnnotations.init(testClass, relaxUnitFun = true) 24 | statement 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/test/kotlin/com/fernandocejas/sample/UnitTest.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2020 Fernando Cejas Open Source Project 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.fernandocejas.sample 17 | 18 | import org.junit.Rule 19 | 20 | /** 21 | * Base class for Unit tests. Inherit from it to create test cases which DO NOT contain android 22 | * framework dependencies or components. 23 | * 24 | * @see AndroidTest 25 | */ 26 | abstract class UnitTest { 27 | 28 | @Suppress("LeakingThis") 29 | @Rule @JvmField val injectMocks = InjectMocksRule.create(this@UnitTest) 30 | 31 | fun fail(message: String): Nothing = throw AssertionError(message) 32 | } 33 | -------------------------------------------------------------------------------- /app/src/test/kotlin/com/fernandocejas/sample/core/flags/FeatureFlagTest.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2020 Fernando Cejas Open Source Project 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.fernandocejas.sample.core.flags 17 | 18 | import com.fernandocejas.sample.UnitTest 19 | import io.mockk.Called 20 | import io.mockk.mockk 21 | import io.mockk.verify 22 | import org.junit.Test 23 | 24 | class FeatureFlagTest : UnitTest() { 25 | 26 | @Test 27 | fun `given a feature flag, when it is activated, then executes given logic block`() { 28 | val activeFlag = ActiveFeatureFlag() 29 | val fakeNavigator = mockk(relaxed = true) 30 | 31 | activeFlag whenActivated { 32 | fakeNavigator.doSomething() 33 | fakeNavigator.navigateToActiveFeature() 34 | fakeNavigator.doSomething() 35 | } 36 | 37 | verify(exactly = 1) { fakeNavigator.navigateToActiveFeature() } 38 | verify(exactly = 2) { fakeNavigator.doSomething() } 39 | } 40 | 41 | @Test 42 | fun `given a feature flag, when it is deactivated, then does not execute given logic block`() { 43 | val inactiveFlag = InactiveFeatureFlag() 44 | val fakeNavigator = mockk(relaxed = true) 45 | 46 | inactiveFlag whenActivated { 47 | fakeNavigator.doSomething() 48 | fakeNavigator.navigateToActiveFeature() 49 | fakeNavigator.doSomething() 50 | } 51 | 52 | verify { fakeNavigator wasNot Called } 53 | } 54 | 55 | @Test 56 | fun `given a feature flag, when it is activated, then does not execute given "otherwise" logic block`() { 57 | val activeFlag = ActiveFeatureFlag() 58 | val fakeNavigator = mockk(relaxed = true) 59 | 60 | activeFlag whenActivated { 61 | fakeNavigator.doSomething() 62 | fakeNavigator.navigateToActiveFeature() 63 | fakeNavigator.doSomething() 64 | } otherwise { 65 | fakeNavigator.navigateToDefaultScreen() 66 | } 67 | 68 | verify(exactly = 1) { fakeNavigator.navigateToActiveFeature() } 69 | verify(exactly = 2) { fakeNavigator.doSomething() } 70 | verify(inverse = true) { fakeNavigator.navigateToDefaultScreen() } 71 | } 72 | 73 | @Test 74 | fun `given a feature flag, when it is deactivated, then execute given "otherwise" logic block`() { 75 | val inactiveFlag = InactiveFeatureFlag() 76 | val fakeNavigator = mockk(relaxed = true) 77 | 78 | inactiveFlag whenActivated { 79 | fakeNavigator.doSomething() 80 | fakeNavigator.navigateToActiveFeature() 81 | fakeNavigator.doSomething() 82 | } otherwise { 83 | fakeNavigator.navigateToDefaultScreen() 84 | } 85 | 86 | verify(inverse = true) { fakeNavigator.navigateToActiveFeature() } 87 | verify(inverse = true) { fakeNavigator.doSomething() } 88 | verify(exactly = 1) { fakeNavigator.navigateToDefaultScreen() } 89 | } 90 | 91 | private class ActiveFeatureFlag : FeatureFlag(enabled = true) 92 | private class InactiveFeatureFlag : FeatureFlag(enabled = false) 93 | 94 | private class Navigator { 95 | fun doSomething() { this.hashCode() } 96 | fun navigateToActiveFeature() { this.hashCode() } 97 | fun navigateToDefaultScreen() { this.hashCode() } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id(ScriptPlugins.infrastructure) 3 | } 4 | 5 | buildscript { 6 | repositories { 7 | google() 8 | jcenter() 9 | } 10 | 11 | dependencies { 12 | classpath (BuildPlugins.androidGradlePlugin) 13 | classpath (BuildPlugins.kotlinGradlePlugin) 14 | } 15 | } 16 | 17 | allprojects { 18 | repositories { 19 | google() 20 | jcenter() 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /buildSrc/build.gradle.kts: -------------------------------------------------------------------------------- 1 | object Dependencies { 2 | const val AndroidBuildTools = "com.android.tools.build:gradle:4.1.0" 3 | const val kotlinGradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.10" 4 | const val detektGradlePlugin = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.15.0" 5 | } 6 | 7 | plugins { 8 | `kotlin-dsl` 9 | `kotlin-dsl-precompiled-script-plugins` 10 | } 11 | 12 | repositories { 13 | jcenter() 14 | google() 15 | } 16 | 17 | dependencies { 18 | implementation(Dependencies.AndroidBuildTools) 19 | implementation(Dependencies.kotlinGradlePlugin) 20 | implementation(Dependencies.detektGradlePlugin) 21 | } 22 | -------------------------------------------------------------------------------- /buildSrc/settings.gradle.kts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/android10/android-trinity/4196049469825ba38270d9bffd6b18826e168443/buildSrc/settings.gradle.kts -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/Dependencies.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2020 Fernando Cejas Open Source Project 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 | object Kotlin { 17 | const val standardLibrary = "1.4.10" 18 | const val coroutines = "1.3.9" 19 | } 20 | 21 | object AndroidSdk { 22 | const val min = 21 23 | const val compile = 29 24 | const val target = compile 25 | } 26 | 27 | object AndroidClient { 28 | const val appId = "com.fernandocejas.sample" 29 | const val versionCode = 1 30 | const val versionName = "1.0" 31 | const val testRunner = "androidx.test.runner.AndroidJUnitRunner" 32 | } 33 | 34 | object BuildPlugins { 35 | object Versions { 36 | const val buildToolsVersion = "4.1.0" 37 | const val gradleVersion = "6.7" 38 | } 39 | 40 | const val androidGradlePlugin = "com.android.tools.build:gradle:${Versions.buildToolsVersion}" 41 | const val kotlinGradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:${Kotlin.standardLibrary}" 42 | const val androidApplication = "com.android.application" 43 | const val kotlinAndroid = "kotlin-android" 44 | const val kotlinAndroidExtensions = "kotlin-android-extensions" 45 | } 46 | 47 | object ScriptPlugins { 48 | const val infrastructure = "scripts.infrastructure" 49 | const val variants = "scripts.variants" 50 | const val quality = "scripts.quality" 51 | const val compilation = "scripts.compilation" 52 | } 53 | 54 | object Libraries { 55 | private object Versions { 56 | const val appCompat = "1.2.0" 57 | const val fragment = "1.2.5" 58 | const val constraintLayout = "2.0.4" 59 | const val material = "1.2.1" 60 | const val ktx = "1.3.2" 61 | } 62 | 63 | const val kotlinStdLib = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${Kotlin.standardLibrary}" 64 | const val kotlinCoroutines = "org.jetbrains.kotlinx:kotlinx-coroutines-core:${Kotlin.coroutines}" 65 | const val kotlinCoroutinesAndroid = "org.jetbrains.kotlinx:kotlinx-coroutines-android:${Kotlin.coroutines}" 66 | const val appCompat = "androidx.appcompat:appcompat:${Versions.appCompat}" 67 | const val fragment = "androidx.fragment:fragment-ktx:${Versions.fragment}" 68 | const val constraintLayout = "androidx.constraintlayout:constraintlayout:${Versions.constraintLayout}" 69 | const val ktxCore = "androidx.core:core-ktx:${Versions.ktx}" 70 | const val material = "com.google.android.material:material:${Versions.material}" 71 | } 72 | 73 | object TestLibraries { 74 | private object Versions { 75 | const val junit4 = "4.13.1" 76 | const val mockk = "1.10.0" 77 | const val robolectric = "4.4" 78 | const val kluent = "1.14" 79 | const val testRunner = "1.1.0" 80 | const val espressoCore = "3.2.0" 81 | const val espressoIntents = "3.1.0" 82 | const val testExtensions = "1.1.1" 83 | const val testRules = "1.1.0" 84 | } 85 | 86 | const val junit4 = "junit:junit:${Versions.junit4}" 87 | const val mockk = "io.mockk:mockk:${Versions.mockk}" 88 | const val robolectric = "org.robolectric:robolectric:${Versions.robolectric}" 89 | const val kluent = "org.amshove.kluent:kluent:${Versions.kluent}" 90 | const val testRunner = "androidx.test:runner:${Versions.testRunner}" 91 | const val testRules = "androidx.test:rules:${Versions.testRules}" 92 | const val espressoCore = "androidx.test.espresso:espresso-core:${Versions.espressoCore}" 93 | const val espressoIntents = "androidx.test.espresso:espresso-intents:${Versions.espressoIntents}" 94 | const val testExtJunit = "androidx.test.ext:junit:${Versions.testExtensions}" 95 | } 96 | 97 | object DevLibraries { 98 | private object Versions { 99 | const val leakCanary = "2.5" 100 | } 101 | 102 | const val leakCanary = "com.squareup.leakcanary:leakcanary-android:${Versions.leakCanary}" 103 | } 104 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/FeatureFlags.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2020 Fernando Cejas Open Source Project 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 | import scripts.Variants_gradle.ProductFlavors 17 | 18 | /** 19 | * By convention use the prefix FEATURE_ for every 20 | * defined functionality that will be under a feature flag. 21 | */ 22 | enum class Features { 23 | FEATURE_HELLO, 24 | FEATURE_BYE 25 | } 26 | 27 | /** 28 | * Defines a map for activated flags per product flavor. 29 | */ 30 | object FeatureFlags { 31 | val activated = mapOf( 32 | 33 | //Enabled Features for DEV Product Flavor 34 | ProductFlavors.DEV to setOf( 35 | Features.FEATURE_HELLO, 36 | Features.FEATURE_BYE), 37 | 38 | //Enabled Features for INTERNAL Product Flavor 39 | ProductFlavors.INTERNAL to setOf( 40 | Features.FEATURE_BYE), 41 | 42 | //Enabled Features for PUBLIC Product Flavor 43 | ProductFlavors.PUBLIC to setOf( 44 | Features.FEATURE_HELLO)) 45 | } 46 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/scripts/compilation.gradle.kts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2020 Fernando Cejas Open Source Project 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 scripts 17 | 18 | plugins { 19 | id("com.android.application") apply false 20 | id("kotlin-android") apply false 21 | } 22 | 23 | android { 24 | packagingOptions { 25 | exclude("LICENSE.txt") 26 | exclude("META-INF/DEPENDENCIES") 27 | exclude("META-INF/ASL2.0") 28 | exclude("META-INF/NOTICE") 29 | exclude("META-INF/NOTICE") 30 | } 31 | 32 | compileOptions { 33 | sourceCompatibility = JavaVersion.VERSION_1_8 34 | targetCompatibility = JavaVersion.VERSION_1_8 35 | } 36 | 37 | testOptions { 38 | animationsDisabled = true 39 | } 40 | 41 | kotlinOptions { 42 | jvmTarget = JavaVersion.VERSION_1_8.toString() 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/scripts/infrastructure.gradle.kts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2020 Fernando Cejas Open Source Project 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 scripts 17 | 18 | import scripts.Variants_gradle.* 19 | import java.util.* 20 | 21 | tasks.register("clean", Delete::class){ 22 | delete(rootProject.buildDir) 23 | } 24 | 25 | tasks.named("wrapper") { 26 | gradleVersion = BuildPlugins.Versions.gradleVersion 27 | distributionType = Wrapper.DistributionType.ALL 28 | } 29 | 30 | tasks.register("runUnitTests") { 31 | description = "Runs all Unit Tests." 32 | dependsOn(":app:test${Default.BUILD_VARIANT}UnitTest") 33 | } 34 | 35 | tasks.register("runAcceptanceTests") { 36 | description = "Runs all Acceptance Tests in the connected device." 37 | dependsOn(":app:connected${Default.BUILD_VARIANT}AndroidTest") 38 | } 39 | 40 | tasks.register("compileApp") { 41 | description = "Compiles the Android Client." 42 | dependsOn(":app:assemble${Default.BUILD_VARIANT}") 43 | } 44 | 45 | tasks.register("runApp", Exec::class) { 46 | val compileAppTask = "compileApp" 47 | val installAppTask = ":app:install${Default.BUILD_VARIANT}" 48 | 49 | description = "Compiles and runs the Android Client in the connected device." 50 | dependsOn(compileAppTask, installAppTask) 51 | tasks.findByName(installAppTask)?.mustRunAfter(compileAppTask) 52 | 53 | val localProperties = File(project.rootDir, "local.properties") 54 | if (localProperties.exists()) { 55 | val properties = Properties() 56 | localProperties.inputStream().use { properties.load(it) } 57 | val sdkDir = properties["sdk.dir"] 58 | val adb = "${sdkDir}/platform-tools/adb" 59 | 60 | val applicationPackage = "com.fernandocejas.sample.${Default.BUILD_FLAVOR}.${Default.BUILD_TYPE}" 61 | val launchActivity = "com.fernandocejas.sample.MainActivity" 62 | 63 | commandLine(adb, "shell", "am", "start", "-n", "${applicationPackage}/${launchActivity}") 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/scripts/quality.gradle.kts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2020 Fernando Cejas Open Source Project 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 scripts 17 | 18 | import io.gitlab.arturbosch.detekt.Detekt 19 | import scripts.Variants_gradle.* 20 | 21 | plugins { 22 | id("com.android.application") apply false 23 | id("jacoco") 24 | id("io.gitlab.arturbosch.detekt") 25 | } 26 | 27 | android { 28 | lintOptions { 29 | isQuiet = true 30 | isAbortOnError = false 31 | isIgnoreWarnings = true 32 | disable("InvalidPackage") //Some libraries have issues with this. 33 | disable("OldTargetApi") //Lint gives this warning related to SDK Beta. 34 | disable("IconDensities") //For testing purpose. This is safe to remove. 35 | disable("IconMissingDensityFolder") //For testing purpose. This is safe to remove. 36 | } 37 | } 38 | 39 | val jacocoReport by tasks.registering(JacocoReport::class) { 40 | group = "Quality" 41 | description = "Report code coverage on tests within the Android codebase." 42 | dependsOn("test${Default.BUILD_VARIANT}UnitTest") 43 | 44 | val buildVariantClassPath = "${Default.BUILD_FLAVOR}${Default.BUILD_TYPE.capitalize()}" 45 | val outputDir = "${project.buildDir}/testCoverage" 46 | 47 | reports { 48 | xml.isEnabled = true 49 | html.isEnabled = true 50 | html.destination = file(outputDir) 51 | } 52 | 53 | classDirectories.setFrom(fileTree(project.buildDir) { 54 | include( 55 | "**/classes/**/main/**", 56 | "**/intermediates/classes/$buildVariantClassPath/**", 57 | "**/intermediates/javac/$buildVariantClassPath/*/classes/**", 58 | "**/tmp/kotlin-classes/$buildVariantClassPath/**") 59 | exclude( 60 | "**/R.class", 61 | "**/R\$*.class", 62 | "**/BuildConfig.*", 63 | "**/Manifest*.*", 64 | "**/Manifest$*.class", 65 | "**/*Test*.*", 66 | "**/Injector.*", 67 | "android/**/*.*", 68 | "**/*\$Lambda$*.*", 69 | "**/*\$inlined$*.*", 70 | "**/di/*.*", 71 | "**/*Database.*", 72 | "**/*Response.*", 73 | "**/*Application.*", 74 | "**/*Entity.*") 75 | } 76 | ) 77 | sourceDirectories.setFrom(fileTree(project.projectDir) { 78 | include("src/main/java/**", "src/main/kotlin/**") }) 79 | executionData.setFrom(fileTree(project.buildDir) { 80 | include("**/*.exec", "**/*.ec") }) 81 | 82 | doLast { println("Code Coverage Report: $outputDir/index.html") } 83 | } 84 | 85 | tasks.register("runTestCoverage") { 86 | group = "Quality" 87 | description = "Report code coverage on tests within the Android codebase." 88 | dependsOn(jacocoReport) 89 | } 90 | 91 | val detektAll by tasks.registering(Detekt::class) { 92 | group = "Quality" 93 | description = "Runs a detekt code analysis on the Android codebase." 94 | parallel = true 95 | buildUponDefaultConfig = true 96 | 97 | val outputFile = "${project.buildDir}/staticAnalysis/index.html" 98 | 99 | setSource(files(rootProject.projectDir)) 100 | config.setFrom("${project.rootDir}/config/detekt/detekt.yml") 101 | 102 | include("**/*.kt") 103 | exclude("**/*.kts", "*/build/*", "/buildSrc") 104 | 105 | reports { 106 | html.enabled = true 107 | html.destination = file(outputFile) 108 | xml.enabled = false 109 | txt.enabled = false 110 | } 111 | 112 | val reportFile = "Static Analysis Report: $outputFile \n" 113 | doFirst { println(reportFile) } 114 | doLast { println(reportFile) } 115 | } 116 | 117 | tasks.register("runStaticAnalysis") { 118 | description = "Run static analysis on the Android codebase." 119 | dependsOn(detektAll) 120 | } 121 | 122 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/scripts/variants.gradle.kts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2020 Fernando Cejas Open Source Project 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 scripts 17 | 18 | plugins { id("com.android.application") apply false } 19 | 20 | private object BuildTypes { 21 | const val DEBUG = "debug" 22 | const val RELEASE = "release" 23 | } 24 | 25 | object ProductFlavors { 26 | const val DEV = "dev" 27 | const val INTERNAL = "internal" 28 | const val PUBLIC = "public" 29 | } 30 | 31 | private object FlavorDimensions { 32 | const val DEFAULT = "default" 33 | } 34 | 35 | object Default { 36 | const val BUILD_TYPE = BuildTypes.DEBUG 37 | const val BUILD_FLAVOR = ProductFlavors.DEV 38 | 39 | val BUILD_VARIANT = "${BUILD_FLAVOR.capitalize()}${BUILD_TYPE.capitalize()}" 40 | } 41 | 42 | android { 43 | buildTypes { 44 | getByName(BuildTypes.DEBUG) { 45 | isMinifyEnabled = false 46 | applicationIdSuffix = ".${BuildTypes.DEBUG}" 47 | isDebuggable = true 48 | } 49 | getByName(BuildTypes.RELEASE) { 50 | isMinifyEnabled = true 51 | proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") 52 | } 53 | } 54 | 55 | flavorDimensions(FlavorDimensions.DEFAULT) 56 | productFlavors { 57 | create(ProductFlavors.DEV) { 58 | dimension = FlavorDimensions.DEFAULT 59 | applicationIdSuffix = ".${ProductFlavors.DEV}" 60 | versionNameSuffix = "-${ProductFlavors.DEV}" 61 | } 62 | create(ProductFlavors.INTERNAL) { 63 | dimension = FlavorDimensions.DEFAULT 64 | applicationIdSuffix = ".${ProductFlavors.INTERNAL}" 65 | versionNameSuffix = "-${ProductFlavors.INTERNAL}" 66 | } 67 | create(ProductFlavors.PUBLIC) { 68 | dimension = FlavorDimensions.DEFAULT 69 | } 70 | } 71 | 72 | /** 73 | * Process feature flags and if the feature is not included in a product flavor, 74 | * a default value of "false" or "deactivated" is used. 75 | * 76 | * @see "FeatureFlags.kt" file definition. 77 | */ 78 | productFlavors.map { flavor -> 79 | Features.values().forEach { feature -> 80 | val activated = FeatureFlags.activated[flavor.name].orEmpty().contains(feature) 81 | flavor.buildConfigField("Boolean", feature.name, activated.toString()) 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /config/detekt/detekt.yml: -------------------------------------------------------------------------------- 1 | build: 2 | maxIssues: 100 3 | excludeCorrectable: false 4 | weights: 5 | # complexity: 2 6 | # LongParameterList: 1 7 | # style: 1 8 | # comments: 1 9 | 10 | config: 11 | validation: true 12 | # when writing own rules with new properties, exclude the property path e.g.: 'my_rule_set,.*>.*>[my_property]' 13 | excludes: '' 14 | 15 | processors: 16 | active: true 17 | exclude: 18 | - 'DetektProgressListener' 19 | # - 'FunctionCountProcessor' 20 | # - 'PropertyCountProcessor' 21 | # - 'ClassCountProcessor' 22 | # - 'PackageCountProcessor' 23 | # - 'KtFileCountProcessor' 24 | 25 | console-reports: 26 | active: true 27 | exclude: 28 | - 'ProjectStatisticsReport' 29 | - 'ComplexityReport' 30 | - 'NotificationReport' 31 | # - 'FindingsReport' 32 | - 'FileBasedFindingsReport' 33 | 34 | comments: 35 | active: true 36 | excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] 37 | AbsentOrWrongFileLicense: 38 | active: false 39 | licenseTemplateFile: 'license.template' 40 | CommentOverPrivateFunction: 41 | active: false 42 | CommentOverPrivateProperty: 43 | active: false 44 | EndOfSentenceFormat: 45 | active: false 46 | endOfSentenceFormat: '([.?!][ \t\n\r\f<])|([.?!:]$)' 47 | UndocumentedPublicClass: 48 | active: false 49 | searchInNestedClass: true 50 | searchInInnerClass: true 51 | searchInInnerObject: true 52 | searchInInnerInterface: true 53 | UndocumentedPublicFunction: 54 | active: false 55 | UndocumentedPublicProperty: 56 | active: false 57 | 58 | complexity: 59 | active: true 60 | ComplexCondition: 61 | active: true 62 | threshold: 4 63 | ComplexInterface: 64 | active: false 65 | threshold: 10 66 | includeStaticDeclarations: false 67 | includePrivateDeclarations: false 68 | ComplexMethod: 69 | active: true 70 | threshold: 15 71 | ignoreSingleWhenExpression: false 72 | ignoreSimpleWhenEntries: false 73 | ignoreNestingFunctions: false 74 | nestingFunctions: [run, let, apply, with, also, use, forEach, isNotNull, ifNull] 75 | LabeledExpression: 76 | active: false 77 | ignoredLabels: [] 78 | LargeClass: 79 | active: true 80 | threshold: 600 81 | LongMethod: 82 | active: true 83 | threshold: 60 84 | LongParameterList: 85 | active: true 86 | functionThreshold: 6 87 | constructorThreshold: 7 88 | ignoreDefaultParameters: false 89 | ignoreDataClasses: true 90 | ignoreAnnotated: [] 91 | MethodOverloading: 92 | active: false 93 | threshold: 6 94 | NestedBlockDepth: 95 | active: true 96 | threshold: 4 97 | StringLiteralDuplication: 98 | active: false 99 | excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] 100 | threshold: 3 101 | ignoreAnnotation: true 102 | excludeStringsWithLessThan5Characters: true 103 | ignoreStringsRegex: '$^' 104 | TooManyFunctions: 105 | active: true 106 | excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] 107 | thresholdInFiles: 14 108 | thresholdInClasses: 14 109 | thresholdInInterfaces: 14 110 | thresholdInObjects: 14 111 | thresholdInEnums: 14 112 | ignoreDeprecated: false 113 | ignorePrivate: false 114 | ignoreOverridden: false 115 | 116 | coroutines: 117 | active: true 118 | GlobalCoroutineUsage: 119 | active: false 120 | RedundantSuspendModifier: 121 | active: false 122 | 123 | empty-blocks: 124 | active: true 125 | EmptyCatchBlock: 126 | active: true 127 | allowedExceptionNameRegex: '_|(ignore|expected).*' 128 | EmptyClassBlock: 129 | active: true 130 | EmptyDefaultConstructor: 131 | active: true 132 | EmptyDoWhileBlock: 133 | active: true 134 | EmptyElseBlock: 135 | active: true 136 | EmptyFinallyBlock: 137 | active: true 138 | EmptyForBlock: 139 | active: true 140 | EmptyFunctionBlock: 141 | active: true 142 | ignoreOverridden: false 143 | EmptyIfBlock: 144 | active: true 145 | EmptyInitBlock: 146 | active: true 147 | EmptyKtFile: 148 | active: true 149 | EmptySecondaryConstructor: 150 | active: true 151 | EmptyTryBlock: 152 | active: true 153 | EmptyWhenBlock: 154 | active: true 155 | EmptyWhileBlock: 156 | active: true 157 | 158 | exceptions: 159 | active: true 160 | ExceptionRaisedInUnexpectedLocation: 161 | active: false 162 | methodNames: [toString, hashCode, equals, finalize] 163 | InstanceOfCheckForException: 164 | active: false 165 | excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] 166 | NotImplementedDeclaration: 167 | active: false 168 | PrintStackTrace: 169 | active: false 170 | RethrowCaughtException: 171 | active: false 172 | ReturnFromFinally: 173 | active: false 174 | ignoreLabeled: false 175 | SwallowedException: 176 | active: false 177 | ignoredExceptionTypes: 178 | - InterruptedException 179 | - NumberFormatException 180 | - ParseException 181 | - MalformedURLException 182 | allowedExceptionNameRegex: '_|(ignore|expected).*' 183 | ThrowingExceptionFromFinally: 184 | active: false 185 | ThrowingExceptionInMain: 186 | active: false 187 | ThrowingExceptionsWithoutMessageOrCause: 188 | active: false 189 | exceptions: 190 | - IllegalArgumentException 191 | - IllegalStateException 192 | - IOException 193 | ThrowingNewInstanceOfSameException: 194 | active: false 195 | TooGenericExceptionCaught: 196 | active: true 197 | excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] 198 | exceptionNames: 199 | - ArrayIndexOutOfBoundsException 200 | - Error 201 | - Exception 202 | - IllegalMonitorStateException 203 | - NullPointerException 204 | - IndexOutOfBoundsException 205 | - RuntimeException 206 | - Throwable 207 | allowedExceptionNameRegex: '_|(ignore|expected).*' 208 | TooGenericExceptionThrown: 209 | active: true 210 | exceptionNames: 211 | - Error 212 | - Exception 213 | - Throwable 214 | - RuntimeException 215 | 216 | formatting: 217 | active: true 218 | android: false 219 | autoCorrect: true 220 | AnnotationOnSeparateLine: 221 | active: false 222 | autoCorrect: true 223 | ChainWrapping: 224 | active: true 225 | autoCorrect: true 226 | CommentSpacing: 227 | active: true 228 | autoCorrect: true 229 | EnumEntryNameCase: 230 | active: false 231 | autoCorrect: true 232 | Filename: 233 | active: true 234 | FinalNewline: 235 | active: true 236 | autoCorrect: true 237 | insertFinalNewLine: true 238 | ImportOrdering: 239 | active: false 240 | autoCorrect: true 241 | Indentation: 242 | active: false 243 | autoCorrect: true 244 | indentSize: 4 245 | continuationIndentSize: 4 246 | MaximumLineLength: 247 | active: true 248 | maxLineLength: 140 249 | ModifierOrdering: 250 | active: true 251 | autoCorrect: true 252 | MultiLineIfElse: 253 | active: true 254 | autoCorrect: true 255 | NoBlankLineBeforeRbrace: 256 | active: true 257 | autoCorrect: true 258 | NoConsecutiveBlankLines: 259 | active: true 260 | autoCorrect: true 261 | NoEmptyClassBody: 262 | active: true 263 | autoCorrect: true 264 | NoEmptyFirstLineInMethodBlock: 265 | active: false 266 | autoCorrect: true 267 | NoLineBreakAfterElse: 268 | active: true 269 | autoCorrect: true 270 | NoLineBreakBeforeAssignment: 271 | active: true 272 | autoCorrect: true 273 | NoMultipleSpaces: 274 | active: true 275 | autoCorrect: true 276 | NoSemicolons: 277 | active: true 278 | autoCorrect: true 279 | NoTrailingSpaces: 280 | active: true 281 | autoCorrect: true 282 | NoUnitReturn: 283 | active: true 284 | autoCorrect: true 285 | NoUnusedImports: 286 | active: true 287 | autoCorrect: true 288 | NoWildcardImports: 289 | active: true 290 | PackageName: 291 | active: true 292 | autoCorrect: true 293 | ParameterListWrapping: 294 | active: true 295 | autoCorrect: true 296 | indentSize: 4 297 | SpacingAroundColon: 298 | active: true 299 | autoCorrect: true 300 | SpacingAroundComma: 301 | active: true 302 | autoCorrect: true 303 | SpacingAroundCurly: 304 | active: true 305 | autoCorrect: true 306 | SpacingAroundDot: 307 | active: true 308 | autoCorrect: true 309 | SpacingAroundKeyword: 310 | active: true 311 | autoCorrect: true 312 | SpacingAroundOperators: 313 | active: true 314 | autoCorrect: true 315 | SpacingAroundParens: 316 | active: true 317 | autoCorrect: true 318 | SpacingAroundRangeOperator: 319 | active: true 320 | autoCorrect: true 321 | StringTemplate: 322 | active: true 323 | autoCorrect: true 324 | 325 | naming: 326 | active: true 327 | ClassNaming: 328 | active: true 329 | excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] 330 | classPattern: '[A-Z][a-zA-Z0-9]*' 331 | ConstructorParameterNaming: 332 | active: true 333 | excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] 334 | parameterPattern: '[a-z][A-Za-z0-9]*' 335 | privateParameterPattern: '[a-z][A-Za-z0-9]*' 336 | excludeClassPattern: '$^' 337 | ignoreOverridden: true 338 | EnumNaming: 339 | active: true 340 | excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] 341 | enumEntryPattern: '[A-Z][_a-zA-Z0-9]*' 342 | ForbiddenClassName: 343 | active: false 344 | excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] 345 | forbiddenName: [] 346 | FunctionMaxLength: 347 | active: false 348 | excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] 349 | maximumFunctionNameLength: 30 350 | FunctionMinLength: 351 | active: false 352 | excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] 353 | minimumFunctionNameLength: 3 354 | FunctionNaming: 355 | active: true 356 | excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] 357 | functionPattern: '([a-z][a-zA-Z0-9]*)|(`.*`)' 358 | excludeClassPattern: '$^' 359 | ignoreOverridden: true 360 | FunctionParameterNaming: 361 | active: true 362 | excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] 363 | parameterPattern: '[a-z][A-Za-z0-9]*' 364 | excludeClassPattern: '$^' 365 | ignoreOverridden: true 366 | InvalidPackageDeclaration: 367 | active: false 368 | rootPackage: '' 369 | MatchingDeclarationName: 370 | active: true 371 | mustBeFirst: true 372 | MemberNameEqualsClassName: 373 | active: true 374 | ignoreOverridden: true 375 | ObjectPropertyNaming: 376 | active: true 377 | excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] 378 | constantPattern: '[A-Za-z][_A-Za-z0-9]*' 379 | propertyPattern: '[A-Za-z][_A-Za-z0-9]*' 380 | privatePropertyPattern: '(_)?[A-Za-z][_A-Za-z0-9]*' 381 | PackageNaming: 382 | active: true 383 | excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] 384 | packagePattern: '[a-z]+(\.[a-z][A-Za-z0-9]*)*' 385 | TopLevelPropertyNaming: 386 | active: true 387 | excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] 388 | constantPattern: '[A-Z][_A-Z0-9]*' 389 | propertyPattern: '[A-Za-z][_A-Za-z0-9]*' 390 | privatePropertyPattern: '_?[A-Za-z][_A-Za-z0-9]*' 391 | VariableMaxLength: 392 | active: false 393 | excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] 394 | maximumVariableNameLength: 64 395 | VariableMinLength: 396 | active: false 397 | excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] 398 | minimumVariableNameLength: 1 399 | VariableNaming: 400 | active: true 401 | excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] 402 | variablePattern: '[a-z][A-Za-z0-9]*' 403 | privateVariablePattern: '(_)?[a-z][A-Za-z0-9]*' 404 | excludeClassPattern: '$^' 405 | ignoreOverridden: true 406 | 407 | performance: 408 | active: true 409 | ArrayPrimitive: 410 | active: true 411 | ForEachOnRange: 412 | active: true 413 | excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] 414 | SpreadOperator: 415 | active: true 416 | excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] 417 | UnnecessaryTemporaryInstantiation: 418 | active: true 419 | 420 | potential-bugs: 421 | active: true 422 | Deprecation: 423 | active: false 424 | DuplicateCaseInWhenExpression: 425 | active: true 426 | EqualsAlwaysReturnsTrueOrFalse: 427 | active: true 428 | EqualsWithHashCodeExist: 429 | active: true 430 | ExplicitGarbageCollectionCall: 431 | active: true 432 | HasPlatformType: 433 | active: false 434 | ImplicitDefaultLocale: 435 | active: false 436 | InvalidRange: 437 | active: true 438 | IteratorHasNextCallsNextMethod: 439 | active: true 440 | IteratorNotThrowingNoSuchElementException: 441 | active: true 442 | LateinitUsage: 443 | active: false 444 | excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] 445 | excludeAnnotatedProperties: [] 446 | ignoreOnClassesPattern: '' 447 | MapGetWithNotNullAssertionOperator: 448 | active: false 449 | MissingWhenCase: 450 | active: true 451 | RedundantElseInWhen: 452 | active: true 453 | UnconditionalJumpStatementInLoop: 454 | active: false 455 | UnnecessaryNotNullOperator: 456 | active: false 457 | UnnecessarySafeCall: 458 | active: false 459 | UnreachableCode: 460 | active: true 461 | UnsafeCallOnNullableType: 462 | active: true 463 | UnsafeCast: 464 | active: false 465 | UselessPostfixExpression: 466 | active: false 467 | WrongEqualsTypeParameter: 468 | active: true 469 | 470 | style: 471 | active: true 472 | CollapsibleIfStatements: 473 | active: false 474 | DataClassContainsFunctions: 475 | active: false 476 | conversionFunctionPrefix: 'to' 477 | DataClassShouldBeImmutable: 478 | active: false 479 | EqualsNullCall: 480 | active: true 481 | EqualsOnSignatureLine: 482 | active: false 483 | ExplicitCollectionElementAccessMethod: 484 | active: false 485 | ExplicitItLambdaParameter: 486 | active: false 487 | ExpressionBodySyntax: 488 | active: false 489 | includeLineWrapping: false 490 | ForbiddenComment: 491 | active: false 492 | values: ['TODO:', 'FIXME:', 'STOPSHIP:'] 493 | allowedPatterns: '' 494 | ForbiddenImport: 495 | active: false 496 | imports: [] 497 | forbiddenPatterns: '' 498 | ForbiddenMethodCall: 499 | active: false 500 | methods: [] 501 | ForbiddenPublicDataClass: 502 | active: false 503 | ignorePackages: ['*.internal', '*.internal.*'] 504 | ForbiddenVoid: 505 | active: false 506 | ignoreOverridden: false 507 | ignoreUsageInGenerics: false 508 | FunctionOnlyReturningConstant: 509 | active: true 510 | ignoreOverridableFunction: true 511 | excludedFunctions: 'describeContents, empty' 512 | excludeAnnotatedFunction: ['dagger.Provides'] 513 | LibraryCodeMustSpecifyReturnType: 514 | active: true 515 | LoopWithTooManyJumpStatements: 516 | active: true 517 | maxJumpCount: 1 518 | MagicNumber: 519 | active: true 520 | excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] 521 | ignoreNumbers: ['-1', '0', '1', '2'] 522 | ignoreHashCodeFunction: true 523 | ignorePropertyDeclaration: false 524 | ignoreLocalVariableDeclaration: false 525 | ignoreConstantDeclaration: true 526 | ignoreCompanionObjectPropertyDeclaration: true 527 | ignoreAnnotation: false 528 | ignoreNamedArgument: true 529 | ignoreEnums: false 530 | ignoreRanges: false 531 | MandatoryBracesIfStatements: 532 | active: false 533 | MandatoryBracesLoops: 534 | active: false 535 | MaxLineLength: 536 | active: true 537 | maxLineLength: 140 538 | excludePackageStatements: true 539 | excludeImportStatements: true 540 | excludeCommentStatements: false 541 | MayBeConst: 542 | active: true 543 | ModifierOrder: 544 | active: true 545 | NestedClassesVisibility: 546 | active: false 547 | NewLineAtEndOfFile: 548 | active: true 549 | NoTabs: 550 | active: false 551 | OptionalAbstractKeyword: 552 | active: true 553 | OptionalUnit: 554 | active: false 555 | OptionalWhenBraces: 556 | active: false 557 | PreferToOverPairSyntax: 558 | active: false 559 | ProtectedMemberInFinalClass: 560 | active: true 561 | RedundantExplicitType: 562 | active: false 563 | RedundantVisibilityModifierRule: 564 | active: false 565 | ReturnCount: 566 | active: true 567 | max: 2 568 | excludedFunctions: 'equals' 569 | excludeLabeled: false 570 | excludeReturnFromLambda: true 571 | excludeGuardClauses: false 572 | SafeCast: 573 | active: true 574 | SerialVersionUIDInSerializableClass: 575 | active: false 576 | SpacingBetweenPackageAndImports: 577 | active: false 578 | ThrowsCount: 579 | active: true 580 | max: 2 581 | TrailingWhitespace: 582 | active: false 583 | UnderscoresInNumericLiterals: 584 | active: false 585 | acceptableDecimalLength: 5 586 | UnnecessaryAbstractClass: 587 | active: true 588 | excludeAnnotatedClasses: ['dagger.Module'] 589 | UnnecessaryAnnotationUseSiteTarget: 590 | active: false 591 | UnnecessaryApply: 592 | active: false 593 | UnnecessaryInheritance: 594 | active: true 595 | UnnecessaryLet: 596 | active: false 597 | UnnecessaryParentheses: 598 | active: false 599 | UntilInsteadOfRangeTo: 600 | active: false 601 | UnusedImports: 602 | active: false 603 | UnusedPrivateClass: 604 | active: true 605 | UnusedPrivateMember: 606 | active: false 607 | allowedNames: '(_|ignored|expected|serialVersionUID)' 608 | UseArrayLiteralsInAnnotations: 609 | active: false 610 | UseCheckOrError: 611 | active: false 612 | UseDataClass: 613 | active: false 614 | excludeAnnotatedClasses: [] 615 | allowVars: false 616 | UseIfInsteadOfWhen: 617 | active: false 618 | UseRequire: 619 | active: false 620 | UselessCallOnNotNull: 621 | active: true 622 | UtilityClassWithPublicConstructor: 623 | active: true 624 | VarCouldBeVal: 625 | active: false 626 | WildcardImport: 627 | active: true 628 | excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] 629 | excludeImports: ['java.util.*', 'kotlinx.android.synthetic.*'] -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app"s APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Automatically convert third-party libraries to use AndroidX 19 | android.enableJetifier=true 20 | # Kotlin code style for this project: "official" or "obsolete": 21 | kotlin.code.style=official 22 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/android10/android-trinity/4196049469825ba38270d9bffd6b18826e168443/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | //Include all the existent modules in the project 2 | rootDir 3 | .walk() 4 | .maxDepth(1) 5 | .filter { 6 | it.name != "buildSrc" && it.isDirectory && 7 | file("${it.absolutePath}/build.gradle.kts").exists() 8 | } 9 | .forEach { 10 | include(":${it.name}") 11 | } --------------------------------------------------------------------------------