Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 06ee0061 authored by Vania Desmonda's avatar Vania Desmonda Committed by Android (Google) Code Review
Browse files

Merge "Enable RTL support for desktop windowing education." into main

parents 9aaa4bc3 6ca6ebe2
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -18,7 +18,8 @@
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:elevation="1dp"
    android:orientation="horizontal">
    android:orientation="horizontal"
    android:gravity="start">

    <!-- ImageView for the arrow icon, positioned horizontally at the start of the tooltip
    container. -->
+18 −6
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.content.Context
import android.content.res.Resources
import android.graphics.Point
import android.os.SystemProperties
import android.view.View.LAYOUT_DIRECTION_RTL
import com.android.window.flags.Flags
import com.android.wm.shell.R
import com.android.wm.shell.desktopmode.CaptionState
@@ -187,9 +188,14 @@ class AppHandleEducationController(
                getSize(R.dimen.desktop_mode_handle_menu_pill_spacing_margin)

        val appHandleBounds = captionState.globalAppHandleBounds
        val appHandleCenterX = appHandleBounds.left + appHandleBounds.width() / 2
        val tooltipGlobalCoordinates =
            Point(
                appHandleBounds.left + appHandleBounds.width() / 2 + appHandleMenuWidth / 2,
                if (isRtl()) {
                    appHandleCenterX - appHandleMenuWidth / 2
                } else {
                    appHandleCenterX + appHandleMenuWidth / 2
                },
                appHandleBounds.top +
                    appHandleMenuMargins +
                    appInfoPillHeight +
@@ -199,7 +205,7 @@ class AppHandleEducationController(
        // tooltip.
        val windowingImageButtonTooltipConfig =
            TooltipEducationViewConfig(
                tooltipViewLayout = R.layout.desktop_windowing_education_left_arrow_tooltip,
                tooltipViewLayout = R.layout.desktop_windowing_education_horizontal_arrow_tooltip,
                tooltipColorScheme =
                    TooltipColorScheme(
                        tertiaryFixedColor,
@@ -210,7 +216,7 @@ class AppHandleEducationController(
                tooltipText =
                    getString(R.string.windowing_desktop_mode_image_button_education_tooltip),
                arrowDirection =
                    DesktopWindowingEducationTooltipController.TooltipArrowDirection.LEFT,
                    DesktopWindowingEducationTooltipController.TooltipArrowDirection.HORIZONTAL,
                onEducationClickAction = {
                    toDesktopModeCallback(
                        captionState.runningTaskInfo.taskId,
@@ -233,13 +239,17 @@ class AppHandleEducationController(
        val globalAppChipBounds = captionState.globalAppChipBounds
        val tooltipGlobalCoordinates =
            Point(
                globalAppChipBounds.right,
                if (isRtl()) {
                    globalAppChipBounds.left
                } else {
                    globalAppChipBounds.right
                },
                globalAppChipBounds.top + globalAppChipBounds.height() / 2,
            )
        // Populate information important to inflate exit desktop mode education tooltip.
        val exitWindowingTooltipConfig =
            TooltipEducationViewConfig(
                tooltipViewLayout = R.layout.desktop_windowing_education_left_arrow_tooltip,
                tooltipViewLayout = R.layout.desktop_windowing_education_horizontal_arrow_tooltip,
                tooltipColorScheme =
                    TooltipColorScheme(
                        tertiaryFixedColor,
@@ -249,7 +259,7 @@ class AppHandleEducationController(
                tooltipViewGlobalCoordinates = tooltipGlobalCoordinates,
                tooltipText = getString(R.string.windowing_desktop_mode_exit_education_tooltip),
                arrowDirection =
                    DesktopWindowingEducationTooltipController.TooltipArrowDirection.LEFT,
                    DesktopWindowingEducationTooltipController.TooltipArrowDirection.HORIZONTAL,
                onDismissAction = {
                    // TODO: b/341320146 - Log previous tooltip was dismissed
                },
@@ -299,6 +309,8 @@ class AppHandleEducationController(

    private fun getString(@StringRes resId: Int): String = context.resources.getString(resId)

    private fun isRtl() = context.resources.configuration.layoutDirection == LAYOUT_DIRECTION_RTL

    companion object {
        const val TAG = "AppHandleEducationController"
        val APP_HANDLE_EDUCATION_DELAY_MILLIS: Long
+5 −2
Original line number Diff line number Diff line
@@ -734,7 +734,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
            // [AppHeaderViewHolder].
            ((AppHeaderViewHolder) mWindowDecorViewHolder).runOnAppChipGlobalLayout(
                    () -> {
                        notifyAppChipStateChanged();
                        notifyAppHeaderStateChanged();
                        return Unit.INSTANCE;
                    });
        }
@@ -766,7 +766,10 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
                mResult.mCaptionHeight);
    }

    private void notifyAppChipStateChanged() {
    private void notifyAppHeaderStateChanged() {
        if (isAppHandle(mWindowDecorViewHolder) || mWindowDecorViewHolder == null) {
            return;
        }
        final Rect appChipPositionInWindow =
                ((AppHeaderViewHolder) mWindowDecorViewHolder).getAppChipLocationInWindow();
        final Rect taskBounds = mTaskInfo.configuration.windowConfiguration.getBounds();
+11 −4
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.util.Size
import android.view.LayoutInflater
import android.view.MotionEvent
import android.view.View
import android.view.View.LAYOUT_DIRECTION_RTL
import android.view.View.MeasureSpec.UNSPECIFIED
import android.view.WindowManager
import android.widget.ImageView
@@ -199,6 +200,7 @@ class DesktopWindowingEducationTooltipController(
    requireViewById<ImageView>(R.id.arrow_icon).apply {
        val wrappedDrawable = DrawableCompat.wrap(this.drawable)
        DrawableCompat.setTint(wrappedDrawable, tooltipColorScheme.container)
        if (isRtl()) scaleX = -1f
    }
    requireViewById<TextView>(R.id.tooltip_text).apply { setTextColor(tooltipColorScheme.text) }
    requireViewById<ImageView>(R.id.tooltip_icon).apply {
@@ -227,6 +229,9 @@ class DesktopWindowingEducationTooltipController(
      // Arrow is placed at vertical center on the left edge of the tooltip. Hence decrement
      // half of tooltip height from [tooltipY] to vertically position the tooltip.
      tooltipY -= tooltipDimen.height / 2
      if (isRtl()) {
          tooltipX -= tooltipDimen.width
      }
    }
    return Point(tooltipX, tooltipY)
  }
@@ -260,6 +265,8 @@ class DesktopWindowingEducationTooltipController(
    return context.resources.getDimensionPixelSize(resourceId)
  }

    private fun isRtl() = context.resources.configuration.layoutDirection == LAYOUT_DIRECTION_RTL

    /**
   * The configuration for education view features:
   *
@@ -297,6 +304,6 @@ class DesktopWindowingEducationTooltipController(
  /** Direction of arrow of the tooltip */
  enum class TooltipArrowDirection {
    UP,
    LEFT,
    HORIZONTAL
  }
}
 No newline at end of file
+2 −2
Original line number Diff line number Diff line
@@ -154,12 +154,12 @@ class DesktopWindowingEducationTooltipControllerTest : ShellTestCase() {
  }

  @Test
  fun showEducationTooltip_tooltipPointsLeft_verticallyPositionTooltip() {
  fun showEducationTooltip_tooltipPointsHorizontally_verticallyPositionTooltip() {
    val initialTooltipX = 0
    val initialTooltipY = 0
    val tooltipViewConfig =
        createTooltipConfig(
            arrowDirection = TooltipArrowDirection.LEFT,
            arrowDirection = TooltipArrowDirection.HORIZONTAL,
            tooltipViewGlobalCoordinates = Point(initialTooltipX, initialTooltipY))
    val tooltipYArgumentCaptor = argumentCaptor<Int>()
    val tooltipHeightArgumentCaptor = argumentCaptor<Int>()