Apply tag color to action and status bar

pull/413/head
Alex Baker 9 years ago
parent ff5c7f7513
commit 3aa3ad3db1

@ -42,6 +42,7 @@ import org.tasks.injection.ActivityComponent;
import org.tasks.injection.ThemedInjectingAppCompatActivity;
import org.tasks.preferences.Preferences;
import org.tasks.themes.ThemeCache;
import org.tasks.themes.ThemeColor;
import org.tasks.ui.MenuColorizer;
import javax.inject.Inject;
@ -76,6 +77,7 @@ public class TagSettingsActivity extends ThemedInjectingAppCompatActivity implem
@Inject Preferences preferences;
@Inject ThemeCache themeCache;
@Inject PurchaseHelper purchaseHelper;
@Inject ThemeColor themeColor;
@BindView(R.id.tag_name) EditText tagName;
@BindView(R.id.toolbar) Toolbar toolbar;
@ -292,9 +294,15 @@ public class TagSettingsActivity extends ThemedInjectingAppCompatActivity implem
private void updateTheme() {
if (selectedTheme < 0) {
themeName.setText(R.string.none);
toolbar.setBackgroundColor(themeColor.getPrimaryColor());
themeColor.applyStatusBarColor(this);
clear.setVisibility(View.GONE);
} else {
themeName.setText(themeCache.getThemeColor(selectedTheme).getName());
ThemeColor themeColor = themeCache.getThemeColor(selectedTheme);
toolbar.setBackgroundColor(themeColor.getPrimaryColor());
themeColor.applyStatusBarColor(this);
themeName.setText(themeColor.getName());
clear.setVisibility(View.VISIBLE);
}
}

@ -17,7 +17,6 @@ import com.todoroo.astrid.activity.TaskListFragment;
import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.api.TagFilter;
import com.todoroo.astrid.core.BuiltInFilterExposer;
import com.todoroo.astrid.dao.TagDataDao;
import com.todoroo.astrid.data.TagData;
import com.todoroo.astrid.tags.TagFilterExposer;

