Photometric magnetic-activity metrics tested with the Sun: application to Kepler M dwarfs