Merge "App Shortcut menu bug fixes and polish." into sc-dev am: c846245f1b
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/14985072 Change-Id: Icba377c0032eee2dacec8a3c4364fa5b958880b7
This commit is contained in:
commit
47f8a1c3ef
|
@ -415,8 +415,8 @@ public abstract class BaseQuickstepLauncher extends Launcher
|
|||
|
||||
@Override
|
||||
public Stream<SystemShortcut.Factory> getSupportedShortcuts() {
|
||||
return Stream.concat(super.getSupportedShortcuts(),
|
||||
Stream.of(WellbeingModel.SHORTCUT_FACTORY));
|
||||
return Stream.concat(Stream.of(WellbeingModel.SHORTCUT_FACTORY),
|
||||
super.getSupportedShortcuts());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -192,7 +192,7 @@ public class QuickstepLauncher extends BaseQuickstepLauncher {
|
|||
@Override
|
||||
public Stream<SystemShortcut.Factory> getSupportedShortcuts() {
|
||||
return Stream.concat(
|
||||
super.getSupportedShortcuts(), Stream.of(mHotseatPredictionController));
|
||||
Stream.of(mHotseatPredictionController), super.getSupportedShortcuts());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
android:height="@dimen/deep_shortcut_drag_handle_size"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0"
|
||||
android:tint="?android:attr/textColorHint" >
|
||||
android:tint="?android:attr/textColorPrimary" >
|
||||
|
||||
<path
|
||||
android:pathData="M20,9H4v2h16V9z M4,15h16v-2H4V15z"
|
||||
|
|
|
@ -45,6 +45,6 @@
|
|||
android:layout_height="@dimen/system_shortcut_icon_size"
|
||||
android:layout_marginStart="@dimen/system_shortcut_margin_start"
|
||||
android:layout_gravity="start|center_vertical"
|
||||
android:backgroundTint="?android:attr/textColorTertiary"/>
|
||||
android:backgroundTint="?android:attr/textColorPrimary"/>
|
||||
|
||||
</com.android.launcher3.shortcuts.DeepShortcutView>
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2017 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.
|
||||
-->
|
||||
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/system_shortcut_full"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/system_shortcut_header_height"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="end|center_vertical"
|
||||
android:elevation="@dimen/deep_shortcuts_elevation"
|
||||
android:tag="@string/popup_container_iterate_children"
|
||||
android:clipToPadding="true">
|
||||
</LinearLayout>
|
|
@ -96,6 +96,8 @@ public class PopupContainerWithArrow<T extends StatefulActivity<LauncherState>>
|
|||
private int mNumNotifications;
|
||||
private ViewGroup mNotificationContainer;
|
||||
|
||||
private ViewGroup mWidgetContainer;
|
||||
|
||||
private ViewGroup mDeepShortcutContainer;
|
||||
|
||||
private ViewGroup mSystemShortcutContainer;
|
||||
|
@ -234,7 +236,7 @@ public class PopupContainerWithArrow<T extends StatefulActivity<LauncherState>>
|
|||
|
||||
@Override
|
||||
protected List<View> getChildrenForColorExtraction() {
|
||||
return Arrays.asList(mSystemShortcutContainer, mDeepShortcutContainer,
|
||||
return Arrays.asList(mSystemShortcutContainer, mWidgetContainer, mDeepShortcutContainer,
|
||||
mNotificationContainer);
|
||||
}
|
||||
|
||||
|
@ -298,10 +300,24 @@ public class PopupContainerWithArrow<T extends StatefulActivity<LauncherState>>
|
|||
updateHiddenShortcuts();
|
||||
|
||||
if (!systemShortcuts.isEmpty()) {
|
||||
mSystemShortcutContainer = inflateAndAdd(R.layout.system_shortcut_icons, this);
|
||||
for (SystemShortcut shortcut : systemShortcuts) {
|
||||
initializeSystemShortcut(
|
||||
R.layout.system_shortcut_icon_only, mSystemShortcutContainer, shortcut);
|
||||
if (shortcut instanceof SystemShortcut.Widgets) {
|
||||
if (mWidgetContainer == null) {
|
||||
mWidgetContainer = inflateAndAdd(R.layout.widget_shortcut_container,
|
||||
this);
|
||||
}
|
||||
initializeSystemShortcut(R.layout.system_shortcut, mWidgetContainer,
|
||||
shortcut);
|
||||
}
|
||||
}
|
||||
mSystemShortcutContainer = inflateAndAdd(R.layout.system_shortcut_icons, this);
|
||||
|
||||
for (SystemShortcut shortcut : systemShortcuts) {
|
||||
if (!(shortcut instanceof SystemShortcut.Widgets)) {
|
||||
initializeSystemShortcut(
|
||||
R.layout.system_shortcut_icon_only, mSystemShortcutContainer,
|
||||
shortcut);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -524,25 +540,34 @@ public class PopupContainerWithArrow<T extends StatefulActivity<LauncherState>>
|
|||
mLauncher.getPopupDataProvider().setChangeListener(null);
|
||||
}
|
||||
|
||||
private View getWidgetsView(ViewGroup container) {
|
||||
for (int i = container.getChildCount() - 1; i >= 0; --i) {
|
||||
View systemShortcutView = container.getChildAt(i);
|
||||
if (systemShortcutView.getTag() instanceof SystemShortcut.Widgets) {
|
||||
return systemShortcutView;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWidgetsBound() {
|
||||
ItemInfo itemInfo = (ItemInfo) mOriginalIcon.getTag();
|
||||
SystemShortcut widgetInfo = SystemShortcut.WIDGETS.getShortcut(mLauncher, itemInfo);
|
||||
View widgetsView = null;
|
||||
int count = mSystemShortcutContainer.getChildCount();
|
||||
for (int i = 0; i < count; i++) {
|
||||
View systemShortcutView = mSystemShortcutContainer.getChildAt(i);
|
||||
if (systemShortcutView.getTag() instanceof SystemShortcut.Widgets) {
|
||||
widgetsView = systemShortcutView;
|
||||
break;
|
||||
}
|
||||
View widgetsView = getWidgetsView(PopupContainerWithArrow.this);
|
||||
if (widgetsView == null && mWidgetContainer != null) {
|
||||
widgetsView = getWidgetsView(mWidgetContainer);
|
||||
}
|
||||
|
||||
if (widgetInfo != null && widgetsView == null) {
|
||||
// We didn't have any widgets cached but now there are some, so enable the shortcut.
|
||||
if (mSystemShortcutContainer != PopupContainerWithArrow.this) {
|
||||
initializeSystemShortcut(R.layout.system_shortcut_icon_only,
|
||||
mSystemShortcutContainer, widgetInfo);
|
||||
if (mWidgetContainer == null) {
|
||||
mWidgetContainer = inflateAndAdd(R.layout.widget_shortcut_container,
|
||||
PopupContainerWithArrow.this);
|
||||
}
|
||||
initializeSystemShortcut(R.layout.system_shortcut, mWidgetContainer,
|
||||
widgetInfo);
|
||||
} else {
|
||||
// If using the expanded system shortcut (as opposed to just the icon), we need
|
||||
// to reopen the container to ensure measurements etc. all work out. While this
|
||||
|
@ -554,8 +579,10 @@ public class PopupContainerWithArrow<T extends StatefulActivity<LauncherState>>
|
|||
}
|
||||
} else if (widgetInfo == null && widgetsView != null) {
|
||||
// No widgets exist, but we previously added the shortcut so remove it.
|
||||
if (mSystemShortcutContainer != PopupContainerWithArrow.this) {
|
||||
mSystemShortcutContainer.removeView(widgetsView);
|
||||
if (mSystemShortcutContainer
|
||||
!= PopupContainerWithArrow.this
|
||||
&& mWidgetContainer != null) {
|
||||
mWidgetContainer.removeView(widgetsView);
|
||||
} else {
|
||||
close(false);
|
||||
PopupContainerWithArrow.showForIcon(mOriginalIcon);
|
||||
|
|
|
@ -293,7 +293,7 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest {
|
|||
try {
|
||||
final AppIconMenu menu = allApps.
|
||||
getAppIcon(APP_NAME).
|
||||
openMenu();
|
||||
openDeepShortcutMenu();
|
||||
|
||||
executeOnLauncher(
|
||||
launcher -> assertTrue("Launcher internal state didn't switch to Showing Menu",
|
||||
|
@ -341,7 +341,7 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest {
|
|||
try {
|
||||
final AppIconMenu menu = allApps
|
||||
.getAppIcon(APP_NAME)
|
||||
.openMenu();
|
||||
.openDeepShortcutMenu();
|
||||
final AppIconMenuItem menuItem0 = menu.getMenuItem(0);
|
||||
final AppIconMenuItem menuItem2 = menu.getMenuItem(2);
|
||||
|
||||
|
|
|
@ -51,6 +51,16 @@ public final class AppIcon extends Launchable {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Long-clicks the icon to open its menu, and looks at the deep shortcuts container only.
|
||||
*/
|
||||
public AppIconMenu openDeepShortcutMenu() {
|
||||
try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) {
|
||||
return new AppIconMenu(mLauncher, mLauncher.clickAndGet(
|
||||
mObject, "deep_shortcuts_container", LONG_CLICK_EVENT));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addExpectedEventsForLongClick() {
|
||||
mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, LONG_CLICK_EVENT);
|
||||
|
|
Loading…
Reference in New Issue