Merge "Fix TaskbarAllApps Icon" into main

This commit is contained in:
Jagrut Desai
2025-05-12 16:58:46 -07:00
committed by Android (Google) Code Review
8 changed files with 56 additions and 12 deletions
@@ -593,6 +593,10 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
&& !mDeviceProfile.isTaskbarPresent;
}
public boolean isTaskbarInMinimalState() {
return mControllers.taskbarViewController.isTaskbarInMinimalState();
}
/**
* @return {@code true} if {@link #isPhoneMode()} is true and we're using 3 button-nav
*/
@@ -404,6 +404,11 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
} else {
updateItemsWithoutLayoutTransition(hotseatItemInfos, recentTasks);
}
mAllAppsButtonContainer.updateTaskbarMinimalState(isTaskbarInMinimalState());
}
public boolean isTaskbarInMinimalState() {
return getIconViews().length <= 1;
}
private void updateItemsWithoutLayoutTransition(
@@ -1355,6 +1355,10 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
return layoutTransition;
}
public boolean isTaskbarInMinimalState() {
return mTaskbarView.isTaskbarInMinimalState();
}
/**
* To be called when the given Task is updated, so that we can tell TaskbarView to also update.
* @param task The Task whose e.g. icon changed.
@@ -49,6 +49,7 @@ constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
private var allAppsTouchTriggered = false
private var allAppsTouchRunnable: Runnable? = null
private var allAppsButtonTouchDelayMs: Long = ViewConfiguration.getLongPressTimeout().toLong()
private var isTaskbarInMinimalState = false
private lateinit var taskbarViewCallbacks: TaskbarViewCallbacks
override val spaceNeeded: Int
@@ -117,22 +118,17 @@ constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
@DrawableRes
private fun getAllAppsButtonForExpressiveTheme(): Int {
return R.drawable.ic_taskbar_all_apps_search_button_expressive_theme
}
@DimenRes
fun getAllAppsButtonTranslationXOffsetForExpressiveTheme(isTransientTaskbar: Boolean): Int {
return if (isTransientTaskbar) {
R.dimen.transient_taskbar_all_apps_button_translation_x_offset_for_expressive_theme
return if (isTaskbarInMinimalState) {
R.drawable.ic_taskbar_minimal_state_all_apps_search_button_expressive_theme
} else {
R.dimen.taskbar_all_apps_search_button_translation_x_offset_for_expressive_theme
R.drawable.ic_taskbar_all_apps_search_button_expressive_theme
}
}
@DimenRes
fun getAllAppsButtonTranslationXOffset(isTransientTaskbar: Boolean): Int {
if (Flags.enableGsf()) {
return getAllAppsButtonTranslationXOffsetForExpressiveTheme(isTransientTaskbar)
return R.dimen.taskbar_all_apps_search_button_translation_x_offset_for_expressive_theme
}
return if (isTransientTaskbar) {
R.dimen.transient_taskbar_all_apps_button_translation_x_offset
@@ -141,6 +137,14 @@ constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
}
}
/** Taskbar minimal state is that taskbar does not host anything other than all apps button. */
fun updateTaskbarMinimalState(isInMinimalState: Boolean) {
if (isTaskbarInMinimalState != isInMinimalState) {
isTaskbarInMinimalState = isInMinimalState
setUpIcon()
}
}
private fun onAllAppsButtonTouch(view: View, ev: MotionEvent): Boolean {
when (ev.action) {
MotionEvent.ACTION_DOWN -> {
@@ -40,6 +40,9 @@ private constructor(private val taskbarActivityContext: TaskbarActivityContext)
val isLandscape: Boolean
get() = taskbarActivityContext.deviceProfile.isLandscape
val isTnMinimalState: Boolean
get() = taskbarActivityContext.isTaskbarInMinimalState
val supportsPinningPopup: Boolean
// TODO(b/381535785): Allow pinning for desktop taskbar when desktop mode transient behavior
// gets updated to retain pinned UI, but translate the taskbar offscreen.