Inicio de proyecto

This commit is contained in:
2026-06-24 11:49:46 +02:00
commit 848d3b47d1
50 changed files with 1424 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
/build
+68
View File
@@ -0,0 +1,68 @@
plugins {
// Solo dejamos el plugin de la aplicación Android base
alias(libs.plugins.android.application)
// El de Kotlin estándar se aplica automáticamente con el anterior en versiones modernas
}
android {
namespace = "com.example.kilometrapp"
compileSdk = 35
defaultConfig {
applicationId = "com.example.kilometrapp"
minSdk = 26
targetSdk = 35
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}
dependencies {
// Soporte para interfaces de usuario y vistas XML clásicas
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("com.google.android.material:material:1.11.0")
implementation(libs.androidx.core.ktx)
// Librerías de la cámara (CameraX)
implementation("androidx.camera:camera-camera2:1.4.0")
implementation("androidx.camera:camera-lifecycle:1.4.0")
implementation("androidx.camera:camera-view:1.4.0")
// OCR mediante Google Play Services para tu Realme GT
implementation("com.google.android.gms:play-services-mlkit-text-recognition:19.0.1")
// Conector MySQL (Mucho más estable en Android para bases de datos MariaDB/MySQL)
implementation("mysql:mysql-connector-java:5.1.49")
// LINEA CRUCIAL: Añade esto para evitar que la cámara cierre la app al abrirse
implementation("com.google.guava:guava:33.0.0-android")
// Dependencias básicas del sistema
implementation(libs.androidx.lifecycle.runtime.ktx)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
}
@@ -0,0 +1,24 @@
package com.example.kilometrapp
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.Assert.*
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.example.kilometrapp", appContext.packageName)
}
}
+35
View File
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<!-- Permiso obligatorio para abrir la cámara -->
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<!-- Indica al sistema que la app necesita una cámara para funcionar -->
<uses-feature android:name="android.hardware.camera" android:required="true" />
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Kilometrapp">
<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.Kilometrapp"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

