fastlane-plugin-appicon 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b4b82cd988af7cef9a984891a69708036a160597
4
- data.tar.gz: 526865efa72ac309b5613317f4e6e25f020346b9
3
+ metadata.gz: 9c81b3d62370dcc4305dc4721b91cdd233d22ff3
4
+ data.tar.gz: 5f93afda98b4baaba126ecc681311920eeed78a6
5
5
  SHA512:
6
- metadata.gz: d73209e211816df166ab322cea5d6e0befba6092d068ed0355d942f86ef4addb546d7b347ceb31b39477384bd228173ede8547964e42376f1724d8ea11ce5704
7
- data.tar.gz: f40f6ed79dd008463cb087384f9c6e4a2b2ac9481e75cc8bf52e7eacdac4c309b044e6691219a9b95038a936435d1caa569d6bc0d4d3952187fbd80485b14dec
6
+ metadata.gz: 27640fe374e76f86f43395a0761637499864b9c36a50331c57056b5ea6af26151b62299a4985b29ed5e21fdfc9fab3a1da0ce886ee927a529ab258e3fc45cede
7
+ data.tar.gz: f39e11cb6a8169eed4475bce75a5e8c72281da5a13d312d58ff78aa2f7fbff93f50c81bf5d52667ea1b1c14ace13574199d53ce6215b6b897ea8aac4c49cfe0e
@@ -15,9 +15,25 @@ module Fastlane
15
15
  }
16
16
  }
17
17
  end
18
+
19
+ def self.notification_icons(path, filename)
20
+ return {} if !path || !filename
21
+
22
+ {
23
+ "#{path}-ldpi/#{filename}" => '36x36',
24
+ "#{path}-mdpi/#{filename}" => '24x24',
25
+ "#{path}-hdpi/#{filename}" => '36x36',
26
+ "#{path}-xhdpi/#{filename}" => '48x48',
27
+ "#{path}-xxhdpi/#{filename}" => '72x72',
28
+ "#{path}-xxxhdpi/#{filename}" => '96x96',
29
+ }
30
+ end
18
31
 
19
32
  def self.run(params)
20
33
  fname = params[:appicon_image_file]
34
+ notification_icon_path = params[:appicon_notification_icon_path]
35
+ notification_icon_filename = params[:appicon_notification_icon_filename]
36
+ custom_sizes = params[:appicon_custom_sizes]
21
37
 
22
38
  require 'mini_magick'
23
39
  image = MiniMagick::Image.open(fname)
@@ -26,15 +42,24 @@ module Fastlane
26
42
 
27
43
  # Convert image to png
28
44
  image.format 'png'
45
+
46
+ # Merge notification icons into customer sizes as they are handled thes same way
47
+ custom_sizes = self.notification_icons(notification_icon_path, notification_icon_filename).merge(custom_sizes)
29
48
 
30
- icons = Helper::AppiconHelper.get_needed_icons(params[:appicon_devices], self.needed_icons, true)
49
+ icons = Helper::AppiconHelper.get_needed_icons(params[:appicon_devices], self.needed_icons, true, custom_sizes)
31
50
  icons.each do |icon|
32
51
  width = icon['width']
33
52
  height = icon['height']
34
53
 
35
- basepath = Pathname.new("#{params[:appicon_path]}-#{icon['scale']}")
54
+ # Custom icons will have basepath and filename already defined
55
+ if icon.has_key?('basepath') && icon.has_key?('filename')
56
+ basepath = Pathname.new(icon['basepath'])
57
+ filename = icon['filename']
58
+ else
59
+ basepath = Pathname.new("#{params[:appicon_path]}-#{icon['scale']}")
60
+ filename = "#{params[:appicon_filename]}.png"
61
+ end
36
62
  FileUtils.mkdir_p(basepath)
37
- filename = "#{params[:appicon_filename]}.png"
38
63
 
39
64
  image.resize "#{width}x#{height}"
40
65
  image.write basepath + filename
@@ -42,6 +67,10 @@ module Fastlane
42
67
 
43
68
  UI.success("Successfully stored launcher icons at '#{params[:appicon_path]}'")
