1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-03 17:02:13 +01:00

Move build variant-specific strings from build.gradle to separate resource files

This commit is contained in:
MrYoranimo 2024-02-05 18:19:15 +01:00 committed by José Rebelo
parent c1f2f5bb4b
commit fa1f99642a
6 changed files with 59 additions and 53 deletions

View File

@ -67,7 +67,7 @@ def getGitHashShort = { ->
standardOutput = stdout standardOutput = stdout
} }
return stdout.toString().trim() return stdout.toString().trim()
} catch (ignored){ } catch (ignored) {
return null return null
} }
} }
@ -84,9 +84,10 @@ android {
defaultConfig { defaultConfig {
applicationId "nodomain.freeyourgadget.gadgetbridge" applicationId "nodomain.freeyourgadget.gadgetbridge"
minSdkVersion 21 //noinspection OldTargetApi
targetSdkVersion 33 targetSdkVersion 33
compileSdk 33 compileSdk 33
minSdkVersion 21
// Note: always bump BOTH versionCode and versionName! // Note: always bump BOTH versionCode and versionName!
versionName "0.79.0" versionName "0.79.0"
@ -94,13 +95,8 @@ android {
vectorDrawables.useSupportLibrary = true vectorDrawables.useSupportLibrary = true
buildConfigField "String", "GIT_HASH_SHORT", "\"${getGitHashShort()}\"" buildConfigField "String", "GIT_HASH_SHORT", "\"${getGitHashShort()}\""
buildConfigField "boolean", "INTERNET_ACCESS", "false" buildConfigField "boolean", "INTERNET_ACCESS", "false"
resValue "string", "pebble_content_provider", "com.getpebble.android.provider"
resValue "string", "app_name", "@string/application_name_generic"
resValue "string", "title_activity_controlcenter", "@string/title_activity_controlcenter_generic"
resValue "string", "about_activity_title", "@string/about_activity_title_generic"
resValue "string", "about_description", "@string/about_description_generic"
resValue "string", "gadgetbridge_running", "@string/gadgetbridge_running_generic"
} }
signingConfigs { signingConfigs {
nightly { nightly {
if (System.getProperty("nightly_store_file") != null) { if (System.getProperty("nightly_store_file") != null) {
@ -122,19 +118,13 @@ android {
//applicationIdSuffix "" //applicationIdSuffix ""
//versionNameSuffix "" //versionNameSuffix ""
} }
banglejs { banglejs {
dimension "device_type" dimension "device_type"
applicationId "com.espruino.gadgetbridge" applicationId "com.espruino.gadgetbridge"
applicationIdSuffix ".banglejs" applicationIdSuffix ".banglejs"
versionNameSuffix "-banglejs" versionNameSuffix "-banglejs"
buildConfigField "boolean", "INTERNET_ACCESS", "true" buildConfigField "boolean", "INTERNET_ACCESS", "true"
// Disable pebble provider to allow Bangle.js Gadgetbridge to coexist with Gadgetbridge
resValue "string", "pebble_content_provider", "com.getpebble.android.nopebble.bangle.provider"
resValue "string", "app_name", "@string/application_name_banglejs_main"
resValue "string", "title_activity_controlcenter", "@string/title_activity_controlcenter_banglejs_main"
resValue "string", "about_activity_title", "@string/about_activity_title_banglejs_main"
resValue "string", "about_description", "@string/about_description_banglejs_main"
resValue "string", "gadgetbridge_running", "@string/gadgetbridge_running_banglejs_main"
targetSdkVersion 33 targetSdkVersion 33
// Note: app/src/banglejs/AndroidManifest.xml contains some extra permissions // Note: app/src/banglejs/AndroidManifest.xml contains some extra permissions
} }
@ -150,62 +140,34 @@ android {
release { release {
minifyEnabled true minifyEnabled true
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
resValue "string", "pebble_content_provider", "com.getpebble.android.provider"
} }
nightly { nightly {
applicationIdSuffix ".nightly" applicationIdSuffix ".nightly"
versionNameSuffix "-${getGitHashShort}" versionNameSuffix "-${getGitHashShort}"
minifyEnabled true
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
resValue "string", "pebble_content_provider", "com.getpebble.android.provider" minifyEnabled true
resValue "string", "app_name", "@string/application_name_main_nightly"
resValue "string", "title_activity_controlcenter", "@string/title_activity_controlcenter_main_nightly"
resValue "string", "about_activity_title", "@string/about_activity_title_main_nightly"
resValue "string", "about_description", "@string/about_description_main_nightly"
resValue "string", "gadgetbridge_running", "@string/gadgetbridge_running_main_nightly"
debuggable true debuggable true
if (System.getProperty("nightly_store_file") != null) { if (System.getProperty("nightly_store_file") != null) {
signingConfig signingConfigs.nightly signingConfig signingConfigs.nightly
//this was conflicting with regular debug type (it should not), so it is only available for CI builds:
productFlavors.mainline.resValue "string", "pebble_content_provider", "com.getpebble.android.provider"
productFlavors.mainline.resValue "string", "app_name", "@string/application_name_main_nightly"
productFlavors.mainline.resValue "string", "title_activity_controlcenter", "@string/title_activity_controlcenter_main_nightly"
productFlavors.mainline.resValue "string", "about_activity_title", "@string/about_activity_title_main_nightly"
productFlavors.mainline.resValue "string", "about_description", "@string/about_description_main_nightly"
productFlavors.mainline.resValue "string", "gadgetbridge_running", "@string/gadgetbridge_running_main_nightly"
//keep the pebble provider for people who want this. In case of need we can create Banglejs Nopebble
productFlavors.banglejs.resValue "string", "pebble_content_provider", "com.getpebble.android.provider"
productFlavors.banglejs.resValue "string", "app_name", "@string/application_name_banglejs_nightly"
productFlavors.banglejs.resValue "string", "title_activity_controlcenter", "@string/title_activity_controlcenter_banglejs_nightly"
productFlavors.banglejs.resValue "string", "about_activity_title", "@string/about_activity_title_banglejs_nightly"
productFlavors.banglejs.resValue "string", "about_description", "@string/about_description_banglejs_nightly"
productFlavors.banglejs.resValue "string", "gadgetbridge_running", "@string/gadgetbridge_running_banglejs_nightly"
} else { } else {
signingConfig signingConfigs.debug signingConfig signingConfigs.debug
} }
} }
nopebble { nopebble {
applicationIdSuffix ".nightly_nopebble" applicationIdSuffix ".nightly_nopebble"
versionNameSuffix "-${getGitHashShort}" versionNameSuffix "-${getGitHashShort}"
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
minifyEnabled true minifyEnabled true
debuggable true
if (System.getProperty("nightly_store_file") != null) { if (System.getProperty("nightly_store_file") != null) {
signingConfig signingConfigs.nightly signingConfig signingConfigs.nightly
} else { } else {
signingConfig signingConfigs.debug signingConfig signingConfigs.debug
} }
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
resValue "string", "pebble_content_provider", "com.getpebble.android.nopebble.provider"
resValue "string", "app_name", "@string/application_name_main_nopebble"
resValue "string", "title_activity_controlcenter", "@string/title_activity_controlcenter_main_nopebble"
resValue "string", "about_activity_title", "@string/about_activity_title_main_nopebble"
resValue "string", "about_description", "@string/about_description_main_nopebble"
resValue "string", "gadgetbridge_running", "@string/gadgetbridge_running_main_nopebble"
debuggable true
} }
applicationVariants.all { variant -> applicationVariants.all { variant ->
@ -221,7 +183,6 @@ android {
} }
} }
} }
} }
lint { lint {
@ -367,8 +328,8 @@ task pmd(type: Pmd) {
sourceSets { sourceSets {
main { main {
main.java.srcDirs += "${protobuf.generatedFilesBaseDir}" java.srcDirs += "${protobuf.generatedFilesBaseDir}"
main.java.srcDirs += "build/generated/source/buildConfig" java.srcDirs += "build/generated/source/buildConfig"
} }
} }
@ -387,10 +348,10 @@ tasks.withType(SpotBugsTask) {
xml.enabled = false xml.enabled = false
html.enabled = true html.enabled = true
xml { xml {
destination file ("$project.buildDir/reports/spotbugs/spotbugs-output.xml") destination file("$project.buildDir/reports/spotbugs/spotbugs-output.xml")
} }
html { html {
destination file ("$project.buildDir/reports/spotbugs/spotbugs-output.html") destination file("$project.buildDir/reports/spotbugs/spotbugs-output.html")
} }
} }
} }

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string translatable="false" name="pebble_content_provider">com.getpebble.android.nopebble.bangle.provider</string>
<string translatable="false" name="app_name">@string/application_name_banglejs_main</string>
<string translatable="false" name="title_activity_controlcenter">@string/title_activity_controlcenter_banglejs_main</string>
<string translatable="false" name="about_activity_title">@string/about_activity_title_banglejs_main</string>
<string translatable="false" name="about_description">@string/about_description_banglejs_main</string>
<string translatable="false" name="gadgetbridge_running">@string/gadgetbridge_running_banglejs_main</string>
</resources>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- enable Pebble content provider for Bangle.js nightly, so can that it can be installed besides regular Bangle.js release -->
<string translatable="false" name="pebble_content_provider">com.getpebble.android.provider</string>
<string translatable="false" name="app_name">@string/application_name_banglejs_nightly</string>
<string translatable="false" name="title_activity_controlcenter">@string/title_activity_controlcenter_banglejs_nightly</string>
<string translatable="false" name="about_activity_title">@string/about_activity_title_banglejs_nightly</string>
<string translatable="false" name="about_description">@string/about_description_banglejs_nightly</string>
<string translatable="false" name="gadgetbridge_running">@string/gadgetbridge_running_banglejs_nightly</string>
</resources>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string translatable="false" name="pebble_content_provider">com.getpebble.android.provider</string>
<string translatable="false" name="app_name">@string/application_name_generic</string>
<string translatable="false" name="title_activity_controlcenter">@string/title_activity_controlcenter_generic</string>
<string translatable="false" name="about_activity_title">@string/about_activity_title_generic</string>
<string translatable="false" name="about_description">@string/about_description_generic</string>
<string translatable="false" name="gadgetbridge_running">@string/gadgetbridge_running_generic</string>
</resources>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" ?>
<resources>
<string translatable="false" name="app_name">@string/application_name_main_nightly</string>
<string translatable="false" name="title_activity_controlcenter">@string/title_activity_controlcenter_main_nightly</string>
<string translatable="false" name="about_activity_title">@string/about_activity_title_main_nightly</string>
<string translatable="false" name="about_description">@string/about_description_main_nightly</string>
<string translatable="false" name="gadgetbridge_running">@string/gadgetbridge_running_main_nightly</string>
</resources>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string translatable="false" name="pebble_content_provider">com.getpebble.android.nopebble.provider</string>
<string translatable="false" name="app_name">@string/application_name_main_nopebble</string>
<string translatable="false" name="title_activity_controlcenter">@string/title_activity_controlcenter_main_nopebble</string>
<string translatable="false" name="about_activity_title">@string/about_activity_title_main_nopebble</string>
<string translatable="false" name="about_description">@string/about_description_main_nopebble</string>
<string translatable="false" name="gadgetbridge_running">@string/gadgetbridge_running_main_nopebble</string>
</resources>