@Override public void setTheme(int resid) { mBase.setTheme(resid); }
/** * Apply the selected theme (on NewPipe settings) in the context, * themed according with the styles defined for the service . * * @param context context that the theme will be applied * @param serviceId the theme will be styled to the service with this id, * pass -1 to get the default style */ public static void setTheme(Context context, int serviceId) { context.setTheme(getThemeForService(context, serviceId)); }
/** * 设置当前主题 * @param ctx 上下文 * @param Style_Day 白天 * @param Style_Night 夜间 */ public static void setTheme(Context ctx,int Style_Day,int Style_Night){ if(ChangeModeHelper.getChangeMode(ctx) == ChangeModeHelper.MODE_DAY){ ctx.setTheme(Style_Day); }else if(ChangeModeHelper.getChangeMode(ctx) == ChangeModeHelper.MODE_NIGHT){ ctx.setTheme(Style_Night); } }
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; } } 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; } } }
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; } } 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; } } }
public static void apply(Context context, boolean dialogTheme, boolean isTranslucent) { ThemePreference.ThemeSpec themeSpec = getTheme(context, isTranslucent); context.setTheme(themeSpec.theme); if (themeSpec.themeOverrides >= 0) { context.getTheme().applyStyle(themeSpec.themeOverrides, true); } if (dialogTheme) { context.setTheme(AppUtils.getThemedResId(context, R.attr.alertDialogTheme)); } }
@Test public void shouldFindInheritedAndroidAttributeInTheme() throws Exception { context.setTheme(R.style.Theme_AnotherTheme); Resources.Theme theme1 = context.getTheme(); TypedArray typedArray = theme1.obtainStyledAttributes(new int[] {R.attr.typeface, android.R.attr.buttonStyle}); assertThat(typedArray.hasValue(0)).isTrue(); // animalStyle assertThat(typedArray.hasValue(1)).isTrue(); // layout_height }
/** * Used by plugin for Theme * 插件使用插件主题 */ public static void setTheme(Context pluginContext, int resId) { if (pluginContext instanceof PluginContextTheme) { ((PluginContextTheme)pluginContext).mTheme = null; pluginContext.setTheme(resId); } }
@Override public void setTheme(int resid) { mBase.setTheme(resid); }
mComponentContext.getAndroidContext().setTheme(0);
SharedPreferences themePrefs = getActivity().getBaseContext().getSharedPreferences("THEME", 0); if (themePrefs.getBoolean("isDark", false)) getContext().setTheme(R.style.PrefsThemeDark); else getActivity().setTheme(R.style.PrefsTheme);
context.setTheme(R.style.BlueTheme); PreUtils.setCurrentTheme(context, Theme.Blue); PreUtils.putString(context, Constants.PRIMARYCOLOR, "#2196F3"); PreUtils.putString(context, Constants.TITLECOLOR, "#ffffff"); } else if (selectedColor == context.getResources().getColor(R.color.colorRedPrimary)) { context.setTheme(R.style.RedTheme); PreUtils.setCurrentTheme(context, Theme.Red); PreUtils.putString(context, Constants.PRIMARYCOLOR, "#F44336"); PreUtils.putString(context, Constants.TITLECOLOR, "#ffffff"); } else if (selectedColor == context.getResources().getColor(R.color.colorBrownPrimary)) { context.setTheme(R.style.BrownTheme); PreUtils.setCurrentTheme(context, Theme.Brown); PreUtils.putString(context, Constants.PRIMARYCOLOR, "#795548"); PreUtils.putString(context, Constants.TITLECOLOR, "#ffffff"); } else if (selectedColor == context.getResources().getColor(R.color.colorGreenPrimary)) { context.setTheme(R.style.GreenTheme); PreUtils.setCurrentTheme(context, Theme.Green); PreUtils.putString(context, Constants.PRIMARYCOLOR, "#4CAF50"); PreUtils.putString(context, Constants.TITLECOLOR, "#ffffff"); } else if (selectedColor == context.getResources().getColor(R.color.colorPurplePrimary)) { context.setTheme(R.style.PurpleTheme); PreUtils.setCurrentTheme(context, Theme.Purple); PreUtils.putString(context, Constants.PRIMARYCOLOR, "#9c27b0"); PreUtils.putString(context, Constants.TITLECOLOR, "#ffffff"); } else if (selectedColor == context.getResources().getColor(R.color.colorTealPrimary)) { context.setTheme(R.style.TealTheme); PreUtils.setCurrentTheme(context, Theme.Teal); PreUtils.putString(context, Constants.PRIMARYCOLOR, "#009688"); PreUtils.putString(context, Constants.TITLECOLOR, "#ffffff");
pluginContext.setTheme(pluginAppTheme);
public class Application extends android.app.Application { public static Context AppContext = null; @Override public void onCreate() { super.onCreate(); AppContext = getApplicationContext(); // You can use this line to solve styling problems // because Manifest android:theme is not working AppContext.setTheme(R.style.AppTheme); } }
Context context = getInstrumentation().getTargetContext(); context.setTheme(R.style.Theme_AppCompat); mActivity = launchActivity(context.getPackageName(), MyActivity.class, null); getInstrumentation().waitForIdleSync(); // YOUR TESTS // assertNotNull("The activity cannot be null.", mActivity); sendKeys(KeyEvent.KEYCODE_BACK); mActivity.finish();
public static void applyTheme(Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); if (prefs.getString(PREFERENCE_APP_THEME, "").equals("Dark")) { context.setTheme(R.style.AppTheme_Dark); } }
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { //get the parent activity context and set it's theme again. Context ctx = getActivity(); ctx.setTheme(android.R.style.Theme_Holo_Light); AlertDialog.Builder builder = new AlertDialog.Builder(ctx); LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.your_dialog_layout, null, false); builder.setView(view); //your other code for the dialog // return builder.create();
/** * Calls context.setTheme() with given theme. * Will automatically swap the theme with an alternative * version if the user requested us to use it */ final public static void setTheme(Context context, int theme) { context.setTheme(getThemeResource(context, theme)); }
/** * 设置当前主题 * @param ctx 上下文 * @param Style_Day 白天 * @param Style_Night 夜间 */ public static void setTheme(Context ctx, int Style_Day, int Style_Night){ if(ChangeModeHelper.getChangeMode(ctx) == ChangeModeHelper.MODE_DAY){ ctx.setTheme(Style_Day); }else if(ChangeModeHelper.getChangeMode(ctx) == ChangeModeHelper.MODE_NIGHT){ ctx.setTheme(Style_Night); } }
public void onDataSetChanged() { context.setTheme(themeNameToResId(getSettings().getEntryTheme())); if (getSettings().getShowDayHeaders()) mWidgetEntries = addDayHeaders(getEventEntries()); else mWidgetEntries = getEventEntries(); }