diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9c37666 --- /dev/null +++ b/.gitignore @@ -0,0 +1,26 @@ +# Gradle +.gradle/ +build/ +*/build/ +gradle-app.setting +!gradle-wrapper.jar + +# Local configuration +local.properties + +# IDE +.idea/ +*.iml +*.ipr +*.iws +.vscode/ + +# APK files (will be in releases) +*.apk + +# OS files +.DS_Store +Thumbs.db + +# Logs +*.log diff --git a/1000004009.png b/1000004009.png new file mode 100644 index 0000000..7847952 Binary files /dev/null and b/1000004009.png differ diff --git a/1000004822.jpg b/1000004822.jpg new file mode 100644 index 0000000..fd6a551 Binary files /dev/null and b/1000004822.jpg differ diff --git a/README.md b/README.md index f16ba45..4074b42 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,15 @@ -# aprs-converter +# APRS Locator (Android) -Конвертор координат GPS → APRS, Maidenhead \ No newline at end of file +Simple Android app (Jetpack Compose) that shows: +- Decimal coordinates (latitude and longitude) +- APRS-format coordinates +- Maidenhead (ham radio) grid square + +Dark theme. The app requests `ACCESS_FINE_LOCATION` at runtime. Build and run with Android Studio or Gradle. + +Quick build (from project root): + +```bash +# Open in Android Studio or run with Gradle wrapper in Android Studio environment +./gradlew :app:installDebug +``` diff --git a/README_SERVER_BUILD.md b/README_SERVER_BUILD.md new file mode 100644 index 0000000..30ba5d8 --- /dev/null +++ b/README_SERVER_BUILD.md @@ -0,0 +1,232 @@ +# Конвертор координат GPS → APRS, Maidenhead + +## Описание проекта + +Приложение Android для конвертации GPS координат в различные форматы: +- Десятичные координаты (широта/долгота) +- Градусы, минуты, секунды (DMS) +- APRS формат +- Maidenhead (QTH локатор) + +**Технологии:** +- Kotlin +- Jetpack Compose (Material 3) +- Android SDK 34 +- Min SDK: 21 + +--- + +## Структура проекта + +``` +vs2/ +├── app/ +│ ├── src/main/ +│ │ ├── java/com/example/aprs/ +│ │ │ ├── MainActivity.kt # Основной экран +│ │ │ └── LocationUtils.kt # Утилиты конвертации +│ │ ├── res/ +│ │ │ ├── values/ +│ │ │ │ ├── strings.xml +│ │ │ │ ├── themes.xml +│ │ │ │ └── ic_launcher_background.xml +│ │ │ └── mipmap-*/ # Иконки приложения +│ │ ├── AndroidManifest.xml +│ │ └── build.gradle.kts +│ └── build/outputs/apk/debug/ # Скомпилированный APK +├── build.gradle.kts +├── gradle.properties +├── settings.gradle.kts +└── gradlew # Gradle wrapper +``` + +--- + +## Требования к серверу + +### Необходимое ПО: +- **Java JDK 17** (`/usr/lib/jvm/java-17-openjdk-amd64`) +- **Git** (опционально) +- **SSH доступ** с паролем или ключом + +### Проверка окружения на сервере: +```bash +java -version +# Должно показать: openjdk version "17.x.x" +``` + +--- + +## Инструкция по компиляции на сервере + +### 1. Подключение к серверу + +```bash +# Подключение по SSH +ssh ua1zbe@192.168.1.46 +# Введите пароль: ktdbycrbq1980 +``` + +### 2. Загрузка проекта на сервер + +#### Вариант A: Через rsync (рекомендуется) +```bash +# С локальной машины +rsync -avz -e ssh /home/ua1zbe/my_aprs_project/vs2/ ua1zbe@192.168.1.46:~/my_aprs_project/vs2/ +``` + +#### Вариант B: Через git +```bash +# На сервере +cd ~ +git clone my_aprs_project/vs2 +``` + +### 3. Сборка APK + +```bash +# Подключение к серверу +ssh ua1zbe@192.168.1.46 + +# Переход в директорию проекта +cd ~/my_aprs_project/vs2 + +# Установка JAVA_HOME +export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 + +# Очистка и сборка +./gradlew clean assembleDebug + +# Или только сборка (быстрее) +./gradlew assembleDebug +``` + +### 4. Результат сборки + +APK файл будет создан в: +``` +/home/ua1zbe/my_aprs_project/vs2/app/build/outputs/apk/debug/app-debug.apk +``` + +Размер: ~12-14 MB + +### 5. Проверка сборки + +```bash +# Проверка существования APK +ls -lh ~/my_aprs_project/vs2/app/build/outputs/apk/debug/app-debug.apk + +# Информация о сборке +./gradlew buildEnvironment +``` + +--- + +## Установка на устройство + +### Вариант A: Через ADB (USB) + +```bash +# Скачать APK с сервера +scp ua1zbe@192.168.1.46:~/my_aprs_project/vs2/app/build/outputs/apk/debug/app-debug.apk /home/ua1zbe/my_aprs_project/vs2/ + +# Установить на устройство +adb install -r /home/ua1zbe/my_aprs_project/vs2/app-debug.apk +``` + +### Вариант B: Прямая установка с сервера + +```bash +# На сервере (если есть ADB и подключено устройство) +adb install ~/my_aprs_project/vs2/app/build/outputs/apk/debug/app-debug.apk +``` + +### Вариант C: Через файловый менеджер + +1. Скачать APK с сервера через SFTP/SCP +2. Передать на телефон +3. Установить через файловый менеджер + +--- + +## Полезные команды Gradle + +```bash +# Очистка сборки +./gradlew clean + +# Сборка debug версии +./gradlew assembleDebug + +# Сборка release версии +./gradlew assembleRelease + +# Запуск тестов +./gradlew test + +# Проверка зависимостей +./gradlew dependencies + +# Остановка Gradle daemon +./gradlew --stop + +# Сборка с логом +./gradlew assembleDebug --info +``` + +--- + +## Решение проблем + +### Ошибка: "Could not connect to Kotlin compile daemon" +```bash +# Остановить Gradle и попробовать снова +./gradlew --stop +./gradlew clean assembleDebug +``` + +### Ошибка: "minSdkVersion cannot be smaller than version 21" +```bash +# Jetpack Compose требует API 21+ +# Проверить app/build.gradle.kts: +# minSdk = 21 +``` + +### Ошибка: "resource not found" для иконок +```bash +# Проверить наличие директорий mipmap +ls app/src/main/res/mipmap-*/ + +# Пересоздать иконки при необходимости +``` + +### Ошибка: "BUILD FAILED - Manifest merger failed" +```bash +# Очистить сборку +./gradlew clean +# Проверить AndroidManifest.xml на ошибки +``` + +### Долгая компиляция +```bash +# Использовать daemon (по умолчанию включён) +./gradlew assembleDebug --daemon + +# Или увеличить память +export GRADLE_OPTS="-Xmx2g" +``` + +--- + +## Быстрая сборка (one-liner) + +```bash +ssh ua1zbe@192.168.1.46 "cd ~/my_aprs_project/vs2 && export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 && ./gradlew assembleDebug" && scp ua1zbe@192.168.1.46:~/my_aprs_project/vs2/app/build/outputs/apk/debug/app-debug.apk /home/ua1zbe/my_aprs_project/vs2/ && adb install -r /home/ua1zbe/my_aprs_project/vs2/app-debug.apk +``` + +--- + +## Контакты + +Автор: UA1ZBE +Дата: Март 2026 diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 0000000..28fbc1c --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,46 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + namespace = "com.example.aprs" + compileSdk = 34 + + defaultConfig { + applicationId = "com.example.aprs" + // Jetpack Compose requires API 21+ + minSdk = 21 + targetSdk = 34 + versionCode = 1 + versionName = "1.0" + } + + buildFeatures { + compose = true + } + + composeOptions { + kotlinCompilerExtensionVersion = "1.5.3" + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } + + kotlinOptions { + jvmTarget = "11" + } +} + +dependencies { + implementation("androidx.core:core-ktx:1.10.1") + implementation("androidx.activity:activity-compose:1.8.0") + implementation("androidx.compose.ui:ui:1.5.0") + implementation("androidx.compose.ui:ui-graphics:1.5.0") + implementation("androidx.compose.material:material:1.5.0") + implementation("androidx.compose.material3:material3:1.1.2") + implementation("androidx.compose.material:material-icons-extended:1.5.0") + implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.1") +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..4fd86d4 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + diff --git a/app/src/main/java/com/example/aprs/LocationUtils.kt b/app/src/main/java/com/example/aprs/LocationUtils.kt new file mode 100644 index 0000000..15e7b01 --- /dev/null +++ b/app/src/main/java/com/example/aprs/LocationUtils.kt @@ -0,0 +1,107 @@ +package com.example.aprs + +import kotlin.math.floor +import kotlin.math.abs +import kotlin.math.sin +import kotlin.math.cos +import kotlin.math.atan +import kotlin.math.sqrt +import kotlin.math.PI +import kotlin.math.ln + +object LocationUtils { + // Convert decimal degrees to APRS position format: DDMM.MM N / DDDMM.MM E + fun toAprs(lat: Double, lon: Double): String { + val latHem = if (lat >= 0) "N" else "S" + val lonHem = if (lon >= 0) "E" else "W" + + val latAbs = abs(lat) + val lonAbs = abs(lon) + + val latDeg = floor(latAbs).toInt() + val latMin = (latAbs - latDeg) * 60.0 + + val lonDeg = floor(lonAbs).toInt() + val lonMin = (lonAbs - lonDeg) * 60.0 + + return String.format( + "%02d%05.2f%s/%03d%05.2f%s", + latDeg, + latMin, + latHem, + lonDeg, + lonMin, + lonHem + ) + } + + // Maidenhead locator (6 chars) from lat/lon + fun toMaidenhead(lat: Double, lon: Double): String { + var adjLon = lon + 180.0 + var adjLat = lat + 90.0 + + val fieldLon = (adjLon / 20.0).toInt() + val fieldLat = (adjLat / 10.0).toInt() + + val squareLon = ((adjLon % 20) / 2).toInt() + val squareLat = ((adjLat % 10) / 1).toInt() + + val subsLon = (((adjLon - fieldLon * 20 - squareLon * 2) * 60) / 5).toInt() + val subsLat = (((adjLat - fieldLat * 10 - squareLat * 1) * 60) / 2.5).toInt() + + val a = 'A'.code + + val fieldChars = charArrayOf((a + fieldLon).toChar(), (a + fieldLat).toChar()) + val squareChars = charArrayOf(('0'.code + squareLon).toChar(), ('0'.code + squareLat).toChar()) + val subsChars = charArrayOf((a + subsLon).toChar(), (a + subsLat).toChar()) + + return String(charArrayOf(fieldChars[0], fieldChars[1], squareChars[0], squareChars[1], subsChars[0], subsChars[1])) + } + + // Convert lat/lon to UTM coordinates + fun toUTM(lat: Double, lon: Double): String { + val k0 = 0.9996 + val a = 6378137.0 + val eSquared = 0.00669438 + val e = sqrt(eSquared) + val ePrimeSquared = eSquared / (1 - eSquared) + + val latRad = lat * PI / 180.0 + val lonRad = lon * PI / 180.0 + + val zone = ((lon + 180) / 6).toInt() + 1 + + val lonOrigin = (zone - 1) * 6 - 180 + 3 + val lonOriginRad = lonOrigin * PI / 180.0 + + val n = a / sqrt(1 - eSquared * sin(latRad) * sin(latRad)) + val T = tan(latRad) * tan(latRad) + val C = ePrimeSquared * cos(latRad) * cos(latRad) + val A = cos(latRad) * (lonRad - lonOriginRad) + + val M = a * ((1 - eSquared / 4 - 3 * eSquared * eSquared / 64 - 5 * eSquared * eSquared * eSquared / 256) * latRad + - (3 * eSquared / 8 + 3 * eSquared * eSquared / 32 + 45 * eSquared * eSquared * eSquared / 1024) * sin(2 * latRad) + + (15 * eSquared * eSquared / 256 + 45 * eSquared * eSquared * eSquared / 1024) * sin(4 * latRad) + - (35 * eSquared * eSquared * eSquared / 3072) * sin(6 * latRad)) + + val UTMEasting = (k0 * n * (A + (1 - T + C) * A * A * A / 6 + + (5 - 18 * T + T * T + 72 * C - 58 * ePrimeSquared) * A * A * A * A * A / 120) + + 500000.0).toLong() + + val UTMNorthing = (k0 * (M + n * tan(latRad) * (A * A / 2 + (5 - T + 9 * C + 4 * C * C) * A * A * A * A / 24 + + (61 - 58 * T + T * T + 600 * C - 330 * ePrimeSquared) * A * A * A * A * A * A / 720)) + + (if (lat < 0) 10000000.0 else 0.0)).toLong() + + val zoneLetter = getUtmZoneLetter(lat, lon) + + return String.format("%d%s %06d %07d", zone, zoneLetter, UTMEasting, UTMNorthing) + } + + private fun tan(rad: Double): Double = sin(rad) / cos(rad) + + private fun getUtmZoneLetter(lat: Double, lon: Double): String { + val letters = "CDEFGHJKLMNPQRSTUVWXX" + val latIndex = ((lat + 80) / 8).toInt().coerceIn(0, letters.length - 1) + return letters[latIndex].toString() + } +} diff --git a/app/src/main/java/com/example/aprs/MainActivity.kt b/app/src/main/java/com/example/aprs/MainActivity.kt new file mode 100644 index 0000000..04a0c69 --- /dev/null +++ b/app/src/main/java/com/example/aprs/MainActivity.kt @@ -0,0 +1,340 @@ +package com.example.aprs + +import android.Manifest +import android.content.Context +import android.location.Location +import android.location.LocationListener +import android.location.LocationManager +import android.os.Bundle +import android.view.WindowManager +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.activity.result.contract.ActivityResultContracts +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.* +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.foundation.verticalScroll +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.* +import androidx.compose.material3.* +import androidx.compose.runtime.* +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.Brush +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.vector.ImageVector +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import androidx.core.content.ContextCompat +import androidx.core.view.WindowCompat +import androidx.core.view.WindowInsetsCompat +import androidx.core.view.WindowInsetsControllerCompat + +var permissionGranted by mutableStateOf(false) + +class MainActivity : ComponentActivity() { + + internal val permissionLauncher = registerForActivityResult(ActivityResultContracts.RequestPermission()) { granted -> + permissionGranted = granted + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + // Включаем полноэкранный режим + WindowCompat.setDecorFitsSystemWindows(window, false) + WindowInsetsControllerCompat(window, window.decorView).apply { + hide(WindowInsetsCompat.Type.statusBars()) + hide(WindowInsetsCompat.Type.navigationBars()) + systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE + } + + // Делаем контент за статус-баром и навигацией + window.setFlags( + WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, + WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS + ) + + setContent { + MaterialTheme( + colorScheme = darkColorScheme() + ) { + Surface( + modifier = Modifier.fillMaxSize(), + color = Color(0xFF0D0D0D) + ) { + CoordinateConverterScreen(this) + } + } + } + } +} + +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun CoordinateConverterScreen(activity: MainActivity) { + var location by remember { mutableStateOf(null) } + var isUpdating by remember { mutableStateOf(false) } + val context = activity.applicationContext + val scrollState = rememberScrollState() + + LaunchedEffect(Unit) { + val granted = ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) == android.content.pm.PackageManager.PERMISSION_GRANTED + permissionGranted = granted + if (!granted) { + activity.permissionLauncher.launch(Manifest.permission.ACCESS_FINE_LOCATION) + } + } + + DisposableEffect(permissionGranted) { + val lm = context.getSystemService(Context.LOCATION_SERVICE) as LocationManager + val listener = object : LocationListener { + override fun onLocationChanged(loc: Location) { + location = loc + isUpdating = false + } + + override fun onProviderEnabled(provider: String) {} + override fun onProviderDisabled(provider: String) {} + override fun onStatusChanged(provider: String?, status: Int, extras: Bundle?) {} + } + + if (permissionGranted) { + try { + isUpdating = true + val last = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER) ?: lm.getLastKnownLocation(LocationManager.NETWORK_PROVIDER) + if (last != null) { + location = last + isUpdating = false + } + lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000L, 0f, listener) + } catch (e: SecurityException) { + isUpdating = false + } + } + + onDispose { + lm.removeUpdates(listener) + } + } + + val lat = location?.latitude ?: 0.0 + val lon = location?.longitude ?: 0.0 + val hasLocation = location != null + + val aprs = if (hasLocation) LocationUtils.toAprs(lat, lon) else "—" + val maiden = if (hasLocation) LocationUtils.toMaidenhead(lat, lon) else "—" + val dmsLat = if (hasLocation) toDMS(lat, true) else "—" + val dmsLon = if (hasLocation) toDMS(lon, false) else "—" + + Column( + modifier = Modifier + .fillMaxSize() + .verticalScroll(scrollState) + .padding(16.dp), + horizontalAlignment = Alignment.CenterHorizontally + ) { + // Header + Spacer(modifier = Modifier.height(24.dp)) + Text( + text = "Конвертор координат", + fontSize = 28.sp, + fontWeight = FontWeight.Bold, + color = Color.White + ) + Text( + text = "GPS → APRS, Maidenhead", + fontSize = 14.sp, + color = Color.Gray, + modifier = Modifier.padding(top = 4.dp) + ) + + Spacer(modifier = Modifier.height(24.dp)) + + // Status indicator + Row( + modifier = Modifier + .clip(RoundedCornerShape(16.dp)) + .background( + if (isUpdating) Brush.horizontalGradient(listOf(Color(0xFFFFA500), Color(0xFFFF6600))) + else if (hasLocation) Brush.horizontalGradient(listOf(Color(0xFF00C853), Color(0xFF69F0AE))) + else Brush.horizontalGradient(listOf(Color(0xFFB0BEC5), Color(0xFF78909C))) + ) + .padding(horizontal = 16.dp, vertical = 8.dp), + verticalAlignment = Alignment.CenterVertically + ) { + Icon( + imageVector = if (isUpdating) Icons.Default.Refresh else if (hasLocation) Icons.Default.CheckCircle else Icons.Default.LocationOff, + contentDescription = null, + tint = Color.White, + modifier = Modifier.size(20.dp) + ) + Spacer(modifier = Modifier.width(8.dp)) + Text( + text = if (isUpdating) "Получение GPS..." else if (hasLocation) "GPS активен" else "Нет GPS", + color = Color.White, + fontWeight = FontWeight.Medium + ) + } + + Spacer(modifier = Modifier.height(24.dp)) + + // Decimal coordinates card + CoordinateCard( + title = "Десятичные координаты", + icon = Icons.Default.MyLocation, + gradient = listOf(Color(0xFF2196F3), Color(0xFF64B5F6)) + ) { + CoordinateRow(label = "Широта", value = if (hasLocation) String.format("%.6f°", lat) else "—") + Spacer(modifier = Modifier.height(8.dp)) + CoordinateRow(label = "Долгота", value = if (hasLocation) String.format("%.6f°", lon) else "—") + } + + Spacer(modifier = Modifier.height(12.dp)) + + // DMS coordinates card + CoordinateCard( + title = "Градусы, минуты, секунды", + icon = Icons.Default.Place, + gradient = listOf(Color(0xFF9C27B0), Color(0xFFBA68C8)) + ) { + CoordinateRow(label = "Широта", value = dmsLat) + Spacer(modifier = Modifier.height(8.dp)) + CoordinateRow(label = "Долгота", value = dmsLon) + } + + Spacer(modifier = Modifier.height(12.dp)) + + // APRS card + CoordinateCard( + title = "APRS формат", + icon = Icons.Default.Radio, + gradient = listOf(Color(0xFFFF5722), Color(0xFFFF8A65)) + ) { + Text( + text = aprs, + fontSize = 16.sp, + fontFamily = androidx.compose.ui.text.font.FontFamily.Monospace, + color = Color(0xFFFFCCBC), + modifier = Modifier.padding(vertical = 8.dp) + ) + } + + Spacer(modifier = Modifier.height(12.dp)) + + // Maidenhead card + CoordinateCard( + title = "Maidenhead (QTH локатор)", + icon = Icons.Default.GridOn, + gradient = listOf(Color(0xFF00BCD4), Color(0xFF4DD0E1)) + ) { + Text( + text = maiden, + fontSize = 24.sp, + fontWeight = FontWeight.Bold, + fontFamily = androidx.compose.ui.text.font.FontFamily.Monospace, + color = Color(0xFFB2EBF2), + modifier = Modifier.padding(vertical = 8.dp) + ) + } + + Spacer(modifier = Modifier.height(48.dp)) + + // Footer + Text( + text = "© 2026 UA1ZBE", + fontSize = 14.sp, + fontWeight = FontWeight.Medium, + color = Color(0xFF9C27B0) + ) + + Spacer(modifier = Modifier.height(16.dp)) + } +} + +@Composable +fun CoordinateCard( + title: String, + icon: ImageVector, + gradient: List, + content: @Composable ColumnScope.() -> Unit +) { + Card( + modifier = Modifier.fillMaxWidth(), + shape = RoundedCornerShape(16.dp), + colors = CardDefaults.cardColors(containerColor = Color(0xFF1A1A1A)) + ) { + Column( + modifier = Modifier + .fillMaxWidth() + .padding(16.dp) + ) { + Row( + modifier = Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically + ) { + Box( + modifier = Modifier + .size(40.dp) + .clip(RoundedCornerShape(12.dp)) + .background(Brush.horizontalGradient(gradient)), + contentAlignment = Alignment.Center + ) { + Icon( + imageVector = icon, + contentDescription = null, + tint = Color.White, + modifier = Modifier.size(22.dp) + ) + } + Spacer(modifier = Modifier.width(12.dp)) + Text( + text = title, + fontSize = 16.sp, + fontWeight = FontWeight.SemiBold, + color = Color.White + ) + } + Spacer(modifier = Modifier.height(16.dp)) + content() + } + } +} + +@Composable +fun CoordinateRow(label: String, value: String) { + Row( + modifier = Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.SpaceBetween, + verticalAlignment = Alignment.CenterVertically + ) { + Text( + text = label, + fontSize = 14.sp, + color = Color.Gray + ) + Text( + text = value, + fontSize = 16.sp, + fontWeight = FontWeight.Medium, + color = Color.White, + fontFamily = androidx.compose.ui.text.font.FontFamily.Monospace + ) + } +} + +fun toDMS(coordinate: Double, isLatitude: Boolean): String { + val abs = kotlin.math.abs(coordinate) + val deg = abs.toInt() + val minFloat = (abs - deg) * 60 + val min = minFloat.toInt() + val sec = (minFloat - min) * 60 + val direction = when { + isLatitude -> if (coordinate >= 0) "N" else "S" + else -> if (coordinate >= 0) "E" else "W" + } + return String.format("%d° %d' %.2f\" %s", deg, min, sec, direction) +} diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..80b730f --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..7001dcb Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..7847952 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..0c71bcf Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..7847952 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..bf5c0d0 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..7847952 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..899518d Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..7847952 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..fc7a105 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..7847952 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/values/ic_launcher_background.xml b/app/src/main/res/values/ic_launcher_background.xml new file mode 100644 index 0000000..e14ec06 --- /dev/null +++ b/app/src/main/res/values/ic_launcher_background.xml @@ -0,0 +1,4 @@ + + + #1A1A1A + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..c65255a --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,4 @@ + + + Конвертор координат + diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml new file mode 100644 index 0000000..f0f0e85 --- /dev/null +++ b/app/src/main/res/values/themes.xml @@ -0,0 +1,12 @@ + + + + diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..a45d3fc --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,9 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +plugins { + id("com.android.application") version "8.1.0" apply false + id("org.jetbrains.kotlin.android") version "1.9.10" apply false +} + +task("clean", Delete::class) { + delete(rootProject.buildDir) +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..1a8c9bc --- /dev/null +++ b/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx2g +android.useAndroidX=true +kotlin.code.style=official diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..ccebba7 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..42defcc --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip +networkTimeout=10000 +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..79a61d4 --- /dev/null +++ b/gradlew @@ -0,0 +1,244 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original 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 POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +# 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 "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# 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 ;; #( + MSYS* | 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" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..6689b85 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,92 @@ +@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=. +@rem This is normally unused +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% equ 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% equ 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! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/run_emulator_gui.sh b/run_emulator_gui.sh new file mode 100755 index 0000000..47ed883 --- /dev/null +++ b/run_emulator_gui.sh @@ -0,0 +1,79 @@ +#!/usr/bin/env bash +set -e + +if [ -z "$DISPLAY" ]; then + echo "No X DISPLAY set. Cannot start GUI emulator here." + echo "If you are on a remote session, run this on a desktop with X or use SSH -X." + exit 1 +fi + +SDK="$HOME/Android/Sdk" +ADB="$SDK/platform-tools/adb" +EMULATOR_BIN="$SDK/emulator/emulator" +AVD_NAME=aprs_avd +LOG=/tmp/emulator_aprs_gui.log + +echo "Killing existing emulator instances..." +pkill -f 'emulator' || true +sleep 1 + +if [ ! -x "$ADB" ]; then + echo "adb not found at $ADB"; exit 1 +fi + +echo "Restarting adb..." +$ADB kill-server || true +sleep 1 +$ADB start-server || true + +if [ ! -x "$EMULATOR_BIN" ]; then + echo "Emulator binary not found: $EMULATOR_BIN"; exit 1 +fi + +echo "Starting emulator '$AVD_NAME' (GUI). Log -> $LOG" +"$EMULATOR_BIN" -avd "$AVD_NAME" -partition-size 5120 -gpu host -wipe-data -no-boot-anim &>"$LOG" & +EMUPID=$! +echo "Emulator PID: $EMUPID" + +echo "Waiting for adb to see emulator..." +for i in $(seq 1 60); do + LIST=$($ADB devices | sed -n '2,200p' | tr -d '\r' || true) + if echo "$LIST" | grep -q 'emulator'; then + echo "Emulator connected to adb" + break + fi + echo "Waiting for adb... ($i)" + sleep 2 +done + +echo "Waiting for emulator to finish boot (up to 240s)..." +for i in $(seq 1 120); do + BOOT=$($ADB shell getprop sys.boot_completed 2>/dev/null | tr -d '\r' || true) + if [ "$BOOT" = "1" ]; then + echo "Emulator booted after $((i*2))s" + break + fi + echo "Boot waiting... ($i)" + sleep 2 +done + +echo "--- emulator log tail ---" +tail -n 200 "$LOG" || true + +echo "Building app..." +cd "$HOME/my_aprs_project/vs2" +chmod +x ./gradlew || true +./gradlew assembleDebug --no-daemon + +APK="app/build/outputs/apk/debug/app-debug.apk" +if [ -f "$APK" ]; then + echo "Installing APK" + $ADB install -r "$APK" || true + $ADB shell am start -n com.example.aprs/.MainActivity || true + echo "App launched on emulator (check window)." +else + echo "APK not found: $APK" + exit 1 +fi + +echo "Done. ADB devices:"; $ADB devices -l diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..aa2d0b6 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,18 @@ +pluginManagement { + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} + +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + } +} + +rootProject.name = "aprs-app" +include(":app") diff --git a/setup_emulator_and_run.sh b/setup_emulator_and_run.sh new file mode 100755 index 0000000..6745f1b --- /dev/null +++ b/setup_emulator_and_run.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash +set -e + +echo "This script installs Android command-line tools, creates an AVD, starts an emulator, builds and installs the app. You will be asked for sudo password for package installation." + +# 1) system packages (requires sudo) +sudo apt update +sudo apt install -y openjdk-11-jdk unzip curl qemu-kvm libvirt-daemon-system libvirt-clients + +export ANDROID_SDK_ROOT="$HOME/Android/Sdk" +mkdir -p "$ANDROID_SDK_ROOT/cmdline-tools" +cd /tmp + +CLI_ZIP=commandlinetools-linux.zip +if [ ! -f "$CLI_ZIP" ]; then + echo "Downloading Android command-line tools..." + curl -L -o "$CLI_ZIP" https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip +fi + +unzip -o "$CLI_ZIP" -d "$ANDROID_SDK_ROOT/cmdline-tools/temp" +rm -rf "$ANDROID_SDK_ROOT/cmdline-tools/latest" +mv "$ANDROID_SDK_ROOT/cmdline-tools/temp" "$ANDROID_SDK_ROOT/cmdline-tools/latest" + +export PATH="$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_SDK_ROOT/platform-tools:$ANDROID_SDK_ROOT/emulator:$PATH" + +echo "Installing SDK packages (this will download several hundred MB)..." +yes | "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" --sdk_root="$ANDROID_SDK_ROOT" "platform-tools" "platforms;android-33" "build-tools;33.0.0" "emulator" "system-images;android-33;google_apis;x86_64" + +yes | "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" --licenses --sdk_root="$ANDROID_SDK_ROOT" + +AVD_NAME=aprs_avd +echo no | "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/avdmanager" create avd -n "$AVD_NAME" -k "system-images;android-33;google_apis;x86_64" --force + +echo "Starting emulator in background (log -> /tmp/emulator_aprs.log). This may take 1-3 minutes." +nohup "$ANDROID_SDK_ROOT/emulator/emulator" -avd "$AVD_NAME" -no-window -no-audio -gpu swiftshader_indirect &>/tmp/emulator_aprs.log & + +echo "Waiting for emulator to boot..." +adb wait-for-device +for i in {1..60}; do + BOOT_DONE=$(adb shell getprop sys.boot_completed 2>/dev/null | tr -d '\r') || BOOT_DONE="" + if [ "$BOOT_DONE" = "1" ]; then + echo "Emulator booted" + break + fi + sleep 2 +done + +echo "Building app with Gradle wrapper (may take several minutes)..." +cd "$HOME/my_aprs_project/vs2" +chmod +x ./gradlew || true +./gradlew assembleDebug --no-daemon + +APK_PATH="app/build/outputs/apk/debug/app-debug.apk" +if [ -f "$APK_PATH" ]; then + echo "Installing APK to emulator..." + adb install -r "$APK_PATH" + adb shell am start -n com.example.aprs/.MainActivity || true + echo "Done: app installed and launched on emulator" + echo "If emulator has no window, you can run Android Studio emulator GUI or remove -no-window flag in this script to display it." +else + echo "APK not found: $APK_PATH" + exit 1 +fi