Remove unused declarations; fix KMP expect/actual and SettingsStore duplicates
- Safe-delete unused declarations across app/ and shared/ - Optimize imports - KMP: align expect/actual for formatRelativeOrTime(ms: Long) and update callers - SettingsStore: remove duplicate wrapper functions causing overloads
This commit is contained in:
@@ -98,7 +98,7 @@ class LocationService : Service() {
|
||||
LastLocationStore.lastKnownLocation = L
|
||||
|
||||
// Uppdatera away-flaggor för den position du ska scanna mot
|
||||
FoundStore.updateAwayFlags(this@LocationService, L.latitude, L.longitude)
|
||||
FoundStore.updateAwayFlags(L.latitude, L.longitude)
|
||||
|
||||
// 1) Tala om att data (ev. away) kan ha ändrats
|
||||
sendBroadcast(Intent(ACTION_FOUND_UPDATED))
|
||||
@@ -142,7 +142,7 @@ class LocationService : Service() {
|
||||
scope.launch {
|
||||
|
||||
// Uppdatera away-flaggor för ALLA sparade fynd utifrån aktuell position
|
||||
FoundStore.updateAwayFlags(this@LocationService, loc.latitude, loc.longitude)
|
||||
FoundStore.updateAwayFlags(loc.latitude, loc.longitude)
|
||||
// (UI lyssnar på SharedPreferences, men vi pingar ändå för säkerhets skull)
|
||||
sendBroadcast(Intent(ACTION_FOUND_UPDATED))
|
||||
|
||||
@@ -158,7 +158,7 @@ class LocationService : Service() {
|
||||
LastLocationStore.lastKnownLocation = refined
|
||||
sendBroadcast(Intent(ACTION_LOCATION_TICK))
|
||||
|
||||
FoundStore.updateAwayFlags(this@LocationService, refined.latitude, refined.longitude)
|
||||
FoundStore.updateAwayFlags(refined.latitude, refined.longitude)
|
||||
sendBroadcast(Intent(ACTION_FOUND_UPDATED))
|
||||
checkMatches(refined.latitude, refined.longitude)
|
||||
}
|
||||
@@ -187,7 +187,7 @@ class LocationService : Service() {
|
||||
|
||||
private suspend fun checkMatches(lat: Double, lon: Double) {
|
||||
// Just nu kör vi bara klotter här (20 m). Wikipedia/DigitaltMuseum/Fornsök scannas i UI vid behov.
|
||||
val showKlotter = SettingsStore.getShowKlotter(this)
|
||||
val showKlotter = SettingsStore.getShowKlotter()
|
||||
if (showKlotter) {
|
||||
val nearby: List<NoteDTO> = try {
|
||||
Geocache.getNearby(lat, lon, radiusMeters = 120, ttlMs = 0L)
|
||||
@@ -205,7 +205,7 @@ class LocationService : Service() {
|
||||
pt = LatLng(n.a, n.o),
|
||||
distanceM = d,
|
||||
insideRadiusM = 20,
|
||||
onlyNew = SettingsStore.getOnlyNewHits(this)
|
||||
onlyNew = SettingsStore.getOnlyNewHits()
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -235,11 +235,11 @@ class LocationService : Service() {
|
||||
}
|
||||
|
||||
// Lagrings-baserad re-arm: om FoundStore flaggat "away=true" och vi nu är inne i radien
|
||||
val wasAwayStore = FoundStore.isAway(this, layer, id)
|
||||
val wasAwayStore = FoundStore.isAway(layer, id)
|
||||
|
||||
if (distanceM <= insideRadiusM) {
|
||||
val wasNotifiedThisSession = notifiedWhileInside[k] == true
|
||||
val alreadyFound = FoundStore.isFound(this, layer, id)
|
||||
val alreadyFound = FoundStore.isFound(layer, id)
|
||||
val now = System.currentTimeMillis()
|
||||
|
||||
// Markera i FoundStore:
|
||||
@@ -248,7 +248,7 @@ class LocationService : Service() {
|
||||
// - (behåller session-reentry för bakåtkompabilitet)
|
||||
val shouldMark = !alreadyFound || wasAwayStore || (!onlyNew && reenteredSession)
|
||||
if (shouldMark) {
|
||||
val marked = FoundStore.markFound(this, layer, id, label, pt.latitude, pt.longitude, now)
|
||||
val marked = FoundStore.markFound(layer, id, label, pt.latitude, pt.longitude, now)
|
||||
if (marked) sendBroadcast(Intent(ACTION_FOUND_UPDATED))
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ import androidx.activity.result.contract.ActivityResultContracts.PickVisualMedia
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.gestures.rememberTransformableState
|
||||
import androidx.compose.foundation.gestures.transformable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
@@ -36,36 +35,22 @@ import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.heightIn
|
||||
import androidx.compose.foundation.layout.imePadding
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.widthIn
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
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.Info
|
||||
import androidx.compose.material.icons.filled.Settings
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.CenterAlignedTopAppBar
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.Divider
|
||||
import androidx.compose.material3.DropdownMenu
|
||||
import androidx.compose.material3.DropdownMenuItem
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.ExposedDropdownMenuBox
|
||||
import androidx.compose.material3.ExposedDropdownMenuDefaults
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.ListItem
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.RadioButton
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Switch
|
||||
@@ -80,15 +65,12 @@ import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.graphics.Brush // För vertikal gradient
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.asImageBitmap
|
||||
import androidx.compose.ui.graphics.graphicsLayer
|
||||
@@ -130,9 +112,7 @@ 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.deleteNote
|
||||
import app.klottr.net.fetchImageStreamPost
|
||||
@@ -142,8 +122,6 @@ import app.klottr.shared.SharedPing
|
||||
import app.klottr.theme.KlottrTheme
|
||||
import app.klottr.ui.DmDetailContent // Ny: delad DM-layout
|
||||
import app.klottr.ui.FornsokDetailContent // Ny: delad Fornsök-layout
|
||||
import app.klottr.ui.FoundList // Delad, material-fri listkomponent för "Hittat"
|
||||
import app.klottr.ui.FoundContent // Delat innehåll för “Hittat”
|
||||
import app.klottr.ui.FoundDetailContent // Delad detalj-UI (CMP)
|
||||
import app.klottr.ui.KlottrAboutContent
|
||||
import app.klottr.ui.KlottrHomeContent // Ny: delat mittinnehåll
|
||||
@@ -157,9 +135,7 @@ import app.klottr.ui.WriteDocContent // Använd delad, material-fri formulär-UI
|
||||
import app.klottr.util.Auth
|
||||
import app.klottr.util.Config
|
||||
import app.klottr.util.FoundStore
|
||||
import app.klottr.util.FoundStore.LAYER_DM
|
||||
import app.klottr.util.FoundStore.LAYER_KLOTTER
|
||||
import app.klottr.util.FoundStore.LAYER_WIKI
|
||||
import app.klottr.util.ImageBitmapCache
|
||||
import app.klottr.util.KLog
|
||||
import app.klottr.util.LastLocationStore
|
||||
@@ -169,7 +145,6 @@ import app.klottr.util.SettingsStore
|
||||
import app.klottr.util.buildFoundDetailStrings // Delad formatterare (commonMain)
|
||||
import app.klottr.util.formatCoords
|
||||
import app.klottr.util.formatDistance
|
||||
import app.klottr.util.formatRelativeOrTime
|
||||
import app.klottr.work.OutboxWorker
|
||||
import com.google.android.gms.auth.api.signin.GoogleSignIn
|
||||
import com.google.android.gms.common.api.ApiException
|
||||
@@ -195,7 +170,6 @@ import java.io.File
|
||||
import java.net.HttpURLConnection
|
||||
import java.net.URL
|
||||
import java.util.UUID
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.roundToInt
|
||||
import com.google.android.gms.location.LocationServices as GmsLocationServices
|
||||
|
||||
@@ -297,14 +271,6 @@ class MainActivity : ComponentActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Hjälp ----
|
||||
|
||||
data class NoteHandle(val id: String, val lat: Double, val lon: Double, val label: String)
|
||||
|
||||
private fun extractTitleFromCompact(t: String): String =
|
||||
t.substringBefore('\n').ifBlank { "Okänt klotter" }
|
||||
|
||||
|
||||
private data class DocumentDraft(
|
||||
val title: String,
|
||||
val body: String,
|
||||
@@ -465,7 +431,7 @@ private fun KlottrAppShell(
|
||||
LastLocationStore.lastKnownLocation = android.location.Location("klottr").apply {
|
||||
latitude = gp.lat; longitude = gp.lon
|
||||
} // Nytt: spegla in i din befintliga store
|
||||
FoundStore.updateAwayFlags(context, gp.lat, gp.lon) // Oför: men nu med delad modell
|
||||
FoundStore.updateAwayFlags(gp.lat, gp.lon) // Oför: men nu med delad modell
|
||||
|
||||
// Tvinga omritning så att avstånd visas utan scroll
|
||||
locationTick++
|
||||
@@ -556,10 +522,10 @@ private fun KlottrAppShell(
|
||||
fetchDm = { la, lo, r -> DigitaltMuseum.getNearby(la, lo, radiusMeters = r) },
|
||||
fetchFornsok = { la, lo, r -> Fornsok.getNearby(la, lo, radiusMeters = r) },
|
||||
markFound = { layer, id, label, la, lo, now ->
|
||||
FoundStore.markFound(context, layer, id, label, la, lo, now)
|
||||
FoundStore.markFound(layer, id, label, la, lo, now)
|
||||
},
|
||||
updateAwayFlags = { la, lo ->
|
||||
FoundStore.updateAwayFlags(context, la, lo)
|
||||
FoundStore.updateAwayFlags(la, lo)
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -591,7 +557,7 @@ private fun KlottrAppShell(
|
||||
) { padding ->
|
||||
// --- Nytt: definiera listan + overrides före UI-anropet ---
|
||||
val foundList = remember(foundRefresh, forceEmptyFound) {
|
||||
if (forceEmptyFound) emptyList() else FoundStore.getAll(context)
|
||||
if (forceEmptyFound) emptyList() else FoundStore.getAll()
|
||||
}
|
||||
val labelOverrides = remember { androidx.compose.runtime.mutableStateMapOf<String, String>() }
|
||||
val foundKey = foundList.joinToString("|") { "${it.layer}:${it.id}" }
|
||||
@@ -687,7 +653,7 @@ private fun KlottrAppShell(
|
||||
}
|
||||
}
|
||||
},
|
||||
isBold = { f -> !FoundStore.isAway(context, f.layer, f.id) },
|
||||
isBold = { f -> !FoundStore.isAway(f.layer, f.id) },
|
||||
distanceFormatter = ::formatDistance,
|
||||
coordsFormatter = ::formatCoords,
|
||||
rowTextStyle = MaterialTheme.typography.bodyMedium.copy(
|
||||
@@ -746,7 +712,7 @@ private fun KlottrAppShell(
|
||||
fornsokRadius = fornsokRadius,
|
||||
defaultKlotterRadiusM = Config.DEFAULT_KLOTTER_RADIUS_M,
|
||||
knownKlotterLabel = { id ->
|
||||
FoundStore.getAll(context)
|
||||
FoundStore.getAll()
|
||||
.asSequence()
|
||||
.filter { it.layer == FoundStore.LAYER_KLOTTER }
|
||||
.associate { it.id to it.label }[id]
|
||||
@@ -813,11 +779,6 @@ private fun KlottrAppShell(
|
||||
FoundOpenAction.None -> Unit
|
||||
}
|
||||
},
|
||||
onMarkedFound = {
|
||||
refreshFound()
|
||||
// ✅ FIX: använd redan fångat 'context' – inte LocalContext.current här
|
||||
context.sendBroadcast(Intent(LocationService.ACTION_FOUND_UPDATED))
|
||||
},
|
||||
onClose = { showNearby = false }
|
||||
)
|
||||
}
|
||||
@@ -836,7 +797,7 @@ private fun KlottrAppShell(
|
||||
isKnownNote = { noteId ->
|
||||
// Känd = finns i Hittat (FoundStore) → ska alltid visa titel
|
||||
FoundStore
|
||||
.getAll(context)
|
||||
.getAll()
|
||||
.any { it.layer == LAYER_KLOTTER && it.id == noteId.toString() }
|
||||
}
|
||||
)
|
||||
@@ -872,7 +833,7 @@ private fun KlottrAppShell(
|
||||
onFornsokRadiusChanged = { SettingsStore.setFornsokRadiusMeters(it); fornsokRadius = it },
|
||||
|
||||
onClearFinds = {
|
||||
FoundStore.clearAll(context) // Töm allt
|
||||
FoundStore.clearAll() // Töm allt
|
||||
forceEmptyFound = true // Visa tomt direkt
|
||||
refreshFound() // Tvinga omritning
|
||||
|
||||
@@ -912,10 +873,10 @@ private fun KlottrAppShell(
|
||||
fetchDm = { la, lo, r -> DigitaltMuseum.getNearby(la, lo, radiusMeters = r) },
|
||||
fetchFornsok = { la, lo, r -> Fornsok.getNearby(la, lo, radiusMeters = r) },
|
||||
markFound = { layer, id, label, la, lo, now ->
|
||||
FoundStore.markFound(context, layer, id, label, la, lo, now)
|
||||
FoundStore.markFound(layer, id, label, la, lo, now)
|
||||
},
|
||||
updateAwayFlags = { la, lo ->
|
||||
FoundStore.updateAwayFlags(context, la, lo)
|
||||
FoundStore.updateAwayFlags(la, lo)
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -1048,7 +1009,6 @@ private fun KlottrAppShell(
|
||||
if (match != null) {
|
||||
val labelTitle = titleText.ifBlank { match.t ?: "Klotter" } // Spara endast rubriken i “Senaste”
|
||||
FoundStore.markFound(
|
||||
context,
|
||||
LAYER_KLOTTER,
|
||||
match.i.toString(),
|
||||
label = labelTitle,
|
||||
@@ -1254,7 +1214,6 @@ private fun KlottrAppShell(
|
||||
// --- Välj användarnamn (blockerande) ---
|
||||
if (showUsernameDialog && loggedIn) {
|
||||
UsernameDialog(
|
||||
onCancel = { /* blockera: ingen back/avbryt */ },
|
||||
onSaved = { chosen ->
|
||||
showUsernameDialog = false
|
||||
scope.launch {
|
||||
@@ -1283,7 +1242,6 @@ private fun NearbyDialog(
|
||||
dm: List<DigitaltMuseumItem>,
|
||||
forn: List<FornsokItem>,
|
||||
onOpenAction: (FoundOpenAction) -> Unit, // Enhetlig callback
|
||||
onMarkedFound: () -> Unit,
|
||||
onClose: () -> Unit
|
||||
) {
|
||||
val ctx = LocalContext.current
|
||||
@@ -1489,7 +1447,6 @@ private fun WriteDocDialog(
|
||||
|
||||
@Composable
|
||||
private fun UsernameDialog(
|
||||
onCancel: () -> Unit,
|
||||
onSaved: (String) -> Unit,
|
||||
onLogout: () -> Unit
|
||||
) {
|
||||
@@ -1816,10 +1773,10 @@ private fun KlotterDialog(
|
||||
var deleting by remember { mutableStateOf(false) }
|
||||
|
||||
val firstVisitMs = remember(id) {
|
||||
FoundStore.getFirstVisitMillis(context, FoundStore.LAYER_KLOTTER, id)
|
||||
FoundStore.getFirstVisitMillis(FoundStore.LAYER_KLOTTER, id)
|
||||
}
|
||||
val lastVisitMs = remember(id) {
|
||||
FoundStore.getLastVisitMillis(context, FoundStore.LAYER_KLOTTER, id)
|
||||
FoundStore.getLastVisitMillis(FoundStore.LAYER_KLOTTER, id)
|
||||
}
|
||||
|
||||
var loading by remember { mutableStateOf(true) }
|
||||
@@ -1838,7 +1795,7 @@ private fun KlotterDialog(
|
||||
|
||||
// Har den här notisen någonsin besökts (oavsett var vi står nu)?
|
||||
val wasFoundBefore = remember(id) {
|
||||
FoundStore.getFirstVisitMillis(context, FoundStore.LAYER_KLOTTER, id) != null
|
||||
FoundStore.getFirstVisitMillis(FoundStore.LAYER_KLOTTER, id) != null
|
||||
}
|
||||
|
||||
var imgBitmap by remember { mutableStateOf<Bitmap?>(null) }
|
||||
@@ -2104,7 +2061,7 @@ private fun KlotterDialog(
|
||||
// 0) Ta bort ev. detaljer ur cachen (om remove finns – annars hoppar try{} över)
|
||||
try { NoteDetailCache.remove(idL) } catch (_: Throwable) {}
|
||||
|
||||
FoundStore.remove(context, LAYER_KLOTTER, id) // id är din String i KlotterDialog
|
||||
FoundStore.remove(LAYER_KLOTTER, id) // id är din String i KlotterDialog
|
||||
|
||||
// Pinga UI:t (din DisposableEffect lyssnar på ACTION_FOUND_UPDATED och kör refreshFound())
|
||||
context.sendBroadcast(Intent(LocationService.ACTION_FOUND_UPDATED))
|
||||
|
||||
@@ -68,7 +68,7 @@ class OutboxWorker(
|
||||
val imgId: Long? = if (p.imagePath != null && p.imageMime != null) {
|
||||
val f = File(p.imagePath)
|
||||
if (f.exists()) {
|
||||
uploadImageFromFile(applicationContext, f, p.imageMime, p.lat, p.lon)
|
||||
uploadImageFromFile(f, p.imageMime, p.lat, p.lon)
|
||||
} else null
|
||||
} else null
|
||||
|
||||
@@ -119,7 +119,6 @@ class OutboxWorker(
|
||||
|
||||
// Markera som hittad i FoundStore
|
||||
FoundStore.markFound(
|
||||
ctx,
|
||||
FoundStore.LAYER_KLOTTER,
|
||||
match.i.toString(),
|
||||
label = label,
|
||||
|
||||
@@ -3,7 +3,6 @@ package app.klottr.net
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import app.klottr.BuildConfig
|
||||
import app.klottr.net.KlottrApiShared
|
||||
import app.klottr.util.Auth
|
||||
import app.klottr.util.KLog
|
||||
import java.io.File
|
||||
@@ -133,7 +132,6 @@ suspend fun uploadImageFromUri(
|
||||
* Samma som ovan men startar från File i stället för Uri.
|
||||
*/
|
||||
suspend fun uploadImageFromFile(
|
||||
context: Context,
|
||||
file: File,
|
||||
mimeHint: String?,
|
||||
lat: Double,
|
||||
|
||||
@@ -53,6 +53,6 @@ object Notifications {
|
||||
}
|
||||
|
||||
// Enkel in‑app “toast”
|
||||
fun showInAppNotification(msg: String) {
|
||||
fun showInAppNotification() {
|
||||
// Lämnad minimal; i en riktig app kan du använda SnackbarHostState.
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user