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
|
package io.homeassistant.companion.android.settings
|
||||||
|
|
||||||
|
import android.content.pm.PackageManager
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
@ -96,7 +97,11 @@ class SettingsFragment : PreferenceFragmentCompat(), SettingsView {
|
||||||
}
|
}
|
||||||
|
|
||||||
findPreference<Preference>("nfc_tags")?.let {
|
findPreference<Preference>("nfc_tags")?.let {
|
||||||
|
val pm: PackageManager = requireContext().packageManager
|
||||||
|
if (pm.hasSystemFeature(PackageManager.FEATURE_NFC))
|
||||||
it.isVisible = presenter.nfcEnabled()
|
it.isVisible = presenter.nfcEnabled()
|
||||||
|
else
|
||||||
|
it.isVisible = false
|
||||||
it.onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
it.onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
||||||
startActivity(NfcSetupActivity.newInstance(requireActivity()))
|
startActivity(NfcSetupActivity.newInstance(requireActivity()))
|
||||||
true
|
true
|
||||||
|
|
|
@ -350,6 +350,8 @@ class WebViewActivity : AppCompatActivity(), io.homeassistant.companion.android.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"config/get" -> {
|
"config/get" -> {
|
||||||
|
val pm: PackageManager = context.packageManager
|
||||||
|
val hasNfc = pm.hasSystemFeature(PackageManager.FEATURE_NFC)
|
||||||
val script = "externalBus(" +
|
val script = "externalBus(" +
|
||||||
"${JSONObject(
|
"${JSONObject(
|
||||||
mapOf(
|
mapOf(
|
||||||
|
@ -359,7 +361,7 @@ class WebViewActivity : AppCompatActivity(), io.homeassistant.companion.android.
|
||||||
"result" to JSONObject(
|
"result" to JSONObject(
|
||||||
mapOf(
|
mapOf(
|
||||||
"hasSettingsScreen" to true,
|
"hasSettingsScreen" to true,
|
||||||
"canWriteTag" to true,
|
"canWriteTag" to hasNfc,
|
||||||
"hasExoPlayer" to true
|
"hasExoPlayer" to true
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue