mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-19 02:38:20 +00:00
Merge "Add divider line into taskbar." into tm-qpr-dev
This commit is contained in:
@@ -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 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
|
||||
// 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 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
|
||||
|
||||
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 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
|
||||
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 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
|
||||
|
||||
if (mAllAppsButton != null) {
|
||||
removeView(mAllAppsButton);
|
||||
|
||||
if (mTaskbarDivider != null) {
|
||||
removeView(mTaskbarDivider);
|
||||
}
|
||||
}
|
||||
removeView(mQsb);
|
||||
|
||||
@@ -256,8 +270,11 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
|
||||
}
|
||||
|
||||
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 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
|
||||
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;
|
||||
|
||||
28
res/layout/taskbar_divider.xml
Normal file
28
res/layout/taskbar_divider.xml
Normal file
@@ -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>
|
||||
Reference in New Issue
Block a user