Charity is one of the most misunderstood concepts between us and the first century. I think James is addressing the first issue you mentioned, but I don't think it's about charity per se. Charity was a different thing to them than it is to us; we don't have the patronage system they did. We don't understand how radical these statements were:

Matt 6:
1 "Beware of practicing your righteousness before men to be noticed by them; otherwise you have no reward with your Father who is in heaven.
2 "So when you give to the poor, do not sound a trumpet before you, as the hypocrites do in the synagogues and in the streets, so that they may be honored by men. Truly I say to you, they have their reward in full.
3 "But when you give to the poor, do not let your left hand know what your right hand is doing,
4 so that your giving will be in secret; and your Father who sees what is done in secret will reward you.
5 "When you pray, you are not to be like the hypocrites; for they love to stand and pray in the synagogues and on the street corners so that they may be seen by men. Truly I say to you, they have their reward in full.
6 "But you, when you pray, go into your inner room, close your door and pray to your Father who is in secret, and your Father who sees what is done in secret will reward you.


Prayer was seen as the same sort of discussion one would have with an earthly patron: you give me something, I give you my loyalty. So of course it would be done out in the open, with witnesses; otherwise, the patron isn't put on the spot. From the patron's POV, of course charity is given in the open; how else would you impress potential clients? This was all taken for granted until Jesus spoke the words above. For the first time, our relationship to God was seen as a relationship disembedded from politics and family.

So, to say charity "only has meaning if no one knows" is only half the story. Without the concept of a greater reward outside of earthly social interaction, charity only makes sense if it is publicized. They "have their reward in full."