@Override public void setTheme(int resid) { super.setTheme(PrefStore.getTheme(this)); }
@Override public void setTheme(int resid) { super.setTheme(PrefStore.getTheme(this)); }
public static void setTheme(AppCompatActivity activity) { final int dark = activity.getResources().getColor(R.color.pref_dark); final int light = activity.getResources().getColor(R.color.pref_light); int i = PreferenceHelper.getTheme(); if (i == light) { activity.setTheme(R.style.Light); } else if (i == dark) { activity.setTheme(R.style.Dark); } else { activity.setTheme(R.style.Classic); } } }
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { // !!! Make some modifications Toast.makeText(getApplicationContext(), "Hello World!", Toast.LENGTH_SHORT).show(); final AppCompatDelegate delegate = getDelegate(); delegate.installViewFactory(); delegate.onCreate(savedInstanceState); if (delegate.applyDayNight() && mThemeId != 0) { // If DayNight has been applied, we need to re-apply the theme for // the changes to take effect. On API 23+, we should bypass // setTheme(), which will no-op if the theme ID is identical to the // current theme ID. if (Build.VERSION.SDK_INT >= 23) { onApplyThemeResource(getTheme(), mThemeId, false); } else { setTheme(mThemeId); } } super.onCreate(savedInstanceState); }
/** * Initializes activity-specific stuff. */ public static void onCreateActivity(AppCompatActivity activity, int flags) { onCreate(activity.getApplicationContext(), flags); // XXX for now... flags |= NO_LOCKSCREEN | NO_VISIBILITY_REGISTRY; if((flags & NO_THEME) == 0) activity.setTheme(Theme.get()); activity.requestWindowFeature(Window.FEATURE_ACTION_BAR); if(BuildConfig.DEBUG) { final String lang = Settings.getString(Keys.LANGUAGE); if(lang != null && lang.length() != 0) { final Resources res = activity.getResources(); final Configuration cfg = res.getConfiguration(); if(!lang.equals(cfg.locale.getLanguage())) { cfg.locale = new Locale(lang); res.updateConfiguration(cfg, res.getDisplayMetrics()); Log.i(TAG, "Setting language to '" + lang + "'"); } else Log.d(TAG, "Language '" + lang + "' already set"); } } SystemEventReceiver.registerOnSystemTimeChangeListener(activity); }
public static void applyTheme(AppCompatActivity activity) { activity.setTheme(ThemeManager.getTheme(activity)); Toolbar toolbar = activity.findViewById(R.id.toolbar); toolbar.setBackgroundColor(ThemeManager.getPrimaryColor(activity)); toolbar.setPopupTheme(getPopupMenuTheme(activity)); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { activity.getWindow().setStatusBarColor(ThemeManager.getPrimaryDarkColor(activity)); activity.getWindow().setNavigationBarColor(ThemeManager.getNavigationBarColor(activity)); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Set english as default language if option is enabled if (Utils.getBoolean("forceenglish", false, this)) Utils.setLocale("en_US", this); // Check if darktheme is in use and cache it as boolean if (Utils.DARKTHEME = Utils.getBoolean("darktheme", false, this)) { super.setTheme(getDarkTheme()); getWindow().getDecorView().getRootView().setBackgroundColor(getResources().getColor(R.color.black)); } if (getParentViewId() != 0) setContentView(getParentViewId()); else if (getParentView() != null) setContentView(getParentView()); Toolbar toolbar; if ((toolbar = getToolbar()) != null) { if (Utils.DARKTHEME) toolbar.setPopupTheme(R.style.ThemeOverlay_AppCompat_Dark); try { setSupportActionBar(toolbar); } catch (NoClassDefFoundError e) { Utils.toast(e.getMessage(), this, Toast.LENGTH_LONG); finish(); } } ActionBar actionBar; if ((actionBar = getSupportActionBar()) != null) actionBar.setDisplayHomeAsUpEnabled(getDisplayHomeAsUpEnabled()); setStatusBarColor(); }