From 7158847b6b4c0aa3851553b1cd95e168ace70e8c Mon Sep 17 00:00:00 2001 From: Lukasz Kozakiewicz Date: Fri, 16 Feb 2018 17:46:57 +0100 Subject: [PATCH] Projucer: allow to customise remote notifications config file per build configuration. --- .../jucer_ProjectExport_Android.h | 29 ++++++++++++++----- .../Source/Utility/Helpers/jucer_PresetIDs.h | 1 + 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Android.h b/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Android.h index e55ed133ce..e2c1beab20 100644 --- a/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Android.h +++ b/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Android.h @@ -314,6 +314,7 @@ protected: AndroidBuildConfiguration (Project& p, const ValueTree& settings, const ProjectExporter& e) : BuildConfiguration (p, settings, e), androidArchitectures (config, Ids::androidArchitectures, getUndoManager(), isDebug() ? "armeabi x86" : ""), + androidBuildConfigRemoteNotifsConfigFile (config, Ids::androidBuildConfigRemoteNotifsConfigFile, getUndoManager()), androidAdditionalXmlValueResources (config, Ids::androidAdditionalXmlValueResources, getUndoManager()), androidAdditionalRawValueResources (config, Ids::androidAdditionalRawValueResources, getUndoManager()), androidCustomStringXmlElements (config, Ids::androidCustomStringXmlElements, getUndoManager()) @@ -323,6 +324,7 @@ protected: } String getArchitectures() const { return androidArchitectures.get().toString(); } + String getRemoteNotifsConfigFile() const { return androidBuildConfigRemoteNotifsConfigFile.get().toString(); } String getAdditionalXmlResources() const { return androidAdditionalXmlValueResources.get().toString(); } String getAdditionalRawResources() const { return androidAdditionalRawValueResources.get().toString();} String getCustomStringsXml() const { return androidCustomStringXmlElements.get().toString(); } @@ -334,6 +336,10 @@ protected: props.add (new TextPropertyComponent (androidArchitectures, "Architectures", 256, false), "A list of the ARM architectures to build (for a fat binary). Leave empty to build for all possible android archiftectures."); + props.add (new TextPropertyComponent (androidBuildConfigRemoteNotifsConfigFile.getPropertyAsValue(), "Remote Notifications Config File", 2048, false), + "Path to google-services.json file. This will be the file provided by Firebase when creating a new app in Firebase console. " + "This will override the setting from the main Android exporter node."); + props.add (new TextPropertyComponent (androidAdditionalXmlValueResources, "Extra Android XML Value Resources", 2048, true), "Paths to additional \"value resource\" files in XML format that should be included in the app (one per line). " "If you have additional XML resources that should be treated as value resources, add them here."); @@ -363,7 +369,8 @@ protected: return "${ANDROID_ABI}"; } - ValueWithDefault androidArchitectures, androidAdditionalXmlValueResources, androidAdditionalRawValueResources, + ValueWithDefault androidArchitectures, androidBuildConfigRemoteNotifsConfigFile, + androidAdditionalXmlValueResources, androidAdditionalRawValueResources, androidCustomStringXmlElements; }; @@ -1192,20 +1199,26 @@ private: for (ConstConfigIterator config (*this); config.next();) { auto& cfg = dynamic_cast (*config); + String cfgPath = cfg.isDebug() ? "app/src/debug" : "app/src/release"; String xmlValuesPath = cfg.isDebug() ? "app/src/debug/res/values" : "app/src/release/res/values"; String rawPath = cfg.isDebug() ? "app/src/debug/res/raw" : "app/src/release/res/raw"; copyExtraResourceFiles (cfg.getAdditionalXmlResources(), xmlValuesPath); copyExtraResourceFiles (cfg.getAdditionalRawResources(), rawPath); - } - if (androidEnableRemoteNotifications.get()) - { - File file (getProject().getFile().getChildFile (androidRemoteNotificationsConfigFile.get().toString())); - // Settings file must be present for remote notifications to work and it must be called google-services.json. - jassert (file.existsAsFile() && file.getFileName() == "google-services.json"); + if (androidEnableRemoteNotifications.get()) + { + auto remoteNotifsConfigFilePath = cfg.getRemoteNotifsConfigFile(); + + if (remoteNotifsConfigFilePath.isEmpty()) + remoteNotifsConfigFilePath = androidRemoteNotificationsConfigFile.get().toString(); - copyExtraResourceFiles (androidRemoteNotificationsConfigFile.get(), "app"); + File file (getProject().getFile().getChildFile (remoteNotifsConfigFilePath)); + // Settings file must be present for remote notifications to work and it must be called google-services.json. + jassert (file.existsAsFile() && file.getFileName() == "google-services.json"); + + copyExtraResourceFiles (remoteNotifsConfigFilePath, cfgPath); + } } } diff --git a/extras/Projucer/Source/Utility/Helpers/jucer_PresetIDs.h b/extras/Projucer/Source/Utility/Helpers/jucer_PresetIDs.h index 5799f703f7..4b8d8d258d 100644 --- a/extras/Projucer/Source/Utility/Helpers/jucer_PresetIDs.h +++ b/extras/Projucer/Source/Utility/Helpers/jucer_PresetIDs.h @@ -181,6 +181,7 @@ namespace Ids DECLARE_ID (androidJavaLibs); DECLARE_ID (androidRepositories); DECLARE_ID (androidDependencies); + DECLARE_ID (androidBuildConfigRemoteNotifsConfigFile); DECLARE_ID (androidAdditionalXmlValueResources); DECLARE_ID (androidAdditionalRawValueResources); DECLARE_ID (androidActivityClass);