diff --git a/app/src/androidTest/java/org/tasks/injection/TestComponent.kt b/app/src/androidTest/java/org/tasks/injection/TestComponent.kt index a62d70e59..113e2dd7e 100644 --- a/app/src/androidTest/java/org/tasks/injection/TestComponent.kt +++ b/app/src/androidTest/java/org/tasks/injection/TestComponent.kt @@ -17,8 +17,9 @@ import com.todoroo.astrid.sync.NewSyncTestCase import dagger.Component import org.tasks.data.* import org.tasks.jobs.BackupServiceTests +import javax.inject.Singleton -@ApplicationScope +@Singleton @Component(modules = [TestModule::class]) interface TestComponent : ApplicationComponent { fun inject(tests: GtasksListServiceTest) diff --git a/app/src/androidTest/java/org/tasks/injection/TestModule.kt b/app/src/androidTest/java/org/tasks/injection/TestModule.kt index 5ac0c8430..22ba99ef1 100644 --- a/app/src/androidTest/java/org/tasks/injection/TestModule.kt +++ b/app/src/androidTest/java/org/tasks/injection/TestModule.kt @@ -9,11 +9,12 @@ import org.tasks.TestUtilities import org.tasks.preferences.PermissionChecker import org.tasks.preferences.PermissivePermissionChecker import org.tasks.preferences.Preferences +import javax.inject.Singleton @Module(includes = [ApplicationModule::class]) class TestModule { @Provides - @ApplicationScope + @Singleton fun getDatabase(@ApplicationContext context: Context): Database { return Room.inMemoryDatabaseBuilder(context, Database::class.java) .fallbackToDestructiveMigration() diff --git a/app/src/googleplay/java/org/tasks/analytics/Firebase.kt b/app/src/googleplay/java/org/tasks/analytics/Firebase.kt index 77c2c125b..a540cd611 100644 --- a/app/src/googleplay/java/org/tasks/analytics/Firebase.kt +++ b/app/src/googleplay/java/org/tasks/analytics/Firebase.kt @@ -11,15 +11,15 @@ import com.google.firebase.remoteconfig.ktx.remoteConfigSettings import io.fabric.sdk.android.Fabric import org.tasks.R import org.tasks.billing.BillingClientImpl -import org.tasks.injection.ApplicationScope import org.tasks.injection.ApplicationContext import org.tasks.jobs.WorkManager import org.tasks.preferences.Preferences import timber.log.Timber import java.util.concurrent.TimeUnit import javax.inject.Inject +import javax.inject.Singleton -@ApplicationScope +@Singleton class Firebase @Inject constructor(@param:ApplicationContext val context: Context, preferences: Preferences) { private var enabled: Boolean = preferences.isTrackingEnabled diff --git a/app/src/main/java/com/todoroo/astrid/alarms/AlarmService.java b/app/src/main/java/com/todoroo/astrid/alarms/AlarmService.java index ae54be0cb..f42b561ce 100644 --- a/app/src/main/java/com/todoroo/astrid/alarms/AlarmService.java +++ b/app/src/main/java/com/todoroo/astrid/alarms/AlarmService.java @@ -10,9 +10,9 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Set; import javax.inject.Inject; +import javax.inject.Singleton; import org.tasks.data.Alarm; import org.tasks.data.AlarmDao; -import org.tasks.injection.ApplicationScope; import org.tasks.jobs.AlarmEntry; import org.tasks.jobs.NotificationQueue; @@ -21,7 +21,7 @@ import org.tasks.jobs.NotificationQueue; * * @author Tim Su */ -@ApplicationScope +@Singleton public class AlarmService { private static final long NO_ALARM = Long.MAX_VALUE; diff --git a/app/src/main/java/com/todoroo/astrid/reminders/ReminderService.java b/app/src/main/java/com/todoroo/astrid/reminders/ReminderService.java index 5e006527d..bf656c022 100644 --- a/app/src/main/java/com/todoroo/astrid/reminders/ReminderService.java +++ b/app/src/main/java/com/todoroo/astrid/reminders/ReminderService.java @@ -14,14 +14,14 @@ import com.todoroo.astrid.dao.TaskDao; import com.todoroo.astrid.data.Task; import java.util.List; import javax.inject.Inject; -import org.tasks.injection.ApplicationScope; +import javax.inject.Singleton; import org.tasks.jobs.NotificationQueue; import org.tasks.jobs.ReminderEntry; import org.tasks.preferences.Preferences; import org.tasks.reminders.Random; import org.tasks.time.DateTime; -@ApplicationScope +@Singleton public final class ReminderService { public static final int TYPE_DUE = 0; diff --git a/app/src/main/java/org/tasks/ShortcutManager.kt b/app/src/main/java/org/tasks/ShortcutManager.kt index 5c9589e2f..8ce2f3a9b 100644 --- a/app/src/main/java/org/tasks/ShortcutManager.kt +++ b/app/src/main/java/org/tasks/ShortcutManager.kt @@ -3,11 +3,11 @@ package org.tasks import android.content.Context import android.content.pm.ShortcutManager import com.todoroo.andlib.utility.AndroidUtilities -import org.tasks.injection.ApplicationScope import org.tasks.injection.ApplicationContext import javax.inject.Inject +import javax.inject.Singleton -@ApplicationScope +@Singleton class ShortcutManager @Inject constructor(@ApplicationContext context: Context) { private val shortcutManager: ShortcutManager? = if (AndroidUtilities.atLeastNougatMR1()) { context.getSystemService(ShortcutManager::class.java) diff --git a/app/src/main/java/org/tasks/billing/Inventory.java b/app/src/main/java/org/tasks/billing/Inventory.java index 593fc8358..03322a821 100644 --- a/app/src/main/java/org/tasks/billing/Inventory.java +++ b/app/src/main/java/org/tasks/billing/Inventory.java @@ -3,14 +3,14 @@ package org.tasks.billing; import java.util.HashMap; import java.util.Map; import javax.inject.Inject; +import javax.inject.Singleton; import org.tasks.BuildConfig; import org.tasks.LocalBroadcastManager; import org.tasks.R; -import org.tasks.injection.ApplicationScope; import org.tasks.preferences.Preferences; import timber.log.Timber; -@ApplicationScope +@Singleton public class Inventory { private static final String SKU_VIP = "vip"; diff --git a/app/src/main/java/org/tasks/injection/ApplicationComponent.kt b/app/src/main/java/org/tasks/injection/ApplicationComponent.kt index 1e3240f5c..3f60940f1 100644 --- a/app/src/main/java/org/tasks/injection/ApplicationComponent.kt +++ b/app/src/main/java/org/tasks/injection/ApplicationComponent.kt @@ -5,8 +5,9 @@ import org.tasks.Tasks import org.tasks.backup.TasksBackupAgent import org.tasks.dashclock.DashClockExtension import org.tasks.widget.ScrollableWidgetUpdateService +import javax.inject.Singleton -@ApplicationScope +@Singleton @Component(modules = [ApplicationModule::class, ProductionModule::class]) interface ApplicationComponent { operator fun plus(module: ActivityModule): ActivityComponent diff --git a/app/src/main/java/org/tasks/injection/ApplicationModule.kt b/app/src/main/java/org/tasks/injection/ApplicationModule.kt index 5e319f5a7..8d9aa8ab9 100644 --- a/app/src/main/java/org/tasks/injection/ApplicationModule.kt +++ b/app/src/main/java/org/tasks/injection/ApplicationModule.kt @@ -15,6 +15,7 @@ import org.tasks.locale.Locale import org.tasks.location.Geocoder import org.tasks.location.MapboxGeocoder import org.tasks.notifications.NotificationDao +import javax.inject.Singleton @Module class ApplicationModule(@get:Provides @get:ApplicationContext val context: Context) { @@ -24,59 +25,59 @@ class ApplicationModule(@get:Provides @get:ApplicationContext val context: Conte get() = Locale.getInstance(context) @Provides - @ApplicationScope + @Singleton fun getJavaLocale(locale: Locale): java.util.Locale = locale.locale @Provides - @ApplicationScope + @Singleton fun getNotificationDao(db: Database): NotificationDao = db.notificationDao() @Provides - @ApplicationScope + @Singleton fun getTagDataDao(db: Database): TagDataDao = db.tagDataDao @Provides - @ApplicationScope + @Singleton fun getUserActivityDao(db: Database): UserActivityDao = db.userActivityDao @Provides - @ApplicationScope + @Singleton fun getTaskAttachmentDao(db: Database): TaskAttachmentDao = db.taskAttachmentDao @Provides - @ApplicationScope + @Singleton fun getTaskListMetadataDao(db: Database): TaskListMetadataDao = db.taskListMetadataDao @Provides - @ApplicationScope + @Singleton fun getGoogleTaskDao(db: Database): GoogleTaskDao = db.googleTaskDao @Provides - @ApplicationScope + @Singleton fun getAlarmDao(db: Database): AlarmDao = db.alarmDao @Provides - @ApplicationScope + @Singleton fun getGeofenceDao(db: Database): LocationDao = db.locationDao @Provides - @ApplicationScope + @Singleton fun getTagDao(db: Database): TagDao = db.tagDao @Provides - @ApplicationScope + @Singleton fun getFilterDao(db: Database): FilterDao = db.filterDao @Provides - @ApplicationScope + @Singleton fun getGoogleTaskListDao(db: Database): GoogleTaskListDao = db.googleTaskListDao @Provides - @ApplicationScope + @Singleton fun getCaldavDao(db: Database): CaldavDao = db.caldavDao @Provides - @ApplicationScope + @Singleton fun getTaskDao(db: Database, workManager: WorkManager): TaskDao { val taskDao = db.taskDao taskDao.initialize(workManager) @@ -84,7 +85,7 @@ class ApplicationModule(@get:Provides @get:ApplicationContext val context: Conte } @Provides - @ApplicationScope + @Singleton fun getDeletionDao(db: Database): DeletionDao = db.deletionDao @Provides diff --git a/app/src/main/java/org/tasks/injection/ApplicationScope.kt b/app/src/main/java/org/tasks/injection/ApplicationScope.kt deleted file mode 100644 index a1e1fece5..000000000 --- a/app/src/main/java/org/tasks/injection/ApplicationScope.kt +++ /dev/null @@ -1,7 +0,0 @@ -package org.tasks.injection - -import javax.inject.Scope - -@Scope -@Retention(AnnotationRetention.RUNTIME) -annotation class ApplicationScope \ No newline at end of file diff --git a/app/src/main/java/org/tasks/injection/ContentProviderComponent.kt b/app/src/main/java/org/tasks/injection/ContentProviderComponent.kt index 6a8d3eaab..c27843974 100644 --- a/app/src/main/java/org/tasks/injection/ContentProviderComponent.kt +++ b/app/src/main/java/org/tasks/injection/ContentProviderComponent.kt @@ -2,8 +2,9 @@ package org.tasks.injection import com.todoroo.astrid.provider.Astrid2TaskProvider import dagger.Component +import javax.inject.Singleton -@ApplicationScope +@Singleton @Component(modules = [ContentProviderModule::class]) interface ContentProviderComponent { fun inject(contentProvider: Astrid2TaskProvider) diff --git a/app/src/main/java/org/tasks/injection/ProductionModule.kt b/app/src/main/java/org/tasks/injection/ProductionModule.kt index 099c19488..4f02bffa6 100644 --- a/app/src/main/java/org/tasks/injection/ProductionModule.kt +++ b/app/src/main/java/org/tasks/injection/ProductionModule.kt @@ -7,11 +7,12 @@ import dagger.Module import dagger.Provides import org.tasks.db.Migrations import org.tasks.preferences.Preferences +import javax.inject.Singleton @Module(includes = [ApplicationModule::class]) internal class ProductionModule { @Provides - @ApplicationScope + @Singleton fun getAppDatabase(@ApplicationContext context: Context): Database { return Room.databaseBuilder(context, Database::class.java, Database.NAME) .allowMainThreadQueries() // TODO: remove me diff --git a/app/src/main/java/org/tasks/jobs/NotificationQueue.kt b/app/src/main/java/org/tasks/jobs/NotificationQueue.kt index e49fc9dd6..d3e69cddc 100644 --- a/app/src/main/java/org/tasks/jobs/NotificationQueue.kt +++ b/app/src/main/java/org/tasks/jobs/NotificationQueue.kt @@ -4,13 +4,13 @@ import com.google.common.collect.Ordering import com.google.common.collect.TreeMultimap import com.google.common.primitives.Ints import kotlinx.collections.immutable.toImmutableList -import org.tasks.injection.ApplicationScope import org.tasks.preferences.Preferences import org.tasks.time.DateTime import java.util.* import javax.inject.Inject +import javax.inject.Singleton -@ApplicationScope +@Singleton class NotificationQueue @Inject constructor(private val preferences: Preferences, private val workManager: WorkManager) { private val jobs = TreeMultimap.create(Ordering.natural(), Comparator { l: NotificationQueueEntry, r: NotificationQueueEntry -> Ints.compare(l.hashCode(), r.hashCode()) }) diff --git a/app/src/main/java/org/tasks/jobs/WorkManager.kt b/app/src/main/java/org/tasks/jobs/WorkManager.kt index 7d0589877..254582fd4 100644 --- a/app/src/main/java/org/tasks/jobs/WorkManager.kt +++ b/app/src/main/java/org/tasks/jobs/WorkManager.kt @@ -22,7 +22,6 @@ import org.tasks.data.GoogleTaskListDao import org.tasks.data.Place import org.tasks.date.DateTimeUtils.midnight import org.tasks.date.DateTimeUtils.newDateTime -import org.tasks.injection.ApplicationScope import org.tasks.injection.ApplicationContext import org.tasks.preferences.Preferences import org.tasks.time.DateTimeUtils @@ -30,9 +29,10 @@ import timber.log.Timber import java.util.* import java.util.concurrent.TimeUnit import javax.inject.Inject +import javax.inject.Singleton import kotlin.math.max -@ApplicationScope +@Singleton class WorkManager @Inject constructor( @param:ApplicationContext private val context: Context, private val preferences: Preferences, diff --git a/app/src/main/java/org/tasks/notifications/NotificationManager.java b/app/src/main/java/org/tasks/notifications/NotificationManager.java index 999300412..91649a1d7 100644 --- a/app/src/main/java/org/tasks/notifications/NotificationManager.java +++ b/app/src/main/java/org/tasks/notifications/NotificationManager.java @@ -38,11 +38,11 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import javax.inject.Inject; +import javax.inject.Singleton; import org.tasks.LocalBroadcastManager; import org.tasks.R; import org.tasks.data.LocationDao; import org.tasks.data.Place; -import org.tasks.injection.ApplicationScope; import org.tasks.injection.ApplicationContext; import org.tasks.intents.TaskIntents; import org.tasks.preferences.Preferences; @@ -55,7 +55,7 @@ import org.tasks.themes.ColorProvider; import org.tasks.time.DateTime; import timber.log.Timber; -@ApplicationScope +@Singleton public class NotificationManager { public static final String NOTIFICATION_CHANNEL_DEFAULT = "notifications"; diff --git a/app/src/main/java/org/tasks/scheduling/RefreshScheduler.java b/app/src/main/java/org/tasks/scheduling/RefreshScheduler.java index 38a635a96..63e552b5a 100644 --- a/app/src/main/java/org/tasks/scheduling/RefreshScheduler.java +++ b/app/src/main/java/org/tasks/scheduling/RefreshScheduler.java @@ -10,12 +10,12 @@ import java.util.List; import java.util.SortedSet; import java.util.TreeSet; import javax.inject.Inject; +import javax.inject.Singleton; import org.tasks.R; -import org.tasks.injection.ApplicationScope; import org.tasks.jobs.WorkManager; import org.tasks.preferences.Preferences; -@ApplicationScope +@Singleton public class RefreshScheduler { private final Preferences preferences; diff --git a/app/src/main/java/org/tasks/security/KeyStoreEncryption.kt b/app/src/main/java/org/tasks/security/KeyStoreEncryption.kt index f9668bba6..5073b6ef2 100644 --- a/app/src/main/java/org/tasks/security/KeyStoreEncryption.kt +++ b/app/src/main/java/org/tasks/security/KeyStoreEncryption.kt @@ -5,7 +5,6 @@ import android.security.keystore.KeyGenParameterSpec import android.security.keystore.KeyProperties import android.util.Base64 import org.tasks.Strings.isNullOrEmpty -import org.tasks.injection.ApplicationScope import timber.log.Timber import java.nio.charset.StandardCharsets import java.security.KeyStore @@ -14,8 +13,9 @@ import java.util.* import javax.crypto.* import javax.crypto.spec.GCMParameterSpec import javax.inject.Inject +import javax.inject.Singleton -@ApplicationScope +@Singleton class KeyStoreEncryption @Inject constructor() { private val keyStore: KeyStore = KeyStore.getInstance(ANDROID_KEYSTORE) diff --git a/app/src/main/java/org/tasks/ui/ChipListCache.java b/app/src/main/java/org/tasks/ui/ChipListCache.java index 3d653d75a..d5b1c233a 100644 --- a/app/src/main/java/org/tasks/ui/ChipListCache.java +++ b/app/src/main/java/org/tasks/ui/ChipListCache.java @@ -8,6 +8,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import javax.inject.Inject; +import javax.inject.Singleton; import org.tasks.LocalBroadcastManager; import org.tasks.data.CaldavCalendar; import org.tasks.data.CaldavDao; @@ -15,9 +16,8 @@ import org.tasks.data.GoogleTaskList; import org.tasks.data.GoogleTaskListDao; import org.tasks.data.TagData; import org.tasks.data.TagDataDao; -import org.tasks.injection.ApplicationScope; -@ApplicationScope +@Singleton public class ChipListCache { private final Map googleTaskLists = new HashMap<>();