LineageParts: Some fixes

* Remove unused code and namespaces
* Rework deprecated code
* Fix a few warnings (mainly possible NPEs for
  getActivity() and getContext())
* Adjust copyrights - we don't want a list, but ranges - see
  https://epiphany.law/articles/copyright/copyright-dates-single-year-or-range

Change-Id: I725114402b4af37b8f95583db356aeba1418e087
diff --git a/res/layout/preference_list_fragment.xml b/res/layout/preference_list_fragment.xml
index c320ff8..c5d9fc7 100644
--- a/res/layout/preference_list_fragment.xml
+++ b/res/layout/preference_list_fragment.xml
@@ -1,12 +1,11 @@
 <?xml version="1.0" encoding="utf-8" ?>
 <!--
      SPDX-FileCopyrightText: 2014 The Android Open Source Project
+     SPDX-FileCopyrightText: 2023 The LineageOS Project
      SPDX-License-Identifier: Apache-2.0
 -->
 <LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
     android:id="@+id/container_material"
     android:orientation="vertical"
     android:layout_width="match_parent"
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index 87d311d..9664012 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -154,7 +154,7 @@
         <item>normal</item>
         <item>vibrate</item>
         <item>mute</item>
-        <item></item>
+        <item />
     </string-array>
 
     <!--  Values for profile Wi-Fi triggers -->
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 4cc2385..f63a42c 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -30,7 +30,7 @@
     <string name="enabled">Enabled</string>
 
     <!-- DO NOT TRANSLATE Empty summary for dynamic preferences -->
-    <string name="summary_empty" translatable="false"></string>
+    <string name="summary_empty" translatable="false" />
 
     <!-- Privacy Settings Header item -->
     <string name="privacy_settings_title">Privacy</string>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 57b212c..be39ae5 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -1,18 +1,18 @@
 <?xml version="1.0" encoding="utf-8" ?>
 <!--
      SPDX-FileCopyrightText: 2010 The Android Open Source Project
+     SPDX-FileCopyrightText: 2023 The LineageOS Project
      SPDX-License-Identifier: Apache-2.0
 -->
-<resources
-    xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
+<resources>
 
-    <style name="TextAppearance" parent="android:TextAppearance.DeviceDefault"/>
+    <style name="TextAppearance" parent="android:TextAppearance.DeviceDefault" />
 
-    <style name="TextAppearance.Medium" parent="@android:style/TextAppearance.DeviceDefault.Medium"/>
-    <style name="TextAppearance.Small" parent="@android:style/TextAppearance.DeviceDefault.Small"/>
+    <style name="TextAppearance.Medium" parent="@android:style/TextAppearance.DeviceDefault.Medium" />
 
-    <style name="TextAppearance.CategoryTitle"
-           parent="@*android:style/TextAppearance.DeviceDefault.Body2">
+    <style name="TextAppearance.Small" parent="@android:style/TextAppearance.DeviceDefault.Small" />
+
+    <style name="TextAppearance.CategoryTitle" parent="@*android:style/TextAppearance.DeviceDefault.Body2">
         <item name="android:textAllCaps">true</item>
         <item name="android:textSize">11sp</item>
         <!-- 0.8 Spacing, 0.8/11 = 0.072727273 -->
diff --git a/res/xml/long_screen_prefs.xml b/res/xml/long_screen_prefs.xml
index 802b674..9a4f7bb 100644
--- a/res/xml/long_screen_prefs.xml
+++ b/res/xml/long_screen_prefs.xml
@@ -1,11 +1,10 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!--
-     SPDX-FileCopyrightText: 2018 The LineageOS Project
+     SPDX-FileCopyrightText: 2018-2023 The LineageOS Project
      SPDX-License-Identifier: Apache-2.0
 -->
 <PreferenceScreen
     xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:lineage="http://schemas.android.com/apk/res/org.lineageos.lineageparts"
     android:key="long_screen_settings"
     android:title="@string/long_screen_settings_title">
 
diff --git a/res/xml/network_traffic_settings.xml b/res/xml/network_traffic_settings.xml
index f4637fc..efa7aa4 100644
--- a/res/xml/network_traffic_settings.xml
+++ b/res/xml/network_traffic_settings.xml
@@ -1,45 +1,44 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!--
-     SPDX-FileCopyrightText: 2017-2018,2023 The LineageOS Project
+     SPDX-FileCopyrightText: 2017-2023 The LineageOS Project
      SPDX-License-Identifier: Apache-2.0
 -->
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
 
     <DropDownPreference
-        android:key="network_traffic_mode"
-        android:title="@string/network_traffic_mode_title"
         android:entries="@array/network_traffic_mode_entries"
         android:entryValues="@array/network_traffic_mode_values"
+        android:key="network_traffic_mode"
+        android:persistent="false"
         android:summary="%s"
-        android:persistent="false" />
+        android:title="@string/network_traffic_mode_title" />
 
     <DropDownPreference
-        android:key="network_traffic_position"
-        android:title="@string/network_traffic_position_title"
         android:entries="@array/network_traffic_position_entries"
         android:entryValues="@array/network_traffic_position_values"
+        android:key="network_traffic_position"
+        android:persistent="false"
         android:summary="%s"
-        android:persistent="false" />
+        android:title="@string/network_traffic_position_title" />
 
     <lineageos.preference.LineageSecureSettingSwitchPreference
+        android:defaultValue="false"
         android:key="network_traffic_autohide"
-        android:title="@string/network_traffic_autohide"
         android:summary="@string/network_traffic_autohide_summary"
-        android:defaultValue="false" />
+        android:title="@string/network_traffic_autohide" />
 
     <DropDownPreference
-        android:key="network_traffic_units"
-        android:title="@string/network_traffic_units_title"
         android:entries="@array/network_traffic_units_entries"
         android:entryValues="@array/network_traffic_units_values"
+        android:key="network_traffic_units"
+        android:persistent="false"
         android:summary="%s"
-        android:persistent="false" />
+        android:title="@string/network_traffic_units_title" />
 
     <lineageos.preference.LineageSecureSettingSwitchPreference
+        android:defaultValue="true"
         android:key="network_traffic_show_units"
-        android:title="@string/network_traffic_show_units"
         android:summary="@string/network_traffic_show_units_summary"
-        android:defaultValue="true" />
+        android:title="@string/network_traffic_show_units" />
 
 </PreferenceScreen>
diff --git a/res/xml/profile_settings.xml b/res/xml/profile_settings.xml
index 4bfb6c1..9d26667 100644
--- a/res/xml/profile_settings.xml
+++ b/res/xml/profile_settings.xml
@@ -1,61 +1,59 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!--
      SPDX-FileCopyrightText: 2012 The CyanogenMod Project
+     SPDX-FileCopyrightText: 2023 The LineageOS Project
      SPDX-License-Identifier: Apache-2.0
 -->
 
 <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
-        android:title="@string/profile_settings"
-        android:key="profile_settings"
-        xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
+    android:key="profile_settings"
+    android:title="@string/profile_settings">
 
     <ListPreference
-            android:key="sound_mode"
-            android:title="@string/sound_mode"
-            android:summary="@string/sound_mode"
-            android:entries="@array/profile_entries"
-            android:persistent="false"
-            android:entryValues="@array/profile_values" />
+        android:entries="@array/profile_entries"
+        android:entryValues="@array/profile_values"
+        android:key="sound_mode"
+        android:persistent="false"
+        android:summary="@string/sound_mode"
+        android:title="@string/sound_mode" />
 
     <org.lineageos.lineageparts.profiles.ProfileRingtonePreference
-            android:key="soundtone"
-            android:title="@string/soundtone_title"
-            android:summary="@string/soundtone_summary"
-            android:dialogTitle="@string/soundtone_title"
-            android:persistent="false"
-            android:ringtoneType="notification" />
+        android:dialogTitle="@string/soundtone_title"
+        android:key="soundtone"
+        android:persistent="false"
+        android:ringtoneType="notification"
+        android:summary="@string/soundtone_summary"
+        android:title="@string/soundtone_title" />
 
     <ListPreference
-            android:key="ringer_mode"
-            android:title="@string/ringer_mode"
-            android:summary="@string/ringer_mode"
-            android:entries="@array/profile_entries"
-            android:persistent="false"
-            android:entryValues="@array/profile_values" />
+        android:entries="@array/profile_entries"
+        android:entryValues="@array/profile_values"
+        android:key="ringer_mode"
+        android:persistent="false"
+        android:summary="@string/ringer_mode"
+        android:title="@string/ringer_mode" />
 
     <org.lineageos.lineageparts.profiles.ProfileRingtonePreference
-            android:key="ringtone"
-            android:title="@string/ringtone_title"
-            android:summary="@string/ringtone_summary"
-            android:dialogTitle="@string/ringtone_title"
-            android:persistent="false"
-            android:ringtoneType="ringtone" />
+        android:dialogTitle="@string/ringtone_title"
+        android:key="ringtone"
+        android:persistent="false"
+        android:ringtoneType="ringtone"
+        android:summary="@string/ringtone_summary"
+        android:title="@string/ringtone_title" />
 
     <ListPreference
-            android:key="vibrate_mode"
-            android:title="@string/vibrate_mode"
-            android:summary="@string/sound_mode"
-            android:entries="@array/profile_entries"
-            android:persistent="false"
-            android:entryValues="@array/profile_values" />
+        android:entries="@array/profile_entries"
+        android:entryValues="@array/profile_values"
+        android:key="vibrate_mode"
+        android:persistent="false"
+        android:summary="@string/sound_mode"
+        android:title="@string/vibrate_mode" />
 
     <ListPreference
-            android:key="lights_mode"
-            android:title="@string/lights_mode"
-            android:summary="@string/sound_mode"
-            android:entries="@array/profile_entries"
-            android:persistent="false"
-            android:entryValues="@array/profile_values" />
-
-
+        android:entries="@array/profile_entries"
+        android:entryValues="@array/profile_values"
+        android:key="lights_mode"
+        android:persistent="false"
+        android:summary="@string/sound_mode"
+        android:title="@string/lights_mode" />
 </PreferenceScreen>
diff --git a/src/org/lineageos/lineageparts/PartsActivity.java b/src/org/lineageos/lineageparts/PartsActivity.java
index 2046bbc..bb6f04e 100644
--- a/src/org/lineageos/lineageparts/PartsActivity.java
+++ b/src/org/lineageos/lineageparts/PartsActivity.java
@@ -1,6 +1,6 @@
 /*
  * SPDX-FileCopyrightText: 2016 The CyanogenMod Project
- * SPDX-FileCopyrightText: 2017-2019,2021-2023 The LineageOS Project
+ * SPDX-FileCopyrightText: 2017-2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 
@@ -138,7 +138,7 @@
     @Override
     protected void onNewIntent(Intent intent) {
         if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(intent.getAction())) {
-            Tag detectedTag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
+            Tag detectedTag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG, Tag.class);
             if (mNfcProfileCallback != null) {
                 mNfcProfileCallback.onTagRead(detectedTag);
             }
@@ -151,7 +151,7 @@
     public void onBackPressed() {
         setTitle(mInitialTitle);
 
-        if (!getFragmentManager().popBackStackImmediate()) {
+        if (!getSupportFragmentManager().popBackStackImmediate()) {
             super.onBackPressed();
         }
     }
@@ -189,11 +189,7 @@
 
     public boolean switchToFragment(String fragmentClass, Bundle args, int titleRes,
                                     CharSequence titleText) {
-        Fragment fragment = Fragment.instantiate(this, fragmentClass);
-        if (fragment == null) {
-            Log.e(TAG, "Invalid fragment! " + fragmentClass);
-            return false;
-        }
+        Fragment fragment = Fragment.instantiate(this, fragmentClass, null);
         return switchToFragment(fragment, args, titleRes, titleText);
     }
 
diff --git a/src/org/lineageos/lineageparts/PartsUpdater.java b/src/org/lineageos/lineageparts/PartsUpdater.java
index 6988aa4..82cd674 100644
--- a/src/org/lineageos/lineageparts/PartsUpdater.java
+++ b/src/org/lineageos/lineageparts/PartsUpdater.java
@@ -1,6 +1,6 @@
 /*
  * SPDX-FileCopyrightText: 2016 The CyanogenMod Project
- * SPDX-FileCopyrightText: 2022 The LineageOS Project
+ * SPDX-FileCopyrightText: 2022-2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 package org.lineageos.lineageparts;
@@ -25,13 +25,13 @@
  * PartsRefresher keeps remote UI clients up to date with any changes in the
  * state of the Part which should be reflected immediately. For preferences,
  * the clear use case is refreshing the summary.
- *
+ * <p>
  * This works in conjunction with LineagePartsPreference, which will send an
  * ordered broadcast requesting updated information. The part will be
  * looked up, and checked for a static SUMMARY_INFO field. If an
  * instance of SummaryInfo is found in this field, the result of the
  * broadcast will be updated with the new information.
- *
+ * <p>
  * Parts can also call refreshPart to send an asynchronous update to any
  * active remote components via broadcast.
  */
@@ -81,8 +81,7 @@
             bundle.putString(EXTRA_SUMMARY, pi.getSummary());
         }
 
-        if (DEBUG) Log.d(TAG, "fillResultExtras key=" + key +
-                         " part=" + pi.toString());
+        if (DEBUG) Log.d(TAG, "fillResultExtras key=" + key + " part=" + pi);
 
         bundle.putParcelable(EXTRA_PART, pi);
         return true;
diff --git a/src/org/lineageos/lineageparts/SettingsPreferenceFragment.java b/src/org/lineageos/lineageparts/SettingsPreferenceFragment.java
index 9f59526..de3ddd3 100644
--- a/src/org/lineageos/lineageparts/SettingsPreferenceFragment.java
+++ b/src/org/lineageos/lineageparts/SettingsPreferenceFragment.java
@@ -1,6 +1,6 @@
 /*
  * SPDX-FileCopyrightText: 2010 The Android Open Source Project
- * SPDX-FileCopyrightText: 2020-2022 The LineageOS Project
+ * SPDX-FileCopyrightText: 2020-2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 
@@ -15,23 +15,18 @@
 import android.content.pm.PackageManager;
 import android.net.Uri;
 import android.os.Bundle;
-import android.text.TextUtils;
-import android.util.ArrayMap;
 import android.util.ArraySet;
 import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.Button;
-import android.view.animation.*;
 
+import androidx.annotation.NonNull;
 import androidx.fragment.app.DialogFragment;
 import androidx.fragment.app.Fragment;
 import androidx.preference.Preference;
-import androidx.preference.PreferenceGroup;
-import androidx.preference.PreferenceGroupAdapter;
 import androidx.preference.PreferenceScreen;
-import androidx.preference.PreferenceViewHolder;
 import androidx.recyclerview.widget.LinearLayoutManager;
 import androidx.recyclerview.widget.RecyclerView;
 
@@ -53,24 +48,13 @@
 public abstract class SettingsPreferenceFragment extends ObservablePreferenceFragment
         implements DialogCreatable, PartsUpdater.Refreshable {
 
-    /**
-     * The Help Uri Resource key. This can be passed as an extra argument when creating the
-     * Fragment.
-     **/
-    public static final String HELP_URI_RESOURCE_KEY = "help_uri_resource";
-
     private static final String TAG = "SettingsPreference";
 
-    private static final int DELAY_HIGHLIGHT_DURATION_MILLIS = 600;
-
     private static final String SAVE_HIGHLIGHTED_KEY = "android:preference_highlighted";
 
     private SettingsDialogFragment mDialogFragment;
 
-    private String mHelpUri;
-
     private static final int ORDER_FIRST = -1;
-    private static final int ORDER_LAST = Integer.MAX_VALUE -1;
 
     // Cache the content resolver for async callbacks
     private ContentResolver mContentResolver;
@@ -87,18 +71,12 @@
         }
     };
 
-    private ViewGroup mPinnedHeaderFrameLayout;
-    private ViewGroup mButtonBar;
-
     private LayoutPreference mHeader;
 
-    private LayoutPreference mFooter;
     private View mEmptyView;
     private HighlightablePreferenceGroupAdapter mAdapter;
-    private ArrayMap<String, Preference> mPreferenceCache;
-    private boolean mAnimationAllowed;
 
-    private final ArraySet<Uri> mTriggerUris = new ArraySet<Uri>();
+    private final ArraySet<Uri> mTriggerUris = new ArraySet<>();
 
     @Override
     public void onCreate(Bundle icicle) {
@@ -110,11 +88,9 @@
     }
 
     @Override
-    public View onCreateView(LayoutInflater inflater, ViewGroup container,
-            Bundle savedInstanceState) {
+    public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
+                             Bundle savedInstanceState) {
         final View root = super.onCreateView(inflater, container, savedInstanceState);
-        mPinnedHeaderFrameLayout = root.findViewById(R.id.pinned_header);
-        mButtonBar = root.findViewById(R.id.button_bar);
         return root;
     }
 
@@ -122,23 +98,6 @@
     public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
     }
 
-    public ViewGroup getButtonBar() {
-        return mButtonBar;
-    }
-
-    public View setPinnedHeaderView(int layoutResId) {
-        final LayoutInflater inflater = getActivity().getLayoutInflater();
-        final View pinnedHeader =
-                inflater.inflate(layoutResId, mPinnedHeaderFrameLayout, false);
-        setPinnedHeaderView(pinnedHeader);
-        return pinnedHeader;
-    }
-
-    public void setPinnedHeaderView(View pinnedHeader) {
-        mPinnedHeaderFrameLayout.addView(pinnedHeader);
-        mPinnedHeaderFrameLayout.setVisibility(View.VISIBLE);
-    }
-
     @Override
     public void onSaveInstanceState(Bundle outState) {
         super.onSaveInstanceState(outState);
@@ -177,51 +136,6 @@
         PartsUpdater.notifyChanged(getActivity(), getPreferenceScreen().getKey());
     }
 
