Add ThemeManager.applyThemeToContext

pull/413/head
Alex Baker 8 years ago
parent 852da6943d
commit 255e015a3c

@ -442,8 +442,7 @@ public class RepeatControlSet extends TaskEditControlFragment {
}
ContextThemeWrapper wrapper = new ContextThemeWrapper(getActivity(), themeManager.getDialogThemeResId());
wrapper.getTheme().applyStyle(themeManager.getColorTheme().getResId(), true);
wrapper.getTheme().applyStyle(themeManager.getAccentTheme().getResId(), true);
themeManager.applyThemeToContext(wrapper);
new NumberPickerDialog(wrapper, new OnNumberPickedListener() {
@Override
public void onNumberPicked(int number) {

@ -70,8 +70,7 @@ public class TimeDurationControlSet implements OnNNumberPickedListener, View.OnC
public void onClick(View v) {
if(dialog == null) {
ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(context, themeManager.getDialogThemeResId());
contextThemeWrapper.getTheme().applyStyle(themeManager.getColorTheme().getResId(), true);
contextThemeWrapper.getTheme().applyStyle(themeManager.getAccentTheme().getResId(), true);
themeManager.applyThemeToContext(contextThemeWrapper);
dialog = new NNumberPickerDialog(contextThemeWrapper, this,
context.getResources().getString(R.string.DLG_hour_minutes),
new int[] {0, 0}, new int[] {1, 5}, new int[] {0, 0},

@ -52,9 +52,7 @@ public class DialogBuilder {
private ContextThemeWrapper buildDialogWrapper() {
ContextThemeWrapper wrapper = new ContextThemeWrapper(activity, themeManager.getBaseTheme().getDialogThemeResId());
Resources.Theme theme = wrapper.getTheme();
theme.applyStyle(themeManager.getColorTheme().getResId(), true);
theme.applyStyle(themeManager.getAccentTheme().getResId(), true);
themeManager.applyThemeToContext(wrapper);
return wrapper;
}
}

@ -1,7 +1,6 @@
package org.tasks.preferences;
import android.app.Activity;
import android.content.res.Resources;
import android.graphics.PixelFormat;
import javax.inject.Inject;
@ -24,14 +23,12 @@ public class ThemeApplicator {
}
public void applyTheme() {
applyTheme(themeManager.getBaseTheme(), themeManager.getColorTheme(), themeManager.getAccentTheme());
applyTheme(themeManager.getBaseTheme());
}
private void applyTheme(Theme theme, Theme color, Theme accent) {
private void applyTheme(Theme theme) {
activity.setTheme(theme.getResId());
Resources.Theme activityTheme = activity.getTheme();
activityTheme.applyStyle(color.getResId(), true);
activityTheme.applyStyle(accent.getResId(), true);
themeManager.applyThemeToContext(activity);
activity.getWindow().setFormat(PixelFormat.RGBA_8888);
}

@ -36,10 +36,14 @@ public class ThemeManager {
public LayoutInflater getThemedLayoutInflater() {
ContextThemeWrapper wrapper = new ContextThemeWrapper(context, getBaseTheme().getResId());
Resources.Theme theme = wrapper.getTheme();
applyThemeToContext(wrapper);
return (LayoutInflater) wrapper.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
public void applyThemeToContext(Context context) {
Resources.Theme theme = context.getTheme();
theme.applyStyle(getColorTheme().getResId(), true);
theme.applyStyle(getAccentTheme().getResId(), true);
return (LayoutInflater) wrapper.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
public Theme getBaseTheme() {

Loading…
Cancel
Save