ruby-macrodroid 0.2.0 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8caad514012d7a2d749101b29c035de0b00d87d91aaaf98a11f8e29d5d0660c5
4
- data.tar.gz: 05e52e01b2aa1e9e77bf745bcb4f4c8533d9ab5c7798ed50f4d7081ebc4ccaca
3
+ metadata.gz: 7e6155695183a13d186ab0f5dc0d41f8b3e2a3624cd27d39ec8aac432b629f3b
4
+ data.tar.gz: e08ac2a18f3cc9c4dc31e3e4529055dfa36f7ddb14f7ce1877fa67f5c27f6bb5
5
5
  SHA512:
6
- metadata.gz: 8986f2053233c870ad76a1cf516a3a902197ee63ea2424fd19d60d64ecd331b5a6cf5efa33f54f0970d3ccbe9918a4018a79bf9c433f1363a8771f7b5d547cf2
7
- data.tar.gz: e8007c3e2b65bf110a32563f7d88e4ec56b0289ee8d0b63a69142b570ed8e312c9721371679cb7d1c3c3597b4917a41f66356e14df99c39c89045a487a693828
6
+ metadata.gz: 389c2e6dc57dc5f1cc0530df419219b09e4422474dc8fb388c18e05476b908290b3c391e77fc735abeaa79e2e253f197cd413a1d634bd9232ee78b5d2196d224
7
+ data.tar.gz: 34dfa5a6f22df2c1abf17214f28e1e531b8cf85692443255d5816ee039e9545d87e0f245bd77929bc0649d88c38cf8231e184f5504e6cc72eb71cd529f83b98f
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -2,12 +2,59 @@
2
2
 
3
3
  # file: ruby-macrodroid.rb
4
4
 
5
- require 'pp'
6
- require 'json'
7
5
  require 'uuid'
8
6
  require 'rxfhelper'
7
+ require 'chronic_cron'
9
8
 
10
9
 
10
+ class TriggersNlp
11
+ include AppRoutes
12
+
13
+ def initialize()
14
+
15
+ super()
16
+ params = {}
17
+ triggers(params)
18
+
19
+ end
20
+
21
+ def triggers(params)
22
+
23
+ get /^at (\d+:\d+(?:[ap]m)?) on (.*)/i do |time, days|
24
+ [TimerTrigger, {time: time, days: days}]
25
+ end
26
+
27
+
28
+ end
29
+
30
+ alias find_trigger run_route
31
+
32
+ end
33
+
34
+ class ActionsNlp
35
+ include AppRoutes
36
+
37
+ def initialize()
38
+
39
+ super()
40
+ params = {}
41
+ actions(params)
42
+
43
+ end
44
+
45
+ def actions(params)
46
+
47
+ get /^message popup: (.*)/i do |msg|
48
+ [ToastAction, {msg: msg}]
49
+ end
50
+
51
+
52
+ end
53
+
54
+ alias find_action run_route
55
+
56
+ end
57
+
11
58
  module Params
12
59
 
13
60
  refine Hash do
@@ -19,7 +66,7 @@ module Params
19
66
  h.inject({}) do |r, x|
20
67
 
21
68
  key, value = x
22
- puts 'value: ' + value.inspect
69
+ #puts 'value: ' + value.inspect
23
70
 
24
71
  val = if value.is_a?(Hash) then
25
72
  to_snake_case(value)
@@ -66,14 +113,18 @@ class Macro
66
113
  using Params
67
114
 
68
115
  attr_reader :local_variables, :triggers, :actions, :guid
116
+ attr_accessor :title
69
117
 
70
- def initialize(debug: false)
118
+ def initialize(name=nil, debug: false)
71
119
 
72
- @debug = debug
120
+ @title, @debug = name, debug
121
+
122
+ puts 'inside Macro#initialize' if @debug
123
+
73
124
  lv=[], triggers=[], actions=[]
74
125
  @local_variables, @triggers, @actions = lv, triggers, actions
75
126
 
76
- @triggers, @actions = [], []
127
+ @triggers, @actions, @constraints = [], [], []
77
128
  @h = {}
78
129
 
79
130
  end
@@ -105,7 +156,15 @@ class Macro
105
156
  local_variables: @local_variables,
106
157
  m_trigger_list: @triggers.map(&:to_h),
107
158
  m_action_list: @actions.map(&:to_h),
108
- m_constraint_list: []
159
+ m_constraint_list: [],
160
+ m_description: '',
161
+ m_name: @title,
162
+ m_excludeLog: false,
163
+ m_GUID: guid(),
164
+ m_isOrCondition: false,
165
+ m_enabled: false,
166
+ m_descriptionOpen: false,
167
+ m_headingColor: 0
109
168
  }
110
169
 
111
170
  puts 'h: ' + h.inspect if @debug
@@ -140,8 +199,112 @@ class Macro
140
199
  @h
141
200
 
142
201
  end
202
+
203
+ def import_xml(node)
204
+
205
+ if @debug then
206
+ puts 'inside Macro#import_xml'
207
+ puts 'node: ' + node.xml.inspect
208
+ end
209
+
210
+ @title = node.attributes[:name]
211
+
212
+ if node.element('triggers') then
213
+
214
+ # level 2
215
+
216
+ # get all the triggers
217
+ @triggers = node.xpath('triggers/*').map do |e|
218
+
219
+ puts 'e.name: ' + e.name.inspect if @debug
220
+ {timer: TimerTrigger}[e.name.to_sym].new(e.attributes.to_h)
221
+
222
+ end
223
+
224
+ # get all the actions
225
+ @actions = node.xpath('actions/*').map do |e|
226
+
227
+ if e.name == 'notification' then
228
+
229
+ case e.attributes[:type].to_sym
230
+ when :popup
231
+ e.attributes.delete :type
232
+ ToastAction.new e.attributes.to_h
233
+ end
234
+
235
+ end
236
+
237
+ end
238
+
239
+ else
240
+
241
+ # Level 1
242
+
243
+ tp = TriggersNlp.new
244
+
245
+ @triggers = node.xpath('trigger').map do |e|
246
+
247
+ r = tp.find_trigger e.text
248
+
249
+ puts 'found trigger ' + r.inspect if @debug
250
+
251
+ if r then
252
+ r[0].new(r[1])
253
+ end
254
+
255
+ end
256
+
257
+ ap = ActionsNlp.new
258
+
259
+ @actions = node.xpath('action').map do |e|
260
+
261
+ r = ap.find_action e.text
262
+ puts 'found action ' + r.inspect if @debug
263
+
264
+ if r then
265
+ r[0].new(r[1])
266
+ end
267
+
268
+ end
269
+
270
+ end
271
+
272
+ self
273
+
274
+ end
275
+
276
+ def match?(triggerx, detail={time: $env[:time]} )
277
+
278
+ if @triggers.any? {|x| x.type == triggerx and x.match?(detail) } then
279
+
280
+ if @debug then
281
+ puts 'checking constraints ...'
282
+ puts '@constraints: ' + @constraints.inspect
283
+ end
284
+
285
+ if @constraints.all? {|x| x.match?($env.merge(detail)) } then
286
+
287
+ true
288
+
289
+ else
290
+
291
+ return false
292
+
293
+ end
294
+
295
+ end
296
+
297
+ end
298
+
299
+ def run()
300
+ @actions.map(&:invoke)
301
+ end
143
302
 
144
303
  private
304
+
305
+ def guid()
306
+ '-' + rand(1..9).to_s + 18.times.map { rand 9 }.join
307
+ end
145
308
 
146
309
  def object(h={})
147
310
 
@@ -166,33 +329,20 @@ class MacroDroid
166
329
  if obj then
167
330
 
168
331
  s, _ = RXFHelper.read(obj)
169
- import_json(s) if s[0] == '{'
332
+
333
+ if s[0] == '{' then
334
+ import_json(s)
335
+ elsif s[0] == '<'
336
+ import_xml(s)
337
+ @h = build_h
338
+ else
339
+ import_xml(text_to_xml(s))
340
+ @h = build_h
341
+ end
170
342
 
171
343
  else
172
344
 
173
- @h = {
174
- cell_tower_groups: [],
175
- cell_towers_ignore: [],
176
- drawer_configuration: {
177
- drawer_items: [],
178
- background_color: -1,
179
- header_color: 12692882,
180
- left_side: false,
181
- swipe_area_color: -7829368,
182
- swipe_area_height: 20,
183
- swipe_area_offset: 40,
184
- swipe_area_opacity: 80,
185
- swipe_area_width: 14,
186
- visible_swipe_area_width: 0
187
- },
188
- variables: [],
189
- user_icons: [],
190
- geofence_data: {
191
- geofence_map: {}
192
- },
193
- macro_list: []
194
-
195
- }
345
+ @h = build_h()
196
346
 
197
347
  @macros = []
198
348
 
@@ -203,6 +353,34 @@ class MacroDroid
203
353
  @macros << macro
204
354
  end
205
355
 
356
+ def build_h()
357
+
358
+ puts 'inside Macro#build_h' if @debug
359
+ {
360
+ cell_tower_groups: [],
361
+ cell_towers_ignore: [],
362
+ drawer_configuration: {
363
+ drawer_items: [],
364
+ background_color: -1,
365
+ header_color: 12692882,
366
+ left_side: false,
367
+ swipe_area_color: -7829368,
368
+ swipe_area_height: 20,
369
+ swipe_area_offset: 40,
370
+ swipe_area_opacity: 80,
371
+ swipe_area_width: 14,
372
+ visible_swipe_area_width: 0
373
+ },
374
+ variables: [],
375
+ user_icons: [],
376
+ geofence_data: {
377
+ geofence_map: {}
378
+ },
379
+ macro_list: []
380
+
381
+ }
382
+ end
383
+
206
384
  def export_json()
207
385
 
208
386
  to_h.to_json
@@ -226,6 +404,49 @@ class MacroDroid
226
404
  end
227
405
 
228
406
  @h[:macro_list] = []
407
+
408
+ end
409
+
410
+ def import_xml(raws)
411
+
412
+ s = RXFHelper.read(raws).first
413
+ puts 's: ' + s.inspect if @debug
414
+ doc = Rexle.new(s)
415
+ puts 'after doc' if @debug
416
+
417
+ @macros = doc.root.xpath('macro').map do |node|
418
+
419
+ macro = Macro.new @title, debug: @debug
420
+ macro.import_xml(node)
421
+ macro
422
+
423
+ end
424
+ end
425
+
426
+ def text_to_xml(s)
427
+
428
+ a = s.split(/.*(?=^m:)/); a.shift
429
+ a.map!(&:chomp)
430
+
431
+ macros = a.map do |x|
432
+
433
+ lines = x.lines
434
+ puts 'lines: ' + lines.inspect if @debug
435
+
436
+ name = lines.shift[/^m: +(.*)/,1]
437
+ h = {t: [], a: [], c: []}
438
+
439
+ lines.each {|line| h[line[0].to_sym] << line[/^\w: +(.*)/,1] }
440
+ triggers = h[:t].map {|text| [:trigger, {}, text]}
441
+ actions = h[:a].map {|text| [:action, {}, text]}
442
+
443
+ [:macro, {name: name},'', *triggers, *actions]
444
+
445
+ end
446
+
447
+ doc = Rexle.new([:macros, {}, '', *macros])
448
+ doc.root.xml pretty: true
449
+
229
450
  end
