initial commit

Signed-off-by: ale <ale@manalejandro.com>
Este commit está contenido en:
ale
2025-07-13 18:22:17 +02:00
commit dea0ee498b
Se han modificado 56 ficheros con 1648 adiciones y 0 borrados

16
.gitignore vendido Archivo normal
Ver fichero

@@ -0,0 +1,16 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
.kotlin

3
.idea/.gitignore generado vendido Archivo normal
Ver fichero

@@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

6
.idea/AndroidProjectSystem.xml generado Archivo normal
Ver fichero

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AndroidProjectSystem">
<option name="providerId" value="com.android.tools.idea.GradleProjectSystem" />
</component>
</project>

6
.idea/compiler.xml generado Archivo normal
Ver fichero

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="21" />
</component>
</project>

10
.idea/deploymentTargetSelector.xml generado Archivo normal
Ver fichero

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetSelector">
<selectionStates>
<SelectionState runConfigName="app">
<option name="selectionMode" value="DROPDOWN" />
</SelectionState>
</selectionStates>
</component>
</project>

19
.idea/gradle.xml generado Archivo normal
Ver fichero

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="CHOOSE_PER_TEST" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
</GradleProjectSettings>
</option>
</component>
</project>

10
.idea/migrations.xml generado Archivo normal
Ver fichero

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectMigrations">
<option name="MigrateToGradleLocalJavaHome">
<set>
<option value="$PROJECT_DIR$" />
</set>
</option>
</component>
</project>

10
.idea/misc.xml generado Archivo normal
Ver fichero

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>

17
.idea/runConfigurations.xml generado Archivo normal
Ver fichero

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="com.intellij.execution.junit.AbstractAllInDirectoryConfigurationProducer" />
<option value="com.intellij.execution.junit.AllInPackageConfigurationProducer" />
<option value="com.intellij.execution.junit.PatternConfigurationProducer" />
<option value="com.intellij.execution.junit.TestInClassConfigurationProducer" />
<option value="com.intellij.execution.junit.UniqueIdConfigurationProducer" />
<option value="com.intellij.execution.junit.testDiscovery.JUnitTestDiscoveryConfigurationProducer" />
<option value="org.jetbrains.kotlin.idea.junit.KotlinJUnitRunConfigurationProducer" />
<option value="org.jetbrains.kotlin.idea.junit.KotlinPatternConfigurationProducer" />
</set>
</option>
</component>
</project>

6
.idea/vcs.xml generado Archivo normal
Ver fichero

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

200
README.md Archivo normal
Ver fichero

