fastlane-plugin-appicon 0.14.1 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +18 -2
- data/lib/fastlane/plugin/appicon/actions/android_appicon_action.rb +85 -13
- data/lib/fastlane/plugin/appicon/actions/appicon_action.rb +19 -5
- data/lib/fastlane/plugin/appicon/helper/appicon_helper.rb +6 -5
- data/lib/fastlane/plugin/appicon/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bced1c1899f354fefda0cd562c1adfc9ed9dcda60a699ab89e669af56d76dfc7
|
4
|
+
data.tar.gz: cb9889f63c757b3c81334c32ee29e4c6cb7567a5ee762005488deb6a4abe84cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d5440ea9762219b3b382515bd463dacbc83e14be779a1d01b962906cba942302d2dfed6de6d240052ab53f7da194fe19a0f5042b9ba021dda2e9f9ea70baed9
|
7
|
+
data.tar.gz: 8c9be79cb72d748708cdda5c60b3341c2043053a9221665763d2fea5663274e3f88b365262ae51bfd66af62ec415d47769069b90f29b9a59d3ac7ca8f319557e
|
data/README.md
CHANGED
@@ -54,11 +54,20 @@ end
|
|
54
54
|
lane :test3 do
|
55
55
|
# `appicon_image_file` defaults to "fastlane/metadata/app_icon.png"
|
56
56
|
appicon(
|
57
|
-
appicon_devices: [:iphone],
|
57
|
+
appicon_devices: [:iphone],
|
58
58
|
appicon_path: 'wwdcfamily/Images.xcassets' # output path
|
59
59
|
)
|
60
60
|
end
|
61
61
|
|
62
|
+
lane :splash_screen do
|
63
|
+
appicon(
|
64
|
+
appicon_image_file: 'spec/fixtures/splash_screen.png',
|
65
|
+
appicon_devices: [:universal],
|
66
|
+
appicon_path: "ios/App/App/Assets.xcassets",
|
67
|
+
appicon_name: 'Splash.imageset'
|
68
|
+
)
|
69
|
+
end
|
70
|
+
|
62
71
|
# or
|
63
72
|
|
64
73
|
lane :android do
|
@@ -71,7 +80,14 @@ lane :android do
|
|
71
80
|
appicon_image_file: 'spec/fixtures/ThemojiNotification.png',
|
72
81
|
appicon_icon_types: [:notification],
|
73
82
|
appicon_path: 'app/res/drawable',
|
74
|
-
appicon_filename: 'ic_notification'
|
83
|
+
appicon_filename: 'ic_notification',
|
84
|
+
generate_rounded: true
|
85
|
+
)
|
86
|
+
android_appicon(
|
87
|
+
appicon_image_file: 'spec/fixtures/splash_base_image.png',
|
88
|
+
appicon_icon_types: [:splash_port, :splash_land],
|
89
|
+
appicon_path: 'app/res/drawable',
|
90
|
+
appicon_filename: 'splash'
|
75
91
|
)
|
76
92
|
end
|
77
93
|
```
|
@@ -1,6 +1,9 @@
|
|
1
|
+
require 'mini_magick'
|
2
|
+
|
1
3
|
module Fastlane
|
2
4
|
module Actions
|
3
5
|
class AndroidAppiconAction < Action
|
6
|
+
|
4
7
|
def self.needed_icons
|
5
8
|
{
|
6
9
|
launcher: {
|
@@ -18,6 +21,22 @@ module Fastlane
|
|
18
21
|
:xhdpi => ['48x48'],
|
19
22
|
:xxhdpi => ['72x72'],
|
20
23
|
:xxxhdpi => ['96x96'],
|
24
|
+
},
|
25
|
+
splash_land: {
|
26
|
+
'land-ldpi' => ['320x200'],
|
27
|
+
'land-mdpi' => ['480x320'],
|
28
|
+
'land-hdpi' => ['800x480'],
|
29
|
+
'land-xhdpi' => ['1280x720'],
|
30
|
+
'land-xxhdpi' => ['1600x960'],
|
31
|
+
'land-xxxhdpi' => ['1920x1280']
|
32
|
+
},
|
33
|
+
splash_port: {
|
34
|
+
'port-ldpi' => ['200x320'],
|
35
|
+
'port-mdpi' => ['320x480'],
|
36
|
+
'port-hdpi' => ['480x800'],
|
37
|
+
'port-xhdpi' => ['720x1280'],
|
38
|
+
'port-xxhdpi' => ['960x1600'],
|
39
|
+
'port-xxxhdpi' => ['1280x1920']
|
21
40
|
}
|
22
41
|
}
|
23
42
|
end
|
@@ -26,18 +45,11 @@ module Fastlane
|
|
26
45
|
fname = params[:appicon_image_file]
|
27
46
|
custom_sizes = params[:appicon_custom_sizes]
|
28
47
|
|
29
|
-
require 'mini_magick'
|
30
|
-
image = MiniMagick::Image.open(fname)
|
31
|
-
|
32
|
-
Helper::AppiconHelper.check_input_image_size(image, 512)
|
33
|
-
|
34
|
-
# Convert image to png
|
35
|
-
image.format 'png'
|
36
|
-
|
37
48
|
icons = Helper::AppiconHelper.get_needed_icons(params[:appicon_icon_types], self.needed_icons, true, custom_sizes)
|
38
49
|
icons.each do |icon|
|
39
|
-
|
40
|
-
|
50
|
+
image = MiniMagick::Image.open(fname)
|
51
|
+
|
52
|
+
Helper::AppiconHelper.check_input_image_size(image, 1024)
|
41
53
|
|
42
54
|
# Custom icons will have basepath and filename already defined
|
43
55
|
if icon.has_key?('basepath') && icon.has_key?('filename')
|
@@ -47,15 +59,71 @@ module Fastlane
|
|
47
59
|
basepath = Pathname.new("#{params[:appicon_path]}-#{icon['scale']}")
|
48
60
|
filename = "#{params[:appicon_filename]}.png"
|
49
61
|
end
|
50
|
-
FileUtils.mkdir_p(basepath)
|
51
62
|
|
52
|
-
|
63
|
+
width_height = [icon['width'], icon['height']].map(&:to_i)
|
64
|
+
width, height = width_height
|
65
|
+
max = width_height.max
|
66
|
+
|
67
|
+
image.format 'png'
|
68
|
+
image.resize "#{max}x#{max}"
|
69
|
+
|
70
|
+
unless width == height
|
71
|
+
offset =
|
72
|
+
if width > height
|
73
|
+
"+0+#{(width - height) / 2}"
|
74
|
+
elsif height > width
|
75
|
+
"+#{(height - width) / 2}+0"
|
76
|
+
end
|
77
|
+
|
78
|
+
image.crop "#{icon['size']}#{offset}"
|
79
|
+
end
|
80
|
+
|
81
|
+
FileUtils.mkdir_p(basepath)
|
53
82
|
image.write basepath + filename
|
83
|
+
|
84
|
+
if basepath.to_s.match("port-")
|
85
|
+
default_portrait_path = basepath.to_s.gsub("port-","")
|
86
|
+
FileUtils.mkdir_p(default_portrait_path)
|
87
|
+
image.write default_portrait_path + '/' + filename
|
88
|
+
end
|
89
|
+
|
90
|
+
if params[:generate_rounded]
|
91
|
+
rounded_image = MiniMagick::Image.open(fname)
|
92
|
+
rounded_image.format 'png'
|
93
|
+
rounded_image.resize "#{width}x#{height}"
|
94
|
+
rounded_image = round(rounded_image)
|
95
|
+
rounded_image.write basepath + filename.gsub('.png', '_round.png')
|
96
|
+
end
|
54
97
|
end
|
55
98
|
|
56
99
|
UI.success("Successfully stored launcher icons at '#{params[:appicon_path]}'")
|
57
100
|
end
|
58
101
|
|
102
|
+
def self.round(img)
|
103
|
+
require 'mini_magick'
|
104
|
+
img.format 'png'
|
105
|
+
|
106
|
+
width = img[:width]-2
|
107
|
+
radius = width/2
|
108
|
+
|
109
|
+
mask = ::MiniMagick::Image.open img.path
|
110
|
+
mask.format 'png'
|
111
|
+
|
112
|
+
mask.combine_options do |m|
|
113
|
+
m.alpha 'transparent'
|
114
|
+
m.background 'none'
|
115
|
+
m.fill 'white'
|
116
|
+
m.draw 'roundrectangle 1,1,%s,%s,%s,%s' % [width, width, radius, radius]
|
117
|
+
end
|
118
|
+
|
119
|
+
masked = img.composite(mask, 'png') do |i|
|
120
|
+
i.alpha "set"
|
121
|
+
i.compose 'DstIn'
|
122
|
+
end
|
123
|
+
|
124
|
+
return masked
|
125
|
+
end
|
126
|
+
|
59
127
|
def self.get_custom_sizes(image, custom_sizes)
|
60
128
|
|
61
129
|
end
|
@@ -97,7 +165,11 @@ module Fastlane
|
|
97
165
|
description: "Hash of custom sizes - {'path/icon.png' => '256x256'}",
|
98
166
|
default_value: {},
|
99
167
|
optional: true,
|
100
|
-
type: Hash)
|
168
|
+
type: Hash),
|
169
|
+
FastlaneCore::ConfigItem.new(key: :generate_rounded,
|
170
|
+
description: "Generate round icons?",
|
171
|
+
default_value: false,
|
172
|
+
type: Boolean)
|
101
173
|
]
|
102
174
|
end
|
103
175
|
|
@@ -1,8 +1,16 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'mini_magick'
|
3
|
+
|
1
4
|
module Fastlane
|
2
5
|
module Actions
|
3
6
|
class AppiconAction < Action
|
4
7
|
def self.needed_icons
|
5
8
|
{
|
9
|
+
universal: {
|
10
|
+
'1x' => ['2732x2732'],
|
11
|
+
'2x' => ['2732x2732'],
|
12
|
+
'3x' => ['2732x2732']
|
13
|
+
},
|
6
14
|
iphone: {
|
7
15
|
'2x' => ['20x20', '29x29', '40x40', '60x60'],
|
8
16
|
'3x' => ['20x20', '29x29', '40x40', '60x60']
|
@@ -39,7 +47,6 @@ module Fastlane
|
|
39
47
|
basename = File.basename(fname, File.extname(fname))
|
40
48
|
basepath = Pathname.new(File.join(params[:appicon_path], params[:appicon_name]))
|
41
49
|
|
42
|
-
require 'mini_magick'
|
43
50
|
image = MiniMagick::Image.open(fname)
|
44
51
|
|
45
52
|
Helper::AppiconHelper.check_input_image_size(image, 1024)
|
@@ -52,7 +59,8 @@ module Fastlane
|
|
52
59
|
image.alpha 'remove'
|
53
60
|
end
|
54
61
|
|
55
|
-
#
|
62
|
+
# Recreate the base path
|
63
|
+
FileUtils.rm_rf(basepath)
|
56
64
|
FileUtils.mkdir_p(basepath)
|
57
65
|
|
58
66
|
images = []
|
@@ -61,7 +69,11 @@ module Fastlane
|
|
61
69
|
icons.each do |icon|
|
62
70
|
width = icon['width']
|
63
71
|
height = icon['height']
|
64
|
-
filename =
|
72
|
+
filename = basename
|
73
|
+
unless icon['device'] == 'universal'
|
74
|
+
filename += "-#{width.to_i}x#{height.to_i}"
|
75
|
+
end
|
76
|
+
filename += ".png"
|
65
77
|
|
66
78
|
# downsize icon
|
67
79
|
image.resize "#{width}x#{height}"
|
@@ -73,12 +85,15 @@ module Fastlane
|
|
73
85
|
image.write basepath + filename
|
74
86
|
|
75
87
|
info = {
|
76
|
-
'size' => icon['size'],
|
77
88
|
'idiom' => icon['device'],
|
78
89
|
'filename' => filename,
|
79
90
|
'scale' => icon['scale']
|
80
91
|
}
|
81
92
|
|
93
|
+
unless icon['device'] == 'universal'
|
94
|
+
info['size'] = icon['size']
|
95
|
+
end
|
96
|
+
|
82
97
|
info['role'] = icon['role'] unless icon['role'].nil?
|
83
98
|
info['subtype'] = icon['subtype'] unless icon['subtype'].nil?
|
84
99
|
|
@@ -93,7 +108,6 @@ module Fastlane
|
|
93
108
|
}
|
94
109
|
}
|
95
110
|
|
96
|
-
require 'json'
|
97
111
|
File.write(File.join(basepath, 'Contents.json'), JSON.pretty_generate(contents))
|
98
112
|
UI.success("Successfully stored app icon at '#{basepath}'")
|
99
113
|
end
|
@@ -19,7 +19,8 @@ module Fastlane
|
|
19
19
|
if is_android
|
20
20
|
width, height = size.split('x').map { |v| v.to_f }
|
21
21
|
else
|
22
|
-
|
22
|
+
multiple = device.match(/universal/) ? 1 : scale.to_i
|
23
|
+
width, height = size.split('x').map { |v| v.to_f * multiple }
|
23
24
|
end
|
24
25
|
|
25
26
|
icons << {
|
@@ -31,12 +32,12 @@ module Fastlane
|
|
31
32
|
'role' => role,
|
32
33
|
'subtype' => subtype
|
33
34
|
}
|
34
|
-
|
35
|
+
|
35
36
|
end
|
36
37
|
end
|
37
38
|
end
|
38
|
-
|
39
|
-
# Add custom icon sizes (probably for notifications)
|
39
|
+
|
40
|
+
# Add custom icon sizes (probably for notifications)
|
40
41
|
custom_sizes.each do |path, size|
|
41
42
|
path = path.to_s
|
42
43
|
width, height = size.split('x').map { |v| v.to_f }
|
@@ -49,7 +50,7 @@ module Fastlane
|
|
49
50
|
'filename' => File.basename(path)
|
50
51
|
}
|
51
52
|
end
|
52
|
-
|
53
|
+
|
53
54
|
# Sort from the largest to the smallest needed icon
|
54
55
|
icons = icons.sort_by {|value| value['width']} .reverse
|
55
56
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-appicon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Boris Bügling
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-04-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mini_magick
|
@@ -142,7 +142,7 @@ files:
|
|
142
142
|
- lib/fastlane/plugin/appicon/actions/appicon_action.rb
|
143
143
|
- lib/fastlane/plugin/appicon/helper/appicon_helper.rb
|
144
144
|
- lib/fastlane/plugin/appicon/version.rb
|
145
|
-
homepage: https://github.com/
|
145
|
+
homepage: https://github.com/fastlane-community/fastlane-plugin-appicon
|
146
146
|
licenses:
|
147
147
|
- MIT
|
148
148
|
metadata: {}
|
@@ -161,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
161
161
|
- !ruby/object:Gem::Version
|
162
162
|
version: '0'
|
163
163
|
requirements: []
|
164
|
-
rubygems_version: 3.0.
|
164
|
+
rubygems_version: 3.0.6
|
165
165
|
signing_key:
|
166
166
|
specification_version: 4
|
167
167
|
summary: Generate required icon sizes and iconset from a master application icon.
|