ruby-macrodroid 0.7.6 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/ruby-macrodroid.rb +99 -4092
- data/lib/ruby-macrodroid/actions.rb +2056 -0
- data/lib/ruby-macrodroid/base.rb +148 -0
- data/lib/ruby-macrodroid/triggers.rb +1558 -0
- metadata +13 -10
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3e810bea9dc68b5b0bb2623b46a08544ed42db8112f0b2be703bbac6dce6178
|
4
|
+
data.tar.gz: d41bbc4bae9e9c5e7f65684db06c54bb0d058aee56b69f8c58a7dff99724725d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5de76ced91b66dae5ce7fba414c4ea09dff2ffbf9c3cd04009c6a270570825605035413fc5b6d3cc115f79816b98d1484bfcb85688f5853e44af5d69fc872539
|
7
|
+
data.tar.gz: 9fe273f88915114ec327913317000548e2fe12a3cac2548a237e13dc7fb8115eb135d329bf1375278414e4b21522faf2de066a5b924ed6152fe63b6a7c7a1103
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/ruby-macrodroid.rb
CHANGED
@@ -29,82 +29,6 @@
|
|
29
29
|
# GeofenceMap
|
30
30
|
#
|
31
31
|
#
|
32
|
-
# ## Object class
|
33
|
-
#
|
34
|
-
# MacroObject
|
35
|
-
#
|
36
|
-
#
|
37
|
-
# ## Trigger classes
|
38
|
-
#
|
39
|
-
# Trigger WebHookTrigger WifiConnectionTrigger
|
40
|
-
# ApplicationInstalledRemovedTrigger ApplicationLaunchedTrigger
|
41
|
-
# BatteryLevelTrigger BatteryTemperatureTrigger PowerButtonToggleTrigger
|
42
|
-
# ExternalPowerTrigger CallActiveTrigger IncomingCallTrigger
|
43
|
-
# OutgoingCallTrigger CallEndedTrigger CallMissedTrigger IncomingSMSTrigger
|
44
|
-
# WebHookTrigger WifiConnectionTrigger BluetoothTrigger HeadphonesTrigger
|
45
|
-
# SignalOnOffTrigger UsbDeviceConnectionTrigger WifiSSIDTrigger
|
46
|
-
# CalendarTrigger TimerTrigger StopwatchTrigger DayTrigger
|
47
|
-
# RegularIntervalTrigger DeviceEventsTrigger AirplaneModeTrigger
|
48
|
-
# AutoSyncChangeTrigger DayDreamTrigger DockTrigger FailedLoginTrigger
|
49
|
-
# GPSEnabledTrigger MusicPlayingTrigger DeviceUnlockedTrigger
|
50
|
-
# AutoRotateChangeTrigger ClipboardChangeTrigger BootTrigger
|
51
|
-
# IntentReceivedTrigger NotificationTrigger ScreenOnOffTrigger
|
52
|
-
# SilentModeTrigger WeatherTrigger GeofenceTrigger SunriseSunsetTrigger
|
53
|
-
# SensorsTrigger ActivityRecognitionTrigger ProximityTrigger
|
54
|
-
# ShakeDeviceTrigger FlipDeviceTrigger OrientationTrigger
|
55
|
-
# FloatingButtonTrigger ShortcutTrigger VolumeButtonTrigger
|
56
|
-
# MediaButtonPressedTrigger SwipeTrigger
|
57
|
-
#
|
58
|
-
#
|
59
|
-
# ## Action classes
|
60
|
-
#
|
61
|
-
# Action LocationAction ShareLocationAction ApplicationAction
|
62
|
-
# LaunchActivityAction KillBackgroundAppAction OpenWebPageAction CameraAction
|
63
|
-
# UploadPhotoAction TakePictureAction ConnectivityAction SetWifiAction
|
64
|
-
# SetBluetoothAction SetBluetoothAction SendIntentAction DateTimeAction
|
65
|
-
# SetAlarmClockAction StopWatchAction SayTimeAction DeviceAction
|
66
|
-
# AndroidShortcutsAction ClipboardAction PressBackAction SpeakTextAction
|
67
|
-
# UIInteractionAction VoiceSearchAction DeviceSettingsAction
|
68
|
-
# ExpandCollapseStatusBarAction LaunchHomeScreenAction CameraFlashLightAction
|
69
|
-
# VibrateAction SetAutoRotateAction DayDreamAction SetKeyboardAction
|
70
|
-
# SetKeyguardAction CarModeAction ChangeKeyboardAction SetWallpaperAction
|
71
|
-
# FileAction OpenFileAction LocationAction ForceLocationUpdateAction
|
72
|
-
# ShareLocationAction SetLocationUpdateRateAction LoggingAction
|
73
|
-
# AddCalendarEntryAction LogAction ClearLogAction MediaAction
|
74
|
-
# RecordMicrophoneAction PlaySoundAction MessagingAction SendEmailAction
|
75
|
-
# SendSMSAction UDPCommandAction NotificationsAction ClearNotificationsAction
|
76
|
-
# MessageDialogAction AllowLEDNotificationLightAction
|
77
|
-
# SetNotificationSoundAction SetNotificationSoundAction
|
78
|
-
# SetNotificationSoundAction NotificationAction ToastAction PhoneAction
|
79
|
-
# AnswerCallAction ClearCallLogAction OpenCallLogAction RejectCallAction
|
80
|
-
# MakeCallAction SetRingtoneAction ScreenAction SetBrightnessAction
|
81
|
-
# ForceScreenRotationAction ScreenOnAction DimScreenAction KeepAwakeAction
|
82
|
-
# SetScreenTimeoutAction VolumeAction SilentModeVibrateOffAction
|
83
|
-
# SetVibrateAction VolumeIncrementDecrementAction SpeakerPhoneAction
|
84
|
-
# SetVolumeAction
|
85
|
-
#
|
86
|
-
#
|
87
|
-
# ## Constraint classes
|
88
|
-
#
|
89
|
-
# Constraint TimeOfDayConstraint BatteryLevelConstraint
|
90
|
-
# BatterySaverStateConstraint BatteryTemperatureConstraint
|
91
|
-
# ExternalPowerConstraint BluetoothConstraint GPSEnabledConstraint
|
92
|
-
# LocationModeConstraint SignalOnOffConstraint WifiConstraint
|
93
|
-
# CellTowerConstraint IsRoamingConstraint DataOnOffConstraint
|
94
|
-
# WifiHotSpotConstraint CalendarConstraint DayOfWeekConstraint
|
95
|
-
# TimeOfDayConstraint DayOfMonthConstraint MonthOfYearConstraint
|
96
|
-
# SunsetSunriseConstraint AirplaneModeConstraint AutoRotateConstraint
|
97
|
-
# DeviceLockedConstraint RoamingOnOffConstraint TimeSinceBootConstraint
|
98
|
-
# AutoSyncConstraint NFCStateConstraint IsRootedConstraint VpnConstraint
|
99
|
-
# MacroEnabledConstraint ModeConstraint TriggerThatInvokedConstraint
|
100
|
-
# LastRunTimeConstraint HeadphonesConnectionConstraint MusicActiveConstraint
|
101
|
-
# NotificationPresentConstraint PriorityModeConstraint
|
102
|
-
# NotificationVolumeConstraint InCallConstraint PhoneRingingConstraint
|
103
|
-
# BrightnessConstraint VolumeConstraint SpeakerPhoneConstraint
|
104
|
-
# DarkThemeConstraint ScreenOnOffConstraint VolumeLevelConstraint
|
105
|
-
# FaceUpDownConstraint LightLevelConstraint DeviceOrientationConstraint
|
106
|
-
# ProximitySensorConstraint
|
107
|
-
|
108
32
|
|
109
33
|
|
110
34
|
require 'yaml'
|
@@ -116,7 +40,10 @@ require 'geocoder'
|
|
116
40
|
require 'subunit'
|
117
41
|
require 'rxfhelper'
|
118
42
|
require 'chronic_cron'
|
119
|
-
|
43
|
+
require 'ruby-macrodroid/base'
|
44
|
+
require 'ruby-macrodroid/triggers'
|
45
|
+
require 'ruby-macrodroid/actions'
|
46
|
+
require 'ruby-macrodroid/constraints'
|
120
47
|
|
121
48
|
MODEL =<<EOF
|
122
49
|
device
|
@@ -200,6 +127,11 @@ class TriggersNlp
|
|
200
127
|
|
201
128
|
alias find_trigger run_route
|
202
129
|
|
130
|
+
def to_s(colour: false)
|
131
|
+
'TriggersNlp ' + @h.inspect
|
132
|
+
end
|
133
|
+
|
134
|
+
alias to_summary to_s
|
203
135
|
end
|
204
136
|
|
205
137
|
class ActionsNlp
|
@@ -319,6 +251,11 @@ class ActionsNlp
|
|
319
251
|
|
320
252
|
alias find_action run_route
|
321
253
|
|
254
|
+
def to_s(colour: false)
|
255
|
+
'ActionsNlp ' + @h.inspect
|
256
|
+
end
|
257
|
+
|
258
|
+
alias to_summary to_s
|
322
259
|
end
|
323
260
|
|
324
261
|
class ConstraintsNlp
|
@@ -344,69 +281,19 @@ class ConstraintsNlp
|
|
344
281
|
|
345
282
|
end
|
346
283
|
|
347
|
-
module Params
|
348
|
-
|
349
|
-
refine Hash do
|
350
|
-
|
351
|
-
# turns keys from camelCase into snake_case
|
352
|
-
|
353
|
-
def to_snake_case(h=self)
|
354
|
-
|
355
|
-
h.inject({}) do |r, x|
|
356
|
-
|
357
|
-
key, value = x
|
358
|
-
#puts 'value: ' + value.inspect
|
359
|
-
|
360
|
-
val = if value.is_a?(Hash) then
|
361
|
-
to_snake_case(value)
|
362
|
-
elsif value.is_a?(Array) and value.first.is_a? Hash
|
363
|
-
value.map {|row| to_snake_case(row)}
|
364
|
-
else
|
365
|
-
value
|
366
|
-
end
|
367
|
-
|
368
|
-
r.merge key.to_s.sub(/^m_/,'').gsub(/[A-Z][a-z]/){|x| '_' +
|
369
|
-
x.downcase}.gsub(/[a-z][A-Z]/){|x| x[0] + '_' + x[1].downcase}\
|
370
|
-
.downcase.to_sym => val
|
371
|
-
|
372
|
-
end
|
373
|
-
end
|
374
|
-
|
375
|
-
# turns keys from snake_case to CamelCase
|
376
|
-
def to_camel_case(h=self)
|
377
|
-
|
378
|
-
h.inject({}) do |r,x|
|
379
|
-
|
380
|
-
key, value = x
|
381
|
-
|
382
|
-
val = if value.is_a?(Hash) then
|
383
|
-
to_camel_case(value)
|
384
|
-
elsif value.is_a?(Array) and value.first.is_a? Hash
|
385
|
-
value.map {|row| to_camel_case(row)}
|
386
|
-
else
|
387
|
-
value
|
388
|
-
end
|
389
|
-
|
390
|
-
r.merge({key.to_s.gsub(/(?<!^m)_[a-z]/){|x| x[-1].upcase} => val})
|
391
|
-
end
|
392
|
-
|
393
|
-
end
|
394
|
-
|
395
|
-
|
396
|
-
end
|
397
284
|
|
398
|
-
end
|
399
285
|
|
400
286
|
class Macro
|
401
287
|
using ColouredText
|
402
288
|
using Params
|
403
289
|
|
404
|
-
attr_reader :local_variables, :triggers, :actions, :constraints,
|
290
|
+
attr_reader :local_variables, :triggers, :actions, :constraints,
|
291
|
+
:guid, :deviceid
|
405
292
|
attr_accessor :title, :description
|
406
293
|
|
407
|
-
def initialize(name=nil, geofences:
|
294
|
+
def initialize(name=nil, geofences: nil, deviceid: nil, debug: false)
|
408
295
|
|
409
|
-
@title, @geofences, @debug = name, geofences, debug
|
296
|
+
@title, @geofences, @deviceid, @debug = name, geofences, deviceid, debug
|
410
297
|
|
411
298
|
puts 'inside Macro#initialize' if @debug
|
412
299
|
|
@@ -473,7 +360,8 @@ class Macro
|
|
473
360
|
|
474
361
|
# fetch the triggers
|
475
362
|
@triggers = h[:trigger_list].map do |trigger|
|
476
|
-
|
363
|
+
puts 'trigger: ' + trigger.inspect
|
364
|
+
#exit
|
477
365
|
object(trigger.to_snake_case)
|
478
366
|
|
479
367
|
end
|
@@ -664,16 +552,24 @@ end
|
|
664
552
|
EOF
|
665
553
|
end
|
666
554
|
|
667
|
-
def to_s()
|
555
|
+
def to_s(colour: false)
|
668
556
|
|
669
557
|
indent = 0
|
670
558
|
actions = @actions.map do |x|
|
671
559
|
|
672
|
-
s = x.to_s
|
560
|
+
s = x.to_s(colour: colour)
|
561
|
+
if s.lines.length > 1 then
|
562
|
+
lines = s.lines
|
563
|
+
s = lines[0] + lines[1..-1].map {|x| x.prepend (' ' * indent) }.join
|
564
|
+
end
|
673
565
|
|
674
566
|
r = if indent <= 0 then
|
675
567
|
|
676
|
-
|
568
|
+
if colour then
|
569
|
+
"a".bg_blue.gray.bold + ": %s" % s
|
570
|
+
else
|
571
|
+
"a: %s" % s
|
572
|
+
end
|
677
573
|
|
678
574
|
elsif indent > 0
|
679
575
|
|
@@ -689,8 +585,15 @@ EOF
|
|
689
585
|
end
|
690
586
|
|
691
587
|
if s =~ /^If/i then
|
588
|
+
|
692
589
|
if indent < 1 then
|
693
|
-
|
590
|
+
|
591
|
+
r = if colour then
|
592
|
+
"a".bg_blue.gray.bold + ":\n %s" % s
|
593
|
+
else
|
594
|
+
"a:\n %s" % s
|
595
|
+
end
|
596
|
+
|
694
597
|
indent += 1
|
695
598
|
else
|
696
599
|
r = (' ' * indent) + "%s" % s
|
@@ -704,30 +607,59 @@ EOF
|
|
704
607
|
end.join("\n")
|
705
608
|
|
706
609
|
a = [
|
707
|
-
'm: ' + @title,
|
708
|
-
@triggers.map {|x| "t:
|
610
|
+
(colour ? "m".bg_cyan.gray.bold : 'm') + ': ' + @title,
|
611
|
+
@triggers.map {|x| (colour ? "t".bg_red.gray.bold : 't') \
|
612
|
+
+ ": %s" % x}.join("\n"),
|
709
613
|
actions
|
710
614
|
]
|
711
615
|
|
712
|
-
|
616
|
+
if @constraints.any? then
|
617
|
+
a << @constraints.map do |x|
|
618
|
+
(colour ? "c".bg_green.gray.bold : 'c') + ": %s" % x
|
619
|
+
end.join("\n")
|
620
|
+
end
|
713
621
|
|
714
622
|
if @description and @description.length >= 1 then
|
715
|
-
a.insert(1,
|
623
|
+
a.insert(1, (colour ? "d".bg_gray.gray.bold : 'd') + ': ' \
|
624
|
+
+ @description.gsub(/\n/,"\n "))
|
716
625
|
end
|
717
626
|
|
718
627
|
a.join("\n") + "\n"
|
719
628
|
|
720
629
|
end
|
721
630
|
|
722
|
-
def to_summary()
|
631
|
+
def to_summary(colour: false)
|
632
|
+
|
633
|
+
if colour then
|
634
|
+
|
635
|
+
a = [
|
636
|
+
'm'.bg_cyan.gray.bold + ': ' + @title,
|
637
|
+
't'.bg_red.gray.bold + ': ' + @triggers.map \
|
638
|
+
{|x| x.to_summary(colour: false)}.join(", "),
|
639
|
+
'a'.bg_blue.gray.bold + ': ' + @actions.map \
|
640
|
+
{|x| x.to_summary(colour: false)}.join(", ")
|
641
|
+
]
|
642
|
+
|
643
|
+
if @constraints.any? then
|
644
|
+
a << 'c'.bg_green.gray.bold + ': ' + @constraints.map \
|
645
|
+
{|x| x.to_summary(colour: false)}.join(", ")
|
646
|
+
end
|
647
|
+
|
648
|
+
else
|
649
|
+
|
650
|
+
a = [
|
651
|
+
'm: ' + @title,
|
652
|
+
't: ' + @triggers.map {|x| x.to_summary(colour: false)}.join(", "),
|
653
|
+
'a: ' + @actions.map {|x| x.to_summary(colour: false)}.join(", ")
|
654
|
+
]
|
655
|
+
|
656
|
+
if @constraints.any? then
|
657
|
+
a << 'c: ' + @constraints.map \
|
658
|
+
{|x| x.to_summary(colour: false)}.join(", ")
|
659
|
+
end
|
660
|
+
end
|
723
661
|
|
724
|
-
a = [
|
725
|
-
'm: ' + @title,
|
726
|
-
't: ' + @triggers.map(&:to_summary).join(", "),
|
727
|
-
'a: ' + @actions.map(&:to_summary).join(", "),
|
728
|
-
]
|
729
662
|
|
730
|
-
a << 'c: ' + @constraints.map(&:to_summary).join(", ") if @constraints.any?
|
731
663
|
|
732
664
|
a.join("\n") + "\n"
|
733
665
|
|
@@ -741,7 +673,7 @@ EOF
|
|
741
673
|
|
742
674
|
def object(h={})
|
743
675
|
|
744
|
-
puts ('inside object h:' + h.inspect).debug if @debug
|
676
|
+
puts ('inside object h:' + h.inspect).debug if @debug
|
745
677
|
klass = Object.const_get h[:class_type]
|
746
678
|
puts klass.inspect.highlight if $debug
|
747
679
|
|
@@ -771,10 +703,14 @@ class MacroDroid
|
|
771
703
|
using Params
|
772
704
|
|
773
705
|
attr_reader :macros, :geofences, :yaml
|
706
|
+
attr_accessor :deviceid
|
707
|
+
|
708
|
+
# note: The deviceid can only be found from an existing Webhook trigger,
|
709
|
+
# generated from MacroDroid itself.
|
774
710
|
|
775
|
-
def initialize(obj=nil, debug: false)
|
711
|
+
def initialize(obj=nil, deviceid: nil, debug: false)
|
776
712
|
|
777
|
-
@debug = debug
|
713
|
+
@deviceid, @debug = deviceid, debug
|
778
714
|
|
779
715
|
@geofences = {}
|
780
716
|
|
@@ -899,21 +835,22 @@ class MacroDroid
|
|
899
835
|
@macros.map(&:to_pc).join("\n\n")
|
900
836
|
end
|
901
837
|
|
902
|
-
def to_s()
|
838
|
+
def to_s(colour: false)
|
903
839
|
|
904
840
|
lines = []
|
905
841
|
|
906
842
|
if @geofences.any? then
|
907
|
-
lines << @geofences.map {|_, value|
|
843
|
+
lines << @geofences.map {|_, value| (colour ? "g".green.bold : 'g') \
|
844
|
+
+ ': ' + value.to_s}.join("\n\n") + "\n"
|
908
845
|
end
|
909
846
|
|
910
|
-
lines << @macros.map(
|
847
|
+
lines << @macros.map {|x| x.to_s(colour: colour)}.join("\n")
|
911
848
|
lines.join("\n")
|
912
849
|
|
913
850
|
end
|
914
851
|
|
915
|
-
def to_summary()
|
916
|
-
@macros.map(
|
852
|
+
def to_summary(colour: false)
|
853
|
+
@macros.map {|x| x.to_summary(colour: colour)}.join("\n")
|
917
854
|
end
|
918
855
|
|
919
856
|
private
|
@@ -978,7 +915,8 @@ class MacroDroid
|
|
978
915
|
puts ('macro: ' + macro.inspect).debug if @debug
|
979
916
|
# puts '@geofences: ' + @geofences.inspect if @debug
|
980
917
|
|
981
|
-
m = Macro.new(geofences: @geofences.map(&:last),
|
918
|
+
m = Macro.new(geofences: @geofences.map(&:last), deviceid: @deviceid,
|
919
|
+
debug: @debug )
|
982
920
|
m.import_h(macro)
|
983
921
|
m
|
984
922
|
|
@@ -999,7 +937,8 @@ class MacroDroid
|
|
999
937
|
|
1000
938
|
@macros = doc.root.xpath('item').map do |node|
|
1001
939
|
puts ('geofences: ' + geofences.inspect).highlight if @debug
|
1002
|
-
Macro.new(geofences: geofences.map(&:last),
|
940
|
+
Macro.new(geofences: geofences.map(&:last), deviceid: @deviceid,
|
941
|
+
debug: @debug).import_xml(node)
|
1003
942
|
|
1004
943
|
end
|
1005
944
|
|
@@ -1022,7 +961,8 @@ class MacroDroid
|
|
1022
961
|
|
1023
962
|
@macros = doc.root.xpath('macro').map do |node|
|
1024
963
|
|
1025
|
-
Macro.new(geofences: @geofences.map(&:last),
|
964
|
+
Macro.new(geofences: @geofences.map(&:last), deviceid: @deviceid,
|
965
|
+
debug: @debug).import_xml(node)
|
1026
966
|
|
1027
967
|
end
|
1028
968
|
end
|
@@ -1075,7 +1015,7 @@ class GeofenceMap
|
|
1075
1015
|
|
1076
1016
|
end
|
1077
1017
|
|
1078
|
-
def to_s()
|
1018
|
+
def to_s(colour: false)
|
1079
1019
|
|
1080
1020
|
lines = []
|
1081
1021
|
coordinates = "%s, %s" % [@latitude, @longitude]
|
@@ -1089,3943 +1029,10 @@ class GeofenceMap
|
|
1089
1029
|
|
1090
1030
|
end
|
1091
1031
|
|
1092
|
-
class MacroObject
|
1093
|
-
using ColouredText
|
1094
|
-
|
1095
|
-
attr_reader :type, :siguid
|
1096
|
-
attr_accessor :options
|
1097
|
-
|
1098
|
-
def initialize(h={})
|
1099
|
-
|
1100
|
-
$env ||= {}
|
1101
|
-
|
1102
|
-
@h = {constraint_list: [], is_or_condition: false,
|
1103
|
-
is_disabled: false}.merge(h)
|
1104
|
-
@list = []
|
1105
|
-
|
1106
|
-
# fetch the class name and convert from camelCase to snake_eyes
|
1107
|
-
@type = self.class.to_s.sub(/Trigger|Action$/,'')\
|
1108
|
-
.gsub(/\B[A-Z][a-z]/){|x| '_' + x.downcase}\
|
1109
|
-
.gsub(/[a-z][A-Z]/){|x| x[0] + '_' + x[1].downcase}\
|
1110
|
-
.downcase.to_sym
|
1111
|
-
end
|
1112
|
-
|
1113
|
-
def to_h()
|
1114
|
-
|
1115
|
-
h = @h
|
1116
|
-
|
1117
|
-
h2 = h.inject({}) do |r,x|
|
1118
|
-
puts 'x: ' + x.inspect if @debug
|
1119
|
-
key, value = x
|
1120
|
-
puts 'key: ' + key.inspect if @debug
|
1121
|
-
new_key = key.to_s.gsub(/\w_\w/){|x| x[0] + x[-1].upcase}
|
1122
|
-
new_key = new_key.prepend 'm_' unless @list.include? new_key
|
1123
|
-
new_key = 'm_SIGUID' if new_key == 'm_siguid'
|
1124
|
-
r.merge(new_key => value)
|
1125
|
-
end
|
1126
|
-
|
1127
|
-
h2.merge('m_classType' => self.class.to_s)
|
1128
|
-
|
1129
|
-
end
|
1130
|
-
|
1131
|
-
def siguid()
|
1132
|
-
@h[:siguid]
|
1133
|
-
end
|
1134
|
-
|
1135
|
-
def to_s()
|
1136
|
-
"#<%s %s>" % [self.class, @h.inspect]
|
1137
|
-
end
|
1138
|
-
|
1139
|
-
alias to_summary to_s
|
1140
|
-
|
1141
|
-
protected
|
1142
|
-
|
1143
|
-
def filter(options, h)
|
1144
|
-
|
1145
|
-
(h.keys - options.keys).each {|key| h.delete key }
|
1146
|
-
return h
|
1147
|
-
|
1148
|
-
end
|
1149
|
-
|
1150
|
-
def uuid()
|
1151
|
-
UUID.new.generate
|
1152
|
-
end
|
1153
|
-
|
1154
|
-
def object(h={})
|
1155
|
-
|
1156
|
-
puts ('inside object h:' + h.inspect).debug if @debug
|
1157
|
-
klass = Object.const_get h[:class_type]
|
1158
|
-
puts klass.inspect.highlight if $debug
|
1159
|
-
|
1160
|
-
klass.new h
|
1161
|
-
|
1162
|
-
end
|
1163
|
-
|
1164
|
-
end
|
1165
|
-
|
1166
|
-
class Trigger < MacroObject
|
1167
|
-
using Params
|
1168
|
-
|
1169
|
-
attr_reader :constraints
|
1170
|
-
|
1171
|
-
def initialize(h={})
|
1172
|
-
super({fakeIcon: 0}.merge(h))
|
1173
|
-
@list << 'fakeIcon'
|
1174
|
-
|
1175
|
-
# fetch the constraints
|
1176
|
-
@constraints = @h[:constraint_list].map do |constraint|
|
1177
|
-
object(constraint.to_snake_case)
|
1178
|
-
end
|
1179
|
-
|
1180
|
-
end
|
1181
|
-
|
1182
|
-
def match?(detail={}, model=nil)
|
1183
|
-
|
1184
|
-
# only match where the key exists in the trigger object
|
1185
|
-
detail.select {|k,v| @h.include? k }.all? {|key,value| @h[key] == value}
|
1186
|
-
|
1187
|
-
end
|
1188
|
-
|
1189
|
-
end
|
1190
|
-
|
1191
|
-
|
1192
|
-
# Category: Applications
|
1193
|
-
#
|
1194
|
-
class WebHookTrigger < Trigger
|
1195
|
-
|
1196
|
-
def initialize(h={})
|
1197
|
-
|
1198
|
-
options = {
|
1199
|
-
identifier: ''
|
1200
|
-
}
|
1201
|
-
|
1202
|
-
super(options.merge h)
|
1203
|
-
|
1204
|
-
end
|
1205
|
-
|
1206
|
-
end
|
1207
|
-
|
1208
|
-
# Category: Applications
|
1209
|
-
#
|
1210
|
-
# Also known as Wifi State Change
|
1211
|
-
#
|
1212
|
-
# wifi_state options:
|
1213
|
-
# 0 - Wifi Enabled
|
1214
|
-
# 1 - Wifi Disabled
|
1215
|
-
# 2 - Connected to network
|
1216
|
-
# ssid_list options:
|
1217
|
-
# ["Any Network"]
|
1218
|
-
# ["some Wifi SSID"] - 1 or more SSID can be supplied
|
1219
|
-
# 3 - Disconnected from network
|
1220
|
-
# ssid_list options:
|
1221
|
-
# ["Any Network"]
|
1222
|
-
# ["some Wifi SSID"] - 1 or more SSID can be supplied
|
1223
|
-
|
1224
|
-
class WifiConnectionTrigger < Trigger
|
1225
|
-
|
1226
|
-
def initialize(h={})
|
1227
|
-
|
1228
|
-
options = {
|
1229
|
-
ssid_list: [""],
|
1230
|
-
wifi_state: 2
|
1231
|
-
}
|
1232
|
-
|
1233
|
-
super(options.merge h)
|
1234
|
-
|
1235
|
-
end
|
1236
|
-
|
1237
|
-
end
|
1238
|
-
|
1239
|
-
# Category: Applications
|
1240
|
-
#
|
1241
|
-
class ApplicationInstalledRemovedTrigger < Trigger
|
1242
|
-
|
1243
|
-
def initialize(h={})
|
1244
|
-
|
1245
|
-
options = {
|
1246
|
-
application_name_list: [],
|
1247
|
-
package_name_list: [],
|
1248
|
-
installed: true,
|
1249
|
-
application_option: 0,
|
1250
|
-
updated: false
|
1251
|
-
}
|
1252
|
-
|
1253
|
-
super(options.merge h)
|
1254
|
-
|
1255
|
-
end
|
1256
|
-
|
1257
|
-
end
|
1258
|
-
|
1259
|
-
# Category: Applications
|
1260
|
-
#
|
1261
|
-
class ApplicationLaunchedTrigger < Trigger
|
1262
|
-
|
1263
|
-
def initialize(h={})
|
1264
|
-
|
1265
|
-
options = {
|
1266
|
-
application_name_list: ["Chrome"],
|
1267
|
-
package_name_list: ["com.android.chrome"],
|
1268
|
-
launched: true
|
1269
|
-
}
|
1270
|
-
|
1271
|
-
super(options.merge h)
|
1272
|
-
|
1273
|
-
end
|
1274
|
-
|
1275
|
-
end
|
1276
|
-
|
1277
|
-
# Category: Battery/Power
|
1278
|
-
#
|
1279
|
-
class BatteryLevelTrigger < Trigger
|
1280
|
-
|
1281
|
-
def initialize(h={})
|
1282
|
-
|
1283
|
-
options = {
|
1284
|
-
battery_level: 50,
|
1285
|
-
decreases_to: true,
|
1286
|
-
option: 0
|
1287
|
-
}
|
1288
|
-
|
1289
|
-
super(options.merge h)
|
1290
|
-
|
1291
|
-
end
|
1292
|
-
|
1293
|
-
def to_s()
|
1294
|
-
operator = @h[:decreases_to] ? '<=' : '>='
|
1295
|
-
"Battery %s %s%%" % [operator, @h[:battery_level]]
|
1296
|
-
end
|
1297
|
-
|
1298
|
-
end
|
1299
|
-
|
1300
|
-
# Category: Battery/Power
|
1301
|
-
#
|
1302
|
-
class BatteryTemperatureTrigger < Trigger
|
1303
|
-
|
1304
|
-
def initialize(h={})
|
1305
|
-
|
1306
|
-
options = {
|
1307
|
-
decreases_to: true,
|
1308
|
-
option: 0,
|
1309
|
-
temperature: 30
|
1310
|
-
}
|
1311
|
-
|
1312
|
-
super(options.merge h)
|
1313
|
-
|
1314
|
-
end
|
1315
|
-
|
1316
|
-
end
|
1317
|
-
|
1318
|
-
# Category: Battery/Power
|
1319
|
-
#
|
1320
|
-
class PowerButtonToggleTrigger < Trigger
|
1321
|
-
|
1322
|
-
def initialize(h={})
|
1323
|
-
|
1324
|
-
options = {
|
1325
|
-
num_toggles: 3
|
1326
|
-
}
|
1327
|
-
|
1328
|
-
super(options.merge h)
|
1329
|
-
|
1330
|
-
end
|
1331
|
-
|
1332
|
-
end
|
1333
|
-
|
1334
|
-
|
1335
|
-
# Category: Battery/Power
|
1336
|
-
#
|
1337
|
-
class ExternalPowerTrigger < Trigger
|
1338
|
-
|
1339
|
-
def initialize(h={})
|
1340
|
-
|
1341
|
-
options = {
|
1342
|
-
power_connected_options: [true, true, true],
|
1343
|
-
has_set_usb_option: true,
|
1344
|
-
power_connected: true,
|
1345
|
-
has_set_new_power_connected_options: true
|
1346
|
-
}
|
1347
|
-
|
1348
|
-
super(options.merge h)
|
1349
|
-
|
1350
|
-
end
|
1351
|
-
|
1352
|
-
def to_s()
|
1353
|
-
|
1354
|
-
return 'Power Disconnected' unless @h[:power_connected]
|
1355
|
-
|
1356
|
-
status = 'Power Connectd'
|
1357
|
-
options = if @h[:power_connected_options].all? then
|
1358
|
-
'Any'
|
1359
|
-
else
|
1360
|
-
|
1361
|
-
a = ['Wired (Fast Charge)', 'Wireless', 'Wired (Slow Charge)']
|
1362
|
-
@h[:power_connected_options].map.with_index {|x,i| x ? i : nil}\
|
1363
|
-
.compact.map {|i| a[i] }.join(' + ')
|
1364
|
-
|
1365
|
-
end
|
1366
|
-
|
1367
|
-
"%s: %s" % [status, options]
|
1368
|
-
end
|
1369
|
-
|
1370
|
-
end
|
1371
|
-
|
1372
|
-
# Category: Call/SMS
|
1373
|
-
#
|
1374
|
-
class CallActiveTrigger < Trigger
|
1375
|
-
|
1376
|
-
def initialize(h={})
|
1377
|
-
|
1378
|
-
options = {
|
1379
|
-
contact_list: [{:m_id=>"-2", :m_lookupKey=>"-2", :m_name=>"[Any Number]"}],
|
1380
|
-
secondary_class_type: 'CallActiveTrigger',
|
1381
|
-
signal_on: true
|
1382
|
-
}
|
1383
|
-
|
1384
|
-
super(options.merge h)
|
1385
|
-
|
1386
|
-
end
|
1387
|
-
|
1388
|
-
end
|
1389
|
-
|
1390
|
-
# Category: Call/SMS
|
1391
|
-
#
|
1392
|
-
class IncomingCallTrigger < Trigger
|
1393
|
-
|
1394
|
-
def initialize(h={})
|
1395
|
-
|
1396
|
-
options = {
|
1397
|
-
incoming_call_from_list: [{:m_id=>"-2", :m_lookupKey=>"-2", :m_name=>"[Any Number]"}],
|
1398
|
-
group_id_list: [],
|
1399
|
-
group_name_list: [],
|
1400
|
-
option: 0,
|
1401
|
-
phone_number_exclude: false
|
1402
|
-
}
|
1403
|
-
|
1404
|
-
super(options.merge h)
|
1405
|
-
|
1406
|
-
end
|
1407
|
-
|
1408
|
-
end
|
1409
|
-
|
1410
|
-
# Category: Call/SMS
|
1411
|
-
#
|
1412
|
-
class OutgoingCallTrigger < Trigger
|
1413
|
-
|
1414
|
-
def initialize(h={})
|
1415
|
-
|
1416
|
-
options = {
|
1417
|
-
outgoing_call_to_list: [{:m_id=>"-2", :m_lookupKey=>"-2", :m_name=>"[Any Number]"}],
|
1418
|
-
group_id_list: [],
|
1419
|
-
group_name_list: [],
|
1420
|
-
option: 0,
|
1421
|
-
phone_number_exclude: false
|
1422
|
-
}
|
1423
|
-
|
1424
|
-
super(options.merge h)
|
1425
|
-
|
1426
|
-
end
|
1427
|
-
|
1428
|
-
end
|
1429
|
-
|
1430
|
-
# Category: Call/SMS
|
1431
|
-
#
|
1432
|
-
class CallEndedTrigger < Trigger
|
1433
|
-
|
1434
|
-
def initialize(h={})
|
1435
|
-
|
1436
|
-
options = {
|
1437
|
-
contact_list: [{:m_id=>"-2", :m_lookupKey=>"-2", :m_name=>"[Any Number]"}],
|
1438
|
-
group_id_list: [],
|
1439
|
-
group_name_list: [],
|
1440
|
-
option: 0,
|
1441
|
-
phone_number_exclude: false
|
1442
|
-
}
|
1443
|
-
|
1444
|
-
super(options.merge h)
|
1445
|
-
|
1446
|
-
end
|
1447
|
-
|
1448
|
-
end
|
1449
|
-
|
1450
|
-
# Category: Call/SMS
|
1451
|
-
#
|
1452
|
-
class CallMissedTrigger < Trigger
|
1453
1032
|
|
1454
|
-
def initialize(h={})
|
1455
1033
|
|
1456
|
-
options = {
|
1457
|
-
contact_list: [{:m_id=>"-2", :m_lookupKey=>"-2", :m_name=>"[Any Number]"}]
|
1458
|
-
}
|
1459
1034
|
|
1460
|
-
super(options.merge h)
|
1461
1035
|
|
1462
|
-
end
|
1463
|
-
|
1464
|
-
end
|
1465
|
-
|
1466
|
-
# Category: Call/SMS
|
1467
|
-
#
|
1468
|
-
class IncomingSMSTrigger < Trigger
|
1469
|
-
|
1470
|
-
def initialize(h={})
|
1471
|
-
|
1472
|
-
options = {
|
1473
|
-
sms_from_list: [{:m_id=>"-2", :m_lookupKey=>"-2", :m_name=>"[Any Number]"}],
|
1474
|
-
group_id_list: [],
|
1475
|
-
group_name_list: [],
|
1476
|
-
sms_content: '',
|
1477
|
-
option: 0,
|
1478
|
-
excludes: false,
|
1479
|
-
exact_match: false,
|
1480
|
-
enable_regex: false,
|
1481
|
-
sms_number_exclude: false
|
1482
|
-
}
|
1483
|
-
|
1484
|
-
super(options.merge h)
|
1485
|
-
|
1486
|
-
end
|
1487
|
-
|
1488
|
-
end
|
1489
|
-
|
1490
|
-
# Category: Connectivity
|
1491
|
-
#
|
1492
|
-
class WebHookTrigger < Trigger
|
1493
|
-
|
1494
|
-
def initialize(h={})
|
1495
|
-
|
1496
|
-
options = {
|
1497
|
-
identifier: ''
|
1498
|
-
}
|
1499
|
-
|
1500
|
-
super(options.merge h)
|
1501
|
-
|
1502
|
-
end
|
1503
|
-
|
1504
|
-
end
|
1505
|
-
|
1506
|
-
# Category: Connectivity
|
1507
|
-
#
|
1508
|
-
class WifiConnectionTrigger < Trigger
|
1509
|
-
|
1510
|
-
def initialize(h={})
|
1511
|
-
|
1512
|
-
options = {
|
1513
|
-
ssid_list: [],
|
1514
|
-
wifi_state: 0
|
1515
|
-
}
|
1516
|
-
|
1517
|
-
super(options.merge h)
|
1518
|
-
|
1519
|
-
end
|
1520
|
-
|
1521
|
-
end
|
1522
|
-
|
1523
|
-
# Category: Connectivity
|
1524
|
-
#
|
1525
|
-
class BluetoothTrigger < Trigger
|
1526
|
-
|
1527
|
-
def initialize(h={})
|
1528
|
-
|
1529
|
-
options = {
|
1530
|
-
device_name: 'Any Device',
|
1531
|
-
bt_state: 0,
|
1532
|
-
any_device: false
|
1533
|
-
}
|
1534
|
-
|
1535
|
-
super(options.merge h)
|
1536
|
-
|
1537
|
-
end
|
1538
|
-
|
1539
|
-
end
|
1540
|
-
|
1541
|
-
# Category: Connectivity
|
1542
|
-
#
|
1543
|
-
class HeadphonesTrigger < Trigger
|
1544
|
-
|
1545
|
-
def initialize(h={})
|
1546
|
-
|
1547
|
-
options = {
|
1548
|
-
headphones_connected: true,
|
1549
|
-
mic_option: 0
|
1550
|
-
}
|
1551
|
-
|
1552
|
-
super(options.merge h)
|
1553
|
-
|
1554
|
-
end
|
1555
|
-
|
1556
|
-
end
|
1557
|
-
|
1558
|
-
# Category: Connectivity
|
1559
|
-
#
|
1560
|
-
class SignalOnOffTrigger < Trigger
|
1561
|
-
|
1562
|
-
def initialize(h={})
|
1563
|
-
|
1564
|
-
options = {
|
1565
|
-
signal_on: true
|
1566
|
-
}
|
1567
|
-
|
1568
|
-
super(options.merge h)
|
1569
|
-
|
1570
|
-
end
|
1571
|
-
|
1572
|
-
end
|
1573
|
-
|
1574
|
-
# Category: Connectivity
|
1575
|
-
#
|
1576
|
-
class UsbDeviceConnectionTrigger < Trigger
|
1577
|
-
|
1578
|
-
def initialize(h={})
|
1579
|
-
|
1580
|
-
options = {
|
1581
|
-
option: 0
|
1582
|
-
}
|
1583
|
-
|
1584
|
-
super(options.merge h)
|
1585
|
-
|
1586
|
-
end
|
1587
|
-
|
1588
|
-
end
|
1589
|
-
|
1590
|
-
# Category: Connectivity
|
1591
|
-
#
|
1592
|
-
# Also known as Wifi SSID Transition
|
1593
|
-
#
|
1594
|
-
# options:
|
1595
|
-
# in_range: true | false
|
1596
|
-
# wifi_cell_info: {display_name: "some Wifi SSID",
|
1597
|
-
# ssid: "some Wifi SSID"} - 1 or more allowed
|
1598
|
-
#
|
1599
|
-
class WifiSSIDTrigger < Trigger
|
1600
|
-
|
1601
|
-
def initialize(h={})
|
1602
|
-
|
1603
|
-
options = {
|
1604
|
-
wifi_cell_info_list: [{:display_name=>"", :ssid=>""}],
|
1605
|
-
ssid_list: [],
|
1606
|
-
in_range: true
|
1607
|
-
}
|
1608
|
-
|
1609
|
-
super(options.merge h)
|
1610
|
-
|
1611
|
-
end
|
1612
|
-
|
1613
|
-
def to_h()
|
1614
|
-
|
1615
|
-
h = super()
|
1616
|
-
val = h[:m_inRange]
|
1617
|
-
|
1618
|
-
h[:m_InRange] = val
|
1619
|
-
h.delete :m_inRange
|
1620
|
-
|
1621
|
-
return h
|
1622
|
-
|
1623
|
-
end
|
1624
|
-
|
1625
|
-
end
|
1626
|
-
|
1627
|
-
# Category: Date/Time
|
1628
|
-
#
|
1629
|
-
class CalendarTrigger < Trigger
|
1630
|
-
|
1631
|
-
def initialize(h={})
|
1632
|
-
|
1633
|
-
options = {
|
1634
|
-
title_text: '',
|
1635
|
-
detail_text: '',
|
1636
|
-
calendar_name: 'Contacts',
|
1637
|
-
calendar_id: '3',
|
1638
|
-
availability: 0,
|
1639
|
-
check_in_advance: false,
|
1640
|
-
advance_time_seconds: 0,
|
1641
|
-
event_start: true,
|
1642
|
-
ignore_all_day: false,
|
1643
|
-
negative_advance_check: false,
|
1644
|
-
enable_regex: false
|
1645
|
-
}
|
1646
|
-
|
1647
|
-
super(options.merge h)
|
1648
|
-
|
1649
|
-
end
|
1650
|
-
|
1651
|
-
end
|
1652
|
-
|
1653
|
-
# Category: Date/Time
|
1654
|
-
#
|
1655
|
-
class TimerTrigger < Trigger
|
1656
|
-
using ColouredText
|
1657
|
-
|
1658
|
-
|
1659
|
-
def initialize(h={})
|
1660
|
-
|
1661
|
-
puts 'TimerTrigger h: ' + h.inspect if $debug
|
1662
|
-
|
1663
|
-
if h[:days] then
|
1664
|
-
|
1665
|
-
days = [false] * 7
|
1666
|
-
|
1667
|
-
h[:days].split(/, */).each do |x|
|
1668
|
-
|
1669
|
-
r = Date::DAYNAMES.grep /#{x}/i
|
1670
|
-
i = Date::DAYNAMES.index(r.first)
|
1671
|
-
days[i-1] = true
|
1672
|
-
|
1673
|
-
end
|
1674
|
-
|
1675
|
-
h[:days_of_week] = days
|
1676
|
-
|
1677
|
-
end
|
1678
|
-
|
1679
|
-
if h[:time] then
|
1680
|
-
|
1681
|
-
t = Time.parse(h[:time])
|
1682
|
-
h[:hour], h[:minute] = t.hour, t.min
|
1683
|
-
|
1684
|
-
end
|
1685
|
-
|
1686
|
-
#puts ('h: ' + h.inspect).debug
|
1687
|
-
|
1688
|
-
options = {
|
1689
|
-
alarm_id: uuid(),
|
1690
|
-
days_of_week: [false, false, false, false, false, false, false],
|
1691
|
-
minute: 10,
|
1692
|
-
hour: 7,
|
1693
|
-
use_alarm: false
|
1694
|
-
}
|
1695
|
-
|
1696
|
-
super(options.merge filter(options, h))
|
1697
|
-
|
1698
|
-
end
|
1699
|
-
|
1700
|
-
def match?(detail={time: $env[:time]}, model=nil)
|
1701
|
-
|
1702
|
-
time() == detail[:time]
|
1703
|
-
|
1704
|
-
end
|
1705
|
-
|
1706
|
-
# sets the environmental conditions for this trigger to fire
|
1707
|
-
#
|
1708
|
-
def set_env()
|
1709
|
-
$env[:time] = time()
|
1710
|
-
end
|
1711
|
-
|
1712
|
-
def to_pc()
|
1713
|
-
"time.is? '%s'" % self.to_s.gsub(',', ' or')
|
1714
|
-
end
|
1715
|
-
|
1716
|
-
def to_s()
|
1717
|
-
|
1718
|
-
dow = @h[:days_of_week]
|
1719
|
-
|
1720
|
-
wd = Date::ABBR_DAYNAMES
|
1721
|
-
a = (wd[1..-1] << wd.first)
|
1722
|
-
|
1723
|
-
a2 = dow.map.with_index.to_a
|
1724
|
-
start = a2.find {|x,i| x}.last
|
1725
|
-
r = a2[start..-1].take_while {|x,i| x == true}
|
1726
|
-
r2 = a2[start..-1].select {|x,i| x}
|
1727
|
-
|
1728
|
-
days = if r == r2 then
|
1729
|
-
|
1730
|
-
x1, x2 = a2[start].last, a2[r.length-1].last
|
1731
|
-
|
1732
|
-
if (x2 - x1) >= 2 then
|
1733
|
-
"%s-%s" % [a[x1],a[x2]]
|
1734
|
-
else
|
1735
|
-
a.zip(dow).select {|_,b| b}.map(&:first).join(', ')
|
1736
|
-
end
|
1737
|
-
else
|
1738
|
-
a.zip(dow).select {|_,b| b}.map(&:first).join(', ')
|
1739
|
-
end
|
1740
|
-
|
1741
|
-
time = Time.parse("%s:%s" % [@h[:hour], @h[:minute]]).strftime("%-H:%M%P")
|
1742
|
-
|
1743
|
-
"%s %s" % [time, days]
|
1744
|
-
end
|
1745
|
-
|
1746
|
-
private
|
1747
|
-
|
1748
|
-
def time()
|
1749
|
-
|
1750
|
-
a = @h[:days_of_week].clone
|
1751
|
-
a.unshift a.pop
|
1752
|
-
|
1753
|
-
dow = a.map.with_index {|x, i| x ? i : nil }.compact.join(',')
|
1754
|
-
s = "%s %s * * %s" % [@h[:minute], @h[:hour], dow]
|
1755
|
-
recent_time = ($env && $env[:time]) ? $env[:time] : Time.now
|
1756
|
-
ChronicCron.new(s, recent_time).to_time
|
1757
|
-
|
1758
|
-
end
|
1759
|
-
|
1760
|
-
end
|
1761
|
-
|
1762
|
-
# Category: Date/Time
|
1763
|
-
#
|
1764
|
-
class StopwatchTrigger < Trigger
|
1765
|
-
|
1766
|
-
def initialize(h={})
|
1767
|
-
|
1768
|
-
options = {
|
1769
|
-
stopwatch_name: 'timer1',
|
1770
|
-
seconds: 240
|
1771
|
-
}
|
1772
|
-
|
1773
|
-
super(options.merge h)
|
1774
|
-
|
1775
|
-
end
|
1776
|
-
|
1777
|
-
end
|
1778
|
-
|
1779
|
-
# Category: Date/Time
|
1780
|
-
#
|
1781
|
-
# Also known as Day of Week/Month
|
1782
|
-
#
|
1783
|
-
# month_of_year equal to 0 means it occurs every month
|
1784
|
-
# day_of_week starts with a Monday (value is 0)
|
1785
|
-
#
|
1786
|
-
class DayTrigger < Trigger
|
1787
|
-
|
1788
|
-
def initialize(h={})
|
1789
|
-
|
1790
|
-
options = {
|
1791
|
-
alarm_id: uuid(),
|
1792
|
-
hour: 9,
|
1793
|
-
minute: 0,
|
1794
|
-
month_of_year: 0,
|
1795
|
-
option: 0,
|
1796
|
-
day_of_week: 2,
|
1797
|
-
day_of_month: 0,
|
1798
|
-
use_alarm: false
|
1799
|
-
}
|
1800
|
-
|
1801
|
-
super(options.merge h)
|
1802
|
-
|
1803
|
-
end
|
1804
|
-
|
1805
|
-
end
|
1806
|
-
|
1807
|
-
# Category: Date/Time
|
1808
|
-
#
|
1809
|
-
# Regular Interval
|
1810
|
-
#
|
1811
|
-
class RegularIntervalTrigger < Trigger
|
1812
|
-
|
1813
|
-
def initialize(h={})
|
1814
|
-
|
1815
|
-
options = {
|
1816
|
-
ignore_reference_start_time: false,
|
1817
|
-
minutes: 0,
|
1818
|
-
seconds: 7200,
|
1819
|
-
start_hour: 9,
|
1820
|
-
start_minute: 10,
|
1821
|
-
use_alarm: false
|
1822
|
-
}
|
1823
|
-
|
1824
|
-
super(options.merge h)
|
1825
|
-
|
1826
|
-
end
|
1827
|
-
|
1828
|
-
end
|
1829
|
-
|
1830
|
-
class DeviceEventsTrigger < Trigger
|
1831
|
-
|
1832
|
-
def initialize(h={})
|
1833
|
-
super(h)
|
1834
|
-
@group = 'device_events'
|
1835
|
-
end
|
1836
|
-
|
1837
|
-
end
|
1838
|
-
|
1839
|
-
# Category: Device Events
|
1840
|
-
#
|
1841
|
-
# Airplane Mode Changed
|
1842
|
-
#
|
1843
|
-
# options:
|
1844
|
-
# Airplane Mode Enabled
|
1845
|
-
# Airplane Mode Disabled
|
1846
|
-
#
|
1847
|
-
# shorthand example:
|
1848
|
-
# airplanemode: enabled
|
1849
|
-
#
|
1850
|
-
class AirplaneModeTrigger < DeviceEventsTrigger
|
1851
|
-
|
1852
|
-
def initialize(h={})
|
1853
|
-
|
1854
|
-
options = {
|
1855
|
-
airplane_mode_enabled: true
|
1856
|
-
}
|
1857
|
-
|
1858
|
-
super(options.merge h)
|
1859
|
-
|
1860
|
-
end
|
1861
|
-
|
1862
|
-
end
|
1863
|
-
|
1864
|
-
# Category: Device Events
|
1865
|
-
#
|
1866
|
-
class AutoSyncChangeTrigger < DeviceEventsTrigger
|
1867
|
-
|
1868
|
-
def initialize(h={})
|
1869
|
-
|
1870
|
-
options = {
|
1871
|
-
option: 0
|
1872
|
-
}
|
1873
|
-
|
1874
|
-
super(options.merge h)
|
1875
|
-
|
1876
|
-
end
|
1877
|
-
|
1878
|
-
end
|
1879
|
-
|
1880
|
-
# Category: Device Events
|
1881
|
-
#
|
1882
|
-
class DayDreamTrigger < DeviceEventsTrigger
|
1883
|
-
|
1884
|
-
def initialize(h={})
|
1885
|
-
|
1886
|
-
options = {
|
1887
|
-
day_dream_enabled: true
|
1888
|
-
}
|
1889
|
-
|
1890
|
-
super(options.merge h)
|
1891
|
-
|
1892
|
-
end
|
1893
|
-
|
1894
|
-
end
|
1895
|
-
|
1896
|
-
# Category: Device Events
|
1897
|
-
#
|
1898
|
-
class DockTrigger < DeviceEventsTrigger
|
1899
|
-
|
1900
|
-
def initialize(h={})
|
1901
|
-
|
1902
|
-
options = {
|
1903
|
-
dock_type: 0
|
1904
|
-
}
|
1905
|
-
|
1906
|
-
super(options.merge h)
|
1907
|
-
|
1908
|
-
end
|
1909
|
-
|
1910
|
-
end
|
1911
|
-
|
1912
|
-
# Category: Device Events
|
1913
|
-
#
|
1914
|
-
class FailedLoginTrigger < DeviceEventsTrigger
|
1915
|
-
|
1916
|
-
def initialize(h={})
|
1917
|
-
|
1918
|
-
options = {
|
1919
|
-
num_failures: 1
|
1920
|
-
}
|
1921
|
-
|
1922
|
-
super(options.merge h)
|
1923
|
-
|
1924
|
-
end
|
1925
|
-
|
1926
|
-
def to_pc()
|
1927
|
-
'failed_login?'
|
1928
|
-
end
|
1929
|
-
|
1930
|
-
def to_s()
|
1931
|
-
'Failed Login Attempt'
|
1932
|
-
end
|
1933
|
-
end
|
1934
|
-
|
1935
|
-
# Category: Device Events
|
1936
|
-
#
|
1937
|
-
class GPSEnabledTrigger < DeviceEventsTrigger
|
1938
|
-
|
1939
|
-
def initialize(h={})
|
1940
|
-
|
1941
|
-
options = {
|
1942
|
-
gps_mode_enabled: true
|
1943
|
-
}
|
1944
|
-
|
1945
|
-
super(options.merge h)
|
1946
|
-
|
1947
|
-
end
|
1948
|
-
|
1949
|
-
end
|
1950
|
-
|
1951
|
-
# Category: Device Events
|
1952
|
-
#
|
1953
|
-
class MusicPlayingTrigger < DeviceEventsTrigger
|
1954
|
-
|
1955
|
-
def initialize(h={})
|
1956
|
-
|
1957
|
-
options = {
|
1958
|
-
option: 0
|
1959
|
-
}
|
1960
|
-
|
1961
|
-
super(options.merge h)
|
1962
|
-
|
1963
|
-
end
|
1964
|
-
|
1965
|
-
end
|
1966
|
-
|
1967
|
-
|
1968
|
-
# Category: Device Events
|
1969
|
-
#
|
1970
|
-
class DeviceUnlockedTrigger < DeviceEventsTrigger
|
1971
|
-
|
1972
|
-
def initialize(h={})
|
1973
|
-
|
1974
|
-
options = {
|
1975
|
-
}
|
1976
|
-
|
1977
|
-
super(options.merge h)
|
1978
|
-
|
1979
|
-
end
|
1980
|
-
|
1981
|
-
def to_s()
|
1982
|
-
'Screen Unlocked'
|
1983
|
-
end
|
1984
|
-
|
1985
|
-
end
|
1986
|
-
|
1987
|
-
# Category: Device Events
|
1988
|
-
#
|
1989
|
-
class AutoRotateChangeTrigger < DeviceEventsTrigger
|
1990
|
-
|
1991
|
-
def initialize(h={})
|
1992
|
-
|
1993
|
-
options = {
|
1994
|
-
option: 0
|
1995
|
-
}
|
1996
|
-
|
1997
|
-
super(options.merge h)
|
1998
|
-
|
1999
|
-
end
|
2000
|
-
|
2001
|
-
end
|
2002
|
-
|
2003
|
-
# Category: Device Events
|
2004
|
-
#
|
2005
|
-
class ClipboardChangeTrigger < DeviceEventsTrigger
|
2006
|
-
|
2007
|
-
def initialize(h={})
|
2008
|
-
|
2009
|
-
options = {
|
2010
|
-
text: '',
|
2011
|
-
enable_regex: false
|
2012
|
-
}
|
2013
|
-
|
2014
|
-
super(options.merge h)
|
2015
|
-
|
2016
|
-
end
|
2017
|
-
|
2018
|
-
end
|
2019
|
-
|
2020
|
-
# Category: Device Events
|
2021
|
-
#
|
2022
|
-
class BootTrigger < DeviceEventsTrigger
|
2023
|
-
|
2024
|
-
def initialize(h={})
|
2025
|
-
|
2026
|
-
options = {
|
2027
|
-
}
|
2028
|
-
|
2029
|
-
super(options.merge h)
|
2030
|
-
|
2031
|
-
end
|
2032
|
-
|
2033
|
-
end
|
2034
|
-
|
2035
|
-
# Category: Device Events
|
2036
|
-
#
|
2037
|
-
class IntentReceivedTrigger < DeviceEventsTrigger
|
2038
|
-
|
2039
|
-
def initialize(h={})
|
2040
|
-
|
2041
|
-
options = {
|
2042
|
-
action: '',
|
2043
|
-
extra_params: [],
|
2044
|
-
extra_value_patterns: [],
|
2045
|
-
extra_variables: [],
|
2046
|
-
enable_regex: false
|
2047
|
-
}
|
2048
|
-
|
2049
|
-
super(options.merge h)
|
2050
|
-
|
2051
|
-
end
|
2052
|
-
|
2053
|
-
end
|
2054
|
-
|
2055
|
-
# Category: Device Events
|
2056
|
-
#
|
2057
|
-
class NotificationTrigger < DeviceEventsTrigger
|
2058
|
-
|
2059
|
-
def initialize(h={})
|
2060
|
-
|
2061
|
-
options = {
|
2062
|
-
text_content: '',
|
2063
|
-
package_name_list: ["Any Application"],
|
2064
|
-
application_name_list: ["Any Application"],
|
2065
|
-
exclude_apps: false,
|
2066
|
-
ignore_ongoing: true,
|
2067
|
-
option: 0,
|
2068
|
-
exact_match: false,
|
2069
|
-
excludes: false,
|
2070
|
-
sound_option: 0,
|
2071
|
-
supress_multiples: true,
|
2072
|
-
enable_regex: false
|
2073
|
-
}
|
2074
|
-
|
2075
|
-
super(options.merge h)
|
2076
|
-
|
2077
|
-
end
|
2078
|
-
|
2079
|
-
end
|
2080
|
-
|
2081
|
-
# Category: Device Events
|
2082
|
-
#
|
2083
|
-
class ScreenOnOffTrigger < DeviceEventsTrigger
|
2084
|
-
|
2085
|
-
def initialize(h={})
|
2086
|
-
|
2087
|
-
options = {
|
2088
|
-
screen_on: true
|
2089
|
-
}
|
2090
|
-
|
2091
|
-
super(options.merge h)
|
2092
|
-
|
2093
|
-
end
|
2094
|
-
|
2095
|
-
end
|
2096
|
-
|
2097
|
-
# Category: Device Events
|
2098
|
-
#
|
2099
|
-
class SilentModeTrigger < DeviceEventsTrigger
|
2100
|
-
|
2101
|
-
def initialize(h={})
|
2102
|
-
|
2103
|
-
options = {
|
2104
|
-
silent_enabled: true
|
2105
|
-
}
|
2106
|
-
|
2107
|
-
super(options.merge h)
|
2108
|
-
|
2109
|
-
end
|
2110
|
-
|
2111
|
-
end
|
2112
|
-
|
2113
|
-
# Category: Location
|
2114
|
-
#
|
2115
|
-
class WeatherTrigger < Trigger
|
2116
|
-
|
2117
|
-
def initialize(h={})
|
2118
|
-
|
2119
|
-
options = {
|
2120
|
-
humidity_above: true,
|
2121
|
-
humidity_value: 50,
|
2122
|
-
option: 4,
|
2123
|
-
temp_below: true,
|
2124
|
-
temp_celcius: true,
|
2125
|
-
temperature: 0,
|
2126
|
-
weather_condition: 0,
|
2127
|
-
wind_speed_above: true,
|
2128
|
-
wind_speed_value: 0,
|
2129
|
-
wind_speed_value_mph: 0
|
2130
|
-
}
|
2131
|
-
|
2132
|
-
super(options.merge h)
|
2133
|
-
|
2134
|
-
end
|
2135
|
-
|
2136
|
-
end
|
2137
|
-
|
2138
|
-
# Category: Location
|
2139
|
-
#
|
2140
|
-
class GeofenceTrigger < Trigger
|
2141
|
-
|
2142
|
-
def initialize( h={}, geofences: {})
|
2143
|
-
|
2144
|
-
if h[:name] then
|
2145
|
-
puts ('geofences2: ' + geofences.inspect) if $debug
|
2146
|
-
found = geofences.find {|x| x.name.downcase == h[:name].downcase}
|
2147
|
-
h[:geofence_id] = found.id if found
|
2148
|
-
|
2149
|
-
end
|
2150
|
-
|
2151
|
-
options = {
|
2152
|
-
update_rate_text: '5 Minutes',
|
2153
|
-
geofence_id: '',
|
2154
|
-
geofence_update_rate_minutes: 5,
|
2155
|
-
trigger_from_unknown: false,
|
2156
|
-
enter_area: true
|
2157
|
-
}
|
2158
|
-
|
2159
|
-
super(options.merge filter(options, h))
|
2160
|
-
@geofences = geofences
|
2161
|
-
|
2162
|
-
end
|
2163
|
-
|
2164
|
-
def to_s()
|
2165
|
-
|
2166
|
-
if $debug then
|
2167
|
-
puts ' @geofences: ' + @geofences.inspect
|
2168
|
-
puts '@h: ' + @h.inspect
|
2169
|
-
puts '@h[:geofence_id]: ' + @h[:geofence_id].inspect
|
2170
|
-
end
|
2171
|
-
|
2172
|
-
direction = @h[:enter_area] ? 'Entry' : 'Exit'
|
2173
|
-
|
2174
|
-
found = @geofences.find {|x| x.id == @h[:geofence_id]}
|
2175
|
-
puts 'found: ' + found.inspect if @debug
|
2176
|
-
label = found ? found.name : 'error: name not found'
|
2177
|
-
|
2178
|
-
"Geofence %s (%s)" % [direction, label]
|
2179
|
-
|
2180
|
-
end
|
2181
|
-
|
2182
|
-
end
|
2183
|
-
|
2184
|
-
# Category: Location
|
2185
|
-
#
|
2186
|
-
class SunriseSunsetTrigger < Trigger
|
2187
|
-
|
2188
|
-
def initialize(h={})
|
2189
|
-
|
2190
|
-
options = {
|
2191
|
-
option: 0,
|
2192
|
-
time_adjust_seconds: 0
|
2193
|
-
}
|
2194
|
-
|
2195
|
-
super(options.merge h)
|
2196
|
-
|
2197
|
-
end
|
2198
|
-
|
2199
|
-
end
|
2200
|
-
|
2201
|
-
|
2202
|
-
class SensorsTrigger < Trigger
|
2203
|
-
|
2204
|
-
def initialize(h={})
|
2205
|
-
super(h)
|
2206
|
-
@group = 'sensors'
|
2207
|
-
end
|
2208
|
-
|
2209
|
-
end
|
2210
|
-
|
2211
|
-
# Category: Sensors
|
2212
|
-
#
|
2213
|
-
class ActivityRecognitionTrigger < SensorsTrigger
|
2214
|
-
|
2215
|
-
def initialize(h={})
|
2216
|
-
|
2217
|
-
options = {
|
2218
|
-
confidence_level: 50,
|
2219
|
-
selected_index: 1
|
2220
|
-
}
|
2221
|
-
|
2222
|
-
super(options.merge h)
|
2223
|
-
|
2224
|
-
@activity = ['In Vehicle', 'On Bicycle', 'Running', 'Walking', 'Still']
|
2225
|
-
|
2226
|
-
end
|
2227
|
-
|
2228
|
-
def to_s()
|
2229
|
-
activity = @activity[@h[:selected_index]]
|
2230
|
-
'Activity - ' + activity
|
2231
|
-
end
|
2232
|
-
|
2233
|
-
def to_summary
|
2234
|
-
|
2235
|
-
activity = @activity[@h[:selected_index]]
|
2236
|
-
s = if activity.length > 10 then
|
2237
|
-
activity[0..7] + '..'
|
2238
|
-
else
|
2239
|
-
activity
|
2240
|
-
end
|
2241
|
-
|
2242
|
-
'Activity - ' + s
|
2243
|
-
|
2244
|
-
end
|
2245
|
-
|
2246
|
-
end
|
2247
|
-
|
2248
|
-
# Category: Sensors
|
2249
|
-
#
|
2250
|
-
class ProximityTrigger < SensorsTrigger
|
2251
|
-
|
2252
|
-
def initialize(h={})
|
2253
|
-
|
2254
|
-
if h[:distance] then
|
2255
|
-
|
2256
|
-
case h[:distance].to_sym
|
2257
|
-
when :near
|
2258
|
-
options[:near] = true
|
2259
|
-
end
|
2260
|
-
end
|
2261
|
-
|
2262
|
-
options = {
|
2263
|
-
near: true,
|
2264
|
-
selected_option: 0
|
2265
|
-
}
|
2266
|
-
|
2267
|
-
super(options.merge filter(options,h))
|
2268
|
-
|
2269
|
-
end
|
2270
|
-
|
2271
|
-
def to_s()
|
2272
|
-
|
2273
|
-
distance = if @h[:near] then
|
2274
|
-
'Near'
|
2275
|
-
else
|
2276
|
-
'Far'
|
2277
|
-
end
|
2278
|
-
|
2279
|
-
"Proximity Sensor (%s)" % distance
|
2280
|
-
end
|
2281
|
-
|
2282
|
-
end
|
2283
|
-
|
2284
|
-
# Category: Sensors
|
2285
|
-
#
|
2286
|
-
class ShakeDeviceTrigger < SensorsTrigger
|
2287
|
-
|
2288
|
-
def initialize(h={})
|
2289
|
-
|
2290
|
-
options = {
|
2291
|
-
}
|
2292
|
-
|
2293
|
-
super(options.merge h)
|
2294
|
-
|
2295
|
-
end
|
2296
|
-
|
2297
|
-
def to_pc()
|
2298
|
-
'shake_device?'
|
2299
|
-
end
|
2300
|
-
|
2301
|
-
def to_s()
|
2302
|
-
'Shake Device'
|
2303
|
-
end
|
2304
|
-
|
2305
|
-
end
|
2306
|
-
|
2307
|
-
# Category: Sensors
|
2308
|
-
#
|
2309
|
-
# options:
|
2310
|
-
# Face Up -> Face Down
|
2311
|
-
# Face Down -> Face Up
|
2312
|
-
# Any -> Face Down
|
2313
|
-
#
|
2314
|
-
class FlipDeviceTrigger < SensorsTrigger
|
2315
|
-
|
2316
|
-
def initialize(h={})
|
2317
|
-
|
2318
|
-
options = {
|
2319
|
-
any_start: false,
|
2320
|
-
face_down: true,
|
2321
|
-
work_with_screen_off: false
|
2322
|
-
}
|
2323
|
-
|
2324
|
-
super(options.merge h)
|
2325
|
-
|
2326
|
-
end
|
2327
|
-
|
2328
|
-
def to_pc()
|
2329
|
-
@h[:face_down] ? 'flip_device_down?' : 'flip_device_up?'
|
2330
|
-
end
|
2331
|
-
|
2332
|
-
def to_s()
|
2333
|
-
|
2334
|
-
action = @h[:face_down] ? 'Face Up -> Face Down' : 'Face Down -> Face Up'
|
2335
|
-
'Flip Device ' + action
|
2336
|
-
end
|
2337
|
-
|
2338
|
-
end
|
2339
|
-
|
2340
|
-
# Category: Sensors
|
2341
|
-
#
|
2342
|
-
class OrientationTrigger < SensorsTrigger
|
2343
|
-
|
2344
|
-
def initialize(h={})
|
2345
|
-
|
2346
|
-
options = {
|
2347
|
-
check_orientation_alive: true,
|
2348
|
-
option: 0
|
2349
|
-
}
|
2350
|
-
|
2351
|
-
super(options.merge h)
|
2352
|
-
|
2353
|
-
end
|
2354
|
-
|
2355
|
-
end
|
2356
|
-
|
2357
|
-
# Category: User Input
|
2358
|
-
#
|
2359
|
-
class FloatingButtonTrigger < Trigger
|
2360
|
-
|
2361
|
-
def initialize(h={})
|
2362
|
-
|
2363
|
-
options = {
|
2364
|
-
image_resource_id: 0,
|
2365
|
-
icon_bg_color: -9079435,
|
2366
|
-
alpha: 100,
|
2367
|
-
padding: 20,
|
2368
|
-
force_location: false,
|
2369
|
-
show_on_lock_screen: false,
|
2370
|
-
size: 0,
|
2371
|
-
transparent_background: false,
|
2372
|
-
x_location: 0,
|
2373
|
-
y_location: 0
|
2374
|
-
}
|
2375
|
-
|
2376
|
-
super(options.merge h)
|
2377
|
-
|
2378
|
-
end
|
2379
|
-
|
2380
|
-
end
|
2381
|
-
|
2382
|
-
# Category: User Input
|
2383
|
-
#
|
2384
|
-
class ShortcutTrigger < Trigger
|
2385
|
-
|
2386
|
-
def initialize(h={})
|
2387
|
-
|
2388
|
-
options = {
|
2389
|
-
}
|
2390
|
-
|
2391
|
-
super(options.merge h)
|
2392
|
-
|
2393
|
-
end
|
2394
|
-
|
2395
|
-
end
|
2396
|
-
|
2397
|
-
# Category: User Input
|
2398
|
-
#
|
2399
|
-
class VolumeButtonTrigger < Trigger
|
2400
|
-
|
2401
|
-
def initialize(h={})
|
2402
|
-
|
2403
|
-
options = {
|
2404
|
-
dont_change_volume: true,
|
2405
|
-
monitor_option: 1,
|
2406
|
-
not_configured: false,
|
2407
|
-
option: 0
|
2408
|
-
}
|
2409
|
-
|
2410
|
-
super(options.merge h)
|
2411
|
-
|
2412
|
-
end
|
2413
|
-
|
2414
|
-
end
|
2415
|
-
|
2416
|
-
# Category: User Input
|
2417
|
-
#
|
2418
|
-
class MediaButtonPressedTrigger < Trigger
|
2419
|
-
|
2420
|
-
def initialize(h={})
|
2421
|
-
|
2422
|
-
options = {
|
2423
|
-
option: 'Single Press',
|
2424
|
-
cancel_press: false
|
2425
|
-
}
|
2426
|
-
|
2427
|
-
super(options.merge h)
|
2428
|
-
|
2429
|
-
end
|
2430
|
-
|
2431
|
-
end
|
2432
|
-
|
2433
|
-
# Category: User Input
|
2434
|
-
#
|
2435
|
-
class SwipeTrigger < Trigger
|
2436
|
-
|
2437
|
-
def initialize(h={})
|
2438
|
-
|
2439
|
-
options = {
|
2440
|
-
swipe_start_area: 0,
|
2441
|
-
swipe_motion: 0,
|
2442
|
-
cleared: true
|
2443
|
-
}
|
2444
|
-
|
2445
|
-
super(options.merge h)
|
2446
|
-
|
2447
|
-
end
|
2448
|
-
|
2449
|
-
end
|
2450
|
-
|
2451
|
-
|
2452
|
-
class Action < MacroObject
|
2453
|
-
using Params
|
2454
|
-
|
2455
|
-
attr_reader :constraints
|
2456
|
-
|
2457
|
-
def initialize(h={})
|
2458
|
-
|
2459
|
-
macro = h[:macro]
|
2460
|
-
h.delete :macro
|
2461
|
-
super(h)
|
2462
|
-
|
2463
|
-
# fetch the constraints
|
2464
|
-
@constraints = @h[:constraint_list].map do |constraint|
|
2465
|
-
object(constraint.to_snake_case.merge(macro: macro))
|
2466
|
-
end
|
2467
|
-
end
|
2468
|
-
|
2469
|
-
def invoke(s='')
|
2470
|
-
"%s/%s: %s" % [@group, @type, s]
|
2471
|
-
end
|
2472
|
-
|
2473
|
-
end
|
2474
|
-
|
2475
|
-
|
2476
|
-
class LocationAction < Action
|
2477
|
-
|
2478
|
-
def initialize(h={})
|
2479
|
-
super(h)
|
2480
|
-
@group = 'location'
|
2481
|
-
end
|
2482
|
-
|
2483
|
-
end
|
2484
|
-
|
2485
|
-
# Category: Location
|
2486
|
-
#
|
2487
|
-
class ShareLocationAction < LocationAction
|
2488
|
-
|
2489
|
-
def initialize(h={})
|
2490
|
-
|
2491
|
-
super()
|
2492
|
-
|
2493
|
-
options = {
|
2494
|
-
email: '',
|
2495
|
-
variable: {:m_stringValue=>"", :m_name=>"",
|
2496
|
-
:m_decimalValue=>0.0, :isLocal=>true, :m_booleanValue=>false,
|
2497
|
-
:excludeFromLog=>false, :m_intValue=>0, :m_type=>2},
|
2498
|
-
sim_id: 0,
|
2499
|
-
output_channel: 5,
|
2500
|
-
old_variable_format: true
|
2501
|
-
}
|
2502
|
-
|
2503
|
-
super(options.merge h)
|
2504
|
-
|
2505
|
-
end
|
2506
|
-
|
2507
|
-
end
|
2508
|
-
|
2509
|
-
|
2510
|
-
class ApplicationAction < Action
|
2511
|
-
|
2512
|
-
def initialize(h={})
|
2513
|
-
super(h)
|
2514
|
-
@group = 'application'
|
2515
|
-
end
|
2516
|
-
|
2517
|
-
end
|
2518
|
-
|
2519
|
-
# Category: Applications
|
2520
|
-
#
|
2521
|
-
class LaunchActivityAction < ApplicationAction
|
2522
|
-
|
2523
|
-
def initialize(h={})
|
2524
|
-
|
2525
|
-
options = {
|
2526
|
-
application_name: 'Chrome',
|
2527
|
-
package_to_launch: 'com.android.chrome',
|
2528
|
-
exclude_from_recents: false,
|
2529
|
-
start_new: false
|
2530
|
-
}
|
2531
|
-
|
2532
|
-
super(options.merge h)
|
2533
|
-
|
2534
|
-
end
|
2535
|
-
|
2536
|
-
def to_s()
|
2537
|
-
'Launch ' + @h[:application_name]
|
2538
|
-
end
|
2539
|
-
|
2540
|
-
end
|
2541
|
-
|
2542
|
-
# Category: Applications
|
2543
|
-
#
|
2544
|
-
class KillBackgroundAppAction < ApplicationAction
|
2545
|
-
|
2546
|
-
def initialize(h={})
|
2547
|
-
|
2548
|
-
options = {
|
2549
|
-
application_name_list: [""],
|
2550
|
-
package_name_list: [""]
|
2551
|
-
}
|
2552
|
-
|
2553
|
-
super(options.merge h)
|
2554
|
-
|
2555
|
-
end
|
2556
|
-
|
2557
|
-
end
|
2558
|
-
|
2559
|
-
# Category: Applications
|
2560
|
-
#
|
2561
|
-
class OpenWebPageAction < ApplicationAction
|
2562
|
-
|
2563
|
-
def initialize(h={})
|
2564
|
-
|
2565
|
-
h[:url_to_open] = h[:url] if h[:url]
|
2566
|
-
|
2567
|
-
options = {
|
2568
|
-
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},
|
2569
|
-
url_to_open: '',
|
2570
|
-
http_get: true,
|
2571
|
-
disable_url_encode: false,
|
2572
|
-
block_next_action: false
|
2573
|
-
}
|
2574
|
-
|
2575
|
-
super(options.merge filter(options,h))
|
2576
|
-
|
2577
|
-
end
|
2578
|
-
|
2579
|
-
def to_s()
|
2580
|
-
"HTTP GET\n url: " + @h[:url_to_open]
|
2581
|
-
end
|
2582
|
-
|
2583
|
-
end
|
2584
|
-
|
2585
|
-
|
2586
|
-
class CameraAction < Action
|
2587
|
-
|
2588
|
-
def initialize(h={})
|
2589
|
-
super(h)
|
2590
|
-
@group = 'camera'
|
2591
|
-
end
|
2592
|
-
|
2593
|
-
end
|
2594
|
-
|
2595
|
-
# Category: Camera/Photo
|
2596
|
-
#
|
2597
|
-
class UploadPhotoAction < CameraAction
|
2598
|
-
|
2599
|
-
def initialize(h={})
|
2600
|
-
|
2601
|
-
options = {
|
2602
|
-
option: 'Via Intent',
|
2603
|
-
use_smtp_email: false
|
2604
|
-
}
|
2605
|
-
|
2606
|
-
super(options.merge h)
|
2607
|
-
|
2608
|
-
end
|
2609
|
-
|
2610
|
-
end
|
2611
|
-
|
2612
|
-
# Category: Camera/Photo
|
2613
|
-
#
|
2614
|
-
class TakePictureAction < CameraAction
|
2615
|
-
|
2616
|
-
def initialize(h={})
|
2617
|
-
|
2618
|
-
options = {
|
2619
|
-
new_path: '/storage/sdcard1/DCIM/Camera',
|
2620
|
-
path: '/storage/sdcard1/DCIM/Camera',
|
2621
|
-
show_icon: true,
|
2622
|
-
use_front_camera: true,
|
2623
|
-
flash_option: 0
|
2624
|
-
}
|
2625
|
-
|
2626
|
-
super(options.merge h)
|
2627
|
-
|
2628
|
-
end
|
2629
|
-
|
2630
|
-
def to_pc()
|
2631
|
-
camera = @h[:use_front_camera] ? :front : :back
|
2632
|
-
'take_photo :' + camera.to_s
|
2633
|
-
end
|
2634
|
-
|
2635
|
-
def to_s()
|
2636
|
-
'Take Picture'
|
2637
|
-
end
|
2638
|
-
|
2639
|
-
end
|
2640
|
-
|
2641
|
-
class IfConditionAction < Action
|
2642
|
-
|
2643
|
-
def initialize(h={})
|
2644
|
-
|
2645
|
-
options = {
|
2646
|
-
a: true,
|
2647
|
-
constraint_list: ''
|
2648
|
-
}
|
2649
|
-
|
2650
|
-
macro = h[:macro]
|
2651
|
-
h2 = options.merge(filter(options,h).merge(macro: macro))
|
2652
|
-
|
2653
|
-
super(h2)
|
2654
|
-
|
2655
|
-
end
|
2656
|
-
|
2657
|
-
def to_s()
|
2658
|
-
|
2659
|
-
operator = @h[:is_or_condition] ? 'OR' : 'AND'
|
2660
|
-
'If ' + @constraints.map(&:to_s).join(" %s " % operator)
|
2661
|
-
|
2662
|
-
end
|
2663
|
-
end
|
2664
|
-
|
2665
|
-
class ElseAction < Action
|
2666
|
-
|
2667
|
-
def initialize(h={})
|
2668
|
-
|
2669
|
-
options = {
|
2670
|
-
constraint_list: ''
|
2671
|
-
}
|
2672
|
-
|
2673
|
-
super(options.merge h)
|
2674
|
-
|
2675
|
-
end
|
2676
|
-
|
2677
|
-
def to_s()
|
2678
|
-
'Else'
|
2679
|
-
end
|
2680
|
-
|
2681
|
-
end
|
2682
|
-
|
2683
|
-
class EndIfAction < Action
|
2684
|
-
|
2685
|
-
def initialize(h={})
|
2686
|
-
|
2687
|
-
options = {
|
2688
|
-
constraint_list: ''
|
2689
|
-
}
|
2690
|
-
|
2691
|
-
super(options.merge h)
|
2692
|
-
|
2693
|
-
end
|
2694
|
-
|
2695
|
-
def to_s()
|
2696
|
-
'End If'
|
2697
|
-
end
|
2698
|
-
|
2699
|
-
end
|
2700
|
-
|
2701
|
-
class ConnectivityAction < Action
|
2702
|
-
|
2703
|
-
def initialize(h={})
|
2704
|
-
super(h)
|
2705
|
-
@group = 'connectivity'
|
2706
|
-
end
|
2707
|
-
|
2708
|
-
end
|
2709
|
-
|
2710
|
-
# Category: Connectivity
|
2711
|
-
#
|
2712
|
-
class SetWifiAction < ConnectivityAction
|
2713
|
-
|
2714
|
-
def initialize(h={})
|
2715
|
-
|
2716
|
-
options = {
|
2717
|
-
ssid: '[Select Wifi]',
|
2718
|
-
network_id: 0,
|
2719
|
-
state: 0
|
2720
|
-
}
|
2721
|
-
|
2722
|
-
super(options.merge h)
|
2723
|
-
|
2724
|
-
end
|
2725
|
-
|
2726
|
-
def to_s()
|
2727
|
-
action = @h[:state] == 0 ? 'Enable' : 'Disable'
|
2728
|
-
action + ' Wifi'
|
2729
|
-
end
|
2730
|
-
|
2731
|
-
end
|
2732
|
-
|
2733
|
-
# Category: Connectivity
|
2734
|
-
#
|
2735
|
-
class SetBluetoothAction < ConnectivityAction
|
2736
|
-
|
2737
|
-
def initialize(h={})
|
2738
|
-
|
2739
|
-
options = {
|
2740
|
-
device_name: '',
|
2741
|
-
state: 0
|
2742
|
-
}
|
2743
|
-
|
2744
|
-
super(options.merge h)
|
2745
|
-
|
2746
|
-
end
|
2747
|
-
|
2748
|
-
end
|
2749
|
-
|
2750
|
-
# Category: Connectivity
|
2751
|
-
#
|
2752
|
-
class SetBluetoothAction < ConnectivityAction
|
2753
|
-
|
2754
|
-
def initialize(h={})
|
2755
|
-
|
2756
|
-
options = {
|
2757
|
-
device_name: '',
|
2758
|
-
state: 1
|
2759
|
-
}
|
2760
|
-
|
2761
|
-
super(options.merge h)
|
2762
|
-
|
2763
|
-
end
|
2764
|
-
|
2765
|
-
end
|
2766
|
-
|
2767
|
-
class SetHotspotAction < ConnectivityAction
|
2768
|
-
|
2769
|
-
def initialize(h={})
|
2770
|
-
|
2771
|
-
options = {
|
2772
|
-
device_name: "", state: 0, turn_wifi_on: true, use_legacy_mechanism: false, mechanism: 0
|
2773
|
-
|
2774
|
-
}
|
2775
|
-
|
2776
|
-
super(options.merge h)
|
2777
|
-
|
2778
|
-
end
|
2779
|
-
|
2780
|
-
def to_s()
|
2781
|
-
action = @h[:turn_wifi_on] ? 'Enable' : 'Disable'
|
2782
|
-
action + ' HotSpot'
|
2783
|
-
end
|
2784
|
-
end
|
2785
|
-
|
2786
|
-
# Category: Connectivity
|
2787
|
-
#
|
2788
|
-
class SendIntentAction < ConnectivityAction
|
2789
|
-
|
2790
|
-
def initialize(h={})
|
2791
|
-
|
2792
|
-
options = {
|
2793
|
-
action: '',
|
2794
|
-
class_name: '',
|
2795
|
-
data: '',
|
2796
|
-
extra1_name: '',
|
2797
|
-
extra1_value: '',
|
2798
|
-
extra2_name: '',
|
2799
|
-
extra2_value: '',
|
2800
|
-
extra3_name: '',
|
2801
|
-
extra3_value: '',
|
2802
|
-
extra4_name: '',
|
2803
|
-
extra4_value: '',
|
2804
|
-
package_name: '',
|
2805
|
-
target: 'Activity'
|
2806
|
-
}
|
2807
|
-
|
2808
|
-
super(options.merge h)
|
2809
|
-
|
2810
|
-
end
|
2811
|
-
|
2812
|
-
end
|
2813
|
-
|
2814
|
-
|
2815
|
-
class DateTimeAction < Action
|
2816
|
-
|
2817
|
-
def initialize(h={})
|
2818
|
-
super(h)
|
2819
|
-
@group = 'datetime'
|
2820
|
-
end
|
2821
|
-
|
2822
|
-
end
|
2823
|
-
|
2824
|
-
# Category: Date/Time
|
2825
|
-
#
|
2826
|
-
class SetAlarmClockAction < DateTimeAction
|
2827
|
-
|
2828
|
-
def initialize(h={})
|
2829
|
-
|
2830
|
-
options = {
|
2831
|
-
days_of_week: [false, false, false, false, false, false, false],
|
2832
|
-
label: 'wakeup mum',
|
2833
|
-
delay_in_minutes: 1,
|
2834
|
-
hour: 8,
|
2835
|
-
delay_in_hours: 0,
|
2836
|
-
minute: 15,
|
2837
|
-
one_off: true,
|
2838
|
-
option: 0,
|
2839
|
-
relative: true,
|
2840
|
-
day_option: 0
|
2841
|
-
}
|
2842
|
-
|
2843
|
-
super(options.merge h)
|
2844
|
-
|
2845
|
-
end
|
2846
|
-
|
2847
|
-
end
|
2848
|
-
|
2849
|
-
# Category: Date/Time
|
2850
|
-
#
|
2851
|
-
class StopWatchAction < DateTimeAction
|
2852
|
-
|
2853
|
-
def initialize(h={})
|
2854
|
-
|
2855
|
-
options = {
|
2856
|
-
stopwatch_name: 'timer1',
|
2857
|
-
option: 0
|
2858
|
-
}
|
2859
|
-
|
2860
|
-
super(options.merge h)
|
2861
|
-
|
2862
|
-
end
|
2863
|
-
|
2864
|
-
end
|
2865
|
-
|
2866
|
-
# Category: Date/Time
|
2867
|
-
#
|
2868
|
-
class SayTimeAction < DateTimeAction
|
2869
|
-
|
2870
|
-
def initialize(h={})
|
2871
|
-
|
2872
|
-
options = {
|
2873
|
-
:'12_hour' => true
|
2874
|
-
}
|
2875
|
-
|
2876
|
-
super(options.merge h)
|
2877
|
-
|
2878
|
-
end
|
2879
|
-
|
2880
|
-
def invoke()
|
2881
|
-
time = ($env and $env[:time]) ? $env[:time] : Time.now
|
2882
|
-
tformat = @h['12_hour'] ? "%-I:%M%P" : "%H:%M"
|
2883
|
-
super(time.strftime(tformat))
|
2884
|
-
end
|
2885
|
-
|
2886
|
-
def to_pc()
|
2887
|
-
'say current_time()'
|
2888
|
-
end
|
2889
|
-
|
2890
|
-
def to_s()
|
2891
|
-
'Say Current Time'
|
2892
|
-
end
|
2893
|
-
|
2894
|
-
end
|
2895
|
-
|
2896
|
-
|
2897
|
-
class DeviceAction < Action
|
2898
|
-
|
2899
|
-
def initialize(h={})
|
2900
|
-
super(h)
|
2901
|
-
@group = 'device'
|
2902
|
-
end
|
2903
|
-
|
2904
|
-
end
|
2905
|
-
|
2906
|
-
# Category: Device Actions
|
2907
|
-
#
|
2908
|
-
class AndroidShortcutsAction < DeviceAction
|
2909
|
-
|
2910
|
-
def initialize(h={})
|
2911
|
-
|
2912
|
-
options = {
|
2913
|
-
option: 1
|
2914
|
-
}
|
2915
|
-
|
2916
|
-
super(options.merge h)
|
2917
|
-
|
2918
|
-
end
|
2919
|
-
|
2920
|
-
end
|
2921
|
-
|
2922
|
-
# Category: Device Actions
|
2923
|
-
#
|
2924
|
-
class ClipboardAction < DeviceAction
|
2925
|
-
|
2926
|
-
def initialize(h={})
|
2927
|
-
|
2928
|
-
options = {
|
2929
|
-
clipboard_text: ''
|
2930
|
-
}
|
2931
|
-
|
2932
|
-
super(options.merge h)
|
2933
|
-
|
2934
|
-
end
|
2935
|
-
|
2936
|
-
end
|
2937
|
-
|
2938
|
-
# Category: Device Actions
|
2939
|
-
#
|
2940
|
-
class PressBackAction < DeviceAction
|
2941
|
-
|
2942
|
-
def initialize(h={})
|
2943
|
-
|
2944
|
-
options = {
|
2945
|
-
}
|
2946
|
-
|
2947
|
-
super(options.merge h)
|
2948
|
-
|
2949
|
-
end
|
2950
|
-
|
2951
|
-
end
|
2952
|
-
|
2953
|
-
# Category: Device Actions
|
2954
|
-
#
|
2955
|
-
class SpeakTextAction < DeviceAction
|
2956
|
-
|
2957
|
-
def initialize(h={})
|
2958
|
-
|
2959
|
-
options = {
|
2960
|
-
text_to_say: '',
|
2961
|
-
queue: false,
|
2962
|
-
read_numbers_individually: false,
|
2963
|
-
specify_audio_stream: false,
|
2964
|
-
speed: 0.99,
|
2965
|
-
pitch: 0.99,
|
2966
|
-
wait_to_finish: false,
|
2967
|
-
audio_stream: 0
|
2968
|
-
}
|
2969
|
-
|
2970
|
-
super(options.merge h)
|
2971
|
-
|
2972
|
-
end
|
2973
|
-
|
2974
|
-
def to_s()
|
2975
|
-
"Speak Text (%s)" % @h[:text_to_say]
|
2976
|
-
end
|
2977
|
-
|
2978
|
-
end
|
2979
|
-
|
2980
|
-
# Category: Device Actions
|
2981
|
-
#
|
2982
|
-
class UIInteractionAction < DeviceAction
|
2983
|
-
|
2984
|
-
def initialize(h={})
|
2985
|
-
|
2986
|
-
options = {
|
2987
|
-
ui_interaction_configuration: {:type=>"Copy"},
|
2988
|
-
action: 2
|
2989
|
-
}
|
2990
|
-
|
2991
|
-
super(options.merge h)
|
2992
|
-
|
2993
|
-
end
|
2994
|
-
|
2995
|
-
end
|
2996
|
-
|
2997
|
-
# Category: Device Actions
|
2998
|
-
#
|
2999
|
-
class VoiceSearchAction < DeviceAction
|
3000
|
-
|
3001
|
-
def initialize(h={})
|
3002
|
-
|
3003
|
-
options = {
|
3004
|
-
}
|
3005
|
-
|
3006
|
-
super(options.merge h)
|
3007
|
-
|
3008
|
-
end
|
3009
|
-
|
3010
|
-
end
|
3011
|
-
|
3012
|
-
|
3013
|
-
class DeviceSettingsAction < Action
|
3014
|
-
|
3015
|
-
def initialize(h={})
|
3016
|
-
super(h)
|
3017
|
-
@group = 'devicesettings'
|
3018
|
-
end
|
3019
|
-
|
3020
|
-
end
|
3021
|
-
|
3022
|
-
# Category: Device Settings
|
3023
|
-
#
|
3024
|
-
class ExpandCollapseStatusBarAction < DeviceSettingsAction
|
3025
|
-
|
3026
|
-
def initialize(h={})
|
3027
|
-
|
3028
|
-
options = {
|
3029
|
-
option: 0
|
3030
|
-
}
|
3031
|
-
|
3032
|
-
super(options.merge h)
|
3033
|
-
|
3034
|
-
end
|
3035
|
-
|
3036
|
-
end
|
3037
|
-
|
3038
|
-
# Category: Device Settings
|
3039
|
-
#
|
3040
|
-
class LaunchHomeScreenAction < DeviceSettingsAction
|
3041
|
-
|
3042
|
-
def initialize(h={})
|
3043
|
-
|
3044
|
-
options = {
|
3045
|
-
}
|
3046
|
-
|
3047
|
-
super(options.merge h)
|
3048
|
-
|
3049
|
-
end
|
3050
|
-
|
3051
|
-
end
|
3052
|
-
|
3053
|
-
# Category: Device Settings
|
3054
|
-
#
|
3055
|
-
class CameraFlashLightAction < DeviceSettingsAction
|
3056
|
-
|
3057
|
-
def initialize(h={})
|
3058
|
-
|
3059
|
-
options = {
|
3060
|
-
launch_foreground: false,
|
3061
|
-
state: 0
|
3062
|
-
}
|
3063
|
-
|
3064
|
-
super(options.merge h)
|
3065
|
-
|
3066
|
-
end
|
3067
|
-
|
3068
|
-
def to_pc()
|
3069
|
-
'torch :on'
|
3070
|
-
end
|
3071
|
-
|
3072
|
-
def to_s()
|
3073
|
-
'Torch On'
|
3074
|
-
end
|
3075
|
-
|
3076
|
-
end
|
3077
|
-
|
3078
|
-
# Category: Device Settings
|
3079
|
-
#
|
3080
|
-
class VibrateAction < DeviceSettingsAction
|
3081
|
-
|
3082
|
-
def initialize(h={})
|
3083
|
-
|
3084
|
-
options = {
|
3085
|
-
vibrate_pattern: 1
|
3086
|
-
}
|
3087
|
-
|
3088
|
-
super(options.merge h)
|
3089
|
-
|
3090
|
-
end
|
3091
|
-
|
3092
|
-
def to_s()
|
3093
|
-
|
3094
|
-
pattern = [
|
3095
|
-
'Blip', 'Short Buzz', 'Long Buzz', 'Rapid', 'Slow', 'Increasing',
|
3096
|
-
'Constant', 'Decreasing', 'Final Fantasy', 'Game Over', 'Star Wars',
|
3097
|
-
'Mini Blip', 'Micro Blip'
|
3098
|
-
]
|
3099
|
-
|
3100
|
-
'Vibrate ' + "(%s)" % pattern[@h[:vibrate_pattern].to_i]
|
3101
|
-
end
|
3102
|
-
|
3103
|
-
end
|
3104
|
-
|
3105
|
-
# Category: Device Settings
|
3106
|
-
#
|
3107
|
-
class SetAutoRotateAction < DeviceSettingsAction
|
3108
|
-
|
3109
|
-
def initialize(h={})
|
3110
|
-
|
3111
|
-
options = {
|
3112
|
-
state: 0
|
3113
|
-
}
|
3114
|
-
|
3115
|
-
super(options.merge h)
|
3116
|
-
|
3117
|
-
end
|
3118
|
-
|
3119
|
-
end
|
3120
|
-
|
3121
|
-
# Category: Device Settings
|
3122
|
-
#
|
3123
|
-
class DayDreamAction < DeviceSettingsAction
|
3124
|
-
|
3125
|
-
def initialize(h={})
|
3126
|
-
|
3127
|
-
options = {
|
3128
|
-
}
|
3129
|
-
|
3130
|
-
super(options.merge h)
|
3131
|
-
|
3132
|
-
end
|
3133
|
-
|
3134
|
-
end
|
3135
|
-
|
3136
|
-
# Category: Device Settings
|
3137
|
-
#
|
3138
|
-
class SetKeyboardAction < DeviceSettingsAction
|
3139
|
-
|
3140
|
-
def initialize(h={})
|
3141
|
-
|
3142
|
-
options = {
|
3143
|
-
}
|
3144
|
-
|
3145
|
-
super(options.merge h)
|
3146
|
-
|
3147
|
-
end
|
3148
|
-
|
3149
|
-
end
|
3150
|
-
|
3151
|
-
# Category: Device Settings
|
3152
|
-
#
|
3153
|
-
class SetKeyguardAction < DeviceSettingsAction
|
3154
|
-
|
3155
|
-
def initialize(h={})
|
3156
|
-
|
3157
|
-
options = {
|
3158
|
-
keyguard_on: true
|
3159
|
-
}
|
3160
|
-
|
3161
|
-
super(options.merge h)
|
3162
|
-
|
3163
|
-
end
|
3164
|
-
|
3165
|
-
end
|
3166
|
-
|
3167
|
-
# Category: Device Settings
|
3168
|
-
#
|
3169
|
-
class CarModeAction < DeviceSettingsAction
|
3170
|
-
|
3171
|
-
def initialize(h={})
|
3172
|
-
|
3173
|
-
options = {
|
3174
|
-
option: 0
|
3175
|
-
}
|
3176
|
-
|
3177
|
-
super(options.merge h)
|
3178
|
-
|
3179
|
-
end
|
3180
|
-
|
3181
|
-
end
|
3182
|
-
|
3183
|
-
# Category: Device Settings
|
3184
|
-
#
|
3185
|
-
class ChangeKeyboardAction < DeviceSettingsAction
|
3186
|
-
|
3187
|
-
def initialize(h={})
|
3188
|
-
|
3189
|
-
options = {
|
3190
|
-
keyboard_id: 'com.android.inputmethod.latin/.LatinIME',
|
3191
|
-
keyboard_name: 'Android Keyboard (AOSP)'
|
3192
|
-
}
|
3193
|
-
|
3194
|
-
super(options.merge h)
|
3195
|
-
|
3196
|
-
end
|
3197
|
-
|
3198
|
-
end
|
3199
|
-
|
3200
|
-
# Category: Device Settings
|
3201
|
-
#
|
3202
|
-
class SetWallpaperAction < DeviceSettingsAction
|
3203
|
-
|
3204
|
-
def initialize(h={})
|
3205
|
-
|
3206
|
-
options = {
|
3207
|
-
image_name: '6051449505275476553',
|
3208
|
-
s_screen_options: ["Home Screen", "Lock Screen", "Home + Lock Screen"],
|
3209
|
-
s_options: ["Image", "Live Wallpaper (Preview Screen)"],
|
3210
|
-
wallpaper_uri_string: 'content://media/external/images/media/928',
|
3211
|
-
screen_option: 0,
|
3212
|
-
option: 0
|
3213
|
-
}
|
3214
|
-
|
3215
|
-
super(options.merge h)
|
3216
|
-
|
3217
|
-
end
|
3218
|
-
|
3219
|
-
end
|
3220
|
-
|
3221
|
-
class FileAction < Action
|
3222
|
-
|
3223
|
-
def initialize(h={})
|
3224
|
-
super(h)
|
3225
|
-
@group = 'file'
|
3226
|
-
end
|
3227
|
-
|
3228
|
-
end
|
3229
|
-
|
3230
|
-
# Category: Files
|
3231
|
-
#
|
3232
|
-
class OpenFileAction < FileAction
|
3233
|
-
|
3234
|
-
def initialize(h={})
|
3235
|
-
|
3236
|
-
options = {
|
3237
|
-
app_name: '',
|
3238
|
-
class_name: '',
|
3239
|
-
package_name: '',
|
3240
|
-
file_path: ''
|
3241
|
-
}
|
3242
|
-
|
3243
|
-
super(options.merge h)
|
3244
|
-
|
3245
|
-
end
|
3246
|
-
|
3247
|
-
end
|
3248
|
-
|
3249
|
-
|
3250
|
-
class LocationAction < Action
|
3251
|
-
|
3252
|
-
def initialize(h={})
|
3253
|
-
super(h)
|
3254
|
-
@group = 'location'
|
3255
|
-
end
|
3256
|
-
|
3257
|
-
end
|
3258
|
-
|
3259
|
-
# Category: Location
|
3260
|
-
#
|
3261
|
-
class ForceLocationUpdateAction < LocationAction
|
3262
|
-
|
3263
|
-
def initialize(h={})
|
3264
|
-
|
3265
|
-
options = {
|
3266
|
-
}
|
3267
|
-
|
3268
|
-
super(options.merge h)
|
3269
|
-
|
3270
|
-
end
|
3271
|
-
|
3272
|
-
end
|
3273
|
-
|
3274
|
-
# Category: Location
|
3275
|
-
#
|
3276
|
-
class ShareLocationAction < LocationAction
|
3277
|
-
|
3278
|
-
def initialize(h={})
|
3279
|
-
|
3280
|
-
options = {
|
3281
|
-
email: '',
|
3282
|
-
variable: {:m_stringValue=>"", :m_name=>"", :m_decimalValue=>0.0, :isLocal=>true, :m_booleanValue=>false, :excludeFromLog=>false, :m_intValue=>0, :m_type=>2},
|
3283
|
-
sim_id: 0,
|
3284
|
-
output_channel: 5,
|
3285
|
-
old_variable_format: true
|
3286
|
-
}
|
3287
|
-
|
3288
|
-
super(options.merge h)
|
3289
|
-
|
3290
|
-
end
|
3291
|
-
|
3292
|
-
end
|
3293
|
-
|
3294
|
-
# Category: Location
|
3295
|
-
#
|
3296
|
-
class SetLocationUpdateRateAction < LocationAction
|
3297
|
-
|
3298
|
-
def initialize(h={})
|
3299
|
-
|
3300
|
-
options = {
|
3301
|
-
update_rate: 0,
|
3302
|
-
update_rate_seconds: 600
|
3303
|
-
}
|
3304
|
-
|
3305
|
-
super(options.merge h)
|
3306
|
-
|
3307
|
-
end
|
3308
|
-
|
3309
|
-
end
|
3310
|
-
|
3311
|
-
class LoggingAction < Action
|
3312
|
-
|
3313
|
-
def initialize(h={})
|
3314
|
-
super(h)
|
3315
|
-
@group = 'logging'
|
3316
|
-
end
|
3317
|
-
|
3318
|
-
end
|
3319
|
-
|
3320
|
-
# Category: Logging
|
3321
|
-
#
|
3322
|
-
class AddCalendarEntryAction < LoggingAction
|
3323
|
-
|
3324
|
-
def initialize(h={})
|
3325
|
-
|
3326
|
-
options = {
|
3327
|
-
title: '',
|
3328
|
-
duration_value: '0',
|
3329
|
-
calendar_id: '3',
|
3330
|
-
detail: '',
|
3331
|
-
availability: 0,
|
3332
|
-
fixed_days: 16,
|
3333
|
-
fixed_hour: 0,
|
3334
|
-
fixed_minute: 0,
|
3335
|
-
fixed_months: 8,
|
3336
|
-
fixed_time: true,
|
3337
|
-
relative_days: 0,
|
3338
|
-
relative_hours: 0,
|
3339
|
-
relative_minutes: 0,
|
3340
|
-
all_day_event: true
|
3341
|
-
}
|
3342
|
-
|
3343
|
-
super(options.merge h)
|
3344
|
-
|
3345
|
-
end
|
3346
|
-
|
3347
|
-
end
|
3348
|
-
|
3349
|
-
# Category: Logging
|
3350
|
-
#
|
3351
|
-
class LogAction < LoggingAction
|
3352
|
-
|
3353
|
-
def initialize(h={})
|
3354
|
-
|
3355
|
-
options = {
|
3356
|
-
log_text: '',
|
3357
|
-
log_date_and_time: true
|
3358
|
-
}
|
3359
|
-
|
3360
|
-
super(options.merge h)
|
3361
|
-
|
3362
|
-
end
|
3363
|
-
|
3364
|
-
end
|
3365
|
-
|
3366
|
-
# Category: Logging
|
3367
|
-
#
|
3368
|
-
class ClearLogAction < LoggingAction
|
3369
|
-
|
3370
|
-
def initialize(h={})
|
3371
|
-
|
3372
|
-
options = {
|
3373
|
-
user_log: true
|
3374
|
-
}
|
3375
|
-
|
3376
|
-
super(options.merge h)
|
3377
|
-
|
3378
|
-
end
|
3379
|
-
|
3380
|
-
end
|
3381
|
-
|
3382
|
-
class MediaAction < Action
|
3383
|
-
|
3384
|
-
def initialize(h={})
|
3385
|
-
super(h)
|
3386
|
-
@group = 'media'
|
3387
|
-
end
|
3388
|
-
|
3389
|
-
end
|
3390
|
-
|
3391
|
-
# Category: Media
|
3392
|
-
#
|
3393
|
-
class RecordMicrophoneAction < MediaAction
|
3394
|
-
|
3395
|
-
def initialize(h={})
|
3396
|
-
|
3397
|
-
options = {
|
3398
|
-
path: '/storage/emulated/0/MacroDroid/Recordings',
|
3399
|
-
record_time_string: 'Cancel Recording',
|
3400
|
-
recording_format: 0,
|
3401
|
-
seconds_to_record_for: -2
|
3402
|
-
}
|
3403
|
-
|
3404
|
-
super(options.merge h)
|
3405
|
-
|
3406
|
-
end
|
3407
|
-
|
3408
|
-
end
|
3409
|
-
|
3410
|
-
# Category: Media
|
3411
|
-
#
|
3412
|
-
class PlaySoundAction < MediaAction
|
3413
|
-
|
3414
|
-
def initialize(h={})
|
3415
|
-
|
3416
|
-
options = {
|
3417
|
-
selected_index: 0,
|
3418
|
-
file_path: ''
|
3419
|
-
}
|
3420
|
-
|
3421
|
-
super(options.merge h)
|
3422
|
-
|
3423
|
-
end
|
3424
|
-
|
3425
|
-
def to_s()
|
3426
|
-
'Play: ' + @h[:file_path]
|
3427
|
-
end
|
3428
|
-
|
3429
|
-
end
|
3430
|
-
|
3431
|
-
|
3432
|
-
class MessagingAction < Action
|
3433
|
-
|
3434
|
-
def initialize(h={})
|
3435
|
-
super(h)
|
3436
|
-
@group = 'messaging'
|
3437
|
-
end
|
3438
|
-
|
3439
|
-
end
|
3440
|
-
|
3441
|
-
# Category: Messaging
|
3442
|
-
#
|
3443
|
-
class SendEmailAction < MessagingAction
|
3444
|
-
|
3445
|
-
def initialize(h={})
|
3446
|
-
|
3447
|
-
options = {
|
3448
|
-
subject: '',
|
3449
|
-
body: '',
|
3450
|
-
email_address: '',
|
3451
|
-
from_email_address: '',
|
3452
|
-
attach_user_log: false,
|
3453
|
-
attach_log: false,
|
3454
|
-
send_option: 0
|
3455
|
-
}
|
3456
|
-
|
3457
|
-
super(options.merge h)
|
3458
|
-
|
3459
|
-
end
|
3460
|
-
|
3461
|
-
end
|
3462
|
-
|
3463
|
-
# Category: Messaging
|
3464
|
-
#
|
3465
|
-
class SendSMSAction < MessagingAction
|
3466
|
-
|
3467
|
-
def initialize(h={})
|
3468
|
-
|
3469
|
-
options = {
|
3470
|
-
number: '',
|
3471
|
-
contact: {:m_id=>"Hardwired_Number", :m_lookupKey=>"Hardwired_Number", :m_name=>"[Select Number]"},
|
3472
|
-
message_content: '',
|
3473
|
-
add_to_message_log: false,
|
3474
|
-
pre_populate: false,
|
3475
|
-
sim_id: 0
|
3476
|
-
}
|
3477
|
-
|
3478
|
-
super(options.merge h)
|
3479
|
-
|
3480
|
-
end
|
3481
|
-
|
3482
|
-
end
|
3483
|
-
|
3484
|
-
# Category: Messaging
|
3485
|
-
#
|
3486
|
-
class UDPCommandAction < MessagingAction
|
3487
|
-
|
3488
|
-
def initialize(h={})
|
3489
|
-
|
3490
|
-
options = {
|
3491
|
-
destination: '',
|
3492
|
-
message: '',
|
3493
|
-
port: 1024
|
3494
|
-
}
|
3495
|
-
|
3496
|
-
super(options.merge h)
|
3497
|
-
|
3498
|
-
end
|
3499
|
-
|
3500
|
-
end
|
3501
|
-
|
3502
|
-
|
3503
|
-
class NotificationsAction < Action
|
3504
|
-
|
3505
|
-
def initialize(h={})
|
3506
|
-
super(h)
|
3507
|
-
@group = 'notifications'
|
3508
|
-
end
|
3509
|
-
|
3510
|
-
end
|
3511
|
-
|
3512
|
-
# Category: Notifications
|
3513
|
-
#
|
3514
|
-
class ClearNotificationsAction < NotificationsAction
|
3515
|
-
|
3516
|
-
def initialize(h={})
|
3517
|
-
|
3518
|
-
options = {
|
3519
|
-
package_name_list: [],
|
3520
|
-
match_text: '',
|
3521
|
-
application_name_list: [],
|
3522
|
-
clear_persistent: false,
|
3523
|
-
excludes: false,
|
3524
|
-
match_option: 0,
|
3525
|
-
age_in_seconds: 0,
|
3526
|
-
option: 0,
|
3527
|
-
enable_regex: false
|
3528
|
-
}
|
3529
|
-
|
3530
|
-
super(options.merge h)
|
3531
|
-
|
3532
|
-
end
|
3533
|
-
|
3534
|
-
end
|
3535
|
-
|
3536
|
-
# Category: Notifications
|
3537
|
-
#
|
3538
|
-
class MessageDialogAction < NotificationsAction
|
3539
|
-
|
3540
|
-
def initialize(h={})
|
3541
|
-
|
3542
|
-
options = {
|
3543
|
-
secondary_class_type: 'MessageDialogAction',
|
3544
|
-
ringtone_name: 'Default',
|
3545
|
-
notification_text: '',
|
3546
|
-
notification_subject: '',
|
3547
|
-
macro_guid_to_run: -0,
|
3548
|
-
notification_channel_type: 0,
|
3549
|
-
image_resource_id: 0,
|
3550
|
-
overwrite_existing: false,
|
3551
|
-
priority: 0,
|
3552
|
-
ringtone_index: 0,
|
3553
|
-
icon_bg_color: -1762269,
|
3554
|
-
run_macro_when_pressed: false
|
3555
|
-
}
|
3556
|
-
|
3557
|
-
super(options.merge h)
|
3558
|
-
|
3559
|
-
end
|
3560
|
-
|
3561
|
-
end
|
3562
|
-
|
3563
|
-
# Category: Notifications
|
3564
|
-
#
|
3565
|
-
class AllowLEDNotificationLightAction < NotificationsAction
|
3566
|
-
|
3567
|
-
def initialize(h={})
|
3568
|
-
|
3569
|
-
options = {
|
3570
|
-
enabled: true
|
3571
|
-
}
|
3572
|
-
|
3573
|
-
super(options.merge h)
|
3574
|
-
|
3575
|
-
end
|
3576
|
-
|
3577
|
-
end
|
3578
|
-
|
3579
|
-
# Category: Notifications
|
3580
|
-
#
|
3581
|
-
class SetNotificationSoundAction < NotificationsAction
|
3582
|
-
|
3583
|
-
def initialize(h={})
|
3584
|
-
|
3585
|
-
options = {
|
3586
|
-
ringtone_uri: 'content://media/internal/audio/media/27'
|
3587
|
-
}
|
3588
|
-
|
3589
|
-
super(options.merge h)
|
3590
|
-
|
3591
|
-
end
|
3592
|
-
|
3593
|
-
end
|
3594
|
-
|
3595
|
-
# Category: Notifications
|
3596
|
-
#
|
3597
|
-
class SetNotificationSoundAction < NotificationsAction
|
3598
|
-
|
3599
|
-
def initialize(h={})
|
3600
|
-
|
3601
|
-
options = {
|
3602
|
-
ringtone_uri: 'content://media/internal/audio/media/51'
|
3603
|
-
}
|
3604
|
-
|
3605
|
-
super(options.merge h)
|
3606
|
-
|
3607
|
-
end
|
3608
|
-
|
3609
|
-
end
|
3610
|
-
|
3611
|
-
# Category: Notifications
|
3612
|
-
#
|
3613
|
-
class SetNotificationSoundAction < NotificationsAction
|
3614
|
-
|
3615
|
-
def initialize(h={})
|
3616
|
-
|
3617
|
-
options = {
|
3618
|
-
ringtone_name: 'None'
|
3619
|
-
}
|
3620
|
-
|
3621
|
-
super(options.merge h)
|
3622
|
-
|
3623
|
-
end
|
3624
|
-
|
3625
|
-
end
|
3626
|
-
|
3627
|
-
# Category: Notifications
|
3628
|
-
#
|
3629
|
-
class NotificationAction < NotificationsAction
|
3630
|
-
|
3631
|
-
def initialize(h={})
|
3632
|
-
|
3633
|
-
h[:notification_subject] = h[:subject] if h[:subject]
|
3634
|
-
h[:notification_text] = h[:text] if h[:text]
|
3635
|
-
|
3636
|
-
options = {
|
3637
|
-
ringtone_name: 'Default',
|
3638
|
-
notification_text: '',
|
3639
|
-
notification_subject: '',
|
3640
|
-
macro_guid_to_run: 0,
|
3641
|
-
notification_channel_type: 0,
|
3642
|
-
image_resource_id: 0,
|
3643
|
-
overwrite_existing: false,
|
3644
|
-
priority: 0,
|
3645
|
-
ringtone_index: 0,
|
3646
|
-
icon_bg_color: -1762269,
|
3647
|
-
run_macro_when_pressed: false
|
3648
|
-
}
|
3649
|
-
|
3650
|
-
super(options.merge filter(options, h))
|
3651
|
-
|
3652
|
-
end
|
3653
|
-
|
3654
|
-
def to_s()
|
3655
|
-
'Display Notification: ' + "%s: %s" % [@h[:notification_subject], @h[:notification_text]]
|
3656
|
-
end
|
3657
|
-
|
3658
|
-
end
|
3659
|
-
|
3660
|
-
# Category: Notifications
|
3661
|
-
#
|
3662
|
-
class ToastAction < NotificationsAction
|
3663
|
-
|
3664
|
-
def initialize(h={})
|
3665
|
-
|
3666
|
-
if h[:msg] then
|
3667
|
-
h[:message_text] = h[:msg]
|
3668
|
-
h.delete :msg
|
3669
|
-
end
|
3670
|
-
|
3671
|
-
options = {
|
3672
|
-
message_text: '',
|
3673
|
-
image_resource_name: 'launcher_no_border',
|
3674
|
-
image_package_name: 'com.arlosoft.macrodroid',
|
3675
|
-
image_name: 'launcher_no_border',
|
3676
|
-
duration: 0,
|
3677
|
-
display_icon: true,
|
3678
|
-
background_color: -12434878,
|
3679
|
-
position: 0
|
3680
|
-
}
|
3681
|
-
|
3682
|
-
super(options.merge h)
|
3683
|
-
|
3684
|
-
end
|
3685
|
-
|
3686
|
-
def invoke()
|
3687
|
-
super(@h[:message_text])
|
3688
|
-
end
|
3689
|
-
|
3690
|
-
def to_pc()
|
3691
|
-
"popup_message '%s'" % @h[:message_text]
|
3692
|
-
end
|
3693
|
-
|
3694
|
-
def to_s()
|
3695
|
-
"Popup Message '%s'" % @h[:message_text]
|
3696
|
-
end
|
3697
|
-
|
3698
|
-
end
|
3699
|
-
|
3700
|
-
|
3701
|
-
class PhoneAction < Action
|
3702
|
-
|
3703
|
-
def initialize(h={})
|
3704
|
-
super(h)
|
3705
|
-
@group = 'phone'
|
3706
|
-
end
|
3707
|
-
|
3708
|
-
end
|
3709
|
-
|
3710
|
-
# Category: Phone
|
3711
|
-
#
|
3712
|
-
class AnswerCallAction < PhoneAction
|
3713
|
-
|
3714
|
-
def initialize(h={})
|
3715
|
-
|
3716
|
-
options = {
|
3717
|
-
selected_index: 0
|
3718
|
-
}
|
3719
|
-
|
3720
|
-
super(options.merge h)
|
3721
|
-
|
3722
|
-
end
|
3723
|
-
|
3724
|
-
end
|
3725
|
-
|
3726
|
-
# Category: Phone
|
3727
|
-
#
|
3728
|
-
class ClearCallLogAction < PhoneAction
|
3729
|
-
|
3730
|
-
def initialize(h={})
|
3731
|
-
|
3732
|
-
options = {
|
3733
|
-
non_contact: false,
|
3734
|
-
specific_contact: false,
|
3735
|
-
type: 0
|
3736
|
-
}
|
3737
|
-
|
3738
|
-
super(options.merge h)
|
3739
|
-
|
3740
|
-
end
|
3741
|
-
|
3742
|
-
end
|
3743
|
-
|
3744
|
-
# Category: Phone
|
3745
|
-
#
|
3746
|
-
class OpenCallLogAction < PhoneAction
|
3747
|
-
|
3748
|
-
def initialize(h={})
|
3749
|
-
|
3750
|
-
options = {
|
3751
|
-
}
|
3752
|
-
|
3753
|
-
super(options.merge h)
|
3754
|
-
|
3755
|
-
end
|
3756
|
-
|
3757
|
-
end
|
3758
|
-
|
3759
|
-
# Category: Phone
|
3760
|
-
#
|
3761
|
-
class RejectCallAction < PhoneAction
|
3762
|
-
|
3763
|
-
def initialize(h={})
|
3764
|
-
|
3765
|
-
options = {
|
3766
|
-
}
|
3767
|
-
|
3768
|
-
super(options.merge h)
|
3769
|
-
|
3770
|
-
end
|
3771
|
-
|
3772
|
-
end
|
3773
|
-
|
3774
|
-
# Category: Phone
|
3775
|
-
#
|
3776
|
-
class MakeCallAction < PhoneAction
|
3777
|
-
|
3778
|
-
def initialize(h={})
|
3779
|
-
|
3780
|
-
options = {
|
3781
|
-
contact: {:m_id=>"Hardwired_Number", :m_lookupKey=>"Hardwired_Number", :m_name=>"[Select Number]"},
|
3782
|
-
number: ''
|
3783
|
-
}
|
3784
|
-
|
3785
|
-
super(options.merge h)
|
3786
|
-
|
3787
|
-
end
|
3788
|
-
|
3789
|
-
end
|
3790
|
-
|
3791
|
-
|
3792
|
-
# Category: Phone
|
3793
|
-
#
|
3794
|
-
class SetRingtoneAction < PhoneAction
|
3795
|
-
|
3796
|
-
def initialize(h={})
|
3797
|
-
|
3798
|
-
options = {
|
3799
|
-
ringtone_uri: 'content://media/internal/audio/media/174'
|
3800
|
-
}
|
3801
|
-
|
3802
|
-
super(options.merge h)
|
3803
|
-
|
3804
|
-
end
|
3805
|
-
|
3806
|
-
end
|
3807
|
-
|
3808
|
-
class ScreenAction < Action
|
3809
|
-
|
3810
|
-
def initialize(h={})
|
3811
|
-
super(h)
|
3812
|
-
@group = 'screen'
|
3813
|
-
end
|
3814
|
-
|
3815
|
-
end
|
3816
|
-
|
3817
|
-
# Category: Screen
|
3818
|
-
#
|
3819
|
-
class SetBrightnessAction < ScreenAction
|
3820
|
-
|
3821
|
-
def initialize(h={})
|
3822
|
-
|
3823
|
-
options = {
|
3824
|
-
brightness_percent: 81,
|
3825
|
-
force_pie_mode: false,
|
3826
|
-
brightness: 0
|
3827
|
-
}
|
3828
|
-
|
3829
|
-
super(options.merge h)
|
3830
|
-
|
3831
|
-
end
|
3832
|
-
|
3833
|
-
end
|
3834
|
-
|
3835
|
-
# Category: Screen
|
3836
|
-
#
|
3837
|
-
class ForceScreenRotationAction < ScreenAction
|
3838
|
-
|
3839
|
-
def initialize(h={})
|
3840
|
-
|
3841
|
-
options = {
|
3842
|
-
option: 0
|
3843
|
-
}
|
3844
|
-
|
3845
|
-
super(options.merge h)
|
3846
|
-
|
3847
|
-
end
|
3848
|
-
|
3849
|
-
end
|
3850
|
-
|
3851
|
-
# Category: Screen
|
3852
|
-
#
|
3853
|
-
class ScreenOnAction < ScreenAction
|
3854
|
-
|
3855
|
-
def initialize(h={})
|
3856
|
-
|
3857
|
-
options = {
|
3858
|
-
pie_lock_screen: false,
|
3859
|
-
screen_off: true,
|
3860
|
-
screen_off_no_lock: false,
|
3861
|
-
screen_on_alternative: false
|
3862
|
-
}
|
3863
|
-
|
3864
|
-
super(options.merge h)
|
3865
|
-
|
3866
|
-
end
|
3867
|
-
|
3868
|
-
end
|
3869
|
-
|
3870
|
-
# Category: Screen
|
3871
|
-
#
|
3872
|
-
class DimScreenAction < ScreenAction
|
3873
|
-
|
3874
|
-
def initialize(h={})
|
3875
|
-
|
3876
|
-
options = {
|
3877
|
-
percent: 50,
|
3878
|
-
dim_screen_on: true
|
3879
|
-
}
|
3880
|
-
|
3881
|
-
super(options.merge h)
|
3882
|
-
|
3883
|
-
end
|
3884
|
-
|
3885
|
-
end
|
3886
|
-
|
3887
|
-
# Category: Screen
|
3888
|
-
#
|
3889
|
-
# options:
|
3890
|
-
# keep awake, screen on => enabled: true
|
3891
|
-
# disable keep awake => enabled: false
|
3892
|
-
#
|
3893
|
-
class KeepAwakeAction < ScreenAction
|
3894
|
-
|
3895
|
-
def initialize(h={})
|
3896
|
-
|
3897
|
-
options = {
|
3898
|
-
enabled: true,
|
3899
|
-
permanent: true,
|
3900
|
-
screen_option: 0,
|
3901
|
-
seconds_to_stay_awake_for: 0
|
3902
|
-
}
|
3903
|
-
|
3904
|
-
super(options.merge h)
|
3905
|
-
|
3906
|
-
end
|
3907
|
-
|
3908
|
-
def to_s()
|
3909
|
-
|
3910
|
-
screen = @h[:screen_option] == 0 ? 'Screen On' : 'Screen Off'
|
3911
|
-
|
3912
|
-
if @h[:enabled] then
|
3913
|
-
|
3914
|
-
whenx = if @h[:seconds_to_stay_awake_for] == 0 then
|
3915
|
-
|
3916
|
-
'Until Disabled'
|
3917
|
-
|
3918
|
-
else
|
3919
|
-
scnds = @h[:seconds_to_stay_awake_for]
|
3920
|
-
Subunit.new(units={minutes:60, hours:60}, seconds: scnds).strfunit("%x")
|
3921
|
-
end
|
3922
|
-
|
3923
|
-
'Keep Device Awake ' + screen + ' ' + whenx
|
3924
|
-
|
3925
|
-
else
|
3926
|
-
'Disable Keep Awake'
|
3927
|
-
end
|
3928
|
-
|
3929
|
-
|
3930
|
-
end
|
3931
|
-
end
|
3932
|
-
|
3933
|
-
# Category: Screen
|
3934
|
-
#
|
3935
|
-
class SetScreenTimeoutAction < ScreenAction
|
3936
|
-
|
3937
|
-
def initialize(h={})
|
3938
|
-
|
3939
|
-
options = {
|
3940
|
-
timeout_delay_string: '1 Minute',
|
3941
|
-
timeout_delay: 60,
|
3942
|
-
custom_value_delay: 0
|
3943
|
-
}
|
3944
|
-
|
3945
|
-
super(options.merge h)
|
3946
|
-
|
3947
|
-
end
|
3948
|
-
|
3949
|
-
end
|
3950
|
-
|
3951
|
-
|
3952
|
-
class VolumeAction < Action
|
3953
|
-
|
3954
|
-
def initialize(h={})
|
3955
|
-
super(h)
|
3956
|
-
@group = 'volume'
|
3957
|
-
end
|
3958
|
-
|
3959
|
-
end
|
3960
|
-
|
3961
|
-
# Category: Volume
|
3962
|
-
#
|
3963
|
-
class SilentModeVibrateOffAction < VolumeAction
|
3964
|
-
|
3965
|
-
def initialize(h={})
|
3966
|
-
|
3967
|
-
options = {
|
3968
|
-
option: 1
|
3969
|
-
}
|
3970
|
-
|
3971
|
-
super(options.merge h)
|
3972
|
-
|
3973
|
-
end
|
3974
|
-
|
3975
|
-
end
|
3976
|
-
|
3977
|
-
# Category: Volume
|
3978
|
-
#
|
3979
|
-
class SetVibrateAction < VolumeAction
|
3980
|
-
|
3981
|
-
def initialize(h={})
|
3982
|
-
|
3983
|
-
options = {
|
3984
|
-
option: 'Silent (Vibrate On)',
|
3985
|
-
option_int: -1
|
3986
|
-
}
|
3987
|
-
|
3988
|
-
super(options.merge h)
|
3989
|
-
|
3990
|
-
end
|
3991
|
-
|
3992
|
-
end
|
3993
|
-
|
3994
|
-
# Category: Volume
|
3995
|
-
#
|
3996
|
-
class VolumeIncrementDecrementAction < VolumeAction
|
3997
|
-
|
3998
|
-
def initialize(h={})
|
3999
|
-
|
4000
|
-
options = {
|
4001
|
-
volume_up: true
|
4002
|
-
}
|
4003
|
-
|
4004
|
-
super(options.merge h)
|
4005
|
-
|
4006
|
-
end
|
4007
|
-
|
4008
|
-
end
|
4009
|
-
|
4010
|
-
# Category: Volume
|
4011
|
-
#
|
4012
|
-
class SpeakerPhoneAction < VolumeAction
|
4013
|
-
|
4014
|
-
def initialize(h={})
|
4015
|
-
|
4016
|
-
options = {
|
4017
|
-
secondary_class_type: 'SpeakerPhoneAction',
|
4018
|
-
state: 0
|
4019
|
-
}
|
4020
|
-
|
4021
|
-
super(options.merge h)
|
4022
|
-
|
4023
|
-
end
|
4024
|
-
|
4025
|
-
end
|
4026
|
-
|
4027
|
-
# Category: Volume
|
4028
|
-
#
|
4029
|
-
class SetVolumeAction < VolumeAction
|
4030
|
-
|
4031
|
-
def initialize(h={})
|
4032
|
-
|
4033
|
-
options = {
|
4034
|
-
variables: [nil, nil, nil, nil, nil, nil, nil],
|
4035
|
-
stream_index_array: [false, false, false, false, false, false, true],
|
4036
|
-
stream_volume_array: [0, 0, 0, 0, 0, 0, 66],
|
4037
|
-
force_vibrate_off: false,
|
4038
|
-
volume: -1
|
4039
|
-
}
|
4040
|
-
|
4041
|
-
super(options.merge h)
|
4042
|
-
|
4043
|
-
end
|
4044
|
-
|
4045
|
-
def to_s()
|
4046
|
-
volume = @h[:stream_index_array].zip(@h[:stream_volume_array]).to_h[true]
|
4047
|
-
'Volume Change ' + "Notification = %s%%" % volume
|
4048
|
-
end
|
4049
|
-
end
|
4050
|
-
|
4051
|
-
class Constraint < MacroObject
|
4052
|
-
|
4053
|
-
def initialize(h={})
|
4054
|
-
super(h)
|
4055
|
-
end
|
4056
|
-
|
4057
|
-
def match?(detail={}, model=nil)
|
4058
|
-
|
4059
|
-
detail.select {|k,v| @h.include? k }.all? {|key,value| @h[key] == value}
|
4060
|
-
|
4061
|
-
end
|
4062
|
-
|
4063
|
-
#def to_s()
|
4064
|
-
# ''
|
4065
|
-
#end
|
4066
|
-
|
4067
|
-
protected
|
4068
|
-
|
4069
|
-
def toggle_match?(key, val)
|
4070
|
-
|
4071
|
-
if @h[key] == true and val == key.to_s then
|
4072
|
-
true
|
4073
|
-
elsif @h[key] == false and val != key.to_s
|
4074
|
-
true
|
4075
|
-
else
|
4076
|
-
false
|
4077
|
-
end
|
4078
|
-
|
4079
|
-
end
|
4080
|
-
|
4081
|
-
end
|
4082
|
-
|
4083
|
-
class TimeOfDayConstraint < Constraint
|
4084
|
-
|
4085
|
-
def initialize(h={})
|
4086
|
-
|
4087
|
-
options = {
|
4088
|
-
end_hour: 8,
|
4089
|
-
end_minute: 0,
|
4090
|
-
start_hour: 22,
|
4091
|
-
start_minute: 0
|
4092
|
-
}
|
4093
|
-
|
4094
|
-
super(options.merge h)
|
4095
|
-
|
4096
|
-
end
|
4097
|
-
|
4098
|
-
end
|
4099
|
-
|
4100
|
-
# Category: Battery/Power
|
4101
|
-
#
|
4102
|
-
class BatteryLevelConstraint < Constraint
|
4103
|
-
|
4104
|
-
def initialize(h={})
|
4105
|
-
|
4106
|
-
options = {
|
4107
|
-
battery_level: 23,
|
4108
|
-
equals: false,
|
4109
|
-
greater_than: false
|
4110
|
-
}
|
4111
|
-
|
4112
|
-
super(options.merge h)
|
4113
|
-
|
4114
|
-
end
|
4115
|
-
|
4116
|
-
def to_s()
|
4117
|
-
|
4118
|
-
operator = if @h[:greater_than] then
|
4119
|
-
'>'
|
4120
|
-
elsif @h[:equals]
|
4121
|
-
'='
|
4122
|
-
else
|
4123
|
-
'<'
|
4124
|
-
end
|
4125
|
-
|
4126
|
-
level = @h[:battery_level]
|
4127
|
-
|
4128
|
-
"Battery %s %s%%" % [operator, level]
|
4129
|
-
end
|
4130
|
-
|
4131
|
-
end
|
4132
|
-
|
4133
|
-
# Category: Battery/Power
|
4134
|
-
#
|
4135
|
-
class BatterySaverStateConstraint < Constraint
|
4136
|
-
|
4137
|
-
def initialize(h={})
|
4138
|
-
|
4139
|
-
options = {
|
4140
|
-
option: 0
|
4141
|
-
}
|
4142
|
-
|
4143
|
-
super(options.merge h)
|
4144
|
-
|
4145
|
-
end
|
4146
|
-
|
4147
|
-
end
|
4148
|
-
|
4149
|
-
# Category: Battery/Power
|
4150
|
-
#
|
4151
|
-
class BatteryTemperatureConstraint < Constraint
|
4152
|
-
|
4153
|
-
def initialize(h={})
|
4154
|
-
|
4155
|
-
options = {
|
4156
|
-
equals: false,
|
4157
|
-
greater_than: false,
|
4158
|
-
temperature: 30
|
4159
|
-
}
|
4160
|
-
|
4161
|
-
super(options.merge h)
|
4162
|
-
|
4163
|
-
end
|
4164
|
-
|
4165
|
-
end
|
4166
|
-
|
4167
|
-
# Category: Battery/Power
|
4168
|
-
#
|
4169
|
-
class ExternalPowerConstraint < Constraint
|
4170
|
-
|
4171
|
-
def initialize(h={})
|
4172
|
-
|
4173
|
-
options = {
|
4174
|
-
external_power: true,
|
4175
|
-
power_connected_options: [false, true, false]
|
4176
|
-
}
|
4177
|
-
|
4178
|
-
super(options.merge h)
|
4179
|
-
|
4180
|
-
end
|
4181
|
-
|
4182
|
-
def to_s()
|
4183
|
-
connection = @h[:external_power] ? 'Connected' : 'Disconnected'
|
4184
|
-
'Power ' + connection
|
4185
|
-
end
|
4186
|
-
|
4187
|
-
end
|
4188
|
-
|
4189
|
-
# Category: Connectivity
|
4190
|
-
#
|
4191
|
-
class BluetoothConstraint < Constraint
|
4192
|
-
|
4193
|
-
def initialize(h={})
|
4194
|
-
|
4195
|
-
options = {
|
4196
|
-
any_device: false,
|
4197
|
-
bt_state: 0,
|
4198
|
-
device_name: 'Any Device'
|
4199
|
-
}
|
4200
|
-
|
4201
|
-
super(options.merge h)
|
4202
|
-
|
4203
|
-
end
|
4204
|
-
|
4205
|
-
def to_s()
|
4206
|
-
device = @h[:device_name] #== 'Any Device' ? 'Any' : @h[:device_name]
|
4207
|
-
"Device Connected (%s)" % device
|
4208
|
-
end
|
4209
|
-
|
4210
|
-
|
4211
|
-
end
|
4212
|
-
|
4213
|
-
# Category: Connectivity
|
4214
|
-
#
|
4215
|
-
class GPSEnabledConstraint < Constraint
|
4216
|
-
|
4217
|
-
def initialize(h={})
|
4218
|
-
|
4219
|
-
options = {
|
4220
|
-
enabled: true
|
4221
|
-
}
|
4222
|
-
|
4223
|
-
super(options.merge h)
|
4224
|
-
|
4225
|
-
end
|
4226
|
-
|
4227
|
-
end
|
4228
|
-
|
4229
|
-
# Category: Connectivity
|
4230
|
-
#
|
4231
|
-
class LocationModeConstraint < Constraint
|
4232
|
-
|
4233
|
-
def initialize(h={})
|
4234
|
-
|
4235
|
-
options = {
|
4236
|
-
options: [false, false, false, true]
|
4237
|
-
}
|
4238
|
-
|
4239
|
-
super(options.merge h)
|
4240
|
-
|
4241
|
-
end
|
4242
|
-
|
4243
|
-
end
|
4244
|
-
|
4245
|
-
# Category: Connectivity
|
4246
|
-
#
|
4247
|
-
class SignalOnOffConstraint < Constraint
|
4248
|
-
|
4249
|
-
def initialize(h={})
|
4250
|
-
|
4251
|
-
options = {
|
4252
|
-
option: 0
|
4253
|
-
}
|
4254
|
-
|
4255
|
-
super(options.merge h)
|
4256
|
-
|
4257
|
-
end
|
4258
|
-
|
4259
|
-
end
|
4260
|
-
|
4261
|
-
# Category: Connectivity
|
4262
|
-
#
|
4263
|
-
class WifiConstraint < Constraint
|
4264
|
-
|
4265
|
-
def initialize(h={})
|
4266
|
-
|
4267
|
-
options = {
|
4268
|
-
ssid_list: [],
|
4269
|
-
wifi_state: 0
|
4270
|
-
}
|
4271
|
-
|
4272
|
-
super(options.merge h)
|
4273
|
-
|
4274
|
-
end
|
4275
|
-
|
4276
|
-
end
|
4277
|
-
|
4278
|
-
# Category: Connectivity
|
4279
|
-
#
|
4280
|
-
class CellTowerConstraint < Constraint
|
4281
|
-
|
4282
|
-
def initialize(h={})
|
4283
|
-
|
4284
|
-
options = {
|
4285
|
-
cell_group_name: 'test group',
|
4286
|
-
cell_ids: ["524,14,41070731"],
|
4287
|
-
in_range: true
|
4288
|
-
}
|
4289
|
-
|
4290
|
-
super(options.merge h)
|
4291
|
-
|
4292
|
-
end
|
4293
|
-
|
4294
|
-
end
|
4295
|
-
|
4296
|
-
# Category: Connectivity
|
4297
|
-
#
|
4298
|
-
class IsRoamingConstraint < Constraint
|
4299
|
-
|
4300
|
-
def initialize(h={})
|
4301
|
-
|
4302
|
-
options = {
|
4303
|
-
is_roaming: true
|
4304
|
-
}
|
4305
|
-
|
4306
|
-
super(options.merge h)
|
4307
|
-
|
4308
|
-
end
|
4309
|
-
|
4310
|
-
end
|
4311
|
-
|
4312
|
-
# Category: Connectivity
|
4313
|
-
#
|
4314
|
-
class DataOnOffConstraint < Constraint
|
4315
|
-
|
4316
|
-
def initialize(h={})
|
4317
|
-
|
4318
|
-
options = {
|
4319
|
-
data_on: true
|
4320
|
-
}
|
4321
|
-
|
4322
|
-
super(options.merge h)
|
4323
|
-
|
4324
|
-
end
|
4325
|
-
|
4326
|
-
end
|
4327
|
-
|
4328
|
-
# Category: Connectivity
|
4329
|
-
#
|
4330
|
-
class WifiHotSpotConstraint < Constraint
|
4331
|
-
|
4332
|
-
def initialize(h={})
|
4333
|
-
|
4334
|
-
options = {
|
4335
|
-
check_connections: false,
|
4336
|
-
comparison_value: 0,
|
4337
|
-
connected_count: 0,
|
4338
|
-
enabled: true
|
4339
|
-
}
|
4340
|
-
|
4341
|
-
super(options.merge h)
|
4342
|
-
|
4343
|
-
end
|
4344
|
-
|
4345
|
-
end
|
4346
|
-
|
4347
|
-
# Category: Date/Time
|
4348
|
-
#
|
4349
|
-
class CalendarConstraint < Constraint
|
4350
|
-
|
4351
|
-
def initialize(h={})
|
4352
|
-
|
4353
|
-
options = {
|
4354
|
-
enable_regex: false,
|
4355
|
-
availability: 0,
|
4356
|
-
calendar_id: '1',
|
4357
|
-
calendar_name: 'PC Sync',
|
4358
|
-
detail_text: '',
|
4359
|
-
entry_set: true,
|
4360
|
-
ignore_all_day: false,
|
4361
|
-
title_text: ''
|
4362
|
-
}
|
4363
|
-
|
4364
|
-
super(options.merge h)
|
4365
|
-
|
4366
|
-
end
|
4367
|
-
|
4368
|
-
end
|
4369
|
-
|
4370
|
-
# Category: Date/Time
|
4371
|
-
#
|
4372
|
-
class DayOfWeekConstraint < Constraint
|
4373
|
-
|
4374
|
-
def initialize(h={})
|
4375
|
-
|
4376
|
-
options = {
|
4377
|
-
days_of_week: [false, false, true, false, false, false, false]
|
4378
|
-
}
|
4379
|
-
|
4380
|
-
super(options.merge h)
|
4381
|
-
|
4382
|
-
end
|
4383
|
-
|
4384
|
-
end
|
4385
|
-
|
4386
|
-
# Category: Date/Time
|
4387
|
-
#
|
4388
|
-
class TimeOfDayConstraint < Constraint
|
4389
|
-
|
4390
|
-
def initialize(h={})
|
4391
|
-
|
4392
|
-
options = {
|
4393
|
-
end_hour: 1,
|
4394
|
-
end_minute: 1,
|
4395
|
-
start_hour: 21,
|
4396
|
-
start_minute: 58
|
4397
|
-
}
|
4398
|
-
|
4399
|
-
super(options.merge h)
|
4400
|
-
|
4401
|
-
end
|
4402
|
-
|
4403
|
-
end
|
4404
|
-
|
4405
|
-
# Category: Date/Time
|
4406
|
-
#
|
4407
|
-
class DayOfMonthConstraint < Constraint
|
4408
|
-
|
4409
|
-
def initialize(h={})
|
4410
|
-
|
4411
|
-
options = {
|
4412
|
-
day_names: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31"],
|
4413
|
-
days_of_month: [false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]
|
4414
|
-
}
|
4415
|
-
|
4416
|
-
super(options.merge h)
|
4417
|
-
|
4418
|
-
end
|
4419
|
-
|
4420
|
-
end
|
4421
|
-
|
4422
|
-
# Category: Date/Time
|
4423
|
-
#
|
4424
|
-
class MonthOfYearConstraint < Constraint
|
4425
|
-
|
4426
|
-
def initialize(h={})
|
4427
|
-
|
4428
|
-
options = {
|
4429
|
-
months: [false, false, false, false, false, false, false, true, false, false, false, false]
|
4430
|
-
}
|
4431
|
-
|
4432
|
-
super(options.merge h)
|
4433
|
-
|
4434
|
-
end
|
4435
|
-
|
4436
|
-
end
|
4437
|
-
|
4438
|
-
# Category: Date/Time
|
4439
|
-
#
|
4440
|
-
class SunsetSunriseConstraint < Constraint
|
4441
|
-
|
4442
|
-
def initialize(h={})
|
4443
|
-
|
4444
|
-
options = {
|
4445
|
-
option: 0
|
4446
|
-
}
|
4447
|
-
|
4448
|
-
super(options.merge h)
|
4449
|
-
|
4450
|
-
end
|
4451
|
-
|
4452
|
-
end
|
4453
|
-
|
4454
|
-
# Category: Device State
|
4455
|
-
#
|
4456
|
-
class AirplaneModeConstraint < Constraint
|
4457
|
-
|
4458
|
-
def initialize(h={})
|
4459
|
-
|
4460
|
-
options = {
|
4461
|
-
enabled: true
|
4462
|
-
}
|
4463
|
-
|
4464
|
-
super(options.merge h)
|
4465
|
-
|
4466
|
-
end
|
4467
|
-
|
4468
|
-
def match?(detail={}, model=nil)
|
4469
|
-
|
4470
|
-
puts 'inside airplaneModeConstraint#match?' if $debug
|
4471
|
-
|
4472
|
-
if detail.has_key? :enabled then
|
4473
|
-
|
4474
|
-
puts 'detail has the key' if $debug
|
4475
|
-
super(detail)
|
4476
|
-
|
4477
|
-
elsif model
|
4478
|
-
|
4479
|
-
if $debug then
|
4480
|
-
puts 'checking the model'
|
4481
|
-
switch = model.connectivity.airplane_mode.switch
|
4482
|
-
puts 'switch: ' + switch.inspect
|
4483
|
-
end
|
4484
|
-
|
4485
|
-
toggle_match?(:enabled, switch)
|
4486
|
-
|
4487
|
-
end
|
4488
|
-
|
4489
|
-
end
|
4490
|
-
|
4491
|
-
def to_pc()
|
4492
|
-
status = @h[:enabled] ? 'enabled?' : 'disabled?'
|
4493
|
-
'airplane_mode.' + status
|
4494
|
-
end
|
4495
|
-
|
4496
|
-
def to_s()
|
4497
|
-
|
4498
|
-
status = @h[:enabled] ? 'Enabled' : 'Disabled'
|
4499
|
-
'Airplane Mode ' + status
|
4500
|
-
|
4501
|
-
end
|
4502
|
-
|
4503
|
-
end
|
4504
|
-
|
4505
|
-
# Category: Device State
|
4506
|
-
#
|
4507
|
-
class AutoRotateConstraint < Constraint
|
4508
|
-
|
4509
|
-
def initialize(h={})
|
4510
|
-
|
4511
|
-
options = {
|
4512
|
-
enabled: true
|
4513
|
-
}
|
4514
|
-
|
4515
|
-
super(options.merge h)
|
4516
|
-
|
4517
|
-
end
|
4518
|
-
|
4519
|
-
end
|
4520
|
-
|
4521
|
-
# Category: Device State
|
4522
|
-
#
|
4523
|
-
class DeviceLockedConstraint < Constraint
|
4524
|
-
|
4525
|
-
def initialize(h={})
|
4526
|
-
|
4527
|
-
options = {
|
4528
|
-
locked: true
|
4529
|
-
}
|
4530
|
-
|
4531
|
-
super(options.merge h)
|
4532
|
-
|
4533
|
-
end
|
4534
|
-
|
4535
|
-
def to_s()
|
4536
|
-
'Device ' + (@h[:locked] ? 'Locked' : 'Unlocked')
|
4537
|
-
end
|
4538
|
-
|
4539
|
-
end
|
4540
|
-
|
4541
|
-
# Category: Device State
|
4542
|
-
#
|
4543
|
-
class RoamingOnOffConstraint < Constraint
|
4544
|
-
|
4545
|
-
def initialize(h={})
|
4546
|
-
|
4547
|
-
options = {
|
4548
|
-
roaming_on: true
|
4549
|
-
}
|
4550
|
-
|
4551
|
-
super(options.merge h)
|
4552
|
-
|
4553
|
-
end
|
4554
|
-
|
4555
|
-
end
|
4556
|
-
|
4557
|
-
# Category: Device State
|
4558
|
-
#
|
4559
|
-
class TimeSinceBootConstraint < Constraint
|
4560
|
-
|
4561
|
-
def initialize(h={})
|
4562
|
-
|
4563
|
-
options = {
|
4564
|
-
less_than: true,
|
4565
|
-
time_period_seconds: 10921
|
4566
|
-
}
|
4567
|
-
|
4568
|
-
super(options.merge h)
|
4569
|
-
|
4570
|
-
end
|
4571
|
-
|
4572
|
-
end
|
4573
|
-
|
4574
|
-
# Category: Device State
|
4575
|
-
#
|
4576
|
-
class AutoSyncConstraint < Constraint
|
4577
|
-
|
4578
|
-
def initialize(h={})
|
4579
|
-
|
4580
|
-
options = {
|
4581
|
-
enabled: false
|
4582
|
-
}
|
4583
|
-
|
4584
|
-
super(options.merge h)
|
4585
|
-
|
4586
|
-
end
|
4587
|
-
|
4588
|
-
end
|
4589
|
-
|
4590
|
-
# Category: Device State
|
4591
|
-
#
|
4592
|
-
class NFCStateConstraint < Constraint
|
4593
|
-
|
4594
|
-
def initialize(h={})
|
4595
|
-
|
4596
|
-
options = {
|
4597
|
-
enabled: true
|
4598
|
-
}
|
4599
|
-
|
4600
|
-
super(options.merge h)
|
4601
|
-
|
4602
|
-
end
|
4603
|
-
|
4604
|
-
end
|
4605
|
-
|
4606
|
-
# Category: Device State
|
4607
|
-
#
|
4608
|
-
class IsRootedConstraint < Constraint
|
4609
|
-
|
4610
|
-
def initialize(h={})
|
4611
|
-
|
4612
|
-
options = {
|
4613
|
-
rooted: true
|
4614
|
-
}
|
4615
|
-
|
4616
|
-
super(options.merge h)
|
4617
|
-
|
4618
|
-
end
|
4619
|
-
|
4620
|
-
end
|
4621
|
-
|
4622
|
-
# Category: Device State
|
4623
|
-
#
|
4624
|
-
class VpnConstraint < Constraint
|
4625
|
-
|
4626
|
-
def initialize(h={})
|
4627
|
-
|
4628
|
-
options = {
|
4629
|
-
option: 0
|
4630
|
-
}
|
4631
|
-
|
4632
|
-
super(options.merge h)
|
4633
|
-
|
4634
|
-
end
|
4635
|
-
|
4636
|
-
end
|
4637
|
-
|
4638
|
-
# Category: MacroDroid Specific
|
4639
|
-
#
|
4640
|
-
class MacroEnabledConstraint < Constraint
|
4641
|
-
|
4642
|
-
def initialize(h={})
|
4643
|
-
|
4644
|
-
options = {
|
4645
|
-
enabled: true,
|
4646
|
-
macro_ids: [-8016812002629322290],
|
4647
|
-
macro_names: ["Intruder photo "]
|
4648
|
-
}
|
4649
|
-
|
4650
|
-
super(options.merge h)
|
4651
|
-
|
4652
|
-
end
|
4653
|
-
|
4654
|
-
end
|
4655
|
-
|
4656
|
-
# Category: MacroDroid Specific
|
4657
|
-
#
|
4658
|
-
class ModeConstraint < Constraint
|
4659
|
-
|
4660
|
-
def initialize(h={})
|
4661
|
-
|
4662
|
-
options = {
|
4663
|
-
mode: 'Away',
|
4664
|
-
mode_selected: true
|
4665
|
-
}
|
4666
|
-
|
4667
|
-
super(options.merge h)
|
4668
|
-
|
4669
|
-
end
|
4670
|
-
|
4671
|
-
end
|
4672
|
-
|
4673
|
-
# Category: MacroDroid Specific
|
4674
|
-
#
|
4675
|
-
class TriggerThatInvokedConstraint < Constraint
|
4676
|
-
using ColouredText
|
4677
|
-
|
4678
|
-
def initialize(h={})
|
4679
|
-
|
4680
|
-
puts ('h: ' + h.inspect).green
|
4681
|
-
@trigger = h[:macro].triggers.find {|x| x.siguid == h[:si_guid_that_invoked] }
|
4682
|
-
|
4683
|
-
options = {
|
4684
|
-
not: false,
|
4685
|
-
si_guid_that_invoked: -4951291100076165433,
|
4686
|
-
trigger_name: 'Shake Device'
|
4687
|
-
}
|
4688
|
-
|
4689
|
-
super(options.merge filter(options,h))
|
4690
|
-
|
4691
|
-
end
|
4692
|
-
|
4693
|
-
def to_s()
|
4694
|
-
'Trigger Fired: ' + @trigger.to_s
|
4695
|
-
end
|
4696
|
-
|
4697
|
-
end
|
4698
|
-
|
4699
|
-
# Category: MacroDroid Specific
|
4700
|
-
#
|
4701
|
-
class LastRunTimeConstraint < Constraint
|
4702
|
-
|
4703
|
-
def initialize(h={})
|
4704
|
-
|
4705
|
-
options = {
|
4706
|
-
check_this_macro: false,
|
4707
|
-
invoked: true,
|
4708
|
-
macro_ids: [-6922688338672048267],
|
4709
|
-
macro_names: ["Opendoor"],
|
4710
|
-
time_period_seconds: 7260
|
4711
|
-
}
|
4712
|
-
|
4713
|
-
super(options.merge h)
|
4714
|
-
|
4715
|
-
end
|
4716
|
-
|
4717
|
-
end
|
4718
|
-
|
4719
|
-
# Category: Media
|
4720
|
-
#
|
4721
|
-
class HeadphonesConnectionConstraint < Constraint
|
4722
|
-
|
4723
|
-
def initialize(h={})
|
4724
|
-
|
4725
|
-
options = {
|
4726
|
-
connected: true
|
4727
|
-
}
|
4728
|
-
|
4729
|
-
super(options.merge h)
|
4730
|
-
|
4731
|
-
end
|
4732
|
-
|
4733
|
-
def to_s()
|
4734
|
-
connection = @h[:connected] ? 'Connected' : 'Disconnected'
|
4735
|
-
'Headphones ' + connection
|
4736
|
-
end
|
4737
|
-
|
4738
|
-
end
|
4739
|
-
|
4740
|
-
# Category: Media
|
4741
|
-
#
|
4742
|
-
class MusicActiveConstraint < Constraint
|
4743
|
-
|
4744
|
-
def initialize(h={})
|
4745
|
-
|
4746
|
-
options = {
|
4747
|
-
music_active: true
|
4748
|
-
}
|
4749
|
-
|
4750
|
-
super(options.merge h)
|
4751
|
-
|
4752
|
-
end
|
4753
|
-
|
4754
|
-
end
|
4755
|
-
|
4756
|
-
# Category: Notification
|
4757
|
-
#
|
4758
|
-
class NotificationPresentConstraint < Constraint
|
4759
|
-
|
4760
|
-
def initialize(h={})
|
4761
|
-
|
4762
|
-
options = {
|
4763
|
-
enable_regex: false,
|
4764
|
-
application_name_list: ["All applications"],
|
4765
|
-
exact_match: false,
|
4766
|
-
excludes: false,
|
4767
|
-
excludes_apps: -1,
|
4768
|
-
option: 0,
|
4769
|
-
package_name_list: ["allApplications"],
|
4770
|
-
text_content: ''
|
4771
|
-
}
|
4772
|
-
|
4773
|
-
super(options.merge h)
|
4774
|
-
|
4775
|
-
end
|
4776
|
-
|
4777
|
-
end
|
4778
|
-
|
4779
|
-
# Category: Notification
|
4780
|
-
#
|
4781
|
-
class PriorityModeConstraint < Constraint
|
4782
|
-
|
4783
|
-
def initialize(h={})
|
4784
|
-
|
4785
|
-
options = {
|
4786
|
-
in_mode: true,
|
4787
|
-
selected_index: 0
|
4788
|
-
}
|
4789
|
-
|
4790
|
-
super(options.merge h)
|
4791
|
-
|
4792
|
-
end
|
4793
|
-
|
4794
|
-
end
|
4795
|
-
|
4796
|
-
# Category: Notification
|
4797
|
-
#
|
4798
|
-
class NotificationVolumeConstraint < Constraint
|
4799
|
-
|
4800
|
-
def initialize(h={})
|
4801
|
-
|
4802
|
-
options = {
|
4803
|
-
option: 1
|
4804
|
-
}
|
4805
|
-
|
4806
|
-
super(options.merge h)
|
4807
|
-
|
4808
|
-
end
|
4809
|
-
|
4810
|
-
end
|
4811
|
-
|
4812
|
-
# Category: Phone
|
4813
|
-
#
|
4814
|
-
class InCallConstraint < Constraint
|
4815
|
-
|
4816
|
-
def initialize(h={})
|
4817
|
-
|
4818
|
-
options = {
|
4819
|
-
in_call: true
|
4820
|
-
}
|
4821
|
-
|
4822
|
-
super(options.merge h)
|
4823
|
-
|
4824
|
-
end
|
4825
|
-
|
4826
|
-
end
|
4827
|
-
|
4828
|
-
# Category: Phone
|
4829
|
-
#
|
4830
|
-
class PhoneRingingConstraint < Constraint
|
4831
|
-
|
4832
|
-
def initialize(h={})
|
4833
|
-
|
4834
|
-
options = {
|
4835
|
-
ringing: true
|
4836
|
-
}
|
4837
|
-
|
4838
|
-
super(options.merge h)
|
4839
|
-
|
4840
|
-
end
|
4841
|
-
|
4842
|
-
end
|
4843
|
-
|
4844
|
-
# Category: Screen and Speaker
|
4845
|
-
#
|
4846
|
-
class BrightnessConstraint < Constraint
|
4847
|
-
|
4848
|
-
def initialize(h={})
|
4849
|
-
|
4850
|
-
options = {
|
4851
|
-
brightness: 35,
|
4852
|
-
equals: false,
|
4853
|
-
force_pie_mode: false,
|
4854
|
-
greater_than: false,
|
4855
|
-
is_auto_brightness: false
|
4856
|
-
}
|
4857
|
-
|
4858
|
-
super(options.merge h)
|
4859
|
-
|
4860
|
-
end
|
4861
|
-
|
4862
|
-
end
|
4863
|
-
|
4864
|
-
# Category: Screen and Speaker
|
4865
|
-
#
|
4866
|
-
class VolumeConstraint < Constraint
|
4867
|
-
|
4868
|
-
def initialize(h={})
|
4869
|
-
|
4870
|
-
options = {
|
4871
|
-
option: 0
|
4872
|
-
}
|
4873
|
-
|
4874
|
-
super(options.merge h)
|
4875
|
-
|
4876
|
-
end
|
4877
|
-
|
4878
|
-
end
|
4879
|
-
|
4880
|
-
# Category: Screen and Speaker
|
4881
|
-
#
|
4882
|
-
class SpeakerPhoneConstraint < Constraint
|
4883
|
-
|
4884
|
-
def initialize(h={})
|
4885
|
-
|
4886
|
-
options = {
|
4887
|
-
enabled: true
|
4888
|
-
}
|
4889
|
-
|
4890
|
-
super(options.merge h)
|
4891
|
-
|
4892
|
-
end
|
4893
|
-
|
4894
|
-
end
|
4895
|
-
|
4896
|
-
# Category: Screen and Speaker
|
4897
|
-
#
|
4898
|
-
class DarkThemeConstraint < Constraint
|
4899
|
-
|
4900
|
-
def initialize(h={})
|
4901
|
-
|
4902
|
-
options = {
|
4903
|
-
option: 0
|
4904
|
-
}
|
4905
|
-
|
4906
|
-
super(options.merge h)
|
4907
|
-
|
4908
|
-
end
|
4909
|
-
|
4910
|
-
end
|
4911
|
-
|
4912
|
-
# Category: Screen and Speaker
|
4913
|
-
#
|
4914
|
-
class ScreenOnOffConstraint < Constraint
|
4915
|
-
|
4916
|
-
def initialize(h={})
|
4917
|
-
|
4918
|
-
options = {
|
4919
|
-
a: true,
|
4920
|
-
screen_on: true
|
4921
|
-
}
|
4922
|
-
|
4923
|
-
super(options.merge h)
|
4924
|
-
|
4925
|
-
end
|
4926
|
-
|
4927
|
-
def to_s()
|
4928
|
-
'Screen ' + (@h[:screen_on] ? 'On' : 'Off')
|
4929
|
-
end
|
4930
|
-
|
4931
|
-
end
|
4932
|
-
|
4933
|
-
# Category: Screen and Speaker
|
4934
|
-
#
|
4935
|
-
class VolumeLevelConstraint < Constraint
|
4936
|
-
|
4937
|
-
def initialize(h={})
|
4938
|
-
|
4939
|
-
options = {
|
4940
|
-
comparison: 0,
|
4941
|
-
stream_index_array: [false, true, false, false, false, false, false],
|
4942
|
-
volume: 42
|
4943
|
-
}
|
4944
|
-
|
4945
|
-
super(options.merge h)
|
4946
|
-
|
4947
|
-
end
|
4948
|
-
|
4949
|
-
end
|
4950
|
-
|
4951
|
-
# Category: Sensors
|
4952
|
-
#
|
4953
|
-
class FaceUpDownConstraint < Constraint
|
4954
|
-
|
4955
|
-
def initialize(h={})
|
4956
|
-
|
4957
|
-
options = {
|
4958
|
-
option: -1,
|
4959
|
-
selected_options: [true, false, true, false, false, false]
|
4960
|
-
}
|
4961
|
-
|
4962
|
-
super(options.merge h)
|
4963
|
-
|
4964
|
-
end
|
4965
|
-
|
4966
|
-
end
|
4967
|
-
|
4968
|
-
# Category: Sensors
|
4969
|
-
#
|
4970
|
-
class LightLevelConstraint < Constraint
|
4971
|
-
|
4972
|
-
def initialize(h={})
|
4973
|
-
|
4974
|
-
options = {
|
4975
|
-
light_level: -1,
|
4976
|
-
light_level_float: 5000.0,
|
4977
|
-
option: 1
|
4978
|
-
}
|
4979
|
-
|
4980
|
-
super(options.merge h)
|
4981
|
-
|
4982
|
-
end
|
4983
|
-
|
4984
|
-
def to_s()
|
4985
|
-
|
4986
|
-
operator = @h[:light_level] == -1 ? 'Less than' : 'Greater than'
|
4987
|
-
condition = operator + ' ' + @h[:light_level_float].to_s + 'lx'
|
4988
|
-
'Light Sensor ' + condition
|
4989
|
-
|
4990
|
-
end
|
4991
|
-
|
4992
|
-
end
|
4993
|
-
|
4994
|
-
# Category: Sensors
|
4995
|
-
#
|
4996
|
-
class DeviceOrientationConstraint < Constraint
|
4997
|
-
|
4998
|
-
def initialize(h={})
|
4999
|
-
|
5000
|
-
options = {
|
5001
|
-
portrait: true
|
5002
|
-
}
|
5003
|
-
|
5004
|
-
super(options.merge h)
|
5005
|
-
|
5006
|
-
end
|
5007
|
-
|
5008
|
-
end
|
5009
|
-
|
5010
|
-
# Category: Sensors
|
5011
|
-
#
|
5012
|
-
class ProximitySensorConstraint < Constraint
|
5013
|
-
|
5014
|
-
def initialize(h={})
|
5015
|
-
|
5016
|
-
options = {
|
5017
|
-
near: true
|
5018
|
-
}
|
5019
|
-
|
5020
|
-
super(options.merge h)
|
5021
|
-
|
5022
|
-
end
|
5023
|
-
|
5024
|
-
def to_s()
|
5025
|
-
'Proximity Sensor: ' + (@h[:near] ? 'Near' : 'Far')
|
5026
|
-
end
|
5027
|
-
|
5028
|
-
end
|
5029
1036
|
|
5030
1037
|
|
5031
1038
|
# ----------------------------------------------------------------------------
|