diff --git a/.github/workflows/app-release.yml b/.github/workflows/app-release.yml index dfc07d79..00b587fe 100644 --- a/.github/workflows/app-release.yml +++ b/.github/workflows/app-release.yml @@ -35,4 +35,4 @@ jobs: run: ./gradlew check --exclude-task testReleaseUnitTest - name: Publish application - run: ./gradlew :toggles-app:publish + run: ./gradlew :toggles-app:publishRelease diff --git a/.github/workflows/core-release.yml b/.github/workflows/core-release.yml index 36db2f0d..d469ae11 100644 --- a/.github/workflows/core-release.yml +++ b/.github/workflows/core-release.yml @@ -25,15 +25,13 @@ jobs: - name: Setup environment run: | - mkdir -p ~/.gradle - touch ~/.gradle/gradle.properties - echo "signing.keyId=${{secrets.SIGNING_KEYID}}" >> ~/.gradle/gradle.properties - echo "signing.password=${{secrets.SIGNING_PASSWORD}}" >> ~/.gradle/gradle.properties - echo "signing.secretKeyRingFile=~/.gradle/secring.gpg" >> ~/.gradle/gradle.properties - echo "mavenCentralRepositoryUsername=${{secrets.MAVEN_CENTRAL_REPOSITORY_USERNAME}}" >> ~/.gradle/gradle.properties - echo "mavenCentralRepositoryPassword=${{secrets.MAVEN_CENTRAL_REPOSITORY_PASSWORD}}" >> ~/.gradle/gradle.properties - echo "${{secrets.SECRING_GPG_B64}}" > ~/.gradle/secring.gpg.b64 - base64 -d ~/.gradle/secring.gpg.b64 > ~/.gradle/secring.gpg + echo "signing.keyId=${{secrets.SIGNING_KEYID}}" >> gradle.properties + echo "signing.password=${{secrets.SIGNING_PASSWORD}}" >> gradle.properties + echo "signing.secretKeyRingFile=../secring.gpg" >> gradle.properties + echo "mavenCentralRepositoryUsername=${{secrets.MAVEN_CENTRAL_REPOSITORY_USERNAME}}" >> gradle.properties + echo "mavenCentralRepositoryPassword=${{secrets.MAVEN_CENTRAL_REPOSITORY_PASSWORD}}" >> gradle.properties + echo "${{secrets.SECRING_GPG_B64}}" > secring.gpg.b64 + base64 -d secring.gpg.b64 > secring.gpg - name: Publish core library run: ./gradlew :toggles-core:publish --no-daemon --no-parallel diff --git a/.github/workflows/flow-release.yml b/.github/workflows/flow-release.yml index 50ac225e..25237f7f 100644 --- a/.github/workflows/flow-release.yml +++ b/.github/workflows/flow-release.yml @@ -25,15 +25,13 @@ jobs: - name: Setup environment run: | - mkdir -p ~/.gradle - touch ~/.gradle/gradle.properties - echo "signing.keyId=${{secrets.SIGNING_KEYID}}" >> ~/.gradle/gradle.properties - echo "signing.password=${{secrets.SIGNING_PASSWORD}}" >> ~/.gradle/gradle.properties - echo "signing.secretKeyRingFile=~/.gradle/secring.gpg" >> ~/.gradle/gradle.properties - echo "mavenCentralRepositoryUsername=${{secrets.MAVEN_CENTRAL_REPOSITORY_USERNAME}}" >> ~/.gradle/gradle.properties - echo "mavenCentralRepositoryPassword=${{secrets.MAVEN_CENTRAL_REPOSITORY_PASSWORD}}" >> ~/.gradle/gradle.properties - echo "${{secrets.SECRING_GPG_B64}}" > ~/.gradle/secring.gpg.b64 - base64 -d ~/.gradle/secring.gpg.b64 > ~/.gradle/secring.gpg + echo "signing.keyId=${{secrets.SIGNING_KEYID}}" >> gradle.properties + echo "signing.password=${{secrets.SIGNING_PASSWORD}}" >> gradle.properties + echo "signing.secretKeyRingFile=../secring.gpg" >> gradle.properties + echo "mavenCentralRepositoryUsername=${{secrets.MAVEN_CENTRAL_REPOSITORY_USERNAME}}" >> gradle.properties + echo "mavenCentralRepositoryPassword=${{secrets.MAVEN_CENTRAL_REPOSITORY_PASSWORD}}" >> gradle.properties + echo "${{secrets.SECRING_GPG_B64}}" > secring.gpg.b64 + base64 -d secring.gpg.b64 > secring.gpg - name: Publish flow library run: ./gradlew :toggles-flow:publish --no-daemon --no-parallel diff --git a/.github/workflows/post-merge.yml b/.github/workflows/post-merge.yml index 1f2d55df..ceb32541 100644 --- a/.github/workflows/post-merge.yml +++ b/.github/workflows/post-merge.yml @@ -36,15 +36,13 @@ jobs: - name: Setup environment run: | - mkdir -p ~/.gradle - touch ~/.gradle/gradle.properties - echo "signing.keyId=${{secrets.SIGNING_KEYID}}" >> ~/.gradle/gradle.properties - echo "signing.password=${{secrets.SIGNING_PASSWORD}}" >> ~/.gradle/gradle.properties - echo "signing.secretKeyRingFile=~/.gradle/secring.gpg" >> ~/.gradle/gradle.properties - echo "mavenCentralRepositoryUsername=${{secrets.MAVEN_CENTRAL_REPOSITORY_USERNAME}}" >> ~/.gradle/gradle.properties - echo "mavenCentralRepositoryPassword=${{secrets.MAVEN_CENTRAL_REPOSITORY_PASSWORD}}" >> ~/.gradle/gradle.properties - echo "${{secrets.SECRING_GPG_B64}}" > ~/.gradle/secring.gpg.b64 - base64 -d ~/.gradle/secring.gpg.b64 > ~/.gradle/secring.gpg + echo "signing.keyId=${{secrets.SIGNING_KEYID}}" >> gradle.properties + echo "signing.password=${{secrets.SIGNING_PASSWORD}}" >> gradle.properties + echo "signing.secretKeyRingFile=secring.gpg" >> gradle.properties + echo "mavenCentralRepositoryUsername=${{secrets.MAVEN_CENTRAL_REPOSITORY_USERNAME}}" >> gradle.properties + echo "mavenCentralRepositoryPassword=${{secrets.MAVEN_CENTRAL_REPOSITORY_PASSWORD}}" >> gradle.properties + echo "${{secrets.SECRING_GPG_B64}}" > secring.gpg.b64 + base64 -d secring.gpg.b64 > secring.gpg - name: Publish core library run: ./gradlew :toggles-prefs:publish --no-daemon --no-parallel diff --git a/.github/workflows/prefs-release.yml b/.github/workflows/prefs-release.yml index 689c888c..e8b8c466 100644 --- a/.github/workflows/prefs-release.yml +++ b/.github/workflows/prefs-release.yml @@ -25,15 +25,13 @@ jobs: - name: Setup environment run: | - mkdir -p ~/.gradle - touch ~/.gradle/gradle.properties - echo "signing.keyId=${{secrets.SIGNING_KEYID}}" >> ~/.gradle/gradle.properties - echo "signing.password=${{secrets.SIGNING_PASSWORD}}" >> ~/.gradle/gradle.properties - echo "signing.secretKeyRingFile=~/.gradle/secring.gpg" >> ~/.gradle/gradle.properties - echo "mavenCentralRepositoryUsername=${{secrets.MAVEN_CENTRAL_REPOSITORY_USERNAME}}" >> ~/.gradle/gradle.properties - echo "mavenCentralRepositoryPassword=${{secrets.MAVEN_CENTRAL_REPOSITORY_PASSWORD}}" >> ~/.gradle/gradle.properties - echo "${{secrets.SECRING_GPG_B64}}" > ~/.gradle/secring.gpg.b64 - base64 -d ~/.gradle/secring.gpg.b64 > ~/.gradle/secring.gpg + echo "signing.keyId=${{secrets.SIGNING_KEYID}}" >> gradle.properties + echo "signing.password=${{secrets.SIGNING_PASSWORD}}" >> gradle.properties + echo "signing.secretKeyRingFile=../secring.gpg" >> gradle.properties + echo "mavenCentralRepositoryUsername=${{secrets.MAVEN_CENTRAL_REPOSITORY_USERNAME}}" >> gradle.properties + echo "mavenCentralRepositoryPassword=${{secrets.MAVEN_CENTRAL_REPOSITORY_PASSWORD}}" >> gradle.properties + echo "${{secrets.SECRING_GPG_B64}}" > secring.gpg.b64 + base64 -d secring.gpg.b64 > secring.gpg - name: Publish prefs library run: ./gradlew :toggles-prefs:publish --no-daemon --no-parallel diff --git a/README.md b/README.md index 118a3c93..3bed3df3 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,6 @@ Development tool to store app settings / feature toggles in an external application making in persist across clean data / reinstallations. -## - ## Toggles app Toggles can be downloaded on [play store](https://play.google.com/store/apps/details?id=se.eelde.toggles). @@ -13,13 +11,25 @@ Stores settings / toggles behind a content provider. This is a development tools meant to facilitate feature switching in an external app so that configurations will be retained across clear data / uninstalls. -2 premade libraries to talk to the toggles application. "Prefs" and "Flow": +2 premade libraries to talk to the toggles application. "Prefs" and "Flow" - Backed by a common core library: ## Toggles-flow library Exposes switches from toggles using a kotlin flow. +``` + implementation("se.eelde.toggles:toggles-flow:0.0.1") +``` ## Toggles-prefs library One-shot fetch of a toggle. Similar API as androids SharedPreferences. +``` + implementation("se.eelde.toggles:toggles-prefs:0.0.1") +``` + +## Toggles-core library +Base library exposing common bit to help communicating with the toggles application via the provider. Generally shouldn't be needed unless implementing your own library. +``` + implementation("se.eelde.toggles:toggles-core:0.0.2") +``` #### Previously known as wrench The idea dates way back to and was inspired by the now removed [Dash Clock Widget](https://play.google.com/store/apps/details?id=net.nurik.roman.dashclock) as well as the still maintained [muzei](https://play.google.com/store/apps/details?id=net.nurik.roman.muzei). diff --git a/build.gradle.kts b/build.gradle.kts index e635b5df..bb35c127 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -49,6 +49,7 @@ allprojects { google() mavenCentral() jcenter() + maven("https://s01.oss.sonatype.org/service/local/repositories/seeelde-1001/content") } } diff --git a/toggles-app/build.gradle.kts b/toggles-app/build.gradle.kts index b394821d..433bcdd4 100644 --- a/toggles-app/build.gradle.kts +++ b/toggles-app/build.gradle.kts @@ -65,8 +65,8 @@ android { applicationId = "se.eelde.toggles" minSdk = 21 targetSdk = 30 - versionCode = 5 - versionName = "1.01.01" + versionCode = 6 + versionName = "1.01.02" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true @@ -202,9 +202,12 @@ dependencies { implementation("androidx.navigation:navigation-ui-ktx:2.3.5") implementation("com.izettle.wrench:wrench-core:0.3") - implementation(project(":toggles-core")) - implementation(project(":toggles-prefs")) - implementation(project(":toggles-flow")) +// implementation(project(":toggles-core")) +// implementation(project(":toggles-prefs")) +// implementation(project(":toggles-flow")) + implementation("se.eelde.toggles:toggles-core:0.0.2") + implementation("se.eelde.toggles:toggles-flow:0.0.1") + implementation("se.eelde.toggles:toggles-prefs:0.0.1") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.3") diff --git a/toggles-core/build.gradle.kts b/toggles-core/build.gradle.kts index 2d52b056..006bdd12 100644 --- a/toggles-core/build.gradle.kts +++ b/toggles-core/build.gradle.kts @@ -47,7 +47,6 @@ kotlin { } dependencies { - implementation("androidx.core:core-ktx:1.3.2") testImplementation("junit:junit:4.13.2") implementation("androidx.annotation:annotation:1.2.0") } diff --git a/toggles-core/gradle.properties b/toggles-core/gradle.properties index 73c0e383..f8074c07 100644 --- a/toggles-core/gradle.properties +++ b/toggles-core/gradle.properties @@ -1,3 +1,3 @@ POM_ARTIFACT_ID=toggles-core POM_NAME=Toggles Core -VERSION_NAME=0.0.2-SNAPSHOT +VERSION_NAME=0.0.3-SNAPSHOT diff --git a/toggles-core/src/main/java/se/eelde/toggles/core/TogglesProviderContract.kt b/toggles-core/src/main/java/se/eelde/toggles/core/TogglesProviderContract.kt index ed4b34de..af7ab8bc 100644 --- a/toggles-core/src/main/java/se/eelde/toggles/core/TogglesProviderContract.kt +++ b/toggles-core/src/main/java/se/eelde/toggles/core/TogglesProviderContract.kt @@ -4,8 +4,6 @@ import android.content.ContentValues import android.database.Cursor import android.net.Uri import androidx.annotation.StringDef -import androidx.core.database.getLongOrNull -import androidx.core.database.getStringOrNull class ColumnNames { object Toggle { @@ -85,15 +83,29 @@ data class Toggle( @JvmStatic fun fromCursor(cursor: Cursor): Toggle { return Toggle( - id = cursor.getLongOrNull(cursor.getColumnIndexOrThrow(ColumnNames.Toggle.COL_ID))!!, - type = cursor.getStringOrNull(cursor.getColumnIndexOrThrow(ColumnNames.Toggle.COL_TYPE))!!, - key = cursor.getStringOrNull(cursor.getColumnIndexOrThrow(ColumnNames.Toggle.COL_KEY))!!, - value = cursor.getStringOrNull(cursor.getColumnIndexOrThrow(ColumnNames.Toggle.COL_VALUE)) + id = cursor.getLongOrThrow(ColumnNames.Toggle.COL_ID), + type = cursor.getStringOrThrow(ColumnNames.Toggle.COL_TYPE), + key = cursor.getStringOrThrow(ColumnNames.Toggle.COL_KEY), + value = cursor.getStringOrNull(ColumnNames.Toggle.COL_VALUE) ) } } } +private fun Cursor.getStringOrThrow(columnName: String): String = getStringOrNull(columnName)!! + +private fun Cursor.getStringOrNull(columnName: String): String? { + val index = getColumnIndexOrThrow(columnName) + return if (isNull(index)) null else getString(index) +} + +private fun Cursor.getLongOrThrow(columnName: String): Long = getLongOrNull(columnName)!! + +private fun Cursor.getLongOrNull(columnName: String): Long? { + val index = getColumnIndexOrThrow(columnName) + return if (isNull(index)) null else getLong(index) +} + object TogglesProviderContract { private const val TOGGLES_AUTHORITY = BuildConfig.TOGGLES_AUTHORITY private const val TOGGLES_API_VERSION_QUERY_PARAM = "API_VERSION" diff --git a/toggles-flow/build.gradle.kts b/toggles-flow/build.gradle.kts index 33d86bc8..d127cb43 100644 --- a/toggles-flow/build.gradle.kts +++ b/toggles-flow/build.gradle.kts @@ -45,10 +45,6 @@ kotlin { explicitApi() } -repositories { - maven("https://s01.oss.sonatype.org/content/repositories/snapshots") -} - dependencies { testImplementation("junit:junit:4.13.2") @@ -59,8 +55,8 @@ dependencies { testImplementation("androidx.test.ext:junit:1.1.2") testImplementation("org.robolectric:robolectric:4.5.1") - //implementation("se.eelde.toggles:toggles-core:0.0.1") - implementation("se.eelde.toggles:toggles-core:0.0.2-SNAPSHOT") + implementation("se.eelde.toggles:toggles-core:0.0.2") + //implementation("se.eelde.toggles:toggles-core:0.0.2-SNAPSHOT") //implementation(project(":toggles-core")) implementation("androidx.annotation:annotation:1.2.0") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.3") diff --git a/toggles-flow/gradle.properties b/toggles-flow/gradle.properties index 078a7049..5cb4aa09 100644 --- a/toggles-flow/gradle.properties +++ b/toggles-flow/gradle.properties @@ -1,3 +1,3 @@ POM_ARTIFACT_ID=toggles-flow POM_NAME=Toggles Flow -VERSION_NAME=0.0.1-SNAPSHOT +VERSION_NAME=0.0.2-SNAPSHOT diff --git a/toggles-prefs/build.gradle.kts b/toggles-prefs/build.gradle.kts index a12013a7..392c009d 100644 --- a/toggles-prefs/build.gradle.kts +++ b/toggles-prefs/build.gradle.kts @@ -42,10 +42,6 @@ kotlin { explicitApi() } -repositories { - maven("https://s01.oss.sonatype.org/content/repositories/snapshots") -} - dependencies { testImplementation("junit:junit:4.13.2") @@ -56,8 +52,8 @@ dependencies { testImplementation("androidx.test.ext:junit:1.1.2") testImplementation("org.robolectric:robolectric:4.5.1") - //implementation("se.eelde.toggles:toggles-core:0.0.1") - implementation("se.eelde.toggles:toggles-core:0.0.2-SNAPSHOT") + implementation("se.eelde.toggles:toggles-core:0.0.2") + //implementation("se.eelde.toggles:toggles-core:0.0.2-SNAPSHOT") //implementation(project(":toggles-core")) implementation("androidx.annotation:annotation:1.2.0") } diff --git a/toggles-prefs/gradle.properties b/toggles-prefs/gradle.properties index 14c81c6c..917f332f 100644 --- a/toggles-prefs/gradle.properties +++ b/toggles-prefs/gradle.properties @@ -1,3 +1,3 @@ POM_ARTIFACT_ID=toggles-prefs POM_NAME=Toggles Prefs -VERSION_NAME=0.0.1-SNAPSHOT +VERSION_NAME=0.0.2-SNAPSHOT diff --git a/toggles-sample/build.gradle.kts b/toggles-sample/build.gradle.kts index f5e3c8de..30faaffd 100644 --- a/toggles-sample/build.gradle.kts +++ b/toggles-sample/build.gradle.kts @@ -90,10 +90,10 @@ dependencies { implementation("androidx.navigation:navigation-fragment-ktx:2.3.5") implementation("androidx.navigation:navigation-ui-ktx:2.3.5") - implementation(project(":toggles-prefs")) - implementation(project(":toggles-flow")) -// implementation("se.eelde.toggles:toggles-flow:0.0.1-SNAPSHOT") -// implementation("se.eelde.toggles:toggles-prefs:0.0.1-SNAPSHOT") +// implementation(project(":toggles-prefs")) +// implementation(project(":toggles-flow")) + implementation("se.eelde.toggles:toggles-flow:0.0.1") + implementation("se.eelde.toggles:toggles-prefs:0.0.1") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.3")