-    public void showLoadingWhenEmpty() {
-        View loading = getView().findViewById(R.id.loading_container);
-        setEmptyView(loading);
-    }
-
-    public void handleLoadingContainer(View loading, View doneLoading, boolean done,
-                                              boolean animate) {
-        setViewShown(loading, !done, animate);
-        setViewShown(doneLoading, done, animate);
-    }
-
-    private void setViewShown(final View view, boolean shown, boolean animate) {
-        if (animate) {
-            Animation animation = AnimationUtils.loadAnimation(view.getContext(),
-                    shown ? android.R.anim.fade_in : android.R.anim.fade_out);
-            if (shown) {
-                view.setVisibility(View.VISIBLE);
-            } else {
-                animation.setAnimationListener(new Animation.AnimationListener() {
-                    @Override
-                    public void onAnimationStart(Animation animation) {
-                    }
-
-                    @Override
-                    public void onAnimationRepeat(Animation animation) {
-                    }
-
-                    @Override
-                    public void onAnimationEnd(Animation animation) {
-                        view.setVisibility(View.INVISIBLE);
-                    }
-                });
-            }
-            view.startAnimation(animation);
-        } else {
-            view.clearAnimation();
-            view.setVisibility(shown ? View.VISIBLE : View.INVISIBLE);
-        }
-    }
-
-    public void setLoading(boolean loading, boolean animate) {
-        View loading_container = getView().findViewById(R.id.loading_container);
-        handleLoadingContainer(loading_container, getListView(), !loading, animate);
-    }
-
     public void registerObserverIfNeeded() {
         if (!mIsDataSetObserverRegistered) {
             if (mCurrentRootAdapter != null) {
@@ -258,19 +172,6 @@
         updateEmptyView();
     }
 
-    public LayoutPreference getHeaderView() {
-        return mHeader;
-    }
-
-    public LayoutPreference getFooterView() {
-        return mFooter;
-    }
-
-    protected void setHeaderView(int resource) {
-        mHeader = new LayoutPreference(getPrefContext(), resource);
-        addPreferenceToTop(mHeader);
-    }
-
     protected void setHeaderView(View view) {
         mHeader = new LayoutPreference(getPrefContext(), view);
         addPreferenceToTop(mHeader);
@@ -283,43 +184,17 @@
         }
     }
 
-    protected void setFooterView(int resource) {
-        setFooterView(resource != 0 ? new LayoutPreference(getPrefContext(), resource) : null);
-    }
-
-    protected void setFooterView(View v) {
-        setFooterView(v != null ? new LayoutPreference(getPrefContext(), v) : null);
-    }
-
-    private void setFooterView(LayoutPreference footer) {
-        if (getPreferenceScreen() != null && mFooter != null) {
-            getPreferenceScreen().removePreference(mFooter);
-        }
-        if (footer != null) {
-            mFooter = footer;
-            mFooter.setOrder(ORDER_LAST);
-            if (getPreferenceScreen() != null) {
-                getPreferenceScreen().addPreference(mFooter);
-            }
-        } else {
-            mFooter = null;
-        }
-    }
-
     @Override
     public void setPreferenceScreen(PreferenceScreen preferenceScreen) {
         if (preferenceScreen != null && !preferenceScreen.isAttached()) {
             // Without ids generated, the RecyclerView won't animate changes to the preferences.
-            preferenceScreen.setShouldUseGeneratedIds(mAnimationAllowed);
+            preferenceScreen.setShouldUseGeneratedIds(false);
         }
         super.setPreferenceScreen(preferenceScreen);
         if (preferenceScreen != null) {
             if (mHeader != null) {
                 preferenceScreen.addPreference(mHeader);
             }
-            if (mFooter != null) {
-                preferenceScreen.addPreference(mFooter);
-            }
         }
     }
 
@@ -327,8 +202,7 @@
         if (mEmptyView == null) return;
         if (getPreferenceScreen() != null) {
             boolean show = (getPreferenceScreen().getPreferenceCount()
-                    - (mHeader != null ? 1 : 0)
-                    - (mFooter != null ? 1 : 0)) <= 0;
+                    - (mHeader != null ? 1 : 0)) <= 0;
             mEmptyView.setVisibility(show ? View.VISIBLE : View.GONE);
         } else {
             mEmptyView.setVisibility(View.VISIBLE);
@@ -343,10 +217,6 @@
         updateEmptyView();
     }
 
-    public View getEmptyView() {
-        return mEmptyView;
-    }
-
     @Override
     public RecyclerView.LayoutManager onCreateLayoutManager() {
         return new LinearLayoutManager(getContext());
@@ -363,48 +233,6 @@
         return mAdapter;
     }
 
