Fixed WidgetConfig filter theming issue

pull/14/head
Sam Bosley 12 years ago
parent b533ff38e3
commit a420730b18

@ -27,7 +27,6 @@ import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.data.TaskApiDao.TaskCriteria; import com.todoroo.astrid.data.TaskApiDao.TaskCriteria;
import com.todoroo.astrid.service.ThemeService; import com.todoroo.astrid.service.ThemeService;
import com.todoroo.astrid.tags.TagService; import com.todoroo.astrid.tags.TagService;
import com.todoroo.astrid.utility.AstridPreferences;
/** /**
* Exposes Astrid's built in filters to the {@link FilterListFragment} * Exposes Astrid's built in filters to the {@link FilterListFragment}
@ -70,8 +69,7 @@ public final class CoreFilterExposer extends BroadcastReceiver implements Astrid
Criterion.and(MetadataCriteria.withKey(TagService.KEY), Criterion.and(MetadataCriteria.withKey(TagService.KEY),
TagService.TAG.like("x_%", "x"))))))), //$NON-NLS-1$ //$NON-NLS-2$ TagService.TAG.like("x_%", "x"))))))), //$NON-NLS-1$ //$NON-NLS-2$
null); null);
boolean isTablet = AstridPreferences.useTabletLayout(ContextManager.getContext()); int themeFlags = ThemeService.getFilterThemeFlags();
int themeFlags = isTablet ? ThemeService.FLAG_FORCE_LIGHT : 0;
inbox.listingIcon = ((BitmapDrawable)r.getDrawable( inbox.listingIcon = ((BitmapDrawable)r.getDrawable(
ThemeService.getDrawable(R.drawable.filter_inbox, themeFlags))).getBitmap(); ThemeService.getDrawable(R.drawable.filter_inbox, themeFlags))).getBitmap();
return inbox; return inbox;

@ -43,7 +43,6 @@ import com.todoroo.astrid.gtasks.GtasksPreferenceService;
import com.todoroo.astrid.service.TagDataService; import com.todoroo.astrid.service.TagDataService;
import com.todoroo.astrid.service.ThemeService; import com.todoroo.astrid.service.ThemeService;
import com.todoroo.astrid.taskrabbit.TaskRabbitMetadata; import com.todoroo.astrid.taskrabbit.TaskRabbitMetadata;
import com.todoroo.astrid.utility.AstridPreferences;
/** /**
* Exposes Astrid's built in filters to the {@link FilterListFragment} * Exposes Astrid's built in filters to the {@link FilterListFragment}
@ -78,8 +77,7 @@ public final class CustomFilterExposer extends BroadcastReceiver implements Astr
} }
private Filter[] buildSavedFilters(Context context, Resources r) { private Filter[] buildSavedFilters(Context context, Resources r) {
boolean isTablet = AstridPreferences.useTabletLayout(context); int themeFlags = ThemeService.getFilterThemeFlags();
int themeFlags = isTablet ? ThemeService.FLAG_FORCE_LIGHT : 0;
StoreObjectDao dao = PluginServices.getStoreObjectDao(); StoreObjectDao dao = PluginServices.getStoreObjectDao();
TodorooCursor<StoreObject> cursor = dao.query(Query.select(StoreObject.PROPERTIES).where( TodorooCursor<StoreObject> cursor = dao.query(Query.select(StoreObject.PROPERTIES).where(
@ -134,8 +132,7 @@ public final class CustomFilterExposer extends BroadcastReceiver implements Astr
} }
public static Filter getAssignedByMeFilter(Resources r) { public static Filter getAssignedByMeFilter(Resources r) {
boolean isTablet = AstridPreferences.useTabletLayout(ContextManager.getContext()); int themeFlags = ThemeService.getFilterThemeFlags();
int themeFlags = isTablet ? ThemeService.FLAG_FORCE_LIGHT : 0;
Filter f = new Filter(r.getString(R.string.BFE_Assigned), Filter f = new Filter(r.getString(R.string.BFE_Assigned),
r.getString(R.string.BFE_Assigned), r.getString(R.string.BFE_Assigned),
new QueryTemplate().join(Join.left(Metadata.TABLE, Criterion.and(Metadata.KEY.eq(TaskRabbitMetadata.METADATA_KEY), Task.ID.eq(Metadata.TASK)))) new QueryTemplate().join(Join.left(Metadata.TABLE, Criterion.and(Metadata.KEY.eq(TaskRabbitMetadata.METADATA_KEY), Task.ID.eq(Metadata.TASK))))

@ -167,8 +167,7 @@ public class TagFilterExposer extends BroadcastReceiver implements AstridFilterE
Context context = ContextManager.getContext(); Context context = ContextManager.getContext();
Resources r = context.getResources(); Resources r = context.getResources();
boolean isTablet = AstridPreferences.useTabletLayout(context); int themeFlags = ThemeService.getFilterThemeFlags();
int themeFlags = isTablet ? ThemeService.FLAG_FORCE_LIGHT : 0;
// --- untagged // --- untagged
if (addUntaggedFilter) { if (addUntaggedFilter) {

@ -35,6 +35,10 @@ public class ThemeService {
private static int currentTheme; private static int currentTheme;
// Widget config activities set this flag since they theme differently than the normal
// filter list. In other cases this should be false
private static boolean forceFilterInvert = false;
public static void applyTheme(Activity activity) { public static void applyTheme(Activity activity) {
currentTheme = getTheme(); currentTheme = getTheme();
activity.setTheme(currentTheme); activity.setTheme(currentTheme);
@ -124,6 +128,22 @@ public class ThemeService {
return getDrawable(lightDrawable, 0); return getDrawable(lightDrawable, 0);
} }
/**
* Only widget config activities should call this (see note on the flag above)
* @param forceInvert
*/
public static void setForceFilterInvert(boolean forceInvert) {
forceFilterInvert = forceInvert;
}
public static int getFilterThemeFlags() {
if (forceFilterInvert)
return ThemeService.FLAG_INVERT;
if (AstridPreferences.useTabletLayout(ContextManager.getContext()))
return ThemeService.FLAG_FORCE_LIGHT;
return 0;
}
public static int getDrawable(int lightDrawable, int alter) { public static int getDrawable(int lightDrawable, int alter) {
boolean darkTheme = currentTheme == R.style.Theme || currentTheme == R.style.Theme_Transparent; boolean darkTheme = currentTheme == R.style.Theme || currentTheme == R.style.Theme_Transparent;
switch(alter) { switch(alter) {

@ -48,7 +48,7 @@ abstract public class WidgetConfigActivity extends ListActivity {
@Override @Override
public void onCreate(Bundle icicle) { public void onCreate(Bundle icicle) {
ThemeService.applyTheme(this); ThemeService.applyTheme(this);
ThemeService.forceTheme(R.style.Theme); ThemeService.setForceFilterInvert(true);
super.onCreate(icicle); super.onCreate(icicle);
// Set the result to CANCELED. This will cause the widget host to cancel // Set the result to CANCELED. This will cause the widget host to cancel
@ -132,6 +132,7 @@ abstract public class WidgetConfigActivity extends ListActivity {
protected void onStop() { protected void onStop() {
super.onStop(); super.onStop();
StatisticsService.sessionStop(this); StatisticsService.sessionStop(this);
ThemeService.setForceFilterInvert(false);
} }
private void saveConfiguration(FilterListItem filterListItem){ private void saveConfiguration(FilterListItem filterListItem){

Loading…
Cancel
Save