Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 561d03e5 authored by Jorge Ruesga's avatar Jorge Ruesga
Browse files

Settings: Fix NPE in QS on tablets



On tablets, onCreate is only called once, while onActivityCreated is called every
time the fragment is visible. So a second remove of a preferent will result in a NPE

Change-Id: I30205380018f29bd99270c707bd4f8ba03103648
Signed-off-by: default avatarJorge Ruesga <jorge@ruesga.com>
parent 832f09c3
Loading
Loading
Loading
Loading
+16 −4
Original line number Diff line number Diff line
@@ -115,16 +115,28 @@ public class QuickSettings extends SettingsPreferenceFragment implements

        // Remove unsupported options
        if (!QSUtils.deviceSupportsDockBattery(getActivity())) {
            mDynamicTiles.removePreference(findPreference(Settings.System.QS_DYNAMIC_DOCK_BATTERY));
            Preference pref = findPreference(Settings.System.QS_DYNAMIC_DOCK_BATTERY);
            if (pref != null) {
                mDynamicTiles.removePreference(pref);
            }
        }
        if (!QSUtils.deviceSupportsImeSwitcher(getActivity())) {
            mDynamicTiles.removePreference(findPreference(Settings.System.QS_DYNAMIC_IME));
            Preference pref = findPreference(Settings.System.QS_DYNAMIC_IME);
            if (pref != null) {
                mDynamicTiles.removePreference(pref);
            }
        }
        if (!QSUtils.deviceSupportsUsbTether(getActivity())) {
            mDynamicTiles.removePreference(findPreference(Settings.System.QS_DYNAMIC_USBTETHER));
            Preference pref = findPreference(Settings.System.QS_DYNAMIC_USBTETHER);
            if (pref != null) {
                mDynamicTiles.removePreference(pref);
            }
        }
        if (!QSUtils.deviceSupportsWifiDisplay(getActivity())) {
            mDynamicTiles.removePreference(findPreference(Settings.System.QS_DYNAMIC_WIFI));
            Preference pref = findPreference(Settings.System.QS_DYNAMIC_WIFI);
            if (pref != null) {
                mDynamicTiles.removePreference(pref);
            }
        }
    }