Add divider line into taskbar.
Test: Visual(Pics in buganizer)
Bug: 265347148
Change-Id: Ia2fbd5f0938b7eed520652573f4aca5346685429
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java
index 2fcd64b..db584d8 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java
@@ -15,8 +15,9 @@
*/
package com.android.launcher3.taskbar;
+import static android.content.pm.PackageManager.FEATURE_PC;
+
import android.content.Context;
-import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Rect;
@@ -81,6 +82,9 @@
// Only non-null when device supports having an All Apps button.
private @Nullable View mAllAppsButton;
+ // Only non-null when device supports having an All Apps button.
+ private @Nullable View mTaskbarDivider;
+
private View mQsb;
public TaskbarView(@NonNull Context context) {
@@ -119,13 +123,16 @@
mThemeIconsBackground = calculateThemeIconsBackground();
- if (FeatureFlags.ENABLE_ALL_APPS_IN_TASKBAR.get()) {
+ if (FeatureFlags.ENABLE_ALL_APPS_IN_TASKBAR.get()
+ && !mActivityContext.getPackageManager().hasSystemFeature(FEATURE_PC)) {
mAllAppsButton = LayoutInflater.from(context)
.inflate(R.layout.taskbar_all_apps_button, this, false);
mAllAppsButton.setPadding(mItemPadding, mItemPadding, mItemPadding, mItemPadding);
mAllAppsButton.setScaleX(mIsRtl ? -1 : 1);
- if (mActivityContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_PC)) {
- mAllAppsButton.setVisibility(GONE);
+
+ if (FeatureFlags.ENABLE_TASKBAR_PINNING.get()) {
+ mTaskbarDivider = LayoutInflater.from(context).inflate(R.layout.taskbar_divider,
+ this, false);
}
}
@@ -159,6 +166,9 @@
if (mAllAppsButton != null) {
mAllAppsButton.setOnClickListener(mControllerCallbacks.getAllAppsButtonClickListener());
}
+ if (mTaskbarDivider != null) {
+ //TODO(b/265434705): set long press listener
+ }
}
private void removeAndRecycle(View view) {
@@ -180,6 +190,10 @@
if (mAllAppsButton != null) {
removeView(mAllAppsButton);
+
+ if (mTaskbarDivider != null) {
+ removeView(mTaskbarDivider);
+ }
}
removeView(mQsb);
@@ -256,8 +270,11 @@
}
if (mAllAppsButton != null) {
- int index = mIsRtl ? getChildCount() : 0;
- addView(mAllAppsButton, index);
+ addView(mAllAppsButton, mIsRtl ? getChildCount() : 0);
+
+ if (mTaskbarDivider != null) {
+ addView(mTaskbarDivider, mIsRtl ? (getChildCount() - 1) : 1);
+ }
}
if (mActivityContext.getDeviceProfile().isQsbInline) {
addView(mQsb, mIsRtl ? getChildCount() : 0);
@@ -328,6 +345,11 @@
int qsbTop = (bottom - top - deviceProfile.hotseatQsbHeight) / 2;
int qsbBottom = qsbTop + deviceProfile.hotseatQsbHeight;
child.layout(qsbStart, qsbTop, qsbEnd, qsbBottom);
+ } else if (child == mTaskbarDivider) {
+ iconEnd += mItemMarginLeftRight;
+ int iconStart = iconEnd - mIconTouchSize;
+ child.layout(iconStart, mIconLayoutBounds.top, iconEnd, mIconLayoutBounds.bottom);
+ iconEnd = iconStart + mItemMarginLeftRight;
} else {
iconEnd -= mItemMarginLeftRight;
int iconStart = iconEnd - mIconTouchSize;
diff --git a/res/layout/taskbar_divider.xml b/res/layout/taskbar_divider.xml
new file mode 100644
index 0000000..e25e7a3
--- /dev/null
+++ b/res/layout/taskbar_divider.xml
@@ -0,0 +1,28 @@
+<?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.
+-->
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/taskbar_divider_container"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content">
+
+ <View
+ android:id="@+id/taskbar_divider_bar"
+ android:layout_height="32dp"
+ android:layout_width="2dp"
+ android:layout_gravity="center"
+ android:background="@drawable/bg_rounded_corner_bottom_sheet_handle" />
+ <!-- TODO(b/265347148): Create separate drawable -->
+</FrameLayout>