Skip to content

Commit

Permalink
add dev option to use the new previewer
Browse files Browse the repository at this point in the history
the pending issue to solve before releasing to the public is handling audio

since right now there are a bunch of TTS work in progress, I'll defer audio handling to later
  • Loading branch information
BrayanDSO committed Dec 12, 2023
1 parent 1d33e0f commit 0cd622a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
6 changes: 5 additions & 1 deletion AnkiDroid/src/main/java/com/ichi2/anki/CardBrowser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
10 changes: 10 additions & 0 deletions AnkiDroid/src/main/java/com/ichi2/anki/Previewer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,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 {
Expand Down
1 change: 1 addition & 0 deletions AnkiDroid/src/main/res/values/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
<string name="pref_trigger_crash_key">trigger_crash_preference</string>
<string name="pref_analytics_debug_key">analytics_debug_preference</string>
<string name="pref_lock_database_key">debug_lock_database</string>
<string name="new_previewer_pref_key">new_previewer</string>
<string name="pref_show_onboarding_key">showOnboarding</string>
<string name="pref_reset_onboarding_key">resetOnboarding</string>
<string name="dev_options_enabled_by_user_key">devOptionsEnabledByUser</string>
Expand Down
4 changes: 4 additions & 0 deletions AnkiDroid/src/main/res/xml/preferences_dev_options.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>
<SwitchPreferenceCompat
android:title="New previewer"
android:key="@string/new_previewer_pref_key"
android:defaultValue="false"/>
<SwitchPreferenceCompat
android:title="@string/show_onboarding"
android:summary="@string/show_onboarding_desc"
Expand Down

0 comments on commit 0cd622a

Please sign in to comment.