From f13234371d7fa2799cd287551331e8f455e33fd1 Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Fri, 22 Jul 2016 21:24:21 -0500 Subject: [PATCH] Use themed layout inflater for task list fragment --- .../todoroo/astrid/activity/TaskListActivity.java | 1 - .../todoroo/astrid/activity/TaskListFragment.java | 12 ++++++++---- src/main/java/org/tasks/themes/Theme.java | 4 ++++ src/main/java/org/tasks/themes/ThemeColor.java | 4 ---- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/todoroo/astrid/activity/TaskListActivity.java b/src/main/java/com/todoroo/astrid/activity/TaskListActivity.java index f320b311a..0e40e2f36 100644 --- a/src/main/java/com/todoroo/astrid/activity/TaskListActivity.java +++ b/src/main/java/com/todoroo/astrid/activity/TaskListActivity.java @@ -190,7 +190,6 @@ public class TaskListActivity extends InjectingAppCompatActivity implements ? themeCache.getThemeColor(filter.tint) : theme.getThemeColor(); themeColor.applyStatusBarColor(drawerLayout); - themeColor.applyStyle(this); themeColor.applyTaskDescription(this, filter.listingTitle); FragmentManager fragmentManager = getSupportFragmentManager(); diff --git a/src/main/java/com/todoroo/astrid/activity/TaskListFragment.java b/src/main/java/com/todoroo/astrid/activity/TaskListFragment.java index 97317039c..102ce79ce 100644 --- a/src/main/java/com/todoroo/astrid/activity/TaskListFragment.java +++ b/src/main/java/com/todoroo/astrid/activity/TaskListFragment.java @@ -80,6 +80,7 @@ import org.tasks.injection.FragmentComponent; import org.tasks.injection.InjectingListFragment; import org.tasks.notifications.NotificationManager; import org.tasks.preferences.Preferences; +import org.tasks.themes.Theme; import org.tasks.themes.ThemeCache; import org.tasks.ui.CheckBoxes; import org.tasks.ui.MenuColorizer; @@ -146,6 +147,7 @@ public class TaskListFragment extends InjectingListFragment implements @Inject Broadcaster broadcaster; @Inject TagService tagService; @Inject ThemeCache themeCache; + @Inject Theme theme; @BindView(R.id.swipe_layout) SwipeRefreshLayout swipeRefreshLayout; @BindView(R.id.swipe_layout_empty) SwipeRefreshLayout emptyView; @@ -240,10 +242,12 @@ public class TaskListFragment extends InjectingListFragment implements } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - View parent = inflater.inflate(R.layout.fragment_task_list, container, false); - ((ViewGroup) parent.findViewById(R.id.task_list_body)).addView(inflater.inflate(getListBody(), null), 0); + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + LayoutInflater themedLayoutInflater = + ((filter.tint >= 0) ? theme.withColor(themeCache.getThemeColor(filter.tint)) : theme) + .getLayoutInflater(context); + View parent = themedLayoutInflater.inflate(R.layout.fragment_task_list, container, false); + ((ViewGroup) parent.findViewById(R.id.task_list_body)).addView(themedLayoutInflater.inflate(getListBody(), null), 0); ButterKnife.bind(this, parent); setupRefresh(swipeRefreshLayout); setupRefresh(emptyView); diff --git a/src/main/java/org/tasks/themes/Theme.java b/src/main/java/org/tasks/themes/Theme.java index 54c7db8fa..b60cacf35 100644 --- a/src/main/java/org/tasks/themes/Theme.java +++ b/src/main/java/org/tasks/themes/Theme.java @@ -72,4 +72,8 @@ public class Theme { applyToContext(wrapper); return wrapper; } + + public Theme withColor(ThemeColor themeColor) { + return new Theme(themeBase, themeColor, themeAccent); + } } diff --git a/src/main/java/org/tasks/themes/ThemeColor.java b/src/main/java/org/tasks/themes/ThemeColor.java index 2579cf4e2..0eca50062 100644 --- a/src/main/java/org/tasks/themes/ThemeColor.java +++ b/src/main/java/org/tasks/themes/ThemeColor.java @@ -85,10 +85,6 @@ public class ThemeColor { : flag & ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; } - public void applyStyle(Context context) { - applyStyle(context.getTheme()); - } - public void applyStyle(Resources.Theme theme) { theme.applyStyle(style, true); }