diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index a2d7c21..3a6d748 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -7,6 +7,7 @@
         <option name="testRunner" value="GRADLE" />
         <option name="distributionType" value="DEFAULT_WRAPPED" />
         <option name="externalProjectPath" value="$PROJECT_DIR$" />
+        <option name="gradleJvm" value="1.8" />
         <option name="modules">
           <set>
             <option value="$PROJECT_DIR$" />
diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml
deleted file mode 100644
index f4c45ba..0000000
--- a/.idea/kotlinc.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="KotlinJpsPluginSettings">
-    <option name="version" value="1.8.20-release" />
-  </component>
-</project>
\ No newline at end of file
diff --git a/app/src/main/java/org/omnirom/control/BatteryLightSettingsFragment.java b/app/src/main/java/org/omnirom/control/BatteryLightSettingsFragment.java
index a67d5c3..08ddd7a 100644
--- a/app/src/main/java/org/omnirom/control/BatteryLightSettingsFragment.java
+++ b/app/src/main/java/org/omnirom/control/BatteryLightSettingsFragment.java
@@ -1,246 +1,246 @@
-/*
- * Copyright (C) 2012 The CyanogenMod Project
- * Copyright (C) 2021 The OmniROM Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.omnirom.control;
-
-import android.content.ContentResolver;
-import android.content.Context;
-import android.content.res.Resources;
-import android.os.Bundle;
-import android.os.UserHandle;
-import android.provider.Settings;
-
-import androidx.annotation.DrawableRes;
-import androidx.annotation.XmlRes;
-import androidx.preference.Preference;
-import androidx.preference.PreferenceGroup;
-import androidx.preference.PreferenceScreen;
-
-import org.omnirom.control.R;
-import org.omnirom.omnilib.preference.SystemSettingsColorSelectPreference;
-import org.omnirom.omnilib.preference.SystemSettingSwitchPreference;
-
-public class BatteryLightSettingsFragment extends AbstractSettingsFragment implements
-                    Preference.OnPreferenceChangeListener {
-
-    private static final String DEFAULT_VALUES = "reset_to_default_key";
-    private static final String LOW_COLOR_PREF = "battery_light_low_color";
-    private static final String MEDIUM_COLOR_PREF = "battery_light_medium_color";
-    private static final String FULL_COLOR_PREF = "battery_light_full_color";
-    private static final String REALLY_FULL_COLOR_PREF = "battery_light_really_full_color";
-    private static final String FAST_COLOR_PREF = "fast_battery_light_color";
-    private static final String FAST_CHARGING_LED_PREF = "fast_charging_led_enabled";
-    private static final String BATTERY_DND_PREF = "battery_light_allow_on_dnd";
-    private static final String BATTERY_LIGHT_PREF = "battery_light_enabled";
-    private static final String BATTERY_PULSE_PREF = "battery_light_pulse";
-    private static final String BATTERY_LIGHT_ONLY_FULL_PREF = "battery_light_only_fully_charged";
-    private static final String KEY_CATEGORY_FAST_CHARGE = "fast_color_cat";
-    private static final String KEY_CATEGORY_CHARGE_COLORS = "colors_list";
-
-    private SystemSettingsColorSelectPreference mLowColorPref;
-    private SystemSettingsColorSelectPreference mMediumColorPref;
-    private SystemSettingsColorSelectPreference mFullColorPref;
-    private SystemSettingsColorSelectPreference mReallyFullColorPref;
-    private SystemSettingsColorSelectPreference mFastColorPref;
-    private Preference mDefaultValues;
-    private SystemSettingSwitchPreference mDndPref;
-    private SystemSettingSwitchPreference mEnabledPref;
-    private SystemSettingSwitchPreference mPulsePref;
-    private SystemSettingSwitchPreference mOnlyFullPref;
-    private SystemSettingSwitchPreference mFastBatteryLightEnabledPref;
-
-    public static final @DrawableRes int ICON_RES = R.drawable.ic_settings_leds;
-    public static final @XmlRes int XML_RES = R.xml.battery_light_settings_preferences;
-
-    public static boolean isEnabled(Context context) {
-        return context.getResources().getBoolean(com.android.internal.R.bool.config_intrusiveBatteryLed);
-    }
-
-    @Override
-    public String getFragmentTitle() {
-        return getString(R.string.batterylight_title);
-    }
-
-    @Override
-    public String getFragmentSummary() {
-        return getString(R.string.batterylight_summary);
-    }
-
-    @Override
-    public int getFragmentIcon() {
-        return ICON_RES;
-    }
-
-    @Override
-    public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
-        setPreferencesFromResource(XML_RES, rootKey);
-
-        PreferenceScreen prefSet = getPreferenceScreen();
-        ContentResolver resolver = getContext().getContentResolver();
-        Resources res = getResources();
-
-        mDefaultValues = (Preference) findPreference(DEFAULT_VALUES);
-        mDefaultValues.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
-            @Override
-            public boolean onPreferenceClick(Preference preference) {
-                resetToDefaults();
-                return true;
-            }
-        });
-
-        mDndPref = (SystemSettingSwitchPreference) findPreference(BATTERY_DND_PREF);
-        mEnabledPref = (SystemSettingSwitchPreference) findPreference(BATTERY_LIGHT_PREF);
-        mPulsePref = (SystemSettingSwitchPreference) findPreference(BATTERY_PULSE_PREF);
-        mOnlyFullPref = (SystemSettingSwitchPreference) findPreference(BATTERY_LIGHT_ONLY_FULL_PREF);
-        mOnlyFullPref.setOnPreferenceChangeListener(this);
-
-        // Does the Device support changing battery LED colors?
-        if (getResources().getBoolean(R.bool.config_multiColorBatteryLed)) {
-
-            mFastBatteryLightEnabledPref = (SystemSettingSwitchPreference) findPreference(FAST_CHARGING_LED_PREF);
-
-            // Low, Medium and full color preferences
-            mLowColorPref = (SystemSettingsColorSelectPreference) findPreference(LOW_COLOR_PREF);
-            mLowColorPref.setDefaultValue(res.getInteger(com.android.internal.R.integer.config_notificationsBatteryLowARGB));
-
-            mMediumColorPref = (SystemSettingsColorSelectPreference) findPreference(MEDIUM_COLOR_PREF);
-            mMediumColorPref.setDefaultValue(res.getInteger(com.android.internal.R.integer.config_notificationsBatteryMediumARGB));
-
-            mFullColorPref = (SystemSettingsColorSelectPreference) findPreference(FULL_COLOR_PREF);
-            mFullColorPref.setDefaultValue(res.getInteger(com.android.internal.R.integer.config_notificationsBatteryFullARGB));
-
-            mReallyFullColorPref = (SystemSettingsColorSelectPreference) findPreference(REALLY_FULL_COLOR_PREF);
-            mReallyFullColorPref.setDefaultValue(res.getInteger(com.android.internal.R.integer.config_notificationsBatteryFullARGB));
-
-            mFastColorPref = (SystemSettingsColorSelectPreference) findPreference(FAST_COLOR_PREF);
-            mFastColorPref.setDefaultValue(res.getInteger(com.android.internal.R.integer.config_notificationsFastBatteryARGB));
-
-            // Does the Device support fast charge ?
-            if (!getResources().getBoolean(R.bool.config_FastChargingLedSupported)) {
-                prefSet.removePreference(prefSet.findPreference(KEY_CATEGORY_FAST_CHARGE));
-            }
-        } else {
-            prefSet.removePreference(prefSet.findPreference(KEY_CATEGORY_CHARGE_COLORS));
-            // not multi color cant have fast charge
-            prefSet.removePreference(prefSet.findPreference(KEY_CATEGORY_FAST_CHARGE));
-        }
-        boolean showOnlyWhenFull = Settings.System.getInt(resolver,
-                Settings.System.OMNI_BATTERY_LIGHT_ONLY_FULLY_CHARGED, 1) != 0;
-        updateEnablement(showOnlyWhenFull);
-    }
-
-    @Override
-    public void onResume() {
-        super.onResume();
-        refreshDefault();
-    }
-
-    @Override
-    public boolean onPreferenceChange(Preference preference, Object objValue) {
-        if (preference == mOnlyFullPref) {
-            boolean value = (Boolean) objValue;
-            // If enabled, disable all but really full color preference.
-            updateEnablement(value);
-        }
-        return true;
-    }
-
-    private void updateEnablement(boolean showOnlyWhenFull) {
-        // If enabled, disable all but really full color preference.
-        if (mLowColorPref != null) {
-            mLowColorPref.setEnabled(!showOnlyWhenFull);
-        }
-        if (mMediumColorPref != null) {
-            mMediumColorPref.setEnabled(!showOnlyWhenFull);
-        }
-        if (mFullColorPref != null) {
-            mFullColorPref.setEnabled(!showOnlyWhenFull);
-        }
-        if (mFastColorPref != null) {
-            mFastColorPref.setEnabled(!showOnlyWhenFull);
-        }
-        if (mFastBatteryLightEnabledPref != null) {
-            mFastBatteryLightEnabledPref.setEnabled(!showOnlyWhenFull);
-        }
-    }
-
-    protected void resetToDefaults() {
-        if (mDndPref != null) {
-            mDndPref.setChecked(false);
-        }
-        if (mEnabledPref != null) {
-            mEnabledPref.setChecked(true);
-        }
-        if (mPulsePref != null) {
-            mPulsePref.setChecked(false);
-        }
-        if (mOnlyFullPref != null) {
-            mOnlyFullPref.setChecked(false);
-        }
-        if (mFastBatteryLightEnabledPref != null) {
-            mFastBatteryLightEnabledPref.setChecked(false);
-        }
-        resetColors();
-        boolean showOnlyWhenFull = Settings.System.getInt(getContext().getContentResolver(),
-                Settings.System.OMNI_BATTERY_LIGHT_ONLY_FULLY_CHARGED, 1) != 0;
-        updateEnablement(showOnlyWhenFull);
-    }
-
-    protected void resetColors() {
-        if (mLowColorPref != null) {
-            mLowColorPref.resetToDefaultValue();
-        }
-
-        if (mMediumColorPref != null) {
-            mMediumColorPref.resetToDefaultValue();
-        }
-
-        if (mFullColorPref != null) {
-            mFullColorPref.resetToDefaultValue();
-        }
-
-        if (mReallyFullColorPref != null) {
-            mReallyFullColorPref.resetToDefaultValue();
-        }
-
-        if (mFastColorPref != null) {
-            mFastColorPref.resetToDefaultValue();
-        }
-    }
-
-    private void refreshDefault() {
-        if (mLowColorPref != null) {
-            mLowColorPref.updateColor();
-        }
-
-        if (mMediumColorPref != null) {
-            mMediumColorPref.updateColor();
-        }
-
-        if (mFullColorPref != null) {
-            mFullColorPref.updateColor();
-        }
-
-        if (mReallyFullColorPref != null) {
-            mReallyFullColorPref.updateColor();
-        }
-
-        if (mFastColorPref != null) {
-            mFastColorPref.updateColor();
-        }
-    }
-}
+///*
+// * Copyright (C) 2012 The CyanogenMod Project
+// * Copyright (C) 2021 The OmniROM Project
+// *
+// * Licensed under the Apache License, Version 2.0 (the "License");
+// * you may not use this file except in compliance with the License.
+// * You may obtain a copy of the License at
+// *
+// *      http://www.apache.org/licenses/LICENSE-2.0
+// *
+// * Unless required by applicable law or agreed to in writing, software
+// * distributed under the License is distributed on an "AS IS" BASIS,
+// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// * See the License for the specific language governing permissions and
+// * limitations under the License.
+// */
+//
+//package org.omnirom.control;
+//
+//import android.content.ContentResolver;
+//import android.content.Context;
+//import android.content.res.Resources;
+//import android.os.Bundle;
+//import android.os.UserHandle;
+//import android.provider.Settings;
+//
+//import androidx.annotation.DrawableRes;
+//import androidx.annotation.XmlRes;
+//import androidx.preference.Preference;
+//import androidx.preference.PreferenceGroup;
+//import androidx.preference.PreferenceScreen;
+//
+//import org.omnirom.control.R;
+//import org.omnirom.omnilib.preference.SystemSettingsColorSelectPreference;
+//import org.omnirom.omnilib.preference.SystemSettingSwitchPreference;
+//
+//public class BatteryLightSettingsFragment extends AbstractSettingsFragment implements
+//                    Preference.OnPreferenceChangeListener {
+//
+//    private static final String DEFAULT_VALUES = "reset_to_default_key";
+//    private static final String LOW_COLOR_PREF = "battery_light_low_color";
+//    private static final String MEDIUM_COLOR_PREF = "battery_light_medium_color";
+//    private static final String FULL_COLOR_PREF = "battery_light_full_color";
+//    private static final String REALLY_FULL_COLOR_PREF = "battery_light_really_full_color";
+//    private static final String FAST_COLOR_PREF = "fast_battery_light_color";
+//    private static final String FAST_CHARGING_LED_PREF = "fast_charging_led_enabled";
+//    private static final String BATTERY_DND_PREF = "battery_light_allow_on_dnd";
+//    private static final String BATTERY_LIGHT_PREF = "battery_light_enabled";
+//    private static final String BATTERY_PULSE_PREF = "battery_light_pulse";
+//    private static final String BATTERY_LIGHT_ONLY_FULL_PREF = "battery_light_only_fully_charged";
+//    private static final String KEY_CATEGORY_FAST_CHARGE = "fast_color_cat";
+//    private static final String KEY_CATEGORY_CHARGE_COLORS = "colors_list";
+//
+//    private SystemSettingsColorSelectPreference mLowColorPref;
+//    private SystemSettingsColorSelectPreference mMediumColorPref;
+//    private SystemSettingsColorSelectPreference mFullColorPref;
+//    private SystemSettingsColorSelectPreference mReallyFullColorPref;
+//    private SystemSettingsColorSelectPreference mFastColorPref;
+//    private Preference mDefaultValues;
+//    private SystemSettingSwitchPreference mDndPref;
+//    private SystemSettingSwitchPreference mEnabledPref;
+//    private SystemSettingSwitchPreference mPulsePref;
+//    private SystemSettingSwitchPreference mOnlyFullPref;
+//    private SystemSettingSwitchPreference mFastBatteryLightEnabledPref;
+//
+//    public static final @DrawableRes int ICON_RES = R.drawable.ic_settings_leds;
+//    public static final @XmlRes int XML_RES = R.xml.battery_light_settings_preferences;
+//
+//    public static boolean isEnabled(Context context) {
+//        return context.getResources().getBoolean(com.android.internal.R.bool.config_intrusiveBatteryLed);
+//    }
+//
+//    @Override
+//    public String getFragmentTitle() {
+//        return getString(R.string.batterylight_title);
+//    }
+//
+//    @Override
+//    public String getFragmentSummary() {
+//        return getString(R.string.batterylight_summary);
+//    }
+//
+//    @Override
+//    public int getFragmentIcon() {
+//        return ICON_RES;
+//    }
+//
+//    @Override
+//    public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
+//        setPreferencesFromResource(XML_RES, rootKey);
+//
+//        PreferenceScreen prefSet = getPreferenceScreen();
+//        ContentResolver resolver = getContext().getContentResolver();
+//        Resources res = getResources();
+//
+//        mDefaultValues = (Preference) findPreference(DEFAULT_VALUES);
+//        mDefaultValues.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
+//            @Override
+//            public boolean onPreferenceClick(Preference preference) {
+//                resetToDefaults();
+//                return true;
+//            }
+//        });
+//
+//        mDndPref = (SystemSettingSwitchPreference) findPreference(BATTERY_DND_PREF);
+//        mEnabledPref = (SystemSettingSwitchPreference) findPreference(BATTERY_LIGHT_PREF);
+//        mPulsePref = (SystemSettingSwitchPreference) findPreference(BATTERY_PULSE_PREF);
+//        mOnlyFullPref = (SystemSettingSwitchPreference) findPreference(BATTERY_LIGHT_ONLY_FULL_PREF);
+//        mOnlyFullPref.setOnPreferenceChangeListener(this);
+//
+//        // Does the Device support changing battery LED colors?
+//        if (getResources().getBoolean(R.bool.config_multiColorBatteryLed)) {
+//
+//            mFastBatteryLightEnabledPref = (SystemSettingSwitchPreference) findPreference(FAST_CHARGING_LED_PREF);
+//
+//            // Low, Medium and full color preferences
+//            mLowColorPref = (SystemSettingsColorSelectPreference) findPreference(LOW_COLOR_PREF);
+//            mLowColorPref.setDefaultValue(res.getInteger(com.android.internal.R.integer.config_notificationsBatteryLowARGB));
+//
+//            mMediumColorPref = (SystemSettingsColorSelectPreference) findPreference(MEDIUM_COLOR_PREF);
+//            mMediumColorPref.setDefaultValue(res.getInteger(com.android.internal.R.integer.config_notificationsBatteryMediumARGB));
+//
+//            mFullColorPref = (SystemSettingsColorSelectPreference) findPreference(FULL_COLOR_PREF);
+//            mFullColorPref.setDefaultValue(res.getInteger(com.android.internal.R.integer.config_notificationsBatteryFullARGB));
+//
+//            mReallyFullColorPref = (SystemSettingsColorSelectPreference) findPreference(REALLY_FULL_COLOR_PREF);
+//            mReallyFullColorPref.setDefaultValue(res.getInteger(com.android.internal.R.integer.config_notificationsBatteryFullARGB));
+//
+//            mFastColorPref = (SystemSettingsColorSelectPreference) findPreference(FAST_COLOR_PREF);
+//            mFastColorPref.setDefaultValue(res.getInteger(com.android.internal.R.integer.config_notificationsFastBatteryARGB));
+//
+//            // Does the Device support fast charge ?
+//            if (!getResources().getBoolean(R.bool.config_FastChargingLedSupported)) {
+//                prefSet.removePreference(prefSet.findPreference(KEY_CATEGORY_FAST_CHARGE));
+//            }
+//        } else {
+//            prefSet.removePreference(prefSet.findPreference(KEY_CATEGORY_CHARGE_COLORS));
+//            // not multi color cant have fast charge
+//            prefSet.removePreference(prefSet.findPreference(KEY_CATEGORY_FAST_CHARGE));
+//        }
+//        boolean showOnlyWhenFull = Settings.System.getInt(resolver,
+//                Settings.System.OMNI_BATTERY_LIGHT_ONLY_FULLY_CHARGED, 1) != 0;
+//        updateEnablement(showOnlyWhenFull);
+//    }
+//
+//    @Override
+//    public void onResume() {
+//        super.onResume();
+//        refreshDefault();
+//    }
+//
+//    @Override
+//    public boolean onPreferenceChange(Preference preference, Object objValue) {
+//        if (preference == mOnlyFullPref) {
+//            boolean value = (Boolean) objValue;
+//            // If enabled, disable all but really full color preference.
+//            updateEnablement(value);
+//        }
+//        return true;
+//    }
+//
+//    private void updateEnablement(boolean showOnlyWhenFull) {
+//        // If enabled, disable all but really full color preference.
+//        if (mLowColorPref != null) {
+//            mLowColorPref.setEnabled(!showOnlyWhenFull);
+//        }
+//        if (mMediumColorPref != null) {
+//            mMediumColorPref.setEnabled(!showOnlyWhenFull);
+//        }
+//        if (mFullColorPref != null) {
+//            mFullColorPref.setEnabled(!showOnlyWhenFull);
+//        }
+//        if (mFastColorPref != null) {
+//            mFastColorPref.setEnabled(!showOnlyWhenFull);
+//        }
+//        if (mFastBatteryLightEnabledPref != null) {
+//            mFastBatteryLightEnabledPref.setEnabled(!showOnlyWhenFull);
+//        }
+//    }
+//
+//    protected void resetToDefaults() {
+//        if (mDndPref != null) {
+//            mDndPref.setChecked(false);
+//        }
+//        if (mEnabledPref != null) {
+//            mEnabledPref.setChecked(true);
+//        }
+//        if (mPulsePref != null) {
+//            mPulsePref.setChecked(false);
+//        }
+//        if (mOnlyFullPref != null) {
+//            mOnlyFullPref.setChecked(false);
+//        }
+//        if (mFastBatteryLightEnabledPref != null) {
+//            mFastBatteryLightEnabledPref.setChecked(false);
+//        }
+//        resetColors();
+//        boolean showOnlyWhenFull = Settings.System.getInt(getContext().getContentResolver(),
+//                Settings.System.OMNI_BATTERY_LIGHT_ONLY_FULLY_CHARGED, 1) != 0;
+//        updateEnablement(showOnlyWhenFull);
+//    }
+//
+//    protected void resetColors() {
+//        if (mLowColorPref != null) {
+//            mLowColorPref.resetToDefaultValue();
+//        }
+//
+//        if (mMediumColorPref != null) {
+//            mMediumColorPref.resetToDefaultValue();
+//        }
+//
+//        if (mFullColorPref != null) {
+//            mFullColorPref.resetToDefaultValue();
+//        }
+//
+//        if (mReallyFullColorPref != null) {
+//            mReallyFullColorPref.resetToDefaultValue();
+//        }
+//
+//        if (mFastColorPref != null) {
+//            mFastColorPref.resetToDefaultValue();
+//        }
+//    }
+//
+//    private void refreshDefault() {
+//        if (mLowColorPref != null) {
+//            mLowColorPref.updateColor();
+//        }
+//
+//        if (mMediumColorPref != null) {
+//            mMediumColorPref.updateColor();
+//        }
+//
+//        if (mFullColorPref != null) {
+//            mFullColorPref.updateColor();
+//        }
+//
+//        if (mReallyFullColorPref != null) {
+//            mReallyFullColorPref.updateColor();
+//        }
+//
+//        if (mFastColorPref != null) {
+//            mFastColorPref.updateColor();
+//        }
+//    }
+//}
diff --git a/app/src/main/java/org/omnirom/control/FingerprintSettingsFragment.kt b/app/src/main/java/org/omnirom/control/FingerprintSettingsFragment.kt
index 5c5d5b5..82fde8f 100644
--- a/app/src/main/java/org/omnirom/control/FingerprintSettingsFragment.kt
+++ b/app/src/main/java/org/omnirom/control/FingerprintSettingsFragment.kt
@@ -1,283 +1,283 @@
-/*
- *  Copyright (C) 2023 The OmniROM Project
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-package org.omnirom.control
-
-import android.app.Activity
-import android.content.ComponentName
-import android.content.Context
-import android.content.Intent
-import android.content.ServiceConnection
-import android.graphics.Bitmap
-import android.graphics.BitmapFactory
-import android.graphics.drawable.BitmapDrawable
-import android.net.Uri
-import android.os.Bundle
-import android.os.IBinder
-import android.provider.MediaStore
-import android.provider.Settings
-import android.util.Log
-import androidx.activity.result.contract.ActivityResultContract
-import androidx.activity.result.contract.ActivityResultContracts
-import androidx.annotation.DrawableRes
-import androidx.annotation.XmlRes
-import androidx.preference.Preference
-import androidx.preference.SwitchPreference
-import com.android.systemui.shared.omni.IOmniSystemUiProxy
-import java.io.File
-import java.io.FileOutputStream
-import java.io.IOException
-
-
-class FingerprintSettingsFragment : AbstractSettingsFragment() {
-    private val TAG = "FingerprintSettingsFragment"
-    private val FINGERPRINT_CUSTOM_ICON_SELECT = "custom_fingerprint_icon_select"
-    private val FINGERPRINT_CUSTOM_ICON_ENABLE = "custom_fingerprint_icon_enable"
-    private val UFPSIMAGE_FILE_NAME = "ufpsImage"
-
-    companion object {
-        @DrawableRes
-        val ICON_RES = R.drawable.ic_settings_fingerprint
-        @XmlRes
-        val XML_RES = R.xml.fingerprint_preferences
-
-        fun isEnabled(context: Context) : Boolean {
-            return context.resources.getBoolean(R.bool.config_has_udfps)
-        }
-    }
-
-    class PickSinglePhotoContract : ActivityResultContract<Void?, Uri?>() {
-        override fun createIntent(context: Context, input: Void?): Intent {
-            return Intent(Intent(MediaStore.ACTION_PICK_IMAGES)).apply { type = "image/*" }
-        }
-
-        override fun parseResult(resultCode: Int, intent: Intent?): Uri? {
-            return intent.takeIf { resultCode == Activity.RESULT_OK }?.data
-        }
-    }
-
-    var pickImageLegacy = registerForActivityResult<String, Uri>(
-        ActivityResultContracts.GetContent()
-    ) { uri: Uri? ->
-        if (uri != null) {
-            try {
-                requireContext().contentResolver.openInputStream(uri).use { inputStream ->
-                    val bitmap = BitmapFactory.decodeStream(inputStream)
-                    systemUIProxy?.setUfpsImageBitmap(bitmap)
-                    savePickerIcon(bitmap)
-                }
-
-                Settings.System.putString(
-                    requireContext().contentResolver,
-                    Settings.System.OMNI_CUSTOM_FP_ICON_UPDATE,
-                    System.currentTimeMillis().toString()
-                )
-            } catch (e: Exception) {
-                Log.d(TAG, "pickImage", e);
-            }
-        }
-    }
-
-    private val pickImage =
-        registerForActivityResult(PickSinglePhotoContract()) { uri ->
-            Log.d(TAG, "pickImage uri = " + uri)
-            if (uri != null) {
-                // TODO we should do some check if the image is even a useful one eg size
-                try {
-                    requireContext().contentResolver.openInputStream(uri).use { inputStream ->
-                        val bitmap = BitmapFactory.decodeStream(inputStream)
-                        systemUIProxy?.setUfpsImageBitmap(bitmap)
-                        savePickerIcon(bitmap)
-                    }
-
-                    Settings.System.putString(
-                        requireContext().contentResolver,
-                        Settings.System.OMNI_CUSTOM_FP_ICON_UPDATE,
-                        System.currentTimeMillis().toString()
-                    )
-                } catch (e: Exception) {
-                    Log.d(TAG, "pickImage", e);
-                }
-            }
-        }
-
-
-    private val mSystemUIProxyService: ServiceConnection = object : ServiceConnection {
-        override fun onServiceConnected(name: ComponentName, service: IBinder) {
-            Log.d(
-                TAG,
-                "onServiceConnected $name $service"
-            )
-            systemUIProxy = IOmniSystemUiProxy.Stub.asInterface(service)
-        }
-
-        override fun onServiceDisconnected(name: ComponentName) {
-            Log.d(TAG, "onServiceDisconnected $name")
-        }
-    }
-
-    private var mSystemUIProxyBound = false
-    private var systemUIProxy: IOmniSystemUiProxy? = null
-    private var mFilePicker: Preference? = null
-    private var mEnableCustom: SwitchPreference? = null
-
-
-    private fun bindSystemUIProxyService() {
-        if (!mSystemUIProxyBound) {
-            Log.d(TAG, "bindSystemUIProxyService")
-            val serviceIntent = Intent("android.intent.action.OMNI_SYSTEMUI_SERVICE")
-                .setPackage("com.android.systemui")
-            try {
-                mSystemUIProxyBound = requireActivity().bindService(
-                    serviceIntent,
-                    mSystemUIProxyService,
-                    Context.BIND_AUTO_CREATE
-                )
-            } catch (e: SecurityException) {
-                Log.e(
-                    TAG,
-                    "Unable to bind because of security error",
-                    e
-                )
-            }
-        }
-    }
-
-    private fun unbindSystemUIProxyService() {
-        if (mSystemUIProxyBound) {
-            Log.d(TAG, "unbindSystemUIProxyService")
-            requireActivity().unbindService(mSystemUIProxyService)
-            mSystemUIProxyBound = false
-        }
-    }
-
-    override fun getFragmentTitle(): String {
-        return getString(R.string.fprint_title)
-    }
-
-    override fun getFragmentSummary(): String {
-        return getString(R.string.fprint_summary)
-    }
-
-    override fun getFragmentIcon(): Int {
-        return ICON_RES
-    }
-
-    override fun onDestroy() {
-        super.onDestroy()
-        unbindSystemUIProxyService()
-    }
-
-    override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
-        setPreferencesFromResource(XML_RES, rootKey)
-
-        mEnableCustom = findPreference<SwitchPreference>(FINGERPRINT_CUSTOM_ICON_ENABLE)
-        mEnableCustom?.let {
-            it.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
-                if (newValue as Boolean) {
-                    if (getCustomImagePath().exists()) {
-                        enablePickerIcon()
-                    }
-                } else {
-                    systemUIProxy?.resetUfpsImage()
-                }
-                true
-            }
-        }
-        mFilePicker = findPreference(FINGERPRINT_CUSTOM_ICON_SELECT)
-        mFilePicker?.let {
-            bindSystemUIProxyService()
-
-            if (getCustomImagePath().exists()) {
-                setPickerIcon()
-            }
-
-            it.onPreferenceClickListener = Preference.OnPreferenceClickListener {
-                pickImageLegacy.launch("image/*")
-                //pickImage.launch(null)
-                true
-            }
-        }
-    }
-
-    private fun getCustomImagePath(): File {
-        return File(requireContext().filesDir, UFPSIMAGE_FILE_NAME)
-    }
-
-    private fun setPickerIcon() {
-        try {
-            val parcelFileDescriptor = requireContext().contentResolver.openFileDescriptor(
-                Uri.fromFile(getCustomImagePath()),
-                "r"
-            )
-            parcelFileDescriptor?.let { it ->
-                val bitmap = BitmapFactory.decodeFileDescriptor(it.fileDescriptor)
-                it.close()
-                val d = BitmapDrawable(resources, bitmap)
-                mFilePicker?.icon = d
-            }
-        } catch (e: Exception) {
-            Log.e(
-                TAG,
-                "setPickerIcon",
-                e
-            )
-        }
-    }
-
-    private fun enablePickerIcon() {
-        try {
-            val parcelFileDescriptor = requireContext().contentResolver.openFileDescriptor(
-                Uri.fromFile(getCustomImagePath()),
-                "r"
-            )
-            parcelFileDescriptor?.let { it ->
-                val bitmap = BitmapFactory.decodeFileDescriptor(it.fileDescriptor)
-                it.close()
-                systemUIProxy?.setUfpsImageBitmap(bitmap)
-            }
-        } catch (e: Exception) {
-            Log.e(
-                TAG,
-                "setPickerIcon",
-                e
-            )
-        }
-    }
-
-    private fun savePickerIcon(bitmap: Bitmap) {
-        try {
-            val fos = FileOutputStream(getCustomImagePath())
-            bitmap.compress(Bitmap.CompressFormat.PNG, 90, fos)
-            fos.close()
-            val d = BitmapDrawable(resources, bitmap)
-            mFilePicker?.icon = d
-        } catch (e: Exception) {
-            Log.e(
-                TAG,
-                "savePickerIcon",
-                e
-            )
-        }
-    }
-
-    private fun deletePickerIcon() {
-        if (getCustomImagePath().exists()) {
-            getCustomImagePath().delete()
-        }
-    }
-}
\ No newline at end of file
+///*
+// *  Copyright (C) 2023 The OmniROM Project
+// *
+// * This program is free software: you can redistribute it and/or modify
+// * it under the terms of the GNU General Public License as published by
+// * the Free Software Foundation, either version 2 of the License, or
+// * (at your option) any later version.
+// *
+// * This program is distributed in the hope that it will be useful,
+// * but WITHOUT ANY WARRANTY; without even the implied warranty of
+// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// * GNU General Public License for more details.
+// *
+// * You should have received a copy of the GNU General Public License
+// * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+// *
+// */
+//package org.omnirom.control
+//
+//import android.app.Activity
+//import android.content.ComponentName
+//import android.content.Context
+//import android.content.Intent
+//import android.content.ServiceConnection
+//import android.graphics.Bitmap
+//import android.graphics.BitmapFactory
+//import android.graphics.drawable.BitmapDrawable
+//import android.net.Uri
+//import android.os.Bundle
+//import android.os.IBinder
+//import android.provider.MediaStore
+//import android.provider.Settings
+//import android.util.Log
+//import androidx.activity.result.contract.ActivityResultContract
+//import androidx.activity.result.contract.ActivityResultContracts
+//import androidx.annotation.DrawableRes
+//import androidx.annotation.XmlRes
+//import androidx.preference.Preference
+//import androidx.preference.SwitchPreference
+//import com.android.systemui.shared.omni.IOmniSystemUiProxy
+//import java.io.File
+//import java.io.FileOutputStream
+//import java.io.IOException
+//
+//
+//class FingerprintSettingsFragment : AbstractSettingsFragment() {
+//    private val TAG = "FingerprintSettingsFragment"
+//    private val FINGERPRINT_CUSTOM_ICON_SELECT = "custom_fingerprint_icon_select"
+//    private val FINGERPRINT_CUSTOM_ICON_ENABLE = "custom_fingerprint_icon_enable"
+//    private val UFPSIMAGE_FILE_NAME = "ufpsImage"
+//
+//    companion object {
+//        @DrawableRes
+//        val ICON_RES = R.drawable.ic_settings_fingerprint
+//        @XmlRes
+//        val XML_RES = R.xml.fingerprint_preferences
+//
+//        fun isEnabled(context: Context) : Boolean {
+//            return context.resources.getBoolean(R.bool.config_has_udfps)
+//        }
+//    }
+//
+//    class PickSinglePhotoContract : ActivityResultContract<Void?, Uri?>() {
+//        override fun createIntent(context: Context, input: Void?): Intent {
+//            return Intent(Intent(MediaStore.ACTION_PICK_IMAGES)).apply { type = "image/*" }
+//        }
+//
+//        override fun parseResult(resultCode: Int, intent: Intent?): Uri? {
+//            return intent.takeIf { resultCode == Activity.RESULT_OK }?.data
+//        }
+//    }
+//
+//    var pickImageLegacy = registerForActivityResult<String, Uri>(
+//        ActivityResultContracts.GetContent()
+//    ) { uri: Uri? ->
+//        if (uri != null) {
+//            try {
+//                requireContext().contentResolver.openInputStream(uri).use { inputStream ->
+//                    val bitmap = BitmapFactory.decodeStream(inputStream)
+//                    systemUIProxy?.setUfpsImageBitmap(bitmap)
+//                    savePickerIcon(bitmap)
+//                }
+//
+//                Settings.System.putString(
+//                    requireContext().contentResolver,
+//                    Settings.System.OMNI_CUSTOM_FP_ICON_UPDATE,
+//                    System.currentTimeMillis().toString()
+//                )
+//            } catch (e: Exception) {
+//                Log.d(TAG, "pickImage", e);
+//            }
+//        }
+//    }
+//
+//    private val pickImage =
+//        registerForActivityResult(PickSinglePhotoContract()) { uri ->
+//            Log.d(TAG, "pickImage uri = " + uri)
+//            if (uri != null) {
+//                // TODO we should do some check if the image is even a useful one eg size
+//                try {
+//                    requireContext().contentResolver.openInputStream(uri).use { inputStream ->
+//                        val bitmap = BitmapFactory.decodeStream(inputStream)
+//                        systemUIProxy?.setUfpsImageBitmap(bitmap)
+//                        savePickerIcon(bitmap)
+//                    }
+//
+//                    Settings.System.putString(
+//                        requireContext().contentResolver,
+//                        Settings.System.OMNI_CUSTOM_FP_ICON_UPDATE,
+//                        System.currentTimeMillis().toString()
+//                    )
+//                } catch (e: Exception) {
+//                    Log.d(TAG, "pickImage", e);
+//                }
+//            }
+//        }
+//
+//
+//    private val mSystemUIProxyService: ServiceConnection = object : ServiceConnection {
+//        override fun onServiceConnected(name: ComponentName, service: IBinder) {
+//            Log.d(
+//                TAG,
+//                "onServiceConnected $name $service"
+//            )
+//            systemUIProxy = IOmniSystemUiProxy.Stub.asInterface(service)
+//        }
+//
+//        override fun onServiceDisconnected(name: ComponentName) {
+//            Log.d(TAG, "onServiceDisconnected $name")
+//        }
+//    }
+//
+//    private var mSystemUIProxyBound = false
+//    private var systemUIProxy: IOmniSystemUiProxy? = null
+//    private var mFilePicker: Preference? = null
+//    private var mEnableCustom: SwitchPreference? = null
+//
+//
+//    private fun bindSystemUIProxyService() {
+//        if (!mSystemUIProxyBound) {
+//            Log.d(TAG, "bindSystemUIProxyService")
+//            val serviceIntent = Intent("android.intent.action.OMNI_SYSTEMUI_SERVICE")
+//                .setPackage("com.android.systemui")
+//            try {
+//                mSystemUIProxyBound = requireActivity().bindService(
+//                    serviceIntent,
+//                    mSystemUIProxyService,
+//                    Context.BIND_AUTO_CREATE
+//                )
+//            } catch (e: SecurityException) {
+//                Log.e(
+//                    TAG,
+//                    "Unable to bind because of security error",
+//                    e
+//                )
+//            }
+//        }
+//    }
+//
+//    private fun unbindSystemUIProxyService() {
+//        if (mSystemUIProxyBound) {
+//            Log.d(TAG, "unbindSystemUIProxyService")
+//            requireActivity().unbindService(mSystemUIProxyService)
+//            mSystemUIProxyBound = false
+//        }
+//    }
+//
+//    override fun getFragmentTitle(): String {
+//        return getString(R.string.fprint_title)
+//    }
+//
+//    override fun getFragmentSummary(): String {
+//        return getString(R.string.fprint_summary)
+//    }
+//
+//    override fun getFragmentIcon(): Int {
+//        return ICON_RES
+//    }
+//
+//    override fun onDestroy() {
+//        super.onDestroy()
+//        unbindSystemUIProxyService()
+//    }
+//
+//    override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
+//        setPreferencesFromResource(XML_RES, rootKey)
+//
+//        mEnableCustom = findPreference<SwitchPreference>(FINGERPRINT_CUSTOM_ICON_ENABLE)
+//        mEnableCustom?.let {
+//            it.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
+//                if (newValue as Boolean) {
+//                    if (getCustomImagePath().exists()) {
+//                        enablePickerIcon()
+//                    }
+//                } else {
+//                    systemUIProxy?.resetUfpsImage()
+//                }
+//                true
+//            }
+//        }
+//        mFilePicker = findPreference(FINGERPRINT_CUSTOM_ICON_SELECT)
+//        mFilePicker?.let {
+//            bindSystemUIProxyService()
+//
+//            if (getCustomImagePath().exists()) {
+//                setPickerIcon()
+//            }
+//
+//            it.onPreferenceClickListener = Preference.OnPreferenceClickListener {
+//                pickImageLegacy.launch("image/*")
+//                //pickImage.launch(null)
+//                true
+//            }
+//        }
+//    }
+//
+//    private fun getCustomImagePath(): File {
+//        return File(requireContext().filesDir, UFPSIMAGE_FILE_NAME)
+//    }
+//
+//    private fun setPickerIcon() {
+//        try {
+//            val parcelFileDescriptor = requireContext().contentResolver.openFileDescriptor(
+//                Uri.fromFile(getCustomImagePath()),
+//                "r"
+//            )
+//            parcelFileDescriptor?.let { it ->
+//                val bitmap = BitmapFactory.decodeFileDescriptor(it.fileDescriptor)
+//                it.close()
+//                val d = BitmapDrawable(resources, bitmap)
+//                mFilePicker?.icon = d
+//            }
+//        } catch (e: Exception) {
+//            Log.e(
+//                TAG,
+//                "setPickerIcon",
+//                e
+//            )
+//        }
+//    }
+//
+//    private fun enablePickerIcon() {
+//        try {
+//            val parcelFileDescriptor = requireContext().contentResolver.openFileDescriptor(
+//                Uri.fromFile(getCustomImagePath()),
+//                "r"
+//            )
+//            parcelFileDescriptor?.let { it ->
+//                val bitmap = BitmapFactory.decodeFileDescriptor(it.fileDescriptor)
+//                it.close()
+//                systemUIProxy?.setUfpsImageBitmap(bitmap)
+//            }
+//        } catch (e: Exception) {
+//            Log.e(
+//                TAG,
+//                "setPickerIcon",
+//                e
+//            )
+//        }
+//    }
+//
+//    private fun savePickerIcon(bitmap: Bitmap) {
+//        try {
+//            val fos = FileOutputStream(getCustomImagePath())
+//            bitmap.compress(Bitmap.CompressFormat.PNG, 90, fos)
+//            fos.close()
+//            val d = BitmapDrawable(resources, bitmap)
+//            mFilePicker?.icon = d
+//        } catch (e: Exception) {
+//            Log.e(
+//                TAG,
+//                "savePickerIcon",
+//                e
+//            )
+//        }
+//    }
+//
+//    private fun deletePickerIcon() {
+//        if (getCustomImagePath().exists()) {
+//            getCustomImagePath().delete()
+//        }
+//    }
+//}
\ No newline at end of file
diff --git a/app/src/main/java/org/omnirom/control/GridViewFragment.kt b/app/src/main/java/org/omnirom/control/GridViewFragment.kt
index df30d71..addd7e2 100644
--- a/app/src/main/java/org/omnirom/control/GridViewFragment.kt
+++ b/app/src/main/java/org/omnirom/control/GridViewFragment.kt
@@ -95,16 +95,16 @@
                 AppListFragment()
             )
         )
