ruby-macrodroid 0.7.5 → 0.7.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 34125d78f367eeff973953934d50436f964bb073ffef48591ce2f09012fc2a01
4
- data.tar.gz: 5bb75988f4d979cb80f57c912d8448837848b3d4a5b34a3e524f8fdad3ff62de
3
+ metadata.gz: 3e6d2bb5ccf9f1caf0c56ba60c4791801dccc28a2be22bfbfc524db01dd553f5
4
+ data.tar.gz: 4d79491e900a308fcc3473ed6d7b96cdf6169e20c7c0c754c08c806cb52c6d34
5
5
  SHA512:
6
- metadata.gz: 223c51744d7dde5e4a7130d3141696df1dc4a8cda0227e0f11324c3ac71e53226c95e8acd1ae27ed62ec46d8c1c8b81060e9135d923285e59e89572985dd146c
7
- data.tar.gz: 39490d0ceeb2bfce5c413607d1ea5a1ca87e8942bdcbfd51ecf32f2baac1a1c6fec7bf8909eda8716cc6b397ef847d4c15de6eca9892f9d244f1724d4956a1fe
6
+ metadata.gz: c671f4e0473e435f7c5c9f760627464b8bf760367485877d43680225f399c6e7a83d2ac95be8ac4960ce8451d301abe7044e70570f1a7344a3a2bcd7ab529746
7
+ data.tar.gz: 5cbfd7fee603949c495e4af3b315ffb45af15e8810c9ed226305627e47472df6a29c92ce2fed2f824d07d5dbb4b28372fcb420d97b4ea673f8c9a8458dc4ad21
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -112,6 +112,7 @@ require 'rowx'
112
112
  require 'uuid'
113
113
  require 'glw'
114
114
  require 'geozone'
115
+ require 'geocoder'
115
116
  require 'subunit'
116
117
  require 'rxfhelper'
117
118
  require 'chronic_cron'
@@ -199,6 +200,11 @@ class TriggersNlp
199
200
 
200
201
  alias find_trigger run_route
201
202
 
203
+ def to_s(colour: false)
204
+ 'TriggersNlp ' + @h.inspect
205
+ end
206
+
207
+ alias to_summary to_s
202
208
  end
203
209
 
204
210
  class ActionsNlp
@@ -318,6 +324,11 @@ class ActionsNlp
318
324
 
319
325
  alias find_action run_route
320
326
 
327
+ def to_s(colour: false)
328
+ 'ActionsNlp ' + @h.inspect
329
+ end
330
+
331
+ alias to_summary to_s
321
332
  end
322
333
 
323
334
  class ConstraintsNlp
@@ -400,12 +411,13 @@ class Macro
400
411
  using ColouredText
401
412
  using Params
402
413
 
403
- attr_reader :local_variables, :triggers, :actions, :constraints, :guid
414
+ attr_reader :local_variables, :triggers, :actions, :constraints,
415
+ :guid, :deviceid
404
416
  attr_accessor :title, :description
405
417
 
406
- def initialize(name=nil, geofences: geofences, debug: false)
418
+ def initialize(name=nil, geofences: geofences, deviceid: nil, debug: false)
407
419
 
408
- @title, @geofences, @debug = name, geofences, debug
420
+ @title, @geofences, @deviceid, @debug = name, geofences, deviceid, debug
409
421
 
410
422
  puts 'inside Macro#initialize' if @debug
411
423
 
@@ -472,7 +484,8 @@ class Macro
472
484
 
473
485
  # fetch the triggers
474
486
  @triggers = h[:trigger_list].map do |trigger|
475
-
487
+ puts 'trigger: ' + trigger.inspect
488
+ #exit
476
489
  object(trigger.to_snake_case)
477
490
 
478
491
  end
@@ -663,16 +676,24 @@ end
663
676
  EOF
664
677
  end
665
678
 
666
- def to_s()
679
+ def to_s(colour: false)
667
680
 
668
681
  indent = 0
669
682
  actions = @actions.map do |x|
670
683
 
671
- s = x.to_s
684
+ s = x.to_s(colour: colour)
685
+ if s.lines.length > 1 then
686
+ lines = s.lines
687
+ s = lines[0] + lines[1..-1].map {|x| x.prepend (' ' * indent) }.join
688
+ end
672
689
 
673
690
  r = if indent <= 0 then
674
691
 
675
- "a: %s" % s
692
+ if colour then
693
+ "a".bg_blue.gray.bold + ": %s" % s
694
+ else
695
+ "a: %s" % s
696
+ end
676
697
 
677
698
  elsif indent > 0
678
699
 
@@ -688,8 +709,15 @@ EOF
688
709
  end
689
710
 
690
711
  if s =~ /^If/i then
712
+
691
713
  if indent < 1 then
692
- r = "a:\n %s" % s
714
+
715
+ r = if colour then
716
+ "a".bg_blue.gray.bold + ":\n %s" % s
717
+ else
718
+ "a:\n %s" % s
719
+ end
720
+
693
721
  indent += 1
694
722
  else
695
723
  r = (' ' * indent) + "%s" % s
@@ -703,30 +731,59 @@ EOF
703
731
  end.join("\n")
704
732
 
705
733
  a = [
706
- 'm: ' + @title,
707
- @triggers.map {|x| "t: %s" % x}.join("\n"),
734
+ (colour ? "m".bg_cyan.gray.bold : 'm') + ': ' + @title,
735
+ @triggers.map {|x| (colour ? "t".bg_red.gray.bold : 't') \
736
+ + ": %s" % x}.join("\n"),
708
737
  actions
709
738
  ]
710
739
 
711
- a << @constraints.map {|x| "c: %s" % x}.join("\n") if @constraints.any?
740
+ if @constraints.any? then
741
+ a << @constraints.map do |x|
742
+ (colour ? "c".bg_green.gray.bold : 'c') + ": %s" % x
743
+ end.join("\n")
744
+ end
712
745
 
713
746
  if @description and @description.length >= 1 then
714
- a.insert(1, 'd: ' + @description.gsub(/\n/,"\n "))
747
+ a.insert(1, (colour ? "d".bg_gray.gray.bold : 'd') + ': ' \
748
+ + @description.gsub(/\n/,"\n "))
715
749
  end
716
750
 
717
751
  a.join("\n") + "\n"
718
752
 
719
753
  end
720
754
 
721
- def to_summary()
755
+ def to_summary(colour: false)
756
+
757
+ if colour then
758
+
759
+ a = [
760
+ 'm'.bg_cyan.gray.bold + ': ' + @title,
761
+ 't'.bg_red.gray.bold + ': ' + @triggers.map \
762
+ {|x| x.to_summary(colour: false)}.join(", "),
763
+ 'a'.bg_blue.gray.bold + ': ' + @actions.map \
764
+ {|x| x.to_summary(colour: false)}.join(", ")
765
+ ]
766
+
767
+ if @constraints.any? then
768
+ a << 'c'.bg_green.gray.bold + ': ' + @constraints.map \
769
+ {|x| x.to_summary(colour: false)}.join(", ")
770
+ end
771
+
772
+ else
773
+
774
+ a = [
775
+ 'm: ' + @title,
776
+ 't: ' + @triggers.map {|x| x.to_summary(colour: false)}.join(", "),
777
+ 'a: ' + @actions.map {|x| x.to_summary(colour: false)}.join(", ")
778
+ ]
779
+
780
+ if @constraints.any? then
781
+ a << 'c: ' + @constraints.map \
782
+ {|x| x.to_summary(colour: false)}.join(", ")
783
+ end
784
+ end
722
785
 
723
- a = [
724
- 'm: ' + @title,
725
- 't: ' + @triggers.map(&:to_summary).join(", "),
726
- 'a: ' + @actions.map(&:to_summary).join(", "),
727
- ]
728
786
 
729
- a << 'c: ' + @constraints.map(&:to_summary).join(", ") if @constraints.any?
730
787
 
731
788
  a.join("\n") + "\n"
732
789
 
@@ -740,7 +797,7 @@ EOF
740
797
 
741
798
  def object(h={})
742
799
 
743
- puts ('inside object h:' + h.inspect).debug if @debug
800
+ puts ('inside object h:' + h.inspect).debug if @debug
744
801
  klass = Object.const_get h[:class_type]
745
802
  puts klass.inspect.highlight if $debug
746
803
 
@@ -748,7 +805,13 @@ EOF
748
805
  puts 'GeofenceTrigger found'.highlight if $debug
749
806
  GeofenceTrigger.new(h, geofences: @geofences)
750
807
  else
751
- klass.new h
808
+ puts 'before klass'
809
+ h2 = h.merge( macro: self)
810
+ puts 'h2: ' + h2.inspect
811
+ r = klass.new h2
812
+
813
+ r
814
+
752
815
  end
753
816
 
754
817
  end
@@ -764,10 +827,14 @@ class MacroDroid
764
827
  using Params
765
828
 
766
829
  attr_reader :macros, :geofences, :yaml
830
+ attr_accessor :deviceid
831
+
832
+ # note: The deviceid can only be found from an existing Webhook trigger,
833
+ # generated from MacroDroid itself.
767
834
 
768
- def initialize(obj=nil, debug: false)
835
+ def initialize(obj=nil, deviceid: nil, debug: false)
769
836
 
770
- @debug = debug
837
+ @deviceid, @debug = deviceid, debug
771
838
 
772
839
  @geofences = {}
773
840
 
@@ -892,21 +959,22 @@ class MacroDroid
892
959
  @macros.map(&:to_pc).join("\n\n")
893
960
  end
894
961
 
895
- def to_s()
962
+ def to_s(colour: false)
896
963
 
897
964
  lines = []
898
965
 
899
966
  if @geofences.any? then
900
- lines << @geofences.map {|_, value| 'g: ' + value.to_s}.join("\n\n") + "\n"
967
+ lines << @geofences.map {|_, value| (colour ? "g".green.bold : 'g') \
968
+ + ': ' + value.to_s}.join("\n\n") + "\n"
901
969
  end
902
970
 
903
- lines << @macros.map(&:to_s).join("\n")
971
+ lines << @macros.map {|x| x.to_s(colour: colour)}.join("\n")
904
972
  lines.join("\n")
905
973
 
906
974
  end
907
975
 
908
- def to_summary()
909
- @macros.map(&:to_summary).join("\n")
976
+ def to_summary(colour: false)
977
+ @macros.map {|x| x.to_summary(colour: colour)}.join("\n")
910
978
  end
911
979
 
912
980
  private
@@ -918,13 +986,23 @@ class MacroDroid
918
986
  name = e.text.to_s.strip
919
987
  item = e.element('item')
920
988
  coordinates = item.text('coordinates')
921
- latitude, longitude = coordinates.split(/, */,2)
922
- radius = item.text('radius')
989
+ location = item.text('location')
990
+
991
+ if not coordinates and location then
992
+ results = Geocoder.search(location)
993
+ coordinates = results[0].coordinates.join(', ') if results.any?
994
+ end
995
+
996
+ if coordinates then
997
+ latitude, longitude = coordinates.split(/, */,2)
998
+ radius = item.text('radius')
999
+ end
923
1000
 
924
1001
  id = UUID.new.generate
925
1002
 
926
1003
  h = {
927
1004
  name: name,
1005
+ location: location,
928
1006
  longitude: longitude,
929
1007
  latitude: latitude,
930
1008
  radius: radius,
@@ -961,7 +1039,8 @@ class MacroDroid
961
1039
  puts ('macro: ' + macro.inspect).debug if @debug
962
1040
  # puts '@geofences: ' + @geofences.inspect if @debug
963
1041
 
964
- m = Macro.new(geofences: @geofences.map(&:last), debug: @debug )
1042
+ m = Macro.new(geofences: @geofences.map(&:last), deviceid: @deviceid,
1043
+ debug: @debug )
965
1044
  m.import_h(macro)
966
1045
  m
967
1046
 
@@ -982,7 +1061,8 @@ class MacroDroid
982
1061
 
983
1062
  @macros = doc.root.xpath('item').map do |node|
984
1063
  puts ('geofences: ' + geofences.inspect).highlight if @debug
985
- Macro.new(geofences: geofences.map(&:last), debug: @debug).import_xml(node)
1064
+ Macro.new(geofences: geofences.map(&:last), deviceid: @deviceid,
1065
+ debug: @debug).import_xml(node)
986
1066
 
987
1067
  end
988
1068
 
@@ -1005,7 +1085,8 @@ class MacroDroid
1005
1085
 
1006
1086
  @macros = doc.root.xpath('macro').map do |node|
1007
1087
 
1008
- Macro.new(geofences: @geofences.map(&:last), debug: @debug).import_xml(node)
1088
+ Macro.new(geofences: @geofences.map(&:last), deviceid: @deviceid,
1089
+ debug: @debug).import_xml(node)
1009
1090
 
1010
1091
  end
1011
1092
  end
@@ -1038,10 +1119,11 @@ class GeofenceMap
1038
1119
 
1039
1120
  attr_accessor :name, :longitude, :latitude, :radius, :id
1040
1121
 
1041
- def initialize(id: '', longitude: '', latitude: '', name: '', radius: '')
1122
+ def initialize(id: '', longitude: '', latitude: '', name: '', radius: '',
1123
+ location: nil)
1042
1124
 
1043
- @id, @latitude, @longitude, @name, @radius = id, latitude, \
1044
- longitude, name, radius
1125
+ @id, @latitude, @longitude, @name, @radius, @location = id, latitude, \
1126
+ longitude, name, radius, location
1045
1127
 
1046
1128
  end
1047
1129
 
@@ -1057,10 +1139,15 @@ class GeofenceMap
1057
1139
 
1058
1140
  end
1059
1141
 
1060
- def to_s()
1142
+ def to_s(colour: false)
1061
1143
 
1062
- coordinates = "%s, %s" % [@longitude, @latitude]
1063
- "%s\n coordinates: %s\n radius: %s" % [@name, coordinates, @radius]
1144
+ lines = []
1145
+ coordinates = "%s, %s" % [@latitude, @longitude]
1146
+ lines << "%s" % @name
1147
+ lines << " location: %s" % @location if @location
1148
+ lines << " coordinates: %s" % coordinates
1149
+ lines << " radius: %s" % @radius
1150
+ lines.join("\n")
1064
1151
 
1065
1152
  end
1066
1153
 
@@ -1069,15 +1156,16 @@ end
1069
1156
  class MacroObject
1070
1157
  using ColouredText
1071
1158
 
1072
- attr_reader :type
1159
+ attr_reader :type, :siguid
1073
1160
  attr_accessor :options
1074
1161
 
1075
1162
  def initialize(h={})
1076
1163
 
1077
1164
  $env ||= {}
1078
1165
 
1166
+ @attributes = %i(constraint_list is_or_condition is_disabled siguid)
1079
1167
  @h = {constraint_list: [], is_or_condition: false,
1080
- is_disabled: false}.merge(h)
1168
+ is_disabled: false, siguid: nil}.merge(h)
1081
1169
  @list = []
