diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/CardBrowser.kt b/AnkiDroid/src/main/java/com/ichi2/anki/CardBrowser.kt index d2d658a46b0b..1d5ebc73d8a4 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/CardBrowser.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/CardBrowser.kt @@ -1256,7 +1256,11 @@ open class CardBrowser : } private fun getPreviewIntent(index: Int, selectedCardIds: LongArray): Intent { - return PreviewDestination(index, selectedCardIds).toIntent(this) + return if (sharedPrefs().getBoolean("new_previewer", false)) { + Previewer2Destination(index, selectedCardIds).toIntent(this) + } else { + PreviewDestination(index, selectedCardIds).toIntent(this) + } } private fun rescheduleSelectedCards() { diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/Previewer.kt b/AnkiDroid/src/main/java/com/ichi2/anki/Previewer.kt index 3c866ccdad47..ec480c577be8 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/Previewer.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/Previewer.kt @@ -32,6 +32,7 @@ import androidx.annotation.VisibleForTesting import com.ichi2.anki.cardviewer.Gesture import com.ichi2.anki.cardviewer.PreviewLayout import com.ichi2.anki.cardviewer.ViewerCommand +import com.ichi2.anki.previewer.PreviewerActivity import com.ichi2.libanki.Collection import timber.log.Timber @@ -282,7 +283,16 @@ class Previewer : AbstractFlashcardViewer() { putExtra("index", index) putExtra("cardList", cardList) } + + @CheckResult + fun Previewer2Destination.toIntent(context: Context) = + Intent(context, PreviewerActivity::class.java).apply { + putExtra(PreviewerActivity.CURRENT_INDEX_EXTRA, currentIndex) + putExtra(PreviewerActivity.CARD_IDS_EXTRA, selectedCardIds) + } } } class PreviewDestination(val index: Int, val cardList: LongArray) + +class Previewer2Destination(val currentIndex: Int, val selectedCardIds: LongArray) diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/previewer/PreviewerActivity.kt b/AnkiDroid/src/main/java/com/ichi2/anki/previewer/PreviewerActivity.kt index 7403e337ec48..c2abbda4461b 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/previewer/PreviewerActivity.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/previewer/PreviewerActivity.kt @@ -226,8 +226,8 @@ class PreviewerActivity : AnkiActivity() { } companion object { - private const val CURRENT_INDEX_EXTRA = "currentIndex" - private const val CARD_IDS_EXTRA = "cardIds" + const val CURRENT_INDEX_EXTRA = "currentIndex" + const val CARD_IDS_EXTRA = "cardIds" fun getIntent(context: Context, selectedCardIds: LongArray, currentIndex: Int): Intent { return Intent(context, PreviewerActivity::class.java).apply { diff --git a/AnkiDroid/src/main/res/values/preferences.xml b/AnkiDroid/src/main/res/values/preferences.xml index cbfa3bafc575..236df9f75ef8 100644 --- a/AnkiDroid/src/main/res/values/preferences.xml +++ b/AnkiDroid/src/main/res/values/preferences.xml @@ -157,6 +157,7 @@ trigger_crash_preference analytics_debug_preference debug_lock_database + new_previewer showOnboarding resetOnboarding devOptionsEnabledByUser diff --git a/AnkiDroid/src/main/res/xml/preferences_dev_options.xml b/AnkiDroid/src/main/res/xml/preferences_dev_options.xml index 28433fbeb93b..ce2449a3300e 100644 --- a/AnkiDroid/src/main/res/xml/preferences_dev_options.xml +++ b/AnkiDroid/src/main/res/xml/preferences_dev_options.xml @@ -44,6 +44,10 @@ android:title="Lock Database" android:summary="Touch here to lock the database (all threads block in-process, exception if using second process)" android:key="@string/pref_lock_database_key"/> +