@@ -0,0 +1,305 @@
package com.example.kilometrapp // <-- Asegúrate de que este es tu paquete exacto
import android.Manifest
import android.content.pm.PackageManager
import android.graphics.Rect
import android.view.ScaleGestureDetector
import android.os.Bundle
import android.util.Log
import android.widget.Button
import android.widget.TextView
import android.widget.Toast
import androidx.activity.result.contract.ActivityResultContracts
import androidx.annotation.OptIn
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.camera.core.*
import androidx.camera.lifecycle.ProcessCameraProvider
import androidx.camera.view.PreviewView
import androidx.core.content.ContextCompat
import com.google.mlkit.vision.common.InputImage
import com.google.mlkit.vision.text.Text
import com.google.mlkit.vision.text.TextRecognition
import com.google.mlkit.vision.text.latin.TextRecognizerOptions
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
class MainActivity : AppCompatActivity() {
private lateinit var viewFinder: PreviewView
private lateinit var overlayFrame: android.view.View
private lateinit var tvResult: TextView
private lateinit var btnCapture: Button
private lateinit var cameraExecutor: ExecutorService
private var imageCapture: ImageCapture? = null
private var cameraControl: CameraControl? = null
private var currentZoomRatio = 1f
private var isDialogShowing = false
// Inicializa el OCR con las opciones estándar
private val recognizer = TextRecognition.getClient(TextRecognizerOptions.DEFAULT_OPTIONS)
// Lanzador para solicitar el permiso de forma nativa en pantalla
private val requestPermissionLauncher = registerForActivityResult(
ActivityResultContracts.RequestPermission()
) { isGranted: Boolean ->
if (isGranted) {
viewFinder.post { startCamera() }
} else {
Toast.makeText(this, "Permiso de cámara obligatorio denegado.", Toast.LENGTH_LONG).show()
}
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
try {
setContentView(R.layout.activity_main)
viewFinder = findViewById(R.id.viewFinder)
overlayFrame = findViewById(R.id.overlayFrame)
tvResult = findViewById(R.id.tvResult)
btnCapture = findViewById(R.id.btnCapture)
cameraExecutor = Executors.newSingleThreadExecutor()
// Configurar el detector de gestos de zoom
val scaleGestureDetector = ScaleGestureDetector(this, object : ScaleGestureDetector.SimpleOnScaleGestureListener() {
override fun onScale(detector: ScaleGestureDetector): Boolean {
cameraControl?.let { control ->
val scale = detector.scaleFactor
currentZoomRatio *= scale
// Limitamos el zoom entre 1x y el máximo de la cámara (ej: 8x)
currentZoomRatio = currentZoomRatio.coerceIn(1f, 8f)
control.setZoomRatio(currentZoomRatio)
}
return true
}
})
// Aplicar el detector al visor de la cámara
viewFinder.setOnTouchListener { view, event ->
scaleGestureDetector.onTouchEvent(event)
view.performClick()
true
}
btnCapture.setOnClickListener { takePhoto() }
if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED) {
viewFinder.post { startCamera() }
} else {
requestPermissionLauncher.launch(Manifest.permission.CAMERA)
}
} catch (e: Exception) {
Log.e("Kilometrapp", "Error controlado en UI: ${e.message}")
Toast.makeText(this, "Error en la interfaz: ${e.message}", Toast.LENGTH_LONG).show()
}
}
private fun startCamera() {
val cameraProviderFuture = ProcessCameraProvider.getInstance(this)
cameraProviderFuture.addListener({
try {
val cameraProvider: ProcessCameraProvider = cameraProviderFuture.get()
val preview = Preview.Builder()
.build()
.also {
it.surfaceProvider = viewFinder.surfaceProvider
}
imageCapture = ImageCapture.Builder()
.setCaptureMode(ImageCapture.CAPTURE_MODE_MINIMIZE_LATENCY)
.build()
val cameraSelector = CameraSelector.DEFAULT_BACK_CAMERA
cameraProvider.unbindAll()
val camera = cameraProvider.bindToLifecycle(
this, cameraSelector, preview, imageCapture
)
cameraControl = camera.cameraControl
// Opcional: Establecer un zoom inicial (ej: 2x) para ver mejor el tablero
// cameraControl?.setLinearZoom(0.3f) // 0.0 a 1.0
Log.d("Kilometrapp", "Cámara vinculada correctamente para captura")
} catch (exc: Exception) {
Log.e("Kilometrapp", "Error al inicializar CameraX", exc)
Toast.makeText(this, "Error al abrir la cámara", Toast.LENGTH_SHORT).show()
}
}, ContextCompat.getMainExecutor(this))
}
private fun takePhoto() {
val imageCapture = imageCapture ?: return
imageCapture.takePicture(
ContextCompat.getMainExecutor(this),
object : ImageCapture.OnImageCapturedCallback() {
override fun onCaptureSuccess(imageProxy: ImageProxy) {
processStaticImage(imageProxy)
}
override fun onError(exception: ImageCaptureException) {
Log.e("Kilometrapp", "Error al capturar foto: ${exception.message}")
}
}
)
}
@OptIn(ExperimentalGetImage::class)
private fun processStaticImage(imageProxy: ImageProxy) {
val mediaImage = imageProxy.image
if (mediaImage != null) {
val image = InputImage.fromMediaImage(mediaImage, imageProxy.imageInfo.rotationDegrees)
recognizer.process(image)
.addOnSuccessListener { visionText ->
val bloquesEnCuadro = visionText.textBlocks.filter {
isInsideFocusFrame(it.boundingBox, imageProxy.width, imageProxy.height)
}
if (bloquesEnCuadro.isEmpty()) {
Toast.makeText(this, "No se detectó texto en el recuadro", Toast.LENGTH_SHORT).show()
} else {
showSelectionDialog(bloquesEnCuadro)
}
}
.addOnCompleteListener {
imageProxy.close()
}
} else {
imageProxy.close()
}
}
private fun showSelectionDialog(bloques: List<Text.TextBlock>) {
val candidatos = mutableListOf<String>()
for (bloque in bloques) {
// Buscamos cualquier secuencia de números (de 2 a 8 cifras)
// Esto separará el "22" del "246115" aunque el OCR los pegue
val matches = Regex("\\d{2,8}").findAll(bloque.text)
matches.forEach { match ->
val num = match.value
// Si el número es muy largo (ej: 22246115), intentamos ver si los últimos 6 son el kilometraje
if (num.length >= 7) {
val ultimosSeis = num.takeLast(6)
if (!candidatos.contains(ultimosSeis)) candidatos.add(ultimosSeis)
val primerosDos = num.take(2)
if (!candidatos.contains(primerosDos)) candidatos.add(primerosDos)
} else {
if (!candidatos.contains(num)) candidatos.add(num)
}
}
}
if (candidatos.isEmpty()) {
Toast.makeText(this, "No se encontraron números claros", Toast.LENGTH_SHORT).show()
return
}
// Ordenamos para que los números de 6 cifras (kilometraje habitual) salgan arriba
val listaFinal = candidatos.sortedByDescending { it.length }.toTypedArray()
AlertDialog.Builder(this)
.setTitle("Selecciona el Kilometraje")
.setItems(listaFinal) { _, which ->
val seleccionado = listaFinal[which]
tvResult.text = "$seleccionado KM"
showConfirmationDialog(seleccionado)
}
.setNegativeButton("Cancelar", null)
.show()
}
private fun showConfirmationDialog(kilometraje: String) {
val opciones = arrayOf("Revisión kilómetros", "Cambio de aceite")
AlertDialog.Builder(this)
.setTitle("¿Qué quieres registrar?")
.setMessage("Kilometraje: $kilometraje KM")
.setPositiveButton("Revisión") { _, _ ->
enviarAServidor(kilometraje, "Revision kilometros")
}
.setNeutralButton("Cambio Aceite") { _, _ ->
enviarAServidor(kilometraje, "Cambio de aceite")
}
.setNegativeButton("Reintentar", null)
.show()
}
private fun enviarAServidor(kilometraje: String, observacionesText: String) {
cameraExecutor.execute {
try {
// Usamos el driver de MySQL que es el más estable en Android
Class.forName("com.mysql.jdbc.Driver")
// Datos de conexión
val url = "jdbc:mysql://mariadb.peta9.com:3306/mantenimiento_db"
val user = "pedro"
val pass = "Pedro@110387"
val connection = java.sql.DriverManager.getConnection(url, user, pass)
// Preparar el INSERT (corregido: comas y parámetros)
val sql = "INSERT INTO mantenimiento (kms, observaciones, fecha, foto) VALUES (?, ?, NOW(), null)"
val statement = connection.prepareStatement(sql)
// Extraemos solo los números para guardar como entero
val soloNumeros = kilometraje.filter { it.isDigit() }.toIntOrNull() ?: 0
statement.setInt(1, soloNumeros)
statement.setString(2, observacionesText)
statement.executeUpdate()
connection.close()
runOnUiThread {
Toast.makeText(this, "¡$observacionesText guardado!", Toast.LENGTH_SHORT).show()
}
} catch (e: Throwable) {
Log.e("Kilometrapp", "Error MariaDB: ${e.message}")
runOnUiThread {
Toast.makeText(this, "Error de conexión: ${e.message}", Toast.LENGTH_LONG).show()
}
}
}
}
private fun isInsideFocusFrame(boundingBox: Rect?, imgWidth: Int, imgHeight: Int): Boolean {
if (boundingBox == null) return false
// 1. Obtener dimensiones del visor y del recuadro en pantalla
val viewWidth = viewFinder.width
val viewHeight = viewFinder.height
// 2. Coordenadas del recuadro de enfoque en la pantalla
val frameLeft = overlayFrame.left.toFloat()
val frameTop = overlayFrame.top.toFloat()
val frameRight = overlayFrame.right.toFloat()
val frameBottom = overlayFrame.bottom.toFloat()
// 3. Mapear coordenadas del OCR (que vienen en tamaño de imagen) a coordenadas de pantalla
// Nota: Esto es una simplificación, pero para un recuadro central funciona bien.
val scaleX = viewWidth.toFloat() / imgHeight.toFloat() // CameraX suele invertir W/H por rotación
val scaleY = viewHeight.toFloat() / imgWidth.toFloat()
val rectCenterX = boundingBox.centerX() * scaleX
val rectCenterY = boundingBox.centerY() * scaleY
// 4. Verificar si el centro del texto detectado está dentro del rectángulo rojo
return rectCenterX in frameLeft..frameRight && rectCenterY in frameTop..frameBottom
}
override fun onDestroy() {
super.onDestroy()
cameraExecutor.shutdown()
}
}
+12
View File
@@ -0,0 +1,12 @@
# Add project specific R8 rules here.
# AGP will combine all keep rule files in src/main/keepRules to pass to R8
#
# For more details, see
# https://d.android.com/r/tools/r8/keep-rules
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
android:width="3dp"
android:color="#FF0000" />
<corners android:radius="8dp" />
<solid android:color="#22FF0000" />
</shape>
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<vector
android:height="108dp"
android:width="108dp"
android:viewportHeight="108"
android:viewportWidth="108"
xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#3DDC84"
android:pathData="M0,0h108v108h-108z"/>
<path android:fillColor="#00000000" android:pathData="M9,0L9,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,0L19,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M29,0L29,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M39,0L39,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M49,0L49,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M59,0L59,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M69,0L69,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M79,0L79,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M89,0L89,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M99,0L99,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,9L108,9"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,19L108,19"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,29L108,29"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,39L108,39"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,49L108,49"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,59L108,59"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,69L108,69"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,79L108,79"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,89L108,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,99L108,99"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,29L89,29"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,39L89,39"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,49L89,49"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,59L89,59"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,69L89,69"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,79L89,79"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M29,19L29,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M39,19L39,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M49,19L49,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M59,19L59,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M69,19L69,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M79,19L79,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
</vector>
@@ -0,0 +1,15 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="48"
android:viewportHeight="48">
<path
android:pathData="M24,8c-3.985,0.002 -7.876,0.144 -11.824,0.664c-2.097,0.276 -4.352,0.707 -5.914,2.243c-1.713,1.686 -2.054,4.171 -2.192,6.45c-0.16,2.641 -0.022,5.273 0.143,7.908c0.167,2.595 0.463,5.215 1.106,7.74c0.298,1.171 0.701,2.347 1.391,3.355c0.663,0.967 1.618,1.652 2.688,2.134c2.271,1.023 4.894,1.111 7.348,1.261C19.152,39.899 21.575,39.988 24,40c2.424,-0.012 4.848,-0.101 7.255,-0.246c2.454,-0.151 5.075,-0.238 7.348,-1.261c1.07,-0.479 2.024,-1.167 2.688,-2.134c0.688,-1.009 1.092,-2.185 1.39,-3.355c0.644,-2.524 0.939,-5.145 1.104,-7.738c0.165,-2.635 0.304,-5.269 0.145,-7.909c-0.137,-2.278 -0.48,-4.764 -2.191,-6.449c-1.563,-1.537 -3.816,-1.969 -5.915,-2.244C31.877,8.144 27.985,8.002 24,8L24,8z"
android:fillColor="#37474F"/>
<path
android:pathData="M39.633,13.045c-0.833,-0.82 -2.281,-1.155 -4.199,-1.407C32.1,11.199 28.574,11.002 24,11c-4.575,0.002 -8.101,0.199 -11.432,0.639c-1.548,0.203 -3.277,0.498 -4.202,1.407c-0.961,0.946 -1.194,2.719 -1.301,4.493c-0.15,2.473 -0.019,4.977 0.142,7.539c0.187,2.904 0.51,5.189 1.019,7.188c0.276,1.086 0.581,1.849 0.959,2.402c0.291,0.424 0.776,0.791 1.443,1.092c1.61,0.726 3.729,0.85 5.779,0.971l0.52,0.031c2.507,0.149 4.827,0.228 7.087,0.238c2.211,-0.011 4.596,-0.092 7.06,-0.24l0.536,-0.033c2.137,-0.127 4.155,-0.247 5.762,-0.97c0.666,-0.298 1.15,-0.666 1.444,-1.095c0.375,-0.549 0.681,-1.313 0.957,-2.398c0.51,-2.001 0.833,-4.285 1.018,-7.188c0.16,-2.563 0.293,-5.072 0.144,-7.538C40.828,15.765 40.598,13.994 39.633,13.045z"
android:fillColor="#FF3D00"/>
<path
android:pathData="M31.61,36.727c0.77,-0.046 1.513,-0.101 2.237,-0.173c-0.046,-0.104 -0.074,-0.218 -0.059,-0.36c0.729,-5.49 1.131,-10.996 1.478,-16.522c0.103,-2.318 0.235,-4.642 0.27,-6.962c0.021,-0.249 -0.069,-0.729 0.022,-1.054c-0.043,-0.005 -0.082,-0.012 -0.125,-0.018c-1.039,-0.137 -2.103,-0.247 -3.205,-0.339c-0.807,2.898 -1.738,6.729 -2.566,9.634c-0.665,2.329 -1.428,5.685 -4.313,5.981c-0.43,0.043 -0.888,0.08 -1.35,0.086c-0.462,-0.006 -0.919,-0.043 -1.35,-0.086c-2.885,-0.299 -3.647,-3.652 -4.313,-5.981c-0.829,-2.904 -1.759,-6.735 -2.567,-9.633c-1.102,0.091 -2.165,0.202 -3.203,0.339c-0.042,0.006 -0.085,0.012 -0.127,0.018c0.091,0.324 0.001,0.804 0.023,1.053c0.033,2.32 0.167,4.645 0.269,6.962c0.345,5.526 0.748,11.032 1.478,16.522c0.015,0.136 -0.002,0.254 -0.033,0.364c0.736,0.074 1.484,0.129 2.23,0.173l0.52,0.031c0.527,0.031 1.041,0.058 1.553,0.083c0.196,-0.649 1.083,-3.469 1.083,-3.469c0.689,-2.214 0.67,-2.842 2.437,-3.185c0.587,-0.114 1.256,-0.188 1.934,-0.191c0.677,0.003 1.347,0.077 1.934,0.191c1.768,0.343 1.883,0.971 2.57,3.185c0,0 0.887,2.815 1.084,3.468c0.514,-0.025 1.03,-0.053 1.553,-0.084L31.61,36.727z"
android:fillColor="#FFF"/>
</vector>
+86
View File
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<!-- Vista en vivo de la cámara -->
<androidx.camera.view.PreviewView
android:id="@+id/viewFinder"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/containerResultado"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<!-- Recuadro de enfoque (Overlay) -->
<View
android:id="@+id/overlayFrame"
android:layout_width="200dp"
android:layout_height="200dp"
android:background="@drawable/focus_frame"
app:layout_constraintTop_toTopOf="@id/viewFinder"
app:layout_constraintBottom_toBottomOf="@id/viewFinder"
app:layout_constraintStart_toStartOf="@id/viewFinder"
app:layout_constraintEnd_toEndOf="@id/viewFinder" />
<TextView
android:id="@+id/tvInstrucciones"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ENCUADRA Y PULSA CAPTURAR"
android:textColor="#FF0000"
android:textSize="12sp"
android:textStyle="bold"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="@id/overlayFrame"
app:layout_constraintStart_toStartOf="@id/overlayFrame"
app:layout_constraintEnd_toEndOf="@id/overlayFrame" />
<Button
android:id="@+id/btnCapture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CAPTURAR"
android:layout_marginBottom="16dp"
app:layout_constraintBottom_toBottomOf="@id/viewFinder"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<!-- Contenedor inferior para mostrar los kilómetros detectados -->
<LinearLayout
android:id="@+id/containerResultado"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="24dp"
android:background="#1E1E1E"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Kilometraje Detectado:"
android:textColor="#999999"
android:textSize="14sp"
android:layout_gravity="center_horizontal" />
<TextView
android:id="@+id/tvResult"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Buscando cuentakilómetros..."
android:textColor="#FFFFFF"
android:textSize="22sp"
android:textStyle="bold"
android:layout_marginTop="8dp"
android:layout_gravity="center_horizontal" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
<monochrome android:drawable="@drawable/ic_launcher_foreground"/>
</adaptive-icon>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
<monochrome android:drawable="@drawable/ic_launcher_foreground"/>
</adaptive-icon>
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

