Merge "Update app grid options after changing grid" into tm-qpr-dev
diff --git a/src/com/android/customization/model/color/ColorSectionController.java b/src/com/android/customization/model/color/ColorSectionController.java
index c31f01e..be051ac 100644
--- a/src/com/android/customization/model/color/ColorSectionController.java
+++ b/src/com/android/customization/model/color/ColorSectionController.java
@@ -41,7 +41,6 @@
import androidx.annotation.Nullable;
import androidx.lifecycle.LifecycleOwner;
import androidx.recyclerview.widget.RecyclerView;
-import androidx.viewpager2.widget.MarginPageTransformer;
import androidx.viewpager2.widget.ViewPager2;
import com.android.customization.model.CustomizationManager;
@@ -54,7 +53,6 @@
import com.android.wallpaper.model.CustomizationSectionController;
import com.android.wallpaper.model.WallpaperColorsViewModel;
import com.android.wallpaper.module.InjectorProvider;
-import com.android.wallpaper.module.LargeScreenMultiPanesChecker;
import com.android.wallpaper.widget.PageIndicator;
import com.android.wallpaper.widget.SeparatedTabLayout;
@@ -104,7 +102,6 @@
new Optional[]{Optional.empty(), Optional.empty()};
private long mLastColorApplyingTime = 0L;
private ColorSectionView mColorSectionView;
- private boolean mIsMultiPane;
private static int getNumPages(int optionsPerPage, int totalOptions) {
return (int) Math.ceil((float) totalOptions / optionsPerPage);
@@ -118,7 +115,6 @@
new OverlayManagerCompat(activity));
mWallpaperColorsViewModel = viewModel;
mLifecycleOwner = lifecycleOwner;
- mIsMultiPane = new LargeScreenMultiPanesChecker().isMultiPanesEnabled(activity);
if (savedInstanceState != null) {
if (savedInstanceState.containsKey(KEY_COLOR_TAB_POSITION)) {
@@ -326,10 +322,8 @@
subOptions = colorOptions;
}
- final int padding = container.getContext().getResources().getDimensionPixelSize(
- R.dimen.section_horizontal_padding);
OptionSelectorController<ColorOption> adaptiveController = new OptionSelectorController<>(
- container, subOptions, /* useGrid= */ true, CENTER, padding);
+ container, subOptions, /* useGrid= */ true, CENTER);
adaptiveController.initOptions(mColorManager);
setUpColorOptionsController(adaptiveController);
}
@@ -474,16 +468,6 @@
mContainer = itemView.findViewById(R.id.color_page_container);
// Correct scrolling goes under collapsing toolbar while scrolling oclor options.
mContainer.getChildAt(0).setNestedScrollingEnabled(false);
- /**
- * Sets page transformer with margin to separate color pages and
- * sets color pages' padding to not scroll to window boundary if multi-pane case
- */
- if (mIsMultiPane) {
- final int padding = itemView.getContext().getResources().getDimensionPixelSize(
- R.dimen.section_horizontal_padding);
- mContainer.setPageTransformer(new MarginPageTransformer(padding * 2));
- mContainer.setPadding(0, /* top= */ 0, 0, /* bottom= */ 0);
- }
mPageIndicator = itemView.findViewById(R.id.color_page_indicator);
if (ColorProvider.themeStyleEnabled) {
mPageIndicator.setVisibility(VISIBLE);
@@ -541,15 +525,13 @@
ColorOptionViewHolder(View itemView) {
super(itemView);
mContainer = itemView.findViewById(R.id.color_option_container);
- // Sets layout with margins for non multi-pane case to separate color options.
- if (!mIsMultiPane) {
- final FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
- mContainer.getLayoutParams());
- final int margin = itemView.getContext().getResources().getDimensionPixelSize(
- R.dimen.section_horizontal_padding);
- layoutParams.setMargins(margin, /* top= */ 0, margin, /* bottom= */ 0);
- mContainer.setLayoutParams(layoutParams);
- }
+ // Sets layout with margins to separate color options.
+ final FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
+ mContainer.getLayoutParams());
+ final int margin = itemView.getContext().getResources().getDimensionPixelSize(
+ R.dimen.section_horizontal_padding);
+ layoutParams.setMargins(margin, /* top= */ 0, margin, /* bottom= */ 0);
+ mContainer.setLayoutParams(layoutParams);
}
}
}
diff --git a/src/com/android/customization/picker/clock/ui/fragment/ClockSettingsFragment.kt b/src/com/android/customization/picker/clock/ui/fragment/ClockSettingsFragment.kt
index ef1a5ef..c5cde53 100644
--- a/src/com/android/customization/picker/clock/ui/fragment/ClockSettingsFragment.kt
+++ b/src/com/android/customization/picker/clock/ui/fragment/ClockSettingsFragment.kt
@@ -108,7 +108,7 @@
},
),
lifecycleOwner = this,
- offsetToStart = displayUtils.isOnWallpaperDisplay(activity),
+ offsetToStart = displayUtils.isSingleDisplayOrUnfoldedHorizontalHinge(activity),
)
.show()
diff --git a/src/com/android/customization/picker/color/ui/fragment/ColorPickerFragment.kt b/src/com/android/customization/picker/color/ui/fragment/ColorPickerFragment.kt
index ef68a4e..c6b2023 100644
--- a/src/com/android/customization/picker/color/ui/fragment/ColorPickerFragment.kt
+++ b/src/com/android/customization/picker/color/ui/fragment/ColorPickerFragment.kt
@@ -105,7 +105,8 @@
},
),
lifecycleOwner = this,
- offsetToStart = displayUtils.isOnWallpaperDisplay(requireActivity()),
+ offsetToStart =
+ displayUtils.isSingleDisplayOrUnfoldedHorizontalHinge(requireActivity()),
)
ScreenPreviewBinder.bind(
activity = requireActivity(),
@@ -136,7 +137,8 @@
},
),
lifecycleOwner = this,
- offsetToStart = displayUtils.isOnWallpaperDisplay(requireActivity()),
+ offsetToStart =
+ displayUtils.isSingleDisplayOrUnfoldedHorizontalHinge(requireActivity()),
)
val darkModeToggleContainerView: FrameLayout =
view.requireViewById(R.id.dark_mode_toggle_container)
diff --git a/src/com/android/customization/picker/grid/GridFragment.java b/src/com/android/customization/picker/grid/GridFragment.java
index 00ae21b..b5ed7ee 100644
--- a/src/com/android/customization/picker/grid/GridFragment.java
+++ b/src/com/android/customization/picker/grid/GridFragment.java
@@ -218,7 +218,7 @@
mLoading.hide();
mOptionsController = new OptionSelectorController<>(
mOptionsContainer, options, /* useGrid= */ false,
- CheckmarkStyle.CENTER_CHANGE_COLOR_WHEN_NOT_SELECTED, 0);
+ CheckmarkStyle.CENTER_CHANGE_COLOR_WHEN_NOT_SELECTED);
mOptionsController.initOptions(mGridManager);
GridOption previouslySelectedOption = findEquivalent(options,
mGridOptionViewModel.getSelectedOption());
diff --git a/src/com/android/customization/picker/quickaffordance/ui/fragment/KeyguardQuickAffordancePickerFragment.kt b/src/com/android/customization/picker/quickaffordance/ui/fragment/KeyguardQuickAffordancePickerFragment.kt
index f956598..d5f0d33 100644
--- a/src/com/android/customization/picker/quickaffordance/ui/fragment/KeyguardQuickAffordancePickerFragment.kt
+++ b/src/com/android/customization/picker/quickaffordance/ui/fragment/KeyguardQuickAffordancePickerFragment.kt
@@ -68,7 +68,9 @@
viewModel = viewModel,
lifecycleOwner = this,
offsetToStart =
- injector.getDisplayUtils(requireActivity()).isOnWallpaperDisplay(requireActivity())
+ requireActivity().let {
+ injector.getDisplayUtils(it).isSingleDisplayOrUnfoldedHorizontalHinge(it)
+ }
)
KeyguardQuickAffordancePickerBinder.bind(
view = view,
diff --git a/src/com/android/customization/picker/theme/CustomThemeComponentFragment.java b/src/com/android/customization/picker/theme/CustomThemeComponentFragment.java
index 83d5e69..a1e9967 100644
--- a/src/com/android/customization/picker/theme/CustomThemeComponentFragment.java
+++ b/src/com/android/customization/picker/theme/CustomThemeComponentFragment.java
@@ -95,7 +95,7 @@
private void setUpOptions() {
mProvider.fetch(options -> {
mOptionsController = new OptionSelectorController(
- mOptionsContainer, options, mUseGridLayout, CheckmarkStyle.NONE, 0);
+ mOptionsContainer, options, mUseGridLayout, CheckmarkStyle.NONE);
mOptionsController.addListener(selected -> {
mSelectedOption = (ThemeComponentOption) selected;
diff --git a/src/com/android/customization/picker/theme/ThemeFragment.java b/src/com/android/customization/picker/theme/ThemeFragment.java
index 493213d..3a9a56f 100644
--- a/src/com/android/customization/picker/theme/ThemeFragment.java
+++ b/src/com/android/customization/picker/theme/ThemeFragment.java
@@ -258,7 +258,7 @@
mThemeManager.fetchOptions(new OptionsFetchedListener<ThemeBundle>() {
@Override
public void onOptionsLoaded(List<ThemeBundle> options) {
- mOptionsController = new OptionSelectorController<>(mOptionsContainer, options, 0);
+ mOptionsController = new OptionSelectorController<>(mOptionsContainer, options);
mOptionsController.initOptions(mThemeManager);
// Find out the selected theme option.
diff --git a/src/com/android/customization/widget/OptionSelectorController.java b/src/com/android/customization/widget/OptionSelectorController.java
index 6ca13be..8c7af00 100644
--- a/src/com/android/customization/widget/OptionSelectorController.java
+++ b/src/com/android/customization/widget/OptionSelectorController.java
@@ -85,19 +85,18 @@
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, int containerInset) {
- this(container, options, true, CheckmarkStyle.CORNER, containerInset);
+ public OptionSelectorController(RecyclerView container, List<T> options) {
+ this(container, options, true, CheckmarkStyle.CORNER);
}
public OptionSelectorController(RecyclerView container, List<T> options,
- boolean useGrid, @CheckmarkStyle int checkmarkStyle, int containerInset) {
+ boolean useGrid, @CheckmarkStyle int checkmarkStyle) {
mContainer = container;
mOptions = options;
mUseGrid = useGrid;
@@ -106,7 +105,6 @@
mContainer.getResources().getValue(R.dimen.linear_layout_horizontal_display_options_max,
typedValue, true);
mLinearLayoutHorizontalDisplayOptionsMax = typedValue.getFloat();
- mContainerInset = containerInset;
}
public void addListener(OptionSelectedListener listener) {
@@ -304,9 +302,6 @@
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(