ruby-macrodroid 0.7.4 → 0.7.9
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 +1264 -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: 1a302b724cde397e0ef27e3461dad14fa0801158692951fdcf013fccfbc0348c
|
4
|
+
data.tar.gz: b8a041e5185746e5bd2809e98d098cba2ff20534ddcb679f1c342397840a2976
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5311bafd81b65b5a0371aab705d469bdab0ec5b920b40c4004e8e7758460b06f72f590c7c2f49d7cf9d21c8407debe682d81235b66d8d27224bd3a8786e75a22
|
7
|
+
data.tar.gz: 27d2d926b5230f6f545d28e59db686edb82708f65d05128ed2fa9e2b3e59375ca14f00dcf72cd99bd8502d7aeb1534077ca9bf71e86e73ad10e62066d1b4dd57
|
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,30 +730,59 @@ EOF
|
|
700
730
|
end.join("\n")
|
701
731
|
|
702
732
|
a = [
|
703
|
-
'm: ' + @title,
|
704
|
-
@triggers.map {|x| "t:
|
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"),
|
705
736
|
actions
|
706
737
|
]
|
707
738
|
|
708
|
-
|
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
|
709
744
|
|
710
745
|
if @description and @description.length >= 1 then
|
711
|
-
a.insert(1,
|
746
|
+
a.insert(1, (colour ? "d".bg_gray.gray.bold : 'd') + ': ' \
|
747
|
+
+ @description.gsub(/\n/,"\n "))
|
712
748
|
end
|
713
749
|
|
714
750
|
a.join("\n") + "\n"
|
715
751
|
|
716
752
|
end
|
717
753
|
|
718
|
-
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
|
719
784
|
|
720
|
-
a = [
|
721
|
-
'm: ' + @title,
|
722
|
-
't: ' + @triggers.map(&:to_summary).join(", "),
|
723
|
-
'a: ' + @actions.map(&:to_summary).join(", "),
|
724
|
-
]
|
725
785
|
|
726
|
-
a << 'c: ' + @constraints.map(&:to_summary).join(", ") if @constraints.any?
|
727
786
|
|
728
787
|
a.join("\n") + "\n"
|
729
788
|
|
@@ -737,7 +796,7 @@ EOF
|
|
737
796
|
|
738
797
|
def object(h={})
|
739
798
|
|
740
|
-
puts ('inside object h:' + h.inspect).debug if @debug
|
799
|
+
puts ('inside object h:' + h.inspect).debug if @debug
|
741
800
|
klass = Object.const_get h[:class_type]
|
742
801
|
puts klass.inspect.highlight if $debug
|
743
802
|
|
@@ -745,7 +804,13 @@ EOF
|
|
745
804
|
puts 'GeofenceTrigger found'.highlight if $debug
|
746
805
|
GeofenceTrigger.new(h, geofences: @geofences)
|
747
806
|
else
|
748
|
-
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
|
+
|
749
814
|
end
|
750
815
|
|
751
816
|
end
|
@@ -889,21 +954,22 @@ class MacroDroid
|
|
889
954
|
@macros.map(&:to_pc).join("\n\n")
|
890
955
|
end
|
891
956
|
|
892
|
-
def to_s()
|
957
|
+
def to_s(colour: false)
|
893
958
|
|
894
959
|
lines = []
|
895
960
|
|
896
961
|
if @geofences.any? then
|
897
|
-
lines << @geofences.map {|_, value|
|
962
|
+
lines << @geofences.map {|_, value| (colour ? "g".green.bold : 'g') \
|
963
|
+
+ ': ' + value.to_s}.join("\n\n") + "\n"
|
898
964
|
end
|
899
965
|
|
900
|
-
lines << @macros.map(
|
966
|
+
lines << @macros.map {|x| x.to_s(colour: colour)}.join("\n")
|
901
967
|
lines.join("\n")
|
902
968
|
|
903
969
|
end
|
904
970
|
|
905
|
-
def to_summary()
|
906
|
-
@macros.map(
|
971
|
+
def to_summary(colour: false)
|
972
|
+
@macros.map {|x| x.to_summary(colour: colour)}.join("\n")
|
907
973
|
end
|
908
974
|
|
909
975
|
private
|
@@ -915,13 +981,23 @@ class MacroDroid
|
|
915
981
|
name = e.text.to_s.strip
|
916
982
|
item = e.element('item')
|
917
983
|
coordinates = item.text('coordinates')
|
918
|
-
|
919
|
-
|
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
|
920
995
|
|
921
996
|
id = UUID.new.generate
|
922
997
|
|
923
998
|
h = {
|
924
999
|
name: name,
|
1000
|
+
location: location,
|
925
1001
|
longitude: longitude,
|
926
1002
|
latitude: latitude,
|
927
1003
|
radius: radius,
|
@@ -1035,10 +1111,11 @@ class GeofenceMap
|
|
1035
1111
|
|
1036
1112
|
attr_accessor :name, :longitude, :latitude, :radius, :id
|
1037
1113
|
|
1038
|
-
def initialize(id: '', longitude: '', latitude: '', name: '', radius: ''
|
1114
|
+
def initialize(id: '', longitude: '', latitude: '', name: '', radius: '',
|
1115
|
+
location: nil)
|
1039
1116
|
|
1040
|
-
@id, @latitude, @longitude, @name, @radius = id, latitude, \
|
1041
|
-
longitude, name, radius
|
1117
|
+
@id, @latitude, @longitude, @name, @radius, @location = id, latitude, \
|
1118
|
+
longitude, name, radius, location
|
1042
1119
|
|
1043
1120
|
end
|
1044
1121
|
|
@@ -1054,10 +1131,15 @@ class GeofenceMap
|
|
1054
1131
|
|
1055
1132
|
end
|
1056
1133
|
|
1057
|
-
def to_s()
|
1134
|
+
def to_s(colour: false)
|
1058
1135
|
|
1059
|
-
|
1060
|
-
|
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")
|
1061
1143
|
|
1062
1144
|
end
|
1063
1145
|
|
@@ -1066,15 +1148,16 @@ end
|
|
1066
1148
|
class MacroObject
|
1067
1149
|
using ColouredText
|
1068
1150
|
|
1069
|
-
attr_reader :type
|
1151
|
+
attr_reader :type, :siguid
|
1070
1152
|
attr_accessor :options
|
1071
1153
|
|
1072
1154
|
def initialize(h={})
|
1073
1155
|
|
1074
1156
|
$env ||= {}
|
1075
1157
|
|
1158
|
+
@attributes = %i(constraint_list is_or_condition is_disabled siguid)
|
1076
1159
|
@h = {constraint_list: [], is_or_condition: false,
|
1077
|
-
is_disabled: false}.merge(h)
|
1160
|
+
is_disabled: false, siguid: nil}.merge(h)
|
1078
1161
|
@list = []
|
1079
1162
|
|
1080
1163
|
# fetch the class name and convert from camelCase to snake_eyes
|
@@ -1082,6 +1165,7 @@ class MacroObject
|
|
1082
1165
|
.gsub(/\B[A-Z][a-z]/){|x| '_' + x.downcase}\
|
1083
1166
|
.gsub(/[a-z][A-Z]/){|x| x[0] + '_' + x[1].downcase}\
|
1084
1167
|
.downcase.to_sym
|
1168
|
+
@constraints = []
|
1085
1169
|
end
|
1086
1170
|
|
1087
1171
|
def to_h()
|
@@ -1102,8 +1186,21 @@ class MacroObject
|
|
1102
1186
|
|
1103
1187
|
end
|
1104
1188
|
|
1105
|
-
def
|
1106
|
-
|
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
|
+
|
1107
1204
|
end
|
1108
1205
|
|
1109
1206
|
alias to_summary to_s
|
@@ -1112,7 +1209,7 @@ class MacroObject
|
|
1112
1209
|
|
1113
1210
|
def filter(options, h)
|
1114
1211
|
|
1115
|
-
(h.keys - options.keys).each {|key| h.delete key }
|
1212
|
+
(h.keys - (options.keys + @attributes.to_a)).each {|key| h.delete key }
|
1116
1213
|
return h
|
1117
1214
|
|
1118
1215
|
end
|
@@ -1173,6 +1270,11 @@ class WebHookTrigger < Trigger
|
|
1173
1270
|
|
1174
1271
|
end
|
1175
1272
|
|
1273
|
+
def to_s(colour: false)
|
1274
|
+
'WebHookTrigger ' + @h.inspect
|
1275
|
+
end
|
1276
|
+
|
1277
|
+
alias to_summary to_s
|
1176
1278
|
end
|
1177
1279
|
|
1178
1280
|
# Category: Applications
|
@@ -1204,6 +1306,11 @@ class WifiConnectionTrigger < Trigger
|
|
1204
1306
|
|
1205
1307
|
end
|
1206
1308
|
|
1309
|
+
def to_s(colour: false)
|
1310
|
+
'WifiConnectionTrigger ' + @h.inspect
|
1311
|
+
end
|
1312
|
+
|
1313
|
+
alias to_summary to_s
|
1207
1314
|
end
|
1208
1315
|
|
1209
1316
|
# Category: Applications
|
@@ -1224,6 +1331,11 @@ class ApplicationInstalledRemovedTrigger < Trigger
|
|
1224
1331
|
|
1225
1332
|
end
|
1226
1333
|
|
1334
|
+
def to_s(colour: false)
|
1335
|
+
'ApplicationInstalledRemovedTrigger ' + @h.inspect
|
1336
|
+
end
|
1337
|
+
|
1338
|
+
alias to_summary to_s
|
1227
1339
|
end
|
1228
1340
|
|
1229
1341
|
# Category: Applications
|
@@ -1242,6 +1354,11 @@ class ApplicationLaunchedTrigger < Trigger
|
|
1242
1354
|
|
1243
1355
|
end
|
1244
1356
|
|
1357
|
+
def to_s(colour: false)
|
1358
|
+
'ApplicationLaunchedTrigger ' + @h.inspect
|
1359
|
+
end
|
1360
|
+
|
1361
|
+
alias to_summary to_s
|
1245
1362
|
end
|
1246
1363
|
|
1247
1364
|
# Category: Battery/Power
|
@@ -1260,7 +1377,7 @@ class BatteryLevelTrigger < Trigger
|
|
1260
1377
|
|
1261
1378
|
end
|
1262
1379
|
|
1263
|
-
def to_s()
|
1380
|
+
def to_s(colour: false)
|
1264
1381
|
operator = @h[:decreases_to] ? '<=' : '>='
|
1265
1382
|
"Battery %s %s%%" % [operator, @h[:battery_level]]
|
1266
1383
|
end
|
@@ -1283,6 +1400,11 @@ class BatteryTemperatureTrigger < Trigger
|
|
1283
1400
|
|
1284
1401
|
end
|
1285
1402
|
|
1403
|
+
def to_s(colour: false)
|
1404
|
+
'BatteryTemperatureTrigger ' + @h.inspect
|
1405
|
+
end
|
1406
|
+
|
1407
|
+
alias to_summary to_s
|
1286
1408
|
end
|
1287
1409
|
|
1288
1410
|
# Category: Battery/Power
|
@@ -1299,6 +1421,11 @@ class PowerButtonToggleTrigger < Trigger
|
|
1299
1421
|
|
1300
1422
|
end
|
1301
1423
|
|
1424
|
+
def to_s(colour: false)
|
1425
|
+
'PowerButtonToggleTrigger ' + @h.inspect
|
1426
|
+
end
|
1427
|
+
|
1428
|
+
alias to_summary to_s
|
1302
1429
|
end
|
1303
1430
|
|
1304
1431
|
|
@@ -1318,6 +1445,27 @@ class ExternalPowerTrigger < Trigger
|
|
1318
1445
|
super(options.merge h)
|
1319
1446
|
|
1320
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
|
1321
1469
|
|
1322
1470
|
end
|
1323
1471
|
|
@@ -1337,6 +1485,11 @@ class CallActiveTrigger < Trigger
|
|
1337
1485
|
|
1338
1486
|
end
|
1339
1487
|
|
1488
|
+
def to_s(colour: false)
|
1489
|
+
'CallActiveTrigger ' + @h.inspect
|
1490
|
+
end
|
1491
|
+
|
1492
|
+
alias to_summary to_s
|
1340
1493
|
end
|
1341
1494
|
|
1342
1495
|
# Category: Call/SMS
|
@@ -1357,6 +1510,12 @@ class IncomingCallTrigger < Trigger
|
|
1357
1510
|
|
1358
1511
|
end
|
1359
1512
|
|
1513
|
+
def to_s(colour: false)
|
1514
|
+
caller = @h[:incoming_call_from_list].map {|x| "%s" % x[:name]}.join(', ')
|
1515
|
+
"Call Incoming [%s]" % caller
|
1516
|
+
end
|
1517
|
+
|
1518
|
+
alias to_summary to_s
|
1360
1519
|
end
|
1361
1520
|
|
1362
1521
|
# Category: Call/SMS
|
@@ -1377,6 +1536,11 @@ class OutgoingCallTrigger < Trigger
|
|
1377
1536
|
|
1378
1537
|
end
|
1379
1538
|
|
1539
|
+
def to_s(colour: false)
|
1540
|
+
'OutgoingCallTrigger ' + @h.inspect
|
1541
|
+
end
|
1542
|
+
|
1543
|
+
alias to_summary to_s
|
1380
1544
|
end
|
1381
1545
|
|
1382
1546
|
# Category: Call/SMS
|
@@ -1397,6 +1561,11 @@ class CallEndedTrigger < Trigger
|
|
1397
1561
|
|
1398
1562
|
end
|
1399
1563
|
|
1564
|
+
def to_s(colour: false)
|
1565
|
+
'CallEndedTrigger ' + @h.inspect
|
1566
|
+
end
|
1567
|
+
|
1568
|
+
alias to_summary to_s
|
1400
1569
|
end
|
1401
1570
|
|
1402
1571
|
# Category: Call/SMS
|
@@ -1413,6 +1582,11 @@ class CallMissedTrigger < Trigger
|
|
1413
1582
|
|
1414
1583
|
end
|
1415
1584
|
|
1585
|
+
def to_s(colour: false)
|
1586
|
+
'CallMissedTrigger ' + @h.inspect
|
1587
|
+
end
|
1588
|
+
|
1589
|
+
alias to_summary to_s
|
1416
1590
|
end
|
1417
1591
|
|
1418
1592
|
# Category: Call/SMS
|
@@ -1437,6 +1611,11 @@ class IncomingSMSTrigger < Trigger
|
|
1437
1611
|
|
1438
1612
|
end
|
1439
1613
|
|
1614
|
+
def to_s(colour: false)
|
1615
|
+
'IncomingSMSTrigger ' + @h.inspect
|
1616
|
+
end
|
1617
|
+
|
1618
|
+
alias to_summary to_s
|
1440
1619
|
end
|
1441
1620
|
|
1442
1621
|
# Category: Connectivity
|
@@ -1453,6 +1632,11 @@ class WebHookTrigger < Trigger
|
|
1453
1632
|
|
1454
1633
|
end
|
1455
1634
|
|
1635
|
+
def to_s(colour: false)
|
1636
|
+
'WebHookTrigger ' + @h.inspect
|
1637
|
+
end
|
1638
|
+
|
1639
|
+
alias to_summary to_s
|
1456
1640
|
end
|
1457
1641
|
|
1458
1642
|
# Category: Connectivity
|
@@ -1470,6 +1654,12 @@ class WifiConnectionTrigger < Trigger
|
|
1470
1654
|
|
1471
1655
|
end
|
1472
1656
|
|
1657
|
+
def to_s(colour: false)
|
1658
|
+
access_point = @h[:ssid_list].first
|
1659
|
+
'Connected to network ' + access_point
|
1660
|
+
end
|
1661
|
+
|
1662
|
+
alias to_summary to_s
|
1473
1663
|
end
|
1474
1664
|
|
1475
1665
|
# Category: Connectivity
|
@@ -1488,6 +1678,11 @@ class BluetoothTrigger < Trigger
|
|
1488
1678
|
|
1489
1679
|
end
|
1490
1680
|
|
1681
|
+
def to_s(colour: false)
|
1682
|
+
'BluetoothTrigger ' + @h.inspect
|
1683
|
+
end
|
1684
|
+
|
1685
|
+
alias to_summary to_s
|
1491
1686
|
end
|
1492
1687
|
|
1493
1688
|
# Category: Connectivity
|
@@ -1505,6 +1700,11 @@ class HeadphonesTrigger < Trigger
|
|
1505
1700
|
|
1506
1701
|
end
|
1507
1702
|
|
1703
|
+
def to_s(colour: false)
|
1704
|
+
'HeadphonesTrigger ' + @h.inspect
|
1705
|
+
end
|
1706
|
+
|
1707
|
+
alias to_summary to_s
|
1508
1708
|
end
|
1509
1709
|
|
1510
1710
|
# Category: Connectivity
|
@@ -1521,6 +1721,11 @@ class SignalOnOffTrigger < Trigger
|
|
1521
1721
|
|
1522
1722
|
end
|
1523
1723
|
|
1724
|
+
def to_s(colour: false)
|
1725
|
+
'SignalOnOffTrigger ' + @h.inspect
|
1726
|
+
end
|
1727
|
+
|
1728
|
+
alias to_summary to_s
|
1524
1729
|
end
|
1525
1730
|
|
1526
1731
|
# Category: Connectivity
|
@@ -1537,6 +1742,11 @@ class UsbDeviceConnectionTrigger < Trigger
|
|
1537
1742
|
|
1538
1743
|
end
|
1539
1744
|
|
1745
|
+
def to_s(colour: false)
|
1746
|
+
'UsbDeviceConnectionTrigger ' + @h.inspect
|
1747
|
+
end
|
1748
|
+
|
1749
|
+
alias to_summary to_s
|
1540
1750
|
end
|
1541
1751
|
|
1542
1752
|
# Category: Connectivity
|
@@ -1574,6 +1784,11 @@ class WifiSSIDTrigger < Trigger
|
|
1574
1784
|
|
1575
1785
|
end
|
1576
1786
|
|
1787
|
+
def to_s(colour: false)
|
1788
|
+
'WifiSSIDTrigger ' + @h.inspect
|
1789
|
+
end
|
1790
|
+
|
1791
|
+
alias to_summary to_s
|
1577
1792
|
end
|
1578
1793
|
|
1579
1794
|
# Category: Date/Time
|
@@ -1600,6 +1815,11 @@ class CalendarTrigger < Trigger
|
|
1600
1815
|
|
1601
1816
|
end
|
1602
1817
|
|
1818
|
+
def to_s(colour: false)
|
1819
|
+
'CalendarTrigger ' + @h.inspect
|
1820
|
+
end
|
1821
|
+
|
1822
|
+
alias to_summary to_s
|
1603
1823
|
end
|
1604
1824
|
|
1605
1825
|
# Category: Date/Time
|
@@ -1637,7 +1857,7 @@ class TimerTrigger < Trigger
|
|
1637
1857
|
|
1638
1858
|
#puts ('h: ' + h.inspect).debug
|
1639
1859
|
|
1640
|
-
options = {
|
1860
|
+
@options = {
|
1641
1861
|
alarm_id: uuid(),
|
1642
1862
|
days_of_week: [false, false, false, false, false, false, false],
|
1643
1863
|
minute: 10,
|
@@ -1645,7 +1865,8 @@ class TimerTrigger < Trigger
|
|
1645
1865
|
use_alarm: false
|
1646
1866
|
}
|
1647
1867
|
|
1648
|
-
super(options.merge filter(options, h))
|
1868
|
+
#super(options.merge filter(options, h))
|
1869
|
+
super(@options.merge h)
|
1649
1870
|
|
1650
1871
|
end
|
1651
1872
|
|
@@ -1665,18 +1886,38 @@ class TimerTrigger < Trigger
|
|
1665
1886
|
"time.is? '%s'" % self.to_s.gsub(',', ' or')
|
1666
1887
|
end
|
1667
1888
|
|
1668
|
-
def to_s()
|
1889
|
+
def to_s(colour: false)
|
1669
1890
|
|
1670
|
-
dow = @h[:days_of_week]
|
1671
|
-
|
1672
|
-
a = Date::ABBR_DAYNAMES
|
1891
|
+
dow = @h[:days_of_week]
|
1673
1892
|
|
1674
|
-
|
1675
|
-
|
1893
|
+
wd = Date::ABBR_DAYNAMES
|
1894
|
+
a = (wd[1..-1] << wd.first)
|
1895
|
+
|
1896
|
+
a2 = dow.map.with_index.to_a
|
1897
|
+
start = a2.find {|x,i| x}.last
|
1898
|
+
r = a2[start..-1].take_while {|x,i| x == true}
|
1899
|
+
r2 = a2[start..-1].select {|x,i| x}
|
1900
|
+
|
1901
|
+
days = if r == r2 then
|
1902
|
+
|
1903
|
+
x1, x2 = a2[start].last, a2[r.length-1].last
|
1904
|
+
|
1905
|
+
if (x2 - x1) >= 2 then
|
1906
|
+
"%s-%s" % [a[x1],a[x2]]
|
1907
|
+
else
|
1908
|
+
a.zip(dow).select {|_,b| b}.map(&:first).join(', ')
|
1909
|
+
end
|
1910
|
+
else
|
1911
|
+
a.zip(dow).select {|_,b| b}.map(&:first).join(', ')
|
1912
|
+
end
|
1913
|
+
|
1914
|
+
time = Time.parse("%s:%s" % [@h[:hour], @h[:minute]]).strftime("%H:%M")
|
1676
1915
|
|
1677
|
-
"
|
1916
|
+
"%s %s" % [time, days]
|
1678
1917
|
end
|
1679
1918
|
|
1919
|
+
alias to_summary to_s
|
1920
|
+
|
1680
1921
|
private
|
1681
1922
|
|
1682
1923
|
def time()
|
@@ -1708,6 +1949,11 @@ class StopwatchTrigger < Trigger
|
|
1708
1949
|
|
1709
1950
|
end
|
1710
1951
|
|
1952
|
+
def to_s(colour: false)
|
1953
|
+
'StopwatchTrigger ' + @h.inspect
|
1954
|
+
end
|
1955
|
+
|
1956
|
+
alias to_summary to_s
|
1711
1957
|
end
|
1712
1958
|
|
1713
1959
|
# Category: Date/Time
|
@@ -1736,6 +1982,11 @@ class DayTrigger < Trigger
|
|
1736
1982
|
|
1737
1983
|
end
|
1738
1984
|
|
1985
|
+
def to_s(colour: false)
|
1986
|
+
'DayTrigger ' + @h.inspect
|
1987
|
+
end
|
1988
|
+
|
1989
|
+
alias to_summary to_s
|
1739
1990
|
end
|
1740
1991
|
|
1741
1992
|
# Category: Date/Time
|
@@ -1759,6 +2010,15 @@ class RegularIntervalTrigger < Trigger
|
|
1759
2010
|
|
1760
2011
|
end
|
1761
2012
|
|
2013
|
+
def to_s(colour: false)
|
2014
|
+
|
2015
|
+
interval = Subunit.new(units={minutes:60, hours:60}, \
|
2016
|
+
seconds: @h[:seconds]).strfunit("%c")
|
2017
|
+
'Regular Interval ' + "\n Interval: " + interval
|
2018
|
+
|
2019
|
+
end
|
2020
|
+
|
2021
|
+
alias to_summary to_s
|
1762
2022
|
end
|
1763
2023
|
|
1764
2024
|
class DeviceEventsTrigger < Trigger
|
@@ -1793,6 +2053,11 @@ class AirplaneModeTrigger < DeviceEventsTrigger
|
|
1793
2053
|
|
1794
2054
|
end
|
1795
2055
|
|
2056
|
+
def to_s(colour: false)
|
2057
|
+
'AirplaneModeTrigger ' + @h.inspect
|
2058
|
+
end
|
2059
|
+
|
2060
|
+
alias to_summary to_s
|
1796
2061
|
end
|
1797
2062
|
|
1798
2063
|
# Category: Device Events
|
@@ -1809,6 +2074,11 @@ class AutoSyncChangeTrigger < DeviceEventsTrigger
|
|
1809
2074
|
|
1810
2075
|
end
|
1811
2076
|
|
2077
|
+
def to_s(colour: false)
|
2078
|
+
'AutoSyncChangeTrigger ' + @h.inspect
|
2079
|
+
end
|
2080
|
+
|
2081
|
+
alias to_summary to_s
|
1812
2082
|
end
|
1813
2083
|
|
1814
2084
|
# Category: Device Events
|
@@ -1825,6 +2095,11 @@ class DayDreamTrigger < DeviceEventsTrigger
|
|
1825
2095
|
|
1826
2096
|
end
|
1827
2097
|
|
2098
|
+
def to_s(colour: false)
|
2099
|
+
'DayDreamTrigger ' + @h.inspect
|
2100
|
+
end
|
2101
|
+
|
2102
|
+
alias to_summary to_s
|
1828
2103
|
end
|
1829
2104
|
|
1830
2105
|
# Category: Device Events
|
@@ -1841,6 +2116,11 @@ class DockTrigger < DeviceEventsTrigger
|
|
1841
2116
|
|
1842
2117
|
end
|
1843
2118
|
|
2119
|
+
def to_s(colour: false)
|
2120
|
+
'DockTrigger ' + @h.inspect
|
2121
|
+
end
|
2122
|
+
|
2123
|
+
alias to_summary to_s
|
1844
2124
|
end
|
1845
2125
|
|
1846
2126
|
# Category: Device Events
|
@@ -1861,7 +2141,7 @@ class FailedLoginTrigger < DeviceEventsTrigger
|
|
1861
2141
|
'failed_login?'
|
1862
2142
|
end
|
1863
2143
|
|
1864
|
-
def to_s()
|
2144
|
+
def to_s(colour: false)
|
1865
2145
|
'Failed Login Attempt'
|
1866
2146
|
end
|
1867
2147
|
end
|
@@ -1880,6 +2160,11 @@ class GPSEnabledTrigger < DeviceEventsTrigger
|
|
1880
2160
|
|
1881
2161
|
end
|
1882
2162
|
|
2163
|
+
def to_s(colour: false)
|
2164
|
+
'GPSEnabledTrigger ' + @h.inspect
|
2165
|
+
end
|
2166
|
+
|
2167
|
+
alias to_summary to_s
|
1883
2168
|
end
|
1884
2169
|
|
1885
2170
|
# Category: Device Events
|
@@ -1896,6 +2181,11 @@ class MusicPlayingTrigger < DeviceEventsTrigger
|
|
1896
2181
|
|
1897
2182
|
end
|
1898
2183
|
|
2184
|
+
def to_s(colour: false)
|
2185
|
+
'MusicPlayingTrigger ' + @h.inspect
|
2186
|
+
end
|
2187
|
+
|
2188
|
+
alias to_summary to_s
|
1899
2189
|
end
|
1900
2190
|
|
1901
2191
|
|
@@ -1912,9 +2202,11 @@ class DeviceUnlockedTrigger < DeviceEventsTrigger
|
|
1912
2202
|
|
1913
2203
|
end
|
1914
2204
|
|
1915
|
-
def to_s()
|
2205
|
+
def to_s(colour: false)
|
1916
2206
|
'Screen Unlocked'
|
1917
2207
|
end
|
2208
|
+
|
2209
|
+
alias to_summary to_s
|
1918
2210
|
|
1919
2211
|
end
|
1920
2212
|
|
@@ -1932,6 +2224,11 @@ class AutoRotateChangeTrigger < DeviceEventsTrigger
|
|
1932
2224
|
|
1933
2225
|
end
|
1934
2226
|
|
2227
|
+
def to_s(colour: false)
|
2228
|
+
'AutoRotateChangeTrigger ' + @h.inspect
|
2229
|
+
end
|
2230
|
+
|
2231
|
+
alias to_summary to_s
|
1935
2232
|
end
|
1936
2233
|
|
1937
2234
|
# Category: Device Events
|
@@ -1949,6 +2246,11 @@ class ClipboardChangeTrigger < DeviceEventsTrigger
|
|
1949
2246
|
|
1950
2247
|
end
|
1951
2248
|
|
2249
|
+
def to_s(colour: false)
|
2250
|
+
'ClipboardChangeTrigger ' + @h.inspect
|
2251
|
+
end
|
2252
|
+
|
2253
|
+
alias to_summary to_s
|
1952
2254
|
end
|
1953
2255
|
|
1954
2256
|
# Category: Device Events
|
@@ -1964,6 +2266,11 @@ class BootTrigger < DeviceEventsTrigger
|
|
1964
2266
|
|
1965
2267
|
end
|
1966
2268
|
|
2269
|
+
def to_s(colour: false)
|
2270
|
+
'BootTrigger ' + @h.inspect
|
2271
|
+
end
|
2272
|
+
|
2273
|
+
alias to_summary to_s
|
1967
2274
|
end
|
1968
2275
|
|
1969
2276
|
# Category: Device Events
|
@@ -1984,6 +2291,11 @@ class IntentReceivedTrigger < DeviceEventsTrigger
|
|
1984
2291
|
|
1985
2292
|
end
|
1986
2293
|
|
2294
|
+
def to_s(colour: false)
|
2295
|
+
'IntentReceivedTrigger ' + @h.inspect
|
2296
|
+
end
|
2297
|
+
|
2298
|
+
alias to_summary to_s
|
1987
2299
|
end
|
1988
2300
|
|
1989
2301
|
# Category: Device Events
|
@@ -2010,6 +2322,12 @@ class NotificationTrigger < DeviceEventsTrigger
|
|
2010
2322
|
|
2011
2323
|
end
|
2012
2324
|
|
2325
|
+
def to_s(colour: false)
|
2326
|
+
s = (@h[:package_name_list] + @h[:application_name_list]).uniq.join(', ')
|
2327
|
+
'Notification Received ' + "\n Any Content (%s)" % s
|
2328
|
+
end
|
2329
|
+
|
2330
|
+
alias to_summary to_s
|
2013
2331
|
end
|
2014
2332
|
|
2015
2333
|
# Category: Device Events
|
@@ -2025,6 +2343,12 @@ class ScreenOnOffTrigger < DeviceEventsTrigger
|
|
2025
2343
|
super(options.merge h)
|
2026
2344
|
|
2027
2345
|
end
|
2346
|
+
|
2347
|
+
def to_s(colour: false)
|
2348
|
+
'Screen ' + (@h[:screen_on] ? 'On' : 'Off')
|
2349
|
+
end
|
2350
|
+
|
2351
|
+
alias to_summary to_s
|
2028
2352
|
|
2029
2353
|
end
|
2030
2354
|
|
@@ -2042,6 +2366,11 @@ class SilentModeTrigger < DeviceEventsTrigger
|
|
2042
2366
|
|
2043
2367
|
end
|
2044
2368
|
|
2369
|
+
def to_s(colour: false)
|
2370
|
+
'SilentModeTrigger ' + @h.inspect
|
2371
|
+
end
|
2372
|
+
|
2373
|
+
alias to_summary to_s
|
2045
2374
|
end
|
2046
2375
|
|
2047
2376
|
# Category: Location
|
@@ -2067,6 +2396,11 @@ class WeatherTrigger < Trigger
|
|
2067
2396
|
|
2068
2397
|
end
|
2069
2398
|
|
2399
|
+
def to_s(colour: false)
|
2400
|
+
'WeatherTrigger ' + @h.inspect
|
2401
|
+
end
|
2402
|
+
|
2403
|
+
alias to_summary to_s
|
2070
2404
|
end
|
2071
2405
|
|
2072
2406
|
# Category: Location
|
@@ -2076,7 +2410,7 @@ class GeofenceTrigger < Trigger
|
|
2076
2410
|
def initialize( h={}, geofences: {})
|
2077
2411
|
|
2078
2412
|
if h[:name] then
|
2079
|
-
puts ('geofences2: ' + geofences.inspect)
|
2413
|
+
puts ('geofences2: ' + geofences.inspect) if $debug
|
2080
2414
|
found = geofences.find {|x| x.name.downcase == h[:name].downcase}
|
2081
2415
|
h[:geofence_id] = found.id if found
|
2082
2416
|
|
@@ -2095,7 +2429,7 @@ class GeofenceTrigger < Trigger
|
|
2095
2429
|
|
2096
2430
|
end
|
2097
2431
|
|
2098
|
-
def to_s()
|
2432
|
+
def to_s(colour: false)
|
2099
2433
|
|
2100
2434
|
if $debug then
|
2101
2435
|
puts ' @geofences: ' + @geofences.inspect
|
@@ -2130,6 +2464,11 @@ class SunriseSunsetTrigger < Trigger
|
|
2130
2464
|
|
2131
2465
|
end
|
2132
2466
|
|
2467
|
+
def to_s(colour: false)
|
2468
|
+
'SunriseSunsetTrigger ' + @h.inspect
|
2469
|
+
end
|
2470
|
+
|
2471
|
+
alias to_summary to_s
|
2133
2472
|
end
|
2134
2473
|
|
2135
2474
|
|
@@ -2159,12 +2498,12 @@ class ActivityRecognitionTrigger < SensorsTrigger
|
|
2159
2498
|
|
2160
2499
|
end
|
2161
2500
|
|
2162
|
-
def to_s()
|
2501
|
+
def to_s(colour: false)
|
2163
2502
|
activity = @activity[@h[:selected_index]]
|
2164
2503
|
'Activity - ' + activity
|
2165
2504
|
end
|
2166
2505
|
|
2167
|
-
def to_summary
|
2506
|
+
def to_summary(colour: false)
|
2168
2507
|
|
2169
2508
|
activity = @activity[@h[:selected_index]]
|
2170
2509
|
s = if activity.length > 10 then
|
@@ -2202,7 +2541,7 @@ class ProximityTrigger < SensorsTrigger
|
|
2202
2541
|
|
2203
2542
|
end
|
2204
2543
|
|
2205
|
-
def to_s()
|
2544
|
+
def to_s(colour: false)
|
2206
2545
|
|
2207
2546
|
distance = if @h[:near] then
|
2208
2547
|
'Near'
|
@@ -2232,7 +2571,7 @@ class ShakeDeviceTrigger < SensorsTrigger
|
|
2232
2571
|
'shake_device?'
|
2233
2572
|
end
|
2234
2573
|
|
2235
|
-
def to_s()
|
2574
|
+
def to_s(colour: false)
|
2236
2575
|
'Shake Device'
|
2237
2576
|
end
|
2238
2577
|
|
@@ -2263,7 +2602,7 @@ class FlipDeviceTrigger < SensorsTrigger
|
|
2263
2602
|
@h[:face_down] ? 'flip_device_down?' : 'flip_device_up?'
|
2264
2603
|
end
|
2265
2604
|
|
2266
|
-
def to_s()
|
2605
|
+
def to_s(colour: false)
|
2267
2606
|
|
2268
2607
|
action = @h[:face_down] ? 'Face Up -> Face Down' : 'Face Down -> Face Up'
|
2269
2608
|
'Flip Device ' + action
|
@@ -2286,6 +2625,11 @@ class OrientationTrigger < SensorsTrigger
|
|
2286
2625
|
|
2287
2626
|
end
|
2288
2627
|
|
2628
|
+
def to_s(colour: false)
|
2629
|
+
'OrientationTrigger ' + @h.inspect
|
2630
|
+
end
|
2631
|
+
|
2632
|
+
alias to_summary to_s
|
2289
2633
|
end
|
2290
2634
|
|
2291
2635
|
# Category: User Input
|
@@ -2311,6 +2655,11 @@ class FloatingButtonTrigger < Trigger
|
|
2311
2655
|
|
2312
2656
|
end
|
2313
2657
|
|
2658
|
+
def to_s(colour: false)
|
2659
|
+
'Floating Button'
|
2660
|
+
end
|
2661
|
+
|
2662
|
+
alias to_summary to_s
|
2314
2663
|
end
|
2315
2664
|
|
2316
2665
|
# Category: User Input
|
@@ -2326,6 +2675,11 @@ class ShortcutTrigger < Trigger
|
|
2326
2675
|
|
2327
2676
|
end
|
2328
2677
|
|
2678
|
+
def to_s(colour: false)
|
2679
|
+
'ShortcutTrigger ' + @h.inspect
|
2680
|
+
end
|
2681
|
+
|
2682
|
+
alias to_summary to_s
|
2329
2683
|
end
|
2330
2684
|
|
2331
2685
|
# Category: User Input
|
@@ -2344,6 +2698,33 @@ class VolumeButtonTrigger < Trigger
|
|
2344
2698
|
super(options.merge h)
|
2345
2699
|
|
2346
2700
|
end
|
2701
|
+
|
2702
|
+
def to_s(colour: false)
|
2703
|
+
|
2704
|
+
a = [
|
2705
|
+
'Volume Up',
|
2706
|
+
'Volume Down',
|
2707
|
+
'Volume Up - Long Press',
|
2708
|
+
'Volume Down - Long Press'
|
2709
|
+
]
|
2710
|
+
|
2711
|
+
lines = [a[@h[:option]]]
|
2712
|
+
lines << ' ' + (@h[:dont_change_volume] ? 'Retain Previous Volume' : 'Update Volume')
|
2713
|
+
@s = lines.join("\n")
|
2714
|
+
end
|
2715
|
+
|
2716
|
+
def to_summary(colour: false)
|
2717
|
+
a = [
|
2718
|
+
'Volume Up',
|
2719
|
+
'Volume Down',
|
2720
|
+
'Volume Up - Long Press',
|
2721
|
+
'Volume Down - Long Press'
|
2722
|
+
]
|
2723
|
+
|
2724
|
+
lines = [a[@h[:option]]]
|
2725
|
+
lines << (@h[:dont_change_volume] ? 'Retain Previous Volume' : 'Update Volume')
|
2726
|
+
@s = lines.join(": ")
|
2727
|
+
end
|
2347
2728
|
|
2348
2729
|
end
|
2349
2730
|
|
@@ -2362,6 +2743,11 @@ class MediaButtonPressedTrigger < Trigger
|
|
2362
2743
|
|
2363
2744
|
end
|
2364
2745
|
|
2746
|
+
def to_s(colour: false)
|
2747
|
+
'MediaButtonPressedTrigger ' + @h.inspect
|
2748
|
+
end
|
2749
|
+
|
2750
|
+
alias to_summary to_s
|
2365
2751
|
end
|
2366
2752
|
|
2367
2753
|
# Category: User Input
|
@@ -2380,6 +2766,11 @@ class SwipeTrigger < Trigger
|
|
2380
2766
|
|
2381
2767
|
end
|
2382
2768
|
|
2769
|
+
def to_s(colour: false)
|
2770
|
+
'SwipeTrigger ' + @h.inspect
|
2771
|
+
end
|
2772
|
+
|
2773
|
+
alias to_summary to_s
|
2383
2774
|
end
|
2384
2775
|
|
2385
2776
|
|
@@ -2388,19 +2779,35 @@ class Action < MacroObject
|
|
2388
2779
|
|
2389
2780
|
attr_reader :constraints
|
2390
2781
|
|
2391
|
-
def initialize(h={})
|
2782
|
+
def initialize(h={})
|
2783
|
+
|
2784
|
+
macro = h[:macro]
|
2785
|
+
h.delete :macro
|
2392
2786
|
super(h)
|
2393
2787
|
|
2394
2788
|
# fetch the constraints
|
2395
2789
|
@constraints = @h[:constraint_list].map do |constraint|
|
2396
|
-
object(constraint.to_snake_case)
|
2790
|
+
object(constraint.to_snake_case.merge(macro: macro))
|
2397
2791
|
end
|
2398
2792
|
end
|
2399
2793
|
|
2400
2794
|
def invoke(s='')
|
2401
2795
|
"%s/%s: %s" % [@group, @type, s]
|
2402
2796
|
end
|
2797
|
+
|
2798
|
+
def to_s(colour: false)
|
2403
2799
|
|
2800
|
+
h = @h.clone
|
2801
|
+
h.delete :macro
|
2802
|
+
@s ||= "#<%s %s>" % [self.class, h.inspect]
|
2803
|
+
operator = @h[:is_or_condition] ? 'OR' : 'AND'
|
2804
|
+
constraints = @constraints.map \
|
2805
|
+
{|x| x.to_summary(colour: colour)}.join(" %s " % operator)
|
2806
|
+
|
2807
|
+
@s + constraints
|
2808
|
+
|
2809
|
+
end
|
2810
|
+
|
2404
2811
|
end
|
2405
2812
|
|
2406
2813
|
|
@@ -2435,6 +2842,11 @@ class ShareLocationAction < LocationAction
|
|
2435
2842
|
|
2436
2843
|
end
|
2437
2844
|
|
2845
|
+
def to_s(colour: false)
|
2846
|
+
'ShareLocationAction ' + @h.inspect
|
2847
|
+
end
|
2848
|
+
|
2849
|
+
alias to_summary to_s
|
2438
2850
|
end
|
2439
2851
|
|
2440
2852
|
|
@@ -2464,7 +2876,7 @@ class LaunchActivityAction < ApplicationAction
|
|
2464
2876
|
|
2465
2877
|
end
|
2466
2878
|
|
2467
|
-
def to_s()
|
2879
|
+
def to_s(colour: false)
|
2468
2880
|
'Launch ' + @h[:application_name]
|
2469
2881
|
end
|
2470
2882
|
|
@@ -2485,6 +2897,11 @@ class KillBackgroundAppAction < ApplicationAction
|
|
2485
2897
|
|
2486
2898
|
end
|
2487
2899
|
|
2900
|
+
def to_s(colour: false)
|
2901
|
+
'KillBackgroundAppAction ' + @h.inspect
|
2902
|
+
end
|
2903
|
+
|
2904
|
+
alias to_summary to_s
|
2488
2905
|
end
|
2489
2906
|
|
2490
2907
|
# Category: Applications
|
@@ -2507,7 +2924,7 @@ class OpenWebPageAction < ApplicationAction
|
|
2507
2924
|
|
2508
2925
|
end
|
2509
2926
|
|
2510
|
-
def to_s()
|
2927
|
+
def to_s(colour: false)
|
2511
2928
|
"HTTP GET\n url: " + @h[:url_to_open]
|
2512
2929
|
end
|
2513
2930
|
|
@@ -2538,6 +2955,11 @@ class UploadPhotoAction < CameraAction
|
|
2538
2955
|
|
2539
2956
|
end
|
2540
2957
|
|
2958
|
+
def to_s(colour: false)
|
2959
|
+
'UploadPhotoAction ' + @h.inspect
|
2960
|
+
end
|
2961
|
+
|
2962
|
+
alias to_summary to_s
|
2541
2963
|
end
|
2542
2964
|
|
2543
2965
|
# Category: Camera/Photo
|
@@ -2563,7 +2985,7 @@ class TakePictureAction < CameraAction
|
|
2563
2985
|
'take_photo :' + camera.to_s
|
2564
2986
|
end
|
2565
2987
|
|
2566
|
-
def to_s()
|
2988
|
+
def to_s(colour: false)
|
2567
2989
|
'Take Picture'
|
2568
2990
|
end
|
2569
2991
|
|
@@ -2572,22 +2994,25 @@ end
|
|
2572
2994
|
class IfConditionAction < Action
|
2573
2995
|
|
2574
2996
|
def initialize(h={})
|
2575
|
-
|
2997
|
+
|
2576
2998
|
options = {
|
2577
2999
|
a: true,
|
2578
3000
|
constraint_list: ''
|
2579
3001
|
}
|
3002
|
+
|
3003
|
+
macro = h[:macro]
|
3004
|
+
h2 = options.merge(filter(options,h).merge(macro: macro))
|
2580
3005
|
|
2581
|
-
super(
|
3006
|
+
super(h2)
|
3007
|
+
|
3008
|
+
@label = 'If '
|
2582
3009
|
|
2583
3010
|
end
|
2584
3011
|
|
2585
|
-
def to_s()
|
3012
|
+
def to_s(colour: false)
|
2586
3013
|
|
2587
|
-
|
2588
|
-
|
2589
|
-
puts 'if ... @h ' + @h.inspect
|
2590
|
-
r
|
3014
|
+
@s = "If " #+ @constraints.map(&:to_s).join(" %s " % operator)
|
3015
|
+
super(colour: colour)
|
2591
3016
|
|
2592
3017
|
end
|
2593
3018
|
end
|
@@ -2601,16 +3026,17 @@ class ElseAction < Action
|
|
2601
3026
|
}
|
2602
3027
|
|
2603
3028
|
super(options.merge h)
|
3029
|
+
|
2604
3030
|
|
2605
3031
|
end
|
2606
3032
|
|
2607
|
-
def to_s()
|
3033
|
+
def to_s(colour: false)
|
2608
3034
|
'Else'
|
2609
3035
|
end
|
2610
3036
|
|
2611
3037
|
end
|
2612
3038
|
|
2613
|
-
class
|
3039
|
+
class ElseIfConditionAction < IfConditionAction
|
2614
3040
|
|
2615
3041
|
def initialize(h={})
|
2616
3042
|
|
@@ -2619,24 +3045,66 @@ class EndIfAction < Action
|
|
2619
3045
|
}
|
2620
3046
|
|
2621
3047
|
super(options.merge h)
|
3048
|
+
@label = 'ElseIf '
|
2622
3049
|
|
2623
3050
|
end
|
2624
|
-
|
2625
|
-
|
2626
|
-
'End If'
|
2627
|
-
end
|
2628
|
-
|
3051
|
+
|
3052
|
+
|
2629
3053
|
end
|
2630
3054
|
|
2631
|
-
|
3055
|
+
|
3056
|
+
class EndIfAction < Action
|
2632
3057
|
|
2633
3058
|
def initialize(h={})
|
2634
|
-
|
3059
|
+
|
3060
|
+
options = {
|
3061
|
+
constraint_list: ''
|
3062
|
+
}
|
3063
|
+
|
3064
|
+
super(options.merge h)
|
3065
|
+
|
3066
|
+
end
|
3067
|
+
|
3068
|
+
def to_s(colour: false)
|
3069
|
+
'End If'
|
3070
|
+
end
|
3071
|
+
|
3072
|
+
end
|
3073
|
+
|
3074
|
+
class ConnectivityAction < Action
|
3075
|
+
|
3076
|
+
def initialize(h={})
|
3077
|
+
super(h)
|
2635
3078
|
@group = 'connectivity'
|
2636
3079
|
end
|
2637
3080
|
|
2638
3081
|
end
|
2639
3082
|
|
3083
|
+
# Category: Connectivity
|
3084
|
+
#
|
3085
|
+
class SetAirplaneModeAction < ConnectivityAction
|
3086
|
+
|
3087
|
+
def initialize(h={})
|
3088
|
+
|
3089
|
+
options = {
|
3090
|
+
device_name: '',
|
3091
|
+
state: 1
|
3092
|
+
}
|
3093
|
+
|
3094
|
+
super(options.merge h)
|
3095
|
+
|
3096
|
+
end
|
3097
|
+
|
3098
|
+
def to_s(colour: false)
|
3099
|
+
|
3100
|
+
state = ['On', 'Off', 'Toggle'][@h[:state]]
|
3101
|
+
@s = 'Airplane Mode ' + state + "\n"
|
3102
|
+
super(colour: colour)
|
3103
|
+
|
3104
|
+
end
|
3105
|
+
|
3106
|
+
end
|
3107
|
+
|
2640
3108
|
# Category: Connectivity
|
2641
3109
|
#
|
2642
3110
|
class SetWifiAction < ConnectivityAction
|
@@ -2653,7 +3121,7 @@ class SetWifiAction < ConnectivityAction
|
|
2653
3121
|
|
2654
3122
|
end
|
2655
3123
|
|
2656
|
-
def to_s()
|
3124
|
+
def to_s(colour: false)
|
2657
3125
|
action = @h[:state] == 0 ? 'Enable' : 'Disable'
|
2658
3126
|
action + ' Wifi'
|
2659
3127
|
end
|
@@ -2675,6 +3143,11 @@ class SetBluetoothAction < ConnectivityAction
|
|
2675
3143
|
|
2676
3144
|
end
|
2677
3145
|
|
3146
|
+
def to_s(colour: false)
|
3147
|
+
'SetBluetoothAction ' + @h.inspect
|
3148
|
+
end
|
3149
|
+
|
3150
|
+
alias to_summary to_s
|
2678
3151
|
end
|
2679
3152
|
|
2680
3153
|
# Category: Connectivity
|
@@ -2692,6 +3165,30 @@ class SetBluetoothAction < ConnectivityAction
|
|
2692
3165
|
|
2693
3166
|
end
|
2694
3167
|
|
3168
|
+
def to_s(colour: false)
|
3169
|
+
'SetBluetoothAction ' + @h.inspect
|
3170
|
+
end
|
3171
|
+
|
3172
|
+
alias to_summary to_s
|
3173
|
+
end
|
3174
|
+
|
3175
|
+
class SetHotspotAction < ConnectivityAction
|
3176
|
+
|
3177
|
+
def initialize(h={})
|
3178
|
+
|
3179
|
+
options = {
|
3180
|
+
device_name: "", state: 0, turn_wifi_on: true, use_legacy_mechanism: false, mechanism: 0
|
3181
|
+
|
3182
|
+
}
|
3183
|
+
|
3184
|
+
super(options.merge h)
|
3185
|
+
|
3186
|
+
end
|
3187
|
+
|
3188
|
+
def to_s(colour: false)
|
3189
|
+
action = @h[:turn_wifi_on] ? 'Enable' : 'Disable'
|
3190
|
+
action + ' HotSpot'
|
3191
|
+
end
|
2695
3192
|
end
|
2696
3193
|
|
2697
3194
|
# Category: Connectivity
|
@@ -2720,6 +3217,11 @@ class SendIntentAction < ConnectivityAction
|
|
2720
3217
|
|
2721
3218
|
end
|
2722
3219
|
|
3220
|
+
def to_s(colour: false)
|
3221
|
+
'SendIntentAction ' + @h.inspect
|
3222
|
+
end
|
3223
|
+
|
3224
|
+
alias to_summary to_s
|
2723
3225
|
end
|
2724
3226
|
|
2725
3227
|
|
@@ -2755,6 +3257,11 @@ class SetAlarmClockAction < DateTimeAction
|
|
2755
3257
|
|
2756
3258
|
end
|
2757
3259
|
|
3260
|
+
def to_s(colour: false)
|
3261
|
+
'SetAlarmClockAction ' + @h.inspect
|
3262
|
+
end
|
3263
|
+
|
3264
|
+
alias to_summary to_s
|
2758
3265
|
end
|
2759
3266
|
|
2760
3267
|
# Category: Date/Time
|
@@ -2772,6 +3279,11 @@ class StopWatchAction < DateTimeAction
|
|
2772
3279
|
|
2773
3280
|
end
|
2774
3281
|
|
3282
|
+
def to_s(colour: false)
|
3283
|
+
'StopWatchAction ' + @h.inspect
|
3284
|
+
end
|
3285
|
+
|
3286
|
+
alias to_summary to_s
|
2775
3287
|
end
|
2776
3288
|
|
2777
3289
|
# Category: Date/Time
|
@@ -2798,7 +3310,7 @@ class SayTimeAction < DateTimeAction
|
|
2798
3310
|
'say current_time()'
|
2799
3311
|
end
|
2800
3312
|
|
2801
|
-
def to_s()
|
3313
|
+
def to_s(colour: false)
|
2802
3314
|
'Say Current Time'
|
2803
3315
|
end
|
2804
3316
|
|
@@ -2828,6 +3340,11 @@ class AndroidShortcutsAction < DeviceAction
|
|
2828
3340
|
|
2829
3341
|
end
|
2830
3342
|
|
3343
|
+
def to_s(colour: false)
|
3344
|
+
'AndroidShortcutsAction ' + @h.inspect
|
3345
|
+
end
|
3346
|
+
|
3347
|
+
alias to_summary to_s
|
2831
3348
|
end
|
2832
3349
|
|
2833
3350
|
# Category: Device Actions
|
@@ -2844,6 +3361,11 @@ class ClipboardAction < DeviceAction
|
|
2844
3361
|
|
2845
3362
|
end
|
2846
3363
|
|
3364
|
+
def to_s(colour: false)
|
3365
|
+
'ClipboardAction ' + @h.inspect
|
3366
|
+
end
|
3367
|
+
|
3368
|
+
alias to_summary to_s
|
2847
3369
|
end
|
2848
3370
|
|
2849
3371
|
# Category: Device Actions
|
@@ -2859,6 +3381,11 @@ class PressBackAction < DeviceAction
|
|
2859
3381
|
|
2860
3382
|
end
|
2861
3383
|
|
3384
|
+
def to_s(colour: false)
|
3385
|
+
'PressBackAction ' + @h.inspect
|
3386
|
+
end
|
3387
|
+
|
3388
|
+
alias to_summary to_s
|
2862
3389
|
end
|
2863
3390
|
|
2864
3391
|
# Category: Device Actions
|
@@ -2882,7 +3409,7 @@ class SpeakTextAction < DeviceAction
|
|
2882
3409
|
|
2883
3410
|
end
|
2884
3411
|
|
2885
|
-
def to_s()
|
3412
|
+
def to_s(colour: false)
|
2886
3413
|
"Speak Text (%s)" % @h[:text_to_say]
|
2887
3414
|
end
|
2888
3415
|
|
@@ -2903,6 +3430,11 @@ class UIInteractionAction < DeviceAction
|
|
2903
3430
|
|
2904
3431
|
end
|
2905
3432
|
|
3433
|
+
def to_s(colour: false)
|
3434
|
+
'UIInteractionAction ' + @h.inspect
|
3435
|
+
end
|
3436
|
+
|
3437
|
+
alias to_summary to_s
|
2906
3438
|
end
|
2907
3439
|
|
2908
3440
|
# Category: Device Actions
|
@@ -2918,6 +3450,11 @@ class VoiceSearchAction < DeviceAction
|
|
2918
3450
|
|
2919
3451
|
end
|
2920
3452
|
|
3453
|
+
def to_s(colour: false)
|
3454
|
+
'VoiceSearchAction ' + @h.inspect
|
3455
|
+
end
|
3456
|
+
|
3457
|
+
alias to_summary to_s
|
2921
3458
|
end
|
2922
3459
|
|
2923
3460
|
|
@@ -2944,6 +3481,11 @@ class ExpandCollapseStatusBarAction < DeviceSettingsAction
|
|
2944
3481
|
|
2945
3482
|
end
|
2946
3483
|
|
3484
|
+
def to_s(colour: false)
|
3485
|
+
'ExpandCollapseStatusBarAction ' + @h.inspect
|
3486
|
+
end
|
3487
|
+
|
3488
|
+
alias to_summary to_s
|
2947
3489
|
end
|
2948
3490
|
|
2949
3491
|
# Category: Device Settings
|
@@ -2959,6 +3501,11 @@ class LaunchHomeScreenAction < DeviceSettingsAction
|
|
2959
3501
|
|
2960
3502
|
end
|
2961
3503
|
|
3504
|
+
def to_s(colour: false)
|
3505
|
+
'LaunchHomeScreenAction ' + @h.inspect
|
3506
|
+
end
|
3507
|
+
|
3508
|
+
alias to_summary to_s
|
2962
3509
|
end
|
2963
3510
|
|
2964
3511
|
# Category: Device Settings
|
@@ -2977,11 +3524,11 @@ class CameraFlashLightAction < DeviceSettingsAction
|
|
2977
3524
|
end
|
2978
3525
|
|
2979
3526
|
def to_pc()
|
2980
|
-
'torch :on'
|
3527
|
+
['torch :on', 'torch :off', 'torch :toggle'][@h[:state]]
|
2981
3528
|
end
|
2982
3529
|
|
2983
|
-
def to_s()
|
2984
|
-
'Torch On'
|
3530
|
+
def to_s(colour: false)
|
3531
|
+
['Torch On', 'Torch Off', 'Torch Toggle'][@h[:state]]
|
2985
3532
|
end
|
2986
3533
|
|
2987
3534
|
end
|
@@ -3000,7 +3547,7 @@ class VibrateAction < DeviceSettingsAction
|
|
3000
3547
|
|
3001
3548
|
end
|
3002
3549
|
|
3003
|
-
def to_s()
|
3550
|
+
def to_s(colour: false)
|
3004
3551
|
|
3005
3552
|
pattern = [
|
3006
3553
|
'Blip', 'Short Buzz', 'Long Buzz', 'Rapid', 'Slow', 'Increasing',
|
@@ -3027,6 +3574,11 @@ class SetAutoRotateAction < DeviceSettingsAction
|
|
3027
3574
|
|
3028
3575
|
end
|
3029
3576
|
|
3577
|
+
def to_s(colour: false)
|
3578
|
+
'SetAutoRotateAction ' + @h.inspect
|
3579
|
+
end
|
3580
|
+
|
3581
|
+
alias to_summary to_s
|
3030
3582
|
end
|
3031
3583
|
|
3032
3584
|
# Category: Device Settings
|
@@ -3042,6 +3594,11 @@ class DayDreamAction < DeviceSettingsAction
|
|
3042
3594
|
|
3043
3595
|
end
|
3044
3596
|
|
3597
|
+
def to_s(colour: false)
|
3598
|
+
'DayDreamAction ' + @h.inspect
|
3599
|
+
end
|
3600
|
+
|
3601
|
+
alias to_summary to_s
|
3045
3602
|
end
|
3046
3603
|
|
3047
3604
|
# Category: Device Settings
|
@@ -3057,6 +3614,11 @@ class SetKeyboardAction < DeviceSettingsAction
|
|
3057
3614
|
|
3058
3615
|
end
|
3059
3616
|
|
3617
|
+
def to_s(colour: false)
|
3618
|
+
'SetKeyboardAction ' + @h.inspect
|
3619
|
+
end
|
3620
|
+
|
3621
|
+
alias to_summary to_s
|
3060
3622
|
end
|
3061
3623
|
|
3062
3624
|
# Category: Device Settings
|
@@ -3073,6 +3635,11 @@ class SetKeyguardAction < DeviceSettingsAction
|
|
3073
3635
|
|
3074
3636
|
end
|
3075
3637
|
|
3638
|
+
def to_s(colour: false)
|
3639
|
+
'SetKeyguardAction ' + @h.inspect
|
3640
|
+
end
|
3641
|
+
|
3642
|
+
alias to_summary to_s
|
3076
3643
|
end
|
3077
3644
|
|
3078
3645
|
# Category: Device Settings
|
@@ -3089,6 +3656,11 @@ class CarModeAction < DeviceSettingsAction
|
|
3089
3656
|
|
3090
3657
|
end
|
3091
3658
|
|
3659
|
+
def to_s(colour: false)
|
3660
|
+
'CarModeAction ' + @h.inspect
|
3661
|
+
end
|
3662
|
+
|
3663
|
+
alias to_summary to_s
|
3092
3664
|
end
|
3093
3665
|
|
3094
3666
|
# Category: Device Settings
|
@@ -3106,6 +3678,11 @@ class ChangeKeyboardAction < DeviceSettingsAction
|
|
3106
3678
|
|
3107
3679
|
end
|
3108
3680
|
|
3681
|
+
def to_s(colour: false)
|
3682
|
+
'ChangeKeyboardAction ' + @h.inspect
|
3683
|
+
end
|
3684
|
+
|
3685
|
+
alias to_summary to_s
|
3109
3686
|
end
|
3110
3687
|
|
3111
3688
|
# Category: Device Settings
|
@@ -3127,6 +3704,11 @@ class SetWallpaperAction < DeviceSettingsAction
|
|
3127
3704
|
|
3128
3705
|
end
|
3129
3706
|
|
3707
|
+
def to_s(colour: false)
|
3708
|
+
'SetWallpaperAction ' + @h.inspect
|
3709
|
+
end
|
3710
|
+
|
3711
|
+
alias to_summary to_s
|
3130
3712
|
end
|
3131
3713
|
|
3132
3714
|
class FileAction < Action
|
@@ -3155,6 +3737,11 @@ class OpenFileAction < FileAction
|
|
3155
3737
|
|
3156
3738
|
end
|
3157
3739
|
|
3740
|
+
def to_s(colour: false)
|
3741
|
+
'OpenFileAction ' + @h.inspect
|
3742
|
+
end
|
3743
|
+
|
3744
|
+
alias to_summary to_s
|
3158
3745
|
end
|
3159
3746
|
|
3160
3747
|
|
@@ -3180,6 +3767,11 @@ class ForceLocationUpdateAction < LocationAction
|
|
3180
3767
|
|
3181
3768
|
end
|
3182
3769
|
|
3770
|
+
def to_s(colour: false)
|
3771
|
+
'ForceLocationUpdateAction ' + @h.inspect
|
3772
|
+
end
|
3773
|
+
|
3774
|
+
alias to_summary to_s
|
3183
3775
|
end
|
3184
3776
|
|
3185
3777
|
# Category: Location
|
@@ -3200,6 +3792,11 @@ class ShareLocationAction < LocationAction
|
|
3200
3792
|
|
3201
3793
|
end
|
3202
3794
|
|
3795
|
+
def to_s(colour: false)
|
3796
|
+
'ShareLocationAction ' + @h.inspect
|
3797
|
+
end
|
3798
|
+
|
3799
|
+
alias to_summary to_s
|
3203
3800
|
end
|
3204
3801
|
|
3205
3802
|
# Category: Location
|
@@ -3217,6 +3814,11 @@ class SetLocationUpdateRateAction < LocationAction
|
|
3217
3814
|
|
3218
3815
|
end
|
3219
3816
|
|
3817
|
+
def to_s(colour: false)
|
3818
|
+
'SetLocationUpdateRateAction ' + @h.inspect
|
3819
|
+
end
|
3820
|
+
|
3821
|
+
alias to_summary to_s
|
3220
3822
|
end
|
3221
3823
|
|
3222
3824
|
class LoggingAction < Action
|
@@ -3255,6 +3857,11 @@ class AddCalendarEntryAction < LoggingAction
|
|
3255
3857
|
|
3256
3858
|
end
|
3257
3859
|
|
3860
|
+
def to_s(colour: false)
|
3861
|
+
'AddCalendarEntryAction ' + @h.inspect
|
3862
|
+
end
|
3863
|
+
|
3864
|
+
alias to_summary to_s
|
3258
3865
|
end
|
3259
3866
|
|
3260
3867
|
# Category: Logging
|
@@ -3272,6 +3879,11 @@ class LogAction < LoggingAction
|
|
3272
3879
|
|
3273
3880
|
end
|
3274
3881
|
|
3882
|
+
def to_s(colour: false)
|
3883
|
+
'LogAction ' + @h.inspect
|
3884
|
+
end
|
3885
|
+
|
3886
|
+
alias to_summary to_s
|
3275
3887
|
end
|
3276
3888
|
|
3277
3889
|
# Category: Logging
|
@@ -3288,6 +3900,40 @@ class ClearLogAction < LoggingAction
|
|
3288
3900
|
|
3289
3901
|
end
|
3290
3902
|
|
3903
|
+
def to_s(colour: false)
|
3904
|
+
'ClearLogAction ' + @h.inspect
|
3905
|
+
end
|
3906
|
+
|
3907
|
+
alias to_summary to_s
|
3908
|
+
end
|
3909
|
+
|
3910
|
+
class PauseAction < Action
|
3911
|
+
|
3912
|
+
def initialize(h={})
|
3913
|
+
|
3914
|
+
options = {
|
3915
|
+
delay_in_milli_seconds: 0, delay_in_seconds: 1, use_alarm: false
|
3916
|
+
}
|
3917
|
+
super(h)
|
3918
|
+
|
3919
|
+
end
|
3920
|
+
|
3921
|
+
def to_s(colour: false)
|
3922
|
+
|
3923
|
+
su = Subunit.new(units={minutes:60, hours:60},
|
3924
|
+
seconds: @h[:delay_in_seconds])
|
3925
|
+
|
3926
|
+
ms = @h[:delay_in_milli_seconds]
|
3927
|
+
|
3928
|
+
duration = if su.to_h.has_key?(:minutes) or (ms < 1) then
|
3929
|
+
su.strfunit("%X")
|
3930
|
+
else
|
3931
|
+
"%s %s ms" % [su.strfunit("%X"), ms]
|
3932
|
+
end
|
3933
|
+
|
3934
|
+
"Wait " + duration
|
3935
|
+
end
|
3936
|
+
|
3291
3937
|
end
|
3292
3938
|
|
3293
3939
|
class MediaAction < Action
|
@@ -3316,6 +3962,11 @@ class RecordMicrophoneAction < MediaAction
|
|
3316
3962
|
|
3317
3963
|
end
|
3318
3964
|
|
3965
|
+
def to_s(colour: false)
|
3966
|
+
'RecordMicrophoneAction ' + @h.inspect
|
3967
|
+
end
|
3968
|
+
|
3969
|
+
alias to_summary to_s
|
3319
3970
|
end
|
3320
3971
|
|
3321
3972
|
# Category: Media
|
@@ -3333,7 +3984,7 @@ class PlaySoundAction < MediaAction
|
|
3333
3984
|
|
3334
3985
|
end
|
3335
3986
|
|
3336
|
-
def to_s()
|
3987
|
+
def to_s(colour: false)
|
3337
3988
|
'Play: ' + @h[:file_path]
|
3338
3989
|
end
|
3339
3990
|
|
@@ -3369,6 +4020,11 @@ class SendEmailAction < MessagingAction
|
|
3369
4020
|
|
3370
4021
|
end
|
3371
4022
|
|
4023
|
+
def to_s(colour: false)
|
4024
|
+
'SendEmailAction ' + @h.inspect
|
4025
|
+
end
|
4026
|
+
|
4027
|
+
alias to_summary to_s
|
3372
4028
|
end
|
3373
4029
|
|
3374
4030
|
# Category: Messaging
|
@@ -3390,6 +4046,11 @@ class SendSMSAction < MessagingAction
|
|
3390
4046
|
|
3391
4047
|
end
|
3392
4048
|
|
4049
|
+
def to_s(colour: false)
|
4050
|
+
'SendSMSAction ' + @h.inspect
|
4051
|
+
end
|
4052
|
+
|
4053
|
+
alias to_summary to_s
|
3393
4054
|
end
|
3394
4055
|
|
3395
4056
|
# Category: Messaging
|
@@ -3408,6 +4069,11 @@ class UDPCommandAction < MessagingAction
|
|
3408
4069
|
|
3409
4070
|
end
|
3410
4071
|
|
4072
|
+
def to_s(colour: false)
|
4073
|
+
'UDPCommandAction ' + @h.inspect
|
4074
|
+
end
|
4075
|
+
|
4076
|
+
alias to_summary to_s
|
3411
4077
|
end
|
3412
4078
|
|
3413
4079
|
|
@@ -3442,6 +4108,11 @@ class ClearNotificationsAction < NotificationsAction
|
|
3442
4108
|
|
3443
4109
|
end
|
3444
4110
|
|
4111
|
+
def to_s(colour: false)
|
4112
|
+
'ClearNotificationsAction ' + @h.inspect
|
4113
|
+
end
|
4114
|
+
|
4115
|
+
alias to_summary to_s
|
3445
4116
|
end
|
3446
4117
|
|
3447
4118
|
# Category: Notifications
|
@@ -3468,6 +4139,10 @@ class MessageDialogAction < NotificationsAction
|
|
3468
4139
|
super(options.merge h)
|
3469
4140
|
|
3470
4141
|
end
|
4142
|
+
|
4143
|
+
def to_s(colour: false)
|
4144
|
+
'Display Dialog' + "\n Battery at: [battery]"
|
4145
|
+
end
|
3471
4146
|
|
3472
4147
|
end
|
3473
4148
|
|
@@ -3485,6 +4160,11 @@ class AllowLEDNotificationLightAction < NotificationsAction
|
|
3485
4160
|
|
3486
4161
|
end
|
3487
4162
|
|
4163
|
+
def to_s(colour: false)
|
4164
|
+
'AllowLEDNotificationLightAction ' + @h.inspect
|
4165
|
+
end
|
4166
|
+
|
4167
|
+
alias to_summary to_s
|
3488
4168
|
end
|
3489
4169
|
|
3490
4170
|
# Category: Notifications
|
@@ -3501,6 +4181,11 @@ class SetNotificationSoundAction < NotificationsAction
|
|
3501
4181
|
|
3502
4182
|
end
|
3503
4183
|
|
4184
|
+
def to_s(colour: false)
|
4185
|
+
'SetNotificationSoundAction ' + @h.inspect
|
4186
|
+
end
|
4187
|
+
|
4188
|
+
alias to_summary to_s
|
3504
4189
|
end
|
3505
4190
|
|
3506
4191
|
# Category: Notifications
|
@@ -3517,6 +4202,11 @@ class SetNotificationSoundAction < NotificationsAction
|
|
3517
4202
|
|
3518
4203
|
end
|
3519
4204
|
|
4205
|
+
def to_s(colour: false)
|
4206
|
+
'SetNotificationSoundAction ' + @h.inspect
|
4207
|
+
end
|
4208
|
+
|
4209
|
+
alias to_summary to_s
|
3520
4210
|
end
|
3521
4211
|
|
3522
4212
|
# Category: Notifications
|
@@ -3533,6 +4223,11 @@ class SetNotificationSoundAction < NotificationsAction
|
|
3533
4223
|
|
3534
4224
|
end
|
3535
4225
|
|
4226
|
+
def to_s(colour: false)
|
4227
|
+
'SetNotificationSoundAction ' + @h.inspect
|
4228
|
+
end
|
4229
|
+
|
4230
|
+
alias to_summary to_s
|
3536
4231
|
end
|
3537
4232
|
|
3538
4233
|
# Category: Notifications
|
@@ -3562,8 +4257,9 @@ class NotificationAction < NotificationsAction
|
|
3562
4257
|
|
3563
4258
|
end
|
3564
4259
|
|
3565
|
-
def to_s()
|
3566
|
-
|
4260
|
+
def to_s(colour: false)
|
4261
|
+
"Display Notification\n " + \
|
4262
|
+
"%s: %s" % [@h[:notification_subject], @h[:notification_text]]
|
3567
4263
|
end
|
3568
4264
|
|
3569
4265
|
end
|
@@ -3602,8 +4298,8 @@ class ToastAction < NotificationsAction
|
|
3602
4298
|
"popup_message '%s'" % @h[:message_text]
|
3603
4299
|
end
|
3604
4300
|
|
3605
|
-
def to_s()
|
3606
|
-
"Popup Message
|
4301
|
+
def to_s(colour: false)
|
4302
|
+
"Popup Message\n %s" % @h[:message_text]
|
3607
4303
|
end
|
3608
4304
|
|
3609
4305
|
end
|
@@ -3631,7 +4327,11 @@ class AnswerCallAction < PhoneAction
|
|
3631
4327
|
super(options.merge h)
|
3632
4328
|
|
3633
4329
|
end
|
3634
|
-
|
4330
|
+
|
4331
|
+
def to_s(colour: false)
|
4332
|
+
@s = 'Answer Call' + "\n "
|
4333
|
+
super()
|
4334
|
+
end
|
3635
4335
|
end
|
3636
4336
|
|
3637
4337
|
# Category: Phone
|
@@ -3650,6 +4350,11 @@ class ClearCallLogAction < PhoneAction
|
|
3650
4350
|
|
3651
4351
|
end
|
3652
4352
|
|
4353
|
+
def to_s(colour: false)
|
4354
|
+
'ClearCallLogAction ' + @h.inspect
|
4355
|
+
end
|
4356
|
+
|
4357
|
+
alias to_summary to_s
|
3653
4358
|
end
|
3654
4359
|
|
3655
4360
|
# Category: Phone
|
@@ -3665,6 +4370,11 @@ class OpenCallLogAction < PhoneAction
|
|
3665
4370
|
|
3666
4371
|
end
|
3667
4372
|
|
4373
|
+
def to_s(colour: false)
|
4374
|
+
'OpenCallLogAction ' + @h.inspect
|
4375
|
+
end
|
4376
|
+
|
4377
|
+
alias to_summary to_s
|
3668
4378
|
end
|
3669
4379
|
|
3670
4380
|
# Category: Phone
|
@@ -3679,6 +4389,11 @@ class RejectCallAction < PhoneAction
|
|
3679
4389
|
super(options.merge h)
|
3680
4390
|
|
3681
4391
|
end
|
4392
|
+
|
4393
|
+
def to_s(colour: false)
|
4394
|
+
@s = 'Call Reject' + "\n "
|
4395
|
+
super()
|
4396
|
+
end
|
3682
4397
|
|
3683
4398
|
end
|
3684
4399
|
|
@@ -3697,6 +4412,11 @@ class MakeCallAction < PhoneAction
|
|
3697
4412
|
|
3698
4413
|
end
|
3699
4414
|
|
4415
|
+
def to_s(colour: false)
|
4416
|
+
'MakeCallAction ' + @h.inspect
|
4417
|
+
end
|
4418
|
+
|
4419
|
+
alias to_summary to_s
|
3700
4420
|
end
|
3701
4421
|
|
3702
4422
|
|
@@ -3714,6 +4434,11 @@ class SetRingtoneAction < PhoneAction
|
|
3714
4434
|
|
3715
4435
|
end
|
3716
4436
|
|
4437
|
+
def to_s(colour: false)
|
4438
|
+
'SetRingtoneAction ' + @h.inspect
|
4439
|
+
end
|
4440
|
+
|
4441
|
+
alias to_summary to_s
|
3717
4442
|
end
|
3718
4443
|
|
3719
4444
|
class ScreenAction < Action
|
@@ -3741,6 +4466,11 @@ class SetBrightnessAction < ScreenAction
|
|
3741
4466
|
|
3742
4467
|
end
|
3743
4468
|
|
4469
|
+
def to_s(colour: false)
|
4470
|
+
'SetBrightnessAction ' + @h.inspect
|
4471
|
+
end
|
4472
|
+
|
4473
|
+
alias to_summary to_s
|
3744
4474
|
end
|
3745
4475
|
|
3746
4476
|
# Category: Screen
|
@@ -3757,6 +4487,11 @@ class ForceScreenRotationAction < ScreenAction
|
|
3757
4487
|
|
3758
4488
|
end
|
3759
4489
|
|
4490
|
+
def to_s(colour: false)
|
4491
|
+
'ForceScreenRotationAction ' + @h.inspect
|
4492
|
+
end
|
4493
|
+
|
4494
|
+
alias to_summary to_s
|
3760
4495
|
end
|
3761
4496
|
|
3762
4497
|
# Category: Screen
|
@@ -3776,6 +4511,17 @@ class ScreenOnAction < ScreenAction
|
|
3776
4511
|
|
3777
4512
|
end
|
3778
4513
|
|
4514
|
+
def to_s(colour: false)
|
4515
|
+
|
4516
|
+
state = @h[:screen_off] ? 'Off' : 'On'
|
4517
|
+
state += ' ' + 'No Lock (root only)' if @h[:screen_off_no_lock]
|
4518
|
+
#state += ' ' + '(Alternative)' if @h[:screen_on_alternative]
|
4519
|
+
|
4520
|
+
'Screen ' + state
|
4521
|
+
|
4522
|
+
end
|
4523
|
+
|
4524
|
+
alias to_summary to_s
|
3779
4525
|
end
|
3780
4526
|
|
3781
4527
|
# Category: Screen
|
@@ -3793,6 +4539,11 @@ class DimScreenAction < ScreenAction
|
|
3793
4539
|
|
3794
4540
|
end
|
3795
4541
|
|
4542
|
+
def to_s(colour: false)
|
4543
|
+
'DimScreenAction ' + @h.inspect
|
4544
|
+
end
|
4545
|
+
|
4546
|
+
alias to_summary to_s
|
3796
4547
|
end
|
3797
4548
|
|
3798
4549
|
# Category: Screen
|
@@ -3816,7 +4567,7 @@ class KeepAwakeAction < ScreenAction
|
|
3816
4567
|
|
3817
4568
|
end
|
3818
4569
|
|
3819
|
-
def to_s()
|
4570
|
+
def to_s(colour: false)
|
3820
4571
|
|
3821
4572
|
screen = @h[:screen_option] == 0 ? 'Screen On' : 'Screen Off'
|
3822
4573
|
|
@@ -3857,6 +4608,11 @@ class SetScreenTimeoutAction < ScreenAction
|
|
3857
4608
|
|
3858
4609
|
end
|
3859
4610
|
|
4611
|
+
def to_s(colour: false)
|
4612
|
+
'SetScreenTimeoutAction ' + @h.inspect
|
4613
|
+
end
|
4614
|
+
|
4615
|
+
alias to_summary to_s
|
3860
4616
|
end
|
3861
4617
|
|
3862
4618
|
|
@@ -3883,6 +4639,11 @@ class SilentModeVibrateOffAction < VolumeAction
|
|
3883
4639
|
|
3884
4640
|
end
|
3885
4641
|
|
4642
|
+
def to_s(colour: false)
|
4643
|
+
'SilentModeVibrateOffAction ' + @h.inspect
|
4644
|
+
end
|
4645
|
+
|
4646
|
+
alias to_summary to_s
|
3886
4647
|
end
|
3887
4648
|
|
3888
4649
|
# Category: Volume
|
@@ -3900,6 +4661,27 @@ class SetVibrateAction < VolumeAction
|
|
3900
4661
|
|
3901
4662
|
end
|
3902
4663
|
|
4664
|
+
def to_s(colour: false)
|
4665
|
+
|
4666
|
+
a = [
|
4667
|
+
'Silent (Vibrate On)',
|
4668
|
+
'Normal (Vibrate Off)',
|
4669
|
+
'Vibrate when ringing On',
|
4670
|
+
'Vibrate when ringing Off',
|
4671
|
+
'Vibrate when ringing Toggle'
|
4672
|
+
]
|
4673
|
+
|
4674
|
+
status = a[@h[:option_int]]
|
4675
|
+
@s = 'Vibrate Enable/Disable ' + "\n " + status + "\n "
|
4676
|
+
super()
|
4677
|
+
|
4678
|
+
end
|
4679
|
+
|
4680
|
+
def to_summary(colour: false)
|
4681
|
+
|
4682
|
+
@s = 'Vibrate Enable/Disable'
|
4683
|
+
|
4684
|
+
end
|
3903
4685
|
end
|
3904
4686
|
|
3905
4687
|
# Category: Volume
|
@@ -3916,6 +4698,11 @@ class VolumeIncrementDecrementAction < VolumeAction
|
|
3916
4698
|
|
3917
4699
|
end
|
3918
4700
|
|
4701
|
+
def to_s(colour: false)
|
4702
|
+
'VolumeIncrementDecrementAction ' + @h.inspect
|
4703
|
+
end
|
4704
|
+
|
4705
|
+
alias to_summary to_s
|
3919
4706
|
end
|
3920
4707
|
|
3921
4708
|
# Category: Volume
|
@@ -3933,6 +4720,11 @@ class SpeakerPhoneAction < VolumeAction
|
|
3933
4720
|
|
3934
4721
|
end
|
3935
4722
|
|
4723
|
+
def to_s(colour: false)
|
4724
|
+
'SpeakerPhoneAction ' + @h.inspect
|
4725
|
+
end
|
4726
|
+
|
4727
|
+
alias to_summary to_s
|
3936
4728
|
end
|
3937
4729
|
|
3938
4730
|
# Category: Volume
|
@@ -3952,7 +4744,11 @@ class SetVolumeAction < VolumeAction
|
|
3952
4744
|
super(options.merge h)
|
3953
4745
|
|
3954
4746
|
end
|
3955
|
-
|
4747
|
+
|
4748
|
+
def to_s(colour: false)
|
4749
|
+
volume = @h[:stream_index_array].zip(@h[:stream_volume_array]).to_h[true]
|
4750
|
+
'Volume Change ' + "Notification = %s%%" % volume
|
4751
|
+
end
|
3956
4752
|
end
|
3957
4753
|
|
3958
4754
|
class Constraint < MacroObject
|
@@ -3965,7 +4761,7 @@ class Constraint < MacroObject
|
|
3965
4761
|
|
3966
4762
|
detail.select {|k,v| @h.include? k }.all? {|key,value| @h[key] == value}
|
3967
4763
|
|
3968
|
-
end
|
4764
|
+
end
|
3969
4765
|
|
3970
4766
|
#def to_s()
|
3971
4767
|
# ''
|
@@ -3987,22 +4783,7 @@ class Constraint < MacroObject
|
|
3987
4783
|
|
3988
4784
|
end
|
3989
4785
|
|
3990
|
-
class TimeOfDayConstraint < Constraint
|
3991
|
-
|
3992
|
-
def initialize(h={})
|
3993
4786
|
|
3994
|
-
options = {
|
3995
|
-
end_hour: 8,
|
3996
|
-
end_minute: 0,
|
3997
|
-
start_hour: 22,
|
3998
|
-
start_minute: 0
|
3999
|
-
}
|
4000
|
-
|
4001
|
-
super(options.merge h)
|
4002
|
-
|
4003
|
-
end
|
4004
|
-
|
4005
|
-
end
|
4006
4787
|
|
4007
4788
|
# Category: Battery/Power
|
4008
4789
|
#
|
@@ -4020,7 +4801,7 @@ class BatteryLevelConstraint < Constraint
|
|
4020
4801
|
|
4021
4802
|
end
|
4022
4803
|
|
4023
|
-
def to_s()
|
4804
|
+
def to_s(colour: false)
|
4024
4805
|
|
4025
4806
|
operator = if @h[:greater_than] then
|
4026
4807
|
'>'
|
@@ -4034,6 +4815,8 @@ class BatteryLevelConstraint < Constraint
|
|
4034
4815
|
|
4035
4816
|
"Battery %s %s%%" % [operator, level]
|
4036
4817
|
end
|
4818
|
+
|
4819
|
+
alias to_summary to_s
|
4037
4820
|
|
4038
4821
|
end
|
4039
4822
|
|
@@ -4051,6 +4834,11 @@ class BatterySaverStateConstraint < Constraint
|
|
4051
4834
|
|
4052
4835
|
end
|
4053
4836
|
|
4837
|
+
def to_s(colour: false)
|
4838
|
+
'BatterySaverStateConstraint ' + @h.inspect
|
4839
|
+
end
|
4840
|
+
|
4841
|
+
alias to_summary to_s
|
4054
4842
|
end
|
4055
4843
|
|
4056
4844
|
# Category: Battery/Power
|
@@ -4069,6 +4857,11 @@ class BatteryTemperatureConstraint < Constraint
|
|
4069
4857
|
|
4070
4858
|
end
|
4071
4859
|
|
4860
|
+
def to_s(colour: false)
|
4861
|
+
'BatteryTemperatureConstraint ' + @h.inspect
|
4862
|
+
end
|
4863
|
+
|
4864
|
+
alias to_summary to_s
|
4072
4865
|
end
|
4073
4866
|
|
4074
4867
|
# Category: Battery/Power
|
@@ -4086,7 +4879,7 @@ class ExternalPowerConstraint < Constraint
|
|
4086
4879
|
|
4087
4880
|
end
|
4088
4881
|
|
4089
|
-
def to_s()
|
4882
|
+
def to_s(colour: false)
|
4090
4883
|
connection = @h[:external_power] ? 'Connected' : 'Disconnected'
|
4091
4884
|
'Power ' + connection
|
4092
4885
|
end
|
@@ -4109,11 +4902,12 @@ class BluetoothConstraint < Constraint
|
|
4109
4902
|
|
4110
4903
|
end
|
4111
4904
|
|
4112
|
-
def to_s()
|
4905
|
+
def to_s(colour: false)
|
4113
4906
|
device = @h[:device_name] #== 'Any Device' ? 'Any' : @h[:device_name]
|
4114
4907
|
"Device Connected (%s)" % device
|
4115
4908
|
end
|
4116
4909
|
|
4910
|
+
alias to_summary to_s
|
4117
4911
|
|
4118
4912
|
end
|
4119
4913
|
|
@@ -4131,6 +4925,11 @@ class GPSEnabledConstraint < Constraint
|
|
4131
4925
|
|
4132
4926
|
end
|
4133
4927
|
|
4928
|
+
def to_s(colour: false)
|
4929
|
+
'GPSEnabledConstraint ' + @h.inspect
|
4930
|
+
end
|
4931
|
+
|
4932
|
+
alias to_summary to_s
|
4134
4933
|
end
|
4135
4934
|
|
4136
4935
|
# Category: Connectivity
|
@@ -4147,6 +4946,11 @@ class LocationModeConstraint < Constraint
|
|
4147
4946
|
|
4148
4947
|
end
|
4149
4948
|
|
4949
|
+
def to_s(colour: false)
|
4950
|
+
'LocationModeConstraint ' + @h.inspect
|
4951
|
+
end
|
4952
|
+
|
4953
|
+
alias to_summary to_s
|
4150
4954
|
end
|
4151
4955
|
|
4152
4956
|
# Category: Connectivity
|
@@ -4163,6 +4967,11 @@ class SignalOnOffConstraint < Constraint
|
|
4163
4967
|
|
4164
4968
|
end
|
4165
4969
|
|
4970
|
+
def to_s(colour: false)
|
4971
|
+
'SignalOnOffConstraint ' + @h.inspect
|
4972
|
+
end
|
4973
|
+
|
4974
|
+
alias to_summary to_s
|
4166
4975
|
end
|
4167
4976
|
|
4168
4977
|
# Category: Connectivity
|
@@ -4180,6 +4989,11 @@ class WifiConstraint < Constraint
|
|
4180
4989
|
|
4181
4990
|
end
|
4182
4991
|
|
4992
|
+
def to_s(colour: false)
|
4993
|
+
'WifiConstraint ' + @h.inspect
|
4994
|
+
end
|
4995
|
+
|
4996
|
+
alias to_summary to_s
|
4183
4997
|
end
|
4184
4998
|
|
4185
4999
|
# Category: Connectivity
|
@@ -4198,6 +5012,11 @@ class CellTowerConstraint < Constraint
|
|
4198
5012
|
|
4199
5013
|
end
|
4200
5014
|
|
5015
|
+
def to_s(colour: false)
|
5016
|
+
'CellTowerConstraint ' + @h.inspect
|
5017
|
+
end
|
5018
|
+
|
5019
|
+
alias to_summary to_s
|
4201
5020
|
end
|
4202
5021
|
|
4203
5022
|
# Category: Connectivity
|
@@ -4214,6 +5033,11 @@ class IsRoamingConstraint < Constraint
|
|
4214
5033
|
|
4215
5034
|
end
|
4216
5035
|
|
5036
|
+
def to_s(colour: false)
|
5037
|
+
'IsRoamingConstraint ' + @h.inspect
|
5038
|
+
end
|
5039
|
+
|
5040
|
+
alias to_summary to_s
|
4217
5041
|
end
|
4218
5042
|
|
4219
5043
|
# Category: Connectivity
|
@@ -4230,6 +5054,11 @@ class DataOnOffConstraint < Constraint
|
|
4230
5054
|
|
4231
5055
|
end
|
4232
5056
|
|
5057
|
+
def to_s(colour: false)
|
5058
|
+
'DataOnOffConstraint ' + @h.inspect
|
5059
|
+
end
|
5060
|
+
|
5061
|
+
alias to_summary to_s
|
4233
5062
|
end
|
4234
5063
|
|
4235
5064
|
# Category: Connectivity
|
@@ -4249,6 +5078,11 @@ class WifiHotSpotConstraint < Constraint
|
|
4249
5078
|
|
4250
5079
|
end
|
4251
5080
|
|
5081
|
+
def to_s(colour: false)
|
5082
|
+
'WifiHotSpotConstraint ' + @h.inspect
|
5083
|
+
end
|
5084
|
+
|
5085
|
+
alias to_summary to_s
|
4252
5086
|
end
|
4253
5087
|
|
4254
5088
|
# Category: Date/Time
|
@@ -4272,6 +5106,11 @@ class CalendarConstraint < Constraint
|
|
4272
5106
|
|
4273
5107
|
end
|
4274
5108
|
|
5109
|
+
def to_s(colour: false)
|
5110
|
+
'CalendarConstraint ' + @h.inspect
|
5111
|
+
end
|
5112
|
+
|
5113
|
+
alias to_summary to_s
|
4275
5114
|
end
|
4276
5115
|
|
4277
5116
|
# Category: Date/Time
|
@@ -4288,6 +5127,11 @@ class DayOfWeekConstraint < Constraint
|
|
4288
5127
|
|
4289
5128
|
end
|
4290
5129
|
|
5130
|
+
def to_s(colour: false)
|
5131
|
+
'DayOfWeekConstraint ' + @h.inspect
|
5132
|
+
end
|
5133
|
+
|
5134
|
+
alias to_summary to_s
|
4291
5135
|
end
|
4292
5136
|
|
4293
5137
|
# Category: Date/Time
|
@@ -4297,16 +5141,22 @@ class TimeOfDayConstraint < Constraint
|
|
4297
5141
|
def initialize(h={})
|
4298
5142
|
|
4299
5143
|
options = {
|
4300
|
-
end_hour:
|
4301
|
-
end_minute:
|
4302
|
-
start_hour:
|
4303
|
-
start_minute:
|
5144
|
+
end_hour: 8,
|
5145
|
+
end_minute: 0,
|
5146
|
+
start_hour: 22,
|
5147
|
+
start_minute: 0
|
4304
5148
|
}
|
4305
5149
|
|
4306
5150
|
super(options.merge h)
|
4307
5151
|
|
4308
5152
|
end
|
4309
|
-
|
5153
|
+
|
5154
|
+
def to_s(colour: false)
|
5155
|
+
a = @h[:start_hour], @h[:start_minute], @h[:end_hour], @h[:start_minute]
|
5156
|
+
'Time of Day ' + "%02d:%02d - %02d:%02d" % a
|
5157
|
+
end
|
5158
|
+
|
5159
|
+
alias to_summary to_s
|
4310
5160
|
end
|
4311
5161
|
|
4312
5162
|
# Category: Date/Time
|
@@ -4324,6 +5174,11 @@ class DayOfMonthConstraint < Constraint
|
|
4324
5174
|
|
4325
5175
|
end
|
4326
5176
|
|
5177
|
+
def to_s(colour: false)
|
5178
|
+
'DayOfMonthConstraint ' + @h.inspect
|
5179
|
+
end
|
5180
|
+
|
5181
|
+
alias to_summary to_s
|
4327
5182
|
end
|
4328
5183
|
|
4329
5184
|
# Category: Date/Time
|
@@ -4340,6 +5195,11 @@ class MonthOfYearConstraint < Constraint
|
|
4340
5195
|
|
4341
5196
|
end
|
4342
5197
|
|
5198
|
+
def to_s(colour: false)
|
5199
|
+
'MonthOfYearConstraint ' + @h.inspect
|
5200
|
+
end
|
5201
|
+
|
5202
|
+
alias to_summary to_s
|
4343
5203
|
end
|
4344
5204
|
|
4345
5205
|
# Category: Date/Time
|
@@ -4356,6 +5216,11 @@ class SunsetSunriseConstraint < Constraint
|
|
4356
5216
|
|
4357
5217
|
end
|
4358
5218
|
|
5219
|
+
def to_s(colour: false)
|
5220
|
+
'SunsetSunriseConstraint ' + @h.inspect
|
5221
|
+
end
|
5222
|
+
|
5223
|
+
alias to_summary to_s
|
4359
5224
|
end
|
4360
5225
|
|
4361
5226
|
# Category: Device State
|
@@ -4400,12 +5265,14 @@ class AirplaneModeConstraint < Constraint
|
|
4400
5265
|
'airplane_mode.' + status
|
4401
5266
|
end
|
4402
5267
|
|
4403
|
-
def to_s()
|
5268
|
+
def to_s(colour: false)
|
4404
5269
|
|
4405
5270
|
status = @h[:enabled] ? 'Enabled' : 'Disabled'
|
4406
5271
|
'Airplane Mode ' + status
|
4407
5272
|
|
4408
5273
|
end
|
5274
|
+
|
5275
|
+
alias to_summary to_s
|
4409
5276
|
|
4410
5277
|
end
|
4411
5278
|
|
@@ -4423,6 +5290,11 @@ class AutoRotateConstraint < Constraint
|
|
4423
5290
|
|
4424
5291
|
end
|
4425
5292
|
|
5293
|
+
def to_s(colour: false)
|
5294
|
+
'AutoRotateConstraint ' + @h.inspect
|
5295
|
+
end
|
5296
|
+
|
5297
|
+
alias to_summary to_s
|
4426
5298
|
end
|
4427
5299
|
|
4428
5300
|
# Category: Device State
|
@@ -4439,9 +5311,11 @@ class DeviceLockedConstraint < Constraint
|
|
4439
5311
|
|
4440
5312
|
end
|
4441
5313
|
|
4442
|
-
def to_s()
|
5314
|
+
def to_s(colour: false)
|
4443
5315
|
'Device ' + (@h[:locked] ? 'Locked' : 'Unlocked')
|
4444
5316
|
end
|
5317
|
+
|
5318
|
+
alias to_summary to_s
|
4445
5319
|
|
4446
5320
|
end
|
4447
5321
|
|
@@ -4459,6 +5333,11 @@ class RoamingOnOffConstraint < Constraint
|
|
4459
5333
|
|
4460
5334
|
end
|
4461
5335
|
|
5336
|
+
def to_s(colour: false)
|
5337
|
+
'RoamingOnOffConstraint ' + @h.inspect
|
5338
|
+
end
|
5339
|
+
|
5340
|
+
alias to_summary to_s
|
4462
5341
|
end
|
4463
5342
|
|
4464
5343
|
# Category: Device State
|
@@ -4476,6 +5355,11 @@ class TimeSinceBootConstraint < Constraint
|
|
4476
5355
|
|
4477
5356
|
end
|
4478
5357
|
|
5358
|
+
def to_s(colour: false)
|
5359
|
+
'TimeSinceBootConstraint ' + @h.inspect
|
5360
|
+
end
|
5361
|
+
|
5362
|
+
alias to_summary to_s
|
4479
5363
|
end
|
4480
5364
|
|
4481
5365
|
# Category: Device State
|
@@ -4492,6 +5376,11 @@ class AutoSyncConstraint < Constraint
|
|
4492
5376
|
|
4493
5377
|
end
|
4494
5378
|
|
5379
|
+
def to_s(colour: false)
|
5380
|
+
'AutoSyncConstraint ' + @h.inspect
|
5381
|
+
end
|
5382
|
+
|
5383
|
+
alias to_summary to_s
|
4495
5384
|
end
|
4496
5385
|
|
4497
5386
|
# Category: Device State
|
@@ -4508,6 +5397,11 @@ class NFCStateConstraint < Constraint
|
|
4508
5397
|
|
4509
5398
|
end
|
4510
5399
|
|
5400
|
+
def to_s(colour: false)
|
5401
|
+
'NFCStateConstraint ' + @h.inspect
|
5402
|
+
end
|
5403
|
+
|
5404
|
+
alias to_summary to_s
|
4511
5405
|
end
|
4512
5406
|
|
4513
5407
|
# Category: Device State
|
@@ -4524,6 +5418,11 @@ class IsRootedConstraint < Constraint
|
|
4524
5418
|
|
4525
5419
|
end
|
4526
5420
|
|
5421
|
+
def to_s(colour: false)
|
5422
|
+
'IsRootedConstraint ' + @h.inspect
|
5423
|
+
end
|
5424
|
+
|
5425
|
+
alias to_summary to_s
|
4527
5426
|
end
|
4528
5427
|
|
4529
5428
|
# Category: Device State
|
@@ -4540,6 +5439,11 @@ class VpnConstraint < Constraint
|
|
4540
5439
|
|
4541
5440
|
end
|
4542
5441
|
|
5442
|
+
def to_s(colour: false)
|
5443
|
+
'VpnConstraint ' + @h.inspect
|
5444
|
+
end
|
5445
|
+
|
5446
|
+
alias to_summary to_s
|
4543
5447
|
end
|
4544
5448
|
|
4545
5449
|
# Category: MacroDroid Specific
|
@@ -4558,6 +5462,11 @@ class MacroEnabledConstraint < Constraint
|
|
4558
5462
|
|
4559
5463
|
end
|
4560
5464
|
|
5465
|
+
def to_s(colour: false)
|
5466
|
+
'MacroEnabledConstraint ' + @h.inspect
|
5467
|
+
end
|
5468
|
+
|
5469
|
+
alias to_summary to_s
|
4561
5470
|
end
|
4562
5471
|
|
4563
5472
|
# Category: MacroDroid Specific
|
@@ -4575,23 +5484,46 @@ class ModeConstraint < Constraint
|
|
4575
5484
|
|
4576
5485
|
end
|
4577
5486
|
|
5487
|
+
def to_s(colour: false)
|
5488
|
+
'ModeConstraint ' + @h.inspect
|
5489
|
+
end
|
5490
|
+
|
5491
|
+
alias to_summary to_s
|
4578
5492
|
end
|
4579
5493
|
|
4580
5494
|
# Category: MacroDroid Specific
|
4581
5495
|
#
|
4582
5496
|
class TriggerThatInvokedConstraint < Constraint
|
4583
|
-
|
5497
|
+
using ColouredText
|
5498
|
+
|
4584
5499
|
def initialize(h={})
|
4585
5500
|
|
5501
|
+
puts ('h: ' + h.inspect).green
|
5502
|
+
@trigger = h[:macro].triggers.find {|x| x.siguid == h[:si_guid_that_invoked] }
|
5503
|
+
|
4586
5504
|
options = {
|
4587
5505
|
not: false,
|
4588
5506
|
si_guid_that_invoked: -4951291100076165433,
|
4589
5507
|
trigger_name: 'Shake Device'
|
4590
5508
|
}
|
4591
5509
|
|
5510
|
+
#super(options.merge filter(options,h))
|
4592
5511
|
super(options.merge h)
|
4593
5512
|
|
4594
5513
|
end
|
5514
|
+
|
5515
|
+
def to_s(colour: false)
|
5516
|
+
'Trigger Fired: ' + @trigger.to_s(colour: colour)
|
5517
|
+
end
|
5518
|
+
|
5519
|
+
def to_summary(colour: false)
|
5520
|
+
#puts '@trigger' + @trigger.inspect
|
5521
|
+
if @trigger then
|
5522
|
+
'Trigger Fired: ' + @trigger.to_summary(colour: colour)
|
5523
|
+
else
|
5524
|
+
'Trigger Fired: Trigger not found; guid: ' + @h[:si_guid_that_invoked].inspect
|
5525
|
+
end
|
5526
|
+
end
|
4595
5527
|
|
4596
5528
|
end
|
4597
5529
|
|
@@ -4613,6 +5545,11 @@ class LastRunTimeConstraint < Constraint
|
|
4613
5545
|
|
4614
5546
|
end
|
4615
5547
|
|
5548
|
+
def to_s(colour: false)
|
5549
|
+
'LastRunTimeConstraint ' + @h.inspect
|
5550
|
+
end
|
5551
|
+
|
5552
|
+
alias to_summary to_s
|
4616
5553
|
end
|
4617
5554
|
|
4618
5555
|
# Category: Media
|
@@ -4629,10 +5566,12 @@ class HeadphonesConnectionConstraint < Constraint
|
|
4629
5566
|
|
4630
5567
|
end
|
4631
5568
|
|
4632
|
-
def to_s()
|
5569
|
+
def to_s(colour: false)
|
4633
5570
|
connection = @h[:connected] ? 'Connected' : 'Disconnected'
|
4634
5571
|
'Headphones ' + connection
|
4635
5572
|
end
|
5573
|
+
|
5574
|
+
alias to_summary to_s
|
4636
5575
|
|
4637
5576
|
end
|
4638
5577
|
|
@@ -4650,6 +5589,11 @@ class MusicActiveConstraint < Constraint
|
|
4650
5589
|
|
4651
5590
|
end
|
4652
5591
|
|
5592
|
+
def to_s(colour: false)
|
5593
|
+
'MusicActiveConstraint ' + @h.inspect
|
5594
|
+
end
|
5595
|
+
|
5596
|
+
alias to_summary to_s
|
4653
5597
|
end
|
4654
5598
|
|
4655
5599
|
# Category: Notification
|
@@ -4673,6 +5617,11 @@ class NotificationPresentConstraint < Constraint
|
|
4673
5617
|
|
4674
5618
|
end
|
4675
5619
|
|
5620
|
+
def to_s(colour: false)
|
5621
|
+
'NotificationPresentConstraint ' + @h.inspect
|
5622
|
+
end
|
5623
|
+
|
5624
|
+
alias to_summary to_s
|
4676
5625
|
end
|
4677
5626
|
|
4678
5627
|
# Category: Notification
|
@@ -4690,6 +5639,11 @@ class PriorityModeConstraint < Constraint
|
|
4690
5639
|
|
4691
5640
|
end
|
4692
5641
|
|
5642
|
+
def to_s(colour: false)
|
5643
|
+
'PriorityModeConstraint ' + @h.inspect
|
5644
|
+
end
|
5645
|
+
|
5646
|
+
alias to_summary to_s
|
4693
5647
|
end
|
4694
5648
|
|
4695
5649
|
# Category: Notification
|
@@ -4706,6 +5660,11 @@ class NotificationVolumeConstraint < Constraint
|
|
4706
5660
|
|
4707
5661
|
end
|
4708
5662
|
|
5663
|
+
def to_s(colour: false)
|
5664
|
+
'NotificationVolumeConstraint ' + @h.inspect
|
5665
|
+
end
|
5666
|
+
|
5667
|
+
alias to_summary to_s
|
4709
5668
|
end
|
4710
5669
|
|
4711
5670
|
# Category: Phone
|
@@ -4722,6 +5681,11 @@ class InCallConstraint < Constraint
|
|
4722
5681
|
|
4723
5682
|
end
|
4724
5683
|
|
5684
|
+
def to_s(colour: false)
|
5685
|
+
'InCallConstraint ' + @h.inspect
|
5686
|
+
end
|
5687
|
+
|
5688
|
+
alias to_summary to_s
|
4725
5689
|
end
|
4726
5690
|
|
4727
5691
|
# Category: Phone
|
@@ -4737,6 +5701,11 @@ class PhoneRingingConstraint < Constraint
|
|
4737
5701
|
super(options.merge h)
|
4738
5702
|
|
4739
5703
|
end
|
5704
|
+
|
5705
|
+
def to_s(colour: false)
|
5706
|
+
@s = @h[:ringing] ? 'Phone Ringing' : 'Not Ringing'
|
5707
|
+
super(colour: colour)
|
5708
|
+
end
|
4740
5709
|
|
4741
5710
|
end
|
4742
5711
|
|
@@ -4758,6 +5727,11 @@ class BrightnessConstraint < Constraint
|
|
4758
5727
|
|
4759
5728
|
end
|
4760
5729
|
|
5730
|
+
def to_s(colour: false)
|
5731
|
+
'BrightnessConstraint ' + @h.inspect
|
5732
|
+
end
|
5733
|
+
|
5734
|
+
alias to_summary to_s
|
4761
5735
|
end
|
4762
5736
|
|
4763
5737
|
# Category: Screen and Speaker
|
@@ -4770,9 +5744,15 @@ class VolumeConstraint < Constraint
|
|
4770
5744
|
option: 0
|
4771
5745
|
}
|
4772
5746
|
|
4773
|
-
super(options.merge h)
|
5747
|
+
super(options.merge filter(options, h))
|
4774
5748
|
|
4775
5749
|
end
|
5750
|
+
|
5751
|
+
def to_s(colour: false)
|
5752
|
+
a = ['Volume On', 'Vibrate Only' 'Silent', 'Vibrate or Silent']
|
5753
|
+
|
5754
|
+
"Ringer Volume\n " + a[@h[:option]]
|
5755
|
+
end
|
4776
5756
|
|
4777
5757
|
end
|
4778
5758
|
|
@@ -4790,6 +5770,11 @@ class SpeakerPhoneConstraint < Constraint
|
|
4790
5770
|
|
4791
5771
|
end
|
4792
5772
|
|
5773
|
+
def to_s(colour: false)
|
5774
|
+
'SpeakerPhoneConstraint ' + @h.inspect
|
5775
|
+
end
|
5776
|
+
|
5777
|
+
alias to_summary to_s
|
4793
5778
|
end
|
4794
5779
|
|
4795
5780
|
# Category: Screen and Speaker
|
@@ -4806,6 +5791,11 @@ class DarkThemeConstraint < Constraint
|
|
4806
5791
|
|
4807
5792
|
end
|
4808
5793
|
|
5794
|
+
def to_s(colour: false)
|
5795
|
+
'DarkThemeConstraint ' + @h.inspect
|
5796
|
+
end
|
5797
|
+
|
5798
|
+
alias to_summary to_s
|
4809
5799
|
end
|
4810
5800
|
|
4811
5801
|
# Category: Screen and Speaker
|
@@ -4823,9 +5813,11 @@ class ScreenOnOffConstraint < Constraint
|
|
4823
5813
|
|
4824
5814
|
end
|
4825
5815
|
|
4826
|
-
def to_s()
|
5816
|
+
def to_s(colour: false)
|
4827
5817
|
'Screen ' + (@h[:screen_on] ? 'On' : 'Off')
|
4828
5818
|
end
|
5819
|
+
|
5820
|
+
alias to_summary to_s
|
4829
5821
|
|
4830
5822
|
end
|
4831
5823
|
|
@@ -4845,6 +5837,11 @@ class VolumeLevelConstraint < Constraint
|
|
4845
5837
|
|
4846
5838
|
end
|
4847
5839
|
|
5840
|
+
def to_s(colour: false)
|
5841
|
+
'VolumeLevelConstraint ' + @h.inspect
|
5842
|
+
end
|
5843
|
+
|
5844
|
+
alias to_summary to_s
|
4848
5845
|
end
|
4849
5846
|
|
4850
5847
|
# Category: Sensors
|
@@ -4862,6 +5859,11 @@ class FaceUpDownConstraint < Constraint
|
|
4862
5859
|
|
4863
5860
|
end
|
4864
5861
|
|
5862
|
+
def to_s(colour: false)
|
5863
|
+
'FaceUpDownConstraint ' + @h.inspect
|
5864
|
+
end
|
5865
|
+
|
5866
|
+
alias to_summary to_s
|
4865
5867
|
end
|
4866
5868
|
|
4867
5869
|
# Category: Sensors
|
@@ -4880,7 +5882,7 @@ class LightLevelConstraint < Constraint
|
|
4880
5882
|
|
4881
5883
|
end
|
4882
5884
|
|
4883
|
-
def to_s()
|
5885
|
+
def to_s(colour: false)
|
4884
5886
|
|
4885
5887
|
operator = @h[:light_level] == -1 ? 'Less than' : 'Greater than'
|
4886
5888
|
condition = operator + ' ' + @h[:light_level_float].to_s + 'lx'
|
@@ -4904,6 +5906,11 @@ class DeviceOrientationConstraint < Constraint
|
|
4904
5906
|
|
4905
5907
|
end
|
4906
5908
|
|
5909
|
+
def to_s(colour: false)
|
5910
|
+
'DeviceOrientationConstraint ' + @h.inspect
|
5911
|
+
end
|
5912
|
+
|
5913
|
+
alias to_summary to_s
|
4907
5914
|
end
|
4908
5915
|
|
4909
5916
|
# Category: Sensors
|
@@ -4920,8 +5927,135 @@ class ProximitySensorConstraint < Constraint
|
|
4920
5927
|
|
4921
5928
|
end
|
4922
5929
|
|
4923
|
-
def to_s()
|
5930
|
+
def to_s(colour: false)
|
4924
5931
|
'Proximity Sensor: ' + (@h[:near] ? 'Near' : 'Far')
|
4925
5932
|
end
|
4926
5933
|
|
4927
5934
|
end
|
5935
|
+
|
5936
|
+
|
5937
|
+
# ----------------------------------------------------------------------------
|
5938
|
+
|
5939
|
+
|
5940
|
+
class DroidSim
|
5941
|
+
|
5942
|
+
class Service
|
5943
|
+
def initialize(callback)
|
5944
|
+
@callback = callback
|
5945
|
+
end
|
5946
|
+
end
|
5947
|
+
|
5948
|
+
class Application < Service
|
5949
|
+
|
5950
|
+
def closed()
|
5951
|
+
end
|
5952
|
+
def launched()
|
5953
|
+
end
|
5954
|
+
end
|
5955
|
+
|
5956
|
+
class Battery < Service
|
5957
|
+
|
5958
|
+
def level()
|
5959
|
+
end
|
5960
|
+
|
5961
|
+
def temperature()
|
5962
|
+
end
|
5963
|
+
|
5964
|
+
end
|
5965
|
+
class Bluetooth < Service
|
5966
|
+
|
5967
|
+
def enable()
|
5968
|
+
@callback.on_bluetooth_enabled()
|
5969
|
+
end
|
5970
|
+
|
5971
|
+
#def enabled
|
5972
|
+
# @callback.on_bluetooth_enabled()
|
5973
|
+
#end
|
5974
|
+
|
5975
|
+
def enabled?
|
5976
|
+
end
|
5977
|
+
|
5978
|
+
def disabled
|
5979
|
+
end
|
5980
|
+
|
5981
|
+
def disabled?
|
5982
|
+
end
|
5983
|
+
end
|
5984
|
+
|
5985
|
+
class Calendar < Service
|
5986
|
+
def event(starts, ends)
|
5987
|
+
end
|
5988
|
+
end
|
5989
|
+
|
5990
|
+
class DayTime < Service
|
5991
|
+
|
5992
|
+
def initialie(s)
|
5993
|
+
end
|
5994
|
+
end
|
5995
|
+
|
5996
|
+
class Headphones < Service
|
5997
|
+
def inserted
|
5998
|
+
end
|
5999
|
+
|
6000
|
+
def removed
|
6001
|
+
end
|
6002
|
+
end
|
6003
|
+
|
6004
|
+
class Webhook < Service
|
6005
|
+
|
6006
|
+
def url()
|
6007
|
+
@url
|
6008
|
+
end
|
6009
|
+
|
6010
|
+
def url=(s)
|
6011
|
+
@url = s
|
6012
|
+
end
|
6013
|
+
end
|
6014
|
+
|
6015
|
+
class Wifi < Service
|
6016
|
+
def enabled
|
6017
|
+
end
|
6018
|
+
|
6019
|
+
def disabled
|
6020
|
+
end
|
6021
|
+
|
6022
|
+
def ssid_in_range()
|
6023
|
+
end
|
6024
|
+
|
6025
|
+
def ssid_out_of_range()
|
6026
|
+
end
|
6027
|
+
end
|
6028
|
+
|
6029
|
+
class Power < Service
|
6030
|
+
def connected()
|
6031
|
+
end
|
6032
|
+
|
6033
|
+
def disconnected()
|
6034
|
+
end
|
6035
|
+
|
6036
|
+
def button_toggle()
|
6037
|
+
end
|
6038
|
+
end
|
6039
|
+
|
6040
|
+
class Popup < Service
|
6041
|
+
def message(s)
|
6042
|
+
puts s
|
6043
|
+
end
|
6044
|
+
end
|
6045
|
+
|
6046
|
+
|
6047
|
+
attr_reader :bluetooth, :popup
|
6048
|
+
|
6049
|
+
def initialize()
|
6050
|
+
|
6051
|
+
@bluetooth = Bluetooth.new self
|
6052
|
+
@popup = Popup.new self
|
6053
|
+
|
6054
|
+
end
|
6055
|
+
|
6056
|
+
def on_bluetooth_enabled()
|
6057
|
+
|
6058
|
+
end
|
6059
|
+
|
6060
|
+
|
6061
|
+
end
|