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

Commit 14c635e8 authored by Venkatraman Nerellapalli's avatar Venkatraman Nerellapalli Committed by Linux Build Service Account
Browse files

Fix: Crash when Progressbar is closed after Homekey is pressed

When Homekey is pressed, Progressbar can not be closed as
Settings app & fragments go to background.
Close Progressbar safely if Settings is not in foreground.

Change-Id: I0324ff66194c14a30105c0949ca6e6caab7393fa
CRs-Fixed: 1022563
parent 09c3c3c6
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -120,6 +120,7 @@ public class ApnSettings extends RestrictedSettingsFragment implements

    private boolean mHideImsApn;
    private boolean mAllowAddingApns;
    private boolean mApnSettingsHidden;

    public ApnSettings() {
        super(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS);
@@ -197,6 +198,12 @@ public class ApnSettings extends RestrictedSettingsFragment implements
        addPreferencesFromResource(R.xml.apn_settings);
    }

    @Override
    public void onStop() {
        super.onStop();
        mApnSettingsHidden = true;
    }

    @Override
    public void onResume() {
        super.onResume();
@@ -210,6 +217,7 @@ public class ApnSettings extends RestrictedSettingsFragment implements
        if (!mRestoreDefaultApnMode) {
            fillList();
        }
        mApnSettingsHidden = false;
    }

    @Override
@@ -518,7 +526,9 @@ public class ApnSettings extends RestrictedSettingsFragment implements
                    fillList();
                    getPreferenceScreen().setEnabled(true);
                    mRestoreDefaultApnMode = false;
                    removeDialog(DIALOG_RESTORE_DEFAULTAPN);
                    // if current fragment is not visible, in background or Homekey is pressed,
                    // dismiss the dialog with state loss.
                    removeDialog(DIALOG_RESTORE_DEFAULTAPN, mApnSettingsHidden);
                    Toast.makeText(
                        activity,
                        getResources().getString(
+12 −0
Original line number Diff line number Diff line
@@ -524,6 +524,18 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
        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