Remove empty Dagger components

pull/1020/head
Alex Baker 4 years ago
parent b1e0ab6d67
commit cde5bcfb87

@ -10,8 +10,8 @@ import com.todoroo.astrid.reminders.ReminderService
import org.tasks.Notifier
import org.tasks.data.LocationDao
import org.tasks.data.Place
import org.tasks.injection.ApplicationComponent
import org.tasks.injection.InjectingJobIntentService
import org.tasks.injection.ServiceComponent
import org.tasks.notifications.Notification
import org.tasks.time.DateTimeUtils
import timber.log.Timber
@ -69,7 +69,7 @@ class GeofenceTransitionsIntentService : InjectingJobIntentService() {
return notification
}
override fun inject(component: ServiceComponent) = component.inject(this)
override fun inject(component: ApplicationComponent) = component.inject(this)
class Broadcast : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {

@ -14,7 +14,7 @@ import org.tasks.calendars.AndroidCalendarEvent;
import org.tasks.calendars.AndroidCalendarEventAttendee;
import org.tasks.calendars.CalendarEventProvider;
import org.tasks.gtasks.GoogleAccountManager;
import org.tasks.injection.BroadcastComponent;
import org.tasks.injection.ApplicationComponent;
import org.tasks.injection.InjectingBroadcastReceiver;
import org.tasks.preferences.Preferences;
import org.tasks.scheduling.CalendarNotificationIntentService;
@ -64,7 +64,7 @@ public class CalendarAlarmReceiver extends InjectingBroadcastReceiver {
}
@Override
protected void inject(BroadcastComponent component) {
protected void inject(ApplicationComponent component) {
component.inject(this);
}

@ -28,7 +28,7 @@ import org.tasks.R;
import org.tasks.data.TagDao;
import org.tasks.data.TagData;
import org.tasks.data.TagDataDao;
import org.tasks.injection.ContentProviderComponent;
import org.tasks.injection.ApplicationComponent;
import org.tasks.injection.InjectingContentProvider;
import timber.log.Timber;
@ -115,7 +115,7 @@ public class Astrid2TaskProvider extends InjectingContentProvider {
}
@Override
protected void inject(ContentProviderComponent component) {
protected void inject(ApplicationComponent component) {
component.inject(this);
}

@ -21,7 +21,7 @@ import io.reactivex.schedulers.Schedulers
import org.tasks.LocalBroadcastManager
import org.tasks.dialogs.DialogBuilder
import org.tasks.filters.FilterProvider
import org.tasks.injection.DialogFragmentComponent
import org.tasks.injection.FragmentComponent
import org.tasks.injection.InjectingDialogFragment
import javax.inject.Inject
@ -63,7 +63,7 @@ class ListPicker : InjectingDialogFragment() {
filterAdapter.save(outState)
}
override fun inject(component: DialogFragmentComponent) = component.inject(this)
override fun inject(component: FragmentComponent) = component.inject(this)
private fun selectedList(list: Filter) {
targetFragment!!.onActivityResult(

@ -18,7 +18,7 @@ import java.util.List;
import javax.inject.Inject;
import org.tasks.R;
import org.tasks.dialogs.DialogBuilder;
import org.tasks.injection.DialogFragmentComponent;
import org.tasks.injection.FragmentComponent;
import org.tasks.injection.InjectingDialogFragment;
import org.tasks.preferences.FragmentPermissionRequestor;
import org.tasks.preferences.PermissionChecker;
@ -126,7 +126,7 @@ public class CalendarPicker extends InjectingDialogFragment {
}
@Override
protected void inject(DialogFragmentComponent component) {
protected void inject(FragmentComponent component) {
component.inject(this);
}
}

@ -15,8 +15,8 @@ import java.util.List;
import javax.inject.Inject;
import org.tasks.R;
import org.tasks.activities.CameraActivity;
import org.tasks.injection.DialogFragmentComponent;
import org.tasks.injection.ActivityContext;
import org.tasks.injection.FragmentComponent;
import org.tasks.injection.InjectingDialogFragment;
import org.tasks.preferences.Device;
@ -38,7 +38,7 @@ public class AddAttachmentDialog extends InjectingDialogFragment {
}
@Override
protected void inject(DialogFragmentComponent component) {
protected void inject(FragmentComponent component) {
component.inject(this);
}

@ -17,7 +17,7 @@ import org.tasks.billing.Inventory
import org.tasks.billing.PurchaseActivity
import org.tasks.dialogs.ColorPickerAdapter.Palette
import org.tasks.dialogs.ColorWheelPicker.Companion.newColorWheel
import org.tasks.injection.DialogFragmentComponent
import org.tasks.injection.FragmentComponent
import org.tasks.injection.InjectingDialogFragment
import org.tasks.themes.ColorProvider
import org.tasks.themes.ThemeColor
@ -134,5 +134,5 @@ class ColorPalettePicker : InjectingDialogFragment() {
}
}
override fun inject(component: DialogFragmentComponent) = component.inject(this)
override fun inject(component: FragmentComponent) = component.inject(this)
}

@ -14,7 +14,7 @@ import com.flask.colorpicker.builder.ColorPickerDialogBuilder
import org.tasks.R
import org.tasks.billing.Inventory
import org.tasks.billing.PurchaseActivity
import org.tasks.injection.DialogFragmentComponent
import org.tasks.injection.FragmentComponent
import org.tasks.injection.InjectingDialogFragment
import org.tasks.ui.NavigationDrawerFragment.Companion.REQUEST_PURCHASE
import javax.inject.Inject
@ -46,7 +46,7 @@ class ColorWheelPicker : InjectingDialogFragment() {
var selected = -1
var callback: ColorPickedCallback? = null
override fun inject(component: DialogFragmentComponent) = component.inject(this)
override fun inject(component: FragmentComponent) = component.inject(this)
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
selected = savedInstanceState?.getInt(EXTRA_SELECTED) ?: requireArguments().getInt(EXTRA_SELECTED, 0)

@ -25,7 +25,7 @@ import org.tasks.R
import org.tasks.databinding.DialogDateTimePickerBinding
import org.tasks.date.DateTimeUtils.newDateTime
import org.tasks.dialogs.MyTimePickerDialog.newTimePicker
import org.tasks.injection.DialogFragmentComponent
import org.tasks.injection.FragmentComponent
import org.tasks.injection.InjectingBottomSheetDialogFragment
import org.tasks.locale.Locale
import org.tasks.notifications.NotificationManager
@ -325,5 +325,5 @@ class DateTimePicker : InjectingBottomSheetDialogFragment() {
}
}
override fun inject(component: DialogFragmentComponent) = component.inject(this)
override fun inject(component: FragmentComponent) = component.inject(this)
}

@ -6,7 +6,7 @@ import android.os.Bundle;
import androidx.annotation.NonNull;
import javax.inject.Inject;
import org.tasks.backup.TasksJsonExporter;
import org.tasks.injection.DialogFragmentComponent;
import org.tasks.injection.FragmentComponent;
import org.tasks.injection.InjectingDialogFragment;
public class ExportTasksDialog extends InjectingDialogFragment {
@ -35,7 +35,7 @@ public class ExportTasksDialog extends InjectingDialogFragment {
}
@Override
protected void inject(DialogFragmentComponent component) {
protected void inject(FragmentComponent component) {
component.inject(this);
}
}

@ -20,8 +20,8 @@ import javax.inject.Inject;
import org.tasks.R;
import org.tasks.data.Geofence;
import org.tasks.data.Location;
import org.tasks.injection.DialogFragmentComponent;
import org.tasks.injection.ActivityContext;
import org.tasks.injection.FragmentComponent;
import org.tasks.injection.InjectingDialogFragment;
import org.tasks.locale.Locale;
import org.tasks.preferences.PermissionChecker;
@ -125,7 +125,7 @@ public class GeofenceDialog extends InjectingDialogFragment {
}
@Override
protected void inject(DialogFragmentComponent component) {
protected void inject(FragmentComponent component) {
component.inject(this);
}
}

@ -17,8 +17,8 @@ import javax.inject.Inject;
import org.tasks.R;
import org.tasks.billing.Inventory;
import org.tasks.billing.PurchaseActivity;
import org.tasks.injection.DialogFragmentComponent;
import org.tasks.injection.ActivityContext;
import org.tasks.injection.FragmentComponent;
import org.tasks.injection.InjectingDialogFragment;
import org.tasks.themes.CustomIcons;
@ -82,7 +82,7 @@ public class IconPickerDialog extends InjectingDialogFragment {
}
@Override
protected void inject(DialogFragmentComponent component) {
protected void inject(FragmentComponent component) {
component.inject(this);
}

@ -14,8 +14,8 @@ import javax.inject.Inject;
import org.tasks.R;
import org.tasks.backup.TasksJsonImporter;
import org.tasks.backup.TasksJsonImporter.ImportResult;
import org.tasks.injection.DialogFragmentComponent;
import org.tasks.injection.ActivityContext;
import org.tasks.injection.FragmentComponent;
import org.tasks.injection.InjectingDialogFragment;
import org.tasks.ui.Toaster;
@ -92,7 +92,7 @@ public class ImportTasksDialog extends InjectingDialogFragment {
}
@Override
protected void inject(DialogFragmentComponent component) {
protected void inject(FragmentComponent component) {
component.inject(this);
}
}

@ -9,7 +9,7 @@ import com.todoroo.astrid.core.CriterionInstance.*
import org.tasks.R
import org.tasks.activities.FilterSettingsActivity
import org.tasks.filters.FilterCriteriaProvider
import org.tasks.injection.DialogFragmentComponent
import org.tasks.injection.FragmentComponent
import org.tasks.injection.InjectingDialogFragment
import org.tasks.ui.NavigationDrawerFragment
import javax.inject.Inject
@ -133,5 +133,5 @@ class NewFilterDialog : InjectingDialogFragment() {
return criterion
}
override fun inject(component: DialogFragmentComponent) = component.inject(this)
override fun inject(component: FragmentComponent) = component.inject(this)
}

@ -22,7 +22,7 @@ import com.todoroo.astrid.voice.AACRecorder;
import java.io.IOException;
import javax.inject.Inject;
import org.tasks.R;
import org.tasks.injection.DialogFragmentComponent;
import org.tasks.injection.FragmentComponent;
import org.tasks.injection.InjectingDialogFragment;
import org.tasks.preferences.FragmentPermissionRequestor;
import org.tasks.preferences.PermissionChecker;
@ -96,7 +96,7 @@ public class RecordAudioDialog extends InjectingDialogFragment
}
@Override
protected void inject(DialogFragmentComponent component) {
protected void inject(FragmentComponent component) {
component.inject(this);
}

@ -13,7 +13,7 @@ import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import org.tasks.R;
import org.tasks.injection.DialogFragmentComponent;
import org.tasks.injection.FragmentComponent;
import org.tasks.injection.InjectingDialogFragment;
import org.tasks.preferences.Preferences;
import timber.log.Timber;
@ -181,7 +181,7 @@ public class SortDialog extends InjectingDialogFragment {
}
@Override
protected void inject(DialogFragmentComponent component) {
protected void inject(FragmentComponent component) {
component.inject(this);
}

@ -15,7 +15,7 @@ import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.Fragment
import org.tasks.R
import org.tasks.billing.Inventory
import org.tasks.injection.DialogFragmentComponent
import org.tasks.injection.FragmentComponent
import org.tasks.injection.InjectingDialogFragment
import org.tasks.themes.ThemeAccent
import org.tasks.themes.ThemeBase
@ -53,7 +53,7 @@ class ThemePickerDialog : InjectingDialogFragment() {
var dialog: AlertDialog? = null
var selected = -1
override fun inject(component: DialogFragmentComponent) = component.inject(this)
override fun inject(component: FragmentComponent) = component.inject(this)
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
selected = savedInstanceState?.getInt(EXTRA_SELECTED) ?: requireArguments().getInt(EXTRA_SELECTED)

@ -17,7 +17,7 @@ import org.tasks.R
import org.tasks.analytics.Firebase
import org.tasks.billing.Inventory
import org.tasks.billing.PurchaseActivity
import org.tasks.injection.DialogFragmentComponent
import org.tasks.injection.FragmentComponent
import org.tasks.injection.InjectingDialogFragment
import org.tasks.preferences.Preferences
import javax.inject.Inject
@ -123,5 +123,5 @@ class WhatsNewDialog : InjectingDialogFragment() {
Pair(R.string.param_user_no_churn, firebase.noChurn()))
}
override fun inject(component: DialogFragmentComponent) = component.inject(this)
override fun inject(component: FragmentComponent) = component.inject(this)
}

@ -36,7 +36,6 @@ import org.tasks.widget.WidgetConfigActivity
@Subcomponent(modules = [ActivityModule::class, LocationModule::class])
interface ActivityComponent {
operator fun plus(module: FragmentModule): FragmentComponent
operator fun plus(dialogFragmentModule: DialogFragmentModule): DialogFragmentComponent
fun inject(activity: GtasksLoginActivity)
fun inject(activity: TaskerSettingsActivity)
fun inject(activity: DashClockSettings)

@ -1,21 +1,57 @@
package org.tasks.injection
import com.todoroo.astrid.gcal.CalendarAlarmReceiver
import com.todoroo.astrid.provider.Astrid2TaskProvider
import dagger.Component
import org.tasks.Tasks
import org.tasks.backup.TasksBackupAgent
import org.tasks.dashclock.DashClockExtension
import org.tasks.jobs.*
import org.tasks.locale.receiver.TaskerIntentService
import org.tasks.location.GeofenceTransitionsIntentService
import org.tasks.notifications.NotificationClearedReceiver
import org.tasks.receivers.BootCompletedReceiver
import org.tasks.receivers.CompleteTaskReceiver
import org.tasks.receivers.MyPackageReplacedReceiver
import org.tasks.receivers.RefreshReceiver
import org.tasks.scheduling.CalendarNotificationIntentService
import org.tasks.scheduling.NotificationSchedulerIntentService
import org.tasks.widget.ScrollableWidgetUpdateService
import org.tasks.widget.TasksWidget
import javax.inject.Singleton
@Singleton
@Component(modules = [ApplicationModule::class, ProductionModule::class])
interface ApplicationComponent {
operator fun plus(module: ActivityModule): ActivityComponent
operator fun plus(module: BroadcastModule): BroadcastComponent
operator fun plus(module: ServiceModule): ServiceComponent
operator fun plus(module: WorkModule): JobComponent
fun inject(dashClockExtension: DashClockExtension)
fun inject(tasks: Tasks)
fun inject(scrollableWidgetUpdateService: ScrollableWidgetUpdateService)
fun inject(tasksBackupAgent: TasksBackupAgent)
fun inject(broadcastReceiver: CalendarAlarmReceiver)
fun inject(broadcastReceiver: MyPackageReplacedReceiver)
fun inject(broadcastReceiver: CompleteTaskReceiver)
fun inject(broadcastReceiver: BootCompletedReceiver)
fun inject(broadcastReceiver: TasksWidget)
fun inject(broadcastReceiver: NotificationClearedReceiver)
fun inject(contentProvider: Astrid2TaskProvider)
fun inject(service: CalendarNotificationIntentService)
fun inject(service: GeofenceTransitionsIntentService)
fun inject(service: NotificationSchedulerIntentService)
fun inject(service: TaskerIntentService)
fun inject(service: NotificationService)
fun inject(service: RefreshReceiver)
fun inject(work: SyncWork)
fun inject(work: BackupWork)
fun inject(work: RefreshWork)
fun inject(work: CleanupWork)
fun inject(work: MidnightRefreshWork)
fun inject(work: AfterSaveWork)
fun inject(work: DriveUploader)
fun inject(work: ReverseGeocodeWork)
fun inject(work: RemoteConfigWork)
}

@ -1,19 +0,0 @@
package org.tasks.injection
import com.todoroo.astrid.gcal.CalendarAlarmReceiver
import dagger.Subcomponent
import org.tasks.notifications.NotificationClearedReceiver
import org.tasks.receivers.BootCompletedReceiver
import org.tasks.receivers.CompleteTaskReceiver
import org.tasks.receivers.MyPackageReplacedReceiver
import org.tasks.widget.TasksWidget
@Subcomponent(modules = [BroadcastModule::class])
interface BroadcastComponent {
fun inject(broadcastReceiver: CalendarAlarmReceiver)
fun inject(broadcastReceiver: MyPackageReplacedReceiver)
fun inject(broadcastReceiver: CompleteTaskReceiver)
fun inject(broadcastReceiver: BootCompletedReceiver)
fun inject(broadcastReceiver: TasksWidget)
fun inject(broadcastReceiver: NotificationClearedReceiver)
}

@ -1,6 +0,0 @@
package org.tasks.injection
import dagger.Module
@Module
class BroadcastModule

@ -1,11 +0,0 @@
package org.tasks.injection
import com.todoroo.astrid.provider.Astrid2TaskProvider
import dagger.Component
import javax.inject.Singleton
@Singleton
@Component(modules = [ContentProviderModule::class])
interface ContentProviderComponent {
fun inject(contentProvider: Astrid2TaskProvider)
}

@ -1,6 +0,0 @@
package org.tasks.injection
import dagger.Module
@Module(includes = [ProductionModule::class])
internal class ContentProviderModule

@ -1,35 +0,0 @@
package org.tasks.injection
import dagger.Subcomponent
import org.tasks.activities.ListPicker
import org.tasks.calendars.CalendarPicker
import org.tasks.dialogs.*
import org.tasks.locale.LocalePickerDialog
import org.tasks.reminders.NotificationDialog
import org.tasks.reminders.SnoozeDialog
import org.tasks.repeats.BasicRecurrenceDialog
import org.tasks.repeats.CustomRecurrenceDialog
@Subcomponent(modules = [DialogFragmentModule::class])
interface DialogFragmentComponent {
fun inject(dialogFragment: ListPicker)
fun inject(dialogFragment: NotificationDialog)
fun inject(dialogFragment: CalendarPicker)
fun inject(dialogFragment: AddAttachmentDialog)
fun inject(dialogFragment: SnoozeDialog)
fun inject(dialogFragment: SortDialog)
fun inject(dialogFragment: RecordAudioDialog)
fun inject(dialogFragment: CustomRecurrenceDialog)
fun inject(dialogFragment: BasicRecurrenceDialog)
fun inject(dialogFragment: GeofenceDialog)
fun inject(dialogFragment: IconPickerDialog)
fun inject(dialogFragment: ExportTasksDialog)
fun inject(dialogFragment: ImportTasksDialog)
fun inject(dialogFragment: LocalePickerDialog)
fun inject(dialogFragment: ThemePickerDialog)
fun inject(dialogFragment: ColorWheelPicker)
fun inject(dialogFragment: ColorPalettePicker)
fun inject(dialogFragment: DateTimePicker)
fun inject(dialogFragment: NewFilterDialog)
fun inject(dialogFragment: WhatsNewDialog)
}

@ -1,8 +0,0 @@
package org.tasks.injection
import androidx.fragment.app.Fragment
import dagger.Module
import dagger.Provides
@Module
class DialogFragmentModule internal constructor(@get:Provides val fragment: Fragment)

@ -9,8 +9,16 @@ import com.todoroo.astrid.timers.TimerControlSet
import com.todoroo.astrid.ui.HideUntilControlSet
import com.todoroo.astrid.ui.ReminderControlSet
import dagger.Subcomponent
import org.tasks.activities.ListPicker
import org.tasks.calendars.CalendarPicker
import org.tasks.dialogs.*
import org.tasks.fragments.CommentBarFragment
import org.tasks.locale.LocalePickerDialog
import org.tasks.preferences.fragments.*
import org.tasks.reminders.NotificationDialog
import org.tasks.reminders.SnoozeDialog
import org.tasks.repeats.BasicRecurrenceDialog
import org.tasks.repeats.CustomRecurrenceDialog
import org.tasks.ui.*
@Subcomponent(modules = [FragmentModule::class])
@ -49,4 +57,25 @@ interface FragmentComponent {
fun inject(fragment: NavigationDrawer)
fun inject(fragment: Widgets)
fun inject(fragment: DateAndTime)
fun inject(dialogFragment: ListPicker)
fun inject(dialogFragment: NotificationDialog)
fun inject(dialogFragment: CalendarPicker)
fun inject(dialogFragment: AddAttachmentDialog)
fun inject(dialogFragment: SnoozeDialog)
fun inject(dialogFragment: SortDialog)
fun inject(dialogFragment: RecordAudioDialog)
fun inject(dialogFragment: CustomRecurrenceDialog)
fun inject(dialogFragment: BasicRecurrenceDialog)
fun inject(dialogFragment: GeofenceDialog)
fun inject(dialogFragment: IconPickerDialog)
fun inject(dialogFragment: ExportTasksDialog)
fun inject(dialogFragment: ImportTasksDialog)
fun inject(dialogFragment: LocalePickerDialog)
fun inject(dialogFragment: ThemePickerDialog)
fun inject(dialogFragment: ColorWheelPicker)
fun inject(dialogFragment: ColorPalettePicker)
fun inject(dialogFragment: DateTimePicker)
fun inject(dialogFragment: NewFilterDialog)
fun inject(dialogFragment: WhatsNewDialog)
}

@ -6,12 +6,9 @@ import android.content.Intent
abstract class InjectingAppWidgetProvider : AppWidgetProvider() {
override fun onReceive(context: Context, intent: Intent) {
inject(
(context.applicationContext as InjectingApplication)
.component
.plus(BroadcastModule()))
inject((context.applicationContext as InjectingApplication).component)
super.onReceive(context, intent)
}
protected abstract fun inject(component: BroadcastComponent)
protected abstract fun inject(component: ApplicationComponent)
}

@ -8,10 +8,10 @@ abstract class InjectingBottomSheetDialogFragment : BottomSheetDialogFragment()
override fun onAttach(activity: Activity) {
super.onAttach(activity)
if (!injected) {
inject((activity as InjectingActivity).component.plus(DialogFragmentModule(this)))
inject((activity as InjectingActivity).component.plus(FragmentModule(this)))
injected = true
}
}
protected abstract fun inject(component: DialogFragmentComponent)
protected abstract fun inject(component: FragmentComponent)
}

@ -6,11 +6,8 @@ import android.content.Intent
abstract class InjectingBroadcastReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
inject(
(context.applicationContext as InjectingApplication)
.component
.plus(BroadcastModule()))
inject((context.applicationContext as InjectingApplication).component)
}
protected abstract fun inject(component: BroadcastComponent)
protected abstract fun inject(component: ApplicationComponent)
}

@ -4,14 +4,9 @@ import android.content.ContentProvider
abstract class InjectingContentProvider : ContentProvider() {
override fun onCreate(): Boolean {
inject(
DaggerContentProviderComponent.builder()
.applicationModule(ApplicationModule(context!!.applicationContext))
.productionModule(ProductionModule())
.contentProviderModule(ContentProviderModule())
.build())
inject(Dagger.Companion[context!!].applicationComponent)
return true
}
protected abstract fun inject(component: ContentProviderComponent)
protected abstract fun inject(component: ApplicationComponent)
}

@ -9,10 +9,10 @@ abstract class InjectingDialogFragment : DialogFragment() {
override fun onAttach(activity: Activity) {
super.onAttach(activity)
if (!injected) {
inject((activity as InjectingActivity).component.plus(DialogFragmentModule(this)))
inject((activity as InjectingActivity).component.plus(FragmentModule(this)))
injected = true
}
}
protected abstract fun inject(component: DialogFragmentComponent)
protected abstract fun inject(component: FragmentComponent)
}

@ -7,7 +7,7 @@ import timber.log.Timber
abstract class InjectingJobIntentService : JobIntentService() {
override fun onHandleWork(intent: Intent) {
inject(
(application as InjectingApplication).component.plus(ServiceModule()))
(application as InjectingApplication).component)
try {
doWork(intent)
} catch (e: Exception) {
@ -16,7 +16,7 @@ abstract class InjectingJobIntentService : JobIntentService() {
}
protected abstract fun doWork(intent: Intent)
protected abstract fun inject(component: ServiceComponent)
protected abstract fun inject(component: ApplicationComponent)
companion object {
const val JOB_ID_GEOFENCE_TRANSITION = 1081

@ -21,7 +21,7 @@ abstract class InjectingService : Service() {
super.onCreate()
startForeground()
disposables = CompositeDisposable()
inject((application as InjectingApplication).component.plus(ServiceModule()))
inject((application as InjectingApplication).component)
}
override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
@ -67,5 +67,5 @@ abstract class InjectingService : Service() {
protected open fun scheduleNext() {}
protected abstract fun doWork()
protected abstract fun inject(component: ServiceComponent)
protected abstract fun inject(component: ApplicationComponent)
}

@ -12,8 +12,7 @@ abstract class InjectingWorker(context: Context, workerParams: WorkerParameters)
override fun doWork(): Result {
Timber.d("%s.doWork()", javaClass.simpleName)
val component = (applicationContext as InjectingApplication).component.plus(WorkModule())
inject(component)
inject((applicationContext as InjectingApplication).component)
return try {
run()
} catch (e: Exception) {
@ -24,5 +23,5 @@ abstract class InjectingWorker(context: Context, workerParams: WorkerParameters)
protected abstract fun run(): Result
protected abstract fun inject(component: JobComponent)
protected abstract fun inject(component: ApplicationComponent)
}

@ -1,17 +0,0 @@
package org.tasks.injection
import dagger.Subcomponent
import org.tasks.jobs.*
@Subcomponent(modules = [WorkModule::class])
interface JobComponent {
fun inject(work: SyncWork)
fun inject(work: BackupWork)
fun inject(work: RefreshWork)
fun inject(work: CleanupWork)
fun inject(work: MidnightRefreshWork)
fun inject(work: AfterSaveWork)
fun inject(work: DriveUploader)
fun inject(work: ReverseGeocodeWork)
fun inject(work: RemoteConfigWork)
}

@ -1,19 +0,0 @@
package org.tasks.injection
import dagger.Subcomponent
import org.tasks.jobs.NotificationService
import org.tasks.locale.receiver.TaskerIntentService
import org.tasks.location.GeofenceTransitionsIntentService
import org.tasks.receivers.RefreshReceiver
import org.tasks.scheduling.CalendarNotificationIntentService
import org.tasks.scheduling.NotificationSchedulerIntentService
@Subcomponent(modules = [ServiceModule::class])
interface ServiceComponent {
fun inject(service: CalendarNotificationIntentService)
fun inject(service: GeofenceTransitionsIntentService)
fun inject(service: NotificationSchedulerIntentService)
fun inject(service: TaskerIntentService)
fun inject(service: NotificationService)
fun inject(service: RefreshReceiver)
}

@ -1,6 +0,0 @@
package org.tasks.injection
import dagger.Module
@Module
class ServiceModule

@ -1,6 +0,0 @@
package org.tasks.injection
import dagger.Module
@Module
class WorkModule

@ -24,9 +24,9 @@ import org.tasks.LocalBroadcastManager;
import org.tasks.R;
import org.tasks.data.CaldavAccount;
import org.tasks.data.CaldavDao;
import org.tasks.injection.ApplicationComponent;
import org.tasks.injection.ApplicationContext;
import org.tasks.injection.InjectingWorker;
import org.tasks.injection.JobComponent;
import org.tasks.location.GeofenceApi;
import org.tasks.notifications.NotificationManager;
import org.tasks.scheduling.RefreshScheduler;
@ -146,7 +146,7 @@ public class AfterSaveWork extends InjectingWorker {
}
@Override
protected void inject(JobComponent component) {
protected void inject(ApplicationComponent component) {
component.inject(this);
}
}

@ -22,8 +22,8 @@ import java.util.List;
import javax.inject.Inject;
import org.tasks.R;
import org.tasks.backup.TasksJsonExporter;
import org.tasks.injection.ApplicationComponent;
import org.tasks.injection.ApplicationContext;
import org.tasks.injection.JobComponent;
import org.tasks.preferences.Preferences;
import timber.log.Timber;
@ -80,7 +80,7 @@ public class BackupWork extends RepeatingWorker {
}
@Override
protected void inject(JobComponent component) {
protected void inject(ApplicationComponent component) {
component.inject(this);
}

@ -15,8 +15,8 @@ import org.tasks.data.TaskAttachmentDao;
import org.tasks.data.UserActivity;
import org.tasks.data.UserActivityDao;
import org.tasks.files.FileHelper;
import org.tasks.injection.ApplicationComponent;
import org.tasks.injection.InjectingWorker;
import org.tasks.injection.JobComponent;
import org.tasks.location.GeofenceApi;
import org.tasks.notifications.NotificationManager;
import timber.log.Timber;
@ -71,7 +71,7 @@ public class CleanupWork extends InjectingWorker {
}
@Override
protected void inject(JobComponent component) {
protected void inject(ApplicationComponent component) {
component.inject(this);
}
}

@ -22,9 +22,9 @@ import javax.inject.Inject;
import javax.net.ssl.SSLException;
import org.tasks.R;
import org.tasks.drive.DriveInvoker;
import org.tasks.injection.ApplicationComponent;
import org.tasks.injection.ApplicationContext;
import org.tasks.injection.InjectingWorker;
import org.tasks.injection.JobComponent;
import org.tasks.preferences.Preferences;
import timber.log.Timber;
@ -107,7 +107,7 @@ public class DriveUploader extends InjectingWorker {
}
@Override
protected void inject(JobComponent component) {
protected void inject(ApplicationComponent component) {
component.inject(this);
}
}

@ -5,7 +5,7 @@ import androidx.annotation.NonNull;
import androidx.work.WorkerParameters;
import javax.inject.Inject;
import org.tasks.LocalBroadcastManager;
import org.tasks.injection.JobComponent;
import org.tasks.injection.ApplicationComponent;
public class MidnightRefreshWork extends RepeatingWorker {
@ -28,7 +28,7 @@ public class MidnightRefreshWork extends RepeatingWorker {
}
@Override
protected void inject(JobComponent component) {
protected void inject(ApplicationComponent component) {
component.inject(this);
}
}

@ -10,8 +10,8 @@ import java.util.List;
import javax.inject.Inject;
import org.tasks.Notifier;
import org.tasks.R;
import org.tasks.injection.ApplicationComponent;
import org.tasks.injection.InjectingService;
import org.tasks.injection.ServiceComponent;
import org.tasks.preferences.Preferences;
public class NotificationService extends InjectingService {
@ -55,7 +55,7 @@ public class NotificationService extends InjectingService {
}
@Override
protected void inject(ServiceComponent component) {
protected void inject(ApplicationComponent component) {
component.inject(this);
}
}

@ -5,7 +5,7 @@ import androidx.annotation.NonNull;
import androidx.work.WorkerParameters;
import javax.inject.Inject;
import org.tasks.LocalBroadcastManager;
import org.tasks.injection.JobComponent;
import org.tasks.injection.ApplicationComponent;
import org.tasks.scheduling.RefreshScheduler;
public class RefreshWork extends RepeatingWorker {
@ -25,7 +25,7 @@ public class RefreshWork extends RepeatingWorker {
}
@Override
protected void inject(JobComponent component) {
protected void inject(ApplicationComponent component) {
component.inject(this);
}

@ -2,8 +2,8 @@ package org.tasks.jobs
import android.content.Context
import androidx.work.WorkerParameters
import org.tasks.injection.ApplicationComponent
import org.tasks.injection.InjectingWorker
import org.tasks.injection.JobComponent
class RemoteConfigWork(context: Context, workerParams: WorkerParameters) : InjectingWorker(context, workerParams) {
override fun run(): Result {
@ -11,5 +11,5 @@ class RemoteConfigWork(context: Context, workerParams: WorkerParameters) : Injec
return Result.success()
}
override fun inject(component: JobComponent) = component.inject(this)
override fun inject(component: ApplicationComponent) = component.inject(this)
}

@ -4,8 +4,8 @@ import android.content.Context
import androidx.work.WorkerParameters
import org.tasks.LocalBroadcastManager
import org.tasks.data.LocationDao
import org.tasks.injection.ApplicationComponent
import org.tasks.injection.InjectingWorker
import org.tasks.injection.JobComponent
import org.tasks.location.Geocoder
import timber.log.Timber
import java.io.IOException
@ -46,5 +46,5 @@ class ReverseGeocodeWork(context: Context, workerParams: WorkerParameters) : Inj
}
}
override fun inject(component: JobComponent) = component.inject(this)
override fun inject(component: ApplicationComponent) = component.inject(this)
}

@ -17,8 +17,8 @@ import org.tasks.data.GoogleTaskAccount;
import org.tasks.data.GoogleTaskListDao;
import org.tasks.etesync.EteSynchronizer;
import org.tasks.gtasks.GoogleTaskSynchronizer;
import org.tasks.injection.ApplicationComponent;
import org.tasks.injection.InjectingWorker;
import org.tasks.injection.JobComponent;
import org.tasks.preferences.Preferences;
import org.tasks.sync.SyncAdapters;
@ -88,7 +88,7 @@ public class SyncWork extends InjectingWorker {
}
@Override
protected void inject(JobComponent component) {
protected void inject(ApplicationComponent component) {
component.inject(this);
}
}

@ -6,7 +6,7 @@ import android.content.Intent
import android.os.Bundle
import org.tasks.R
import org.tasks.dialogs.DialogBuilder
import org.tasks.injection.DialogFragmentComponent
import org.tasks.injection.FragmentComponent
import org.tasks.injection.InjectingDialogFragment
import java.util.*
import javax.inject.Inject
@ -34,7 +34,7 @@ class LocalePickerDialog : InjectingDialogFragment() {
.show()
}
override fun inject(component: DialogFragmentComponent) = component.inject(this)
override fun inject(component: FragmentComponent) = component.inject(this)
companion object {
const val EXTRA_LOCALE = "extra_locale"

@ -7,9 +7,9 @@ import androidx.annotation.NonNull;
import com.todoroo.astrid.api.Filter;
import javax.inject.Inject;
import org.tasks.Notifier;
import org.tasks.injection.ApplicationComponent;
import org.tasks.injection.ApplicationContext;
import org.tasks.injection.InjectingJobIntentService;
import org.tasks.injection.ServiceComponent;
import org.tasks.locale.bundle.ListNotificationBundle;
import org.tasks.locale.bundle.TaskCreationBundle;
import org.tasks.preferences.DefaultFilterProvider;
@ -44,7 +44,7 @@ public class TaskerIntentService extends InjectingJobIntentService {
}
@Override
protected void inject(ServiceComponent component) {
protected void inject(ApplicationComponent component) {
component.inject(this);
}
}

@ -3,7 +3,7 @@ package org.tasks.notifications;
import android.content.Context;
import android.content.Intent;
import javax.inject.Inject;
import org.tasks.injection.BroadcastComponent;
import org.tasks.injection.ApplicationComponent;
import org.tasks.injection.InjectingBroadcastReceiver;
import timber.log.Timber;
@ -21,7 +21,7 @@ public class NotificationClearedReceiver extends InjectingBroadcastReceiver {
}
@Override
protected void inject(BroadcastComponent component) {
protected void inject(ApplicationComponent component) {
component.inject(this);
}
}

@ -2,7 +2,7 @@ package org.tasks.receivers;
import android.content.Context;
import android.content.Intent;
import org.tasks.injection.BroadcastComponent;
import org.tasks.injection.ApplicationComponent;
import org.tasks.injection.InjectingBroadcastReceiver;
import timber.log.Timber;
@ -20,7 +20,7 @@ public class BootCompletedReceiver extends InjectingBroadcastReceiver {
}
@Override
protected void inject(BroadcastComponent component) {
protected void inject(ApplicationComponent component) {
component.inject(this);
}
}

@ -6,7 +6,7 @@ import com.todoroo.astrid.service.TaskCompleter;
import io.reactivex.Completable;
import io.reactivex.schedulers.Schedulers;
import javax.inject.Inject;
import org.tasks.injection.BroadcastComponent;
import org.tasks.injection.ApplicationComponent;
import org.tasks.injection.InjectingBroadcastReceiver;
import timber.log.Timber;
@ -28,7 +28,7 @@ public class CompleteTaskReceiver extends InjectingBroadcastReceiver {
}
@Override
protected void inject(BroadcastComponent component) {
protected void inject(ApplicationComponent component) {
component.inject(this);
}
}

@ -2,7 +2,7 @@ package org.tasks.receivers;
import android.content.Context;
import android.content.Intent;
import org.tasks.injection.BroadcastComponent;
import org.tasks.injection.ApplicationComponent;
import org.tasks.injection.InjectingBroadcastReceiver;
import timber.log.Timber;
@ -20,7 +20,7 @@ public class MyPackageReplacedReceiver extends InjectingBroadcastReceiver {
}
@Override
protected void inject(BroadcastComponent component) {
protected void inject(ApplicationComponent component) {
component.inject(this);
}
}

@ -8,9 +8,9 @@ import com.todoroo.astrid.dao.TaskDao;
import com.todoroo.astrid.provider.Astrid2TaskProvider;
import javax.inject.Inject;
import org.tasks.R;
import org.tasks.injection.ApplicationComponent;
import org.tasks.injection.ApplicationContext;
import org.tasks.injection.InjectingJobIntentService;
import org.tasks.injection.ServiceComponent;
import org.tasks.preferences.DefaultFilterProvider;
import org.tasks.preferences.Preferences;
@ -32,7 +32,7 @@ public class RefreshReceiver extends InjectingJobIntentService {
}
@Override
protected void inject(ServiceComponent component) {
protected void inject(ApplicationComponent component) {
component.inject(this);
}
}

@ -10,7 +10,7 @@ import java.util.List;
import javax.inject.Inject;
import org.tasks.R;
import org.tasks.dialogs.DialogBuilder;
import org.tasks.injection.DialogFragmentComponent;
import org.tasks.injection.FragmentComponent;
import org.tasks.injection.InjectingDialogFragment;
public class NotificationDialog extends InjectingDialogFragment {
@ -20,7 +20,7 @@ public class NotificationDialog extends InjectingDialogFragment {
private NotificationHandler handler;
@Override
protected void inject(DialogFragmentComponent component) {
protected void inject(FragmentComponent component) {
component.inject(this);
}

@ -12,8 +12,8 @@ import java.util.List;
import javax.inject.Inject;
import org.tasks.R;
import org.tasks.dialogs.DialogBuilder;
import org.tasks.injection.DialogFragmentComponent;
import org.tasks.injection.ApplicationContext;
import org.tasks.injection.FragmentComponent;
import org.tasks.injection.InjectingDialogFragment;
import org.tasks.preferences.Preferences;
import org.tasks.time.DateTime;
@ -143,7 +143,7 @@ public class SnoozeDialog extends InjectingDialogFragment {
}
@Override
protected void inject(DialogFragmentComponent component) {
protected void inject(FragmentComponent component) {
component.inject(this);
}
}

@ -23,8 +23,8 @@ import java.util.List;
import javax.inject.Inject;
import org.tasks.R;
import org.tasks.dialogs.DialogBuilder;
import org.tasks.injection.DialogFragmentComponent;
import org.tasks.injection.ActivityContext;
import org.tasks.injection.FragmentComponent;
import org.tasks.injection.InjectingDialogFragment;
import org.tasks.ui.SingleCheckedArrayAdapter;
import timber.log.Timber;
@ -160,7 +160,7 @@ public class BasicRecurrenceDialog extends InjectingDialogFragment {
}
@Override
protected void inject(DialogFragmentComponent component) {
protected void inject(FragmentComponent component) {
component.inject(this);
}
}

@ -50,6 +50,7 @@ import com.google.ical.values.WeekdayNum;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.astrid.repeats.RepeatControlSet;
import java.text.DateFormatSymbols;
import java.time.format.FormatStyle;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
@ -58,13 +59,12 @@ import javax.inject.Inject;
import org.tasks.R;
import org.tasks.dialogs.DialogBuilder;
import org.tasks.dialogs.MyDatePickerDialog;
import org.tasks.injection.DialogFragmentComponent;
import org.tasks.injection.ActivityContext;
import org.tasks.injection.FragmentComponent;
import org.tasks.injection.InjectingDialogFragment;
import org.tasks.locale.Locale;
import org.tasks.preferences.ResourceResolver;
import org.tasks.time.DateTime;
import java.time.format.FormatStyle;
import timber.log.Timber;
public class CustomRecurrenceDialog extends InjectingDialogFragment {
@ -553,7 +553,7 @@ public class CustomRecurrenceDialog extends InjectingDialogFragment {
}
@Override
protected void inject(DialogFragmentComponent component) {
protected void inject(FragmentComponent component) {
component.inject(this);
}
}

@ -13,9 +13,9 @@ import javax.inject.Inject;
import org.tasks.R;
import org.tasks.calendars.AndroidCalendarEvent;
import org.tasks.calendars.CalendarEventProvider;
import org.tasks.injection.ApplicationComponent;
import org.tasks.injection.ApplicationContext;
import org.tasks.injection.InjectingJobIntentService;
import org.tasks.injection.ServiceComponent;
import org.tasks.preferences.Preferences;
import timber.log.Timber;
@ -73,7 +73,7 @@ public class CalendarNotificationIntentService extends RecurringIntervalIntentSe
}
@Override
protected void inject(ServiceComponent component) {
protected void inject(ApplicationComponent component) {
component.inject(this);
}

@ -16,9 +16,9 @@ import com.todoroo.astrid.alarms.AlarmService;
import com.todoroo.astrid.reminders.ReminderService;
import javax.inject.Inject;
import org.tasks.R;
import org.tasks.injection.ApplicationComponent;
import org.tasks.injection.ApplicationContext;
import org.tasks.injection.InjectingJobIntentService;
import org.tasks.injection.ServiceComponent;
import org.tasks.jobs.NotificationQueue;
import org.tasks.notifications.NotificationManager;
import timber.log.Timber;
@ -94,7 +94,7 @@ public class NotificationSchedulerIntentService extends InjectingJobIntentServic
}
@Override
protected void inject(ServiceComponent component) {
protected void inject(ApplicationComponent component) {
component.inject(this);
}
}

@ -18,7 +18,7 @@ import com.todoroo.astrid.dao.TaskDao;
import javax.inject.Inject;
import org.tasks.R;
import org.tasks.activities.FilterSelectionActivity;
import org.tasks.injection.BroadcastComponent;
import org.tasks.injection.ApplicationComponent;
import org.tasks.injection.ApplicationContext;
import org.tasks.injection.InjectingAppWidgetProvider;
import org.tasks.intents.TaskIntents;
@ -38,7 +38,7 @@ public class TasksWidget extends InjectingAppWidgetProvider {
@Inject @ApplicationContext Context context;
@Override
protected void inject(BroadcastComponent component) {
protected void inject(ApplicationComponent component) {
component.inject(this);
}

Loading…
Cancel
Save