Skip to content

Commit

Permalink
Migrate to m3 (#40)
Browse files Browse the repository at this point in the history
* Upgrade dependencies

Signed-off-by: Arnau Mora Gras <[email protected]>

* Using new Compose Compiler plugin

Signed-off-by: Arnau Mora Gras <[email protected]>

* Upgrade AGP

Signed-off-by: Arnau Mora Gras <[email protected]>

* Migrated to M3

Signed-off-by: Arnau Mora Gras <[email protected]>

* Upgrade dependency versions

* Got rid of Matrix

* Upgrade JDK to 21

* Upgrade Conscrypt

* Missing JDK upgrade

* Upgrade Gradle Wrapper

* Fixed theme

* Upgrade SDK level

* Add safe drawing padding (edge-to-edge)

---------

Signed-off-by: Arnau Mora Gras <[email protected]>
Co-authored-by: Ricki Hirner <[email protected]>
  • Loading branch information
ArnyminerZ and rfc2822 authored Dec 12, 2024
1 parent 65de909 commit 3b314c4
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 56 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ androidx-test-core = { module = "androidx.test:core-ktx", version.ref = "android
androidx-test-runner = { module = "androidx.test:runner", version.ref = "androidx-test-runner" }
androidx-test-rules = { module = "androidx.test:rules", version.ref = "androidx-test-rules" }
compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "compose-bom" }
compose-material = { module = "androidx.compose.material:material" }
compose-material3 = { module = "androidx.compose.material3:material3" }
compose-runtime-livedata = { module = "androidx.compose.runtime:runtime-livedata" }
compose-ui-base = { module = "androidx.compose.ui:ui" }
compose-ui-graphics = { module = "androidx.compose.ui:ui-graphics" }
Expand Down
2 changes: 1 addition & 1 deletion lib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ dependencies {
// Jetpack Compose
implementation(libs.androidx.activityCompose)
implementation(platform(libs.compose.bom))
implementation(libs.compose.material)
implementation(libs.compose.material3)
implementation(libs.compose.runtime.livedata)
debugImplementation(libs.compose.ui.tooling)
implementation(libs.compose.ui.toolingPreview)
Expand Down
11 changes: 9 additions & 2 deletions lib/src/main/java/at/bitfire/cert4android/Cert4Android.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
package at.bitfire.cert4android

import android.util.Log
import androidx.compose.material.MaterialTheme
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.safeDrawingPadding
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import java.util.logging.Level
import java.util.logging.Logger

Expand All @@ -28,7 +31,11 @@ object Cert4Android {
// theme

var theme: @Composable (content: @Composable () -> Unit) -> Unit = { content ->
MaterialTheme(content = content)
MaterialTheme {
Box(Modifier.safeDrawingPadding()) {
content()
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.BackHandler
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.activity.viewModels
import androidx.annotation.StringRes
import androidx.compose.foundation.clickable
Expand All @@ -19,14 +20,14 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.Card
import androidx.compose.material.Checkbox
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Scaffold
import androidx.compose.material.SnackbarHost
import androidx.compose.material.SnackbarHostState
import androidx.compose.material.Text
import androidx.compose.material.TextButton
import androidx.compose.material3.Card
import androidx.compose.material3.Checkbox
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
Expand Down Expand Up @@ -74,11 +75,15 @@ class TrustCertificateActivity : ComponentActivity() {
processIntent(newIntent)
}

enableEdgeToEdge()

setContent {
MainLayout(
onRegisterDecision = { trusted -> model.registerDecision(trusted) },
onFinish = { finish() }
)
Cert4Android.theme {
MainLayout(
onRegisterDecision = { trusted -> model.registerDecision(trusted) },
onFinish = { finish() }
)
}
}
}

Expand Down Expand Up @@ -124,37 +129,35 @@ class TrustCertificateActivity : ComponentActivity() {
backPressedCounter = newBackPressedCounter
}

Cert4Android.theme {
Scaffold(
snackbarHost = { SnackbarHost(snackbarHostState) },
modifier = Modifier.padding(16.dp)
) { paddingValues ->
Column(
Scaffold(
snackbarHost = { SnackbarHost(snackbarHostState) },
modifier = Modifier.padding(16.dp)
) { paddingValues ->
Column(
modifier = Modifier
.padding(paddingValues)
.verticalScroll(rememberScrollState()),
) {
Text(
text = stringResource(R.string.trust_certificate_unknown_certificate_found),
style = MaterialTheme.typography.bodySmall,
modifier = Modifier
.padding(paddingValues)
.verticalScroll(rememberScrollState()),
) {
Text(
text = stringResource(R.string.trust_certificate_unknown_certificate_found),
style = MaterialTheme.typography.body1,
modifier = Modifier
.fillMaxWidth()
.padding(bottom = 16.dp)
)
.fillMaxWidth()
.padding(bottom = 16.dp)
)

CertificateCard(
uiState = uiState,
onRegisterDecision = onRegisterDecision
)
CertificateCard(
uiState = uiState,
onRegisterDecision = onRegisterDecision
)

Text(
text = stringResource(R.string.trust_certificate_reset_info),
style = MaterialTheme.typography.body1,
modifier = Modifier
.fillMaxWidth()
.padding(top = 16.dp),
)
}
Text(
text = stringResource(R.string.trust_certificate_reset_info),
style = MaterialTheme.typography.bodySmall,
modifier = Modifier
.fillMaxWidth()
.padding(top = 16.dp),
)
}
}
}
Expand All @@ -174,7 +177,7 @@ class TrustCertificateActivity : ComponentActivity() {
) {
Text(
text = stringResource(R.string.trust_certificate_x509_certificate_details),
style = MaterialTheme.typography.h5,
style = MaterialTheme.typography.titleMedium,
modifier = Modifier
.fillMaxWidth()
.padding(bottom = 16.dp),
Expand All @@ -201,14 +204,14 @@ class TrustCertificateActivity : ComponentActivity() {
if (sha1 != null || sha256 != null) {
Text(
text = stringResource(R.string.trust_certificate_fingerprints).uppercase(),
style = MaterialTheme.typography.body2,
style = MaterialTheme.typography.bodyMedium,
modifier = Modifier.fillMaxWidth(),
)

if (sha1 != null)
Text(
text = sha1,
style = MaterialTheme.typography.body2,
style = MaterialTheme.typography.bodyMedium,
modifier = Modifier
.fillMaxWidth()
.padding(bottom = 16.dp, top = 4.dp),
Expand All @@ -217,7 +220,7 @@ class TrustCertificateActivity : ComponentActivity() {
if (sha256 != null)
Text(
text = sha256,
style = MaterialTheme.typography.body2,
style = MaterialTheme.typography.bodyMedium,
modifier = Modifier
.fillMaxWidth()
.padding(bottom = 16.dp, top = 4.dp),
Expand All @@ -242,7 +245,7 @@ class TrustCertificateActivity : ComponentActivity() {
}
.weight(1f)
.padding(bottom = 8.dp),
style = MaterialTheme.typography.body2
style = MaterialTheme.typography.bodyMedium
)
}

Expand Down Expand Up @@ -274,13 +277,13 @@ class TrustCertificateActivity : ComponentActivity() {
fun InfoPack(@StringRes labelStringRes: Int, text: String) {
Text(
text = stringResource(labelStringRes).uppercase(),
style = MaterialTheme.typography.body2,
style = MaterialTheme.typography.bodyMedium,
modifier = Modifier
.fillMaxWidth(),
)
Text(
text = text,
style = MaterialTheme.typography.body1,
style = MaterialTheme.typography.bodySmall,
modifier = Modifier
.fillMaxWidth()
.padding(bottom = 16.dp),
Expand Down
2 changes: 1 addition & 1 deletion sample-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ dependencies {

implementation(libs.androidx.activityCompose)
implementation(platform(libs.compose.bom))
implementation(libs.compose.material)
implementation(libs.compose.material3)
implementation(libs.compose.ui.base)
implementation(libs.compose.ui.graphics)
debugImplementation(libs.compose.ui.toolingPreview)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.*
import androidx.compose.material3.Button
import androidx.compose.material3.Checkbox
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Text
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.livedata.observeAsState
Expand All @@ -30,13 +35,13 @@ import androidx.lifecycle.viewModelScope
import at.bitfire.cert4android.Cert4Android
import at.bitfire.cert4android.CustomCertManager
import at.bitfire.cert4android.CustomCertStore
import java.net.URL
import javax.net.ssl.HttpsURLConnection
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.launch
import org.apache.http.conn.ssl.AllowAllHostnameVerifier
import org.apache.http.conn.ssl.StrictHostnameVerifier
import java.net.URL
import javax.net.ssl.HttpsURLConnection

class MainActivity : ComponentActivity() {

Expand All @@ -50,7 +55,7 @@ class MainActivity : ComponentActivity() {
ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.POST_NOTIFICATIONS), 0)

setContent {
MaterialTheme {
Cert4Android.theme {
Column(Modifier
.padding(8.dp)
.verticalScroll(rememberScrollState())) {
Expand Down

0 comments on commit 3b314c4

Please sign in to comment.