confetti 0.7.7 → 0.7.8
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.
- data/Gemfile.lock +1 -1
- data/lib/confetti/config.rb +6 -2
- data/lib/confetti/config/image.rb +4 -1
- data/lib/confetti/version.rb +1 -1
- data/spec/config_spec.rb +13 -17
- data/spec/fixtures/config-icons-custom-attribs-extended.xml +41 -36
- metadata +2 -2
data/Gemfile.lock
CHANGED
data/lib/confetti/config.rb
CHANGED
@@ -169,11 +169,15 @@ module Confetti
|
|
169
169
|
opts['width'] ||= nil
|
170
170
|
opts['height'] ||= nil
|
171
171
|
opts['role'] ||= nil
|
172
|
+
opts['density'] ||= nil
|
173
|
+
opts['state'] ||= nil
|
172
174
|
opts['platform'] ||= nil
|
173
175
|
|
174
176
|
# filters to look through sets for
|
175
177
|
filters = [
|
176
178
|
{'height' => opts['height'], 'width' => opts['width']},
|
179
|
+
{'platform' => opts['platform'], 'density' => opts['density']},
|
180
|
+
{'platform' => opts['platform'], 'state' => opts['state']},
|
177
181
|
{'platform' => opts['platform'], 'role' => opts['role']},
|
178
182
|
{'platform' => opts['platform']}
|
179
183
|
]
|
@@ -193,14 +197,14 @@ module Confetti
|
|
193
197
|
|
194
198
|
def default_icon
|
195
199
|
@icon_set.each do |icon|
|
196
|
-
return icon
|
200
|
+
return icon if icon.src.match /^icon\.png$/i
|
197
201
|
end
|
198
202
|
nil
|
199
203
|
end
|
200
204
|
|
201
205
|
def default_splash
|
202
206
|
@splash_set.each do |splash|
|
203
|
-
return splash
|
207
|
+
return splash if splash.src.match /^splash\.png$/i
|
204
208
|
end
|
205
209
|
nil
|
206
210
|
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
module Confetti
|
2
2
|
class Config
|
3
3
|
class Image
|
4
|
-
attr_accessor :src, :width, :height, :extras,
|
4
|
+
attr_accessor :src, :width, :height, :extras,
|
5
|
+
:role, :platform, :main, :density, :state
|
5
6
|
|
6
7
|
def initialize *args
|
7
8
|
@src = args.shift
|
@@ -15,6 +16,8 @@ module Confetti
|
|
15
16
|
@role = @extras['role']
|
16
17
|
@platform = @extras['platform']
|
17
18
|
@main = @extras['main']
|
19
|
+
@density = @extras['density']
|
20
|
+
@state = @extras['state']
|
18
21
|
end
|
19
22
|
end
|
20
23
|
end
|
data/lib/confetti/version.rb
CHANGED
data/spec/config_spec.rb
CHANGED
@@ -542,7 +542,7 @@ describe Confetti::Config do
|
|
542
542
|
end
|
543
543
|
end
|
544
544
|
|
545
|
-
describe "
|
545
|
+
describe "icon and splash helpers" do
|
546
546
|
before do
|
547
547
|
file = "#{fixture_dir}/config-icons-custom-attribs-extended.xml"
|
548
548
|
@config = Confetti::Config.new file
|
@@ -553,11 +553,11 @@ describe Confetti::Config do
|
|
553
553
|
@config.icon_set,
|
554
554
|
{
|
555
555
|
'platform' => 'blackberry',
|
556
|
-
'
|
556
|
+
'state' => 'hover'
|
557
557
|
}
|
558
558
|
)
|
559
559
|
match.length.should == 1
|
560
|
-
match.first.src.should == 'icons/icon_hover.png'
|
560
|
+
match.first.src.should == 'icons/bb/icon_hover.png'
|
561
561
|
end
|
562
562
|
|
563
563
|
it "should return all icons" do
|
@@ -570,10 +570,10 @@ describe Confetti::Config do
|
|
570
570
|
@config.icon_set,
|
571
571
|
{
|
572
572
|
'platform' => 'blackberry',
|
573
|
-
'
|
573
|
+
'state' => 'hover'
|
574
574
|
}
|
575
575
|
)
|
576
|
-
match.src.should == "icons/icon_hover.png"
|
576
|
+
match.src.should == "icons/bb/icon_hover.png"
|
577
577
|
end
|
578
578
|
|
579
579
|
it "should find the best fit icon for winphone" do
|
@@ -582,13 +582,11 @@ describe Confetti::Config do
|
|
582
582
|
match = @config.find_best_fit_img(
|
583
583
|
@config.send(:icon_set),
|
584
584
|
{
|
585
|
-
'height' => '54',
|
586
|
-
'width' => '54',
|
587
585
|
'platform' => 'winphone',
|
588
|
-
'role' => '
|
586
|
+
'role' => 'background'
|
589
587
|
}
|
590
588
|
)
|
591
|
-
match.src.should == "icons/
|
589
|
+
match.src.should == "icons/winphone/tileicon.png"
|
592
590
|
end
|
593
591
|
|
594
592
|
it "should find the best fit splash for android" do
|
@@ -597,31 +595,29 @@ describe Confetti::Config do
|
|
597
595
|
match = @config.find_best_fit_img(
|
598
596
|
@config.send(:splash_set),
|
599
597
|
{
|
600
|
-
'height' => '54',
|
601
|
-
'width' => '54',
|
602
598
|
'platform' => 'android',
|
603
|
-
'
|
599
|
+
'density' => 'ldpi'
|
604
600
|
}
|
605
601
|
)
|
606
|
-
match.src.should == "
|
602
|
+
match.src.should == "splash/android/ldpi.png"
|
607
603
|
end
|
608
604
|
|
609
605
|
it "should return the default icon: icon.png" do
|
610
|
-
@config.default_icon.src.should == "
|
606
|
+
@config.default_icon.src.should == "icon.png"
|
611
607
|
end
|
612
608
|
|
613
609
|
it "should fail to return the default icon: icon.png" do
|
614
610
|
@config = Confetti::Config.new
|
615
|
-
@config.default_icon.should
|
611
|
+
@config.default_icon.should == nil
|
616
612
|
end
|
617
613
|
|
618
614
|
it "should return the default splash: splash.png" do
|
619
|
-
@config.default_splash.src.should == "
|
615
|
+
@config.default_splash.src.should == "splash.png"
|
620
616
|
end
|
621
617
|
|
622
618
|
it "should fail to return the default splash: splash.png" do
|
623
619
|
@config = Confetti::Config.new
|
624
|
-
@config.default_splash.should
|
620
|
+
@config.default_splash.should == nil
|
625
621
|
end
|
626
622
|
end
|
627
623
|
|
@@ -1,38 +1,43 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<widget xmlns
|
3
|
-
xmlns:gap
|
4
|
-
|
5
|
-
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
2
|
+
<widget xmlns = "http://www.w3.org/ns/widgets"
|
3
|
+
xmlns:gap = "http://phonegap.com/ns/1.0"
|
4
|
+
id = "com.phonegap.example"
|
5
|
+
version = "1.0.0">
|
6
|
+
|
7
|
+
<name>Icon and Splash Demo</name>
|
8
|
+
|
9
|
+
<description>
|
10
|
+
Basic application to test and demonstrate icons and splash screens.
|
11
|
+
</description>
|
12
|
+
|
13
|
+
<author href="https://build.phonegap.com" email="shardeep@adobe.com">
|
14
|
+
Hardeep Shoker
|
15
|
+
</author>
|
16
|
+
|
17
|
+
<!-- Icons -->
|
18
|
+
|
19
|
+
<icon src="icon.png" />
|
20
|
+
<icon src="icons/ios/icon.png" width="57" height="57" />
|
21
|
+
<icon src="icons/ios/icon-72.png" gap:platform="ios" width="72" height="72" />
|
22
|
+
<icon src="icons/ios/icon_at_2x.png" width="114" height="114" />
|
23
|
+
<icon src="icons/android/ldpi.png" gap:platform="android" gap:density="ldpi" />
|
24
|
+
<icon src="icons/android/mdpi.png" gap:platform="android" gap:density="mdpi" />
|
25
|
+
<icon src="icons/android/hdpi.png" gap:platform="android" gap:density="hdpi" />
|
26
|
+
<icon src="icons/bb/icon.png" gap:platform="blackberry" />
|
27
|
+
<icon src="icons/bb/icon_hover.png" gap:platform="blackberry" gap:state="hover"/>
|
28
|
+
<icon src="icons/winphone/icon.png" gap:platform="winphone" />
|
29
|
+
<icon src="icons/winphone/tileicon.png" gap:platform="winphone" gap:role="background"/>
|
30
|
+
|
31
|
+
<!-- Splash Screens -->
|
32
|
+
<gap:splash src="splash.png" />
|
33
|
+
<gap:splash src="splash/ios/Default-Landscape.png" width="1024" height="786"/>
|
34
|
+
<gap:splash src="splash/ios/Default-Portrait.png" width="786" height="1024" />
|
35
|
+
<gap:splash src="splash/ios/Default.png" width="320" height="480" />
|
36
|
+
<gap:splash src="splash/ios/Default_at_2x.png" width="640" height="960" />
|
37
|
+
<gap:splash src="splash/android/ldpi.png" gap:platform="android" gap:density="ldpi" />
|
38
|
+
<gap:splash src="splash/android/mdpi.png" gap:platform="android" gap:density="mdpi" />
|
39
|
+
<gap:splash src="splash/android/hdpi.png" gap:platform="android" gap:density="hdpi" />
|
40
|
+
<gap:splash src="splash/bb/splash.png" gap:platform="blackberry" />
|
41
|
+
<gap:splash src="splash/winphone/splash.png" gap:platform="winphone" />
|
6
42
|
|
7
|
-
<name>Confetti Sample App</name>
|
8
|
-
|
9
|
-
<description>
|
10
|
-
This is a sample config.xml for integration testing with Confetti
|
11
|
-
</description>
|
12
|
-
|
13
|
-
<author href="http://alunny.github.com"
|
14
|
-
email="hardeep.shoker@nitobi.com">
|
15
|
-
Hardeep Shoker
|
16
|
-
</author>
|
17
|
-
|
18
|
-
<icon src="icons/icon.png" />
|
19
|
-
<gap:splash src="splashes/splash.png" />
|
20
|
-
|
21
|
-
<icon src="icons/icon.png" gap:platform="blackberry" />
|
22
|
-
<icon src="icons/icon_hover.png" gap:platform="blackberry" gap:role="hover"/>
|
23
|
-
|
24
|
-
<icon src="icons/icon-57.png" width="57" height="57"/>
|
25
|
-
<icon src="icons/icon-iphone-72.png" height="72" width="72" gap:platform="ios"/>
|
26
|
-
<icon src="icons/icon-114.png" width="114" height="114"/>
|
27
|
-
|
28
|
-
<icon src="icons/icon-36.png" width="36" height="36"/>
|
29
|
-
<icon src="icons/icon-48.png" width="48" height="48"/>
|
30
|
-
<icon src="icons/icon-android-72.png" height="72" width="72" gap:platform="android"/>
|
31
|
-
<gap:splash src="splashes/splash-android.png" gap:platform="android"/>
|
32
|
-
|
33
|
-
<icon src="icons/icon-173.png" width="173" height="173"/>
|
34
|
-
<icon src="icons/icon-68.png" gap:platform="winphone"/>
|
35
|
-
|
36
|
-
<feature name="http://api.phonegap.com/1.0/geolocation"/>
|
37
|
-
<feature name="http://api.phonegap.com/1.0/network"/>
|
38
43
|
</widget>
|