resolved conflicts for a8709ddb to ub-launcher3-master
Change-Id: I172395e6e172914627b6dec721070a66520557b1
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index 92e4043..289f64c 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -69,7 +69,8 @@
public static final int WORKSPACE_ACCESSIBILITY_DRAG = 2;
public static final int FOLDER_ACCESSIBILITY_DRAG = 1;
- static final String TAG = "CellLayout";
+ private static final String TAG = "CellLayout";
+ private static final boolean LOGD = false;
private Launcher mLauncher;
@Thunk int mCellWidth;
@@ -244,9 +245,7 @@
// If an animation is started and then stopped very quickly, we can still
// get spurious updates we've cleared the tag. Guard against this.
if (outline == null) {
- @SuppressWarnings("all") // suppress dead code warning
- final boolean debug = false;
- if (debug) {
+ if (LOGD) {
Object val = animation.getAnimatedValue();
Log.d(TAG, "anim " + thisIndex + " update: " + val +
", isStopped " + anim.isStopped());
@@ -653,6 +652,9 @@
if (lp.cellVSpan < 0) lp.cellVSpan = mCountY;
child.setId(childId);
+ if (LOGD) {
+ Log.d(TAG, "Adding view to ShortcutsAndWidgetsContainer: " + child);
+ }
mShortcutsAndWidgets.addView(child, index, lp);
if (markCells) markCellsAsOccupiedForView(child);
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 5fde615..51d075f 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -1712,14 +1712,14 @@
mWorkspace.postDelayed(mBuildLayersRunnable, 500);
final ViewTreeObserver.OnDrawListener listener = this;
mWorkspace.post(new Runnable() {
- public void run() {
- if (mWorkspace != null &&
- mWorkspace.getViewTreeObserver() != null) {
- mWorkspace.getViewTreeObserver().
- removeOnDrawListener(listener);
- }
+ public void run() {
+ if (mWorkspace != null &&
+ mWorkspace.getViewTreeObserver() != null) {
+ mWorkspace.getViewTreeObserver().
+ removeOnDrawListener(listener);
}
- });
+ }
+ });
return;
}
});
@@ -2210,8 +2210,11 @@
mPendingAddInfo.minSpanX = mPendingAddInfo.minSpanY = 1;
}
- void addAppWidgetImpl(final int appWidgetId, final ItemInfo info, final
+ void addAppWidgetFromDropImpl(final int appWidgetId, final ItemInfo info, final
AppWidgetHostView boundWidget, final LauncherAppWidgetProviderInfo appWidgetInfo) {
+ if (LOGD) {
+ Log.d(TAG, "Adding widget from drop");
+ }
addAppWidgetImpl(appWidgetId, info, boundWidget, appWidgetInfo, 0);
}
@@ -2317,8 +2320,14 @@
AppWidgetHostView hostView = info.boundWidget;
int appWidgetId;
if (hostView != null) {
+ // In the case where we've prebound the widget, we remove it from the DragLayer
+ if (LOGD) {
+ Log.d(TAG, "Removing widget view from drag layer and setting boundWidget to null");
+ }
+ getDragLayer().removeView(hostView);
+
appWidgetId = hostView.getAppWidgetId();
- addAppWidgetImpl(appWidgetId, info, hostView, info.info);
+ addAppWidgetFromDropImpl(appWidgetId, info, hostView, info.info);
// Clear the boundWidget so that it doesn't get destroyed.
info.boundWidget = null;
@@ -2331,7 +2340,7 @@
boolean success = mAppWidgetManager.bindAppWidgetIdIfAllowed(
appWidgetId, info.info, options);
if (success) {
- addAppWidgetImpl(appWidgetId, info, null, info.info);
+ addAppWidgetFromDropImpl(appWidgetId, info, null, info.info);
} else {
mPendingAddWidgetInfo = info.info;
Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND);
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 2bedb9f..66f7cb1 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -2064,6 +2064,7 @@
@Override
public void onLauncherTransitionPrepare(Launcher l, boolean animated, boolean toWorkspace) {
mIsSwitchingState = true;
+ mTransitionProgress = 0;
// Invalidate here to ensure that the pages are rendered during the state change transition.
invalidate();
@@ -3574,11 +3575,6 @@
Resources res = mLauncher.getResources();
final int duration = res.getInteger(R.integer.config_dropAnimMaxDuration) - 200;
- // In the case where we've prebound the widget, we remove it from the DragLayer
- if (finalView instanceof AppWidgetHostView && external) {
- mLauncher.getDragLayer().removeView(finalView);
- }
-
boolean isWidget = info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET ||
info.itemType == LauncherSettings.Favorites.ITEM_TYPE_CUSTOM_APPWIDGET;
if ((animationType == ANIMATE_INTO_POSITION_AND_RESIZE || external) && finalView != null) {
diff --git a/src/com/android/launcher3/widget/WidgetHostViewLoader.java b/src/com/android/launcher3/widget/WidgetHostViewLoader.java
index 7607d85..b47ba84 100644
--- a/src/com/android/launcher3/widget/WidgetHostViewLoader.java
+++ b/src/com/android/launcher3/widget/WidgetHostViewLoader.java
@@ -4,9 +4,9 @@
import android.appwidget.AppWidgetManager;
import android.content.Context;
import android.graphics.Rect;
-import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
+import android.util.Log;
import android.view.View;
import com.android.launcher3.AppWidgetResizeFrame;
@@ -16,11 +16,13 @@
import com.android.launcher3.LauncherAppWidgetProviderInfo;
import com.android.launcher3.Utilities;
import com.android.launcher3.compat.AppWidgetManagerCompat;
-import com.android.launcher3.dragndrop.DragController.DragListener;
+import com.android.launcher3.dragndrop.DragController;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.util.Thunk;
-public class WidgetHostViewLoader implements DragListener {
+public class WidgetHostViewLoader implements DragController.DragListener {
+ private static final String TAG = "WidgetHostViewLoader";
+ private static final boolean LOGD = false;
/* Runnables to handle inflation and binding. */
@Thunk Runnable mInflateWidgetRunnable = null;
@@ -49,6 +51,10 @@
@Override
public void onDragEnd() {
+ if (LOGD) {
+ Log.d(TAG, "Cleaning up in onDragEnd()...");
+ }
+
// Cleanup up preloading state.
mLauncher.getDragController().removeDragListener(this);
@@ -63,6 +69,9 @@
// The widget was inflated and added to the DragLayer -- remove it.
if (mInfo.boundWidget != null) {
+ if (LOGD) {
+ Log.d(TAG, "...removing widget from drag layer");
+ }
mLauncher.getDragLayer().removeView(mInfo.boundWidget);
mLauncher.getAppWidgetHost().deleteAppWidgetId(mInfo.boundWidget.getAppWidgetId());
mInfo.boundWidget = null;
@@ -90,6 +99,9 @@
@Override
public void run() {
mWidgetLoadingId = mLauncher.getAppWidgetHost().allocateAppWidgetId();
+ if (LOGD) {
+ Log.d(TAG, "Binding widget, id: " + mWidgetLoadingId);
+ }
if(AppWidgetManagerCompat.getInstance(mLauncher).bindAppWidgetIdIfAllowed(
mWidgetLoadingId, pInfo, options)) {
@@ -102,6 +114,9 @@
mInflateWidgetRunnable = new Runnable() {
@Override
public void run() {
+ if (LOGD) {
+ Log.d(TAG, "Inflating widget, id: " + mWidgetLoadingId);
+ }
if (mWidgetLoadingId == -1) {
return;
}
@@ -121,11 +136,17 @@
lp.x = lp.y = 0;
lp.customPosition = true;
hostView.setLayoutParams(lp);
+ if (LOGD) {
+ Log.d(TAG, "Adding host view to drag layer");
+ }
mLauncher.getDragLayer().addView(hostView);
mView.setTag(mInfo);
}
};
+ if (LOGD) {
+ Log.d(TAG, "About to bind/inflate widget");
+ }
mHandler.post(mBindWidgetRunnable);
return true;
}
diff --git a/src/com/android/launcher3/widget/WidgetsContainerView.java b/src/com/android/launcher3/widget/WidgetsContainerView.java
index 143f989..a1472cc 100644
--- a/src/com/android/launcher3/widget/WidgetsContainerView.java
+++ b/src/com/android/launcher3/widget/WidgetsContainerView.java
@@ -52,10 +52,9 @@
* The widgets list view container.
*/
public class WidgetsContainerView extends BaseContainerView
- implements View.OnLongClickListener, View.OnClickListener, DragSource{
-
+ implements View.OnLongClickListener, View.OnClickListener, DragSource {
private static final String TAG = "WidgetsContainerView";
- private static final boolean DEBUG = false;
+ private static final boolean LOGD = false;
/* Coefficient multiplied to the screen height for preloading widgets. */
private static final int PRELOAD_SCREEN_HEIGHT_MULTIPLE = 1;
@@ -92,13 +91,14 @@
mDragController = mLauncher.getDragController();
mAdapter = new WidgetsListAdapter(this, this, mLauncher);
mIconCache = (LauncherAppState.getInstance()).getIconCache();
- if (DEBUG) {
+ if (LOGD) {
Log.d(TAG, "WidgetsContainerView constructor");
}
}
@Override
protected void onFinishInflate() {
+ super.onFinishInflate();
mContent = findViewById(R.id.content);
mView = (WidgetsRecyclerView) findViewById(R.id.widgets_list_view);
mView.setAdapter(mAdapter);
@@ -158,7 +158,7 @@
@Override
public boolean onLongClick(View v) {
- if (DEBUG) {
+ if (LOGD) {
Log.d(TAG, String.format("onLonglick [v=%s]", v));
}
// Return early if this is not initiated from a touch
@@ -173,7 +173,7 @@
if (status && v.getTag() instanceof PendingAddWidgetInfo) {
WidgetHostViewLoader hostLoader = new WidgetHostViewLoader(mLauncher, v);
boolean preloadStatus = hostLoader.preloadWidget();
- if (DEBUG) {
+ if (LOGD) {
Log.d(TAG, String.format("preloading widget [status=%s]", preloadStatus));
}
mLauncher.getDragController().addDragListener(hostLoader);
@@ -304,6 +304,9 @@
@Override
public void onDropCompleted(View target, DragObject d, boolean isFlingToDelete,
boolean success) {
+ if (LOGD) {
+ Log.d(TAG, "onDropCompleted");
+ }
if (isFlingToDelete || !success || (target != mLauncher.getWorkspace() &&
!(target instanceof DeleteDropTarget) && !(target instanceof Folder))) {
// Exit spring loaded mode if we have not successfully dropped or have not handled the