@@ -0,0 +1,200 @@
# Location Simulator Android App 📍
Una aplicación Android desarrollada en Kotlin que simula la funcionalidad de ubicaciones de Google **sin necesidad de permisos reales de ubicación**. Perfecta para desarrollo, testing y demostraciones.
## 🎯 Características
-**Sin permisos de ubicación**: Simula ubicaciones sin acceso real al GPS
- 🗺️ **Última ubicación de Google**: Consulta y muestra la última posición guardada por Google (simulada)
- 🎲 **Ubicaciones aleatorias**: Genera posiciones aleatorias cerca de ciudades populares
- 🌍 **Ubicaciones populares**: Lista predefinida de ciudades importantes
- 📍 **Ubicación personalizada**: Permite ingresar coordenadas específicas
- 💾 **Persistencia**: Guarda la última ubicación simulada
## 🏗️ Tecnologías
- **Kotlin** - Lenguaje principal
- **Jetpack Compose** - UI moderna y declarativa
- **Material 3** - Diseño y componentes
- **Architecture Components** - ViewModel, StateFlow
- **SharedPreferences** - Almacenamiento local
- **Coroutines** - Programación asíncrona
## 📱 Funcionalidades
### 1. Ubicación Simulada
- **Última de Google**: Obtiene la última ubicación que Google tendría guardada
- **Simular Nueva**: Genera una nueva ubicación actual simulada
- Muestra coordenadas, precisión y timestamp
### 2. Ubicaciones Populares
Ciudades predefinidas disponibles:
- 🇪🇸 Madrid, España
- 🇫🇷 París, Francia
- 🇬🇧 Londres, Reino Unido
- 🇺🇸 Nueva York, Estados Unidos
- 🇯🇵 Tokio, Japón
- 🇧🇷 São Paulo, Brasil
- 🇦🇺 Sídney, Australia
Cada ciudad permite:
- Ir directamente a esa ubicación
- Generar una posición aleatoria cercana (radio de 1km)
### 3. Ubicación Personalizada
- Ingreso manual de latitud y longitud
- Validación de coordenadas
- Guardado automático de la nueva posición
## 🚀 Instalación y Configuración
### Prerrequisitos
- Android Studio Arctic Fox o superior
- SDK mínimo: API 24 (Android 7.0)
- SDK objetivo: API 36
### Clonar e Instalar
```bash
# Clonar el repositorio
git clone https://git.manalejandro.com/ale/location.git
cd location
# Abrir en Android Studio
# File -> Open -> Seleccionar carpeta del proyecto
# Sincronizar dependencias
# Build -> Make Project
```
### Configuración
No se requiere configuración adicional. La app funciona inmediatamente sin permisos especiales.
## 🎮 Uso
1. **Consultar última ubicación**:
- Toca "Última de Google" para obtener la posición guardada
- La app simula una consulta a los servicios de Google
2. **Generar nueva ubicación**:
- Toca "Simular Nueva" para crear una ubicación actual
3. **Usar ubicaciones populares**:
- Selecciona una ciudad para ir directamente
- Usa "Aleatorio" para generar posiciones cercanas
4. **Ubicación personalizada**:
- Ingresa latitud y longitud manualmente
- Toca "Simular Ubicación" para aplicar
## 📂 Estructura del Proyecto
```
app/src/main/java/com/manalejandro/location/
├── MainActivity.kt # Actividad principal y UI
├── LocationViewModel.kt # Lógica de negocio y estado
├── LocationService.kt # Servicios de ubicación simulados
└── ui/theme/ # Tema y estilos Material 3
├── Color.kt
├── Theme.kt
└── Type.kt
```
## 🔧 Arquitectura
La aplicación sigue el patrón **MVVM (Model-View-ViewModel)**:
- **View (Compose)**: Interfaz de usuario declarativa
- **ViewModel**: Manejo de estado y lógica de presentación
- **Model (LocationService)**: Simulación de servicios de ubicación
### Flujo de Datos
```
UI (Compose) ↔ ViewModel ↔ LocationService ↔ SharedPreferences
```
## 🎨 Diseño
- **Material 3 Design**: Componentes modernos y accesibles
- **Responsive**: Adaptable a diferentes tamaños de pantalla
- **Dark/Light Theme**: Soporte automático según configuración del sistema
- **Cards y Sections**: Organización clara de funcionalidades
## 🧪 Testing
La aplicación incluye pruebas básicas:
```bash
# Ejecutar tests unitarios
./gradlew test
# Ejecutar tests instrumentados
./gradlew connectedAndroidTest
```
## 🤝 Contribuir
1. Fork el proyecto
2. Crea una rama para tu feature (`git checkout -b feature/AmazingFeature`)
3. Commit tus cambios (`git commit -m 'Add some AmazingFeature'`)
4. Push a la rama (`git push origin feature/AmazingFeature`)
5. Abre un Pull Request
## 📝 Casos de Uso
### Para Desarrolladores
- Testing de aplicaciones que requieren ubicación
- Desarrollo sin depender de ubicación real
- Demostraciones en entornos controlados
### Para QA/Testing
- Verificar comportamiento con diferentes ubicaciones
- Probar funcionalidades geográficas
- Testing sin moverse físicamente
### Para Educación
- Enseñar conceptos de geolocalización
- Demostrar APIs de ubicación
- Workshops y tutoriales
## 🔒 Privacidad
Esta aplicación **NO**:
- Accede a tu ubicación real
- Requiere permisos de ubicación
- Envía datos a servidores externos
- Almacena información personal
Toda la funcionalidad es local y simulada.
## 📄 Licencia
Este proyecto está bajo la Licencia MIT. Ver el archivo `LICENSE` para más detalles.
## 👨‍💻 Autor
**Manuel Alejandro**
- Git: [@manalejandro](https://git.manalejandro.com/ale)
## 🙏 Agradecimientos
- Equipo de Android Developers
- Comunidad de Kotlin
- Material Design Team
---
⭐ Si este proyecto te ha sido útil, ¡no olvides darle una estrella!
## 📸 Screenshots
> Agrega capturas de pantalla de tu aplicación aquí
## 🔄 Changelog
### v1.0.0
- Lanzamiento inicial
- Simulación de ubicaciones de Google
- Ubicaciones populares predefinidas
- Ubicaciones personalizadas
- UI con Material 3

1
app/.gitignore vendido Archivo normal
Ver fichero

@@ -0,0 +1 @@
/build

65
app/build.gradle.kts Archivo normal
Ver fichero

@@ -0,0 +1,65 @@
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.compose)
}
android {
namespace = "com.manalejandro.location"
compileSdk = 36
defaultConfig {
applicationId = "com.manalejandro.location"
minSdk = 24
targetSdk = 36
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
}
kotlinOptions {
jvmTarget = "11"
}
buildFeatures {
compose = true
}
}
dependencies {
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.activity.compose)
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.ui)
implementation(libs.androidx.ui.graphics)
implementation(libs.androidx.ui.tooling.preview)
implementation(libs.androidx.material3)
// ViewModel y LiveData
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.7.0")
implementation("androidx.compose.runtime:runtime-livedata:1.5.4")
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(platform(libs.androidx.compose.bom))
androidTestImplementation(libs.androidx.ui.test.junit4)
debugImplementation(libs.androidx.ui.tooling)
debugImplementation(libs.androidx.ui.test.manifest)
}