230
451
 
231
452
  def to_h()
@@ -239,12 +460,22 @@ class MacroDroid
239
460
  end
240
461
 
241
462
  class MacroObject
463
+ using ColouredText
464
+
465
+ attr_reader :type
466
+ attr_accessor :options
242
467
 
243
468
  def initialize(h={})
244
469
 
245
470
  @h = {constraint_list: [], is_or_condition: false,
246
471
  is_disabled: false}.merge(h)
247
472
  @list = []
473
+
474
+ # fetch the class name and convert from camelCase to snake_eyes
475
+ @type = self.class.to_s.sub(/Trigger|Action$/,'')\
476
+ .gsub(/\B[A-Z][a-z]/){|x| '_' + x.downcase}\
477
+ .gsub(/[a-z][A-Z]/){|x| x[0] + '_' + x[1].downcase}\
478
+ .downcase.to_sym
248
479
  end
249
480
 
250
481
  def to_h()
@@ -267,6 +498,13 @@ class MacroObject
267
498
 
268
499
  protected
269
500
 
501
+ def filter(options, h)
502
+
503
+ (h.keys - options.keys).each {|key| h.delete key }
504
+ return h
505
+
506
+ end
507
+
270
508
  def uuid()
271
509
  UUID.new.generate
272
510
  end
@@ -279,973 +517,2473 @@ class Trigger < MacroObject
279
517
  super({fakeIcon: 0}.merge(h))
280
518
  @list << 'fakeIcon'
281
519
  end
520
+
521
+ def match?(detail={})
282
522
 
283
- end
284
-
285
-
286
-
287
- class WifiConnectionTrigger < Trigger
288
-
289
- def initialize(h={})
290
- super({}.merge(h))
523
+ detail.all? {|key,value| @h[key] == value}
524
+
291
525
  end
292
526
 
293
527
  end
294
528
 
529
+
530
+ # Category: Applications
531
+ #
295
532
  class WebHookTrigger < Trigger
296
533
 
297
- def initialize(h={})
298
- super({identifier: ''}.merge(h))
299
- @list << 'identifier'
300
- end
534
+ def initialize(h={})
301
535
 
302
- def identifier()
303
- @h[:identifier]
304
- end
536
+ options = {
537
+ identifier: ''
538
+ }
539
+
540
+ super(options.merge h)
305
541
 
306
- def identifier=(val)
307
- @h[:identifier] = val
308
542
  end
309
543
 
310
544
  end
311
545
 
546
+ # Category: Applications
547
+ #
548
+ # Also known as Wifi State Change
549
+ #
550
+ # wifi_state options:
551
+ # 0 - Wifi Enabled
552
+ # 1 - Wifi Disabled
553
+ # 2 - Connected to network
554
+ # ssid_list options:
555
+ # ["Any Network"]
556
+ # ["some Wifi SSID"] - 1 or more SSID can be supplied
557
+ # 3 - Disconnected from network
558
+ # ssid_list options:
559
+ # ["Any Network"]
560
+ # ["some Wifi SSID"] - 1 or more SSID can be supplied
561
+
312
562
  class WifiConnectionTrigger < Trigger
313
563
 
314
- def initialize(h={})
315
- super({}.merge h)
564
+ def initialize(h={})
565
+
566
+ options = {
567
+ ssid_list: [""],
568
+ wifi_state: 2
569
+ }
570
+
571
+ super(options.merge h)
572
+
316
573
  end
317
574
 
318
575
  end
319
576
 
577
+ # Category: Applications
578
+ #
320
579
  class ApplicationInstalledRemovedTrigger < Trigger
321
580
 
322
- def initialize(h={})
323
- super({}.merge h)
581
+ def initialize(h={})
582
+
583
+ options = {
584
+ application_name_list: [],
585
+ package_name_list: [],
586
+ installed: true,
587
+ application_option: 0,
588
+ updated: false
589
+ }
590
+
591
+ super(options.merge h)
592
+
324
593
  end
325
594
 
326
595
  end
327
596
 
597
+ # Category: Applications
598
+ #
328
599
  class ApplicationLaunchedTrigger < Trigger
329
600
 
330
- def initialize(h={})
331
- super({}.merge h)
601
+ def initialize(h={})
602
+
603
+ options = {
604
+ application_name_list: ["Chrome"],
605
+ package_name_list: ["com.android.chrome"],
606
+ launched: true
607
+ }
608
+
609
+ super(options.merge h)
610
+
332
611
  end
333
612
 
334
613
  end
335
614
 
615
+ # Category: Battery/Power
616
+ #
336
617
  class BatteryLevelTrigger < Trigger
337
618
 
338
- def initialize(h={})
339
- super({}.merge h)
619
+ def initialize(h={})
620
+
621
+ options = {
622
+ battery_level: 50,
623
+ decreases_to: true,
624
+ option: 0
625
+ }
626
+
627
+ super(options.merge h)
628
+
340
629
  end
341
630
 
342
631
  end
343
632
 
633
+ # Category: Battery/Power
634
+ #
344
635
  class BatteryTemperatureTrigger < Trigger
345
636
 
346
- def initialize(h={})
347
- super({}.merge h)
637
+ def initialize(h={})
638
+
639
+ options = {
640
+ decreases_to: true,
641
+ option: 0,
642
+ temperature: 30
643
+ }
644
+
645
+ super(options.merge h)
646
+
348
647
  end
349
648
 
350
649
  end
351
650
 
651
+ # Category: Battery/Power
652
+ #
352
653
  class PowerButtonToggleTrigger < Trigger
353
654
 
354
- def initialize(h={})
355
- super({}.merge h)
655
+ def initialize(h={})
656
+
657
+ options = {
658
+ num_toggles: 3
659
+ }
660
+
661
+ super(options.merge h)
662
+
356
663
  end
357
664
 
358
665
  end
359
666
 
667
+
668
+ # Category: Battery/Power
669
+ #
360
670
  class ExternalPowerTrigger < Trigger
361
671
 
362
- def initialize(h={})
363
- super({}.merge h)
672
+ def initialize(h={})
673
+
674
+ options = {
675
+ power_connected_options: [true, true, true],
676
+ has_set_usb_option: true,
677
+ power_connected: true,
678
+ has_set_new_power_connected_options: true
679
+ }
680
+
681
+ super(options.merge h)
682
+
364
683
  end
365
684
 
366
685
  end
367
686
 
687
+ # Category: Call/SMS
688
+ #
368
689
  class CallActiveTrigger < Trigger
369
690
 
370
- def initialize(h={})
371
- super({}.merge h)
691
+ def initialize(h={})
692
+
693
+ options = {
694
+ contact_list: [{:m_id=>"-2", :m_lookupKey=>"-2", :m_name=>"[Any Number]"}],
695
+ secondary_class_type: 'CallActiveTrigger',
696
+ signal_on: true
697
+ }
698
+
699
+ super(options.merge h)
700
+
372
701
  end
373
702
 
374
703
  end
375
704
 
705
+ # Category: Call/SMS
706
+ #
376
707
  class IncomingCallTrigger < Trigger
377
708
 
378
- def initialize(h={})
379
- super({}.merge h)
709
+ def initialize(h={})
710
+
711
+ options = {
712
+ incoming_call_from_list: [{:m_id=>"-2", :m_lookupKey=>"-2", :m_name=>"[Any Number]"}],
713
+ group_id_list: [],
714
+ group_name_list: [],
715
+ option: 0,
716
+ phone_number_exclude: false
717
+ }
718
+
719
+ super(options.merge h)
720
+
380
721
  end
381
722
 
382
723
  end
383
724
 
725
+ # Category: Call/SMS
726
+ #
384
727
  class OutgoingCallTrigger < Trigger
385
728
 
386
- def initialize(h={})
387
- super({}.merge h)
729
+ def initialize(h={})
730
+
731
+ options = {
732
+ outgoing_call_to_list: [{:m_id=>"-2", :m_lookupKey=>"-2", :m_name=>"[Any Number]"}],
733
+ group_id_list: [],
734
+ group_name_list: [],
735
+ option: 0,
736
+ phone_number_exclude: false
737
+ }
738
+
739
+ super(options.merge h)
740
+
388
741
  end
389
742
 
390
743
  end
391
744
 
745
+ # Category: Call/SMS
746
+ #
392
747
  class CallEndedTrigger < Trigger
393
748
 
394
- def initialize(h={})
395
- super({}.merge h)
749
+ def initialize(h={})
750
+
751
+ options = {
752
+ contact_list: [{:m_id=>"-2", :m_lookupKey=>"-2", :m_name=>"[Any Number]"}],
753
+ group_id_list: [],
754
+ group_name_list: [],
755
+ option: 0,
756
+ phone_number_exclude: false
757
+ }
758
+
759
+ super(options.merge h)
760
+
396
761
  end
397
762
 
398
763
  end
399
764
 
765
+ # Category: Call/SMS
766
+ #
400
767
  class CallMissedTrigger < Trigger
401
768
 
402
- def initialize(h={})
403
- super({}.merge h)
404
- end
769
+ def initialize(h={})
405
770
 
406
- end
771
+ options = {
772
+ contact_list: [{:m_id=>"-2", :m_lookupKey=>"-2", :m_name=>"[Any Number]"}]
773
+ }
407
774
 
408
- class IncomingSMSTrigger < Trigger
775
+ super(options.merge h)
409
776
 
410
- def initialize(h={})
411
- super({}.merge h)
412
777
  end
413
778
 
414
779
  end
415
780
 
416
- class BluetoothTrigger < Trigger
781
+ # Category: Call/SMS
782
+ #
783
+ class IncomingSMSTrigger < Trigger
417
784
 
418
- def initialize(h={})
419
- super({}.merge h)
420
- end
785
+ def initialize(h={})
421
786
 
422
- end
787
+ options = {
788
+ sms_from_list: [{:m_id=>"-2", :m_lookupKey=>"-2", :m_name=>"[Any Number]"}],
789
+ group_id_list: [],
790
+ group_name_list: [],
791
+ sms_content: '',
792
+ option: 0,
793
+ excludes: false,
794
+ exact_match: false,
795
+ enable_regex: false,
796
+ sms_number_exclude: false
797
+ }
423
798
 
424
- class HeadphonesTrigger < Trigger
799
+ super(options.merge h)
425
800
 
426
- def initialize(h={})
427
- super({}.merge h)
428
801
  end
429
802
 
430
803
  end
431
804
 
432
- class SignalOnOffTrigger < Trigger
805
+ # Category: Connectivity
806
+ #
807
+ class WebHookTrigger < Trigger
433
808
 
434
- def initialize(h={})
435
- super({}.merge h)
436
- end
809
+ def initialize(h={})
437
810
 
438
- end
811
+ options = {
812
+ identifier: ''
813
+ }
439
814
 
440
- class UsbDeviceConnectionTrigger < Trigger
815
+ super(options.merge h)
441
816
 
442
- def initialize(h={})
443
- super({}.merge h)
444
817
  end
445
818
 
446
819
  end
447
820
 
