Class: Fastlane::Actions::AndroidChangeAppNameRevertAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/android_change_app_name/actions/android_change_app_name_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



104
105
106
# File 'lib/fastlane/plugin/android_change_app_name/actions/android_change_app_name_action.rb', line 104

def self.authors
  ["MaximusMcCann"]
end

.available_optionsObject



116
117
118
119
120
121
122
123
124
125
# File 'lib/fastlane/plugin/android_change_app_name/actions/android_change_app_name_action.rb', line 116

def self.available_options
  [
    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

.descriptionObject



100
101
102
# File 'lib/fastlane/plugin/android_change_app_name/actions/android_change_app_name_action.rb', line 100

def self.description
  "Reverts the manifest's label attribute (appName) from ANDROID_CHANGE_APP_NAME_ORIGINAL_NAME"
end

.detailsObject



112
113
114
# File 'lib/fastlane/plugin/android_change_app_name/actions/android_change_app_name_action.rb', line 112

def self.details
  "Reverts the manifest's label attribute (appName) from ANDROID_CHANGE_APP_NAME_ORIGINAL_NAME"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


127
128
129
# File 'lib/fastlane/plugin/android_change_app_name/actions/android_change_app_name_action.rb', line 127

def self.is_supported?(platform)
  platform == :android
end

.return_valueObject



108
109
110
# File 'lib/fastlane/plugin/android_change_app_name/actions/android_change_app_name_action.rb', line 108

def self.return_value
  # If your method provides a return value, you can describe here what it does
end

.run(params) ⇒ Object



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/fastlane/plugin/android_change_app_name/actions/android_change_app_name_action.rb', line 76

def self.run(params)
  require 'nokogiri'

  oldName = Actions.lane_context[SharedValues::ANDROID_CHANGE_APP_NAME_ORIGINAL_NAME]

  if oldName.to_s.strip.length != 0
    manifest = params[:manifest]
  else
    UI.error("no string for ANDROID_CHANGE_APP_NAME_ORIGINAL_NAME.  Have you run android_change_app_name?")
  end

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

    @doc.css("application").each do |response_node|
      response_node["android:label"] = oldName
      UI.message("Reverting app name to: #{oldName}")
    end

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

end