Twenty eight libraries are to stay open across Birmingham after a campaign led by activists, children and celebrity authors.