From 4669275680a5ee09d8c12bb6dafa4b73f7eb198c Mon Sep 17 00:00:00 2001 From: Matt Portune <59324545+mportune-bw@users.noreply.github.com> Date: Wed, 13 Oct 2021 12:26:54 -0400 Subject: [PATCH] Fix for Android 5.x crash caused by new switch styling (#1575) --- src/Android/Renderers/CustomSwitchRenderer.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Android/Renderers/CustomSwitchRenderer.cs b/src/Android/Renderers/CustomSwitchRenderer.cs index 121f152ca..00caa6290 100644 --- a/src/Android/Renderers/CustomSwitchRenderer.cs +++ b/src/Android/Renderers/CustomSwitchRenderer.cs @@ -2,6 +2,7 @@ using Android.Content; using Android.Content.Res; using Android.Graphics.Drawables; +using Android.OS; using AndroidX.Core.Content.Resources; using Bit.Droid.Renderers; using Bit.Droid.Utilities; @@ -35,6 +36,12 @@ namespace Bit.Droid.Renderers private void UpdateColors() { + if (Build.VERSION.SdkInt <= BuildVersionCodes.LollipopMr1) + { + // Android 5.x doesn't support ThumbTintList, and using SwitchCompat on every version after 5.x + // doesn't apply tinting the way we want. Let 5.x to do its own thing here. + return; + } if (Control != null) { var t = ResourcesCompat.GetDrawable(Resources, Resource.Drawable.switch_thumb, null);