21
app/proguard-rules.pro vendido Archivo normal
Ver fichero

@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# 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 *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

Ver fichero

@@ -0,0 +1,24 @@
package com.manalejandro.location
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.manalejandro.location", appContext.packageName)
}
}

Ver fichero

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<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.Location">
<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.Location">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

Archivo binario no mostrado.

Después

Anchura:  |  Altura:  |  Tamaño: 12 KiB

Ver fichero

@@ -0,0 +1,138 @@
package com.manalejandro.location
import android.content.Context
import android.location.Location
import kotlinx.coroutines.delay
class LocationService(private val context: Context) {
/**
* Simula obtener la última ubicación conocida que Google tendría guardada
* Devuelve una ubicación predeterminada o la última simulada
*/
suspend fun getLastKnownLocation(): Location? {
// Simular un pequeño delay como si fuera una consulta real a Google
delay(1000)
// Primero intentar obtener la ubicación simulada guardada
val mockedLocation = getMockedLocation()
if (mockedLocation != null) {
// Actualizar el timestamp para simular que Google la tiene guardada
return mockedLocation.apply {
time = System.currentTimeMillis() - (1000 * 60 * 30) // 30 minutos atrás
}
}
// Si no hay ubicación simulada, devolver una ubicación predeterminada que Google tendría guardada (Madrid)
return Location("google_provider").apply {
latitude = 40.4168
longitude = -3.7038
time = System.currentTimeMillis() - (1000 * 60 * 60 * 2) // 2 horas atrás
accuracy = 15.0f // Menos precisión para simular que es una ubicación guardada
}
}
/**
* Simula obtener la ubicación actual de Google
*/
suspend fun getCurrentLocation(): Location? {
// Simular un delay más largo como si fuera una consulta GPS real
delay(2000)
return getLastKnownLocation()
}
/**
* Guarda una ubicación simulada
*/
suspend fun mockLocation(latitude: Double, longitude: Double): Boolean {
return try {
val preferences = context.getSharedPreferences("mock_location", Context.MODE_PRIVATE)
preferences.edit()
.putString("latitude", latitude.toString())
.putString("longitude", longitude.toString())
.putLong("timestamp", System.currentTimeMillis())
.apply()
// Simular un pequeño delay
delay(500)
true
} catch (e: Exception) {
false
}
}
/**
* Obtiene la ubicación simulada guardada
*/
fun getMockedLocation(): Location? {
val preferences = context.getSharedPreferences("mock_location", Context.MODE_PRIVATE)
val latStr = preferences.getString("latitude", null)
val lngStr = preferences.getString("longitude", null)
return if (latStr != null && lngStr != null) {
Location("mock_provider").apply {
latitude = latStr.toDouble()
longitude = lngStr.toDouble()
time = preferences.getLong("timestamp", System.currentTimeMillis())
accuracy = 5.0f // Simular buena precisión
}
} else null
}
/**
* Genera ubicaciones aleatorias cercanas a una ubicación base
*/
fun generateRandomNearbyLocation(baseLatitude: Double, baseLongitude: Double, radiusKm: Double = 1.0): Location {
val random = kotlin.random.Random
// Generar offset aleatorio dentro del radio especificado
val offsetLat = (random.nextDouble() - 0.5) * 2 * (radiusKm / 111.0) // 1 grado lat ≈ 111 km
val offsetLng = (random.nextDouble() - 0.5) * 2 * (radiusKm / (111.0 * kotlin.math.cos(Math.toRadians(baseLatitude))))
return Location("random_provider").apply {
latitude = baseLatitude + offsetLat
longitude = baseLongitude + offsetLng
time = System.currentTimeMillis()
accuracy = random.nextFloat() * 20 + 5 // Precisión entre 5-25 metros
}
}
/**
* Obtiene ubicaciones predefinidas populares en España
*/
fun getPopularLocations(): List<Pair<String, Location>> {
return listOf(
"Madrid" to Location("predefined").apply {
latitude = 40.4168
longitude = -3.7038
time = System.currentTimeMillis()
accuracy = 10.0f
},
"Barcelona" to Location("predefined").apply {
latitude = 41.3851
longitude = 2.1734
time = System.currentTimeMillis()
accuracy = 10.0f
},
"Valencia" to Location("predefined").apply {
latitude = 39.4699
longitude = -0.3763
time = System.currentTimeMillis()
accuracy = 10.0f
},
"Sevilla" to Location("predefined").apply {
latitude = 37.3886
longitude = -5.9823
time = System.currentTimeMillis()
accuracy = 10.0f
},
"Bilbao" to Location("predefined").apply {
latitude = 43.2627
longitude = -2.9253
time = System.currentTimeMillis()
accuracy = 10.0f
}
)
}
}