44
69
  end
70
+
71
+ def self.get_custom_sizes(image, custom_sizes)
72
+
73
+ end
45
74
 
46
75
  def self.description
47
76
  "Generate required icon sizes from a master application icon"
@@ -75,7 +104,23 @@ module Fastlane
75
104
  default_value: 'ic_launcher',
76
105
  description: "The output filename of each image",
77
106
  optional: true,
78
- type: String)
107
+ type: String),
108
+ FastlaneCore::ConfigItem.new(key: :appicon_notification_icon_path,
109
+ env_name: "APPICON_NOTIFICATION_ICON_PATH",
110
+ default_value: 'app/res/drawable/',
111
+ description: "Path to res subfolder",
112
+ optional: true,
113
+ type: String),
114
+ FastlaneCore::ConfigItem.new(key: :appicon_notification_icon_filename,
115
+ env_name: "APPICON_NOTIFICATION_ICON_FILENAME",
116
+ default_value: 'ic_stat_onesignal_default',
117
+ description: "File name for notification icons",
118
+ optional: true,
119
+ type: String),
120
+ FastlaneCore::ConfigItem.new(key: :appicon_custom_sizes,
121
+ description: "Hash of custom sizes - {'path/icon.png' => '256x256'}",
122
+ optional: true,
123
+ type: Hash)
79
124
  ]
80
125
  end
81
126
 
@@ -37,6 +37,11 @@ module Fastlane
37
37
  # Convert image to png
38
38
  image.format 'png'
39
39
 
40
+ # remove alpha channel
41
+ if params[:remove_alpha]
42
+ image.alpha 'remove'
43
+ end
44
+
40
45
  # Create the base path
41
46
  FileUtils.mkdir_p(basepath)
42
47
 
@@ -116,7 +121,13 @@ module Fastlane
116
121
  default_value: 'AppIcon.appiconset',
117
122
  description: "Name of the appiconset inside the asset catalogue",
118
123
  optional: true,
119
- type: String)
124
+ type: String),
125
+ FastlaneCore::ConfigItem.new(key: :remove_alpha,
126
+ env_name: "REMOVE_ALPHA",
127
+ default_value: false,
128
+ description: "Remove the alpha channel from generated PNG",
129
+ optional: true,
130
+ type: Boolean)
120
131
  ]
121
132
  end
122
133
 
@@ -7,7 +7,7 @@ module Fastlane
7
7
  UI.user_error!("Input image should be square") if image.width != image.height
8
8
  end
9
9
 
10
- def self.get_needed_icons(devices, needed_icons, is_android = false)
10
+ def self.get_needed_icons(devices, needed_icons, is_android = false, custom_sizes = {})
11
11
  icons = []
12
12
  devices.each do |device|
13
13
  needed_icons[device].each do |scale, sizes|
@@ -35,6 +35,21 @@ module Fastlane
35
35
  end
36
36
  end
37
37
  end
38
+
39
+ # Add custom icon sizes (probably for notifications)
40
+ custom_sizes.each do |path, size|
41
+ path = path.to_s
42
+ width, height = size.split('x').map { |v| v.to_f }
43
+
44
+ icons << {
45
+ 'width' => width,
46
+ 'height' => height,
47
+ 'size' => size,
48
+ 'basepath' => File.dirname(path),
49
+ 'filename' => File.basename(path)
50
+ }
51
+ end
52
+
38
53
  # Sort from the largest to the smallest needed icon
39
54
  icons = icons.sort_by {|value| value['width']} .reverse
40
55
  end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Appicon
3
- VERSION = "0.10.0"
3
+ VERSION = "0.11.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-appicon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Boris Bügling
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-25 00:00:00.000000000 Z
11
+ date: 2018-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mini_magick
@@ -155,9 +155,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
155
  version: '0'
156
156
  requirements: []
157
157
  rubyforge_project:
158
- rubygems_version: 2.6.10
158
+ rubygems_version: 2.6.8
159
159
  signing_key:
160
160
  specification_version: 4
161
161
  summary: Generate required icon sizes and iconset from a master application icon.
162
162
  test_files: []
163
- has_rdoc: