high_five 0.3.15 → 0.3.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/high_five/android_helper.rb +8 -0
- data/lib/high_five/image_helper.rb +83 -0
- data/lib/high_five/thor/tasks/android.rb +40 -3
- data/lib/high_five/thor/tasks/ios.rb +43 -4
- data/lib/high_five/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 616b4f628f3d4af0087fee42e660347c3a0c7225
|
4
|
+
data.tar.gz: 9ecf7fe5a40e59c1fa767e56b33143b6a8b7d503
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 106943f47660d4da515f516d06b5982b542b1c60ad3337e4e99f97045b00dd5615c0e0af813cb8a307c3e53e2f4fd4ccaf0ed78dd0803911af34a7cdc1f5b595
|
7
|
+
data.tar.gz: f24ca6f27af4760e43592b7c1781fef4fa9fed98f554d687f8162bc44224b6ea81e568638ac3d121e2031e7e984c288c80046b4e204819f88cfffe6f51b1d376
|
@@ -34,6 +34,14 @@ module HighFive
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
+
def gradle_file_path
|
38
|
+
if options[:platform_path]
|
39
|
+
gradle_path = Dir[File.join(options[:platform_path], "/app/build.gradle")][0]
|
40
|
+
return gradle_path if gradle_path && File.exists?(gradle_path)
|
41
|
+
end
|
42
|
+
return nil
|
43
|
+
end
|
44
|
+
|
37
45
|
def res_map
|
38
46
|
{
|
39
47
|
ldpi: 36,
|
@@ -13,7 +13,82 @@ module HighFive
|
|
13
13
|
source = ChunkyPNG::Image.from_file(source_path)
|
14
14
|
source.resize(image.height, image.width).save(image_path)
|
15
15
|
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def generate_splash_screen_image(image_path, logo_path, background)
|
19
|
+
raise "Requires RMagick gem" unless rmagick?
|
20
|
+
image = ChunkyPNG::Image.from_file(image_path)
|
21
|
+
width = image.width
|
22
|
+
height = image.height
|
23
|
+
source = Magick::Image.new(width, height) { self.background_color = background }
|
16
24
|
|
25
|
+
logo = Magick::Image.read(logo_path).first
|
26
|
+
scale_factor = min_scale_factor(logo, 0.75*width, 0.3*height)
|
27
|
+
|
28
|
+
logo.scale!(scale_factor)
|
29
|
+
source.composite!(logo, Magick::CenterGravity, Magick::AtopCompositeOp)
|
30
|
+
|
31
|
+
source.write(image_path)
|
32
|
+
end
|
33
|
+
|
34
|
+
def generate_ios_splash_screen_image(type, ios_path, path, color)
|
35
|
+
raise "Requires RMagick gem" unless rmagick?
|
36
|
+
case type
|
37
|
+
when 'iphone_portrait_8_retina_hd_5_5'
|
38
|
+
width = 1242
|
39
|
+
height = 2208
|
40
|
+
when 'iphone_portrait_8_retina_hd_4_7'
|
41
|
+
width = 750
|
42
|
+
height = 1334
|
43
|
+
when 'iphone_landscape_8_retina_hd_5_5'
|
44
|
+
width = 2208
|
45
|
+
height = 1242
|
46
|
+
when 'iphone_portrait_1x'
|
47
|
+
width = 320
|
48
|
+
height = 480
|
49
|
+
when 'iphone_portrait_2x', 'android'
|
50
|
+
width = 640
|
51
|
+
height = 960
|
52
|
+
when 'iphone_portrait_retina_4'
|
53
|
+
width = 640
|
54
|
+
height = 1136
|
55
|
+
when 'ios-7-iphone_portrait_2x'
|
56
|
+
width = 640
|
57
|
+
height = 960
|
58
|
+
when 'ios-7-iphone_portrait_retina_4'
|
59
|
+
width = 640
|
60
|
+
height = 1136
|
61
|
+
when 'ipad_portrait_1x'
|
62
|
+
width = 768
|
63
|
+
height = 1024
|
64
|
+
when 'ipad_portrait_2x'
|
65
|
+
width = 1536
|
66
|
+
height = 2048
|
67
|
+
when 'ipad_landscape_1x'
|
68
|
+
width = 1024
|
69
|
+
height = 768
|
70
|
+
when 'ipad_landscape_2x'
|
71
|
+
width = 2048
|
72
|
+
height = 1536
|
73
|
+
when 'ipad_portrait_without_status_bar_5_6_1x'
|
74
|
+
width = 768
|
75
|
+
height = 1004
|
76
|
+
when 'ipad_portrait_without_status_bar_5_6_2x'
|
77
|
+
width = 1536
|
78
|
+
height = 2008
|
79
|
+
when 'ipad_landscape_without_status_bar_5_6_1x'
|
80
|
+
width = 1024
|
81
|
+
height = 748
|
82
|
+
when 'ipad_landscape_without_status_bar_5_6_2x'
|
83
|
+
width = 2048
|
84
|
+
height = 1496
|
85
|
+
end
|
86
|
+
|
87
|
+
filename = "#{type}.png"
|
88
|
+
splash_path = Dir.glob("#{ios_path}/**/Images.xcassets/LaunchImage.launchimage").first + "/#{filename}"
|
89
|
+
puts "Creating #{splash_path}"
|
90
|
+
Magick::Image.new(width, height).write(splash_path)
|
91
|
+
generate_splash_screen_image splash_path, path, color
|
17
92
|
end
|
18
93
|
|
19
94
|
private
|
@@ -28,5 +103,13 @@ module HighFive
|
|
28
103
|
false
|
29
104
|
end
|
30
105
|
end
|
106
|
+
|
107
|
+
def min_scale_factor(image, max_width, max_height)
|
108
|
+
width_scale_factor = max_width / image.columns
|
109
|
+
height_scale_factor = max_height / image.rows
|
110
|
+
sf = [width_scale_factor, height_scale_factor].min
|
111
|
+
puts "Warning: upscaling image for splash screen" if sf > 1.0
|
112
|
+
sf
|
113
|
+
end
|
31
114
|
end
|
32
115
|
end
|
@@ -33,6 +33,9 @@ module HighFive
|
|
33
33
|
xml = Nokogiri::XML(file)
|
34
34
|
|
35
35
|
# replace \n and any additional whitespace with a space
|
36
|
+
puts "========================================="
|
37
|
+
puts "#{android_manifest_path}"
|
38
|
+
puts "========================================="
|
36
39
|
xml.xpath("//manifest").each do |node|
|
37
40
|
if (options[:version])
|
38
41
|
old = node["android:versionName"]
|
@@ -46,15 +49,32 @@ module HighFive
|
|
46
49
|
end
|
47
50
|
end
|
48
51
|
|
52
|
+
if gradle_file_path
|
53
|
+
puts "========================================="
|
54
|
+
puts "#{gradle_file_path}"
|
55
|
+
puts "========================================="
|
56
|
+
gradle_file = File.read(gradle_file_path)
|
57
|
+
|
58
|
+
old = gradle_file.match(/versionName\s"(.+)"$/)[1]
|
59
|
+
gradle_file.gsub!(/versionName\s"(.+)"$/, "versionName \"#{options[:version]}\"")
|
60
|
+
puts "Setting version #{old} => #{options[:version]}"
|
61
|
+
|
62
|
+
old = gradle_file.match(/versionCode\s(\d+)$/)[1]
|
63
|
+
gradle_file.gsub!(/versionCode\s\d+$/, "versionCode #{options[:build_number]}")
|
64
|
+
puts "Setting versionCode #{old} => #{options[:build_number]}"
|
65
|
+
|
66
|
+
File.open(gradle_file_path, "w") do |f|
|
67
|
+
f.write gradle_file
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
49
71
|
# save the output into a new file
|
50
72
|
File.open(android_manifest_path, "w") do |f|
|
51
73
|
f.write xml.to_xml
|
52
74
|
end
|
53
75
|
end
|
54
76
|
|
55
|
-
desc "set_icon", "Generate app icons from base png image"
|
56
|
-
method_option :platform_path, desc: "Path to the ios or android directory"
|
57
|
-
method_option :environment, :aliases => '-e', :desc => "Set environment"
|
77
|
+
desc "set_icon", "Generate and replace app icons from base png image"
|
58
78
|
def set_icon(path)
|
59
79
|
image = ChunkyPNG::Image.from_file(path)
|
60
80
|
|
@@ -77,6 +97,23 @@ module HighFive
|
|
77
97
|
end
|
78
98
|
end
|
79
99
|
|
100
|
+
desc "generate_splash_screen", "Generate and replace splash screens from logo and background color"
|
101
|
+
method_option :color, desc: "Background color"
|
102
|
+
def generate_splash_screen(path)
|
103
|
+
image = ChunkyPNG::Image.from_file(path)
|
104
|
+
|
105
|
+
splash_name = 'screen.png'
|
106
|
+
|
107
|
+
drawable_dir = File.join File.dirname(android_manifest_path), 'res'
|
108
|
+
Dir.glob(File.join drawable_dir, "drawable*").each do |dir|
|
109
|
+
splash_path = File.join(dir, splash_name)
|
110
|
+
if File.exists?(splash_path)
|
111
|
+
generate_splash_screen_image splash_path, path, options[:color] || "#ffffff"
|
112
|
+
puts "Writing #{splash_path}"
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
80
117
|
private
|
81
118
|
def config
|
82
119
|
base_config.build_platform_config(:android).build_platform_config(options[:environment])
|
@@ -45,9 +45,16 @@ module HighFive
|
|
45
45
|
method_option :target, :aliases => '-t', :desc => "Use a specific target (i.e. <Target>.plist)"
|
46
46
|
method_option :platform_path, :desc => "Path to ios or android directory"
|
47
47
|
def set_icon(path)
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
begin
|
49
|
+
icon_files = plist['CFBundleIcons']["CFBundlePrimaryIcon"]["CFBundleIconFiles"]
|
50
|
+
icon_files += [ plist['CFBundleIconFile'] ]
|
51
|
+
icon_files += plist['CFBundleIcons~ipad']["CFBundlePrimaryIcon"]["CFBundleIconFiles"]
|
52
|
+
rescue
|
53
|
+
icon_files = []
|
54
|
+
end
|
55
|
+
if icon_files.empty?
|
56
|
+
icon_files = Dir.glob("#{ios_path}/**/Images.xcassets/AppIcon.appiconset/*.png")
|
57
|
+
end
|
51
58
|
icon_files.each do |icon_entry|
|
52
59
|
icon_file_name = icon_entry
|
53
60
|
unless icon_entry.end_with? ".png"
|
@@ -58,6 +65,7 @@ module HighFive
|
|
58
65
|
# This helps with multi-target apps
|
59
66
|
old_icon_path = Dir[File.join(ios_path, "#{target}/**/#{icon_file_name}")].first
|
60
67
|
old_icon_path = Dir[File.join(ios_path, "**/#{icon_file_name}")].first if old_icon_path.nil?
|
68
|
+
old_icon_path = Dir[File.join(icon_entry)].first if old_icon_path.nil?
|
61
69
|
|
62
70
|
if old_icon_path.nil?
|
63
71
|
puts "Skipping #{icon_entry} because the file is missing. This will cause problems with app store submission"
|
@@ -70,6 +78,37 @@ module HighFive
|
|
70
78
|
end
|
71
79
|
end
|
72
80
|
|
81
|
+
desc "generate_splash_screen", "Generate and replace splash screens from logo and background color"
|
82
|
+
method_option :color, desc: "Background color"
|
83
|
+
def generate_splash_screen(path)
|
84
|
+
image = ChunkyPNG::Image.from_file(path)
|
85
|
+
|
86
|
+
splashes_to_make = [
|
87
|
+
'iphone_portrait_8_retina_hd_5_5',
|
88
|
+
'iphone_portrait_8_retina_hd_4_7',
|
89
|
+
'iphone_landscape_8_retina_hd_5_5',
|
90
|
+
'iphone_portrait_1x',
|
91
|
+
'iphone_portrait_2x',
|
92
|
+
'iphone_portrait_retina_4',
|
93
|
+
'ios-7-iphone_portrait_2x',
|
94
|
+
'ios-7-iphone_portrait_retina_4',
|
95
|
+
'ipad_portrait_1x',
|
96
|
+
'ipad_portrait_2x',
|
97
|
+
'ipad_landscape_1x',
|
98
|
+
'ipad_landscape_2x',
|
99
|
+
'ipad_portrait_without_status_bar_5_6_1x',
|
100
|
+
'ipad_portrait_without_status_bar_5_6_2x',
|
101
|
+
'ipad_landscape_without_status_bar_5_6_1x',
|
102
|
+
'ipad_landscape_without_status_bar_5_6_2x'
|
103
|
+
]
|
104
|
+
|
105
|
+
splashes_to_make.each do |type|
|
106
|
+
generate_ios_splash_screen_image(type, ios_path, path, options[:color] || "#ffffff")
|
107
|
+
end
|
108
|
+
|
109
|
+
puts "Make sure you assign them in xcode if this is the first time you generated these"
|
110
|
+
end
|
111
|
+
|
73
112
|
private
|
74
113
|
|
75
114
|
def set_plist_property(key, value)
|
@@ -98,4 +137,4 @@ module HighFive
|
|
98
137
|
end
|
99
138
|
end
|
100
139
|
end
|
101
|
-
end
|
140
|
+
end
|
data/lib/high_five/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: high_five
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Samson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|