Skip to content

Commit

Permalink
fix #25 and upgrade version
Browse files Browse the repository at this point in the history
  • Loading branch information
Helium314 committed Apr 22, 2024
1 parent b5cfb6c commit 773c25c
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 15 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Removed
- Not applicable

## [1.2.12] - 2024-xx-xx
## [1.2.12] - 2024-04-22
### Added
- Not applicable

### Changed
- Upgraded dependencies
- Extend blacklist
- Avoid crashes due to invalid emitter type
- Upgrade dependencies

### Removed
- Not applicable
Expand Down
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "helium314.localbackend"
minSdkVersion 18
targetSdkVersion 33
versionCode 39
versionName "1.2.11"
versionCode 40
versionName "1.2.12"
}

buildTypes {
Expand Down Expand Up @@ -47,5 +47,5 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0'
implementation 'org.microg.nlp:api:2.0-alpha10'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0'
}
12 changes: 8 additions & 4 deletions app/src/main/java/org/fitchfamily/android/dejavu/Database.kt
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,10 @@ class Database(context: Context?, name: String = DB_NAME) : // allow overriding
// get multiple emitters instead of querying one by one
fun getEmitters(rfIds: Collection<RfIdentification>): List<RfEmitter> {
val idString = rfIds.joinToString(",") { "'${it.uniqueId}'" }
return query(allColumns, "$COL_RFID IN ($idString)") { it.toRfEmitter() }.toList()
return query(allColumns, "$COL_RFID IN ($idString)") { it.toRfEmitter() }.filterNotNull().toList()
}

fun getAll() = query(allColumns) { it.toRfEmitter() }
fun getAll() = query(allColumns) { it.toRfEmitter() }.filterNotNull()

fun getSize() = DatabaseUtils.queryNumEntries(database, TABLE_SAMPLES)

Expand Down Expand Up @@ -483,10 +483,14 @@ private inline fun <T> Cursor.toSequence(crossinline transform: (CursorPosition)
}
}

private fun CursorPosition.toRfEmitter(rfId: RfIdentification? = null): RfEmitter {
private fun CursorPosition.toRfEmitter(rfId: RfIdentification? = null): RfEmitter? {
val info = EmitterInfo(getDouble(COL_LAT), getDouble(COL_LON), getDouble(COL_RAD_NS), getDouble(COL_RAD_EW), getString(COL_NOTE))
return if (rfId == null) {
val type = EmitterType.valueOf(getString(COL_TYPE))
val type = try {
EmitterType.valueOf(getString(COL_TYPE))
} catch (_: Exception) {
return null
}
val dbId = getString(COL_RFID)
val id = if (type in wifis) dbId.substringAfter('/')
else dbId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,14 +398,16 @@ class SettingsActivity : PreferenceActivity() {
if (splitLine[5].isEmpty()) return null // why is this the case so often? do some phones not report it (properly)?
"LTE/${splitLine[1]}/${splitLine[2]}/${splitLine[4]}/${splitLine[5]}/${splitLine[3]}" //LTE,202,1,3126,35714457,20 -> LTE/202/1/35714457/20/3126
}
else -> ""
else -> return null
}
splitLine = listOf(rfid, rfid.substringBefore('/'), splitLine[7], splitLine[6], splitLine[8], splitLine[8], "")

} else if (readFormat == 4 && splitLine.size != 7) {
if (splitLine[0].uppercase() !in emitterTypes) return null
// we have one or more comma in ssid, rare enough to not optimize anything
splitLine = splitLine.subList(0, 6) + splitLine.subList(6, splitLine.size).joinToString(",") // careful, subList endIndex is exclusive!
}
if (splitLine[0].uppercase() !in emitterTypes) return null
return splitLine
}

Expand Down Expand Up @@ -588,6 +590,7 @@ class SettingsActivity : PreferenceActivity() {

private const val IMPORT_CODE = 6957238
private const val EXPORT_CODE = 75902745
private val emitterTypes = EmitterType.entries.map { it.name.uppercase() }.toHashSet()

const val PREF_KALMAN = "pref_kalman"
const val PREF_MOBILE = "pref_use_cell"
Expand Down
6 changes: 1 addition & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
google()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.21"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.23"
classpath 'com.android.tools.build:gradle:8.1.4'
}
}
Expand All @@ -15,7 +15,3 @@ allprojects {
google()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
3 changes: 3 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/40.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Extend blacklist
- Avoid crashes due to invalid emitter type
- Upgrade dependencies

0 comments on commit 773c25c

Please sign in to comment.