Hide NFC if the device reports it has no hardware (#941)

* Hide NFC if the device reports it has no hardware

* Add hardware check to webview activity
This commit is contained in:
Daniel Shokouhi 2020-09-16 08:47:09 -07:00 committed by GitHub
parent 532ae9d366
commit debeadb707
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View file

@ -1,5 +1,6 @@
package io.homeassistant.companion.android.settings
import android.content.pm.PackageManager
import android.graphics.Color
import android.os.Build
import android.os.Bundle
@ -96,7 +97,11 @@ 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.onPreferenceClickListener = Preference.OnPreferenceClickListener {
startActivity(NfcSetupActivity.newInstance(requireActivity()))
true

View file

@ -350,6 +350,8 @@ class WebViewActivity : AppCompatActivity(), io.homeassistant.companion.android.
}
}
"config/get" -> {
val pm: PackageManager = context.packageManager
val hasNfc = pm.hasSystemFeature(PackageManager.FEATURE_NFC)
val script = "externalBus(" +
"${JSONObject(
mapOf(
@ -359,7 +361,7 @@ class WebViewActivity : AppCompatActivity(), io.homeassistant.companion.android.
"result" to JSONObject(
mapOf(
"hasSettingsScreen" to true,
"canWriteTag" to true,
"canWriteTag" to hasNfc,
"hasExoPlayer" to true
)
)