Ver fichero

@@ -0,0 +1,176 @@
package com.manalejandro.location
import android.location.Location
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.launch
data class LocationState(
val currentLocation: Location? = null,
val mockedLocation: Location? = null,
val popularLocations: List<Pair<String, Location>> = emptyList(),
val isLoading: Boolean = false,
val error: String? = null,
val hasLocationPermission: Boolean = true // Siempre true ya que no necesitamos permisos
)
class LocationViewModel(private val locationService: LocationService) : ViewModel() {
private val _uiState = MutableStateFlow(LocationState())
val uiState: StateFlow<LocationState> = _uiState.asStateFlow()
init {
loadMockedLocation()
loadPopularLocations()
}
/**
* Carga la ubicación simulada guardada
*/
private fun loadMockedLocation() {
val mockedLocation = locationService.getMockedLocation()
_uiState.value = _uiState.value.copy(mockedLocation = mockedLocation)
}
/**
* Carga las ubicaciones populares predefinidas
*/
private fun loadPopularLocations() {
val popularLocations = locationService.getPopularLocations()
_uiState.value = _uiState.value.copy(popularLocations = popularLocations)
}
/**
* Obtiene la última ubicación conocida (simulada)
*/
fun getLastKnownLocation() {
viewModelScope.launch {
_uiState.value = _uiState.value.copy(isLoading = true, error = null)
try {
val location = locationService.getLastKnownLocation()
_uiState.value = _uiState.value.copy(
currentLocation = location,
isLoading = false,
error = if (location == null) "No se encontró ubicación guardada" else null
)
} catch (e: Exception) {
_uiState.value = _uiState.value.copy(
isLoading = false,
error = "Error al obtener ubicación: ${e.message}"
)
}
}
}
/**
* Obtiene la ubicación actual (simulada)
*/
fun getCurrentLocation() {
viewModelScope.launch {
_uiState.value = _uiState.value.copy(isLoading = true, error = null)
try {
val location = locationService.getCurrentLocation()
_uiState.value = _uiState.value.copy(
currentLocation = location,
isLoading = false,
error = if (location == null) "No se pudo obtener ubicación actual" else null
)
} catch (e: Exception) {
_uiState.value = _uiState.value.copy(
isLoading = false,
error = "Error al obtener ubicación actual: ${e.message}"
)
}
}
}
/**
* Simula una nueva ubicación
*/
fun mockLocation(latitude: Double, longitude: Double) {
viewModelScope.launch {
_uiState.value = _uiState.value.copy(isLoading = true, error = null)
try {
val success = locationService.mockLocation(latitude, longitude)
if (success) {
val mockedLocation = locationService.getMockedLocation()
_uiState.value = _uiState.value.copy(
mockedLocation = mockedLocation,
isLoading = false,
error = null
)
} else {
_uiState.value = _uiState.value.copy(
isLoading = false,
error = "Error al simular ubicación"
)
}
} catch (e: Exception) {
_uiState.value = _uiState.value.copy(
isLoading = false,
error = "Error al simular ubicación: ${e.message}"
)
}
}
}
/**
* Establece una ubicación predefinida
*/
fun setPopularLocation(location: Location) {
mockLocation(location.latitude, location.longitude)
}
/**
* Genera una ubicación aleatoria cerca de una ubicación base
*/
fun generateRandomLocation(baseLocation: Location) {
viewModelScope.launch {
_uiState.value = _uiState.value.copy(isLoading = true, error = null)
try {
val randomLocation = locationService.generateRandomNearbyLocation(
baseLocation.latitude,
baseLocation.longitude,
2.0 // Radio de 2 km
)
val success = locationService.mockLocation(randomLocation.latitude, randomLocation.longitude)
if (success) {
val mockedLocation = locationService.getMockedLocation()
_uiState.value = _uiState.value.copy(
mockedLocation = mockedLocation,
currentLocation = randomLocation,
isLoading = false,
error = null
)
}
} catch (e: Exception) {
_uiState.value = _uiState.value.copy(
isLoading = false,
error = "Error al generar ubicación aleatoria: ${e.message}"
)
}
}
}
/**
* Actualiza el estado de permisos (ya no necesario)
*/
fun updatePermissionStatus(hasPermission: Boolean) {
// No hacemos nada ya que no necesitamos permisos
}
/**
* Limpia errores
*/
fun clearError() {
_uiState.value = _uiState.value.copy(error = null)
}
}

