Skip to content

Commit 5c933b8

Browse files
author
“Akshay
committed
[MOB-9111] - Inbox overlap on Android 35
This fix makes the IterableInboxFragment adjust with window insets allowing full screen apps to take advantage of IterableInboxActivity or IterableInboxFragment. As IterableInboxActivity internally launches IterableFragment, the changes in Fragment is sufficient to make up for cut outs and notches on displays
1 parent 64d89bf commit 5c933b8

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

iterableapi-ui/src/main/java/com/iterable/iterableapi/ui/inbox/IterableInboxFragment.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package com.iterable.iterableapi.ui.inbox;
22

33
import android.content.Intent;
4+
import android.graphics.Insets;
5+
import android.os.Build;
46
import android.os.Bundle;
57
import androidx.annotation.LayoutRes;
68
import androidx.annotation.NonNull;
79
import androidx.annotation.Nullable;
10+
import androidx.core.view.ViewCompat;
811
import androidx.fragment.app.Fragment;
912
import androidx.recyclerview.widget.LinearLayoutManager;
1013
import androidx.recyclerview.widget.RecyclerView;
@@ -184,6 +187,33 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
184187
return relativeLayout;
185188
}
186189

190+
@Override
191+
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
192+
super.onViewCreated(view, savedInstanceState);
193+
// Use ViewCompat to handle insets dynamically
194+
ViewCompat.setOnApplyWindowInsetsListener(view, (v, insets) -> {
195+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
196+
// For API 30 and above: Use WindowInsetsCompat to handle insets
197+
Insets systemBarsInsets = insets.getSystemGestureInsets().toPlatformInsets();
198+
v.setPadding(
199+
0,
200+
systemBarsInsets.top, // Padding for status bar and cutout
201+
0,
202+
systemBarsInsets.bottom // Padding for navigation bar
203+
);
204+
} else {
205+
// For older Android versions: Use legacy methods
206+
v.setPadding(
207+
0,
208+
insets.getSystemWindowInsetTop(), // Padding for status bar and cutout
209+
0,
210+
insets.getSystemWindowInsetBottom() // Padding for navigation bar
211+
);
212+
}
213+
return insets;
214+
});
215+
}
216+
187217
@Override
188218
public void onResume() {
189219
super.onResume();

0 commit comments

Comments
 (0)