Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from haroldadmin:main #1

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ jobs:
steps:
- uses: actions/checkout@v1

- name: set up JDK 1.8
- name: set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 1.8
java-version: 11

- name: Build with Gradle
run: ./gradlew build test
4 changes: 2 additions & 2 deletions .github/workflows/style-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ jobs:
steps:
- uses: actions/checkout@v1

- name: set up JDK 1.8
- name: set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 1.8
java-version: 11

- name: Ktlint check
run: ./gradlew ktlintCheck
2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 28 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .jitpack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
jdk: openjdk11
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ dependencies {
The library ships with Proguard rules to ensure that it works correctly even after minification.
</details>

### Multi-Process Service

`WhatTheStack` runs a bound service in a separate process to show you the error screen on a crash.

We need to run this code in a separate process because you can't reliably launch new Activities
in the host application's process after an uncaught exception is thrown.



## Contributions

We are happy to accept any external contributions in the form of PRs, issues, or blog posts.
Expand Down
15 changes: 11 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ android {
}

buildFeatures {
viewBinding true
compose true
}

composeOptions {
kotlinCompilerExtensionVersion "1.0.5"
}
}

Expand All @@ -53,9 +57,12 @@ dependencies {
implementation libs.kotlinStdLib
implementation libs.appCompat
implementation libs.coreKtx
implementation libs.fragmentKtx
implementation libs.constraintLayout
implementation libs.materialComponents

implementation libs.composeActivity
implementation libs.composeMaterial
implementation libs.composeTooling
implementation libs.accompanistSysUi
implementation libs.accompanistInsets

testImplementation libs.junit

Expand Down
6 changes: 4 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:label="Crashy App"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
15 changes: 7 additions & 8 deletions app/src/main/java/com/haroldadmin/crashyapp/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
package com.haroldadmin.crashyapp

import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity
import com.haroldadmin.crashyapp.databinding.ActivityMainBinding
import com.haroldadmin.crashyapp.ui.pages.HomePage
import com.haroldadmin.crashyapp.ui.theme.CrashyAppTheme

class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)

binding.crashButton.setOnClickListener {
throw BecauseICanException()
setContent {
CrashyAppTheme {
HomePage()
}
}
}
}

private class BecauseICanException : Exception("This exception is thrown purely because it can be thrown")
41 changes: 41 additions & 0 deletions app/src/main/java/com/haroldadmin/crashyapp/ui/pages/HomePage.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.haroldadmin.crashyapp.ui.pages

import androidx.compose.foundation.layout.*
import androidx.compose.material.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp

@Composable
fun HomePage() {
Scaffold(
topBar = {
TopAppBar {
Text(text = "Crashy App", style = MaterialTheme.typography.h6)
}
}
) {
Column(
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center,
modifier = Modifier
.padding(8.dp)
.fillMaxWidth()
.fillMaxHeight()
) {
Text(
text = "Press the button to see the error screen from WhatTheStack!",
textAlign = TextAlign.Center
)
Spacer(modifier = Modifier.height(16.dp))
Button(onClick = { throw BecauseICanException() }) {
Text(text = "Crash!")
}
}
}
}

private class BecauseICanException :
Exception("This exception is thrown purely because it can be thrown")
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.haroldadmin.crashyapp.ui.theme

import androidx.compose.material.MaterialTheme
import androidx.compose.material.lightColors
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color

private val ColorPalette = lightColors(
primary = Color(0xffd32f2f),
primaryVariant = Color(0xff9a0007),
secondary = Color(0xff616161),
secondaryVariant = Color(0x33373737),
)

@Composable
fun CrashyAppTheme(
content: @Composable () -> Unit
) {
MaterialTheme(colors = ColorPalette, content = content)
}
32 changes: 0 additions & 32 deletions app/src/main/res/layout/activity_main.xml

This file was deleted.

11 changes: 0 additions & 11 deletions app/src/main/res/values/colors.xml

This file was deleted.

3 changes: 0 additions & 3 deletions app/src/main/res/values/strings.xml

This file was deleted.

11 changes: 1 addition & 10 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
<resources>

<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<item name="colorPrimary">@color/primaryColor</item>
<item name="colorPrimaryVariant">@color/primaryLightColor</item>
<item name="colorPrimaryDark">@color/primaryDarkColor</item>
<item name="colorOnPrimary">@color/primaryTextColor</item>
<item name="colorSecondary">@color/secondaryColor</item>
<item name="colorSecondaryVariant">@color/secondaryLightColor</item>
<item name="colorOnSecondary">@color/secondaryTextColor</item>
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
</style>

</resources>
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
buildscript {
ext.buildConfig = [
"applicationId": "com.haroldadmin.crashyapp",
"compileSdk" : 29,
"compileSdk" : 31,
"minSdk" : 21,
"targetSdk" : 29,
"targetSdk" : 31,
"versionCode" : 1,
"versionName" : "0.0.1"
]
Expand Down Expand Up @@ -33,7 +33,7 @@ allprojects {
subprojects {
apply plugin: "org.jlleitschuh.gradle.ktlint"
ktlint {
version = "0.36.0"
version = "0.43.0"
ignoreFailures = false
disabledRules = ["no-wildcard-imports"]
}
Expand Down
12 changes: 10 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[versions]
kotlin = "1.5.20"
agp = "4.2.0"
kotlin = "1.5.31"
agp = "7.0.3"
ktlint = "10.1.0"
appCompat = "1.3.0"
coreTest = "2.0.0"
Expand All @@ -17,9 +17,17 @@ espressoCore = "3.2.0"
mockk = "1.9.3"
robolectric = "4.3.1"
startup = "1.0.0"
composeActivity = "1.3.1"
compose = "1.0.5"
accompanist = "0.21.3-beta"

[libraries]

composeActivity = { module = "androidx.activity:activity-compose", version.ref = "composeActivity" }
composeMaterial = { module = "androidx.compose.material:material", version.ref = "compose" }
composeTooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" }
accompanistSysUi = { module = "com.google.accompanist:accompanist-systemuicontroller", version.ref = "accompanist" }
accompanistInsets = { module = "com.google.accompanist:accompanist-insets", version.ref = "accompanist" }
agp = { module = "com.android.tools.build:gradle", version.ref = "agp" }
kotlinGradlePlugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
ktlintGradlePlugin = { module = "org.jlleitschuh.gradle:ktlint-gradle", version.ref = "ktlint" }
Expand Down
16 changes: 11 additions & 5 deletions what-the-stack/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ android {
}

buildFeatures {
viewBinding true
compose true
}

composeOptions {
kotlinCompilerExtensionVersion libs.versions.compose.get()
}
}

Expand All @@ -46,11 +50,13 @@ dependencies {
implementation libs.kotlinStdLib
implementation libs.appCompat
implementation libs.coreKtx
implementation libs.fragmentKtx
implementation libs.constraintLayout
implementation libs.materialComponents
implementation libs.startup
implementation libs.insetter

implementation libs.composeActivity
implementation libs.composeMaterial
implementation libs.composeTooling
implementation libs.accompanistSysUi
implementation libs.accompanistInsets

testImplementation libs.junit
testImplementation libs.mockk
Expand Down
Loading