Ver fichero

@@ -0,0 +1,344 @@
package com.manalejandro.location
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.lifecycle.viewmodel.compose.viewModel
import com.manalejandro.location.ui.theme.LocationTheme
import java.text.SimpleDateFormat
import java.util.*
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContent {
LocationTheme {
LocationApp()
}
}
}
}
@Composable
fun LocationApp() {
val context = LocalContext.current
val locationService = remember { LocationService(context) }
val viewModel: LocationViewModel = viewModel { LocationViewModel(locationService) }
val uiState by viewModel.uiState.collectAsState()
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
Column(
modifier = Modifier
.fillMaxSize()
.padding(innerPadding)
.padding(16.dp),
verticalArrangement = Arrangement.spacedBy(16.dp)
) {
// Título
Text(
text = "Simulador de Ubicación",
fontSize = 24.sp,
fontWeight = FontWeight.Bold,
modifier = Modifier.align(Alignment.CenterHorizontally)
)
Text(
text = "Esta aplicación simula ubicaciones sin necesidad de permisos reales",
fontSize = 14.sp,
color = MaterialTheme.colorScheme.onSurfaceVariant,
modifier = Modifier.align(Alignment.CenterHorizontally)
)
// Sección de ubicación actual/simulada
CurrentLocationSection(
uiState = uiState,
onGetLastLocation = viewModel::getLastKnownLocation,
onGetCurrentLocation = viewModel::getCurrentLocation
)
// Sección de ubicaciones populares
PopularLocationsSection(
uiState = uiState,
onSelectLocation = viewModel::setPopularLocation,
onGenerateRandom = viewModel::generateRandomLocation
)
HorizontalDivider()
// Sección para simular ubicación personalizada
CustomLocationSection(
uiState = uiState,
onMockLocation = viewModel::mockLocation
)
// Mostrar errores
uiState.error?.let { error ->
ErrorSection(
error = error,
onDismiss = viewModel::clearError
)
}
}
}
}
@Composable
fun CurrentLocationSection(
uiState: LocationState,
onGetLastLocation: () -> Unit,
onGetCurrentLocation: () -> Unit
) {
Card(modifier = Modifier.fillMaxWidth()) {
Column(
modifier = Modifier.padding(16.dp),
verticalArrangement = Arrangement.spacedBy(12.dp)
) {
Text(
text = "Ubicación Simulada",
fontSize = 18.sp,
fontWeight = FontWeight.Bold
)
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
Button(
onClick = onGetLastLocation,
enabled = !uiState.isLoading,
modifier = Modifier.weight(1f)
) {
Text("Última de Google")
}
Button(
onClick = onGetCurrentLocation,
enabled = !uiState.isLoading,
modifier = Modifier.weight(1f)
) {
Text("Simular Nueva")
}
}
if (uiState.isLoading) {
Box(
modifier = Modifier.fillMaxWidth(),
contentAlignment = Alignment.Center
) {
CircularProgressIndicator()
}
}
uiState.currentLocation?.let { location ->
LocationDisplay(
title = if (location.provider == "google_provider")
"Última ubicación guardada por Google"
else
"Ubicación Actual",
location = location
)
}
}
}
}
@Composable
fun PopularLocationsSection(
uiState: LocationState,
onSelectLocation: (android.location.Location) -> Unit,
onGenerateRandom: (android.location.Location) -> Unit
) {
Card(modifier = Modifier.fillMaxWidth()) {
Column(
modifier = Modifier.padding(16.dp),
verticalArrangement = Arrangement.spacedBy(12.dp)
) {
Text(
text = "Ubicaciones Populares",
fontSize = 18.sp,
fontWeight = FontWeight.Bold
)
LazyRow(
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
items(uiState.popularLocations) { (cityName, location) ->
Column(
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(4.dp)
) {
Button(
onClick = { onSelectLocation(location) },
enabled = !uiState.isLoading
) {
Text(cityName)
}
OutlinedButton(
onClick = { onGenerateRandom(location) },
enabled = !uiState.isLoading,
modifier = Modifier.width(100.dp)
) {
Text("Aleatorio", fontSize = 10.sp)
}
}
}
}
if (uiState.popularLocations.isNotEmpty()) {
Text(
text = "Toca una ciudad para ir allí, o 'Aleatorio' para generar una ubicación cercana",
fontSize = 12.sp,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
}
}
}
}
@Composable
fun CustomLocationSection(
uiState: LocationState,
onMockLocation: (Double, Double) -> Unit
) {
var latitude by remember { mutableStateOf("") }
var longitude by remember { mutableStateOf("") }
Card(modifier = Modifier.fillMaxWidth()) {
Column(
modifier = Modifier.padding(16.dp),
verticalArrangement = Arrangement.spacedBy(12.dp)
) {
Text(
text = "Ubicación Personalizada",
fontSize = 18.sp,
fontWeight = FontWeight.Bold
)
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
OutlinedTextField(
value = latitude,
onValueChange = { latitude = it },
label = { Text("Latitud") },
placeholder = { Text("40.4168") },
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Decimal),
modifier = Modifier.weight(1f)
)
OutlinedTextField(
value = longitude,
onValueChange = { longitude = it },
label = { Text("Longitud") },
placeholder = { Text("-3.7038") },
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Decimal),
modifier = Modifier.weight(1f)
)
}
Button(
onClick = {
val lat = latitude.toDoubleOrNull()
val lng = longitude.toDoubleOrNull()
if (lat != null && lng != null) {
onMockLocation(lat, lng)
}
},
enabled = latitude.isNotBlank() && longitude.isNotBlank() && !uiState.isLoading,
modifier = Modifier.fillMaxWidth()
) {
Text("Establecer Ubicación Personalizada")
}
uiState.mockedLocation?.let { location ->
LocationDisplay(
title = "Ubicación Guardada",
location = location
)
}
}
}
}
@Composable
fun LocationDisplay(title: String, location: android.location.Location) {
Card(
modifier = Modifier.fillMaxWidth(),
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.secondaryContainer)
) {
Column(
modifier = Modifier.padding(12.dp),
verticalArrangement = Arrangement.spacedBy(4.dp)
) {
Text(
text = title,
fontWeight = FontWeight.Medium,
color = MaterialTheme.colorScheme.onSecondaryContainer
)
Text(
text = "Latitud: ${String.format("%.6f", location.latitude)}",
color = MaterialTheme.colorScheme.onSecondaryContainer
)
Text(
text = "Longitud: ${String.format("%.6f", location.longitude)}",
color = MaterialTheme.colorScheme.onSecondaryContainer
)
if (location.hasAccuracy()) {
Text(
text = "Precisión: ${String.format("%.1f", location.accuracy)} metros",
color = MaterialTheme.colorScheme.onSecondaryContainer
)
}
Text(
text = "Hora: ${SimpleDateFormat("dd/MM/yyyy HH:mm:ss", Locale.getDefault()).format(Date(location.time))}",
color = MaterialTheme.colorScheme.onSecondaryContainer
)
}
}
}
@Composable
fun ErrorSection(error: String, onDismiss: () -> Unit) {
Card(
modifier = Modifier.fillMaxWidth(),
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.errorContainer)
) {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(16.dp),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) {
Text(
text = error,
color = MaterialTheme.colorScheme.onErrorContainer,
modifier = Modifier.weight(1f)
)
TextButton(onClick = onDismiss) {
Text(
text = "Cerrar",
color = MaterialTheme.colorScheme.onErrorContainer
)
}
}
}
}

