Skip to content

Commit cdd7394

Browse files
committed
more padding
1 parent 2e17c04 commit cdd7394

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

auth/src/main/java/com/firebase/ui/auth/ui/AppCompatBase.java

+26
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,22 @@
1616

1717
import android.annotation.SuppressLint;
1818
import android.content.pm.ActivityInfo;
19+
import android.os.Build;
1920
import android.os.Bundle;
21+
import android.view.View;
22+
import android.view.WindowInsetsController;
23+
import android.view.WindowManager;
2024

2125
import com.firebase.ui.auth.R;
2226

2327
import androidx.annotation.NonNull;
2428
import androidx.annotation.Nullable;
2529
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;
2635
import androidx.fragment.app.Fragment;
2736
import 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

Comments
 (0)