Align items in the center within each table row within suggestions.
When differently-sized widgets OR widgets of same size but not filling space in previews are shown side by side, the top alignment looks odd. Besides, in the updated UX, we want them to be center aligned. Bug: 318410881 Bug: 319152349 Flag: N/A Test: Screenshot update in cl chain. Change-Id: I52cd7d6a1b5397a3c4c9dea8b072792b3211a8d3
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.launcher3.widget;
|
||||
|
||||
import static com.android.launcher3.Flags.enableCategorizedWidgetSuggestions;
|
||||
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_BOTTOM_WIDGETS_TRAY;
|
||||
|
||||
import android.content.Context;
|
||||
@@ -187,7 +188,13 @@ public class WidgetsBottomSheet extends BaseWidgetSheet {
|
||||
mWidgetCellHorizontalPadding)
|
||||
.forEach(row -> {
|
||||
TableRow tableRow = new TableRow(getContext());
|
||||
tableRow.setGravity(Gravity.TOP);
|
||||
if (enableCategorizedWidgetSuggestions()) {
|
||||
// Vertically center align items, so that even if they don't fill bounds,
|
||||
// they can look organized when placed together in a row.
|
||||
tableRow.setGravity(Gravity.CENTER_VERTICAL);
|
||||
} else {
|
||||
tableRow.setGravity(Gravity.TOP);
|
||||
}
|
||||
row.forEach(widgetItem -> {
|
||||
WidgetCell widget = addItemCell(tableRow);
|
||||
widget.applyFromCellItem(widgetItem);
|
||||
|
||||
@@ -162,7 +162,7 @@ public class WidgetsFullSheet extends BaseWidgetSheet
|
||||
@Nullable PersonalWorkPagedView mViewPager;
|
||||
private boolean mIsInSearchMode;
|
||||
private boolean mIsNoWidgetsViewNeeded;
|
||||
@Px private int mMaxSpanPerRow;
|
||||
@Px protected int mMaxSpanPerRow;
|
||||
protected DeviceProfile mDeviceProfile;
|
||||
|
||||
protected TextView mNoWidgetsView;
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.android.launcher3.widget.picker;
|
||||
|
||||
import static com.android.launcher3.Flags.enableCategorizedWidgetSuggestions;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.util.Log;
|
||||
@@ -147,7 +149,13 @@ public final class WidgetsListTableViewHolderBinder
|
||||
tableRow = (TableRow) table.getChildAt(i);
|
||||
} else {
|
||||
tableRow = new TableRow(table.getContext());
|
||||
tableRow.setGravity(Gravity.TOP);
|
||||
if (enableCategorizedWidgetSuggestions()) {
|
||||
// Vertically center align items, so that even if they don't fill bounds, they
|
||||
// can look organized when placed together in a row.
|
||||
tableRow.setGravity(Gravity.CENTER_VERTICAL);
|
||||
} else {
|
||||
tableRow.setGravity(Gravity.TOP);
|
||||
}
|
||||
table.addView(tableRow);
|
||||
}
|
||||
if (tableRow.getChildCount() > widgetItems.size()) {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.android.launcher3.widget.picker;
|
||||
|
||||
import static com.android.launcher3.Flags.enableCategorizedWidgetSuggestions;
|
||||
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_WIDGETS_PREDICTION;
|
||||
|
||||
import android.content.Context;
|
||||
@@ -104,8 +105,13 @@ public final class WidgetsRecommendationTableLayout extends TableLayout {
|
||||
for (int i = 0; i < data.mRecommendationTable.size(); i++) {
|
||||
List<WidgetItem> widgetItems = data.mRecommendationTable.get(i);
|
||||
TableRow tableRow = new TableRow(getContext());
|
||||
tableRow.setGravity(Gravity.TOP);
|
||||
|
||||
if (enableCategorizedWidgetSuggestions()) {
|
||||
// Vertically center align items, so that even if they don't fill bounds, they can
|
||||
// look organized when placed together in a row.
|
||||
tableRow.setGravity(Gravity.CENTER_VERTICAL);
|
||||
} else {
|
||||
tableRow.setGravity(Gravity.TOP);
|
||||
}
|
||||
for (WidgetItem widgetItem : widgetItems) {
|
||||
WidgetCell widgetCell = addItemCell(tableRow);
|
||||
widgetCell.applyFromCellItem(widgetItem, data.mPreviewScale);
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.android.launcher3.widget.picker;
|
||||
|
||||
import static com.android.launcher3.Flags.enableCategorizedWidgetSuggestions;
|
||||
import static com.android.launcher3.Flags.enableUnfoldedTwoPanePicker;
|
||||
|
||||
import android.content.Context;
|
||||
@@ -308,15 +309,25 @@ public class WidgetsTwoPaneSheet extends WidgetsFullSheet {
|
||||
if (mSuggestedWidgetsHeader != null) {
|
||||
mSuggestedWidgetsHeader.setExpanded(false);
|
||||
}
|
||||
|
||||
WidgetsListContentEntry contentEntryToBind;
|
||||
if (enableCategorizedWidgetSuggestions()) {
|
||||
// Setting max span size enables row to understand how to fit more than one item
|
||||
// in a row.
|
||||
contentEntryToBind = contentEntry.withMaxSpanSize(mMaxSpanPerRow);
|
||||
} else {
|
||||
contentEntryToBind = contentEntry;
|
||||
}
|
||||
|
||||
WidgetsRowViewHolder widgetsRowViewHolder =
|
||||
mWidgetsListTableViewHolderBinder.newViewHolder(mRightPane);
|
||||
mWidgetsListTableViewHolderBinder.bindViewHolder(widgetsRowViewHolder,
|
||||
contentEntry,
|
||||
contentEntryToBind,
|
||||
ViewHolderBinder.POSITION_FIRST | ViewHolderBinder.POSITION_LAST,
|
||||
Collections.EMPTY_LIST);
|
||||
widgetsRowViewHolder.mDataCallback = data -> {
|
||||
mWidgetsListTableViewHolderBinder.bindViewHolder(widgetsRowViewHolder,
|
||||
contentEntry,
|
||||
contentEntryToBind,
|
||||
ViewHolderBinder.POSITION_FIRST | ViewHolderBinder.POSITION_LAST,
|
||||
Collections.singletonList(data));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user