feat: add maintainers section to info screen and improve photo sharing logic by enhancing file path resolution

This commit is contained in:
Jhony Cesar
2026-08-07 08:37:33 -04:00
parent aaa5871292
commit c0dfd700a0
10 changed files with 282 additions and 29 deletions

View File

@@ -17,8 +17,8 @@ android {
applicationId = "com.aistudio.gestaoparadaos.xvyzwt"
minSdk = 24
targetSdk = 36
versionCode = 1
versionName = "1.0"
versionCode = 2
versionName = "1.1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

View File

@@ -12,10 +12,14 @@ import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowForward
import androidx.compose.material.icons.filled.Code
import androidx.compose.material.icons.filled.Description
import androidx.compose.material.icons.filled.Email
import androidx.compose.material.icons.filled.Info
import androidx.compose.material.icons.filled.Link
import androidx.compose.material.icons.filled.Lock
import androidx.compose.material.icons.filled.OpenInNew
import androidx.compose.material.icons.filled.Person
import androidx.compose.material.icons.filled.Refresh
import androidx.compose.material.icons.filled.Security
import androidx.compose.material3.*
@@ -156,7 +160,7 @@ fun ImportantInfoScreen(
)
Spacer(modifier = Modifier.height(2.dp))
Text(
text = if (isNetworkConnected) "Sincronizado com a planilha online (Aba config)" else "Modo Offline (Links armazenados localmente)",
text = if (isNetworkConnected) "Sincronizado com o BD online" else "Modo Offline (Links armazenados localmente)",
fontSize = 12.sp,
color = if (isNetworkConnected) BrandGreen else Color(0xFFD97706)
)
@@ -173,7 +177,7 @@ fun ImportantInfoScreen(
modifier = Modifier.padding(start = 4.dp, bottom = 8.dp)
)
// Links List
// Links List + Responsáveis
LazyColumn(
verticalArrangement = Arrangement.spacedBy(12.dp),
modifier = Modifier.fillMaxWidth()
@@ -184,6 +188,28 @@ fun ImportantInfoScreen(
onOpenUrl = { openUrl(linkItem.url) }
)
}
item {
Spacer(modifier = Modifier.height(8.dp))
Text(
text = "RESPONSÁVEIS PELO APLICATIVO",
fontSize = 12.sp,
fontWeight = FontWeight.Bold,
color = Color.Gray,
modifier = Modifier.padding(start = 4.dp, bottom = 8.dp)
)
AppMaintainersCard(
onSendEmail = { email ->
try {
val intent = Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:$email"))
context.startActivity(intent)
} catch (e: Exception) {
Toast.makeText(context, "E-mail: $email", Toast.LENGTH_SHORT).show()
}
}
)
}
}
}
}
@@ -199,6 +225,7 @@ fun ImportantLinkCard(
"1" -> Icons.Default.Security to Color(0xFF0284C7)
"2" -> Icons.Default.Lock to Color(0xFF7C3AED)
"3" -> Icons.Default.Description to Color(0xFF059669)
"4" -> Icons.Default.Link to Color(0xFFEA580C)
else -> Icons.Default.OpenInNew to BrandGreen
}
@@ -287,3 +314,102 @@ fun ImportantLinkCard(
}
}
}
@Composable
fun AppMaintainersCard(
onSendEmail: (String) -> Unit,
modifier: Modifier = Modifier
) {
Card(
modifier = modifier.fillMaxWidth(),
shape = RoundedCornerShape(14.dp),
colors = CardDefaults.cardColors(containerColor = Color.White),
elevation = CardDefaults.cardElevation(defaultElevation = 2.dp)
) {
Column(
modifier = Modifier
.fillMaxWidth()
.padding(16.dp)
) {
MaintainerRow(
role = "Desenvolvedor",
email = "cesarjhony+dev@gmail.com",
icon = Icons.Default.Code,
badgeColor = Color(0xFF0284C7),
onSendEmail = onSendEmail
)
HorizontalDivider(
modifier = Modifier.padding(vertical = 12.dp),
color = LightGrey
)
MaintainerRow(
role = "Responsável",
email = "gabrielpizzinatto123@gmail.com",
icon = Icons.Default.Person,
badgeColor = BrandGreen,
onSendEmail = onSendEmail
)
}
}
}
@Composable
private fun MaintainerRow(
role: String,
email: String,
icon: ImageVector,
badgeColor: Color,
onSendEmail: (String) -> Unit
) {
Row(
modifier = Modifier
.fillMaxWidth()
.clickable { onSendEmail(email) },
verticalAlignment = Alignment.CenterVertically
) {
Box(
modifier = Modifier
.size(40.dp)
.clip(RoundedCornerShape(10.dp))
.background(badgeColor.copy(alpha = 0.1f)),
contentAlignment = Alignment.Center
) {
Icon(
imageVector = icon,
contentDescription = role,
tint = badgeColor,
modifier = Modifier.size(20.dp)
)
}
Spacer(modifier = Modifier.width(12.dp))
Column(modifier = Modifier.weight(1f)) {
Text(
text = role,
fontSize = 12.sp,
fontWeight = FontWeight.SemiBold,
color = Color.Gray
)
Spacer(modifier = Modifier.height(2.dp))
Text(
text = email,
fontSize = 14.sp,
fontWeight = FontWeight.Bold,
color = BrandBlack,
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
}
Icon(
imageVector = Icons.Default.Email,
contentDescription = "Enviar E-mail",
tint = badgeColor,
modifier = Modifier.size(20.dp)
)
}
}

View File

@@ -1303,30 +1303,49 @@ fun FullscreenPhotoViewerDialog(
IconButton(
onClick = {
try {
if (photoPath.startsWith("/")) {
val file = java.io.File(photoPath)
if (file.exists()) {
val uri = androidx.core.content.FileProvider.getUriForFile(
context,
"${context.packageName}.fileprovider",
file
)
val shareIntent = android.content.Intent(android.content.Intent.ACTION_SEND).apply {
type = "image/jpeg"
putExtra(android.content.Intent.EXTRA_STREAM, uri)
addFlags(android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION)
}
context.startActivity(android.content.Intent.createChooser(shareIntent, "Compartilhar Foto OS"))
} else {
Toast.makeText(context, "Arquivo local não encontrado", Toast.LENGTH_SHORT).show()
val resolvedModel = resolvePhotoModel(photoPath, context)
var targetFile: java.io.File? = null
if (resolvedModel.startsWith("/")) {
val f = java.io.File(resolvedModel)
if (f.exists()) targetFile = f
}
if (targetFile == null && photoPath.startsWith("/")) {
val f = java.io.File(photoPath)
if (f.exists()) targetFile = f
}
if (targetFile == null) {
val cleanPathForName = photoPath.substringBefore("?").substringBefore("#").replace("%2F", "/", ignoreCase = true)
val fileName = cleanPathForName.substringAfterLast("/").substringAfterLast("\\")
.removeSuffix("_DELETED").removeSuffix(".jpg_DELETED").replace("_DELETED", "")
if (fileName.isNotBlank()) {
val photosDir = java.io.File(context.filesDir, "os_photos")
val cachedFile = java.io.File(photosDir, fileName)
if (cachedFile.exists()) targetFile = cachedFile
}
} else {
}
if (targetFile != null && targetFile.exists()) {
val uri = androidx.core.content.FileProvider.getUriForFile(
context,
"${context.packageName}.fileprovider",
targetFile
)
val shareIntent = android.content.Intent(android.content.Intent.ACTION_SEND).apply {
type = "image/jpeg"
putExtra(android.content.Intent.EXTRA_STREAM, uri)
addFlags(android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION)
}
context.startActivity(android.content.Intent.createChooser(shareIntent, "Compartilhar Foto OS"))
} else if (resolvedModel.startsWith("http://") || resolvedModel.startsWith("https://")) {
val shareIntent = android.content.Intent(android.content.Intent.ACTION_SEND).apply {
type = "text/plain"
putExtra(android.content.Intent.EXTRA_SUBJECT, "Foto OS $osNumber")
putExtra(android.content.Intent.EXTRA_TEXT, photoPath)
putExtra(android.content.Intent.EXTRA_TEXT, resolvedModel)
}
context.startActivity(android.content.Intent.createChooser(shareIntent, "Compartilhar Link da Foto"))
} else {
Toast.makeText(context, "Arquivo da foto não encontrado localmente", Toast.LENGTH_SHORT).show()
}
} catch (e: Exception) {
Toast.makeText(context, "Erro ao compartilhar: ${e.message}", Toast.LENGTH_SHORT).show()

View File

@@ -83,6 +83,29 @@ class MaintenanceViewModel(private val repository: MaintenanceRepository) : View
)
)
}
val link4Obj = configMap["Link4"]
val link4Url = link4Obj?.value?.trim()?.takeIf { it.isNotBlank() }
if (link4Obj != null && link4Url != null) {
val descObj = configMap["DescricaoLink4"]
val title = descObj?.value?.trim()?.takeIf { it.isNotBlank() }
?: descObj?.description?.trim()?.takeIf { it.isNotBlank() }
?: link4Obj.description?.trim()?.takeIf { it.isNotBlank() }
?: "Link 4"
val description = link4Obj.description?.trim()?.takeIf { it.isNotBlank() }
?: descObj?.description?.trim()?.takeIf { it.isNotBlank() }
result.add(
com.example.data.model.ImportantLink(
id = "4",
title = title,
url = link4Url,
description = description
)
)
}
return result
}

View File

@@ -46,7 +46,7 @@ object DeviceUtils {
fun getAppVersion(context: Context): String {
return try {
val packageInfo = context.packageManager.getPackageInfo(context.packageName, 0)
val versionName = packageInfo.versionName ?: "1.0.0"
val versionName = packageInfo.versionName ?: "1.1.0"
@Suppress("DEPRECATION")
val versionCode = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
packageInfo.longVersionCode
@@ -55,7 +55,7 @@ object DeviceUtils {
}
"$versionName (v$versionCode)"
} catch (e: Exception) {
"1.0.0"
"1.1.0"
}
}
}

View File

@@ -35,4 +35,45 @@ class AppConfigTest {
assertEquals("https://forms.office.com/test", link.url)
assertEquals("Link para ser exibido na tela de informações", link.description)
}
@Test
fun testLink4ParsingLogic_whenPresent_includesFourthLink() {
val configs = listOf(
AppConfig("Link1", "https://example.com/1", "Desc 1"),
AppConfig("DescricaoLink1", "Título 1", null),
AppConfig("Link4", "https://example.com/4", "Link 4 Descrição"),
AppConfig("DescricaoLink4", "Manual do Usuário", null)
)
val configMap = configs.associateBy { it.key }
val link4Obj = configMap["Link4"]
val link4Url = link4Obj?.value?.trim()?.takeIf { it.isNotBlank() }
val descObj = configMap["DescricaoLink4"]
val title = descObj?.value?.trim()?.takeIf { it.isNotBlank() } ?: "Link 4"
assertNotNull(link4Url)
assertEquals("https://example.com/4", link4Url)
assertEquals("Manual do Usuário", title)
}
@Test
fun testLink4ParsingLogic_whenAbsentOrBlank_hidesFourthLink() {
val configsWithoutLink4 = listOf(
AppConfig("Link1", "https://example.com/1", "Desc 1"),
AppConfig("DescricaoLink1", "Título 1", null)
)
val mapWithoutLink4 = configsWithoutLink4.associateBy { it.key }
val link4Obj1 = mapWithoutLink4["Link4"]
val link4Url1 = link4Obj1?.value?.trim()?.takeIf { it.isNotBlank() }
assertEquals(null, link4Url1)
val configsWithBlankLink4 = listOf(
AppConfig("Link4", " ", "Desc 4")
)
val mapWithBlankLink4 = configsWithBlankLink4.associateBy { it.key }
val link4Obj2 = mapWithBlankLink4["Link4"]
val link4Url2 = link4Obj2?.value?.trim()?.takeIf { it.isNotBlank() }
assertEquals(null, link4Url2)
}
}

View File

@@ -54,7 +54,7 @@ class DeviceUtilsTest {
email = "teste@empresa.com",
nomeUsuario = "Usuario Teste",
versaoAndroid = "Android 14 (API 34)",
versaoApp = "1.0.0 (v1)",
versaoApp = "1.1.0 (v2)",
ultimoAcesso = "2026-08-06 12:00:00",
statusSincronizacao = "Sucesso"
)
@@ -63,7 +63,7 @@ class DeviceUtilsTest {
assertEquals("teste@empresa.com", info.email)
assertEquals("Usuario Teste", info.nomeUsuario)
assertEquals("Android 14 (API 34)", info.versaoAndroid)
assertEquals("1.0.0 (v1)", info.versaoApp)
assertEquals("1.1.0 (v2)", info.versaoApp)
assertEquals("2026-08-06 12:00:00", info.ultimoAcesso)
assertEquals("Sucesso", info.statusSincronizacao)
}