-    protected void setAnimationAllowed(boolean animationAllowed) {
-        mAnimationAllowed = animationAllowed;
-    }
-
-    protected void cacheRemoveAllPrefs(PreferenceGroup group) {
-        mPreferenceCache = new ArrayMap<String, Preference>();
-        final int N = group.getPreferenceCount();
-        for (int i = 0; i < N; i++) {
-            Preference p = group.getPreference(i);
-            if (TextUtils.isEmpty(p.getKey())) {
-                continue;
-            }
-            mPreferenceCache.put(p.getKey(), p);
-        }
-    }
-
-    protected Preference getCachedPreference(String key) {
-        return mPreferenceCache != null ? mPreferenceCache.remove(key) : null;
-    }
-
-    protected void removeCachedPrefs(PreferenceGroup group) {
-        for (Preference p : mPreferenceCache.values()) {
-            group.removePreference(p);
-        }
-    }
-
-    protected int getCachedCount() {
-        return mPreferenceCache.size();
-    }
-
-    private int findListPositionFromKey(PreferenceGroupAdapter adapter, String key) {
-        final int count = adapter.getItemCount();
-        for (int n = 0; n < count; n++) {
-            final Preference preference = adapter.getItem(n);
-            final String preferenceKey = preference.getKey();
-            if (preferenceKey != null && preferenceKey.equals(key)) {
-                return n;
-            }
-        }
-        return -1;
-    }
-
     protected void removePreference(String key) {
         Preference pref = findPreference(key);
         if (pref != null) {
@@ -417,11 +245,11 @@
      * users won't misunderstand its meaning.
      */
     public final void finishFragment() {
-        getActivity().onBackPressed();
+        requireActivity().onBackPressed();
     }
 
     public final void finishPreferencePanel(Fragment caller, int resultCode, Intent data) {
-        ((PartsActivity)getActivity()).finishPreferencePanel(caller, resultCode, data);
+        ((PartsActivity) requireActivity()).finishPreferencePanel(caller, resultCode, data);
     }
 
     // Some helpers for functions used by the settings fragments when they were activities
@@ -438,24 +266,17 @@
     }
 
     /**
-     * Returns the specified system service from the owning Activity.
-     */
-    protected Object getSystemService(final String name) {
-        return getActivity().getSystemService(name);
-    }
-
-    /**
      * Returns the PackageManager from the owning Activity.
      */
     protected PackageManager getPackageManager() {
-        return getActivity().getPackageManager();
+        return requireActivity().getPackageManager();
     }
 
     @Override
-    public void onAttach(Activity activity) {
-        super.onAttach(activity);
+    public void onAttach(Context context) {
+        super.onAttach(context);
         synchronized (mTriggerUris) {
-            SettingsHelper.get(activity).startWatching(this, mTriggerUris.toArray(new Uri[0]));
+            SettingsHelper.get(context).startWatching(this, mTriggerUris.toArray(new Uri[0]));
         }
     }
 
@@ -498,39 +319,6 @@
         return null;
     }
 
-    protected void removeDialog(int dialogId) {
-        // mDialogFragment may not be visible yet in parent fragment's onResume().
-        // To be able to dismiss dialog at that time, don't check
-        // mDialogFragment.isVisible().
-        if (mDialogFragment != null && mDialogFragment.getDialogId() == dialogId) {
-            mDialogFragment.dismiss();
-        }
-        mDialogFragment = null;
-    }
-
-    protected void removeDialog(int dialogId, boolean stateLossAllowed) {
-        if (stateLossAllowed) {
-            if (mDialogFragment != null && mDialogFragment.getDialogId() == dialogId) {
-                getFragmentManager().beginTransaction().remove(mDialogFragment).
-                        commitAllowingStateLoss();
-            }
-            mDialogFragment = null;
-        } else {
-            removeDialog(dialogId);
-        }
-    }
-
-    /**
-     * Sets the OnCancelListener of the dialog shown. This method can only be
-     * called after showDialog(int) and before removeDialog(int). The method
-     * does nothing otherwise.
-     */
-    protected void setOnCancelListener(DialogInterface.OnCancelListener listener) {
-        if (mDialogFragment != null) {
-            mDialogFragment.mOnCancelListener = listener;
-        }
-    }
-
     /**
      * Sets the OnDismissListener of the dialog shown. This method can only be
      * called after showDialog(int) and before removeDialog(int). The method
@@ -561,7 +349,7 @@
             return;
         }
         f.setTargetFragment(this, 0);
-        f.show(getFragmentManager(), "dialog_preference");
+        f.show(getParentFragmentManager(), "dialog_preference");
         onDialogShowing();
     }
 
@@ -573,7 +361,6 @@
 
         private Fragment mParentFragment;
 
-        private DialogInterface.OnCancelListener mOnCancelListener;
         private DialogInterface.OnDismissListener mOnDismissListener;
 
         public static SettingsDialogFragment newInstance(DialogCreatable fragment, int dialogId) {
@@ -590,7 +377,7 @@
         }
 
         @Override
-        public void onSaveInstanceState(Bundle outState) {
+        public void onSaveInstanceState(@NonNull Bundle outState) {
             super.onSaveInstanceState(outState);
             if (mParentFragment != null) {
                 outState.putInt(KEY_DIALOG_ID, mDialogId);
@@ -607,6 +394,7 @@
             }
         }
 
+        @NonNull
         @Override
         public Dialog onCreateDialog(Bundle savedInstanceState) {
             if (savedInstanceState != null) {
@@ -614,7 +402,7 @@
                 mParentFragment = getParentFragment();
                 int mParentFragmentId = savedInstanceState.getInt(KEY_PARENT_FRAGMENT_ID, -1);
                 if (mParentFragment == null) {
-                    mParentFragment = getFragmentManager().findFragmentById(mParentFragmentId);
+                    mParentFragment = getChildFragmentManager().findFragmentById(mParentFragmentId);
                 }
                 if (!(mParentFragment instanceof DialogCreatable)) {
                     throw new IllegalArgumentException(
@@ -634,25 +422,18 @@
         }
 
         @Override
-        public void onCancel(DialogInterface dialog) {
+        public void onCancel(@NonNull DialogInterface dialog) {
             super.onCancel(dialog);
-            if (mOnCancelListener != null) {
-                mOnCancelListener.onCancel(dialog);
-            }
         }
 
         @Override
-        public void onDismiss(DialogInterface dialog) {
+        public void onDismiss(@NonNull DialogInterface dialog) {
             super.onDismiss(dialog);
             if (mOnDismissListener != null) {
                 mOnDismissListener.onDismiss(dialog);
             }
         }
 
-        public int getDialogId() {
-            return mDialogId;
-        }
-
         @Override
         public void onDetach() {
             super.onDetach();
@@ -676,53 +457,27 @@
     }
 
     protected Button getBackButton() {
-        return ((PartsActivity)getActivity()).getBackButton();
+        return ((PartsActivity) requireActivity()).getBackButton();
     }
 
     protected Button getNextButton() {
-        return ((PartsActivity)getActivity()).getNextButton();
+        return ((PartsActivity) requireActivity()).getNextButton();
     }
 
     protected void showButtonBar(boolean show) {
-        ((PartsActivity)getActivity()).showButtonBar(show);
+        ((PartsActivity) requireActivity()).showButtonBar(show);
     }
 
     public void finish() {
         Activity activity = getActivity();
         if (activity == null) return;
-        if (getFragmentManager().getBackStackEntryCount() > 0) {
-            getFragmentManager().popBackStack();
+        if (getParentFragmentManager().getBackStackEntryCount() > 0) {
+            getParentFragmentManager().popBackStack();
         } else {
             activity.finish();
         }
     }
 
-    protected Intent getIntent() {
-        if (getActivity() == null) {
-            return null;
-        }
-        return getActivity().getIntent();
-    }
-
-    protected void setResult(int result, Intent intent) {
-        if (getActivity() == null) {
-            return;
-        }
-        getActivity().setResult(result, intent);
-    }
-
-    protected void setResult(int result) {
-        if (getActivity() == null) {
-            return;
-        }
-        getActivity().setResult(result);
-    }
-
-    protected boolean isFinishingOrDestroyed() {
-        final Activity activity = getActivity();
-        return activity == null || activity.isFinishing() || activity.isDestroyed();
-    }
-
     public boolean isAvailable() {
         return true;
     }
@@ -730,18 +485,4 @@
     protected final Context getPrefContext() {
         return getPreferenceManager().getContext();
     }
-
-    public boolean startFragment(Fragment caller, String fragmentClass, int titleRes,
-                                 int requestCode, Bundle extras) {
-        final Activity activity = getActivity();
-        if (activity instanceof PartsActivity) {
-            PartsActivity sa = (PartsActivity) activity;
-            sa.startPreferencePanel(fragmentClass, extras, titleRes, null, caller, requestCode);
-            return true;
-        } else {
-            Log.w(TAG,
-                    "Parent isn't PartsActivity! (name: " + fragmentClass + ")");
-            return false;
-        }
-    }
 }
diff --git a/src/org/lineageos/lineageparts/applications/LongScreenSettings.java b/src/org/lineageos/lineageparts/applications/LongScreenSettings.java
index 6b98e20..7155e12 100644
--- a/src/org/lineageos/lineageparts/applications/LongScreenSettings.java
+++ b/src/org/lineageos/lineageparts/applications/LongScreenSettings.java
@@ -1,5 +1,5 @@
 /*
- * SPDX-FileCopyrightText: 2018-2022 The LineageOS Project
+ * SPDX-FileCopyrightText: 2018-2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 package org.lineageos.lineageparts.applications;
@@ -23,6 +23,8 @@
 import android.widget.Switch;
 import android.widget.TextView;
 
+import androidx.annotation.NonNull;
+
 import com.android.settingslib.applications.ApplicationsState;
 
 import org.lineageos.internal.applications.LongScreen;
@@ -47,28 +49,23 @@
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
-        mApplicationsState = ApplicationsState.getInstance(getActivity().getApplication());
+        mApplicationsState = ApplicationsState.getInstance(requireActivity().getApplication());
         mSession = mApplicationsState.newSession(this);
         mSession.onResume();
-        mActivityFilter = new ActivityFilter(getActivity().getPackageManager());
+        mActivityFilter = new ActivityFilter(requireActivity().getPackageManager());
         mAllPackagesAdapter = new AllPackagesAdapter(getActivity());
 
         mLongScreen = new LongScreen(getContext());
     }
 
     @Override
-    public View onCreateView(LayoutInflater inflater, ViewGroup container,
+    public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
                              Bundle savedInstanceState) {
         return inflater.inflate(R.layout.long_screen_layout, container, false);
     }
 
     @Override
-    public void onDestroyView() {
-        super.onDestroyView();
-    }
-
-    @Override
-    public void onViewCreated(final View view, @Nullable Bundle savedInstanceState) {
+    public void onViewCreated(@NonNull final View view, @Nullable Bundle savedInstanceState) {
         super.onViewCreated(view, savedInstanceState);
 
         ListView userListView = view.findViewById(R.id.user_list_view);
@@ -126,8 +123,8 @@
     public void onRunningStateChanged(boolean running) {}
 
     private void handleAppEntries(List<ApplicationsState.AppEntry> entries) {
-        final ArrayList<String> sections = new ArrayList<String>();
-        final ArrayList<Integer> positions = new ArrayList<Integer>();
+        final ArrayList<String> sections = new ArrayList<>();
+        final ArrayList<Integer> positions = new ArrayList<>();
         final PackageManager pm = getPackageManager();
         String lastSectionIndex = null;
         int offset = 0;
@@ -304,7 +301,8 @@
         public void updateLauncherInfoList() {
             Intent i = new Intent(Intent.ACTION_MAIN);
             i.addCategory(Intent.CATEGORY_LAUNCHER);
-            List<ResolveInfo> resolveInfoList = mPackageManager.queryIntentActivities(i, 0);
+            List<ResolveInfo> resolveInfoList = mPackageManager.queryIntentActivities(i,
+                    PackageManager.ResolveInfoFlags.of(0));
 
             synchronized (mLauncherResolveInfoList) {
                 mLauncherResolveInfoList.clear();
diff --git a/src/org/lineageos/lineageparts/atv/KeyHandler.java b/src/org/lineageos/lineageparts/atv/KeyHandler.java
index 4e63536..170d906 100644
--- a/src/org/lineageos/lineageparts/atv/KeyHandler.java
+++ b/src/org/lineageos/lineageparts/atv/KeyHandler.java
@@ -1,5 +1,5 @@
 /*
- * SPDX-FileCopyrightText: 2021-2022 The LineageOS Project
+ * SPDX-FileCopyrightText: 2021-2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 
@@ -8,7 +8,6 @@
 import android.content.Context;
 import android.content.Intent;
 import android.content.pm.PackageManager;
-import android.os.SystemProperties;
 import android.provider.Settings;
 import android.util.Log;
 import android.view.KeyEvent;
diff --git a/src/org/lineageos/lineageparts/contributors/ContributorsCloudFragment.java b/src/org/lineageos/lineageparts/contributors/ContributorsCloudFragment.java
index a7dc943..32413cc 100644
--- a/src/org/lineageos/lineageparts/contributors/ContributorsCloudFragment.java
+++ b/src/org/lineageos/lineageparts/contributors/ContributorsCloudFragment.java
@@ -1,6 +1,6 @@
 /*
  * SPDX-FileCopyrightText: 2015 The CyanogenMod Project
- * SPDX-FileCopyrightText: 2017-2018,2020-2021 The LineageOS Project
+ * SPDX-FileCopyrightText: 2017-2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 
@@ -10,7 +10,6 @@
 import android.animation.Animator.AnimatorListener;
 import android.animation.AnimatorSet;
 import android.animation.ObjectAnimator;
-import android.app.Activity;
 import android.app.ActivityManager;
 import android.content.Context;
 import android.content.res.AssetManager;
@@ -22,7 +21,6 @@
 import android.graphics.Canvas;
 import android.graphics.Paint;
 import android.graphics.Rect;
-import android.os.AsyncTask;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.Looper;
@@ -39,14 +37,13 @@
 import android.view.ViewGroup;
 import android.view.WindowManager;
 import android.view.animation.LinearInterpolator;
-import android.widget.AdapterView;
-import android.widget.AdapterView.OnItemClickListener;
 import android.widget.ArrayAdapter;
 import android.widget.ImageView;
 import android.widget.ListView;
 import android.widget.SearchView;
 import android.widget.TextView;
 
+import androidx.annotation.NonNull;
 import androidx.appcompat.app.AlertDialog;
 import androidx.fragment.app.Fragment;
 
@@ -65,6 +62,8 @@
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Locale;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 
 public class ContributorsCloudFragment extends Fragment implements SearchView.OnQueryTextListener,
         SearchView.OnCloseListener, MenuItem.OnActionExpandListener, Searchable {
@@ -120,7 +119,7 @@
     private static class ContributorsAdapter extends ArrayAdapter<ContributorsDataHolder> {
 
         public ContributorsAdapter(Context context) {
-            super(context, R.id.contributor_name, new ArrayList<ContributorsDataHolder>());
+            super(context, R.id.contributor_name, new ArrayList<>());
         }
 
         @Override
@@ -147,7 +146,7 @@
         }
     }
 
-    private class ContributorCloudLoaderTask extends AsyncTask<Void, Void, Boolean> {
+    private class ContributorCloudLoaderTask {
         private ViewInfo mViewInfo;
         private final boolean mNotify;
         private final boolean mNavigate;
@@ -157,54 +156,49 @@
             mNavigate = navigate;
         }
 
-        @Override
-        protected void onPreExecute() {
+        public void execute() {
             mLoadingView.setAlpha(1f);
-        }
 
-        @Override
-        protected Boolean doInBackground(Void... params) {
-            try {
-                loadContributorsInfo(getActivity());
-                loadUserInfo(getActivity());
-                mViewInfo = generateViewInfo(getActivity(), mSelectedContributor);
-                if (mViewInfo != null && mViewInfo.mBitmap != null) {
-                    return Boolean.TRUE;
-                }
-
-            } catch (Exception ex) {
-                Log.e(TAG, "Failed to generate cloud bitmap", ex);
-            }
-            return Boolean.FALSE;
-        }
-
-        @Override
-        protected void onPostExecute(Boolean result) {
-            if (result) {
-                mImageView.setImageBitmap(mViewInfo.mBitmap);
-                mViewController.update();
-                if (mNotify) {
-                    if (mNavigate) {
-                        onLoadCloudDataSuccess(mViewInfo.mFocusX, mViewInfo.mFocusY);
-                    } else {
-                        onLoadCloudDataSuccess(-1, -1);
+            ExecutorService executor = Executors.newSingleThreadExecutor();
+            Handler handler = new Handler(Looper.getMainLooper());
+            executor.execute(() -> {
+                Boolean result = Boolean.FALSE;
+                try {
+                    loadContributorsInfo(getActivity());
+                    loadUserInfo(getActivity());
+                    mViewInfo = generateViewInfo(requireActivity(), mSelectedContributor);
+                    if (mViewInfo != null && mViewInfo.mBitmap != null) {
+                        result = Boolean.TRUE;
                     }
-                }
-            } else {
-                mImageView.setImageBitmap(null);
-                mViewController.update();
-                if (mViewInfo != null && mViewInfo.mBitmap != null) {
-                    mViewInfo.mBitmap.recycle();
-                }
-                if (mNotify) {
-                    onLoadCloudDataFailed();
-                }
-            }
-        }
 
-        @Override
-        protected void onCancelled() {
-            onLoadCloudDataFailed();
+                } catch (Exception ex) {
+                    Log.e(TAG, "Failed to generate cloud bitmap", ex);
+                }
+
+                final Boolean finalResult = result;
+                handler.post(() -> {
+                    if (finalResult) {
+                        mImageView.setImageBitmap(mViewInfo.mBitmap);
+                        mViewController.update();
+                        if (mNotify) {
+                            if (mNavigate) {
+                                onLoadCloudDataSuccess(mViewInfo.mFocusX, mViewInfo.mFocusY);
+                            } else {
+                                onLoadCloudDataSuccess(-1, -1);
+                            }
+                        }
+                    } else {
+                        mImageView.setImageBitmap(null);
+                        mViewController.update();
+                        if (mViewInfo != null && mViewInfo.mBitmap != null) {
+                            mViewInfo.mBitmap.recycle();
+                        }
+                        if (mNotify) {
+                            onLoadCloudDataFailed();
+                        }
+                    }
+                });
+            });
         }
     }
 
@@ -234,22 +228,22 @@
     }
 
     @Override
-    public void onSaveInstanceState(Bundle outState) {
+    public void onSaveInstanceState(@NonNull Bundle outState) {
         super.onSaveInstanceState(outState);
         outState.putInt(STATE_SELECTED_CONTRIBUTOR, mSelectedContributor);
     }
 
     @Override
-    public void onAttach(Activity activity) {
-        super.onAttach(activity);
-        activity.getWindow().setSoftInputMode(
+    public void onAttach(@NonNull Context context) {
+        super.onAttach(context);
+        requireActivity().getWindow().setSoftInputMode(
                 WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN
                 | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
         mHandler = new Handler(Looper.getMainLooper());
     }
 
     @Override
-    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+    public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
         super.onCreateOptionsMenu(menu, inflater);
 
         // Remove all previous menus
@@ -586,10 +580,6 @@
             try {
                 mDatabase = SQLiteDatabase.openDatabase(dbPath.getAbsolutePath(),
                         null, SQLiteDatabase.OPEN_READONLY);
-                if (mDatabase == null) {
-                    Log.e(TAG, "Cannot open cloud database: " + DB_NAME + ". db == null");
-                    return null;
-                }
                 return mDatabase;
 
             } catch (SQLException ex) {
@@ -753,7 +743,7 @@
     }
 
     private boolean hasLargeHeap() {
-        ActivityManager am = getActivity().getSystemService(ActivityManager.class);
+        ActivityManager am = requireActivity().getSystemService(ActivityManager.class);
         return am.getMemoryClass() >= 96;
     }
 
@@ -768,6 +758,7 @@
         OutputStream os;
         File databasePath = context.getDatabasePath(DB_NAME);
         try {
+            //noinspection ResultOfMethodCallIgnored
             databasePath.getParentFile().mkdir();
             is = context.getResources().getAssets().open(DB_NAME, AssetManager.ACCESS_BUFFER);
             os = new FileOutputStream(databasePath);
@@ -801,10 +792,6 @@
                     try {
                         db = SQLiteDatabase.openDatabase(dbPath.getAbsolutePath(),
                                 null, SQLiteDatabase.OPEN_READONLY);
-                        if (db == null) {
-                            Log.e(TAG, "Cannot open cloud database: " + DB_NAME + ". db == null");
-                            return null;
-                        }
                     } catch (Exception e) {
                         Log.e(TAG, e.getMessage(), e);
                         return null;
diff --git a/src/org/lineageos/lineageparts/contributors/ContributorsCloudViewController.java b/src/org/lineageos/lineageparts/contributors/ContributorsCloudViewController.java
index e7ca111..7e5f660 100644
--- a/src/org/lineageos/lineageparts/contributors/ContributorsCloudViewController.java
+++ b/src/org/lineageos/lineageparts/contributors/ContributorsCloudViewController.java
@@ -1,7 +1,7 @@
 /*
  * SPDX-FileCopyrightText: 2011, 2012 Chris Banes.
  * SPDX-FileCopyrightText: 2015 The CyanogenMod Project
- * SPDX-FileCopyrightText: 2022 The LineageOS Project
+ * SPDX-FileCopyrightText: 2022-2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 
@@ -886,22 +886,6 @@
     }
 
     /**
-     * Interface definition for a callback to be invoked when the internal Matrix has changed for
-     * this View.
-     *
-     * @author Chris Banes
-     */
-    public interface OnMatrixChangedListener {
-        /**
-         * Callback for when the Matrix displaying the Drawable has changed. This could be because
-         * the View's bounds have changed, or the user has zoomed.
-         *
-         * @param rect - Rectangle displaying the Drawable's new bounds.
-         */
-        void onMatrixChanged(RectF rect);
-    }
-
-    /**
      * Interface definition for a callback to be invoked when the Photo is tapped with a single
      * tap.
      *
diff --git a/src/org/lineageos/lineageparts/egg/octo/TaperedPathStroke.java b/src/org/lineageos/lineageparts/egg/octo/TaperedPathStroke.java
index 05ecfee..7748236 100644
--- a/src/org/lineageos/lineageparts/egg/octo/TaperedPathStroke.java
+++ b/src/org/lineageos/lineageparts/egg/octo/TaperedPathStroke.java
@@ -1,6 +1,6 @@
 /*
  * SPDX-FileCopyrightText: 2010 The Android Open Source Project
- * SPDX-FileCopyrightText: 2017-2022 The LineageOS Project
+ * SPDX-FileCopyrightText: 2017-2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 
@@ -13,9 +13,9 @@
 
 public class TaperedPathStroke {
     static float sMinStepPx = 4f;
-    static PathMeasure pm = new PathMeasure();
-    static float[] pos = {0, 0};
-    static float[] tan = {0, 0};
+    static final PathMeasure pm = new PathMeasure();
+    static final float[] pos = {0, 0};
+    static final float[] tan = {0, 0};
     public static void setMinStep(float px) {
         sMinStepPx = px;
     }
diff --git a/src/org/lineageos/lineageparts/gestures/KeyHandler.java b/src/org/lineageos/lineageparts/gestures/KeyHandler.java
index c2bac4c..fcc7f9d 100644
--- a/src/org/lineageos/lineageparts/gestures/KeyHandler.java
+++ b/src/org/lineageos/lineageparts/gestures/KeyHandler.java
@@ -261,8 +261,7 @@
     }
 
     private void launchBrowser() {
-        mGestureWakeLock.acquire(GESTURE_WAKELOCK_DURATION);
-        mPowerManager.wakeUp(SystemClock.uptimeMillis(), GESTURE_WAKEUP_REASON);
+        performWakeUp();
         final Intent intent = getLaunchableIntent(
                 new Intent(Intent.ACTION_VIEW, Uri.parse("http:")));
         startActivitySafely(intent);
@@ -270,16 +269,14 @@
     }
 
     private void launchDialer() {
-        mGestureWakeLock.acquire(GESTURE_WAKELOCK_DURATION);
-        mPowerManager.wakeUp(SystemClock.uptimeMillis(), GESTURE_WAKEUP_REASON);
+        performWakeUp();
         final Intent intent = new Intent(Intent.ACTION_DIAL, null);
         startActivitySafely(intent);
         doHapticFeedback();
     }
 
     private void launchEmail() {
-        mGestureWakeLock.acquire(GESTURE_WAKELOCK_DURATION);
-        mPowerManager.wakeUp(SystemClock.uptimeMillis(), GESTURE_WAKEUP_REASON);
+        performWakeUp();
         final Intent intent = getLaunchableIntent(
                 new Intent(Intent.ACTION_VIEW, Uri.parse("mailto:")));
         startActivitySafely(intent);
@@ -287,14 +284,19 @@
     }
 
     private void launchMessages() {
-        mGestureWakeLock.acquire(GESTURE_WAKELOCK_DURATION);
-        mPowerManager.wakeUp(SystemClock.uptimeMillis(), GESTURE_WAKEUP_REASON);
+        performWakeUp();
         final Intent intent = getLaunchableIntent(
                 new Intent(Intent.ACTION_VIEW, Uri.parse("sms:")));
         startActivitySafely(intent);
         doHapticFeedback();
     }
 
+    private void performWakeUp() {
+        mGestureWakeLock.acquire(GESTURE_WAKELOCK_DURATION);
+        mPowerManager.wakeUp(SystemClock.uptimeMillis(), PowerManager.WAKE_REASON_GESTURE,
+                GESTURE_WAKEUP_REASON);
+    }
+
     private void toggleFlashlight() {
         String rearCameraId = getRearCameraId();
         if (rearCameraId != null) {
@@ -412,7 +414,8 @@
 
     private Intent getLaunchableIntent(Intent intent) {
         PackageManager pm = mContext.getPackageManager();
-        List<ResolveInfo> resInfo = pm.queryIntentActivities(intent, 0);
+        List<ResolveInfo> resInfo = pm.queryIntentActivities(intent,
+                PackageManager.ResolveInfoFlags.of(0));
         if (resInfo.isEmpty()) {
             return null;
         }
diff --git a/src/org/lineageos/lineageparts/gestures/TouchscreenGestureSettings.java b/src/org/lineageos/lineageparts/gestures/TouchscreenGestureSettings.java
index 8f55e7a..20aa48a 100644
--- a/src/org/lineageos/lineageparts/gestures/TouchscreenGestureSettings.java
+++ b/src/org/lineageos/lineageparts/gestures/TouchscreenGestureSettings.java
@@ -1,6 +1,6 @@
 /*
  * SPDX-FileCopyrightText: 2016 The CyanogenMod project
- * SPDX-FileCopyrightText: 2017,2019-2022 The LineageOS Project
+ * SPDX-FileCopyrightText: 2017-2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 
@@ -54,7 +54,7 @@
     private void initTouchscreenGestures() {
         final LineageHardwareManager manager = LineageHardwareManager.getInstance(getContext());
         mTouchscreenGestures = manager.getTouchscreenGestures();
-        final int[] actions = getDefaultGestureActions(getContext(), mTouchscreenGestures);
+        final int[] actions = getDefaultGestureActions(requireContext(), mTouchscreenGestures);
         for (final TouchscreenGesture gesture : mTouchscreenGestures) {
             getPreferenceScreen().addPreference(new TouchscreenGesturePreference(
                     getContext(), gesture, actions[gesture.id]));
diff --git a/src/org/lineageos/lineageparts/hardware/DisplayRotation.java b/src/org/lineageos/lineageparts/hardware/DisplayRotation.java
index 770a719..5db0ff7 100644
--- a/src/org/lineageos/lineageparts/hardware/DisplayRotation.java
+++ b/src/org/lineageos/lineageparts/hardware/DisplayRotation.java
@@ -1,12 +1,11 @@
 /*
  * SPDX-FileCopyrightText: 2016 The CyanogenMod Project
- * SPDX-FileCopyrightText: 2017-2022 The LineageOS Project
+ * SPDX-FileCopyrightText: 2017-2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 
 package org.lineageos.lineageparts.hardware;
 
-import android.content.Context;
 import android.net.Uri;
 import android.os.Bundle;
 import android.os.UserHandle;
@@ -29,7 +28,6 @@
     private static final String TAG = "DisplayRotation";
 
     public static final String KEY_ACCELEROMETER = "accelerometer";
-    private static final String KEY_LOCKSCREEN_ROTATION = "lockscreen_rotation";
     private static final String ROTATION_0_PREF = "display_rotation_0";
     private static final String ROTATION_90_PREF = "display_rotation_90";
     private static final String ROTATION_180_PREF = "display_rotation_180";
@@ -88,7 +86,7 @@
     }
 
     private void updateAccelerometerRotationSwitch() {
-        mAccelerometer.setChecked(!RotationPolicy.isRotationLocked(getActivity()));
+        mAccelerometer.setChecked(!RotationPolicy.isRotationLocked(requireActivity()));
     }
 
     private int getRotationBitmask() {
@@ -119,7 +117,7 @@
                 mode |= ROTATION_0_MODE;
                 mRotation0Pref.setChecked(true);
             }
-            Settings.System.putIntForUser(getActivity().getContentResolver(),
+            Settings.System.putIntForUser(requireActivity().getContentResolver(),
                     Settings.System.ACCELEROMETER_ROTATION_ANGLES, mode, UserHandle.USER_CURRENT);
             return true;
         }
@@ -129,7 +127,8 @@
 
     @Override
     public void onSwitchChanged(Switch switchView, boolean isChecked) {
-        RotationPolicy.setRotationLockForAccessibility(getActivity(), !mAccelerometer.isChecked());
+        RotationPolicy.setRotationLockForAccessibility(requireActivity(),
+                !mAccelerometer.isChecked());
     }
 
     public static final SummaryProvider SUMMARY_PROVIDER = (context, key) -> {
diff --git a/src/org/lineageos/lineageparts/health/ChargingControlSettings.java b/src/org/lineageos/lineageparts/health/ChargingControlSettings.java
index 12234de..9e9c6e6 100644
--- a/src/org/lineageos/lineageparts/health/ChargingControlSettings.java
+++ b/src/org/lineageos/lineageparts/health/ChargingControlSettings.java
@@ -63,7 +63,7 @@
         final Resources res = getResources();
 
         addPreferencesFromResource(R.xml.charging_control_settings);
-        getActivity().getActionBar().setTitle(R.string.charging_control_title);
+        requireActivity().getActionBar().setTitle(R.string.charging_control_title);
 
         mHealthInterface = HealthInterface.getInstance(getActivity());
 
diff --git a/src/org/lineageos/lineageparts/health/TimePreference.java b/src/org/lineageos/lineageparts/health/TimePreference.java
index 896970d..7272466 100644
--- a/src/org/lineageos/lineageparts/health/TimePreference.java
+++ b/src/org/lineageos/lineageparts/health/TimePreference.java
@@ -31,7 +31,7 @@
     private TimePicker mTimePicker;
     private LocalTime mLocalTime;
 
-    protected HealthInterface mHealthInterface;
+    protected final HealthInterface mHealthInterface;
 
     public TimePreference(final Context context, final AttributeSet attrs) {
         super(context, attrs);
diff --git a/src/org/lineageos/lineageparts/input/ButtonBacklightBrightness.java b/src/org/lineageos/lineageparts/input/ButtonBacklightBrightness.java
index 94dea72..8c080b8 100644
--- a/src/org/lineageos/lineageparts/input/ButtonBacklightBrightness.java
+++ b/src/org/lineageos/lineageparts/input/ButtonBacklightBrightness.java
@@ -1,6 +1,6 @@
 /*
  * SPDX-FileCopyrightText: 2013 The CyanogenMod Project
- * SPDX-FileCopyrightText: 2017-2022 The LineageOS Project
+ * SPDX-FileCopyrightText: 2017-2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 
@@ -323,13 +323,10 @@
             dest.writeFloat(keyboard);
         }
 
-        public static final Parcelable.Creator<SavedState> CREATOR =
-                new Parcelable.Creator<SavedState>() {
-
+        public static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.Creator<>() {
             public SavedState createFromParcel(Parcel in) {
                 return new SavedState(in);
             }
-
             public SavedState[] newArray(int size) {
                 return new SavedState[size];
             }
diff --git a/src/org/lineageos/lineageparts/input/ButtonSettings.java b/src/org/lineageos/lineageparts/input/ButtonSettings.java
index 2a80a18..1a54349 100644
--- a/src/org/lineageos/lineageparts/input/ButtonSettings.java
+++ b/src/org/lineageos/lineageparts/input/ButtonSettings.java
@@ -1,6 +1,6 @@
 /*
  * SPDX-FileCopyrightText: 2016 The CyanogenMod project
- * SPDX-FileCopyrightText: 2017-2022 The LineageOS project
+ * SPDX-FileCopyrightText: 2017-2023 The LineageOS project
  * SPDX-License-Identifier: Apache-2.0
  */
 
@@ -25,7 +25,6 @@
 import android.util.ArraySet;
 import android.util.Log;
 import android.view.Display;
-import android.view.DisplayInfo;
 import android.view.IWindowManager;
 import android.view.WindowManagerGlobal;
 
@@ -44,7 +43,6 @@
 import org.lineageos.lineageparts.search.Searchable;
 import org.lineageos.lineageparts.utils.DeviceUtils;
 import org.lineageos.lineageparts.utils.TelephonyUtils;
-import org.lineageos.internal.util.ScreenType;
 
 import static org.lineageos.internal.util.DeviceKeysConstants.*;
 
@@ -112,7 +110,6 @@
     private static final String CATEGORY_APPSWITCH = "app_switch_key";
     private static final String CATEGORY_CAMERA = "camera_key";
     private static final String CATEGORY_VOLUME = "volume_keys";
-    private static final String CATEGORY_BACKLIGHT = "key_backlight";
     private static final String CATEGORY_NAVBAR = "navigation_bar_category";
     private static final String CATEGORY_EXTRAS = "extras_category";
 
@@ -159,7 +156,7 @@
         addPreferencesFromResource(R.xml.button_settings);
 
         final Resources res = getResources();
-        final ContentResolver resolver = getActivity().getContentResolver();
+        final ContentResolver resolver = requireActivity().getContentResolver();
         final PreferenceScreen prefScreen = getPreferenceScreen();
 
         final boolean hasPowerKey = DeviceUtils.hasPowerKey();
@@ -268,11 +265,11 @@
         updateDisableNavkeysCategories(mDisableNavigationKeys.isChecked(), /* force */ true);
 
         if (hasPowerKey) {
-            if (!TelephonyUtils.isVoiceCapable(getActivity())) {
+            if (!TelephonyUtils.isVoiceCapable(requireActivity())) {
                 powerCategory.removePreference(mPowerEndCall);
                 mPowerEndCall = null;
             }
-            if (!DeviceUtils.deviceSupportsFlashLight(getActivity())) {
+            if (!DeviceUtils.deviceSupportsFlashLight(requireActivity())) {
                 powerCategory.removePreference(torchLongPressPowerGesture);
                 powerCategory.removePreference(mTorchLongPressPowerTimeout);
             }
@@ -286,7 +283,7 @@
                 homeCategory.removePreference(findPreference(KEY_HOME_WAKE_SCREEN));
             }
 
-            if (!TelephonyUtils.isVoiceCapable(getActivity())) {
+            if (!TelephonyUtils.isVoiceCapable(requireActivity())) {
                 homeCategory.removePreference(mHomeAnswerCall);
                 mHomeAnswerCall = null;
             }
@@ -394,7 +391,7 @@
                 volumeCategory.removePreference(findPreference(KEY_VOLUME_WAKE_SCREEN));
             }
 
-            if (!TelephonyUtils.isVoiceCapable(getActivity())) {
+            if (!TelephonyUtils.isVoiceCapable(requireActivity())) {
                 volumeCategory.removePreference(findPreference(KEY_VOLUME_ANSWER_CALL));
             }
 
@@ -430,7 +427,7 @@
         }
 
         final ButtonBacklightBrightness backlight = findPreference(KEY_BUTTON_BACKLIGHT);
-        if (!DeviceUtils.hasButtonBacklightSupport(getActivity())
+        if (!DeviceUtils.hasButtonBacklightSupport(requireActivity())
                 && !DeviceUtils.hasKeyboardBacklightSupport(getActivity())) {
             prefScreen.removePreference(backlight);
         }
@@ -464,13 +461,13 @@
 
         mEnableTaskbar = findPreference(KEY_ENABLE_TASKBAR);
         if (mEnableTaskbar != null) {
-            if (!isLargeScreen(getContext()) || !hasNavigationBar()) {
+            if (!isLargeScreen(requireContext()) || !hasNavigationBar()) {
                 mNavigationPreferencesCat.removePreference(mEnableTaskbar);
             } else {
                 mEnableTaskbar.setOnPreferenceChangeListener(this);
                 mEnableTaskbar.setChecked(LineageSettings.System.getInt(resolver,
                         LineageSettings.System.ENABLE_TASKBAR,
-                        isLargeScreen(getContext()) ? 1 : 0) == 1);
+                        isLargeScreen(requireContext()) ? 1 : 0) == 1);
                 toggleTaskBarDependencies(mEnableTaskbar.isChecked());
             }
         }
@@ -589,14 +586,14 @@
         String value = (String) newValue;
         int index = pref.findIndexOfValue(value);
         pref.setSummary(pref.getEntries()[index]);
-        LineageSettings.System.putInt(getContentResolver(), setting, Integer.valueOf(value));
+        LineageSettings.System.putInt(getContentResolver(), setting, Integer.parseInt(value));
     }
 
     private void handleSystemListChange(ListPreference pref, Object newValue, String setting) {
         String value = (String) newValue;
         int index = pref.findIndexOfValue(value);
         pref.setSummary(pref.getEntries()[index]);
-        Settings.System.putInt(getContentResolver(), setting, Integer.valueOf(value));
+        Settings.System.putInt(getContentResolver(), setting, Integer.parseInt(value));
     }
 
     @Override
@@ -658,7 +655,7 @@
             return true;
         } else if (preference == mEnableTaskbar) {
             toggleTaskBarDependencies((Boolean) newValue);
-            if ((Boolean) newValue && is2ButtonNavigationEnabled(getContext())) {
+            if ((Boolean) newValue && is2ButtonNavigationEnabled(requireContext())) {
                 // Let's switch to gestural mode if user previously had 2 buttons enabled.
                 setButtonNavigationMode(NAV_BAR_MODE_GESTURAL_OVERLAY);
             }
@@ -705,7 +702,8 @@
     }
 
     private void updateDisableNavkeysOption() {
-        boolean enabled = LineageSettings.System.getIntForUser(getActivity().getContentResolver(),
+        boolean enabled = LineageSettings.System.getIntForUser(
+                requireActivity().getContentResolver(),
                 LineageSettings.System.FORCE_SHOW_NAVBAR, 0, UserHandle.USER_CURRENT) != 0;
 
         mDisableNavigationKeys.setChecked(enabled);
@@ -738,7 +736,7 @@
         /* Toggle hardkey control availability depending on navbar state */
         if (mNavigationPreferencesCat != null) {
             if (force || navbarEnabled) {
-                if (DeviceUtils.isEdgeToEdgeEnabled(getContext())) {
+                if (DeviceUtils.isEdgeToEdgeEnabled(requireContext())) {
                     mNavigationPreferencesCat.addPreference(mEdgeLongSwipeAction);
 
                     mNavigationPreferencesCat.removePreference(mNavigationArrowKeys);
@@ -847,10 +845,10 @@
                 /* Disable the re-orient functionality */
                 value = 0;
             }
-            LineageSettings.System.putInt(getActivity().getContentResolver(),
+            LineageSettings.System.putInt(requireActivity().getContentResolver(),
                     LineageSettings.System.SWAP_VOLUME_KEYS_ON_ROTATION, value);
         } else if (preference == mVolumePanelOnLeft) {
-            LineageSettings.Secure.putIntForUser(getActivity().getContentResolver(),
+            LineageSettings.Secure.putIntForUser(requireActivity().getContentResolver(),
                     LineageSettings.Secure.VOLUME_PANEL_ON_LEFT,
                     mVolumePanelOnLeft.isChecked() ? 1 : 0, UserHandle.USER_CURRENT);
             return true;
@@ -860,16 +858,13 @@
             if (!mDisableNavigationKeys.isChecked()) {
                 setButtonNavigationMode(NAV_BAR_MODE_3BUTTON_OVERLAY);
             }
-            writeDisableNavkeysOption(getActivity(), mDisableNavigationKeys.isChecked());
+            writeDisableNavkeysOption(requireActivity(), mDisableNavigationKeys.isChecked());
             updateDisableNavkeysOption();
             updateDisableNavkeysCategories(true, false);
-            mHandler.postDelayed(new Runnable() {
-                @Override
-                public void run() {
-                    mDisableNavigationKeys.setEnabled(true);
-                    mNavigationPreferencesCat.setEnabled(mDisableNavigationKeys.isChecked());
-                    updateDisableNavkeysCategories(mDisableNavigationKeys.isChecked(), false);
-                }
+            mHandler.postDelayed(() -> {
+                mDisableNavigationKeys.setEnabled(true);
+                mNavigationPreferencesCat.setEnabled(mDisableNavigationKeys.isChecked());
+                updateDisableNavkeysCategories(mDisableNavigationKeys.isChecked(), false);
             }, 1000);
         } else if (preference == mPowerEndCall) {
             handleTogglePowerButtonEndsCallPreferenceClick();
@@ -901,7 +896,7 @@
 
         @Override
         public Set<String> getNonIndexableKeys(Context context) {
-            final Set<String> result = new ArraySet<String>();
+            final Set<String> result = new ArraySet<>();
 
             if (!TelephonyUtils.isVoiceCapable(context)) {
                 result.add(KEY_POWER_END_CALL);
diff --git a/src/org/lineageos/lineageparts/input/PowerMenuActions.java b/src/org/lineageos/lineageparts/input/PowerMenuActions.java
index 2e5eec1..b725944 100644
--- a/src/org/lineageos/lineageparts/input/PowerMenuActions.java
+++ b/src/org/lineageos/lineageparts/input/PowerMenuActions.java
@@ -1,6 +1,6 @@
 /*
  * SPDX-FileCopyrightText: 2014-2015 The CyanogenMod Project
- * SPDX-FileCopyrightText: 2017-2022 The LineageOS Project
+ * SPDX-FileCopyrightText: 2017-2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 
@@ -20,7 +20,6 @@
 import androidx.preference.PreferenceCategory;
 
 import com.android.internal.util.EmergencyAffordanceManager;
-import com.android.internal.widget.LockPatternUtils;
 import com.android.settingslib.applications.ServiceListing;
 
 import org.lineageos.internal.util.PowerMenuConstants;
@@ -31,7 +30,6 @@
 import java.util.List;
 
 import lineageos.app.LineageGlobalActions;
-import lineageos.providers.LineageSettings;
 
 import static org.lineageos.internal.util.PowerMenuConstants.*;
 
@@ -62,8 +60,8 @@
         super.onCreate(savedInstanceState);
 
         addPreferencesFromResource(R.xml.power_menu_settings);
-        getActivity().setTitle(R.string.power_menu_title);
-        mContext = getActivity().getApplicationContext();
+        requireActivity().setTitle(R.string.power_menu_title);
+        mContext = requireActivity().getApplicationContext();
         mUserManager = UserManager.get(mContext);
         mLineageGlobalActions = LineageGlobalActions.getInstance(mContext);
         mEmergencyAffordanceManager = new EmergencyAffordanceManager(mContext);
@@ -86,7 +84,7 @@
             }
         }
 
-        if (!TelephonyUtils.isVoiceCapable(getActivity())) {
+        if (!TelephonyUtils.isVoiceCapable(requireActivity())) {
             mPowerMenuItemsCategory.removePreference(mEmergencyPref);
             mEmergencyPref = null;
         }
diff --git a/src/org/lineageos/lineageparts/lineagestats/PreviewData.java b/src/org/lineageos/lineageparts/lineagestats/PreviewData.java
index fe795c0..32e4413 100644
--- a/src/org/lineageos/lineageparts/lineagestats/PreviewData.java
+++ b/src/org/lineageos/lineageparts/lineagestats/PreviewData.java
@@ -1,6 +1,6 @@
 /*
  * SPDX-FileCopyrightText: 2012 The CyanogenMod Project
- * SPDX-FileCopyrightText: 2017 The LineageOS Project
+ * SPDX-FileCopyrightText: 2017-2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 
@@ -28,7 +28,7 @@
         addPreferencesFromResource(R.xml.preview_data);
 
         final PreferenceScreen prefSet = getPreferenceScreen();
-        final Context context = getActivity();
+        final Context context = requireActivity();
 
         prefSet.findPreference(UNIQUE_ID).setSummary(Utilities.getUniqueID(context));
         prefSet.findPreference(DEVICE).setSummary(Utilities.getDevice());
diff --git a/src/org/lineageos/lineageparts/lineagestats/ReportingServiceManager.java b/src/org/lineageos/lineageparts/lineagestats/ReportingServiceManager.java
index 9e3013c..5698953 100644
--- a/src/org/lineageos/lineageparts/lineagestats/ReportingServiceManager.java
+++ b/src/org/lineageos/lineageparts/lineagestats/ReportingServiceManager.java
@@ -1,6 +1,6 @@
 /*
  * SPDX-FileCopyrightText: 2012 The CyanogenMod Project
- * SPDX-FileCopyrightText: 2017,2020-2021 The LineageOS Project
+ * SPDX-FileCopyrightText: 2017-2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 
@@ -84,7 +84,7 @@
 
         Intent intent = new Intent();
         intent.setClass(context, ReportingService.class);
-        context.startServiceAsUser(intent, UserHandle.OWNER);
+        context.startServiceAsUser(intent, UserHandle.SYSTEM);
     }
 
     private static void migrate(Context context, SharedPreferences prefs) {
diff --git a/src/org/lineageos/lineageparts/lineagestats/StatsUploadJobService.java b/src/org/lineageos/lineageparts/lineagestats/StatsUploadJobService.java
index 9c6defe..e19c2e5 100644
--- a/src/org/lineageos/lineageparts/lineagestats/StatsUploadJobService.java
+++ b/src/org/lineageos/lineageparts/lineagestats/StatsUploadJobService.java
@@ -1,6 +1,6 @@
 /*
  * SPDX-FileCopyrightText: 2015 The CyanogenMod Project
- * SPDX-FileCopyrightText: 2017-2022 The LineageOS project
+ * SPDX-FileCopyrightText: 2017-2023 The LineageOS project
  * SPDX-License-Identifier: Apache-2.0
  */
 
@@ -9,7 +9,8 @@
 import android.app.job.JobParameters;
 import android.app.job.JobService;
 import android.net.Uri;
-import android.os.AsyncTask;
+import android.os.Handler;
+import android.os.Looper;
 import android.os.PersistableBundle;
 import android.util.ArrayMap;
 import android.util.Log;
@@ -28,6 +29,8 @@
 import java.nio.charset.StandardCharsets;
 import java.util.Collections;
 import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 
 public class StatsUploadJobService extends JobService {
 
@@ -46,7 +49,7 @@
     public static final String KEY_TIMESTAMP = "timeStamp";
 
     private final Map<JobParameters, StatsUploadTask> mCurrentJobs
-            = Collections.synchronizedMap(new ArrayMap<JobParameters, StatsUploadTask>());
+            = Collections.synchronizedMap(new ArrayMap<>());
 
     @Override
     public boolean onStartJob(JobParameters jobParameters) {
@@ -59,7 +62,7 @@
 
         final StatsUploadTask uploadTask = new StatsUploadTask(jobParameters);
         mCurrentJobs.put(jobParameters, uploadTask);
-        uploadTask.execute((Void) null);
+        uploadTask.execute();
         return true;
     }
 
@@ -73,59 +76,67 @@
 
         if (cancelledJob != null) {
             // cancel the ongoing background task
-            cancelledJob.cancel(true);
+            cancelledJob.cancel();
             return true; // reschedule
         }
 
         return false;
     }
 
-    private class StatsUploadTask extends AsyncTask<Void, Void, Boolean> {
+    private class StatsUploadTask {
 
         private final JobParameters mJobParams;
+        private boolean mCancelled;
 
         public StatsUploadTask(JobParameters jobParams) {
             this.mJobParams = jobParams;
         }
 
-        @Override
-        protected Boolean doInBackground(Void... params) {
+        public void execute() {
+            ExecutorService executor = Executors.newSingleThreadExecutor();
+            Handler handler = new Handler(Looper.getMainLooper());
+            executor.execute(() -> {
+                PersistableBundle extras = mJobParams.getExtras();
 
-            PersistableBundle extras = mJobParams.getExtras();
+                String deviceId = extras.getString(KEY_UNIQUE_ID);
+                String deviceName = extras.getString(KEY_DEVICE_NAME);
+                String deviceVersion = extras.getString(KEY_VERSION);
+                String deviceCountry = extras.getString(KEY_COUNTRY);
+                String deviceCarrier = extras.getString(KEY_CARRIER);
+                String deviceCarrierId = extras.getString(KEY_CARRIER_ID);
 
-            String deviceId = extras.getString(KEY_UNIQUE_ID);
-            String deviceName = extras.getString(KEY_DEVICE_NAME);
-            String deviceVersion = extras.getString(KEY_VERSION);
-            String deviceCountry = extras.getString(KEY_COUNTRY);
-            String deviceCarrier = extras.getString(KEY_CARRIER);
-            String deviceCarrierId = extras.getString(KEY_CARRIER_ID);
-
-            boolean success = false;
-            int jobType = extras.getInt(KEY_JOB_TYPE, -1);
-            if (!isCancelled()) {
-                switch (jobType) {
-                    case JOB_TYPE_LINEAGEORG:
-                        try {
-                            JSONObject json = buildStatsRequest(deviceId, deviceName,
-                                    deviceVersion, deviceCountry, deviceCarrier, deviceCarrierId);
-                            success = uploadToLineage(json);
-                        } catch (IOException | JSONException e) {
-                            Log.e(TAG, "Could not upload stats checkin to community server", e);
-                            success = false;
-                        }
-                        break;
+                boolean success = false;
+                int jobType = extras.getInt(KEY_JOB_TYPE, -1);
+                if (!mCancelled) {
+                    switch (jobType) {
+                        case JOB_TYPE_LINEAGEORG:
+                            try {
+                                JSONObject json = buildStatsRequest(deviceId, deviceName,
+                                        deviceVersion, deviceCountry, deviceCarrier,
+                                        deviceCarrierId);
+                                success = uploadToLineage(json);
+                            } catch (IOException | JSONException e) {
+                                Log.e(TAG, "Could not upload stats checkin to community server", e);
+                            }
+                            break;
+                    }
                 }
-            }
-            if (DEBUG)
-                Log.d(TAG, "job id " + mJobParams.getJobId() + ", has finished with success="
-                        + success);
-            return success;
+                if (DEBUG)
+                    Log.d(TAG, "job id " + mJobParams.getJobId() + ", has finished with success="
+                            + success);
+
+                if (!mCancelled) {
+                    final boolean finalResult = success;
+                    handler.post(() -> {
+                        mCurrentJobs.remove(mJobParams);
+                        jobFinished(mJobParams, !finalResult);
+                    });
+                }
+            });
         }
 
-        @Override
-        protected void onPostExecute(Boolean success) {
-            mCurrentJobs.remove(mJobParams);
-            jobFinished(mJobParams, !success);
+        public void cancel() {
+            mCancelled = true;
         }
     }
 
diff --git a/src/org/lineageos/lineageparts/livedisplay/DisplayColor.java b/src/org/lineageos/lineageparts/livedisplay/DisplayColor.java
index 239b479..d1367fa 100644
--- a/src/org/lineageos/lineageparts/livedisplay/DisplayColor.java
+++ b/src/org/lineageos/lineageparts/livedisplay/DisplayColor.java
@@ -1,6 +1,6 @@
 /*
  * SPDX-FileCopyrightText: 2013-2015 The CyanogenMod Project
- * SPDX-FileCopyrightText: 2021-2022 The LineageOS Project
+ * SPDX-FileCopyrightText: 2021-2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 
@@ -166,9 +166,7 @@
             dest.writeFloatArray(currentColors);
         }
 
-        public static final Parcelable.Creator<SavedState> CREATOR =
-                new Parcelable.Creator<SavedState>() {
-
+        public static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.Creator<>() {
             public SavedState createFromParcel(Parcel in) {
                 return new SavedState(in);
             }
diff --git a/src/org/lineageos/lineageparts/livedisplay/DisplayTemperature.java b/src/org/lineageos/lineageparts/livedisplay/DisplayTemperature.java
index 3b792c6..bb98c17 100644
--- a/src/org/lineageos/lineageparts/livedisplay/DisplayTemperature.java
+++ b/src/org/lineageos/lineageparts/livedisplay/DisplayTemperature.java
@@ -1,6 +1,6 @@
 /*
  * SPDX-FileCopyrightText: 2015 The CyanogenMod Project
- * SPDX-FileCopyrightText: 2021-2022 The LineageOS Project
+ * SPDX-FileCopyrightText: 2021-2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 
@@ -168,9 +168,7 @@
             dest.writeInt(currentNightTemperature);
         }
 
-        public static final Parcelable.Creator<SavedState> CREATOR =
-                new Parcelable.Creator<SavedState>() {
-
+        public static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.Creator<>() {
             public SavedState createFromParcel(Parcel in) {
                 return new SavedState(in);
             }
diff --git a/src/org/lineageos/lineageparts/livedisplay/LiveDisplaySettings.java b/src/org/lineageos/lineageparts/livedisplay/LiveDisplaySettings.java
index 6105297..5dc6899 100644
--- a/src/org/lineageos/lineageparts/livedisplay/LiveDisplaySettings.java
+++ b/src/org/lineageos/lineageparts/livedisplay/LiveDisplaySettings.java
@@ -1,6 +1,6 @@
 /*
  * SPDX-FileCopyrightText: 2015 The CyanogenMod Project
- * SPDX-FileCopyrightText: 2017-2022 The LineageOS Project
+ * SPDX-FileCopyrightText: 2017-2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 package org.lineageos.lineageparts.livedisplay;
@@ -113,7 +113,7 @@
         super.onCreate(savedInstanceState);
         final Resources res = getResources();
         final boolean isNightDisplayAvailable =
-                ColorDisplayManager.isNightDisplayAvailable(getContext());
+                ColorDisplayManager.isNightDisplayAvailable(requireContext());
 
         mHardware = LineageHardwareManager.getInstance(getActivity());
         mLiveDisplayManager = LiveDisplayManager.getInstance(getActivity());
@@ -361,9 +361,9 @@
     @Override
     public boolean onPreferenceChange(Preference preference, Object objValue) {
         if (preference == mLiveDisplay) {
-            mLiveDisplayManager.setMode(Integer.valueOf((String)objValue));
+            mLiveDisplayManager.setMode(Integer.parseInt((String)objValue));
         } else if (preference == mColorProfile) {
-            int id = Integer.valueOf((String)objValue);
+            int id = Integer.parseInt((String)objValue);
             Log.i("LiveDisplay", "Setting mode: " + id);
             for (DisplayMode mode : mHardware.getDisplayModes()) {
                 if (mode.id == id) {
@@ -392,7 +392,7 @@
         @Override
         public Set<String> getNonIndexableKeys(Context context) {
             final LiveDisplayConfig config = LiveDisplayManager.getInstance(context).getConfig();
-            final Set<String> result = new ArraySet<String>();
+            final Set<String> result = new ArraySet<>();
 
             if (!config.hasFeature(FEATURE_DISPLAY_MODES)) {
                 result.add(KEY_LIVE_DISPLAY_COLOR_PROFILE);
diff --git a/src/org/lineageos/lineageparts/livedisplay/PictureAdjustment.java b/src/org/lineageos/lineageparts/livedisplay/PictureAdjustment.java
index 7867539..b4b6f13 100644
--- a/src/org/lineageos/lineageparts/livedisplay/PictureAdjustment.java
+++ b/src/org/lineageos/lineageparts/livedisplay/PictureAdjustment.java
@@ -1,6 +1,6 @@
 /*
  * SPDX-FileCopyrightText: 2016 The CyanogenMod Project
- * SPDX-FileCopyrightText: 2021-2022 The LineageOS Project
+ * SPDX-FileCopyrightText: 2021-2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 
@@ -174,9 +174,7 @@
             dest.writeFloatArray(currentAdj);
         }
 
-        public static final Creator<SavedState> CREATOR =
-                new Creator<PictureAdjustment.SavedState>() {
-
+        public static final Creator<SavedState> CREATOR = new Creator<>() {
             public PictureAdjustment.SavedState createFromParcel(Parcel in) {
                 return new PictureAdjustment.SavedState(in);
             }
diff --git a/src/org/lineageos/lineageparts/notificationlight/BatteryLightSettings.java b/src/org/lineageos/lineageparts/notificationlight/BatteryLightSettings.java
index 7a035b7..84f674b 100644
--- a/src/org/lineageos/lineageparts/notificationlight/BatteryLightSettings.java
+++ b/src/org/lineageos/lineageparts/notificationlight/BatteryLightSettings.java
@@ -69,7 +69,7 @@
     public void onActivityCreated(Bundle savedInstanceState) {
         super.onActivityCreated(savedInstanceState);
 
-        final Context context = getContext();
+        final Context context = requireContext();
         final Resources res = getResources();
 
         // Collect battery led capabilities.
@@ -84,7 +84,7 @@
                 LightsCapabilities.LIGHTS_SEGMENTED_BATTERY_LED);
 
         addPreferencesFromResource(R.xml.battery_light_settings);
-        getActivity().getActionBar().setTitle(R.string.battery_light_title);
+        requireActivity().getActionBar().setTitle(R.string.battery_light_title);
 
         PreferenceScreen prefSet = getPreferenceScreen();
 
@@ -156,8 +156,7 @@
     }
 
     private void refreshColors() {
-        ContentResolver resolver = getActivity().getContentResolver();
-        Resources res = getResources();
+        ContentResolver resolver = requireActivity().getContentResolver();
 
         if (mLowColorPref != null) {
             int lowColor = LineageSettings.System.getInt(resolver,
@@ -195,18 +194,21 @@
      * @param key of the specific setting to update
      */
     protected void updateValues(String key, Integer color) {
-        ContentResolver resolver = getActivity().getContentResolver();
-
-        if (key.equals(LOW_COLOR_PREF)) {
-            LineageSettings.System.putInt(resolver,
-                    LineageSettings.System.BATTERY_LIGHT_LOW_COLOR, color);
-        } else if (key.equals(MEDIUM_COLOR_PREF)) {
-            LineageSettings.System.putInt(resolver,
-                    LineageSettings.System.BATTERY_LIGHT_MEDIUM_COLOR, color);
-        } else if (key.equals(FULL_COLOR_PREF)) {
-            LineageSettings.System.putInt(resolver,
-                    LineageSettings.System.BATTERY_LIGHT_FULL_COLOR, color);
-            updateBrightnessPrefColor(color);
+        ContentResolver resolver = requireActivity().getContentResolver();
+        switch (key) {
+            case LOW_COLOR_PREF:
+                LineageSettings.System.putInt(resolver,
+                        LineageSettings.System.BATTERY_LIGHT_LOW_COLOR, color);
+                break;
+            case MEDIUM_COLOR_PREF:
+                LineageSettings.System.putInt(resolver,
+                        LineageSettings.System.BATTERY_LIGHT_MEDIUM_COLOR, color);
+                break;
+            case FULL_COLOR_PREF:
+                LineageSettings.System.putInt(resolver,
+                        LineageSettings.System.BATTERY_LIGHT_FULL_COLOR, color);
+                updateBrightnessPrefColor(color);
+                break;
         }
     }
 
@@ -232,7 +234,7 @@
     }
 
     protected void resetColors() {
-        ContentResolver resolver = getActivity().getContentResolver();
+        ContentResolver resolver = requireActivity().getContentResolver();
 
         // Reset to the framework default colors
         LineageSettings.System.putInt(resolver, LineageSettings.System.BATTERY_LIGHT_LOW_COLOR,
diff --git a/src/org/lineageos/lineageparts/notificationlight/BrightnessPreference.java b/src/org/lineageos/lineageparts/notificationlight/BrightnessPreference.java
index 96fdc53..7630c43 100644
--- a/src/org/lineageos/lineageparts/notificationlight/BrightnessPreference.java
+++ b/src/org/lineageos/lineageparts/notificationlight/BrightnessPreference.java
@@ -1,5 +1,5 @@
 /*
- * SPDX-FileCopyrightText: 2017,2019-2022 The LineageOS Project
+ * SPDX-FileCopyrightText: 2017-2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 
@@ -21,12 +21,8 @@
 import android.widget.TextView;
 
 import androidx.appcompat.app.AlertDialog;
-import androidx.preference.Preference;
 import androidx.preference.PreferenceViewHolder;
 
-import lineageos.providers.LineageSettings;
-
-import org.lineageos.internal.notification.LightsCapabilities;
 import org.lineageos.internal.notification.LineageNotification;
 import org.lineageos.lineageparts.widget.CustomDialogPreference;
 import org.lineageos.lineageparts.R;
diff --git a/src/org/lineageos/lineageparts/notificationlight/ColorPickerView.java b/src/org/lineageos/lineageparts/notificationlight/ColorPickerView.java
index 3044f24..582b97f 100644
--- a/src/org/lineageos/lineageparts/notificationlight/ColorPickerView.java
+++ b/src/org/lineageos/lineageparts/notificationlight/ColorPickerView.java
@@ -1,7 +1,7 @@
 /*
  * SPDX-FileCopyrightText: 2010 Daniel Nilsson
  * SPDX-FileCopyrightText: 2012 The CyanogenMod Project
- * SPDX-FileCopyrightText: 2022 The LineageOS Project
+ * SPDX-FileCopyrightText: 2022-2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 
@@ -452,9 +452,7 @@
                     update = true;
                     break;
                 case PANEL_ALPHA:
-                    if (!mShowAlphaPanel || mAlphaRect == null) {
-                        update = false;
-                    } else {
+                    if (mShowAlphaPanel && mAlphaRect != null) {
                         int alpha = (int) (mAlpha - x * 10);
                         if (alpha < 0) {
                             alpha = 0;
diff --git a/src/org/lineageos/lineageparts/notificationlight/LightSettingsDialog.java b/src/org/lineageos/lineageparts/notificationlight/LightSettingsDialog.java
index 1ec4fe9..c2b452d 100644
--- a/src/org/lineageos/lineageparts/notificationlight/LightSettingsDialog.java
+++ b/src/org/lineageos/lineageparts/notificationlight/LightSettingsDialog.java
@@ -1,7 +1,7 @@
 /*
  * SPDX-FileCopyrightText: 2010 Daniel Nilsson
  * SPDX-FileCopyrightText: 2012 The CyanogenMod Project
- * SPDX-FileCopyrightText: 2017,2019-2022 The LineageOS Project
+ * SPDX-FileCopyrightText: 2017-2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 
@@ -370,7 +370,7 @@
 
             // Check if we also need to add the custom value entry
             if (getTimePosition(customTime) == -1) {
-                times.add(new Pair<String, Integer>(mContext.getResources()
+                times.add(new Pair<>(mContext.getResources()
                         .getString(R.string.custom_time), customTime));
             }
         }
diff --git a/src/org/lineageos/lineageparts/notificationlight/NotificationLightSettings.java b/src/org/lineageos/lineageparts/notificationlight/NotificationLightSettings.java
index 654a995..08ceb3a 100644
--- a/src/org/lineageos/lineageparts/notificationlight/NotificationLightSettings.java
+++ b/src/org/lineageos/lineageparts/notificationlight/NotificationLightSettings.java
@@ -19,8 +19,6 @@
 import android.telephony.TelephonyManager;
 import android.text.TextUtils;
 import android.util.ArraySet;
-import android.view.View;
-import android.widget.AdapterView;
 import android.widget.ListView;
 
 import androidx.appcompat.app.AlertDialog;
@@ -77,9 +75,6 @@
     private static final String MISSED_CALL_PREF = "missed_call";
     private static final String VOICEMAIL_PREF = "voicemail";
     private static final String ADD_APPS = "custom_apps_add";
-
-    public static final int ACTION_TEST = 0;
-    public static final int ACTION_DELETE = 1;
     private static final int DIALOG_APPS = 0;
 
     private int mDefaultColor;
@@ -106,10 +101,10 @@
     public void onActivityCreated(Bundle savedInstanceState) {
         super.onActivityCreated(savedInstanceState);
 
-        final Context context = getContext();
+        final Context context = requireContext();
 
         addPreferencesFromResource(R.xml.notification_light_settings);
-        getActivity().getActionBar().setTitle(R.string.notification_light_title);
+        requireActivity().getActionBar().setTitle(R.string.notification_light_title);
 
         PreferenceScreen prefSet = getPreferenceScreen();
         Resources resources = getResources();
@@ -207,11 +202,11 @@
         super.onResume();
         refreshDefault();
         refreshCustomApplicationPrefs();
-        getActivity().invalidateOptionsMenu();
+        requireActivity().invalidateOptionsMenu();
     }
 
     private void refreshDefault() {
-        ContentResolver resolver = getActivity().getContentResolver();
+        ContentResolver resolver = requireActivity().getContentResolver();
         int color = LineageSettings.System.getInt(resolver,
                 LineageSettings.System.NOTIFICATION_LIGHT_PULSE_DEFAULT_COLOR, mDefaultColor);
         int timeOn = LineageSettings.System.getInt(resolver,
@@ -302,7 +297,7 @@
             for (Package pkg : mPackages.values()) {
                 try {
                     PackageInfo info = mPackageManager.getPackageInfo(pkg.name,
-                            PackageManager.GET_META_DATA);
+                            PackageManager.PackageInfoFlags.of(PackageManager.GET_META_DATA));
                     ApplicationLightPreference pref =
                             new ApplicationLightPreference(context, null,
                                     pkg.color, pkg.timeon, pkg.timeoff);
@@ -320,7 +315,7 @@
             }
 
             maybeDisplayApplicationHint(context);
-            mPackageAdapter.setExcludedPackages(new HashSet<String>(mPackages.keySet()));
+            mPackageAdapter.setExcludedPackages(new HashSet<>(mPackages.keySet()));
         }
     }
 
@@ -419,45 +414,46 @@
      *
      * @param packageName Package name of application specific settings to update
      */
-    protected void updateValues(String packageName, Integer color, Integer timeon,
-                                Integer timeoff) {
-        ContentResolver resolver = getActivity().getContentResolver();
+    protected void updateValues(String packageName, Integer color, Integer timeOn,
+                                Integer timeOff) {
+        ContentResolver resolver = requireActivity().getContentResolver();
 
-        if (packageName.equals(DEFAULT_PREF)) {
-            LineageSettings.System.putInt(resolver,
-                    LineageSettings.System.NOTIFICATION_LIGHT_PULSE_DEFAULT_COLOR, color);
-            LineageSettings.System.putInt(resolver,
-                    LineageSettings.System.NOTIFICATION_LIGHT_PULSE_DEFAULT_LED_ON, timeon);
-            LineageSettings.System.putInt(resolver,
-                    LineageSettings.System.NOTIFICATION_LIGHT_PULSE_DEFAULT_LED_OFF, timeoff);
-            refreshDefault();
-            return;
-        } else if (packageName.equals(MISSED_CALL_PREF)) {
-            LineageSettings.System.putInt(resolver,
-                    LineageSettings.System.NOTIFICATION_LIGHT_PULSE_CALL_COLOR, color);
-            LineageSettings.System.putInt(resolver,
-                    LineageSettings.System.NOTIFICATION_LIGHT_PULSE_CALL_LED_ON, timeon);
-            LineageSettings.System.putInt(resolver,
-                    LineageSettings.System.NOTIFICATION_LIGHT_PULSE_CALL_LED_OFF, timeoff);
-            refreshDefault();
-            return;
-        } else if (packageName.equals(VOICEMAIL_PREF)) {
-            LineageSettings.System.putInt(resolver,
-                    LineageSettings.System.NOTIFICATION_LIGHT_PULSE_VMAIL_COLOR, color);
-            LineageSettings.System.putInt(resolver,
-                    LineageSettings.System.NOTIFICATION_LIGHT_PULSE_VMAIL_LED_ON, timeon);
-            LineageSettings.System.putInt(resolver,
-                    LineageSettings.System.NOTIFICATION_LIGHT_PULSE_VMAIL_LED_OFF, timeoff);
-            refreshDefault();
-            return;
+        switch (packageName) {
+            case DEFAULT_PREF:
+                LineageSettings.System.putInt(resolver,
+                        LineageSettings.System.NOTIFICATION_LIGHT_PULSE_DEFAULT_COLOR, color);
+                LineageSettings.System.putInt(resolver,
+                        LineageSettings.System.NOTIFICATION_LIGHT_PULSE_DEFAULT_LED_ON, timeOn);
+                LineageSettings.System.putInt(resolver,
+                        LineageSettings.System.NOTIFICATION_LIGHT_PULSE_DEFAULT_LED_OFF, timeOff);
+                refreshDefault();
+                return;
+            case MISSED_CALL_PREF:
+                LineageSettings.System.putInt(resolver,
+                        LineageSettings.System.NOTIFICATION_LIGHT_PULSE_CALL_COLOR, color);
+                LineageSettings.System.putInt(resolver,
+                        LineageSettings.System.NOTIFICATION_LIGHT_PULSE_CALL_LED_ON, timeOn);
+                LineageSettings.System.putInt(resolver,
+                        LineageSettings.System.NOTIFICATION_LIGHT_PULSE_CALL_LED_OFF, timeOff);
+                refreshDefault();
+                return;
+            case VOICEMAIL_PREF:
+                LineageSettings.System.putInt(resolver,
+                        LineageSettings.System.NOTIFICATION_LIGHT_PULSE_VMAIL_COLOR, color);
+                LineageSettings.System.putInt(resolver,
+                        LineageSettings.System.NOTIFICATION_LIGHT_PULSE_VMAIL_LED_ON, timeOn);
+                LineageSettings.System.putInt(resolver,
+                        LineageSettings.System.NOTIFICATION_LIGHT_PULSE_VMAIL_LED_OFF, timeOff);
+                refreshDefault();
+                return;
         }
 
         // Find the custom package and sets its new values
         Package app = mPackages.get(packageName);
         if (app != null) {
             app.color = color;
-            app.timeon = timeon;
-            app.timeoff = timeoff;
+            app.timeon = timeOn;
+            app.timeoff = timeOff;
             savePackageList(true);
         }
     }
@@ -481,7 +477,7 @@
             return false;
         }
 
-        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
+        AlertDialog.Builder builder = new AlertDialog.Builder(requireActivity())
                 .setTitle(R.string.dialog_delete_title)
                 .setMessage(R.string.dialog_delete_message)
                 .setIconAttribute(android.R.attr.alertDialogIcon)
@@ -513,14 +509,14 @@
      */
     @Override
     public Dialog onCreateDialog(int id) {
-        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
+        AlertDialog.Builder builder = new AlertDialog.Builder(requireActivity());
         final Dialog dialog;
         switch (id) {
             case DIALOG_APPS:
                 Resources res = getResources();
                 int paddingTop = res.getDimensionPixelOffset(R.dimen.package_list_padding_top);
 
-                final ListView list = new ListView(getActivity());
+                final ListView list = new ListView(requireActivity());
                 list.setAdapter(mPackageAdapter);
                 list.setDivider(null);
                 list.setPadding(0, paddingTop, 0, 0);
@@ -562,15 +558,7 @@
         }
 
         public String toString() {
-            StringBuilder builder = new StringBuilder();
-            builder.append(name);
-            builder.append("=");
-            builder.append(color);
-            builder.append(";");
-            builder.append(timeon);
-            builder.append(";");
-            builder.append(timeoff);
-            return builder.toString();
+            return name + "=" + color + ";" + timeon + ";" + timeoff;
         }
 
         public static Package fromString(String value) {
diff --git a/src/org/lineageos/lineageparts/profiles/NFCProfile.java b/src/org/lineageos/lineageparts/profiles/NFCProfile.java
index 1da4c3a..bfd6648 100644
--- a/src/org/lineageos/lineageparts/profiles/NFCProfile.java
+++ b/src/org/lineageos/lineageparts/profiles/NFCProfile.java
@@ -1,6 +1,6 @@
 /*
  * SPDX-FileCopyrightText: 2012 The CyanogenMod Project
- * SPDX-FileCopyrightText: 2017-2018 The LineageOS Project
+ * SPDX-FileCopyrightText: 2017-2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 
@@ -53,7 +53,8 @@
         Intent intent = getIntent();
         String action = intent.getAction();
         if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) {
-            Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
+            Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES,
+                    Parcelable.class);
             if (rawMsgs != null) {
                 NdefMessage[] msgs = new NdefMessage[rawMsgs.length];
                 for (int i = 0; i < rawMsgs.length; i++) {
@@ -61,8 +62,7 @@
                     for (NdefRecord record : msgs[i].getRecords()) {
                         String type = new String(record.getType());
                         byte[] payload = record.getPayload();
-                        if (PROFILE_MIME_TYPE.equals(type) && payload != null
-                                && payload.length == 16) {
+                        if (PROFILE_MIME_TYPE.equals(type) && payload.length == 16) {
                             handleProfileMimeType(payload);
                         }
                     }
diff --git a/src/org/lineageos/lineageparts/profiles/NFCProfileWriter.java b/src/org/lineageos/lineageparts/profiles/NFCProfileWriter.java
index 4d7e5ae..e2b9b65 100644
--- a/src/org/lineageos/lineageparts/profiles/NFCProfileWriter.java
+++ b/src/org/lineageos/lineageparts/profiles/NFCProfileWriter.java
@@ -1,6 +1,6 @@
 /*
  * SPDX-FileCopyrightText: 2012 The CyanogenMod Project
- * SPDX-FileCopyrightText: 2017-2018,2021-2022 The LineageOS Project
+ * SPDX-FileCopyrightText: 2017-2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 
@@ -91,7 +91,7 @@
     protected void onNewIntent(Intent intent) {
         // Tag writing mode
         if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(intent.getAction())) {
-            Tag detectedTag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
+            Tag detectedTag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG, Tag.class);
             if (NFCProfileUtils.writeTag(NFCProfileUtils.getProfileAsNdef(mProfile), detectedTag)) {
                 Toast.makeText(this, R.string.profile_write_success, Toast.LENGTH_LONG).show();
                 NFCProfileUtils.vibrate(this);
diff --git a/src/org/lineageos/lineageparts/profiles/ProfileGroupConfig.java b/src/org/lineageos/lineageparts/profiles/ProfileGroupConfig.java
index 095d9de..2f95e30 100644
--- a/src/org/lineageos/lineageparts/profiles/ProfileGroupConfig.java
+++ b/src/org/lineageos/lineageparts/profiles/ProfileGroupConfig.java
@@ -1,5 +1,6 @@
 /*
  * SPDX-FileCopyrightText: 2012 The CyanogenMod Project
+ * SPDX-FileCopyrightText: 2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 
@@ -30,6 +31,7 @@
     private static final CharSequence KEY_RINGERMODE = "ringer_mode";
     private static final CharSequence KEY_SOUNDTONE = "soundtone";
     private static final CharSequence KEY_RINGTONE = "ringtone";
+    private static final String EXTRA_PROFILE_GROUP = "ProfileGroup";
 
     Profile mProfile;
     ProfileGroup mProfileGroup;
@@ -50,8 +52,8 @@
 
         final Bundle args = getArguments();
         if (args != null) {
-            mProfile = (Profile) args.getParcelable("Profile");
-            UUID uuid = UUID.fromString(args.getString("ProfileGroup"));
+            mProfile = args.getParcelable(ProfilesSettings.EXTRA_PROFILE, Profile.class);
+            UUID uuid = UUID.fromString(args.getString(EXTRA_PROFILE_GROUP));
 
             mProfileManager = ProfileManager.getInstance(getActivity());
             mProfileGroup = mProfile.getProfileGroup(uuid);
diff --git a/src/org/lineageos/lineageparts/profiles/ProfilesPreference.java b/src/org/lineageos/lineageparts/profiles/ProfilesPreference.java
index 80907d5..14fbd52 100644
--- a/src/org/lineageos/lineageparts/profiles/ProfilesPreference.java
+++ b/src/org/lineageos/lineageparts/profiles/ProfilesPreference.java
@@ -1,5 +1,6 @@
 /*
  * SPDX-FileCopyrightText: 2012 The CyanogenMod Project
+ * SPDX-FileCopyrightText: 2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 
@@ -121,7 +122,7 @@
 
     // utility method used to start sub activity
     private void startProfileConfigActivity() {
-        PartsActivity pa = (PartsActivity) mFragment.getActivity();
+        PartsActivity pa = (PartsActivity) mFragment.requireActivity();
         pa.startPreferencePanel(SetupActionsFragment.class.getCanonicalName(), mSettingsBundle,
                 R.string.profile_profile_manage, null, null, PROFILE_DETAILS);
     }
diff --git a/src/org/lineageos/lineageparts/profiles/ProfilesSettings.java b/src/org/lineageos/lineageparts/profiles/ProfilesSettings.java
index b2c8f20..7a62ce4 100644
--- a/src/org/lineageos/lineageparts/profiles/ProfilesSettings.java
+++ b/src/org/lineageos/lineageparts/profiles/ProfilesSettings.java
@@ -1,6 +1,6 @@
 /*
  * SPDX-FileCopyrightText: 2012 The CyanogenMod Project
- * SPDX-FileCopyrightText: 2017-2022 The LineageOS Project
+ * SPDX-FileCopyrightText: 2017-2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 
@@ -9,7 +9,6 @@
 import android.annotation.Nullable;
 import android.content.BroadcastReceiver;
 import android.content.Context;
-import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.os.Bundle;
@@ -23,6 +22,7 @@
 import android.widget.FrameLayout;
 import android.widget.TextView;
 
+import androidx.annotation.NonNull;
 import androidx.appcompat.app.AlertDialog;
 import androidx.fragment.app.FragmentActivity;
 import androidx.preference.Preference;
@@ -57,10 +57,6 @@
 
     private boolean mEnabled;
 
-    ViewGroup mContainer;
-
-    static Bundle mSavedState;
-
     public ProfilesSettings() {
         mFilter = new IntentFilter();
         mFilter.addAction(ProfileManager.PROFILES_STATE_CHANGED_ACTION);
@@ -85,19 +81,18 @@
     }
 
     @Override
-    public View onCreateView(LayoutInflater inflater, ViewGroup container,
+    public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
                              Bundle savedInstanceState) {
         View view = super.onCreateView(inflater, container, savedInstanceState);
-        FrameLayout frameLayout = new FrameLayout(getActivity());
-        mContainer = frameLayout;
+        FrameLayout frameLayout = new FrameLayout(requireActivity());
         frameLayout.addView(view);
         return frameLayout;
     }
 
     @Override
-    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
+    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
         super.onViewCreated(view, savedInstanceState);
-        View v = LayoutInflater.from(getActivity())
+        View v = LayoutInflater.from(requireActivity())
                 .inflate(R.layout.empty_textview, (ViewGroup) view, true);
 
         TextView emptyTextView = v.findViewById(R.id.empty);
@@ -116,25 +111,24 @@
     @Override
     public void onResume() {
         super.onResume();
-        getActivity().registerReceiver(mReceiver, mFilter);
+        requireActivity().registerReceiver(mReceiver, mFilter);
         updateProfilesEnabledState();
     }
 
     @Override
     public void onPause() {
         super.onPause();
-        getActivity().unregisterReceiver(mReceiver);
+        requireActivity().unregisterReceiver(mReceiver);
     }
 
     @Override
     public void onStart() {
         super.onStart();
-        final PartsActivity activity = (PartsActivity) getActivity();
+        final PartsActivity activity = (PartsActivity) requireActivity();
         mProfileEnabler = activity.getMainSwitchBar();
-        mProfileEnabler.getSwitch().setOnCheckedChangeListener((buttonView, isChecked) -> {
-            LineageSettings.System.putInt(activity.getContentResolver(),
-                    LineageSettings.System.SYSTEM_PROFILES_ENABLED, isChecked ? 1 : 0);
-        });
+        mProfileEnabler.getSwitch().setOnCheckedChangeListener((buttonView, isChecked) ->
+                LineageSettings.System.putInt(activity.getContentResolver(),
+                LineageSettings.System.SYSTEM_PROFILES_ENABLED, isChecked ? 1 : 0));
         mProfileEnabler.setTitle(getString(R.string.profiles_settings_enable_title));
         mProfileEnabler.setVisibility(View.VISIBLE);
     }
@@ -163,33 +157,29 @@
         args.putBoolean(EXTRA_NEW_PROFILE, true);
         args.putParcelable(EXTRA_PROFILE, new Profile(getString(R.string.new_profile_name)));
 
-        PartsActivity pa = (PartsActivity) getActivity();
+        PartsActivity pa = (PartsActivity) requireActivity();
         pa.startPreferencePanel(SetupTriggersFragment.class.getCanonicalName(), args,
                 0, null, this, 0);
     }
 
     private void resetAll() {
-        new AlertDialog.Builder(getActivity())
+        new AlertDialog.Builder(requireActivity())
                 .setTitle(R.string.profile_reset_title)
                 .setIconAttribute(android.R.attr.alertDialogIcon)
                 .setMessage(R.string.profile_reset_message)
-                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
-                    @Override
-                    public void onClick(DialogInterface dialog, int id) {
-                        mProfileManager.resetAll();
-                        mProfileManager.setActiveProfile(
-                                mProfileManager.getActiveProfile().getUuid());
-                        dialog.dismiss();
-                        refreshList();
-
-                    }
+                .setPositiveButton(android.R.string.ok, (dialog, id) -> {
+                    mProfileManager.resetAll();
+                    mProfileManager.setActiveProfile(
+                            mProfileManager.getActiveProfile().getUuid());
+                    dialog.dismiss();
+                    refreshList();
                 })
                 .setNegativeButton(R.string.cancel, null)
                 .show();
     }
 
     private void updateProfilesEnabledState() {
-        FragmentActivity activity = getActivity();
+        FragmentActivity activity = requireActivity();
 
         mEnabled = LineageSettings.System.getInt(activity.getContentResolver(),
                 LineageSettings.System.SYSTEM_PROFILES_ENABLED, 1) == 1;
@@ -234,7 +224,7 @@
         }
 
         // Add pref to create new profile
-        Preference preference = new Preference(getContext());
+        Preference preference = new Preference(requireContext());
         preference.setIcon(R.drawable.ic_add_24dp);
         preference.setTitle(R.string.profiles_create_new);
         preference.setSelectable(true);
diff --git a/src/org/lineageos/lineageparts/profiles/SeekBarVolumizer.java b/src/org/lineageos/lineageparts/profiles/SeekBarVolumizer.java
index 2d5f5a8..5fd4de0 100644
--- a/src/org/lineageos/lineageparts/profiles/SeekBarVolumizer.java
+++ b/src/org/lineageos/lineageparts/profiles/SeekBarVolumizer.java
@@ -1,6 +1,6 @@
 /*
  * SPDX-FileCopyrightText: 2014 The Android Open Source Project
- * SPDX-FileCopyrightText: 2021 The LineageOS Project
+ * SPDX-FileCopyrightText: 2021-2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 
@@ -299,7 +299,11 @@
         synchronized (this) {
             mRingtone = RingtoneManager.getRingtone(mContext, mDefaultUri);
             if (mRingtone != null) {
-                mRingtone.setStreamType(mStreamType);
+                AudioAttributes attributes =
+                        new AudioAttributes.Builder(mRingtone.getAudioAttributes())
+                                .setLegacyStreamType(mStreamType)
+                                .build();
+                mRingtone.setAudioAttributes(attributes);
             }
         }
     }
diff --git a/src/org/lineageos/lineageparts/profiles/SetupActionsFragment.java b/src/org/lineageos/lineageparts/profiles/SetupActionsFragment.java
index f6f3ceb..13d6ba5 100644
--- a/src/org/lineageos/lineageparts/profiles/SetupActionsFragment.java
+++ b/src/org/lineageos/lineageparts/profiles/SetupActionsFragment.java
@@ -1,6 +1,6 @@
 /*
  * SPDX-FileCopyrightText: 2014 The CyanogenMod Project
- * SPDX-FileCopyrightText: 2017-2022 The LineageOS Project
+ * SPDX-FileCopyrightText: 2017-2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 
@@ -9,19 +9,21 @@
 import android.app.Activity;
 import android.app.Dialog;
 import android.app.admin.DevicePolicyManager;
-import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothManager;
 import android.content.ContentResolver;
 import android.content.Context;
 import android.content.DialogInterface;
 import android.content.Intent;
 import android.location.LocationManager;
 import android.media.AudioManager;
-import android.net.ConnectivityManager;
 import android.net.wifi.WifiManager;
 import android.nfc.NfcManager;
-import android.os.AsyncTask;
 import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
 import android.provider.Settings;
+
+import androidx.annotation.NonNull;
 import androidx.recyclerview.widget.LinearLayoutManager;
 import androidx.recyclerview.widget.RecyclerView;
 import android.text.Editable;
@@ -42,7 +44,6 @@
 import androidx.appcompat.app.AlertDialog;
 
 import lineageos.app.Profile;
-import lineageos.app.ProfileGroup;
 import lineageos.app.ProfileManager;
 import lineageos.profiles.AirplaneModeSettings;
 import lineageos.profiles.BrightnessSettings;
@@ -72,6 +73,8 @@
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 
 import static lineageos.profiles.ConnectionSettings.PROFILE_CONNECTION_BLUETOOTH;
 import static lineageos.profiles.ConnectionSettings.PROFILE_CONNECTION_LOCATION;
@@ -147,7 +150,7 @@
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         if (getArguments() != null) {
-            mProfile = getArguments().getParcelable(ProfilesSettings.EXTRA_PROFILE);
+            mProfile = getArguments().getParcelable(ProfilesSettings.EXTRA_PROFILE, Profile.class);
             mNewProfileMode = getArguments().getBoolean(ProfilesSettings.EXTRA_NEW_PROFILE, false);
         }
 
@@ -183,7 +186,7 @@
             // triggers
             mItems.add(new Header(R.string.profile_triggers_header));
             mItems.add(generateTriggerItem(TriggerItem.WIFI));
-            if (DeviceUtils.deviceSupportsBluetooth()) {
+            if (DeviceUtils.deviceSupportsBluetooth(context)) {
                 mItems.add(generateTriggerItem(TriggerItem.BLUETOOTH));
             }
             if (DeviceUtils.deviceSupportsNfc(context)) {
@@ -193,7 +196,7 @@
 
         // connection overrides
         mItems.add(new Header(R.string.wireless_networks_settings_title));
-        if (DeviceUtils.deviceSupportsBluetooth()) {
+        if (DeviceUtils.deviceSupportsBluetooth(context)) {
             mItems.add(new ConnectionOverrideItem(PROFILE_CONNECTION_BLUETOOTH,
                     mProfile.getSettingsForConnection(PROFILE_CONNECTION_BLUETOOTH)));
         }
@@ -295,7 +298,7 @@
     }
 
     @Override
-    public void onViewCreated(View view, Bundle savedInstanceState) {
+    public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
         super.onViewCreated(view, savedInstanceState);
 
         mRecyclerView = view.findViewById(android.R.id.list);
@@ -303,7 +306,7 @@
         mRecyclerView.setAdapter(mAdapter);
 
         if (mNewProfileMode) {
-            TextView desc = new TextView(getActivity());
+            TextView desc = new TextView(requireActivity());
             int descPadding = getResources().getDimensionPixelSize(
                     R.dimen.profile_instruction_padding);
             desc.setPadding(descPadding, descPadding, descPadding, descPadding);
@@ -319,7 +322,7 @@
     @Override
     public void onActivityCreated(Bundle savedInstanceState) {
         super.onActivityCreated(savedInstanceState);
-        final PartsActivity activity = (PartsActivity) getActivity();
+        final PartsActivity activity = (PartsActivity) requireActivity();
         if (mNewProfileMode) {
             activity.setTitle(getString(R.string.profiles_create_new));
             activity.getTopIntro().setText(R.string.profile_setup_actions_title);
@@ -332,11 +335,10 @@
     }
 
     private AlertDialog requestFillProfileFromSettingsDialog() {
-        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
+        AlertDialog.Builder builder = new AlertDialog.Builder(requireActivity());
         builder.setMessage(R.string.profile_populate_profile_from_state);
         builder.setNegativeButton(R.string.no, null);
-        builder.setPositiveButton(R.string.yes,
-                (DialogInterface.OnClickListener) (dialog, which) -> {
+        builder.setPositiveButton(R.string.yes, (dialog, which) -> {
             fillProfileFromCurrentSettings();
             dialog.dismiss();
         });
@@ -344,28 +346,23 @@
     }
 
     private void fillProfileFromCurrentSettings() {
-        new AsyncTask<Void, Void, Void>() {
-            @Override
-            protected Void doInBackground(Void... params) {
-                fillProfileWithCurrentSettings(getActivity(), mProfile);
-                updateProfile();
-                return null;
-            }
-
-            @Override
-            protected void onPostExecute(Void aVoid) {
-                super.onPostExecute(aVoid);
-                rebuildItemList();
-            }
-        }.execute((Void) null);
+        ExecutorService executor = Executors.newSingleThreadExecutor();
+        Handler handler = new Handler(Looper.getMainLooper());
+        executor.execute(() -> {
+            fillProfileWithCurrentSettings(getActivity(), mProfile);
+            updateProfile();
+            handler.post(this::rebuildItemList);
+        });
     }
 
     public static void fillProfileWithCurrentSettings(Context context, Profile profile) {
         // bt
-        if (DeviceUtils.deviceSupportsBluetooth()) {
+        if (DeviceUtils.deviceSupportsBluetooth(context)) {
+            BluetoothManager bluetoothManager =
+                    (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE);
             profile.setConnectionSettings(
                     new ConnectionSettings(ConnectionSettings.PROFILE_CONNECTION_BLUETOOTH,
-                            BluetoothAdapter.getDefaultAdapter().isEnabled() ? 1 : 0,
+                            bluetoothManager.getAdapter().isEnabled() ? 1 : 0,
                             true));
         }
 
@@ -388,7 +385,6 @@
 
         // mobile data
         if (DeviceUtils.deviceSupportsMobileData(context)) {
-            ConnectivityManager cm = context.getSystemService(ConnectivityManager.class);
             profile.setConnectionSettings(
                     new ConnectionSettings(ConnectionSettings.PROFILE_CONNECTION_MOBILEDATA,
                             DeviceUtils.isMobileDataEnabled(context) ? 1 : 0, true));
@@ -653,7 +649,7 @@
     }
 
     private AlertDialog requestRingModeDialog(final RingModeSettings setting) {
-        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
+        AlertDialog.Builder builder = new AlertDialog.Builder(requireActivity());
         final String[] values = getResources().getStringArray(R.array.ring_mode_values);
         final String[] names = getResources().getStringArray(R.array.ring_mode_entries);
 
@@ -857,7 +853,7 @@
     }
 
     @Override
-    public View onCreateView(LayoutInflater inflater, ViewGroup container,
+    public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
                              Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.fragment_setup_actions, container, false);
 
diff --git a/src/org/lineageos/lineageparts/profiles/SetupTriggersFragment.java b/src/org/lineageos/lineageparts/profiles/SetupTriggersFragment.java
index 472742c..d50d9ea 100644
--- a/src/org/lineageos/lineageparts/profiles/SetupTriggersFragment.java
+++ b/src/org/lineageos/lineageparts/profiles/SetupTriggersFragment.java
@@ -15,6 +15,10 @@
 import android.view.View;
 import android.view.ViewGroup;
 
+import androidx.annotation.NonNull;
+
+import com.google.android.material.appbar.CollapsingToolbarLayout;
+
 import lineageos.app.Profile;
 import lineageos.app.ProfileManager;
 
@@ -29,7 +33,6 @@
 
     RtlCompatibleViewPager mPager;
     Profile mProfile;
-    ProfileManager mProfileManager;
     SlidingTabLayout mTabLayout;
     TriggerPagerAdapter mAdapter;
     boolean mNewProfileMode;
@@ -56,17 +59,16 @@
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         if (getArguments() != null) {
-            mProfile = getArguments().getParcelable(ProfilesSettings.EXTRA_PROFILE);
+            mProfile = getArguments().getParcelable(ProfilesSettings.EXTRA_PROFILE, Profile.class);
             mNewProfileMode = getArguments().getBoolean(ProfilesSettings.EXTRA_NEW_PROFILE, false);
             mPreselectedItem = getArguments().getInt(EXTRA_INITIAL_PAGE, 0);
         }
-        mProfileManager = ProfileManager.getInstance(getActivity());
     }
 
     @Override
     public void onActivityCreated(Bundle savedInstanceState) {
         super.onActivityCreated(savedInstanceState);
-        final PartsActivity activity = (PartsActivity) getActivity();
+        final PartsActivity activity = (PartsActivity) requireActivity();
         if (mNewProfileMode) {
             activity.setTitle(R.string.profiles_create_new);
             activity.getTopIntro().setText(R.string.profile_setup_setup_triggers_title);
@@ -76,11 +78,11 @@
                     R.string.profile_setup_setup_triggers_title_config, mProfile.getName()));
         }
         activity.showTopIntro(true);
-
-        activity.getCollapsingToolbarLayout().measure(
-                View.MeasureSpec.EXACTLY, View.MeasureSpec.EXACTLY);
-        activity.getCollapsingToolbarLayout().post(() ->
-                mPager.setHeightOffset(mTabLayout.getHeight()));
+        CollapsingToolbarLayout toolbarLayout = activity.getCollapsingToolbarLayout();
+        if (toolbarLayout != null) {
+            toolbarLayout.measure(View.MeasureSpec.EXACTLY, View.MeasureSpec.EXACTLY);
+            toolbarLayout.post(() -> mPager.setHeightOffset(mTabLayout.getHeight()));
+        }
     }
 
     @Override
@@ -91,8 +93,8 @@
     }
 
     @Override
-    public View onCreateView(LayoutInflater inflater, ViewGroup container,
-            Bundle savedInstanceState) {
+    public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
+                             Bundle savedInstanceState) {
         // Inflate the layout for this fragment
         View root = inflater.inflate(R.layout.fragment_setup_triggers, container, false);
 
diff --git a/src/org/lineageos/lineageparts/profiles/TriggerPagerAdapter.java b/src/org/lineageos/lineageparts/profiles/TriggerPagerAdapter.java
index c4e6307..944863b 100644
--- a/src/org/lineageos/lineageparts/profiles/TriggerPagerAdapter.java
+++ b/src/org/lineageos/lineageparts/profiles/TriggerPagerAdapter.java
@@ -1,6 +1,6 @@
 /*
  * SPDX-FileCopyrightText: 2014 The CyanogenMod Project
- * SPDX-FileCopyrightText: 2017-2022 The LineageOS Project
+ * SPDX-FileCopyrightText: 2017-2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 
@@ -10,6 +10,7 @@
 import android.util.SparseArray;
 import android.view.ViewGroup;
 
+import androidx.annotation.NonNull;
 import androidx.fragment.app.Fragment;
 import androidx.fragment.app.FragmentActivity;
 import androidx.fragment.app.FragmentManager;
@@ -36,10 +37,8 @@
 
     private final FragmentActivity mFragmentActivity;
 
-    private int mCurrentPage;
-
     /**
-     * Constructor of <code>PagerAdatper<code>
+     * Constructor of <code>PagerAdapter<code>
      *
      * @param activity The {@link androidx.fragment.app.FragmentActivity} of the
      *            {@link androidx.fragment.app.Fragment}.
@@ -71,37 +70,24 @@
     }
 
     /**
-     * Method that returns the {@link androidx.fragment.app.Fragment} in the argument
-     * position.
-     *
-     * @param position The position of the fragment to return.
-     * @return Fragment The {@link androidx.fragment.app.Fragment} in the argument position.
-     */
-    public Fragment getFragment(final int position) {
-        final WeakReference<Fragment> mWeakFragment = mFragmentArray.get(position);
-        if (mWeakFragment != null && mWeakFragment.get() != null) {
-            return mWeakFragment.get();
-        }
-        return getItem(position);
-    }
-
-    /**
      * {@inheritDoc}
      */
+    @NonNull
     @Override
-    public Object instantiateItem(final ViewGroup container, final int position) {
+    public Object instantiateItem(@NonNull final ViewGroup container, final int position) {
         final Fragment mFragment = (Fragment)super.instantiateItem(container, position);
         final WeakReference<Fragment> mWeakFragment = mFragmentArray.get(position);
         if (mWeakFragment != null) {
             mWeakFragment.clear();
         }
-        mFragmentArray.put(position, new WeakReference<Fragment>(mFragment));
+        mFragmentArray.put(position, new WeakReference<>(mFragment));
         return mFragment;
     }
 
     /**
      * {@inheritDoc}
      */
+    @NonNull
     @Override
     public Fragment getItem(final int position) {
         final Holder mCurrentHolder = mHolderList.get(position);
@@ -113,7 +99,8 @@
      * {@inheritDoc}
      */
     @Override
-    public void destroyItem(final ViewGroup container, final int position, final Object object) {
+    public void destroyItem(@NonNull final ViewGroup container, final int position,
+                            @NonNull final Object object) {
         super.destroyItem(container, position, object);
         final WeakReference<Fragment> mWeakFragment = mFragmentArray.get(position);
         if (mWeakFragment != null) {
@@ -138,24 +125,6 @@
     }
 
     /**
-     * Method that returns the current page position.
-     *
-     * @return int The current page.
-     */
-    public int getCurrentPage() {
-        return mCurrentPage;
-    }
-
-    /**
-     * Method that sets the current page position.
-     *
-     * @param currentPage The current page.
-     */
-    protected void setCurrentPage(final int currentPage) {
-        mCurrentPage = currentPage;
-    }
-
-    /**
      * An enumeration of all the main fragments supported.
      */
     public enum TriggerFragments {
diff --git a/src/org/lineageos/lineageparts/profiles/actions/ItemListAdapter.java b/src/org/lineageos/lineageparts/profiles/actions/ItemListAdapter.java
index 870c905..5112582 100644
--- a/src/org/lineageos/lineageparts/profiles/actions/ItemListAdapter.java
+++ b/src/org/lineageos/lineageparts/profiles/actions/ItemListAdapter.java
@@ -1,11 +1,13 @@
 /*
  * SPDX-FileCopyrightText: 2014 The CyanogenMod Project
- * SPDX-FileCopyrightText: 2020-2022 The LineageOS Project
+ * SPDX-FileCopyrightText: 2020-2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 package org.lineageos.lineageparts.profiles.actions;
 
 import android.content.Context;
+
+import androidx.annotation.NonNull;
 import androidx.recyclerview.widget.RecyclerView;
 import android.view.LayoutInflater;
 import android.view.View;
@@ -47,8 +49,9 @@
         return mItems.get(position).isHeader() ? VIEW_TYPE_HEADER : VIEW_TYPE_ITEM;
     }
 
+    @NonNull
     @Override
-    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
         final RecyclerView.ViewHolder holder;
         if (viewType == VIEW_TYPE_HEADER) {
             holder = new HeaderViewHolder(
@@ -63,7 +66,7 @@
     }
 
     @Override
-    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
+    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
         final Item item = mItems.get(position);
         if (holder instanceof HeaderViewHolder) {
             ((HeaderViewHolder) holder).bind(item);
@@ -76,7 +79,7 @@
     @Override
     public void onClick(View view) {
         RecyclerView.ViewHolder holder = (RecyclerView.ViewHolder) view.getTag();
-        int position = holder.getAdapterPosition();
+        int position = holder.getBindingAdapterPosition();
         if (position != RecyclerView.NO_POSITION) {
             mItemClickListener.onItemClick(mItems.get(position), position);
         }
diff --git a/src/org/lineageos/lineageparts/profiles/actions/item/VolumeStreamItem.java b/src/org/lineageos/lineageparts/profiles/actions/item/VolumeStreamItem.java
index 931ed11..53c2185 100644
--- a/src/org/lineageos/lineageparts/profiles/actions/item/VolumeStreamItem.java
+++ b/src/org/lineageos/lineageparts/profiles/actions/item/VolumeStreamItem.java
@@ -1,13 +1,12 @@
 /*
  * SPDX-FileCopyrightText: 2014 The CyanogenMod Project
- * SPDX-FileCopyrightText: 2020-2022 The LineageOS Project
+ * SPDX-FileCopyrightText: 2020-2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 package org.lineageos.lineageparts.profiles.actions.item;
 
 import android.content.Context;
 import android.media.AudioManager;
-import android.provider.Settings;
 
 import org.lineageos.lineageparts.R;
 
@@ -44,10 +43,7 @@
     @Override
     public boolean isEnabled(Context context) {
         // all streams are enabled, except notification stream if linking to ring volume is enabled
-        if (mStreamId != AudioManager.STREAM_NOTIFICATION) {
-            return true;
-        }
-        return false;
+        return mStreamId != AudioManager.STREAM_NOTIFICATION;
     }
 
     public static int getNameForStream(int stream) {
diff --git a/src/org/lineageos/lineageparts/profiles/triggers/AbstractTriggerListFragment.java b/src/org/lineageos/lineageparts/profiles/triggers/AbstractTriggerListFragment.java
index ae29bec..5dd186d 100644
--- a/src/org/lineageos/lineageparts/profiles/triggers/AbstractTriggerListFragment.java
+++ b/src/org/lineageos/lineageparts/profiles/triggers/AbstractTriggerListFragment.java
@@ -1,5 +1,5 @@
 /*
- * SPDX-FileCopyrightText: 2020-2022 The LineageOS Project
+ * SPDX-FileCopyrightText: 2020-2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 
@@ -8,6 +8,8 @@
 import android.content.Intent;
 import android.content.res.Resources;
 import android.os.Bundle;
+
+import androidx.annotation.NonNull;
 import androidx.recyclerview.widget.LinearLayoutManager;
 import androidx.recyclerview.widget.RecyclerView;
 import android.view.LayoutInflater;
@@ -68,7 +70,7 @@
             }
         }
 
-        new AlertDialog.Builder(getActivity())
+        new AlertDialog.Builder(requireActivity())
                 .setTitle(R.string.profile_trigger_configure)
                 .setSingleChoiceItems(entries, currentItem, (dialog, which) -> {
                     mProfile.setTrigger(info.type, info.id, valueInts[which], info.name);
@@ -90,7 +92,7 @@
         super.onCreate(savedInstanceState);
         mProfileManager = ProfileManager.getInstance(getActivity());
         if (getArguments() != null) {
-            mProfile = getArguments().getParcelable(ProfilesSettings.EXTRA_PROFILE);
+            mProfile = getArguments().getParcelable(ProfilesSettings.EXTRA_PROFILE, Profile.class);
         }
     }
 
@@ -111,7 +113,7 @@
     }
 
     @Override
-    public void onViewCreated(View view, Bundle savedInstanceState) {
+    public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
         super.onViewCreated(view, savedInstanceState);
         mAdapter = new TriggerAdapter(mTriggers, mItemClickListener);
         mRecyclerView.setAdapter(mAdapter);
@@ -210,6 +212,7 @@
             return mTriggers.size();
         }
 
+        @NonNull
         @Override
         public TriggerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
             LayoutInflater inflater = LayoutInflater.from(parent.getContext());
@@ -228,7 +231,7 @@
         @Override
         public void onClick(View view) {
             TriggerViewHolder holder = (TriggerViewHolder) view.getTag();
-            int position = holder.getAdapterPosition();
+            int position = holder.getBindingAdapterPosition();
             if (position != RecyclerView.NO_POSITION) {
                 mItemClickListener.onItemClick(mTriggers.get(position));
             }
diff --git a/src/org/lineageos/lineageparts/profiles/triggers/BluetoothTriggerFragment.java b/src/org/lineageos/lineageparts/profiles/triggers/BluetoothTriggerFragment.java
index 5ff326a..7c99c4b 100644
--- a/src/org/lineageos/lineageparts/profiles/triggers/BluetoothTriggerFragment.java
+++ b/src/org/lineageos/lineageparts/profiles/triggers/BluetoothTriggerFragment.java
@@ -8,6 +8,8 @@
 import android.bluetooth.BluetoothAdapter;
 import android.bluetooth.BluetoothClass;
 import android.bluetooth.BluetoothDevice;
+import android.bluetooth.BluetoothManager;
+import android.content.Context;
 import android.content.Intent;
 import android.os.Bundle;
 import android.provider.Settings;
@@ -31,7 +33,9 @@
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-        mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
+        BluetoothManager bluetoothManager = (BluetoothManager)
+                requireContext().getSystemService(Context.BLUETOOTH_SERVICE);
+        mBluetoothAdapter = bluetoothManager.getAdapter();
     }
 
     @Override
diff --git a/src/org/lineageos/lineageparts/profiles/triggers/NfcTriggerFragment.java b/src/org/lineageos/lineageparts/profiles/triggers/NfcTriggerFragment.java
index 462f75c..2807cf6 100644
--- a/src/org/lineageos/lineageparts/profiles/triggers/NfcTriggerFragment.java
+++ b/src/org/lineageos/lineageparts/profiles/triggers/NfcTriggerFragment.java
@@ -1,11 +1,12 @@
 /*
  * SPDX-FileCopyrightText: 2014 The CyanogenMod Project
- * SPDX-FileCopyrightText: 2017,2021-2022 The LineageOS Project
+ * SPDX-FileCopyrightText: 2017-2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 
 package org.lineageos.lineageparts.profiles.triggers;
 
+import android.app.Activity;
 import android.app.PendingIntent;
 import android.content.Intent;
 import android.content.IntentFilter;
@@ -49,17 +50,17 @@
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-        mNfcAdapter = NfcAdapter.getDefaultAdapter(getActivity());
+        mNfcAdapter = NfcAdapter.getDefaultAdapter(requireActivity());
         if (getArguments() != null) {
-            mProfile = getArguments().getParcelable(ProfilesSettings.EXTRA_PROFILE);
+            mProfile = getArguments().getParcelable(ProfilesSettings.EXTRA_PROFILE, Profile.class);
         }
-        ((PartsActivity) getActivity()).setNfcProfileCallback(this);
+        ((PartsActivity) requireActivity()).setNfcProfileCallback(this);
     }
 
     @Override
     public void onDestroy() {
         super.onDestroy();
-        ((PartsActivity) getActivity()).setNfcProfileCallback(null);
+        ((PartsActivity) requireActivity()).setNfcProfileCallback(null);
     }
 
     @Override
@@ -77,9 +78,10 @@
     }
 
     private PendingIntent getPendingIntent() {
-        Intent intent = new Intent(getActivity(), getActivity().getClass())
+        Activity activity = requireActivity();
+        Intent intent = new Intent(activity, activity.getClass())
                 .addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
-        return PendingIntent.getActivity(getActivity(), 0, intent, PendingIntent.FLAG_IMMUTABLE);
+        return PendingIntent.getActivity(requireActivity(), 0, intent, PendingIntent.FLAG_IMMUTABLE);
     }
 
     private void disableTagWriteMode() {
@@ -91,17 +93,18 @@
         IntentFilter[] writeTagFilters = new IntentFilter[]{
                 tagDetected
         };
-        mNfcAdapter.enableForegroundDispatch(getActivity(), getPendingIntent(), writeTagFilters,
+        mNfcAdapter.enableForegroundDispatch(requireActivity(), getPendingIntent(), writeTagFilters,
                 null);
     }
 
     @Override
     public void onTagRead(Tag tag) {
+        Activity activity = requireActivity();
         if (NFCProfileUtils.writeTag(NFCProfileUtils.getProfileAsNdef(mProfile), tag)) {
-            Toast.makeText(getActivity(), R.string.profile_write_success, Toast.LENGTH_LONG).show();
-            NFCProfileUtils.vibrate(getActivity());
+            Toast.makeText(activity, R.string.profile_write_success, Toast.LENGTH_LONG).show();
+            NFCProfileUtils.vibrate(requireActivity());
         } else {
-            Toast.makeText(getActivity(), R.string.profile_write_failed, Toast.LENGTH_LONG).show();
+            Toast.makeText(activity, R.string.profile_write_failed, Toast.LENGTH_LONG).show();
         }
     }
 
diff --git a/src/org/lineageos/lineageparts/search/Searchable.java b/src/org/lineageos/lineageparts/search/Searchable.java
index fbcd202..7a09afc 100644
--- a/src/org/lineageos/lineageparts/search/Searchable.java
+++ b/src/org/lineageos/lineageparts/search/Searchable.java
@@ -1,6 +1,6 @@
 /*
  * SPDX-FileCopyrightText: 2016 The CyanogenMod Project
- * SPDX-FileCopyrightText: 2022 The LineageOS Project
+ * SPDX-FileCopyrightText: 2022-2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 package org.lineageos.lineageparts.search;
@@ -15,7 +15,7 @@
  * dynamic metadata to the indexer. Since our entrypoints are standardized around
  * the parts catalog, there is no need to enumerate XML resources here. Keywords
  * and non-indexable keys may be supplied by a class.
- *
+ * <p>
  * If a class wants to use this functionality, it should contain a static field
  * named SEARCH_INDEX_DATA_PROVIDER which contains an instance of SearchIndexProvider.
  * This is similar to the mechanism used by the Settings app.
diff --git a/src/org/lineageos/lineageparts/sounds/ChargingSoundsSettings.java b/src/org/lineageos/lineageparts/sounds/ChargingSoundsSettings.java
index 9ae3464..d987cb0 100644
--- a/src/org/lineageos/lineageparts/sounds/ChargingSoundsSettings.java
+++ b/src/org/lineageos/lineageparts/sounds/ChargingSoundsSettings.java
@@ -1,6 +1,6 @@
 /*
  * SPDX-FileCopyrightText: 2016 The CyanogenMod Project
- * SPDX-FileCopyrightText: 2017,2019-2023 The LineageOS Project
+ * SPDX-FileCopyrightText: 2017-2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 
@@ -21,6 +21,9 @@
 import android.util.Log;
 import android.view.View;
 
+import androidx.activity.result.ActivityResultLauncher;
+import androidx.activity.result.contract.ActivityResultContracts;
+import androidx.annotation.NonNull;
 import androidx.preference.Preference;
 
 import org.lineageos.lineageparts.R;
@@ -56,13 +59,57 @@
     private Uri mDefaultWiredChargingSoundUri;
     private Uri mDefaultWirelessChargingSoundUri;
 
+    private int mRequestCode;
+
+    private final ActivityResultLauncher<Intent> mActivityResultLauncher =
+            registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
+                    result -> {
+                        if (result.getResultCode() != Activity.RESULT_OK) {
+                            return;
+                        }
+                        Intent data = result.getData();
+                        if (data == null) {
+                            return;
+                        }
+                        Uri uri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI,
+                                Uri.class);
+
+                        if (uri == null) {
+                            updateChargingSounds(RINGTONE_SILENT_URI_STRING,
+                                    mRequestCode == REQUEST_CODE_WIRELESS_CHARGING_SOUND);
+                            return;
+                        }
+
+                        String mimeType = requireContext().getContentResolver().getType(uri);
+                        if (mimeType == null) {
+                            Log.e(TAG, "call to updateChargingSounds for URI:" + uri
+                                    + " ignored: failure to find mimeType "
+                                    + "(no access from this context?)");
+                            return;
+                        }
+
+                        if (!isSupportedMimeType(mimeType)) {
+                            Log.e(TAG, "call to updateChargingSounds for URI:" + uri
+                                    + " ignored: associated mimeType:" + mimeType
+                                    + " is not an audio type");
+                            return;
+                        }
+
+                        updateChargingSounds(uri.toString(),
+                                mRequestCode == REQUEST_CODE_WIRELESS_CHARGING_SOUND);
+            });
+
+    private boolean isSupportedMimeType(String mimeType) {
+        return mimeType.startsWith("audio/") || mimeType.equals("application/ogg");
+    }
+
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         addPreferencesFromResource(R.xml.charging_sounds_settings);
 
-        Vibrator vibrator = getActivity().getSystemService(Vibrator.class);
+        Vibrator vibrator = requireActivity().getSystemService(Vibrator.class);
         if (vibrator == null || !vibrator.hasVibrator()) {
             removePreference(KEY_CHARGING_VIBRATION_ENABLED);
         }
@@ -72,7 +119,7 @@
     }
 
     @Override
-    public void onViewCreated(View view, Bundle savedInstanceState) {
+    public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
         super.onViewCreated(view, savedInstanceState);
 
         final String currentWiredChargingSound = Settings.Global.getString(getContentResolver(),
@@ -82,16 +129,16 @@
 
         // Convert default sound file path to a media uri so that we can
         // set a proper default for the ringtone picker.
-        mDefaultWiredChargingSoundUri = audioFileToUri(getContext(),
+        mDefaultWiredChargingSoundUri = audioFileToUri(requireContext(),
                 DEFAULT_WIRED_CHARGING_SOUND);
-        mDefaultWirelessChargingSoundUri = audioFileToUri(getContext(),
+        mDefaultWirelessChargingSoundUri = audioFileToUri(requireContext(),
                 DEFAULT_WIRELESS_CHARGING_SOUND);
 
         updateChargingSounds(currentWiredChargingSound, false /* wireless */);
         updateChargingSounds(currentWirelessChargingSound, true /* wireless */);
     }
 
-    private Uri audioFileToUri(Context context, String audioFile) {
+    private Uri audioFileToUri(@NonNull Context context, String audioFile) {
         Cursor cursor = context.getContentResolver().query(
                 MediaStore.Audio.Media.INTERNAL_CONTENT_URI,
                 new String[] { MediaStore.Audio.Media._ID },
@@ -185,44 +232,10 @@
         }
         if (toneUriString != null && !toneUriString.equals(RINGTONE_SILENT_URI_STRING)) {
             Uri uri = Uri.parse(toneUriString);
-            if (uri != null) {
-                intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, uri);
-            }
+            intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, uri);
         }
-        startActivityForResult(intent, requestCode);
-    }
-
-    @Override
-    public void onActivityResult(int requestCode, int resultCode, Intent data) {
-        super.onActivityResult(requestCode, resultCode, data);
-
-        if ((requestCode == REQUEST_CODE_WIRED_CHARGING_SOUND ||
-                requestCode == REQUEST_CODE_WIRELESS_CHARGING_SOUND) &&
-                resultCode == Activity.RESULT_OK) {
-            Uri uri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
-
-            if (uri == null) {
-                updateChargingSounds(RINGTONE_SILENT_URI_STRING,
-                        requestCode == REQUEST_CODE_WIRELESS_CHARGING_SOUND);
-                return;
-            }
-
-            String mimeType = getContext().getContentResolver().getType(uri);
-            if (mimeType == null) {
-                Log.e(TAG, "call to updateChargingSounds for URI:" + uri
-                        + " ignored: failure to find mimeType (no access from this context?)");
-                return;
-            }
-
-            if (!(mimeType.startsWith("audio/") || mimeType.equals("application/ogg"))) {
-                Log.e(TAG, "call to updateChargingSounds for URI:" + uri
-                        + " ignored: associated mimeType:" + mimeType + " is not an audio type");
-                return;
-            }
-
-            updateChargingSounds(uri.toString(),
-                    requestCode == REQUEST_CODE_WIRELESS_CHARGING_SOUND);
-        }
+        mRequestCode = requestCode;
+        mActivityResultLauncher.launch(intent);
     }
 
     public static final Searchable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
diff --git a/src/org/lineageos/lineageparts/statusbar/NetworkTrafficSettings.java b/src/org/lineageos/lineageparts/statusbar/NetworkTrafficSettings.java
index 81655de..316f615 100644
--- a/src/org/lineageos/lineageparts/statusbar/NetworkTrafficSettings.java
+++ b/src/org/lineageos/lineageparts/statusbar/NetworkTrafficSettings.java
@@ -8,7 +8,6 @@
 import android.content.ContentResolver;
 import android.os.Bundle;
 import android.view.View;
-import android.widget.Toast;
 
 import androidx.preference.DropDownPreference;
 import androidx.preference.Preference;
@@ -103,16 +102,16 @@
     @Override
     public boolean onPreferenceChange(Preference preference, Object newValue) {
         if (preference == mNetTrafficMode) {
-            int mode = Integer.valueOf((String) newValue);
+            int mode = Integer.parseInt((String) newValue);
             LineageSettings.Secure.putInt(getActivity().getContentResolver(),
                     LineageSettings.Secure.NETWORK_TRAFFIC_MODE, mode);
             updateEnabledStates(mode);
         } else if (preference == mNetTrafficPosition) {
-            int position = Integer.valueOf((String) newValue);
+            int position = Integer.parseInt((String) newValue);
             LineageSettings.Secure.putInt(getActivity().getContentResolver(),
                     LineageSettings.Secure.NETWORK_TRAFFIC_POSITION, position);
         } else if (preference == mNetTrafficUnits) {
-            int units = Integer.valueOf((String) newValue);
+            int units = Integer.parseInt((String) newValue);
             LineageSettings.Secure.putInt(getActivity().getContentResolver(),
                     LineageSettings.Secure.NETWORK_TRAFFIC_UNITS, units);
         }
diff --git a/src/org/lineageos/lineageparts/statusbar/StatusBarSettings.java b/src/org/lineageos/lineageparts/statusbar/StatusBarSettings.java
index 1a3309f..d256392 100644
--- a/src/org/lineageos/lineageparts/statusbar/StatusBarSettings.java
+++ b/src/org/lineageos/lineageparts/statusbar/StatusBarSettings.java
@@ -5,26 +5,21 @@
  */
 package org.lineageos.lineageparts.statusbar;
 
-import android.content.Context;
 import android.os.Bundle;
 import android.provider.Settings;
-import android.text.format.DateFormat;
 import android.text.TextUtils;
-import android.util.ArraySet;
+import android.text.format.DateFormat;
 import android.view.View;
 
 import androidx.preference.Preference;
 import androidx.preference.PreferenceCategory;
-import androidx.preference.PreferenceScreen;
-
-import lineageos.preference.LineageSystemSettingListPreference;
-import lineageos.providers.LineageSettings;
 
 import org.lineageos.lineageparts.R;
 import org.lineageos.lineageparts.SettingsPreferenceFragment;
 import org.lineageos.lineageparts.utils.DeviceUtils;
 
-import java.util.Set;
+import lineageos.preference.LineageSystemSettingListPreference;
+import lineageos.providers.LineageSettings;
 
 public class StatusBarSettings extends SettingsPreferenceFragment
         implements Preference.OnPreferenceChangeListener {
diff --git a/src/org/lineageos/lineageparts/trust/TrustPreferences.java b/src/org/lineageos/lineageparts/trust/TrustPreferences.java
index 7fdfddd..6bdb9cf 100644
--- a/src/org/lineageos/lineageparts/trust/TrustPreferences.java
+++ b/src/org/lineageos/lineageparts/trust/TrustPreferences.java
@@ -1,5 +1,5 @@
 /*
- * SPDX-FileCopyrightText: 2018-2022 The LineageOS Project
+ * SPDX-FileCopyrightText: 2018-2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 
@@ -190,7 +190,7 @@
     }
 
     private boolean showInfo(int text) {
-        new AlertDialog.Builder(getContext())
+        new AlertDialog.Builder(requireContext())
             .setMessage(text)
             .show();
         return true;
@@ -199,23 +199,23 @@
     private void updateSmsSecuritySummary(int selection) {
         String value = String.valueOf(selection);
         String message = selection > 0
-                ? getContext().getString(R.string.sms_security_check_limit_summary, value)
-                : getContext().getString(R.string.sms_security_check_limit_summary_none);
+                ? requireContext().getString(R.string.sms_security_check_limit_summary, value)
+                : requireContext().getString(R.string.sms_security_check_limit_summary_none);
         mSmsLimitPref.setSummary(message);
     }
 
     private boolean onSmsLimitChanged(Integer value) {
-        Settings.Global.putInt(getContext().getContentResolver(),
+        Settings.Global.putInt(requireContext().getContentResolver(),
                 Settings.Global.SMS_OUTGOING_CHECK_MAX_COUNT, value);
         updateSmsSecuritySummary(value);
         return true;
     }
 
     private boolean onWarningChanged(Boolean value, int feature) {
-        int original = LineageSettings.Secure.getInt(getContext().getContentResolver(),
+        int original = LineageSettings.Secure.getInt(requireContext().getContentResolver(),
                 LineageSettings.Secure.TRUST_WARNINGS, TrustInterface.TRUST_WARN_MAX_VALUE);
         int newValue = value ? (original | feature) : (original & ~feature);
-        boolean success = LineageSettings.Secure.putInt(getContext().getContentResolver(),
+        boolean success = LineageSettings.Secure.putInt(requireContext().getContentResolver(),
                 LineageSettings.Secure.TRUST_WARNINGS,
                 newValue & TrustInterface.TRUST_WARN_MAX_VALUE);
         if (success && !value) {
diff --git a/src/org/lineageos/lineageparts/utils/DeviceUtils.java b/src/org/lineageos/lineageparts/utils/DeviceUtils.java
index 2417551..e68d855 100644
--- a/src/org/lineageos/lineageparts/utils/DeviceUtils.java
+++ b/src/org/lineageos/lineageparts/utils/DeviceUtils.java
@@ -1,6 +1,6 @@
 /*
  * SPDX-FileCopyrightText: 2016 The CyanogenMod project
- * SPDX-FileCopyrightText: 2017-2022 The LineageOS project
+ * SPDX-FileCopyrightText: 2017-2023 The LineageOS project
  * SPDX-License-Identifier: Apache-2.0
  */
 package org.lineageos.lineageparts.utils;
@@ -9,7 +9,7 @@
 import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
 
 import android.app.Activity;
-import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothManager;
 import android.content.Context;
 import android.content.pm.ActivityInfo;
 import android.content.pm.PackageInfo;
@@ -34,6 +34,8 @@
 
 import static org.lineageos.internal.util.DeviceKeysConstants.*;
 
+import androidx.annotation.NonNull;
+
 public class DeviceUtils {
 
     /* returns whether the device has a centered display cutout or not. */
@@ -172,7 +174,8 @@
     public static boolean isPackageInstalled(Context context, String pkg, boolean ignoreState) {
         if (pkg != null) {
             try {
-                PackageInfo pi = context.getPackageManager().getPackageInfo(pkg, 0);
+                PackageInfo pi = context.getPackageManager().getPackageInfo(pkg,
+                        PackageManager.PackageInfoFlags.of(0));
                 if (!pi.applicationInfo.enabled && !ignoreState) {
                     return false;
                 }
@@ -230,15 +233,17 @@
         return telephonyManager.isDataCapable();
     }
 
-    public static boolean deviceSupportsBluetooth() {
-        return (BluetoothAdapter.getDefaultAdapter() != null);
+    public static boolean deviceSupportsBluetooth(Context ctx) {
+        BluetoothManager bluetoothManager = (BluetoothManager)
+                ctx.getSystemService(Context.BLUETOOTH_SERVICE);
+        return (bluetoothManager.getAdapter() != null);
     }
 
     public static boolean deviceSupportsNfc(Context ctx) {
         return NfcAdapter.getDefaultAdapter(ctx) != null;
     }
 
-    public static boolean deviceSupportsFlashLight(Context context) {
+    public static boolean deviceSupportsFlashLight(@NonNull Context context) {
         CameraManager cameraManager = context.getSystemService(CameraManager.class);
         try {
             String[] ids = cameraManager.getCameraIdList();
diff --git a/src/org/lineageos/lineageparts/utils/TelephonyUtils.java b/src/org/lineageos/lineageparts/utils/TelephonyUtils.java
index af1d1d1..83c2b53 100644
--- a/src/org/lineageos/lineageparts/utils/TelephonyUtils.java
+++ b/src/org/lineageos/lineageparts/utils/TelephonyUtils.java
@@ -1,14 +1,14 @@
 /*
  * SPDX-FileCopyrightText: 2016 The CyanogenMod Project
+ * SPDX-FileCopyrightText: 2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 package org.lineageos.lineageparts.utils;
 
 import android.content.Context;
-import android.content.pm.PackageManager;
-import android.content.res.Resources;
 import android.telephony.TelephonyManager;
-import android.util.Log;
+
+import androidx.annotation.NonNull;
 
 public class TelephonyUtils {
 
@@ -17,19 +17,8 @@
     /**
      * Returns whether the device is voice-capable (meaning, it is also a phone).
      */
-    public static boolean isVoiceCapable(Context context) {
+    public static boolean isVoiceCapable(@NonNull Context context) {
         TelephonyManager telephony = context.getSystemService(TelephonyManager.class);
         return telephony != null && telephony.isVoiceCapable();
     }
-
-    private static Resources getPhoneResources(Context context) {
-        try {
-            final Context packageContext = context.createPackageContext("com.android.phone", 0);
-            return packageContext.getResources();
-        } catch (PackageManager.NameNotFoundException e) {
-            e.printStackTrace();
-        }
-        Log.w(TAG, "couldn't locate resources for com.android.phone!");
-        return null;
-    }
 }
diff --git a/src/org/lineageos/lineageparts/widget/HighlightablePreferenceGroupAdapter.java b/src/org/lineageos/lineageparts/widget/HighlightablePreferenceGroupAdapter.java
index a9cf7aa..9c02fe7 100644
--- a/src/org/lineageos/lineageparts/widget/HighlightablePreferenceGroupAdapter.java
+++ b/src/org/lineageos/lineageparts/widget/HighlightablePreferenceGroupAdapter.java
@@ -1,6 +1,6 @@
 /*
  * SPDX-FileCopyrightText: 2018 The Android Open Source Project
- * SPDX-FileCopyrightText: 2020 The LineageOS Project
+ * SPDX-FileCopyrightText: 2020-2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 
@@ -17,10 +17,10 @@
 import android.util.TypedValue;
 import android.view.View;
 
+import androidx.annotation.NonNull;
 import androidx.annotation.VisibleForTesting;
 import androidx.preference.PreferenceGroup;
 import androidx.preference.PreferenceGroupAdapter;
-import androidx.preference.PreferenceScreen;
 import androidx.preference.PreferenceViewHolder;
 import androidx.recyclerview.widget.RecyclerView;
 
@@ -59,7 +59,7 @@
     }
 
     @Override
-    public void onBindViewHolder(PreferenceViewHolder holder, int position) {
+    public void onBindViewHolder(@NonNull PreferenceViewHolder holder, int position) {
         super.onBindViewHolder(holder, position);
         updateBackground(holder, position);
     }
diff --git a/src/org/lineageos/lineageparts/widget/PackageListAdapter.java b/src/org/lineageos/lineageparts/widget/PackageListAdapter.java
index 981e891..a38ae70 100644
--- a/src/org/lineageos/lineageparts/widget/PackageListAdapter.java
+++ b/src/org/lineageos/lineageparts/widget/PackageListAdapter.java
@@ -1,6 +1,6 @@
 /*
  * SPDX-FileCopyrightText: 2012-2014 The CyanogenMod Project
- * SPDX-FileCopyrightText: 2022 The LineageOS Project
+ * SPDX-FileCopyrightText: 2022-2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 
@@ -150,7 +150,8 @@
     public void run() {
         final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
         mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
-        List<ResolveInfo> installedAppsInfo = mPm.queryIntentActivities(mainIntent, 0);
+        List<ResolveInfo> installedAppsInfo = mPm.queryIntentActivities(mainIntent,
+                PackageManager.ResolveInfoFlags.of(0));
 
         for (ResolveInfo info : installedAppsInfo) {
             ApplicationInfo appInfo = info.activityInfo.applicationInfo;
@@ -169,7 +170,8 @@
                 continue;
             }
             try {
-                ApplicationInfo appInfo = mPm.getApplicationInfo(packageName, 0);
+                ApplicationInfo appInfo = mPm.getApplicationInfo(packageName,
+                        PackageManager.ApplicationInfoFlags.of(0));
                 final PackageItem item = new PackageItem(appInfo.packageName,
                         appInfo.loadLabel(mPm), appInfo.loadIcon(mPm));
                 mHandler.obtainMessage(0, item).sendToTarget();
diff --git a/src/org/lineageos/lineageparts/widget/RingtonePreference.java b/src/org/lineageos/lineageparts/widget/RingtonePreference.java
index a4cb833..4cb64ca 100644
--- a/src/org/lineageos/lineageparts/widget/RingtonePreference.java
+++ b/src/org/lineageos/lineageparts/widget/RingtonePreference.java
@@ -1,5 +1,6 @@
 /*
  * SPDX-FileCopyrightText: 2007 The Android Open Source Project
+ * SPDX-FileCopyrightText: 2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 
@@ -31,7 +32,7 @@
  * @attr ref android.R.styleable#RingtonePreference_ringtoneType
  * @attr ref android.R.styleable#RingtonePreference_showDefault
  * @attr ref android.R.styleable#RingtonePreference_showSilent
- *
+ * <p>
  * Based of frameworks/base/core/java/android/preference/RingtonePreference.java
  * but extends androidx.preference.Preference instead.
  */
@@ -43,73 +44,35 @@
     private boolean mShowDefault;
     private boolean mShowSilent;
 
-    private int mRequestCode;
-
     public RingtonePreference(Context context, AttributeSet attrs) {
         super(context, attrs);
 
-        final TypedArray a = context.obtainStyledAttributes(attrs,
-                com.android.internal.R.styleable.RingtonePreference, 0, 0);
-        mRingtoneType = a.getInt(com.android.internal.R.styleable.RingtonePreference_ringtoneType,
-                RingtoneManager.TYPE_RINGTONE);
-        mShowDefault = a.getBoolean(com.android.internal.R.styleable.RingtonePreference_showDefault,
-                true);
-        mShowSilent = a.getBoolean(com.android.internal.R.styleable.RingtonePreference_showSilent,
-                true);
-        setIntent(new Intent(RingtoneManager.ACTION_RINGTONE_PICKER));
-        a.recycle();
+        try (TypedArray a = context.obtainStyledAttributes(attrs,
+                com.android.internal.R.styleable.RingtonePreference, 0, 0)) {
+
+            mRingtoneType = a.getInt(
+                    com.android.internal.R.styleable.RingtonePreference_ringtoneType,
+                    RingtoneManager.TYPE_RINGTONE);
+            mShowDefault = a.getBoolean(
+                    com.android.internal.R.styleable.RingtonePreference_showDefault,
+                    true);
+            mShowSilent = a.getBoolean(
+                    com.android.internal.R.styleable.RingtonePreference_showSilent,
+                    true);
+            setIntent(new Intent(RingtoneManager.ACTION_RINGTONE_PICKER));
+        }
     }
 
     /**
      * Returns the sound type(s) that are shown in the picker.
      *
      * @return The sound type(s) that are shown in the picker.
-     * @see #setRingtoneType(int)
      */
     public int getRingtoneType() {
         return mRingtoneType;
     }
 
     /**
-     * Sets the sound type(s) that are shown in the picker.
-     *
-     * @param type The sound type(s) that are shown in the picker.
-     * @see RingtoneManager#EXTRA_RINGTONE_TYPE
-     */
-    public void setRingtoneType(int type) {
-        mRingtoneType = type;
-    }
-
-    /**
-     * Returns whether to a show an item for the default sound/ringtone.
-     *
-     * @return Whether to show an item for the default sound/ringtone.
-     */
-    public boolean getShowDefault() {
-        return mShowDefault;
-    }
-
-    /**
-     * Sets whether to show an item for the default sound/ringtone. The default
-     * to use will be deduced from the sound type(s) being shown.
-     *
-     * @param showDefault Whether to show the default or not.
-     * @see RingtoneManager#EXTRA_RINGTONE_SHOW_DEFAULT
-     */
-    public void setShowDefault(boolean showDefault) {
-        mShowDefault = showDefault;
-    }
-
-    /**
-     * Returns whether to a show an item for 'Silent'.
-     *
-     * @return Whether to show an item for 'Silent'.
-     */
-    public boolean getShowSilent() {
-        return mShowSilent;
-    }
-
-    /**
      * Sets whether to show an item for 'Silent'.
      *
      * @param showSilent Whether to show 'Silent'.
@@ -119,10 +82,6 @@
         mShowSilent = showSilent;
     }
 
-    public int getRequestCode() {
-        return mRequestCode;
-    }
-
     /**
      * Prepares the intent to launch the ringtone picker. This can be modified
      * to adjust the parameters of the ringtone picker.
@@ -205,7 +164,7 @@
 
     public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
         if (data != null) {
-            Uri uri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
+            Uri uri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI, Uri.class);
 
             if (callChangeListener(uri != null ? uri.toString() : "")) {
                 onSaveRingtone(uri);
@@ -214,5 +173,4 @@
 
         return true;
     }
-
 }
diff --git a/src/org/lineageos/lineageparts/widget/RtlCompatibleViewPager.java b/src/org/lineageos/lineageparts/widget/RtlCompatibleViewPager.java
index 046743e..8cda8e8 100644
--- a/src/org/lineageos/lineageparts/widget/RtlCompatibleViewPager.java
+++ b/src/org/lineageos/lineageparts/widget/RtlCompatibleViewPager.java
@@ -1,6 +1,6 @@
 /*
  * SPDX-FileCopyrightText: 2016 The Android Open Source Project
- * SPDX-FileCopyrightText: 2020 The LineageOS Project
+ * SPDX-FileCopyrightText: 2020-2023 The LineageOS Project
  * SPDX-License-Identifier: Apache-2.0
  */
 
@@ -112,7 +112,7 @@
         }
 
         public static final Parcelable.ClassLoaderCreator<RtlSavedState> CREATOR
-                = new Parcelable.ClassLoaderCreator<RtlSavedState>() {
+                = new Parcelable.ClassLoaderCreator<>() {
             @Override
             public RtlSavedState createFromParcel(Parcel source,
                     ClassLoader loader) {