Restore and rename ForActivity and ForApplication

pull/1020/head
Alex Baker 4 years ago
parent 6d9b949e37
commit 9bf15c1490

@ -14,19 +14,19 @@ import org.tasks.preferences.Preferences
class TestModule { class TestModule {
@Provides @Provides
@ApplicationScope @ApplicationScope
fun getDatabase(context: Application): Database { fun getDatabase(@ApplicationContext context: Context): Database {
return Room.inMemoryDatabaseBuilder(context, Database::class.java) return Room.inMemoryDatabaseBuilder(context, Database::class.java)
.fallbackToDestructiveMigration() .fallbackToDestructiveMigration()
.build() .build()
} }
@Provides @Provides
fun getPermissionChecker(context: Application): PermissionChecker { fun getPermissionChecker(@ApplicationContext context: Context): PermissionChecker {
return PermissivePermissionChecker(context) return PermissivePermissionChecker(context)
} }
@Provides @Provides
fun getPreferences(context: Application): Preferences { fun getPreferences(@ApplicationContext context: Context): Preferences {
return TestUtilities.newPreferences(context) return TestUtilities.newPreferences(context)
} }
} }

@ -1,8 +1,9 @@
package org.tasks.preferences package org.tasks.preferences
import android.content.Context import android.content.Context
import org.tasks.injection.ApplicationContext
class PermissivePermissionChecker(context: Application) : PermissionChecker(context) { class PermissivePermissionChecker(@ApplicationContext context: Context) : PermissionChecker(context) {
override fun canAccessCalendars() = true override fun canAccessCalendars() = true
override fun canAccessAccounts() = true override fun canAccessAccounts() = true

@ -1,6 +1,5 @@
package org.tasks package org.tasks
import android.app.Application
import android.content.Context import android.content.Context
import android.os.StrictMode import android.os.StrictMode
import android.os.StrictMode.VmPolicy import android.os.StrictMode.VmPolicy
@ -13,12 +12,13 @@ import com.facebook.flipper.plugins.network.NetworkFlipperPlugin
import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin
import com.facebook.soloader.SoLoader import com.facebook.soloader.SoLoader
import leakcanary.AppWatcher import leakcanary.AppWatcher
import org.tasks.injection.ApplicationContext
import org.tasks.preferences.Preferences import org.tasks.preferences.Preferences
import timber.log.Timber import timber.log.Timber
import timber.log.Timber.DebugTree import timber.log.Timber.DebugTree
import javax.inject.Inject import javax.inject.Inject
class BuildSetup @Inject constructor(private val context: Application, private val preferences: Preferences) { class BuildSetup @Inject constructor(@param:ApplicationContext private val context: Context, private val preferences: Preferences) {
fun setup() { fun setup() {
Timber.plant(DebugTree()) Timber.plant(DebugTree())
SoLoader.init(context, false) SoLoader.init(context, false)

@ -1,6 +1,5 @@
package org.tasks package org.tasks
import android.app.Application
import android.content.Context import android.content.Context
import com.facebook.flipper.android.AndroidFlipperClient import com.facebook.flipper.android.AndroidFlipperClient
import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor
@ -8,10 +7,11 @@ import com.facebook.flipper.plugins.network.NetworkFlipperPlugin
import com.google.api.client.http.HttpRequest import com.google.api.client.http.HttpRequest
import com.google.api.client.http.HttpResponse import com.google.api.client.http.HttpResponse
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import org.tasks.injection.ApplicationContext
import java.io.IOException import java.io.IOException
import javax.inject.Inject import javax.inject.Inject
class DebugNetworkInterceptor @Inject constructor(private val context: Application) { class DebugNetworkInterceptor @Inject constructor(@param:ApplicationContext private val context: Context) {
fun add(builder: OkHttpClient.Builder) { fun add(builder: OkHttpClient.Builder) {
builder.addNetworkInterceptor(FlipperOkhttpInterceptor(getNetworkPlugin(context))) builder.addNetworkInterceptor(FlipperOkhttpInterceptor(getNetworkPlugin(context)))
} }

@ -1,6 +1,6 @@
package org.tasks.injection package org.tasks.injection
import android.app.Application import android.content.Context
import dagger.Module import dagger.Module
import dagger.Provides import dagger.Provides
import org.tasks.location.MapFragment import org.tasks.location.MapFragment
@ -12,13 +12,13 @@ import org.tasks.location.PlaceSearchProvider
class LocationModule { class LocationModule {
@Provides @Provides
@ActivityScope @ActivityScope
fun getPlaceSearchProvider(context: Application): PlaceSearchProvider { fun getPlaceSearchProvider(@ForApplication context: Context): PlaceSearchProvider {
return MapboxSearchProvider(context) return MapboxSearchProvider(context)
} }
@Provides @Provides
@ActivityScope @ActivityScope
fun getMapFragment(context: Application): MapFragment { fun getMapFragment(@ForApplication context: Context): MapFragment {
return MapboxMapFragment(context) return MapboxMapFragment(context)
} }
} }

@ -1,6 +1,5 @@
package org.tasks.analytics package org.tasks.analytics
import android.app.Application
import android.content.Context import android.content.Context
import android.os.Bundle import android.os.Bundle
import androidx.annotation.StringRes import androidx.annotation.StringRes
@ -13,6 +12,7 @@ import io.fabric.sdk.android.Fabric
import org.tasks.R import org.tasks.R
import org.tasks.billing.BillingClientImpl import org.tasks.billing.BillingClientImpl
import org.tasks.injection.ApplicationScope import org.tasks.injection.ApplicationScope
import org.tasks.injection.ApplicationContext
import org.tasks.jobs.WorkManager import org.tasks.jobs.WorkManager
import org.tasks.preferences.Preferences import org.tasks.preferences.Preferences
import timber.log.Timber import timber.log.Timber
@ -20,7 +20,7 @@ import java.util.concurrent.TimeUnit
import javax.inject.Inject import javax.inject.Inject
@ApplicationScope @ApplicationScope
class Firebase @Inject constructor(val context: Application, preferences: Preferences) { class Firebase @Inject constructor(@param:ApplicationContext val context: Context, preferences: Preferences) {
private var enabled: Boolean = preferences.isTrackingEnabled private var enabled: Boolean = preferences.isTrackingEnabled
private var analytics: FirebaseAnalytics? = null private var analytics: FirebaseAnalytics? = null

@ -4,7 +4,7 @@ import static com.google.common.collect.Lists.newArrayList;
import static com.todoroo.andlib.utility.AndroidUtilities.assertMainThread; import static com.todoroo.andlib.utility.AndroidUtilities.assertMainThread;
import android.app.Activity; import android.app.Activity;
import android.app.Application; import android.content.Context;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.android.billingclient.api.BillingClient.BillingResponse; import com.android.billingclient.api.BillingClient.BillingResponse;
import com.android.billingclient.api.BillingClient.FeatureType; import com.android.billingclient.api.BillingClient.FeatureType;
@ -22,6 +22,7 @@ import io.reactivex.schedulers.Schedulers;
import java.util.List; import java.util.List;
import org.tasks.BuildConfig; import org.tasks.BuildConfig;
import org.tasks.analytics.Firebase; import org.tasks.analytics.Firebase;
import org.tasks.injection.ApplicationContext;
import timber.log.Timber; import timber.log.Timber;
@SuppressWarnings("all") @SuppressWarnings("all")
@ -35,7 +36,7 @@ public class BillingClientImpl implements BillingClient, PurchasesUpdatedListene
private boolean connected; private boolean connected;
private OnPurchasesUpdated onPurchasesUpdated; private OnPurchasesUpdated onPurchasesUpdated;
public BillingClientImpl(Application context, Inventory inventory, Firebase firebase) { public BillingClientImpl(@ApplicationContext Context context, Inventory inventory, Firebase firebase) {
this.inventory = inventory; this.inventory = inventory;
this.firebase = firebase; this.firebase = firebase;
billingClient = billingClient =

@ -1,13 +1,13 @@
package org.tasks.billing package org.tasks.billing
import android.app.Application
import android.content.Context import android.content.Context
import org.tasks.R import org.tasks.R
import org.tasks.injection.ApplicationContext
import timber.log.Timber import timber.log.Timber
import java.io.IOException import java.io.IOException
import javax.inject.Inject import javax.inject.Inject
internal class SignatureVerifier @Inject constructor(context: Application) { internal class SignatureVerifier @Inject constructor(@ApplicationContext context: Context) {
private val billingKey: String = context.getString(R.string.gp_key) private val billingKey: String = context.getString(R.string.gp_key)
fun verifySignature(purchase: Purchase): Boolean { fun verifySignature(purchase: Purchase): Boolean {

@ -1,7 +1,6 @@
package org.tasks.gtasks package org.tasks.gtasks
import android.app.Activity import android.app.Activity
import android.app.Application
import android.content.Context import android.content.Context
import android.widget.Toast import android.widget.Toast
import com.google.android.gms.common.ConnectionResult import com.google.android.gms.common.ConnectionResult
@ -14,12 +13,13 @@ import io.reactivex.schedulers.Schedulers
import org.tasks.R import org.tasks.R
import org.tasks.data.GoogleTaskListDao import org.tasks.data.GoogleTaskListDao
import org.tasks.data.LocationDao import org.tasks.data.LocationDao
import org.tasks.injection.ApplicationContext
import org.tasks.preferences.Preferences import org.tasks.preferences.Preferences
import timber.log.Timber import timber.log.Timber
import javax.inject.Inject import javax.inject.Inject
class PlayServices @Inject constructor( class PlayServices @Inject constructor(
private val context: Application, @param:ApplicationContext private val context: Context,
private val preferences: Preferences, private val preferences: Preferences,
private val googleTaskListDao: GoogleTaskListDao, private val googleTaskListDao: GoogleTaskListDao,
private val locationDao: LocationDao) { private val locationDao: LocationDao) {

@ -1,6 +1,6 @@
package org.tasks.injection package org.tasks.injection
import android.app.Application import android.content.Context
import dagger.Module import dagger.Module
import dagger.Provides import dagger.Provides
import org.tasks.billing.Inventory import org.tasks.billing.Inventory
@ -13,7 +13,7 @@ internal class LocationModule {
@Provides @Provides
@ActivityScope @ActivityScope
fun getPlaceSearchProvider( fun getPlaceSearchProvider(
context: Application, @ApplicationContext context: Context,
preferences: Preferences, preferences: Preferences,
playServices: PlayServices, playServices: PlayServices,
inventory: Inventory): PlaceSearchProvider { inventory: Inventory): PlaceSearchProvider {
@ -28,7 +28,7 @@ internal class LocationModule {
@Provides @Provides
@ActivityScope @ActivityScope
fun getMapFragment(context: Application, preferences: Preferences): MapFragment { fun getMapFragment(@ApplicationContext context: Context, preferences: Preferences): MapFragment {
return if (preferences.useGoogleMaps()) { return if (preferences.useGoogleMaps()) {
GoogleMapFragment(context) GoogleMapFragment(context)
} else { } else {

@ -1,7 +1,6 @@
package org.tasks.location package org.tasks.location
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.app.Application
import android.app.PendingIntent import android.app.PendingIntent
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
@ -11,12 +10,13 @@ import com.google.android.gms.location.LocationServices
import org.tasks.data.LocationDao import org.tasks.data.LocationDao
import org.tasks.data.MergedGeofence import org.tasks.data.MergedGeofence
import org.tasks.data.Place import org.tasks.data.Place
import org.tasks.injection.ApplicationContext
import org.tasks.preferences.PermissionChecker import org.tasks.preferences.PermissionChecker
import timber.log.Timber import timber.log.Timber
import javax.inject.Inject import javax.inject.Inject
class GeofenceApi @Inject constructor( class GeofenceApi @Inject constructor(
private val context: Application, @param:ApplicationContext private val context: Context,
private val permissionChecker: PermissionChecker, private val permissionChecker: PermissionChecker,
private val locationDao: LocationDao) { private val locationDao: LocationDao) {

@ -8,7 +8,6 @@ import static org.tasks.files.FileHelper.copyToUri;
import static org.tasks.files.FileHelper.getFilename; import static org.tasks.files.FileHelper.getFilename;
import static org.tasks.intents.TaskIntents.getTaskListIntent; import static org.tasks.intents.TaskIntents.getTaskListIntent;
import android.app.Application;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
@ -22,6 +21,7 @@ import javax.inject.Inject;
import org.tasks.data.TaskAttachment; import org.tasks.data.TaskAttachment;
import org.tasks.files.FileHelper; import org.tasks.files.FileHelper;
import org.tasks.injection.ActivityComponent; import org.tasks.injection.ActivityComponent;
import org.tasks.injection.ApplicationContext;
import org.tasks.injection.InjectingAppCompatActivity; import org.tasks.injection.InjectingAppCompatActivity;
import org.tasks.preferences.Preferences; import org.tasks.preferences.Preferences;
import timber.log.Timber; import timber.log.Timber;
@ -32,7 +32,7 @@ import timber.log.Timber;
*/ */
public final class ShareLinkActivity extends InjectingAppCompatActivity { public final class ShareLinkActivity extends InjectingAppCompatActivity {
@Inject Application context; @Inject @ApplicationContext Context context;
@Inject TaskCreator taskCreator; @Inject TaskCreator taskCreator;
@Inject Preferences preferences; @Inject Preferences preferences;

@ -59,6 +59,7 @@ import org.tasks.databinding.FragmentTaskEditBinding;
import org.tasks.dialogs.DialogBuilder; import org.tasks.dialogs.DialogBuilder;
import org.tasks.dialogs.Linkify; import org.tasks.dialogs.Linkify;
import org.tasks.fragments.TaskEditControlSetFragmentManager; import org.tasks.fragments.TaskEditControlSetFragmentManager;
import org.tasks.injection.ActivityContext;
import org.tasks.injection.FragmentComponent; import org.tasks.injection.FragmentComponent;
import org.tasks.injection.InjectingFragment; import org.tasks.injection.InjectingFragment;
import org.tasks.notifications.NotificationManager; import org.tasks.notifications.NotificationManager;
@ -80,7 +81,7 @@ public final class TaskEditFragment extends InjectingFragment
@Inject TaskDeleter taskDeleter; @Inject TaskDeleter taskDeleter;
@Inject NotificationManager notificationManager; @Inject NotificationManager notificationManager;
@Inject DialogBuilder dialogBuilder; @Inject DialogBuilder dialogBuilder;
@Inject Activity context; @Inject @ActivityContext Context context;
@Inject TaskEditControlSetFragmentManager taskEditControlSetFragmentManager; @Inject TaskEditControlSetFragmentManager taskEditControlSetFragmentManager;
@Inject CommentsController commentsController; @Inject CommentsController commentsController;
@Inject Preferences preferences; @Inject Preferences preferences;

@ -1,6 +1,5 @@
package com.todoroo.astrid.adapter package com.todoroo.astrid.adapter
import android.app.Application
import android.content.Context import android.content.Context
import com.todoroo.astrid.api.CaldavFilter import com.todoroo.astrid.api.CaldavFilter
import com.todoroo.astrid.api.Filter import com.todoroo.astrid.api.Filter
@ -17,11 +16,12 @@ import org.tasks.data.CaldavDao
import org.tasks.data.GoogleTaskDao import org.tasks.data.GoogleTaskDao
import org.tasks.data.TaskListMetadata import org.tasks.data.TaskListMetadata
import org.tasks.data.TaskListMetadataDao import org.tasks.data.TaskListMetadataDao
import org.tasks.injection.ApplicationContext
import org.tasks.preferences.Preferences import org.tasks.preferences.Preferences
import javax.inject.Inject import javax.inject.Inject
class TaskAdapterProvider @Inject constructor( class TaskAdapterProvider @Inject constructor(
private val context: Application, @param:ApplicationContext private val context: Context,
private val preferences: Preferences, private val preferences: Preferences,
private val taskListMetadataDao: TaskListMetadataDao, private val taskListMetadataDao: TaskListMetadataDao,
private val taskDao: TaskDao, private val taskDao: TaskDao,

@ -6,7 +6,6 @@
package com.todoroo.astrid.core; package com.todoroo.astrid.core;
import android.app.Application;
import android.content.Context; import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
import com.todoroo.andlib.sql.Criterion; import com.todoroo.andlib.sql.Criterion;
@ -26,6 +25,7 @@ import javax.inject.Inject;
import org.tasks.R; import org.tasks.R;
import org.tasks.filters.RecentlyModifiedFilter; import org.tasks.filters.RecentlyModifiedFilter;
import org.tasks.filters.SortableFilter; import org.tasks.filters.SortableFilter;
import org.tasks.injection.ApplicationContext;
import org.tasks.preferences.Preferences; import org.tasks.preferences.Preferences;
import org.tasks.themes.CustomIcons; import org.tasks.themes.CustomIcons;
@ -42,7 +42,7 @@ public final class BuiltInFilterExposer {
@Inject @Inject
public BuiltInFilterExposer( public BuiltInFilterExposer(
Application context, Preferences preferences, TaskDao taskDao) { @ApplicationContext Context context, Preferences preferences, TaskDao taskDao) {
this.context = context; this.context = context;
this.preferences = preferences; this.preferences = preferences;
this.taskDao = taskDao; this.taskDao = taskDao;

@ -25,6 +25,7 @@ import org.tasks.data.TaskAttachmentDao
import org.tasks.dialogs.AddAttachmentDialog import org.tasks.dialogs.AddAttachmentDialog
import org.tasks.dialogs.DialogBuilder import org.tasks.dialogs.DialogBuilder
import org.tasks.files.FileHelper import org.tasks.files.FileHelper
import org.tasks.injection.ActivityContext
import org.tasks.injection.FragmentComponent import org.tasks.injection.FragmentComponent
import org.tasks.preferences.Preferences import org.tasks.preferences.Preferences
import org.tasks.ui.TaskEditControlFragment import org.tasks.ui.TaskEditControlFragment
@ -32,7 +33,7 @@ import java.util.*
import javax.inject.Inject import javax.inject.Inject
class FilesControlSet : TaskEditControlFragment() { class FilesControlSet : TaskEditControlFragment() {
@Inject lateinit var activity: Activity @Inject @ActivityContext lateinit var activity: Context
@Inject lateinit var taskAttachmentDao: TaskAttachmentDao @Inject lateinit var taskAttachmentDao: TaskAttachmentDao
@Inject lateinit var dialogBuilder: DialogBuilder @Inject lateinit var dialogBuilder: DialogBuilder
@Inject lateinit var preferences: Preferences @Inject lateinit var preferences: Preferences

@ -8,9 +8,9 @@ package com.todoroo.astrid.gcal;
import static org.tasks.Strings.isNullOrEmpty; import static org.tasks.Strings.isNullOrEmpty;
import android.app.Application;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.ContentValues; import android.content.ContentValues;
import android.content.Context;
import android.net.Uri; import android.net.Uri;
import android.provider.CalendarContract; import android.provider.CalendarContract;
import android.text.format.Time; import android.text.format.Time;
@ -22,6 +22,7 @@ import javax.inject.Inject;
import org.tasks.R; import org.tasks.R;
import org.tasks.calendars.AndroidCalendarEvent; import org.tasks.calendars.AndroidCalendarEvent;
import org.tasks.calendars.CalendarEventProvider; import org.tasks.calendars.CalendarEventProvider;
import org.tasks.injection.ApplicationContext;
import org.tasks.preferences.PermissionChecker; import org.tasks.preferences.PermissionChecker;
import org.tasks.preferences.Preferences; import org.tasks.preferences.Preferences;
import timber.log.Timber; import timber.log.Timber;
@ -39,7 +40,7 @@ public class GCalHelper {
@Inject @Inject
public GCalHelper( public GCalHelper(
Application context, @ApplicationContext Context context,
TaskDao taskDao, TaskDao taskDao,
Preferences preferences, Preferences preferences,
PermissionChecker permissionChecker, PermissionChecker permissionChecker,

@ -1,6 +1,5 @@
package com.todoroo.astrid.gtasks.api; package com.todoroo.astrid.gtasks.api;
import android.app.Application;
import android.content.Context; import android.content.Context;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.google.api.client.http.HttpRequest; import com.google.api.client.http.HttpRequest;
@ -19,6 +18,7 @@ import javax.inject.Inject;
import org.tasks.BuildConfig; import org.tasks.BuildConfig;
import org.tasks.DebugNetworkInterceptor; import org.tasks.DebugNetworkInterceptor;
import org.tasks.gtasks.GoogleAccountManager; import org.tasks.gtasks.GoogleAccountManager;
import org.tasks.injection.ApplicationContext;
import org.tasks.preferences.Preferences; import org.tasks.preferences.Preferences;
import timber.log.Timber; import timber.log.Timber;
@ -40,7 +40,7 @@ public class GtasksInvoker {
@Inject @Inject
public GtasksInvoker( public GtasksInvoker(
Application context, @ApplicationContext Context context,
GoogleAccountManager googleAccountManager, GoogleAccountManager googleAccountManager,
Preferences preferences, Preferences preferences,
DebugNetworkInterceptor interceptor) { DebugNetworkInterceptor interceptor) {

@ -5,7 +5,6 @@
*/ */
package com.todoroo.astrid.repeats package com.todoroo.astrid.repeats
import android.app.Activity
import android.content.Context import android.content.Context
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
@ -25,6 +24,7 @@ import org.tasks.R
import org.tasks.Strings.isNullOrEmpty import org.tasks.Strings.isNullOrEmpty
import org.tasks.analytics.Firebase import org.tasks.analytics.Firebase
import org.tasks.dialogs.DialogBuilder import org.tasks.dialogs.DialogBuilder
import org.tasks.injection.ActivityContext
import org.tasks.injection.FragmentComponent import org.tasks.injection.FragmentComponent
import org.tasks.repeats.BasicRecurrenceDialog import org.tasks.repeats.BasicRecurrenceDialog
import org.tasks.repeats.RepeatRuleToString import org.tasks.repeats.RepeatRuleToString
@ -45,7 +45,7 @@ import javax.inject.Inject
class RepeatControlSet : TaskEditControlFragment() { class RepeatControlSet : TaskEditControlFragment() {
private val repeatTypes: MutableList<String> = ArrayList() private val repeatTypes: MutableList<String> = ArrayList()
@Inject lateinit var activity: Activity @Inject @ActivityContext lateinit var activity: Context
@Inject lateinit var dialogBuilder: DialogBuilder @Inject lateinit var dialogBuilder: DialogBuilder
@Inject lateinit var theme: Theme @Inject lateinit var theme: Theme
@Inject lateinit var firebase: Firebase @Inject lateinit var firebase: Firebase

@ -1,6 +1,5 @@
package com.todoroo.astrid.service package com.todoroo.astrid.service
import android.app.Application
import android.content.Context import android.content.Context
import com.todoroo.andlib.utility.DateUtilities import com.todoroo.andlib.utility.DateUtilities
import com.todoroo.astrid.api.CaldavFilter import com.todoroo.astrid.api.CaldavFilter
@ -12,12 +11,13 @@ import org.tasks.BuildConfig
import org.tasks.LocalBroadcastManager import org.tasks.LocalBroadcastManager
import org.tasks.data.* import org.tasks.data.*
import org.tasks.db.DbUtils.dbchunk import org.tasks.db.DbUtils.dbchunk
import org.tasks.injection.ApplicationContext
import org.tasks.preferences.Preferences import org.tasks.preferences.Preferences
import java.util.* import java.util.*
import javax.inject.Inject import javax.inject.Inject
class TaskMover @Inject constructor( class TaskMover @Inject constructor(
private val context: Application, @param:ApplicationContext private val context: Context,
private val taskDao: TaskDao, private val taskDao: TaskDao,
private val caldavDao: CaldavDao, private val caldavDao: CaldavDao,
private val googleTaskDao: GoogleTaskDao, private val googleTaskDao: GoogleTaskDao,

@ -1,6 +1,5 @@
package com.todoroo.astrid.service package com.todoroo.astrid.service
import android.app.Application
import android.content.Context import android.content.Context
import androidx.annotation.ColorRes import androidx.annotation.ColorRes
import com.google.common.collect.ImmutableListMultimap import com.google.common.collect.ImmutableListMultimap
@ -15,6 +14,7 @@ import org.tasks.caldav.iCalendar.Companion.fromVtodo
import org.tasks.caldav.iCalendar.Companion.getParent import org.tasks.caldav.iCalendar.Companion.getParent
import org.tasks.caldav.iCalendar.Companion.order import org.tasks.caldav.iCalendar.Companion.order
import org.tasks.data.* import org.tasks.data.*
import org.tasks.injection.ApplicationContext
import org.tasks.preferences.DefaultFilterProvider import org.tasks.preferences.DefaultFilterProvider
import org.tasks.preferences.Preferences import org.tasks.preferences.Preferences
import org.tasks.widget.AppWidgetManager import org.tasks.widget.AppWidgetManager
@ -24,7 +24,7 @@ import java.util.*
import javax.inject.Inject import javax.inject.Inject
class Upgrader @Inject constructor( class Upgrader @Inject constructor(
private val context: Application, @param:ApplicationContext private val context: Context,
private val preferences: Preferences, private val preferences: Preferences,
private val tagDataDao: TagDataDao, private val tagDataDao: TagDataDao,
private val tagDao: TagDao, private val tagDao: TagDao,

@ -3,7 +3,6 @@ package com.todoroo.astrid.subtasks;
import static org.tasks.Strings.isNullOrEmpty; import static org.tasks.Strings.isNullOrEmpty;
import static org.tasks.db.QueryUtils.showHiddenAndCompleted; import static org.tasks.db.QueryUtils.showHiddenAndCompleted;
import android.app.Application;
import android.content.Context; import android.content.Context;
import com.todoroo.astrid.api.Filter; import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.core.BuiltInFilterExposer; import com.todoroo.astrid.core.BuiltInFilterExposer;
@ -19,6 +18,7 @@ import org.tasks.data.TagData;
import org.tasks.data.TagDataDao; import org.tasks.data.TagDataDao;
import org.tasks.data.TaskListMetadata; import org.tasks.data.TaskListMetadata;
import org.tasks.data.TaskListMetadataDao; import org.tasks.data.TaskListMetadataDao;
import org.tasks.injection.ApplicationContext;
import org.tasks.preferences.Preferences; import org.tasks.preferences.Preferences;
import timber.log.Timber; import timber.log.Timber;
@ -32,7 +32,7 @@ public class SubtasksHelper {
@Inject @Inject
public SubtasksHelper( public SubtasksHelper(
Application context, @ApplicationContext Context context,
Preferences preferences, Preferences preferences,
TaskDao taskDao, TaskDao taskDao,
TagDataDao tagDataDao, TagDataDao tagDataDao,

@ -27,6 +27,7 @@ import com.todoroo.astrid.ui.TimeDurationControlSet
import org.tasks.R import org.tasks.R
import org.tasks.Strings.isNullOrEmpty import org.tasks.Strings.isNullOrEmpty
import org.tasks.dialogs.DialogBuilder import org.tasks.dialogs.DialogBuilder
import org.tasks.injection.ActivityContext
import org.tasks.injection.FragmentComponent import org.tasks.injection.FragmentComponent
import org.tasks.themes.Theme import org.tasks.themes.Theme
import org.tasks.ui.TaskEditControlFragment import org.tasks.ui.TaskEditControlFragment
@ -38,7 +39,7 @@ import javax.inject.Inject
* @author Tim Su <tim></tim>@todoroo.com> * @author Tim Su <tim></tim>@todoroo.com>
*/ */
class TimerControlSet : TaskEditControlFragment() { class TimerControlSet : TaskEditControlFragment() {
@Inject lateinit var activity: Activity @Inject @ActivityContext lateinit var activity: Context
@Inject lateinit var dialogBuilder: DialogBuilder @Inject lateinit var dialogBuilder: DialogBuilder
@Inject lateinit var theme: Theme @Inject lateinit var theme: Theme

@ -8,7 +8,6 @@ package com.todoroo.astrid.timers;
import static org.tasks.time.DateTimeUtils.currentTimeMillis; import static org.tasks.time.DateTimeUtils.currentTimeMillis;
import android.app.Application;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@ -25,6 +24,7 @@ import io.reactivex.Completable;
import io.reactivex.schedulers.Schedulers; import io.reactivex.schedulers.Schedulers;
import javax.inject.Inject; import javax.inject.Inject;
import org.tasks.R; import org.tasks.R;
import org.tasks.injection.ApplicationContext;
import org.tasks.intents.TaskIntents; import org.tasks.intents.TaskIntents;
import org.tasks.notifications.NotificationManager; import org.tasks.notifications.NotificationManager;
@ -36,7 +36,7 @@ public class TimerPlugin {
@Inject @Inject
public TimerPlugin( public TimerPlugin(
Application context, @ApplicationContext Context context,
NotificationManager notificationManager, NotificationManager notificationManager,
TaskDao taskDao) { TaskDao taskDao) {
this.context = context; this.context = context;

@ -22,6 +22,7 @@ import org.tasks.R
import org.tasks.activities.DateAndTimePickerActivity import org.tasks.activities.DateAndTimePickerActivity
import org.tasks.date.DateTimeUtils import org.tasks.date.DateTimeUtils
import org.tasks.dialogs.MyTimePickerDialog import org.tasks.dialogs.MyTimePickerDialog
import org.tasks.injection.ActivityContext
import org.tasks.injection.FragmentComponent import org.tasks.injection.FragmentComponent
import org.tasks.locale.Locale import org.tasks.locale.Locale
import org.tasks.preferences.Preferences import org.tasks.preferences.Preferences
@ -39,7 +40,7 @@ import javax.inject.Inject
class HideUntilControlSet : TaskEditControlFragment(), OnItemSelectedListener { class HideUntilControlSet : TaskEditControlFragment(), OnItemSelectedListener {
private val spinnerItems: MutableList<HideUntilValue> = ArrayList() private val spinnerItems: MutableList<HideUntilValue> = ArrayList()
@Inject lateinit var activity: Activity @Inject @ActivityContext lateinit var activity: Context
@Inject lateinit var themeBase: ThemeBase @Inject lateinit var themeBase: ThemeBase
@Inject lateinit var preferences: Preferences @Inject lateinit var preferences: Preferences
@Inject lateinit var locale: Locale @Inject lateinit var locale: Locale

@ -28,6 +28,7 @@ import org.tasks.data.Alarm
import org.tasks.date.DateTimeUtils import org.tasks.date.DateTimeUtils
import org.tasks.dialogs.DialogBuilder import org.tasks.dialogs.DialogBuilder
import org.tasks.dialogs.MyTimePickerDialog import org.tasks.dialogs.MyTimePickerDialog
import org.tasks.injection.ActivityContext
import org.tasks.injection.FragmentComponent import org.tasks.injection.FragmentComponent
import org.tasks.locale.Locale import org.tasks.locale.Locale
import org.tasks.ui.TaskEditControlFragment import org.tasks.ui.TaskEditControlFragment
@ -43,7 +44,7 @@ import javax.inject.Inject
class ReminderControlSet : TaskEditControlFragment() { class ReminderControlSet : TaskEditControlFragment() {
private val alarms: MutableSet<Long> = LinkedHashSet() private val alarms: MutableSet<Long> = LinkedHashSet()
@Inject lateinit var activity: Activity @Inject @ActivityContext lateinit var activity: Context
@Inject lateinit var alarmService: AlarmService @Inject lateinit var alarmService: AlarmService
@Inject lateinit var locale: Locale @Inject lateinit var locale: Locale
@Inject lateinit var dialogBuilder: DialogBuilder @Inject lateinit var dialogBuilder: DialogBuilder

@ -1,6 +1,5 @@
package com.todoroo.astrid.voice; package com.todoroo.astrid.voice;
import android.app.Application;
import android.content.Context; import android.content.Context;
import android.media.AudioManager; import android.media.AudioManager;
import android.speech.tts.TextToSpeech; import android.speech.tts.TextToSpeech;
@ -9,6 +8,7 @@ import java.util.HashMap;
import java.util.Locale; import java.util.Locale;
import java.util.UUID; import java.util.UUID;
import javax.inject.Inject; import javax.inject.Inject;
import org.tasks.injection.ApplicationContext;
import timber.log.Timber; import timber.log.Timber;
/** @author Arne Jans */ /** @author Arne Jans */
@ -21,7 +21,7 @@ public class VoiceOutputAssistant implements OnInitListener {
private String lastTextToSpeak; private String lastTextToSpeak;
@Inject @Inject
public VoiceOutputAssistant(Application context) { public VoiceOutputAssistant(@ApplicationContext Context context) {
this.context = context; this.context = context;
} }

@ -1,11 +1,12 @@
package org.tasks; package org.tasks;
import android.app.Application;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import com.todoroo.astrid.api.AstridApiConstants; import com.todoroo.astrid.api.AstridApiConstants;
import javax.inject.Inject; import javax.inject.Inject;
import org.tasks.injection.ApplicationContext;
import org.tasks.widget.AppWidgetManager; import org.tasks.widget.AppWidgetManager;
public class LocalBroadcastManager { public class LocalBroadcastManager {
@ -19,7 +20,7 @@ public class LocalBroadcastManager {
private final AppWidgetManager appWidgetManager; private final AppWidgetManager appWidgetManager;
@Inject @Inject
public LocalBroadcastManager(Application context, AppWidgetManager appWidgetManager) { public LocalBroadcastManager(@ApplicationContext Context context, AppWidgetManager appWidgetManager) {
this.appWidgetManager = appWidgetManager; this.appWidgetManager = appWidgetManager;
localBroadcastManager = localBroadcastManager =
androidx.localbroadcastmanager.content.LocalBroadcastManager.getInstance(context); androidx.localbroadcastmanager.content.LocalBroadcastManager.getInstance(context);

@ -1,7 +1,7 @@
package org.tasks package org.tasks
import android.app.Application
import android.app.PendingIntent import android.app.PendingIntent
import android.content.Context
import android.content.Intent import android.content.Intent
import androidx.core.app.NotificationCompat import androidx.core.app.NotificationCompat
import com.todoroo.andlib.utility.AndroidUtilities import com.todoroo.andlib.utility.AndroidUtilities
@ -10,6 +10,7 @@ import com.todoroo.astrid.api.Filter
import com.todoroo.astrid.dao.TaskDao import com.todoroo.astrid.dao.TaskDao
import com.todoroo.astrid.reminders.ReminderService import com.todoroo.astrid.reminders.ReminderService
import com.todoroo.astrid.voice.VoiceOutputAssistant import com.todoroo.astrid.voice.VoiceOutputAssistant
import org.tasks.injection.ApplicationContext
import org.tasks.notifications.AudioManager import org.tasks.notifications.AudioManager
import org.tasks.notifications.Notification import org.tasks.notifications.Notification
import org.tasks.notifications.NotificationManager import org.tasks.notifications.NotificationManager
@ -23,7 +24,7 @@ import javax.inject.Inject
import kotlin.math.min import kotlin.math.min
class Notifier @Inject constructor( class Notifier @Inject constructor(
private val context: Application, @param:ApplicationContext private val context: Context,
private val taskDao: TaskDao, private val taskDao: TaskDao,
private val notificationManager: NotificationManager, private val notificationManager: NotificationManager,
private val telephonyManager: TelephonyManager, private val telephonyManager: TelephonyManager,

@ -1,13 +1,14 @@
package org.tasks package org.tasks
import android.app.Application import android.content.Context
import android.content.pm.ShortcutManager import android.content.pm.ShortcutManager
import com.todoroo.andlib.utility.AndroidUtilities import com.todoroo.andlib.utility.AndroidUtilities
import org.tasks.injection.ApplicationScope import org.tasks.injection.ApplicationScope
import org.tasks.injection.ApplicationContext
import javax.inject.Inject import javax.inject.Inject
@ApplicationScope @ApplicationScope
class ShortcutManager @Inject constructor(context: Application) { class ShortcutManager @Inject constructor(@ApplicationContext context: Context) {
private val shortcutManager: ShortcutManager? = if (AndroidUtilities.atLeastNougatMR1()) { private val shortcutManager: ShortcutManager? = if (AndroidUtilities.atLeastNougatMR1()) {
context.getSystemService(ShortcutManager::class.java) context.getSystemService(ShortcutManager::class.java)
} else { } else {

@ -1,6 +1,5 @@
package org.tasks package org.tasks
import android.app.Application
import android.content.BroadcastReceiver import android.content.BroadcastReceiver
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
@ -15,6 +14,7 @@ import org.tasks.billing.BillingClient
import org.tasks.billing.Inventory import org.tasks.billing.Inventory
import org.tasks.files.FileHelper import org.tasks.files.FileHelper
import org.tasks.injection.ApplicationComponent import org.tasks.injection.ApplicationComponent
import org.tasks.injection.ApplicationContext
import org.tasks.injection.InjectingApplication import org.tasks.injection.InjectingApplication
import org.tasks.injection.InjectingJobIntentService import org.tasks.injection.InjectingJobIntentService
import org.tasks.jobs.WorkManager import org.tasks.jobs.WorkManager
@ -30,6 +30,7 @@ import timber.log.Timber
import javax.inject.Inject import javax.inject.Inject
class Tasks : InjectingApplication(), Configuration.Provider { class Tasks : InjectingApplication(), Configuration.Provider {
@Inject @ApplicationContext lateinit var context: Context
@Inject lateinit var preferences: Preferences @Inject lateinit var preferences: Preferences
@Inject lateinit var buildSetup: BuildSetup @Inject lateinit var buildSetup: BuildSetup
@Inject lateinit var inventory: Inventory @Inject lateinit var inventory: Inventory
@ -64,15 +65,15 @@ class Tasks : InjectingApplication(), Configuration.Provider {
} }
private fun doInBackground() { private fun doInBackground() {
NotificationSchedulerIntentService.enqueueWork(this, false) NotificationSchedulerIntentService.enqueueWork(context, false)
CalendarNotificationIntentService.enqueueWork(this) CalendarNotificationIntentService.enqueueWork(context)
refreshScheduler.get().scheduleAll() refreshScheduler.get().scheduleAll()
workManager.get().updateBackgroundSync() workManager.get().updateBackgroundSync()
workManager.get().scheduleMidnightRefresh() workManager.get().scheduleMidnightRefresh()
workManager.get().scheduleBackup() workManager.get().scheduleBackup()
workManager.get().scheduleConfigRefresh() workManager.get().scheduleConfigRefresh()
geofenceApi.get().registerAll() geofenceApi.get().registerAll()
FileHelper.delete(this, preferences.cacheDirectory) FileHelper.delete(context, preferences.cacheDirectory)
billingClient.get().queryPurchases() billingClient.get().queryPurchases()
appWidgetManager.get().reconfigureWidgets() appWidgetManager.get().reconfigureWidgets()
} }

@ -1,6 +1,5 @@
package org.tasks.activities; package org.tasks.activities;
import android.app.Application;
import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetManager;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
@ -18,6 +17,7 @@ import org.tasks.LocalBroadcastManager;
import org.tasks.dialogs.DialogBuilder; import org.tasks.dialogs.DialogBuilder;
import org.tasks.filters.FilterProvider; import org.tasks.filters.FilterProvider;
import org.tasks.injection.ActivityComponent; import org.tasks.injection.ActivityComponent;
import org.tasks.injection.ApplicationContext;
import org.tasks.injection.InjectingAppCompatActivity; import org.tasks.injection.InjectingAppCompatActivity;
import org.tasks.preferences.DefaultFilterProvider; import org.tasks.preferences.DefaultFilterProvider;
import org.tasks.preferences.Preferences; import org.tasks.preferences.Preferences;
@ -31,7 +31,7 @@ public class FilterSelectionActivity extends InjectingAppCompatActivity {
private static final String EXTRA_FILTER_SQL = "extra_filter_query"; private static final String EXTRA_FILTER_SQL = "extra_filter_query";
private static final String EXTRA_FILTER_VALUES = "extra_filter_values"; private static final String EXTRA_FILTER_VALUES = "extra_filter_values";
@Inject Application context; @Inject @ApplicationContext Context context;
@Inject DialogBuilder dialogBuilder; @Inject DialogBuilder dialogBuilder;
@Inject FilterAdapter filterAdapter; @Inject FilterAdapter filterAdapter;
@Inject FilterProvider filterProvider; @Inject FilterProvider filterProvider;

@ -2,7 +2,6 @@ package org.tasks.activities;
import static org.tasks.Strings.isNullOrEmpty; import static org.tasks.Strings.isNullOrEmpty;
import android.app.Application;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
@ -26,13 +25,14 @@ import org.tasks.data.GoogleTaskAccount;
import org.tasks.data.GoogleTaskList; import org.tasks.data.GoogleTaskList;
import org.tasks.data.GoogleTaskListDao; import org.tasks.data.GoogleTaskListDao;
import org.tasks.injection.ActivityComponent; import org.tasks.injection.ActivityComponent;
import org.tasks.injection.ApplicationContext;
import timber.log.Timber; import timber.log.Timber;
public class GoogleTaskListSettingsActivity extends BaseListSettingsActivity { public class GoogleTaskListSettingsActivity extends BaseListSettingsActivity {
public static final String EXTRA_ACCOUNT = "extra_account"; public static final String EXTRA_ACCOUNT = "extra_account";
public static final String EXTRA_STORE_DATA = "extra_store_data"; public static final String EXTRA_STORE_DATA = "extra_store_data";
@Inject Application context; @Inject @ApplicationContext Context context;
@Inject GoogleTaskListDao googleTaskListDao; @Inject GoogleTaskListDao googleTaskListDao;
@Inject GtasksListService gtasksListService; @Inject GtasksListService gtasksListService;
@Inject TaskDeleter taskDeleter; @Inject TaskDeleter taskDeleter;

@ -5,7 +5,6 @@ import static at.bitfire.dav4jvm.XmlUtils.NS_CARDDAV;
import static at.bitfire.dav4jvm.XmlUtils.NS_WEBDAV; import static at.bitfire.dav4jvm.XmlUtils.NS_WEBDAV;
import static org.tasks.Strings.isNullOrEmpty; import static org.tasks.Strings.isNullOrEmpty;
import android.app.Application;
import android.content.Context; import android.content.Context;
import at.bitfire.cert4android.CustomCertManager; import at.bitfire.cert4android.CustomCertManager;
import at.bitfire.cert4android.CustomCertManager.CustomHostnameVerifier; import at.bitfire.cert4android.CustomCertManager.CustomHostnameVerifier;
@ -44,6 +43,7 @@ import org.tasks.DebugNetworkInterceptor;
import org.tasks.R; import org.tasks.R;
import org.tasks.data.CaldavAccount; import org.tasks.data.CaldavAccount;
import org.tasks.data.CaldavCalendar; import org.tasks.data.CaldavCalendar;
import org.tasks.injection.ApplicationContext;
import org.tasks.preferences.Preferences; import org.tasks.preferences.Preferences;
import org.tasks.security.KeyStoreEncryption; import org.tasks.security.KeyStoreEncryption;
import org.tasks.ui.DisplayableException; import org.tasks.ui.DisplayableException;
@ -65,7 +65,7 @@ public class CaldavClient {
@Inject @Inject
CaldavClient( CaldavClient(
Application context, @ApplicationContext Context context,
KeyStoreEncryption encryption, KeyStoreEncryption encryption,
Preferences preferences, Preferences preferences,
DebugNetworkInterceptor interceptor) { DebugNetworkInterceptor interceptor) {

@ -9,7 +9,6 @@ import static com.google.common.collect.Sets.newHashSet;
import static org.tasks.Strings.isNullOrEmpty; import static org.tasks.Strings.isNullOrEmpty;
import static org.tasks.time.DateTimeUtils.currentTimeMillis; import static org.tasks.time.DateTimeUtils.currentTimeMillis;
import android.app.Application;
import android.content.Context; import android.content.Context;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import at.bitfire.dav4jvm.DavCalendar; import at.bitfire.dav4jvm.DavCalendar;
@ -56,6 +55,7 @@ import org.tasks.data.CaldavAccount;
import org.tasks.data.CaldavCalendar; import org.tasks.data.CaldavCalendar;
import org.tasks.data.CaldavDao; import org.tasks.data.CaldavDao;
import org.tasks.data.CaldavTask; import org.tasks.data.CaldavTask;
import org.tasks.injection.ApplicationContext;
import timber.log.Timber; import timber.log.Timber;
public class CaldavSynchronizer { public class CaldavSynchronizer {
@ -77,7 +77,7 @@ public class CaldavSynchronizer {
@Inject @Inject
public CaldavSynchronizer( public CaldavSynchronizer(
Application context, @ApplicationContext Context context,
CaldavDao caldavDao, CaldavDao caldavDao,
TaskDao taskDao, TaskDao taskDao,
LocalBroadcastManager localBroadcastManager, LocalBroadcastManager localBroadcastManager,

@ -1,13 +1,14 @@
package org.tasks.calendars; package org.tasks.calendars;
import android.app.Application;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.Context;
import android.database.Cursor; import android.database.Cursor;
import android.provider.CalendarContract; import android.provider.CalendarContract;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import javax.inject.Inject; import javax.inject.Inject;
import org.tasks.injection.ApplicationContext;
import org.tasks.preferences.PermissionChecker; import org.tasks.preferences.PermissionChecker;
import timber.log.Timber; import timber.log.Timber;
@ -22,7 +23,7 @@ class CalendarEventAttendeeProvider {
@Inject @Inject
public CalendarEventAttendeeProvider( public CalendarEventAttendeeProvider(
Application context, PermissionChecker permissionChecker) { @ApplicationContext Context context, PermissionChecker permissionChecker) {
this.permissionChecker = permissionChecker; this.permissionChecker = permissionChecker;
contentResolver = context.getContentResolver(); contentResolver = context.getContentResolver();
} }

@ -3,8 +3,8 @@ package org.tasks.calendars;
import static android.provider.BaseColumns._ID; import static android.provider.BaseColumns._ID;
import static org.tasks.Strings.isNullOrEmpty; import static org.tasks.Strings.isNullOrEmpty;
import android.app.Application;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.Context;
import android.database.Cursor; import android.database.Cursor;
import android.net.Uri; import android.net.Uri;
import android.provider.CalendarContract; import android.provider.CalendarContract;
@ -14,6 +14,7 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import javax.inject.Inject; import javax.inject.Inject;
import org.tasks.injection.ApplicationContext;
import org.tasks.preferences.PermissionChecker; import org.tasks.preferences.PermissionChecker;
import timber.log.Timber; import timber.log.Timber;
@ -33,7 +34,7 @@ public class CalendarEventProvider {
@Inject @Inject
public CalendarEventProvider( public CalendarEventProvider(
Application context, @ApplicationContext Context context,
PermissionChecker permissionChecker, PermissionChecker permissionChecker,
CalendarEventAttendeeProvider calendarEventAttendeeProvider) { CalendarEventAttendeeProvider calendarEventAttendeeProvider) {
this.permissionChecker = permissionChecker; this.permissionChecker = permissionChecker;

@ -3,8 +3,8 @@ package org.tasks.calendars;
import static android.provider.BaseColumns._ID; import static android.provider.BaseColumns._ID;
import static org.tasks.Strings.isNullOrEmpty; import static org.tasks.Strings.isNullOrEmpty;
import android.app.Application;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.Context;
import android.database.Cursor; import android.database.Cursor;
import android.net.Uri; import android.net.Uri;
import android.provider.CalendarContract; import android.provider.CalendarContract;
@ -13,6 +13,7 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import javax.inject.Inject; import javax.inject.Inject;
import org.tasks.injection.ApplicationContext;
import org.tasks.preferences.PermissionChecker; import org.tasks.preferences.PermissionChecker;
import timber.log.Timber; import timber.log.Timber;
@ -31,7 +32,7 @@ public class CalendarProvider {
private final ContentResolver contentResolver; private final ContentResolver contentResolver;
@Inject @Inject
public CalendarProvider(Application context, PermissionChecker permissionChecker) { public CalendarProvider(@ApplicationContext Context context, PermissionChecker permissionChecker) {
this.permissionChecker = permissionChecker; this.permissionChecker = permissionChecker;
contentResolver = context.getContentResolver(); contentResolver = context.getContentResolver();
} }

@ -3,8 +3,8 @@ package org.tasks.dialogs;
import static org.tasks.dialogs.RecordAudioDialog.newRecordAudioDialog; import static org.tasks.dialogs.RecordAudioDialog.newRecordAudioDialog;
import static org.tasks.files.FileHelper.newFilePickerIntent; import static org.tasks.files.FileHelper.newFilePickerIntent;
import android.app.Activity;
import android.app.Dialog; import android.app.Dialog;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.provider.MediaStore.Images.Media; import android.provider.MediaStore.Images.Media;
@ -16,6 +16,7 @@ import javax.inject.Inject;
import org.tasks.R; import org.tasks.R;
import org.tasks.activities.CameraActivity; import org.tasks.activities.CameraActivity;
import org.tasks.injection.DialogFragmentComponent; import org.tasks.injection.DialogFragmentComponent;
import org.tasks.injection.ActivityContext;
import org.tasks.injection.InjectingDialogFragment; import org.tasks.injection.InjectingDialogFragment;
import org.tasks.preferences.Device; import org.tasks.preferences.Device;
@ -26,7 +27,7 @@ public class AddAttachmentDialog extends InjectingDialogFragment {
public static final int REQUEST_STORAGE = 12122; public static final int REQUEST_STORAGE = 12122;
public static final int REQUEST_AUDIO = 12123; public static final int REQUEST_AUDIO = 12123;
private static final String FRAG_TAG_RECORD_AUDIO = "frag_tag_record_audio"; private static final String FRAG_TAG_RECORD_AUDIO = "frag_tag_record_audio";
@Inject Activity context; @Inject @ActivityContext Context context;
@Inject DialogBuilder dialogBuilder; @Inject DialogBuilder dialogBuilder;
@Inject Device device; @Inject Device device;

@ -2,8 +2,8 @@ package org.tasks.dialogs;
import static android.app.Activity.RESULT_OK; import static android.app.Activity.RESULT_OK;
import android.app.Activity;
import android.app.Dialog; import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
@ -21,6 +21,7 @@ import org.tasks.R;
import org.tasks.data.Geofence; import org.tasks.data.Geofence;
import org.tasks.data.Location; import org.tasks.data.Location;
import org.tasks.injection.DialogFragmentComponent; import org.tasks.injection.DialogFragmentComponent;
import org.tasks.injection.ActivityContext;
import org.tasks.injection.InjectingDialogFragment; import org.tasks.injection.InjectingDialogFragment;
import org.tasks.locale.Locale; import org.tasks.locale.Locale;
import org.tasks.preferences.PermissionChecker; import org.tasks.preferences.PermissionChecker;
@ -34,7 +35,7 @@ public class GeofenceDialog extends InjectingDialogFragment {
private static final int MAX_RADIUS = 1000; private static final int MAX_RADIUS = 1000;
@Inject DialogBuilder dialogBuilder; @Inject DialogBuilder dialogBuilder;
@Inject Activity context; @Inject @ActivityContext Context context;
@Inject Locale locale; @Inject Locale locale;
@Inject PermissionChecker permissionChecker; @Inject PermissionChecker permissionChecker;
@Inject Toaster toaster; @Inject Toaster toaster;

@ -2,6 +2,7 @@ package org.tasks.dialogs;
import android.app.Activity; import android.app.Activity;
import android.app.Dialog; import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
@ -17,6 +18,7 @@ import org.tasks.R;
import org.tasks.billing.Inventory; import org.tasks.billing.Inventory;
import org.tasks.billing.PurchaseActivity; import org.tasks.billing.PurchaseActivity;
import org.tasks.injection.DialogFragmentComponent; import org.tasks.injection.DialogFragmentComponent;
import org.tasks.injection.ActivityContext;
import org.tasks.injection.InjectingDialogFragment; import org.tasks.injection.InjectingDialogFragment;
import org.tasks.themes.CustomIcons; import org.tasks.themes.CustomIcons;
@ -28,7 +30,7 @@ public class IconPickerDialog extends InjectingDialogFragment {
RecyclerView recyclerView; RecyclerView recyclerView;
@Inject DialogBuilder dialogBuilder; @Inject DialogBuilder dialogBuilder;
@Inject Activity context; @Inject @ActivityContext Context context;
@Inject Inventory inventory; @Inject Inventory inventory;
private IconPickerCallback callback; private IconPickerCallback callback;

@ -3,6 +3,7 @@ package org.tasks.dialogs;
import android.app.Activity; import android.app.Activity;
import android.app.Dialog; import android.app.Dialog;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
@ -14,6 +15,7 @@ import org.tasks.R;
import org.tasks.backup.TasksJsonImporter; import org.tasks.backup.TasksJsonImporter;
import org.tasks.backup.TasksJsonImporter.ImportResult; import org.tasks.backup.TasksJsonImporter.ImportResult;
import org.tasks.injection.DialogFragmentComponent; import org.tasks.injection.DialogFragmentComponent;
import org.tasks.injection.ActivityContext;
import org.tasks.injection.InjectingDialogFragment; import org.tasks.injection.InjectingDialogFragment;
import org.tasks.ui.Toaster; import org.tasks.ui.Toaster;
@ -25,7 +27,7 @@ public class ImportTasksDialog extends InjectingDialogFragment {
@Inject TasksXmlImporter xmlImporter; @Inject TasksXmlImporter xmlImporter;
@Inject TasksJsonImporter jsonImporter; @Inject TasksJsonImporter jsonImporter;
@Inject DialogBuilder dialogBuilder; @Inject DialogBuilder dialogBuilder;
@Inject Activity context; @Inject @ActivityContext Context context;
@Inject Toaster toaster; @Inject Toaster toaster;
public static ImportTasksDialog newImportTasksDialog(Uri data, String extension) { public static ImportTasksDialog newImportTasksDialog(Uri data, String extension) {

@ -3,7 +3,6 @@ package org.tasks.dialogs;
import static java.util.Arrays.asList; import static java.util.Arrays.asList;
import static org.tasks.Strings.isNullOrEmpty; import static org.tasks.Strings.isNullOrEmpty;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
@ -17,6 +16,7 @@ import java.io.UnsupportedEncodingException;
import java.net.URLDecoder; import java.net.URLDecoder;
import javax.inject.Inject; import javax.inject.Inject;
import org.tasks.R; import org.tasks.R;
import org.tasks.injection.ActivityContext;
public class Linkify { public class Linkify {
@ -24,7 +24,7 @@ public class Linkify {
private final DialogBuilder dialogBuilder; private final DialogBuilder dialogBuilder;
@Inject @Inject
public Linkify(Activity context, DialogBuilder dialogBuilder) { public Linkify(@ActivityContext Context context, DialogBuilder dialogBuilder) {
this.context = context; this.context = context;
this.dialogBuilder = dialogBuilder; this.dialogBuilder = dialogBuilder;
} }

@ -2,7 +2,6 @@ package org.tasks.drive;
import static com.todoroo.andlib.utility.DateUtilities.now; import static com.todoroo.andlib.utility.DateUtilities.now;
import android.app.Application;
import android.content.Context; import android.content.Context;
import android.net.Uri; import android.net.Uri;
import com.google.api.client.http.HttpResponse; import com.google.api.client.http.HttpResponse;
@ -24,6 +23,7 @@ import org.tasks.BuildConfig;
import org.tasks.DebugNetworkInterceptor; import org.tasks.DebugNetworkInterceptor;
import org.tasks.R; import org.tasks.R;
import org.tasks.files.FileHelper; import org.tasks.files.FileHelper;
import org.tasks.injection.ApplicationContext;
import org.tasks.preferences.Preferences; import org.tasks.preferences.Preferences;
import timber.log.Timber; import timber.log.Timber;
@ -39,7 +39,7 @@ public class DriveInvoker {
@Inject @Inject
public DriveInvoker( public DriveInvoker(
Application context, @ApplicationContext Context context,
Preferences preferences, Preferences preferences,
HttpCredentialsAdapter credentialsAdapter, HttpCredentialsAdapter credentialsAdapter,
DebugNetworkInterceptor interceptor) { DebugNetworkInterceptor interceptor) {

@ -3,7 +3,6 @@ package org.tasks.etesync;
import static com.google.common.collect.Lists.partition; import static com.google.common.collect.Lists.partition;
import static com.google.common.collect.Lists.transform; import static com.google.common.collect.Lists.transform;
import android.app.Application;
import android.content.Context; import android.content.Context;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.core.util.Pair; import androidx.core.util.Pair;
@ -45,6 +44,7 @@ import org.tasks.DebugNetworkInterceptor;
import org.tasks.caldav.MemoryCookieStore; import org.tasks.caldav.MemoryCookieStore;
import org.tasks.data.CaldavAccount; import org.tasks.data.CaldavAccount;
import org.tasks.data.CaldavCalendar; import org.tasks.data.CaldavCalendar;
import org.tasks.injection.ApplicationContext;
import org.tasks.preferences.Preferences; import org.tasks.preferences.Preferences;
import org.tasks.security.KeyStoreEncryption; import org.tasks.security.KeyStoreEncryption;
import timber.log.Timber; import timber.log.Timber;
@ -69,7 +69,7 @@ public class EteSyncClient {
@Inject @Inject
public EteSyncClient( public EteSyncClient(
Application context, @ApplicationContext Context context,
KeyStoreEncryption encryption, KeyStoreEncryption encryption,
Preferences preferences, Preferences preferences,
DebugNetworkInterceptor interceptor) { DebugNetworkInterceptor interceptor) {

@ -6,7 +6,6 @@ import static com.google.common.collect.Sets.newHashSet;
import static java.util.Collections.emptySet; import static java.util.Collections.emptySet;
import static org.tasks.Strings.isNullOrEmpty; import static org.tasks.Strings.isNullOrEmpty;
import android.app.Application;
import android.content.Context; import android.content.Context;
import androidx.core.util.Pair; import androidx.core.util.Pair;
import at.bitfire.ical4android.ICalendar; import at.bitfire.ical4android.ICalendar;
@ -43,6 +42,7 @@ import org.tasks.data.CaldavCalendar;
import org.tasks.data.CaldavDao; import org.tasks.data.CaldavDao;
import org.tasks.data.CaldavTask; import org.tasks.data.CaldavTask;
import org.tasks.data.CaldavTaskContainer; import org.tasks.data.CaldavTaskContainer;
import org.tasks.injection.ApplicationContext;
import timber.log.Timber; import timber.log.Timber;
public class EteSynchronizer { public class EteSynchronizer {
@ -62,7 +62,7 @@ public class EteSynchronizer {
@Inject @Inject
public EteSynchronizer( public EteSynchronizer(
Application context, @ApplicationContext Context context,
CaldavDao caldavDao, CaldavDao caldavDao,
LocalBroadcastManager localBroadcastManager, LocalBroadcastManager localBroadcastManager,
TaskDeleter taskDeleter, TaskDeleter taskDeleter,

@ -3,7 +3,6 @@ package org.tasks.filters;
import static com.google.common.collect.Iterables.transform; import static com.google.common.collect.Iterables.transform;
import static com.google.common.collect.Sets.newLinkedHashSet; import static com.google.common.collect.Sets.newLinkedHashSet;
import android.app.Application;
import android.content.Context; import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
import com.todoroo.andlib.sql.Criterion; import com.todoroo.andlib.sql.Criterion;
@ -32,6 +31,7 @@ import org.tasks.data.GoogleTaskListDao;
import org.tasks.data.Tag; import org.tasks.data.Tag;
import org.tasks.data.TagData; import org.tasks.data.TagData;
import org.tasks.data.TagDataDao; import org.tasks.data.TagDataDao;
import org.tasks.injection.ApplicationContext;
public class FilterCriteriaProvider { public class FilterCriteriaProvider {
@ -52,7 +52,7 @@ public class FilterCriteriaProvider {
@Inject @Inject
public FilterCriteriaProvider( public FilterCriteriaProvider(
Application context, @ApplicationContext Context context,
TagDataDao tagDataDao, TagDataDao tagDataDao,
GoogleTaskListDao googleTaskListDao, GoogleTaskListDao googleTaskListDao,
CaldavDao caldavDao) { CaldavDao caldavDao) {

@ -1,6 +1,5 @@
package org.tasks.filters package org.tasks.filters
import android.app.Application
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import com.todoroo.andlib.utility.AndroidUtilities.assertNotMainThread import com.todoroo.andlib.utility.AndroidUtilities.assertNotMainThread
@ -19,6 +18,7 @@ import org.tasks.caldav.BaseCaldavCalendarSettingsActivity
import org.tasks.data.* import org.tasks.data.*
import org.tasks.data.CaldavAccount.Companion.TYPE_LOCAL import org.tasks.data.CaldavAccount.Companion.TYPE_LOCAL
import org.tasks.filters.NavigationDrawerSubheader.SubheaderType import org.tasks.filters.NavigationDrawerSubheader.SubheaderType
import org.tasks.injection.ApplicationContext
import org.tasks.location.LocationPickerActivity import org.tasks.location.LocationPickerActivity
import org.tasks.preferences.HelpAndFeedback import org.tasks.preferences.HelpAndFeedback
import org.tasks.preferences.MainPreferences import org.tasks.preferences.MainPreferences
@ -27,7 +27,7 @@ import org.tasks.ui.NavigationDrawerFragment
import javax.inject.Inject import javax.inject.Inject
class FilterProvider @Inject constructor( class FilterProvider @Inject constructor(
private val context: Application, @param:ApplicationContext private val context: Context,
private val inventory: Inventory, private val inventory: Inventory,
private val builtInFilterExposer: BuiltInFilterExposer, private val builtInFilterExposer: BuiltInFilterExposer,
private val filterDao: FilterDao, private val filterDao: FilterDao,

@ -1,6 +1,6 @@
package org.tasks.fragments; package org.tasks.fragments;
import android.app.Activity; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
import com.todoroo.astrid.activity.BeastModePreferences; import com.todoroo.astrid.activity.BeastModePreferences;
@ -19,13 +19,14 @@ import java.util.Map;
import javax.inject.Inject; import javax.inject.Inject;
import org.tasks.BuildConfig; import org.tasks.BuildConfig;
import org.tasks.R; import org.tasks.R;
import org.tasks.injection.ActivityContext;
import org.tasks.preferences.Preferences; import org.tasks.preferences.Preferences;
import org.tasks.ui.CalendarControlSet; import org.tasks.ui.CalendarControlSet;
import org.tasks.ui.DeadlineControlSet; import org.tasks.ui.DeadlineControlSet;
import org.tasks.ui.DescriptionControlSet; import org.tasks.ui.DescriptionControlSet;
import org.tasks.ui.ListFragment;
import org.tasks.ui.LocationControlSet; import org.tasks.ui.LocationControlSet;
import org.tasks.ui.PriorityControlSet; import org.tasks.ui.PriorityControlSet;
import org.tasks.ui.ListFragment;
import org.tasks.ui.SubtaskControlSet; import org.tasks.ui.SubtaskControlSet;
import org.tasks.ui.TaskEditControlFragment; import org.tasks.ui.TaskEditControlFragment;
@ -80,7 +81,7 @@ public class TaskEditControlSetFragmentManager {
private int numRows; private int numRows;
@Inject @Inject
public TaskEditControlSetFragmentManager(Activity context, Preferences preferences) { public TaskEditControlSetFragmentManager(@ActivityContext Context context, Preferences preferences) {
displayOrder = BeastModePreferences.constructOrderedControlList(preferences, context); displayOrder = BeastModePreferences.constructOrderedControlList(preferences, context);
displayOrder.add(0, context.getString(CommentBarFragment.TAG)); displayOrder.add(0, context.getString(CommentBarFragment.TAG));
String hideAlwaysTrigger = context.getString(R.string.TEA_ctrl_hide_section_pref); String hideAlwaysTrigger = context.getString(R.string.TEA_ctrl_hide_section_pref);

@ -12,7 +12,7 @@ import android.accounts.AuthenticatorException;
import android.accounts.OperationCanceledException; import android.accounts.OperationCanceledException;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.app.Application; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import com.google.api.services.drive.DriveScopes; import com.google.api.services.drive.DriveScopes;
@ -25,6 +25,7 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import javax.inject.Inject; import javax.inject.Inject;
import org.tasks.R; import org.tasks.R;
import org.tasks.injection.ApplicationContext;
import org.tasks.play.AuthResultHandler; import org.tasks.play.AuthResultHandler;
import org.tasks.preferences.PermissionChecker; import org.tasks.preferences.PermissionChecker;
import org.tasks.preferences.Preferences; import org.tasks.preferences.Preferences;
@ -38,7 +39,7 @@ public class GoogleAccountManager {
@Inject @Inject
public GoogleAccountManager( public GoogleAccountManager(
Application context, PermissionChecker permissionChecker, Preferences preferences) { @ApplicationContext Context context, PermissionChecker permissionChecker, Preferences preferences) {
this.permissionChecker = permissionChecker; this.permissionChecker = permissionChecker;
accountManager = android.accounts.AccountManager.get(context); accountManager = android.accounts.AccountManager.get(context);
this.preferences = preferences; this.preferences = preferences;

@ -4,7 +4,6 @@ import static com.google.common.collect.Lists.transform;
import static org.tasks.Strings.isNullOrEmpty; import static org.tasks.Strings.isNullOrEmpty;
import static org.tasks.date.DateTimeUtils.newDateTime; import static org.tasks.date.DateTimeUtils.newDateTime;
import android.app.Application;
import android.content.Context; import android.content.Context;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.google.api.client.googleapis.json.GoogleJsonResponseException; import com.google.api.client.googleapis.json.GoogleJsonResponseException;
@ -43,6 +42,7 @@ import org.tasks.data.GoogleTaskAccount;
import org.tasks.data.GoogleTaskDao; import org.tasks.data.GoogleTaskDao;
import org.tasks.data.GoogleTaskList; import org.tasks.data.GoogleTaskList;
import org.tasks.data.GoogleTaskListDao; import org.tasks.data.GoogleTaskListDao;
import org.tasks.injection.ApplicationContext;
import org.tasks.preferences.DefaultFilterProvider; import org.tasks.preferences.DefaultFilterProvider;
import org.tasks.preferences.PermissionChecker; import org.tasks.preferences.PermissionChecker;
import org.tasks.preferences.Preferences; import org.tasks.preferences.Preferences;
@ -82,7 +82,7 @@ public class GoogleTaskSynchronizer {
@Inject @Inject
public GoogleTaskSynchronizer( public GoogleTaskSynchronizer(
Application context, @ApplicationContext Context context,
GoogleTaskListDao googleTaskListDao, GoogleTaskListDao googleTaskListDao,
GtasksListService gtasksListService, GtasksListService gtasksListService,
Preferences preferences, Preferences preferences,

@ -0,0 +1,9 @@
package org.tasks.injection
import javax.inject.Qualifier
@Qualifier
@Target(AnnotationTarget.FIELD, AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER)
@MustBeDocumented
@Retention(AnnotationRetention.RUNTIME)
annotation class ActivityContext

@ -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 dagger.Module import dagger.Module
import dagger.Provides import dagger.Provides
import org.tasks.R import org.tasks.R
@ -14,6 +15,11 @@ import org.tasks.themes.ThemeColor
@Module @Module
class ActivityModule(@get:Provides val activity: Activity) { class ActivityModule(@get:Provides val activity: Activity) {
@get:ActivityContext
@get:Provides
val activityContext: Context
get() = activity
@Provides @Provides
@ActivityScope @ActivityScope
fun getThemeBase(preferences: Preferences, inventory: Inventory): ThemeBase fun getThemeBase(preferences: Preferences, inventory: Inventory): ThemeBase

@ -0,0 +1,9 @@
package org.tasks.injection
import javax.inject.Qualifier
@Qualifier
@Target(AnnotationTarget.FIELD, AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER)
@MustBeDocumented
@Retention(AnnotationRetention.RUNTIME)
annotation class ApplicationContext

@ -1,6 +1,6 @@
package org.tasks.injection package org.tasks.injection
import android.app.Application import android.content.Context
import com.todoroo.astrid.dao.Database import com.todoroo.astrid.dao.Database
import com.todoroo.astrid.dao.TaskDao import com.todoroo.astrid.dao.TaskDao
import dagger.Module import dagger.Module
@ -17,7 +17,7 @@ import org.tasks.location.MapboxGeocoder
import org.tasks.notifications.NotificationDao import org.tasks.notifications.NotificationDao
@Module @Module
class ApplicationModule(@get:Provides val context: Application) { class ApplicationModule(@get:Provides @get:ApplicationContext val context: Context) {
@get:Provides @get:Provides
val locale: Locale val locale: Locale

@ -1,23 +1,19 @@
package org.tasks.injection package org.tasks.injection
import android.app.Application import android.content.Context
import org.tasks.locale.Locale import org.tasks.locale.Locale
import timber.log.Timber
internal class Dagger private constructor(context: Application) { internal class Dagger private constructor(context: Context) {
val applicationComponent: ApplicationComponent = val applicationComponent: ApplicationComponent
DaggerApplicationComponent.builder()
.applicationModule(ApplicationModule(context))
.productionModule(ProductionModule())
.build()
companion object { companion object {
private val lock = Any() private val lock = Any()
private var instance: Dagger? = null private var instance: Dagger? = null
operator fun get(context: Application): Dagger { operator fun get(context: Context): Dagger {
if (instance == null) { if (instance == null) {
synchronized(lock) { synchronized(lock) {
if (instance == null) { if (instance == null) {
Locale.getInstance(context)
instance = Dagger(context) instance = Dagger(context)
} }
} }
@ -25,4 +21,17 @@ internal class Dagger private constructor(context: Application) {
return instance!! return instance!!
} }
} }
init {
var localeContext = context.applicationContext
try {
localeContext = Locale.getInstance(localeContext).createConfigurationContext(localeContext)
} catch (e: Exception) {
Timber.e(e)
}
applicationComponent = DaggerApplicationComponent.builder()
.applicationModule(ApplicationModule(localeContext))
.productionModule(ProductionModule())
.build()
}
} }

@ -1,13 +1,15 @@
package org.tasks.injection package org.tasks.injection
import android.app.Application import android.app.Application
import org.tasks.locale.Locale
abstract class InjectingApplication : Application() { abstract class InjectingApplication : Application() {
lateinit var component: ApplicationComponent lateinit var component: ApplicationComponent
override fun onCreate() { override fun onCreate() {
super.onCreate() super.onCreate()
component = Dagger.Companion[this].applicationComponent val context = Locale.getInstance(this).createConfigurationContext(applicationContext)
component = Dagger.Companion[context].applicationComponent
inject(component) inject(component)
} }

@ -1,13 +1,12 @@
package org.tasks.injection package org.tasks.injection
import android.app.Application
import android.content.ContentProvider import android.content.ContentProvider
abstract class InjectingContentProvider : ContentProvider() { abstract class InjectingContentProvider : ContentProvider() {
override fun onCreate(): Boolean { override fun onCreate(): Boolean {
inject( inject(
DaggerContentProviderComponent.builder() DaggerContentProviderComponent.builder()
.applicationModule(ApplicationModule(context!!.applicationContext as Application)) .applicationModule(ApplicationModule(context!!.applicationContext))
.productionModule(ProductionModule()) .productionModule(ProductionModule())
.contentProviderModule(ContentProviderModule()) .contentProviderModule(ContentProviderModule())
.build()) .build())

@ -1,6 +1,6 @@
package org.tasks.injection package org.tasks.injection
import android.app.Application import android.content.Context
import androidx.room.Room import androidx.room.Room
import com.todoroo.astrid.dao.Database import com.todoroo.astrid.dao.Database
import dagger.Module import dagger.Module
@ -12,7 +12,7 @@ import org.tasks.preferences.Preferences
internal class ProductionModule { internal class ProductionModule {
@Provides @Provides
@ApplicationScope @ApplicationScope
fun getAppDatabase(context: Application): Database { fun getAppDatabase(@ApplicationContext context: Context): Database {
return Room.databaseBuilder(context, Database::class.java, Database.NAME) return Room.databaseBuilder(context, Database::class.java, Database.NAME)
.allowMainThreadQueries() // TODO: remove me .allowMainThreadQueries() // TODO: remove me
.addMigrations(*Migrations.MIGRATIONS) .addMigrations(*Migrations.MIGRATIONS)
@ -20,7 +20,7 @@ internal class ProductionModule {
} }
@Provides @Provides
fun getPreferences(context: Application): Preferences { fun getPreferences(@ApplicationContext context: Context): Preferences {
return Preferences(context) return Preferences(context)
} }
} }

@ -3,7 +3,6 @@ package org.tasks.jobs;
import static com.todoroo.astrid.dao.TaskDao.TRANS_SUPPRESS_REFRESH; import static com.todoroo.astrid.dao.TaskDao.TRANS_SUPPRESS_REFRESH;
import static org.tasks.Strings.isNullOrEmpty; import static org.tasks.Strings.isNullOrEmpty;
import android.app.Application;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.ContentValues; import android.content.ContentValues;
import android.content.Context; import android.content.Context;
@ -25,6 +24,7 @@ import org.tasks.LocalBroadcastManager;
import org.tasks.R; import org.tasks.R;
import org.tasks.data.CaldavAccount; import org.tasks.data.CaldavAccount;
import org.tasks.data.CaldavDao; import org.tasks.data.CaldavDao;
import org.tasks.injection.ApplicationContext;
import org.tasks.injection.InjectingWorker; import org.tasks.injection.InjectingWorker;
import org.tasks.injection.JobComponent; import org.tasks.injection.JobComponent;
import org.tasks.location.GeofenceApi; import org.tasks.location.GeofenceApi;
@ -43,7 +43,7 @@ public class AfterSaveWork extends InjectingWorker {
private static final String EXTRA_SUPPRESS_REFRESH = "extra_suppress_refresh"; private static final String EXTRA_SUPPRESS_REFRESH = "extra_suppress_refresh";
@Inject RepeatTaskHelper repeatTaskHelper; @Inject RepeatTaskHelper repeatTaskHelper;
@Inject Application context; @Inject @ApplicationContext Context context;
@Inject NotificationManager notificationManager; @Inject NotificationManager notificationManager;
@Inject GeofenceApi geofenceApi; @Inject GeofenceApi geofenceApi;
@Inject TimerPlugin timerPlugin; @Inject TimerPlugin timerPlugin;

@ -6,7 +6,6 @@ import static com.google.common.collect.Lists.newArrayList;
import static com.todoroo.andlib.utility.DateUtilities.now; import static com.todoroo.andlib.utility.DateUtilities.now;
import static java.util.Collections.emptyList; import static java.util.Collections.emptyList;
import android.app.Application;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.Context; import android.content.Context;
import android.net.Uri; import android.net.Uri;
@ -23,6 +22,7 @@ import java.util.List;
import javax.inject.Inject; import javax.inject.Inject;
import org.tasks.R; import org.tasks.R;
import org.tasks.backup.TasksJsonExporter; import org.tasks.backup.TasksJsonExporter;
import org.tasks.injection.ApplicationContext;
import org.tasks.injection.JobComponent; import org.tasks.injection.JobComponent;
import org.tasks.preferences.Preferences; import org.tasks.preferences.Preferences;
import timber.log.Timber; import timber.log.Timber;
@ -37,7 +37,7 @@ public class BackupWork extends RepeatingWorker {
(f1, f2) -> Long.compare(f2.lastModified(), f1.lastModified()); (f1, f2) -> Long.compare(f2.lastModified(), f1.lastModified());
private static final Comparator<DocumentFile> DOCUMENT_FILE_COMPARATOR = private static final Comparator<DocumentFile> DOCUMENT_FILE_COMPARATOR =
(d1, d2) -> Long.compare(d2.lastModified(), d1.lastModified()); (d1, d2) -> Long.compare(d2.lastModified(), d1.lastModified());
@Inject Application context; @Inject @ApplicationContext Context context;
@Inject TasksJsonExporter tasksJsonExporter; @Inject TasksJsonExporter tasksJsonExporter;
@Inject Preferences preferences; @Inject Preferences preferences;
@Inject WorkManager workManager; @Inject WorkManager workManager;

@ -4,7 +4,6 @@ import static com.google.common.collect.Iterables.skip;
import static com.google.common.collect.Lists.newArrayList; import static com.google.common.collect.Lists.newArrayList;
import static org.tasks.Strings.isNullOrEmpty; import static org.tasks.Strings.isNullOrEmpty;
import android.app.Application;
import android.content.Context; import android.content.Context;
import android.net.Uri; import android.net.Uri;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@ -23,6 +22,7 @@ import javax.inject.Inject;
import javax.net.ssl.SSLException; import javax.net.ssl.SSLException;
import org.tasks.R; import org.tasks.R;
import org.tasks.drive.DriveInvoker; import org.tasks.drive.DriveInvoker;
import org.tasks.injection.ApplicationContext;
import org.tasks.injection.InjectingWorker; import org.tasks.injection.InjectingWorker;
import org.tasks.injection.JobComponent; import org.tasks.injection.JobComponent;
import org.tasks.preferences.Preferences; import org.tasks.preferences.Preferences;
@ -36,7 +36,7 @@ public class DriveUploader extends InjectingWorker {
private static final Comparator<File> DRIVE_FILE_COMPARATOR = private static final Comparator<File> DRIVE_FILE_COMPARATOR =
(f1, f2) -> Long.compare(f2.getModifiedTime().getValue(), f1.getModifiedTime().getValue()); (f1, f2) -> Long.compare(f2.getModifiedTime().getValue(), f1.getModifiedTime().getValue());
@Inject Application context; @Inject @ApplicationContext Context context;
@Inject DriveInvoker drive; @Inject DriveInvoker drive;
@Inject Preferences preferences; @Inject Preferences preferences;

@ -2,7 +2,6 @@ package org.tasks.jobs
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.app.AlarmManager import android.app.AlarmManager
import android.app.Application
import android.app.PendingIntent import android.app.PendingIntent
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
@ -24,6 +23,7 @@ import org.tasks.data.Place
import org.tasks.date.DateTimeUtils.midnight import org.tasks.date.DateTimeUtils.midnight
import org.tasks.date.DateTimeUtils.newDateTime import org.tasks.date.DateTimeUtils.newDateTime
import org.tasks.injection.ApplicationScope import org.tasks.injection.ApplicationScope
import org.tasks.injection.ApplicationContext
import org.tasks.preferences.Preferences import org.tasks.preferences.Preferences
import org.tasks.time.DateTimeUtils import org.tasks.time.DateTimeUtils
import timber.log.Timber import timber.log.Timber
@ -34,7 +34,7 @@ import kotlin.math.max
@ApplicationScope @ApplicationScope
class WorkManager @Inject constructor( class WorkManager @Inject constructor(
private val context: Application, @param:ApplicationContext private val context: Context,
private val preferences: Preferences, private val preferences: Preferences,
private val googleTaskListDao: GoogleTaskListDao, private val googleTaskListDao: GoogleTaskListDao,
private val caldavDao: CaldavDao) { private val caldavDao: CaldavDao) {

@ -1,12 +1,13 @@
package org.tasks.locale.receiver; package org.tasks.locale.receiver;
import android.app.Application; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import com.todoroo.astrid.api.Filter; import com.todoroo.astrid.api.Filter;
import javax.inject.Inject; import javax.inject.Inject;
import org.tasks.Notifier; import org.tasks.Notifier;
import org.tasks.injection.ApplicationContext;
import org.tasks.injection.InjectingJobIntentService; import org.tasks.injection.InjectingJobIntentService;
import org.tasks.injection.ServiceComponent; import org.tasks.injection.ServiceComponent;
import org.tasks.locale.bundle.ListNotificationBundle; import org.tasks.locale.bundle.ListNotificationBundle;
@ -16,7 +17,7 @@ import timber.log.Timber;
public class TaskerIntentService extends InjectingJobIntentService { public class TaskerIntentService extends InjectingJobIntentService {
@Inject Application context; @Inject @ApplicationContext Context context;
@Inject Notifier notifier; @Inject Notifier notifier;
@Inject DefaultFilterProvider defaultFilterProvider; @Inject DefaultFilterProvider defaultFilterProvider;
@Inject TaskerTaskCreator taskerTaskCreator; @Inject TaskerTaskCreator taskerTaskCreator;

@ -1,15 +1,15 @@
package org.tasks.notifications; package org.tasks.notifications;
import android.app.Application;
import android.content.Context; import android.content.Context;
import javax.inject.Inject; import javax.inject.Inject;
import org.tasks.injection.ApplicationContext;
public class AudioManager { public class AudioManager {
private final android.media.AudioManager audioManager; private final android.media.AudioManager audioManager;
@Inject @Inject
public AudioManager(Application context) { public AudioManager(@ApplicationContext Context context) {
audioManager = (android.media.AudioManager) context.getSystemService(Context.AUDIO_SERVICE); audioManager = (android.media.AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
} }

@ -17,7 +17,6 @@ import static java.util.Collections.singletonList;
import static org.tasks.Strings.isNullOrEmpty; import static org.tasks.Strings.isNullOrEmpty;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Application;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@ -44,6 +43,7 @@ import org.tasks.R;
import org.tasks.data.LocationDao; import org.tasks.data.LocationDao;
import org.tasks.data.Place; import org.tasks.data.Place;
import org.tasks.injection.ApplicationScope; import org.tasks.injection.ApplicationScope;
import org.tasks.injection.ApplicationContext;
import org.tasks.intents.TaskIntents; import org.tasks.intents.TaskIntents;
import org.tasks.preferences.Preferences; import org.tasks.preferences.Preferences;
import org.tasks.receivers.CompleteTaskReceiver; import org.tasks.receivers.CompleteTaskReceiver;
@ -80,7 +80,7 @@ public class NotificationManager {
@Inject @Inject
public NotificationManager( public NotificationManager(
Application context, @ApplicationContext Context context,
Preferences preferences, Preferences preferences,
NotificationDao notificationDao, NotificationDao notificationDao,
TaskDao taskDao, TaskDao taskDao,

@ -1,15 +1,15 @@
package org.tasks.notifications; package org.tasks.notifications;
import android.app.Application;
import android.content.Context; import android.content.Context;
import javax.inject.Inject; import javax.inject.Inject;
import org.tasks.injection.ApplicationContext;
public class TelephonyManager { public class TelephonyManager {
private final android.telephony.TelephonyManager telephonyManager; private final android.telephony.TelephonyManager telephonyManager;
@Inject @Inject
public TelephonyManager(Application context) { public TelephonyManager(@ApplicationContext Context context) {
telephonyManager = telephonyManager =
(android.telephony.TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); (android.telephony.TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
} }

@ -1,6 +1,5 @@
package org.tasks.preferences package org.tasks.preferences
import android.app.Application
import android.content.Context import android.content.Context
import com.todoroo.astrid.api.* import com.todoroo.astrid.api.*
import com.todoroo.astrid.api.Filter import com.todoroo.astrid.api.Filter
@ -10,11 +9,12 @@ import org.tasks.R
import org.tasks.Strings.isNullOrEmpty import org.tasks.Strings.isNullOrEmpty
import org.tasks.data.* import org.tasks.data.*
import org.tasks.filters.PlaceFilter import org.tasks.filters.PlaceFilter
import org.tasks.injection.ApplicationContext
import timber.log.Timber import timber.log.Timber
import javax.inject.Inject import javax.inject.Inject
class DefaultFilterProvider @Inject constructor( class DefaultFilterProvider @Inject constructor(
private val context: Application, @param:ApplicationContext private val context: Context,
private val preferences: Preferences, private val preferences: Preferences,
private val filterDao: FilterDao, private val filterDao: FilterDao,
private val tagDataDao: TagDataDao, private val tagDataDao: TagDataDao,

@ -2,7 +2,6 @@ package org.tasks.preferences;
import static java.util.Arrays.asList; import static java.util.Arrays.asList;
import android.app.Application;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
@ -15,6 +14,7 @@ import java.util.List;
import javax.inject.Inject; import javax.inject.Inject;
import org.tasks.BuildConfig; import org.tasks.BuildConfig;
import org.tasks.R; import org.tasks.R;
import org.tasks.injection.ApplicationContext;
import org.tasks.locale.Locale; import org.tasks.locale.Locale;
import timber.log.Timber; import timber.log.Timber;
@ -24,7 +24,7 @@ public class Device {
private final Locale locale; private final Locale locale;
@Inject @Inject
public Device(Application context, Locale locale) { public Device(@ApplicationContext Context context, Locale locale) {
this.context = context; this.context = context;
this.locale = locale; this.locale = locale;
} }

@ -4,10 +4,10 @@ import static com.todoroo.andlib.utility.AndroidUtilities.atLeastOreo;
import static com.todoroo.andlib.utility.AndroidUtilities.atLeastQ; import static com.todoroo.andlib.utility.AndroidUtilities.atLeastQ;
import android.Manifest.permission; import android.Manifest.permission;
import android.app.Application;
import android.content.Context; import android.content.Context;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import javax.inject.Inject; import javax.inject.Inject;
import org.tasks.injection.ApplicationContext;
import timber.log.Timber; import timber.log.Timber;
public class PermissionChecker { public class PermissionChecker {
@ -15,7 +15,7 @@ public class PermissionChecker {
private final Context context; private final Context context;
@Inject @Inject
PermissionChecker(Application context) { PermissionChecker(@ApplicationContext Context context) {
this.context = context; this.context = context;
} }

@ -1,6 +1,6 @@
package org.tasks.receivers; package org.tasks.receivers;
import android.app.Application; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import com.todoroo.astrid.api.Filter; import com.todoroo.astrid.api.Filter;
@ -8,6 +8,7 @@ import com.todoroo.astrid.dao.TaskDao;
import com.todoroo.astrid.provider.Astrid2TaskProvider; import com.todoroo.astrid.provider.Astrid2TaskProvider;
import javax.inject.Inject; import javax.inject.Inject;
import org.tasks.R; import org.tasks.R;
import org.tasks.injection.ApplicationContext;
import org.tasks.injection.InjectingJobIntentService; import org.tasks.injection.InjectingJobIntentService;
import org.tasks.injection.ServiceComponent; import org.tasks.injection.ServiceComponent;
import org.tasks.preferences.DefaultFilterProvider; import org.tasks.preferences.DefaultFilterProvider;
@ -15,7 +16,7 @@ import org.tasks.preferences.Preferences;
public class RefreshReceiver extends InjectingJobIntentService { public class RefreshReceiver extends InjectingJobIntentService {
@Inject Application context; @Inject @ApplicationContext Context context;
@Inject DefaultFilterProvider defaultFilterProvider; @Inject DefaultFilterProvider defaultFilterProvider;
@Inject TaskDao taskDao; @Inject TaskDao taskDao;
@Inject Preferences preferences; @Inject Preferences preferences;

@ -2,8 +2,8 @@ package org.tasks.reminders;
import static com.todoroo.andlib.utility.DateUtilities.getTimeString; import static com.todoroo.andlib.utility.DateUtilities.getTimeString;
import android.app.Application;
import android.app.Dialog; import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.os.Bundle; import android.os.Bundle;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@ -13,6 +13,7 @@ import javax.inject.Inject;
import org.tasks.R; import org.tasks.R;
import org.tasks.dialogs.DialogBuilder; import org.tasks.dialogs.DialogBuilder;
import org.tasks.injection.DialogFragmentComponent; import org.tasks.injection.DialogFragmentComponent;
import org.tasks.injection.ApplicationContext;
import org.tasks.injection.InjectingDialogFragment; import org.tasks.injection.InjectingDialogFragment;
import org.tasks.preferences.Preferences; import org.tasks.preferences.Preferences;
import org.tasks.time.DateTime; import org.tasks.time.DateTime;
@ -21,7 +22,7 @@ public class SnoozeDialog extends InjectingDialogFragment {
private final List<String> items = new ArrayList<>(); private final List<String> items = new ArrayList<>();
@Inject Preferences preferences; @Inject Preferences preferences;
@Inject Application context; @Inject @ApplicationContext Context context;
@Inject DialogBuilder dialogBuilder; @Inject DialogBuilder dialogBuilder;
private SnoozeCallback snoozeCallback; private SnoozeCallback snoozeCallback;
private DialogInterface.OnCancelListener onCancelListener; private DialogInterface.OnCancelListener onCancelListener;

@ -11,8 +11,8 @@ import static org.tasks.Strings.isNullOrEmpty;
import static org.tasks.repeats.CustomRecurrenceDialog.newCustomRecurrenceDialog; import static org.tasks.repeats.CustomRecurrenceDialog.newCustomRecurrenceDialog;
import static org.tasks.time.DateTimeUtils.currentTimeMillis; import static org.tasks.time.DateTimeUtils.currentTimeMillis;
import android.app.Activity;
import android.app.Dialog; import android.app.Dialog;
import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@ -24,6 +24,7 @@ import javax.inject.Inject;
import org.tasks.R; import org.tasks.R;
import org.tasks.dialogs.DialogBuilder; import org.tasks.dialogs.DialogBuilder;
import org.tasks.injection.DialogFragmentComponent; import org.tasks.injection.DialogFragmentComponent;
import org.tasks.injection.ActivityContext;
import org.tasks.injection.InjectingDialogFragment; import org.tasks.injection.InjectingDialogFragment;
import org.tasks.ui.SingleCheckedArrayAdapter; import org.tasks.ui.SingleCheckedArrayAdapter;
import timber.log.Timber; import timber.log.Timber;
@ -34,7 +35,7 @@ public class BasicRecurrenceDialog extends InjectingDialogFragment {
private static final String EXTRA_DATE = "extra_date"; private static final String EXTRA_DATE = "extra_date";
private static final String FRAG_TAG_CUSTOM_RECURRENCE = "frag_tag_custom_recurrence"; private static final String FRAG_TAG_CUSTOM_RECURRENCE = "frag_tag_custom_recurrence";
@Inject Activity context; @Inject @ActivityContext Context context;
@Inject DialogBuilder dialogBuilder; @Inject DialogBuilder dialogBuilder;
@Inject RepeatRuleToString repeatRuleToString; @Inject RepeatRuleToString repeatRuleToString;

@ -14,6 +14,7 @@ import static org.tasks.time.DateTimeUtils.currentTimeMillis;
import android.app.Activity; import android.app.Activity;
import android.app.Dialog; import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.res.ColorStateList; import android.content.res.ColorStateList;
@ -49,7 +50,6 @@ import com.google.ical.values.WeekdayNum;
import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.astrid.repeats.RepeatControlSet; import com.todoroo.astrid.repeats.RepeatControlSet;
import java.text.DateFormatSymbols; import java.text.DateFormatSymbols;
import java.time.format.FormatStyle;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collections; import java.util.Collections;
@ -59,10 +59,12 @@ import org.tasks.R;
import org.tasks.dialogs.DialogBuilder; import org.tasks.dialogs.DialogBuilder;
import org.tasks.dialogs.MyDatePickerDialog; import org.tasks.dialogs.MyDatePickerDialog;
import org.tasks.injection.DialogFragmentComponent; import org.tasks.injection.DialogFragmentComponent;
import org.tasks.injection.ActivityContext;
import org.tasks.injection.InjectingDialogFragment; import org.tasks.injection.InjectingDialogFragment;
import org.tasks.locale.Locale; import org.tasks.locale.Locale;
import org.tasks.preferences.ResourceResolver; import org.tasks.preferences.ResourceResolver;
import org.tasks.time.DateTime; import org.tasks.time.DateTime;
import java.time.format.FormatStyle;
import timber.log.Timber; import timber.log.Timber;
public class CustomRecurrenceDialog extends InjectingDialogFragment { public class CustomRecurrenceDialog extends InjectingDialogFragment {
@ -74,7 +76,7 @@ public class CustomRecurrenceDialog extends InjectingDialogFragment {
private static final String FRAG_TAG_DATE_PICKER = "frag_tag_date_picker"; private static final String FRAG_TAG_DATE_PICKER = "frag_tag_date_picker";
private static final int REQUEST_PICK_DATE = 505; private static final int REQUEST_PICK_DATE = 505;
private final List<String> repeatUntilOptions = new ArrayList<>(); private final List<String> repeatUntilOptions = new ArrayList<>();
@Inject Activity context; @Inject @ActivityContext Context context;
@Inject DialogBuilder dialogBuilder; @Inject DialogBuilder dialogBuilder;
@Inject Locale locale; @Inject Locale locale;

@ -3,7 +3,6 @@ package org.tasks.repeats;
import static com.google.ical.values.Frequency.MONTHLY; import static com.google.ical.values.Frequency.MONTHLY;
import static com.google.ical.values.Frequency.WEEKLY; import static com.google.ical.values.Frequency.WEEKLY;
import android.app.Application;
import android.content.Context; import android.content.Context;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.ical.values.Frequency; import com.google.ical.values.Frequency;
@ -18,6 +17,7 @@ import java.util.Calendar;
import java.util.List; import java.util.List;
import javax.inject.Inject; import javax.inject.Inject;
import org.tasks.R; import org.tasks.R;
import org.tasks.injection.ApplicationContext;
import org.tasks.locale.Locale; import org.tasks.locale.Locale;
import org.tasks.time.DateTime; import org.tasks.time.DateTime;
@ -28,7 +28,7 @@ public class RepeatRuleToString {
private final List<Weekday> weekdays = Arrays.asList(Weekday.values()); private final List<Weekday> weekdays = Arrays.asList(Weekday.values());
@Inject @Inject
public RepeatRuleToString(Application context, Locale locale) { public RepeatRuleToString(@ApplicationContext Context context, Locale locale) {
this.context = context; this.context = context;
this.locale = locale; this.locale = locale;
} }

@ -1,17 +1,17 @@
package org.tasks.scheduling; package org.tasks.scheduling;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Application;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.content.Context; import android.content.Context;
import javax.inject.Inject; import javax.inject.Inject;
import org.tasks.injection.ApplicationContext;
public class AlarmManager { public class AlarmManager {
private final android.app.AlarmManager alarmManager; private final android.app.AlarmManager alarmManager;
@Inject @Inject
public AlarmManager(Application context) { public AlarmManager(@ApplicationContext Context context) {
alarmManager = (android.app.AlarmManager) context.getSystemService(Context.ALARM_SERVICE); alarmManager = (android.app.AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
} }

@ -1,6 +1,5 @@
package org.tasks.scheduling; package org.tasks.scheduling;
import android.app.Application;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
@ -14,6 +13,7 @@ import javax.inject.Inject;
import org.tasks.R; import org.tasks.R;
import org.tasks.calendars.AndroidCalendarEvent; import org.tasks.calendars.AndroidCalendarEvent;
import org.tasks.calendars.CalendarEventProvider; import org.tasks.calendars.CalendarEventProvider;
import org.tasks.injection.ApplicationContext;
import org.tasks.injection.InjectingJobIntentService; import org.tasks.injection.InjectingJobIntentService;
import org.tasks.injection.ServiceComponent; import org.tasks.injection.ServiceComponent;
import org.tasks.preferences.Preferences; import org.tasks.preferences.Preferences;
@ -26,7 +26,7 @@ public class CalendarNotificationIntentService extends RecurringIntervalIntentSe
private static final String URI_PREFIX = "cal-reminder"; private static final String URI_PREFIX = "cal-reminder";
@Inject Preferences preferences; @Inject Preferences preferences;
@Inject CalendarEventProvider calendarEventProvider; @Inject CalendarEventProvider calendarEventProvider;
@Inject Application context; @Inject @ApplicationContext Context context;
@Inject AlarmManager alarmManager; @Inject AlarmManager alarmManager;
public static void enqueueWork(Context context) { public static void enqueueWork(Context context) {

@ -7,7 +7,6 @@ import static org.tasks.notifications.NotificationManager.NOTIFICATION_CHANNEL_T
import static org.tasks.notifications.NotificationManager.NOTIFICATION_CHANNEL_TIMERS; import static org.tasks.notifications.NotificationManager.NOTIFICATION_CHANNEL_TIMERS;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.Application;
import android.app.NotificationChannel; import android.app.NotificationChannel;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@ -17,6 +16,7 @@ import com.todoroo.astrid.alarms.AlarmService;
import com.todoroo.astrid.reminders.ReminderService; import com.todoroo.astrid.reminders.ReminderService;
import javax.inject.Inject; import javax.inject.Inject;
import org.tasks.R; import org.tasks.R;
import org.tasks.injection.ApplicationContext;
import org.tasks.injection.InjectingJobIntentService; import org.tasks.injection.InjectingJobIntentService;
import org.tasks.injection.ServiceComponent; import org.tasks.injection.ServiceComponent;
import org.tasks.jobs.NotificationQueue; import org.tasks.jobs.NotificationQueue;
@ -27,7 +27,7 @@ public class NotificationSchedulerIntentService extends InjectingJobIntentServic
private static final String EXTRA_CANCEL_EXISTING_NOTIFICATIONS = private static final String EXTRA_CANCEL_EXISTING_NOTIFICATIONS =
"extra_cancel_existing_notifications"; "extra_cancel_existing_notifications";
@Inject Application context; @Inject @ApplicationContext Context context;
@Inject AlarmService alarmService; @Inject AlarmService alarmService;
@Inject ReminderService reminderService; @Inject ReminderService reminderService;
@Inject NotificationQueue notificationQueue; @Inject NotificationQueue notificationQueue;

@ -9,6 +9,7 @@ import com.todoroo.andlib.utility.AndroidUtilities
import com.todoroo.astrid.service.TaskCompleter import com.todoroo.astrid.service.TaskCompleter
import org.tasks.R import org.tasks.R
import org.tasks.dialogs.Linkify import org.tasks.dialogs.Linkify
import org.tasks.injection.ActivityContext
import org.tasks.preferences.Preferences import org.tasks.preferences.Preferences
import org.tasks.preferences.ResourceResolver import org.tasks.preferences.ResourceResolver
import org.tasks.tasklist.TaskViewHolder.ViewHolderCallbacks import org.tasks.tasklist.TaskViewHolder.ViewHolderCallbacks
@ -18,7 +19,7 @@ import java.util.*
import javax.inject.Inject import javax.inject.Inject
class ViewHolderFactory @Inject constructor( class ViewHolderFactory @Inject constructor(
private val context: Activity, @param:ActivityContext private val context: Context,
private val preferences: Preferences, private val preferences: Preferences,
private val chipProvider: ChipProvider, private val chipProvider: ChipProvider,
private val checkBoxProvider: CheckBoxProvider, private val checkBoxProvider: CheckBoxProvider,

@ -1,15 +1,13 @@
package org.tasks.themes package org.tasks.themes
import android.app.Activity
import android.content.Context import android.content.Context
import androidx.annotation.ColorInt import androidx.annotation.ColorInt
import org.tasks.R import org.tasks.R
import org.tasks.injection.ActivityContext
import org.tasks.preferences.Preferences import org.tasks.preferences.Preferences
import javax.inject.Inject import javax.inject.Inject
class ColorProvider constructor(private val context: Context, preferences: Preferences) { class ColorProvider @Inject constructor(@param:ActivityContext private val context: Context, preferences: Preferences) {
@Inject constructor(activity: Activity, preferences: Preferences): this(activity as Context, preferences)
companion object { companion object {
const val BLUE_500 = -14575885 const val BLUE_500 = -14575885

@ -24,6 +24,7 @@ import org.tasks.calendars.CalendarEventProvider
import org.tasks.calendars.CalendarPicker import org.tasks.calendars.CalendarPicker
import org.tasks.calendars.CalendarProvider import org.tasks.calendars.CalendarProvider
import org.tasks.dialogs.DialogBuilder import org.tasks.dialogs.DialogBuilder
import org.tasks.injection.ActivityContext
import org.tasks.injection.FragmentComponent import org.tasks.injection.FragmentComponent
import org.tasks.preferences.FragmentPermissionRequestor import org.tasks.preferences.FragmentPermissionRequestor
import org.tasks.preferences.PermissionChecker import org.tasks.preferences.PermissionChecker
@ -39,7 +40,7 @@ class CalendarControlSet : TaskEditControlFragment() {
@BindView(R.id.calendar_display_which) @BindView(R.id.calendar_display_which)
lateinit var calendar: TextView lateinit var calendar: TextView
@Inject lateinit var activity: Activity @Inject @ActivityContext lateinit var activity: Context
@Inject lateinit var gcalHelper: GCalHelper @Inject lateinit var gcalHelper: GCalHelper
@Inject lateinit var calendarProvider: CalendarProvider @Inject lateinit var calendarProvider: CalendarProvider
@Inject lateinit var preferences: Preferences @Inject lateinit var preferences: Preferences

@ -1,6 +1,5 @@
package org.tasks.ui package org.tasks.ui
import android.app.Activity
import android.content.Context import android.content.Context
import android.graphics.Bitmap import android.graphics.Bitmap
import android.graphics.Canvas import android.graphics.Canvas
@ -8,13 +7,12 @@ import android.graphics.drawable.Drawable
import androidx.annotation.DrawableRes import androidx.annotation.DrawableRes
import com.todoroo.astrid.data.Task import com.todoroo.astrid.data.Task
import org.tasks.R import org.tasks.R
import org.tasks.injection.ActivityContext
import org.tasks.themes.ColorProvider import org.tasks.themes.ColorProvider
import org.tasks.themes.DrawableUtil import org.tasks.themes.DrawableUtil
import javax.inject.Inject import javax.inject.Inject
class CheckBoxProvider constructor(private val context: Context, private val colorProvider: ColorProvider) { class CheckBoxProvider @Inject constructor(@param:ActivityContext private val context: Context, private val colorProvider: ColorProvider) {
@Inject constructor(context: Activity, colorProvider: ColorProvider): this(context as Context, colorProvider)
fun getCheckBox(task: Task) = getCheckBox(task.isCompleted, task.isRecurring, task.priority) fun getCheckBox(task: Task) = getCheckBox(task.isCompleted, task.isRecurring, task.priority)

@ -17,6 +17,7 @@ import org.tasks.R
import org.tasks.date.DateTimeUtils import org.tasks.date.DateTimeUtils
import org.tasks.dialogs.DateTimePicker import org.tasks.dialogs.DateTimePicker
import org.tasks.dialogs.DateTimePicker.Companion.newDateTimePicker import org.tasks.dialogs.DateTimePicker.Companion.newDateTimePicker
import org.tasks.injection.ActivityContext
import org.tasks.injection.FragmentComponent import org.tasks.injection.FragmentComponent
import org.tasks.locale.Locale import org.tasks.locale.Locale
import org.tasks.preferences.Preferences import org.tasks.preferences.Preferences
@ -25,7 +26,7 @@ import java.time.format.FormatStyle
import javax.inject.Inject import javax.inject.Inject
class DeadlineControlSet : TaskEditControlFragment() { class DeadlineControlSet : TaskEditControlFragment() {
@Inject lateinit var activity: Activity @Inject @ActivityContext lateinit var activity: Context
@Inject lateinit var locale: Locale @Inject lateinit var locale: Locale
@Inject lateinit var preferences: Preferences @Inject lateinit var preferences: Preferences

@ -3,11 +3,11 @@ package org.tasks.ui;
import static android.widget.Toast.LENGTH_LONG; import static android.widget.Toast.LENGTH_LONG;
import static org.tasks.Strings.isNullOrEmpty; import static org.tasks.Strings.isNullOrEmpty;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.StringRes; import androidx.annotation.StringRes;
import javax.inject.Inject; import javax.inject.Inject;
import org.tasks.injection.ActivityContext;
import org.tasks.locale.Locale; import org.tasks.locale.Locale;
public class Toaster { public class Toaster {
@ -16,7 +16,7 @@ public class Toaster {
private final Locale locale; private final Locale locale;
@Inject @Inject
public Toaster(Activity context, Locale locale) { public Toaster(@ActivityContext Context context, Locale locale) {
this.context = context; this.context = context;
this.locale = locale; this.locale = locale;
} }

@ -2,7 +2,7 @@ package org.tasks.voice;
import static org.tasks.Strings.isNullOrEmpty; import static org.tasks.Strings.isNullOrEmpty;
import android.app.Application; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.widget.Toast; import android.widget.Toast;
@ -10,12 +10,13 @@ import com.todoroo.astrid.service.TaskCreator;
import javax.inject.Inject; import javax.inject.Inject;
import org.tasks.R; import org.tasks.R;
import org.tasks.injection.ActivityComponent; import org.tasks.injection.ActivityComponent;
import org.tasks.injection.ApplicationContext;
import org.tasks.injection.InjectingAppCompatActivity; import org.tasks.injection.InjectingAppCompatActivity;
public class VoiceCommandActivity extends InjectingAppCompatActivity { public class VoiceCommandActivity extends InjectingAppCompatActivity {
@Inject TaskCreator taskCreator; @Inject TaskCreator taskCreator;
@Inject Application context; @Inject @ApplicationContext Context context;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {

@ -1,11 +1,11 @@
package org.tasks.widget; package org.tasks.widget;
import android.app.Application;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import javax.inject.Inject; import javax.inject.Inject;
import org.tasks.R; import org.tasks.R;
import org.tasks.injection.ApplicationContext;
public class AppWidgetManager { public class AppWidgetManager {
@ -13,7 +13,7 @@ public class AppWidgetManager {
private final Context context; private final Context context;
@Inject @Inject
public AppWidgetManager(Application context) { public AppWidgetManager(@ApplicationContext Context context) {
this.context = context; this.context = context;
appWidgetManager = android.appwidget.AppWidgetManager.getInstance(context); appWidgetManager = android.appwidget.AppWidgetManager.getInstance(context);
} }

@ -4,7 +4,6 @@ import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TASK;
import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP; import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
import android.app.Application;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetManager;
import android.content.Context; import android.content.Context;
@ -20,6 +19,7 @@ import javax.inject.Inject;
import org.tasks.R; import org.tasks.R;
import org.tasks.activities.FilterSelectionActivity; import org.tasks.activities.FilterSelectionActivity;
import org.tasks.injection.BroadcastComponent; import org.tasks.injection.BroadcastComponent;
import org.tasks.injection.ApplicationContext;
import org.tasks.injection.InjectingAppWidgetProvider; import org.tasks.injection.InjectingAppWidgetProvider;
import org.tasks.intents.TaskIntents; import org.tasks.intents.TaskIntents;
import org.tasks.locale.Locale; import org.tasks.locale.Locale;
@ -35,7 +35,7 @@ public class TasksWidget extends InjectingAppWidgetProvider {
@Inject DefaultFilterProvider defaultFilterProvider; @Inject DefaultFilterProvider defaultFilterProvider;
@Inject Locale locale; @Inject Locale locale;
@Inject TaskDao taskDao; @Inject TaskDao taskDao;
@Inject Application context; @Inject @ApplicationContext Context context;
@Override @Override
protected void inject(BroadcastComponent component) { protected void inject(BroadcastComponent component) {

Loading…
Cancel
Save