Fix issue where reaction shade is offset in chat bubbles.

Fixes #10843
This commit is contained in:
Greyson Parrelli 2021-02-01 10:23:22 -05:00
parent e9e2846532
commit 0b7c22886d
3 changed files with 16 additions and 2 deletions

View file

@ -23,6 +23,7 @@ import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.graphics.Rect;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
@ -309,7 +310,9 @@ public class ConversationFragment extends LoggingFragment {
list.setTranslationY(Math.min(0, -chTop));
list.setOverScrollMode(RecyclerView.OVER_SCROLL_NEVER);
}
listener.onListVerticalTranslationChanged(list.getTranslationY());
int offset = WindowUtil.isStatusBarPresent(requireActivity().getWindow()) ? ViewUtil.getStatusBarHeight(list) : 0;
listener.onListVerticalTranslationChanged(list.getTranslationY() - offset);
}
@Override

View file

@ -141,7 +141,7 @@ public final class ConversationReactionOverlay extends RelativeLayout {
}
public void setListVerticalTranslation(float translationY) {
maskView.setTargetParentTranslationY(translationY - ViewUtil.getStatusBarHeight(maskView));
maskView.setTargetParentTranslationY(translationY);
}
public void show(@NonNull Activity activity,

View file

@ -1,6 +1,7 @@
package org.thoughtcrime.securesms.util;
import android.app.Activity;
import android.graphics.Rect;
import android.os.Build;
import android.view.View;
import android.view.Window;
@ -62,6 +63,16 @@ public final class WindowUtil {
window.setStatusBarColor(color);
}
/**
* A sort of roundabout way of determining if the status bar is present by seeing if there's a
* vertical window offset.
*/
public static boolean isStatusBarPresent(@NonNull Window window) {
Rect rectangle = new Rect();
window.getDecorView().getWindowVisibleDisplayFrame(rectangle);
return rectangle.top > 0;
}
private static void clearSystemUiFlags(@NonNull Window window, int flags) {
View view = window.getDecorView();
int uiFlags = view.getSystemUiVisibility();