da_funk 3.30.0 → 3.31.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/RELEASE_NOTES.md +5 -0
- data/lib/da_funk/helper/status_bar.rb +120 -63
- data/lib/da_funk/rake_task.rb +13 -6
- data/lib/da_funk/version.rb +1 -1
- data/lib/device/display.rb +2 -1
- data/lib/device/system.rb +9 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5492c7a7c61fc8559c3d0267a010c62fc6b85f47ff9c40b6164d6afef3536cfd
|
4
|
+
data.tar.gz: 06cccc06f994055eb85e68163412af8b076b2342a59661f92e2ab2907514be32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 158eb51a52a2895383bfb2864c5717659aa3d601a3780c0abcc42029b3ad86e7606aa5b1c02c55bb95e6c90dbe187f55e5fdc0ab3a1af659a4320598ef192703
|
7
|
+
data.tar.gz: cdff69f582095c79cbe9a5e1e063e495aec2a21fd74e29cc132b12653942b770da6d56d8fa309a07c433ea4e2d0a3ac8b9680c47692c109897d68020d615fa56
|
data/Gemfile.lock
CHANGED
data/RELEASE_NOTES.md
CHANGED
@@ -1,12 +1,23 @@
|
|
1
|
+
#
|
2
|
+
# @file status_bar.rb
|
3
|
+
# @brief DaFunk status bar helper script.
|
4
|
+
# @platform N/A
|
5
|
+
#
|
6
|
+
# @copyright Copyright (c) 2016 CloudWalk, Inc.
|
7
|
+
#
|
8
|
+
|
1
9
|
module DaFunk
|
2
10
|
module Helper
|
11
|
+
# Status bar class definition.
|
3
12
|
class StatusBar
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
13
|
+
# Class macros and constants
|
14
|
+
STATUS_TIMEOUT = 60
|
15
|
+
SLOT_MEDIA = 0
|
16
|
+
SLOT_SIGNAL_LEVEL = 1
|
17
|
+
SLOT_UPDATE = 2
|
8
18
|
SLOT_BATTERY_PERCENTUAL = 6
|
9
|
-
SLOT_BATTERY_LEVEL
|
19
|
+
SLOT_BATTERY_LEVEL = 7
|
20
|
+
|
10
21
|
SLOT_MESSAGE_CONNECTION = {
|
11
22
|
true => {
|
12
23
|
:slot1 => 2,
|
@@ -22,10 +33,53 @@ module DaFunk
|
|
22
33
|
}
|
23
34
|
}
|
24
35
|
|
36
|
+
# TODO: review the 'print_status_bar' API to reduce the number of files
|
37
|
+
# to eleven?
|
38
|
+
BATTERY_PERCENTAGE_IMAGES = [
|
39
|
+
'./shared/1%.png', './shared/1%.png', './shared/2%.png',
|
40
|
+
'./shared/3%.png', './shared/4%.png', './shared/5%.png',
|
41
|
+
'./shared/6%.png', './shared/7%.png', './shared/8%.png',
|
42
|
+
'./shared/9%.png', './shared/10%.png', './shared/11%.png',
|
43
|
+
'./shared/12%.png', './shared/13%.png', './shared/14%.png',
|
44
|
+
'./shared/15%.png', './shared/16%.png', './shared/17%.png',
|
45
|
+
'./shared/18%.png', './shared/19%.png', './shared/20%.png',
|
46
|
+
'./shared/21%.png', './shared/22%.png', './shared/23%.png',
|
47
|
+
'./shared/24%.png', './shared/25%.png', './shared/26%.png',
|
48
|
+
'./shared/27%.png', './shared/28%.png', './shared/29%.png',
|
49
|
+
'./shared/30%.png', './shared/31%.png', './shared/32%.png',
|
50
|
+
'./shared/33%.png', './shared/34%.png', './shared/35%.png',
|
51
|
+
'./shared/36%.png', './shared/37%.png', './shared/38%.png',
|
52
|
+
'./shared/39%.png', './shared/40%.png', './shared/41%.png',
|
53
|
+
'./shared/42%.png', './shared/43%.png', './shared/44%.png',
|
54
|
+
'./shared/45%.png', './shared/46%.png', './shared/47%.png',
|
55
|
+
'./shared/48%.png', './shared/49%.png', './shared/50%.png',
|
56
|
+
'./shared/51%.png', './shared/52%.png', './shared/53%.png',
|
57
|
+
'./shared/54%.png', './shared/55%.png', './shared/56%.png',
|
58
|
+
'./shared/57%.png', './shared/58%.png', './shared/59%.png',
|
59
|
+
'./shared/60%.png', './shared/61%.png', './shared/62%.png',
|
60
|
+
'./shared/63%.png', './shared/64%.png', './shared/65%.png',
|
61
|
+
'./shared/66%.png', './shared/67%.png', './shared/68%.png',
|
62
|
+
'./shared/69%.png', './shared/70%.png', './shared/71%.png',
|
63
|
+
'./shared/72%.png', './shared/73%.png', './shared/74%.png',
|
64
|
+
'./shared/75%.png', './shared/76%.png', './shared/77%.png',
|
65
|
+
'./shared/78%.png', './shared/79%.png', './shared/80%.png',
|
66
|
+
'./shared/81%.png', './shared/82%.png', './shared/83%.png',
|
67
|
+
'./shared/84%.png', './shared/85%.png', './shared/86%.png',
|
68
|
+
'./shared/87%.png', './shared/88%.png', './shared/89%.png',
|
69
|
+
'./shared/90%.png', './shared/91%.png', './shared/92%.png',
|
70
|
+
'./shared/93%.png', './shared/94%.png', './shared/95%.png',
|
71
|
+
'./shared/96%.png', './shared/97%.png', './shared/98%.png',
|
72
|
+
'./shared/99%.png', './shared/100%.png'
|
73
|
+
].freeze
|
74
|
+
|
75
|
+
BATTERY_CHARGING = [
|
76
|
+
"./shared/battery_charging.png",
|
77
|
+
"./shared/battery_charged.png"
|
78
|
+
].freeze
|
79
|
+
|
25
80
|
BATTERY_IMAGES = {
|
26
81
|
0..4 => "./shared/battery0.png",
|
27
|
-
5..
|
28
|
-
10..19 => "./shared/battery10.png",
|
82
|
+
5..19 => "./shared/battery10.png",
|
29
83
|
20..29 => "./shared/battery20.png",
|
30
84
|
30..39 => "./shared/battery30.png",
|
31
85
|
40..49 => "./shared/battery40.png",
|
@@ -34,44 +88,24 @@ module DaFunk
|
|
34
88
|
70..79 => "./shared/battery70.png",
|
35
89
|
80..89 => "./shared/battery80.png",
|
36
90
|
90..99 => "./shared/battery90.png",
|
37
|
-
100..100 => "./shared/battery100.png"
|
38
|
-
}
|
39
|
-
|
40
|
-
BATTERY_CHARGE_IMAGES = {
|
41
|
-
50 => "./shared/battery0c.png",
|
42
|
-
100 => "./shared/battery100c.png"
|
43
|
-
}
|
44
|
-
|
45
|
-
BATTERY_PERCENTAGE_IMAGES = {
|
46
|
-
0..4 => "./shared/battery1_percent.png",
|
47
|
-
5..9 => "./shared/battery5_percent.png",
|
48
|
-
10..19 => "./shared/battery10_percent.png",
|
49
|
-
20..29 => "./shared/battery20_percent.png",
|
50
|
-
30..39 => "./shared/battery30_percent.png",
|
51
|
-
40..49 => "./shared/battery40_percent.png",
|
52
|
-
50..59 => "./shared/battery50_percent.png",
|
53
|
-
60..69 => "./shared/battery60_percent.png",
|
54
|
-
70..79 => "./shared/battery70_percent.png",
|
55
|
-
80..89 => "./shared/battery80_percent.png",
|
56
|
-
90..99 => "./shared/battery90_percent.png",
|
57
|
-
100..100 => "./shared/battery100_percent.png",
|
91
|
+
100..100 => "./shared/battery100.png"
|
58
92
|
}
|
59
93
|
|
60
94
|
WIFI_IMAGES = {
|
61
|
-
0..0
|
62
|
-
1..25
|
63
|
-
26..50
|
64
|
-
59..75
|
65
|
-
76..200
|
95
|
+
0..0 => "./shared/wifi0.png",
|
96
|
+
1..25 => "./shared/wifi25.png",
|
97
|
+
26..50 => "./shared/wifi50.png",
|
98
|
+
59..75 => "./shared/wifi75.png",
|
99
|
+
76..200 => "./shared/wifi100.png"
|
66
100
|
}
|
67
101
|
|
68
102
|
MOBILE_IMAGES = {
|
69
|
-
0..0
|
70
|
-
1..20
|
71
|
-
21..40
|
72
|
-
41..60
|
73
|
-
61..80
|
74
|
-
81..200
|
103
|
+
0..0 => "./shared/mobile0.png",
|
104
|
+
1..20 => "./shared/mobile20.png",
|
105
|
+
21..40 => "./shared/mobile40.png",
|
106
|
+
41..60 => "./shared/mobile60.png",
|
107
|
+
61..80 => "./shared/mobile80.png",
|
108
|
+
81..200 => "./shared/mobile100.png"
|
75
109
|
}
|
76
110
|
|
77
111
|
class << self
|
@@ -92,7 +126,7 @@ module DaFunk
|
|
92
126
|
PAX::Display.print_status_bar(3, nil)
|
93
127
|
self.connected = false
|
94
128
|
else
|
95
|
-
change_message
|
129
|
+
self.change_message
|
96
130
|
end
|
97
131
|
end
|
98
132
|
|
@@ -128,8 +162,8 @@ module DaFunk
|
|
128
162
|
get_image_path(:gprs, self.signal))
|
129
163
|
elsif Device::Network.wifi?
|
130
164
|
Device::Display.print_status_bar(SLOT_MEDIA, "./shared/WIFI.png")
|
131
|
-
Device::Display.print_status_bar(SLOT_SIGNAL_LEVEL,
|
132
|
-
get_image_path(:wifi, self.signal))
|
165
|
+
Device::Display.print_status_bar(SLOT_SIGNAL_LEVEL,
|
166
|
+
self.get_image_path(:wifi, self.signal))
|
133
167
|
end
|
134
168
|
end
|
135
169
|
else
|
@@ -138,50 +172,74 @@ module DaFunk
|
|
138
172
|
end
|
139
173
|
end
|
140
174
|
|
175
|
+
# Updates the battery slot whenever a capacity or power supply change is
|
176
|
+
# detected.
|
141
177
|
def self.change_battery
|
142
|
-
|
143
|
-
|
178
|
+
capacity_type = Device::System.battery_capacity_type
|
179
|
+
|
180
|
+
capacity = Device::System.battery
|
181
|
+
charging = Device::System.power_supply
|
144
182
|
|
145
|
-
if self.battery !=
|
146
|
-
self.battery = bat
|
147
|
-
self.power = dock
|
183
|
+
if self.battery != capacity || self.power != charging
|
148
184
|
|
149
|
-
if self.
|
150
|
-
|
185
|
+
if self.battery.nil? # basic integrity check
|
186
|
+
self.battery = capacity
|
187
|
+
elsif charging
|
188
|
+
capacity >= self.battery && self.battery = capacity
|
151
189
|
else
|
152
|
-
|
153
|
-
|
190
|
+
capacity <= self.battery && self.battery = capacity
|
191
|
+
end
|
192
|
+
|
193
|
+
if self.power == charging && capacity != self.battery
|
194
|
+
return nil
|
154
195
|
end
|
155
196
|
|
156
|
-
|
157
|
-
|
158
|
-
|
197
|
+
self.power = charging
|
198
|
+
|
199
|
+
rsc = self.get_image_path(self.power ? :battery_charge : :battery, self.battery)
|
200
|
+
|
201
|
+
Device::Display.print_status_bar(SLOT_BATTERY_LEVEL, rsc)
|
202
|
+
|
203
|
+
if capacity_type == 'percentage' || !self.power
|
204
|
+
rsc = self.get_image_path(:battery_percentual, self.battery)
|
159
205
|
else
|
160
|
-
|
161
|
-
get_image_path(:battery, self.battery))
|
206
|
+
rsc = nil
|
162
207
|
end
|
208
|
+
|
209
|
+
Device::Display.print_status_bar(SLOT_BATTERY_PERCENTUAL, rsc)
|
163
210
|
end
|
164
211
|
end
|
165
212
|
|
213
|
+
# Searches for the correspondent image to 'type' and 'signal strength'.
|
166
214
|
def self.get_image_path(type, sig)
|
167
215
|
return if sig.nil?
|
168
216
|
case type
|
169
217
|
when :gprs
|
170
|
-
MOBILE_IMAGES.each
|
218
|
+
MOBILE_IMAGES.each do |k, v|
|
219
|
+
return v if k.include? sig
|
220
|
+
end
|
171
221
|
when :wifi
|
172
|
-
WIFI_IMAGES.each
|
222
|
+
WIFI_IMAGES.each do |k, v|
|
223
|
+
return v if k.include? sig
|
224
|
+
end
|
173
225
|
when :battery
|
174
|
-
BATTERY_IMAGES.each
|
226
|
+
BATTERY_IMAGES.each do |k, v|
|
227
|
+
return v if k.include? sig
|
228
|
+
end
|
175
229
|
when :battery_charge
|
176
|
-
|
230
|
+
if sig < 100
|
231
|
+
BATTERY_CHARGING[0]
|
232
|
+
else
|
233
|
+
BATTERY_CHARGING[1]
|
234
|
+
end
|
177
235
|
when :battery_percentual
|
178
|
-
BATTERY_PERCENTAGE_IMAGES
|
236
|
+
BATTERY_PERCENTAGE_IMAGES[sig]
|
179
237
|
else
|
180
238
|
nil
|
181
239
|
end
|
182
240
|
end
|
183
241
|
|
184
|
-
self.managment
|
242
|
+
self.managment ||= true
|
185
243
|
def self.valid?
|
186
244
|
if self.managment
|
187
245
|
true
|
@@ -190,4 +248,3 @@ module DaFunk
|
|
190
248
|
end
|
191
249
|
end
|
192
250
|
end
|
193
|
-
|
data/lib/da_funk/rake_task.rb
CHANGED
@@ -31,7 +31,7 @@ module DaFunk
|
|
31
31
|
@resources_out ||= @resources.pathmap("%{resources,#{File.join(root_path, "out")}}p")
|
32
32
|
@tests_res_out ||= @tests_resources.pathmap("%{test/resources,out}p")
|
33
33
|
@mruby ||= "cloudwalk run -b"
|
34
|
-
@mrbc
|
34
|
+
@mrbc = get_mrbc_bin(@mrbc)
|
35
35
|
|
36
36
|
define
|
37
37
|
end
|
@@ -44,14 +44,21 @@ module DaFunk
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
+
# Searches for a mrbc binary.
|
47
48
|
def get_mrbc_bin(from_user)
|
48
|
-
|
49
|
+
device = "/dev/null"
|
50
|
+
|
51
|
+
if %w[i386-mingw32 x64-mingw32].include?(RUBY_PLATFORM) && !ENV['SHELL']
|
52
|
+
device = "NUL" # Windows Command Prompt
|
53
|
+
end
|
54
|
+
|
55
|
+
if !system("type mrbc > #{device} 2>&1") && from_user
|
49
56
|
from_user
|
50
|
-
elsif system("type mrbc >
|
57
|
+
elsif system("type mrbc > #{device} 2>&1")
|
51
58
|
"env mrbc"
|
52
59
|
elsif ENV["MRBC"]
|
53
60
|
ENV["MRBC"]
|
54
|
-
elsif system("type cloudwalk >
|
61
|
+
elsif system("type cloudwalk > #{device} 2>&1")
|
55
62
|
"env cloudwalk compile"
|
56
63
|
else
|
57
64
|
puts "$MRBC isn't set or mrbc/cloudwalk isn't on $PATH"
|
@@ -64,7 +71,7 @@ module DaFunk
|
|
64
71
|
command_line = File.join(File.dirname(__FILE__), "..", "..", "utils", "command_line_platform.rb")
|
65
72
|
command_line_obj = File.join(root_path, "out", "main", "command_line_platform.mrb")
|
66
73
|
all_files = FileList["test/test_helper.rb"] + libs + files + [command_line] + [File.join(File.dirname(__FILE__), "..", "..", "utils", "test_run.rb")]
|
67
|
-
if platform_call("#{mrbc} -g -o #{command_line_obj} #{command_line}") && platform_call("#{mrbc} -g -o #{test_out} #{all_files.uniq}")
|
74
|
+
if platform_call("#{@mrbc} -g -o #{command_line_obj} #{command_line}") && platform_call("#{@mrbc} -g -o #{test_out} #{all_files.uniq}")
|
68
75
|
puts "cd #{File.dirname(out_path)}"
|
69
76
|
FileUtils.cd File.dirname(out_path)
|
70
77
|
platform_call("#{mruby} #{File.join(name, "test.mrb")}")
|
@@ -108,7 +115,7 @@ module DaFunk
|
|
108
115
|
|
109
116
|
desc "Compile app to mrb and process resources"
|
110
117
|
task :build => :resources do
|
111
|
-
platform_call "#{mrbc} #{debug_flag} -o #{main_out} #{libs} "
|
118
|
+
platform_call "#{@mrbc} #{debug_flag} -o #{main_out} #{libs} "
|
112
119
|
end
|
113
120
|
|
114
121
|
desc "Compile, build and pack app and resources"
|
data/lib/da_funk/version.rb
CHANGED
data/lib/device/display.rb
CHANGED
@@ -81,7 +81,8 @@ class Device
|
|
81
81
|
|
82
82
|
private
|
83
83
|
def self.main_image_format
|
84
|
-
|
84
|
+
major, min, patch = Device.version.to_s.split('.').map { |v| v.to_i }
|
85
|
+
if DaFunk::Transaction::Reversal.exists? && major >= 8
|
85
86
|
"main_#{Device::System.model}_reversal.bmp"
|
86
87
|
else
|
87
88
|
"main_#{Device::System.model}.bmp"
|
data/lib/device/system.rb
CHANGED
@@ -45,6 +45,15 @@ class Device
|
|
45
45
|
adapter.battery
|
46
46
|
end
|
47
47
|
|
48
|
+
# Checks the type of the battery capacity return (percentage or scale).
|
49
|
+
def self.battery_capacity_type
|
50
|
+
begin
|
51
|
+
adapter.battery_capacity_type
|
52
|
+
rescue StandardError => exception
|
53
|
+
'scale'
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
48
57
|
def self.beep
|
49
58
|
adapter.beep
|
50
59
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: da_funk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.31.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thiago Scalone
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-11-
|
11
|
+
date: 2020-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|