+10
View File
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="purple_200">#FFBB86FC</color>
<color name="purple_500">#FF6200EE</color>
<color name="purple_700">#FF3700B3</color>
<color name="teal_200">#FF03DAC5</color>
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
</resources>
+3
View File
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">Mantenimiento</string>
</resources>
+14
View File
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Tema principal adaptado a Realme GT / Oplus Framework -->
<style name="Theme.Kilometrapp" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Colores base -->
<item name="colorPrimary">@color/purple_200</item>
<item name="colorPrimaryDark">@color/purple_700</item>
<item name="colorAccent">@color/teal_200</item>
<!-- Banderas maestras: Desactivan la inyección y optimización de Realme UI -->
<item name="android:windowDisablePreview">true</item>
<item name="android:windowActivityTransitions">false</item>
</style>
</resources>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?><!--
Sample backup rules file; uncomment and customize as necessary.
See https://developer.android.com/guide/topics/data/autobackup
for details.
Note: This file is ignored for devices older than API 31
See https://developer.android.com/about/versions/12/backup-restore
-->
<full-backup-content>
<!--
<include domain="sharedpref" path="."/>
<exclude domain="sharedpref" path="device.xml"/>
-->
</full-backup-content>
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?><!--
Sample data extraction rules file; uncomment and customize as necessary.
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
for details.
-->
<data-extraction-rules>
<cloud-backup>
<!-- TODO: Use <include> and <exclude> to control what is backed up.
<include .../>
<exclude .../>
-->
</cloud-backup>
<!--
<device-transfer>
<include .../>
<exclude .../>
</device-transfer>
-->
</data-extraction-rules>
@@ -0,0 +1,17 @@
package com.example.kilometrapp
import org.junit.Test
import org.junit.Assert.*
/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}