summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/BubbleTextView.java4
-rw-r--r--src/com/android/launcher3/DeviceProfile.java34
-rw-r--r--src/com/android/launcher3/Utilities.java4
-rw-r--r--src/com/android/launcher3/widget/WidgetCell.java2
-rw-r--r--src/com/android/launcher3/widget/WidgetsContainerView.java33
5 files changed, 44 insertions, 33 deletions
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index 33b3ad347..a294fa538 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -65,6 +65,7 @@ public class BubbleTextView extends TextView
private static final int DISPLAY_WORKSPACE = 0;
private static final int DISPLAY_ALL_APPS = 1;
+ private static final int DISPLAY_FOLDER = 2;
private final Launcher mLauncher;
private Drawable mIcon;
@@ -125,12 +126,13 @@ public class BubbleTextView extends TextView
setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.allAppsIconTextSizePx);
setCompoundDrawablePadding(grid.allAppsIconDrawablePaddingPx);
defaultIconSize = grid.allAppsIconSizePx;
+ } else if (display == DISPLAY_FOLDER) {
+ setCompoundDrawablePadding(grid.folderChildDrawablePaddingPx);
}
mCenterVertically = a.getBoolean(R.styleable.BubbleTextView_centerVertically, false);
mIconSize = a.getDimensionPixelSize(R.styleable.BubbleTextView_iconSizeOverride,
defaultIconSize);
-
a.recycle();
if (mCustomShadowsEnabled) {
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index c9fd85a16..c4e6ed119 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -20,8 +20,6 @@ import android.appwidget.AppWidgetHostView;
import android.content.ComponentName;
import android.content.Context;
import android.content.res.Resources;
-import android.graphics.Paint;
-import android.graphics.Paint.FontMetrics;
import android.graphics.Point;
import android.graphics.Rect;
import android.util.DisplayMetrics;
@@ -100,6 +98,7 @@ public class DeviceProfile {
public int folderIconPreviewPadding;
public int folderCellWidthPx;
public int folderCellHeightPx;
+ public int folderChildDrawablePaddingPx;
// Hotseat
public int hotseatCellWidthPx;
@@ -255,12 +254,9 @@ public class DeviceProfile {
allAppsIconDrawablePaddingPx = iconDrawablePaddingPx;
allAppsIconTextSizePx = iconTextSizePx;
- // Calculate the actual text height
- Paint textPaint = new Paint();
- textPaint.setTextSize(iconTextSizePx);
- FontMetrics fm = textPaint.getFontMetrics();
cellWidthPx = iconSizePx;
- cellHeightPx = iconSizePx + iconDrawablePaddingPx + (int) Math.ceil(fm.bottom - fm.top);
+ cellHeightPx = iconSizePx + iconDrawablePaddingPx
+ + Utilities.calculateTextHeight(iconTextSizePx);
final float scaleDps = !FeatureFlags.LAUNCHER3_LEGACY_WORKSPACE_DND ? 0f
: res.getDimensionPixelSize(R.dimen.dragViewScale);
dragViewScale = (iconSizePx + scaleDps) / iconSizePx;
@@ -281,12 +277,25 @@ public class DeviceProfile {
res.getInteger(R.integer.config_workspaceSpringLoadShrinkPercentage) / 100.0f;
}
- // Folder
- int folderCellPadding = isTablet || isLandscape ? 6 * edgeMarginPx : 3 * edgeMarginPx;
+ // Folder cell
+ int cellPaddingX = res.getDimensionPixelSize(R.dimen.folder_cell_x_padding);
+ int cellPaddingY = res.getDimensionPixelSize(R.dimen.folder_cell_y_padding);
+ final int folderChildTextSize =
+ Utilities.calculateTextHeight(res.getDimension(R.dimen.folder_child_text_size));
+
+ final int folderBottomPanelSize =
+ 2 * res.getDimensionPixelSize(R.dimen.folder_label_padding)
+ + Utilities.calculateTextHeight(res.getDimension(R.dimen.folder_label_text_size));
+
// Don't let the folder get too close to the edges of the screen.
- folderCellWidthPx = Math.min(cellWidthPx + folderCellPadding,
+ folderCellWidthPx = Math.min(iconSizePx + 2 * cellPaddingX,
(availableWidthPx - 4 * edgeMarginPx) / inv.numFolderColumns);
- folderCellHeightPx = cellHeightPx + edgeMarginPx;
+ folderCellHeightPx = Math.min(iconSizePx + 3 * cellPaddingY + folderChildTextSize,
+ (availableHeightPx - 4 * edgeMarginPx - folderBottomPanelSize) / inv.numFolderRows);
+ folderChildDrawablePaddingPx = Math.max(0,
+ (folderCellHeightPx - iconSizePx - folderChildTextSize) / 3);
+
+ // Folder icon
folderBackgroundOffset = -edgeMarginPx;
folderIconSizePx = iconSizePx + 2 * -folderBackgroundOffset;
folderIconPreviewPadding = res.getDimensionPixelSize(R.dimen.folder_preview_padding);
@@ -296,9 +305,6 @@ public class DeviceProfile {
mInsets.set(insets);
}
- /**
- * @param recyclerViewWidth the available width of the AllAppsRecyclerView
- */
public void updateAppsViewNumCols() {
allAppsNumCols = allAppsNumPredictiveCols = inv.numColumns;
}
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index e34f509da..b0e096a2e 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -686,11 +686,11 @@ public final class Utilities {
/**
* Calculates the height of a given string at a specific text size.
*/
- public static float calculateTextHeight(float textSizePx) {
+ public static int calculateTextHeight(float textSizePx) {
Paint p = new Paint();
p.setTextSize(textSizePx);
Paint.FontMetrics fm = p.getFontMetrics();
- return -fm.top + fm.bottom;
+ return (int) Math.ceil(fm.bottom - fm.top);
}
/**
diff --git a/src/com/android/launcher3/widget/WidgetCell.java b/src/com/android/launcher3/widget/WidgetCell.java
index 97877fd35..293585dd6 100644
--- a/src/com/android/launcher3/widget/WidgetCell.java
+++ b/src/com/android/launcher3/widget/WidgetCell.java
@@ -135,6 +135,8 @@ public class WidgetCell extends LinearLayout implements OnLayoutChangeListener {
mWidgetName.setText(mItem.label);
mWidgetDims.setText(getContext().getString(R.string.widget_dims_format,
mItem.spanX, mItem.spanY));
+ mWidgetDims.setContentDescription(getContext().getString(
+ R.string.widget_accessible_dims_format, mItem.spanX, mItem.spanY));
mWidgetPreviewLoader = loader;
if (item.activityInfo != null) {
diff --git a/src/com/android/launcher3/widget/WidgetsContainerView.java b/src/com/android/launcher3/widget/WidgetsContainerView.java
index 70b2945f5..89c44c859 100644
--- a/src/com/android/launcher3/widget/WidgetsContainerView.java
+++ b/src/com/android/launcher3/widget/WidgetsContainerView.java
@@ -49,6 +49,7 @@ import com.android.launcher3.model.WidgetsModel;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
import com.android.launcher3.util.Thunk;
+import com.android.launcher3.util.TransformingTouchDelegate;
/**
* The widgets list view container.
@@ -64,11 +65,11 @@ public class WidgetsContainerView extends BaseContainerView
private IconCache mIconCache;
private final Rect mTmpBgPaddingRect = new Rect();
- private final Rect mTmpRect = new Rect();
/* Recycler view related member variables */
private WidgetsRecyclerView mRecyclerView;
private WidgetsListAdapter mAdapter;
+ private TransformingTouchDelegate mRecyclerViewTouchDelegate;
/* Touch handling related member variables. */
private Toast mWidgetInstructionToast;
@@ -96,29 +97,29 @@ public class WidgetsContainerView extends BaseContainerView
}
@Override
+ protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
+ super.onLayout(changed, left, top, right, bottom);
+ getRevealView().getBackground().getPadding(mTmpBgPaddingRect);
+ mRecyclerViewTouchDelegate.setBounds(
+ mRecyclerView.getLeft() - mTmpBgPaddingRect.left,
+ mRecyclerView.getTop() - mTmpBgPaddingRect.top,
+ mRecyclerView.getRight() + mTmpBgPaddingRect.right,
+ mRecyclerView.getBottom() + mTmpBgPaddingRect.bottom);
+ }
+
+ @Override
protected void onFinishInflate() {
super.onFinishInflate();
mRecyclerView = (WidgetsRecyclerView) getContentView().findViewById(R.id.widgets_list_view);
mRecyclerView.setAdapter(mAdapter);
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
+ mRecyclerViewTouchDelegate = new TransformingTouchDelegate(mRecyclerView);
}
@Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- getRevealView().getBackground().getPadding(mTmpBgPaddingRect);
- if (Utilities.isRtl(getResources())) {
- getContentView().setPadding(0, mTmpBgPaddingRect.top, mTmpBgPaddingRect.right,
- mTmpBgPaddingRect.bottom);
- mTmpRect.set(mTmpBgPaddingRect.left, 0, 0, 0);
- mRecyclerView.updateBackgroundPadding(mTmpRect);
- } else {
- getContentView().setPadding(mTmpBgPaddingRect.left, mTmpBgPaddingRect.top, 0,
- mTmpBgPaddingRect.bottom);
- mTmpRect.set(0, 0, mTmpBgPaddingRect.right, 0);
- mRecyclerView.updateBackgroundPadding(mTmpRect);
- }
-
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ protected void onAttachedToWindow() {
+ super.onAttachedToWindow();
+ ((View) mRecyclerView.getParent()).setTouchDelegate(mRecyclerViewTouchDelegate);
}
//