diff --git a/build.gradle.kts b/build.gradle.kts index 69e25dfe..659b875b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -25,6 +25,8 @@ plugins { // https://github.com/Kotlin/KEEP/blob/master/proposals/explicit-api-mode.md alias(libs.plugins.com.github.triplet.play) apply (false) id("toggles.ownership-conventions") + alias(libs.plugins.com.android.library) apply false + alias(libs.plugins.org.jetbrains.kotlin.android) apply false } fun isNonStable(version: String): Boolean { diff --git a/gradle.properties b/gradle.properties index 5edc5ca7..56cd9917 100644 --- a/gradle.properties +++ b/gradle.properties @@ -43,5 +43,5 @@ android.enableJetifier=false #kotlin.parallel.tasks.in.project=true org.gradle.caching=true -org.gradle.configuration-cache=false +org.gradle.configuration-cache=true org.gradle.configuration-cache.max-problems=5 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 089aa180..14725e8b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -19,6 +19,12 @@ com-squareup-moshi = "1.15.0" dokka = "1.8.20" kotlin = "1.9.10" org-jetbrains-kotlinx = "1.7.1" +agp = "8.1.2" +org-jetbrains-kotlin-android = "1.9.0" +junit = "4.13.2" +androidx-test-ext-junit = "1.1.5" +espresso-core = "3.5.1" +material = "1.9.0" [libraries] androidx-activity = { module = "androidx.activity:activity", version.ref = "androidx-activity" } @@ -177,6 +183,10 @@ org-robolectric = "org.robolectric:robolectric:4.10.3" se-eelde-toggles-toggles-core = { module = "se.eelde.toggles:toggles-core" } se-eelde-toggles-toggles-flow = { module = "se.eelde.toggles:toggles-flow" } se-eelde-toggles-toggles-prefs = { module = "se.eelde.toggles:toggles-prefs" } +junit-junit = { group = "junit", name = "junit", version.ref = "junit" } +androidx-test-ext-junit115 = { group = "androidx.test.ext", name = "junit", version.ref = "androidx-test-ext-junit" } +espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espresso-core" } +material = { group = "com.google.android.material", name = "material", version.ref = "material" } #se-eelde-toggles-toggles-core = "se.eelde.toggles:toggles-core:0.0.2" #se-eelde-toggles-toggles-flow = "se.eelde.toggles:toggles-flow:0.0.1" #se-eelde-toggles-toggles-prefs = "se.eelde.toggles:toggles-prefs:0.0.1" @@ -193,3 +203,5 @@ dagger-hilt-android-plugin = "dagger.hilt.android.plugin:2.47" nl-littlerobots-version-catalog-update = "nl.littlerobots.version-catalog-update:0.8.1" org-jetbrains-dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } org-jetbrains-kotlinx-binary-compatibility-validator = "org.jetbrains.kotlinx.binary-compatibility-validator:0.13.2" +com-android-library = { id = "com.android.library", version.ref = "agp" } +org-jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "org-jetbrains-kotlin-android" } diff --git a/modules/applications/consumer-rules.pro b/modules/applications/consumer-rules.pro deleted file mode 100644 index e69de29b..00000000 diff --git a/modules/applications/proguard-rules.pro b/modules/applications/proguard-rules.pro deleted file mode 100644 index 481bb434..00000000 --- a/modules/applications/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/modules/booleanconfiguration/.gitignore b/modules/booleanconfiguration/.gitignore new file mode 100644 index 00000000..42afabfd --- /dev/null +++ b/modules/booleanconfiguration/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/modules/booleanconfiguration/OWNERSHIP.toml b/modules/booleanconfiguration/OWNERSHIP.toml new file mode 100644 index 00000000..9e1cee56 --- /dev/null +++ b/modules/booleanconfiguration/OWNERSHIP.toml @@ -0,0 +1,4 @@ +version = 1 + +[owner] +user = "@erikeelde" \ No newline at end of file diff --git a/modules/booleanconfiguration/build.gradle.kts b/modules/booleanconfiguration/build.gradle.kts new file mode 100644 index 00000000..50d3d89d --- /dev/null +++ b/modules/booleanconfiguration/build.gradle.kts @@ -0,0 +1,33 @@ +plugins { + id("toggles.android.module-conventions") + id("toggles.ownership-conventions") +} + +android { + namespace = "se.eelde.toggles.booleanconfiguration" + buildFeatures { + compose = true + } + composeOptions { + kotlinCompilerExtensionVersion = libs.versions.androidx.compose.compiler.get() + } +} + +dependencies { + implementation(platform(libs.androidx.compose.bom)) + implementation(projects.modules.composeTheme) + implementation(projects.modules.database) + implementation(projects.modules.provider) + implementation(libs.androidx.core.core.ktx) + implementation(libs.androidx.appcompat) + implementation(libs.androidx.navigation.navigation.compose) + implementation(libs.androidx.hilt.hilt.navigation.compose) + implementation(libs.androidx.compose.runtime) + implementation(libs.androidx.compose.material3) + debugImplementation(libs.androidx.compose.ui.ui.tooling) + implementation(libs.androidx.compose.ui.ui.tooling.preview) + implementation(libs.androidx.startup.startup.runtime) + implementation(libs.com.google.dagger.hilt.android) + implementation(libs.se.eelde.toggles.toggles.core) + kapt(libs.com.google.dagger.hilt.compiler) +} \ No newline at end of file diff --git a/modules/booleanconfiguration/lint-baseline.xml b/modules/booleanconfiguration/lint-baseline.xml new file mode 100644 index 00000000..f32fed49 --- /dev/null +++ b/modules/booleanconfiguration/lint-baseline.xml @@ -0,0 +1,4 @@ + + + + diff --git a/modules/booleanconfiguration/src/main/AndroidManifest.xml b/modules/booleanconfiguration/src/main/AndroidManifest.xml new file mode 100644 index 00000000..a5918e68 --- /dev/null +++ b/modules/booleanconfiguration/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/toggles-app/src/main/java/se/eelde/toggles/dialogs/booleanvalue/BooleanValueView.kt b/modules/booleanconfiguration/src/main/java/se/eelde/toggles/booleanconfiguration/BooleanValueView.kt similarity index 96% rename from toggles-app/src/main/java/se/eelde/toggles/dialogs/booleanvalue/BooleanValueView.kt rename to modules/booleanconfiguration/src/main/java/se/eelde/toggles/booleanconfiguration/BooleanValueView.kt index 62a5ce1d..369635a4 100644 --- a/toggles-app/src/main/java/se/eelde/toggles/dialogs/booleanvalue/BooleanValueView.kt +++ b/modules/booleanconfiguration/src/main/java/se/eelde/toggles/booleanconfiguration/BooleanValueView.kt @@ -1,4 +1,4 @@ -package se.eelde.toggles.dialogs.booleanvalue +package se.eelde.toggles.booleanconfiguration import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column @@ -19,7 +19,7 @@ import kotlinx.coroutines.launch @Composable @Suppress("LongParameterList") -internal fun BooleanValueView( +fun BooleanValueView( uiState: ViewState, popBackStack: () -> Unit, setBooleanValue: (Boolean) -> Unit, diff --git a/toggles-app/src/main/java/se/eelde/toggles/dialogs/booleanvalue/BooleanValueViewModel.kt b/modules/booleanconfiguration/src/main/java/se/eelde/toggles/booleanconfiguration/BooleanValueViewModel.kt similarity index 93% rename from toggles-app/src/main/java/se/eelde/toggles/dialogs/booleanvalue/BooleanValueViewModel.kt rename to modules/booleanconfiguration/src/main/java/se/eelde/toggles/booleanconfiguration/BooleanValueViewModel.kt index e2f09dda..6ef25e2c 100644 --- a/toggles-app/src/main/java/se/eelde/toggles/dialogs/booleanvalue/BooleanValueViewModel.kt +++ b/modules/booleanconfiguration/src/main/java/se/eelde/toggles/booleanconfiguration/BooleanValueViewModel.kt @@ -1,4 +1,4 @@ -package se.eelde.toggles.dialogs.booleanvalue +package se.eelde.toggles.booleanconfiguration import android.app.Application import androidx.lifecycle.SavedStateHandle @@ -19,7 +19,7 @@ import se.eelde.toggles.provider.notifyUpdate import java.util.Date import javax.inject.Inject -internal data class ViewState( +data class ViewState( val title: String? = null, val checked: Boolean? = null, val saving: Boolean = false, @@ -44,7 +44,7 @@ class FragmentBooleanValueViewModel @Inject internal constructor( private val _state = MutableStateFlow(reduce(ViewState(), PartialViewState.Empty)) - internal val state: StateFlow + val state: StateFlow get() = _state private val configurationId: Long = savedStateHandle.get("configurationId")!! @@ -63,7 +63,10 @@ class FragmentBooleanValueViewModel @Inject internal constructor( if (it != null) { selectedConfigurationValue = it // viewEffects.value = Event(ViewEffect.CheckedChanged(it.value!!.toBoolean())) - _state.value = reduce(state.value, PartialViewState.NewConfigurationValue(it.value!!.toBoolean())) + _state.value = reduce( + state.value, + PartialViewState.NewConfigurationValue(it.value!!.toBoolean()) + ) } } } @@ -92,12 +95,12 @@ class FragmentBooleanValueViewModel @Inject internal constructor( } } - internal suspend fun saveClick() { + suspend fun saveClick() { _state.value = reduce(state.value, PartialViewState.Saving) updateConfigurationValue(state.value.checked.toString()).join() } - internal suspend fun revertClick() { + suspend fun revertClick() { _state.value = reduce(state.value, PartialViewState.Reverting) deleteConfigurationValue().join() } diff --git a/modules/configurations/.gitignore b/modules/configurations/.gitignore new file mode 100644 index 00000000..42afabfd --- /dev/null +++ b/modules/configurations/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/modules/configurations/OWNERSHIP.toml b/modules/configurations/OWNERSHIP.toml new file mode 100644 index 00000000..9e1cee56 --- /dev/null +++ b/modules/configurations/OWNERSHIP.toml @@ -0,0 +1,4 @@ +version = 1 + +[owner] +user = "@erikeelde" \ No newline at end of file diff --git a/modules/configurations/build.gradle.kts b/modules/configurations/build.gradle.kts new file mode 100644 index 00000000..8db64397 --- /dev/null +++ b/modules/configurations/build.gradle.kts @@ -0,0 +1,34 @@ +plugins { + id("toggles.android.module-conventions") + id("toggles.ownership-conventions") +} + +android { + namespace = "se.eelde.toggles.configurations" + buildFeatures { + compose = true + } + composeOptions { + kotlinCompilerExtensionVersion = libs.versions.androidx.compose.compiler.get() + } +} + +dependencies { + implementation(platform(libs.androidx.compose.bom)) + implementation(projects.modules.composeTheme) + implementation(projects.modules.database) + implementation(libs.se.eelde.toggles.toggles.core) + implementation(libs.androidx.core.core.ktx) + implementation(libs.androidx.lifecycle.lifecycle.runtime.compose) + implementation(libs.androidx.appcompat) + implementation(libs.androidx.navigation.navigation.compose) + implementation(libs.androidx.hilt.hilt.navigation.compose) + implementation(libs.androidx.compose.runtime) + implementation(libs.androidx.compose.material3) + debugImplementation(libs.androidx.compose.ui.ui.tooling) + implementation(libs.androidx.compose.material.material.icons.extended) + implementation(libs.androidx.compose.ui.ui.tooling.preview) + implementation(libs.androidx.startup.startup.runtime) + implementation(libs.com.google.dagger.hilt.android) + kapt(libs.com.google.dagger.hilt.compiler) +} \ No newline at end of file diff --git a/modules/configurations/lint-baseline.xml b/modules/configurations/lint-baseline.xml new file mode 100644 index 00000000..f32fed49 --- /dev/null +++ b/modules/configurations/lint-baseline.xml @@ -0,0 +1,4 @@ + + + + diff --git a/modules/configurations/src/main/AndroidManifest.xml b/modules/configurations/src/main/AndroidManifest.xml new file mode 100644 index 00000000..aa656a10 --- /dev/null +++ b/modules/configurations/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/toggles-app/src/main/java/se/eelde/toggles/configurationlist/ConfigurationListView.kt b/modules/configurations/src/main/java/se/eelde/toggles/configurations/ConfigurationListView.kt similarity index 77% rename from toggles-app/src/main/java/se/eelde/toggles/configurationlist/ConfigurationListView.kt rename to modules/configurations/src/main/java/se/eelde/toggles/configurations/ConfigurationListView.kt index b9c4de94..8ffe9692 100644 --- a/toggles-app/src/main/java/se/eelde/toggles/configurationlist/ConfigurationListView.kt +++ b/modules/configurations/src/main/java/se/eelde/toggles/configurations/ConfigurationListView.kt @@ -1,4 +1,4 @@ -package se.eelde.toggles.configurationlist +package se.eelde.toggles.configurations import android.text.TextUtils import android.util.Log @@ -18,16 +18,18 @@ import androidx.compose.ui.text.buildAnnotatedString import androidx.compose.ui.text.style.TextDecoration import androidx.compose.ui.text.withStyle import androidx.compose.ui.unit.dp -import androidx.navigation.NavController -import kotlinx.coroutines.ExperimentalCoroutinesApi import se.eelde.toggles.core.Toggle import se.eelde.toggles.database.WrenchConfigurationValue import se.eelde.toggles.database.WrenchConfigurationWithValues import se.eelde.toggles.database.WrenchScope @Composable +@Suppress("LongParameterList") internal fun ConfigurationListView( - navController: NavController, + navigateToBooleanConfiguration: (scopeId: Long, configurationId: Long) -> Unit, + navigateToIntegerConfiguration: (scopeId: Long, configurationId: Long) -> Unit, + navigateToStringConfiguration: (scopeId: Long, configurationId: Long) -> Unit, + navigateToEnumConfiguration: (scopeId: Long, configurationId: Long) -> Unit, uiState: State, modifier: Modifier = Modifier, ) { @@ -46,7 +48,10 @@ internal fun ConfigurationListView( .clickable { Log.w("Clicked configuration", "") configurationClicked( - navController = navController, + navigateToBooleanConfiguration = navigateToBooleanConfiguration, + navigateToIntegerConfiguration = navigateToIntegerConfiguration, + navigateToStringConfiguration = navigateToStringConfiguration, + navigateToEnumConfiguration = navigateToEnumConfiguration, configuration = configuration, selectedScope = uiState.value.selectedScope ) @@ -107,10 +112,12 @@ private fun getItemForScope( return null } -@Suppress("LongMethod") -@OptIn(ExperimentalCoroutinesApi::class) +@Suppress("LongMethod", "LongParameterList") fun configurationClicked( - navController: NavController, + navigateToBooleanConfiguration: (scopeId: Long, configurationId: Long) -> Unit, + navigateToIntegerConfiguration: (scopeId: Long, configurationId: Long) -> Unit, + navigateToStringConfiguration: (scopeId: Long, configurationId: Long) -> Unit, + navigateToEnumConfiguration: (scopeId: Long, configurationId: Long) -> Unit, configuration: WrenchConfigurationWithValues, selectedScope: WrenchScope? ) { @@ -124,25 +131,25 @@ fun configurationClicked( configuration.type ) || TextUtils.equals(Toggle.TYPE.STRING, configuration.type) ) { - navController.navigate("configuration/${configuration.id}/${selectedScope!!.id}/string") + navigateToStringConfiguration(selectedScope!!.id, configuration.id) } else if (TextUtils.equals(Int::class.java.name, configuration.type) || TextUtils.equals( Toggle.TYPE.INTEGER, configuration.type ) ) { - navController.navigate("configuration/${configuration.id}/${selectedScope!!.id}/integer") + navigateToIntegerConfiguration(selectedScope!!.id, configuration.id) } else if (TextUtils.equals( Boolean::class.java.name, configuration.type ) || TextUtils.equals(Toggle.TYPE.BOOLEAN, configuration.type) ) { - navController.navigate("configuration/${configuration.id}/${selectedScope!!.id}/boolean") + navigateToBooleanConfiguration(selectedScope!!.id, configuration.id) } else if (TextUtils.equals(Enum::class.java.name, configuration.type) || TextUtils.equals( Toggle.TYPE.ENUM, configuration.type ) ) { - navController.navigate("configuration/${configuration.id}/${selectedScope!!.id}/enum") + navigateToEnumConfiguration(selectedScope!!.id, configuration.id) } else { // Snackbar.make( // binding.animator, diff --git a/toggles-app/src/main/java/se/eelde/toggles/configurationlist/ConfigurationViewModel.kt b/modules/configurations/src/main/java/se/eelde/toggles/configurations/ConfigurationViewModel.kt similarity index 99% rename from toggles-app/src/main/java/se/eelde/toggles/configurationlist/ConfigurationViewModel.kt rename to modules/configurations/src/main/java/se/eelde/toggles/configurations/ConfigurationViewModel.kt index ae49e5ea..97ca2f51 100644 --- a/toggles-app/src/main/java/se/eelde/toggles/configurationlist/ConfigurationViewModel.kt +++ b/modules/configurations/src/main/java/se/eelde/toggles/configurations/ConfigurationViewModel.kt @@ -1,4 +1,4 @@ -package se.eelde.toggles.configurationlist +package se.eelde.toggles.configurations import android.app.ActivityManager import android.content.Context @@ -107,7 +107,6 @@ class ConfigurationViewModel @Inject internal constructor( is PartialViewState.Configurations -> viewState.copy( configurations = partialViewState.configurations ) - PartialViewState.Empty -> viewState is PartialViewState.DefaultScope -> viewState.copy(defaultScope = partialViewState.scope) is PartialViewState.SelectedScope -> viewState.copy(selectedScope = partialViewState.scope) diff --git a/toggles-app/src/main/java/se/eelde/toggles/configurationlist/ConfigurationsEntry.kt b/modules/configurations/src/main/java/se/eelde/toggles/configurations/ConfigurationsEntry.kt similarity index 88% rename from toggles-app/src/main/java/se/eelde/toggles/configurationlist/ConfigurationsEntry.kt rename to modules/configurations/src/main/java/se/eelde/toggles/configurations/ConfigurationsEntry.kt index a2faa76e..a2837dcb 100644 --- a/toggles-app/src/main/java/se/eelde/toggles/configurationlist/ConfigurationsEntry.kt +++ b/modules/configurations/src/main/java/se/eelde/toggles/configurations/ConfigurationsEntry.kt @@ -1,4 +1,4 @@ -package se.eelde.toggles.configurationlist +package se.eelde.toggles.configurations import android.content.Intent import android.net.Uri @@ -23,7 +23,6 @@ import androidx.compose.runtime.collectAsState import androidx.compose.ui.Modifier import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle -import androidx.navigation.NavController import androidx.navigation.NavGraphBuilder import androidx.navigation.NavType import androidx.navigation.compose.composable @@ -32,7 +31,10 @@ import androidx.navigation.navArgument @Suppress("LongMethod") @OptIn(ExperimentalMaterial3Api::class) fun NavGraphBuilder.configurationsNavigations( - navController: NavController, + navigateToBooleanConfiguration: (scopeId: Long, configurationId: Long) -> Unit, + navigateToIntegerConfiguration: (scopeId: Long, configurationId: Long) -> Unit, + navigateToStringConfiguration: (scopeId: Long, configurationId: Long) -> Unit, + navigateToEnumConfiguration: (scopeId: Long, configurationId: Long) -> Unit, back: () -> Unit, ) { composable( @@ -124,7 +126,10 @@ fun NavGraphBuilder.configurationsNavigations( }, ) { paddingValues -> ConfigurationListView( - navController = navController, + navigateToBooleanConfiguration = navigateToBooleanConfiguration, + navigateToIntegerConfiguration = navigateToIntegerConfiguration, + navigateToStringConfiguration = navigateToStringConfiguration, + navigateToEnumConfiguration = navigateToEnumConfiguration, uiState = uiState, modifier = Modifier.padding(paddingValues), ) diff --git a/modules/database/consumer-rules.pro b/modules/database/consumer-rules.pro deleted file mode 100644 index e69de29b..00000000 diff --git a/modules/enumconfiguration/.gitignore b/modules/enumconfiguration/.gitignore new file mode 100644 index 00000000..42afabfd --- /dev/null +++ b/modules/enumconfiguration/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/modules/enumconfiguration/OWNERSHIP.toml b/modules/enumconfiguration/OWNERSHIP.toml new file mode 100644 index 00000000..9e1cee56 --- /dev/null +++ b/modules/enumconfiguration/OWNERSHIP.toml @@ -0,0 +1,4 @@ +version = 1 + +[owner] +user = "@erikeelde" \ No newline at end of file diff --git a/modules/enumconfiguration/build.gradle.kts b/modules/enumconfiguration/build.gradle.kts new file mode 100644 index 00000000..50d3d89d --- /dev/null +++ b/modules/enumconfiguration/build.gradle.kts @@ -0,0 +1,33 @@ +plugins { + id("toggles.android.module-conventions") + id("toggles.ownership-conventions") +} + +android { + namespace = "se.eelde.toggles.booleanconfiguration" + buildFeatures { + compose = true + } + composeOptions { + kotlinCompilerExtensionVersion = libs.versions.androidx.compose.compiler.get() + } +} + +dependencies { + implementation(platform(libs.androidx.compose.bom)) + implementation(projects.modules.composeTheme) + implementation(projects.modules.database) + implementation(projects.modules.provider) + implementation(libs.androidx.core.core.ktx) + implementation(libs.androidx.appcompat) + implementation(libs.androidx.navigation.navigation.compose) + implementation(libs.androidx.hilt.hilt.navigation.compose) + implementation(libs.androidx.compose.runtime) + implementation(libs.androidx.compose.material3) + debugImplementation(libs.androidx.compose.ui.ui.tooling) + implementation(libs.androidx.compose.ui.ui.tooling.preview) + implementation(libs.androidx.startup.startup.runtime) + implementation(libs.com.google.dagger.hilt.android) + implementation(libs.se.eelde.toggles.toggles.core) + kapt(libs.com.google.dagger.hilt.compiler) +} \ No newline at end of file diff --git a/modules/enumconfiguration/lint-baseline.xml b/modules/enumconfiguration/lint-baseline.xml new file mode 100644 index 00000000..f32fed49 --- /dev/null +++ b/modules/enumconfiguration/lint-baseline.xml @@ -0,0 +1,4 @@ + + + + diff --git a/modules/enumconfiguration/src/main/AndroidManifest.xml b/modules/enumconfiguration/src/main/AndroidManifest.xml new file mode 100644 index 00000000..a5918e68 --- /dev/null +++ b/modules/enumconfiguration/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/toggles-app/src/main/java/se/eelde/toggles/dialogs/enumvalue/EnumValueView.kt b/modules/enumconfiguration/src/main/java/se/eelde/toggles/enumconfiguration/EnumValueView.kt similarity index 97% rename from toggles-app/src/main/java/se/eelde/toggles/dialogs/enumvalue/EnumValueView.kt rename to modules/enumconfiguration/src/main/java/se/eelde/toggles/enumconfiguration/EnumValueView.kt index b917acbf..1e9ec425 100644 --- a/toggles-app/src/main/java/se/eelde/toggles/dialogs/enumvalue/EnumValueView.kt +++ b/modules/enumconfiguration/src/main/java/se/eelde/toggles/enumconfiguration/EnumValueView.kt @@ -1,4 +1,4 @@ -package se.eelde.toggles.dialogs.enumvalue +package se.eelde.toggles.enumconfiguration import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement @@ -19,7 +19,7 @@ import androidx.compose.ui.unit.dp import kotlinx.coroutines.launch @Composable -internal fun EnumValueView( +fun EnumValueView( state: ViewState, setEnumValue: suspend (String) -> Unit, revert: suspend () -> Unit, diff --git a/toggles-app/src/main/java/se/eelde/toggles/dialogs/enumvalue/EnumValueViewModel.kt b/modules/enumconfiguration/src/main/java/se/eelde/toggles/enumconfiguration/EnumValueViewModel.kt similarity index 96% rename from toggles-app/src/main/java/se/eelde/toggles/dialogs/enumvalue/EnumValueViewModel.kt rename to modules/enumconfiguration/src/main/java/se/eelde/toggles/enumconfiguration/EnumValueViewModel.kt index 4ea5f0f4..0be8c600 100644 --- a/toggles-app/src/main/java/se/eelde/toggles/dialogs/enumvalue/EnumValueViewModel.kt +++ b/modules/enumconfiguration/src/main/java/se/eelde/toggles/enumconfiguration/EnumValueViewModel.kt @@ -1,4 +1,4 @@ -package se.eelde.toggles.dialogs.enumvalue +package se.eelde.toggles.enumconfiguration import android.app.Application import androidx.lifecycle.SavedStateHandle @@ -22,7 +22,7 @@ import se.eelde.toggles.provider.notifyUpdate import java.util.Date import javax.inject.Inject -internal data class ViewState( +data class ViewState( val title: String? = null, val configurationValues: List = listOf(), val saving: Boolean = false, @@ -50,7 +50,7 @@ class FragmentEnumValueViewModel @Inject internal constructor( private val _state = MutableStateFlow(reduce(ViewState(), PartialViewState.Empty)) - internal val state: StateFlow + val state: StateFlow get() = _state private val configurationId: Long = savedStateHandle.get("configurationId")!! @@ -99,7 +99,7 @@ class FragmentEnumValueViewModel @Inject internal constructor( } } - internal suspend fun saveClick(value: String) { + suspend fun saveClick(value: String) { _state.value = reduce(_state.value, PartialViewState.Saving) updateConfigurationValue(value).join() application.contentResolver.notifyUpdate( @@ -109,7 +109,7 @@ class FragmentEnumValueViewModel @Inject internal constructor( ) } - internal suspend fun revertClick() { + suspend fun revertClick() { _state.value = reduce(_state.value, PartialViewState.Reverting) deleteConfigurationValue().join() application.contentResolver.notifyInsert( diff --git a/modules/help/.gitignore b/modules/help/.gitignore new file mode 100644 index 00000000..42afabfd --- /dev/null +++ b/modules/help/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/modules/help/OWNERSHIP.toml b/modules/help/OWNERSHIP.toml new file mode 100644 index 00000000..9e1cee56 --- /dev/null +++ b/modules/help/OWNERSHIP.toml @@ -0,0 +1,4 @@ +version = 1 + +[owner] +user = "@erikeelde" \ No newline at end of file diff --git a/modules/help/build.gradle.kts b/modules/help/build.gradle.kts new file mode 100644 index 00000000..762c9503 --- /dev/null +++ b/modules/help/build.gradle.kts @@ -0,0 +1,30 @@ +plugins { + id("toggles.android.module-conventions") + id("toggles.ownership-conventions") +} + +android { + namespace = "se.eelde.toggles.help" + buildFeatures { + compose = true + } + composeOptions { + kotlinCompilerExtensionVersion = libs.versions.androidx.compose.compiler.get() + } +} + +dependencies { + implementation(platform(libs.androidx.compose.bom)) + implementation(projects.modules.composeTheme) + implementation(libs.androidx.core.core.ktx) + implementation(libs.androidx.appcompat) + implementation(libs.androidx.navigation.navigation.compose) + implementation(libs.androidx.hilt.hilt.navigation.compose) + implementation(libs.androidx.compose.runtime) + implementation(libs.androidx.compose.material3) + debugImplementation(libs.androidx.compose.ui.ui.tooling) + implementation(libs.androidx.compose.ui.ui.tooling.preview) + implementation(libs.androidx.startup.startup.runtime) + implementation(libs.com.google.dagger.hilt.android) + kapt(libs.com.google.dagger.hilt.compiler) +} \ No newline at end of file diff --git a/modules/help/lint-baseline.xml b/modules/help/lint-baseline.xml new file mode 100644 index 00000000..f32fed49 --- /dev/null +++ b/modules/help/lint-baseline.xml @@ -0,0 +1,4 @@ + + + + diff --git a/modules/help/src/main/AndroidManifest.xml b/modules/help/src/main/AndroidManifest.xml new file mode 100644 index 00000000..a5918e68 --- /dev/null +++ b/modules/help/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/toggles-app/src/main/java/se/eelde/toggles/help/HelpView.kt b/modules/help/src/main/java/se/eelde/toggles/help/HelpView.kt similarity index 100% rename from toggles-app/src/main/java/se/eelde/toggles/help/HelpView.kt rename to modules/help/src/main/java/se/eelde/toggles/help/HelpView.kt diff --git a/modules/integerconfiguration/.gitignore b/modules/integerconfiguration/.gitignore new file mode 100644 index 00000000..42afabfd --- /dev/null +++ b/modules/integerconfiguration/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/modules/integerconfiguration/OWNERSHIP.toml b/modules/integerconfiguration/OWNERSHIP.toml new file mode 100644 index 00000000..9e1cee56 --- /dev/null +++ b/modules/integerconfiguration/OWNERSHIP.toml @@ -0,0 +1,4 @@ +version = 1 + +[owner] +user = "@erikeelde" \ No newline at end of file diff --git a/modules/integerconfiguration/build.gradle.kts b/modules/integerconfiguration/build.gradle.kts new file mode 100644 index 00000000..50d3d89d --- /dev/null +++ b/modules/integerconfiguration/build.gradle.kts @@ -0,0 +1,33 @@ +plugins { + id("toggles.android.module-conventions") + id("toggles.ownership-conventions") +} + +android { + namespace = "se.eelde.toggles.booleanconfiguration" + buildFeatures { + compose = true + } + composeOptions { + kotlinCompilerExtensionVersion = libs.versions.androidx.compose.compiler.get() + } +} + +dependencies { + implementation(platform(libs.androidx.compose.bom)) + implementation(projects.modules.composeTheme) + implementation(projects.modules.database) + implementation(projects.modules.provider) + implementation(libs.androidx.core.core.ktx) + implementation(libs.androidx.appcompat) + implementation(libs.androidx.navigation.navigation.compose) + implementation(libs.androidx.hilt.hilt.navigation.compose) + implementation(libs.androidx.compose.runtime) + implementation(libs.androidx.compose.material3) + debugImplementation(libs.androidx.compose.ui.ui.tooling) + implementation(libs.androidx.compose.ui.ui.tooling.preview) + implementation(libs.androidx.startup.startup.runtime) + implementation(libs.com.google.dagger.hilt.android) + implementation(libs.se.eelde.toggles.toggles.core) + kapt(libs.com.google.dagger.hilt.compiler) +} \ No newline at end of file diff --git a/modules/integerconfiguration/lint-baseline.xml b/modules/integerconfiguration/lint-baseline.xml new file mode 100644 index 00000000..f32fed49 --- /dev/null +++ b/modules/integerconfiguration/lint-baseline.xml @@ -0,0 +1,4 @@ + + + + diff --git a/modules/integerconfiguration/src/main/AndroidManifest.xml b/modules/integerconfiguration/src/main/AndroidManifest.xml new file mode 100644 index 00000000..a5918e68 --- /dev/null +++ b/modules/integerconfiguration/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/toggles-app/src/main/java/se/eelde/toggles/dialogs/integervalue/IntegerValueView.kt b/modules/integerconfiguration/src/main/java/se/eelde/toggles/integerconfiguration/IntegerValueView.kt similarity index 97% rename from toggles-app/src/main/java/se/eelde/toggles/dialogs/integervalue/IntegerValueView.kt rename to modules/integerconfiguration/src/main/java/se/eelde/toggles/integerconfiguration/IntegerValueView.kt index 49ce1e27..e8b41737 100644 --- a/toggles-app/src/main/java/se/eelde/toggles/dialogs/integervalue/IntegerValueView.kt +++ b/modules/integerconfiguration/src/main/java/se/eelde/toggles/integerconfiguration/IntegerValueView.kt @@ -1,4 +1,4 @@ -package se.eelde.toggles.dialogs.integervalue +package se.eelde.toggles.integerconfiguration import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column @@ -33,7 +33,7 @@ fun IntegerValueViewPreview() { @Composable @Suppress("LongParameterList") -internal fun IntegerValueView( +fun IntegerValueView( uiState: ViewState, popBackStack: () -> Unit, revert: suspend () -> Unit, diff --git a/toggles-app/src/main/java/se/eelde/toggles/dialogs/integervalue/IntegerValueViewModel.kt b/modules/integerconfiguration/src/main/java/se/eelde/toggles/integerconfiguration/IntegerValueViewModel.kt similarity index 96% rename from toggles-app/src/main/java/se/eelde/toggles/dialogs/integervalue/IntegerValueViewModel.kt rename to modules/integerconfiguration/src/main/java/se/eelde/toggles/integerconfiguration/IntegerValueViewModel.kt index 26e6a648..df7826bc 100644 --- a/toggles-app/src/main/java/se/eelde/toggles/dialogs/integervalue/IntegerValueViewModel.kt +++ b/modules/integerconfiguration/src/main/java/se/eelde/toggles/integerconfiguration/IntegerValueViewModel.kt @@ -1,4 +1,4 @@ -package se.eelde.toggles.dialogs.integervalue +package se.eelde.toggles.integerconfiguration import android.app.Application import androidx.lifecycle.SavedStateHandle @@ -19,7 +19,7 @@ import se.eelde.toggles.provider.notifyUpdate import java.util.Date import javax.inject.Inject -internal data class ViewState( +data class ViewState( val title: String? = null, val integerValue: Int? = null, val saving: Boolean = false, @@ -44,7 +44,7 @@ class FragmentIntegerValueViewModel @Inject internal constructor( private val _state = MutableStateFlow(reduce(ViewState(), PartialViewState.Empty)) - internal val state: StateFlow + val state: StateFlow get() = _state private val configurationId: Long = savedStateHandle.get("configurationId")!! @@ -101,7 +101,7 @@ class FragmentIntegerValueViewModel @Inject internal constructor( _state.value = reduce(state.value, PartialViewState.NewConfigurationValue(newValue)) } - internal suspend fun saveClick() { + suspend fun saveClick() { _state.value = reduce(state.value, PartialViewState.Saving) // updateConfigurationValue(state.value.integerValue).join() @@ -112,7 +112,7 @@ class FragmentIntegerValueViewModel @Inject internal constructor( } } - internal suspend fun revertClick() { + suspend fun revertClick() { _state.value = reduce(state.value, PartialViewState.Reverting) deleteConfigurationValue().join() } diff --git a/modules/provider/.gitignore b/modules/provider/.gitignore new file mode 100644 index 00000000..42afabfd --- /dev/null +++ b/modules/provider/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/modules/provider/OWNERSHIP.toml b/modules/provider/OWNERSHIP.toml new file mode 100644 index 00000000..9e1cee56 --- /dev/null +++ b/modules/provider/OWNERSHIP.toml @@ -0,0 +1,4 @@ +version = 1 + +[owner] +user = "@erikeelde" \ No newline at end of file diff --git a/modules/provider/build.gradle.kts b/modules/provider/build.gradle.kts new file mode 100644 index 00000000..1e3705f3 --- /dev/null +++ b/modules/provider/build.gradle.kts @@ -0,0 +1,34 @@ +plugins { + id("toggles.android.module-conventions") + id("toggles.ownership-conventions") +} + +android { + namespace = "se.eelde.toggles.help" + buildFeatures { + + compose = true + } + composeOptions { + kotlinCompilerExtensionVersion = libs.versions.androidx.compose.compiler.get() + } +} + +dependencies { + implementation(platform(libs.androidx.compose.bom)) + implementation(projects.modules.composeTheme) + implementation(projects.modules.database) + implementation(libs.androidx.core.core.ktx) + implementation(libs.androidx.appcompat) + implementation(libs.se.eelde.toggles.toggles.core) + implementation(libs.se.eelde.toggles.toggles.prefs) + implementation(libs.androidx.navigation.navigation.compose) + implementation(libs.androidx.hilt.hilt.navigation.compose) + implementation(libs.androidx.compose.runtime) + implementation(libs.androidx.compose.material3) + debugImplementation(libs.androidx.compose.ui.ui.tooling) + implementation(libs.androidx.compose.ui.ui.tooling.preview) + implementation(libs.androidx.startup.startup.runtime) + implementation(libs.com.google.dagger.hilt.android) + kapt(libs.com.google.dagger.hilt.compiler) +} \ No newline at end of file diff --git a/modules/provider/lint-baseline.xml b/modules/provider/lint-baseline.xml new file mode 100644 index 00000000..f32fed49 --- /dev/null +++ b/modules/provider/lint-baseline.xml @@ -0,0 +1,4 @@ + + + + diff --git a/modules/provider/src/main/AndroidManifest.xml b/modules/provider/src/main/AndroidManifest.xml new file mode 100644 index 00000000..a5918e68 --- /dev/null +++ b/modules/provider/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/toggles-app/src/main/java/se/eelde/toggles/provider/ContentResolverExtensions.kt b/modules/provider/src/main/java/se/eelde/toggles/provider/ContentResolverExtensions.kt similarity index 100% rename from toggles-app/src/main/java/se/eelde/toggles/provider/ContentResolverExtensions.kt rename to modules/provider/src/main/java/se/eelde/toggles/provider/ContentResolverExtensions.kt diff --git a/toggles-app/src/main/java/se/eelde/toggles/provider/PackageManagerWrapper.kt b/modules/provider/src/main/java/se/eelde/toggles/provider/PackageManagerWrapper.kt similarity index 100% rename from toggles-app/src/main/java/se/eelde/toggles/provider/PackageManagerWrapper.kt rename to modules/provider/src/main/java/se/eelde/toggles/provider/PackageManagerWrapper.kt diff --git a/toggles-app/src/main/java/se/eelde/toggles/provider/TogglesApiVersion.kt b/modules/provider/src/main/java/se/eelde/toggles/provider/TogglesApiVersion.kt similarity index 100% rename from toggles-app/src/main/java/se/eelde/toggles/provider/TogglesApiVersion.kt rename to modules/provider/src/main/java/se/eelde/toggles/provider/TogglesApiVersion.kt diff --git a/toggles-app/src/main/java/se/eelde/toggles/provider/TogglesProvider.kt b/modules/provider/src/main/java/se/eelde/toggles/provider/TogglesProvider.kt similarity index 90% rename from toggles-app/src/main/java/se/eelde/toggles/provider/TogglesProvider.kt rename to modules/provider/src/main/java/se/eelde/toggles/provider/TogglesProvider.kt index 4bdceee3..660bc955 100644 --- a/toggles-app/src/main/java/se/eelde/toggles/provider/TogglesProvider.kt +++ b/modules/provider/src/main/java/se/eelde/toggles/provider/TogglesProvider.kt @@ -12,12 +12,6 @@ import dagger.hilt.EntryPoint import dagger.hilt.InstallIn import dagger.hilt.android.EntryPointAccessors import dagger.hilt.components.SingletonComponent -import se.eelde.toggles.BuildConfig -import se.eelde.toggles.TogglesUriMatcher -import se.eelde.toggles.TogglesUriMatcher.Companion.CURRENT_CONFIGURATIONS -import se.eelde.toggles.TogglesUriMatcher.Companion.CURRENT_CONFIGURATION_ID -import se.eelde.toggles.TogglesUriMatcher.Companion.CURRENT_CONFIGURATION_KEY -import se.eelde.toggles.TogglesUriMatcher.Companion.PREDEFINED_CONFIGURATION_VALUES import se.eelde.toggles.core.Toggle import se.eelde.toggles.database.WrenchApplication import se.eelde.toggles.database.WrenchApplicationDao @@ -62,6 +56,10 @@ class TogglesProvider : ContentProvider() { applicationEntryPoint.providesWrenchPreferences() } + private val togglesUriMatcher: TogglesUriMatcher by lazy { + applicationEntryPoint.providesTogglesUriMatcher() + } + private val applicationEntryPoint: TogglesProviderEntryPoint by lazy { EntryPointAccessors.fromApplication(context!!, TogglesProviderEntryPoint::class.java) } @@ -76,6 +74,7 @@ class TogglesProvider : ContentProvider() { fun providePredefinedConfigurationValueDao(): WrenchPredefinedConfigurationValueDao fun providePackageManagerWrapper(): IPackageManagerWrapper fun providesWrenchPreferences(): TogglesPreferences + fun providesTogglesUriMatcher(): TogglesUriMatcher } private fun getCallingApplication(applicationDao: WrenchApplicationDao): WrenchApplication = @@ -114,8 +113,8 @@ class TogglesProvider : ContentProvider() { var cursor: Cursor? - when (uriMatcher.match(uri)) { - CURRENT_CONFIGURATION_ID -> { + when (togglesUriMatcher.match(uri)) { + togglesUriMatcher.currentConfigurationId -> { val scope = getSelectedScope(context, scopeDao, callingApplication.id) cursor = configurationDao.getToggle( java.lang.Long.valueOf(uri.lastPathSegment!!), @@ -133,7 +132,7 @@ class TogglesProvider : ContentProvider() { } } - CURRENT_CONFIGURATION_KEY -> { + togglesUriMatcher.currentConfigurationKey -> { // this change is experimental and might be a way // for consumers to @Suppress("ConstantConditionIf") @@ -171,7 +170,7 @@ class TogglesProvider : ContentProvider() { } private fun isTogglesApplication(callingApplication: WrenchApplication): Boolean { - return callingApplication.packageName == BuildConfig.APPLICATION_ID + return callingApplication.packageName == context!!.packageName } override fun insert(uri: Uri, values: ContentValues?): Uri { @@ -182,8 +181,8 @@ class TogglesProvider : ContentProvider() { } val insertId: Long - when (uriMatcher.match(uri)) { - CURRENT_CONFIGURATIONS -> { + when (togglesUriMatcher.match(uri)) { + togglesUriMatcher.currentConfigurations -> { val toggle = Toggle.fromContentValues(values!!) var wrenchConfiguration: WrenchConfiguration? = @@ -220,7 +219,7 @@ class TogglesProvider : ContentProvider() { insertId = wrenchConfiguration.id } - PREDEFINED_CONFIGURATION_VALUES -> { + togglesUriMatcher.predefinedConfigurationValues -> { val fullConfig = WrenchPredefinedConfigurationValue.fromContentValues(values!!) insertId = try { predefinedConfigurationDao.insert(fullConfig) @@ -265,8 +264,8 @@ class TogglesProvider : ContentProvider() { } val updatedRows: Int - when (uriMatcher.match(uri)) { - CURRENT_CONFIGURATION_ID -> { + when (togglesUriMatcher.match(uri)) { + togglesUriMatcher.currentConfigurationId -> { val toggle = Toggle.fromContentValues(values!!) val scope = getSelectedScope(context, scopeDao, callingApplication.id) updatedRows = configurationValueDao.updateConfigurationValueSync( @@ -314,21 +313,21 @@ class TogglesProvider : ContentProvider() { assertValidApiVersion(togglesPreferences, uri) } - return when (uriMatcher.match(uri)) { - CURRENT_CONFIGURATIONS -> { - "vnd.android.cursor.dir/vnd.${BuildConfig.APPLICATION_ID}.currentConfiguration" + return when (togglesUriMatcher.match(uri)) { + togglesUriMatcher.currentConfigurations -> { + "vnd.android.cursor.dir/vnd.${context!!.packageName}.currentConfiguration" } - CURRENT_CONFIGURATION_ID -> { - "vnd.android.cursor.item/vnd.${BuildConfig.APPLICATION_ID}.currentConfiguration" + togglesUriMatcher.currentConfigurationId -> { + "vnd.android.cursor.item/vnd.${context!!.packageName}.currentConfiguration" } - CURRENT_CONFIGURATION_KEY -> { - "vnd.android.cursor.dir/vnd.${BuildConfig.APPLICATION_ID}.currentConfiguration" + togglesUriMatcher.currentConfigurationKey -> { + "vnd.android.cursor.dir/vnd.${context!!.packageName}.currentConfiguration" } - PREDEFINED_CONFIGURATION_VALUES -> { - "vnd.android.cursor.dir/vnd.${BuildConfig.APPLICATION_ID}.predefinedConfigurationValue" + togglesUriMatcher.predefinedConfigurationValues -> { + "vnd.android.cursor.dir/vnd.${context!!.packageName}.predefinedConfigurationValue" } else -> { @@ -339,8 +338,6 @@ class TogglesProvider : ContentProvider() { companion object { - private val uriMatcher = TogglesUriMatcher.getTogglesUriMatcher() - private const val oneSecond = 1000 @Synchronized diff --git a/modules/provider/src/main/java/se/eelde/toggles/provider/TogglesUriMatcher.kt b/modules/provider/src/main/java/se/eelde/toggles/provider/TogglesUriMatcher.kt new file mode 100644 index 00000000..eb55604a --- /dev/null +++ b/modules/provider/src/main/java/se/eelde/toggles/provider/TogglesUriMatcher.kt @@ -0,0 +1,53 @@ +package se.eelde.toggles.provider + +import android.content.UriMatcher +import android.net.Uri + +class TogglesUriMatcher constructor(providerAuthority: String) { + @Suppress("MagicNumber") + internal val currentConfigurationId = 1 + + @Suppress("MagicNumber") + internal val currentConfigurationKey = 2 + + @Suppress("MagicNumber") + internal val currentConfigurations = 3 + + @Suppress("MagicNumber") + internal val predefinedConfigurationValues = 5 + + @Suppress("MagicNumber") + private val applicationId = 6 + + private val uriMatcher = UriMatcher(UriMatcher.NO_MATCH) + + fun match(uri: Uri) = uriMatcher.match(uri) + + init { + uriMatcher.addURI( + providerAuthority, + "application/#", + applicationId + ) + uriMatcher.addURI( + providerAuthority, + "currentConfiguration/#", + currentConfigurationId + ) + uriMatcher.addURI( + providerAuthority, + "currentConfiguration/*", + currentConfigurationKey + ) + uriMatcher.addURI( + providerAuthority, + "currentConfiguration", + currentConfigurations + ) + uriMatcher.addURI( + providerAuthority, + "predefinedConfigurationValue", + predefinedConfigurationValues + ) + } +} diff --git a/modules/stringconfiguration/.gitignore b/modules/stringconfiguration/.gitignore new file mode 100644 index 00000000..42afabfd --- /dev/null +++ b/modules/stringconfiguration/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/modules/stringconfiguration/OWNERSHIP.toml b/modules/stringconfiguration/OWNERSHIP.toml new file mode 100644 index 00000000..9e1cee56 --- /dev/null +++ b/modules/stringconfiguration/OWNERSHIP.toml @@ -0,0 +1,4 @@ +version = 1 + +[owner] +user = "@erikeelde" \ No newline at end of file diff --git a/modules/stringconfiguration/build.gradle.kts b/modules/stringconfiguration/build.gradle.kts new file mode 100644 index 00000000..50d3d89d --- /dev/null +++ b/modules/stringconfiguration/build.gradle.kts @@ -0,0 +1,33 @@ +plugins { + id("toggles.android.module-conventions") + id("toggles.ownership-conventions") +} + +android { + namespace = "se.eelde.toggles.booleanconfiguration" + buildFeatures { + compose = true + } + composeOptions { + kotlinCompilerExtensionVersion = libs.versions.androidx.compose.compiler.get() + } +} + +dependencies { + implementation(platform(libs.androidx.compose.bom)) + implementation(projects.modules.composeTheme) + implementation(projects.modules.database) + implementation(projects.modules.provider) + implementation(libs.androidx.core.core.ktx) + implementation(libs.androidx.appcompat) + implementation(libs.androidx.navigation.navigation.compose) + implementation(libs.androidx.hilt.hilt.navigation.compose) + implementation(libs.androidx.compose.runtime) + implementation(libs.androidx.compose.material3) + debugImplementation(libs.androidx.compose.ui.ui.tooling) + implementation(libs.androidx.compose.ui.ui.tooling.preview) + implementation(libs.androidx.startup.startup.runtime) + implementation(libs.com.google.dagger.hilt.android) + implementation(libs.se.eelde.toggles.toggles.core) + kapt(libs.com.google.dagger.hilt.compiler) +} \ No newline at end of file diff --git a/modules/stringconfiguration/lint-baseline.xml b/modules/stringconfiguration/lint-baseline.xml new file mode 100644 index 00000000..f32fed49 --- /dev/null +++ b/modules/stringconfiguration/lint-baseline.xml @@ -0,0 +1,4 @@ + + + + diff --git a/modules/stringconfiguration/src/main/AndroidManifest.xml b/modules/stringconfiguration/src/main/AndroidManifest.xml new file mode 100644 index 00000000..a5918e68 --- /dev/null +++ b/modules/stringconfiguration/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/toggles-app/src/main/java/se/eelde/toggles/dialogs/stringvalue/StringValueView.kt b/modules/stringconfiguration/src/main/java/se/eelde/toggles/stringconfiguration/StringValueView.kt similarity index 97% rename from toggles-app/src/main/java/se/eelde/toggles/dialogs/stringvalue/StringValueView.kt rename to modules/stringconfiguration/src/main/java/se/eelde/toggles/stringconfiguration/StringValueView.kt index 655188ca..70460281 100644 --- a/toggles-app/src/main/java/se/eelde/toggles/dialogs/stringvalue/StringValueView.kt +++ b/modules/stringconfiguration/src/main/java/se/eelde/toggles/stringconfiguration/StringValueView.kt @@ -1,4 +1,4 @@ -package se.eelde.toggles.dialogs.stringvalue +package se.eelde.toggles.stringconfiguration import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column @@ -34,7 +34,7 @@ fun StringValueViewPreview() { @Composable @Suppress("LongParameterList") -internal fun StringValueView( +fun StringValueView( state: ViewState, setStringValue: (String) -> Unit, save: suspend () -> Unit, diff --git a/toggles-app/src/main/java/se/eelde/toggles/dialogs/stringvalue/StringValueViewModel.kt b/modules/stringconfiguration/src/main/java/se/eelde/toggles/stringconfiguration/StringValueViewModel.kt similarity index 96% rename from toggles-app/src/main/java/se/eelde/toggles/dialogs/stringvalue/StringValueViewModel.kt rename to modules/stringconfiguration/src/main/java/se/eelde/toggles/stringconfiguration/StringValueViewModel.kt index 6ec453bf..ba8b8bf0 100644 --- a/toggles-app/src/main/java/se/eelde/toggles/dialogs/stringvalue/StringValueViewModel.kt +++ b/modules/stringconfiguration/src/main/java/se/eelde/toggles/stringconfiguration/StringValueViewModel.kt @@ -1,4 +1,4 @@ -package se.eelde.toggles.dialogs.stringvalue +package se.eelde.toggles.stringconfiguration import android.app.Application import androidx.lifecycle.SavedStateHandle @@ -19,7 +19,7 @@ import se.eelde.toggles.provider.notifyUpdate import java.util.Date import javax.inject.Inject -internal data class ViewState( +data class ViewState( val title: String? = null, val stringValue: String? = null, val saving: Boolean = false, @@ -45,7 +45,7 @@ class FragmentStringValueViewModel private val _state = MutableStateFlow(reduce(ViewState(), PartialViewState.Empty)) - internal val state: StateFlow + val state: StateFlow get() = _state private val configurationId: Long = savedStateHandle.get("configurationId")!! @@ -97,7 +97,7 @@ class FragmentStringValueViewModel _state.value = reduce(state.value, PartialViewState.NewConfigurationValue(newValue)) } - internal suspend fun saveClick() { + suspend fun saveClick() { _state.value = reduce(state.value, PartialViewState.Saving) state.value.stringValue?.let { updateConfigurationValue(it).join() @@ -106,7 +106,7 @@ class FragmentStringValueViewModel } } - internal suspend fun revertClick() { + suspend fun revertClick() { _state.value = reduce(state.value, PartialViewState.Reverting) deleteConfigurationValue() } diff --git a/settings.gradle.kts b/settings.gradle.kts index b95704d6..258300f9 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -69,8 +69,15 @@ include( ":toggles-sample", ":modules:compose-theme", ":modules:database", + ":modules:provider", ":modules:applications", + ":modules:configurations", ":modules:oss", + ":modules:help", + ":modules:stringconfiguration", + ":modules:booleanconfiguration", + ":modules:integerconfiguration", + ":modules:enumconfiguration", ) dependencyResolutionManagement { diff --git a/toggles-app/build.gradle.kts b/toggles-app/build.gradle.kts index 8fd9b802..fb809d4a 100644 --- a/toggles-app/build.gradle.kts +++ b/toggles-app/build.gradle.kts @@ -99,8 +99,15 @@ android { dependencies { implementation(projects.modules.composeTheme) implementation(projects.modules.database) + implementation(projects.modules.provider) implementation(projects.modules.applications) + implementation(projects.modules.configurations) implementation(projects.modules.oss) + implementation(projects.modules.help) + implementation(projects.modules.booleanconfiguration) + implementation(projects.modules.integerconfiguration) + implementation(projects.modules.stringconfiguration) + implementation(projects.modules.enumconfiguration) implementation(libs.androidx.ui.ui.tooling) implementation(platform(libs.androidx.compose.bom)) diff --git a/toggles-app/src/main/AndroidManifest.xml b/toggles-app/src/main/AndroidManifest.xml index f0b09093..eb987516 100644 --- a/toggles-app/src/main/AndroidManifest.xml +++ b/toggles-app/src/main/AndroidManifest.xml @@ -9,7 +9,6 @@ android:protectionLevel="normal" /> - + navController.navigate("configuration/$configurationId/$scopeId/boolean") + }, + navigateToIntegerConfiguration = { scopeId: Long, configurationId: Long -> + navController.navigate("configuration/$configurationId/$scopeId/integer") + }, + navigateToStringConfiguration = { scopeId: Long, configurationId: Long -> + navController.navigate("configuration/$configurationId/$scopeId/string") + }, + navigateToEnumConfiguration = { scopeId: Long, configurationId: Long -> + navController.navigate("configuration/$configurationId/$scopeId/enum") + } + ) { navController.popBackStack() } composable( "configuration/{configurationId}/{scopeId}/boolean", arguments = listOf( @@ -243,7 +255,7 @@ fun Navigation( ) }, ) { paddingValues -> - HelpView(modifier = Modifier.padding(paddingValues)) + se.eelde.toggles.help.HelpView(modifier = Modifier.padding(paddingValues)) } } } diff --git a/toggles-app/src/main/java/se/eelde/toggles/TogglesUriMatcher.kt b/toggles-app/src/main/java/se/eelde/toggles/TogglesUriMatcher.kt deleted file mode 100644 index 416db2de..00000000 --- a/toggles-app/src/main/java/se/eelde/toggles/TogglesUriMatcher.kt +++ /dev/null @@ -1,45 +0,0 @@ -package se.eelde.toggles - -import android.content.UriMatcher - -class TogglesUriMatcher private constructor() { - companion object { - internal const val CURRENT_CONFIGURATION_ID = 1 - internal const val CURRENT_CONFIGURATION_KEY = 2 - internal const val CURRENT_CONFIGURATIONS = 3 - internal const val PREDEFINED_CONFIGURATION_VALUES = 5 - private const val APPLICATION_ID = 6 - - private val uriMatcher = UriMatcher(UriMatcher.NO_MATCH) - - fun getTogglesUriMatcher() = uriMatcher - - init { - uriMatcher.addURI( - BuildConfig.CONFIG_AUTHORITY, - "application/#", - APPLICATION_ID - ) - uriMatcher.addURI( - BuildConfig.CONFIG_AUTHORITY, - "currentConfiguration/#", - CURRENT_CONFIGURATION_ID - ) - uriMatcher.addURI( - BuildConfig.CONFIG_AUTHORITY, - "currentConfiguration/*", - CURRENT_CONFIGURATION_KEY - ) - uriMatcher.addURI( - BuildConfig.CONFIG_AUTHORITY, - "currentConfiguration", - CURRENT_CONFIGURATIONS - ) - uriMatcher.addURI( - BuildConfig.CONFIG_AUTHORITY, - "predefinedConfigurationValue", - PREDEFINED_CONFIGURATION_VALUES - ) - } - } -} diff --git a/toggles-app/src/main/java/se/eelde/toggles/di/ApplicationModule.kt b/toggles-app/src/main/java/se/eelde/toggles/di/ApplicationModule.kt index e64e313b..1b799722 100644 --- a/toggles-app/src/main/java/se/eelde/toggles/di/ApplicationModule.kt +++ b/toggles-app/src/main/java/se/eelde/toggles/di/ApplicationModule.kt @@ -7,14 +7,19 @@ import dagger.hilt.InstallIn import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.components.SingletonComponent import kotlinx.coroutines.Dispatchers +import se.eelde.toggles.BuildConfig import se.eelde.toggles.prefs.TogglesPreferences import se.eelde.toggles.prefs.TogglesPreferencesImpl import se.eelde.toggles.provider.IPackageManagerWrapper import se.eelde.toggles.provider.PackageManagerWrapper +import se.eelde.toggles.provider.TogglesUriMatcher @Module @InstallIn(SingletonComponent::class) object ApplicationModule { + @Provides + fun provideTogglesUriMatcher() = TogglesUriMatcher(BuildConfig.CONFIG_AUTHORITY) + @Provides fun provideIoDispatcher() = Dispatchers.IO diff --git a/toggles-app/src/test/java/se/eelde/toggles/provider/TogglesProviderTest.kt b/toggles-app/src/test/java/se/eelde/toggles/provider/TogglesProviderTest.kt index 992fb5cc..548ff19f 100644 --- a/toggles-app/src/test/java/se/eelde/toggles/provider/TogglesProviderTest.kt +++ b/toggles-app/src/test/java/se/eelde/toggles/provider/TogglesProviderTest.kt @@ -136,12 +136,12 @@ class TogglesProviderTest { Assert.assertEquals(insertToggle.value, providerToggle.value) Assert.assertEquals(insertToggle.type, providerToggle.type) - val updateToggle = Toggle( - providerToggle.id, - providerToggle.type, - providerToggle.key, - providerToggle.value!! + providerToggle.value!! - ) + val updateToggle = Toggle { + id = providerToggle.id + type = providerToggle.type + key = providerToggle.key + value = providerToggle.value!! + providerToggle.value!! + } val update = togglesProvider.update( TogglesProviderContract.toggleUri(updateToggle.id), @@ -253,10 +253,18 @@ class TogglesProviderTest { } private fun getToggleValue(value: String): ToggleValue { - return ToggleValue(0, value) + return ToggleValue { + id = 0 + this.value = value + } } private fun getToggle(key: String): Toggle { - return Toggle(0L, "toggletype", key, "togglevalue") + return Toggle { + id = 0L + type = "toggletype" + this.key = key + value = "togglevalue" + } } } diff --git a/toggles-core/gradle.properties b/toggles-core/gradle.properties index db030065..5e25a3b1 100644 --- a/toggles-core/gradle.properties +++ b/toggles-core/gradle.properties @@ -29,5 +29,5 @@ android.useAndroidX=true android.enableJetifier=false org.gradle.caching=true -org.gradle.configuration-cache=false +org.gradle.configuration-cache=true org.gradle.configuration-cache.max-problems=5 diff --git a/toggles-flow-noop/gradle.properties b/toggles-flow-noop/gradle.properties index 5f7e1688..829c958c 100644 --- a/toggles-flow-noop/gradle.properties +++ b/toggles-flow-noop/gradle.properties @@ -29,5 +29,5 @@ android.useAndroidX=true android.enableJetifier=false org.gradle.caching=true -org.gradle.configuration-cache=false +org.gradle.configuration-cache=true org.gradle.configuration-cache.max-problems=5 diff --git a/toggles-flow/gradle.properties b/toggles-flow/gradle.properties index 580fe004..d323a277 100644 --- a/toggles-flow/gradle.properties +++ b/toggles-flow/gradle.properties @@ -29,5 +29,5 @@ android.useAndroidX=true android.enableJetifier=false org.gradle.caching=true -org.gradle.configuration-cache=false +org.gradle.configuration-cache=true org.gradle.configuration-cache.max-problems=5 diff --git a/toggles-prefs-noop/gradle.properties b/toggles-prefs-noop/gradle.properties index 1ae96d63..0f25c8b6 100644 --- a/toggles-prefs-noop/gradle.properties +++ b/toggles-prefs-noop/gradle.properties @@ -29,5 +29,5 @@ android.useAndroidX=true android.enableJetifier=false org.gradle.caching=true -org.gradle.configuration-cache=false +org.gradle.configuration-cache=true org.gradle.configuration-cache.max-problems=5 diff --git a/toggles-prefs/gradle.properties b/toggles-prefs/gradle.properties index 234dc945..85b9837e 100644 --- a/toggles-prefs/gradle.properties +++ b/toggles-prefs/gradle.properties @@ -29,5 +29,5 @@ android.useAndroidX=true android.enableJetifier=false org.gradle.caching=true -org.gradle.configuration-cache=false +org.gradle.configuration-cache=true org.gradle.configuration-cache.max-problems=5 diff --git a/versions.properties b/versions.properties new file mode 100644 index 00000000..e9750eab --- /dev/null +++ b/versions.properties @@ -0,0 +1,6 @@ +V_VERSION=1.02.00 +V_VERSION_CODE=102000 +V_DEBUG_VERSION_SUFFIX=25-g6026e2e +V_DEBUG_VERSION=1.02.00-25-g6026e2e +HASH=6026e2e +DIRTY=false