diff options
author | Guillaume Jacquart <guillaume.jacquart-ext@mousquetaires.com> | 2022-10-07 08:45:15 +0200 |
---|---|---|
committer | Guillaume Jacquart <guillaume.jacquart-ext@mousquetaires.com> | 2022-10-26 14:01:43 +0200 |
commit | 5f02fd142ca438a48423340aeb9a36b017a6be83 (patch) | |
tree | 793326be63e878c880298f075f9c0de3413bb6e4 /fakelocation/fakelocationdemo/src | |
parent | f8d19823ea9be0c8700a69a215fac7d3af4d6d87 (diff) |
Fix lint.
Diffstat (limited to 'fakelocation/fakelocationdemo/src')
-rw-r--r-- | fakelocation/fakelocationdemo/src/main/java/foundation/e/privacymodules/fakelocationdemo/MainActivity.kt | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/fakelocation/fakelocationdemo/src/main/java/foundation/e/privacymodules/fakelocationdemo/MainActivity.kt b/fakelocation/fakelocationdemo/src/main/java/foundation/e/privacymodules/fakelocationdemo/MainActivity.kt index 1b0a35b..42cf658 100644 --- a/fakelocation/fakelocationdemo/src/main/java/foundation/e/privacymodules/fakelocationdemo/MainActivity.kt +++ b/fakelocation/fakelocationdemo/src/main/java/foundation/e/privacymodules/fakelocationdemo/MainActivity.kt @@ -58,7 +58,6 @@ class MainActivity : AppCompatActivity() { ) } - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) binding = DataBindingUtil.setContentView(this, R.layout.activity_main) @@ -79,7 +78,7 @@ class MainActivity : AppCompatActivity() { binding.mockedLocation = mockedLocation } - private val listener = object: LocationListener { + private val listener = object : LocationListener { override fun onLocationChanged(location: Location) { binding.currentLocation = "lat: ${location.latitude} - lon: ${location.longitude}" } @@ -130,16 +129,19 @@ class MainActivity : AppCompatActivity() { private val locationPermissionRequest = registerForActivityResult( ActivityResultContracts.RequestMultiplePermissions() ) { permissions -> - if (permissions.getOrDefault(Manifest.permission.ACCESS_FINE_LOCATION, false) - || permissions.getOrDefault(Manifest.permission.ACCESS_COARSE_LOCATION, false) + if (permissions.getOrDefault(Manifest.permission.ACCESS_FINE_LOCATION, false) || + permissions.getOrDefault(Manifest.permission.ACCESS_COARSE_LOCATION, false) ) { startLocationUpdates() } } private fun requireLocationPermissions() { - if (ContextCompat.checkSelfPermission(this, - Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) { + if (ContextCompat.checkSelfPermission( + this, + Manifest.permission.ACCESS_COARSE_LOCATION + ) == PackageManager.PERMISSION_GRANTED + ) { startLocationUpdates() } else { // Before you perform the actual permission request, check whether your app @@ -152,19 +154,20 @@ class MainActivity : AppCompatActivity() { ) ) } - } @Suppress("UNUSED_PARAMETER") fun onClickPermission(view: View?) { - val isGranted = permissionsModule.setAppOpMode(appDesc, AppOpsManager.OPSTR_MOCK_LOCATION, - AppOpModes.ALLOWED) + val isGranted = permissionsModule.setAppOpMode( + appDesc, AppOpsManager.OPSTR_MOCK_LOCATION, + AppOpModes.ALLOWED + ) if (isGranted) { updateData("") return } - //dev mode disabled + // dev mode disabled val alertDialog = AlertDialog.Builder(this) alertDialog .setTitle("Mock location disabled") @@ -177,7 +180,7 @@ class MainActivity : AppCompatActivity() { fun onClickReset(view: View?) { try { fakeLocationModule.stopFakeLocation() - } catch(e: Exception) { + } catch (e: Exception) { Log.e(TAG, "Can't stop FakeLocation", e) } } @@ -185,11 +188,11 @@ class MainActivity : AppCompatActivity() { private fun setFakeLocation(latitude: Double, longitude: Double) { try { fakeLocationModule.startFakeLocation() - } catch(e: Exception) { + } catch (e: Exception) { Log.e(TAG, "Can't startFakeLocation", e) } fakeLocationModule.setFakeLocation(latitude, longitude) - updateData("lat: ${latitude} - lon: ${longitude}") + updateData("lat: $latitude - lon: $longitude") } @Suppress("UNUSED_PARAMETER") |