Do not use View.getLayoutDirection().

This value doesn't populate until after the first layout pass. Instead,
it appears to be safer to just read it from the Configuration.
This commit is contained in:
Greyson Parrelli
2021-02-11 10:41:40 -05:00
committed by GitHub
parent 432a732e7c
commit 2a3f85008b
13 changed files with 68 additions and 35 deletions

View File

@@ -16,6 +16,7 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
import com.google.android.material.appbar.AppBarLayout;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.util.ViewUtil;
import java.lang.ref.WeakReference;
@@ -92,7 +93,7 @@ public final class RecipientSettingsCoordinatorLayoutBehavior extends Coordinato
}
private static int getStart(@NonNull CoordinatorLayout parent, @NonNull Rect rect) {
return parent.getLayoutDirection() == View.LAYOUT_DIRECTION_LTR ? rect.left : rect.right;
return ViewUtil.isLtr(parent) ? rect.left : rect.right;
}
private static final class ViewReference {

View File

@@ -54,6 +54,7 @@ import org.thoughtcrime.securesms.util.DateUtils;
import org.thoughtcrime.securesms.util.LifecycleCursorWrapper;
import org.thoughtcrime.securesms.util.ServiceUtil;
import org.thoughtcrime.securesms.util.Util;
import org.thoughtcrime.securesms.util.ViewUtil;
import org.thoughtcrime.securesms.wallpaper.ChatWallpaperActivity;
import java.util.Locale;
@@ -351,7 +352,7 @@ public class ManageRecipientFragment extends LoggingFragment {
threadPhotoRailView.setListener(mediaRecord ->
startActivityForResult(MediaPreviewActivity.intentFromMediaRecord(requireContext(),
mediaRecord,
ViewCompat.getLayoutDirection(threadPhotoRailView) == ViewCompat.LAYOUT_DIRECTION_LTR),
ViewUtil.isLtr(threadPhotoRailView)),
REQUEST_CODE_RETURN_FROM_MEDIA));
}