Skip to content

Commit

Permalink
ui: Updated RoundedTag to use ellipsis for text overflow
Browse files Browse the repository at this point in the history
ui: Removed Settings from drawer
ui: Updated CrashHandlerActivity to use CrashHandlerTheme

Signed-off-by: Gabriel Fontán <[email protected]>
  • Loading branch information
BobbyESP committed Jul 31, 2024
1 parent b1bf9b8 commit 2b81364
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 72 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ plugins {

if (isFullBuild) {
apply(plugin = libs.plugins.google.gms.get().pluginId)
apply(plugin = "com.google.firebase.crashlytics")
apply(plugin = libs.plugins.firebase.crashlytics.get().pluginId)
apply<CrashlyticsBuildConfig>()
}

Expand All @@ -40,7 +40,7 @@ android {
defaultConfig {
applicationId = "com.bobbyesp.metadator"
minSdk = 24
targetSdk = 34
targetSdk = 35

versionCode = currentVersion.toVersionCode()
versionName = currentVersion.toVersionName()
Expand Down
69 changes: 31 additions & 38 deletions app/src/main/java/com/bobbyesp/metadator/presentation/Navigation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,20 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.add
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.safeDrawing
import androidx.compose.foundation.layout.systemBars
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.Settings
import androidx.compose.material.icons.rounded.Square
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
Expand All @@ -39,7 +35,6 @@ import androidx.compose.material3.OutlinedCard
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Snackbar
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
Expand All @@ -51,13 +46,9 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.role
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextOverflow
Expand Down Expand Up @@ -265,35 +256,37 @@ fun Navigator() {
shape = MaterialTheme.shapes.small
)
}
Surface(onClick = {
navController.navigate(Route.SettingsNavigator.Settings)
scope.launch {
drawerState.close()
}
},
modifier = Modifier
.semantics { role = Role.Tab }
.height(56.dp)
.fillMaxWidth(),
color = Color.Transparent) {
Row(
Modifier.padding(start = 16.dp, end = 24.dp),
verticalAlignment = Alignment.CenterVertically
) {
Icon(
imageVector = Icons.Rounded.Settings,
contentDescription = stringResource(id = R.string.settings)
)
Spacer(Modifier.width(12.dp))
Text(
text = stringResource(id = R.string.settings),
style = MaterialTheme.typography.bodyMedium,
fontWeight = FontWeight.Bold,
fontFamily = FontFamily.Monospace,
overflow = TextOverflow.Ellipsis
)
}
}
// Surface(
// modifier = Modifier
// .semantics { role = Role.Tab }
// .height(56.dp)
// .fillMaxWidth(),
// onClick = {
// navController.navigate(Route.SettingsNavigator.Settings)
// scope.launch {
// drawerState.close()
// }
// },
// color = Color.Transparent
// ) {
// Row(
// Modifier.padding(start = 16.dp, end = 24.dp),
// verticalAlignment = Alignment.CenterVertically
// ) {
// Icon(
// imageVector = Icons.Rounded.Settings,
// contentDescription = stringResource(id = R.string.settings)
// )
// Spacer(Modifier.width(12.dp))
// Text(
// text = stringResource(id = R.string.settings),
// style = MaterialTheme.typography.bodyMedium,
// fontWeight = FontWeight.Bold,
// fontFamily = FontFamily.Monospace,
// overflow = TextOverflow.Ellipsis
// )
// }
// }
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp

@Composable
Expand All @@ -33,6 +34,7 @@ fun RoundedTag(
text = text,
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.8f),
overflow = TextOverflow.Ellipsis,
fontWeight = FontWeight.Bold,
modifier = Modifier.padding(horizontal = 8.dp, vertical = 4.dp)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.platform.LocalClipboardManager
import androidx.compose.ui.text.AnnotatedString
import androidx.core.view.ViewCompat
import androidx.core.view.WindowCompat
import com.bobbyesp.crashhandler.ui.CrashReportPage
import com.bobbyesp.crashhandler.ui.theme.CrashHandlerTheme
import java.io.File

class CrashHandlerActivity : ComponentActivity() {
Expand All @@ -27,29 +28,30 @@ class CrashHandlerActivity : ComponentActivity() {
val logfilePath: String = intent.getStringExtra("logfile_path").toString()

setContent {
val clipboardManager = LocalClipboardManager.current
CrashHandlerTheme {
val clipboardManager = LocalClipboardManager.current
var log by rememberSaveable(key = "log") {
mutableStateOf("")
}

var log by rememberSaveable(key = "log") {
mutableStateOf("")
}

LaunchedEffect(true) {
val logFile = File(logfilePath)
log = logFile.readText()
}
LaunchedEffect(true) {
val logFile = File(logfilePath)
log = logFile.readText()
}

CrashReportPage(
versionReport = versionReport,
errorMessage = log
) {
clipboardManager.setText(
AnnotatedString(versionReport).plus(
AnnotatedString(
"\n"
)
).plus(AnnotatedString(log))
)
this.finishAffinity()
CrashReportPage(
versionReport = versionReport,
errorMessage = log
) {
clipboardManager.setText(
AnnotatedString(versionReport).plus(
AnnotatedString(
"\n"
)
).plus(AnnotatedString(log))
)
this.finishAffinity()
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.bobbyesp.crashhandler.ui.theme

import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.dynamicDarkColorScheme
import androidx.compose.material3.dynamicLightColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext

@Composable
fun CrashHandlerTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
content: @Composable () -> Unit
) {
val context = LocalContext.current

//if is android higher than 12, use dynamic color scheme, else use static color scheme based on dark theme
if (android.os.Build.VERSION.SDK_INT >= 31) {
MaterialTheme(
colorScheme = if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(
context
)
) {
content()
}
} else {
MaterialTheme(
colorScheme = if (darkTheme) darkColorScheme() else lightColorScheme()
) {
content()
}
}
}
14 changes: 5 additions & 9 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ room = "2.6.1"
mmkv = "1.3.9"

#Firebase, GMS...
firebaseAuth = "23.0.0"
gmsPlayServicesAuth = "21.2.0"
googleServices = "4.4.2"
firebaseBom = "33.1.2"
Expand Down Expand Up @@ -106,7 +105,6 @@ compose-foundation = { group = "androidx.compose.foundation", name = "foundation
compose-material-iconsExtended = { group = "androidx.compose.material", name = "material-icons-extended" }
compose-animation = { group = "androidx.compose.animation", name = "animation" }
compose-ui = { group = "androidx.compose.ui", name = "ui" }
compose-material = { group = "androidx.compose.material", name = "material" }
compose-ui-util = { group = "androidx.compose.ui", name = "ui-util", version.ref = "compose-util" }
compose-material3 = { group = "androidx.compose.material3", name = "material3", version.ref = "androidx-compose-material3" }
compose-material3-windowSizeClass = { group = "androidx.compose.material3", name = "material3-window-size-class", version.ref = "androidx-compose-material3" }
Expand Down Expand Up @@ -164,6 +162,7 @@ media3-exoplayer = { group = "androidx.media3", name = "media3-exoplayer", versi
media3-ui = { group = "androidx.media3", name = "media3-ui", version.ref = "media3" }
media3-session = { group = "androidx.media3", name = "media3-session", version.ref = "media3" }
media3-common = { group = "androidx.media3", name = "media3-common", version.ref = "media3" }
androidx-media3-datasource-okhttp = { group = "androidx.media3", name = "media3-datasource-okhttp", version.ref = "media3DatasourceOkhttp" }

#LeakCanary
leakcanary = { group = "com.squareup.leakcanary", name = "leakcanary-android", version.ref = "leakcanary" }
Expand All @@ -182,10 +181,10 @@ kotlinx-datetime = { group = "org.jetbrains.kotlinx", name = "kotlinx-datetime",
mmkv = { group = "com.tencent", name = "mmkv", version.ref = "mmkv" }

#Firebase and GMS
firebase-auth = { group = "com.google.firebase", name = "firebase-auth-ktx", version.ref = "firebaseAuth" }
gms-playservices-auth = { group = "com.google.android.gms", name = "play-services-auth", version.ref = "gmsPlayServicesAuth" }
google-services = { group = "com.google.gms", name = "google-services", version.ref = "googleServices" }
gms-playservices-auth = { group = "com.google.android.gms", name = "play-services-auth", version.ref = "gmsPlayServicesAuth" }
firebase-bom = { group = "com.google.firebase", name = "firebase-bom", version.ref = "firebaseBom" }
firebase-auth = { group = "com.google.firebase", name = "firebase-auth-ktx" }
firebase-analytics = { group = "com.google.firebase", name = "firebase-analytics-ktx" }
firebase-crashlytics = { group = "com.google.firebase", name = "firebase-crashlytics-ktx" }

Expand All @@ -207,22 +206,19 @@ compose-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
junit = { group = "junit", name = "junit", version.ref = "junit" }
androidx-test-ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "androidx-test-ext-junit" }
espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espresso-core" }
uiautomator = { group = "androidx.test.uiautomator", name = "uiautomator", version.ref = "uiautomator" }
benchmark-macro-junit4 = { group = "androidx.benchmark", name = "benchmark-macro-junit4", version.ref = "benchmark-macro-junit4" }
profileinstaller = { group = "androidx.profileinstaller", name = "profileinstaller", version.ref = "profileinstaller" }
material = { group = "com.google.android.material", name = "material", version.ref = "materialVersion" }
androidx-media3-datasource-okhttp = { group = "androidx.media3", name = "media3-datasource-okhttp", version.ref = "media3DatasourceOkhttp" }

[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
android-library = { id = "com.android.library", version.ref = "agp" }
android-kotlin = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
kotlin-ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
androidTest = { id = "com.android.test", version.ref = "agp" }
firebase-crashlytics = { id = "com.google.firebase.crashlytics", version.ref = "firebaseCrashlyticsGradle" }
androidx-baselineprofile = { id = "androidx.baselineprofile", version.ref = "androidx-baselineprofile" }
google-gms = { id = "com.google.gms.google-services", version.ref = "googleServices" }

Expand Down

0 comments on commit 2b81364

Please sign in to comment.