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

Commit 6c1a1232 authored by abdullahirum's avatar abdullahirum
Browse files

Fix for color picker pager getting clipped

the color picker in the CustomizationPickerFragment is being clipped prematurely.
This CL ensures that the clipping doesn't occur

video before:https://drive.google.com/file/d/1_kOYPWubYrS0s_Z8mSNHqF4CF7t0gsi5/view?usp=share_link&resourcekey=0-PkqdGUzJ3FtZ_9iLqxJrkg
video after:https://drive.google.com/file/d/14k4em_PXJmQqxQTFQDeCMRMTQHDpvGTI/view?usp=share_link&resourcekey=0-D6qXOJ2QBXIh7dyud-vtXQ

Fix: 221762001
Test: manual
Change-Id: Iad0573c378c6234febb55d7c054e2bb5716b1107
parent eea14d36
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -326,8 +326,10 @@ public class ColorSectionController implements CustomizationSectionController<Co
            subOptions = colorOptions;
        }

        final int padding = container.getContext().getResources().getDimensionPixelSize(
                R.dimen.section_horizontal_padding);
        OptionSelectorController<ColorOption> adaptiveController = new OptionSelectorController<>(
                container, subOptions, /* useGrid= */ true, CENTER);
                container, subOptions, /* useGrid= */ true, CENTER, padding);
        adaptiveController.initOptions(mColorManager);
        setUpColorOptionsController(adaptiveController);
    }
@@ -480,7 +482,7 @@ public class ColorSectionController implements CustomizationSectionController<Co
                    final int padding = itemView.getContext().getResources().getDimensionPixelSize(
                            R.dimen.section_horizontal_padding);
                    mContainer.setPageTransformer(new MarginPageTransformer(padding * 2));
                    mContainer.setPadding(padding, /* top= */ 0, padding, /* bottom= */ 0);
                    mContainer.setPadding(0, /* top= */ 0, 0, /* bottom= */ 0);
                }
                mPageIndicator = itemView.findViewById(R.id.color_page_indicator);
                if (ColorProvider.themeStyleEnabled) {
+1 −1
Original line number Diff line number Diff line
@@ -217,7 +217,7 @@ public class GridFragment extends AppbarFragment {
                mLoading.hide();
                mOptionsController = new OptionSelectorController<>(
                        mOptionsContainer, options, /* useGrid= */ false,
                        CheckmarkStyle.CENTER_CHANGE_COLOR_WHEN_NOT_SELECTED);
                        CheckmarkStyle.CENTER_CHANGE_COLOR_WHEN_NOT_SELECTED, 0);
                mOptionsController.initOptions(mGridManager);
                GridOption previouslySelectedOption = findEquivalent(options,
                        mGridOptionViewModel.getSelectedOption());
+1 −1
Original line number Diff line number Diff line
@@ -95,7 +95,7 @@ public class CustomThemeComponentFragment extends CustomThemeStepFragment {
    private void setUpOptions() {
        mProvider.fetch(options -> {
            mOptionsController = new OptionSelectorController(
                    mOptionsContainer, options, mUseGridLayout, CheckmarkStyle.NONE);
                    mOptionsContainer, options, mUseGridLayout, CheckmarkStyle.NONE, 0);

            mOptionsController.addListener(selected -> {
                mSelectedOption = (ThemeComponentOption) selected;
+1 −1
Original line number Diff line number Diff line
@@ -258,7 +258,7 @@ public class ThemeFragment extends AppbarFragment {
        mThemeManager.fetchOptions(new OptionsFetchedListener<ThemeBundle>() {
            @Override
            public void onOptionsLoaded(List<ThemeBundle> options) {
                mOptionsController = new OptionSelectorController<>(mOptionsContainer, options);
                mOptionsController = new OptionSelectorController<>(mOptionsContainer, options, 0);
                mOptionsController.initOptions(mThemeManager);

                // Find out the selected theme option.
+9 −4
Original line number Diff line number Diff line
@@ -78,25 +78,26 @@ public class OptionSelectorController<T extends CustomizationOption<T>> {
        int CENTER_CHANGE_COLOR_WHEN_NOT_SELECTED = 3;
    }

    private float mLinearLayoutHorizontalDisplayOptionsMax;
    private final float mLinearLayoutHorizontalDisplayOptionsMax;

    private final RecyclerView mContainer;
    private final List<T> mOptions;
    private final boolean mUseGrid;
    @CheckmarkStyle
    private final int mCheckmarkStyle;
    private final int mContainerInset;

    private final Set<OptionSelectedListener> mListeners = new HashSet<>();
    private RecyclerView.Adapter<TileViewHolder> mAdapter;
    private T mSelectedOption;
    private T mAppliedOption;

    public OptionSelectorController(RecyclerView container, List<T> options) {
        this(container, options, true, CheckmarkStyle.CORNER);
    public OptionSelectorController(RecyclerView container, List<T> options, int containerInset) {
        this(container, options, true, CheckmarkStyle.CORNER, containerInset);
    }

    public OptionSelectorController(RecyclerView container, List<T> options,
            boolean useGrid, @CheckmarkStyle int checkmarkStyle) {
            boolean useGrid, @CheckmarkStyle int checkmarkStyle, int containerInset) {
        mContainer = container;
        mOptions = options;
        mUseGrid = useGrid;
@@ -105,6 +106,7 @@ public class OptionSelectorController<T extends CustomizationOption<T>> {
        mContainer.getResources().getValue(R.dimen.linear_layout_horizontal_display_options_max,
                typedValue, true);
        mLinearLayoutHorizontalDisplayOptionsMax = typedValue.getFloat();
        mContainerInset = containerInset;
    }

    public void addListener(OptionSelectedListener listener) {
@@ -302,6 +304,9 @@ public class OptionSelectorController<T extends CustomizationOption<T>> {
            int numColumns = res.getInteger(R.integer.options_grid_num_columns);
            GridLayoutManager gridLayoutManager = new GridLayoutManager(mContainer.getContext(),
                    numColumns);
            if (mContainerInset != 0) {
                mContainer.setPadding(mContainerInset, 0, mContainerInset, 0);
            }
            mContainer.setLayoutManager(gridLayoutManager);
        } else {
            final int padding = res.getDimensionPixelSize(