Loading libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/DividerPresenter.java +66 −15 Original line number Diff line number Diff line Loading @@ -466,10 +466,6 @@ class DividerPresenter implements View.OnTouchListener { } if (dividerAttributes.getDividerType() == DividerAttributes.DIVIDER_TYPE_DRAGGABLE) { // Draggable divider width must be larger than the drag handle size. widthDp = Math.max(widthDp, getDimensionDp(R.dimen.activity_embedding_divider_touch_target_width)); // Update minRatio and maxRatio only when it is a draggable divider. if (minRatio == RATIO_SYSTEM_DEFAULT) { minRatio = DEFAULT_MIN_RATIO; Loading Loading @@ -912,17 +908,21 @@ class DividerPresenter implements View.OnTouchListener { @NonNull private final FrameLayout mDividerLayout; @NonNull private final View mDividerLine; private View mDragHandle; @NonNull private final View.OnTouchListener mListener; @NonNull private Properties mProperties; private int mDividerWidthPx; private int mHandleWidthPx; @Nullable private SurfaceControl mPrimaryVeil; @Nullable private SurfaceControl mSecondaryVeil; private boolean mIsDragging; private int mDividerPosition; private View mDragHandle; private int mDividerSurfaceWidthPx; private Renderer(@NonNull Properties properties, @NonNull View.OnTouchListener listener) { mProperties = properties; Loading @@ -940,6 +940,7 @@ class DividerPresenter implements View.OnTouchListener { context, displayManager.getDisplay(mProperties.mDisplayId), mWindowlessWindowManager, "DividerContainer"); mDividerLayout = new FrameLayout(context); mDividerLine = new View(context); update(); } Loading @@ -956,6 +957,17 @@ class DividerPresenter implements View.OnTouchListener { mDividerWidthPx = getDividerWidthPx(mProperties.mDividerAttributes); mDividerPosition = mProperties.mInitialDividerPosition; mWindowlessWindowManager.setConfiguration(mProperties.mConfiguration); if (mProperties.mDividerAttributes.getDividerType() == DividerAttributes.DIVIDER_TYPE_DRAGGABLE) { // TODO(b/329193115) support divider on secondary display final Context context = ActivityThread.currentActivityThread().getApplication(); mHandleWidthPx = context.getResources().getDimensionPixelSize( R.dimen.activity_embedding_divider_touch_target_width); } else { mHandleWidthPx = 0; } // TODO handle synchronization between surface transactions and WCT. final SurfaceControl.Transaction t = new SurfaceControl.Transaction(); updateSurface(t); Loading Loading @@ -985,13 +997,45 @@ class DividerPresenter implements View.OnTouchListener { */ private void updateSurface(@NonNull SurfaceControl.Transaction t) { final Rect taskBounds = mProperties.mConfiguration.windowConfiguration.getBounds(); int dividerSurfacePosition; if (mProperties.mDividerAttributes.getDividerType() == DividerAttributes.DIVIDER_TYPE_DRAGGABLE) { // When the divider drag handle width is larger than the divider width, the position // of the divider surface is adjusted so that it is large enough to host both the // divider line and the divider drag handle. mDividerSurfaceWidthPx = Math.max(mDividerWidthPx, mHandleWidthPx); dividerSurfacePosition = mProperties.mIsReversedLayout ? mDividerPosition : mDividerPosition + mDividerWidthPx - mDividerSurfaceWidthPx; dividerSurfacePosition = Math.clamp(dividerSurfacePosition, 0, mProperties.mIsVerticalSplit ? taskBounds.width() : taskBounds.height()); } else { mDividerSurfaceWidthPx = mDividerWidthPx; dividerSurfacePosition = mDividerPosition; } if (mProperties.mIsVerticalSplit) { t.setPosition(mDividerSurface, mDividerPosition, 0.0f); t.setWindowCrop(mDividerSurface, mDividerWidthPx, taskBounds.height()); t.setPosition(mDividerSurface, dividerSurfacePosition, 0.0f); t.setWindowCrop(mDividerSurface, mDividerSurfaceWidthPx, taskBounds.height()); } else { t.setPosition(mDividerSurface, 0.0f, mDividerPosition); t.setWindowCrop(mDividerSurface, taskBounds.width(), mDividerWidthPx); t.setPosition(mDividerSurface, 0.0f, dividerSurfacePosition); t.setWindowCrop(mDividerSurface, taskBounds.width(), mDividerSurfaceWidthPx); } // Update divider line position in the surface if (!mProperties.mIsReversedLayout) { final int offset = mDividerPosition - dividerSurfacePosition; mDividerLine.setX(mProperties.mIsVerticalSplit ? offset : 0); mDividerLine.setY(mProperties.mIsVerticalSplit ? 0 : offset); } else { // For reversed layout, the divider line is always at the start of the divider // surface. mDividerLine.setX(0); mDividerLine.setY(0); } if (mIsDragging) { updateVeils(t); } Loading @@ -1006,14 +1050,14 @@ class DividerPresenter implements View.OnTouchListener { final Rect taskBounds = mProperties.mConfiguration.windowConfiguration.getBounds(); final WindowManager.LayoutParams lp = mProperties.mIsVerticalSplit ? new WindowManager.LayoutParams( mDividerWidthPx, mDividerSurfaceWidthPx, taskBounds.height(), TYPE_APPLICATION_PANEL, FLAG_NOT_FOCUSABLE | FLAG_NOT_TOUCH_MODAL | FLAG_SLIPPERY, PixelFormat.TRANSLUCENT) : new WindowManager.LayoutParams( taskBounds.width(), mDividerWidthPx, mDividerSurfaceWidthPx, TYPE_APPLICATION_PANEL, FLAG_NOT_FOCUSABLE | FLAG_NOT_TOUCH_MODAL | FLAG_SLIPPERY, PixelFormat.TRANSLUCENT); Loading @@ -1030,12 +1074,19 @@ class DividerPresenter implements View.OnTouchListener { */ private void updateDivider(@NonNull SurfaceControl.Transaction t) { mDividerLayout.removeAllViews(); if (mProperties.mIsDraggableExpandType) { mDividerLayout.addView(mDividerLine); if (mProperties.mIsDraggableExpandType && !mIsDragging) { // If a container is fully expanded, the divider overlays on the expanded container. mDividerLayout.setBackgroundColor(Color.TRANSPARENT); mDividerLine.setBackgroundColor(Color.TRANSPARENT); } else { mDividerLayout.setBackgroundColor(mProperties.mDividerAttributes.getDividerColor()); mDividerLine.setBackgroundColor(mProperties.mDividerAttributes.getDividerColor()); } final Rect taskBounds = mProperties.mConfiguration.windowConfiguration.getBounds(); mDividerLine.setLayoutParams( mProperties.mIsVerticalSplit ? new FrameLayout.LayoutParams(mDividerWidthPx, taskBounds.height()) : new FrameLayout.LayoutParams(taskBounds.width(), mDividerWidthPx) ); if (mProperties.mDividerAttributes.getDividerType() == DividerAttributes.DIVIDER_TYPE_DRAGGABLE) { createVeils(); Loading @@ -1062,7 +1113,7 @@ class DividerPresenter implements View.OnTouchListener { R.dimen.activity_embedding_divider_touch_target_width)); params.gravity = Gravity.CENTER; button.setLayoutParams(params); button.setBackgroundColor(R.color.transparent); button.setBackgroundColor(Color.TRANSPARENT); final Drawable handle = context.getResources().getDrawable( R.drawable.activity_embedding_divider_handle, context.getTheme()); Loading Loading
libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/DividerPresenter.java +66 −15 Original line number Diff line number Diff line Loading @@ -466,10 +466,6 @@ class DividerPresenter implements View.OnTouchListener { } if (dividerAttributes.getDividerType() == DividerAttributes.DIVIDER_TYPE_DRAGGABLE) { // Draggable divider width must be larger than the drag handle size. widthDp = Math.max(widthDp, getDimensionDp(R.dimen.activity_embedding_divider_touch_target_width)); // Update minRatio and maxRatio only when it is a draggable divider. if (minRatio == RATIO_SYSTEM_DEFAULT) { minRatio = DEFAULT_MIN_RATIO; Loading Loading @@ -912,17 +908,21 @@ class DividerPresenter implements View.OnTouchListener { @NonNull private final FrameLayout mDividerLayout; @NonNull private final View mDividerLine; private View mDragHandle; @NonNull private final View.OnTouchListener mListener; @NonNull private Properties mProperties; private int mDividerWidthPx; private int mHandleWidthPx; @Nullable private SurfaceControl mPrimaryVeil; @Nullable private SurfaceControl mSecondaryVeil; private boolean mIsDragging; private int mDividerPosition; private View mDragHandle; private int mDividerSurfaceWidthPx; private Renderer(@NonNull Properties properties, @NonNull View.OnTouchListener listener) { mProperties = properties; Loading @@ -940,6 +940,7 @@ class DividerPresenter implements View.OnTouchListener { context, displayManager.getDisplay(mProperties.mDisplayId), mWindowlessWindowManager, "DividerContainer"); mDividerLayout = new FrameLayout(context); mDividerLine = new View(context); update(); } Loading @@ -956,6 +957,17 @@ class DividerPresenter implements View.OnTouchListener { mDividerWidthPx = getDividerWidthPx(mProperties.mDividerAttributes); mDividerPosition = mProperties.mInitialDividerPosition; mWindowlessWindowManager.setConfiguration(mProperties.mConfiguration); if (mProperties.mDividerAttributes.getDividerType() == DividerAttributes.DIVIDER_TYPE_DRAGGABLE) { // TODO(b/329193115) support divider on secondary display final Context context = ActivityThread.currentActivityThread().getApplication(); mHandleWidthPx = context.getResources().getDimensionPixelSize( R.dimen.activity_embedding_divider_touch_target_width); } else { mHandleWidthPx = 0; } // TODO handle synchronization between surface transactions and WCT. final SurfaceControl.Transaction t = new SurfaceControl.Transaction(); updateSurface(t); Loading Loading @@ -985,13 +997,45 @@ class DividerPresenter implements View.OnTouchListener { */ private void updateSurface(@NonNull SurfaceControl.Transaction t) { final Rect taskBounds = mProperties.mConfiguration.windowConfiguration.getBounds(); int dividerSurfacePosition; if (mProperties.mDividerAttributes.getDividerType() == DividerAttributes.DIVIDER_TYPE_DRAGGABLE) { // When the divider drag handle width is larger than the divider width, the position // of the divider surface is adjusted so that it is large enough to host both the // divider line and the divider drag handle. mDividerSurfaceWidthPx = Math.max(mDividerWidthPx, mHandleWidthPx); dividerSurfacePosition = mProperties.mIsReversedLayout ? mDividerPosition : mDividerPosition + mDividerWidthPx - mDividerSurfaceWidthPx; dividerSurfacePosition = Math.clamp(dividerSurfacePosition, 0, mProperties.mIsVerticalSplit ? taskBounds.width() : taskBounds.height()); } else { mDividerSurfaceWidthPx = mDividerWidthPx; dividerSurfacePosition = mDividerPosition; } if (mProperties.mIsVerticalSplit) { t.setPosition(mDividerSurface, mDividerPosition, 0.0f); t.setWindowCrop(mDividerSurface, mDividerWidthPx, taskBounds.height()); t.setPosition(mDividerSurface, dividerSurfacePosition, 0.0f); t.setWindowCrop(mDividerSurface, mDividerSurfaceWidthPx, taskBounds.height()); } else { t.setPosition(mDividerSurface, 0.0f, mDividerPosition); t.setWindowCrop(mDividerSurface, taskBounds.width(), mDividerWidthPx); t.setPosition(mDividerSurface, 0.0f, dividerSurfacePosition); t.setWindowCrop(mDividerSurface, taskBounds.width(), mDividerSurfaceWidthPx); } // Update divider line position in the surface if (!mProperties.mIsReversedLayout) { final int offset = mDividerPosition - dividerSurfacePosition; mDividerLine.setX(mProperties.mIsVerticalSplit ? offset : 0); mDividerLine.setY(mProperties.mIsVerticalSplit ? 0 : offset); } else { // For reversed layout, the divider line is always at the start of the divider // surface. mDividerLine.setX(0); mDividerLine.setY(0); } if (mIsDragging) { updateVeils(t); } Loading @@ -1006,14 +1050,14 @@ class DividerPresenter implements View.OnTouchListener { final Rect taskBounds = mProperties.mConfiguration.windowConfiguration.getBounds(); final WindowManager.LayoutParams lp = mProperties.mIsVerticalSplit ? new WindowManager.LayoutParams( mDividerWidthPx, mDividerSurfaceWidthPx, taskBounds.height(), TYPE_APPLICATION_PANEL, FLAG_NOT_FOCUSABLE | FLAG_NOT_TOUCH_MODAL | FLAG_SLIPPERY, PixelFormat.TRANSLUCENT) : new WindowManager.LayoutParams( taskBounds.width(), mDividerWidthPx, mDividerSurfaceWidthPx, TYPE_APPLICATION_PANEL, FLAG_NOT_FOCUSABLE | FLAG_NOT_TOUCH_MODAL | FLAG_SLIPPERY, PixelFormat.TRANSLUCENT); Loading @@ -1030,12 +1074,19 @@ class DividerPresenter implements View.OnTouchListener { */ private void updateDivider(@NonNull SurfaceControl.Transaction t) { mDividerLayout.removeAllViews(); if (mProperties.mIsDraggableExpandType) { mDividerLayout.addView(mDividerLine); if (mProperties.mIsDraggableExpandType && !mIsDragging) { // If a container is fully expanded, the divider overlays on the expanded container. mDividerLayout.setBackgroundColor(Color.TRANSPARENT); mDividerLine.setBackgroundColor(Color.TRANSPARENT); } else { mDividerLayout.setBackgroundColor(mProperties.mDividerAttributes.getDividerColor()); mDividerLine.setBackgroundColor(mProperties.mDividerAttributes.getDividerColor()); } final Rect taskBounds = mProperties.mConfiguration.windowConfiguration.getBounds(); mDividerLine.setLayoutParams( mProperties.mIsVerticalSplit ? new FrameLayout.LayoutParams(mDividerWidthPx, taskBounds.height()) : new FrameLayout.LayoutParams(taskBounds.width(), mDividerWidthPx) ); if (mProperties.mDividerAttributes.getDividerType() == DividerAttributes.DIVIDER_TYPE_DRAGGABLE) { createVeils(); Loading @@ -1062,7 +1113,7 @@ class DividerPresenter implements View.OnTouchListener { R.dimen.activity_embedding_divider_touch_target_width)); params.gravity = Gravity.CENTER; button.setLayoutParams(params); button.setBackgroundColor(R.color.transparent); button.setBackgroundColor(Color.TRANSPARENT); final Drawable handle = context.getResources().getDrawable( R.drawable.activity_embedding_divider_handle, context.getTheme()); Loading