Skip to content

Commit 4db6bc5

Browse files
committed
Support Android 15 on new chats screen
1 parent 44ed1e7 commit 4db6bc5

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

app/src/main/java/org/thunderdog/challegram/ui/ContactsController.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,13 +271,25 @@ private boolean canAddContacts () {
271271
return mode == MODE_NEW_CHAT || mode == MODE_CALL;
272272
}
273273

274+
@Override
275+
public boolean supportsBottomInset () {
276+
return true;
277+
}
278+
279+
@Override
280+
protected void onBottomInsetChanged (int extraBottomInset, int extraBottomInsetWithoutIme, boolean isImeInset) {
281+
super.onBottomInsetChanged(extraBottomInset, extraBottomInsetWithoutIme, isImeInset);
282+
Views.applyBottomInset(recyclerView, extraBottomInset);
283+
}
284+
274285
@SuppressWarnings("ResourceType")
275286
@Override
276287
protected View onCreateView (Context context) {
277288
contentView = new FrameLayoutFix(context);
278289
ViewSupport.setThemedBackground(contentView, ColorId.filling, this);
279290

280291
recyclerView = new SectionedRecyclerView(context);
292+
Views.applyBottomInset(recyclerView, extraBottomInset);
281293
recyclerView.setSectionedAdapter(adapter = new ContactsAdapter(recyclerView, this));
282294
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
283295
@Override

app/src/main/java/org/thunderdog/challegram/widget/SectionedRecyclerView.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,17 @@ private void layoutSections () {
196196
private final int scrollbarPadding = Screen.dp(9f);
197197
private final int scrollbarMinHeight = Screen.dp(32f);
198198

199+
private int getScrollBarViewportHeight () {
200+
return getMeasuredHeight() - getPaddingBottom();
201+
}
202+
199203
private void layoutScrollbar () {
200204
if (adapter == null || adapter.getSectionCount() == 0) {
201205
scrollbarEnabled = false;
202206
return;
203207
}
204208

205-
final int totalHeight = getMeasuredHeight();
209+
final int totalHeight = getScrollBarViewportHeight();
206210
if (totalHeight <= 0) {
207211
scrollbarEnabled = false;
208212
return;
@@ -267,7 +271,7 @@ private float calculateScrollbarFactor () {
267271
}
268272
}
269273

270-
return (float) scrollY / (float) (totalScrollY - getMeasuredHeight());
274+
return (float) scrollY / (float) (totalScrollY - getScrollBarViewportHeight());
271275
}
272276

273277
private final RectF bubbleRect = new RectF();
@@ -340,7 +344,7 @@ private void closeScrollbar (boolean animated) {
340344
private void moveScrollbar (float y) {
341345
float dy = y - lastScrollY;
342346
lastScrollY = y;
343-
float scale = (float) totalScrollY / (float) getMeasuredHeight();
347+
float scale = (float) totalScrollY / (float) getScrollBarViewportHeight();
344348
int by = (int) (dy * scale);
345349
if (by != 0) {
346350
scrollBy(0, by);

0 commit comments

Comments
 (0)