├── codecov.yml
├── _config.yml
├── lifecyklelog
├── .gitignore
├── src
│ ├── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── chesire
│ │ │ │ └── lifecyklelog
│ │ │ │ ├── LogHandler.kt
│ │ │ │ ├── LifecycleEvent.kt
│ │ │ │ ├── LogLifecykle.kt
│ │ │ │ ├── events
│ │ │ │ ├── ActivityEvents.kt
│ │ │ │ └── FragmentEvents.kt
│ │ │ │ └── LifecykleLog.kt
│ │ └── res
│ │ │ └── values
│ │ │ └── library_info.xml
│ └── test
│ │ └── java
│ │ └── com
│ │ └── chesire
│ │ └── lifecyklelog
│ │ ├── AnnotationClasses.kt
│ │ ├── events
│ │ ├── ActivityEventsTests.kt
│ │ └── FragmentEventsTests.kt
│ │ └── LifecykleLogTests.kt
├── proguard-rules.pro
└── build.gradle
├── lifecyklelog-sample
├── .gitignore
├── src
│ └── main
│ │ ├── res
│ │ ├── values
│ │ │ ├── strings.xml
│ │ │ ├── colors.xml
│ │ │ └── styles.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
│ │ ├── layout
│ │ │ ├── fragment_main.xml
│ │ │ └── activity_main.xml
│ │ ├── mipmap-anydpi-v26
│ │ │ ├── ic_launcher.xml
│ │ │ └── ic_launcher_round.xml
│ │ ├── drawable-v24
│ │ │ └── ic_launcher_foreground.xml
│ │ └── drawable
│ │ │ └── ic_launcher_background.xml
│ │ ├── java
│ │ └── com
│ │ │ └── chesire
│ │ │ └── lifecyklelogsample
│ │ │ ├── MainFragment.kt
│ │ │ ├── MainActivity.kt
│ │ │ ├── ApplicationOverride.kt
│ │ │ └── JApplicationOverride.java
│ │ └── AndroidManifest.xml
├── build.gradle
└── proguard-rules.pro
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── Gemfile
├── .idea
└── codeStyles
│ ├── codeStyleConfig.xml
│ └── Project.xml
├── .github
├── dependabot.yml
├── ISSUE_TEMPLATE
│ ├── feature_request.md
│ └── bug_report.md
└── workflows
│ └── android.yml
├── CONTRIBUTING.md
├── jacoco.gradle
├── Dangerfile
├── gradle.properties
├── CHANGELOG.md
├── Gemfile.lock
├── gradlew.bat
├── README.md
├── .gitignore
├── gradlew
├── LICENSE
└── detekt.yml
/codecov.yml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-cayman
--------------------------------------------------------------------------------
/lifecyklelog/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/lifecyklelog-sample/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':lifecyklelog', ':lifecyklelog-sample'
2 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Chesire/LifecykleLog/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/lifecyklelog/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/lifecyklelog-sample/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | LifecykleLog Sample
3 |
4 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source "https://rubygems.org"
2 |
3 | gem "danger"
4 | gem "danger-android_lint"
5 | gem "danger-checkstyle_format"
6 | gem "danger-junit"
7 |
--------------------------------------------------------------------------------
/lifecyklelog-sample/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Chesire/LifecykleLog/HEAD/lifecyklelog-sample/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/lifecyklelog-sample/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Chesire/LifecykleLog/HEAD/lifecyklelog-sample/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/lifecyklelog-sample/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Chesire/LifecykleLog/HEAD/lifecyklelog-sample/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/lifecyklelog-sample/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Chesire/LifecykleLog/HEAD/lifecyklelog-sample/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/lifecyklelog-sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Chesire/LifecykleLog/HEAD/lifecyklelog-sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/lifecyklelog-sample/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Chesire/LifecykleLog/HEAD/lifecyklelog-sample/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/lifecyklelog-sample/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Chesire/LifecykleLog/HEAD/lifecyklelog-sample/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/lifecyklelog-sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Chesire/LifecykleLog/HEAD/lifecyklelog-sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/lifecyklelog-sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Chesire/LifecykleLog/HEAD/lifecyklelog-sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/.idea/codeStyles/codeStyleConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/lifecyklelog-sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Chesire/LifecykleLog/HEAD/lifecyklelog-sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/lifecyklelog-sample/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #008577
4 | #00574B
5 | #D81B60
6 |
7 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Oct 20 18:30:53 BST 2020
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
7 |
--------------------------------------------------------------------------------
/lifecyklelog-sample/src/main/res/layout/fragment_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
--------------------------------------------------------------------------------
/lifecyklelog-sample/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/lifecyklelog-sample/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: gradle
4 | directory: "/"
5 | schedule:
6 | interval: daily
7 | time: '09:00'
8 | open-pull-requests-limit: 30
9 | assignees:
10 | - Chesire
11 |
12 | - package-ecosystem: github-actions
13 | directory: "/"
14 | schedule:
15 | interval: daily
16 | time: '09:00'
17 | open-pull-requests-limit: 30
18 | assignees:
19 | - Chesire
--------------------------------------------------------------------------------
/lifecyklelog/src/test/java/com/chesire/lifecyklelog/AnnotationClasses.kt:
--------------------------------------------------------------------------------
1 | package com.chesire.lifecyklelog
2 |
3 | internal class UnannotatedClass
4 |
5 | @LogLifecykle
6 | internal class AnnotatedClass
7 |
8 | @LogLifecykle("Overridden className")
9 | internal class AnnotatedClassWithNameOverride
10 |
11 | @LogLifecykle(overrideLogEvents = [LifecycleEvent.ON_SAVE_INSTANCE_STATE])
12 | internal class AnnotatedClassWithLifecycleOverride
13 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
--------------------------------------------------------------------------------
/lifecyklelog-sample/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | ## Style
4 |
5 | Ensure that the code passes the `ktlint` task, and that there are no `detekt` issues present.
6 | All commits should follow the conventional changelog style. More information can be found at [Commitizen](https://github.com/commitizen/cz-cli).
7 |
8 |
9 | ## Pull Request Process
10 |
11 | 1. Fork it ()
12 | 2. Create your feature branch (`git checkout -b feat/foobar`)
13 | 3. Commit your changes (`git commit -am 'feat: add some foobar'`)
14 | 4. Push to the branch (`git push origin feat/foobar`)
15 | 5. Create a new Pull Request
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 |
16 | **Expected behavior**
17 | A clear and concise description of what you expected to happen.
18 |
19 | **Smartphone (please complete the following information):**
20 | - Device: [e.g. Pixel 2]
21 | - OS: [e.g. Android 9]
22 | - Version [e.g. 1.0.0]
23 |
24 | **Additional context**
25 | Add any other context about the problem here.
26 |
--------------------------------------------------------------------------------
/lifecyklelog/src/main/java/com/chesire/lifecyklelog/LogHandler.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("UndocumentedPublicClass")
2 | package com.chesire.lifecyklelog
3 |
4 | import android.os.Bundle
5 |
6 | /**
7 | * Handles logging out lifecycle methods.
8 | */
9 | fun interface LogHandler {
10 | /**
11 | * Executed when a lifecycle method requires logging.
12 | *
13 | * [clazz] is the string representation of the class that the lifecycle event occurred on.
14 | * [lifecycleEvent] is the string representation of the lifecycle event that occurred.
15 | * [bundle] the bundle passed into the lifecycle event, or null if not available.
16 | */
17 | fun logLifecycleMethod(clazz: String, lifecycleEvent: String, bundle: Bundle?)
18 | }
19 |
--------------------------------------------------------------------------------
/lifecyklelog-sample/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 |
4 | android {
5 | compileSdkVersion 31
6 |
7 | defaultConfig {
8 | applicationId "com.chesire.lifecyklelogsample"
9 | minSdkVersion 14
10 | targetSdkVersion 31
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 |
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 | }
22 |
23 | dependencies {
24 | implementation project(':lifecyklelog')
25 | implementation 'androidx.appcompat:appcompat:1.4.1'
26 | implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
27 | }
28 |
--------------------------------------------------------------------------------
/lifecyklelog-sample/src/main/java/com/chesire/lifecyklelogsample/MainFragment.kt:
--------------------------------------------------------------------------------
1 | package com.chesire.lifecyklelogsample
2 |
3 | import androidx.fragment.app.Fragment
4 | import com.chesire.lifecyklelog.LifecycleEvent
5 | import com.chesire.lifecyklelog.LogLifecykle
6 |
7 | /**
8 | * [Fragment] to show how to use [LogLifecykle].
9 | */
10 | @LogLifecykle(
11 | overrideLogEvents = [
12 | LifecycleEvent.ON_ACTIVITY_CREATED,
13 | LifecycleEvent.ON_ATTACH,
14 | LifecycleEvent.ON_DETACH,
15 | LifecycleEvent.ON_DESTROY
16 | ]
17 | )
18 | class MainFragment : Fragment(R.layout.fragment_main) {
19 | companion object {
20 | /**
21 | * Generate a new instance of [MainFragment].
22 | */
23 | fun newInstance() = MainFragment()
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/lifecyklelog-sample/src/main/java/com/chesire/lifecyklelogsample/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.chesire.lifecyklelogsample
2 |
3 | import android.os.Bundle
4 | import androidx.appcompat.app.AppCompatActivity
5 | import com.chesire.lifecyklelog.LogLifecykle
6 |
7 | /**
8 | * [AppCompatActivity] to show how to use [LogLifecykle].
9 | */
10 | @LogLifecykle(className = "MainActivity")
11 | class MainActivity : AppCompatActivity(R.layout.activity_main) {
12 | override fun onCreate(savedInstanceState: Bundle?) {
13 | super.onCreate(savedInstanceState)
14 |
15 | if (savedInstanceState == null) {
16 | supportFragmentManager
17 | .beginTransaction()
18 | .replace(R.id.activityMainContainer, MainFragment.newInstance())
19 | .commit()
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/lifecyklelog/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 |
--------------------------------------------------------------------------------
/lifecyklelog-sample/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 |
--------------------------------------------------------------------------------
/jacoco.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'jacoco'
2 |
3 | jacoco {
4 | toolVersion = "$jacoco_version"
5 | }
6 |
7 | tasks.withType(Test) {
8 | jacoco.includeNoLocationClasses = true
9 | jacoco.excludes = ['jdk.internal.*']
10 | }
11 |
12 | task jacocoTestReport(
13 | type: JacocoReport,
14 | group: 'verification'
15 | ) {
16 | reports {
17 | xml.enabled = true
18 | html.enabled = true
19 | }
20 |
21 | def coverageExcludes = []
22 | def debugTree = fileTree(dir: "$project.buildDir/tmp/kotlin-classes/debug", excludes: coverageExcludes)
23 | def mainSrc = "$project.projectDir/src/main/java"
24 |
25 | getSourceDirectories().setFrom(files([mainSrc]))
26 | getClassDirectories().setFrom(files([debugTree]))
27 | getExecutionData().setFrom(fileTree(dir: project.buildDir, includes: [
28 | 'jacoco/*.exec'
29 | ]))
30 | }
31 |
--------------------------------------------------------------------------------
/lifecyklelog-sample/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/lifecyklelog/src/main/java/com/chesire/lifecyklelog/LifecycleEvent.kt:
--------------------------------------------------------------------------------
1 | package com.chesire.lifecyklelog
2 |
3 | import android.app.Activity
4 | import androidx.fragment.app.Fragment
5 |
6 | /**
7 | * Contains a list of lifecycle events available on a [Fragment] or [Activity].
8 | * Use [eventName] to get its string representation.
9 | */
10 | enum class LifecycleEvent(val eventName: String) {
11 | ON_ATTACH("onAttach"),
12 | ON_CREATE("onCreate"),
13 | ON_CREATE_VIEW("onCreateView"),
14 | ON_ACTIVITY_CREATED("onActivityCreated"),
15 | ON_START("onStart"),
16 | ON_RESUME("onResume"),
17 |
18 | ON_PAUSE("onPause"),
19 | ON_STOP("onStop"),
20 | ON_DESTROY_VIEW("onDestroyView"),
21 | ON_DESTROY("onDestroy"),
22 | ON_DETACH("onDetach"),
23 |
24 | ON_PRE_ATTACHED("onPreAttached"),
25 | ON_PRE_CREATED("onPreCreated"),
26 | ON_SAVE_INSTANCE_STATE("onSaveInstanceState")
27 | }
28 |
--------------------------------------------------------------------------------
/lifecyklelog-sample/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
13 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/lifecyklelog/src/main/java/com/chesire/lifecyklelog/LogLifecykle.kt:
--------------------------------------------------------------------------------
1 | package com.chesire.lifecyklelog
2 |
3 | import android.app.Activity
4 | import androidx.fragment.app.Fragment
5 |
6 | /**
7 | * Annotation to put on an [Activity] or a [Fragment] that denotes its lifecycle methods should be
8 | * logged out.
9 | * If the [className] is provided, this is the name that will be used for this class,
10 | * use either the name of the class or something descriptive to see in the logs. If nothing is
11 | * provided then [LifecykleLog] will attempt to get it by inspecting the class.
12 | * By default all lifecycle methods that were provided in [LifecykleLog] will be logged out,
13 | * if [overrideLogEvents] is provided then only the methods provided to it will be logged out.
14 | */
15 | @MustBeDocumented
16 | @Retention
17 | @Target(AnnotationTarget.CLASS)
18 | annotation class LogLifecykle(
19 | val className: String = "",
20 | val overrideLogEvents: Array = []
21 | )
22 |
--------------------------------------------------------------------------------
/lifecyklelog-sample/src/main/java/com/chesire/lifecyklelogsample/ApplicationOverride.kt:
--------------------------------------------------------------------------------
1 | package com.chesire.lifecyklelogsample
2 |
3 | import android.app.Application
4 | import android.util.Log
5 | import com.chesire.lifecyklelog.LifecycleEvent
6 | import com.chesire.lifecyklelog.LifecykleLog
7 | import com.chesire.lifecyklelog.LogHandler
8 |
9 | /**
10 | * [Application] to show how to use [LifecykleLog].
11 | */
12 | @Suppress("unused")
13 | class ApplicationOverride : Application() {
14 | override fun onCreate() {
15 | super.onCreate()
16 |
17 | LifecykleLog.apply {
18 | initialize(this@ApplicationOverride)
19 | logEvents = arrayOf(
20 | LifecycleEvent.ON_CREATE,
21 | LifecycleEvent.ON_ATTACH,
22 | LifecycleEvent.ON_DESTROY
23 | )
24 | logHandler = LogHandler { clazz, lifecycleEvent, bundle ->
25 | Log.i(clazz, "$lifecycleEvent ${bundle?.let { "- $it" } ?: ""}")
26 | }
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/lifecyklelog/src/main/res/values/library_info.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Chesire
5 | https://github.com/Chesire
6 | LifecykleLog
7 | Library to easily log out Android lifecycle methods for Activities and Fragments.
8 | https://github.com/Chesire/LifecykleLog
9 | apache_2_0
10 | true
11 | https://github.com/Chesire/LifecykleLog
12 |
13 |
--------------------------------------------------------------------------------
/Dangerfile:
--------------------------------------------------------------------------------
1 | # Make it more obvious that a PR is a work in progress and shouldn't be merged yet
2 | warn("PR is classed as Work in Progress") if github.pr_title.include? "[WIP]"
3 |
4 | # Warn when there is a big PR
5 | warn("Big PR") if git.lines_of_code > 500
6 |
7 | # General
8 | failure "Please provide a summary in the Pull Request description" if github.pr_body.length < 5
9 | warn "This PR does not have any assignees yet." unless github.pr_json["assignee"]
10 | can_merge = github.pr_json["mergeable"]
11 | warn("This PR cannot be merged yet.", sticky: false) unless can_merge
12 | github.dismiss_out_of_range_messages
13 |
14 | # AndroidLint
15 | lint_dir = "**/reports/lint-results*.xml"
16 | Dir[lint_dir].each do |file_name|
17 | android_lint.skip_gradle_task = true
18 | android_lint.filtering = true
19 | android_lint.report_file = file_name
20 | android_lint.lint(inline_mode: true)
21 | end
22 |
23 | # CheckstyleFormat
24 | checkstyle_format.base_path = Dir.pwd
25 | checkstyle_format.report 'build/reports/detekt/detekt.xml'
26 |
27 | # JUnit
28 | junit_tests_dir = "**/test-results/**/*.xml"
29 | Dir[junit_tests_dir].each do |file_name|
30 | junit.parse file_name
31 | junit.show_skipped_tests = true
32 | junit.report
33 | end
--------------------------------------------------------------------------------
/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=-Xmx1536m
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 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | Change Log
2 | ==========
3 |
4 | ## Version 3.1.1
5 |
6 | _22-10-30_
7 |
8 | * chore: fix broken builds when using library
9 |
10 | ## Version 3.1.0
11 |
12 | _20-12-22_
13 |
14 | * feat: allow logging without annotation
15 | * Add new configuration option to enable logging for all activities/fragments, without the need
16 | for the annotation.
17 |
18 | ## Version 3.0.0
19 |
20 | _19-12-31_
21 |
22 | * __[Breaking change]__ feat: pass the bundle through the interface
23 | * The public API has been updated to also pass the bundle through it now, please see the README
24 | for more information.
25 | * refactor: update license type to apache 2.0
26 |
27 | ## Version 2.1.0
28 |
29 | _19-11-07_
30 |
31 | * feat: add information for about libraries support
32 | * LifecykleLog will now be added to the list of libraries used for applications making use
33 | of [AboutLibraries](https://github.com/mikepenz/AboutLibraries).
34 |
35 | ## Version 2.0.0
36 |
37 | _19-03-29_
38 |
39 | * refactor: change to configuration
40 | * Change from everything being configured in the `initialize` block, to be more configuration
41 | based using properties.
42 |
43 | ## Version 1.0.0
44 |
45 | _19-03-24_
46 |
47 | * Initial version.
48 |
--------------------------------------------------------------------------------
/lifecyklelog/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply from: '../jacoco.gradle'
4 |
5 | android {
6 | compileSdkVersion 31
7 | defaultConfig.minSdkVersion 14
8 |
9 | defaultConfig {
10 | resValue "string", "library_Lifecyklelog_libraryVersion", "${getVersionTag()}"
11 | }
12 | }
13 |
14 | dependencies {
15 | implementation 'androidx.appcompat:appcompat:1.4.1'
16 |
17 | testImplementation 'io.mockk:mockk:1.12.4'
18 | testImplementation 'junit:junit:4.13.2'
19 | }
20 |
21 | ext {
22 | bintrayRepo = 'LifecykleLog'
23 | bintrayName = 'lifecyklelog'
24 |
25 | libraryName = 'lifecyklelog'
26 |
27 | publishedGroupId = 'com.chesire'
28 | artifact = 'lifecyklelog'
29 | libraryVersion = '0.0.0'
30 |
31 | libraryDescription = 'Android library for logging out Activity and Fragment lifecycle methods.'
32 | siteUrl = 'https://chesire.github.io/LifecykleLog/'
33 | gitUrl = 'https://github.com/Chesire/LifecykleLog.git'
34 | developerId = 'chesire'
35 | developerName = 'chesire'
36 | developerEmail = 'troy.rijkaard@chesire.dev'
37 | ghRepo = 'chesire/LifecykleLog'
38 | ghReleaseNotesFile = 'README.md'
39 | licenseName = 'The Apache Software License, Version 2.0'
40 | licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
41 | allLicenses = ["Apache-2.0"]
42 | }
43 |
--------------------------------------------------------------------------------
/lifecyklelog-sample/src/main/java/com/chesire/lifecyklelogsample/JApplicationOverride.java:
--------------------------------------------------------------------------------
1 | package com.chesire.lifecyklelogsample;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.app.Application;
5 | import android.os.Bundle;
6 | import android.util.Log;
7 |
8 | import androidx.annotation.Nullable;
9 |
10 | import com.chesire.lifecyklelog.LifecycleEvent;
11 | import com.chesire.lifecyklelog.LifecykleLog;
12 | import com.chesire.lifecyklelog.LogHandler;
13 |
14 | import org.jetbrains.annotations.NotNull;
15 |
16 | /**
17 | * {@link Application} class to show how to use {@link LifecykleLog} in Java.
18 | */
19 | @SuppressLint("Registered")
20 | public class JApplicationOverride extends Application {
21 | @Override
22 | public void onCreate() {
23 | super.onCreate();
24 |
25 | LifecycleEvent[] events = {
26 | LifecycleEvent.ON_CREATE,
27 | LifecycleEvent.ON_ATTACH,
28 | LifecycleEvent.ON_DESTROY
29 | };
30 | LifecykleLog.INSTANCE.initialize(this);
31 | LifecykleLog.INSTANCE.setLogEvents(events);
32 | LifecykleLog.INSTANCE.setLogHandler(new LogHandler() {
33 | @Override
34 | public void logLifecycleMethod(@NotNull String clazz, @NotNull String lifecycleEvent, @Nullable Bundle bundle) {
35 | Log.i(clazz, lifecycleEvent);
36 | }
37 | });
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/lifecyklelog/src/main/java/com/chesire/lifecyklelog/events/ActivityEvents.kt:
--------------------------------------------------------------------------------
1 | package com.chesire.lifecyklelog.events
2 |
3 | import android.app.Activity
4 | import android.app.Application
5 | import android.os.Bundle
6 | import androidx.fragment.app.FragmentActivity
7 | import com.chesire.lifecyklelog.LifecycleEvent
8 | import com.chesire.lifecyklelog.LifecykleLog
9 |
10 | /**
11 | * Handles callbacks for all of the [Activity] lifecycle events.
12 | * When `onActivityCreated` is called, it will register for the fragment lifecycle events.
13 | */
14 | internal object ActivityEvents : Application.ActivityLifecycleCallbacks {
15 | override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
16 | LifecykleLog.logLifecycle(activity, LifecycleEvent.ON_CREATE, savedInstanceState)
17 | if (activity is FragmentActivity) {
18 | activity.supportFragmentManager.registerFragmentLifecycleCallbacks(
19 | FragmentEvents,
20 | true
21 | )
22 | }
23 | }
24 |
25 | override fun onActivityStarted(activity: Activity) {
26 | LifecykleLog.logLifecycle(activity, LifecycleEvent.ON_START)
27 | }
28 |
29 | override fun onActivityResumed(activity: Activity) {
30 | LifecykleLog.logLifecycle(activity, LifecycleEvent.ON_RESUME)
31 | }
32 |
33 | override fun onActivityPaused(activity: Activity) {
34 | LifecykleLog.logLifecycle(activity, LifecycleEvent.ON_PAUSE)
35 | }
36 |
37 | override fun onActivityStopped(activity: Activity) {
38 | LifecykleLog.logLifecycle(activity, LifecycleEvent.ON_STOP)
39 | }
40 |
41 | override fun onActivityDestroyed(activity: Activity) {
42 | LifecykleLog.logLifecycle(activity, LifecycleEvent.ON_DESTROY)
43 | }
44 |
45 | override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {
46 | LifecykleLog.logLifecycle(activity, LifecycleEvent.ON_SAVE_INSTANCE_STATE, outState)
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/lifecyklelog-sample/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/Gemfile.lock:
--------------------------------------------------------------------------------
1 | GEM
2 | remote: https://rubygems.org/
3 | specs:
4 | addressable (2.8.0)
5 | public_suffix (>= 2.0.2, < 5.0)
6 | ansi (1.5.0)
7 | ast (2.4.1)
8 | claide (1.0.3)
9 | claide-plugins (0.9.2)
10 | cork
11 | nap
12 | open4 (~> 1.3)
13 | colored2 (3.1.2)
14 | cork (0.3.0)
15 | colored2 (~> 3.1)
16 | danger (8.0.3)
17 | claide (~> 1.0)
18 | claide-plugins (>= 0.9.2)
19 | colored2 (~> 3.1)
20 | cork (~> 0.1)
21 | faraday (>= 0.9.0, < 2.0)
22 | faraday-http-cache (~> 2.0)
23 | git (~> 1.7)
24 | kramdown (~> 2.0)
25 | kramdown-parser-gfm (~> 1.0)
26 | no_proxy_fix
27 | octokit (~> 4.7)
28 | terminal-table (~> 1)
29 | danger-android_lint (0.0.8)
30 | danger-plugin-api (~> 1.0)
31 | oga
32 | danger-checkstyle_format (0.1.1)
33 | danger-plugin-api (~> 1.0)
34 | ox (~> 2.0)
35 | danger-junit (1.0.2)
36 | danger (> 2.0)
37 | ox (~> 2.0)
38 | danger-plugin-api (1.0.0)
39 | danger (> 2.0)
40 | faraday (1.0.1)
41 | multipart-post (>= 1.2, < 3)
42 | faraday-http-cache (2.2.0)
43 | faraday (>= 0.8)
44 | git (1.11.0)
45 | rchardet (~> 1.8)
46 | kramdown (2.3.1)
47 | rexml
48 | kramdown-parser-gfm (1.1.0)
49 | kramdown (~> 2.0)
50 | multipart-post (2.1.1)
51 | nap (1.1.0)
52 | no_proxy_fix (0.1.2)
53 | octokit (4.18.0)
54 | faraday (>= 0.9)
55 | sawyer (~> 0.8.0, >= 0.5.3)
56 | oga (3.2)
57 | ast
58 | ruby-ll (~> 2.1)
59 | open4 (1.3.4)
60 | ox (2.13.2)
61 | public_suffix (4.0.6)
62 | rchardet (1.8.0)
63 | rexml (3.2.5)
64 | ruby-ll (2.1.2)
65 | ansi
66 | ast
67 | sawyer (0.8.2)
68 | addressable (>= 2.3.5)
69 | faraday (> 0.8, < 2.0)
70 | terminal-table (1.8.0)
71 | unicode-display_width (~> 1.1, >= 1.1.1)
72 | unicode-display_width (1.7.0)
73 |
74 | PLATFORMS
75 | ruby
76 |
77 | DEPENDENCIES
78 | danger
79 | danger-android_lint
80 | danger-checkstyle_format
81 | danger-junit
82 |
83 | BUNDLED WITH
84 | 2.1.2
85 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/.github/workflows/android.yml:
--------------------------------------------------------------------------------
1 | name: Android CI
2 |
3 | on:
4 | push:
5 | branches: [ master ]
6 | pull_request:
7 | branches: [ master ]
8 | release:
9 | types: [ published ]
10 |
11 | jobs:
12 | test:
13 | runs-on: ubuntu-latest
14 | steps:
15 | - uses: actions/checkout@v3
16 | - name: set up JDK 11
17 | uses: actions/setup-java@v3
18 | with:
19 | distribution: 'adopt'
20 | java-version: 11
21 | - name: run testDebugUnitTest
22 | run: ./gradlew testDebugUnitTest
23 | - name: run jacocoTestReport
24 | run: ./gradlew jacocoTestReport
25 | - uses: codecov/codecov-action@v3
26 | - name: upload test results
27 | uses: actions/upload-artifact@v3
28 | with:
29 | name: tests
30 | path: lifecyklelog/build/reports/
31 | - name: upload test xml
32 | uses: actions/upload-artifact@v3
33 | with:
34 | name: test_xml
35 | path: lifecyklelog/build/test-results/
36 |
37 | analyze:
38 | runs-on: ubuntu-latest
39 | steps:
40 | - uses: actions/checkout@v3
41 | - name: set up JDK 11
42 | uses: actions/setup-java@v3
43 | with:
44 | distribution: 'adopt'
45 | java-version: 11
46 | - name: run ktlintCheck
47 | run: ./gradlew ktlintCheck
48 | - name: run lintDebug
49 | run: ./gradlew lintDebug
50 | - name: upload lint results
51 | uses: actions/upload-artifact@v3
52 | with:
53 | name: lint
54 | path: lifecyklelog/build/reports/
55 | - name: run detekt
56 | run: ./gradlew detekt
57 | - name: upload detekt results
58 | uses: actions/upload-artifact@v3
59 | with:
60 | name: detekt
61 | path: build/reports/
62 |
63 | danger:
64 | needs: [test, analyze]
65 | if: github.event_name == 'pull_request'
66 | runs-on: ubuntu-latest
67 | steps:
68 | - uses: actions/checkout@v3
69 | with:
70 | fetch-depth: 100
71 | - name: set up JDK 11
72 | uses: actions/setup-java@v3
73 | with:
74 | distribution: 'adopt'
75 | java-version: 11
76 | - uses: actions/setup-ruby@v1.1.3
77 | with:
78 | ruby-version: '2.6'
79 | - name: install bundler 2.1.2
80 | run: gem install bundler:2.1.2
81 | - uses: actions/cache@v3
82 | with:
83 | path: vendor/bundle
84 | key: ${{ runner.os }}-gems-${{ hashFiles('Gemfile') }}
85 | restore-keys: |
86 | ${{ runner.os }}-gems-
87 | - name: download lint results
88 | uses: actions/download-artifact@v3
89 | with:
90 | name: lint
91 | path: lifecyklelog/build/reports/
92 | - name: download detekt results
93 | uses: actions/download-artifact@v3
94 | with:
95 | name: detekt
96 | path: build/reports/
97 | - name: download test results
98 | uses: actions/download-artifact@v3
99 | with:
100 | name: test_xml
101 | path: lifecyklelog/build/test-results/
102 | - uses: MeilCli/danger-action@v5.5.5
103 | if: github.event_name == 'pull_request'
104 | with:
105 | plugins_file: 'Gemfile'
106 | install_path: 'vendor/bundle'
107 | danger_file: 'Dangerfile'
108 | danger_id: 'danger-ci'
109 | env:
110 | DANGER_GITHUB_API_TOKEN: ${{ secrets.DANGER_API_TOKEN }}
111 |
112 | deploy:
113 | needs: [test, analyze]
114 | if: github.event_name == 'release'
115 | runs-on: ubuntu-latest
116 | steps:
117 | - uses: actions/checkout@v3
118 | - name: set up JDK 11
119 | uses: actions/setup-java@v3
120 | with:
121 | distribution: 'adopt'
122 | java-version: 11
123 | - name: Fetch tags
124 | run: git fetch origin 'refs/tags/*:refs/tags/*'
125 | - name: run assemble
126 | run: ./gradlew assemble
127 | - name: Set env
128 | run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
129 | - name: Deploy
130 | run: ./gradlew deploy -PbintrayUser=${{ secrets.BINTRAY_USER_ID }} -PbintrayKey=${{ secrets.BINTRAY_API_KEY }} -PpublishVersion=$RELEASE_VERSION
131 |
--------------------------------------------------------------------------------
/lifecyklelog/src/main/java/com/chesire/lifecyklelog/events/FragmentEvents.kt:
--------------------------------------------------------------------------------
1 | package com.chesire.lifecyklelog.events
2 |
3 | import android.content.Context
4 | import android.os.Bundle
5 | import android.view.View
6 | import androidx.fragment.app.Fragment
7 | import androidx.fragment.app.FragmentManager
8 | import com.chesire.lifecyklelog.LifecycleEvent
9 | import com.chesire.lifecyklelog.LifecykleLog
10 |
11 | /**
12 | * Handles callbacks for all of the [Fragment] lifecycle events.
13 | */
14 | @Suppress("TooManyFunctions")
15 | internal object FragmentEvents : FragmentManager.FragmentLifecycleCallbacks() {
16 | override fun onFragmentAttached(fm: FragmentManager, f: Fragment, context: Context) {
17 | LifecykleLog.logLifecycle(f, LifecycleEvent.ON_ATTACH)
18 | super.onFragmentAttached(fm, f, context)
19 | }
20 |
21 | override fun onFragmentCreated(
22 | fm: FragmentManager,
23 | f: Fragment,
24 | savedInstanceState: Bundle?
25 | ) {
26 | LifecykleLog.logLifecycle(f, LifecycleEvent.ON_CREATE, savedInstanceState)
27 | super.onFragmentCreated(fm, f, savedInstanceState)
28 | }
29 |
30 | override fun onFragmentViewCreated(
31 | fm: FragmentManager,
32 | f: Fragment,
33 | v: View,
34 | savedInstanceState: Bundle?
35 | ) {
36 | LifecykleLog.logLifecycle(f, LifecycleEvent.ON_CREATE_VIEW, savedInstanceState)
37 | super.onFragmentViewCreated(fm, f, v, savedInstanceState)
38 | }
39 |
40 | override fun onFragmentActivityCreated(
41 | fm: FragmentManager,
42 | f: Fragment,
43 | savedInstanceState: Bundle?
44 | ) {
45 | LifecykleLog.logLifecycle(f, LifecycleEvent.ON_ACTIVITY_CREATED, savedInstanceState)
46 | super.onFragmentActivityCreated(fm, f, savedInstanceState)
47 | }
48 |
49 | override fun onFragmentStarted(fm: FragmentManager, f: Fragment) {
50 | LifecykleLog.logLifecycle(f, LifecycleEvent.ON_START)
51 | super.onFragmentStarted(fm, f)
52 | }
53 |
54 | override fun onFragmentResumed(fm: FragmentManager, f: Fragment) {
55 | LifecykleLog.logLifecycle(f, LifecycleEvent.ON_RESUME)
56 | super.onFragmentResumed(fm, f)
57 | }
58 |
59 | override fun onFragmentPaused(fm: FragmentManager, f: Fragment) {
60 | LifecykleLog.logLifecycle(f, LifecycleEvent.ON_PAUSE)
61 | super.onFragmentPaused(fm, f)
62 | }
63 |
64 | override fun onFragmentStopped(fm: FragmentManager, f: Fragment) {
65 | LifecykleLog.logLifecycle(f, LifecycleEvent.ON_STOP)
66 | super.onFragmentStopped(fm, f)
67 | }
68 |
69 | override fun onFragmentViewDestroyed(fm: FragmentManager, f: Fragment) {
70 | LifecykleLog.logLifecycle(f, LifecycleEvent.ON_DESTROY_VIEW)
71 | super.onFragmentViewDestroyed(fm, f)
72 | }
73 |
74 | override fun onFragmentDestroyed(fm: FragmentManager, f: Fragment) {
75 | LifecykleLog.logLifecycle(f, LifecycleEvent.ON_DESTROY)
76 | super.onFragmentDestroyed(fm, f)
77 | }
78 |
79 | override fun onFragmentDetached(fm: FragmentManager, f: Fragment) {
80 | LifecykleLog.logLifecycle(f, LifecycleEvent.ON_DETACH)
81 | super.onFragmentDetached(fm, f)
82 | }
83 |
84 | override fun onFragmentPreAttached(fm: FragmentManager, f: Fragment, context: Context) {
85 | LifecykleLog.logLifecycle(f, LifecycleEvent.ON_PRE_ATTACHED)
86 | super.onFragmentPreAttached(fm, f, context)
87 | }
88 |
89 | override fun onFragmentPreCreated(
90 | fm: FragmentManager,
91 | f: Fragment,
92 | savedInstanceState: Bundle?
93 | ) {
94 | LifecykleLog.logLifecycle(f, LifecycleEvent.ON_PRE_CREATED, savedInstanceState)
95 | super.onFragmentPreCreated(fm, f, savedInstanceState)
96 | }
97 |
98 | override fun onFragmentSaveInstanceState(
99 | fm: FragmentManager,
100 | f: Fragment,
101 | outState: Bundle
102 | ) {
103 | LifecykleLog.logLifecycle(f, LifecycleEvent.ON_SAVE_INSTANCE_STATE, outState)
104 | super.onFragmentSaveInstanceState(fm, f, outState)
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/lifecyklelog/src/test/java/com/chesire/lifecyklelog/events/ActivityEventsTests.kt:
--------------------------------------------------------------------------------
1 | package com.chesire.lifecyklelog.events
2 |
3 | import android.app.Activity
4 | import android.os.Bundle
5 | import androidx.fragment.app.FragmentActivity
6 | import androidx.fragment.app.FragmentManager
7 | import com.chesire.lifecyklelog.LifecycleEvent
8 | import com.chesire.lifecyklelog.LifecykleLog
9 | import io.mockk.Runs
10 | import io.mockk.every
11 | import io.mockk.just
12 | import io.mockk.mockk
13 | import io.mockk.mockkObject
14 | import io.mockk.unmockkObject
15 | import io.mockk.verify
16 | import org.junit.After
17 | import org.junit.Before
18 | import org.junit.Test
19 |
20 | class ActivityEventsTests {
21 | @Before
22 | fun setup() = mockkObject(LifecykleLog)
23 |
24 | @After
25 | fun teardown() = unmockkObject(LifecykleLog)
26 |
27 | @Test
28 | fun `onActivityCreated sets up fragment lifecycle logging`() {
29 | val mockFragmentManager = mockk {
30 | every { registerFragmentLifecycleCallbacks(FragmentEvents, true) } just Runs
31 | }
32 | val mockActivity = mockk {
33 | every { supportFragmentManager } returns mockFragmentManager
34 | }
35 |
36 | ActivityEvents.onActivityCreated(mockActivity, null)
37 |
38 | verify { mockFragmentManager.registerFragmentLifecycleCallbacks(FragmentEvents, true) }
39 | }
40 |
41 | @Test
42 | fun `onActivityCreated logs the activity with ON_CREATE lifecycle event`() {
43 | val mockActivity = mockk()
44 |
45 | ActivityEvents.onActivityCreated(mockActivity, null)
46 |
47 | verify { LifecykleLog.logLifecycle(mockActivity, LifecycleEvent.ON_CREATE) }
48 | }
49 |
50 | @Test
51 | fun `onActivityCreated logs the activity with ON_CREATE lifecycle event and bundle`() {
52 | val mockBundle = mockk()
53 | val mockActivity = mockk()
54 |
55 | ActivityEvents.onActivityCreated(mockActivity, mockBundle)
56 |
57 | verify { LifecykleLog.logLifecycle(mockActivity, LifecycleEvent.ON_CREATE, mockBundle) }
58 | }
59 |
60 | @Test
61 | fun `onActivityStarted logs the activity with ON_START lifecycle event`() {
62 | val mockActivity = mockk()
63 |
64 | ActivityEvents.onActivityStarted(mockActivity)
65 |
66 | verify { LifecykleLog.logLifecycle(mockActivity, LifecycleEvent.ON_START) }
67 | }
68 |
69 | @Test
70 | fun `onActivityResumed logs the activity with ON_RESUME lifecycle event`() {
71 | val mockActivity = mockk()
72 |
73 | ActivityEvents.onActivityResumed(mockActivity)
74 |
75 | verify { LifecykleLog.logLifecycle(mockActivity, LifecycleEvent.ON_RESUME) }
76 | }
77 |
78 | @Test
79 | fun `onActivityPaused logs the activity with ON_PAUSE lifecycle event`() {
80 | val mockActivity = mockk()
81 |
82 | ActivityEvents.onActivityPaused(mockActivity)
83 |
84 | verify { LifecykleLog.logLifecycle(mockActivity, LifecycleEvent.ON_PAUSE) }
85 | }
86 |
87 | @Test
88 | fun `onActivityStopped logs the activity with ON_STOP lifecycle event`() {
89 | val mockActivity = mockk()
90 |
91 | ActivityEvents.onActivityStopped(mockActivity)
92 |
93 | verify { LifecykleLog.logLifecycle(mockActivity, LifecycleEvent.ON_STOP) }
94 | }
95 |
96 | @Test
97 | fun `onActivityDestroyed logs the activity with ON_DESTROY lifecycle event`() {
98 | val mockActivity = mockk()
99 |
100 | ActivityEvents.onActivityDestroyed(mockActivity)
101 |
102 | verify { LifecykleLog.logLifecycle(mockActivity, LifecycleEvent.ON_DESTROY) }
103 | }
104 |
105 | @Test
106 | fun `onActivitySaveInstanceState logs the activity with ON_SAVE_INSTANCE_STATE lifecycle event with bundle`() {
107 | val mockBundle = mockk()
108 | val mockActivity = mockk()
109 |
110 | ActivityEvents.onActivitySaveInstanceState(mockActivity, mockBundle)
111 |
112 | verify {
113 | LifecykleLog.logLifecycle(
114 | mockActivity,
115 | LifecycleEvent.ON_SAVE_INSTANCE_STATE,
116 | mockBundle
117 | )
118 | }
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/lifecyklelog/src/main/java/com/chesire/lifecyklelog/LifecykleLog.kt:
--------------------------------------------------------------------------------
1 | package com.chesire.lifecyklelog
2 |
3 | import android.app.Activity
4 | import android.app.Application
5 | import android.os.Bundle
6 | import android.util.Log
7 | import androidx.fragment.app.Fragment
8 | import com.chesire.lifecyklelog.LifecykleLog.initialize
9 | import com.chesire.lifecyklelog.events.ActivityEvents
10 |
11 | /**
12 | * A container to execute logging on Android lifecycle events.
13 | * To begin using this call [initialize] passing in the application class.
14 | */
15 | object LifecykleLog {
16 | private val annotationClass = LogLifecykle::class.java
17 |
18 | /**
19 | * An array of lifecycle events to provide logging for.
20 | * If not overridden then will use the defaults of [LifecycleEvent.ON_ATTACH],
21 | * [LifecycleEvent.ON_CREATE], [LifecycleEvent.ON_CREATE_VIEW],
22 | * [LifecycleEvent.ON_ACTIVITY_CREATED], [LifecycleEvent.ON_START],
23 | * [LifecycleEvent.ON_RESUME], [LifecycleEvent.ON_PAUSE], [LifecycleEvent.ON_STOP],
24 | * [LifecycleEvent.ON_DESTROY_VIEW], [LifecycleEvent.ON_DESTROY], & [LifecycleEvent.ON_DETACH].
25 | */
26 | var logEvents: Array = arrayOf(
27 | LifecycleEvent.ON_ATTACH,
28 | LifecycleEvent.ON_CREATE,
29 | LifecycleEvent.ON_CREATE_VIEW,
30 | LifecycleEvent.ON_ACTIVITY_CREATED,
31 | LifecycleEvent.ON_START,
32 | LifecycleEvent.ON_RESUME,
33 | LifecycleEvent.ON_PAUSE,
34 | LifecycleEvent.ON_STOP,
35 | LifecycleEvent.ON_DESTROY_VIEW,
36 | LifecycleEvent.ON_DESTROY,
37 | LifecycleEvent.ON_DETACH
38 | )
39 |
40 | /**
41 | * Callback to execute when a lifecycle is logged, override this to change how logging occurs.
42 | * If this is null then it will default to logging using `Log.d`.
43 | */
44 | var logHandler: LogHandler? = null
45 |
46 | /**
47 | * Sets a flag indicating if the annotation is required on an [Activity] or [Fragment] to log
48 | * the lifecycle events for them. Setting this to false will log out every lifecycle event in
49 | * [logEvents] for every [Activity] and [Fragment] in the application.
50 | * If not overridden then will use the default of true.
51 | */
52 | var requireAnnotation: Boolean = true
53 |
54 | /**
55 | * Initializes the [LifecykleLog] with the given [app].
56 | * Using [app] it will hook into all [Activity] life cycles, and from there the [Fragment]
57 | * life cycles.
58 | */
59 | fun initialize(app: Application) = app.registerActivityLifecycleCallbacks(ActivityEvents)
60 |
61 | /**
62 | * Checks if the [lifecycleEvent] should be logged, and if it should it will send it through the
63 | * provided [logHandler].
64 | */
65 | internal fun logLifecycle(
66 | clazz: T,
67 | lifecycleEvent: LifecycleEvent,
68 | bundle: Bundle? = null
69 | ) {
70 | val annotation = clazz::class.java.getAnnotation(annotationClass)
71 | val shouldExecuteLog = if (!requireAnnotation) {
72 | shouldLog(lifecycleEvent, emptyArray())
73 | } else if (annotation != null) {
74 | shouldLog(lifecycleEvent, annotation.overrideLogEvents)
75 | } else {
76 | false
77 | }
78 |
79 | if (shouldExecuteLog) {
80 | executeLog(
81 | getLogStatement(clazz, annotation),
82 | lifecycleEvent.eventName,
83 | bundle
84 | )
85 | }
86 | }
87 |
88 | private fun getLogStatement(clazz: T, annotation: LogLifecykle?): String {
89 | return if (annotation == null || annotation.className.isEmpty()) {
90 | clazz::class.java.simpleName
91 | } else {
92 | annotation.className
93 | }
94 | }
95 |
96 | @Suppress("ReturnCount")
97 | private fun shouldLog(
98 | lifecycleEvent: LifecycleEvent,
99 | overrideEvents: Array
100 | ): Boolean {
101 | if (overrideEvents.isNotEmpty()) {
102 | // Overridden the defaults, check if should perform logging
103 | if (!overrideEvents.contains(lifecycleEvent)) {
104 | // Don't perform logging as this lifecycle event is not wanted
105 | return false
106 | }
107 | } else {
108 | // Check the defaults
109 | if (!logEvents.contains(lifecycleEvent)) {
110 | // Defaults doesn't contain this event
111 | return false
112 | }
113 | }
114 |
115 | return true
116 | }
117 |
118 | private fun executeLog(statement: String, lifecycleEvent: String, bundle: Bundle?) {
119 | logHandler
120 | ?.logLifecycleMethod(statement, lifecycleEvent, bundle)
121 | ?: Log.d("Lifecykle", "$statement ⇀ $lifecycleEvent")
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | xmlns:android
38 |
39 | ^$
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | xmlns:.*
49 |
50 | ^$
51 |
52 |
53 | BY_NAME
54 |
55 |
56 |
57 |
58 |
59 |
60 | .*:id
61 |
62 | http://schemas.android.com/apk/res/android
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 | .*:name
72 |
73 | http://schemas.android.com/apk/res/android
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 | name
83 |
84 | ^$
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 | style
94 |
95 | ^$
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 | .*
105 |
106 | ^$
107 |
108 |
109 | BY_NAME
110 |
111 |
112 |
113 |
114 |
115 |
116 | .*
117 |
118 | http://schemas.android.com/apk/res/android
119 |
120 |
121 | ANDROID_ATTRIBUTE_ORDER
122 |
123 |
124 |
125 |
126 |
127 |
128 | .*
129 |
130 | .*
131 |
132 |
133 | BY_NAME
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # LifecykleLog
2 |
3 | > Library to easily log out Android lifecycle methods for Activities and Fragments.
4 |
5 | [](https://android-arsenal.com/details/1/7752)
6 | 
7 | [](https://codecov.io/gh/Chesire/LifecykleLog)
8 |
9 | ## Installation
10 |
11 | Gradle:
12 | Make sure you have JitPack as a source
13 | ```groovy
14 | maven { url 'https://jitpack.io' }
15 | ```
16 | add the following line to your `build.gradle`, with version being the latest tag.
17 |
18 | ```groovy
19 | implementation 'com.github.chesire:lifecyklelog:{version}'
20 | ```
21 |
22 | ## Usage example
23 |
24 | Initialize in your application class.
25 |
26 | ```kotlin
27 | class ApplicationOverride : Application() {
28 | override fun onCreate() {
29 | super.onCreate()
30 | LifecykleLog.initialize(this)
31 | }
32 | }
33 | ```
34 |
35 | Add the `@LogLifecykle` annotation to the Activity or Fragment that the
36 | lifecycle methods should be logged for.
37 |
38 | ```kotlin
39 | @LogLifecykle
40 | class MainActivity : AppCompatActivity() { ...
41 |
42 | @LogLifecykle
43 | class MainFragment : Fragment() { ...
44 | ```
45 |
46 | Then lifecycle events will be logged out in logcat.
47 |
48 | ```text
49 | D/Lifecykle: MainActivity ⇀ onStart
50 | D/Lifecykle: MainFragment ⇀ onAttach
51 | D/Lifecykle: MainFragment ⇀ onCreate
52 | D/Lifecykle: MainFragment ⇀ onCreateView
53 | D/Lifecykle: MainFragment ⇀ onActivityCreated
54 | D/Lifecykle: MainFragment ⇀ onStart
55 | D/Lifecykle: MainActivity ⇀ onResume
56 | D/Lifecykle: MainFragment ⇀ onResume
57 | D/Lifecykle: MainActivity ⇀ onPause
58 | D/Lifecykle: MainFragment ⇀ onPause
59 | D/Lifecykle: MainActivity ⇀ onStop
60 | D/Lifecykle: MainFragment ⇀ onStop
61 | ```
62 |
63 | ## Configuration
64 |
65 | ### Logging mechanism
66 |
67 | By default LogLifecykle will output to `Log.d` with a tag of `Lifecykle`, to
68 | override this behaviour pass an implementation into the
69 | `LifecykleLog.logHandler`.
70 |
71 | ```kotlin
72 | LifecykleLog.logHandler = LogHandler { clazz, lifecycleEvent, bundle ->
73 | Log.e(clazz, lifecycleEvent)
74 | }
75 | ```
76 |
77 | This can allow you to use other logging frameworks such as Timber.
78 |
79 | ```kotlin
80 | LifecykleLog.logHandler = LogHandler { clazz, lifecycleEvent, bundle ->
81 | Timber.i("$clazz -> $lifecycleEvent - $bundle")
82 | }
83 | ```
84 |
85 | For lifecycle methods which pass a bundle along, it will automatically be pushed
86 | through the LogHandler. In instances where there is no bundle, or it is empty,
87 | then the value will simply be "null".
88 |
89 | ### Lifecycle methods
90 |
91 | To customise which lifecycle methods are logged out, an array of the
92 | `LifecycleEvent` enum can be passed into `LifecykleLog.logEvents`, this can
93 | also be done with the `@LogLifecykle` annotation.
94 |
95 | ```kotlin
96 | LifecykleLog.logEvents = arrayOf(
97 | LifecycleEvent.ON_CREATE,
98 | LifecycleEvent.ON_DESTROY
99 | )
100 |
101 | @LogLifecykle(overrideLogEvents = [LifecycleEvent.ON_START])
102 | class MainActivity : AppCompatActivity() {
103 |
104 | @LogLifecykle(overrideLogEvents = [LifecycleEvent.ON_ACTIVITY_CREATED, LifecycleEvent.ON_ATTACH])
105 | class MainFragment : Fragment() {
106 | ```
107 |
108 | If `logEvents` is provided to the `LifecykleLog` then it will override the
109 | defaults.
110 | If `overrideLogEvents` is provided on the annotation, **only** the methods that
111 | are provided in this will be logged out.
112 |
113 | ### Class name
114 |
115 | To customise the class name that is logged out, a new name can be provided to
116 | the annotation.
117 |
118 | ```kotlin
119 | @LogLifecykle(className = "MainActivity")
120 | class MainActivity : AppCompatActivity() {
121 |
122 | @LogLifecykle(className = "MaybeMainFragment")
123 | class MainFragment : Fragment() {
124 | ```
125 |
126 | This can be useful if ProGuard strips out the class names and you really need to
127 | see them in the logs. By default the name will be pulled from the objects
128 | `class.java.simpleName`.
129 |
130 | ### Remove Annotation
131 |
132 | If you want to perform logging of *ALL* Activities and Fragments, without
133 | needing to add the annotation to them, then the configuration option
134 | `requireAnnotation` can be set to `false`.
135 |
136 | ```kotlin
137 | LifecykleLog.requireAnnotation = false
138 | ```
139 |
140 | This will ignore any annotations that are currently set, and perform logging for
141 | every Activity and Fragment on the lifecycle events defined in
142 | `LifecykleLog.logEvents`.
143 |
144 | _For more examples and usage, please refer to the
145 | [sample](https://github.com/Chesire/LifecykleLog/tree/master/lifecyklelog-sample)._
146 |
147 | ## Contributing
148 |
149 | Please read
150 | [CONTRIBUTING.md](https://github.com/Chesire/LifecykleLog/blob/master/CONTRIBUTING.md)
151 | for details on how to contribute.
152 |
153 | ## License
154 |
155 | Apache 2.0 - See
156 | [LICENSE](https://github.com/Chesire/LifecykleLog/blob/master/LICENSE) for more
157 | information.
158 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | # Created by https://www.gitignore.io/api/java,macos,kotlin,windows,android,androidstudio
3 | # Edit at https://www.gitignore.io/?templates=java,macos,kotlin,windows,android,androidstudio
4 |
5 | ### Android ###
6 | # Built application files
7 | *.apk
8 | *.ap_
9 | *.aab
10 |
11 | # Files for the ART/Dalvik VM
12 | *.dex
13 |
14 | # Java class files
15 | *.class
16 |
17 | # Generated files
18 | bin/
19 | gen/
20 | out/
21 |
22 | # Gradle files
23 | .gradle/
24 | build/
25 |
26 | # Local configuration file (sdk path, etc)
27 | local.properties
28 |
29 | # Proguard folder generated by Eclipse
30 | proguard/
31 |
32 | # Log Files
33 | *.log
34 |
35 | # Android Studio Navigation editor temp files
36 | .navigation/
37 |
38 | # Android Studio captures folder
39 | captures/
40 |
41 | # IntelliJ
42 | *.iml
43 | .idea/workspace.xml
44 | .idea/tasks.xml
45 | .idea/gradle.xml
46 | .idea/assetWizardSettings.xml
47 | .idea/dictionaries
48 | .idea/libraries
49 | .idea/caches
50 | .idea/deploymentTargetDropDown.xml
51 | .idea/jarRepositories.xml
52 | # Android Studio 3 in .gitignore file.
53 | .idea/caches/build_file_checksums.ser
54 | .idea/modules.xml
55 |
56 | # Keystore files
57 | # Uncomment the following lines if you do not want to check your keystore files in.
58 | #*.jks
59 | #*.keystore
60 |
61 | # External native build folder generated in Android Studio 2.2 and later
62 | .externalNativeBuild
63 |
64 | # Google Services (e.g. APIs or Firebase)
65 | # google-services.json
66 |
67 | # Freeline
68 | freeline.py
69 | freeline/
70 | freeline_project_description.json
71 |
72 | # fastlane
73 | fastlane/report.xml
74 | fastlane/Preview.html
75 | fastlane/screenshots
76 | fastlane/test_output
77 | fastlane/readme.md
78 |
79 | # Version control
80 | vcs.xml
81 |
82 | # lint
83 | lint/intermediates/
84 | lint/generated/
85 | lint/outputs/
86 | lint/tmp/
87 | # lint/reports/
88 |
89 | ### Android Patch ###
90 | gen-external-apklibs
91 | output.json
92 |
93 | ### AndroidStudio ###
94 | # Covers files to be ignored for android development using Android Studio.
95 |
96 | # Built application files
97 |
98 | # Files for the ART/Dalvik VM
99 |
100 | # Java class files
101 |
102 | # Generated files
103 |
104 | # Gradle files
105 | .gradle
106 |
107 | # Signing files
108 | .signing/
109 |
110 | # Local configuration file (sdk path, etc)
111 |
112 | # Proguard folder generated by Eclipse
113 |
114 | # Log Files
115 |
116 | # Android Studio
117 | /*/build/
118 | /*/local.properties
119 | /*/out
120 | /*/*/build
121 | /*/*/production
122 | *.ipr
123 | *~
124 | *.swp
125 |
126 | # Android Patch
127 |
128 | # External native build folder generated in Android Studio 2.2 and later
129 |
130 | # NDK
131 | obj/
132 |
133 | # IntelliJ IDEA
134 | *.iws
135 | /out/
136 |
137 | # User-specific configurations
138 | .idea/caches/
139 | .idea/libraries/
140 | .idea/shelf/
141 | .idea/.name
142 | .idea/compiler.xml
143 | .idea/copyright/profiles_settings.xml
144 | .idea/encodings.xml
145 | .idea/misc.xml
146 | .idea/scopes/scope_settings.xml
147 | .idea/vcs.xml
148 | .idea/jsLibraryMappings.xml
149 | .idea/datasources.xml
150 | .idea/dataSources.ids
151 | .idea/sqlDataSources.xml
152 | .idea/dynamic.xml
153 | .idea/uiDesigner.xml
154 |
155 | # OS-specific files
156 | .DS_Store
157 | .DS_Store?
158 | ._*
159 | .Spotlight-V100
160 | .Trashes
161 | ehthumbs.db
162 | Thumbs.db
163 |
164 | # Legacy Eclipse project files
165 | .classpath
166 | .project
167 | .cproject
168 | .settings/
169 |
170 | # Mobile Tools for Java (J2ME)
171 | .mtj.tmp/
172 |
173 | # Package Files #
174 | *.war
175 | *.ear
176 |
177 | # virtual machine crash logs (Reference: http://www.java.com/en/download/help/error_hotspot.xml)
178 | hs_err_pid*
179 |
180 | ## Plugin-specific files:
181 |
182 | # mpeltonen/sbt-idea plugin
183 | .idea_modules/
184 |
185 | # JIRA plugin
186 | atlassian-ide-plugin.xml
187 |
188 | # Mongo Explorer plugin
189 | .idea/mongoSettings.xml
190 |
191 | # Crashlytics plugin (for Android Studio and IntelliJ)
192 | com_crashlytics_export_strings.xml
193 | crashlytics.properties
194 | crashlytics-build.properties
195 | fabric.properties
196 |
197 | ### AndroidStudio Patch ###
198 |
199 | !/gradle/wrapper/gradle-wrapper.jar
200 |
201 | ### Java ###
202 | # Compiled class file
203 |
204 | # Log file
205 |
206 | # BlueJ files
207 | *.ctxt
208 |
209 | # Mobile Tools for Java (J2ME)
210 |
211 | # Package Files #
212 | *.jar
213 | *.nar
214 | *.zip
215 | *.tar.gz
216 | *.rar
217 |
218 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
219 |
220 | ### Kotlin ###
221 | # Compiled class file
222 |
223 | # Log file
224 |
225 | # BlueJ files
226 |
227 | # Mobile Tools for Java (J2ME)
228 |
229 | # Package Files #
230 |
231 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
232 |
233 | ### macOS ###
234 | # General
235 | .AppleDouble
236 | .LSOverride
237 |
238 | # Icon must end with two \r
239 | Icon
240 |
241 | # Thumbnails
242 |
243 | # Files that might appear in the root of a volume
244 | .DocumentRevisions-V100
245 | .fseventsd
246 | .TemporaryItems
247 | .VolumeIcon.icns
248 | .com.apple.timemachine.donotpresent
249 |
250 | # Directories potentially created on remote AFP share
251 | .AppleDB
252 | .AppleDesktop
253 | Network Trash Folder
254 | Temporary Items
255 | .apdisk
256 |
257 | ### Windows ###
258 | # Windows thumbnail cache files
259 | ehthumbs_vista.db
260 |
261 | # Dump file
262 | *.stackdump
263 |
264 | # Folder config file
265 | [Dd]esktop.ini
266 |
267 | # Recycle Bin used on file shares
268 | $RECYCLE.BIN/
269 |
270 | # Windows Installer files
271 | *.cab
272 | *.msi
273 | *.msix
274 | *.msm
275 | *.msp
276 |
277 | # Windows shortcuts
278 | *.lnk
279 |
280 | # End of https://www.gitignore.io/api/java,macos,kotlin,windows,android,androidstudio
--------------------------------------------------------------------------------
/lifecyklelog/src/test/java/com/chesire/lifecyklelog/LifecykleLogTests.kt:
--------------------------------------------------------------------------------
1 | package com.chesire.lifecyklelog
2 |
3 | import io.mockk.Runs
4 | import io.mockk.every
5 | import io.mockk.just
6 | import io.mockk.mockk
7 | import io.mockk.verify
8 | import org.junit.Before
9 | import org.junit.BeforeClass
10 | import org.junit.Test
11 |
12 | class LifecykleLogTests {
13 | companion object {
14 | private var logHandlerDefault: LogHandler? = null
15 | private lateinit var logEvents: Array
16 | private var requireAnnotation: Boolean = true
17 |
18 | @BeforeClass
19 | @JvmStatic
20 | fun getDefaults() {
21 | logHandlerDefault = LifecykleLog.logHandler
22 | logEvents = LifecykleLog.logEvents
23 | requireAnnotation = LifecykleLog.requireAnnotation
24 | }
25 | }
26 |
27 | @Before
28 | fun setup() {
29 | LifecykleLog.logHandler = logHandlerDefault
30 | LifecykleLog.logEvents = logEvents
31 | LifecykleLog.requireAnnotation = requireAnnotation
32 | }
33 |
34 | @Test
35 | fun `logLifecycle with no annotation and requireAnnotation doesn't execute on handler`() {
36 | val unannotatedClass = UnannotatedClass()
37 | val mockHandler = mockk()
38 | LifecykleLog.logHandler = mockHandler
39 |
40 | LifecykleLog.logLifecycle(unannotatedClass, LifecycleEvent.ON_ATTACH)
41 |
42 | verify(exactly = 0) { mockHandler.logLifecycleMethod(any(), any(), any()) }
43 | }
44 |
45 | @Test
46 | fun `logLifecycle with no annotation and !requireAnnotation executes on handler`() {
47 | val unannotatedClass = UnannotatedClass()
48 | val mockHandler = mockk {
49 | every { logLifecycleMethod(any(), any(), any()) } just Runs
50 | }
51 | LifecykleLog.logHandler = mockHandler
52 | LifecykleLog.requireAnnotation = false
53 |
54 | LifecykleLog.logLifecycle(unannotatedClass, LifecycleEvent.ON_ATTACH)
55 |
56 | verify(exactly = 1) {
57 | mockHandler.logLifecycleMethod(
58 | any(),
59 | LifecycleEvent.ON_ATTACH.eventName,
60 | any()
61 | )
62 | }
63 | }
64 |
65 | @Test
66 | fun `logLifecycle with unsupported default lifecycle event doesn't execute on handler`() {
67 | val annotatedClass = AnnotatedClass()
68 | val mockHandler = mockk()
69 | LifecykleLog.logHandler = mockHandler
70 |
71 | LifecykleLog.logLifecycle(annotatedClass, LifecycleEvent.ON_SAVE_INSTANCE_STATE)
72 |
73 | verify(exactly = 0) { mockHandler.logLifecycleMethod(any(), any(), any()) }
74 | }
75 |
76 | @Test
77 | fun `logLifecycle with overridden default logEvents only executes for that event`() {
78 | val annotatedClass = AnnotatedClass()
79 | val mockHandler = mockk {
80 | every { logLifecycleMethod(any(), any(), any()) } just Runs
81 | }
82 | LifecykleLog.logHandler = mockHandler
83 | LifecykleLog.logEvents = arrayOf(LifecycleEvent.ON_SAVE_INSTANCE_STATE)
84 |
85 | LifecykleLog.logLifecycle(annotatedClass, LifecycleEvent.ON_ATTACH)
86 | LifecykleLog.logLifecycle(annotatedClass, LifecycleEvent.ON_CREATE)
87 | LifecykleLog.logLifecycle(annotatedClass, LifecycleEvent.ON_SAVE_INSTANCE_STATE)
88 | LifecykleLog.logLifecycle(annotatedClass, LifecycleEvent.ON_DESTROY)
89 |
90 | verify(exactly = 1) { mockHandler.logLifecycleMethod(any(), any(), any()) }
91 | }
92 |
93 | @Test
94 | fun `logLifecycle with annotation overrideLogEvents only executes for that event`() {
95 | val annotatedClass = AnnotatedClassWithLifecycleOverride()
96 | val mockHandler = mockk {
97 | every { logLifecycleMethod(any(), any(), any()) } just Runs
98 | }
99 | LifecykleLog.logHandler = mockHandler
100 |
101 | LifecykleLog.logLifecycle(annotatedClass, LifecycleEvent.ON_ATTACH)
102 | LifecykleLog.logLifecycle(annotatedClass, LifecycleEvent.ON_CREATE)
103 | LifecykleLog.logLifecycle(annotatedClass, LifecycleEvent.ON_SAVE_INSTANCE_STATE)
104 | LifecykleLog.logLifecycle(annotatedClass, LifecycleEvent.ON_DESTROY)
105 |
106 | verify(exactly = 1) {
107 | mockHandler.logLifecycleMethod(
108 | any(),
109 | LifecycleEvent.ON_SAVE_INSTANCE_STATE.eventName,
110 | any()
111 | )
112 | }
113 | }
114 |
115 | @Test
116 | fun `logLifecycle with defaults and valid logEvent executes on handler`() {
117 | val annotatedClass = AnnotatedClass()
118 | val mockHandler = mockk {
119 | every { logLifecycleMethod(any(), any(), any()) } just Runs
120 | }
121 | LifecykleLog.logHandler = mockHandler
122 |
123 | LifecykleLog.logLifecycle(annotatedClass, LifecycleEvent.ON_ATTACH)
124 |
125 | verify(exactly = 1) {
126 | mockHandler.logLifecycleMethod(
127 | AnnotatedClass::class.java.simpleName,
128 | LifecycleEvent.ON_ATTACH.eventName,
129 | any()
130 | )
131 | }
132 | }
133 |
134 | @Test
135 | fun `logLifecycle with annotation name override, uses custom name`() {
136 | val annotatedClass = AnnotatedClassWithNameOverride()
137 | val mockHandler = mockk {
138 | every { logLifecycleMethod(any(), any(), any()) } just Runs
139 | }
140 | LifecykleLog.logHandler = mockHandler
141 |
142 | LifecykleLog.logLifecycle(annotatedClass, LifecycleEvent.ON_ATTACH)
143 |
144 | verify(exactly = 1) {
145 | mockHandler.logLifecycleMethod(
146 | "Overridden className",
147 | LifecycleEvent.ON_ATTACH.eventName,
148 | any()
149 | )
150 | }
151 | }
152 | }
153 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/lifecyklelog-sample/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 |
--------------------------------------------------------------------------------
/lifecyklelog/src/test/java/com/chesire/lifecyklelog/events/FragmentEventsTests.kt:
--------------------------------------------------------------------------------
1 | package com.chesire.lifecyklelog.events
2 |
3 | import android.os.Bundle
4 | import androidx.fragment.app.Fragment
5 | import com.chesire.lifecyklelog.LifecycleEvent
6 | import com.chesire.lifecyklelog.LifecykleLog
7 | import io.mockk.mockk
8 | import io.mockk.mockkObject
9 | import io.mockk.unmockkObject
10 | import io.mockk.verify
11 | import org.junit.After
12 | import org.junit.Before
13 | import org.junit.Test
14 |
15 | class FragmentEventsTests {
16 | @Before
17 | fun setup() = mockkObject(LifecykleLog)
18 |
19 | @After
20 | fun teardown() = unmockkObject(LifecykleLog)
21 |
22 | @Test
23 | fun `onFragmentAttached logs the fragment with ON_ATTACH lifecycle event`() {
24 | val mockFragment = mockk()
25 |
26 | FragmentEvents.onFragmentAttached(mockk(), mockFragment, mockk())
27 |
28 | verify { LifecykleLog.logLifecycle(mockFragment, LifecycleEvent.ON_ATTACH) }
29 | }
30 |
31 | @Test
32 | fun `onFragmentCreated logs the fragment with ON_CREATE lifecycle event`() {
33 | val mockFragment = mockk()
34 |
35 | FragmentEvents.onFragmentCreated(mockk(), mockFragment, null)
36 |
37 | verify { LifecykleLog.logLifecycle(mockFragment, LifecycleEvent.ON_CREATE) }
38 | }
39 |
40 | @Test
41 | fun `onFragmentCreated logs the fragment with ON_CREATE lifecycle event and bundle`() {
42 | val mockBundle = mockk()
43 | val mockFragment = mockk()
44 |
45 | FragmentEvents.onFragmentCreated(mockk(), mockFragment, mockBundle)
46 |
47 | verify { LifecykleLog.logLifecycle(mockFragment, LifecycleEvent.ON_CREATE, mockBundle) }
48 | }
49 |
50 | @Test
51 | fun `onFragmentViewCreated logs the fragment with ON_CREATE_VIEW lifecycle event`() {
52 | val mockFragment = mockk()
53 |
54 | FragmentEvents.onFragmentViewCreated(mockk(), mockFragment, mockk(), null)
55 |
56 | verify { LifecykleLog.logLifecycle(mockFragment, LifecycleEvent.ON_CREATE_VIEW) }
57 | }
58 |
59 | @Test
60 | fun `onFragmentViewCreated logs the fragment with ON_CREATE_VIEW lifecycle event and bundle`() {
61 | val mockBundle = mockk()
62 | val mockFragment = mockk()
63 |
64 | FragmentEvents.onFragmentViewCreated(mockk(), mockFragment, mockk(), mockBundle)
65 |
66 | verify {
67 | LifecykleLog.logLifecycle(
68 | mockFragment,
69 | LifecycleEvent.ON_CREATE_VIEW,
70 | mockBundle
71 | )
72 | }
73 | }
74 |
75 | @Test
76 | fun `onFragmentActivityCreated logs the fragment with ON_ACTIVITY_CREATED lifecycle event`() {
77 | val mockFragment = mockk()
78 |
79 | FragmentEvents.onFragmentActivityCreated(mockk(), mockFragment, null)
80 |
81 | verify { LifecykleLog.logLifecycle(mockFragment, LifecycleEvent.ON_ACTIVITY_CREATED) }
82 | }
83 |
84 | @Test
85 | fun `onFragmentActivityCreated logs the fragment with ON_ACTIVITY_CREATED lifecycle event and bundle`() {
86 | val mockBundle = mockk()
87 | val mockFragment = mockk()
88 |
89 | FragmentEvents.onFragmentActivityCreated(mockk(), mockFragment, mockBundle)
90 |
91 | verify {
92 | LifecykleLog.logLifecycle(
93 | mockFragment,
94 | LifecycleEvent.ON_ACTIVITY_CREATED,
95 | mockBundle
96 | )
97 | }
98 | }
99 |
100 | @Test
101 | fun `onFragmentStarted logs the fragment with ON_START lifecycle event`() {
102 | val mockFragment = mockk()
103 |
104 | FragmentEvents.onFragmentStarted(mockk(), mockFragment)
105 |
106 | verify { LifecykleLog.logLifecycle(mockFragment, LifecycleEvent.ON_START) }
107 | }
108 |
109 | @Test
110 | fun `onFragmentResumed logs the fragment with ON_RESUME lifecycle event`() {
111 | val mockFragment = mockk()
112 |
113 | FragmentEvents.onFragmentResumed(mockk(), mockFragment)
114 |
115 | verify { LifecykleLog.logLifecycle(mockFragment, LifecycleEvent.ON_RESUME) }
116 | }
117 |
118 | @Test
119 | fun `onFragmentPaused logs the fragment with ON_PAUSE lifecycle event`() {
120 | val mockFragment = mockk()
121 |
122 | FragmentEvents.onFragmentPaused(mockk(), mockFragment)
123 |
124 | verify { LifecykleLog.logLifecycle(mockFragment, LifecycleEvent.ON_PAUSE) }
125 | }
126 |
127 | @Test
128 | fun `onFragmentStopped logs the fragment with ON_STOP lifecycle event`() {
129 | val mockFragment = mockk()
130 |
131 | FragmentEvents.onFragmentStopped(mockk(), mockFragment)
132 |
133 | verify { LifecykleLog.logLifecycle(mockFragment, LifecycleEvent.ON_STOP) }
134 | }
135 |
136 | @Test
137 | fun `onFragmentViewDestroyed logs the fragment with ON_DESTROY_VIEW lifecycle event`() {
138 | val mockFragment = mockk()
139 |
140 | FragmentEvents.onFragmentViewDestroyed(mockk(), mockFragment)
141 |
142 | verify { LifecykleLog.logLifecycle(mockFragment, LifecycleEvent.ON_DESTROY_VIEW) }
143 | }
144 |
145 | @Test
146 | fun `onFragmentDestroyed logs the fragment with ON_DESTROY lifecycle event`() {
147 | val mockFragment = mockk()
148 |
149 | FragmentEvents.onFragmentDestroyed(mockk(), mockFragment)
150 |
151 | verify { LifecykleLog.logLifecycle(mockFragment, LifecycleEvent.ON_DESTROY) }
152 | }
153 |
154 | @Test
155 | fun `onFragmentDetached logs the fragment with ON_DETACH lifecycle event`() {
156 | val mockFragment = mockk()
157 |
158 | FragmentEvents.onFragmentDetached(mockk(), mockFragment)
159 |
160 | verify { LifecykleLog.logLifecycle(mockFragment, LifecycleEvent.ON_DETACH) }
161 | }
162 |
163 | @Test
164 | fun `onFragmentPreAttached logs the fragment with ON_PRE_ATTACHED lifecycle event`() {
165 | val mockFragment = mockk()
166 |
167 | FragmentEvents.onFragmentPreAttached(mockk(), mockFragment, mockk())
168 |
169 | verify { LifecykleLog.logLifecycle(mockFragment, LifecycleEvent.ON_PRE_ATTACHED) }
170 | }
171 |
172 | @Test
173 | fun `onFragmentPreCreated logs the fragment with ON_PRE_CREATED lifecycle event`() {
174 | val mockFragment = mockk()
175 |
176 | FragmentEvents.onFragmentPreCreated(mockk(), mockFragment, null)
177 |
178 | verify { LifecykleLog.logLifecycle(mockFragment, LifecycleEvent.ON_PRE_CREATED) }
179 | }
180 |
181 | @Test
182 | fun `onFragmentPreCreated logs the fragment with ON_PRE_CREATED lifecycle event and bundle`() {
183 | val mockBundle = mockk()
184 | val mockFragment = mockk()
185 |
186 | FragmentEvents.onFragmentPreCreated(mockk(), mockFragment, mockBundle)
187 |
188 | verify {
189 | LifecykleLog.logLifecycle(
190 | mockFragment,
191 | LifecycleEvent.ON_PRE_CREATED,
192 | mockBundle
193 | )
194 | }
195 | }
196 |
197 | @Test
198 | fun `onFragmentSaveInstanceState logs the fragment with ON_SAVE_INSTANCE_STATE lifecycle event and bundle`() {
199 | val mockBundle = mockk()
200 | val mockFragment = mockk()
201 |
202 | FragmentEvents.onFragmentSaveInstanceState(mockk(), mockFragment, mockBundle)
203 |
204 | verify {
205 | LifecykleLog.logLifecycle(
206 | mockFragment,
207 | LifecycleEvent.ON_SAVE_INSTANCE_STATE,
208 | mockBundle
209 | )
210 | }
211 | }
212 | }
213 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/detekt.yml:
--------------------------------------------------------------------------------
1 | build:
2 | maxIssues: 10
3 |
4 | processors:
5 | active: true
6 |
7 | console-reports:
8 | active: true
9 |
10 | comments:
11 | active: true
12 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
13 | AbsentOrWrongFileLicense:
14 | active: false
15 | CommentOverPrivateFunction:
16 | active: true
17 | CommentOverPrivateProperty:
18 | active: true
19 | EndOfSentenceFormat:
20 | active: true
21 | endOfSentenceFormat: ([.?!][ \t\n\r\f<])|([.?!]$)
22 | UndocumentedPublicClass:
23 | active: true
24 | searchInNestedClass: true
25 | searchInInnerClass: true
26 | searchInInnerObject: true
27 | searchInInnerInterface: true
28 | UndocumentedPublicFunction:
29 | active: true
30 |
31 | complexity:
32 | active: true
33 | ComplexCondition:
34 | active: true
35 | threshold: 4
36 | ComplexInterface:
37 | active: true
38 | threshold: 10
39 | includeStaticDeclarations: false
40 | ComplexMethod:
41 | active: true
42 | threshold: 10
43 | ignoreSingleWhenExpression: false
44 | ignoreSimpleWhenEntries: false
45 | LabeledExpression:
46 | active: false
47 | ignoredLabels: ""
48 | LargeClass:
49 | active: true
50 | threshold: 150
51 | LongMethod:
52 | active: true
53 | threshold: 30
54 | LongParameterList:
55 | active: true
56 | constructorThreshold: 6
57 | functionThreshold: 6
58 | ignoreDefaultParameters: false
59 | MethodOverloading:
60 | active: false
61 | threshold: 6
62 | NestedBlockDepth:
63 | active: true
64 | threshold: 4
65 | StringLiteralDuplication:
66 | active: true
67 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
68 | threshold: 3
69 | ignoreAnnotation: true
70 | excludeStringsWithLessThan5Characters: true
71 | ignoreStringsRegex: '$^'
72 | TooManyFunctions:
73 | active: true
74 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
75 | thresholdInFiles: 11
76 | thresholdInClasses: 11
77 | thresholdInInterfaces: 11
78 | thresholdInObjects: 11
79 | thresholdInEnums: 11
80 | ignoreDeprecated: false
81 | ignorePrivate: false
82 | ignoreOverridden: false
83 |
84 | coroutines:
85 | active: true
86 | GlobalCoroutineUsage:
87 | active: true
88 | RedundantSuspendModifier:
89 | active: true
90 |
91 | empty-blocks:
92 | active: true
93 | EmptyCatchBlock:
94 | active: true
95 | allowedExceptionNameRegex: "^(_|(ignore|expected).*)"
96 | EmptyClassBlock:
97 | active: true
98 | EmptyDefaultConstructor:
99 | active: true
100 | EmptyDoWhileBlock:
101 | active: true
102 | EmptyElseBlock:
103 | active: true
104 | EmptyFinallyBlock:
105 | active: true
106 | EmptyForBlock:
107 | active: true
108 | EmptyFunctionBlock:
109 | active: true
110 | ignoreOverridden: false
111 | EmptyIfBlock:
112 | active: true
113 | EmptyInitBlock:
114 | active: true
115 | EmptyKtFile:
116 | active: true
117 | EmptySecondaryConstructor:
118 | active: true
119 | EmptyTryBlock:
120 | active: true
121 | EmptyWhenBlock:
122 | active: true
123 | EmptyWhileBlock:
124 | active: true
125 |
126 | exceptions:
127 | active: true
128 | ExceptionRaisedInUnexpectedLocation:
129 | active: true
130 | methodNames: 'toString,hashCode,equals,finalize'
131 | InstanceOfCheckForException:
132 | active: true
133 | NotImplementedDeclaration:
134 | active: false
135 | PrintStackTrace:
136 | active: true
137 | RethrowCaughtException:
138 | active: true
139 | ReturnFromFinally:
140 | active: true
141 | SwallowedException:
142 | active: true
143 | ignoredExceptionTypes: 'InterruptedException,NumberFormatException,ParseException,MalformedURLException'
144 | ThrowingExceptionFromFinally:
145 | active: true
146 | ThrowingExceptionInMain:
147 | active: true
148 | ThrowingExceptionsWithoutMessageOrCause:
149 | active: true
150 | exceptions: 'IllegalArgumentException,IllegalStateException,IOException'
151 | ThrowingNewInstanceOfSameException:
152 | active: true
153 | TooGenericExceptionCaught:
154 | active: true
155 | exceptionNames:
156 | - ArrayIndexOutOfBoundsException
157 | - Error
158 | - Exception
159 | - IllegalMonitorStateException
160 | - NullPointerException
161 | - IndexOutOfBoundsException
162 | - RuntimeException
163 | - Throwable
164 | TooGenericExceptionThrown:
165 | active: true
166 | exceptionNames:
167 | - Error
168 | - Exception
169 | - Throwable
170 | - RuntimeException
171 |
172 | formatting:
173 | active: true
174 | android: true
175 | autoCorrect: false
176 | ChainWrapping:
177 | active: true
178 | autoCorrect: false
179 | CommentSpacing:
180 | active: true
181 | autoCorrect: false
182 | Filename:
183 | active: true
184 | FinalNewline:
185 | active: true
186 | autoCorrect: false
187 | ImportOrdering:
188 | active: true
189 | autoCorrect: false
190 | Indentation:
191 | active: true
192 | autoCorrect: false
193 | indentSize: 4
194 | continuationIndentSize: 4
195 | MaximumLineLength:
196 | active: true
197 | maxLineLength: 120
198 | ModifierOrdering:
199 | active: true
200 | autoCorrect: false
201 | NoBlankLineBeforeRbrace:
202 | active: true
203 | autoCorrect: false
204 | NoConsecutiveBlankLines:
205 | active: true
206 | autoCorrect: false
207 | NoEmptyClassBody:
208 | active: true
209 | autoCorrect: false
210 | NoLineBreakAfterElse:
211 | active: true
212 | autoCorrect: false
213 | NoLineBreakBeforeAssignment:
214 | active: true
215 | autoCorrect: false
216 | NoMultipleSpaces:
217 | active: true
218 | autoCorrect: false
219 | NoSemicolons:
220 | active: true
221 | autoCorrect: false
222 | NoTrailingSpaces:
223 | active: true
224 | autoCorrect: false
225 | NoUnitReturn:
226 | active: true
227 | autoCorrect: false
228 | NoUnusedImports:
229 | active: true
230 | autoCorrect: false
231 | NoWildcardImports:
232 | active: true
233 | autoCorrect: false
234 | ParameterListWrapping:
235 | active: true
236 | autoCorrect: false
237 | indentSize: 4
238 | SpacingAroundColon:
239 | active: true
240 | autoCorrect: false
241 | SpacingAroundComma:
242 | active: true
243 | autoCorrect: false
244 | SpacingAroundCurly:
245 | active: true
246 | autoCorrect: false
247 | SpacingAroundKeyword:
248 | active: true
249 | autoCorrect: false
250 | SpacingAroundOperators:
251 | active: true
252 | autoCorrect: false
253 | SpacingAroundParens:
254 | active: true
255 | autoCorrect: false
256 | SpacingAroundRangeOperator:
257 | active: true
258 | autoCorrect: false
259 | StringTemplate:
260 | active: true
261 | autoCorrect: false
262 |
263 | naming:
264 | active: true
265 | ClassNaming:
266 | active: true
267 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
268 | classPattern: '[A-Z$][a-zA-Z0-9$]*'
269 | ConstructorParameterNaming:
270 | active: true
271 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
272 | parameterPattern: '[a-z][A-Za-z0-9]*'
273 | privateParameterPattern: '[a-z][A-Za-z0-9]*'
274 | excludeClassPattern: '$^'
275 | EnumNaming:
276 | active: true
277 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
278 | enumEntryPattern: '^[A-Z][_a-zA-Z0-9]*'
279 | ForbiddenClassName:
280 | active: true
281 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
282 | forbiddenName: ''
283 | FunctionMaxLength:
284 | active: true
285 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
286 | maximumFunctionNameLength: 30
287 | FunctionMinLength:
288 | active: true
289 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
290 | minimumFunctionNameLength: 3
291 | FunctionNaming:
292 | active: true
293 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
294 | functionPattern: '^([a-z$][a-zA-Z$0-9]*)|(`.*`)$'
295 | excludeClassPattern: '$^'
296 | ignoreOverridden: true
297 | FunctionParameterNaming:
298 | active: true
299 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
300 | parameterPattern: '[a-z][A-Za-z0-9]*'
301 | excludeClassPattern: '$^'
302 | ignoreOverridden: true
303 | InvalidPackageDeclaration:
304 | active: true
305 | rootPackage: ''
306 | MatchingDeclarationName:
307 | active: true
308 | MemberNameEqualsClassName:
309 | active: false
310 | ignoreOverridden: true
311 | ObjectPropertyNaming:
312 | active: true
313 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
314 | constantPattern: '[A-Za-z][_A-Za-z0-9]*'
315 | propertyPattern: '[A-Za-z][_A-Za-z0-9]*'
316 | privatePropertyPattern: '(_)?[A-Za-z][_A-Za-z0-9]*'
317 | PackageNaming:
318 | active: true
319 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
320 | packagePattern: '^[a-z]+(\.[a-z][A-Za-z0-9]*)*$'
321 | TopLevelPropertyNaming:
322 | active: true
323 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
324 | constantPattern: '[A-Z][_A-Z0-9]*'
325 | propertyPattern: '[A-Za-z][_A-Za-z0-9]*'
326 | privatePropertyPattern: '_?[A-Za-z][_A-Za-z0-9]*'
327 | VariableMaxLength:
328 | active: true
329 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
330 | maximumVariableNameLength: 64
331 | VariableMinLength:
332 | active: false
333 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
334 | minimumVariableNameLength: 1
335 | VariableNaming:
336 | active: true
337 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
338 | variablePattern: '[a-z][A-Za-z0-9]*'
339 | privateVariablePattern: '(_)?[a-z][A-Za-z0-9]*'
340 | excludeClassPattern: '$^'
341 | ignoreOverridden: true
342 |
343 | performance:
344 | active: true
345 | ArrayPrimitive:
346 | active: true
347 | ForEachOnRange:
348 | active: true
349 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
350 | SpreadOperator:
351 | active: true
352 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
353 | UnnecessaryTemporaryInstantiation:
354 | active: true
355 |
356 | potential-bugs:
357 | active: true
358 | DuplicateCaseInWhenExpression:
359 | active: true
360 | EqualsAlwaysReturnsTrueOrFalse:
361 | active: false
362 | EqualsWithHashCodeExist:
363 | active: true
364 | ExplicitGarbageCollectionCall:
365 | active: true
366 | IgnoredReturnValue:
367 | active: true
368 | ImplicitUnitReturnType:
369 | active: true
370 | InvalidRange:
371 | active: true
372 | IteratorHasNextCallsNextMethod:
373 | active: true
374 | IteratorNotThrowingNoSuchElementException:
375 | active: true
376 | LateinitUsage:
377 | active: false
378 | excludeAnnotatedProperties: ""
379 | ignoreOnClassesPattern: ""
380 | MapGetWithNotNullAssertionOperator:
381 | active: true
382 | MissingWhenCase:
383 | active: true
384 | UnconditionalJumpStatementInLoop:
385 | active: true
386 | UnnecessaryNotNullOperator:
387 | active: true
388 | UnnecessarySafeCall:
389 | active: true
390 | UnreachableCode:
391 | active: true
392 | UnsafeCallOnNullableType:
393 | active: true
394 | UnsafeCast:
395 | active: true
396 | UselessPostfixExpression:
397 | active: true
398 | WrongEqualsTypeParameter:
399 | active: true
400 |
401 | style:
402 | active: true
403 | CollapsibleIfStatements:
404 | active: true
405 | DataClassContainsFunctions:
406 | active: false
407 | conversionFunctionPrefix: 'to'
408 | DataClassShouldBeImmutable:
409 | active: false
410 | EqualsNullCall:
411 | active: true
412 | EqualsOnSignatureLine:
413 | active: true
414 | ExplicitCollectionElementAccessMethod:
415 | active: true
416 | ExplicitItLambdaParameter:
417 | active: true
418 | ExpressionBodySyntax:
419 | active: true
420 | includeLineWrapping: false
421 | ForbiddenComment:
422 | active: false
423 | values: 'FIXME:,STOPSHIP:'
424 | ForbiddenImport:
425 | active: true
426 | imports: ''
427 | ForbiddenMethodCall:
428 | active: false
429 | methods: ''
430 | ForbiddenPublicDataClass:
431 | active: false
432 | ignorePackages: '*.internal,*.internal.*'
433 | ForbiddenVoid:
434 | active: true
435 | ignoreOverridden: false
436 | FunctionOnlyReturningConstant:
437 | active: true
438 | ignoreOverridableFunction: true
439 | excludedFunctions: 'describeContents'
440 | LoopWithTooManyJumpStatements:
441 | active: true
442 | maxJumpCount: 1
443 | MagicNumber:
444 | active: false
445 | ignoreNumbers: '-1,0,1,2'
446 | ignoreHashCodeFunction: true
447 | ignorePropertyDeclaration: false
448 | ignoreConstantDeclaration: true
449 | ignoreCompanionObjectPropertyDeclaration: true
450 | ignoreAnnotation: false
451 | ignoreNamedArgument: true
452 | ignoreEnums: false
453 | ignoreRanges: false
454 | MandatoryBracesIfStatements:
455 | active: true
456 | MandatoryBracesLoops:
457 | active: true
458 | MaxLineLength:
459 | active: true
460 | maxLineLength: 120
461 | excludePackageStatements: true
462 | excludeImportStatements: true
463 | excludeCommentStatements: false
464 | MayBeConst:
465 | active: true
466 | ModifierOrder:
467 | active: true
468 | NestedClassesVisibility:
469 | active: true
470 | NewLineAtEndOfFile:
471 | active: true
472 | NoTabs:
473 | active: true
474 | OptionalAbstractKeyword:
475 | active: true
476 | OptionalUnit:
477 | active: true
478 | OptionalWhenBraces:
479 | active: true
480 | PreferToOverPairSyntax:
481 | active: true
482 | ProtectedMemberInFinalClass:
483 | active: true
484 | RedundantVisibilityModifierRule:
485 | active: true
486 | ReturnCount:
487 | active: true
488 | max: 2
489 | excludedFunctions: "equals"
490 | excludeLabeled: false
491 | excludeReturnFromLambda: true
492 | SafeCast:
493 | active: true
494 | SerialVersionUIDInSerializableClass:
495 | active: true
496 | SpacingBetweenPackageAndImports:
497 | active: true
498 | ThrowsCount:
499 | active: true
500 | max: 2
501 | TrailingWhitespace:
502 | active: true
503 | UnderscoresInNumericLiterals:
504 | active: false
505 | acceptableDecimalLength: 5
506 | UnnecessaryAbstractClass:
507 | active: false
508 | excludeAnnotatedClasses: "dagger.Module"
509 | UnnecessaryAnnotationUseSiteTarget:
510 | active: true
511 | UnnecessaryApply:
512 | active: true
513 | UnnecessaryInheritance:
514 | active: true
515 | UnnecessaryLet:
516 | active: true
517 | UnnecessaryParentheses:
518 | active: true
519 | UntilInsteadOfRangeTo:
520 | active: true
521 | UnusedImports:
522 | active: true
523 | UnusedPrivateClass:
524 | active: true
525 | UnusedPrivateMember:
526 | active: true
527 | allowedNames: "(_|ignored|expected|serialVersionUID)"
528 | UseCheckOrError:
529 | active: true
530 | UseDataClass:
531 | active: true
532 | excludeAnnotatedClasses: ""
533 | UseRequire:
534 | active: true
535 | UselessCallOnNotNull:
536 | active: true
537 | UtilityClassWithPublicConstructor:
538 | active: true
539 | VarCouldBeVal:
540 | active: true
541 | WildcardImport:
542 | active: true
543 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
544 | excludeImports: 'java.util.*,kotlinx.android.synthetic.*'
545 |
--------------------------------------------------------------------------------