-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: port iOS location architecture to Android (#568)
* refactor: port iOS location architecture to Android * fix collectAsState with mapped flow * grant location permission and provide locals * wait until done loading * split object declarations into separate classes * resolve a TODO
- Loading branch information
1 parent
301e33b
commit 8f0ba13
Showing
20 changed files
with
744 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
126 changes: 126 additions & 0 deletions
126
...ndroidTest/java/com/mbta/tid/mbta_app/android/location/MockFusedLocationProviderClient.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
package com.mbta.tid.mbta_app.android.location | ||
|
||
import android.app.PendingIntent | ||
import android.location.Location | ||
import android.os.Looper | ||
import com.google.android.gms.common.api.Api | ||
import com.google.android.gms.common.api.internal.ApiKey | ||
import com.google.android.gms.location.CurrentLocationRequest | ||
import com.google.android.gms.location.DeviceOrientationListener | ||
import com.google.android.gms.location.DeviceOrientationRequest | ||
import com.google.android.gms.location.FusedLocationProviderClient | ||
import com.google.android.gms.location.LastLocationRequest | ||
import com.google.android.gms.location.LocationAvailability | ||
import com.google.android.gms.location.LocationCallback | ||
import com.google.android.gms.location.LocationListener | ||
import com.google.android.gms.location.LocationRequest | ||
import com.google.android.gms.tasks.CancellationToken | ||
import com.google.android.gms.tasks.Task | ||
import com.google.android.gms.tasks.Tasks | ||
import java.util.concurrent.Executor | ||
|
||
class MockFusedLocationProviderClient : FusedLocationProviderClient { | ||
override fun getApiKey(): ApiKey<Api.ApiOptions.NoOptions> { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun getLastLocation(): Task<Location> = Tasks.forCanceled() | ||
|
||
override fun getLastLocation(p0: LastLocationRequest): Task<Location> { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun getCurrentLocation(p0: Int, p1: CancellationToken?): Task<Location> { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun getCurrentLocation( | ||
p0: CurrentLocationRequest, | ||
p1: CancellationToken? | ||
): Task<Location> { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun getLocationAvailability(): Task<LocationAvailability> { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun requestLocationUpdates( | ||
p0: LocationRequest, | ||
p1: Executor, | ||
p2: LocationListener | ||
): Task<Void> { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun requestLocationUpdates( | ||
p0: LocationRequest, | ||
p1: LocationListener, | ||
p2: Looper? | ||
): Task<Void> = Tasks.forCanceled() | ||
|
||
override fun requestLocationUpdates( | ||
p0: LocationRequest, | ||
p1: LocationCallback, | ||
p2: Looper? | ||
): Task<Void> { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun requestLocationUpdates( | ||
p0: LocationRequest, | ||
p1: Executor, | ||
p2: LocationCallback | ||
): Task<Void> { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun requestLocationUpdates(p0: LocationRequest, p1: PendingIntent): Task<Void> { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun removeLocationUpdates(p0: LocationListener): Task<Void> = Tasks.forCanceled() | ||
|
||
override fun removeLocationUpdates(p0: LocationCallback): Task<Void> { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun removeLocationUpdates(p0: PendingIntent): Task<Void> { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun flushLocations(): Task<Void> { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun setMockMode(p0: Boolean): Task<Void> { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun setMockLocation(p0: Location): Task<Void> { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
@Deprecated("Deprecated in Java") | ||
override fun requestDeviceOrientationUpdates( | ||
p0: DeviceOrientationRequest, | ||
p1: Executor, | ||
p2: DeviceOrientationListener | ||
): Task<Void> { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
@Deprecated("Deprecated in Java") | ||
override fun requestDeviceOrientationUpdates( | ||
p0: DeviceOrientationRequest, | ||
p1: DeviceOrientationListener, | ||
p2: Looper? | ||
): Task<Void> { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
@Deprecated("Deprecated in Java") | ||
override fun removeDeviceOrientationUpdates(p0: DeviceOrientationListener): Task<Void> { | ||
TODO("Not yet implemented") | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...pp/src/androidTest/java/com/mbta/tid/mbta_app/android/location/MockLocationDataManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.mbta.tid.mbta_app.android.location | ||
|
||
import android.location.Location | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
|
||
class MockLocationDataManager(location: Location) : LocationDataManager() { | ||
override val currentLocation = MutableStateFlow(location) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.