Skip to content

Commit

Permalink
fix: study options opening old reviewer
Browse files Browse the repository at this point in the history
All the places that launched the Reviewer class now check if they should launch the new reviewer
  • Loading branch information
RobozinhoD committed Jan 5, 2025
1 parent 5ff3c18 commit 2e8da9d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
8 changes: 1 addition & 7 deletions AnkiDroid/src/main/java/com/ichi2/anki/DeckPicker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ import com.ichi2.anki.servicelayer.checkMedia
import com.ichi2.anki.snackbar.BaseSnackbarBuilderProvider
import com.ichi2.anki.snackbar.SnackbarBuilder
import com.ichi2.anki.snackbar.showSnackbar
import com.ichi2.anki.ui.windows.reviewer.ReviewerFragment
import com.ichi2.anki.utils.ext.dismissAllDialogFragments
import com.ichi2.anki.utils.ext.showDialogFragment
import com.ichi2.anki.widgets.DeckAdapter
Expand Down Expand Up @@ -2472,12 +2471,7 @@ open class DeckPicker :
}

private fun openReviewer() {
val intent =
if (sharedPrefs().getBoolean("newReviewer", false)) {
ReviewerFragment.getIntent(this)
} else {
Intent(this, Reviewer::class.java)
}
val intent = Reviewer.getIntent(this)
reviewLauncher.launch(intent)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ abstract class NavigationDrawerActivity :
return
}
// Review Cards Shortcut
val intentReviewCards = Intent(context, Reviewer::class.java)
val intentReviewCards = Reviewer.getIntent(context)
intentReviewCards.action = Intent.ACTION_VIEW
intentReviewCards.flags = Intent.FLAG_ACTIVITY_CLEAR_TASK
intentReviewCards.putExtra(EXTRA_STARTED_WITH_SHORTCUT, true)
Expand Down
9 changes: 9 additions & 0 deletions AnkiDroid/src/main/java/com/ichi2/anki/Reviewer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import android.Manifest
import android.animation.Animator
import android.animation.AnimatorListenerAdapter
import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent
import android.content.SharedPreferences
import android.content.pm.PackageManager
Expand Down Expand Up @@ -92,6 +93,7 @@ import com.ichi2.anki.servicelayer.NoteService.isMarked
import com.ichi2.anki.servicelayer.NoteService.toggleMark
import com.ichi2.anki.snackbar.showSnackbar
import com.ichi2.anki.ui.internationalization.toSentenceCase
import com.ichi2.anki.ui.windows.reviewer.ReviewerFragment
import com.ichi2.anki.utils.ext.showDialogFragment
import com.ichi2.anki.utils.navBarNeedsScrim
import com.ichi2.anki.utils.remainingTime
Expand Down Expand Up @@ -1666,5 +1668,12 @@ open class Reviewer :

/** Default (500ms) time for action snackbars, such as undo, bury and suspend */
const val ACTION_SNACKBAR_TIME = 500

fun getIntent(context: Context): Intent =
if (context.sharedPrefs().getBoolean("newReviewer", false)) {
ReviewerFragment.getIntent(context)
} else {
Intent(context, Reviewer::class.java)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ class StudyOptionsActivity :
launchCatchingTask {
undoAndShowSnackbar()
// TODO why are we going to the Reviewer from here? Desktop doesn't do this
Intent(this@StudyOptionsActivity, Reviewer::class.java)
Reviewer
.getIntent(this@StudyOptionsActivity)
.apply { flags = Intent.FLAG_ACTIVITY_FORWARD_RESULT }
.also { startActivity(it) }
finish()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class StudyOptionsFragment :

private fun openReviewer() {
Timber.i("openReviewer()")
val reviewer = Intent(activity, Reviewer::class.java)
val reviewer = Reviewer.getIntent(requireContext())
if (fragmented) {
toReviewer = true
Timber.i("openReviewer() fragmented mode")
Expand Down

0 comments on commit 2e8da9d

Please sign in to comment.