Tim Paine has resigned from the Australia Test captaincy due to explicit text messages he sent in 2017.