82
82
import me .vkryl .core .MathUtils ;
83
83
import me .vkryl .core .StringUtils ;
84
84
85
- public class CallController extends ViewController <CallController .Arguments > implements TdlibCache .UserDataChangeListener , TdlibCache .CallStateChangeListener , View .OnClickListener , FactorAnimator .Target , Runnable , CallControlsLayout .CallControlCallback {
85
+ public class CallController extends ViewController <CallController .Arguments > implements TdlibCache .UserDataChangeListener , TdlibCache .CallStateChangeListener , View .OnClickListener , FactorAnimator .Target , Runnable , CallControlsLayout .CallControlCallback , Screen . StatusBarHeightChangeListener {
86
86
private static final boolean DEBUG_FADE_BRANDING = true ;
87
87
88
88
private static class ButtonView extends View implements FactorAnimator .Target {
@@ -314,6 +314,26 @@ private void setCallBarsCount (int count) {
314
314
}
315
315
}
316
316
317
+ @ Override
318
+ public boolean supportsBottomInset () {
319
+ return true ;
320
+ }
321
+
322
+ @ Override
323
+ protected void onBottomInsetChanged (int extraBottomInset , int extraBottomInsetWithoutIme , boolean isImeInset ) {
324
+ super .onBottomInsetChanged (extraBottomInset , extraBottomInsetWithoutIme , isImeInset );
325
+ Views .setPaddingBottom (buttonWrap , extraBottomInset );
326
+ Views .setPaddingBottom (callControlsLayout , extraBottomInset );
327
+ }
328
+
329
+ @ Override
330
+ public void onStatusBarHeightChanged (int newHeight ) {
331
+ int startMargin = Math .max (Screen .dp (18f ) + newHeight , Screen .dp (42f ));
332
+ Views .setTopMargin (brandWrap , startMargin );
333
+ Views .setTopMargin (nameView , startMargin + Screen .dp (34f ));
334
+ Views .setTopMargin (stateView , startMargin + Screen .dp (94f ));
335
+ }
336
+
317
337
@ Override
318
338
protected View onCreateView (final Context context ) {
319
339
final FrameLayoutFix contentView = new FrameLayoutFix (context ) {
@@ -378,7 +398,9 @@ protected void onDraw(Canvas c){
378
398
379
399
// Top-left corner
380
400
381
- params .topMargin = Screen .dp (76f );
401
+ int startMargin = Math .max (Screen .dp (18f ) + Screen .getStatusBarHeight (), Screen .dp (42f ));
402
+
403
+ params .topMargin = startMargin + Screen .dp (34f );
382
404
params .leftMargin = params .rightMargin = Screen .dp (18f );
383
405
384
406
nameView = new EmojiTextView (context ) {
@@ -414,7 +436,7 @@ protected void onDraw (Canvas canvas) {
414
436
emojiStatusHelper = new EmojiStatusHelper (tdlib , nameView , null );
415
437
416
438
params = FrameLayoutFix .newParams (ViewGroup .LayoutParams .MATCH_PARENT , ViewGroup .LayoutParams .WRAP_CONTENT );
417
- params .topMargin = Screen .dp (136f );
439
+ params .topMargin = startMargin + Screen .dp (94f );
418
440
params .leftMargin = params .rightMargin = Screen .dp (18f );
419
441
420
442
stateView = new TextView (context );
@@ -430,8 +452,9 @@ protected void onDraw (Canvas canvas) {
430
452
stateView .setLayoutParams (params );
431
453
contentView .addView (stateView );
432
454
455
+ Screen .addStatusBarHeightListener (this );
433
456
params = FrameLayoutFix .newParams (ViewGroup .LayoutParams .WRAP_CONTENT , ViewGroup .LayoutParams .WRAP_CONTENT );
434
- params .topMargin = Screen . dp ( 42f ) ;
457
+ params .topMargin = startMargin ;
435
458
params .leftMargin = params .rightMargin = Screen .dp (18f );
436
459
brandWrap = new LinearLayout (context );
437
460
if (DEBUG_FADE_BRANDING ) {
@@ -603,6 +626,7 @@ public boolean onTouchEvent (MotionEvent event) {
603
626
buttonWrap .addView (muteButtonView );
604
627
buttonWrap .addView (messageButtonView );
605
628
buttonWrap .addView (speakerButtonView );
629
+ Views .setPaddingBottom (buttonWrap , extraBottomInset );
606
630
Drawable drawable = ScrimUtil .makeCubicGradientScrimDrawable (0xff000000 , 2 , Gravity .BOTTOM , false );
607
631
drawable .setAlpha ((int ) (255f * .3f ));
608
632
ViewUtils .setBackground (buttonWrap , drawable );
@@ -611,6 +635,7 @@ public boolean onTouchEvent (MotionEvent event) {
611
635
// Answer controls
612
636
613
637
callControlsLayout = new CallControlsLayout (context , this );
638
+ Views .setPaddingBottom (callControlsLayout , extraBottomInset );
614
639
callControlsLayout .setCallback (this );
615
640
callControlsLayout .setLayoutParams (FrameLayoutFix .newParams (ViewGroup .LayoutParams .MATCH_PARENT , ViewGroup .LayoutParams .MATCH_PARENT ));
616
641
contentView .addView (callControlsLayout );
@@ -1150,6 +1175,7 @@ public void replaceCall (TdApi.Call call) {
1150
1175
@ Override
1151
1176
public void destroy () {
1152
1177
super .destroy ();
1178
+ Screen .removeStatusBarHeightListener (this );
1153
1179
tdlib .cache ().unsubscribeFromCallUpdates (call .id , this );
1154
1180
tdlib .cache ().removeUserDataListener (call .userId , this );
1155
1181
avatarView .performDestroy ();
0 commit comments