-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate project to Jetpack Compose (#27)
* feat: Switch to versions catalog and AGP 7 * feat: Refactor library module to use jetpack compose * feat: Migrate sample app to jetpack compose * fix: Use JDK 11 in CI * fix: Update ktlint * lint: Fix lint errors * fix: Use the same version for compose material and tooling libs * fix: Inline single use composables, make filenames consistent with composables, use version references in build.gradle * fix: Replace deprecated Handler constructor
- Loading branch information
1 parent
9208819
commit 5f9b660
Showing
36 changed files
with
563 additions
and
411 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 7 additions & 8 deletions
15
app/src/main/java/com/haroldadmin/crashyapp/MainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
41
app/src/main/java/com/haroldadmin/crashyapp/ui/pages/HomePage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 below to see 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") |
20 changes: 20 additions & 0 deletions
20
app/src/main/java/com/haroldadmin/crashyapp/ui/theme/CrashyAppTheme.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
what-the-stack/src/main/java/com/haroldadmin/whatthestack/ExceptionProcessor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.