Skip to content

Commit

Permalink
fix menu in template editor
Browse files Browse the repository at this point in the history
this was very hard to do because CardTemplateEditor is tightly coupled with CardTemplateFragment, so most changes break something even if not related
  • Loading branch information
RobozinhoD committed Sep 1, 2024
1 parent 4c3fde2 commit 89d32d3
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions AnkiDroid/src/main/java/com/ichi2/anki/CardTemplateEditor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.fragment.app.FragmentContainerView
import androidx.fragment.app.commitNow
import androidx.lifecycle.Lifecycle
import androidx.viewpager2.adapter.FragmentStateAdapter
import androidx.viewpager2.widget.ViewPager2
import com.google.android.material.bottomnavigation.BottomNavigationView
Expand Down Expand Up @@ -638,9 +637,7 @@ open class CardTemplateEditor : AnkiActivity(), DeckSelectionListener {
insertField(bundle.getString(InsertFieldDialog.KEY_INSERTED_FIELD)!!)
}
}
if (!templateEditor.fragmented) {
setupMenu()
}
setupMenu()
}

private fun initTabLayoutMediator() {
Expand Down Expand Up @@ -669,17 +666,14 @@ open class CardTemplateEditor : AnkiActivity(), DeckSelectionListener {
(requireActivity() as MenuHost).addMenuProvider(
object : MenuProvider {
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
menu.clear()
menuInflater.inflate(R.menu.card_template_editor, menu)
setupCommonMenu(menu)
}

override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
return handleCommonMenuItemSelected(menuItem)
}
},
viewLifecycleOwner,
Lifecycle.State.RESUMED
}
)
}

Expand Down

0 comments on commit 89d32d3

Please sign in to comment.