-        if (resources.getBoolean(com.android.internal.R.bool.config_intrusiveBatteryLed)) {
-            gridItems.add(
-                FragmentGridItem(
-                    R.string.batterylight_title,
-                    R.string.batterylight_summary,
-                    R.drawable.ic_settings_leds,
-                    BatteryLightSettingsFragment()
-                )
-            )
-        }
+//        if (resources.getBoolean(com.android.internal.R.bool.config_intrusiveBatteryLed)) {
+//            gridItems.add(
+//                FragmentGridItem(
+//                    R.string.batterylight_title,
+//                    R.string.batterylight_summary,
+//                    R.drawable.ic_settings_leds,
+//                    BatteryLightSettingsFragment()
+//                )
+//            )
+//        }
         gridItems.add(
             FragmentGridItem(
                 R.string.bars_settings_title,
@@ -131,16 +131,16 @@
                 )
             )
         }
-        if (resources.getBoolean(R.bool.config_has_udfps)) {
-            gridItems.add(
-                FragmentGridItem(
-                    R.string.fprint_title,
-                    R.string.fprint_summary,
-                    R.drawable.ic_settings_fingerprint,
-                    FingerprintSettingsFragment()
-                )
-            )
-        }
+//        if (resources.getBoolean(R.bool.config_has_udfps)) {
+//            gridItems.add(
+//                FragmentGridItem(
+//                    R.string.fprint_title,
+//                    R.string.fprint_summary,
+//                    R.drawable.ic_settings_fingerprint,
+//                    FingerprintSettingsFragment()
+//                )
+//            )
+//        }
         gridItems.add(
             FragmentGridItem(
                 R.string.lockscreen_item_title,
@@ -157,14 +157,14 @@
                 OverlaysFragment()
             )
         )
