├── .github
├── contributing.md
└── workflows
│ ├── android.yml
│ └── style-check.yml
├── .gitignore
├── .idea
├── codeStyles
├── compiler.xml
├── inspectionProfiles
│ └── Project_Default.xml
├── jarRepositories.xml
└── misc.xml
├── .jitpack.yml
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── debug.keystore
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── haroldadmin
│ │ └── crashyapp
│ │ ├── MainActivity.kt
│ │ └── ui
│ │ ├── pages
│ │ └── HomePage.kt
│ │ └── theme
│ │ └── CrashyAppTheme.kt
│ └── res
│ ├── drawable
│ ├── ic_launcher_background.xml
│ └── ic_launcher_foreground.xml
│ ├── mipmap-anydpi-v26
│ ├── ic_launcher.xml
│ └── ic_launcher_round.xml
│ ├── mipmap-hdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-mdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ └── values
│ └── styles.xml
├── build.gradle
├── gradle.properties
├── gradle
├── libs.versions.toml
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── media
├── demo.gif
├── icon.sketch
├── repo-banner.png
├── screenshot-dark.png
├── screenshot-light.png
├── screenshot.jpeg
└── what-the-stack-icon.svg
├── settings.gradle
└── what-the-stack
├── .gitignore
├── build.gradle
├── consumer-rules.pro
├── proguard-rules.pro
└── src
├── main
├── AndroidManifest.xml
├── java
│ └── com
│ │ └── haroldadmin
│ │ └── whatthestack
│ │ ├── Annotations.kt
│ │ ├── Constants.kt
│ │ ├── ExceptionProcessor.kt
│ │ ├── StackoverflowUtils.kt
│ │ ├── WhatTheStackActivity.kt
│ │ ├── WhatTheStackExceptionHandler.kt
│ │ ├── WhatTheStackInitializer.kt
│ │ ├── WhatTheStackService.kt
│ │ └── ui
│ │ ├── components
│ │ ├── OutlinedIconButton.kt
│ │ └── OverlineLabel.kt
│ │ ├── pages
│ │ └── ExceptionPage.kt
│ │ ├── preview
│ │ └── SampleData.kt
│ │ └── theme
│ │ └── WhatTheStackTheme.kt
└── res
│ ├── drawable
│ ├── ic_baseline_refresh_24.xml
│ ├── ic_outline_content_copy_24.xml
│ ├── ic_outline_share_24.xml
│ └── ic_round_search_24.xml
│ └── values
│ ├── strings.xml
│ └── styles.xml
└── test
└── java
└── com
└── haroldadmin
└── whatthestack
├── ExceptionProcessingTest.kt
├── ExceptionWithRootCause.kt
├── StackoverflowUrlTest.kt
├── StringOutputStream.kt
└── StringOutputStreamTest.kt
/.github/contributing.md:
--------------------------------------------------------------------------------
1 | # Contribution Guidelines
2 |
3 | Please contribute to this repository if any of the following is true:
4 |
5 | - You want open source communities to be more collaborative and inclusive
6 | - You want to help lower the burden to first time contributors
7 | - You want to help make the project better with your contributions
8 |
9 | ## How to contribute
10 |
11 | Prerequisites:
12 |
13 | - Familiarity with the basics of native Android Development and the Kotlin programming language.
14 | - Familiarity with [pull requests](https://help.github.com/articles/using-pull-requests) and [issues](https://guides.github.com/features/issues/).
15 |
16 | ## Conduct
17 |
18 | We are committed to providing a friendly, safe and welcoming environment for
19 | all, regardless of gender, sexual orientation, disability, ethnicity, religion,
20 | or similar personal characteristic.
21 |
22 | Please be kind and courteous. There's no need to be mean or rude.
23 | Respect that people have differences of opinion and that every design or
24 | implementation choice carries a trade-off and numerous costs. There is seldom
25 | a right answer, merely an optimal answer given a set of values and
26 | circumstances.
27 |
28 | Please keep unstructured critique to a minimum. If you have solid ideas you
29 | want to experiment with, make a fork and see how it works.
30 |
31 | We will exclude you from interaction if you insult, demean or harass anyone.
32 | That is not welcome behaviour. We interpret the term "harassment" as
33 | including the definition in the
34 | [Citizen Code of Conduct](http://citizencodeofconduct.org/);
35 | if you have any lack of clarity about what might be included in that concept,
36 | please read their definition. In particular, we don't tolerate behavior that
37 | excludes people in socially marginalized groups. Private harassment is also unacceptable. Whether you're a regular contributor or a newcomer, we care about
38 | making this community a safe place for you and we've got your back.
39 |
40 | Likewise any spamming, trolling, flaming, baiting or other attention-stealing
41 | behaviour is not welcome.
42 |
--------------------------------------------------------------------------------
/.github/workflows/android.yml:
--------------------------------------------------------------------------------
1 | name: Android CI
2 |
3 | on: [push]
4 |
5 | jobs:
6 | build:
7 | runs-on: ubuntu-latest
8 | steps:
9 | - uses: actions/checkout@v1
10 |
11 | - name: set up JDK 11
12 | uses: actions/setup-java@v1
13 | with:
14 | java-version: 11
15 |
16 | - name: Build with Gradle
17 | run: ./gradlew build test
--------------------------------------------------------------------------------
/.github/workflows/style-check.yml:
--------------------------------------------------------------------------------
1 | name: Code-style checks
2 |
3 | on: [pull_request]
4 |
5 | jobs:
6 | build:
7 | runs-on: ubuntu-latest
8 | steps:
9 | - uses: actions/checkout@v1
10 |
11 | - name: set up JDK 11
12 | uses: actions/setup-java@v1
13 | with:
14 | java-version: 11
15 |
16 | - name: Ktlint check
17 | run: ./gradlew ktlintCheck
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 |
16 | # Built application files
17 | *.apk
18 | *.aar
19 | *.ap_
20 | *.aab
21 |
22 | # Files for the ART/Dalvik VM
23 | *.dex
24 |
25 | # Java class files
26 | *.class
27 |
28 | # Generated files
29 | bin/
30 | gen/
31 | out/
32 | # Uncomment the following line in case you need and you don't have the release build type files in your app
33 | # release/
34 |
35 | # Gradle files
36 | .gradle/
37 | build/
38 |
39 | # Local configuration file (sdk path, etc)
40 | local.properties
41 |
42 | # Proguard folder generated by Eclipse
43 | proguard/
44 |
45 | # Log Files
46 | *.log
47 |
48 | # Android Studio Navigation editor temp files
49 | .navigation/
50 |
51 | # Android Studio captures folder
52 | captures/
53 |
54 | # IntelliJ
55 | *.iml
56 | .idea/workspace.xml
57 | .idea/tasks.xml
58 | .idea/gradle.xml
59 | .idea/assetWizardSettings.xml
60 | .idea/dictionaries
61 | .idea/libraries
62 | # Android Studio 3 in .gitignore file.
63 | .idea/caches
64 | .idea/modules.xml
65 | # Comment next line if keeping position of elements in Navigation Editor is relevant for you
66 | .idea/navEditor.xml
67 |
68 | # Keystore files
69 | # Uncomment the following lines if you do not want to check your keystore files in.
70 | #*.jks
71 | #*.keystore
72 |
73 | # External native build folder generated in Android Studio 2.2 and later
74 | .externalNativeBuild
75 | .cxx/
76 |
77 | # Google Services (e.g. APIs or Firebase)
78 | # google-services.json
79 |
80 | # Freeline
81 | freeline.py
82 | freeline/
83 | freeline_project_description.json
84 |
85 | # fastlane
86 | fastlane/report.xml
87 | fastlane/Preview.html
88 | fastlane/screenshots
89 | fastlane/test_output
90 | fastlane/readme.md
91 |
92 | # Version control
93 | vcs.xml
94 |
95 | # lint
96 | lint/intermediates/
97 | lint/generated/
98 | lint/outputs/
99 | lint/tmp/
100 | # lint/reports/
101 |
102 | .project
--------------------------------------------------------------------------------
/.idea/codeStyles:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | xmlns:android
16 |
17 | ^$
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 | xmlns:.*
27 |
28 | ^$
29 |
30 |
31 | BY_NAME
32 |
33 |
34 |
35 |
36 |
37 |
38 | .*:id
39 |
40 | http://schemas.android.com/apk/res/android
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 | .*:name
50 |
51 | http://schemas.android.com/apk/res/android
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 | name
61 |
62 | ^$
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 | style
72 |
73 | ^$
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 | .*
83 |
84 | ^$
85 |
86 |
87 | BY_NAME
88 |
89 |
90 |
91 |
92 |
93 |
94 | .*
95 |
96 | http://schemas.android.com/apk/res/android
97 |
98 |
99 | ANDROID_ATTRIBUTE_ORDER
100 |
101 |
102 |
103 |
104 |
105 |
106 | .*
107 |
108 | .*
109 |
110 |
111 | BY_NAME
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/.idea/jarRepositories.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/.jitpack.yml:
--------------------------------------------------------------------------------
1 | jdk: openjdk11
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # WhatTheStack
2 |
3 | 
4 |
5 | WhatTheStack is a library to make your debugging experience on Android better.
6 |
7 | It shows you a pretty error screen when your Android App crashes, instead of a boring old dialog saying "Unfortunately, \ has crashed".
8 |
9 | 
10 |
11 | ## Setup
12 |
13 | [](https://jitpack.io/#haroldadmin/WhatTheStack)
14 |
15 | Add Jitpack repository in your root `build.gradle` file:
16 |
17 | ```groovy
18 | allprojects {
19 | repositories {
20 | maven { url 'https://jitpack.io' }
21 | }
22 | }
23 | ```
24 |
25 | And then add the dependency to your app:
26 |
27 | ```groovy
28 | dependencies {
29 | debugImplementation 'com.github.haroldadmin:WhatTheStack:(latest-version)'
30 | }
31 | ```
32 |
33 | Now when an uncaught exception is thrown in your application, you will be greeted with a screen containing information about the crash. We support light and dark themes too!
34 |
35 |
36 |
37 |
38 | ## Usage
39 |
40 | WhatTheStack works by overriding the default exception handler in your app. It processes any uncaught exception in your app, parses it to extract useful information, and then shows it in a pretty screen.
41 |
42 | ### Automatic Initialization
43 |
44 | WhatTheStack uses the [Jetpack App Startup](https://developer.android.com/topic/libraries/app-startup) library to run automatically when your app starts. You don't need to write any code to initialize it manually.
45 |
46 |
47 | Need to disable automatic initialization?
48 | If you want to disable automatic startup, add the following lines to your Manifest file:
49 |
50 | ```xml
51 |
56 |
59 |
60 | ```
61 |
62 |
63 | ### Debug vs Release builds
64 |
65 | We recommend using `WhatTheStack` in debug builds only. We see it as a tool to improve the experience of the developer, not the user.
66 |
67 |
68 | Need to use it in release builds?
69 | If you want to use WhatTheStack in release builds, replace the `debugImplementation` dependency with `implementation'.
70 |
71 | ```diff
72 | dependencies {
73 | - debugImplementation 'com.github.haroldadmin:WhatTheStack:(latest-version)'
74 | + implementation 'com.github.haroldadmin:WhatTheStack:(latest-version)'
75 | }'
76 | ```
77 |
78 | The library ships with Proguard rules to ensure that it works correctly even after minification.
79 |
80 |
81 | ### Multi-Process Service
82 |
83 | `WhatTheStack` runs a bound service in a separate process to show you the error screen on a crash.
84 |
85 | We need to run this code in a separate process because you can't reliably launch new Activities
86 | in the host application's process after an uncaught exception is thrown.
87 |
88 |
89 |
90 | ## Contributions
91 |
92 | We are happy to accept any external contributions in the form of PRs, issues, or blog posts.
93 |
94 | Please consider starring the repository if you find it useful or intriguing!
95 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 |
4 | android {
5 | compileSdkVersion buildConfig.compileSdk
6 |
7 | defaultConfig {
8 | minSdkVersion buildConfig.minSdk
9 | targetSdkVersion buildConfig.targetSdk
10 | versionCode buildConfig.versionCode
11 | versionName buildConfig.versionName
12 | applicationId buildConfig.applicationId
13 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
14 | consumerProguardFiles 'consumer-rules.pro'
15 | }
16 |
17 | signingConfigs {
18 | debug {
19 | storeFile file('debug.keystore')
20 | storePassword 'whatthestack'
21 | keyAlias 'whatthestack'
22 | keyPassword 'whatthestack'
23 | }
24 | }
25 |
26 | buildTypes {
27 | release {
28 | signingConfig signingConfigs.debug
29 | minifyEnabled true
30 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
31 | }
32 | }
33 |
34 | compileOptions {
35 | sourceCompatibility 1.8
36 | targetCompatibility 1.8
37 | }
38 |
39 | kotlinOptions {
40 | jvmTarget = "1.8"
41 | }
42 |
43 | buildFeatures {
44 | compose true
45 | }
46 |
47 | composeOptions {
48 | kotlinCompilerExtensionVersion "1.0.5"
49 | }
50 | }
51 |
52 | dependencies {
53 | implementation fileTree(dir: 'libs', include: ['*.jar'])
54 |
55 | debugImplementation project(path: ":what-the-stack")
56 |
57 | implementation libs.kotlinStdLib
58 | implementation libs.appCompat
59 | implementation libs.coreKtx
60 |
61 | implementation libs.composeActivity
62 | implementation libs.composeMaterial
63 | implementation libs.composeTooling
64 | implementation libs.accompanistSysUi
65 | implementation libs.accompanistInsets
66 |
67 | testImplementation libs.junit
68 |
69 | androidTestImplementation libs.androidxTestCore
70 | androidTestImplementation libs.androidxTestExt
71 | androidTestImplementation libs.espressoCore
72 | }
--------------------------------------------------------------------------------
/app/debug.keystore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haroldadmin/WhatTheStack/dbe12fec2c3dcd039ed6833ae500ad95a7752324/app/debug.keystore
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/java/com/haroldadmin/crashyapp/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.haroldadmin.crashyapp
2 |
3 | import android.os.Bundle
4 | import androidx.activity.compose.setContent
5 | import androidx.appcompat.app.AppCompatActivity
6 | import com.haroldadmin.crashyapp.ui.pages.HomePage
7 | import com.haroldadmin.crashyapp.ui.theme.CrashyAppTheme
8 |
9 | class MainActivity : AppCompatActivity() {
10 |
11 | override fun onCreate(savedInstanceState: Bundle?) {
12 | super.onCreate(savedInstanceState)
13 | setContent {
14 | CrashyAppTheme {
15 | HomePage()
16 | }
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/app/src/main/java/com/haroldadmin/crashyapp/ui/pages/HomePage.kt:
--------------------------------------------------------------------------------
1 | package com.haroldadmin.crashyapp.ui.pages
2 |
3 | import androidx.compose.foundation.layout.*
4 | import androidx.compose.material.*
5 | import androidx.compose.runtime.Composable
6 | import androidx.compose.ui.Alignment
7 | import androidx.compose.ui.Modifier
8 | import androidx.compose.ui.text.style.TextAlign
9 | import androidx.compose.ui.unit.dp
10 |
11 | @Composable
12 | fun HomePage() {
13 | Scaffold(
14 | topBar = {
15 | TopAppBar {
16 | Text(text = "Crashy App", style = MaterialTheme.typography.h6)
17 | }
18 | }
19 | ) {
20 | Column(
21 | horizontalAlignment = Alignment.CenterHorizontally,
22 | verticalArrangement = Arrangement.Center,
23 | modifier = Modifier
24 | .padding(8.dp)
25 | .fillMaxWidth()
26 | .fillMaxHeight()
27 | ) {
28 | Text(
29 | text = "Press the button to see the error screen from WhatTheStack!",
30 | textAlign = TextAlign.Center
31 | )
32 | Spacer(modifier = Modifier.height(16.dp))
33 | Button(onClick = { throw BecauseICanException() }) {
34 | Text(text = "Crash!")
35 | }
36 | }
37 | }
38 | }
39 |
40 | private class BecauseICanException :
41 | Exception("This exception is thrown purely because it can be thrown")
42 |
--------------------------------------------------------------------------------
/app/src/main/java/com/haroldadmin/crashyapp/ui/theme/CrashyAppTheme.kt:
--------------------------------------------------------------------------------
1 | package com.haroldadmin.crashyapp.ui.theme
2 |
3 | import androidx.compose.material.MaterialTheme
4 | import androidx.compose.material.lightColors
5 | import androidx.compose.runtime.Composable
6 | import androidx.compose.ui.graphics.Color
7 |
8 | private val ColorPalette = lightColors(
9 | primary = Color(0xffd32f2f),
10 | primaryVariant = Color(0xff9a0007),
11 | secondary = Color(0xff616161),
12 | secondaryVariant = Color(0x33373737),
13 | )
14 |
15 | @Composable
16 | fun CrashyAppTheme(
17 | content: @Composable () -> Unit
18 | ) {
19 | MaterialTheme(colors = ColorPalette, content = content)
20 | }
21 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
6 |
8 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
6 |
10 |
18 |
25 |
31 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haroldadmin/WhatTheStack/dbe12fec2c3dcd039ed6833ae500ad95a7752324/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haroldadmin/WhatTheStack/dbe12fec2c3dcd039ed6833ae500ad95a7752324/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haroldadmin/WhatTheStack/dbe12fec2c3dcd039ed6833ae500ad95a7752324/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haroldadmin/WhatTheStack/dbe12fec2c3dcd039ed6833ae500ad95a7752324/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haroldadmin/WhatTheStack/dbe12fec2c3dcd039ed6833ae500ad95a7752324/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haroldadmin/WhatTheStack/dbe12fec2c3dcd039ed6833ae500ad95a7752324/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haroldadmin/WhatTheStack/dbe12fec2c3dcd039ed6833ae500ad95a7752324/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haroldadmin/WhatTheStack/dbe12fec2c3dcd039ed6833ae500ad95a7752324/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haroldadmin/WhatTheStack/dbe12fec2c3dcd039ed6833ae500ad95a7752324/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haroldadmin/WhatTheStack/dbe12fec2c3dcd039ed6833ae500ad95a7752324/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext.buildConfig = [
3 | "applicationId": "com.haroldadmin.crashyapp",
4 | "compileSdk" : 31,
5 | "minSdk" : 21,
6 | "targetSdk" : 31,
7 | "versionCode" : 1,
8 | "versionName" : "0.0.1"
9 | ]
10 |
11 | repositories {
12 | mavenCentral()
13 | google()
14 | maven {
15 | url "https://plugins.gradle.org/m2/"
16 | }
17 | }
18 |
19 | dependencies {
20 | classpath libs.agp
21 | classpath libs.kotlinGradlePlugin
22 | classpath libs.ktlintGradlePlugin
23 | }
24 | }
25 |
26 | allprojects {
27 | repositories {
28 | mavenCentral()
29 | google()
30 | }
31 | }
32 |
33 | subprojects {
34 | apply plugin: "org.jlleitschuh.gradle.ktlint"
35 | ktlint {
36 | version = "0.43.0"
37 | ignoreFailures = false
38 | disabledRules = ["no-wildcard-imports"]
39 | }
40 | }
41 |
42 | task clean(type: Delete) {
43 | delete rootProject.buildDir
44 | }
45 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/gradle/libs.versions.toml:
--------------------------------------------------------------------------------
1 | [versions]
2 | kotlin = "1.5.31"
3 | agp = "7.0.3"
4 | ktlint = "10.1.0"
5 | appCompat = "1.3.0"
6 | coreTest = "2.0.0"
7 | coreKtx = "1.3.2"
8 | materialComponents = "1.4.0"
9 | fragment = "1.3.5"
10 | constraintLayout = "2.0.4"
11 | insetter = "0.6.0"
12 | junit = "4.12"
13 | androidxTestCore = "1.2.0"
14 | androidxTestExt = "1.1.1"
15 | androidxTestRunner = "1.2.0"
16 | espressoCore = "3.2.0"
17 | mockk = "1.9.3"
18 | robolectric = "4.3.1"
19 | startup = "1.0.0"
20 | composeActivity = "1.3.1"
21 | compose = "1.0.5"
22 | accompanist = "0.21.3-beta"
23 |
24 | [libraries]
25 |
26 | composeActivity = { module = "androidx.activity:activity-compose", version.ref = "composeActivity" }
27 | composeMaterial = { module = "androidx.compose.material:material", version.ref = "compose" }
28 | composeTooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" }
29 | accompanistSysUi = { module = "com.google.accompanist:accompanist-systemuicontroller", version.ref = "accompanist" }
30 | accompanistInsets = { module = "com.google.accompanist:accompanist-insets", version.ref = "accompanist" }
31 | agp = { module = "com.android.tools.build:gradle", version.ref = "agp" }
32 | kotlinGradlePlugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
33 | ktlintGradlePlugin = { module = "org.jlleitschuh.gradle:ktlint-gradle", version.ref = "ktlint" }
34 | kotlinStdLib = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" }
35 | appCompat = { module = "androidx.appcompat:appcompat", version.ref = "appCompat" }
36 | coreTest = { module = "androidx.arch.core:core-testing", version.ref = "coreTest" }
37 | coreKtx = { module = "androidx.core:core-ktx", version.ref = "coreKtx" }
38 | materialComponents = { module = "com.google.android.material:material", version.ref = "materialComponents" }
39 | constraintLayout = { module = "androidx.constraintlayout:constraintlayout", version.ref = "constraintLayout" }
40 | fragmentKtx = { module = "androidx.fragment:fragment-ktx", version.ref = "fragment" }
41 | startup = { module = "androidx.startup:startup-runtime", version.ref = "startup" }
42 | insetter = { module = "dev.chrisbanes.insetter:insetter", version.ref = "insetter" }
43 | junit = { module = "junit:junit", version.ref = "junit" }
44 | androidxTestCore = { module = "androidx.test:core", version.ref = "androidxTestCore" }
45 | androidxTestExt = { module = "androidx.test.ext:junit", version.ref = "androidxTestExt" }
46 | androidxTestRunner = { module = "androidx.test:runner", version.ref = "androidxTestRunner" }
47 | espressoCore = { module = "androidx.test.espresso:espresso-core", version.ref = "espressoCore" }
48 | mockk = { module = "io.mockk:mockk", version.ref = "mockk" }
49 | robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" }
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haroldadmin/WhatTheStack/dbe12fec2c3dcd039ed6833ae500ad95a7752324/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Jan 14 11:19:34 IST 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.1.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/media/demo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haroldadmin/WhatTheStack/dbe12fec2c3dcd039ed6833ae500ad95a7752324/media/demo.gif
--------------------------------------------------------------------------------
/media/icon.sketch:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haroldadmin/WhatTheStack/dbe12fec2c3dcd039ed6833ae500ad95a7752324/media/icon.sketch
--------------------------------------------------------------------------------
/media/repo-banner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haroldadmin/WhatTheStack/dbe12fec2c3dcd039ed6833ae500ad95a7752324/media/repo-banner.png
--------------------------------------------------------------------------------
/media/screenshot-dark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haroldadmin/WhatTheStack/dbe12fec2c3dcd039ed6833ae500ad95a7752324/media/screenshot-dark.png
--------------------------------------------------------------------------------
/media/screenshot-light.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haroldadmin/WhatTheStack/dbe12fec2c3dcd039ed6833ae500ad95a7752324/media/screenshot-light.png
--------------------------------------------------------------------------------
/media/screenshot.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haroldadmin/WhatTheStack/dbe12fec2c3dcd039ed6833ae500ad95a7752324/media/screenshot.jpeg
--------------------------------------------------------------------------------
/media/what-the-stack-icon.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':what-the-stack'
2 | include ':app'
3 | rootProject.name = "WhatTheStack"
4 | enableFeaturePreview("VERSION_CATALOGS")
5 |
--------------------------------------------------------------------------------
/what-the-stack/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/what-the-stack/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-parcelize'
4 | apply plugin: 'maven-publish'
5 |
6 | android {
7 | compileSdkVersion buildConfig.compileSdk
8 |
9 | defaultConfig {
10 | minSdkVersion buildConfig.minSdk
11 | targetSdkVersion buildConfig.targetSdk
12 | versionCode buildConfig.versionCode
13 | versionName buildConfig.versionName
14 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
15 | consumerProguardFiles 'consumer-rules.pro'
16 | }
17 |
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 |
25 | kotlinOptions {
26 | jvmTarget = "1.8"
27 | }
28 |
29 | compileOptions {
30 | sourceCompatibility JavaVersion.VERSION_1_8
31 | targetCompatibility JavaVersion.VERSION_1_8
32 | }
33 |
34 | kotlin {
35 | explicitApi()
36 | }
37 |
38 | buildFeatures {
39 | compose true
40 | }
41 |
42 | composeOptions {
43 | kotlinCompilerExtensionVersion libs.versions.compose.get()
44 | }
45 | }
46 |
47 | dependencies {
48 | implementation fileTree(dir: 'libs', include: ['*.jar'])
49 |
50 | implementation libs.kotlinStdLib
51 | implementation libs.appCompat
52 | implementation libs.coreKtx
53 | implementation libs.startup
54 |
55 | implementation libs.composeActivity
56 | implementation libs.composeMaterial
57 | implementation libs.composeTooling
58 | implementation libs.accompanistSysUi
59 | implementation libs.accompanistInsets
60 |
61 | testImplementation libs.junit
62 | testImplementation libs.mockk
63 |
64 | androidTestImplementation libs.androidxTestCore
65 | androidTestImplementation libs.androidxTestExt
66 | androidTestImplementation libs.espressoCore
67 | }
68 |
69 | afterEvaluate {
70 | publishing {
71 | publications {
72 | WhatTheStack(MavenPublication) {
73 | from components.release
74 | groupId = "com.github.haroldadmin"
75 | artifactId = "WhatTheStack"
76 | version = "0.3.1"
77 | }
78 | }
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/what-the-stack/consumer-rules.pro:
--------------------------------------------------------------------------------
1 | -keep class com.haroldadmin.whatthestack.WhatTheStackInitializer {
2 | ();
3 | }
4 |
--------------------------------------------------------------------------------
/what-the-stack/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 |
--------------------------------------------------------------------------------
/what-the-stack/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
10 |
12 |
13 |
14 |
18 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/what-the-stack/src/main/java/com/haroldadmin/whatthestack/Annotations.kt:
--------------------------------------------------------------------------------
1 | package com.haroldadmin.whatthestack
2 |
3 | /**
4 | * Indicates that the annotated class/function runs in the host application's
5 | * process, not in the bound service's process
6 | */
7 | @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
8 | @Retention(AnnotationRetention.SOURCE)
9 | internal annotation class HostAppProcess
10 |
11 | /**
12 | * Indicates that the annotated class/function runs in the bound service's
13 | * process, not in the host app's process
14 | */
15 | @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
16 | @Retention(AnnotationRetention.SOURCE)
17 | internal annotation class ServiceProcess
18 |
--------------------------------------------------------------------------------
/what-the-stack/src/main/java/com/haroldadmin/whatthestack/Constants.kt:
--------------------------------------------------------------------------------
1 | package com.haroldadmin.whatthestack
2 |
3 | /**
4 | * These keys are used to transfer the various components of [ExceptionData] across processes.
5 | */
6 | internal const val KEY_EXCEPTION_TYPE = "com.haroldadmin.whatthestack.exception.type"
7 | internal const val KEY_EXCEPTION_CAUSE = "com.haroldadmin.whatthestack.exception.cause"
8 | internal const val KEY_EXCEPTION_MESSAGE = "com.haroldadmin.whatthestack.exception.message"
9 | internal const val KEY_EXCEPTION_STACKTRACE = "com.haroldadmin.whatthestack.exception.stacktrace"
10 |
--------------------------------------------------------------------------------
/what-the-stack/src/main/java/com/haroldadmin/whatthestack/ExceptionProcessor.kt:
--------------------------------------------------------------------------------
1 | package com.haroldadmin.whatthestack
2 |
3 | import android.os.Parcelable
4 | import kotlinx.parcelize.Parcelize
5 |
6 | /**
7 | * Represents the data of the exception to be displayed to the user.
8 | *
9 | * @param type The class of the exception
10 | * @param message The message of the exception
11 | * @param stacktrace The stacktrace of the exception represented as a string
12 | */
13 | @Parcelize
14 | data class ExceptionData(
15 | val type: String,
16 | val cause: String,
17 | val message: String,
18 | val stacktrace: String
19 | ) : Parcelable
20 |
21 | /**
22 | * Processes the given exception to produce [ExceptionData]
23 | *
24 | * The returned [ExceptionData] contains the processed values for the root cause of the exception.
25 | */
26 | internal fun Throwable.process(): ExceptionData {
27 | val type = type()
28 | val rootCauseOfException = rootCause()
29 | val cause = rootCauseOfException.type()
30 | val message = rootCauseOfException.message ?: "Unknown"
31 | val stacktrace = this.stackTraceToString()
32 | return ExceptionData(type, cause, message, stacktrace)
33 | }
34 |
35 | /**
36 | * Finds and returns the root cause of the exception.
37 | *
38 | * The cause tree is traversed recursively to find the last cause.
39 | * If the original exception has no cause, then it itself is returned.
40 | */
41 | internal tailrec fun Throwable.rootCause(): Throwable {
42 | return if (cause == null) {
43 | this
44 | } else {
45 | cause!!.rootCause()
46 | }
47 | }
48 |
49 | /**
50 | * Returns the class name of the exception
51 | */
52 | internal fun Throwable.type(): String {
53 | return this::class.java.simpleName
54 | }
55 |
--------------------------------------------------------------------------------
/what-the-stack/src/main/java/com/haroldadmin/whatthestack/StackoverflowUtils.kt:
--------------------------------------------------------------------------------
1 | package com.haroldadmin.whatthestack
2 |
3 | import java.net.URLEncoder
4 |
5 | fun generateStackoverflowSearchUrl(query: String): String {
6 | val baseUrl = "https://stackoverflow.com/search"
7 | val queryString = URLEncoder.encode(query, "utf-8")
8 | return "$baseUrl?q=$queryString"
9 | }
10 |
--------------------------------------------------------------------------------
/what-the-stack/src/main/java/com/haroldadmin/whatthestack/WhatTheStackActivity.kt:
--------------------------------------------------------------------------------
1 | package com.haroldadmin.whatthestack
2 |
3 | import android.os.Bundle
4 | import androidx.activity.compose.setContent
5 | import androidx.appcompat.app.AppCompatActivity
6 | import androidx.core.view.WindowCompat
7 | import com.google.accompanist.insets.ProvideWindowInsets
8 | import com.google.accompanist.systemuicontroller.rememberSystemUiController
9 | import com.haroldadmin.whatthestack.ui.pages.ExceptionPage
10 | import com.haroldadmin.whatthestack.ui.theme.SystemBarsColor
11 | import com.haroldadmin.whatthestack.ui.theme.WhatTheStackTheme
12 |
13 | /**
14 | * An Activity which displays various pieces of information regarding the exception which
15 | * occurred.
16 | */
17 | class WhatTheStackActivity : AppCompatActivity() {
18 |
19 | override fun onCreate(savedInstanceState: Bundle?) {
20 | super.onCreate(savedInstanceState)
21 | WindowCompat.setDecorFitsSystemWindows(window, false)
22 |
23 | val type = intent.getStringExtra(KEY_EXCEPTION_TYPE) ?: ""
24 | val message = intent.getStringExtra(KEY_EXCEPTION_MESSAGE) ?: ""
25 | val stackTrace = intent.getStringExtra(KEY_EXCEPTION_STACKTRACE) ?: ""
26 |
27 | setContent {
28 | val sysUiController = rememberSystemUiController()
29 | sysUiController.setSystemBarsColor(SystemBarsColor)
30 |
31 | WhatTheStackTheme {
32 | ProvideWindowInsets {
33 | ExceptionPage(
34 | type = type,
35 | message = message,
36 | stackTrace = stackTrace
37 | )
38 | }
39 | }
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/what-the-stack/src/main/java/com/haroldadmin/whatthestack/WhatTheStackExceptionHandler.kt:
--------------------------------------------------------------------------------
1 | package com.haroldadmin.whatthestack
2 |
3 | import android.os.Message
4 | import android.os.Messenger
5 | import androidx.core.os.bundleOf
6 |
7 | /**
8 | * A [Thread.UncaughtExceptionHandler] which is meant to be used as a default exception handler on
9 | * the application.
10 | *
11 | * It runs in the host app's process to:
12 | * 1. Process any exception it catches and forward the result in a [Message] to [WhatTheStackService]
13 | * 2. Call the default exception handler it replaced, if any
14 | * 3. Kill the app process if there was no previous default exception handler
15 | */
16 | @HostAppProcess
17 | internal class WhatTheStackExceptionHandler(
18 | private val serviceMessenger: Messenger,
19 | private val defaultHandler: Thread.UncaughtExceptionHandler?,
20 | ) : Thread.UncaughtExceptionHandler {
21 | override fun uncaughtException(t: Thread, e: Throwable) {
22 | e.printStackTrace()
23 | val exceptionData = e.process()
24 | serviceMessenger.send(
25 | Message().apply {
26 | data = bundleOf(
27 | KEY_EXCEPTION_TYPE to exceptionData.type,
28 | KEY_EXCEPTION_CAUSE to exceptionData.cause,
29 | KEY_EXCEPTION_MESSAGE to exceptionData.message,
30 | KEY_EXCEPTION_STACKTRACE to exceptionData.stacktrace
31 | )
32 | }
33 | )
34 |
35 | defaultHandler?.uncaughtException(t, e)
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/what-the-stack/src/main/java/com/haroldadmin/whatthestack/WhatTheStackInitializer.kt:
--------------------------------------------------------------------------------
1 | package com.haroldadmin.whatthestack
2 |
3 | import android.content.ComponentName
4 | import android.content.Context
5 | import android.content.Intent
6 | import android.content.ServiceConnection
7 | import android.os.IBinder
8 | import android.os.Messenger
9 | import androidx.startup.Initializer
10 | import java.lang.Class
11 |
12 | /**
13 | * WhatTheStackInitializer is an [androidx.startup.Initializer] for WhatTheStack
14 | */
15 | @HostAppProcess
16 | class WhatTheStackInitializer : Initializer {
17 |
18 | /**
19 | * Runs in the host app's process to:
20 | *
21 | * 1. Start [WhatTheStackService] as a bound service to allow communication between the
22 | * app's process and the service's process
23 | * 2. Replace the app's default [Thread.UncaughtExceptionHandler] with [WhatTheStackExceptionHandler]
24 | * when the service is connected.
25 | *
26 | * This method does not need to return anything, but it is required to return
27 | * a sensible value here so we return a dummy object [InitializedToken] instead.
28 | */
29 | override fun create(context: Context): InitializedToken {
30 | val connection = object : ServiceConnection {
31 | override fun onServiceConnected(name: ComponentName?, service: IBinder) {
32 | val messenger = Messenger(service)
33 | val defaultExceptionHandler = Thread.getDefaultUncaughtExceptionHandler()
34 | val customExceptionHandler = WhatTheStackExceptionHandler(
35 | messenger,
36 | defaultExceptionHandler
37 | )
38 | Thread.setDefaultUncaughtExceptionHandler(customExceptionHandler)
39 | }
40 |
41 | override fun onServiceDisconnected(name: ComponentName?) = Unit
42 | }
43 |
44 | val intent = Intent(context, WhatTheStackService::class.java)
45 | context.bindService(intent, connection, Context.BIND_AUTO_CREATE)
46 |
47 | return InitializedToken
48 | }
49 |
50 | override fun dependencies(): List>> = emptyList()
51 |
52 | /**
53 | * A dummy object that does nothing but represent a type that can be returned by
54 | * [WhatTheStackInitializer]
55 | */
56 | object InitializedToken
57 | }
58 |
--------------------------------------------------------------------------------
/what-the-stack/src/main/java/com/haroldadmin/whatthestack/WhatTheStackService.kt:
--------------------------------------------------------------------------------
1 | package com.haroldadmin.whatthestack
2 |
3 | import android.app.Service
4 | import android.content.Context
5 | import android.content.Intent
6 | import android.os.*
7 |
8 | /**
9 | * A Bound Service which runs in a separate process than the host application.
10 | *
11 | * This service must be started with [Context.bindService]. A bound service lives only as long as
12 | * the calling context, so `bindService` must be called on an **APPLICATION CONTEXT**.
13 | *
14 | * [WhatTheStackInitializer] starts this service, and it dies when the host app terminates.
15 | * Therefore we don't need to explicitly handle [Service.onCreate], [Service.onDestroy] or call
16 | * [Service.stopSelf].
17 | *
18 | * [WhatTheStackExceptionHandler] sends messages to this service whenever an uncaught exception
19 | * is thrown in the host application. This service then starts an activity with the processed
20 | * exception data as an intent extra.
21 | */
22 | @ServiceProcess
23 | class WhatTheStackService : Service() {
24 | /**
25 | * [Handler] that runs on the main thread to handle incoming processed uncaught
26 | * exceptions from [WhatTheStackExceptionHandler]
27 | *
28 | * We need to lazily initialize it because [getApplicationContext] returns null right
29 | * after the service is created.
30 | */
31 | private val handler by lazy { WhatTheStackHandler(applicationContext) }
32 |
33 | /**
34 | * Runs when [WhatTheStackInitializer] calls [Context.bindService] to create a connection
35 | * to this service.
36 | *
37 | * It creates a [Messenger] that can be used to communicate with its [handler],
38 | * and returns its [IBinder].
39 | */
40 | override fun onBind(intent: Intent?): IBinder? {
41 | val messenger = Messenger(handler)
42 | return messenger.binder
43 | }
44 | }
45 |
46 | /**
47 | * A [Handler] that runs on the main thread of the service process to process
48 | * incoming uncaught exception messages.
49 | */
50 | @ServiceProcess
51 | private class WhatTheStackHandler(
52 | private val applicationContext: Context
53 | ) : Handler(Looper.getMainLooper()) {
54 |
55 | override fun handleMessage(msg: Message) {
56 | Intent()
57 | .apply {
58 | setClass(applicationContext, WhatTheStackActivity::class.java)
59 | putExtras(msg.data)
60 | flags = Intent.FLAG_ACTIVITY_NEW_TASK
61 | }
62 | .also { intent ->
63 | applicationContext.startActivity(intent)
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/what-the-stack/src/main/java/com/haroldadmin/whatthestack/ui/components/OutlinedIconButton.kt:
--------------------------------------------------------------------------------
1 | package com.haroldadmin.whatthestack.ui.components
2 |
3 | import androidx.annotation.DrawableRes
4 | import androidx.compose.foundation.layout.fillMaxWidth
5 | import androidx.compose.material.*
6 | import androidx.compose.runtime.Composable
7 | import androidx.compose.ui.Modifier
8 | import androidx.compose.ui.res.painterResource
9 | import androidx.compose.ui.text.style.TextAlign
10 |
11 | @Composable
12 | internal fun OutlinedIconButton(
13 | text: String,
14 | @DrawableRes iconId: Int,
15 | onClick: () -> Unit,
16 | contentDescription: String,
17 | modifier: Modifier = Modifier,
18 | ) {
19 | OutlinedButton(
20 | onClick = onClick,
21 | modifier = modifier.fillMaxWidth(),
22 | colors = ButtonDefaults.outlinedButtonColors(
23 | backgroundColor = MaterialTheme.colors.background,
24 | contentColor = MaterialTheme.colors.onBackground,
25 | disabledContentColor = MaterialTheme.colors.onBackground.copy(alpha = 0.5f)
26 | ),
27 | ) {
28 | Icon(
29 | painter = painterResource(id = iconId),
30 | contentDescription = contentDescription
31 | )
32 | Text(
33 | text = text,
34 | modifier = Modifier.fillMaxWidth(),
35 | textAlign = TextAlign.Center,
36 | )
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/what-the-stack/src/main/java/com/haroldadmin/whatthestack/ui/components/OverlineLabel.kt:
--------------------------------------------------------------------------------
1 | package com.haroldadmin.whatthestack.ui.components
2 |
3 | import androidx.compose.material.MaterialTheme
4 | import androidx.compose.material.Text
5 | import androidx.compose.runtime.Composable
6 | import androidx.compose.ui.Modifier
7 | import androidx.compose.ui.text.font.FontWeight
8 |
9 | /**
10 | * A text label with the "overline" typography style
11 | */
12 | @Composable
13 | internal fun OverlineLabel(label: String, modifier: Modifier = Modifier) {
14 | Text(
15 | text = label,
16 | style = MaterialTheme.typography.overline,
17 | fontWeight = FontWeight.Medium,
18 | color = MaterialTheme.colors.onSurface,
19 | modifier = modifier
20 | )
21 | }
22 |
--------------------------------------------------------------------------------
/what-the-stack/src/main/java/com/haroldadmin/whatthestack/ui/pages/ExceptionPage.kt:
--------------------------------------------------------------------------------
1 | package com.haroldadmin.whatthestack.ui.pages
2 |
3 | import android.content.Intent
4 | import android.content.res.Configuration.UI_MODE_NIGHT_YES
5 | import android.net.Uri
6 | import androidx.compose.foundation.horizontalScroll
7 | import androidx.compose.foundation.layout.Column
8 | import androidx.compose.foundation.layout.Spacer
9 | import androidx.compose.foundation.layout.height
10 | import androidx.compose.foundation.layout.padding
11 | import androidx.compose.foundation.rememberScrollState
12 | import androidx.compose.foundation.text.selection.SelectionContainer
13 | import androidx.compose.foundation.verticalScroll
14 | import androidx.compose.material.*
15 | import androidx.compose.runtime.Composable
16 | import androidx.compose.runtime.rememberCoroutineScope
17 | import androidx.compose.ui.Modifier
18 | import androidx.compose.ui.platform.LocalClipboardManager
19 | import androidx.compose.ui.platform.LocalContext
20 | import androidx.compose.ui.res.stringResource
21 | import androidx.compose.ui.text.AnnotatedString
22 | import androidx.compose.ui.text.font.FontFamily
23 | import androidx.compose.ui.tooling.preview.Preview
24 | import androidx.compose.ui.unit.dp
25 | import androidx.compose.ui.unit.sp
26 | import com.google.accompanist.insets.navigationBarsHeight
27 | import com.google.accompanist.insets.statusBarsHeight
28 | import com.haroldadmin.whatthestack.R
29 | import com.haroldadmin.whatthestack.generateStackoverflowSearchUrl
30 | import com.haroldadmin.whatthestack.ui.components.OutlinedIconButton
31 | import com.haroldadmin.whatthestack.ui.components.OverlineLabel
32 | import com.haroldadmin.whatthestack.ui.preview.SampleData
33 | import com.haroldadmin.whatthestack.ui.theme.WhatTheStackTheme
34 | import kotlinx.coroutines.launch
35 |
36 | @Composable
37 | fun ExceptionPage(
38 | type: String,
39 | message: String,
40 | stackTrace: String
41 | ) {
42 | val clipboard = LocalClipboardManager.current
43 | val context = LocalContext.current
44 | val scaffoldState = rememberScaffoldState()
45 | val coroutineScope = rememberCoroutineScope()
46 |
47 | val snackbarMessage = stringResource(id = R.string.copied_message)
48 |
49 | Scaffold(scaffoldState = scaffoldState) {
50 | Column(
51 | modifier = Modifier
52 | .padding(horizontal = 16.dp)
53 | .verticalScroll(rememberScrollState())
54 | ) {
55 | Spacer(modifier = Modifier.statusBarsHeight(additional = 8.dp))
56 | PageHeader()
57 | ExceptionDetails(
58 | type = type,
59 | message = message,
60 | modifier = Modifier.padding(vertical = 8.dp)
61 | )
62 | ExceptionOptions(
63 | onCopy = {
64 | coroutineScope.launch {
65 | clipboard.setText(AnnotatedString(stackTrace))
66 | scaffoldState.snackbarHostState.showSnackbar(snackbarMessage)
67 | }
68 | },
69 | onShare = {
70 | val sendIntent: Intent = Intent().apply {
71 | this.action = Intent.ACTION_SEND
72 | this.putExtra(Intent.EXTRA_TEXT, stackTrace)
73 | this.type = "text/plain"
74 | }
75 |
76 | val shareIntent = Intent.createChooser(sendIntent, "Stacktrace")
77 | context.startActivity(shareIntent)
78 | },
79 | onSearch = {
80 | val searchQuery = "$type: $message"
81 | val url = generateStackoverflowSearchUrl(searchQuery)
82 | val searchIntent = Intent().apply {
83 | action = Intent.ACTION_VIEW
84 | data = Uri.parse(url)
85 | }
86 | context.startActivity(searchIntent)
87 | },
88 | onRestart = {
89 | val applicationContext = context.applicationContext
90 | val packageManager = applicationContext.packageManager
91 | val packageName = applicationContext.packageName
92 |
93 | val launchIntent = packageManager.getLaunchIntentForPackage(packageName)
94 | if (launchIntent != null) {
95 | launchIntent.flags =
96 | Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
97 | context.startActivity(launchIntent)
98 | }
99 | }
100 | )
101 | Stacktrace(
102 | stackTrace = stackTrace,
103 | modifier = Modifier.padding(top = 8.dp)
104 | )
105 | Spacer(modifier = Modifier.navigationBarsHeight(additional = 8.dp))
106 | }
107 | }
108 | }
109 |
110 | @Composable
111 | fun PageHeader() {
112 | Text(
113 | stringResource(id = R.string.header_text),
114 | style = MaterialTheme.typography.h4,
115 | modifier = Modifier.padding(vertical = 4.dp),
116 | color = MaterialTheme.colors.onBackground
117 | )
118 | Spacer(modifier = Modifier.height(4.dp))
119 | Text(
120 | text = stringResource(id = R.string.explanation_text),
121 | color = MaterialTheme.colors.onBackground
122 | )
123 | }
124 |
125 | @Composable
126 | fun ExceptionDetails(type: String, message: String, modifier: Modifier) {
127 | Column(modifier = modifier) {
128 | OverlineLabel(label = stringResource(id = R.string.exception_name))
129 | Text(
130 | text = type,
131 | fontFamily = FontFamily.Monospace,
132 | color = MaterialTheme.colors.onBackground
133 | )
134 | Spacer(modifier = Modifier.height(8.dp))
135 | OverlineLabel(label = stringResource(id = R.string.exception_message))
136 | Text(
137 | text = message,
138 | fontFamily = FontFamily.Monospace,
139 | color = MaterialTheme.colors.onBackground
140 | )
141 | }
142 | }
143 |
144 | @Composable
145 | fun ExceptionOptions(
146 | onCopy: () -> Unit,
147 | onShare: () -> Unit,
148 | onRestart: () -> Unit,
149 | onSearch: () -> Unit,
150 | modifier: Modifier = Modifier
151 | ) {
152 | Column(modifier = modifier) {
153 | OutlinedIconButton(
154 | text = stringResource(id = R.string.copy_stacktrace),
155 | iconId = R.drawable.ic_outline_content_copy_24,
156 | onClick = onCopy,
157 | contentDescription = "Copy",
158 | modifier = Modifier.padding(vertical = 4.dp),
159 | )
160 | OutlinedIconButton(
161 | text = stringResource(id = R.string.share_stacktrace),
162 | iconId = R.drawable.ic_outline_share_24,
163 | onClick = onShare,
164 | contentDescription = "Share",
165 | modifier = Modifier.padding(vertical = 4.dp)
166 | )
167 | OutlinedIconButton(
168 | text = stringResource(id = R.string.search_stackoverflow),
169 | iconId = R.drawable.ic_round_search_24,
170 | onClick = onSearch,
171 | contentDescription = "Search Stackoverflow",
172 | modifier = Modifier.padding(vertical = 4.dp)
173 | )
174 | OutlinedIconButton(
175 | text = stringResource(id = R.string.restart_application),
176 | iconId = R.drawable.ic_baseline_refresh_24,
177 | onClick = onRestart,
178 | contentDescription = "Restart"
179 | )
180 | }
181 | }
182 |
183 | @Composable
184 | fun Stacktrace(stackTrace: String, modifier: Modifier) {
185 | Column(modifier) {
186 | OverlineLabel(label = stringResource(id = R.string.stacktrace))
187 | Surface(modifier = Modifier.padding(top = 4.dp)) {
188 | SelectionContainer {
189 | Text(
190 | text = stackTrace,
191 | style = MaterialTheme.typography.body2.copy(fontSize = 12.sp),
192 | fontFamily = FontFamily.Monospace,
193 | color = MaterialTheme.colors.primary,
194 | modifier = Modifier
195 | .padding(4.dp)
196 | .horizontalScroll(rememberScrollState())
197 | )
198 | }
199 | }
200 | }
201 | }
202 |
203 | @Preview
204 | @Composable
205 | fun ExceptionPagePreview() {
206 | WhatTheStackTheme {
207 | ExceptionPage(
208 | type = SampleData.ExceptionType,
209 | message = SampleData.ExceptionMessage,
210 | stackTrace = SampleData.Stacktrace
211 | )
212 | }
213 | }
214 |
215 | @Preview(uiMode = UI_MODE_NIGHT_YES)
216 | @Composable
217 | fun ExceptionPagePreviewNightMode() {
218 | WhatTheStackTheme {
219 | ExceptionPage(
220 | type = SampleData.ExceptionType,
221 | message = SampleData.ExceptionMessage,
222 | stackTrace = SampleData.Stacktrace
223 | )
224 | }
225 | }
226 |
--------------------------------------------------------------------------------
/what-the-stack/src/main/java/com/haroldadmin/whatthestack/ui/preview/SampleData.kt:
--------------------------------------------------------------------------------
1 | package com.haroldadmin.whatthestack.ui.preview
2 |
3 | object SampleData {
4 | const val ExceptionType = "Runtime Exception"
5 |
6 | const val ExceptionMessage = "This exception was thrown purely because it can be thrown"
7 |
8 | const val Stacktrace =
9 | """java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
10 | at com.android.internal.os.RuntimeInitMethodAndArgsCaller.run(RuntimeInit.java:558)
11 | at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
12 | Caused by: java.lang.reflect.InvocationTargetException
13 | at java.lang.reflect.Method.invoke(Native Method)
14 | at com.android.internal.os.RuntimeInitMethodAndArgsCaller.run(RuntimeInit.java:548)
15 | ... 1 more
16 | Caused by: com.haroldadmin.crashyapp.BecauseICanException: This exception is thrown purely because it can be thrown
17 | at com.haroldadmin.crashyapp.MainActivity.onCreatelambda-0(MainActivity.kt:15)
18 | at com.haroldadmin.crashyapp.MainActivity.r8lambdapFZVHP1EeT4E2LW7TLA5yGBRTTk(Unknown Source:0)
19 | at com.haroldadmin.crashyapp.MainActivityxternalSyntheticLambda0.onClick(Unknown Source:0)
20 | at android.view.View.performClick(View.java:7441)
21 | at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1119)
22 | at android.view.View.performClickInternal(View.java:7418)
23 | at android.view.View.access$3700(View.java:835)
24 | at android.view.ViewPerformClick.run(View.java:28676)
25 | at android.os.Handler.handleCallback(Handler.java:938)
26 | at android.os.Handler.dispatchMessage(Handler.java:99)
27 | at android.os.Looper.loopOnce(Looper.java:201)
28 | at android.os.Looper.loop(Looper.java:288)
29 | at android.app.ActivityThread.main(ActivityThread.java:7839)
30 | ... 3 more
31 | """
32 | }
33 |
--------------------------------------------------------------------------------
/what-the-stack/src/main/java/com/haroldadmin/whatthestack/ui/theme/WhatTheStackTheme.kt:
--------------------------------------------------------------------------------
1 | package com.haroldadmin.whatthestack.ui.theme
2 |
3 | import androidx.compose.foundation.isSystemInDarkTheme
4 | import androidx.compose.material.MaterialTheme
5 | import androidx.compose.material.darkColors
6 | import androidx.compose.material.lightColors
7 | import androidx.compose.runtime.Composable
8 | import androidx.compose.ui.graphics.Color
9 |
10 | private val DarkColorPalette = darkColors(
11 | primary = Color(0xffd32f2f),
12 | primaryVariant = Color(0xffff6659),
13 | secondary = Color(0xff616161),
14 | secondaryVariant = Color(0xff373737),
15 | )
16 |
17 | private val LightColorPalette = lightColors(
18 | primary = Color(0xffd32f2f),
19 | primaryVariant = Color(0xff9a0007),
20 | secondary = Color(0xff616161),
21 | secondaryVariant = Color(0x33373737),
22 | )
23 |
24 | internal val SystemBarsColor = Color(0x33373737)
25 |
26 | @Composable
27 | fun WhatTheStackTheme(
28 | darkTheme: Boolean = isSystemInDarkTheme(),
29 | content: @Composable () -> Unit
30 | ) {
31 | val colors = if (darkTheme) {
32 | DarkColorPalette
33 | } else {
34 | LightColorPalette
35 | }
36 |
37 | MaterialTheme(colors = colors, content = content)
38 | }
39 |
--------------------------------------------------------------------------------
/what-the-stack/src/main/res/drawable/ic_baseline_refresh_24.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/what-the-stack/src/main/res/drawable/ic_outline_content_copy_24.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/what-the-stack/src/main/res/drawable/ic_outline_share_24.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/what-the-stack/src/main/res/drawable/ic_round_search_24.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/what-the-stack/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Uncaught Exception
4 | An uncaught exception was thrown during the execution of your application
5 |
6 | 2020-01-12 16:01:48.190 15365-15365/com.haroldadmin.crashyapp E/AndroidRuntime: FATAL EXCEPTION: main
7 | Process: com.haroldadmin.crashyapp, PID: 15365
8 | java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
9 | at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:502)
10 | at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
11 | Caused by: java.lang.reflect.InvocationTargetException
12 | at java.lang.reflect.Method.invoke(Native Method)
13 | at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
14 | at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
15 | Caused by: com.haroldadmin.crashyapp.MyCustomException: Because I can exception
16 | at com.haroldadmin.crashyapp.MainActivity$onCreate$1.onClick(MainActivity.kt:17)
17 | at android.view.View.performClick(View.java:7140)
18 | at android.view.View.performClickInternal(View.java:7117)
19 | at android.view.View.access$3500(View.java:801)
20 | at android.view.View$PerformClick.run(View.java:27351)
21 | at android.os.Handler.handleCallback(Handler.java:883)
22 | at android.os.Handler.dispatchMessage(Handler.java:100)
23 | at android.os.Looper.loop(Looper.java:214)
24 | at android.app.ActivityThread.main(ActivityThread.java:7356)
25 | at java.lang.reflect.Method.invoke(Native Method)
26 | at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
27 | at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
28 |
29 | Exception
30 | Stacktrace
31 | Message
32 | Copy Stacktrace
33 | Share Stacktrace
34 | Restart Application
35 | Relaunch App
36 | Stacktrace copied!
37 | Search Stackoverflow
38 |
--------------------------------------------------------------------------------
/what-the-stack/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/what-the-stack/src/test/java/com/haroldadmin/whatthestack/ExceptionProcessingTest.kt:
--------------------------------------------------------------------------------
1 | package com.haroldadmin.whatthestack
2 |
3 | import org.junit.Test
4 | import java.io.PrintStream
5 |
6 | internal class ExceptionProcessingTest {
7 |
8 | @Test
9 | fun `root cause test`() {
10 | val exceptionWithRootCause = ExceptionWithRootCause()
11 | val rootCause = exceptionWithRootCause.rootCause()
12 |
13 | assert(rootCause is RootCauseException)
14 | }
15 |
16 | @Test
17 | fun `exception message test`() {
18 | val exception = ExceptionWithRootCause()
19 | val message = exception.message
20 |
21 | assert(message == ExceptionWithRootCause.MESSAGE)
22 | }
23 |
24 | @Test
25 | fun `exception type test`() {
26 | val exception = ExceptionWithRootCause()
27 | val type = exception.type()
28 |
29 | assert(type == ExceptionWithRootCause::class.java.simpleName)
30 | }
31 |
32 | @Test
33 | fun `exception stacktrace test`() {
34 | val exception = ExceptionWithRootCause()
35 | val outputStream = StringOutputStream()
36 | exception.printStackTrace(PrintStream(outputStream))
37 |
38 | assert(outputStream.getString() == exception.stackTraceToString())
39 | }
40 |
41 | @Test
42 | fun `exception processing test`() {
43 | val exception = ExceptionWithRootCause()
44 | val processedData = exception.process()
45 |
46 | assert(processedData.type == exception.type())
47 | assert(processedData.message == exception.rootCause().message)
48 | assert(processedData.stacktrace == exception.stackTraceToString())
49 | assert(processedData.cause == exception.rootCause().type())
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/what-the-stack/src/test/java/com/haroldadmin/whatthestack/ExceptionWithRootCause.kt:
--------------------------------------------------------------------------------
1 | package com.haroldadmin.whatthestack
2 |
3 | internal class RootCauseException : Throwable() {
4 |
5 | override val message = MESSAGE
6 |
7 | companion object {
8 | internal const val MESSAGE = "root cause exception"
9 | }
10 | }
11 |
12 | internal class ExceptionWithRootCause : Throwable() {
13 | override val cause = RootCauseException()
14 | override val message = MESSAGE
15 |
16 | companion object {
17 | internal const val MESSAGE = "exception with root cause"
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/what-the-stack/src/test/java/com/haroldadmin/whatthestack/StackoverflowUrlTest.kt:
--------------------------------------------------------------------------------
1 | package com.haroldadmin.whatthestack
2 |
3 | import org.junit.Test
4 |
5 | internal class StackoverflowUrlTest {
6 | @Test
7 | fun shouldEncodeSearchStringCorrectly() {
8 | val searchQuery = "test search"
9 | val url = generateStackoverflowSearchUrl(searchQuery)
10 | assert(!url.contains(' '))
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/what-the-stack/src/test/java/com/haroldadmin/whatthestack/StringOutputStream.kt:
--------------------------------------------------------------------------------
1 | package com.haroldadmin.whatthestack
2 |
3 | import java.io.OutputStream
4 | import java.lang.StringBuilder
5 |
6 | internal class StringOutputStream : OutputStream() {
7 |
8 | private val builder = StringBuilder()
9 |
10 | override fun write(byte: Int) {
11 | builder.append(byte.toChar())
12 | }
13 |
14 | fun getString() = builder.toString()
15 |
16 | fun clear() = builder.clear()
17 | }
18 |
--------------------------------------------------------------------------------
/what-the-stack/src/test/java/com/haroldadmin/whatthestack/StringOutputStreamTest.kt:
--------------------------------------------------------------------------------
1 | package com.haroldadmin.whatthestack
2 |
3 | import org.junit.Assert.*
4 | import org.junit.Test
5 |
6 | private const val testMessage = "This is a test message"
7 |
8 | internal class StringOutputStreamTest {
9 |
10 | @Test
11 | fun `data write test`() {
12 | val outputStream = StringOutputStream()
13 | outputStream.write(testMessage.toByteArray())
14 |
15 | val actualMessage = outputStream.getString()
16 |
17 | assertEquals(testMessage, actualMessage)
18 | }
19 |
20 | @Test
21 | fun `data clear test`() {
22 | val outputStream = StringOutputStream().apply {
23 | write(testMessage.toByteArray())
24 | }
25 |
26 | outputStream.clear()
27 |
28 | assertTrue(outputStream.getString().isEmpty())
29 | }
30 | }
31 |
--------------------------------------------------------------------------------