1082
1170
 
1083
1171
  # fetch the class name and convert from camelCase to snake_eyes
@@ -1085,6 +1173,7 @@ class MacroObject
1085
1173
  .gsub(/\B[A-Z][a-z]/){|x| '_' + x.downcase}\
1086
1174
  .gsub(/[a-z][A-Z]/){|x| x[0] + '_' + x[1].downcase}\
1087
1175
  .downcase.to_sym
1176
+ @constraints = []
1088
1177
  end
1089
1178
 
1090
1179
  def to_h()
@@ -1105,8 +1194,21 @@ class MacroObject
1105
1194
 
1106
1195
  end
1107
1196
 
1108
- def to_s()
1109
- "#<%s %s>" % [self.class, @h.inspect]
1197
+ def siguid()
1198
+ @h[:siguid]
1199
+ end
1200
+
1201
+ def to_s(colour: false)
1202
+
1203
+ h = @h.clone
1204
+ h.delete :macro
1205
+ @s ||= "#<%s %s>" % [self.class, h.inspect]
1206
+ operator = @h[:is_or_condition] ? 'OR' : 'AND'
1207
+ constraints = @constraints.map \
1208
+ {|x| x.to_summary(colour: colour)}.join(" %s " % operator)
1209
+
1210
+ @s + constraints
1211
+
1110
1212
  end
1111
1213
 
1112
1214
  alias to_summary to_s
@@ -1115,7 +1217,7 @@ class MacroObject
1115
1217
 
1116
1218
  def filter(options, h)
1117
1219
 
1118
- (h.keys - options.keys).each {|key| h.delete key }
1220
+ (h.keys - (options.keys + @attributes.to_a)).each {|key| h.delete key }
1119
1221
  return h
1120
1222
 
1121
1223
  end
@@ -1162,21 +1264,7 @@ class Trigger < MacroObject
1162
1264
  end
1163
1265
 
1164
1266
 
1165
- # Category: Applications
1166
- #
1167
- class WebHookTrigger < Trigger
1168
-
1169
- def initialize(h={})
1170
-
1171
- options = {
1172
- identifier: ''
1173
- }
1174
-
1175
- super(options.merge h)
1176
-
1177
- end
1178
1267
 
1179
- end
1180
1268
 
1181
1269
  # Category: Applications
1182
1270
  #
@@ -1207,6 +1295,11 @@ class WifiConnectionTrigger < Trigger
1207
1295
 
1208
1296
  end
1209
1297
 
1298
+ def to_s(colour: false)
1299
+ 'WifiConnectionTrigger ' + @h.inspect
1300
+ end
1301
+
1302
+ alias to_summary to_s
1210
1303
  end
1211
1304
 
1212
1305
  # Category: Applications
@@ -1227,6 +1320,11 @@ class ApplicationInstalledRemovedTrigger < Trigger
1227
1320
 
1228
1321
  end
1229
1322
 
1323
+ def to_s(colour: false)
1324
+ 'ApplicationInstalledRemovedTrigger ' + @h.inspect
1325
+ end
1326
+
1327
+ alias to_summary to_s
1230
1328
  end
1231
1329
 
1232
1330
  # Category: Applications
@@ -1245,6 +1343,11 @@ class ApplicationLaunchedTrigger < Trigger
1245
1343
 
1246
1344
  end
1247
1345
 
1346
+ def to_s(colour: false)
1347
+ 'ApplicationLaunchedTrigger ' + @h.inspect
1348
+ end
1349
+
1350
+ alias to_summary to_s
1248
1351
  end
1249
1352
 
1250
1353
  # Category: Battery/Power
@@ -1263,7 +1366,7 @@ class BatteryLevelTrigger < Trigger
1263
1366
 
1264
1367
  end
1265
1368
 
1266
- def to_s()
1369
+ def to_s(colour: false)
1267
1370
  operator = @h[:decreases_to] ? '<=' : '>='
1268
1371
  "Battery %s %s%%" % [operator, @h[:battery_level]]
1269
1372
  end
@@ -1286,6 +1389,11 @@ class BatteryTemperatureTrigger < Trigger
1286
1389
 
1287
1390
  end
1288
1391
 
1392
+ def to_s(colour: false)
1393
+ 'BatteryTemperatureTrigger ' + @h.inspect
1394
+ end
1395
+
1396
+ alias to_summary to_s
1289
1397
  end
1290
1398
 
1291
1399
  # Category: Battery/Power
@@ -1302,6 +1410,11 @@ class PowerButtonToggleTrigger < Trigger
1302
1410
 
1303
1411
  end
1304
1412
 
1413
+ def to_s(colour: false)
1414
+ 'PowerButtonToggleTrigger ' + @h.inspect
1415
+ end
1416
+
1417
+ alias to_summary to_s
1305
1418
  end
1306
1419
 
1307
1420
 
@@ -1321,6 +1434,27 @@ class ExternalPowerTrigger < Trigger
1321
1434
  super(options.merge h)
1322
1435
 
1323
1436
  end
1437
+
1438
+ def to_s(colour: false)
1439
+
1440
+ return 'Power Disconnected' unless @h[:power_connected]
1441
+
1442
+ status = 'Power Connectd'
1443
+ options = if @h[:power_connected_options].all? then
1444
+ 'Any'
1445
+ else
1446
+
1447
+ a = ['Wired (Fast Charge)', 'Wireless', 'Wired (Slow Charge)']
1448
+ @h[:power_connected_options].map.with_index {|x,i| x ? i : nil}\
1449
+ .compact.map {|i| a[i] }.join(' + ')
1450
+
1451
+ end
1452
+
1453
+ "%s: %s" % [status, options]
1454
+
1455
+ end
1456
+
1457
+ alias to_summary to_s
1324
1458
 
1325
1459
  end
1326
1460
 
@@ -1340,6 +1474,11 @@ class CallActiveTrigger < Trigger
1340
1474
 
1341
1475
  end
1342
1476
 
1477
+ def to_s(colour: false)
1478
+ 'CallActiveTrigger ' + @h.inspect
1479
+ end
1480
+
1481
+ alias to_summary to_s
1343
1482
  end
1344
1483
 
1345
1484
  # Category: Call/SMS
@@ -1360,6 +1499,12 @@ class IncomingCallTrigger < Trigger
1360
1499
 
1361
1500
  end
1362
1501
 
1502
+ def to_s(colour: false)
1503
+ caller = @h[:incoming_call_from_list].map {|x| "%s" % x[:name]}.join(', ')
1504
+ "Call Incoming [%s]" % caller
1505
+ end
1506
+
1507
+ alias to_summary to_s
1363
1508
  end
1364
1509
 
1365
1510
  # Category: Call/SMS
@@ -1380,6 +1525,11 @@ class OutgoingCallTrigger < Trigger
1380
1525
 
1381
1526
  end
1382
1527
 
1528
+ def to_s(colour: false)
1529
+ 'OutgoingCallTrigger ' + @h.inspect
1530
+ end
1531
+
1532
+ alias to_summary to_s
1383
1533
  end
1384
1534
 
1385
1535
  # Category: Call/SMS
@@ -1400,6 +1550,11 @@ class CallEndedTrigger < Trigger
1400
1550
 
1401
1551
  end
1402
1552
 
1553
+ def to_s(colour: false)
1554
+ 'CallEndedTrigger ' + @h.inspect
1555
+ end
1556
+
1557
+ alias to_summary to_s
1403
1558
  end
1404
1559
 
1405
1560
  # Category: Call/SMS
@@ -1416,6 +1571,11 @@ class CallMissedTrigger < Trigger
1416
1571
 
1417
1572
  end
1418
1573
 
1574
+ def to_s(colour: false)
1575
+ 'CallMissedTrigger ' + @h.inspect
1576
+ end
1577
+
1578
+ alias to_summary to_s
1419
1579
  end
1420
1580
 
1421
1581
  # Category: Call/SMS
@@ -1440,6 +1600,11 @@ class IncomingSMSTrigger < Trigger
1440
1600
 
1441
1601
  end
1442
1602
 
1603
+ def to_s(colour: false)
1604
+ 'IncomingSMSTrigger ' + @h.inspect
1605
+ end
1606
+
1607
+ alias to_summary to_s
1443
1608
  end
1444
1609
 
1445
1610
  # Category: Connectivity
@@ -1456,6 +1621,16 @@ class WebHookTrigger < Trigger
1456
1621
 
1457
1622
  end
1458
1623
 
1624
+ def to_s(colour: false)
1625
+
1626
+ url = "https://trigger.macrodroid.com/%s/%s" % \
1627
+ [@h[:macro].deviceid, @h[:identifier]]
1628
+ @s = 'WebHook (Url)' + "\n " + url
1629
+ super()
1630
+
1631
+ end
1632
+
1633
+ alias to_summary to_s
1459
1634
  end
1460
1635
 
1461
1636
  # Category: Connectivity
@@ -1473,6 +1648,12 @@ class WifiConnectionTrigger < Trigger
1473
1648
 
1474
1649
  end
1475
1650
 
1651
+ def to_s(colour: false)
1652
+ access_point = @h[:ssid_list].first
1653
+ 'Connected to network ' + access_point
1654
+ end
1655
+
1656
+ alias to_summary to_s
1476
1657
  end
1477
1658
 
1478
1659
  # Category: Connectivity
@@ -1491,6 +1672,11 @@ class BluetoothTrigger < Trigger
1491
1672
 
1492
1673
  end
1493
1674
 
1675
+ def to_s(colour: false)
1676
+ 'BluetoothTrigger ' + @h.inspect
1677
+ end
1678
+
1679
+ alias to_summary to_s
1494
1680
  end
1495
1681
 
1496
1682
  # Category: Connectivity
@@ -1508,6 +1694,11 @@ class HeadphonesTrigger < Trigger
1508
1694
 
1509
1695
  end
1510
1696
 
1697
+ def to_s(colour: false)
1698
+ 'HeadphonesTrigger ' + @h.inspect
1699
+ end
1700
+
1701
+ alias to_summary to_s
1511
1702
  end
1512
1703
 
1513
1704
  # Category: Connectivity
@@ -1524,6 +1715,11 @@ class SignalOnOffTrigger < Trigger
1524
1715
 
1525
1716
  end
1526
1717
 
1718
+ def to_s(colour: false)
1719
+ 'SignalOnOffTrigger ' + @h.inspect
1720
+ end
1721
+
1722
+ alias to_summary to_s
1527
1723
  end
1528
1724
 
1529
1725
  # Category: Connectivity
@@ -1540,6 +1736,11 @@ class UsbDeviceConnectionTrigger < Trigger
1540
1736
 
1541
1737
  end
1542
1738
 
1739
+ def to_s(colour: false)
1740
+ 'UsbDeviceConnectionTrigger ' + @h.inspect
1741
+ end
1742
+
1743
+ alias to_summary to_s
1543
1744
  end
1544
1745
 
1545
1746
  # Category: Connectivity
@@ -1577,6 +1778,11 @@ class WifiSSIDTrigger < Trigger
1577
1778
 
1578
1779
  end
1579
1780
 
1781
+ def to_s(colour: false)
1782
+ 'WifiSSIDTrigger ' + @h.inspect
1783
+ end
1784
+
1785
+ alias to_summary to_s
1580
1786
  end
1581
1787
 
