class AndroidStringsSwitcher def initialize end def update(config) Solara.logger.start_step("Generate artifacts/strings.xml") strings_file = FilePath.android_artifacts_strings # Create the file if it doesn't exist unless File.exist?(strings_file) FileUtils.mkdir_p(File.dirname(strings_file)) end strings_content = generate_strings_xml_content(config) File.write(strings_file, strings_content) Solara.logger.debug("Updated #{strings_file} with name: \"#{config['brandName']}\"") remove_app_name_from_strings Solara.logger.end_step("Generate artifacts/strings.xml") end # It's important to delete app_name to avoid duplicate resources def remove_app_name_from_strings file_path = FilePath.android_strings manager = StringsXmlManager.new(file_path) manager.delete_app_name end private def generate_strings_xml_content(config) <<-XML #{config['brandName']} XML end end