Skip to content

Commit 5ba5d9d

Browse files
jennantillajinliu9508
authored andcommitted
update location module property naming
address linting error that enforces camel case
1 parent 8f47931 commit 5ba5d9d

File tree

3 files changed

+62
-62
lines changed

3 files changed

+62
-62
lines changed

OneSignalSDK/onesignal/location/src/main/java/com/onesignal/location/internal/controller/impl/GmsLocationController.kt

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,26 @@ import java.io.Closeable
3030
internal class GmsLocationController(
3131
private val _applicationService: IApplicationService,
3232
) : ILocationController {
33-
private val _locationHandlerThread = LocationHandlerThread()
34-
private val _startStopMutex = Mutex()
35-
private val _event = EventProducer<ILocationUpdatedHandler>()
33+
private val locationHandlerThread = LocationHandlerThread()
34+
private val startStopMutex = Mutex()
35+
private val event = EventProducer<ILocationUpdatedHandler>()
3636

3737
// exist after start and before stop. updates are protected by the startStopMutex
38-
private var _googleApiClient: GoogleApiClientCompatProxy? = null
39-
private var _locationUpdateListener: LocationUpdateListener? = null
38+
private var googleApiClient: GoogleApiClientCompatProxy? = null
39+
private var locationUpdateListener: LocationUpdateListener? = null
4040

4141
// contains the last location received from location services
42-
private var _lastLocation: Location? = null
42+
private var lastLocation: Location? = null
4343

4444
override suspend fun start(): Boolean {
4545
var self = this
4646
var wasSuccessful = false
4747

4848
withContext(Dispatchers.IO) {
49-
_startStopMutex.withLock {
50-
if (_googleApiClient != null) {
51-
if (_lastLocation != null) {
52-
_event.fire { it.onLocationChanged(_lastLocation!!) }
49+
startStopMutex.withLock {
50+
if (googleApiClient != null) {
51+
if (lastLocation != null) {
52+
event.fire { it.onLocationChanged(lastLocation!!) }
5353
} else {
5454
val localLastLocation = getLastLocation()
5555
if (localLastLocation != null) {
@@ -66,24 +66,24 @@ internal class GmsLocationController(
6666
.addApi(LocationServices.API)
6767
.addConnectionCallbacks(googleApiClientListener)
6868
.addOnConnectionFailedListener(googleApiClientListener)
69-
.setHandler(_locationHandlerThread.mHandler)
69+
.setHandler(locationHandlerThread.mHandler)
7070
.build()
7171
var proxyGoogleApiClient = GoogleApiClientCompatProxy(googleApiClient)
7272

7373
// TODO: google api client has a blocking connect with timeout, use that instead of our withTimeout?
7474
var result = proxyGoogleApiClient.blockingConnect()
7575

7676
if (result?.isSuccess == true) {
77-
if (_lastLocation == null) {
77+
if (lastLocation == null) {
7878
var lastLocation = FusedLocationApiWrapper.getLastLocation(googleApiClient)
7979
if (lastLocation != null) {
8080
setLocationAndFire(lastLocation)
8181
}
8282
}
8383

8484
// only after the connect do we save
85-
self._locationUpdateListener = LocationUpdateListener(_applicationService, self, proxyGoogleApiClient.realInstance)
86-
self._googleApiClient = proxyGoogleApiClient
85+
self.locationUpdateListener = LocationUpdateListener(_applicationService, self, proxyGoogleApiClient.realInstance)
86+
self.googleApiClient = proxyGoogleApiClient
8787
wasSuccessful = true
8888
} else {
8989
Logging.debug(
@@ -104,39 +104,39 @@ internal class GmsLocationController(
104104
}
105105

106106
override suspend fun stop() {
107-
_startStopMutex.withLock {
108-
if (_locationUpdateListener != null) {
109-
_locationUpdateListener!!.close()
110-
_locationUpdateListener = null
107+
startStopMutex.withLock {
108+
if (locationUpdateListener != null) {
109+
locationUpdateListener!!.close()
110+
locationUpdateListener = null
111111
}
112112

113-
if (_googleApiClient != null) {
114-
_googleApiClient!!.disconnect()
115-
_googleApiClient = null
113+
if (googleApiClient != null) {
114+
googleApiClient!!.disconnect()
115+
googleApiClient = null
116116
}
117117

118-
_lastLocation = null
118+
lastLocation = null
119119
}
120120
}
121121

122122
override fun getLastLocation(): Location? {
123-
val apiInstance = _googleApiClient?.realInstance ?: return null
123+
val apiInstance = googleApiClient?.realInstance ?: return null
124124
return FusedLocationApiWrapper.getLastLocation(apiInstance)
125125
}
126126

127-
override fun subscribe(handler: ILocationUpdatedHandler) = _event.subscribe(handler)
127+
override fun subscribe(handler: ILocationUpdatedHandler) = event.subscribe(handler)
128128

129-
override fun unsubscribe(handler: ILocationUpdatedHandler) = _event.unsubscribe(handler)
129+
override fun unsubscribe(handler: ILocationUpdatedHandler) = event.unsubscribe(handler)
130130

131131
override val hasSubscribers: Boolean
132-
get() = _event.hasSubscribers
132+
get() = event.hasSubscribers
133133

134134
private fun setLocationAndFire(location: Location) {
135-
Logging.debug("GMSLocationController lastLocation: $_lastLocation")
135+
Logging.debug("GMSLocationController lastLocation: $lastLocation")
136136

137-
_lastLocation = location
137+
lastLocation = location
138138

139-
_event.fire { it.onLocationChanged(location) }
139+
event.fire { it.onLocationChanged(location) }
140140
}
141141

142142
private class GoogleApiClientListener(private val _parent: GmsLocationController) : GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {

OneSignalSDK/onesignal/location/src/main/java/com/onesignal/location/internal/controller/impl/HmsLocationController.kt

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,23 @@ import java.io.Closeable
2828
internal class HmsLocationController(
2929
private val _applicationService: IApplicationService,
3030
) : ILocationController {
31-
private val _locationHandlerThread = LocationHandlerThread()
32-
private val _startStopMutex = Mutex()
33-
private val _event = EventProducer<ILocationUpdatedHandler>()
31+
private val locationHandlerThread = LocationHandlerThread()
32+
private val startStopMutex = Mutex()
33+
private val event = EventProducer<ILocationUpdatedHandler>()
3434

3535
// exist after start and before stop. updates are protected by the startStopMutex
3636
private var hmsFusedLocationClient: FusedLocationProviderClient? = null
3737
private var locationUpdateListener: LocationUpdateListener? = null
3838

3939
// contains the last location received from location services
40-
private var _lastLocation: Location? = null
40+
private var lastLocation: Location? = null
4141

4242
override suspend fun start(): Boolean {
4343
var self = this
4444
var wasSuccessful = false
4545

4646
withContext(Dispatchers.IO) {
47-
_startStopMutex.withLock {
47+
startStopMutex.withLock {
4848
if (hmsFusedLocationClient == null) {
4949
try {
5050
hmsFusedLocationClient =
@@ -56,8 +56,8 @@ internal class HmsLocationController(
5656
}
5757
}
5858

59-
if (_lastLocation != null) {
60-
_event.fire { it.onLocationChanged(_lastLocation!!) }
59+
if (lastLocation != null) {
60+
event.fire { it.onLocationChanged(lastLocation!!) }
6161
} else {
6262
var waiter = WaiterWithValue<Boolean>()
6363
hmsFusedLocationClient!!.lastLocation
@@ -70,7 +70,7 @@ internal class HmsLocationController(
7070
return@OnSuccessListener
7171
}
7272

73-
_lastLocation = location
73+
lastLocation = location
7474
waiter.wake(true)
7575
},
7676
)
@@ -81,7 +81,7 @@ internal class HmsLocationController(
8181
wasSuccessful = waiter.waitForWake()
8282

8383
if (wasSuccessful) {
84-
_event.fire { it.onLocationChanged(_lastLocation!!) }
84+
event.fire { it.onLocationChanged(lastLocation!!) }
8585
locationUpdateListener =
8686
LocationUpdateListener(
8787
self,
@@ -97,7 +97,7 @@ internal class HmsLocationController(
9797
}
9898

9999
override suspend fun stop() {
100-
_startStopMutex.withLock {
100+
startStopMutex.withLock {
101101
if (locationUpdateListener != null) {
102102
locationUpdateListener!!.close()
103103
locationUpdateListener = null
@@ -107,7 +107,7 @@ internal class HmsLocationController(
107107
hmsFusedLocationClient = null
108108
}
109109

110-
_lastLocation = null
110+
lastLocation = null
111111
}
112112
}
113113

@@ -142,12 +142,12 @@ internal class HmsLocationController(
142142
return retVal
143143
}
144144

145-
override fun subscribe(handler: ILocationUpdatedHandler) = _event.subscribe(handler)
145+
override fun subscribe(handler: ILocationUpdatedHandler) = event.subscribe(handler)
146146

147-
override fun unsubscribe(handler: ILocationUpdatedHandler) = _event.unsubscribe(handler)
147+
override fun unsubscribe(handler: ILocationUpdatedHandler) = event.unsubscribe(handler)
148148

149149
override val hasSubscribers: Boolean
150-
get() = _event.hasSubscribers
150+
get() = event.hasSubscribers
151151

152152
internal class LocationUpdateListener(
153153
private val _parent: HmsLocationController,
@@ -181,7 +181,7 @@ internal class HmsLocationController(
181181

182182
override fun onLocationResult(locationResult: LocationResult) {
183183
Logging.debug("HMSLocationController onLocationResult: $locationResult")
184-
_parent._lastLocation = locationResult.lastLocation
184+
_parent.lastLocation = locationResult.lastLocation
185185
}
186186

187187
private fun refreshRequest() {
@@ -204,7 +204,7 @@ internal class HmsLocationController(
204204
huaweiFusedLocationProviderClient.requestLocationUpdates(
205205
locationRequest,
206206
this,
207-
_parent._locationHandlerThread.looper,
207+
_parent.locationHandlerThread.looper,
208208
)
209209
hasExistingRequest = true
210210
}

OneSignalSDK/onesignal/location/src/main/java/com/onesignal/location/internal/permissions/LocationPermissionController.kt

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ internal class LocationPermissionController(
5252
private const val PERMISSION_TYPE = "LOCATION"
5353
}
5454

55-
private val _waiter = WaiterWithValue<Boolean>()
56-
private val _events = EventProducer<ILocationPermissionChangedHandler>()
57-
private var _currPermission: String = ""
55+
private val waiter = WaiterWithValue<Boolean>()
56+
private val events = EventProducer<ILocationPermissionChangedHandler>()
57+
private var currPermission: String = ""
5858

5959
override fun start() {
6060
_requestPermission.registerAsCallback(PERMISSION_TYPE, this)
@@ -64,7 +64,7 @@ internal class LocationPermissionController(
6464
fallbackToSettings: Boolean,
6565
androidPermissionString: String,
6666
): Boolean {
67-
_currPermission = androidPermissionString
67+
currPermission = androidPermissionString
6868
_requestPermission.startPrompt(
6969
fallbackToSettings,
7070
PERMISSION_TYPE,
@@ -74,12 +74,12 @@ internal class LocationPermissionController(
7474

7575
// this won't return until onAccept or onReject sends the response on the channel (either
7676
// through the native prompt or through the fallback)
77-
return _waiter.waitForWake()
77+
return waiter.waitForWake()
7878
}
7979

8080
override fun onAccept() {
81-
_waiter.wake(true)
82-
_events.fire { it.onLocationPermissionChanged(true) }
81+
waiter.wake(true)
82+
events.fire { it.onLocationPermissionChanged(true) }
8383
}
8484

8585
override fun onReject(fallbackToSettings: Boolean) {
@@ -91,8 +91,8 @@ internal class LocationPermissionController(
9191
}
9292

9393
if (!fallbackShown) {
94-
_waiter.wake(false)
95-
_events.fire { it.onLocationPermissionChanged(false) }
94+
waiter.wake(false)
95+
events.fire { it.onLocationPermissionChanged(false) }
9696
}
9797
}
9898

@@ -110,28 +110,28 @@ internal class LocationPermissionController(
110110
override fun onFocus() {
111111
super.onFocus()
112112
_applicationService.removeApplicationLifecycleHandler(this)
113-
val hasPermission = AndroidUtils.hasPermission(_currPermission, true, _applicationService)
114-
_waiter.wake(hasPermission)
115-
_events.fire { it.onLocationPermissionChanged(hasPermission) }
113+
val hasPermission = AndroidUtils.hasPermission(currPermission, true, _applicationService)
114+
waiter.wake(hasPermission)
115+
events.fire { it.onLocationPermissionChanged(hasPermission) }
116116
}
117117
},
118118
)
119119
NavigateToAndroidSettingsForLocation.show(activity)
120120
}
121121

122122
override fun onDecline() {
123-
_waiter.wake(false)
124-
_events.fire { it.onLocationPermissionChanged(false) }
123+
waiter.wake(false)
124+
events.fire { it.onLocationPermissionChanged(false) }
125125
}
126126
},
127127
)
128128
return true
129129
}
130130

131-
override fun subscribe(handler: ILocationPermissionChangedHandler) = _events.subscribe(handler)
131+
override fun subscribe(handler: ILocationPermissionChangedHandler) = events.subscribe(handler)
132132

133-
override fun unsubscribe(handler: ILocationPermissionChangedHandler) = _events.subscribe(handler)
133+
override fun unsubscribe(handler: ILocationPermissionChangedHandler) = events.subscribe(handler)
134134

135135
override val hasSubscribers: Boolean
136-
get() = _events.hasSubscribers
136+
get() = events.hasSubscribers
137137
}

0 commit comments

Comments
 (0)