mirror of https://github.com/tasks/tasks
Convert injection package to Kotlin
parent
c014490fe0
commit
f9246a0674
@ -1,129 +0,0 @@
|
||||
package org.tasks.injection;
|
||||
|
||||
import com.todoroo.astrid.activity.BeastModePreferences;
|
||||
import com.todoroo.astrid.activity.MainActivity;
|
||||
import com.todoroo.astrid.activity.ShareLinkActivity;
|
||||
import com.todoroo.astrid.activity.TaskEditActivity;
|
||||
import com.todoroo.astrid.gcal.CalendarReminderActivity;
|
||||
import com.todoroo.astrid.gtasks.auth.GtasksLoginActivity;
|
||||
import dagger.Subcomponent;
|
||||
import org.tasks.activities.CameraActivity;
|
||||
import org.tasks.activities.DateAndTimePickerActivity;
|
||||
import org.tasks.activities.FilterSelectionActivity;
|
||||
import org.tasks.activities.FilterSettingsActivity;
|
||||
import org.tasks.activities.GoogleTaskListSettingsActivity;
|
||||
import org.tasks.activities.PlaceSettingsActivity;
|
||||
import org.tasks.activities.TagSettingsActivity;
|
||||
import org.tasks.billing.PurchaseActivity;
|
||||
import org.tasks.caldav.CaldavAccountSettingsActivity;
|
||||
import org.tasks.caldav.CaldavCalendarSettingsActivity;
|
||||
import org.tasks.dashclock.DashClockSettings;
|
||||
import org.tasks.drive.DriveLoginActivity;
|
||||
import org.tasks.etesync.EncryptionSettingsActivity;
|
||||
import org.tasks.etesync.EteSyncAccountSettingsActivity;
|
||||
import org.tasks.etesync.EteSyncCalendarSettingsActivity;
|
||||
import org.tasks.locale.ui.activity.TaskerCreateTaskActivity;
|
||||
import org.tasks.locale.ui.activity.TaskerSettingsActivity;
|
||||
import org.tasks.location.LocationPickerActivity;
|
||||
import org.tasks.activities.attribution.AttributionActivity;
|
||||
import org.tasks.preferences.HelpAndFeedback;
|
||||
import org.tasks.preferences.MainPreferences;
|
||||
import org.tasks.preferences.ManageSpaceActivity;
|
||||
import org.tasks.preferences.NotificationPreferences;
|
||||
import org.tasks.preferences.SyncPreferences;
|
||||
import org.tasks.reminders.NotificationActivity;
|
||||
import org.tasks.reminders.SnoozeActivity;
|
||||
import org.tasks.tags.TagPickerActivity;
|
||||
import org.tasks.tags.TagPickerViewModel;
|
||||
import org.tasks.ui.TaskListViewModel;
|
||||
import org.tasks.voice.VoiceCommandActivity;
|
||||
import org.tasks.widget.ShortcutConfigActivity;
|
||||
import org.tasks.widget.WidgetClickActivity;
|
||||
import org.tasks.widget.WidgetConfigActivity;
|
||||
|
||||
@ActivityScope
|
||||
@Subcomponent(modules = {ActivityModule.class, LocationModule.class})
|
||||
public interface ActivityComponent {
|
||||
|
||||
void inject(GtasksLoginActivity gtasksLoginActivity);
|
||||
|
||||
FragmentComponent plus(FragmentModule module);
|
||||
|
||||
DialogFragmentComponent plus(DialogFragmentModule dialogFragmentModule);
|
||||
|
||||
void inject(TaskerSettingsActivity taskerSettingsActivity);
|
||||
|
||||
void inject(DashClockSettings dashClockSettings);
|
||||
|
||||
void inject(CalendarReminderActivity calendarReminderActivity);
|
||||
|
||||
void inject(FilterSettingsActivity filterSettingsActivity);
|
||||
|
||||
void inject(TagSettingsActivity tagSettingsActivity);
|
||||
|
||||
void inject(ShareLinkActivity shareLinkActivity);
|
||||
|
||||
void inject(MainActivity mainActivity);
|
||||
|
||||
void inject(BeastModePreferences beastModePreferences);
|
||||
|
||||
void inject(NotificationActivity notificationActivity);
|
||||
|
||||
void inject(SnoozeActivity snoozeActivity);
|
||||
|
||||
void inject(FilterSelectionActivity filterSelectionActivity);
|
||||
|
||||
void inject(DateAndTimePickerActivity dateAndTimePickerActivity);
|
||||
|
||||
void inject(CameraActivity cameraActivity);
|
||||
|
||||
void inject(VoiceCommandActivity voiceCommandActivity);
|
||||
|
||||
void inject(WidgetConfigActivity widgetConfigActivity);
|
||||
|
||||
void inject(ShortcutConfigActivity shortcutConfigActivity);
|
||||
|
||||
void inject(GoogleTaskListSettingsActivity googleTaskListSettingsActivity);
|
||||
|
||||
void inject(CaldavCalendarSettingsActivity caldavCalendarSettingsActivity);
|
||||
|
||||
void inject(TaskerCreateTaskActivity taskerCreateTaskActivity);
|
||||
|
||||
void inject(TaskListViewModel taskListViewModel);
|
||||
|
||||
void inject(PurchaseActivity purchaseActivity);
|
||||
|
||||
void inject(CaldavAccountSettingsActivity caldavAccountSettingsActivity);
|
||||
|
||||
void inject(EteSyncAccountSettingsActivity eteSyncAccountSettingsActivity);
|
||||
|
||||
void inject(DriveLoginActivity driveLoginActivity);
|
||||
|
||||
void inject(TaskEditActivity taskEditActivity);
|
||||
|
||||
void inject(WidgetClickActivity widgetActivity);
|
||||
|
||||
void inject(LocationPickerActivity locationPickerActivity);
|
||||
|
||||
void inject(AttributionActivity attributionActivity);
|
||||
|
||||
void inject(TagPickerActivity tagPickerActivity);
|
||||
|
||||
void inject(TagPickerViewModel viewModel);
|
||||
|
||||
void inject(EteSyncCalendarSettingsActivity eteSyncCalendarSettingsActivity);
|
||||
|
||||
void inject(EncryptionSettingsActivity encryptionSettingsActivity);
|
||||
|
||||
void inject(MainPreferences mainPreferences);
|
||||
|
||||
void inject(HelpAndFeedback helpAndFeedback);
|
||||
|
||||
void inject(NotificationPreferences notificationPreferences);
|
||||
|
||||
void inject(ManageSpaceActivity manageSpaceActivity);
|
||||
|
||||
void inject(SyncPreferences syncPreferences);
|
||||
|
||||
void inject(PlaceSettingsActivity placeSettingsActivity);
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
package org.tasks.injection
|
||||
|
||||
import com.todoroo.astrid.activity.BeastModePreferences
|
||||
import com.todoroo.astrid.activity.MainActivity
|
||||
import com.todoroo.astrid.activity.ShareLinkActivity
|
||||
import com.todoroo.astrid.activity.TaskEditActivity
|
||||
import com.todoroo.astrid.gcal.CalendarReminderActivity
|
||||
import com.todoroo.astrid.gtasks.auth.GtasksLoginActivity
|
||||
import dagger.Subcomponent
|
||||
import org.tasks.activities.*
|
||||
import org.tasks.activities.attribution.AttributionActivity
|
||||
import org.tasks.billing.PurchaseActivity
|
||||
import org.tasks.caldav.CaldavAccountSettingsActivity
|
||||
import org.tasks.caldav.CaldavCalendarSettingsActivity
|
||||
import org.tasks.dashclock.DashClockSettings
|
||||
import org.tasks.drive.DriveLoginActivity
|
||||
import org.tasks.etesync.EncryptionSettingsActivity
|
||||
import org.tasks.etesync.EteSyncAccountSettingsActivity
|
||||
import org.tasks.etesync.EteSyncCalendarSettingsActivity
|
||||
import org.tasks.locale.ui.activity.TaskerCreateTaskActivity
|
||||
import org.tasks.locale.ui.activity.TaskerSettingsActivity
|
||||
import org.tasks.location.LocationPickerActivity
|
||||
import org.tasks.preferences.*
|
||||
import org.tasks.reminders.NotificationActivity
|
||||
import org.tasks.reminders.SnoozeActivity
|
||||
import org.tasks.tags.TagPickerActivity
|
||||
import org.tasks.tags.TagPickerViewModel
|
||||
import org.tasks.ui.TaskListViewModel
|
||||
import org.tasks.voice.VoiceCommandActivity
|
||||
import org.tasks.widget.ShortcutConfigActivity
|
||||
import org.tasks.widget.WidgetClickActivity
|
||||
import org.tasks.widget.WidgetConfigActivity
|
||||
|
||||
@ActivityScope
|
||||
@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)
|
||||
fun inject(activity: CalendarReminderActivity)
|
||||
fun inject(activity: FilterSettingsActivity)
|
||||
fun inject(activity: TagSettingsActivity)
|
||||
fun inject(activity: ShareLinkActivity)
|
||||
fun inject(activity: MainActivity)
|
||||
fun inject(activity: BeastModePreferences)
|
||||
fun inject(activity: NotificationActivity)
|
||||
fun inject(activity: SnoozeActivity)
|
||||
fun inject(activity: FilterSelectionActivity)
|
||||
fun inject(activity: DateAndTimePickerActivity)
|
||||
fun inject(activity: CameraActivity)
|
||||
fun inject(activity: VoiceCommandActivity)
|
||||
fun inject(activity: WidgetConfigActivity)
|
||||
fun inject(activity: ShortcutConfigActivity)
|
||||
fun inject(activity: GoogleTaskListSettingsActivity)
|
||||
fun inject(activity: CaldavCalendarSettingsActivity)
|
||||
fun inject(activity: TaskerCreateTaskActivity)
|
||||
fun inject(activity: TaskListViewModel)
|
||||
fun inject(activity: PurchaseActivity)
|
||||
fun inject(activity: CaldavAccountSettingsActivity)
|
||||
fun inject(activity: EteSyncAccountSettingsActivity)
|
||||
fun inject(activity: DriveLoginActivity)
|
||||
fun inject(activity: TaskEditActivity)
|
||||
fun inject(activity: WidgetClickActivity)
|
||||
fun inject(activity: LocationPickerActivity)
|
||||
fun inject(activity: AttributionActivity)
|
||||
fun inject(activity: TagPickerActivity)
|
||||
fun inject(activity: TagPickerViewModel)
|
||||
fun inject(activity: EteSyncCalendarSettingsActivity)
|
||||
fun inject(activity: EncryptionSettingsActivity)
|
||||
fun inject(activity: MainPreferences)
|
||||
fun inject(activity: HelpAndFeedback)
|
||||
fun inject(activity: NotificationPreferences)
|
||||
fun inject(activity: ManageSpaceActivity)
|
||||
fun inject(activity: SyncPreferences)
|
||||
fun inject(activity: PlaceSettingsActivity)
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
package org.tasks.injection;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import org.tasks.R;
|
||||
import org.tasks.billing.Inventory;
|
||||
import org.tasks.preferences.Preferences;
|
||||
import org.tasks.themes.ColorProvider;
|
||||
import org.tasks.themes.ThemeAccent;
|
||||
import org.tasks.themes.ThemeBase;
|
||||
import org.tasks.themes.ThemeColor;
|
||||
|
||||
@Module
|
||||
class ActivityModule {
|
||||
|
||||
private final Activity activity;
|
||||
|
||||
public ActivityModule(Activity activity) {
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
@Provides
|
||||
public Activity getActivity() {
|
||||
return activity;
|
||||
}
|
||||
|
||||
@Provides
|
||||
@ForActivity
|
||||
Context getActivityContext() {
|
||||
return activity;
|
||||
}
|
||||
|
||||
@Provides
|
||||
@ActivityScope
|
||||
ThemeBase getThemeBase(Preferences preferences, Inventory inventory) {
|
||||
return ThemeBase.getThemeBase(preferences, inventory, activity.getIntent());
|
||||
}
|
||||
|
||||
@Provides
|
||||
@ActivityScope
|
||||
public ThemeColor getThemeColor(ColorProvider colorProvider, Preferences preferences) {
|
||||
return colorProvider.getThemeColor(preferences.getDefaultThemeColor(), true);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@ActivityScope
|
||||
ThemeAccent getThemeAccent(ColorProvider colorProvider, Preferences preferences) {
|
||||
return colorProvider.getThemeAccent(preferences.getInt(R.string.p_theme_accent, 1));
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package org.tasks.injection
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import org.tasks.R
|
||||
import org.tasks.billing.Inventory
|
||||
import org.tasks.preferences.Preferences
|
||||
import org.tasks.themes.ColorProvider
|
||||
import org.tasks.themes.ThemeAccent
|
||||
import org.tasks.themes.ThemeBase
|
||||
import org.tasks.themes.ThemeColor
|
||||
|
||||
@Module
|
||||
class ActivityModule(@get:Provides val activity: Activity) {
|
||||
|
||||
@get:ForActivity
|
||||
@get:Provides
|
||||
val activityContext: Context
|
||||
get() = activity
|
||||
|
||||
@Provides
|
||||
@ActivityScope
|
||||
fun getThemeBase(preferences: Preferences, inventory: Inventory): ThemeBase
|
||||
= ThemeBase.getThemeBase(preferences, inventory, activity.intent)
|
||||
|
||||
@Provides
|
||||
@ActivityScope
|
||||
fun getThemeColor(colorProvider: ColorProvider, preferences: Preferences): ThemeColor
|
||||
= colorProvider.getThemeColor(preferences.defaultThemeColor, true)
|
||||
|
||||
@Provides
|
||||
@ActivityScope
|
||||
fun getThemeAccent(colorProvider: ColorProvider, preferences: Preferences): ThemeAccent
|
||||
= colorProvider.getThemeAccent(preferences.getInt(R.string.p_theme_accent, 1))
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package org.tasks.injection;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import javax.inject.Scope;
|
||||
|
||||
@Scope
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface ActivityScope {}
|
@ -0,0 +1,7 @@
|
||||
package org.tasks.injection
|
||||
|
||||
import javax.inject.Scope
|
||||
|
||||
@Scope
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
internal annotation class ActivityScope
|
@ -1,28 +0,0 @@
|
||||
package org.tasks.injection;
|
||||
|
||||
import dagger.Component;
|
||||
import org.tasks.Tasks;
|
||||
import org.tasks.backup.TasksBackupAgent;
|
||||
import org.tasks.dashclock.DashClockExtension;
|
||||
import org.tasks.widget.ScrollableWidgetUpdateService;
|
||||
|
||||
@ApplicationScope
|
||||
@Component(modules = {ApplicationModule.class, ProductionModule.class})
|
||||
public interface ApplicationComponent {
|
||||
|
||||
void inject(DashClockExtension dashClockExtension);
|
||||
|
||||
void inject(Tasks tasks);
|
||||
|
||||
void inject(ScrollableWidgetUpdateService scrollableWidgetUpdateService);
|
||||
|
||||
ActivityComponent plus(ActivityModule module);
|
||||
|
||||
BroadcastComponent plus(BroadcastModule module);
|
||||
|
||||
ServiceComponent plus(ServiceModule module);
|
||||
|
||||
JobComponent plus(WorkModule module);
|
||||
|
||||
void inject(TasksBackupAgent tasksBackupAgent);
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package org.tasks.injection
|
||||
|
||||
import dagger.Component
|
||||
import org.tasks.Tasks
|
||||
import org.tasks.backup.TasksBackupAgent
|
||||
import org.tasks.dashclock.DashClockExtension
|
||||
import org.tasks.widget.ScrollableWidgetUpdateService
|
||||
|
||||
@ApplicationScope
|
||||
@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)
|
||||
}
|
@ -1,145 +0,0 @@
|
||||
package org.tasks.injection;
|
||||
|
||||
import android.content.Context;
|
||||
import com.todoroo.astrid.dao.Database;
|
||||
import com.todoroo.astrid.dao.TaskDao;
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import org.tasks.analytics.Firebase;
|
||||
import org.tasks.billing.BillingClient;
|
||||
import org.tasks.billing.BillingClientImpl;
|
||||
import org.tasks.billing.Inventory;
|
||||
import org.tasks.data.AlarmDao;
|
||||
import org.tasks.data.CaldavDao;
|
||||
import org.tasks.data.DeletionDao;
|
||||
import org.tasks.data.FilterDao;
|
||||
import org.tasks.data.GoogleTaskDao;
|
||||
import org.tasks.data.GoogleTaskListDao;
|
||||
import org.tasks.data.LocationDao;
|
||||
import org.tasks.data.TagDao;
|
||||
import org.tasks.data.TagDataDao;
|
||||
import org.tasks.data.TaskAttachmentDao;
|
||||
import org.tasks.data.TaskListMetadataDao;
|
||||
import org.tasks.data.UserActivityDao;
|
||||
import org.tasks.jobs.WorkManager;
|
||||
import org.tasks.locale.Locale;
|
||||
import org.tasks.location.Geocoder;
|
||||
import org.tasks.location.MapboxGeocoder;
|
||||
import org.tasks.notifications.NotificationDao;
|
||||
|
||||
@Module
|
||||
public class ApplicationModule {
|
||||
|
||||
private final Context context;
|
||||
|
||||
public ApplicationModule(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Provides
|
||||
public Locale getLocale() {
|
||||
return Locale.getInstance(context);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@ForApplication
|
||||
public Context getApplicationContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
@Provides
|
||||
@ApplicationScope
|
||||
NotificationDao getNotificationDao(Database database) {
|
||||
return database.notificationDao();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@ApplicationScope
|
||||
TagDataDao getTagDataDao(Database database) {
|
||||
return database.getTagDataDao();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@ApplicationScope
|
||||
UserActivityDao getUserActivityDao(Database database) {
|
||||
return database.getUserActivityDao();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@ApplicationScope
|
||||
TaskAttachmentDao getTaskAttachmentDao(Database database) {
|
||||
return database.getTaskAttachmentDao();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@ApplicationScope
|
||||
TaskListMetadataDao getTaskListMetadataDao(Database database) {
|
||||
return database.getTaskListMetadataDao();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@ApplicationScope
|
||||
GoogleTaskDao getGoogleTaskDao(Database database) {
|
||||
return database.getGoogleTaskDao();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@ApplicationScope
|
||||
AlarmDao getAlarmDao(Database database) {
|
||||
return database.getAlarmDao();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@ApplicationScope
|
||||
LocationDao getGeofenceDao(Database database) {
|
||||
return database.getLocationDao();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@ApplicationScope
|
||||
TagDao getTagDao(Database database) {
|
||||
return database.getTagDao();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@ApplicationScope
|
||||
FilterDao getFilterDao(Database database) {
|
||||
return database.getFilterDao();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@ApplicationScope
|
||||
GoogleTaskListDao getGoogleTaskListDao(Database database) {
|
||||
return database.getGoogleTaskListDao();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@ApplicationScope
|
||||
CaldavDao getCaldavDao(Database database) {
|
||||
return database.getCaldavDao();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@ApplicationScope
|
||||
TaskDao getTaskDao(Database database, WorkManager workManager) {
|
||||
TaskDao taskDao = database.getTaskDao();
|
||||
taskDao.initialize(workManager);
|
||||
return taskDao;
|
||||
}
|
||||
|
||||
@Provides
|
||||
@ApplicationScope
|
||||
DeletionDao getDeletionDao(Database database) {
|
||||
return database.getDeletionDao();
|
||||
}
|
||||
|
||||
@Provides
|
||||
BillingClient getBillingClient(Inventory inventory, Firebase firebase) {
|
||||
return new BillingClientImpl(context, inventory, firebase);
|
||||
}
|
||||
|
||||
@Provides
|
||||
Geocoder getGeocoder(@ForApplication Context context) {
|
||||
return new MapboxGeocoder(context);
|
||||
}
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
package org.tasks.injection
|
||||
|
||||
import android.content.Context
|
||||
import com.todoroo.astrid.dao.Database
|
||||
import com.todoroo.astrid.dao.TaskDao
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import org.tasks.analytics.Firebase
|
||||
import org.tasks.billing.BillingClient
|
||||
import org.tasks.billing.BillingClientImpl
|
||||
import org.tasks.billing.Inventory
|
||||
import org.tasks.data.*
|
||||
import org.tasks.jobs.WorkManager
|
||||
import org.tasks.locale.Locale
|
||||
import org.tasks.location.Geocoder
|
||||
import org.tasks.location.MapboxGeocoder
|
||||
import org.tasks.notifications.NotificationDao
|
||||
|
||||
@Module
|
||||
class ApplicationModule(@get:Provides @get:ForApplication val context: Context) {
|
||||
|
||||
@get:Provides
|
||||
val locale: Locale
|
||||
get() = Locale.getInstance(context)
|
||||
|
||||
@Provides
|
||||
@ApplicationScope
|
||||
fun getNotificationDao(db: Database): NotificationDao = db.notificationDao()
|
||||
|
||||
@Provides
|
||||
@ApplicationScope
|
||||
fun getTagDataDao(db: Database): TagDataDao = db.tagDataDao
|
||||
|
||||
@Provides
|
||||
@ApplicationScope
|
||||
fun getUserActivityDao(db: Database): UserActivityDao = db.userActivityDao
|
||||
|
||||
@Provides
|
||||
@ApplicationScope
|
||||
fun getTaskAttachmentDao(db: Database): TaskAttachmentDao = db.taskAttachmentDao
|
||||
|
||||
@Provides
|
||||
@ApplicationScope
|
||||
fun getTaskListMetadataDao(db: Database): TaskListMetadataDao = db.taskListMetadataDao
|
||||
|
||||
@Provides
|
||||
@ApplicationScope
|
||||
fun getGoogleTaskDao(db: Database): GoogleTaskDao = db.googleTaskDao
|
||||
|
||||
@Provides
|
||||
@ApplicationScope
|
||||
fun getAlarmDao(db: Database): AlarmDao = db.alarmDao
|
||||
|
||||
@Provides
|
||||
@ApplicationScope
|
||||
fun getGeofenceDao(db: Database): LocationDao = db.locationDao
|
||||
|
||||
@Provides
|
||||
@ApplicationScope
|
||||
fun getTagDao(db: Database): TagDao = db.tagDao
|
||||
|
||||
@Provides
|
||||
@ApplicationScope
|
||||
fun getFilterDao(db: Database): FilterDao = db.filterDao
|
||||
|
||||
@Provides
|
||||
@ApplicationScope
|
||||
fun getGoogleTaskListDao(db: Database): GoogleTaskListDao = db.googleTaskListDao
|
||||
|
||||
@Provides
|
||||
@ApplicationScope
|
||||
fun getCaldavDao(db: Database): CaldavDao = db.caldavDao
|
||||
|
||||
@Provides
|
||||
@ApplicationScope
|
||||
fun getTaskDao(db: Database, workManager: WorkManager): TaskDao {
|
||||
val taskDao = db.taskDao
|
||||
taskDao.initialize(workManager)
|
||||
return taskDao
|
||||
}
|
||||
|
||||
@Provides
|
||||
@ApplicationScope
|
||||
fun getDeletionDao(db: Database): DeletionDao = db.deletionDao
|
||||
|
||||
@Provides
|
||||
fun getBillingClient(inventory: Inventory, firebase: Firebase): BillingClient
|
||||
= BillingClientImpl(context, inventory, firebase)
|
||||
|
||||
@get:Provides
|
||||
val geocoder: Geocoder
|
||||
get() = MapboxGeocoder(context)
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package org.tasks.injection;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import javax.inject.Scope;
|
||||
|
||||
@Scope
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface ApplicationScope {}
|
@ -0,0 +1,7 @@
|
||||
package org.tasks.injection
|
||||
|
||||
import javax.inject.Scope
|
||||
|
||||
@Scope
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
annotation class ApplicationScope
|
@ -1,25 +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)
|
||||
public interface BroadcastComponent {
|
||||
|
||||
void inject(CalendarAlarmReceiver calendarAlarmReceiver);
|
||||
|
||||
void inject(MyPackageReplacedReceiver myPackageReplacedReceiver);
|
||||
|
||||
void inject(CompleteTaskReceiver completeTaskReceiver);
|
||||
|
||||
void inject(BootCompletedReceiver bootCompletedReceiver);
|
||||
|
||||
void inject(TasksWidget tasksWidget);
|
||||
|
||||
void inject(NotificationClearedReceiver notificationClearedReceiver);
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
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 {}
|
@ -0,0 +1,6 @@
|
||||
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;
|
||||
|
||||
@ApplicationScope
|
||||
@Component(modules = ContentProviderModule.class)
|
||||
public interface ContentProviderComponent {
|
||||
|
||||
void inject(Astrid2TaskProvider astrid2TaskProvider);
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package org.tasks.injection
|
||||
|
||||
import com.todoroo.astrid.provider.Astrid2TaskProvider
|
||||
import dagger.Component
|
||||
|
||||
@ApplicationScope
|
||||
@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)
|
||||
class ContentProviderModule {}
|
@ -0,0 +1,6 @@
|
||||
package org.tasks.injection
|
||||
|
||||
import dagger.Module
|
||||
|
||||
@Module(includes = [ProductionModule::class])
|
||||
internal class ContentProviderModule
|
@ -1,43 +0,0 @@
|
||||
package org.tasks.injection;
|
||||
|
||||
import android.content.Context;
|
||||
import org.tasks.locale.Locale;
|
||||
import timber.log.Timber;
|
||||
|
||||
class Dagger {
|
||||
|
||||
private static final Object lock = new Object();
|
||||
|
||||
private static Dagger instance;
|
||||
private final ApplicationComponent applicationComponent;
|
||||
|
||||
private Dagger(Context context) {
|
||||
Context localeContext = context.getApplicationContext();
|
||||
try {
|
||||
localeContext = Locale.getInstance(localeContext).createConfigurationContext(localeContext);
|
||||
} catch (Exception e) {
|
||||
Timber.e(e);
|
||||
}
|
||||
|
||||
applicationComponent =
|
||||
DaggerApplicationComponent.builder()
|
||||
.applicationModule(new ApplicationModule(localeContext))
|
||||
.productionModule(new ProductionModule())
|
||||
.build();
|
||||
}
|
||||
|
||||
public static Dagger get(Context context) {
|
||||
if (instance == null) {
|
||||
synchronized (lock) {
|
||||
if (instance == null) {
|
||||
instance = new Dagger(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
ApplicationComponent getApplicationComponent() {
|
||||
return applicationComponent;
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package org.tasks.injection
|
||||
|
||||
import android.content.Context
|
||||
import org.tasks.locale.Locale
|
||||
import timber.log.Timber
|
||||
|
||||
internal class Dagger private constructor(context: Context) {
|
||||
val applicationComponent: ApplicationComponent
|
||||
|
||||
companion object {
|
||||
private val lock = Any()
|
||||
private var instance: Dagger? = null
|
||||
operator fun get(context: Context): Dagger {
|
||||
if (instance == null) {
|
||||
synchronized(lock) {
|
||||
if (instance == null) {
|
||||
instance = Dagger(context)
|
||||
}
|
||||
}
|
||||
}
|
||||
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,67 +0,0 @@
|
||||
package org.tasks.injection;
|
||||
|
||||
import dagger.Subcomponent;
|
||||
import org.tasks.activities.RemoteListPicker;
|
||||
import org.tasks.calendars.CalendarPicker;
|
||||
import org.tasks.dialogs.AddAttachmentDialog;
|
||||
import org.tasks.dialogs.ColorPalettePicker;
|
||||
import org.tasks.dialogs.ColorWheelPicker;
|
||||
import org.tasks.dialogs.DateTimePicker;
|
||||
import org.tasks.dialogs.ExportTasksDialog;
|
||||
import org.tasks.dialogs.GeofenceDialog;
|
||||
import org.tasks.dialogs.IconPickerDialog;
|
||||
import org.tasks.dialogs.ImportTasksDialog;
|
||||
import org.tasks.dialogs.NewFilterDialog;
|
||||
import org.tasks.dialogs.RecordAudioDialog;
|
||||
import org.tasks.dialogs.SortDialog;
|
||||
import org.tasks.dialogs.ThemePickerDialog;
|
||||
import org.tasks.dialogs.WhatsNewDialog;
|
||||
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)
|
||||
public interface DialogFragmentComponent {
|
||||
|
||||
void inject(RemoteListPicker remoteListPicker);
|
||||
|
||||
void inject(NotificationDialog notificationDialog);
|
||||
|
||||
void inject(CalendarPicker calendarPicker);
|
||||
|
||||
void inject(AddAttachmentDialog addAttachmentDialog);
|
||||
|
||||
void inject(SnoozeDialog snoozeDialog);
|
||||
|
||||
void inject(SortDialog sortDialog);
|
||||
|
||||
void inject(RecordAudioDialog recordAudioDialog);
|
||||
|
||||
void inject(CustomRecurrenceDialog customRecurrenceDialog);
|
||||
|
||||
void inject(BasicRecurrenceDialog basicRecurrenceDialog);
|
||||
|
||||
void inject(GeofenceDialog geofenceDialog);
|
||||
|
||||
void inject(IconPickerDialog iconPickerDialog);
|
||||
|
||||
void inject(ExportTasksDialog exportTasksDialog);
|
||||
|
||||
void inject(ImportTasksDialog importTasksDialog);
|
||||
|
||||
void inject(LocalePickerDialog localePickerDialog);
|
||||
|
||||
void inject(ThemePickerDialog themePickerDialog);
|
||||
|
||||
void inject(ColorWheelPicker colorWheelPicker);
|
||||
|
||||
void inject(ColorPalettePicker colorPalettePicker);
|
||||
|
||||
void inject(DateTimePicker dateTimePicker);
|
||||
|
||||
void inject(NewFilterDialog newFilterDialog);
|
||||
|
||||
void inject(WhatsNewDialog whatsNewDialog);
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package org.tasks.injection
|
||||
|
||||
import dagger.Subcomponent
|
||||
import org.tasks.activities.RemoteListPicker
|
||||
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: RemoteListPicker)
|
||||
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,21 +0,0 @@
|
||||
package org.tasks.injection;
|
||||
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
@Module
|
||||
class DialogFragmentModule {
|
||||
|
||||
private final DialogFragment dialogFragment;
|
||||
|
||||
DialogFragmentModule(DialogFragment dialogFragment) {
|
||||
this.dialogFragment = dialogFragment;
|
||||
}
|
||||
|
||||
@Provides
|
||||
public Fragment getFragment() {
|
||||
return dialogFragment;
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
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)
|
@ -1,17 +0,0 @@
|
||||
package org.tasks.injection;
|
||||
|
||||
import static java.lang.annotation.ElementType.FIELD;
|
||||
import static java.lang.annotation.ElementType.METHOD;
|
||||
import static java.lang.annotation.ElementType.PARAMETER;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
import javax.inject.Qualifier;
|
||||
|
||||
@Qualifier
|
||||
@Target({FIELD, PARAMETER, METHOD})
|
||||
@Documented
|
||||
@Retention(RUNTIME)
|
||||
public @interface ForActivity {}
|
@ -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 ForActivity
|
@ -1,17 +0,0 @@
|
||||
package org.tasks.injection;
|
||||
|
||||
import static java.lang.annotation.ElementType.FIELD;
|
||||
import static java.lang.annotation.ElementType.METHOD;
|
||||
import static java.lang.annotation.ElementType.PARAMETER;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
import javax.inject.Qualifier;
|
||||
|
||||
@Qualifier
|
||||
@Target({FIELD, PARAMETER, METHOD})
|
||||
@Documented
|
||||
@Retention(RUNTIME)
|
||||
public @interface ForApplication {}
|
@ -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 ForApplication
|
@ -1,109 +0,0 @@
|
||||
package org.tasks.injection;
|
||||
|
||||
import com.todoroo.astrid.activity.TaskEditFragment;
|
||||
import com.todoroo.astrid.activity.TaskListFragment;
|
||||
import com.todoroo.astrid.files.FilesControlSet;
|
||||
import com.todoroo.astrid.repeats.RepeatControlSet;
|
||||
import com.todoroo.astrid.tags.TagsControlSet;
|
||||
import com.todoroo.astrid.timers.TimerControlSet;
|
||||
import com.todoroo.astrid.ui.HideUntilControlSet;
|
||||
import com.todoroo.astrid.ui.ReminderControlSet;
|
||||
import dagger.Subcomponent;
|
||||
import org.tasks.fragments.CommentBarFragment;
|
||||
import org.tasks.preferences.fragments.Advanced;
|
||||
import org.tasks.preferences.fragments.Backups;
|
||||
import org.tasks.preferences.fragments.DashClock;
|
||||
import org.tasks.preferences.fragments.DateAndTime;
|
||||
import org.tasks.preferences.fragments.Debug;
|
||||
import org.tasks.preferences.fragments.HelpAndFeedback;
|
||||
import org.tasks.preferences.fragments.LookAndFeel;
|
||||
import org.tasks.preferences.fragments.MainSettingsFragment;
|
||||
import org.tasks.preferences.fragments.NavigationDrawer;
|
||||
import org.tasks.preferences.fragments.Notifications;
|
||||
import org.tasks.preferences.fragments.ScrollableWidget;
|
||||
import org.tasks.preferences.fragments.Synchronization;
|
||||
import org.tasks.preferences.fragments.TaskDefaults;
|
||||
import org.tasks.preferences.fragments.TaskerListNotification;
|
||||
import org.tasks.preferences.fragments.Widgets;
|
||||
import org.tasks.ui.CalendarControlSet;
|
||||
import org.tasks.ui.DeadlineControlSet;
|
||||
import org.tasks.ui.DescriptionControlSet;
|
||||
import org.tasks.ui.EmptyTaskEditFragment;
|
||||
import org.tasks.ui.LocationControlSet;
|
||||
import org.tasks.ui.NavigationDrawerFragment;
|
||||
import org.tasks.ui.PriorityControlSet;
|
||||
import org.tasks.ui.RemoteListFragment;
|
||||
import org.tasks.ui.SubtaskControlSet;
|
||||
import org.tasks.ui.TaskListViewModel;
|
||||
|
||||
@Subcomponent(modules = FragmentModule.class)
|
||||
public interface FragmentComponent {
|
||||
|
||||
void inject(TimerControlSet timerControlSet);
|
||||
|
||||
void inject(TaskEditFragment taskEditFragment);
|
||||
|
||||
void inject(NavigationDrawerFragment navigationDrawerFragment);
|
||||
|
||||
void inject(PriorityControlSet priorityControlSet);
|
||||
|
||||
void inject(RepeatControlSet repeatControlSet);
|
||||
|
||||
void inject(CommentBarFragment commentBarFragment);
|
||||
|
||||
void inject(FilesControlSet filesControlSet);
|
||||
|
||||
void inject(TagsControlSet tagsControlSet);
|
||||
|
||||
void inject(HideUntilControlSet hideUntilControlSet);
|
||||
|
||||
void inject(ReminderControlSet reminderControlSet);
|
||||
|
||||
void inject(DeadlineControlSet deadlineControlSet);
|
||||
|
||||
void inject(DescriptionControlSet descriptionControlSet);
|
||||
|
||||
void inject(CalendarControlSet calendarControlSet);
|
||||
|
||||
void inject(TaskListFragment taskListFragment);
|
||||
|
||||
void inject(RemoteListFragment remoteListFragment);
|
||||
|
||||
void inject(LocationControlSet locationControlSet);
|
||||
|
||||
void inject(SubtaskControlSet subtaskControlSet);
|
||||
|
||||
void inject(TaskListViewModel taskListViewModel);
|
||||
|
||||
void inject(HelpAndFeedback helpAndFeedback);
|
||||
|
||||
void inject(LookAndFeel lookAndFeel);
|
||||
|
||||
void inject(Synchronization synchronization);
|
||||
|
||||
void inject(Debug debug);
|
||||
|
||||
void inject(MainSettingsFragment mainSettingsFragment);
|
||||
|
||||
void inject(Backups backups);
|
||||
|
||||
void inject(Advanced advanced);
|
||||
|
||||
void inject(Notifications notifications);
|
||||
|
||||
void inject(TaskDefaults taskDefaults);
|
||||
|
||||
void inject(ScrollableWidget scrollableWidget);
|
||||
|
||||
void inject(DashClock dashClock);
|
||||
|
||||
void inject(TaskerListNotification taskerListNotification);
|
||||
|
||||
void inject(EmptyTaskEditFragment emptyTaskEditFragment);
|
||||
|
||||
void inject(NavigationDrawer navigationDrawer);
|
||||
|
||||
void inject(Widgets widgets);
|
||||
|
||||
void inject(DateAndTime dateAndTime);
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package org.tasks.injection
|
||||
|
||||
import com.todoroo.astrid.activity.TaskEditFragment
|
||||
import com.todoroo.astrid.activity.TaskListFragment
|
||||
import com.todoroo.astrid.files.FilesControlSet
|
||||
import com.todoroo.astrid.repeats.RepeatControlSet
|
||||
import com.todoroo.astrid.tags.TagsControlSet
|
||||
import com.todoroo.astrid.timers.TimerControlSet
|
||||
import com.todoroo.astrid.ui.HideUntilControlSet
|
||||
import com.todoroo.astrid.ui.ReminderControlSet
|
||||
import dagger.Subcomponent
|
||||
import org.tasks.fragments.CommentBarFragment
|
||||
import org.tasks.preferences.fragments.*
|
||||
import org.tasks.ui.*
|
||||
|
||||
@Subcomponent(modules = [FragmentModule::class])
|
||||
interface FragmentComponent {
|
||||
fun inject(fragment: TimerControlSet)
|
||||
fun inject(fragment: TaskEditFragment)
|
||||
fun inject(fragment: NavigationDrawerFragment)
|
||||
fun inject(fragment: PriorityControlSet)
|
||||
fun inject(fragment: RepeatControlSet)
|
||||
fun inject(fragment: CommentBarFragment)
|
||||
fun inject(fragment: FilesControlSet)
|
||||
fun inject(fragment: TagsControlSet)
|
||||
fun inject(fragment: HideUntilControlSet)
|
||||
fun inject(fragment: ReminderControlSet)
|
||||
fun inject(fragment: DeadlineControlSet)
|
||||
fun inject(fragment: DescriptionControlSet)
|
||||
fun inject(fragment: CalendarControlSet)
|
||||
fun inject(fragment: TaskListFragment)
|
||||
fun inject(fragment: RemoteListFragment)
|
||||
fun inject(fragment: LocationControlSet)
|
||||
fun inject(fragment: SubtaskControlSet)
|
||||
fun inject(fragment: TaskListViewModel)
|
||||
fun inject(fragment: HelpAndFeedback)
|
||||
fun inject(fragment: LookAndFeel)
|
||||
fun inject(fragment: Synchronization)
|
||||
fun inject(fragment: Debug)
|
||||
fun inject(fragment: MainSettingsFragment)
|
||||
fun inject(fragment: Backups)
|
||||
fun inject(fragment: Advanced)
|
||||
fun inject(fragment: Notifications)
|
||||
fun inject(fragment: TaskDefaults)
|
||||
fun inject(fragment: ScrollableWidget)
|
||||
fun inject(fragment: DashClock)
|
||||
fun inject(fragment: TaskerListNotification)
|
||||
fun inject(fragment: EmptyTaskEditFragment)
|
||||
fun inject(fragment: NavigationDrawer)
|
||||
fun inject(fragment: Widgets)
|
||||
fun inject(fragment: DateAndTime)
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package org.tasks.injection;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
@Module
|
||||
public class FragmentModule {
|
||||
|
||||
private final Fragment fragment;
|
||||
|
||||
public FragmentModule(Fragment fragment) {
|
||||
this.fragment = fragment;
|
||||
}
|
||||
|
||||
@Provides
|
||||
public Fragment getFragment() {
|
||||
return fragment;
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package org.tasks.injection
|
||||
|
||||
import androidx.fragment.app.Fragment
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
|
||||
@Module
|
||||
class FragmentModule(@get:Provides val fragment: Fragment)
|
@ -1,8 +0,0 @@
|
||||
package org.tasks.injection;
|
||||
|
||||
public interface InjectingActivity {
|
||||
|
||||
void inject(ActivityComponent component);
|
||||
|
||||
ActivityComponent getComponent();
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package org.tasks.injection
|
||||
|
||||
interface InjectingActivity {
|
||||
fun inject(component: ActivityComponent)
|
||||
|
||||
val component: ActivityComponent
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package org.tasks.injection;
|
||||
|
||||
import android.os.Bundle;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import org.tasks.locale.Locale;
|
||||
|
||||
public abstract class InjectingAppCompatActivity extends AppCompatActivity
|
||||
implements InjectingActivity {
|
||||
|
||||
private ActivityComponent activityComponent;
|
||||
|
||||
protected InjectingAppCompatActivity() {
|
||||
Locale.getInstance(this).applyOverrideConfiguration(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
activityComponent =
|
||||
((InjectingApplication) getApplication()).getComponent().plus(new ActivityModule(this));
|
||||
inject(activityComponent);
|
||||
setTitle("");
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivityComponent getComponent() {
|
||||
return activityComponent;
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package org.tasks.injection
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import org.tasks.locale.Locale
|
||||
|
||||
abstract class InjectingAppCompatActivity protected constructor() : AppCompatActivity(), InjectingActivity {
|
||||
override lateinit var component: ActivityComponent
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
component = (application as InjectingApplication).component.plus(ActivityModule(this))
|
||||
inject(component)
|
||||
title = ""
|
||||
super.onCreate(savedInstanceState)
|
||||
}
|
||||
|
||||
init {
|
||||
Locale.getInstance(this).applyOverrideConfiguration(this)
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package org.tasks.injection;
|
||||
|
||||
import android.appwidget.AppWidgetProvider;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
public abstract class InjectingAppWidgetProvider extends AppWidgetProvider {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
inject(
|
||||
((InjectingApplication) context.getApplicationContext())
|
||||
.getComponent()
|
||||
.plus(new BroadcastModule()));
|
||||
|
||||
super.onReceive(context, intent);
|
||||
}
|
||||
|
||||
protected abstract void inject(BroadcastComponent component);
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package org.tasks.injection
|
||||
|
||||
import android.appwidget.AppWidgetProvider
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
|
||||
abstract class InjectingAppWidgetProvider : AppWidgetProvider() {
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
inject(
|
||||
(context.applicationContext as InjectingApplication)
|
||||
.component
|
||||
.plus(BroadcastModule()))
|
||||
super.onReceive(context, intent)
|
||||
}
|
||||
|
||||
protected abstract fun inject(component: BroadcastComponent)
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package org.tasks.injection;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import org.tasks.locale.Locale;
|
||||
|
||||
public abstract class InjectingApplication extends Application {
|
||||
|
||||
private ApplicationComponent applicationComponent;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
Context context = Locale.getInstance(this).createConfigurationContext(getApplicationContext());
|
||||
|
||||
applicationComponent = Dagger.get(context).getApplicationComponent();
|
||||
|
||||
inject(applicationComponent);
|
||||
}
|
||||
|
||||
protected abstract void inject(ApplicationComponent component);
|
||||
|
||||
public ApplicationComponent getComponent() {
|
||||
return applicationComponent;
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package org.tasks.injection
|
||||
|
||||
import android.app.Application
|
||||
import org.tasks.locale.Locale
|
||||
|
||||
abstract class InjectingApplication : Application() {
|
||||
lateinit var component: ApplicationComponent
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
val context = Locale.getInstance(this).createConfigurationContext(applicationContext)
|
||||
component = Dagger.Companion[context].applicationComponent
|
||||
inject(component)
|
||||
}
|
||||
|
||||
protected abstract fun inject(component: ApplicationComponent?)
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package org.tasks.injection;
|
||||
|
||||
import android.app.Activity;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
|
||||
public abstract class InjectingBottomSheetDialogFragment extends BottomSheetDialogFragment {
|
||||
|
||||
private boolean injected;
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
|
||||
if (!injected) {
|
||||
inject(((InjectingActivity) activity).getComponent().plus(new DialogFragmentModule(this)));
|
||||
injected = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void inject(DialogFragmentComponent component);
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package org.tasks.injection
|
||||
|
||||
import android.app.Activity
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
|
||||
abstract class InjectingBottomSheetDialogFragment : BottomSheetDialogFragment() {
|
||||
private var injected = false
|
||||
override fun onAttach(activity: Activity) {
|
||||
super.onAttach(activity)
|
||||
if (!injected) {
|
||||
inject((activity as InjectingActivity).component.plus(DialogFragmentModule(this)))
|
||||
injected = true
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract fun inject(component: DialogFragmentComponent)
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
package org.tasks.injection;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
public abstract class InjectingBroadcastReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
inject(
|
||||
((InjectingApplication) context.getApplicationContext())
|
||||
.getComponent()
|
||||
.plus(new BroadcastModule()));
|
||||
}
|
||||
|
||||
protected abstract void inject(BroadcastComponent component);
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package org.tasks.injection
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
|
||||
abstract class InjectingBroadcastReceiver : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
inject(
|
||||
(context.applicationContext as InjectingApplication)
|
||||
.component
|
||||
.plus(BroadcastModule()))
|
||||
}
|
||||
|
||||
protected abstract fun inject(component: BroadcastComponent)
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package org.tasks.injection;
|
||||
|
||||
import android.content.ContentProvider;
|
||||
import android.content.Context;
|
||||
|
||||
public abstract class InjectingContentProvider extends ContentProvider {
|
||||
|
||||
@Override
|
||||
public boolean onCreate() {
|
||||
Context context = getContext();
|
||||
inject(
|
||||
DaggerContentProviderComponent.builder()
|
||||
.applicationModule(new ApplicationModule(context.getApplicationContext()))
|
||||
.productionModule(new ProductionModule())
|
||||
.contentProviderModule(new ContentProviderModule())
|
||||
.build());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected abstract void inject(ContentProviderComponent component);
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package org.tasks.injection
|
||||
|
||||
import android.content.ContentProvider
|
||||
|
||||
abstract class InjectingContentProvider : ContentProvider() {
|
||||
override fun onCreate(): Boolean {
|
||||
inject(
|
||||
DaggerContentProviderComponent.builder()
|
||||
.applicationModule(ApplicationModule(context!!.applicationContext))
|
||||
.productionModule(ProductionModule())
|
||||
.contentProviderModule(ContentProviderModule())
|
||||
.build())
|
||||
return true
|
||||
}
|
||||
|
||||
protected abstract fun inject(component: ContentProviderComponent)
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package org.tasks.injection;
|
||||
|
||||
import android.app.Activity;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
|
||||
public abstract class InjectingDialogFragment extends DialogFragment {
|
||||
|
||||
private boolean injected;
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
|
||||
if (!injected) {
|
||||
inject(((InjectingActivity) activity).getComponent().plus(new DialogFragmentModule(this)));
|
||||
injected = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void inject(DialogFragmentComponent component);
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package org.tasks.injection
|
||||
|
||||
import android.app.Activity
|
||||
import androidx.fragment.app.DialogFragment
|
||||
|
||||
abstract class InjectingDialogFragment : DialogFragment() {
|
||||
private var injected = false
|
||||
|
||||
override fun onAttach(activity: Activity) {
|
||||
super.onAttach(activity)
|
||||
if (!injected) {
|
||||
inject((activity as InjectingActivity).component.plus(DialogFragmentModule(this)))
|
||||
injected = true
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract fun inject(component: DialogFragmentComponent)
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package org.tasks.injection;
|
||||
|
||||
import android.app.Activity;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
public abstract class InjectingFragment extends Fragment {
|
||||
|
||||
private boolean injected;
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
|
||||
if (!injected) {
|
||||
inject(((InjectingActivity) activity).getComponent().plus(new FragmentModule(this)));
|
||||
injected = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void inject(FragmentComponent component);
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package org.tasks.injection
|
||||
|
||||
import android.app.Activity
|
||||
import androidx.fragment.app.Fragment
|
||||
|
||||
abstract class InjectingFragment : Fragment() {
|
||||
private var injected = false
|
||||
override fun onAttach(activity: Activity) {
|
||||
super.onAttach(activity)
|
||||
if (!injected) {
|
||||
inject((activity as InjectingActivity).component.plus(FragmentModule(this)))
|
||||
injected = true
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract fun inject(component: FragmentComponent)
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
package org.tasks.injection;
|
||||
|
||||
import android.content.Intent;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.app.JobIntentService;
|
||||
import timber.log.Timber;
|
||||
|
||||
public abstract class InjectingJobIntentService extends JobIntentService {
|
||||
|
||||
public static final int JOB_ID_GEOFENCE_TRANSITION = 1081;
|
||||
public static final int JOB_ID_REFRESH_RECEIVER = 1082;
|
||||
public static final int JOB_ID_NOTIFICATION_SCHEDULER = 1084;
|
||||
public static final int JOB_ID_CALENDAR_NOTIFICATION = 1085;
|
||||
public static final int JOB_ID_TASKER = 1086;
|
||||
|
||||
@Override
|
||||
protected final void onHandleWork(@NonNull Intent intent) {
|
||||
inject(
|
||||
((InjectingApplication) getApplication()).getComponent().plus(new ServiceModule()));
|
||||
|
||||
try {
|
||||
doWork(intent);
|
||||
} catch (Exception e) {
|
||||
Timber.e(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void doWork(@NonNull Intent intent);
|
||||
|
||||
protected abstract void inject(ServiceComponent component);
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package org.tasks.injection
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.core.app.JobIntentService
|
||||
import timber.log.Timber
|
||||
|
||||
abstract class InjectingJobIntentService : JobIntentService() {
|
||||
override fun onHandleWork(intent: Intent) {
|
||||
inject(
|
||||
(application as InjectingApplication).component.plus(ServiceModule()))
|
||||
try {
|
||||
doWork(intent)
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e)
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract fun doWork(intent: Intent)
|
||||
protected abstract fun inject(component: ServiceComponent)
|
||||
|
||||
companion object {
|
||||
const val JOB_ID_GEOFENCE_TRANSITION = 1081
|
||||
const val JOB_ID_REFRESH_RECEIVER = 1082
|
||||
const val JOB_ID_NOTIFICATION_SCHEDULER = 1084
|
||||
const val JOB_ID_CALENDAR_NOTIFICATION = 1085
|
||||
const val JOB_ID_TASKER = 1086
|
||||
}
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
package org.tasks.injection;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import io.reactivex.Completable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import javax.inject.Inject;
|
||||
import org.tasks.R;
|
||||
import org.tasks.analytics.Firebase;
|
||||
import org.tasks.notifications.NotificationManager;
|
||||
|
||||
public abstract class InjectingService extends Service {
|
||||
|
||||
@Inject Firebase firebase;
|
||||
|
||||
private CompositeDisposable disposables;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
startForeground();
|
||||
|
||||
disposables = new CompositeDisposable();
|
||||
|
||||
inject(((InjectingApplication) getApplication()).getComponent().plus(new ServiceModule()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
startForeground();
|
||||
|
||||
disposables.add(
|
||||
Completable.fromAction(this::doWork)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(
|
||||
() -> done(startId),
|
||||
t -> {
|
||||
firebase.reportException(t);
|
||||
done(startId);
|
||||
}));
|
||||
|
||||
return Service.START_NOT_STICKY;
|
||||
}
|
||||
|
||||
private void done(int startId) {
|
||||
scheduleNext();
|
||||
stopSelf(startId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
stopForeground(true);
|
||||
|
||||
disposables.dispose();
|
||||
}
|
||||
|
||||
private void startForeground() {
|
||||
startForeground(getNotificationId(), buildNotification());
|
||||
}
|
||||
|
||||
protected abstract int getNotificationId();
|
||||
|
||||
protected abstract int getNotificationBody();
|
||||
|
||||
private Notification buildNotification() {
|
||||
return new NotificationCompat.Builder(
|
||||
this, NotificationManager.NOTIFICATION_CHANNEL_MISCELLANEOUS)
|
||||
.setSound(null)
|
||||
.setSmallIcon(R.drawable.ic_check_white_24dp)
|
||||
.setContentTitle(getString(R.string.app_name))
|
||||
.setContentText(getString(getNotificationBody()))
|
||||
.build();
|
||||
}
|
||||
|
||||
protected void scheduleNext() {
|
||||
|
||||
}
|
||||
|
||||
protected abstract void doWork();
|
||||
|
||||
protected abstract void inject(ServiceComponent component);
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package org.tasks.injection
|
||||
|
||||
import android.app.Notification
|
||||
import android.app.Service
|
||||
import android.content.Intent
|
||||
import androidx.core.app.NotificationCompat
|
||||
import io.reactivex.Completable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import org.tasks.R
|
||||
import org.tasks.analytics.Firebase
|
||||
import org.tasks.notifications.NotificationManager
|
||||
import javax.inject.Inject
|
||||
|
||||
abstract class InjectingService : Service() {
|
||||
@Inject lateinit var firebase: Firebase
|
||||
private var disposables: CompositeDisposable? = null
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
startForeground()
|
||||
disposables = CompositeDisposable()
|
||||
inject((application as InjectingApplication).component.plus(ServiceModule()))
|
||||
}
|
||||
|
||||
override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
|
||||
startForeground()
|
||||
disposables!!.add(
|
||||
Completable.fromAction { doWork() }
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(
|
||||
{ done(startId) }
|
||||
) { t: Throwable? ->
|
||||
firebase!!.reportException(t)
|
||||
done(startId)
|
||||
})
|
||||
return START_NOT_STICKY
|
||||
}
|
||||
|
||||
private fun done(startId: Int) {
|
||||
scheduleNext()
|
||||
stopSelf(startId)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
stopForeground(true)
|
||||
disposables!!.dispose()
|
||||
}
|
||||
|
||||
private fun startForeground() {
|
||||
startForeground(notificationId, buildNotification())
|
||||
}
|
||||
|
||||
protected abstract val notificationId: Int
|
||||
protected abstract val notificationBody: Int
|
||||
|
||||
private fun buildNotification(): Notification {
|
||||
return NotificationCompat.Builder(
|
||||
this, NotificationManager.NOTIFICATION_CHANNEL_MISCELLANEOUS)
|
||||
.setSound(null)
|
||||
.setSmallIcon(R.drawable.ic_check_white_24dp)
|
||||
.setContentTitle(getString(R.string.app_name))
|
||||
.setContentText(getString(notificationBody))
|
||||
.build()
|
||||
}
|
||||
|
||||
protected open fun scheduleNext() {}
|
||||
protected abstract fun doWork()
|
||||
protected abstract fun inject(component: ServiceComponent)
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
package org.tasks.injection;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.work.Worker;
|
||||
import androidx.work.WorkerParameters;
|
||||
import javax.inject.Inject;
|
||||
import org.tasks.analytics.Firebase;
|
||||
import timber.log.Timber;
|
||||
|
||||
public abstract class InjectingWorker extends Worker {
|
||||
|
||||
@Inject protected Firebase firebase;
|
||||
|
||||
public InjectingWorker(@NonNull Context context, @NonNull WorkerParameters workerParams) {
|
||||
super(context, workerParams);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Result doWork() {
|
||||
Timber.d("%s.doWork()", getClass().getSimpleName());
|
||||
JobComponent component =
|
||||
((InjectingApplication) getApplicationContext()).getComponent().plus(new WorkModule());
|
||||
inject(component);
|
||||
try {
|
||||
return run();
|
||||
} catch (Exception e) {
|
||||
firebase.reportException(e);
|
||||
return Result.failure();
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract Result run();
|
||||
|
||||
protected abstract void inject(JobComponent component);
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package org.tasks.injection
|
||||
|
||||
import android.content.Context
|
||||
import androidx.work.Worker
|
||||
import androidx.work.WorkerParameters
|
||||
import org.tasks.analytics.Firebase
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
abstract class InjectingWorker(context: Context, workerParams: WorkerParameters) : Worker(context, workerParams) {
|
||||
@Inject lateinit var firebase: Firebase
|
||||
|
||||
override fun doWork(): Result {
|
||||
Timber.d("%s.doWork()", javaClass.simpleName)
|
||||
val component = (applicationContext as InjectingApplication).component.plus(WorkModule())
|
||||
inject(component)
|
||||
return try {
|
||||
run()
|
||||
} catch (e: Exception) {
|
||||
firebase.reportException(e)
|
||||
Result.failure()
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract fun run(): Result
|
||||
|
||||
protected abstract fun inject(component: JobComponent)
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
package org.tasks.injection;
|
||||
|
||||
import dagger.Subcomponent;
|
||||
import org.tasks.jobs.AfterSaveWork;
|
||||
import org.tasks.jobs.BackupWork;
|
||||
import org.tasks.jobs.CleanupWork;
|
||||
import org.tasks.jobs.DriveUploader;
|
||||
import org.tasks.jobs.MidnightRefreshWork;
|
||||
import org.tasks.jobs.RefreshWork;
|
||||
import org.tasks.jobs.RemoteConfigWork;
|
||||
import org.tasks.jobs.ReverseGeocodeWork;
|
||||
import org.tasks.jobs.SyncWork;
|
||||
|
||||
@Subcomponent(modules = WorkModule.class)
|
||||
public interface JobComponent {
|
||||
|
||||
void inject(SyncWork syncWork);
|
||||
|
||||
void inject(BackupWork backupWork);
|
||||
|
||||
void inject(RefreshWork refreshWork);
|
||||
|
||||
void inject(CleanupWork cleanupWork);
|
||||
|
||||
void inject(MidnightRefreshWork midnightRefreshWork);
|
||||
|
||||
void inject(AfterSaveWork afterSaveWork);
|
||||
|
||||
void inject(DriveUploader driveUploader);
|
||||
|
||||
void inject(ReverseGeocodeWork reverseGeocodeWork);
|
||||
|
||||
void inject(RemoteConfigWork remoteConfigWork);
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
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,26 +0,0 @@
|
||||
package org.tasks.injection;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.room.Room;
|
||||
import com.todoroo.astrid.dao.Database;
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import org.tasks.db.Migrations;
|
||||
import org.tasks.preferences.Preferences;
|
||||
|
||||
@Module(includes = ApplicationModule.class)
|
||||
class ProductionModule {
|
||||
@Provides
|
||||
@ApplicationScope
|
||||
Database getAppDatabase(@ForApplication Context context) {
|
||||
return Room.databaseBuilder(context, Database.class, Database.NAME)
|
||||
.allowMainThreadQueries() // TODO: remove me
|
||||
.addMigrations(Migrations.MIGRATIONS)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Provides
|
||||
Preferences getPreferences(@ForApplication Context context) {
|
||||
return new Preferences(context);
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package org.tasks.injection
|
||||
|
||||
import android.content.Context
|
||||
import androidx.room.Room
|
||||
import com.todoroo.astrid.dao.Database
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import org.tasks.db.Migrations
|
||||
import org.tasks.preferences.Preferences
|
||||
|
||||
@Module(includes = [ApplicationModule::class])
|
||||
internal class ProductionModule {
|
||||
@Provides
|
||||
@ApplicationScope
|
||||
fun getAppDatabase(@ForApplication context: Context): Database {
|
||||
return Room.databaseBuilder(context, Database::class.java, Database.NAME)
|
||||
.allowMainThreadQueries() // TODO: remove me
|
||||
.addMigrations(*Migrations.MIGRATIONS)
|
||||
.build()
|
||||
}
|
||||
|
||||
@Provides
|
||||
fun getPreferences(@ForApplication context: Context): Preferences {
|
||||
return Preferences(context)
|
||||
}
|
||||
}
|
@ -1,25 +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)
|
||||
public interface ServiceComponent {
|
||||
|
||||
void inject(CalendarNotificationIntentService calendarNotificationIntentService);
|
||||
|
||||
void inject(GeofenceTransitionsIntentService geofenceTransitionsIntentService);
|
||||
|
||||
void inject(NotificationSchedulerIntentService notificationSchedulerIntentService);
|
||||
|
||||
void inject(TaskerIntentService taskerIntentService);
|
||||
|
||||
void inject(NotificationService notificationService);
|
||||
|
||||
void inject(RefreshReceiver refreshReceiver);
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
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 {}
|
@ -0,0 +1,6 @@
|
||||
package org.tasks.injection
|
||||
|
||||
import dagger.Module
|
||||
|
||||
@Module
|
||||
class ServiceModule
|
@ -1,36 +0,0 @@
|
||||
package org.tasks.injection;
|
||||
|
||||
import android.os.Bundle;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import javax.inject.Inject;
|
||||
import org.tasks.locale.Locale;
|
||||
import org.tasks.themes.Theme;
|
||||
import org.tasks.themes.ThemeColor;
|
||||
|
||||
public abstract class ThemedInjectingAppCompatActivity extends AppCompatActivity
|
||||
implements InjectingActivity {
|
||||
|
||||
@Inject protected Theme theme;
|
||||
@Inject protected ThemeColor themeColor;
|
||||
|
||||
private ActivityComponent activityComponent;
|
||||
|
||||
protected ThemedInjectingAppCompatActivity() {
|
||||
Locale.getInstance(this).applyOverrideConfiguration(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
activityComponent =
|
||||
((InjectingApplication) getApplication()).getComponent().plus(new ActivityModule(this));
|
||||
inject(activityComponent);
|
||||
setTitle(null);
|
||||
theme.applyThemeAndStatusBarColor(this);
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivityComponent getComponent() {
|
||||
return activityComponent;
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package org.tasks.injection
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import org.tasks.locale.Locale
|
||||
import org.tasks.themes.Theme
|
||||
import org.tasks.themes.ThemeColor
|
||||
import javax.inject.Inject
|
||||
|
||||
abstract class ThemedInjectingAppCompatActivity protected constructor() : AppCompatActivity(), InjectingActivity {
|
||||
@Inject lateinit var tasksTheme: Theme
|
||||
@Inject protected lateinit var themeColor: ThemeColor
|
||||
|
||||
override lateinit var component: ActivityComponent
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
component = (application as InjectingApplication).component.plus(ActivityModule(this))
|
||||
inject(component)
|
||||
title = null
|
||||
tasksTheme.applyThemeAndStatusBarColor(this)
|
||||
super.onCreate(savedInstanceState)
|
||||
}
|
||||
|
||||
init {
|
||||
Locale.getInstance(this).applyOverrideConfiguration(this)
|
||||
}
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
package org.tasks.injection;
|
||||
|
||||
import dagger.Module;
|
||||
|
||||
@Module
|
||||
class WorkModule {}
|
@ -0,0 +1,6 @@
|
||||
package org.tasks.injection
|
||||
|
||||
import dagger.Module
|
||||
|
||||
@Module
|
||||
class WorkModule
|
Loading…
Reference in New Issue