Merge "This enables to slide up All Apps from anywhere in the workspace, not only over the hotseat." into ub-launcher3-master
diff --git a/src/com/android/launcher3/AppWidgetResizeFrame.java b/src/com/android/launcher3/AppWidgetResizeFrame.java
index f879216..92da9b7 100644
--- a/src/com/android/launcher3/AppWidgetResizeFrame.java
+++ b/src/com/android/launcher3/AppWidgetResizeFrame.java
@@ -212,6 +212,23 @@
lp.height = mTempRange1.size();
resizeWidgetIfNeeded(false);
+
+ // When the widget resizes in multi-window mode, the translation value changes to maintain
+ // a center fit. These overrides ensure the resize frame always aligns with the widget view.
+ getSnappedRectRelativeToDragLayer(sTmpRect);
+ if (mLeftBorderActive) {
+ lp.width = sTmpRect.width() + sTmpRect.left - lp.x;
+ }
+ if (mTopBorderActive) {
+ lp.height = sTmpRect.height() + sTmpRect.top - lp.y;
+ }
+ if (mRightBorderActive) {
+ lp.x = sTmpRect.left;
+ }
+ if (mBottomBorderActive) {
+ lp.y = sTmpRect.top;
+ }
+
requestLayout();
}
@@ -340,8 +357,8 @@
int xThreshold = mCellLayout.getCellWidth();
int yThreshold = mCellLayout.getCellHeight();
- mDeltaXAddOn = mRunningHInc * xThreshold;
- mDeltaYAddOn = mRunningVInc * yThreshold;
+ mDeltaXAddOn = mRunningHInc * xThreshold;
+ mDeltaYAddOn = mRunningVInc * yThreshold;
mDeltaX = 0;
mDeltaY = 0;
@@ -353,18 +370,35 @@
});
}
- public void snapToWidget(boolean animate) {
+ /**
+ * Returns the rect of this view when the frame is snapped around the widget, with the bounds
+ * relative to the {@link DragLayer}.
+ */
+ private void getSnappedRectRelativeToDragLayer(Rect out) {
float scale = mWidgetView.getScaleToFit();
- mDragLayer.getViewRectRelativeToSelf(mWidgetView, sTmpRect);
+ mDragLayer.getViewRectRelativeToSelf(mWidgetView, out);
- int newWidth = 2 * mBackgroundPadding
- + (int) (scale * (sTmpRect.width() - mWidgetPadding.left - mWidgetPadding.right));
- int newHeight = 2 * mBackgroundPadding
- + (int) (scale * (sTmpRect.height() - mWidgetPadding.top - mWidgetPadding.bottom));
+ int width = 2 * mBackgroundPadding
+ + (int) (scale * (out.width() - mWidgetPadding.left - mWidgetPadding.right));
+ int height = 2 * mBackgroundPadding
+ + (int) (scale * (out.height() - mWidgetPadding.top - mWidgetPadding.bottom));
- int newX = (int) (sTmpRect.left - mBackgroundPadding + scale * mWidgetPadding.left);
- int newY = (int) (sTmpRect.top - mBackgroundPadding + scale * mWidgetPadding.top);
+ int x = (int) (out.left - mBackgroundPadding + scale * mWidgetPadding.left);
+ int y = (int) (out.top - mBackgroundPadding + scale * mWidgetPadding.top);
+
+ out.left = x;
+ out.top = y;
+ out.right = out.left + width;
+ out.bottom = out.top + height;
+ }
+
+ public void snapToWidget(boolean animate) {
+ getSnappedRectRelativeToDragLayer(sTmpRect);
+ int newWidth = sTmpRect.width();
+ int newHeight = sTmpRect.height();
+ int newX = sTmpRect.left;
+ int newY = sTmpRect.top;
// We need to make sure the frame's touchable regions lie fully within the bounds of the
// DragLayer. We allow the actual handles to be clipped, but we shift the touch regions
diff --git a/src/com/android/launcher3/LauncherBackupAgent.java b/src/com/android/launcher3/LauncherBackupAgent.java
index b3e73f7..140794b 100644
--- a/src/com/android/launcher3/LauncherBackupAgent.java
+++ b/src/com/android/launcher3/LauncherBackupAgent.java
@@ -5,11 +5,19 @@
import android.app.backup.BackupDataOutput;
import android.os.ParcelFileDescriptor;
+import com.android.launcher3.logging.FileLog;
import com.android.launcher3.provider.RestoreDbTask;
public class LauncherBackupAgent extends BackupAgent {
@Override
+ public void onCreate() {
+ super.onCreate();
+ // Set the log dir as LauncherAppState is not initialized during restore.
+ FileLog.setDir(getFilesDir());
+ }
+
+ @Override
public void onRestore(
BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) {
// Doesn't do incremental backup/restore
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 2cb9138..89ffd31 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -104,6 +104,12 @@
public static final boolean ATLEAST_LOLLIPOP_MR1 =
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1;
+ /**
+ * Indicates if the device has a debug build. Should only be used to store additional info or
+ * add extra logging and not for changing the app behavior.
+ */
+ public static final boolean IS_DEBUG_DEVICE = Build.TYPE.toLowerCase().contains("debug");
+
// An intent extra to indicate the horizontal scroll of the wallpaper.
public static final String EXTRA_WALLPAPER_OFFSET = "com.android.launcher3.WALLPAPER_OFFSET";
diff --git a/src/com/android/launcher3/logging/FileLog.java b/src/com/android/launcher3/logging/FileLog.java
index 8629e92..ffb41b7 100644
--- a/src/com/android/launcher3/logging/FileLog.java
+++ b/src/com/android/launcher3/logging/FileLog.java
@@ -40,7 +40,7 @@
private static File sLogsDirectory = null;
public static void setDir(File logsDir) {
- if (ProviderConfig.IS_DOGFOOD_BUILD) {
+ if (ProviderConfig.IS_DOGFOOD_BUILD || Utilities.IS_DEBUG_DEVICE) {
synchronized (DATE_FORMAT) {
// If the target directory changes, stop any active thread.
if (sHandler != null && !logsDir.equals(sLogsDirectory)) {
diff --git a/src/com/android/launcher3/provider/ImportDataTask.java b/src/com/android/launcher3/provider/ImportDataTask.java
index 9d8e62a..808e6e3 100644
--- a/src/com/android/launcher3/provider/ImportDataTask.java
+++ b/src/com/android/launcher3/provider/ImportDataTask.java
@@ -89,10 +89,12 @@
ArrayList<Long> allScreens = LauncherDbUtils.getScreenIdsFromCursor(
mContext.getContentResolver().query(mOtherScreensUri, null, null, null,
LauncherSettings.WorkspaceScreens.SCREEN_RANK));
+ FileLog.d(TAG, "Importing DB from " + mOtherFavoritesUri);
// During import we reset the screen IDs to 0-indexed values.
if (allScreens.isEmpty()) {
// No thing to migrate
+ FileLog.e(TAG, "No data found to import");
return false;
}
@@ -293,6 +295,7 @@
}
}
}
+ FileLog.d(TAG, totalItemsOnWorkspace + " items imported from external source");
if (totalItemsOnWorkspace < MIN_ITEM_COUNT_FOR_SUCCESSFUL_MIGRATION) {
throw new Exception("Insufficient data");
}
diff --git a/src/com/android/launcher3/provider/RestoreDbTask.java b/src/com/android/launcher3/provider/RestoreDbTask.java
index 47bee06..a200a85 100644
--- a/src/com/android/launcher3/provider/RestoreDbTask.java
+++ b/src/com/android/launcher3/provider/RestoreDbTask.java
@@ -142,6 +142,7 @@
}
public static void setPending(Context context, boolean isPending) {
+ FileLog.d(TAG, "Restore data received through full backup");
Utilities.getPrefs(context).edit().putBoolean(RESTORE_TASK_PENDING, isPending).commit();
}
}