@@ -24,7 +24,6 @@ import androidx.annotation.VisibleForTesting
2424import androidx.appcompat.app.AlertDialog
2525import com.google.android.material.snackbar.Snackbar
2626import com.ichi2.anki.CollectionManager
27- import com.ichi2.anki.CollectionManager.withCol
2827import com.ichi2.anki.R
2928import com.ichi2.anki.common.annotations.NeedsTest
3029import com.ichi2.anki.libanki.Collection
@@ -62,7 +61,6 @@ class CreateDeckDialog(
6261 private var shownDialog: AlertDialog ? = null
6362
6463 enum class DeckDialogType {
65- FILTERED_DECK ,
6664 DECK ,
6765 SUB_DECK ,
6866 RENAME_DECK ,
@@ -71,15 +69,6 @@ class CreateDeckDialog(
7169 private val getColUnsafe
7270 get() = CollectionManager .getColUnsafe()
7371
74- suspend fun showFilteredDeckDialog () {
75- Timber .i(" CreateDeckDialog::showFilteredDeckDialog" )
76- initialDeckName =
77- withCol {
78- sched.getOrCreateFilteredDeck(did = 0 ).name
79- }
80- showDialog()
81- }
82-
8372 /* * Used for rename */
8473 var deckName: String
8574 get() = shownDialog!! .getInputField().text.toString()
@@ -102,7 +91,6 @@ class CreateDeckDialog(
10291
10392 DeckDialogType .DECK ,
10493 DeckDialogType .SUB_DECK ,
105- DeckDialogType .FILTERED_DECK ,
10694 -> R .string.dialog_positive_create
10795 }
10896 positiveButton(positiveButtonTextRes) {
@@ -181,7 +169,7 @@ class CreateDeckDialog(
181169 */
182170 private fun fullyQualifyDeckName (dialogText : CharSequence ) =
183171 when (deckDialogType) {
184- DeckDialogType .DECK , DeckDialogType .FILTERED_DECK , DeckDialogType . RENAME_DECK -> dialogText.toString()
172+ DeckDialogType .DECK , DeckDialogType .RENAME_DECK -> dialogText.toString()
185173 DeckDialogType .SUB_DECK -> getColUnsafe.decks.getSubdeckName(parentId!! , dialogText.toString())
186174 }
187175
@@ -206,34 +194,6 @@ class CreateDeckDialog(
206194 shownDialog?.dismiss()
207195 }
208196
209- fun createFilteredDeck (deckName : String ): Boolean {
210- fun validFilteredDeckName (initialName : String ): String {
211- for (i in 0 .. 10 ) {
212- val name = initialName + " +" .repeat(i)
213- if (getColUnsafe.decks.byName(name) == null ) return name
214- }
215- throw IllegalStateException (" Could not generate valid name" )
216- }
217-
218- try {
219- // create filtered deck
220- Timber .i(" CreateDeckDialog::createFilteredDeck..." )
221- val newDeckId = getColUnsafe.decks.newFiltered(validFilteredDeckName(deckName))
222- Timber .d(" Created filtered deck '%s'; id: %d" , deckName, newDeckId)
223- onNewDeckCreated(newDeckId)
224- } catch (ex: IllegalStateException ) {
225- if (ex.message != " Could not generate valid name" ) {
226- throw ex
227- }
228- displayFeedback(ex.localizedMessage ? : ex.message ? : " " , Snackbar .LENGTH_LONG )
229- return false
230- } catch (ex: BackendDeckIsFilteredException ) {
231- displayFeedback(ex.localizedMessage ? : ex.message ? : " " , Snackbar .LENGTH_LONG )
232- return false
233- }
234- return true
235- }
236-
237197 private fun createNewDeck (deckName : String ): Boolean {
238198 try {
239199 // create normal deck or sub deck
@@ -262,10 +222,6 @@ class CreateDeckDialog(
262222 // create sub deck
263223 createSubDeck(parentId!! , deckName)
264224 }
265- DeckDialogType .FILTERED_DECK -> {
266- // create filtered deck
267- createFilteredDeck(deckName)
268- }
269225 }
270226 }
271227 }
0 commit comments