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

Commit 0dec0be8 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "Settings: Selections of Home app are lost" into android_ui.lnx.2.1-dev

parents dfed4445 18d0d23f
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -52,6 +52,8 @@ import java.util.List;
public class AppListPreference extends CustomListPreference {

    public static final String ITEM_NONE_VALUE = "";
    public static final int TYPE_PACKAGE = 0;
    public static final int TYPE_COMPONENT = 1;

    protected final boolean mForWork;
    protected final int mUserId;
@@ -60,6 +62,7 @@ public class AppListPreference extends CustomListPreference {
    private boolean mShowItemNone = false;
    private CharSequence[] mSummaries;
    private int mSystemAppIndex = -1;
    private int mType = TYPE_PACKAGE;

    public class AppArrayAdapter extends ArrayAdapter<CharSequence> {
        private Drawable[] mImageDrawables = null;
@@ -189,6 +192,8 @@ public class AppListPreference extends CustomListPreference {
    public void setComponentNames(ComponentName[] componentNames, ComponentName defaultCN,
            CharSequence[] summaries) {
        mSummaries = summaries;
        mType = TYPE_COMPONENT;

        // Look up all package names in PackageManager. Skip ones we can't find.
        PackageManager pm = getContext().getPackageManager();
        final int entryCount = componentNames.length + (mShowItemNone ? 1 : 0);
@@ -257,7 +262,18 @@ public class AppListPreference extends CustomListPreference {
        if (state instanceof SavedState) {
            SavedState savedState = (SavedState) state;
            mShowItemNone = savedState.showItemNone;
            if (mType == TYPE_PACKAGE) {
                setPackageNames(savedState.entryValues, savedState.value);
            } else if (mType == TYPE_COMPONENT) {
                int len = savedState.entryValues.length;
                ComponentName[] entryValues = new ComponentName[len];
                for(int i = 0; i < len; i++) {
                    entryValues[i] = ComponentName.unflattenFromString(
                        savedState.entryValues[i]+"");
                }
                setComponentNames(entryValues,
                    ComponentName.unflattenFromString(savedState.value+""));
            }
            mSummaries = savedState.summaries;
            super.onRestoreInstanceState(savedState.superState);
        } else {