refactor: rename Yorlik -> Klottr (paket, resurser, manifest, mappbyten)

This commit is contained in:
2025-08-25 00:38:57 +02:00
parent 0d30ae0051
commit cc498ac55f
54 changed files with 278 additions and 292 deletions

View File

@@ -29,19 +29,20 @@ fun propOrEmpty(key: String) = localProps[key] ?: ""
android {
namespace = "com.example.yorlik"
namespace = "app.klottr"
compileSdk = 35
defaultConfig {
applicationId = "com.example.yorlik"
applicationId = "app.klottr"
minSdk = 26
targetSdk = 35
versionCode = 7
versionName = "0.2.0"
versionCode = 8
versionName = "0.2.1"
// Byggtid i UTC (ISO 8601) genereras vid build-konfiguration
val buildTimeUtc = Instant.now().toString()
buildConfigField("String", "BUILD_TIME_UTC", "\"$buildTimeUtc\"")
buildConfigField("String", "APP_NAME", "\"Klottr\"")
// BuildConfig-fält (åtkomst i Kotlin via BuildConfig.X)
@@ -108,3 +109,9 @@ dependencies {
// WorkManager (valfritt, ej nödvändigt här)
implementation("androidx.work:work-runtime-ktx:2.9.1")
}
androidComponents {
onVariants { v ->
println("### Klottr: variant=${v.name}, applicationId=${v.applicationId.get()}")
}
}

View File

@@ -4,7 +4,7 @@
"type": "APK",
"kind": "Directory"
},
"applicationId": "com.example.yorlik",
"applicationId": "app.klottr",
"variantName": "release",
"elements": [
{

View File

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

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.example.yorlik"
<manifest package="app.klottr"
xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Behörigheter -->
@@ -14,7 +14,7 @@
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="Yorlik"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Yorlik">
@@ -25,7 +25,7 @@
<activity
android:name=".MainActivity"
android:name="app.klottr.MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -34,7 +34,7 @@
</activity>
<service
android:name=".LocationService"
android:name="app.klottr.LocationService"
android:exported="false"
android:foregroundServiceType="location" />
</application>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 151 KiB

After

Width:  |  Height:  |  Size: 76 KiB

View File

@@ -1,10 +1,10 @@
package com.example.yorlik
package app.klottr
import android.Manifest
import android.app.Notification
import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.Service
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.os.Build
@@ -12,14 +12,12 @@ import android.os.IBinder
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import androidx.core.content.ContextCompat
import com.example.yorlik.net.Geocache
import com.example.yorlik.net.NoteDTO
import com.example.yorlik.util.FoundStore
import com.example.yorlik.util.FoundStore.LAYER_DM
import com.example.yorlik.util.FoundStore.LAYER_KLOTTER
import com.example.yorlik.util.FoundStore.LAYER_WIKI
import com.example.yorlik.util.LastLocationStore
import com.example.yorlik.util.SettingsStore
import app.klottr.R
import app.klottr.net.Geocache
import app.klottr.net.NoteDTO
import app.klottr.util.FoundStore
import app.klottr.util.LastLocationStore
import app.klottr.util.SettingsStore
import com.google.android.gms.location.LocationCallback
import com.google.android.gms.location.LocationRequest
import com.google.android.gms.location.LocationResult
@@ -33,16 +31,17 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.tasks.await
import kotlin.math.roundToInt
class LocationService : Service() {
companion object {
private const val CHANNEL_LOCATION_ID = "yorlik_location" // för foreground, tyst
private const val CHANNEL_HITS_ID = "yorlik_hits" // NY kanal för fynd-notiser
private const val CHANNEL_LOCATION_ID = "Klottr_location" // för foreground, tyst
private const val CHANNEL_HITS_ID = "Klottr_hits" // NY kanal för fynd-notiser
const val ACTION_FOUND_UPDATED = "com.example.yorlik.ACTION_FOUND_UPDATED"
const val ACTION_CLEAR_FOUND_SESSION = "com.example.yorlik.ACTION_CLEAR_FOUND_SESSION"
const val ACTION_RESCAN_NOW = "com.example.yorlik.ACTION_RESCAN_NOW"
const val ACTION_LOCATION_TICK = "com.example.yorlik.ACTION_LOCATION_TICK"
const val ACTION_FOUND_UPDATED = "app.klottr.ACTION_FOUND_UPDATED"
const val ACTION_CLEAR_FOUND_SESSION = "app.klottr.ACTION_CLEAR_FOUND_SESSION"
const val ACTION_RESCAN_NOW = "app.klottr.ACTION_RESCAN_NOW"
const val ACTION_LOCATION_TICK = "app.klottr.ACTION_LOCATION_TICK"
}
@@ -115,11 +114,11 @@ class LocationService : Service() {
if (!hasLocationPerms()) return
val req = LocationRequest.create().apply {
interval = 4_000L
fastestInterval = 2_000L
smallestDisplacement = 3f
priority = Priority.PRIORITY_HIGH_ACCURACY
maxWaitTime = 5_000L
LocationRequest.setInterval = 4_000L
LocationRequest.setFastestInterval = 2_000L
LocationRequest.setSmallestDisplacement = 3f
LocationRequest.setPriority = Priority.PRIORITY_HIGH_ACCURACY
LocationRequest.setMaxWaitTime = 5_000L
}
callback = object : LocationCallback() {
@@ -167,8 +166,8 @@ class LocationService : Service() {
}
private fun hasLocationPerms(): Boolean {
val fine = ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED
val coarse = ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED
val fine = ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED
val coarse = ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED
return fine || coarse
}
@@ -187,7 +186,7 @@ class LocationService : Service() {
for (n in nearby) {
val d = distanceMeters(lat, lon, n.a, n.o).roundToInt()
handleCandidate(
layer = LAYER_KLOTTER,
layer = FoundStore.LAYER_KLOTTER,
id = n.i.toString(),
label = n.t.orEmpty(),
pt = LatLng(n.a, n.o),
@@ -268,16 +267,16 @@ class LocationService : Service() {
val dist = "≈ ${distanceM} m"
val shown = label.ifBlank {
when (layer) {
LAYER_KLOTTER -> "Okänt klotter"
LAYER_WIKI -> "Wikipedia"
LAYER_DM -> "DigitaltMuseum"
FoundStore.LAYER_KLOTTER -> "Okänt klotter"
FoundStore.LAYER_WIKI -> "Wikipedia"
FoundStore.LAYER_DM -> "DigitaltMuseum"
else -> "Plats"
}
}
val title = when (layer) {
LAYER_KLOTTER -> "Funnet klotter"
LAYER_WIKI -> "Funnen Wikipediaplats"
LAYER_DM -> "Funnen DigitaltMuseum-plats"
FoundStore.LAYER_KLOTTER -> "Funnet klotter"
FoundStore.LAYER_WIKI -> "Funnen Wikipediaplats"
FoundStore.LAYER_DM -> "Funnen DigitaltMuseum-plats"
else -> "Funnen plats"
}
return title to "$shown • $dist"
@@ -298,12 +297,12 @@ class LocationService : Service() {
private fun ensureChannel() {
if (Build.VERSION.SDK_INT >= 26) {
val mgr = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
val mgr = getSystemService(NOTIFICATION_SERVICE) as NotificationManager
// Foreground-kanal (tyst)
val loc = NotificationChannel(
CHANNEL_LOCATION_ID,
"Yorlik plats",
"Klottr plats",
NotificationManager.IMPORTANCE_MIN
).apply { description = "Bakgrundspositionering" }
mgr.createNotificationChannel(loc)
@@ -311,7 +310,7 @@ class LocationService : Service() {
// NY: Fynd-notiser (synliga)
val hits = NotificationChannel(
CHANNEL_HITS_ID,
"Yorlik fynd",
"Klottr fynd",
NotificationManager.IMPORTANCE_HIGH // vill du ha pling: HIGH
).apply { description = "Aviseringar för nya/återkommande fynd" }
mgr.createNotificationChannel(hits)
@@ -321,7 +320,7 @@ class LocationService : Service() {
private fun persistentNotification(): Notification {
return NotificationCompat.Builder(this, CHANNEL_LOCATION_ID)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("Yorlik")
.setContentTitle("Klottr")
.setContentText("Platsaktivering pågår")
.setOngoing(true)
.build()

View File

@@ -1,4 +1,4 @@
package com.example.yorlik
package app.klottr
import android.Manifest
import android.content.BroadcastReceiver
@@ -21,6 +21,7 @@ import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContracts
import androidx.activity.result.contract.ActivityResultContracts.PickVisualMedia
import androidx.activity.result.PickVisualMediaRequest
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
@@ -74,33 +75,40 @@ import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties
import androidx.core.content.ContextCompat
import androidx.core.content.pm.PackageInfoCompat
import com.example.yorlik.BuildConfig
import com.example.yorlik.data.AppDatabase
import com.example.yorlik.data.NoteRepository
import com.example.yorlik.net.ApiConfig
import com.example.yorlik.util.Config
import com.example.yorlik.net.DigitaltMuseum
import com.example.yorlik.net.DigitaltMuseumItem
import com.example.yorlik.net.Fornsok
import com.example.yorlik.net.FornsokItem
import com.example.yorlik.net.Geocache
import com.example.yorlik.net.NoteDTO
import com.example.yorlik.net.Wikipedia
import com.example.yorlik.net.WikipediaPage
import com.example.yorlik.net.createNote
import com.example.yorlik.net.fetchNoteDetail
import com.example.yorlik.net.imageUrl
import com.example.yorlik.net.uploadImageFromUri
import com.example.yorlik.net.createNoteDoc
import com.example.yorlik.ui.theme.YorlikTheme
import com.example.yorlik.util.Auth
import com.example.yorlik.util.FoundStore
import com.example.yorlik.util.FoundStore.LAYER_DM
import com.example.yorlik.util.FoundStore.LAYER_KLOTTER
import com.example.yorlik.util.FoundStore.LAYER_WIKI
import com.example.yorlik.util.LastLocationStore
import com.example.yorlik.util.OutboxStore
import com.example.yorlik.util.SettingsStore
import androidx.work.Constraints
import androidx.work.NetworkType
import androidx.work.OneTimeWorkRequestBuilder
import androidx.work.WorkManager
import app.klottr.data.AppDatabase
import app.klottr.data.NoteRepository
import app.klottr.net.Api
import app.klottr.net.ApiConfig
import app.klottr.net.DigitaltMuseum
import app.klottr.net.DigitaltMuseumItem
import app.klottr.net.Fornsok
import app.klottr.net.FornsokItem
import app.klottr.net.Geocache
import app.klottr.net.NoteDTO
import app.klottr.net.Wikipedia
import app.klottr.net.WikipediaPage
import app.klottr.net.createNoteDoc
import app.klottr.net.fetchNoteDetail
import app.klottr.net.imageUrl
import app.klottr.net.uploadImageFromUri
import app.klottr.theme.KlottrTheme
import app.klottr.util.Auth
import app.klottr.util.Config
import app.klottr.util.FoundStore
import app.klottr.util.ImageBitmapCache
import app.klottr.util.LastLocationStore
import app.klottr.util.NoteDetailCache
import app.klottr.util.OutboxStore
import app.klottr.util.SettingsStore
import app.klottr.BuildConfig
import app.klottr.util.FoundStore.LAYER_DM
import app.klottr.util.FoundStore.LAYER_KLOTTER
import app.klottr.util.FoundStore.LAYER_WIKI
import app.klottr.work.OutboxWorker
import com.google.android.gms.auth.api.signin.GoogleSignIn
import com.google.android.gms.common.api.ApiException
import com.google.android.gms.location.LocationServices as GmsLocationServices
@@ -119,8 +127,6 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.tasks.await
import kotlinx.coroutines.withContext
import okhttp3.OkHttpClient
import okhttp3.Request
import org.json.JSONObject
import java.io.BufferedInputStream
import java.io.File
@@ -129,6 +135,7 @@ import java.net.URL
import java.time.Instant
import java.time.ZoneId
import java.time.format.DateTimeFormatter
import java.util.UUID
import kotlin.math.abs
import kotlin.math.roundToInt
@@ -193,8 +200,8 @@ class MainActivity : ComponentActivity() {
onDispose { SettingsStore.unobserve(context, listener) }
}
YorlikTheme(darkTheme = night) {
YorlikApp(
KlottrTheme(darkTheme = night) {
KlottrApp(
onRequestPerms = { this@MainActivity.requestAllRuntimePerms() },
onLogin = {
val client = Auth.signInClient(this)
@@ -227,7 +234,7 @@ private data class OpenKlotter(val id: String, val lat: Double, val lon: Double,
private data class OpenWiki(val pageId: Long, val lat: Double?, val lon: Double?)
private data class OpenFornsok(val item: com.example.yorlik.net.FornsokItem)
private data class OpenFornsok(val item: FornsokItem)
data class NoteHandle(val id: String, val lat: Double, val lon: Double, val label: String)
@@ -243,7 +250,7 @@ private data class DocumentDraft(
@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun YorlikApp(
private fun KlottrApp(
onRequestPerms: () -> Unit,
onLogin: () -> Unit,
onLogout: () -> Unit
@@ -256,7 +263,7 @@ private fun YorlikApp(
LaunchedEffect(Unit) { Auth.refreshSilently(context) { } }
// DB/Repo
val db = remember { AppDatabase.getInstance(context) }
val db = remember { AppDatabase.Companion.getInstance(context) }
val repo = remember { NoteRepository(db.noteDao()) }
val notes by repo.allNotes().collectAsState(initial = emptyList())
@@ -343,7 +350,7 @@ private fun YorlikApp(
// 🔴 NYTT: Omedelbar UI-uppdatering när FoundStore ändras (SharedPreferences)
DisposableEffect(Unit) {
val prefs = context.getSharedPreferences("yorlik_found_store", Context.MODE_PRIVATE)
val prefs = context.getSharedPreferences("klottr_found_store", Context.MODE_PRIVATE)
val listener = SharedPreferences.OnSharedPreferenceChangeListener { _, _ ->
// Trigga omritning varje gång FoundStore uppdateras
forceEmptyFound = false
@@ -443,7 +450,7 @@ private fun YorlikApp(
Scaffold(
topBar = {
CenterAlignedTopAppBar(
title = { Text("Yorlik v" + BuildConfig.VERSION_NAME) },
title = { Text("Klottr v" + BuildConfig.VERSION_NAME) },
actions = {
IconButton(onClick = { showSettings = true }) {
Icon(Icons.Filled.Settings, contentDescription = "Inställningar")
@@ -554,32 +561,32 @@ private fun YorlikApp(
}
// Buffra detalj + bild för kända klotter inom radien → snabbare öppning
LaunchedEffect(foundList) {
val my = com.example.yorlik.util.LastLocationStore.lastKnownLocation
val my = LastLocationStore.lastKnownLocation
val myLat = my?.latitude
val myLon = my?.longitude
foundList.forEach { f ->
if (f.layer == com.example.yorlik.util.FoundStore.LAYER_KLOTTER) {
if (f.layer == LAYER_KLOTTER) {
val inside = if (myLat != null && myLon != null)
distanceMeters(myLat, myLon, f.lat, f.lon) <= com.example.yorlik.util.Config.DEFAULT_KLOTTER_RADIUS_M
distanceMeters(myLat, myLon, f.lat, f.lon) <= Config.DEFAULT_KLOTTER_RADIUS_M
else true
if (inside) {
val idL = f.id.toLongOrNull() ?: return@forEach
if (com.example.yorlik.util.NoteDetailCache.get(idL) == null) {
if (NoteDetailCache.get(idL) == null) {
// Hämta detalj med NOTISENS koordinater (ger rätt “bevis” på servern)
val detail = withContext(kotlinx.coroutines.Dispatchers.IO) {
com.example.yorlik.net.fetchNoteDetail(idL, f.lat, f.lon)
val detail = withContext(Dispatchers.IO) {
fetchNoteDetail(idL, f.lat, f.lon)
}
if (detail != null) {
com.example.yorlik.util.NoteDetailCache.put(idL, detail)
NoteDetailCache.put(idL, detail)
val img = detail.image
if (img != null && img.id > 0 && com.example.yorlik.util.ImageBitmapCache.get(img.id) == null) {
withContext(kotlinx.coroutines.Dispatchers.IO) {
val url = com.example.yorlik.net.imageUrl(img.id, detail.id, f.lat, f.lon)
val resp = com.example.yorlik.net.Api.svc.getImageStream(url)
if (img != null && img.id > 0 && ImageBitmapCache.get(img.id) == null) {
withContext(Dispatchers.IO) {
val url = imageUrl(img.id, detail.id, f.lat, f.lon)
val resp = Api.svc.getImageStream(url)
if (resp.isSuccessful) {
resp.body()?.byteStream()?.use { ins ->
android.graphics.BitmapFactory.decodeStream(ins)?.let { bmp ->
com.example.yorlik.util.ImageBitmapCache.put(img.id, bmp)
BitmapFactory.decodeStream(ins)?.let { bmp ->
ImageBitmapCache.put(img.id, bmp)
}
}
}
@@ -599,7 +606,7 @@ private fun YorlikApp(
items(foundList) { f ->
var displayLabel by remember(f.id, f.layer, f.label) { mutableStateOf(f.label) }
LaunchedEffect(f.id, f.layer) {
if (f.layer == LAYER_KLOTTER && (displayLabel.isBlank() || displayLabel == "Okänt klotter")) {
if (f.layer == FoundStore.LAYER_KLOTTER && (displayLabel.isBlank() || displayLabel == "Okänt klotter")) {
val items = withContext(Dispatchers.IO) {
Geocache.getNearby(lat = f.lat, lon = f.lon, radiusMeters = 60, ttlMs = 0)
}
@@ -609,7 +616,7 @@ private fun YorlikApp(
}
}
}
val clickable = (f.layer == LAYER_WIKI) || (f.layer == LAYER_FORNSOK || f.layer == LAYER_KLOTTER)
val clickable = (f.layer == FoundStore.LAYER_WIKI) || (f.layer == LAYER_FORNSOK || f.layer == FoundStore.LAYER_KLOTTER)
// --- NYTT: hämta away/first/last för UI ---
val away = FoundStore.isAway(context, f.layer, f.id)
@@ -621,8 +628,8 @@ private fun YorlikApp(
Text(
displayLabel.ifBlank {
when (f.layer) {
LAYER_KLOTTER -> "Okänt klotter"
LAYER_DM -> "DigitaltMuseum"
FoundStore.LAYER_KLOTTER -> "Okänt klotter"
FoundStore.LAYER_DM -> "DigitaltMuseum"
LAYER_FORNSOK -> "Fornsök"
else -> "Wikipedia"
}
@@ -634,15 +641,15 @@ private fun YorlikApp(
supportingContent = {
// 1) Typ (lager)
val layerName = when (f.layer) {
LAYER_KLOTTER -> "Klotter"
FoundStore.LAYER_KLOTTER -> "Klotter"
LAYER_FORNSOK -> "Fornsök"
LAYER_DM -> "DigitaltMuseum"
LAYER_WIKI -> "Wikipedia"
FoundStore.LAYER_DM -> "DigitaltMuseum"
FoundStore.LAYER_WIKI -> "Wikipedia"
else -> "Plats"
}
// 2) Avstånd från senaste kända position
val my = com.example.yorlik.util.LastLocationStore.lastKnownLocation
val my = LastLocationStore.lastKnownLocation
val distM = my?.let { distanceMeters(it.latitude, it.longitude, f.lat, f.lon).roundToInt() }
val distText = distM?.let { "$it\u00A0m" } ?: "-" // \u00A0 = hårt mellanslag
@@ -650,8 +657,8 @@ private fun YorlikApp(
val coordPart = if (showCoords) " • (%.5f, %.5f)".format(f.lat, f.lon) else ""
// 4) Tider från FoundStore (för debug/insikt)
val firstVis = com.example.yorlik.util.FoundStore.getFirstVisitMillis(context, f.layer, f.id)
val lastVis = com.example.yorlik.util.FoundStore.getLastVisitMillis(context, f.layer, f.id) ?: f.timeMillis
val firstVis = FoundStore.getFirstVisitMillis(context, f.layer, f.id)
val lastVis = FoundStore.getLastVisitMillis(context, f.layer, f.id) ?: f.timeMillis
val firstText = firstVis?.let { formatTime(it) } ?: "-"
val lastText = formatTime(lastVis)
@@ -662,7 +669,7 @@ private fun YorlikApp(
},
modifier = if (clickable) Modifier.clickable {
when (f.layer) {
LAYER_KLOTTER -> {
FoundStore.LAYER_KLOTTER -> {
// Öppna samma detaljruta som från “Närliggande”
openKlotter = OpenKlotter(
id = f.id,
@@ -671,7 +678,7 @@ private fun YorlikApp(
label = displayLabel.ifBlank { "Okänt klotter" } // vi har ofta redan berikat displayLabel ovan
)
}
LAYER_WIKI -> {
FoundStore.LAYER_WIKI -> {
val pid = f.id.toLongOrNull()
if (pid != null) openWiki = OpenWiki(pid, f.lat, f.lon)
}
@@ -752,9 +759,9 @@ private fun YorlikApp(
},
isKnownNote = { noteId ->
// Känd = finns i Hittat (FoundStore) → ska alltid visa titel
com.example.yorlik.util.FoundStore
FoundStore
.getAll(context)
.any { it.layer == com.example.yorlik.util.FoundStore.LAYER_KLOTTER && it.id == noteId.toString() }
.any { it.layer == LAYER_KLOTTER && it.id == noteId.toString() }
}
)
}
@@ -848,7 +855,7 @@ private fun YorlikApp(
var isSavingDoc by remember { mutableStateOf(false) }
if (showWrite) {
// Lagra positionen när man klickat Klottra:
val initial = com.example.yorlik.util.LastLocationStore.lastKnownLocation
val initial = LastLocationStore.lastKnownLocation
val initialLat = initial?.latitude
val initialLon = initial?.longitude
@@ -860,7 +867,7 @@ private fun YorlikApp(
return@WriteDocDialog
}
val created = System.currentTimeMillis()
val requestId = java.util.UUID.randomUUID().toString()
val requestId = UUID.randomUUID().toString()
if (isSavingDoc) return@WriteDocDialog
isSavingDoc = true
@@ -874,7 +881,7 @@ private fun YorlikApp(
}
if (draft.imageUri != null && imgId == null) {
withContext(Dispatchers.Main) {
val msg = com.example.yorlik.net.Api.lastUploadError
val msg = Api.lastUploadError
?: "Bilduppladdning misslyckades."
Toast.makeText(context, msg, Toast.LENGTH_LONG).show()
resetSavingCounter++
@@ -890,7 +897,7 @@ private fun YorlikApp(
title = draft.title.trim(),
body = draft.body.trim(),
imageId = imgId,
radiusM = com.example.yorlik.util.Config.DEFAULT_KLOTTER_RADIUS_M,
radiusM = Config.DEFAULT_KLOTTER_RADIUS_M,
createdAt = created,
clientRequestId = requestId
)
@@ -909,12 +916,12 @@ private fun YorlikApp(
append(draft.body.trim())
}.trim()
val match = nearby.firstOrNull {
it.t == combined && kotlin.math.abs(it.c - created) <= 2_000
it.t == combined && abs(it.c - created) <= 2_000
}
if (match != null) {
com.example.yorlik.util.FoundStore.markFound(
FoundStore.markFound(
context,
com.example.yorlik.util.FoundStore.LAYER_KLOTTER,
LAYER_KLOTTER,
match.i.toString(),
label = match.t,
lat = match.a,
@@ -923,7 +930,7 @@ private fun YorlikApp(
)
withContext(Dispatchers.Main) {
context.sendBroadcast(
Intent(com.example.yorlik.LocationService.ACTION_FOUND_UPDATED)
Intent(LocationService.Companion.ACTION_FOUND_UPDATED)
)
}
}
@@ -943,8 +950,8 @@ private fun YorlikApp(
mime.equals("image/png", true) -> ".png"
else -> ".img"
}
val outDir = java.io.File(context.filesDir, "outbox").apply { mkdirs() }
val outFile = java.io.File(outDir, "img_${created}$ext")
val outDir = File(context.filesDir, "outbox").apply { mkdirs() }
val outFile = File(outDir, "img_${created}$ext")
try {
context.contentResolver.openInputStream(draft.imageUri!!)?.use { ins ->
outFile.outputStream().use { outs -> ins.copyTo(outs, 8 * 1024) }
@@ -956,25 +963,25 @@ private fun YorlikApp(
}
}
com.example.yorlik.util.OutboxStore.addDoc(
OutboxStore.addDoc(
context = context,
lat = selLat,
lon = selLon,
title = titleText,
body = bodyText,
createdAt = created,
radiusM = com.example.yorlik.util.Config.DEFAULT_KLOTTER_RADIUS_M,
radiusM = Config.DEFAULT_KLOTTER_RADIUS_M,
imagePath = imagePath,
imageMime = imageMime
)
Toast.makeText(context, "Offline. Sparas i utkorgen.", Toast.LENGTH_LONG).show()
val constraints = androidx.work.Constraints.Builder()
.setRequiredNetworkType(androidx.work.NetworkType.CONNECTED)
val constraints = Constraints.Builder()
.setRequiredNetworkType(NetworkType.CONNECTED)
.build()
val req = androidx.work.OneTimeWorkRequestBuilder<com.example.yorlik.work.OutboxWorker>()
val req = OneTimeWorkRequestBuilder<OutboxWorker>()
.setConstraints(constraints).build()
androidx.work.WorkManager.getInstance(context).enqueue(req)
WorkManager.getInstance(context).enqueue(req)
showWrite = false
}
} finally {
@@ -989,19 +996,19 @@ private fun YorlikApp(
}
if (showLoginRequired) {
androidx.compose.material3.AlertDialog(
AlertDialog(
onDismissRequest = { showLoginRequired = false },
title = { androidx.compose.material3.Text("Inloggning krävs") },
text = { androidx.compose.material3.Text("Du måste logga in för att kunna klottra.") },
title = { Text("Inloggning krävs") },
text = { Text("Du måste logga in för att kunna klottra.") },
confirmButton = {
androidx.compose.material3.Button(onClick = {
Button(onClick = {
showLoginRequired = false
onLogin() // använder samma onLogin som redan används av “Logga in”-knappen
}) { androidx.compose.material3.Text("Logga in") }
}) { Text("Logga in") }
},
dismissButton = {
androidx.compose.material3.Button(onClick = { showLoginRequired = false }) {
androidx.compose.material3.Text("Stäng")
Button(onClick = { showLoginRequired = false }) {
Text("Stäng")
}
}
)
@@ -1025,7 +1032,7 @@ private fun NearbyDialog(
fornsokRadius: Int,
onKlotterClick: (String, Double, Double, String) -> Unit,
onWikiClick: (Long, Double, Double) -> Unit,
onFornsokClick: (com.example.yorlik.net.FornsokItem) -> Unit,
onFornsokClick: (FornsokItem) -> Unit,
onMarkedFound: () -> Unit,
onClose: () -> Unit
) {
@@ -1059,7 +1066,7 @@ private fun NearbyDialog(
val d = distanceMeters(lat, lon, w.lat, w.lon).roundToInt()
add(
NearbyEntry(
layer = LAYER_WIKI,
layer = FoundStore.LAYER_WIKI,
id = w.pageId.toString(),
label = w.title,
lat = w.lat,
@@ -1074,7 +1081,7 @@ private fun NearbyDialog(
val d = distanceMeters(lat, lon, dmi.lat, dmi.lon).roundToInt()
add(
NearbyEntry(
layer = LAYER_DM,
layer = FoundStore.LAYER_DM,
id = dmi.id,
label = dmi.title,
lat = dmi.lat,
@@ -1112,7 +1119,7 @@ private fun NearbyDialog(
}
add(
NearbyEntry(
layer = LAYER_KLOTTER,
layer = FoundStore.LAYER_KLOTTER,
id = n.i.toString(),
label = display,
lat = n.a,
@@ -1135,10 +1142,10 @@ private fun NearbyDialog(
val subtitle = buildString {
append(
when (e.layer) {
LAYER_WIKI -> "Wikipedia"
LAYER_DM -> "DigitaltMuseum"
FoundStore.LAYER_WIKI -> "Wikipedia"
FoundStore.LAYER_DM -> "DigitaltMuseum"
LAYER_FORNSOK -> "Fornsök"
LAYER_KLOTTER -> "Klotter"
FoundStore.LAYER_KLOTTER -> "Klotter"
else -> "Plats"
}
)
@@ -1197,7 +1204,7 @@ private fun WriteDocDialog(
)
}
}
val satellite = com.example.yorlik.util.SettingsStore.getSatelliteMap(context)
val satellite = SettingsStore.getSatelliteMap(context)
AlertDialog(
@@ -1252,7 +1259,7 @@ private fun WriteDocDialog(
) {
Button(
onClick = {
val L = com.example.yorlik.util.LastLocationStore.lastKnownLocation
val L = LastLocationStore.lastKnownLocation
if (L == null) {
Toast.makeText(context, "Ingen plats ännu – försök igen.", Toast.LENGTH_SHORT).show()
} else {
@@ -1420,7 +1427,7 @@ private fun SettingsDialog(
AlertDialog(
onDismissRequest = onClose,
properties = androidx.compose.ui.window.DialogProperties(usePlatformDefaultWidth = false),
properties = DialogProperties(usePlatformDefaultWidth = false),
title = { Text("Inställningar") },
text = {
Box(
@@ -1449,7 +1456,7 @@ private fun SettingsDialog(
val versionCode = PackageInfoCompat.getLongVersionCode(pInfo)
Text(
"Yorlik v${BuildConfig.VERSION_NAME} (${BuildConfig.BUILD_TYPE}) • build ${versionCode}",
"Klottr v${BuildConfig.VERSION_NAME} (${BuildConfig.BUILD_TYPE}) • build ${versionCode}",
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
@@ -1674,7 +1681,7 @@ private fun KlotterDialog(
LaunchedEffect(id) {
val idL = id.toLongOrNull()
if (idL != null) {
com.example.yorlik.util.NoteDetailCache.get(idL)?.let { d ->
NoteDetailCache.get(idL)?.let { d ->
titleText = d.title.ifBlank { "Okänt klotter" }
text = d.body.ifBlank { titleText }
val img = d.image
@@ -1682,7 +1689,7 @@ private fun KlotterDialog(
loading = false
if (img != null && img.id > 0) {
com.example.yorlik.util.ImageBitmapCache.get(img.id)?.let { bmp ->
ImageBitmapCache.get(img.id)?.let { bmp ->
imgBitmap = bmp
}
}
@@ -1695,10 +1702,10 @@ private fun KlotterDialog(
val baseLabel = label.trim()
val isKnown = baseLabel.isNotBlank() && baseLabel != "Okänt klotter"
Log.d("Yorlik", "KlotterDialog start id=$id isKnown=$isKnown label='${baseLabel.take(40)}'")
Log.d("Klottr", "KlotterDialog start id=$id isKnown=$isKnown label='${baseLabel.take(40)}'")
// Hämta ev. färsk plats (fallback LastLocationStore)
val my = com.example.yorlik.util.LastLocationStore.lastKnownLocation
val my = LastLocationStore.lastKnownLocation
val fused = GmsLocationServices.getFusedLocationProviderClient(context)
val current = try {
fused.lastLocation.await()
@@ -1716,7 +1723,7 @@ private fun KlotterDialog(
// Försök hämta detalj/bild om posten är känd (Hittat) ELLER vi är inom radien
val canAttempt = isKnown || withinRadius
Log.d("Yorlik", "KlotterDialog canAttempt=$canAttempt withinRadius=$withinRadius")
Log.d("Klottr", "KlotterDialog canAttempt=$canAttempt withinRadius=$withinRadius")
if (canAttempt) {
// get_note.php ska få: Hittat => NOTISENS coords, annars besökarens (fallback notisens)
@@ -1724,9 +1731,11 @@ private fun KlotterDialog(
val reqLon = if (isKnown) lon else (qLon ?: lon)
val detail = withContext(Dispatchers.IO) {
try { fetchNoteDetail(id.toLong(), reqLat, reqLon) } catch (_: Throwable) { null }
try {
fetchNoteDetail(id.toLong(), reqLat, reqLon)
} catch (_: Throwable) { null }
}
Log.d("Yorlik", "detail fetch id=$id ok=${detail != null}")
Log.d("Klottr", "detail fetch id=$id ok=${detail != null}")
if (detail != null) {
// Sätt titel + brödtext från servern
@@ -1735,7 +1744,7 @@ private fun KlotterDialog(
// Lagra detalj i cache för snabb öppning nästa gång
runCatching {
com.example.yorlik.util.NoteDetailCache.put(detail.id, detail)
NoteDetailCache.put(detail.id, detail)
}
// Bild: bygg URL som innehåller NOTISENS koordinater (servern kräver koordinat-bevis)
@@ -1755,9 +1764,9 @@ private fun KlotterDialog(
}
val resp = withContext(Dispatchers.IO) {
runCatching { com.example.yorlik.net.Api.svc.getImageStream(fullUrl) }.getOrNull()
runCatching { Api.svc.getImageStream(fullUrl) }.getOrNull()
}
Log.d("Yorlik", "img GET code=${resp?.code()} url=$fullUrl")
Log.d("Klottr", "img GET code=${resp?.code()} url=$fullUrl")
val bmp = if (resp?.isSuccessful == true) {
resp.body()?.byteStream()?.use { BitmapFactory.decodeStream(it) }
@@ -1766,7 +1775,7 @@ private fun KlotterDialog(
imgBitmap = bmp
// cachea för snabb öppning nästa gång
val imgId = imgMeta.id
if (imgId > 0) com.example.yorlik.util.ImageBitmapCache.put(imgId, bmp)
if (imgId > 0) ImageBitmapCache.put(imgId, bmp)
}
}
} else {
@@ -1837,7 +1846,7 @@ private fun KlotterDialog(
onClick = {
val labelEnc = Uri.encode(titleText.ifBlank { "Plats" })
val uri = Uri.parse("geo:$lat,$lon?q=$lat,$lon($labelEnc)")
val intent = Intent(Intent.ACTION_VIEW, uri).apply { `package` = "com.google.android.apps.maps" }
val intent = Intent(Intent.ACTION_VIEW, uri).apply { Intent.setPackage = "com.google.android.apps.maps" }
try { context.startActivity(intent) } catch (_: Exception) {
context.startActivity(Intent(Intent.ACTION_VIEW, uri))
}
@@ -1857,12 +1866,12 @@ private fun KlotterDialog(
}
}
@OptIn(androidx.compose.foundation.ExperimentalFoundationApi::class)
@OptIn(ExperimentalFoundationApi::class)
@Composable
private fun ImageViewerDialog(bitmap: Bitmap, onClose: () -> Unit) {
androidx.compose.ui.window.Dialog(
Dialog(
onDismissRequest = onClose,
properties = androidx.compose.ui.window.DialogProperties(usePlatformDefaultWidth = false)
properties = DialogProperties(usePlatformDefaultWidth = false)
) {
Box(
modifier = Modifier
@@ -1931,7 +1940,7 @@ private fun WikiArticleDialog(
AlertDialog(
onDismissRequest = onClose,
properties = androidx.compose.ui.window.DialogProperties(usePlatformDefaultWidth = false),
properties = DialogProperties(usePlatformDefaultWidth = false),
title = {
Box(Modifier.fillMaxWidth().widthIn(max = dialogWidth)) {
Text(if (title.isNotBlank()) title else "Wikipedia")
@@ -1978,7 +1987,7 @@ private fun WikiArticleDialog(
if (lat != null && lon != null) {
val uri = Uri.parse("geo:$lat,$lon?q=$lat,$lon(${Uri.encode(title.ifBlank { "Wikipedia-plats" })})")
val intent = Intent(Intent.ACTION_VIEW, uri).apply {
`package` = "com.google.android.apps.maps"
Intent.setPackage = "com.google.android.apps.maps"
}
try { context.startActivity(intent) } catch (_: Exception) {
context.startActivity(Intent(Intent.ACTION_VIEW, uri))
@@ -1998,7 +2007,7 @@ private fun WikiArticleDialog(
@Composable
private fun FornsokDialog(
item: com.example.yorlik.net.FornsokItem,
item: FornsokItem,
onClose: () -> Unit
) {
val context = LocalContext.current
@@ -2014,7 +2023,7 @@ private fun FornsokDialog(
AlertDialog(
onDismissRequest = onClose,
properties = androidx.compose.ui.window.DialogProperties(usePlatformDefaultWidth = false),
properties = DialogProperties(usePlatformDefaultWidth = false),
title = {
Box(Modifier.fillMaxWidth().widthIn(max = dialogWidth)) {
Text(title)
@@ -2040,7 +2049,7 @@ private fun FornsokDialog(
val geoTitle = Uri.encode(title)
val geo = Uri.parse("geo:$platLat,$platLon?q=$platLat,$platLon($geoTitle)")
val intent = Intent(Intent.ACTION_VIEW, geo).apply {
`package` = "com.google.android.apps.maps"
Intent.setPackage = "com.google.android.apps.maps"
}
try { context.startActivity(intent) } catch (_: Exception) {
context.startActivity(Intent(Intent.ACTION_VIEW, geo))
@@ -2068,9 +2077,9 @@ private fun FornsokDialog(
fun hasFgLocationPerms(ctx: Context): Boolean {
val fine = ContextCompat.checkSelfPermission(ctx, Manifest.permission.ACCESS_FINE_LOCATION) ==
android.content.pm.PackageManager.PERMISSION_GRANTED
PackageManager.PERMISSION_GRANTED
val coarse = ContextCompat.checkSelfPermission(ctx, Manifest.permission.ACCESS_COARSE_LOCATION) ==
android.content.pm.PackageManager.PERMISSION_GRANTED
PackageManager.PERMISSION_GRANTED
return fine || coarse
}
@@ -2078,7 +2087,7 @@ fun hasBgLocationPerm(ctx: Context): Boolean {
return if (Build.VERSION.SDK_INT < 29) true
else ContextCompat.checkSelfPermission(
ctx, Manifest.permission.ACCESS_BACKGROUND_LOCATION
) == android.content.pm.PackageManager.PERMISSION_GRANTED
) == PackageManager.PERMISSION_GRANTED
}
private fun formatTime(ms: Long): String {

View File

@@ -1,4 +1,4 @@
package com.example.yorlik
package app.klottr
import android.content.Context
import android.content.Intent
@@ -18,16 +18,16 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.dp
import com.example.yorlik.net.DigitaltMuseum
import com.example.yorlik.net.DigitaltMuseumItem
import com.example.yorlik.net.Fornsok
import com.example.yorlik.net.FornsokItem
import com.example.yorlik.net.Geocache
import com.example.yorlik.net.NoteDTO
import com.example.yorlik.net.Wikipedia
import com.example.yorlik.net.WikipediaPage
import com.example.yorlik.util.Config
import com.example.yorlik.util.SettingsStore
import app.klottr.net.DigitaltMuseum
import app.klottr.net.DigitaltMuseumItem
import app.klottr.net.Fornsok
import app.klottr.net.FornsokItem
import app.klottr.net.Geocache
import app.klottr.net.NoteDTO
import app.klottr.net.Wikipedia
import app.klottr.net.WikipediaPage
import app.klottr.util.Config
import app.klottr.util.SettingsStore
import com.google.android.gms.location.LocationServices as GmsLocationServices
import com.google.android.gms.location.Priority
import com.google.android.gms.maps.model.CameraPosition
@@ -37,7 +37,6 @@ import com.google.maps.android.compose.CameraPositionState
import com.google.maps.android.compose.GoogleMap
import com.google.maps.android.compose.MapProperties
import com.google.maps.android.compose.MapType
import com.google.maps.android.compose.Marker
import com.google.maps.android.compose.MarkerInfoWindow
import com.google.maps.android.compose.MarkerState
import com.google.maps.android.compose.MapUiSettings
@@ -175,7 +174,7 @@ fun MapDialog(
distanceMeters(lat, lon, n.a, n.o).roundToInt() else Int.MAX_VALUE
val titleLine = n.t.substringBefore('\n').ifBlank { "Okänt klotter" }
val radius = com.example.yorlik.util.Config.DEFAULT_KLOTTER_RADIUS_M
val radius = Config.DEFAULT_KLOTTER_RADIUS_M
val visited = isKnownNote(n.i.toLong())
val within = (d != Int.MAX_VALUE && d <= radius)
val display = if (visited || (within && titleLine != "Okänt klotter")) titleLine else "Okänt klotter"
@@ -339,7 +338,7 @@ private fun openInMaps(ctx: Context, lat: Double?, lon: Double?, title: String?)
if (lat == null || lon == null) return
val uri = Uri.parse("geo:$lat,$lon?q=$lat,$lon(${Uri.encode(title ?: "Plats")})")
val intent = Intent(Intent.ACTION_VIEW, uri).apply {
`package` = "com.google.android.apps.maps"
Intent.setPackage = "com.google.android.apps.maps"
}
try {
ctx.startActivity(intent)
@@ -353,7 +352,7 @@ private fun openWalkingDirections(ctx: Context, lat: Double?, lon: Double?, titl
val label = Uri.encode(title ?: "Plats")
val uri = Uri.parse("google.navigation?q=$lat,$lon($label)&mode=w")
val intent = Intent(Intent.ACTION_VIEW, uri).apply {
`package` = "com.google.android.apps.maps"
Intent.setPackage = "com.google.android.apps.maps"
}
try {
ctx.startActivity(intent)

View File

@@ -1,12 +1,12 @@
package com.example.yorlik.work
package app.klottr.work
import android.content.Context
import androidx.work.CoroutineWorker
import androidx.work.WorkerParameters
import com.example.yorlik.net.createNote
import com.example.yorlik.net.createNoteDoc
import com.example.yorlik.net.uploadImageFromFile
import com.example.yorlik.util.OutboxStore
import app.klottr.net.createNote
import app.klottr.net.createNoteDoc
import app.klottr.net.uploadImageFromFile
import app.klottr.util.OutboxStore
import java.io.File
import java.security.MessageDigest

View File

@@ -1,4 +1,4 @@
package com.example.yorlik.data
package app.klottr.data
import android.content.Context
import androidx.room.Database
@@ -26,7 +26,7 @@ abstract class AppDatabase : RoomDatabase() {
INSTANCE ?: Room.databaseBuilder(
ctx.applicationContext,
AppDatabase::class.java,
"yorlik.db"
"klottr.db"
)
.addMigrations(MIGRATION_1_2)
.build().also { INSTANCE = it }

View File

@@ -1,4 +1,4 @@
package com.example.yorlik.data
package app.klottr.data
import androidx.room.*
import kotlinx.coroutines.flow.Flow

View File

@@ -1,4 +1,4 @@
package com.example.yorlik.data
package app.klottr.data
import androidx.room.Entity
import androidx.room.Index

View File

@@ -1,4 +1,4 @@
package com.example.yorlik.data
package app.klottr.data
import kotlinx.coroutines.flow.Flow

View File

@@ -1,4 +1,4 @@
package com.example.yorlik.net
package app.klottr.net
import com.squareup.moshi.Moshi
import com.squareup.moshi.Json
@@ -13,8 +13,8 @@ import retrofit2.Retrofit
import retrofit2.converter.moshi.MoshiConverterFactory
import retrofit2.http.*
import retrofit2.http.Url
import com.example.yorlik.util.Auth
import com.example.yorlik.BuildConfig
import app.klottr.util.Auth
import app.klottr.BuildConfig
import java.io.File
import java.util.concurrent.TimeUnit
import android.content.Context
@@ -28,7 +28,7 @@ import okhttp3.RequestBody.Companion.toRequestBody
/**
* Läser bas‑URL och API‑nyckel från BuildConfig (hålls i local.properties → buildConfigField).
* Byt inte namn här – resten av appen förväntar sig NoteDTO/CreateBody/YorlikApi.
* Byt inte namn här – resten av appen förväntar sig NoteDTO/CreateBody/KlottrApi.
*/
object ApiConfig {
val SERVER_API_BASE_URL: String get() = ensureTrailingSlash(BuildConfig.SERVER_API_BASE_URL)
@@ -110,7 +110,7 @@ data class NoteDetailBody(
/** Dina endpoints – samma namn/banor som i v0.0.1 */
interface YorlikApi {
interface KlottrApi {
@Multipart
@POST("upload_image.php")
@@ -204,7 +204,7 @@ object Api {
.build()
}
val svc: YorlikApi = retrofit.create(YorlikApi::class.java)
val svc: KlottrApi = retrofit.create(KlottrApi::class.java)
}
/** Resultatcontainer för cache/ETag‑flödet. */
@@ -261,7 +261,7 @@ suspend fun uploadImageFromUri(
): Long? {
Api.lastUploadError = null
val mime = context.contentResolver.getType(uri) ?: "application/octet-stream"
val tmp = kotlin.runCatching { java.io.File.createTempFile("yorlik_up", ".bin", context.cacheDir) }.getOrNull() ?: return null
val tmp = runCatching { File.createTempFile("Klottr_up", ".bin", context.cacheDir) }.getOrNull() ?: return null
try {
context.contentResolver.openInputStream(uri)?.use { ins ->
tmp.outputStream().use { outs -> ins.copyTo(outs, 8 * 1024) }
@@ -283,14 +283,14 @@ suspend fun uploadImageFromUri(
val lonPart = lon.toString().toRequestBody("text/plain".toMediaTypeOrNull())
val resp = try { Api.svc.uploadImage(imgPart, latPart, lonPart) } catch (t: Throwable) {
Log.d("Yorlik", "uploadImage exception: ${t.message}")
Log.d("Klottr", "uploadImage exception: ${t.message}")
return null
}
Log.d("Yorlik", "uploadImage code=${resp.code()} body=${resp.body()}")
Log.d("Klottr", "uploadImage code=${resp.code()} body=${resp.body()}")
if (!resp.isSuccessful) {
val err = resp.errorBody()?.string()
Log.d("Yorlik", "uploadImage FAIL code=${resp.code()} err=$err")
Log.d("Klottr", "uploadImage FAIL code=${resp.code()} err=$err")
// Försök plocka ut {"error": "...", "max": "..."} om servern skickar det
Api.lastUploadError = extractApiErrorMessage(err) ?: "Uppladdningen misslyckades (kod ${resp.code()})."
return null
@@ -349,14 +349,14 @@ suspend fun uploadImageFromFile(
val lonPart = lon.toString().toRequestBody("text/plain".toMediaTypeOrNull())
val resp = try { Api.svc.uploadImage(imgPart, latPart, lonPart) } catch (t: Throwable) {
Log.d("Yorlik", "uploadImage(file) exception: ${t.message}")
Log.d("Klottr", "uploadImage(file) exception: ${t.message}")
return null
}
Log.d("Yorlik", "uploadImage(file) code=${resp.code()} body=${resp.body()}")
Log.d("Klottr", "uploadImage(file) code=${resp.code()} body=${resp.body()}")
if (!resp.isSuccessful) {
val err = resp.errorBody()?.string()
Log.d("Yorlik", "uploadImage(file) FAIL code=${resp.code()} err=$err")
Log.d("Klottr", "uploadImage(file) FAIL code=${resp.code()} err=$err")
return null
}
@@ -385,7 +385,7 @@ suspend fun createNote(
createdAt: Long,
clientRequestId: String?
): Boolean {
if (com.example.yorlik.util.Auth.idToken == null || com.example.yorlik.util.Auth.userId == null) {
if (Auth.idToken == null || Auth.userId == null) {
return false
}
@@ -418,7 +418,7 @@ suspend fun createNoteDoc(
createdAt: Long,
clientRequestId: String?
): Boolean {
if (com.example.yorlik.util.Auth.idToken == null || com.example.yorlik.util.Auth.userId == null) {
if (Auth.idToken == null || Auth.userId == null) {
return false
}
val payload = CreateDocBody(
@@ -445,16 +445,16 @@ suspend fun fetchNoteDetail(id: Long, lat: Double, lon: Double): NoteDetailDTO?
val body = NoteDetailBody(id = id, lat = lat, lon = lon)
return try {
val resp = Api.svc.getNote(body)
android.util.Log.d("Yorlik", "get_note code=${resp.code()} ok=${resp.isSuccessful}")
Log.d("Klottr", "get_note code=${resp.code()} ok=${resp.isSuccessful}")
if (!resp.isSuccessful) {
val err = resp.errorBody()?.string()
android.util.Log.d("Yorlik", "get_note err=$err")
Log.d("Klottr", "get_note err=$err")
null
} else {
resp.body()
}
} catch (t: Throwable) {
android.util.Log.d("Yorlik", "get_note exception: ${t.message}")
Log.d("Klottr", "get_note exception: ${t.message}")
null
}
}

View File

@@ -1,4 +1,4 @@
package com.example.yorlik.net
package app.klottr.net
import android.util.Log

View File

@@ -1,4 +1,4 @@
package com.example.yorlik.net
package app.klottr.net
import android.util.Log
import kotlinx.coroutines.Dispatchers
@@ -147,7 +147,7 @@ object Fornsok {
connectTimeout = 10000
readTimeout = 20000
setRequestProperty("Accept", "application/json")
setRequestProperty("User-Agent", "Yorlik/0.1.x (Android)")
setRequestProperty("User-Agent", "Klottr/0.1.x (Android)")
}
return try {
val code = conn.responseCode

View File

@@ -1,4 +1,4 @@
package com.example.yorlik.net
package app.klottr.net
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext

View File

@@ -0,0 +1,11 @@
package app.klottr.net
import android.os.Build
object NetHeaders {
val userAgent: String by lazy {
val os = Build.VERSION.RELEASE ?: "?"
"${BuildConfig.APP_NAME}/${BuildConfig.VERSION_NAME} " +
"(Android $os; ${BuildConfig.APPLICATION_ID}; ${BuildConfig.BUILD_TIME_UTC})"
}
}

View File

@@ -1,10 +1,13 @@
package com.example.yorlik.net
package app.klottr.net
import org.json.JSONObject
import java.net.HttpURLConnection
import java.net.URL
import java.net.URLEncoder
import android.content.Context
import android.os.Build
data class WikipediaPage(
val pageId: Long,
val title: String,

View File

@@ -1,4 +1,4 @@
package com.example.yorlik.ui.theme
package app.klottr.theme
import androidx.compose.ui.graphics.Color

View File

@@ -1,6 +1,5 @@
package com.example.yorlik.ui.theme
package app.klottr.theme
import android.app.Activity
import android.os.Build
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
@@ -34,7 +33,7 @@ private val LightColorScheme = lightColorScheme(
)
@Composable
fun YorlikTheme(
fun KlottrTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
// Dynamic color is available on Android 12+
dynamicColor: Boolean = true,

View File

@@ -1,4 +1,4 @@
package com.example.yorlik.ui.theme
package app.klottr.theme
import androidx.compose.material3.Typography
import androidx.compose.ui.text.TextStyle

View File

@@ -1,8 +1,8 @@
package com.example.yorlik.util
package app.klottr.util
import android.content.Context
import android.util.Log
import com.example.yorlik.BuildConfig
import app.klottr.BuildConfig
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import com.google.android.gms.auth.api.signin.GoogleSignIn
@@ -14,7 +14,7 @@ object Auth {
private val WEB_CLIENT_ID: String
get() = BuildConfig.WEB_CLIENT_ID
private const val PREFS = "yorlik_auth"
private const val PREFS = "klottr_auth"
private const val KEY_IDTOKEN = "id_token"
private const val KEY_SUB = "sub"
private const val KEY_EMAIL = "email"
@@ -69,7 +69,7 @@ object Auth {
_loggedIn.value = token != null
_email.value = mail
if (token == null) {
Log.w("Yorlik/Auth", "ID‑token är null efter sign‑in. Kontrollera WEB_CLIENT_ID i Auth.kt och på servern.")
Log.w("Klottr/Auth", "ID‑token är null efter sign‑in. Kontrollera WEB_CLIENT_ID i Auth.kt och på servern.")
}
}

View File

@@ -1,4 +1,4 @@
package com.example.yorlik.util
package app.klottr.util
object Config {
// Finns redan hos dig:

View File

@@ -1,4 +1,4 @@
package com.example.yorlik.util
package app.klottr.util
import kotlinx.coroutines.flow.MutableStateFlow

View File

@@ -1,4 +1,4 @@
package com.example.yorlik.util
package app.klottr.util
import android.content.Context
import org.json.JSONObject
@@ -13,7 +13,7 @@ data class FoundEntry(
)
object FoundStore {
private const val PREF = "yorlik_found_store"
private const val PREF = "klottr_found_store"
private const val KEY_KEYS = "keys" // StringSet
// Lager

View File

@@ -1,8 +1,8 @@
package com.example.yorlik.util
package app.klottr.util
import android.location.Location
import app.klottr.data.NoteEntity
import kotlinx.coroutines.flow.MutableSharedFlow
import com.example.yorlik.data.NoteEntity
import kotlin.math.*
fun distanceMeters(lat1: Double, lon1: Double, lat2: Double, lon2: Double): Double {

View File

@@ -1,4 +1,4 @@
package com.example.yorlik.util
package app.klottr.util
import kotlinx.coroutines.flow.MutableStateFlow

View File

@@ -1,7 +1,7 @@
package com.example.yorlik.util
package app.klottr.util
import android.graphics.Bitmap
import com.example.yorlik.net.NoteDetailDTO
import app.klottr.net.NoteDetailDTO
import java.util.LinkedHashMap
object NoteDetailCache {

View File

@@ -1,4 +1,4 @@
package com.example.yorlik.util
package app.klottr.util
import android.app.Notification
import android.app.NotificationChannel
@@ -6,12 +6,12 @@ import android.app.NotificationManager
import android.content.Context
import android.os.Build
import androidx.core.app.NotificationCompat
import com.example.yorlik.R
import com.example.yorlik.data.NoteEntity
import app.klottr.data.NoteEntity
import app.klottr.R
object Notifications {
const val CHANNEL_ONGOING = "yorlik_ongoing"
const val CHANNEL_HIT = "yorlik_hit"
const val CHANNEL_ONGOING = "klottr_ongoing"
const val CHANNEL_HIT = "klottr_hit"
const val ONGOING_ID = 1
private var ongoingText: String = "Bevakar plats var 10:e sekund."
@@ -27,7 +27,7 @@ object Notifications {
ongoingText = text
return NotificationCompat.Builder(ctx, CHANNEL_ONGOING)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("Yorlik kör i bakgrunden")
.setContentTitle("Klottr kör i bakgrunden")
.setContentText(text)
.setOngoing(true)
.build()
@@ -43,7 +43,7 @@ object Notifications {
val nm = ctx.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
val n = NotificationCompat.Builder(ctx, CHANNEL_HIT)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("Yorlik – sparad plats")
.setContentTitle("Klottr – sparad plats")
.setContentText(note.text.take(80))
.setStyle(NotificationCompat.BigTextStyle().bigText("${note.text}\n(${note.lat}, ${note.lon})"))
.setAutoCancel(true)

View File

@@ -1,4 +1,4 @@
package com.example.yorlik.util
package app.klottr.util
import android.content.Context
import org.json.JSONArray
@@ -9,7 +9,7 @@ import org.json.JSONObject
* för att skickas senare när nätet kommer tillbaka.
*/
object OutboxStore {
private const val PREFS = "yorlik_outbox"
private const val PREFS = "klottr_outbox"
private const val KEY = "pending_json"
data class PendingNote(
val lat: Double,

View File

@@ -1,4 +1,4 @@
package com.example.yorlik.util
package app.klottr.util
import android.content.Context
import org.json.JSONArray
@@ -9,7 +9,7 @@ import org.json.JSONObject
* Lagrar de senaste 200 med (text, lat, lon, timeMillis), nyast först.
*/
object RecentHitsStore {
private const val PREFS = "yorlik_recent_hits"
private const val PREFS = "klottr_recent_hits"
private const val KEY = "hits_json"
private const val MAX = 200

View File

@@ -1,4 +1,4 @@
package com.example.yorlik.util
package app.klottr.util
import android.content.Context
@@ -7,7 +7,7 @@ import android.content.Context
* Implementerat med SharedPreferences StringSet för enkelhet.
*/
object SeenHits {
private const val PREFS_NAME = "yorlik_seen_hits"
private const val PREFS_NAME = "klottr_seen_hits"
private const val KEY_SET = "seen_ids"
private fun prefs(ctx: Context) =

View File

@@ -1,10 +1,10 @@
package com.example.yorlik.util
package app.klottr.util
import android.content.Context
import android.content.SharedPreferences
object SettingsStore {
private const val PREFS = "yorlik_settings"
private const val PREFS = "klottr_settings"
// Keys (befintliga)
const val KEY_ONLY_NEW_HITS = "only_new_hits"

View File

@@ -1,10 +1,10 @@
package com.example.yorlik.util
package app.klottr.util
import android.content.Context
import java.util.UUID
object UserId {
private const val PREFS = "yorlik_prefs"
private const val PREFS = "klottr_prefs"
private const val KEY = "user_id"
/** Ett anonymt men stabilt ID per app-installation. */

View File

@@ -1,9 +1,9 @@
package com.example.yorlik.util
package app.klottr.util
import android.content.Context
object WikiHitIndex {
private const val PREFS = "yorlik_wiki_hit_index"
private const val PREFS = "klottr_wiki_hit_index"
private fun prefs(ctx: Context) = ctx.getSharedPreferences(PREFS, Context.MODE_PRIVATE)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.7 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

@@ -1,3 +1,3 @@
<resources>
<string name="app_name">Yorlik</string>
<string name="app_name">Klottr</string>
</resources>

View File

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