From 66b3173e1c481e7e7fa641e57afe920f1254017b Mon Sep 17 00:00:00 2001 From: Anton Knyazev Date: Wed, 22 Nov 2023 12:47:15 +0300 Subject: [PATCH 1/8] Upgrade OmegaMoxy, fix MvpProcessor --- .../com/omega_r/base/simple/MainPresenter.kt | 2 - .../dialog_fragment/DialogDialogFragment.kt | 1 - .../simple/dialog_fragment/DialogPresenter.kt | 2 - build.gradle | 2 +- core/build.gradle | 9 --- .../omega_r/base/data/OmegaBaseRepository.kt | 5 ++ .../com/omega_r/base/data/OmegaRepository.kt | 2 + .../base/mvp/presenters/OmegaPresenter.kt | 2 - .../omega_r/base/mvp/views/OmegaBindView.kt | 3 +- mvp-processor/build.gradle | 1 + .../com/omegar/mvp_processor/MvpProcessor.kt | 62 +++++++++++++++++-- 11 files changed, 69 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/com/omega_r/base/simple/MainPresenter.kt b/app/src/main/java/com/omega_r/base/simple/MainPresenter.kt index 25e4fff..d32ed44 100644 --- a/app/src/main/java/com/omega_r/base/simple/MainPresenter.kt +++ b/app/src/main/java/com/omega_r/base/simple/MainPresenter.kt @@ -4,7 +4,6 @@ import android.os.SystemClock import com.omega_r.base.annotations.AutoPresenterLauncher import com.omega_r.base.mvp.presenters.OmegaPresenter import com.omega_r.libs.omegatypes.Text -import com.omegar.mvp.InjectViewState import java.io.Serializable /** @@ -12,7 +11,6 @@ import java.io.Serializable */ typealias TestEntity2 = TestEntity @AutoPresenterLauncher(MainActivity::class, TestFragment::class) -@InjectViewState class MainPresenter(testEntity: TestEntity?, t2: TestEntity2?): OmegaPresenter() { companion object { diff --git a/app/src/main/java/com/omega_r/base/simple/dialog_fragment/DialogDialogFragment.kt b/app/src/main/java/com/omega_r/base/simple/dialog_fragment/DialogDialogFragment.kt index 0f828f0..4599454 100644 --- a/app/src/main/java/com/omega_r/base/simple/dialog_fragment/DialogDialogFragment.kt +++ b/app/src/main/java/com/omega_r/base/simple/dialog_fragment/DialogDialogFragment.kt @@ -6,7 +6,6 @@ import com.omega_r.base.components.OmegaDialogFragment import com.omega_r.base.simple.R import com.omega_r.libs.omegatypes.Text import com.omegar.libs.omegalaunchers.createDialogFragmentLauncher -import com.omegar.mvp.ktx.providePresenter /** * Created by Anton Knyazev on 10.03.2020. diff --git a/app/src/main/java/com/omega_r/base/simple/dialog_fragment/DialogPresenter.kt b/app/src/main/java/com/omega_r/base/simple/dialog_fragment/DialogPresenter.kt index 37260b6..0b3cd00 100644 --- a/app/src/main/java/com/omega_r/base/simple/dialog_fragment/DialogPresenter.kt +++ b/app/src/main/java/com/omega_r/base/simple/dialog_fragment/DialogPresenter.kt @@ -1,12 +1,10 @@ package com.omega_r.base.simple.dialog_fragment import com.omega_r.base.mvp.presenters.OmegaPresenter -import com.omegar.mvp.InjectViewState /** * Created by Anton Knyazev on 10.03.2020. */ -@InjectViewState class DialogPresenter : OmegaPresenter() { } \ No newline at end of file diff --git a/build.gradle b/build.gradle index dd3c532..f422ab2 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ buildscript { ext { omegaRecyclerView = '1.10.1' - omegaMoxy_version = '3.0.0' + omegaMoxy_version = 'b5e0b08d88' kotlinCorutines_version = '1.5.0' }// Top-level build file where you can add configuration options common to all sub-projects/modules. diff --git a/core/build.gradle b/core/build.gradle index d4b70e4..153110d 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -56,15 +56,6 @@ android { } kotlinOptions.jvmTarget = "1.8" - - kapt { - arguments { - arg("moxyReflectorPackage", 'com.omega_r.base') - } - } - ksp { - arg("moxyReflectorPackage", 'com.omega_r.base') - } } diff --git a/core/src/main/java/com/omega_r/base/data/OmegaBaseRepository.kt b/core/src/main/java/com/omega_r/base/data/OmegaBaseRepository.kt index 273b13f..62d0ce9 100644 --- a/core/src/main/java/com/omega_r/base/data/OmegaBaseRepository.kt +++ b/core/src/main/java/com/omega_r/base/data/OmegaBaseRepository.kt @@ -27,6 +27,8 @@ open class OmegaBaseRepository( protected val coroutineScope = CoroutineScope(Dispatchers.Background + job) + override var mockMode: Boolean = false + protected val remoteSource: SOURCE? = sources.firstOrNull { it.type == Source.Type.REMOTE } protected val memorySource: SOURCE? @@ -49,6 +51,9 @@ open class OmegaBaseRepository( return result } + private val generalSource: SOURCE? + get() = if (mockMode) mockSource else remoteSource + protected fun createChannel(strategy: Strategy, block: suspend SOURCE.() -> R): ReceiveChannel { return coroutineScope.produce { try { diff --git a/core/src/main/java/com/omega_r/base/data/OmegaRepository.kt b/core/src/main/java/com/omega_r/base/data/OmegaRepository.kt index 4f60170..da2ae8e 100644 --- a/core/src/main/java/com/omega_r/base/data/OmegaRepository.kt +++ b/core/src/main/java/com/omega_r/base/data/OmegaRepository.kt @@ -2,6 +2,8 @@ package com.omega_r.base.data interface OmegaRepository { + var mockMode: Boolean + fun clearCache() enum class Strategy { diff --git a/core/src/main/java/com/omega_r/base/mvp/presenters/OmegaPresenter.kt b/core/src/main/java/com/omega_r/base/mvp/presenters/OmegaPresenter.kt index 7b97ace..8e9823f 100644 --- a/core/src/main/java/com/omega_r/base/mvp/presenters/OmegaPresenter.kt +++ b/core/src/main/java/com/omega_r/base/mvp/presenters/OmegaPresenter.kt @@ -14,7 +14,6 @@ import com.omegar.libs.omegalaunchers.ActivityLauncher import com.omegar.libs.omegalaunchers.BaseIntentLauncher import com.omegar.libs.omegalaunchers.DialogFragmentLauncher import com.omegar.libs.omegalaunchers.Launcher -import com.omegar.mvp.InjectViewState import com.omegar.mvp.MvpPresenter import kotlinx.coroutines.* import java.io.PrintWriter @@ -30,7 +29,6 @@ import kotlin.coroutines.EmptyCoroutineContext private const val REQUEST_PERMISSION_BASE = 10000 private const val REQUEST_CODE_MAX: Int = Int.MAX_VALUE - 1 -@InjectViewState open class OmegaPresenter : MvpPresenter(), CoroutineScope { companion object { diff --git a/core/src/main/java/com/omega_r/base/mvp/views/OmegaBindView.kt b/core/src/main/java/com/omega_r/base/mvp/views/OmegaBindView.kt index 97e44d1..ca264b1 100644 --- a/core/src/main/java/com/omega_r/base/mvp/views/OmegaBindView.kt +++ b/core/src/main/java/com/omega_r/base/mvp/views/OmegaBindView.kt @@ -1,11 +1,12 @@ package com.omega_r.base.mvp.views +import com.omegar.mvp.viewstate.strategy.MoxyViewCommand import com.omegar.mvp.viewstate.strategy.StateStrategyType import com.omegar.mvp.viewstate.strategy.StrategyType interface OmegaBindView: OmegaView { - @StateStrategyType(StrategyType.ADD_TO_END_SINGLE) + @MoxyViewCommand(StrategyType.ADD_TO_END_SINGLE) fun bind(item: M) } \ No newline at end of file diff --git a/mvp-processor/build.gradle b/mvp-processor/build.gradle index 7a6a692..41e1f2f 100644 --- a/mvp-processor/build.gradle +++ b/mvp-processor/build.gradle @@ -37,6 +37,7 @@ dependencies { implementation project(path: ':annotations') implementation 'com.google.devtools.ksp:symbol-processing-api:1.9.0-1.0.11' + implementation "com.github.Omega-R.OmegaMoxy:moxy:${omegaMoxy_version}" implementation("com.squareup:kotlinpoet:1.14.2") implementation("com.squareup:kotlinpoet-ksp:1.14.2") diff --git a/mvp-processor/src/main/java/com/omegar/mvp_processor/MvpProcessor.kt b/mvp-processor/src/main/java/com/omegar/mvp_processor/MvpProcessor.kt index 8869ebe..e4b36b9 100644 --- a/mvp-processor/src/main/java/com/omegar/mvp_processor/MvpProcessor.kt +++ b/mvp-processor/src/main/java/com/omegar/mvp_processor/MvpProcessor.kt @@ -8,14 +8,18 @@ import com.google.devtools.ksp.processing.CodeGenerator import com.google.devtools.ksp.processing.KSPLogger import com.google.devtools.ksp.processing.Resolver import com.google.devtools.ksp.processing.SymbolProcessor +import com.google.devtools.ksp.symbol.ClassKind import com.google.devtools.ksp.symbol.KSAnnotated import com.google.devtools.ksp.symbol.KSClassDeclaration import com.google.devtools.ksp.symbol.KSType import com.google.devtools.ksp.symbol.KSTypeAlias +import com.google.devtools.ksp.symbol.KSTypeParameter +import com.google.devtools.ksp.symbol.KSTypeReference import com.google.devtools.ksp.symbol.KSValueParameter import com.google.devtools.ksp.symbol.KSVisitorVoid import com.google.devtools.ksp.validate import com.omega_r.base.annotations.AutoPresenterLauncher +import com.omegar.mvp.MvpView import com.squareup.kotlinpoet.ClassName import com.squareup.kotlinpoet.CodeBlock import com.squareup.kotlinpoet.FileSpec @@ -36,6 +40,7 @@ import com.squareup.kotlinpoet.ksp.addOriginatingKSFile import com.squareup.kotlinpoet.ksp.toClassName import com.squareup.kotlinpoet.ksp.toTypeName import com.squareup.kotlinpoet.ksp.writeTo +import java.lang.RuntimeException class MvpProcessor( private val options: Map, @@ -85,7 +90,7 @@ class MvpProcessor( val activityType = resolver.getClassDeclarationByName(ACTIVITY_NAME.canonicalName)!!.asType(emptyList()) val fragmentType = resolver.getClassDeclarationByName(FRAGMENT_NAME.canonicalName)!!.asType(emptyList()) val dialogFragmentType = resolver.getClassDeclarationByName(DIALOG_FRAGMENT_NAME.canonicalName)!!.asType(emptyList()) - + val mvpView = resolver.getClassDeclarationByName(MvpView::class.qualifiedName!!)!!.asStarProjectedType() return resolver.getSymbolsWithAnnotation(AutoPresenterLauncher::class.qualifiedName!!) .filterIsInstance() @@ -97,7 +102,8 @@ class MvpProcessor( parcelableType = parcelableType, activityType = activityType, fragmentType = fragmentType, - dialogFragmentType = dialogFragmentType + dialogFragmentType = dialogFragmentType, + mvpView = mvpView ), data = Unit ) @@ -113,6 +119,7 @@ class MvpProcessor( private val activityType: KSType, private val fragmentType: KSType, private val dialogFragmentType: KSType, + private val mvpView: KSType, ) : KSVisitorVoid() { @@ -128,6 +135,9 @@ class MvpProcessor( val presenterType = if (annotation.localPresenterType) "LOCAL" else "GLOBAL" + val (_, view) = classDeclaration.getSuperPresenterAndView() + val viewStateName = view.toClassName().simpleName.replace("View", "MvpViewState") + val presenterClassName = classDeclaration.toClassName() val typeSpec = TypeSpec.objectBuilder(factoryName) @@ -197,7 +207,10 @@ class MvpProcessor( mvpDelegateLauncherMap[delegatedClass.getDelegateType()]!! ) ) - .addCode("return with($factoryName) { createPresenterField() }") + .addCode("return with($factoryName) { \n" + + "$viewStateName.Companion\n" + + "createPresenterField() " + + "}") .build() .apply { builder.addFunction(this) @@ -206,10 +219,51 @@ class MvpProcessor( } .build() .also { fileSpec -> - fileSpec.writeTo(codeGenerator = codeGenerator, aggregating = true) + fileSpec.writeTo(codeGenerator = codeGenerator, aggregating = false) + } + } + + private fun KSClassDeclaration.getSuperPresenterAndView(): Pair { + return superTypes + .firstNotNullOf { reference -> + (reference.resolve().declaration as? KSClassDeclaration) + ?.takeIf { it.classKind == ClassKind.CLASS } + ?.let { + it to (reference.findView() ?: throw RuntimeException("It is impossible to find a view in $this")) + } } } + private fun KSTypeReference.findView(): KSType? { + val type = element + ?.typeArguments + ?.asSequence() + ?.map { it.type?.resolve() } + ?.firstOrNull { + it?.let { + mvpView.isAssignableFrom(it) + } ?: false + } + return when (type?.declaration) { + is KSClassDeclaration -> type + is KSTypeParameter -> { + (type.declaration as KSTypeParameter) + .bounds + .map { + it.resolve() + } + .firstOrNull { + mvpView.isAssignableFrom(it) + } + } + + else -> { + logger.warn("Unknown type is " + type?.declaration?.let { it::class}.toString()) + null + } + } + } + private fun List>.generateBundlePutter(delegatedClass: TypeName): CodeBlock { val args = mutableListOf(delegatedClass) val format = "return createLauncher(%T::class, " + From ba0fbbd7df6628ec9f2373edf6eeeb9dfc687460 Mon Sep 17 00:00:00 2001 From: Anton Knyazev Date: Wed, 22 Nov 2023 13:28:39 +0300 Subject: [PATCH 2/8] Fix early initialization of the presenter --- .../src/main/java/com/omegar/mvp_processor/MvpProcessor.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/mvp-processor/src/main/java/com/omegar/mvp_processor/MvpProcessor.kt b/mvp-processor/src/main/java/com/omegar/mvp_processor/MvpProcessor.kt index e4b36b9..359ced0 100644 --- a/mvp-processor/src/main/java/com/omegar/mvp_processor/MvpProcessor.kt +++ b/mvp-processor/src/main/java/com/omegar/mvp_processor/MvpProcessor.kt @@ -144,6 +144,7 @@ class MvpProcessor( .addOriginatingKSFile(classDeclaration.containingFile!!) .superclass(MVP_PRESENTER_FACTORY.parameterizedBy(presenterClassName)) .addSuperclassConstructorParameter("%T.$presenterType, %T::class", PRESENTER_TYPE, presenterClassName) + .addInitializerBlock(CodeBlock.of( "$viewStateName.Companion")) .also { builder -> val pairParams: List> = classDeclaration.primaryConstructor!!.parameters.map { parameter -> From 16c07b6196177d119fcc52450145348d92cb45d7 Mon Sep 17 00:00:00 2001 From: Anton Knyazev Date: Wed, 22 Nov 2023 16:02:23 +0300 Subject: [PATCH 3/8] Change OmegaMoxy version --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index f422ab2..1054131 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ buildscript { ext { omegaRecyclerView = '1.10.1' - omegaMoxy_version = 'b5e0b08d88' + omegaMoxy_version = '3.1.0' kotlinCorutines_version = '1.5.0' }// Top-level build file where you can add configuration options common to all sub-projects/modules. From 2b230fecd50a087da6e0e42d573b578b6b399d98 Mon Sep 17 00:00:00 2001 From: Anton Knyazev Date: Tue, 19 Dec 2023 16:24:44 +0300 Subject: [PATCH 4/8] Add settings and Percent --- .../java/com/omega_r/base/simple/Settings.kt | 11 ++++ .../com/omega_r/base/settings/BaseSettings.kt | 56 ++++++++++++++++++ .../java/com/omega_r/base/settings/Setting.kt | 59 +++++++++++++++++++ .../omega_r/base/settings/SettingStorage.kt | 29 +++++++++ 4 files changed, 155 insertions(+) create mode 100644 app/src/main/java/com/omega_r/base/simple/Settings.kt create mode 100644 core/src/main/java/com/omega_r/base/settings/BaseSettings.kt create mode 100644 core/src/main/java/com/omega_r/base/settings/Setting.kt create mode 100644 core/src/main/java/com/omega_r/base/settings/SettingStorage.kt diff --git a/app/src/main/java/com/omega_r/base/simple/Settings.kt b/app/src/main/java/com/omega_r/base/simple/Settings.kt new file mode 100644 index 0000000..00a791e --- /dev/null +++ b/app/src/main/java/com/omega_r/base/simple/Settings.kt @@ -0,0 +1,11 @@ +package com.omega_r.base.simple + +import com.omega_r.base.settings.BaseSettings +import com.omega_r.base.settings.SettingStorage + +class Settings(setting: SettingStorage): BaseSettings(setting) { + + var firstLaunch by provideBoolean(key = "jklh", defaultValue = false, label = "possim") + + +} \ No newline at end of file diff --git a/core/src/main/java/com/omega_r/base/settings/BaseSettings.kt b/core/src/main/java/com/omega_r/base/settings/BaseSettings.kt new file mode 100644 index 0000000..fb4e885 --- /dev/null +++ b/core/src/main/java/com/omega_r/base/settings/BaseSettings.kt @@ -0,0 +1,56 @@ +package com.omega_r.base.settings + +import com.omega_r.base.enitity.Percent +import kotlin.properties.ReadWriteProperty + +open class BaseSettings(private val setting: SettingStorage) { + + protected fun provideBoolean( + key: String, + defaultValue: Boolean, + label: String, + description: String = "" + ) = run { + setting.provide( + Setting.BooleanSetting( + key = key, + defaultValue = defaultValue, + label = label, + description = description + ) + ) + } + + protected fun provideString( + key: String, + defaultValue: String, + label: String, + description: String = "" + ) = run { + setting.provide( + Setting.StringSetting( + key = key, + defaultValue = defaultValue, + label = label, + description = description + ) + ) + } + + protected fun providePercent( + key: String, + defaultValue: Percent, + label: String, + description: String = "" + ) = run { + setting.provide( + Setting.PercentSetting( + key = key, + defaultValue = defaultValue, + label = label, + description = description + ) + ) + } + +} \ No newline at end of file diff --git a/core/src/main/java/com/omega_r/base/settings/Setting.kt b/core/src/main/java/com/omega_r/base/settings/Setting.kt new file mode 100644 index 0000000..184030f --- /dev/null +++ b/core/src/main/java/com/omega_r/base/settings/Setting.kt @@ -0,0 +1,59 @@ +package com.omega_r.base.settings + +import android.content.SharedPreferences +import com.omega_r.base.enitity.Percent +import com.omega_r.base.enitity.PercentModel +import com.omega_r.base.enitity.toPercent + +sealed class Setting( + val key: String, + val defaultValue: T, + val label: String, + val description: String +) { + + internal abstract fun getValue(sharedPreferences: SharedPreferences): T + + internal abstract fun setValue(editor: SharedPreferences.Editor, value: T) + + open class BooleanSetting(key: String, defaultValue: Boolean, label: String, description: String) : + Setting(key = key, defaultValue = defaultValue, label = label, description = description) { + + override fun getValue(sharedPreferences: SharedPreferences): Boolean { + return sharedPreferences.getBoolean(key, defaultValue) + } + + override fun setValue(editor: SharedPreferences.Editor, value: Boolean) { + editor.putBoolean(key, value) + } + + } + + open class StringSetting(key: String, defaultValue: String, label: String, description: String) : + Setting(key = key, defaultValue = defaultValue, label = label, description = description) { + override fun getValue(sharedPreferences: SharedPreferences): String { + return sharedPreferences.getString(key, defaultValue) ?: defaultValue + } + + override fun setValue(editor: SharedPreferences.Editor, value: String) { + editor.putString(key, value) + } + } + + open class PercentSetting(key: String, defaultValue: Percent, label: String, description: String) : + Setting(key = key, defaultValue = defaultValue, label = label, description = description) { + + private companion object { + private val percentModel = PercentModel(0f, 100f) + } + + override fun getValue(sharedPreferences: SharedPreferences): Percent { + return sharedPreferences.getFloat(key, defaultValue.toFloat(percentModel)).toPercent(percentModel) + } + + override fun setValue(editor: SharedPreferences.Editor, value: Percent) { + editor.putFloat(key, value.toFloat(percentModel)) + } + } + +} \ No newline at end of file diff --git a/core/src/main/java/com/omega_r/base/settings/SettingStorage.kt b/core/src/main/java/com/omega_r/base/settings/SettingStorage.kt new file mode 100644 index 0000000..b7b0c53 --- /dev/null +++ b/core/src/main/java/com/omega_r/base/settings/SettingStorage.kt @@ -0,0 +1,29 @@ +package com.omega_r.base.settings + +import android.content.SharedPreferences +import androidx.core.content.edit +import kotlin.properties.ReadWriteProperty +import kotlin.reflect.KProperty + +class SettingStorage(private val sharedPreferences: SharedPreferences){ + + operator fun get(setting: Setting): T { + return setting.getValue(sharedPreferences) + } + + operator fun set(setting: Setting, newValue: T) { + sharedPreferences.edit { + setting.setValue(this, newValue) + } + } + + fun provide(setting: Setting): ReadWriteProperty = Property(setting) + + private inner class Property(private val setting: Setting): ReadWriteProperty { + override fun getValue(thisRef: Any, property: KProperty<*>): T = get(setting) + + override fun setValue(thisRef: Any, property: KProperty<*>, value: T) = set(setting, value) + + } + +} \ No newline at end of file From 91c015b87af12381f8ce5bcd4815c778a9e609f2 Mon Sep 17 00:00:00 2001 From: Anton Knyazev Date: Wed, 20 Dec 2023 11:41:34 +0300 Subject: [PATCH 5/8] Add settings and Percent --- .../java/com/omega_r/base/enitity/Percent.kt | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 core/src/main/java/com/omega_r/base/enitity/Percent.kt diff --git a/core/src/main/java/com/omega_r/base/enitity/Percent.kt b/core/src/main/java/com/omega_r/base/enitity/Percent.kt new file mode 100644 index 0000000..7fd10fc --- /dev/null +++ b/core/src/main/java/com/omega_r/base/enitity/Percent.kt @@ -0,0 +1,92 @@ +package com.omega_r.base.enitity + +import com.omega_r.base.enitity.Percent.Companion.DEFAULT_PERCENT_MODEL +import com.omega_r.base.enitity.Percent.Companion.FLOAT_PERCENT_MODEL +import java.io.Serializable + +/** + * Created by Anton Knyazev on 20.07.2023. + * Copyright (c) 2023 Omega https://omega-r.com + */ +@JvmInline +value class Percent private constructor(private val value: Float): Serializable { + + companion object { + + val FLOAT_PERCENT_MODEL = PercentModel(0f, 1f) + + val DEFAULT_PERCENT_MODEL = PercentModel(0, 100) + + val MAX = Percent(1.0f) + val MIN = Percent(0.0f) + + fun calc(current: Number, max: Number): Percent = (current.toFloat() / max.toFloat()).toPercent(FLOAT_PERCENT_MODEL) + + } + + constructor(value: Float, model: PercentModel) : this(value, model.min, model.max) + + + constructor(value: Number, min: Number, max: Number): this(value.toFloat(), min.toFloat(), max.toFloat()) + + constructor(value: Float, min: Float, max: Float) : this( + when { + value < min -> MIN.value + value > max -> MAX.value + else -> (value - min) / (max - min) + } + ) + + fun toInt(model: PercentModel = DEFAULT_PERCENT_MODEL): Int = toFloat(model).toInt() + + fun toInt(min: Int, max: Int): Int = toFloat(min.toFloat(), max.toFloat()).toInt() + + fun toFloat(model: PercentModel = FLOAT_PERCENT_MODEL): Float = toFloat(model.min, model.max) + + fun toFloat(min: Float, max: Float): Float = when { + value > MAX.value -> max + value < MIN.value -> min + else -> value * (max - min) + min + } + + fun isMin() = value <= MIN.value + + fun isMax() = value >= MAX.value + + operator fun compareTo(percent: Percent): Int { + return value.compareTo(percent.value) + } + + operator fun times(number: Number): Percent = Percent(value * number.toFloat()) + + operator fun div(number: Number): Percent = Percent(value / number.toFloat()) + + operator fun times(percent: Percent): Percent = Percent(value * percent.value) + + operator fun div(percent: Percent): Percent = Percent(value / percent.value) + + operator fun plus(percent: Percent): Percent = Percent(value + percent.value) + + operator fun minus(percent: Percent): Percent = Percent(value - percent.value) + + override fun toString(): String = "${value * 100}%" + +} + +data class PercentModel(val min: Float, val max: Float) { + constructor(min: Number, max: Number) : this(min.toFloat(), max.toFloat()) +} + +fun Number.toPercent(model: PercentModel) = Percent(toFloat(), model) + +fun Double.toPercent(model: PercentModel = FLOAT_PERCENT_MODEL) = Percent(toFloat(), model) + +fun Int.toPercent(model: PercentModel = DEFAULT_PERCENT_MODEL) = Percent(toFloat(), model) + +fun Long.toPercent(model: PercentModel = DEFAULT_PERCENT_MODEL) = Percent(toFloat(), model) + +fun Number.toPercent(min: Number, max: Number) = Percent(this, min, max) + +fun Float.toPercent(model: PercentModel = FLOAT_PERCENT_MODEL) = Percent(this, model) + +fun Float.toPercent(min: Float, max: Float) = Percent(this, min, max) \ No newline at end of file From 7477ec91917ada21b409fa1b24a5bfc44821a37b Mon Sep 17 00:00:00 2001 From: Anton Knyazev Date: Fri, 29 Dec 2023 17:20:50 +0300 Subject: [PATCH 6/8] Add primitive types settings --- .../java/com/omega_r/base/simple/Settings.kt | 8 +- core/build.gradle | 4 +- .../com/omega_r/base/settings/BaseSettings.kt | 119 +++++++++++++++++- .../java/com/omega_r/base/settings/Setting.kt | 104 ++++++++++++++- 4 files changed, 228 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/omega_r/base/simple/Settings.kt b/app/src/main/java/com/omega_r/base/simple/Settings.kt index 00a791e..7e81885 100644 --- a/app/src/main/java/com/omega_r/base/simple/Settings.kt +++ b/app/src/main/java/com/omega_r/base/simple/Settings.kt @@ -2,10 +2,16 @@ package com.omega_r.base.simple import com.omega_r.base.settings.BaseSettings import com.omega_r.base.settings.SettingStorage +import com.squareup.moshi.Moshi +import com.squareup.moshi.adapter -class Settings(setting: SettingStorage): BaseSettings(setting) { +class Settings(setting: SettingStorage, moshi: Moshi): BaseSettings(setting) { var firstLaunch by provideBoolean(key = "jklh", defaultValue = false, label = "possim") + @OptIn(ExperimentalStdlibApi::class) + var session: Session? by provideAnyJson(key = "", defaultValue = null, label = "sdf", moshi.adapter()) + + class Session(val token: String, val refreshToken: String) } \ No newline at end of file diff --git a/core/build.gradle b/core/build.gradle index 153110d..272b101 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -81,7 +81,7 @@ dependencies { api 'com.github.Omega-R.OmegaIntentBuilder:core:1.3.4' api 'com.github.Omega-R.OmegaLaunchers:omegalauncherslib:1.0.6' api 'com.github.Omega-R:OmegaExtensions:1.0.6' - api 'com.github.Omega-R.OmegaIntentBuilder:annotations:1.0.5' + api 'com.github.Omega-R.OmegaIntentBuilder:annotations:1.3.4' api 'com.github.Omega-R:OmegaBind:1.0.5' api 'com.github.Omega-R:OmegaClicks:1.0.0' api 'com.github.Omega-R:OmegaAdapters:1.0.3' @@ -90,7 +90,7 @@ dependencies { api project(':annotations') api "com.squareup.retrofit2:retrofit:2.9.0" - api "com.squareup.moshi:moshi-kotlin:1.11.0" + api "com.squareup.moshi:moshi-kotlin:1.14.0" // define any required OkHttp artifacts without version api "com.squareup.okhttp3:okhttp:3.14.9" diff --git a/core/src/main/java/com/omega_r/base/settings/BaseSettings.kt b/core/src/main/java/com/omega_r/base/settings/BaseSettings.kt index fb4e885..7fb6fd5 100644 --- a/core/src/main/java/com/omega_r/base/settings/BaseSettings.kt +++ b/core/src/main/java/com/omega_r/base/settings/BaseSettings.kt @@ -1,7 +1,9 @@ package com.omega_r.base.settings import com.omega_r.base.enitity.Percent -import kotlin.properties.ReadWriteProperty +import com.squareup.moshi.JsonAdapter +import java.util.Date +import kotlin.time.Duration open class BaseSettings(private val setting: SettingStorage) { @@ -37,6 +39,102 @@ open class BaseSettings(private val setting: SettingStorage) { ) } + protected fun provideInt( + key: String, + defaultValue: Int, + label: String, + description: String = "" + ) = run { + setting.provide( + Setting.IntSetting( + key = key, + defaultValue = defaultValue, + label = label, + description = description + ) + ) + } + + protected fun provideFloat( + key: String, + defaultValue: Float, + label: String, + description: String = "" + ) = run { + setting.provide( + Setting.FloatSetting( + key = key, + defaultValue = defaultValue, + label = label, + description = description + ) + ) + } + + protected fun provideLong( + key: String, + defaultValue: Long, + label: String, + description: String = "" + ) = run { + setting.provide( + Setting.LongSetting( + key = key, + defaultValue = defaultValue, + label = label, + description = description + ) + ) + } + + protected fun provideDouble( + key: String, + defaultValue: Double, + label: String, + description: String = "" + ) = run { + setting.provide( + Setting.DoubleSetting( + key = key, + defaultValue = defaultValue, + label = label, + description = description + ) + ) + } + + protected fun provideDate( + key: String, + defaultValue: Date, + label: String, + description: String = "" + ) = run { + setting.provide( + Setting.DateSetting( + key = key, + defaultValue = defaultValue, + label = label, + description = description + ) + ) + } + + protected fun provideDuration( + key: String, + defaultValue: Duration, + label: String, + description: String = "" + ) = run { + setting.provide( + Setting.DurationSetting( + key = key, + defaultValue = defaultValue, + label = label, + description = description + ) + ) + } + protected fun providePercent( key: String, defaultValue: Percent, @@ -53,4 +151,23 @@ open class BaseSettings(private val setting: SettingStorage) { ) } + + protected fun provideAnyJson( + key: String, + defaultValue: T, + label: String, + jsonAdapter: JsonAdapter, + description: String = "", + ) = run { + setting.provide( + Setting.AnyJsonSetting( + key = key, + defaultValue = defaultValue, + label = label, + description = description, + jsonAdapter = jsonAdapter + ) + ) + } + } \ No newline at end of file diff --git a/core/src/main/java/com/omega_r/base/settings/Setting.kt b/core/src/main/java/com/omega_r/base/settings/Setting.kt index 184030f..3737b14 100644 --- a/core/src/main/java/com/omega_r/base/settings/Setting.kt +++ b/core/src/main/java/com/omega_r/base/settings/Setting.kt @@ -4,6 +4,10 @@ import android.content.SharedPreferences import com.omega_r.base.enitity.Percent import com.omega_r.base.enitity.PercentModel import com.omega_r.base.enitity.toPercent +import com.squareup.moshi.JsonAdapter +import java.util.Date +import kotlin.time.Duration +import kotlin.time.Duration.Companion.milliseconds sealed class Setting( val key: String, @@ -29,6 +33,77 @@ sealed class Setting( } + open class IntSetting(key: String, defaultValue: Int, label: String, description: String) : + Setting(key = key, defaultValue = defaultValue, label = label, description = description) { + override fun getValue(sharedPreferences: SharedPreferences): Int { + return sharedPreferences.getInt(key, defaultValue) + } + + override fun setValue(editor: SharedPreferences.Editor, value: Int) { + editor.putInt(key, value) + } + } + + open class FloatSetting(key: String, defaultValue: Float, label: String, description: String) : + Setting(key = key, defaultValue = defaultValue, label = label, description = description) { + override fun getValue(sharedPreferences: SharedPreferences): Float { + return sharedPreferences.getFloat(key, defaultValue) + } + + override fun setValue(editor: SharedPreferences.Editor, value: Float) { + editor.putFloat(key, value) + } + } + + open class LongSetting(key: String, defaultValue: Long, label: String, description: String) : + Setting(key = key, defaultValue = defaultValue, label = label, description = description) { + override fun getValue(sharedPreferences: SharedPreferences): Long { + return sharedPreferences.getLong(key, defaultValue) + } + + override fun setValue(editor: SharedPreferences.Editor, value: Long) { + editor.putLong(key, value) + } + } + + open class DoubleSetting(key: String, defaultValue: Double, label: String, description: String) : + Setting(key = key, defaultValue = defaultValue, label = label, description = description) { + override fun getValue(sharedPreferences: SharedPreferences): Double { + return java.lang.Double.longBitsToDouble( + sharedPreferences.getLong( + key, + java.lang.Double.doubleToLongBits(defaultValue) + ) + ) + } + + override fun setValue(editor: SharedPreferences.Editor, value: Double) { + editor.putLong(key, java.lang.Double.doubleToLongBits(value)) + } + } + + open class DateSetting(key: String, defaultValue: Date, label: String, description: String) : + Setting(key = key, defaultValue = defaultValue, label = label, description = description) { + override fun getValue(sharedPreferences: SharedPreferences): Date { + return Date(sharedPreferences.getLong(key, defaultValue.time)) + } + + override fun setValue(editor: SharedPreferences.Editor, value: Date) { + editor.putLong(key, value.time) + } + } + + open class DurationSetting(key: String, defaultValue: Duration, label: String, description: String) : + Setting(key = key, defaultValue = defaultValue, label = label, description = description) { + override fun getValue(sharedPreferences: SharedPreferences): Duration { + return sharedPreferences.getLong(key, defaultValue.inWholeMilliseconds).milliseconds + } + + override fun setValue(editor: SharedPreferences.Editor, value: Duration) { + editor.putLong(key, value.inWholeMilliseconds) + } + } + open class StringSetting(key: String, defaultValue: String, label: String, description: String) : Setting(key = key, defaultValue = defaultValue, label = label, description = description) { override fun getValue(sharedPreferences: SharedPreferences): String { @@ -43,9 +118,9 @@ sealed class Setting( open class PercentSetting(key: String, defaultValue: Percent, label: String, description: String) : Setting(key = key, defaultValue = defaultValue, label = label, description = description) { - private companion object { - private val percentModel = PercentModel(0f, 100f) - } + private companion object { + private val percentModel = PercentModel(0f, 100f) + } override fun getValue(sharedPreferences: SharedPreferences): Percent { return sharedPreferences.getFloat(key, defaultValue.toFloat(percentModel)).toPercent(percentModel) @@ -56,4 +131,27 @@ sealed class Setting( } } + + open class AnyJsonSetting( + key: String, + defaultValue: T, + label: String, + description: String, + private val jsonAdapter: JsonAdapter + ) : Setting(key = key, defaultValue = defaultValue, label = label, description = description) { + + private companion object { + private const val DEFAULT_VALUE = "default_value" + } + + override fun getValue(sharedPreferences: SharedPreferences): T { + val json = sharedPreferences.getString(key, DEFAULT_VALUE) + return if (json == DEFAULT_VALUE) defaultValue else json?.let { jsonAdapter.fromJson(json) } as T + } + + override fun setValue(editor: SharedPreferences.Editor, value: T) { + editor.putString(key, jsonAdapter.toJson(value)) + } + } + } \ No newline at end of file From 80ce1ee8fc0d4b8d1149927a592b415ff0224c48 Mon Sep 17 00:00:00 2001 From: Anton Knyazev Date: Tue, 9 Jan 2024 18:36:00 +0300 Subject: [PATCH 7/8] Refactoring MvpScreenFactory --- .../base/annotations/AutoPresenterLauncher.kt | 10 ---- .../com/omega_r/base/simple/MainPresenter.kt | 9 ++-- .../dialog_fragment/DialogDialogFragment.kt | 7 +-- .../base/mvp/factory/MvpPresentersFactory.kt | 4 +- ...resenterFactory.kt => MvpScreenFactory.kt} | 2 +- .../com/omegar/mvp_processor/MvpProcessor.kt | 50 +++++++++++++------ 6 files changed, 41 insertions(+), 41 deletions(-) delete mode 100644 annotations/src/main/java/com/omega_r/base/annotations/AutoPresenterLauncher.kt rename core/src/main/java/com/omega_r/base/mvp/factory/{MvpPresenterFactory.kt => MvpScreenFactory.kt} (98%) diff --git a/annotations/src/main/java/com/omega_r/base/annotations/AutoPresenterLauncher.kt b/annotations/src/main/java/com/omega_r/base/annotations/AutoPresenterLauncher.kt deleted file mode 100644 index a725f09..0000000 --- a/annotations/src/main/java/com/omega_r/base/annotations/AutoPresenterLauncher.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.omega_r.base.annotations - -import kotlin.reflect.KClass - -@Retention(AnnotationRetention.SOURCE) -@Target(allowedTargets = [AnnotationTarget.CLASS]) -annotation class AutoPresenterLauncher( - vararg val delegatedClass: KClass<*>, - val localPresenterType: Boolean = true, -) \ No newline at end of file diff --git a/app/src/main/java/com/omega_r/base/simple/MainPresenter.kt b/app/src/main/java/com/omega_r/base/simple/MainPresenter.kt index d32ed44..83e130d 100644 --- a/app/src/main/java/com/omega_r/base/simple/MainPresenter.kt +++ b/app/src/main/java/com/omega_r/base/simple/MainPresenter.kt @@ -1,8 +1,8 @@ package com.omega_r.base.simple import android.os.SystemClock -import com.omega_r.base.annotations.AutoPresenterLauncher import com.omega_r.base.mvp.presenters.OmegaPresenter +import com.omega_r.base.simple.dialog_fragment.DialogScreenFactory import com.omega_r.libs.omegatypes.Text import java.io.Serializable @@ -10,7 +10,6 @@ import java.io.Serializable * Created by Anton Knyazev on 06.05.19. */ typealias TestEntity2 = TestEntity -@AutoPresenterLauncher(MainActivity::class, TestFragment::class) class MainPresenter(testEntity: TestEntity?, t2: TestEntity2?): OmegaPresenter() { companion object { @@ -23,8 +22,7 @@ class MainPresenter(testEntity: TestEntity?, t2: TestEntity2?): OmegaPresenter>, MvpPresenterFactory<*>>() + private val factoryMap = mutableMapOf>, MvpScreenFactory<*>>() fun hasFactory(presenterClass: KClass>) = factoryMap.containsKey(presenterClass) - fun

> addFactory(presenterClass: KClass

, factory: MvpPresenterFactory

) { + fun

> addFactory(presenterClass: KClass

, factory: MvpScreenFactory

) { factoryMap[presenterClass] = factory } diff --git a/core/src/main/java/com/omega_r/base/mvp/factory/MvpPresenterFactory.kt b/core/src/main/java/com/omega_r/base/mvp/factory/MvpScreenFactory.kt similarity index 98% rename from core/src/main/java/com/omega_r/base/mvp/factory/MvpPresenterFactory.kt rename to core/src/main/java/com/omega_r/base/mvp/factory/MvpScreenFactory.kt index 890ca27..9bbb6ac 100644 --- a/core/src/main/java/com/omega_r/base/mvp/factory/MvpPresenterFactory.kt +++ b/core/src/main/java/com/omega_r/base/mvp/factory/MvpScreenFactory.kt @@ -21,7 +21,7 @@ import com.omegar.mvp.presenter.PresenterType import java.io.Serializable import kotlin.reflect.KClass -abstract class MvpPresenterFactory>( +abstract class MvpScreenFactory>( internal val presenterType: PresenterType, private val presenterClass: KClass, ) { diff --git a/mvp-processor/src/main/java/com/omegar/mvp_processor/MvpProcessor.kt b/mvp-processor/src/main/java/com/omegar/mvp_processor/MvpProcessor.kt index 359ced0..a0184d9 100644 --- a/mvp-processor/src/main/java/com/omegar/mvp_processor/MvpProcessor.kt +++ b/mvp-processor/src/main/java/com/omegar/mvp_processor/MvpProcessor.kt @@ -2,7 +2,6 @@ package com.omegar.mvp_processor import com.google.devtools.ksp.KspExperimental import com.google.devtools.ksp.getAllSuperTypes -import com.google.devtools.ksp.getAnnotationsByType import com.google.devtools.ksp.getClassDeclarationByName import com.google.devtools.ksp.processing.CodeGenerator import com.google.devtools.ksp.processing.KSPLogger @@ -18,7 +17,7 @@ import com.google.devtools.ksp.symbol.KSTypeReference import com.google.devtools.ksp.symbol.KSValueParameter import com.google.devtools.ksp.symbol.KSVisitorVoid import com.google.devtools.ksp.validate -import com.omega_r.base.annotations.AutoPresenterLauncher +import com.omegar.mvp.MvpPresenter import com.omegar.mvp.MvpView import com.squareup.kotlinpoet.ClassName import com.squareup.kotlinpoet.CodeBlock @@ -51,7 +50,7 @@ class MvpProcessor( companion object { private val PRESENTER_TYPE = ClassName("com.omegar.mvp.presenter", "PresenterType") - private val MVP_PRESENTER_FACTORY = ClassName("com.omega_r.base.mvp.factory", "MvpPresenterFactory") + private val MVP_PRESENTER_FACTORY = ClassName("com.omega_r.base.mvp.factory", "MvpScreenFactory") private val BUNDLE = ClassName("android.os", "Bundle") private val PARCELABLE = ClassName("android.os", "Parcelable") private val SERIALIZABLE = ClassName("java.io", "Serializable") @@ -73,7 +72,7 @@ class MvpProcessor( private val delegateLauncherMap = mapOf( DelegateType.ACTIVITY to ACTIVITY_LAUNCHER_NAME, DelegateType.FRAGMENT to FRAGMENT_LAUNCHER_NAME, - DelegateType.DIALOG_FRAGMENT to DIALOG_FRAGMENT_NAME, + DelegateType.DIALOG_FRAGMENT to DIALOG_FRAGMENT_LAUNCHER_NAME, ) private val mvpDelegateLauncherMap = mapOf( @@ -83,17 +82,25 @@ class MvpProcessor( ) } + private var isProcessed = false override fun process(resolver: Resolver): List { + if (isProcessed) { + return emptyList() + } + isProcessed = true val serializableType = resolver.getClassDeclarationByName(SERIALIZABLE.canonicalName)!!.asType(emptyList()) val parcelableType = resolver.getClassDeclarationByName(PARCELABLE.canonicalName)!!.asType(emptyList()) val activityType = resolver.getClassDeclarationByName(ACTIVITY_NAME.canonicalName)!!.asType(emptyList()) val fragmentType = resolver.getClassDeclarationByName(FRAGMENT_NAME.canonicalName)!!.asType(emptyList()) val dialogFragmentType = resolver.getClassDeclarationByName(DIALOG_FRAGMENT_NAME.canonicalName)!!.asType(emptyList()) val mvpView = resolver.getClassDeclarationByName(MvpView::class.qualifiedName!!)!!.asStarProjectedType() + val mvpPresenter = resolver.getClassDeclarationByName(MvpPresenter::class.qualifiedName!!)!!.asStarProjectedType() - return resolver.getSymbolsWithAnnotation(AutoPresenterLauncher::class.qualifiedName!!) + return resolver.getAllFiles() + .flatMap { it.declarations } .filterIsInstance() + .filter { mvpPresenter.isAssignableFrom(it.asStarProjectedType()) } .filter { if (it.validate()) { it.accept( @@ -103,7 +110,8 @@ class MvpProcessor( activityType = activityType, fragmentType = fragmentType, dialogFragmentType = dialogFragmentType, - mvpView = mvpView + mvpView = mvpView, + resolver = resolver ), data = Unit ) @@ -120,28 +128,38 @@ class MvpProcessor( private val fragmentType: KSType, private val dialogFragmentType: KSType, private val mvpView: KSType, + private val resolver: Resolver, ) : KSVisitorVoid() { @OptIn(KspExperimental::class) override fun visitClassDeclaration(classDeclaration: KSClassDeclaration, data: Unit) { - val factoryName = classDeclaration.simpleName.asString() + "Factory" + val factoryName = classDeclaration.simpleName.asString().replace("Presenter", "") + "ScreenFactory" - val annotation = classDeclaration.getAnnotationsByType(AutoPresenterLauncher::class).first() - val ksAnnotation = classDeclaration.annotations.first { - it.annotationType.resolve().declaration.qualifiedName?.asString() == AutoPresenterLauncher::class.qualifiedName - } - val targetClass = ksAnnotation.arguments.first { it.name?.asString() == "delegatedClass" }.value as List + val (_, view) = classDeclaration.getSuperPresenterAndView() - val presenterType = if (annotation.localPresenterType) "LOCAL" else "GLOBAL" + val targetClass = resolver.getAllFiles() + .flatMap { it.declarations } + .filterIsInstance() + .map { it.asStarProjectedType() } + .filter { + (it.isActivity() || it.isFragment() || it.isDialogFragment()) && (view.isAssignableFrom(it)) + } + .toList() + + val presenterType = "LOCAL" - val (_, view) = classDeclaration.getSuperPresenterAndView() val viewStateName = view.toClassName().simpleName.replace("View", "MvpViewState") val presenterClassName = classDeclaration.toClassName() val typeSpec = TypeSpec.objectBuilder(factoryName) - .addOriginatingKSFile(classDeclaration.containingFile!!) + .apply { + addOriginatingKSFile(classDeclaration.containingFile!!) + targetClass.forEach { + addOriginatingKSFile(it.declaration.containingFile!!) + } + } .superclass(MVP_PRESENTER_FACTORY.parameterizedBy(presenterClassName)) .addSuperclassConstructorParameter("%T.$presenterType, %T::class", PRESENTER_TYPE, presenterClassName) .addInitializerBlock(CodeBlock.of( "$viewStateName.Companion")) @@ -330,8 +348,8 @@ class MvpProcessor( private fun KSType.getDelegateType() = when { isActivity() -> DelegateType.ACTIVITY - isFragment() -> DelegateType.FRAGMENT isDialogFragment() -> DelegateType.DIALOG_FRAGMENT + isFragment() -> DelegateType.FRAGMENT else -> throw IllegalArgumentException("Unknown type $this") } From acd314ab8a585387b217e64ca76aee464c2a1e42 Mon Sep 17 00:00:00 2001 From: Anton Knyazev Date: Wed, 7 Aug 2024 19:43:58 +0300 Subject: [PATCH 8/8] Upgrade libs --- Crash/build.gradle | 11 +++-------- app/build.gradle | 5 ++--- build.gradle | 6 +++--- core/build.gradle | 7 ++----- mvp-processor/build.gradle | 4 ++-- stub/build.gradle | 4 ++-- 6 files changed, 14 insertions(+), 23 deletions(-) diff --git a/Crash/build.gradle b/Crash/build.gradle index 07f3234..362cc5f 100644 --- a/Crash/build.gradle +++ b/Crash/build.gradle @@ -7,10 +7,8 @@ android { compileSdkVersion 31 defaultConfig { - minSdkVersion 16 + minSdkVersion 19 targetSdkVersion 31 - versionCode 1 - versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles "consumer-rules.pro" @@ -23,11 +21,8 @@ android { } } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - kotlinOptions { - jvmTarget = '1.8' + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } } diff --git a/app/build.gradle b/app/build.gradle index 28ca72a..1d34a20 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -32,11 +32,10 @@ android { compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } - kotlinOptions.jvmTarget = "1.8" } diff --git a/build.gradle b/build.gradle index 1054131..8be7492 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ buildscript { ext { omegaRecyclerView = '1.10.1' - omegaMoxy_version = '3.1.0' + omegaMoxy_version = '3.1.2' kotlinCorutines_version = '1.5.0' }// Top-level build file where you can add configuration options common to all sub-projects/modules. @@ -10,8 +10,8 @@ buildscript { } } plugins { - id 'com.android.application' version '7.3.0' apply false - id 'com.android.library' version '7.3.0' apply false + id 'com.android.application' version '7.4.2' apply false + id 'com.android.library' version '7.4.2' apply false id 'org.jetbrains.kotlin.android' version '1.9.0' apply false id 'org.jetbrains.kotlin.jvm' version '1.9.0' apply false id 'com.google.devtools.ksp' version '1.9.0-1.0.11' apply false diff --git a/core/build.gradle b/core/build.gradle index 272b101..a15fe98 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -36,8 +36,6 @@ android { defaultConfig { minSdkVersion 21 targetSdkVersion 31 - versionCode 1 - versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" @@ -51,11 +49,10 @@ android { } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } - kotlinOptions.jvmTarget = "1.8" } diff --git a/mvp-processor/build.gradle b/mvp-processor/build.gradle index 41e1f2f..eb121fa 100644 --- a/mvp-processor/build.gradle +++ b/mvp-processor/build.gradle @@ -29,8 +29,8 @@ publishing { } java { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } dependencies { diff --git a/stub/build.gradle b/stub/build.gradle index 1fdd92c..b647093 100644 --- a/stub/build.gradle +++ b/stub/build.gradle @@ -19,6 +19,6 @@ publishing { } java { - sourceCompatibility = JavaVersion.VERSION_1_7 - targetCompatibility = JavaVersion.VERSION_1_7 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } \ No newline at end of file