ruby-macrodroid 0.7.9 → 0.8.3

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.
@@ -0,0 +1,2120 @@
1
+ # file: ruby-macrodroid/actions.rb
2
+
3
+ # This file contains the following classes:
4
+ #
5
+ #
6
+ # ## Action classes
7
+ #
8
+ # Action LocationAction ShareLocationAction ApplicationAction
9
+ # LaunchActivityAction KillBackgroundAppAction OpenWebPageAction CameraAction
10
+ # UploadPhotoAction TakePictureAction ConnectivityAction SetWifiAction
11
+ # SetBluetoothAction SetBluetoothAction SendIntentAction DateTimeAction
12
+ # SetAlarmClockAction StopWatchAction SayTimeAction DeviceAction
13
+ # AndroidShortcutsAction ClipboardAction PressBackAction SpeakTextAction
14
+ # UIInteractionAction VoiceSearchAction DeviceSettingsAction
15
+ # ExpandCollapseStatusBarAction LaunchHomeScreenAction CameraFlashLightAction
16
+ # VibrateAction SetAutoRotateAction DayDreamAction SetKeyboardAction
17
+ # SetKeyguardAction CarModeAction ChangeKeyboardAction SetWallpaperAction
18
+ # FileAction OpenFileAction LocationAction ForceLocationUpdateAction
19
+ # ShareLocationAction SetLocationUpdateRateAction LoggingAction
20
+ # AddCalendarEntryAction LogAction ClearLogAction MediaAction
21
+ # RecordMicrophoneAction PlaySoundAction MessagingAction SendEmailAction
22
+ # SendSMSAction UDPCommandAction NotificationsAction ClearNotificationsAction
23
+ # MessageDialogAction AllowLEDNotificationLightAction
24
+ # SetNotificationSoundAction SetNotificationSoundAction
25
+ # SetNotificationSoundAction NotificationAction ToastAction PhoneAction
26
+ # AnswerCallAction ClearCallLogAction OpenCallLogAction RejectCallAction
27
+ # MakeCallAction SetRingtoneAction ScreenAction SetBrightnessAction
28
+ # ForceScreenRotationAction ScreenOnAction DimScreenAction KeepAwakeAction
29
+ # SetScreenTimeoutAction VolumeAction SilentModeVibrateOffAction
30
+ # SetVibrateAction VolumeIncrementDecrementAction SpeakerPhoneAction
31
+ # SetVolumeAction
32
+ #
33
+
34
+
35
+ class Action < MacroObject
36
+ using Params
37
+
38
+ attr_reader :constraints
39
+
40
+ def initialize(h={})
41
+
42
+ macro = h[:macro]
43
+ h.delete :macro
44
+ super(h)
45
+
46
+ # fetch the constraints
47
+ @constraints = @h[:constraint_list].map do |constraint|
48
+ object(constraint.to_snake_case.merge(macro: macro))
49
+ end
50
+ end
51
+
52
+ def invoke(s='')
53
+ "%s/%s: %s" % [@group, @type, s]
54
+ end
55
+
56
+ def to_s(colour: false)
57
+
58
+ h = @h.clone
59
+ h.delete :macro
60
+ @s ||= "#<%s %s>" % [self.class, h.inspect]
61
+ operator = @h[:is_or_condition] ? 'OR' : 'AND'
62
+ constraints = @constraints.map \
63
+ {|x| x.to_summary(colour: colour)}.join(" %s " % operator)
64
+
65
+ @s + constraints
66
+
67
+ end
68
+
69
+ end
70
+
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
+
110
+
111
+ class ApplicationAction < Action
112
+
113
+ def initialize(h={})
114
+ super(h)
115
+ @group = 'application'
116
+ end
117
+
118
+ end
119
+
120
+ # Category: Applications
121
+ #
122
+ class LaunchActivityAction < ApplicationAction
123
+
124
+ def initialize(h={})
125
+
126
+ options = {
127
+ application_name: 'Chrome',
128
+ package_to_launch: 'com.android.chrome',
129
+ exclude_from_recents: false,
130
+ start_new: false
131
+ }
132
+
133
+ super(options.merge h)
134
+
135
+ end
136
+
137
+ def to_s(colour: false)
138
+ 'Launch ' + @h[:application_name]
139
+ end
140
+
141
+ end
142
+
143
+ # Category: Applications
144
+ #
145
+ class KillBackgroundAppAction < ApplicationAction
146
+
147
+ def initialize(h={})
148
+
149
+ options = {
150
+ application_name_list: [""],
151
+ package_name_list: [""]
152
+ }
153
+
154
+ super(options.merge h)
155
+
156
+ end
157
+
158
+ def to_s(colour: false)
159
+ 'KillBackgroundAppAction ' + @h.inspect
160
+ end
161
+
162
+ alias to_summary to_s
163
+ end
164
+
165
+ # Category: Applications
166
+ #
167
+ class LaunchShortcutAction < ApplicationAction
168
+
169
+ def initialize(h={})
170
+
171
+ options = {
172
+ :app_name=>"Amazon Alexa", :intent_encoded=>"", :name=>"Ask Alexa"
173
+ }
174
+
175
+ super(options.merge h)
176
+
177
+ end
178
+
179
+ def to_s(colour: false)
180
+ @s = "Launch Shortcut: " + @h[:app_name] + "\n " + @h[:name]
181
+ super()
182
+ end
183
+
184
+ alias to_summary to_s
185
+
186
+ end
187
+
188
+ # Category: Applications
189
+ #
190
+ class OpenWebPageAction < ApplicationAction
191
+
192
+ def initialize(h={})
193
+
194
+ h[:url_to_open] = h[:url] if h[:url]
195
+
196
+ options = {
197
+ 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},
198
+ url_to_open: '',
199
+ http_get: true,
200
+ disable_url_encode: false,
201
+ block_next_action: false
202
+ }
203
+
204
+ super(options.merge filter(options,h))
205
+
206
+ end
207
+
208
+ def to_s(colour: false)
209
+ "HTTP GET\n url: " + @h[:url_to_open]
210
+ end
211
+
212
+ end
213
+
214
+
215
+ class CameraAction < Action
216
+
217
+ def initialize(h={})
218
+ super(h)
219
+ @group = 'camera'
220
+ end
221
+
222
+ end
223
+
224
+ # Category: Camera/Photo
225
+ #
226
+ class UploadPhotoAction < CameraAction
227
+
228
+ def initialize(h={})
229
+
230
+ options = {
231
+ option: 'Via Intent',
232
+ use_smtp_email: false
233
+ }
234
+
235
+ super(options.merge h)
236
+
237
+ end
238
+
239
+ def to_s(colour: false)
240
+ 'UploadPhotoAction ' + @h.inspect
241
+ end
242
+
243
+ alias to_summary to_s
244
+ end
245
+
246
+ # Category: Camera/Photo
247
+ #
248
+ class TakePictureAction < CameraAction
249
+
250
+ def initialize(h={})
251
+
252
+ options = {
253
+ new_path: '/storage/sdcard1/DCIM/Camera',
254
+ path: '/storage/sdcard1/DCIM/Camera',
255
+ show_icon: true,
256
+ use_front_camera: true,
257
+ flash_option: 0
258
+ }
259
+
260
+ super(options.merge h)
261
+
262
+ end
263
+
264
+ def to_pc()
265
+ camera = @h[:use_front_camera] ? :front : :back
266
+ 'take_photo :' + camera.to_s
267
+ end
268
+
269
+ def to_s(colour: false)
270
+ 'Take Picture'
271
+ end
272
+
273
+ end
274
+
275
+
276
+ # Conditions/Loops
277
+ #
278
+ class LoopAction < Action
279
+
280
+ def initialize(h={})
281
+
282
+ options = {
283
+
284
+ }
285
+
286
+ h2 = options.merge(h)
287
+
288
+ super(h2)
289
+
290
+ @label = 'WHILE / DO '
291
+
292
+ end
293
+
294
+ def to_s(colour: false)
295
+
296
+ @s = 'WHILE / DO '
297
+ super()
298
+
299
+ end
300
+ end
301
+
302
+ # Conditions/Loops
303
+ #
304
+ class EndLoopAction < Action
305
+
306
+ def initialize(h={})
307
+
308
+ options = {
309
+
310
+ }
311
+
312
+ h2 = options.merge(h)
313
+
314
+ super(h2)
315
+
316
+ @label = 'End Loop '
317
+
318
+ end
319
+
320
+ def to_s(colour: false)
321
+
322
+ 'End Loop '
323
+
324
+ end
325
+ end
326
+
327
+ # Conditions/Loops
328
+ #
329
+ class IfConditionAction < Action
330
+
331
+ def initialize(h={})
332
+
333
+ options = {
334
+ a: true,
335
+ constraint_list: ''
336
+ }
337
+
338
+ macro = h[:macro]
339
+ h2 = options.merge(filter(options,h).merge(macro: macro))
340
+
341
+ super(h2)
342
+
343
+ @label = 'If '
344
+
345
+ end
346
+
347
+ def to_s(colour: false)
348
+
349
+ @s = "If " #+ @constraints.map(&:to_s).join(" %s " % operator)
350
+ super(colour: colour)
351
+
352
+ end
353
+ end
354
+
355
+ class ElseAction < Action
356
+
357
+ def initialize(h={})
358
+
359
+ options = {
360
+ constraint_list: ''
361
+ }
362
+
363
+ super(options.merge h)
364
+
365
+
366
+ end
367
+
368
+ def to_s(colour: false)
369
+ 'Else'
370
+ end
371
+
372
+ end
373
+
374
+ class ElseIfConditionAction < Action
375
+
376
+ def initialize(h={})
377
+
378
+ options = {
379
+ constraint_list: ''
380
+ }
381
+
382
+ super(options.merge h)
383
+ @label = 'Else If '
384
+
385
+ end
386
+
387
+ def to_s(colour: false)
388
+ @s = 'Else If '
389
+ super()
390
+ end
391
+
392
+
393
+ end
394
+
395
+
396
+ class EndIfAction < Action
397
+
398
+ def initialize(h={})
399
+
400
+ options = {
401
+ constraint_list: ''
402
+ }
403
+
404
+ super(options.merge h)
405
+
406
+ end
407
+
408
+ def to_s(colour: false)
409
+ 'End If'
410
+ end
411
+
412
+ end
413
+
414
+ class ConnectivityAction < Action
415
+
416
+ def initialize(h={})
417
+ super(h)
418
+ @group = 'connectivity'
419
+ end
420
+
421
+ end
422
+
423
+ # Category: Connectivity
424
+ #
425
+ class SetAirplaneModeAction < ConnectivityAction
426
+
427
+ def initialize(h={})
428
+
429
+ options = {
430
+ device_name: '',
431
+ state: 1
432
+ }
433
+
434
+ super(options.merge h)
435
+
436
+ end
437
+
438
+ def to_s(colour: false)
439
+
440
+ state = ['On', 'Off', 'Toggle'][@h[:state]]
441
+ @s = 'Airplane Mode ' + state + "\n"
442
+ super(colour: colour)
443
+
444
+ end
445
+
446
+ end
447
+
448
+ # Category: Connectivity
449
+ #
450
+ class SetWifiAction < ConnectivityAction
451
+
452
+ def initialize(h={})
453
+
454
+ options = {
455
+ ssid: '[Select Wifi]',
456
+ network_id: 0,
457
+ state: 0
458
+ }
459
+
460
+ super(options.merge h)
461
+
462
+ end
463
+
464
+ def to_s(colour: false)
465
+ action = @h[:state] == 0 ? 'Enable' : 'Disable'
466
+ action + ' Wifi'
467
+ end
468
+
469
+ end
470
+
471
+ # Category: Connectivity
472
+ #
473
+ class SetBluetoothAction < ConnectivityAction
474
+
475
+ def initialize(h={})
476
+
477
+ options = {
478
+ device_name: '',
479
+ state: 0
480
+ }
481
+
482
+ super(options.merge h)
483
+
484
+ end
485
+
486
+ def to_s(colour: false)
487
+ 'SetBluetoothAction ' + @h.inspect
488
+ end
489
+
490
+ alias to_summary to_s
491
+ end
492
+
493
+ # Category: Connectivity
494
+ #
495
+ class SetBluetoothAction < ConnectivityAction
496
+
497
+ def initialize(h={})
498
+
499
+ options = {
500
+ device_name: '',
501
+ state: 1
502
+ }
503
+
504
+ super(options.merge h)
505
+
506
+ end
507
+
508
+ def to_s(colour: false)
509
+ 'SetBluetoothAction ' + @h.inspect
510
+ end
511
+
512
+ alias to_summary to_s
513
+ end
514
+
515
+ class SetHotspotAction < ConnectivityAction
516
+
517
+ def initialize(h={})
518
+
519
+ options = {
520
+ device_name: "", state: 0, turn_wifi_on: true, use_legacy_mechanism: false, mechanism: 0
521
+
522
+ }
523
+
524
+ super(options.merge h)
525
+
526
+ end
527
+
528
+ def to_s(colour: false)
529
+ action = @h[:turn_wifi_on] ? 'Enable' : 'Disable'
530
+ action + ' HotSpot'
531
+ end
532
+ end
533
+
534
+ # Category: Connectivity
535
+ #
536
+ class SendIntentAction < ConnectivityAction
537
+
538
+ def initialize(h={})
539
+
540
+ options = {
541
+ action: '',
542
+ class_name: '',
543
+ data: '',
544
+ extra1_name: '',
545
+ extra1_value: '',
546
+ extra2_name: '',
547
+ extra2_value: '',
548
+ extra3_name: '',
549
+ extra3_value: '',
550
+ extra4_name: '',
551
+ extra4_value: '',
552
+ package_name: '',
553
+ target: 'Activity'
554
+ }
555
+
556
+ super(options.merge h)
557
+
558
+ end
559
+
560
+ def to_s(colour: false)
561
+ 'Send Intent ' + "\n " + @h[:action]
562
+ end
563
+
564
+ alias to_summary to_s
565
+ end
566
+
567
+
568
+ class DateTimeAction < Action
569
+
570
+ def initialize(h={})
571
+ super(h)
572
+ @group = 'datetime'
573
+ end
574
+
575
+ end
576
+
577
+ # Category: Date/Time
578
+ #
579
+ class SetAlarmClockAction < DateTimeAction
580
+
581
+ def initialize(h={})
582
+
583
+ options = {
584
+ days_of_week: [false, false, false, false, false, false, false],
585
+ label: 'wakeup mum',
586
+ delay_in_minutes: 1,
587
+ hour: 8,
588
+ delay_in_hours: 0,
589
+ minute: 15,
590
+ one_off: true,
591
+ option: 0,
592
+ relative: true,
593
+ day_option: 0
594
+ }
595
+
596
+ super(options.merge h)
597
+
598
+ end
599
+
600
+ def to_s(colour: false)
601
+ 'SetAlarmClockAction ' + @h.inspect
602
+ end
603
+
604
+ alias to_summary to_s
605
+ end
606
+
607
+ # Category: Date/Time
608
+ #
609
+ class StopWatchAction < DateTimeAction
610
+
611
+ def initialize(h={})
612
+
613
+ options = {
614
+ stopwatch_name: 'timer1',
615
+ option: 0
616
+ }
617
+
618
+ super(options.merge h)
619
+
620
+ end
621
+
622
+ def to_s(colour: false)
623
+ 'StopWatchAction ' + @h.inspect
624
+ end
625
+
626
+ alias to_summary to_s
627
+ end
628
+
629
+ # Category: Date/Time
630
+ #
631
+ class SayTimeAction < DateTimeAction
632
+
633
+ def initialize(h={})
634
+
635
+ options = {
636
+ :'12_hour' => true
637
+ }
638
+
639
+ super(options.merge h)
640
+
641
+ end
642
+
643
+ def invoke()
644
+ time = ($env and $env[:time]) ? $env[:time] : Time.now
645
+ tformat = @h['12_hour'] ? "%-I:%M%P" : "%H:%M"
646
+ super(time.strftime(tformat))
647
+ end
648
+
649
+ def to_pc()
650
+ 'say current_time()'
651
+ end
652
+
653
+ def to_s(colour: false)
654
+ 'Say Current Time'
655
+ end
656
+
657
+ end
658
+
659
+
660
+ class DeviceAction < Action
661
+
662
+ def initialize(h={})
663
+ super(h)
664
+ @group = 'device'
665
+ end
666
+
667
+ end
668
+
669
+ # Category: Device Actions
670
+ #
671
+ class AndroidShortcutsAction < DeviceAction
672
+
673
+ def initialize(h={})
674
+
675
+ options = {
676
+ option: 1
677
+ }
678
+
679
+ super(options.merge h)
680
+
681
+ end
682
+
683
+ def to_s(colour: false)
684
+ 'AndroidShortcutsAction ' + @h.inspect
685
+ end
686
+
687
+ alias to_summary to_s
688
+ end
689
+
690
+ # Category: Device Actions
691
+ #
692
+ class ClipboardAction < DeviceAction
693
+
694
+ def initialize(h={})
695
+
696
+ options = {
697
+ clipboard_text: ''
698
+ }
699
+
700
+ super(options.merge h)
701
+
702
+ end
703
+
704
+ def to_s(colour: false)
705
+ 'ClipboardAction ' + @h.inspect
706
+ end
707
+
708
+ alias to_summary to_s
709
+ end
710
+
711
+ # Category: Device Actions
712
+ #
713
+ class PressBackAction < DeviceAction
714
+
715
+ def initialize(h={})
716
+
717
+ options = {
718
+ }
719
+
720
+ super(options.merge h)
721
+
722
+ end
723
+
724
+ def to_s(colour: false)
725
+ 'PressBackAction ' + @h.inspect
726
+ end
727
+
728
+ alias to_summary to_s
729
+ end
730
+
731
+ # Category: Device Actions
732
+ #
733
+ class SpeakTextAction < DeviceAction
734
+
735
+ def initialize(h={})
736
+
737
+ options = {
738
+ text_to_say: '',
739
+ queue: false,
740
+ read_numbers_individually: false,
741
+ specify_audio_stream: false,
742
+ speed: 0.99,
743
+ pitch: 0.99,
744
+ wait_to_finish: false,
745
+ audio_stream: 0
746
+ }
747
+
748
+ super(options.merge h)
749
+
750
+ end
751
+
752
+ def to_s(colour: false)
753
+ "Speak Text (%s)" % @h[:text_to_say]
754
+ end
755
+
756
+ end
757
+
758
+ # Category: Device Actions
759
+ #
760
+ class UIInteractionAction < DeviceAction
761
+
762
+ def initialize(h={})
763
+
764
+ options = {
765
+ ui_interaction_configuration: {:type=>"Copy"},
766
+ action: 2
767
+ }
768
+
769
+ super(options.merge h)
770
+
771
+ end
772
+
773
+ def to_s(colour: false)
774
+ 'UIInteractionAction ' + @h.inspect
775
+ end
776
+
777
+ alias to_summary to_s
778
+ end
779
+
780
+ # Category: Device Actions
781
+ #
782
+ class VoiceSearchAction < DeviceAction
783
+
784
+ def initialize(h={})
785
+
786
+ options = {
787
+ }
788
+
789
+ super(options.merge h)
790
+
791
+ end
792
+
793
+ def to_s(colour: false)
794
+ 'VoiceSearchAction ' + @h.inspect
795
+ end
796
+
797
+ alias to_summary to_s
798
+ end
799
+
800
+
801
+ class DeviceSettingsAction < Action
802
+
803
+ def initialize(h={})
804
+ super(h)
805
+ @group = 'devicesettings'
806
+ end
807
+
808
+ end
809
+
810
+ # Category: Device Settings
811
+ #
812
+ class ExpandCollapseStatusBarAction < DeviceSettingsAction
813
+
814
+ def initialize(h={})
815
+
816
+ options = {
817
+ option: 0
818
+ }
819
+
820
+ super(options.merge h)
821
+
822
+ end
823
+
824
+ def to_s(colour: false)
825
+ 'ExpandCollapseStatusBarAction ' + @h.inspect
826
+ end
827
+
828
+ alias to_summary to_s
829
+ end
830
+
831
+ # Category: Device Settings
832
+ #
833
+ class LaunchHomeScreenAction < DeviceSettingsAction
834
+
835
+ def initialize(h={})
836
+
837
+ options = {
838
+ }
839
+
840
+ super(options.merge h)
841
+
842
+ end
843
+
844
+ def to_s(colour: false)
845
+ 'LaunchHomeScreenAction ' + @h.inspect
846
+ end
847
+
848
+ alias to_summary to_s
849
+ end
850
+
851
+ # Category: Device Settings
852
+ #
853
+ class CameraFlashLightAction < DeviceSettingsAction
854
+
855
+ # options
856
+ # 0 Toch On
857
+ # 1 Torch Off
858
+ # 2 Torch Toggle
859
+ #
860
+ def initialize(h={})
861
+
862
+ options = {
863
+ launch_foreground: false,
864
+ state: 0
865
+ }
866
+
867
+ super(options.merge h)
868
+
869
+ end
870
+
871
+ def to_pc()
872
+ ['torch :on', 'torch :off', 'torch :toggle'][@h[:state]]
873
+ end
874
+
875
+ def to_s(colour: false)
876
+ ['Torch On', 'Torch Off', 'Torch Toggle'][@h[:state]]
877
+ end
878
+
879
+ end
880
+
881
+ # Category: Device Settings
882
+ #
883
+ class VibrateAction < DeviceSettingsAction
884
+
885
+ def initialize(h={})
886
+
887
+ options = {
888
+ vibrate_pattern: 1
889
+ }
890
+
891
+ super(options.merge h)
892
+
893
+ end
894
+
895
+ def to_s(colour: false)
896
+
897
+ pattern = [
898
+ 'Blip', 'Short Buzz', 'Long Buzz', 'Rapid', 'Slow', 'Increasing',
899
+ 'Constant', 'Decreasing', 'Final Fantasy', 'Game Over', 'Star Wars',
900
+ 'Mini Blip', 'Micro Blip'
901
+ ]
902
+
903
+ 'Vibrate ' + "(%s)" % pattern[@h[:vibrate_pattern].to_i]
904
+ end
905
+
906
+ end
907
+
908
+ # Category: Device Settings
909
+ #
910
+ class SetAutoRotateAction < DeviceSettingsAction
911
+
912
+ def initialize(h={})
913
+
914
+ options = {
915
+ state: 0
916
+ }
917
+
918
+ super(options.merge h)
919
+
920
+ end
921
+
922
+ def to_s(colour: false)
923
+ 'SetAutoRotateAction ' + @h.inspect
924
+ end
925
+
926
+ alias to_summary to_s
927
+ end
928
+
929
+ # Category: Device Settings
930
+ #
931
+ class DayDreamAction < DeviceSettingsAction
932
+
933
+ def initialize(h={})
934
+
935
+ options = {
936
+ }
937
+
938
+ super(options.merge h)
939
+
940
+ end
941
+
942
+ def to_s(colour: false)
943
+ 'DayDreamAction ' + @h.inspect
944
+ end
945
+
946
+ alias to_summary to_s
947
+ end
948
+
949
+ # Category: Device Settings
950
+ #
951
+ class SetKeyboardAction < DeviceSettingsAction
952
+
953
+ def initialize(h={})
954
+
955
+ options = {
956
+ }
957
+
958
+ super(options.merge h)
959
+
960
+ end
961
+
962
+ def to_s(colour: false)
963
+ 'SetKeyboardAction ' + @h.inspect
964
+ end
965
+
966
+ alias to_summary to_s
967
+ end
968
+
969
+ # Category: Device Settings
970
+ #
971
+ class SetKeyguardAction < DeviceSettingsAction
972
+
973
+ def initialize(h={})
974
+
975
+ options = {
976
+ keyguard_on: true
977
+ }
978
+
979
+ super(options.merge h)
980
+
981
+ end
982
+
983
+ def to_s(colour: false)
984
+ 'SetKeyguardAction ' + @h.inspect
985
+ end
986
+
987
+ alias to_summary to_s
988
+ end
989
+
990
+ # Category: Device Settings
991
+ #
992
+ class CarModeAction < DeviceSettingsAction
993
+
994
+ def initialize(h={})
995
+
996
+ options = {
997
+ option: 0
998
+ }
999
+
1000
+ super(options.merge h)
1001
+
1002
+ end
1003
+
1004
+ def to_s(colour: false)
1005
+ 'CarModeAction ' + @h.inspect
1006
+ end
1007
+
1008
+ alias to_summary to_s
1009
+ end
1010
+
1011
+ # Category: Device Settings
1012
+ #
1013
+ class ChangeKeyboardAction < DeviceSettingsAction
1014
+
1015
+ def initialize(h={})
1016
+
1017
+ options = {
1018
+ keyboard_id: 'com.android.inputmethod.latin/.LatinIME',
1019
+ keyboard_name: 'Android Keyboard (AOSP)'
1020
+ }
1021
+
1022
+ super(options.merge h)
1023
+
1024
+ end
1025
+
1026
+ def to_s(colour: false)
1027
+ 'ChangeKeyboardAction ' + @h.inspect
1028
+ end
1029
+
1030
+ alias to_summary to_s
1031
+ end
1032
+
1033
+ # Category: Device Settings
1034
+ #
1035
+ class SetWallpaperAction < DeviceSettingsAction
1036
+
1037
+ def initialize(h={})
1038
+
1039
+ options = {
1040
+ image_name: '6051449505275476553',
1041
+ s_screen_options: ["Home Screen", "Lock Screen", "Home + Lock Screen"],
1042
+ s_options: ["Image", "Live Wallpaper (Preview Screen)"],
1043
+ wallpaper_uri_string: 'content://media/external/images/media/928',
1044
+ screen_option: 0,
1045
+ option: 0
1046
+ }
1047
+
1048
+ super(options.merge h)
1049
+
1050
+ end
1051
+
1052
+ def to_s(colour: false)
1053
+ 'SetWallpaperAction ' + @h.inspect
1054
+ end
1055
+
1056
+ alias to_summary to_s
1057
+ end
1058
+
1059
+ class FileAction < Action
1060
+
1061
+ def initialize(h={})
1062
+ super(h)
1063
+ @group = 'file'
1064
+ end
1065
+
1066
+ end
1067
+
1068
+ # Category: Files
1069
+ #
1070
+ class OpenFileAction < FileAction
1071
+
1072
+ def initialize(h={})
1073
+
1074
+ options = {
1075
+ app_name: '',
1076
+ class_name: '',
1077
+ package_name: '',
1078
+ file_path: ''
1079
+ }
1080
+
1081
+ super(options.merge h)
1082
+
1083
+ end
1084
+
1085
+ def to_s(colour: false)
1086
+ 'OpenFileAction ' + @h.inspect
1087
+ end
1088
+
1089
+ alias to_summary to_s
1090
+ end
1091
+
1092
+
1093
+ class LocationAction < Action
1094
+
1095
+ def initialize(h={})
1096
+ super(h)
1097
+ @group = 'location'
1098
+ end
1099
+
1100
+ end
1101
+
1102
+ # Category: Location
1103
+ #
1104
+ class ForceLocationUpdateAction < LocationAction
1105
+
1106
+ def initialize(h={})
1107
+
1108
+ options = {
1109
+ }
1110
+
1111
+ super(options.merge h)
1112
+
1113
+ end
1114
+
1115
+ def to_s(colour: false)
1116
+ 'ForceLocationUpdateAction ' + @h.inspect
1117
+ end
1118
+
1119
+ alias to_summary to_s
1120
+ end
1121
+
1122
+ # Category: Location
1123
+ #
1124
+ class ShareLocationAction < LocationAction
1125
+
1126
+ def initialize(h={})
1127
+
1128
+ options = {
1129
+ email: '',
1130
+ variable: {:m_stringValue=>"", :m_name=>"", :m_decimalValue=>0.0, :isLocal=>true, :m_booleanValue=>false, :excludeFromLog=>false, :m_intValue=>0, :m_type=>2},
1131
+ sim_id: 0,
1132
+ output_channel: 5,
1133
+ old_variable_format: true
1134
+ }
1135
+
1136
+ super(options.merge h)
1137
+
1138
+ end
1139
+
1140
+ def to_s(colour: false)
1141
+ 'ShareLocationAction ' + @h.inspect
1142
+ end
1143
+
1144
+ alias to_summary to_s
1145
+ end
1146
+
1147
+ # Category: Location
1148
+ #
1149
+ class SetLocationUpdateRateAction < LocationAction
1150
+
1151
+ def initialize(h={})
1152
+
1153
+ options = {
1154
+ update_rate: 0,
1155
+ update_rate_seconds: 600
1156
+ }
1157
+
1158
+ super(options.merge h)
1159
+
1160
+ end
1161
+
1162
+ def to_s(colour: false)
1163
+ 'SetLocationUpdateRateAction ' + @h.inspect
1164
+ end
1165
+
1166
+ alias to_summary to_s
1167
+ end
1168
+
1169
+ class LoggingAction < Action
1170
+
1171
+ def initialize(h={})
1172
+ super(h)
1173
+ @group = 'logging'
1174
+ end
1175
+
1176
+ end
1177
+
1178
+ # Category: Logging
1179
+ #
1180
+ class AddCalendarEntryAction < LoggingAction
1181
+
1182
+ def initialize(h={})
1183
+
1184
+ options = {
1185
+ title: '',
1186
+ duration_value: '0',
1187
+ calendar_id: '3',
1188
+ detail: '',
1189
+ availability: 0,
1190
+ fixed_days: 16,
1191
+ fixed_hour: 0,
1192
+ fixed_minute: 0,
1193
+ fixed_months: 8,
1194
+ fixed_time: true,
1195
+ relative_days: 0,
1196
+ relative_hours: 0,
1197
+ relative_minutes: 0,
1198
+ all_day_event: true
1199
+ }
1200
+
1201
+ super(options.merge h)
1202
+
1203
+ end
1204
+
1205
+ def to_s(colour: false)
1206
+ 'AddCalendarEntryAction ' + @h.inspect
1207
+ end
1208
+
1209
+ alias to_summary to_s
1210
+ end
1211
+
1212
+ # Category: Logging
1213
+ #
1214
+ class LogAction < LoggingAction
1215
+
1216
+ def initialize(h={})
1217
+
1218
+ options = {
1219
+ log_text: '',
1220
+ log_date_and_time: true
1221
+ }
1222
+
1223
+ super(options.merge h)
1224
+
1225
+ end
1226
+
1227
+ def to_s(colour: false)
1228
+ 'LogAction ' + @h.inspect
1229
+ end
1230
+
1231
+ alias to_summary to_s
1232
+ end
1233
+
1234
+ # Category: Logging
1235
+ #
1236
+ class ClearLogAction < LoggingAction
1237
+
1238
+ def initialize(h={})
1239
+
1240
+ options = {
1241
+ user_log: true
1242
+ }
1243
+
1244
+ super(options.merge h)
1245
+
1246
+ end
1247
+
1248
+ def to_s(colour: false)
1249
+ 'ClearLogAction ' + @h.inspect
1250
+ end
1251
+
1252
+ alias to_summary to_s
1253
+ end
1254
+
1255
+ # MacroDroid Specific
1256
+ #
1257
+ class ExportMacrosAction < Action
1258
+
1259
+ def initialize(h={})
1260
+
1261
+ options = {
1262
+ file_path: "", path_uri: ""
1263
+ }
1264
+ super(h)
1265
+
1266
+ end
1267
+
1268
+ def to_s(colour: false)
1269
+
1270
+ 'Export macros'
1271
+
1272
+ end
1273
+
1274
+ alias to_summary to_s
1275
+
1276
+ end
1277
+
1278
+ class PauseAction < Action
1279
+
1280
+ def initialize(h={})
1281
+
1282
+ options = {
1283
+ delay_in_milli_seconds: 0, delay_in_seconds: 1, use_alarm: false
1284
+ }
1285
+ super(h)
1286
+
1287
+ end
1288
+
1289
+ def to_s(colour: false)
1290
+
1291
+ su = Subunit.new(units={minutes:60, hours:60},
1292
+ seconds: @h[:delay_in_seconds])
1293
+
1294
+ ms = @h[:delay_in_milli_seconds]
1295
+
1296
+ duration = if su.to_h.has_key?(:minutes) or (ms < 1) then
1297
+ su.strfunit("%X")
1298
+ else
1299
+ "%s %s ms" % [su.strfunit("%X"), ms]
1300
+ end
1301
+
1302
+ "Wait " + duration
1303
+ end
1304
+
1305
+ end
1306
+
1307
+ class MediaAction < Action
1308
+
1309
+ def initialize(h={})
1310
+ super(h)
1311
+ @group = 'media'
1312
+ end
1313
+
1314
+ end
1315
+
1316
+ # Category: Media
1317
+ #
1318
+ class RecordMicrophoneAction < MediaAction
1319
+
1320
+ def initialize(h={})
1321
+
1322
+ options = {
1323
+ path: '/storage/emulated/0/MacroDroid/Recordings',
1324
+ record_time_string: 'Cancel Recording',
1325
+ recording_format: 0,
1326
+ seconds_to_record_for: -2
1327
+ }
1328
+
1329
+ super(options.merge h)
1330
+
1331
+ end
1332
+
1333
+ def to_s(colour: false)
1334
+ 'RecordMicrophoneAction ' + @h.inspect
1335
+ end
1336
+
1337
+ alias to_summary to_s
1338
+ end
1339
+
1340
+ # Category: Media
1341
+ #
1342
+ class PlaySoundAction < MediaAction
1343
+
1344
+ def initialize(h={})
1345
+
1346
+ options = {
1347
+ selected_index: 0,
1348
+ file_path: ''
1349
+ }
1350
+
1351
+ super(options.merge h)
1352
+
1353
+ end
1354
+
1355
+ def to_s(colour: false)
1356
+ 'Play: ' + @h[:file_path]
1357
+ end
1358
+
1359
+ end
1360
+
1361
+
1362
+ class MessagingAction < Action
1363
+
1364
+ def initialize(h={})
1365
+ super(h)
1366
+ @group = 'messaging'
1367
+ end
1368
+
1369
+ end
1370
+
1371
+ # Category: Messaging
1372
+ #
1373
+ class SendEmailAction < MessagingAction
1374
+
1375
+ def initialize(h={})
1376
+
1377
+ options = {
1378
+ subject: '',
1379
+ body: '',
1380
+ email_address: '',
1381
+ from_email_address: '',
1382
+ attach_user_log: false,
1383
+ attach_log: false,
1384
+ send_option: 0
1385
+ }
1386
+
1387
+ super(options.merge h)
1388
+
1389
+ end
1390
+
1391
+ def to_s(colour: false)
1392
+ 'SendEmailAction ' + @h.inspect
1393
+ end
1394
+
1395
+ alias to_summary to_s
1396
+ end
1397
+
1398
+ # Category: Messaging
1399
+ #
1400
+ class SendSMSAction < MessagingAction
1401
+
1402
+ def initialize(h={})
1403
+
1404
+ options = {
1405
+ number: '',
1406
+ contact: {:m_id=>"Hardwired_Number", :m_lookupKey=>"Hardwired_Number", :m_name=>"[Select Number]"},
1407
+ message_content: '',
1408
+ add_to_message_log: false,
1409
+ pre_populate: false,
1410
+ sim_id: 0
1411
+ }
1412
+
1413
+ super(options.merge h)
1414
+
1415
+ end
1416
+
1417
+ def to_s(colour: false)
1418
+ 'SendSMSAction ' + @h.inspect
1419
+ end
1420
+
1421
+ alias to_summary to_s
1422
+ end
1423
+
1424
+ # Category: Messaging
1425
+ #
1426
+ class UDPCommandAction < MessagingAction
1427
+
1428
+ def initialize(h={})
1429
+
1430
+ options = {
1431
+ destination: '',
1432
+ message: '',
1433
+ port: 1024
1434
+ }
1435
+
1436
+ super(options.merge h)
1437
+
1438
+ end
1439
+
1440
+ def to_s(colour: false)
1441
+ 'UDPCommandAction ' + @h.inspect
1442
+ end
1443
+
1444
+ alias to_summary to_s
1445
+ end
1446
+
1447
+
1448
+ class NotificationsAction < Action
1449
+
1450
+ def initialize(h={})
1451
+ super(h)
1452
+ @group = 'notifications'
1453
+ end
1454
+
1455
+ end
1456
+
1457
+ # Category: Notifications
1458
+ #
1459
+ class ClearNotificationsAction < NotificationsAction
1460
+
1461
+ def initialize(h={})
1462
+
1463
+ options = {
1464
+ package_name_list: [],
1465
+ match_text: '',
1466
+ application_name_list: [],
1467
+ clear_persistent: false,
1468
+ excludes: false,
1469
+ match_option: 0,
1470
+ age_in_seconds: 0,
1471
+ option: 0,
1472
+ enable_regex: false
1473
+ }
1474
+
1475
+ super(options.merge h)
1476
+
1477
+ end
1478
+
1479
+ def to_s(colour: false)
1480
+ 'ClearNotificationsAction ' + @h.inspect
1481
+ end
1482
+
1483
+ alias to_summary to_s
1484
+ end
1485
+
1486
+ # Category: Notifications
1487
+ #
1488
+ class MessageDialogAction < NotificationsAction
1489
+
1490
+ def initialize(h={})
1491
+
1492
+ options = {
1493
+ secondary_class_type: 'MessageDialogAction',
1494
+ ringtone_name: 'Default',
1495
+ notification_text: '',
1496
+ notification_subject: '',
1497
+ macro_guid_to_run: -0,
1498
+ notification_channel_type: 0,
1499
+ image_resource_id: 0,
1500
+ overwrite_existing: false,
1501
+ priority: 0,
1502
+ ringtone_index: 0,
1503
+ icon_bg_color: -1762269,
1504
+ run_macro_when_pressed: false
1505
+ }
1506
+
1507
+ super(options.merge h)
1508
+
1509
+ end
1510
+
1511
+ def to_s(colour: false)
1512
+ 'Display Dialog' + "\n Battery at: [battery]"
1513
+ end
1514
+
1515
+ end
1516
+
1517
+ # Category: Notifications
1518
+ #
1519
+ class AllowLEDNotificationLightAction < NotificationsAction
1520
+
1521
+ def initialize(h={})
1522
+
1523
+ options = {
1524
+ enabled: true
1525
+ }
1526
+
1527
+ super(options.merge h)
1528
+
1529
+ end
1530
+
1531
+ def to_s(colour: false)
1532
+ 'AllowLEDNotificationLightAction ' + @h.inspect
1533
+ end
1534
+
1535
+ alias to_summary to_s
1536
+ end
1537
+
1538
+ # Category: Notifications
1539
+ #
1540
+ class SetNotificationSoundAction < NotificationsAction
1541
+
1542
+ def initialize(h={})
1543
+
1544
+ options = {
1545
+ ringtone_uri: 'content://media/internal/audio/media/27'
1546
+ }
1547
+
1548
+ super(options.merge h)
1549
+
1550
+ end
1551
+
1552
+ def to_s(colour: false)
1553
+ 'SetNotificationSoundAction ' + @h.inspect
1554
+ end
1555
+
1556
+ alias to_summary to_s
1557
+ end
1558
+
1559
+ # Category: Notifications
1560
+ #
1561
+ class SetNotificationSoundAction < NotificationsAction
1562
+
1563
+ def initialize(h={})
1564
+
1565
+ options = {
1566
+ ringtone_uri: 'content://media/internal/audio/media/51'
1567
+ }
1568
+
1569
+ super(options.merge h)
1570
+
1571
+ end
1572
+
1573
+ def to_s(colour: false)
1574
+ 'SetNotificationSoundAction ' + @h.inspect
1575
+ end
1576
+
1577
+ alias to_summary to_s
1578
+ end
1579
+
1580
+ # Category: Notifications
1581
+ #
1582
+ class SetNotificationSoundAction < NotificationsAction
1583
+
1584
+ def initialize(h={})
1585
+
1586
+ options = {
1587
+ ringtone_name: 'None'
1588
+ }
1589
+
1590
+ super(options.merge h)
1591
+
1592
+ end
1593
+
1594
+ def to_s(colour: false)
1595
+ 'SetNotificationSoundAction ' + @h.inspect
1596
+ end
1597
+
1598
+ alias to_summary to_s
1599
+ end
1600
+
1601
+ # Category: Notifications
1602
+ #
1603
+ class NotificationAction < NotificationsAction
1604
+
1605
+ def initialize(h={})
1606
+
1607
+ h[:notification_subject] = h[:subject] if h[:subject]
1608
+ h[:notification_text] = h[:text] if h[:text]
1609
+
1610
+ options = {
1611
+ ringtone_name: 'Default',
1612
+ notification_text: '',
1613
+ notification_subject: '',
1614
+ macro_guid_to_run: 0,
1615
+ notification_channel_type: 0,
1616
+ image_resource_id: 0,
1617
+ overwrite_existing: false,
1618
+ priority: 0,
1619
+ ringtone_index: 0,
1620
+ icon_bg_color: -1762269,
1621
+ run_macro_when_pressed: false
1622
+ }
1623
+
1624
+ super(options.merge filter(options, h))
1625
+
1626
+ end
1627
+
1628
+ def to_s(colour: false)
1629
+ "Display Notification\n " + \
1630
+ "%s: %s" % [@h[:notification_subject], @h[:notification_text]]
1631
+ end
1632
+
1633
+ end
1634
+
1635
+ # Category: Notifications
1636
+ #
1637
+ class ToastAction < NotificationsAction
1638
+
1639
+ def initialize(h={})
1640
+
1641
+ if h[:msg] then
1642
+ h[:message_text] = h[:msg]
1643
+ h.delete :msg
1644
+ end
1645
+
1646
+ options = {
1647
+ message_text: '',
1648
+ image_resource_name: 'launcher_no_border',
1649
+ image_package_name: 'com.arlosoft.macrodroid',
1650
+ image_name: 'launcher_no_border',
1651
+ duration: 0,
1652
+ display_icon: true,
1653
+ background_color: -12434878,
1654
+ position: 0
1655
+ }
1656
+
1657
+ super(options.merge h)
1658
+
1659
+ end
1660
+
1661
+ def invoke()
1662
+ super(@h[:message_text])
1663
+ end
1664
+
1665
+ def to_pc()
1666
+ "popup_message '%s'" % @h[:message_text]
1667
+ end
1668
+
1669
+ def to_s(colour: false)
1670
+ "Popup Message\n %s" % @h[:message_text]
1671
+ end
1672
+
1673
+ end
1674
+
1675
+
1676
+ class PhoneAction < Action
1677
+
1678
+ def initialize(h={})
1679
+ super(h)
1680
+ @group = 'phone'
1681
+ end
1682
+
1683
+ end
1684
+
1685
+ # Category: Phone
1686
+ #
1687
+ class AnswerCallAction < PhoneAction
1688
+
1689
+ def initialize(h={})
1690
+
1691
+ options = {
1692
+ selected_index: 0
1693
+ }
1694
+
1695
+ super(options.merge h)
1696
+
1697
+ end
1698
+
1699
+ def to_s(colour: false)
1700
+ @s = 'Answer Call' + "\n "
1701
+ super()
1702
+ end
1703
+ end
1704
+
1705
+ # Category: Phone
1706
+ #
1707
+ class ClearCallLogAction < PhoneAction
1708
+
1709
+ def initialize(h={})
1710
+
1711
+ options = {
1712
+ non_contact: false,
1713
+ specific_contact: false,
1714
+ type: 0
1715
+ }
1716
+
1717
+ super(options.merge h)
1718
+
1719
+ end
1720
+
1721
+ def to_s(colour: false)
1722
+ 'ClearCallLogAction ' + @h.inspect
1723
+ end
1724
+
1725
+ alias to_summary to_s
1726
+ end
1727
+
1728
+ # Category: Phone
1729
+ #
1730
+ class OpenCallLogAction < PhoneAction
1731
+
1732
+ def initialize(h={})
1733
+
1734
+ options = {
1735
+ }
1736
+
1737
+ super(options.merge h)
1738
+
1739
+ end
1740
+
1741
+ def to_s(colour: false)
1742
+ 'OpenCallLogAction ' + @h.inspect
1743
+ end
1744
+
1745
+ alias to_summary to_s
1746
+ end
1747
+
1748
+ # Category: Phone
1749
+ #
1750
+ class RejectCallAction < PhoneAction
1751
+
1752
+ def initialize(h={})
1753
+
1754
+ options = {
1755
+ }
1756
+
1757
+ super(options.merge h)
1758
+
1759
+ end
1760
+
1761
+ def to_s(colour: false)
1762
+ @s = 'Call Reject' + "\n "
1763
+ super()
1764
+ end
1765
+
1766
+ end
1767
+
1768
+ # Category: Phone
1769
+ #
1770
+ class MakeCallAction < PhoneAction
1771
+
1772
+ def initialize(h={})
1773
+
1774
+ options = {
1775
+ contact: {:m_id=>"Hardwired_Number", :m_lookupKey=>"Hardwired_Number", :m_name=>"[Select Number]"},
1776
+ number: ''
1777
+ }
1778
+
1779
+ super(options.merge h)
1780
+
1781
+ end
1782
+
1783
+ def to_s(colour: false)
1784
+ 'MakeCallAction ' + @h.inspect
1785
+ end
1786
+
1787
+ alias to_summary to_s
1788
+ end
1789
+
1790
+
1791
+ # Category: Phone
1792
+ #
1793
+ class SetRingtoneAction < PhoneAction
1794
+
1795
+ def initialize(h={})
1796
+
1797
+ options = {
1798
+ ringtone_uri: 'content://media/internal/audio/media/174'
1799
+ }
1800
+
1801
+ super(options.merge h)
1802
+
1803
+ end
1804
+
1805
+ def to_s(colour: false)
1806
+ 'SetRingtoneAction ' + @h.inspect
1807
+ end
1808
+
1809
+ alias to_summary to_s
1810
+ end
1811
+
1812
+ class ScreenAction < Action
1813
+
1814
+ def initialize(h={})
1815
+ super(h)
1816
+ @group = 'screen'
1817
+ end
1818
+
1819
+ end
1820
+
1821
+ # Category: Screen
1822
+ #
1823
+ class SetBrightnessAction < ScreenAction
1824
+
1825
+ def initialize(h={})
1826
+
1827
+ options = {
1828
+ brightness_percent: 81,
1829
+ force_pie_mode: false,
1830
+ brightness: 0
1831
+ }
1832
+
1833
+ super(options.merge h)
1834
+
1835
+ end
1836
+
1837
+ def to_s(colour: false)
1838
+ 'SetBrightnessAction ' + @h.inspect
1839
+ end
1840
+
1841
+ alias to_summary to_s
1842
+ end
1843
+
1844
+ # Category: Screen
1845
+ #
1846
+ class ForceScreenRotationAction < ScreenAction
1847
+
1848
+ def initialize(h={})
1849
+
1850
+ options = {
1851
+ option: 0
1852
+ }
1853
+
1854
+ super(options.merge h)
1855
+
1856
+ end
1857
+
1858
+ def to_s(colour: false)
1859
+ 'ForceScreenRotationAction ' + @h.inspect
1860
+ end
1861
+
1862
+ alias to_summary to_s
1863
+ end
1864
+
1865
+ # Category: Screen
1866
+ #
1867
+ class ScreenOnAction < ScreenAction
1868
+
1869
+ def initialize(h={})
1870
+
1871
+ options = {
1872
+ pie_lock_screen: false,
1873
+ screen_off: true,
1874
+ screen_off_no_lock: false,
1875
+ screen_on_alternative: false
1876
+ }
1877
+
1878
+ super(options.merge h)
1879
+
1880
+ end
1881
+
1882
+ def to_s(colour: false)
1883
+
1884
+ state = @h[:screen_off] ? 'Off' : 'On'
1885
+ state += ' ' + 'No Lock (root only)' if @h[:screen_off_no_lock]
1886
+ #state += ' ' + '(Alternative)' if @h[:screen_on_alternative]
1887
+
1888
+ 'Screen ' + state
1889
+
1890
+ end
1891
+
1892
+ alias to_summary to_s
1893
+ end
1894
+
1895
+ # Category: Screen
1896
+ #
1897
+ class DimScreenAction < ScreenAction
1898
+
1899
+ def initialize(h={})
1900
+
1901
+ options = {
1902
+ percent: 50,
1903
+ dim_screen_on: true
1904
+ }
1905
+
1906
+ super(options.merge h)
1907
+
1908
+ end
1909
+
1910
+ def to_s(colour: false)
1911
+ 'DimScreenAction ' + @h.inspect
1912
+ end
1913
+
1914
+ alias to_summary to_s
1915
+ end
1916
+
1917
+ # Category: Screen
1918
+ #
1919
+ # options:
1920
+ # keep awake, screen on => enabled: true
1921
+ # disable keep awake => enabled: false
1922
+ #
1923
+ class KeepAwakeAction < ScreenAction
1924
+
1925
+ def initialize(h={})
1926
+
1927
+ options = {
1928
+ enabled: true,
1929
+ permanent: true,
1930
+ screen_option: 0,
1931
+ seconds_to_stay_awake_for: 0
1932
+ }
1933
+
1934
+ super(options.merge h)
1935
+
1936
+ end
1937
+
1938
+ def to_s(colour: false)
1939
+
1940
+ screen = @h[:screen_option] == 0 ? 'Screen On' : 'Screen Off'
1941
+
1942
+ if @h[:enabled] then
1943
+
1944
+ whenx = if @h[:seconds_to_stay_awake_for] == 0 then
1945
+
1946
+ 'Until Disabled'
1947
+
1948
+ else
1949
+ scnds = @h[:seconds_to_stay_awake_for]
1950
+ Subunit.new(units={minutes:60, hours:60}, seconds: scnds).strfunit("%x")
1951
+ end
1952
+
1953
+ "Keep Device Awake\n " + screen + ' - ' + whenx
1954
+
1955
+ else
1956
+ 'Disable Keep Awake'
1957
+ end
1958
+
1959
+
1960
+ end
1961
+ end
1962
+
1963
+ # Category: Screen
1964
+ #
1965
+ class SetScreenTimeoutAction < ScreenAction
1966
+
1967
+ def initialize(h={})
1968
+
1969
+ options = {
1970
+ timeout_delay_string: '1 Minute',
1971
+ timeout_delay: 60,
1972
+ custom_value_delay: 0
1973
+ }
1974
+
1975
+ super(options.merge h)
1976
+
1977
+ end
1978
+
1979
+ def to_s(colour: false)
1980
+ 'SetScreenTimeoutAction ' + @h.inspect
1981
+ end
1982
+
1983
+ alias to_summary to_s
1984
+ end
1985
+
1986
+
1987
+ class VolumeAction < Action
1988
+
1989
+ def initialize(h={})
1990
+ super(h)
1991
+ @group = 'volume'
1992
+ end
1993
+
1994
+ end
1995
+
1996
+ # Category: Volume
1997
+ #
1998
+ class SilentModeVibrateOffAction < VolumeAction
1999
+
2000
+ def initialize(h={})
2001
+
2002
+ options = {
2003
+ option: 1
2004
+ }
2005
+
2006
+ super(options.merge h)
2007
+
2008
+ end
2009
+
2010
+ def to_s(colour: false)
2011
+ 'SilentModeVibrateOffAction ' + @h.inspect
2012
+ end
2013
+
2014
+ alias to_summary to_s
2015
+ end
2016
+
2017
+ # Category: Volume
2018
+ #
2019
+ class SetVibrateAction < VolumeAction
2020
+
2021
+ def initialize(h={})
2022
+
2023
+ options = {
2024
+ option: 'Silent (Vibrate On)',
2025
+ option_int: -1
2026
+ }
2027
+
2028
+ super(options.merge h)
2029
+
2030
+ end
2031
+
2032
+ def to_s(colour: false)
2033
+
2034
+ a = [
2035
+ 'Silent (Vibrate On)',
2036
+ 'Normal (Vibrate Off)',
2037
+ 'Vibrate when ringing On',
2038
+ 'Vibrate when ringing Off',
2039
+ 'Vibrate when ringing Toggle'
2040
+ ]
2041
+
2042
+ status = a[@h[:option_int]]
2043
+ @s = 'Vibrate Enable/Disable ' + "\n " + status + "\n "
2044
+ super()
2045
+
2046
+ end
2047
+
2048
+ def to_summary(colour: false)
2049
+
2050
+ @s = 'Vibrate Enable/Disable'
2051
+
2052
+ end
2053
+ end
2054
+
2055
+ # Category: Volume
2056
+ #
2057
+ class VolumeIncrementDecrementAction < VolumeAction
2058
+
2059
+ def initialize(h={})
2060
+
2061
+ options = {
2062
+ volume_up: true
2063
+ }
2064
+
2065
+ super(options.merge h)
2066
+
2067
+ end
2068
+
2069
+ def to_s(colour: false)
2070
+ 'VolumeIncrementDecrementAction ' + @h.inspect
2071
+ end
2072
+
2073
+ alias to_summary to_s
2074
+ end
2075
+
2076
+ # Category: Volume
2077
+ #
2078
+ class SpeakerPhoneAction < VolumeAction
2079
+
2080
+ def initialize(h={})
2081
+
2082
+ options = {
2083
+ secondary_class_type: 'SpeakerPhoneAction',
2084
+ state: 0
2085
+ }
2086
+
2087
+ super(options.merge h)
2088
+
2089
+ end
2090
+
2091
+ def to_s(colour: false)
2092
+ 'SpeakerPhoneAction ' + @h.inspect
2093
+ end
2094
+
2095
+ alias to_summary to_s
2096
+ end
2097
+
2098
+ # Category: Volume
2099
+ #
2100
+ class SetVolumeAction < VolumeAction
2101
+
2102
+ def initialize(h={})
2103
+
2104
+ options = {
2105
+ variables: [nil, nil, nil, nil, nil, nil, nil],
2106
+ stream_index_array: [false, false, false, false, false, false, true],
2107
+ stream_volume_array: [0, 0, 0, 0, 0, 0, 66],
2108
+ force_vibrate_off: false,
2109
+ volume: -1
2110
+ }
2111
+
2112
+ super(options.merge h)
2113
+
2114
+ end
2115
+
2116
+ def to_s(colour: false)
2117
+ volume = @h[:stream_index_array].zip(@h[:stream_volume_array]).to_h[true]
2118
+ 'Volume Change ' + "Notification = %s%%" % volume
2119
+ end
2120
+ end