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 #4362, #1491: When reading text size is extra large, resume lesson page and revision tabs content is seen in normal size #5290

Merged
merged 78 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
d4c9168
fixed reading text size for lesson activity
Vishwajith-Shettigar Dec 25, 2023
e46ca6b
fixed reading text size for lesson activity
Vishwajith-Shettigar Dec 25, 2023
380562b
fixed reading text size for lesson activity
Vishwajith-Shettigar Dec 25, 2023
8386f62
fixed reading text size for lesson activity
Vishwajith-Shettigar Dec 25, 2023
a158e5f
fixed reading text size for lesson activity
Vishwajith-Shettigar Dec 25, 2023
1074505
fixed reading text size for revision
Vishwajith-Shettigar Dec 25, 2023
3c83b32
fixed reading text size for revision
Vishwajith-Shettigar Dec 25, 2023
e5ba6c3
set reading text size medium for revision option items
Vishwajith-Shettigar Dec 25, 2023
e393543
lint issue fix
Vishwajith-Shettigar Dec 25, 2023
7e634ad
lint issue fix
Vishwajith-Shettigar Dec 27, 2023
35a9b51
fix lint issue
Vishwajith-Shettigar Dec 28, 2023
7afe5a9
tool bar title size fixed
Vishwajith-Shettigar Jan 4, 2024
932d7a2
kdoc added
Vishwajith-Shettigar Jan 4, 2024
46c5ed0
Merge branch 'develop' into readingsize
Vishwajith-Shettigar Jan 10, 2024
5435338
Merge branch 'develop' into readingsize
Vishwajith-Shettigar Jan 13, 2024
da66a27
Merge branch 'develop' into readingsize
Vishwajith-Shettigar Jan 29, 2024
8e6e686
Merge branch 'develop' into readingsize
Vishwajith-Shettigar Feb 2, 2024
c5a0431
Merge branch 'develop' into readingsize
Vishwajith-Shettigar Feb 23, 2024
f420536
addressed comments
Vishwajith-Shettigar Feb 26, 2024
907654b
addressed comments
Vishwajith-Shettigar Feb 26, 2024
033ab60
Merge branch 'develop' into readingsize
Vishwajith-Shettigar Feb 27, 2024
fe9a1d9
added tests for reumelesson fragment
Vishwajith-Shettigar Feb 29, 2024
7c8183b
added tests for reumelesson fragment
Vishwajith-Shettigar Feb 29, 2024
a84d759
test modified
Vishwajith-Shettigar Mar 1, 2024
caaf2c7
tests added for revision card fragment
Vishwajith-Shettigar Mar 1, 2024
d070084
tests fixed
Vishwajith-Shettigar Mar 1, 2024
e6d36b1
tests fixed
Vishwajith-Shettigar Mar 1, 2024
c1eacd4
Merge branch 'develop' into readingsize
Vishwajith-Shettigar Mar 1, 2024
c3321d1
tests fixed
Vishwajith-Shettigar Mar 1, 2024
dbd3528
refinied
Vishwajith-Shettigar Mar 1, 2024
9b6444d
Merge branch 'develop' into readingsize
Vishwajith-Shettigar Mar 7, 2024
a434c3e
Merge branch 'develop' into readingsize
Vishwajith-Shettigar Mar 14, 2024
749f58a
Merge branch 'develop' into readingsize
Vishwajith-Shettigar Apr 3, 2024
f2fc42f
addressed comments
Vishwajith-Shettigar Apr 3, 2024
20c80e2
fix klint
Vishwajith-Shettigar Apr 3, 2024
693b39a
Delete hs_err_pid7956.log
Vishwajith-Shettigar Apr 3, 2024
1087154
addressed comments
Vishwajith-Shettigar Apr 8, 2024
5ccabef
Merge branch 'develop' into readingsize
Vishwajith-Shettigar Apr 8, 2024
28b1b5c
Merge branch 'develop' into readingsize
Vishwajith-Shettigar Apr 17, 2024
4306527
support text scaling question player
Vishwajith-Shettigar Apr 27, 2024
fef59c7
clean up
Vishwajith-Shettigar Apr 27, 2024
0de4260
Merge branch 'develop' into readingsize
Vishwajith-Shettigar May 9, 2024
4e473c6
test fix
Vishwajith-Shettigar May 9, 2024
c723f4c
test fix
Vishwajith-Shettigar May 9, 2024
58a1055
tests fix
Vishwajith-Shettigar May 10, 2024
9088d30
tests fix
Vishwajith-Shettigar May 10, 2024
b68b6fc
tests added for question player
Vishwajith-Shettigar May 10, 2024
8d5c612
tests fix
Vishwajith-Shettigar May 10, 2024
cc7bf87
tests fixed
Vishwajith-Shettigar May 10, 2024
45b38ef
test changes
Vishwajith-Shettigar May 11, 2024
45df691
klint
Vishwajith-Shettigar May 11, 2024
6b8a9a8
test changes
Vishwajith-Shettigar May 11, 2024
e197107
fix
Vishwajith-Shettigar May 11, 2024
27f077f
marks test as flaky
Vishwajith-Shettigar May 14, 2024
ce57386
mark test as flaky
Vishwajith-Shettigar May 14, 2024
1d15e3e
Resolved conflicts
Vishwajith-Shettigar Jun 5, 2024
1b05539
Fixed tests for QuestionPLayerActivity
Vishwajith-Shettigar Jun 5, 2024
4f6f050
klint
Vishwajith-Shettigar Jun 5, 2024
ff7f685
Rename verify font size method
Vishwajith-Shettigar Jun 5, 2024
731d03e
Fixed unresolved reference
Vishwajith-Shettigar Jun 5, 2024
0a45fbb
Merge branch 'develop' into readingsize
Vishwajith-Shettigar Jun 16, 2024
c03807d
Merge branch 'develop' into readingsize
Vishwajith-Shettigar Jun 23, 2024
de916f0
resolve conflicts and merge
Vishwajith-Shettigar Jun 26, 2024
32b3f4d
klint
Vishwajith-Shettigar Jun 26, 2024
537913d
undo a change
Vishwajith-Shettigar Jun 26, 2024
92bfbd8
clear warnings
Vishwajith-Shettigar Jun 26, 2024
bb34669
Merge branch 'develop' into readingsize
Vishwajith-Shettigar Jun 29, 2024
260fd28
Merge branch 'develop' into readingsize
Vishwajith-Shettigar Jul 1, 2024
3ed839f
Merge branch 'develop' into readingsize
Vishwajith-Shettigar Jul 2, 2024
4a63da6
Resolved conflicts
Vishwajith-Shettigar Jul 24, 2024
65f44ed
Resolved conflicts
Vishwajith-Shettigar Jul 24, 2024
285e602
Fix test
Vishwajith-Shettigar Jul 24, 2024
2718a61
Experimenting-- removing device config from robolectric test passes o…
Vishwajith-Shettigar Jul 26, 2024
a68fa98
Merge branch 'develop' into readingsize
Vishwajith-Shettigar Jul 26, 2024
c35937b
Removed redundant configuration in tests
Vishwajith-Shettigar Jul 27, 2024
ff7683e
Merge branch 'develop' into readingsize
Vishwajith-Shettigar Jul 30, 2024
ba7939b
Addressed comments
Vishwajith-Shettigar Jul 30, 2024
93c6fe0
Fix static check
Vishwajith-Shettigar Jul 30, 2024
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 @@ -9,8 +9,10 @@ import org.oppia.android.app.home.RouteToExplorationListener
import org.oppia.android.app.model.ExplorationActivityParams
import org.oppia.android.app.model.ExplorationCheckpoint
import org.oppia.android.app.model.ProfileId
import org.oppia.android.app.model.ReadingTextSize
import org.oppia.android.app.model.ResumeLessonActivityParams
import org.oppia.android.app.model.ScreenName.RESUME_LESSON_ACTIVITY
import org.oppia.android.app.player.exploration.DefaultFontSizeStateListener
import org.oppia.android.app.player.exploration.ExplorationActivity
import org.oppia.android.util.extensions.getProtoExtra
import org.oppia.android.util.extensions.putProtoExtra
Expand All @@ -20,6 +22,7 @@ import javax.inject.Inject
/** Activity that allows the user to resume a saved exploration. */
class ResumeLessonActivity :
InjectableAutoLocalizedAppCompatActivity(),
DefaultFontSizeStateListener,
RouteToExplorationListener {
@Inject
lateinit var resumeLessonActivityPresenter: ResumeLessonActivityPresenter
Expand Down Expand Up @@ -91,6 +94,7 @@ class ResumeLessonActivity :
parentScreen: ExplorationActivityParams.ParentScreen,
isCheckpointingEnabled: Boolean
) {
resumeLessonActivityPresenter.setReadingTextSizeNormal()
adhiamboperes marked this conversation as resolved.
Show resolved Hide resolved
startActivity(
ExplorationActivity.createExplorationActivityIntent(
this,
Expand All @@ -105,4 +109,13 @@ class ResumeLessonActivity :
)
finish()
}

override fun onDefaultFontSizeLoaded(readingTextSize: ReadingTextSize) {
resumeLessonActivityPresenter.loadResumeLessonFragment(readingTextSize)
}

override fun onBackPressed() {
resumeLessonActivityPresenter.setReadingTextSizeNormal()
finish()
}
adhiamboperes marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,40 @@ package org.oppia.android.app.resumelesson

import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import androidx.fragment.app.Fragment
import androidx.lifecycle.LiveData
import androidx.lifecycle.Transformations
import org.oppia.android.R
import org.oppia.android.app.model.ExplorationActivityParams
import org.oppia.android.app.model.ExplorationCheckpoint
import org.oppia.android.app.model.Profile
import org.oppia.android.app.model.ProfileId
import org.oppia.android.app.model.ReadingTextSize
import org.oppia.android.app.player.exploration.DefaultFontSizeStateListener
import org.oppia.android.app.utility.FontScaleConfigurationUtil
import org.oppia.android.databinding.ResumeLessonActivityBinding
import org.oppia.android.domain.oppialogger.OppiaLogger
import org.oppia.android.domain.profile.ProfileManagementController
import org.oppia.android.util.data.AsyncResult
import org.oppia.android.util.data.DataProviders.Companion.toLiveData
import javax.inject.Inject

private const val RESUME_LESSON_TAG = "ResumeLesson"

/** The presenter for [ResumeLessonActivity]. */
class ResumeLessonActivityPresenter @Inject constructor(
private val activity: AppCompatActivity
private val activity: AppCompatActivity,
private val profileManagementController: ProfileManagementController,
private val fontScaleConfigurationUtil: FontScaleConfigurationUtil,
private val oppiaLogger: OppiaLogger
) {
private lateinit var profileId: ProfileId
private lateinit var classroomId: String
private lateinit var topicId: String
private lateinit var storyId: String
private lateinit var explorationId: String
private lateinit var parentScreen: ExplorationActivityParams.ParentScreen
private lateinit var explorationCheckpoint: ExplorationCheckpoint

/** Handles onCreate() method of the [ResumeLessonActivity]. */
fun handleOnCreate(
Expand All @@ -30,30 +51,84 @@ class ResumeLessonActivityPresenter @Inject constructor(
activity,
R.layout.resume_lesson_activity
)
this.profileId = profileId
this.classroomId = classroomId
this.topicId = topicId
this.storyId = storyId
this.explorationId = explorationId
this.explorationCheckpoint = explorationCheckpoint
this.parentScreen = parentScreen
val resumeLessonToolbar = binding.resumeLessonActivityToolbar
activity.setSupportActionBar(resumeLessonToolbar)

retrieveReadingTextSize().observe(
activity as ResumeLessonActivity,
{ result ->
(activity as DefaultFontSizeStateListener).onDefaultFontSizeLoaded(result)
}
)

resumeLessonToolbar.setNavigationOnClickListener {
fontScaleConfigurationUtil.adjustFontScale(
context = activity,
ReadingTextSize.MEDIUM_TEXT_SIZE
)
@Suppress("DEPRECATION") // TODO(#5404): Migrate to a back pressed dispatcher.
activity.onBackPressed()
}
}

if (getResumeLessonFragment() == null) {
val resumeLessonFragment = ResumeLessonFragment.newInstance(
profileId,
classroomId,
topicId,
storyId,
explorationId,
parentScreen,
explorationCheckpoint
)
activity.supportFragmentManager.beginTransaction().add(
R.id.resume_lesson_fragment_placeholder,
resumeLessonFragment,
RESUME_LESSON_TAG
).commitNow()
}
/** Loads [ResumeLessonFragment]. */
fun loadResumeLessonFragment(readingTextSize: ReadingTextSize) {
if (getResumeLessonFragment() != null)
activity.supportFragmentManager.beginTransaction()
.remove(getResumeLessonFragment() as Fragment).commitNow()

val resumeLessonFragment = ResumeLessonFragment.newInstance(
profileId,
classroomId,
topicId,
storyId,
explorationId,
parentScreen,
explorationCheckpoint,
readingTextSize
)
activity.supportFragmentManager.beginTransaction().add(
R.id.resume_lesson_fragment_placeholder,
resumeLessonFragment,
RESUME_LESSON_TAG
).commitNow()
}

private fun retrieveReadingTextSize(): LiveData<ReadingTextSize> {
return Transformations.map(
profileManagementController.getProfile(profileId).toLiveData(),
::processReadingTextSizeResult
)
}

private fun processReadingTextSizeResult(
profileResult: AsyncResult<Profile>
): ReadingTextSize {
return when (profileResult) {
is AsyncResult.Failure -> {
oppiaLogger.e(
"ResumeLessonActivity",
"Failed to retrieve profile",
profileResult.error
)
Profile.getDefaultInstance()
}
is AsyncResult.Pending -> {
oppiaLogger.d(
"ResumeLessonActivity",
"Result is pending"
)
Profile.getDefaultInstance()
adhiamboperes marked this conversation as resolved.
Show resolved Hide resolved
}
is AsyncResult.Success -> profileResult.value
}.readingTextSize
}

private fun getResumeLessonFragment(): ResumeLessonFragment? {
Expand All @@ -63,4 +138,12 @@ class ResumeLessonActivityPresenter @Inject constructor(
R.id.resume_lesson_fragment_placeholder
) as ResumeLessonFragment?
}

/** Set reading text size normal. */
fun setReadingTextSizeNormal() {
fontScaleConfigurationUtil.adjustFontScale(
context = activity,
ReadingTextSize.MEDIUM_TEXT_SIZE
)
}
adhiamboperes marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import org.oppia.android.app.fragment.InjectableFragment
import org.oppia.android.app.model.ExplorationActivityParams
import org.oppia.android.app.model.ExplorationCheckpoint
import org.oppia.android.app.model.ProfileId
import org.oppia.android.app.model.ReadingTextSize
import org.oppia.android.app.model.ResumeLessonFragmentArguments
import org.oppia.android.util.extensions.getProto
import org.oppia.android.util.extensions.putProto
Expand All @@ -18,7 +19,9 @@ import javax.inject.Inject
/** Fragment that allows the user to resume a saved exploration. */
class ResumeLessonFragment : InjectableFragment() {
companion object {
private const val ARGUMENTS_KEY = "ResumeExplorationFragment.arguments"

/** Arguments key for [ResumeLessonFragment]. */
const val RESUME_LESSON_FRAGMENT_ARGUMENTS_KEY = "ResumeLessonFragment.arguments"

/** Creates new instance of [ResumeLessonFragment] for the provided parameters. */
fun newInstance(
Expand All @@ -28,7 +31,8 @@ class ResumeLessonFragment : InjectableFragment() {
storyId: String,
explorationId: String,
parentScreen: ExplorationActivityParams.ParentScreen,
checkpoint: ExplorationCheckpoint
checkpoint: ExplorationCheckpoint,
readingTextSize: ReadingTextSize
): ResumeLessonFragment {
val args = ResumeLessonFragmentArguments.newBuilder().apply {
this.profileId = profileId
Expand All @@ -38,10 +42,11 @@ class ResumeLessonFragment : InjectableFragment() {
this.explorationId = explorationId
this.parentScreen = parentScreen
this.checkpoint = checkpoint
this.readingTextSize = readingTextSize
}.build()
return ResumeLessonFragment().apply {
arguments = Bundle().apply {
putProto(ARGUMENTS_KEY, args)
putProto(RESUME_LESSON_FRAGMENT_ARGUMENTS_KEY, args)
}
}
}
Expand All @@ -53,6 +58,7 @@ class ResumeLessonFragment : InjectableFragment() {
override fun onAttach(context: Context) {
super.onAttach(context)
(fragmentComponent as FragmentComponentImpl).inject(this)
resumeLessonFragmentPresenter.handleAttach(context)
}

override fun onCreateView(
Expand All @@ -62,7 +68,10 @@ class ResumeLessonFragment : InjectableFragment() {
): View? {
val args = checkNotNull(arguments) {
"Expected arguments to be provided for fragment."
}.getProto(ARGUMENTS_KEY, ResumeLessonFragmentArguments.getDefaultInstance())
}.getProto(
RESUME_LESSON_FRAGMENT_ARGUMENTS_KEY,
ResumeLessonFragmentArguments.getDefaultInstance()
)
return resumeLessonFragmentPresenter.handleOnCreate(
inflater,
container,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.oppia.android.app.resumelesson

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand All @@ -12,14 +13,17 @@ import org.oppia.android.app.model.EphemeralChapterSummary
import org.oppia.android.app.model.ExplorationActivityParams
import org.oppia.android.app.model.ExplorationCheckpoint
import org.oppia.android.app.model.ProfileId
import org.oppia.android.app.model.ResumeLessonFragmentArguments
import org.oppia.android.app.translation.AppLanguageResourceHandler
import org.oppia.android.app.utility.FontScaleConfigurationUtil
import org.oppia.android.databinding.ResumeLessonFragmentBinding
import org.oppia.android.domain.exploration.ExplorationDataController
import org.oppia.android.domain.oppialogger.OppiaLogger
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 org.oppia.android.util.extensions.getProto
import org.oppia.android.util.gcsresource.DefaultResourceBucketName
import org.oppia.android.util.parser.html.HtmlParser
import javax.inject.Inject
Expand All @@ -31,6 +35,7 @@ class ResumeLessonFragmentPresenter @Inject constructor(
private val resumeLessonViewModel: ResumeLessonViewModel,
private val topicController: TopicController,
private val explorationDataController: ExplorationDataController,
private val fontScaleConfigurationUtil: FontScaleConfigurationUtil,
private val htmlParserFactory: HtmlParser.Factory,
private val translationController: TranslationController,
@DefaultResourceBucketName private val resourceBucketName: String,
Expand All @@ -55,6 +60,11 @@ class ResumeLessonFragmentPresenter @Inject constructor(
getChapterSummary()
}

/** Handles the [Fragment.onAttach] portion of [ResumeLessonFragment]'s lifecycle. */
fun handleAttach(context: Context) {
fontScaleConfigurationUtil.adjustFontScale(context, retrieveArguments().readingTextSize)
}

/** Handles onCreateView() method of the [ResumeLessonFragment]. */
fun handleOnCreate(
inflater: LayoutInflater,
Expand All @@ -72,7 +82,6 @@ class ResumeLessonFragmentPresenter @Inject constructor(
container,
/* attachToRoot= */ false
)

this.profileId = profileId
this.topicId = topicId
this.classroomId = classroomId
Expand Down Expand Up @@ -110,10 +119,16 @@ class ResumeLessonFragmentPresenter @Inject constructor(
parentScreen
)
}

return binding.root
}

private fun retrieveArguments(): ResumeLessonFragmentArguments {
return fragment.requireArguments().getProto(
ResumeLessonFragment.RESUME_LESSON_FRAGMENT_ARGUMENTS_KEY,
ResumeLessonFragmentArguments.getDefaultInstance()
)
}

private fun subscribeToChapterSummary() {
chapterSummaryLiveData.observe(
fragment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ import org.oppia.android.app.hintsandsolution.RevealSolutionInterface
import org.oppia.android.app.model.HelpIndex
import org.oppia.android.app.model.ProfileId
import org.oppia.android.app.model.QuestionPlayerActivityParams
import org.oppia.android.app.model.ReadingTextSize
import org.oppia.android.app.model.ScreenName.QUESTION_PLAYER_ACTIVITY
import org.oppia.android.app.model.State
import org.oppia.android.app.model.WrittenTranslationContext
import org.oppia.android.app.player.exploration.DefaultFontSizeStateListener
import org.oppia.android.app.player.state.listener.RouteToHintsAndSolutionListener
import org.oppia.android.app.player.state.listener.StateKeyboardButtonListener
import org.oppia.android.app.player.stopplaying.RestartPlayingSessionListener
Expand Down Expand Up @@ -41,6 +43,7 @@ class QuestionPlayerActivity :
RevealHintListener,
RevealSolutionInterface,
HintsAndSolutionQuestionManagerListener,
DefaultFontSizeStateListener,
ConceptCardListener {

@Inject
Expand All @@ -57,6 +60,7 @@ class QuestionPlayerActivity :

override fun onBackPressed() {
showStopExplorationDialogFragment()
questionPlayerActivityPresenter.setReadingTextSizeNormal()
}

override fun restartSession() = questionPlayerActivityPresenter.restartSession()
Expand Down Expand Up @@ -130,4 +134,8 @@ class QuestionPlayerActivity :
override fun stopSession() {
questionPlayerActivityPresenter.stopTrainingSession()
}

override fun onDefaultFontSizeLoaded(readingTextSize: ReadingTextSize) {
questionPlayerActivityPresenter.loadFragments(readingTextSize)
}
}
Loading
Loading