Ver fichero

@@ -0,0 +1,11 @@
package com.manalejandro.location.ui.theme
import androidx.compose.ui.graphics.Color
val Purple80 = Color(0xFFD0BCFF)
val PurpleGrey80 = Color(0xFFCCC2DC)
val Pink80 = Color(0xFFEFB8C8)
val Purple40 = Color(0xFF6650a4)
val PurpleGrey40 = Color(0xFF625b71)
val Pink40 = Color(0xFF7D5260)

Ver fichero

@@ -0,0 +1,58 @@
package com.manalejandro.location.ui.theme
import android.app.Activity
import android.os.Build
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
private val DarkColorScheme = darkColorScheme(
primary = Purple80,
secondary = PurpleGrey80,
tertiary = Pink80
)
private val LightColorScheme = lightColorScheme(
primary = Purple40,
secondary = PurpleGrey40,
tertiary = Pink40
/* Other default colors to override
background = Color(0xFFFFFBFE),
surface = Color(0xFFFFFBFE),
onPrimary = Color.White,
onSecondary = Color.White,
onTertiary = Color.White,
onBackground = Color(0xFF1C1B1F),
onSurface = Color(0xFF1C1B1F),
*/
)
@Composable
fun LocationTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
// Dynamic color is available on Android 12+
dynamicColor: Boolean = true,
content: @Composable () -> Unit
) {
val colorScheme = when {
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
val context = LocalContext.current
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
}
darkTheme -> DarkColorScheme
else -> LightColorScheme
}
MaterialTheme(
colorScheme = colorScheme,
typography = Typography,
content = content
)
}

