1616
1717import android .annotation .SuppressLint ;
1818import android .content .pm .ActivityInfo ;
19+ import android .os .Build ;
1920import android .os .Bundle ;
21+ import android .view .View ;
22+ import android .view .WindowInsetsController ;
23+ import android .view .WindowManager ;
2024
2125import com .firebase .ui .auth .R ;
2226
2327import androidx .annotation .NonNull ;
2428import androidx .annotation .Nullable ;
2529import 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 ;
2635import androidx .fragment .app .Fragment ;
2736import androidx .fragment .app .FragmentTransaction ;
2837
@@ -34,11 +43,28 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
3443 setTheme (R .style .FirebaseUI ); // Provides default values
3544 setTheme (getFlowParams ().themeId );
3645
46+ // Enable edge-to-edge
47+ WindowCompat .setDecorFitsSystemWindows (getWindow (), false );
48+
3749 if (getFlowParams ().lockOrientation ) {
3850 lockOrientation ();
3951 }
4052 }
4153
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+
4268 protected void switchFragment (@ NonNull Fragment fragment ,
4369 int fragmentId ,
4470 @ NonNull String tag ,
0 commit comments