821
+ # Category: Connectivity
822
+ #
823
+ class WifiConnectionTrigger < Trigger
824
+
825
+ def initialize(h={})
826
+
827
+ options = {
828
+ ssid_list: [],
829
+ wifi_state: 0
830
+ }
831
+
832
+ super(options.merge h)
833
+
834
+ end
835
+
836
+ end
837
+
838
+ # Category: Connectivity
839
+ #
840
+ class BluetoothTrigger < Trigger
841
+
842
+ def initialize(h={})
843
+
844
+ options = {
845
+ device_name: 'Any Device',
846
+ bt_state: 0,
847
+ any_device: false
848
+ }
849
+
850
+ super(options.merge h)
851
+
852
+ end
853
+
854
+ end
855
+
856
+ # Category: Connectivity
857
+ #
858
+ class HeadphonesTrigger < Trigger
859
+
860
+ def initialize(h={})
861
+
862
+ options = {
863
+ headphones_connected: true,
864
+ mic_option: 0
865
+ }
866
+
867
+ super(options.merge h)
868
+
869
+ end
870
+
871
+ end
872
+
873
+ # Category: Connectivity
874
+ #
875
+ class SignalOnOffTrigger < Trigger
876
+
877
+ def initialize(h={})
878
+
879
+ options = {
880
+ signal_on: true
881
+ }
882
+
883
+ super(options.merge h)
884
+
885
+ end
886
+
887
+ end
888
+
889
+ # Category: Connectivity
890
+ #
891
+ class UsbDeviceConnectionTrigger < Trigger
892
+
893
+ def initialize(h={})
894
+
895
+ options = {
896
+ option: 0
897
+ }
898
+
899
+ super(options.merge h)
900
+
901
+ end
902
+
903
+ end
904
+
905
+ # Category: Connectivity
906
+ #
907
+ # Also known as Wifi SSID Transition
908
+ #
909
+ # options:
910
+ # in_range: true | false
911
+ # wifi_cell_info: {display_name: "some Wifi SSID",
912
+ # ssid: "some Wifi SSID"} - 1 or more allowed
913
+ #
448
914
  class WifiSSIDTrigger < Trigger
449
915
 
