16
16
17
17
import android .annotation .SuppressLint ;
18
18
import android .content .pm .ActivityInfo ;
19
+ import android .os .Build ;
19
20
import android .os .Bundle ;
21
+ import android .view .View ;
22
+ import android .view .WindowInsetsController ;
23
+ import android .view .WindowManager ;
20
24
21
25
import com .firebase .ui .auth .R ;
22
26
23
27
import androidx .annotation .NonNull ;
24
28
import androidx .annotation .Nullable ;
25
29
import androidx .annotation .RestrictTo ;
30
+ import androidx .core .view .ViewCompat ;
31
+ import androidx .core .view .WindowCompat ;
32
+ import androidx .core .view .WindowInsetsCompat ;
33
+ import androidx .core .view .WindowInsetsControllerCompat ;
34
+ import androidx .core .graphics .Insets ;
26
35
import androidx .fragment .app .Fragment ;
27
36
import androidx .fragment .app .FragmentTransaction ;
28
37
@@ -34,11 +43,28 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
34
43
setTheme (R .style .FirebaseUI ); // Provides default values
35
44
setTheme (getFlowParams ().themeId );
36
45
46
+ // Enable edge-to-edge
47
+ WindowCompat .setDecorFitsSystemWindows (getWindow (), false );
48
+
37
49
if (getFlowParams ().lockOrientation ) {
38
50
lockOrientation ();
39
51
}
40
52
}
41
53
54
+ @ Override
55
+ public void onAttachedToWindow () {
56
+ super .onAttachedToWindow ();
57
+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .UPSIDE_DOWN_CAKE ) {
58
+ // Add padding to the top for API 35+ when using edge-to-edge
59
+ View rootView = findViewById (android .R .id .content );
60
+ ViewCompat .setOnApplyWindowInsetsListener (rootView , (v , insets ) -> {
61
+ Insets systemBars = insets .getInsets (WindowInsetsCompat .Type .systemBars ());
62
+ v .setPadding (v .getPaddingLeft (), systemBars .top , v .getPaddingRight (), v .getPaddingBottom ());
63
+ return insets ;
64
+ });
65
+ }
66
+ }
67
+
42
68
protected void switchFragment (@ NonNull Fragment fragment ,
43
69
int fragmentId ,
44
70
@ NonNull String tag ,
0 commit comments