code: static boolean isRtl(Context context) {
      return Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1
          && context.getResources().getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
    }
docs: Check if layout direction is RTL
  
  @param context the current context
  @return {@code true} if the layout direction is right-to-left