class Fastlane::Actions::AndroidChangeAppNameAction

Public Class Methods

authors() click to toggle source
# File lib/fastlane/plugin/android_change_app_name/actions/android_change_app_name_action.rb, line 36
def self.authors
  ["MaximusMcCann"]
end
available_options() click to toggle source
# File lib/fastlane/plugin/android_change_app_name/actions/android_change_app_name_action.rb, line 48
def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :newName,
                            env_name: "",
                         description: "The new name for the app",
                            optional: true,
                                type: String),
    FastlaneCore::ConfigItem.new(key: :manifest,
                            env_name: "",
                         description: "Optional custom location for AndroidManifest.xml",
                            optional: false,
                                type: String,
                       default_value: "app/src/main/AndroidManifest.xml")
  ]
end
description() click to toggle source
# File lib/fastlane/plugin/android_change_app_name/actions/android_change_app_name_action.rb, line 32
def self.description
  "Changes the manifest's label attribute (appName).  Stores the original name for revertinng."
end
details() click to toggle source
# File lib/fastlane/plugin/android_change_app_name/actions/android_change_app_name_action.rb, line 44
def self.details
  "Changes the apk manifest file's label attribute (appName).  Stores the original label value for reverting later."
end
is_supported?(platform) click to toggle source
# File lib/fastlane/plugin/android_change_app_name/actions/android_change_app_name_action.rb, line 70
def self.is_supported?(platform)
  platform == :android
end
output() click to toggle source
# File lib/fastlane/plugin/android_change_app_name/actions/android_change_app_name_action.rb, line 64
def self.output
  [
    ['ANDROID_CHANGE_APP_NAME_ORIGINAL_NAME', 'The original app name.']
  ]
end
return_value() click to toggle source
# File lib/fastlane/plugin/android_change_app_name/actions/android_change_app_name_action.rb, line 40
def self.return_value
  # If your method provides a return value, you can describe here what it does
end
run(params) click to toggle source
# File lib/fastlane/plugin/android_change_app_name/actions/android_change_app_name_action.rb, line 7
def self.run(params)
  require 'nokogiri'

  newName = params[:newName]
  manifest = params[:manifest]

  doc = File.open(manifest) { |f|
    @doc = Nokogiri::XML(f)

    originalName = nil

    @doc.css("application").each do |response_node|
      originalName = response_node["android:label"]
      response_node["android:label"] = newName

      UI.message("Updating app name to: #{newName}")
    end

    Actions.lane_context[SharedValues::ANDROID_CHANGE_APP_NAME_ORIGINAL_NAME] = originalName

    File.write(manifest, @doc.to_xml)
  }

end