1582
1788
  # Category: Date/Time
@@ -1603,6 +1809,11 @@ class CalendarTrigger < Trigger
1603
1809
 
1604
1810
  end
1605
1811
 
1812
+ def to_s(colour: false)
1813
+ 'CalendarTrigger ' + @h.inspect
1814
+ end
1815
+
1816
+ alias to_summary to_s
1606
1817
  end
1607
1818
 
1608
1819
  # Category: Date/Time
@@ -1640,7 +1851,7 @@ class TimerTrigger < Trigger
1640
1851
 
1641
1852
  #puts ('h: ' + h.inspect).debug
1642
1853
 
1643
- options = {
1854
+ @options = {
1644
1855
  alarm_id: uuid(),
1645
1856
  days_of_week: [false, false, false, false, false, false, false],
1646
1857
  minute: 10,
@@ -1648,7 +1859,8 @@ class TimerTrigger < Trigger
1648
1859
  use_alarm: false
1649
1860
  }
1650
1861
 
1651
- super(options.merge filter(options, h))
1862
+ #super(options.merge filter(options, h))
1863
+ super(@options.merge h)
1652
1864
 
1653
1865
  end
1654
1866
 
@@ -1668,7 +1880,7 @@ class TimerTrigger < Trigger
1668
1880
  "time.is? '%s'" % self.to_s.gsub(',', ' or')
1669
1881
  end
1670
1882
 
1671
- def to_s()
1883
+ def to_s(colour: false)
1672
1884
 
1673
1885
  dow = @h[:days_of_week]
1674
1886
 
@@ -1693,11 +1905,13 @@ class TimerTrigger < Trigger
1693
1905
  a.zip(dow).select {|_,b| b}.map(&:first).join(', ')
1694
1906
  end
1695
1907
 
1696
- time = Time.parse("%s:%s" % [@h[:hour], @h[:minute]]).strftime("%-H:%M%P")
1908
+ time = Time.parse("%s:%s" % [@h[:hour], @h[:minute]]).strftime("%H:%M")
1697
1909
 
1698
1910
  "%s %s" % [time, days]
1699
1911
  end
1700
1912
 
1913
+ alias to_summary to_s
1914
+
1701
1915
  private
1702
1916
 
1703
1917
  def time()
@@ -1729,6 +1943,11 @@ class StopwatchTrigger < Trigger
1729
1943
 
1730
1944
  end
1731
1945
 
1946
+ def to_s(colour: false)
1947
+ 'StopwatchTrigger ' + @h.inspect
1948
+ end
1949
+
1950
+ alias to_summary to_s
1732
1951
  end
1733
1952
 
1734
1953
  # Category: Date/Time
@@ -1757,6 +1976,11 @@ class DayTrigger < Trigger
1757
1976
 
1758
1977
  end
1759
1978
 
1979
+ def to_s(colour: false)
1980
+ 'DayTrigger ' + @h.inspect
1981
+ end
1982
+
1983
+ alias to_summary to_s
1760
1984
  end
1761
1985
 
1762
1986
  # Category: Date/Time
@@ -1780,6 +2004,15 @@ class RegularIntervalTrigger < Trigger
1780
2004
 
1781
2005
  end
1782
2006
 
2007
+ def to_s(colour: false)
2008
+
2009
+ interval = Subunit.new(units={minutes:60, hours:60}, \
2010
+ seconds: @h[:seconds]).strfunit("%c")
2011
+ 'Regular Interval ' + "\n Interval: " + interval
2012
+
2013
+ end
2014
+
2015
+ alias to_summary to_s
1783
2016
  end
1784
2017
 
1785
2018
  class DeviceEventsTrigger < Trigger
@@ -1814,6 +2047,11 @@ class AirplaneModeTrigger < DeviceEventsTrigger
1814
2047
 
1815
2048
  end
1816
2049
 
2050
+ def to_s(colour: false)
2051
+ 'AirplaneModeTrigger ' + @h.inspect
2052
+ end
2053
+
2054
+ alias to_summary to_s
1817
2055
  end
1818
2056
 
1819
2057
  # Category: Device Events
@@ -1830,6 +2068,11 @@ class AutoSyncChangeTrigger < DeviceEventsTrigger
1830
2068
 
1831
2069
  end
1832
2070
 
2071
+ def to_s(colour: false)
2072
+ 'AutoSyncChangeTrigger ' + @h.inspect
2073
+ end
2074
+
2075
+ alias to_summary to_s
1833
2076
  end
1834
2077
 
1835
2078
  # Category: Device Events
@@ -1846,6 +2089,11 @@ class DayDreamTrigger < DeviceEventsTrigger
1846
2089
 
1847
2090
  end
1848
2091
 
2092
+ def to_s(colour: false)
2093
+ 'DayDreamTrigger ' + @h.inspect
2094
+ end
2095
+
2096
+ alias to_summary to_s
1849
2097
  end
1850
2098
 
1851
2099
  # Category: Device Events
@@ -1862,6 +2110,11 @@ class DockTrigger < DeviceEventsTrigger
1862
2110
 
1863
2111
  end
1864
2112
 
2113
+ def to_s(colour: false)
2114
+ 'DockTrigger ' + @h.inspect
2115
+ end
2116
+
2117
+ alias to_summary to_s
1865
2118
  end
1866
2119
 
1867
2120
  # Category: Device Events
@@ -1882,7 +2135,7 @@ class FailedLoginTrigger < DeviceEventsTrigger
1882
2135
  'failed_login?'
1883
2136
  end
1884
2137
 
1885
- def to_s()
2138
+ def to_s(colour: false)
1886
2139
  'Failed Login Attempt'
1887
2140
  end
1888
2141
  end
@@ -1901,6 +2154,11 @@ class GPSEnabledTrigger < DeviceEventsTrigger
1901
2154
 
1902
2155
  end
1903
2156
 
2157
+ def to_s(colour: false)
2158
+ 'GPSEnabledTrigger ' + @h.inspect
2159
+ end
2160
+
2161
+ alias to_summary to_s
1904
2162
  end
1905
2163
 
1906
2164
  # Category: Device Events
@@ -1917,6 +2175,11 @@ class MusicPlayingTrigger < DeviceEventsTrigger
1917
2175
 
1918
2176
  end
1919
2177
 
2178
+ def to_s(colour: false)
2179
+ 'MusicPlayingTrigger ' + @h.inspect
2180
+ end
2181
+
2182
+ alias to_summary to_s
1920
2183
  end
1921
2184
 
1922
2185
 
@@ -1933,9 +2196,11 @@ class DeviceUnlockedTrigger < DeviceEventsTrigger
1933
2196
 
1934
2197
  end
1935
2198
 
1936
- def to_s()
2199
+ def to_s(colour: false)
1937
2200
  'Screen Unlocked'
1938
2201
  end
2202
+
2203
+ alias to_summary to_s
1939
2204
 
1940
2205
  end
1941
2206
 
@@ -1953,6 +2218,11 @@ class AutoRotateChangeTrigger < DeviceEventsTrigger
1953
2218
 
1954
2219
  end
1955
2220
 
2221
+ def to_s(colour: false)
2222
+ 'AutoRotateChangeTrigger ' + @h.inspect
2223
+ end
2224
+
2225
+ alias to_summary to_s
1956
2226
  end
1957
2227
 
1958
2228
  # Category: Device Events
@@ -1970,6 +2240,11 @@ class ClipboardChangeTrigger < DeviceEventsTrigger
1970
2240
 
1971
2241
  end
1972
2242
 
2243
+ def to_s(colour: false)
2244
+ 'ClipboardChangeTrigger ' + @h.inspect
2245
+ end
2246
+
2247
+ alias to_summary to_s
1973
2248
  end
1974
2249
 
1975
2250
  # Category: Device Events
@@ -1985,6 +2260,11 @@ class BootTrigger < DeviceEventsTrigger
1985
2260
 
1986
2261
  end
1987
2262
 
2263
+ def to_s(colour: false)
2264
+ 'BootTrigger ' + @h.inspect
2265
+ end
2266
+
2267
+ alias to_summary to_s
1988
2268
  end
1989
2269
 
1990
2270
  # Category: Device Events
@@ -2005,6 +2285,11 @@ class IntentReceivedTrigger < DeviceEventsTrigger
2005
2285
 
2006
2286
  end
2007
2287
 
2288
+ def to_s(colour: false)
2289
+ 'IntentReceivedTrigger ' + @h.inspect
2290
+ end
2291
+
2292
+ alias to_summary to_s
2008
2293
  end
2009
2294
 
2010
2295
  # Category: Device Events
@@ -2031,6 +2316,12 @@ class NotificationTrigger < DeviceEventsTrigger
2031
2316
 
2032
2317
  end
2033
2318
 
2319
+ def to_s(colour: false)
2320
+ s = (@h[:package_name_list] + @h[:application_name_list]).uniq.join(', ')
2321
+ 'Notification Received ' + "\n Any Content (%s)" % s
2322
+ end
2323
+
2324
+ alias to_summary to_s
2034
2325
  end
2035
2326
 
2036
2327
  # Category: Device Events
@@ -2046,6 +2337,12 @@ class ScreenOnOffTrigger < DeviceEventsTrigger
2046
2337
  super(options.merge h)
2047
2338
 
2048
2339
  end
2340
+
2341
+ def to_s(colour: false)
2342
+ 'Screen ' + (@h[:screen_on] ? 'On' : 'Off')
2343
+ end
2344
+
2345
+ alias to_summary to_s
2049
2346
 
2050
2347
  end
2051
2348
 
@@ -2063,6 +2360,11 @@ class SilentModeTrigger < DeviceEventsTrigger
2063
2360
 
2064
2361
  end
2065
2362
 
2363
+ def to_s(colour: false)
2364
+ 'SilentModeTrigger ' + @h.inspect
2365
+ end
2366
+
2367
+ alias to_summary to_s
2066
2368
  end
2067
2369
 
2068
2370
  # Category: Location
@@ -2088,6 +2390,11 @@ class WeatherTrigger < Trigger
2088
2390
 
2089
2391
  end
2090
2392
 
2393
+ def to_s(colour: false)
2394
+ 'WeatherTrigger ' + @h.inspect
2395
+ end
2396
+
2397
+ alias to_summary to_s
2091
2398
  end
2092
2399
 
2093
2400
  # Category: Location
@@ -2097,7 +2404,7 @@ class GeofenceTrigger < Trigger
2097
2404
  def initialize( h={}, geofences: {})
2098
2405
 
2099
2406
  if h[:name] then
2100
- puts ('geofences2: ' + geofences.inspect)
2407
+ puts ('geofences2: ' + geofences.inspect) if $debug
2101
2408
  found = geofences.find {|x| x.name.downcase == h[:name].downcase}
2102
2409
  h[:geofence_id] = found.id if found
2103
2410
 
@@ -2116,7 +2423,7 @@ class GeofenceTrigger < Trigger
2116
2423
 
2117
2424
  end
2118
2425
 
2119
- def to_s()
2426
+ def to_s(colour: false)
2120
2427
 
2121
2428
  if $debug then
2122
2429
  puts ' @geofences: ' + @geofences.inspect
@@ -2151,6 +2458,11 @@ class SunriseSunsetTrigger < Trigger
2151
2458
 
2152
2459
  end
2153
2460
 
2461
+ def to_s(colour: false)
2462
+ 'SunriseSunsetTrigger ' + @h.inspect
2463
+ end
2464
+
2465
+ alias to_summary to_s
2154
2466
  end
2155
2467
 
2156
2468
 
@@ -2180,12 +2492,12 @@ class ActivityRecognitionTrigger < SensorsTrigger
2180
2492
 
2181
2493
  end
2182
2494
 
2183
- def to_s()
2495
+ def to_s(colour: false)
2184
2496
  activity = @activity[@h[:selected_index]]
2185
2497
  'Activity - ' + activity
2186
2498
  end
2187
2499
 
2188
- def to_summary
2500
+ def to_summary(colour: false)
2189
2501
 
2190
2502
  activity = @activity[@h[:selected_index]]
2191
2503
  s = if activity.length > 10 then
@@ -2219,11 +2531,11 @@ class ProximityTrigger < SensorsTrigger
2219
2531
  selected_option: 0
2220
2532
  }
2221
2533
 
2222
- super(options.merge filter(options,h))
2534
+ super(options.merge h)
2223
2535
 
2224
2536
  end
2225
2537
 
2226
- def to_s()
2538
+ def to_s(colour: false)
2227
2539
 
2228
2540
  distance = if @h[:near] then
2229
2541
  'Near'
@@ -2233,6 +2545,8 @@ class ProximityTrigger < SensorsTrigger
2233
2545
 
2234
2546
  "Proximity Sensor (%s)" % distance
2235
2547
  end
2548
+
2549
+ alias to_summary to_s
2236
2550
 
2237
2551
  end
2238
2552
 
@@ -2253,7 +2567,7 @@ class ShakeDeviceTrigger < SensorsTrigger
2253
2567
  'shake_device?'
2254
2568
  end
2255
2569
 
2256
- def to_s()
2570
+ def to_s(colour: false)
2257
2571
  'Shake Device'
2258
2572
  end
