From b6b6bff24ad0dc3febf60a548d518e26f70f16bc Mon Sep 17 00:00:00 2001 From: Alexis THOMAS Date: Thu, 28 Oct 2021 01:56:18 +0200 Subject: [PATCH] IS_AT_LEAST SDK_INT --- src/android/nl/xservices/plugins/Toast.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/android/nl/xservices/plugins/Toast.java b/src/android/nl/xservices/plugins/Toast.java index de6b510..03242bf 100644 --- a/src/android/nl/xservices/plugins/Toast.java +++ b/src/android/nl/xservices/plugins/Toast.java @@ -35,6 +35,7 @@ public class Toast extends CordovaPlugin { private android.widget.Toast mostRecentToast; private ViewGroup viewGroup; + private static final boolean IS_AT_LEAST_JELLY_BEAN = Build.VERSION.SDK_INT >= 16; private static final boolean IS_AT_LEAST_LOLLIPOP = Build.VERSION.SDK_INT >= 21; private static final boolean IS_AT_LEAST_PIE = Build.VERSION.SDK_INT >= 28; @@ -105,7 +106,7 @@ public void run() { } // if one of the custom layout options have been passed in, draw our own shape - if (styling != null && Build.VERSION.SDK_INT >= 16) { + if (styling != null && IS_AT_LEAST_JELLY_BEAN) { // the defaults mimic the default toast as close as possible final String backgroundColor = styling.optString("backgroundColor", "#333333"); @@ -132,7 +133,7 @@ public void run() { toast.getView().setPadding(horizontalPadding, verticalPadding, horizontalPadding, verticalPadding); // this gives the toast a very subtle shadow on newer devices - if (Build.VERSION.SDK_INT >= 21) { + if (IS_AT_LEAST_LOLLIPOP) { toast.getView().setElevation(6); } }