Earth-Abundant Thin-Film Devices for Photovoltaic and Electrochemical Applications