450
- def initialize(h={})
451
- super({}.merge h)
916
+ def initialize(h={})
917
+
918
+ options = {
919
+ wifi_cell_info_list: [{:display_name=>"", :ssid=>""}],
920
+ ssid_list: [],
921
+ in_range: true
922
+ }
923
+
924
+ super(options.merge h)
925
+
926
+ end
927
+
928
+ def to_h()
929
+
930
+ h = super()
931
+ val = h[:m_inRange]
932
+
933
+ h[:m_InRange] = val
934
+ h.delete :m_inRange
935
+
936
+ return h
937
+
938
+ end
939
+
940
+ end
941
+
942
+ # Category: Date/Time
943
+ #
944
+ class CalendarTrigger < Trigger
945
+
946
+ def initialize(h={})
947
+
948
+ options = {
949
+ title_text: '',
950
+ detail_text: '',
951
+ calendar_name: 'Contacts',
952
+ calendar_id: '3',
953
+ availability: 0,
954
+ check_in_advance: false,
955
+ advance_time_seconds: 0,
956
+ event_start: true,
957
+ ignore_all_day: false,
958
+ negative_advance_check: false,
959
+ enable_regex: false
960
+ }
961
+
962
+ super(options.merge h)
963
+
964
+ end
965
+
966
+ end
967
+
968
+ # Category: Date/Time
969
+ #
970
+ class TimerTrigger < Trigger
971
+ using ColouredText
972
+
973
+
974
+ def initialize(h={})
975
+
976
+ puts 'TimerTrigger h: ' + h.inspect if $debug
977
+
978
+ if h[:days] then
979
+
980
+ days = [false] * 7
981
+
982
+ h[:days].split(/, */).each do |x|
983
+
984
+ r = Date::DAYNAMES.grep /#{x}/i
985
+ i = Date::DAYNAMES.index(r.first)
986
+ days[i-1] = true
987
+
988
+ end
989
+
990
+ h[:days_of_week] = days
991
+
992
+ end
993
+
994
+ if h[:time] then
995
+
996
+ t = Time.parse(h[:time])
997
+ h[:hour], h[:minute] = t.hour, t.min
998
+
999
+ end
1000
+
1001
+ #puts ('h: ' + h.inspect).debug
1002
+
1003
+ options = {
1004
+ alarm_id: uuid(),
1005
+ days_of_week: [false, false, false, false, false, false, false],
1006
+ minute: 10,
1007
+ hour: 7,
1008
+ use_alarm: false
1009
+ }
1010
+
1011
+ super(options.merge filter(options,h))
1012
+
1013
+ end
1014
+
1015
+ def match?(detail={time: $env[:time]})
1016
+
1017
+ a = @h[:days_of_week]
1018
+ a.unshift a.pop
1019
+
1020
+ dow = a.map.with_index {|x, i| x ? i : nil }.compact.join(',')
1021
+
1022
+ s = "%s %s * * %s" % [@h[:minute], @h[:hour], dow]
1023
+
1024
+ if $debug then
1025
+ puts 's: ' + s.inspect
1026
+ puts 'detail: ' + detail.inspect
1027
+ puts '@h: ' + @h.inspect
1028
+ end
1029
+
1030
+ ChronicCron.new(s, detail[:time]).to_time == detail[:time]
1031
+
1032
+ end
1033
+
1034
+ end
1035
+
1036
+ # Category: Date/Time
1037
+ #
1038
+ class StopwatchTrigger < Trigger
1039
+
1040
+ def initialize(h={})
1041
+
1042
+ options = {
1043
+ stopwatch_name: 'timer1',
1044
+ seconds: 240
1045
+ }
1046
+
1047
+ super(options.merge h)
1048
+
1049
+ end
1050
+
1051
+ end
1052
+
1053
+ # Category: Date/Time
1054
+ #
1055
+ # Also known as Day of Week/Month
1056
+ #
1057
+ # month_of_year equal to 0 means it occurs every month
1058
+ # day_of_week starts with a Monday (value is 0)
1059
+ #
1060
+ class DayTrigger < Trigger
1061
+
1062
+ def initialize(h={})
1063
+
1064
+ options = {
1065
+ alarm_id: uuid(),
1066
+ hour: 9,
1067
+ minute: 0,
1068
+ month_of_year: 0,
1069
+ option: 0,
1070
+ day_of_week: 2,
1071
+ day_of_month: 0,
1072
+ use_alarm: false
1073
+ }
1074
+
1075
+ super(options.merge h)
1076
+
1077
+ end
1078
+
1079
+ end
1080
+
1081
+ # Category: Date/Time
1082
+ #
1083
+ # Regular Interval
1084
+ #
1085
+ class RegularIntervalTrigger < Trigger
1086
+
1087
+ def initialize(h={})
1088
+
1089
+ options = {
1090
+ ignore_reference_start_time: false,
1091
+ minutes: 0,
1092
+ seconds: 7200,
1093
+ start_hour: 9,
1094
+ start_minute: 10,
1095
+ use_alarm: false
1096
+ }
1097
+
1098
+ super(options.merge h)
1099
+
1100
+ end
1101
+
1102
+ end
1103
+
1104
+ # Category: Device Events
1105
+ #
1106
+ # Airplane Mode Changed
1107
+ #
1108
+ # options:
1109
+ # Airplane Mode Enabled
1110
+ # Airplane Mode Disabled
1111
+ #
1112
+ # shorthand example:
1113
+ # airplanemode: enabled
1114
+ #
1115
+ class AirplaneModeTrigger < Trigger
1116
+
1117
+ def initialize(h={})
1118
+
1119
+ options = {
1120
+ airplane_mode_enabled: true
1121
+ }
1122
+
1123
+ super(options.merge h)
1124
+
1125
+ end
1126
+
1127
+ end
1128
+
1129
+ # Category: Device Events
1130
+ #
1131
+ class AutoSyncChangeTrigger < Trigger
1132
+
1133
+ def initialize(h={})
1134
+
1135
+ options = {
1136
+ option: 0
1137
+ }
1138
+
1139
+ super(options.merge h)
1140
+
1141
+ end
1142
+
1143
+ end
1144
+
1145
+ # Category: Device Events
1146
+ #
1147
+ class DayDreamTrigger < Trigger
1148
+
1149
+ def initialize(h={})
1150
+
1151
+ options = {
1152
+ day_dream_enabled: true
1153
+ }
1154
+
1155
+ super(options.merge h)
1156
+
1157
+ end
1158
+
1159
+ end
1160
+
1161
+ # Category: Device Events
1162
+ #
1163
+ class DockTrigger < Trigger
1164
+
1165
+ def initialize(h={})
1166
+
1167
+ options = {
1168
+ dock_type: 0
1169
+ }
1170
+
1171
+ super(options.merge h)
1172
+
1173
+ end
1174
+
1175
+ end
1176
+
1177
+ # Category: Device Events
1178
+ #
1179
+ class GPSEnabledTrigger < Trigger
1180
+
1181
+ def initialize(h={})
1182
+
1183
+ options = {
1184
+ gps_mode_enabled: true
1185
+ }
1186
+
1187
+ super(options.merge h)
1188
+
1189
+ end
1190
+
1191
+ end
1192
+
1193
+ # Category: Device Events
1194
+ #
1195
+ class MusicPlayingTrigger < Trigger
1196
+
1197
+ def initialize(h={})
1198
+
1199
+ options = {
1200
+ option: 0
1201
+ }
1202
+
1203
+ super(options.merge h)
1204
+
1205
+ end
1206
+
1207
+ end
1208
+
1209
+
1210
+ # Category: Device Events
1211
+ #
1212
+ class DeviceUnlockedTrigger < Trigger
1213
+
1214
+ def initialize(h={})
1215
+
1216
+ options = {
1217
+ }
1218
+
1219
+ super(options.merge h)
1220
+
1221
+ end
1222
+
1223
+ end
1224
+
1225
+ # Category: Device Events
1226
+ #
1227
+ class AutoRotateChangeTrigger < Trigger
1228
+
1229
+ def initialize(h={})
1230
+
1231
+ options = {
1232
+ option: 0
1233
+ }
1234
+
1235
+ super(options.merge h)
1236
+
1237
+ end
1238
+
1239
+ end
1240
+
1241
+ # Category: Device Events
1242
+ #
1243
+ class ClipboardChangeTrigger < Trigger
1244
+
1245
+ def initialize(h={})
1246
+
1247
+ options = {
1248
+ text: '',
1249
+ enable_regex: false
1250
+ }
1251
+
1252
+ super(options.merge h)
1253
+
1254
+ end
1255
+
1256
+ end
1257
+
1258
+ # Category: Device Events
1259
+ #
1260
+ class BootTrigger < Trigger
1261
+
1262
+ def initialize(h={})
1263
+
1264
+ options = {
1265
+ }
1266
+
1267
+ super(options.merge h)
1268
+
1269
+ end
1270
+
1271
+ end
1272
+
1273
+ # Category: Device Events
1274
+ #
1275
+ class IntentReceivedTrigger < Trigger
1276
+
1277
+ def initialize(h={})
1278
+
1279
+ options = {
1280
+ action: '',
1281
+ extra_params: [],
1282
+ extra_value_patterns: [],
1283
+ extra_variables: [],
1284
+ enable_regex: false
1285
+ }
1286
+
1287
+ super(options.merge h)
1288
+
1289
+ end
1290
+
1291
+ end
1292
+
1293
+ # Category: Device Events
1294
+ #
1295
+ class NotificationTrigger < Trigger
1296
+
1297
+ def initialize(h={})
1298
+
1299
+ options = {
1300
+ text_content: '',
1301
+ package_name_list: ["Any Application"],
1302
+ application_name_list: ["Any Application"],
1303
+ exclude_apps: false,
1304
+ ignore_ongoing: true,
1305
+ option: 0,
1306
+ exact_match: false,
1307
+ excludes: false,
1308
+ sound_option: 0,
1309
+ supress_multiples: true,
1310
+ enable_regex: false
1311
+ }
1312
+
1313
+ super(options.merge h)
1314
+
1315
+ end
1316
+
1317
+ end
1318
+
1319
+ # Category: Device Events
1320
+ #
1321
+ class ScreenOnOffTrigger < Trigger
1322
+
1323
+ def initialize(h={})
1324
+
1325
+ options = {
1326
+ screen_on: true
1327
+ }
1328
+
1329
+ super(options.merge h)
1330
+
1331
+ end
1332
+
1333
+ end
1334
+
1335
+ # Category: Device Events
1336
+ #
1337
+ class SilentModeTrigger < Trigger
1338
+
1339
+ def initialize(h={})
1340
+
1341
+ options = {
1342
+ silent_enabled: true
1343
+ }
1344
+
1345
+ super(options.merge h)
1346
+
1347
+ end
1348
+
1349
+ end
1350
+
1351
+ # Category: Location
1352
+ #
1353
+ class WeatherTrigger < Trigger
1354
+
1355
+ def initialize(h={})
1356
+
1357
+ options = {
1358
+ humidity_above: true,
1359
+ humidity_value: 50,
1360
+ option: 4,
1361
+ temp_below: true,
1362
+ temp_celcius: true,
1363
+ temperature: 0,
1364
+ weather_condition: 0,
1365
+ wind_speed_above: true,
1366
+ wind_speed_value: 0,
1367
+ wind_speed_value_mph: 0
1368
+ }
1369
+
1370
+ super(options.merge h)
1371
+
1372
+ end
1373
+
1374
+ end
1375
+
1376
+ # Category: Location
1377
+ #
1378
+ class GeofenceTrigger < Trigger
1379
+
1380
+ def initialize(h={})
1381
+
1382
+ options = {
1383
+ update_rate_text: '5 Minutes',
1384
+ geofence_id: '',
1385
+ geofence_update_rate_minutes: 5,
1386
+ trigger_from_unknown: false,
1387
+ enter_area: true
1388
+ }
1389
+
1390
+ super(options.merge h)
1391
+
1392
+ end
1393
+
1394
+ end
1395
+
1396
+ # Category: Location
1397
+ #
1398
+ class SunriseSunsetTrigger < Trigger
1399
+
1400
+ def initialize(h={})
1401
+
1402
+ options = {
1403
+ option: 0,
1404
+ time_adjust_seconds: 0
1405
+ }
1406
+
1407
+ super(options.merge h)
1408
+
1409
+ end
1410
+
1411
+ end
1412
+
1413
+ # Category: Sensors
1414
+ #
1415
+ class ActivityRecognitionTrigger < Trigger
1416
+
1417
+ def initialize(h={})
1418
+
1419
+ options = {
1420
+ confidence_level: 50,
1421
+ selected_index: 1
1422
+ }
1423
+
1424
+ super(options.merge h)
1425
+
1426
+ end
1427
+
1428
+ end
1429
+
1430
+ # Category: Sensors
1431
+ #
1432
+ class ProximityTrigger < Trigger
1433
+
1434
+ def initialize(h={})
1435
+
1436
+ options = {
1437
+ near: true,
1438
+ selected_option: 0
1439
+ }
1440
+
1441
+ super(options.merge h)
1442
+
1443
+ end
1444
+
1445
+ end
1446
+
1447
+ # Category: Sensors
1448
+ #
1449
+ class ShakeDeviceTrigger < Trigger
1450
+
1451
+ def initialize(h={})
1452
+
1453
+ options = {
1454
+ }
1455
+
1456
+ super(options.merge h)
1457
+
1458
+ end
1459
+
1460
+ end
1461
+
1462
+ # Category: Sensors
1463
+ #
1464
+ class FlipDeviceTrigger < Trigger
1465
+
1466
+ def initialize(h={})
1467
+
1468
+ options = {
1469
+ any_start: false,
1470
+ face_down: true,
1471
+ work_with_screen_off: false
1472
+ }
1473
+
1474
+ super(options.merge h)
1475
+
1476
+ end
1477
+
1478
+ end
1479
+
1480
+ # Category: Sensors
1481
+ #
1482
+ class OrientationTrigger < Trigger
1483
+
1484
+ def initialize(h={})
1485
+
1486
+ options = {
1487
+ check_orientation_alive: true,
1488
+ option: 0
1489
+ }
1490
+
1491
+ super(options.merge h)
1492
+
1493
+ end
1494
+
1495
+ end
1496
+
1497
+ # Category: User Input
1498
+ #
1499
+ class FloatingButtonTrigger < Trigger
1500
+
1501
+ def initialize(h={})
1502
+
1503
+ options = {
1504
+ image_resource_id: 0,
1505
+ icon_bg_color: -9079435,
1506
+ alpha: 100,
1507
+ padding: 20,
1508
+ force_location: false,
1509
+ show_on_lock_screen: false,
1510
+ size: 0,
1511
+ transparent_background: false,
1512
+ x_location: 0,
1513
+ y_location: 0
1514
+ }
1515
+
1516
+ super(options.merge h)
1517
+
1518
+ end
1519
+
1520
+ end
1521
+
1522
+ # Category: User Input
1523
+ #
1524
+ class ShortcutTrigger < Trigger
1525
+
1526
+ def initialize(h={})
1527
+
1528
+ options = {
1529
+ }
1530
+
1531
+ super(options.merge h)
1532
+
1533
+ end
1534
+
1535
+ end
1536
+
1537
+ # Category: User Input
1538
+ #
1539
+ class VolumeButtonTrigger < Trigger
1540
+
1541
+ def initialize(h={})
1542
+
1543
+ options = {
1544
+ dont_change_volume: true,
1545
+ monitor_option: 1,
1546
+ not_configured: false,
1547
+ option: 0
1548
+ }
1549
+
1550
+ super(options.merge h)
1551
+
1552
+ end
1553
+
1554
+ end
1555
+
1556
+ # Category: User Input
1557
+ #
1558
+ class MediaButtonPressedTrigger < Trigger
1559
+
1560
+ def initialize(h={})
1561
+
1562
+ options = {
1563
+ option: 'Single Press',
1564
+ cancel_press: false
1565
+ }
1566
+
1567
+ super(options.merge h)
1568
+
1569
+ end
1570
+
1571
+ end
1572
+
1573
+ # Category: User Input
1574
+ #
1575
+ class SwipeTrigger < Trigger
1576
+
1577
+ def initialize(h={})
1578
+
1579
+ options = {
1580
+ swipe_start_area: 0,
1581
+ swipe_motion: 0,
1582
+ cleared: true
1583
+ }
1584
+
1585
+ super(options.merge h)
1586
+
1587
+ end
1588
+
1589
+ end
1590
+
1591
+
1592
+ class Action < MacroObject
1593
+
1594
+ def initialize(h={})
1595
+ super(h)
1596
+ end
1597
+
1598
+ def invoke(s='')
1599
+ "%s/%s: %s" % [@group, @type, s]
1600
+ end
1601
+
1602
+ end
1603
+
1604
+
1605
+ class LocationAction < Action
1606
+
1607
+ def initialize(h={})
1608
+ super(h)
1609
+ @group = 'location'
1610
+ end
1611
+
1612
+ end
1613
+
1614
+ # Category: Location
1615
+ #
1616
+ class ShareLocationAction < LocationAction
1617
+
1618
+ def initialize(h={})
1619
+
1620
+ super()
1621
+
1622
+ options = {
1623
+ email: '',
1624
+ variable: {:m_stringValue=>"", :m_name=>"",
1625
+ :m_decimalValue=>0.0, :isLocal=>true, :m_booleanValue=>false,
1626
+ :excludeFromLog=>false, :m_intValue=>0, :m_type=>2},
1627
+ sim_id: 0,
1628
+ output_channel: 5,
1629
+ old_variable_format: true
1630
+ }
1631
+
1632
+ super(options.merge h)
1633
+
1634
+ end
1635
+
1636
+ end
1637
+
1638
+
1639
+ class ApplicationAction < Action
1640
+
1641
+ def initialize(h={})
1642
+ super(h)
1643
+ @group = 'application'
1644
+ end
1645
+
1646
+ end
1647
+
1648
+ # Category: Applications
1649
+ #
1650
+ class LaunchActivityAction < ApplicationAction
1651
+
1652
+ def initialize(h={})
1653
+
1654
+ options = {
1655
+ application_name: 'Chrome',
1656
+ package_to_launch: 'com.android.chrome',
1657
+ exclude_from_recents: false,
1658
+ start_new: false
1659
+ }
1660
+
1661
+ super(options.merge h)
1662
+
1663
+ end
1664
+
1665
+ end
1666
+
1667
+ # Category: Applications
1668
+ #
1669
+ class KillBackgroundAppAction < ApplicationAction
1670
+
1671
+ def initialize(h={})
1672
+
1673
+ options = {
1674
+ application_name_list: [""],
1675
+ package_name_list: [""]
1676
+ }
1677
+
1678
+ super(options.merge h)
1679
+
1680
+ end
1681
+
1682
+ end
1683
+
1684
+ # Category: Applications
1685
+ #
1686
+ class OpenWebPageAction < ApplicationAction
1687
+
1688
+ def initialize(h={})
1689
+
1690
+ options = {
1691
+ variable_to_save_response: {:m_stringValue=>"", :m_name=>"", :m_decimalValue=>0.0, :isLocal=>true, :m_booleanValue=>false, :excludeFromLog=>false, :m_intValue=>0, :m_type=>2},
1692
+ url_to_open: '',
1693
+ http_get: true,
1694
+ disable_url_encode: false,
1695
+ block_next_action: false
1696
+ }
1697
+
1698
+ super(options.merge h)
1699
+
1700
+ end
1701
+
1702
+ end
1703
+
1704
+
1705
+ class CameraAction < Action
1706
+
1707
+ def initialize(h={})
1708
+ super(h)
1709
+ @group = 'camera'
1710
+ end
1711
+
1712
+ end
1713
+
1714
+ # Category: Camera/Photo
1715
+ #
1716
+ class UploadPhotoAction < CameraAction
1717
+
1718
+ def initialize(h={})
1719
+
1720
+ options = {
1721
+ option: 'Via Intent',
1722
+ use_smtp_email: false
1723
+ }
1724
+
1725
+ super(options.merge h)
1726
+
1727
+ end
1728
+
1729
+ end
1730
+
1731
+ # Category: Camera/Photo
1732
+ #
1733
+ class TakePictureAction < CameraAction
1734
+
1735
+ def initialize(h={})
1736
+
1737
+ options = {
1738
+ new_path: '/storage/sdcard1/DCIM/Camera',
1739
+ path: '/storage/sdcard1/DCIM/Camera',
1740
+ show_icon: true,
1741
+ use_front_camera: true,
1742
+ flash_option: 0
1743
+ }
1744
+
1745
+ super(options.merge h)
1746
+
1747
+ end
1748
+
1749
+ end
1750
+
1751
+
1752
+ class ConnectivityAction < Action
1753
+
1754
+ def initialize(h={})
1755
+ super(h)
1756
+ @group = 'connectivity'
1757
+ end
1758
+
1759
+ end
1760
+
1761
+ # Category: Connectivity
1762
+ #
1763
+ class SetWifiAction < ConnectivityAction
1764
+
1765
+ def initialize(h={})
1766
+
1767
+ options = {
1768
+ ssid: '[Select Wifi]',
1769
+ network_id: 0,
1770
+ state: 0
1771
+ }
1772
+
1773
+ super(options.merge h)
1774
+
1775
+ end
1776
+
1777
+ end
1778
+
1779
+ # Category: Connectivity
1780
+ #
1781
+ class SetBluetoothAction < ConnectivityAction
1782
+
1783
+ def initialize(h={})
1784
+
1785
+ options = {
1786
+ device_name: '',
1787
+ state: 0
1788
+ }
1789
+
1790
+ super(options.merge h)
1791
+
1792
+ end
1793
+
1794
+ end
1795
+
1796
+ # Category: Connectivity
1797
+ #
1798
+ class SetBluetoothAction < ConnectivityAction
1799
+
1800
+ def initialize(h={})
1801
+
1802
+ options = {
1803
+ device_name: '',
1804
+ state: 1
1805
+ }
1806
+
1807
+ super(options.merge h)
1808
+
1809
+ end
1810
+
1811
+ end
1812
+
1813
+ # Category: Connectivity
1814
+ #
1815
+ class SendIntentAction < ConnectivityAction
1816
+
1817
+ def initialize(h={})
1818
+
1819
+ options = {
1820
+ action: '',
1821
+ class_name: '',
1822
+ data: '',
1823
+ extra1_name: '',
1824
+ extra1_value: '',
1825
+ extra2_name: '',
1826
+ extra2_value: '',
1827
+ extra3_name: '',
1828
+ extra3_value: '',
1829
+ extra4_name: '',
1830
+ extra4_value: '',
1831
+ package_name: '',
1832
+ target: 'Activity'
1833
+ }
1834
+
1835
+ super(options.merge h)
1836
+
1837
+ end
1838
+
1839
+ end
1840
+
1841
+
1842
+ class DateTimeAction < Action
1843
+
1844
+ def initialize(h={})
1845
+ super(h)
1846
+ @group = 'datetime'
1847
+ end
1848
+
1849
+ end
1850
+
1851
+ # Category: Date/Time
1852
+ #
1853
+ class SetAlarmClockAction < DateTimeAction
1854
+
1855
+ def initialize(h={})
1856
+
1857
+ options = {
1858
+ days_of_week: [false, false, false, false, false, false, false],
1859
+ label: 'wakeup mum',
1860
+ delay_in_minutes: 1,
1861
+ hour: 8,
1862
+ delay_in_hours: 0,
1863
+ minute: 15,
1864
+ one_off: true,
1865
+ option: 0,
1866
+ relative: true,
1867
+ day_option: 0
1868
+ }
1869
+
1870
+ super(options.merge h)
1871
+
1872
+ end
1873
+
1874
+ end
1875
+
1876
+ # Category: Date/Time
1877
+ #
1878
+ class StopWatchAction < DateTimeAction
1879
+
1880
+ def initialize(h={})
1881
+
1882
+ options = {
1883
+ stopwatch_name: 'timer1',
1884
+ option: 0
1885
+ }
1886
+
1887
+ super(options.merge h)
1888
+
1889
+ end
1890
+
1891
+ end
1892
+
1893
+ # Category: Date/Time
1894
+ #
1895
+ class SayTimeAction < DateTimeAction
1896
+
1897
+ def initialize(h={})
1898
+
1899
+ options = {
1900
+ :'12_hour' => true
1901
+ }
1902
+
1903
+ super(options.merge h)
1904
+
1905
+ end
1906
+
1907
+ end
1908
+
1909
+
1910
+ class DeviceAction < Action
1911
+
1912
+ def initialize(h={})
1913
+ super(h)
1914
+ @group = 'device'
1915
+ end
1916
+
1917
+ end
1918
+
1919
+ # Category: Device Actions
1920
+ #
1921
+ class AndroidShortcutsAction < DeviceAction
1922
+
1923
+ def initialize(h={})
1924
+
1925
+ options = {
1926
+ option: 1
1927
+ }
1928
+
1929
+ super(options.merge h)
1930
+
1931
+ end
1932
+
1933
+ end
1934
+
1935
+ # Category: Device Actions
1936
+ #
1937
+ class ClipboardAction < DeviceAction
1938
+
1939
+ def initialize(h={})
1940
+
1941
+ options = {
1942
+ clipboard_text: ''
1943
+ }
1944
+
1945
+ super(options.merge h)
1946
+
1947
+ end
1948
+
1949
+ end
1950
+
1951
+ # Category: Device Actions
1952
+ #
1953
+ class PressBackAction < DeviceAction
1954
+
1955
+ def initialize(h={})
1956
+
1957
+ options = {
1958
+ }
1959
+
1960
+ super(options.merge h)
1961
+
1962
+ end
1963
+
1964
+ end
1965
+
1966
+ # Category: Device Actions
1967
+ #
1968
+ class SpeakTextAction < DeviceAction
1969
+
1970
+ def initialize(h={})
1971
+
1972
+ options = {
1973
+ text_to_say: '',
1974
+ queue: false,
1975
+ read_numbers_individually: false,
1976
+ specify_audio_stream: false,
1977
+ speed: 0.99,
1978
+ pitch: 0.99,
1979
+ wait_to_finish: false,
1980
+ audio_stream: 0
1981
+ }
1982
+
1983
+ super(options.merge h)
1984
+
1985
+ end
1986
+
1987
+ end
1988
+
1989
+ # Category: Device Actions
1990
+ #
1991
+ class UIInteractionAction < DeviceAction
1992
+
1993
+ def initialize(h={})
1994
+
1995
+ options = {
1996
+ ui_interaction_configuration: {:type=>"Copy"},
1997
+ action: 2
1998
+ }
1999
+
2000
+ super(options.merge h)
2001
+
452
2002
  end