-        gridItems.add(
-            FragmentGridItem(
-                R.string.qs_settings_title,
-                R.string.qs_settings_summary,
-                R.drawable.ic_qs_tile,
-                QSSettingsFragment()
-            )
-        )
+//        gridItems.add(
+//            FragmentGridItem(
+//                R.string.qs_settings_title,
+//                R.string.qs_settings_summary,
+//                R.drawable.ic_qs_tile,
+//                QSSettingsFragment()
+//            )
+//        )
         if (Utils.isAvailableApp(requireContext(), "org.omnirom.omniwallpaper")) {
             val intent = Intent()
             intent.component = ComponentName(
diff --git a/app/src/main/java/org/omnirom/control/QSSettingsFragment.kt b/app/src/main/java/org/omnirom/control/QSSettingsFragment.kt
index 79088e1..08fa359 100644
--- a/app/src/main/java/org/omnirom/control/QSSettingsFragment.kt
+++ b/app/src/main/java/org/omnirom/control/QSSettingsFragment.kt
@@ -1,110 +1,110 @@
-/*
- *  Copyright (C) 2021 The OmniROM Project
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-package org.omnirom.control
-
-import android.os.Bundle
-import android.provider.Settings
-import androidx.annotation.DrawableRes
-import androidx.annotation.XmlRes
-import androidx.preference.Preference
-import org.omnirom.omnilib.preference.SeekBarPreference
-
-
-class QSSettingsFragment : AbstractSettingsFragment() {
-    companion object {
-        @DrawableRes
-        val ICON_RES = R.drawable.ic_qs_tile
-        @XmlRes
-        val XML_RES = R.xml.qs_settings_preferences
-    }
-    override fun getFragmentTitle(): String {
-        return resources.getString(R.string.qs_settings_title)
-    }
-
-    override fun getFragmentSummary(): String {
-        return resources.getString(R.string.qs_settings_summary)
-    }
-
-    override fun getFragmentIcon(): Int {
-        return ICON_RES
-    }
-
-    override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
-        setPreferencesFromResource(XML_RES, rootKey)
-
-        val pm = requireContext().packageManager
-        val resources = pm.getResourcesForApplication("com.android.systemui")
-
-        var defPortraitColumns = 2
-        val portraitColumns = findPreference<SeekBarPreference>("qs_layout_columns")
-        if (portraitColumns != null) {
-            var id =
-                resources.getIdentifier(
-                    "quick_settings_num_columns",
-                    "integer",
-                    "com.android.systemui"
-                )
-            if (id != 0) {
-                defPortraitColumns = resources.getInteger(id)
-            }
-            val settingsPortraitColumns = Settings.System.getInt(
-                requireContext().contentResolver, Settings.System.OMNI_QS_LAYOUT_COLUMNS,
-                defPortraitColumns
-            )
-            portraitColumns.setValue(settingsPortraitColumns)
-            portraitColumns.onPreferenceChangeListener =
-                Preference.OnPreferenceChangeListener { _, newValue ->
-                    Settings.System.putInt(
-                        requireContext().contentResolver, Settings.System.OMNI_QS_LAYOUT_COLUMNS,
-                        newValue as Int
-                    )
-                    true
-                }
-        }
-        val landscapeColumns = findPreference<SeekBarPreference>("qs_layout_columns_landscape")
-        if (landscapeColumns != null) {
-            var defLandspaceColumns = defPortraitColumns
-            var id =
-                resources.getIdentifier(
-                    "quick_settings_num_columns_landscape",
-                    "integer",
-                    "com.android.systemui"
-                )
-            if (id != 0) {
-                defLandspaceColumns = resources.getInteger(id)
-            }
-            val settingsLandscapeColumns = Settings.System.getInt(
-                requireContext().contentResolver, Settings.System.OMNI_QS_LAYOUT_COLUMNS_LANDSCAPE,
-                defLandspaceColumns
-            )
-            landscapeColumns.setValue(settingsLandscapeColumns)
-            landscapeColumns.onPreferenceChangeListener =
-                Preference.OnPreferenceChangeListener { _, newValue ->
-                    Settings.System.putInt(
-                        requireContext().contentResolver, Settings.System.OMNI_QS_LAYOUT_COLUMNS_LANDSCAPE,
-                        newValue as Int
-                    )
-                    true
-                }
-        }
-    }
-
-    override fun onPreferenceTreeClick(preference: Preference): Boolean {
-        return super.onPreferenceTreeClick(preference)
-    }
-}
+///*
+// *  Copyright (C) 2021 The OmniROM Project
+// *
+// * This program is free software: you can redistribute it and/or modify
+// * it under the terms of the GNU General Public License as published by
+// * the Free Software Foundation, either version 2 of the License, or
+// * (at your option) any later version.
+// *
+// * This program is distributed in the hope that it will be useful,
+// * but WITHOUT ANY WARRANTY; without even the implied warranty of
+// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// * GNU General Public License for more details.
+// *
+// * You should have received a copy of the GNU General Public License
+// * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+// *
+// */
+//package org.omnirom.control
+//
+//import android.os.Bundle
+//import android.provider.Settings
+//import androidx.annotation.DrawableRes
+//import androidx.annotation.XmlRes
+//import androidx.preference.Preference
+//import org.omnirom.omnilib.preference.SeekBarPreference
+//
+//
+//class QSSettingsFragment : AbstractSettingsFragment() {
+//    companion object {
+//        @DrawableRes
+//        val ICON_RES = R.drawable.ic_qs_tile
+//        @XmlRes
+//        val XML_RES = R.xml.qs_settings_preferences
+//    }
+//    override fun getFragmentTitle(): String {
+//        return resources.getString(R.string.qs_settings_title)
+//    }
+//
+//    override fun getFragmentSummary(): String {
+//        return resources.getString(R.string.qs_settings_summary)
+//    }
+//
+//    override fun getFragmentIcon(): Int {
+//        return ICON_RES
+//    }
+//
+//    override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
+//        setPreferencesFromResource(XML_RES, rootKey)
+//
+//        val pm = requireContext().packageManager
+//        val resources = pm.getResourcesForApplication("com.android.systemui")
+//
+//        var defPortraitColumns = 2
+//        val portraitColumns = findPreference<SeekBarPreference>("qs_layout_columns")
+//        if (portraitColumns != null) {
+//            var id =
+//                resources.getIdentifier(
+//                    "quick_settings_num_columns",
+//                    "integer",
+//                    "com.android.systemui"
+//                )
+//            if (id != 0) {
+//                defPortraitColumns = resources.getInteger(id)
+//            }
+//            val settingsPortraitColumns = Settings.System.getInt(
+//                requireContext().contentResolver, Settings.System.OMNI_QS_LAYOUT_COLUMNS,
+//                defPortraitColumns
+//            )
+//            portraitColumns.setValue(settingsPortraitColumns)
+//            portraitColumns.onPreferenceChangeListener =
+//                Preference.OnPreferenceChangeListener { _, newValue ->
+//                    Settings.System.putInt(
+//                        requireContext().contentResolver, Settings.System.OMNI_QS_LAYOUT_COLUMNS,
+//                        newValue as Int
+//                    )
+//                    true
+//                }
+//        }
+//        val landscapeColumns = findPreference<SeekBarPreference>("qs_layout_columns_landscape")
+//        if (landscapeColumns != null) {
+//            var defLandspaceColumns = defPortraitColumns
+//            var id =
+//                resources.getIdentifier(
+//                    "quick_settings_num_columns_landscape",
+//                    "integer",
+//                    "com.android.systemui"
+//                )
+//            if (id != 0) {
+//                defLandspaceColumns = resources.getInteger(id)
+//            }
+//            val settingsLandscapeColumns = Settings.System.getInt(
+//                requireContext().contentResolver, Settings.System.OMNI_QS_LAYOUT_COLUMNS_LANDSCAPE,
+//                defLandspaceColumns
+//            )
+//            landscapeColumns.setValue(settingsLandscapeColumns)
+//            landscapeColumns.onPreferenceChangeListener =
+//                Preference.OnPreferenceChangeListener { _, newValue ->
+//                    Settings.System.putInt(
+//                        requireContext().contentResolver, Settings.System.OMNI_QS_LAYOUT_COLUMNS_LANDSCAPE,
+//                        newValue as Int
+//                    )
+//                    true
+//                }
+//        }
+//    }
+//
+//    override fun onPreferenceTreeClick(preference: Preference): Boolean {
+//        return super.onPreferenceTreeClick(preference)
+//    }
+//}
diff --git a/app/src/main/java/org/omnirom/control/search/SearchProvider.kt b/app/src/main/java/org/omnirom/control/search/SearchProvider.kt
index 1ddf97a..0cbd508 100644
--- a/app/src/main/java/org/omnirom/control/search/SearchProvider.kt
+++ b/app/src/main/java/org/omnirom/control/search/SearchProvider.kt
@@ -23,13 +23,13 @@
 import androidx.annotation.XmlRes
 import org.omnirom.control.AppListFragment
 import org.omnirom.control.BarsSettingsFragment
-import org.omnirom.control.BatteryLightSettingsFragment
+//import org.omnirom.control.BatteryLightSettingsFragment
 import org.omnirom.control.ButtonSettingsFragment
 import org.omnirom.control.DialerSettingsFragment
-import org.omnirom.control.FingerprintSettingsFragment
+//import org.omnirom.control.FingerprintSettingsFragment
 import org.omnirom.control.LockscreenSettingsFragment
 import org.omnirom.control.MoreSettingsFragment
-import org.omnirom.control.QSSettingsFragment
+//import org.omnirom.control.QSSettingsFragment
 import org.omnirom.control.search.PreferenceXmlParserUtils.METADATA_KEY
 import org.omnirom.control.search.PreferenceXmlParserUtils.METADATA_SUMMARY
 import org.omnirom.control.search.PreferenceXmlParserUtils.METADATA_TITLE
@@ -88,23 +88,23 @@
                 this::isEnabled
             )
         )
