diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/AnkiFragment.kt b/AnkiDroid/src/main/java/com/ichi2/anki/AnkiFragment.kt index 8acae5051d9f..d49346fc6744 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/AnkiFragment.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/AnkiFragment.kt @@ -20,6 +20,7 @@ import android.net.Uri import android.os.Bundle import android.view.Menu import android.view.View +import android.widget.ProgressBar import androidx.annotation.AttrRes import androidx.annotation.IdRes import androidx.annotation.LayoutRes @@ -112,7 +113,10 @@ open class AnkiFragment(@LayoutRes layout: Int) : Fragment(layout), AnkiActivity /** * Hides progress bar. */ - private fun hideProgressBar() = ankiActivity.hideProgressBar() + private fun hideProgressBar() { + val progressBar = findViewById(R.id.progress_bar) + progressBar.visibility = View.GONE + } /** * Shows progress bar. diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/CardBrowser.kt b/AnkiDroid/src/main/java/com/ichi2/anki/CardBrowser.kt index cc909000b568..488ed8a6da23 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/CardBrowser.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/CardBrowser.kt @@ -49,6 +49,9 @@ import androidx.annotation.ColorInt import androidx.annotation.MainThread import androidx.annotation.VisibleForTesting import androidx.appcompat.widget.SearchView +import androidx.core.view.isVisible +import androidx.fragment.app.FragmentContainerView +import androidx.fragment.app.commit import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.lifecycleScope import anki.collection.OpChanges @@ -78,6 +81,7 @@ import com.ichi2.anki.dialogs.DeckSelectionDialog import com.ichi2.anki.dialogs.DeckSelectionDialog.Companion.newInstance import com.ichi2.anki.dialogs.DeckSelectionDialog.DeckSelectionListener import com.ichi2.anki.dialogs.DeckSelectionDialog.SelectableDeck +import com.ichi2.anki.dialogs.DiscardChangesDialog import com.ichi2.anki.dialogs.IntegerDialog import com.ichi2.anki.dialogs.SimpleMessageDialog import com.ichi2.anki.dialogs.tags.TagsDialog @@ -163,6 +167,19 @@ open class CardBrowser : ChangeManager.Subscriber, ExportDialogsFactoryProvider { + /** + * Provides an instance of NoteEditorLauncher for adding a note + */ + @get:VisibleForTesting + val addNoteLauncher: NoteEditorLauncher + get() = createAddNoteLauncher(viewModel, fragmented) + + /** + * Provides an instance of NoteEditorLauncher for editing a note + */ + private val editNoteLauncher: NoteEditorLauncher + get() = NoteEditorLauncher.EditCard(currentCardId, Direction.DEFAULT, fragmented) + override fun onDeckSelected(deck: SelectableDeck?) { deck?.let { launchCatchingTask { selectDeckAndSave(deck.deckId) } @@ -175,6 +192,11 @@ open class CardBrowser : lateinit var viewModel: CardBrowserViewModel + /** + * The frame containing the NoteEditor. Non null only in layout x-large. + */ + private var noteEditorFrame: FragmentContainerView? = null + /** List of cards in the browser. * When the list is changed, the position member of its elements should get changed. */ private val cards get() = viewModel.cards @@ -198,7 +220,10 @@ open class CardBrowser : private lateinit var exportingDelegate: ActivityExportingDelegate - // card that was clicked (not marked) + // The card to display in the note editor. Either in the trailing fragment or in an opened activity. + // It is the last card clicked without entering or being in multi select mode. + // If no card were clicked, then it's the first card of the search result, if any. + // Thus, it is null if and only if no cards are displayed. override var currentCardId get() = viewModel.currentCardId set(value) { viewModel.currentCardId = value } @@ -372,8 +397,22 @@ open class CardBrowser : // must be called once we have an accessible collection viewModel = createViewModel(launchOptions) - setContentView(R.layout.card_browser) + setContentView(R.layout.cardbrowser) initNavigationDrawer(findViewById(android.R.id.content)) + + noteEditorFrame = findViewById(R.id.note_editor_frame) + + if (!sharedPrefs().getBoolean("split_cardbrowser", false)) { + noteEditorFrame?.visibility = View.GONE + } + + /** + * Check if noteEditorFrame is not null and if its visibility is set to VISIBLE. + * If both conditions are true, assign true to the variable [fragmented], otherwise assign false. + * [fragmented] will be true if the view size is large otherwise false + */ + fragmented = noteEditorFrame?.visibility == View.VISIBLE + // initialize the lateinit variables // Load reference to action bar title actionBarTitle = findViewById(R.id.toolbar_title) @@ -427,6 +466,68 @@ open class CardBrowser : registerOnForgetHandler { viewModel.queryAllSelectedCardIds() } } + private fun showSaveChangessDialog(launcher: NoteEditorLauncher) { + DiscardChangesDialog.showDialog( + context = this, + positiveButtonText = this.getString(R.string.save), + negativeButtonText = this.getString(R.string.discard), + message = this.getString(R.string.save_changes_message), + positiveMethod = { + launchCatchingTask { + fragment?.saveNote() + loadNoteEditorFragment(launcher) + } + }, + negativeMethod = { + loadNoteEditorFragment(launcher) + } + ) + } + + private fun loadNoteEditorFragment(launcher: NoteEditorLauncher) { + val noteEditor = NoteEditor.newInstance(launcher) + supportFragmentManager.commit { + replace(R.id.note_editor_frame, noteEditor) + } + // Invalidate options menu so that note editor menu will show + invalidateOptionsMenu() + } + + /** + * Retrieves the `NoteEditor` fragment if it is present in the fragment container + */ + val fragment: NoteEditor? + get() { + val frag = supportFragmentManager.findFragmentById(R.id.note_editor_frame) + return if (frag is NoteEditor) { + frag + } else { + null + } + } + + /** + * Loads the NoteEditor fragment in container if the view is x-large. + * + * @param launcher The NoteEditorLauncher containing the necessary data to initialize the NoteEditor Fragment. + */ + private fun loadNoteEditorFragmentIfFragmented(launcher: NoteEditorLauncher) { + if (!fragmented) { + return + } + // Show note editor frame when adding first card + if (!noteEditorFrame!!.isVisible) { + noteEditorFrame!!.isVisible = true + } + + // If there are unsaved changes in NoteEditor then show dialog for confirmation + if (fragment?.hasUnsavedChanges() == true) { + showSaveChangessDialog(launcher) + } else { + loadNoteEditorFragment(launcher) + } + } + @Suppress("UNUSED_PARAMETER") private fun setupFlows() { // provides a name for each flow receiver to improve stack traces @@ -584,15 +685,22 @@ open class CardBrowser : cards.reset() cardsListView.setOnItemClickListener { _: AdapterView<*>?, view: View?, position: Int, _: Long -> - if (viewModel.isInMultiSelectMode) { - // click on whole cell triggers select - val cb = view!!.findViewById(R.id.card_checkbox) - cb.toggle() - viewModel.toggleRowSelectionAtPosition(position) - } else { - launchCatchingTask { + launchCatchingTask { + val clickedCardId = viewModel.queryCardIdAtPosition(position) + // set selected position + cardsAdapter.selectedPosition = position + if (viewModel.isInMultiSelectMode) { + // click on whole cell triggers select + val cb = view!!.findViewById(R.id.card_checkbox) + cb.toggle() + viewModel.toggleRowSelectionAtPosition(position) + // Load NoteEditor on trailing side if card is selected + if (cb.isChecked) { + currentCardId = clickedCardId + loadNoteEditorFragmentIfFragmented(editNoteLauncher) + } + } else { // load up the card selected on the list - val clickedCardId = viewModel.queryCardIdAtPosition(position) saveScrollingState(position) openNoteEditorForCard(clickedCardId) } @@ -600,10 +708,13 @@ open class CardBrowser : } @KotlinCleanup("helper function for min/max range") cardsListView.setOnItemLongClickListener { _: AdapterView<*>?, view: View?, position: Int, _: Long -> - if (viewModel.isInMultiSelectMode) { - viewModel.selectRowsBetweenPositions(lastSelectedPosition, position) - } else { - launchCatchingTask { + launchCatchingTask { + currentCardId = viewModel.queryCardIdAtPosition(position) + // set selected position + cardsAdapter.selectedPosition = position + if (viewModel.isInMultiSelectMode) { + viewModel.selectRowsBetweenPositions(lastSelectedPosition, position) + } else { lastSelectedPosition = position saveScrollingState(position) @@ -614,6 +725,7 @@ open class CardBrowser : recenterListView(view) cardsAdapter.notifyDataSetChanged() } + loadNoteEditorFragmentIfFragmented(editNoteLauncher) } true } @@ -837,10 +949,14 @@ open class CardBrowser : @NeedsTest("I/O edits are saved") private fun openNoteEditorForCard(cardId: CardId) { currentCardId = cardId - val intent = NoteEditorLauncher.EditCard(currentCardId, Direction.DEFAULT).getIntent(this) - onEditCardActivityResult.launch(intent) - // #6432 - FIXME - onCreateOptionsMenu crashes if receiving an activity result from edit card when in multiselect - viewModel.endMultiSelectMode() + // Load NoteEditor on trailing side if in fragmented mode + if (fragmented) { + loadNoteEditorFragmentIfFragmented(editNoteLauncher) + } else { + onEditCardActivityResult.launch(editNoteLauncher.getIntent(this)) + // #6432 - FIXME - onCreateOptionsMenu crashes if receiving an activity result from edit card when in multiselect + viewModel.endMultiSelectMode() + } } /** @@ -1000,6 +1116,10 @@ open class CardBrowser : showBackIcon() increaseHorizontalPaddingOfOverflowMenuIcons(menu) } + // Append note editor menu to card browser menu if fragmented and deck is not empty + if (fragmented && viewModel.rowCount != 0) { + fragment?.onCreateMenu(menu, menuInflater) + } actionBarMenu?.findItem(R.id.action_undo)?.run { isVisible = getColUnsafe.undoAvailable() title = getColUnsafe.undoLabel() @@ -1045,7 +1165,7 @@ open class CardBrowser : } private fun updatePreviewMenuItem() { - previewItem?.isVisible = viewModel.rowCount > 0 + previewItem?.isVisible = !fragmented && viewModel.rowCount > 0 } private fun updateMultiselectMenu() { @@ -1091,7 +1211,7 @@ open class CardBrowser : // Note: Theoretically should not happen, as this should kick us back to the menu actionBarMenu.findItem(R.id.action_select_none).isVisible = viewModel.hasSelectedAnyRows() - actionBarMenu.findItem(R.id.action_edit_note).isVisible = canPerformMultiSelectEditNote() + actionBarMenu.findItem(R.id.action_edit_note).isVisible = !fragmented && canPerformMultiSelectEditNote() actionBarMenu.findItem(R.id.action_view_card_info).isVisible = canPerformCardInfo() } @@ -1261,7 +1381,7 @@ open class CardBrowser : showCreateFilteredDeckDialog() } } - return super.onOptionsItemSelected(item) + return fragmented && fragment!!.onMenuItemSelected(item) } private fun showCreateFilteredDeckDialog() { @@ -1457,12 +1577,12 @@ open class CardBrowser : showDialogFragment(dialog) } - @get:VisibleForTesting - val addNoteIntent: Intent - get() = createAddNoteIntent(this, viewModel) - private fun addNoteFromCardBrowser() { - onAddNoteActivityResult.launch(addNoteIntent) + if (fragmented) { + loadNoteEditorFragmentIfFragmented(addNoteLauncher) + } else { + onAddNoteActivityResult.launch(addNoteLauncher.getIntent(this)) + } } private val reviewerCardId: CardId @@ -1614,6 +1734,17 @@ open class CardBrowser : private fun redrawAfterSearch() { Timber.i("CardBrowser:: Completed searchCards() Successfully") updateList() + // Check whether deck is empty or not + val isDeckEmpty = viewModel.rowCount == 0 + // Hide note editor frame if deck is empty and fragmented + noteEditorFrame?.visibility = if (fragmented && !isDeckEmpty) { + currentCardId = viewModel.cards[cardsAdapter.selectedPosition].id + loadNoteEditorFragmentIfFragmented(editNoteLauncher) + View.VISIBLE + } else { + invalidateOptionsMenu() + View.GONE + } /*check whether mSearchView is initialized as it is lateinit property.*/ if (searchView == null || searchView!!.isIconified) { restoreScrollPositionIfRequested() @@ -1951,6 +2082,7 @@ open class CardBrowser : ) : BaseAdapter() { private var originalTextSize = -1.0f private val inflater: LayoutInflater + var selectedPosition: Int = 0 override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { // Get the main container view if it doesn't already exist, and call bindView val v: View @@ -1978,8 +2110,10 @@ open class CardBrowser : setFont(column as TextView) // set font for column column.text = card.getColumnHeaderText(fromKeys[i]) // set text for column } + // check whether the view is selected + val isHighLight = position == selectedPosition // set card's background color - val backgroundColor: Int = card.getBackgroundColor(this@CardBrowser) + val backgroundColor: Int = card.getBackgroundColor(this@CardBrowser, isHighLight) v.setBackgroundColor(backgroundColor) // setup checkbox to change color in multi-select mode val checkBox = v.findViewById(R.id.card_checkbox) @@ -2161,12 +2295,14 @@ open class CardBrowser : * @return index into TypedArray specifying the background color */ @ColorInt - fun getBackgroundColor(context: Context): Int { + fun getBackgroundColor(context: Context, isHighlight: Boolean): Int { val flagColor = Flag.fromCode(card.userFlag()).browserColorRes if (flagColor != null) { return context.getColor(flagColor) } - val colorAttr = if (isMarked(col, card.note(col))) { + val colorAttr = if (isHighlight) { + R.attr.currentDeckBackgroundColor + } else if (isMarked(col, card.note(col))) { R.attr.markedColor } else if (card.queue == Consts.QUEUE_TYPE_SUSPENDED) { R.attr.suspendedColor @@ -2425,8 +2561,8 @@ open class CardBrowser : fun clearLastDeckId() = SharedPreferencesLastDeckIdRepository.clearLastDeckId() @VisibleForTesting - fun createAddNoteIntent(context: Context, viewModel: CardBrowserViewModel): Intent { - return NoteEditorLauncher.AddNoteFromCardBrowser(viewModel).getIntent(context) + fun createAddNoteLauncher(viewModel: CardBrowserViewModel, inFragmentedActivity: Boolean = false): NoteEditorLauncher { + return NoteEditorLauncher.AddNoteFromCardBrowser(viewModel, inFragmentedActivity) } @CheckResult diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/NoteEditor.kt b/AnkiDroid/src/main/java/com/ichi2/anki/NoteEditor.kt index 8ab9d2b1490b..65e085506bc8 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/NoteEditor.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/NoteEditor.kt @@ -262,6 +262,12 @@ class NoteEditor : AnkiFragment(R.layout.note_editor), DeckSelectionListener, Su var clipboard: ClipboardManager? = null + /** + * Whether this is displayed in a fragment view. + * If true, this fragment is on the trailing side of the card browser. + */ + private var inFragmentedActivity = false + private val requestAddLauncher = registerForActivityResult( ActivityResultContracts.StartActivityForResult(), NoteEditorActivityResultCallback { @@ -480,6 +486,8 @@ class NoteEditor : AnkiFragment(R.layout.note_editor), DeckSelectionListener, Su override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + // Retrieve the boolean argument "inFragmentedActivity" from the fragment's arguments bundle + inFragmentedActivity = requireArguments().getBoolean(IN_FRAGMENTED_ACTIVITY) // Set up toolbar toolbar = findViewById(R.id.editor_toolbar) toolbar.apply { @@ -497,6 +505,11 @@ class NoteEditor : AnkiFragment(R.layout.note_editor), DeckSelectionListener, Su ) setIconColor(MaterialColors.getColor(requireContext(), R.attr.toolbarIconColor, 0)) } + // Hide mainToolbar since CardBrowser handles the toolbar in fragmented activities. + if (inFragmentedActivity) { + mainToolbar.visibility = View.GONE + } + startLoadingCollection() // TODO this callback doesn't handle predictive back navigation! // see #14678, added to temporarily fix for a bug @@ -1278,7 +1291,9 @@ class NoteEditor : AnkiFragment(R.layout.note_editor), DeckSelectionListener, Su menu.findItem(R.id.action_save).isVisible = iconVisible menu.findItem(R.id.action_preview).isVisible = iconVisible } else { - menu.findItem(R.id.action_add_note_from_note_editor).isVisible = true + // Hide add note item if fragment is in fragmented activity + // because this item is already present in CardBrowser + menu.findItem(R.id.action_add_note_from_note_editor).isVisible = !inFragmentedActivity } if (editFields != null) { for (i in editFields!!.indices) { @@ -1498,6 +1513,11 @@ class NoteEditor : AnkiFragment(R.layout.note_editor), DeckSelectionListener, Su // ensure there are no orphans from possible edit previews CardTemplateNotetype.clearTempModelFiles() + // Don't close this fragment if it is in fragmented activity + if (inFragmentedActivity) { + return + } + // Set the finish animation if there is one on the intent which created the activity val animation = BundleCompat.getParcelable( requireArguments(), @@ -2673,6 +2693,7 @@ class NoteEditor : AnkiFragment(R.layout.note_editor), DeckSelectionListener, Su const val NOTE_CHANGED_EXTRA_KEY = "noteChanged" const val RELOAD_REQUIRED_EXTRA_KEY = "reloadRequired" const val EXTRA_IMG_OCCLUSION = "image_uri" + const val IN_FRAGMENTED_ACTIVITY = "inFragmentedActivity" // calling activity const val CALLER_NO_CALLER = 0 @@ -2697,6 +2718,12 @@ class NoteEditor : AnkiFragment(R.layout.note_editor), DeckSelectionListener, Su private const val PREF_NOTE_EDITOR_FONT_SIZE = "note_editor_font_size" private const val PREF_NOTE_EDITOR_CUSTOM_BUTTONS = "note_editor_custom_buttons" + fun newInstance(launcher: NoteEditorLauncher): NoteEditor { + return NoteEditor().apply { + this.arguments = launcher.toBundle() + } + } + private fun shouldReplaceNewlines(): Boolean { return AnkiDroidApp.instance.sharedPrefs() .getBoolean(PREF_NOTE_EDITOR_NEWLINE_REPLACE, true) diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/dialogs/DiscardChangesDialog.kt b/AnkiDroid/src/main/java/com/ichi2/anki/dialogs/DiscardChangesDialog.kt index 511076061466..1f9c7d208c3a 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/dialogs/DiscardChangesDialog.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/dialogs/DiscardChangesDialog.kt @@ -31,11 +31,12 @@ object DiscardChangesDialog { positiveButtonText: String = context.getString(R.string.discard), negativeButtonText: String = CollectionManager.TR.addingKeepEditing(), message: String = CollectionManager.TR.addingDiscardCurrentInput(), + negativeMethod: () -> Unit = {}, positiveMethod: () -> Unit ) = AlertDialog.Builder(context).show { Timber.i("showing 'discard changes' dialog") message(text = message) positiveButton(text = positiveButtonText) { positiveMethod() } - negativeButton(text = negativeButtonText) + negativeButton(text = negativeButtonText) { negativeMethod() } } } diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/noteeditor/NoteEditorLauncher.kt b/AnkiDroid/src/main/java/com/ichi2/anki/noteeditor/NoteEditorLauncher.kt index e7391b5a305f..b5ca4877e787 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/noteeditor/NoteEditorLauncher.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/noteeditor/NoteEditorLauncher.kt @@ -89,12 +89,13 @@ sealed interface NoteEditorLauncher { * Represents adding a note to the NoteEditor from the card browser. * @property viewModel The view model containing data from the card browser. */ - data class AddNoteFromCardBrowser(val viewModel: CardBrowserViewModel) : + data class AddNoteFromCardBrowser(val viewModel: CardBrowserViewModel, val inFragmentedActivity: Boolean = false) : NoteEditorLauncher { override fun toBundle(): Bundle { val bundle = bundleOf( NoteEditor.EXTRA_CALLER to NoteEditor.CALLER_CARDBROWSER_ADD, - NoteEditor.EXTRA_TEXT_FROM_SEARCH_VIEW to viewModel.searchTerms + NoteEditor.EXTRA_TEXT_FROM_SEARCH_VIEW to viewModel.searchTerms, + NoteEditor.IN_FRAGMENTED_ACTIVITY to inFragmentedActivity ) if (viewModel.lastDeckId?.let { id -> id > 0 } == true) { bundle.putLong(NoteEditor.EXTRA_DID, viewModel.lastDeckId!!) @@ -138,12 +139,13 @@ sealed interface NoteEditorLauncher { * @property cardId The ID of the card to edit. * @property animation The animation direction. */ - data class EditCard(val cardId: CardId, val animation: ActivityTransitionAnimation.Direction) : + data class EditCard(val cardId: CardId, val animation: ActivityTransitionAnimation.Direction, val inFragmentedActivity: Boolean = false) : NoteEditorLauncher { override fun toBundle(): Bundle = bundleOf( NoteEditor.EXTRA_CALLER to NoteEditor.CALLER_EDIT, NoteEditor.EXTRA_CARD_ID to cardId, - AnkiActivity.FINISH_ANIMATION_EXTRA to animation as Parcelable + AnkiActivity.FINISH_ANIMATION_EXTRA to animation as Parcelable, + NoteEditor.IN_FRAGMENTED_ACTIVITY to inFragmentedActivity ) } diff --git a/AnkiDroid/src/main/res/layout-xlarge/cardbrowser.xml b/AnkiDroid/src/main/res/layout-xlarge/cardbrowser.xml new file mode 100644 index 000000000000..a60ac817efbd --- /dev/null +++ b/AnkiDroid/src/main/res/layout-xlarge/cardbrowser.xml @@ -0,0 +1,27 @@ + + + + + + + + + + \ No newline at end of file diff --git a/AnkiDroid/src/main/res/layout/card_browser.xml b/AnkiDroid/src/main/res/layout/card_browser.xml index bd29ef9e983d..32e0b85e219c 100644 --- a/AnkiDroid/src/main/res/layout/card_browser.xml +++ b/AnkiDroid/src/main/res/layout/card_browser.xml @@ -4,16 +4,13 @@ android:id="@+id/root_layout" android:layout_width="match_parent" android:layout_height="match_parent" - xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto"> + xmlns:android="http://schemas.android.com/apk/res/android"> - - + + + + + + diff --git a/AnkiDroid/src/main/res/values/07-cardbrowser.xml b/AnkiDroid/src/main/res/values/07-cardbrowser.xml index 024561696057..b33a0a4bd683 100644 --- a/AnkiDroid/src/main/res/values/07-cardbrowser.xml +++ b/AnkiDroid/src/main/res/values/07-cardbrowser.xml @@ -92,4 +92,6 @@ Edit tags dialog Show order dialog + + Do you want to save changes? \ No newline at end of file diff --git a/AnkiDroid/src/main/res/values/preferences.xml b/AnkiDroid/src/main/res/values/preferences.xml index 7b9f2c97823d..2829ebc369ed 100644 --- a/AnkiDroid/src/main/res/values/preferences.xml +++ b/AnkiDroid/src/main/res/values/preferences.xml @@ -178,6 +178,7 @@ debug_lock_database new_congrats_screen newReviewer + split_cardbrowser newReviewerOptions devOptionsEnabledByUser workInProgressDevOptions diff --git a/AnkiDroid/src/main/res/xml/preferences_dev_options.xml b/AnkiDroid/src/main/res/xml/preferences_dev_options.xml index 9db550cda1e8..51384d10c3fd 100644 --- a/AnkiDroid/src/main/res/xml/preferences_dev_options.xml +++ b/AnkiDroid/src/main/res/xml/preferences_dev_options.xml @@ -48,6 +48,10 @@ android:title="New congrats screen" android:key="@string/new_congrats_screen_pref_key" android:defaultValue="false"/> + diff --git a/AnkiDroid/src/test/java/com/ichi2/anki/CardBrowserTest.kt b/AnkiDroid/src/test/java/com/ichi2/anki/CardBrowserTest.kt index 1a92315adf3c..232620251a05 100644 --- a/AnkiDroid/src/test/java/com/ichi2/anki/CardBrowserTest.kt +++ b/AnkiDroid/src/test/java/com/ichi2/anki/CardBrowserTest.kt @@ -490,7 +490,7 @@ class CardBrowserTest : RobolectricTest() { assertThat("The target deck should be selected", b.lastDeckId, equalTo(targetDid)) - val addIntent = b.addNoteIntent + val addIntent = b.addNoteLauncher.getIntent(targetContext) val bundle = addIntent.getBundleExtra(SingleFragmentActivity.FRAGMENT_ARGS_EXTRA) IntentAssert.hasExtra(bundle, NoteEditor.EXTRA_DID, targetDid) } @@ -504,7 +504,7 @@ class CardBrowserTest : RobolectricTest() { assertThat("The initial deck should be selected", b.lastDeckId, equalTo(initialDid)) - val addIntent = b.addNoteIntent + val addIntent = b.addNoteLauncher.getIntent(targetContext) val bundle = addIntent.getBundleExtra(SingleFragmentActivity.FRAGMENT_ARGS_EXTRA) IntentAssert.hasExtra(bundle, NoteEditor.EXTRA_DID, initialDid) } diff --git a/AnkiDroid/src/test/java/com/ichi2/anki/browser/CardBrowserViewModelTest.kt b/AnkiDroid/src/test/java/com/ichi2/anki/browser/CardBrowserViewModelTest.kt index e4d726684987..0cce10d19868 100644 --- a/AnkiDroid/src/test/java/com/ichi2/anki/browser/CardBrowserViewModelTest.kt +++ b/AnkiDroid/src/test/java/com/ichi2/anki/browser/CardBrowserViewModelTest.kt @@ -134,7 +134,7 @@ class CardBrowserViewModelTest : JvmTest() { assertThat("All decks should be selected", hasSelectedAllDecks()) - val addIntent = CardBrowser.createAddNoteIntent(mockIt(), this) + val addIntent = CardBrowser.createAddNoteLauncher(this).getIntent(mockIt()) val bundle = addIntent.getBundleExtra(SingleFragmentActivity.FRAGMENT_ARGS_EXTRA) IntentAssert.doesNotHaveExtra(bundle, NoteEditor.EXTRA_DID) }