453
2003
 
454
2004
  end
455
2005
 
456
- class CalendarTrigger < Trigger
2006
+ # Category: Device Actions
2007
+ #
2008
+ class VoiceSearchAction < DeviceAction
2009
+
2010
+ def initialize(h={})
2011
+
2012
+ options = {
2013
+ }
2014
+
2015
+ super(options.merge h)
457
2016
 
458
- def initialize(h={})
459
- super({}.merge h)
460
2017
  end
461
2018
 
462
2019
  end
2020
+
2021
+
2022
+ class DeviceSettingsAction < Action
463
2023
 
2024
+ def initialize(h={})
2025
+ super(h)
2026
+ @group = 'devicesettings'
2027
+ end
464
2028
 
2029
+ end
465
2030
 
466
-
467
- class TimerTrigger < Trigger
2031
+ # Category: Device Settings
2032
+ #
2033
+ class ExpandCollapseStatusBarAction < DeviceSettingsAction
2034
+
2035
+ def initialize(h={})
468
2036
 
469
- def initialize(h={})
470
-
471
2037
  options = {
472
- alarm_id: uuid(),
473
- days_of_week: [false, true, false, false, false, false, false],
474
- hour: 0,
475
- minute: 0,
476
- use_alarm: false
2038
+ option: 0
477
2039
  }
478
-
2040
+
479
2041
  super(options.merge h)
480
-
481
-
2042
+
482
2043
  end
483
2044
 
484
2045
  end
485
2046
 
486
- class StopwatchTrigger < Trigger
2047
+ # Category: Device Settings
2048
+ #
2049
+ class LaunchHomeScreenAction < DeviceSettingsAction
487
2050
 
488
- def initialize(h={})
489
- super({}.merge h)
490
- end
2051
+ def initialize(h={})
491
2052
 
492
- end
2053
+ options = {
2054
+ }
493
2055
 
494
- class DayTrigger < Trigger
2056
+ super(options.merge h)
495
2057
 
496
- def initialize(h={})
497
- super({}.merge h)
498
2058
  end
499
2059
 
500
2060
  end
501
2061
 
502
- class RegularIntervalTrigger < Trigger
2062
+ # Category: Device Settings
2063
+ #
2064
+ class CameraFlashLightAction < DeviceSettingsAction
503
2065
 
504
- def initialize(h={})
505
- super({}.merge h)
506
- end
2066
+ def initialize(h={})
507
2067
 
508
- end
2068
+ options = {
2069
+ launch_foreground: false,
2070
+ state: 0
2071
+ }
509
2072
 
510
- class AirplaneModeTrigger < Trigger
2073
+ super(options.merge h)
511
2074
 
512
- def initialize(h={})
513
- super({}.merge h)
514
2075
  end
515
2076
 
516
2077
  end
517
2078
 
518
- class AutoSyncChangeTrigger < Trigger
2079
+ # Category: Device Settings
2080
+ #
2081
+ class VibrateAction < DeviceSettingsAction
519
2082
 
520
- def initialize(h={})
521
- super({}.merge h)
522
- end
2083
+ def initialize(h={})
523
2084
 
524
- end
2085
+ options = {
2086
+ vibrate_pattern: 1
2087
+ }
525
2088
 
526
- class DayDreamTrigger < Trigger
2089
+ super(options.merge h)
527
2090
 
528
- def initialize(h={})
529
- super({}.merge h)
530
2091
  end
531
2092
 
532
2093
  end
533
2094
 
534
- class DockTrigger < Trigger
2095
+ # Category: Device Settings
2096
+ #
2097
+ class SetAutoRotateAction < DeviceSettingsAction
535
2098
 
536
- def initialize(h={})
537
- super({}.merge h)
538
- end
2099
+ def initialize(h={})
539
2100
 
540
- end
2101
+ options = {
2102
+ state: 0
2103
+ }
541
2104
 
542
- class GPSEnabledTrigger < Trigger
2105
+ super(options.merge h)
543
2106
 
544
- def initialize(h={})
545
- super({}.merge h)
546
2107
  end
547
2108
 
548
2109
  end
549
2110
 
550
- class MusicPlayingTrigger < Trigger
2111
+ # Category: Device Settings
2112
+ #
2113
+ class DayDreamAction < DeviceSettingsAction
551
2114
 
552
- def initialize(h={})
553
- super({}.merge h)
554
- end
2115
+ def initialize(h={})
555
2116
 
556
- end
2117
+ options = {
2118
+ }
557
2119
 
558
- class DeviceUnlockedTrigger < Trigger
2120
+ super(options.merge h)
559
2121
 
560
- def initialize(h={})
561
- super({}.merge h)
562
2122
  end
563
2123
 
564
2124
  end
565
2125
 
