mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 18:56:44 -04:00
tidy up plugin configurers and reuse ActivtyComponent in fragments
This commit is contained in:
parent
381e2bd9d8
commit
15b3b4ad41
@ -109,15 +109,6 @@ play {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
androidTestImplementation(Libs.barista) {
|
||||
exclude group: "com.android.support.test.uiautomator"
|
||||
}
|
||||
androidTestImplementation(Libs.simple_xml) {
|
||||
exclude module: 'stax'
|
||||
exclude module: 'stax-api'
|
||||
exclude module: 'xpp3'
|
||||
}
|
||||
implementation(Libs.squidb)
|
||||
implementation(Libs.squidb_annotations)
|
||||
kapt(Libs.squidb_processor)
|
||||
|
@ -31,12 +31,12 @@ import org.kiwix.kiwixmobile.R
|
||||
import org.kiwix.kiwixmobile.core.base.BaseActivity
|
||||
import org.kiwix.kiwixmobile.core.base.BaseFragment
|
||||
import org.kiwix.kiwixmobile.core.downloader.Downloader
|
||||
import org.kiwix.kiwixmobile.core.downloader.model.DownloadItem
|
||||
import org.kiwix.kiwixmobile.core.extensions.viewModel
|
||||
import org.kiwix.kiwixmobile.core.utils.DialogShower
|
||||
import org.kiwix.kiwixmobile.core.utils.KiwixDialog.YesNoDialog.StopDownload
|
||||
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
|
||||
import org.kiwix.kiwixmobile.core.downloader.model.DownloadItem
|
||||
import org.kiwix.kiwixmobile.kiwixActivityComponent
|
||||
import org.kiwix.kiwixmobile.zim_manager.ZimManageActivity
|
||||
import org.kiwix.kiwixmobile.zim_manager.ZimManageViewModel
|
||||
import javax.inject.Inject
|
||||
|
||||
@ -56,7 +56,7 @@ class DownloadFragment : BaseFragment() {
|
||||
}
|
||||
|
||||
override fun inject(baseActivity: BaseActivity) {
|
||||
baseActivity.kiwixActivityComponent.inject(this)
|
||||
(baseActivity as ZimManageActivity).cachedComponent.inject(this)
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
|
@ -45,7 +45,7 @@ import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
|
||||
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BookOnDiskDelegate.BookDelegate
|
||||
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BookOnDiskDelegate.LanguageDelegate
|
||||
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskAdapter
|
||||
import org.kiwix.kiwixmobile.kiwixActivityComponent
|
||||
import org.kiwix.kiwixmobile.zim_manager.ZimManageActivity
|
||||
import org.kiwix.kiwixmobile.zim_manager.ZimManageViewModel
|
||||
import org.kiwix.kiwixmobile.zim_manager.ZimManageViewModel.FileSelectActions
|
||||
import org.kiwix.kiwixmobile.zim_manager.ZimManageViewModel.FileSelectActions.RequestMultiSelection
|
||||
@ -76,7 +76,7 @@ class ZimFileSelectFragment : BaseFragment() {
|
||||
}
|
||||
|
||||
override fun inject(baseActivity: BaseActivity) {
|
||||
baseActivity.kiwixActivityComponent.inject(this)
|
||||
(baseActivity as ZimManageActivity).cachedComponent.inject(this)
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
|
@ -50,10 +50,10 @@ import org.kiwix.kiwixmobile.core.utils.KiwixDialog.YesNoDialog.WifiOnly
|
||||
import org.kiwix.kiwixmobile.core.utils.NetworkUtils
|
||||
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
|
||||
import org.kiwix.kiwixmobile.core.utils.TestingUtils
|
||||
import org.kiwix.kiwixmobile.kiwixActivityComponent
|
||||
import org.kiwix.kiwixmobile.zim_manager.NetworkState
|
||||
import org.kiwix.kiwixmobile.zim_manager.NetworkState.CONNECTED
|
||||
import org.kiwix.kiwixmobile.zim_manager.NetworkState.NOT_CONNECTED
|
||||
import org.kiwix.kiwixmobile.zim_manager.ZimManageActivity
|
||||
import org.kiwix.kiwixmobile.zim_manager.ZimManageViewModel
|
||||
import org.kiwix.kiwixmobile.zim_manager.library_view.adapter.LibraryAdapter
|
||||
import org.kiwix.kiwixmobile.zim_manager.library_view.adapter.LibraryDelegate.BookDelegate
|
||||
@ -92,7 +92,7 @@ class LibraryFragment : BaseFragment() {
|
||||
private val isNotConnected get() = conMan.activeNetworkInfo?.isConnected == false
|
||||
|
||||
override fun inject(baseActivity: BaseActivity) {
|
||||
baseActivity.kiwixActivityComponent.inject(this)
|
||||
(baseActivity as ZimManageActivity).cachedComponent.inject(this)
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
|
@ -53,18 +53,19 @@ class AllProjectConfigurer {
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
getByName("debug").apply {
|
||||
getByName("debug") {
|
||||
isTestCoverageEnabled = true
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions.apply {
|
||||
compileOptions {
|
||||
encoding = "UTF-8"
|
||||
sourceCompatibility = Config.javaVersion
|
||||
targetCompatibility = Config.javaVersion
|
||||
}
|
||||
|
||||
testOptions {
|
||||
execution = "ANDROIDX_TEST_ORCHESTRATOR"
|
||||
unitTests.apply {
|
||||
isReturnDefaultValues = true
|
||||
all(KotlinClosure1<Any, Test>({
|
||||
@ -101,8 +102,7 @@ class AllProjectConfigurer {
|
||||
warning(
|
||||
"UnknownNullness",
|
||||
"SelectableText",
|
||||
"IconDensities",
|
||||
"SyntheticAccessor"
|
||||
"IconDensities"
|
||||
)
|
||||
baseline("${path}/lint-baseline.xml")
|
||||
}
|
||||
@ -119,15 +119,19 @@ class AllProjectConfigurer {
|
||||
exclude("META-INF/ASL2.0")
|
||||
}
|
||||
sourceSets {
|
||||
getByName("test").java.srcDir("${target.rootDir}/core/src/sharedTestFunctions/java")
|
||||
getByName("test") {
|
||||
java.srcDir("${target.rootDir}/core/src/sharedTestFunctions/java")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun configurePlugins(target: Project) {
|
||||
target.configureExtension<AndroidExtensionsExtension> { isExperimental = true }
|
||||
target.configureExtension<JacocoPluginExtension> { toolVersion = "0.8.3" }
|
||||
target.configureExtension<KtlintExtension> { android.set(true) }
|
||||
target.run {
|
||||
configureExtension<AndroidExtensionsExtension> { isExperimental = true }
|
||||
configureExtension<JacocoPluginExtension> { toolVersion = "0.8.3" }
|
||||
configureExtension<KtlintExtension> { android.set(true) }
|
||||
}
|
||||
}
|
||||
|
||||
fun applyScripts(target: Project) {
|
||||
|
@ -22,6 +22,7 @@ import Libs
|
||||
import com.android.build.gradle.AppExtension
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.dependencies
|
||||
import org.gradle.kotlin.dsl.exclude
|
||||
import org.gradle.kotlin.dsl.project
|
||||
|
||||
class AppConfigurer {
|
||||
@ -41,9 +42,6 @@ class AppConfigurer {
|
||||
isUniversalApk = true
|
||||
}
|
||||
}
|
||||
testOptions {
|
||||
execution = "ANDROIDX_TEST_ORCHESTRATOR"
|
||||
}
|
||||
aaptOptions {
|
||||
cruncherEnabled = true
|
||||
}
|
||||
@ -54,7 +52,7 @@ class AppConfigurer {
|
||||
|
||||
private fun configureDependencies(target: Project) {
|
||||
target.dependencies {
|
||||
this.add("implementation", project(":core"))
|
||||
add("implementation", project(":core"))
|
||||
androidTestImplementation(Libs.espresso_core)
|
||||
androidTestImplementation(Libs.espresso_web)
|
||||
androidTestImplementation(Libs.espresso_intents)
|
||||
@ -66,6 +64,14 @@ class AppConfigurer {
|
||||
androidTestImplementation(Libs.androidx_test_rules)
|
||||
androidTestImplementation(Libs.androidx_test_core)
|
||||
androidTestImplementation(Libs.mockwebserver)
|
||||
androidTestImplementation(Libs.barista) {
|
||||
exclude(group = "com.android.support.test.uiautomator")
|
||||
}
|
||||
androidTestImplementation(Libs.simple_xml) {
|
||||
exclude(module = "stax")
|
||||
exclude(module = "stax-api")
|
||||
exclude(module = "xpp3")
|
||||
}
|
||||
androidTestUtil(Libs.orchestrator)
|
||||
androidTestImplementation(Libs.mockito_android)
|
||||
androidTestCompileOnly(Libs.javax_annotation_api)
|
||||
|
@ -19,6 +19,7 @@
|
||||
package plugin
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.artifacts.ModuleDependency
|
||||
import org.gradle.kotlin.dsl.DependencyHandlerScope
|
||||
|
||||
internal inline fun <reified T> Project.configureExtension(function: T.() -> Unit) =
|
||||
@ -33,8 +34,13 @@ internal fun DependencyHandlerScope.kaptAndroidTest(dependency: String) =
|
||||
internal fun DependencyHandlerScope.androidTestCompileOnly(dependency: String) =
|
||||
addDependency("androidTestCompileOnly", dependency)
|
||||
|
||||
internal fun DependencyHandlerScope.androidTestImplementation(dependency: String) =
|
||||
addDependency("androidTestImplementation", dependency)
|
||||
internal fun DependencyHandlerScope.androidTestImplementation(
|
||||
dependency: String,
|
||||
dependencyFunc: (ModuleDependency.() -> Unit)? = null
|
||||
) =
|
||||
addDependency("androidTestImplementation", dependency).also {
|
||||
(it as ModuleDependency?)?.let { moduleDependency -> dependencyFunc?.invoke(moduleDependency) }
|
||||
}
|
||||
|
||||
internal fun DependencyHandlerScope.compileOnly(dependency: String) =
|
||||
addDependency("compileOnly", dependency)
|
||||
|
Loading…
x
Reference in New Issue
Block a user