List of usage examples for android.content Context setTheme
public abstract void setTheme(@StyleRes int resid);
From source file:com.galgame.august.MainDrawerActivity.java
public static void isNight(Context context) { // ??/*from w ww .ja va 2s . co m*/ boolean isNight = SPUtils.isNight(context); if (isNight) { // super.onCreate()? context.setTheme(R.style.night); } else { context.setTheme(R.style.light); } }
From source file:bander.notepad.Notepad.java
/** * Sets the theme for the dialogs./* ww w . ja v a2 s . co m*/ * * @param context */ public static void setDialogThemeFromPreferences(Context context) { SharedPreferences mSettings = PreferenceManager.getDefaultSharedPreferences(context); String color = mSettings.getString("colorScheme", "Dark"); String theme = mSettings.getString("themeType", "0"); switch (Integer.parseInt(theme)) { // Holo theme case 1: case 2: if (color.equals("Light") | color.equals("Mixed")) { context.setTheme(android.R.style.Theme_Holo_Light_Dialog); } else { context.setTheme(android.R.style.Theme_Holo_Dialog); } break; // Device Default case 3: if (color.equals("Light") | color.equals("Mixed")) { context.setTheme(android.R.style.Theme_DeviceDefault_Light_Dialog); } else { context.setTheme(android.R.style.Theme_DeviceDefault_Dialog); } break; // Gingerbread case 4: context.setTheme(android.R.style.Theme_Dialog); break; // fallback for error. default: if (color.equals("Light") | color.equals("Mixed")) { context.setTheme(android.R.style.Theme_Holo_Light_Dialog); } else { context.setTheme(android.R.style.Theme_Holo_Dialog); } break; } }
From source file:com.vuze.android.remote.AndroidUtilsUI.java
public static void onCreate(Context context) { // AppThemeDark is LeanBack, and LeanBack is API 17 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { boolean isTV = AndroidUtils.isTV(); if (ALWAYS_DARK || isTV) { context.setTheme(R.style.AppThemeDark); if (!isTV && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { Window window = ((AppCompatActivity) context).getWindow(); window.clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_OVERSCAN); }//from w w w .j a v a 2 s. c om } } }
From source file:bander.notepad.Notepad.java
/** * Sets the normal theme.//from w w w. j a v a2 s .c o m * * @param context */ public static void setThemeFromPreferences(Context context) { SharedPreferences mSettings = PreferenceManager.getDefaultSharedPreferences(context); String color = mSettings.getString("colorScheme", "Dark"); String theme = mSettings.getString("themeType", "0"); switch (Integer.parseInt(theme)) { // Lollipop theme case 0: // Do nothing break; // KitKat-styled theme case 1: switch (color) { case "Light": context.setTheme(R.style.Theme_KitKat_Light); break; case "Mixed": context.setTheme(R.style.Theme_KitKat_Light_DarkActionBar); break; default: context.setTheme(R.style.Theme_KitKat_Dark); break; } break; // Default Holo theme case 2: switch (color) { case "Light": context.setTheme(android.R.style.Theme_Holo_Light); break; case "Mixed": context.setTheme(android.R.style.Theme_Holo_Light_DarkActionBar); break; default: context.setTheme(android.R.style.Theme_Holo); break; } break; // Device Default case 3: switch (color) { case "Light": context.setTheme(android.R.style.Theme_DeviceDefault_Light); break; case "Mixed": context.setTheme(android.R.style.Theme_DeviceDefault_Light_DarkActionBar); break; default: context.setTheme(android.R.style.Theme_DeviceDefault); break; } break; // Gingerbread case 4: switch (color) { case "Light": context.setTheme(android.R.style.Theme_Light); break; case "Mixed": context.setTheme(R.style.Theme_WithActionBar); break; default: context.setTheme(R.style.Theme); break; } break; // fallback for error. default: switch (color) { case "Light": context.setTheme(R.style.Theme_KitKat_Light); break; case "Mixed": context.setTheme(R.style.Theme_KitKat_Light_DarkActionBar); break; default: context.setTheme(R.style.Theme_KitKat_Dark); break; } break; } }
From source file:dentex.youtube.downloader.utils.Utils.java
public static void themeInit(Context context) { String theme = YTD.settings.getString("choose_theme", "D"); if (theme.equals("D")) { context.setTheme(R.style.AppThemeDark); } else {/* www . j a v a 2 s. c o m*/ context.setTheme(R.style.AppThemeLight); } }
From source file:com.desno365.mods.DesnoUtils.java
public static void setSavedTheme(Context context) { SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context); String theme = sharedPrefs.getString("selected_theme", "0"); try {// ww w .j av a2 s .c o m int themeNumber = Integer.parseInt(theme); switch (themeNumber) { case 0: context.setTheme(R.style.AppTheme_Brown); break; case 1: context.setTheme(R.style.AppTheme_Green); break; case 2: context.setTheme(R.style.AppTheme_Red); break; case 3: context.setTheme(R.style.AppTheme_Blue); break; default: context.setTheme(R.style.AppTheme_Brown); break; } } catch (NumberFormatException e) { Log.e(TAG, "NumberFormatExcpetion in setSavedTheme() with " + theme, e); context.setTheme(R.style.AppTheme_Brown); } }
From source file:com.zhengde163.netguard.Util.java
public static void setTheme(Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); // context.setTheme(dark ? R.style.AppThemeBlueDark : R.style.AppThemeBlue); context.setTheme(R.style.AppThemeTeal); }
From source file:android_network.hetnet.vpn_service.Util.java
public static void setTheme(Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); boolean dark = prefs.getBoolean("dark_theme", false); String theme = prefs.getString("theme", "teal"); if (theme.equals("teal")) context.setTheme(dark ? R.style.AppThemeTealDark : R.style.AppThemeTeal); else if (theme.equals("blue")) context.setTheme(dark ? R.style.AppThemeBlueDark : R.style.AppThemeBlue); else if (theme.equals("purple")) context.setTheme(dark ? R.style.AppThemePurpleDark : R.style.AppThemePurple); else if (theme.equals("amber")) context.setTheme(dark ? R.style.AppThemeAmberDark : R.style.AppThemeAmber); else if (theme.equals("orange")) context.setTheme(dark ? R.style.AppThemeOrangeDark : R.style.AppThemeOrange); else if (theme.equals("green")) context.setTheme(dark ? R.style.AppThemeGreenDark : R.style.AppThemeGreen); if (context instanceof Activity && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { TypedValue tv = new TypedValue(); context.getTheme().resolveAttribute(R.attr.colorPrimary, tv, true); ((Activity) context).setTaskDescription(new ActivityManager.TaskDescription(null, null, tv.data)); }/*from www . j a v a2 s . co m*/ }
From source file:com.master.metehan.filtereagle.Util.java
public static void setTheme(Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); boolean dark = prefs.getBoolean("dark_theme", false); String theme = prefs.getString("theme", "teal"); if (theme.equals("teal")) context.setTheme(dark ? R.style.AppThemeTealDark : R.style.AppThemeTeal); else if (theme.equals("blue")) context.setTheme(dark ? R.style.AppThemeBlueDark : R.style.AppThemeBlue); else if (theme.equals("purple")) context.setTheme(dark ? R.style.AppThemePurpleDark : R.style.AppThemePurple); else if (theme.equals("amber")) context.setTheme(dark ? R.style.AppThemeAmberDark : R.style.AppThemeAmber); else if (theme.equals("orange")) context.setTheme(dark ? R.style.AppThemeOrangeDark : R.style.AppThemeOrange); else if (theme.equals("green")) context.setTheme(dark ? R.style.AppThemeGreenDark : R.style.AppThemeGreen); }
From source file:eu.faircode.netguard.Util.java
public static void setTheme(Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); boolean dark = prefs.getBoolean("dark_theme", false); String theme = prefs.getString("theme", "teal"); if (theme.equals("teal")) context.setTheme(dark ? R.style.AppThemeTealDark : R.style.AppThemeTeal); else if (theme.equals("blue")) context.setTheme(dark ? R.style.AppThemeBlueDark : R.style.AppThemeBlue); else if (theme.equals("purple")) context.setTheme(dark ? R.style.AppThemePurpleDark : R.style.AppThemePurple); else if (theme.equals("amber")) context.setTheme(dark ? R.style.AppThemeAmberDark : R.style.AppThemeAmber); else if (theme.equals("orange")) context.setTheme(dark ? R.style.AppThemeOrangeDark : R.style.AppThemeOrange); else if (theme.equals("green")) context.setTheme(dark ? R.style.AppThemeGreenDark : R.style.AppThemeGreen); if (context instanceof Activity && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) setTaskColor(context);/* w ww. j ava 2s . c om*/ }