566
- class AutoRotateChangeTrigger < Trigger
2126
+ # Category: Device Settings
2127
+ #
2128
+ class SetKeyboardAction < DeviceSettingsAction
567
2129
 
568
- def initialize(h={})
569
- super({}.merge h)
570
- end
2130
+ def initialize(h={})
571
2131
 
572
- end
2132
+ options = {
2133
+ }
573
2134
 
574
- class ClipboardChangeTrigger < Trigger
2135
+ super(options.merge h)
575
2136
 
576
- def initialize(h={})
577
- super({}.merge h)
578
2137
  end
579
2138
 
580
2139
  end
581
2140
 
582
- class BootTrigger < Trigger
2141
+ # Category: Device Settings
2142
+ #
2143
+ class SetKeyguardAction < DeviceSettingsAction
583
2144
 
584
- def initialize(h={})
585
- super({}.merge h)
586
- end
2145
+ def initialize(h={})
587
2146
 
588
- end
2147
+ options = {
2148
+ keyguard_on: true
2149
+ }
589
2150
 
590
- class IntentReceivedTrigger < Trigger
2151
+ super(options.merge h)
591
2152
 
592
- def initialize(h={})
593
- super({}.merge h)
594
2153
  end
595
2154
 
596
2155
  end
597
2156
 
598
- class NotificationTrigger < Trigger
2157
+ # Category: Device Settings
2158
+ #
2159
+ class CarModeAction < DeviceSettingsAction
599
2160
 
600
- def initialize(h={})
601
- super({}.merge h)
602
- end
2161
+ def initialize(h={})
603
2162
 
604
- end
2163
+ options = {
2164
+ option: 0
2165
+ }
605
2166
 
606
- class ScreenOnOffTrigger < Trigger
2167
+ super(options.merge h)
607
2168
 
608
- def initialize(h={})
609
- super({}.merge h)
610
2169
  end
611
2170
 
612
2171
  end
613
2172
 
614
- class SilentModeTrigger < Trigger
2173
+ # Category: Device Settings
2174
+ #
2175
+ class ChangeKeyboardAction < DeviceSettingsAction
615
2176
 
616
- def initialize(h={})
617
- super({}.merge h)
618
- end
2177
+ def initialize(h={})
619
2178
 
620
- end
2179
+ options = {
2180
+ keyboard_id: 'com.android.inputmethod.latin/.LatinIME',
2181
+ keyboard_name: 'Android Keyboard (AOSP)'
2182
+ }
621
2183
 
622
- class WeatherTrigger < Trigger
2184
+ super(options.merge h)
623
2185
 
624
- def initialize(h={})
625
- super({}.merge h)
626
2186
  end
627
2187
 
628
2188
  end
629
2189
 
630
- class GeofenceTrigger < Trigger
2190
+ # Category: Device Settings
2191
+ #
2192
+ class SetWallpaperAction < DeviceSettingsAction
631
2193
 
632
- def initialize(h={})
633
- super({}.merge h)
634
- end
2194
+ def initialize(h={})
635
2195
 
636
- end
2196
+ options = {
2197
+ image_name: '6051449505275476553',
2198
+ s_screen_options: ["Home Screen", "Lock Screen", "Home + Lock Screen"],
2199
+ s_options: ["Image", "Live Wallpaper (Preview Screen)"],
2200
+ wallpaper_uri_string: 'content://media/external/images/media/928',
2201
+ screen_option: 0,
2202
+ option: 0
2203
+ }
637
2204
 
638
- class SunriseSunsetTrigger < Trigger
2205
+ super(options.merge h)
639
2206
 
640
- def initialize(h={})
641
- super({}.merge h)
642
2207
  end
643
2208
 
644
2209
  end
645
2210
 
646
- class ActivityRecognitionTrigger < Trigger
647
-
648
- def initialize(h={})
649
- super({}.merge h)
2211
+ class FileAction < Action
2212
+
2213
+ def initialize(h={})
2214
+ super(h)
2215
+ @group = 'file'
650
2216
  end
651
-
2217
+
652
2218
  end
653
2219
 
654
- class ProximityTrigger < Trigger
2220
+ # Category: Files
2221
+ #
2222
+ class OpenFileAction < FileAction
655
2223
 
656
- def initialize(h={})
657
- super({}.merge h)
658
- end
2224
+ def initialize(h={})
659
2225
 
660
- end
2226
+ options = {
2227
+ app_name: '',
2228
+ class_name: '',
2229
+ package_name: '',
2230
+ file_path: ''
2231
+ }
661
2232
 
662
- class ShakeDeviceTrigger < Trigger
2233
+ super(options.merge h)
663
2234
 
664
- def initialize(h={})
665
- super({}.merge h)
666
2235
  end
667
2236
 
668
2237
  end
669
2238
 
670
- class FlipDeviceTrigger < Trigger
671
2239
 
672
- def initialize(h={})
673
- super({}.merge h)
2240
+ class LocationAction < Action
2241
+
2242
+ def initialize(h={})
2243
+ super(h)
2244
+ @group = 'location'
674
2245
  end
675
-
2246
+
676
2247
  end
677
2248
 
678
- class OrientationTrigger < Trigger
2249
+ # Category: Location
2250
+ #
2251
+ class ForceLocationUpdateAction < LocationAction
679
2252
 
680
- def initialize(h={})
681
- super({}.merge h)
682
- end
2253
+ def initialize(h={})
683
2254
 
684
- end
2255
+ options = {
2256
+ }
685
2257
 
686
- class FloatingButtonTrigger < Trigger
2258
+ super(options.merge h)
687
2259
 
688
- def initialize(h={})
689
- super({}.merge h)
690
2260
  end
691
2261
 
692
2262
  end
693
2263
 
694
- class ShortcutTrigger < Trigger
2264
+ # Category: Location
2265
+ #
2266
+ class ShareLocationAction < LocationAction
695
2267
 
696
- def initialize(h={})
697
- super({}.merge h)
698
- end
2268
+ def initialize(h={})
699
2269
 
700
- end
2270
+ options = {
2271
+ email: '',
2272
+ variable: {:m_stringValue=>"", :m_name=>"", :m_decimalValue=>0.0, :isLocal=>true, :m_booleanValue=>false, :excludeFromLog=>false, :m_intValue=>0, :m_type=>2},
2273
+ sim_id: 0,
2274
+ output_channel: 5,
2275
+ old_variable_format: true
2276
+ }
701
2277
 
702
- class VolumeButtonTrigger < Trigger
2278
+ super(options.merge h)
703
2279
 
704
- def initialize(h={})
705
- super({}.merge h)
706
2280
  end
707
2281
 
708
2282
  end
709
2283
 
710
- class MediaButtonPressedTrigger < Trigger
2284
+ # Category: Location
2285
+ #
2286
+ class SetLocationUpdateRateAction < LocationAction
711
2287
 
712
- def initialize(h={})
713
- super({}.merge h)
714
- end
2288
+ def initialize(h={})
715
2289
 
716
- end
2290
+ options = {
2291
+ update_rate: 0,
2292
+ update_rate_seconds: 600
2293
+ }
717
2294
 
718
- class SwipeTrigger < Trigger
2295
+ super(options.merge h)
719
2296
 
720
- def initialize(h={})
721
- super({}.merge h)
722
2297
  end
723
2298
 
724
2299
  end
725
2300
 
726
-
727
- class Action < MacroObject
728
-
729
- def initialize(h={})
2301
+ class LoggingAction < Action
2302
+
2303
+ def initialize(h={})
730
2304
  super(h)
2305
+ @group = 'logging'
731
2306
  end
732
-
2307
+
733
2308
  end
734
2309
 
2310
+ # Category: Logging
2311
+ #
2312
+ class AddCalendarEntryAction < LoggingAction
2313
+
2314
+ def initialize(h={})
735
2315
 
2316
+ options = {
2317
+ title: '',
2318
+ duration_value: '0',
2319
+ calendar_id: '3',
2320
+ detail: '',
2321
+ availability: 0,
2322
+ fixed_days: 16,
2323
+ fixed_hour: 0,
2324
+ fixed_minute: 0,
2325
+ fixed_months: 8,
2326
+ fixed_time: true,
2327
+ relative_days: 0,
2328
+ relative_hours: 0,
2329
+ relative_minutes: 0,
2330
+ all_day_event: true
2331
+ }
736
2332
 
737
- class ShareLocationAction < Action
2333
+ super(options.merge h)
738
2334
 
739
- def initialize(h={})
740
- super({sim_id: 0, output_channel: 5, old_variable_format: true}.merge(h))
741
2335
  end
742
2336
 
743
2337
  end
744
2338
 
745
- class UDPCommandAction < Action
2339
+ # Category: Logging
2340
+ #
2341
+ class LogAction < LoggingAction
2342
+
2343
+ def initialize(h={})
2344
+
2345
+ options = {
2346
+ log_text: '',
2347
+ log_date_and_time: true
2348
+ }
2349
+
2350
+ super(options.merge h)
746
2351
 
747
- def initialize(h={})
748
- super({destination: '', message: '', port: 0}.merge h)
749
2352
  end
750
2353
 
751
2354
  end
752
2355
 
753
- class LaunchActivityAction < Action
2356
+ # Category: Logging
2357
+ #
2358
+ class ClearLogAction < LoggingAction
2359
+
2360
+ def initialize(h={})
2361
+
2362
+ options = {
2363
+ user_log: true
2364
+ }
2365
+
2366
+ super(options.merge h)
754
2367
 
755
- def initialize(h={})
756
- super({}.merge h)
757
2368
  end
758
2369
 
759
2370
  end
760
2371
 
761
- class KillBackgroundAppAction < Action
2372
+ class MediaAction < Action
2373
+
2374
+ def initialize(h={})
2375
+ super(h)
2376
+ @group = 'media'
2377
+ end
2378
+
2379
+ end
2380
+
2381
+ # Category: Media
2382
+ #
2383
+ class RecordMicrophoneAction < MediaAction
2384
+
2385
+ def initialize(h={})
2386
+
2387
+ options = {
2388
+ path: '/storage/emulated/0/MacroDroid/Recordings',
2389
+ record_time_string: 'Cancel Recording',
2390
+ recording_format: 0,
2391
+ seconds_to_record_for: -2
2392
+ }
2393
+
2394
+ super(options.merge h)
762
2395
 
763
- def initialize(h={})
764
- super({}.merge h)
765
2396
  end
766
2397
 
767
2398
  end
768
2399
 
769
- class OpenWebPageAction < Action
2400
+ # Category: Media
2401
+ #
2402
+ class PlaySoundAction < MediaAction
2403
+
2404
+ def initialize(h={})
2405
+
2406
+ options = {
2407
+ selected_index: 0,
2408
+ file_path: ''
2409
+ }
2410
+
2411
+ super(options.merge h)
770
2412
 
771
- def initialize(h={})
772
- super({}.merge h)
773
2413
  end
774
2414
 
775
2415
  end
776
2416
 
777
- class UploadPhotoAction < Action
778
2417
 
779
- def initialize(h={})
780
- super({}.merge h)
2418
+ class MessagingAction < Action
2419
+
2420
+ def initialize(h={})
2421
+ super(h)
2422
+ @group = 'messaging'
781
2423
  end
782
-
2424
+
783
2425
  end
784
2426
 
