Class: Fastlane::Helper::AppiconHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane/plugin/appicon/helper/appicon_helper.rb

Class Method Summary collapse

Class Method Details

.check_input_image_size(image, width, height) ⇒ Object



6
7
8
9
10
# File 'lib/fastlane/plugin/appicon/helper/appicon_helper.rb', line 6

def self.check_input_image_size(image, width, height)
  UI.user_error!("Minimum width of input image should be #{width}") if image.width < width
  UI.user_error!("Minimum height of input image should be #{height}") if image.height < height
  UI.user_error!("Input image should be square") if image.width / image.height != width / height
end

.get_needed_icons(devices, needed_icons, is_android = false, custom_sizes = {}) ⇒ Object



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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/fastlane/plugin/appicon/helper/appicon_helper.rb', line 26

def self.get_needed_icons(devices, needed_icons, is_android = false, custom_sizes = {})
  icons = []
  devices.each do |device|
    needed_icons[device].each do |scale, sizes|
      sizes.each do |size|
        if size.kind_of?(Array)
          size, role, subtype = size
        end

        if is_android
          width, height = size.split('x').map { |v| v.to_f }
        else
          multiple = device.match(/universal/) ? 1 : scale.to_i
          width, height = size.split('x').map { |v| v.to_f * multiple }
        end

        icons << {
          'width' => width,
          'height' => height,
          'size' => size,
          'device' => device.to_s.gsub('_', '-'),
          'scale' => scale,
          'role' => role,
          'subtype' => subtype
        }

      end
    end
  end

  # Add custom icon sizes (probably for notifications)
  custom_sizes.each do |path, size|
    path = path.to_s
    width, height = size.split('x').map { |v| v.to_f }

    icons << {
      'width' => width,
      'height' => height,
      'size' => size,
      'basepath' => File.dirname(path),
      'filename' => File.basename(path)
    }
  end

  # Sort from the largest to the smallest needed icon
  icons = icons.sort_by {|value| value['width']} .reverse
end

.set_cli(minimagick_cli) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/fastlane/plugin/appicon/helper/appicon_helper.rb', line 12

def self.set_cli(minimagick_cli)
  MiniMagick.configure do |config|
    case minimagick_cli
    when "graphicsmagick"
    config.cli = :graphicsmagick
    when "imagemagick"
      config.cli = :imagemagick
    else
      config.cli = MiniMagick.cli()
    end
    config.timeout = 5
  end
end