Class: Fastlane::Actions::AndroidAppiconAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::AndroidAppiconAction
- Defined in:
- lib/fastlane/plugin/appicon/actions/android_appicon_action.rb
Class Method Summary collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .get_custom_sizes(image, custom_sizes) ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .needed_icons ⇒ Object
- .run(params) ⇒ Object
Class Method Details
.authors ⇒ Object
67 68 69 |
# File 'lib/fastlane/plugin/appicon/actions/android_appicon_action.rb', line 67 def self. ["@adrum"] end |
.available_options ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/fastlane/plugin/appicon/actions/android_appicon_action.rb', line 71 def self. [ FastlaneCore::ConfigItem.new(key: :appicon_image_file, env_name: "APPICON_IMAGE_FILE", description: "Path to a square image file, at least 512x512", optional: false, type: String), FastlaneCore::ConfigItem.new(key: :appicon_icon_types, env_name: "APPICON_ICON_TYPES", default_value: [:launcher], description: "Array of device types to generate icons for", optional: true, type: Array), FastlaneCore::ConfigItem.new(key: :appicon_path, env_name: "APPICON_PATH", default_value: 'app/res/mipmap', description: "Path to res subfolder", optional: true, type: String), FastlaneCore::ConfigItem.new(key: :appicon_filename, env_name: "APPICON_FILENAME", default_value: 'ic_launcher', description: "The output filename of each image", optional: true, type: String), FastlaneCore::ConfigItem.new(key: :appicon_custom_sizes, description: "Hash of custom sizes - {'path/icon.png' => '256x256'}", default_value: {}, optional: true, type: Hash) ] end |
.description ⇒ Object
63 64 65 |
# File 'lib/fastlane/plugin/appicon/actions/android_appicon_action.rb', line 63 def self.description "Generate required icon sizes from a master application icon" end |
.get_custom_sizes(image, custom_sizes) ⇒ Object
59 60 61 |
# File 'lib/fastlane/plugin/appicon/actions/android_appicon_action.rb', line 59 def self.get_custom_sizes(image, custom_sizes) end |
.is_supported?(platform) ⇒ Boolean
104 105 106 |
# File 'lib/fastlane/plugin/appicon/actions/android_appicon_action.rb', line 104 def self.is_supported?(platform) [:android].include?(platform) end |
.needed_icons ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/fastlane/plugin/appicon/actions/android_appicon_action.rb', line 4 def self.needed_icons { launcher: { :ldpi => ['36x36'], :mdpi => ['48x48'], :hdpi => ['72x72'], :xhdpi => ['96x96'], :xxhdpi => ['144x144'], :xxxhdpi => ['192x192'] }, notification: { :ldpi => ['18x18'], :mdpi => ['24x24'], :hdpi => ['36x36'], :xhdpi => ['48x48'], :xxhdpi => ['72x72'], :xxxhdpi => ['96x96'], } } end |
.run(params) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/fastlane/plugin/appicon/actions/android_appicon_action.rb', line 25 def self.run(params) fname = params[:appicon_image_file] custom_sizes = params[:appicon_custom_sizes] require 'mini_magick' image = MiniMagick::Image.open(fname) Helper::AppiconHelper.check_input_image_size(image, 512) # Convert image to png image.format 'png' icons = Helper::AppiconHelper.get_needed_icons(params[:appicon_icon_types], self.needed_icons, true, custom_sizes) icons.each do |icon| width = icon['width'] height = icon['height'] # Custom icons will have basepath and filename already defined if icon.has_key?('basepath') && icon.has_key?('filename') basepath = Pathname.new(icon['basepath']) filename = icon['filename'] else basepath = Pathname.new("#{params[:appicon_path]}-#{icon['scale']}") filename = "#{params[:appicon_filename]}.png" end FileUtils.mkdir_p(basepath) image.resize "#{width}x#{height}" image.write basepath + filename end UI.success("Successfully stored launcher icons at '#{params[:appicon_path]}'") end |