From 3001e2b2a93835dd0d416aedda3f5d0507caf738 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 23 May 2021 16:25:26 +0200 Subject: [PATCH] Prevent crash --- .../main/java/eu/faircode/email/FragmentOptionsMisc.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java index e595fb28da..d496d4dad0 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java @@ -253,7 +253,8 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc swPowerMenu.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { - Helper.enableComponent(getContext(), ServicePowerControl.class, checked); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) + Helper.enableComponent(getContext(), ServicePowerControl.class, checked); } }); @@ -944,7 +945,8 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc private void setOptions() { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); - swPowerMenu.setChecked(Helper.isComponentEnabled(getContext(), ServicePowerControl.class)); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) + swPowerMenu.setChecked(Helper.isComponentEnabled(getContext(), ServicePowerControl.class)); swExternalSearch.setChecked(Helper.isComponentEnabled(getContext(), ActivitySearch.class)); swShortcuts.setChecked(prefs.getBoolean("shortcuts", true)); swFts.setChecked(prefs.getBoolean("fts", false));