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

Commit 0dab8ccc authored by Sebastiano Barezzi's avatar Sebastiano Barezzi Committed by Bruno Martins
Browse files

LineageParts: Don't directly call onStart/onStop on dialogs

This messes with dialog lifecycle, move to onResume/onPause instead,
which also gets automatically called on preferences

Change-Id: I3bb0a25e275822bdc481ff659fc9c7f39541473c
parent 6e0e1f02
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
/*
 * SPDX-FileCopyrightText: 2012 The CyanogenMod Project
 * SPDX-FileCopyrightText: 2017-2022 The LineageOS Project
 * SPDX-FileCopyrightText: 2017-2024 The LineageOS Project
 * SPDX-License-Identifier: Apache-2.0
 */

@@ -114,15 +114,17 @@ public class ApplicationLightPreference extends CustomDialogPreference<LightSett
        holder.itemView.setOnLongClickListener(this);
    }

    public void onStop() {
    @Override
    public void onPause() {
        if (getDialog() != null) {
            getDialog().onStop();
            getDialog().onPause();
        }
    }

    public void onStart() {
    @Override
    public void onResume() {
        if (getDialog() != null) {
            getDialog().onStart();
            getDialog().onResume();
        }
    }

+3 −7
Original line number Diff line number Diff line
/*
 * SPDX-FileCopyrightText: 2010 Daniel Nilsson
 * SPDX-FileCopyrightText: 2012 The CyanogenMod Project
 * SPDX-FileCopyrightText: 2017-2023 The LineageOS Project
 * SPDX-FileCopyrightText: 2017-2024 The LineageOS Project
 * SPDX-License-Identifier: Apache-2.0
 */

@@ -193,15 +193,11 @@ public class LightSettingsDialog extends AlertDialog implements
        mColorPicker.setColor(state.getInt(STATE_KEY_COLOR), true);
    }

    @Override
    public void onStop() {
        super.onStop();
    public void onPause() {
        dismissLed();
    }

    @Override
    public void onStart() {
        super.onStart();
    public void onResume() {
        updateLed();
    }

+1 −30
Original line number Diff line number Diff line
/*
 * SPDX-FileCopyrightText: 2012 The CyanogenMod Project
 * SPDX-FileCopyrightText: 2017-2023 The LineageOS Project
 * SPDX-FileCopyrightText: 2017-2024 The LineageOS Project
 * SPDX-License-Identifier: Apache-2.0
 */

@@ -245,35 +245,6 @@ public class NotificationLightSettings extends SettingsPreferenceFragment implem
        }
    }

    @Override
    public void onStart() {
        super.onStart();
        setChildrenStarted(getPreferenceScreen(), true);
    }

    @Override
    public void onStop() {
        super.onStop();
        setChildrenStarted(getPreferenceScreen(), false);
    }

    private void setChildrenStarted(PreferenceGroup group, boolean started) {
        final int count = group.getPreferenceCount();
        for (int i = 0; i < count; i++) {
            Preference pref = group.getPreference(i);
            if (pref instanceof ApplicationLightPreference) {
                ApplicationLightPreference ap = (ApplicationLightPreference) pref;
                if (started) {
                    ap.onStart();
                } else {
                    ap.onStop();
                }
            } else if (pref instanceof PreferenceGroup) {
                setChildrenStarted((PreferenceGroup) pref, started);
            }
        }
    }

    private void refreshCustomApplicationPrefs() {
        Context context = getActivity();