summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/values-sw600dp/config.xml3
-rw-r--r--res/values-sw600dp/dimens.xml6
-rw-r--r--res/values/config.xml1
-rw-r--r--res/values/dimens.xml3
-rw-r--r--src/com/android/launcher3/AppWidgetResizeFrame.java33
-rw-r--r--src/com/android/launcher3/DeviceProfile.java12
-rw-r--r--src/com/android/launcher3/ItemInfo.java32
-rw-r--r--src/com/android/launcher3/Launcher.java69
-rw-r--r--src/com/android/launcher3/LauncherStateTransitionAnimation.java7
-rw-r--r--src/com/android/launcher3/Utilities.java10
-rw-r--r--src/com/android/launcher3/Workspace.java43
-rw-r--r--src/com/android/launcher3/allapps/AllAppsRecyclerView.java1
-rw-r--r--src/com/android/launcher3/dragndrop/DragController.java3
-rw-r--r--src/com/android/launcher3/widget/WidgetsContainerView.java2
-rw-r--r--src/com/android/launcher3/widget/WidgetsListAdapter.java19
15 files changed, 95 insertions, 149 deletions
diff --git a/res/values-sw600dp/config.xml b/res/values-sw600dp/config.xml
index a7345a705..eb9af9793 100644
--- a/res/values-sw600dp/config.xml
+++ b/res/values-sw600dp/config.xml
@@ -1,7 +1,4 @@
<resources>
<bool name="is_tablet">true</bool>
<bool name="allow_rotation">true</bool>
-
-<!-- DragController -->
- <integer name="config_flingToDeleteMinVelocity">-1000</integer>
</resources>
diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml
index 2651fbb3f..c1ac9aa44 100644
--- a/res/values-sw600dp/dimens.xml
+++ b/res/values-sw600dp/dimens.xml
@@ -28,4 +28,10 @@
<dimen name="cling_migration_content_margin">64dp</dimen>
<dimen name="cling_migration_content_width">280dp</dimen>
+<!-- Widget tray -->
+ <dimen name="widget_section_indent">56dp</dimen>
+
+
+<!-- DragController -->
+ <dimen name="drag_flingToDeleteMinVelocity">-1000dp</dimen>
</resources>
diff --git a/res/values/config.xml b/res/values/config.xml
index 0f18dffb8..6a6784015 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -17,7 +17,6 @@
<bool name="enable_backup">false</bool>
<!-- DragController -->
- <integer name="config_flingToDeleteMinVelocity">-1500</integer>
<item type="id" name="drag_event_parity" />
<!-- AllApps & Launcher transitions -->
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index b9fb6e257..cc5be1f1e 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -85,6 +85,7 @@
<dimen name="widget_section_icon_size">40dp</dimen>
<dimen name="widget_section_vertical_padding">8dp</dimen>
<dimen name="widget_section_horizontal_padding">16dp</dimen>
+ <dimen name="widget_section_indent">0dp</dimen>
<dimen name="widget_row_padding">8dp</dimen>
<dimen name="widget_row_divider">2dp</dimen>
@@ -111,6 +112,8 @@
and drop targets like all-apps and folders -->
<dimen name="drag_elevation">30dp</dimen>
+ <dimen name="drag_flingToDeleteMinVelocity">-1500dp</dimen>
+
<!-- Theme -->
<dimen name="quantum_panel_outer_padding">4dp</dimen>
diff --git a/src/com/android/launcher3/AppWidgetResizeFrame.java b/src/com/android/launcher3/AppWidgetResizeFrame.java
index 2846b55e0..6818929f7 100644
--- a/src/com/android/launcher3/AppWidgetResizeFrame.java
+++ b/src/com/android/launcher3/AppWidgetResizeFrame.java
@@ -11,6 +11,7 @@ import android.appwidget.AppWidgetHostView;
import android.appwidget.AppWidgetProviderInfo;
import android.content.Context;
import android.content.res.Resources;
+import android.graphics.Point;
import android.graphics.Rect;
import android.view.Gravity;
import android.widget.FrameLayout;
@@ -21,7 +22,10 @@ public class AppWidgetResizeFrame extends FrameLayout {
private static final float DIMMED_HANDLE_ALPHA = 0f;
private static final float RESIZE_THRESHOLD = 0.66f;
- private static Rect sTmpRect = new Rect();
+ private static final Rect sTmpRect = new Rect();
+
+ // Represents the cell size on the grid in the two orientations.
+ private static Point[] sCellSize;
private final Launcher mLauncher;
private final LauncherAppWidgetHostView mWidgetView;
@@ -343,28 +347,27 @@ public class AppWidgetResizeFrame extends FrameLayout {
}
public static Rect getWidgetSizeRanges(Launcher launcher, int spanX, int spanY, Rect rect) {
+ if (sCellSize == null) {
+ InvariantDeviceProfile inv = LauncherAppState.getInstance().getInvariantDeviceProfile();
+
+ // Initiate cell sizes.
+ sCellSize = new Point[2];
+ sCellSize[0] = inv.landscapeProfile.getCellSize();
+ sCellSize[1] = inv.portraitProfile.getCellSize();
+ }
+
if (rect == null) {
rect = new Rect();
}
- Rect landMetrics = Workspace.getCellLayoutMetrics(launcher, CellLayout.LANDSCAPE);
- Rect portMetrics = Workspace.getCellLayoutMetrics(launcher, CellLayout.PORTRAIT);
final float density = launcher.getResources().getDisplayMetrics().density;
// Compute landscape size
- int cellWidth = landMetrics.left;
- int cellHeight = landMetrics.top;
- int widthGap = landMetrics.right;
- int heightGap = landMetrics.bottom;
- int landWidth = (int) ((spanX * cellWidth + (spanX - 1) * widthGap) / density);
- int landHeight = (int) ((spanY * cellHeight + (spanY - 1) * heightGap) / density);
+ int landWidth = (int) ((spanX * sCellSize[0].x) / density);
+ int landHeight = (int) ((spanY * sCellSize[0].y) / density);
// Compute portrait size
- cellWidth = portMetrics.left;
- cellHeight = portMetrics.top;
- widthGap = portMetrics.right;
- heightGap = portMetrics.bottom;
- int portWidth = (int) ((spanX * cellWidth + (spanX - 1) * widthGap) / density);
- int portHeight = (int) ((spanY * cellHeight + (spanY - 1) * heightGap) / density);
+ int portWidth = (int) ((spanX * sCellSize[1].x) / density);
+ int portHeight = (int) ((spanY * sCellSize[1].y) / density);
rect.set(portWidth, landHeight, landWidth, portHeight);
return rect;
}
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 9b4642d66..6364d90c1 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -280,6 +280,18 @@ public class DeviceProfile {
return bounds;
}
+ public Point getCellSize() {
+ Point result = new Point();
+ // Since we are only concerned with the overall padding, layout direction does
+ // not matter.
+ Rect padding = getWorkspacePadding(false /* isLayoutRtl */ );
+ result.x = calculateCellWidth(availableWidthPx - padding.left - padding.right,
+ inv.numColumns);
+ result.y = calculateCellHeight(availableHeightPx - padding.top - padding.bottom,
+ inv.numRows);
+ return result;
+ }
+
/** Returns the workspace padding in the specified orientation */
Rect getWorkspacePadding(boolean isLayoutRtl) {
Rect searchBarBounds = getSearchBarBounds(isLayoutRtl);
diff --git a/src/com/android/launcher3/ItemInfo.java b/src/com/android/launcher3/ItemInfo.java
index 956bb8c75..6d5bbab33 100644
--- a/src/com/android/launcher3/ItemInfo.java
+++ b/src/com/android/launcher3/ItemInfo.java
@@ -137,15 +137,8 @@ public class ItemInfo {
return null;
}
- /**
- * Write the fields of this item to the DB
- *
- * @param context A context object to use for getting UserManagerCompat
- * @param values
- */
-
- void onAddToDatabase(Context context, ContentValues values) {
- values.put(LauncherSettings.BaseLauncherColumns.ITEM_TYPE, itemType);
+ public void writeToValues(ContentValues values) {
+ values.put(LauncherSettings.Favorites.ITEM_TYPE, itemType);
values.put(LauncherSettings.Favorites.CONTAINER, container);
values.put(LauncherSettings.Favorites.SCREEN, screenId);
values.put(LauncherSettings.Favorites.CELLX, cellX);
@@ -153,6 +146,27 @@ public class ItemInfo {
values.put(LauncherSettings.Favorites.SPANX, spanX);
values.put(LauncherSettings.Favorites.SPANY, spanY);
values.put(LauncherSettings.Favorites.RANK, rank);
+ }
+
+ public void readFromValues(ContentValues values) {
+ itemType = values.getAsInteger(LauncherSettings.Favorites.ITEM_TYPE);
+ container = values.getAsLong(LauncherSettings.Favorites.CONTAINER);
+ screenId = values.getAsLong(LauncherSettings.Favorites.SCREEN);
+ cellX = values.getAsInteger(LauncherSettings.Favorites.ITEM_TYPE);
+ cellY = values.getAsInteger(LauncherSettings.Favorites.ITEM_TYPE);
+ spanX = values.getAsInteger(LauncherSettings.Favorites.ITEM_TYPE);
+ spanY = values.getAsInteger(LauncherSettings.Favorites.ITEM_TYPE);
+ rank = values.getAsInteger(LauncherSettings.Favorites.ITEM_TYPE);
+ }
+
+ /**
+ * Write the fields of this item to the DB
+ *
+ * @param context A context object to use for getting UserManagerCompat
+ * @param values
+ */
+ void onAddToDatabase(Context context, ContentValues values) {
+ writeToValues(values);
long serialNumber = UserManagerCompat.getInstance(context).getSerialNumberForUser(user);
values.put(LauncherSettings.Favorites.PROFILE_ID, serialNumber);
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 9533da7d8..d926cc170 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -35,6 +35,7 @@ import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
import android.content.ComponentCallbacks2;
import android.content.ComponentName;
+import android.content.ContentValues;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
@@ -73,7 +74,6 @@ import android.view.Display;
import android.view.Gravity;
import android.view.HapticFeedbackConstants;
import android.view.KeyEvent;
-import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.Surface;
@@ -177,18 +177,8 @@ public class Launcher extends Activity
private static final String RUNTIME_STATE_CURRENT_SCREEN = "launcher.current_screen";
// Type: int
private static final String RUNTIME_STATE = "launcher.state";
- // Type: int
- private static final String RUNTIME_STATE_PENDING_ADD_CONTAINER = "launcher.add_container";
- // Type: int
- private static final String RUNTIME_STATE_PENDING_ADD_SCREEN = "launcher.add_screen";
- // Type: int
- private static final String RUNTIME_STATE_PENDING_ADD_CELL_X = "launcher.add_cell_x";
- // Type: int
- private static final String RUNTIME_STATE_PENDING_ADD_CELL_Y = "launcher.add_cell_y";
- // Type: int
- private static final String RUNTIME_STATE_PENDING_ADD_SPAN_X = "launcher.add_span_x";
- // Type: int
- private static final String RUNTIME_STATE_PENDING_ADD_SPAN_Y = "launcher.add_span_y";
+ // Type: Content Values / parcelable
+ private static final String RUNTIME_STATE_PENDING_ADD_ITEM = "launcher.add_item";
// Type: parcelable
private static final String RUNTIME_STATE_PENDING_ADD_WIDGET_INFO = "launcher.add_widget_info";
// Type: parcelable
@@ -239,8 +229,6 @@ public class Launcher extends Activity
private final BroadcastReceiver mCloseSystemDialogsReceiver
= new CloseSystemDialogsIntentReceiver();
- private LayoutInflater mInflater;
-
@Thunk Workspace mWorkspace;
private View mLauncherView;
private View mPageIndicators;
@@ -272,7 +260,6 @@ public class Launcher extends Activity
@Thunk WidgetsContainerView mWidgetsView;
@Thunk WidgetsModel mWidgetsModel;
- private boolean mAutoAdvanceRunning = false;
private AppWidgetHostView mQsb;
private Bundle mSavedState;
@@ -306,16 +293,17 @@ public class Launcher extends Activity
// Related to the auto-advancing of widgets
private final int ADVANCE_MSG = 1;
- private final int mAdvanceInterval = 20000;
- private final int mAdvanceStagger = 250;
+ private static final int ADVANCE_INTERVAL = 20000;
+ private static final int ADVANCE_STAGGER = 250;
+
+ private boolean mAutoAdvanceRunning = false;
private long mAutoAdvanceSentTime;
private long mAutoAdvanceTimeLeft = -1;
- @Thunk HashMap<View, AppWidgetProviderInfo> mWidgetsToAdvance =
- new HashMap<View, AppWidgetProviderInfo>();
+ @Thunk HashMap<View, AppWidgetProviderInfo> mWidgetsToAdvance = new HashMap<>();
// Determines how long to wait after a rotation before restoring the screen orientation to
// match the sensor state.
- private final int mRestoreScreenOrientationDelay = 500;
+ private static final int RESTORE_SCREEN_ORIENTATION_DELAY = 500;
@Thunk Drawable mWorkspaceBackgroundDrawable;
@@ -435,7 +423,6 @@ public class Launcher extends Activity
mIconCache = app.getIconCache();
mDragController = new DragController(this);
- mInflater = getLayoutInflater();
mStateTransitionAnimation = new LauncherStateTransitionAnimation(this);
mStats = new Stats(this);
@@ -640,10 +627,6 @@ public class Launcher extends Activity
return mStats;
}
- public LayoutInflater getInflater() {
- return mInflater;
- }
-
public boolean isDraggingEnabled() {
// We prevent dragging when we are loading the workspace as it is possible to pick up a view
// that is subsequently removed from the workspace in startBinding().
@@ -1307,16 +1290,9 @@ public class Launcher extends Activity
mWorkspace.setRestorePage(currentScreen);
}
- final long pendingAddContainer = savedState.getLong(RUNTIME_STATE_PENDING_ADD_CONTAINER, -1);
- final long pendingAddScreen = savedState.getLong(RUNTIME_STATE_PENDING_ADD_SCREEN, -1);
-
- if (pendingAddContainer != ItemInfo.NO_ID && pendingAddScreen > -1) {
- mPendingAddInfo.container = pendingAddContainer;
- mPendingAddInfo.screenId = pendingAddScreen;
- mPendingAddInfo.cellX = savedState.getInt(RUNTIME_STATE_PENDING_ADD_CELL_X);
- mPendingAddInfo.cellY = savedState.getInt(RUNTIME_STATE_PENDING_ADD_CELL_Y);
- mPendingAddInfo.spanX = savedState.getInt(RUNTIME_STATE_PENDING_ADD_SPAN_X);
- mPendingAddInfo.spanY = savedState.getInt(RUNTIME_STATE_PENDING_ADD_SPAN_Y);
+ ContentValues itemValues = savedState.getParcelable(RUNTIME_STATE_PENDING_ADD_ITEM);
+ if (itemValues != null) {
+ mPendingAddInfo.readFromValues(itemValues);
AppWidgetProviderInfo info = savedState.getParcelable(
RUNTIME_STATE_PENDING_ADD_WIDGET_INFO);
mPendingAddWidgetInfo = info == null ?
@@ -1475,7 +1451,7 @@ public class Launcher extends Activity
* @return A View inflated from layoutResId.
*/
public View createShortcut(ViewGroup parent, ShortcutInfo info) {
- BubbleTextView favorite = (BubbleTextView) mInflater.inflate(R.layout.app_icon,
+ BubbleTextView favorite = (BubbleTextView) getLayoutInflater().inflate(R.layout.app_icon,
parent, false);
favorite.applyFromShortcutInfo(info, mIconCache);
favorite.setCompoundDrawablePadding(mDeviceProfile.iconDrawablePaddingPx);
@@ -1721,11 +1697,11 @@ public class Launcher extends Activity
if (autoAdvanceRunning != mAutoAdvanceRunning) {
mAutoAdvanceRunning = autoAdvanceRunning;
if (autoAdvanceRunning) {
- long delay = mAutoAdvanceTimeLeft == -1 ? mAdvanceInterval : mAutoAdvanceTimeLeft;
+ long delay = mAutoAdvanceTimeLeft == -1 ? ADVANCE_INTERVAL : mAutoAdvanceTimeLeft;
sendAdvanceMessage(delay);
} else {
if (!mWidgetsToAdvance.isEmpty()) {
- mAutoAdvanceTimeLeft = Math.max(0, mAdvanceInterval -
+ mAutoAdvanceTimeLeft = Math.max(0, ADVANCE_INTERVAL -
(System.currentTimeMillis() - mAutoAdvanceSentTime));
}
mHandler.removeMessages(ADVANCE_MSG);
@@ -1742,7 +1718,7 @@ public class Launcher extends Activity
int i = 0;
for (View key: mWidgetsToAdvance.keySet()) {
final View v = key.findViewById(mWidgetsToAdvance.get(key).autoAdvanceViewId);
- final int delay = mAdvanceStagger * i;
+ final int delay = ADVANCE_STAGGER * i;
if (v instanceof Advanceable) {
mHandler.postDelayed(new Runnable() {
public void run() {
@@ -1752,7 +1728,7 @@ public class Launcher extends Activity
}
i++;
}
- sendAdvanceMessage(mAdvanceInterval);
+ sendAdvanceMessage(ADVANCE_INTERVAL);
}
return true;
}
@@ -1943,12 +1919,9 @@ public class Launcher extends Activity
if (mPendingAddInfo.container != ItemInfo.NO_ID && mPendingAddInfo.screenId > -1 &&
mWaitingForResult) {
- outState.putLong(RUNTIME_STATE_PENDING_ADD_CONTAINER, mPendingAddInfo.container);
- outState.putLong(RUNTIME_STATE_PENDING_ADD_SCREEN, mPendingAddInfo.screenId);
- outState.putInt(RUNTIME_STATE_PENDING_ADD_CELL_X, mPendingAddInfo.cellX);
- outState.putInt(RUNTIME_STATE_PENDING_ADD_CELL_Y, mPendingAddInfo.cellY);
- outState.putInt(RUNTIME_STATE_PENDING_ADD_SPAN_X, mPendingAddInfo.spanX);
- outState.putInt(RUNTIME_STATE_PENDING_ADD_SPAN_Y, mPendingAddInfo.spanY);
+ ContentValues itemValues = new ContentValues();
+ mPendingAddInfo.writeToValues(itemValues);
+ outState.putParcelable(RUNTIME_STATE_PENDING_ADD_ITEM, itemValues);
outState.putParcelable(RUNTIME_STATE_PENDING_ADD_WIDGET_INFO, mPendingAddWidgetInfo);
outState.putInt(RUNTIME_STATE_PENDING_ADD_WIDGET_ID, mPendingAddWidgetId);
}
@@ -4309,7 +4282,7 @@ public class Launcher extends Activity
public void run() {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
}
- }, mRestoreScreenOrientationDelay);
+ }, RESTORE_SCREEN_ORIENTATION_DELAY);
}
}
}
diff --git a/src/com/android/launcher3/LauncherStateTransitionAnimation.java b/src/com/android/launcher3/LauncherStateTransitionAnimation.java
index 3d1efc64b..0e20fabbd 100644
--- a/src/com/android/launcher3/LauncherStateTransitionAnimation.java
+++ b/src/com/android/launcher3/LauncherStateTransitionAnimation.java
@@ -23,7 +23,9 @@ import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.animation.TimeInterpolator;
import android.annotation.SuppressLint;
+import android.annotation.TargetApi;
import android.content.res.Resources;
+import android.os.Build;
import android.util.Log;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
@@ -361,7 +363,7 @@ public class LauncherStateTransitionAnimation {
if (layerViews.get(v) == BUILD_AND_SET_LAYER) {
v.setLayerType(View.LAYER_TYPE_HARDWARE, null);
}
- if (Utilities.ATLEAST_LOLLIPOP && Utilities.isViewAttachedToWindow(v)) {
+ if (Utilities.ATLEAST_LOLLIPOP && v.isAttachedToWindow()) {
v.buildLayer();
}
}
@@ -656,6 +658,7 @@ public class LauncherStateTransitionAnimation {
final AnimatorSet stateAnimation = animation;
final Runnable startAnimRunnable = new Runnable() {
+ @TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void run() {
// Check that mCurrentAnimation hasn't changed while
// we waited for a layout/draw pass
@@ -670,7 +673,7 @@ public class LauncherStateTransitionAnimation {
if (layerViews.get(v) == BUILD_AND_SET_LAYER) {
v.setLayerType(View.LAYER_TYPE_HARDWARE, null);
}
- if (Utilities.ATLEAST_LOLLIPOP && Utilities.isViewAttachedToWindow(v)) {
+ if (Utilities.ATLEAST_LOLLIPOP && v.isAttachedToWindow()) {
v.buildLayer();
}
}
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index e0a4a1c3a..2340f95aa 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -529,16 +529,6 @@ public final class Utilities {
return null;
}
- @TargetApi(Build.VERSION_CODES.KITKAT)
- public static boolean isViewAttachedToWindow(View v) {
- if (ATLEAST_KITKAT) {
- return v.isAttachedToWindow();
- } else {
- // A proxy call which returns null, if the view is not attached to the window.
- return v.getKeyDispatcherState() != null;
- }
- }
-
/**
* Returns a widget with category {@link AppWidgetProviderInfo#WIDGET_CATEGORY_SEARCHBOX}
* provided by the same package which is set to be global search activity.
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 5115bf344..964a83db1 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -48,7 +48,6 @@ import android.util.AttributeSet;
import android.util.Log;
import android.util.SparseArray;
import android.view.Choreographer;
-import android.view.Display;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
@@ -140,9 +139,6 @@ public class Workspace extends PagedView
private int mDragOverX = -1;
private int mDragOverY = -1;
- private static Rect mLandscapeCellLayoutMetrics = null;
- private static Rect mPortraitCellLayoutMetrics = null;
-
CustomContentCallbacks mCustomContentCallbacks;
boolean mCustomContentShowing;
private float mLastCustomContentScrollProgress = -1f;
@@ -2851,45 +2847,6 @@ public class Workspace extends PagedView
}
}
- /** Return a rect that has the cellWidth/cellHeight (left, top), and
- * widthGap/heightGap (right, bottom) */
- static Rect getCellLayoutMetrics(Launcher launcher, int orientation) {
- LauncherAppState app = LauncherAppState.getInstance();
- InvariantDeviceProfile inv = app.getInvariantDeviceProfile();
-
- Display display = launcher.getWindowManager().getDefaultDisplay();
- Point smallestSize = new Point();
- Point largestSize = new Point();
- display.getCurrentSizeRange(smallestSize, largestSize);
- int countX = (int) inv.numColumns;
- int countY = (int) inv.numRows;
- boolean isLayoutRtl = Utilities.isRtl(launcher.getResources());
- if (orientation == CellLayout.LANDSCAPE) {
- if (mLandscapeCellLayoutMetrics == null) {
- Rect padding = inv.landscapeProfile.getWorkspacePadding(isLayoutRtl);
- int width = largestSize.x - padding.left - padding.right;
- int height = smallestSize.y - padding.top - padding.bottom;
- mLandscapeCellLayoutMetrics = new Rect();
- mLandscapeCellLayoutMetrics.set(
- DeviceProfile.calculateCellWidth(width, countX),
- DeviceProfile.calculateCellHeight(height, countY), 0, 0);
- }
- return mLandscapeCellLayoutMetrics;
- } else if (orientation == CellLayout.PORTRAIT) {
- if (mPortraitCellLayoutMetrics == null) {
- Rect padding = inv.portraitProfile.getWorkspacePadding(isLayoutRtl);
- int width = smallestSize.x - padding.left - padding.right;
- int height = largestSize.y - padding.top - padding.bottom;
- mPortraitCellLayoutMetrics = new Rect();
- mPortraitCellLayoutMetrics.set(
- DeviceProfile.calculateCellWidth(width, countX),
- DeviceProfile.calculateCellHeight(height, countY), 0, 0);
- }
- return mPortraitCellLayoutMetrics;
- }
- return null;
- }
-
@Override
public void onDragExit(DragObject d) {
if (ENFORCE_DRAG_EVENT_ORDER) {
diff --git a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
index 1187a6455..5ec8bb258 100644
--- a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
@@ -27,6 +27,7 @@ import com.android.launcher3.BaseRecyclerView;
import com.android.launcher3.BaseRecyclerViewFastScrollBar;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Stats;
+import com.android.launcher3.Utilities;
import com.android.launcher3.util.Thunk;
import java.util.List;
diff --git a/src/com/android/launcher3/dragndrop/DragController.java b/src/com/android/launcher3/dragndrop/DragController.java
index 97315cf04..8777dc6ae 100644
--- a/src/com/android/launcher3/dragndrop/DragController.java
+++ b/src/com/android/launcher3/dragndrop/DragController.java
@@ -169,9 +169,8 @@ public class DragController implements DragDriver.EventListener {
mScrollZone = r.getDimensionPixelSize(R.dimen.scroll_zone);
mVelocityTracker = VelocityTracker.obtain();
- float density = r.getDisplayMetrics().density;
mFlingToDeleteThresholdVelocity =
- (int) (r.getInteger(R.integer.config_flingToDeleteMinVelocity) * density);
+ r.getDimensionPixelSize(R.dimen.drag_flingToDeleteMinVelocity);
mIsRtl = Utilities.isRtl(r);
}
diff --git a/src/com/android/launcher3/widget/WidgetsContainerView.java b/src/com/android/launcher3/widget/WidgetsContainerView.java
index dfdf9643a..e6059d5c7 100644
--- a/src/com/android/launcher3/widget/WidgetsContainerView.java
+++ b/src/com/android/launcher3/widget/WidgetsContainerView.java
@@ -90,7 +90,7 @@ public class WidgetsContainerView extends BaseContainerView
super(context, attrs, defStyleAttr);
mLauncher = (Launcher) context;
mDragController = mLauncher.getDragController();
- mAdapter = new WidgetsListAdapter(context, this, this, mLauncher);
+ mAdapter = new WidgetsListAdapter(this, this, mLauncher);
mIconCache = (LauncherAppState.getInstance()).getIconCache();
if (DEBUG) {
Log.d(TAG, "WidgetsContainerView constructor");
diff --git a/src/com/android/launcher3/widget/WidgetsListAdapter.java b/src/com/android/launcher3/widget/WidgetsListAdapter.java
index 885d96fe5..ac9d62e9a 100644
--- a/src/com/android/launcher3/widget/WidgetsListAdapter.java
+++ b/src/com/android/launcher3/widget/WidgetsListAdapter.java
@@ -64,20 +64,17 @@ public class WidgetsListAdapter extends Adapter<WidgetsRowViewHolder> {
private View.OnClickListener mIconClickListener;
private View.OnLongClickListener mIconLongClickListener;
- private static final int PRESET_INDENT_SIZE_TABLET = 56;
- private int mIndent = 0;
+ private final int mIndent;
- public WidgetsListAdapter(Context context,
- View.OnClickListener iconClickListener,
+ public WidgetsListAdapter(View.OnClickListener iconClickListener,
View.OnLongClickListener iconLongClickListener,
Launcher launcher) {
- mLayoutInflater = LayoutInflater.from(context);
+ mLayoutInflater = launcher.getLayoutInflater();
mIconClickListener = iconClickListener;
mIconLongClickListener = iconLongClickListener;
mLauncher = launcher;
-
- setContainerHeight();
+ mIndent = launcher.getResources().getDimensionPixelSize(R.dimen.widget_section_indent);
}
public void setWidgetsModel(WidgetsModel w) {
@@ -206,12 +203,4 @@ public class WidgetsListAdapter extends Adapter<WidgetsRowViewHolder> {
}
return mWidgetPreviewLoader;
}
-
- private void setContainerHeight() {
- Resources r = mLauncher.getResources();
- DeviceProfile profile = mLauncher.getDeviceProfile();
- if (profile.isLargeTablet || profile.isTablet) {
- mIndent = Utilities.pxFromDp(PRESET_INDENT_SIZE_TABLET, r.getDisplayMetrics());
- }
- }
}