2259
2573
 
@@ -2284,7 +2598,7 @@ class FlipDeviceTrigger < SensorsTrigger
2284
2598
  @h[:face_down] ? 'flip_device_down?' : 'flip_device_up?'
2285
2599
  end
2286
2600
 
2287
- def to_s()
2601
+ def to_s(colour: false)
2288
2602
 
2289
2603
  action = @h[:face_down] ? 'Face Up -> Face Down' : 'Face Down -> Face Up'
2290
2604
  'Flip Device ' + action
@@ -2307,6 +2621,11 @@ class OrientationTrigger < SensorsTrigger
2307
2621
 
2308
2622
  end
2309
2623
 
2624
+ def to_s(colour: false)
2625
+ 'OrientationTrigger ' + @h.inspect
2626
+ end
2627
+
2628
+ alias to_summary to_s
2310
2629
  end
2311
2630
 
2312
2631
  # Category: User Input
@@ -2332,6 +2651,11 @@ class FloatingButtonTrigger < Trigger
2332
2651
 
2333
2652
  end
2334
2653
 
2654
+ def to_s(colour: false)
2655
+ 'Floating Button'
2656
+ end
2657
+
2658
+ alias to_summary to_s
2335
2659
  end
2336
2660
 
2337
2661
  # Category: User Input
@@ -2347,6 +2671,11 @@ class ShortcutTrigger < Trigger
2347
2671
 
2348
2672
  end
2349
2673
 
2674
+ def to_s(colour: false)
2675
+ 'ShortcutTrigger ' + @h.inspect
2676
+ end
2677
+
2678
+ alias to_summary to_s
2350
2679
  end
2351
2680
 
2352
2681
  # Category: User Input
@@ -2365,6 +2694,33 @@ class VolumeButtonTrigger < Trigger
2365
2694
  super(options.merge h)
2366
2695
 
2367
2696
  end
2697
+
2698
+ def to_s(colour: false)
2699
+
2700
+ a = [
2701
+ 'Volume Up',
2702
+ 'Volume Down',
2703
+ 'Volume Up - Long Press',
2704
+ 'Volume Down - Long Press'
2705
+ ]
2706
+
2707
+ lines = [a[@h[:option]]]
2708
+ lines << ' ' + (@h[:dont_change_volume] ? 'Retain Previous Volume' : 'Update Volume')
2709
+ @s = lines.join("\n")
2710
+ end
2711
+
2712
+ def to_summary(colour: false)
2713
+ a = [
2714
+ 'Volume Up',
2715
+ 'Volume Down',
2716
+ 'Volume Up - Long Press',
2717
+ 'Volume Down - Long Press'
2718
+ ]
2719
+
2720
+ lines = [a[@h[:option]]]
2721
+ lines << (@h[:dont_change_volume] ? 'Retain Previous Volume' : 'Update Volume')
2722
+ @s = lines.join(": ")
2723
+ end
2368
2724
 
2369
2725
  end
2370
2726
 
@@ -2383,6 +2739,11 @@ class MediaButtonPressedTrigger < Trigger
2383
2739
 
2384
2740
  end
2385
2741
 
2742
+ def to_s(colour: false)
2743
+ 'MediaButtonPressedTrigger ' + @h.inspect
2744
+ end
2745
+
2746
+ alias to_summary to_s
2386
2747
  end
2387
2748
 
2388
2749
  # Category: User Input
@@ -2401,6 +2762,11 @@ class SwipeTrigger < Trigger
2401
2762
 
2402
2763
  end
2403
2764
 
2765
+ def to_s(colour: false)
2766
+ 'SwipeTrigger ' + @h.inspect
2767
+ end
2768
+
2769
+ alias to_summary to_s
2404
2770
  end
2405
2771
 
2406
2772
 
@@ -2409,19 +2775,35 @@ class Action < MacroObject
2409
2775
 
2410
2776
  attr_reader :constraints
2411
2777
 
2412
- def initialize(h={})
2778
+ def initialize(h={})
2779
+
2780
+ macro = h[:macro]
2781
+ h.delete :macro
2413
2782
  super(h)
2414
2783
 
2415
2784
  # fetch the constraints
2416
2785
  @constraints = @h[:constraint_list].map do |constraint|
2417
- object(constraint.to_snake_case)
2786
+ object(constraint.to_snake_case.merge(macro: macro))
2418
2787
  end
2419
2788
  end
2420
2789
 
2421
2790
  def invoke(s='')
2422
2791
  "%s/%s: %s" % [@group, @type, s]
2423
2792
  end
2793
+
2794
+ def to_s(colour: false)
2424
2795
 
2796
+ h = @h.clone
2797
+ h.delete :macro
2798
+ @s ||= "#<%s %s>" % [self.class, h.inspect]
2799
+ operator = @h[:is_or_condition] ? 'OR' : 'AND'
2800
+ constraints = @constraints.map \
2801
+ {|x| x.to_summary(colour: colour)}.join(" %s " % operator)
2802
+
2803
+ @s + constraints
2804
+
2805
+ end
2806
+
2425
2807
  end
2426
2808
 
2427
2809
 
@@ -2456,6 +2838,11 @@ class ShareLocationAction < LocationAction
2456
2838
 
2457
2839
  end
2458
2840
 
2841
+ def to_s(colour: false)
2842
+ 'ShareLocationAction ' + @h.inspect
2843
+ end
2844
+
2845
+ alias to_summary to_s
2459
2846
  end
2460
2847
 
2461
2848
 
@@ -2485,7 +2872,7 @@ class LaunchActivityAction < ApplicationAction
2485
2872
 
2486
2873
  end
2487
2874
 
2488
- def to_s()
2875
+ def to_s(colour: false)
2489
2876
  'Launch ' + @h[:application_name]
2490
2877
  end
2491
2878
 
@@ -2506,36 +2893,64 @@ class KillBackgroundAppAction < ApplicationAction
2506
2893
 
2507
2894
  end
2508
2895
 
2896
+ def to_s(colour: false)
2897
+ 'KillBackgroundAppAction ' + @h.inspect
2898
+ end
2899
+
2900
+ alias to_summary to_s
2509
2901
  end
2510
2902
 
2511
2903
  # Category: Applications
2512
2904
  #
2513
- class OpenWebPageAction < ApplicationAction
2905
+ class LaunchShortcutAction < ApplicationAction
2514
2906
 
2515
2907
  def initialize(h={})
2516
2908
 
2517
- h[:url_to_open] = h[:url] if h[:url]
2518
-
2519
2909
  options = {
2520
- variable_to_save_response: {:m_stringValue=>"", :m_name=>"", :m_decimalValue=>0.0, :isLocal=>true, :m_booleanValue=>false, :excludeFromLog=>false, :m_intValue=>0, :m_type=>2},
2521
- url_to_open: '',
2522
- http_get: true,
2523
- disable_url_encode: false,
2524
- block_next_action: false
2910
+ :app_name=>"Amazon Alexa", :intent_encoded=>"", :name=>"Ask Alexa"
2525
2911
  }
2526
2912
 
2527
- super(options.merge filter(options,h))
2913
+ super(options.merge h)
2528
2914
 
2529
2915
  end
2530
2916
 
2531
- def to_s()
2532
- "HTTP GET\n url: " + @h[:url_to_open]
2917
+ def to_s(colour: false)
2918
+ @s = "Launch Shortcut: " + @h[:app_name] + "\n " + @h[:name]
2919
+ super()
2533
2920
  end
2921
+
2922
+ alias to_summary to_s
2534
2923
 
2535
2924
  end
2536
2925
 
2537
-
2538
- class CameraAction < Action
2926
+ # Category: Applications
2927
+ #
2928
+ class OpenWebPageAction < ApplicationAction
2929
+
2930
+ def initialize(h={})
2931
+
2932
+ h[:url_to_open] = h[:url] if h[:url]
2933
+
2934
+ options = {
2935
+ variable_to_save_response: {:m_stringValue=>"", :m_name=>"", :m_decimalValue=>0.0, :isLocal=>true, :m_booleanValue=>false, :excludeFromLog=>false, :m_intValue=>0, :m_type=>2},
2936
+ url_to_open: '',
2937
+ http_get: true,
2938
+ disable_url_encode: false,
2939
+ block_next_action: false
2940
+ }
2941
+
2942
+ super(options.merge filter(options,h))
2943
+
2944
+ end
2945
+
2946
+ def to_s(colour: false)
2947
+ "HTTP GET\n url: " + @h[:url_to_open]
2948
+ end
2949
+
2950
+ end
2951
+
2952
+
2953
+ class CameraAction < Action
2539
2954
 
2540
2955
  def initialize(h={})
2541
2956
  super(h)
@@ -2559,6 +2974,11 @@ class UploadPhotoAction < CameraAction
2559
2974
 
2560
2975
  end
2561
2976
 
2977
+ def to_s(colour: false)
2978
+ 'UploadPhotoAction ' + @h.inspect
2979
+ end
2980
+
2981
+ alias to_summary to_s
2562
2982
  end
2563
2983
 
2564
2984
  # Category: Camera/Photo
@@ -2584,7 +3004,7 @@ class TakePictureAction < CameraAction
2584
3004
  'take_photo :' + camera.to_s
2585
3005
  end
2586
3006
 
2587
- def to_s()
3007
+ def to_s(colour: false)
2588
3008
  'Take Picture'
2589
3009
  end
2590
3010
 
@@ -2593,22 +3013,25 @@ end
2593
3013
  class IfConditionAction < Action
2594
3014
 
2595
3015
  def initialize(h={})
2596
-
3016
+
2597
3017
  options = {
2598
3018
  a: true,
2599
3019
  constraint_list: ''
2600
3020
  }
3021
+
3022
+ macro = h[:macro]
3023
+ h2 = options.merge(filter(options,h).merge(macro: macro))
2601
3024
 
2602
- super(options.merge h)
3025
+ super(h2)
3026
+
3027
+ @label = 'If '
2603
3028
 
2604
3029
  end
2605
3030
 
2606
- def to_s()
3031
+ def to_s(colour: false)
2607
3032
 
2608
- operator = @h[:is_or_condition] ? 'OR' : 'AND'
2609
- r = 'If ' + @constraints.map(&:to_s).join(" %s " % operator)
2610
- puts 'if ... @h ' + @h.inspect
2611
- r
3033
+ @s = "If " #+ @constraints.map(&:to_s).join(" %s " % operator)
3034
+ super(colour: colour)
2612
3035
 
2613
3036
  end
2614
3037
  end
@@ -2622,15 +3045,33 @@ class ElseAction < Action
2622
3045
  }
2623
3046
 
2624
3047
  super(options.merge h)
3048
+
2625
3049
 
2626
3050
  end
2627
3051
 
2628
- def to_s()
3052
+ def to_s(colour: false)
2629
3053
  'Else'
2630
3054
  end
2631
3055
 
2632
3056
  end
2633
3057
 
3058
+ class ElseIfConditionAction < IfConditionAction
3059
+
3060
+ def initialize(h={})
3061
+
3062
+ options = {
3063
+ constraint_list: ''
3064
+ }
3065
+
3066
+ super(options.merge h)
3067
+ @label = 'ElseIf '
3068
+
3069
+ end
3070
+
3071
+
3072
+ end
3073
+
3074
+
2634
3075
  class EndIfAction < Action
2635
3076
 
2636
3077
  def initialize(h={})
@@ -2643,7 +3084,7 @@ class EndIfAction < Action
2643
3084
 
2644
3085
  end
2645
3086
 
2646
- def to_s()
3087
+ def to_s(colour: false)
2647
3088
  'End If'
2648
3089
  end
2649
3090
 
@@ -2658,6 +3099,31 @@ class ConnectivityAction < Action
2658
3099
 
2659
3100
  end
2660
3101
 
3102
+ # Category: Connectivity
3103
+ #
3104
+ class SetAirplaneModeAction < ConnectivityAction
3105
+
3106
+ def initialize(h={})
3107
+
3108
+ options = {
3109
+ device_name: '',
3110
+ state: 1
3111
+ }
3112
+
3113
+ super(options.merge h)
3114
+
3115
+ end
3116
+
3117
+ def to_s(colour: false)
3118
+
3119
+ state = ['On', 'Off', 'Toggle'][@h[:state]]
3120
+ @s = 'Airplane Mode ' + state + "\n"
3121
+ super(colour: colour)
3122
+
3123
+ end
3124
+
3125
+ end
3126
+
2661
3127
  # Category: Connectivity
2662
3128
  #
2663
3129
  class SetWifiAction < ConnectivityAction
@@ -2674,7 +3140,7 @@ class SetWifiAction < ConnectivityAction
2674
3140
 
2675
3141
  end
2676
3142
 
2677
- def to_s()
3143
+ def to_s(colour: false)
2678
3144
  action = @h[:state] == 0 ? 'Enable' : 'Disable'
2679
3145
  action + ' Wifi'
2680
3146
  end
@@ -2696,6 +3162,11 @@ class SetBluetoothAction < ConnectivityAction
2696
3162
 
2697
3163
  end
2698
3164
 
