makeicon 0.1.1 → 0.1.2
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/bin/makeicon.rb +209 -0
- data/lib/makeicon/version.rb +1 -1
- data/makeicon-0.1.0.gem +0 -0
- data/makeicon-0.1.1.gem +0 -0
- metadata +5 -5
- data/bin/console +0 -14
- data/bin/setup +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77d534bdc6ab0d05d8907694e4ea9102e45280cd
|
4
|
+
data.tar.gz: 0eb1323ab3fcd8b8d214eef6d62a989ce7f32e23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 983c65c669cbaec220aa67fcead3b04549f7cbcf9b58366a4de9199f940b708537dd9bdc89d446a6b29b5508ed799ea0ceed6a42ed7382924ddec86b36fcb064
|
7
|
+
data.tar.gz: 540ce32e81ea0dbad2870d4d766f3dc44a00f494f3aabda363c869f420e4032b9e2a0e2c7dc9156e3bcf3761ec87e7b79ddd5ae315d8f1e3d040c2cfeda5879c
|
data/bin/makeicon.rb
ADDED
@@ -0,0 +1,209 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'commander'
|
5
|
+
|
6
|
+
module MakeIcon
|
7
|
+
module Helper
|
8
|
+
class AppiconHelper
|
9
|
+
def self.check_input_image_size(image, size)
|
10
|
+
puts "Minimum width of input image should be #{size}" if image.width < size
|
11
|
+
puts "Minimum height of input image should be #{size}" if image.height < size
|
12
|
+
puts "Input image should be square" if image.width != image.height
|
13
|
+
# UI.user_error!("Minimum width of input image should be #{size}") if image.width < size
|
14
|
+
# UI.user_error!("Minimum height of input image should be #{size}") if image.height < size
|
15
|
+
# UI.user_error!("Input image should be square") if image.width != image.height
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class SocialAction
|
21
|
+
def self.get_needed_icons(device, needed_icons, is_android = false, custom_sizes = {})
|
22
|
+
icons = []
|
23
|
+
puts device
|
24
|
+
needed_icons[device].each do |scale, sizes|
|
25
|
+
sizes.each do |size|
|
26
|
+
if size.kind_of?(Array)
|
27
|
+
size, role, subtype = size
|
28
|
+
end
|
29
|
+
|
30
|
+
if is_android
|
31
|
+
width, height = size.split('x').map { |v| v.to_f }
|
32
|
+
else
|
33
|
+
width, height = size.split('x').map { |v| v.to_f * scale.to_i }
|
34
|
+
end
|
35
|
+
|
36
|
+
icons << {
|
37
|
+
'width' => width,
|
38
|
+
'height' => height,
|
39
|
+
'size' => size,
|
40
|
+
'device' => device.to_s.gsub('_', '-'),
|
41
|
+
'scale' => scale,
|
42
|
+
'role' => role,
|
43
|
+
'subtype' => subtype
|
44
|
+
}
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Add custom icon sizes (probably for notifications)
|
49
|
+
custom_sizes.each do |path, size|
|
50
|
+
path = path.to_s
|
51
|
+
width, height = size.split('x').map { |v| v.to_f }
|
52
|
+
|
53
|
+
icons << {
|
54
|
+
'width' => width,
|
55
|
+
'height' => height,
|
56
|
+
'size' => size,
|
57
|
+
'basepath' => File.dirname(path),
|
58
|
+
'filename' => File.basename(path)
|
59
|
+
}
|
60
|
+
end
|
61
|
+
|
62
|
+
# Sort from the largest to the smallest needed icon
|
63
|
+
icons = icons.sort_by {|value| value['width']} .reverse
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.needed_icons
|
67
|
+
{
|
68
|
+
social: {
|
69
|
+
'weixin' => ['28x28','108x108'],
|
70
|
+
'weibo' => ['16x16','80x80','120x120'],
|
71
|
+
'qq' => ['16x16','512x512'],
|
72
|
+
},
|
73
|
+
}
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.notification_icons(path, filename)
|
77
|
+
return {} if !path || !filename
|
78
|
+
|
79
|
+
{
|
80
|
+
"#{path}-ldpi/#{filename}" => '36x36',
|
81
|
+
"#{path}-mdpi/#{filename}" => '24x24',
|
82
|
+
"#{path}-hdpi/#{filename}" => '36x36',
|
83
|
+
"#{path}-xhdpi/#{filename}" => '48x48',
|
84
|
+
"#{path}-xxhdpi/#{filename}" => '72x72',
|
85
|
+
"#{path}-xxxhdpi/#{filename}" => '96x96',
|
86
|
+
}
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.run(params)
|
90
|
+
fname = params[:appicon_image_file]
|
91
|
+
|
92
|
+
require 'mini_magick'
|
93
|
+
image = MiniMagick::Image.open(fname)
|
94
|
+
|
95
|
+
Helper::AppiconHelper.check_input_image_size(image, 512)
|
96
|
+
|
97
|
+
# Convert image to png
|
98
|
+
image.format 'png'
|
99
|
+
|
100
|
+
# Merge notification icons into customer sizes as they are handled thes same way
|
101
|
+
|
102
|
+
icons = get_needed_icons(:social, self.needed_icons, true)
|
103
|
+
icons.each do |icon|
|
104
|
+
width = icon['width']
|
105
|
+
height = icon['height']
|
106
|
+
|
107
|
+
# Custom icons will have basepath and filename already defined
|
108
|
+
if icon.has_key?('basepath') && icon.has_key?('filename')
|
109
|
+
basepath = Pathname.new(icon['basepath'])
|
110
|
+
filename = icon['filename']
|
111
|
+
else
|
112
|
+
basepath = Pathname.new("#{params[:appicon_path]}-#{icon['scale']}")
|
113
|
+
filename = "#{params[:appicon_filename]}_#{width}x#{height}.png"
|
114
|
+
end
|
115
|
+
FileUtils.mkdir_p(basepath)
|
116
|
+
|
117
|
+
image.resize "#{width}x#{height}"
|
118
|
+
image.write basepath + filename
|
119
|
+
end
|
120
|
+
|
121
|
+
puts "Successfully stored launcher icons at '#{params[:appicon_path]}'"
|
122
|
+
end
|
123
|
+
|
124
|
+
def self.get_custom_sizes(image, custom_sizes)
|
125
|
+
|
126
|
+
end
|
127
|
+
|
128
|
+
def self.description
|
129
|
+
"Generate required icon sizes from a master application icon"
|
130
|
+
end
|
131
|
+
|
132
|
+
def self.authors
|
133
|
+
["@adrum"]
|
134
|
+
end
|
135
|
+
|
136
|
+
def self.available_options
|
137
|
+
[
|
138
|
+
FastlaneCore::ConfigItem.new(key: :appicon_image_file,
|
139
|
+
env_name: "APPICON_IMAGE_FILE",
|
140
|
+
description: "Path to a square image file, at least 512x512",
|
141
|
+
optional: false,
|
142
|
+
type: String),
|
143
|
+
FastlaneCore::ConfigItem.new(key: :appicon_devices,
|
144
|
+
env_name: "APPICON_DEVICES",
|
145
|
+
default_value: [:phone],
|
146
|
+
description: "Array of device types to generate icons for",
|
147
|
+
optional: true,
|
148
|
+
type: Array),
|
149
|
+
FastlaneCore::ConfigItem.new(key: :appicon_path,
|
150
|
+
env_name: "APPICON_PATH",
|
151
|
+
default_value: 'app/res/mipmap/',
|
152
|
+
description: "Path to res subfolder",
|
153
|
+
optional: true,
|
154
|
+
type: String),
|
155
|
+
FastlaneCore::ConfigItem.new(key: :appicon_filename,
|
156
|
+
env_name: "APPICON_FILENAME",
|
157
|
+
default_value: 'ic_launcher',
|
158
|
+
description: "The output filename of each image",
|
159
|
+
optional: true,
|
160
|
+
type: String),
|
161
|
+
FastlaneCore::ConfigItem.new(key: :appicon_notification_icon_path,
|
162
|
+
env_name: "APPICON_NOTIFICATION_ICON_PATH",
|
163
|
+
default_value: 'app/res/drawable/',
|
164
|
+
description: "Path to res subfolder",
|
165
|
+
optional: true,
|
166
|
+
type: String),
|
167
|
+
FastlaneCore::ConfigItem.new(key: :appicon_notification_icon_filename,
|
168
|
+
env_name: "APPICON_NOTIFICATION_ICON_FILENAME",
|
169
|
+
default_value: 'ic_stat_onesignal_default',
|
170
|
+
description: "File name for notification icons",
|
171
|
+
optional: true,
|
172
|
+
type: String),
|
173
|
+
FastlaneCore::ConfigItem.new(key: :appicon_custom_sizes,
|
174
|
+
description: "Hash of custom sizes - {'path/icon.png' => '256x256'}",
|
175
|
+
optional: true,
|
176
|
+
type: Hash)
|
177
|
+
]
|
178
|
+
end
|
179
|
+
|
180
|
+
def self.is_supported?(platform)
|
181
|
+
[:android].include?(platform)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
class MyApplication
|
186
|
+
include Commander::Methods
|
187
|
+
|
188
|
+
def run
|
189
|
+
program :name, 'makeicon'
|
190
|
+
program :version, '0.0.1'
|
191
|
+
program :description, 'makeicon'
|
192
|
+
|
193
|
+
command :makeicon do |c|
|
194
|
+
c.syntax = 'foobar foo'
|
195
|
+
c.description = 'Displays foo'
|
196
|
+
c.action do |args, options|
|
197
|
+
puts args
|
198
|
+
params = Hash[:appicon_image_file => args[0], :appicon_path => "icon",:appicon_filename=>"icon"]
|
199
|
+
SocialAction::run(params)
|
200
|
+
say 'foo'
|
201
|
+
end
|
202
|
+
end
|
203
|
+
run!
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
|
209
|
+
MakeIcon::MyApplication.new.run if $0 == __FILE__
|
data/lib/makeicon/version.rb
CHANGED
data/makeicon-0.1.0.gem
ADDED
Binary file
|
data/makeicon-0.1.1.gem
ADDED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: makeicon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- marekchen
|
@@ -70,8 +70,7 @@ description: makeicon
|
|
70
70
|
email:
|
71
71
|
- marek@163.com
|
72
72
|
executables:
|
73
|
-
-
|
74
|
-
- setup
|
73
|
+
- makeicon.rb
|
75
74
|
extensions: []
|
76
75
|
extra_rdoc_files: []
|
77
76
|
files:
|
@@ -83,10 +82,11 @@ files:
|
|
83
82
|
- LICENSE.txt
|
84
83
|
- README.md
|
85
84
|
- Rakefile
|
86
|
-
- bin/
|
87
|
-
- bin/setup
|
85
|
+
- bin/makeicon.rb
|
88
86
|
- lib/makeicon.rb
|
89
87
|
- lib/makeicon/version.rb
|
88
|
+
- makeicon-0.1.0.gem
|
89
|
+
- makeicon-0.1.1.gem
|
90
90
|
- makeicon.gemspec
|
91
91
|
homepage: http://www.droi.com
|
92
92
|
licenses:
|
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "makeicon"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start(__FILE__)
|