Skip to content

Commit

Permalink
Remove extra HA version check for NFC settings (#1785)
Browse files Browse the repository at this point in the history
  • Loading branch information
dshokouhi committed Oct 15, 2021
1 parent 7a026c4 commit 62d7542
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,7 @@ class SettingsFragment : PreferenceFragmentCompat(), SettingsView {

findPreference<Preference>("nfc_tags")?.let {
val pm: PackageManager = requireContext().packageManager
if (pm.hasSystemFeature(PackageManager.FEATURE_NFC))
it.isVisible = presenter.nfcEnabled()
else
it.isVisible = false
it.isVisible = pm.hasSystemFeature(PackageManager.FEATURE_NFC)
it.onPreferenceClickListener = Preference.OnPreferenceClickListener {
startActivity(NfcSetupActivity.newInstance(requireActivity()))
true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ interface SettingsPresenter {
fun getPreferenceDataStore(): PreferenceDataStore
fun onCreate()
fun onFinish()
fun nfcEnabled(): Boolean
fun isLockEnabled(): Boolean
fun sessionTimeOut(): Int
suspend fun getNotificationRateLimits(): RateLimitResponse?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,22 +188,6 @@ class SettingsPresenterImpl @Inject constructor(
}
}

// Make sure Core is above 0.114.0 because that's the first time NFC is available.
override fun nfcEnabled(): Boolean {
return runBlocking {
var splitVersion = listOf<String>()

try {
splitVersion = integrationUseCase.getHomeAssistantVersion().split(".")
} catch (e: Exception) {
Log.e(TAG, "Unable to get core version.", e)
}

return@runBlocking splitVersion.size > 2 &&
(Integer.parseInt(splitVersion[0]) > 0 || Integer.parseInt(splitVersion[1]) >= 114)
}
}

override suspend fun getNotificationRateLimits(): RateLimitResponse? = withContext(Dispatchers.IO) {
try {
integrationUseCase.getNotificationRateLimits()
Expand Down

0 comments on commit 62d7542

Please sign in to comment.