Ver fichero

@@ -0,0 +1,34 @@
package com.manalejandro.location.ui.theme
import androidx.compose.material3.Typography
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.sp
// Set of Material typography styles to start with
val Typography = Typography(
bodyLarge = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 16.sp,
lineHeight = 24.sp,
letterSpacing = 0.5.sp
)
/* Other default text styles to override
titleLarge = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 22.sp,
lineHeight = 28.sp,
letterSpacing = 0.sp
),
labelSmall = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Medium,
fontSize = 11.sp,
lineHeight = 16.sp,
letterSpacing = 0.5.sp
)
*/
)

Archivo binario no mostrado.

Después

Anchura:  |  Altura:  |  Tamaño: 1.4 KiB

Ver fichero

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>

Ver fichero

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>

Archivo binario no mostrado.

Después

Anchura:  |  Altura:  |  Tamaño: 1.4 KiB

Archivo binario no mostrado.

Después

Anchura:  |  Altura:  |  Tamaño: 1.8 KiB

Archivo binario no mostrado.

Después

Anchura:  |  Altura:  |  Tamaño: 2.9 KiB

Archivo binario no mostrado.

Después

Anchura:  |  Altura:  |  Tamaño: 934 B

Archivo binario no mostrado.

Después

Anchura:  |  Altura:  |  Tamaño: 954 B

