feat: add date simulation feature to manipulate system time in dashboard and settings
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
package com.example.data.model
|
||||
|
||||
enum class DateSimulationMode {
|
||||
DISABLED,
|
||||
VISUALIZATION_ONLY,
|
||||
EDIT_PROGRESS
|
||||
}
|
||||
|
||||
data class DateSimulationConfig(
|
||||
val simulatedDateMillis: Long? = null,
|
||||
val mode: DateSimulationMode = DateSimulationMode.DISABLED,
|
||||
val expirationTimestampMillis: Long? = null
|
||||
) {
|
||||
val isActive: Boolean get() = mode != DateSimulationMode.DISABLED && simulatedDateMillis != null
|
||||
}
|
||||
@@ -61,7 +61,8 @@ class MaintenanceRepository(
|
||||
observacao: String?,
|
||||
fotoPath: String?,
|
||||
recurso: String,
|
||||
emailEditor: String?
|
||||
emailEditor: String?,
|
||||
customTimestampMillis: Long? = null
|
||||
) = withContext(Dispatchers.IO) {
|
||||
// Validate system date only when online
|
||||
val isOnline = isCurrentlyConnected()
|
||||
@@ -71,13 +72,14 @@ class MaintenanceRepository(
|
||||
}
|
||||
|
||||
val currentActivity = dao.getActivityByOsOneShot(numeroOs) ?: return@withContext
|
||||
val effectiveTimestamp = customTimestampMillis ?: System.currentTimeMillis()
|
||||
|
||||
val updatedActivity = currentActivity.copy(
|
||||
percentualExecucao = novoPercentual.coerceIn(0, 100),
|
||||
observacoes = observacao ?: currentActivity.observacoes,
|
||||
fotoPath = fotoPath ?: currentActivity.fotoPath,
|
||||
synced = false, // Must sync later
|
||||
lastUpdated = System.currentTimeMillis()
|
||||
lastUpdated = effectiveTimestamp
|
||||
)
|
||||
|
||||
dao.updateActivity(updatedActivity)
|
||||
@@ -85,6 +87,7 @@ class MaintenanceRepository(
|
||||
// Log to history
|
||||
val historyEntry = OSUpdateHistory(
|
||||
numeroOs = numeroOs,
|
||||
timestamp = effectiveTimestamp,
|
||||
percentualAnterior = currentActivity.percentualExecucao,
|
||||
percentualNovo = novoPercentual,
|
||||
observacao = observacao,
|
||||
|
||||
@@ -23,6 +23,7 @@ import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
|
||||
@@ -98,6 +98,7 @@ fun MaintenanceDashboardScreen(
|
||||
val selectedActivityHistory by viewModel.selectedActivityHistory.collectAsStateWithLifecycle()
|
||||
val currentUser by viewModel.currentUser.collectAsStateWithLifecycle()
|
||||
val userAccessLevel by viewModel.userAccessLevel.collectAsStateWithLifecycle()
|
||||
val simulationConfig by viewModel.simulationConfig.collectAsStateWithLifecycle()
|
||||
|
||||
var showEditSheet by remember { mutableStateOf(false) }
|
||||
var showImporterSheet by remember { mutableStateOf(false) }
|
||||
@@ -403,6 +404,11 @@ fun MaintenanceDashboardScreen(
|
||||
.fillMaxSize()
|
||||
.padding(innerPadding)
|
||||
) {
|
||||
// Banner de Alerta de Simulação de Data
|
||||
SimulationAlertBanner(
|
||||
simulationConfig = simulationConfig,
|
||||
onDismiss = { viewModel.clearDateSimulation() }
|
||||
)
|
||||
// Search Bar & Filter Toggle Button
|
||||
Row(
|
||||
modifier = Modifier
|
||||
@@ -1988,13 +1994,76 @@ fun ImporterConsoleSheet(
|
||||
@Composable
|
||||
fun rememberScrollState() = androidx.compose.foundation.rememberScrollState()
|
||||
|
||||
|
||||
|
||||
@Composable
|
||||
fun GoogleIcon(modifier: Modifier = Modifier.size(16.dp)) {
|
||||
androidx.compose.foundation.Image(
|
||||
painter = androidx.compose.ui.res.painterResource(id = com.example.R.drawable.ic_google),
|
||||
contentDescription = "Google Logo",
|
||||
modifier = modifier
|
||||
fun GoogleIcon(modifier: Modifier = Modifier) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.AccountCircle,
|
||||
contentDescription = "Google",
|
||||
modifier = modifier,
|
||||
tint = Color.White
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun SimulationAlertBanner(
|
||||
simulationConfig: com.example.data.model.DateSimulationConfig,
|
||||
onDismiss: () -> Unit
|
||||
) {
|
||||
if (!simulationConfig.isActive || simulationConfig.simulatedDateMillis == null) return
|
||||
|
||||
val sdf = remember { SimpleDateFormat("dd/MM/yyyy", Locale.getDefault()) }
|
||||
val formattedDate = remember(simulationConfig.simulatedDateMillis) {
|
||||
sdf.format(Date(simulationConfig.simulatedDateMillis))
|
||||
}
|
||||
|
||||
val modeLabel = if (simulationConfig.mode == com.example.data.model.DateSimulationMode.EDIT_PROGRESS) {
|
||||
"Edição de OSs"
|
||||
} else {
|
||||
"Visualização"
|
||||
}
|
||||
|
||||
Surface(
|
||||
color = Color(0xFFFFF3E0),
|
||||
contentColor = Color(0xFFE65100),
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp, vertical = 8.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
modifier = Modifier.weight(1f)
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.Warning,
|
||||
contentDescription = "Simulação Ativa",
|
||||
tint = Color(0xFFE65100),
|
||||
modifier = Modifier.size(20.dp)
|
||||
)
|
||||
Text(
|
||||
text = "Modo Simulação: $formattedDate ($modeLabel)",
|
||||
fontSize = 13.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = Color(0xFFE65100)
|
||||
)
|
||||
}
|
||||
|
||||
TextButton(
|
||||
onClick = onDismiss,
|
||||
contentPadding = PaddingValues(horizontal = 8.dp, vertical = 2.dp)
|
||||
) {
|
||||
Text(
|
||||
text = "Desativar Simulação",
|
||||
fontSize = 12.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = Color(0xFFD84315)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +65,12 @@ fun SettingsScreen(
|
||||
val isSyncing by viewModel.isSyncing.collectAsStateWithLifecycle()
|
||||
val conflictLogs by viewModel.conflictLogs.collectAsStateWithLifecycle()
|
||||
val appLogs by viewModel.appLogsState.collectAsStateWithLifecycle()
|
||||
val userAccessLevel by viewModel.userAccessLevel.collectAsStateWithLifecycle()
|
||||
val simulationConfig by viewModel.simulationConfig.collectAsStateWithLifecycle()
|
||||
|
||||
val hasTotalAccess = remember(userAccessLevel) {
|
||||
userAccessLevel?.trim()?.equals("total", ignoreCase = true) == true
|
||||
}
|
||||
|
||||
var showClearCacheDialog by remember { mutableStateOf(false) }
|
||||
var showConflictsDialog by remember { mutableStateOf(false) }
|
||||
@@ -317,6 +323,18 @@ fun SettingsScreen(
|
||||
}
|
||||
}
|
||||
|
||||
// Seção: Simulação de Data
|
||||
DateSimulationSection(
|
||||
hasTotalAccess = hasTotalAccess,
|
||||
simulationConfig = simulationConfig,
|
||||
onActivateSimulation = { dateMillis, mode ->
|
||||
viewModel.setDateSimulation(dateMillis, mode)
|
||||
},
|
||||
onClearSimulation = {
|
||||
viewModel.clearDateSimulation()
|
||||
}
|
||||
)
|
||||
|
||||
// Seção 3: Painel do Administrador
|
||||
Column {
|
||||
Text(
|
||||
@@ -438,6 +456,242 @@ fun SettingsScreen(
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun DateSimulationSection(
|
||||
hasTotalAccess: Boolean,
|
||||
simulationConfig: com.example.data.model.DateSimulationConfig,
|
||||
onActivateSimulation: (dateMillis: Long, mode: com.example.data.model.DateSimulationMode) -> Unit,
|
||||
onClearSimulation: () -> Unit
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
var showDatePicker by remember { mutableStateOf(false) }
|
||||
var selectedDateMillis by remember(simulationConfig.simulatedDateMillis) {
|
||||
mutableLongStateOf(simulationConfig.simulatedDateMillis ?: System.currentTimeMillis())
|
||||
}
|
||||
var selectedMode by remember(simulationConfig.mode) {
|
||||
mutableStateOf(
|
||||
if (simulationConfig.mode == com.example.data.model.DateSimulationMode.DISABLED)
|
||||
com.example.data.model.DateSimulationMode.VISUALIZATION_ONLY
|
||||
else simulationConfig.mode
|
||||
)
|
||||
}
|
||||
|
||||
val dateFormatter = remember { SimpleDateFormat("dd/MM/yyyy", Locale.getDefault()) }
|
||||
val formattedDate = remember(selectedDateMillis) { dateFormatter.format(Date(selectedDateMillis)) }
|
||||
|
||||
Column {
|
||||
Text(
|
||||
text = "Simulação de Data do Sistema",
|
||||
fontSize = 20.sp,
|
||||
fontWeight = FontWeight.Black,
|
||||
color = Color(0xFF0F2644),
|
||||
modifier = Modifier.padding(bottom = 8.dp)
|
||||
)
|
||||
|
||||
Card(
|
||||
colors = CardDefaults.cardColors(containerColor = Color.White),
|
||||
shape = RoundedCornerShape(12.dp),
|
||||
elevation = CardDefaults.cardElevation(defaultElevation = 1.dp),
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(16.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(12.dp)
|
||||
) {
|
||||
if (!hasTotalAccess) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||
modifier = Modifier.padding(vertical = 8.dp)
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.Lock,
|
||||
contentDescription = "Acesso Bloqueado",
|
||||
tint = Color.Gray,
|
||||
modifier = Modifier.size(28.dp)
|
||||
)
|
||||
Column {
|
||||
Text(
|
||||
text = "Simulação de Data Restrita",
|
||||
fontSize = 16.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = Color.Gray
|
||||
)
|
||||
Text(
|
||||
text = "Este recurso requer permissão de Nível Total no aplicativo.",
|
||||
fontSize = 13.sp,
|
||||
color = Color.Gray
|
||||
)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.DateRange,
|
||||
contentDescription = "Simulação de Data",
|
||||
tint = BrandGreen,
|
||||
modifier = Modifier.size(24.dp)
|
||||
)
|
||||
Text(
|
||||
text = if (simulationConfig.isActive) "Simulação Ativa" else "Configurar Simulação",
|
||||
fontSize = 16.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = BrandBlack
|
||||
)
|
||||
}
|
||||
|
||||
HorizontalDivider(color = Color(0xFFE5E5E5))
|
||||
|
||||
// Seleção de Data
|
||||
Text(
|
||||
text = "Data para Simulação:",
|
||||
fontSize = 14.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = BrandBlack
|
||||
)
|
||||
|
||||
OutlinedButton(
|
||||
onClick = { showDatePicker = true },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
shape = RoundedCornerShape(8.dp),
|
||||
border = BorderStroke(1.dp, BrandGreen)
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.CalendarToday,
|
||||
contentDescription = "Calendário",
|
||||
tint = BrandGreen,
|
||||
modifier = Modifier.size(18.dp)
|
||||
)
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
Text(
|
||||
text = "Data Selecionada: $formattedDate",
|
||||
color = BrandBlack,
|
||||
fontWeight = FontWeight.Bold
|
||||
)
|
||||
}
|
||||
|
||||
// Seleção de Modo
|
||||
Text(
|
||||
text = "Modo de Simulação:",
|
||||
fontSize = 14.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = BrandBlack
|
||||
)
|
||||
|
||||
Column(verticalArrangement = Arrangement.spacedBy(4.dp)) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clickable { selectedMode = com.example.data.model.DateSimulationMode.VISUALIZATION_ONLY }
|
||||
) {
|
||||
RadioButton(
|
||||
selected = selectedMode == com.example.data.model.DateSimulationMode.VISUALIZATION_ONLY,
|
||||
onClick = { selectedMode = com.example.data.model.DateSimulationMode.VISUALIZATION_ONLY },
|
||||
colors = RadioButtonDefaults.colors(selectedColor = BrandGreen)
|
||||
)
|
||||
Text(
|
||||
text = "Somente Simulação para Visualização",
|
||||
fontSize = 14.sp,
|
||||
color = BrandBlack
|
||||
)
|
||||
}
|
||||
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clickable { selectedMode = com.example.data.model.DateSimulationMode.EDIT_PROGRESS }
|
||||
) {
|
||||
RadioButton(
|
||||
selected = selectedMode == com.example.data.model.DateSimulationMode.EDIT_PROGRESS,
|
||||
onClick = { selectedMode = com.example.data.model.DateSimulationMode.EDIT_PROGRESS },
|
||||
colors = RadioButtonDefaults.colors(selectedColor = BrandGreen)
|
||||
)
|
||||
Text(
|
||||
text = "Simulação para Edição do Progresso das Ordens",
|
||||
fontSize = 14.sp,
|
||||
color = BrandBlack
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Text(
|
||||
text = "Nota: A simulação se encerra automaticamente após 15 minutos de uso contínuo.",
|
||||
fontSize = 11.sp,
|
||||
color = Color.Gray
|
||||
)
|
||||
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
||||
) {
|
||||
Button(
|
||||
onClick = {
|
||||
onActivateSimulation(selectedDateMillis, selectedMode)
|
||||
Toast.makeText(context, "Simulação de data ativada!", Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
colors = ButtonDefaults.buttonColors(containerColor = BrandGreen),
|
||||
shape = RoundedCornerShape(8.dp),
|
||||
modifier = Modifier.weight(1f)
|
||||
) {
|
||||
Text("Ativar Simulação", fontWeight = FontWeight.Bold, color = Color.White)
|
||||
}
|
||||
|
||||
if (simulationConfig.isActive) {
|
||||
OutlinedButton(
|
||||
onClick = {
|
||||
onClearSimulation()
|
||||
Toast.makeText(context, "Simulação encerrada.", Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
shape = RoundedCornerShape(8.dp),
|
||||
border = BorderStroke(1.dp, Color.Red),
|
||||
modifier = Modifier.weight(1f)
|
||||
) {
|
||||
Text("Restaurar Data Real", fontWeight = FontWeight.Bold, color = Color.Red)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (showDatePicker) {
|
||||
val datePickerState = rememberDatePickerState(
|
||||
initialSelectedDateMillis = selectedDateMillis
|
||||
)
|
||||
DatePickerDialog(
|
||||
onDismissRequest = { showDatePicker = false },
|
||||
confirmButton = {
|
||||
TextButton(
|
||||
onClick = {
|
||||
datePickerState.selectedDateMillis?.let {
|
||||
selectedDateMillis = it
|
||||
}
|
||||
showDatePicker = false
|
||||
}
|
||||
) {
|
||||
Text("OK", fontWeight = FontWeight.Bold, color = BrandGreen)
|
||||
}
|
||||
},
|
||||
dismissButton = {
|
||||
TextButton(onClick = { showDatePicker = false }) {
|
||||
Text("Cancelar")
|
||||
}
|
||||
}
|
||||
) {
|
||||
DatePicker(state = datePickerState)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun ConflictsDialog(
|
||||
|
||||
@@ -12,10 +12,12 @@ import com.example.data.model.SyncConflictLog
|
||||
import com.example.data.model.extractDateOnly
|
||||
import com.example.data.model.formatToShortDate
|
||||
import com.example.data.model.parseFullDateTime
|
||||
import com.example.data.model.AnalyticsState
|
||||
import com.example.data.model.parseDateOnly
|
||||
import com.example.data.repository.MaintenanceRepository
|
||||
import com.example.data.repository.SyncResult
|
||||
import com.example.data.model.AnalyticsState
|
||||
import com.example.data.model.parseDateOnly
|
||||
import com.example.data.model.DateSimulationConfig
|
||||
import com.example.data.model.DateSimulationMode
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.flowOn
|
||||
import java.util.Calendar
|
||||
@@ -81,6 +83,36 @@ class MaintenanceViewModel(private val repository: MaintenanceRepository) : View
|
||||
private val _selectedActivity = MutableStateFlow<MaintenanceActivity?>(null)
|
||||
val selectedActivity = _selectedActivity.asStateFlow()
|
||||
|
||||
// Simulation state
|
||||
private val _simulationConfig = MutableStateFlow(DateSimulationConfig())
|
||||
val simulationConfig: StateFlow<DateSimulationConfig> = _simulationConfig.asStateFlow()
|
||||
|
||||
private var simulationTimerJob: kotlinx.coroutines.Job? = null
|
||||
|
||||
fun setDateSimulation(simulatedDateMillis: Long, mode: DateSimulationMode) {
|
||||
simulationTimerJob?.cancel()
|
||||
val expirationMs = System.currentTimeMillis() + 15 * 60 * 1000L // 15 min
|
||||
_simulationConfig.value = DateSimulationConfig(
|
||||
simulatedDateMillis = simulatedDateMillis,
|
||||
mode = mode,
|
||||
expirationTimestampMillis = expirationMs
|
||||
)
|
||||
|
||||
simulationTimerJob = viewModelScope.launch {
|
||||
kotlinx.coroutines.delay(15 * 60 * 1000L)
|
||||
clearDateSimulation(byTimeout = true)
|
||||
}
|
||||
}
|
||||
|
||||
fun clearDateSimulation(byTimeout: Boolean = false) {
|
||||
simulationTimerJob?.cancel()
|
||||
simulationTimerJob = null
|
||||
_simulationConfig.value = DateSimulationConfig()
|
||||
if (byTimeout) {
|
||||
_syncStatusMessage.value = "Tempo máximo de 15 minutos no modo simulação atingido. A simulação foi encerrada."
|
||||
}
|
||||
}
|
||||
|
||||
// All activities from repository
|
||||
val allActivitiesState: StateFlow<List<MaintenanceActivity>> = repository.allActivities
|
||||
.stateIn(
|
||||
@@ -173,9 +205,11 @@ class MaintenanceViewModel(private val repository: MaintenanceRepository) : View
|
||||
val analyticsState: StateFlow<AnalyticsState> = combine(
|
||||
repository.allActivities,
|
||||
repository.allHistory,
|
||||
_selectedSetorSCurve
|
||||
) { activities, history, setorSCurve ->
|
||||
calculateAnalyticsState(activities, history, selectedSetorSCurve = setorSCurve)
|
||||
_selectedSetorSCurve,
|
||||
_simulationConfig
|
||||
) { activities, history, setorSCurve, simConfig ->
|
||||
val refDate = if (simConfig.isActive && simConfig.simulatedDateMillis != null) Date(simConfig.simulatedDateMillis) else null
|
||||
calculateAnalyticsState(activities, history, referenceDateOverride = refDate, selectedSetorSCurve = setorSCurve)
|
||||
}
|
||||
.flowOn(Dispatchers.Default)
|
||||
.stateIn(
|
||||
@@ -451,7 +485,13 @@ class MaintenanceViewModel(private val repository: MaintenanceRepository) : View
|
||||
return@launch
|
||||
}
|
||||
try {
|
||||
repository.updateProgress(numeroOs, novoPercentual, observacao, fotoPath, recurso, emailEditor)
|
||||
val currentSim = _simulationConfig.value
|
||||
val customTimestamp = if (currentSim.mode == DateSimulationMode.EDIT_PROGRESS) {
|
||||
currentSim.simulatedDateMillis
|
||||
} else {
|
||||
null
|
||||
}
|
||||
repository.updateProgress(numeroOs, novoPercentual, observacao, fotoPath, recurso, emailEditor, customTimestamp)
|
||||
} catch (e: Exception) {
|
||||
_syncStatusMessage.value = e.message ?: "Erro ao atualizar a OS."
|
||||
return@launch
|
||||
|
||||
@@ -109,6 +109,9 @@ Para expandir o aplicativo de sua estrutura atual de tela única ("Single Screen
|
||||
* *Recurso:* Formulário para alterar dinamicamente o ID da Planilha Google Sheets ativa.
|
||||
* *Recurso:* Status de cota e conexão da API do Google, permitindo testar credenciais em tempo real.
|
||||
* *Recurso:* Console para forçar limpezas na base SQLite ou exportar backup do banco de dados local.
|
||||
5. **Módulo de Simulação de Data do Sistema (`SettingsScreen` / `DateSimulationSection`):**
|
||||
* *Recurso:* Painel com controle de permissão por **Nível Total**. Permite escolher a data simulada (Material3 `DatePickerDialog`) e o modo (*Somente Visualização* vs *Edição do Progresso das Ordens*).
|
||||
* *Recurso:* Possui encerramento automático após **15 minutos** de simulação contínua e exibe banner de alerta no topo do Dashboard indicando a data simulada, modo ativo e ação de desativação rápida.
|
||||
|
||||
### 3.2. Proposta de Recursos Técnicos para Implementação Visando Complexidade
|
||||
1. **Câmera Nativa com Upload Real (Firebase Storage), Suporte a HEIC e Compactação (<= 500KB):**
|
||||
|
||||
@@ -87,3 +87,24 @@ Abaixo está o levantamento detalhado de cada um desses elementos, com suas resp
|
||||
* **Descrição Técnica:**
|
||||
Anteriormente, o sistema realizava o carregamento automático de dados simulados/modelo (`loadSampleData()`) caso ocorresse uma falha na primeira sincronização com as planilhas do Google Sheets ou através de botões manuais na UI. Este mecanismo de fallback de dados fictícios foi removido do aplicativo.
|
||||
* **Impacto/Limitação:** O aplicativo não popula mais dados simulados automaticamente ou sob demanda na base SQLite local, garantindo integridade estrita aos dados reais vindos das planilhas Google Sheets ou de importação manual do CSV real do PCM. Se a sincronização inicial falhar e o banco local estiver vazio, o aplicativo exibirá a falha de sincronização e manterá a listagem limpa.
|
||||
|
||||
---
|
||||
|
||||
## 6. Simulação de Data do Sistema e Modos de Operação (Visualização / Edição)
|
||||
|
||||
* **Status:** **IMPLEMENTADO (Produção)**
|
||||
* **Arquivos Relacionados:**
|
||||
* [`DateSimulationState.kt`](file:///home/cesarjhony/dev/projects/gestao_de_manutencao/app/src/main/java/com/example/data/model/DateSimulationState.kt)
|
||||
* [`MaintenanceViewModel.kt`](file:///home/cesarjhony/dev/projects/gestao_de_manutencao/app/src/main/java/com/example/ui/viewmodel/MaintenanceViewModel.kt)
|
||||
* [`MaintenanceRepository.kt`](file:///home/cesarjhony/dev/projects/gestao_de_manutencao/app/src/main/java/com/example/data/repository/MaintenanceRepository.kt)
|
||||
* [`SettingsScreen.kt`](file:///home/cesarjhony/dev/projects/gestao_de_manutencao/app/src/main/java/com/example/ui/screens/SettingsScreen.kt)
|
||||
* [`MaintenanceDashboardScreen.kt`](file:///home/cesarjhony/dev/projects/gestao_de_manutencao/app/src/main/java/com/example/ui/screens/MaintenanceDashboardScreen.kt)
|
||||
* **Descrição Técnica:**
|
||||
Funcionalidade de controle e simulação de data do sistema acessível a partir da tela de Configurações:
|
||||
* **Controle de Acesso:** Acesso liberado exclusivamente para usuários com nível de acesso **Total**. Para usuários de outros níveis, a seção é exibida desabilitada com ícone de cadeado e mensagem indicando a necessidade de permissão Nível Total.
|
||||
* **Modos de Simulação:**
|
||||
* *Somente Visualização:* Altera a data de referência usada nos cálculos de atraso de OSs, linha do tempo e Curva S no Dashboard.
|
||||
* *Edição do Progresso das Ordens:* Além de alterar a referência visual, grava o timestamp da data simulada no histórico (`OSUpdateHistory.timestamp`) e na data de atualização da OS (`lastUpdated`).
|
||||
* **Tempo Máximo (15 Minutos):** A simulação possui um timer regressivo automático de **15 minutos**. Ao atingir esse tempo limite, o aplicativo encerra a simulação, retorna à data real e emite um aviso informativo.
|
||||
* **Banner Visual de Alerta:** Um banner no topo das telas principais indica o modo de simulação ativo, a data simulada e disponibiliza um botão rápido para *"Desativar Simulação"*.
|
||||
* **Reset Automático:** O estado da simulação reside exclusivamente em memória e reseta automaticamente para a data real ao reiniciar ou fechar o aplicativo.
|
||||
|
||||
Reference in New Issue
Block a user