mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-19 04:16:27 -04:00
Reintroduced the "Hotspot Feature" for custom apps.
This commit is contained in:
parent
a88884a055
commit
0485691ab0
@ -43,11 +43,6 @@
|
|||||||
<ID>PackageNaming:SimplePageChangeListener.kt$package org.kiwix.kiwixmobile.zimManager</ID>
|
<ID>PackageNaming:SimplePageChangeListener.kt$package org.kiwix.kiwixmobile.zimManager</ID>
|
||||||
<ID>PackageNaming:StartMultiSelection.kt$package
|
<ID>PackageNaming:StartMultiSelection.kt$package
|
||||||
org.kiwix.kiwixmobile.zimManager.fileselectView.effects</ID>
|
org.kiwix.kiwixmobile.zimManager.fileselectView.effects</ID>
|
||||||
<ID>PackageNaming:HotspotNotificationManager.kt$package org.kiwix.kiwixmobile.webserver.wifi_hotspot</ID>
|
|
||||||
<ID>PackageNaming:HotspotStateReceiver.kt$package org.kiwix.kiwixmobile.webserver.wifi_hotspot</ID>
|
|
||||||
<ID>PackageNaming:IpAddressCallbacks.kt$package org.kiwix.kiwixmobile.webserver.wifi_hotspot</ID>
|
|
||||||
<ID>PackageNaming:HotspotService.kt$package org.kiwix.kiwixmobile.webserver.wifi_hotspot</ID>
|
|
||||||
<ID>PackageNaming:ServerStatus.kt$package org.kiwix.kiwixmobile.webserver.wifi_hotspot</ID>
|
|
||||||
<ID>PackageNaming:ZimManageViewModel.kt$package org.kiwix.kiwixmobile.zimManager</ID>
|
<ID>PackageNaming:ZimManageViewModel.kt$package org.kiwix.kiwixmobile.zimManager</ID>
|
||||||
<ID>ReturnCount:Fat32Checker.kt$Fat32Checker$private fun canCreate4GbFile(storage: String): Boolean</ID>
|
<ID>ReturnCount:Fat32Checker.kt$Fat32Checker$private fun canCreate4GbFile(storage: String): Boolean</ID>
|
||||||
<ID>TooGenericExceptionCaught:FileWritingFileSystemChecker.kt$FileWritingFileSystemChecker$e: Exception</ID>
|
<ID>TooGenericExceptionCaught:FileWritingFileSystemChecker.kt$FileWritingFileSystemChecker$e: Exception</ID>
|
||||||
|
@ -35,7 +35,6 @@ import org.kiwix.kiwixmobile.Findable.StringId.TextId
|
|||||||
import org.kiwix.kiwixmobile.Findable.Text
|
import org.kiwix.kiwixmobile.Findable.Text
|
||||||
import org.kiwix.kiwixmobile.Findable.ViewId
|
import org.kiwix.kiwixmobile.Findable.ViewId
|
||||||
import org.kiwix.kiwixmobile.core.R
|
import org.kiwix.kiwixmobile.core.R
|
||||||
import org.kiwix.kiwixmobile.R.id
|
|
||||||
import org.kiwix.kiwixmobile.core.utils.files.Log
|
import org.kiwix.kiwixmobile.core.utils.files.Log
|
||||||
import org.kiwix.kiwixmobile.testutils.TestUtils
|
import org.kiwix.kiwixmobile.testutils.TestUtils
|
||||||
import org.kiwix.kiwixmobile.testutils.TestUtils.testFlakyView
|
import org.kiwix.kiwixmobile.testutils.TestUtils.testFlakyView
|
||||||
@ -75,7 +74,7 @@ class ZimHostRobot : BaseRobot() {
|
|||||||
fun startServer() {
|
fun startServer() {
|
||||||
// stop the server if it is already running.
|
// stop the server if it is already running.
|
||||||
stopServerIfAlreadyStarted()
|
stopServerIfAlreadyStarted()
|
||||||
clickOn(ViewId(id.startServerButton))
|
clickOn(ViewId(R.id.startServerButton))
|
||||||
assetWifiDialogDisplayed()
|
assetWifiDialogDisplayed()
|
||||||
testFlakyView({ onView(withText("PROCEED")).perform(click()) })
|
testFlakyView({ onView(withText("PROCEED")).perform(click()) })
|
||||||
}
|
}
|
||||||
@ -116,7 +115,7 @@ class ZimHostRobot : BaseRobot() {
|
|||||||
} catch (assertionFailedError: AssertionFailedError) {
|
} catch (assertionFailedError: AssertionFailedError) {
|
||||||
try {
|
try {
|
||||||
val recyclerViewItemsCount =
|
val recyclerViewItemsCount =
|
||||||
RecyclerViewItemCount(id.recyclerViewZimHost).checkRecyclerViewCount()
|
RecyclerViewItemCount(R.id.recyclerViewZimHost).checkRecyclerViewCount()
|
||||||
(0 until recyclerViewItemsCount)
|
(0 until recyclerViewItemsCount)
|
||||||
.asSequence()
|
.asSequence()
|
||||||
.filter { it != 0 }
|
.filter { it != 0 }
|
||||||
@ -130,14 +129,14 @@ class ZimHostRobot : BaseRobot() {
|
|||||||
private fun selectZimFile(position: Int) {
|
private fun selectZimFile(position: Int) {
|
||||||
try {
|
try {
|
||||||
onView(
|
onView(
|
||||||
RecyclerViewMatcher(id.recyclerViewZimHost).atPositionOnView(
|
RecyclerViewMatcher(R.id.recyclerViewZimHost).atPositionOnView(
|
||||||
position,
|
position,
|
||||||
R.id.itemBookCheckbox
|
R.id.itemBookCheckbox
|
||||||
)
|
)
|
||||||
).check(matches(ViewMatchers.isChecked()))
|
).check(matches(ViewMatchers.isChecked()))
|
||||||
} catch (assertionError: AssertionFailedError) {
|
} catch (assertionError: AssertionFailedError) {
|
||||||
onView(
|
onView(
|
||||||
RecyclerViewMatcher(id.recyclerViewZimHost).atPositionOnView(
|
RecyclerViewMatcher(R.id.recyclerViewZimHost).atPositionOnView(
|
||||||
position,
|
position,
|
||||||
R.id.itemBookCheckbox
|
R.id.itemBookCheckbox
|
||||||
)
|
)
|
||||||
@ -148,14 +147,14 @@ class ZimHostRobot : BaseRobot() {
|
|||||||
fun assertItemHostedOnServer(itemCount: Int) {
|
fun assertItemHostedOnServer(itemCount: Int) {
|
||||||
val checkedCheckboxCount =
|
val checkedCheckboxCount =
|
||||||
RecyclerViewSelectedCheckBoxCountAssertion(
|
RecyclerViewSelectedCheckBoxCountAssertion(
|
||||||
id.recyclerViewZimHost,
|
R.id.recyclerViewZimHost,
|
||||||
R.id.itemBookCheckbox
|
R.id.itemBookCheckbox
|
||||||
).countCheckedCheckboxes()
|
).countCheckedCheckboxes()
|
||||||
assertThat(checkedCheckboxCount, CoreMatchers.`is`(itemCount))
|
assertThat(checkedCheckboxCount, CoreMatchers.`is`(itemCount))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun stopServer() {
|
fun stopServer() {
|
||||||
testFlakyView({ onView(withId(id.startServerButton)).perform(click()) })
|
testFlakyView({ onView(withId(R.id.startServerButton)).perform(click()) })
|
||||||
}
|
}
|
||||||
|
|
||||||
fun assertServerStopped() {
|
fun assertServerStopped() {
|
||||||
@ -164,11 +163,11 @@ class ZimHostRobot : BaseRobot() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun assertQrShown() {
|
fun assertQrShown() {
|
||||||
isVisible(ViewId(id.serverQrCode))
|
isVisible(ViewId(R.id.serverQrCode))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun assertQrNotShown() {
|
fun assertQrNotShown() {
|
||||||
isNotVisible(ViewId(id.serverQrCode))
|
isNotVisible(ViewId(R.id.serverQrCode))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun pauseForBetterTestPerformance() {
|
private fun pauseForBetterTestPerformance() {
|
||||||
|
@ -152,8 +152,5 @@
|
|||||||
<action android:name="KiwixSearchWidget.STAR_CLICKED" />
|
<action android:name="KiwixSearchWidget.STAR_CLICKED" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
<service
|
|
||||||
android:name=".webserver.wifi_hotspot.HotspotService"
|
|
||||||
android:foregroundServiceType="dataSync" />
|
|
||||||
</application>
|
</application>
|
||||||
</manifest>
|
</manifest>
|
||||||
|
@ -22,8 +22,7 @@ import dagger.BindsInstance
|
|||||||
import dagger.Subcomponent
|
import dagger.Subcomponent
|
||||||
import org.kiwix.kiwixmobile.core.di.ActivityScope
|
import org.kiwix.kiwixmobile.core.di.ActivityScope
|
||||||
import org.kiwix.kiwixmobile.core.di.components.CoreActivityComponent
|
import org.kiwix.kiwixmobile.core.di.components.CoreActivityComponent
|
||||||
import org.kiwix.kiwixmobile.webserver.ZimHostModule
|
import org.kiwix.kiwixmobile.core.webserver.ZimHostModule
|
||||||
import org.kiwix.kiwixmobile.webserver.ZimHostFragment
|
|
||||||
import org.kiwix.kiwixmobile.di.modules.KiwixActivityModule
|
import org.kiwix.kiwixmobile.di.modules.KiwixActivityModule
|
||||||
import org.kiwix.kiwixmobile.intro.IntroFragment
|
import org.kiwix.kiwixmobile.intro.IntroFragment
|
||||||
import org.kiwix.kiwixmobile.intro.IntroModule
|
import org.kiwix.kiwixmobile.intro.IntroModule
|
||||||
@ -50,7 +49,6 @@ interface KiwixActivityComponent : CoreActivityComponent {
|
|||||||
fun inject(deleteFiles: DeleteFiles)
|
fun inject(deleteFiles: DeleteFiles)
|
||||||
fun inject(localFileTransferFragment: LocalFileTransferFragment)
|
fun inject(localFileTransferFragment: LocalFileTransferFragment)
|
||||||
fun inject(languageFragment: LanguageFragment)
|
fun inject(languageFragment: LanguageFragment)
|
||||||
fun inject(zimHostFragment: ZimHostFragment)
|
|
||||||
fun inject(kiwixSettingsFragment: KiwixSettingsFragment)
|
fun inject(kiwixSettingsFragment: KiwixSettingsFragment)
|
||||||
fun inject(introActivity: IntroFragment)
|
fun inject(introActivity: IntroFragment)
|
||||||
fun inject(kiwixMainActivity: KiwixMainActivity)
|
fun inject(kiwixMainActivity: KiwixMainActivity)
|
||||||
|
@ -21,7 +21,6 @@ package org.kiwix.kiwixmobile.di.components
|
|||||||
import dagger.Component
|
import dagger.Component
|
||||||
import org.kiwix.kiwixmobile.core.di.components.CoreComponent
|
import org.kiwix.kiwixmobile.core.di.components.CoreComponent
|
||||||
import org.kiwix.kiwixmobile.di.KiwixScope
|
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.KiwixModule
|
||||||
import org.kiwix.kiwixmobile.di.modules.KiwixViewModelModule
|
import org.kiwix.kiwixmobile.di.modules.KiwixViewModelModule
|
||||||
|
|
||||||
@ -32,5 +31,4 @@ import org.kiwix.kiwixmobile.di.modules.KiwixViewModelModule
|
|||||||
)
|
)
|
||||||
interface KiwixComponent {
|
interface KiwixComponent {
|
||||||
fun activityComponentBuilder(): KiwixActivityComponent.Builder
|
fun activityComponentBuilder(): KiwixActivityComponent.Builder
|
||||||
fun serviceComponent(): Builder
|
|
||||||
}
|
}
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
/*
|
|
||||||
* Kiwix Android
|
|
||||||
* Copyright (c) 2019 Kiwix <android.kiwix.org>
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
@ -20,6 +20,7 @@ package org.kiwix.kiwixmobile.di.modules
|
|||||||
|
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import org.kiwix.kiwixmobile.core.di.modules.ActivityModule
|
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
|
class KiwixActivityModule
|
||||||
|
@ -20,7 +20,6 @@ package org.kiwix.kiwixmobile.di.modules
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.location.LocationManager
|
import android.location.LocationManager
|
||||||
import android.net.wifi.WifiManager
|
|
||||||
import android.net.wifi.p2p.WifiP2pManager
|
import android.net.wifi.p2p.WifiP2pManager
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.Provides
|
import dagger.Provides
|
||||||
@ -56,9 +55,4 @@ object KiwixModule {
|
|||||||
// See: https://github.com/kiwix/kiwix-android/issues/2488
|
// See: https://github.com/kiwix/kiwix-android/issues/2488
|
||||||
fun providesWiFiP2pManager(context: Context): WifiP2pManager? =
|
fun providesWiFiP2pManager(context: Context): WifiP2pManager? =
|
||||||
context.getSystemService(Context.WIFI_P2P_SERVICE) as WifiP2pManager?
|
context.getSystemService(Context.WIFI_P2P_SERVICE) as WifiP2pManager?
|
||||||
|
|
||||||
@Provides
|
|
||||||
@KiwixScope
|
|
||||||
fun provideWifiManager(context: Context): WifiManager =
|
|
||||||
context.applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager
|
|
||||||
}
|
}
|
||||||
|
@ -1,71 +0,0 @@
|
|||||||
/*
|
|
||||||
* Kiwix Android
|
|
||||||
* Copyright (c) 2024 Kiwix <android.kiwix.org>
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
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()
|
|
||||||
}
|
|
@ -23,7 +23,6 @@ import android.content.res.Configuration
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
import android.view.MenuItem
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.appcompat.view.ActionMode
|
import androidx.appcompat.view.ActionMode
|
||||||
import androidx.core.content.pm.ShortcutInfoCompat
|
import androidx.core.content.pm.ShortcutInfoCompat
|
||||||
@ -46,7 +45,6 @@ import kotlinx.coroutines.launch
|
|||||||
import org.kiwix.kiwixmobile.BuildConfig
|
import org.kiwix.kiwixmobile.BuildConfig
|
||||||
import org.kiwix.kiwixmobile.R
|
import org.kiwix.kiwixmobile.R
|
||||||
import org.kiwix.kiwixmobile.core.R.drawable
|
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.mipmap
|
||||||
import org.kiwix.kiwixmobile.core.R.string
|
import org.kiwix.kiwixmobile.core.R.string
|
||||||
import org.kiwix.kiwixmobile.core.base.FragmentActivityExtensions
|
import org.kiwix.kiwixmobile.core.base.FragmentActivityExtensions
|
||||||
@ -107,6 +105,8 @@ class KiwixMainActivity : CoreMainActivity() {
|
|||||||
override val notesFragmentResId: Int = R.id.notesFragment
|
override val notesFragmentResId: Int = R.id.notesFragment
|
||||||
override val readerFragmentResId: Int = R.id.readerFragment
|
override val readerFragmentResId: Int = R.id.readerFragment
|
||||||
override val helpFragmentResId: Int = R.id.helpFragment
|
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 =
|
override val topLevelDestinations =
|
||||||
setOf(R.id.downloadsFragment, R.id.libraryFragment, R.id.readerFragment)
|
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 getIconResId() = mipmap.ic_launcher
|
||||||
|
|
||||||
override fun createApplicationShortcuts() {
|
override fun createApplicationShortcuts() {
|
||||||
|
@ -125,7 +125,7 @@
|
|||||||
tools:layout="@layout/activity_language" />
|
tools:layout="@layout/activity_language" />
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/zimHostFragment"
|
android:id="@+id/zimHostFragment"
|
||||||
android:name="org.kiwix.kiwixmobile.webserver.ZimHostFragment"
|
android:name="org.kiwix.kiwixmobile.core.webserver.ZimHostFragment"
|
||||||
android:label="ZimHostFragment"
|
android:label="ZimHostFragment"
|
||||||
tools:layout="@layout/activity_zim_host" />
|
tools:layout="@layout/activity_zim_host" />
|
||||||
<fragment
|
<fragment
|
||||||
|
@ -51,6 +51,11 @@
|
|||||||
<ID>PackageNaming:MountPointProducer.kt$package org.kiwix.kiwixmobile.core.zim_manager</ID>
|
<ID>PackageNaming:MountPointProducer.kt$package org.kiwix.kiwixmobile.core.zim_manager</ID>
|
||||||
<ID>PackageNaming:SelectionMode.kt$package org.kiwix.kiwixmobile.core.zim_manager.fileselect_view</ID>
|
<ID>PackageNaming:SelectionMode.kt$package org.kiwix.kiwixmobile.core.zim_manager.fileselect_view</ID>
|
||||||
<ID>PackageNaming:TagsView.kt$package org.kiwix.kiwixmobile.core.zim_manager</ID>
|
<ID>PackageNaming:TagsView.kt$package org.kiwix.kiwixmobile.core.zim_manager</ID>
|
||||||
|
<ID>PackageNaming:HotspotNotificationManager.kt$package org.kiwix.kiwixmobile.core.webserver.wifi_hotspot</ID>
|
||||||
|
<ID>PackageNaming:HotspotStateReceiver.kt$package org.kiwix.kiwixmobile.core.webserver.wifi_hotspot</ID>
|
||||||
|
<ID>PackageNaming:IpAddressCallbacks.kt$package org.kiwix.kiwixmobile.core.webserver.wifi_hotspot</ID>
|
||||||
|
<ID>PackageNaming:HotspotService.kt$package org.kiwix.kiwixmobile.core.webserver.wifi_hotspot</ID>
|
||||||
|
<ID>PackageNaming:ServerStatus.kt$package org.kiwix.kiwixmobile.core.webserver.wifi_hotspot</ID>
|
||||||
<ID>PackageNaming:ConnectivityBroadcastReceiver.kt$package org.kiwix.kiwixmobile.core.zim_manager</ID>
|
<ID>PackageNaming:ConnectivityBroadcastReceiver.kt$package org.kiwix.kiwixmobile.core.zim_manager</ID>
|
||||||
<ID>PackageNaming:NetworkState.kt$package org.kiwix.kiwixmobile.core.zim_manager</ID>
|
<ID>PackageNaming:NetworkState.kt$package org.kiwix.kiwixmobile.core.zim_manager</ID>
|
||||||
<ID>ReturnCount:FileUtils.kt$FileUtils$@JvmStatic fun getAllZimParts(book: Book): List<File></ID>
|
<ID>ReturnCount:FileUtils.kt$FileUtils$@JvmStatic fun getAllZimParts(book: Book): List<File></ID>
|
||||||
|
@ -95,5 +95,8 @@
|
|||||||
<service
|
<service
|
||||||
android:name=".downloader.downloadManager.DownloadMonitorService"
|
android:name=".downloader.downloadManager.DownloadMonitorService"
|
||||||
android:foregroundServiceType="dataSync" />
|
android:foregroundServiceType="dataSync" />
|
||||||
|
<service
|
||||||
|
android:name=".webserver.wifi_hotspot.HotspotService"
|
||||||
|
android:foregroundServiceType="dataSync" />
|
||||||
</application>
|
</application>
|
||||||
</manifest>
|
</manifest>
|
||||||
|
@ -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.SearchFragment
|
||||||
import org.kiwix.kiwixmobile.core.search.viewmodel.effects.ShowDeleteSearchDialog
|
import org.kiwix.kiwixmobile.core.search.viewmodel.effects.ShowDeleteSearchDialog
|
||||||
import org.kiwix.kiwixmobile.core.settings.CorePrefsFragment
|
import org.kiwix.kiwixmobile.core.settings.CorePrefsFragment
|
||||||
|
import org.kiwix.kiwixmobile.core.webserver.ZimHostFragment
|
||||||
|
import org.kiwix.kiwixmobile.core.webserver.ZimHostModule
|
||||||
|
|
||||||
@ActivityScope
|
@ActivityScope
|
||||||
@Subcomponent(
|
@Subcomponent(
|
||||||
modules = [ActivityModule::class]
|
modules = [ActivityModule::class, ZimHostModule::class],
|
||||||
)
|
)
|
||||||
interface CoreActivityComponent {
|
interface CoreActivityComponent {
|
||||||
fun inject(searchFragment: SearchFragment)
|
fun inject(searchFragment: SearchFragment)
|
||||||
@ -55,6 +57,7 @@ interface CoreActivityComponent {
|
|||||||
fun inject(helpFragment: HelpFragment)
|
fun inject(helpFragment: HelpFragment)
|
||||||
fun inject(notesFragment: NotesFragment)
|
fun inject(notesFragment: NotesFragment)
|
||||||
fun inject(navigationHistoryDialog: NavigationHistoryDialog)
|
fun inject(navigationHistoryDialog: NavigationHistoryDialog)
|
||||||
|
fun inject(zimHostFragment: ZimHostFragment)
|
||||||
|
|
||||||
@Subcomponent.Builder
|
@Subcomponent.Builder
|
||||||
interface Builder {
|
interface Builder {
|
||||||
|
@ -21,6 +21,7 @@ import android.app.Application
|
|||||||
import android.app.NotificationManager
|
import android.app.NotificationManager
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.net.ConnectivityManager
|
import android.net.ConnectivityManager
|
||||||
|
import android.net.wifi.WifiManager
|
||||||
import dagger.BindsInstance
|
import dagger.BindsInstance
|
||||||
import dagger.Component
|
import dagger.Component
|
||||||
import eu.mhutti1.utils.storage.StorageSelectDialog
|
import eu.mhutti1.utils.storage.StorageSelectDialog
|
||||||
@ -102,6 +103,7 @@ interface CoreComponent {
|
|||||||
fun downloadRoomDao(): DownloadRoomDao
|
fun downloadRoomDao(): DownloadRoomDao
|
||||||
fun newBookmarksDao(): NewBookmarksDao
|
fun newBookmarksDao(): NewBookmarksDao
|
||||||
fun connectivityManager(): ConnectivityManager
|
fun connectivityManager(): ConnectivityManager
|
||||||
|
fun wifiManager(): WifiManager
|
||||||
fun objectBoxToLibkiwixMigrator(): ObjectBoxToLibkiwixMigrator
|
fun objectBoxToLibkiwixMigrator(): ObjectBoxToLibkiwixMigrator
|
||||||
fun libkiwixBookmarks(): LibkiwixBookmarks
|
fun libkiwixBookmarks(): LibkiwixBookmarks
|
||||||
fun recentSearchRoomDao(): RecentSearchRoomDao
|
fun recentSearchRoomDao(): RecentSearchRoomDao
|
||||||
|
@ -25,12 +25,14 @@ import org.kiwix.kiwixmobile.core.di.CoreServiceScope
|
|||||||
import org.kiwix.kiwixmobile.core.di.modules.CoreServiceModule
|
import org.kiwix.kiwixmobile.core.di.modules.CoreServiceModule
|
||||||
import org.kiwix.kiwixmobile.core.downloader.downloadManager.DownloadMonitorService
|
import org.kiwix.kiwixmobile.core.downloader.downloadManager.DownloadMonitorService
|
||||||
import org.kiwix.kiwixmobile.core.read_aloud.ReadAloudService
|
import org.kiwix.kiwixmobile.core.read_aloud.ReadAloudService
|
||||||
|
import org.kiwix.kiwixmobile.core.webserver.wifi_hotspot.HotspotService
|
||||||
|
|
||||||
@Subcomponent(modules = [CoreServiceModule::class])
|
@Subcomponent(modules = [CoreServiceModule::class])
|
||||||
@CoreServiceScope
|
@CoreServiceScope
|
||||||
interface CoreServiceComponent {
|
interface CoreServiceComponent {
|
||||||
fun inject(readAloudService: ReadAloudService)
|
fun inject(readAloudService: ReadAloudService)
|
||||||
fun inject(downloadMonitorService: DownloadMonitorService)
|
fun inject(downloadMonitorService: DownloadMonitorService)
|
||||||
|
fun inject(hotspotService: HotspotService)
|
||||||
|
|
||||||
@Subcomponent.Builder
|
@Subcomponent.Builder
|
||||||
interface Builder {
|
interface Builder {
|
||||||
|
@ -21,6 +21,7 @@ import android.app.Application
|
|||||||
import android.app.NotificationManager
|
import android.app.NotificationManager
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.net.ConnectivityManager
|
import android.net.ConnectivityManager
|
||||||
|
import android.net.wifi.WifiManager
|
||||||
import android.os.storage.StorageManager
|
import android.os.storage.StorageManager
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.Provides
|
import dagger.Provides
|
||||||
@ -101,4 +102,9 @@ class ApplicationModule {
|
|||||||
@Singleton
|
@Singleton
|
||||||
fun provideConnectivityManager(context: Context): ConnectivityManager =
|
fun provideConnectivityManager(context: Context): ConnectivityManager =
|
||||||
context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
fun provideWifiManager(context: Context): WifiManager =
|
||||||
|
context.applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager
|
||||||
}
|
}
|
||||||
|
@ -19,11 +19,18 @@
|
|||||||
package org.kiwix.kiwixmobile.core.di.modules
|
package org.kiwix.kiwixmobile.core.di.modules
|
||||||
|
|
||||||
import android.app.NotificationManager
|
import android.app.NotificationManager
|
||||||
|
import android.app.Service
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.Provides
|
import dagger.Provides
|
||||||
import org.kiwix.kiwixmobile.core.di.CoreServiceScope
|
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.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
|
@Module
|
||||||
class CoreServiceModule {
|
class CoreServiceModule {
|
||||||
@ -33,4 +40,39 @@ class CoreServiceModule {
|
|||||||
notificationManager: NotificationManager,
|
notificationManager: NotificationManager,
|
||||||
context: Context
|
context: Context
|
||||||
): ReadAloudNotificationManger = ReadAloudNotificationManger(notificationManager, 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()
|
||||||
}
|
}
|
||||||
|
@ -97,6 +97,8 @@ abstract class CoreMainActivity : BaseActivity(), WebViewProvider {
|
|||||||
abstract val historyFragmentResId: Int
|
abstract val historyFragmentResId: Int
|
||||||
abstract val notesFragmentResId: Int
|
abstract val notesFragmentResId: Int
|
||||||
abstract val helpFragmentResId: Int
|
abstract val helpFragmentResId: Int
|
||||||
|
abstract val zimHostFragmentResId: Int
|
||||||
|
abstract val navGraphId: Int
|
||||||
abstract val cachedComponent: CoreActivityComponent
|
abstract val cachedComponent: CoreActivityComponent
|
||||||
abstract val topLevelDestinations: Set<Int>
|
abstract val topLevelDestinations: Set<Int>
|
||||||
abstract val navHostContainer: FragmentContainerView
|
abstract val navHostContainer: FragmentContainerView
|
||||||
@ -307,11 +309,17 @@ abstract class CoreMainActivity : BaseActivity(), WebViewProvider {
|
|||||||
R.id.menu_notes -> openNotes()
|
R.id.menu_notes -> openNotes()
|
||||||
R.id.menu_history -> openHistory()
|
R.id.menu_history -> openHistory()
|
||||||
R.id.menu_bookmarks_list -> openBookmarks()
|
R.id.menu_bookmarks_list -> openBookmarks()
|
||||||
|
R.id.menu_host_books -> openZimHostFragment()
|
||||||
else -> return false
|
else -> return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun openZimHostFragment() {
|
||||||
|
navigate(zimHostFragmentResId)
|
||||||
|
handleDrawerOnNavigation()
|
||||||
|
}
|
||||||
|
|
||||||
private fun openHelpFragment() {
|
private fun openHelpFragment() {
|
||||||
navigate(helpFragmentResId)
|
navigate(helpFragmentResId)
|
||||||
handleDrawerOnNavigation()
|
handleDrawerOnNavigation()
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.kiwix.kiwixmobile.webserver
|
package org.kiwix.kiwixmobile.core.webserver
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
@ -15,7 +15,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.kiwix.kiwixmobile.webserver
|
package org.kiwix.kiwixmobile.core.webserver
|
||||||
|
|
||||||
import io.reactivex.Flowable
|
import io.reactivex.Flowable
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
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.getIp
|
||||||
import org.kiwix.kiwixmobile.core.utils.ServerUtils.getIpAddress
|
import org.kiwix.kiwixmobile.core.utils.ServerUtils.getIpAddress
|
||||||
import org.kiwix.kiwixmobile.core.utils.files.Log
|
import org.kiwix.kiwixmobile.core.utils.files.Log
|
||||||
import org.kiwix.kiwixmobile.webserver.wifi_hotspot.IpAddressCallbacks
|
import org.kiwix.kiwixmobile.core.webserver.wifi_hotspot.IpAddressCallbacks
|
||||||
import org.kiwix.kiwixmobile.webserver.wifi_hotspot.ServerStatus
|
import org.kiwix.kiwixmobile.core.webserver.wifi_hotspot.ServerStatus
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
@ -15,7 +15,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.kiwix.kiwixmobile.webserver
|
package org.kiwix.kiwixmobile.core.webserver
|
||||||
|
|
||||||
interface ZimHostCallbacks {
|
interface ZimHostCallbacks {
|
||||||
fun onServerStarted(ip: String)
|
fun onServerStarted(ip: String)
|
@ -15,7 +15,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.kiwix.kiwixmobile.webserver
|
package org.kiwix.kiwixmobile.core.webserver
|
||||||
|
|
||||||
import org.kiwix.kiwixmobile.core.base.BaseContract
|
import org.kiwix.kiwixmobile.core.base.BaseContract
|
||||||
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem
|
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem
|
@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.kiwix.kiwixmobile.webserver
|
package org.kiwix.kiwixmobile.core.webserver
|
||||||
|
|
||||||
import android.Manifest
|
import android.Manifest
|
||||||
import android.Manifest.permission.POST_NOTIFICATIONS
|
import android.Manifest.permission.POST_NOTIFICATIONS
|
||||||
@ -42,7 +42,7 @@ import androidx.appcompat.widget.Toolbar
|
|||||||
import androidx.core.app.ActivityCompat
|
import androidx.core.app.ActivityCompat
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.fragment.app.FragmentActivity
|
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.R
|
||||||
import org.kiwix.kiwixmobile.core.base.BaseActivity
|
import org.kiwix.kiwixmobile.core.base.BaseActivity
|
||||||
import org.kiwix.kiwixmobile.core.base.BaseFragment
|
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.BooksOnDiskAdapter
|
||||||
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem
|
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.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem.BookOnDisk
|
||||||
import org.kiwix.kiwixmobile.databinding.ActivityZimHostBinding
|
import org.kiwix.kiwixmobile.core.databinding.ActivityZimHostBinding
|
||||||
import org.kiwix.kiwixmobile.main.KiwixMainActivity
|
import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.cachedComponent
|
||||||
import org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotService
|
import org.kiwix.kiwixmobile.core.webserver.wifi_hotspot.HotspotService
|
||||||
import org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotService.Companion.ACTION_CHECK_IP_ADDRESS
|
import org.kiwix.kiwixmobile.core.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.core.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.webserver.wifi_hotspot.HotspotService.Companion.ACTION_STOP_SERVER
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class ZimHostFragment : BaseFragment(), ZimHostCallbacks, ZimHostContract.View {
|
class ZimHostFragment : BaseFragment(), ZimHostCallbacks, ZimHostContract.View {
|
||||||
@ -178,7 +178,16 @@ class ZimHostFragment : BaseFragment(), ZimHostCallbacks, ZimHostContract.View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun inject(baseActivity: BaseActivity) {
|
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?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
@ -15,7 +15,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.kiwix.kiwixmobile.webserver
|
package org.kiwix.kiwixmobile.core.webserver
|
||||||
|
|
||||||
import dagger.Binds
|
import dagger.Binds
|
||||||
import dagger.Module
|
import dagger.Module
|
@ -15,7 +15,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.kiwix.kiwixmobile.webserver
|
package org.kiwix.kiwixmobile.core.webserver
|
||||||
|
|
||||||
import org.kiwix.kiwixmobile.core.utils.files.Log
|
import org.kiwix.kiwixmobile.core.utils.files.Log
|
||||||
import io.reactivex.SingleObserver
|
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.data.DataSource
|
||||||
import org.kiwix.kiwixmobile.core.di.ActivityScope
|
import org.kiwix.kiwixmobile.core.di.ActivityScope
|
||||||
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem
|
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem
|
||||||
import org.kiwix.kiwixmobile.webserver.ZimHostContract.Presenter
|
import org.kiwix.kiwixmobile.core.webserver.ZimHostContract.Presenter
|
||||||
import org.kiwix.kiwixmobile.webserver.ZimHostContract.View
|
import org.kiwix.kiwixmobile.core.webserver.ZimHostContract.View
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@ActivityScope
|
@ActivityScope
|
@ -15,7 +15,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.kiwix.kiwixmobile.webserver.wifi_hotspot
|
package org.kiwix.kiwixmobile.core.webserver.wifi_hotspot
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.app.Notification
|
import android.app.Notification
|
||||||
@ -29,8 +29,6 @@ import androidx.core.app.NotificationCompat
|
|||||||
import androidx.navigation.NavDeepLinkBuilder
|
import androidx.navigation.NavDeepLinkBuilder
|
||||||
import org.kiwix.kiwixmobile.core.CoreApp
|
import org.kiwix.kiwixmobile.core.CoreApp
|
||||||
import org.kiwix.kiwixmobile.core.R
|
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.qr.GenerateQR
|
||||||
import org.kiwix.kiwixmobile.core.utils.HOTSPOT_SERVICE_CHANNEL_ID
|
import org.kiwix.kiwixmobile.core.utils.HOTSPOT_SERVICE_CHANNEL_ID
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
@ -62,8 +60,8 @@ class HotspotNotificationManager @Inject constructor(
|
|||||||
val contentIntent = NavDeepLinkBuilder(context).setComponentName(
|
val contentIntent = NavDeepLinkBuilder(context).setComponentName(
|
||||||
coreMainActivity.mainActivity::class.java
|
coreMainActivity.mainActivity::class.java
|
||||||
)
|
)
|
||||||
.setGraph(navigation.kiwix_nav_graph)
|
.setGraph(coreMainActivity.navGraphId)
|
||||||
.setDestination(id.zimHostFragment)
|
.setDestination(coreMainActivity.zimHostFragmentResId)
|
||||||
.createPendingIntent()
|
.createPendingIntent()
|
||||||
hotspotNotificationChannel()
|
hotspotNotificationChannel()
|
||||||
val stopIntent = Intent(context, HotspotService::class.java).setAction(
|
val stopIntent = Intent(context, HotspotService::class.java).setAction(
|
@ -15,7 +15,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.kiwix.kiwixmobile.webserver.wifi_hotspot
|
package org.kiwix.kiwixmobile.core.webserver.wifi_hotspot
|
||||||
|
|
||||||
import android.app.Service
|
import android.app.Service
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
@ -26,14 +26,14 @@ import kotlinx.coroutines.CoroutineScope
|
|||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
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.R
|
||||||
import org.kiwix.kiwixmobile.core.extensions.registerReceiver
|
import org.kiwix.kiwixmobile.core.extensions.registerReceiver
|
||||||
import org.kiwix.kiwixmobile.core.utils.ServerUtils.getSocketAddress
|
import org.kiwix.kiwixmobile.core.utils.ServerUtils.getSocketAddress
|
||||||
import org.kiwix.kiwixmobile.webserver.WebServerHelper
|
import org.kiwix.kiwixmobile.core.webserver.WebServerHelper
|
||||||
import org.kiwix.kiwixmobile.webserver.ZimHostCallbacks
|
import org.kiwix.kiwixmobile.core.webserver.ZimHostCallbacks
|
||||||
import org.kiwix.kiwixmobile.webserver.ZimHostFragment
|
import org.kiwix.kiwixmobile.core.webserver.ZimHostFragment
|
||||||
import org.kiwix.kiwixmobile.webserver.ZimHostFragment.Companion.RESTART_SERVER
|
import org.kiwix.kiwixmobile.core.webserver.ZimHostFragment.Companion.RESTART_SERVER
|
||||||
import java.lang.ref.WeakReference
|
import java.lang.ref.WeakReference
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@ -58,18 +58,18 @@ class HotspotService :
|
|||||||
private val serviceBinder: IBinder = HotspotBinder(this)
|
private val serviceBinder: IBinder = HotspotBinder(this)
|
||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
(this.application as KiwixApp).kiwixComponent
|
coreComponent
|
||||||
.serviceComponent()
|
.coreServiceComponent()
|
||||||
.service(this)
|
.service(this)
|
||||||
.build()
|
.build()
|
||||||
.inject(this)
|
.inject(this)
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
hotspotStateReceiver?.let(this::registerReceiver)
|
hotspotStateReceiver?.let(::registerReceiver)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
webServerHelper?.dispose()
|
webServerHelper?.dispose()
|
||||||
hotspotStateReceiver?.let(this@HotspotService::unregisterReceiver)
|
hotspotStateReceiver?.let(::unregisterReceiver)
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
}
|
}
|
||||||
|
|
@ -15,12 +15,12 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.kiwix.kiwixmobile.webserver.wifi_hotspot
|
package org.kiwix.kiwixmobile.core.webserver.wifi_hotspot
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import org.kiwix.kiwixmobile.core.base.BaseBroadcastReceiver
|
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
|
import javax.inject.Inject
|
||||||
|
|
||||||
const val EXTRA_WIFI_AP_STATE = "wifi_state"
|
const val EXTRA_WIFI_AP_STATE = "wifi_state"
|
@ -15,7 +15,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.kiwix.kiwixmobile.webserver.wifi_hotspot
|
package org.kiwix.kiwixmobile.core.webserver.wifi_hotspot
|
||||||
|
|
||||||
interface IpAddressCallbacks {
|
interface IpAddressCallbacks {
|
||||||
fun onIpAddressValid()
|
fun onIpAddressValid()
|
@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.kiwix.kiwixmobile.webserver.wifi_hotspot
|
package org.kiwix.kiwixmobile.core.webserver.wifi_hotspot
|
||||||
|
|
||||||
data class ServerStatus(
|
data class ServerStatus(
|
||||||
val isServerStarted: Boolean,
|
val isServerStarted: Boolean,
|
@ -22,6 +22,7 @@ import android.app.Activity
|
|||||||
import dagger.BindsInstance
|
import dagger.BindsInstance
|
||||||
import dagger.Subcomponent
|
import dagger.Subcomponent
|
||||||
import org.kiwix.kiwixmobile.core.di.ActivityScope
|
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.core.di.components.CoreActivityComponent
|
||||||
import org.kiwix.kiwixmobile.custom.download.CustomDownloadFragment
|
import org.kiwix.kiwixmobile.custom.download.CustomDownloadFragment
|
||||||
import org.kiwix.kiwixmobile.custom.main.CustomMainActivity
|
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
|
import org.kiwix.kiwixmobile.custom.settings.CustomSettingsFragment
|
||||||
|
|
||||||
@ActivityScope
|
@ActivityScope
|
||||||
@Subcomponent(modules = [CustomActivityModule::class])
|
@Subcomponent(modules = [CustomActivityModule::class, ZimHostModule::class])
|
||||||
interface CustomActivityComponent : CoreActivityComponent {
|
interface CustomActivityComponent : CoreActivityComponent {
|
||||||
fun inject(customMainActivity: CustomMainActivity)
|
fun inject(customMainActivity: CustomMainActivity)
|
||||||
fun inject(customSettingsFragment: CustomSettingsFragment)
|
fun inject(customSettingsFragment: CustomSettingsFragment)
|
||||||
|
@ -75,6 +75,8 @@ class CustomMainActivity : CoreMainActivity() {
|
|||||||
override val historyFragmentResId: Int = R.id.historyFragment
|
override val historyFragmentResId: Int = R.id.historyFragment
|
||||||
override val notesFragmentResId: Int = R.id.notesFragment
|
override val notesFragmentResId: Int = R.id.notesFragment
|
||||||
override val helpFragmentResId: Int = R.id.helpFragment
|
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 cachedComponent by lazy { customActivityComponent }
|
||||||
override val topLevelDestinations =
|
override val topLevelDestinations =
|
||||||
setOf(R.id.customReaderFragment)
|
setOf(R.id.customReaderFragment)
|
||||||
@ -114,7 +116,7 @@ class CustomMainActivity : CoreMainActivity() {
|
|||||||
* For more info see https://github.com/kiwix/kiwix-android/pull/3516,
|
* For more info see https://github.com/kiwix/kiwix-android/pull/3516,
|
||||||
* https://github.com/kiwix/kiwix-android/issues/4026
|
* 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.
|
* Hide the `HelpFragment` from custom apps.
|
||||||
* We have not removed the relevant code for `HelpFragment` from custom apps.
|
* We have not removed the relevant code for `HelpFragment` from custom apps.
|
||||||
|
@ -55,6 +55,10 @@
|
|||||||
android:id="@+id/bookmarksFragment"
|
android:id="@+id/bookmarksFragment"
|
||||||
android:name="org.kiwix.kiwixmobile.core.page.bookmark.BookmarksFragment"
|
android:name="org.kiwix.kiwixmobile.core.page.bookmark.BookmarksFragment"
|
||||||
android:label="BookmarksFragment" />
|
android:label="BookmarksFragment" />
|
||||||
|
<fragment
|
||||||
|
android:id="@+id/zimHostFragment"
|
||||||
|
android:name="org.kiwix.kiwixmobile.core.webserver.ZimHostFragment"
|
||||||
|
android:label="ZimHostFragment" />
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/helpFragment"
|
android:id="@+id/helpFragment"
|
||||||
android:name="org.kiwix.kiwixmobile.custom.help.CustomHelpFragment"
|
android:name="org.kiwix.kiwixmobile.custom.help.CustomHelpFragment"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user