Remove checkbox caching

pull/820/head
Alex Baker 7 years ago
parent fb59324a50
commit 21f1275ca4

@ -10,6 +10,7 @@ import static android.app.Activity.RESULT_OK;
import static androidx.core.content.ContextCompat.getColor; import static androidx.core.content.ContextCompat.getColor;
import static com.todoroo.andlib.utility.AndroidUtilities.assertMainThread; import static com.todoroo.andlib.utility.AndroidUtilities.assertMainThread;
import static org.tasks.caldav.CaldavCalendarSettingsActivity.EXTRA_CALDAV_CALENDAR; import static org.tasks.caldav.CaldavCalendarSettingsActivity.EXTRA_CALDAV_CALENDAR;
import static org.tasks.ui.CheckBoxes.getPriorityColor;
import android.app.Activity; import android.app.Activity;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
@ -90,7 +91,6 @@ import org.tasks.tasklist.ManualSortRecyclerAdapter;
import org.tasks.tasklist.PagedListRecyclerAdapter; import org.tasks.tasklist.PagedListRecyclerAdapter;
import org.tasks.tasklist.TaskListRecyclerAdapter; import org.tasks.tasklist.TaskListRecyclerAdapter;
import org.tasks.tasklist.ViewHolderFactory; import org.tasks.tasklist.ViewHolderFactory;
import org.tasks.ui.CheckBoxes;
import org.tasks.ui.MenuColorizer; import org.tasks.ui.MenuColorizer;
import org.tasks.ui.TaskListViewModel; import org.tasks.ui.TaskListViewModel;
import org.tasks.ui.Toaster; import org.tasks.ui.Toaster;
@ -126,7 +126,6 @@ public final class TaskListFragment extends InjectingFragment
@Inject @ForActivity Context context; @Inject @ForActivity Context context;
@Inject Preferences preferences; @Inject Preferences preferences;
@Inject DialogBuilder dialogBuilder; @Inject DialogBuilder dialogBuilder;
@Inject CheckBoxes checkBoxes;
@Inject TaskCreator taskCreator; @Inject TaskCreator taskCreator;
@Inject TimerPlugin timerPlugin; @Inject TimerPlugin timerPlugin;
@Inject ViewHolderFactory viewHolderFactory; @Inject ViewHolderFactory viewHolderFactory;
@ -454,7 +453,11 @@ public final class TaskListFragment extends InjectingFragment
private void setupRefresh(SwipeRefreshLayout layout) { private void setupRefresh(SwipeRefreshLayout layout) {
layout.setOnRefreshListener(this); layout.setOnRefreshListener(this);
layout.setColorSchemeColors(checkBoxes.getPriorityColors()); layout.setColorSchemeColors(
getPriorityColor(context, 0),
getPriorityColor(context, 1),
getPriorityColor(context, 2),
getPriorityColor(context, 3));
} }
@Override @Override

