diff --git a/BUILD.bazel b/BUILD.bazel index 4dccfd87153..81250077b03 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -75,6 +75,7 @@ package_group( [ transform_android_manifest( name = "oppia_apk_%s_transformed_manifest" % apk_flavor_metadata["flavor"], + application_relative_qualified_class = ".app.application.dev.DeveloperOppiaApplication", build_flavor = apk_flavor_metadata["flavor"], input_file = "//app:src/main/AndroidManifest.xml", major_version = MAJOR_VERSION, @@ -108,7 +109,7 @@ package_group( }, multidex = apk_flavor_metadata["multidex"], deps = [ - "//app", + "//app/src/main/java/org/oppia/android/app/application/dev:developer_application", ], ) for apk_flavor_metadata in [ diff --git a/app/BUILD.bazel b/app/BUILD.bazel index 83841648a29..c7893e98635 100644 --- a/app/BUILD.bazel +++ b/app/BUILD.bazel @@ -630,9 +630,6 @@ kt_android_library( "//third_party:androidx_databinding_databinding-runtime", "//third_party:circularimageview_circular_image_view", "//utility/src/main/java/org/oppia/android/util/accessibility", - "//utility/src/main/java/org/oppia/android/util/caching:caching_prod_module", - "//utility/src/main/java/org/oppia/android/util/logging:prod_module", - "//utility/src/main/java/org/oppia/android/util/logging/firebase:prod_module", "//utility/src/main/java/org/oppia/android/util/parser/html:html_parser", "//utility/src/main/java/org/oppia/android/util/parser/image:image_loader", "//utility/src/main/java/org/oppia/android/util/parser/image:image_parsing_annonations", @@ -668,11 +665,11 @@ kt_android_library( ":listeners", ":resources", "//app/src/main/java/org/oppia/android/app/shim:intent_factory_shim", + "//app/src/main/java/org/oppia/android/app/utility/datetime:date_time_util", + "//app/src/main/java/org/oppia/android/app/utility/math:math_expression_accessibility_util", "//app/src/main/java/org/oppia/android/app/viewmodel:observable_array_list", "//app/src/main/java/org/oppia/android/app/viewmodel:observable_view_model", "//app/src/main/java/org/oppia/android/app/viewmodel:view_model_provider", - "//app/src/main/java/org/oppia/android/app/utility/datetime:date_time_util", - "//app/src/main/java/org/oppia/android/app/utility/math:math_expression_accessibility_util", "//domain", "//domain/src/main/java/org/oppia/android/domain/audio:audio_player_controller", "//domain/src/main/java/org/oppia/android/domain/clipboard:clipboard_controller", @@ -684,11 +681,8 @@ kt_android_library( "//utility", "//utility/src/main/java/org/oppia/android/util/extensions:context_extensions", "//utility/src/main/java/org/oppia/android/util/logging/firebase:debug_event_logger", - "//utility/src/main/java/org/oppia/android/util/logging/firebase:debug_module", "//utility/src/main/java/org/oppia/android/util/math:fraction_parser", - # TODO(#59): Remove 'debug_util_module' once we completely migrate to Bazel from Gradle as - # we can then directly exclude debug files from the build and thus won't be requiring this module. - "//utility/src/main/java/org/oppia/android/util/networking:debug_util_module", + "//utility/src/main/java/org/oppia/android/util/networking:network_connection_debug_util", "//utility/src/main/java/org/oppia/android/util/parser/html:html_parser", ], ) @@ -757,34 +751,11 @@ kt_android_library( "//app/src/main/java/org/oppia/android/app/fragment:injectable_dialog_fragment", "//app/src/main/java/org/oppia/android/app/fragment:injectable_fragment", "//app/src/main/java/org/oppia/android/app/shim:prod_modules", - "//app/src/main/java/org/oppia/android/app/translation:prod_module", - "//data/src/main/java/org/oppia/android/data/backends/gae:network_config_prod_module", - "//data/src/main/java/org/oppia/android/data/backends/gae:prod_module", - "//domain/src/main/java/org/oppia/android/domain/classify:interactions_module", - "//domain/src/main/java/org/oppia/android/domain/classify/rules/algebraicexpressioninput:algebraic_expression_input_rule_module", - "//domain/src/main/java/org/oppia/android/domain/classify/rules/continueinteraction:continue_module", - "//domain/src/main/java/org/oppia/android/domain/classify/rules/dragAndDropSortInput:drag_and_drop_sort_input_module", - "//domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput:fraction_input_module", - "//domain/src/main/java/org/oppia/android/domain/classify/rules/imageClickInput:image_click_input_module", - "//domain/src/main/java/org/oppia/android/domain/classify/rules/itemselectioninput:item_selection_input_module", - "//domain/src/main/java/org/oppia/android/domain/classify/rules/mathequationinput:math_equation_input_rule_module", - "//domain/src/main/java/org/oppia/android/domain/classify/rules/multiplechoiceinput:multiple_choice_input_module", - "//domain/src/main/java/org/oppia/android/domain/classify/rules/numberwithunits:number_with_units_rule_module", - "//domain/src/main/java/org/oppia/android/domain/classify/rules/numericexpressioninput:numeric_expression_input_rule_module", - "//domain/src/main/java/org/oppia/android/domain/classify/rules/numericinput:numeric_input_rule_module", - "//domain/src/main/java/org/oppia/android/domain/classify/rules/ratioinput:ratio_input_module", - "//domain/src/main/java/org/oppia/android/domain/classify/rules/textinput:text_input_rule_module", - "//domain/src/main/java/org/oppia/android/domain/locale:locale_application_injector", - "//domain/src/main/java/org/oppia/android/domain/locale:locale_application_injector_provider", - "//domain/src/main/java/org/oppia/android/domain/onboarding:retriever_prod_module", + "//app/src/main/java/org/oppia/android/app/testing/activity:test_activity", "//domain/src/main/java/org/oppia/android/domain/onboarding:state_controller", "//domain/src/main/java/org/oppia/android/domain/oppialogger:startup_listener", - "//domain/src/main/java/org/oppia/android/domain/oppialogger/exceptions:logger_module", - "//domain/src/main/java/org/oppia/android/domain/oppialogger/loguploader:worker_module", - "//model/src/main/proto:arguments_java_proto_lite", "//domain/src/main/java/org/oppia/android/domain/profile:profile_management_controller", - "//domain/src/main/java/org/oppia/android/domain/oppialogger/analytics:prod_module", - "//app/src/main/java/org/oppia/android/app/testing/activity:test_activity", + "//model/src/main/proto:arguments_java_proto_lite", "//third_party:androidx_databinding_databinding-adapters", "//third_party:androidx_databinding_databinding-common", "//third_party:androidx_databinding_databinding-runtime", @@ -794,26 +765,14 @@ kt_android_library( "//third_party:androidx_multidex_multidex", "//third_party:androidx_viewpager2_viewpager2", "//third_party:androidx_viewpager_viewpager", - "//third_party:androidx_work_work-runtime-ktx", "//third_party:com_caverock_androidsvg", "//third_party:com_google_android_flexbox_flexbox", "//third_party:javax_annotation_javax_annotation-api_jar", "//utility", - "//utility/src/main/java/org/oppia/android/util/accessibility:prod_module", - "//utility/src/main/java/org/oppia/android/util/caching:asset_prod_module", "//utility/src/main/java/org/oppia/android/util/extensions:bundle_extensions", - "//utility/src/main/java/org/oppia/android/util/locale:prod_module", - "//utility/src/main/java/org/oppia/android/util/parser/html:html_parser_entity_type_module", "//utility/src/main/java/org/oppia/android/util/parser/image:image_loader", - "//utility/src/main/java/org/oppia/android/util/parser/image:glide_image_loader_module", - "//utility/src/main/java/org/oppia/android/util/parser/image:repository_glide_module", "//utility/src/main/java/org/oppia/android/util/parser/image:image_parsing_annonations", - "//utility/src/main/java/org/oppia/android/util/parser/image:image_parsing_module", - # TODO(#2432): Replace debug_module with prod_module when building the app in prod mode. - "//utility/src/main/java/org/oppia/android/util/networking:debug_module", - "//utility/src/main/java/org/oppia/android/util/logging:console_logger_injector_provider", "//utility/src/main/java/org/oppia/android/util/statusbar:status_bar_color", - "//utility/src/main/java/org/oppia/android/util/threading:dispatcher_injector_provider", ], ) @@ -858,6 +817,10 @@ TEST_DEPS = [ ":dagger", ":resources", ":test_deps", + "//app/src/main/java/org/oppia/android/app/application:application_component", + "//app/src/main/java/org/oppia/android/app/application:application_injector", + "//app/src/main/java/org/oppia/android/app/application:application_injector_provider", + "//app/src/main/java/org/oppia/android/app/application:common_application_modules", "//app/src/main/java/org/oppia/android/app/testing/activity:test_activity", "//app/src/main/java/org/oppia/android/app/translation/testing:test_module", "//app/src/main/java/org/oppia/android/app/utility/math:math_expression_accessibility_util", @@ -924,7 +887,9 @@ TEST_DEPS = [ "//utility/src/main/java/org/oppia/android/util/accessibility:test_module", "//utility/src/main/java/org/oppia/android/util/caching:asset_prod_module", "//utility/src/main/java/org/oppia/android/util/caching/testing:caching_test_module", + "//utility/src/main/java/org/oppia/android/util/logging/firebase:debug_module", "//utility/src/main/java/org/oppia/android/util/math:math_expression_parser", + "//utility/src/main/java/org/oppia/android/util/networking:debug_module", "//utility/src/main/java/org/oppia/android/util/parser/html:custom_bullet_span", "//utility/src/main/java/org/oppia/android/util/parser/html:html_parser", "//utility/src/main/java/org/oppia/android/util/parser/html:html_parser_entity_type_module", diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6515cf4329a..89dc7903f41 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -9,7 +9,7 @@ ApplicationComponent.Builder +) : MultiDexApplication(), ActivityComponentFactory, ApplicationInjectorProvider, Configuration.Provider { + /** The root [ApplicationComponent]. */ private val component: ApplicationComponent by lazy { - DaggerApplicationComponent.builder() - .setApplication(this) - .build() + createComponentBuilder().setApplication(this).build() } override fun createActivityComponent(activity: AppCompatActivity): ActivityComponent { diff --git a/app/src/main/java/org/oppia/android/app/application/ApplicationComponent.kt b/app/src/main/java/org/oppia/android/app/application/ApplicationComponent.kt index f08f475b263..1c92ad5c6c6 100644 --- a/app/src/main/java/org/oppia/android/app/application/ApplicationComponent.kt +++ b/app/src/main/java/org/oppia/android/app/application/ApplicationComponent.kt @@ -3,116 +3,22 @@ package org.oppia.android.app.application import android.app.Application import androidx.work.Configuration import dagger.BindsInstance -import dagger.Component import org.oppia.android.app.activity.ActivityComponentImpl -import org.oppia.android.app.devoptions.DeveloperOptionsModule -import org.oppia.android.app.devoptions.DeveloperOptionsStarterModule -import org.oppia.android.app.player.state.itemviewmodel.SplitScreenInteractionModule -import org.oppia.android.app.shim.IntentFactoryShimModule -import org.oppia.android.app.shim.ViewBindingShimModule -import org.oppia.android.app.topic.PracticeTabModule -import org.oppia.android.app.translation.ActivityRecreatorProdModule -import org.oppia.android.data.backends.gae.NetworkConfigProdModule -import org.oppia.android.data.backends.gae.NetworkModule -import org.oppia.android.domain.classify.InteractionsModule -import org.oppia.android.domain.classify.rules.algebraicexpressioninput.AlgebraicExpressionInputModule -import org.oppia.android.domain.classify.rules.continueinteraction.ContinueModule -import org.oppia.android.domain.classify.rules.dragAndDropSortInput.DragDropSortInputModule -import org.oppia.android.domain.classify.rules.fractioninput.FractionInputModule -import org.oppia.android.domain.classify.rules.imageClickInput.ImageClickInputModule -import org.oppia.android.domain.classify.rules.itemselectioninput.ItemSelectionInputModule -import org.oppia.android.domain.classify.rules.mathequationinput.MathEquationInputModule -import org.oppia.android.domain.classify.rules.multiplechoiceinput.MultipleChoiceInputModule -import org.oppia.android.domain.classify.rules.numberwithunits.NumberWithUnitsRuleModule -import org.oppia.android.domain.classify.rules.numericexpressioninput.NumericExpressionInputModule -import org.oppia.android.domain.classify.rules.numericinput.NumericInputRuleModule -import org.oppia.android.domain.classify.rules.ratioinput.RatioInputModule -import org.oppia.android.domain.classify.rules.textinput.TextInputRuleModule -import org.oppia.android.domain.exploration.lightweightcheckpointing.ExplorationStorageModule -import org.oppia.android.domain.hintsandsolution.HintsAndSolutionConfigModule -import org.oppia.android.domain.hintsandsolution.HintsAndSolutionDebugModule -import org.oppia.android.domain.onboarding.ExpirationMetaDataRetrieverModule import org.oppia.android.domain.oppialogger.ApplicationStartupListener -import org.oppia.android.domain.oppialogger.LogStorageModule -import org.oppia.android.domain.oppialogger.LoggingIdentifierModule -import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule -import org.oppia.android.domain.oppialogger.exceptions.UncaughtExceptionLoggerModule -import org.oppia.android.domain.oppialogger.loguploader.LogUploadWorkerModule -import org.oppia.android.domain.platformparameter.PlatformParameterModule -import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule -import org.oppia.android.domain.platformparameter.syncup.PlatformParameterSyncUpWorkerModule -import org.oppia.android.domain.question.QuestionModule -import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule -import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.util.accessibility.AccessibilityProdModule -import org.oppia.android.util.caching.AssetModule -import org.oppia.android.util.caching.CachingModule -import org.oppia.android.util.gcsresource.GcsResourceModule -import org.oppia.android.util.locale.LocaleProdModule -import org.oppia.android.util.logging.LoggerModule -import org.oppia.android.util.logging.SyncStatusModule -import org.oppia.android.util.logging.firebase.DebugLogReportingModule -import org.oppia.android.util.logging.firebase.FirebaseLogUploaderModule -import org.oppia.android.util.networking.NetworkConnectionDebugUtilModule -import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule -import org.oppia.android.util.parser.html.HtmlParserEntityTypeModule -import org.oppia.android.util.parser.image.GlideImageLoaderModule -import org.oppia.android.util.parser.image.ImageParsingModule -import org.oppia.android.util.system.OppiaClockModule -import org.oppia.android.util.threading.DispatcherModule import javax.inject.Provider -import javax.inject.Singleton /** * Root Dagger component for the application. All application-scoped modules should be included in * this component. * - * At the time of building the app in prod mode - - * Remove: [DeveloperOptionsStarterModule], [DebugLogReportingModule], - * [NetworkConnectionUtilDebugModule], [HintsAndSolutionDebugModule] - * Add: [LogReportingModule], [NetworkConnectionUtilProdModule], [HintsAndSolutionProdModule] - * - * When building with Bazel, please also refer to instructions in app/BUILD.bazel. + * This component will be subclasses for specific contexts (such as test builds, or specific build + * flavors of the app). */ -@Singleton -@Component( - modules = [ - ApplicationModule::class, DispatcherModule::class, - LoggerModule::class, OppiaClockModule::class, - ContinueModule::class, FractionInputModule::class, - ItemSelectionInputModule::class, MultipleChoiceInputModule::class, - NumberWithUnitsRuleModule::class, NumericInputRuleModule::class, - TextInputRuleModule::class, DragDropSortInputModule::class, - InteractionsModule::class, GcsResourceModule::class, - GlideImageLoaderModule::class, ImageParsingModule::class, - HtmlParserEntityTypeModule::class, CachingModule::class, - QuestionModule::class, DebugLogReportingModule::class, - AccessibilityProdModule::class, ImageClickInputModule::class, - LogStorageModule::class, IntentFactoryShimModule::class, - ViewBindingShimModule::class, PrimeTopicAssetsControllerModule::class, - ExpirationMetaDataRetrieverModule::class, RatioInputModule::class, - UncaughtExceptionLoggerModule::class, ApplicationStartupListenerModule::class, - LogUploadWorkerModule::class, WorkManagerConfigurationModule::class, - HintsAndSolutionConfigModule::class, HintsAndSolutionDebugModule::class, - FirebaseLogUploaderModule::class, NetworkModule::class, PracticeTabModule::class, - PlatformParameterModule::class, PlatformParameterSingletonModule::class, - ExplorationStorageModule::class, DeveloperOptionsStarterModule::class, - DeveloperOptionsModule::class, PlatformParameterSyncUpWorkerModule::class, - NetworkConnectionUtilDebugModule::class, NetworkConfigProdModule::class, AssetModule::class, - LocaleProdModule::class, ActivityRecreatorProdModule::class, - NumericExpressionInputModule::class, AlgebraicExpressionInputModule::class, - MathEquationInputModule::class, SplitScreenInteractionModule::class, - LoggingIdentifierModule::class, ApplicationLifecycleModule::class, - // TODO(#59): Remove this module once we completely migrate to Bazel from Gradle as we can then - // directly exclude debug files from the build and thus won't be requiring this module. - NetworkConnectionDebugUtilModule::class, LoggingIdentifierModule::class, SyncStatusModule::class - ] -) interface ApplicationComponent : ApplicationInjector { - @Component.Builder interface Builder { @BindsInstance fun setApplication(application: Application): Builder + fun build(): ApplicationComponent } diff --git a/app/src/main/java/org/oppia/android/app/application/ApplicationContext.kt b/app/src/main/java/org/oppia/android/app/application/ApplicationContext.kt deleted file mode 100644 index d4aa0324272..00000000000 --- a/app/src/main/java/org/oppia/android/app/application/ApplicationContext.kt +++ /dev/null @@ -1,7 +0,0 @@ -package org.oppia.android.app.application - -import javax.inject.Qualifier - -/** Qualifier for injecting the application context. */ -@Qualifier -annotation class ApplicationContext diff --git a/app/src/main/java/org/oppia/android/app/application/ApplicationModule.kt b/app/src/main/java/org/oppia/android/app/application/ApplicationModule.kt index 00954abdc7d..9cd0698c05b 100644 --- a/app/src/main/java/org/oppia/android/app/application/ApplicationModule.kt +++ b/app/src/main/java/org/oppia/android/app/application/ApplicationModule.kt @@ -2,25 +2,13 @@ package org.oppia.android.app.application import android.app.Application import android.content.Context +import dagger.Binds import dagger.Module -import dagger.Provides import org.oppia.android.app.activity.ActivityComponentImpl -import javax.inject.Singleton /** Provides core infrastructure needed to support all other dependencies in the app. */ @Module(subcomponents = [ActivityComponentImpl::class]) -class ApplicationModule { - @Provides - @Singleton - @ApplicationContext - fun provideApplicationContext(application: Application): Context { - return application - } - - // TODO(#59): Remove this provider once all modules have access to the @ApplicationContext qualifier. - @Provides - @Singleton - fun provideContext(@ApplicationContext context: Context): Context { - return context - } +interface ApplicationModule { + @Binds + fun provideContext(application: Application): Context } diff --git a/app/src/main/java/org/oppia/android/app/application/ApplicationStartupListenerModule.kt b/app/src/main/java/org/oppia/android/app/application/ApplicationStartupListenerModule.kt index 239e3b0e9f8..77287f080d3 100644 --- a/app/src/main/java/org/oppia/android/app/application/ApplicationStartupListenerModule.kt +++ b/app/src/main/java/org/oppia/android/app/application/ApplicationStartupListenerModule.kt @@ -7,7 +7,6 @@ import org.oppia.android.domain.oppialogger.ApplicationStartupListener /** Binds multiple dependencies that implement [ApplicationStartupListener] into a set. */ @Module interface ApplicationStartupListenerModule { - @Multibinds fun bindStartupListenerSet(): Set } diff --git a/app/src/main/java/org/oppia/android/app/application/BUILD.bazel b/app/src/main/java/org/oppia/android/app/application/BUILD.bazel new file mode 100644 index 00000000000..9b2927ff303 --- /dev/null +++ b/app/src/main/java/org/oppia/android/app/application/BUILD.bazel @@ -0,0 +1,135 @@ +""" +This package contains all of the top-level infrastructure for the application entrypoint and root +Dagger graph. + +Specific application implementations can be found in subpackages. +""" + +load("@dagger//:workspace_defs.bzl", "dagger_rules") +load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") + +kt_android_library( + name = "abstract_application", + srcs = [ + "AbstractOppiaApplication.kt", + ], + visibility = [ + "//app/src/main/java/org/oppia/android/app/application:__subpackages__", + "//instrumentation/src/java/org/oppia/android/instrumentation/application:__pkg__", + ], + deps = [ + ":application_component", + ":application_injector", + ":application_injector_provider", + "//domain/src/main/java/org/oppia/android/domain/oppialogger:startup_listener", + "//third_party:androidx_work_work-runtime-ktx", + "//third_party:com_google_firebase_firebase-common", + ], +) + +kt_android_library( + name = "application_component", + srcs = [ + "ApplicationComponent.kt", + ], + visibility = [ + "//:oppia_testing_visibility", + "//app/src/main/java/org/oppia/android/app/application:__subpackages__", + ], + deps = [ + ":application_injector", + "//app", + "//domain/src/main/java/org/oppia/android/domain/oppialogger:startup_listener", + "//third_party:androidx_work_work-runtime-ktx", + ], +) + +kt_android_library( + name = "application_injector", + srcs = [ + "ApplicationInjector.kt", + ], + visibility = ["//:oppia_testing_visibility"], + deps = [ + "//app/src/main/java/org/oppia/android/app/translation:app_language_application_injector", + "//domain/src/main/java/org/oppia/android/domain/locale:locale_application_injector", + "//utility/src/main/java/org/oppia/android/util/logging:console_logger_injector", + "//utility/src/main/java/org/oppia/android/util/system:oppia_clock_injector", + "//utility/src/main/java/org/oppia/android/util/threading:dispatcher_injector", + ], +) + +kt_android_library( + name = "application_injector_provider", + srcs = [ + "ApplicationInjectorProvider.kt", + ], + visibility = ["//:oppia_testing_visibility"], + deps = [ + ":application_injector", + "//app/src/main/java/org/oppia/android/app/translation:app_language_application_injector_provider", + "//domain/src/main/java/org/oppia/android/domain/locale:locale_application_injector_provider", + "//utility/src/main/java/org/oppia/android/util/logging:console_logger_injector_provider", + "//utility/src/main/java/org/oppia/android/util/system:oppia_clock_injector_provider", + "//utility/src/main/java/org/oppia/android/util/threading:dispatcher_injector_provider", + ], +) + +kt_android_library( + name = "modules", + srcs = [ + "ApplicationModule.kt", + "ApplicationStartupListenerModule.kt", + ], + deps = [ + ":dagger", + "//app", + "//domain/src/main/java/org/oppia/android/domain/oppialogger:startup_listener", + ], +) + +# TODO(#1720): Remove this once the list can be automatically determined from the build graph. +android_library( + name = "common_application_modules", + visibility = [ + "//:oppia_testing_visibility", + "//app/src/main/java/org/oppia/android/app/application:__subpackages__", + ], + exports = [ + ":modules", + "//app/src/main/java/org/oppia/android/app/translation:prod_module", + "//data/src/main/java/org/oppia/android/data/backends/gae:network_config_prod_module", + "//data/src/main/java/org/oppia/android/data/backends/gae:prod_module", + "//domain/src/main/java/org/oppia/android/domain/classify:interactions_module", + "//domain/src/main/java/org/oppia/android/domain/classify/rules/algebraicexpressioninput:algebraic_expression_input_rule_module", + "//domain/src/main/java/org/oppia/android/domain/classify/rules/continueinteraction:continue_module", + "//domain/src/main/java/org/oppia/android/domain/classify/rules/dragAndDropSortInput:drag_and_drop_sort_input_module", + "//domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput:fraction_input_module", + "//domain/src/main/java/org/oppia/android/domain/classify/rules/imageClickInput:image_click_input_module", + "//domain/src/main/java/org/oppia/android/domain/classify/rules/itemselectioninput:item_selection_input_module", + "//domain/src/main/java/org/oppia/android/domain/classify/rules/mathequationinput:math_equation_input_rule_module", + "//domain/src/main/java/org/oppia/android/domain/classify/rules/multiplechoiceinput:multiple_choice_input_module", + "//domain/src/main/java/org/oppia/android/domain/classify/rules/numberwithunits:number_with_units_rule_module", + "//domain/src/main/java/org/oppia/android/domain/classify/rules/numericexpressioninput:numeric_expression_input_rule_module", + "//domain/src/main/java/org/oppia/android/domain/classify/rules/numericinput:numeric_input_rule_module", + "//domain/src/main/java/org/oppia/android/domain/classify/rules/ratioinput:ratio_input_module", + "//domain/src/main/java/org/oppia/android/domain/classify/rules/textinput:text_input_rule_module", + "//domain/src/main/java/org/oppia/android/domain/onboarding:retriever_prod_module", + "//domain/src/main/java/org/oppia/android/domain/oppialogger/analytics:prod_module", + "//domain/src/main/java/org/oppia/android/domain/oppialogger/exceptions:logger_module", + "//domain/src/main/java/org/oppia/android/domain/oppialogger/loguploader:worker_module", + "//utility/src/main/java/org/oppia/android/util/accessibility:prod_module", + "//utility/src/main/java/org/oppia/android/util/caching:asset_prod_module", + "//utility/src/main/java/org/oppia/android/util/caching:caching_prod_module", + "//utility/src/main/java/org/oppia/android/util/locale:prod_module", + "//utility/src/main/java/org/oppia/android/util/logging:prod_module", + "//utility/src/main/java/org/oppia/android/util/logging/firebase:prod_module", + "//utility/src/main/java/org/oppia/android/util/networking:debug_util_module", + "//utility/src/main/java/org/oppia/android/util/parser/html:html_parser_entity_type_module", + "//utility/src/main/java/org/oppia/android/util/parser/image:glide_image_loader_module", + "//utility/src/main/java/org/oppia/android/util/parser/image:image_parsing_module", + "//utility/src/main/java/org/oppia/android/util/parser/image:repository_glide_module", + ], +) + +dagger_rules() diff --git a/app/src/main/java/org/oppia/android/app/application/alpha/AlphaApplicationComponent.kt b/app/src/main/java/org/oppia/android/app/application/alpha/AlphaApplicationComponent.kt new file mode 100644 index 00000000000..8aa2c20f6bd --- /dev/null +++ b/app/src/main/java/org/oppia/android/app/application/alpha/AlphaApplicationComponent.kt @@ -0,0 +1,104 @@ +package org.oppia.android.app.application.alpha + +import dagger.Component +import org.oppia.android.app.application.ApplicationComponent +import org.oppia.android.app.application.ApplicationModule +import org.oppia.android.app.application.ApplicationStartupListenerModule +import org.oppia.android.app.devoptions.DeveloperOptionsModule +import org.oppia.android.app.player.state.itemviewmodel.SplitScreenInteractionModule +import org.oppia.android.app.shim.IntentFactoryShimModule +import org.oppia.android.app.shim.ViewBindingShimModule +import org.oppia.android.app.topic.PracticeTabModule +import org.oppia.android.app.translation.ActivityRecreatorProdModule +import org.oppia.android.data.backends.gae.NetworkConfigProdModule +import org.oppia.android.data.backends.gae.NetworkModule +import org.oppia.android.domain.classify.InteractionsModule +import org.oppia.android.domain.classify.rules.algebraicexpressioninput.AlgebraicExpressionInputModule +import org.oppia.android.domain.classify.rules.continueinteraction.ContinueModule +import org.oppia.android.domain.classify.rules.dragAndDropSortInput.DragDropSortInputModule +import org.oppia.android.domain.classify.rules.fractioninput.FractionInputModule +import org.oppia.android.domain.classify.rules.imageClickInput.ImageClickInputModule +import org.oppia.android.domain.classify.rules.itemselectioninput.ItemSelectionInputModule +import org.oppia.android.domain.classify.rules.mathequationinput.MathEquationInputModule +import org.oppia.android.domain.classify.rules.multiplechoiceinput.MultipleChoiceInputModule +import org.oppia.android.domain.classify.rules.numberwithunits.NumberWithUnitsRuleModule +import org.oppia.android.domain.classify.rules.numericexpressioninput.NumericExpressionInputModule +import org.oppia.android.domain.classify.rules.numericinput.NumericInputRuleModule +import org.oppia.android.domain.classify.rules.ratioinput.RatioInputModule +import org.oppia.android.domain.classify.rules.textinput.TextInputRuleModule +import org.oppia.android.domain.exploration.lightweightcheckpointing.ExplorationStorageModule +import org.oppia.android.domain.hintsandsolution.HintsAndSolutionConfigModule +import org.oppia.android.domain.hintsandsolution.HintsAndSolutionProdModule +import org.oppia.android.domain.onboarding.ExpirationMetaDataRetrieverModule +import org.oppia.android.domain.oppialogger.LogStorageModule +import org.oppia.android.domain.oppialogger.LoggingIdentifierModule +import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule +import org.oppia.android.domain.oppialogger.exceptions.UncaughtExceptionLoggerModule +import org.oppia.android.domain.oppialogger.loguploader.LogUploadWorkerModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule +import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule +import org.oppia.android.domain.platformparameter.syncup.PlatformParameterSyncUpWorkerModule +import org.oppia.android.domain.question.QuestionModule +import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule +import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.util.accessibility.AccessibilityProdModule +import org.oppia.android.util.caching.AssetModule +import org.oppia.android.util.caching.CachingModule +import org.oppia.android.util.gcsresource.GcsResourceModule +import org.oppia.android.util.locale.LocaleProdModule +import org.oppia.android.util.logging.LoggerModule +import org.oppia.android.util.logging.SyncStatusModule +import org.oppia.android.util.logging.firebase.FirebaseLogUploaderModule +import org.oppia.android.util.logging.firebase.LogReportingModule +import org.oppia.android.util.networking.NetworkConnectionDebugUtilModule +import org.oppia.android.util.networking.NetworkConnectionUtilProdModule +import org.oppia.android.util.parser.html.HtmlParserEntityTypeModule +import org.oppia.android.util.parser.image.GlideImageLoaderModule +import org.oppia.android.util.parser.image.ImageParsingModule +import org.oppia.android.util.system.OppiaClockModule +import org.oppia.android.util.threading.DispatcherModule +import javax.inject.Singleton + +/** + * Root Dagger component for alpha versions of the application. + * + * All application-scoped modules should be included in this component. + */ +@Singleton +@Component( + modules = [ + ApplicationModule::class, DispatcherModule::class, LoggerModule::class, OppiaClockModule::class, + ContinueModule::class, FractionInputModule::class, ItemSelectionInputModule::class, + MultipleChoiceInputModule::class, NumberWithUnitsRuleModule::class, + NumericInputRuleModule::class, TextInputRuleModule::class, DragDropSortInputModule::class, + InteractionsModule::class, GcsResourceModule::class, GlideImageLoaderModule::class, + ImageParsingModule::class, HtmlParserEntityTypeModule::class, CachingModule::class, + QuestionModule::class, AccessibilityProdModule::class, ImageClickInputModule::class, + LogStorageModule::class, IntentFactoryShimModule::class, ViewBindingShimModule::class, + PrimeTopicAssetsControllerModule::class, ExpirationMetaDataRetrieverModule::class, + RatioInputModule::class, UncaughtExceptionLoggerModule::class, + ApplicationStartupListenerModule::class, LogUploadWorkerModule::class, + WorkManagerConfigurationModule::class, HintsAndSolutionConfigModule::class, + FirebaseLogUploaderModule::class, NetworkModule::class, PracticeTabModule::class, + PlatformParameterModule::class, PlatformParameterSingletonModule::class, + ExplorationStorageModule::class, DeveloperOptionsModule::class, + PlatformParameterSyncUpWorkerModule::class, NetworkConfigProdModule::class, AssetModule::class, + LocaleProdModule::class, ActivityRecreatorProdModule::class, + NumericExpressionInputModule::class, AlgebraicExpressionInputModule::class, + MathEquationInputModule::class, SplitScreenInteractionModule::class, + LoggingIdentifierModule::class, ApplicationLifecycleModule::class, + NetworkConnectionDebugUtilModule::class, LoggingIdentifierModule::class, + SyncStatusModule::class, LogReportingModule::class, NetworkConnectionUtilProdModule::class, + HintsAndSolutionProdModule::class + ] +) +interface AlphaApplicationComponent : ApplicationComponent { + /** + * The [ApplicationComponent.Builder] for this component. Dagger will generate an implementation + * of this builder for use. + */ + @Component.Builder + interface Builder : ApplicationComponent.Builder { + override fun build(): AlphaApplicationComponent + } +} diff --git a/app/src/main/java/org/oppia/android/app/application/alpha/AlphaOppiaApplication.kt b/app/src/main/java/org/oppia/android/app/application/alpha/AlphaOppiaApplication.kt new file mode 100644 index 00000000000..c37a271e8e1 --- /dev/null +++ b/app/src/main/java/org/oppia/android/app/application/alpha/AlphaOppiaApplication.kt @@ -0,0 +1,6 @@ +package org.oppia.android.app.application.alpha + +import org.oppia.android.app.application.AbstractOppiaApplication + +/** The root [AbstractOppiaApplication] for alpha builds of the Oppia app. */ +class AlphaOppiaApplication : AbstractOppiaApplication(DaggerAlphaApplicationComponent::builder) diff --git a/app/src/main/java/org/oppia/android/app/application/alpha/BUILD.bazel b/app/src/main/java/org/oppia/android/app/application/alpha/BUILD.bazel new file mode 100644 index 00000000000..c0df9390ced --- /dev/null +++ b/app/src/main/java/org/oppia/android/app/application/alpha/BUILD.bazel @@ -0,0 +1,26 @@ +""" +This package contains the root application definitions for alpha builds of the app. +""" + +load("@dagger//:workspace_defs.bzl", "dagger_rules") +load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") + +kt_android_library( + name = "alpha_application", + srcs = [ + "AlphaApplicationComponent.kt", + "AlphaOppiaApplication.kt", + ], + visibility = ["//:oppia_binary_visibility"], + deps = [ + ":dagger", + "//app", + "//app/src/main/java/org/oppia/android/app/application:abstract_application", + "//app/src/main/java/org/oppia/android/app/application:application_component", + "//app/src/main/java/org/oppia/android/app/application:common_application_modules", + "//utility/src/main/java/org/oppia/android/util/logging/firebase:prod_module", + "//utility/src/main/java/org/oppia/android/util/networking:prod_module", + ], +) + +dagger_rules() diff --git a/app/src/main/java/org/oppia/android/app/application/dev/BUILD.bazel b/app/src/main/java/org/oppia/android/app/application/dev/BUILD.bazel new file mode 100644 index 00000000000..0b087d04fb9 --- /dev/null +++ b/app/src/main/java/org/oppia/android/app/application/dev/BUILD.bazel @@ -0,0 +1,30 @@ +""" +This package contains the root application definitions for developer builds of the app. + +Note that this will be the application configuration used for Gradle builds of the app. For Bazel, +there are specially defined top-level build flavors which will select their corresponding +application configuration. +""" + +load("@dagger//:workspace_defs.bzl", "dagger_rules") +load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") + +kt_android_library( + name = "developer_application", + srcs = [ + "DeveloperApplicationComponent.kt", + "DeveloperOppiaApplication.kt", + ], + visibility = ["//:oppia_binary_visibility"], + deps = [ + ":dagger", + "//app", + "//app/src/main/java/org/oppia/android/app/application:abstract_application", + "//app/src/main/java/org/oppia/android/app/application:application_component", + "//app/src/main/java/org/oppia/android/app/application:common_application_modules", + "//utility/src/main/java/org/oppia/android/util/logging/firebase:debug_module", + "//utility/src/main/java/org/oppia/android/util/networking:debug_module", + ], +) + +dagger_rules() diff --git a/app/src/main/java/org/oppia/android/app/application/dev/DeveloperApplicationComponent.kt b/app/src/main/java/org/oppia/android/app/application/dev/DeveloperApplicationComponent.kt new file mode 100644 index 00000000000..aee630025d2 --- /dev/null +++ b/app/src/main/java/org/oppia/android/app/application/dev/DeveloperApplicationComponent.kt @@ -0,0 +1,105 @@ +package org.oppia.android.app.application.dev + +import dagger.Component +import org.oppia.android.app.application.ApplicationComponent +import org.oppia.android.app.application.ApplicationModule +import org.oppia.android.app.application.ApplicationStartupListenerModule +import org.oppia.android.app.devoptions.DeveloperOptionsModule +import org.oppia.android.app.devoptions.DeveloperOptionsStarterModule +import org.oppia.android.app.player.state.itemviewmodel.SplitScreenInteractionModule +import org.oppia.android.app.shim.IntentFactoryShimModule +import org.oppia.android.app.shim.ViewBindingShimModule +import org.oppia.android.app.topic.PracticeTabModule +import org.oppia.android.app.translation.ActivityRecreatorProdModule +import org.oppia.android.data.backends.gae.NetworkConfigProdModule +import org.oppia.android.data.backends.gae.NetworkModule +import org.oppia.android.domain.classify.InteractionsModule +import org.oppia.android.domain.classify.rules.algebraicexpressioninput.AlgebraicExpressionInputModule +import org.oppia.android.domain.classify.rules.continueinteraction.ContinueModule +import org.oppia.android.domain.classify.rules.dragAndDropSortInput.DragDropSortInputModule +import org.oppia.android.domain.classify.rules.fractioninput.FractionInputModule +import org.oppia.android.domain.classify.rules.imageClickInput.ImageClickInputModule +import org.oppia.android.domain.classify.rules.itemselectioninput.ItemSelectionInputModule +import org.oppia.android.domain.classify.rules.mathequationinput.MathEquationInputModule +import org.oppia.android.domain.classify.rules.multiplechoiceinput.MultipleChoiceInputModule +import org.oppia.android.domain.classify.rules.numberwithunits.NumberWithUnitsRuleModule +import org.oppia.android.domain.classify.rules.numericexpressioninput.NumericExpressionInputModule +import org.oppia.android.domain.classify.rules.numericinput.NumericInputRuleModule +import org.oppia.android.domain.classify.rules.ratioinput.RatioInputModule +import org.oppia.android.domain.classify.rules.textinput.TextInputRuleModule +import org.oppia.android.domain.exploration.lightweightcheckpointing.ExplorationStorageModule +import org.oppia.android.domain.hintsandsolution.HintsAndSolutionConfigModule +import org.oppia.android.domain.hintsandsolution.HintsAndSolutionDebugModule +import org.oppia.android.domain.onboarding.ExpirationMetaDataRetrieverModule +import org.oppia.android.domain.oppialogger.LogStorageModule +import org.oppia.android.domain.oppialogger.LoggingIdentifierModule +import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule +import org.oppia.android.domain.oppialogger.exceptions.UncaughtExceptionLoggerModule +import org.oppia.android.domain.oppialogger.loguploader.LogUploadWorkerModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule +import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule +import org.oppia.android.domain.platformparameter.syncup.PlatformParameterSyncUpWorkerModule +import org.oppia.android.domain.question.QuestionModule +import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule +import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.util.accessibility.AccessibilityProdModule +import org.oppia.android.util.caching.AssetModule +import org.oppia.android.util.caching.CachingModule +import org.oppia.android.util.gcsresource.GcsResourceModule +import org.oppia.android.util.locale.LocaleProdModule +import org.oppia.android.util.logging.LoggerModule +import org.oppia.android.util.logging.SyncStatusModule +import org.oppia.android.util.logging.firebase.DebugLogReportingModule +import org.oppia.android.util.logging.firebase.FirebaseLogUploaderModule +import org.oppia.android.util.networking.NetworkConnectionDebugUtilModule +import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule +import org.oppia.android.util.parser.html.HtmlParserEntityTypeModule +import org.oppia.android.util.parser.image.GlideImageLoaderModule +import org.oppia.android.util.parser.image.ImageParsingModule +import org.oppia.android.util.system.OppiaClockModule +import org.oppia.android.util.threading.DispatcherModule +import javax.inject.Singleton + +/** + * Root Dagger component for developer versions of the application. + * + * All application-scoped modules should be included in this component. + */ +@Singleton +@Component( + modules = [ + ApplicationModule::class, DispatcherModule::class, LoggerModule::class, OppiaClockModule::class, + ContinueModule::class, FractionInputModule::class, ItemSelectionInputModule::class, + MultipleChoiceInputModule::class, NumberWithUnitsRuleModule::class, + NumericInputRuleModule::class, TextInputRuleModule::class, DragDropSortInputModule::class, + InteractionsModule::class, GcsResourceModule::class, GlideImageLoaderModule::class, + ImageParsingModule::class, HtmlParserEntityTypeModule::class, CachingModule::class, + QuestionModule::class, DebugLogReportingModule::class, AccessibilityProdModule::class, + ImageClickInputModule::class, LogStorageModule::class, IntentFactoryShimModule::class, + ViewBindingShimModule::class, PrimeTopicAssetsControllerModule::class, + ExpirationMetaDataRetrieverModule::class, RatioInputModule::class, + UncaughtExceptionLoggerModule::class, ApplicationStartupListenerModule::class, + LogUploadWorkerModule::class, WorkManagerConfigurationModule::class, + HintsAndSolutionConfigModule::class, HintsAndSolutionDebugModule::class, + FirebaseLogUploaderModule::class, NetworkModule::class, PracticeTabModule::class, + PlatformParameterModule::class, PlatformParameterSingletonModule::class, + ExplorationStorageModule::class, DeveloperOptionsStarterModule::class, + DeveloperOptionsModule::class, PlatformParameterSyncUpWorkerModule::class, + NetworkConnectionUtilDebugModule::class, NetworkConfigProdModule::class, AssetModule::class, + LocaleProdModule::class, ActivityRecreatorProdModule::class, + NumericExpressionInputModule::class, AlgebraicExpressionInputModule::class, + MathEquationInputModule::class, SplitScreenInteractionModule::class, + LoggingIdentifierModule::class, ApplicationLifecycleModule::class, + NetworkConnectionDebugUtilModule::class, LoggingIdentifierModule::class, SyncStatusModule::class + ] +) +interface DeveloperApplicationComponent : ApplicationComponent { + /** + * The [ApplicationComponent.Builder] for this component. Dagger will generate an implementation + * of this builder for use. + */ + @Component.Builder + interface Builder : ApplicationComponent.Builder { + override fun build(): DeveloperApplicationComponent + } +} diff --git a/app/src/main/java/org/oppia/android/app/application/dev/DeveloperOppiaApplication.kt b/app/src/main/java/org/oppia/android/app/application/dev/DeveloperOppiaApplication.kt new file mode 100644 index 00000000000..495a21d7a3e --- /dev/null +++ b/app/src/main/java/org/oppia/android/app/application/dev/DeveloperOppiaApplication.kt @@ -0,0 +1,8 @@ +package org.oppia.android.app.application.dev + +import org.oppia.android.app.application.AbstractOppiaApplication + +/** The root [AbstractOppiaApplication] for developer builds of the Oppia app. */ +class DeveloperOppiaApplication : AbstractOppiaApplication( + DaggerDeveloperApplicationComponent::builder +) diff --git a/app/src/main/java/org/oppia/android/app/translation/BUILD.bazel b/app/src/main/java/org/oppia/android/app/translation/BUILD.bazel index 3fb8eb46d02..e5bc20b3d81 100644 --- a/app/src/main/java/org/oppia/android/app/translation/BUILD.bazel +++ b/app/src/main/java/org/oppia/android/app/translation/BUILD.bazel @@ -120,6 +120,7 @@ kt_android_library( ], visibility = [ "//app/src/main/java/org/oppia/android/app/activity:__pkg__", + "//app/src/main/java/org/oppia/android/app/application:__pkg__", ], deps = [ ":app_language_locale_handler", @@ -133,6 +134,7 @@ kt_android_library( ], visibility = [ "//app/src/main/java/org/oppia/android/app/activity:__pkg__", + "//app/src/main/java/org/oppia/android/app/application:__pkg__", ], deps = [ ":app_language_application_injector", diff --git a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/BUILD.bazel b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/BUILD.bazel index 383d73493df..32688f31e7b 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/BUILD.bazel +++ b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/BUILD.bazel @@ -10,6 +10,10 @@ app_test( ":dagger", "//app", "//app:test_deps", + "//app/src/main/java/org/oppia/android/app/application:application_component", + "//app/src/main/java/org/oppia/android/app/application:application_injector", + "//app/src/main/java/org/oppia/android/app/application:application_injector_provider", + "//app/src/main/java/org/oppia/android/app/application:common_application_modules", "//app/src/main/java/org/oppia/android/app/translation/testing:test_module", "//testing", "//testing/src/main/java/org/oppia/android/testing/junit:initialize_default_locale_rule", @@ -24,6 +28,8 @@ app_test( "//utility/src/main/java/org/oppia/android/util/accessibility:test_module", "//utility/src/main/java/org/oppia/android/util/caching/testing:caching_test_module", "//utility/src/main/java/org/oppia/android/util/logging:prod_module", + "//utility/src/main/java/org/oppia/android/util/logging/firebase:debug_module", + "//utility/src/main/java/org/oppia/android/util/networking:debug_module", ], ) @@ -35,6 +41,10 @@ app_test( ":dagger", "//app", "//app:test_deps", + "//app/src/main/java/org/oppia/android/app/application:application_component", + "//app/src/main/java/org/oppia/android/app/application:application_injector", + "//app/src/main/java/org/oppia/android/app/application:application_injector_provider", + "//app/src/main/java/org/oppia/android/app/application:common_application_modules", "//app/src/main/java/org/oppia/android/app/translation/testing:test_module", "//testing", "//testing/src/main/java/org/oppia/android/testing/junit:initialize_default_locale_rule", @@ -50,6 +60,8 @@ app_test( "//utility/src/main/java/org/oppia/android/util/accessibility:test_module", "//utility/src/main/java/org/oppia/android/util/caching/testing:caching_test_module", "//utility/src/main/java/org/oppia/android/util/logging:prod_module", + "//utility/src/main/java/org/oppia/android/util/logging/firebase:debug_module", + "//utility/src/main/java/org/oppia/android/util/networking:debug_module", ], ) diff --git a/app/src/sharedTest/java/org/oppia/android/app/customview/interaction/BUILD.bazel b/app/src/sharedTest/java/org/oppia/android/app/customview/interaction/BUILD.bazel index f63fd4d52d8..d7571e7f1ac 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/customview/interaction/BUILD.bazel +++ b/app/src/sharedTest/java/org/oppia/android/app/customview/interaction/BUILD.bazel @@ -13,6 +13,10 @@ app_test( deps = [ ":dagger", "//app", + "//app/src/main/java/org/oppia/android/app/application:application_component", + "//app/src/main/java/org/oppia/android/app/application:application_injector", + "//app/src/main/java/org/oppia/android/app/application:application_injector_provider", + "//app/src/main/java/org/oppia/android/app/application:common_application_modules", "//app/src/main/java/org/oppia/android/app/translation/testing:test_module", "//testing", "//testing/src/main/java/org/oppia/android/testing/espresso:edit_text_input_action", @@ -30,6 +34,8 @@ app_test( "//third_party:robolectric_android-all", "//utility/src/main/java/org/oppia/android/util/accessibility:test_module", "//utility/src/main/java/org/oppia/android/util/caching/testing:caching_test_module", + "//utility/src/main/java/org/oppia/android/util/logging/firebase:debug_module", + "//utility/src/main/java/org/oppia/android/util/networking:debug_module", ], ) diff --git a/app/src/sharedTest/java/org/oppia/android/app/databinding/BUILD.bazel b/app/src/sharedTest/java/org/oppia/android/app/databinding/BUILD.bazel index 1279ddff613..e6c820172aa 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/databinding/BUILD.bazel +++ b/app/src/sharedTest/java/org/oppia/android/app/databinding/BUILD.bazel @@ -73,6 +73,10 @@ oppia_android_test( "//app", "//app:test_deps", "//app/src/main/java/org/oppia/android/app/activity:activity_intent_factories_shim", + "//app/src/main/java/org/oppia/android/app/application:application_component", + "//app/src/main/java/org/oppia/android/app/application:application_injector", + "//app/src/main/java/org/oppia/android/app/application:application_injector_provider", + "//app/src/main/java/org/oppia/android/app/application:common_application_modules", "//app/src/main/java/org/oppia/android/app/translation/testing:test_module", "//domain", "//testing", @@ -89,6 +93,8 @@ oppia_android_test( "//utility/src/main/java/org/oppia/android/util/caching/testing:caching_test_module", "//utility/src/main/java/org/oppia/android/util/data:data_providers", "//utility/src/main/java/org/oppia/android/util/logging:prod_module", + "//utility/src/main/java/org/oppia/android/util/logging/firebase:debug_module", + "//utility/src/main/java/org/oppia/android/util/networking:debug_module", ], ) @@ -103,6 +109,10 @@ oppia_android_test( "//app", "//app:test_deps", "//app/src/main/java/org/oppia/android/app/activity:activity_intent_factories_shim", + "//app/src/main/java/org/oppia/android/app/application:application_component", + "//app/src/main/java/org/oppia/android/app/application:application_injector", + "//app/src/main/java/org/oppia/android/app/application:application_injector_provider", + "//app/src/main/java/org/oppia/android/app/application:common_application_modules", "//app/src/main/java/org/oppia/android/app/translation/testing:test_module", "//domain", "//testing", @@ -119,6 +129,8 @@ oppia_android_test( "//utility/src/main/java/org/oppia/android/util/caching/testing:caching_test_module", "//utility/src/main/java/org/oppia/android/util/data:data_providers", "//utility/src/main/java/org/oppia/android/util/logging:prod_module", + "//utility/src/main/java/org/oppia/android/util/logging/firebase:debug_module", + "//utility/src/main/java/org/oppia/android/util/networking:debug_module", ], ) @@ -133,6 +145,10 @@ oppia_android_test( "//app", "//app:test_deps", "//app/src/main/java/org/oppia/android/app/activity:activity_intent_factories_shim", + "//app/src/main/java/org/oppia/android/app/application:application_component", + "//app/src/main/java/org/oppia/android/app/application:application_injector", + "//app/src/main/java/org/oppia/android/app/application:application_injector_provider", + "//app/src/main/java/org/oppia/android/app/application:common_application_modules", "//app/src/main/java/org/oppia/android/app/translation/testing:test_module", "//domain", "//testing", @@ -149,6 +165,8 @@ oppia_android_test( "//utility/src/main/java/org/oppia/android/util/caching/testing:caching_test_module", "//utility/src/main/java/org/oppia/android/util/data:data_providers", "//utility/src/main/java/org/oppia/android/util/logging:prod_module", + "//utility/src/main/java/org/oppia/android/util/logging/firebase:debug_module", + "//utility/src/main/java/org/oppia/android/util/networking:debug_module", ], ) @@ -163,6 +181,10 @@ oppia_android_test( "//app", "//app:test_deps", "//app/src/main/java/org/oppia/android/app/activity:activity_intent_factories_shim", + "//app/src/main/java/org/oppia/android/app/application:application_component", + "//app/src/main/java/org/oppia/android/app/application:application_injector", + "//app/src/main/java/org/oppia/android/app/application:application_injector_provider", + "//app/src/main/java/org/oppia/android/app/application:common_application_modules", "//app/src/main/java/org/oppia/android/app/translation/testing:test_module", "//domain", "//testing", @@ -179,6 +201,8 @@ oppia_android_test( "//utility/src/main/java/org/oppia/android/util/caching/testing:caching_test_module", "//utility/src/main/java/org/oppia/android/util/data:data_providers", "//utility/src/main/java/org/oppia/android/util/logging:prod_module", + "//utility/src/main/java/org/oppia/android/util/logging/firebase:debug_module", + "//utility/src/main/java/org/oppia/android/util/networking:debug_module", ], ) @@ -193,6 +217,10 @@ oppia_android_test( "//app", "//app:test_deps", "//app/src/main/java/org/oppia/android/app/activity:activity_intent_factories_shim", + "//app/src/main/java/org/oppia/android/app/application:application_component", + "//app/src/main/java/org/oppia/android/app/application:application_injector", + "//app/src/main/java/org/oppia/android/app/application:application_injector_provider", + "//app/src/main/java/org/oppia/android/app/application:common_application_modules", "//app/src/main/java/org/oppia/android/app/translation/testing:test_module", "//domain", "//testing", @@ -209,6 +237,8 @@ oppia_android_test( "//utility/src/main/java/org/oppia/android/util/caching/testing:caching_test_module", "//utility/src/main/java/org/oppia/android/util/data:data_providers", "//utility/src/main/java/org/oppia/android/util/logging:prod_module", + "//utility/src/main/java/org/oppia/android/util/logging/firebase:debug_module", + "//utility/src/main/java/org/oppia/android/util/networking:debug_module", ], ) @@ -223,6 +253,10 @@ oppia_android_test( "//app", "//app:test_deps", "//app/src/main/java/org/oppia/android/app/activity:activity_intent_factories_shim", + "//app/src/main/java/org/oppia/android/app/application:application_component", + "//app/src/main/java/org/oppia/android/app/application:application_injector", + "//app/src/main/java/org/oppia/android/app/application:application_injector_provider", + "//app/src/main/java/org/oppia/android/app/application:common_application_modules", "//app/src/main/java/org/oppia/android/app/translation/testing:test_module", "//domain", "//testing", @@ -239,6 +273,8 @@ oppia_android_test( "//utility/src/main/java/org/oppia/android/util/caching/testing:caching_test_module", "//utility/src/main/java/org/oppia/android/util/data:data_providers", "//utility/src/main/java/org/oppia/android/util/logging:prod_module", + "//utility/src/main/java/org/oppia/android/util/logging/firebase:debug_module", + "//utility/src/main/java/org/oppia/android/util/networking:debug_module", ], ) @@ -253,6 +289,10 @@ oppia_android_test( "//app", "//app:test_deps", "//app/src/main/java/org/oppia/android/app/activity:activity_intent_factories_shim", + "//app/src/main/java/org/oppia/android/app/application:application_component", + "//app/src/main/java/org/oppia/android/app/application:application_injector", + "//app/src/main/java/org/oppia/android/app/application:application_injector_provider", + "//app/src/main/java/org/oppia/android/app/application:common_application_modules", "//app/src/main/java/org/oppia/android/app/translation/testing:test_module", "//domain", "//testing", @@ -269,6 +309,8 @@ oppia_android_test( "//utility/src/main/java/org/oppia/android/util/caching/testing:caching_test_module", "//utility/src/main/java/org/oppia/android/util/data:data_providers", "//utility/src/main/java/org/oppia/android/util/logging:prod_module", + "//utility/src/main/java/org/oppia/android/util/logging/firebase:debug_module", + "//utility/src/main/java/org/oppia/android/util/networking:debug_module", ], ) diff --git a/app/src/sharedTest/java/org/oppia/android/app/devoptions/mathexpressionparser/BUILD.bazel b/app/src/sharedTest/java/org/oppia/android/app/devoptions/mathexpressionparser/BUILD.bazel index 6329deeae6f..b0d8810bf89 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/devoptions/mathexpressionparser/BUILD.bazel +++ b/app/src/sharedTest/java/org/oppia/android/app/devoptions/mathexpressionparser/BUILD.bazel @@ -13,6 +13,10 @@ app_test( deps = [ ":dagger", "//app", + "//app/src/main/java/org/oppia/android/app/application:application_component", + "//app/src/main/java/org/oppia/android/app/application:application_injector", + "//app/src/main/java/org/oppia/android/app/application:application_injector_provider", + "//app/src/main/java/org/oppia/android/app/application:common_application_modules", "//app/src/main/java/org/oppia/android/app/translation/testing:test_module", "//testing", "//testing/src/main/java/org/oppia/android/testing/espresso:edit_text_input_action", @@ -27,6 +31,8 @@ app_test( "//third_party:robolectric_android-all", "//utility/src/main/java/org/oppia/android/util/accessibility:test_module", "//utility/src/main/java/org/oppia/android/util/caching/testing:caching_test_module", + "//utility/src/main/java/org/oppia/android/util/logging/firebase:debug_module", + "//utility/src/main/java/org/oppia/android/util/networking:debug_module", ], ) @@ -37,6 +43,10 @@ app_test( deps = [ ":dagger", "//app", + "//app/src/main/java/org/oppia/android/app/application:application_component", + "//app/src/main/java/org/oppia/android/app/application:application_injector", + "//app/src/main/java/org/oppia/android/app/application:application_injector_provider", + "//app/src/main/java/org/oppia/android/app/application:common_application_modules", "//app/src/main/java/org/oppia/android/app/testing/activity:test_activity", "//app/src/main/java/org/oppia/android/app/translation/testing:test_module", "//testing", @@ -52,6 +62,8 @@ app_test( "//third_party:robolectric_android-all", "//utility/src/main/java/org/oppia/android/util/accessibility:test_module", "//utility/src/main/java/org/oppia/android/util/caching/testing:caching_test_module", + "//utility/src/main/java/org/oppia/android/util/logging/firebase:debug_module", + "//utility/src/main/java/org/oppia/android/util/networking:debug_module", ], ) diff --git a/app/src/sharedTest/java/org/oppia/android/app/player/state/BUILD.bazel b/app/src/sharedTest/java/org/oppia/android/app/player/state/BUILD.bazel index 631bf8ec398..457225f4fe4 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/player/state/BUILD.bazel +++ b/app/src/sharedTest/java/org/oppia/android/app/player/state/BUILD.bazel @@ -14,6 +14,10 @@ app_test( ":dagger", "//app", "//app:test_deps", + "//app/src/main/java/org/oppia/android/app/application:application_component", + "//app/src/main/java/org/oppia/android/app/application:application_injector", + "//app/src/main/java/org/oppia/android/app/application:application_injector_provider", + "//app/src/main/java/org/oppia/android/app/application:common_application_modules", "//app/src/main/java/org/oppia/android/app/translation/testing:test_module", "//data/src/main/java/org/oppia/android/data/backends/gae:prod_module", "//domain/src/main/java/org/oppia/android/domain/onboarding/testing:retriever_test_module", @@ -38,6 +42,7 @@ app_test( "//utility/src/main/java/org/oppia/android/util/data:data_providers", "//utility/src/main/java/org/oppia/android/util/locale/testing:test_module", "//utility/src/main/java/org/oppia/android/util/logging:prod_module", + "//utility/src/main/java/org/oppia/android/util/logging/firebase:debug_module", "//utility/src/main/java/org/oppia/android/util/networking:debug_module", "//utility/src/main/java/org/oppia/android/util/networking:debug_util_module", ], diff --git a/app/src/sharedTest/java/org/oppia/android/app/recyclerview/BindableAdapterTest.kt b/app/src/sharedTest/java/org/oppia/android/app/recyclerview/BindableAdapterTest.kt index a207a2e9a59..a0b1d3577a3 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/recyclerview/BindableAdapterTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/recyclerview/BindableAdapterTest.kt @@ -34,7 +34,6 @@ import org.oppia.android.app.activity.ActivityComponentImpl import org.oppia.android.app.activity.ActivityIntentFactoriesModule import org.oppia.android.app.activity.ActivityScope import org.oppia.android.app.application.ApplicationComponent -import org.oppia.android.app.application.ApplicationContext import org.oppia.android.app.application.ApplicationInjector import org.oppia.android.app.application.ApplicationInjectorProvider import org.oppia.android.app.application.ApplicationStartupListenerModule @@ -732,11 +731,7 @@ class BindableAdapterTest { @Module(subcomponents = [TestActivityComponent::class]) interface TestApplicationModule { @Binds - @ApplicationContext - fun provideApplicationContext(application: Application): Context - - @Binds - fun provideContext(@ApplicationContext context: Context): Context + fun provideContext(application: Application): Context // Bridge the test & original ActivityComponent builders to properly hook up the :replacement // test subcomponent. diff --git a/app/src/test/java/org/oppia/android/app/activity/BUILD.bazel b/app/src/test/java/org/oppia/android/app/activity/BUILD.bazel index 1b94e416f2b..a3c4e616851 100644 --- a/app/src/test/java/org/oppia/android/app/activity/BUILD.bazel +++ b/app/src/test/java/org/oppia/android/app/activity/BUILD.bazel @@ -15,6 +15,10 @@ oppia_android_test( ":dagger", "//app", "//app/src/main/java/org/oppia/android/app/activity:activity_intent_factories_shim", + "//app/src/main/java/org/oppia/android/app/application:application_component", + "//app/src/main/java/org/oppia/android/app/application:application_injector", + "//app/src/main/java/org/oppia/android/app/application:application_injector_provider", + "//app/src/main/java/org/oppia/android/app/application:common_application_modules", "//app/src/main/java/org/oppia/android/app/translation/testing:test_module", "//domain", "//domain/src/main/java/org/oppia/android/domain/classify:interactions_module", @@ -33,6 +37,8 @@ oppia_android_test( "//utility/src/main/java/org/oppia/android/util/caching/testing:caching_test_module", "//utility/src/main/java/org/oppia/android/util/data:data_providers", "//utility/src/main/java/org/oppia/android/util/logging:prod_module", + "//utility/src/main/java/org/oppia/android/util/logging/firebase:debug_module", + "//utility/src/main/java/org/oppia/android/util/networking:debug_module", ], ) diff --git a/app/src/test/java/org/oppia/android/app/devoptions/devoptionsitemviewmodel/BUILD.bazel b/app/src/test/java/org/oppia/android/app/devoptions/devoptionsitemviewmodel/BUILD.bazel index 5f9ce1e46d2..55d5000dbd8 100644 --- a/app/src/test/java/org/oppia/android/app/devoptions/devoptionsitemviewmodel/BUILD.bazel +++ b/app/src/test/java/org/oppia/android/app/devoptions/devoptionsitemviewmodel/BUILD.bazel @@ -12,9 +12,15 @@ oppia_android_test( test_manifest = "//app:test_manifest", deps = [ "//app", + "//app/src/main/java/org/oppia/android/app/application:application_component", + "//app/src/main/java/org/oppia/android/app/application:application_injector", + "//app/src/main/java/org/oppia/android/app/application:application_injector_provider", + "//app/src/main/java/org/oppia/android/app/application:common_application_modules", "//third_party:junit_junit", "//third_party:org_mockito_mockito-core", "//third_party:org_robolectric_robolectric", "//third_party:robolectric_android-all", + "//utility/src/main/java/org/oppia/android/util/logging/firebase:debug_module", + "//utility/src/main/java/org/oppia/android/util/networking:debug_module", ], ) diff --git a/app/src/test/java/org/oppia/android/app/player/state/StateFragmentLocalTest.kt b/app/src/test/java/org/oppia/android/app/player/state/StateFragmentLocalTest.kt index 4fe37db7c6f..7e5c339ef1b 100644 --- a/app/src/test/java/org/oppia/android/app/player/state/StateFragmentLocalTest.kt +++ b/app/src/test/java/org/oppia/android/app/player/state/StateFragmentLocalTest.kt @@ -54,7 +54,6 @@ import org.oppia.android.R import org.oppia.android.app.activity.ActivityComponent import org.oppia.android.app.activity.ActivityComponentFactory import org.oppia.android.app.application.ApplicationComponent -import org.oppia.android.app.application.ApplicationContext import org.oppia.android.app.application.ApplicationInjector import org.oppia.android.app.application.ApplicationInjectorProvider import org.oppia.android.app.application.ApplicationModule @@ -191,7 +190,6 @@ class StateFragmentLocalTest { lateinit var testCoroutineDispatchers: TestCoroutineDispatchers @Inject - @field:ApplicationContext lateinit var context: Context @Inject diff --git a/app/src/test/java/org/oppia/android/app/testing/activity/BUILD.bazel b/app/src/test/java/org/oppia/android/app/testing/activity/BUILD.bazel index 0b005e08fb7..e56a257b618 100644 --- a/app/src/test/java/org/oppia/android/app/testing/activity/BUILD.bazel +++ b/app/src/test/java/org/oppia/android/app/testing/activity/BUILD.bazel @@ -14,6 +14,10 @@ oppia_android_test( deps = [ ":dagger", "//app", + "//app/src/main/java/org/oppia/android/app/application:application_component", + "//app/src/main/java/org/oppia/android/app/application:application_injector", + "//app/src/main/java/org/oppia/android/app/application:application_injector_provider", + "//app/src/main/java/org/oppia/android/app/application:common_application_modules", "//app/src/main/java/org/oppia/android/app/testing/activity:test_activity", "//app/src/main/java/org/oppia/android/app/translation/testing:test_module", "//domain", @@ -35,6 +39,7 @@ oppia_android_test( "//utility/src/main/java/org/oppia/android/util/locale:prod_module", "//utility/src/main/java/org/oppia/android/util/locale/testing:test_module", "//utility/src/main/java/org/oppia/android/util/logging:prod_module", + "//utility/src/main/java/org/oppia/android/util/logging/firebase:debug_module", "//utility/src/main/java/org/oppia/android/util/networking:debug_module", "//utility/src/main/java/org/oppia/android/util/networking:debug_util_module", ], diff --git a/app/src/test/java/org/oppia/android/app/testing/player/state/StateFragmentAccessibilityTest.kt b/app/src/test/java/org/oppia/android/app/testing/player/state/StateFragmentAccessibilityTest.kt index 24565f44dd7..8c22af7c2d9 100644 --- a/app/src/test/java/org/oppia/android/app/testing/player/state/StateFragmentAccessibilityTest.kt +++ b/app/src/test/java/org/oppia/android/app/testing/player/state/StateFragmentAccessibilityTest.kt @@ -20,7 +20,6 @@ import org.oppia.android.R import org.oppia.android.app.activity.ActivityComponent import org.oppia.android.app.activity.ActivityComponentFactory import org.oppia.android.app.application.ApplicationComponent -import org.oppia.android.app.application.ApplicationContext import org.oppia.android.app.application.ApplicationInjector import org.oppia.android.app.application.ApplicationInjectorProvider import org.oppia.android.app.application.ApplicationModule @@ -108,7 +107,6 @@ class StateFragmentAccessibilityTest { lateinit var testCoroutineDispatchers: TestCoroutineDispatchers @Inject - @field:ApplicationContext lateinit var context: Context @Inject diff --git a/app/src/test/java/org/oppia/android/app/topic/questionplayer/QuestionPlayerActivityLocalTest.kt b/app/src/test/java/org/oppia/android/app/topic/questionplayer/QuestionPlayerActivityLocalTest.kt index 3af85d95b99..35862612657 100644 --- a/app/src/test/java/org/oppia/android/app/topic/questionplayer/QuestionPlayerActivityLocalTest.kt +++ b/app/src/test/java/org/oppia/android/app/topic/questionplayer/QuestionPlayerActivityLocalTest.kt @@ -31,7 +31,6 @@ import org.oppia.android.R import org.oppia.android.app.activity.ActivityComponent import org.oppia.android.app.activity.ActivityComponentFactory import org.oppia.android.app.application.ApplicationComponent -import org.oppia.android.app.application.ApplicationContext import org.oppia.android.app.application.ApplicationInjector import org.oppia.android.app.application.ApplicationInjectorProvider import org.oppia.android.app.application.ApplicationModule @@ -136,7 +135,6 @@ class QuestionPlayerActivityLocalTest { lateinit var testCoroutineDispatchers: TestCoroutineDispatchers @Inject - @field:ApplicationContext lateinit var context: Context @Inject diff --git a/app/src/test/java/org/oppia/android/app/translation/BUILD.bazel b/app/src/test/java/org/oppia/android/app/translation/BUILD.bazel index b0e7a26150e..5777d66c61e 100644 --- a/app/src/test/java/org/oppia/android/app/translation/BUILD.bazel +++ b/app/src/test/java/org/oppia/android/app/translation/BUILD.bazel @@ -49,6 +49,10 @@ oppia_android_test( deps = [ ":dagger", "//app", + "//app/src/main/java/org/oppia/android/app/application:application_component", + "//app/src/main/java/org/oppia/android/app/application:application_injector", + "//app/src/main/java/org/oppia/android/app/application:application_injector_provider", + "//app/src/main/java/org/oppia/android/app/application:common_application_modules", "//app/src/main/java/org/oppia/android/app/translation:app_language_locale_handler", "//app/src/main/java/org/oppia/android/app/translation/testing:test_module", "//domain", @@ -75,6 +79,7 @@ oppia_android_test( "//utility/src/main/java/org/oppia/android/util/locale/testing:test_module", "//utility/src/main/java/org/oppia/android/util/locale/testing:test_oppia_bidi_formatter", "//utility/src/main/java/org/oppia/android/util/logging:prod_module", + "//utility/src/main/java/org/oppia/android/util/logging/firebase:debug_module", "//utility/src/main/java/org/oppia/android/util/networking:debug_module", "//utility/src/main/java/org/oppia/android/util/networking:debug_util_module", "//utility/src/main/java/org/oppia/android/util/system:prod_module", @@ -90,6 +95,10 @@ oppia_android_test( deps = [ ":dagger", "//app", + "//app/src/main/java/org/oppia/android/app/application:application_component", + "//app/src/main/java/org/oppia/android/app/application:application_injector", + "//app/src/main/java/org/oppia/android/app/application:application_injector_provider", + "//app/src/main/java/org/oppia/android/app/application:common_application_modules", "//app/src/main/java/org/oppia/android/app/translation/testing:test_module", "//data/src/main/java/org/oppia/android/data/backends/gae:prod_module", "//domain/src/main/java/org/oppia/android/domain/onboarding/testing:retriever_test_module", @@ -113,6 +122,7 @@ oppia_android_test( "//utility/src/main/java/org/oppia/android/util/data:data_providers", "//utility/src/main/java/org/oppia/android/util/locale/testing:test_module", "//utility/src/main/java/org/oppia/android/util/logging:prod_module", + "//utility/src/main/java/org/oppia/android/util/logging/firebase:debug_module", "//utility/src/main/java/org/oppia/android/util/networking:debug_module", "//utility/src/main/java/org/oppia/android/util/networking:debug_util_module", "//utility/src/main/java/org/oppia/android/util/system:prod_module", diff --git a/app/src/test/java/org/oppia/android/app/utility/math/BUILD.bazel b/app/src/test/java/org/oppia/android/app/utility/math/BUILD.bazel index 3f5ff80c424..b50532b834d 100644 --- a/app/src/test/java/org/oppia/android/app/utility/math/BUILD.bazel +++ b/app/src/test/java/org/oppia/android/app/utility/math/BUILD.bazel @@ -14,6 +14,10 @@ oppia_android_test( deps = [ ":dagger", "//app", + "//app/src/main/java/org/oppia/android/app/application:application_component", + "//app/src/main/java/org/oppia/android/app/application:application_injector", + "//app/src/main/java/org/oppia/android/app/application:application_injector_provider", + "//app/src/main/java/org/oppia/android/app/application:common_application_modules", "//app/src/main/java/org/oppia/android/app/translation/testing:test_module", "//app/src/main/java/org/oppia/android/app/utility/math:math_expression_accessibility_util", "//domain/src/main/java/org/oppia/android/domain/onboarding/testing:retriever_test_module", @@ -39,6 +43,7 @@ oppia_android_test( "//utility/src/main/java/org/oppia/android/util/caching/testing:caching_test_module", "//utility/src/main/java/org/oppia/android/util/locale/testing:test_module", "//utility/src/main/java/org/oppia/android/util/logging:prod_module", + "//utility/src/main/java/org/oppia/android/util/logging/firebase:debug_module", "//utility/src/main/java/org/oppia/android/util/math:math_expression_parser", "//utility/src/main/java/org/oppia/android/util/networking:debug_module", "//utility/src/main/java/org/oppia/android/util/networking:debug_util_module", diff --git a/build_flavors.bzl b/build_flavors.bzl index a42b3d916c3..e5bf54adb2f 100644 --- a/build_flavors.bzl +++ b/build_flavors.bzl @@ -47,9 +47,10 @@ _FLAVOR_METADATA = { "proguard_specs": [], # Developer builds are not optimized. "production_release": False, "deps": [ - "//app", + "//app/src/main/java/org/oppia/android/app/application/dev:developer_application", ], "version_code": OPPIA_DEV_VERSION_CODE, + "application_class": ".app.application.dev.DeveloperOppiaApplication", }, "dev_kitkat": { "manifest": "//app:src/main/AndroidManifest.xml", @@ -60,9 +61,10 @@ _FLAVOR_METADATA = { "proguard_specs": [], # Developer builds are not optimized. "production_release": False, "deps": [ - "//app", + "//app/src/main/java/org/oppia/android/app/application/dev:developer_application", ], "version_code": OPPIA_DEV_KITKAT_VERSION_CODE, + "application_class": ".app.application.dev.DeveloperOppiaApplication", }, "alpha": { "manifest": "//app:src/main/AndroidManifest.xml", @@ -72,9 +74,10 @@ _FLAVOR_METADATA = { "proguard_specs": _PRODUCTION_PROGUARD_SPECS, "production_release": True, "deps": [ - "//app", + "//app/src/main/java/org/oppia/android/app/application/alpha:alpha_application", ], "version_code": OPPIA_ALPHA_VERSION_CODE, + "application_class": ".app.application.alpha.AlphaOppiaApplication", }, "alpha_kitkat": { "manifest": "//app:src/main/AndroidManifest.xml", @@ -85,9 +88,10 @@ _FLAVOR_METADATA = { "proguard_specs": [], # TODO(#3886): Re-add Proguard support to alpha_kitkat. "production_release": True, "deps": [ - "//app", + "//app/src/main/java/org/oppia/android/app/application/alpha:alpha_application", ], "version_code": OPPIA_ALPHA_KITKAT_VERSION_CODE, + "application_class": ".app.application.alpha.AlphaOppiaApplication", }, } @@ -99,6 +103,7 @@ def _transform_android_manifest_impl(ctx): major_version = ctx.attr.major_version minor_version = ctx.attr.minor_version version_code = ctx.attr.version_code + application_relative_qualified_class = ctx.attr.application_relative_qualified_class # See corresponding transformation script for details on the passed arguments. arguments = [ @@ -109,6 +114,7 @@ def _transform_android_manifest_impl(ctx): "%s" % major_version, "%s" % minor_version, "%s" % version_code, + "%s" % application_relative_qualified_class, "origin/develop", # The base branch for computing the version name. ] @@ -144,6 +150,7 @@ _transform_android_manifest = rule( "major_version": attr.int(mandatory = True), "minor_version": attr.int(mandatory = True), "version_code": attr.int(mandatory = True), + "application_relative_qualified_class": attr.string(mandatory = True), "_transform_android_manifest_tool": attr.label( executable = True, cfg = "host", @@ -160,7 +167,8 @@ def transform_android_manifest( build_flavor, major_version, minor_version, - version_code): + version_code, + application_relative_qualified_class): """ Generates a new transformation of the specified AndroidManifest.xml. @@ -177,6 +185,8 @@ def transform_android_manifest( major_version: int. The major version of the app. minor_version: int. The minor version of the app. version_code: int. The version code of this flavor of the app. + application_relative_qualified_class: String. The relatively qualified main application + class of the app for this build flavor. """ _transform_android_manifest( name = name, @@ -187,6 +197,7 @@ def transform_android_manifest( major_version = major_version, minor_version = minor_version, version_code = version_code, + application_relative_qualified_class = application_relative_qualified_class, ) def define_oppia_aab_binary_flavor(flavor): @@ -206,6 +217,7 @@ def define_oppia_aab_binary_flavor(flavor): """ transform_android_manifest( name = "oppia_%s_transformed_manifest" % flavor, + application_relative_qualified_class = _FLAVOR_METADATA[flavor]["application_class"], input_file = _FLAVOR_METADATA[flavor]["manifest"], output_file = "AndroidManifest_transformed_%s.xml" % flavor, build_flavor = flavor, diff --git a/data/src/main/java/org/oppia/android/data/persistence/PersistentCacheStore.kt b/data/src/main/java/org/oppia/android/data/persistence/PersistentCacheStore.kt index b1c131bc498..daacb9b8822 100644 --- a/data/src/main/java/org/oppia/android/data/persistence/PersistentCacheStore.kt +++ b/data/src/main/java/org/oppia/android/data/persistence/PersistentCacheStore.kt @@ -306,8 +306,6 @@ class PersistentCacheStore private constructor( private data class CachePayload(val state: CacheState, val value: T) - // TODO(#59): Use @ApplicationContext instead of Context once package dependencies allow for - // cross-module circular ependencies. Currently, the data module cannot depend on the app module. /** * An injectable factory for [PersistentCacheStore]s. The stores themselves should be retrievable * from central controllers since they can't be placed directly in the Dagger graph. diff --git a/domain/src/main/java/org/oppia/android/domain/locale/BUILD.bazel b/domain/src/main/java/org/oppia/android/domain/locale/BUILD.bazel index a62092b664e..392a52b317f 100644 --- a/domain/src/main/java/org/oppia/android/domain/locale/BUILD.bazel +++ b/domain/src/main/java/org/oppia/android/domain/locale/BUILD.bazel @@ -92,7 +92,7 @@ kt_android_library( "LocaleApplicationInjector.kt", ], visibility = [ - "//app:__pkg__", + "//app/src/main/java/org/oppia/android/app/application:__pkg__", "//testing/src/main/java/org/oppia/android/testing/junit:__pkg__", ], deps = [ @@ -106,7 +106,7 @@ kt_android_library( "LocaleApplicationInjectorProvider.kt", ], visibility = [ - "//app:__pkg__", + "//app/src/main/java/org/oppia/android/app/application:__pkg__", "//testing/src/main/java/org/oppia/android/testing/junit:__pkg__", ], deps = [ diff --git a/instrumentation/src/java/AndroidManifest.xml b/instrumentation/src/java/AndroidManifest.xml index 847486b0240..3db0b5f7c51 100644 --- a/instrumentation/src/java/AndroidManifest.xml +++ b/instrumentation/src/java/AndroidManifest.xml @@ -7,7 +7,7 @@ - - fun getApplicationStartupListeners(): Set - - fun getWorkManagerConfiguration(): Configuration } diff --git a/instrumentation/src/java/org/oppia/android/instrumentation/application/TestOppiaApplication.kt b/instrumentation/src/java/org/oppia/android/instrumentation/application/TestOppiaApplication.kt new file mode 100644 index 00000000000..9fbe3666675 --- /dev/null +++ b/instrumentation/src/java/org/oppia/android/instrumentation/application/TestOppiaApplication.kt @@ -0,0 +1,6 @@ +package org.oppia.android.instrumentation.application + +import org.oppia.android.app.application.AbstractOppiaApplication + +/** The root [Application] of the all end-to-end test apps. */ +class TestOppiaApplication : AbstractOppiaApplication(DaggerTestApplicationComponent::builder) diff --git a/scripts/assets/maven_dependencies.textproto b/scripts/assets/maven_dependencies.textproto index 63b0bca6b08..ddb692a40f3 100644 --- a/scripts/assets/maven_dependencies.textproto +++ b/scripts/assets/maven_dependencies.textproto @@ -503,61 +503,6 @@ maven_dependency { } } } -maven_dependency { - artifact_name: "androidx.annotation:annotation-experimental:1.0.0" - artifact_version: "1.0.0" - license { - license_name: "The Apache Software License, Version 2.0" - original_link: "https://www.apache.org/licenses/LICENSE-2.0.txt" - scrapable_link { - url: "https://www.apache.org/licenses/LICENSE-2.0.txt" - } - } -} -maven_dependency { - artifact_name: "androidx.cardview:cardview:1.0.0" - artifact_version: "1.0.0" - license { - license_name: "The Apache Software License, Version 2.0" - original_link: "https://www.apache.org/licenses/LICENSE-2.0.txt" - scrapable_link { - url: "https://www.apache.org/licenses/LICENSE-2.0.txt" - } - } -} -maven_dependency { - artifact_name: "androidx.coordinatorlayout:coordinatorlayout:1.1.0" - artifact_version: "1.1.0" - license { - license_name: "The Apache Software License, Version 2.0" - original_link: "https://www.apache.org/licenses/LICENSE-2.0.txt" - scrapable_link { - url: "https://www.apache.org/licenses/LICENSE-2.0.txt" - } - } -} -maven_dependency { - artifact_name: "androidx.transition:transition:1.2.0" - artifact_version: "1.2.0" - license { - license_name: "The Apache Software License, Version 2.0" - original_link: "https://www.apache.org/licenses/LICENSE-2.0.txt" - scrapable_link { - url: "https://www.apache.org/licenses/LICENSE-2.0.txt" - } - } -} -maven_dependency { - artifact_name: "androidx.vectordrawable:vectordrawable:1.1.0" - artifact_version: "1.1.0" - license { - license_name: "The Apache Software License, Version 2.0" - original_link: "https://www.apache.org/licenses/LICENSE-2.0.txt" - scrapable_link { - url: "https://www.apache.org/licenses/LICENSE-2.0.txt" - } - } -} maven_dependency { artifact_name: "com.google.android.material:material:1.3.0" artifact_version: "1.3.0" @@ -633,6 +578,17 @@ maven_dependency { } } } +maven_dependency { + artifact_name: "com.google.firebase:firebase-common:19.3.0" + artifact_version: "19.3.0" + license { + license_name: "The Apache Software License, Version 2.0" + original_link: "https://www.apache.org/licenses/LICENSE-2.0.txt" + scrapable_link { + url: "https://www.apache.org/licenses/LICENSE-2.0.txt" + } + } +} maven_dependency { artifact_name: "com.google.firebase:firebase-crashlytics:17.1.1" artifact_version: "17.1.1" diff --git a/scripts/assets/test_file_exemptions.textproto b/scripts/assets/test_file_exemptions.textproto index ad6b4398d00..71a0bc61c76 100644 --- a/scripts/assets/test_file_exemptions.textproto +++ b/scripts/assets/test_file_exemptions.textproto @@ -38,6 +38,7 @@ exempted_file_path: "app/src/main/java/org/oppia/android/app/administratorcontro exempted_file_path: "app/src/main/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileLearnerIdItemViewModel.kt" exempted_file_path: "app/src/main/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileListViewModel.kt" exempted_file_path: "app/src/main/java/org/oppia/android/app/administratorcontrols/learneranalytics/SyncStatusItemViewModel.kt" +exempted_file_path: "app/src/main/java/org/oppia/android/app/application/AbstractOppiaApplication.kt" exempted_file_path: "app/src/main/java/org/oppia/android/app/application/ActivityComponentFactory.kt" exempted_file_path: "app/src/main/java/org/oppia/android/app/application/ApplicationComponent.kt" exempted_file_path: "app/src/main/java/org/oppia/android/app/application/ApplicationContext.kt" @@ -45,7 +46,10 @@ exempted_file_path: "app/src/main/java/org/oppia/android/app/application/Applica exempted_file_path: "app/src/main/java/org/oppia/android/app/application/ApplicationInjectorProvider.kt" exempted_file_path: "app/src/main/java/org/oppia/android/app/application/ApplicationModule.kt" exempted_file_path: "app/src/main/java/org/oppia/android/app/application/ApplicationStartupListenerModule.kt" -exempted_file_path: "app/src/main/java/org/oppia/android/app/application/OppiaApplication.kt" +exempted_file_path: "app/src/main/java/org/oppia/android/app/application/alpha/AlphaOppiaApplication.kt" +exempted_file_path: "app/src/main/java/org/oppia/android/app/application/alpha/AlphaApplicationComponent.kt" +exempted_file_path: "app/src/main/java/org/oppia/android/app/application/dev/DeveloperOppiaApplication.kt" +exempted_file_path: "app/src/main/java/org/oppia/android/app/application/dev/DeveloperApplicationComponent.kt" exempted_file_path: "app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryItemViewModel.kt" exempted_file_path: "app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryListActivityPresenter.kt" exempted_file_path: "app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryListFragment.kt" @@ -646,8 +650,8 @@ exempted_file_path: "domain/src/main/java/org/oppia/android/domain/util/JsonExte exempted_file_path: "domain/src/main/java/org/oppia/android/domain/util/WorkDataExtensions.kt" exempted_file_path: "domain/src/main/java/org/oppia/android/domain/workmanager/WorkManagerConfigurationModule.kt" exempted_file_path: "domain/src/test/java/org/oppia/android/domain/classify/InteractionObjectTestBuilder.kt" -exempted_file_path: "instrumentation/src/java/org/oppia/android/instrumentation/application/OppiaTestApplication.kt" exempted_file_path: "instrumentation/src/java/org/oppia/android/instrumentation/application/TestApplicationComponent.kt" +exempted_file_path: "instrumentation/src/java/org/oppia/android/instrumentation/application/TestOppiaApplication.kt" exempted_file_path: "instrumentation/src/java/org/oppia/android/instrumentation/testing/EndToEndTestHelper.kt" exempted_file_path: "scripts/src/java/org/oppia/android/scripts/common/CommandExecutor.kt" exempted_file_path: "scripts/src/java/org/oppia/android/scripts/common/CommandResult.kt" diff --git a/scripts/src/java/org/oppia/android/scripts/build/TransformAndroidManifest.kt b/scripts/src/java/org/oppia/android/scripts/build/TransformAndroidManifest.kt index fc5ec90d7e0..51732748d68 100644 --- a/scripts/src/java/org/oppia/android/scripts/build/TransformAndroidManifest.kt +++ b/scripts/src/java/org/oppia/android/scripts/build/TransformAndroidManifest.kt @@ -2,6 +2,7 @@ package org.oppia.android.scripts.build import org.oppia.android.scripts.common.GitClient import org.w3c.dom.Document +import org.w3c.dom.NodeList import java.io.File import java.io.StringWriter import javax.xml.parsers.DocumentBuilderFactory @@ -14,7 +15,7 @@ private const val USAGE_STRING = " " + " " + " " + - "" + " " /** * The main entrypoint for transforming an AndroidManifest to include both a version code and @@ -38,6 +39,7 @@ private const val USAGE_STRING = * \\ * \\ * \\ + * \\ * * * Arguments: @@ -54,10 +56,10 @@ private const val USAGE_STRING = * Example: * bazel run //scripts:transform_android_manifest -- $(pwd) \\ * $(pwd)/app/src/main/AndroidManifest.xml $(pwd)/TransformedAndroidManifest.xml alpha 0 6 6 \\ - * origin/develop + * .app.application.alpha.AlphaOppiaApplication origin/develop */ fun main(args: Array) { - check(args.size >= 8) { USAGE_STRING } + check(args.size >= 9) { USAGE_STRING } val repoRoot = File(args[0]).also { if (!it.exists()) error("File doesn't exist: ${args[0]}") } TransformAndroidManifest( @@ -72,7 +74,8 @@ fun main(args: Array) { majorVersion = args[4].toIntOrNull() ?: error(USAGE_STRING), minorVersion = args[5].toIntOrNull() ?: error(USAGE_STRING), versionCode = args[6].toIntOrNull() ?: error(USAGE_STRING), - baseDevelopBranchReference = args[7] + relativelyQualifiedApplicationClass = args[7], + baseDevelopBranchReference = args[8] ).generateAndOutputNewManifest() } @@ -84,6 +87,7 @@ private class TransformAndroidManifest( private val majorVersion: Int, private val minorVersion: Int, private val versionCode: Int, + private val relativelyQualifiedApplicationClass: String, private val baseDevelopBranchReference: String ) { private val gitClient by lazy { @@ -107,11 +111,26 @@ private class TransformAndroidManifest( buildFlavor, majorVersion, minorVersion, commitHash = gitClient.branchMergeBase ) } + val applicationNameAttribute = manifestDocument.createAttribute("android:name").apply { + value = relativelyQualifiedApplicationClass + } + val replaceNameAttribute = manifestDocument.createAttribute("tools:replace").apply { + // Other manifests may define duplicate names. Make sure the manifest merger knows to + // prioritize this name. + value = "android:name" + } val manifestNode = manifestDocument.childNodes.item(0) manifestNode.attributes.apply { setNamedItem(versionCodeAttribute) setNamedItem(versionNameAttribute) } + val applicationNode = + manifestNode.childNodes.asSequence().find { it.nodeName == "application" } + ?: error("Failed to find an 'application' tag in manifest.") + applicationNode.attributes.apply { + setNamedItem(applicationNameAttribute) + setNamedItem(replaceNameAttribute) + } // Output the new transformed manifest. outputManifestFile.writeText(manifestDocument.toSource()) @@ -135,4 +154,8 @@ private class TransformAndroidManifest( transformer.transform(DOMSource(this@toSource), StreamResult(this@apply)) }.toString() } + + private companion object { + private fun NodeList.asSequence() = (0 until length).asSequence().map { item(it) } + } } diff --git a/scripts/src/javatests/org/oppia/android/scripts/build/TransformAndroidManifestTest.kt b/scripts/src/javatests/org/oppia/android/scripts/build/TransformAndroidManifestTest.kt index 02889cc08bd..fadf3154983 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/build/TransformAndroidManifestTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/build/TransformAndroidManifestTest.kt @@ -26,22 +26,33 @@ class TransformAndroidManifestTest { " " + " " + " " + - "" + " " private val TEST_MANIFEST_FILE_NAME = "AndroidManifest.xml" private val TRANSFORMED_MANIFEST_FILE_NAME = "TransformedAndroidManifest.xml" - private val TEST_MANIFEST_CONTENT_WITHOUT_VERSIONS = + private val TEST_MANIFEST_CONTENT_WITHOUT_VERSIONS_AND_APPLICATION = """ """.trimIndent() + private val TEST_MANIFEST_CONTENT_WITHOUT_VERSIONS = + """ + + + + + """.trimIndent() private val BUILD_FLAVOR = "beta" private val MAJOR_VERSION = "1" private val MINOR_VERSION = "3" private val VERSION_CODE = "23" + private val APPLICATION_RELATIVE_QUALIFIED_CLASS = ".example.CustomApplication" @Rule @JvmField @@ -87,7 +98,7 @@ class TransformAndroidManifestTest { } @Test - fun testUtility_threeAgs_failsWithUsageString() { + fun testUtility_threeArgs_failsWithUsageString() { initializeEmptyGitRepository() val manifestFile = tempFolder.newFile(TEST_MANIFEST_FILE_NAME) @@ -103,7 +114,7 @@ class TransformAndroidManifestTest { } @Test - fun testUtility_fourAgs_failsWithUsageString() { + fun testUtility_fourArgs_failsWithUsageString() { initializeEmptyGitRepository() val manifestFile = tempFolder.newFile(TEST_MANIFEST_FILE_NAME) @@ -120,7 +131,7 @@ class TransformAndroidManifestTest { } @Test - fun testUtility_fiveAgs_failsWithUsageString() { + fun testUtility_fiveArgs_failsWithUsageString() { initializeEmptyGitRepository() val manifestFile = tempFolder.newFile(TEST_MANIFEST_FILE_NAME) @@ -138,7 +149,7 @@ class TransformAndroidManifestTest { } @Test - fun testUtility_sixAgs_failsWithUsageString() { + fun testUtility_sixArgs_failsWithUsageString() { initializeEmptyGitRepository() val manifestFile = tempFolder.newFile(TEST_MANIFEST_FILE_NAME) @@ -157,7 +168,7 @@ class TransformAndroidManifestTest { } @Test - fun testUtility_sevenAgs_failsWithUsageString() { + fun testUtility_sevenArgs_failsWithUsageString() { initializeEmptyGitRepository() val manifestFile = tempFolder.newFile(TEST_MANIFEST_FILE_NAME) @@ -176,6 +187,27 @@ class TransformAndroidManifestTest { assertThat(exception).hasMessageThat().contains(USAGE_STRING) } + @Test + fun testUtility_eightArgs_failsWithUsageString() { + initializeEmptyGitRepository() + val manifestFile = tempFolder.newFile(TEST_MANIFEST_FILE_NAME) + + val exception = assertThrows(IllegalStateException::class) { + runScript( + tempFolder.root.absolutePath, + manifestFile.absolutePath, + File(tempFolder.root, TRANSFORMED_MANIFEST_FILE_NAME).absolutePath, + BUILD_FLAVOR, + MAJOR_VERSION, + MINOR_VERSION, + VERSION_CODE, + APPLICATION_RELATIVE_QUALIFIED_CLASS + ) + } + + assertThat(exception).hasMessageThat().contains(USAGE_STRING) + } + @Test fun testUtility_allArgs_nonIntMajorVersion_failsWithUsageString() { initializeEmptyGitRepository() @@ -190,6 +222,7 @@ class TransformAndroidManifestTest { "major_version", MINOR_VERSION, VERSION_CODE, + APPLICATION_RELATIVE_QUALIFIED_CLASS, "develop" ) } @@ -211,6 +244,7 @@ class TransformAndroidManifestTest { MAJOR_VERSION, "minor_version", VERSION_CODE, + APPLICATION_RELATIVE_QUALIFIED_CLASS, "develop" ) } @@ -232,6 +266,7 @@ class TransformAndroidManifestTest { MAJOR_VERSION, MINOR_VERSION, "version_code", + APPLICATION_RELATIVE_QUALIFIED_CLASS, "develop" ) } @@ -253,6 +288,7 @@ class TransformAndroidManifestTest { MAJOR_VERSION, MINOR_VERSION, VERSION_CODE, + APPLICATION_RELATIVE_QUALIFIED_CLASS, "develop" ) } @@ -273,6 +309,7 @@ class TransformAndroidManifestTest { MAJOR_VERSION, MINOR_VERSION, VERSION_CODE, + APPLICATION_RELATIVE_QUALIFIED_CLASS, "develop" ) } @@ -281,7 +318,33 @@ class TransformAndroidManifestTest { } @Test - fun testUtility_allArgsCorrect_outputsNewManifestWithVersionNameAndCode() { + fun testUtility_allArgsCorrect_manifestMissingApplicationTag_throwsException() { + initializeEmptyGitRepository() + val manifestFile = tempFolder.newFile(TEST_MANIFEST_FILE_NAME).apply { + writeText(TEST_MANIFEST_CONTENT_WITHOUT_VERSIONS_AND_APPLICATION) + } + + val exception = assertThrows(IllegalStateException::class) { + runScript( + tempFolder.root.absolutePath, + manifestFile.absolutePath, + File(tempFolder.root, TRANSFORMED_MANIFEST_FILE_NAME).absolutePath, + BUILD_FLAVOR, + MAJOR_VERSION, + MINOR_VERSION, + VERSION_CODE, + APPLICATION_RELATIVE_QUALIFIED_CLASS, + "develop" + ) + } + + assertThat(exception) + .hasMessageThat() + .contains("Failed to find an 'application' tag in manifest") + } + + @Test + fun testUtility_allArgsCorrect_outputsNewManifestWithVersionNameAndCodeAndCustomApplication() { initializeEmptyGitRepository() val manifestFile = tempFolder.newFile(TEST_MANIFEST_FILE_NAME).apply { writeText(TEST_MANIFEST_CONTENT_WITHOUT_VERSIONS) @@ -295,6 +358,7 @@ class TransformAndroidManifestTest { MAJOR_VERSION, MINOR_VERSION, VERSION_CODE, + APPLICATION_RELATIVE_QUALIFIED_CLASS, "develop" ) @@ -305,6 +369,8 @@ class TransformAndroidManifestTest { "android:versionName=\"$MAJOR_VERSION\\.$MINOR_VERSION" + "-$BUILD_FLAVOR-[a-f0-9]{10}\"" ) + assertThat(transformedManifest) + .containsMatch("