Update widget picker row logic to resolve cropping
Using pixels instead of cell spans for calculating the widget picker row binding logic. Before: https://screenshot.googleplex.com/3uXX2m7xWh3om5t Now: https://screenshot.googleplex.com/C593mrQfqTahNrQ Test: Manual Fix: 269790954 Change-Id: Ib591a6f6d3cf8b72766e0714b9bc8ceb86b2ba4f
This commit is contained in:
1 parent
24b1890c4b
commit
16180801e8
9 files changed
+216
-143
No files matched your search
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.android.launcher3.widget.model;
|
||||
|
||||
import androidx.annotation.Px;
|
||||
|
||||
import com.android.launcher3.model.WidgetItem;
|
||||
import com.android.launcher3.model.data.PackageItemInfo;
|
||||
|
||||
@@ -26,7 +28,7 @@ import java.util.List;
|
||||
*/
|
||||
public final class WidgetsListContentEntry extends WidgetsListBaseEntry {
|
||||
|
||||
private final int mMaxSpanSizeInCells;
|
||||
@Px private final int mMaxSpanSize;
|
||||
|
||||
/**
|
||||
* Constructor for {@link WidgetsListContentEntry}.
|
||||
@@ -37,7 +39,7 @@ public final class WidgetsListContentEntry extends WidgetsListBaseEntry {
|
||||
*/
|
||||
public WidgetsListContentEntry(PackageItemInfo pkgItem, String titleSectionName,
|
||||
List<WidgetItem> items) {
|
||||
this(pkgItem, titleSectionName, items, /* maxSpanSizeInCells= */ 0);
|
||||
this(pkgItem, titleSectionName, items, /* maxSpanSize= */ 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,43 +48,43 @@ public final class WidgetsListContentEntry extends WidgetsListBaseEntry {
|
||||
* @param pkgItem package info associated with the entry
|
||||
* @param titleSectionName title section name associated with the entry.
|
||||
* @param items list of widgets for the package.
|
||||
* @param maxSpanSizeInCells the max horizontal span in cells that is allowed for grouping more
|
||||
* @param maxSpanSize the max horizontal span in pixels that is allowed for grouping more
|
||||
* than one widgets in a table row.
|
||||
*/
|
||||
public WidgetsListContentEntry(PackageItemInfo pkgItem, String titleSectionName,
|
||||
List<WidgetItem> items, int maxSpanSizeInCells) {
|
||||
List<WidgetItem> items, @Px int maxSpanSize) {
|
||||
super(pkgItem, titleSectionName, items);
|
||||
mMaxSpanSizeInCells = maxSpanSizeInCells;
|
||||
mMaxSpanSize = maxSpanSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Content:" + mPkgItem.packageName + ":" + mWidgets.size() + " maxSpanSizeInCells: "
|
||||
+ mMaxSpanSizeInCells;
|
||||
return "Content:" + mPkgItem.packageName + ":" + mWidgets.size() + " maxSpanSize: "
|
||||
+ mMaxSpanSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a copy of this {@link WidgetsListContentEntry} with updated
|
||||
* {@param maxSpanSizeInCells}.
|
||||
* Returns a copy of this {@link WidgetsListContentEntry} with updated {@code maxSpanSize}.
|
||||
*
|
||||
* @param maxSpanSizeInCells the maximum horizontal span in cells that is allowed for grouping
|
||||
* @param maxSpanSize the maximum horizontal span in pixels that is allowed for grouping
|
||||
* more than one widgets in a table row.
|
||||
*/
|
||||
public WidgetsListContentEntry withMaxSpanSize(int maxSpanSizeInCells) {
|
||||
if (mMaxSpanSizeInCells == maxSpanSizeInCells) return this;
|
||||
public WidgetsListContentEntry withMaxSpanSize(@Px int maxSpanSize) {
|
||||
if (mMaxSpanSize == maxSpanSize) return this;
|
||||
return new WidgetsListContentEntry(
|
||||
mPkgItem,
|
||||
mTitleSectionName,
|
||||
mWidgets,
|
||||
/* maxSpanSizeInCells= */ maxSpanSizeInCells);
|
||||
/* maxSpanSize= */ maxSpanSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the max horizontal span size in cells that is allowed for grouping more than one
|
||||
* Returns the max horizontal span size in pixels that is allowed for grouping more than one
|
||||
* widget in a table row.
|
||||
*/
|
||||
public int getMaxSpanSizeInCells() {
|
||||
return mMaxSpanSizeInCells;
|
||||
@Px
|
||||
public int getMaxSpanSize() {
|
||||
return mMaxSpanSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -91,6 +93,6 @@ public final class WidgetsListContentEntry extends WidgetsListBaseEntry {
|
||||
WidgetsListContentEntry otherEntry = (WidgetsListContentEntry) obj;
|
||||
return mWidgets.equals(otherEntry.mWidgets) && mPkgItem.equals(otherEntry.mPkgItem)
|
||||
&& mTitleSectionName.equals(otherEntry.mTitleSectionName)
|
||||
&& mMaxSpanSizeInCells == otherEntry.mMaxSpanSizeInCells;
|
||||
&& mMaxSpanSize == otherEntry.mMaxSpanSize;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user