diff --git a/app/detekt_baseline.xml b/app/detekt_baseline.xml
index aec5922a9..58e9e3df9 100644
--- a/app/detekt_baseline.xml
+++ b/app/detekt_baseline.xml
@@ -5,7 +5,7 @@
EmptyFunctionBlock:None.kt$None${ }
EmptyFunctionBlock:SimplePageChangeListener.kt$SimplePageChangeListener${ }
EmptyFunctionBlock:ZimHostActivity.kt$ZimHostActivity.<no name provided>${}
- ForbiddenComment:KiwixMainFragment.kt$KiwixMainFragment$// TODO: Show to user
+ ForbiddenComment:KiwixReaderFragment.kt$KiwixReaderFragment$// TODO: Show to user
ForbiddenComment:ReaderFragment.kt$ReaderFragment$// TODO: Show to user
LongParameterList:ZimManageViewModel.kt$ZimManageViewModel$( booksOnFileSystem: List<BookOnDisk>, activeDownloads: List<DownloadModel>, allLanguages: List<Language>, libraryNetworkEntity: LibraryNetworkEntity, filter: String, fileSystemState: FileSystemState )
MagicNumber:LibraryListItem.kt$LibraryListItem.LibraryDownloadItem$1000L
@@ -46,7 +46,7 @@
ReturnCount:Fat32Checker.kt$Fat32Checker$private fun canCreate4GbFile(storage: String): Boolean
ReturnCount:LanguageActivity.kt$LanguageActivity$override fun onOptionsItemSelected(item: MenuItem): Boolean
TooGenericExceptionCaught:FileWritingFileSystemChecker.kt$FileWritingFileSystemChecker$e: Exception
- TooGenericExceptionCaught:KiwixMainFragment.kt$KiwixMainFragment$e: Exception
+ TooGenericExceptionCaught:KiwixReaderFragment.kt$KiwixReaderFragment$e: Exception
TooGenericExceptionCaught:ReaderFragment.kt$ReaderFragment$e: Exception
TooGenericExceptionThrown:ActivityExtensions.kt$throw RuntimeException( """ applicationContext is ${applicationContext::class.java.simpleName} application is ${application::class.java.simpleName} """.trimIndent() )
TooGenericExceptionThrown:LibraryViewHolder.kt$LibraryViewHolder.LibraryBookViewHolder$throw RuntimeException("impossible invalid state: ${item.fileSystemState}")
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/di/components/KiwixActivityComponent.kt b/app/src/main/java/org/kiwix/kiwixmobile/di/components/KiwixActivityComponent.kt
index 721f6c644..7aafbdf66 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/di/components/KiwixActivityComponent.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/di/components/KiwixActivityComponent.kt
@@ -27,10 +27,10 @@ import org.kiwix.kiwixmobile.intro.IntroModule
import org.kiwix.kiwixmobile.language.LanguageActivity
import org.kiwix.kiwixmobile.local_file_transfer.LocalFileTransferActivity
import org.kiwix.kiwixmobile.main.KiwixMainActivity
-import org.kiwix.kiwixmobile.main.KiwixMainFragment
import org.kiwix.kiwixmobile.main.KiwixNewNavigationActivity
-import org.kiwix.kiwixmobile.nav.destination.library.OnlineLibraryFragment
+import org.kiwix.kiwixmobile.main.KiwixReaderFragment
import org.kiwix.kiwixmobile.nav.destination.library.LocalLibraryFragment
+import org.kiwix.kiwixmobile.nav.destination.library.OnlineLibraryFragment
import org.kiwix.kiwixmobile.nav.destination.reader.ReaderFragment
import org.kiwix.kiwixmobile.settings.KiwixSettingsActivity
import org.kiwix.kiwixmobile.splash.KiwixSplashActivity
@@ -63,9 +63,9 @@ interface KiwixActivityComponent {
fun inject(zimHostActivity: ZimHostActivity)
fun inject(introActivity: IntroActivity)
fun inject(kiwixSplashActivity: KiwixSplashActivity)
- fun inject(kiwixMainFragment: KiwixMainFragment)
fun inject(kiwixNewNavigationActivity: KiwixNewNavigationActivity)
fun inject(onlineLibraryFragment: OnlineLibraryFragment)
+ fun inject(kiwixMainFragment: KiwixReaderFragment)
@Subcomponent.Builder
interface Builder {
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/main/KiwixMainActivity.kt b/app/src/main/java/org/kiwix/kiwixmobile/main/KiwixMainActivity.kt
index 75c852385..b6dfb6c30 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/main/KiwixMainActivity.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/main/KiwixMainActivity.kt
@@ -18,11 +18,8 @@
package org.kiwix.kiwixmobile.main
-import android.content.Intent
import android.os.Bundle
-import android.view.ActionMode
import org.kiwix.kiwixmobile.R
-import org.kiwix.kiwixmobile.core.base.BaseFragmentActivityExtensions
import org.kiwix.kiwixmobile.core.di.components.CoreComponent
import org.kiwix.kiwixmobile.core.main.CoreMainActivity
import org.kiwix.kiwixmobile.kiwixActivityComponent
@@ -32,35 +29,6 @@ class KiwixMainActivity : CoreMainActivity() {
kiwixActivityComponent.inject(this)
}
- override fun onActionModeStarted(mode: ActionMode) {
- super.onActionModeStarted(mode)
- supportFragmentManager.fragments.filterIsInstance().forEach {
- it.onActionModeStarted(mode, this)
- }
- }
-
- override fun onActionModeFinished(mode: ActionMode) {
- super.onActionModeFinished(mode)
- supportFragmentManager.fragments.filterIsInstance().forEach {
- it.onActionModeFinished(mode, this)
- }
- }
-
- override fun onBackPressed() {
- supportFragmentManager.fragments.filterIsInstance().forEach {
- if (it.onBackPressed(this) == BaseFragmentActivityExtensions.Super.ShouldCall) {
- super.onBackPressed()
- }
- }
- }
-
- override fun onNewIntent(intent: Intent) {
- super.onNewIntent(intent)
- supportFragmentManager.fragments.filterIsInstance().forEach {
- it.onNewIntent(intent, this)
- }
- }
-
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_kiwix_new_navigation)
@@ -69,6 +37,6 @@ class KiwixMainActivity : CoreMainActivity() {
return
}
supportFragmentManager.beginTransaction()
- .add(R.id.kiwix_fragment_containter, KiwixMainFragment()).commit()
+ .add(R.id.kiwix_fragment_containter, KiwixReaderFragment()).commit()
}
}
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/main/KiwixNewNavigationActivity.kt b/app/src/main/java/org/kiwix/kiwixmobile/main/KiwixNewNavigationActivity.kt
index 42dfa33fc..f9d73eaca 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/main/KiwixNewNavigationActivity.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/main/KiwixNewNavigationActivity.kt
@@ -30,10 +30,10 @@ import com.google.android.material.bottomnavigation.BottomNavigationView
import org.kiwix.kiwixmobile.R
import org.kiwix.kiwixmobile.core.base.BaseFragmentActivityExtensions
import org.kiwix.kiwixmobile.core.di.components.CoreComponent
-import org.kiwix.kiwixmobile.core.main.CoreNewNavigationActivity
+import org.kiwix.kiwixmobile.core.main.CoreMainActivity
import org.kiwix.kiwixmobile.kiwixActivityComponent
-class KiwixNewNavigationActivity : CoreNewNavigationActivity() {
+class KiwixNewNavigationActivity : CoreMainActivity() {
private lateinit var navController: NavController
private lateinit var appBarConfiguration: AppBarConfiguration
override fun injection(coreComponent: CoreComponent) {
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/main/KiwixMainFragment.kt b/app/src/main/java/org/kiwix/kiwixmobile/main/KiwixReaderFragment.kt
similarity index 99%
rename from app/src/main/java/org/kiwix/kiwixmobile/main/KiwixMainFragment.kt
rename to app/src/main/java/org/kiwix/kiwixmobile/main/KiwixReaderFragment.kt
index 56f1bfcdc..890c1c585 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/main/KiwixMainFragment.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/main/KiwixReaderFragment.kt
@@ -53,7 +53,7 @@ import org.kiwix.kiwixmobile.webserver.ZimHostActivity
import org.kiwix.kiwixmobile.zim_manager.ZimManageActivity
import java.io.File
-class KiwixMainFragment : CoreReaderFragment() {
+class KiwixReaderFragment : CoreReaderFragment() {
override fun inject(baseActivity: BaseActivity) {
baseActivity.kiwixActivityComponent.inject(this)
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/main/NavigationHostFragment.kt b/app/src/main/java/org/kiwix/kiwixmobile/main/NavigationHostFragment.kt
index 3c0c69bf5..7ce290d62 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/main/NavigationHostFragment.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/main/NavigationHostFragment.kt
@@ -19,11 +19,87 @@
package org.kiwix.kiwixmobile.main
import android.content.Intent
+import android.view.ActionMode
+import android.view.Menu
+import androidx.appcompat.app.AppCompatActivity
import androidx.navigation.fragment.NavHostFragment
+import org.kiwix.kiwixmobile.core.base.BaseFragmentActivityExtensions
+import org.kiwix.kiwixmobile.core.base.BaseFragmentActivityExtensions.Super
+import org.kiwix.kiwixmobile.core.base.BaseFragmentActivityExtensions.Super.ShouldCall
+import org.kiwix.kiwixmobile.core.main.KiwixWebView
+import org.kiwix.kiwixmobile.core.main.WebViewProvider
-class NavigationHostFragment : NavHostFragment() {
+class NavigationHostFragment : NavHostFragment(), WebViewProvider, BaseFragmentActivityExtensions {
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
childFragmentManager.fragments.forEach { it.onActivityResult(requestCode, resultCode, data) }
}
+
+ override fun getCurrentWebView(): KiwixWebView? {
+ return childFragmentManager.fragments.filterIsInstance().firstOrNull()
+ ?.getCurrentWebView()
+ }
+
+ override fun onRequestPermissionsResult(
+ requestCode: Int,
+ permissions: Array,
+ grantResults: IntArray
+ ) {
+ super.onRequestPermissionsResult(requestCode, permissions, grantResults)
+ childFragmentManager.fragments.forEach {
+ it.onRequestPermissionsResult(requestCode, permissions, grantResults)
+ }
+ }
+
+ override fun onActionModeStarted(
+ actionMode: ActionMode,
+ activity: AppCompatActivity
+ ): Super {
+ var result = ShouldCall
+ childFragmentManager.fragments.filterIsInstance().forEach {
+ result = it.onActionModeStarted(actionMode, activity)
+ }
+ return result
+ }
+
+ override fun onActionModeFinished(
+ actionMode: ActionMode,
+ activity: AppCompatActivity
+ ): Super {
+ var result = ShouldCall
+ childFragmentManager.fragments.filterIsInstance().forEach {
+ result = it.onActionModeFinished(actionMode, activity)
+ }
+ return result
+ }
+
+ override fun onBackPressed(activity: AppCompatActivity): Super {
+ var result = ShouldCall
+ childFragmentManager.fragments.filterIsInstance().forEach {
+ result = it.onBackPressed(activity)
+ }
+ return result
+ }
+
+ override fun onNewIntent(
+ intent: Intent,
+ activity: AppCompatActivity
+ ): Super {
+ var result = ShouldCall
+ childFragmentManager.fragments.filterIsInstance().forEach {
+ result = it.onNewIntent(intent, activity)
+ }
+ return result
+ }
+
+ override fun onCreateOptionsMenu(
+ menu: Menu,
+ activity: AppCompatActivity
+ ): Super {
+ var result = ShouldCall
+ childFragmentManager.fragments.filterIsInstance().forEach {
+ result = it.onCreateOptionsMenu(menu, activity)
+ }
+ return result
+ }
}
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/base/BaseFragmentActivityExtensions.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/base/BaseFragmentActivityExtensions.kt
index a693f9a8a..8e013a715 100644
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/base/BaseFragmentActivityExtensions.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/base/BaseFragmentActivityExtensions.kt
@@ -22,16 +22,17 @@ import android.content.Intent
import android.view.ActionMode
import android.view.Menu
import androidx.appcompat.app.AppCompatActivity
+import org.kiwix.kiwixmobile.core.base.BaseFragmentActivityExtensions.Super.ShouldCall
interface BaseFragmentActivityExtensions {
enum class Super {
ShouldCall,
- DontCall
+ ShouldNotCall
}
- fun onActionModeStarted(actionMode: ActionMode, activity: AppCompatActivity): Super
- fun onActionModeFinished(actionMode: ActionMode, activity: AppCompatActivity): Super
- fun onBackPressed(activity: AppCompatActivity): Super
- fun onNewIntent(intent: Intent, activity: AppCompatActivity): Super
- fun onCreateOptionsMenu(menu: Menu, activity: AppCompatActivity): Super
+ fun onActionModeStarted(actionMode: ActionMode, activity: AppCompatActivity): Super = ShouldCall
+ fun onActionModeFinished(actionMode: ActionMode, activity: AppCompatActivity): Super = ShouldCall
+ fun onBackPressed(activity: AppCompatActivity): Super = ShouldCall
+ fun onNewIntent(intent: Intent, activity: AppCompatActivity): Super = ShouldCall
+ fun onCreateOptionsMenu(menu: Menu, activity: AppCompatActivity): Super = ShouldCall
}
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreMainActivity.java b/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreMainActivity.java
deleted file mode 100644
index 3898752ec..000000000
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreMainActivity.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Kiwix Android
- * Copyright (c) 2019 Kiwix
- * 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 org.kiwix.kiwixmobile.core.main;
-
-import android.content.Intent;
-import android.os.Bundle;
-import androidx.fragment.app.Fragment;
-import org.jetbrains.annotations.Nullable;
-import org.kiwix.kiwixmobile.core.R;
-import org.kiwix.kiwixmobile.core.base.BaseActivity;
-
-public abstract class CoreMainActivity extends BaseActivity implements WebViewProvider {
- @Override protected void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- }
-
- @Override protected void onActivityResult(int requestCode, int resultCode,
- @androidx.annotation.Nullable Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
-
- for (Fragment it : getSupportFragmentManager().getFragments()) {
- it.onActivityResult(requestCode, resultCode, data);
- }
- }
-
- @androidx.annotation.Nullable @Override public KiwixWebView getCurrentWebView() {
- for (Fragment frag : getSupportFragmentManager().getFragments()) {
- if (frag instanceof WebViewProvider) {
- return ((WebViewProvider) frag).getCurrentWebView();
- }
- }
- return null;
- }
-}
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreMainActivity.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreMainActivity.kt
new file mode 100644
index 000000000..3f44eec17
--- /dev/null
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreMainActivity.kt
@@ -0,0 +1,83 @@
+/*
+ * Kiwix Android
+ * Copyright (c) 2019 Kiwix
+ * 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 org.kiwix.kiwixmobile.core.main
+
+import android.content.Intent
+import android.os.Bundle
+import android.view.ActionMode
+import org.kiwix.kiwixmobile.core.R
+import org.kiwix.kiwixmobile.core.base.BaseActivity
+import org.kiwix.kiwixmobile.core.base.BaseFragmentActivityExtensions
+import org.kiwix.kiwixmobile.core.base.BaseFragmentActivityExtensions.Super.ShouldCall
+
+abstract class CoreMainActivity : BaseActivity(), WebViewProvider {
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_main)
+ }
+
+ override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
+ super.onActivityResult(requestCode, resultCode, data)
+ supportFragmentManager.fragments.forEach { it.onActivityResult(requestCode, resultCode, data) }
+ }
+
+ override fun onRequestPermissionsResult(
+ requestCode: Int,
+ permissions: Array,
+ grantResults: IntArray
+ ) {
+ super.onRequestPermissionsResult(requestCode, permissions, grantResults)
+ supportFragmentManager.fragments.forEach {
+ it.onRequestPermissionsResult(requestCode, permissions, grantResults)
+ }
+ }
+
+ override fun onActionModeStarted(mode: ActionMode) {
+ super.onActionModeStarted(mode)
+ supportFragmentManager.fragments.filterIsInstance().forEach {
+ it.onActionModeStarted(mode, this)
+ }
+ }
+
+ override fun onActionModeFinished(mode: ActionMode) {
+ super.onActionModeFinished(mode)
+ supportFragmentManager.fragments.filterIsInstance().forEach {
+ it.onActionModeFinished(mode, this)
+ }
+ }
+
+ override fun onBackPressed() {
+ supportFragmentManager.fragments.filterIsInstance().forEach {
+ if (it.onBackPressed(this) == ShouldCall) {
+ super.onBackPressed()
+ }
+ }
+ }
+
+ override fun onNewIntent(intent: Intent) {
+ super.onNewIntent(intent)
+ supportFragmentManager.fragments.filterIsInstance().forEach {
+ it.onNewIntent(intent, this)
+ }
+ }
+
+ override fun getCurrentWebView(): KiwixWebView? {
+ return supportFragmentManager.fragments.filterIsInstance().firstOrNull()
+ ?.getCurrentWebView()
+ }
+}
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreNewNavigationActivity.java b/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreNewNavigationActivity.java
deleted file mode 100644
index fa361b56f..000000000
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreNewNavigationActivity.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Kiwix Android
- * Copyright (c) 2020 Kiwix
- * 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 org.kiwix.kiwixmobile.core.main;
-
-import android.content.Intent;
-import androidx.fragment.app.Fragment;
-import org.kiwix.kiwixmobile.core.base.BaseActivity;
-
-public abstract class CoreNewNavigationActivity extends BaseActivity {
-
- @Override protected void onActivityResult(int requestCode, int resultCode,
- @androidx.annotation.Nullable Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
-
- for (Fragment it : getSupportFragmentManager().getFragments()) {
- it.onActivityResult(requestCode, resultCode, data);
- }
- }
-
- @Override public void setContentView(int layoutResID) {
- super.setContentView(layoutResID);
- }
-}
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.java b/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.java
index b9696a137..8b5684800 100644
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.java
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.java
@@ -300,13 +300,12 @@ public abstract class CoreReaderFragment extends BaseFragment
getActivity().getMenuInflater().inflate(R.menu.menu_webview_action, menu);
configureWebViewSelectionHandler(menu);
}
-
return Super.ShouldCall;
}
@NotNull @Override public Super onActionModeFinished(@NotNull ActionMode actionMode,
@NotNull AppCompatActivity activity) {
- actionMode = null;
+ this.actionMode = null;
return Super.ShouldCall;
}
@@ -654,7 +653,7 @@ public abstract class CoreReaderFragment extends BaseFragment
} else {
return Super.ShouldCall;
}
- return Super.DontCall;
+ return Super.ShouldNotCall;
}
private void checkForRateDialog() {
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/main/MainMenu.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/main/MainMenu.kt
index 72d8143e8..37ba3cd1c 100644
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/main/MainMenu.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/main/MainMenu.kt
@@ -23,6 +23,7 @@ import android.view.Menu
import android.view.MenuItem
import android.widget.TextView
import androidx.core.view.isVisible
+import org.kiwix.kiwixmobile.core.BuildConfig
import org.kiwix.kiwixmobile.core.Intents.internal
import org.kiwix.kiwixmobile.core.R
import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.intent
@@ -108,6 +109,9 @@ class MainMenu(
tabSwitcher = null
tabSwitcherTextView = null
}
+
+ newNavigation.isVisible = BuildConfig.DEBUG
+
randomArticle.setShowAsAction(
if (activity.resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE)
MenuItem.SHOW_AS_ACTION_IF_ROOM
diff --git a/custom/src/main/java/org/kiwix/kiwixmobile/custom/main/CustomMainActivity.kt b/custom/src/main/java/org/kiwix/kiwixmobile/custom/main/CustomMainActivity.kt
index 998d1ade7..7c6e25d3b 100644
--- a/custom/src/main/java/org/kiwix/kiwixmobile/custom/main/CustomMainActivity.kt
+++ b/custom/src/main/java/org/kiwix/kiwixmobile/custom/main/CustomMainActivity.kt
@@ -18,10 +18,7 @@
package org.kiwix.kiwixmobile.custom.main
-import android.content.Intent
import android.os.Bundle
-import android.view.ActionMode
-import org.kiwix.kiwixmobile.core.base.BaseFragmentActivityExtensions
import org.kiwix.kiwixmobile.core.di.components.CoreComponent
import org.kiwix.kiwixmobile.core.main.CoreMainActivity
import org.kiwix.kiwixmobile.custom.R
@@ -35,35 +32,6 @@ class CustomMainActivity : CoreMainActivity() {
customActivityComponent.inject(this)
}
- override fun onActionModeStarted(mode: ActionMode) {
- super.onActionModeStarted(mode)
- supportFragmentManager.fragments.filterIsInstance().forEach {
- it.onActionModeStarted(mode, this)
- }
- }
-
- override fun onActionModeFinished(mode: ActionMode) {
- super.onActionModeFinished(mode)
- supportFragmentManager.fragments.filterIsInstance().forEach {
- it.onActionModeFinished(mode, this)
- }
- }
-
- override fun onBackPressed() {
- supportFragmentManager.fragments.filterIsInstance().forEach {
- if (it.onBackPressed(this) == BaseFragmentActivityExtensions.Super.ShouldCall) {
- super.onBackPressed()
- }
- }
- }
-
- override fun onNewIntent(intent: Intent) {
- super.onNewIntent(intent)
- supportFragmentManager.fragments.filterIsInstance().forEach {
- it.onNewIntent(intent, this)
- }
- }
-
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
diff --git a/custom/src/main/java/org/kiwix/kiwixmobile/custom/main/CustomReaderFragment.kt b/custom/src/main/java/org/kiwix/kiwixmobile/custom/main/CustomReaderFragment.kt
index 9f3f271cb..84f177bbe 100644
--- a/custom/src/main/java/org/kiwix/kiwixmobile/custom/main/CustomReaderFragment.kt
+++ b/custom/src/main/java/org/kiwix/kiwixmobile/custom/main/CustomReaderFragment.kt
@@ -40,11 +40,13 @@ import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.drawerlayout.widget.DrawerLayout
import org.kiwix.kiwixmobile.core.base.BaseActivity
-import org.kiwix.kiwixmobile.core.base.BaseFragmentActivityExtensions
+import org.kiwix.kiwixmobile.core.base.BaseFragmentActivityExtensions.Super
+import org.kiwix.kiwixmobile.core.base.BaseFragmentActivityExtensions.Super.ShouldCall
import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.start
import org.kiwix.kiwixmobile.core.main.CoreReaderFragment
import org.kiwix.kiwixmobile.core.main.MainMenu
import org.kiwix.kiwixmobile.core.main.WebViewCallback
+import org.kiwix.kiwixmobile.core.reader.ZimFileReader.Companion.CONTENT_PREFIX
import org.kiwix.kiwixmobile.core.reader.ZimReaderContainer
import org.kiwix.kiwixmobile.core.utils.DialogShower
import org.kiwix.kiwixmobile.core.utils.KiwixDialog
@@ -120,6 +122,14 @@ class CustomReaderFragment : CoreReaderFragment() {
)
}
+ override fun onBackPressed(activity: AppCompatActivity): Super {
+ val result = super.onBackPressed(activity)
+ if (zimReaderContainer.mainPage == getCurrentWebView().url.substringAfter(CONTENT_PREFIX)) {
+ return ShouldCall
+ }
+ return result
+ }
+
override fun onRequestPermissionsResult(
requestCode: Int,
permissions: Array,
@@ -151,18 +161,12 @@ class CustomReaderFragment : CoreReaderFragment() {
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
super.onCreateOptionsMenu(menu, inflater)
- val onCreateOptionsMenu = super.onCreateOptionsMenu(menu, requireActivity().menuInflater)
menu.findItem(R.id.menu_help)?.isVisible = false
menu.findItem(R.id.menu_new_navigation)?.isVisible = false
menu.findItem(R.id.menu_openfile)?.isVisible = false
menu.findItem(R.id.menu_host_books)?.isVisible = false
}
- override fun onCreateOptionsMenu(
- menu: Menu,
- activity: AppCompatActivity
- ): BaseFragmentActivityExtensions.Super = BaseFragmentActivityExtensions.Super.ShouldCall
-
override fun getIconResId() = R.mipmap.ic_launcher
override fun createWebClient(