-        searchItemList.add(
-            SearchItem(
-                QSSettingsFragment.XML_RES,
-                QSSettingsFragment().javaClass.canonicalName,
-                QSSettingsFragment.ICON_RES,
-                this::isEnabled
-            )
-        )
-
-        searchItemList.add(
-            SearchItem(
-                FingerprintSettingsFragment.XML_RES,
-                FingerprintSettingsFragment().javaClass.canonicalName,
-                FingerprintSettingsFragment.ICON_RES,
-                FingerprintSettingsFragment::isEnabled
-            )
-        )
+//        searchItemList.add(
+//            SearchItem(
+//                QSSettingsFragment.XML_RES,
+//                QSSettingsFragment().javaClass.canonicalName,
+//                QSSettingsFragment.ICON_RES,
+//                this::isEnabled
+//            )
+//        )
+//
+//        searchItemList.add(
+//            SearchItem(
+//                FingerprintSettingsFragment.XML_RES,
+//                FingerprintSettingsFragment().javaClass.canonicalName,
+//                FingerprintSettingsFragment.ICON_RES,
+//                FingerprintSettingsFragment::isEnabled
+//            )
+//        )
 
         searchItemList.add(
             SearchItem(
@@ -124,14 +124,14 @@
             )
         )
 
-        searchItemList.add(
-            SearchItem(
-                BatteryLightSettingsFragment.XML_RES,
-                BatteryLightSettingsFragment().javaClass.canonicalName,
-                BatteryLightSettingsFragment.ICON_RES,
-                BatteryLightSettingsFragment::isEnabled
-            )
-        )
+//        searchItemList.add(
+//            SearchItem(
+//                BatteryLightSettingsFragment.XML_RES,
+//                BatteryLightSettingsFragment().javaClass.canonicalName,
+//                BatteryLightSettingsFragment.ICON_RES,
+//                BatteryLightSettingsFragment::isEnabled
+//            )
+//        )
 
         searchItemList.add(
             SearchItem(
