diff --git a/app/src/main/java/no/naiv/tilfluktsrom/MainActivity.kt b/app/src/main/java/no/naiv/tilfluktsrom/MainActivity.kt index a91e249..af96248 100644 --- a/app/src/main/java/no/naiv/tilfluktsrom/MainActivity.kt +++ b/app/src/main/java/no/naiv/tilfluktsrom/MainActivity.kt @@ -3,6 +3,7 @@ package no.naiv.tilfluktsrom import android.Manifest import android.content.Context import android.content.Intent +import android.view.HapticFeedbackConstants import android.content.pm.PackageManager import android.hardware.Sensor import android.hardware.SensorEvent @@ -202,6 +203,7 @@ class MainActivity : AppCompatActivity(), SensorEventListener { private fun setupButtons() { binding.toggleViewFab.setOnClickListener { + it.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY) isCompassMode = !isCompassMode if (isCompassMode) { binding.mapView.visibility = View.GONE @@ -216,24 +218,29 @@ class MainActivity : AppCompatActivity(), SensorEventListener { // Reset to navigation: re-fit map to show user + selected shelter binding.resetNavigationFab.setOnClickListener { + it.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY) userHasInteractedWithMap = false binding.resetNavigationFab.visibility = View.GONE selectedShelter?.let { highlightShelterOnMap(it) } } binding.infoButton.setOnClickListener { + it.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY) CivilDefenseInfoDialog().show(supportFragmentManager, CivilDefenseInfoDialog.TAG) } binding.refreshButton.setOnClickListener { + it.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY) forceRefresh() } binding.shareButton.setOnClickListener { + it.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY) shareShelter() } binding.cacheRetryButton.setOnClickListener { + it.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY) val loc = currentLocation if (loc == null) { Toast.makeText(this, R.string.status_no_location, Toast.LENGTH_SHORT).show() diff --git a/app/src/main/java/no/naiv/tilfluktsrom/ui/ShelterListAdapter.kt b/app/src/main/java/no/naiv/tilfluktsrom/ui/ShelterListAdapter.kt index 41e09ca..f4a7307 100644 --- a/app/src/main/java/no/naiv/tilfluktsrom/ui/ShelterListAdapter.kt +++ b/app/src/main/java/no/naiv/tilfluktsrom/ui/ShelterListAdapter.kt @@ -1,5 +1,6 @@ package no.naiv.tilfluktsrom.ui +import android.view.HapticFeedbackConstants import android.view.LayoutInflater import android.view.ViewGroup import androidx.recyclerview.widget.DiffUtil @@ -63,6 +64,7 @@ class ShelterListAdapter( binding.root.alpha = if (isSelected) 1.0f else 0.7f binding.root.setOnClickListener { + it.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY) val pos = adapterPosition if (pos != RecyclerView.NO_POSITION) { selectPosition(pos) diff --git a/pwa/src/app.ts b/pwa/src/app.ts index 9f601c3..4bfd68c 100644 --- a/pwa/src/app.ts +++ b/pwa/src/app.ts @@ -76,6 +76,7 @@ function setupButtons(): void { // Toggle map/compass const toggleFab = document.getElementById('toggle-fab')!; toggleFab.addEventListener('click', async () => { + navigator.vibrate?.(10); isCompassMode = !isCompassMode; const mapContainer = document.getElementById('map-container')!; @@ -112,6 +113,7 @@ function setupButtons(): void { const cacheRetryBtn = document.getElementById('cache-retry-btn')!; cacheRetryBtn.textContent = t('action_cache_now'); cacheRetryBtn.addEventListener('click', () => { + navigator.vibrate?.(10); if (currentLocation && navigator.onLine) { startCaching(currentLocation.latitude, currentLocation.longitude); } @@ -120,6 +122,7 @@ function setupButtons(): void { // Reset view button const resetBtn = document.getElementById('reset-view-btn')!; resetBtn.addEventListener('click', () => { + navigator.vibrate?.(10); const selected = nearestShelters[selectedShelterIndex] ?? null; mapView.resetView(selected, currentLocation); resetBtn.classList.remove('visible'); diff --git a/pwa/src/ui/shelter-list.ts b/pwa/src/ui/shelter-list.ts index b90755a..c0d6f8d 100644 --- a/pwa/src/ui/shelter-list.ts +++ b/pwa/src/ui/shelter-list.ts @@ -52,6 +52,7 @@ export function updateList( item.appendChild(addressSpan); item.appendChild(detailsSpan); item.addEventListener('click', () => { + navigator.vibrate?.(10); onSelect?.(i); }); container!.appendChild(item); diff --git a/pwa/src/ui/status-bar.ts b/pwa/src/ui/status-bar.ts index 84dd857..d4ab54b 100644 --- a/pwa/src/ui/status-bar.ts +++ b/pwa/src/ui/status-bar.ts @@ -11,5 +11,8 @@ export function setStatus(text: string): void { /** Set the refresh button click handler. */ export function onRefreshClick(handler: () => void): void { const btn = document.getElementById('refresh-btn'); - if (btn) btn.addEventListener('click', handler); + if (btn) btn.addEventListener('click', () => { + navigator.vibrate?.(10); + handler(); + }); }