Clean up dagger scopes

pull/437/head
Alex Baker 8 years ago
parent 5df88f2093
commit 1804e00568

@ -11,14 +11,14 @@ import com.google.common.base.Strings;
import org.tasks.BuildConfig; import org.tasks.BuildConfig;
import org.tasks.R; import org.tasks.R;
import org.tasks.injection.ApplicationScope;
import org.tasks.injection.ForApplication; import org.tasks.injection.ForApplication;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton;
import timber.log.Timber; import timber.log.Timber;
@Singleton @ApplicationScope
public class Tracker { public class Tracker {
private final GoogleAnalytics analytics; private final GoogleAnalytics analytics;

@ -1,10 +1,8 @@
package org.tasks.injection; package org.tasks.injection;
import javax.inject.Singleton;
import dagger.Subcomponent; import dagger.Subcomponent;
@Singleton @ActivityScope
@Subcomponent(modules = ActivityModule.class) @Subcomponent(modules = ActivityModule.class)
public interface ActivityComponent extends BaseActivityComponent { public interface ActivityComponent extends BaseActivityComponent {

@ -1,10 +1,8 @@
package org.tasks.injection; package org.tasks.injection;
import javax.inject.Singleton;
import dagger.Component; import dagger.Component;
@Singleton @ApplicationScope
@Component(modules = ApplicationModule.class) @Component(modules = ApplicationModule.class)
public interface ApplicationComponent extends BaseApplicationComponent { public interface ApplicationComponent extends BaseApplicationComponent {
} }

@ -6,8 +6,6 @@ import com.todoroo.astrid.dao.Database;
import org.tasks.analytics.Tracker; import org.tasks.analytics.Tracker;
import javax.inject.Singleton;
import dagger.Module; import dagger.Module;
import dagger.Provides; import dagger.Provides;
@ -21,7 +19,7 @@ public class TestModule {
this.context = context; this.context = context;
} }
@Singleton @ApplicationScope
@Provides @Provides
public Database getDatabase() { public Database getDatabase() {
return new Database(context, mock(Tracker.class)) { return new Database(context, mock(Tracker.class)) {
@ -32,7 +30,7 @@ public class TestModule {
}; };
} }
@Singleton @ApplicationScope
@Provides @Provides
@ForApplication @ForApplication
public Context getContext() { public Context getContext() {

@ -1,10 +1,8 @@
package org.tasks.injection; package org.tasks.injection;
import javax.inject.Singleton;
import dagger.Component; import dagger.Component;
@Singleton @ApplicationScope
@Component(modules = TestModule.class) @Component(modules = TestModule.class)
public interface TestComponent extends BaseTestComponent { public interface TestComponent extends BaseTestComponent {
} }

@ -1,10 +1,8 @@
package org.tasks.injection; package org.tasks.injection;
import javax.inject.Singleton;
import dagger.Component; import dagger.Component;
@Singleton @ApplicationScope
@Component(modules = TestModule.class) @Component(modules = TestModule.class)
public interface TestComponent extends BaseTestComponent { public interface TestComponent extends BaseTestComponent {
} }

@ -6,11 +6,9 @@ import com.todoroo.astrid.gtasks.GtasksMetadataServiceTest;
import com.todoroo.astrid.gtasks.GtasksTaskListUpdaterTest; import com.todoroo.astrid.gtasks.GtasksTaskListUpdaterTest;
import com.todoroo.astrid.gtasks.GtasksTaskMovingTest; import com.todoroo.astrid.gtasks.GtasksTaskMovingTest;
import javax.inject.Singleton;
import dagger.Component; import dagger.Component;
@Singleton @ApplicationScope
@Component(modules = TestModule.class) @Component(modules = TestModule.class)
public interface TestComponent extends BaseTestComponent { public interface TestComponent extends BaseTestComponent {

@ -1,10 +1,8 @@
package org.tasks.injection; package org.tasks.injection;
import javax.inject.Singleton;
import dagger.Subcomponent; import dagger.Subcomponent;
@Singleton @ActivityScope
@Subcomponent(modules = ActivityModule.class) @Subcomponent(modules = ActivityModule.class)
public interface ActivityComponent extends BaseActivityComponent { public interface ActivityComponent extends BaseActivityComponent {

@ -1,10 +1,8 @@
package org.tasks.injection; package org.tasks.injection;
import javax.inject.Singleton;
import dagger.Component; import dagger.Component;
@Singleton @ApplicationScope
@Component(modules = ApplicationModule.class) @Component(modules = ApplicationModule.class)
public interface ApplicationComponent extends BaseApplicationComponent { public interface ApplicationComponent extends BaseApplicationComponent {
} }

@ -5,7 +5,6 @@
*/ */
package com.todoroo.astrid.gtasks; package com.todoroo.astrid.gtasks;
import android.app.Activity;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
@ -44,7 +43,6 @@ public class GtasksPreferences extends InjectingPreferenceActivity implements Go
@Inject GtasksListService gtasksListService; @Inject GtasksListService gtasksListService;
@Inject Tracker tracker; @Inject Tracker tracker;
@Inject SyncAdapterHelper syncAdapterHelper; @Inject SyncAdapterHelper syncAdapterHelper;
@Inject Activity activity;
@Inject PlayServicesAvailability playServicesAvailability; @Inject PlayServicesAvailability playServicesAvailability;
@Inject DialogBuilder dialogBuilder; @Inject DialogBuilder dialogBuilder;
@Inject MetadataDao metadataDao; @Inject MetadataDao metadataDao;
@ -62,7 +60,7 @@ public class GtasksPreferences extends InjectingPreferenceActivity implements Go
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
if ((boolean) newValue) { if ((boolean) newValue) {
if (!playServicesAvailability.refreshAndCheck()) { if (!playServicesAvailability.refreshAndCheck()) {
playServicesAvailability.resolve(activity); playServicesAvailability.resolve(GtasksPreferences.this);
} else if (permissionRequestor.requestAccountPermissions()) { } else if (permissionRequestor.requestAccountPermissions()) {
requestLogin(); requestLogin();
} }

@ -19,6 +19,8 @@ import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.gtasks.sync.GtasksSyncService; import com.todoroo.astrid.gtasks.sync.GtasksSyncService;
import org.tasks.injection.ApplicationScope;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
@ -26,11 +28,10 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton;
import timber.log.Timber; import timber.log.Timber;
@Singleton @ApplicationScope
public class GtasksTaskListUpdater extends OrderedMetadataListUpdater<GtasksList> { public class GtasksTaskListUpdater extends OrderedMetadataListUpdater<GtasksList> {
/** map of task -> parent task */ /** map of task -> parent task */

@ -16,17 +16,16 @@ import com.google.api.services.tasks.model.TaskList;
import com.google.api.services.tasks.model.TaskLists; import com.google.api.services.tasks.model.TaskLists;
import com.todoroo.astrid.gtasks.GtasksPreferenceService; import com.todoroo.astrid.gtasks.GtasksPreferenceService;
import org.tasks.AccountManager;
import org.tasks.BuildConfig; import org.tasks.BuildConfig;
import org.tasks.analytics.Tracker; import org.tasks.analytics.Tracker;
import org.tasks.gtasks.GoogleTasksUnsuccessfulResponseHandler; import org.tasks.gtasks.GoogleTasksUnsuccessfulResponseHandler;
import org.tasks.injection.ApplicationScope;
import org.tasks.injection.ForApplication; import org.tasks.injection.ForApplication;
import java.io.IOException; import java.io.IOException;
import java.util.Collections; import java.util.Collections;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton;
import timber.log.Timber; import timber.log.Timber;
@ -36,7 +35,7 @@ import timber.log.Timber;
* *
* @author Sam Bosley * @author Sam Bosley
*/ */
@Singleton @ApplicationScope
public class GtasksInvoker { public class GtasksInvoker {
private final Context context; private final Context context;

@ -26,6 +26,7 @@ import com.todoroo.astrid.gtasks.api.GtasksInvoker;
import com.todoroo.astrid.gtasks.api.MoveRequest; import com.todoroo.astrid.gtasks.api.MoveRequest;
import org.tasks.gtasks.SyncAdapterHelper; import org.tasks.gtasks.SyncAdapterHelper;
import org.tasks.injection.ApplicationScope;
import java.io.IOException; import java.io.IOException;
import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.LinkedBlockingQueue;
@ -34,11 +35,10 @@ import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton;
import timber.log.Timber; import timber.log.Timber;
@Singleton @ApplicationScope
public class GtasksSyncService { public class GtasksSyncService {
private final MetadataDao metadataDao; private final MetadataDao metadataDao;

@ -1,13 +1,10 @@
package org.tasks; package org.tasks;
import com.todoroo.astrid.gtasks.GtasksPreferenceService; import com.todoroo.astrid.gtasks.GtasksPreferenceService;
import com.todoroo.astrid.gtasks.GtasksTaskListUpdater;
import org.tasks.billing.InventoryHelper; import org.tasks.billing.InventoryHelper;
import org.tasks.billing.PurchaseHelper;
import org.tasks.gtasks.PlayServicesAvailability; import org.tasks.gtasks.PlayServicesAvailability;
import org.tasks.gtasks.SyncAdapterHelper; import org.tasks.gtasks.SyncAdapterHelper;
import org.tasks.sync.SyncExecutor;
import javax.inject.Inject; import javax.inject.Inject;
@ -19,11 +16,7 @@ public class FlavorSetup {
private final PlayServicesAvailability playServicesAvailability; private final PlayServicesAvailability playServicesAvailability;
@Inject @Inject
public FlavorSetup(GtasksPreferenceService gtasksPreferenceService, public FlavorSetup(GtasksPreferenceService gtasksPreferenceService, InventoryHelper inventoryHelper,
@SuppressWarnings("UnusedParameters") GtasksTaskListUpdater gtasksTaskListUpdater,
@SuppressWarnings("UnusedParameters") PurchaseHelper purchaseHelper,
@SuppressWarnings("UnusedParameters") SyncExecutor syncExecutor,
InventoryHelper inventoryHelper,
SyncAdapterHelper syncAdapterHelper, PlayServicesAvailability playServicesAvailability) { SyncAdapterHelper syncAdapterHelper, PlayServicesAvailability playServicesAvailability) {
this.gtasksPreferenceService = gtasksPreferenceService; this.gtasksPreferenceService = gtasksPreferenceService;
this.inventoryHelper = inventoryHelper; this.inventoryHelper = inventoryHelper;

@ -12,14 +12,14 @@ import com.google.common.base.Strings;
import org.tasks.BuildConfig; import org.tasks.BuildConfig;
import org.tasks.R; import org.tasks.R;
import org.tasks.injection.ApplicationScope;
import org.tasks.injection.ForApplication; import org.tasks.injection.ForApplication;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton;
import timber.log.Timber; import timber.log.Timber;
@Singleton @ApplicationScope
public class Tracker { public class Tracker {
private final GoogleAnalytics analytics; private final GoogleAnalytics analytics;

@ -11,6 +11,7 @@ import com.android.vending.billing.Purchase;
import org.tasks.Broadcaster; import org.tasks.Broadcaster;
import org.tasks.R; import org.tasks.R;
import org.tasks.injection.ApplicationScope;
import org.tasks.injection.ForApplication; import org.tasks.injection.ForApplication;
import org.tasks.preferences.Preferences; import org.tasks.preferences.Preferences;
@ -18,11 +19,10 @@ import java.util.concurrent.Executor;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
import javax.inject.Singleton;
import timber.log.Timber; import timber.log.Timber;
@Singleton @ApplicationScope
public class InventoryHelper implements IabBroadcastReceiver.IabBroadcastListener { public class InventoryHelper implements IabBroadcastReceiver.IabBroadcastListener {
private final Context context; private final Context context;

@ -16,6 +16,7 @@ import org.tasks.BuildConfig;
import org.tasks.R; import org.tasks.R;
import org.tasks.analytics.Tracker; import org.tasks.analytics.Tracker;
import org.tasks.dialogs.DialogBuilder; import org.tasks.dialogs.DialogBuilder;
import org.tasks.injection.ApplicationScope;
import org.tasks.injection.ForApplication; import org.tasks.injection.ForApplication;
import org.tasks.preferences.Preferences; import org.tasks.preferences.Preferences;
@ -25,13 +26,12 @@ import java.util.concurrent.Executor;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
import javax.inject.Singleton;
import timber.log.Timber; import timber.log.Timber;
import static com.todoroo.andlib.utility.AndroidUtilities.isAppInstalled; import static com.todoroo.andlib.utility.AndroidUtilities.isAppInstalled;
@Singleton @ApplicationScope
public class PurchaseHelper implements IabHelper.OnIabSetupFinishedListener { public class PurchaseHelper implements IabHelper.OnIabSetupFinishedListener {
private final Context context; private final Context context;

@ -6,11 +6,9 @@ import com.todoroo.astrid.gtasks.auth.GtasksLoginActivity;
import org.tasks.dashclock.DashClockSettings; import org.tasks.dashclock.DashClockSettings;
import org.tasks.locale.ui.activity.TaskerSettingsActivity; import org.tasks.locale.ui.activity.TaskerSettingsActivity;
import javax.inject.Singleton;
import dagger.Subcomponent; import dagger.Subcomponent;
@Singleton @ActivityScope
@Subcomponent(modules = ActivityModule.class) @Subcomponent(modules = ActivityModule.class)
public interface ActivityComponent extends BaseActivityComponent { public interface ActivityComponent extends BaseActivityComponent {

@ -1,10 +1,8 @@
package org.tasks.injection; package org.tasks.injection;
import javax.inject.Singleton;
import dagger.Component; import dagger.Component;
@Singleton @ApplicationScope
@Component(modules = ApplicationModule.class) @Component(modules = ApplicationModule.class)
public interface ApplicationComponent extends BaseApplicationComponent { public interface ApplicationComponent extends BaseApplicationComponent {
SyncAdapterComponent plus(SyncAdapterModule syncAdapterModule); SyncAdapterComponent plus(SyncAdapterModule syncAdapterModule);

@ -24,6 +24,7 @@ import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.reminders.ReminderService; import com.todoroo.astrid.reminders.ReminderService;
import com.todoroo.astrid.service.SynchronizeMetadataCallback; import com.todoroo.astrid.service.SynchronizeMetadataCallback;
import org.tasks.injection.ApplicationScope;
import org.tasks.injection.ForApplication; import org.tasks.injection.ForApplication;
import org.tasks.receivers.TaskNotificationReceiver; import org.tasks.receivers.TaskNotificationReceiver;
import org.tasks.scheduling.AlarmManager; import org.tasks.scheduling.AlarmManager;
@ -35,7 +36,6 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton;
/** /**
* Provides operations for working with alerts * Provides operations for working with alerts
@ -43,7 +43,7 @@ import javax.inject.Singleton;
* @author Tim Su <tim@todoroo.com> * @author Tim Su <tim@todoroo.com>
* *
*/ */
@Singleton @ApplicationScope
public class AlarmService { public class AlarmService {
private static final long NO_ALARM = Long.MAX_VALUE; private static final long NO_ALARM = Long.MAX_VALUE;

@ -30,10 +30,10 @@ import com.todoroo.astrid.provider.Astrid2TaskProvider;
import com.todoroo.astrid.provider.Astrid3ContentProvider; import com.todoroo.astrid.provider.Astrid3ContentProvider;
import org.tasks.analytics.Tracker; import org.tasks.analytics.Tracker;
import org.tasks.injection.ApplicationScope;
import org.tasks.injection.ForApplication; import org.tasks.injection.ForApplication;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton;
import timber.log.Timber; import timber.log.Timber;
@ -43,7 +43,7 @@ import timber.log.Timber;
* @author Tim Su <tim@todoroo.com> * @author Tim Su <tim@todoroo.com>
* *
*/ */
@Singleton @ApplicationScope
public class Database { public class Database {
private static final int VERSION = 36; private static final int VERSION = 36;

@ -15,10 +15,11 @@ import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.astrid.data.Metadata; import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import org.tasks.injection.ApplicationScope;
import java.util.List; import java.util.List;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton;
/** /**
* Data Access layer for {@link Metadata}-related operations. * Data Access layer for {@link Metadata}-related operations.
@ -26,7 +27,7 @@ import javax.inject.Singleton;
* @author Tim Su <tim@todoroo.com> * @author Tim Su <tim@todoroo.com>
* *
*/ */
@Singleton @ApplicationScope
public class MetadataDao { public class MetadataDao {
private final DatabaseDao<Metadata> dao; private final DatabaseDao<Metadata> dao;

@ -6,7 +6,6 @@
package com.todoroo.astrid.dao; package com.todoroo.astrid.dao;
import com.todoroo.andlib.data.Callback; import com.todoroo.andlib.data.Callback;
import com.todoroo.andlib.data.DatabaseDao;
import com.todoroo.andlib.data.Property; import com.todoroo.andlib.data.Property;
import com.todoroo.andlib.sql.Criterion; import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.sql.Functions; import com.todoroo.andlib.sql.Functions;
@ -15,15 +14,16 @@ import com.todoroo.andlib.sql.Query;
import com.todoroo.astrid.data.RemoteModel; import com.todoroo.astrid.data.RemoteModel;
import com.todoroo.astrid.data.TagData; import com.todoroo.astrid.data.TagData;
import org.tasks.injection.ApplicationScope;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton;
/** /**
* Data Access layer for {@link TagData}-related operations. * Data Access layer for {@link TagData}-related operations.
* *
* @author Tim Su <tim@todoroo.com> * @author Tim Su <tim@todoroo.com>
*/ */
@Singleton @ApplicationScope
public class TagDataDao { public class TagDataDao {
private final RemoteModelDao<TagData> dao; private final RemoteModelDao<TagData> dao;

@ -26,6 +26,7 @@ import com.todoroo.astrid.reminders.ReminderService;
import org.tasks.Broadcaster; import org.tasks.Broadcaster;
import org.tasks.R; import org.tasks.R;
import org.tasks.injection.ApplicationScope;
import org.tasks.location.GeofenceService; import org.tasks.location.GeofenceService;
import org.tasks.notifications.NotificationManager; import org.tasks.notifications.NotificationManager;
import org.tasks.preferences.Preferences; import org.tasks.preferences.Preferences;
@ -33,7 +34,6 @@ import org.tasks.preferences.Preferences;
import java.util.List; import java.util.List;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton;
import timber.log.Timber; import timber.log.Timber;
@ -43,7 +43,7 @@ import timber.log.Timber;
* @author Tim Su <tim@todoroo.com> * @author Tim Su <tim@todoroo.com>
* *
*/ */
@Singleton @ApplicationScope
public class TaskDao { public class TaskDao {
public static final String TRANS_SUPPRESS_REFRESH = "suppress-refresh"; public static final String TRANS_SUPPRESS_REFRESH = "suppress-refresh";

@ -18,7 +18,6 @@ import org.tasks.injection.ActivityComponent;
import org.tasks.injection.ThemedInjectingAppCompatActivity; import org.tasks.injection.ThemedInjectingAppCompatActivity;
import org.tasks.preferences.BasicPreferences; import org.tasks.preferences.BasicPreferences;
import org.tasks.preferences.Preferences; import org.tasks.preferences.Preferences;
import org.tasks.preferences.ResourceResolver;
import org.tasks.scheduling.AlarmManager; import org.tasks.scheduling.AlarmManager;
import org.tasks.scheduling.CalendarNotificationIntentService; import org.tasks.scheduling.CalendarNotificationIntentService;
import org.tasks.themes.ThemeAccent; import org.tasks.themes.ThemeAccent;
@ -39,7 +38,6 @@ public class CalendarReminderActivity extends ThemedInjectingAppCompatActivity {
private static final int IGNORE_PROMPT_COUNT = 3; private static final int IGNORE_PROMPT_COUNT = 3;
@Inject Preferences preferences; @Inject Preferences preferences;
@Inject ResourceResolver resourceResolver;
@Inject DialogBuilder dialogBuilder; @Inject DialogBuilder dialogBuilder;
@Inject AlarmManager alarmManager; @Inject AlarmManager alarmManager;
@Inject ThemeAccent themeAccent; @Inject ThemeAccent themeAccent;

@ -13,14 +13,12 @@ import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.astrid.data.Metadata; import com.todoroo.astrid.data.Metadata;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton;
/** /**
* Metadata entries for a GTasks Task * Metadata entries for a GTasks Task
* @author Tim Su <tim@todoroo.com> * @author Tim Su <tim@todoroo.com>
* *
*/ */
@Singleton
public class GtasksMetadata { public class GtasksMetadata {
/** metadata key */ /** metadata key */

@ -19,6 +19,7 @@ import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import org.tasks.R; import org.tasks.R;
import org.tasks.injection.ApplicationScope;
import org.tasks.injection.ForApplication; import org.tasks.injection.ForApplication;
import org.tasks.preferences.Preferences; import org.tasks.preferences.Preferences;
import org.tasks.receivers.TaskNotificationReceiver; import org.tasks.receivers.TaskNotificationReceiver;
@ -28,7 +29,6 @@ import org.tasks.time.DateTime;
import java.util.Random; import java.util.Random;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton;
import timber.log.Timber; import timber.log.Timber;
@ -40,7 +40,7 @@ import static org.tasks.date.DateTimeUtils.newDateTime;
* @author Tim Su <tim@todoroo.com> * @author Tim Su <tim@todoroo.com>
* *
*/ */
@Singleton @ApplicationScope
public final class ReminderService { public final class ReminderService {
// --- constants // --- constants

@ -27,13 +27,13 @@ import com.todoroo.astrid.tags.TaskToTagMetadata;
import com.todoroo.astrid.utility.TitleParser; import com.todoroo.astrid.utility.TitleParser;
import org.tasks.Broadcaster; import org.tasks.Broadcaster;
import org.tasks.injection.ApplicationScope;
import org.tasks.scheduling.RefreshScheduler; import org.tasks.scheduling.RefreshScheduler;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Map.Entry; import java.util.Map.Entry;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton;
import timber.log.Timber; import timber.log.Timber;
@ -44,7 +44,7 @@ import timber.log.Timber;
* @author Tim Su <tim@todoroo.com> * @author Tim Su <tim@todoroo.com>
* *
*/ */
@Singleton @ApplicationScope
public class TaskService { public class TaskService {
private final TagDataDao tagDataDao; private final TagDataDao tagDataDao;

@ -23,11 +23,12 @@ import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.TagData; import com.todoroo.astrid.data.TagData;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import org.tasks.injection.ApplicationScope;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton;
import static com.google.common.collect.Lists.newArrayList; import static com.google.common.collect.Lists.newArrayList;
import static com.google.common.collect.Lists.transform; import static com.google.common.collect.Lists.transform;
@ -38,7 +39,7 @@ import static com.google.common.collect.Lists.transform;
* @author Tim Su <tim@todoroo.com> * @author Tim Su <tim@todoroo.com>
* *
*/ */
@Singleton @ApplicationScope
public final class TagService { public final class TagService {
private final MetadataDao metadataDao; private final MetadataDao metadataDao;

@ -12,9 +12,7 @@ import org.tasks.receivers.CompleteTaskReceiver;
import org.tasks.receivers.FirstLaunchReceiver; import org.tasks.receivers.FirstLaunchReceiver;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton;
@Singleton
public class Broadcaster { public class Broadcaster {
private final Context context; private final Context context;

@ -1,12 +1,6 @@
package org.tasks; package org.tasks;
import com.todoroo.astrid.dao.MetadataDao;
import com.todoroo.astrid.dao.StoreObjectDao;
import com.todoroo.astrid.dao.TagDataDao;
import com.todoroo.astrid.dao.TaskDao;
import com.todoroo.astrid.service.StartupService; import com.todoroo.astrid.service.StartupService;
import com.todoroo.astrid.service.TaskService;
import com.todoroo.astrid.tags.TagService;
import org.tasks.analytics.Tracker; import org.tasks.analytics.Tracker;
import org.tasks.injection.ApplicationComponent; import org.tasks.injection.ApplicationComponent;
@ -17,17 +11,9 @@ import org.tasks.themes.ThemeCache;
import javax.inject.Inject; import javax.inject.Inject;
@SuppressWarnings("UnusedDeclaration")
public class Tasks extends InjectingApplication { public class Tasks extends InjectingApplication {
@Inject StartupService startupService; @Inject StartupService startupService;
@Inject TaskDao taskDao;
@Inject MetadataDao metadataDao;
@Inject TagDataDao tagDataDao;
@Inject StoreObjectDao storeObjectDao;
@Inject TaskService taskService;
@Inject TagService tagService;
@Inject Broadcaster broadcaster;
@Inject Preferences preferences; @Inject Preferences preferences;
@Inject Tracker tracker; @Inject Tracker tracker;
@Inject FlavorSetup flavorSetup; @Inject FlavorSetup flavorSetup;

@ -1,6 +1,5 @@
package org.tasks.activities; package org.tasks.activities;
import android.app.Activity;
import android.content.ClipData; import android.content.ClipData;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
@ -31,7 +30,6 @@ public class CameraActivity extends InjectingAppCompatActivity {
public static final String EXTRA_URI = "extra_uri"; public static final String EXTRA_URI = "extra_uri";
@Inject Preferences preferences; @Inject Preferences preferences;
@Inject Activity activity;
private File output; private File output;
@ -44,7 +42,7 @@ public class CameraActivity extends InjectingAppCompatActivity {
} else { } else {
output = getFilename(".jpeg"); output = getFilename(".jpeg");
if (output == null) { if (output == null) {
Toast.makeText(activity, R.string.external_storage_unavailable, Toast.LENGTH_LONG).show(); Toast.makeText(this, R.string.external_storage_unavailable, Toast.LENGTH_LONG).show();
} else { } else {
final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
Uri uri = Uri.fromFile(output); Uri uri = Uri.fromFile(output);
@ -54,7 +52,7 @@ public class CameraActivity extends InjectingAppCompatActivity {
if (atLeastLollipop()) { if (atLeastLollipop()) {
intent.setClipData(ClipData.newRawUri(null, uri)); intent.setClipData(ClipData.newRawUri(null, uri));
} }
activity.startActivityForResult(intent, REQUEST_CODE_CAMERA); startActivityForResult(intent, REQUEST_CODE_CAMERA);
} }
} }
} }

@ -1,6 +1,7 @@
package org.tasks.injection; package org.tasks.injection;
import android.app.Activity; import android.app.Activity;
import android.content.Context;
import org.tasks.R; import org.tasks.R;
import org.tasks.fragments.TaskEditControlSetFragmentManager; import org.tasks.fragments.TaskEditControlSetFragmentManager;
@ -11,8 +12,6 @@ import org.tasks.themes.ThemeBase;
import org.tasks.themes.ThemeCache; import org.tasks.themes.ThemeCache;
import org.tasks.themes.ThemeColor; import org.tasks.themes.ThemeColor;
import javax.inject.Singleton;
import dagger.Module; import dagger.Module;
import dagger.Provides; import dagger.Provides;
@ -31,25 +30,31 @@ public class ActivityModule {
} }
@Provides @Provides
@Singleton @ForActivity
public Context getActivityContext() {
return activity;
}
@Provides
@ActivityScope
public ThemeBase getThemeBase(ThemeCache themeCache, Preferences preferences) { public ThemeBase getThemeBase(ThemeCache themeCache, Preferences preferences) {
return themeCache.getThemeBase(preferences.getInt(R.string.p_theme, 0)); return themeCache.getThemeBase(preferences.getInt(R.string.p_theme, 0));
} }
@Provides @Provides
@Singleton @ActivityScope
public ThemeColor getThemeColor(ThemeCache themeCache, Preferences preferences) { public ThemeColor getThemeColor(ThemeCache themeCache, Preferences preferences) {
return themeCache.getThemeColor(preferences.getInt(R.string.p_theme_color, 0)); return themeCache.getThemeColor(preferences.getInt(R.string.p_theme_color, 0));
} }
@Provides @Provides
@Singleton @ActivityScope
public ThemeAccent getThemeAccent(ThemeCache themeCache, Preferences preferences) { public ThemeAccent getThemeAccent(ThemeCache themeCache, Preferences preferences) {
return themeCache.getThemeAccent(preferences.getInt(R.string.p_theme_accent, 1)); return themeCache.getThemeAccent(preferences.getInt(R.string.p_theme_accent, 1));
} }
@Provides @Provides
@Singleton @ActivityScope
public TaskEditControlSetFragmentManager getTaskEditControlSetFragmentManager(Preferences preferences, SyncAdapterHelper syncAdapterHelper) { public TaskEditControlSetFragmentManager getTaskEditControlSetFragmentManager(Preferences preferences, SyncAdapterHelper syncAdapterHelper) {
return new TaskEditControlSetFragmentManager(activity, preferences, syncAdapterHelper); return new TaskEditControlSetFragmentManager(activity, preferences, syncAdapterHelper);
} }

@ -0,0 +1,11 @@
package org.tasks.injection;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import javax.inject.Scope;
@Scope
@Retention(RetentionPolicy.RUNTIME)
public @interface ActivityScope {
}

@ -12,7 +12,6 @@ import org.tasks.ui.WidgetCheckBoxes;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import javax.inject.Named; import javax.inject.Named;
import javax.inject.Singleton;
import dagger.Module; import dagger.Module;
import dagger.Provides; import dagger.Provides;
@ -40,26 +39,26 @@ public class ApplicationModule {
} }
@Provides @Provides
@Singleton @ApplicationScope
@Named("iab-executor") @Named("iab-executor")
public Executor getIabExecutor(Tracker tracker) { public Executor getIabExecutor(Tracker tracker) {
return new ErrorReportingSingleThreadExecutor("iab-executor", tracker); return new ErrorReportingSingleThreadExecutor("iab-executor", tracker);
} }
@Provides @Provides
@Singleton @ApplicationScope
public CheckBoxes getCheckBoxes() { public CheckBoxes getCheckBoxes() {
return newCheckBoxes(context); return newCheckBoxes(context);
} }
@Provides @Provides
@Singleton @ApplicationScope
public WidgetCheckBoxes getWidgetCheckBoxes(CheckBoxes checkBoxes) { public WidgetCheckBoxes getWidgetCheckBoxes(CheckBoxes checkBoxes) {
return newWidgetCheckBoxes(checkBoxes); return newWidgetCheckBoxes(checkBoxes);
} }
@Provides @Provides
@Singleton @ApplicationScope
public ThemeCache getThemeCache() { public ThemeCache getThemeCache() {
return new ThemeCache(context); return new ThemeCache(context);
} }

@ -0,0 +1,11 @@
package org.tasks.injection;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import javax.inject.Scope;
@Scope
@Retention(RetentionPolicy.RUNTIME)
public @interface ApplicationScope {
}

@ -2,10 +2,6 @@ package org.tasks.injection;
import org.tasks.Tasks; import org.tasks.Tasks;
import javax.inject.Singleton;
import dagger.Component;
public interface BaseApplicationComponent { public interface BaseApplicationComponent {
Tasks inject(Tasks tasks); Tasks inject(Tasks tasks);

@ -4,11 +4,9 @@ import com.todoroo.astrid.provider.Astrid2TaskProvider;
import com.todoroo.astrid.provider.Astrid3ContentProvider; import com.todoroo.astrid.provider.Astrid3ContentProvider;
import com.todoroo.astrid.provider.SqlContentProvider; import com.todoroo.astrid.provider.SqlContentProvider;
import javax.inject.Singleton;
import dagger.Component; import dagger.Component;
@Singleton @ApplicationScope
@Component(modules = { @Component(modules = {
ApplicationModule.class, ApplicationModule.class,
ContentProviderModule.class ContentProviderModule.class

@ -1,7 +1,5 @@
package org.tasks.injection; package org.tasks.injection;
import android.app.Activity;
import android.content.Context;
import android.support.v4.app.DialogFragment; import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
@ -16,19 +14,8 @@ public class DialogFragmentModule {
this.dialogFragment = dialogFragment; this.dialogFragment = dialogFragment;
} }
@Provides
public Activity getActivity() {
return dialogFragment.getActivity();
}
@Provides @Provides
public Fragment getFragment() { public Fragment getFragment() {
return dialogFragment; return dialogFragment;
} }
@Provides
@ForActivity
public Context getContext() {
return dialogFragment.getActivity();
}
} }

@ -1,6 +1,5 @@
package org.tasks.injection; package org.tasks.injection;
import android.content.Context;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import dagger.Module; import dagger.Module;
@ -14,12 +13,6 @@ public class FragmentModule {
this.fragment = fragment; this.fragment = fragment;
} }
@Provides
@ForActivity
public Context getContext() {
return fragment.getActivity();
}
@Provides @Provides
public Fragment getFragment() { public Fragment getFragment() {
return fragment; return fragment;

@ -22,12 +22,10 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton;
import static com.google.common.collect.Iterables.transform; import static com.google.common.collect.Iterables.transform;
import static com.google.common.collect.Lists.newArrayList; import static com.google.common.collect.Lists.newArrayList;
@Singleton
public class GeofenceService { public class GeofenceService {
private final MetadataDao metadataDao; private final MetadataDao metadataDao;

@ -8,9 +8,7 @@ import org.tasks.injection.ForApplication;
import org.tasks.preferences.Preferences; import org.tasks.preferences.Preferences;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton;
@Singleton
public class NotificationManager { public class NotificationManager {
private final android.app.NotificationManager notificationManager; private final android.app.NotificationManager notificationManager;

@ -1,28 +1,11 @@
package org.tasks.preferences; package org.tasks.preferences;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.util.TypedValue; import android.util.TypedValue;
import javax.inject.Inject;
import javax.inject.Singleton;
@Singleton
@Deprecated
public class ResourceResolver { public class ResourceResolver {
private final Activity activity; @Deprecated public static int getData(Context context, int attr) {
@Inject
public ResourceResolver(Activity activity) {
this.activity = activity;
}
public int getData(int attr) {
return getData(activity, attr);
}
public static int getData(Context context, int attr) {
TypedValue typedValue = new TypedValue(); TypedValue typedValue = new TypedValue();
context.getTheme().resolveAttribute(attr, typedValue, true); context.getTheme().resolveAttribute(attr, typedValue, true);
return typedValue.data; return typedValue.data;

@ -13,17 +13,17 @@ import com.todoroo.astrid.dao.TaskDao;
import org.tasks.Broadcaster; import org.tasks.Broadcaster;
import org.tasks.BuildConfig; import org.tasks.BuildConfig;
import org.tasks.analytics.Tracker; import org.tasks.analytics.Tracker;
import org.tasks.injection.ApplicationScope;
import org.tasks.injection.BroadcastComponent; import org.tasks.injection.BroadcastComponent;
import org.tasks.injection.ForApplication; import org.tasks.injection.ForApplication;
import org.tasks.injection.InjectingBroadcastReceiver; import org.tasks.injection.InjectingBroadcastReceiver;
import org.tasks.preferences.DefaultFilterProvider; import org.tasks.preferences.DefaultFilterProvider;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton;
import timber.log.Timber; import timber.log.Timber;
@Singleton @ApplicationScope
public class TeslaUnreadReceiver extends InjectingBroadcastReceiver { public class TeslaUnreadReceiver extends InjectingBroadcastReceiver {
private static final String TESLA_URI = "content://com.teslacoilsw.notifier/unread_count"; private static final String TESLA_URI = "content://com.teslacoilsw.notifier/unread_count";

@ -4,18 +4,18 @@ import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.todoroo.astrid.sync.SyncResultCallback; import com.todoroo.astrid.sync.SyncResultCallback;
import org.tasks.analytics.Tracker; import org.tasks.analytics.Tracker;
import org.tasks.injection.ApplicationScope;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.RejectedExecutionException;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton;
import timber.log.Timber; import timber.log.Timber;
import static java.util.concurrent.Executors.newSingleThreadExecutor; import static java.util.concurrent.Executors.newSingleThreadExecutor;
@Singleton @ApplicationScope
public class SyncExecutor { public class SyncExecutor {
private final ExecutorService executor = newSingleThreadExecutor( private final ExecutorService executor = newSingleThreadExecutor(

Loading…
Cancel
Save