List of usage examples for android.content Context setTheme
public abstract void setTheme(@StyleRes int resid);
From source file:Main.java
/** * Get a color value from a theme attribute. * @param context used for getting the color. * @param attribute theme attribute.// w ww. j av a2 s .com * @param defaultColor default to use. * @return color value */ public static int getThemeColor(Context context, int attribute, int defaultColor) { int themeColor = 0; String packageName = context.getPackageName(); try { Context packageContext = context.createPackageContext(packageName, 0); ApplicationInfo applicationInfo = context.getPackageManager().getApplicationInfo(packageName, 0); packageContext.setTheme(applicationInfo.theme); Resources.Theme theme = packageContext.getTheme(); TypedArray ta = theme.obtainStyledAttributes(new int[] { attribute }); themeColor = ta.getColor(0, defaultColor); ta.recycle(); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } return themeColor; }
From source file:net.reichholf.dreamdroid.DreamDroid.java
public static void setTheme(Context context) { if (!isLightTheme(context)) context.setTheme(R.style.Theme_DreamDroid); }
From source file:com.ichi2.themes.Themes.java
public static void setTheme(Context context) { SharedPreferences prefs = AnkiDroidApp.getSharedPrefs(context.getApplicationContext()); if (prefs.getBoolean("invertedColors", false)) { int theme = Integer.parseInt(prefs.getString("nightTheme", "0")); switch (theme) { case THEME_NIGHT_DARK: context.setTheme(R.style.Theme_Dark_Compat); break; case THEME_NIGHT_BLACK: context.setTheme(R.style.Theme_Black_Compat); break; }/*from www .ja va2s.c o m*/ } else { int theme = Integer.parseInt(prefs.getString("dayTheme", "0")); switch (theme) { case THEME_DAY_LIGHT: context.setTheme(R.style.Theme_Light_Compat); break; case THEME_DAY_PLAIN: context.setTheme(R.style.Theme_Plain_Compat); break; } } }
From source file:com.ichi2.themes.Themes.java
public static void setThemeLegacy(Context context) { SharedPreferences prefs = AnkiDroidApp.getSharedPrefs(context.getApplicationContext()); if (prefs.getBoolean("invertedColors", false)) { int theme = Integer.parseInt(prefs.getString("nightTheme", "0")); switch (theme) { case THEME_NIGHT_DARK: context.setTheme(R.style.LegacyActionBarDark); break; case THEME_NIGHT_BLACK: context.setTheme(R.style.LegacyActionBarBlack); break; }/*from w w w .j a v a2 s.c o m*/ } else { int theme = Integer.parseInt(prefs.getString("dayTheme", "0")); switch (theme) { case THEME_DAY_LIGHT: context.setTheme(R.style.LegacyActionBarLight); break; case THEME_DAY_PLAIN: context.setTheme(R.style.LegacyActionBarPlain); break; } } }
From source file:Main.java
public static void setTheme(boolean dialog, Context context) { int theme = android.R.style.Theme_Black; if (Build.VERSION.SDK_INT >= 11) { theme = 0x0103006b; //-> android.R.Theme_Holo, needed, because build target is only 2.3.1 if (dialog) theme = 0x0103006f; //-> android.R.Theme_Holo_Dialog, needed, because build target is only 2.3.1 } else {//from ww w. j av a 2s. c o m if (dialog) { theme = android.R.style.Theme_Dialog; } } context.setTheme(theme); }
From source file:Utils.GenericUtils.java
public static void showSimpleAlert(Context context, String title, String msg) { context.setTheme(R.style.MenuTheme); new AlertDialog.Builder(context).setTitle(title).setMessage(msg) .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { }//from www . jav a 2s . com }).setIcon(android.R.drawable.ic_dialog_alert).show(); context.setTheme(R.style.ETTheme); }
From source file:Utils.GenericUtils.java
public static void showPlainAlert(Context context, String title, String msg) { context.setTheme(R.style.MenuTheme); new AlertDialog.Builder(context).setTitle(title).setMessage(msg) .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // do nothing }/*from w w w. j a va2 s. co m*/ }).setIcon(android.R.drawable.ic_dialog_alert).show(); context.setTheme(R.style.ETTheme); }
From source file:Utils.GenericUtils.java
public static void showAlert(Context context, String title, String msg) { context.setTheme(R.style.MenuTheme); new AlertDialog.Builder(context).setTitle(title).setMessage(msg) .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // Sync the data, pop up the Sync Server screen. Intent intentSync = new Intent(context, MenuSyncServer.class); context.startActivity(intentSync); Toast.makeText(context, "Servery Sync selected", Toast.LENGTH_SHORT).show(); }/*ww w .j a v a 2 s. co m*/ }).setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // do nothing } }).setIcon(android.R.drawable.ic_dialog_alert).show(); context.setTheme(R.style.ETTheme); }
From source file:com.mci.firstidol.view.ActionSheet.java
public static Builder createBuilder(Context context, FragmentManager fragmentManager) { context.setTheme(R.style.ActionSheetStyleiOS7); return new Builder(context, fragmentManager); }
From source file:com.becapps.easydownloader.utils.Utils.java
public static void themeInit(Context context) { settings = context.getSharedPreferences(PREFS_NAME, 0); String theme = settings.getString("choose_theme", "D"); if (theme.equals("D")) { context.setTheme(R.style.AppThemeDark); } else {/*from w w w. j a v a 2 s . c o m*/ context.setTheme(R.style.AppThemeLight); } }