From af2be913c4b47c2aa1b9ae7ff0e97c3aab404c37 Mon Sep 17 00:00:00 2001 From: Phillip Thelen Date: Fri, 17 Jun 2016 12:43:49 +0200 Subject: [PATCH] move secret strings to gradle config file --- .gitignore | 3 ++- .travis.yml | 1 + Habitica/build.gradle | 19 +++++++++++++++++++ Habitica/res/values/secret_strings.xml | 6 ------ habitica.resources.example | 3 +++ 5 files changed, 25 insertions(+), 7 deletions(-) delete mode 100644 Habitica/res/values/secret_strings.xml create mode 100644 habitica.resources.example diff --git a/.gitignore b/.gitignore index 3d1c0e3e8..6e6e04e44 100644 --- a/.gitignore +++ b/.gitignore @@ -52,4 +52,5 @@ fabric.properties .DS_Store *.iml Habitica/res/values/secret_strings.xml -habitica.properties \ No newline at end of file +habitica.properties +habitica.resources diff --git a/.travis.yml b/.travis.yml index cae09786d..faeed744b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,5 +40,6 @@ android: #- sys-img-x86-android-17 script: - cp habitica.properties.travis habitica.properties + - cp habitica.resources.example habitica.resources - ./gradlew assembleDebug - ./gradlew testDebugUnitTest --info diff --git a/Habitica/build.gradle b/Habitica/build.gradle index 079b2a47e..b7d8f2b1f 100644 --- a/Habitica/build.gradle +++ b/Habitica/build.gradle @@ -240,6 +240,25 @@ if (HRPG_PROPS_FILE.canRead()) { throw new MissingResourceException('habitica.properties not found') } +// Add Habitica Resources to resources +final File HRPG_RES_FILE = new File('habitica.resources') +if (HRPG_RES_FILE.canRead()) { + def Properties HRPG_RES = new Properties() + HRPG_RES.load(new FileInputStream(HRPG_RES_FILE)) + + if (HRPG_RES != null) { + android.buildTypes.all { buildType -> + HRPG_RES.any { property -> + buildType.resValue "string", property.key, "\"${property.value}\"" + } + } + } else { + throw new InvalidUserDataException('habitica.resources found but some entries are missing') + } +} else { + throw new MissingResourceException('habitica.resources not found') +} + tasks.whenTaskAdded { task -> if (task.name.equals("lint")) { task.enabled = false diff --git a/Habitica/res/values/secret_strings.xml b/Habitica/res/values/secret_strings.xml deleted file mode 100644 index d1f8c5e4a..000000000 --- a/Habitica/res/values/secret_strings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - CHANGE_ME - CHANGE_ME - CHANGE_ME - diff --git a/habitica.resources.example b/habitica.resources.example new file mode 100644 index 000000000..989a5322f --- /dev/null +++ b/habitica.resources.example @@ -0,0 +1,3 @@ +fabric_key=CHANGE_ME +facebook_app_id=CHANGE_ME +amplitude_app_id=CHANGE_ME