@ -81,7 +81,6 @@ public class Astrid2TaskProvider extends InjectingContentProvider {
} }
@Inject Lazy<TagService> tagService; @Inject Lazy<TagService> tagService;
@Inject Lazy<CheckBoxes> checkBoxes;
@Inject Lazy<TaskDao> taskDao; @Inject Lazy<TaskDao> taskDao;
@Inject Lazy<TagDao> tagDao; @Inject Lazy<TagDao> tagDao;
@ -177,7 +176,7 @@ public class Astrid2TaskProvider extends InjectingContentProvider {
Object[] values = new Object[7]; Object[] values = new Object[7];
values[0] = task.getTitle(); values[0] = task.getTitle();
values[1] = checkBoxes.get().getPriorityColor(task.getPriority()); values[1] = CheckBoxes.getPriorityColor(getContext(), task.getPriority());
values[2] = task.getDueDate(); values[2] = task.getDueDate();
values[3] = task.getDueDate(); values[3] = task.getDueDate();
values[4] = task.getPriority(); values[4] = task.getPriority();

@ -26,6 +26,7 @@ import com.todoroo.astrid.data.Task;
import javax.inject.Inject; import javax.inject.Inject;
import org.tasks.R; import org.tasks.R;
import org.tasks.dialogs.Linkify; import org.tasks.dialogs.Linkify;
import org.tasks.injection.ForApplication;
import org.tasks.injection.FragmentComponent; import org.tasks.injection.FragmentComponent;
import org.tasks.ui.CheckBoxes; import org.tasks.ui.CheckBoxes;
import org.tasks.ui.TaskEditControlFragment; import org.tasks.ui.TaskEditControlFragment;
@ -44,8 +45,8 @@ public class EditTitleControlSet extends TaskEditControlFragment {
private static final String EXTRA_REPEATING = "extra_repeating"; private static final String EXTRA_REPEATING = "extra_repeating";
private static final String EXTRA_PRIORITY = "extra_priority"; private static final String EXTRA_PRIORITY = "extra_priority";
@Inject @ForApplication Context context;
@Inject TaskDao taskDao; @Inject TaskDao taskDao;
@Inject CheckBoxes checkBoxes;
@Inject Linkify linkify; @Inject Linkify linkify;
@BindView(R.id.title) @BindView(R.id.title)
@ -140,13 +141,8 @@ public class EditTitleControlSet extends TaskEditControlFragment {
private void updateCompleteBox() { private void updateCompleteBox() {
isComplete = completeBox.isChecked(); isComplete = completeBox.isChecked();
if (isComplete) { completeBox.setImageDrawable(
completeBox.setImageDrawable(checkBoxes.getCompletedCheckbox(importanceValue)); CheckBoxes.getCheckBox(context, isComplete, isRepeating, importanceValue));
} else if (isRepeating) {
completeBox.setImageDrawable(checkBoxes.getRepeatingCheckBox(importanceValue));
} else {
completeBox.setImageDrawable(checkBoxes.getCheckBox(importanceValue));
}
if (isComplete) { if (isComplete) {
editText.setPaintFlags(editText.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); editText.setPaintFlags(editText.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);

@ -39,7 +39,6 @@ public class Notifier {
private final AudioManager audioManager; private final AudioManager audioManager;
private final VoiceOutputAssistant voiceOutputAssistant; private final VoiceOutputAssistant voiceOutputAssistant;
private final Preferences preferences; private final Preferences preferences;
private final CheckBoxes checkBoxes;
@Inject @Inject
public Notifier( public Notifier(
@ -49,8 +48,7 @@ public class Notifier {
TelephonyManager telephonyManager, TelephonyManager telephonyManager,
AudioManager audioManager, AudioManager audioManager,
VoiceOutputAssistant voiceOutputAssistant, VoiceOutputAssistant voiceOutputAssistant,
Preferences preferences, Preferences preferences) {
CheckBoxes checkBoxes) {
this.context = context; this.context = context;
this.taskDao = taskDao; this.taskDao = taskDao;
this.notificationManager = notificationManager; this.notificationManager = notificationManager;
@ -58,7 +56,6 @@ public class Notifier {
this.audioManager = audioManager; this.audioManager = audioManager;
this.voiceOutputAssistant = voiceOutputAssistant; this.voiceOutputAssistant = voiceOutputAssistant;
this.preferences = preferences; this.preferences = preferences;
this.checkBoxes = checkBoxes;
} }
public void triggerFilterNotification(final Filter filter) { public void triggerFilterNotification(final Filter filter) {
@ -96,7 +93,7 @@ public class Notifier {
.setAutoCancel(true) .setAutoCancel(true)
.setWhen(currentTimeMillis()) .setWhen(currentTimeMillis())
.setShowWhen(true) .setShowWhen(true)
.setColor(checkBoxes.getPriorityColor(maxPriority)) .setColor(CheckBoxes.getPriorityColor(context, maxPriority))
.setGroupSummary(true) .setGroupSummary(true)
.setGroup(filter.listingTitle) .setGroup(filter.listingTitle)
.setStyle(style); .setStyle(style);

@ -71,7 +71,6 @@ public class NotificationManager {
private final TaskDao taskDao; private final TaskDao taskDao;
private final Context context; private final Context context;
private final Preferences preferences; private final Preferences preferences;
private final CheckBoxes checkBoxes;
private final Throttle throttle = new Throttle(NOTIFICATIONS_PER_SECOND); private final Throttle throttle = new Throttle(NOTIFICATIONS_PER_SECOND);
private final NotificationLimiter queue = new NotificationLimiter(MAX_NOTIFICATIONS); private final NotificationLimiter queue = new NotificationLimiter(MAX_NOTIFICATIONS);
@ -81,13 +80,11 @@ public class NotificationManager {
Preferences preferences, Preferences preferences,
NotificationDao notificationDao, NotificationDao notificationDao,
TaskDao taskDao, TaskDao taskDao,
CheckBoxes checkBoxes,
LocationDao locationDao) { LocationDao locationDao) {
this.context = context; this.context = context;
this.preferences = preferences; this.preferences = preferences;
this.notificationDao = notificationDao; this.notificationDao = notificationDao;
this.taskDao = taskDao; this.taskDao = taskDao;
this.checkBoxes = checkBoxes;
this.locationDao = locationDao; this.locationDao = locationDao;
notificationManagerCompat = NotificationManagerCompat.from(context); notificationManagerCompat = NotificationManagerCompat.from(context);
} }
@ -273,7 +270,7 @@ public class NotificationManager {
.setWhen(when) .setWhen(when)
.setSmallIcon(R.drawable.ic_done_all_white_24dp) .setSmallIcon(R.drawable.ic_done_all_white_24dp)
.setStyle(style) .setStyle(style)
.setColor(checkBoxes.getPriorityColor(maxPriority)) .setColor(CheckBoxes.getPriorityColor(context, maxPriority))
.setOnlyAlertOnce(false) .setOnlyAlertOnce(false)
.setContentIntent( .setContentIntent(
PendingIntent.getActivity( PendingIntent.getActivity(
@ -352,7 +349,7 @@ public class NotificationManager {
new NotificationCompat.Builder(context, NotificationManager.NOTIFICATION_CHANNEL_DEFAULT) new NotificationCompat.Builder(context, NotificationManager.NOTIFICATION_CHANNEL_DEFAULT)
.setCategory(NotificationCompat.CATEGORY_REMINDER) .setCategory(NotificationCompat.CATEGORY_REMINDER)
.setContentTitle(taskTitle) .setContentTitle(taskTitle)
.setColor(checkBoxes.getPriorityColor(task.getPriority())) .setColor(CheckBoxes.getPriorityColor(context, task.getPriority()))
.setSmallIcon(R.drawable.ic_check_white_24dp) .setSmallIcon(R.drawable.ic_check_white_24dp)
.setWhen(when) .setWhen(when)
.setOnlyAlertOnce(false) .setOnlyAlertOnce(false)

@ -9,7 +9,6 @@ import static com.todoroo.andlib.utility.DateUtilities.getAbbreviatedRelativeDat
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.graphics.Paint; import android.graphics.Paint;
import android.text.TextUtils;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -40,7 +39,6 @@ public class ViewHolder extends RecyclerView.ViewHolder {
private final Activity context; private final Activity context;
private final Preferences preferences; private final Preferences preferences;
private final CheckBoxes checkBoxes;
private final int textColorSecondary; private final int textColorSecondary;
private final int textColorPrimary; private final int textColorPrimary;
private final TaskDao taskDao; private final TaskDao taskDao;
@ -92,7 +90,6 @@ public class ViewHolder extends RecyclerView.ViewHolder {
ViewGroup view, ViewGroup view,
Preferences preferences, Preferences preferences,
int fontSize, int fontSize,
CheckBoxes checkBoxes,
ChipProvider chipProvider, ChipProvider chipProvider,
int textColorOverdue, int textColorOverdue,
int textColorSecondary, int textColorSecondary,
@ -107,7 +104,6 @@ public class ViewHolder extends RecyclerView.ViewHolder {
super(view); super(view);
this.context = context; this.context = context;
this.preferences = preferences; this.preferences = preferences;
this.checkBoxes = checkBoxes;
this.chipProvider = chipProvider; this.chipProvider = chipProvider;
this.textColorOverdue = textColorOverdue; this.textColorOverdue = textColorOverdue;
this.textColorSecondary = textColorSecondary; this.textColorSecondary = textColorSecondary;
@ -247,16 +243,8 @@ public class ViewHolder extends RecyclerView.ViewHolder {
private void setupCompleteBox() { private void setupCompleteBox() {
// complete box // complete box
final CheckableImageView checkBoxView = completeBox; final CheckableImageView checkBoxView = completeBox;
boolean completed = task.isCompleted(); checkBoxView.setChecked(task.isCompleted());
checkBoxView.setChecked(completed); checkBoxView.setImageDrawable(CheckBoxes.getCheckBox(context, task.getTask()));
if (completed) {
checkBoxView.setImageDrawable(checkBoxes.getCompletedCheckbox(task.getPriority()));
} else if (TextUtils.isEmpty(task.getRecurrence())) {
checkBoxView.setImageDrawable(checkBoxes.getCheckBox(task.getPriority()));
} else {
checkBoxView.setImageDrawable(checkBoxes.getRepeatingCheckBox(task.getPriority()));
}
checkBoxView.invalidate(); checkBoxView.invalidate();
} }

@ -17,7 +17,6 @@ import org.tasks.dialogs.Linkify;
import org.tasks.injection.ForActivity; import org.tasks.injection.ForActivity;
import org.tasks.locale.Locale; import org.tasks.locale.Locale;
import org.tasks.preferences.Preferences; import org.tasks.preferences.Preferences;
import org.tasks.ui.CheckBoxes;
import org.tasks.ui.ChipProvider; import org.tasks.ui.ChipProvider;
public class ViewHolderFactory { public class ViewHolderFactory {
@ -27,7 +26,6 @@ public class ViewHolderFactory {
private final int textColorOverdue; private final int textColorOverdue;
private final Context context; private final Context context;
private final Locale locale; private final Locale locale;
private final CheckBoxes checkBoxes;
private final ChipProvider chipProvider; private final ChipProvider chipProvider;
private final int fontSize; private final int fontSize;
private final TaskDao taskDao; private final TaskDao taskDao;
@ -43,13 +41,11 @@ public class ViewHolderFactory {
@ForActivity Context context, @ForActivity Context context,
Locale locale, Locale locale,
Preferences preferences, Preferences preferences,
CheckBoxes checkBoxes,
ChipProvider chipProvider, ChipProvider chipProvider,
TaskDao taskDao, TaskDao taskDao,
Linkify linkify) { Linkify linkify) {
this.context = context; this.context = context;
this.locale = locale; this.locale = locale;
this.checkBoxes = checkBoxes;
this.chipProvider = chipProvider; this.chipProvider = chipProvider;
this.taskDao = taskDao; this.taskDao = taskDao;
this.preferences = preferences; this.preferences = preferences;
@ -72,7 +68,6 @@ public class ViewHolderFactory {
LayoutInflater.from(context).inflate(R.layout.task_adapter_row_simple, parent, false), LayoutInflater.from(context).inflate(R.layout.task_adapter_row_simple, parent, false),
preferences, preferences,
fontSize, fontSize,
checkBoxes,
chipProvider, chipProvider,
textColorOverdue, textColorOverdue,
textColorSecondary, textColorSecondary,

@ -3,38 +3,18 @@ package org.tasks.ui;
import static androidx.core.content.ContextCompat.getColor; import static androidx.core.content.ContextCompat.getColor;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import androidx.annotation.DrawableRes; import androidx.annotation.DrawableRes;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.core.graphics.drawable.DrawableCompat; import androidx.core.graphics.drawable.DrawableCompat;
import javax.inject.Inject; import com.todoroo.astrid.data.Task;
import org.tasks.R; import org.tasks.R;
import org.tasks.injection.ApplicationScope;
import org.tasks.injection.ForApplication;
@ApplicationScope
public class CheckBoxes { public class CheckBoxes {
private static final int MIN_PRIORITY = 0; private CheckBoxes() {}
private static final int MAX_PRIORITY = 3;
private final Drawable[] checkboxes = new Drawable[4];
private final Drawable[] repeatingCheckboxes = new Drawable[4];
private final Drawable[] completedCheckboxes = new Drawable[4];
private final Context context;
private final int[] priorityColors;
@Inject
public CheckBoxes(@ForApplication Context context) {
this.context = context;
priorityColors =
new int[] {
getColor(context, R.color.priority_1),
getColor(context, R.color.priority_2),
getColor(context, R.color.priority_3),
getColor(context, R.color.priority_4)
};
}
private static Drawable getDrawable(Context context, @DrawableRes int resId, int priority) { private static Drawable getDrawable(Context context, @DrawableRes int resId, int priority) {
Drawable original = ContextCompat.getDrawable(context, resId); Drawable original = ContextCompat.getDrawable(context, resId);
@ -44,50 +24,46 @@ public class CheckBoxes {
} }
private static int getPriorityResId(int priority) { private static int getPriorityResId(int priority) {
switch (priority) { if (priority <= 0) {
case 0:
return R.color.priority_1; return R.color.priority_1;
case 1: } else if (priority == 1) {
return R.color.priority_2; return R.color.priority_2;
case 2: } else if (priority == 2) {
return R.color.priority_3; return R.color.priority_3;
default: } else {
return R.color.priority_4; return R.color.priority_4;
} }
} }
public int getPriorityColor(int priority) { private static Bitmap convertToBitmap(Drawable d) {
return priorityColors[Math.max(MIN_PRIORITY, Math.min(MAX_PRIORITY, priority))]; Bitmap bitmap =
Bitmap.createBitmap(d.getIntrinsicWidth(), d.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
d.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
d.draw(canvas);
return bitmap;
} }
public int[] getPriorityColors() { public static Bitmap getCheckBoxBitmap(Context context, Task task) {
return priorityColors; return convertToBitmap(getCheckBox(context, task));
} }
public Drawable getCompletedCheckbox(int priority) { public static Drawable getCheckBox(Context context, Task task) {
priority = Math.min(priority, MAX_PRIORITY); return getCheckBox(context, task.isCompleted(), task.isRecurring(), task.getPriority());
if (completedCheckboxes[priority] == null) {
completedCheckboxes[priority] =
getDrawable(context, R.drawable.ic_outline_check_box_24px, priority);
}
return completedCheckboxes[priority];
} }
public Drawable getRepeatingCheckBox(int priority) { public static Drawable getCheckBox(
priority = Math.min(priority, MAX_PRIORITY); Context context, boolean complete, boolean repeating, int priority) {
if (repeatingCheckboxes[priority] == null) { if (complete) {
repeatingCheckboxes[priority] = return getDrawable(context, R.drawable.ic_outline_check_box_24px, priority);
getDrawable(context, R.drawable.ic_outline_repeat_24px, priority); } else if (repeating) {
return getDrawable(context, R.drawable.ic_outline_repeat_24px, priority);
} else {
return getDrawable(context, R.drawable.ic_outline_check_box_outline_blank_24px, priority);
} }
return repeatingCheckboxes[priority];
} }
public Drawable getCheckBox(int priority) { public static int getPriorityColor(Context context, int priority) {
priority = Math.min(priority, MAX_PRIORITY); return getColor(context, getPriorityResId(priority));
if (checkboxes[priority] == null) {
checkboxes[priority] =
getDrawable(context, R.drawable.ic_outline_check_box_outline_blank_24px, priority);
}
return checkboxes[priority];
} }
} }

@ -3,6 +3,7 @@ package org.tasks.ui;
import static com.todoroo.andlib.utility.AndroidUtilities.preLollipop; import static com.todoroo.andlib.utility.AndroidUtilities.preLollipop;
import android.app.Activity; import android.app.Activity;
import android.content.Context;
import android.content.res.ColorStateList; import android.content.res.ColorStateList;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -18,13 +19,15 @@ import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.data.Task.Priority; import com.todoroo.astrid.data.Task.Priority;
import javax.inject.Inject; import javax.inject.Inject;
import org.tasks.R; import org.tasks.R;
import org.tasks.injection.ForApplication;
import org.tasks.injection.FragmentComponent; import org.tasks.injection.FragmentComponent;
public class PriorityControlSet extends TaskEditControlFragment { public class PriorityControlSet extends TaskEditControlFragment {
public static final int TAG = R.string.TEA_ctrl_importance_pref; public static final int TAG = R.string.TEA_ctrl_importance_pref;
private static final String EXTRA_PRIORITY = "extra_priority"; private static final String EXTRA_PRIORITY = "extra_priority";
@Inject CheckBoxes checkBoxes;
@Inject @ForApplication Context context;
@BindView(R.id.priority_high) @BindView(R.id.priority_high)
AppCompatRadioButton priorityHigh; AppCompatRadioButton priorityHigh;
@ -120,7 +123,7 @@ public class PriorityControlSet extends TaskEditControlFragment {
} }
private void tintRadioButton(AppCompatRadioButton radioButton, int priority) { private void tintRadioButton(AppCompatRadioButton radioButton, int priority) {
int color = checkBoxes.getPriorityColor(priority); int color = CheckBoxes.getPriorityColor(context, priority);
CompoundButtonCompat.setButtonTintList( CompoundButtonCompat.setButtonTintList(
radioButton, radioButton,
new ColorStateList( new ColorStateList(

@ -1,51 +0,0 @@
package org.tasks.ui;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import javax.inject.Inject;
import org.tasks.injection.ApplicationScope;
@ApplicationScope
public class WidgetCheckBoxes {
private final CheckBoxes checkBoxes;
private final Bitmap[] incomplete = new Bitmap[4];
private final Bitmap[] repeating = new Bitmap[4];
private final Bitmap[] completed = new Bitmap[4];
@Inject
public WidgetCheckBoxes(CheckBoxes checkBoxes) {
this.checkBoxes = checkBoxes;
}
private static Bitmap convertToBitmap(Drawable d) {
Bitmap bitmap =
Bitmap.createBitmap(d.getIntrinsicWidth(), d.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
d.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
d.draw(canvas);
return bitmap;
}
public Bitmap getCompletedCheckbox(int importance) {
if (completed[importance] == null) {
completed[importance] = convertToBitmap(checkBoxes.getCompletedCheckbox(importance));
}
return completed[importance];
}
public Bitmap getRepeatingCheckBox(int importance) {
if (repeating[importance] == null) {
repeating[importance] = convertToBitmap(checkBoxes.getRepeatingCheckBox(importance));
}
return repeating[importance];
}
public Bitmap getCheckBox(int importance) {
if (incomplete[importance] == null) {
incomplete[importance] = convertToBitmap(checkBoxes.getCheckBox(importance));
}
return incomplete[importance];
}
}

@ -9,7 +9,6 @@ import android.content.Intent;
import android.database.Cursor; import android.database.Cursor;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Paint; import android.graphics.Paint;
import android.text.TextUtils;
import android.view.View; import android.view.View;
import android.widget.RemoteViews; import android.widget.RemoteViews;
import android.widget.RemoteViewsService; import android.widget.RemoteViewsService;
@ -30,12 +29,11 @@ import org.tasks.preferences.DefaultFilterProvider;
import org.tasks.preferences.Preferences; import org.tasks.preferences.Preferences;
import org.tasks.themes.ThemeCache; import org.tasks.themes.ThemeCache;
import org.tasks.themes.WidgetTheme; import org.tasks.themes.WidgetTheme;
import org.tasks.ui.WidgetCheckBoxes; import org.tasks.ui.CheckBoxes;
import timber.log.Timber; import timber.log.Timber;
class ScrollableViewsFactory implements RemoteViewsService.RemoteViewsFactory { class ScrollableViewsFactory implements RemoteViewsService.RemoteViewsFactory {
private final WidgetCheckBoxes checkBoxes;
private final ThemeCache themeCache; private final ThemeCache themeCache;
private final int widgetId; private final int widgetId;
private final TaskDao taskDao; private final TaskDao taskDao;
@ -62,7 +60,6 @@ class ScrollableViewsFactory implements RemoteViewsService.RemoteViewsFactory {
int widgetId, int widgetId,
TaskDao taskDao, TaskDao taskDao,
DefaultFilterProvider defaultFilterProvider, DefaultFilterProvider defaultFilterProvider,
WidgetCheckBoxes checkBoxes,
ThemeCache themeCache) { ThemeCache themeCache) {
this.subtasksHelper = subtasksHelper; this.subtasksHelper = subtasksHelper;
this.preferences = preferences; this.preferences = preferences;
@ -70,7 +67,6 @@ class ScrollableViewsFactory implements RemoteViewsService.RemoteViewsFactory {
this.widgetId = widgetId; this.widgetId = widgetId;
this.taskDao = taskDao; this.taskDao = taskDao;
this.defaultFilterProvider = defaultFilterProvider; this.defaultFilterProvider = defaultFilterProvider;
this.checkBoxes = checkBoxes;
this.themeCache = themeCache; this.themeCache = themeCache;
widgetPreferences = new WidgetPreferences(context, preferences, widgetId); widgetPreferences = new WidgetPreferences(context, preferences, widgetId);
@ -79,9 +75,7 @@ class ScrollableViewsFactory implements RemoteViewsService.RemoteViewsFactory {
} }
@Override @Override
public void onCreate() { public void onCreate() {}
}
@Override @Override
public void onDataSetChanged() { public void onDataSetChanged() {
@ -130,13 +124,7 @@ class ScrollableViewsFactory implements RemoteViewsService.RemoteViewsFactory {
} }
private Bitmap getCheckbox(Task task) { private Bitmap getCheckbox(Task task) {
if (task.isCompleted()) { return CheckBoxes.getCheckBoxBitmap(context, task);
return checkBoxes.getCompletedCheckbox(task.getPriority());
} else if (TextUtils.isEmpty(task.getRecurrence())) {
return checkBoxes.getCheckBox(task.getPriority());
} else {
return checkBoxes.getRepeatingCheckBox(task.getPriority());
}
} }
private RemoteViews buildUpdate(int position) { private RemoteViews buildUpdate(int position) {

@ -12,7 +12,6 @@ import org.tasks.locale.Locale;
import org.tasks.preferences.DefaultFilterProvider; import org.tasks.preferences.DefaultFilterProvider;
import org.tasks.preferences.Preferences; import org.tasks.preferences.Preferences;
import org.tasks.themes.ThemeCache; import org.tasks.themes.ThemeCache;
import org.tasks.ui.WidgetCheckBoxes;
public class ScrollableWidgetUpdateService extends RemoteViewsService { public class ScrollableWidgetUpdateService extends RemoteViewsService {
@ -20,7 +19,6 @@ public class ScrollableWidgetUpdateService extends RemoteViewsService {
@Inject Preferences preferences; @Inject Preferences preferences;
@Inject SubtasksHelper subtasksHelper; @Inject SubtasksHelper subtasksHelper;
@Inject DefaultFilterProvider defaultFilterProvider; @Inject DefaultFilterProvider defaultFilterProvider;
@Inject WidgetCheckBoxes widgetCheckBoxes;
@Inject ThemeCache themeCache; @Inject ThemeCache themeCache;
@Inject Locale locale; @Inject Locale locale;
@ -57,7 +55,6 @@ public class ScrollableWidgetUpdateService extends RemoteViewsService {
widgetId, widgetId,
taskDao, taskDao,
defaultFilterProvider, defaultFilterProvider,
widgetCheckBoxes,
themeCache); themeCache);
} }
} }

Loading…
Cancel
Save