Fix settings crash (#911)

This commit is contained in:
Daniel Shokouhi 2020-09-10 17:12:58 -07:00 committed by GitHub
parent da9d4dbc72
commit e5baf1e64c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,6 +4,7 @@ import android.graphics.Color
import android.os.Build
import android.os.Bundle
import android.text.InputType
import android.util.Log
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.content.res.AppCompatResources
import androidx.biometric.BiometricManager
@ -147,20 +148,28 @@ class SettingsFragment : PreferenceFragmentCompat(), SettingsView {
override fun disableInternalConnection() {
findPreference<EditTextPreference>("connection_internal")?.let {
it.isEnabled = false
val unwrappedDrawable =
AppCompatResources.getDrawable(requireContext(), R.drawable.ic_computer)
unwrappedDrawable?.setTint(Color.DKGRAY)
it.icon = unwrappedDrawable
try {
val unwrappedDrawable =
AppCompatResources.getDrawable(requireContext(), R.drawable.ic_computer)
unwrappedDrawable?.setTint(Color.DKGRAY)
it.icon = unwrappedDrawable
} catch (e: Exception) {
Log.d("SettingsFragment", "Unable to set the icon tint", e)
}
}
}
override fun enableInternalConnection() {
findPreference<EditTextPreference>("connection_internal")?.let {
it.isEnabled = true
val unwrappedDrawable =
AppCompatResources.getDrawable(requireContext(), R.drawable.ic_computer)
unwrappedDrawable?.setTint(resources.getColor(R.color.colorAccent))
it.icon = unwrappedDrawable
try {
val unwrappedDrawable =
AppCompatResources.getDrawable(requireContext(), R.drawable.ic_computer)
unwrappedDrawable?.setTint(resources.getColor(R.color.colorAccent))
it.icon = unwrappedDrawable
} catch (e: Exception) {
Log.d("SettingsFragment", "Unable to set the icon tint", e)
}
}
}