Archivo binario no mostrado.

Después

Anchura:  |  Altura:  |  Tamaño: 1.9 KiB

Archivo binario no mostrado.

Después

Anchura:  |  Altura:  |  Tamaño: 1.9 KiB

Archivo binario no mostrado.

Después

Anchura:  |  Altura:  |  Tamaño: 2.6 KiB

Archivo binario no mostrado.

Después

Anchura:  |  Altura:  |  Tamaño: 4.3 KiB

Archivo binario no mostrado.

Después

Anchura:  |  Altura:  |  Tamaño: 2.6 KiB

Archivo binario no mostrado.

Después

Anchura:  |  Altura:  |  Tamaño: 3.2 KiB

Archivo binario no mostrado.

Después

Anchura:  |  Altura:  |  Tamaño: 6.2 KiB

Archivo binario no mostrado.

Después

Anchura:  |  Altura:  |  Tamaño: 3.4 KiB

Archivo binario no mostrado.

Después

Anchura:  |  Altura:  |  Tamaño: 3.3 KiB

Archivo binario no mostrado.

Después

Anchura:  |  Altura:  |  Tamaño: 8.5 KiB

Ver fichero

@@ -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>

Ver fichero

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#F0F3F7</color>
</resources>

Ver fichero

@@ -0,0 +1,3 @@
<resources>
<string name="app_name">location</string>
</resources>

Ver fichero

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Location" parent="android:Theme.Material.Light.NoActionBar" />
</resources>

Ver fichero

@@ -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>

Ver fichero

@@ -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>

Ver fichero

@@ -0,0 +1,17 @@
package com.manalejandro.location
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)
}
}

6
build.gradle.kts Archivo normal
Ver fichero

@@ -0,0 +1,6 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.compose) apply false
}

23
gradle.properties Archivo normal
Ver fichero

@@ -0,0 +1,23 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. For more details, visit
# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true

32
gradle/libs.versions.toml Archivo normal
Ver fichero

@@ -0,0 +1,32 @@
[versions]
agp = "8.11.1"
kotlin = "2.0.21"
coreKtx = "1.16.0"
junit = "4.13.2"
junitVersion = "1.2.1"
espressoCore = "3.6.1"
lifecycleRuntimeKtx = "2.9.1"
activityCompose = "1.10.1"
composeBom = "2024.09.00"
[libraries]
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
junit = { group = "junit", name = "junit", version.ref = "junit" }
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" }
androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" }
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" }
androidx-ui = { group = "androidx.compose.ui", name = "ui" }
androidx-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
androidx-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
androidx-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
androidx-material3 = { group = "androidx.compose.material3", name = "material3" }
[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }

BIN
gradle/wrapper/gradle-wrapper.jar vendido Archivo normal

Archivo binario no mostrado.

6
gradle/wrapper/gradle-wrapper.properties vendido Archivo normal
Ver fichero

@@ -0,0 +1,6 @@
#Sun Jul 13 02:37:09 CEST 2025
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

185
gradlew vendido Archivo ejecutable
Ver fichero

@@ -0,0 +1,185 @@
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
exec "$JAVACMD" "$@"

89
gradlew.bat vendido Archivo normal
Ver fichero

@@ -0,0 +1,89 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

23
settings.gradle.kts Archivo normal
Ver fichero

@@ -0,0 +1,23 @@
pluginManagement {
repositories {
google {
content {
includeGroupByRegex("com\\.android.*")
includeGroupByRegex("com\\.google.*")
includeGroupByRegex("androidx.*")
}
}
mavenCentral()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "location"
include(":app")