da_funk 3.18.0 → 3.21.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/Gemfile.lock +17 -12
- data/RELEASE_NOTES.md +35 -0
- data/Rakefile +2 -1
- data/lib/da_funk/helper.rb +27 -19
- data/lib/da_funk/helper/status_bar.rb +65 -39
- 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/setting.rb +2 -2
- 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: 8e875275390a4f7dc2339aee32563d421eefb5b8c99506ddad0d07259ea0d3dc
|
4
|
+
data.tar.gz: 66171f575862fa2b8706d489f6c30092508a57e97ef2b447aeba2905b4f5fbfa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d10be46df2116e414f0d6b8b77f4018caf9edf7c9f4edce6b2b2870b1b40185ef89a4f058593940cfc5b21ca76a17fd1047b54afe19a2775fc3aac10a49d06f4
|
7
|
+
data.tar.gz: 659f95c34040693e80395f8fa006015e07b85d8ddd6e14eb3357ce8c484337eb96db92bcf9e163f16756aa8705f3493cf2ebc67164c74d59f83fe22fa49c7c02
|
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.2)
|
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,40 @@
|
|
1
1
|
# DaFunk
|
2
2
|
|
3
|
+
### 3.21.2 - 2020-06-16
|
4
|
+
|
5
|
+
- Fixed timeout return on DaFunK::Helper#menu, it should return Device::IO::KEY_TIMEOUT not options[:timeout];
|
6
|
+
- Set cloudwalk endpoint as default.
|
7
|
+
|
8
|
+
### 3.21.1 - 2020-06-16
|
9
|
+
|
10
|
+
- Fix error when timeout on DaFunk::menu_image_touchscreen_or_keyboard.
|
11
|
+
|
12
|
+
### 3.21.0 - 2020-06-12
|
13
|
+
|
14
|
+
- Removed unnecessary processing method call;
|
15
|
+
- Status bar refactored:
|
16
|
+
- Removed link icon;
|
17
|
+
- Added support to SLOT_MEDIA to print WIFI or GPRS;
|
18
|
+
- Renamed SLOT_CONNECTION to SLOT_SIGNAL_LEVEL;
|
19
|
+
- Added support to SLOT_BATTERY_PERCENTUAL to print percentual of battery level;
|
20
|
+
- Renamed SLOT_BATTERY to SLOT_BATTERY_LEVEL;
|
21
|
+
- Update battery and wifi images;
|
22
|
+
- Added BATTERY_PERCENTAGE_IMAGES;
|
23
|
+
- Show searching icon when network is not connected;
|
24
|
+
- Added support to virtual keyboard;
|
25
|
+
- Added support to touchscreen event on DaFunk::Helper#menu;
|
26
|
+
- Added support to return timeout parameter on DaFunk::Helper#menu when timeout is achieved;
|
27
|
+
- Update funky-emv 1.3.0.
|
28
|
+
|
29
|
+
### 3.20.0 - 2020-05-28
|
30
|
+
|
31
|
+
- Rename PaymentChannel::client to ::current;
|
32
|
+
- Fix status bar change link to cache old value.
|
33
|
+
|
34
|
+
### 3.18.1 - 2020-05-20
|
35
|
+
|
36
|
+
- Fix issue on DaFunk::Helper#menu_image_touchscreen_or_keyboard it was not checking for special keys
|
37
|
+
|
3
38
|
### 3.18.0 - 2020-04-03
|
4
39
|
|
5
40
|
- Added enable_txt_ui parameter on the following methods
|
data/Rakefile
CHANGED
data/lib/da_funk/helper.rb
CHANGED
@@ -15,7 +15,7 @@ module DaFunk
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def attach_options(enable_txt_ui = true)
|
18
|
-
if DaFunk::PaymentChannel.
|
18
|
+
if DaFunk::PaymentChannel.current == Context::CommunicationChannel
|
19
19
|
{:print_last => true, :enable_txt_ui => enable_txt_ui}
|
20
20
|
else
|
21
21
|
{:print_last => false, :enable_txt_ui => enable_txt_ui}
|
@@ -179,26 +179,34 @@ module DaFunk
|
|
179
179
|
# menu_image_touchscreen_or_keyboard('image.bmp', menu_itens, options)
|
180
180
|
#
|
181
181
|
# @return menu_item_index selected will be returned
|
182
|
-
# @return if timeout
|
182
|
+
# @return if timeout Device::IO::KEY_TIMEOUT will be returned
|
183
183
|
def menu_image_touchscreen_or_keyboard(path, menu_itens, options = {})
|
184
184
|
return nil if menu_itens.empty?
|
185
185
|
|
186
186
|
Device::Display.print_bitmap(path)
|
187
|
-
|
188
187
|
timeout = options[:timeout] || Device::IO.timeout
|
189
|
-
|
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
|
190
194
|
|
191
195
|
event, key = wait_touchscreen_or_keyboard_event(menu_itens, timeout, options)
|
192
196
|
|
193
197
|
if event == :keyboard
|
194
198
|
if key == Device::IO::CANCEL
|
195
199
|
options[:default]
|
200
|
+
elsif options[:special_keys].include?(key)
|
201
|
+
key
|
196
202
|
else
|
197
203
|
index = key.to_i-1 == -1 ? 0 : key.to_i-1
|
198
204
|
menu_itens.keys[index]
|
199
205
|
end
|
200
206
|
elsif event == :touchscreen
|
201
207
|
menu_itens.select {|k, v| k == key}.shift[0]
|
208
|
+
elsif event == :timeout
|
209
|
+
Device::IO::KEY_TIMEOUT
|
202
210
|
end
|
203
211
|
end
|
204
212
|
|
@@ -268,7 +276,7 @@ module DaFunk
|
|
268
276
|
# }
|
269
277
|
#
|
270
278
|
# menu("Option menu", selection, options)
|
271
|
-
#
|
279
|
+
# @return nil if user canceled or Device::IO::KEY_TIMEOUT if timeout or option selected
|
272
280
|
def menu(title, selection, options = {})
|
273
281
|
return nil if selection.empty?
|
274
282
|
options[:number] = true if options[:number].nil?
|
@@ -290,6 +298,8 @@ module DaFunk
|
|
290
298
|
|
291
299
|
if key == Device::IO::ENTER
|
292
300
|
options[:default]
|
301
|
+
elsif key == Device::IO::KEY_TIMEOUT
|
302
|
+
Device::IO::KEY_TIMEOUT
|
293
303
|
else
|
294
304
|
selected
|
295
305
|
end
|
@@ -297,7 +307,10 @@ module DaFunk
|
|
297
307
|
|
298
308
|
# TODO Scalone: Refactor.
|
299
309
|
def pagination(title, options, collection, &block)
|
310
|
+
timeout = options[:timeout].nil? ? options[:timeout] : Device::IO.timeout
|
311
|
+
touchscreen_options = {}
|
300
312
|
start_line, options[:limit], options[:header] = pagination_limit(title, options)
|
313
|
+
|
301
314
|
if collection.size > (options[:limit] - options[:header]) # minus pagination header
|
302
315
|
key = Device::IO.back_key
|
303
316
|
pages = pagination_page(collection, options[:limit] - options[:header]) # minus pagination header
|
@@ -307,7 +320,13 @@ module DaFunk
|
|
307
320
|
pagination_header(title, page, pages.size, start_line, options[:default], options[:header])
|
308
321
|
values = pages[page].to_a
|
309
322
|
block.call(values, start_line + options[:header])
|
310
|
-
|
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)
|
311
330
|
page = pagination_key_page(page, key, pages.size)
|
312
331
|
end
|
313
332
|
else
|
@@ -315,7 +334,8 @@ module DaFunk
|
|
315
334
|
print_title(title, options[:default]) if title
|
316
335
|
values = collection.to_a
|
317
336
|
block.call(values, start_line)
|
318
|
-
|
337
|
+
params = {special_keys: pagination_keys(collection.size, false)}
|
338
|
+
_, key = wait_touchscreen_or_keyboard_event(touchscreen_options, timeout, params)
|
319
339
|
end
|
320
340
|
result = values[key.to_i-1] if key.integer?
|
321
341
|
if result.is_a? Array
|
@@ -435,18 +455,6 @@ module DaFunk
|
|
435
455
|
end
|
436
456
|
end
|
437
457
|
|
438
|
-
def processing(image, message = {})
|
439
|
-
Device::Display.print_bitmap(to_bmp(image)) if bmp_exists?(image)
|
440
|
-
end
|
441
|
-
|
442
|
-
def bmp_exists?(bmp)
|
443
|
-
File.exists?(to_bmp(bmp))
|
444
|
-
end
|
445
|
-
|
446
|
-
def to_bmp(image)
|
447
|
-
"./shared/#{image.to_s}.bmp"
|
448
|
-
end
|
449
|
-
|
450
458
|
private
|
451
459
|
def parse_touchscreen_event(menu_itens, x, y)
|
452
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
|
@@ -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
|
data/lib/device/setting.rb
CHANGED
@@ -62,8 +62,8 @@ class Device
|
|
62
62
|
"payment_channel_date" => "",
|
63
63
|
"infinitepay_authorizer" => "0",
|
64
64
|
"infinitepay_api" => "0",
|
65
|
-
"infinitepay_cw_endpoint" => "
|
66
|
-
"infinitepay_google_endpoint" => "
|
65
|
+
"infinitepay_cw_endpoint" => "1",
|
66
|
+
"infinitepay_google_endpoint" => "0",
|
67
67
|
"transaction_http_enabled" => "1",
|
68
68
|
"transaction_http_host" => HTTP_HOST_PRODUCTION,
|
69
69
|
"transaction_http_port" => HTTP_PORT,
|
@@ -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.2
|
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
|