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 #4452, #4453, #4454, #4445, #4446, #4447, #4448: Add spotlight functionality #4699

Merged
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
145 commits
Select commit Hold shift + click to select a range
fa56d1a
first approach
JishnuGoyal Apr 30, 2022
230420a
before starting top down.
JishnuGoyal May 1, 2022
38e9372
binding for spotlight onboarding
JishnuGoyal May 1, 2022
e891019
add dependency
JishnuGoyal May 1, 2022
d08a69e
onboarding spotlight activated
JishnuGoyal May 2, 2022
2294c88
add platform parameter
JishnuGoyal May 3, 2022
3ee9884
topic spotlight activated
JishnuGoyal May 3, 2022
3eadee3
refactored and ready to document
JishnuGoyal May 4, 2022
b4cad92
refactored and ready to document
JishnuGoyal May 4, 2022
6c860d7
refactored and ready to document
JishnuGoyal May 7, 2022
98a086c
multiple overlay res added and partially working
JishnuGoyal Jun 24, 2022
492392c
using single overlay. Calculate screen size method
JishnuGoyal Jun 25, 2022
a2c4685
spotlights in top position are working
JishnuGoyal Jun 26, 2022
63ccc51
use absolute screen position instead of view.x which was relative to …
JishnuGoyal Jun 26, 2022
9591834
before adding rtl
JishnuGoyal Jun 26, 2022
ab8183f
rtl support added but not working
JishnuGoyal Jun 27, 2022
4f21f4d
support for hint text workig
JishnuGoyal Jun 27, 2022
287e67a
updated proto structure
JishnuGoyal Jun 27, 2022
b4f6480
updated model and domain layers
JishnuGoyal Jun 29, 2022
0a39ca6
update onboarding and topic packages for new proto
JishnuGoyal Jun 29, 2022
864b657
spotlight fragment introduced. Retrieving from spotFrag so not working
JishnuGoyal Jun 30, 2022
25dbfc4
rearrange
JishnuGoyal Jun 30, 2022
08d7217
commit because i need to see another commit
JishnuGoyal Jul 4, 2022
b23becf
commit before checkout
JishnuGoyal Oct 14, 2022
cf4bc9c
store position parameters as fields
JishnuGoyal Oct 16, 2022
7f7b623
all working. Partial impl for rtl compat
JishnuGoyal Oct 19, 2022
99e14f6
rtl functionality added
JishnuGoyal Oct 19, 2022
882573f
support for suspending spotlights when talkback is being used
JishnuGoyal Oct 19, 2022
cca553b
use indexed list parser
JishnuGoyal Oct 20, 2022
03817fa
initial commit - to be reverted
JishnuGoyal Oct 25, 2022
020004d
setup
JishnuGoyal Oct 26, 2022
6aff002
setup - not to be pushed
JishnuGoyal Oct 26, 2022
85de660
add lesson tab spotlight and content desc
JishnuGoyal Oct 26, 2022
4edef9e
add test
JishnuGoyal Oct 26, 2022
293150c
try to get reference to the toolbar through findviewbyid
JishnuGoyal Oct 26, 2022
169a1cb
setup spotlight fragment
JishnuGoyal Oct 26, 2022
893e2cf
re-structure the code
JishnuGoyal Oct 27, 2022
3116b1a
rename overlay layout resources
JishnuGoyal Oct 27, 2022
6430463
lint
JishnuGoyal Oct 27, 2022
5f2c634
remove unused resources
JishnuGoyal Oct 27, 2022
e75c958
toolbar can now be spotlit. todo: Add extra logic for including some …
JishnuGoyal Oct 28, 2022
594c511
do not push
JishnuGoyal Oct 28, 2022
7efee4f
spotlight languages icon
JishnuGoyal Oct 29, 2022
2bcbba6
Merge branch 'develop' into introduce_spotlight_fragment
JishnuGoyal Oct 29, 2022
84e6737
spotlight setup complete for base prs
JishnuGoyal Oct 29, 2022
e394d86
add index to story, spotlight chapter using custom view
JishnuGoyal Oct 29, 2022
852c175
remove unused resources
JishnuGoyal Oct 29, 2022
4275d7d
Merge branch 'develop' into promoted_story_spotlight_custom_view
JishnuGoyal Oct 29, 2022
c77e8e9
setup
JishnuGoyal Oct 30, 2022
82f5b6e
add spotlight and tests
JishnuGoyal Oct 30, 2022
18f04d1
ben's suggestion
JishnuGoyal Nov 2, 2022
44ec527
revision and lesson tab spotlights working. Tests to be added.
JishnuGoyal Nov 4, 2022
62acffb
spotlights working. tests to be added.
JishnuGoyal Nov 4, 2022
f09fe98
Merge branch 'lesson_screen_spotlights' into add_all_spotlights
JishnuGoyal Nov 4, 2022
68b3435
Merge branch 'audio_fragment_spotlights' into add_all_spotlights
JishnuGoyal Nov 4, 2022
6172d22
no changes added
JishnuGoyal Nov 5, 2022
9c79522
Merge branch 'use_custom_view_to_spotlight_first_chapter' into add_al…
JishnuGoyal Nov 5, 2022
de30dd4
all spotlights work.
JishnuGoyal Nov 5, 2022
cf83479
add target store impl
JishnuGoyal Nov 6, 2022
427da12
custom queue implementation done
JishnuGoyal Nov 6, 2022
23b2efb
small fixes
JishnuGoyal Nov 7, 2022
e7c6f9b
Merge branch 'spotlight_custom_queue' into add_all_spotlights_using_c…
JishnuGoyal Nov 7, 2022
a63e552
add all spotlights, properly initialize profileid in spotlight fragme…
JishnuGoyal Nov 7, 2022
6b2d17a
update spotlight fragment and refactor function name
JishnuGoyal Nov 7, 2022
a77f4cb
lint
JishnuGoyal Nov 8, 2022
26177ed
manage audio that was playing beneath the spotlight fragment
JishnuGoyal Nov 8, 2022
d960e8f
commit before checkout
JishnuGoyal Nov 8, 2022
23af2ef
slight adjustments for overlay design
JishnuGoyal Nov 9, 2022
587ad65
finalise overlay alignments
JishnuGoyal Nov 9, 2022
c36fb80
adjustments so that app temporarily works
JishnuGoyal Nov 9, 2022
792638e
restrict doOnPreDraw calls to spotlight fragment
JishnuGoyal Nov 11, 2022
8f4c108
improve placement of overlay elements
JishnuGoyal Nov 11, 2022
e6832d7
top left position in rtl not working
JishnuGoyal Nov 11, 2022
3b18852
fully configure rtl compatibility
JishnuGoyal Nov 11, 2022
f863226
fully configure rtl compatibility + add onboarding spotlights
JishnuGoyal Nov 11, 2022
af17712
partial: add home activity and topic activity tests for spotlight.
JishnuGoyal Nov 12, 2022
130f781
spotlight voice-over icon after 3 logins
JishnuGoyal Nov 13, 2022
4b64b1c
add tests to check spotlight is shown
JishnuGoyal Nov 13, 2022
0836a22
problem with tests
JishnuGoyal Nov 13, 2022
09caa0d
add create functions for the spotlight fragments
JishnuGoyal Nov 13, 2022
c4ea52d
commit review suggestions
JishnuGoyal Nov 13, 2022
6f8b475
dont use synthetic
JishnuGoyal Nov 14, 2022
f452f29
make sure voiceover icon is visible as well
JishnuGoyal Nov 14, 2022
dcee36c
add forced announcement for hints
JishnuGoyal Nov 14, 2022
fc0b20f
move test to another file
JishnuGoyal Nov 14, 2022
be64cb9
add all tests for individual spotlights
JishnuGoyal Nov 16, 2022
4e99502
overlay design changes
JishnuGoyal Nov 16, 2022
b8e1d96
some tests in exploration activity tests are failing
JishnuGoyal Nov 16, 2022
3262e9f
adjust tests for homeactivitytest
JishnuGoyal Nov 16, 2022
198aab2
merge with develop
JishnuGoyal Nov 16, 2022
4164c1e
re adjust test
JishnuGoyal Nov 16, 2022
9543ce1
setup tests for spotlight fragment
JishnuGoyal Nov 17, 2022
385fe76
add kdocs
JishnuGoyal Nov 17, 2022
03caa78
use correct test configuration
JishnuGoyal Nov 17, 2022
10e0aca
suggetive fixes
JishnuGoyal Nov 17, 2022
c6ecbf8
add bazel config
JishnuGoyal Nov 18, 2022
4f42536
adjust affected tests
JishnuGoyal Nov 18, 2022
3067db0
Merge remote-tracking branch 'origin/add_all_spotlights_using_custom_…
JishnuGoyal Nov 18, 2022
1afecb3
merge with develop
JishnuGoyal Nov 18, 2022
080080b
adjust tests
JishnuGoyal Nov 18, 2022
b950bf7
kdocs
JishnuGoyal Nov 18, 2022
ab463bf
fix bug
JishnuGoyal Nov 18, 2022
d8b20c5
small corrections
JishnuGoyal Nov 18, 2022
dd32221
adjust test
JishnuGoyal Nov 18, 2022
ac3621c
use resource handler instead
JishnuGoyal Nov 18, 2022
e3450ce
lint
JishnuGoyal Nov 18, 2022
acff280
use spannable to highlight text
JishnuGoyal Nov 18, 2022
ce463bf
suggestions
JishnuGoyal Nov 19, 2022
d0787a7
lint
JishnuGoyal Nov 19, 2022
15eb671
Fix broken test.
BenHenning Nov 19, 2022
2b92e62
Fix variety of issues.
BenHenning Nov 19, 2022
4703d44
Merge pull request #4 from BenHenning/small-fixes
JishnuGoyal Nov 19, 2022
4295d79
lint
madhurgera2 Nov 19, 2022
53d41a0
fix build failure
madhurgera2 Nov 20, 2022
1eb51e6
fix build failure
madhurgera2 Nov 20, 2022
912c357
Revert "Fix #4746: Update app to target SDK 31 (#4747)"
JishnuGoyal Nov 20, 2022
e54728b
add hint background design
Nov 20, 2022
a4c7a31
Merge branch 'develop' into add_all_spotlights_using_custom_queue
Nov 20, 2022
6e4d9d2
merge with develop
Nov 20, 2022
401df06
Merge remote-tracking branch 'origin/add_all_spotlights_using_custom_…
madhurgera2 Nov 20, 2022
72a3c84
suggestive comments
JishnuGoyal Nov 20, 2022
9fc2aef
suggestive comments
JishnuGoyal Nov 20, 2022
855e324
general nits
JishnuGoyal Nov 20, 2022
a69c4c1
general nits
JishnuGoyal Nov 20, 2022
1af47a2
general nits
JishnuGoyal Nov 20, 2022
5ac6742
general nits
JishnuGoyal Nov 20, 2022
6cff9c9
add requested changes
JishnuGoyal Nov 21, 2022
4fbe97e
more fixes
JishnuGoyal Nov 21, 2022
2bfafc3
more fixes
JishnuGoyal Nov 21, 2022
5826fa1
more fixes
JishnuGoyal Nov 21, 2022
6ea3cb0
Fix broken ExplorationActivityTest tests.
BenHenning Nov 21, 2022
344e34e
Revert "Revert "Fix #4746: Update app to target SDK 31 (#4747)""
BenHenning Nov 21, 2022
d27b461
more fixes
JishnuGoyal Nov 21, 2022
9452cce
Simplify margin computations a bit for overlays.
BenHenning Nov 21, 2022
4db4a53
another fix
JishnuGoyal Nov 21, 2022
8dee6c1
another fix
JishnuGoyal Nov 21, 2022
554f8b2
Merge branch 'add_all_spotlights_using_custom_queue' of https://githu…
BenHenning Nov 21, 2022
fa2e69f
fix constraints, add tests
JishnuGoyal Nov 21, 2022
62e4715
Merge branch 'add_all_spotlights_using_custom_queue' of https://githu…
BenHenning Nov 21, 2022
40c32e7
Miscellaneous follow-up static check & test fixes.
BenHenning Nov 21, 2022
8ee4ec0
some additional small fixes
JishnuGoyal Nov 21, 2022
e570d9e
Merge branch 'develop' into add_all_spotlights_using_custom_queue
BenHenning Nov 21, 2022
9b7aca4
fixes
JishnuGoyal Nov 21, 2022
60e00b3
final suggestions
JishnuGoyal Nov 21, 2022
7e27091
final suggestions
JishnuGoyal Nov 21, 2022
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
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<activity
android:name=".app.testing.SpotlightFragmentTestActivity"
android:label="@string/test_activity_label"
android:theme="@style/OppiaThemeWithoutActionBar"/>
android:theme="@style/OppiaThemeWithoutActionBar" />
<activity
android:name=".app.administratorcontrols.appversion.AppVersionActivity"
android:label="@string/app_version_activity_title"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ interface ActivityComponentImpl :
StateAssemblerPaddingBindingAdaptersTestActivity
)

