Skip to content

Commit 8c4fd2f

Browse files
authored
Merge pull request #29 from KieronQuinn/release/1.0.3
1.0.3
2 parents 3a20ab9 + 135453d commit 8c4fd2f

File tree

10 files changed

+57
-22
lines changed

10 files changed

+57
-22
lines changed

app/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ fun getKeystoreProperties(): Properties? {
3232
return properties
3333
}
3434

35-
val tagName = "1.0.2"
36-
val tagCode = 102
35+
val tagName = "1.0.3"
36+
val tagCode = 103
3737

3838
android {
3939
namespace = "com.kieronquinn.app.utag"

app/src/main/java/com/kieronquinn/app/utag/components/bluetooth/BaseTagConnection.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,13 @@ abstract class BaseTagConnection(
132132
}
133133

134134
suspend fun syncLocationAndWait(onDemand: Boolean): SyncResult {
135+
var hasResumed = false
135136
return suspendCoroutine { resume ->
136137
syncLocation(onDemand) {
137-
resume.resume(it)
138+
if(!hasResumed) {
139+
hasResumed = true
140+
resume.resume(it)
141+
}
138142
}
139143
}
140144
}

app/src/main/java/com/kieronquinn/app/utag/repositories/CacheRepository.kt

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,19 @@ class CacheRepositoryImpl(
105105
}
106106

107107
private suspend fun CacheItemTable.getItem(type: CacheType, subType: String?): CacheItem? {
108-
return withContext(Dispatchers.IO) {
109-
get().firstOrNull {
110-
it.type.toEnumOrNull<CacheType>() == type &&
111-
(subType == null || it.subType?.let { type -> String(type.bytes) } == subType)
108+
return try {
109+
withContext(Dispatchers.IO) {
110+
get().firstOrNull {
111+
it.type.toEnumOrNull<CacheType>() == type &&
112+
(subType == null || it.subType?.let { type -> String(type.bytes) } == subType)
113+
}
114+
}
115+
}catch (e: IllegalStateException) {
116+
//Cache has become corrupt, clear and start again
117+
withContext(Dispatchers.IO) {
118+
table.clear()
112119
}
120+
null
113121
}
114122
}
115123

app/src/main/java/com/kieronquinn/app/utag/repositories/GeocoderRepository.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,13 @@ class GeocoderRepositoryImpl(
6464
private suspend fun getCachedAddressOrNull(location: LatLng): String? = databaseLock.withLock {
6565
withContext(Dispatchers.IO) {
6666
val hash = location.hashCode()
67-
geocodedAddressTable.getAddress(hash)?.address?.bytes?.let {
68-
String(it, Charsets.UTF_8)
67+
try {
68+
geocodedAddressTable.getAddress(hash)?.address?.bytes?.let {
69+
String(it, Charsets.UTF_8)
70+
}
71+
}catch (e: IllegalStateException) {
72+
//Address is somehow null in database, just return null
73+
null
6974
}
7075
}
7176
}

app/src/main/java/com/kieronquinn/app/utag/service/UTagForegroundService.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,12 @@ class UTagForegroundService: LifecycleService() {
155155

156156
fun startIfNeeded(context: Context): Boolean {
157157
if(context.isServiceRunning(UTagForegroundService::class.java)) return false
158-
context.startService(Intent(context, UTagForegroundService::class.java))
158+
try {
159+
context.startService(Intent(context, UTagForegroundService::class.java))
160+
}catch (e: SecurityException) {
161+
//Process is bad
162+
return false
163+
}
159164
return true
160165
}
161166

@@ -1549,7 +1554,10 @@ class UTagForegroundService: LifecycleService() {
15491554
private fun locateAndScheduleNext() = whenCreated {
15501555
scheduleLocationAlarm()
15511556
val results = ArrayList<SyncResult>()
1552-
tagConnections.values.iterator().forEach {
1557+
val tagConnectionIterator = synchronized(tagConnections) {
1558+
tagConnections.values.iterator()
1559+
}
1560+
tagConnectionIterator.forEach {
15531561
it.syncLocationAndWait(false).also { result ->
15541562
results.add(result)
15551563
log("Sync result for ${it.deviceId}: $result")

app/src/main/java/com/kieronquinn/app/utag/ui/screens/tag/more/nearby/TagMoreNearbyFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ class TagMoreNearbyFragment: BoundFragment<FragmentTagMoreNearbyBinding>(Fragmen
332332
}
333333

334334
private fun handleRssi(state: State.RSSI) = with(binding.nearbyRssi) {
335-
nearbyRssiProgress.setProgress(state.distance.progress)
335+
nearbyRssiProgress.setProgress(state.progress)
336336
nearbyRssiInstruction.setText(state.moveAroundText.label)
337337
nearbyRssiDistance.setText(state.distance.label)
338338
nearbyRssiRing.handleRing(state.ringState)

app/src/main/java/com/kieronquinn/app/utag/ui/screens/tag/more/nearby/TagMoreNearbyViewModel.kt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,14 @@ abstract class TagMoreNearbyViewModel: ViewModel() {
8787
data class Searching(val remainingSeconds: Long, val progress: Float): State()
8888
data class RSSI(
8989
val distance: Distance,
90+
val progress: Float,
9091
val moveAroundText: MoveAroundText,
9192
val ringState: RingState = RingState.NotRinging
9293
): State() {
93-
enum class Distance(@StringRes val label: Int, val progress: Float) {
94-
FAR(R.string.nearby_its_far_away, 0.333f),
95-
NOT_FAR(R.string.nearby_its_not_far_from_here, 0.666f),
96-
NEAR(R.string.nearby_its_near_you, 1f)
94+
enum class Distance(@StringRes val label: Int) {
95+
FAR(R.string.nearby_its_far_away),
96+
NOT_FAR(R.string.nearby_its_not_far_from_here),
97+
NEAR(R.string.nearby_its_near_you)
9798
}
9899
enum class MoveAroundText(@StringRes val label: Int) {
99100
MOVE_AROUND(R.string.nearby_move_around),
@@ -487,6 +488,7 @@ class TagMoreNearbyViewModelImpl(
487488
this > -80 -> Distance.NOT_FAR
488489
else -> Distance.FAR
489490
}
491+
val progress = toProgress()
490492
val moveAroundText = if(rssiPingCount > 10) {
491493
if(lastPingRssi > -50 && this > -50) {
492494
MoveAroundText.MOVE_AROUND
@@ -504,7 +506,11 @@ class TagMoreNearbyViewModelImpl(
504506
}else lastMoveAroundText
505507
rssiPingCount++
506508
lastMoveAroundText = moveAroundText
507-
return RSSI(distance, moveAroundText)
509+
return RSSI(distance, progress, moveAroundText)
510+
}
511+
512+
private fun Int.toProgress(): Float {
513+
return ((100 + this) / 70f).coerceAtLeast(0f).coerceAtMost(1f)
508514
}
509515

510516
override fun onResume() {

app/src/main/java/com/kieronquinn/app/utag/utils/extensions/Extensions+Retrofit.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ fun reportRetrofitError(
8282
url: String? = null,
8383
code: Int? = null
8484
) {
85+
//Ignore auth errors
86+
if(code in 400..403) return
87+
//Ignore errors from cancelled coroutines
88+
if(exception?.javaClass?.simpleName == "ChildCancelledException") return
8589
val inException = exception ?: Throwable("$url returned $code")
8690
val userVisibleError = exception?.toString() ?: if(url != null && code != null) {
8791
"$url returned $code:\n\n$error"

gradle/libs.versions.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[versions]
22
agp = "8.7.3"
33
kotlin = "2.1.0"
4-
navigation = "2.8.7"
4+
navigation = "2.8.8"
55
browser = "1.8.0"
66
lifecycle = "2.8.7"
77
crypto = "1.1.0-alpha06"
@@ -33,7 +33,7 @@ oneuiIcons = "1.1.0"
3333
oneuiAppPicker = "1.0.0"
3434
koin = "4.0.0-RC2"
3535
retrofit = "2.11.0"
36-
playServicesMaps = "19.0.0"
36+
playServicesMaps = "19.1.0"
3737
playServicesLocation = "21.3.0"
3838
playServices = "4.4.2"
3939
playServicesOssPlugin = "0.10.6"
@@ -45,7 +45,7 @@ lottie = "6.4.1"
4545
kotlinDateRange = "1.0.0"
4646
kotlinReflect = "2.0.21"
4747
firebase-crashlytics = "3.0.3"
48-
firebase-bom = "33.9.0"
48+
firebase-bom = "33.10.0"
4949
room = "2.6.1"
5050
ksp = "2.1.0-1.0.29"
5151
parcelize = "2.0.21"

xposed-core/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ plugins {
33
alias(libs.plugins.kotlin.android)
44
}
55

6-
val xposedName = "1.0.1"
7-
val xposedCode = 101
6+
val xposedName = "1.0.2"
7+
val xposedCode = 102
88

99
android {
1010
namespace = "com.kieronquinn.app.utag.xposed.core"

0 commit comments

Comments
 (0)