From 18f311512aec7b828c87c3b297135482abd389a2 Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Tue, 21 Jul 2020 14:58:44 -0300 Subject: [wallet] introduce build flavors for distribution channels (google play, fdroid, nightly) and show flavor name in dev settings --- wallet/.gitlab-ci.yml | 14 +---------- wallet/build.gradle | 28 ++++++++++++++++++++++ .../net/taler/wallet/settings/SettingsFragment.kt | 3 ++- wallet/src/nightly/res/values/strings.xml | 19 +++++++++++++++ 4 files changed, 50 insertions(+), 14 deletions(-) create mode 100644 wallet/src/nightly/res/values/strings.xml (limited to 'wallet') diff --git a/wallet/.gitlab-ci.yml b/wallet/.gitlab-ci.yml index 8845aa4..56768f7 100644 --- a/wallet/.gitlab-ci.yml +++ b/wallet/.gitlab-ci.yml @@ -23,20 +23,8 @@ wallet_deploy_nightly: script: # Ensure that key exists - test -z "$DEBUG_KEYSTORE" && exit 0 - # Rename nightly app - - sed -i - 's,.*,Taler Wallet Nightly,' - wallet/src/main/res/values*/strings.xml - # Set time-based version code - - export versionCode=$(date '+%s') - - sed -i "s,^\(\s*versionCode\) *[0-9].*,\1 $versionCode," wallet/build.gradle - # Add commit to version name - - export versionName=$(git rev-parse --short=7 HEAD) - - sed -i "s,^\(\s*versionName\ *\"[0-9].*\)\",\1 ($versionName)\"," wallet/build.gradle - # Set nightly application ID - - sed -i "s,^\(\s*applicationId\) \"*[a-z\.].*\",\1 \"net.taler.wallet.nightly\"," wallet/build.gradle # Build the APK - - ./gradlew :wallet:assembleDebug + - ./gradlew :wallet:assembleNightlyDebug # START only needed while patch not accepted/released upstream - apt update && apt install patch - patch -b /usr/lib/python3/dist-packages/fdroidserver/nightly.py nightly-stats.patch diff --git a/wallet/build.gradle b/wallet/build.gradle index d93b8b9..5b28c6c 100644 --- a/wallet/build.gradle +++ b/wallet/build.gradle @@ -25,6 +25,18 @@ plugins { def walletCoreVersion = "v0.7.1-dev.10" +static def versionCodeEpoch() { + return (new Date().getTime() / 1000).toInteger() +} +def gitCommit = { -> + def stdout = new ByteArrayOutputStream() + exec { + commandLine 'git', 'rev-parse', '--short=7', 'HEAD' + standardOutput = stdout + } + return stdout.toString().trim() +} + android { compileSdkVersion 29 //noinspection GradleDependency @@ -45,6 +57,22 @@ android { proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } + flavorDimensions "distributionChannel" + productFlavors { + fdroid { + dimension "distributionChannel" + applicationIdSuffix ".fdroid" + } + google { + dimension "distributionChannel" + } + nightly { + dimension "distributionChannel" + applicationIdSuffix ".nightly" + versionCode versionCodeEpoch() + versionNameSuffix " ($gitCommit)" + } + } compileOptions { sourceCompatibility = 1.8 diff --git a/wallet/src/main/java/net/taler/wallet/settings/SettingsFragment.kt b/wallet/src/main/java/net/taler/wallet/settings/SettingsFragment.kt index d9b1def..a52b9d8 100644 --- a/wallet/src/main/java/net/taler/wallet/settings/SettingsFragment.kt +++ b/wallet/src/main/java/net/taler/wallet/settings/SettingsFragment.kt @@ -27,6 +27,7 @@ import androidx.preference.SwitchPreferenceCompat import com.google.android.material.snackbar.BaseTransientBottomBar.LENGTH_SHORT import com.google.android.material.snackbar.Snackbar import net.taler.common.toRelativeTime +import net.taler.wallet.BuildConfig.FLAVOR import net.taler.wallet.BuildConfig.VERSION_CODE import net.taler.wallet.BuildConfig.VERSION_NAME import net.taler.wallet.BuildConfig.WALLET_CORE_VERSION @@ -82,7 +83,7 @@ class SettingsFragment : PreferenceFragmentCompat() { model.devMode.observe(viewLifecycleOwner, Observer { enabled -> prefDevMode.isChecked = enabled if (enabled) { - prefVersionApp.summary = "$VERSION_NAME ($VERSION_CODE)" + prefVersionApp.summary = "$VERSION_NAME ($FLAVOR $VERSION_CODE)" prefVersionCore.summary = WALLET_CORE_VERSION model.exchangeVersion?.let { prefVersionExchange.summary = it } model.merchantVersion?.let { prefVersionMerchant.summary = it } diff --git a/wallet/src/nightly/res/values/strings.xml b/wallet/src/nightly/res/values/strings.xml new file mode 100644 index 0000000..7276d52 --- /dev/null +++ b/wallet/src/nightly/res/values/strings.xml @@ -0,0 +1,19 @@ + + + + Taler Wallet Nightly + -- cgit v1.2.3