3165
+ def to_s(colour: false)
3166
+ 'SetBluetoothAction ' + @h.inspect
3167
+ end
3168
+
3169
+ alias to_summary to_s
2699
3170
  end
2700
3171
 
2701
3172
  # Category: Connectivity
@@ -2713,6 +3184,11 @@ class SetBluetoothAction < ConnectivityAction
2713
3184
 
2714
3185
  end
2715
3186
 
3187
+ def to_s(colour: false)
3188
+ 'SetBluetoothAction ' + @h.inspect
3189
+ end
3190
+
3191
+ alias to_summary to_s
2716
3192
  end
2717
3193
 
2718
3194
  class SetHotspotAction < ConnectivityAction
@@ -2728,9 +3204,9 @@ class SetHotspotAction < ConnectivityAction
2728
3204
 
2729
3205
  end
2730
3206
 
2731
- def to_s()
3207
+ def to_s(colour: false)
2732
3208
  action = @h[:turn_wifi_on] ? 'Enable' : 'Disable'
2733
- action + ' Hotspot'
3209
+ action + ' HotSpot'
2734
3210
  end
2735
3211
  end
2736
3212
 
@@ -2760,6 +3236,11 @@ class SendIntentAction < ConnectivityAction
2760
3236
 
2761
3237
  end
2762
3238
 
3239
+ def to_s(colour: false)
3240
+ 'Send Intent ' + "\n " + @h[:action]
3241
+ end
3242
+
3243
+ alias to_summary to_s
2763
3244
  end
2764
3245
 
2765
3246
 
@@ -2795,6 +3276,11 @@ class SetAlarmClockAction < DateTimeAction
2795
3276
 
2796
3277
  end
2797
3278
 
3279
+ def to_s(colour: false)
3280
+ 'SetAlarmClockAction ' + @h.inspect
3281
+ end
3282
+
3283
+ alias to_summary to_s
2798
3284
  end
2799
3285
 
2800
3286
  # Category: Date/Time
@@ -2812,6 +3298,11 @@ class StopWatchAction < DateTimeAction
2812
3298
 
2813
3299
  end
2814
3300
 
3301
+ def to_s(colour: false)
3302
+ 'StopWatchAction ' + @h.inspect
3303
+ end
3304
+
3305
+ alias to_summary to_s
2815
3306
  end
2816
3307
 
2817
3308
  # Category: Date/Time
@@ -2838,7 +3329,7 @@ class SayTimeAction < DateTimeAction
2838
3329
  'say current_time()'
2839
3330
  end
2840
3331
 
2841
- def to_s()
3332
+ def to_s(colour: false)
2842
3333
  'Say Current Time'
2843
3334
  end
2844
3335
 
@@ -2868,6 +3359,11 @@ class AndroidShortcutsAction < DeviceAction
2868
3359
 
2869
3360
  end
2870
3361
 
3362
+ def to_s(colour: false)
3363
+ 'AndroidShortcutsAction ' + @h.inspect
3364
+ end
3365
+
3366
+ alias to_summary to_s
2871
3367
  end
2872
3368
 
2873
3369
  # Category: Device Actions
@@ -2884,6 +3380,11 @@ class ClipboardAction < DeviceAction
2884
3380
 
2885
3381
  end
2886
3382
 
3383
+ def to_s(colour: false)
3384
+ 'ClipboardAction ' + @h.inspect
3385
+ end
3386
+
3387
+ alias to_summary to_s
2887
3388
  end
2888
3389
 
2889
3390
  # Category: Device Actions
@@ -2899,6 +3400,11 @@ class PressBackAction < DeviceAction
2899
3400
 
2900
3401
  end
2901
3402
 
3403
+ def to_s(colour: false)
3404
+ 'PressBackAction ' + @h.inspect
3405
+ end
3406
+
3407
+ alias to_summary to_s
2902
3408
  end
2903
3409
 
2904
3410
  # Category: Device Actions
@@ -2922,7 +3428,7 @@ class SpeakTextAction < DeviceAction
2922
3428
 
2923
3429
  end
2924
3430
 
2925
- def to_s()
3431
+ def to_s(colour: false)
2926
3432
  "Speak Text (%s)" % @h[:text_to_say]
2927
3433
  end
2928
3434
 
@@ -2943,6 +3449,11 @@ class UIInteractionAction < DeviceAction
2943
3449
 
2944
3450
  end
2945
3451
 
3452
+ def to_s(colour: false)
3453
+ 'UIInteractionAction ' + @h.inspect
3454
+ end
3455
+
3456
+ alias to_summary to_s
2946
3457
  end
2947
3458
 
2948
3459
  # Category: Device Actions
@@ -2958,6 +3469,11 @@ class VoiceSearchAction < DeviceAction
2958
3469
 
2959
3470
  end
2960
3471
 
3472
+ def to_s(colour: false)
3473
+ 'VoiceSearchAction ' + @h.inspect
3474
+ end
3475
+
3476
+ alias to_summary to_s
2961
3477
  end
2962
3478
 
2963
3479
 
@@ -2984,6 +3500,11 @@ class ExpandCollapseStatusBarAction < DeviceSettingsAction
2984
3500
 
2985
3501
  end
2986
3502
 
3503
+ def to_s(colour: false)
3504
+ 'ExpandCollapseStatusBarAction ' + @h.inspect
3505
+ end
3506
+
3507
+ alias to_summary to_s
2987
3508
  end
2988
3509
 
2989
3510
  # Category: Device Settings
@@ -2999,6 +3520,11 @@ class LaunchHomeScreenAction < DeviceSettingsAction
2999
3520
 
3000
3521
  end
3001
3522
 
3523
+ def to_s(colour: false)
3524
+ 'LaunchHomeScreenAction ' + @h.inspect
3525
+ end
3526
+
3527
+ alias to_summary to_s
3002
3528
  end
3003
3529
 
3004
3530
  # Category: Device Settings
@@ -3017,11 +3543,11 @@ class CameraFlashLightAction < DeviceSettingsAction
3017
3543
  end
3018
3544
 
3019
3545
  def to_pc()
3020
- 'torch :on'
3546
+ ['torch :on', 'torch :off', 'torch :toggle'][@h[:state]]
3021
3547
  end
3022
3548
 
3023
- def to_s()
3024
- 'Torch On'
3549
+ def to_s(colour: false)
3550
+ ['Torch On', 'Torch Off', 'Torch Toggle'][@h[:state]]
3025
3551
  end
3026
3552
 
3027
3553
  end
@@ -3040,7 +3566,7 @@ class VibrateAction < DeviceSettingsAction
3040
3566
 
3041
3567
  end
3042
3568
 
3043
- def to_s()
3569
+ def to_s(colour: false)
3044
3570
 