fun inject(spotlightFragmentTestActivity: SpotlightFragmentTestActivity)
fun inject(stateFragmentTestActivity: StateFragmentTestActivity)
fun inject(storyActivity: StoryActivity)
fun inject(testFontScaleConfigurationUtilActivity: TestFontScaleConfigurationUtilActivity)
Expand All @@ -198,5 +199,4 @@ interface ActivityComponentImpl :
fun inject(viewEventLogsActivity: ViewEventLogsActivity)
fun inject(viewEventLogsTestActivity: ViewEventLogsTestActivity)
fun inject(walkthroughActivity: WalkthroughActivity)
fun inject(spotlightFragmentTestActivity: SpotlightFragmentTestActivity)
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import org.oppia.android.app.view.ViewComponentFactory
import org.oppia.android.app.view.ViewComponentImpl
import javax.inject.Inject

/** Custom view to hold the chapter that has not yet been started. */
/** Custom view that represents an incomplete chapter. */
class ChapterNotStartedContainerConstraintLayout @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
Expand All @@ -30,7 +30,7 @@ class ChapterNotStartedContainerConstraintLayout @JvmOverloads constructor(
@Inject
lateinit var resourceHandler: AppLanguageResourceHandler

/** Set the index of the story of which this custom view is a part of. */
/** Sets the index of the story of which this custom view is a part of. */
fun setStoryIndex(index: Int) {
// Only spotlight the first chapter of the "first" story. We know for sure that for a new user,
// the first chapter shall be a type of not started chapter view. The index tells which story
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import org.oppia.android.app.view.ViewComponentFactory
import org.oppia.android.app.view.ViewComponentImpl
import javax.inject.Inject

/** Custom view to hold the promoted story cards. */
/** [MaterialCardView] that represents stories promoted to the learner. */
class PromotedStoryCardView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
Expand All @@ -30,17 +30,17 @@ class PromotedStoryCardView @JvmOverloads constructor(
private var isSpotlit = false

/** Sets the index at which this custom view is located inside the recycler view. */
fun setIndex(index: Int) {
if (!isSpotlit) {
fun setPromotedStoryIndex(index: Int) {
// This view can get attached multiple times and we must make sure that the spotlight is
// requested only once. Only spotlight the item at the first index of the recycler view.
if (!isSpotlit && index == 0) {
isSpotlit = true
val spotlightTarget = SpotlightTarget(
this,
resourceHandler.getStringInLocale(R.string.promoted_story_spotlight_hint),
feature = Spotlight.FeatureCase.PROMOTED_STORIES
)
if (index == 0) {
checkNotNull(getSpotlightFragment()).requestSpotlightViewWithDelayedLayout(spotlightTarget)
}
checkNotNull(getSpotlightFragment()).requestSpotlightViewWithDelayedLayout(spotlightTarget)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ interface FragmentComponentImpl : FragmentComponent, ViewComponentBuilderInjecto
fun inject(resumeLessonFragment: ResumeLessonFragment)
fun inject(revealSolutionDialogFragment: RevealSolutionDialogFragment)
fun inject(revisionCardFragment: RevisionCardFragment)
fun inject(spotlightFragment: SpotlightFragment)
fun inject(stateFragment: StateFragment)
fun inject(stopExplorationDialogFragment: StopExplorationDialogFragment)
fun inject(storyFragment: StoryFragment)
Expand All @@ -176,5 +177,4 @@ interface FragmentComponentImpl : FragmentComponent, ViewComponentBuilderInjecto
fun inject(walkthroughFinalFragment: WalkthroughFinalFragment)
fun inject(walkthroughTopicListFragment: WalkthroughTopicListFragment)
fun inject(walkthroughWelcomeFragment: WalkthroughWelcomeFragment)
fun inject(spotlightFragment: SpotlightFragment)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.oppia.android.app.home

import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar
Expand All @@ -10,7 +9,6 @@ import org.oppia.android.app.activity.ActivityScope
import org.oppia.android.app.drawer.NavigationDrawerFragment
import org.oppia.android.app.spotlight.SpotlightFragment
import org.oppia.android.app.spotlight.SpotlightManager
import org.oppia.android.app.topic.PROFILE_ID_ARGUMENT_KEY
import javax.inject.Inject

const val TAG_HOME_FRAGMENT = "HOME_FRAGMENT"
Expand All @@ -32,13 +30,10 @@ class HomeActivityPresenter @Inject constructor(private val activity: AppCompatA
}

if (getSpotlightFragment() == null) {
val spotlightFragment = SpotlightFragment()
val args = Bundle()
args.putInt(PROFILE_ID_ARGUMENT_KEY, internalProfileId)
spotlightFragment.arguments = args
activity.supportFragmentManager.beginTransaction().add(
R.id.home_spotlight_fragment_placeholder,
spotlightFragment, SpotlightManager.SPOTLIGHT_FRAGMENT_TAG
SpotlightFragment.newInstance(internalProfileId),
SpotlightManager.SPOTLIGHT_FRAGMENT_TAG
).commitNow()
}
}
Expand Down Expand Up @@ -69,6 +64,6 @@ class HomeActivityPresenter @Inject constructor(private val activity: AppCompatA
private fun getSpotlightFragment(): SpotlightFragment? {
return activity.supportFragmentManager.findFragmentById(
R.id.home_spotlight_fragment_placeholder
) as SpotlightFragment?
) as? SpotlightFragment
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package org.oppia.android.app.onboarding

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import org.oppia.android.R
import org.oppia.android.app.activity.ActivityScope
import org.oppia.android.app.spotlight.SpotlightFragment
import org.oppia.android.app.spotlight.SpotlightManager
import org.oppia.android.app.topic.PROFILE_ID_ARGUMENT_KEY
import javax.inject.Inject

/** The presenter for [OnboardingActivity]. */
Expand All @@ -22,13 +20,10 @@ class OnboardingActivityPresenter @Inject constructor(private val activity: AppC
}

if (getSpotlightFragment() == null) {
rt4914 marked this conversation as resolved.
Show resolved Hide resolved
val spotlightFragment = SpotlightFragment()
val args = Bundle()
args.putInt(PROFILE_ID_ARGUMENT_KEY, -1)
spotlightFragment.arguments = args
activity.supportFragmentManager.beginTransaction().add(
R.id.onboarding_spotlight_fragment_placeholder,
spotlightFragment, SpotlightManager.SPOTLIGHT_FRAGMENT_TAG
SpotlightFragment.newInstance(internalProfileId = 0),
SpotlightManager.SPOTLIGHT_FRAGMENT_TAG
).commitNow()
}
}
Expand All @@ -46,6 +41,6 @@ class OnboardingActivityPresenter @Inject constructor(private val activity: AppC
.supportFragmentManager
.findFragmentById(
R.id.onboarding_spotlight_fragment_placeholder
) as SpotlightFragment?
) as? SpotlightFragment
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ class OnboardingFragmentPresenter @Inject constructor(
return binding.root
}

private fun getSpotlightFragment(): SpotlightFragment {
private fun getSpotlightFragment(): SpotlightFragment? {
return activity.supportFragmentManager.findFragmentByTag(
SpotlightManager.SPOTLIGHT_FRAGMENT_TAG
) as SpotlightFragment
) as? SpotlightFragment
}

fun startSpotlight() {
Expand All @@ -73,7 +73,7 @@ class OnboardingFragmentPresenter @Inject constructor(
SpotlightShape.Circle,
Spotlight.FeatureCase.ONBOARDING_NEXT_BUTTON
)
getSpotlightFragment().requestSpotlightViewWithDelayedLayout(nextSpotlightTarget)
checkNotNull(getSpotlightFragment()).requestSpotlightViewWithDelayedLayout(nextSpotlightTarget)
}

private fun setUpViewPager() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import org.oppia.android.domain.profile.ProfileManagementController
import org.oppia.android.util.data.AsyncResult
import org.oppia.android.util.data.DataProviders.Companion.toLiveData
import org.oppia.android.util.networking.NetworkConnectionUtil
import org.oppia.android.util.platformparameter.EnableSpotlightUi
import org.oppia.android.util.platformparameter.PlatformParameterValue
import javax.inject.Inject

const val TAG_LANGUAGE_DIALOG = "LANGUAGE_DIALOG"
Expand All @@ -52,7 +54,8 @@ class AudioFragmentPresenter @Inject constructor(
private val networkConnectionUtil: NetworkConnectionUtil,
private val viewModelProvider: ViewModelProvider<AudioViewModel>,
private val oppiaLogger: OppiaLogger,
private val resourceHandler: AppLanguageResourceHandler
private val resourceHandler: AppLanguageResourceHandler,
@EnableSpotlightUi private val enableSpotlightUi: PlatformParameterValue<Boolean>
) {
var userIsSeeking = false
var userProgress = 0
Expand Down Expand Up @@ -119,16 +122,6 @@ class AudioFragmentPresenter @Inject constructor(
return binding.root
}

private fun subscribeToSpotlightStatusLiveData() {
getSpotlightFragment().getSpotlightStatusLiveData().observe(fragment) { isSpotlightActive ->
if (isSpotlightActive) {
handleOnStop()
} else {
handleOnPlay()
}
}
}

private fun startSpotlights() {
val audioLanguageIconSpotlightTarget = SpotlightTarget(
binding.audioLanguageIcon,
Expand Down Expand Up @@ -214,12 +207,6 @@ class AudioFragmentPresenter @Inject constructor(
}
}

private fun handleOnPlay() {
if (!activity.isChangingConfigurations && prepared) {
viewModel.togglePlayPause(UiAudioPlayStatus.PAUSED)
}
}

/** Releases audio player resources */
fun handleOnDestroy() {
if (!activity.isChangingConfigurations) {
Expand Down Expand Up @@ -297,13 +284,12 @@ class AudioFragmentPresenter @Inject constructor(
audioButtonListener.scrollToTop()
if (feedbackId == null) {
// This isn't reloading content since it's the first case of the content auto-playing.
loadMainContentAudio(allowAutoPlay = true, reloadingContent = false)
BenHenning marked this conversation as resolved.
Show resolved Hide resolved
loadMainContentAudio(allowAutoPlay = !enableSpotlightUi.value, reloadingContent = false)
} else {
loadFeedbackAudio(feedbackId!!, true)
loadFeedbackAudio(feedbackId!!, !enableSpotlightUi.value)
}
fragment.view?.startAnimation(AnimationUtils.loadAnimation(context, R.anim.slide_down_audio))
startSpotlights()
subscribeToSpotlightStatusLiveData()
}

private fun hideAudioFragment() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package org.oppia.android.app.player.exploration

import android.content.Context
import android.os.Bundle
import android.view.View
import android.view.inputmethod.EditorInfo
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar
import androidx.core.view.doOnPreDraw
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.LiveData
import androidx.lifecycle.Observer
Expand All @@ -26,7 +27,6 @@ import org.oppia.android.app.spotlight.SpotlightFragment
import org.oppia.android.app.spotlight.SpotlightManager
import org.oppia.android.app.spotlight.SpotlightShape
import org.oppia.android.app.spotlight.SpotlightTarget
import org.oppia.android.app.topic.PROFILE_ID_ARGUMENT_KEY
import org.oppia.android.app.topic.TopicActivity
import org.oppia.android.app.translation.AppLanguageResourceHandler
import org.oppia.android.app.utility.FontScaleConfigurationUtil
Expand Down Expand Up @@ -136,39 +136,40 @@ class ExplorationActivityPresenter @Inject constructor(
}

if (getSpotlightFragment() == null) {
val spotlightFragment = SpotlightFragment()
val args = Bundle()
args.putInt(PROFILE_ID_ARGUMENT_KEY, profileId.internalId)
spotlightFragment.arguments = args
activity.supportFragmentManager.beginTransaction().add(
R.id.exploration_spotlight_fragment_placeholder,
spotlightFragment, SpotlightManager.SPOTLIGHT_FRAGMENT_TAG
SpotlightFragment.newInstance(profileId.internalId),
SpotlightManager.SPOTLIGHT_FRAGMENT_TAG
).commitNow()
}
}

fun requestVoiceOverIconSpotlight(numberOfLogins: Int) {
if (numberOfLogins >= 3) {
// Spotlight the voice-over icon after 3 or more logins.
val audioPlayerSpotlightTarget = SpotlightTarget(
binding.actionAudioPlayer,
resourceHandler.getStringInLocaleWithWrapping(
R.string.voiceover_icon_spotlight_hint,
resourceHandler.getStringInLocale(R.string.app_name)
),
SpotlightShape.Circle,
Spotlight.FeatureCase.VOICEOVER_PLAY_ICON
)
checkNotNull(getSpotlightFragment()).requestSpotlightViewWithDelayedLayout(
audioPlayerSpotlightTarget
)
// Spotlight the voice-over icon after 3 or more logins, and only if it's visible. Note that
// the doOnPreDraw here ensures that the visibility check for the button is up-to-date before
// a decision is made on whether to show the button.
binding.actionAudioPlayer.doOnPreDraw {
if (it.visibility == View.VISIBLE) {
val audioPlayerSpotlightTarget = SpotlightTarget(
it,
resourceHandler.getStringInLocaleWithWrapping(
R.string.voiceover_icon_spotlight_hint,
resourceHandler.getStringInLocale(R.string.app_name)
),
SpotlightShape.Circle,
Spotlight.FeatureCase.VOICEOVER_PLAY_ICON
)
checkNotNull(getSpotlightFragment()).requestSpotlight(audioPlayerSpotlightTarget)
}
}
}
}

private fun getSpotlightFragment(): SpotlightFragment? {
return activity.supportFragmentManager.findFragmentByTag(
SpotlightManager.SPOTLIGHT_FRAGMENT_TAG
) as SpotlightFragment?
) as? SpotlightFragment
}

fun loadExplorationFragment(readingTextSize: ReadingTextSize) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,14 @@ class ExplorationFragmentPresenter @Inject constructor(
fragment
) { result ->
val readingTextSize = retrieveArguments().readingTextSize
if (result is AsyncResult.Success && result.value.readingTextSize != readingTextSize) {
selectNewReadingTextSize(result.value.readingTextSize)

// Since text views are based on sp for sizing, the activity needs to be recreated so that
// sp can be correctly recomputed.
fragment.requireActivity().recreate()
} else {
if (result is AsyncResult.Success) {
showSpotlights(result.value.numberOfLogins)
}
if (result is AsyncResult.Success) {
if (result.value.readingTextSize != readingTextSize) {

// Since text views are based on sp for sizing, the activity needs to be recreated so that
// sp can be correctly recomputed.
selectNewReadingTextSize(result.value.readingTextSize)
fragment.requireActivity().recreate()
} else showSpotlights(result.value.numberOfLogins)
}
}
}
Expand All @@ -92,7 +90,7 @@ class ExplorationFragmentPresenter @Inject constructor(
fragment.requireActivity().findViewById<View>(R.id.exploration_toolbar) as Toolbar
explorationToolbar.forEach {
if (it is ImageButton) {
// this toolbar contains only one image button, which is the back navigation icon
// This toolbar contains only one image button, which is the back navigation icon.
val backButtonSpotlightTarget = SpotlightTarget(
it,
resourceHandler.getStringInLocale(R.string.exploration_exit_button_spotlight_hint),
Expand All @@ -110,7 +108,7 @@ class ExplorationFragmentPresenter @Inject constructor(
private fun getSpotlightFragment(): SpotlightFragment? {
return fragment.requireActivity().supportFragmentManager.findFragmentByTag(
SpotlightManager.SPOTLIGHT_FRAGMENT_TAG
) as SpotlightFragment?
) as? SpotlightFragment
}

fun handlePlayAudio() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.oppia.android.app.player.exploration

/** Interface to request voice-over icon spotlight. */
/** Listener for scenarios when the user should be shown a spotlight for playing voiceovers. */
interface RequestVoiceOverIconSpotlightListener {
/** Requests the spotlight fragment to show voice-over icon spotlight. */
/** Requests to show a voice-over icon spotlight. */
fun requestVoiceOverIconSpotlight(numberOfLogins: Int)
}
Loading