From 03cabd324806588e6f69632ebaedf0c8da4ff57c Mon Sep 17 00:00:00 2001 From: Phillip Thelen Date: Thu, 30 Jun 2022 11:19:41 +0200 Subject: [PATCH] pull version name and code from special properties file --- Gemfile.lock | 4 ++ Habitica/build.gradle | 7 ++- Habitica/proguard-rules.pro | 2 + .../habitica/ui/activities/LoginActivity.kt | 5 +- build.gradle | 21 ++++++- common/proguard-rules.pro | 3 +- fastlane/Pluginfile | 1 + version.properties | 2 + wearos/build.gradle | 60 ++++++++++++++++++- wearos/proguard-rules.pro | 5 +- 10 files changed, 102 insertions(+), 8 deletions(-) create mode 100644 version.properties diff --git a/Gemfile.lock b/Gemfile.lock index 4e1223154..7ad7fbb7d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -81,6 +81,8 @@ GEM xcodeproj (>= 1.13.0, < 2.0.0) xcpretty (~> 0.3.0) xcpretty-travis-formatter (>= 0.0.3) + fastlane-plugin-properties (1.1.2) + java-properties fastlane-plugin-semantic_release (1.14.1) fastlane-plugin-versioning_android (0.1.0) gh_inspector (1.1.3) @@ -116,6 +118,7 @@ GEM http-cookie (1.0.3) domain_name (~> 0.5) httpclient (2.8.3) + java-properties (0.3.0) jmespath (1.4.0) json (2.3.0) jwt (2.1.0) @@ -176,6 +179,7 @@ PLATFORMS DEPENDENCIES fastlane + fastlane-plugin-properties fastlane-plugin-semantic_release fastlane-plugin-versioning_android diff --git a/Habitica/build.gradle b/Habitica/build.gradle index d4baccca6..93ac09aa7 100644 --- a/Habitica/build.gradle +++ b/Habitica/build.gradle @@ -48,7 +48,7 @@ dependencies { implementation "androidx.preference:preference-ktx:$preferences_version" //Desugaring - coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5' + coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.6' implementation('com.jaredrummler:android-device-names:2.1.0') @@ -115,7 +115,7 @@ dependencies { implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version" - coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5' + coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.6' implementation 'com.willowtreeapps:signinwithapplebutton:0.3' @@ -150,6 +150,9 @@ android { buildConfigField "String", "TESTING_LEVEL", "\"production\"" resConfigs 'en', 'bg', 'de', 'en-rGB', 'es', 'fr', 'hr-rHR', 'in', 'it', 'iw', 'ja', 'ko', 'lt', 'nl', 'pl', 'pt-rBR', 'pt-rPT', 'ru', 'tr', 'zh', 'zh-rTW' + println app_version_code + println app_version_name + versionCode app_version_code versionName app_version_name diff --git a/Habitica/proguard-rules.pro b/Habitica/proguard-rules.pro index c6aea91eb..15e1ba3a7 100644 --- a/Habitica/proguard-rules.pro +++ b/Habitica/proguard-rules.pro @@ -65,6 +65,8 @@ #keep Habitica code -keep class com.habitrpg.android.habitica.** { *; } +-keep class com.habitrpg.common.habitica.** { *; } +-keep class com.habitrpg.shared.habitica.** { *; } #realm -keep class io.realm.annotations.RealmModule diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/activities/LoginActivity.kt b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/activities/LoginActivity.kt index 65a574e0d..07eb547b2 100644 --- a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/activities/LoginActivity.kt +++ b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/activities/LoginActivity.kt @@ -15,6 +15,7 @@ import android.text.InputType import android.text.SpannableString import android.text.method.LinkMovementMethod import android.text.style.UnderlineSpan +import android.util.Log import android.view.MenuItem import android.view.View import android.view.Window @@ -36,11 +37,11 @@ import com.habitrpg.android.habitica.extensions.updateStatusBarColor import com.habitrpg.android.habitica.helpers.AmplitudeManager import com.habitrpg.android.habitica.helpers.AppConfigManager import com.habitrpg.android.habitica.helpers.RxErrorHandler -import com.habitrpg.common.habitica.models.auth.UserAuthResponse import com.habitrpg.android.habitica.models.user.User import com.habitrpg.android.habitica.ui.helpers.dismissKeyboard import com.habitrpg.android.habitica.ui.viewmodels.AuthenticationViewModel import com.habitrpg.android.habitica.ui.views.dialogs.HabiticaAlertDialog +import com.habitrpg.common.habitica.models.auth.UserAuthResponse import javax.inject.Inject class LoginActivity : BaseActivity() { @@ -88,11 +89,13 @@ class LoginActivity : BaseActivity() { showValidationError(R.string.login_validation_error_fieldsmissing) return@OnClickListener } + Log.d("LoginActivity", ": $username, $password") apiClient.connectUser(username, password).subscribe( { handleAuthResponse(it) }, { hideProgress() RxErrorHandler.reportError(it) + Log.d("LoginActivity", ": ${it.message}", it) } ) } diff --git a/build.gradle b/build.gradle index 72f158e37..3f48048c6 100644 --- a/build.gradle +++ b/build.gradle @@ -33,8 +33,8 @@ buildscript { dependencies { classpath 'com.android.tools.build:gradle:7.1.3' classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' - classpath 'com.google.gms:google-services:4.3.10' - classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.0' + classpath 'com.google.gms:google-services:4.3.13' + classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.1' classpath "io.realm:realm-gradle-plugin:10.10.1" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.19.0" @@ -53,6 +53,23 @@ allprojects { } } +Properties props = new Properties() +def propFile = new File('version.properties') +if (propFile.canRead()) { + props.load(new FileInputStream(propFile)) + + if (props != null && props.containsKey('NAME') && props.containsKey('CODE') ) { + ext.app_version_name = props['NAME'] + ext.app_version_code = props['CODE'] as Integer + } else { + println 'signing.properties found but some entries are missing' + android.buildTypes.release.signingConfig = null + } +} else { + println 'signing.properties not found' + android.buildTypes.release.signingConfig = null +} + detekt { source = files("Habitica/src/main/java") config = files("detekt.yml") diff --git a/common/proguard-rules.pro b/common/proguard-rules.pro index 481bb4348..c8477a1ad 100644 --- a/common/proguard-rules.pro +++ b/common/proguard-rules.pro @@ -18,4 +18,5 @@ # If you keep the line number information, uncomment this to # hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file +#-renamesourcefileattribute SourceFile +-keep class com.habitrpg.common.habitica.** { *; } diff --git a/fastlane/Pluginfile b/fastlane/Pluginfile index 5c0f5d89f..e07588c84 100644 --- a/fastlane/Pluginfile +++ b/fastlane/Pluginfile @@ -4,3 +4,4 @@ gem 'fastlane-plugin-versioning_android' gem 'fastlane-plugin-semantic_release' +gem 'fastlane-plugin-properties' diff --git a/version.properties b/version.properties new file mode 100644 index 000000000..c7da5e74c --- /dev/null +++ b/version.properties @@ -0,0 +1,2 @@ +NAME=4.0 +CODE=4040 \ No newline at end of file diff --git a/wearos/build.gradle b/wearos/build.gradle index b4fd08bc1..b54f9b232 100644 --- a/wearos/build.gradle +++ b/wearos/build.gradle @@ -15,7 +15,7 @@ android { targetSdk target_sdk versionCode app_version_code + 1 versionName app_version_name - + buildConfigField "String", "TESTING_LEVEL", "\"production\"" } buildTypes { @@ -33,6 +33,44 @@ android { resValue "string", "app_name", "Habitica" } } + + signingConfigs { + release + } + flavorDimensions "buildType" + + productFlavors { + dev { + dimension "buildType" + } + + staff { + dimension "buildType" + buildConfigField "String", "TESTING_LEVEL", "\"staff\"" + resValue "string", "app_name", "Habitica Staff" + versionCode app_version_code + 7 + } + + alpha { + dimension "buildType" + buildConfigField "String", "TESTING_LEVEL", "\"alpha\"" + resValue "string", "app_name", "Habitica Alpha" + versionCode app_version_code + 5 + } + + beta { + buildConfigField "String", "TESTING_LEVEL", "\"beta\"" + dimension "buildType" + versionCode app_version_code + 3 + } + + prod { + buildConfigField "String", "TESTING_LEVEL", "\"production\"" + dimension "buildType" + versionCode app_version_code + 1 + } + } + buildFeatures { viewBinding true } @@ -102,4 +140,24 @@ if (HRPG_PROPS_FILE.canRead()) { } } else { throw new MissingResourceException('habitica.properties not found') +} + +Properties props = new Properties() +def propFile = new File('signingrelease.properties') +if (propFile.canRead()) { + props.load(new FileInputStream(propFile)) + + if (props != null && props.containsKey('STORE_FILE') && props.containsKey('STORE_PASSWORD') && + props.containsKey('KEY_ALIAS') && props.containsKey('KEY_PASSWORD')) { + android.signingConfigs.release.storeFile = file(props['STORE_FILE']) + android.signingConfigs.release.storePassword = props['STORE_PASSWORD'] + android.signingConfigs.release.keyAlias = props['KEY_ALIAS'] + android.signingConfigs.release.keyPassword = props['KEY_PASSWORD'] + } else { + println 'signing.properties found but some entries are missing' + android.buildTypes.release.signingConfig = null + } +} else { + println 'signing.properties not found' + android.buildTypes.release.signingConfig = null } \ No newline at end of file diff --git a/wearos/proguard-rules.pro b/wearos/proguard-rules.pro index 481bb4348..4cc78faa5 100644 --- a/wearos/proguard-rules.pro +++ b/wearos/proguard-rules.pro @@ -18,4 +18,7 @@ # If you keep the line number information, uncomment this to # hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file +#-renamesourcefileattribute SourceFile +-keep class com.habitrpg.wearos.habitica.** { *; } +-keep class com.habitrpg.common.habitica.** { *; } +-keep class com.habitrpg.shared.habitica.** { *; } \ No newline at end of file