diff --git a/AnkiDroid/src/main/AndroidManifest.xml b/AnkiDroid/src/main/AndroidManifest.xml
index 964bd51b5bd6..73307fdb3c3d 100644
--- a/AnkiDroid/src/main/AndroidManifest.xml
+++ b/AnkiDroid/src/main/AndroidManifest.xml
@@ -345,6 +345,10 @@
android:label="@string/preview_title"
android:exported="false"
/>
+
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see .
+ */
+package com.ichi2.anki
+
+import android.content.Context
+import android.content.Intent
+import android.os.Bundle
+import androidx.fragment.app.Fragment
+import androidx.fragment.app.FragmentContainerView
+import androidx.fragment.app.commit
+import com.ichi2.themes.setTransparentStatusBar
+import com.ichi2.utils.getInstanceFromClassName
+import kotlin.reflect.KClass
+import kotlin.reflect.jvm.jvmName
+
+/**
+ * Activity aimed to host a fragment on the entire screen.
+ * For that, it uses [R.layout.single_fragment_activity], which has only a [FragmentContainerView]
+ *
+ * Useful to avoid creating a Activity for every new screen
+ * while being able to reuse the fragment on other places.
+ *
+ * [getIntent] can be used as an easy way to build a [SingleFragmentActivity]
+ */
+class SingleFragmentActivity : AnkiActivity() {
+ override fun onCreate(savedInstanceState: Bundle?) {
+ if (showedActivityFailedScreen(savedInstanceState)) {
+ return
+ }
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.single_fragment_activity)
+ setTransparentStatusBar()
+
+ val fragmentClassName = requireNotNull(intent.getStringExtra(FRAGMENT_NAME_EXTRA)) { "'fragmentName' should be provided" }
+ val fragment = getInstanceFromClassName(fragmentClassName).apply {
+ arguments = intent.getBundleExtra(FRAGMENT_ARGS_EXTRA)
+ }
+ supportFragmentManager.commit {
+ replace(R.id.fragment_container, fragment)
+ }
+ }
+ companion object {
+ private const val FRAGMENT_NAME_EXTRA = "fragmentName"
+ private const val FRAGMENT_ARGS_EXTRA = "fragmentArgs"
+
+ fun getIntent(context: Context, fragmentClass: KClass, arguments: Bundle? = null): Intent {
+ return Intent(context, SingleFragmentActivity::class.java).apply {
+ putExtra(FRAGMENT_NAME_EXTRA, fragmentClass.jvmName)
+ putExtra(FRAGMENT_ARGS_EXTRA, arguments)
+ }
+ }
+ }
+}
diff --git a/AnkiDroid/src/main/res/layout/single_fragment_activity.xml b/AnkiDroid/src/main/res/layout/single_fragment_activity.xml
new file mode 100644
index 000000000000..69c55db5af66
--- /dev/null
+++ b/AnkiDroid/src/main/res/layout/single_fragment_activity.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AnkiDroid/src/test/java/com/ichi2/anki/ActivityStartupUnderBackupTest.kt b/AnkiDroid/src/test/java/com/ichi2/anki/ActivityStartupUnderBackupTest.kt
index ee3fd13e137d..d5eeb74ec9a0 100644
--- a/AnkiDroid/src/test/java/com/ichi2/anki/ActivityStartupUnderBackupTest.kt
+++ b/AnkiDroid/src/test/java/com/ichi2/anki/ActivityStartupUnderBackupTest.kt
@@ -53,6 +53,7 @@ class ActivityStartupUnderBackupTest : RobolectricTest() {
notYetHandled(IntentHandler::class.java.simpleName, "Not working (or implemented) - inherits from Activity")
notYetHandled(Preferences::class.java.simpleName, "Not working (or implemented) - inherits from AppCompatPreferenceActivity")
notYetHandled(FilteredDeckOptions::class.java.simpleName, "Not working (or implemented) - inherits from AppCompatPreferenceActivity")
+ notYetHandled(SingleFragmentActivity::class.java.simpleName, "Implemented, but the test fails because the activity throws if a specific intent extra isn't set")
}
/**
diff --git a/AnkiDroid/src/test/java/com/ichi2/testutils/ActivityList.kt b/AnkiDroid/src/test/java/com/ichi2/testutils/ActivityList.kt
index 32ac97a4c823..4f651cb55beb 100644
--- a/AnkiDroid/src/test/java/com/ichi2/testutils/ActivityList.kt
+++ b/AnkiDroid/src/test/java/com/ichi2/testutils/ActivityList.kt
@@ -74,7 +74,8 @@ object ActivityList {
get(IntroductionActivity::class.java),
get(ManageNotetypes::class.java),
get(ManageSpaceActivity::class.java),
- get(PermissionsActivity::class.java)
+ get(PermissionsActivity::class.java),
+ get(SingleFragmentActivity::class.java)
)
}