3045
3571
  pattern = [
3046
3572
  'Blip', 'Short Buzz', 'Long Buzz', 'Rapid', 'Slow', 'Increasing',
@@ -3067,6 +3593,11 @@ class SetAutoRotateAction < DeviceSettingsAction
3067
3593
 
3068
3594
  end
3069
3595
 
3596
+ def to_s(colour: false)
3597
+ 'SetAutoRotateAction ' + @h.inspect
3598
+ end
3599
+
3600
+ alias to_summary to_s
3070
3601
  end
3071
3602
 
3072
3603
  # Category: Device Settings
@@ -3082,6 +3613,11 @@ class DayDreamAction < DeviceSettingsAction
3082
3613
 
3083
3614
  end
3084
3615
 
3616
+ def to_s(colour: false)
3617
+ 'DayDreamAction ' + @h.inspect
3618
+ end
3619
+
3620
+ alias to_summary to_s
3085
3621
  end
3086
3622
 
3087
3623
  # Category: Device Settings
@@ -3097,6 +3633,11 @@ class SetKeyboardAction < DeviceSettingsAction
3097
3633
 
3098
3634
  end
3099
3635
 
3636
+ def to_s(colour: false)
3637
+ 'SetKeyboardAction ' + @h.inspect
3638
+ end
3639
+
3640
+ alias to_summary to_s
3100
3641
  end
3101
3642
 
3102
3643
  # Category: Device Settings
@@ -3113,6 +3654,11 @@ class SetKeyguardAction < DeviceSettingsAction
3113
3654
 
3114
3655
  end
3115
3656
 
3657
+ def to_s(colour: false)
3658
+ 'SetKeyguardAction ' + @h.inspect
3659
+ end
3660
+
3661
+ alias to_summary to_s
3116
3662
  end
3117
3663
 
3118
3664
  # Category: Device Settings
@@ -3129,6 +3675,11 @@ class CarModeAction < DeviceSettingsAction
3129
3675
 
3130
3676
  end
3131
3677
 
3678
+ def to_s(colour: false)
3679
+ 'CarModeAction ' + @h.inspect
3680
+ end
3681
+
3682
+ alias to_summary to_s
3132
3683
  end
3133
3684
 
3134
3685
  # Category: Device Settings
@@ -3146,6 +3697,11 @@ class ChangeKeyboardAction < DeviceSettingsAction
3146
3697
 
3147
3698
  end
3148
3699
 
3700
+ def to_s(colour: false)
3701
+ 'ChangeKeyboardAction ' + @h.inspect
3702
+ end
3703
+
3704
+ alias to_summary to_s
3149
3705
  end
3150
3706
 
3151
3707
  # Category: Device Settings
@@ -3167,6 +3723,11 @@ class SetWallpaperAction < DeviceSettingsAction
3167
3723
 
3168
3724
  end
3169
3725
 
3726
+ def to_s(colour: false)
3727
+ 'SetWallpaperAction ' + @h.inspect
3728
+ end
3729
+
3730
+ alias to_summary to_s
3170
3731
  end
3171
3732
 
3172
3733
  class FileAction < Action
@@ -3195,6 +3756,11 @@ class OpenFileAction < FileAction
3195
3756
 
3196
3757
  end
3197
3758
 
3759
+ def to_s(colour: false)
3760
+ 'OpenFileAction ' + @h.inspect
3761
+ end
3762
+
3763
+ alias to_summary to_s
3198
3764
  end
3199
3765
 
3200
3766
 
@@ -3220,6 +3786,11 @@ class ForceLocationUpdateAction < LocationAction
3220
3786
 
3221
3787
  end
3222
3788
 
3789
+ def to_s(colour: false)
3790
+ 'ForceLocationUpdateAction ' + @h.inspect
3791
+ end
3792
+
3793
+ alias to_summary to_s
3223
3794
  end
3224
3795
 
3225
3796
  # Category: Location
@@ -3240,6 +3811,11 @@ class ShareLocationAction < LocationAction
3240
3811
 
3241
3812
  end
3242
3813
 
3814
+ def to_s(colour: false)
3815
+ 'ShareLocationAction ' + @h.inspect
3816
+ end
3817
+
3818
+ alias to_summary to_s
3243
3819
  end
3244
3820
 
3245
3821
  # Category: Location
@@ -3257,6 +3833,11 @@ class SetLocationUpdateRateAction < LocationAction
3257
3833
 
3258
3834
  end
3259
3835
 
3836
+ def to_s(colour: false)
3837
+ 'SetLocationUpdateRateAction ' + @h.inspect
3838
+ end
3839
+
3840
+ alias to_summary to_s
3260
3841
  end
3261
3842
 
3262
3843
  class LoggingAction < Action
@@ -3295,6 +3876,11 @@ class AddCalendarEntryAction < LoggingAction
3295
3876
 
3296
3877
  end
3297
3878
 
3879
+ def to_s(colour: false)
3880
+ 'AddCalendarEntryAction ' + @h.inspect
3881
+ end
3882
+
3883
+ alias to_summary to_s
3298
3884
  end
3299
3885
 
3300
3886
  # Category: Logging
@@ -3312,6 +3898,11 @@ class LogAction < LoggingAction
3312
3898
 
3313
3899
  end
3314
3900
 
3901
+ def to_s(colour: false)
3902
+ 'LogAction ' + @h.inspect
3903
+ end
3904
+
3905
+ alias to_summary to_s
3315
3906
  end
3316
3907
 
3317
3908
  # Category: Logging
@@ -3328,6 +3919,40 @@ class ClearLogAction < LoggingAction
3328
3919
 
3329
3920
  end
3330
3921
 
3922
+ def to_s(colour: false)
3923
+ 'ClearLogAction ' + @h.inspect
3924
+ end
3925
+
3926
+ alias to_summary to_s
3927
+ end
3928
+
3929
+ class PauseAction < Action
3930
+
3931
+ def initialize(h={})
3932
+
3933
+ options = {
3934
+ delay_in_milli_seconds: 0, delay_in_seconds: 1, use_alarm: false
3935
+ }
3936
+ super(h)
3937
+
3938
+ end
3939
+
3940
+ def to_s(colour: false)
3941
+
3942
+ su = Subunit.new(units={minutes:60, hours:60},
3943
+ seconds: @h[:delay_in_seconds])
3944
+
3945
+ ms = @h[:delay_in_milli_seconds]
3946
+
3947
+ duration = if su.to_h.has_key?(:minutes) or (ms < 1) then
3948
+ su.strfunit("%X")
3949
+ else
3950
+ "%s %s ms" % [su.strfunit("%X"), ms]
3951
+ end
3952
+
3953
+ "Wait " + duration
3954
+ end
3955
+
3331
3956
  end
3332
3957
 
3333
3958
  class MediaAction < Action
@@ -3356,6 +3981,11 @@ class RecordMicrophoneAction < MediaAction
3356
3981
 
3357
3982
  end
3358
3983
 
3984
+ def to_s(colour: false)
3985
+ 'RecordMicrophoneAction ' + @h.inspect
3986
+ end
3987
+
3988
+ alias to_summary to_s
3359
3989
  end
3360
3990
 
3361
3991
  # Category: Media
@@ -3373,7 +4003,7 @@ class PlaySoundAction < MediaAction
3373
4003
 
3374
4004
  end
3375
4005
 
3376
- def to_s()
4006
+ def to_s(colour: false)
3377
4007
  'Play: ' + @h[:file_path]
3378
4008
  end
3379
4009
 
@@ -3409,6 +4039,11 @@ class SendEmailAction < MessagingAction
3409
4039
 
3410
4040
  end
3411
4041
 
4042
+ def to_s(colour: false)
4043
+ 'SendEmailAction ' + @h.inspect
4044
+ end
4045
+
4046
+ alias to_summary to_s
3412
4047
  end
3413
4048
 
3414
4049
  # Category: Messaging
@@ -3430,6 +4065,11 @@ class SendSMSAction < MessagingAction
3430
4065
 
3431
4066
  end
3432
4067
 
4068
+ def to_s(colour: false)
4069
+ 'SendSMSAction ' + @h.inspect
4070
+ end
4071
+
4072
+ alias to_summary to_s
3433
4073
  end
3434
4074
 
3435
4075
  # Category: Messaging
@@ -3448,6 +4088,11 @@ class UDPCommandAction < MessagingAction
3448
4088
 
3449
4089
  end
3450
4090
 
4091
+ def to_s(colour: false)
4092
+ 'UDPCommandAction ' + @h.inspect
4093
+ end
4094
+
4095
+ alias to_summary to_s
3451
4096
  end
3452
4097
 
3453
4098
 
@@ -3482,6 +4127,11 @@ class ClearNotificationsAction < NotificationsAction
3482
4127
 
3483
4128
  end
3484
4129
 
4130
+ def to_s(colour: false)
4131
+ 'ClearNotificationsAction ' + @h.inspect
4132
+ end
4133
+
4134
+ alias to_summary to_s
3485
4135
  end
3486
4136
 
3487
4137
  # Category: Notifications
@@ -3508,6 +4158,10 @@ class MessageDialogAction < NotificationsAction
3508
4158
  super(options.merge h)
3509
4159
 
3510
4160
  end
4161
+
4162
+ def to_s(colour: false)
4163
+ 'Display Dialog' + "\n Battery at: [battery]"
4164
+ end
3511
4165
 
3512
4166
  end
3513
4167
 
@@ -3525,6 +4179,11 @@ class AllowLEDNotificationLightAction < NotificationsAction
3525
4179
 
3526
4180
  end
3527
4181
 
4182
+ def to_s(colour: false)
4183
+ 'AllowLEDNotificationLightAction ' + @h.inspect
4184
+ end
4185
+
4186
+ alias to_summary to_s
3528
4187
  end
3529
4188
 
3530
4189
  # Category: Notifications
@@ -3541,6 +4200,11 @@ class SetNotificationSoundAction < NotificationsAction
3541
4200
 
3542
4201
  end
3543
4202
 
4203
+ def to_s(colour: false)
4204
+ 'SetNotificationSoundAction ' + @h.inspect
4205
+ end
4206
+
4207
+ alias to_summary to_s
3544
4208
  end
3545
4209
 
3546
4210
  # Category: Notifications
@@ -3557,6 +4221,11 @@ class SetNotificationSoundAction < NotificationsAction
3557
4221
 
3558
4222
  end
3559
4223
 
4224
+ def to_s(colour: false)
4225
+ 'SetNotificationSoundAction ' + @h.inspect
4226
+ end
4227
+
4228
+ alias to_summary to_s
3560
4229
  end
3561
4230
 
3562
4231
  # Category: Notifications
@@ -3573,6 +4242,11 @@ class SetNotificationSoundAction < NotificationsAction
3573
4242
 
3574
4243
  end
3575
4244
 
4245
+ def to_s(colour: false)
4246
+ 'SetNotificationSoundAction ' + @h.inspect
4247
+ end
4248
+
4249
+ alias to_summary to_s
3576
4250
  end
3577
4251
 
3578
4252
  # Category: Notifications
@@ -3602,8 +4276,9 @@ class NotificationAction < NotificationsAction
3602
4276
 
3603
4277
  end
3604
4278
 
3605
- def to_s()
3606
- 'Display Notification: ' + "%s: %s" % [@h[:notification_subject], @h[:notification_text]]
4279
+ def to_s(colour: false)
4280
+ "Display Notification\n " + \
4281
+ "%s: %s" % [@h[:notification_subject], @h[:notification_text]]
3607
4282
  end
3608
4283
 
3609
4284
  end
@@ -3642,8 +4317,8 @@ class ToastAction < NotificationsAction
3642
4317
  "popup_message '%s'" % @h[:message_text]
3643
4318
  end
3644
4319
 
3645
- def to_s()
3646
- "Popup Message '%s'" % @h[:message_text]
4320
+ def to_s(colour: false)
4321
+ "Popup Message\n %s" % @h[:message_text]
3647
4322
  end
3648
4323
 
3649
4324
  end
@@ -3671,7 +4346,11 @@ class AnswerCallAction < PhoneAction
3671
4346
  super(options.merge h)
3672
4347
 
3673
4348
  end
3674
-
4349
+
4350
+ def to_s(colour: false)
4351
+ @s = 'Answer Call' + "\n "
4352
+ super()
4353
+ end
3675
4354
  end
3676
4355
 
3677
4356
  # Category: Phone
@@ -3690,6 +4369,11 @@ class ClearCallLogAction < PhoneAction
3690
4369
 
3691
4370
  end
3692
4371
 
4372
+ def to_s(colour: false)
4373
+ 'ClearCallLogAction ' + @h.inspect
4374
+ end
4375
+
4376
+ alias to_summary to_s
3693
4377
  end
3694
4378
 
3695
4379
  # Category: Phone
@@ -3705,6 +4389,11 @@ class OpenCallLogAction < PhoneAction
3705
4389
 
3706
4390
  end
3707
4391
 
4392
+ def to_s(colour: false)
4393
+ 'OpenCallLogAction ' + @h.inspect
4394
+ end
4395
+
4396
+ alias to_summary to_s
3708
4397
  end
3709
4398
 
3710
4399
  # Category: Phone
@@ -3719,6 +4408,11 @@ class RejectCallAction < PhoneAction
3719
4408
  super(options.merge h)
3720
4409
 
3721
4410
  end
4411
+
4412
+ def to_s(colour: false)
4413
+ @s = 'Call Reject' + "\n "
4414
+ super()
4415
+ end
3722
4416
 
3723
4417
  end
3724
4418
 
@@ -3737,6 +4431,11 @@ class MakeCallAction < PhoneAction
3737
4431
 
3738
4432
  end
3739
4433
 
4434
+ def to_s(colour: false)
4435
+ 'MakeCallAction ' + @h.inspect
4436
+ end
4437
+
4438
+ alias to_summary to_s
3740
4439
  end
3741
4440
 
3742
4441
 
@@ -3754,6 +4453,11 @@ class SetRingtoneAction < PhoneAction
3754
4453
 
3755
4454
  end
3756
4455
 
4456
+ def to_s(colour: false)
4457
+ 'SetRingtoneAction ' + @h.inspect
4458
+ end
4459
+
4460
+ alias to_summary to_s
3757
4461
  end
3758
4462
 
3759
4463
  class ScreenAction < Action
@@ -3781,6 +4485,11 @@ class SetBrightnessAction < ScreenAction
3781
4485
 
3782
4486
  end
3783
4487
 
4488
+ def to_s(colour: false)
4489
+ 'SetBrightnessAction ' + @h.inspect
4490
+ end
4491
+
4492
+ alias to_summary to_s
3784
4493
  end
3785
4494
 
3786
4495
  # Category: Screen
@@ -3797,6 +4506,11 @@ class ForceScreenRotationAction < ScreenAction
3797
4506
 
3798
4507
  end
3799
4508
 
4509
+ def to_s(colour: false)
4510
+ 'ForceScreenRotationAction ' + @h.inspect
4511
+ end
4512
+
4513
+ alias to_summary to_s
3800
4514
  end
3801
4515
 
3802
4516
  # Category: Screen
@@ -3816,6 +4530,17 @@ class ScreenOnAction < ScreenAction
3816
4530
 
3817
4531
  end
3818
4532
 
4533
+ def to_s(colour: false)
4534
+
4535
+ state = @h[:screen_off] ? 'Off' : 'On'
4536
+ state += ' ' + 'No Lock (root only)' if @h[:screen_off_no_lock]
4537
+ #state += ' ' + '(Alternative)' if @h[:screen_on_alternative]
4538
+
4539
+ 'Screen ' + state
4540
+
4541
+ end
4542
+
4543
+ alias to_summary to_s
3819
4544
  end
3820
4545
 
3821
4546
  # Category: Screen
@@ -3833,6 +4558,11 @@ class DimScreenAction < ScreenAction
3833
4558
 
3834
4559
  end
3835
4560
 
4561
+ def to_s(colour: false)
4562
+ 'DimScreenAction ' + @h.inspect
4563
+ end
4564
+
4565
+ alias to_summary to_s
3836
4566
  end
3837
4567
 
3838
4568
  # Category: Screen
@@ -3856,7 +4586,7 @@ class KeepAwakeAction < ScreenAction
3856
4586
 
3857
4587
  end
3858
4588
 
3859
- def to_s()
4589
+ def to_s(colour: false)
3860
4590
 
3861
4591
  screen = @h[:screen_option] == 0 ? 'Screen On' : 'Screen Off'
3862
4592
 
@@ -3871,7 +4601,7 @@ class KeepAwakeAction < ScreenAction
3871
4601
  Subunit.new(units={minutes:60, hours:60}, seconds: scnds).strfunit("%x")
3872
4602
  end
3873
4603
 
3874
- 'Keep Device Awake ' + screen + ' ' + whenx
4604
+ "Keep Device Awake\n " + screen + ' - ' + whenx
3875
4605
 
3876
4606
  else
3877
4607
  'Disable Keep Awake'
@@ -3897,6 +4627,11 @@ class SetScreenTimeoutAction < ScreenAction
3897
4627
 
3898
4628
  end
3899
4629
 
4630
+ def to_s(colour: false)
4631
+ 'SetScreenTimeoutAction ' + @h.inspect
4632
+ end
4633
+
4634
+ alias to_summary to_s
3900
4635
  end
3901
4636
 
3902
4637
 
@@ -3923,6 +4658,11 @@ class SilentModeVibrateOffAction < VolumeAction
3923
4658
 
3924
4659
  end
3925
4660
 
4661
+ def to_s(colour: false)
4662
+ 'SilentModeVibrateOffAction ' + @h.inspect
4663
+ end
4664
+
4665
+ alias to_summary to_s
3926
4666
  end
3927
4667
 
3928
4668
  # Category: Volume
@@ -3940,6 +4680,27 @@ class SetVibrateAction < VolumeAction
3940
4680
 
3941
4681
  end
3942
4682
 
4683
+ def to_s(colour: false)
4684
+
4685
+ a = [
4686
+ 'Silent (Vibrate On)',
4687
+ 'Normal (Vibrate Off)',
4688
+ 'Vibrate when ringing On',
4689
+ 'Vibrate when ringing Off',
4690
+ 'Vibrate when ringing Toggle'
4691
+ ]
4692
+
4693
+ status = a[@h[:option_int]]
4694
+ @s = 'Vibrate Enable/Disable ' + "\n " + status + "\n "
4695
+ super()
4696
+
4697
+ end
4698
+
4699
+ def to_summary(colour: false)
4700
+
4701
+ @s = 'Vibrate Enable/Disable'
4702
+
4703
+ end
3943
4704
  end
3944
4705
 
3945
4706
  # Category: Volume
@@ -3956,6 +4717,11 @@ class VolumeIncrementDecrementAction < VolumeAction
3956
4717
 
3957
4718
  end
3958
4719
 
4720
+ def to_s(colour: false)
4721
+ 'VolumeIncrementDecrementAction ' + @h.inspect
4722
+ end
4723
+
4724
+ alias to_summary to_s
3959
4725
  end
3960
4726
 
3961
4727
  # Category: Volume
@@ -3973,6 +4739,11 @@ class SpeakerPhoneAction < VolumeAction
3973
4739
 
3974
4740
  end
3975
4741
 
4742
+ def to_s(colour: false)
4743
+ 'SpeakerPhoneAction ' + @h.inspect
4744
+ end
4745
+
4746
+ alias to_summary to_s
3976
4747
  end
3977
4748
 
3978
4749
  # Category: Volume
@@ -3992,7 +4763,11 @@ class SetVolumeAction < VolumeAction
3992
4763
  super(options.merge h)
3993
4764
 
3994
4765
  end
3995
-
4766
+
4767
+ def to_s(colour: false)
4768
+ volume = @h[:stream_index_array].zip(@h[:stream_volume_array]).to_h[true]
4769
+ 'Volume Change ' + "Notification = %s%%" % volume
4770
+ end
3996
4771
  end
3997
4772
 
3998
4773
  class Constraint < MacroObject
@@ -4005,7 +4780,7 @@ class Constraint < MacroObject
4005
4780
 
4006
4781
  detail.select {|k,v| @h.include? k }.all? {|key,value| @h[key] == value}
4007
4782
 
4008
- end
4783
+ end
4009
4784
 
4010
4785
  #def to_s()
4011
4786
  # ''
@@ -4027,22 +4802,7 @@ class Constraint < MacroObject
4027
4802
 
4028
4803
  end
4029
4804
 
4030
- class TimeOfDayConstraint < Constraint
4031
-
4032
- def initialize(h={})
4033
-
4034
- options = {
4035
- end_hour: 8,
4036
- end_minute: 0,
4037
- start_hour: 22,
4038
- start_minute: 0
4039
- }
4040
-
4041
- super(options.merge h)
4042
-
4043
- end
4044
4805
 
4045
- end
4046
4806
 
4047
4807
  # Category: Battery/Power
4048
4808
  #
@@ -4060,7 +4820,7 @@ class BatteryLevelConstraint < Constraint
4060
4820
 
4061
4821
  end
4062
4822
 
4063
- def to_s()
4823
+ def to_s(colour: false)
4064
4824
 
4065
4825
  operator = if @h[:greater_than] then
4066
4826
  '>'
@@ -4074,6 +4834,8 @@ class BatteryLevelConstraint < Constraint
4074
4834
 
4075
4835
  "Battery %s %s%%" % [operator, level]
4076
4836
  end
4837
+
4838
+ alias to_summary to_s
4077
4839
 
4078
4840
  end
4079
4841
 
@@ -4091,6 +4853,11 @@ class BatterySaverStateConstraint < Constraint
4091
4853
 
4092
4854
  end
4093
4855
 
4856
+ def to_s(colour: false)
4857
+ 'BatterySaverStateConstraint ' + @h.inspect
4858
+ end
4859
+
4860
+ alias to_summary to_s
4094
4861
  end
4095
4862
 
4096
4863
  # Category: Battery/Power
@@ -4109,6 +4876,11 @@ class BatteryTemperatureConstraint < Constraint
4109
4876
 
4110
4877
  end
4111
4878
 
4879
+ def to_s(colour: false)
4880
+ 'BatteryTemperatureConstraint ' + @h.inspect
4881
+ end
4882
+
4883
+ alias to_summary to_s
4112
4884
  end
4113
4885
 
4114
4886
  # Category: Battery/Power
@@ -4126,7 +4898,7 @@ class ExternalPowerConstraint < Constraint
4126
4898
 
4127
4899
  end
4128
4900
 
4129
- def to_s()
4901
+ def to_s(colour: false)
4130
4902
  connection = @h[:external_power] ? 'Connected' : 'Disconnected'
4131
4903
  'Power ' + connection
4132
4904
  end
@@ -4149,11 +4921,15 @@ class BluetoothConstraint < Constraint
4149
4921
 
4150
4922
  end
4151
4923
 
4152
- def to_s()
4924
+ def to_s(colour: false)
4153
4925
  device = @h[:device_name] #== 'Any Device' ? 'Any' : @h[:device_name]
4154
- "Device Connected (%s)" % device
4926
+ "Device Connected\n %s" % device
4155
4927
  end
4156
4928
 
4929
+ def to_summary(colour: false)
4930
+ device = @h[:device_name] #== 'Any Device' ? 'Any' : @h[:device_name]
4931
+ "Device Connected (%s)" % device
4932
+ end
4157
4933
 
4158
4934
  end
4159
4935
 
@@ -4171,6 +4947,11 @@ class GPSEnabledConstraint < Constraint
4171
4947
 
4172
4948
  end
4173
4949
 
4950
+ def to_s(colour: false)
4951
+ 'GPSEnabledConstraint ' + @h.inspect
4952
+ end
4953
+
4954
+ alias to_summary to_s
4174
4955
  end
4175
4956
 
4176
4957
  # Category: Connectivity
@@ -4187,6 +4968,11 @@ class LocationModeConstraint < Constraint
4187
4968
 
4188
4969
  end
4189
4970
 
4971
+ def to_s(colour: false)
4972
+ 'LocationModeConstraint ' + @h.inspect
4973
+ end
4974
+
4975
+ alias to_summary to_s
4190
4976
  end
4191
4977
 
4192
4978
  # Category: Connectivity
@@ -4203,6 +4989,11 @@ class SignalOnOffConstraint < Constraint
4203
4989
 
4204
4990
  end
4205
4991
 
4992
+ def to_s(colour: false)
4993
+ 'SignalOnOffConstraint ' + @h.inspect
4994
+ end
4995
+
4996
+ alias to_summary to_s
4206
4997
  end
4207
4998
 
4208
4999
  # Category: Connectivity
@@ -4220,6 +5011,11 @@ class WifiConstraint < Constraint
4220
5011
 
4221
5012
  end
4222
5013
 
5014
+ def to_s(colour: false)
5015
+ 'WifiConstraint ' + @h.inspect
5016
+ end
5017
+
5018
+ alias to_summary to_s
4223
5019
  end
4224
5020
 
4225
5021
  # Category: Connectivity
@@ -4238,6 +5034,11 @@ class CellTowerConstraint < Constraint
4238
5034
 
4239
5035
  end
4240
5036
 
5037
+ def to_s(colour: false)
5038
+ 'CellTowerConstraint ' + @h.inspect
5039
+ end
5040
+
5041
+ alias to_summary to_s
4241
5042
  end
4242
5043
 
4243
5044
  # Category: Connectivity
@@ -4254,6 +5055,11 @@ class IsRoamingConstraint < Constraint
4254
5055
 
4255
5056
  end
4256
5057
 
5058
+ def to_s(colour: false)
5059
+ 'IsRoamingConstraint ' + @h.inspect
5060
+ end
5061
+
5062
+ alias to_summary to_s
4257
5063
  end
4258
5064
 
4259
5065
  # Category: Connectivity
@@ -4270,6 +5076,11 @@ class DataOnOffConstraint < Constraint
4270
5076
 
4271
5077
  end
4272
5078
 
5079
+ def to_s(colour: false)
5080
+ 'DataOnOffConstraint ' + @h.inspect
5081
+ end
5082
+
5083
+ alias to_summary to_s
4273
5084
  end
4274
5085
 
4275
5086
  # Category: Connectivity
@@ -4289,6 +5100,11 @@ class WifiHotSpotConstraint < Constraint
4289
5100
 
4290
5101
  end
4291
5102
 
5103
+ def to_s(colour: false)
5104
+ 'WifiHotSpotConstraint ' + @h.inspect
5105
+ end
5106
+
5107
+ alias to_summary to_s
4292
5108
  end
4293
5109
 
4294
5110
  # Category: Date/Time
@@ -4312,6 +5128,11 @@ class CalendarConstraint < Constraint
4312
5128
 
4313
5129
  end
4314
5130
 
5131
+ def to_s(colour: false)
5132
+ 'CalendarConstraint ' + @h.inspect
5133
+ end
5134
+
5135
+ alias to_summary to_s
4315
5136
  end
4316
5137
 
4317
5138
  # Category: Date/Time
@@ -4328,6 +5149,11 @@ class DayOfWeekConstraint < Constraint
4328
5149
 
4329
5150
  end
4330
5151
 
5152
+ def to_s(colour: false)
5153
+ 'DayOfWeekConstraint ' + @h.inspect
5154
+ end
5155
+
5156
+ alias to_summary to_s
4331
5157
  end
4332
5158
 
4333
5159
  # Category: Date/Time
@@ -4337,16 +5163,22 @@ class TimeOfDayConstraint < Constraint
4337
5163
  def initialize(h={})
4338
5164
 
4339
5165
  options = {
4340
- end_hour: 1,
4341
- end_minute: 1,
4342
- start_hour: 21,
4343
- start_minute: 58
5166
+ end_hour: 8,
5167
+ end_minute: 0,
5168
+ start_hour: 22,
5169
+ start_minute: 0
4344
5170
  }
4345
5171
 
4346
5172
  super(options.merge h)
4347
5173
 
4348
5174
  end
4349
-
5175
+
5176
+ def to_s(colour: false)
5177
+ a = @h[:start_hour], @h[:start_minute], @h[:end_hour], @h[:start_minute]
5178
+ 'Time of Day ' + "%02d:%02d - %02d:%02d" % a
5179
+ end
5180
+
5181
+ alias to_summary to_s
4350
5182
  end
4351
5183
 
4352
5184
  # Category: Date/Time
@@ -4364,6 +5196,11 @@ class DayOfMonthConstraint < Constraint
4364
5196
 
4365
5197
  end
4366
5198
 
5199
+ def to_s(colour: false)
5200
+ 'DayOfMonthConstraint ' + @h.inspect
5201
+ end
5202
+
5203
+ alias to_summary to_s
4367
5204
  end
4368
5205
 
4369
5206
  # Category: Date/Time
@@ -4380,6 +5217,11 @@ class MonthOfYearConstraint < Constraint
4380
5217
 
4381
5218
  end
4382
5219
 
5220
+ def to_s(colour: false)
5221
+ 'MonthOfYearConstraint ' + @h.inspect
5222
+ end
5223
+
5224
+ alias to_summary to_s
4383
5225
  end
4384
5226
 
4385
5227
  # Category: Date/Time
@@ -4396,6 +5238,11 @@ class SunsetSunriseConstraint < Constraint
4396
5238
 
4397
5239
  end
4398
5240
 
5241
+ def to_s(colour: false)
5242
+ 'SunsetSunriseConstraint ' + @h.inspect
5243
+ end
5244
+
5245
+ alias to_summary to_s
4399
5246
  end
4400
5247
 
4401
5248
  # Category: Device State
@@ -4440,12 +5287,14 @@ class AirplaneModeConstraint < Constraint
4440
5287
  'airplane_mode.' + status
4441
5288
  end
4442
5289
 
4443
- def to_s()
5290
+ def to_s(colour: false)
4444
5291
 
4445
5292
  status = @h[:enabled] ? 'Enabled' : 'Disabled'
4446
5293
  'Airplane Mode ' + status
4447
5294
 
4448
5295
  end
5296
+
5297
+ alias to_summary to_s
4449
5298
 
4450
5299
  end
4451
5300
 
@@ -4463,6 +5312,11 @@ class AutoRotateConstraint < Constraint
4463
5312
 
4464
5313
  end
4465
5314
 
5315
+ def to_s(colour: false)
5316
+ 'AutoRotateConstraint ' + @h.inspect
5317
+ end
5318
+
5319
+ alias to_summary to_s
4466
5320
  end
4467
5321
 
4468
5322
  # Category: Device State
@@ -4479,9 +5333,11 @@ class DeviceLockedConstraint < Constraint
4479
5333
 
4480
5334
  end
4481
5335
 
4482
- def to_s()
5336
+ def to_s(colour: false)
4483
5337
  'Device ' + (@h[:locked] ? 'Locked' : 'Unlocked')
4484
5338
  end
5339
+
5340
+ alias to_summary to_s
4485
5341
 
4486
5342
  end
4487
5343
 
@@ -4499,6 +5355,11 @@ class RoamingOnOffConstraint < Constraint
4499
5355
 
4500
5356
  end
4501
5357
 
5358
+ def to_s(colour: false)
5359
+ 'RoamingOnOffConstraint ' + @h.inspect
5360
+ end
5361
+
5362
+ alias to_summary to_s
4502
5363
  end
4503
5364
 
4504
5365
  # Category: Device State
@@ -4516,6 +5377,11 @@ class TimeSinceBootConstraint < Constraint
4516
5377
 
4517
5378
  end
4518
5379
 
5380
+ def to_s(colour: false)
5381
+ 'TimeSinceBootConstraint ' + @h.inspect
5382
+ end
5383
+
5384
+ alias to_summary to_s
4519
5385
  end
4520
5386
 
4521
5387
  # Category: Device State
@@ -4532,6 +5398,11 @@ class AutoSyncConstraint < Constraint
4532
5398
 
4533
5399
  end
4534
5400
 
5401
+ def to_s(colour: false)
5402
+ 'AutoSyncConstraint ' + @h.inspect
5403
+ end
5404
+
5405
+ alias to_summary to_s
4535
5406
  end
4536
5407
 
4537
5408
  # Category: Device State
@@ -4548,6 +5419,11 @@ class NFCStateConstraint < Constraint
4548
5419
 
4549
5420
  end
4550
5421
 
5422
+ def to_s(colour: false)
5423
+ 'NFCStateConstraint ' + @h.inspect
5424
+ end
5425
+
5426
+ alias to_summary to_s
4551
5427
  end
4552
5428
 
4553
5429
  # Category: Device State
@@ -4564,6 +5440,11 @@ class IsRootedConstraint < Constraint
4564
5440
 
4565
5441
  end
4566
5442
 
5443
+ def to_s(colour: false)
5444
+ 'IsRootedConstraint ' + @h.inspect
5445
+ end
5446
+
5447
+ alias to_summary to_s
4567
5448
  end
4568
5449
 
4569
5450
  # Category: Device State
@@ -4580,6 +5461,11 @@ class VpnConstraint < Constraint
4580
5461
 
4581
5462
  end
4582
5463
 
5464
+ def to_s(colour: false)
5465
+ 'VpnConstraint ' + @h.inspect
5466
+ end
5467
+
5468
+ alias to_summary to_s
4583
5469
  end
4584
5470
 
4585
5471
  # Category: MacroDroid Specific
@@ -4598,6 +5484,11 @@ class MacroEnabledConstraint < Constraint
4598
5484
 
4599
5485
  end
4600
5486
 
5487
+ def to_s(colour: false)
5488
+ 'MacroEnabledConstraint ' + @h.inspect
5489
+ end
5490
+
5491
+ alias to_summary to_s
4601
5492
  end
4602
5493
 
4603
5494
  # Category: MacroDroid Specific
@@ -4615,23 +5506,46 @@ class ModeConstraint < Constraint
4615
5506
 
4616
5507
  end
4617
5508
 
5509
+ def to_s(colour: false)
5510
+ 'ModeConstraint ' + @h.inspect
5511
+ end
5512
+
5513
+ alias to_summary to_s
4618
5514
  end
4619
5515
 
4620
5516
  # Category: MacroDroid Specific
4621
5517
  #
4622
5518
  class TriggerThatInvokedConstraint < Constraint
4623
-
5519
+ using ColouredText
5520
+
4624
5521
  def initialize(h={})
4625
5522
 
5523
+ puts ('h: ' + h.inspect).green
5524
+ @trigger = h[:macro].triggers.find {|x| x.siguid == h[:si_guid_that_invoked] }
5525
+
4626
5526
  options = {
4627
5527
  not: false,
4628
5528
  si_guid_that_invoked: -4951291100076165433,
4629
5529
  trigger_name: 'Shake Device'
4630
5530
  }
4631
5531
 
5532
+ #super(options.merge filter(options,h))
4632
5533
  super(options.merge h)
4633
5534
 
4634
5535
  end
5536
+
5537
+ def to_s(colour: false)
5538
+ 'Trigger Fired: ' + @trigger.to_s(colour: colour)
5539
+ end
5540
+
5541
+ def to_summary(colour: false)
5542
+ #puts '@trigger' + @trigger.inspect
5543
+ if @trigger then
5544
+ 'Trigger Fired: ' + @trigger.to_summary(colour: colour)
5545
+ else
5546
+ 'Trigger Fired: Trigger not found; guid: ' + @h[:si_guid_that_invoked].inspect
5547
+ end
5548
+ end
4635
5549
 
4636
5550
  end
4637
5551
 
@@ -4653,6 +5567,11 @@ class LastRunTimeConstraint < Constraint
4653
5567
 
4654
5568
  end
4655
5569
 
5570
+ def to_s(colour: false)
5571
+ 'LastRunTimeConstraint ' + @h.inspect
5572
+ end
5573
+
5574
+ alias to_summary to_s
4656
5575
  end
4657
5576
 
4658
5577
  # Category: Media
@@ -4669,10 +5588,12 @@ class HeadphonesConnectionConstraint < Constraint
4669
5588
 
4670
5589
  end
4671
5590
 
4672
- def to_s()
5591
+ def to_s(colour: false)
4673
5592
  connection = @h[:connected] ? 'Connected' : 'Disconnected'
4674
5593
  'Headphones ' + connection
4675
5594
  end
5595
+
5596
+ alias to_summary to_s
4676
5597
 
4677
5598
  end
4678
5599
 
@@ -4690,6 +5611,11 @@ class MusicActiveConstraint < Constraint
4690
5611
 
4691
5612
  end
4692
5613
 
5614
+ def to_s(colour: false)
5615
+ 'MusicActiveConstraint ' + @h.inspect
5616
+ end
5617
+
5618
+ alias to_summary to_s
4693
5619
  end
4694
5620
 
4695
5621
  # Category: Notification
@@ -4713,6 +5639,11 @@ class NotificationPresentConstraint < Constraint
4713
5639
 
4714
5640
  end
4715
5641
 
5642
+ def to_s(colour: false)
5643
+ 'NotificationPresentConstraint ' + @h.inspect
5644
+ end
5645
+
5646
+ alias to_summary to_s
4716
5647
  end
4717
5648
 
4718
5649
  # Category: Notification
@@ -4730,6 +5661,11 @@ class PriorityModeConstraint < Constraint
4730
5661
 
4731
5662
  end
4732
5663
 
5664
+ def to_s(colour: false)
5665
+ 'PriorityModeConstraint ' + @h.inspect
5666
+ end
5667
+
5668
+ alias to_summary to_s
4733
5669
  end
4734
5670
 
4735
5671
  # Category: Notification
@@ -4746,6 +5682,11 @@ class NotificationVolumeConstraint < Constraint
4746
5682
 
4747
5683
  end
4748
5684
 
5685
+ def to_s(colour: false)
5686
+ 'NotificationVolumeConstraint ' + @h.inspect
5687
+ end
5688
+
5689
+ alias to_summary to_s
4749
5690
  end
4750
5691
 
4751
5692
  # Category: Phone
@@ -4762,6 +5703,11 @@ class InCallConstraint < Constraint
4762
5703
 
4763
5704
  end
4764
5705
 
5706
+ def to_s(colour: false)
5707
+ 'InCallConstraint ' + @h.inspect
5708
+ end
5709
+
5710
+ alias to_summary to_s
4765
5711
  end
4766
5712
 
4767
5713
  # Category: Phone
@@ -4777,6 +5723,11 @@ class PhoneRingingConstraint < Constraint
4777
5723
  super(options.merge h)
4778
5724
 
4779
5725
  end
5726
+
5727
+ def to_s(colour: false)
5728
+ @s = @h[:ringing] ? 'Phone Ringing' : 'Not Ringing'
5729
+ super(colour: colour)
5730
+ end
4780
5731
 
4781
5732
  end
4782
5733
 
@@ -4798,6 +5749,11 @@ class BrightnessConstraint < Constraint
4798
5749
 
4799
5750
  end
4800
5751
 
5752
+ def to_s(colour: false)
5753
+ 'BrightnessConstraint ' + @h.inspect
5754
+ end
5755
+
5756
+ alias to_summary to_s
4801
5757
  end
4802
5758
 
4803
5759
  # Category: Screen and Speaker
@@ -4810,9 +5766,15 @@ class VolumeConstraint < Constraint
4810
5766
  option: 0
4811
5767
  }
