diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/pages/ImageOcclusion.kt b/AnkiDroid/src/main/java/com/ichi2/anki/pages/ImageOcclusion.kt index 0cd25597e781..423bf80c28cf 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/pages/ImageOcclusion.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/pages/ImageOcclusion.kt @@ -18,18 +18,35 @@ package com.ichi2.anki.pages import android.content.Context import android.content.Intent import android.os.Bundle +import android.view.View import android.webkit.WebView import androidx.core.os.bundleOf +import com.google.android.material.appbar.MaterialToolbar import com.ichi2.anki.CollectionManager.TR import com.ichi2.anki.ImageOcclusionActivity +import com.ichi2.anki.R import org.json.JSONObject -class ImageOcclusion : PageFragment() { +class ImageOcclusion : PageFragment(R.layout.image_occlusion) { override val title: String get() = TR.notetypesImageOcclusionName() override val pageName = "image-occlusion" + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + view.findViewById(R.id.toolbar).apply { + setOnMenuItemClickListener { + if (it.itemId == R.id.action_add) { + webView.evaluateJavascript("anki.imageOcclusion.addNote()", null) + } + return@setOnMenuItemClickListener true + } + setNavigationOnClickListener { requireActivity().onBackPressedDispatcher.onBackPressed() } + } + } + override fun onCreateWebViewClient(savedInstanceState: Bundle?): PageWebViewClient { val kind = arguments?.getString(ARG_KEY_KIND) ?: throw Exception("missing kind") val id = arguments?.getLong(ARG_KEY_ID) ?: throw Exception("missing ID") diff --git a/AnkiDroid/src/main/res/layout/image_occlusion.xml b/AnkiDroid/src/main/res/layout/image_occlusion.xml new file mode 100644 index 000000000000..3f331dd71ee5 --- /dev/null +++ b/AnkiDroid/src/main/res/layout/image_occlusion.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/AnkiDroid/src/main/res/menu/image_occlusion.xml b/AnkiDroid/src/main/res/menu/image_occlusion.xml new file mode 100644 index 000000000000..6e2f71861165 --- /dev/null +++ b/AnkiDroid/src/main/res/menu/image_occlusion.xml @@ -0,0 +1,10 @@ + + + + \ No newline at end of file