Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #4790 Talkback will read toolbar title clickable #5027

Merged
merged 34 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
0dc2d77
"Topic Page Toolbar title will only be clickable only if the accessib…
XichengSpencer Jun 7, 2023
3679bfe
"Topic Page Toolbar title will only be clickable only if the accessib…
XichengSpencer Jun 7, 2023
cfd8cbe
"Formatting"
XichengSpencer Jun 8, 2023
f3d67a3
Merge remote-tracking branch 'origin/#4790' into #4790
XichengSpencer Jun 8, 2023
3dc06a6
"Another Formatting"
XichengSpencer Jun 9, 2023
7269223
Merge branch 'develop' into #4790
XichengSpencer Jun 9, 2023
bf9d837
Merge branch 'oppia:develop' into #4790
XichengSpencer Jun 16, 2023
14ddb22
"Finish all conditional trigger of marquee effect"
XichengSpencer Jun 16, 2023
2aeaa19
"Formatting"
XichengSpencer Jun 20, 2023
6339c82
Merge branch 'oppia:develop' into #4790
XichengSpencer Jun 20, 2023
4461b4b
Merge branch 'oppia:develop' into #4790
XichengSpencer Jun 27, 2023
aa30ed9
Add test for marquee effect under different accessibility condition
XichengSpencer Jun 29, 2023
1c3732c
Merge branch 'develop' of https://github.com/oppia/oppia-android into…
XichengSpencer Jun 29, 2023
07203f1
Change all to accessibility service for conformity
XichengSpencer Jun 29, 2023
4fe17ed
Formatting
XichengSpencer Jun 30, 2023
02e96f9
Change the naming
XichengSpencer Jul 4, 2023
5325740
change Accessibility service from constructor injection to field inje…
XichengSpencer Jul 12, 2023
72e58b1
Merge branch 'develop' of https://github.com/oppia/oppia-android into…
XichengSpencer Jul 12, 2023
f83bd28
change Accessibility service from constructor injection to field inje…
XichengSpencer Jul 12, 2023
5285bc7
formatting
XichengSpencer Jul 13, 2023
586bc60
remove the redundant context as requested
XichengSpencer Jul 18, 2023
413e57a
Merge branch 'develop' of https://github.com/oppia/oppia-android into…
XichengSpencer Jul 18, 2023
9751686
Add corresponding test
XichengSpencer Jul 18, 2023
5e7f9c4
formatting
XichengSpencer Jul 19, 2023
60c9539
add set and activation check for all marquee tests
XichengSpencer Jul 25, 2023
f6ca595
add test variables
XichengSpencer Aug 1, 2023
4fd5e5e
Rerun CI to see the test
XichengSpencer Aug 25, 2023
037d561
Everything else beside TopicFragmentTest.kt is working
XichengSpencer Aug 25, 2023
3f54525
Merge branch 'develop' of https://github.com/oppia/oppia-android into…
XichengSpencer Aug 29, 2023
e16f239
Minor change
XichengSpencer Aug 29, 2023
e999e5b
Merge branch 'develop' of https://github.com/oppia/oppia-android into…
XichengSpencer Sep 6, 2023
d7fdc5e
Add markSpotlightSeen
XichengSpencer Sep 6, 2023
d5fc658
Merge branch 'develop' of https://github.com/oppia/oppia-android into…
XichengSpencer Sep 14, 2023
f9f2d97
Fix test layout direction and remove unnecessary variable in TopicFra…
XichengSpencer Sep 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@ package org.oppia.android.app.help.thirdparty

import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import javax.inject.Inject
import org.oppia.android.R
import org.oppia.android.app.activity.ActivityScope
import org.oppia.android.app.translation.AppLanguageResourceHandler
import org.oppia.android.databinding.LicenseTextViewerActivityBinding
import javax.inject.Inject
import org.oppia.android.util.accessibility.AccessibilityService

