Remove getDrawable from ThemeService

pull/189/head
Alex Baker 12 years ago
parent 2d4fe67e7f
commit 4557c0dec1

@ -6,7 +6,6 @@
package com.todoroo.astrid.api; package com.todoroo.astrid.api;
import android.content.Intent; import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
@ -23,11 +22,6 @@ abstract public class FilterListItem implements Parcelable {
*/ */
public String listingTitle = null; public String listingTitle = null;
/**
* Bitmap for icon used on listing page. <code>null</code> => no icon
*/
public Bitmap listingIcon = null;
/** /**
* Text Color. <code>0</code> => default color * Text Color. <code>0</code> => default color
*/ */
@ -54,7 +48,6 @@ abstract public class FilterListItem implements Parcelable {
@Override @Override
public void writeToParcel(Parcel dest, int flags) { public void writeToParcel(Parcel dest, int flags) {
dest.writeString(listingTitle); dest.writeString(listingTitle);
dest.writeParcelable(listingIcon, 0);
dest.writeInt(color); dest.writeInt(color);
// write array lengths before arrays // write array lengths before arrays
@ -67,7 +60,6 @@ abstract public class FilterListItem implements Parcelable {
*/ */
public void readFromParcel(Parcel source) { public void readFromParcel(Parcel source) {
listingTitle = source.readString(); listingTitle = source.readString();
listingIcon = source.readParcelable(Bitmap.class.getClassLoader());
color = source.readInt(); color = source.readInt();
contextMenuLabels = source.createStringArray(); contextMenuLabels = source.createStringArray();

@ -55,7 +55,7 @@ public class ShortcutActivity extends Activity {
public static final String TOKEN_CUSTOM_CLASS = "class"; //$NON-NLS-1$ public static final String TOKEN_CUSTOM_CLASS = "class"; //$NON-NLS-1$
/** token for passing a image url*/ /** token for passing a image url*/
public static final String TOKEN_IMAGE_URL = "imageUrl"; //$NON-NLS-1$ public static final String TOKEN_IMAGE_URL = "imageUrl"; //$NON-NLS-1$ TODO: Remove this
/** List of the above constants for searching */ /** List of the above constants for searching */
private static final String[] CUSTOM_EXTRAS = { private static final String[] CUSTOM_EXTRAS = {

@ -963,7 +963,7 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
} }
item = menu.add(Menu.NONE, MENU_DELETE_TASK_ID, 0, R.string.delete_task); item = menu.add(Menu.NONE, MENU_DELETE_TASK_ID, 0, R.string.delete_task);
item.setIcon(ThemeService.getDrawable(resourceResolver.getResource(R.attr.ic_action_discard))); item.setIcon(resourceResolver.getResource(R.attr.ic_action_discard));
setShowAsAction(item, MenuItem.SHOW_AS_ACTION_ALWAYS); setShowAsAction(item, MenuItem.SHOW_AS_ACTION_ALWAYS);
boolean useSaveAndCancel = preferences.getBoolean(R.string.p_save_and_cancel, false); boolean useSaveAndCancel = preferences.getBoolean(R.string.p_save_and_cancel, false);

@ -151,8 +151,6 @@ public class FilterAdapter extends ArrayAdapter<Filter> {
private void transferImageReferences(Filter from, Filter to) { private void transferImageReferences(Filter from, Filter to) {
if (from instanceof FilterWithUpdate && to instanceof FilterWithUpdate) { if (from instanceof FilterWithUpdate && to instanceof FilterWithUpdate) {
((FilterWithUpdate) to).imageUrl = ((FilterWithUpdate) from).imageUrl; ((FilterWithUpdate) to).imageUrl = ((FilterWithUpdate) from).imageUrl;
} else {
to.listingIcon = from.listingIcon;
} }
} }

@ -9,7 +9,6 @@ import android.content.ContentValues;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.drawable.BitmapDrawable;
import com.todoroo.andlib.service.ContextManager; import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.sql.Criterion; import com.todoroo.andlib.sql.Criterion;
@ -26,7 +25,6 @@ import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria;
import com.todoroo.astrid.dao.TaskDao.TaskCriteria; import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
import com.todoroo.astrid.data.Metadata; import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.service.ThemeService;
import com.todoroo.astrid.tags.TaskToTagMetadata; import com.todoroo.astrid.tags.TaskToTagMetadata;
import org.tasks.R; import org.tasks.R;
@ -81,32 +79,26 @@ public final class CoreFilterExposer extends InjectingBroadcastReceiver implemen
* Build inbox filter * Build inbox filter
*/ */
public static Filter buildInboxFilter(Resources r) { public static Filter buildInboxFilter(Resources r) {
Filter inbox = new Filter(r.getString(R.string.BFE_Active), r.getString(R.string.BFE_Active), return new Filter(r.getString(R.string.BFE_Active), r.getString(R.string.BFE_Active),
new QueryTemplate().where( new QueryTemplate().where(
Criterion.and(TaskCriteria.activeVisibleMine(), Criterion.and(TaskCriteria.activeVisibleMine(),
Criterion.not(Task.ID.in(Query.select(Metadata.TASK).from(Metadata.TABLE).where( Criterion.not(Task.ID.in(Query.select(Metadata.TASK).from(Metadata.TABLE).where(
Criterion.and(MetadataCriteria.withKey(TaskToTagMetadata.KEY), Criterion.and(MetadataCriteria.withKey(TaskToTagMetadata.KEY),
TaskToTagMetadata.TAG_NAME.like("x_%", "x"))))))), //$NON-NLS-1$ //$NON-NLS-2$ TaskToTagMetadata.TAG_NAME.like("x_%", "x"))))))), //$NON-NLS-1$ //$NON-NLS-2$
null); null);
inbox.listingIcon = ((BitmapDrawable)r.getDrawable(
ThemeService.getDrawable(R.drawable.filter_inbox))).getBitmap();
return inbox;
} }
private static Filter getTodayFilter(Resources r) { private static Filter getTodayFilter(Resources r) {
String todayTitle = AndroidUtilities.capitalize(r.getString(R.string.today)); String todayTitle = AndroidUtilities.capitalize(r.getString(R.string.today));
ContentValues todayValues = new ContentValues(); ContentValues todayValues = new ContentValues();
todayValues.put(Task.DUE_DATE.name, PermaSql.VALUE_NOON); todayValues.put(Task.DUE_DATE.name, PermaSql.VALUE_NOON);
Filter todayFilter = new Filter(todayTitle, return new Filter(todayTitle,
todayTitle, todayTitle,
new QueryTemplate().where( new QueryTemplate().where(
Criterion.and(TaskCriteria.activeVisibleMine(), Criterion.and(TaskCriteria.activeVisibleMine(),
Task.DUE_DATE.gt(0), Task.DUE_DATE.gt(0),
Task.DUE_DATE.lte(PermaSql.VALUE_EOD))), Task.DUE_DATE.lte(PermaSql.VALUE_EOD))),
todayValues); todayValues);
todayFilter.listingIcon = ((BitmapDrawable)r.getDrawable(
ThemeService.getDrawable(R.drawable.filter_calendar))).getBitmap();
return todayFilter;
} }
/** /**

@ -86,9 +86,6 @@ public final class CustomFilterExposer extends InjectingBroadcastReceiver implem
TaskCriteria.ownedByMe()).orderBy( TaskCriteria.ownedByMe()).orderBy(
Order.desc(Task.MODIFICATION_DATE)).limit(15), Order.desc(Task.MODIFICATION_DATE)).limit(15),
null); null);
recent.listingIcon = ((BitmapDrawable)r.getDrawable(
ThemeService.getDrawable(R.drawable.filter_pencil))).getBitmap();
list.add(recent); list.add(recent);
} }
@ -103,8 +100,6 @@ public final class CustomFilterExposer extends InjectingBroadcastReceiver implem
deleteIntent.putExtra(TOKEN_FILTER_NAME, f.title); deleteIntent.putExtra(TOKEN_FILTER_NAME, f.title);
f.contextMenuLabels = new String[] { context.getString(R.string.BFE_Saved_delete) }; f.contextMenuLabels = new String[] { context.getString(R.string.BFE_Saved_delete) };
f.contextMenuIntents = new Intent[] { deleteIntent }; f.contextMenuIntents = new Intent[] { deleteIntent };
f.listingIcon = ((BitmapDrawable)r.getDrawable(
ThemeService.getDrawable(R.drawable.filter_sliders))).getBitmap();
list.add(f); list.add(f);
} }
} }

@ -70,7 +70,6 @@ public class GtasksFilterExposer extends InjectingBroadcastReceiver implements A
GtasksMetadata.LIST_ID.eq(list.getValue(GtasksList.REMOTE_ID)))).orderBy( GtasksMetadata.LIST_ID.eq(list.getValue(GtasksList.REMOTE_ID)))).orderBy(
Order.asc(Functions.cast(GtasksMetadata.ORDER, "LONG"))), //$NON-NLS-1$ Order.asc(Functions.cast(GtasksMetadata.ORDER, "LONG"))), //$NON-NLS-1$
values); values);
filter.listingIcon = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.gtasks_icon)).getBitmap();
filter.customTaskList = new ComponentName(ContextManager.getContext(), GtasksListFragment.class); filter.customTaskList = new ComponentName(ContextManager.getContext(), GtasksListFragment.class);
Bundle extras = new Bundle(); Bundle extras = new Bundle();
extras.putLong(GtasksListFragment.TOKEN_STORE_ID, list.getId()); extras.putLong(GtasksListFragment.TOKEN_STORE_ID, list.getId());

@ -7,7 +7,6 @@ package com.todoroo.astrid.service;
import android.app.Activity; import android.app.Activity;
import android.graphics.PixelFormat; import android.graphics.PixelFormat;
import android.util.Log;
import com.todoroo.andlib.utility.AndroidUtilities; import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.andlib.utility.Preferences; import com.todoroo.andlib.utility.Preferences;
@ -80,31 +79,6 @@ public class ThemeService {
return theme; return theme;
} }
public static int getDrawable(int lightDrawable) {
int theme = getTheme();
boolean darkTheme = theme == R.style.Tasks;
if(!darkTheme) {
return lightDrawable;
}
switch(lightDrawable) {
case R.drawable.filter_calendar:
return R.drawable.filter_calendar_dark;
case R.drawable.filter_inbox:
return R.drawable.filter_inbox_dark;
case R.drawable.filter_pencil:
return R.drawable.filter_pencil_dark;
case R.drawable.filter_sliders:
return R.drawable.filter_sliders_dark;
case R.drawable.gl_lists:
return R.drawable.gl_lists_dark;
}
Log.w("ThemeService", "No theme drawable found for " + lightDrawable);
return lightDrawable;
}
public static int getDarkVsLight(int resForLight, int resForDark) { public static int getDarkVsLight(int resForLight, int resForDark) {
int theme = getTheme(); int theme = getTheme();
if (theme == R.style.Tasks) { if (theme == R.style.Tasks) {

@ -152,8 +152,6 @@ public class TagFilterExposer extends InjectingBroadcastReceiver implements Astr
r.getString(R.string.tag_FEx_untagged), r.getString(R.string.tag_FEx_untagged),
tagService.untaggedTemplate(), tagService.untaggedTemplate(),
null); null);
untagged.listingIcon = ((BitmapDrawable)r.getDrawable(
ThemeService.getDrawable(R.drawable.gl_lists))).getBitmap();
filters.add(untagged); filters.add(untagged);
} }

@ -9,7 +9,6 @@ import android.content.ContentValues;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.drawable.BitmapDrawable;
import com.todoroo.andlib.service.ContextManager; import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.sql.Query; import com.todoroo.andlib.sql.Query;
@ -70,12 +69,10 @@ public final class TimerFilterExposer extends InjectingBroadcastReceiver impleme
Resources r = context.getResources(); Resources r = context.getResources();
ContentValues values = new ContentValues(); ContentValues values = new ContentValues();
values.put(Task.TIMER_START.name, Filter.VALUE_NOW); values.put(Task.TIMER_START.name, Filter.VALUE_NOW);
Filter workingOn = new Filter(r.getString(R.string.TFE_workingOn), return new Filter(r.getString(R.string.TFE_workingOn),
r.getString(R.string.TFE_workingOn), r.getString(R.string.TFE_workingOn),
new QueryTemplate().where(Task.TIMER_START.gt(0)), new QueryTemplate().where(Task.TIMER_START.gt(0)),
values); values);
workingOn.listingIcon = ((BitmapDrawable)r.getDrawable(R.drawable.tango_clock)).getBitmap();
return workingOn;
} }
@Override @Override

Binary file not shown.

Before

Width:  |  Height:  |  Size: 914 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 950 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 781 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 790 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 710 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 693 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 699 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 382 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 382 B

Loading…
Cancel
Save