diff --git a/app/src/main/java/fr/free/nrw/commons/di/ActivityBuilderModule.java b/app/src/main/java/fr/free/nrw/commons/di/ActivityBuilderModule.java deleted file mode 100644 index 4516d806f..000000000 --- a/app/src/main/java/fr/free/nrw/commons/di/ActivityBuilderModule.java +++ /dev/null @@ -1,90 +0,0 @@ -package fr.free.nrw.commons.di; - -import dagger.Module; -import dagger.android.ContributesAndroidInjector; -import fr.free.nrw.commons.AboutActivity; -import fr.free.nrw.commons.LocationPicker.LocationPickerActivity; -import fr.free.nrw.commons.WelcomeActivity; -import fr.free.nrw.commons.auth.LoginActivity; -import fr.free.nrw.commons.auth.SignupActivity; -import fr.free.nrw.commons.category.CategoryDetailsActivity; -import fr.free.nrw.commons.contributions.MainActivity; -import fr.free.nrw.commons.customselector.ui.selector.CustomSelectorActivity; -import fr.free.nrw.commons.description.DescriptionEditActivity; -import fr.free.nrw.commons.explore.depictions.WikidataItemDetailsActivity; -import fr.free.nrw.commons.explore.SearchActivity; -import fr.free.nrw.commons.media.ZoomableActivity; -import fr.free.nrw.commons.nearby.WikidataFeedback; -import fr.free.nrw.commons.notification.NotificationActivity; -import fr.free.nrw.commons.profile.ProfileActivity; -import fr.free.nrw.commons.review.ReviewActivity; -import fr.free.nrw.commons.settings.SettingsActivity; -import fr.free.nrw.commons.upload.UploadActivity; -import fr.free.nrw.commons.upload.UploadProgressActivity; - -/** - * This Class handles the dependency injection (using dagger) - * so, if a developer needs to add a new activity to the commons app - * then that must be mentioned here to inject the dependencies - */ -@Module -@SuppressWarnings({"WeakerAccess", "unused"}) -public abstract class ActivityBuilderModule { - - @ContributesAndroidInjector - abstract LoginActivity bindLoginActivity(); - - @ContributesAndroidInjector - abstract WelcomeActivity bindWelcomeActivity(); - - @ContributesAndroidInjector - abstract MainActivity bindContributionsActivity(); - - @ContributesAndroidInjector - abstract CustomSelectorActivity bindCustomSelectorActivity(); - - @ContributesAndroidInjector - abstract SettingsActivity bindSettingsActivity(); - - @ContributesAndroidInjector - abstract AboutActivity bindAboutActivity(); - - @ContributesAndroidInjector - abstract LocationPickerActivity bindLocationPickerActivity(); - - @ContributesAndroidInjector - abstract SignupActivity bindSignupActivity(); - - @ContributesAndroidInjector - abstract NotificationActivity bindNotificationActivity(); - - @ContributesAndroidInjector - abstract UploadActivity bindUploadActivity(); - - @ContributesAndroidInjector - abstract SearchActivity bindSearchActivity(); - - @ContributesAndroidInjector - abstract CategoryDetailsActivity bindCategoryDetailsActivity(); - - @ContributesAndroidInjector - abstract WikidataItemDetailsActivity bindDepictionDetailsActivity(); - - @ContributesAndroidInjector - abstract ProfileActivity bindAchievementsActivity(); - - @ContributesAndroidInjector - abstract ReviewActivity bindReviewActivity(); - - @ContributesAndroidInjector - abstract DescriptionEditActivity bindDescriptionEditActivity(); - - @ContributesAndroidInjector - abstract ZoomableActivity bindZoomableActivity(); - - @ContributesAndroidInjector - abstract UploadProgressActivity bindUploadProgressActivity(); - - @ContributesAndroidInjector - abstract WikidataFeedback bindWikiFeedback(); -} diff --git a/app/src/main/java/fr/free/nrw/commons/di/ActivityBuilderModule.kt b/app/src/main/java/fr/free/nrw/commons/di/ActivityBuilderModule.kt new file mode 100644 index 000000000..86750a553 --- /dev/null +++ b/app/src/main/java/fr/free/nrw/commons/di/ActivityBuilderModule.kt @@ -0,0 +1,89 @@ +package fr.free.nrw.commons.di + +import dagger.Module +import dagger.android.ContributesAndroidInjector +import fr.free.nrw.commons.AboutActivity +import fr.free.nrw.commons.LocationPicker.LocationPickerActivity +import fr.free.nrw.commons.WelcomeActivity +import fr.free.nrw.commons.auth.LoginActivity +import fr.free.nrw.commons.auth.SignupActivity +import fr.free.nrw.commons.category.CategoryDetailsActivity +import fr.free.nrw.commons.contributions.MainActivity +import fr.free.nrw.commons.customselector.ui.selector.CustomSelectorActivity +import fr.free.nrw.commons.description.DescriptionEditActivity +import fr.free.nrw.commons.explore.SearchActivity +import fr.free.nrw.commons.explore.depictions.WikidataItemDetailsActivity +import fr.free.nrw.commons.media.ZoomableActivity +import fr.free.nrw.commons.nearby.WikidataFeedback +import fr.free.nrw.commons.notification.NotificationActivity +import fr.free.nrw.commons.profile.ProfileActivity +import fr.free.nrw.commons.review.ReviewActivity +import fr.free.nrw.commons.settings.SettingsActivity +import fr.free.nrw.commons.upload.UploadActivity +import fr.free.nrw.commons.upload.UploadProgressActivity + +/** + * This Class handles the dependency injection (using dagger) + * so, if a developer needs to add a new activity to the commons app + * then that must be mentioned here to inject the dependencies + */ +@Module +@Suppress("unused") +abstract class ActivityBuilderModule { + @ContributesAndroidInjector + abstract fun bindLoginActivity(): LoginActivity + + @ContributesAndroidInjector + abstract fun bindWelcomeActivity(): WelcomeActivity + + @ContributesAndroidInjector + abstract fun bindContributionsActivity(): MainActivity + + @ContributesAndroidInjector + abstract fun bindCustomSelectorActivity(): CustomSelectorActivity + + @ContributesAndroidInjector + abstract fun bindSettingsActivity(): SettingsActivity + + @ContributesAndroidInjector + abstract fun bindAboutActivity(): AboutActivity + + @ContributesAndroidInjector + abstract fun bindLocationPickerActivity(): LocationPickerActivity + + @ContributesAndroidInjector + abstract fun bindSignupActivity(): SignupActivity + + @ContributesAndroidInjector + abstract fun bindNotificationActivity(): NotificationActivity + + @ContributesAndroidInjector + abstract fun bindUploadActivity(): UploadActivity + + @ContributesAndroidInjector + abstract fun bindSearchActivity(): SearchActivity + + @ContributesAndroidInjector + abstract fun bindCategoryDetailsActivity(): CategoryDetailsActivity + + @ContributesAndroidInjector + abstract fun bindDepictionDetailsActivity(): WikidataItemDetailsActivity + + @ContributesAndroidInjector + abstract fun bindAchievementsActivity(): ProfileActivity + + @ContributesAndroidInjector + abstract fun bindReviewActivity(): ReviewActivity + + @ContributesAndroidInjector + abstract fun bindDescriptionEditActivity(): DescriptionEditActivity + + @ContributesAndroidInjector + abstract fun bindZoomableActivity(): ZoomableActivity + + @ContributesAndroidInjector + abstract fun bindUploadProgressActivity(): UploadProgressActivity + + @ContributesAndroidInjector + abstract fun bindWikiFeedback(): WikidataFeedback +} diff --git a/app/src/main/java/fr/free/nrw/commons/di/CommonsApplicationComponent.java b/app/src/main/java/fr/free/nrw/commons/di/CommonsApplicationComponent.java deleted file mode 100644 index 0d847b649..000000000 --- a/app/src/main/java/fr/free/nrw/commons/di/CommonsApplicationComponent.java +++ /dev/null @@ -1,85 +0,0 @@ -package fr.free.nrw.commons.di; - -import com.google.gson.Gson; - -import fr.free.nrw.commons.explore.categories.CategoriesModule; -import fr.free.nrw.commons.navtab.MoreBottomSheetFragment; -import fr.free.nrw.commons.navtab.MoreBottomSheetLoggedOutFragment; -import fr.free.nrw.commons.nearby.NearbyController; -import fr.free.nrw.commons.upload.worker.UploadWorker; -import javax.inject.Singleton; - -import dagger.Component; -import dagger.android.AndroidInjectionModule; -import dagger.android.AndroidInjector; -import dagger.android.support.AndroidSupportInjectionModule; -import fr.free.nrw.commons.CommonsApplication; -import fr.free.nrw.commons.auth.LoginActivity; -import fr.free.nrw.commons.contributions.ContributionsModule; -import fr.free.nrw.commons.explore.depictions.DepictionModule; -import fr.free.nrw.commons.explore.SearchModule; -import fr.free.nrw.commons.review.ReviewController; -import fr.free.nrw.commons.settings.SettingsFragment; -import fr.free.nrw.commons.upload.FileProcessor; -import fr.free.nrw.commons.upload.UploadModule; -import fr.free.nrw.commons.widget.PicOfDayAppWidget; - - -/** - * Facilitates Injection from CommonsApplicationModule to all the - * classes seeking a dependency to be injected - */ -@Singleton -@Component(modules = { - CommonsApplicationModule.class, - NetworkingModule.class, - AndroidInjectionModule.class, - AndroidSupportInjectionModule.class, - ActivityBuilderModule.class, - FragmentBuilderModule.class, - ServiceBuilderModule.class, - ContentProviderBuilderModule.class, - UploadModule.class, - ContributionsModule.class, - SearchModule.class, - DepictionModule.class, - CategoriesModule.class -}) -public interface CommonsApplicationComponent extends AndroidInjector { - void inject(CommonsApplication application); - - void inject(UploadWorker worker); - - void inject(LoginActivity activity); - - void inject(SettingsFragment fragment); - - void inject(MoreBottomSheetFragment fragment); - - void inject(MoreBottomSheetLoggedOutFragment fragment); - - void inject(ReviewController reviewController); - - //void inject(NavTabLayout view); - - @Override - void inject(ApplicationlessInjection instance); - - void inject(FileProcessor fileProcessor); - - void inject(PicOfDayAppWidget picOfDayAppWidget); - - @Singleton - void inject(NearbyController nearbyController); - - Gson gson(); - - @Component.Builder - @SuppressWarnings({"WeakerAccess", "unused"}) - interface Builder { - - Builder appModule(CommonsApplicationModule applicationModule); - - CommonsApplicationComponent build(); - } -} diff --git a/app/src/main/java/fr/free/nrw/commons/di/CommonsApplicationComponent.kt b/app/src/main/java/fr/free/nrw/commons/di/CommonsApplicationComponent.kt new file mode 100644 index 000000000..b0c0c4d37 --- /dev/null +++ b/app/src/main/java/fr/free/nrw/commons/di/CommonsApplicationComponent.kt @@ -0,0 +1,80 @@ +package fr.free.nrw.commons.di + +import com.google.gson.Gson +import dagger.Component +import dagger.android.AndroidInjectionModule +import dagger.android.AndroidInjector +import dagger.android.support.AndroidSupportInjectionModule +import fr.free.nrw.commons.CommonsApplication +import fr.free.nrw.commons.auth.LoginActivity +import fr.free.nrw.commons.contributions.ContributionsModule +import fr.free.nrw.commons.explore.SearchModule +import fr.free.nrw.commons.explore.categories.CategoriesModule +import fr.free.nrw.commons.explore.depictions.DepictionModule +import fr.free.nrw.commons.navtab.MoreBottomSheetFragment +import fr.free.nrw.commons.navtab.MoreBottomSheetLoggedOutFragment +import fr.free.nrw.commons.nearby.NearbyController +import fr.free.nrw.commons.review.ReviewController +import fr.free.nrw.commons.settings.SettingsFragment +import fr.free.nrw.commons.upload.FileProcessor +import fr.free.nrw.commons.upload.UploadModule +import fr.free.nrw.commons.upload.worker.UploadWorker +import fr.free.nrw.commons.widget.PicOfDayAppWidget +import javax.inject.Singleton + +/** + * Facilitates Injection from CommonsApplicationModule to all the + * classes seeking a dependency to be injected + */ +@Singleton +@Component( + modules = [ + CommonsApplicationModule::class, + NetworkingModule::class, + AndroidInjectionModule::class, + AndroidSupportInjectionModule::class, + ActivityBuilderModule::class, + FragmentBuilderModule::class, + ServiceBuilderModule::class, + ContentProviderBuilderModule::class, + UploadModule::class, + ContributionsModule::class, + SearchModule::class, + DepictionModule::class, + CategoriesModule::class + ] +) +interface CommonsApplicationComponent : AndroidInjector { + fun inject(application: CommonsApplication) + + fun inject(worker: UploadWorker) + + fun inject(activity: LoginActivity) + + fun inject(fragment: SettingsFragment) + + fun inject(fragment: MoreBottomSheetFragment) + + fun inject(fragment: MoreBottomSheetLoggedOutFragment) + + fun inject(reviewController: ReviewController) + + override fun inject(instance: ApplicationlessInjection) + + fun inject(fileProcessor: FileProcessor) + + fun inject(picOfDayAppWidget: PicOfDayAppWidget) + + @Singleton + fun inject(nearbyController: NearbyController) + + fun gson(): Gson + + @Component.Builder + @Suppress("unused") + interface Builder { + fun appModule(applicationModule: CommonsApplicationModule): Builder + + fun build(): CommonsApplicationComponent + } +} diff --git a/app/src/main/java/fr/free/nrw/commons/di/ContentProviderBuilderModule.java b/app/src/main/java/fr/free/nrw/commons/di/ContentProviderBuilderModule.java deleted file mode 100644 index aca6a2bf9..000000000 --- a/app/src/main/java/fr/free/nrw/commons/di/ContentProviderBuilderModule.java +++ /dev/null @@ -1,38 +0,0 @@ -package fr.free.nrw.commons.di; - -import dagger.Module; -import dagger.android.ContributesAndroidInjector; -import fr.free.nrw.commons.bookmarks.items.BookmarkItemsContentProvider; -import fr.free.nrw.commons.bookmarks.locations.BookmarkLocationsContentProvider; -import fr.free.nrw.commons.bookmarks.pictures.BookmarkPicturesContentProvider; -import fr.free.nrw.commons.category.CategoryContentProvider; -import fr.free.nrw.commons.explore.recentsearches.RecentSearchesContentProvider; -import fr.free.nrw.commons.recentlanguages.RecentLanguagesContentProvider; - -/** - * This Class Represents the Module for dependency injection (using dagger) - * so, if a developer needs to add a new ContentProvider to the commons app - * then that must be mentioned here to inject the dependencies - */ -@Module -@SuppressWarnings({ "WeakerAccess", "unused" }) -public abstract class ContentProviderBuilderModule { - - @ContributesAndroidInjector - abstract CategoryContentProvider bindCategoryContentProvider(); - - @ContributesAndroidInjector - abstract RecentSearchesContentProvider bindRecentSearchesContentProvider(); - - @ContributesAndroidInjector - abstract BookmarkPicturesContentProvider bindBookmarkContentProvider(); - - @ContributesAndroidInjector - abstract BookmarkLocationsContentProvider bindBookmarkLocationContentProvider(); - - @ContributesAndroidInjector - abstract BookmarkItemsContentProvider bindBookmarkItemContentProvider(); - - @ContributesAndroidInjector - abstract RecentLanguagesContentProvider bindRecentLanguagesContentProvider(); -} diff --git a/app/src/main/java/fr/free/nrw/commons/di/ContentProviderBuilderModule.kt b/app/src/main/java/fr/free/nrw/commons/di/ContentProviderBuilderModule.kt new file mode 100644 index 000000000..1882f77a9 --- /dev/null +++ b/app/src/main/java/fr/free/nrw/commons/di/ContentProviderBuilderModule.kt @@ -0,0 +1,37 @@ +package fr.free.nrw.commons.di + +import dagger.Module +import dagger.android.ContributesAndroidInjector +import fr.free.nrw.commons.bookmarks.items.BookmarkItemsContentProvider +import fr.free.nrw.commons.bookmarks.locations.BookmarkLocationsContentProvider +import fr.free.nrw.commons.bookmarks.pictures.BookmarkPicturesContentProvider +import fr.free.nrw.commons.category.CategoryContentProvider +import fr.free.nrw.commons.explore.recentsearches.RecentSearchesContentProvider +import fr.free.nrw.commons.recentlanguages.RecentLanguagesContentProvider + +/** + * This Class Represents the Module for dependency injection (using dagger) + * so, if a developer needs to add a new ContentProvider to the commons app + * then that must be mentioned here to inject the dependencies + */ +@Module +@Suppress("unused") +abstract class ContentProviderBuilderModule { + @ContributesAndroidInjector + abstract fun bindCategoryContentProvider(): CategoryContentProvider + + @ContributesAndroidInjector + abstract fun bindRecentSearchesContentProvider(): RecentSearchesContentProvider + + @ContributesAndroidInjector + abstract fun bindBookmarkContentProvider(): BookmarkPicturesContentProvider + + @ContributesAndroidInjector + abstract fun bindBookmarkLocationContentProvider(): BookmarkLocationsContentProvider + + @ContributesAndroidInjector + abstract fun bindBookmarkItemContentProvider(): BookmarkItemsContentProvider + + @ContributesAndroidInjector + abstract fun bindRecentLanguagesContentProvider(): RecentLanguagesContentProvider +} diff --git a/app/src/main/java/fr/free/nrw/commons/di/FragmentBuilderModule.java b/app/src/main/java/fr/free/nrw/commons/di/FragmentBuilderModule.java deleted file mode 100644 index 698ca1500..000000000 --- a/app/src/main/java/fr/free/nrw/commons/di/FragmentBuilderModule.java +++ /dev/null @@ -1,166 +0,0 @@ -package fr.free.nrw.commons.di; - -import dagger.Module; -import dagger.android.ContributesAndroidInjector; -import fr.free.nrw.commons.bookmarks.BookmarkFragment; -import fr.free.nrw.commons.bookmarks.BookmarkListRootFragment; -import fr.free.nrw.commons.bookmarks.items.BookmarkItemsFragment; -import fr.free.nrw.commons.bookmarks.locations.BookmarkLocationsFragment; -import fr.free.nrw.commons.bookmarks.pictures.BookmarkPicturesFragment; -import fr.free.nrw.commons.contributions.ContributionsFragment; -import fr.free.nrw.commons.contributions.ContributionsListFragment; -import fr.free.nrw.commons.customselector.ui.selector.FolderFragment; -import fr.free.nrw.commons.customselector.ui.selector.ImageFragment; -import fr.free.nrw.commons.explore.ExploreFragment; -import fr.free.nrw.commons.explore.ExploreListRootFragment; -import fr.free.nrw.commons.explore.ExploreMapRootFragment; -import fr.free.nrw.commons.explore.map.ExploreMapFragment; -import fr.free.nrw.commons.explore.categories.media.CategoriesMediaFragment; -import fr.free.nrw.commons.explore.categories.parent.ParentCategoriesFragment; -import fr.free.nrw.commons.explore.categories.search.SearchCategoryFragment; -import fr.free.nrw.commons.explore.categories.sub.SubCategoriesFragment; -import fr.free.nrw.commons.explore.depictions.child.ChildDepictionsFragment; -import fr.free.nrw.commons.explore.depictions.media.DepictedImagesFragment; -import fr.free.nrw.commons.explore.depictions.parent.ParentDepictionsFragment; -import fr.free.nrw.commons.explore.depictions.search.SearchDepictionsFragment; -import fr.free.nrw.commons.explore.media.SearchMediaFragment; -import fr.free.nrw.commons.explore.recentsearches.RecentSearchesFragment; -import fr.free.nrw.commons.media.MediaDetailFragment; -import fr.free.nrw.commons.media.MediaDetailPagerFragment; -import fr.free.nrw.commons.navtab.MoreBottomSheetFragment; -import fr.free.nrw.commons.navtab.MoreBottomSheetLoggedOutFragment; -import fr.free.nrw.commons.nearby.fragments.NearbyParentFragment; -import fr.free.nrw.commons.profile.achievements.AchievementsFragment; -import fr.free.nrw.commons.profile.leaderboard.LeaderboardFragment; -import fr.free.nrw.commons.review.ReviewImageFragment; -import fr.free.nrw.commons.settings.SettingsFragment; -import fr.free.nrw.commons.upload.FailedUploadsFragment; -import fr.free.nrw.commons.upload.PendingUploadsFragment; -import fr.free.nrw.commons.upload.categories.UploadCategoriesFragment; -import fr.free.nrw.commons.upload.depicts.DepictsFragment; -import fr.free.nrw.commons.upload.license.MediaLicenseFragment; -import fr.free.nrw.commons.upload.mediaDetails.UploadMediaDetailFragment; - -/** - * This Class Represents the Module for dependency injection (using dagger) - * so, if a developer needs to add a new Fragment to the commons app - * then that must be mentioned here to inject the dependencies - */ -@Module -@SuppressWarnings({"WeakerAccess", "unused"}) -public abstract class FragmentBuilderModule { - - @ContributesAndroidInjector - abstract ContributionsListFragment bindContributionsListFragment(); - - @ContributesAndroidInjector - abstract MediaDetailFragment bindMediaDetailFragment(); - - @ContributesAndroidInjector - abstract FolderFragment bindFolderFragment(); - - @ContributesAndroidInjector - abstract ImageFragment bindImageFragment(); - - @ContributesAndroidInjector - abstract MediaDetailPagerFragment bindMediaDetailPagerFragment(); - - @ContributesAndroidInjector - abstract SettingsFragment bindSettingsFragment(); - - @ContributesAndroidInjector - abstract DepictedImagesFragment bindDepictedImagesFragment(); - - @ContributesAndroidInjector - abstract SearchMediaFragment bindBrowseImagesListFragment(); - - @ContributesAndroidInjector - abstract SearchCategoryFragment bindSearchCategoryListFragment(); - - @ContributesAndroidInjector - abstract SearchDepictionsFragment bindSearchDepictionListFragment(); - - @ContributesAndroidInjector - abstract RecentSearchesFragment bindRecentSearchesFragment(); - - @ContributesAndroidInjector - abstract ContributionsFragment bindContributionsFragment(); - - @ContributesAndroidInjector(modules = NearbyParentFragmentModule.class) - abstract NearbyParentFragment bindNearbyParentFragment(); - - @ContributesAndroidInjector - abstract BookmarkPicturesFragment bindBookmarkPictureListFragment(); - - @ContributesAndroidInjector(modules = BookmarkLocationsFragmentModule.class) - abstract BookmarkLocationsFragment bindBookmarkLocationListFragment(); - - @ContributesAndroidInjector(modules = BookmarkItemsFragmentModule.class) - abstract BookmarkItemsFragment bindBookmarkItemListFragment(); - - @ContributesAndroidInjector - abstract ReviewImageFragment bindReviewOutOfContextFragment(); - - @ContributesAndroidInjector - abstract UploadMediaDetailFragment bindUploadMediaDetailFragment(); - - @ContributesAndroidInjector - abstract UploadCategoriesFragment bindUploadCategoriesFragment(); - - @ContributesAndroidInjector - abstract DepictsFragment bindDepictsFragment(); - - @ContributesAndroidInjector - abstract MediaLicenseFragment bindMediaLicenseFragment(); - - @ContributesAndroidInjector - abstract ParentDepictionsFragment bindParentDepictionsFragment(); - - @ContributesAndroidInjector - abstract ChildDepictionsFragment bindChildDepictionsFragment(); - - @ContributesAndroidInjector - abstract CategoriesMediaFragment bindCategoriesMediaFragment(); - - @ContributesAndroidInjector - abstract SubCategoriesFragment bindSubCategoriesFragment(); - - @ContributesAndroidInjector - abstract ParentCategoriesFragment bindParentCategoriesFragment(); - - @ContributesAndroidInjector - abstract ExploreFragment bindExploreFragmentFragment(); - - @ContributesAndroidInjector - abstract ExploreListRootFragment bindExploreFeaturedRootFragment(); - - @ContributesAndroidInjector(modules = ExploreMapFragmentModule.class) - abstract ExploreMapFragment bindExploreNearbyUploadsFragment(); - - @ContributesAndroidInjector - abstract ExploreMapRootFragment bindExploreNearbyUploadsRootFragment(); - - @ContributesAndroidInjector - abstract BookmarkListRootFragment bindBookmarkListRootFragment(); - - @ContributesAndroidInjector - abstract BookmarkFragment bindBookmarkFragmentFragment(); - - @ContributesAndroidInjector - abstract MoreBottomSheetFragment bindMoreBottomSheetFragment(); - - @ContributesAndroidInjector - abstract MoreBottomSheetLoggedOutFragment bindMoreBottomSheetLoggedOutFragment(); - - @ContributesAndroidInjector - abstract AchievementsFragment bindAchievementsFragment(); - - @ContributesAndroidInjector - abstract LeaderboardFragment bindLeaderboardFragment(); - - @ContributesAndroidInjector - abstract PendingUploadsFragment bindPendingUploadsFragment(); - - @ContributesAndroidInjector - abstract FailedUploadsFragment bindFailedUploadsFragment(); -} diff --git a/app/src/main/java/fr/free/nrw/commons/di/FragmentBuilderModule.kt b/app/src/main/java/fr/free/nrw/commons/di/FragmentBuilderModule.kt new file mode 100644 index 000000000..bfdb90181 --- /dev/null +++ b/app/src/main/java/fr/free/nrw/commons/di/FragmentBuilderModule.kt @@ -0,0 +1,165 @@ +package fr.free.nrw.commons.di + +import dagger.Module +import dagger.android.ContributesAndroidInjector +import fr.free.nrw.commons.bookmarks.BookmarkFragment +import fr.free.nrw.commons.bookmarks.BookmarkListRootFragment +import fr.free.nrw.commons.bookmarks.items.BookmarkItemsFragment +import fr.free.nrw.commons.bookmarks.locations.BookmarkLocationsFragment +import fr.free.nrw.commons.bookmarks.pictures.BookmarkPicturesFragment +import fr.free.nrw.commons.contributions.ContributionsFragment +import fr.free.nrw.commons.contributions.ContributionsListFragment +import fr.free.nrw.commons.customselector.ui.selector.FolderFragment +import fr.free.nrw.commons.customselector.ui.selector.ImageFragment +import fr.free.nrw.commons.explore.ExploreFragment +import fr.free.nrw.commons.explore.ExploreListRootFragment +import fr.free.nrw.commons.explore.ExploreMapRootFragment +import fr.free.nrw.commons.explore.categories.media.CategoriesMediaFragment +import fr.free.nrw.commons.explore.categories.parent.ParentCategoriesFragment +import fr.free.nrw.commons.explore.categories.search.SearchCategoryFragment +import fr.free.nrw.commons.explore.categories.sub.SubCategoriesFragment +import fr.free.nrw.commons.explore.depictions.child.ChildDepictionsFragment +import fr.free.nrw.commons.explore.depictions.media.DepictedImagesFragment +import fr.free.nrw.commons.explore.depictions.parent.ParentDepictionsFragment +import fr.free.nrw.commons.explore.depictions.search.SearchDepictionsFragment +import fr.free.nrw.commons.explore.map.ExploreMapFragment +import fr.free.nrw.commons.explore.media.SearchMediaFragment +import fr.free.nrw.commons.explore.recentsearches.RecentSearchesFragment +import fr.free.nrw.commons.media.MediaDetailFragment +import fr.free.nrw.commons.media.MediaDetailPagerFragment +import fr.free.nrw.commons.navtab.MoreBottomSheetFragment +import fr.free.nrw.commons.navtab.MoreBottomSheetLoggedOutFragment +import fr.free.nrw.commons.nearby.fragments.NearbyParentFragment +import fr.free.nrw.commons.profile.achievements.AchievementsFragment +import fr.free.nrw.commons.profile.leaderboard.LeaderboardFragment +import fr.free.nrw.commons.review.ReviewImageFragment +import fr.free.nrw.commons.settings.SettingsFragment +import fr.free.nrw.commons.upload.FailedUploadsFragment +import fr.free.nrw.commons.upload.PendingUploadsFragment +import fr.free.nrw.commons.upload.categories.UploadCategoriesFragment +import fr.free.nrw.commons.upload.depicts.DepictsFragment +import fr.free.nrw.commons.upload.license.MediaLicenseFragment +import fr.free.nrw.commons.upload.mediaDetails.UploadMediaDetailFragment + +/** + * This Class Represents the Module for dependency injection (using dagger) + * so, if a developer needs to add a new Fragment to the commons app + * then that must be mentioned here to inject the dependencies + */ +@Module +@Suppress("unused") +abstract class FragmentBuilderModule { + @ContributesAndroidInjector + abstract fun bindContributionsListFragment(): ContributionsListFragment + + @ContributesAndroidInjector + abstract fun bindMediaDetailFragment(): MediaDetailFragment + + @ContributesAndroidInjector + abstract fun bindFolderFragment(): FolderFragment + + @ContributesAndroidInjector + abstract fun bindImageFragment(): ImageFragment + + @ContributesAndroidInjector + abstract fun bindMediaDetailPagerFragment(): MediaDetailPagerFragment + + @ContributesAndroidInjector + abstract fun bindSettingsFragment(): SettingsFragment + + @ContributesAndroidInjector + abstract fun bindDepictedImagesFragment(): DepictedImagesFragment + + @ContributesAndroidInjector + abstract fun bindBrowseImagesListFragment(): SearchMediaFragment + + @ContributesAndroidInjector + abstract fun bindSearchCategoryListFragment(): SearchCategoryFragment + + @ContributesAndroidInjector + abstract fun bindSearchDepictionListFragment(): SearchDepictionsFragment + + @ContributesAndroidInjector + abstract fun bindRecentSearchesFragment(): RecentSearchesFragment + + @ContributesAndroidInjector + abstract fun bindContributionsFragment(): ContributionsFragment + + @ContributesAndroidInjector(modules = [NearbyParentFragmentModule::class]) + abstract fun bindNearbyParentFragment(): NearbyParentFragment + + @ContributesAndroidInjector + abstract fun bindBookmarkPictureListFragment(): BookmarkPicturesFragment + + @ContributesAndroidInjector(modules = [BookmarkLocationsFragmentModule::class]) + abstract fun bindBookmarkLocationListFragment(): BookmarkLocationsFragment + + @ContributesAndroidInjector(modules = [BookmarkItemsFragmentModule::class]) + abstract fun bindBookmarkItemListFragment(): BookmarkItemsFragment + + @ContributesAndroidInjector + abstract fun bindReviewOutOfContextFragment(): ReviewImageFragment + + @ContributesAndroidInjector + abstract fun bindUploadMediaDetailFragment(): UploadMediaDetailFragment + + @ContributesAndroidInjector + abstract fun bindUploadCategoriesFragment(): UploadCategoriesFragment + + @ContributesAndroidInjector + abstract fun bindDepictsFragment(): DepictsFragment + + @ContributesAndroidInjector + abstract fun bindMediaLicenseFragment(): MediaLicenseFragment + + @ContributesAndroidInjector + abstract fun bindParentDepictionsFragment(): ParentDepictionsFragment + + @ContributesAndroidInjector + abstract fun bindChildDepictionsFragment(): ChildDepictionsFragment + + @ContributesAndroidInjector + abstract fun bindCategoriesMediaFragment(): CategoriesMediaFragment + + @ContributesAndroidInjector + abstract fun bindSubCategoriesFragment(): SubCategoriesFragment + + @ContributesAndroidInjector + abstract fun bindParentCategoriesFragment(): ParentCategoriesFragment + + @ContributesAndroidInjector + abstract fun bindExploreFragmentFragment(): ExploreFragment + + @ContributesAndroidInjector + abstract fun bindExploreFeaturedRootFragment(): ExploreListRootFragment + + @ContributesAndroidInjector(modules = [ExploreMapFragmentModule::class]) + abstract fun bindExploreNearbyUploadsFragment(): ExploreMapFragment + + @ContributesAndroidInjector + abstract fun bindExploreNearbyUploadsRootFragment(): ExploreMapRootFragment + + @ContributesAndroidInjector + abstract fun bindBookmarkListRootFragment(): BookmarkListRootFragment + + @ContributesAndroidInjector + abstract fun bindBookmarkFragmentFragment(): BookmarkFragment + + @ContributesAndroidInjector + abstract fun bindMoreBottomSheetFragment(): MoreBottomSheetFragment + + @ContributesAndroidInjector + abstract fun bindMoreBottomSheetLoggedOutFragment(): MoreBottomSheetLoggedOutFragment + + @ContributesAndroidInjector + abstract fun bindAchievementsFragment(): AchievementsFragment + + @ContributesAndroidInjector + abstract fun bindLeaderboardFragment(): LeaderboardFragment + + @ContributesAndroidInjector + abstract fun bindPendingUploadsFragment(): PendingUploadsFragment + + @ContributesAndroidInjector + abstract fun bindFailedUploadsFragment(): FailedUploadsFragment +} diff --git a/app/src/main/java/fr/free/nrw/commons/di/ServiceBuilderModule.java b/app/src/main/java/fr/free/nrw/commons/di/ServiceBuilderModule.java deleted file mode 100644 index 1fb52c937..000000000 --- a/app/src/main/java/fr/free/nrw/commons/di/ServiceBuilderModule.java +++ /dev/null @@ -1,19 +0,0 @@ -package fr.free.nrw.commons.di; - -import dagger.Module; -import dagger.android.ContributesAndroidInjector; -import fr.free.nrw.commons.auth.WikiAccountAuthenticatorService; - -/** - * This Class Represents the Module for dependency injection (using dagger) - * so, if a developer needs to add a new Service to the commons app - * then that must be mentioned here to inject the dependencies - */ -@Module -@SuppressWarnings({"WeakerAccess", "unused"}) -public abstract class ServiceBuilderModule { - - @ContributesAndroidInjector - abstract WikiAccountAuthenticatorService bindWikiAccountAuthenticatorService(); - -} diff --git a/app/src/main/java/fr/free/nrw/commons/di/ServiceBuilderModule.kt b/app/src/main/java/fr/free/nrw/commons/di/ServiceBuilderModule.kt new file mode 100644 index 000000000..45dbd5721 --- /dev/null +++ b/app/src/main/java/fr/free/nrw/commons/di/ServiceBuilderModule.kt @@ -0,0 +1,17 @@ +package fr.free.nrw.commons.di + +import dagger.Module +import dagger.android.ContributesAndroidInjector +import fr.free.nrw.commons.auth.WikiAccountAuthenticatorService + +/** + * This Class Represents the Module for dependency injection (using dagger) + * so, if a developer needs to add a new Service to the commons app + * then that must be mentioned here to inject the dependencies + */ +@Module +@Suppress("unused") +abstract class ServiceBuilderModule { + @ContributesAndroidInjector + abstract fun bindWikiAccountAuthenticatorService(): WikiAccountAuthenticatorService +}