From bce22ca4a031d29652cc9108e0d76f4c42e288cf Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Thu, 10 Mar 2016 12:12:05 -0600 Subject: [PATCH] Upgrade to Dagger 2 --- build.gradle | 4 +- .../todoroo/astrid/dao/MetadataDaoTests.java | 7 + .../com/todoroo/astrid/dao/TaskDaoTests.java | 7 + .../com/todoroo/astrid/model/TaskTest.java | 6 + .../astrid/provider/Astrid3ProviderTests.java | 7 + .../astrid/reminders/NotificationTests.java | 29 +++- .../astrid/reminders/ReminderServiceTest.java | 6 + .../astrid/repeats/NewRepeatTests.java | 6 + .../astrid/service/QuickAddMarkupTest.java | 7 + .../astrid/service/TitleParserTest.java | 8 +- .../astrid/subtasks/SubtasksHelperTest.java | 9 + .../astrid/subtasks/SubtasksTestCase.java | 6 + .../todoroo/astrid/sync/NewSyncTestCase.java | 7 + .../tasks/injection/InjectingTestCase.java | 12 +- .../org/tasks/injection/TestComponent.java | 65 ++++++++ .../java/org/tasks/injection/TestModule.java | 21 +-- .../tasks/scheduling/BackupServiceTests.java | 6 + .../astrid/gtasks/GtasksIndentActionTest.java | 12 +- .../astrid/gtasks/GtasksListServiceTest.java | 9 +- .../gtasks/GtasksMetadataServiceTest.java | 19 ++- .../gtasks/GtasksTaskListUpdaterTest.java | 11 +- .../astrid/gtasks/GtasksTaskMovingTest.java | 12 +- .../gtasks/GtasksTestPreferenceService.java | 5 +- .../astrid/gtasks/GtasksPreferences.java | 6 + .../gtasks/auth/GtasksLoginActivity.java | 6 + .../activities/ClearGtaskDataActivity.java | 6 + .../tasks/activities/DonationActivity.java | 6 + .../tasks/dialogs/AccountSelectionDialog.java | 6 + .../GeofenceTransitionsIntentService.java | 6 + .../scheduling/GtasksBackgroundService.java | 6 + .../astrid/actfm/FilterSettingsActivity.java | 6 + .../astrid/actfm/TagSettingsActivity.java | 6 + .../astrid/activity/BeastModePreferences.java | 6 + .../activity/FilterShortcutActivity.java | 6 + .../astrid/activity/ShareLinkActivity.java | 6 + .../astrid/activity/ShortcutActivity.java | 6 + .../astrid/activity/TaskEditFragment.java | 6 + .../astrid/activity/TaskListActivity.java | 6 + .../astrid/activity/TaskListFragment.java | 6 + .../alarms/AlarmTaskRepeatListener.java | 6 + .../calls/PhoneStateChangedReceiver.java | 6 + .../astrid/core/CustomFilterActivity.java | 7 +- .../astrid/core/DefaultsPreferences.java | 6 + .../astrid/core/OldTaskPreferences.java | 6 + .../astrid/files/AACRecordingActivity.java | 6 + .../todoroo/astrid/files/FilesControlSet.java | 6 + .../astrid/gcal/CalendarAlarmReceiver.java | 6 + .../astrid/gcal/CalendarReminderActivity.java | 6 + .../astrid/gcal/GCalTaskCompleteListener.java | 6 + .../astrid/provider/Astrid2TaskProvider.java | 6 + .../provider/Astrid3ContentProvider.java | 6 + .../astrid/provider/SqlContentProvider.java | 6 + .../astrid/reminders/ReminderPreferences.java | 6 + .../astrid/repeats/RepeatControlSet.java | 6 + .../repeats/RepeatTaskCompleteListener.java | 6 + .../astrid/service/UpgradeActivity.java | 6 + .../todoroo/astrid/tags/TagsControlSet.java | 6 + .../astrid/timers/TimerControlSet.java | 6 + .../timers/TimerTaskCompleteListener.java | 6 + .../astrid/ui/EditTitleControlSet.java | 6 + .../astrid/ui/HideUntilControlSet.java | 6 + .../todoroo/astrid/ui/ReminderControlSet.java | 6 + .../todoroo/astrid/widget/TasksWidget.java | 6 + .../astrid/widget/WidgetConfigActivity.java | 6 + src/main/java/org/tasks/Tasks.java | 6 + .../activities/AddAttachmentActivity.java | 6 + .../activities/CalendarSelectionActivity.java | 6 + .../activities/CalendarSelectionDialog.java | 6 + .../org/tasks/activities/CameraActivity.java | 6 + .../activities/ClearAllDataActivity.java | 6 + .../activities/DateAndTimePickerActivity.java | 6 + .../tasks/activities/DatePickerActivity.java | 6 + .../DeleteAllCalendarEventsActivity.java | 6 + .../activities/DeleteCompletedActivity.java | 6 + .../DeleteCompletedEventsActivity.java | 6 + .../tasks/activities/ExportTaskActivity.java | 6 + .../activities/FilterSelectionActivity.java | 6 + .../tasks/activities/ImportTaskActivity.java | 6 + .../activities/PurgeDeletedActivity.java | 6 + .../activities/ResetPreferencesActivity.java | 6 + .../org/tasks/activities/SortActivity.java | 6 + .../tasks/activities/TimePickerActivity.java | 6 + .../tasks/dialogs/AddAttachmentDialog.java | 6 + .../java/org/tasks/files/FileExplore.java | 6 + .../tasks/fragments/CommentBarFragment.java | 6 + .../tasks/injection/ActivityComponent.java | 154 ++++++++++++++++++ .../org/tasks/injection/ActivityModule.java | 102 +----------- .../tasks/injection/ApplicationComponent.java | 22 +++ .../tasks/injection/ApplicationModule.java | 21 +++ .../tasks/injection/BroadcastComponent.java | 51 ++++++ .../org/tasks/injection/BroadcastModule.java | 35 +--- .../injection/ContentProviderComponent.java | 22 +++ .../injection/ContentProviderModule.java | 11 +- src/main/java/org/tasks/injection/Dagger.java | 16 -- .../injection/DialogFragmentComponent.java | 25 +++ .../tasks/injection/DialogFragmentModule.java | 18 +- .../tasks/injection/FragmentComponent.java | 57 +++++++ .../org/tasks/injection/FragmentModule.java | 54 +----- .../tasks/injection/InjectingActivity.java | 7 + .../injection/InjectingAppCompatActivity.java | 19 +-- .../injection/InjectingAppWidgetProvider.java | 11 +- .../tasks/injection/InjectingApplication.java | 24 ++- .../injection/InjectingBroadcastReceiver.java | 11 +- .../injection/InjectingContentProvider.java | 10 +- .../injection/InjectingDialogFragment.java | 8 +- .../tasks/injection/InjectingFragment.java | 20 +-- .../injection/InjectingIntentService.java | 9 +- .../injection/InjectingListActivity.java | 20 +-- .../injection/InjectingListFragment.java | 20 +-- .../InjectingPreferenceActivity.java | 21 +-- .../InjectingRemoteViewsService.java | 9 +- .../org/tasks/injection/InjectingService.java | 15 -- .../java/org/tasks/injection/Injector.java | 10 -- .../injection/IntentServiceComponent.java | 28 ++++ .../tasks/injection/IntentServiceModule.java | 14 +- .../RemoteViewsServiceComponent.java | 10 ++ .../injection/RemoteViewsServiceModule.java | 7 + .../org/tasks/injection/ServiceModule.java | 12 -- .../java/org/tasks/injection/TasksModule.java | 26 --- .../preferences/AppearancePreferences.java | 6 + .../tasks/preferences/BackupPreferences.java | 6 + .../tasks/preferences/BasicPreferences.java | 6 + .../preferences/DateShortcutPreferences.java | 6 + .../preferences/HelpAndFeedbackActivity.java | 6 + .../preferences/MiscellaneousPreferences.java | 6 + .../receivers/BootCompletedReceiver.java | 6 + .../tasks/receivers/CompleteTaskReceiver.java | 6 + .../tasks/receivers/FirstLaunchReceiver.java | 6 + .../receivers/ListNotificationReceiver.java | 6 + .../receivers/MyPackageReplacedReceiver.java | 6 + .../org/tasks/receivers/RefreshReceiver.java | 6 + .../receivers/TaskNotificationReceiver.java | 6 + .../tasks/reminders/MissedCallActivity.java | 6 + .../org/tasks/reminders/MissedCallDialog.java | 6 + .../tasks/reminders/NotificationActivity.java | 6 + .../tasks/reminders/NotificationDialog.java | 6 + .../org/tasks/reminders/SnoozeActivity.java | 6 + .../org/tasks/reminders/SnoozeDialog.java | 6 + .../tasks/scheduling/BackupIntentService.java | 6 + .../CalendarNotificationIntentService.java | 6 + .../GeofenceSchedulingIntentService.java | 6 + .../RefreshSchedulerIntentService.java | 6 + .../ReminderSchedulerIntentService.java | 6 + .../java/org/tasks/ui/CalendarControlSet.java | 6 + .../java/org/tasks/ui/DeadlineControlSet.java | 6 + .../org/tasks/ui/DescriptionControlSet.java | 6 + .../tasks/ui/NavigationDrawerFragment.java | 6 + .../java/org/tasks/ui/PriorityControlSet.java | 6 + .../org/tasks/voice/VoiceCommandActivity.java | 6 + .../widget/ScrollableWidgetUpdateService.java | 6 + 150 files changed, 1273 insertions(+), 466 deletions(-) create mode 100644 src/androidTest/java/org/tasks/injection/TestComponent.java create mode 100644 src/main/java/org/tasks/injection/ActivityComponent.java create mode 100644 src/main/java/org/tasks/injection/ApplicationComponent.java create mode 100644 src/main/java/org/tasks/injection/ApplicationModule.java create mode 100644 src/main/java/org/tasks/injection/BroadcastComponent.java create mode 100644 src/main/java/org/tasks/injection/ContentProviderComponent.java delete mode 100644 src/main/java/org/tasks/injection/Dagger.java create mode 100644 src/main/java/org/tasks/injection/DialogFragmentComponent.java create mode 100644 src/main/java/org/tasks/injection/FragmentComponent.java create mode 100644 src/main/java/org/tasks/injection/InjectingActivity.java delete mode 100644 src/main/java/org/tasks/injection/InjectingService.java delete mode 100644 src/main/java/org/tasks/injection/Injector.java create mode 100644 src/main/java/org/tasks/injection/IntentServiceComponent.java create mode 100644 src/main/java/org/tasks/injection/RemoteViewsServiceComponent.java create mode 100644 src/main/java/org/tasks/injection/RemoteViewsServiceModule.java delete mode 100644 src/main/java/org/tasks/injection/ServiceModule.java delete mode 100644 src/main/java/org/tasks/injection/TasksModule.java diff --git a/build.gradle b/build.gradle index 005f00ff0..441392fc1 100644 --- a/build.gradle +++ b/build.gradle @@ -72,8 +72,8 @@ android { } dependencies { - provided 'com.squareup.dagger:dagger-compiler:1.2.2' - compile 'com.squareup.dagger:dagger:1.2.2' + provided 'com.google.dagger:dagger-compiler:2.1' + compile 'com.google.dagger:dagger:2.1' compile 'com.nononsenseapps:filepicker:2.5.0' compile 'com.android.support:design:23.1.1' diff --git a/src/androidTest/java/com/todoroo/astrid/dao/MetadataDaoTests.java b/src/androidTest/java/com/todoroo/astrid/dao/MetadataDaoTests.java index 8edb5642c..25f0b63ab 100644 --- a/src/androidTest/java/com/todoroo/astrid/dao/MetadataDaoTests.java +++ b/src/androidTest/java/com/todoroo/astrid/dao/MetadataDaoTests.java @@ -12,6 +12,8 @@ import com.todoroo.astrid.data.Metadata; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.test.DatabaseTestCase; +import org.tasks.injection.TestComponent; + import java.util.List; import javax.inject.Inject; @@ -31,6 +33,11 @@ public class MetadataDaoTests extends DatabaseTestCase { metadata = new Metadata(); } + @Override + protected void inject(TestComponent component) { + component.inject(this); + } + /** * Test basic creation, fetch, and save */ diff --git a/src/androidTest/java/com/todoroo/astrid/dao/TaskDaoTests.java b/src/androidTest/java/com/todoroo/astrid/dao/TaskDaoTests.java index dac1267f1..74d13b73d 100644 --- a/src/androidTest/java/com/todoroo/astrid/dao/TaskDaoTests.java +++ b/src/androidTest/java/com/todoroo/astrid/dao/TaskDaoTests.java @@ -12,6 +12,8 @@ import com.todoroo.astrid.dao.TaskDao.TaskCriteria; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.test.DatabaseTestCase; +import org.tasks.injection.TestComponent; + import java.util.List; import javax.inject.Inject; @@ -156,6 +158,11 @@ public class TaskDaoTests extends DatabaseTestCase { assertEquals(0, taskDao.toList(Query.select(IDS)).size()); } + @Override + protected void inject(TestComponent component) { + component.inject(this); + } + // TODO check eventing } diff --git a/src/androidTest/java/com/todoroo/astrid/model/TaskTest.java b/src/androidTest/java/com/todoroo/astrid/model/TaskTest.java index c571c0bda..1944074ea 100644 --- a/src/androidTest/java/com/todoroo/astrid/model/TaskTest.java +++ b/src/androidTest/java/com/todoroo/astrid/model/TaskTest.java @@ -10,6 +10,7 @@ import com.todoroo.astrid.data.Task; import com.todoroo.astrid.service.TaskService; import org.tasks.Snippet; +import org.tasks.injection.TestComponent; import org.tasks.preferences.Preferences; import javax.inject.Inject; @@ -53,4 +54,9 @@ public class TaskTest extends InjectingTestCase { assertTrue(defaults.containsKey(Task.COMPLETION_DATE.name)); assertTrue(defaults.containsKey(Task.IMPORTANCE.name)); } + + @Override + protected void inject(TestComponent component) { + component.inject(this); + } } diff --git a/src/androidTest/java/com/todoroo/astrid/provider/Astrid3ProviderTests.java b/src/androidTest/java/com/todoroo/astrid/provider/Astrid3ProviderTests.java index cf8f8ed9f..87fe85272 100644 --- a/src/androidTest/java/com/todoroo/astrid/provider/Astrid3ProviderTests.java +++ b/src/androidTest/java/com/todoroo/astrid/provider/Astrid3ProviderTests.java @@ -18,6 +18,8 @@ import com.todoroo.astrid.data.StoreObject; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.test.DatabaseTestCase; +import org.tasks.injection.TestComponent; + public class Astrid3ProviderTests extends DatabaseTestCase { String[] PROJECTION = new String[] { @@ -34,6 +36,11 @@ public class Astrid3ProviderTests extends DatabaseTestCase { } + @Override + protected void inject(TestComponent component) { + component.inject(this); + } + /** Test CRUD over tasks with the ALL ITEMS cursor */ public void testAllItemsCrud() { ContentResolver resolver = getContext().getContentResolver(); diff --git a/src/androidTest/java/com/todoroo/astrid/reminders/NotificationTests.java b/src/androidTest/java/com/todoroo/astrid/reminders/NotificationTests.java index 93ce82f54..e17207a51 100644 --- a/src/androidTest/java/com/todoroo/astrid/reminders/NotificationTests.java +++ b/src/androidTest/java/com/todoroo/astrid/reminders/NotificationTests.java @@ -14,14 +14,14 @@ import com.todoroo.astrid.test.DatabaseTestCase; import org.tasks.Broadcaster; import org.tasks.Notifier; -import org.tasks.injection.TestModule; +import org.tasks.injection.TestComponent; import org.tasks.notifications.NotificationManager; import javax.inject.Inject; -import javax.inject.Singleton; import dagger.Module; import dagger.Provides; +import dagger.Subcomponent; import static org.mockito.Matchers.any; import static org.mockito.Matchers.eq; @@ -31,21 +31,27 @@ import static org.mockito.Mockito.verifyNoMoreInteractions; public class NotificationTests extends DatabaseTestCase { - @Module(addsTo = TestModule.class, injects = {NotificationTests.class}) - static class NotificationTestsModule { - @Singleton + @Module + public static class NotificationTestsModule { + private final NotificationManager notificationManager = mock(NotificationManager.class); + private final Broadcaster broadcaster = mock(Broadcaster.class); + @Provides public NotificationManager getNotificationManager() { - return mock(NotificationManager.class); + return notificationManager; } - @Singleton @Provides public Broadcaster getBroadcaster() { - return mock(Broadcaster.class); + return broadcaster; } } + @Subcomponent(modules = NotificationTestsModule.class) + public interface NotificationTestsComponent { + void inject(NotificationTests notificationTests); + } + @Inject TaskDao taskDao; @Inject NotificationManager notificationManager; @Inject Broadcaster broadcaster; @@ -158,6 +164,13 @@ public class NotificationTests extends DatabaseTestCase { // notificationReceiver.onReceive(getContext(), intent); // } + @Override + protected void inject(TestComponent component) { + component + .plus(new NotificationTestsModule()) + .inject(this); + } + @Override protected Object getModule() { return new NotificationTestsModule(); diff --git a/src/androidTest/java/com/todoroo/astrid/reminders/ReminderServiceTest.java b/src/androidTest/java/com/todoroo/astrid/reminders/ReminderServiceTest.java index 144167d1f..dc95d1de3 100644 --- a/src/androidTest/java/com/todoroo/astrid/reminders/ReminderServiceTest.java +++ b/src/androidTest/java/com/todoroo/astrid/reminders/ReminderServiceTest.java @@ -13,6 +13,7 @@ import com.todoroo.astrid.data.Task; import com.todoroo.astrid.reminders.ReminderService.AlarmScheduler; import org.tasks.injection.InjectingTestCase; +import org.tasks.injection.TestComponent; import javax.inject.Inject; @@ -31,6 +32,11 @@ public class ReminderServiceTest extends InjectingTestCase { freezeClock(); } + @Override + protected void inject(TestComponent component) { + component.inject(this); + } + @Override public void tearDown() { thaw(); diff --git a/src/androidTest/java/com/todoroo/astrid/repeats/NewRepeatTests.java b/src/androidTest/java/com/todoroo/astrid/repeats/NewRepeatTests.java index a09efe7e3..615d88fa3 100644 --- a/src/androidTest/java/com/todoroo/astrid/repeats/NewRepeatTests.java +++ b/src/androidTest/java/com/todoroo/astrid/repeats/NewRepeatTests.java @@ -22,6 +22,7 @@ import com.todoroo.astrid.data.Task; import com.todoroo.astrid.test.DatabaseTestCase; import org.tasks.R; +import org.tasks.injection.TestComponent; import org.tasks.preferences.Preferences; import org.tasks.time.DateTime; @@ -44,6 +45,11 @@ public class NewRepeatTests extends DatabaseTestCase { preferences.setStringFromInteger(R.string.p_default_urgency_key, 0); } + @Override + protected void inject(TestComponent component) { + component.inject(this); + } + private void saveAndTriggerRepeatListener(Task task) { task.putTransitory(SyncFlags.ACTFM_SUPPRESS_OUTSTANDING_ENTRIES, true); if(task.isSaved()) diff --git a/src/androidTest/java/com/todoroo/astrid/service/QuickAddMarkupTest.java b/src/androidTest/java/com/todoroo/astrid/service/QuickAddMarkupTest.java index f6e484d0e..54cc918a7 100644 --- a/src/androidTest/java/com/todoroo/astrid/service/QuickAddMarkupTest.java +++ b/src/androidTest/java/com/todoroo/astrid/service/QuickAddMarkupTest.java @@ -8,6 +8,8 @@ package com.todoroo.astrid.service; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.test.DatabaseTestCase; +import org.tasks.injection.TestComponent; + import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -23,6 +25,11 @@ public class QuickAddMarkupTest extends DatabaseTestCase { super.setUp(); } + @Override + protected void inject(TestComponent component) { + component.inject(this); + } + public void testTags() { whenTitleIs("this #cool"); assertTitleBecomes("this"); diff --git a/src/androidTest/java/com/todoroo/astrid/service/TitleParserTest.java b/src/androidTest/java/com/todoroo/astrid/service/TitleParserTest.java index 3e5b7b5ac..818524cca 100644 --- a/src/androidTest/java/com/todoroo/astrid/service/TitleParserTest.java +++ b/src/androidTest/java/com/todoroo/astrid/service/TitleParserTest.java @@ -13,6 +13,7 @@ import com.todoroo.astrid.test.DatabaseTestCase; import com.todoroo.astrid.utility.TitleParser; import org.tasks.R; +import org.tasks.injection.TestComponent; import org.tasks.preferences.Preferences; import org.tasks.time.DateTime; @@ -35,7 +36,12 @@ public class TitleParserTest extends DatabaseTestCase { preferences.setStringFromInteger(R.string.p_default_urgency_key, 0); } - /** test that completing a task w/ no regular expressions creates a simple task with no date, no repeat, no lists*/ + @Override + protected void inject(TestComponent component) { + component.inject(this); + } + + /** test that completing a task w/ no regular expressions creates a simple task with no date, no repeat, no lists*/ public void testNoRegexes() throws Exception{ Task task = new Task(); Task nothing = new Task(); diff --git a/src/androidTest/java/com/todoroo/astrid/subtasks/SubtasksHelperTest.java b/src/androidTest/java/com/todoroo/astrid/subtasks/SubtasksHelperTest.java index 969d46adf..710157d63 100644 --- a/src/androidTest/java/com/todoroo/astrid/subtasks/SubtasksHelperTest.java +++ b/src/androidTest/java/com/todoroo/astrid/subtasks/SubtasksHelperTest.java @@ -4,6 +4,8 @@ import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.TaskListMetadata; import com.todoroo.astrid.service.TaskService; +import org.tasks.injection.TestComponent; + import javax.inject.Inject; public class SubtasksHelperTest extends SubtasksTestCase { @@ -52,4 +54,11 @@ public class SubtasksHelperTest extends SubtasksTestCase { String mapped = SubtasksHelper.convertTreeToRemoteIds(taskService, DEFAULT_SERIALIZED_TREE).replaceAll("\\s", ""); assertEquals(EXPECTED_REMOTE, mapped); } + + @Override + protected void inject(TestComponent component) { + super.inject(component); + + component.inject(this); + } } diff --git a/src/androidTest/java/com/todoroo/astrid/subtasks/SubtasksTestCase.java b/src/androidTest/java/com/todoroo/astrid/subtasks/SubtasksTestCase.java index aaab3f76b..71e99fb50 100644 --- a/src/androidTest/java/com/todoroo/astrid/subtasks/SubtasksTestCase.java +++ b/src/androidTest/java/com/todoroo/astrid/subtasks/SubtasksTestCase.java @@ -9,6 +9,7 @@ import com.todoroo.astrid.service.TaskService; import com.todoroo.astrid.subtasks.AstridOrderedListUpdater.Node; import com.todoroo.astrid.test.DatabaseTestCase; +import org.tasks.injection.TestComponent; import org.tasks.preferences.Preferences; import javax.inject.Inject; @@ -46,6 +47,11 @@ public class SubtasksTestCase extends DatabaseTestCase { updater = new SubtasksFilterUpdater(taskListMetadataDao, taskService); } + @Override + protected void inject(TestComponent component) { + component.inject(this); + } + protected void expectParentAndPosition(Task task, Task parent, int positionInParent) { String parentId = (parent == null ? "-1" : parent.getUuid()); Node n = updater.findNodeForTask(task.getUuid()); diff --git a/src/androidTest/java/com/todoroo/astrid/sync/NewSyncTestCase.java b/src/androidTest/java/com/todoroo/astrid/sync/NewSyncTestCase.java index 19f996fc2..5c3d0ebe9 100644 --- a/src/androidTest/java/com/todoroo/astrid/sync/NewSyncTestCase.java +++ b/src/androidTest/java/com/todoroo/astrid/sync/NewSyncTestCase.java @@ -6,6 +6,8 @@ import com.todoroo.astrid.data.TagData; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.test.DatabaseTestCase; +import org.tasks.injection.TestComponent; + import javax.inject.Inject; public class NewSyncTestCase extends DatabaseTestCase { @@ -40,4 +42,9 @@ public class NewSyncTestCase extends DatabaseTestCase { protected TagData createTagData() { return createTagData("new tag"); } + + @Override + protected void inject(TestComponent component) { + component.inject(this); + } } diff --git a/src/androidTest/java/org/tasks/injection/InjectingTestCase.java b/src/androidTest/java/org/tasks/injection/InjectingTestCase.java index 8391b83cf..5da400b79 100644 --- a/src/androidTest/java/org/tasks/injection/InjectingTestCase.java +++ b/src/androidTest/java/org/tasks/injection/InjectingTestCase.java @@ -2,8 +2,6 @@ package org.tasks.injection; import android.test.AndroidTestCase; -import dagger.ObjectGraph; - import static org.tasks.TestUtilities.initializeMockito; public abstract class InjectingTestCase extends AndroidTestCase { @@ -12,14 +10,18 @@ public abstract class InjectingTestCase extends AndroidTestCase { protected void setUp() { initializeMockito(getContext()); - ObjectGraph objectGraph = ObjectGraph.create(new TestModule(getContext())); + TestComponent component = DaggerTestComponent.builder() + .testModule(new TestModule(getContext())) + .build(); Object extension = getModule(); if (extension != null) { - objectGraph = objectGraph.plus(extension); +// objectGraph = objectGraph.plus(extension); } - objectGraph.inject(this); + inject(component); } + protected abstract void inject(TestComponent component); + protected Object getModule() { return null; } diff --git a/src/androidTest/java/org/tasks/injection/TestComponent.java b/src/androidTest/java/org/tasks/injection/TestComponent.java new file mode 100644 index 000000000..fec9cc37a --- /dev/null +++ b/src/androidTest/java/org/tasks/injection/TestComponent.java @@ -0,0 +1,65 @@ +package org.tasks.injection; + +import com.todoroo.astrid.dao.MetadataDaoTests; +import com.todoroo.astrid.dao.TaskDaoTests; +import com.todoroo.astrid.gtasks.GtasksIndentActionTest; +import com.todoroo.astrid.gtasks.GtasksListServiceTest; +import com.todoroo.astrid.gtasks.GtasksMetadataServiceTest; +import com.todoroo.astrid.gtasks.GtasksTaskListUpdaterTest; +import com.todoroo.astrid.gtasks.GtasksTaskMovingTest; +import com.todoroo.astrid.model.TaskTest; +import com.todoroo.astrid.provider.Astrid3ProviderTests; +import com.todoroo.astrid.reminders.NotificationTests; +import com.todoroo.astrid.reminders.ReminderServiceTest; +import com.todoroo.astrid.repeats.NewRepeatTests; +import com.todoroo.astrid.service.QuickAddMarkupTest; +import com.todoroo.astrid.service.TitleParserTest; +import com.todoroo.astrid.subtasks.SubtasksHelperTest; +import com.todoroo.astrid.subtasks.SubtasksTestCase; +import com.todoroo.astrid.sync.NewSyncTestCase; + +import org.tasks.scheduling.BackupServiceTests; + +import javax.inject.Singleton; + +import dagger.Component; + +@Singleton +@Component(modules = TestModule.class) +public interface TestComponent { + void inject(ReminderServiceTest reminderServiceTest); + + void inject(TaskTest taskTest); + + void inject(TaskDaoTests taskDaoTests); + + void inject(MetadataDaoTests metadataDaoTests); + + void inject(Astrid3ProviderTests astrid3ProviderTests); + + void inject(NewSyncTestCase newSyncTestCase); + + void inject(SubtasksTestCase subtasksTestCase); + + void inject(SubtasksHelperTest subtasksHelperTest); + + void inject(QuickAddMarkupTest quickAddMarkupTest); + + void inject(TitleParserTest titleParserTest); + + void inject(NewRepeatTests newRepeatTests); + + void inject(BackupServiceTests backupServiceTests); + + void inject(GtasksIndentActionTest gtasksIndentActionTest); + + void inject(GtasksTaskMovingTest gtasksTaskMovingTest); + + void inject(GtasksListServiceTest gtasksListServiceTest); + + void inject(GtasksTaskListUpdaterTest gtasksTaskListUpdaterTest); + + GtasksMetadataServiceTest.GtasksMetadataServiceTestComponent plus(GtasksMetadataServiceTest.GtasksMetadataServiceTestModule gtasksMetadataServiceTestModule); + + NotificationTests.NotificationTestsComponent plus(NotificationTests.NotificationTestsModule notificationTestsModule); +} diff --git a/src/androidTest/java/org/tasks/injection/TestModule.java b/src/androidTest/java/org/tasks/injection/TestModule.java index 1fb46e16b..4e277376d 100644 --- a/src/androidTest/java/org/tasks/injection/TestModule.java +++ b/src/androidTest/java/org/tasks/injection/TestModule.java @@ -27,26 +27,7 @@ import javax.inject.Singleton; import dagger.Module; import dagger.Provides; -@Module(injects = { - BackupServiceTests.class, - MetadataDaoTests.class, - TaskDaoTests.class, - GtasksIndentActionTest.class, - GtasksTaskListUpdaterTest.class, - GtasksTaskMovingTest.class, - Astrid3ProviderTests.class, - NewRepeatTests.class, - QuickAddMarkupTest.class, - TitleParserTest.class, - SubtasksTestCase.class, - NewSyncTestCase.class, - TaskTest.class, - ReminderServiceTest.class, - SubtasksHelperTest.class, - SubtasksMovingTest.class, - SyncModelTest.class, - GtasksListServiceTest.class -}) +@Module public class TestModule { private Context context; diff --git a/src/androidTest/java/org/tasks/scheduling/BackupServiceTests.java b/src/androidTest/java/org/tasks/scheduling/BackupServiceTests.java index a903f64c3..fd394db18 100644 --- a/src/androidTest/java/org/tasks/scheduling/BackupServiceTests.java +++ b/src/androidTest/java/org/tasks/scheduling/BackupServiceTests.java @@ -12,6 +12,7 @@ import com.todoroo.astrid.data.Task; import com.todoroo.astrid.test.DatabaseTestCase; import org.tasks.R; +import org.tasks.injection.TestComponent; import org.tasks.preferences.Preferences; import java.io.File; @@ -55,6 +56,11 @@ public class BackupServiceTests extends DatabaseTestCase { taskDao.createNew(task); } + @Override + protected void inject(TestComponent component) { + component.inject(this); + } + @Override protected void tearDown() { super.tearDown(); diff --git a/src/androidTestGoogleplay/java/com/todoroo/astrid/gtasks/GtasksIndentActionTest.java b/src/androidTestGoogleplay/java/com/todoroo/astrid/gtasks/GtasksIndentActionTest.java index 9b5526d67..814f286ac 100644 --- a/src/androidTestGoogleplay/java/com/todoroo/astrid/gtasks/GtasksIndentActionTest.java +++ b/src/androidTestGoogleplay/java/com/todoroo/astrid/gtasks/GtasksIndentActionTest.java @@ -6,13 +6,14 @@ package com.todoroo.astrid.gtasks; import com.google.api.services.tasks.model.TaskList; -import com.google.api.services.tasks.model.TaskLists; import com.todoroo.astrid.dao.MetadataDao; import com.todoroo.astrid.data.Metadata; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.service.TaskService; import com.todoroo.astrid.test.DatabaseTestCase; +import org.tasks.injection.TestComponent; + import java.util.ArrayList; import java.util.List; @@ -140,18 +141,21 @@ public class GtasksIndentActionTest extends DatabaseTestCase { protected void setUp() { super.setUp(); - TaskLists lists = new TaskLists(); List items = new ArrayList<>(); TaskList list = new TaskList(); list.setId("list"); list.setTitle("Test Tasks"); items.add(list); - lists.setItems(items); - gtasksListService.updateLists(lists); + gtasksListService.updateLists(items); storeList = gtasksListService.getLists().get(0); } + @Override + protected void inject(TestComponent component) { + component.inject(this); + } + private Task taskWithMetadata(long order, int indentation) { Task newTask = new Task(); taskService.save(newTask); diff --git a/src/androidTestGoogleplay/java/com/todoroo/astrid/gtasks/GtasksListServiceTest.java b/src/androidTestGoogleplay/java/com/todoroo/astrid/gtasks/GtasksListServiceTest.java index 5fbe1685e..21ce1fe6e 100644 --- a/src/androidTestGoogleplay/java/com/todoroo/astrid/gtasks/GtasksListServiceTest.java +++ b/src/androidTestGoogleplay/java/com/todoroo/astrid/gtasks/GtasksListServiceTest.java @@ -7,6 +7,7 @@ import com.todoroo.astrid.dao.Database; import com.todoroo.astrid.dao.StoreObjectDao; import com.todoroo.astrid.test.DatabaseTestCase; +import org.tasks.injection.TestComponent; import org.tasks.makers.RemoteGtaskListMaker; import javax.inject.Inject; @@ -36,6 +37,11 @@ public class GtasksListServiceTest extends DatabaseTestCase { gtasksListService = new GtasksListService(storeObjectDao); } + @Override + protected void inject(TestComponent component) { + component.inject(this); + } + public void testCreateNewList() { setLists(newRemoteList( with(RemoteGtaskListMaker.REMOTE_ID, "1"), @@ -94,7 +100,6 @@ public class GtasksListServiceTest extends DatabaseTestCase { } private void setLists(TaskList... list) { - gtasksListService.updateLists(new TaskLists().setItems( - asList(list))); + gtasksListService.updateLists(asList(list)); } } diff --git a/src/androidTestGoogleplay/java/com/todoroo/astrid/gtasks/GtasksMetadataServiceTest.java b/src/androidTestGoogleplay/java/com/todoroo/astrid/gtasks/GtasksMetadataServiceTest.java index ba0a143f3..894c06f42 100644 --- a/src/androidTestGoogleplay/java/com/todoroo/astrid/gtasks/GtasksMetadataServiceTest.java +++ b/src/androidTestGoogleplay/java/com/todoroo/astrid/gtasks/GtasksMetadataServiceTest.java @@ -13,19 +13,20 @@ import com.todoroo.astrid.data.Task; import com.todoroo.astrid.service.TaskService; import com.todoroo.astrid.test.DatabaseTestCase; -import org.tasks.injection.TestModule; +import org.tasks.injection.TestComponent; import org.tasks.preferences.Preferences; import javax.inject.Inject; import dagger.Module; import dagger.Provides; +import dagger.Subcomponent; @SuppressWarnings("nls") public class GtasksMetadataServiceTest extends DatabaseTestCase { - @Module(addsTo = TestModule.class, injects = {GtasksMetadataServiceTest.class}) - static class GtasksMetadataServiceTestModule { + @Module + public class GtasksMetadataServiceTestModule { private final GtasksTestPreferenceService service; public GtasksMetadataServiceTestModule(Context context) { @@ -43,6 +44,11 @@ public class GtasksMetadataServiceTest extends DatabaseTestCase { } } + @Subcomponent(modules = GtasksMetadataServiceTest.GtasksMetadataServiceTestModule.class) + public interface GtasksMetadataServiceTestComponent { + void inject(GtasksMetadataServiceTest gtasksMetadataServiceTest); + } + @Inject GtasksTestPreferenceService preferences; @Inject GtasksMetadataService gtasksMetadataService; @Inject MetadataDao metadataDao; @@ -61,6 +67,13 @@ public class GtasksMetadataServiceTest extends DatabaseTestCase { } } + @Override + protected void inject(TestComponent component) { + component + .plus(new GtasksMetadataServiceTestModule(getContext())) + .inject(this); + } + public void testMetadataFound() { givenTask(taskWithMetadata(null)); diff --git a/src/androidTestGoogleplay/java/com/todoroo/astrid/gtasks/GtasksTaskListUpdaterTest.java b/src/androidTestGoogleplay/java/com/todoroo/astrid/gtasks/GtasksTaskListUpdaterTest.java index 1d1f164b6..9523621fd 100644 --- a/src/androidTestGoogleplay/java/com/todoroo/astrid/gtasks/GtasksTaskListUpdaterTest.java +++ b/src/androidTestGoogleplay/java/com/todoroo/astrid/gtasks/GtasksTaskListUpdaterTest.java @@ -13,6 +13,8 @@ import com.todoroo.astrid.data.Task; import com.todoroo.astrid.service.TaskService; import com.todoroo.astrid.test.DatabaseTestCase; +import org.tasks.injection.TestComponent; + import java.util.ArrayList; import java.util.List; @@ -124,14 +126,17 @@ public class GtasksTaskListUpdaterTest extends DatabaseTestCase { protected void setUp() { super.setUp(); - TaskLists lists = new TaskLists(); List items = new ArrayList<>(); TaskList list = new TaskList(); list.setId("1"); list.setTitle("Tim's Tasks"); items.add(list); - lists.setItems(items); - gtasksListService.updateLists(lists); + gtasksListService.updateLists(items); + } + + @Override + protected void inject(TestComponent component) { + component.inject(this); } private void whenCalculatingParentsAndSiblings() { diff --git a/src/androidTestGoogleplay/java/com/todoroo/astrid/gtasks/GtasksTaskMovingTest.java b/src/androidTestGoogleplay/java/com/todoroo/astrid/gtasks/GtasksTaskMovingTest.java index 4020e0ffc..e4898a418 100644 --- a/src/androidTestGoogleplay/java/com/todoroo/astrid/gtasks/GtasksTaskMovingTest.java +++ b/src/androidTestGoogleplay/java/com/todoroo/astrid/gtasks/GtasksTaskMovingTest.java @@ -6,13 +6,14 @@ package com.todoroo.astrid.gtasks; import com.google.api.services.tasks.model.TaskList; -import com.google.api.services.tasks.model.TaskLists; import com.todoroo.astrid.dao.MetadataDao; import com.todoroo.astrid.data.Metadata; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.service.TaskService; import com.todoroo.astrid.test.DatabaseTestCase; +import org.tasks.injection.TestComponent; + import java.util.ArrayList; import java.util.List; @@ -246,18 +247,21 @@ public class GtasksTaskMovingTest extends DatabaseTestCase { protected void setUp() { super.setUp(); - TaskLists lists = new TaskLists(); List items = new ArrayList<>(); TaskList taskList = new TaskList(); taskList.setId("1"); taskList.setTitle("Tim's Tasks"); items.add(taskList); - lists.setItems(items); - gtasksListService.updateLists(lists); + gtasksListService.updateLists(items); list = gtasksListService.getLists().get(0); } + @Override + protected void inject(TestComponent component) { + component.inject(this); + } + /** * A * B diff --git a/src/androidTestGoogleplay/java/com/todoroo/astrid/gtasks/GtasksTestPreferenceService.java b/src/androidTestGoogleplay/java/com/todoroo/astrid/gtasks/GtasksTestPreferenceService.java index c1eaa7f94..f62f6f33e 100644 --- a/src/androidTestGoogleplay/java/com/todoroo/astrid/gtasks/GtasksTestPreferenceService.java +++ b/src/androidTestGoogleplay/java/com/todoroo/astrid/gtasks/GtasksTestPreferenceService.java @@ -7,13 +7,14 @@ package com.todoroo.astrid.gtasks; import android.content.Context; +import org.tasks.AccountManager; import org.tasks.preferences.PermissionChecker; import org.tasks.preferences.Preferences; public class GtasksTestPreferenceService extends GtasksPreferenceService { - public GtasksTestPreferenceService(Context context, Preferences preferences, PermissionChecker permissionChecker) { - super(context, preferences, permissionChecker); + public GtasksTestPreferenceService(Context context, Preferences preferences, AccountManager accountManager) { + super(context, preferences, accountManager); } @Override diff --git a/src/googleplay/java/com/todoroo/astrid/gtasks/GtasksPreferences.java b/src/googleplay/java/com/todoroo/astrid/gtasks/GtasksPreferences.java index 409867c29..f2fc39046 100644 --- a/src/googleplay/java/com/todoroo/astrid/gtasks/GtasksPreferences.java +++ b/src/googleplay/java/com/todoroo/astrid/gtasks/GtasksPreferences.java @@ -16,6 +16,7 @@ import com.todoroo.astrid.gtasks.auth.GtasksLoginActivity; import org.tasks.R; import org.tasks.activities.ClearGtaskDataActivity; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingPreferenceActivity; import org.tasks.preferences.ActivityPermissionRequestor; import org.tasks.preferences.PermissionRequestor; @@ -101,4 +102,9 @@ public class GtasksPreferences extends InjectingPreferenceActivity { super.onPause(); backgroundScheduler.scheduleGtaskSync(); } + + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } } diff --git a/src/googleplay/java/com/todoroo/astrid/gtasks/auth/GtasksLoginActivity.java b/src/googleplay/java/com/todoroo/astrid/gtasks/auth/GtasksLoginActivity.java index cdef9c958..39a1a9b27 100644 --- a/src/googleplay/java/com/todoroo/astrid/gtasks/auth/GtasksLoginActivity.java +++ b/src/googleplay/java/com/todoroo/astrid/gtasks/auth/GtasksLoginActivity.java @@ -19,6 +19,7 @@ import org.tasks.AccountManager; import org.tasks.R; import org.tasks.dialogs.AccountSelectionDialog; import org.tasks.dialogs.DialogBuilder; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingAppCompatActivity; import javax.inject.Inject; @@ -62,6 +63,11 @@ public class GtasksLoginActivity extends InjectingAppCompatActivity implements A } } + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } + private void getAuthToken(String account) { final ProgressDialog pd = dialogBuilder.newProgressDialog(R.string.gtasks_GLA_authenticating); pd.show(); diff --git a/src/googleplay/java/org/tasks/activities/ClearGtaskDataActivity.java b/src/googleplay/java/org/tasks/activities/ClearGtaskDataActivity.java index da5bafce0..94ba6ef5a 100644 --- a/src/googleplay/java/org/tasks/activities/ClearGtaskDataActivity.java +++ b/src/googleplay/java/org/tasks/activities/ClearGtaskDataActivity.java @@ -7,6 +7,7 @@ import com.todoroo.astrid.gtasks.sync.GtasksSyncV2Provider; import org.tasks.R; import org.tasks.dialogs.DialogBuilder; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingAppCompatActivity; import javax.inject.Inject; @@ -37,4 +38,9 @@ public class ClearGtaskDataActivity extends InjectingAppCompatActivity { }) .show(); } + + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } } diff --git a/src/googleplay/java/org/tasks/activities/DonationActivity.java b/src/googleplay/java/org/tasks/activities/DonationActivity.java index 32862731d..2aa4375d1 100644 --- a/src/googleplay/java/org/tasks/activities/DonationActivity.java +++ b/src/googleplay/java/org/tasks/activities/DonationActivity.java @@ -12,6 +12,7 @@ import org.tasks.billing.IabResult; import org.tasks.billing.Inventory; import org.tasks.billing.Purchase; import org.tasks.dialogs.DialogBuilder; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingAppCompatActivity; import java.util.ArrayList; @@ -73,6 +74,11 @@ public class DonationActivity extends InjectingAppCompatActivity implements IabH .show(); } + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } + private void initiateDonation(int amount) { final String sku = String.format("%03d", amount); if (inventory != null && inventory.hasPurchase(sku)) { diff --git a/src/googleplay/java/org/tasks/dialogs/AccountSelectionDialog.java b/src/googleplay/java/org/tasks/dialogs/AccountSelectionDialog.java index aa5f316f6..034c9b76e 100644 --- a/src/googleplay/java/org/tasks/dialogs/AccountSelectionDialog.java +++ b/src/googleplay/java/org/tasks/dialogs/AccountSelectionDialog.java @@ -7,6 +7,7 @@ import android.support.annotation.NonNull; import org.tasks.AccountManager; import org.tasks.R; +import org.tasks.injection.DialogFragmentComponent; import org.tasks.injection.InjectingDialogFragment; import java.util.List; @@ -17,6 +18,11 @@ public class AccountSelectionDialog extends InjectingDialogFragment { private AccountSelectionHandler handler; + @Override + protected void inject(DialogFragmentComponent component) { + component.inject(this); + } + public interface AccountSelectionHandler { void accountSelected(String account); diff --git a/src/googleplay/java/org/tasks/location/GeofenceTransitionsIntentService.java b/src/googleplay/java/org/tasks/location/GeofenceTransitionsIntentService.java index bc730d4c5..7847df81d 100644 --- a/src/googleplay/java/org/tasks/location/GeofenceTransitionsIntentService.java +++ b/src/googleplay/java/org/tasks/location/GeofenceTransitionsIntentService.java @@ -9,6 +9,7 @@ import com.todoroo.astrid.reminders.ReminderService; import org.tasks.Notifier; import org.tasks.injection.InjectingIntentService; +import org.tasks.injection.IntentServiceComponent; import java.util.List; @@ -47,6 +48,11 @@ public class GeofenceTransitionsIntentService extends InjectingIntentService { } } + @Override + protected void inject(IntentServiceComponent component) { + component.inject(this); + } + private void triggerNotification(com.google.android.gms.location.Geofence triggeringGeofence) { String requestId = triggeringGeofence.getRequestId(); try { diff --git a/src/googleplay/java/org/tasks/scheduling/GtasksBackgroundService.java b/src/googleplay/java/org/tasks/scheduling/GtasksBackgroundService.java index c10eb1539..214c5967a 100644 --- a/src/googleplay/java/org/tasks/scheduling/GtasksBackgroundService.java +++ b/src/googleplay/java/org/tasks/scheduling/GtasksBackgroundService.java @@ -5,6 +5,7 @@ import com.todoroo.astrid.gtasks.sync.GtasksSyncV2Provider; import org.tasks.Broadcaster; import org.tasks.R; +import org.tasks.injection.IntentServiceComponent; import org.tasks.preferences.Preferences; import org.tasks.sync.RecordSyncStatusCallback; @@ -51,4 +52,9 @@ public class GtasksBackgroundService extends RecurringIntervalIntentService { String getLastRunPreference() { return "gtasks_last_sync"; } + + @Override + protected void inject(IntentServiceComponent component) { + component.inject(this); + } } diff --git a/src/main/java/com/todoroo/astrid/actfm/FilterSettingsActivity.java b/src/main/java/com/todoroo/astrid/actfm/FilterSettingsActivity.java index 6f7736af2..b615bcb4e 100644 --- a/src/main/java/com/todoroo/astrid/actfm/FilterSettingsActivity.java +++ b/src/main/java/com/todoroo/astrid/actfm/FilterSettingsActivity.java @@ -24,6 +24,7 @@ import com.todoroo.astrid.dao.StoreObjectDao; import org.tasks.R; import org.tasks.dialogs.DialogBuilder; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingAppCompatActivity; import org.tasks.preferences.ActivityPreferences; import org.tasks.ui.MenuColorizer; @@ -70,6 +71,11 @@ public class FilterSettingsActivity extends InjectingAppCompatActivity { filterName.setText(filter.listingTitle); } + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } + private void save() { String oldName = filter.listingTitle; String newName = filterName.getText().toString().trim(); diff --git a/src/main/java/com/todoroo/astrid/actfm/TagSettingsActivity.java b/src/main/java/com/todoroo/astrid/actfm/TagSettingsActivity.java index 503811ec0..16e923507 100644 --- a/src/main/java/com/todoroo/astrid/actfm/TagSettingsActivity.java +++ b/src/main/java/com/todoroo/astrid/actfm/TagSettingsActivity.java @@ -34,6 +34,7 @@ import com.todoroo.astrid.tags.TaskToTagMetadata; import org.tasks.R; import org.tasks.dialogs.DialogBuilder; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingAppCompatActivity; import org.tasks.preferences.ActivityPreferences; import org.tasks.ui.MenuColorizer; @@ -112,6 +113,11 @@ public class TagSettingsActivity extends InjectingAppCompatActivity { } } + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } + private String getNewName() { return tagName.getText().toString().trim(); } diff --git a/src/main/java/com/todoroo/astrid/activity/BeastModePreferences.java b/src/main/java/com/todoroo/astrid/activity/BeastModePreferences.java index b4c90e294..6b05266e0 100644 --- a/src/main/java/com/todoroo/astrid/activity/BeastModePreferences.java +++ b/src/main/java/com/todoroo/astrid/activity/BeastModePreferences.java @@ -25,6 +25,7 @@ import com.commonsware.cwac.tlv.TouchListView; import com.commonsware.cwac.tlv.TouchListView.DropListener; import org.tasks.R; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingAppCompatActivity; import org.tasks.preferences.ActivityPreferences; import org.tasks.preferences.Preferences; @@ -109,6 +110,11 @@ public class BeastModePreferences extends InjectingAppCompatActivity { }); } + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } + @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.beast_mode, menu); diff --git a/src/main/java/com/todoroo/astrid/activity/FilterShortcutActivity.java b/src/main/java/com/todoroo/astrid/activity/FilterShortcutActivity.java index ec8f92099..6cb95e0fc 100644 --- a/src/main/java/com/todoroo/astrid/activity/FilterShortcutActivity.java +++ b/src/main/java/com/todoroo/astrid/activity/FilterShortcutActivity.java @@ -23,6 +23,7 @@ import org.tasks.R; import org.tasks.dialogs.DialogBuilder; import org.tasks.filters.FilterCounter; import org.tasks.filters.FilterProvider; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.ForApplication; import org.tasks.injection.InjectingListActivity; import org.tasks.preferences.ActivityPreferences; @@ -137,4 +138,9 @@ public class FilterShortcutActivity extends InjectingListActivity { super.onPause(); adapter.unregisterRecevier(); } + + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } } diff --git a/src/main/java/com/todoroo/astrid/activity/ShareLinkActivity.java b/src/main/java/com/todoroo/astrid/activity/ShareLinkActivity.java index b569500c0..a9c5eaa4a 100644 --- a/src/main/java/com/todoroo/astrid/activity/ShareLinkActivity.java +++ b/src/main/java/com/todoroo/astrid/activity/ShareLinkActivity.java @@ -11,6 +11,7 @@ import com.todoroo.astrid.service.StartupService; import com.todoroo.astrid.service.TaskCreator; import com.todoroo.astrid.service.TaskService; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingAppCompatActivity; import javax.inject.Inject; @@ -37,6 +38,11 @@ public final class ShareLinkActivity extends InjectingAppCompatActivity { readIntent(); } + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } + @Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); diff --git a/src/main/java/com/todoroo/astrid/activity/ShortcutActivity.java b/src/main/java/com/todoroo/astrid/activity/ShortcutActivity.java index 3288745d1..7dd0e29fb 100644 --- a/src/main/java/com/todoroo/astrid/activity/ShortcutActivity.java +++ b/src/main/java/com/todoroo/astrid/activity/ShortcutActivity.java @@ -14,6 +14,7 @@ import com.todoroo.andlib.utility.AndroidUtilities; import com.todoroo.astrid.api.Filter; import com.todoroo.astrid.api.FilterWithCustomIntent; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingAppCompatActivity; import java.util.Set; @@ -58,6 +59,11 @@ public class ShortcutActivity extends InjectingAppCompatActivity { launchShortcut(); } + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } + @Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); diff --git a/src/main/java/com/todoroo/astrid/activity/TaskEditFragment.java b/src/main/java/com/todoroo/astrid/activity/TaskEditFragment.java index f62dadc72..7654e0865 100755 --- a/src/main/java/com/todoroo/astrid/activity/TaskEditFragment.java +++ b/src/main/java/com/todoroo/astrid/activity/TaskEditFragment.java @@ -38,6 +38,7 @@ import org.tasks.analytics.Tracker; import org.tasks.dialogs.DialogBuilder; import org.tasks.fragments.TaskEditControlSetFragmentManager; import org.tasks.injection.ForActivity; +import org.tasks.injection.FragmentComponent; import org.tasks.injection.InjectingFragment; import org.tasks.notifications.NotificationManager; import org.tasks.preferences.Preferences; @@ -104,6 +105,11 @@ public final class TaskEditFragment extends InjectingFragment implements Toolbar callback = (TaskEditFragmentCallbackHandler) activity; } + @Override + protected void inject(FragmentComponent component) { + component.inject(this); + } + @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_task_edit, container, false); diff --git a/src/main/java/com/todoroo/astrid/activity/TaskListActivity.java b/src/main/java/com/todoroo/astrid/activity/TaskListActivity.java index 82121244e..9b07701b7 100644 --- a/src/main/java/com/todoroo/astrid/activity/TaskListActivity.java +++ b/src/main/java/com/todoroo/astrid/activity/TaskListActivity.java @@ -34,6 +34,7 @@ import com.todoroo.astrid.timers.TimerControlSet; import org.tasks.R; import org.tasks.fragments.CommentBarFragment; import org.tasks.fragments.TaskEditControlSetFragmentManager; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingAppCompatActivity; import org.tasks.intents.TaskIntents; import org.tasks.preferences.ActivityPreferences; @@ -189,6 +190,11 @@ public class TaskListActivity extends InjectingAppCompatActivity implements new IntentFilter(AstridApiConstants.BROADCAST_EVENT_TASK_REPEATED)); } + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } + @Override protected void onPause() { super.onPause(); diff --git a/src/main/java/com/todoroo/astrid/activity/TaskListFragment.java b/src/main/java/com/todoroo/astrid/activity/TaskListFragment.java index 29796e9b6..071437d92 100644 --- a/src/main/java/com/todoroo/astrid/activity/TaskListFragment.java +++ b/src/main/java/com/todoroo/astrid/activity/TaskListFragment.java @@ -82,6 +82,7 @@ import org.tasks.R; import org.tasks.activities.SortActivity; import org.tasks.dialogs.DialogBuilder; import org.tasks.injection.ForActivity; +import org.tasks.injection.FragmentComponent; import org.tasks.injection.InjectingListFragment; import org.tasks.notifications.NotificationManager; import org.tasks.preferences.ActivityPreferences; @@ -203,6 +204,11 @@ public class TaskListFragment extends InjectingListFragment implements SwipeRefr callbacks = (TaskListFragmentCallbackHandler) activity; } + @Override + public void inject(FragmentComponent component) { + component.inject(this); + } + /** * @return view to attach to the body of the task list. must contain two * elements, a view with id android:id/empty and a list view with id diff --git a/src/main/java/com/todoroo/astrid/alarms/AlarmTaskRepeatListener.java b/src/main/java/com/todoroo/astrid/alarms/AlarmTaskRepeatListener.java index 9a053d4d6..18a7b2ad6 100644 --- a/src/main/java/com/todoroo/astrid/alarms/AlarmTaskRepeatListener.java +++ b/src/main/java/com/todoroo/astrid/alarms/AlarmTaskRepeatListener.java @@ -13,6 +13,7 @@ import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.astrid.api.AstridApiConstants; import com.todoroo.astrid.data.Metadata; +import org.tasks.injection.BroadcastComponent; import org.tasks.injection.InjectingBroadcastReceiver; import java.util.LinkedHashSet; @@ -52,4 +53,9 @@ public class AlarmTaskRepeatListener extends InjectingBroadcastReceiver { alarmService.synchronizeAlarms(taskId, alarms); } } + + @Override + protected void inject(BroadcastComponent component) { + component.inject(this); + } } diff --git a/src/main/java/com/todoroo/astrid/calls/PhoneStateChangedReceiver.java b/src/main/java/com/todoroo/astrid/calls/PhoneStateChangedReceiver.java index a0a8a376f..572e69a86 100644 --- a/src/main/java/com/todoroo/astrid/calls/PhoneStateChangedReceiver.java +++ b/src/main/java/com/todoroo/astrid/calls/PhoneStateChangedReceiver.java @@ -18,6 +18,7 @@ import com.todoroo.andlib.utility.AndroidUtilities; import com.todoroo.andlib.utility.DateUtilities; import org.tasks.Notifier; +import org.tasks.injection.BroadcastComponent; import org.tasks.injection.InjectingBroadcastReceiver; import org.tasks.preferences.Preferences; @@ -132,6 +133,11 @@ public class PhoneStateChangedReceiver extends InjectingBroadcastReceiver { } } + @Override + protected void inject(BroadcastComponent component) { + component.inject(this); + } + private String digitsOnly(String number) { if (number == null) { return ""; diff --git a/src/main/java/com/todoroo/astrid/core/CustomFilterActivity.java b/src/main/java/com/todoroo/astrid/core/CustomFilterActivity.java index effc6fdf7..8ffe9849f 100644 --- a/src/main/java/com/todoroo/astrid/core/CustomFilterActivity.java +++ b/src/main/java/com/todoroo/astrid/core/CustomFilterActivity.java @@ -28,7 +28,6 @@ import android.widget.ListView; import com.todoroo.andlib.data.Property.CountProperty; import com.todoroo.andlib.sql.Query; import com.todoroo.andlib.sql.UnaryCriterion; -import com.todoroo.andlib.utility.AndroidUtilities; import com.todoroo.astrid.actfm.TagSettingsActivity; import com.todoroo.astrid.api.CustomFilter; import com.todoroo.astrid.api.CustomFilterCriterion; @@ -45,6 +44,7 @@ import com.todoroo.astrid.data.Task; import org.tasks.R; import org.tasks.dialogs.DialogBuilder; import org.tasks.filters.FilterCriteriaProvider; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingAppCompatActivity; import org.tasks.preferences.ActivityPreferences; import org.tasks.ui.MenuColorizer; @@ -178,6 +178,11 @@ public class CustomFilterActivity extends InjectingAppCompatActivity { setUpListeners(); } + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } + private CriterionInstance getStartingUniverse() { CriterionInstance instance = new CriterionInstance(); instance.criterion = new MultipleSelectCriterion(IDENTIFIER_UNIVERSE, diff --git a/src/main/java/com/todoroo/astrid/core/DefaultsPreferences.java b/src/main/java/com/todoroo/astrid/core/DefaultsPreferences.java index 4b9d55cfd..eb43c0b48 100644 --- a/src/main/java/com/todoroo/astrid/core/DefaultsPreferences.java +++ b/src/main/java/com/todoroo/astrid/core/DefaultsPreferences.java @@ -14,6 +14,7 @@ import org.tasks.R; import org.tasks.activities.CalendarSelectionActivity; import org.tasks.calendars.AndroidCalendar; import org.tasks.calendars.CalendarProvider; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingPreferenceActivity; import org.tasks.preferences.ActivityPermissionRequestor; import org.tasks.preferences.PermissionRequestor; @@ -91,4 +92,9 @@ public class DefaultsPreferences extends InjectingPreferenceActivity { super.onActivityResult(requestCode, resultCode, data); } } + + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } } diff --git a/src/main/java/com/todoroo/astrid/core/OldTaskPreferences.java b/src/main/java/com/todoroo/astrid/core/OldTaskPreferences.java index 7299d0d07..b8f9c3a69 100644 --- a/src/main/java/com/todoroo/astrid/core/OldTaskPreferences.java +++ b/src/main/java/com/todoroo/astrid/core/OldTaskPreferences.java @@ -10,6 +10,7 @@ import android.os.Bundle; import com.todoroo.astrid.service.StartupService; import org.tasks.R; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingPreferenceActivity; import javax.inject.Inject; @@ -26,4 +27,9 @@ public class OldTaskPreferences extends InjectingPreferenceActivity { addPreferencesFromResource(R.xml.preferences_oldtasks); } + + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } } diff --git a/src/main/java/com/todoroo/astrid/files/AACRecordingActivity.java b/src/main/java/com/todoroo/astrid/files/AACRecordingActivity.java index 4ccce521b..a4eee35a1 100644 --- a/src/main/java/com/todoroo/astrid/files/AACRecordingActivity.java +++ b/src/main/java/com/todoroo/astrid/files/AACRecordingActivity.java @@ -14,6 +14,7 @@ import com.todoroo.astrid.voice.AACRecorder; import com.todoroo.astrid.voice.AACRecorder.AACRecorderCallbacks; import org.tasks.R; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingAppCompatActivity; import org.tasks.preferences.ActivityPermissionRequestor; import org.tasks.preferences.PermissionRequestor; @@ -49,6 +50,11 @@ public class AACRecordingActivity extends InjectingAppCompatActivity implements } } + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } + private void startRecording() { setContentView(R.layout.aac_record_activity); ButterKnife.bind(this); diff --git a/src/main/java/com/todoroo/astrid/files/FilesControlSet.java b/src/main/java/com/todoroo/astrid/files/FilesControlSet.java index b350760da..9a648f7b9 100644 --- a/src/main/java/com/todoroo/astrid/files/FilesControlSet.java +++ b/src/main/java/com/todoroo/astrid/files/FilesControlSet.java @@ -36,6 +36,7 @@ import org.tasks.R; import org.tasks.activities.AddAttachmentActivity; import org.tasks.dialogs.DialogBuilder; import org.tasks.injection.ForActivity; +import org.tasks.injection.FragmentComponent; import org.tasks.ui.TaskEditControlFragment; import java.io.File; @@ -197,6 +198,11 @@ public class FilesControlSet extends TaskEditControlFragment { addAttachment.setVisibility(View.GONE); } + @Override + protected void inject(FragmentComponent component) { + component.inject(this); + } + public interface PlaybackExceptionHandler { void playbackFailed(); } diff --git a/src/main/java/com/todoroo/astrid/gcal/CalendarAlarmReceiver.java b/src/main/java/com/todoroo/astrid/gcal/CalendarAlarmReceiver.java index e0b046fc2..e56d6e3ed 100644 --- a/src/main/java/com/todoroo/astrid/gcal/CalendarAlarmReceiver.java +++ b/src/main/java/com/todoroo/astrid/gcal/CalendarAlarmReceiver.java @@ -13,6 +13,7 @@ import org.tasks.R; import org.tasks.calendars.AndroidCalendarEvent; import org.tasks.calendars.AndroidCalendarEventAttendee; import org.tasks.calendars.CalendarEventProvider; +import org.tasks.injection.BroadcastComponent; import org.tasks.injection.InjectingBroadcastReceiver; import org.tasks.preferences.Preferences; import org.tasks.scheduling.CalendarNotificationIntentService; @@ -66,6 +67,11 @@ public class CalendarAlarmReceiver extends InjectingBroadcastReceiver { } } + @Override + protected void inject(BroadcastComponent component) { + component.inject(this); + } + private void showCalReminder(Context context, final long eventId, final boolean fromPostpone) { final AndroidCalendarEvent event = calendarEventProvider.getEvent(eventId); if (event == null) { diff --git a/src/main/java/com/todoroo/astrid/gcal/CalendarReminderActivity.java b/src/main/java/com/todoroo/astrid/gcal/CalendarReminderActivity.java index 3bd30f2cc..2602f8ada 100644 --- a/src/main/java/com/todoroo/astrid/gcal/CalendarReminderActivity.java +++ b/src/main/java/com/todoroo/astrid/gcal/CalendarReminderActivity.java @@ -15,6 +15,7 @@ import com.todoroo.astrid.service.StartupService; import org.tasks.R; import org.tasks.dialogs.DialogBuilder; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingAppCompatActivity; import org.tasks.preferences.ActivityPreferences; import org.tasks.preferences.BasicPreferences; @@ -116,6 +117,11 @@ public class CalendarReminderActivity extends InjectingAppCompatActivity { addListeners(); } + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } + private void setupUi() { ((TextView) findViewById(R.id.reminder_title)) .setText(getString(R.string.CRA_title)); diff --git a/src/main/java/com/todoroo/astrid/gcal/GCalTaskCompleteListener.java b/src/main/java/com/todoroo/astrid/gcal/GCalTaskCompleteListener.java index 2228dc87e..adf070dba 100644 --- a/src/main/java/com/todoroo/astrid/gcal/GCalTaskCompleteListener.java +++ b/src/main/java/com/todoroo/astrid/gcal/GCalTaskCompleteListener.java @@ -18,6 +18,7 @@ import com.todoroo.astrid.data.Task; import com.todoroo.astrid.service.TaskService; import org.tasks.R; +import org.tasks.injection.BroadcastComponent; import org.tasks.injection.InjectingBroadcastReceiver; import javax.inject.Inject; @@ -57,4 +58,9 @@ public class GCalTaskCompleteListener extends InjectingBroadcastReceiver { } } + @Override + protected void inject(BroadcastComponent component) { + component.inject(this); + } + } diff --git a/src/main/java/com/todoroo/astrid/provider/Astrid2TaskProvider.java b/src/main/java/com/todoroo/astrid/provider/Astrid2TaskProvider.java index bbb487611..6a84aa96c 100644 --- a/src/main/java/com/todoroo/astrid/provider/Astrid2TaskProvider.java +++ b/src/main/java/com/todoroo/astrid/provider/Astrid2TaskProvider.java @@ -24,6 +24,7 @@ import com.todoroo.astrid.data.Task; import com.todoroo.astrid.service.TaskService; import com.todoroo.astrid.tags.TagService; +import org.tasks.injection.ContentProviderComponent; import org.tasks.injection.InjectingContentProvider; import org.tasks.ui.CheckBoxes; @@ -110,6 +111,11 @@ public class Astrid2TaskProvider extends InjectingContentProvider { return false; } + @Override + protected void inject(ContentProviderComponent component) { + component.inject(this); + } + /** * Note: tag id is no longer a real column, so we pass in a UID * generated from the tag string. diff --git a/src/main/java/com/todoroo/astrid/provider/Astrid3ContentProvider.java b/src/main/java/com/todoroo/astrid/provider/Astrid3ContentProvider.java index 61a0ce141..bece6cdfc 100644 --- a/src/main/java/com/todoroo/astrid/provider/Astrid3ContentProvider.java +++ b/src/main/java/com/todoroo/astrid/provider/Astrid3ContentProvider.java @@ -27,6 +27,7 @@ import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.UserActivity; import org.tasks.BuildConfig; +import org.tasks.injection.ContentProviderComponent; import org.tasks.injection.InjectingContentProvider; import java.util.HashSet; @@ -118,6 +119,11 @@ public class Astrid3ContentProvider extends InjectingContentProvider { } } + @Override + protected void inject(ContentProviderComponent component) { + component.inject(this); + } + /* ====================================================================== * ========================================================== helpers === * ====================================================================== */ diff --git a/src/main/java/com/todoroo/astrid/provider/SqlContentProvider.java b/src/main/java/com/todoroo/astrid/provider/SqlContentProvider.java index bbbae5c28..2b6291c17 100644 --- a/src/main/java/com/todoroo/astrid/provider/SqlContentProvider.java +++ b/src/main/java/com/todoroo/astrid/provider/SqlContentProvider.java @@ -14,6 +14,7 @@ import com.todoroo.astrid.api.AstridApiConstants; import com.todoroo.astrid.dao.Database; import org.tasks.BuildConfig; +import org.tasks.injection.ContentProviderComponent; import org.tasks.injection.InjectingContentProvider; import javax.inject.Inject; @@ -121,4 +122,9 @@ public class SqlContentProvider extends InjectingContentProvider { return database.get(); } + + @Override + protected void inject(ContentProviderComponent component) { + component.inject(this); + } } diff --git a/src/main/java/com/todoroo/astrid/reminders/ReminderPreferences.java b/src/main/java/com/todoroo/astrid/reminders/ReminderPreferences.java index 855fb15a6..22ec45c07 100644 --- a/src/main/java/com/todoroo/astrid/reminders/ReminderPreferences.java +++ b/src/main/java/com/todoroo/astrid/reminders/ReminderPreferences.java @@ -17,6 +17,7 @@ import android.preference.PreferenceManager; import org.tasks.R; import org.tasks.activities.TimePickerActivity; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingPreferenceActivity; import org.tasks.preferences.ActivityPermissionRequestor; import org.tasks.preferences.Device; @@ -186,4 +187,9 @@ public class ReminderPreferences extends InjectingPreferenceActivity { private TimePreference getTimePreference(int resId) { return (TimePreference) findPreference(getString(resId)); } + + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } } diff --git a/src/main/java/com/todoroo/astrid/repeats/RepeatControlSet.java b/src/main/java/com/todoroo/astrid/repeats/RepeatControlSet.java index f94e481da..035b1879f 100644 --- a/src/main/java/com/todoroo/astrid/repeats/RepeatControlSet.java +++ b/src/main/java/com/todoroo/astrid/repeats/RepeatControlSet.java @@ -42,6 +42,7 @@ import org.tasks.R; import org.tasks.activities.DatePickerActivity; import org.tasks.dialogs.DialogBuilder; import org.tasks.injection.ForActivity; +import org.tasks.injection.FragmentComponent; import org.tasks.preferences.ActivityPreferences; import org.tasks.time.DateTime; import org.tasks.ui.TaskEditControlFragment; @@ -291,6 +292,11 @@ public class RepeatControlSet extends TaskEditControlFragment { callback = (RepeatChangedListener) activity; } + @Override + protected void inject(FragmentComponent component) { + component.inject(this); + } + @OnClick(R.id.clear) void clearRepeat(View view) { doRepeat = false; diff --git a/src/main/java/com/todoroo/astrid/repeats/RepeatTaskCompleteListener.java b/src/main/java/com/todoroo/astrid/repeats/RepeatTaskCompleteListener.java index 9a631c7c9..ad6c25abf 100644 --- a/src/main/java/com/todoroo/astrid/repeats/RepeatTaskCompleteListener.java +++ b/src/main/java/com/todoroo/astrid/repeats/RepeatTaskCompleteListener.java @@ -22,6 +22,7 @@ import com.todoroo.astrid.data.Task; import com.todoroo.astrid.gcal.GCalHelper; import com.todoroo.astrid.service.TaskService; +import org.tasks.injection.BroadcastComponent; import org.tasks.injection.InjectingBroadcastReceiver; import org.tasks.time.DateTime; @@ -91,6 +92,11 @@ public class RepeatTaskCompleteListener extends InjectingBroadcastReceiver { } } + @Override + protected void inject(BroadcastComponent component) { + component.inject(this); + } + static boolean repeatFinished(long newDueDate, long repeatUntil) { return repeatUntil > 0 && newDateTime(newDueDate).startOfDay().isAfter(newDateTime(repeatUntil).startOfDay()); } diff --git a/src/main/java/com/todoroo/astrid/service/UpgradeActivity.java b/src/main/java/com/todoroo/astrid/service/UpgradeActivity.java index 91a53af7c..3b1d71563 100644 --- a/src/main/java/com/todoroo/astrid/service/UpgradeActivity.java +++ b/src/main/java/com/todoroo/astrid/service/UpgradeActivity.java @@ -15,6 +15,7 @@ import com.todoroo.astrid.api.AstridApiConstants; import org.tasks.R; import org.tasks.dialogs.DialogBuilder; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingAppCompatActivity; import org.tasks.preferences.Preferences; @@ -69,6 +70,11 @@ public class UpgradeActivity extends InjectingAppCompatActivity { } } + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } + @Override public void onBackPressed() { // Don't allow the back button to finish this activity before things are done diff --git a/src/main/java/com/todoroo/astrid/tags/TagsControlSet.java b/src/main/java/com/todoroo/astrid/tags/TagsControlSet.java index 6bf6cf085..c07f6dcd8 100644 --- a/src/main/java/com/todoroo/astrid/tags/TagsControlSet.java +++ b/src/main/java/com/todoroo/astrid/tags/TagsControlSet.java @@ -43,6 +43,7 @@ import com.todoroo.astrid.utility.Flags; import org.tasks.R; import org.tasks.dialogs.DialogBuilder; +import org.tasks.injection.FragmentComponent; import org.tasks.ui.TaskEditControlFragment; import java.util.ArrayList; @@ -401,4 +402,9 @@ public final class TagsControlSet extends TaskEditControlFragment { TaskToTagMetadata.TASK_UUID.eq(taskUuid), TaskToTagMetadata.TAG_UUID.eq(tag.getUuid())), deleteTemplate); } } + + @Override + protected void inject(FragmentComponent component) { + component.inject(this); + } } diff --git a/src/main/java/com/todoroo/astrid/timers/TimerControlSet.java b/src/main/java/com/todoroo/astrid/timers/TimerControlSet.java index 36e2de57e..c7f08018f 100644 --- a/src/main/java/com/todoroo/astrid/timers/TimerControlSet.java +++ b/src/main/java/com/todoroo/astrid/timers/TimerControlSet.java @@ -30,6 +30,7 @@ import com.todoroo.astrid.ui.TimeDurationControlSet; import org.tasks.R; import org.tasks.dialogs.DialogBuilder; import org.tasks.injection.ForActivity; +import org.tasks.injection.FragmentComponent; import org.tasks.preferences.ActivityPreferences; import org.tasks.ui.TaskEditControlFragment; @@ -100,6 +101,11 @@ public class TimerControlSet extends TaskEditControlFragment { callback = (TimerControlSetCallback) activity; } + @Override + protected void inject(FragmentComponent component) { + component.inject(this); + } + @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); diff --git a/src/main/java/com/todoroo/astrid/timers/TimerTaskCompleteListener.java b/src/main/java/com/todoroo/astrid/timers/TimerTaskCompleteListener.java index 58760ff42..f886be58a 100644 --- a/src/main/java/com/todoroo/astrid/timers/TimerTaskCompleteListener.java +++ b/src/main/java/com/todoroo/astrid/timers/TimerTaskCompleteListener.java @@ -12,6 +12,7 @@ import com.todoroo.astrid.api.AstridApiConstants; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.service.TaskService; +import org.tasks.injection.BroadcastComponent; import org.tasks.injection.InjectingBroadcastReceiver; import org.tasks.notifications.NotificationManager; @@ -39,4 +40,9 @@ public class TimerTaskCompleteListener extends InjectingBroadcastReceiver { TimerPlugin.stopTimer(notificationManager, taskService, context, task); } + + @Override + protected void inject(BroadcastComponent component) { + component.inject(this); + } } diff --git a/src/main/java/com/todoroo/astrid/ui/EditTitleControlSet.java b/src/main/java/com/todoroo/astrid/ui/EditTitleControlSet.java index a7199891d..28d4264b1 100644 --- a/src/main/java/com/todoroo/astrid/ui/EditTitleControlSet.java +++ b/src/main/java/com/todoroo/astrid/ui/EditTitleControlSet.java @@ -22,6 +22,7 @@ import com.todoroo.astrid.data.Task; import com.todoroo.astrid.service.TaskService; import org.tasks.R; +import org.tasks.injection.FragmentComponent; import org.tasks.ui.CheckBoxes; import org.tasks.ui.TaskEditControlFragment; @@ -65,6 +66,11 @@ public class EditTitleControlSet extends TaskEditControlFragment { checkBoxes = new CheckBoxes(activity); } + @Override + protected void inject(FragmentComponent component) { + component.inject(this); + } + @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { diff --git a/src/main/java/com/todoroo/astrid/ui/HideUntilControlSet.java b/src/main/java/com/todoroo/astrid/ui/HideUntilControlSet.java index 54a8315ed..656926416 100644 --- a/src/main/java/com/todoroo/astrid/ui/HideUntilControlSet.java +++ b/src/main/java/com/todoroo/astrid/ui/HideUntilControlSet.java @@ -27,6 +27,7 @@ import org.tasks.R; import org.tasks.activities.DateAndTimePickerActivity; import org.tasks.activities.TimePickerActivity; import org.tasks.injection.ForActivity; +import org.tasks.injection.FragmentComponent; import org.tasks.time.DateTime; import org.tasks.ui.HiddenTopArrayAdapter; import org.tasks.ui.TaskEditControlFragment; @@ -203,6 +204,11 @@ public class HideUntilControlSet extends TaskEditControlFragment implements OnIt outState.putInt(EXTRA_SELECTION, selection); } + @Override + protected void inject(FragmentComponent component) { + component.inject(this); + } + /** * Container class for urgencies * diff --git a/src/main/java/com/todoroo/astrid/ui/ReminderControlSet.java b/src/main/java/com/todoroo/astrid/ui/ReminderControlSet.java index 63140d5a2..e3d851900 100644 --- a/src/main/java/com/todoroo/astrid/ui/ReminderControlSet.java +++ b/src/main/java/com/todoroo/astrid/ui/ReminderControlSet.java @@ -33,6 +33,7 @@ import org.tasks.R; import org.tasks.activities.DateAndTimePickerActivity; import org.tasks.activities.TimePickerActivity; import org.tasks.injection.ForActivity; +import org.tasks.injection.FragmentComponent; import org.tasks.location.Geofence; import org.tasks.location.GeofenceService; import org.tasks.location.PlacePicker; @@ -423,4 +424,9 @@ public class ReminderControlSet extends TaskEditControlFragment { mode.setSelection(0); } } + + @Override + protected void inject(FragmentComponent component) { + component.inject(this); + } } diff --git a/src/main/java/com/todoroo/astrid/widget/TasksWidget.java b/src/main/java/com/todoroo/astrid/widget/TasksWidget.java index c700f8a49..80b837358 100644 --- a/src/main/java/com/todoroo/astrid/widget/TasksWidget.java +++ b/src/main/java/com/todoroo/astrid/widget/TasksWidget.java @@ -26,6 +26,7 @@ import com.todoroo.astrid.tags.TagFilterExposer; import org.tasks.Broadcaster; import org.tasks.R; +import org.tasks.injection.BroadcastComponent; import org.tasks.injection.InjectingAppWidgetProvider; import org.tasks.intents.TaskIntents; import org.tasks.preferences.Preferences; @@ -75,6 +76,11 @@ public class TasksWidget extends InjectingAppWidgetProvider { } } + @Override + protected void inject(BroadcastComponent component) { + component.inject(this); + } + @Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { try { diff --git a/src/main/java/com/todoroo/astrid/widget/WidgetConfigActivity.java b/src/main/java/com/todoroo/astrid/widget/WidgetConfigActivity.java index 15e852256..b5cc8a9c8 100644 --- a/src/main/java/com/todoroo/astrid/widget/WidgetConfigActivity.java +++ b/src/main/java/com/todoroo/astrid/widget/WidgetConfigActivity.java @@ -24,6 +24,7 @@ import com.todoroo.astrid.api.FilterWithCustomIntent; import org.tasks.R; import org.tasks.filters.FilterCounter; import org.tasks.filters.FilterProvider; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingListActivity; import org.tasks.preferences.ActivityPreferences; @@ -164,4 +165,9 @@ public class WidgetConfigActivity extends InjectingListActivity { } } } + + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } } diff --git a/src/main/java/org/tasks/Tasks.java b/src/main/java/org/tasks/Tasks.java index 57e8ec61d..ce9b358e2 100644 --- a/src/main/java/org/tasks/Tasks.java +++ b/src/main/java/org/tasks/Tasks.java @@ -21,6 +21,7 @@ import com.todoroo.astrid.tags.TagService; import org.tasks.analytics.Tracker; import org.tasks.filters.FilterCounter; +import org.tasks.injection.ApplicationComponent; import org.tasks.injection.InjectingApplication; import org.tasks.preferences.Preferences; import org.tasks.sync.SyncThrottle; @@ -88,4 +89,9 @@ public class Tasks extends InjectingApplication { } } } + + @Override + protected void inject(ApplicationComponent component) { + component.inject(this); + } } diff --git a/src/main/java/org/tasks/activities/AddAttachmentActivity.java b/src/main/java/org/tasks/activities/AddAttachmentActivity.java index c04a6cf1b..78790a2f8 100644 --- a/src/main/java/org/tasks/activities/AddAttachmentActivity.java +++ b/src/main/java/org/tasks/activities/AddAttachmentActivity.java @@ -17,6 +17,7 @@ import com.todoroo.astrid.files.AACRecordingActivity; import org.tasks.R; import org.tasks.dialogs.AddAttachmentDialog; import org.tasks.files.FileExplore; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingAppCompatActivity; import org.tasks.preferences.Preferences; @@ -58,6 +59,11 @@ public class AddAttachmentActivity extends InjectingAppCompatActivity implements dialog.setAddAttachmentCallback(this); } + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } + @Override public void onCancel(DialogInterface dialog) { finish(); diff --git a/src/main/java/org/tasks/activities/CalendarSelectionActivity.java b/src/main/java/org/tasks/activities/CalendarSelectionActivity.java index 2a3db88dd..6903e478d 100644 --- a/src/main/java/org/tasks/activities/CalendarSelectionActivity.java +++ b/src/main/java/org/tasks/activities/CalendarSelectionActivity.java @@ -7,6 +7,7 @@ import android.os.Bundle; import org.tasks.calendars.AndroidCalendar; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingAppCompatActivity; import org.tasks.preferences.ActivityPermissionRequestor; import org.tasks.preferences.ActivityPreferences; @@ -36,6 +37,11 @@ public class CalendarSelectionActivity extends InjectingAppCompatActivity implem } } + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } + @Override public void selectedCalendar(final AndroidCalendar androidCalendar) { setResult(RESULT_OK, new Intent() {{ diff --git a/src/main/java/org/tasks/activities/CalendarSelectionDialog.java b/src/main/java/org/tasks/activities/CalendarSelectionDialog.java index 827ba396a..8817f779b 100644 --- a/src/main/java/org/tasks/activities/CalendarSelectionDialog.java +++ b/src/main/java/org/tasks/activities/CalendarSelectionDialog.java @@ -13,6 +13,7 @@ import org.tasks.R; import org.tasks.calendars.AndroidCalendar; import org.tasks.calendars.CalendarProvider; import org.tasks.dialogs.DialogBuilder; +import org.tasks.injection.DialogFragmentComponent; import org.tasks.injection.InjectingDialogFragment; import java.util.List; @@ -27,6 +28,11 @@ public class CalendarSelectionDialog extends InjectingDialogFragment { enableNone = true; } + @Override + protected void inject(DialogFragmentComponent component) { + component.inject(this); + } + public interface CalendarSelectionHandler { void selectedCalendar(AndroidCalendar calendar); void dismiss(); diff --git a/src/main/java/org/tasks/activities/CameraActivity.java b/src/main/java/org/tasks/activities/CameraActivity.java index e2857ea8b..40b93f81b 100644 --- a/src/main/java/org/tasks/activities/CameraActivity.java +++ b/src/main/java/org/tasks/activities/CameraActivity.java @@ -9,6 +9,7 @@ import android.provider.MediaStore; import android.widget.Toast; import org.tasks.R; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingAppCompatActivity; import org.tasks.preferences.Preferences; @@ -58,6 +59,11 @@ public class CameraActivity extends InjectingAppCompatActivity { } } + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } + @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_CODE_CAMERA) { diff --git a/src/main/java/org/tasks/activities/ClearAllDataActivity.java b/src/main/java/org/tasks/activities/ClearAllDataActivity.java index 151bafd04..96a4b62d7 100644 --- a/src/main/java/org/tasks/activities/ClearAllDataActivity.java +++ b/src/main/java/org/tasks/activities/ClearAllDataActivity.java @@ -7,6 +7,7 @@ import com.todoroo.astrid.dao.Database; import org.tasks.R; import org.tasks.dialogs.DialogBuilder; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingAppCompatActivity; import javax.inject.Inject; @@ -37,4 +38,9 @@ public class ClearAllDataActivity extends InjectingAppCompatActivity { }) .show(); } + + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } } diff --git a/src/main/java/org/tasks/activities/DateAndTimePickerActivity.java b/src/main/java/org/tasks/activities/DateAndTimePickerActivity.java index 9a201cbea..bb66b1a15 100644 --- a/src/main/java/org/tasks/activities/DateAndTimePickerActivity.java +++ b/src/main/java/org/tasks/activities/DateAndTimePickerActivity.java @@ -9,6 +9,7 @@ import com.wdullaer.materialdatetimepicker.date.DatePickerDialog; import org.tasks.R; import org.tasks.dialogs.MyDatePickerDialog; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingAppCompatActivity; import org.tasks.preferences.ActivityPreferences; import org.tasks.time.DateTime; @@ -58,6 +59,11 @@ public class DateAndTimePickerActivity extends InjectingAppCompatActivity implem datePickerDialog.setOnDateSetListener(this); } + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } + @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); diff --git a/src/main/java/org/tasks/activities/DatePickerActivity.java b/src/main/java/org/tasks/activities/DatePickerActivity.java index 06ee57a67..144ce2caa 100644 --- a/src/main/java/org/tasks/activities/DatePickerActivity.java +++ b/src/main/java/org/tasks/activities/DatePickerActivity.java @@ -9,6 +9,7 @@ import com.wdullaer.materialdatetimepicker.date.DatePickerDialog; import org.tasks.R; import org.tasks.dialogs.MyDatePickerDialog; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingAppCompatActivity; import org.tasks.preferences.ActivityPreferences; import org.tasks.time.DateTime; @@ -49,6 +50,11 @@ public class DatePickerActivity extends InjectingAppCompatActivity dialog.setOnDateSetListener(this); } + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } + @Override public void onDateSet(DatePickerDialog view, final int year, final int monthOfYear, final int dayOfMonth) { setResult(RESULT_OK, new Intent() {{ diff --git a/src/main/java/org/tasks/activities/DeleteAllCalendarEventsActivity.java b/src/main/java/org/tasks/activities/DeleteAllCalendarEventsActivity.java index 5e48730ce..0899f7657 100644 --- a/src/main/java/org/tasks/activities/DeleteAllCalendarEventsActivity.java +++ b/src/main/java/org/tasks/activities/DeleteAllCalendarEventsActivity.java @@ -11,6 +11,7 @@ import com.todoroo.astrid.service.TaskService; import org.tasks.R; import org.tasks.dialogs.DialogBuilder; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingAppCompatActivity; import org.tasks.ui.ProgressDialogAsyncTask; @@ -72,4 +73,9 @@ public class DeleteAllCalendarEventsActivity extends InjectingAppCompatActivity }) .show(); } + + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } } diff --git a/src/main/java/org/tasks/activities/DeleteCompletedActivity.java b/src/main/java/org/tasks/activities/DeleteCompletedActivity.java index 0784f3975..a6a4fd9c1 100644 --- a/src/main/java/org/tasks/activities/DeleteCompletedActivity.java +++ b/src/main/java/org/tasks/activities/DeleteCompletedActivity.java @@ -13,6 +13,7 @@ import com.todoroo.astrid.service.TaskService; import org.tasks.R; import org.tasks.dialogs.DialogBuilder; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingAppCompatActivity; import org.tasks.ui.ProgressDialogAsyncTask; @@ -68,4 +69,9 @@ public class DeleteCompletedActivity extends InjectingAppCompatActivity { }) .show(); } + + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } } diff --git a/src/main/java/org/tasks/activities/DeleteCompletedEventsActivity.java b/src/main/java/org/tasks/activities/DeleteCompletedEventsActivity.java index b259ca353..2c17827a4 100644 --- a/src/main/java/org/tasks/activities/DeleteCompletedEventsActivity.java +++ b/src/main/java/org/tasks/activities/DeleteCompletedEventsActivity.java @@ -12,6 +12,7 @@ import com.todoroo.astrid.service.TaskService; import org.tasks.R; import org.tasks.dialogs.DialogBuilder; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingAppCompatActivity; import org.tasks.ui.ProgressDialogAsyncTask; @@ -76,4 +77,9 @@ public class DeleteCompletedEventsActivity extends InjectingAppCompatActivity { }) .show(); } + + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } } diff --git a/src/main/java/org/tasks/activities/ExportTaskActivity.java b/src/main/java/org/tasks/activities/ExportTaskActivity.java index 9eca2d59e..acf28eb2b 100644 --- a/src/main/java/org/tasks/activities/ExportTaskActivity.java +++ b/src/main/java/org/tasks/activities/ExportTaskActivity.java @@ -5,6 +5,7 @@ import android.os.Bundle; import com.todoroo.astrid.backup.TasksXmlExporter; import org.tasks.dialogs.DialogBuilder; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingAppCompatActivity; import javax.inject.Inject; @@ -19,4 +20,9 @@ public class ExportTaskActivity extends InjectingAppCompatActivity { super.onCreate(savedInstanceState); xmlExporter.exportTasks(ExportTaskActivity.this, TasksXmlExporter.ExportType.EXPORT_TYPE_MANUAL, dialogBuilder); } + + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } } diff --git a/src/main/java/org/tasks/activities/FilterSelectionActivity.java b/src/main/java/org/tasks/activities/FilterSelectionActivity.java index 57d0d26a0..5385f5492 100644 --- a/src/main/java/org/tasks/activities/FilterSelectionActivity.java +++ b/src/main/java/org/tasks/activities/FilterSelectionActivity.java @@ -11,6 +11,7 @@ import com.todoroo.astrid.api.Filter; import org.tasks.dialogs.DialogBuilder; import org.tasks.filters.FilterCounter; import org.tasks.filters.FilterProvider; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingAppCompatActivity; import org.tasks.preferences.ActivityPreferences; @@ -66,4 +67,9 @@ public class FilterSelectionActivity extends InjectingAppCompatActivity { }) .show(); } + + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } } diff --git a/src/main/java/org/tasks/activities/ImportTaskActivity.java b/src/main/java/org/tasks/activities/ImportTaskActivity.java index 504c35e75..51f8cce74 100644 --- a/src/main/java/org/tasks/activities/ImportTaskActivity.java +++ b/src/main/java/org/tasks/activities/ImportTaskActivity.java @@ -7,6 +7,7 @@ import android.os.Bundle; import com.todoroo.astrid.backup.TasksXmlImporter; import org.tasks.files.FileExplore; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingAppCompatActivity; import org.tasks.preferences.ActivityPreferences; @@ -28,6 +29,11 @@ public class ImportTaskActivity extends InjectingAppCompatActivity { }}, REQUEST_PICKER); } + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } + @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_PICKER) { diff --git a/src/main/java/org/tasks/activities/PurgeDeletedActivity.java b/src/main/java/org/tasks/activities/PurgeDeletedActivity.java index 6313b568d..4d4c8e1e4 100644 --- a/src/main/java/org/tasks/activities/PurgeDeletedActivity.java +++ b/src/main/java/org/tasks/activities/PurgeDeletedActivity.java @@ -14,6 +14,7 @@ import com.todoroo.astrid.service.TaskService; import org.tasks.R; import org.tasks.dialogs.DialogBuilder; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingAppCompatActivity; import org.tasks.ui.ProgressDialogAsyncTask; @@ -71,4 +72,9 @@ public class PurgeDeletedActivity extends InjectingAppCompatActivity { }) .show(); } + + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } } diff --git a/src/main/java/org/tasks/activities/ResetPreferencesActivity.java b/src/main/java/org/tasks/activities/ResetPreferencesActivity.java index 89f2664ba..b7d8bc82d 100644 --- a/src/main/java/org/tasks/activities/ResetPreferencesActivity.java +++ b/src/main/java/org/tasks/activities/ResetPreferencesActivity.java @@ -5,6 +5,7 @@ import android.os.Bundle; import org.tasks.R; import org.tasks.dialogs.DialogBuilder; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingAppCompatActivity; import org.tasks.preferences.Preferences; @@ -36,4 +37,9 @@ public class ResetPreferencesActivity extends InjectingAppCompatActivity { }) .show(); } + + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } } diff --git a/src/main/java/org/tasks/activities/SortActivity.java b/src/main/java/org/tasks/activities/SortActivity.java index bf8961889..5e9855d03 100644 --- a/src/main/java/org/tasks/activities/SortActivity.java +++ b/src/main/java/org/tasks/activities/SortActivity.java @@ -10,6 +10,7 @@ import com.todoroo.astrid.core.SortHelper; import org.tasks.R; import org.tasks.dialogs.DialogBuilder; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingAppCompatActivity; import org.tasks.preferences.ActivityPreferences; import org.tasks.preferences.Preferences; @@ -101,6 +102,11 @@ public class SortActivity extends InjectingAppCompatActivity { enableReverse(); } + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } + private void enableReverse() { if (manualEnabled) { Button reverse = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL); diff --git a/src/main/java/org/tasks/activities/TimePickerActivity.java b/src/main/java/org/tasks/activities/TimePickerActivity.java index 25ce0cac5..d8db9919a 100644 --- a/src/main/java/org/tasks/activities/TimePickerActivity.java +++ b/src/main/java/org/tasks/activities/TimePickerActivity.java @@ -11,6 +11,7 @@ import com.wdullaer.materialdatetimepicker.time.TimePickerDialog; import org.tasks.R; import org.tasks.dialogs.MyTimePickerDialog; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingAppCompatActivity; import org.tasks.preferences.ActivityPreferences; import org.tasks.time.DateTime; @@ -53,6 +54,11 @@ public class TimePickerActivity extends InjectingAppCompatActivity implements Ti dialog.setOnTimeSetListener(this); } + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } + @Override public void onTimeSet(RadialPickerLayout radialPickerLayout, final int hours, final int minutes, int seconds) { setResult(RESULT_OK, new Intent() {{ diff --git a/src/main/java/org/tasks/dialogs/AddAttachmentDialog.java b/src/main/java/org/tasks/dialogs/AddAttachmentDialog.java index 6f2bef8b2..50eaa8145 100644 --- a/src/main/java/org/tasks/dialogs/AddAttachmentDialog.java +++ b/src/main/java/org/tasks/dialogs/AddAttachmentDialog.java @@ -5,6 +5,7 @@ import android.content.DialogInterface; import android.os.Bundle; import org.tasks.R; +import org.tasks.injection.DialogFragmentComponent; import org.tasks.injection.InjectingDialogFragment; import org.tasks.preferences.Device; @@ -16,6 +17,11 @@ import static com.google.common.collect.Lists.newArrayList; public class AddAttachmentDialog extends InjectingDialogFragment { + @Override + protected void inject(DialogFragmentComponent component) { + component.inject(this); + } + public interface AddAttachmentCallback { void takePicture(); diff --git a/src/main/java/org/tasks/files/FileExplore.java b/src/main/java/org/tasks/files/FileExplore.java index 3e31611e2..41e4dc090 100644 --- a/src/main/java/org/tasks/files/FileExplore.java +++ b/src/main/java/org/tasks/files/FileExplore.java @@ -10,6 +10,7 @@ import android.os.Environment; import com.google.common.base.Strings; import com.nononsenseapps.filepicker.FilePickerActivity; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingAppCompatActivity; import org.tasks.preferences.ActivityPermissionRequestor; import org.tasks.preferences.PermissionRequestor; @@ -45,6 +46,11 @@ public class FileExplore extends InjectingAppCompatActivity { } } + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } + private void launchPicker() { File path = null; if (!Strings.isNullOrEmpty(startPath)) { diff --git a/src/main/java/org/tasks/fragments/CommentBarFragment.java b/src/main/java/org/tasks/fragments/CommentBarFragment.java index 1905179c8..628fc357e 100644 --- a/src/main/java/org/tasks/fragments/CommentBarFragment.java +++ b/src/main/java/org/tasks/fragments/CommentBarFragment.java @@ -28,6 +28,7 @@ import org.json.JSONObject; import org.tasks.R; import org.tasks.activities.CameraActivity; import org.tasks.dialogs.DialogBuilder; +import org.tasks.injection.FragmentComponent; import org.tasks.preferences.Device; import org.tasks.preferences.Preferences; import org.tasks.ui.TaskEditControlFragment; @@ -85,6 +86,11 @@ public class CommentBarFragment extends TaskEditControlFragment { callback = (CommentBarFragmentCallback) activity; } + @Override + protected void inject(FragmentComponent component) { + component.inject(this); + } + @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { diff --git a/src/main/java/org/tasks/injection/ActivityComponent.java b/src/main/java/org/tasks/injection/ActivityComponent.java new file mode 100644 index 000000000..1121ae48f --- /dev/null +++ b/src/main/java/org/tasks/injection/ActivityComponent.java @@ -0,0 +1,154 @@ +package org.tasks.injection; + +import com.todoroo.astrid.actfm.FilterSettingsActivity; +import com.todoroo.astrid.actfm.TagSettingsActivity; +import com.todoroo.astrid.activity.BeastModePreferences; +import com.todoroo.astrid.activity.FilterShortcutActivity; +import com.todoroo.astrid.activity.ShareLinkActivity; +import com.todoroo.astrid.activity.ShortcutActivity; +import com.todoroo.astrid.activity.TaskListActivity; +import com.todoroo.astrid.core.CustomFilterActivity; +import com.todoroo.astrid.core.DefaultsPreferences; +import com.todoroo.astrid.core.OldTaskPreferences; +import com.todoroo.astrid.files.AACRecordingActivity; +import com.todoroo.astrid.gcal.CalendarReminderActivity; +import com.todoroo.astrid.gtasks.GtasksPreferences; +import com.todoroo.astrid.gtasks.auth.GtasksLoginActivity; +import com.todoroo.astrid.reminders.ReminderPreferences; +import com.todoroo.astrid.service.UpgradeActivity; +import com.todoroo.astrid.widget.WidgetConfigActivity; + +import org.tasks.activities.AddAttachmentActivity; +import org.tasks.activities.CalendarSelectionActivity; +import org.tasks.activities.CameraActivity; +import org.tasks.activities.ClearAllDataActivity; +import org.tasks.activities.ClearGtaskDataActivity; +import org.tasks.activities.DateAndTimePickerActivity; +import org.tasks.activities.DatePickerActivity; +import org.tasks.activities.DeleteAllCalendarEventsActivity; +import org.tasks.activities.DeleteCompletedActivity; +import org.tasks.activities.DeleteCompletedEventsActivity; +import org.tasks.activities.DonationActivity; +import org.tasks.activities.ExportTaskActivity; +import org.tasks.activities.FilterSelectionActivity; +import org.tasks.activities.ImportTaskActivity; +import org.tasks.activities.PurgeDeletedActivity; +import org.tasks.activities.ResetPreferencesActivity; +import org.tasks.activities.SortActivity; +import org.tasks.activities.TimePickerActivity; +import org.tasks.files.FileExplore; +import org.tasks.preferences.AppearancePreferences; +import org.tasks.preferences.BackupPreferences; +import org.tasks.preferences.BasicPreferences; +import org.tasks.preferences.DateShortcutPreferences; +import org.tasks.preferences.HelpAndFeedbackActivity; +import org.tasks.preferences.MiscellaneousPreferences; +import org.tasks.reminders.MissedCallActivity; +import org.tasks.reminders.NotificationActivity; +import org.tasks.reminders.SnoozeActivity; +import org.tasks.voice.VoiceCommandActivity; + +import javax.inject.Singleton; + +import dagger.Subcomponent; + +@Singleton +@Subcomponent(modules = ActivityModule.class) +public interface ActivityComponent { + + FragmentComponent plus(FragmentModule module); + + DialogFragmentComponent plus(DialogFragmentModule dialogFragmentModule); + + void inject(AACRecordingActivity aacRecordingActivity); + + void inject(CustomFilterActivity customFilterActivity); + + void inject(CalendarReminderActivity calendarReminderActivity); + + void inject(FilterSettingsActivity filterSettingsActivity); + + void inject(TagSettingsActivity tagSettingsActivity); + + void inject(UpgradeActivity upgradeActivity); + + void inject(ShareLinkActivity shareLinkActivity); + + void inject(TaskListActivity taskListActivity); + + void inject(ShortcutActivity shortcutActivity); + + void inject(BeastModePreferences beastModePreferences); + + void inject(NotificationActivity notificationActivity); + + void inject(SnoozeActivity snoozeActivity); + + void inject(MissedCallActivity missedCallActivity); + + void inject(FileExplore fileExplore); + + void inject(ClearAllDataActivity clearAllDataActivity); + + void inject(CalendarSelectionActivity calendarSelectionActivity); + + void inject(SortActivity sortActivity); + + void inject(DeleteAllCalendarEventsActivity deleteAllCalendarEventsActivity); + + void inject(DeleteCompletedEventsActivity deleteCompletedEventsActivity); + + void inject(FilterSelectionActivity filterSelectionActivity); + + void inject(ResetPreferencesActivity resetPreferencesActivity); + + void inject(PurgeDeletedActivity purgeDeletedActivity); + + void inject(DateAndTimePickerActivity dateAndTimePickerActivity); + + void inject(ExportTaskActivity exportTaskActivity); + + void inject(ImportTaskActivity importTaskActivity); + + void inject(AddAttachmentActivity addAttachmentActivity); + + void inject(DeleteCompletedActivity deleteCompletedActivity); + + void inject(DatePickerActivity datePickerActivity); + + void inject(CameraActivity cameraActivity); + + void inject(TimePickerActivity timePickerActivity); + + void inject(VoiceCommandActivity voiceCommandActivity); + + void inject(GtasksLoginActivity gtasksLoginActivity); + + void inject(DonationActivity donationActivity); + + void inject(ClearGtaskDataActivity clearGtaskDataActivity); + + void inject(ReminderPreferences reminderPreferences); + + void inject(WidgetConfigActivity widgetConfigActivity); + + void inject(OldTaskPreferences oldTaskPreferences); + + void inject(DefaultsPreferences defaultsPreferences); + + void inject(FilterShortcutActivity filterShortcutActivity); + + void inject(BackupPreferences backupPreferences); + + void inject(MiscellaneousPreferences miscellaneousPreferences); + + void inject(BasicPreferences basicPreferences); + + void inject(HelpAndFeedbackActivity helpAndFeedbackActivity); + + void inject(DateShortcutPreferences dateShortcutPreferences); + + void inject(AppearancePreferences appearancePreferences); + + void inject(GtasksPreferences gtasksPreferences); +} diff --git a/src/main/java/org/tasks/injection/ActivityModule.java b/src/main/java/org/tasks/injection/ActivityModule.java index 9879bf506..cfd51e010 100644 --- a/src/main/java/org/tasks/injection/ActivityModule.java +++ b/src/main/java/org/tasks/injection/ActivityModule.java @@ -2,109 +2,10 @@ package org.tasks.injection; import android.app.Activity; -import com.todoroo.astrid.actfm.FilterSettingsActivity; -import com.todoroo.astrid.actfm.TagSettingsActivity; -import com.todoroo.astrid.activity.BeastModePreferences; -import com.todoroo.astrid.activity.FilterShortcutActivity; -import com.todoroo.astrid.activity.ShareLinkActivity; -import com.todoroo.astrid.activity.ShortcutActivity; -import com.todoroo.astrid.activity.TaskListActivity; -import com.todoroo.astrid.core.CustomFilterActivity; -import com.todoroo.astrid.core.DefaultsPreferences; -import com.todoroo.astrid.core.OldTaskPreferences; -import com.todoroo.astrid.files.AACRecordingActivity; -import org.tasks.files.FileExplore; - -import com.todoroo.astrid.gcal.CalendarReminderActivity; -import com.todoroo.astrid.gtasks.GtasksPreferences; -import com.todoroo.astrid.gtasks.auth.GtasksLoginActivity; -import com.todoroo.astrid.reminders.ReminderPreferences; -import com.todoroo.astrid.service.UpgradeActivity; -import com.todoroo.astrid.widget.WidgetConfigActivity; - -import org.tasks.activities.AddAttachmentActivity; -import org.tasks.activities.CalendarSelectionActivity; -import org.tasks.activities.CameraActivity; -import org.tasks.activities.ClearAllDataActivity; -import org.tasks.activities.ClearGtaskDataActivity; -import org.tasks.activities.DateAndTimePickerActivity; -import org.tasks.activities.DatePickerActivity; -import org.tasks.activities.DeleteAllCalendarEventsActivity; -import org.tasks.activities.DeleteCompletedActivity; -import org.tasks.activities.DeleteCompletedEventsActivity; -import org.tasks.activities.DonationActivity; -import org.tasks.activities.ExportTaskActivity; -import org.tasks.activities.FilterSelectionActivity; -import org.tasks.activities.ImportTaskActivity; -import org.tasks.activities.PurgeDeletedActivity; -import org.tasks.activities.ResetPreferencesActivity; -import org.tasks.activities.SortActivity; -import org.tasks.activities.TimePickerActivity; -import org.tasks.preferences.AppearancePreferences; -import org.tasks.preferences.BackupPreferences; -import org.tasks.preferences.BasicPreferences; -import org.tasks.preferences.DateShortcutPreferences; -import org.tasks.preferences.HelpAndFeedbackActivity; -import org.tasks.preferences.MiscellaneousPreferences; -import org.tasks.reminders.MissedCallActivity; -import org.tasks.reminders.NotificationActivity; -import org.tasks.reminders.SnoozeActivity; -import org.tasks.voice.VoiceCommandActivity; - -import javax.inject.Singleton; - import dagger.Module; import dagger.Provides; -@Module(addsTo = TasksModule.class, - injects = { - TaskListActivity.class, - ShareLinkActivity.class, - TagSettingsActivity.class, - FilterSettingsActivity.class, - CustomFilterActivity.class, - MissedCallActivity.class, - CalendarReminderActivity.class, - VoiceCommandActivity.class, - GtasksLoginActivity.class, - WidgetConfigActivity.class, - BasicPreferences.class, - GtasksPreferences.class, - OldTaskPreferences.class, - FilterShortcutActivity.class, - BeastModePreferences.class, - DefaultsPreferences.class, - AACRecordingActivity.class, - SnoozeActivity.class, - MiscellaneousPreferences.class, - ImportTaskActivity.class, - ExportTaskActivity.class, - ClearAllDataActivity.class, - ResetPreferencesActivity.class, - PurgeDeletedActivity.class, - DeleteCompletedActivity.class, - DeleteCompletedEventsActivity.class, - DeleteAllCalendarEventsActivity.class, - ClearGtaskDataActivity.class, - ReminderPreferences.class, - AppearancePreferences.class, - BackupPreferences.class, - NotificationActivity.class, - HelpAndFeedbackActivity.class, - DateShortcutPreferences.class, - SortActivity.class, - FilterSelectionActivity.class, - FileExplore.class, - DonationActivity.class, - UpgradeActivity.class, - CalendarSelectionActivity.class, - AddAttachmentActivity.class, - ShortcutActivity.class, - CameraActivity.class, - DatePickerActivity.class, - TimePickerActivity.class, - DateAndTimePickerActivity.class - }) +@Module public class ActivityModule { private final Activity activity; @@ -113,7 +14,6 @@ public class ActivityModule { this.activity = activity; } - @Singleton @Provides public Activity getActivity() { return activity; diff --git a/src/main/java/org/tasks/injection/ApplicationComponent.java b/src/main/java/org/tasks/injection/ApplicationComponent.java new file mode 100644 index 000000000..f1586d633 --- /dev/null +++ b/src/main/java/org/tasks/injection/ApplicationComponent.java @@ -0,0 +1,22 @@ +package org.tasks.injection; + +import org.tasks.Tasks; + +import javax.inject.Singleton; + +import dagger.Component; + +@Singleton +@Component(modules = ApplicationModule.class) +public interface ApplicationComponent { + + Tasks inject(Tasks tasks); + + ActivityComponent plus(ActivityModule module); + + BroadcastComponent plus(BroadcastModule module); + + IntentServiceComponent plus(IntentServiceModule module); + + RemoteViewsServiceComponent plus(RemoteViewsServiceModule remoteViewsServiceModule); +} diff --git a/src/main/java/org/tasks/injection/ApplicationModule.java b/src/main/java/org/tasks/injection/ApplicationModule.java new file mode 100644 index 000000000..fc423e341 --- /dev/null +++ b/src/main/java/org/tasks/injection/ApplicationModule.java @@ -0,0 +1,21 @@ +package org.tasks.injection; + +import android.content.Context; + +import dagger.Module; +import dagger.Provides; + +@Module +public class ApplicationModule { + private Context context; + + public ApplicationModule(Context context) { + this.context = context.getApplicationContext(); + } + + @Provides + @ForApplication + public Context getApplicationContext() { + return context; + } +} diff --git a/src/main/java/org/tasks/injection/BroadcastComponent.java b/src/main/java/org/tasks/injection/BroadcastComponent.java new file mode 100644 index 000000000..e44284127 --- /dev/null +++ b/src/main/java/org/tasks/injection/BroadcastComponent.java @@ -0,0 +1,51 @@ +package org.tasks.injection; + +import com.todoroo.astrid.alarms.AlarmTaskRepeatListener; +import com.todoroo.astrid.calls.PhoneStateChangedReceiver; +import com.todoroo.astrid.gcal.CalendarAlarmReceiver; +import com.todoroo.astrid.gcal.GCalTaskCompleteListener; +import com.todoroo.astrid.repeats.RepeatTaskCompleteListener; +import com.todoroo.astrid.timers.TimerTaskCompleteListener; +import com.todoroo.astrid.widget.TasksWidget; + +import org.tasks.receivers.BootCompletedReceiver; +import org.tasks.receivers.CompleteTaskReceiver; +import org.tasks.receivers.FirstLaunchReceiver; +import org.tasks.receivers.ListNotificationReceiver; +import org.tasks.receivers.MyPackageReplacedReceiver; +import org.tasks.receivers.RefreshReceiver; +import org.tasks.receivers.TaskNotificationReceiver; + +import dagger.Subcomponent; + +@Subcomponent(modules = BroadcastModule.class) +public interface BroadcastComponent { + + void inject(TimerTaskCompleteListener timerTaskCompleteListener); + + void inject(PhoneStateChangedReceiver phoneStateChangedReceiver); + + void inject(AlarmTaskRepeatListener alarmTaskRepeatListener); + + void inject(GCalTaskCompleteListener gCalTaskCompleteListener); + + void inject(CalendarAlarmReceiver calendarAlarmReceiver); + + void inject(RepeatTaskCompleteListener repeatTaskCompleteListener); + + void inject(MyPackageReplacedReceiver myPackageReplacedReceiver); + + void inject(RefreshReceiver refreshReceiver); + + void inject(TaskNotificationReceiver taskNotificationReceiver); + + void inject(CompleteTaskReceiver completeTaskReceiver); + + void inject(FirstLaunchReceiver firstLaunchReceiver); + + void inject(ListNotificationReceiver listNotificationReceiver); + + void inject(BootCompletedReceiver bootCompletedReceiver); + + void inject(TasksWidget tasksWidget); +} diff --git a/src/main/java/org/tasks/injection/BroadcastModule.java b/src/main/java/org/tasks/injection/BroadcastModule.java index 95cd903c0..a5c245365 100644 --- a/src/main/java/org/tasks/injection/BroadcastModule.java +++ b/src/main/java/org/tasks/injection/BroadcastModule.java @@ -1,40 +1,7 @@ package org.tasks.injection; -import com.todoroo.astrid.alarms.AlarmTaskRepeatListener; -import com.todoroo.astrid.calls.PhoneStateChangedReceiver; -import com.todoroo.astrid.gcal.CalendarAlarmReceiver; -import com.todoroo.astrid.gcal.GCalTaskCompleteListener; -import com.todoroo.astrid.repeats.RepeatTaskCompleteListener; -import com.todoroo.astrid.timers.TimerTaskCompleteListener; -import com.todoroo.astrid.widget.TasksWidget; - -import org.tasks.receivers.BootCompletedReceiver; -import org.tasks.receivers.CompleteTaskReceiver; -import org.tasks.receivers.FirstLaunchReceiver; -import org.tasks.receivers.ListNotificationReceiver; -import org.tasks.receivers.MyPackageReplacedReceiver; -import org.tasks.receivers.RefreshReceiver; -import org.tasks.receivers.RepeatConfirmationReceiver; -import org.tasks.receivers.TaskNotificationReceiver; - import dagger.Module; -@Module(addsTo = TasksModule.class, - injects = { - TasksWidget.class, - TaskNotificationReceiver.class, - ListNotificationReceiver.class, - GCalTaskCompleteListener.class, - TimerTaskCompleteListener.class, - RepeatTaskCompleteListener.class, - AlarmTaskRepeatListener.class, - PhoneStateChangedReceiver.class, - CalendarAlarmReceiver.class, - BootCompletedReceiver.class, - FirstLaunchReceiver.class, - MyPackageReplacedReceiver.class, - RefreshReceiver.class, - CompleteTaskReceiver.class - }) +@Module public class BroadcastModule { } diff --git a/src/main/java/org/tasks/injection/ContentProviderComponent.java b/src/main/java/org/tasks/injection/ContentProviderComponent.java new file mode 100644 index 000000000..576fc32ca --- /dev/null +++ b/src/main/java/org/tasks/injection/ContentProviderComponent.java @@ -0,0 +1,22 @@ +package org.tasks.injection; + +import com.todoroo.astrid.provider.Astrid2TaskProvider; +import com.todoroo.astrid.provider.Astrid3ContentProvider; +import com.todoroo.astrid.provider.SqlContentProvider; + +import javax.inject.Singleton; + +import dagger.Component; + +@Singleton +@Component(modules = { + ApplicationModule.class, + ContentProviderModule.class +}) +public interface ContentProviderComponent { + void inject(Astrid3ContentProvider astrid3ContentProvider); + + void inject(Astrid2TaskProvider astrid2TaskProvider); + + void inject(SqlContentProvider sqlContentProvider); +} diff --git a/src/main/java/org/tasks/injection/ContentProviderModule.java b/src/main/java/org/tasks/injection/ContentProviderModule.java index 525a16599..dbbf17a28 100644 --- a/src/main/java/org/tasks/injection/ContentProviderModule.java +++ b/src/main/java/org/tasks/injection/ContentProviderModule.java @@ -1,16 +1,7 @@ package org.tasks.injection; -import com.todoroo.astrid.provider.Astrid2TaskProvider; -import com.todoroo.astrid.provider.Astrid3ContentProvider; -import com.todoroo.astrid.provider.SqlContentProvider; - import dagger.Module; -@Module(addsTo = TasksModule.class, - injects = { - Astrid2TaskProvider.class, - Astrid3ContentProvider.class, - SqlContentProvider.class -}) +@Module public class ContentProviderModule { } diff --git a/src/main/java/org/tasks/injection/Dagger.java b/src/main/java/org/tasks/injection/Dagger.java deleted file mode 100644 index ea860f9d4..000000000 --- a/src/main/java/org/tasks/injection/Dagger.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.tasks.injection; - -import android.content.Context; - -import dagger.ObjectGraph; - -public final class Dagger { - private static ObjectGraph objectGraph; - - static ObjectGraph getObjectGraph(Context context) { - if (objectGraph == null) { - objectGraph = ObjectGraph.create(new TasksModule(context)); - } - return objectGraph; - } -} diff --git a/src/main/java/org/tasks/injection/DialogFragmentComponent.java b/src/main/java/org/tasks/injection/DialogFragmentComponent.java new file mode 100644 index 000000000..0a2f32909 --- /dev/null +++ b/src/main/java/org/tasks/injection/DialogFragmentComponent.java @@ -0,0 +1,25 @@ +package org.tasks.injection; + +import org.tasks.activities.CalendarSelectionDialog; +import org.tasks.dialogs.AccountSelectionDialog; +import org.tasks.dialogs.AddAttachmentDialog; +import org.tasks.reminders.MissedCallDialog; +import org.tasks.reminders.NotificationDialog; +import org.tasks.reminders.SnoozeDialog; + +import dagger.Subcomponent; + +@Subcomponent(modules = DialogFragmentModule.class) +public interface DialogFragmentComponent { + void inject(NotificationDialog notificationDialog); + + void inject(MissedCallDialog missedCallDialog); + + void inject(CalendarSelectionDialog calendarSelectionDialog); + + void inject(AddAttachmentDialog addAttachmentDialog); + + void inject(AccountSelectionDialog accountSelectionDialog); + + void inject(SnoozeDialog snoozeDialog); +} diff --git a/src/main/java/org/tasks/injection/DialogFragmentModule.java b/src/main/java/org/tasks/injection/DialogFragmentModule.java index 65f39b0d4..3d90e133e 100644 --- a/src/main/java/org/tasks/injection/DialogFragmentModule.java +++ b/src/main/java/org/tasks/injection/DialogFragmentModule.java @@ -3,26 +3,10 @@ package org.tasks.injection; import android.app.Activity; import android.app.DialogFragment; -import org.tasks.activities.CalendarSelectionDialog; -import org.tasks.dialogs.AccountSelectionDialog; -import org.tasks.dialogs.AddAttachmentDialog; -import org.tasks.reminders.MissedCallDialog; -import org.tasks.reminders.NotificationDialog; -import org.tasks.reminders.SnoozeDialog; - import dagger.Module; import dagger.Provides; -@Module(addsTo = TasksModule.class, - injects = { - NotificationDialog.class, - SnoozeDialog.class, - MissedCallDialog.class, - CalendarSelectionDialog.class, - AccountSelectionDialog.class, - AddAttachmentDialog.class - }, - library = true) +@Module public class DialogFragmentModule { private DialogFragment dialogFragment; diff --git a/src/main/java/org/tasks/injection/FragmentComponent.java b/src/main/java/org/tasks/injection/FragmentComponent.java new file mode 100644 index 000000000..8344a8b81 --- /dev/null +++ b/src/main/java/org/tasks/injection/FragmentComponent.java @@ -0,0 +1,57 @@ +package org.tasks.injection; + +import com.todoroo.astrid.activity.TaskEditFragment; +import com.todoroo.astrid.activity.TaskListFragment; +import com.todoroo.astrid.files.FilesControlSet; +import com.todoroo.astrid.repeats.RepeatControlSet; +import com.todoroo.astrid.tags.TagsControlSet; +import com.todoroo.astrid.timers.TimerControlSet; +import com.todoroo.astrid.ui.EditTitleControlSet; +import com.todoroo.astrid.ui.HideUntilControlSet; +import com.todoroo.astrid.ui.ReminderControlSet; + +import org.tasks.fragments.CommentBarFragment; +import org.tasks.ui.CalendarControlSet; +import org.tasks.ui.DeadlineControlSet; +import org.tasks.ui.DescriptionControlSet; +import org.tasks.ui.NavigationDrawerFragment; +import org.tasks.ui.PriorityControlSet; + +import javax.inject.Singleton; + +import dagger.Subcomponent; + +@Singleton +@Subcomponent(modules = FragmentModule.class) +public interface FragmentComponent { + + void inject(TimerControlSet timerControlSet); + + void inject(TaskEditFragment taskEditFragment); + + void inject(NavigationDrawerFragment navigationDrawerFragment); + + void inject(PriorityControlSet priorityControlSet); + + void inject(RepeatControlSet repeatControlSet); + + void inject(CommentBarFragment commentBarFragment); + + void inject(EditTitleControlSet editTitleControlSet); + + void inject(FilesControlSet filesControlSet); + + void inject(TagsControlSet tagsControlSet); + + void inject(HideUntilControlSet hideUntilControlSet); + + void inject(ReminderControlSet reminderControlSet); + + void inject(DeadlineControlSet deadlineControlSet); + + void inject(DescriptionControlSet descriptionControlSet); + + void inject(CalendarControlSet calendarControlSet); + + void inject(TaskListFragment taskListFragment); +} diff --git a/src/main/java/org/tasks/injection/FragmentModule.java b/src/main/java/org/tasks/injection/FragmentModule.java index b41d40c31..d532dcd13 100644 --- a/src/main/java/org/tasks/injection/FragmentModule.java +++ b/src/main/java/org/tasks/injection/FragmentModule.java @@ -1,59 +1,13 @@ package org.tasks.injection; -import android.app.Activity; import android.app.Fragment; import android.content.Context; -import com.todoroo.astrid.actfm.TagViewFragment; -import com.todoroo.astrid.activity.TaskEditFragment; -import com.todoroo.astrid.activity.TaskListFragment; -import com.todoroo.astrid.files.FilesControlSet; -import com.todoroo.astrid.gtasks.GtasksListFragment; -import com.todoroo.astrid.repeats.RepeatControlSet; -import com.todoroo.astrid.subtasks.SubtasksListFragment; -import com.todoroo.astrid.subtasks.SubtasksTagListFragment; -import com.todoroo.astrid.tags.TagsControlSet; -import com.todoroo.astrid.timers.TimerControlSet; -import com.todoroo.astrid.ui.EditTitleControlSet; -import com.todoroo.astrid.ui.HideUntilControlSet; -import com.todoroo.astrid.ui.ReminderControlSet; - -import org.tasks.fragments.CommentBarFragment; -import org.tasks.ui.CalendarControlSet; -import org.tasks.ui.DeadlineControlSet; -import org.tasks.ui.DescriptionControlSet; -import org.tasks.ui.NavigationDrawerFragment; -import org.tasks.ui.PriorityControlSet; - -import javax.inject.Singleton; - import dagger.Module; import dagger.Provides; -@Module(addsTo = TasksModule.class, - injects = { - TaskListFragment.class, - GtasksListFragment.class, - SubtasksListFragment.class, - SubtasksTagListFragment.class, - TagViewFragment.class, - TaskEditFragment.class, - NavigationDrawerFragment.class, - CalendarControlSet.class, - DeadlineControlSet.class, - PriorityControlSet.class, - DescriptionControlSet.class, - HideUntilControlSet.class, - ReminderControlSet.class, - FilesControlSet.class, - EditTitleControlSet.class, - TimerControlSet.class, - TagsControlSet.class, - RepeatControlSet.class, - CommentBarFragment.class - }) +@Module public class FragmentModule { - private final Fragment fragment; public FragmentModule(Fragment fragment) { @@ -66,12 +20,6 @@ public class FragmentModule { return fragment.getActivity(); } - @Provides - public Activity getActivity() { - return fragment.getActivity(); - } - - @Singleton @Provides public Fragment getFragment() { return fragment; diff --git a/src/main/java/org/tasks/injection/InjectingActivity.java b/src/main/java/org/tasks/injection/InjectingActivity.java new file mode 100644 index 000000000..bf700a6eb --- /dev/null +++ b/src/main/java/org/tasks/injection/InjectingActivity.java @@ -0,0 +1,7 @@ +package org.tasks.injection; + +public interface InjectingActivity { + void inject(ActivityComponent component); + + ActivityComponent getComponent(); +} diff --git a/src/main/java/org/tasks/injection/InjectingAppCompatActivity.java b/src/main/java/org/tasks/injection/InjectingAppCompatActivity.java index b329566de..c9e32efb9 100644 --- a/src/main/java/org/tasks/injection/InjectingAppCompatActivity.java +++ b/src/main/java/org/tasks/injection/InjectingAppCompatActivity.java @@ -7,17 +7,15 @@ import org.tasks.analytics.Tracker; import javax.inject.Inject; -import dagger.ObjectGraph; - -public abstract class InjectingAppCompatActivity extends AppCompatActivity implements Injector { - private ObjectGraph objectGraph; +public abstract class InjectingAppCompatActivity extends AppCompatActivity implements InjectingActivity { + private ActivityComponent activityComponent; @Inject Tracker tracker; @Override protected void onCreate(Bundle savedInstanceState) { - objectGraph = ((Injector) getApplication()).getObjectGraph().plus(new ActivityModule(this)); - inject(this); + activityComponent = ((InjectingApplication) getApplication()).getComponent().plus(new ActivityModule(this)); + inject(activityComponent); super.onCreate(savedInstanceState); } @@ -30,12 +28,7 @@ public abstract class InjectingAppCompatActivity extends AppCompatActivity imple } @Override - public void inject(Object caller) { - objectGraph.inject(caller); - } - - @Override - public ObjectGraph getObjectGraph() { - return objectGraph; + public ActivityComponent getComponent() { + return activityComponent; } } diff --git a/src/main/java/org/tasks/injection/InjectingAppWidgetProvider.java b/src/main/java/org/tasks/injection/InjectingAppWidgetProvider.java index ec584c606..f02e8cb70 100644 --- a/src/main/java/org/tasks/injection/InjectingAppWidgetProvider.java +++ b/src/main/java/org/tasks/injection/InjectingAppWidgetProvider.java @@ -4,14 +4,15 @@ import android.appwidget.AppWidgetProvider; import android.content.Context; import android.content.Intent; -public class InjectingAppWidgetProvider extends AppWidgetProvider { +public abstract class InjectingAppWidgetProvider extends AppWidgetProvider { @Override public void onReceive(Context context, Intent intent) { - ((Injector) context.getApplicationContext()) - .getObjectGraph() - .plus(new BroadcastModule()) - .inject(this); + inject(((InjectingApplication) context.getApplicationContext()) + .getComponent() + .plus(new BroadcastModule())); super.onReceive(context, intent); } + + protected abstract void inject(BroadcastComponent component); } diff --git a/src/main/java/org/tasks/injection/InjectingApplication.java b/src/main/java/org/tasks/injection/InjectingApplication.java index f0f6f7590..7770c4c77 100644 --- a/src/main/java/org/tasks/injection/InjectingApplication.java +++ b/src/main/java/org/tasks/injection/InjectingApplication.java @@ -2,28 +2,26 @@ package org.tasks.injection; import android.app.Application; -import dagger.ObjectGraph; +public abstract class InjectingApplication extends Application { -public class InjectingApplication extends Application implements Injector { - - private ObjectGraph objectGraph; + private ApplicationComponent applicationComponent; @Override public void onCreate() { super.onCreate(); - objectGraph = Dagger.getObjectGraph(this); + applicationComponent = DaggerApplicationComponent.builder() + .applicationModule(new ApplicationModule(this)) + .build(); - inject(this); + inject(applicationComponent); } - @Override - public void inject(Object caller) { - objectGraph.inject(this); - } + protected abstract void inject(ApplicationComponent component); - @Override - public ObjectGraph getObjectGraph() { - return objectGraph; + public ApplicationComponent getComponent() { + return applicationComponent; } + + } diff --git a/src/main/java/org/tasks/injection/InjectingBroadcastReceiver.java b/src/main/java/org/tasks/injection/InjectingBroadcastReceiver.java index f8f03ee82..1eeb05ede 100644 --- a/src/main/java/org/tasks/injection/InjectingBroadcastReceiver.java +++ b/src/main/java/org/tasks/injection/InjectingBroadcastReceiver.java @@ -4,12 +4,13 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; -public class InjectingBroadcastReceiver extends BroadcastReceiver { +public abstract class InjectingBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { - ((Injector) context.getApplicationContext()) - .getObjectGraph() - .plus(new BroadcastModule()) - .inject(this); + inject(((InjectingApplication) context.getApplicationContext()) + .getComponent() + .plus(new BroadcastModule())); } + + protected abstract void inject(BroadcastComponent component); } diff --git a/src/main/java/org/tasks/injection/InjectingContentProvider.java b/src/main/java/org/tasks/injection/InjectingContentProvider.java index 9f5de9b65..2df4ac686 100644 --- a/src/main/java/org/tasks/injection/InjectingContentProvider.java +++ b/src/main/java/org/tasks/injection/InjectingContentProvider.java @@ -7,9 +7,13 @@ public abstract class InjectingContentProvider extends ContentProvider { @Override public boolean onCreate() { Context context = getContext(); - Dagger.getObjectGraph(context) - .plus(new ContentProviderModule()) - .inject(this); + inject(DaggerContentProviderComponent.builder() + .applicationModule(new ApplicationModule(context)) + .contentProviderModule(new ContentProviderModule()) + .build()); + return true; } + + protected abstract void inject(ContentProviderComponent component); } diff --git a/src/main/java/org/tasks/injection/InjectingDialogFragment.java b/src/main/java/org/tasks/injection/InjectingDialogFragment.java index d10bedeff..cfb1b03ab 100644 --- a/src/main/java/org/tasks/injection/InjectingDialogFragment.java +++ b/src/main/java/org/tasks/injection/InjectingDialogFragment.java @@ -3,7 +3,7 @@ package org.tasks.injection; import android.app.Activity; import android.app.DialogFragment; -public class InjectingDialogFragment extends DialogFragment { +public abstract class InjectingDialogFragment extends DialogFragment { private boolean injected; @Override @@ -11,8 +11,12 @@ public class InjectingDialogFragment extends DialogFragment { super.onAttach(activity); if (!injected) { - ((Injector) activity).getObjectGraph().plus(new DialogFragmentModule(this)).inject(this); + inject(((InjectingActivity) activity) + .getComponent() + .plus(new DialogFragmentModule(this))); injected = true; } } + + protected abstract void inject(DialogFragmentComponent component); } diff --git a/src/main/java/org/tasks/injection/InjectingFragment.java b/src/main/java/org/tasks/injection/InjectingFragment.java index 436c9da21..ca77573c5 100644 --- a/src/main/java/org/tasks/injection/InjectingFragment.java +++ b/src/main/java/org/tasks/injection/InjectingFragment.java @@ -3,31 +3,21 @@ package org.tasks.injection; import android.app.Activity; import android.app.Fragment; -import dagger.ObjectGraph; - -public class InjectingFragment extends Fragment implements Injector { +public abstract class InjectingFragment extends Fragment { private boolean injected; - private ObjectGraph objectGraph; @Override public void onAttach(Activity activity) { super.onAttach(activity); if (!injected) { - objectGraph = ((Injector) activity).getObjectGraph().plus(new FragmentModule(this)); - inject(this); + inject(((InjectingActivity) activity) + .getComponent() + .plus(new FragmentModule(this))); injected = true; } } - @Override - public void inject(Object caller) { - objectGraph.inject(caller); - } - - @Override - public ObjectGraph getObjectGraph() { - return objectGraph; - } + protected abstract void inject(FragmentComponent component); } diff --git a/src/main/java/org/tasks/injection/InjectingIntentService.java b/src/main/java/org/tasks/injection/InjectingIntentService.java index e4e216ca1..883db9f29 100644 --- a/src/main/java/org/tasks/injection/InjectingIntentService.java +++ b/src/main/java/org/tasks/injection/InjectingIntentService.java @@ -11,9 +11,10 @@ public abstract class InjectingIntentService extends IntentService { @Override protected void onHandleIntent(Intent intent) { - ((Injector) getApplication()) - .getObjectGraph() - .plus(new IntentServiceModule()) - .inject(this); + inject(((InjectingApplication) getApplication()) + .getComponent() + .plus(new IntentServiceModule())); } + + protected abstract void inject(IntentServiceComponent component); } diff --git a/src/main/java/org/tasks/injection/InjectingListActivity.java b/src/main/java/org/tasks/injection/InjectingListActivity.java index 1891b6af8..f314e4e4c 100644 --- a/src/main/java/org/tasks/injection/InjectingListActivity.java +++ b/src/main/java/org/tasks/injection/InjectingListActivity.java @@ -7,29 +7,25 @@ import org.tasks.analytics.Tracker; import javax.inject.Inject; -import dagger.ObjectGraph; +public abstract class InjectingListActivity extends ListActivity implements InjectingActivity { -public abstract class InjectingListActivity extends ListActivity implements Injector { - private ObjectGraph objectGraph; + private ActivityComponent activityComponent; @Inject Tracker tracker; @Override protected void onCreate(Bundle savedInstanceState) { - objectGraph = ((Injector) getApplication()).getObjectGraph().plus(new ActivityModule(this)); - inject(this); + activityComponent = ((InjectingApplication) getApplication()) + .getComponent() + .plus(new ActivityModule(this)); + inject(activityComponent); super.onCreate(savedInstanceState); } @Override - public void inject(Object caller) { - objectGraph.inject(caller); - } - - @Override - public ObjectGraph getObjectGraph() { - return objectGraph; + public ActivityComponent getComponent() { + return activityComponent; } @Override diff --git a/src/main/java/org/tasks/injection/InjectingListFragment.java b/src/main/java/org/tasks/injection/InjectingListFragment.java index f0f512f4e..a52b3bf8c 100644 --- a/src/main/java/org/tasks/injection/InjectingListFragment.java +++ b/src/main/java/org/tasks/injection/InjectingListFragment.java @@ -3,31 +3,21 @@ package org.tasks.injection; import android.app.Activity; import android.app.ListFragment; -import dagger.ObjectGraph; - -public class InjectingListFragment extends ListFragment implements Injector { +public abstract class InjectingListFragment extends ListFragment { private boolean injected; - private ObjectGraph objectGraph; @Override public void onAttach(Activity activity) { super.onAttach(activity); if (!injected) { - objectGraph = ((Injector) activity).getObjectGraph().plus(new FragmentModule(this)); - inject(this); + inject(((InjectingActivity) activity) + .getComponent() + .plus(new FragmentModule(this))); injected = true; } } - @Override - public void inject(Object caller) { - objectGraph.inject(caller); - } - - @Override - public ObjectGraph getObjectGraph() { - return objectGraph; - } + public abstract void inject(FragmentComponent component); } diff --git a/src/main/java/org/tasks/injection/InjectingPreferenceActivity.java b/src/main/java/org/tasks/injection/InjectingPreferenceActivity.java index f5785ffb7..2cb123a33 100644 --- a/src/main/java/org/tasks/injection/InjectingPreferenceActivity.java +++ b/src/main/java/org/tasks/injection/InjectingPreferenceActivity.java @@ -16,11 +16,9 @@ import org.tasks.preferences.AppCompatPreferenceActivity; import javax.inject.Inject; -import dagger.ObjectGraph; +public abstract class InjectingPreferenceActivity extends AppCompatPreferenceActivity implements InjectingActivity { -public abstract class InjectingPreferenceActivity extends AppCompatPreferenceActivity implements Injector { - - private ObjectGraph objectGraph; + private ActivityComponent activityComponent; protected Toolbar toolbar; @@ -29,8 +27,10 @@ public abstract class InjectingPreferenceActivity extends AppCompatPreferenceAct @Override public void onCreate(Bundle savedInstanceState) { - objectGraph = ((Injector) getApplication()).getObjectGraph().plus(new ActivityModule(this)); - inject(this); + activityComponent = ((InjectingApplication) getApplication()) + .getComponent() + .plus(new ActivityModule(this)); + inject(activityComponent); activityPreferences.applyThemeAndStatusBarColor(); @@ -58,13 +58,8 @@ public abstract class InjectingPreferenceActivity extends AppCompatPreferenceAct } @Override - public void inject(Object caller) { - objectGraph.inject(caller); - } - - @Override - public ObjectGraph getObjectGraph() { - return objectGraph; + public ActivityComponent getComponent() { + return activityComponent; } @Override diff --git a/src/main/java/org/tasks/injection/InjectingRemoteViewsService.java b/src/main/java/org/tasks/injection/InjectingRemoteViewsService.java index aa51b23aa..a137ad79c 100644 --- a/src/main/java/org/tasks/injection/InjectingRemoteViewsService.java +++ b/src/main/java/org/tasks/injection/InjectingRemoteViewsService.java @@ -7,9 +7,10 @@ public abstract class InjectingRemoteViewsService extends RemoteViewsService { public void onCreate() { super.onCreate(); - ((Injector) getApplication()) - .getObjectGraph() - .plus(new ServiceModule()) - .inject(this); + inject(((InjectingApplication) getApplication()) + .getComponent() + .plus(new RemoteViewsServiceModule())); } + + protected abstract void inject(RemoteViewsServiceComponent component); } diff --git a/src/main/java/org/tasks/injection/InjectingService.java b/src/main/java/org/tasks/injection/InjectingService.java deleted file mode 100644 index 02488093f..000000000 --- a/src/main/java/org/tasks/injection/InjectingService.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.tasks.injection; - -import android.app.Service; - -public abstract class InjectingService extends Service { - @Override - public void onCreate() { - super.onCreate(); - - ((Injector) getApplication()) - .getObjectGraph() - .plus(new ServiceModule()) - .inject(this); - } -} diff --git a/src/main/java/org/tasks/injection/Injector.java b/src/main/java/org/tasks/injection/Injector.java deleted file mode 100644 index 97ae5dade..000000000 --- a/src/main/java/org/tasks/injection/Injector.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.tasks.injection; - -import dagger.ObjectGraph; - -public interface Injector { - - void inject(Object caller); - - ObjectGraph getObjectGraph(); -} diff --git a/src/main/java/org/tasks/injection/IntentServiceComponent.java b/src/main/java/org/tasks/injection/IntentServiceComponent.java new file mode 100644 index 000000000..dd6fcaa90 --- /dev/null +++ b/src/main/java/org/tasks/injection/IntentServiceComponent.java @@ -0,0 +1,28 @@ +package org.tasks.injection; + +import org.tasks.location.GeofenceTransitionsIntentService; +import org.tasks.scheduling.BackupIntentService; +import org.tasks.scheduling.CalendarNotificationIntentService; +import org.tasks.scheduling.GeofenceSchedulingIntentService; +import org.tasks.scheduling.GtasksBackgroundService; +import org.tasks.scheduling.RefreshSchedulerIntentService; +import org.tasks.scheduling.ReminderSchedulerIntentService; + +import dagger.Subcomponent; + +@Subcomponent(modules = IntentServiceModule.class) +public interface IntentServiceComponent { + void inject(ReminderSchedulerIntentService reminderSchedulerIntentService); + + void inject(RefreshSchedulerIntentService refreshSchedulerIntentService); + + void inject(GeofenceSchedulingIntentService geofenceSchedulingIntentService); + + void inject(CalendarNotificationIntentService calendarNotificationIntentService); + + void inject(BackupIntentService backupIntentService); + + void inject(GeofenceTransitionsIntentService geofenceTransitionsIntentService); + + void inject(GtasksBackgroundService gtasksBackgroundService); +} diff --git a/src/main/java/org/tasks/injection/IntentServiceModule.java b/src/main/java/org/tasks/injection/IntentServiceModule.java index b9067bc35..4597e9b80 100644 --- a/src/main/java/org/tasks/injection/IntentServiceModule.java +++ b/src/main/java/org/tasks/injection/IntentServiceModule.java @@ -1,19 +1,7 @@ package org.tasks.injection; -import org.tasks.location.GeofenceTransitionsIntentService; -import org.tasks.scheduling.*; - import dagger.Module; -@Module(addsTo = TasksModule.class, - injects = { - GeofenceSchedulingIntentService.class, - BackupIntentService.class, - GtasksBackgroundService.class, - RefreshSchedulerIntentService.class, - ReminderSchedulerIntentService.class, - GeofenceTransitionsIntentService.class, - CalendarNotificationIntentService.class - }) +@Module public class IntentServiceModule { } diff --git a/src/main/java/org/tasks/injection/RemoteViewsServiceComponent.java b/src/main/java/org/tasks/injection/RemoteViewsServiceComponent.java new file mode 100644 index 000000000..b3d2ab5e7 --- /dev/null +++ b/src/main/java/org/tasks/injection/RemoteViewsServiceComponent.java @@ -0,0 +1,10 @@ +package org.tasks.injection; + +import org.tasks.widget.ScrollableWidgetUpdateService; + +import dagger.Subcomponent; + +@Subcomponent(modules = RemoteViewsServiceModule.class) +public interface RemoteViewsServiceComponent { + void inject(ScrollableWidgetUpdateService scrollableWidgetUpdateService); +} diff --git a/src/main/java/org/tasks/injection/RemoteViewsServiceModule.java b/src/main/java/org/tasks/injection/RemoteViewsServiceModule.java new file mode 100644 index 000000000..e6ce5d25a --- /dev/null +++ b/src/main/java/org/tasks/injection/RemoteViewsServiceModule.java @@ -0,0 +1,7 @@ +package org.tasks.injection; + +import dagger.Module; + +@Module +public class RemoteViewsServiceModule { +} diff --git a/src/main/java/org/tasks/injection/ServiceModule.java b/src/main/java/org/tasks/injection/ServiceModule.java deleted file mode 100644 index ab7a97c64..000000000 --- a/src/main/java/org/tasks/injection/ServiceModule.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.tasks.injection; - -import org.tasks.widget.ScrollableWidgetUpdateService; - -import dagger.Module; - -@Module(addsTo = TasksModule.class, - injects = { - ScrollableWidgetUpdateService.class -}) -public class ServiceModule { -} diff --git a/src/main/java/org/tasks/injection/TasksModule.java b/src/main/java/org/tasks/injection/TasksModule.java deleted file mode 100644 index c210f7ecf..000000000 --- a/src/main/java/org/tasks/injection/TasksModule.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.tasks.injection; - -import android.content.Context; - -import org.tasks.Tasks; - -import javax.inject.Singleton; - -import dagger.Module; -import dagger.Provides; - -@Module(injects = { Tasks.class }) -public class TasksModule { - private Context context; - - public TasksModule(Context context) { - this.context = context; - } - - @Singleton - @Provides - @ForApplication - public Context getApplicationContext() { - return context.getApplicationContext(); - } -} diff --git a/src/main/java/org/tasks/preferences/AppearancePreferences.java b/src/main/java/org/tasks/preferences/AppearancePreferences.java index d3e99e4c9..2017897bd 100644 --- a/src/main/java/org/tasks/preferences/AppearancePreferences.java +++ b/src/main/java/org/tasks/preferences/AppearancePreferences.java @@ -9,6 +9,7 @@ import com.todoroo.astrid.api.Filter; import org.tasks.R; import org.tasks.activities.FilterSelectionActivity; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingPreferenceActivity; import javax.inject.Inject; @@ -105,4 +106,9 @@ public class AppearancePreferences extends InjectingPreferenceActivity { } }); } + + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } } diff --git a/src/main/java/org/tasks/preferences/BackupPreferences.java b/src/main/java/org/tasks/preferences/BackupPreferences.java index 76b8e09ba..3220f17fc 100644 --- a/src/main/java/org/tasks/preferences/BackupPreferences.java +++ b/src/main/java/org/tasks/preferences/BackupPreferences.java @@ -7,6 +7,7 @@ import android.preference.Preference; import org.tasks.files.FileExplore; import org.tasks.R; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingPreferenceActivity; import java.io.File; @@ -63,4 +64,9 @@ public class BackupPreferences extends InjectingPreferenceActivity { File dir = preferences.getBackupDirectory(); return dir == null ? "" : dir.getAbsolutePath(); } + + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } } diff --git a/src/main/java/org/tasks/preferences/BasicPreferences.java b/src/main/java/org/tasks/preferences/BasicPreferences.java index e5adc51fe..56b92dd8c 100644 --- a/src/main/java/org/tasks/preferences/BasicPreferences.java +++ b/src/main/java/org/tasks/preferences/BasicPreferences.java @@ -10,6 +10,7 @@ import com.todoroo.astrid.reminders.ReminderPreferences; import org.tasks.R; import org.tasks.analytics.Tracker; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingPreferenceActivity; import javax.inject.Inject; @@ -82,4 +83,9 @@ public class BasicPreferences extends InjectingPreferenceActivity { super.onActivityResult(requestCode, resultCode, data); } } + + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } } diff --git a/src/main/java/org/tasks/preferences/DateShortcutPreferences.java b/src/main/java/org/tasks/preferences/DateShortcutPreferences.java index fe9bc4e21..dec870543 100644 --- a/src/main/java/org/tasks/preferences/DateShortcutPreferences.java +++ b/src/main/java/org/tasks/preferences/DateShortcutPreferences.java @@ -5,6 +5,7 @@ import android.os.Bundle; import android.preference.Preference; import android.widget.Toast; +import org.tasks.injection.ActivityComponent; import org.tasks.time.DateTime; import org.tasks.R; import org.tasks.activities.TimePickerActivity; @@ -135,4 +136,9 @@ public class DateShortcutPreferences extends InjectingPreferenceActivity impleme Toast.LENGTH_SHORT) .show(); } + + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } } diff --git a/src/main/java/org/tasks/preferences/HelpAndFeedbackActivity.java b/src/main/java/org/tasks/preferences/HelpAndFeedbackActivity.java index b294cc870..49d04d99f 100644 --- a/src/main/java/org/tasks/preferences/HelpAndFeedbackActivity.java +++ b/src/main/java/org/tasks/preferences/HelpAndFeedbackActivity.java @@ -5,6 +5,7 @@ import android.net.Uri; import android.os.Bundle; import org.tasks.R; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingPreferenceActivity; import javax.inject.Inject; @@ -33,4 +34,9 @@ public class HelpAndFeedbackActivity extends InjectingPreferenceActivity { private void remove(int resId) { getPreferenceScreen().removePreference(findPreference(getString(resId))); } + + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } } \ No newline at end of file diff --git a/src/main/java/org/tasks/preferences/MiscellaneousPreferences.java b/src/main/java/org/tasks/preferences/MiscellaneousPreferences.java index 89d6728d0..69f8a9424 100644 --- a/src/main/java/org/tasks/preferences/MiscellaneousPreferences.java +++ b/src/main/java/org/tasks/preferences/MiscellaneousPreferences.java @@ -11,6 +11,7 @@ import com.todoroo.astrid.voice.VoiceOutputAssistant; import org.tasks.R; import org.tasks.files.FileExplore; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingPreferenceActivity; import org.tasks.scheduling.BackgroundScheduler; @@ -159,4 +160,9 @@ public class MiscellaneousPreferences extends InjectingPreferenceActivity { super.onRequestPermissionsResult(requestCode, permissions, grantResults); } } + + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } } diff --git a/src/main/java/org/tasks/receivers/BootCompletedReceiver.java b/src/main/java/org/tasks/receivers/BootCompletedReceiver.java index 67ab959a4..22f0ef715 100644 --- a/src/main/java/org/tasks/receivers/BootCompletedReceiver.java +++ b/src/main/java/org/tasks/receivers/BootCompletedReceiver.java @@ -3,6 +3,7 @@ package org.tasks.receivers; import android.content.Context; import android.content.Intent; +import org.tasks.injection.BroadcastComponent; import org.tasks.injection.InjectingBroadcastReceiver; import org.tasks.scheduling.BackgroundScheduler; @@ -22,4 +23,9 @@ public class BootCompletedReceiver extends InjectingBroadcastReceiver { backgroundScheduler.scheduleEverything(); } + + @Override + protected void inject(BroadcastComponent component) { + component.inject(this); + } } diff --git a/src/main/java/org/tasks/receivers/CompleteTaskReceiver.java b/src/main/java/org/tasks/receivers/CompleteTaskReceiver.java index 4ab63412e..554832ec6 100644 --- a/src/main/java/org/tasks/receivers/CompleteTaskReceiver.java +++ b/src/main/java/org/tasks/receivers/CompleteTaskReceiver.java @@ -6,6 +6,7 @@ import android.content.Intent; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.service.TaskService; +import org.tasks.injection.BroadcastComponent; import org.tasks.injection.InjectingBroadcastReceiver; import javax.inject.Inject; @@ -33,4 +34,9 @@ public class CompleteTaskReceiver extends InjectingBroadcastReceiver { Timber.e("Could not find task with id %s", taskId); } } + + @Override + protected void inject(BroadcastComponent component) { + component.inject(this); + } } diff --git a/src/main/java/org/tasks/receivers/FirstLaunchReceiver.java b/src/main/java/org/tasks/receivers/FirstLaunchReceiver.java index 77bdf2d30..6b2cdce1e 100644 --- a/src/main/java/org/tasks/receivers/FirstLaunchReceiver.java +++ b/src/main/java/org/tasks/receivers/FirstLaunchReceiver.java @@ -3,6 +3,7 @@ package org.tasks.receivers; import android.content.Context; import android.content.Intent; +import org.tasks.injection.BroadcastComponent; import org.tasks.injection.InjectingBroadcastReceiver; import org.tasks.scheduling.BackgroundScheduler; @@ -23,4 +24,9 @@ public class FirstLaunchReceiver extends InjectingBroadcastReceiver { backgroundScheduler.scheduleBackupService(); backgroundScheduler.scheduleMidnightRefresh(); } + + @Override + protected void inject(BroadcastComponent component) { + component.inject(this); + } } diff --git a/src/main/java/org/tasks/receivers/ListNotificationReceiver.java b/src/main/java/org/tasks/receivers/ListNotificationReceiver.java index 32cff10f5..7ea946f6d 100644 --- a/src/main/java/org/tasks/receivers/ListNotificationReceiver.java +++ b/src/main/java/org/tasks/receivers/ListNotificationReceiver.java @@ -4,6 +4,7 @@ import android.content.Context; import android.content.Intent; import org.tasks.Notifier; +import org.tasks.injection.BroadcastComponent; import org.tasks.injection.InjectingBroadcastReceiver; import java.util.concurrent.ExecutorService; @@ -39,4 +40,9 @@ public class ListNotificationReceiver extends InjectingBroadcastReceiver { } }); } + + @Override + protected void inject(BroadcastComponent component) { + component.inject(this); + } } diff --git a/src/main/java/org/tasks/receivers/MyPackageReplacedReceiver.java b/src/main/java/org/tasks/receivers/MyPackageReplacedReceiver.java index feb982c74..c760f108e 100644 --- a/src/main/java/org/tasks/receivers/MyPackageReplacedReceiver.java +++ b/src/main/java/org/tasks/receivers/MyPackageReplacedReceiver.java @@ -3,6 +3,7 @@ package org.tasks.receivers; import android.content.Context; import android.content.Intent; +import org.tasks.injection.BroadcastComponent; import org.tasks.injection.InjectingBroadcastReceiver; import org.tasks.scheduling.BackgroundScheduler; @@ -22,4 +23,9 @@ public class MyPackageReplacedReceiver extends InjectingBroadcastReceiver { backgroundScheduler.scheduleEverything(); } + + @Override + protected void inject(BroadcastComponent component) { + component.inject(this); + } } diff --git a/src/main/java/org/tasks/receivers/RefreshReceiver.java b/src/main/java/org/tasks/receivers/RefreshReceiver.java index 1f750a38e..999326304 100644 --- a/src/main/java/org/tasks/receivers/RefreshReceiver.java +++ b/src/main/java/org/tasks/receivers/RefreshReceiver.java @@ -4,6 +4,7 @@ import android.content.Context; import android.content.Intent; import org.tasks.Broadcaster; +import org.tasks.injection.BroadcastComponent; import org.tasks.injection.InjectingBroadcastReceiver; import javax.inject.Inject; @@ -22,4 +23,9 @@ public class RefreshReceiver extends InjectingBroadcastReceiver { broadcaster.refresh(); } + + @Override + protected void inject(BroadcastComponent component) { + component.inject(this); + } } diff --git a/src/main/java/org/tasks/receivers/TaskNotificationReceiver.java b/src/main/java/org/tasks/receivers/TaskNotificationReceiver.java index a3f7200bc..8b81d0b5a 100644 --- a/src/main/java/org/tasks/receivers/TaskNotificationReceiver.java +++ b/src/main/java/org/tasks/receivers/TaskNotificationReceiver.java @@ -4,6 +4,7 @@ import android.content.Context; import android.content.Intent; import org.tasks.Notifier; +import org.tasks.injection.BroadcastComponent; import org.tasks.injection.InjectingBroadcastReceiver; import java.util.concurrent.ExecutorService; @@ -33,4 +34,9 @@ public class TaskNotificationReceiver extends InjectingBroadcastReceiver { } }); } + + @Override + protected void inject(BroadcastComponent component) { + component.inject(this); + } } diff --git a/src/main/java/org/tasks/reminders/MissedCallActivity.java b/src/main/java/org/tasks/reminders/MissedCallActivity.java index 2e21b9f7a..e65ae47aa 100644 --- a/src/main/java/org/tasks/reminders/MissedCallActivity.java +++ b/src/main/java/org/tasks/reminders/MissedCallActivity.java @@ -10,6 +10,7 @@ import com.todoroo.astrid.data.Task; import com.todoroo.astrid.service.TaskService; import org.tasks.R; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingAppCompatActivity; import org.tasks.intents.TaskIntents; import org.tasks.notifications.NotificationManager; @@ -39,6 +40,11 @@ public class MissedCallActivity extends InjectingAppCompatActivity implements Mi setup(getIntent()); } + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } + @Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); diff --git a/src/main/java/org/tasks/reminders/MissedCallDialog.java b/src/main/java/org/tasks/reminders/MissedCallDialog.java index b977f926c..900b020e8 100644 --- a/src/main/java/org/tasks/reminders/MissedCallDialog.java +++ b/src/main/java/org/tasks/reminders/MissedCallDialog.java @@ -7,6 +7,7 @@ import android.support.annotation.NonNull; import org.tasks.R; import org.tasks.dialogs.DialogBuilder; +import org.tasks.injection.DialogFragmentComponent; import org.tasks.injection.InjectingDialogFragment; import java.util.List; @@ -17,6 +18,11 @@ import static java.util.Arrays.asList; public class MissedCallDialog extends InjectingDialogFragment { + @Override + protected void inject(DialogFragmentComponent component) { + component.inject(this); + } + public interface MissedCallHandler { void callNow(); diff --git a/src/main/java/org/tasks/reminders/NotificationActivity.java b/src/main/java/org/tasks/reminders/NotificationActivity.java index 19de65cb0..bf5ba5397 100644 --- a/src/main/java/org/tasks/reminders/NotificationActivity.java +++ b/src/main/java/org/tasks/reminders/NotificationActivity.java @@ -5,6 +5,7 @@ import android.content.Intent; import android.os.Bundle; import org.tasks.Broadcaster; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.InjectingAppCompatActivity; import org.tasks.intents.TaskIntents; import org.tasks.notifications.NotificationManager; @@ -29,6 +30,11 @@ public class NotificationActivity extends InjectingAppCompatActivity implements setup(getIntent()); } + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } + @Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); diff --git a/src/main/java/org/tasks/reminders/NotificationDialog.java b/src/main/java/org/tasks/reminders/NotificationDialog.java index 9012f3272..083e5f170 100644 --- a/src/main/java/org/tasks/reminders/NotificationDialog.java +++ b/src/main/java/org/tasks/reminders/NotificationDialog.java @@ -7,6 +7,7 @@ import android.support.annotation.NonNull; import org.tasks.R; import org.tasks.dialogs.DialogBuilder; +import org.tasks.injection.DialogFragmentComponent; import org.tasks.injection.InjectingDialogFragment; import java.util.List; @@ -17,6 +18,11 @@ import static java.util.Arrays.asList; public class NotificationDialog extends InjectingDialogFragment { + @Override + protected void inject(DialogFragmentComponent component) { + component.inject(this); + } + public interface NotificationHandler { void edit(); diff --git a/src/main/java/org/tasks/reminders/SnoozeActivity.java b/src/main/java/org/tasks/reminders/SnoozeActivity.java index 29c4d8403..afb8eeaca 100644 --- a/src/main/java/org/tasks/reminders/SnoozeActivity.java +++ b/src/main/java/org/tasks/reminders/SnoozeActivity.java @@ -10,6 +10,7 @@ import com.todoroo.astrid.reminders.SnoozeCallback; import com.todoroo.astrid.service.StartupService; import com.todoroo.astrid.service.TaskService; +import org.tasks.injection.ActivityComponent; import org.tasks.time.DateTime; import org.tasks.activities.DateAndTimePickerActivity; import org.tasks.activities.TimePickerActivity; @@ -40,6 +41,11 @@ public class SnoozeActivity extends InjectingAppCompatActivity implements Snooze setup(getIntent(), savedInstanceState); } + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } + @Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); diff --git a/src/main/java/org/tasks/reminders/SnoozeDialog.java b/src/main/java/org/tasks/reminders/SnoozeDialog.java index 7e654c6e5..8e77b2ff4 100644 --- a/src/main/java/org/tasks/reminders/SnoozeDialog.java +++ b/src/main/java/org/tasks/reminders/SnoozeDialog.java @@ -8,6 +8,7 @@ import android.support.annotation.NonNull; import com.todoroo.astrid.reminders.SnoozeCallback; +import org.tasks.injection.DialogFragmentComponent; import org.tasks.time.DateTime; import org.tasks.R; import org.tasks.dialogs.DialogBuilder; @@ -111,4 +112,9 @@ public class SnoozeDialog extends InjectingDialogFragment { public void setOnCancelListener(DialogInterface.OnCancelListener onCancelListener) { this.onCancelListener = onCancelListener; } + + @Override + protected void inject(DialogFragmentComponent component) { + component.inject(this); + } } \ No newline at end of file diff --git a/src/main/java/org/tasks/scheduling/BackupIntentService.java b/src/main/java/org/tasks/scheduling/BackupIntentService.java index 9bea02245..1c6ed3aa2 100644 --- a/src/main/java/org/tasks/scheduling/BackupIntentService.java +++ b/src/main/java/org/tasks/scheduling/BackupIntentService.java @@ -4,6 +4,7 @@ import android.content.Context; import com.todoroo.astrid.backup.TasksXmlExporter; +import org.tasks.injection.IntentServiceComponent; import org.tasks.preferences.Preferences; import java.io.File; @@ -96,4 +97,9 @@ public class BackupIntentService extends MidnightIntentService { } } } + + @Override + protected void inject(IntentServiceComponent component) { + component.inject(this); + } } diff --git a/src/main/java/org/tasks/scheduling/CalendarNotificationIntentService.java b/src/main/java/org/tasks/scheduling/CalendarNotificationIntentService.java index caa515f6b..81907552a 100644 --- a/src/main/java/org/tasks/scheduling/CalendarNotificationIntentService.java +++ b/src/main/java/org/tasks/scheduling/CalendarNotificationIntentService.java @@ -12,6 +12,7 @@ import org.tasks.R; import org.tasks.calendars.AndroidCalendarEvent; import org.tasks.calendars.CalendarEventProvider; import org.tasks.injection.ForApplication; +import org.tasks.injection.IntentServiceComponent; import org.tasks.preferences.Preferences; import java.util.concurrent.TimeUnit; @@ -65,4 +66,9 @@ public class CalendarNotificationIntentService extends RecurringIntervalIntentSe String getLastRunPreference() { return null; } + + @Override + protected void inject(IntentServiceComponent component) { + component.inject(this); + } } diff --git a/src/main/java/org/tasks/scheduling/GeofenceSchedulingIntentService.java b/src/main/java/org/tasks/scheduling/GeofenceSchedulingIntentService.java index aaf38edbb..34210ebdf 100644 --- a/src/main/java/org/tasks/scheduling/GeofenceSchedulingIntentService.java +++ b/src/main/java/org/tasks/scheduling/GeofenceSchedulingIntentService.java @@ -3,6 +3,7 @@ package org.tasks.scheduling; import android.content.Intent; import org.tasks.injection.InjectingIntentService; +import org.tasks.injection.IntentServiceComponent; import org.tasks.location.GeofenceService; import javax.inject.Inject; @@ -26,4 +27,9 @@ public class GeofenceSchedulingIntentService extends InjectingIntentService { geofenceService.cancelGeofences(); geofenceService.setupGeofences(); } + + @Override + protected void inject(IntentServiceComponent component) { + component.inject(this); + } } diff --git a/src/main/java/org/tasks/scheduling/RefreshSchedulerIntentService.java b/src/main/java/org/tasks/scheduling/RefreshSchedulerIntentService.java index 4f82da2fe..b819a5cf4 100644 --- a/src/main/java/org/tasks/scheduling/RefreshSchedulerIntentService.java +++ b/src/main/java/org/tasks/scheduling/RefreshSchedulerIntentService.java @@ -1,6 +1,7 @@ package org.tasks.scheduling; import org.tasks.Broadcaster; +import org.tasks.injection.IntentServiceComponent; import javax.inject.Inject; @@ -18,4 +19,9 @@ public class RefreshSchedulerIntentService extends MidnightIntentService { refreshScheduler.scheduleApplicationRefreshes(); broadcaster.refresh(); } + + @Override + protected void inject(IntentServiceComponent component) { + component.inject(this); + } } diff --git a/src/main/java/org/tasks/scheduling/ReminderSchedulerIntentService.java b/src/main/java/org/tasks/scheduling/ReminderSchedulerIntentService.java index 319b7d567..f7c5b5c36 100644 --- a/src/main/java/org/tasks/scheduling/ReminderSchedulerIntentService.java +++ b/src/main/java/org/tasks/scheduling/ReminderSchedulerIntentService.java @@ -7,6 +7,7 @@ import com.todoroo.astrid.dao.TaskDao; import com.todoroo.astrid.reminders.ReminderService; import org.tasks.injection.InjectingIntentService; +import org.tasks.injection.IntentServiceComponent; import javax.inject.Inject; @@ -31,4 +32,9 @@ public class ReminderSchedulerIntentService extends InjectingIntentService { reminderService.scheduleAllAlarms(taskDao); alarmService.scheduleAllAlarms(); } + + @Override + protected void inject(IntentServiceComponent component) { + component.inject(this); + } } diff --git a/src/main/java/org/tasks/ui/CalendarControlSet.java b/src/main/java/org/tasks/ui/CalendarControlSet.java index f7ec8a85b..b507857b0 100644 --- a/src/main/java/org/tasks/ui/CalendarControlSet.java +++ b/src/main/java/org/tasks/ui/CalendarControlSet.java @@ -29,6 +29,7 @@ import org.tasks.analytics.Tracker; import org.tasks.calendars.CalendarProvider; import org.tasks.dialogs.DialogBuilder; import org.tasks.injection.ForActivity; +import org.tasks.injection.FragmentComponent; import org.tasks.preferences.FragmentPermissionRequestor; import org.tasks.preferences.PermissionChecker; import org.tasks.preferences.Preferences; @@ -336,4 +337,9 @@ public class CalendarControlSet extends TaskEditControlFragment { return false; } + + @Override + protected void inject(FragmentComponent component) { + component.inject(this); + } } diff --git a/src/main/java/org/tasks/ui/DeadlineControlSet.java b/src/main/java/org/tasks/ui/DeadlineControlSet.java index b590d6a76..7c08fe450 100644 --- a/src/main/java/org/tasks/ui/DeadlineControlSet.java +++ b/src/main/java/org/tasks/ui/DeadlineControlSet.java @@ -22,6 +22,7 @@ import org.tasks.R; import org.tasks.activities.DatePickerActivity; import org.tasks.activities.TimePickerActivity; import org.tasks.injection.ForActivity; +import org.tasks.injection.FragmentComponent; import org.tasks.preferences.ActivityPreferences; import org.tasks.time.DateTime; @@ -113,6 +114,11 @@ public class DeadlineControlSet extends TaskEditControlFragment { activity.getString(R.string.pick_a_time)); } + @Override + protected void inject(FragmentComponent component) { + component.inject(this); + } + @Nullable @Override public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { diff --git a/src/main/java/org/tasks/ui/DescriptionControlSet.java b/src/main/java/org/tasks/ui/DescriptionControlSet.java index e4c206707..5aa34534b 100644 --- a/src/main/java/org/tasks/ui/DescriptionControlSet.java +++ b/src/main/java/org/tasks/ui/DescriptionControlSet.java @@ -11,6 +11,7 @@ import com.google.common.base.Strings; import com.todoroo.astrid.data.Task; import org.tasks.R; +import org.tasks.injection.FragmentComponent; import butterknife.Bind; import butterknife.OnTextChanged; @@ -78,4 +79,9 @@ public class DescriptionControlSet extends TaskEditControlFragment { public boolean hasChanges(Task original) { return !description.equals(original.getNotes()); } + + @Override + protected void inject(FragmentComponent component) { + component.inject(this); + } } diff --git a/src/main/java/org/tasks/ui/NavigationDrawerFragment.java b/src/main/java/org/tasks/ui/NavigationDrawerFragment.java index 6bacb212f..11756c732 100644 --- a/src/main/java/org/tasks/ui/NavigationDrawerFragment.java +++ b/src/main/java/org/tasks/ui/NavigationDrawerFragment.java @@ -26,6 +26,7 @@ import org.tasks.R; import org.tasks.filters.FilterCounter; import org.tasks.filters.FilterProvider; import org.tasks.filters.NavigationDrawerAction; +import org.tasks.injection.FragmentComponent; import org.tasks.injection.InjectingFragment; import org.tasks.preferences.AppearancePreferences; @@ -199,6 +200,11 @@ public class NavigationDrawerFragment extends InjectingFragment { mCallbacks = (OnFilterItemClickedListener) activity; } + @Override + protected void inject(FragmentComponent component) { + component.inject(this); + } + @Override public void onDetach() { super.onDetach(); diff --git a/src/main/java/org/tasks/ui/PriorityControlSet.java b/src/main/java/org/tasks/ui/PriorityControlSet.java index a87437a4d..dd79fef19 100644 --- a/src/main/java/org/tasks/ui/PriorityControlSet.java +++ b/src/main/java/org/tasks/ui/PriorityControlSet.java @@ -13,6 +13,7 @@ import android.widget.CompoundButton; import com.todoroo.astrid.data.Task; import org.tasks.R; +import org.tasks.injection.FragmentComponent; import javax.inject.Inject; @@ -48,6 +49,11 @@ public class PriorityControlSet extends TaskEditControlFragment { callback = (OnPriorityChanged) activity; } + @Override + protected void inject(FragmentComponent component) { + component.inject(this); + } + @OnClick({R.id.priority_high, R.id.priority_medium, R.id.priority_low, R.id.priority_none}) void onImportanceChanged(CompoundButton button) { priority = getPriority(); diff --git a/src/main/java/org/tasks/voice/VoiceCommandActivity.java b/src/main/java/org/tasks/voice/VoiceCommandActivity.java index c3ee7094f..ad8613d23 100644 --- a/src/main/java/org/tasks/voice/VoiceCommandActivity.java +++ b/src/main/java/org/tasks/voice/VoiceCommandActivity.java @@ -8,6 +8,7 @@ import android.widget.Toast; import com.todoroo.astrid.service.TaskCreator; import org.tasks.R; +import org.tasks.injection.ActivityComponent; import org.tasks.injection.ForApplication; import org.tasks.injection.InjectingAppCompatActivity; @@ -32,4 +33,9 @@ public class VoiceCommandActivity extends InjectingAppCompatActivity { finish(); } } + + @Override + public void inject(ActivityComponent component) { + component.inject(this); + } } diff --git a/src/main/java/org/tasks/widget/ScrollableWidgetUpdateService.java b/src/main/java/org/tasks/widget/ScrollableWidgetUpdateService.java index 5dc426e3f..aa2e80dbc 100644 --- a/src/main/java/org/tasks/widget/ScrollableWidgetUpdateService.java +++ b/src/main/java/org/tasks/widget/ScrollableWidgetUpdateService.java @@ -10,6 +10,7 @@ import com.todoroo.astrid.service.TaskService; import com.todoroo.astrid.subtasks.SubtasksHelper; import org.tasks.injection.InjectingRemoteViewsService; +import org.tasks.injection.RemoteViewsServiceComponent; import org.tasks.preferences.Preferences; import javax.inject.Inject; @@ -47,4 +48,9 @@ public class ScrollableWidgetUpdateService extends InjectingRemoteViewsService { return new ScrollableViewsFactory(subtasksHelper, preferences, this, filter, widgetId, database, taskService); } + + @Override + protected void inject(RemoteViewsServiceComponent component) { + component.inject(this); + } }