diff --git a/app/detekt_baseline.xml b/app/detekt_baseline.xml index 887f52e8c..6c2a6da63 100644 --- a/app/detekt_baseline.xml +++ b/app/detekt_baseline.xml @@ -49,6 +49,7 @@ 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/main/java/org/kiwix/kiwixmobile/di/components/ServiceComponent.kt b/app/src/main/java/org/kiwix/kiwixmobile/di/components/ServiceComponent.kt new file mode 100644 index 000000000..8f587f307 --- /dev/null +++ b/app/src/main/java/org/kiwix/kiwixmobile/di/components/ServiceComponent.kt @@ -0,0 +1,38 @@ +/* +* 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 762828173..a881282d0 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,7 +20,6 @@ package org.kiwix.kiwixmobile.di.modules import dagger.Module import org.kiwix.kiwixmobile.core.di.modules.ActivityModule -import org.kiwix.kiwixmobile.webserver.ZimHostModule -@Module(includes = [ActivityModule::class, ZimHostModule::class]) +@Module(includes = [ActivityModule::class]) class KiwixActivityModule 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 f211a310b..ff49bf4fc 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/main/KiwixMainActivity.kt +++ b/app/src/main/java/org/kiwix/kiwixmobile/main/KiwixMainActivity.kt @@ -41,6 +41,7 @@ import com.google.android.material.navigation.NavigationView import eu.mhutti1.utils.storage.StorageDeviceUtils import org.kiwix.kiwixmobile.BuildConfig import org.kiwix.kiwixmobile.R +import org.kiwix.kiwixmobile.core.R.id import org.kiwix.kiwixmobile.core.R.drawable import org.kiwix.kiwixmobile.core.R.mipmap import org.kiwix.kiwixmobile.core.R.string @@ -273,7 +274,7 @@ class KiwixMainActivity : CoreMainActivity() { override fun onNavigationItemSelected(item: MenuItem): Boolean { when (item.itemId) { - R.id.menu_host_books -> openZimHostFragment() + id.menu_host_books -> openZimHostFragment() else -> return super.onNavigationItemSelected(item) } return true diff --git a/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/CopyMoveFileHandler.kt b/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/CopyMoveFileHandler.kt index d068e6720..0a4f8b4f9 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/CopyMoveFileHandler.kt +++ b/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/CopyMoveFileHandler.kt @@ -382,7 +382,7 @@ class CopyMoveFileHandler @Inject constructor( @SuppressLint("InflateParams") fun showPreparingCopyMoveDialog() { if (copyMovePreparingDialog == null) { val dialogView: View = - activity.layoutInflater.inflate(R.layout.item_custom_spinner, null) + activity.layoutInflater.inflate(layout.item_custom_spinner, null) copyMovePreparingDialog = alertDialogShower.create(KiwixDialog.PreparingCopyingFilesDialog { dialogView }) } diff --git a/app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostFragment.kt b/app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostFragment.kt index d10f0535c..93a47a74d 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostFragment.kt +++ b/app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostFragment.kt @@ -43,9 +43,9 @@ import androidx.core.app.ActivityCompat import androidx.core.content.ContextCompat import androidx.fragment.app.FragmentActivity import org.kiwix.kiwixmobile.core.R +import org.kiwix.kiwixmobile.R.layout import org.kiwix.kiwixmobile.core.base.BaseActivity import org.kiwix.kiwixmobile.core.base.BaseFragment -import org.kiwix.kiwixmobile.core.databinding.ActivityZimHostBinding import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.hasNotificationPermission import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.isCustomApp import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.isManageExternalStoragePermissionGranted @@ -67,6 +67,7 @@ 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 @@ -275,7 +276,7 @@ class ZimHostFragment : BaseFragment(), ZimHostCallbacks, ZimHostContract.View { private fun startKiwixHotspot() { if (dialog == null) { val dialogView: View = - layoutInflater.inflate(R.layout.item_custom_spinner, null) + layoutInflater.inflate(layout.item_custom_spinner, null) dialog = alertDialogShower.create(StartServer { dialogView }) } dialog?.show() 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 7d674424b..93d305c05 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 @@ -129,5 +129,5 @@ interface CoreComponent { fun inject(objectBoxToRoomMigrator: ObjectBoxToRoomMigrator) fun inject(settingsFragment: CoreSettingsFragment) - fun coreServiceComponent(): org.kiwix.kiwixmobile.di.components.CoreServiceComponent.Builder + fun coreServiceComponent(): CoreServiceComponent.Builder } 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 44843a6d9..bec1c4c33 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 @@ -22,6 +22,7 @@ import android.app.Service import dagger.BindsInstance import dagger.Subcomponent import org.kiwix.kiwixmobile.core.di.CoreServiceScope +import org.kiwix.kiwixmobile.core.di.modules.CoreServiceModule import org.kiwix.kiwixmobile.core.read_aloud.ReadAloudService @Subcomponent(modules = [CoreServiceModule::class])