4812
5768
 
4813
- super(options.merge h)
5769
+ super(options.merge filter(options, h))
4814
5770
 
4815
5771
  end
5772
+
5773
+ def to_s(colour: false)
5774
+ a = ['Volume On', 'Vibrate Only' 'Silent', 'Vibrate or Silent']
5775
+
5776
+ "Ringer Volume\n " + a[@h[:option]]
5777
+ end
4816
5778
 
4817
5779
  end
4818
5780
 
@@ -4830,6 +5792,11 @@ class SpeakerPhoneConstraint < Constraint
4830
5792
 
4831
5793
  end
4832
5794
 
5795
+ def to_s(colour: false)
5796
+ 'SpeakerPhoneConstraint ' + @h.inspect
5797
+ end
5798
+
5799
+ alias to_summary to_s
4833
5800
  end
4834
5801
 
4835
5802
  # Category: Screen and Speaker
@@ -4846,6 +5813,11 @@ class DarkThemeConstraint < Constraint
4846
5813
 
4847
5814
  end
4848
5815
 
5816
+ def to_s(colour: false)
5817
+ 'DarkThemeConstraint ' + @h.inspect
5818
+ end
5819
+
5820
+ alias to_summary to_s
4849
5821
  end
4850
5822
 
4851
5823
  # Category: Screen and Speaker
