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 #3488: Domain layer mechanism to resume explorations. [Blocked: #2476] #3507

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
3c316cb
show partial progress in progress bar
MaskedCarrot Jul 17, 2021
521490a
fixed and added tests
MaskedCarrot Jul 17, 2021
fea9a96
removed log.d added for debugging
MaskedCarrot Jul 17, 2021
8398cdf
fixed failing test
MaskedCarrot Jul 17, 2021
c059b77
ignore failing tests
MaskedCarrot Jul 18, 2021
d1eb649
fixed tests
MaskedCarrot Jul 18, 2021
3487d74
added basic approach to resume exploration
MaskedCarrot Jul 20, 2021
17983f7
nit changes
MaskedCarrot Jul 20, 2021
37cef62
Merge remote-tracking branch 'origin/develop' into domain-layer-mech-…
MaskedCarrot Jul 22, 2021
7824734
implemented mech to resume exploration
MaskedCarrot Jul 24, 2021
e647e3c
lint fix
MaskedCarrot Jul 24, 2021
5ff179e
Merge remote-tracking branch 'origin/develop' into domain-layer-mech-…
MaskedCarrot Jul 24, 2021
6bc3d36
added tests and nit changes
MaskedCarrot Jul 27, 2021
7376070
fixed hint handler
MaskedCarrot Jul 27, 2021
1ada3db
replaced pending icon
MaskedCarrot Jul 30, 2021
cf91ac4
Merge remote-tracking branch 'origin/develop' into show-partial-progr…
MaskedCarrot Jul 30, 2021
c3347b6
nit fix
MaskedCarrot Jul 30, 2021
91fb052
started new approach
MaskedCarrot Jul 30, 2021
afc6187
Merge remote-tracking branch 'origin/develop' into domain-layer-mech-…
MaskedCarrot Jul 30, 2021
fa23e44
lint fix
MaskedCarrot Jul 30, 2021
2e8f7ad
lint fix
MaskedCarrot Jul 30, 2021
a248165
nit
MaskedCarrot Jul 30, 2021
671d20e
Merge branch 'show-partial-progress-in-ui' into domain-layer-mech-to-…
MaskedCarrot Jul 31, 2021
585de66
updating the hint handler
MaskedCarrot Aug 1, 2021
733b439
working
MaskedCarrot Aug 1, 2021
394f597
fixed hint handler
MaskedCarrot Aug 1, 2021
c88a453
Merge remote-tracking branch 'origin/develop' into show-partial-progr…
MaskedCarrot Aug 1, 2021
e169f3f
nit fix
MaskedCarrot Aug 1, 2021
bd863fc
Merge branch 'show-partial-progress-in-ui' into domain-layer-mech-to-…
MaskedCarrot Aug 1, 2021
5f8f5eb
nit fix
MaskedCarrot Aug 1, 2021
62879c3
nit fix
MaskedCarrot Aug 2, 2021
09e9b16
fixed failing build
MaskedCarrot Aug 2, 2021
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 @@ -27,21 +27,29 @@ class SegmentedCircularProgressView : View {
private val isRTL = TextUtilsCompat
.getLayoutDirectionFromLocale(Locale.getDefault()) == ViewCompat.LAYOUT_DIRECTION_RTL

private var baseRect: RectF? = null
private lateinit var baseRect: RectF
private lateinit var chapterFinishedArcPaint: Paint
private lateinit var chapterNotFinishedArcPaint: Paint
private lateinit var chapterInProgressArcPaint: Paint
private lateinit var chapterNotStartedArcPaint: Paint

private var chaptersNotFinished: Int = 0
private var chaptersNotStarted: Int = 0
private var chaptersFinished: Int = 0
private var chaptersInProgress: Int = 0
private var totalChapters: Int = 0

fun setStoryChapterDetails(totalChaptersCount: Int, chaptersFinishedCount: Int) {
fun setStoryChapterDetails(
totalChaptersCount: Int,
chaptersFinishedCount: Int,
chaptersInProgressCount: Int
) {
if (this.totalChapters != totalChaptersCount ||
this.chaptersFinished != chaptersFinishedCount
this.chaptersFinished != chaptersFinishedCount ||
this.chaptersInProgress != chaptersInProgressCount
) {
this.totalChapters = totalChaptersCount
this.chaptersFinished = chaptersFinishedCount
this.chaptersNotFinished = totalChaptersCount - chaptersFinishedCount
this.chaptersInProgress = chaptersInProgressCount
this.chaptersNotStarted = totalChaptersCount - chaptersFinishedCount - chaptersInProgressCount
initialise()
}
}
Expand All @@ -55,34 +63,29 @@ class SegmentedCircularProgressView : View {
)

private fun initialise() {
chaptersNotFinished = totalChapters - chaptersFinished
chaptersNotStarted = totalChapters - chaptersFinished - chaptersInProgress
strokeWidth = dpToPx(4)
calculateSweepAngle()

chapterFinishedArcPaint = Paint(Paint.ANTI_ALIAS_FLAG)
chapterFinishedArcPaint.style = Paint.Style.STROKE
chapterFinishedArcPaint.strokeCap = Paint.Cap.ROUND
chapterFinishedArcPaint.strokeWidth = strokeWidth
chapterFinishedArcPaint.color =
ContextCompat.getColor(context, R.color.oppiaProgressChapterFinished)

chapterNotFinishedArcPaint = Paint(Paint.ANTI_ALIAS_FLAG)
chapterNotFinishedArcPaint.style = Paint.Style.STROKE
chapterNotFinishedArcPaint.strokeCap = Paint.Cap.ROUND
chapterNotFinishedArcPaint.strokeWidth = strokeWidth
setupArcPaint(chapterFinishedArcPaint, R.color.oppiaProgressChapterFinished)

chapterInProgressArcPaint = Paint(Paint.ANTI_ALIAS_FLAG)
setupArcPaint(chapterInProgressArcPaint, R.color.oppiaProgressChapterInProgress)

chapterNotStartedArcPaint = Paint(Paint.ANTI_ALIAS_FLAG)
if (chaptersFinished != 0) {
chapterNotFinishedArcPaint.color =
ContextCompat.getColor(context, R.color.oppiaProgressChapterNotFinished)
setupArcPaint(chapterNotStartedArcPaint, R.color.oppiaProgressChapterNotFinished)
} else {
chapterNotFinishedArcPaint.color = ContextCompat.getColor(context, R.color.grey_shade_20)
setupArcPaint(chapterNotStartedArcPaint, R.color.grey_shade_20)
}
}

override fun onDraw(canvas: Canvas) {
if (isRTL)
rotationY = 180f
super.onDraw(canvas)
if (baseRect == null) {
if (!this::baseRect.isInitialized) {
val centerX = measuredWidth / 2
val centerY = measuredHeight / 2
val radius = Math.min(centerX, centerY)
Expand All @@ -106,33 +109,49 @@ class SegmentedCircularProgressView : View {
val startAngle =
angleStartPoint + i * (sweepAngle + STROKE_DASH_GAP_IN_DEGREE) +
STROKE_DASH_GAP_IN_DEGREE / 2
canvas.drawArc(baseRect!!, startAngle, sweepAngle, false, chapterFinishedArcPaint)
canvas.drawArc(baseRect, startAngle, sweepAngle, false, chapterFinishedArcPaint)
}
angleStartPoint += chaptersFinished * (sweepAngle + STROKE_DASH_GAP_IN_DEGREE)
// Draws arc for every unfinished chapter.
for (i in 0 until chaptersNotFinished) {
// Draws arc for every chapter that is in progress.
for (i in 0 until chaptersInProgress) {
val startAngle =
angleStartPoint + i * (sweepAngle + STROKE_DASH_GAP_IN_DEGREE) +
STROKE_DASH_GAP_IN_DEGREE / 2
canvas.drawArc(baseRect!!, startAngle, sweepAngle, false, chapterNotFinishedArcPaint)
canvas.drawArc(baseRect, startAngle, sweepAngle, false, chapterInProgressArcPaint)
}
angleStartPoint += chaptersInProgress * (sweepAngle + STROKE_DASH_GAP_IN_DEGREE)
// Draws arc for every chapter that is not started.
for (i in 0 until chaptersNotStarted) {
val startAngle =
angleStartPoint + i * (sweepAngle + STROKE_DASH_GAP_IN_DEGREE) +
STROKE_DASH_GAP_IN_DEGREE / 2
canvas.drawArc(baseRect, startAngle, sweepAngle, false, chapterNotStartedArcPaint)
}
} else if (totalChapters == 1) {
// Draws entire circle for finished an unfinished chapter.
if (chaptersFinished == 1) {
canvas.drawArc(
baseRect!!,
baseRect,
angleStartPoint,
360f,
false,
chapterFinishedArcPaint
)
} else if (chaptersInProgress == 1) {
canvas.drawArc(
baseRect,
angleStartPoint,
360f,
false,
chapterInProgressArcPaint
)
} else {
canvas.drawArc(
baseRect!!,
baseRect,
angleStartPoint,
360f,
false,
chapterNotFinishedArcPaint
chapterNotStartedArcPaint
)
}
}
Expand All @@ -150,4 +169,13 @@ class SegmentedCircularProgressView : View {
resources.displayMetrics
)
}

private fun setupArcPaint(arcPaint: Paint, color: Int) {
arcPaint.apply {
style = Paint.Style.STROKE
strokeCap = Paint.Cap.ROUND
strokeWidth = [email protected]
this.color = ContextCompat.getColor(context, color)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import androidx.recyclerview.widget.RecyclerView
import org.oppia.android.R
import org.oppia.android.app.fragment.FragmentScope
import org.oppia.android.app.home.RouteToExplorationListener
import org.oppia.android.app.model.ExplorationCheckpoint
import org.oppia.android.app.model.ProfileId
import org.oppia.android.app.model.PromotedActivityList
import org.oppia.android.app.model.PromotedStory
Expand Down Expand Up @@ -224,7 +225,9 @@ class RecentlyPlayedFragmentPresenter @Inject constructor(
topicId,
storyId,
explorationId,
shouldSavePartialProgress = false
shouldSavePartialProgress = false,
// Pass an empty checkpoint if the exploration does not have to be resumed.
ExplorationCheckpoint.getDefaultInstance()
).observe(
fragment,
Observer<AsyncResult<Any?>> { result ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class StateFragment :
fun scrollToTop() = stateFragmentPresenter.scrollToTop()

fun revealHint(saveUserChoice: Boolean, hintIndex: Int) {
stateFragmentPresenter.revealHint(saveUserChoice, hintIndex)
stateFragmentPresenter.revealHint()
}

fun revealSolution() = stateFragmentPresenter.revealSolution()
Expand Down
Loading