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

Commit 4158d57e authored by chihhangchuang's avatar chihhangchuang
Browse files

Make the ThemePicker remember the state before system config changes

1. It was added the logic to save the selection, but it was overrided by active theme. Fix it in the cl.
2. Remove optionsController#setAppliedOption from ThemeFragment, since the #1 get fixed, we will see two thumbnails with check, see: https://drive.google.com/file/d/1bl20BBxCi7lRWnBV-vD4xmvx5MWwGH9i/view?usp=sharing
The thumbnail check would be added by OptionSelectorController, the ThemeFragment won't handle it. (Same as GridFragment)

Video of the fixing: https://drive.google.com/file/d/1dhu1oR0T2gR0ZE-vyFjL5XQTeY3zkvBK/view?usp=sharing

Test: Manually
Fixes: 157723282
Fixes: 157724003
Change-Id: Ib668b7ca0f7630065c6da2df19b276ccca05eb5a
parent 3a120b7c
Loading
Loading
Loading
Loading
+16 −12
Original line number Diff line number Diff line
@@ -290,29 +290,36 @@ public class ThemeFragment extends AppbarFragment {
                    }
                });
                mOptionsController.initOptions(mThemeManager);

                String previouslySelected = savedInstanceState != null
                        ? savedInstanceState.getString(KEY_SELECTED_THEME) : null;
                ThemeBundle previouslySelectedTheme = null;
                ThemeBundle activeTheme = null;
                for (ThemeBundle theme : options) {
                    if (previouslySelected != null
                            && previouslySelected.equals(theme.getSerializedPackages())) {
                        mSelectedTheme = theme;
                    } else if (theme.isActive(mThemeManager)) {
                        mSelectedTheme = theme;
                        break;
                        previouslySelectedTheme = theme;
                    }
                    if (theme.isActive(mThemeManager)) {
                        activeTheme = theme;
                    }
                }
                mSelectedTheme = previouslySelectedTheme != null
                        ? previouslySelectedTheme
                        : activeTheme;

                if (mSelectedTheme == null) {
                    // Select the default theme if there is no matching custom enabled theme
                    mSelectedTheme = findDefaultThemeBundle(options);
                } else {
                    // Only show show checkmark if we found a matching theme
                    mOptionsController.setAppliedOption(mSelectedTheme);
                }
                mOptionsController.setSelectedOption(mSelectedTheme);
                // Set selected option above will show BottomActionBar when entering the tab. But
                // it should not show when entering the tab.
                // it should not show when entering the tab. But it's visible for previously
                // selected theme.
                if (mSelectedTheme != previouslySelectedTheme) {
                    mBottomActionBar.hide();
                }
            }
            @Override
            public void onError(@Nullable Throwable throwable) {
                if (throwable != null) {
@@ -335,9 +342,6 @@ public class ThemeFragment extends AppbarFragment {
            if (mSelectedTheme == null) {
                // Select the default theme if there is no matching custom enabled theme
                mSelectedTheme = findDefaultThemeBundle(options);
            } else {
                // Only show show checkmark if we found a matching theme
                mOptionsController.setAppliedOption(mSelectedTheme);
            }
            mOptionsController.setSelectedOption(mSelectedTheme);
            // Set selected option above will show BottomActionBar,