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

Commit e06050cc authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Fix crash on rotation

by making the information the dialog needs available earlier

Test: manual, with rotation
Fixes: 165889571
Change-Id: I68627d17573a876f8e81cc63ccf74eee0063b63d
parent 7fb5f938
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import com.google.common.annotations.VisibleForTesting;
import java.util.ArrayList;

import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;

public class ShowOnLockScreenNotificationPreferenceController extends AbstractPreferenceController
        implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
@@ -66,8 +67,9 @@ public class ShowOnLockScreenNotificationPreferenceController extends AbstractPr
    }

    @Override
    public void updateState(Preference preference) {
        RestrictedListPreference pref = (RestrictedListPreference) preference;
    public void displayPreference(PreferenceScreen screen) {
        super.displayPreference(screen);
        RestrictedListPreference pref = screen.findPreference(mSettingKey);
        pref.clearRestrictedItems();
        ArrayList<CharSequence> entries = new ArrayList<>();
        ArrayList<CharSequence> values = new ArrayList<>();
@@ -104,7 +106,7 @@ public class ShowOnLockScreenNotificationPreferenceController extends AbstractPr

        pref.setOnPreferenceChangeListener(this);

        refreshSummary(preference);
        refreshSummary(pref);
    }

    @Override
+5 −5
Original line number Diff line number Diff line
@@ -89,7 +89,7 @@ public class ShowOnLockscreenNotificationPreferenceControllerTest {
                LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS,
                1);

        mController.updateState(mPreference);
        mController.displayPreference(mScreen);

        assertThat(mPreference.getValue()).isEqualTo(
                String.valueOf(R.string.lock_screen_notifs_show_none));
@@ -107,7 +107,7 @@ public class ShowOnLockscreenNotificationPreferenceControllerTest {
                LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS,
                0);

        mController.updateState(mPreference);
        mController.displayPreference(mScreen);

        assertThat(mPreference.getValue()).isEqualTo(
                String.valueOf(R.string.lock_screen_notifs_show_alerting));
@@ -124,7 +124,7 @@ public class ShowOnLockscreenNotificationPreferenceControllerTest {
                LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS,
                1);

        mController.updateState(mPreference);
        mController.displayPreference(mScreen);

        assertThat(mPreference.getValue()).isEqualTo(
                String.valueOf(R.string.lock_screen_notifs_show_all));
@@ -136,7 +136,7 @@ public class ShowOnLockscreenNotificationPreferenceControllerTest {
    public void updateState_allNotifsOnLockscreen_isDefault() {
        // settings don't exist

        mController.updateState(mPreference);
        mController.displayPreference(mScreen);

        assertThat(mPreference.getValue()).isEqualTo(
                String.valueOf(R.string.lock_screen_notifs_show_all));
@@ -158,7 +158,7 @@ public class ShowOnLockscreenNotificationPreferenceControllerTest {
        ShadowRestrictedLockUtilsInternal.setKeyguardDisabledFeatures(
                KEYGUARD_DISABLE_SECURE_NOTIFICATIONS);

        mController.updateState(mPreference);
        mController.displayPreference(mScreen);

        assertThat(mPreference.getValue()).isEqualTo(
                String.valueOf(R.string.lock_screen_notifs_show_none));