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.service.ThemeService;
import com.todoroo.astrid.tags.TagService;
import com.todoroo.astrid.utility.AstridPreferences;
/**
* 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),
TagService.TAG.like("x_%", "x"))))))), //$NON-NLS-1$ //$NON-NLS-2$
null);
boolean isTablet = AstridPreferences.useTabletLayout(ContextManager.getContext());
int themeFlags = isTablet ? ThemeService.FLAG_FORCE_LIGHT : 0;
int themeFlags = ThemeService.getFilterThemeFlags();
inbox.listingIcon = ((BitmapDrawable)r.getDrawable(
ThemeService.getDrawable(R.drawable.filter_inbox, themeFlags))).getBitmap();
return inbox;

@ -43,7 +43,6 @@ import com.todoroo.astrid.gtasks.GtasksPreferenceService;
import com.todoroo.astrid.service.TagDataService;
import com.todoroo.astrid.service.ThemeService;
import com.todoroo.astrid.taskrabbit.TaskRabbitMetadata;
import com.todoroo.astrid.utility.AstridPreferences;
/**
* 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) {
boolean isTablet = AstridPreferences.useTabletLayout(context);
int themeFlags = isTablet ? ThemeService.FLAG_FORCE_LIGHT : 0;
int themeFlags = ThemeService.getFilterThemeFlags();
StoreObjectDao dao = PluginServices.getStoreObjectDao();
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) {
boolean isTablet = AstridPreferences.useTabletLayout(ContextManager.getContext());
int themeFlags = isTablet ? ThemeService.FLAG_FORCE_LIGHT : 0;
int themeFlags = ThemeService.getFilterThemeFlags();
Filter f = new Filter(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))))

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

@ -35,6 +35,10 @@ public class ThemeService {
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) {
currentTheme = getTheme();
activity.setTheme(currentTheme);
@ -124,6 +128,22 @@ public class ThemeService {
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) {
boolean darkTheme = currentTheme == R.style.Theme || currentTheme == R.style.Theme_Transparent;
switch(alter) {

@ -48,7 +48,7 @@ abstract public class WidgetConfigActivity extends ListActivity {
@Override
public void onCreate(Bundle icicle) {
ThemeService.applyTheme(this);
ThemeService.forceTheme(R.style.Theme);
ThemeService.setForceFilterInvert(true);
super.onCreate(icicle);
// 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() {
super.onStop();
StatisticsService.sessionStop(this);
ThemeService.setForceFilterInvert(false);
}
private void saveConfiguration(FilterListItem filterListItem){

Loading…
Cancel
Save