diff --git a/Android.bp b/Android.bp index f5a38b4e6f..1c7c448948 100644 --- a/Android.bp +++ b/Android.bp @@ -224,6 +224,21 @@ filegroup { ], } +// Common source files used to build go launcher +filegroup { + name: "launcher-go-src-no-build-config", + srcs: [ + "src/**/*.java", + "src/**/*.kt", + "quickstep/src/**/*.java", + "quickstep/src/**/*.kt", + "go/src/**/*.java", + "go/src/**/*.kt", + "go/quickstep/src/**/*.java", + "go/quickstep/src/**/*.kt", + ], +} + // Proguard files for Launcher3 filegroup { name: "launcher-proguard-rules", diff --git a/OWNERS b/OWNERS index 05fa502b34..f3fafe77a0 100644 --- a/OWNERS +++ b/OWNERS @@ -7,13 +7,6 @@ alexchau@google.com andraskloczl@google.com patmanning@google.com -petrcermak@google.com -pbdr@google.com -kideckel@google.com -stevenckng@google.com -ydixit@google.com -boadway@google.com -alinazaidi@google.com adamcohen@google.com hyunyoungs@google.com mrcasey@google.com diff --git a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java index a26f3e890d..cb6094b749 100644 --- a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java @@ -41,6 +41,7 @@ import android.hardware.SensorManager; import android.hardware.devicestate.DeviceStateManager; import android.os.Bundle; import android.os.CancellationSignal; +import android.os.IBinder; import android.view.Display; import android.view.View; import android.view.WindowInsets; @@ -548,11 +549,26 @@ public abstract class BaseQuickstepLauncher extends Launcher } /** - * Adds a new launch cookie for the activity launch of the given {@param info} if supported. + * Adds a new launch cookie for the activity launch if supported. + * + * @param info the item info for the launch + * @param opts the options to set the launchCookie on. */ public void addLaunchCookie(ItemInfo info, ActivityOptions opts) { + IBinder launchCookie = getLaunchCookie(info); + if (launchCookie != null) { + opts.setLaunchCookie(launchCookie); + } + } + + /** + * Return a new launch cookie for the activity launch if supported. + * + * @param info the item info for the launch + */ + public IBinder getLaunchCookie(ItemInfo info) { if (info == null) { - return; + return null; } switch (info.container) { case LauncherSettings.Favorites.CONTAINER_DESKTOP: @@ -566,8 +582,7 @@ public abstract class BaseQuickstepLauncher extends Launcher break; } // Reset any existing launch cookies associated with the cookie - opts.setLaunchCookie(ObjectWrapper.wrap(NO_MATCHING_ID)); - return; + return ObjectWrapper.wrap(NO_MATCHING_ID); } switch (info.itemType) { case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION: @@ -578,10 +593,9 @@ public abstract class BaseQuickstepLauncher extends Launcher break; default: // Reset any existing launch cookies associated with the cookie - opts.setLaunchCookie(ObjectWrapper.wrap(NO_MATCHING_ID)); - return; + return ObjectWrapper.wrap(NO_MATCHING_ID); } - opts.setLaunchCookie(ObjectWrapper.wrap(new Integer(info.id))); + return ObjectWrapper.wrap(new Integer(info.id)); } public void setHintUserWillBeActive() { diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepInteractionHandler.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepInteractionHandler.java index c058aa7bba..be7535a90e 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepInteractionHandler.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepInteractionHandler.java @@ -21,6 +21,7 @@ import android.app.ActivityOptions; import android.app.ActivityTaskManager; import android.app.PendingIntent; import android.content.Intent; +import android.os.IBinder; import android.os.RemoteException; import android.util.Log; import android.util.Pair; @@ -58,6 +59,12 @@ class QuickstepInteractionHandler implements RemoteViews.InteractionHandler { Pair options = remoteResponse.getLaunchOptions(view); ActivityOptionsWrapper activityOptions = mLauncher.getAppTransitionManager() .getActivityLaunchOptions(hostView); + Object itemInfo = hostView.getTag(); + IBinder launchCookie = null; + if (itemInfo instanceof ItemInfo) { + launchCookie = mLauncher.getLaunchCookie((ItemInfo) itemInfo); + activityOptions.options.setLaunchCookie(launchCookie); + } if (Utilities.ATLEAST_S && !pendingIntent.isActivity()) { // In the event this pending intent eventually launches an activity, i.e. a trampoline, // use the Quickstep transition animation. @@ -65,17 +72,14 @@ class QuickstepInteractionHandler implements RemoteViews.InteractionHandler { ActivityTaskManager.getService() .registerRemoteAnimationForNextActivityStart( pendingIntent.getCreatorPackage(), - activityOptions.options.getRemoteAnimationAdapter()); + activityOptions.options.getRemoteAnimationAdapter(), + launchCookie); } catch (RemoteException e) { // Do nothing. } } activityOptions.options.setPendingIntentLaunchFlags(Intent.FLAG_ACTIVITY_NEW_TASK); activityOptions.options.setSplashScreenStyle(SplashScreen.SPLASH_SCREEN_STYLE_EMPTY); - Object itemInfo = hostView.getTag(); - if (itemInfo instanceof ItemInfo) { - mLauncher.addLaunchCookie((ItemInfo) itemInfo, activityOptions.options); - } options = Pair.create(options.first, activityOptions.options); if (pendingIntent.isActivity()) { logAppLaunch(itemInfo); diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java b/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java index 4583fc3f5e..cd14b3f75c 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java +++ b/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java @@ -38,7 +38,7 @@ public class AllAppsState extends LauncherState { @Override public int getTransitionDuration(Context context) { - return 320; + return 150; } @Override diff --git a/quickstep/src/com/android/quickstep/SystemUiProxy.java b/quickstep/src/com/android/quickstep/SystemUiProxy.java index d28796c89e..8b00f45426 100644 --- a/quickstep/src/com/android/quickstep/SystemUiProxy.java +++ b/quickstep/src/com/android/quickstep/SystemUiProxy.java @@ -816,8 +816,12 @@ public class SystemUiProxy implements ISystemUiProxy, public ArrayList getRecentTasks(int numTasks, int userId) { if (mRecentTasks != null) { try { - return new ArrayList<>(Arrays.asList(mRecentTasks.getRecentTasks(numTasks, - RECENT_IGNORE_UNAVAILABLE, userId))); + final GroupedRecentTaskInfo[] rawTasks = mRecentTasks.getRecentTasks(numTasks, + RECENT_IGNORE_UNAVAILABLE, userId); + if (rawTasks == null) { + return new ArrayList<>(); + } + return new ArrayList<>(Arrays.asList(rawTasks)); } catch (RemoteException e) { Log.w(TAG, "Failed call getRecentTasks", e); } diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java index 2ed75b5c98..fc5f34df9a 100644 --- a/quickstep/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java @@ -959,6 +959,9 @@ public class TouchInteractionService extends Service pw.println("ProtoTrace:"); pw.println(" file=" + ProtoTracer.INSTANCE.get(this).getTraceFile()); mTaskbarManager.dumpLogs("", pw); + if (createdOverviewActivity != null) { + createdOverviewActivity.getDeviceProfile().dump("", pw); + } } } diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java index cb0cc113b0..e1680fc7e7 100644 --- a/src/com/android/launcher3/Hotseat.java +++ b/src/com/android/launcher3/Hotseat.java @@ -173,9 +173,15 @@ public class Hotseat extends CellLayout implements Insettable { protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); - int width = mActivity.getDeviceProfile().isQsbInline - ? mActivity.getDeviceProfile().qsbWidth - : getShortcutsAndWidgets().getMeasuredWidth(); + int width; + if (mActivity.getDeviceProfile().isQsbInline) { + width = mActivity.getDeviceProfile().qsbWidth; + } else { + MarginLayoutParams qsbParams = (MarginLayoutParams) mQsb.getLayoutParams(); + width = getShortcutsAndWidgets().getMeasuredWidth() + - qsbParams.getMarginStart() + - qsbParams.getMarginEnd(); + } mQsb.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(mQsbHeight, MeasureSpec.EXACTLY)); diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 8fb2f53ec6..e2bce00fcc 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -2173,10 +2173,6 @@ public class Launcher extends StatefulActivity implements Launche IntSet result = new IntSet(); if (visibleIds.isEmpty()) { - if (TestProtocol.sDebugTracing) { - Log.d(TestProtocol.NULL_INT_SET, "getPagesToBindSynchronously (1): " - + result); - } return result; } for (int id : orderedScreenIds.toArray()) { @@ -2197,10 +2193,6 @@ public class Launcher extends StatefulActivity implements Launche // pages being hidden in single panel. result.add(pairId); } - if (TestProtocol.sDebugTracing) { - Log.d(TestProtocol.NULL_INT_SET, "getPagesToBindSynchronously (2): " - + result); - } return result; } diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java index 8646849c2c..2d7fcb12fa 100644 --- a/src/com/android/launcher3/LauncherModel.java +++ b/src/com/android/launcher3/LauncherModel.java @@ -357,12 +357,6 @@ public class LauncherModel extends LauncherApps.Callback implements InstallSessi public void addCallbacks(Callbacks callbacks) { Preconditions.assertUIThread(); synchronized (mCallbacksList) { - if (TestProtocol.sDebugTracing) { - Log.d(TestProtocol.NULL_INT_SET, "addCallbacks pointer: " - + callbacks - + ", name: " - + callbacks.getClass().getName(), new Exception()); - } mCallbacksList.add(callbacks); } } diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index b3f5c0334f..df97d2fd06 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -2484,21 +2484,27 @@ public class Workspace extends PagedView } } + // Note, centerX represents the center of the object that is being dragged, visually. d.x + // represents the location of the finger within the dragged item. + float touchX; + float touchY = d.y; + + // Go through the pages and check if the dragged item is inside one of them. This block + // is responsible for determining whether we need to snap to a different screen. int nextPage = getNextPage(); - IntSet pageIndexesToVerify = IntSet.wrap(nextPage - 1, nextPage + 1); - if (isTwoPanelEnabled()) { - // If two panel is enabled, users can also drag items to nextPage + 2 - pageIndexesToVerify.add(nextPage + 2); - } - - int touchX = (int) Math.min(centerX, d.x); - int touchY = d.y; - - // Go through the pages and check if the dragged item is inside one of them + IntSet pageIndexesToVerify = IntSet.wrap(nextPage - 1, nextPage + + (isTwoPanelEnabled() ? 2 : 1)); for (int pageIndex : pageIndexesToVerify) { if (layout != null || isPageInTransition()) { break; } + + // When deciding whether to perform a page switch, we need to consider the most extreme + // X coordinate between the finger location and the center of the object being dragged. + // This is either the max or the min of the two depending on whether dragging to the + // left / right, respectively. + touchX = ((((pageIndex < nextPage) && !mIsRtl) || pageIndex > nextPage && mIsRtl) + ? Math.min(d.x, centerX) : Math.max(d.x, centerX)); layout = verifyInsidePage(pageIndex, touchX, touchY); } @@ -2507,12 +2513,16 @@ public class Workspace extends PagedView // on one panel just choose the current page. if (layout == null && nextPage >= 0 && nextPage < getPageCount()) { if (isTwoPanelEnabled()) { + // When determining which panel to use within a single screen, we always use + // the centroid of the object rather than the finger. + touchX = centerX; nextPage = getScreenCenter(getScrollX()) > touchX ? (mIsRtl ? nextPage + 1 : nextPage) // left side : (mIsRtl ? nextPage : nextPage + 1); // right side } layout = (CellLayout) getChildAt(nextPage); } + if (layout != mDragTargetLayout) { setCurrentDropLayout(layout); setCurrentDragOverlappingLayout(layout); diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java index 8b2184d8fe..b9054fe985 100644 --- a/src/com/android/launcher3/config/FeatureFlags.java +++ b/src/com/android/launcher3/config/FeatureFlags.java @@ -52,7 +52,7 @@ public final class FeatureFlags { * Enable moving the QSB on the 0th screen of the workspace. This is not a configuration feature * and should be modified at a project level. */ - public static final boolean QSB_ON_FIRST_SCREEN = true; + public static final boolean QSB_ON_FIRST_SCREEN = BuildConfig.QSB_ON_FIRST_SCREEN; /** * Feature flag to handle define config changes dynamically instead of killing the process. diff --git a/src/com/android/launcher3/model/BaseLoaderResults.java b/src/com/android/launcher3/model/BaseLoaderResults.java index 5b278ab4cf..db417a7e5e 100644 --- a/src/com/android/launcher3/model/BaseLoaderResults.java +++ b/src/com/android/launcher3/model/BaseLoaderResults.java @@ -32,7 +32,6 @@ import com.android.launcher3.model.BgDataModel.FixedContainerItems; import com.android.launcher3.model.data.AppInfo; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.LauncherAppWidgetInfo; -import com.android.launcher3.testing.TestProtocol; import com.android.launcher3.util.IntArray; import com.android.launcher3.util.IntSet; import com.android.launcher3.util.LooperExecutor; @@ -174,20 +173,8 @@ public abstract class BaseLoaderResults { ArrayList currentAppWidgets = new ArrayList<>(); ArrayList otherAppWidgets = new ArrayList<>(); - if (TestProtocol.sDebugTracing) { - Log.d(TestProtocol.NULL_INT_SET, "bind (1) currentScreenIds: " - + currentScreenIds - + ", pointer: " - + mCallbacks - + ", name: " - + mCallbacks.getClass().getName()); - } filterCurrentWorkspaceItems(currentScreenIds, mWorkspaceItems, currentWorkspaceItems, otherWorkspaceItems); - if (TestProtocol.sDebugTracing) { - Log.d(TestProtocol.NULL_INT_SET, "bind (2) currentScreenIds: " - + currentScreenIds); - } filterCurrentWorkspaceItems(currentScreenIds, mAppWidgets, currentAppWidgets, otherAppWidgets); final InvariantDeviceProfile idp = mApp.getInvariantDeviceProfile(); diff --git a/src/com/android/launcher3/model/ModelUtils.java b/src/com/android/launcher3/model/ModelUtils.java index ef5eef1e43..58aa9e591f 100644 --- a/src/com/android/launcher3/model/ModelUtils.java +++ b/src/com/android/launcher3/model/ModelUtils.java @@ -31,7 +31,6 @@ import com.android.launcher3.icons.BitmapInfo; import com.android.launcher3.icons.LauncherIcons; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.WorkspaceItemInfo; -import com.android.launcher3.testing.TestProtocol; import com.android.launcher3.util.IntArray; import com.android.launcher3.util.IntSet; @@ -67,10 +66,6 @@ public class ModelUtils { (lhs, rhs) -> Integer.compare(lhs.container, rhs.container)); for (T info : allWorkspaceItems) { if (info.container == LauncherSettings.Favorites.CONTAINER_DESKTOP) { - if (TestProtocol.sDebugTracing) { - Log.d(TestProtocol.NULL_INT_SET, "filterCurrentWorkspaceItems: " - + currentScreenIds); - } if (currentScreenIds.contains(info.screenId)) { currentScreenItems.add(info); itemsOnScreen.add(info.id); diff --git a/src/com/android/launcher3/testing/TestProtocol.java b/src/com/android/launcher3/testing/TestProtocol.java index fc18ada958..11a585fffb 100644 --- a/src/com/android/launcher3/testing/TestProtocol.java +++ b/src/com/android/launcher3/testing/TestProtocol.java @@ -127,7 +127,6 @@ public final class TestProtocol { public static final String PERMANENT_DIAG_TAG = "TaplTarget"; public static final String TASK_VIEW_ID_CRASH = "b/195430732"; public static final String NO_DROP_TARGET = "b/195031154"; - public static final String NULL_INT_SET = "b/200572078"; public static final String MISSING_PROMISE_ICON = "b/202985412"; public static final String LAUNCHER_NOT_INITIALIZED = "b/215233405"; } diff --git a/src_build_config/com/android/launcher3/BuildConfig.java b/src_build_config/com/android/launcher3/BuildConfig.java index 49aadf61ff..9a81d3f54c 100644 --- a/src_build_config/com/android/launcher3/BuildConfig.java +++ b/src_build_config/com/android/launcher3/BuildConfig.java @@ -17,6 +17,11 @@ package com.android.launcher3; public final class BuildConfig { - public static final String APPLICATION_ID = "com.android.launcher3"; - public static final boolean DEBUG = false; + public static final String APPLICATION_ID = "com.android.launcher3"; + public static final boolean DEBUG = false; + /** + * Flag to state if the QSB is on the first screen and placed on the top, + * this can be overwritten in other launchers with a different value, if needed. + */ + public static final boolean QSB_ON_FIRST_SCREEN = true; } diff --git a/tests/AndroidManifest-common.xml b/tests/AndroidManifest-common.xml index e44c172081..b4cd773435 100644 --- a/tests/AndroidManifest-common.xml +++ b/tests/AndroidManifest-common.xml @@ -267,6 +267,15 @@ + + + + + + + + + + + + + + + + + + diff --git a/tests/src/com/android/launcher3/ui/workspace/ThemeIconsTest.java b/tests/src/com/android/launcher3/ui/workspace/ThemeIconsTest.java new file mode 100644 index 0000000000..e66810cc3d --- /dev/null +++ b/tests/src/com/android/launcher3/ui/workspace/ThemeIconsTest.java @@ -0,0 +1,128 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.launcher3.ui.workspace; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import android.content.ContentProviderClient; +import android.content.ContentResolver; +import android.content.ContentValues; +import android.net.Uri; +import android.view.View; +import android.view.ViewGroup; + +import androidx.test.filters.LargeTest; + +import com.android.launcher3.BubbleTextView; +import com.android.launcher3.icons.ThemedIconDrawable; +import com.android.launcher3.tapl.HomeAllApps; +import com.android.launcher3.tapl.HomeAppIcon; +import com.android.launcher3.ui.AbstractLauncherUiTest; +import com.android.launcher3.ui.TaplTestsLauncher3; + +import org.junit.Test; + +import java.util.ArrayDeque; +import java.util.Queue; + +/** + * Tests for theme icon support in Launcher + * + * Note running these tests will clear the workspace on the device. + */ +@LargeTest +public class ThemeIconsTest extends AbstractLauncherUiTest { + + private static final String APP_NAME = "ThemeIconTestActivity"; + + @Test + public void testIconWithoutTheme() throws Exception { + setThemeEnabled(false); + TaplTestsLauncher3.initialize(this); + + HomeAllApps allApps = mLauncher.getWorkspace().switchToAllApps(); + allApps.freeze(); + + try { + HomeAppIcon icon = allApps.getAppIcon(APP_NAME); + executeOnLauncher(l -> verifyIconTheme(l.getAppsView(), false)); + icon.dragToWorkspace(false, false); + executeOnLauncher(l -> verifyIconTheme(l.getWorkspace(), false)); + } finally { + allApps.unfreeze(); + } + } + + @Test + public void testIconWithTheme() throws Exception { + setThemeEnabled(true); + TaplTestsLauncher3.initialize(this); + + HomeAllApps allApps = mLauncher.getWorkspace().switchToAllApps(); + allApps.freeze(); + + try { + HomeAppIcon icon = allApps.getAppIcon(APP_NAME); + executeOnLauncher(l -> verifyIconTheme(l.getAppsView(), false)); + icon.dragToWorkspace(false, false); + executeOnLauncher(l -> verifyIconTheme(l.getWorkspace(), true)); + } finally { + allApps.unfreeze(); + } + } + + private void verifyIconTheme(ViewGroup parent, boolean isThemed) { + // Find the app icon + Queue viewQueue = new ArrayDeque<>(); + viewQueue.add(parent); + BubbleTextView icon = null; + while (!viewQueue.isEmpty()) { + View view = viewQueue.poll(); + if (view instanceof ViewGroup) { + parent = (ViewGroup) view; + for (int i = parent.getChildCount() - 1; i >= 0; i--) { + viewQueue.add(parent.getChildAt(i)); + } + } else if (view instanceof BubbleTextView) { + BubbleTextView btv = (BubbleTextView) view; + if (APP_NAME.equals(btv.getText())) { + icon = btv; + break; + } + } + } + + assertNotNull(icon.getIcon()); + assertEquals(isThemed, icon.getIcon() instanceof ThemedIconDrawable); + } + + private void setThemeEnabled(boolean isEnabled) throws Exception { + Uri uri = new Uri.Builder() + .scheme(ContentResolver.SCHEME_CONTENT) + .authority(mTargetPackage + ".grid_control") + .appendPath("set_icon_themed") + .build(); + ContentValues values = new ContentValues(); + values.put("boolean_value", isEnabled); + try (ContentProviderClient client = mTargetContext.getContentResolver() + .acquireContentProviderClient(uri)) { + int result = client.update(uri, values, null); + assertTrue(result > 0); + } + } +}