@@ -58,7 +58,6 @@ import androidx.annotation.CheckResult
5858import androidx.annotation.DrawableRes
5959import androidx.annotation.VisibleForTesting
6060import androidx.appcompat.app.AlertDialog
61- import androidx.appcompat.app.AppCompatActivity
6261import androidx.appcompat.widget.AppCompatButton
6362import androidx.appcompat.widget.PopupMenu
6463import androidx.core.content.FileProvider
@@ -239,7 +238,6 @@ class NoteEditorFragment :
239238
240239 @VisibleForTesting
241240 internal var noteTypeSpinner: Spinner ? = null
242- private var deckSpinnerSelection: DeckSpinnerSelection ? = null
243241 private var imageOcclusionButtonsContainer: LinearLayout ? = null
244242 private var selectImageForOcclusionButton: Button ? = null
245243 private var editOcclusionsButton: Button ? = null
@@ -433,11 +431,7 @@ class NoteEditorFragment :
433431 }
434432 require(deck is SelectableDeck .Deck )
435433 deckId = deck.deckId
436- // this is called because DeckSpinnerSelection.onDeckAdded doesn't update the list
437- deckSpinnerSelection!! .initializeNoteEditorDeckSpinner(getColUnsafe)
438- launchCatchingTask {
439- deckSpinnerSelection!! .selectDeckById(deckId, false )
440- }
434+ view?.findViewById<TextView >(R .id.note_deck_name)?.text = deck.name
441435 }
442436
443437 private enum class AddClozeType {
@@ -825,17 +819,14 @@ class NoteEditorFragment :
825819 if (! addNote && editorNote!! .notetype.templates.length() > 1 ) {
826820 deckTextView.setText(R .string.CardEditorCardDeck )
827821 }
828- deckSpinnerSelection =
829- DeckSpinnerSelection (
830- requireContext() as AppCompatActivity ,
831- requireView().findViewById(R .id.note_deck_spinner),
832- showAllDecks = false ,
833- alwaysShowDefault = true ,
834- showFilteredDecks = false ,
835- fragmentManagerSupplier = { childFragmentManager },
836- )
837- deckSpinnerSelection!! .initializeNoteEditorDeckSpinner(col)
822+
838823 deckId = requireArguments().getLong(EXTRA_DID , deckId)
824+ view?.findViewById<TextView >(R .id.note_deck_name)?.apply {
825+ text = col.decks.name(deckId)
826+ setOnClickListener {
827+ startDeckSelection(all = false , filtered = false )
828+ }
829+ }
839830 val getTextFromSearchView = requireArguments().getString(EXTRA_TEXT_FROM_SEARCH_VIEW )
840831 setDid(editorNote)
841832 setNote(editorNote, FieldChangeType .onActivityCreation(shouldReplaceNewlines()))
@@ -1055,7 +1046,7 @@ class NoteEditorFragment :
10551046 }
10561047 KeyEvent .KEYCODE_D -> // null check in case Spinner is moved into options menu in the future
10571048 if (event.isCtrlPressed) {
1058- launchCatchingTask { deckSpinnerSelection !! .displayDeckSelectionDialog( ) }
1049+ launchCatchingTask { startDeckSelection(all = false , filtered = false ) }
10591050 return true
10601051 }
10611052 KeyEvent .KEYCODE_L ->
@@ -1847,7 +1838,7 @@ class NoteEditorFragment :
18471838 )
18481839 if (Build .VERSION .SDK_INT < Build .VERSION_CODES .O ) {
18491840 if (i == 0 ) {
1850- requireView().findViewById<View >(R .id.note_deck_spinner ).nextFocusForwardId = newEditText.id
1841+ requireView().findViewById<View >(R .id.note_deck_name ).nextFocusForwardId = newEditText.id
18511842 }
18521843 if (previous != null ) {
18531844 previous.lastViewInTabOrder.nextFocusForwardId = newEditText.id
@@ -2379,7 +2370,10 @@ class NoteEditorFragment :
23792370 }
23802371
23812372 deckId = calculateDeckId()
2382- launchCatchingTask { deckSpinnerSelection!! .selectDeckById(deckId, false ) }
2373+ launchCatchingTask {
2374+ val selectedDeckName = withCol { decks.name(deckId) }
2375+ view?.findViewById<TextView >(R .id.note_deck_name)?.text = selectedDeckName
2376+ }
23832377 }
23842378
23852379 /* * Refreshes the UI using the currently selected note type as a template */
@@ -2393,7 +2387,7 @@ class NoteEditorFragment :
23932387 changeType : FieldChangeType ,
23942388 ) {
23952389 requireView().findViewById<TextView >(R .id.CardEditorDeckText ).isVisible = ! currentNotetypeIsImageOcclusion()
2396- requireView().findViewById<View >(R .id.note_deck_spinner ).isVisible = ! currentNotetypeIsImageOcclusion()
2390+ requireView().findViewById<View >(R .id.note_deck_name ).isVisible = ! currentNotetypeIsImageOcclusion()
23972391 editorNote =
23982392 if (note == null || addNote) {
23992393 getColUnsafe.run {
@@ -2784,7 +2778,6 @@ class NoteEditorFragment :
27842778
27852779 refreshNoteData(FieldChangeType .changeFieldCount(shouldReplaceNewlines()))
27862780 setDuplicateFieldStyles()
2787- deckSpinnerSelection!! .updateDeckPosition(deckId)
27882781 }
27892782
27902783 // ----------------------------------------------------------------------------
@@ -2858,15 +2851,14 @@ class NoteEditorFragment :
28582851 updateTags()
28592852 requireView().findViewById<View >(R .id.CardEditorTagButton ).isEnabled = false
28602853 // ((LinearLayout) findViewById(R.id.CardEditorCardsButton)).setEnabled(false);
2861- deckSpinnerSelection!! .setEnabledActionBarSpinner(false )
2862- deckSpinnerSelection!! .updateDeckPosition(currentEditedCard!! .did)
2854+ view?.findViewById<TextView >(R .id.note_deck_name)?.isEnabled = false
28632855 updateFieldsFromStickyText()
28642856 } else {
28652857 populateEditFields(FieldChangeType .refresh(shouldReplaceNewlines()), false )
28662858 updateCards(currentEditedCard!! .noteType(getColUnsafe))
28672859 requireView().findViewById<View >(R .id.CardEditorTagButton ).isEnabled = true
28682860 // ((LinearLayout) findViewById(R.id.CardEditorCardsButton)).setEnabled(false);
2869- deckSpinnerSelection !! .setEnabledActionBarSpinner( true )
2861+ view?.findViewById< TextView >( R .id.note_deck_name)?.isEnabled = true
28702862 }
28712863 }
28722864
0 commit comments