mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-08 14:52:13 -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 {
|
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)
|
||||||
implementation(Libs.squidb_annotations)
|
implementation(Libs.squidb_annotations)
|
||||||
kapt(Libs.squidb_processor)
|
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.BaseActivity
|
||||||
import org.kiwix.kiwixmobile.core.base.BaseFragment
|
import org.kiwix.kiwixmobile.core.base.BaseFragment
|
||||||
import org.kiwix.kiwixmobile.core.downloader.Downloader
|
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.extensions.viewModel
|
||||||
import org.kiwix.kiwixmobile.core.utils.DialogShower
|
import org.kiwix.kiwixmobile.core.utils.DialogShower
|
||||||
import org.kiwix.kiwixmobile.core.utils.KiwixDialog.YesNoDialog.StopDownload
|
import org.kiwix.kiwixmobile.core.utils.KiwixDialog.YesNoDialog.StopDownload
|
||||||
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
|
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
|
||||||
import org.kiwix.kiwixmobile.core.downloader.model.DownloadItem
|
import org.kiwix.kiwixmobile.zim_manager.ZimManageActivity
|
||||||
import org.kiwix.kiwixmobile.kiwixActivityComponent
|
|
||||||
import org.kiwix.kiwixmobile.zim_manager.ZimManageViewModel
|
import org.kiwix.kiwixmobile.zim_manager.ZimManageViewModel
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ class DownloadFragment : BaseFragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun inject(baseActivity: BaseActivity) {
|
override fun inject(baseActivity: BaseActivity) {
|
||||||
baseActivity.kiwixActivityComponent.inject(this)
|
(baseActivity as ZimManageActivity).cachedComponent.inject(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(
|
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.BookDelegate
|
||||||
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BookOnDiskDelegate.LanguageDelegate
|
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.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
|
||||||
import org.kiwix.kiwixmobile.zim_manager.ZimManageViewModel.FileSelectActions
|
import org.kiwix.kiwixmobile.zim_manager.ZimManageViewModel.FileSelectActions
|
||||||
import org.kiwix.kiwixmobile.zim_manager.ZimManageViewModel.FileSelectActions.RequestMultiSelection
|
import org.kiwix.kiwixmobile.zim_manager.ZimManageViewModel.FileSelectActions.RequestMultiSelection
|
||||||
@ -76,7 +76,7 @@ class ZimFileSelectFragment : BaseFragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun inject(baseActivity: BaseActivity) {
|
override fun inject(baseActivity: BaseActivity) {
|
||||||
baseActivity.kiwixActivityComponent.inject(this)
|
(baseActivity as ZimManageActivity).cachedComponent.inject(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(
|
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.NetworkUtils
|
||||||
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
|
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
|
||||||
import org.kiwix.kiwixmobile.core.utils.TestingUtils
|
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
|
||||||
import org.kiwix.kiwixmobile.zim_manager.NetworkState.CONNECTED
|
import org.kiwix.kiwixmobile.zim_manager.NetworkState.CONNECTED
|
||||||
import org.kiwix.kiwixmobile.zim_manager.NetworkState.NOT_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.ZimManageViewModel
|
||||||
import org.kiwix.kiwixmobile.zim_manager.library_view.adapter.LibraryAdapter
|
import org.kiwix.kiwixmobile.zim_manager.library_view.adapter.LibraryAdapter
|
||||||
import org.kiwix.kiwixmobile.zim_manager.library_view.adapter.LibraryDelegate.BookDelegate
|
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
|
private val isNotConnected get() = conMan.activeNetworkInfo?.isConnected == false
|
||||||
|
|
||||||
override fun inject(baseActivity: BaseActivity) {
|
override fun inject(baseActivity: BaseActivity) {
|
||||||
baseActivity.kiwixActivityComponent.inject(this)
|
(baseActivity as ZimManageActivity).cachedComponent.inject(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
|
@ -53,18 +53,19 @@ class AllProjectConfigurer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
getByName("debug").apply {
|
getByName("debug") {
|
||||||
isTestCoverageEnabled = true
|
isTestCoverageEnabled = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
compileOptions.apply {
|
compileOptions {
|
||||||
encoding = "UTF-8"
|
encoding = "UTF-8"
|
||||||
sourceCompatibility = Config.javaVersion
|
sourceCompatibility = Config.javaVersion
|
||||||
targetCompatibility = Config.javaVersion
|
targetCompatibility = Config.javaVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
testOptions {
|
testOptions {
|
||||||
|
execution = "ANDROIDX_TEST_ORCHESTRATOR"
|
||||||
unitTests.apply {
|
unitTests.apply {
|
||||||
isReturnDefaultValues = true
|
isReturnDefaultValues = true
|
||||||
all(KotlinClosure1<Any, Test>({
|
all(KotlinClosure1<Any, Test>({
|
||||||
@ -101,8 +102,7 @@ class AllProjectConfigurer {
|
|||||||
warning(
|
warning(
|
||||||
"UnknownNullness",
|
"UnknownNullness",
|
||||||
"SelectableText",
|
"SelectableText",
|
||||||
"IconDensities",
|
"IconDensities"
|
||||||
"SyntheticAccessor"
|
|
||||||
)
|
)
|
||||||
baseline("${path}/lint-baseline.xml")
|
baseline("${path}/lint-baseline.xml")
|
||||||
}
|
}
|
||||||
@ -119,15 +119,19 @@ class AllProjectConfigurer {
|
|||||||
exclude("META-INF/ASL2.0")
|
exclude("META-INF/ASL2.0")
|
||||||
}
|
}
|
||||||
sourceSets {
|
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) {
|
fun configurePlugins(target: Project) {
|
||||||
target.configureExtension<AndroidExtensionsExtension> { isExperimental = true }
|
target.run {
|
||||||
target.configureExtension<JacocoPluginExtension> { toolVersion = "0.8.3" }
|
configureExtension<AndroidExtensionsExtension> { isExperimental = true }
|
||||||
target.configureExtension<KtlintExtension> { android.set(true) }
|
configureExtension<JacocoPluginExtension> { toolVersion = "0.8.3" }
|
||||||
|
configureExtension<KtlintExtension> { android.set(true) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun applyScripts(target: Project) {
|
fun applyScripts(target: Project) {
|
||||||
|
@ -22,6 +22,7 @@ import Libs
|
|||||||
import com.android.build.gradle.AppExtension
|
import com.android.build.gradle.AppExtension
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.kotlin.dsl.dependencies
|
import org.gradle.kotlin.dsl.dependencies
|
||||||
|
import org.gradle.kotlin.dsl.exclude
|
||||||
import org.gradle.kotlin.dsl.project
|
import org.gradle.kotlin.dsl.project
|
||||||
|
|
||||||
class AppConfigurer {
|
class AppConfigurer {
|
||||||
@ -41,9 +42,6 @@ class AppConfigurer {
|
|||||||
isUniversalApk = true
|
isUniversalApk = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
testOptions {
|
|
||||||
execution = "ANDROIDX_TEST_ORCHESTRATOR"
|
|
||||||
}
|
|
||||||
aaptOptions {
|
aaptOptions {
|
||||||
cruncherEnabled = true
|
cruncherEnabled = true
|
||||||
}
|
}
|
||||||
@ -54,7 +52,7 @@ class AppConfigurer {
|
|||||||
|
|
||||||
private fun configureDependencies(target: Project) {
|
private fun configureDependencies(target: Project) {
|
||||||
target.dependencies {
|
target.dependencies {
|
||||||
this.add("implementation", project(":core"))
|
add("implementation", project(":core"))
|
||||||
androidTestImplementation(Libs.espresso_core)
|
androidTestImplementation(Libs.espresso_core)
|
||||||
androidTestImplementation(Libs.espresso_web)
|
androidTestImplementation(Libs.espresso_web)
|
||||||
androidTestImplementation(Libs.espresso_intents)
|
androidTestImplementation(Libs.espresso_intents)
|
||||||
@ -66,6 +64,14 @@ class AppConfigurer {
|
|||||||
androidTestImplementation(Libs.androidx_test_rules)
|
androidTestImplementation(Libs.androidx_test_rules)
|
||||||
androidTestImplementation(Libs.androidx_test_core)
|
androidTestImplementation(Libs.androidx_test_core)
|
||||||
androidTestImplementation(Libs.mockwebserver)
|
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)
|
androidTestUtil(Libs.orchestrator)
|
||||||
androidTestImplementation(Libs.mockito_android)
|
androidTestImplementation(Libs.mockito_android)
|
||||||
androidTestCompileOnly(Libs.javax_annotation_api)
|
androidTestCompileOnly(Libs.javax_annotation_api)
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
package plugin
|
package plugin
|
||||||
|
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.api.artifacts.ModuleDependency
|
||||||
import org.gradle.kotlin.dsl.DependencyHandlerScope
|
import org.gradle.kotlin.dsl.DependencyHandlerScope
|
||||||
|
|
||||||
internal inline fun <reified T> Project.configureExtension(function: T.() -> Unit) =
|
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) =
|
internal fun DependencyHandlerScope.androidTestCompileOnly(dependency: String) =
|
||||||
addDependency("androidTestCompileOnly", dependency)
|
addDependency("androidTestCompileOnly", dependency)
|
||||||
|
|
||||||
internal fun DependencyHandlerScope.androidTestImplementation(dependency: String) =
|
internal fun DependencyHandlerScope.androidTestImplementation(
|
||||||
addDependency("androidTestImplementation", dependency)
|
dependency: String,
|
||||||
|
dependencyFunc: (ModuleDependency.() -> Unit)? = null
|
||||||
|
) =
|
||||||
|
addDependency("androidTestImplementation", dependency).also {
|
||||||
|
(it as ModuleDependency?)?.let { moduleDependency -> dependencyFunc?.invoke(moduleDependency) }
|
||||||
|
}
|
||||||
|
|
||||||
internal fun DependencyHandlerScope.compileOnly(dependency: String) =
|
internal fun DependencyHandlerScope.compileOnly(dependency: String) =
|
||||||
addDependency("compileOnly", dependency)
|
addDependency("compileOnly", dependency)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user