ruby-macrodroid 0.8.1 → 0.8.7
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
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/ruby-macrodroid.rb +155 -28
- data/lib/ruby-macrodroid/actions.rb +325 -46
- data/lib/ruby-macrodroid/base.rb +0 -52
- data/lib/ruby-macrodroid/triggers.rb +81 -2
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e161537334457ba0da45d5058d8a7a75a1a845cb2e5b9aa7895ea224aac472c5
|
4
|
+
data.tar.gz: 9503ca1e163739e18fba141a333e99fcf27eb3c34c34798f72099f723e63f3fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1035077a740b2308cde75c96da176d0dd616111bd9541b364ce2a9e3f13eb39a3ad49930222348a186fe1180bade2eb264e0a9cf4bf05ee5efd2802da27a3850
|
7
|
+
data.tar.gz: 6f0919e4921f12d5c646484f56b8c5b459335d3997559226803e4da30ec5e96e007882a247c0a52ff9766702066f28df534c044792c557a40335079828458da0
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/ruby-macrodroid.rb
CHANGED
@@ -154,6 +154,16 @@ class ActionsNlp
|
|
154
154
|
[ToastAction, {msg: msg}]
|
155
155
|
end
|
156
156
|
|
157
|
+
# e.g. Popup Message\n hello world!
|
158
|
+
get /^Popup Message\n\s+(.*)/im do |msg|
|
159
|
+
[ToastAction, {msg: msg}]
|
160
|
+
end
|
161
|
+
|
162
|
+
# e.g. Popup Message
|
163
|
+
get /^Popup Message$/i do
|
164
|
+
[ToastAction, {}]
|
165
|
+
end
|
166
|
+
|
157
167
|
# e.g. say current time
|
158
168
|
get /^say current[ _]time/i do
|
159
169
|
[SayTimeAction, {}]
|
@@ -243,16 +253,17 @@ class ActionsNlp
|
|
243
253
|
[KeepAwakeAction, {enabled: false, screen_option: 0}]
|
244
254
|
end
|
245
255
|
|
256
|
+
#a: Disable Keep Awake
|
257
|
+
#
|
258
|
+
get /if (.*)/i do
|
259
|
+
[IfConditionAction, {}]
|
260
|
+
end
|
246
261
|
|
247
262
|
end
|
248
263
|
|
249
264
|
alias find_action run_route
|
250
265
|
|
251
|
-
def to_s(colour: false)
|
252
|
-
'ActionsNlp ' + @h.inspect
|
253
|
-
end
|
254
266
|
|
255
|
-
alias to_summary to_s
|
256
267
|
end
|
257
268
|
|
258
269
|
class ConstraintsNlp
|
@@ -279,6 +290,60 @@ class ConstraintsNlp
|
|
279
290
|
end
|
280
291
|
|
281
292
|
|
293
|
+
module Params
|
294
|
+
|
295
|
+
refine Hash do
|
296
|
+
|
297
|
+
# turns keys from camelCase into snake_case
|
298
|
+
|
299
|
+
def to_snake_case(h=self)
|
300
|
+
|
301
|
+
h.inject({}) do |r, x|
|
302
|
+
|
303
|
+
key, value = x
|
304
|
+
#puts 'value: ' + value.inspect
|
305
|
+
|
306
|
+
val = if value.is_a?(Hash) then
|
307
|
+
to_snake_case(value)
|
308
|
+
elsif value.is_a?(Array) and value.first.is_a? Hash
|
309
|
+
value.map {|row| to_snake_case(row)}
|
310
|
+
else
|
311
|
+
value
|
312
|
+
end
|
313
|
+
|
314
|
+
r.merge key.to_s.sub(/^m_/,'').gsub(/[A-Z][a-z]/){|x| '_' +
|
315
|
+
x.downcase}.gsub(/[a-z][A-Z]/){|x| x[0] + '_' + x[1].downcase}\
|
316
|
+
.downcase.to_sym => val
|
317
|
+
|
318
|
+
end
|
319
|
+
end
|
320
|
+
|
321
|
+
# turns keys from snake_case to CamelCase
|
322
|
+
def to_camel_case(h=self)
|
323
|
+
|
324
|
+
h.inject({}) do |r,x|
|
325
|
+
|
326
|
+
key, value = x
|
327
|
+
|
328
|
+
val = if value.is_a?(Hash) then
|
329
|
+
to_camel_case(value)
|
330
|
+
elsif value.is_a?(Array) and value.first.is_a? Hash
|
331
|
+
value.map {|row| to_camel_case(row)}
|
332
|
+
else
|
333
|
+
value
|
334
|
+
end
|
335
|
+
|
336
|
+
r.merge({key.to_s.gsub(/(?<!^m)_[a-z]/){|x| x[-1].upcase} => val})
|
337
|
+
end
|
338
|
+
|
339
|
+
end
|
340
|
+
|
341
|
+
|
342
|
+
end
|
343
|
+
|
344
|
+
end
|
345
|
+
|
346
|
+
|
282
347
|
|
283
348
|
class Macro
|
284
349
|
using ColouredText
|
@@ -326,6 +391,7 @@ class Macro
|
|
326
391
|
local_variables: @local_variables,
|
327
392
|
m_trigger_list: @triggers.map(&:to_h),
|
328
393
|
m_action_list: @actions.map(&:to_h),
|
394
|
+
m_category: @category,
|
329
395
|
m_constraint_list: @constraints.map(&:to_h),
|
330
396
|
m_description: '',
|
331
397
|
m_name: title(),
|
@@ -349,11 +415,30 @@ class Macro
|
|
349
415
|
puts 'h:' + h.inspect
|
350
416
|
end
|
351
417
|
|
418
|
+
@category = h[:category]
|
352
419
|
@title = h[:name]
|
353
420
|
@description = h[:description]
|
354
421
|
|
355
422
|
# fetch the local variables
|
356
|
-
|
423
|
+
if h[:local_variables].any? and h[:local_variables].first.any? then
|
424
|
+
|
425
|
+
@local_variables = h[:local_variables].map do |var|
|
426
|
+
|
427
|
+
val = case var[:type]
|
428
|
+
when 0 # boolean
|
429
|
+
var[:boolean_value]
|
430
|
+
when 1 # integer
|
431
|
+
var[:int_value]
|
432
|
+
when 2 # string
|
433
|
+
var[:string_value]
|
434
|
+
when 3 # decimal
|
435
|
+
var[:decimal_Value]
|
436
|
+
end
|
437
|
+
|
438
|
+
[var[:name], val]
|
439
|
+
|
440
|
+
end.to_h
|
441
|
+
end
|
357
442
|
|
358
443
|
# fetch the triggers
|
359
444
|
@triggers = h[:trigger_list].map do |trigger|
|
@@ -366,17 +451,17 @@ class Macro
|
|
366
451
|
@actions = h[:action_list].map do |action|
|
367
452
|
object(action.to_snake_case)
|
368
453
|
end
|
369
|
-
|
454
|
+
puts 'before fetch constraints' if @debug
|
370
455
|
# fetch the constraints
|
371
456
|
@constraints = h[:constraint_list].map do |constraint|
|
372
457
|
object(constraint.to_snake_case)
|
373
458
|
end
|
374
|
-
|
459
|
+
puts 'after fetch constraints' if @debug
|
375
460
|
@h = h
|
376
461
|
|
377
462
|
%i(local_variables m_trigger_list m_action_list m_constraint_list)\
|
378
463
|
.each {|x| @h[x] = [] }
|
379
|
-
|
464
|
+
puts 'after @h set' if @debug
|
380
465
|
@h
|
381
466
|
|
382
467
|
end
|
@@ -393,6 +478,7 @@ class Macro
|
|
393
478
|
# level 2
|
394
479
|
|
395
480
|
@title = node.attributes[:name]
|
481
|
+
@category = node.attributes[:category]
|
396
482
|
@description = node.attributes[:description]
|
397
483
|
|
398
484
|
|
@@ -460,20 +546,42 @@ class Macro
|
|
460
546
|
@actions = node.xpath('action').map do |e|
|
461
547
|
|
462
548
|
puts 'action e: ' + e.xml.inspect if @debug
|
463
|
-
|
549
|
+
puts 'e.text ' + e.text if @debug
|
550
|
+
|
551
|
+
inner_lines = e.xpath('item/description/text()')
|
552
|
+
|
553
|
+
action = if e.text.to_s.strip.empty? then
|
554
|
+
inner_lines.shift
|
555
|
+
else
|
556
|
+
e.text.strip
|
557
|
+
end
|
558
|
+
|
559
|
+
r = ap.find_action action
|
464
560
|
puts 'found action ' + r.inspect if @debug
|
465
561
|
|
466
562
|
if r then
|
467
563
|
|
468
|
-
|
564
|
+
loose = inner_lines.shift
|
469
565
|
|
470
|
-
|
471
|
-
|
566
|
+
raw_attributes = if loose then
|
567
|
+
|
568
|
+
puts 'do something ' + loose.to_s if @debug
|
569
|
+
loose.to_s
|
570
|
+
|
472
571
|
else
|
473
|
-
|
572
|
+
|
573
|
+
a = e.xpath('item/*')
|
574
|
+
|
575
|
+
h = if a.any? then
|
576
|
+
a.map {|node| [node.name.to_sym, node.text.to_s]}.to_h
|
577
|
+
else
|
578
|
+
{}
|
579
|
+
end
|
580
|
+
|
581
|
+
r[1].merge(h)
|
582
|
+
|
474
583
|
end
|
475
|
-
|
476
|
-
r[0].new(r[1].merge(h))
|
584
|
+
r[0].new(raw_attributes)
|
477
585
|
end
|
478
586
|
|
479
587
|
end
|
@@ -581,7 +689,7 @@ EOF
|
|
581
689
|
|
582
690
|
end
|
583
691
|
|
584
|
-
if s =~ /^If/i then
|
692
|
+
if s =~ /^(?:If|WHILE \/ DO)/i then
|
585
693
|
|
586
694
|
if indent < 1 then
|
587
695
|
|
@@ -602,13 +710,32 @@ EOF
|
|
602
710
|
r
|
603
711
|
|
604
712
|
end.join("\n")
|
713
|
+
|
714
|
+
a = []
|
715
|
+
a << '# ' + @category + "\n" if @category
|
716
|
+
a << (colour ? "m".bg_cyan.gray.bold : 'm') + ': ' + @title
|
717
|
+
|
718
|
+
|
719
|
+
if @description and @description.length >= 1 then
|
720
|
+
a << (colour ? "d".bg_gray.gray.bold : 'd') + ': ' \
|
721
|
+
+ @description.gsub(/\n/,"\n ")
|
722
|
+
end
|
605
723
|
|
606
|
-
|
607
|
-
|
608
|
-
@
|
609
|
-
|
610
|
-
|
611
|
-
|
724
|
+
if @local_variables.length >= 1 then
|
725
|
+
|
726
|
+
vars = @local_variables.map do |k,v|
|
727
|
+
label = colour ? 'v'.bg_magenta : 'v'
|
728
|
+
label += ': '
|
729
|
+
label + "%s: %s" % [k,v]
|
730
|
+
end
|
731
|
+
|
732
|
+
a << vars.join("\n")
|
733
|
+
end
|
734
|
+
|
735
|
+
a << @triggers.map {|x| (colour ? "t".bg_red.gray.bold : 't') \
|
736
|
+
+ ": %s" % x}.join("\n")
|
737
|
+
a << actions
|
738
|
+
|
612
739
|
|
613
740
|
if @constraints.any? then
|
614
741
|
a << @constraints.map do |x|
|
@@ -616,10 +743,9 @@ EOF
|
|
616
743
|
end.join("\n")
|
617
744
|
end
|
618
745
|
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
end
|
746
|
+
|
747
|
+
|
748
|
+
|
623
749
|
|
624
750
|
a.join("\n") + "\n"
|
625
751
|
|
@@ -682,7 +808,7 @@ EOF
|
|
682
808
|
h2 = h.merge( macro: self)
|
683
809
|
puts 'h2: ' + h2.inspect
|
684
810
|
r = klass.new h2
|
685
|
-
|
811
|
+
puts 'r:' + r.inspect
|
686
812
|
r
|
687
813
|
|
688
814
|
end
|
@@ -720,6 +846,7 @@ class MacroDroid
|
|
720
846
|
if s[0] == '{' then
|
721
847
|
|
722
848
|
import_json(s)
|
849
|
+
puts 'after import_json' if @debug
|
723
850
|
|
724
851
|
elsif s[0] == '<'
|
725
852
|
|
@@ -812,7 +939,7 @@ class MacroDroid
|
|
812
939
|
end
|
813
940
|
|
814
941
|
alias to_json export_json
|
815
|
-
|
942
|
+
|
816
943
|
|
817
944
|
def to_h()
|
818
945
|
|
@@ -69,43 +69,6 @@ class Action < MacroObject
|
|
69
69
|
end
|
70
70
|
|
71
71
|
|
72
|
-
class LocationAction < Action
|
73
|
-
|
74
|
-
def initialize(h={})
|
75
|
-
super(h)
|
76
|
-
@group = 'location'
|
77
|
-
end
|
78
|
-
|
79
|
-
end
|
80
|
-
|
81
|
-
# Category: Location
|
82
|
-
#
|
83
|
-
class ShareLocationAction < LocationAction
|
84
|
-
|
85
|
-
def initialize(h={})
|
86
|
-
|
87
|
-
super()
|
88
|
-
|
89
|
-
options = {
|
90
|
-
email: '',
|
91
|
-
variable: {:m_stringValue=>"", :m_name=>"",
|
92
|
-
:m_decimalValue=>0.0, :isLocal=>true, :m_booleanValue=>false,
|
93
|
-
:excludeFromLog=>false, :m_intValue=>0, :m_type=>2},
|
94
|
-
sim_id: 0,
|
95
|
-
output_channel: 5,
|
96
|
-
old_variable_format: true
|
97
|
-
}
|
98
|
-
|
99
|
-
super(options.merge h)
|
100
|
-
|
101
|
-
end
|
102
|
-
|
103
|
-
def to_s(colour: false)
|
104
|
-
'ShareLocationAction ' + @h.inspect
|
105
|
-
end
|
106
|
-
|
107
|
-
alias to_summary to_s
|
108
|
-
end
|
109
72
|
|
110
73
|
|
111
74
|
class ApplicationAction < Action
|
@@ -272,7 +235,10 @@ class TakePictureAction < CameraAction
|
|
272
235
|
|
273
236
|
end
|
274
237
|
|
275
|
-
|
238
|
+
|
239
|
+
# Conditions/Loops
|
240
|
+
#
|
241
|
+
class IfConfirmedThenAction < Action
|
276
242
|
|
277
243
|
def initialize(h={})
|
278
244
|
|
@@ -286,6 +252,92 @@ class IfConditionAction < Action
|
|
286
252
|
|
287
253
|
super(h2)
|
288
254
|
|
255
|
+
@label = 'If Confirmed Then '
|
256
|
+
|
257
|
+
end
|
258
|
+
|
259
|
+
def to_s(colour: false)
|
260
|
+
|
261
|
+
@s = "If Confirmed Then " #+ @constraints.map(&:to_s).join(" %s " % operator)
|
262
|
+
super(colour: colour)
|
263
|
+
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
# Conditions/Loops
|
268
|
+
#
|
269
|
+
class LoopAction < Action
|
270
|
+
|
271
|
+
def initialize(h={})
|
272
|
+
|
273
|
+
options = {
|
274
|
+
|
275
|
+
}
|
276
|
+
|
277
|
+
h2 = options.merge(h)
|
278
|
+
|
279
|
+
super(h2)
|
280
|
+
|
281
|
+
@label = 'WHILE / DO '
|
282
|
+
|
283
|
+
end
|
284
|
+
|
285
|
+
def to_s(colour: false)
|
286
|
+
|
287
|
+
@s = 'WHILE / DO '
|
288
|
+
super()
|
289
|
+
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
# Conditions/Loops
|
294
|
+
#
|
295
|
+
class EndLoopAction < Action
|
296
|
+
|
297
|
+
def initialize(h={})
|
298
|
+
|
299
|
+
options = {
|
300
|
+
|
301
|
+
}
|
302
|
+
|
303
|
+
h2 = options.merge(h)
|
304
|
+
|
305
|
+
super(h2)
|
306
|
+
|
307
|
+
@label = 'End Loop '
|
308
|
+
|
309
|
+
end
|
310
|
+
|
311
|
+
def to_s(colour: false)
|
312
|
+
|
313
|
+
'End Loop '
|
314
|
+
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
# Conditions/Loops
|
319
|
+
#
|
320
|
+
class IfConditionAction < Action
|
321
|
+
|
322
|
+
def initialize(obj=nil)
|
323
|
+
|
324
|
+
h = if obj.is_a? Hash then
|
325
|
+
obj
|
326
|
+
else
|
327
|
+
# get the constraints
|
328
|
+
|
329
|
+
end
|
330
|
+
|
331
|
+
options = {
|
332
|
+
a: true,
|
333
|
+
constraint_list: ''
|
334
|
+
}
|
335
|
+
|
336
|
+
macro = h[:macro]
|
337
|
+
h2 = options.merge(filter(options,h).merge(macro: macro))
|
338
|
+
|
339
|
+
super(h2)
|
340
|
+
|
289
341
|
@label = 'If '
|
290
342
|
|
291
343
|
end
|
@@ -317,7 +369,7 @@ class ElseAction < Action
|
|
317
369
|
|
318
370
|
end
|
319
371
|
|
320
|
-
class ElseIfConditionAction <
|
372
|
+
class ElseIfConditionAction < Action
|
321
373
|
|
322
374
|
def initialize(h={})
|
323
375
|
|
@@ -326,9 +378,14 @@ class ElseIfConditionAction < IfConditionAction
|
|
326
378
|
}
|
327
379
|
|
328
380
|
super(options.merge h)
|
329
|
-
@label = '
|
381
|
+
@label = 'Else If '
|
330
382
|
|
331
383
|
end
|
384
|
+
|
385
|
+
def to_s(colour: false)
|
386
|
+
@s = 'Else If '
|
387
|
+
super()
|
388
|
+
end
|
332
389
|
|
333
390
|
|
334
391
|
end
|
@@ -643,7 +700,7 @@ class ClipboardAction < DeviceAction
|
|
643
700
|
end
|
644
701
|
|
645
702
|
def to_s(colour: false)
|
646
|
-
'
|
703
|
+
'Fill Clipboard' + "\n " + @h[:clipboard_text] #+ @h.inspect
|
647
704
|
end
|
648
705
|
|
649
706
|
alias to_summary to_s
|
@@ -793,6 +850,11 @@ end
|
|
793
850
|
#
|
794
851
|
class CameraFlashLightAction < DeviceSettingsAction
|
795
852
|
|
853
|
+
# options
|
854
|
+
# 0 Toch On
|
855
|
+
# 1 Torch Off
|
856
|
+
# 2 Torch Toggle
|
857
|
+
#
|
796
858
|
def initialize(h={})
|
797
859
|
|
798
860
|
options = {
|
@@ -1001,6 +1063,40 @@ class FileAction < Action
|
|
1001
1063
|
|
1002
1064
|
end
|
1003
1065
|
|
1066
|
+
|
1067
|
+
|
1068
|
+
# Category: Files
|
1069
|
+
#
|
1070
|
+
class FileOperationV21Action < FileAction
|
1071
|
+
|
1072
|
+
def initialize(h={})
|
1073
|
+
|
1074
|
+
options = {
|
1075
|
+
:app_name=>"", :class_name=>"", :package_name=>"", :file_path=>"",
|
1076
|
+
:file_extensions=>["jpg", "jpeg", "png", "raw", "bmp", "tif", "tiff",
|
1077
|
+
"gif"], :file_option=>2, :from_name=>"Sent",
|
1078
|
+
:from_uri_string=>"", :option=>2
|
1079
|
+
}
|
1080
|
+
|
1081
|
+
super(options.merge h)
|
1082
|
+
|
1083
|
+
end
|
1084
|
+
|
1085
|
+
def to_s(colour: false)
|
1086
|
+
|
1087
|
+
operation = ['Copy', 'Move', 'Delete', 'Create Folder']
|
1088
|
+
file = ['All Files', 'All Media Files', 'Images', 'Audio', 'Videos', 'Specify File Pattern', 'Folder']
|
1089
|
+
|
1090
|
+
detail = @h[:from_name]
|
1091
|
+
detail += ' to: ' + @h[:to_name] if @h[:option] == 1
|
1092
|
+
@s = "%s %s" % [operation[@h[:option]], file[@h[:file_option]]] \
|
1093
|
+
+ "\n " + detail #+ @h.inspect
|
1094
|
+
super()
|
1095
|
+
end
|
1096
|
+
|
1097
|
+
alias to_summary to_s
|
1098
|
+
end
|
1099
|
+
|
1004
1100
|
# Category: Files
|
1005
1101
|
#
|
1006
1102
|
class OpenFileAction < FileAction
|
@@ -1026,6 +1122,30 @@ class OpenFileAction < FileAction
|
|
1026
1122
|
end
|
1027
1123
|
|
1028
1124
|
|
1125
|
+
# Category: Files
|
1126
|
+
#
|
1127
|
+
class WriteToFileAction < FileAction
|
1128
|
+
|
1129
|
+
def initialize(h={})
|
1130
|
+
|
1131
|
+
options = {
|
1132
|
+
app_name: '',
|
1133
|
+
class_name: '',
|
1134
|
+
package_name: '',
|
1135
|
+
file_path: ''
|
1136
|
+
}
|
1137
|
+
|
1138
|
+
super(options.merge h)
|
1139
|
+
|
1140
|
+
end
|
1141
|
+
|
1142
|
+
def to_s(colour: false)
|
1143
|
+
'Write To File' + "\n " + @h[:filename] #+ @h.inspect
|
1144
|
+
end
|
1145
|
+
|
1146
|
+
alias to_summary to_s
|
1147
|
+
end
|
1148
|
+
|
1029
1149
|
class LocationAction < Action
|
1030
1150
|
|
1031
1151
|
def initialize(h={})
|
@@ -1055,15 +1175,30 @@ class ForceLocationUpdateAction < LocationAction
|
|
1055
1175
|
alias to_summary to_s
|
1056
1176
|
end
|
1057
1177
|
|
1178
|
+
# Category: Location
|
1179
|
+
#
|
1180
|
+
class LocationAction < Action
|
1181
|
+
|
1182
|
+
def initialize(h={})
|
1183
|
+
super(h)
|
1184
|
+
@group = 'location'
|
1185
|
+
end
|
1186
|
+
|
1187
|
+
end
|
1188
|
+
|
1058
1189
|
# Category: Location
|
1059
1190
|
#
|
1060
1191
|
class ShareLocationAction < LocationAction
|
1061
1192
|
|
1062
1193
|
def initialize(h={})
|
1194
|
+
|
1195
|
+
super()
|
1063
1196
|
|
1064
1197
|
options = {
|
1065
1198
|
email: '',
|
1066
|
-
variable: {:m_stringValue=>"", :m_name=>"",
|
1199
|
+
variable: {:m_stringValue=>"", :m_name=>"",
|
1200
|
+
:m_decimalValue=>0.0, :isLocal=>true, :m_booleanValue=>false,
|
1201
|
+
:excludeFromLog=>false, :m_intValue=>0, :m_type=>2},
|
1067
1202
|
sim_id: 0,
|
1068
1203
|
output_channel: 5,
|
1069
1204
|
old_variable_format: true
|
@@ -1074,12 +1209,14 @@ class ShareLocationAction < LocationAction
|
|
1074
1209
|
end
|
1075
1210
|
|
1076
1211
|
def to_s(colour: false)
|
1077
|
-
'
|
1212
|
+
@s = 'Share Location' + "\n GPS" # + @h.inspect
|
1213
|
+
super()
|
1078
1214
|
end
|
1079
1215
|
|
1080
1216
|
alias to_summary to_s
|
1081
1217
|
end
|
1082
1218
|
|
1219
|
+
|
1083
1220
|
# Category: Location
|
1084
1221
|
#
|
1085
1222
|
class SetLocationUpdateRateAction < LocationAction
|
@@ -1188,6 +1325,32 @@ class ClearLogAction < LoggingAction
|
|
1188
1325
|
alias to_summary to_s
|
1189
1326
|
end
|
1190
1327
|
|
1328
|
+
# MacroDroid Specific
|
1329
|
+
#
|
1330
|
+
class ConfirmNextAction < Action
|
1331
|
+
|
1332
|
+
def initialize(h={})
|
1333
|
+
|
1334
|
+
options = {
|
1335
|
+
:message=>"Do you want to fill the clipboard? ", :title=>"Fill clipboard? ", :negative_text=>"NO", :positive_text=>"YES", :class_type=>"ConfirmNextAction"
|
1336
|
+
|
1337
|
+
}
|
1338
|
+
|
1339
|
+
super(h)
|
1340
|
+
|
1341
|
+
end
|
1342
|
+
|
1343
|
+
def to_s(colour: false)
|
1344
|
+
|
1345
|
+
@s = 'Confirm Next' + "\n %s: %s" % [@h[:title], @h[:message]]
|
1346
|
+
super()
|
1347
|
+
|
1348
|
+
end
|
1349
|
+
|
1350
|
+
alias to_summary to_s
|
1351
|
+
|
1352
|
+
end
|
1353
|
+
|
1191
1354
|
# MacroDroid Specific
|
1192
1355
|
#
|
1193
1356
|
class ExportMacrosAction < Action
|
@@ -1211,6 +1374,114 @@ class ExportMacrosAction < Action
|
|
1211
1374
|
|
1212
1375
|
end
|
1213
1376
|
|
1377
|
+
|
1378
|
+
# MacroDroid Specific
|
1379
|
+
#
|
1380
|
+
class SetVariableAction < Action
|
1381
|
+
|
1382
|
+
def initialize(h={})
|
1383
|
+
|
1384
|
+
options = {
|
1385
|
+
:user_prompt=>true,
|
1386
|
+
:user_prompt_message=>"Please enter a word to see it reversed",
|
1387
|
+
:user_prompt_show_cancel=>true,
|
1388
|
+
:user_prompt_stop_after_cancel=>true,
|
1389
|
+
:user_prompt_title=>"Word reverse",
|
1390
|
+
:name => 'word'
|
1391
|
+
}
|
1392
|
+
super(h)
|
1393
|
+
|
1394
|
+
end
|
1395
|
+
|
1396
|
+
def to_s(colour: false)
|
1397
|
+
|
1398
|
+
input = if @h[:user_prompt] then
|
1399
|
+
'[User Prompt]'
|
1400
|
+
elsif @h[:expression]
|
1401
|
+
@h[:expression]
|
1402
|
+
elsif @h[:int_value_increment]
|
1403
|
+
'(+1)'
|
1404
|
+
elsif @h[:int_value_decrement]
|
1405
|
+
'(-1)'
|
1406
|
+
elsif @h[:int_random]
|
1407
|
+
"Random %d -> %d" % [@h[:int_random_min], @h[:int_random_max]]
|
1408
|
+
else
|
1409
|
+
|
1410
|
+
=begin
|
1411
|
+
sym = case @h[:variable][:type]
|
1412
|
+
when 0 # boolean
|
1413
|
+
:new_boolean_value
|
1414
|
+
when 1 # integer
|
1415
|
+
:new_int_value
|
1416
|
+
when 2 # string
|
1417
|
+
:new_string_value
|
1418
|
+
when 3 # decimal
|
1419
|
+
:new_double_value
|
1420
|
+
end
|
1421
|
+
|
1422
|
+
@h[sym].to_s
|
1423
|
+
=end
|
1424
|
+
a = %i(new_boolean_value new_int_value new_string_value new_double_value)
|
1425
|
+
@h[a[@h[:variable][:type]]].to_s
|
1426
|
+
|
1427
|
+
end
|
1428
|
+
|
1429
|
+
@s = 'Set Variable' + ("\n %s: " % @h[:variable][:name]) + input #+ @h.inspect
|
1430
|
+
super()
|
1431
|
+
|
1432
|
+
end
|
1433
|
+
|
1434
|
+
alias to_summary to_s
|
1435
|
+
|
1436
|
+
end
|
1437
|
+
|
1438
|
+
|
1439
|
+
|
1440
|
+
# MacroDroid Specific
|
1441
|
+
#
|
1442
|
+
class TextManipulationAction < Action
|
1443
|
+
|
1444
|
+
def initialize(h={})
|
1445
|
+
|
1446
|
+
options = {
|
1447
|
+
|
1448
|
+
}
|
1449
|
+
super(h)
|
1450
|
+
|
1451
|
+
end
|
1452
|
+
|
1453
|
+
def to_s(colour: false)
|
1454
|
+
|
1455
|
+
#tm = @h[:text_manipulation][:type]
|
1456
|
+
|
1457
|
+
#s = case tm[:type].to_sym
|
1458
|
+
s = case 3 # @h[:text_manipulation][:option].to_i
|
1459
|
+
when 0 # :SubstringManipulation
|
1460
|
+
"Substring(%s, %s)" % [@h[:text], tm[:params].join(', ')]
|
1461
|
+
when 1 # :ReplaceAllManipulation
|
1462
|
+
"Replace all(%s, %s, %s)" % [@h[:text], *tm[:params]]
|
1463
|
+
when 2 # :ExtractTextManipulation
|
1464
|
+
"Extract text(%s, %s)" % [@h[:text], tm[:params].join(', ')]
|
1465
|
+
when 3 # :UpperCaseManipulation
|
1466
|
+
"Upper case(%s)" % [@h[:text]]
|
1467
|
+
#'foo'
|
1468
|
+
when 4 # :LowerCaseManipulation
|
1469
|
+
"Lower case(%s)" % [@h[:text]]
|
1470
|
+
when 5 # :TrimWhitespaceManipulation
|
1471
|
+
"Trim whitespace(%s)" % [@h[:text]]
|
1472
|
+
end
|
1473
|
+
|
1474
|
+
'Text Manipulation' + "\n " + s.inspect #+ ' ' + @h.inspect
|
1475
|
+
|
1476
|
+
end
|
1477
|
+
|
1478
|
+
alias to_summary to_s
|
1479
|
+
|
1480
|
+
end
|
1481
|
+
|
1482
|
+
|
1483
|
+
|
1484
|
+
|
1214
1485
|
class PauseAction < Action
|
1215
1486
|
|
1216
1487
|
def initialize(h={})
|
@@ -1325,7 +1596,9 @@ class SendEmailAction < MessagingAction
|
|
1325
1596
|
end
|
1326
1597
|
|
1327
1598
|
def to_s(colour: false)
|
1328
|
-
|
1599
|
+
recipient = @h[:email_address]
|
1600
|
+
@s = 'Send EmailAction' + "\n To: " + recipient #+ ' ' + @h.inspect
|
1601
|
+
super()
|
1329
1602
|
end
|
1330
1603
|
|
1331
1604
|
alias to_summary to_s
|
@@ -1572,7 +1845,13 @@ end
|
|
1572
1845
|
#
|
1573
1846
|
class ToastAction < NotificationsAction
|
1574
1847
|
|
1575
|
-
def initialize(
|
1848
|
+
def initialize(obj)
|
1849
|
+
|
1850
|
+
h = if obj.is_a? Hash then
|
1851
|
+
obj
|
1852
|
+
else
|
1853
|
+
{msg: obj}
|
1854
|
+
end
|
1576
1855
|
|
1577
1856
|
if h[:msg] then
|
1578
1857
|
h[:message_text] = h[:msg]
|
@@ -1603,7 +1882,7 @@ class ToastAction < NotificationsAction
|
|
1603
1882
|
end
|
1604
1883
|
|
1605
1884
|
def to_s(colour: false)
|
1606
|
-
"Popup Message\n %s" % @h[:message_text]
|
1885
|
+
@s = "Popup Message\n %s" % @h[:message_text]
|
1607
1886
|
end
|
1608
1887
|
|
1609
1888
|
end
|
data/lib/ruby-macrodroid/base.rb
CHANGED
@@ -8,58 +8,6 @@
|
|
8
8
|
#
|
9
9
|
|
10
10
|
|
11
|
-
module Params
|
12
|
-
|
13
|
-
refine Hash do
|
14
|
-
|
15
|
-
# turns keys from camelCase into snake_case
|
16
|
-
|
17
|
-
def to_snake_case(h=self)
|
18
|
-
|
19
|
-
h.inject({}) do |r, x|
|
20
|
-
|
21
|
-
key, value = x
|
22
|
-
#puts 'value: ' + value.inspect
|
23
|
-
|
24
|
-
val = if value.is_a?(Hash) then
|
25
|
-
to_snake_case(value)
|
26
|
-
elsif value.is_a?(Array) and value.first.is_a? Hash
|
27
|
-
value.map {|row| to_snake_case(row)}
|
28
|
-
else
|
29
|
-
value
|
30
|
-
end
|
31
|
-
|
32
|
-
r.merge key.to_s.sub(/^m_/,'').gsub(/[A-Z][a-z]/){|x| '_' +
|
33
|
-
x.downcase}.gsub(/[a-z][A-Z]/){|x| x[0] + '_' + x[1].downcase}\
|
34
|
-
.downcase.to_sym => val
|
35
|
-
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
# turns keys from snake_case to CamelCase
|
40
|
-
def to_camel_case(h=self)
|
41
|
-
|
42
|
-
h.inject({}) do |r,x|
|
43
|
-
|
44
|
-
key, value = x
|
45
|
-
|
46
|
-
val = if value.is_a?(Hash) then
|
47
|
-
to_camel_case(value)
|
48
|
-
elsif value.is_a?(Array) and value.first.is_a? Hash
|
49
|
-
value.map {|row| to_camel_case(row)}
|
50
|
-
else
|
51
|
-
value
|
52
|
-
end
|
53
|
-
|
54
|
-
r.merge({key.to_s.gsub(/(?<!^m)_[a-z]/){|x| x[-1].upcase} => val})
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
63
11
|
|
64
12
|
class MacroObject
|
65
13
|
using ColouredText
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# file: ruby-macrodroid/
|
1
|
+
# file: ruby-macrodroid/triggers.rb
|
2
2
|
|
3
3
|
# This file contains the following classes:
|
4
4
|
#
|
@@ -26,6 +26,8 @@
|
|
26
26
|
#
|
27
27
|
|
28
28
|
|
29
|
+
|
30
|
+
|
29
31
|
class Trigger < MacroObject
|
30
32
|
using Params
|
31
33
|
|
@@ -132,7 +134,9 @@ class ApplicationLaunchedTrigger < Trigger
|
|
132
134
|
end
|
133
135
|
|
134
136
|
def to_s(colour: false)
|
135
|
-
|
137
|
+
a = @h[:application_name_list]
|
138
|
+
apps = a.length > 1 ? "[%s]" % a.join(', ') : a.first
|
139
|
+
'Application Launched' + "\n " + apps
|
136
140
|
end
|
137
141
|
|
138
142
|
alias to_summary to_s
|
@@ -971,6 +975,28 @@ class MusicPlayingTrigger < DeviceEventsTrigger
|
|
971
975
|
end
|
972
976
|
|
973
977
|
|
978
|
+
# Category: Device Events
|
979
|
+
#
|
980
|
+
class NFCTrigger < DeviceEventsTrigger
|
981
|
+
|
982
|
+
def initialize(h={})
|
983
|
+
|
984
|
+
options = {
|
985
|
+
}
|
986
|
+
|
987
|
+
super(options.merge h)
|
988
|
+
|
989
|
+
end
|
990
|
+
|
991
|
+
def to_s(colour: false)
|
992
|
+
'NFC Tag' + "\n " + @h[:tag_name]
|
993
|
+
end
|
994
|
+
|
995
|
+
alias to_summary to_s
|
996
|
+
|
997
|
+
end
|
998
|
+
|
999
|
+
|
974
1000
|
# Category: Device Events
|
975
1001
|
#
|
976
1002
|
class DeviceUnlockedTrigger < DeviceEventsTrigger
|
@@ -1254,6 +1280,28 @@ class SunriseSunsetTrigger < Trigger
|
|
1254
1280
|
end
|
1255
1281
|
|
1256
1282
|
|
1283
|
+
# Category: MacroDroid Specific
|
1284
|
+
#
|
1285
|
+
class EmptyTrigger < Trigger
|
1286
|
+
|
1287
|
+
def initialize(h={})
|
1288
|
+
|
1289
|
+
options = {
|
1290
|
+
|
1291
|
+
}
|
1292
|
+
|
1293
|
+
super(options.merge h)
|
1294
|
+
|
1295
|
+
end
|
1296
|
+
|
1297
|
+
def to_s(colour: false)
|
1298
|
+
'EmptyTrigger'
|
1299
|
+
end
|
1300
|
+
|
1301
|
+
alias to_summary to_s
|
1302
|
+
end
|
1303
|
+
|
1304
|
+
|
1257
1305
|
class SensorsTrigger < Trigger
|
1258
1306
|
|
1259
1307
|
def initialize(h={})
|
@@ -1556,3 +1604,34 @@ class SwipeTrigger < Trigger
|
|
1556
1604
|
|
1557
1605
|
alias to_summary to_s
|
1558
1606
|
end
|
1607
|
+
|
1608
|
+
|
1609
|
+
|
1610
|
+
|
1611
|
+
# Category: User Input
|
1612
|
+
#
|
1613
|
+
class WidgetPressedTrigger < Trigger
|
1614
|
+
|
1615
|
+
def initialize(h={})
|
1616
|
+
|
1617
|
+
options = {
|
1618
|
+
:swipe_start_area=>0, :swipe_motion=>0, :cleared=>true,
|
1619
|
+
:image_id=>2130968576, :image_package_name=>"com.android.providers.settings",
|
1620
|
+
:image_resource_name=>"com.android.providers.settings", :widget_label=>"",
|
1621
|
+
:widget_type=>4
|
1622
|
+
}
|
1623
|
+
|
1624
|
+
super(options.merge h)
|
1625
|
+
|
1626
|
+
end
|
1627
|
+
|
1628
|
+
def to_s(colour: false)
|
1629
|
+
# 4 == cutom , 0 = green, 1 = blue, 2 = red, 3 = yellow
|
1630
|
+
style = %w(Green Blue Red Yellow Custom)[@h[:widget_type]]
|
1631
|
+
@s = "Widget Button (%s)" % [style] #+ @h.inspect
|
1632
|
+
super()
|
1633
|
+
end
|
1634
|
+
|
1635
|
+
alias to_summary to_s
|
1636
|
+
end
|
1637
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-macrodroid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
NZ2kdBIUDnAM24e0/wXdVxg4HnsZbdymxyzMQ4P5pKYcpI6oisBxI37p/Xy+wAg3
|
36
36
|
SBHno3GEuuD8ZWj24IMJpfbp
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2020-09-
|
38
|
+
date: 2020-09-20 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: glw
|
metadata.gz.sig
CHANGED
Binary file
|