Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Fixed
- Fixed app crash when location service is disabled on Android 10 and prior ([#177])

## [1.3.0] - 2025-09-17
### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.Manifest
import android.location.Location
import android.location.LocationListener
import android.location.LocationManager
import android.os.Bundle
import androidx.annotation.RequiresPermission
import org.fossify.camera.extensions.checkLocationPermission
import org.fossify.commons.activities.BaseSimpleActivity
Expand All @@ -15,12 +16,23 @@ class SimpleLocationManager(private val activity: BaseSimpleActivity) {
private const val LOCATION_UPDATE_MIN_DISTANCE_M = 10F
}

private var location: Location? = null

private val locationManager = activity.getSystemService(LocationManager::class.java)!!
private val locationListener = LocationListener { location ->
[email protected] = location
}

private var location: Location? = null
@Suppress("EmptyFunctionBlock")
private val locationListener = object: LocationListener {
override fun onLocationChanged(location: Location) {
[email protected] = location
}

// No-op methods that must be overridden.
// See https://github.com/FossifyOrg/Camera/issues/177
@Suppress("DEPRECATION")
override fun onStatusChanged(provider: String?, status: Int, extras: Bundle?) {}
override fun onProviderEnabled(provider: String) {}
override fun onProviderDisabled(provider: String) {}
}

fun getLocation(): Location? {
if (location == null) {
Expand Down
Loading