0
0
mirror of https://github.com/ankidroid/Anki-Android.git synced 2024-09-20 20:03:05 +02:00

Fixed the bug that filtered/custom study decks don't show in the Card browser

This commit is contained in:
MrPenguins 2022-05-21 19:15:39 +08:00 committed by Mike Hardy
parent e0ff9d3533
commit 7673c410ce
4 changed files with 11 additions and 7 deletions

View File

@ -671,7 +671,7 @@ open class CardBrowser :
val deckId = col.decks.selected()
mDeckSpinnerSelection = DeckSpinnerSelection(
this, col, findViewById(R.id.toolbar_spinner),
showAllDecks = true, alwaysShowDefault = false
showAllDecks = true, alwaysShowDefault = false, showFilteredDecks = true
)
mDeckSpinnerSelection!!.initializeActionBarDeckSpinner(this.supportActionBar!!)
selectDeckAndSave(deckId)

View File

@ -19,6 +19,7 @@ import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
import android.widget.ArrayAdapter
import android.widget.Filter
import android.widget.Spinner
import android.widget.TextView
import androidx.appcompat.app.ActionBar
@ -48,13 +49,15 @@ import timber.log.Timber
* 2. All decks from [mAllDeckIds].
* @param showAllDecks Whether the deck selection should allow "All Decks" as an option
* @param alwaysShowDefault If true, never hide the default deck. If false, match [DeckPicker]'s logic
* @param showFilteredDecks whether to show filtered decks
*/
class DeckSpinnerSelection(
private val context: AnkiActivity,
private val collection: Collection,
private val spinner: Spinner,
private val showAllDecks: Boolean,
private val alwaysShowDefault: Boolean
private val alwaysShowDefault: Boolean,
private val showFilteredDecks: Boolean,
) {
/**
* All of the decks shown to the user.
@ -225,9 +228,9 @@ class DeckSpinnerSelection(
/**
* Displays a [DeckSelectionDialog]
*/
fun displayDeckSelectionDialog(col: Collection) {
val nonDynamic = FunctionalInterfaces.Filter { d: Deck -> !Decks.isDynamic(d) }
val decks = fromCollection(col, nonDynamic).toMutableList()
fun displayDeckSelectionDialog(col: Collection?) {
val filter = FunctionalInterfaces.Filter { d: Deck -> showFilteredDecks || !Decks.isDynamic(d) }
val decks = fromCollection(col!!, filter).toMutableList()
if (showAllDecks) {
decks.add(SelectableDeck(ALL_DECKS_ID, context.resources.getString(R.string.card_browser_all_decks)))
}

View File

@ -442,7 +442,8 @@ class NoteEditor : AnkiActivity(), DeckSelectionListener, SubtitleListener, Tags
DeckSpinnerSelection(
this, col, findViewById(R.id.note_deck_spinner),
showAllDecks = false,
alwaysShowDefault = true
alwaysShowDefault = true,
showFilteredDecks = false
)
mDeckSpinnerSelection!!.initializeNoteEditorDeckSpinner(mCurrentEditedCard, addNote)
deckId = intent.getLongExtra(EXTRA_DID, deckId)

View File

@ -116,7 +116,7 @@ class Statistics : NavigationDrawerActivity(), DeckSelectionListener, SubtitleLi
}
mDeckSpinnerSelection = DeckSpinnerSelection(
this, col,
findViewById(R.id.toolbar_spinner), showAllDecks = true, alwaysShowDefault = true
findViewById(R.id.toolbar_spinner), showAllDecks = true, alwaysShowDefault = true, showFilteredDecks = true
)
mDeckSpinnerSelection.initializeActionBarDeckSpinner(this.supportActionBar!!)
mDeckSpinnerSelection.selectDeckById(mStatsDeckId, false)