785
- class TakePictureAction < Action
2427
+ # Category: Messaging
2428
+ #
2429
+ class SendEmailAction < MessagingAction
2430
+
2431
+ def initialize(h={})
2432
+
2433
+ options = {
2434
+ subject: '',
2435
+ body: '',
2436
+ email_address: '',
2437
+ from_email_address: '',
2438
+ attach_user_log: false,
2439
+ attach_log: false,
2440
+ send_option: 0
2441
+ }
2442
+
2443
+ super(options.merge h)
786
2444
 
787
- def initialize(h={})
788
- super({}.merge h)
789
2445
  end
790
2446
 
791
- end
2447
+ end
2448
+
2449
+ # Category: Messaging
2450
+ #
2451
+ class SendSMSAction < MessagingAction
2452
+
2453
+ def initialize(h={})
2454
+
2455
+ options = {
2456
+ number: '',
2457
+ contact: {:m_id=>"Hardwired_Number", :m_lookupKey=>"Hardwired_Number", :m_name=>"[Select Number]"},
2458
+ message_content: '',
2459
+ add_to_message_log: false,
2460
+ pre_populate: false,
2461
+ sim_id: 0
2462
+ }
792
2463
 
793
- class SetWifiAction < Action
2464
+ super(options.merge h)
794
2465
 
795
- def initialize(h={})
796
- super({}.merge h)
797
2466
  end
798
2467
 
799
2468
  end
800
2469
 
801
- class SetBluetoothAction < Action
2470
+ # Category: Messaging
2471
+ #
2472
+ class UDPCommandAction < MessagingAction
802
2473
 
803
- def initialize(h={})
804
- super({}.merge h)
805
- end
2474
+ def initialize(h={})
806
2475
 
807
- end
2476
+ options = {
2477
+ destination: '',
2478
+ message: '',
2479
+ port: 1024
2480
+ }
808
2481
 
809
- class SendIntentAction < Action
2482
+ super(options.merge h)
810
2483
 
811
- def initialize(h={})
812
- super({}.merge h)
813
2484
  end
814
2485
 
815
2486
  end
816
2487
 
817
- class SetAlarmClockAction < Action
818
2488
 
819
- def initialize(h={})
820
- super({}.merge h)
2489
+ class NotificationsAction < Action
2490
+
2491
+ def initialize(h={})
2492
+ super(h)
2493
+ @group = 'notifications'
821
2494
  end
822
-
2495
+
823
2496
  end
824
2497
 
825
- class StopWatchAction < Action
2498
+ # Category: Notifications
2499
+ #
2500
+ class ClearNotificationsAction < NotificationsAction
826
2501
 
827
- def initialize(h={})
828
- super({}.merge h)
829
- end
2502
+ def initialize(h={})
830
2503
 
831
- end
2504
+ options = {
2505
+ package_name_list: [],
2506
+ match_text: '',
2507
+ application_name_list: [],
2508
+ clear_persistent: false,
2509
+ excludes: false,
2510
+ match_option: 0,
2511
+ age_in_seconds: 0,
2512
+ option: 0,
2513
+ enable_regex: false
2514
+ }
832
2515
 
833
- class SayTimeAction < Action
2516
+ super(options.merge h)
834
2517
 
835
- def initialize(h={})
836
- super({}.merge h)
837
2518
  end
838
2519
 
839
2520
  end
840
2521
 
841
- class AndroidShortcutsAction < Action
2522
+ # Category: Notifications
2523
+ #
2524
+ class MessageDialogAction < NotificationsAction
842
2525
 
843
- def initialize(h={})
844
- super({}.merge h)
845
- end
2526
+ def initialize(h={})
846
2527
 
847
- end
2528
+ options = {
2529
+ secondary_class_type: 'MessageDialogAction',
2530
+ ringtone_name: 'Default',
2531
+ notification_text: '',
2532
+ notification_subject: '',
2533
+ macro_guid_to_run: -0,
2534
+ notification_channel_type: 0,
2535
+ image_resource_id: 0,
2536
+ overwrite_existing: false,
2537
+ priority: 0,
2538
+ ringtone_index: 0,
2539
+ icon_bg_color: -1762269,
2540
+ run_macro_when_pressed: false
2541
+ }
848
2542
 
849
- class ClipboardAction < Action
2543
+ super(options.merge h)
850
2544
 
851
- def initialize(h={})
852
- super({}.merge h)
853
2545
  end
854
2546
 
855
2547
  end
856
2548
 
857
- class PressBackAction < Action
2549
+ # Category: Notifications
2550
+ #
2551
+ class AllowLEDNotificationLightAction < NotificationsAction
858
2552
 
859
- def initialize(h={})
860
- super({}.merge h)
861
- end
2553
+ def initialize(h={})
862
2554
 
863
- end
2555
+ options = {
2556
+ enabled: true
2557
+ }
864
2558
 
865
- class SpeakTextAction < Action
2559
+ super(options.merge h)
866
2560
 
867
- def initialize(h={})
868
- super({}.merge h)
869
2561
  end
870
2562
 
871
2563
  end
872
2564
 
873
- class UIInteractionAction < Action
2565
+ # Category: Notifications
2566
+ #
2567
+ class SetNotificationSoundAction < NotificationsAction
874
2568
 
875
- def initialize(h={})
876
- super({}.merge h)
877
- end
2569
+ def initialize(h={})
878
2570
 
879
- end
2571
+ options = {
2572
+ ringtone_uri: 'content://media/internal/audio/media/27'
2573
+ }
880
2574
 
881
- class VoiceSearchAction < Action
2575
+ super(options.merge h)
882
2576
 
883
- def initialize(h={})
884
- super({}.merge h)
885
2577
  end
886
2578
 
887
2579
  end
888
2580
 
889
- class ExpandCollapseStatusBarAction < Action
2581
+ # Category: Notifications
2582
+ #
2583
+ class SetNotificationSoundAction < NotificationsAction
890
2584
 
891
- def initialize(h={})
892
- super({}.merge h)
893
- end
2585
+ def initialize(h={})
894
2586
 
895
- end
2587
+ options = {
2588
+ ringtone_uri: 'content://media/internal/audio/media/51'
2589
+ }
896
2590
 
897
- class LaunchHomeScreenAction < Action
2591
+ super(options.merge h)
898
2592
 
899
- def initialize(h={})
900
- super({}.merge h)
901
2593
  end
902
2594
 
903
2595
  end
904
2596
 
905
- class CameraFlashLightAction < Action
2597
+ # Category: Notifications
2598
+ #
2599
+ class SetNotificationSoundAction < NotificationsAction
906
2600
 
907
- def initialize(h={})
908
- super({}.merge h)
909
- end
2601
+ def initialize(h={})
910
2602
 
911
- end
2603
+ options = {
2604
+ ringtone_name: 'None'
2605
+ }
912
2606
 
913
- class VibrateAction < Action
2607
+ super(options.merge h)
914
2608
 
915
- def initialize(h={})
916
- super({}.merge h)
917
2609
  end
918
2610
 
919
2611
  end
920
2612
 
921
- class SetAutoRotateAction < Action
2613
+ # Category: Notifications
2614
+ #
2615
+ class NotificationAction < NotificationsAction
922
2616
 
923
- def initialize(h={})
924
- super({}.merge h)
925
- end
2617
+ def initialize(h={})
926
2618
 
927
- end
2619
+ options = {
2620
+ ringtone_name: 'Default',
2621
+ notification_text: '',
2622
+ notification_subject: '',
2623
+ macro_guid_to_run: 0,
2624
+ notification_channel_type: 0,
2625
+ image_resource_id: 0,
2626
+ overwrite_existing: false,
2627
+ priority: 0,
2628
+ ringtone_index: 0,
2629
+ icon_bg_color: -1762269,
2630
+ run_macro_when_pressed: false
2631
+ }
928
2632
 
929
- class DayDreamAction < Action
2633
+ super(options.merge h)
930
2634
 
931
- def initialize(h={})
932
- super({}.merge h)
933
2635
  end
934
2636
 
935
2637
  end
936
2638
 
937
- class SetKeyboardAction < Action
2639
+ # Category: Notifications
2640
+ #
2641
+ class ToastAction < NotificationsAction
938
2642
 
939
- def initialize(h={})
940
- super({}.merge h)
941
- end
2643
+ def initialize(h={})
942
2644
 
943
- end
2645
+ if h[:msg] then
2646
+ h[:message_text] = h[:msg]
2647
+ h.delete :msg
2648
+ end
2649
+
2650
+ options = {
2651
+ message_text: '',
2652
+ image_resource_name: 'launcher_no_border',
2653
+ image_package_name: 'com.arlosoft.macrodroid',
2654
+ image_name: 'launcher_no_border',
2655
+ duration: 0,
2656
+ display_icon: true,
2657
+ background_color: -12434878,
2658
+ position: 0
2659
+ }
944
2660
 
945
- class SetKeyguardAction < Action
2661
+ super(options.merge h)
946
2662
 
947
- def initialize(h={})
948
- super({}.merge h)
2663
+ end
2664
+
2665
+ def invoke()
2666
+ super(@h[:message_text])
949
2667
  end
950
2668
 
951
2669
  end
952
2670
 
953
- class CarModeAction < Action
954
2671
 
955
- def initialize(h={})
956
- super({}.merge h)
2672
+ class PhoneAction < Action
2673
+
2674
+ def initialize(h={})
2675
+ super(h)
2676
+ @group = 'phone'
957
2677
  end
958
-
2678
+
959
2679
  end
960
2680
 
961
- class ChangeKeyboardAction < Action
2681
+ # Category: Phone
2682
+ #
2683
+ class AnswerCallAction < PhoneAction
962
2684
 
963
- def initialize(h={})
964
- super({}.merge h)
965
- end
2685
+ def initialize(h={})
966
2686
 
967
- end
2687
+ options = {
2688
+ selected_index: 0
2689
+ }
968
2690
 
969
- class SetWallpaperAction < Action
2691
+ super(options.merge h)
970
2692
 
971
- def initialize(h={})
972
- super({}.merge h)
973
2693
  end
974
2694
 
975
2695
  end
976
2696
 
977
- class OpenFileAction < Action
2697
+ # Category: Phone
2698
+ #
2699
+ class ClearCallLogAction < PhoneAction
978
2700
 
979
- def initialize(h={})
980
- super({}.merge h)
981
- end
2701
+ def initialize(h={})
982
2702
 
983
- end
2703
+ options = {
2704
+ non_contact: false,
2705
+ specific_contact: false,
2706
+ type: 0
2707
+ }
984
2708
 
985
- class ForceLocationUpdateAction < Action
2709
+ super(options.merge h)
986
2710
 
987
- def initialize(h={})
988
- super({}.merge h)
989
2711
  end
990
2712
 
991
2713
  end
992
2714
 
993
- class SetLocationUpdateRateAction < Action
2715
+ # Category: Phone
2716
+ #
2717
+ class OpenCallLogAction < PhoneAction
994
2718
 
995
- def initialize(h={})
996
- super({}.merge h)
997
- end
2719
+ def initialize(h={})
998
2720
 
999
- end
2721
+ options = {
2722
+ }
1000
2723
 
1001
- class AddCalendarEntryAction < Action
2724
+ super(options.merge h)
1002
2725
 
