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

Commit 5ef35dc0 authored by Wesley.CW Wang's avatar Wesley.CW Wang
Browse files

Change Style tab's content layout

 - Change style content layout to grid(was 1 line only, recycleview)
 - Move Custom option to the first
 screenshot: https://screenshot.googleplex.com/pZ7tTOqk71R.png

Bug: 151285552
Test: manually
Change-Id: I7d5ef1ef3ac81d6da4d29052f49ddf30335564f8
parent d21bf861
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -16,5 +16,5 @@
     limitations under the License.
-->
<resources>
    <bool name="use_grid_for_options">false</bool>
    <bool name="use_grid_for_options">true</bool>
</resources>
 No newline at end of file
+3 −0
Original line number Diff line number Diff line
@@ -119,6 +119,9 @@
        [CHAR LIMIT=20] -->
    <string name="custom_theme_previous">Previous</string>

    <!-- Title for "Custom theme" option. [CHAR LIMIT=15] -->
    <string name="custom_theme">Custom</string>

    <!-- Generic label for one system Style/Theme (combination of fonts/colors/icons) that is
        defined and customized by the user (note there could be more than one so the label includes
        a number, eg "Custom 1, Custom 2, etc") [CHAR LIMIT=15] -->
+4 −10
Original line number Diff line number Diff line
@@ -78,9 +78,6 @@ public class DefaultThemeProvider extends ResourcesApkProvider implements ThemeB
    private static final String THEME_TITLE_FIELD = "_theme_title";
    private static final String THEME_ID_FIELD = "_theme_id";

    // Maximum number of themes allowed (including default, pre-bundled and custom)
    private static final int MAX_TOTAL_THEMES = 10;

    private final OverlayThemeExtractor mOverlayProvider;
    private List<ThemeBundle> mThemes;
    private final CustomizationPreferences mCustomizationPreferences;
@@ -109,6 +106,10 @@ public class DefaultThemeProvider extends ResourcesApkProvider implements ThemeB
    }

    private void loadAll() {
        // Add "Custom" option at the first.
        mThemes.add(new CustomTheme(CustomTheme.newId(), mContext.getString(
                R.string.custom_theme), new HashMap<>(), null));

        addDefaultTheme();

        String[] themeNames = getItemsFromStub(THEMES_ARRAY);
@@ -321,13 +322,6 @@ public class DefaultThemeProvider extends ResourcesApkProvider implements ThemeB
                        new HashMap<>(), null));
            }
        }

        if (mThemes.size() < MAX_TOTAL_THEMES) {
            // Add an empty one at the end.
            mThemes.add(new CustomTheme(CustomTheme.newId(), mContext.getString(
                    R.string.custom_theme_title, customThemesCount + 1), new HashMap<>(), null));
        }

    }

    @Override
+13 −4
Original line number Diff line number Diff line
@@ -278,8 +278,7 @@ public class ThemeFragment extends AppbarFragment {
                }
                if (mSelectedTheme == null) {
                    // Select the default theme if there is no matching custom enabled theme
                    // TODO(b/124796742): default to custom if there is no matching theme bundle
                    mSelectedTheme = options.get(0);
                    mSelectedTheme = findDefaultThemeBundle(options);
                } else {
                    // Only show show checkmark if we found a matching theme
                    mOptionsController.setAppliedOption(mSelectedTheme);
@@ -307,8 +306,7 @@ public class ThemeFragment extends AppbarFragment {
            }
            if (mSelectedTheme == null) {
                // Select the default theme if there is no matching custom enabled theme
                // TODO(b/124796742): default to custom if there is no matching theme bundle
                mSelectedTheme = options.get(0);
                mSelectedTheme = findDefaultThemeBundle(options);
            } else {
                // Only show show checkmark if we found a matching theme
                mOptionsController.setAppliedOption(mSelectedTheme);
@@ -317,6 +315,17 @@ public class ThemeFragment extends AppbarFragment {
        }, true);
    }

    private ThemeBundle findDefaultThemeBundle(List<ThemeBundle> options) {
        String defaultThemeTitle =
                getActivity().getResources().getString(R.string.default_theme_title);
        for (ThemeBundle bundle : options) {
            if (bundle.getTitle().equals(defaultThemeTitle)) {
                return bundle;
            }
        }
        return null;
    }

    private void navigateToCustomTheme(CustomTheme themeToEdit) {
        Intent intent = new Intent(getActivity(), CustomThemeActivity.class);
        intent.putExtra(CustomThemeActivity.EXTRA_THEME_TITLE, themeToEdit.getTitle());