Skip to content

Commit

Permalink
Fix settings crash (home-assistant#911)
Browse files Browse the repository at this point in the history
  • Loading branch information
dshokouhi authored and anyuta1166 committed Sep 12, 2020
1 parent 189bdf6 commit 34e1fd4
Showing 1 changed file with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import android.os.Bundle
import android.os.Process.myPid
import android.os.Process.myUid
import android.text.InputType
import android.util.Log
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.content.res.AppCompatResources
import androidx.biometric.BiometricManager
Expand Down Expand Up @@ -162,20 +163,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)
}
}
}

Expand Down

0 comments on commit 34e1fd4

Please sign in to comment.