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 #1592: Previous responses header collapsed state not retained across landscape changes #5685

Open
wants to merge 14 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
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 @@ -170,5 +170,11 @@ class StateFragment :
STATE_FRAGMENT_STATE_KEY,
stateFragmentPresenter.getUserAnswerState()
)
stateFragmentPresenter.saveExpandedState(outState)
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
stateFragmentPresenter.restoreExpandedState(savedInstanceState)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.oppia.android.app.player.state

import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand Down Expand Up @@ -617,4 +618,12 @@ class StateFragmentPresenter @Inject constructor(
SurveyQuestionName.NPS
)
}

fun saveExpandedState(outState: Bundle) {
recyclerViewAssembler.saveExpandedState(outState)
}

fun restoreExpandedState(savedInstanceState: Bundle?) {
recyclerViewAssembler.restoreExpandedState(savedInstanceState)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.oppia.android.app.player.state

import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.animation.AccelerateInterpolator
Expand Down Expand Up @@ -1506,4 +1507,15 @@ class StatePlayerRecyclerViewAssembler private constructor(
}
}
}

/** Saves the expanded state to a Bundle. */
fun saveExpandedState(outState: Bundle) {
outState.putBoolean("hasPreviousResponsesExpanded", hasPreviousResponsesExpanded)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here and below: name constants are usually preferred, or use patterns already established in this class. Additionally, we use protos for Bundles. Please see #5458 for example.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure...

}

/** Restores the expanded state from a Bundle. */
fun restoreExpandedState(savedInstanceState: Bundle?) {
hasPreviousResponsesExpanded =
savedInstanceState?.getBoolean("hasPreviousResponsesExpanded", false) ?: false
}
}
Loading