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 015b06f commit 1b94814
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
5 changes: 1 addition & 4 deletions AnkiDroid/src/main/java/com/ichi2/anki/CardTemplateEditor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -638,9 +638,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,7 +667,6 @@ 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)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/root_layout"
xmlns:app="http://schemas.android.com/apk/res-auto">
tools:context=".CardTemplateEditor">

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
Expand Down
5 changes: 4 additions & 1 deletion AnkiDroid/src/main/res/layout/card_template_editor.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/root_layout">
android:id="@+id/root_layout"
tools:context=".CardTemplateEditor"
>

<LinearLayout
android:layout_width="match_parent"
Expand Down
4 changes: 3 additions & 1 deletion AnkiDroid/src/main/res/layout/card_template_editor_top.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
android:minHeight="?attr/actionBarSize"
android:theme="@style/ActionBarStyle"
app:navigationContentDescription="@string/abc_action_bar_up_description"
app:navigationIcon="?attr/homeAsUpIndicator"/>
app:navigationIcon="?attr/homeAsUpIndicator"
app:menu="@menu/card_template_editor"
/>

<com.google.android.material.tabs.TabLayout
style="@style/TabLayoutStyle"
Expand Down

0 comments on commit 1b94814

Please sign in to comment.