Merge "Refactoring some loadWorkspace logic in a separate class" into ub-launcher3-master
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index a8a25af..1a09fa0 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -81,8 +81,6 @@
<dimen name="all_apps_divider_margin_vertical">8dp</dimen>
- <dimen name="all_apps_bezel_swipe_height">24dp</dimen>
-
<!-- Widget tray -->
<dimen name="widget_preview_label_vertical_padding">8dp</dimen>
<dimen name="widget_preview_label_horizontal_padding">8dp</dimen>
diff --git a/src/com/android/launcher3/LauncherAppWidgetHostView.java b/src/com/android/launcher3/LauncherAppWidgetHostView.java
index 49bbfd0..1429df5 100644
--- a/src/com/android/launcher3/LauncherAppWidgetHostView.java
+++ b/src/com/android/launcher3/LauncherAppWidgetHostView.java
@@ -33,9 +33,11 @@
import android.view.ViewDebug;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityNodeInfo;
+import android.widget.AdapterView;
import android.widget.Advanceable;
import android.widget.RemoteViews;
+import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.dragndrop.DragLayer.TouchCompleteListener;
import java.lang.reflect.Method;
@@ -45,7 +47,8 @@
/**
* {@inheritDoc}
*/
-public class LauncherAppWidgetHostView extends AppWidgetHostView implements TouchCompleteListener {
+public class LauncherAppWidgetHostView extends AppWidgetHostView
+ implements TouchCompleteListener, View.OnLongClickListener {
private static final String TAG = "LauncherWidgetHostView";
@@ -56,11 +59,12 @@
// Maintains a list of widget ids which are supposed to be auto advanced.
private static final SparseBooleanArray sAutoAdvanceWidgetIds = new SparseBooleanArray();
- LayoutInflater mInflater;
+ protected final LayoutInflater mInflater;
- private CheckLongPressHelper mLongPressHelper;
- private StylusEventHelper mStylusEventHelper;
- private Context mContext;
+ private final CheckLongPressHelper mLongPressHelper;
+ private final StylusEventHelper mStylusEventHelper;
+ private final Context mContext;
+
@ViewDebug.ExportedProperty(category = "launcher")
private int mPreviousOrientation;
@@ -69,6 +73,7 @@
@ViewDebug.ExportedProperty(category = "launcher")
private boolean mChildrenFocused;
+ private boolean mIsScrollable;
private boolean mIsAttachedToWindow;
private boolean mIsAutoAdvanceRegistered;
private Runnable mAutoAdvanceRunnable;
@@ -86,7 +91,7 @@
public LauncherAppWidgetHostView(Context context) {
super(context);
mContext = context;
- mLongPressHelper = new CheckLongPressHelper(this);
+ mLongPressHelper = new CheckLongPressHelper(this, this);
mStylusEventHelper = new StylusEventHelper(new SimpleOnStylusPressListener(this), this);
mInflater = LayoutInflater.from(context);
setAccessibilityDelegate(Launcher.getLauncher(context).getAccessibilityDelegate());
@@ -104,6 +109,16 @@
}
@Override
+ public boolean onLongClick(View view) {
+ if (mIsScrollable) {
+ DragLayer dragLayer = Launcher.getLauncher(getContext()).getDragLayer();
+ dragLayer.requestDisallowInterceptTouchEvent(false);
+ }
+ view.performLongClick();
+ return true;
+ }
+
+ @Override
protected View getErrorView() {
return mInflater.inflate(R.layout.appwidget_error, this, false);
}
@@ -120,6 +135,24 @@
// The provider info or the views might have changed.
checkIfAutoAdvance();
+
+ mIsScrollable = checkScrollableRecursively(this);
+ }
+
+ private boolean checkScrollableRecursively(ViewGroup viewGroup) {
+ if (viewGroup instanceof AdapterView) {
+ return true;
+ } else {
+ for (int i=0; i < viewGroup.getChildCount(); i++) {
+ View child = viewGroup.getChildAt(i);
+ if (child instanceof ViewGroup) {
+ if (checkScrollableRecursively((ViewGroup) child)) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
}
public boolean isReinflateRequired() {
@@ -150,12 +183,18 @@
mLongPressHelper.cancelLongPress();
return true;
}
+
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN: {
+ DragLayer dragLayer = Launcher.getLauncher(getContext()).getDragLayer();
+
+ if (mIsScrollable) {
+ dragLayer.requestDisallowInterceptTouchEvent(true);
+ }
if (!mStylusEventHelper.inStylusButtonPressed()) {
mLongPressHelper.postCheckForLongPress();
}
- Launcher.getLauncher(getContext()).getDragLayer().setTouchCompleteListener(this);
+ dragLayer.setTouchCompleteListener(this);
break;
}
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/ShortcutInfo.java b/src/com/android/launcher3/ShortcutInfo.java
index 7f9bc2ba..77c6837 100644
--- a/src/com/android/launcher3/ShortcutInfo.java
+++ b/src/com/android/launcher3/ShortcutInfo.java
@@ -254,6 +254,9 @@
AppInfo appInfo = new AppInfo();
appInfo.user = user;
appInfo.componentName = shortcutInfo.getActivity();
+ appInfo.intent = new Intent(Intent.ACTION_MAIN)
+ .addCategory(Intent.CATEGORY_LAUNCHER)
+ .setComponent(shortcutInfo.getActivity());
cache.getTitleAndIcon(appInfo, false);
return LauncherIcons.badgeWithBitmap(unbadgedBitmap, appInfo.iconBitmap, context);
}
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/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
index c199fef..547ab2b 100644
--- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
@@ -18,15 +18,12 @@
import android.view.animation.Interpolator;
import com.android.launcher3.AbstractFloatingView;
-import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Hotseat;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAnimUtils;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.Workspace;
-import com.android.launcher3.shortcuts.DeepShortcutsContainer;
-import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
import com.android.launcher3.util.TouchController;
@@ -88,7 +85,6 @@
private static final float RECATCH_REJECTION_FRACTION = .0875f;
- private int mBezelSwipeUpHeight;
private long mAnimationDuration;
private AnimatorSet mCurrentAnimation;
@@ -104,8 +100,6 @@
mDetector.setListener(this);
mShiftRange = DEFAULT_SHIFT_RANGE;
mProgress = 1f;
- mBezelSwipeUpHeight = l.getResources().getDimensionPixelSize(
- R.dimen.all_apps_bezel_swipe_height);
mEvaluator = new ArgbEvaluator();
mAllAppsBackgroundColor = ContextCompat.getColor(l, R.color.all_apps_container_color);
@@ -120,8 +114,6 @@
} else if (mLauncher.isAllAppsVisible() &&
!mAppsView.shouldContainerScroll(ev)) {
mNoIntercept = true;
- } else if (!mLauncher.isAllAppsVisible() && !shouldPossiblyIntercept(ev)) {
- mNoIntercept = true;
} else if (AbstractFloatingView.getTopOpenView(mLauncher) != null) {
mNoIntercept = true;
} else {
@@ -150,6 +142,7 @@
ignoreSlopWhenSettling);
}
}
+
if (mNoIntercept) {
return false;
}
@@ -160,25 +153,6 @@
return mDetector.isDraggingOrSettling();
}
- private boolean shouldPossiblyIntercept(MotionEvent ev) {
- DeviceProfile grid = mLauncher.getDeviceProfile();
- if (mDetector.isIdleState()) {
- if (grid.isVerticalBarLayout()) {
- if (ev.getY() > mLauncher.getDeviceProfile().heightPx - mBezelSwipeUpHeight) {
- return true;
- }
- } else {
- if (mLauncher.getDragLayer().isEventOverHotseat(ev) ||
- mLauncher.getDragLayer().isEventOverPageIndicator(ev)) {
- return true;
- }
- }
- return false;
- } else {
- return true;
- }
- }
-
@Override
public boolean onControllerTouchEvent(MotionEvent ev) {
return mDetector.onTouchEvent(ev);
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();
}
}