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

Draft
wants to merge 62 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
62 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
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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 @@ -87,6 +90,7 @@ class ResumeLessonActivity :
parentScreen: ExplorationActivityParams.ParentScreen,
isCheckpointingEnabled: Boolean
) {
resumeLessonActivityPresenter.setReadingTextSizeNormal()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe there is no need to reset the size here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we don't set text size medium it will affect the exploration tool bar title text size.

Resume.webm

startActivity(
ExplorationActivity.createExplorationActivityIntent(
this,
Expand All @@ -100,4 +104,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 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 @@ -29,28 +50,82 @@ class ResumeLessonActivityPresenter @Inject constructor(
activity,
R.layout.resume_lesson_activity
)
this.profileId = profileId
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
)

adhiamboperes marked this conversation as resolved.
Show resolved Hide resolved
activity.onBackPressed()
}
}

if (getResumeLessonFragment() == null) {
val resumeLessonFragment = ResumeLessonFragment.newInstance(
profileId,
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,
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()
adhiamboperes marked this conversation as resolved.
Show resolved Hide resolved
}
is AsyncResult.Pending -> {
oppiaLogger.d(
"ResumeLessonActivity",
"Result is pending"
)
Profile.getDefaultInstance()
}
is AsyncResult.Success -> profileResult.value
}.readingTextSize
}

private fun getResumeLessonFragment(): ResumeLessonFragment? {
Expand All @@ -60,4 +135,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 ARGUMENTS_KEY = "ResumeExplorationFragment.arguments"

/** Creates new instance of [ResumeLessonFragment] for the provided parameters. */
fun newInstance(
Expand All @@ -27,7 +30,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 @@ -36,6 +40,7 @@ class ResumeLessonFragment : InjectableFragment() {
this.explorationId = explorationId
this.parentScreen = parentScreen
this.checkpoint = checkpoint
this.readingTextSize = readingTextSize
}.build()
return ResumeLessonFragment().apply {
arguments = Bundle().apply {
Expand All @@ -51,6 +56,7 @@ class ResumeLessonFragment : InjectableFragment() {
override fun onAttach(context: Context) {
super.onAttach(context)
(fragmentComponent as FragmentComponentImpl).inject(this)
resumeLessonFragmentPresenter.handleAttach(context)
}

override fun onCreateView(
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,7 +13,9 @@ 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.app.viewmodel.ViewModelProvider
import org.oppia.android.databinding.ResumeLessonFragmentBinding
import org.oppia.android.domain.exploration.ExplorationDataController
Expand All @@ -21,6 +24,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 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 @@ -32,6 +36,7 @@ class ResumeLessonFragmentPresenter @Inject constructor(
private val viewModelProvider: ViewModelProvider<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 @@ -56,6 +61,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.storyId = storyId
Expand Down Expand Up @@ -107,10 +116,15 @@ class ResumeLessonFragmentPresenter @Inject constructor(
parentScreen
)
}

return binding.root
}

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

private fun subscribeToChapterSummary() {
chapterSummaryLiveData.observe(
fragment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import org.oppia.android.app.hintsandsolution.RevealHintListener
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.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 @@ -59,6 +62,7 @@ class QuestionPlayerActivity :

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

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

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