/** Set the theme of the Activity, and restart it by creating a new Activity of the same type. */ public static void changeToTheme(Activity activity, EGCThemeEnum themeEnum) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity); SharedPreferences.Editor editor = prefs.edit(); editor.putString(THEME_KEY, themeEnum.toString()); editor.apply(); refreshActivity(activity); }
/** Set the theme of the activity, according to the configuration. */ public static void onActivityCreateSetTheme(Activity activity) { String themeString = getCurrentTheme(activity); switch (EGCThemeEnum.valueOf(themeString)) { default: case DEFAULT_THEME: activity.setTheme(R.style.DefaultTheme); break; case BLUE_THEME: activity.setTheme(R.style.BlueTheme); break; case PURPLE_THEME: activity.setTheme(R.style.PurpleTheme); break; case GREEN_THEME: activity.setTheme(R.style.GreenTheme); break; case RED_THEME: activity.setTheme(R.style.RedTheme); break; } }