@@ -4863,9 +5835,11 @@ class ScreenOnOffConstraint < Constraint
4863
5835
 
4864
5836
  end
4865
5837
 
4866
- def to_s()
5838
+ def to_s(colour: false)
4867
5839
  'Screen ' + (@h[:screen_on] ? 'On' : 'Off')
4868
5840
  end
5841
+
5842
+ alias to_summary to_s
4869
5843
 
4870
5844
  end
4871
5845
 
@@ -4885,6 +5859,11 @@ class VolumeLevelConstraint < Constraint
4885
5859
 
4886
5860
  end
4887
5861
 
5862
+ def to_s(colour: false)
5863
+ 'VolumeLevelConstraint ' + @h.inspect
5864
+ end
5865
+
5866
+ alias to_summary to_s
4888
5867
  end
4889
5868
 
4890
5869
  # Category: Sensors
@@ -4902,6 +5881,11 @@ class FaceUpDownConstraint < Constraint
4902
5881
 
4903
5882
  end
4904
5883
 
5884
+ def to_s(colour: false)
5885
+ 'FaceUpDownConstraint ' + @h.inspect
5886
+ end
5887
+
5888
+ alias to_summary to_s
4905
5889
  end
4906
5890
 
4907
5891
  # Category: Sensors
@@ -4920,7 +5904,7 @@ class LightLevelConstraint < Constraint
4920
5904
 
4921
5905
  end
4922
5906
 
4923
- def to_s()
5907
+ def to_s(colour: false)
4924
5908
 
4925
5909
  operator = @h[:light_level] == -1 ? 'Less than' : 'Greater than'
4926
5910
  condition = operator + ' ' + @h[:light_level_float].to_s + 'lx'
@@ -4944,6 +5928,11 @@ class DeviceOrientationConstraint < Constraint
4944
5928
 
4945
5929
  end
4946
5930
 
5931
+ def to_s(colour: false)
5932
+ 'DeviceOrientationConstraint ' + @h.inspect
5933
+ end
5934
+
5935
+ alias to_summary to_s
4947
5936
  end
4948
5937
 
4949
5938
  # Category: Sensors
@@ -4960,8 +5949,135 @@ class ProximitySensorConstraint < Constraint
4960
5949
 
4961
5950
  end
4962
5951
 
4963
- def to_s()
5952
+ def to_s(colour: false)
4964
5953
  'Proximity Sensor: ' + (@h[:near] ? 'Near' : 'Far')
4965
5954
  end
4966
5955
 
4967
5956
  end
5957
+
5958
+
5959
+ # ----------------------------------------------------------------------------
5960
+
5961
+
5962
+ class DroidSim
5963
+
5964
+ class Service
5965
+ def initialize(callback)
5966
+ @callback = callback
5967
+ end
5968
+ end
5969
+
5970
+ class Application < Service
5971
+
5972
+ def closed()
5973
+ end
5974
+ def launched()
5975
+ end
5976
+ end
5977
+
5978
+ class Battery < Service
5979
+
5980
+ def level()
5981
+ end
5982
+
5983
+ def temperature()
5984
+ end
5985
+
5986
+ end
5987
+ class Bluetooth < Service
5988
+
5989
+ def enable()
5990
+ @callback.on_bluetooth_enabled()
5991
+ end
5992
+
5993
+ #def enabled
5994
+ # @callback.on_bluetooth_enabled()
5995
+ #end
5996
+
5997
+ def enabled?
5998
+ end
5999
+
6000
+ def disabled
6001
+ end
6002
+
6003
+ def disabled?
6004
+ end
6005
+ end
6006
+
6007
+ class Calendar < Service
6008
+ def event(starts, ends)
6009
+ end
6010
+ end
6011
+
6012
+ class DayTime < Service
6013
+
6014
+ def initialie(s)
6015
+ end
6016
+ end
6017
+
6018
+ class Headphones < Service
6019
+ def inserted
6020
+ end
6021
+
6022
+ def removed
6023
+ end
6024
+ end
6025
+
6026
+ class Webhook < Service
6027
+
6028
+ def url()
6029
+ @url
6030
+ end
6031
+
6032
+ def url=(s)
6033
+ @url = s
6034
+ end
6035
+ end
6036
+
6037
+ class Wifi < Service
6038
+ def enabled
6039
+ end
6040
+
6041
+ def disabled
6042
+ end
6043
+
6044
+ def ssid_in_range()
6045
+ end
6046
+
6047
+ def ssid_out_of_range()
6048
+ end
6049
+ end
6050
+
6051
+ class Power < Service
6052
+ def connected()
6053
+ end
6054
+
6055
+ def disconnected()
6056
+ end
6057
+
6058
+ def button_toggle()
6059
+ end
6060
+ end
6061
+
6062
+ class Popup < Service
6063
+ def message(s)
6064
+ puts s
6065
+ end
6066
+ end
6067
+
6068
+
6069
+ attr_reader :bluetooth, :popup
6070
+
6071
+ def initialize()
6072
+
6073
+ @bluetooth = Bluetooth.new self
6074
+ @popup = Popup.new self
6075
+
6076
+ end
6077
+
6078
+ def on_bluetooth_enabled()
6079
+
6080
+ end
6081
+
6082
+
6083
+ end