Skip to content

Commit

Permalink
Fix oppia#2643: Introduce canonical Bazel library structure & migrate…
Browse files Browse the repository at this point in the history
… util accessibility package (oppia#2775)

* Refactor util a11y package with prod/test modules.

* Hook up new accessibility module.

Includes introducing new top-level package groups to simpify visibility
management. This also establishes a pattern for excluding migrated
production files.

* Lint fixes.

* Address reviewer comments.

* Linter fix.

* Use direct file names.

Addresses review comment.
  • Loading branch information
BenHenning authored and techjd committed Mar 9, 2021
1 parent 8755a13 commit a89c609
Show file tree
Hide file tree
Showing 98 changed files with 365 additions and 247 deletions.
46 changes: 46 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,50 @@
# TODO(#1532): Rename file to 'BUILD' post-Gradle.

# Corresponds to being accessible to all Oppia targets. This should be used for production APIs &
# modules that may be used both in production targets and in tests.
package_group(
name = "oppia_api_visibility",
packages = [
"//...",
],
)

# Corresponds to being accessible to the Oppia binary. This should only be used by production-facing
# modules that must be included in the top-level binary in order for the app to build.
package_group(
name = "oppia_binary_visibility",
packages = [
"//",
],
)

# Corresponds to being accessible to Oppia tests. This should be used by fakes & test-only modules
# that can be included in tests for custom state arrangement or to satisfy upstream/downstream
# dependency requirements for components whose production implementations cannot be used in test
# environments.
# TODO(#2773): Remove the open visibility access granted here & instead restrict this access to only
# test targets.
package_group(
name = "oppia_testing_visibility",
packages = [
"//app/...",
"//data/...",
"//domain/...",
"//testing/...",
"//utility/...",
],
)

# Special visibility group specific to prod modules. This provides access to the module for both the
# Oppia binary & tests.
package_group(
name = "oppia_prod_module_visibility",
includes = [
":oppia_binary_visibility",
":oppia_testing_visibility",
],
)

# TODO(#1640): Move binary manifest to top-level package post-Gradle.
android_binary(
name = "oppia",
Expand Down
5 changes: 4 additions & 1 deletion app/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ exports_files(["src/main/AndroidManifest.xml"])
# - A file of any type has their own BAZEL library
# NOTE: if the file is added here make sure to remove this from the other sub lists
# of EXCLUDED_APP_LIB_FILES.

# keep sorted
MIGRATED_SOURCE_FILES = [
"src/main/java/org/oppia/android/app/viewmodel/ObservableArrayList.kt",
Expand Down Expand Up @@ -533,6 +532,7 @@ kt_android_library(
"//third_party:androidx_databinding_databinding-common",
"//third_party:androidx_databinding_databinding-runtime",
"//third_party:circularimageview_circular_image_view",
"//utility/src/main/java/org/oppia/android/util/accessibility",
],
)

Expand Down Expand Up @@ -632,6 +632,7 @@ kt_android_library(
"//third_party:com_google_android_flexbox",
"//third_party:javax_annotation_javax_annotation-api_jar",
"//utility",
"//utility/src/main/java/org/oppia/android/util/accessibility:prod_module",
],
)

Expand Down Expand Up @@ -697,6 +698,8 @@ TEST_DEPS = [
"//third_party:org_robolectric_annotations",
"//third_party:robolectric_android-all",
"//utility",
"//utility/src/main/java/org/oppia/android/util/accessibility",
"//utility/src/main/java/org/oppia/android/util/accessibility:test_module",
]

# App module tests. Note that all tests are assumed to be tests with resources (even though not all
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import org.oppia.android.domain.oppialogger.loguploader.LogUploadWorkerModule
import org.oppia.android.domain.oppialogger.loguploader.WorkManagerConfigurationModule
import org.oppia.android.domain.question.QuestionModule
import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule
import org.oppia.android.util.accessibility.AccessibilityModule
import org.oppia.android.util.accessibility.AccessibilityProdModule
import org.oppia.android.util.caching.CachingModule
import org.oppia.android.util.gcsresource.GcsResourceModule
import org.oppia.android.util.logging.LoggerModule
Expand Down Expand Up @@ -59,7 +59,7 @@ import javax.inject.Singleton
GlideImageLoaderModule::class, ImageParsingModule::class,
HtmlParserEntityTypeModule::class, CachingModule::class,
QuestionModule::class, LogReportingModule::class,
AccessibilityModule::class, ImageClickInputModule::class,
AccessibilityProdModule::class, ImageClickInputModule::class,
LogStorageModule::class, IntentFactoryShimModule::class,
ViewBindingShimModule::class, PrimeTopicAssetsControllerModule::class,
ExpirationMetaDataRetrieverModule::class, RatioInputModule::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import org.oppia.android.app.recyclerview.OnDragEndedListener
import org.oppia.android.app.recyclerview.OnItemDragListener
import org.oppia.android.app.shim.ViewBindingShim
import org.oppia.android.app.shim.ViewComponentFactory
import org.oppia.android.util.accessibility.CustomAccessibilityManager
import org.oppia.android.util.accessibility.AccessibilityChecker
import org.oppia.android.util.gcsresource.DefaultResourceBucketName
import org.oppia.android.util.parser.ExplorationHtmlParserEntityType
import org.oppia.android.util.parser.HtmlParser
Expand All @@ -39,7 +39,7 @@ class DragDropSortInteractionView @JvmOverloads constructor(
lateinit var htmlParserFactory: HtmlParser.Factory

@Inject
lateinit var accessibilityManager: CustomAccessibilityManager
lateinit var accessibilityChecker: AccessibilityChecker

@Inject
@field:ExplorationHtmlParserEntityType
Expand All @@ -60,7 +60,7 @@ class DragDropSortInteractionView @JvmOverloads constructor(
super.onAttachedToWindow()
(FragmentManager.findFragment<Fragment>(this) as ViewComponentFactory)
.createViewComponent(this).inject(this)
isAccessibilityEnabled = accessibilityManager.isScreenReaderEnabled()
isAccessibilityEnabled = accessibilityChecker.isScreenReaderEnabled()
}

fun allowMultipleItemsInSamePosition(isAllowed: Boolean) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import org.oppia.android.app.shim.ViewBindingShim
import org.oppia.android.app.shim.ViewComponentFactory
import org.oppia.android.app.utility.ClickableAreasImage
import org.oppia.android.app.utility.OnClickableAreaClickedListener
import org.oppia.android.util.accessibility.CustomAccessibilityManager
import org.oppia.android.util.accessibility.AccessibilityChecker
import org.oppia.android.util.gcsresource.DefaultResourceBucketName
import org.oppia.android.util.parser.DefaultGcsPrefix
import org.oppia.android.util.parser.ExplorationHtmlParserEntityType
Expand Down Expand Up @@ -41,7 +41,7 @@ class ImageRegionSelectionInteractionView @JvmOverloads constructor(
private lateinit var listener: OnClickableAreaClickedListener

@Inject
lateinit var accessibilityManager: CustomAccessibilityManager
lateinit var accessibilityChecker: AccessibilityChecker

@Inject
lateinit var imageLoader: ImageLoader
Expand Down Expand Up @@ -132,7 +132,7 @@ class ImageRegionSelectionInteractionView @JvmOverloads constructor(
(FragmentManager.findFragment<Fragment>(this) as ViewComponentFactory)
.createViewComponent(this)
.inject(this)
isAccessibilityEnabled = accessibilityManager.isScreenReaderEnabled()
isAccessibilityEnabled = accessibilityChecker.isScreenReaderEnabled()
}

fun setOnRegionClicked(onRegionClicked: OnClickableAreaClickedListener) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ import org.oppia.android.domain.oppialogger.loguploader.WorkManagerConfiguration
import org.oppia.android.domain.question.QuestionModule
import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule
import org.oppia.android.testing.RobolectricModule
import org.oppia.android.testing.TestAccessibilityModule
import org.oppia.android.testing.TestCoroutineDispatchers
import org.oppia.android.testing.TestDispatcherModule
import org.oppia.android.testing.TestLogReportingModule
import org.oppia.android.testing.profile.ProfileTestHelper
import org.oppia.android.testing.time.FakeOppiaClockModule
import org.oppia.android.util.accessibility.AccessibilityTestModule
import org.oppia.android.util.caching.testing.CachingTestModule
import org.oppia.android.util.gcsresource.GcsResourceModule
import org.oppia.android.util.logging.LoggerModule
Expand Down Expand Up @@ -556,7 +556,7 @@ class AdministratorControlsActivityTest {
DragDropSortInputModule::class, ImageClickInputModule::class, InteractionsModule::class,
GcsResourceModule::class, GlideImageLoaderModule::class, ImageParsingModule::class,
HtmlParserEntityTypeModule::class, QuestionModule::class, TestLogReportingModule::class,
TestAccessibilityModule::class, LogStorageModule::class, CachingTestModule::class,
AccessibilityTestModule::class, LogStorageModule::class, CachingTestModule::class,
PrimeTopicAssetsControllerModule::class, ExpirationMetaDataRetrieverModule::class,
ViewBindingShimModule::class, RatioInputModule::class,
ApplicationStartupListenerModule::class, LogUploadWorkerModule::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ import org.oppia.android.domain.oppialogger.loguploader.WorkManagerConfiguration
import org.oppia.android.domain.question.QuestionModule
import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule
import org.oppia.android.testing.RobolectricModule
import org.oppia.android.testing.TestAccessibilityModule
import org.oppia.android.testing.TestCoroutineDispatchers
import org.oppia.android.testing.TestDispatcherModule
import org.oppia.android.testing.TestLogReportingModule
import org.oppia.android.testing.time.FakeOppiaClockModule
import org.oppia.android.util.accessibility.AccessibilityTestModule
import org.oppia.android.util.caching.testing.CachingTestModule
import org.oppia.android.util.gcsresource.GcsResourceModule
import org.oppia.android.util.logging.LoggerModule
Expand Down Expand Up @@ -228,7 +228,7 @@ class AppVersionActivityTest {
DragDropSortInputModule::class, ImageClickInputModule::class, InteractionsModule::class,
GcsResourceModule::class, GlideImageLoaderModule::class, ImageParsingModule::class,
HtmlParserEntityTypeModule::class, QuestionModule::class, TestLogReportingModule::class,
TestAccessibilityModule::class, LogStorageModule::class, CachingTestModule::class,
AccessibilityTestModule::class, LogStorageModule::class, CachingTestModule::class,
PrimeTopicAssetsControllerModule::class, ExpirationMetaDataRetrieverModule::class,
ViewBindingShimModule::class, RatioInputModule::class,
ApplicationStartupListenerModule::class, LogUploadWorkerModule::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ import org.oppia.android.domain.topic.FRACTIONS_STORY_ID_0
import org.oppia.android.domain.topic.FRACTIONS_TOPIC_ID
import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule
import org.oppia.android.testing.RobolectricModule
import org.oppia.android.testing.TestAccessibilityModule
import org.oppia.android.testing.TestCoroutineDispatchers
import org.oppia.android.testing.TestDispatcherModule
import org.oppia.android.testing.TestLogReportingModule
import org.oppia.android.testing.story.StoryProgressTestHelper
import org.oppia.android.testing.time.FakeOppiaClock
import org.oppia.android.testing.time.FakeOppiaClockModule
import org.oppia.android.util.accessibility.AccessibilityTestModule
import org.oppia.android.util.caching.testing.CachingTestModule
import org.oppia.android.util.gcsresource.GcsResourceModule
import org.oppia.android.util.logging.LoggerModule
Expand Down Expand Up @@ -452,7 +452,7 @@ class CompletedStoryListActivityTest {
DragDropSortInputModule::class, ImageClickInputModule::class, InteractionsModule::class,
GcsResourceModule::class, GlideImageLoaderModule::class, ImageParsingModule::class,
HtmlParserEntityTypeModule::class, QuestionModule::class, TestLogReportingModule::class,
TestAccessibilityModule::class, LogStorageModule::class, CachingTestModule::class,
AccessibilityTestModule::class, LogStorageModule::class, CachingTestModule::class,
PrimeTopicAssetsControllerModule::class, ExpirationMetaDataRetrieverModule::class,
ViewBindingShimModule::class, RatioInputModule::class,
ApplicationStartupListenerModule::class, LogUploadWorkerModule::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ import org.oppia.android.domain.oppialogger.loguploader.WorkManagerConfiguration
import org.oppia.android.domain.question.QuestionModule
import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule
import org.oppia.android.testing.RobolectricModule
import org.oppia.android.testing.TestAccessibilityModule
import org.oppia.android.testing.TestDispatcherModule
import org.oppia.android.testing.TestLogReportingModule
import org.oppia.android.testing.time.FakeOppiaClockModule
import org.oppia.android.util.accessibility.AccessibilityTestModule
import org.oppia.android.util.caching.testing.CachingTestModule
import org.oppia.android.util.gcsresource.GcsResourceModule
import org.oppia.android.util.logging.LoggerModule
Expand Down Expand Up @@ -166,7 +166,7 @@ class FAQListFragmentTest {
DragDropSortInputModule::class, ImageClickInputModule::class, InteractionsModule::class,
GcsResourceModule::class, GlideImageLoaderModule::class, ImageParsingModule::class,
HtmlParserEntityTypeModule::class, QuestionModule::class, TestLogReportingModule::class,
TestAccessibilityModule::class, LogStorageModule::class, CachingTestModule::class,
AccessibilityTestModule::class, LogStorageModule::class, CachingTestModule::class,
PrimeTopicAssetsControllerModule::class, ExpirationMetaDataRetrieverModule::class,
ViewBindingShimModule::class, RatioInputModule::class,
ApplicationStartupListenerModule::class, LogUploadWorkerModule::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ import org.oppia.android.domain.oppialogger.loguploader.WorkManagerConfiguration
import org.oppia.android.domain.question.QuestionModule
import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule
import org.oppia.android.testing.RobolectricModule
import org.oppia.android.testing.TestAccessibilityModule
import org.oppia.android.testing.TestDispatcherModule
import org.oppia.android.testing.TestLogReportingModule
import org.oppia.android.testing.time.FakeOppiaClockModule
import org.oppia.android.util.accessibility.AccessibilityTestModule
import org.oppia.android.util.caching.testing.CachingTestModule
import org.oppia.android.util.gcsresource.DefaultResourceBucketName
import org.oppia.android.util.gcsresource.GcsResourceModule
Expand Down Expand Up @@ -165,7 +165,7 @@ class FAQSingleActivityTest {
DragDropSortInputModule::class, ImageClickInputModule::class, InteractionsModule::class,
GcsResourceModule::class, GlideImageLoaderModule::class, ImageParsingModule::class,
HtmlParserEntityTypeModule::class, QuestionModule::class, TestLogReportingModule::class,
TestAccessibilityModule::class, LogStorageModule::class, CachingTestModule::class,
AccessibilityTestModule::class, LogStorageModule::class, CachingTestModule::class,
PrimeTopicAssetsControllerModule::class, ExpirationMetaDataRetrieverModule::class,
ViewBindingShimModule::class, RatioInputModule::class,
ApplicationStartupListenerModule::class, LogUploadWorkerModule::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ import org.oppia.android.domain.oppialogger.loguploader.WorkManagerConfiguration
import org.oppia.android.domain.question.QuestionModule
import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule
import org.oppia.android.testing.RobolectricModule
import org.oppia.android.testing.TestAccessibilityModule
import org.oppia.android.testing.TestDispatcherModule
import org.oppia.android.testing.TestLogReportingModule
import org.oppia.android.testing.time.FakeOppiaClockModule
import org.oppia.android.util.accessibility.AccessibilityTestModule
import org.oppia.android.util.caching.testing.CachingTestModule
import org.oppia.android.util.gcsresource.GcsResourceModule
import org.oppia.android.util.logging.LoggerModule
Expand Down Expand Up @@ -110,7 +110,7 @@ class FaqListActivityTest {
DragDropSortInputModule::class, ImageClickInputModule::class, InteractionsModule::class,
GcsResourceModule::class, GlideImageLoaderModule::class, ImageParsingModule::class,
HtmlParserEntityTypeModule::class, QuestionModule::class, TestLogReportingModule::class,
TestAccessibilityModule::class, LogStorageModule::class, CachingTestModule::class,
AccessibilityTestModule::class, LogStorageModule::class, CachingTestModule::class,
PrimeTopicAssetsControllerModule::class, ExpirationMetaDataRetrieverModule::class,
ViewBindingShimModule::class, RatioInputModule::class,
ApplicationStartupListenerModule::class, LogUploadWorkerModule::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule
import org.oppia.android.testing.OppiaTestRule
import org.oppia.android.testing.RobolectricModule
import org.oppia.android.testing.RunOn
import org.oppia.android.testing.TestAccessibilityModule
import org.oppia.android.testing.TestCoroutineDispatchers
import org.oppia.android.testing.TestDispatcherModule
import org.oppia.android.testing.TestLogReportingModule
import org.oppia.android.testing.TestPlatform
import org.oppia.android.testing.time.FakeOppiaClockModule
import org.oppia.android.util.accessibility.AccessibilityTestModule
import org.oppia.android.util.caching.testing.CachingTestModule
import org.oppia.android.util.gcsresource.GcsResourceModule
import org.oppia.android.util.logging.LoggerModule
Expand Down Expand Up @@ -235,7 +235,7 @@ class HelpFragmentTest {
DragDropSortInputModule::class, ImageClickInputModule::class, InteractionsModule::class,
GcsResourceModule::class, GlideImageLoaderModule::class, ImageParsingModule::class,
HtmlParserEntityTypeModule::class, QuestionModule::class, TestLogReportingModule::class,
TestAccessibilityModule::class, LogStorageModule::class, CachingTestModule::class,
AccessibilityTestModule::class, LogStorageModule::class, CachingTestModule::class,
PrimeTopicAssetsControllerModule::class, ExpirationMetaDataRetrieverModule::class,
ViewBindingShimModule::class, RatioInputModule::class,
ApplicationStartupListenerModule::class, LogUploadWorkerModule::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule
import org.oppia.android.domain.topic.TEST_TOPIC_ID_0
import org.oppia.android.testing.RobolectricModule
import org.oppia.android.testing.RunOn
import org.oppia.android.testing.TestAccessibilityModule
import org.oppia.android.testing.TestCoroutineDispatchers
import org.oppia.android.testing.TestDispatcherModule
import org.oppia.android.testing.TestLogReportingModule
Expand All @@ -88,6 +87,7 @@ import org.oppia.android.testing.profile.ProfileTestHelper
import org.oppia.android.testing.story.StoryProgressTestHelper
import org.oppia.android.testing.time.FakeOppiaClock
import org.oppia.android.testing.time.FakeOppiaClockModule
import org.oppia.android.util.accessibility.AccessibilityTestModule
import org.oppia.android.util.caching.testing.CachingTestModule
import org.oppia.android.util.gcsresource.GcsResourceModule
import org.oppia.android.util.logging.LoggerModule
Expand Down Expand Up @@ -1445,7 +1445,7 @@ class HomeActivityTest {
DragDropSortInputModule::class, ImageClickInputModule::class, InteractionsModule::class,
GcsResourceModule::class, GlideImageLoaderModule::class, ImageParsingModule::class,
HtmlParserEntityTypeModule::class, QuestionModule::class, TestLogReportingModule::class,
TestAccessibilityModule::class, LogStorageModule::class, CachingTestModule::class,
AccessibilityTestModule::class, LogStorageModule::class, CachingTestModule::class,
PrimeTopicAssetsControllerModule::class, ExpirationMetaDataRetrieverModule::class,
ViewBindingShimModule::class, RatioInputModule::class,
ApplicationStartupListenerModule::class, LogUploadWorkerModule::class,
Expand Down
Loading

0 comments on commit a89c609

Please sign in to comment.