/** The presenter for [LicenseTextViewerActivity]. */
@ActivityScope
class LicenseTextViewerActivityPresenter @Inject constructor(
private val activity: AppCompatActivity,
private val accessibilityService: AccessibilityService,
private val resourceHandler: AppLanguageResourceHandler
) {

Expand Down Expand Up @@ -44,8 +46,12 @@ class LicenseTextViewerActivityPresenter @Inject constructor(
(activity as LicenseTextViewerActivity).finish()
}

binding.licenseTextViewerActivityToolbarTitle.setOnClickListener {
binding.licenseTextViewerActivityToolbarTitle.isSelected = true
activity.applicationContext?.let {
XichengSpencer marked this conversation as resolved.
Show resolved Hide resolved
if (!accessibilityService.isScreenReaderEnabled()) {
binding.licenseTextViewerActivityToolbarTitle.setOnClickListener {
binding.licenseTextViewerActivityToolbarTitle.isSelected = true
}
}
}

if (getLicenseTextViewerFragment() == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.core.view.doOnPreDraw
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.LiveData
import androidx.lifecycle.Transformations
import javax.inject.Inject
import org.oppia.android.R
import org.oppia.android.app.activity.ActivityScope
import org.oppia.android.app.help.HelpActivity
Expand All @@ -36,7 +37,7 @@ import org.oppia.android.domain.oppialogger.OppiaLogger
import org.oppia.android.domain.translation.TranslationController
import org.oppia.android.util.data.AsyncResult
import org.oppia.android.util.data.DataProviders.Companion.toLiveData
import javax.inject.Inject
import org.oppia.android.util.accessibility.AccessibilityService

private const val TAG_UNSAVED_EXPLORATION_DIALOG = "UNSAVED_EXPLORATION_DIALOG"
private const val TAG_STOP_EXPLORATION_DIALOG = "STOP_EXPLORATION_DIALOG"
Expand All @@ -53,6 +54,7 @@ class ExplorationActivityPresenter @Inject constructor(
private val viewModelProvider: ViewModelProvider<ExplorationViewModel>,
private val fontScaleConfigurationUtil: FontScaleConfigurationUtil,
private val translationController: TranslationController,
private val accessibilityService: AccessibilityService,
private val oppiaLogger: OppiaLogger,
private val resourceHandler: AppLanguageResourceHandler
) {
Expand Down Expand Up @@ -97,8 +99,12 @@ class ExplorationActivityPresenter @Inject constructor(
explorationToolbarTitle = binding.explorationToolbarTitle
activity.setSupportActionBar(explorationToolbar)

binding.explorationToolbarTitle.setOnClickListener {
binding.explorationToolbarTitle.isSelected = true
activity.applicationContext?.let {
if (!accessibilityService.isScreenReaderEnabled()) {
binding.explorationToolbarTitle.setOnClickListener {
binding.explorationToolbarTitle.isSelected = true
}
}
XichengSpencer marked this conversation as resolved.
Show resolved Hide resolved
}

binding.explorationToolbar.setNavigationOnClickListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.LinearSmoothScroller
import androidx.recyclerview.widget.RecyclerView
import javax.inject.Inject
import org.oppia.android.R
import org.oppia.android.app.home.RouteToExplorationListener
import org.oppia.android.app.model.ChapterPlayState
Expand All @@ -42,7 +43,6 @@ import org.oppia.android.util.data.DataProviders.Companion.toLiveData
import org.oppia.android.util.gcsresource.DefaultResourceBucketName
import org.oppia.android.util.parser.html.HtmlParser
import org.oppia.android.util.parser.html.TopicHtmlParserEntityType
import javax.inject.Inject

/** The presenter for [StoryFragment]. */
class StoryFragmentPresenter @Inject constructor(
Expand Down Expand Up @@ -90,8 +90,12 @@ class StoryFragmentPresenter @Inject constructor(
(activity as StoryActivity).finish()
}

binding.storyToolbarTitle.setOnClickListener {
binding.storyToolbarTitle.isSelected = true
activity.applicationContext?.let {
if (!accessibilityService.isScreenReaderEnabled()) {
binding.storyToolbarTitle.setOnClickListener {
binding.storyToolbarTitle.isSelected = true
}
}
}

linearLayoutManager = LinearLayoutManager(activity.applicationContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.fragment.app.Fragment
import androidx.viewpager2.widget.ViewPager2
import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayoutMediator
import javax.inject.Inject
import org.oppia.android.R
import org.oppia.android.app.fragment.FragmentScope
import org.oppia.android.app.model.ProfileId
Expand All @@ -22,7 +23,7 @@ import org.oppia.android.domain.oppialogger.OppiaLogger
import org.oppia.android.domain.oppialogger.analytics.AnalyticsController
import org.oppia.android.util.platformparameter.EnableExtraTopicTabsUi
import org.oppia.android.util.platformparameter.PlatformParameterValue
import javax.inject.Inject
import org.oppia.android.util.accessibility.AccessibilityService

/** The presenter for [TopicFragment]. */
@FragmentScope
Expand All @@ -31,6 +32,7 @@ class TopicFragmentPresenter @Inject constructor(
private val fragment: Fragment,
private val viewModel: TopicViewModel,
private val oppiaLogger: OppiaLogger,
private val accessibilityService: AccessibilityService,
private val analyticsController: AnalyticsController,
@EnableExtraTopicTabsUi private val enableExtraTopicTabsUi: PlatformParameterValue<Boolean>,
private val resourceHandler: AppLanguageResourceHandler
Expand Down Expand Up @@ -61,12 +63,17 @@ class TopicFragmentPresenter @Inject constructor(
this.internalProfileId = internalProfileId
this.topicId = topicId

binding.topicToolbar.setNavigationOnClickListener {
binding.topicToolbar.getChildAt(0).setOnClickListener {
adhiamboperes marked this conversation as resolved.
Show resolved Hide resolved
(activity as TopicActivity).finish()
}

binding.topicToolbar.setOnClickListener {
binding.topicToolbarTitle.isSelected = true
activity.applicationContext?.let {

if (!accessibilityService.isScreenReaderEnabled()) {
binding.topicToolbar.setOnClickListener {
binding.topicToolbarTitle.isSelected = true
}
}
}

viewModel.setInternalProfileId(internalProfileId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.databinding.DataBindingUtil
import androidx.lifecycle.LiveData
import androidx.lifecycle.Observer
import androidx.lifecycle.Transformations
import javax.inject.Inject
import org.oppia.android.R
import org.oppia.android.app.activity.ActivityScope
import org.oppia.android.app.help.HelpActivity
Expand All @@ -21,7 +22,7 @@ import org.oppia.android.domain.topic.TopicController
import org.oppia.android.domain.translation.TranslationController
import org.oppia.android.util.data.AsyncResult
import org.oppia.android.util.data.DataProviders.Companion.toLiveData
import javax.inject.Inject
import org.oppia.android.util.accessibility.AccessibilityService

/** The presenter for [RevisionCardActivity]. */
@ActivityScope
Expand All @@ -30,6 +31,7 @@ class RevisionCardActivityPresenter @Inject constructor(
private val oppiaLogger: OppiaLogger,
private val analyticsController: AnalyticsController,
private val topicController: TopicController,
private val accessibilityService: AccessibilityService,
private val translationController: TranslationController
) {

Expand Down Expand Up @@ -66,9 +68,14 @@ class RevisionCardActivityPresenter @Inject constructor(
binding.revisionCardToolbar.setNavigationOnClickListener {
(activity as ReturnToTopicClickListener).onReturnToTopicRequested()
}
binding.revisionCardToolbarTitle.setOnClickListener {
binding.revisionCardToolbarTitle.isSelected = true
activity.applicationContext?.let {
if (!accessibilityService.isScreenReaderEnabled()) {
binding.revisionCardToolbarTitle.setOnClickListener {
binding.revisionCardToolbarTitle.isSelected = true
}
}
}

subscribeToSubtopicTitle()

binding.actionBottomSheetOptionsMenu.setOnClickListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.rule.ActivityTestRule
import com.google.common.truth.Truth.assertThat
import dagger.Component
import javax.inject.Inject
import javax.inject.Singleton
import org.hamcrest.CoreMatchers.containsString
import org.hamcrest.Matchers.allOf
import org.junit.After
Expand Down Expand Up @@ -105,6 +107,7 @@ import org.oppia.android.testing.threading.TestDispatcherModule
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.accessibility.FakeAccessibilityService
import org.oppia.android.util.caching.AssetModule
import org.oppia.android.util.caching.testing.CachingTestModule
import org.oppia.android.util.gcsresource.GcsResourceModule
Expand All @@ -122,8 +125,6 @@ import org.oppia.android.util.platformparameter.EnableExtraTopicTabsUi
import org.oppia.android.util.platformparameter.PlatformParameterValue
import org.robolectric.annotation.Config
import org.robolectric.annotation.LooperMode
import javax.inject.Inject
import javax.inject.Singleton

private const val INFO_TAB_POSITION = 0
private const val LESSON_TAB_POSITION = 1
Expand Down Expand Up @@ -156,6 +157,9 @@ class TopicFragmentTest {
@Inject lateinit var storyProgressTestHelper: StoryProgressTestHelper
@Inject lateinit var fakeAnalyticsEventLogger: FakeAnalyticsEventLogger

@Inject
lateinit var fakeAccessibilityManager: FakeAccessibilityService

@field:[Inject EnableExtraTopicTabsUi]
lateinit var enableExtraTopicTabsUi: PlatformParameterValue<Boolean>

Expand Down Expand Up @@ -315,7 +319,7 @@ class TopicFragmentTest {
}

@Test
fun testTopicFragment_toolbarTitle_marqueeInRtl_isDisplayedCorrectly() {
fun testTopicFragment_toolbarTitle_marqueeInRtl_isDisplayedCorrectly_whenReaderOff() {
XichengSpencer marked this conversation as resolved.
Show resolved Hide resolved
initializeApplicationComponent(false)
activityTestRule.launchActivity(
createTopicActivityIntent(
Expand All @@ -324,18 +328,58 @@ class TopicFragmentTest {
)
)
testCoroutineDispatchers.runCurrent()
// setup accessibility manager
fakeAccessibilityManager.setScreenReaderEnabled(false)
val topicToolbarTitle: TextView =
activityTestRule.activity.findViewById(R.id.topic_toolbar_title)
ViewCompat.setLayoutDirection(topicToolbarTitle, ViewCompat.LAYOUT_DIRECTION_RTL)
onView(withId(R.id.topic_toolbar_title)).perform(click())
assertThat(topicToolbarTitle.ellipsize).isEqualTo(TextUtils.TruncateAt.MARQUEE)
assertThat(topicToolbarTitle.textAlignment).isEqualTo(View.TEXT_ALIGNMENT_VIEW_START)
}
XichengSpencer marked this conversation as resolved.
Show resolved Hide resolved
@Test
fun testTopicFragment_toolbarTitle_marqueeInRtl_isDisplayedCorrectly_whenReaderOn() {
XichengSpencer marked this conversation as resolved.
Show resolved Hide resolved
initializeApplicationComponent(false)
fakeAccessibilityManager.setScreenReaderEnabled(true)
activityTestRule.launchActivity(
createTopicActivityIntent(
internalProfileId,
FRACTIONS_TOPIC_ID
)
)
testCoroutineDispatchers.runCurrent()
val topicToolbarTitle: TextView =
activityTestRule.activity.findViewById(R.id.topic_toolbar_title)
ViewCompat.setLayoutDirection(topicToolbarTitle, ViewCompat.LAYOUT_DIRECTION_RTL)

onView(withId(R.id.topic_toolbar_title)).perform(click())
assertThat(topicToolbarTitle.isFocused).isEqualTo(false)
assertThat(topicToolbarTitle.textAlignment).isEqualTo(View.TEXT_ALIGNMENT_VIEW_START)
}

@Test
fun testTopicFragment_toolbarTitle_marqueeInLtr_isDisplayedCorrectly_whenReaderOff() {
XichengSpencer marked this conversation as resolved.
Show resolved Hide resolved
initializeApplicationComponent(false)
fakeAccessibilityManager.setScreenReaderEnabled(false)
activityTestRule.launchActivity(
createTopicActivityIntent(
internalProfileId,
FRACTIONS_TOPIC_ID
)
)
testCoroutineDispatchers.runCurrent()
val topicToolbarTitle: TextView =
activityTestRule.activity.findViewById(R.id.topic_toolbar_title)
ViewCompat.setLayoutDirection(topicToolbarTitle, ViewCompat.LAYOUT_DIRECTION_LTR)
onView(withId(R.id.topic_toolbar_title)).perform(click())
assertThat(topicToolbarTitle.ellipsize).isEqualTo(TextUtils.TruncateAt.MARQUEE)
assertThat(topicToolbarTitle.textAlignment).isEqualTo(View.TEXT_ALIGNMENT_VIEW_START)
}

@Test
fun testTopicFragment_toolbarTitle_marqueeInLtr_isDisplayedCorrectly() {
fun testTopicFragment_toolbarTitle_marqueeInLtr_isDisplayedCorrectly_whenReaderOn() {
XichengSpencer marked this conversation as resolved.
Show resolved Hide resolved
initializeApplicationComponent(false)
fakeAccessibilityManager.setScreenReaderEnabled(true)
activityTestRule.launchActivity(
createTopicActivityIntent(
internalProfileId,
Expand Down