Merge "Add the KeyboardQuickSwitchView (1/2)" into tm-qpr-dev
diff --git a/OWNERS b/OWNERS
index 560b562..962d63a 100644
--- a/OWNERS
+++ b/OWNERS
@@ -4,31 +4,36 @@
# People who can approve changes for submission
#
-alexchau@google.com
-andraskloczl@google.com
-patmanning@google.com
adamcohen@google.com
-hyunyoungs@google.com
-mrcasey@google.com
-sunnygoyal@google.com
+alexchau@google.com
+andonian@google.com
awickham@google.com
-twickham@google.com
-winsonc@google.com
-zakcohen@google.com
-santie@google.com
-vadimt@google.com
-jonmiranda@google.com
-pinyaoting@google.com
-gwasserman@google.com
-jamesoleary@google.com
-joshtrask@google.com
-mrenouf@google.com
-mkephart@google.com
-hwwang@google.com
-tracyzhou@google.com
-peanutbutter@google.com
-xuqiu@google.com
+brdayauon@google.com
brianji@google.com
+captaincole@google.com
+charlander@google.com
+fbaron@google.com
+ganjam@google.com
+hwwang@google.com
+hyunyoungs@google.com
+jagrutdesai@google.com
+jeremysim@google.com
+jiuyu@google.com
+jonmiranda@google.com
+kylim@google.com
+patmanning@google.com
+peanutbutter@google.com
+pinyaoting@google.com
+randypfohl@google.com
+saumyaprakash@google.com
+sihua@google.com
+sunnygoyal@google.com
+tracyzhou@google.com
+twickham@google.com
+vadimt@google.com
+victortulias@google.com
+winsonc@google.com
+xuqiu@google.com
per-file FeatureFlags.java, globs = set noparent
-per-file FeatureFlags.java = sunnygoyal@google.com, winsonc@google.com, zakcohen@google.com, mrcasey@google.com, adamcohen@google.com, hyunyoungs@google.com
+per-file FeatureFlags.java = sunnygoyal@google.com, winsonc@google.com, adamcohen@google.com, hyunyoungs@google.com
diff --git a/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java b/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java
index 74e7375..0f25ba1 100644
--- a/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java
@@ -15,6 +15,8 @@
*/
package com.android.launcher3.taskbar;
+import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NAV_BAR_HIDDEN;
+
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
@@ -36,6 +38,7 @@
import com.android.launcher3.util.MultiPropertyFactory;
import com.android.launcher3.util.MultiValueAlpha;
import com.android.systemui.shared.navigationbar.RegionSamplingHelper;
+import com.android.systemui.shared.system.QuickStepContract;
import java.io.PrintWriter;
@@ -78,6 +81,10 @@
private float mStartProgressForNextRevealAnim;
private boolean mWasLastRevealAnimReversed;
+ // States that affect whether region sampling is enabled or not
+ private boolean mIsStashed;
+ private boolean mTaskbarHidden;
+
public StashedHandleViewController(TaskbarActivityContext activity,
StashedHandleView stashedHandleView) {
mActivity = activity;
@@ -218,7 +225,8 @@
/** Called when taskbar is stashed or unstashed. */
public void onIsStashedChanged(boolean isStashed) {
- mRegionSamplingHelper.setWindowVisible(isStashed);
+ mIsStashed = isStashed;
+ updateRegionSamplingWindowVisibility();
if (isStashed) {
mStashedHandleView.updateSampledRegion(mStashedHandleBounds);
mRegionSamplingHelper.start(mStashedHandleView.getSampledRegion());
@@ -247,6 +255,15 @@
homeDisabled ? 0 : 1);
}
+ public void updateStateForSysuiFlags(int systemUiStateFlags) {
+ mTaskbarHidden = (systemUiStateFlags & SYSUI_STATE_NAV_BAR_HIDDEN) != 0;
+ updateRegionSamplingWindowVisibility();
+ }
+
+ private void updateRegionSamplingWindowVisibility() {
+ mRegionSamplingHelper.setWindowVisible(mIsStashed && !mTaskbarHidden);
+ }
+
public boolean isStashedHandleVisible() {
return mStashedHandleView.getVisibility() == View.VISIBLE;
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
index c6d8fce..c0c14a3 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
@@ -247,6 +247,12 @@
// Initialize controllers after all are constructed.
mControllers.init(sharedState);
updateSysuiStateFlags(sharedState.sysuiStateFlags, true /* fromInit */);
+ disableNavBarElements(sharedState.disableNavBarDisplayId, sharedState.disableNavBarState1,
+ sharedState.disableNavBarState2, false /* animate */);
+ onSystemBarAttributesChanged(sharedState.systemBarAttrsDisplayId,
+ sharedState.systemBarAttrsBehavior);
+ onNavButtonsDarkIntensityChanged(sharedState.navButtonsDarkIntensity);
+
if (!mAddedWindow) {
mWindowManager.addView(mDragLayer, mWindowLayoutParams);
@@ -564,6 +570,7 @@
|| isNavBarKidsModeActive());
mControllers.stashedHandleViewController.setIsHomeButtonDisabled(
mControllers.navbarButtonsViewController.isHomeDisabled());
+ mControllers.stashedHandleViewController.updateStateForSysuiFlags(systemUiStateFlags);
mControllers.taskbarKeyguardController.updateStateForSysuiFlags(systemUiStateFlags);
mControllers.taskbarStashController.updateStateForSysuiFlags(
systemUiStateFlags, fromInit || !isUserSetupComplete());
@@ -1061,6 +1068,12 @@
mWindowManager.updateViewLayout(mDragLayer, mWindowLayoutParams);
}
+ void notifyUpdateLayoutParams() {
+ if (mDragLayer.isAttachedToWindow()) {
+ mWindowManager.updateViewLayout(mDragLayer, mWindowLayoutParams);
+ }
+ }
+
public void showPopupMenuForIcon(BubbleTextView btv) {
setTaskbarWindowFullscreen(true);
btv.post(() -> mControllers.taskbarPopupController.showForIcon(btv));
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt
index 9f24565..571d443 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt
@@ -18,16 +18,21 @@
import android.graphics.Insets
import android.graphics.Region
import android.view.InsetsFrameProvider
+import android.view.InsetsFrameProvider.SOURCE_DISPLAY
+import android.view.InsetsFrameProvider.SOURCE_FRAME
import android.view.InsetsState
import android.view.InsetsState.ITYPE_BOTTOM_MANDATORY_GESTURES
import android.view.InsetsState.ITYPE_BOTTOM_TAPPABLE_ELEMENT
import android.view.InsetsState.ITYPE_EXTRA_NAVIGATION_BAR
+import android.view.InsetsState.ITYPE_LEFT_GESTURES
+import android.view.InsetsState.ITYPE_RIGHT_GESTURES
import android.view.ViewTreeObserver
import android.view.ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME
import android.view.ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION
import android.view.WindowManager
import android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD
import android.view.WindowManager.LayoutParams.TYPE_VOICE_INTERACTION
+import com.android.internal.policy.GestureNavigationSettingsObserver
import com.android.launcher3.AbstractFloatingView
import com.android.launcher3.AbstractFloatingView.TYPE_TASKBAR_OVERLAY_PROXY
import com.android.launcher3.DeviceProfile
@@ -45,6 +50,9 @@
private val deviceProfileChangeListener = { _: DeviceProfile ->
onTaskbarWindowHeightOrInsetsChanged()
}
+ private val gestureNavSettingsObserver =
+ GestureNavigationSettingsObserver(context.mainThreadHandler, context,
+ this::onTaskbarWindowHeightOrInsetsChanged)
// Initialized in init.
private lateinit var controllers: TaskbarControllers
@@ -59,7 +67,16 @@
intArrayOf(
ITYPE_EXTRA_NAVIGATION_BAR,
ITYPE_BOTTOM_TAPPABLE_ELEMENT,
- ITYPE_BOTTOM_MANDATORY_GESTURES
+ ITYPE_BOTTOM_MANDATORY_GESTURES,
+ ITYPE_LEFT_GESTURES,
+ ITYPE_RIGHT_GESTURES,
+ ),
+ intArrayOf(
+ SOURCE_FRAME,
+ SOURCE_FRAME,
+ SOURCE_FRAME,
+ SOURCE_DISPLAY,
+ SOURCE_DISPLAY
)
)
@@ -67,10 +84,12 @@
windowLayoutParams.insetsRoundedCornerFrame = true
context.addOnDeviceProfileChangeListener(deviceProfileChangeListener)
+ gestureNavSettingsObserver.registerForCurrentUser()
}
fun onDestroy() {
context.removeOnDeviceProfileChangeListener(deviceProfileChangeListener)
+ gestureNavSettingsObserver.unregister()
}
fun onTaskbarWindowHeightOrInsetsChanged() {
@@ -91,6 +110,22 @@
provider.insetsSize = getInsetsByNavMode(contentHeight)
} else if (provider.type == ITYPE_BOTTOM_TAPPABLE_ELEMENT) {
provider.insetsSize = getInsetsByNavMode(tappableHeight)
+ } else if (provider.type == ITYPE_LEFT_GESTURES) {
+ provider.insetsSize =
+ Insets.of(
+ gestureNavSettingsObserver.getLeftSensitivity(context.resources),
+ 0,
+ 0,
+ 0
+ )
+ } else if (provider.type == ITYPE_RIGHT_GESTURES) {
+ provider.insetsSize =
+ Insets.of(
+ 0,
+ 0,
+ gestureNavSettingsObserver.getRightSensitivity(context.resources),
+ 0
+ )
}
}
@@ -116,6 +151,7 @@
provider.insetsSizeOverrides = insetsSizeOverride
}
}
+ context.notifyUpdateLayoutParams()
}
/**
@@ -140,10 +176,12 @@
* @param params The window layout params.
* @param providesInsetsTypes The inset types we would like this layout params to provide.
*/
- fun setProvidesInsetsTypes(params: WindowManager.LayoutParams, providesInsetsTypes: IntArray) {
+ fun setProvidesInsetsTypes(params: WindowManager.LayoutParams, providesInsetsTypes: IntArray,
+ providesInsetsSources: IntArray) {
params.providedInsets = arrayOfNulls<InsetsFrameProvider>(providesInsetsTypes.size)
for (i in providesInsetsTypes.indices) {
- params.providedInsets[i] = InsetsFrameProvider(providesInsetsTypes[i])
+ params.providedInsets[i] = InsetsFrameProvider(providesInsetsTypes[i],
+ providesInsetsSources[i], null, null)
}
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
index a58906f..4110822 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
@@ -362,18 +362,24 @@
}
public void disableNavBarElements(int displayId, int state1, int state2, boolean animate) {
+ mSharedState.disableNavBarDisplayId = displayId;
+ mSharedState.disableNavBarState1 = state1;
+ mSharedState.disableNavBarState2 = state2;
if (mTaskbarActivityContext != null) {
mTaskbarActivityContext.disableNavBarElements(displayId, state1, state2, animate);
}
}
public void onSystemBarAttributesChanged(int displayId, int behavior) {
+ mSharedState.systemBarAttrsDisplayId = displayId;
+ mSharedState.systemBarAttrsBehavior = behavior;
if (mTaskbarActivityContext != null) {
mTaskbarActivityContext.onSystemBarAttributesChanged(displayId, behavior);
}
}
public void onNavButtonsDarkIntensityChanged(float darkIntensity) {
+ mSharedState.navButtonsDarkIntensity = darkIntensity;
if (mTaskbarActivityContext != null) {
mTaskbarActivityContext.onNavButtonsDarkIntensityChanged(darkIntensity);
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarSharedState.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarSharedState.java
index 87b3789..026eff7 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarSharedState.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarSharedState.java
@@ -20,8 +20,21 @@
*/
public class TaskbarSharedState {
+ // TaskbarManager#onSystemUiFlagsChanged
public int sysuiStateFlags;
+ // TaskbarManager#disableNavBarElements()
+ public int disableNavBarDisplayId;
+ public int disableNavBarState1;
+ public int disableNavBarState2;
+
+ // TaskbarManager#onSystemBarAttributesChanged()
+ public int systemBarAttrsDisplayId;
+ public int systemBarAttrsBehavior;
+
+ // TaskbarManager#onNavButtonsDarkIntensityChanged()
+ public float navButtonsDarkIntensity;
+
public boolean setupUIVisible = false;
public boolean allAppsVisible = false;
diff --git a/res/drawable/bg_widgets_content.xml b/res/drawable/bg_widgets_content.xml
new file mode 100644
index 0000000..8060430
--- /dev/null
+++ b/res/drawable/bg_widgets_content.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2023 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.
+-->
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <!--
+ L -> large radius
+ s -> small radius
+ 0 -> no radiuls
+ -->
+
+ <!-- MIDDLE : 0 0 s s -->
+ <item android:state_middle="true">
+ <shape android:shape="rectangle">
+ <solid android:color="@color/surface" />
+ <corners
+ android:topLeftRadius="0dp"
+ android:topRightRadius="0dp"
+ android:bottomLeftRadius="@dimen/widget_list_content_corner_radius"
+ android:bottomRightRadius="@dimen/widget_list_content_corner_radius" />
+ </shape>
+ </item>
+
+ <!-- LAST : 0 0 L L -->
+ <item android:state_last="true">
+ <shape android:shape="rectangle">
+ <solid android:color="@color/surface" />
+ <corners
+ android:topLeftRadius="0dp"
+ android:topRightRadius="0dp"
+ android:bottomLeftRadius="@dimen/widget_list_top_bottom_corner_radius"
+ android:bottomRightRadius="@dimen/widget_list_top_bottom_corner_radius" />
+ </shape>
+ </item>
+</selector>
diff --git a/res/drawable/bg_widgets_header.xml b/res/drawable/bg_widgets_header.xml
new file mode 100644
index 0000000..a89aad4
--- /dev/null
+++ b/res/drawable/bg_widgets_header.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2023 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.
+-->
+<inset xmlns:android="http://schemas.android.com/apk/res/android"
+ android:insetTop="@dimen/widget_list_entry_spacing" >
+ <ripple
+ android:color="?android:attr/colorControlHighlight"
+ android:paddingTop="@dimen/widget_list_header_view_vertical_padding"
+ android:paddingBottom="@dimen/widget_list_header_view_vertical_padding" >
+ <item android:id="@android:id/mask"
+ android:drawable="@drawable/bg_widgets_header_states" />
+ <item android:drawable="@drawable/bg_widgets_header_states" />
+ </ripple>
+</inset>
\ No newline at end of file
diff --git a/res/drawable/bg_widgets_header_states.xml b/res/drawable/bg_widgets_header_states.xml
new file mode 100644
index 0000000..f45a7ab
--- /dev/null
+++ b/res/drawable/bg_widgets_header_states.xml
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2023 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.
+-->
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <!--
+ L -> large radius
+ s -> small radius
+ 0 -> no radiuls
+ -->
+
+ <!-- SINGLE : L L L L -->
+ <item android:state_single="true">
+ <shape android:shape="rectangle">
+ <solid android:color="@color/surface" />
+ <corners
+ android:topLeftRadius="@dimen/widget_list_top_bottom_corner_radius"
+ android:topRightRadius="@dimen/widget_list_top_bottom_corner_radius"
+ android:bottomLeftRadius="@dimen/widget_list_top_bottom_corner_radius"
+ android:bottomRightRadius="@dimen/widget_list_top_bottom_corner_radius" />
+ </shape>
+ </item>
+
+ <!-- FIRST_EXPANDED : L L 0 0 -->
+ <item android:state_first="true" android:state_expanded="true">
+ <shape android:shape="rectangle">
+ <solid android:color="@color/surface" />
+ <corners
+ android:topLeftRadius="@dimen/widget_list_top_bottom_corner_radius"
+ android:topRightRadius="@dimen/widget_list_top_bottom_corner_radius"
+ android:bottomLeftRadius="0dp"
+ android:bottomRightRadius="0dp" />
+ </shape>
+ </item>
+
+ <!-- FIRST : L L s s -->
+ <item android:state_first="true" >
+ <shape android:shape="rectangle">
+ <solid android:color="@color/surface" />
+ <corners
+ android:topLeftRadius="@dimen/widget_list_top_bottom_corner_radius"
+ android:topRightRadius="@dimen/widget_list_top_bottom_corner_radius"
+ android:bottomLeftRadius="@dimen/widget_list_content_corner_radius"
+ android:bottomRightRadius="@dimen/widget_list_content_corner_radius" />
+ </shape>
+ </item>
+
+ <!-- MIDDLE_EXPANDED : s s 0 0 -->
+ <item android:state_middle="true" android:state_expanded="true">
+ <shape android:shape="rectangle">
+ <solid android:color="@color/surface" />
+ <corners
+ android:topLeftRadius="@dimen/widget_list_content_corner_radius"
+ android:topRightRadius="@dimen/widget_list_content_corner_radius"
+ android:bottomLeftRadius="0dp"
+ android:bottomRightRadius="0dp" />
+ </shape>
+ </item>
+
+ <!-- MIDDLE : s s s s -->
+ <item android:state_middle="true">
+ <shape android:shape="rectangle">
+ <solid android:color="@color/surface" />
+ <corners
+ android:topLeftRadius="@dimen/widget_list_content_corner_radius"
+ android:topRightRadius="@dimen/widget_list_content_corner_radius"
+ android:bottomLeftRadius="@dimen/widget_list_content_corner_radius"
+ android:bottomRightRadius="@dimen/widget_list_content_corner_radius" />
+ </shape>
+ </item>
+
+ <!-- LAST : s s L L -->
+ <item android:state_last="true">
+ <shape android:shape="rectangle">
+ <solid android:color="@color/surface" />
+ <corners
+ android:topLeftRadius="@dimen/widget_list_content_corner_radius"
+ android:topRightRadius="@dimen/widget_list_content_corner_radius"
+ android:bottomLeftRadius="@dimen/widget_list_top_bottom_corner_radius"
+ android:bottomRightRadius="@dimen/widget_list_top_bottom_corner_radius" />
+ </shape>
+ </item>
+</selector>
diff --git a/res/drawable/widgets_tray_expand_button.xml b/res/drawable/widgets_tray_expand_button.xml
index 8316e0f..f2e142e 100644
--- a/res/drawable/widgets_tray_expand_button.xml
+++ b/res/drawable/widgets_tray_expand_button.xml
@@ -14,8 +14,8 @@
limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_checked="true"
+ <item android:state_expanded="true"
android:drawable="@drawable/ic_expand_less" />
- <item android:state_checked="false"
+ <item android:state_expanded="false"
android:drawable="@drawable/ic_expand_more" />
</selector>
diff --git a/res/layout/widgets_list_row_header.xml b/res/layout/widgets_list_row_header.xml
index 35bea27..6d26ce3 100644
--- a/res/layout/widgets_list_row_header.xml
+++ b/res/layout/widgets_list_row_header.xml
@@ -23,7 +23,8 @@
android:importantForAccessibility="yes"
android:focusable="true"
launcher:appIconSize="48dp"
- android:descendantFocusability="afterDescendants">
+ android:descendantFocusability="afterDescendants"
+ android:background="@drawable/bg_widgets_header" >
<ImageView
android:id="@+id/app_icon"
@@ -65,8 +66,11 @@
<!-- This checkbox is not clickable. The outermost LinearLayout is responsible to handle all
click event and update the checkbox state. -->
- <CheckBox
+ <ImageView
+ android:duplicateParentState="true"
android:id="@+id/toggle"
+ android:alpha=".6"
+ android:src="@drawable/widgets_tray_expand_button"
android:layout_marginHorizontal="16dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -74,7 +78,6 @@
android:layout_alignParentEnd="true"
android:enabled="false"
android:clickable="false"
- android:importantForAccessibility="no"
- android:button="@drawable/widgets_tray_expand_button"/>
+ android:importantForAccessibility="no" />
</com.android.launcher3.widget.picker.WidgetsListHeader>
\ No newline at end of file
diff --git a/res/layout/widgets_table_container.xml b/res/layout/widgets_table_container.xml
index ab96b1343..4a32672 100644
--- a/res/layout/widgets_table_container.xml
+++ b/res/layout/widgets_table_container.xml
@@ -16,5 +16,6 @@
<com.android.launcher3.widget.picker.WidgetsListTableView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widgets_table"
+ android:background="@drawable/bg_widgets_content"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java
index e4815c6..7b0033d 100644
--- a/src/com/android/launcher3/config/FeatureFlags.java
+++ b/src/com/android/launcher3/config/FeatureFlags.java
@@ -356,6 +356,9 @@
"SECONDARY_DRAG_N_DROP_TO_PIN", false,
"Enable dragging and dropping to pin apps within secondary display");
+ public static final BooleanFlag ENABLE_ICON_IN_TEXT_HEADER = getDebugFlag(
+ "ENABLE_ICON_IN_TEXT_HEADER", false, "Show icon in textheader");
+
public static final BooleanFlag SHOW_DOT_PAGINATION = getDebugFlag(
"SHOW_DOT_PAGINATION", false, "Enable showing dot pagination in workspace");
diff --git a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
index 7c7cdf4..2ce400e 100644
--- a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
+++ b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
@@ -274,8 +274,6 @@
mSuggestedWidgetsHeader = (WidgetsListHeader) layoutInflater.inflate(
R.layout.widgets_list_row_header, mSuggestedWidgetsContainer, false);
mSuggestedWidgetsHeader.setExpanded(true);
- mSuggestedWidgetsHeader.setBackground(
- new WidgetsListDrawableFactory(getContext()).createHeaderBackgroundDrawable());
PackageItemInfo packageItemInfo = new PackageItemInfo(
/* packageName= */ SUGGESTIONS_PACKAGE_NAME,
@@ -311,9 +309,8 @@
? mContent.findViewById(R.id.title)
: mSearchScrollView.findViewById(R.id.title);
mRightPane = mIsTwoPane ? mContent.findViewById(R.id.right_pane) : null;
- mWidgetsListTableViewHolderBinder = new WidgetsListTableViewHolderBinder(
- layoutInflater, this, this,
- new WidgetsListDrawableFactory(getContext()));
+ mWidgetsListTableViewHolderBinder =
+ new WidgetsListTableViewHolderBinder(layoutInflater, this, this);
onRecommendedWidgetsBound();
onWidgetsBound();
diff --git a/src/com/android/launcher3/widget/picker/WidgetsListAdapter.java b/src/com/android/launcher3/widget/picker/WidgetsListAdapter.java
index 549ac42..b5ff719 100644
--- a/src/com/android/launcher3/widget/picker/WidgetsListAdapter.java
+++ b/src/com/android/launcher3/widget/picker/WidgetsListAdapter.java
@@ -108,19 +108,15 @@
mHeaderChangeListener = headerChangeListener;
mContext = context;
mDiffReporter = new WidgetsDiffReporter(iconCache, this);
- WidgetsListDrawableFactory listDrawableFactory = new WidgetsListDrawableFactory(context);
mViewHolderBinders.put(
VIEW_TYPE_WIDGETS_LIST,
new WidgetsListTableViewHolderBinder(
- layoutInflater, iconClickListener, iconLongClickListener,
- listDrawableFactory));
+ layoutInflater, iconClickListener, iconLongClickListener));
mViewHolderBinders.put(
VIEW_TYPE_WIDGETS_HEADER,
new WidgetsListHeaderViewHolderBinder(
- layoutInflater,
- /* onHeaderClickListener= */ this,
- listDrawableFactory));
+ layoutInflater, /* onHeaderClickListener= */ this));
mViewHolderBinders.put(
VIEW_TYPE_WIDGETS_SPACE,
new WidgetsSpaceViewHolderBinder(emptySpaceHeightProvider));
diff --git a/src/com/android/launcher3/widget/picker/WidgetsListDrawableFactory.java b/src/com/android/launcher3/widget/picker/WidgetsListDrawableFactory.java
deleted file mode 100644
index 984a274..0000000
--- a/src/com/android/launcher3/widget/picker/WidgetsListDrawableFactory.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (C) 2021 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.widget.picker;
-
-import static com.android.launcher3.widget.picker.WidgetsListDrawableState.FIRST;
-import static com.android.launcher3.widget.picker.WidgetsListDrawableState.FIRST_EXPANDED;
-import static com.android.launcher3.widget.picker.WidgetsListDrawableState.LAST;
-import static com.android.launcher3.widget.picker.WidgetsListDrawableState.MIDDLE;
-import static com.android.launcher3.widget.picker.WidgetsListDrawableState.MIDDLE_EXPANDED;
-import static com.android.launcher3.widget.picker.WidgetsListDrawableState.SINGLE;
-
-import android.content.Context;
-import android.content.res.ColorStateList;
-import android.content.res.Resources;
-import android.graphics.drawable.Drawable;
-import android.graphics.drawable.GradientDrawable;
-import android.graphics.drawable.InsetDrawable;
-import android.graphics.drawable.RippleDrawable;
-import android.graphics.drawable.StateListDrawable;
-
-import com.android.launcher3.R;
-import com.android.launcher3.util.Themes;
-
-/** Factory for creating drawables to use as background for list elements. */
-final class WidgetsListDrawableFactory {
-
- private final float mTopBottomCornerRadius;
- private final float mMiddleCornerRadius;
- private final ColorStateList mSurfaceColor;
- private final ColorStateList mRippleColor;
- private final int mVerticalPadding;
- private final int mHeaderMargin;
-
- WidgetsListDrawableFactory(Context context) {
- Resources res = context.getResources();
- mTopBottomCornerRadius = res.getDimension(R.dimen.widget_list_top_bottom_corner_radius);
- mMiddleCornerRadius = res.getDimension(R.dimen.widget_list_content_corner_radius);
- mSurfaceColor = context.getColorStateList(R.color.surface);
- mRippleColor = ColorStateList.valueOf(
- Themes.getAttrColor(context, android.R.attr.colorControlHighlight));
- mVerticalPadding =
- res.getDimensionPixelSize(R.dimen.widget_list_header_view_vertical_padding);
- mHeaderMargin = res.getDimensionPixelSize(R.dimen.widget_list_entry_spacing);
- }
-
- /**
- * Creates a drawable for widget header list items. This drawable supports all positions
- * in {@link WidgetsListDrawableState}.
- */
- Drawable createHeaderBackgroundDrawable() {
- StateListDrawable stateList = new StateListDrawable();
- stateList.addState(
- SINGLE.mStateSet,
- createRoundedRectDrawable(mTopBottomCornerRadius, mTopBottomCornerRadius));
- stateList.addState(
- FIRST_EXPANDED.mStateSet,
- createRoundedRectDrawable(mTopBottomCornerRadius, 0));
- stateList.addState(
- FIRST.mStateSet,
- createRoundedRectDrawable(mTopBottomCornerRadius, mMiddleCornerRadius));
- stateList.addState(
- MIDDLE_EXPANDED.mStateSet,
- createRoundedRectDrawable(mMiddleCornerRadius, 0));
- stateList.addState(
- MIDDLE.mStateSet,
- createRoundedRectDrawable(mMiddleCornerRadius, mMiddleCornerRadius));
- stateList.addState(
- LAST.mStateSet,
- createRoundedRectDrawable(mMiddleCornerRadius, mTopBottomCornerRadius));
- RippleDrawable ripple =
- new RippleDrawable(mRippleColor, /* content= */ stateList, /* mask= */ stateList);
- ripple.setPadding(0, mVerticalPadding, 0, mVerticalPadding);
- return new InsetDrawable(ripple, 0, mHeaderMargin, 0, 0);
- }
-
- /**
- * Creates a drawable for widget content list items. This state list supports the middle and
- * last states.
- */
- Drawable createContentBackgroundDrawable() {
- StateListDrawable stateList = new StateListDrawable();
- stateList.addState(
- MIDDLE.mStateSet,
- createRoundedRectDrawable(0, mMiddleCornerRadius));
- stateList.addState(
- LAST.mStateSet,
- createRoundedRectDrawable(0, mTopBottomCornerRadius));
- return new RippleDrawable(mRippleColor, /* content= */ stateList, /* mask= */ stateList);
- }
-
- /** Creates a rounded-rect drawable with the specified radii. */
- private Drawable createRoundedRectDrawable(float topRadius, float bottomRadius) {
- GradientDrawable backgroundMask = new GradientDrawable();
- backgroundMask.setColor(mSurfaceColor);
- backgroundMask.setShape(GradientDrawable.RECTANGLE);
- backgroundMask.setCornerRadii(
- new float[]{
- topRadius,
- topRadius,
- topRadius,
- topRadius,
- bottomRadius,
- bottomRadius,
- bottomRadius,
- bottomRadius
- });
- return backgroundMask;
- }
-}
diff --git a/src/com/android/launcher3/widget/picker/WidgetsListHeader.java b/src/com/android/launcher3/widget/picker/WidgetsListHeader.java
index a6ef89f..547f39e 100644
--- a/src/com/android/launcher3/widget/picker/WidgetsListHeader.java
+++ b/src/com/android/launcher3/widget/picker/WidgetsListHeader.java
@@ -28,7 +28,6 @@
import android.util.TypedValue;
import android.view.View;
import android.view.accessibility.AccessibilityNodeInfo;
-import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
@@ -67,7 +66,6 @@
private TextView mTitle;
private TextView mSubtitle;
private GradientDrawable mBackground;
- private CheckBox mExpandToggle;
private boolean mEnableIconUpdateAnimation = false;
private boolean mIsExpanded = false;
@@ -101,9 +99,8 @@
mAppIcon = findViewById(R.id.app_icon);
mTitle = findViewById(R.id.app_title);
mSubtitle = findViewById(R.id.app_subtitle);
- mExpandToggle = findViewById(R.id.toggle);
if (mIsTwoPane) {
- mExpandToggle.setVisibility(GONE);
+ findViewById(R.id.toggle).setVisibility(GONE);
}
setAccessibilityDelegate(new AccessibilityDelegate() {
@@ -153,7 +150,6 @@
@UiThread
public void setExpanded(boolean isExpanded) {
this.mIsExpanded = isExpanded;
- mExpandToggle.setChecked(isExpanded);
if (mIsTwoPane) {
if (Utilities.isDarkTheme(getContext())) {
if (mIsExpanded) {
diff --git a/src/com/android/launcher3/widget/picker/WidgetsListHeaderViewHolderBinder.java b/src/com/android/launcher3/widget/picker/WidgetsListHeaderViewHolderBinder.java
index c6a7285..27a2b1c 100644
--- a/src/com/android/launcher3/widget/picker/WidgetsListHeaderViewHolderBinder.java
+++ b/src/com/android/launcher3/widget/picker/WidgetsListHeaderViewHolderBinder.java
@@ -32,22 +32,17 @@
ViewHolderBinder<WidgetsListHeaderEntry, WidgetsListHeaderHolder> {
private final LayoutInflater mLayoutInflater;
private final OnHeaderClickListener mOnHeaderClickListener;
- private final WidgetsListDrawableFactory mListDrawableFactory;
public WidgetsListHeaderViewHolderBinder(LayoutInflater layoutInflater,
- OnHeaderClickListener onHeaderClickListener,
- WidgetsListDrawableFactory listDrawableFactory) {
+ OnHeaderClickListener onHeaderClickListener) {
mLayoutInflater = layoutInflater;
mOnHeaderClickListener = onHeaderClickListener;
- mListDrawableFactory = listDrawableFactory;
}
@Override
public WidgetsListHeaderHolder newViewHolder(ViewGroup parent) {
- WidgetsListHeader header = (WidgetsListHeader) mLayoutInflater.inflate(
- R.layout.widgets_list_row_header, parent, false);
- header.setBackground(mListDrawableFactory.createHeaderBackgroundDrawable());
- return new WidgetsListHeaderHolder(header);
+ return new WidgetsListHeaderHolder((WidgetsListHeader) mLayoutInflater.inflate(
+ R.layout.widgets_list_row_header, parent, false));
}
@Override
diff --git a/src/com/android/launcher3/widget/picker/WidgetsListTableViewHolderBinder.java b/src/com/android/launcher3/widget/picker/WidgetsListTableViewHolderBinder.java
index 8500b9a..4c1f7a9 100644
--- a/src/com/android/launcher3/widget/picker/WidgetsListTableViewHolderBinder.java
+++ b/src/com/android/launcher3/widget/picker/WidgetsListTableViewHolderBinder.java
@@ -51,17 +51,14 @@
private final LayoutInflater mLayoutInflater;
private final OnClickListener mIconClickListener;
private final OnLongClickListener mIconLongClickListener;
- private final WidgetsListDrawableFactory mListDrawableFactory;
public WidgetsListTableViewHolderBinder(
LayoutInflater layoutInflater,
OnClickListener iconClickListener,
- OnLongClickListener iconLongClickListener,
- WidgetsListDrawableFactory listDrawableFactory) {
+ OnLongClickListener iconLongClickListener) {
mLayoutInflater = layoutInflater;
mIconClickListener = iconClickListener;
mIconLongClickListener = iconLongClickListener;
- mListDrawableFactory = listDrawableFactory;
}
@Override
@@ -70,12 +67,8 @@
Log.v(TAG, "\nonCreateViewHolder");
}
- WidgetsRowViewHolder viewHolder =
- new WidgetsRowViewHolder(mLayoutInflater.inflate(
+ return new WidgetsRowViewHolder(mLayoutInflater.inflate(
R.layout.widgets_table_container, parent, false));
- viewHolder.tableContainer.setBackgroundDrawable(
- mListDrawableFactory.createContentBackgroundDrawable());
- return viewHolder;
}
@Override
diff --git a/tests/src/com/android/launcher3/widget/picker/WidgetsListHeaderViewHolderBinderTest.java b/tests/src/com/android/launcher3/widget/picker/WidgetsListHeaderViewHolderBinderTest.java
index f53d15b..612a4c6 100644
--- a/tests/src/com/android/launcher3/widget/picker/WidgetsListHeaderViewHolderBinderTest.java
+++ b/tests/src/com/android/launcher3/widget/picker/WidgetsListHeaderViewHolderBinderTest.java
@@ -90,8 +90,7 @@
}).when(mIconCache).getTitleNoCache(any());
mViewHolderBinder = new WidgetsListHeaderViewHolderBinder(
LayoutInflater.from(mContext),
- mOnHeaderClickListener,
- new WidgetsListDrawableFactory(mContext));
+ mOnHeaderClickListener);
}
@Test
diff --git a/tests/src/com/android/launcher3/widget/picker/WidgetsListTableViewHolderBinderTest.java b/tests/src/com/android/launcher3/widget/picker/WidgetsListTableViewHolderBinderTest.java
index 7ec4d20..9dc46f1 100644
--- a/tests/src/com/android/launcher3/widget/picker/WidgetsListTableViewHolderBinderTest.java
+++ b/tests/src/com/android/launcher3/widget/picker/WidgetsListTableViewHolderBinderTest.java
@@ -96,8 +96,7 @@
mViewHolderBinder = new WidgetsListTableViewHolderBinder(
LayoutInflater.from(mContext),
mOnIconClickListener,
- mOnLongClickListener,
- new WidgetsListDrawableFactory(mContext));
+ mOnLongClickListener);
}
@Test