Skip to content

Commit 628dd8b

Browse files
committed
Fix black bar on display cutout side in landscape
In landscape orientation, the display cutout moves to a long edge of the screen. With windowLayoutInDisplayCutoutMode set to shortEdges, the system prevents the window from extending into the cutout area on long edges, leaving a black bar. Two changes fix this: 1. Set windowLayoutInDisplayCutoutMode to "always" (API 30+) so the window extends into the cutout area on all edges, not just short ones. 2. Stop DrawerLayoutContainer from voluntarily avoiding the cutout: remove displayCutout() from the inset types used to calculate child margins and to draw black background rects. The content now fills the full screen area including behind the cutout.
1 parent 3581a10 commit 628dd8b

File tree

2 files changed

+4
-25
lines changed

2 files changed

+4
-25
lines changed

TMessagesProj/src/main/java/org/telegram/ui/ActionBar/DrawerLayoutContainer.java

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import androidx.annotation.NonNull;
2121
import androidx.annotation.Nullable;
2222
import androidx.core.graphics.Insets;
23-
import androidx.core.view.DisplayCutoutCompat;
2423
import androidx.core.view.ViewCompat;
2524
import androidx.core.view.WindowInsetsCompat;
2625

@@ -36,8 +35,6 @@ public class DrawerLayoutContainer extends FrameLayout {
3635

3736
private int behindKeyboardColor;
3837

39-
private boolean hasCutout;
40-
4138
private boolean inLayout;
4239

4340
public boolean allowDrawContent = true;
@@ -75,10 +72,6 @@ public DrawerLayoutContainer(Context context) {
7572
firstLayout = false;
7673
drawerLayoutContainer.setWillNotDraw(insets.getSystemWindowInsetTop() <= 0 && getBackground() == null);
7774

78-
if (Build.VERSION.SDK_INT >= 28) {
79-
DisplayCutoutCompat cutout = insets.getDisplayCutout();
80-
hasCutout = cutout != null && !cutout.getBoundingRects().isEmpty();
81-
}
8275
invalidate();
8376

8477
return onApplyWindowInsets(v, insets);
@@ -203,8 +196,7 @@ protected void onDraw(@NonNull Canvas canvas) {
203196
}
204197

205198
final Insets insets = lastWindowInsetsCompat.getInsets(WindowInsetsCompat.Type.ime()
206-
| WindowInsetsCompat.Type.systemBars()
207-
| WindowInsetsCompat.Type.displayCutout());
199+
| WindowInsetsCompat.Type.systemBars());
208200

209201
if (insets.bottom > 0) {
210202
backgroundPaint.setColor(behindKeyboardColor);
@@ -216,18 +208,6 @@ protected void onDraw(@NonNull Canvas canvas) {
216208
internalNavbarPaint
217209
);
218210
}
219-
220-
if (hasCutout) {
221-
backgroundPaint.setColor(0xff000000);
222-
int left = insets.left;
223-
if (left != 0) {
224-
canvas.drawRect(0, 0, left, getMeasuredHeight(), backgroundPaint);
225-
}
226-
int right = insets.right;
227-
if (right != 0) {
228-
canvas.drawRect(right, 0, getMeasuredWidth(), getMeasuredHeight(), backgroundPaint);
229-
}
230-
}
231211
}
232212

233213
@Override
@@ -270,8 +250,7 @@ private void dispatchApplyWindowInsetsInternal(View child, WindowInsetsCompat in
270250

271251
final MarginLayoutParams lp = (MarginLayoutParams) child.getLayoutParams();
272252
final Insets systemInsetsWithIme = insets.getInsets(WindowInsetsCompat.Type.ime()
273-
| WindowInsetsCompat.Type.systemBars()
274-
| WindowInsetsCompat.Type.displayCutout());
253+
| WindowInsetsCompat.Type.systemBars());
275254

276255
final boolean changed = lp.topMargin != 0 || lp.bottomMargin != 0
277256
|| lp.leftMargin != systemInsetsWithIme.left

TMessagesProj/src/main/res/values-v31/styles.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
<item name="android:calendarViewStyle">@style/Theme.TMessages.CalendarView</item>
5757
<item name="android:navigationBarColor">#000000</item>
5858
<item name="android:textViewStyle">@style/MyTextViewStyle</item>
59-
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
59+
<item name="android:windowLayoutInDisplayCutoutMode">always</item>
6060
<item name="android:forceDarkAllowed">false</item>
6161
</style>
6262

@@ -82,7 +82,7 @@
8282
<item name="android:calendarViewStyle">@style/Theme.TMessages.CalendarView</item>
8383
<item name="android:navigationBarColor">#000000</item>
8484
<item name="android:textViewStyle">@style/MyTextViewStyle</item>
85-
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
85+
<item name="android:windowLayoutInDisplayCutoutMode">always</item>
8686
<item name="android:forceDarkAllowed">false</item>
8787
</style>
8888

0 commit comments

Comments
 (0)