diff --git a/app/detekt_baseline.xml b/app/detekt_baseline.xml
index afafc1a17..2985f0f99 100644
--- a/app/detekt_baseline.xml
+++ b/app/detekt_baseline.xml
@@ -43,11 +43,6 @@
PackageNaming:SimplePageChangeListener.kt$package org.kiwix.kiwixmobile.zimManager
PackageNaming:StartMultiSelection.kt$package
org.kiwix.kiwixmobile.zimManager.fileselectView.effects
- PackageNaming:HotspotNotificationManager.kt$package org.kiwix.kiwixmobile.webserver.wifi_hotspot
- PackageNaming:HotspotStateReceiver.kt$package org.kiwix.kiwixmobile.webserver.wifi_hotspot
- PackageNaming:IpAddressCallbacks.kt$package org.kiwix.kiwixmobile.webserver.wifi_hotspot
- PackageNaming:HotspotService.kt$package org.kiwix.kiwixmobile.webserver.wifi_hotspot
- PackageNaming:ServerStatus.kt$package org.kiwix.kiwixmobile.webserver.wifi_hotspot
PackageNaming:ZimManageViewModel.kt$package org.kiwix.kiwixmobile.zimManager
ReturnCount:Fat32Checker.kt$Fat32Checker$private fun canCreate4GbFile(storage: String): Boolean
TooGenericExceptionCaught:FileWritingFileSystemChecker.kt$FileWritingFileSystemChecker$e: Exception
diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/webserver/ZimHostRobot.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/webserver/ZimHostRobot.kt
index 57e165360..38078b0ef 100644
--- a/app/src/androidTest/java/org/kiwix/kiwixmobile/webserver/ZimHostRobot.kt
+++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/webserver/ZimHostRobot.kt
@@ -35,7 +35,6 @@ import org.kiwix.kiwixmobile.Findable.StringId.TextId
import org.kiwix.kiwixmobile.Findable.Text
import org.kiwix.kiwixmobile.Findable.ViewId
import org.kiwix.kiwixmobile.core.R
-import org.kiwix.kiwixmobile.R.id
import org.kiwix.kiwixmobile.core.utils.files.Log
import org.kiwix.kiwixmobile.testutils.TestUtils
import org.kiwix.kiwixmobile.testutils.TestUtils.testFlakyView
@@ -75,7 +74,7 @@ class ZimHostRobot : BaseRobot() {
fun startServer() {
// stop the server if it is already running.
stopServerIfAlreadyStarted()
- clickOn(ViewId(id.startServerButton))
+ clickOn(ViewId(R.id.startServerButton))
assetWifiDialogDisplayed()
testFlakyView({ onView(withText("PROCEED")).perform(click()) })
}
@@ -116,7 +115,7 @@ class ZimHostRobot : BaseRobot() {
} catch (assertionFailedError: AssertionFailedError) {
try {
val recyclerViewItemsCount =
- RecyclerViewItemCount(id.recyclerViewZimHost).checkRecyclerViewCount()
+ RecyclerViewItemCount(R.id.recyclerViewZimHost).checkRecyclerViewCount()
(0 until recyclerViewItemsCount)
.asSequence()
.filter { it != 0 }
@@ -130,14 +129,14 @@ class ZimHostRobot : BaseRobot() {
private fun selectZimFile(position: Int) {
try {
onView(
- RecyclerViewMatcher(id.recyclerViewZimHost).atPositionOnView(
+ RecyclerViewMatcher(R.id.recyclerViewZimHost).atPositionOnView(
position,
R.id.itemBookCheckbox
)
).check(matches(ViewMatchers.isChecked()))
} catch (assertionError: AssertionFailedError) {
onView(
- RecyclerViewMatcher(id.recyclerViewZimHost).atPositionOnView(
+ RecyclerViewMatcher(R.id.recyclerViewZimHost).atPositionOnView(
position,
R.id.itemBookCheckbox
)
@@ -148,14 +147,14 @@ class ZimHostRobot : BaseRobot() {
fun assertItemHostedOnServer(itemCount: Int) {
val checkedCheckboxCount =
RecyclerViewSelectedCheckBoxCountAssertion(
- id.recyclerViewZimHost,
+ R.id.recyclerViewZimHost,
R.id.itemBookCheckbox
).countCheckedCheckboxes()
assertThat(checkedCheckboxCount, CoreMatchers.`is`(itemCount))
}
fun stopServer() {
- testFlakyView({ onView(withId(id.startServerButton)).perform(click()) })
+ testFlakyView({ onView(withId(R.id.startServerButton)).perform(click()) })
}
fun assertServerStopped() {
@@ -164,11 +163,11 @@ class ZimHostRobot : BaseRobot() {
}
fun assertQrShown() {
- isVisible(ViewId(id.serverQrCode))
+ isVisible(ViewId(R.id.serverQrCode))
}
fun assertQrNotShown() {
- isNotVisible(ViewId(id.serverQrCode))
+ isNotVisible(ViewId(R.id.serverQrCode))
}
private fun pauseForBetterTestPerformance() {
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 07fe617ea..da3b3ca46 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -152,8 +152,5 @@
-
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 91046d55d..b0949c585 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
@@ -22,8 +22,7 @@ import dagger.BindsInstance
import dagger.Subcomponent
import org.kiwix.kiwixmobile.core.di.ActivityScope
import org.kiwix.kiwixmobile.core.di.components.CoreActivityComponent
-import org.kiwix.kiwixmobile.webserver.ZimHostModule
-import org.kiwix.kiwixmobile.webserver.ZimHostFragment
+import org.kiwix.kiwixmobile.core.webserver.ZimHostModule
import org.kiwix.kiwixmobile.di.modules.KiwixActivityModule
import org.kiwix.kiwixmobile.intro.IntroFragment
import org.kiwix.kiwixmobile.intro.IntroModule
@@ -50,7 +49,6 @@ interface KiwixActivityComponent : CoreActivityComponent {
fun inject(deleteFiles: DeleteFiles)
fun inject(localFileTransferFragment: LocalFileTransferFragment)
fun inject(languageFragment: LanguageFragment)
- fun inject(zimHostFragment: ZimHostFragment)
fun inject(kiwixSettingsFragment: KiwixSettingsFragment)
fun inject(introActivity: IntroFragment)
fun inject(kiwixMainActivity: KiwixMainActivity)
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/di/components/KiwixComponent.kt b/app/src/main/java/org/kiwix/kiwixmobile/di/components/KiwixComponent.kt
index 3b13af038..240f09c8a 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/di/components/KiwixComponent.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/di/components/KiwixComponent.kt
@@ -21,7 +21,6 @@ package org.kiwix.kiwixmobile.di.components
import dagger.Component
import org.kiwix.kiwixmobile.core.di.components.CoreComponent
import org.kiwix.kiwixmobile.di.KiwixScope
-import org.kiwix.kiwixmobile.di.components.ServiceComponent.Builder
import org.kiwix.kiwixmobile.di.modules.KiwixModule
import org.kiwix.kiwixmobile.di.modules.KiwixViewModelModule
@@ -32,5 +31,4 @@ import org.kiwix.kiwixmobile.di.modules.KiwixViewModelModule
)
interface KiwixComponent {
fun activityComponentBuilder(): KiwixActivityComponent.Builder
- fun serviceComponent(): Builder
}
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/di/components/ServiceComponent.kt b/app/src/main/java/org/kiwix/kiwixmobile/di/components/ServiceComponent.kt
deleted file mode 100644
index 8f587f307..000000000
--- a/app/src/main/java/org/kiwix/kiwixmobile/di/components/ServiceComponent.kt
+++ /dev/null
@@ -1,38 +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.di.components
-
-import android.app.Service
-import dagger.BindsInstance
-import dagger.Subcomponent
-import org.kiwix.kiwixmobile.di.ServiceScope
-import org.kiwix.kiwixmobile.di.modules.ServiceModule
-import org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotService
-
-@Subcomponent(modules = [ServiceModule::class])
-@ServiceScope
-interface ServiceComponent {
- fun inject(hotspotService: HotspotService)
-
- @Subcomponent.Builder
- interface Builder {
- @BindsInstance fun service(service: Service): Builder
- fun build(): ServiceComponent
- }
-}
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/di/modules/KiwixActivityModule.kt b/app/src/main/java/org/kiwix/kiwixmobile/di/modules/KiwixActivityModule.kt
index a881282d0..5748e6688 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/di/modules/KiwixActivityModule.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/di/modules/KiwixActivityModule.kt
@@ -20,6 +20,7 @@ package org.kiwix.kiwixmobile.di.modules
import dagger.Module
import org.kiwix.kiwixmobile.core.di.modules.ActivityModule
+import org.kiwix.kiwixmobile.core.webserver.ZimHostModule
-@Module(includes = [ActivityModule::class])
+@Module(includes = [ActivityModule::class, ZimHostModule::class])
class KiwixActivityModule
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/di/modules/KiwixModule.kt b/app/src/main/java/org/kiwix/kiwixmobile/di/modules/KiwixModule.kt
index 7254aad47..0efdf7c1b 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/di/modules/KiwixModule.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/di/modules/KiwixModule.kt
@@ -20,7 +20,6 @@ package org.kiwix.kiwixmobile.di.modules
import android.content.Context
import android.location.LocationManager
-import android.net.wifi.WifiManager
import android.net.wifi.p2p.WifiP2pManager
import dagger.Module
import dagger.Provides
@@ -56,9 +55,4 @@ object KiwixModule {
// See: https://github.com/kiwix/kiwix-android/issues/2488
fun providesWiFiP2pManager(context: Context): WifiP2pManager? =
context.getSystemService(Context.WIFI_P2P_SERVICE) as WifiP2pManager?
-
- @Provides
- @KiwixScope
- fun provideWifiManager(context: Context): WifiManager =
- context.applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager
}
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/di/modules/ServiceModule.kt b/app/src/main/java/org/kiwix/kiwixmobile/di/modules/ServiceModule.kt
deleted file mode 100644
index a48aacfe1..000000000
--- a/app/src/main/java/org/kiwix/kiwixmobile/di/modules/ServiceModule.kt
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Kiwix Android
- * Copyright (c) 2024 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.di.modules
-
-import android.app.NotificationManager
-import android.app.Service
-import android.content.Context
-import dagger.Module
-import dagger.Provides
-import org.kiwix.kiwixmobile.core.qr.GenerateQR
-import org.kiwix.kiwixmobile.di.ServiceScope
-import org.kiwix.kiwixmobile.webserver.KiwixServer
-import org.kiwix.kiwixmobile.webserver.WebServerHelper
-import org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotNotificationManager
-import org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotStateReceiver
-import org.kiwix.kiwixmobile.webserver.wifi_hotspot.IpAddressCallbacks
-
-@Module
-class ServiceModule {
-
- @Provides
- @ServiceScope
- fun providesWebServerHelper(
- kiwixServerFactory: KiwixServer.Factory,
- ipAddressCallbacks: IpAddressCallbacks
- ): WebServerHelper = WebServerHelper(kiwixServerFactory, ipAddressCallbacks)
-
- @Provides
- @ServiceScope
- fun providesIpAddressCallbacks(service: Service): IpAddressCallbacks =
- service as IpAddressCallbacks
-
- @Provides
- @ServiceScope
- fun providesHotspotNotificationManager(
- notificationManager: NotificationManager,
- context: Context,
- generateQR: GenerateQR,
- ): HotspotNotificationManager =
- HotspotNotificationManager(notificationManager, context, generateQR)
-
- @Provides
- @ServiceScope
- fun providesHotspotStateReceiver(callback: HotspotStateReceiver.Callback): HotspotStateReceiver =
- HotspotStateReceiver(callback)
-
- @Provides
- @ServiceScope
- fun providesHotspotStateReceiverCallback(service: Service): HotspotStateReceiver.Callback =
- service as HotspotStateReceiver.Callback
-
- @Provides
- @ServiceScope
- fun providesGenerateQr(): GenerateQR = GenerateQR()
-}
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 e207c6f81..3adf25002 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/main/KiwixMainActivity.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/main/KiwixMainActivity.kt
@@ -23,7 +23,6 @@ import android.content.res.Configuration
import android.os.Bundle
import android.os.Handler
import android.os.Looper
-import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.view.ActionMode
import androidx.core.content.pm.ShortcutInfoCompat
@@ -46,7 +45,6 @@ import kotlinx.coroutines.launch
import org.kiwix.kiwixmobile.BuildConfig
import org.kiwix.kiwixmobile.R
import org.kiwix.kiwixmobile.core.R.drawable
-import org.kiwix.kiwixmobile.core.R.id
import org.kiwix.kiwixmobile.core.R.mipmap
import org.kiwix.kiwixmobile.core.R.string
import org.kiwix.kiwixmobile.core.base.FragmentActivityExtensions
@@ -107,6 +105,8 @@ class KiwixMainActivity : CoreMainActivity() {
override val notesFragmentResId: Int = R.id.notesFragment
override val readerFragmentResId: Int = R.id.readerFragment
override val helpFragmentResId: Int = R.id.helpFragment
+ override val zimHostFragmentResId: Int = R.id.zimHostFragment
+ override val navGraphId: Int = R.navigation.kiwix_nav_graph
override val topLevelDestinations =
setOf(R.id.downloadsFragment, R.id.libraryFragment, R.id.readerFragment)
@@ -310,19 +310,6 @@ class KiwixMainActivity : CoreMainActivity() {
}
}
- override fun onNavigationItemSelected(item: MenuItem): Boolean {
- when (item.itemId) {
- id.menu_host_books -> openZimHostFragment()
- else -> return super.onNavigationItemSelected(item)
- }
- return true
- }
-
- private fun openZimHostFragment() {
- disableDrawer()
- navigate(R.id.zimHostFragment)
- }
-
override fun getIconResId() = mipmap.ic_launcher
override fun createApplicationShortcuts() {
diff --git a/app/src/main/res/navigation/kiwix_nav_graph.xml b/app/src/main/res/navigation/kiwix_nav_graph.xml
index 067bbf5e2..92ab791f2 100644
--- a/app/src/main/res/navigation/kiwix_nav_graph.xml
+++ b/app/src/main/res/navigation/kiwix_nav_graph.xml
@@ -125,7 +125,7 @@
tools:layout="@layout/activity_language" />
PackageNaming:MountPointProducer.kt$package org.kiwix.kiwixmobile.core.zim_manager
PackageNaming:SelectionMode.kt$package org.kiwix.kiwixmobile.core.zim_manager.fileselect_view
PackageNaming:TagsView.kt$package org.kiwix.kiwixmobile.core.zim_manager
+ PackageNaming:HotspotNotificationManager.kt$package org.kiwix.kiwixmobile.core.webserver.wifi_hotspot
+ PackageNaming:HotspotStateReceiver.kt$package org.kiwix.kiwixmobile.core.webserver.wifi_hotspot
+ PackageNaming:IpAddressCallbacks.kt$package org.kiwix.kiwixmobile.core.webserver.wifi_hotspot
+ PackageNaming:HotspotService.kt$package org.kiwix.kiwixmobile.core.webserver.wifi_hotspot
+ PackageNaming:ServerStatus.kt$package org.kiwix.kiwixmobile.core.webserver.wifi_hotspot
PackageNaming:ConnectivityBroadcastReceiver.kt$package org.kiwix.kiwixmobile.core.zim_manager
PackageNaming:NetworkState.kt$package org.kiwix.kiwixmobile.core.zim_manager
ReturnCount:FileUtils.kt$FileUtils$@JvmStatic fun getAllZimParts(book: Book): List<File>
diff --git a/core/src/main/AndroidManifest.xml b/core/src/main/AndroidManifest.xml
index d8ddfacdf..67235d9d6 100644
--- a/core/src/main/AndroidManifest.xml
+++ b/core/src/main/AndroidManifest.xml
@@ -95,5 +95,8 @@
+
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/di/components/CoreActivityComponent.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/di/components/CoreActivityComponent.kt
index 518e6613a..7c20087af 100644
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/di/components/CoreActivityComponent.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/di/components/CoreActivityComponent.kt
@@ -36,10 +36,12 @@ import org.kiwix.kiwixmobile.core.page.notes.viewmodel.effects.ShowOpenNoteDialo
import org.kiwix.kiwixmobile.core.search.SearchFragment
import org.kiwix.kiwixmobile.core.search.viewmodel.effects.ShowDeleteSearchDialog
import org.kiwix.kiwixmobile.core.settings.CorePrefsFragment
+import org.kiwix.kiwixmobile.core.webserver.ZimHostFragment
+import org.kiwix.kiwixmobile.core.webserver.ZimHostModule
@ActivityScope
@Subcomponent(
- modules = [ActivityModule::class]
+ modules = [ActivityModule::class, ZimHostModule::class],
)
interface CoreActivityComponent {
fun inject(searchFragment: SearchFragment)
@@ -55,6 +57,7 @@ interface CoreActivityComponent {
fun inject(helpFragment: HelpFragment)
fun inject(notesFragment: NotesFragment)
fun inject(navigationHistoryDialog: NavigationHistoryDialog)
+ fun inject(zimHostFragment: ZimHostFragment)
@Subcomponent.Builder
interface Builder {
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/di/components/CoreComponent.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/di/components/CoreComponent.kt
index 367f47be0..bec314d56 100644
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/di/components/CoreComponent.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/di/components/CoreComponent.kt
@@ -21,6 +21,7 @@ import android.app.Application
import android.app.NotificationManager
import android.content.Context
import android.net.ConnectivityManager
+import android.net.wifi.WifiManager
import dagger.BindsInstance
import dagger.Component
import eu.mhutti1.utils.storage.StorageSelectDialog
@@ -102,6 +103,7 @@ interface CoreComponent {
fun downloadRoomDao(): DownloadRoomDao
fun newBookmarksDao(): NewBookmarksDao
fun connectivityManager(): ConnectivityManager
+ fun wifiManager(): WifiManager
fun objectBoxToLibkiwixMigrator(): ObjectBoxToLibkiwixMigrator
fun libkiwixBookmarks(): LibkiwixBookmarks
fun recentSearchRoomDao(): RecentSearchRoomDao
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/di/components/CoreServiceComponent.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/di/components/CoreServiceComponent.kt
index 27e559a84..6199a6ea1 100644
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/di/components/CoreServiceComponent.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/di/components/CoreServiceComponent.kt
@@ -25,12 +25,14 @@ import org.kiwix.kiwixmobile.core.di.CoreServiceScope
import org.kiwix.kiwixmobile.core.di.modules.CoreServiceModule
import org.kiwix.kiwixmobile.core.downloader.downloadManager.DownloadMonitorService
import org.kiwix.kiwixmobile.core.read_aloud.ReadAloudService
+import org.kiwix.kiwixmobile.core.webserver.wifi_hotspot.HotspotService
@Subcomponent(modules = [CoreServiceModule::class])
@CoreServiceScope
interface CoreServiceComponent {
fun inject(readAloudService: ReadAloudService)
fun inject(downloadMonitorService: DownloadMonitorService)
+ fun inject(hotspotService: HotspotService)
@Subcomponent.Builder
interface Builder {
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/di/modules/ApplicationModule.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/di/modules/ApplicationModule.kt
index 0e9764bc3..e9d77cdcd 100644
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/di/modules/ApplicationModule.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/di/modules/ApplicationModule.kt
@@ -21,6 +21,7 @@ import android.app.Application
import android.app.NotificationManager
import android.content.Context
import android.net.ConnectivityManager
+import android.net.wifi.WifiManager
import android.os.storage.StorageManager
import dagger.Module
import dagger.Provides
@@ -101,4 +102,9 @@ class ApplicationModule {
@Singleton
fun provideConnectivityManager(context: Context): ConnectivityManager =
context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
+
+ @Provides
+ @Singleton
+ fun provideWifiManager(context: Context): WifiManager =
+ context.applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager
}
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/di/modules/CoreServiceModule.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/di/modules/CoreServiceModule.kt
index 037adf8b4..dc2b6b6e4 100644
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/di/modules/CoreServiceModule.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/di/modules/CoreServiceModule.kt
@@ -19,11 +19,18 @@
package org.kiwix.kiwixmobile.core.di.modules
import android.app.NotificationManager
+import android.app.Service
import android.content.Context
import dagger.Module
import dagger.Provides
import org.kiwix.kiwixmobile.core.di.CoreServiceScope
+import org.kiwix.kiwixmobile.core.qr.GenerateQR
import org.kiwix.kiwixmobile.core.read_aloud.ReadAloudNotificationManger
+import org.kiwix.kiwixmobile.core.webserver.KiwixServer
+import org.kiwix.kiwixmobile.core.webserver.WebServerHelper
+import org.kiwix.kiwixmobile.core.webserver.wifi_hotspot.HotspotNotificationManager
+import org.kiwix.kiwixmobile.core.webserver.wifi_hotspot.HotspotStateReceiver
+import org.kiwix.kiwixmobile.core.webserver.wifi_hotspot.IpAddressCallbacks
@Module
class CoreServiceModule {
@@ -33,4 +40,39 @@ class CoreServiceModule {
notificationManager: NotificationManager,
context: Context
): ReadAloudNotificationManger = ReadAloudNotificationManger(notificationManager, context)
+
+ @Provides
+ @CoreServiceScope
+ fun providesWebServerHelper(
+ kiwixServerFactory: KiwixServer.Factory,
+ ipAddressCallbacks: IpAddressCallbacks
+ ): WebServerHelper = WebServerHelper(kiwixServerFactory, ipAddressCallbacks)
+
+ @Provides
+ @CoreServiceScope
+ fun providesIpAddressCallbacks(service: Service): IpAddressCallbacks =
+ service as IpAddressCallbacks
+
+ @Provides
+ @CoreServiceScope
+ fun providesHotspotNotificationManager(
+ notificationManager: NotificationManager,
+ context: Context,
+ generateQR: GenerateQR,
+ ): HotspotNotificationManager =
+ HotspotNotificationManager(notificationManager, context, generateQR)
+
+ @Provides
+ @CoreServiceScope
+ fun providesHotspotStateReceiver(callback: HotspotStateReceiver.Callback): HotspotStateReceiver =
+ HotspotStateReceiver(callback)
+
+ @Provides
+ @CoreServiceScope
+ fun providesHotspotStateReceiverCallback(service: Service): HotspotStateReceiver.Callback =
+ service as HotspotStateReceiver.Callback
+
+ @Provides
+ @CoreServiceScope
+ fun providesGenerateQr(): GenerateQR = GenerateQR()
}
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
index 1d2ba9acc..0bf531b4c 100644
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreMainActivity.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreMainActivity.kt
@@ -97,6 +97,8 @@ abstract class CoreMainActivity : BaseActivity(), WebViewProvider {
abstract val historyFragmentResId: Int
abstract val notesFragmentResId: Int
abstract val helpFragmentResId: Int
+ abstract val zimHostFragmentResId: Int
+ abstract val navGraphId: Int
abstract val cachedComponent: CoreActivityComponent
abstract val topLevelDestinations: Set
abstract val navHostContainer: FragmentContainerView
@@ -307,11 +309,17 @@ abstract class CoreMainActivity : BaseActivity(), WebViewProvider {
R.id.menu_notes -> openNotes()
R.id.menu_history -> openHistory()
R.id.menu_bookmarks_list -> openBookmarks()
+ R.id.menu_host_books -> openZimHostFragment()
else -> return false
}
return true
}
+ private fun openZimHostFragment() {
+ navigate(zimHostFragmentResId)
+ handleDrawerOnNavigation()
+ }
+
private fun openHelpFragment() {
navigate(helpFragmentResId)
handleDrawerOnNavigation()
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/webserver/KiwixServer.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/webserver/KiwixServer.kt
similarity index 98%
rename from app/src/main/java/org/kiwix/kiwixmobile/webserver/KiwixServer.kt
rename to core/src/main/java/org/kiwix/kiwixmobile/core/webserver/KiwixServer.kt
index 94ebff4bd..fd49f3cf9 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/webserver/KiwixServer.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/webserver/KiwixServer.kt
@@ -16,7 +16,7 @@
*
*/
-package org.kiwix.kiwixmobile.webserver
+package org.kiwix.kiwixmobile.core.webserver
import android.content.Context
import kotlinx.coroutines.Dispatchers
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/webserver/WebServerHelper.kt
similarity index 95%
rename from app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.kt
rename to core/src/main/java/org/kiwix/kiwixmobile/core/webserver/WebServerHelper.kt
index 862266d57..f017274f3 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/webserver/WebServerHelper.kt
@@ -15,7 +15,7 @@
* along with this program. If not, see .
*
*/
-package org.kiwix.kiwixmobile.webserver
+package org.kiwix.kiwixmobile.core.webserver
import io.reactivex.Flowable
import io.reactivex.android.schedulers.AndroidSchedulers
@@ -27,8 +27,8 @@ import org.kiwix.kiwixmobile.core.utils.ServerUtils.INVALID_IP
import org.kiwix.kiwixmobile.core.utils.ServerUtils.getIp
import org.kiwix.kiwixmobile.core.utils.ServerUtils.getIpAddress
import org.kiwix.kiwixmobile.core.utils.files.Log
-import org.kiwix.kiwixmobile.webserver.wifi_hotspot.IpAddressCallbacks
-import org.kiwix.kiwixmobile.webserver.wifi_hotspot.ServerStatus
+import org.kiwix.kiwixmobile.core.webserver.wifi_hotspot.IpAddressCallbacks
+import org.kiwix.kiwixmobile.core.webserver.wifi_hotspot.ServerStatus
import java.util.concurrent.TimeUnit
import javax.inject.Inject
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostCallbacks.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/webserver/ZimHostCallbacks.kt
similarity index 95%
rename from app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostCallbacks.kt
rename to core/src/main/java/org/kiwix/kiwixmobile/core/webserver/ZimHostCallbacks.kt
index f0c9f8425..0a257904c 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostCallbacks.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/webserver/ZimHostCallbacks.kt
@@ -15,7 +15,7 @@
* along with this program. If not, see .
*
*/
-package org.kiwix.kiwixmobile.webserver
+package org.kiwix.kiwixmobile.core.webserver
interface ZimHostCallbacks {
fun onServerStarted(ip: String)
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostContract.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/webserver/ZimHostContract.kt
similarity index 96%
rename from app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostContract.kt
rename to core/src/main/java/org/kiwix/kiwixmobile/core/webserver/ZimHostContract.kt
index e298facf1..95db29e25 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostContract.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/webserver/ZimHostContract.kt
@@ -15,7 +15,7 @@
* along with this program. If not, see .
*
*/
-package org.kiwix.kiwixmobile.webserver
+package org.kiwix.kiwixmobile.core.webserver
import org.kiwix.kiwixmobile.core.base.BaseContract
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostFragment.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/webserver/ZimHostFragment.kt
similarity index 94%
rename from app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostFragment.kt
rename to core/src/main/java/org/kiwix/kiwixmobile/core/webserver/ZimHostFragment.kt
index dc9998561..164e9a61e 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostFragment.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/webserver/ZimHostFragment.kt
@@ -16,7 +16,7 @@
*
*/
-package org.kiwix.kiwixmobile.webserver
+package org.kiwix.kiwixmobile.core.webserver
import android.Manifest
import android.Manifest.permission.POST_NOTIFICATIONS
@@ -42,7 +42,7 @@ import androidx.appcompat.widget.Toolbar
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.fragment.app.FragmentActivity
-import org.kiwix.kiwixmobile.R.layout
+import org.kiwix.kiwixmobile.core.CoreApp.Companion.coreComponent
import org.kiwix.kiwixmobile.core.R
import org.kiwix.kiwixmobile.core.base.BaseActivity
import org.kiwix.kiwixmobile.core.base.BaseFragment
@@ -67,12 +67,12 @@ import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BookOnDisk
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskAdapter
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem.BookOnDisk
-import org.kiwix.kiwixmobile.databinding.ActivityZimHostBinding
-import org.kiwix.kiwixmobile.main.KiwixMainActivity
-import org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotService
-import org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotService.Companion.ACTION_CHECK_IP_ADDRESS
-import org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotService.Companion.ACTION_START_SERVER
-import org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotService.Companion.ACTION_STOP_SERVER
+import org.kiwix.kiwixmobile.core.databinding.ActivityZimHostBinding
+import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.cachedComponent
+import org.kiwix.kiwixmobile.core.webserver.wifi_hotspot.HotspotService
+import org.kiwix.kiwixmobile.core.webserver.wifi_hotspot.HotspotService.Companion.ACTION_CHECK_IP_ADDRESS
+import org.kiwix.kiwixmobile.core.webserver.wifi_hotspot.HotspotService.Companion.ACTION_START_SERVER
+import org.kiwix.kiwixmobile.core.webserver.wifi_hotspot.HotspotService.Companion.ACTION_STOP_SERVER
import javax.inject.Inject
class ZimHostFragment : BaseFragment(), ZimHostCallbacks, ZimHostContract.View {
@@ -178,7 +178,16 @@ class ZimHostFragment : BaseFragment(), ZimHostCallbacks, ZimHostContract.View {
}
override fun inject(baseActivity: BaseActivity) {
- (baseActivity as KiwixMainActivity).cachedComponent.inject(this)
+ baseActivity.cachedComponent.inject(this)
+ }
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ coreComponent
+ .activityComponentBuilder()
+ .activity(requireActivity())
+ .build()
+ .inject(this)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostModule.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/webserver/ZimHostModule.kt
similarity index 95%
rename from app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostModule.kt
rename to core/src/main/java/org/kiwix/kiwixmobile/core/webserver/ZimHostModule.kt
index 7e5ab8392..8692c0106 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostModule.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/webserver/ZimHostModule.kt
@@ -15,7 +15,7 @@
* along with this program. If not, see .
*
*/
-package org.kiwix.kiwixmobile.webserver
+package org.kiwix.kiwixmobile.core.webserver
import dagger.Binds
import dagger.Module
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostPresenter.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/webserver/ZimHostPresenter.kt
similarity index 92%
rename from app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostPresenter.kt
rename to core/src/main/java/org/kiwix/kiwixmobile/core/webserver/ZimHostPresenter.kt
index cd8caf688..1e65966bf 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostPresenter.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/webserver/ZimHostPresenter.kt
@@ -15,7 +15,7 @@
* along with this program. If not, see .
*
*/
-package org.kiwix.kiwixmobile.webserver
+package org.kiwix.kiwixmobile.core.webserver
import org.kiwix.kiwixmobile.core.utils.files.Log
import io.reactivex.SingleObserver
@@ -24,8 +24,8 @@ import org.kiwix.kiwixmobile.core.base.BasePresenter
import org.kiwix.kiwixmobile.core.data.DataSource
import org.kiwix.kiwixmobile.core.di.ActivityScope
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem
-import org.kiwix.kiwixmobile.webserver.ZimHostContract.Presenter
-import org.kiwix.kiwixmobile.webserver.ZimHostContract.View
+import org.kiwix.kiwixmobile.core.webserver.ZimHostContract.Presenter
+import org.kiwix.kiwixmobile.core.webserver.ZimHostContract.View
import javax.inject.Inject
@ActivityScope
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/webserver/wifi_hotspot/HotspotNotificationManager.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/webserver/wifi_hotspot/HotspotNotificationManager.kt
similarity index 94%
rename from app/src/main/java/org/kiwix/kiwixmobile/webserver/wifi_hotspot/HotspotNotificationManager.kt
rename to core/src/main/java/org/kiwix/kiwixmobile/core/webserver/wifi_hotspot/HotspotNotificationManager.kt
index 68ddd798c..f26ff3554 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/webserver/wifi_hotspot/HotspotNotificationManager.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/webserver/wifi_hotspot/HotspotNotificationManager.kt
@@ -15,7 +15,7 @@
* along with this program. If not, see .
*
*/
-package org.kiwix.kiwixmobile.webserver.wifi_hotspot
+package org.kiwix.kiwixmobile.core.webserver.wifi_hotspot
import android.annotation.SuppressLint
import android.app.Notification
@@ -29,8 +29,6 @@ import androidx.core.app.NotificationCompat
import androidx.navigation.NavDeepLinkBuilder
import org.kiwix.kiwixmobile.core.CoreApp
import org.kiwix.kiwixmobile.core.R
-import org.kiwix.kiwixmobile.R.id
-import org.kiwix.kiwixmobile.R.navigation
import org.kiwix.kiwixmobile.core.qr.GenerateQR
import org.kiwix.kiwixmobile.core.utils.HOTSPOT_SERVICE_CHANNEL_ID
import javax.inject.Inject
@@ -62,8 +60,8 @@ class HotspotNotificationManager @Inject constructor(
val contentIntent = NavDeepLinkBuilder(context).setComponentName(
coreMainActivity.mainActivity::class.java
)
- .setGraph(navigation.kiwix_nav_graph)
- .setDestination(id.zimHostFragment)
+ .setGraph(coreMainActivity.navGraphId)
+ .setDestination(coreMainActivity.zimHostFragmentResId)
.createPendingIntent()
hotspotNotificationChannel()
val stopIntent = Intent(context, HotspotService::class.java).setAction(
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/webserver/wifi_hotspot/HotspotService.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/webserver/wifi_hotspot/HotspotService.kt
similarity index 90%
rename from app/src/main/java/org/kiwix/kiwixmobile/webserver/wifi_hotspot/HotspotService.kt
rename to core/src/main/java/org/kiwix/kiwixmobile/core/webserver/wifi_hotspot/HotspotService.kt
index 49c34b8c7..8e16b1d46 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/webserver/wifi_hotspot/HotspotService.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/webserver/wifi_hotspot/HotspotService.kt
@@ -15,7 +15,7 @@
* along with this program. If not, see .
*
*/
-package org.kiwix.kiwixmobile.webserver.wifi_hotspot
+package org.kiwix.kiwixmobile.core.webserver.wifi_hotspot
import android.app.Service
import android.content.Intent
@@ -26,14 +26,14 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
-import org.kiwix.kiwixmobile.KiwixApp
+import org.kiwix.kiwixmobile.core.CoreApp.Companion.coreComponent
import org.kiwix.kiwixmobile.core.R
import org.kiwix.kiwixmobile.core.extensions.registerReceiver
import org.kiwix.kiwixmobile.core.utils.ServerUtils.getSocketAddress
-import org.kiwix.kiwixmobile.webserver.WebServerHelper
-import org.kiwix.kiwixmobile.webserver.ZimHostCallbacks
-import org.kiwix.kiwixmobile.webserver.ZimHostFragment
-import org.kiwix.kiwixmobile.webserver.ZimHostFragment.Companion.RESTART_SERVER
+import org.kiwix.kiwixmobile.core.webserver.WebServerHelper
+import org.kiwix.kiwixmobile.core.webserver.ZimHostCallbacks
+import org.kiwix.kiwixmobile.core.webserver.ZimHostFragment
+import org.kiwix.kiwixmobile.core.webserver.ZimHostFragment.Companion.RESTART_SERVER
import java.lang.ref.WeakReference
import javax.inject.Inject
@@ -58,18 +58,18 @@ class HotspotService :
private val serviceBinder: IBinder = HotspotBinder(this)
override fun onCreate() {
- (this.application as KiwixApp).kiwixComponent
- .serviceComponent()
+ coreComponent
+ .coreServiceComponent()
.service(this)
.build()
.inject(this)
super.onCreate()
- hotspotStateReceiver?.let(this::registerReceiver)
+ hotspotStateReceiver?.let(::registerReceiver)
}
override fun onDestroy() {
webServerHelper?.dispose()
- hotspotStateReceiver?.let(this@HotspotService::unregisterReceiver)
+ hotspotStateReceiver?.let(::unregisterReceiver)
super.onDestroy()
}
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/webserver/wifi_hotspot/HotspotStateReceiver.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/webserver/wifi_hotspot/HotspotStateReceiver.kt
similarity index 92%
rename from app/src/main/java/org/kiwix/kiwixmobile/webserver/wifi_hotspot/HotspotStateReceiver.kt
rename to core/src/main/java/org/kiwix/kiwixmobile/core/webserver/wifi_hotspot/HotspotStateReceiver.kt
index 2482dff38..476d70463 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/webserver/wifi_hotspot/HotspotStateReceiver.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/webserver/wifi_hotspot/HotspotStateReceiver.kt
@@ -15,12 +15,12 @@
* along with this program. If not, see .
*
*/
-package org.kiwix.kiwixmobile.webserver.wifi_hotspot
+package org.kiwix.kiwixmobile.core.webserver.wifi_hotspot
import android.content.Context
import android.content.Intent
import org.kiwix.kiwixmobile.core.base.BaseBroadcastReceiver
-import org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotStateReceiver.HotspotState.DISABLED
+import org.kiwix.kiwixmobile.core.webserver.wifi_hotspot.HotspotStateReceiver.HotspotState.DISABLED
import javax.inject.Inject
const val EXTRA_WIFI_AP_STATE = "wifi_state"
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/webserver/wifi_hotspot/IpAddressCallbacks.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/webserver/wifi_hotspot/IpAddressCallbacks.kt
similarity index 93%
rename from app/src/main/java/org/kiwix/kiwixmobile/webserver/wifi_hotspot/IpAddressCallbacks.kt
rename to core/src/main/java/org/kiwix/kiwixmobile/core/webserver/wifi_hotspot/IpAddressCallbacks.kt
index 936618276..c96d9ccfd 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/webserver/wifi_hotspot/IpAddressCallbacks.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/webserver/wifi_hotspot/IpAddressCallbacks.kt
@@ -15,7 +15,7 @@
* along with this program. If not, see .
*
*/
-package org.kiwix.kiwixmobile.webserver.wifi_hotspot
+package org.kiwix.kiwixmobile.core.webserver.wifi_hotspot
interface IpAddressCallbacks {
fun onIpAddressValid()
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/webserver/wifi_hotspot/ServerStatus.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/webserver/wifi_hotspot/ServerStatus.kt
similarity index 93%
rename from app/src/main/java/org/kiwix/kiwixmobile/webserver/wifi_hotspot/ServerStatus.kt
rename to core/src/main/java/org/kiwix/kiwixmobile/core/webserver/wifi_hotspot/ServerStatus.kt
index 194cb2f2a..1b88aaf4a 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/webserver/wifi_hotspot/ServerStatus.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/webserver/wifi_hotspot/ServerStatus.kt
@@ -16,7 +16,7 @@
*
*/
-package org.kiwix.kiwixmobile.webserver.wifi_hotspot
+package org.kiwix.kiwixmobile.core.webserver.wifi_hotspot
data class ServerStatus(
val isServerStarted: Boolean,
diff --git a/app/src/main/res/layout/activity_zim_host.xml b/core/src/main/res/layout/activity_zim_host.xml
similarity index 100%
rename from app/src/main/res/layout/activity_zim_host.xml
rename to core/src/main/res/layout/activity_zim_host.xml
diff --git a/custom/src/main/java/org/kiwix/kiwixmobile/custom/di/CustomActivityComponent.kt b/custom/src/main/java/org/kiwix/kiwixmobile/custom/di/CustomActivityComponent.kt
index 9456ac62d..b5138a828 100644
--- a/custom/src/main/java/org/kiwix/kiwixmobile/custom/di/CustomActivityComponent.kt
+++ b/custom/src/main/java/org/kiwix/kiwixmobile/custom/di/CustomActivityComponent.kt
@@ -22,6 +22,7 @@ import android.app.Activity
import dagger.BindsInstance
import dagger.Subcomponent
import org.kiwix.kiwixmobile.core.di.ActivityScope
+import org.kiwix.kiwixmobile.core.webserver.ZimHostModule
import org.kiwix.kiwixmobile.core.di.components.CoreActivityComponent
import org.kiwix.kiwixmobile.custom.download.CustomDownloadFragment
import org.kiwix.kiwixmobile.custom.main.CustomMainActivity
@@ -29,7 +30,7 @@ import org.kiwix.kiwixmobile.custom.main.CustomReaderFragment
import org.kiwix.kiwixmobile.custom.settings.CustomSettingsFragment
@ActivityScope
-@Subcomponent(modules = [CustomActivityModule::class])
+@Subcomponent(modules = [CustomActivityModule::class, ZimHostModule::class])
interface CustomActivityComponent : CoreActivityComponent {
fun inject(customMainActivity: CustomMainActivity)
fun inject(customSettingsFragment: CustomSettingsFragment)
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 813bdd997..875e8d907 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
@@ -75,6 +75,8 @@ class CustomMainActivity : CoreMainActivity() {
override val historyFragmentResId: Int = R.id.historyFragment
override val notesFragmentResId: Int = R.id.notesFragment
override val helpFragmentResId: Int = R.id.helpFragment
+ override val zimHostFragmentResId: Int = R.id.zimHostFragment
+ override val navGraphId: Int = R.navigation.custom_nav_graph
override val cachedComponent by lazy { customActivityComponent }
override val topLevelDestinations =
setOf(R.id.customReaderFragment)
@@ -114,7 +116,7 @@ class CustomMainActivity : CoreMainActivity() {
* For more info see https://github.com/kiwix/kiwix-android/pull/3516,
* https://github.com/kiwix/kiwix-android/issues/4026
*/
- menu.findItem(org.kiwix.kiwixmobile.core.R.id.menu_host_books)?.isVisible = false
+ menu.findItem(org.kiwix.kiwixmobile.core.R.id.menu_host_books)?.isVisible = true
/**
* Hide the `HelpFragment` from custom apps.
* We have not removed the relevant code for `HelpFragment` from custom apps.
diff --git a/custom/src/main/res/navigation/custom_nav_graph.xml b/custom/src/main/res/navigation/custom_nav_graph.xml
index 198bb8c4b..6efe07808 100644
--- a/custom/src/main/res/navigation/custom_nav_graph.xml
+++ b/custom/src/main/res/navigation/custom_nav_graph.xml
@@ -55,6 +55,10 @@
android:id="@+id/bookmarksFragment"
android:name="org.kiwix.kiwixmobile.core.page.bookmark.BookmarksFragment"
android:label="BookmarksFragment" />
+