Skip to content

Commit 83d1ce2

Browse files
Lyokonethatfiredev
authored andcommitted
feat: add support for API 35 EdgeToEdge (#2187)
1 parent 4af7d0b commit 83d1ce2

File tree

19 files changed

+288
-162
lines changed

19 files changed

+288
-162
lines changed

app/src/main/java/com/firebase/uidemo/ChooserActivity.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
import android.view.View;
2121
import android.view.ViewGroup;
2222
import android.widget.TextView;
23+
import androidx.core.graphics.Insets;
24+
import androidx.core.view.ViewCompat;
25+
import androidx.core.view.WindowCompat;
26+
import androidx.core.view.WindowInsetsCompat;
27+
import androidx.core.view.WindowInsetsControllerCompat;
2328

2429
import com.firebase.ui.auth.AuthUI;
2530
import com.firebase.ui.auth.util.ExtraConstants;
@@ -45,6 +50,9 @@ public class ChooserActivity extends AppCompatActivity {
4550
protected void onCreate(@Nullable Bundle savedInstanceState) {
4651
super.onCreate(savedInstanceState);
4752

53+
// Enable edge-to-edge
54+
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
55+
4856
if (AuthUI.canHandleIntent(getIntent())) {
4957
Intent intent = new Intent(ChooserActivity.this, AuthUiActivity
5058
.class);
@@ -56,6 +64,22 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
5664
mBinding = ActivityChooserBinding.inflate(getLayoutInflater());
5765
setContentView(mBinding.getRoot());
5866

67+
// Set up toolbar
68+
setSupportActionBar(mBinding.toolbar);
69+
getSupportActionBar().setTitle(R.string.app_name);
70+
71+
// Handle the navigation bar padding
72+
ViewCompat.setOnApplyWindowInsetsListener(mBinding.activities, (view, windowInsets) -> {
73+
Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.navigationBars());
74+
view.setPadding(
75+
view.getPaddingLeft(),
76+
view.getPaddingTop(),
77+
view.getPaddingRight(),
78+
insets.bottom
79+
);
80+
return WindowInsetsCompat.CONSUMED;
81+
});
82+
5983
mBinding.activities.setLayoutManager(new LinearLayoutManager(this));
6084
mBinding.activities.setAdapter(new ActivityChooserAdapter());
6185
mBinding.activities.setHasFixedSize(true);

app/src/main/java/com/firebase/uidemo/auth/AnonymousUpgradeActivity.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import androidx.annotation.NonNull;
3030
import androidx.annotation.Nullable;
3131
import androidx.appcompat.app.AppCompatActivity;
32+
import androidx.core.view.WindowCompat;
3233

3334
public class AnonymousUpgradeActivity extends AppCompatActivity
3435
implements ActivityResultCallback<FirebaseAuthUIAuthenticationResult> {
@@ -45,6 +46,10 @@ public class AnonymousUpgradeActivity extends AppCompatActivity
4546
@Override
4647
protected void onCreate(@Nullable Bundle savedInstanceState) {
4748
super.onCreate(savedInstanceState);
49+
50+
// Enable edge-to-edge
51+
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
52+
4853
mBinding = ActivityAnonymousUpgradeBinding.inflate(getLayoutInflater());
4954
setContentView(mBinding.getRoot());
5055

app/src/main/java/com/firebase/uidemo/auth/AuthUiActivity.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import androidx.annotation.StyleRes;
5454
import androidx.appcompat.app.AppCompatActivity;
5555
import androidx.appcompat.app.AppCompatDelegate;
56+
import androidx.core.view.WindowCompat;
5657

5758
public class AuthUiActivity extends AppCompatActivity
5859
implements ActivityResultCallback<FirebaseAuthUIAuthenticationResult> {
@@ -80,6 +81,10 @@ public static Intent createIntent(@NonNull Context context) {
8081
@Override
8182
public void onCreate(@Nullable Bundle savedInstanceState) {
8283
super.onCreate(savedInstanceState);
84+
85+
// Enable edge-to-edge
86+
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
87+
8388
mBinding = AuthUiLayoutBinding.inflate(getLayoutInflater());
8489
setContentView(mBinding.getRoot());
8590

app/src/main/java/com/firebase/uidemo/auth/SignedInActivity.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import androidx.annotation.Nullable;
5151
import androidx.annotation.StringRes;
5252
import androidx.appcompat.app.AppCompatActivity;
53+
import androidx.core.view.WindowCompat;
5354

5455
import static com.firebase.ui.auth.AuthUI.EMAIL_LINK_PROVIDER;
5556

@@ -68,6 +69,9 @@ public static Intent createIntent(@NonNull Context context, @Nullable IdpRespons
6869
public void onCreate(@Nullable Bundle savedInstanceState) {
6970
super.onCreate(savedInstanceState);
7071

72+
// Enable edge-to-edge
73+
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
74+
7175
FirebaseUser currentUser = FirebaseAuth.getInstance().getCurrentUser();
7276
if (currentUser == null) {
7377
startActivity(AuthUiActivity.createIntent(this));

app/src/main/java/com/firebase/uidemo/database/firestore/FirestoreChatActivity.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import androidx.annotation.NonNull;
2525
import androidx.annotation.Nullable;
2626
import androidx.appcompat.app.AppCompatActivity;
27+
import androidx.core.view.WindowCompat;
2728
import androidx.recyclerview.widget.LinearLayoutManager;
2829
import androidx.recyclerview.widget.RecyclerView;
2930

@@ -55,6 +56,10 @@ public class FirestoreChatActivity extends AppCompatActivity
5556
@Override
5657
protected void onCreate(@Nullable Bundle savedInstanceState) {
5758
super.onCreate(savedInstanceState);
59+
60+
// Enable edge-to-edge
61+
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
62+
5863
mBinding = ActivityChatBinding.inflate(getLayoutInflater());
5964
setContentView(mBinding.getRoot());
6065

app/src/main/java/com/firebase/uidemo/database/realtime/RealtimeDbChatActivity.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import androidx.annotation.NonNull;
2525
import androidx.annotation.Nullable;
2626
import androidx.appcompat.app.AppCompatActivity;
27+
import androidx.core.view.WindowCompat;
2728
import androidx.recyclerview.widget.LinearLayoutManager;
2829
import androidx.recyclerview.widget.RecyclerView;
2930

@@ -52,6 +53,10 @@ public class RealtimeDbChatActivity extends AppCompatActivity
5253
@Override
5354
protected void onCreate(@Nullable Bundle savedInstanceState) {
5455
super.onCreate(savedInstanceState);
56+
57+
// Enable edge-to-edge
58+
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
59+
5560
mBinding = ActivityChatBinding.inflate(getLayoutInflater());
5661
setContentView(mBinding.getRoot());
5762

app/src/main/java/com/firebase/uidemo/storage/ImageActivity.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import androidx.annotation.NonNull;
2929
import androidx.annotation.Nullable;
3030
import androidx.appcompat.app.AppCompatActivity;
31+
import androidx.core.view.WindowCompat;
3132
import pub.devrel.easypermissions.AfterPermissionGranted;
3233
import pub.devrel.easypermissions.AppSettingsDialog;
3334
import pub.devrel.easypermissions.EasyPermissions;
@@ -46,6 +47,10 @@ public class ImageActivity extends AppCompatActivity implements EasyPermissions.
4647
@Override
4748
protected void onCreate(@Nullable Bundle savedInstanceState) {
4849
super.onCreate(savedInstanceState);
50+
51+
// Enable edge-to-edge
52+
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
53+
4954
mBinding = ActivityImageBinding.inflate(getLayoutInflater());
5055
setContentView(mBinding.getRoot());
5156

Lines changed: 60 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,72 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
<androidx.coordinatorlayout.widget.CoordinatorLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
34
xmlns:tools="http://schemas.android.com/tools"
45
xmlns:app="http://schemas.android.com/apk/res-auto"
5-
android:id="@+id/root"
66
android:layout_width="match_parent"
77
android:layout_height="match_parent"
8-
android:layout_marginLeft="24dp"
9-
android:layout_marginRight="24dp"
10-
android:layout_marginTop="16dp"
11-
android:layout_marginBottom="16dp"
12-
android:orientation="vertical"
13-
tools:context=".auth.AuthUiActivity">
8+
android:fitsSystemWindows="true">
149

15-
<com.google.android.material.textview.MaterialTextView
16-
style="@style/TextAppearance.MaterialComponents.Headline5"
17-
android:layout_width="wrap_content"
18-
android:layout_height="wrap_content"
19-
android:layout_gravity="center_horizontal"
20-
android:text="@string/title_anonymous_upgrade"
21-
app:drawableTopCompat="@drawable/firebase_auth_120dp" />
22-
23-
<TextView
24-
android:id="@+id/status_text"
10+
<LinearLayout
2511
android:layout_width="match_parent"
26-
android:layout_height="wrap_content"
27-
android:layout_margin="16dp"
28-
android:gravity="center"
29-
android:textIsSelectable="true"
30-
tools:text="This is the status view, sometimes it will have a very long status and other..." />
12+
android:layout_height="match_parent"
13+
android:orientation="vertical"
14+
android:padding="16dp"
15+
android:clipToPadding="false"
16+
android:fitsSystemWindows="true">
17+
18+
<com.google.android.material.textview.MaterialTextView
19+
style="@style/TextAppearance.MaterialComponents.Headline5"
20+
android:layout_width="wrap_content"
21+
android:layout_height="wrap_content"
22+
android:layout_gravity="center_horizontal"
23+
android:text="@string/title_anonymous_upgrade"
24+
app:drawableTopCompat="@drawable/firebase_auth_120dp" />
25+
26+
<TextView
27+
android:id="@+id/status_text"
28+
android:layout_width="match_parent"
29+
android:layout_height="wrap_content"
30+
android:layout_margin="16dp"
31+
android:gravity="center"
32+
android:textIsSelectable="true"
33+
tools:text="This is the status view, sometimes it will have a very long status and other..." />
34+
35+
<Button
36+
android:id="@+id/anon_sign_in"
37+
style="@style/Widget.MaterialComponents.Button"
38+
android:layout_width="200dp"
39+
android:layout_height="wrap_content"
40+
android:layout_gravity="center"
41+
android:text="@string/anonymous_sign_in" />
3142

32-
<Button
33-
android:id="@+id/anon_sign_in"
34-
style="@style/Widget.MaterialComponents.Button"
35-
android:layout_width="200dp"
36-
android:layout_height="wrap_content"
37-
android:layout_gravity="center"
38-
android:text="@string/anonymous_sign_in" />
43+
<Button
44+
android:id="@+id/begin_flow"
45+
style="@style/Widget.MaterialComponents.Button"
46+
android:layout_width="200dp"
47+
android:layout_height="wrap_content"
48+
android:layout_gravity="center"
49+
android:text="@string/launch_auth_ui"
50+
android:enabled="false" />
3951

40-
<Button
41-
android:id="@+id/begin_flow"
42-
style="@style/Widget.MaterialComponents.Button"
43-
android:layout_width="200dp"
44-
android:layout_height="wrap_content"
45-
android:layout_gravity="center"
46-
android:text="@string/launch_auth_ui"
47-
android:enabled="false" />
52+
<Button
53+
android:id="@+id/resolve_merge"
54+
style="@style/Widget.MaterialComponents.Button"
55+
android:layout_width="200dp"
56+
android:layout_height="wrap_content"
57+
android:layout_gravity="center"
58+
android:text="@string/resolve_merge_conflict"
59+
android:enabled="false" />
4860

49-
<Button
50-
android:id="@+id/resolve_merge"
51-
style="@style/Widget.MaterialComponents.Button"
52-
android:layout_width="200dp"
53-
android:layout_height="wrap_content"
54-
android:layout_gravity="center"
55-
android:text="@string/resolve_merge_conflict"
56-
android:enabled="false" />
61+
<Button
62+
android:id="@+id/sign_out"
63+
style="@style/Widget.MaterialComponents.Button"
64+
android:layout_width="200dp"
65+
android:layout_height="wrap_content"
66+
android:layout_gravity="center"
67+
android:text="@string/sign_out"
68+
android:enabled="false" />
5769

58-
<Button
59-
android:id="@+id/sign_out"
60-
style="@style/Widget.MaterialComponents.Button"
61-
android:layout_width="200dp"
62-
android:layout_height="wrap_content"
63-
android:layout_gravity="center"
64-
android:text="@string/sign_out"
65-
android:enabled="false" />
70+
</LinearLayout>
6671

67-
</LinearLayout>
72+
</androidx.coordinatorlayout.widget.CoordinatorLayout>

0 commit comments

Comments
 (0)