Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 0.25.3-beta #140

Merged
merged 2 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ android {
minSdk = 29
targetSdk = 34

versionCode = 1708536354
versionName = "0.25.2-beta"
versionCode = 1708536355
versionName = "0.25.3-beta"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package f.cking.software.domain.interactor.filterchecker

import f.cking.software.checkRegexSafe
import f.cking.software.data.helpers.PowerModeHelper
import f.cking.software.data.repo.DevicesRepository
import f.cking.software.domain.interactor.CheckDeviceIsFollowingInteractor
Expand All @@ -26,12 +27,12 @@ class FilterCheckerImpl(
device.firstDetectTimeMs in filter.from..filter.to
}
private val name = filterChecker<RadarProfile.Filter.Name>(useCache = true) { device, filter ->
val regexMatch = device.name?.contains(filter.name.toRegex()) ?: false
val regexMatch = device.name?.checkRegexSafe(filter.name) ?: false
val noCaseSubstringMatch = device.name?.contains(filter.name, filter.ignoreCase) ?: false
regexMatch || noCaseSubstringMatch
}
private val address = filterChecker<RadarProfile.Filter.Address>(useCache = true) { device, filter ->
device.address.contains(filter.address.toRegex())
device.address.checkRegexSafe(filter.address)
}
private val manufacturer = filterChecker<RadarProfile.Filter.Manufacturer>(useCache = true) { device, filter ->
device.manufacturerInfo?.id?.let { it == filter.manufacturerId } ?: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import f.cking.software.BuildConfig
import f.cking.software.R
import f.cking.software.checkRegexSafe
import f.cking.software.data.helpers.IntentHelper
import f.cking.software.data.repo.DevicesRepository
import f.cking.software.data.repo.SettingsRepository
Expand Down Expand Up @@ -294,8 +295,8 @@ class DeviceListViewModel(
|| (device.customName?.contains(searchStr, true) ?: false)
|| (device.manufacturerInfo?.name?.contains(searchStr, true) ?: false)
|| device.address.contains(searchStr, true)
|| device.address.contains(query.toRegex())
|| (device.name?.contains(query.toRegex()) ?: false)
|| device.address.checkRegexSafe(query)
|| (device.name?.checkRegexSafe(query) ?: false)
} ?: true
}

Expand Down
13 changes: 13 additions & 0 deletions app/src/main/java/f/cking/software/utils/ext.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ import android.view.Display
import android.view.WindowManager
import android.widget.Toast
import androidx.core.content.ContextCompat
import timber.log.Timber
import java.security.MessageDigest
import java.time.Instant
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.LocalTime
import java.time.ZoneId
import java.time.format.DateTimeFormatter
import java.util.regex.PatternSyntaxException


fun Long.getTimePeriodStr(context: Context): String {
Expand Down Expand Up @@ -125,4 +127,15 @@ fun <T> List<T>.splitToBatches(batchSize: Int): List<List<T>> {
fun Context.isDarkModeOn(): Boolean {
val nightModeFlags = resources.configuration.uiMode and android.content.res.Configuration.UI_MODE_NIGHT_MASK
return nightModeFlags == android.content.res.Configuration.UI_MODE_NIGHT_YES
}

fun String.checkRegexSafe(pattern: String): Boolean {
return try {
this.contains(pattern.toRegex())
} catch (e: PatternSyntaxException) {
false
} catch (e: Throwable) {
Timber.e("Unexpected regex failure", e)
false
}
}
Loading