mirror of
https://github.com/home-assistant/android
synced 2024-09-19 16:11:37 +00:00
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:
parent
532ae9d366
commit
debeadb707
|
@ -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 {
|
||||
it.isVisible = presenter.nfcEnabled()
|
||||
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
|
||||
|
|
|
@ -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
|
||||
)
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue