ruby-macrodroid 0.7.3 → 0.7.8
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 +1251 -130
- metadata +16 -16
- 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: fb08c0b934e551a836b13053c11620701b999344e32c584ead58ed4ba09bc22e
|
4
|
+
data.tar.gz: 80b878ffc9dfa68ebe83e0d530a131b29610d7e0d3fa60cee0674ee5f2969c68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 534112f1b6685dc04c16ff80313bdef13a69c71bad370c4b1ac0fa9688a1605e3869d80e5e5edaab86db18b204726acbda1038070ad2b5de962ebc2d09d63dc7
|
7
|
+
data.tar.gz: cebc3aac1fc702c9e6bf21700fe983cb2e243b18458219a36f07131904b35ce983cdcaab8b5c244f5dfe171d1bdd14cd1643a71ffbf79a9701fb94776d94713c
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/ruby-macrodroid.rb
CHANGED
@@ -110,13 +110,11 @@
|
|
110
110
|
require 'yaml'
|
111
111
|
require 'rowx'
|
112
112
|
require 'uuid'
|
113
|
-
|
114
|
-
|
113
|
+
require 'glw'
|
114
|
+
require 'geozone'
|
115
|
+
require 'geocoder'
|
115
116
|
require 'subunit'
|
116
|
-
|
117
|
-
require 'requestor'
|
118
|
-
eval Requestor.read('http://a0.jamesrobertson.eu/rorb/r/ruby'){|x| x.require 'rxfhelper' }
|
119
|
-
|
117
|
+
require 'rxfhelper'
|
120
118
|
require 'chronic_cron'
|
121
119
|
|
122
120
|
|
@@ -138,6 +136,12 @@ class TriggersNlp
|
|
138
136
|
end
|
139
137
|
|
140
138
|
def triggers(params)
|
139
|
+
|
140
|
+
# e.g. at 7:30pm daily
|
141
|
+
get /^(?:at )?(\d+:\d+(?:[ap]m)?) daily/i do |time, days|
|
142
|
+
[TimerTrigger, {time: time,
|
143
|
+
days: %w(Mon Tue Wed Thu Fri Sat Sun).join(', ')}]
|
144
|
+
end
|
141
145
|
|
142
146
|
get /^(?:at )?(\d+:\d+(?:[ap]m)?) (?:on )?(.*)/i do |time, days|
|
143
147
|
[TimerTrigger, {time: time, days: days}]
|
@@ -146,7 +150,7 @@ class TriggersNlp
|
|
146
150
|
# time.is? 'at 18:30pm on Mon or Tue'
|
147
151
|
get /^time.is\? ['"](?:at )?(\d+:\d+(?:[ap]m)?) (?:on )?(.*)['"]/i do |time, days|
|
148
152
|
[TimerTrigger, {time: time, days: days.gsub(' or ',', ')}]
|
149
|
-
end
|
153
|
+
end
|
150
154
|
|
151
155
|
get /^shake[ _]device\??$/i do
|
152
156
|
[ShakeDeviceTrigger, {}]
|
@@ -196,6 +200,11 @@ class TriggersNlp
|
|
196
200
|
|
197
201
|
alias find_trigger run_route
|
198
202
|
|
203
|
+
def to_s(colour: false)
|
204
|
+
'TriggersNlp ' + @h.inspect
|
205
|
+
end
|
206
|
+
|
207
|
+
alias to_summary to_s
|
199
208
|
end
|
200
209
|
|
201
210
|
class ActionsNlp
|
@@ -315,6 +324,11 @@ class ActionsNlp
|
|
315
324
|
|
316
325
|
alias find_action run_route
|
317
326
|
|
327
|
+
def to_s(colour: false)
|
328
|
+
'ActionsNlp ' + @h.inspect
|
329
|
+
end
|
330
|
+
|
331
|
+
alias to_summary to_s
|
318
332
|
end
|
319
333
|
|
320
334
|
class ConstraintsNlp
|
@@ -469,7 +483,8 @@ class Macro
|
|
469
483
|
|
470
484
|
# fetch the triggers
|
471
485
|
@triggers = h[:trigger_list].map do |trigger|
|
472
|
-
|
486
|
+
puts 'trigger: ' + trigger.inspect
|
487
|
+
#exit
|
473
488
|
object(trigger.to_snake_case)
|
474
489
|
|
475
490
|
end
|
@@ -660,16 +675,24 @@ end
|
|
660
675
|
EOF
|
661
676
|
end
|
662
677
|
|
663
|
-
def to_s()
|
678
|
+
def to_s(colour: false)
|
664
679
|
|
665
680
|
indent = 0
|
666
681
|
actions = @actions.map do |x|
|
667
682
|
|
668
|
-
s = x.to_s
|
683
|
+
s = x.to_s(colour: colour)
|
684
|
+
if s.lines.length > 1 then
|
685
|
+
lines = s.lines
|
686
|
+
s = lines[0] + lines[1..-1].map {|x| x.prepend (' ' * indent) }.join
|
687
|
+
end
|
669
688
|
|
670
689
|
r = if indent <= 0 then
|
671
690
|
|
672
|
-
|
691
|
+
if colour then
|
692
|
+
"a".bg_blue.gray.bold + ": %s" % s
|
693
|
+
else
|
694
|
+
"a: %s" % s
|
695
|
+
end
|
673
696
|
|
674
697
|
elsif indent > 0
|
675
698
|
|
@@ -685,8 +708,15 @@ EOF
|
|
685
708
|
end
|
686
709
|
|
687
710
|
if s =~ /^If/i then
|
711
|
+
|
688
712
|
if indent < 1 then
|
689
|
-
|
713
|
+
|
714
|
+
r = if colour then
|
715
|
+
"a".bg_blue.gray.bold + ":\n %s" % s
|
716
|
+
else
|
717
|
+
"a:\n %s" % s
|
718
|
+
end
|
719
|
+
|
690
720
|
indent += 1
|
691
721
|
else
|
692
722
|
r = (' ' * indent) + "%s" % s
|
@@ -700,29 +730,59 @@ EOF
|
|
700
730
|
end.join("\n")
|
701
731
|
|
702
732
|
a = [
|
703
|
-
'm: ' + @title,
|
704
|
-
@triggers.map {|x| "t:
|
705
|
-
|
706
|
-
|
733
|
+
(colour ? "m".bg_cyan.gray.bold : 'm') + ': ' + @title,
|
734
|
+
@triggers.map {|x| (colour ? "t".bg_red.gray.bold : 't') \
|
735
|
+
+ ": %s" % x}.join("\n"),
|
736
|
+
actions
|
707
737
|
]
|
708
738
|
|
739
|
+
if @constraints.any? then
|
740
|
+
a << @constraints.map do |x|
|
741
|
+
(colour ? "c".bg_green.gray.bold : 'c') + ": %s" % x
|
742
|
+
end.join("\n")
|
743
|
+
end
|
744
|
+
|
709
745
|
if @description and @description.length >= 1 then
|
710
|
-
a.insert(1,
|
746
|
+
a.insert(1, (colour ? "d".bg_gray.gray.bold : 'd') + ': ' \
|
747
|
+
+ @description.gsub(/\n/,"\n "))
|
711
748
|
end
|
712
749
|
|
713
750
|
a.join("\n") + "\n"
|
714
751
|
|
715
752
|
end
|
716
753
|
|
717
|
-
def to_summary()
|
754
|
+
def to_summary(colour: false)
|
755
|
+
|
756
|
+
if colour then
|
757
|
+
|
758
|
+
a = [
|
759
|
+
'm'.bg_cyan.gray.bold + ': ' + @title,
|
760
|
+
't'.bg_red.gray.bold + ': ' + @triggers.map \
|
761
|
+
{|x| x.to_summary(colour: false)}.join(", "),
|
762
|
+
'a'.bg_blue.gray.bold + ': ' + @actions.map \
|
763
|
+
{|x| x.to_summary(colour: false)}.join(", ")
|
764
|
+
]
|
765
|
+
|
766
|
+
if @constraints.any? then
|
767
|
+
a << 'c'.bg_green.gray.bold + ': ' + @constraints.map \
|
768
|
+
{|x| x.to_summary(colour: false)}.join(", ")
|
769
|
+
end
|
770
|
+
|
771
|
+
else
|
772
|
+
|
773
|
+
a = [
|
774
|
+
'm: ' + @title,
|
775
|
+
't: ' + @triggers.map {|x| x.to_summary(colour: false)}.join(", "),
|
776
|
+
'a: ' + @actions.map {|x| x.to_summary(colour: false)}.join(", ")
|
777
|
+
]
|
778
|
+
|
779
|
+
if @constraints.any? then
|
780
|
+
a << 'c: ' + @constraints.map \
|
781
|
+
{|x| x.to_summary(colour: false)}.join(", ")
|
782
|
+
end
|
783
|
+
end
|
718
784
|
|
719
|
-
a = [
|
720
|
-
'm: ' + @title,
|
721
|
-
't: ' + @triggers.map(&:to_summary).join(", "),
|
722
|
-
'a: ' + @actions.map(&:to_summary).join(", "),
|
723
|
-
]
|
724
785
|
|
725
|
-
a << 'c: ' + @constraints.map(&:to_summary).join(", ") if @constraints.any?
|
726
786
|
|
727
787
|
a.join("\n") + "\n"
|
728
788
|
|
@@ -736,7 +796,7 @@ EOF
|
|
736
796
|
|
737
797
|
def object(h={})
|
738
798
|
|
739
|
-
puts ('inside object h:' + h.inspect).debug if @debug
|
799
|
+
puts ('inside object h:' + h.inspect).debug if @debug
|
740
800
|
klass = Object.const_get h[:class_type]
|
741
801
|
puts klass.inspect.highlight if $debug
|
742
802
|
|
@@ -744,7 +804,13 @@ EOF
|
|
744
804
|
puts 'GeofenceTrigger found'.highlight if $debug
|
745
805
|
GeofenceTrigger.new(h, geofences: @geofences)
|
746
806
|
else
|
747
|
-
klass
|
807
|
+
puts 'before klass'
|
808
|
+
h2 = h.merge( macro: self)
|
809
|
+
puts 'h2: ' + h2.inspect
|
810
|
+
r = klass.new h2
|
811
|
+
|
812
|
+
r
|
813
|
+
|
748
814
|
end
|
749
815
|
|
750
816
|
end
|
@@ -888,21 +954,22 @@ class MacroDroid
|
|
888
954
|
@macros.map(&:to_pc).join("\n\n")
|
889
955
|
end
|
890
956
|
|
891
|
-
def to_s()
|
957
|
+
def to_s(colour: false)
|
892
958
|
|
893
959
|
lines = []
|
894
960
|
|
895
961
|
if @geofences.any? then
|
896
|
-
lines << @geofences.map {|_, value|
|
962
|
+
lines << @geofences.map {|_, value| (colour ? "g".green.bold : 'g') \
|
963
|
+
+ ': ' + value.to_s}.join("\n\n") + "\n"
|
897
964
|
end
|
898
965
|
|
899
|
-
lines << @macros.map(
|
966
|
+
lines << @macros.map {|x| x.to_s(colour: colour)}.join("\n")
|
900
967
|
lines.join("\n")
|
901
968
|
|
902
969
|
end
|
903
970
|
|
904
|
-
def to_summary()
|
905
|
-
@macros.map(
|
971
|
+
def to_summary(colour: false)
|
972
|
+
@macros.map {|x| x.to_summary(colour: colour)}.join("\n")
|
906
973
|
end
|
907
974
|
|
908
975
|
private
|
@@ -914,13 +981,23 @@ class MacroDroid
|
|
914
981
|
name = e.text.to_s.strip
|
915
982
|
item = e.element('item')
|
916
983
|
coordinates = item.text('coordinates')
|
917
|
-
|
918
|
-
|
984
|
+
location = item.text('location')
|
985
|
+
|
986
|
+
if not coordinates and location then
|
987
|
+
results = Geocoder.search(location)
|
988
|
+
coordinates = results[0].coordinates.join(', ') if results.any?
|
989
|
+
end
|
990
|
+
|
991
|
+
if coordinates then
|
992
|
+
latitude, longitude = coordinates.split(/, */,2)
|
993
|
+
radius = item.text('radius')
|
994
|
+
end
|
919
995
|
|
920
996
|
id = UUID.new.generate
|
921
997
|
|
922
998
|
h = {
|
923
999
|
name: name,
|
1000
|
+
location: location,
|
924
1001
|
longitude: longitude,
|
925
1002
|
latitude: latitude,
|
926
1003
|
radius: radius,
|
@@ -1034,10 +1111,11 @@ class GeofenceMap
|
|
1034
1111
|
|
1035
1112
|
attr_accessor :name, :longitude, :latitude, :radius, :id
|
1036
1113
|
|
1037
|
-
def initialize(id: '', longitude: '', latitude: '', name: '', radius: ''
|
1114
|
+
def initialize(id: '', longitude: '', latitude: '', name: '', radius: '',
|
1115
|
+
location: nil)
|
1038
1116
|
|
1039
|
-
@id, @latitude, @longitude, @name, @radius = id, latitude, \
|
1040
|
-
longitude, name, radius
|
1117
|
+
@id, @latitude, @longitude, @name, @radius, @location = id, latitude, \
|
1118
|
+
longitude, name, radius, location
|
1041
1119
|
|
1042
1120
|
end
|
1043
1121
|
|
@@ -1053,10 +1131,15 @@ class GeofenceMap
|
|
1053
1131
|
|
1054
1132
|
end
|
1055
1133
|
|
1056
|
-
def to_s()
|
1134
|
+
def to_s(colour: false)
|
1057
1135
|
|
1058
|
-
|
1059
|
-
|
1136
|
+
lines = []
|
1137
|
+
coordinates = "%s, %s" % [@latitude, @longitude]
|
1138
|
+
lines << "%s" % @name
|
1139
|
+
lines << " location: %s" % @location if @location
|
1140
|
+
lines << " coordinates: %s" % coordinates
|
1141
|
+
lines << " radius: %s" % @radius
|
1142
|
+
lines.join("\n")
|
1060
1143
|
|
1061
1144
|
end
|
1062
1145
|
|
@@ -1065,15 +1148,16 @@ end
|
|
1065
1148
|
class MacroObject
|
1066
1149
|
using ColouredText
|
1067
1150
|
|
1068
|
-
attr_reader :type
|
1151
|
+
attr_reader :type, :siguid
|
1069
1152
|
attr_accessor :options
|
1070
1153
|
|
1071
1154
|
def initialize(h={})
|
1072
1155
|
|
1073
1156
|
$env ||= {}
|
1074
1157
|
|
1158
|
+
@attributes = %i(constraint_list is_or_condition is_disabled siguid)
|
1075
1159
|
@h = {constraint_list: [], is_or_condition: false,
|
1076
|
-
is_disabled: false}.merge(h)
|
1160
|
+
is_disabled: false, siguid: nil}.merge(h)
|
1077
1161
|
@list = []
|
1078
1162
|
|
1079
1163
|
# fetch the class name and convert from camelCase to snake_eyes
|
@@ -1081,6 +1165,7 @@ class MacroObject
|
|
1081
1165
|
.gsub(/\B[A-Z][a-z]/){|x| '_' + x.downcase}\
|
1082
1166
|
.gsub(/[a-z][A-Z]/){|x| x[0] + '_' + x[1].downcase}\
|
1083
1167
|
.downcase.to_sym
|
1168
|
+
@constraints = []
|
1084
1169
|
end
|
1085
1170
|
|
1086
1171
|
def to_h()
|
@@ -1101,8 +1186,21 @@ class MacroObject
|
|
1101
1186
|
|
1102
1187
|
end
|
1103
1188
|
|
1104
|
-
def
|
1105
|
-
|
1189
|
+
def siguid()
|
1190
|
+
@h[:siguid]
|
1191
|
+
end
|
1192
|
+
|
1193
|
+
def to_s(colour: false)
|
1194
|
+
|
1195
|
+
h = @h.clone
|
1196
|
+
h.delete :macro
|
1197
|
+
@s ||= "#<%s %s>" % [self.class, h.inspect]
|
1198
|
+
operator = @h[:is_or_condition] ? 'OR' : 'AND'
|
1199
|
+
constraints = @constraints.map \
|
1200
|
+
{|x| x.to_summary(colour: colour)}.join(" %s " % operator)
|
1201
|
+
|
1202
|
+
@s + constraints
|
1203
|
+
|
1106
1204
|
end
|
1107
1205
|
|
1108
1206
|
alias to_summary to_s
|
@@ -1111,7 +1209,7 @@ class MacroObject
|
|
1111
1209
|
|
1112
1210
|
def filter(options, h)
|
1113
1211
|
|
1114
|
-
(h.keys - options.keys).each {|key| h.delete key }
|
1212
|
+
(h.keys - (options.keys + @attributes.to_a)).each {|key| h.delete key }
|
1115
1213
|
return h
|
1116
1214
|
|
1117
1215
|
end
|
@@ -1142,7 +1240,7 @@ class Trigger < MacroObject
|
|
1142
1240
|
@list << 'fakeIcon'
|
1143
1241
|
|
1144
1242
|
# fetch the constraints
|
1145
|
-
@constraints = h[:constraint_list].map do |constraint|
|
1243
|
+
@constraints = @h[:constraint_list].map do |constraint|
|
1146
1244
|
object(constraint.to_snake_case)
|
1147
1245
|
end
|
1148
1246
|
|
@@ -1172,6 +1270,11 @@ class WebHookTrigger < Trigger
|
|
1172
1270
|
|
1173
1271
|
end
|
1174
1272
|
|
1273
|
+
def to_s(colour: false)
|
1274
|
+
'WebHookTrigger ' + @h.inspect
|
1275
|
+
end
|
1276
|
+
|
1277
|
+
alias to_summary to_s
|
1175
1278
|
end
|
1176
1279
|
|
1177
1280
|
# Category: Applications
|
@@ -1203,6 +1306,11 @@ class WifiConnectionTrigger < Trigger
|
|
1203
1306
|
|
1204
1307
|
end
|
1205
1308
|
|
1309
|
+
def to_s(colour: false)
|
1310
|
+
'WifiConnectionTrigger ' + @h.inspect
|
1311
|
+
end
|
1312
|
+
|
1313
|
+
alias to_summary to_s
|
1206
1314
|
end
|
1207
1315
|
|
1208
1316
|
# Category: Applications
|
@@ -1223,6 +1331,11 @@ class ApplicationInstalledRemovedTrigger < Trigger
|
|
1223
1331
|
|
1224
1332
|
end
|
1225
1333
|
|
1334
|
+
def to_s(colour: false)
|
1335
|
+
'ApplicationInstalledRemovedTrigger ' + @h.inspect
|
1336
|
+
end
|
1337
|
+
|
1338
|
+
alias to_summary to_s
|
1226
1339
|
end
|
1227
1340
|
|
1228
1341
|
# Category: Applications
|
@@ -1241,6 +1354,11 @@ class ApplicationLaunchedTrigger < Trigger
|
|
1241
1354
|
|
1242
1355
|
end
|
1243
1356
|
|
1357
|
+
def to_s(colour: false)
|
1358
|
+
'ApplicationLaunchedTrigger ' + @h.inspect
|
1359
|
+
end
|
1360
|
+
|
1361
|
+
alias to_summary to_s
|
1244
1362
|
end
|
1245
1363
|
|
1246
1364
|
# Category: Battery/Power
|
@@ -1259,7 +1377,7 @@ class BatteryLevelTrigger < Trigger
|
|
1259
1377
|
|
1260
1378
|
end
|
1261
1379
|
|
1262
|
-
def to_s()
|
1380
|
+
def to_s(colour: false)
|
1263
1381
|
operator = @h[:decreases_to] ? '<=' : '>='
|
1264
1382
|
"Battery %s %s%%" % [operator, @h[:battery_level]]
|
1265
1383
|
end
|
@@ -1282,6 +1400,11 @@ class BatteryTemperatureTrigger < Trigger
|
|
1282
1400
|
|
1283
1401
|
end
|
1284
1402
|
|
1403
|
+
def to_s(colour: false)
|
1404
|
+
'BatteryTemperatureTrigger ' + @h.inspect
|
1405
|
+
end
|
1406
|
+
|
1407
|
+
alias to_summary to_s
|
1285
1408
|
end
|
1286
1409
|
|
1287
1410
|
# Category: Battery/Power
|
@@ -1298,6 +1421,11 @@ class PowerButtonToggleTrigger < Trigger
|
|
1298
1421
|
|
1299
1422
|
end
|
1300
1423
|
|
1424
|
+
def to_s(colour: false)
|
1425
|
+
'PowerButtonToggleTrigger ' + @h.inspect
|
1426
|
+
end
|
1427
|
+
|
1428
|
+
alias to_summary to_s
|
1301
1429
|
end
|
1302
1430
|
|
1303
1431
|
|
@@ -1317,6 +1445,27 @@ class ExternalPowerTrigger < Trigger
|
|
1317
1445
|
super(options.merge h)
|
1318
1446
|
|
1319
1447
|
end
|
1448
|
+
|
1449
|
+
def to_s(colour: false)
|
1450
|
+
|
1451
|
+
return 'Power Disconnected' unless @h[:power_connected]
|
1452
|
+
|
1453
|
+
status = 'Power Connectd'
|
1454
|
+
options = if @h[:power_connected_options].all? then
|
1455
|
+
'Any'
|
1456
|
+
else
|
1457
|
+
|
1458
|
+
a = ['Wired (Fast Charge)', 'Wireless', 'Wired (Slow Charge)']
|
1459
|
+
@h[:power_connected_options].map.with_index {|x,i| x ? i : nil}\
|
1460
|
+
.compact.map {|i| a[i] }.join(' + ')
|
1461
|
+
|
1462
|
+
end
|
1463
|
+
|
1464
|
+
"%s: %s" % [status, options]
|
1465
|
+
|
1466
|
+
end
|
1467
|
+
|
1468
|
+
alias to_summary to_s
|
1320
1469
|
|
1321
1470
|
end
|
1322
1471
|
|
@@ -1336,6 +1485,11 @@ class CallActiveTrigger < Trigger
|
|
1336
1485
|
|
1337
1486
|
end
|
1338
1487
|
|
1488
|
+
def to_s(colour: false)
|
1489
|
+
'CallActiveTrigger ' + @h.inspect
|
1490
|
+
end
|
1491
|
+
|
1492
|
+
alias to_summary to_s
|
1339
1493
|
end
|
1340
1494
|
|
1341
1495
|
# Category: Call/SMS
|
@@ -1356,6 +1510,11 @@ class IncomingCallTrigger < Trigger
|
|
1356
1510
|
|
1357
1511
|
end
|
1358
1512
|
|
1513
|
+
def to_s(colour: false)
|
1514
|
+
'IncomingCallTrigger ' + @h.inspect
|
1515
|
+
end
|
1516
|
+
|
1517
|
+
alias to_summary to_s
|
1359
1518
|
end
|
1360
1519
|
|
1361
1520
|
# Category: Call/SMS
|
@@ -1376,6 +1535,11 @@ class OutgoingCallTrigger < Trigger
|
|
1376
1535
|
|
1377
1536
|
end
|
1378
1537
|
|
1538
|
+
def to_s(colour: false)
|
1539
|
+
'OutgoingCallTrigger ' + @h.inspect
|
1540
|
+
end
|
1541
|
+
|
1542
|
+
alias to_summary to_s
|
1379
1543
|
end
|
1380
1544
|
|
1381
1545
|
# Category: Call/SMS
|
@@ -1396,6 +1560,11 @@ class CallEndedTrigger < Trigger
|
|
1396
1560
|
|
1397
1561
|
end
|
1398
1562
|
|
1563
|
+
def to_s(colour: false)
|
1564
|
+
'CallEndedTrigger ' + @h.inspect
|
1565
|
+
end
|
1566
|
+
|
1567
|
+
alias to_summary to_s
|
1399
1568
|
end
|
1400
1569
|
|
1401
1570
|
# Category: Call/SMS
|
@@ -1412,6 +1581,11 @@ class CallMissedTrigger < Trigger
|
|
1412
1581
|
|
1413
1582
|
end
|
1414
1583
|
|
1584
|
+
def to_s(colour: false)
|
1585
|
+
'CallMissedTrigger ' + @h.inspect
|
1586
|
+
end
|
1587
|
+
|
1588
|
+
alias to_summary to_s
|
1415
1589
|
end
|
1416
1590
|
|
1417
1591
|
# Category: Call/SMS
|
@@ -1436,6 +1610,11 @@ class IncomingSMSTrigger < Trigger
|
|
1436
1610
|
|
1437
1611
|
end
|
1438
1612
|
|
1613
|
+
def to_s(colour: false)
|
1614
|
+
'IncomingSMSTrigger ' + @h.inspect
|
1615
|
+
end
|
1616
|
+
|
1617
|
+
alias to_summary to_s
|
1439
1618
|
end
|
1440
1619
|
|
1441
1620
|
# Category: Connectivity
|
@@ -1452,6 +1631,11 @@ class WebHookTrigger < Trigger
|
|
1452
1631
|
|
1453
1632
|
end
|
1454
1633
|
|
1634
|
+
def to_s(colour: false)
|
1635
|
+
'WebHookTrigger ' + @h.inspect
|
1636
|
+
end
|
1637
|
+
|
1638
|
+
alias to_summary to_s
|
1455
1639
|
end
|
1456
1640
|
|
1457
1641
|
# Category: Connectivity
|
@@ -1469,6 +1653,11 @@ class WifiConnectionTrigger < Trigger
|
|
1469
1653
|
|
1470
1654
|
end
|
1471
1655
|
|
1656
|
+
def to_s(colour: false)
|
1657
|
+
'WifiConnectionTrigger ' + @h.inspect
|
1658
|
+
end
|
1659
|
+
|
1660
|
+
alias to_summary to_s
|
1472
1661
|
end
|
1473
1662
|
|
1474
1663
|
# Category: Connectivity
|
@@ -1487,6 +1676,11 @@ class BluetoothTrigger < Trigger
|
|
1487
1676
|
|
1488
1677
|
end
|
1489
1678
|
|
1679
|
+
def to_s(colour: false)
|
1680
|
+
'BluetoothTrigger ' + @h.inspect
|
1681
|
+
end
|
1682
|
+
|
1683
|
+
alias to_summary to_s
|
1490
1684
|
end
|
1491
1685
|
|
1492
1686
|
# Category: Connectivity
|
@@ -1504,6 +1698,11 @@ class HeadphonesTrigger < Trigger
|
|
1504
1698
|
|
1505
1699
|
end
|
1506
1700
|
|
1701
|
+
def to_s(colour: false)
|
1702
|
+
'HeadphonesTrigger ' + @h.inspect
|
1703
|
+
end
|
1704
|
+
|
1705
|
+
alias to_summary to_s
|
1507
1706
|
end
|
1508
1707
|
|
1509
1708
|
# Category: Connectivity
|
@@ -1520,6 +1719,11 @@ class SignalOnOffTrigger < Trigger
|
|
1520
1719
|
|
1521
1720
|
end
|
1522
1721
|
|
1722
|
+
def to_s(colour: false)
|
1723
|
+
'SignalOnOffTrigger ' + @h.inspect
|
1724
|
+
end
|
1725
|
+
|
1726
|
+
alias to_summary to_s
|
1523
1727
|
end
|
1524
1728
|
|
1525
1729
|
# Category: Connectivity
|
@@ -1536,6 +1740,11 @@ class UsbDeviceConnectionTrigger < Trigger
|
|
1536
1740
|
|
1537
1741
|
end
|
1538
1742
|
|
1743
|
+
def to_s(colour: false)
|
1744
|
+
'UsbDeviceConnectionTrigger ' + @h.inspect
|
1745
|
+
end
|
1746
|
+
|
1747
|
+
alias to_summary to_s
|
1539
1748
|
end
|
1540
1749
|
|
1541
1750
|
# Category: Connectivity
|
@@ -1573,6 +1782,11 @@ class WifiSSIDTrigger < Trigger
|
|
1573
1782
|
|
1574
1783
|
end
|
1575
1784
|
|
1785
|
+
def to_s(colour: false)
|
1786
|
+
'WifiSSIDTrigger ' + @h.inspect
|
1787
|
+
end
|
1788
|
+
|
1789
|
+
alias to_summary to_s
|
1576
1790
|
end
|
1577
1791
|
|
1578
1792
|
# Category: Date/Time
|
@@ -1599,6 +1813,11 @@ class CalendarTrigger < Trigger
|
|
1599
1813
|
|
1600
1814
|
end
|
1601
1815
|
|
1816
|
+
def to_s(colour: false)
|
1817
|
+
'CalendarTrigger ' + @h.inspect
|
1818
|
+
end
|
1819
|
+
|
1820
|
+
alias to_summary to_s
|
1602
1821
|
end
|
1603
1822
|
|
1604
1823
|
# Category: Date/Time
|
@@ -1636,7 +1855,7 @@ class TimerTrigger < Trigger
|
|
1636
1855
|
|
1637
1856
|
#puts ('h: ' + h.inspect).debug
|
1638
1857
|
|
1639
|
-
options = {
|
1858
|
+
@options = {
|
1640
1859
|
alarm_id: uuid(),
|
1641
1860
|
days_of_week: [false, false, false, false, false, false, false],
|
1642
1861
|
minute: 10,
|
@@ -1644,7 +1863,8 @@ class TimerTrigger < Trigger
|
|
1644
1863
|
use_alarm: false
|
1645
1864
|
}
|
1646
1865
|
|
1647
|
-
super(options.merge filter(options, h))
|
1866
|
+
#super(options.merge filter(options, h))
|
1867
|
+
super(@options.merge h)
|
1648
1868
|
|
1649
1869
|
end
|
1650
1870
|
|
@@ -1664,18 +1884,38 @@ class TimerTrigger < Trigger
|
|
1664
1884
|
"time.is? '%s'" % self.to_s.gsub(',', ' or')
|
1665
1885
|
end
|
1666
1886
|
|
1667
|
-
def to_s()
|
1887
|
+
def to_s(colour: false)
|
1668
1888
|
|
1669
|
-
dow = @h[:days_of_week]
|
1670
|
-
|
1671
|
-
a = Date::ABBR_DAYNAMES
|
1889
|
+
dow = @h[:days_of_week]
|
1672
1890
|
|
1673
|
-
|
1674
|
-
|
1891
|
+
wd = Date::ABBR_DAYNAMES
|
1892
|
+
a = (wd[1..-1] << wd.first)
|
1893
|
+
|
1894
|
+
a2 = dow.map.with_index.to_a
|
1895
|
+
start = a2.find {|x,i| x}.last
|
1896
|
+
r = a2[start..-1].take_while {|x,i| x == true}
|
1897
|
+
r2 = a2[start..-1].select {|x,i| x}
|
1898
|
+
|
1899
|
+
days = if r == r2 then
|
1675
1900
|
|
1676
|
-
|
1901
|
+
x1, x2 = a2[start].last, a2[r.length-1].last
|
1902
|
+
|
1903
|
+
if (x2 - x1) >= 2 then
|
1904
|
+
"%s-%s" % [a[x1],a[x2]]
|
1905
|
+
else
|
1906
|
+
a.zip(dow).select {|_,b| b}.map(&:first).join(', ')
|
1907
|
+
end
|
1908
|
+
else
|
1909
|
+
a.zip(dow).select {|_,b| b}.map(&:first).join(', ')
|
1910
|
+
end
|
1911
|
+
|
1912
|
+
time = Time.parse("%s:%s" % [@h[:hour], @h[:minute]]).strftime("%H:%M")
|
1913
|
+
|
1914
|
+
"%s %s" % [time, days]
|
1677
1915
|
end
|
1678
1916
|
|
1917
|
+
alias to_summary to_s
|
1918
|
+
|
1679
1919
|
private
|
1680
1920
|
|
1681
1921
|
def time()
|
@@ -1707,6 +1947,11 @@ class StopwatchTrigger < Trigger
|
|
1707
1947
|
|
1708
1948
|
end
|
1709
1949
|
|
1950
|
+
def to_s(colour: false)
|
1951
|
+
'StopwatchTrigger ' + @h.inspect
|
1952
|
+
end
|
1953
|
+
|
1954
|
+
alias to_summary to_s
|
1710
1955
|
end
|
1711
1956
|
|
1712
1957
|
# Category: Date/Time
|
@@ -1735,6 +1980,11 @@ class DayTrigger < Trigger
|
|
1735
1980
|
|
1736
1981
|
end
|
1737
1982
|
|
1983
|
+
def to_s(colour: false)
|
1984
|
+
'DayTrigger ' + @h.inspect
|
1985
|
+
end
|
1986
|
+
|
1987
|
+
alias to_summary to_s
|
1738
1988
|
end
|
1739
1989
|
|
1740
1990
|
# Category: Date/Time
|
@@ -1758,6 +2008,11 @@ class RegularIntervalTrigger < Trigger
|
|
1758
2008
|
|
1759
2009
|
end
|
1760
2010
|
|
2011
|
+
def to_s(colour: false)
|
2012
|
+
'RegularIntervalTrigger ' + @h.inspect
|
2013
|
+
end
|
2014
|
+
|
2015
|
+
alias to_summary to_s
|
1761
2016
|
end
|
1762
2017
|
|
1763
2018
|
class DeviceEventsTrigger < Trigger
|
@@ -1792,6 +2047,11 @@ class AirplaneModeTrigger < DeviceEventsTrigger
|
|
1792
2047
|
|
1793
2048
|
end
|
1794
2049
|
|
2050
|
+
def to_s(colour: false)
|
2051
|
+
'AirplaneModeTrigger ' + @h.inspect
|
2052
|
+
end
|
2053
|
+
|
2054
|
+
alias to_summary to_s
|
1795
2055
|
end
|
1796
2056
|
|
1797
2057
|
# Category: Device Events
|
@@ -1808,6 +2068,11 @@ class AutoSyncChangeTrigger < DeviceEventsTrigger
|
|
1808
2068
|
|
1809
2069
|
end
|
1810
2070
|
|
2071
|
+
def to_s(colour: false)
|
2072
|
+
'AutoSyncChangeTrigger ' + @h.inspect
|
2073
|
+
end
|
2074
|
+
|
2075
|
+
alias to_summary to_s
|
1811
2076
|
end
|
1812
2077
|
|
1813
2078
|
# Category: Device Events
|
@@ -1824,6 +2089,11 @@ class DayDreamTrigger < DeviceEventsTrigger
|
|
1824
2089
|
|
1825
2090
|
end
|
1826
2091
|
|
2092
|
+
def to_s(colour: false)
|
2093
|
+
'DayDreamTrigger ' + @h.inspect
|
2094
|
+
end
|
2095
|
+
|
2096
|
+
alias to_summary to_s
|
1827
2097
|
end
|
1828
2098
|
|
1829
2099
|
# Category: Device Events
|
@@ -1840,6 +2110,11 @@ class DockTrigger < DeviceEventsTrigger
|
|
1840
2110
|
|
1841
2111
|
end
|
1842
2112
|
|
2113
|
+
def to_s(colour: false)
|
2114
|
+
'DockTrigger ' + @h.inspect
|
2115
|
+
end
|
2116
|
+
|
2117
|
+
alias to_summary to_s
|
1843
2118
|
end
|
1844
2119
|
|
1845
2120
|
# Category: Device Events
|
@@ -1860,7 +2135,7 @@ class FailedLoginTrigger < DeviceEventsTrigger
|
|
1860
2135
|
'failed_login?'
|
1861
2136
|
end
|
1862
2137
|
|
1863
|
-
def to_s()
|
2138
|
+
def to_s(colour: false)
|
1864
2139
|
'Failed Login Attempt'
|
1865
2140
|
end
|
1866
2141
|
end
|
@@ -1879,6 +2154,11 @@ class GPSEnabledTrigger < DeviceEventsTrigger
|
|
1879
2154
|
|
1880
2155
|
end
|
1881
2156
|
|
2157
|
+
def to_s(colour: false)
|
2158
|
+
'GPSEnabledTrigger ' + @h.inspect
|
2159
|
+
end
|
2160
|
+
|
2161
|
+
alias to_summary to_s
|
1882
2162
|
end
|
1883
2163
|
|
1884
2164
|
# Category: Device Events
|
@@ -1895,6 +2175,11 @@ class MusicPlayingTrigger < DeviceEventsTrigger
|
|
1895
2175
|
|
1896
2176
|
end
|
1897
2177
|
|
2178
|
+
def to_s(colour: false)
|
2179
|
+
'MusicPlayingTrigger ' + @h.inspect
|
2180
|
+
end
|
2181
|
+
|
2182
|
+
alias to_summary to_s
|
1898
2183
|
end
|
1899
2184
|
|
1900
2185
|
|
@@ -1911,9 +2196,11 @@ class DeviceUnlockedTrigger < DeviceEventsTrigger
|
|
1911
2196
|
|
1912
2197
|
end
|
1913
2198
|
|
1914
|
-
def to_s()
|
2199
|
+
def to_s(colour: false)
|
1915
2200
|
'Screen Unlocked'
|
1916
2201
|
end
|
2202
|
+
|
2203
|
+
alias to_summary to_s
|
1917
2204
|
|
1918
2205
|
end
|
1919
2206
|
|
@@ -1931,6 +2218,11 @@ class AutoRotateChangeTrigger < DeviceEventsTrigger
|
|
1931
2218
|
|
1932
2219
|
end
|
1933
2220
|
|
2221
|
+
def to_s(colour: false)
|
2222
|
+
'AutoRotateChangeTrigger ' + @h.inspect
|
2223
|
+
end
|
2224
|
+
|
2225
|
+
alias to_summary to_s
|
1934
2226
|
end
|
1935
2227
|
|
1936
2228
|
# Category: Device Events
|
@@ -1948,6 +2240,11 @@ class ClipboardChangeTrigger < DeviceEventsTrigger
|
|
1948
2240
|
|
1949
2241
|
end
|
1950
2242
|
|
2243
|
+
def to_s(colour: false)
|
2244
|
+
'ClipboardChangeTrigger ' + @h.inspect
|
2245
|
+
end
|
2246
|
+
|
2247
|
+
alias to_summary to_s
|
1951
2248
|
end
|
1952
2249
|
|
1953
2250
|
# Category: Device Events
|
@@ -1963,6 +2260,11 @@ class BootTrigger < DeviceEventsTrigger
|
|
1963
2260
|
|
1964
2261
|
end
|
1965
2262
|
|
2263
|
+
def to_s(colour: false)
|
2264
|
+
'BootTrigger ' + @h.inspect
|
2265
|
+
end
|
2266
|
+
|
2267
|
+
alias to_summary to_s
|
1966
2268
|
end
|
1967
2269
|
|
1968
2270
|
# Category: Device Events
|
@@ -1983,6 +2285,11 @@ class IntentReceivedTrigger < DeviceEventsTrigger
|
|
1983
2285
|
|
1984
2286
|
end
|
1985
2287
|
|
2288
|
+
def to_s(colour: false)
|
2289
|
+
'IntentReceivedTrigger ' + @h.inspect
|
2290
|
+
end
|
2291
|
+
|
2292
|
+
alias to_summary to_s
|
1986
2293
|
end
|
1987
2294
|
|
1988
2295
|
# Category: Device Events
|
@@ -2009,6 +2316,11 @@ class NotificationTrigger < DeviceEventsTrigger
|
|
2009
2316
|
|
2010
2317
|
end
|
2011
2318
|
|
2319
|
+
def to_s(colour: false)
|
2320
|
+
'NotificationTrigger ' + @h.inspect
|
2321
|
+
end
|
2322
|
+
|
2323
|
+
alias to_summary to_s
|
2012
2324
|
end
|
2013
2325
|
|
2014
2326
|
# Category: Device Events
|
@@ -2024,6 +2336,12 @@ class ScreenOnOffTrigger < DeviceEventsTrigger
|
|
2024
2336
|
super(options.merge h)
|
2025
2337
|
|
2026
2338
|
end
|
2339
|
+
|
2340
|
+
def to_s(colour: false)
|
2341
|
+
'Screen ' + (@h[:screen_on] ? 'On' : 'Off')
|
2342
|
+
end
|
2343
|
+
|
2344
|
+
alias to_summary to_s
|
2027
2345
|
|
2028
2346
|
end
|
2029
2347
|
|
@@ -2041,6 +2359,11 @@ class SilentModeTrigger < DeviceEventsTrigger
|
|
2041
2359
|
|
2042
2360
|
end
|
2043
2361
|
|
2362
|
+
def to_s(colour: false)
|
2363
|
+
'SilentModeTrigger ' + @h.inspect
|
2364
|
+
end
|
2365
|
+
|
2366
|
+
alias to_summary to_s
|
2044
2367
|
end
|
2045
2368
|
|
2046
2369
|
# Category: Location
|
@@ -2066,6 +2389,11 @@ class WeatherTrigger < Trigger
|
|
2066
2389
|
|
2067
2390
|
end
|
2068
2391
|
|
2392
|
+
def to_s(colour: false)
|
2393
|
+
'WeatherTrigger ' + @h.inspect
|
2394
|
+
end
|
2395
|
+
|
2396
|
+
alias to_summary to_s
|
2069
2397
|
end
|
2070
2398
|
|
2071
2399
|
# Category: Location
|
@@ -2075,7 +2403,7 @@ class GeofenceTrigger < Trigger
|
|
2075
2403
|
def initialize( h={}, geofences: {})
|
2076
2404
|
|
2077
2405
|
if h[:name] then
|
2078
|
-
puts ('geofences2: ' + geofences.inspect)
|
2406
|
+
puts ('geofences2: ' + geofences.inspect) if $debug
|
2079
2407
|
found = geofences.find {|x| x.name.downcase == h[:name].downcase}
|
2080
2408
|
h[:geofence_id] = found.id if found
|
2081
2409
|
|
@@ -2094,7 +2422,7 @@ class GeofenceTrigger < Trigger
|
|
2094
2422
|
|
2095
2423
|
end
|
2096
2424
|
|
2097
|
-
def to_s()
|
2425
|
+
def to_s(colour: false)
|
2098
2426
|
|
2099
2427
|
if $debug then
|
2100
2428
|
puts ' @geofences: ' + @geofences.inspect
|
@@ -2129,6 +2457,11 @@ class SunriseSunsetTrigger < Trigger
|
|
2129
2457
|
|
2130
2458
|
end
|
2131
2459
|
|
2460
|
+
def to_s(colour: false)
|
2461
|
+
'SunriseSunsetTrigger ' + @h.inspect
|
2462
|
+
end
|
2463
|
+
|
2464
|
+
alias to_summary to_s
|
2132
2465
|
end
|
2133
2466
|
|
2134
2467
|
|
@@ -2158,12 +2491,12 @@ class ActivityRecognitionTrigger < SensorsTrigger
|
|
2158
2491
|
|
2159
2492
|
end
|
2160
2493
|
|
2161
|
-
def to_s()
|
2494
|
+
def to_s(colour: false)
|
2162
2495
|
activity = @activity[@h[:selected_index]]
|
2163
2496
|
'Activity - ' + activity
|
2164
2497
|
end
|
2165
2498
|
|
2166
|
-
def to_summary
|
2499
|
+
def to_summary(colour: false)
|
2167
2500
|
|
2168
2501
|
activity = @activity[@h[:selected_index]]
|
2169
2502
|
s = if activity.length > 10 then
|
@@ -2201,7 +2534,7 @@ class ProximityTrigger < SensorsTrigger
|
|
2201
2534
|
|
2202
2535
|
end
|
2203
2536
|
|
2204
|
-
def to_s()
|
2537
|
+
def to_s(colour: false)
|
2205
2538
|
|
2206
2539
|
distance = if @h[:near] then
|
2207
2540
|
'Near'
|
@@ -2231,7 +2564,7 @@ class ShakeDeviceTrigger < SensorsTrigger
|
|
2231
2564
|
'shake_device?'
|
2232
2565
|
end
|
2233
2566
|
|
2234
|
-
def to_s()
|
2567
|
+
def to_s(colour: false)
|
2235
2568
|
'Shake Device'
|
2236
2569
|
end
|
2237
2570
|
|
@@ -2262,7 +2595,7 @@ class FlipDeviceTrigger < SensorsTrigger
|
|
2262
2595
|
@h[:face_down] ? 'flip_device_down?' : 'flip_device_up?'
|
2263
2596
|
end
|
2264
2597
|
|
2265
|
-
def to_s()
|
2598
|
+
def to_s(colour: false)
|
2266
2599
|
|
2267
2600
|
action = @h[:face_down] ? 'Face Up -> Face Down' : 'Face Down -> Face Up'
|
2268
2601
|
'Flip Device ' + action
|
@@ -2285,6 +2618,11 @@ class OrientationTrigger < SensorsTrigger
|
|
2285
2618
|
|
2286
2619
|
end
|
2287
2620
|
|
2621
|
+
def to_s(colour: false)
|
2622
|
+
'OrientationTrigger ' + @h.inspect
|
2623
|
+
end
|
2624
|
+
|
2625
|
+
alias to_summary to_s
|
2288
2626
|
end
|
2289
2627
|
|
2290
2628
|
# Category: User Input
|
@@ -2310,6 +2648,11 @@ class FloatingButtonTrigger < Trigger
|
|
2310
2648
|
|
2311
2649
|
end
|
2312
2650
|
|
2651
|
+
def to_s(colour: false)
|
2652
|
+
'FloatingButtonTrigger ' + @h.inspect
|
2653
|
+
end
|
2654
|
+
|
2655
|
+
alias to_summary to_s
|
2313
2656
|
end
|
2314
2657
|
|
2315
2658
|
# Category: User Input
|
@@ -2325,6 +2668,11 @@ class ShortcutTrigger < Trigger
|
|
2325
2668
|
|
2326
2669
|
end
|
2327
2670
|
|
2671
|
+
def to_s(colour: false)
|
2672
|
+
'ShortcutTrigger ' + @h.inspect
|
2673
|
+
end
|
2674
|
+
|
2675
|
+
alias to_summary to_s
|
2328
2676
|
end
|
2329
2677
|
|
2330
2678
|
# Category: User Input
|
@@ -2343,6 +2691,33 @@ class VolumeButtonTrigger < Trigger
|
|
2343
2691
|
super(options.merge h)
|
2344
2692
|
|
2345
2693
|
end
|
2694
|
+
|
2695
|
+
def to_s(colour: false)
|
2696
|
+
|
2697
|
+
a = [
|
2698
|
+
'Volume Up',
|
2699
|
+
'Volume Down',
|
2700
|
+
'Volume Up - Long Press',
|
2701
|
+
'Volume Down - Long Press'
|
2702
|
+
]
|
2703
|
+
|
2704
|
+
lines = [a[@h[:option]]]
|
2705
|
+
lines << ' ' + (@h[:dont_change_volume] ? 'Retain Previous Volume' : 'Update Volume')
|
2706
|
+
@s = lines.join("\n")
|
2707
|
+
end
|
2708
|
+
|
2709
|
+
def to_summary(colour: false)
|
2710
|
+
a = [
|
2711
|
+
'Volume Up',
|
2712
|
+
'Volume Down',
|
2713
|
+
'Volume Up - Long Press',
|
2714
|
+
'Volume Down - Long Press'
|
2715
|
+
]
|
2716
|
+
|
2717
|
+
lines = [a[@h[:option]]]
|
2718
|
+
lines << (@h[:dont_change_volume] ? 'Retain Previous Volume' : 'Update Volume')
|
2719
|
+
@s = lines.join(": ")
|
2720
|
+
end
|
2346
2721
|
|
2347
2722
|
end
|
2348
2723
|
|
@@ -2361,6 +2736,11 @@ class MediaButtonPressedTrigger < Trigger
|
|
2361
2736
|
|
2362
2737
|
end
|
2363
2738
|
|
2739
|
+
def to_s(colour: false)
|
2740
|
+
'MediaButtonPressedTrigger ' + @h.inspect
|
2741
|
+
end
|
2742
|
+
|
2743
|
+
alias to_summary to_s
|
2364
2744
|
end
|
2365
2745
|
|
2366
2746
|
# Category: User Input
|
@@ -2379,6 +2759,11 @@ class SwipeTrigger < Trigger
|
|
2379
2759
|
|
2380
2760
|
end
|
2381
2761
|
|
2762
|
+
def to_s(colour: false)
|
2763
|
+
'SwipeTrigger ' + @h.inspect
|
2764
|
+
end
|
2765
|
+
|
2766
|
+
alias to_summary to_s
|
2382
2767
|
end
|
2383
2768
|
|
2384
2769
|
|
@@ -2387,19 +2772,35 @@ class Action < MacroObject
|
|
2387
2772
|
|
2388
2773
|
attr_reader :constraints
|
2389
2774
|
|
2390
|
-
def initialize(h={})
|
2775
|
+
def initialize(h={})
|
2776
|
+
|
2777
|
+
macro = h[:macro]
|
2778
|
+
h.delete :macro
|
2391
2779
|
super(h)
|
2392
2780
|
|
2393
2781
|
# fetch the constraints
|
2394
|
-
@constraints = h[:constraint_list].map do |constraint|
|
2395
|
-
object(constraint.to_snake_case)
|
2782
|
+
@constraints = @h[:constraint_list].map do |constraint|
|
2783
|
+
object(constraint.to_snake_case.merge(macro: macro))
|
2396
2784
|
end
|
2397
2785
|
end
|
2398
2786
|
|
2399
2787
|
def invoke(s='')
|
2400
2788
|
"%s/%s: %s" % [@group, @type, s]
|
2401
2789
|
end
|
2790
|
+
|
2791
|
+
def to_s(colour: false)
|
2402
2792
|
|
2793
|
+
h = @h.clone
|
2794
|
+
h.delete :macro
|
2795
|
+
@s ||= "#<%s %s>" % [self.class, h.inspect]
|
2796
|
+
operator = @h[:is_or_condition] ? 'OR' : 'AND'
|
2797
|
+
constraints = @constraints.map \
|
2798
|
+
{|x| x.to_summary(colour: colour)}.join(" %s " % operator)
|
2799
|
+
|
2800
|
+
@s + constraints
|
2801
|
+
|
2802
|
+
end
|
2803
|
+
|
2403
2804
|
end
|
2404
2805
|
|
2405
2806
|
|
@@ -2434,6 +2835,11 @@ class ShareLocationAction < LocationAction
|
|
2434
2835
|
|
2435
2836
|
end
|
2436
2837
|
|
2838
|
+
def to_s(colour: false)
|
2839
|
+
'ShareLocationAction ' + @h.inspect
|
2840
|
+
end
|
2841
|
+
|
2842
|
+
alias to_summary to_s
|
2437
2843
|
end
|
2438
2844
|
|
2439
2845
|
|
@@ -2463,7 +2869,7 @@ class LaunchActivityAction < ApplicationAction
|
|
2463
2869
|
|
2464
2870
|
end
|
2465
2871
|
|
2466
|
-
def to_s()
|
2872
|
+
def to_s(colour: false)
|
2467
2873
|
'Launch ' + @h[:application_name]
|
2468
2874
|
end
|
2469
2875
|
|
@@ -2484,6 +2890,11 @@ class KillBackgroundAppAction < ApplicationAction
|
|
2484
2890
|
|
2485
2891
|
end
|
2486
2892
|
|
2893
|
+
def to_s(colour: false)
|
2894
|
+
'KillBackgroundAppAction ' + @h.inspect
|
2895
|
+
end
|
2896
|
+
|
2897
|
+
alias to_summary to_s
|
2487
2898
|
end
|
2488
2899
|
|
2489
2900
|
# Category: Applications
|
@@ -2506,7 +2917,7 @@ class OpenWebPageAction < ApplicationAction
|
|
2506
2917
|
|
2507
2918
|
end
|
2508
2919
|
|
2509
|
-
def to_s()
|
2920
|
+
def to_s(colour: false)
|
2510
2921
|
"HTTP GET\n url: " + @h[:url_to_open]
|
2511
2922
|
end
|
2512
2923
|
|
@@ -2537,6 +2948,11 @@ class UploadPhotoAction < CameraAction
|
|
2537
2948
|
|
2538
2949
|
end
|
2539
2950
|
|
2951
|
+
def to_s(colour: false)
|
2952
|
+
'UploadPhotoAction ' + @h.inspect
|
2953
|
+
end
|
2954
|
+
|
2955
|
+
alias to_summary to_s
|
2540
2956
|
end
|
2541
2957
|
|
2542
2958
|
# Category: Camera/Photo
|
@@ -2562,7 +2978,7 @@ class TakePictureAction < CameraAction
|
|
2562
2978
|
'take_photo :' + camera.to_s
|
2563
2979
|
end
|
2564
2980
|
|
2565
|
-
def to_s()
|
2981
|
+
def to_s(colour: false)
|
2566
2982
|
'Take Picture'
|
2567
2983
|
end
|
2568
2984
|
|
@@ -2571,22 +2987,25 @@ end
|
|
2571
2987
|
class IfConditionAction < Action
|
2572
2988
|
|
2573
2989
|
def initialize(h={})
|
2574
|
-
|
2990
|
+
|
2575
2991
|
options = {
|
2576
2992
|
a: true,
|
2577
2993
|
constraint_list: ''
|
2578
2994
|
}
|
2995
|
+
|
2996
|
+
macro = h[:macro]
|
2997
|
+
h2 = options.merge(filter(options,h).merge(macro: macro))
|
2579
2998
|
|
2580
|
-
super(
|
2999
|
+
super(h2)
|
3000
|
+
|
3001
|
+
@label = 'If '
|
2581
3002
|
|
2582
3003
|
end
|
2583
3004
|
|
2584
|
-
def to_s()
|
3005
|
+
def to_s(colour: false)
|
2585
3006
|
|
2586
|
-
|
2587
|
-
|
2588
|
-
puts 'if ... @h ' + @h.inspect
|
2589
|
-
r
|
3007
|
+
@s = "If " #+ @constraints.map(&:to_s).join(" %s " % operator)
|
3008
|
+
super(colour: colour)
|
2590
3009
|
|
2591
3010
|
end
|
2592
3011
|
end
|
@@ -2600,16 +3019,17 @@ class ElseAction < Action
|
|
2600
3019
|
}
|
2601
3020
|
|
2602
3021
|
super(options.merge h)
|
3022
|
+
|
2603
3023
|
|
2604
3024
|
end
|
2605
3025
|
|
2606
|
-
def to_s()
|
3026
|
+
def to_s(colour: false)
|
2607
3027
|
'Else'
|
2608
3028
|
end
|
2609
3029
|
|
2610
3030
|
end
|
2611
3031
|
|
2612
|
-
class
|
3032
|
+
class ElseIfConditionAction < IfConditionAction
|
2613
3033
|
|
2614
3034
|
def initialize(h={})
|
2615
3035
|
|
@@ -2618,16 +3038,33 @@ class EndIfAction < Action
|
|
2618
3038
|
}
|
2619
3039
|
|
2620
3040
|
super(options.merge h)
|
3041
|
+
@label = 'ElseIf '
|
2621
3042
|
|
2622
3043
|
end
|
2623
|
-
|
2624
|
-
|
2625
|
-
'End If'
|
2626
|
-
end
|
2627
|
-
|
3044
|
+
|
3045
|
+
|
2628
3046
|
end
|
2629
3047
|
|
2630
|
-
|
3048
|
+
|
3049
|
+
class EndIfAction < Action
|
3050
|
+
|
3051
|
+
def initialize(h={})
|
3052
|
+
|
3053
|
+
options = {
|
3054
|
+
constraint_list: ''
|
3055
|
+
}
|
3056
|
+
|
3057
|
+
super(options.merge h)
|
3058
|
+
|
3059
|
+
end
|
3060
|
+
|
3061
|
+
def to_s(colour: false)
|
3062
|
+
'End If'
|
3063
|
+
end
|
3064
|
+
|
3065
|
+
end
|
3066
|
+
|
3067
|
+
class ConnectivityAction < Action
|
2631
3068
|
|
2632
3069
|
def initialize(h={})
|
2633
3070
|
super(h)
|
@@ -2636,6 +3073,31 @@ class ConnectivityAction < Action
|
|
2636
3073
|
|
2637
3074
|
end
|
2638
3075
|
|
3076
|
+
# Category: Connectivity
|
3077
|
+
#
|
3078
|
+
class SetAirplaneModeAction < ConnectivityAction
|
3079
|
+
|
3080
|
+
def initialize(h={})
|
3081
|
+
|
3082
|
+
options = {
|
3083
|
+
device_name: '',
|
3084
|
+
state: 1
|
3085
|
+
}
|
3086
|
+
|
3087
|
+
super(options.merge h)
|
3088
|
+
|
3089
|
+
end
|
3090
|
+
|
3091
|
+
def to_s(colour: false)
|
3092
|
+
|
3093
|
+
state = ['On', 'Off', 'Toggle'][@h[:state]]
|
3094
|
+
@s = 'Airplane Mode ' + state + "\n"
|
3095
|
+
super(colour: colour)
|
3096
|
+
|
3097
|
+
end
|
3098
|
+
|
3099
|
+
end
|
3100
|
+
|
2639
3101
|
# Category: Connectivity
|
2640
3102
|
#
|
2641
3103
|
class SetWifiAction < ConnectivityAction
|
@@ -2652,7 +3114,7 @@ class SetWifiAction < ConnectivityAction
|
|
2652
3114
|
|
2653
3115
|
end
|
2654
3116
|
|
2655
|
-
def to_s()
|
3117
|
+
def to_s(colour: false)
|
2656
3118
|
action = @h[:state] == 0 ? 'Enable' : 'Disable'
|
2657
3119
|
action + ' Wifi'
|
2658
3120
|
end
|
@@ -2674,6 +3136,11 @@ class SetBluetoothAction < ConnectivityAction
|
|
2674
3136
|
|
2675
3137
|
end
|
2676
3138
|
|
3139
|
+
def to_s(colour: false)
|
3140
|
+
'SetBluetoothAction ' + @h.inspect
|
3141
|
+
end
|
3142
|
+
|
3143
|
+
alias to_summary to_s
|
2677
3144
|
end
|
2678
3145
|
|
2679
3146
|
# Category: Connectivity
|
@@ -2691,6 +3158,30 @@ class SetBluetoothAction < ConnectivityAction
|
|
2691
3158
|
|
2692
3159
|
end
|
2693
3160
|
|
3161
|
+
def to_s(colour: false)
|
3162
|
+
'SetBluetoothAction ' + @h.inspect
|
3163
|
+
end
|
3164
|
+
|
3165
|
+
alias to_summary to_s
|
3166
|
+
end
|
3167
|
+
|
3168
|
+
class SetHotspotAction < ConnectivityAction
|
3169
|
+
|
3170
|
+
def initialize(h={})
|
3171
|
+
|
3172
|
+
options = {
|
3173
|
+
device_name: "", state: 0, turn_wifi_on: true, use_legacy_mechanism: false, mechanism: 0
|
3174
|
+
|
3175
|
+
}
|
3176
|
+
|
3177
|
+
super(options.merge h)
|
3178
|
+
|
3179
|
+
end
|
3180
|
+
|
3181
|
+
def to_s(colour: false)
|
3182
|
+
action = @h[:turn_wifi_on] ? 'Enable' : 'Disable'
|
3183
|
+
action + ' HotSpot'
|
3184
|
+
end
|
2694
3185
|
end
|
2695
3186
|
|
2696
3187
|
# Category: Connectivity
|
@@ -2719,6 +3210,11 @@ class SendIntentAction < ConnectivityAction
|
|
2719
3210
|
|
2720
3211
|
end
|
2721
3212
|
|
3213
|
+
def to_s(colour: false)
|
3214
|
+
'SendIntentAction ' + @h.inspect
|
3215
|
+
end
|
3216
|
+
|
3217
|
+
alias to_summary to_s
|
2722
3218
|
end
|
2723
3219
|
|
2724
3220
|
|
@@ -2754,6 +3250,11 @@ class SetAlarmClockAction < DateTimeAction
|
|
2754
3250
|
|
2755
3251
|
end
|
2756
3252
|
|
3253
|
+
def to_s(colour: false)
|
3254
|
+
'SetAlarmClockAction ' + @h.inspect
|
3255
|
+
end
|
3256
|
+
|
3257
|
+
alias to_summary to_s
|
2757
3258
|
end
|
2758
3259
|
|
2759
3260
|
# Category: Date/Time
|
@@ -2771,6 +3272,11 @@ class StopWatchAction < DateTimeAction
|
|
2771
3272
|
|
2772
3273
|
end
|
2773
3274
|
|
3275
|
+
def to_s(colour: false)
|
3276
|
+
'StopWatchAction ' + @h.inspect
|
3277
|
+
end
|
3278
|
+
|
3279
|
+
alias to_summary to_s
|
2774
3280
|
end
|
2775
3281
|
|
2776
3282
|
# Category: Date/Time
|
@@ -2797,7 +3303,7 @@ class SayTimeAction < DateTimeAction
|
|
2797
3303
|
'say current_time()'
|
2798
3304
|
end
|
2799
3305
|
|
2800
|
-
def to_s()
|
3306
|
+
def to_s(colour: false)
|
2801
3307
|
'Say Current Time'
|
2802
3308
|
end
|
2803
3309
|
|
@@ -2827,6 +3333,11 @@ class AndroidShortcutsAction < DeviceAction
|
|
2827
3333
|
|
2828
3334
|
end
|
2829
3335
|
|
3336
|
+
def to_s(colour: false)
|
3337
|
+
'AndroidShortcutsAction ' + @h.inspect
|
3338
|
+
end
|
3339
|
+
|
3340
|
+
alias to_summary to_s
|
2830
3341
|
end
|
2831
3342
|
|
2832
3343
|
# Category: Device Actions
|
@@ -2843,6 +3354,11 @@ class ClipboardAction < DeviceAction
|
|
2843
3354
|
|
2844
3355
|
end
|
2845
3356
|
|
3357
|
+
def to_s(colour: false)
|
3358
|
+
'ClipboardAction ' + @h.inspect
|
3359
|
+
end
|
3360
|
+
|
3361
|
+
alias to_summary to_s
|
2846
3362
|
end
|
2847
3363
|
|
2848
3364
|
# Category: Device Actions
|
@@ -2858,6 +3374,11 @@ class PressBackAction < DeviceAction
|
|
2858
3374
|
|
2859
3375
|
end
|
2860
3376
|
|
3377
|
+
def to_s(colour: false)
|
3378
|
+
'PressBackAction ' + @h.inspect
|
3379
|
+
end
|
3380
|
+
|
3381
|
+
alias to_summary to_s
|
2861
3382
|
end
|
2862
3383
|
|
2863
3384
|
# Category: Device Actions
|
@@ -2881,7 +3402,7 @@ class SpeakTextAction < DeviceAction
|
|
2881
3402
|
|
2882
3403
|
end
|
2883
3404
|
|
2884
|
-
def to_s()
|
3405
|
+
def to_s(colour: false)
|
2885
3406
|
"Speak Text (%s)" % @h[:text_to_say]
|
2886
3407
|
end
|
2887
3408
|
|
@@ -2902,6 +3423,11 @@ class UIInteractionAction < DeviceAction
|
|
2902
3423
|
|
2903
3424
|
end
|
2904
3425
|
|
3426
|
+
def to_s(colour: false)
|
3427
|
+
'UIInteractionAction ' + @h.inspect
|
3428
|
+
end
|
3429
|
+
|
3430
|
+
alias to_summary to_s
|
2905
3431
|
end
|
2906
3432
|
|
2907
3433
|
# Category: Device Actions
|
@@ -2917,6 +3443,11 @@ class VoiceSearchAction < DeviceAction
|
|
2917
3443
|
|
2918
3444
|
end
|
2919
3445
|
|
3446
|
+
def to_s(colour: false)
|
3447
|
+
'VoiceSearchAction ' + @h.inspect
|
3448
|
+
end
|
3449
|
+
|
3450
|
+
alias to_summary to_s
|
2920
3451
|
end
|
2921
3452
|
|
2922
3453
|
|
@@ -2943,6 +3474,11 @@ class ExpandCollapseStatusBarAction < DeviceSettingsAction
|
|
2943
3474
|
|
2944
3475
|
end
|
2945
3476
|
|
3477
|
+
def to_s(colour: false)
|
3478
|
+
'ExpandCollapseStatusBarAction ' + @h.inspect
|
3479
|
+
end
|
3480
|
+
|
3481
|
+
alias to_summary to_s
|
2946
3482
|
end
|
2947
3483
|
|
2948
3484
|
# Category: Device Settings
|
@@ -2958,6 +3494,11 @@ class LaunchHomeScreenAction < DeviceSettingsAction
|
|
2958
3494
|
|
2959
3495
|
end
|
2960
3496
|
|
3497
|
+
def to_s(colour: false)
|
3498
|
+
'LaunchHomeScreenAction ' + @h.inspect
|
3499
|
+
end
|
3500
|
+
|
3501
|
+
alias to_summary to_s
|
2961
3502
|
end
|
2962
3503
|
|
2963
3504
|
# Category: Device Settings
|
@@ -2976,11 +3517,11 @@ class CameraFlashLightAction < DeviceSettingsAction
|
|
2976
3517
|
end
|
2977
3518
|
|
2978
3519
|
def to_pc()
|
2979
|
-
'torch :on'
|
3520
|
+
['torch :on', 'torch :off', 'torch :toggle'][@h[:state]]
|
2980
3521
|
end
|
2981
3522
|
|
2982
|
-
def to_s()
|
2983
|
-
'Torch On'
|
3523
|
+
def to_s(colour: false)
|
3524
|
+
['Torch On', 'Torch Off', 'Torch Toggle'][@h[:state]]
|
2984
3525
|
end
|
2985
3526
|
|
2986
3527
|
end
|
@@ -2999,7 +3540,7 @@ class VibrateAction < DeviceSettingsAction
|
|
2999
3540
|
|
3000
3541
|
end
|
3001
3542
|
|
3002
|
-
def to_s()
|
3543
|
+
def to_s(colour: false)
|
3003
3544
|
|
3004
3545
|
pattern = [
|
3005
3546
|
'Blip', 'Short Buzz', 'Long Buzz', 'Rapid', 'Slow', 'Increasing',
|
@@ -3026,6 +3567,11 @@ class SetAutoRotateAction < DeviceSettingsAction
|
|
3026
3567
|
|
3027
3568
|
end
|
3028
3569
|
|
3570
|
+
def to_s(colour: false)
|
3571
|
+
'SetAutoRotateAction ' + @h.inspect
|
3572
|
+
end
|
3573
|
+
|
3574
|
+
alias to_summary to_s
|
3029
3575
|
end
|
3030
3576
|
|
3031
3577
|
# Category: Device Settings
|
@@ -3041,6 +3587,11 @@ class DayDreamAction < DeviceSettingsAction
|
|
3041
3587
|
|
3042
3588
|
end
|
3043
3589
|
|
3590
|
+
def to_s(colour: false)
|
3591
|
+
'DayDreamAction ' + @h.inspect
|
3592
|
+
end
|
3593
|
+
|
3594
|
+
alias to_summary to_s
|
3044
3595
|
end
|
3045
3596
|
|
3046
3597
|
# Category: Device Settings
|
@@ -3056,6 +3607,11 @@ class SetKeyboardAction < DeviceSettingsAction
|
|
3056
3607
|
|
3057
3608
|
end
|
3058
3609
|
|
3610
|
+
def to_s(colour: false)
|
3611
|
+
'SetKeyboardAction ' + @h.inspect
|
3612
|
+
end
|
3613
|
+
|
3614
|
+
alias to_summary to_s
|
3059
3615
|
end
|
3060
3616
|
|
3061
3617
|
# Category: Device Settings
|
@@ -3072,6 +3628,11 @@ class SetKeyguardAction < DeviceSettingsAction
|
|
3072
3628
|
|
3073
3629
|
end
|
3074
3630
|
|
3631
|
+
def to_s(colour: false)
|
3632
|
+
'SetKeyguardAction ' + @h.inspect
|
3633
|
+
end
|
3634
|
+
|
3635
|
+
alias to_summary to_s
|
3075
3636
|
end
|
3076
3637
|
|
3077
3638
|
# Category: Device Settings
|
@@ -3088,6 +3649,11 @@ class CarModeAction < DeviceSettingsAction
|
|
3088
3649
|
|
3089
3650
|
end
|
3090
3651
|
|
3652
|
+
def to_s(colour: false)
|
3653
|
+
'CarModeAction ' + @h.inspect
|
3654
|
+
end
|
3655
|
+
|
3656
|
+
alias to_summary to_s
|
3091
3657
|
end
|
3092
3658
|
|
3093
3659
|
# Category: Device Settings
|
@@ -3105,6 +3671,11 @@ class ChangeKeyboardAction < DeviceSettingsAction
|
|
3105
3671
|
|
3106
3672
|
end
|
3107
3673
|
|
3674
|
+
def to_s(colour: false)
|
3675
|
+
'ChangeKeyboardAction ' + @h.inspect
|
3676
|
+
end
|
3677
|
+
|
3678
|
+
alias to_summary to_s
|
3108
3679
|
end
|
3109
3680
|
|
3110
3681
|
# Category: Device Settings
|
@@ -3126,6 +3697,11 @@ class SetWallpaperAction < DeviceSettingsAction
|
|
3126
3697
|
|
3127
3698
|
end
|
3128
3699
|
|
3700
|
+
def to_s(colour: false)
|
3701
|
+
'SetWallpaperAction ' + @h.inspect
|
3702
|
+
end
|
3703
|
+
|
3704
|
+
alias to_summary to_s
|
3129
3705
|
end
|
3130
3706
|
|
3131
3707
|
class FileAction < Action
|
@@ -3154,6 +3730,11 @@ class OpenFileAction < FileAction
|
|
3154
3730
|
|
3155
3731
|
end
|
3156
3732
|
|
3733
|
+
def to_s(colour: false)
|
3734
|
+
'OpenFileAction ' + @h.inspect
|
3735
|
+
end
|
3736
|
+
|
3737
|
+
alias to_summary to_s
|
3157
3738
|
end
|
3158
3739
|
|
3159
3740
|
|
@@ -3179,6 +3760,11 @@ class ForceLocationUpdateAction < LocationAction
|
|
3179
3760
|
|
3180
3761
|
end
|
3181
3762
|
|
3763
|
+
def to_s(colour: false)
|
3764
|
+
'ForceLocationUpdateAction ' + @h.inspect
|
3765
|
+
end
|
3766
|
+
|
3767
|
+
alias to_summary to_s
|
3182
3768
|
end
|
3183
3769
|
|
3184
3770
|
# Category: Location
|
@@ -3199,6 +3785,11 @@ class ShareLocationAction < LocationAction
|
|
3199
3785
|
|
3200
3786
|
end
|
3201
3787
|
|
3788
|
+
def to_s(colour: false)
|
3789
|
+
'ShareLocationAction ' + @h.inspect
|
3790
|
+
end
|
3791
|
+
|
3792
|
+
alias to_summary to_s
|
3202
3793
|
end
|
3203
3794
|
|
3204
3795
|
# Category: Location
|
@@ -3216,6 +3807,11 @@ class SetLocationUpdateRateAction < LocationAction
|
|
3216
3807
|
|
3217
3808
|
end
|
3218
3809
|
|
3810
|
+
def to_s(colour: false)
|
3811
|
+
'SetLocationUpdateRateAction ' + @h.inspect
|
3812
|
+
end
|
3813
|
+
|
3814
|
+
alias to_summary to_s
|
3219
3815
|
end
|
3220
3816
|
|
3221
3817
|
class LoggingAction < Action
|
@@ -3254,6 +3850,11 @@ class AddCalendarEntryAction < LoggingAction
|
|
3254
3850
|
|
3255
3851
|
end
|
3256
3852
|
|
3853
|
+
def to_s(colour: false)
|
3854
|
+
'AddCalendarEntryAction ' + @h.inspect
|
3855
|
+
end
|
3856
|
+
|
3857
|
+
alias to_summary to_s
|
3257
3858
|
end
|
3258
3859
|
|
3259
3860
|
# Category: Logging
|
@@ -3271,6 +3872,11 @@ class LogAction < LoggingAction
|
|
3271
3872
|
|
3272
3873
|
end
|
3273
3874
|
|
3875
|
+
def to_s(colour: false)
|
3876
|
+
'LogAction ' + @h.inspect
|
3877
|
+
end
|
3878
|
+
|
3879
|
+
alias to_summary to_s
|
3274
3880
|
end
|
3275
3881
|
|
3276
3882
|
# Category: Logging
|
@@ -3287,6 +3893,40 @@ class ClearLogAction < LoggingAction
|
|
3287
3893
|
|
3288
3894
|
end
|
3289
3895
|
|
3896
|
+
def to_s(colour: false)
|
3897
|
+
'ClearLogAction ' + @h.inspect
|
3898
|
+
end
|
3899
|
+
|
3900
|
+
alias to_summary to_s
|
3901
|
+
end
|
3902
|
+
|
3903
|
+
class PauseAction < Action
|
3904
|
+
|
3905
|
+
def initialize(h={})
|
3906
|
+
|
3907
|
+
options = {
|
3908
|
+
delay_in_milli_seconds: 0, delay_in_seconds: 1, use_alarm: false
|
3909
|
+
}
|
3910
|
+
super(h)
|
3911
|
+
|
3912
|
+
end
|
3913
|
+
|
3914
|
+
def to_s(colour: false)
|
3915
|
+
|
3916
|
+
su = Subunit.new(units={minutes:60, hours:60},
|
3917
|
+
seconds: @h[:delay_in_seconds])
|
3918
|
+
|
3919
|
+
ms = @h[:delay_in_milli_seconds]
|
3920
|
+
|
3921
|
+
duration = if su.to_h.has_key?(:minutes) or (ms < 1) then
|
3922
|
+
su.strfunit("%X")
|
3923
|
+
else
|
3924
|
+
"%s %s ms" % [su.strfunit("%X"), ms]
|
3925
|
+
end
|
3926
|
+
|
3927
|
+
"Wait " + duration
|
3928
|
+
end
|
3929
|
+
|
3290
3930
|
end
|
3291
3931
|
|
3292
3932
|
class MediaAction < Action
|
@@ -3315,6 +3955,11 @@ class RecordMicrophoneAction < MediaAction
|
|
3315
3955
|
|
3316
3956
|
end
|
3317
3957
|
|
3958
|
+
def to_s(colour: false)
|
3959
|
+
'RecordMicrophoneAction ' + @h.inspect
|
3960
|
+
end
|
3961
|
+
|
3962
|
+
alias to_summary to_s
|
3318
3963
|
end
|
3319
3964
|
|
3320
3965
|
# Category: Media
|
@@ -3332,7 +3977,7 @@ class PlaySoundAction < MediaAction
|
|
3332
3977
|
|
3333
3978
|
end
|
3334
3979
|
|
3335
|
-
def to_s()
|
3980
|
+
def to_s(colour: false)
|
3336
3981
|
'Play: ' + @h[:file_path]
|
3337
3982
|
end
|
3338
3983
|
|
@@ -3368,6 +4013,11 @@ class SendEmailAction < MessagingAction
|
|
3368
4013
|
|
3369
4014
|
end
|
3370
4015
|
|
4016
|
+
def to_s(colour: false)
|
4017
|
+
'SendEmailAction ' + @h.inspect
|
4018
|
+
end
|
4019
|
+
|
4020
|
+
alias to_summary to_s
|
3371
4021
|
end
|
3372
4022
|
|
3373
4023
|
# Category: Messaging
|
@@ -3389,6 +4039,11 @@ class SendSMSAction < MessagingAction
|
|
3389
4039
|
|
3390
4040
|
end
|
3391
4041
|
|
4042
|
+
def to_s(colour: false)
|
4043
|
+
'SendSMSAction ' + @h.inspect
|
4044
|
+
end
|
4045
|
+
|
4046
|
+
alias to_summary to_s
|
3392
4047
|
end
|
3393
4048
|
|
3394
4049
|
# Category: Messaging
|
@@ -3407,6 +4062,11 @@ class UDPCommandAction < MessagingAction
|
|
3407
4062
|
|
3408
4063
|
end
|
3409
4064
|
|
4065
|
+
def to_s(colour: false)
|
4066
|
+
'UDPCommandAction ' + @h.inspect
|
4067
|
+
end
|
4068
|
+
|
4069
|
+
alias to_summary to_s
|
3410
4070
|
end
|
3411
4071
|
|
3412
4072
|
|
@@ -3441,6 +4101,11 @@ class ClearNotificationsAction < NotificationsAction
|
|
3441
4101
|
|
3442
4102
|
end
|
3443
4103
|
|
4104
|
+
def to_s(colour: false)
|
4105
|
+
'ClearNotificationsAction ' + @h.inspect
|
4106
|
+
end
|
4107
|
+
|
4108
|
+
alias to_summary to_s
|
3444
4109
|
end
|
3445
4110
|
|
3446
4111
|
# Category: Notifications
|
@@ -3467,6 +4132,10 @@ class MessageDialogAction < NotificationsAction
|
|
3467
4132
|
super(options.merge h)
|
3468
4133
|
|
3469
4134
|
end
|
4135
|
+
|
4136
|
+
def to_s(colour: false)
|
4137
|
+
'Display Dialog' + "\n Battery at: [battery]"
|
4138
|
+
end
|
3470
4139
|
|
3471
4140
|
end
|
3472
4141
|
|
@@ -3484,6 +4153,11 @@ class AllowLEDNotificationLightAction < NotificationsAction
|
|
3484
4153
|
|
3485
4154
|
end
|
3486
4155
|
|
4156
|
+
def to_s(colour: false)
|
4157
|
+
'AllowLEDNotificationLightAction ' + @h.inspect
|
4158
|
+
end
|
4159
|
+
|
4160
|
+
alias to_summary to_s
|
3487
4161
|
end
|
3488
4162
|
|
3489
4163
|
# Category: Notifications
|
@@ -3500,6 +4174,11 @@ class SetNotificationSoundAction < NotificationsAction
|
|
3500
4174
|
|
3501
4175
|
end
|
3502
4176
|
|
4177
|
+
def to_s(colour: false)
|
4178
|
+
'SetNotificationSoundAction ' + @h.inspect
|
4179
|
+
end
|
4180
|
+
|
4181
|
+
alias to_summary to_s
|
3503
4182
|
end
|
3504
4183
|
|
3505
4184
|
# Category: Notifications
|
@@ -3516,6 +4195,11 @@ class SetNotificationSoundAction < NotificationsAction
|
|
3516
4195
|
|
3517
4196
|
end
|
3518
4197
|
|
4198
|
+
def to_s(colour: false)
|
4199
|
+
'SetNotificationSoundAction ' + @h.inspect
|
4200
|
+
end
|
4201
|
+
|
4202
|
+
alias to_summary to_s
|
3519
4203
|
end
|
3520
4204
|
|
3521
4205
|
# Category: Notifications
|
@@ -3532,6 +4216,11 @@ class SetNotificationSoundAction < NotificationsAction
|
|
3532
4216
|
|
3533
4217
|
end
|
3534
4218
|
|
4219
|
+
def to_s(colour: false)
|
4220
|
+
'SetNotificationSoundAction ' + @h.inspect
|
4221
|
+
end
|
4222
|
+
|
4223
|
+
alias to_summary to_s
|
3535
4224
|
end
|
3536
4225
|
|
3537
4226
|
# Category: Notifications
|
@@ -3561,7 +4250,7 @@ class NotificationAction < NotificationsAction
|
|
3561
4250
|
|
3562
4251
|
end
|
3563
4252
|
|
3564
|
-
def to_s()
|
4253
|
+
def to_s(colour: false)
|
3565
4254
|
'Display Notification: ' + "%s: %s" % [@h[:notification_subject], @h[:notification_text]]
|
3566
4255
|
end
|
3567
4256
|
|
@@ -3601,7 +4290,7 @@ class ToastAction < NotificationsAction
|
|
3601
4290
|
"popup_message '%s'" % @h[:message_text]
|
3602
4291
|
end
|
3603
4292
|
|
3604
|
-
def to_s()
|
4293
|
+
def to_s(colour: false)
|
3605
4294
|
"Popup Message '%s'" % @h[:message_text]
|
3606
4295
|
end
|
3607
4296
|
|
@@ -3630,7 +4319,11 @@ class AnswerCallAction < PhoneAction
|
|
3630
4319
|
super(options.merge h)
|
3631
4320
|
|
3632
4321
|
end
|
3633
|
-
|
4322
|
+
|
4323
|
+
def to_s(colour: false)
|
4324
|
+
@s = 'Answer Call' + "\n "
|
4325
|
+
super()
|
4326
|
+
end
|
3634
4327
|
end
|
3635
4328
|
|
3636
4329
|
# Category: Phone
|
@@ -3649,6 +4342,11 @@ class ClearCallLogAction < PhoneAction
|
|
3649
4342
|
|
3650
4343
|
end
|
3651
4344
|
|
4345
|
+
def to_s(colour: false)
|
4346
|
+
'ClearCallLogAction ' + @h.inspect
|
4347
|
+
end
|
4348
|
+
|
4349
|
+
alias to_summary to_s
|
3652
4350
|
end
|
3653
4351
|
|
3654
4352
|
# Category: Phone
|
@@ -3664,6 +4362,11 @@ class OpenCallLogAction < PhoneAction
|
|
3664
4362
|
|
3665
4363
|
end
|
3666
4364
|
|
4365
|
+
def to_s(colour: false)
|
4366
|
+
'OpenCallLogAction ' + @h.inspect
|
4367
|
+
end
|
4368
|
+
|
4369
|
+
alias to_summary to_s
|
3667
4370
|
end
|
3668
4371
|
|
3669
4372
|
# Category: Phone
|
@@ -3678,6 +4381,11 @@ class RejectCallAction < PhoneAction
|
|
3678
4381
|
super(options.merge h)
|
3679
4382
|
|
3680
4383
|
end
|
4384
|
+
|
4385
|
+
def to_s(colour: false)
|
4386
|
+
@s = 'Call Reject' + "\n "
|
4387
|
+
super()
|
4388
|
+
end
|
3681
4389
|
|
3682
4390
|
end
|
3683
4391
|
|
@@ -3696,6 +4404,11 @@ class MakeCallAction < PhoneAction
|
|
3696
4404
|
|
3697
4405
|
end
|
3698
4406
|
|
4407
|
+
def to_s(colour: false)
|
4408
|
+
'MakeCallAction ' + @h.inspect
|
4409
|
+
end
|
4410
|
+
|
4411
|
+
alias to_summary to_s
|
3699
4412
|
end
|
3700
4413
|
|
3701
4414
|
|
@@ -3713,6 +4426,11 @@ class SetRingtoneAction < PhoneAction
|
|
3713
4426
|
|
3714
4427
|
end
|
3715
4428
|
|
4429
|
+
def to_s(colour: false)
|
4430
|
+
'SetRingtoneAction ' + @h.inspect
|
4431
|
+
end
|
4432
|
+
|
4433
|
+
alias to_summary to_s
|
3716
4434
|
end
|
3717
4435
|
|
3718
4436
|
class ScreenAction < Action
|
@@ -3740,6 +4458,11 @@ class SetBrightnessAction < ScreenAction
|
|
3740
4458
|
|
3741
4459
|
end
|
3742
4460
|
|
4461
|
+
def to_s(colour: false)
|
4462
|
+
'SetBrightnessAction ' + @h.inspect
|
4463
|
+
end
|
4464
|
+
|
4465
|
+
alias to_summary to_s
|
3743
4466
|
end
|
3744
4467
|
|
3745
4468
|
# Category: Screen
|
@@ -3756,6 +4479,11 @@ class ForceScreenRotationAction < ScreenAction
|
|
3756
4479
|
|
3757
4480
|
end
|
3758
4481
|
|
4482
|
+
def to_s(colour: false)
|
4483
|
+
'ForceScreenRotationAction ' + @h.inspect
|
4484
|
+
end
|
4485
|
+
|
4486
|
+
alias to_summary to_s
|
3759
4487
|
end
|
3760
4488
|
|
3761
4489
|
# Category: Screen
|
@@ -3775,6 +4503,11 @@ class ScreenOnAction < ScreenAction
|
|
3775
4503
|
|
3776
4504
|
end
|
3777
4505
|
|
4506
|
+
def to_s(colour: false)
|
4507
|
+
'ScreenOnAction ' + @h.inspect
|
4508
|
+
end
|
4509
|
+
|
4510
|
+
alias to_summary to_s
|
3778
4511
|
end
|
3779
4512
|
|
3780
4513
|
# Category: Screen
|
@@ -3792,6 +4525,11 @@ class DimScreenAction < ScreenAction
|
|
3792
4525
|
|
3793
4526
|
end
|
3794
4527
|
|
4528
|
+
def to_s(colour: false)
|
4529
|
+
'DimScreenAction ' + @h.inspect
|
4530
|
+
end
|
4531
|
+
|
4532
|
+
alias to_summary to_s
|
3795
4533
|
end
|
3796
4534
|
|
3797
4535
|
# Category: Screen
|
@@ -3815,7 +4553,7 @@ class KeepAwakeAction < ScreenAction
|
|
3815
4553
|
|
3816
4554
|
end
|
3817
4555
|
|
3818
|
-
def to_s()
|
4556
|
+
def to_s(colour: false)
|
3819
4557
|
|
3820
4558
|
screen = @h[:screen_option] == 0 ? 'Screen On' : 'Screen Off'
|
3821
4559
|
|
@@ -3856,6 +4594,11 @@ class SetScreenTimeoutAction < ScreenAction
|
|
3856
4594
|
|
3857
4595
|
end
|
3858
4596
|
|
4597
|
+
def to_s(colour: false)
|
4598
|
+
'SetScreenTimeoutAction ' + @h.inspect
|
4599
|
+
end
|
4600
|
+
|
4601
|
+
alias to_summary to_s
|
3859
4602
|
end
|
3860
4603
|
|
3861
4604
|
|
@@ -3882,6 +4625,11 @@ class SilentModeVibrateOffAction < VolumeAction
|
|
3882
4625
|
|
3883
4626
|
end
|
3884
4627
|
|
4628
|
+
def to_s(colour: false)
|
4629
|
+
'SilentModeVibrateOffAction ' + @h.inspect
|
4630
|
+
end
|
4631
|
+
|
4632
|
+
alias to_summary to_s
|
3885
4633
|
end
|
3886
4634
|
|
3887
4635
|
# Category: Volume
|
@@ -3899,6 +4647,27 @@ class SetVibrateAction < VolumeAction
|
|
3899
4647
|
|
3900
4648
|
end
|
3901
4649
|
|
4650
|
+
def to_s(colour: false)
|
4651
|
+
|
4652
|
+
a = [
|
4653
|
+
'Silent (Vibrate On)',
|
4654
|
+
'Normal (Vibrate Off)',
|
4655
|
+
'Vibrate when ringing On',
|
4656
|
+
'Vibrate when ringing Off',
|
4657
|
+
'Vibrate when ringing Toggle'
|
4658
|
+
]
|
4659
|
+
|
4660
|
+
status = a[@h[:option_int]]
|
4661
|
+
@s = 'Vibrate Enable/Disable ' + "\n " + status + "\n "
|
4662
|
+
super()
|
4663
|
+
|
4664
|
+
end
|
4665
|
+
|
4666
|
+
def to_summary(colour: false)
|
4667
|
+
|
4668
|
+
@s = 'Vibrate Enable/Disable'
|
4669
|
+
|
4670
|
+
end
|
3902
4671
|
end
|
3903
4672
|
|
3904
4673
|
# Category: Volume
|
@@ -3915,6 +4684,11 @@ class VolumeIncrementDecrementAction < VolumeAction
|
|
3915
4684
|
|
3916
4685
|
end
|
3917
4686
|
|
4687
|
+
def to_s(colour: false)
|
4688
|
+
'VolumeIncrementDecrementAction ' + @h.inspect
|
4689
|
+
end
|
4690
|
+
|
4691
|
+
alias to_summary to_s
|
3918
4692
|
end
|
3919
4693
|
|
3920
4694
|
# Category: Volume
|
@@ -3932,6 +4706,11 @@ class SpeakerPhoneAction < VolumeAction
|
|
3932
4706
|
|
3933
4707
|
end
|
3934
4708
|
|
4709
|
+
def to_s(colour: false)
|
4710
|
+
'SpeakerPhoneAction ' + @h.inspect
|
4711
|
+
end
|
4712
|
+
|
4713
|
+
alias to_summary to_s
|
3935
4714
|
end
|
3936
4715
|
|
3937
4716
|
# Category: Volume
|
@@ -3951,7 +4730,11 @@ class SetVolumeAction < VolumeAction
|
|
3951
4730
|
super(options.merge h)
|
3952
4731
|
|
3953
4732
|
end
|
3954
|
-
|
4733
|
+
|
4734
|
+
def to_s(colour: false)
|
4735
|
+
volume = @h[:stream_index_array].zip(@h[:stream_volume_array]).to_h[true]
|
4736
|
+
'Volume Change ' + "Notification = %s%%" % volume
|
4737
|
+
end
|
3955
4738
|
end
|
3956
4739
|
|
3957
4740
|
class Constraint < MacroObject
|
@@ -3964,7 +4747,7 @@ class Constraint < MacroObject
|
|
3964
4747
|
|
3965
4748
|
detail.select {|k,v| @h.include? k }.all? {|key,value| @h[key] == value}
|
3966
4749
|
|
3967
|
-
end
|
4750
|
+
end
|
3968
4751
|
|
3969
4752
|
#def to_s()
|
3970
4753
|
# ''
|
@@ -3986,22 +4769,7 @@ class Constraint < MacroObject
|
|
3986
4769
|
|
3987
4770
|
end
|
3988
4771
|
|
3989
|
-
class TimeOfDayConstraint < Constraint
|
3990
4772
|
|
3991
|
-
def initialize(h={})
|
3992
|
-
|
3993
|
-
options = {
|
3994
|
-
end_hour: 8,
|
3995
|
-
end_minute: 0,
|
3996
|
-
start_hour: 22,
|
3997
|
-
start_minute: 0
|
3998
|
-
}
|
3999
|
-
|
4000
|
-
super(options.merge h)
|
4001
|
-
|
4002
|
-
end
|
4003
|
-
|
4004
|
-
end
|
4005
4773
|
|
4006
4774
|
# Category: Battery/Power
|
4007
4775
|
#
|
@@ -4019,7 +4787,7 @@ class BatteryLevelConstraint < Constraint
|
|
4019
4787
|
|
4020
4788
|
end
|
4021
4789
|
|
4022
|
-
def to_s()
|
4790
|
+
def to_s(colour: false)
|
4023
4791
|
|
4024
4792
|
operator = if @h[:greater_than] then
|
4025
4793
|
'>'
|
@@ -4033,6 +4801,8 @@ class BatteryLevelConstraint < Constraint
|
|
4033
4801
|
|
4034
4802
|
"Battery %s %s%%" % [operator, level]
|
4035
4803
|
end
|
4804
|
+
|
4805
|
+
alias to_summary to_s
|
4036
4806
|
|
4037
4807
|
end
|
4038
4808
|
|
@@ -4050,6 +4820,11 @@ class BatterySaverStateConstraint < Constraint
|
|
4050
4820
|
|
4051
4821
|
end
|
4052
4822
|
|
4823
|
+
def to_s(colour: false)
|
4824
|
+
'BatterySaverStateConstraint ' + @h.inspect
|
4825
|
+
end
|
4826
|
+
|
4827
|
+
alias to_summary to_s
|
4053
4828
|
end
|
4054
4829
|
|
4055
4830
|
# Category: Battery/Power
|
@@ -4068,6 +4843,11 @@ class BatteryTemperatureConstraint < Constraint
|
|
4068
4843
|
|
4069
4844
|
end
|
4070
4845
|
|
4846
|
+
def to_s(colour: false)
|
4847
|
+
'BatteryTemperatureConstraint ' + @h.inspect
|
4848
|
+
end
|
4849
|
+
|
4850
|
+
alias to_summary to_s
|
4071
4851
|
end
|
4072
4852
|
|
4073
4853
|
# Category: Battery/Power
|
@@ -4085,7 +4865,7 @@ class ExternalPowerConstraint < Constraint
|
|
4085
4865
|
|
4086
4866
|
end
|
4087
4867
|
|
4088
|
-
def to_s()
|
4868
|
+
def to_s(colour: false)
|
4089
4869
|
connection = @h[:external_power] ? 'Connected' : 'Disconnected'
|
4090
4870
|
'Power ' + connection
|
4091
4871
|
end
|
@@ -4108,11 +4888,12 @@ class BluetoothConstraint < Constraint
|
|
4108
4888
|
|
4109
4889
|
end
|
4110
4890
|
|
4111
|
-
def to_s()
|
4891
|
+
def to_s(colour: false)
|
4112
4892
|
device = @h[:device_name] #== 'Any Device' ? 'Any' : @h[:device_name]
|
4113
4893
|
"Device Connected (%s)" % device
|
4114
4894
|
end
|
4115
4895
|
|
4896
|
+
alias to_summary to_s
|
4116
4897
|
|
4117
4898
|
end
|
4118
4899
|
|
@@ -4130,6 +4911,11 @@ class GPSEnabledConstraint < Constraint
|
|
4130
4911
|
|
4131
4912
|
end
|
4132
4913
|
|
4914
|
+
def to_s(colour: false)
|
4915
|
+
'GPSEnabledConstraint ' + @h.inspect
|
4916
|
+
end
|
4917
|
+
|
4918
|
+
alias to_summary to_s
|
4133
4919
|
end
|
4134
4920
|
|
4135
4921
|
# Category: Connectivity
|
@@ -4146,6 +4932,11 @@ class LocationModeConstraint < Constraint
|
|
4146
4932
|
|
4147
4933
|
end
|
4148
4934
|
|
4935
|
+
def to_s(colour: false)
|
4936
|
+
'LocationModeConstraint ' + @h.inspect
|
4937
|
+
end
|
4938
|
+
|
4939
|
+
alias to_summary to_s
|
4149
4940
|
end
|
4150
4941
|
|
4151
4942
|
# Category: Connectivity
|
@@ -4162,6 +4953,11 @@ class SignalOnOffConstraint < Constraint
|
|
4162
4953
|
|
4163
4954
|
end
|
4164
4955
|
|
4956
|
+
def to_s(colour: false)
|
4957
|
+
'SignalOnOffConstraint ' + @h.inspect
|
4958
|
+
end
|
4959
|
+
|
4960
|
+
alias to_summary to_s
|
4165
4961
|
end
|
4166
4962
|
|
4167
4963
|
# Category: Connectivity
|
@@ -4179,6 +4975,11 @@ class WifiConstraint < Constraint
|
|
4179
4975
|
|
4180
4976
|
end
|
4181
4977
|
|
4978
|
+
def to_s(colour: false)
|
4979
|
+
'WifiConstraint ' + @h.inspect
|
4980
|
+
end
|
4981
|
+
|
4982
|
+
alias to_summary to_s
|
4182
4983
|
end
|
4183
4984
|
|
4184
4985
|
# Category: Connectivity
|
@@ -4197,6 +4998,11 @@ class CellTowerConstraint < Constraint
|
|
4197
4998
|
|
4198
4999
|
end
|
4199
5000
|
|
5001
|
+
def to_s(colour: false)
|
5002
|
+
'CellTowerConstraint ' + @h.inspect
|
5003
|
+
end
|
5004
|
+
|
5005
|
+
alias to_summary to_s
|
4200
5006
|
end
|
4201
5007
|
|
4202
5008
|
# Category: Connectivity
|
@@ -4213,6 +5019,11 @@ class IsRoamingConstraint < Constraint
|
|
4213
5019
|
|
4214
5020
|
end
|
4215
5021
|
|
5022
|
+
def to_s(colour: false)
|
5023
|
+
'IsRoamingConstraint ' + @h.inspect
|
5024
|
+
end
|
5025
|
+
|
5026
|
+
alias to_summary to_s
|
4216
5027
|
end
|
4217
5028
|
|
4218
5029
|
# Category: Connectivity
|
@@ -4229,6 +5040,11 @@ class DataOnOffConstraint < Constraint
|
|
4229
5040
|
|
4230
5041
|
end
|
4231
5042
|
|
5043
|
+
def to_s(colour: false)
|
5044
|
+
'DataOnOffConstraint ' + @h.inspect
|
5045
|
+
end
|
5046
|
+
|
5047
|
+
alias to_summary to_s
|
4232
5048
|
end
|
4233
5049
|
|
4234
5050
|
# Category: Connectivity
|
@@ -4248,6 +5064,11 @@ class WifiHotSpotConstraint < Constraint
|
|
4248
5064
|
|
4249
5065
|
end
|
4250
5066
|
|
5067
|
+
def to_s(colour: false)
|
5068
|
+
'WifiHotSpotConstraint ' + @h.inspect
|
5069
|
+
end
|
5070
|
+
|
5071
|
+
alias to_summary to_s
|
4251
5072
|
end
|
4252
5073
|
|
4253
5074
|
# Category: Date/Time
|
@@ -4271,6 +5092,11 @@ class CalendarConstraint < Constraint
|
|
4271
5092
|
|
4272
5093
|
end
|
4273
5094
|
|
5095
|
+
def to_s(colour: false)
|
5096
|
+
'CalendarConstraint ' + @h.inspect
|
5097
|
+
end
|
5098
|
+
|
5099
|
+
alias to_summary to_s
|
4274
5100
|
end
|
4275
5101
|
|
4276
5102
|
# Category: Date/Time
|
@@ -4287,6 +5113,11 @@ class DayOfWeekConstraint < Constraint
|
|
4287
5113
|
|
4288
5114
|
end
|
4289
5115
|
|
5116
|
+
def to_s(colour: false)
|
5117
|
+
'DayOfWeekConstraint ' + @h.inspect
|
5118
|
+
end
|
5119
|
+
|
5120
|
+
alias to_summary to_s
|
4290
5121
|
end
|
4291
5122
|
|
4292
5123
|
# Category: Date/Time
|
@@ -4296,16 +5127,22 @@ class TimeOfDayConstraint < Constraint
|
|
4296
5127
|
def initialize(h={})
|
4297
5128
|
|
4298
5129
|
options = {
|
4299
|
-
end_hour:
|
4300
|
-
end_minute:
|
4301
|
-
start_hour:
|
4302
|
-
start_minute:
|
5130
|
+
end_hour: 8,
|
5131
|
+
end_minute: 0,
|
5132
|
+
start_hour: 22,
|
5133
|
+
start_minute: 0
|
4303
5134
|
}
|
4304
5135
|
|
4305
5136
|
super(options.merge h)
|
4306
5137
|
|
4307
5138
|
end
|
4308
|
-
|
5139
|
+
|
5140
|
+
def to_s(colour: false)
|
5141
|
+
a = @h[:start_hour], @h[:start_minute], @h[:end_hour], @h[:start_minute]
|
5142
|
+
'Time of Day ' + "%02d:%02d - %02d:%02d" % a
|
5143
|
+
end
|
5144
|
+
|
5145
|
+
alias to_summary to_s
|
4309
5146
|
end
|
4310
5147
|
|
4311
5148
|
# Category: Date/Time
|
@@ -4323,6 +5160,11 @@ class DayOfMonthConstraint < Constraint
|
|
4323
5160
|
|
4324
5161
|
end
|
4325
5162
|
|
5163
|
+
def to_s(colour: false)
|
5164
|
+
'DayOfMonthConstraint ' + @h.inspect
|
5165
|
+
end
|
5166
|
+
|
5167
|
+
alias to_summary to_s
|
4326
5168
|
end
|
4327
5169
|
|
4328
5170
|
# Category: Date/Time
|
@@ -4339,6 +5181,11 @@ class MonthOfYearConstraint < Constraint
|
|
4339
5181
|
|
4340
5182
|
end
|
4341
5183
|
|
5184
|
+
def to_s(colour: false)
|
5185
|
+
'MonthOfYearConstraint ' + @h.inspect
|
5186
|
+
end
|
5187
|
+
|
5188
|
+
alias to_summary to_s
|
4342
5189
|
end
|
4343
5190
|
|
4344
5191
|
# Category: Date/Time
|
@@ -4355,6 +5202,11 @@ class SunsetSunriseConstraint < Constraint
|
|
4355
5202
|
|
4356
5203
|
end
|
4357
5204
|
|
5205
|
+
def to_s(colour: false)
|
5206
|
+
'SunsetSunriseConstraint ' + @h.inspect
|
5207
|
+
end
|
5208
|
+
|
5209
|
+
alias to_summary to_s
|
4358
5210
|
end
|
4359
5211
|
|
4360
5212
|
# Category: Device State
|
@@ -4399,12 +5251,14 @@ class AirplaneModeConstraint < Constraint
|
|
4399
5251
|
'airplane_mode.' + status
|
4400
5252
|
end
|
4401
5253
|
|
4402
|
-
def to_s()
|
5254
|
+
def to_s(colour: false)
|
4403
5255
|
|
4404
5256
|
status = @h[:enabled] ? 'Enabled' : 'Disabled'
|
4405
5257
|
'Airplane Mode ' + status
|
4406
5258
|
|
4407
5259
|
end
|
5260
|
+
|
5261
|
+
alias to_summary to_s
|
4408
5262
|
|
4409
5263
|
end
|
4410
5264
|
|
@@ -4422,6 +5276,11 @@ class AutoRotateConstraint < Constraint
|
|
4422
5276
|
|
4423
5277
|
end
|
4424
5278
|
|
5279
|
+
def to_s(colour: false)
|
5280
|
+
'AutoRotateConstraint ' + @h.inspect
|
5281
|
+
end
|
5282
|
+
|
5283
|
+
alias to_summary to_s
|
4425
5284
|
end
|
4426
5285
|
|
4427
5286
|
# Category: Device State
|
@@ -4438,9 +5297,11 @@ class DeviceLockedConstraint < Constraint
|
|
4438
5297
|
|
4439
5298
|
end
|
4440
5299
|
|
4441
|
-
def to_s()
|
5300
|
+
def to_s(colour: false)
|
4442
5301
|
'Device ' + (@h[:locked] ? 'Locked' : 'Unlocked')
|
4443
5302
|
end
|
5303
|
+
|
5304
|
+
alias to_summary to_s
|
4444
5305
|
|
4445
5306
|
end
|
4446
5307
|
|
@@ -4458,6 +5319,11 @@ class RoamingOnOffConstraint < Constraint
|
|
4458
5319
|
|
4459
5320
|
end
|
4460
5321
|
|
5322
|
+
def to_s(colour: false)
|
5323
|
+
'RoamingOnOffConstraint ' + @h.inspect
|
5324
|
+
end
|
5325
|
+
|
5326
|
+
alias to_summary to_s
|
4461
5327
|
end
|
4462
5328
|
|
4463
5329
|
# Category: Device State
|
@@ -4475,6 +5341,11 @@ class TimeSinceBootConstraint < Constraint
|
|
4475
5341
|
|
4476
5342
|
end
|
4477
5343
|
|
5344
|
+
def to_s(colour: false)
|
5345
|
+
'TimeSinceBootConstraint ' + @h.inspect
|
5346
|
+
end
|
5347
|
+
|
5348
|
+
alias to_summary to_s
|
4478
5349
|
end
|
4479
5350
|
|
4480
5351
|
# Category: Device State
|
@@ -4491,6 +5362,11 @@ class AutoSyncConstraint < Constraint
|
|
4491
5362
|
|
4492
5363
|
end
|
4493
5364
|
|
5365
|
+
def to_s(colour: false)
|
5366
|
+
'AutoSyncConstraint ' + @h.inspect
|
5367
|
+
end
|
5368
|
+
|
5369
|
+
alias to_summary to_s
|
4494
5370
|
end
|
4495
5371
|
|
4496
5372
|
# Category: Device State
|
@@ -4507,6 +5383,11 @@ class NFCStateConstraint < Constraint
|
|
4507
5383
|
|
4508
5384
|
end
|
4509
5385
|
|
5386
|
+
def to_s(colour: false)
|
5387
|
+
'NFCStateConstraint ' + @h.inspect
|
5388
|
+
end
|
5389
|
+
|
5390
|
+
alias to_summary to_s
|
4510
5391
|
end
|
4511
5392
|
|
4512
5393
|
# Category: Device State
|
@@ -4523,6 +5404,11 @@ class IsRootedConstraint < Constraint
|
|
4523
5404
|
|
4524
5405
|
end
|
4525
5406
|
|
5407
|
+
def to_s(colour: false)
|
5408
|
+
'IsRootedConstraint ' + @h.inspect
|
5409
|
+
end
|
5410
|
+
|
5411
|
+
alias to_summary to_s
|
4526
5412
|
end
|
4527
5413
|
|
4528
5414
|
# Category: Device State
|
@@ -4539,6 +5425,11 @@ class VpnConstraint < Constraint
|
|
4539
5425
|
|
4540
5426
|
end
|
4541
5427
|
|
5428
|
+
def to_s(colour: false)
|
5429
|
+
'VpnConstraint ' + @h.inspect
|
5430
|
+
end
|
5431
|
+
|
5432
|
+
alias to_summary to_s
|
4542
5433
|
end
|
4543
5434
|
|
4544
5435
|
# Category: MacroDroid Specific
|
@@ -4557,6 +5448,11 @@ class MacroEnabledConstraint < Constraint
|
|
4557
5448
|
|
4558
5449
|
end
|
4559
5450
|
|
5451
|
+
def to_s(colour: false)
|
5452
|
+
'MacroEnabledConstraint ' + @h.inspect
|
5453
|
+
end
|
5454
|
+
|
5455
|
+
alias to_summary to_s
|
4560
5456
|
end
|
4561
5457
|
|
4562
5458
|
# Category: MacroDroid Specific
|
@@ -4574,23 +5470,46 @@ class ModeConstraint < Constraint
|
|
4574
5470
|
|
4575
5471
|
end
|
4576
5472
|
|
5473
|
+
def to_s(colour: false)
|
5474
|
+
'ModeConstraint ' + @h.inspect
|
5475
|
+
end
|
5476
|
+
|
5477
|
+
alias to_summary to_s
|
4577
5478
|
end
|
4578
5479
|
|
4579
5480
|
# Category: MacroDroid Specific
|
4580
5481
|
#
|
4581
5482
|
class TriggerThatInvokedConstraint < Constraint
|
4582
|
-
|
5483
|
+
using ColouredText
|
5484
|
+
|
4583
5485
|
def initialize(h={})
|
4584
5486
|
|
5487
|
+
puts ('h: ' + h.inspect).green
|
5488
|
+
@trigger = h[:macro].triggers.find {|x| x.siguid == h[:si_guid_that_invoked] }
|
5489
|
+
|
4585
5490
|
options = {
|
4586
5491
|
not: false,
|
4587
5492
|
si_guid_that_invoked: -4951291100076165433,
|
4588
5493
|
trigger_name: 'Shake Device'
|
4589
5494
|
}
|
4590
5495
|
|
5496
|
+
#super(options.merge filter(options,h))
|
4591
5497
|
super(options.merge h)
|
4592
5498
|
|
4593
5499
|
end
|
5500
|
+
|
5501
|
+
def to_s(colour: false)
|
5502
|
+
'Trigger Fired: ' + @trigger.to_s(colour: colour)
|
5503
|
+
end
|
5504
|
+
|
5505
|
+
def to_summary(colour: false)
|
5506
|
+
#puts '@trigger' + @trigger.inspect
|
5507
|
+
if @trigger then
|
5508
|
+
'Trigger Fired: ' + @trigger.to_summary(colour: colour)
|
5509
|
+
else
|
5510
|
+
'Trigger Fired: Trigger not found; guid: ' + @h[:si_guid_that_invoked].inspect
|
5511
|
+
end
|
5512
|
+
end
|
4594
5513
|
|
4595
5514
|
end
|
4596
5515
|
|
@@ -4612,6 +5531,11 @@ class LastRunTimeConstraint < Constraint
|
|
4612
5531
|
|
4613
5532
|
end
|
4614
5533
|
|
5534
|
+
def to_s(colour: false)
|
5535
|
+
'LastRunTimeConstraint ' + @h.inspect
|
5536
|
+
end
|
5537
|
+
|
5538
|
+
alias to_summary to_s
|
4615
5539
|
end
|
4616
5540
|
|
4617
5541
|
# Category: Media
|
@@ -4628,10 +5552,12 @@ class HeadphonesConnectionConstraint < Constraint
|
|
4628
5552
|
|
4629
5553
|
end
|
4630
5554
|
|
4631
|
-
def to_s()
|
5555
|
+
def to_s(colour: false)
|
4632
5556
|
connection = @h[:connected] ? 'Connected' : 'Disconnected'
|
4633
5557
|
'Headphones ' + connection
|
4634
5558
|
end
|
5559
|
+
|
5560
|
+
alias to_summary to_s
|
4635
5561
|
|
4636
5562
|
end
|
4637
5563
|
|
@@ -4649,6 +5575,11 @@ class MusicActiveConstraint < Constraint
|
|
4649
5575
|
|
4650
5576
|
end
|
4651
5577
|
|
5578
|
+
def to_s(colour: false)
|
5579
|
+
'MusicActiveConstraint ' + @h.inspect
|
5580
|
+
end
|
5581
|
+
|
5582
|
+
alias to_summary to_s
|
4652
5583
|
end
|
4653
5584
|
|
4654
5585
|
# Category: Notification
|
@@ -4672,6 +5603,11 @@ class NotificationPresentConstraint < Constraint
|
|
4672
5603
|
|
4673
5604
|
end
|
4674
5605
|
|
5606
|
+
def to_s(colour: false)
|
5607
|
+
'NotificationPresentConstraint ' + @h.inspect
|
5608
|
+
end
|
5609
|
+
|
5610
|
+
alias to_summary to_s
|
4675
5611
|
end
|
4676
5612
|
|
4677
5613
|
# Category: Notification
|
@@ -4689,6 +5625,11 @@ class PriorityModeConstraint < Constraint
|
|
4689
5625
|
|
4690
5626
|
end
|
4691
5627
|
|
5628
|
+
def to_s(colour: false)
|
5629
|
+
'PriorityModeConstraint ' + @h.inspect
|
5630
|
+
end
|
5631
|
+
|
5632
|
+
alias to_summary to_s
|
4692
5633
|
end
|
4693
5634
|
|
4694
5635
|
# Category: Notification
|
@@ -4705,6 +5646,11 @@ class NotificationVolumeConstraint < Constraint
|
|
4705
5646
|
|
4706
5647
|
end
|
4707
5648
|
|
5649
|
+
def to_s(colour: false)
|
5650
|
+
'NotificationVolumeConstraint ' + @h.inspect
|
5651
|
+
end
|
5652
|
+
|
5653
|
+
alias to_summary to_s
|
4708
5654
|
end
|
4709
5655
|
|
4710
5656
|
# Category: Phone
|
@@ -4721,6 +5667,11 @@ class InCallConstraint < Constraint
|
|
4721
5667
|
|
4722
5668
|
end
|
4723
5669
|
|
5670
|
+
def to_s(colour: false)
|
5671
|
+
'InCallConstraint ' + @h.inspect
|
5672
|
+
end
|
5673
|
+
|
5674
|
+
alias to_summary to_s
|
4724
5675
|
end
|
4725
5676
|
|
4726
5677
|
# Category: Phone
|
@@ -4736,6 +5687,11 @@ class PhoneRingingConstraint < Constraint
|
|
4736
5687
|
super(options.merge h)
|
4737
5688
|
|
4738
5689
|
end
|
5690
|
+
|
5691
|
+
def to_s(colour: false)
|
5692
|
+
@s = @h[:ringing] ? 'Phone Ringing' : 'Not Ringing'
|
5693
|
+
super(colour: colour)
|
5694
|
+
end
|
4739
5695
|
|
4740
5696
|
end
|
4741
5697
|
|
@@ -4757,6 +5713,11 @@ class BrightnessConstraint < Constraint
|
|
4757
5713
|
|
4758
5714
|
end
|
4759
5715
|
|
5716
|
+
def to_s(colour: false)
|
5717
|
+
'BrightnessConstraint ' + @h.inspect
|
5718
|
+
end
|
5719
|
+
|
5720
|
+
alias to_summary to_s
|
4760
5721
|
end
|
4761
5722
|
|
4762
5723
|
# Category: Screen and Speaker
|
@@ -4769,9 +5730,15 @@ class VolumeConstraint < Constraint
|
|
4769
5730
|
option: 0
|
4770
5731
|
}
|
4771
5732
|
|
4772
|
-
super(options.merge h)
|
5733
|
+
super(options.merge filter(options, h))
|
4773
5734
|
|
4774
5735
|
end
|
5736
|
+
|
5737
|
+
def to_s(colour: false)
|
5738
|
+
a = ['Volume On', 'Vibrate Only' 'Silent', 'Vibrate or Silent']
|
5739
|
+
|
5740
|
+
"Ringer Volume\n " + a[@h[:option]]
|
5741
|
+
end
|
4775
5742
|
|
4776
5743
|
end
|
4777
5744
|
|
@@ -4789,6 +5756,11 @@ class SpeakerPhoneConstraint < Constraint
|
|
4789
5756
|
|
4790
5757
|
end
|
4791
5758
|
|
5759
|
+
def to_s(colour: false)
|
5760
|
+
'SpeakerPhoneConstraint ' + @h.inspect
|
5761
|
+
end
|
5762
|
+
|
5763
|
+
alias to_summary to_s
|
4792
5764
|
end
|
4793
5765
|
|
4794
5766
|
# Category: Screen and Speaker
|
@@ -4805,6 +5777,11 @@ class DarkThemeConstraint < Constraint
|
|
4805
5777
|
|
4806
5778
|
end
|
4807
5779
|
|
5780
|
+
def to_s(colour: false)
|
5781
|
+
'DarkThemeConstraint ' + @h.inspect
|
5782
|
+
end
|
5783
|
+
|
5784
|
+
alias to_summary to_s
|
4808
5785
|
end
|
4809
5786
|
|
4810
5787
|
# Category: Screen and Speaker
|
@@ -4822,9 +5799,11 @@ class ScreenOnOffConstraint < Constraint
|
|
4822
5799
|
|
4823
5800
|
end
|
4824
5801
|
|
4825
|
-
def to_s()
|
5802
|
+
def to_s(colour: false)
|
4826
5803
|
'Screen ' + (@h[:screen_on] ? 'On' : 'Off')
|
4827
5804
|
end
|
5805
|
+
|
5806
|
+
alias to_summary to_s
|
4828
5807
|
|
4829
5808
|
end
|
4830
5809
|
|
@@ -4844,6 +5823,11 @@ class VolumeLevelConstraint < Constraint
|
|
4844
5823
|
|
4845
5824
|
end
|
4846
5825
|
|
5826
|
+
def to_s(colour: false)
|
5827
|
+
'VolumeLevelConstraint ' + @h.inspect
|
5828
|
+
end
|
5829
|
+
|
5830
|
+
alias to_summary to_s
|
4847
5831
|
end
|
4848
5832
|
|
4849
5833
|
# Category: Sensors
|
@@ -4861,6 +5845,11 @@ class FaceUpDownConstraint < Constraint
|
|
4861
5845
|
|
4862
5846
|
end
|
4863
5847
|
|
5848
|
+
def to_s(colour: false)
|
5849
|
+
'FaceUpDownConstraint ' + @h.inspect
|
5850
|
+
end
|
5851
|
+
|
5852
|
+
alias to_summary to_s
|
4864
5853
|
end
|
4865
5854
|
|
4866
5855
|
# Category: Sensors
|
@@ -4879,7 +5868,7 @@ class LightLevelConstraint < Constraint
|
|
4879
5868
|
|
4880
5869
|
end
|
4881
5870
|
|
4882
|
-
def to_s()
|
5871
|
+
def to_s(colour: false)
|
4883
5872
|
|
4884
5873
|
operator = @h[:light_level] == -1 ? 'Less than' : 'Greater than'
|
4885
5874
|
condition = operator + ' ' + @h[:light_level_float].to_s + 'lx'
|
@@ -4903,6 +5892,11 @@ class DeviceOrientationConstraint < Constraint
|
|
4903
5892
|
|
4904
5893
|
end
|
4905
5894
|
|
5895
|
+
def to_s(colour: false)
|
5896
|
+
'DeviceOrientationConstraint ' + @h.inspect
|
5897
|
+
end
|
5898
|
+
|
5899
|
+
alias to_summary to_s
|
4906
5900
|
end
|
4907
5901
|
|
4908
5902
|
# Category: Sensors
|
@@ -4919,8 +5913,135 @@ class ProximitySensorConstraint < Constraint
|
|
4919
5913
|
|
4920
5914
|
end
|
4921
5915
|
|
4922
|
-
def to_s()
|
5916
|
+
def to_s(colour: false)
|
4923
5917
|
'Proximity Sensor: ' + (@h[:near] ? 'Near' : 'Far')
|
4924
5918
|
end
|
4925
5919
|
|
4926
5920
|
end
|
5921
|
+
|
5922
|
+
|
5923
|
+
# ----------------------------------------------------------------------------
|
5924
|
+
|
5925
|
+
|
5926
|
+
class DroidSim
|
5927
|
+
|
5928
|
+
class Service
|
5929
|
+
def initialize(callback)
|
5930
|
+
@callback = callback
|
5931
|
+
end
|
5932
|
+
end
|
5933
|
+
|
5934
|
+
class Application < Service
|
5935
|
+
|
5936
|
+
def closed()
|
5937
|
+
end
|
5938
|
+
def launched()
|
5939
|
+
end
|
5940
|
+
end
|
5941
|
+
|
5942
|
+
class Battery < Service
|
5943
|
+
|
5944
|
+
def level()
|
5945
|
+
end
|
5946
|
+
|
5947
|
+
def temperature()
|
5948
|
+
end
|
5949
|
+
|
5950
|
+
end
|
5951
|
+
class Bluetooth < Service
|
5952
|
+
|
5953
|
+
def enable()
|
5954
|
+
@callback.on_bluetooth_enabled()
|
5955
|
+
end
|
5956
|
+
|
5957
|
+
#def enabled
|
5958
|
+
# @callback.on_bluetooth_enabled()
|
5959
|
+
#end
|
5960
|
+
|
5961
|
+
def enabled?
|
5962
|
+
end
|
5963
|
+
|
5964
|
+
def disabled
|
5965
|
+
end
|
5966
|
+
|
5967
|
+
def disabled?
|
5968
|
+
end
|
5969
|
+
end
|
5970
|
+
|
5971
|
+
class Calendar < Service
|
5972
|
+
def event(starts, ends)
|
5973
|
+
end
|
5974
|
+
end
|
5975
|
+
|
5976
|
+
class DayTime < Service
|
5977
|
+
|
5978
|
+
def initialie(s)
|
5979
|
+
end
|
5980
|
+
end
|
5981
|
+
|
5982
|
+
class Headphones < Service
|
5983
|
+
def inserted
|
5984
|
+
end
|
5985
|
+
|
5986
|
+
def removed
|
5987
|
+
end
|
5988
|
+
end
|
5989
|
+
|
5990
|
+
class Webhook < Service
|
5991
|
+
|
5992
|
+
def url()
|
5993
|
+
@url
|
5994
|
+
end
|
5995
|
+
|
5996
|
+
def url=(s)
|
5997
|
+
@url = s
|
5998
|
+
end
|
5999
|
+
end
|
6000
|
+
|
6001
|
+
class Wifi < Service
|
6002
|
+
def enabled
|
6003
|
+
end
|
6004
|
+
|
6005
|
+
def disabled
|
6006
|
+
end
|
6007
|
+
|
6008
|
+
def ssid_in_range()
|
6009
|
+
end
|
6010
|
+
|
6011
|
+
def ssid_out_of_range()
|
6012
|
+
end
|
6013
|
+
end
|
6014
|
+
|
6015
|
+
class Power < Service
|
6016
|
+
def connected()
|
6017
|
+
end
|
6018
|
+
|
6019
|
+
def disconnected()
|
6020
|
+
end
|
6021
|
+
|
6022
|
+
def button_toggle()
|
6023
|
+
end
|
6024
|
+
end
|
6025
|
+
|
6026
|
+
class Popup < Service
|
6027
|
+
def message(s)
|
6028
|
+
puts s
|
6029
|
+
end
|
6030
|
+
end
|
6031
|
+
|
6032
|
+
|
6033
|
+
attr_reader :bluetooth, :popup
|
6034
|
+
|
6035
|
+
def initialize()
|
6036
|
+
|
6037
|
+
@bluetooth = Bluetooth.new self
|
6038
|
+
@popup = Popup.new self
|
6039
|
+
|
6040
|
+
end
|
6041
|
+
|
6042
|
+
def on_bluetooth_enabled()
|
6043
|
+
|
6044
|
+
end
|
6045
|
+
|
6046
|
+
|
6047
|
+
end
|