da_funk 3.17.0 → 3.21.1
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/Gemfile.lock +17 -12
- data/RELEASE_NOTES.md +40 -0
- data/Rakefile +2 -1
- data/lib/da_funk/helper.rb +53 -37
- data/lib/da_funk/helper/status_bar.rb +65 -39
- data/lib/da_funk/params_dat.rb +25 -19
- data/lib/da_funk/payment_channel.rb +36 -20
- data/lib/da_funk/version.rb +1 -1
- data/lib/device/runtime.rb +0 -1
- data/lib/device/virtual_keyboard.rb +187 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbb46ee9400d7652a74252864cfe292c4dd0ea5d96ef09bc53505812f7c75e11
|
4
|
+
data.tar.gz: 879162e1d06908fbabc24f462f47b365db1dbd8bed8fd66b3bdf4669de006f7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4607840b3eae2bdd4e02463d0b89ce6f6b599bb75d25f00e6d9158592384626b2597dd81c327ac12cfd8d67a9752c6d297864bd489421f2b7c56de05017e9ae8
|
7
|
+
data.tar.gz: 6bca8598d604b3c5532cb31e1ab64b5dc066be8e160be9ce28a5140a0b0c249082576e45d81751204ecc8160a7bab01ec0f7772cdadd655acce20bfc849a1595
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
da_funk (3.
|
4
|
+
da_funk (3.21.1)
|
5
5
|
archive-zip (~> 0.5)
|
6
6
|
bundler
|
7
7
|
cloudwalk_handshake
|
@@ -14,36 +14,41 @@ GEM
|
|
14
14
|
specs:
|
15
15
|
archive-zip (0.12.0)
|
16
16
|
io-like (~> 0.3.0)
|
17
|
-
ast (2.4.
|
17
|
+
ast (2.4.1)
|
18
18
|
cloudwalk (1.15.0)
|
19
19
|
bundler
|
20
20
|
rake
|
21
|
-
cloudwalk_handshake (1.13.
|
21
|
+
cloudwalk_handshake (1.13.1)
|
22
22
|
funky-simplehttp (~> 0.6)
|
23
|
-
funky-emv (1.
|
23
|
+
funky-emv (1.3.0)
|
24
24
|
funky-tlv (~> 0.2)
|
25
25
|
funky-mock (0.1.0)
|
26
26
|
funky-simplehttp (0.6.0)
|
27
27
|
funky-tlv (0.2.3)
|
28
28
|
io-like (0.3.1)
|
29
|
-
jaro_winkler (1.5.4)
|
30
29
|
parallel (1.19.1)
|
31
|
-
parser (2.7.
|
30
|
+
parser (2.7.1.3)
|
32
31
|
ast (~> 2.4.0)
|
33
32
|
posxml_parser (2.26.0)
|
34
33
|
funky-emv (~> 1)
|
35
34
|
rainbow (3.0.0)
|
36
35
|
rake (13.0.1)
|
37
|
-
|
38
|
-
|
36
|
+
regexp_parser (1.7.1)
|
37
|
+
rexml (3.2.4)
|
38
|
+
rubocop (0.85.1)
|
39
39
|
parallel (~> 1.10)
|
40
40
|
parser (>= 2.7.0.1)
|
41
41
|
rainbow (>= 2.2.2, < 4.0)
|
42
|
+
regexp_parser (>= 1.7)
|
43
|
+
rexml
|
44
|
+
rubocop-ast (>= 0.0.3)
|
42
45
|
ruby-progressbar (~> 1.7)
|
43
|
-
unicode-display_width (>= 1.4.0, <
|
46
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
47
|
+
rubocop-ast (0.0.3)
|
48
|
+
parser (>= 2.7.0.1)
|
44
49
|
ruby-progressbar (1.10.1)
|
45
|
-
unicode-display_width (1.
|
46
|
-
yard (0.9.
|
50
|
+
unicode-display_width (1.7.0)
|
51
|
+
yard (0.9.25)
|
47
52
|
|
48
53
|
PLATFORMS
|
49
54
|
ruby
|
@@ -59,4 +64,4 @@ DEPENDENCIES
|
|
59
64
|
yard
|
60
65
|
|
61
66
|
BUNDLED WITH
|
62
|
-
2.
|
67
|
+
2.1.4
|
data/RELEASE_NOTES.md
CHANGED
@@ -1,5 +1,45 @@
|
|
1
1
|
# DaFunk
|
2
2
|
|
3
|
+
### 3.21.1 - 2020-06-16
|
4
|
+
|
5
|
+
- Fix error when timeout on DaFunk::menu_image_touchscreen_or_keyboard.
|
6
|
+
|
7
|
+
### 3.21.0 - 2020-06-12
|
8
|
+
|
9
|
+
- Removed unnecessary processing method call;
|
10
|
+
- Status bar refactored:
|
11
|
+
- Removed link icon;
|
12
|
+
- Added support to SLOT_MEDIA to print WIFI or GPRS;
|
13
|
+
- Renamed SLOT_CONNECTION to SLOT_SIGNAL_LEVEL;
|
14
|
+
- Added support to SLOT_BATTERY_PERCENTUAL to print percentual of battery level;
|
15
|
+
- Renamed SLOT_BATTERY to SLOT_BATTERY_LEVEL;
|
16
|
+
- Update battery and wifi images;
|
17
|
+
- Added BATTERY_PERCENTAGE_IMAGES;
|
18
|
+
- Show searching icon when network is not connected;
|
19
|
+
- Added support to virtual keyboard;
|
20
|
+
- Added support to touchscreen event on DaFunk::Helper#menu;
|
21
|
+
- Added support to return timeout parameter on DaFunk::Helper#menu when timeout is achieved;
|
22
|
+
- Update funky-emv 1.3.0.
|
23
|
+
|
24
|
+
### 3.20.0 - 2020-05-28
|
25
|
+
|
26
|
+
- Rename PaymentChannel::client to ::current;
|
27
|
+
- Fix status bar change link to cache old value.
|
28
|
+
|
29
|
+
### 3.18.1 - 2020-05-20
|
30
|
+
|
31
|
+
- Fix issue on DaFunk::Helper#menu_image_touchscreen_or_keyboard it was not checking for special keys
|
32
|
+
|
33
|
+
### 3.18.0 - 2020-04-03
|
34
|
+
|
35
|
+
- Added enable_txt_ui parameter on the following methods
|
36
|
+
- DaFunk::ParamsDat#download;
|
37
|
+
- DaFunk::ParamsDat#update_apps;
|
38
|
+
- DaFunk::ParamsDat#update_app;
|
39
|
+
- DaFunk::ParamsDat#update_file;
|
40
|
+
- DaFunk::Helper#attach_options;
|
41
|
+
- DaFunk::Helper#check_download_error;
|
42
|
+
|
3
43
|
### 3.17.0 - 2020-02-10
|
4
44
|
|
5
45
|
- Added support to infinitepay endpoints config on config.dat file;
|
data/Rakefile
CHANGED
data/lib/da_funk/helper.rb
CHANGED
@@ -14,11 +14,11 @@ module DaFunk
|
|
14
14
|
string
|
15
15
|
end
|
16
16
|
|
17
|
-
def attach_options
|
18
|
-
if DaFunk::PaymentChannel.
|
19
|
-
{:print_last => true}
|
17
|
+
def attach_options(enable_txt_ui = true)
|
18
|
+
if DaFunk::PaymentChannel.current == Context::CommunicationChannel
|
19
|
+
{:print_last => true, :enable_txt_ui => enable_txt_ui}
|
20
20
|
else
|
21
|
-
{:print_last => false}
|
21
|
+
{:print_last => false, :enable_txt_ui => enable_txt_ui}
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -35,55 +35,63 @@ module DaFunk
|
|
35
35
|
|
36
36
|
def attach(options = attach_options)
|
37
37
|
if Device::Network.configured?
|
38
|
-
print_attach(:attach_connecting, options)
|
38
|
+
print_attach(:attach_connecting, options) if options[:enable_txt_ui]
|
39
39
|
unless Device::Network.connected?
|
40
40
|
if Device::Network.attach(options) == Device::Network::SUCCESS
|
41
41
|
Device::Setting.network_configured = 1
|
42
|
-
print_attach(:attach_connected, options)
|
42
|
+
print_attach(:attach_connected, options) if options[:enable_txt_ui]
|
43
43
|
else
|
44
44
|
Device::Setting.network_configured = 0 if DaFunk::ParamsDat.file["connection_management"] == "0"
|
45
|
-
|
46
|
-
|
45
|
+
if options[:enable_txt_ui]
|
46
|
+
print_attach(:attach_fail, options.merge(:args => [Device::Network.code.to_s]))
|
47
|
+
getc(10000)
|
48
|
+
end
|
47
49
|
return false
|
48
50
|
end
|
49
51
|
else
|
50
|
-
print_attach(:attach_already_connected, options)
|
52
|
+
print_attach(:attach_already_connected, options) if options[:enable_txt_ui]
|
51
53
|
end
|
52
54
|
true
|
53
55
|
else
|
54
|
-
|
55
|
-
|
56
|
+
if options[:enable_txt_ui]
|
57
|
+
print_attach(:attach_device_not_configured, options)
|
58
|
+
getc(2000)
|
59
|
+
end
|
56
60
|
false
|
57
61
|
end
|
58
62
|
end
|
59
63
|
|
60
|
-
def check_download_error(ret)
|
64
|
+
def check_download_error(ret, enable_txt_ui = true)
|
61
65
|
value = true
|
66
|
+
ui = {}
|
67
|
+
|
62
68
|
case ret
|
63
69
|
when DaFunk::Transaction::Download::SERIAL_NUMBER_NOT_FOUND
|
64
|
-
|
70
|
+
ui[:i18n] = :download_serial_number_not_found
|
65
71
|
value = false
|
66
72
|
when DaFunk::Transaction::Download::FILE_NOT_FOUND
|
67
|
-
|
73
|
+
ui[:i18n] = :download_file_not_found
|
68
74
|
value = false
|
69
75
|
when DaFunk::Transaction::Download::FILE_NOT_CHANGE
|
70
|
-
|
76
|
+
ui[:i18n] = :download_file_is_the_same
|
71
77
|
when DaFunk::Transaction::Download::SUCCESS
|
72
|
-
|
78
|
+
ui[:i18n] = :download_success
|
73
79
|
when DaFunk::Transaction::Download::COMMUNICATION_ERROR
|
74
|
-
|
80
|
+
ui[:i18n] = :download_communication_failure
|
75
81
|
value = false
|
76
82
|
when DaFunk::Transaction::Download::MAPREDUCE_RESPONSE_ERROR
|
77
|
-
|
83
|
+
ui[:i18n] = :download_encoding_error
|
78
84
|
value = false
|
79
85
|
when DaFunk::Transaction::Download::IO_ERROR
|
80
|
-
|
86
|
+
ui[:i18n] = :download_io_error
|
81
87
|
value = false
|
82
88
|
else
|
83
|
-
|
89
|
+
ui[:i18n] = :download_communication_failure
|
84
90
|
value = false
|
85
91
|
end
|
86
92
|
|
93
|
+
I18n.pt(ui[:i18n], :args => [ret]) if enable_txt_ui
|
94
|
+
|
87
95
|
value
|
88
96
|
end
|
89
97
|
|
@@ -171,26 +179,34 @@ module DaFunk
|
|
171
179
|
# menu_image_touchscreen_or_keyboard('image.bmp', menu_itens, options)
|
172
180
|
#
|
173
181
|
# @return menu_item_index selected will be returned
|
174
|
-
# @return if timeout
|
182
|
+
# @return if timeout Device::IO::KEY_TIMEOUT will be returned
|
175
183
|
def menu_image_touchscreen_or_keyboard(path, menu_itens, options = {})
|
176
184
|
return nil if menu_itens.empty?
|
177
185
|
|
178
186
|
Device::Display.print_bitmap(path)
|
179
|
-
|
180
187
|
timeout = options[:timeout] || Device::IO.timeout
|
181
|
-
|
188
|
+
|
189
|
+
if options.include?(:special_keys)
|
190
|
+
options[:special_keys] += options[:special_keys]
|
191
|
+
else
|
192
|
+
options[:special_keys] = [Device::IO::CANCEL]
|
193
|
+
end
|
182
194
|
|
183
195
|
event, key = wait_touchscreen_or_keyboard_event(menu_itens, timeout, options)
|
184
196
|
|
185
197
|
if event == :keyboard
|
186
198
|
if key == Device::IO::CANCEL
|
187
199
|
options[:default]
|
200
|
+
elsif options[:special_keys].include?(key)
|
201
|
+
key
|
188
202
|
else
|
189
203
|
index = key.to_i-1 == -1 ? 0 : key.to_i-1
|
190
204
|
menu_itens.keys[index]
|
191
205
|
end
|
192
206
|
elsif event == :touchscreen
|
193
207
|
menu_itens.select {|k, v| k == key}.shift[0]
|
208
|
+
elsif event == :timeout
|
209
|
+
Device::IO::KEY_TIMEOUT
|
194
210
|
end
|
195
211
|
end
|
196
212
|
|
@@ -282,6 +298,8 @@ module DaFunk
|
|
282
298
|
|
283
299
|
if key == Device::IO::ENTER
|
284
300
|
options[:default]
|
301
|
+
elsif key == Device::IO::KEY_TIMEOUT
|
302
|
+
options[:timeout]
|
285
303
|
else
|
286
304
|
selected
|
287
305
|
end
|
@@ -289,7 +307,10 @@ module DaFunk
|
|
289
307
|
|
290
308
|
# TODO Scalone: Refactor.
|
291
309
|
def pagination(title, options, collection, &block)
|
310
|
+
timeout = Device::IO.timeout
|
311
|
+
touchscreen_options = {}
|
292
312
|
start_line, options[:limit], options[:header] = pagination_limit(title, options)
|
313
|
+
|
293
314
|
if collection.size > (options[:limit] - options[:header]) # minus pagination header
|
294
315
|
key = Device::IO.back_key
|
295
316
|
pages = pagination_page(collection, options[:limit] - options[:header]) # minus pagination header
|
@@ -299,7 +320,13 @@ module DaFunk
|
|
299
320
|
pagination_header(title, page, pages.size, start_line, options[:default], options[:header])
|
300
321
|
values = pages[page].to_a
|
301
322
|
block.call(values, start_line + options[:header])
|
302
|
-
|
323
|
+
|
324
|
+
params = {special_keys: pagination_keys(values.size, true)}
|
325
|
+
if options.include?(:touchscreen_options)
|
326
|
+
touchscreen_options = options[:touchscreen_options]
|
327
|
+
end
|
328
|
+
|
329
|
+
_, key = wait_touchscreen_or_keyboard_event(touchscreen_options, timeout, params)
|
303
330
|
page = pagination_key_page(page, key, pages.size)
|
304
331
|
end
|
305
332
|
else
|
@@ -307,7 +334,8 @@ module DaFunk
|
|
307
334
|
print_title(title, options[:default]) if title
|
308
335
|
values = collection.to_a
|
309
336
|
block.call(values, start_line)
|
310
|
-
|
337
|
+
params = {special_keys: pagination_keys(collection.size, false)}
|
338
|
+
_, key = wait_touchscreen_or_keyboard_event(touchscreen_options, timeout, params)
|
311
339
|
end
|
312
340
|
result = values[key.to_i-1] if key.integer?
|
313
341
|
if result.is_a? Array
|
@@ -427,18 +455,6 @@ module DaFunk
|
|
427
455
|
end
|
428
456
|
end
|
429
457
|
|
430
|
-
def processing(image, message = {})
|
431
|
-
Device::Display.print_bitmap(to_bmp(image)) if bmp_exists?(image)
|
432
|
-
end
|
433
|
-
|
434
|
-
def bmp_exists?(bmp)
|
435
|
-
File.exists?(to_bmp(bmp))
|
436
|
-
end
|
437
|
-
|
438
|
-
def to_bmp(image)
|
439
|
-
"./shared/#{image.to_s}.bmp"
|
440
|
-
end
|
441
|
-
|
442
458
|
private
|
443
459
|
def parse_touchscreen_event(menu_itens, x, y)
|
444
460
|
menu_itens.each do |key, value|
|
@@ -1,18 +1,26 @@
|
|
1
1
|
module DaFunk
|
2
2
|
module Helper
|
3
3
|
class StatusBar
|
4
|
-
STATUS_TIMEOUT
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
STATUS_TIMEOUT = 60
|
5
|
+
SLOT_MEDIA = 0
|
6
|
+
SLOT_SIGNAL_LEVEL = 1
|
7
|
+
SLOT_UPDATE = 2
|
8
|
+
SLOT_BATTERY_PERCENTUAL = 6
|
9
|
+
SLOT_BATTERY_LEVEL = 7
|
9
10
|
|
10
11
|
BATTERY_IMAGES = {
|
11
|
-
0..
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
0..4 => "./shared/battery0.png",
|
13
|
+
5..9 => "./shared/baterry5.png",
|
14
|
+
10..19 => "./shared/battery10.png",
|
15
|
+
20..29 => "./shared/battery20.png",
|
16
|
+
30..39 => "./shared/battery30.png",
|
17
|
+
40..49 => "./shared/battery40.png",
|
18
|
+
50..59 => "./shared/battery50.png",
|
19
|
+
60..69 => "./shared/battery60.png",
|
20
|
+
70..79 => "./shared/battery70.png",
|
21
|
+
80..89 => "./shared/battery80.png",
|
22
|
+
90..99 => "./shared/battery90.png",
|
23
|
+
100..100 => "./shared/battery100.png",
|
16
24
|
}
|
17
25
|
|
18
26
|
BATTERY_CHARGE_IMAGES = {
|
@@ -20,11 +28,27 @@ module DaFunk
|
|
20
28
|
100 => "./shared/battery100c.png"
|
21
29
|
}
|
22
30
|
|
31
|
+
BATTERY_PERCENTAGE_IMAGES = {
|
32
|
+
0..4 => "./shared/battery1_percent.png",
|
33
|
+
5..9 => "./shared/battery5_percent.png",
|
34
|
+
10..19 => "./shared/battery10_percent.png",
|
35
|
+
20..29 => "./shared/battery20_percent.png",
|
36
|
+
30..39 => "./shared/battery30_percent.png",
|
37
|
+
40..49 => "./shared/battery40_percent.png",
|
38
|
+
50..59 => "./shared/battery50_percent.png",
|
39
|
+
60..69 => "./shared/battery60_percent.png",
|
40
|
+
70..79 => "./shared/battery70_percent.png",
|
41
|
+
80..89 => "./shared/battery80_percent.png",
|
42
|
+
90..99 => "./shared/battery90_percent.png",
|
43
|
+
100..100 => "./shared/battery100_percent.png",
|
44
|
+
}
|
45
|
+
|
23
46
|
WIFI_IMAGES = {
|
24
|
-
0..
|
25
|
-
|
26
|
-
|
27
|
-
|
47
|
+
0..0 => "./shared/wifi0.png",
|
48
|
+
1..25 => "./shared/wifi25.png",
|
49
|
+
26..50 => "./shared/wifi50.png",
|
50
|
+
59..75 => "./shared/wifi75.png",
|
51
|
+
76..200 => "./shared/wifi100.png"
|
28
52
|
}
|
29
53
|
|
30
54
|
MOBILE_IMAGES = {
|
@@ -37,14 +61,13 @@ module DaFunk
|
|
37
61
|
}
|
38
62
|
|
39
63
|
class << self
|
40
|
-
attr_accessor :signal, :battery, :power, :managment
|
64
|
+
attr_accessor :signal, :battery, :power, :managment
|
41
65
|
end
|
42
66
|
|
43
67
|
def self.check
|
44
68
|
if self.valid?
|
45
69
|
self.change_connection
|
46
70
|
self.change_battery
|
47
|
-
self.change_link
|
48
71
|
self.change_update
|
49
72
|
end
|
50
73
|
end
|
@@ -57,44 +80,45 @@ module DaFunk
|
|
57
80
|
end
|
58
81
|
end
|
59
82
|
|
60
|
-
def self.
|
83
|
+
def self.change_connection
|
61
84
|
if Device::Network.connected?
|
62
|
-
|
63
|
-
PAX::Display.print_status_bar(SLOT_LINK, "./shared/link.png")
|
64
|
-
else
|
65
|
-
PAX::Display.print_status_bar(SLOT_LINK, "./shared/unlink.png")
|
66
|
-
end
|
67
|
-
else
|
68
|
-
PAX::Display.print_status_bar(SLOT_LINK, "./shared/unlink.png")
|
69
|
-
end
|
70
|
-
end
|
85
|
+
sig = Device::Network.signal
|
71
86
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
87
|
+
if self.signal != sig
|
88
|
+
self.signal = sig
|
89
|
+
|
90
|
+
if Device::Network.gprs?
|
91
|
+
Device::Display.print_status_bar(SLOT_MEDIA, "./shared/GPRS.png")
|
92
|
+
Device::Display.print_status_bar(SLOT_SIGNAL_LEVEL,
|
93
|
+
get_image_path(:gprs, self.signal))
|
94
|
+
elsif Device::Network.wifi?
|
95
|
+
Device::Display.print_status_bar(SLOT_MEDIA, "./shared/WIFI.png")
|
96
|
+
Device::Display.print_status_bar(SLOT_SIGNAL_LEVEL,
|
97
|
+
get_image_path(:wifi, self.signal))
|
98
|
+
end
|
82
99
|
end
|
100
|
+
else
|
101
|
+
Device::Display.print_status_bar(SLOT_MEDIA, nil)
|
102
|
+
Device::Display.print_status_bar(SLOT_SIGNAL_LEVEL, "./shared/searching.png")
|
83
103
|
end
|
84
104
|
end
|
85
105
|
|
86
106
|
def self.change_battery
|
87
107
|
bat = Device::System.battery
|
88
108
|
dock = Device::System.power_supply
|
109
|
+
|
89
110
|
if self.battery != bat || self.power != dock
|
90
111
|
self.battery = bat
|
91
112
|
self.power = dock
|
113
|
+
|
114
|
+
Device::Display.print_status_bar(SLOT_BATTERY_PERCENTUAL,
|
115
|
+
get_image_path(:battery_percentual, self.battery))
|
92
116
|
if self.power
|
93
117
|
Device::Display.print_status_bar(
|
94
|
-
|
118
|
+
SLOT_BATTERY_LEVEL, get_image_path(:battery_charge, self.battery))
|
95
119
|
else
|
96
|
-
Device::Display.print_status_bar(
|
97
|
-
|
120
|
+
Device::Display.print_status_bar(SLOT_BATTERY_LEVEL,
|
121
|
+
get_image_path(:battery, self.battery))
|
98
122
|
end
|
99
123
|
end
|
100
124
|
end
|
@@ -110,6 +134,8 @@ module DaFunk
|
|
110
134
|
BATTERY_IMAGES.each {|k,v| return v if k.include? sig }
|
111
135
|
when :battery_charge
|
112
136
|
BATTERY_CHARGE_IMAGES[sig]
|
137
|
+
when :battery_percentual
|
138
|
+
BATTERY_PERCENTAGE_IMAGES.each {|k,v| return v if k.include? sig }
|
113
139
|
else
|
114
140
|
nil
|
115
141
|
end
|
data/lib/da_funk/params_dat.rb
CHANGED
@@ -104,15 +104,17 @@ module DaFunk
|
|
104
104
|
nil
|
105
105
|
end
|
106
106
|
|
107
|
-
def self.download
|
108
|
-
if attach
|
107
|
+
def self.download(enable_txt_ui = true)
|
108
|
+
if attach(attach_options(enable_txt_ui))
|
109
109
|
parse
|
110
110
|
ret = try(3) do |attempt|
|
111
|
-
|
112
|
-
|
111
|
+
if enable_txt_ui
|
112
|
+
Device::Display.clear
|
113
|
+
I18n.pt(:downloading_content, :args => ["PARAMS", 1, 1])
|
114
|
+
end
|
113
115
|
getc(100)
|
114
116
|
ret = DaFunk::Transaction::Download.request_param_file(FILE_NAME)
|
115
|
-
unless check_download_error(ret)
|
117
|
+
unless check_download_error(ret, enable_txt_ui)
|
116
118
|
getc(2000)
|
117
119
|
false
|
118
120
|
else
|
@@ -124,21 +126,21 @@ module DaFunk
|
|
124
126
|
end
|
125
127
|
end
|
126
128
|
|
127
|
-
def self.update_apps(force_params = false, force_crc = false, force = false)
|
128
|
-
self.download if force_params || ! self.valid
|
129
|
+
def self.update_apps(force_params = false, force_crc = false, force = false, enable_txt_ui = true)
|
130
|
+
self.download(enable_txt_ui) if force_params || ! self.valid
|
129
131
|
main_updated = nil
|
130
132
|
if self.valid
|
131
133
|
apps_to_update = self.outdated_apps(force_crc, force)
|
132
134
|
size_apps = apps_to_update.size
|
133
135
|
apps_to_update.each_with_index do |app, index|
|
134
|
-
ret = self.update_app(app, index+1, size_apps, force_crc || force)
|
136
|
+
ret = self.update_app(app, index+1, size_apps, force_crc || force, enable_txt_ui)
|
135
137
|
main_updated ||= (ret && app.main_application?)
|
136
138
|
end
|
137
139
|
|
138
140
|
files_to_update = self.outdated_files(force_crc, force)
|
139
141
|
size_files = files_to_update.size
|
140
142
|
files_to_update.each_with_index do |file_, index|
|
141
|
-
self.update_file(file_, index+1, size_files, force_crc || force)
|
143
|
+
self.update_file(file_, index+1, size_files, force_crc || force, enable_txt_ui)
|
142
144
|
end
|
143
145
|
end
|
144
146
|
ensure
|
@@ -179,26 +181,30 @@ module DaFunk
|
|
179
181
|
File.file?(path) && ! keep
|
180
182
|
end
|
181
183
|
|
182
|
-
def self.update_app(application, index = 1, all = 1, force = false)
|
183
|
-
if attach && application
|
184
|
+
def self.update_app(application, index = 1, all = 1, force = false, enable_txt_ui = true)
|
185
|
+
if attach(attach_options(enable_txt_ui)) && application
|
184
186
|
try(3) do |attempt|
|
185
|
-
|
186
|
-
|
187
|
+
if enable_txt_ui
|
188
|
+
Device::Display.clear
|
189
|
+
I18n.pt(:downloading_content, :args => [I18n.t(:apps), index, all])
|
190
|
+
end
|
187
191
|
getc(100)
|
188
|
-
ret = check_download_error(application.download(force))
|
192
|
+
ret = check_download_error(application.download(force), enable_txt_ui)
|
189
193
|
getc(1000)
|
190
194
|
ret
|
191
195
|
end
|
192
196
|
end
|
193
197
|
end
|
194
198
|
|
195
|
-
def self.update_file(file_parameter, index = 1, all = 1, force = false)
|
196
|
-
if attach && file_parameter
|
199
|
+
def self.update_file(file_parameter, index = 1, all = 1, force = false, enable_txt_ui = true)
|
200
|
+
if attach(attach_options(enable_txt_ui)) && file_parameter
|
197
201
|
try(3) do |attempt|
|
198
|
-
|
199
|
-
|
202
|
+
if enable_txt_ui
|
203
|
+
Device::Display.clear
|
204
|
+
I18n.pt(:downloading_content, :args => [I18n.t(:files), index, all])
|
205
|
+
end
|
200
206
|
getc(100)
|
201
|
-
ret = check_download_error(file_parameter.download(force))
|
207
|
+
ret = check_download_error(file_parameter.download(force), enable_txt_ui)
|
202
208
|
file_parameter.unzip if ret
|
203
209
|
getc(1000)
|
204
210
|
ret
|
@@ -3,11 +3,29 @@ module DaFunk
|
|
3
3
|
DEFAULT_HEARBEAT = "180"
|
4
4
|
|
5
5
|
class << self
|
6
|
-
attr_accessor :
|
6
|
+
attr_accessor :current, :app
|
7
7
|
end
|
8
8
|
|
9
9
|
attr_accessor :handshake_response, :handshake_request, :client, :host, :port
|
10
10
|
|
11
|
+
# Backward compatibility
|
12
|
+
def self.client
|
13
|
+
self.current
|
14
|
+
end
|
15
|
+
|
16
|
+
# Backward compatibility
|
17
|
+
def self.client=(obj)
|
18
|
+
self.current = obj
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.current
|
22
|
+
@current
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.current=(obj)
|
26
|
+
@current = obj
|
27
|
+
end
|
28
|
+
|
11
29
|
def self.ready?
|
12
30
|
Device::Network.connected? && self.configured?
|
13
31
|
end
|
@@ -22,8 +40,8 @@ module DaFunk
|
|
22
40
|
if @app != application
|
23
41
|
@app = application
|
24
42
|
# if Context::CommunicationChannel send application name thought threads
|
25
|
-
if
|
26
|
-
|
43
|
+
if self.current == Context::CommunicationChannel
|
44
|
+
self.current.app = application
|
27
45
|
else
|
28
46
|
Device::System.klass = application
|
29
47
|
end
|
@@ -48,11 +66,11 @@ module DaFunk
|
|
48
66
|
self.print_info(I18n.t(:attach_attaching), display_message)
|
49
67
|
create
|
50
68
|
self.print_info(I18n.t(:attach_authenticate), display_message)
|
51
|
-
|
69
|
+
self.current.handshake
|
52
70
|
else
|
53
71
|
client_clear!
|
54
72
|
end
|
55
|
-
|
73
|
+
self.current
|
56
74
|
end
|
57
75
|
|
58
76
|
def self.payment_channel_limit?
|
@@ -84,18 +102,16 @@ module DaFunk
|
|
84
102
|
if self.dead?
|
85
103
|
unless self.channel_limit_exceed?
|
86
104
|
PaymentChannel.connect(display_message)
|
87
|
-
if
|
105
|
+
if self.current
|
88
106
|
self.print_info(I18n.t(:attach_waiting), display_message)
|
89
|
-
if message =
|
107
|
+
if message = self.current.check || self.current.handshake?
|
90
108
|
self.print_info(I18n.t(:attach_connected), display_message)
|
91
109
|
message
|
92
110
|
end
|
93
111
|
end
|
94
112
|
end
|
95
113
|
else
|
96
|
-
|
97
|
-
@client.check
|
98
|
-
end
|
114
|
+
self.current&.check
|
99
115
|
end
|
100
116
|
end
|
101
117
|
|
@@ -104,11 +120,11 @@ module DaFunk
|
|
104
120
|
end
|
105
121
|
|
106
122
|
def self.alive?
|
107
|
-
Device::Network.connected? &&
|
123
|
+
Device::Network.connected? && self.current&.connected?
|
108
124
|
end
|
109
125
|
|
110
126
|
def self.close!
|
111
|
-
|
127
|
+
self.current&.close
|
112
128
|
ensure
|
113
129
|
client_clear!
|
114
130
|
end
|
@@ -133,16 +149,16 @@ module DaFunk
|
|
133
149
|
end
|
134
150
|
|
135
151
|
def self.create
|
136
|
-
if
|
152
|
+
if self.current != Context::CommunicationChannel
|
137
153
|
payment_channel_increment_attempts
|
138
|
-
|
154
|
+
self.current = PaymentChannel.new
|
139
155
|
else
|
140
|
-
|
156
|
+
self.current.connect
|
141
157
|
end
|
142
158
|
end
|
143
159
|
|
144
160
|
def self.client_clear!
|
145
|
-
|
161
|
+
self.current = nil unless self.current == Context::CommunicationChannel
|
146
162
|
end
|
147
163
|
|
148
164
|
def initialize(client = nil)
|
@@ -180,13 +196,13 @@ module DaFunk
|
|
180
196
|
end
|
181
197
|
|
182
198
|
def close
|
183
|
-
@client
|
199
|
+
@client&.close
|
184
200
|
@client = nil
|
185
|
-
PaymentChannel.
|
201
|
+
PaymentChannel.current = nil
|
186
202
|
end
|
187
203
|
|
188
204
|
def connected?
|
189
|
-
self.client
|
205
|
+
self.client&.connected?
|
190
206
|
end
|
191
207
|
|
192
208
|
def handshake?
|
@@ -215,7 +231,7 @@ module DaFunk
|
|
215
231
|
if Context.development?
|
216
232
|
ContextLog.exception(exception, exception.backtrace, "PaymentChannel error")
|
217
233
|
end
|
218
|
-
PaymentChannel.
|
234
|
+
PaymentChannel.current = nil
|
219
235
|
@client = nil
|
220
236
|
end
|
221
237
|
|
data/lib/da_funk/version.rb
CHANGED
data/lib/device/runtime.rb
CHANGED
@@ -14,7 +14,6 @@ class Device
|
|
14
14
|
# @param json [String] Parameters to confifure new aplication.
|
15
15
|
# @return [Object] From the new runtime instance.
|
16
16
|
def self.execute(app, json = nil)
|
17
|
-
processing(:processing)
|
18
17
|
buf = "#{json.dup}" if json.is_a?(String)
|
19
18
|
mrb_eval("Context.execute('#{app.dup}', '#{Device.adapter}', '#{buf}')", "#{app.dup}")
|
20
19
|
ensure
|
@@ -0,0 +1,187 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Device
|
4
|
+
class VirtualKeyboard
|
5
|
+
class << self
|
6
|
+
attr_accessor :attributes, :type, :text
|
7
|
+
end
|
8
|
+
|
9
|
+
self.attributes = {
|
10
|
+
keyboard_capital: [
|
11
|
+
{ x: 0..34, y: 191..209, char: 'q' },
|
12
|
+
{ x: 0..46, y: 191..209, char: 'w' },
|
13
|
+
{ x: 0..65, y: 191..209, char: 'e' },
|
14
|
+
{ x: 0..96, y: 191..209, char: 'r' },
|
15
|
+
{ x: 0..115, y: 191..209, char: 't' },
|
16
|
+
{ x: 0..145, y: 191..209, char: 'y' },
|
17
|
+
{ x: 0..161, y: 191..209, char: 'u' },
|
18
|
+
{ x: 0..191, y: 191..209, char: 'i' },
|
19
|
+
{ x: 0..216, y: 191..209, char: 'o' },
|
20
|
+
{ x: 0..255, y: 191..209, char: 'p' },
|
21
|
+
{ x: 0..34, y: 223..241, char: 'a' },
|
22
|
+
{ x: 0..59, y: 223..241, char: 's' },
|
23
|
+
{ x: 0..83, y: 223..241, char: 'd' },
|
24
|
+
{ x: 0..106, y: 223..241, char: 'f' },
|
25
|
+
{ x: 0..131, y: 223..241, char: 'g' },
|
26
|
+
{ x: 0..153, y: 223..241, char: 'h' },
|
27
|
+
{ x: 0..178, y: 223..241, char: 'j' },
|
28
|
+
{ x: 0..201, y: 223..241, char: 'k' },
|
29
|
+
{ x: 0..230, y: 223..241, char: 'l' },
|
30
|
+
{ x: 0..30, y: 223..273, char: :keyboard_uppercase },
|
31
|
+
{ x: 0..56, y: 223..273, char: 'y' },
|
32
|
+
{ x: 0..82, y: 223..273, char: 'x' },
|
33
|
+
{ x: 0..109, y: 223..273, char: 'c' },
|
34
|
+
{ x: 0..130, y: 223..273, char: 'v' },
|
35
|
+
{ x: 0..154, y: 223..273, char: 'b' },
|
36
|
+
{ x: 0..176, y: 223..273, char: 'n' },
|
37
|
+
{ x: 0..201, y: 223..273, char: 'm' },
|
38
|
+
{ x: 0..240, y: 223..273, char: :erase },
|
39
|
+
{ x: 0..34, y: 223..315, char: :keyboard_symbol_number },
|
40
|
+
{ x: 0..58, y: 223..315, char: '@' },
|
41
|
+
{ x: 0..83, y: 223..315, char: ',' },
|
42
|
+
{ x: 0..148, y: 223..315, char: :space },
|
43
|
+
{ x: 0..177, y: 223..315, char: '.' },
|
44
|
+
{ x: 0..255, y: 223..315, char: :enter }
|
45
|
+
],
|
46
|
+
|
47
|
+
keyboard_uppercase: [
|
48
|
+
{ x: 0..34, y: 191..209, char: 'Q' },
|
49
|
+
{ x: 0..46, y: 191..209, char: 'W' },
|
50
|
+
{ x: 0..65, y: 191..209, char: 'E' },
|
51
|
+
{ x: 0..96, y: 191..209, char: 'R' },
|
52
|
+
{ x: 0..115, y: 191..209, char: 'T' },
|
53
|
+
{ x: 0..145, y: 191..209, char: 'Y' },
|
54
|
+
{ x: 0..161, y: 191..209, char: 'U' },
|
55
|
+
{ x: 0..191, y: 191..209, char: 'I' },
|
56
|
+
{ x: 0..216, y: 191..209, char: 'O' },
|
57
|
+
{ x: 0..255, y: 191..209, char: 'P' },
|
58
|
+
{ x: 0..34, y: 223..241, char: 'A' },
|
59
|
+
{ x: 0..59, y: 223..241, char: 'S' },
|
60
|
+
{ x: 0..83, y: 223..241, char: 'D' },
|
61
|
+
{ x: 0..106, y: 223..241, char: 'F' },
|
62
|
+
{ x: 0..131, y: 223..241, char: 'G' },
|
63
|
+
{ x: 0..153, y: 223..241, char: 'H' },
|
64
|
+
{ x: 0..178, y: 223..241, char: 'J' },
|
65
|
+
{ x: 0..201, y: 223..241, char: 'K' },
|
66
|
+
{ x: 0..230, y: 223..241, char: 'L' },
|
67
|
+
{ x: 0..30, y: 223..273, char: :keyboard_capital },
|
68
|
+
{ x: 0..56, y: 223..273, char: 'Y' },
|
69
|
+
{ x: 0..82, y: 223..273, char: 'X' },
|
70
|
+
{ x: 0..109, y: 223..273, char: 'C' },
|
71
|
+
{ x: 0..130, y: 223..273, char: 'V' },
|
72
|
+
{ x: 0..154, y: 223..273, char: 'B' },
|
73
|
+
{ x: 0..176, y: 223..273, char: 'N' },
|
74
|
+
{ x: 0..201, y: 223..273, char: 'M' },
|
75
|
+
{ x: 0..240, y: 223..273, char: :erase },
|
76
|
+
{ x: 0..34, y: 223..315, char: :keyboard_symbol_number },
|
77
|
+
{ x: 0..58, y: 223..315, char: '@' },
|
78
|
+
{ x: 0..83, y: 223..315, char: ',' },
|
79
|
+
{ x: 0..148, y: 223..315, char: :space },
|
80
|
+
{ x: 0..177, y: 223..315, char: '.' },
|
81
|
+
{ x: 0..255, y: 223..315, char: :enter }
|
82
|
+
],
|
83
|
+
|
84
|
+
keyboard_symbol_number: [
|
85
|
+
{ x: 0..35, y: 190..210, char: '(' },
|
86
|
+
{ x: 0..68, y: 190..210, char: ')' },
|
87
|
+
{ x: 0..104, y: 190..210, char: '1' },
|
88
|
+
{ x: 0..138, y: 190..210, char: '2' },
|
89
|
+
{ x: 0..169, y: 190..210, char: '3' },
|
90
|
+
{ x: 0..203, y: 190..210, char: '+' },
|
91
|
+
{ x: 0..239, y: 190..210, char: '-' },
|
92
|
+
{ x: 0..35, y: 220..245, char: '?' },
|
93
|
+
{ x: 0..68, y: 220..245, char: '$' },
|
94
|
+
{ x: 0..104, y: 220..245, char: '4' },
|
95
|
+
{ x: 0..138, y: 220..245, char: '5' },
|
96
|
+
{ x: 0..169, y: 220..245, char: '6' },
|
97
|
+
{ x: 0..203, y: 220..245, char: '*' },
|
98
|
+
{ x: 0..239, y: 220..245, char: '/' },
|
99
|
+
{ x: 0..35, y: 255..275, char: '!' },
|
100
|
+
{ x: 0..68, y: 255..275, char: ';' },
|
101
|
+
{ x: 0..104, y: 255..275, char: '7' },
|
102
|
+
{ x: 0..138, y: 255..275, char: '8' },
|
103
|
+
{ x: 0..169, y: 255..275, char: '9' },
|
104
|
+
{ x: 0..203, y: 255..275, char: '=' },
|
105
|
+
{ x: 0..239, y: 255..275, char: :erase },
|
106
|
+
{ x: 0..35, y: 290..315, char: :keyboard_capital },
|
107
|
+
{ x: 0..68, y: 290..315, char: '@' },
|
108
|
+
{ x: 0..104, y: 290..315, char: '%' },
|
109
|
+
{ x: 0..138, y: 290..315, char: '0' },
|
110
|
+
{ x: 0..169, y: 290..315, char: '#' },
|
111
|
+
{ x: 0..203, y: 290..315, char: '_' },
|
112
|
+
{ x: 0..239, y: 290..315, char: :enter }
|
113
|
+
]
|
114
|
+
}
|
115
|
+
|
116
|
+
def self.type_text(params = {})
|
117
|
+
change_keyboard
|
118
|
+
Device::Display.print_line("#{self.text}", params[:line], params[:column])
|
119
|
+
time = Time.now + (params[:timeout] || Device::IO.timeout) / 1000
|
120
|
+
key = nil
|
121
|
+
|
122
|
+
while text_not_ready?(key)
|
123
|
+
line_x, line_y = getxy_stream(100)
|
124
|
+
|
125
|
+
if line_x && line_y
|
126
|
+
touch_clear
|
127
|
+
key = parse(line_x, line_y, params)
|
128
|
+
else
|
129
|
+
break(Device::IO::KEY_TIMEOUT) if Time.now > time
|
130
|
+
|
131
|
+
key = getc(100)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
[key, self.text]
|
136
|
+
end
|
137
|
+
|
138
|
+
def self.text_not_ready?(key)
|
139
|
+
key != :enter && key != Device::IO::ENTER && key != Device::IO::CANCEL
|
140
|
+
end
|
141
|
+
|
142
|
+
def self.parse(line_x, line_y, params)
|
143
|
+
key = attributes[type].find do |value|
|
144
|
+
value[:x].include?(line_x) && value[:y].include?(line_y)
|
145
|
+
end
|
146
|
+
return if key.nil?
|
147
|
+
|
148
|
+
Device::Audio.beep(7, 60)
|
149
|
+
show_text(key, params)
|
150
|
+
|
151
|
+
key[:char]
|
152
|
+
end
|
153
|
+
|
154
|
+
def self.show_text(key, params)
|
155
|
+
case key[:char]
|
156
|
+
when :keyboard_uppercase, :keyboard_symbol_number, :keyboard_capital
|
157
|
+
self.type = key[:char]
|
158
|
+
change_keyboard
|
159
|
+
when :erase
|
160
|
+
self.text += '' if text.nil?
|
161
|
+
self.text = text[0..-2]
|
162
|
+
when :space
|
163
|
+
self.text += ' '
|
164
|
+
else
|
165
|
+
self.text << key[:char] unless key[:char] == :enter
|
166
|
+
end
|
167
|
+
Device::Display.print_line("#{self.text}", params[:line], params[:column])
|
168
|
+
end
|
169
|
+
|
170
|
+
def self.change_keyboard
|
171
|
+
if type.nil?
|
172
|
+
self.type = :keyboard_capital
|
173
|
+
Device::Display.print_bitmap('./shared/keyboard_capital.bmp')
|
174
|
+
else
|
175
|
+
Device::Display.print_bitmap("./shared/#{type}.bmp")
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
def self.wifi_password
|
180
|
+
self.text = if Device::Setting.wifi_password == 'false'
|
181
|
+
''
|
182
|
+
else
|
183
|
+
Device::Setting.wifi_password
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
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.21.1
|
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
|
+
date: 2020-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -192,6 +192,7 @@ files:
|
|
192
192
|
- lib/device/support.rb
|
193
193
|
- lib/device/system.rb
|
194
194
|
- lib/device/version.rb
|
195
|
+
- lib/device/virtual_keyboard.rb
|
195
196
|
- lib/ext/array.rb
|
196
197
|
- lib/ext/float.rb
|
197
198
|
- lib/ext/hash.rb
|