1003
- def initialize(h={})
1004
- super({}.merge h)
1005
2726
  end
1006
2727
 
1007
2728
  end
1008
2729
 
1009
- class LogAction < Action
2730
+ # Category: Phone
2731
+ #
2732
+ class RejectCallAction < PhoneAction
1010
2733
 
1011
- def initialize(h={})
1012
- super({}.merge h)
1013
- end
2734
+ def initialize(h={})
1014
2735
 
1015
- end
2736
+ options = {
2737
+ }
1016
2738
 
1017
- class ClearLogAction < Action
2739
+ super(options.merge h)
1018
2740
 
1019
- def initialize(h={})
1020
- super({}.merge h)
1021
2741
  end
1022
2742
 
1023
2743
  end
1024
2744
 
1025
- class RecordMicrophoneAction < Action
2745
+ # Category: Phone
2746
+ #
2747
+ class MakeCallAction < PhoneAction
1026
2748
 
1027
- def initialize(h={})
1028
- super({}.merge h)
1029
- end
2749
+ def initialize(h={})
1030
2750
 
1031
- end
2751
+ options = {
2752
+ contact: {:m_id=>"Hardwired_Number", :m_lookupKey=>"Hardwired_Number", :m_name=>"[Select Number]"},
2753
+ number: ''
2754
+ }
1032
2755
 
1033
- class PlaySoundAction < Action
2756
+ super(options.merge h)
1034
2757
 
1035
- def initialize(h={})
1036
- super({}.merge h)
1037
2758
  end
1038
2759
 
1039
2760
  end
1040
2761
 
1041
- class SendEmailAction < Action
1042
2762
 
1043
- def initialize(h={})
1044
- super({}.merge h)
1045
- end
2763
+ # Category: Phone
2764
+ #
2765
+ class SetRingtoneAction < PhoneAction
1046
2766
 
1047
- end
2767
+ def initialize(h={})
1048
2768
 
1049
- class SendSMSAction < Action
2769
+ options = {
2770
+ ringtone_uri: 'content://media/internal/audio/media/174'
2771
+ }
2772
+
2773
+ super(options.merge h)
1050
2774
 
1051
- def initialize(h={})
1052
- super({}.merge h)
1053
2775
  end
1054
2776
 
1055
2777
  end
1056
2778
 
1057
- class ClearNotificationsAction < Action
1058
-
1059
- def initialize(h={})
1060
- super({}.merge h)
2779
+ class ScreenAction < Action
2780
+
2781
+ def initialize(h={})
2782
+ super(h)
2783
+ @group = 'screen'
1061
2784
  end
1062
-
2785
+
1063
2786
  end
1064
2787
 
1065
- class MessageDialogAction < Action
2788
+ # Category: Screen
2789
+ #
2790
+ class SetBrightnessAction < ScreenAction
1066
2791
 
1067
- def initialize(h={})
1068
- super({}.merge h)
1069
- end
2792
+ def initialize(h={})
1070
2793
 
1071
- end
2794
+ options = {
2795
+ brightness_percent: 81,
2796
+ force_pie_mode: false,
2797
+ brightness: 0
2798
+ }
1072
2799
 
1073
- class AllowLEDNotificationLightAction < Action
2800
+ super(options.merge h)
1074
2801
 
1075
- def initialize(h={})
1076
- super({}.merge h)
1077
2802
  end
1078
2803
 
1079
2804
  end
1080
2805
 
1081
- class SetNotificationSoundAction < Action
2806
+ # Category: Screen
2807
+ #
2808
+ class ForceScreenRotationAction < ScreenAction
1082
2809
 
1083
- def initialize(h={})
1084
- super({}.merge h)
1085
- end
2810
+ def initialize(h={})
1086
2811
 
1087
- end
2812
+ options = {
2813
+ option: 0
2814
+ }
1088
2815
 
1089
- class NotificationAction < Action
2816
+ super(options.merge h)
1090
2817
 
1091
- def initialize(h={})
1092
- super({}.merge h)
1093
2818
  end
1094
2819
 
1095
2820
  end
1096
2821
 
1097
- class ToastAction < Action
2822
+ # Category: Screen
2823
+ #
2824
+ class ScreenOnAction < ScreenAction
2825
+
2826
+ def initialize(h={})
1098
2827
 
1099
- def initialize(h={})
1100
-
1101
2828
  options = {
1102
- message_text: 'Popup message for you!',
1103
- image_resource_name: 'launcher_no_border',
1104
- image_package_name: 'com.arlosoft.macrodroid',
1105
- image_name: 'launcher_no_border',
1106
- duration: 0,
1107
- display_icon: true,
1108
- background_color: -12434878,
1109
- position: 0,
2829
+ pie_lock_screen: false,
2830
+ screen_off: true,
2831
+ screen_off_no_lock: false,
2832
+ screen_on_alternative: false
1110
2833
  }
1111
-
2834
+
1112
2835
  super(options.merge h)
2836
+
1113
2837
  end
1114
2838
 
1115
2839
  end
1116
2840
 
1117
- class AnswerCallAction < Action
2841
+ # Category: Screen
2842
+ #
2843
+ class DimScreenAction < ScreenAction
1118
2844
 
1119
- def initialize(h={})
1120
- super({}.merge h)
1121
- end
2845
+ def initialize(h={})
1122
2846
 
1123
- end
2847
+ options = {
2848
+ percent: 50,
2849
+ dim_screen_on: true
2850
+ }
1124
2851
 
1125
- class ClearCallLogAction < Action
2852
+ super(options.merge h)
1126
2853
 
1127
- def initialize(h={})
1128
- super({}.merge h)
1129
2854
  end
1130
2855
 
1131
2856
  end
1132
2857
 
1133
- class OpenCallLogAction < Action
2858
+ # Category: Screen
2859
+ #
2860
+ class KeepAwakeAction < ScreenAction
1134
2861
 
1135
- def initialize(h={})
1136
- super({}.merge h)
1137
- end
2862
+ def initialize(h={})
1138
2863
 
1139
- end
2864
+ options = {
2865
+ enabled: true,
2866
+ permanent: true,
2867
+ screen_option: 0,
2868
+ seconds_to_stay_awake_for: 0
2869
+ }
1140
2870
 
1141
- class RejectCallAction < Action
2871
+ super(options.merge h)
1142
2872
 
1143
- def initialize(h={})
1144
- super({}.merge h)
1145
2873
  end
1146
2874
 
1147
2875
  end
1148
2876
 
1149
- class MakeCallAction < Action
2877
+ # Category: Screen
2878
+ #
2879
+ class SetScreenTimeoutAction < ScreenAction
1150
2880
 
1151
- def initialize(h={})
1152
- super({}.merge h)
1153
- end
2881
+ def initialize(h={})
1154
2882
 
1155
- end
2883
+ options = {
2884
+ timeout_delay_string: '1 Minute',
2885
+ timeout_delay: 60,
2886
+ custom_value_delay: 0
2887
+ }
1156
2888
 
1157
- class SetRingtoneAction < Action
2889
+ super(options.merge h)
1158
2890
 
1159
- def initialize(h={})
1160
- super({}.merge h)
1161
2891
  end
1162
2892
 
1163
2893
  end
1164
2894
 
1165
- class SetBrightnessAction < Action
1166
2895
 
1167
- def initialize(h={})
1168
- super({}.merge h)
2896
+ class VolumeAction < Action
2897
+
2898
+ def initialize(h={})
2899
+ super(h)
2900
+ @group = 'volume'
1169
2901
  end
1170
-
2902
+
1171
2903
  end
1172
2904
 
1173
- class ForceScreenRotationAction < Action
2905
+ # Category: Volume
2906
+ #
2907
+ class SilentModeVibrateOffAction < VolumeAction
1174
2908
 
1175
- def initialize(h={})
1176
- super({}.merge h)
1177
- end
2909
+ def initialize(h={})
1178
2910
 
1179
- end
2911
+ options = {
2912
+ option: 1
2913
+ }
1180
2914
 
1181
- class ScreenOnAction < Action
2915
+ super(options.merge h)
1182
2916
 
1183
- def initialize(h={})
1184
- super({}.merge h)
1185
2917
  end
1186
2918
 
1187
2919
  end
1188
2920
 
1189
- class DimScreenAction < Action
2921
+ # Category: Volume
2922
+ #
2923
+ class SetVibrateAction < VolumeAction
1190
2924
 
1191
- def initialize(h={})
1192
- super({}.merge h)
1193
- end
2925
+ def initialize(h={})
1194
2926
 
1195
- end
2927
+ options = {
2928
+ option: 'Silent (Vibrate On)',
2929
+ option_int: -1
2930
+ }
1196
2931
 
1197
- class KeepAwakeAction < Action
2932
+ super(options.merge h)
1198
2933
 
1199
- def initialize(h={})
1200
- super({}.merge h)
1201
2934
  end
1202
2935
 
1203
2936
  end
1204
2937
 
1205
- class SetScreenTimeoutAction < Action
2938
+ # Category: Volume
2939
+ #
2940
+ class VolumeIncrementDecrementAction < VolumeAction
1206
2941
 
1207
- def initialize(h={})
1208
- super({}.merge h)
1209
- end
2942
+ def initialize(h={})
1210
2943
 
1211
- end
2944
+ options = {
2945
+ volume_up: true
2946
+ }
1212
2947
 
1213
- class SilentModeVibrateOffAction < Action
2948
+ super(options.merge h)
1214
2949
 
1215
- def initialize(h={})
1216
- super({}.merge h)
1217
2950
  end
1218
2951
 
1219
2952
  end
1220
2953
 
1221
- class SetVibrateAction < Action
2954
+ # Category: Volume
2955
+ #
2956
+ class SpeakerPhoneAction < VolumeAction
1222
2957
 
1223
- def initialize(h={})
1224
- super({}.merge h)
1225
- end
2958
+ def initialize(h={})
1226
2959
 
1227
- end
2960
+ options = {
2961
+ secondary_class_type: 'SpeakerPhoneAction',
2962
+ state: 0
2963
+ }
1228
2964
 
1229
- class VolumeIncrementDecrementAction < Action
2965
+ super(options.merge h)
1230
2966
 
1231
- def initialize(h={})
1232
- super({}.merge h)
1233
2967
  end
1234
2968
 
1235
2969
  end
1236
2970
 
1237
- class SpeakerPhoneAction < Action
2971
+ # Category: Volume
2972
+ #
2973
+ class SetVolumeAction < VolumeAction
1238
2974
 
1239
- def initialize(h={})
1240
- super({}.merge h)
1241
- end
2975
+ def initialize(h={})
1242
2976
 
1243
- end
2977
+ options = {
2978
+ variables: [nil, nil, nil, nil, nil, nil, nil],
2979
+ stream_index_array: [false, false, false, false, false, false, true],
2980
+ stream_volume_array: [0, 0, 0, 0, 0, 0, 66],
2981
+ force_vibrate_off: false,
2982
+ volume: -1
2983
+ }
1244
2984
 
1245
- class SetVolumeAction < Action
2985
+ super(options.merge h)
1246
2986
 
1247
- def initialize(h={})
1248
- super({}.merge h)
1249
2987
  end
1250
2988
 
1251
2989
  end