@ -53,6 +53,7 @@ import org.tasks.preferences.DefaultFilterProvider;
import org.tasks.preferences.Preferences;
import org.tasks.receivers.RepeatConfirmationReceiver;
import org.tasks.themes.Theme;
import org.tasks.themes.ThemeCache;
import org.tasks.ui.EmptyTaskEditFragment;
import org.tasks.ui.NavigationDrawerFragment;
import org.tasks.ui.PriorityControlSet;
@ -62,6 +63,8 @@ import java.util.List;
import javax.inject.Inject;
import butterknife.BindView;
import butterknife.ButterKnife;
import timber.log.Timber;
import static com.todoroo.astrid.activity.TaskEditFragment.newTaskEditFragment;
@ -89,6 +92,9 @@ public class TaskListActivity extends InjectingAppCompatActivity implements
@Inject TagDataDao tagDataDao;
@Inject Theme theme;
@Inject Broadcaster broadcaster;
@Inject ThemeCache themeCache;
@BindView(R.id.drawer_layout) DrawerLayout drawerLayout;
public static final int REQUEST_UPGRADE = 505;
@ -114,8 +120,9 @@ public class TaskListActivity extends InjectingAppCompatActivity implements
setContentView(R.layout.task_list_activity);
ButterKnife.bind(this);
navigationDrawer = getNavigationDrawerFragment();
DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
navigationDrawer.setUp(drawerLayout);
handleIntent();
@ -180,7 +187,13 @@ public class TaskListActivity extends InjectingAppCompatActivity implements
.replace(isDoublePaneLayout() ? R.id.master_dual : R.id.single_pane, taskListFragment, TaskListFragment.TAG_TASKLIST_FRAGMENT)
.addToBackStack(TaskListFragment.TAG_TASKLIST_FRAGMENT)
.commit();
theme.applyTaskDescription(this, taskListFragment.filter.listingTitle);
Filter filter = taskListFragment.filter;
if (filter.tint >= 0) {
themeCache.getThemeColor(filter.tint).applyStatusBarColor(drawerLayout);
} else {
theme.getThemeColor().applyStatusBarColor(drawerLayout);
}
theme.applyTaskDescription(this, filter.listingTitle);
}
private void loadTaskEditFragment(boolean onCreate, TaskEditFragment taskEditFragment, List<TaskEditControlFragment> taskEditControlFragments) {

@ -73,14 +73,15 @@ import com.todoroo.astrid.voice.VoiceInputAssistant;
import org.tasks.Broadcaster;
import org.tasks.R;
import org.tasks.dialogs.SortDialog;
import org.tasks.dialogs.DialogBuilder;
import org.tasks.dialogs.SortDialog;
import org.tasks.injection.ForActivity;
import org.tasks.injection.FragmentComponent;
import org.tasks.injection.InjectingListFragment;
import org.tasks.notifications.NotificationManager;
import org.tasks.preferences.Preferences;
import org.tasks.themes.ThemeCache;
import org.tasks.themes.ThemeColor;
import org.tasks.ui.CheckBoxes;
import org.tasks.ui.MenuColorizer;
@ -150,6 +151,7 @@ public class TaskListFragment extends InjectingListFragment implements
@Inject Broadcaster broadcaster;
@Inject TagService tagService;
@Inject ThemeCache themeCache;
@Inject ThemeColor themeColor;
@BindView(R.id.swipe_layout) SwipeRefreshLayout swipeRefreshLayout;
@BindView(R.id.swipe_layout_empty) SwipeRefreshLayout emptyView;
@ -175,6 +177,10 @@ public class TaskListFragment extends InjectingListFragment implements
}
}
public ThemeColor getThemeColor() {
return filter.tint >= 0 ? themeCache.getThemeColor(filter.tint) : themeColor;
}
public void setSyncOngoing(final boolean ongoing) {
Activity activity = getActivity();
if (activity != null) {
@ -263,6 +269,8 @@ public class TaskListFragment extends InjectingListFragment implements
callbacks.onNavigationIconClicked();
}
});
ThemeColor color = getThemeColor();
toolbar.setBackgroundColor(color.getPrimaryColor());
inflateMenu(toolbar);
Menu menu = toolbar.getMenu();
for (int i = 0 ; i < menu.size() ; i++) {

@ -30,6 +30,10 @@ public class Theme {
return themeBase;
}
public ThemeColor getThemeColor() {
return themeColor;
}
public int getDialogStyle() {
return themeBase.getDialogStyle();
}
@ -46,7 +50,7 @@ public class Theme {
public void applyThemeAndStatusBarColor(Activity activity) {
applyTheme(activity);
applyStatusBarColor(activity);
themeColor.applyStatusBarColor(activity);
applyTaskDescription(activity, activity.getString(R.string.app_name));
}
@ -56,12 +60,6 @@ public class Theme {
activity.getWindow().setFormat(PixelFormat.RGBA_8888);
}
private void applyStatusBarColor(Activity activity) {
if (atLeastLollipop()) {
activity.getWindow().setStatusBarColor(themeColor.getColorPrimaryDark());
}
}
public void applyTaskDescription(Activity activity, String description) {
if (atLeastLollipop()) {
activity.setTaskDescription(new ActivityManager.TaskDescription(description, null, themeColor.getPrimaryColor()));

@ -1,6 +1,12 @@
package org.tasks.themes;
import android.app.Activity;
import android.support.v4.widget.DrawerLayout;
import org.tasks.R;
import org.tasks.ui.NavigationDrawerFragment;
import static com.todoroo.andlib.utility.AndroidUtilities.atLeastLollipop;
public class ThemeColor {
@ -41,6 +47,18 @@ public class ThemeColor {
this.colorPrimaryDark = colorPrimaryDark;
}
public void applyStatusBarColor(Activity activity) {
if (atLeastLollipop()) {
activity.getWindow().setStatusBarColor(getColorPrimaryDark());
}
}
public void applyStatusBarColor(DrawerLayout drawerLayout) {
if (atLeastLollipop()) {
drawerLayout.setStatusBarBackgroundColor(getColorPrimaryDark());
}
}
public String getName() {
return name;
}

Loading…
Cancel
Save