ruby-macrodroid 0.7.10 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3e6d2bb5ccf9f1caf0c56ba60c4791801dccc28a2be22bfbfc524db01dd553f5
4
- data.tar.gz: 4d79491e900a308fcc3473ed6d7b96cdf6169e20c7c0c754c08c806cb52c6d34
3
+ metadata.gz: e3e810bea9dc68b5b0bb2623b46a08544ed42db8112f0b2be703bbac6dce6178
4
+ data.tar.gz: d41bbc4bae9e9c5e7f65684db06c54bb0d058aee56b69f8c58a7dff99724725d
5
5
  SHA512:
6
- metadata.gz: c671f4e0473e435f7c5c9f760627464b8bf760367485877d43680225f399c6e7a83d2ac95be8ac4960ce8451d301abe7044e70570f1a7344a3a2bcd7ab529746
7
- data.tar.gz: 5cbfd7fee603949c495e4af3b315ffb45af15e8810c9ed226305627e47472df6a29c92ce2fed2f824d07d5dbb4b28372fcb420d97b4ea673f8c9a8458dc4ad21
6
+ metadata.gz: 5de76ced91b66dae5ce7fba414c4ea09dff2ffbf9c3cd04009c6a270570825605035413fc5b6d3cc115f79816b98d1484bfcb85688f5853e44af5d69fc872539
7
+ data.tar.gz: 9fe273f88915114ec327913317000548e2fe12a3cac2548a237e13dc7fb8115eb135d329bf1375278414e4b21522faf2de066a5b924ed6152fe63b6a7c7a1103
@@ -1,3 +1,2 @@
1
- �hu�o�_GM��~xH+T���Z}�"
2
- ���|
3
- �Gg��C�A��p*�~��� �f���J��Ë$�^/�C&��4�$���
1
+ t_�
2
+ K��/�%f�8���Ɛ03R�y�}=n�K��+`�#J�Rs'��<���#S�]k� �W$Rگ�WI�q{*�=w�#>�$�0��eل�tYe`����6��O�։/.�X��-0(Y��Yç�\\��6�&�0�����@�B������6�$k�)����}���@h���2���IN�V#3��ۋٶ��,f\K�4#Q`��7X���g|s;�D���2$����ɭ[K;��1f�X��DB߇jPP��J�GA���#K�3�Ӻօ&��JSzL�IZ��� kK&��sh+��(��9��Hdi"��(�"��M�6g�r��MC�1r_[&J�K�����FN�|�L�hطG>_��߉9�cJ�� �
data.tar.gz.sig CHANGED
Binary file
@@ -29,82 +29,6 @@
29
29
  # GeofenceMap
30
30
  #
31
31
  #
32
- # ## Object class
33
- #
34
- # MacroObject
35
- #
36
- #
37
- # ## Trigger classes
38
- #
39
- # Trigger WebHookTrigger WifiConnectionTrigger
40
- # ApplicationInstalledRemovedTrigger ApplicationLaunchedTrigger
41
- # BatteryLevelTrigger BatteryTemperatureTrigger PowerButtonToggleTrigger
42
- # ExternalPowerTrigger CallActiveTrigger IncomingCallTrigger
43
- # OutgoingCallTrigger CallEndedTrigger CallMissedTrigger IncomingSMSTrigger
44
- # WebHookTrigger WifiConnectionTrigger BluetoothTrigger HeadphonesTrigger
45
- # SignalOnOffTrigger UsbDeviceConnectionTrigger WifiSSIDTrigger
46
- # CalendarTrigger TimerTrigger StopwatchTrigger DayTrigger
47
- # RegularIntervalTrigger DeviceEventsTrigger AirplaneModeTrigger
48
- # AutoSyncChangeTrigger DayDreamTrigger DockTrigger FailedLoginTrigger
49
- # GPSEnabledTrigger MusicPlayingTrigger DeviceUnlockedTrigger
50
- # AutoRotateChangeTrigger ClipboardChangeTrigger BootTrigger
51
- # IntentReceivedTrigger NotificationTrigger ScreenOnOffTrigger
52
- # SilentModeTrigger WeatherTrigger GeofenceTrigger SunriseSunsetTrigger
53
- # SensorsTrigger ActivityRecognitionTrigger ProximityTrigger
54
- # ShakeDeviceTrigger FlipDeviceTrigger OrientationTrigger
55
- # FloatingButtonTrigger ShortcutTrigger VolumeButtonTrigger
56
- # MediaButtonPressedTrigger SwipeTrigger
57
- #
58
- #
59
- # ## Action classes
60
- #
61
- # Action LocationAction ShareLocationAction ApplicationAction
62
- # LaunchActivityAction KillBackgroundAppAction OpenWebPageAction CameraAction
63
- # UploadPhotoAction TakePictureAction ConnectivityAction SetWifiAction
64
- # SetBluetoothAction SetBluetoothAction SendIntentAction DateTimeAction
65
- # SetAlarmClockAction StopWatchAction SayTimeAction DeviceAction
66
- # AndroidShortcutsAction ClipboardAction PressBackAction SpeakTextAction
67
- # UIInteractionAction VoiceSearchAction DeviceSettingsAction
68
- # ExpandCollapseStatusBarAction LaunchHomeScreenAction CameraFlashLightAction
69
- # VibrateAction SetAutoRotateAction DayDreamAction SetKeyboardAction
70
- # SetKeyguardAction CarModeAction ChangeKeyboardAction SetWallpaperAction
71
- # FileAction OpenFileAction LocationAction ForceLocationUpdateAction
72
- # ShareLocationAction SetLocationUpdateRateAction LoggingAction
73
- # AddCalendarEntryAction LogAction ClearLogAction MediaAction
74
- # RecordMicrophoneAction PlaySoundAction MessagingAction SendEmailAction
75
- # SendSMSAction UDPCommandAction NotificationsAction ClearNotificationsAction
76
- # MessageDialogAction AllowLEDNotificationLightAction
77
- # SetNotificationSoundAction SetNotificationSoundAction
78
- # SetNotificationSoundAction NotificationAction ToastAction PhoneAction
79
- # AnswerCallAction ClearCallLogAction OpenCallLogAction RejectCallAction
80
- # MakeCallAction SetRingtoneAction ScreenAction SetBrightnessAction
81
- # ForceScreenRotationAction ScreenOnAction DimScreenAction KeepAwakeAction
82
- # SetScreenTimeoutAction VolumeAction SilentModeVibrateOffAction
83
- # SetVibrateAction VolumeIncrementDecrementAction SpeakerPhoneAction
84
- # SetVolumeAction
85
- #
86
- #
87
- # ## Constraint classes
88
- #
89
- # Constraint TimeOfDayConstraint BatteryLevelConstraint
90
- # BatterySaverStateConstraint BatteryTemperatureConstraint
91
- # ExternalPowerConstraint BluetoothConstraint GPSEnabledConstraint
92
- # LocationModeConstraint SignalOnOffConstraint WifiConstraint
93
- # CellTowerConstraint IsRoamingConstraint DataOnOffConstraint
94
- # WifiHotSpotConstraint CalendarConstraint DayOfWeekConstraint
95
- # TimeOfDayConstraint DayOfMonthConstraint MonthOfYearConstraint
96
- # SunsetSunriseConstraint AirplaneModeConstraint AutoRotateConstraint
97
- # DeviceLockedConstraint RoamingOnOffConstraint TimeSinceBootConstraint
98
- # AutoSyncConstraint NFCStateConstraint IsRootedConstraint VpnConstraint
99
- # MacroEnabledConstraint ModeConstraint TriggerThatInvokedConstraint
100
- # LastRunTimeConstraint HeadphonesConnectionConstraint MusicActiveConstraint
101
- # NotificationPresentConstraint PriorityModeConstraint
102
- # NotificationVolumeConstraint InCallConstraint PhoneRingingConstraint
103
- # BrightnessConstraint VolumeConstraint SpeakerPhoneConstraint
104
- # DarkThemeConstraint ScreenOnOffConstraint VolumeLevelConstraint
105
- # FaceUpDownConstraint LightLevelConstraint DeviceOrientationConstraint
106
- # ProximitySensorConstraint
107
-
108
32
 
109
33
 
110
34
  require 'yaml'
@@ -116,7 +40,10 @@ require 'geocoder'
116
40
  require 'subunit'
117
41
  require 'rxfhelper'
118
42
  require 'chronic_cron'
119
-
43
+ require 'ruby-macrodroid/base'
44
+ require 'ruby-macrodroid/triggers'
45
+ require 'ruby-macrodroid/actions'
46
+ require 'ruby-macrodroid/constraints'
120
47
 
121
48
  MODEL =<<EOF
122
49
  device
@@ -354,58 +281,7 @@ class ConstraintsNlp
354
281
 
355
282
  end
356
283
 
357
- module Params
358
-
359
- refine Hash do
360
-
361
- # turns keys from camelCase into snake_case
362
-
363
- def to_snake_case(h=self)
364
-
365
- h.inject({}) do |r, x|
366
-
367
- key, value = x
368
- #puts 'value: ' + value.inspect
369
-
370
- val = if value.is_a?(Hash) then
371
- to_snake_case(value)
372
- elsif value.is_a?(Array) and value.first.is_a? Hash
373
- value.map {|row| to_snake_case(row)}
374
- else
375
- value
376
- end
377
-
378
- r.merge key.to_s.sub(/^m_/,'').gsub(/[A-Z][a-z]/){|x| '_' +
379
- x.downcase}.gsub(/[a-z][A-Z]/){|x| x[0] + '_' + x[1].downcase}\
380
- .downcase.to_sym => val
381
-
382
- end
383
- end
384
-
385
- # turns keys from snake_case to CamelCase
386
- def to_camel_case(h=self)
387
-
388
- h.inject({}) do |r,x|
389
-
390
- key, value = x
391
-
392
- val = if value.is_a?(Hash) then
393
- to_camel_case(value)
394
- elsif value.is_a?(Array) and value.first.is_a? Hash
395
- value.map {|row| to_camel_case(row)}
396
- else
397
- value
398
- end
399
-
400
- r.merge({key.to_s.gsub(/(?<!^m)_[a-z]/){|x| x[-1].upcase} => val})
401
- end
402
-
403
- end
404
-
405
-
406
- end
407
284
 
408
- end
409
285
 
410
286
  class Macro
411
287
  using ColouredText
@@ -415,7 +291,7 @@ class Macro
415
291
  :guid, :deviceid
416
292
  attr_accessor :title, :description
417
293
 
418
- def initialize(name=nil, geofences: geofences, deviceid: nil, debug: false)
294
+ def initialize(name=nil, geofences: nil, deviceid: nil, debug: false)
419
295
 
420
296
  @title, @geofences, @deviceid, @debug = name, geofences, deviceid, debug
421
297
 
@@ -1153,4807 +1029,10 @@ class GeofenceMap
1153
1029
 
1154
1030
  end
1155
1031
 
1156
- class MacroObject
1157
- using ColouredText
1158
-
1159
- attr_reader :type, :siguid
1160
- attr_accessor :options
1161
-
1162
- def initialize(h={})
1163
-
1164
- $env ||= {}
1165
-
1166
- @attributes = %i(constraint_list is_or_condition is_disabled siguid)
1167
- @h = {constraint_list: [], is_or_condition: false,
1168
- is_disabled: false, siguid: nil}.merge(h)
1169
- @list = []
1170
-
1171
- # fetch the class name and convert from camelCase to snake_eyes
1172
- @type = self.class.to_s.sub(/Trigger|Action$/,'')\
1173
- .gsub(/\B[A-Z][a-z]/){|x| '_' + x.downcase}\
1174
- .gsub(/[a-z][A-Z]/){|x| x[0] + '_' + x[1].downcase}\
1175
- .downcase.to_sym
1176
- @constraints = []
1177
- end
1178
-
1179
- def to_h()
1180
-
1181
- h = @h
1182
-
1183
- h2 = h.inject({}) do |r,x|
1184
- puts 'x: ' + x.inspect if @debug
1185
- key, value = x
1186
- puts 'key: ' + key.inspect if @debug
1187
- new_key = key.to_s.gsub(/\w_\w/){|x| x[0] + x[-1].upcase}
1188
- new_key = new_key.prepend 'm_' unless @list.include? new_key
1189
- new_key = 'm_SIGUID' if new_key == 'm_siguid'
1190
- r.merge(new_key => value)
1191
- end
1192
-
1193
- h2.merge('m_classType' => self.class.to_s)
1194
-
1195
- end
1196
-
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
-
1212
- end
1213
-
1214
- alias to_summary to_s
1215
-
1216
- protected
1217
-
1218
- def filter(options, h)
1219
-
1220
- (h.keys - (options.keys + @attributes.to_a)).each {|key| h.delete key }
1221
- return h
1222
-
1223
- end
1224
-
1225
- def uuid()
1226
- UUID.new.generate
1227
- end
1228
-
1229
- def object(h={})
1230
-
1231
- puts ('inside object h:' + h.inspect).debug if @debug
1232
- klass = Object.const_get h[:class_type]
1233
- puts klass.inspect.highlight if $debug
1234
-
1235
- klass.new h
1236
-
1237
- end
1238
-
1239
- end
1240
-
1241
- class Trigger < MacroObject
1242
- using Params
1243
-
1244
- attr_reader :constraints
1245
-
1246
- def initialize(h={})
1247
- super({fakeIcon: 0}.merge(h))
1248
- @list << 'fakeIcon'
1249
-
1250
- # fetch the constraints
1251
- @constraints = @h[:constraint_list].map do |constraint|
1252
- object(constraint.to_snake_case)
1253
- end
1254
-
1255
- end
1256
-
1257
- def match?(detail={}, model=nil)
1258
-
1259
- # only match where the key exists in the trigger object
1260
- detail.select {|k,v| @h.include? k }.all? {|key,value| @h[key] == value}
1261
-
1262
- end
1263
-
1264
- end
1265
-
1266
-
1267
-
1268
-
1269
- # Category: Applications
1270
- #
1271
- # Also known as Wifi State Change
1272
- #
1273
- # wifi_state options:
1274
- # 0 - Wifi Enabled
1275
- # 1 - Wifi Disabled
1276
- # 2 - Connected to network
1277
- # ssid_list options:
1278
- # ["Any Network"]
1279
- # ["some Wifi SSID"] - 1 or more SSID can be supplied
1280
- # 3 - Disconnected from network
1281
- # ssid_list options:
1282
- # ["Any Network"]
1283
- # ["some Wifi SSID"] - 1 or more SSID can be supplied
1284
-
1285
- class WifiConnectionTrigger < Trigger
1286
-
1287
- def initialize(h={})
1288
-
1289
- options = {
1290
- ssid_list: [""],
1291
- wifi_state: 2
1292
- }
1293
-
1294
- super(options.merge h)
1295
-
1296
- end
1297
-
1298
- def to_s(colour: false)
1299
- 'WifiConnectionTrigger ' + @h.inspect
1300
- end
1301
-
1302
- alias to_summary to_s
1303
- end
1304
-
1305
- # Category: Applications
1306
- #
1307
- class ApplicationInstalledRemovedTrigger < Trigger
1308
-
1309
- def initialize(h={})
1310
-
1311
- options = {
1312
- application_name_list: [],
1313
- package_name_list: [],
1314
- installed: true,
1315
- application_option: 0,
1316
- updated: false
1317
- }
1318
-
1319
- super(options.merge h)
1320
-
1321
- end
1322
-
1323
- def to_s(colour: false)
1324
- 'ApplicationInstalledRemovedTrigger ' + @h.inspect
1325
- end
1326
-
1327
- alias to_summary to_s
1328
- end
1329
-
1330
- # Category: Applications
1331
- #
1332
- class ApplicationLaunchedTrigger < Trigger
1333
-
1334
- def initialize(h={})
1335
-
1336
- options = {
1337
- application_name_list: ["Chrome"],
1338
- package_name_list: ["com.android.chrome"],
1339
- launched: true
1340
- }
1341
-
1342
- super(options.merge h)
1343
-
1344
- end
1345
-
1346
- def to_s(colour: false)
1347
- 'ApplicationLaunchedTrigger ' + @h.inspect
1348
- end
1349
-
1350
- alias to_summary to_s
1351
- end
1352
-
1353
- # Category: Battery/Power
1354
- #
1355
- class BatteryLevelTrigger < Trigger
1356
-
1357
- def initialize(h={})
1358
-
1359
- options = {
1360
- battery_level: 50,
1361
- decreases_to: true,
1362
- option: 0
1363
- }
1364
-
1365
- super(options.merge h)
1366
-
1367
- end
1368
-
1369
- def to_s(colour: false)
1370
- operator = @h[:decreases_to] ? '<=' : '>='
1371
- "Battery %s %s%%" % [operator, @h[:battery_level]]
1372
- end
1373
-
1374
- end
1375
-
1376
- # Category: Battery/Power
1377
- #
1378
- class BatteryTemperatureTrigger < Trigger
1379
-
1380
- def initialize(h={})
1381
-
1382
- options = {
1383
- decreases_to: true,
1384
- option: 0,
1385
- temperature: 30
1386
- }
1387
-
1388
- super(options.merge h)
1389
-
1390
- end
1391
-
1392
- def to_s(colour: false)
1393
- 'BatteryTemperatureTrigger ' + @h.inspect
1394
- end
1395
-
1396
- alias to_summary to_s
1397
- end
1398
-
1399
- # Category: Battery/Power
1400
- #
1401
- class PowerButtonToggleTrigger < Trigger
1402
-
1403
- def initialize(h={})
1404
-
1405
- options = {
1406
- num_toggles: 3
1407
- }
1408
-
1409
- super(options.merge h)
1410
-
1411
- end
1412
-
1413
- def to_s(colour: false)
1414
- 'PowerButtonToggleTrigger ' + @h.inspect
1415
- end
1416
-
1417
- alias to_summary to_s
1418
- end
1419
-
1420
-
1421
- # Category: Battery/Power
1422
- #
1423
- class ExternalPowerTrigger < Trigger
1424
-
1425
- def initialize(h={})
1426
-
1427
- options = {
1428
- power_connected_options: [true, true, true],
1429
- has_set_usb_option: true,
1430
- power_connected: true,
1431
- has_set_new_power_connected_options: true
1432
- }
1433
-
1434
- super(options.merge h)
1435
-
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
1458
-
1459
- end
1460
-
1461
- # Category: Call/SMS
1462
- #
1463
- class CallActiveTrigger < Trigger
1464
-
1465
- def initialize(h={})
1466
-
1467
- options = {
1468
- contact_list: [{:m_id=>"-2", :m_lookupKey=>"-2", :m_name=>"[Any Number]"}],
1469
- secondary_class_type: 'CallActiveTrigger',
1470
- signal_on: true
1471
- }
1472
-
1473
- super(options.merge h)
1474
-
1475
- end
1476
-
1477
- def to_s(colour: false)
1478
- 'CallActiveTrigger ' + @h.inspect
1479
- end
1480
-
1481
- alias to_summary to_s
1482
- end
1483
-
1484
- # Category: Call/SMS
1485
- #
1486
- class IncomingCallTrigger < Trigger
1487
-
1488
- def initialize(h={})
1489
-
1490
- options = {
1491
- incoming_call_from_list: [{:m_id=>"-2", :m_lookupKey=>"-2", :m_name=>"[Any Number]"}],
1492
- group_id_list: [],
1493
- group_name_list: [],
1494
- option: 0,
1495
- phone_number_exclude: false
1496
- }
1497
-
1498
- super(options.merge h)
1499
-
1500
- end
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
1508
- end
1509
-
1510
- # Category: Call/SMS
1511
- #
1512
- class OutgoingCallTrigger < Trigger
1513
-
1514
- def initialize(h={})
1515
-
1516
- options = {
1517
- outgoing_call_to_list: [{:m_id=>"-2", :m_lookupKey=>"-2", :m_name=>"[Any Number]"}],
1518
- group_id_list: [],
1519
- group_name_list: [],
1520
- option: 0,
1521
- phone_number_exclude: false
1522
- }
1523
-
1524
- super(options.merge h)
1525
-
1526
- end
1527
-
1528
- def to_s(colour: false)
1529
- 'OutgoingCallTrigger ' + @h.inspect
1530
- end
1531
-
1532
- alias to_summary to_s
1533
- end
1534
-
1535
- # Category: Call/SMS
1536
- #
1537
- class CallEndedTrigger < Trigger
1538
-
1539
- def initialize(h={})
1540
-
1541
- options = {
1542
- contact_list: [{:m_id=>"-2", :m_lookupKey=>"-2", :m_name=>"[Any Number]"}],
1543
- group_id_list: [],
1544
- group_name_list: [],
1545
- option: 0,
1546
- phone_number_exclude: false
1547
- }
1548
1032
 
1549
- super(options.merge h)
1550
1033
 
1551
- end
1552
1034
 
1553
- def to_s(colour: false)
1554
- 'CallEndedTrigger ' + @h.inspect
1555
- end
1556
1035
 
1557
- alias to_summary to_s
1558
- end
1559
-
1560
- # Category: Call/SMS
1561
- #
1562
- class CallMissedTrigger < Trigger
1563
-
1564
- def initialize(h={})
1565
-
1566
- options = {
1567
- contact_list: [{:m_id=>"-2", :m_lookupKey=>"-2", :m_name=>"[Any Number]"}]
1568
- }
1569
-
1570
- super(options.merge h)
1571
-
1572
- end
1573
-
1574
- def to_s(colour: false)
1575
- 'CallMissedTrigger ' + @h.inspect
1576
- end
1577
-
1578
- alias to_summary to_s
1579
- end
1580
-
1581
- # Category: Call/SMS
1582
- #
1583
- class IncomingSMSTrigger < Trigger
1584
-
1585
- def initialize(h={})
1586
-
1587
- options = {
1588
- sms_from_list: [{:m_id=>"-2", :m_lookupKey=>"-2", :m_name=>"[Any Number]"}],
1589
- group_id_list: [],
1590
- group_name_list: [],
1591
- sms_content: '',
1592
- option: 0,
1593
- excludes: false,
1594
- exact_match: false,
1595
- enable_regex: false,
1596
- sms_number_exclude: false
1597
- }
1598
-
1599
- super(options.merge h)
1600
-
1601
- end
1602
-
1603
- def to_s(colour: false)
1604
- 'IncomingSMSTrigger ' + @h.inspect
1605
- end
1606
-
1607
- alias to_summary to_s
1608
- end
1609
-
1610
- # Category: Connectivity
1611
- #
1612
- class WebHookTrigger < Trigger
1613
-
1614
- def initialize(h={})
1615
-
1616
- options = {
1617
- identifier: ''
1618
- }
1619
-
1620
- super(options.merge h)
1621
-
1622
- end
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
1634
- end
1635
-
1636
- # Category: Connectivity
1637
- #
1638
- class WifiConnectionTrigger < Trigger
1639
-
1640
- def initialize(h={})
1641
-
1642
- options = {
1643
- ssid_list: [],
1644
- wifi_state: 0
1645
- }
1646
-
1647
- super(options.merge h)
1648
-
1649
- end
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
1657
- end
1658
-
1659
- # Category: Connectivity
1660
- #
1661
- class BluetoothTrigger < Trigger
1662
-
1663
- def initialize(h={})
1664
-
1665
- options = {
1666
- device_name: 'Any Device',
1667
- bt_state: 0,
1668
- any_device: false
1669
- }
1670
-
1671
- super(options.merge h)
1672
-
1673
- end
1674
-
1675
- def to_s(colour: false)
1676
- 'BluetoothTrigger ' + @h.inspect
1677
- end
1678
-
1679
- alias to_summary to_s
1680
- end
1681
-
1682
- # Category: Connectivity
1683
- #
1684
- class HeadphonesTrigger < Trigger
1685
-
1686
- def initialize(h={})
1687
-
1688
- options = {
1689
- headphones_connected: true,
1690
- mic_option: 0
1691
- }
1692
-
1693
- super(options.merge h)
1694
-
1695
- end
1696
-
1697
- def to_s(colour: false)
1698
- 'HeadphonesTrigger ' + @h.inspect
1699
- end
1700
-
1701
- alias to_summary to_s
1702
- end
1703
-
1704
- # Category: Connectivity
1705
- #
1706
- class SignalOnOffTrigger < Trigger
1707
-
1708
- def initialize(h={})
1709
-
1710
- options = {
1711
- signal_on: true
1712
- }
1713
-
1714
- super(options.merge h)
1715
-
1716
- end
1717
-
1718
- def to_s(colour: false)
1719
- 'SignalOnOffTrigger ' + @h.inspect
1720
- end
1721
-
1722
- alias to_summary to_s
1723
- end
1724
-
1725
- # Category: Connectivity
1726
- #
1727
- class UsbDeviceConnectionTrigger < Trigger
1728
-
1729
- def initialize(h={})
1730
-
1731
- options = {
1732
- option: 0
1733
- }
1734
-
1735
- super(options.merge h)
1736
-
1737
- end
1738
-
1739
- def to_s(colour: false)
1740
- 'UsbDeviceConnectionTrigger ' + @h.inspect
1741
- end
1742
-
1743
- alias to_summary to_s
1744
- end
1745
-
1746
- # Category: Connectivity
1747
- #
1748
- # Also known as Wifi SSID Transition
1749
- #
1750
- # options:
1751
- # in_range: true | false
1752
- # wifi_cell_info: {display_name: "some Wifi SSID",
1753
- # ssid: "some Wifi SSID"} - 1 or more allowed
1754
- #
1755
- class WifiSSIDTrigger < Trigger
1756
-
1757
- def initialize(h={})
1758
-
1759
- options = {
1760
- wifi_cell_info_list: [{:display_name=>"", :ssid=>""}],
1761
- ssid_list: [],
1762
- in_range: true
1763
- }
1764
-
1765
- super(options.merge h)
1766
-
1767
- end
1768
-
1769
- def to_h()
1770
-
1771
- h = super()
1772
- val = h[:m_inRange]
1773
-
1774
- h[:m_InRange] = val
1775
- h.delete :m_inRange
1776
-
1777
- return h
1778
-
1779
- end
1780
-
1781
- def to_s(colour: false)
1782
- 'WifiSSIDTrigger ' + @h.inspect
1783
- end
1784
-
1785
- alias to_summary to_s
1786
- end
1787
-
1788
- # Category: Date/Time
1789
- #
1790
- class CalendarTrigger < Trigger
1791
-
1792
- def initialize(h={})
1793
-
1794
- options = {
1795
- title_text: '',
1796
- detail_text: '',
1797
- calendar_name: 'Contacts',
1798
- calendar_id: '3',
1799
- availability: 0,
1800
- check_in_advance: false,
1801
- advance_time_seconds: 0,
1802
- event_start: true,
1803
- ignore_all_day: false,
1804
- negative_advance_check: false,
1805
- enable_regex: false
1806
- }
1807
-
1808
- super(options.merge h)
1809
-
1810
- end
1811
-
1812
- def to_s(colour: false)
1813
- 'CalendarTrigger ' + @h.inspect
1814
- end
1815
-
1816
- alias to_summary to_s
1817
- end
1818
-
1819
- # Category: Date/Time
1820
- #
1821
- class TimerTrigger < Trigger
1822
- using ColouredText
1823
-
1824
-
1825
- def initialize(h={})
1826
-
1827
- puts 'TimerTrigger h: ' + h.inspect if $debug
1828
-
1829
- if h[:days] then
1830
-
1831
- days = [false] * 7
1832
-
1833
- h[:days].split(/, */).each do |x|
1834
-
1835
- r = Date::DAYNAMES.grep /#{x}/i
1836
- i = Date::DAYNAMES.index(r.first)
1837
- days[i-1] = true
1838
-
1839
- end
1840
-
1841
- h[:days_of_week] = days
1842
-
1843
- end
1844
-
1845
- if h[:time] then
1846
-
1847
- t = Time.parse(h[:time])
1848
- h[:hour], h[:minute] = t.hour, t.min
1849
-
1850
- end
1851
-
1852
- #puts ('h: ' + h.inspect).debug
1853
-
1854
- @options = {
1855
- alarm_id: uuid(),
1856
- days_of_week: [false, false, false, false, false, false, false],
1857
- minute: 10,
1858
- hour: 7,
1859
- use_alarm: false
1860
- }
1861
-
1862
- #super(options.merge filter(options, h))
1863
- super(@options.merge h)
1864
-
1865
- end
1866
-
1867
- def match?(detail={time: $env[:time]}, model=nil)
1868
-
1869
- time() == detail[:time]
1870
-
1871
- end
1872
-
1873
- # sets the environmental conditions for this trigger to fire
1874
- #
1875
- def set_env()
1876
- $env[:time] = time()
1877
- end
1878
-
1879
- def to_pc()
1880
- "time.is? '%s'" % self.to_s.gsub(',', ' or')
1881
- end
1882
-
1883
- def to_s(colour: false)
1884
-
1885
- dow = @h[:days_of_week]
1886
-
1887
- wd = Date::ABBR_DAYNAMES
1888
- a = (wd[1..-1] << wd.first)
1889
-
1890
- a2 = dow.map.with_index.to_a
1891
- start = a2.find {|x,i| x}.last
1892
- r = a2[start..-1].take_while {|x,i| x == true}
1893
- r2 = a2[start..-1].select {|x,i| x}
1894
-
1895
- days = if r == r2 then
1896
-
1897
- x1, x2 = a2[start].last, a2[r.length-1].last
1898
-
1899
- if (x2 - x1) >= 2 then
1900
- "%s-%s" % [a[x1],a[x2]]
1901
- else
1902
- a.zip(dow).select {|_,b| b}.map(&:first).join(', ')
1903
- end
1904
- else
1905
- a.zip(dow).select {|_,b| b}.map(&:first).join(', ')
1906
- end
1907
-
1908
- time = Time.parse("%s:%s" % [@h[:hour], @h[:minute]]).strftime("%H:%M")
1909
-
1910
- "%s %s" % [time, days]
1911
- end
1912
-
1913
- alias to_summary to_s
1914
-
1915
- private
1916
-
1917
- def time()
1918
-
1919
- a = @h[:days_of_week].clone
1920
- a.unshift a.pop
1921
-
1922
- dow = a.map.with_index {|x, i| x ? i : nil }.compact.join(',')
1923
- s = "%s %s * * %s" % [@h[:minute], @h[:hour], dow]
1924
- recent_time = ($env && $env[:time]) ? $env[:time] : Time.now
1925
- ChronicCron.new(s, recent_time).to_time
1926
-
1927
- end
1928
-
1929
- end
1930
-
1931
- # Category: Date/Time
1932
- #
1933
- class StopwatchTrigger < Trigger
1934
-
1935
- def initialize(h={})
1936
-
1937
- options = {
1938
- stopwatch_name: 'timer1',
1939
- seconds: 240
1940
- }
1941
-
1942
- super(options.merge h)
1943
-
1944
- end
1945
-
1946
- def to_s(colour: false)
1947
- 'StopwatchTrigger ' + @h.inspect
1948
- end
1949
-
1950
- alias to_summary to_s
1951
- end
1952
-
1953
- # Category: Date/Time
1954
- #
1955
- # Also known as Day of Week/Month
1956
- #
1957
- # month_of_year equal to 0 means it occurs every month
1958
- # day_of_week starts with a Monday (value is 0)
1959
- #
1960
- class DayTrigger < Trigger
1961
-
1962
- def initialize(h={})
1963
-
1964
- options = {
1965
- alarm_id: uuid(),
1966
- hour: 9,
1967
- minute: 0,
1968
- month_of_year: 0,
1969
- option: 0,
1970
- day_of_week: 2,
1971
- day_of_month: 0,
1972
- use_alarm: false
1973
- }
1974
-
1975
- super(options.merge h)
1976
-
1977
- end
1978
-
1979
- def to_s(colour: false)
1980
- 'DayTrigger ' + @h.inspect
1981
- end
1982
-
1983
- alias to_summary to_s
1984
- end
1985
-
1986
- # Category: Date/Time
1987
- #
1988
- # Regular Interval
1989
- #
1990
- class RegularIntervalTrigger < Trigger
1991
-
1992
- def initialize(h={})
1993
-
1994
- options = {
1995
- ignore_reference_start_time: false,
1996
- minutes: 0,
1997
- seconds: 7200,
1998
- start_hour: 9,
1999
- start_minute: 10,
2000
- use_alarm: false
2001
- }
2002
-
2003
- super(options.merge h)
2004
-
2005
- end
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
2016
- end
2017
-
2018
- class DeviceEventsTrigger < Trigger
2019
-
2020
- def initialize(h={})
2021
- super(h)
2022
- @group = 'device_events'
2023
- end
2024
-
2025
- end
2026
-
2027
- # Category: Device Events
2028
- #
2029
- # Airplane Mode Changed
2030
- #
2031
- # options:
2032
- # Airplane Mode Enabled
2033
- # Airplane Mode Disabled
2034
- #
2035
- # shorthand example:
2036
- # airplanemode: enabled
2037
- #
2038
- class AirplaneModeTrigger < DeviceEventsTrigger
2039
-
2040
- def initialize(h={})
2041
-
2042
- options = {
2043
- airplane_mode_enabled: true
2044
- }
2045
-
2046
- super(options.merge h)
2047
-
2048
- end
2049
-
2050
- def to_s(colour: false)
2051
- 'AirplaneModeTrigger ' + @h.inspect
2052
- end
2053
-
2054
- alias to_summary to_s
2055
- end
2056
-
2057
- # Category: Device Events
2058
- #
2059
- class AutoSyncChangeTrigger < DeviceEventsTrigger
2060
-
2061
- def initialize(h={})
2062
-
2063
- options = {
2064
- option: 0
2065
- }
2066
-
2067
- super(options.merge h)
2068
-
2069
- end
2070
-
2071
- def to_s(colour: false)
2072
- 'AutoSyncChangeTrigger ' + @h.inspect
2073
- end
2074
-
2075
- alias to_summary to_s
2076
- end
2077
-
2078
- # Category: Device Events
2079
- #
2080
- class DayDreamTrigger < DeviceEventsTrigger
2081
-
2082
- def initialize(h={})
2083
-
2084
- options = {
2085
- day_dream_enabled: true
2086
- }
2087
-
2088
- super(options.merge h)
2089
-
2090
- end
2091
-
2092
- def to_s(colour: false)
2093
- 'DayDreamTrigger ' + @h.inspect
2094
- end
2095
-
2096
- alias to_summary to_s
2097
- end
2098
-
2099
- # Category: Device Events
2100
- #
2101
- class DockTrigger < DeviceEventsTrigger
2102
-
2103
- def initialize(h={})
2104
-
2105
- options = {
2106
- dock_type: 0
2107
- }
2108
-
2109
- super(options.merge h)
2110
-
2111
- end
2112
-
2113
- def to_s(colour: false)
2114
- 'DockTrigger ' + @h.inspect
2115
- end
2116
-
2117
- alias to_summary to_s
2118
- end
2119
-
2120
- # Category: Device Events
2121
- #
2122
- class FailedLoginTrigger < DeviceEventsTrigger
2123
-
2124
- def initialize(h={})
2125
-
2126
- options = {
2127
- num_failures: 1
2128
- }
2129
-
2130
- super(options.merge h)
2131
-
2132
- end
2133
-
2134
- def to_pc()
2135
- 'failed_login?'
2136
- end
2137
-
2138
- def to_s(colour: false)
2139
- 'Failed Login Attempt'
2140
- end
2141
- end
2142
-
2143
- # Category: Device Events
2144
- #
2145
- class GPSEnabledTrigger < DeviceEventsTrigger
2146
-
2147
- def initialize(h={})
2148
-
2149
- options = {
2150
- gps_mode_enabled: true
2151
- }
2152
-
2153
- super(options.merge h)
2154
-
2155
- end
2156
-
2157
- def to_s(colour: false)
2158
- 'GPSEnabledTrigger ' + @h.inspect
2159
- end
2160
-
2161
- alias to_summary to_s
2162
- end
2163
-
2164
- # Category: Device Events
2165
- #
2166
- class MusicPlayingTrigger < DeviceEventsTrigger
2167
-
2168
- def initialize(h={})
2169
-
2170
- options = {
2171
- option: 0
2172
- }
2173
-
2174
- super(options.merge h)
2175
-
2176
- end
2177
-
2178
- def to_s(colour: false)
2179
- 'MusicPlayingTrigger ' + @h.inspect
2180
- end
2181
-
2182
- alias to_summary to_s
2183
- end
2184
-
2185
-
2186
- # Category: Device Events
2187
- #
2188
- class DeviceUnlockedTrigger < DeviceEventsTrigger
2189
-
2190
- def initialize(h={})
2191
-
2192
- options = {
2193
- }
2194
-
2195
- super(options.merge h)
2196
-
2197
- end
2198
-
2199
- def to_s(colour: false)
2200
- 'Screen Unlocked'
2201
- end
2202
-
2203
- alias to_summary to_s
2204
-
2205
- end
2206
-
2207
- # Category: Device Events
2208
- #
2209
- class AutoRotateChangeTrigger < DeviceEventsTrigger
2210
-
2211
- def initialize(h={})
2212
-
2213
- options = {
2214
- option: 0
2215
- }
2216
-
2217
- super(options.merge h)
2218
-
2219
- end
2220
-
2221
- def to_s(colour: false)
2222
- 'AutoRotateChangeTrigger ' + @h.inspect
2223
- end
2224
-
2225
- alias to_summary to_s
2226
- end
2227
-
2228
- # Category: Device Events
2229
- #
2230
- class ClipboardChangeTrigger < DeviceEventsTrigger
2231
-
2232
- def initialize(h={})
2233
-
2234
- options = {
2235
- text: '',
2236
- enable_regex: false
2237
- }
2238
-
2239
- super(options.merge h)
2240
-
2241
- end
2242
-
2243
- def to_s(colour: false)
2244
- 'ClipboardChangeTrigger ' + @h.inspect
2245
- end
2246
-
2247
- alias to_summary to_s
2248
- end
2249
-
2250
- # Category: Device Events
2251
- #
2252
- class BootTrigger < DeviceEventsTrigger
2253
-
2254
- def initialize(h={})
2255
-
2256
- options = {
2257
- }
2258
-
2259
- super(options.merge h)
2260
-
2261
- end
2262
-
2263
- def to_s(colour: false)
2264
- 'BootTrigger ' + @h.inspect
2265
- end
2266
-
2267
- alias to_summary to_s
2268
- end
2269
-
2270
- # Category: Device Events
2271
- #
2272
- class IntentReceivedTrigger < DeviceEventsTrigger
2273
-
2274
- def initialize(h={})
2275
-
2276
- options = {
2277
- action: '',
2278
- extra_params: [],
2279
- extra_value_patterns: [],
2280
- extra_variables: [],
2281
- enable_regex: false
2282
- }
2283
-
2284
- super(options.merge h)
2285
-
2286
- end
2287
-
2288
- def to_s(colour: false)
2289
- 'IntentReceivedTrigger ' + @h.inspect
2290
- end
2291
-
2292
- alias to_summary to_s
2293
- end
2294
-
2295
- # Category: Device Events
2296
- #
2297
- class NotificationTrigger < DeviceEventsTrigger
2298
-
2299
- def initialize(h={})
2300
-
2301
- options = {
2302
- text_content: '',
2303
- package_name_list: ["Any Application"],
2304
- application_name_list: ["Any Application"],
2305
- exclude_apps: false,
2306
- ignore_ongoing: true,
2307
- option: 0,
2308
- exact_match: false,
2309
- excludes: false,
2310
- sound_option: 0,
2311
- supress_multiples: true,
2312
- enable_regex: false
2313
- }
2314
-
2315
- super(options.merge h)
2316
-
2317
- end
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
2325
- end
2326
-
2327
- # Category: Device Events
2328
- #
2329
- class ScreenOnOffTrigger < DeviceEventsTrigger
2330
-
2331
- def initialize(h={})
2332
-
2333
- options = {
2334
- screen_on: true
2335
- }
2336
-
2337
- super(options.merge h)
2338
-
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
2346
-
2347
- end
2348
-
2349
- # Category: Device Events
2350
- #
2351
- class SilentModeTrigger < DeviceEventsTrigger
2352
-
2353
- def initialize(h={})
2354
-
2355
- options = {
2356
- silent_enabled: true
2357
- }
2358
-
2359
- super(options.merge h)
2360
-
2361
- end
2362
-
2363
- def to_s(colour: false)
2364
- 'SilentModeTrigger ' + @h.inspect
2365
- end
2366
-
2367
- alias to_summary to_s
2368
- end
2369
-
2370
- # Category: Location
2371
- #
2372
- class WeatherTrigger < Trigger
2373
-
2374
- def initialize(h={})
2375
-
2376
- options = {
2377
- humidity_above: true,
2378
- humidity_value: 50,
2379
- option: 4,
2380
- temp_below: true,
2381
- temp_celcius: true,
2382
- temperature: 0,
2383
- weather_condition: 0,
2384
- wind_speed_above: true,
2385
- wind_speed_value: 0,
2386
- wind_speed_value_mph: 0
2387
- }
2388
-
2389
- super(options.merge h)
2390
-
2391
- end
2392
-
2393
- def to_s(colour: false)
2394
- 'WeatherTrigger ' + @h.inspect
2395
- end
2396
-
2397
- alias to_summary to_s
2398
- end
2399
-
2400
- # Category: Location
2401
- #
2402
- class GeofenceTrigger < Trigger
2403
-
2404
- def initialize( h={}, geofences: {})
2405
-
2406
- if h[:name] then
2407
- puts ('geofences2: ' + geofences.inspect) if $debug
2408
- found = geofences.find {|x| x.name.downcase == h[:name].downcase}
2409
- h[:geofence_id] = found.id if found
2410
-
2411
- end
2412
-
2413
- options = {
2414
- update_rate_text: '5 Minutes',
2415
- geofence_id: '',
2416
- geofence_update_rate_minutes: 5,
2417
- trigger_from_unknown: false,
2418
- enter_area: true
2419
- }
2420
-
2421
- super(options.merge filter(options, h))
2422
- @geofences = geofences
2423
-
2424
- end
2425
-
2426
- def to_s(colour: false)
2427
-
2428
- if $debug then
2429
- puts ' @geofences: ' + @geofences.inspect
2430
- puts '@h: ' + @h.inspect
2431
- puts '@h[:geofence_id]: ' + @h[:geofence_id].inspect
2432
- end
2433
-
2434
- direction = @h[:enter_area] ? 'Entry' : 'Exit'
2435
-
2436
- found = @geofences.find {|x| x.id == @h[:geofence_id]}
2437
- puts 'found: ' + found.inspect if @debug
2438
- label = found ? found.name : 'error: name not found'
2439
-
2440
- "Geofence %s (%s)" % [direction, label]
2441
-
2442
- end
2443
-
2444
- end
2445
-
2446
- # Category: Location
2447
- #
2448
- class SunriseSunsetTrigger < Trigger
2449
-
2450
- def initialize(h={})
2451
-
2452
- options = {
2453
- option: 0,
2454
- time_adjust_seconds: 0
2455
- }
2456
-
2457
- super(options.merge h)
2458
-
2459
- end
2460
-
2461
- def to_s(colour: false)
2462
- 'SunriseSunsetTrigger ' + @h.inspect
2463
- end
2464
-
2465
- alias to_summary to_s
2466
- end
2467
-
2468
-
2469
- class SensorsTrigger < Trigger
2470
-
2471
- def initialize(h={})
2472
- super(h)
2473
- @group = 'sensors'
2474
- end
2475
-
2476
- end
2477
-
2478
- # Category: Sensors
2479
- #
2480
- class ActivityRecognitionTrigger < SensorsTrigger
2481
-
2482
- def initialize(h={})
2483
-
2484
- options = {
2485
- confidence_level: 50,
2486
- selected_index: 1
2487
- }
2488
-
2489
- super(options.merge h)
2490
-
2491
- @activity = ['In Vehicle', 'On Bicycle', 'Running', 'Walking', 'Still']
2492
-
2493
- end
2494
-
2495
- def to_s(colour: false)
2496
- activity = @activity[@h[:selected_index]]
2497
- 'Activity - ' + activity
2498
- end
2499
-
2500
- def to_summary(colour: false)
2501
-
2502
- activity = @activity[@h[:selected_index]]
2503
- s = if activity.length > 10 then
2504
- activity[0..7] + '..'
2505
- else
2506
- activity
2507
- end
2508
-
2509
- 'Activity - ' + s
2510
-
2511
- end
2512
-
2513
- end
2514
-
2515
- # Category: Sensors
2516
- #
2517
- class ProximityTrigger < SensorsTrigger
2518
-
2519
- def initialize(h={})
2520
-
2521
- if h[:distance] then
2522
-
2523
- case h[:distance].to_sym
2524
- when :near
2525
- options[:near] = true
2526
- end
2527
- end
2528
-
2529
- options = {
2530
- near: true,
2531
- selected_option: 0
2532
- }
2533
-
2534
- super(options.merge h)
2535
-
2536
- end
2537
-
2538
- def to_s(colour: false)
2539
-
2540
- distance = if @h[:near] then
2541
- 'Near'
2542
- else
2543
- 'Far'
2544
- end
2545
-
2546
- "Proximity Sensor (%s)" % distance
2547
- end
2548
-
2549
- alias to_summary to_s
2550
-
2551
- end
2552
-
2553
- # Category: Sensors
2554
- #
2555
- class ShakeDeviceTrigger < SensorsTrigger
2556
-
2557
- def initialize(h={})
2558
-
2559
- options = {
2560
- }
2561
-
2562
- super(options.merge h)
2563
-
2564
- end
2565
-
2566
- def to_pc()
2567
- 'shake_device?'
2568
- end
2569
-
2570
- def to_s(colour: false)
2571
- 'Shake Device'
2572
- end
2573
-
2574
- end
2575
-
2576
- # Category: Sensors
2577
- #
2578
- # options:
2579
- # Face Up -> Face Down
2580
- # Face Down -> Face Up
2581
- # Any -> Face Down
2582
- #
2583
- class FlipDeviceTrigger < SensorsTrigger
2584
-
2585
- def initialize(h={})
2586
-
2587
- options = {
2588
- any_start: false,
2589
- face_down: true,
2590
- work_with_screen_off: false
2591
- }
2592
-
2593
- super(options.merge h)
2594
-
2595
- end
2596
-
2597
- def to_pc()
2598
- @h[:face_down] ? 'flip_device_down?' : 'flip_device_up?'
2599
- end
2600
-
2601
- def to_s(colour: false)
2602
-
2603
- action = @h[:face_down] ? 'Face Up -> Face Down' : 'Face Down -> Face Up'
2604
- 'Flip Device ' + action
2605
- end
2606
-
2607
- end
2608
-
2609
- # Category: Sensors
2610
- #
2611
- class OrientationTrigger < SensorsTrigger
2612
-
2613
- def initialize(h={})
2614
-
2615
- options = {
2616
- check_orientation_alive: true,
2617
- option: 0
2618
- }
2619
-
2620
- super(options.merge h)
2621
-
2622
- end
2623
-
2624
- def to_s(colour: false)
2625
- 'OrientationTrigger ' + @h.inspect
2626
- end
2627
-
2628
- alias to_summary to_s
2629
- end
2630
-
2631
- # Category: User Input
2632
- #
2633
- class FloatingButtonTrigger < Trigger
2634
-
2635
- def initialize(h={})
2636
-
2637
- options = {
2638
- image_resource_id: 0,
2639
- icon_bg_color: -9079435,
2640
- alpha: 100,
2641
- padding: 20,
2642
- force_location: false,
2643
- show_on_lock_screen: false,
2644
- size: 0,
2645
- transparent_background: false,
2646
- x_location: 0,
2647
- y_location: 0
2648
- }
2649
-
2650
- super(options.merge h)
2651
-
2652
- end
2653
-
2654
- def to_s(colour: false)
2655
- 'Floating Button'
2656
- end
2657
-
2658
- alias to_summary to_s
2659
- end
2660
-
2661
- # Category: User Input
2662
- #
2663
- class ShortcutTrigger < Trigger
2664
-
2665
- def initialize(h={})
2666
-
2667
- options = {
2668
- }
2669
-
2670
- super(options.merge h)
2671
-
2672
- end
2673
-
2674
- def to_s(colour: false)
2675
- 'ShortcutTrigger ' + @h.inspect
2676
- end
2677
-
2678
- alias to_summary to_s
2679
- end
2680
-
2681
- # Category: User Input
2682
- #
2683
- class VolumeButtonTrigger < Trigger
2684
-
2685
- def initialize(h={})
2686
-
2687
- options = {
2688
- dont_change_volume: true,
2689
- monitor_option: 1,
2690
- not_configured: false,
2691
- option: 0
2692
- }
2693
-
2694
- super(options.merge h)
2695
-
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
2724
-
2725
- end
2726
-
2727
- # Category: User Input
2728
- #
2729
- class MediaButtonPressedTrigger < Trigger
2730
-
2731
- def initialize(h={})
2732
-
2733
- options = {
2734
- option: 'Single Press',
2735
- cancel_press: false
2736
- }
2737
-
2738
- super(options.merge h)
2739
-
2740
- end
2741
-
2742
- def to_s(colour: false)
2743
- 'MediaButtonPressedTrigger ' + @h.inspect
2744
- end
2745
-
2746
- alias to_summary to_s
2747
- end
2748
-
2749
- # Category: User Input
2750
- #
2751
- class SwipeTrigger < Trigger
2752
-
2753
- def initialize(h={})
2754
-
2755
- options = {
2756
- swipe_start_area: 0,
2757
- swipe_motion: 0,
2758
- cleared: true
2759
- }
2760
-
2761
- super(options.merge h)
2762
-
2763
- end
2764
-
2765
- def to_s(colour: false)
2766
- 'SwipeTrigger ' + @h.inspect
2767
- end
2768
-
2769
- alias to_summary to_s
2770
- end
2771
-
2772
-
2773
- class Action < MacroObject
2774
- using Params
2775
-
2776
- attr_reader :constraints
2777
-
2778
- def initialize(h={})
2779
-
2780
- macro = h[:macro]
2781
- h.delete :macro
2782
- super(h)
2783
-
2784
- # fetch the constraints
2785
- @constraints = @h[:constraint_list].map do |constraint|
2786
- object(constraint.to_snake_case.merge(macro: macro))
2787
- end
2788
- end
2789
-
2790
- def invoke(s='')
2791
- "%s/%s: %s" % [@group, @type, s]
2792
- end
2793
-
2794
- def to_s(colour: false)
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
-
2807
- end
2808
-
2809
-
2810
- class LocationAction < Action
2811
-
2812
- def initialize(h={})
2813
- super(h)
2814
- @group = 'location'
2815
- end
2816
-
2817
- end
2818
-
2819
- # Category: Location
2820
- #
2821
- class ShareLocationAction < LocationAction
2822
-
2823
- def initialize(h={})
2824
-
2825
- super()
2826
-
2827
- options = {
2828
- email: '',
2829
- variable: {:m_stringValue=>"", :m_name=>"",
2830
- :m_decimalValue=>0.0, :isLocal=>true, :m_booleanValue=>false,
2831
- :excludeFromLog=>false, :m_intValue=>0, :m_type=>2},
2832
- sim_id: 0,
2833
- output_channel: 5,
2834
- old_variable_format: true
2835
- }
2836
-
2837
- super(options.merge h)
2838
-
2839
- end
2840
-
2841
- def to_s(colour: false)
2842
- 'ShareLocationAction ' + @h.inspect
2843
- end
2844
-
2845
- alias to_summary to_s
2846
- end
2847
-
2848
-
2849
- class ApplicationAction < Action
2850
-
2851
- def initialize(h={})
2852
- super(h)
2853
- @group = 'application'
2854
- end
2855
-
2856
- end
2857
-
2858
- # Category: Applications
2859
- #
2860
- class LaunchActivityAction < ApplicationAction
2861
-
2862
- def initialize(h={})
2863
-
2864
- options = {
2865
- application_name: 'Chrome',
2866
- package_to_launch: 'com.android.chrome',
2867
- exclude_from_recents: false,
2868
- start_new: false
2869
- }
2870
-
2871
- super(options.merge h)
2872
-
2873
- end
2874
-
2875
- def to_s(colour: false)
2876
- 'Launch ' + @h[:application_name]
2877
- end
2878
-
2879
- end
2880
-
2881
- # Category: Applications
2882
- #
2883
- class KillBackgroundAppAction < ApplicationAction
2884
-
2885
- def initialize(h={})
2886
-
2887
- options = {
2888
- application_name_list: [""],
2889
- package_name_list: [""]
2890
- }
2891
-
2892
- super(options.merge h)
2893
-
2894
- end
2895
-
2896
- def to_s(colour: false)
2897
- 'KillBackgroundAppAction ' + @h.inspect
2898
- end
2899
-
2900
- alias to_summary to_s
2901
- end
2902
-
2903
- # Category: Applications
2904
- #
2905
- class LaunchShortcutAction < ApplicationAction
2906
-
2907
- def initialize(h={})
2908
-
2909
- options = {
2910
- :app_name=>"Amazon Alexa", :intent_encoded=>"", :name=>"Ask Alexa"
2911
- }
2912
-
2913
- super(options.merge h)
2914
-
2915
- end
2916
-
2917
- def to_s(colour: false)
2918
- @s = "Launch Shortcut: " + @h[:app_name] + "\n " + @h[:name]
2919
- super()
2920
- end
2921
-
2922
- alias to_summary to_s
2923
-
2924
- end
2925
-
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
2954
-
2955
- def initialize(h={})
2956
- super(h)
2957
- @group = 'camera'
2958
- end
2959
-
2960
- end
2961
-
2962
- # Category: Camera/Photo
2963
- #
2964
- class UploadPhotoAction < CameraAction
2965
-
2966
- def initialize(h={})
2967
-
2968
- options = {
2969
- option: 'Via Intent',
2970
- use_smtp_email: false
2971
- }
2972
-
2973
- super(options.merge h)
2974
-
2975
- end
2976
-
2977
- def to_s(colour: false)
2978
- 'UploadPhotoAction ' + @h.inspect
2979
- end
2980
-
2981
- alias to_summary to_s
2982
- end
2983
-
2984
- # Category: Camera/Photo
2985
- #
2986
- class TakePictureAction < CameraAction
2987
-
2988
- def initialize(h={})
2989
-
2990
- options = {
2991
- new_path: '/storage/sdcard1/DCIM/Camera',
2992
- path: '/storage/sdcard1/DCIM/Camera',
2993
- show_icon: true,
2994
- use_front_camera: true,
2995
- flash_option: 0
2996
- }
2997
-
2998
- super(options.merge h)
2999
-
3000
- end
3001
-
3002
- def to_pc()
3003
- camera = @h[:use_front_camera] ? :front : :back
3004
- 'take_photo :' + camera.to_s
3005
- end
3006
-
3007
- def to_s(colour: false)
3008
- 'Take Picture'
3009
- end
3010
-
3011
- end
3012
-
3013
- class IfConditionAction < Action
3014
-
3015
- def initialize(h={})
3016
-
3017
- options = {
3018
- a: true,
3019
- constraint_list: ''
3020
- }
3021
-
3022
- macro = h[:macro]
3023
- h2 = options.merge(filter(options,h).merge(macro: macro))
3024
-
3025
- super(h2)
3026
-
3027
- @label = 'If '
3028
-
3029
- end
3030
-
3031
- def to_s(colour: false)
3032
-
3033
- @s = "If " #+ @constraints.map(&:to_s).join(" %s " % operator)
3034
- super(colour: colour)
3035
-
3036
- end
3037
- end
3038
-
3039
- class ElseAction < Action
3040
-
3041
- def initialize(h={})
3042
-
3043
- options = {
3044
- constraint_list: ''
3045
- }
3046
-
3047
- super(options.merge h)
3048
-
3049
-
3050
- end
3051
-
3052
- def to_s(colour: false)
3053
- 'Else'
3054
- end
3055
-
3056
- end
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
-
3075
- class EndIfAction < Action
3076
-
3077
- def initialize(h={})
3078
-
3079
- options = {
3080
- constraint_list: ''
3081
- }
3082
-
3083
- super(options.merge h)
3084
-
3085
- end
3086
-
3087
- def to_s(colour: false)
3088
- 'End If'
3089
- end
3090
-
3091
- end
3092
-
3093
- class ConnectivityAction < Action
3094
-
3095
- def initialize(h={})
3096
- super(h)
3097
- @group = 'connectivity'
3098
- end
3099
-
3100
- end
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
-
3127
- # Category: Connectivity
3128
- #
3129
- class SetWifiAction < ConnectivityAction
3130
-
3131
- def initialize(h={})
3132
-
3133
- options = {
3134
- ssid: '[Select Wifi]',
3135
- network_id: 0,
3136
- state: 0
3137
- }
3138
-
3139
- super(options.merge h)
3140
-
3141
- end
3142
-
3143
- def to_s(colour: false)
3144
- action = @h[:state] == 0 ? 'Enable' : 'Disable'
3145
- action + ' Wifi'
3146
- end
3147
-
3148
- end
3149
-
3150
- # Category: Connectivity
3151
- #
3152
- class SetBluetoothAction < ConnectivityAction
3153
-
3154
- def initialize(h={})
3155
-
3156
- options = {
3157
- device_name: '',
3158
- state: 0
3159
- }
3160
-
3161
- super(options.merge h)
3162
-
3163
- end
3164
-
3165
- def to_s(colour: false)
3166
- 'SetBluetoothAction ' + @h.inspect
3167
- end
3168
-
3169
- alias to_summary to_s
3170
- end
3171
-
3172
- # Category: Connectivity
3173
- #
3174
- class SetBluetoothAction < ConnectivityAction
3175
-
3176
- def initialize(h={})
3177
-
3178
- options = {
3179
- device_name: '',
3180
- state: 1
3181
- }
3182
-
3183
- super(options.merge h)
3184
-
3185
- end
3186
-
3187
- def to_s(colour: false)
3188
- 'SetBluetoothAction ' + @h.inspect
3189
- end
3190
-
3191
- alias to_summary to_s
3192
- end
3193
-
3194
- class SetHotspotAction < ConnectivityAction
3195
-
3196
- def initialize(h={})
3197
-
3198
- options = {
3199
- device_name: "", state: 0, turn_wifi_on: true, use_legacy_mechanism: false, mechanism: 0
3200
-
3201
- }
3202
-
3203
- super(options.merge h)
3204
-
3205
- end
3206
-
3207
- def to_s(colour: false)
3208
- action = @h[:turn_wifi_on] ? 'Enable' : 'Disable'
3209
- action + ' HotSpot'
3210
- end
3211
- end
3212
-
3213
- # Category: Connectivity
3214
- #
3215
- class SendIntentAction < ConnectivityAction
3216
-
3217
- def initialize(h={})
3218
-
3219
- options = {
3220
- action: '',
3221
- class_name: '',
3222
- data: '',
3223
- extra1_name: '',
3224
- extra1_value: '',
3225
- extra2_name: '',
3226
- extra2_value: '',
3227
- extra3_name: '',
3228
- extra3_value: '',
3229
- extra4_name: '',
3230
- extra4_value: '',
3231
- package_name: '',
3232
- target: 'Activity'
3233
- }
3234
-
3235
- super(options.merge h)
3236
-
3237
- end
3238
-
3239
- def to_s(colour: false)
3240
- 'Send Intent ' + "\n " + @h[:action]
3241
- end
3242
-
3243
- alias to_summary to_s
3244
- end
3245
-
3246
-
3247
- class DateTimeAction < Action
3248
-
3249
- def initialize(h={})
3250
- super(h)
3251
- @group = 'datetime'
3252
- end
3253
-
3254
- end
3255
-
3256
- # Category: Date/Time
3257
- #
3258
- class SetAlarmClockAction < DateTimeAction
3259
-
3260
- def initialize(h={})
3261
-
3262
- options = {
3263
- days_of_week: [false, false, false, false, false, false, false],
3264
- label: 'wakeup mum',
3265
- delay_in_minutes: 1,
3266
- hour: 8,
3267
- delay_in_hours: 0,
3268
- minute: 15,
3269
- one_off: true,
3270
- option: 0,
3271
- relative: true,
3272
- day_option: 0
3273
- }
3274
-
3275
- super(options.merge h)
3276
-
3277
- end
3278
-
3279
- def to_s(colour: false)
3280
- 'SetAlarmClockAction ' + @h.inspect
3281
- end
3282
-
3283
- alias to_summary to_s
3284
- end
3285
-
3286
- # Category: Date/Time
3287
- #
3288
- class StopWatchAction < DateTimeAction
3289
-
3290
- def initialize(h={})
3291
-
3292
- options = {
3293
- stopwatch_name: 'timer1',
3294
- option: 0
3295
- }
3296
-
3297
- super(options.merge h)
3298
-
3299
- end
3300
-
3301
- def to_s(colour: false)
3302
- 'StopWatchAction ' + @h.inspect
3303
- end
3304
-
3305
- alias to_summary to_s
3306
- end
3307
-
3308
- # Category: Date/Time
3309
- #
3310
- class SayTimeAction < DateTimeAction
3311
-
3312
- def initialize(h={})
3313
-
3314
- options = {
3315
- :'12_hour' => true
3316
- }
3317
-
3318
- super(options.merge h)
3319
-
3320
- end
3321
-
3322
- def invoke()
3323
- time = ($env and $env[:time]) ? $env[:time] : Time.now
3324
- tformat = @h['12_hour'] ? "%-I:%M%P" : "%H:%M"
3325
- super(time.strftime(tformat))
3326
- end
3327
-
3328
- def to_pc()
3329
- 'say current_time()'
3330
- end
3331
-
3332
- def to_s(colour: false)
3333
- 'Say Current Time'
3334
- end
3335
-
3336
- end
3337
-
3338
-
3339
- class DeviceAction < Action
3340
-
3341
- def initialize(h={})
3342
- super(h)
3343
- @group = 'device'
3344
- end
3345
-
3346
- end
3347
-
3348
- # Category: Device Actions
3349
- #
3350
- class AndroidShortcutsAction < DeviceAction
3351
-
3352
- def initialize(h={})
3353
-
3354
- options = {
3355
- option: 1
3356
- }
3357
-
3358
- super(options.merge h)
3359
-
3360
- end
3361
-
3362
- def to_s(colour: false)
3363
- 'AndroidShortcutsAction ' + @h.inspect
3364
- end
3365
-
3366
- alias to_summary to_s
3367
- end
3368
-
3369
- # Category: Device Actions
3370
- #
3371
- class ClipboardAction < DeviceAction
3372
-
3373
- def initialize(h={})
3374
-
3375
- options = {
3376
- clipboard_text: ''
3377
- }
3378
-
3379
- super(options.merge h)
3380
-
3381
- end
3382
-
3383
- def to_s(colour: false)
3384
- 'ClipboardAction ' + @h.inspect
3385
- end
3386
-
3387
- alias to_summary to_s
3388
- end
3389
-
3390
- # Category: Device Actions
3391
- #
3392
- class PressBackAction < DeviceAction
3393
-
3394
- def initialize(h={})
3395
-
3396
- options = {
3397
- }
3398
-
3399
- super(options.merge h)
3400
-
3401
- end
3402
-
3403
- def to_s(colour: false)
3404
- 'PressBackAction ' + @h.inspect
3405
- end
3406
-
3407
- alias to_summary to_s
3408
- end
3409
-
3410
- # Category: Device Actions
3411
- #
3412
- class SpeakTextAction < DeviceAction
3413
-
3414
- def initialize(h={})
3415
-
3416
- options = {
3417
- text_to_say: '',
3418
- queue: false,
3419
- read_numbers_individually: false,
3420
- specify_audio_stream: false,
3421
- speed: 0.99,
3422
- pitch: 0.99,
3423
- wait_to_finish: false,
3424
- audio_stream: 0
3425
- }
3426
-
3427
- super(options.merge h)
3428
-
3429
- end
3430
-
3431
- def to_s(colour: false)
3432
- "Speak Text (%s)" % @h[:text_to_say]
3433
- end
3434
-
3435
- end
3436
-
3437
- # Category: Device Actions
3438
- #
3439
- class UIInteractionAction < DeviceAction
3440
-
3441
- def initialize(h={})
3442
-
3443
- options = {
3444
- ui_interaction_configuration: {:type=>"Copy"},
3445
- action: 2
3446
- }
3447
-
3448
- super(options.merge h)
3449
-
3450
- end
3451
-
3452
- def to_s(colour: false)
3453
- 'UIInteractionAction ' + @h.inspect
3454
- end
3455
-
3456
- alias to_summary to_s
3457
- end
3458
-
3459
- # Category: Device Actions
3460
- #
3461
- class VoiceSearchAction < DeviceAction
3462
-
3463
- def initialize(h={})
3464
-
3465
- options = {
3466
- }
3467
-
3468
- super(options.merge h)
3469
-
3470
- end
3471
-
3472
- def to_s(colour: false)
3473
- 'VoiceSearchAction ' + @h.inspect
3474
- end
3475
-
3476
- alias to_summary to_s
3477
- end
3478
-
3479
-
3480
- class DeviceSettingsAction < Action
3481
-
3482
- def initialize(h={})
3483
- super(h)
3484
- @group = 'devicesettings'
3485
- end
3486
-
3487
- end
3488
-
3489
- # Category: Device Settings
3490
- #
3491
- class ExpandCollapseStatusBarAction < DeviceSettingsAction
3492
-
3493
- def initialize(h={})
3494
-
3495
- options = {
3496
- option: 0
3497
- }
3498
-
3499
- super(options.merge h)
3500
-
3501
- end
3502
-
3503
- def to_s(colour: false)
3504
- 'ExpandCollapseStatusBarAction ' + @h.inspect
3505
- end
3506
-
3507
- alias to_summary to_s
3508
- end
3509
-
3510
- # Category: Device Settings
3511
- #
3512
- class LaunchHomeScreenAction < DeviceSettingsAction
3513
-
3514
- def initialize(h={})
3515
-
3516
- options = {
3517
- }
3518
-
3519
- super(options.merge h)
3520
-
3521
- end
3522
-
3523
- def to_s(colour: false)
3524
- 'LaunchHomeScreenAction ' + @h.inspect
3525
- end
3526
-
3527
- alias to_summary to_s
3528
- end
3529
-
3530
- # Category: Device Settings
3531
- #
3532
- class CameraFlashLightAction < DeviceSettingsAction
3533
-
3534
- def initialize(h={})
3535
-
3536
- options = {
3537
- launch_foreground: false,
3538
- state: 0
3539
- }
3540
-
3541
- super(options.merge h)
3542
-
3543
- end
3544
-
3545
- def to_pc()
3546
- ['torch :on', 'torch :off', 'torch :toggle'][@h[:state]]
3547
- end
3548
-
3549
- def to_s(colour: false)
3550
- ['Torch On', 'Torch Off', 'Torch Toggle'][@h[:state]]
3551
- end
3552
-
3553
- end
3554
-
3555
- # Category: Device Settings
3556
- #
3557
- class VibrateAction < DeviceSettingsAction
3558
-
3559
- def initialize(h={})
3560
-
3561
- options = {
3562
- vibrate_pattern: 1
3563
- }
3564
-
3565
- super(options.merge h)
3566
-
3567
- end
3568
-
3569
- def to_s(colour: false)
3570
-
3571
- pattern = [
3572
- 'Blip', 'Short Buzz', 'Long Buzz', 'Rapid', 'Slow', 'Increasing',
3573
- 'Constant', 'Decreasing', 'Final Fantasy', 'Game Over', 'Star Wars',
3574
- 'Mini Blip', 'Micro Blip'
3575
- ]
3576
-
3577
- 'Vibrate ' + "(%s)" % pattern[@h[:vibrate_pattern].to_i]
3578
- end
3579
-
3580
- end
3581
-
3582
- # Category: Device Settings
3583
- #
3584
- class SetAutoRotateAction < DeviceSettingsAction
3585
-
3586
- def initialize(h={})
3587
-
3588
- options = {
3589
- state: 0
3590
- }
3591
-
3592
- super(options.merge h)
3593
-
3594
- end
3595
-
3596
- def to_s(colour: false)
3597
- 'SetAutoRotateAction ' + @h.inspect
3598
- end
3599
-
3600
- alias to_summary to_s
3601
- end
3602
-
3603
- # Category: Device Settings
3604
- #
3605
- class DayDreamAction < DeviceSettingsAction
3606
-
3607
- def initialize(h={})
3608
-
3609
- options = {
3610
- }
3611
-
3612
- super(options.merge h)
3613
-
3614
- end
3615
-
3616
- def to_s(colour: false)
3617
- 'DayDreamAction ' + @h.inspect
3618
- end
3619
-
3620
- alias to_summary to_s
3621
- end
3622
-
3623
- # Category: Device Settings
3624
- #
3625
- class SetKeyboardAction < DeviceSettingsAction
3626
-
3627
- def initialize(h={})
3628
-
3629
- options = {
3630
- }
3631
-
3632
- super(options.merge h)
3633
-
3634
- end
3635
-
3636
- def to_s(colour: false)
3637
- 'SetKeyboardAction ' + @h.inspect
3638
- end
3639
-
3640
- alias to_summary to_s
3641
- end
3642
-
3643
- # Category: Device Settings
3644
- #
3645
- class SetKeyguardAction < DeviceSettingsAction
3646
-
3647
- def initialize(h={})
3648
-
3649
- options = {
3650
- keyguard_on: true
3651
- }
3652
-
3653
- super(options.merge h)
3654
-
3655
- end
3656
-
3657
- def to_s(colour: false)
3658
- 'SetKeyguardAction ' + @h.inspect
3659
- end
3660
-
3661
- alias to_summary to_s
3662
- end
3663
-
3664
- # Category: Device Settings
3665
- #
3666
- class CarModeAction < DeviceSettingsAction
3667
-
3668
- def initialize(h={})
3669
-
3670
- options = {
3671
- option: 0
3672
- }
3673
-
3674
- super(options.merge h)
3675
-
3676
- end
3677
-
3678
- def to_s(colour: false)
3679
- 'CarModeAction ' + @h.inspect
3680
- end
3681
-
3682
- alias to_summary to_s
3683
- end
3684
-
3685
- # Category: Device Settings
3686
- #
3687
- class ChangeKeyboardAction < DeviceSettingsAction
3688
-
3689
- def initialize(h={})
3690
-
3691
- options = {
3692
- keyboard_id: 'com.android.inputmethod.latin/.LatinIME',
3693
- keyboard_name: 'Android Keyboard (AOSP)'
3694
- }
3695
-
3696
- super(options.merge h)
3697
-
3698
- end
3699
-
3700
- def to_s(colour: false)
3701
- 'ChangeKeyboardAction ' + @h.inspect
3702
- end
3703
-
3704
- alias to_summary to_s
3705
- end
3706
-
3707
- # Category: Device Settings
3708
- #
3709
- class SetWallpaperAction < DeviceSettingsAction
3710
-
3711
- def initialize(h={})
3712
-
3713
- options = {
3714
- image_name: '6051449505275476553',
3715
- s_screen_options: ["Home Screen", "Lock Screen", "Home + Lock Screen"],
3716
- s_options: ["Image", "Live Wallpaper (Preview Screen)"],
3717
- wallpaper_uri_string: 'content://media/external/images/media/928',
3718
- screen_option: 0,
3719
- option: 0
3720
- }
3721
-
3722
- super(options.merge h)
3723
-
3724
- end
3725
-
3726
- def to_s(colour: false)
3727
- 'SetWallpaperAction ' + @h.inspect
3728
- end
3729
-
3730
- alias to_summary to_s
3731
- end
3732
-
3733
- class FileAction < Action
3734
-
3735
- def initialize(h={})
3736
- super(h)
3737
- @group = 'file'
3738
- end
3739
-
3740
- end
3741
-
3742
- # Category: Files
3743
- #
3744
- class OpenFileAction < FileAction
3745
-
3746
- def initialize(h={})
3747
-
3748
- options = {
3749
- app_name: '',
3750
- class_name: '',
3751
- package_name: '',
3752
- file_path: ''
3753
- }
3754
-
3755
- super(options.merge h)
3756
-
3757
- end
3758
-
3759
- def to_s(colour: false)
3760
- 'OpenFileAction ' + @h.inspect
3761
- end
3762
-
3763
- alias to_summary to_s
3764
- end
3765
-
3766
-
3767
- class LocationAction < Action
3768
-
3769
- def initialize(h={})
3770
- super(h)
3771
- @group = 'location'
3772
- end
3773
-
3774
- end
3775
-
3776
- # Category: Location
3777
- #
3778
- class ForceLocationUpdateAction < LocationAction
3779
-
3780
- def initialize(h={})
3781
-
3782
- options = {
3783
- }
3784
-
3785
- super(options.merge h)
3786
-
3787
- end
3788
-
3789
- def to_s(colour: false)
3790
- 'ForceLocationUpdateAction ' + @h.inspect
3791
- end
3792
-
3793
- alias to_summary to_s
3794
- end
3795
-
3796
- # Category: Location
3797
- #
3798
- class ShareLocationAction < LocationAction
3799
-
3800
- def initialize(h={})
3801
-
3802
- options = {
3803
- email: '',
3804
- variable: {:m_stringValue=>"", :m_name=>"", :m_decimalValue=>0.0, :isLocal=>true, :m_booleanValue=>false, :excludeFromLog=>false, :m_intValue=>0, :m_type=>2},
3805
- sim_id: 0,
3806
- output_channel: 5,
3807
- old_variable_format: true
3808
- }
3809
-
3810
- super(options.merge h)
3811
-
3812
- end
3813
-
3814
- def to_s(colour: false)
3815
- 'ShareLocationAction ' + @h.inspect
3816
- end
3817
-
3818
- alias to_summary to_s
3819
- end
3820
-
3821
- # Category: Location
3822
- #
3823
- class SetLocationUpdateRateAction < LocationAction
3824
-
3825
- def initialize(h={})
3826
-
3827
- options = {
3828
- update_rate: 0,
3829
- update_rate_seconds: 600
3830
- }
3831
-
3832
- super(options.merge h)
3833
-
3834
- end
3835
-
3836
- def to_s(colour: false)
3837
- 'SetLocationUpdateRateAction ' + @h.inspect
3838
- end
3839
-
3840
- alias to_summary to_s
3841
- end
3842
-
3843
- class LoggingAction < Action
3844
-
3845
- def initialize(h={})
3846
- super(h)
3847
- @group = 'logging'
3848
- end
3849
-
3850
- end
3851
-
3852
- # Category: Logging
3853
- #
3854
- class AddCalendarEntryAction < LoggingAction
3855
-
3856
- def initialize(h={})
3857
-
3858
- options = {
3859
- title: '',
3860
- duration_value: '0',
3861
- calendar_id: '3',
3862
- detail: '',
3863
- availability: 0,
3864
- fixed_days: 16,
3865
- fixed_hour: 0,
3866
- fixed_minute: 0,
3867
- fixed_months: 8,
3868
- fixed_time: true,
3869
- relative_days: 0,
3870
- relative_hours: 0,
3871
- relative_minutes: 0,
3872
- all_day_event: true
3873
- }
3874
-
3875
- super(options.merge h)
3876
-
3877
- end
3878
-
3879
- def to_s(colour: false)
3880
- 'AddCalendarEntryAction ' + @h.inspect
3881
- end
3882
-
3883
- alias to_summary to_s
3884
- end
3885
-
3886
- # Category: Logging
3887
- #
3888
- class LogAction < LoggingAction
3889
-
3890
- def initialize(h={})
3891
-
3892
- options = {
3893
- log_text: '',
3894
- log_date_and_time: true
3895
- }
3896
-
3897
- super(options.merge h)
3898
-
3899
- end
3900
-
3901
- def to_s(colour: false)
3902
- 'LogAction ' + @h.inspect
3903
- end
3904
-
3905
- alias to_summary to_s
3906
- end
3907
-
3908
- # Category: Logging
3909
- #
3910
- class ClearLogAction < LoggingAction
3911
-
3912
- def initialize(h={})
3913
-
3914
- options = {
3915
- user_log: true
3916
- }
3917
-
3918
- super(options.merge h)
3919
-
3920
- end
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
-
3956
- end
3957
-
3958
- class MediaAction < Action
3959
-
3960
- def initialize(h={})
3961
- super(h)
3962
- @group = 'media'
3963
- end
3964
-
3965
- end
3966
-
3967
- # Category: Media
3968
- #
3969
- class RecordMicrophoneAction < MediaAction
3970
-
3971
- def initialize(h={})
3972
-
3973
- options = {
3974
- path: '/storage/emulated/0/MacroDroid/Recordings',
3975
- record_time_string: 'Cancel Recording',
3976
- recording_format: 0,
3977
- seconds_to_record_for: -2
3978
- }
3979
-
3980
- super(options.merge h)
3981
-
3982
- end
3983
-
3984
- def to_s(colour: false)
3985
- 'RecordMicrophoneAction ' + @h.inspect
3986
- end
3987
-
3988
- alias to_summary to_s
3989
- end
3990
-
3991
- # Category: Media
3992
- #
3993
- class PlaySoundAction < MediaAction
3994
-
3995
- def initialize(h={})
3996
-
3997
- options = {
3998
- selected_index: 0,
3999
- file_path: ''
4000
- }
4001
-
4002
- super(options.merge h)
4003
-
4004
- end
4005
-
4006
- def to_s(colour: false)
4007
- 'Play: ' + @h[:file_path]
4008
- end
4009
-
4010
- end
4011
-
4012
-
4013
- class MessagingAction < Action
4014
-
4015
- def initialize(h={})
4016
- super(h)
4017
- @group = 'messaging'
4018
- end
4019
-
4020
- end
4021
-
4022
- # Category: Messaging
4023
- #
4024
- class SendEmailAction < MessagingAction
4025
-
4026
- def initialize(h={})
4027
-
4028
- options = {
4029
- subject: '',
4030
- body: '',
4031
- email_address: '',
4032
- from_email_address: '',
4033
- attach_user_log: false,
4034
- attach_log: false,
4035
- send_option: 0
4036
- }
4037
-
4038
- super(options.merge h)
4039
-
4040
- end
4041
-
4042
- def to_s(colour: false)
4043
- 'SendEmailAction ' + @h.inspect
4044
- end
4045
-
4046
- alias to_summary to_s
4047
- end
4048
-
4049
- # Category: Messaging
4050
- #
4051
- class SendSMSAction < MessagingAction
4052
-
4053
- def initialize(h={})
4054
-
4055
- options = {
4056
- number: '',
4057
- contact: {:m_id=>"Hardwired_Number", :m_lookupKey=>"Hardwired_Number", :m_name=>"[Select Number]"},
4058
- message_content: '',
4059
- add_to_message_log: false,
4060
- pre_populate: false,
4061
- sim_id: 0
4062
- }
4063
-
4064
- super(options.merge h)
4065
-
4066
- end
4067
-
4068
- def to_s(colour: false)
4069
- 'SendSMSAction ' + @h.inspect
4070
- end
4071
-
4072
- alias to_summary to_s
4073
- end
4074
-
4075
- # Category: Messaging
4076
- #
4077
- class UDPCommandAction < MessagingAction
4078
-
4079
- def initialize(h={})
4080
-
4081
- options = {
4082
- destination: '',
4083
- message: '',
4084
- port: 1024
4085
- }
4086
-
4087
- super(options.merge h)
4088
-
4089
- end
4090
-
4091
- def to_s(colour: false)
4092
- 'UDPCommandAction ' + @h.inspect
4093
- end
4094
-
4095
- alias to_summary to_s
4096
- end
4097
-
4098
-
4099
- class NotificationsAction < Action
4100
-
4101
- def initialize(h={})
4102
- super(h)
4103
- @group = 'notifications'
4104
- end
4105
-
4106
- end
4107
-
4108
- # Category: Notifications
4109
- #
4110
- class ClearNotificationsAction < NotificationsAction
4111
-
4112
- def initialize(h={})
4113
-
4114
- options = {
4115
- package_name_list: [],
4116
- match_text: '',
4117
- application_name_list: [],
4118
- clear_persistent: false,
4119
- excludes: false,
4120
- match_option: 0,
4121
- age_in_seconds: 0,
4122
- option: 0,
4123
- enable_regex: false
4124
- }
4125
-
4126
- super(options.merge h)
4127
-
4128
- end
4129
-
4130
- def to_s(colour: false)
4131
- 'ClearNotificationsAction ' + @h.inspect
4132
- end
4133
-
4134
- alias to_summary to_s
4135
- end
4136
-
4137
- # Category: Notifications
4138
- #
4139
- class MessageDialogAction < NotificationsAction
4140
-
4141
- def initialize(h={})
4142
-
4143
- options = {
4144
- secondary_class_type: 'MessageDialogAction',
4145
- ringtone_name: 'Default',
4146
- notification_text: '',
4147
- notification_subject: '',
4148
- macro_guid_to_run: -0,
4149
- notification_channel_type: 0,
4150
- image_resource_id: 0,
4151
- overwrite_existing: false,
4152
- priority: 0,
4153
- ringtone_index: 0,
4154
- icon_bg_color: -1762269,
4155
- run_macro_when_pressed: false
4156
- }
4157
-
4158
- super(options.merge h)
4159
-
4160
- end
4161
-
4162
- def to_s(colour: false)
4163
- 'Display Dialog' + "\n Battery at: [battery]"
4164
- end
4165
-
4166
- end
4167
-
4168
- # Category: Notifications
4169
- #
4170
- class AllowLEDNotificationLightAction < NotificationsAction
4171
-
4172
- def initialize(h={})
4173
-
4174
- options = {
4175
- enabled: true
4176
- }
4177
-
4178
- super(options.merge h)
4179
-
4180
- end
4181
-
4182
- def to_s(colour: false)
4183
- 'AllowLEDNotificationLightAction ' + @h.inspect
4184
- end
4185
-
4186
- alias to_summary to_s
4187
- end
4188
-
4189
- # Category: Notifications
4190
- #
4191
- class SetNotificationSoundAction < NotificationsAction
4192
-
4193
- def initialize(h={})
4194
-
4195
- options = {
4196
- ringtone_uri: 'content://media/internal/audio/media/27'
4197
- }
4198
-
4199
- super(options.merge h)
4200
-
4201
- end
4202
-
4203
- def to_s(colour: false)
4204
- 'SetNotificationSoundAction ' + @h.inspect
4205
- end
4206
-
4207
- alias to_summary to_s
4208
- end
4209
-
4210
- # Category: Notifications
4211
- #
4212
- class SetNotificationSoundAction < NotificationsAction
4213
-
4214
- def initialize(h={})
4215
-
4216
- options = {
4217
- ringtone_uri: 'content://media/internal/audio/media/51'
4218
- }
4219
-
4220
- super(options.merge h)
4221
-
4222
- end
4223
-
4224
- def to_s(colour: false)
4225
- 'SetNotificationSoundAction ' + @h.inspect
4226
- end
4227
-
4228
- alias to_summary to_s
4229
- end
4230
-
4231
- # Category: Notifications
4232
- #
4233
- class SetNotificationSoundAction < NotificationsAction
4234
-
4235
- def initialize(h={})
4236
-
4237
- options = {
4238
- ringtone_name: 'None'
4239
- }
4240
-
4241
- super(options.merge h)
4242
-
4243
- end
4244
-
4245
- def to_s(colour: false)
4246
- 'SetNotificationSoundAction ' + @h.inspect
4247
- end
4248
-
4249
- alias to_summary to_s
4250
- end
4251
-
4252
- # Category: Notifications
4253
- #
4254
- class NotificationAction < NotificationsAction
4255
-
4256
- def initialize(h={})
4257
-
4258
- h[:notification_subject] = h[:subject] if h[:subject]
4259
- h[:notification_text] = h[:text] if h[:text]
4260
-
4261
- options = {
4262
- ringtone_name: 'Default',
4263
- notification_text: '',
4264
- notification_subject: '',
4265
- macro_guid_to_run: 0,
4266
- notification_channel_type: 0,
4267
- image_resource_id: 0,
4268
- overwrite_existing: false,
4269
- priority: 0,
4270
- ringtone_index: 0,
4271
- icon_bg_color: -1762269,
4272
- run_macro_when_pressed: false
4273
- }
4274
-
4275
- super(options.merge filter(options, h))
4276
-
4277
- end
4278
-
4279
- def to_s(colour: false)
4280
- "Display Notification\n " + \
4281
- "%s: %s" % [@h[:notification_subject], @h[:notification_text]]
4282
- end
4283
-
4284
- end
4285
-
4286
- # Category: Notifications
4287
- #
4288
- class ToastAction < NotificationsAction
4289
-
4290
- def initialize(h={})
4291
-
4292
- if h[:msg] then
4293
- h[:message_text] = h[:msg]
4294
- h.delete :msg
4295
- end
4296
-
4297
- options = {
4298
- message_text: '',
4299
- image_resource_name: 'launcher_no_border',
4300
- image_package_name: 'com.arlosoft.macrodroid',
4301
- image_name: 'launcher_no_border',
4302
- duration: 0,
4303
- display_icon: true,
4304
- background_color: -12434878,
4305
- position: 0
4306
- }
4307
-
4308
- super(options.merge h)
4309
-
4310
- end
4311
-
4312
- def invoke()
4313
- super(@h[:message_text])
4314
- end
4315
-
4316
- def to_pc()
4317
- "popup_message '%s'" % @h[:message_text]
4318
- end
4319
-
4320
- def to_s(colour: false)
4321
- "Popup Message\n %s" % @h[:message_text]
4322
- end
4323
-
4324
- end
4325
-
4326
-
4327
- class PhoneAction < Action
4328
-
4329
- def initialize(h={})
4330
- super(h)
4331
- @group = 'phone'
4332
- end
4333
-
4334
- end
4335
-
4336
- # Category: Phone
4337
- #
4338
- class AnswerCallAction < PhoneAction
4339
-
4340
- def initialize(h={})
4341
-
4342
- options = {
4343
- selected_index: 0
4344
- }
4345
-
4346
- super(options.merge h)
4347
-
4348
- end
4349
-
4350
- def to_s(colour: false)
4351
- @s = 'Answer Call' + "\n "
4352
- super()
4353
- end
4354
- end
4355
-
4356
- # Category: Phone
4357
- #
4358
- class ClearCallLogAction < PhoneAction
4359
-
4360
- def initialize(h={})
4361
-
4362
- options = {
4363
- non_contact: false,
4364
- specific_contact: false,
4365
- type: 0
4366
- }
4367
-
4368
- super(options.merge h)
4369
-
4370
- end
4371
-
4372
- def to_s(colour: false)
4373
- 'ClearCallLogAction ' + @h.inspect
4374
- end
4375
-
4376
- alias to_summary to_s
4377
- end
4378
-
4379
- # Category: Phone
4380
- #
4381
- class OpenCallLogAction < PhoneAction
4382
-
4383
- def initialize(h={})
4384
-
4385
- options = {
4386
- }
4387
-
4388
- super(options.merge h)
4389
-
4390
- end
4391
-
4392
- def to_s(colour: false)
4393
- 'OpenCallLogAction ' + @h.inspect
4394
- end
4395
-
4396
- alias to_summary to_s
4397
- end
4398
-
4399
- # Category: Phone
4400
- #
4401
- class RejectCallAction < PhoneAction
4402
-
4403
- def initialize(h={})
4404
-
4405
- options = {
4406
- }
4407
-
4408
- super(options.merge h)
4409
-
4410
- end
4411
-
4412
- def to_s(colour: false)
4413
- @s = 'Call Reject' + "\n "
4414
- super()
4415
- end
4416
-
4417
- end
4418
-
4419
- # Category: Phone
4420
- #
4421
- class MakeCallAction < PhoneAction
4422
-
4423
- def initialize(h={})
4424
-
4425
- options = {
4426
- contact: {:m_id=>"Hardwired_Number", :m_lookupKey=>"Hardwired_Number", :m_name=>"[Select Number]"},
4427
- number: ''
4428
- }
4429
-
4430
- super(options.merge h)
4431
-
4432
- end
4433
-
4434
- def to_s(colour: false)
4435
- 'MakeCallAction ' + @h.inspect
4436
- end
4437
-
4438
- alias to_summary to_s
4439
- end
4440
-
4441
-
4442
- # Category: Phone
4443
- #
4444
- class SetRingtoneAction < PhoneAction
4445
-
4446
- def initialize(h={})
4447
-
4448
- options = {
4449
- ringtone_uri: 'content://media/internal/audio/media/174'
4450
- }
4451
-
4452
- super(options.merge h)
4453
-
4454
- end
4455
-
4456
- def to_s(colour: false)
4457
- 'SetRingtoneAction ' + @h.inspect
4458
- end
4459
-
4460
- alias to_summary to_s
4461
- end
4462
-
4463
- class ScreenAction < Action
4464
-
4465
- def initialize(h={})
4466
- super(h)
4467
- @group = 'screen'
4468
- end
4469
-
4470
- end
4471
-
4472
- # Category: Screen
4473
- #
4474
- class SetBrightnessAction < ScreenAction
4475
-
4476
- def initialize(h={})
4477
-
4478
- options = {
4479
- brightness_percent: 81,
4480
- force_pie_mode: false,
4481
- brightness: 0
4482
- }
4483
-
4484
- super(options.merge h)
4485
-
4486
- end
4487
-
4488
- def to_s(colour: false)
4489
- 'SetBrightnessAction ' + @h.inspect
4490
- end
4491
-
4492
- alias to_summary to_s
4493
- end
4494
-
4495
- # Category: Screen
4496
- #
4497
- class ForceScreenRotationAction < ScreenAction
4498
-
4499
- def initialize(h={})
4500
-
4501
- options = {
4502
- option: 0
4503
- }
4504
-
4505
- super(options.merge h)
4506
-
4507
- end
4508
-
4509
- def to_s(colour: false)
4510
- 'ForceScreenRotationAction ' + @h.inspect
4511
- end
4512
-
4513
- alias to_summary to_s
4514
- end
4515
-
4516
- # Category: Screen
4517
- #
4518
- class ScreenOnAction < ScreenAction
4519
-
4520
- def initialize(h={})
4521
-
4522
- options = {
4523
- pie_lock_screen: false,
4524
- screen_off: true,
4525
- screen_off_no_lock: false,
4526
- screen_on_alternative: false
4527
- }
4528
-
4529
- super(options.merge h)
4530
-
4531
- end
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
4544
- end
4545
-
4546
- # Category: Screen
4547
- #
4548
- class DimScreenAction < ScreenAction
4549
-
4550
- def initialize(h={})
4551
-
4552
- options = {
4553
- percent: 50,
4554
- dim_screen_on: true
4555
- }
4556
-
4557
- super(options.merge h)
4558
-
4559
- end
4560
-
4561
- def to_s(colour: false)
4562
- 'DimScreenAction ' + @h.inspect
4563
- end
4564
-
4565
- alias to_summary to_s
4566
- end
4567
-
4568
- # Category: Screen
4569
- #
4570
- # options:
4571
- # keep awake, screen on => enabled: true
4572
- # disable keep awake => enabled: false
4573
- #
4574
- class KeepAwakeAction < ScreenAction
4575
-
4576
- def initialize(h={})
4577
-
4578
- options = {
4579
- enabled: true,
4580
- permanent: true,
4581
- screen_option: 0,
4582
- seconds_to_stay_awake_for: 0
4583
- }
4584
-
4585
- super(options.merge h)
4586
-
4587
- end
4588
-
4589
- def to_s(colour: false)
4590
-
4591
- screen = @h[:screen_option] == 0 ? 'Screen On' : 'Screen Off'
4592
-
4593
- if @h[:enabled] then
4594
-
4595
- whenx = if @h[:seconds_to_stay_awake_for] == 0 then
4596
-
4597
- 'Until Disabled'
4598
-
4599
- else
4600
- scnds = @h[:seconds_to_stay_awake_for]
4601
- Subunit.new(units={minutes:60, hours:60}, seconds: scnds).strfunit("%x")
4602
- end
4603
-
4604
- "Keep Device Awake\n " + screen + ' - ' + whenx
4605
-
4606
- else
4607
- 'Disable Keep Awake'
4608
- end
4609
-
4610
-
4611
- end
4612
- end
4613
-
4614
- # Category: Screen
4615
- #
4616
- class SetScreenTimeoutAction < ScreenAction
4617
-
4618
- def initialize(h={})
4619
-
4620
- options = {
4621
- timeout_delay_string: '1 Minute',
4622
- timeout_delay: 60,
4623
- custom_value_delay: 0
4624
- }
4625
-
4626
- super(options.merge h)
4627
-
4628
- end
4629
-
4630
- def to_s(colour: false)
4631
- 'SetScreenTimeoutAction ' + @h.inspect
4632
- end
4633
-
4634
- alias to_summary to_s
4635
- end
4636
-
4637
-
4638
- class VolumeAction < Action
4639
-
4640
- def initialize(h={})
4641
- super(h)
4642
- @group = 'volume'
4643
- end
4644
-
4645
- end
4646
-
4647
- # Category: Volume
4648
- #
4649
- class SilentModeVibrateOffAction < VolumeAction
4650
-
4651
- def initialize(h={})
4652
-
4653
- options = {
4654
- option: 1
4655
- }
4656
-
4657
- super(options.merge h)
4658
-
4659
- end
4660
-
4661
- def to_s(colour: false)
4662
- 'SilentModeVibrateOffAction ' + @h.inspect
4663
- end
4664
-
4665
- alias to_summary to_s
4666
- end
4667
-
4668
- # Category: Volume
4669
- #
4670
- class SetVibrateAction < VolumeAction
4671
-
4672
- def initialize(h={})
4673
-
4674
- options = {
4675
- option: 'Silent (Vibrate On)',
4676
- option_int: -1
4677
- }
4678
-
4679
- super(options.merge h)
4680
-
4681
- end
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
4704
- end
4705
-
4706
- # Category: Volume
4707
- #
4708
- class VolumeIncrementDecrementAction < VolumeAction
4709
-
4710
- def initialize(h={})
4711
-
4712
- options = {
4713
- volume_up: true
4714
- }
4715
-
4716
- super(options.merge h)
4717
-
4718
- end
4719
-
4720
- def to_s(colour: false)
4721
- 'VolumeIncrementDecrementAction ' + @h.inspect
4722
- end
4723
-
4724
- alias to_summary to_s
4725
- end
4726
-
4727
- # Category: Volume
4728
- #
4729
- class SpeakerPhoneAction < VolumeAction
4730
-
4731
- def initialize(h={})
4732
-
4733
- options = {
4734
- secondary_class_type: 'SpeakerPhoneAction',
4735
- state: 0
4736
- }
4737
-
4738
- super(options.merge h)
4739
-
4740
- end
4741
-
4742
- def to_s(colour: false)
4743
- 'SpeakerPhoneAction ' + @h.inspect
4744
- end
4745
-
4746
- alias to_summary to_s
4747
- end
4748
-
4749
- # Category: Volume
4750
- #
4751
- class SetVolumeAction < VolumeAction
4752
-
4753
- def initialize(h={})
4754
-
4755
- options = {
4756
- variables: [nil, nil, nil, nil, nil, nil, nil],
4757
- stream_index_array: [false, false, false, false, false, false, true],
4758
- stream_volume_array: [0, 0, 0, 0, 0, 0, 66],
4759
- force_vibrate_off: false,
4760
- volume: -1
4761
- }
4762
-
4763
- super(options.merge h)
4764
-
4765
- end
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
4771
- end
4772
-
4773
- class Constraint < MacroObject
4774
-
4775
- def initialize(h={})
4776
- super(h)
4777
- end
4778
-
4779
- def match?(detail={}, model=nil)
4780
-
4781
- detail.select {|k,v| @h.include? k }.all? {|key,value| @h[key] == value}
4782
-
4783
- end
4784
-
4785
- #def to_s()
4786
- # ''
4787
- #end
4788
-
4789
- protected
4790
-
4791
- def toggle_match?(key, val)
4792
-
4793
- if @h[key] == true and val == key.to_s then
4794
- true
4795
- elsif @h[key] == false and val != key.to_s
4796
- true
4797
- else
4798
- false
4799
- end
4800
-
4801
- end
4802
-
4803
- end
4804
-
4805
-
4806
-
4807
- # Category: Battery/Power
4808
- #
4809
- class BatteryLevelConstraint < Constraint
4810
-
4811
- def initialize(h={})
4812
-
4813
- options = {
4814
- battery_level: 23,
4815
- equals: false,
4816
- greater_than: false
4817
- }
4818
-
4819
- super(options.merge h)
4820
-
4821
- end
4822
-
4823
- def to_s(colour: false)
4824
-
4825
- operator = if @h[:greater_than] then
4826
- '>'
4827
- elsif @h[:equals]
4828
- '='
4829
- else
4830
- '<'
4831
- end
4832
-
4833
- level = @h[:battery_level]
4834
-
4835
- "Battery %s %s%%" % [operator, level]
4836
- end
4837
-
4838
- alias to_summary to_s
4839
-
4840
- end
4841
-
4842
- # Category: Battery/Power
4843
- #
4844
- class BatterySaverStateConstraint < Constraint
4845
-
4846
- def initialize(h={})
4847
-
4848
- options = {
4849
- option: 0
4850
- }
4851
-
4852
- super(options.merge h)
4853
-
4854
- end
4855
-
4856
- def to_s(colour: false)
4857
- 'BatterySaverStateConstraint ' + @h.inspect
4858
- end
4859
-
4860
- alias to_summary to_s
4861
- end
4862
-
4863
- # Category: Battery/Power
4864
- #
4865
- class BatteryTemperatureConstraint < Constraint
4866
-
4867
- def initialize(h={})
4868
-
4869
- options = {
4870
- equals: false,
4871
- greater_than: false,
4872
- temperature: 30
4873
- }
4874
-
4875
- super(options.merge h)
4876
-
4877
- end
4878
-
4879
- def to_s(colour: false)
4880
- 'BatteryTemperatureConstraint ' + @h.inspect
4881
- end
4882
-
4883
- alias to_summary to_s
4884
- end
4885
-
4886
- # Category: Battery/Power
4887
- #
4888
- class ExternalPowerConstraint < Constraint
4889
-
4890
- def initialize(h={})
4891
-
4892
- options = {
4893
- external_power: true,
4894
- power_connected_options: [false, true, false]
4895
- }
4896
-
4897
- super(options.merge h)
4898
-
4899
- end
4900
-
4901
- def to_s(colour: false)
4902
- connection = @h[:external_power] ? 'Connected' : 'Disconnected'
4903
- 'Power ' + connection
4904
- end
4905
-
4906
- end
4907
-
4908
- # Category: Connectivity
4909
- #
4910
- class BluetoothConstraint < Constraint
4911
-
4912
- def initialize(h={})
4913
-
4914
- options = {
4915
- any_device: false,
4916
- bt_state: 0,
4917
- device_name: 'Any Device'
4918
- }
4919
-
4920
- super(options.merge h)
4921
-
4922
- end
4923
-
4924
- def to_s(colour: false)
4925
- device = @h[:device_name] #== 'Any Device' ? 'Any' : @h[:device_name]
4926
- "Device Connected\n %s" % device
4927
- end
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
4933
-
4934
- end
4935
-
4936
- # Category: Connectivity
4937
- #
4938
- class GPSEnabledConstraint < Constraint
4939
-
4940
- def initialize(h={})
4941
-
4942
- options = {
4943
- enabled: true
4944
- }
4945
-
4946
- super(options.merge h)
4947
-
4948
- end
4949
-
4950
- def to_s(colour: false)
4951
- 'GPSEnabledConstraint ' + @h.inspect
4952
- end
4953
-
4954
- alias to_summary to_s
4955
- end
4956
-
4957
- # Category: Connectivity
4958
- #
4959
- class LocationModeConstraint < Constraint
4960
-
4961
- def initialize(h={})
4962
-
4963
- options = {
4964
- options: [false, false, false, true]
4965
- }
4966
-
4967
- super(options.merge h)
4968
-
4969
- end
4970
-
4971
- def to_s(colour: false)
4972
- 'LocationModeConstraint ' + @h.inspect
4973
- end
4974
-
4975
- alias to_summary to_s
4976
- end
4977
-
4978
- # Category: Connectivity
4979
- #
4980
- class SignalOnOffConstraint < Constraint
4981
-
4982
- def initialize(h={})
4983
-
4984
- options = {
4985
- option: 0
4986
- }
4987
-
4988
- super(options.merge h)
4989
-
4990
- end
4991
-
4992
- def to_s(colour: false)
4993
- 'SignalOnOffConstraint ' + @h.inspect
4994
- end
4995
-
4996
- alias to_summary to_s
4997
- end
4998
-
4999
- # Category: Connectivity
5000
- #
5001
- class WifiConstraint < Constraint
5002
-
5003
- def initialize(h={})
5004
-
5005
- options = {
5006
- ssid_list: [],
5007
- wifi_state: 0
5008
- }
5009
-
5010
- super(options.merge h)
5011
-
5012
- end
5013
-
5014
- def to_s(colour: false)
5015
- 'WifiConstraint ' + @h.inspect
5016
- end
5017
-
5018
- alias to_summary to_s
5019
- end
5020
-
5021
- # Category: Connectivity
5022
- #
5023
- class CellTowerConstraint < Constraint
5024
-
5025
- def initialize(h={})
5026
-
5027
- options = {
5028
- cell_group_name: 'test group',
5029
- cell_ids: ["524,14,41070731"],
5030
- in_range: true
5031
- }
5032
-
5033
- super(options.merge h)
5034
-
5035
- end
5036
-
5037
- def to_s(colour: false)
5038
- 'CellTowerConstraint ' + @h.inspect
5039
- end
5040
-
5041
- alias to_summary to_s
5042
- end
5043
-
5044
- # Category: Connectivity
5045
- #
5046
- class IsRoamingConstraint < Constraint
5047
-
5048
- def initialize(h={})
5049
-
5050
- options = {
5051
- is_roaming: true
5052
- }
5053
-
5054
- super(options.merge h)
5055
-
5056
- end
5057
-
5058
- def to_s(colour: false)
5059
- 'IsRoamingConstraint ' + @h.inspect
5060
- end
5061
-
5062
- alias to_summary to_s
5063
- end
5064
-
5065
- # Category: Connectivity
5066
- #
5067
- class DataOnOffConstraint < Constraint
5068
-
5069
- def initialize(h={})
5070
-
5071
- options = {
5072
- data_on: true
5073
- }
5074
-
5075
- super(options.merge h)
5076
-
5077
- end
5078
-
5079
- def to_s(colour: false)
5080
- 'DataOnOffConstraint ' + @h.inspect
5081
- end
5082
-
5083
- alias to_summary to_s
5084
- end
5085
-
5086
- # Category: Connectivity
5087
- #
5088
- class WifiHotSpotConstraint < Constraint
5089
-
5090
- def initialize(h={})
5091
-
5092
- options = {
5093
- check_connections: false,
5094
- comparison_value: 0,
5095
- connected_count: 0,
5096
- enabled: true
5097
- }
5098
-
5099
- super(options.merge h)
5100
-
5101
- end
5102
-
5103
- def to_s(colour: false)
5104
- 'WifiHotSpotConstraint ' + @h.inspect
5105
- end
5106
-
5107
- alias to_summary to_s
5108
- end
5109
-
5110
- # Category: Date/Time
5111
- #
5112
- class CalendarConstraint < Constraint
5113
-
5114
- def initialize(h={})
5115
-
5116
- options = {
5117
- enable_regex: false,
5118
- availability: 0,
5119
- calendar_id: '1',
5120
- calendar_name: 'PC Sync',
5121
- detail_text: '',
5122
- entry_set: true,
5123
- ignore_all_day: false,
5124
- title_text: ''
5125
- }
5126
-
5127
- super(options.merge h)
5128
-
5129
- end
5130
-
5131
- def to_s(colour: false)
5132
- 'CalendarConstraint ' + @h.inspect
5133
- end
5134
-
5135
- alias to_summary to_s
5136
- end
5137
-
5138
- # Category: Date/Time
5139
- #
5140
- class DayOfWeekConstraint < Constraint
5141
-
5142
- def initialize(h={})
5143
-
5144
- options = {
5145
- days_of_week: [false, false, true, false, false, false, false]
5146
- }
5147
-
5148
- super(options.merge h)
5149
-
5150
- end
5151
-
5152
- def to_s(colour: false)
5153
- 'DayOfWeekConstraint ' + @h.inspect
5154
- end
5155
-
5156
- alias to_summary to_s
5157
- end
5158
-
5159
- # Category: Date/Time
5160
- #
5161
- class TimeOfDayConstraint < Constraint
5162
-
5163
- def initialize(h={})
5164
-
5165
- options = {
5166
- end_hour: 8,
5167
- end_minute: 0,
5168
- start_hour: 22,
5169
- start_minute: 0
5170
- }
5171
-
5172
- super(options.merge h)
5173
-
5174
- end
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
5182
- end
5183
-
5184
- # Category: Date/Time
5185
- #
5186
- class DayOfMonthConstraint < Constraint
5187
-
5188
- def initialize(h={})
5189
-
5190
- options = {
5191
- day_names: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31"],
5192
- days_of_month: [false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]
5193
- }
5194
-
5195
- super(options.merge h)
5196
-
5197
- end
5198
-
5199
- def to_s(colour: false)
5200
- 'DayOfMonthConstraint ' + @h.inspect
5201
- end
5202
-
5203
- alias to_summary to_s
5204
- end
5205
-
5206
- # Category: Date/Time
5207
- #
5208
- class MonthOfYearConstraint < Constraint
5209
-
5210
- def initialize(h={})
5211
-
5212
- options = {
5213
- months: [false, false, false, false, false, false, false, true, false, false, false, false]
5214
- }
5215
-
5216
- super(options.merge h)
5217
-
5218
- end
5219
-
5220
- def to_s(colour: false)
5221
- 'MonthOfYearConstraint ' + @h.inspect
5222
- end
5223
-
5224
- alias to_summary to_s
5225
- end
5226
-
5227
- # Category: Date/Time
5228
- #
5229
- class SunsetSunriseConstraint < Constraint
5230
-
5231
- def initialize(h={})
5232
-
5233
- options = {
5234
- option: 0
5235
- }
5236
-
5237
- super(options.merge h)
5238
-
5239
- end
5240
-
5241
- def to_s(colour: false)
5242
- 'SunsetSunriseConstraint ' + @h.inspect
5243
- end
5244
-
5245
- alias to_summary to_s
5246
- end
5247
-
5248
- # Category: Device State
5249
- #
5250
- class AirplaneModeConstraint < Constraint
5251
-
5252
- def initialize(h={})
5253
-
5254
- options = {
5255
- enabled: true
5256
- }
5257
-
5258
- super(options.merge h)
5259
-
5260
- end
5261
-
5262
- def match?(detail={}, model=nil)
5263
-
5264
- puts 'inside airplaneModeConstraint#match?' if $debug
5265
-
5266
- if detail.has_key? :enabled then
5267
-
5268
- puts 'detail has the key' if $debug
5269
- super(detail)
5270
-
5271
- elsif model
5272
-
5273
- if $debug then
5274
- puts 'checking the model'
5275
- switch = model.connectivity.airplane_mode.switch
5276
- puts 'switch: ' + switch.inspect
5277
- end
5278
-
5279
- toggle_match?(:enabled, switch)
5280
-
5281
- end
5282
-
5283
- end
5284
-
5285
- def to_pc()
5286
- status = @h[:enabled] ? 'enabled?' : 'disabled?'
5287
- 'airplane_mode.' + status
5288
- end
5289
-
5290
- def to_s(colour: false)
5291
-
5292
- status = @h[:enabled] ? 'Enabled' : 'Disabled'
5293
- 'Airplane Mode ' + status
5294
-
5295
- end
5296
-
5297
- alias to_summary to_s
5298
-
5299
- end
5300
-
5301
- # Category: Device State
5302
- #
5303
- class AutoRotateConstraint < Constraint
5304
-
5305
- def initialize(h={})
5306
-
5307
- options = {
5308
- enabled: true
5309
- }
5310
-
5311
- super(options.merge h)
5312
-
5313
- end
5314
-
5315
- def to_s(colour: false)
5316
- 'AutoRotateConstraint ' + @h.inspect
5317
- end
5318
-
5319
- alias to_summary to_s
5320
- end
5321
-
5322
- # Category: Device State
5323
- #
5324
- class DeviceLockedConstraint < Constraint
5325
-
5326
- def initialize(h={})
5327
-
5328
- options = {
5329
- locked: true
5330
- }
5331
-
5332
- super(options.merge h)
5333
-
5334
- end
5335
-
5336
- def to_s(colour: false)
5337
- 'Device ' + (@h[:locked] ? 'Locked' : 'Unlocked')
5338
- end
5339
-
5340
- alias to_summary to_s
5341
-
5342
- end
5343
-
5344
- # Category: Device State
5345
- #
5346
- class RoamingOnOffConstraint < Constraint
5347
-
5348
- def initialize(h={})
5349
-
5350
- options = {
5351
- roaming_on: true
5352
- }
5353
-
5354
- super(options.merge h)
5355
-
5356
- end
5357
-
5358
- def to_s(colour: false)
5359
- 'RoamingOnOffConstraint ' + @h.inspect
5360
- end
5361
-
5362
- alias to_summary to_s
5363
- end
5364
-
5365
- # Category: Device State
5366
- #
5367
- class TimeSinceBootConstraint < Constraint
5368
-
5369
- def initialize(h={})
5370
-
5371
- options = {
5372
- less_than: true,
5373
- time_period_seconds: 10921
5374
- }
5375
-
5376
- super(options.merge h)
5377
-
5378
- end
5379
-
5380
- def to_s(colour: false)
5381
- 'TimeSinceBootConstraint ' + @h.inspect
5382
- end
5383
-
5384
- alias to_summary to_s
5385
- end
5386
-
5387
- # Category: Device State
5388
- #
5389
- class AutoSyncConstraint < Constraint
5390
-
5391
- def initialize(h={})
5392
-
5393
- options = {
5394
- enabled: false
5395
- }
5396
-
5397
- super(options.merge h)
5398
-
5399
- end
5400
-
5401
- def to_s(colour: false)
5402
- 'AutoSyncConstraint ' + @h.inspect
5403
- end
5404
-
5405
- alias to_summary to_s
5406
- end
5407
-
5408
- # Category: Device State
5409
- #
5410
- class NFCStateConstraint < Constraint
5411
-
5412
- def initialize(h={})
5413
-
5414
- options = {
5415
- enabled: true
5416
- }
5417
-
5418
- super(options.merge h)
5419
-
5420
- end
5421
-
5422
- def to_s(colour: false)
5423
- 'NFCStateConstraint ' + @h.inspect
5424
- end
5425
-
5426
- alias to_summary to_s
5427
- end
5428
-
5429
- # Category: Device State
5430
- #
5431
- class IsRootedConstraint < Constraint
5432
-
5433
- def initialize(h={})
5434
-
5435
- options = {
5436
- rooted: true
5437
- }
5438
-
5439
- super(options.merge h)
5440
-
5441
- end
5442
-
5443
- def to_s(colour: false)
5444
- 'IsRootedConstraint ' + @h.inspect
5445
- end
5446
-
5447
- alias to_summary to_s
5448
- end
5449
-
5450
- # Category: Device State
5451
- #
5452
- class VpnConstraint < Constraint
5453
-
5454
- def initialize(h={})
5455
-
5456
- options = {
5457
- option: 0
5458
- }
5459
-
5460
- super(options.merge h)
5461
-
5462
- end
5463
-
5464
- def to_s(colour: false)
5465
- 'VpnConstraint ' + @h.inspect
5466
- end
5467
-
5468
- alias to_summary to_s
5469
- end
5470
-
5471
- # Category: MacroDroid Specific
5472
- #
5473
- class MacroEnabledConstraint < Constraint
5474
-
5475
- def initialize(h={})
5476
-
5477
- options = {
5478
- enabled: true,
5479
- macro_ids: [-8016812002629322290],
5480
- macro_names: ["Intruder photo "]
5481
- }
5482
-
5483
- super(options.merge h)
5484
-
5485
- end
5486
-
5487
- def to_s(colour: false)
5488
- 'MacroEnabledConstraint ' + @h.inspect
5489
- end
5490
-
5491
- alias to_summary to_s
5492
- end
5493
-
5494
- # Category: MacroDroid Specific
5495
- #
5496
- class ModeConstraint < Constraint
5497
-
5498
- def initialize(h={})
5499
-
5500
- options = {
5501
- mode: 'Away',
5502
- mode_selected: true
5503
- }
5504
-
5505
- super(options.merge h)
5506
-
5507
- end
5508
-
5509
- def to_s(colour: false)
5510
- 'ModeConstraint ' + @h.inspect
5511
- end
5512
-
5513
- alias to_summary to_s
5514
- end
5515
-
5516
- # Category: MacroDroid Specific
5517
- #
5518
- class TriggerThatInvokedConstraint < Constraint
5519
- using ColouredText
5520
-
5521
- def initialize(h={})
5522
-
5523
- puts ('h: ' + h.inspect).green
5524
- @trigger = h[:macro].triggers.find {|x| x.siguid == h[:si_guid_that_invoked] }
5525
-
5526
- options = {
5527
- not: false,
5528
- si_guid_that_invoked: -4951291100076165433,
5529
- trigger_name: 'Shake Device'
5530
- }
5531
-
5532
- #super(options.merge filter(options,h))
5533
- super(options.merge h)
5534
-
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
5549
-
5550
- end
5551
-
5552
- # Category: MacroDroid Specific
5553
- #
5554
- class LastRunTimeConstraint < Constraint
5555
-
5556
- def initialize(h={})
5557
-
5558
- options = {
5559
- check_this_macro: false,
5560
- invoked: true,
5561
- macro_ids: [-6922688338672048267],
5562
- macro_names: ["Opendoor"],
5563
- time_period_seconds: 7260
5564
- }
5565
-
5566
- super(options.merge h)
5567
-
5568
- end
5569
-
5570
- def to_s(colour: false)
5571
- 'LastRunTimeConstraint ' + @h.inspect
5572
- end
5573
-
5574
- alias to_summary to_s
5575
- end
5576
-
5577
- # Category: Media
5578
- #
5579
- class HeadphonesConnectionConstraint < Constraint
5580
-
5581
- def initialize(h={})
5582
-
5583
- options = {
5584
- connected: true
5585
- }
5586
-
5587
- super(options.merge h)
5588
-
5589
- end
5590
-
5591
- def to_s(colour: false)
5592
- connection = @h[:connected] ? 'Connected' : 'Disconnected'
5593
- 'Headphones ' + connection
5594
- end
5595
-
5596
- alias to_summary to_s
5597
-
5598
- end
5599
-
5600
- # Category: Media
5601
- #
5602
- class MusicActiveConstraint < Constraint
5603
-
5604
- def initialize(h={})
5605
-
5606
- options = {
5607
- music_active: true
5608
- }
5609
-
5610
- super(options.merge h)
5611
-
5612
- end
5613
-
5614
- def to_s(colour: false)
5615
- 'MusicActiveConstraint ' + @h.inspect
5616
- end
5617
-
5618
- alias to_summary to_s
5619
- end
5620
-
5621
- # Category: Notification
5622
- #
5623
- class NotificationPresentConstraint < Constraint
5624
-
5625
- def initialize(h={})
5626
-
5627
- options = {
5628
- enable_regex: false,
5629
- application_name_list: ["All applications"],
5630
- exact_match: false,
5631
- excludes: false,
5632
- excludes_apps: -1,
5633
- option: 0,
5634
- package_name_list: ["allApplications"],
5635
- text_content: ''
5636
- }
5637
-
5638
- super(options.merge h)
5639
-
5640
- end
5641
-
5642
- def to_s(colour: false)
5643
- 'NotificationPresentConstraint ' + @h.inspect
5644
- end
5645
-
5646
- alias to_summary to_s
5647
- end
5648
-
5649
- # Category: Notification
5650
- #
5651
- class PriorityModeConstraint < Constraint
5652
-
5653
- def initialize(h={})
5654
-
5655
- options = {
5656
- in_mode: true,
5657
- selected_index: 0
5658
- }
5659
-
5660
- super(options.merge h)
5661
-
5662
- end
5663
-
5664
- def to_s(colour: false)
5665
- 'PriorityModeConstraint ' + @h.inspect
5666
- end
5667
-
5668
- alias to_summary to_s
5669
- end
5670
-
5671
- # Category: Notification
5672
- #
5673
- class NotificationVolumeConstraint < Constraint
5674
-
5675
- def initialize(h={})
5676
-
5677
- options = {
5678
- option: 1
5679
- }
5680
-
5681
- super(options.merge h)
5682
-
5683
- end
5684
-
5685
- def to_s(colour: false)
5686
- 'NotificationVolumeConstraint ' + @h.inspect
5687
- end
5688
-
5689
- alias to_summary to_s
5690
- end
5691
-
5692
- # Category: Phone
5693
- #
5694
- class InCallConstraint < Constraint
5695
-
5696
- def initialize(h={})
5697
-
5698
- options = {
5699
- in_call: true
5700
- }
5701
-
5702
- super(options.merge h)
5703
-
5704
- end
5705
-
5706
- def to_s(colour: false)
5707
- 'InCallConstraint ' + @h.inspect
5708
- end
5709
-
5710
- alias to_summary to_s
5711
- end
5712
-
5713
- # Category: Phone
5714
- #
5715
- class PhoneRingingConstraint < Constraint
5716
-
5717
- def initialize(h={})
5718
-
5719
- options = {
5720
- ringing: true
5721
- }
5722
-
5723
- super(options.merge h)
5724
-
5725
- end
5726
-
5727
- def to_s(colour: false)
5728
- @s = @h[:ringing] ? 'Phone Ringing' : 'Not Ringing'
5729
- super(colour: colour)
5730
- end
5731
-
5732
- end
5733
-
5734
- # Category: Screen and Speaker
5735
- #
5736
- class BrightnessConstraint < Constraint
5737
-
5738
- def initialize(h={})
5739
-
5740
- options = {
5741
- brightness: 35,
5742
- equals: false,
5743
- force_pie_mode: false,
5744
- greater_than: false,
5745
- is_auto_brightness: false
5746
- }
5747
-
5748
- super(options.merge h)
5749
-
5750
- end
5751
-
5752
- def to_s(colour: false)
5753
- 'BrightnessConstraint ' + @h.inspect
5754
- end
5755
-
5756
- alias to_summary to_s
5757
- end
5758
-
5759
- # Category: Screen and Speaker
5760
- #
5761
- class VolumeConstraint < Constraint
5762
-
5763
- def initialize(h={})
5764
-
5765
- options = {
5766
- option: 0
5767
- }
5768
-
5769
- super(options.merge filter(options, h))
5770
-
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
5778
-
5779
- end
5780
-
5781
- # Category: Screen and Speaker
5782
- #
5783
- class SpeakerPhoneConstraint < Constraint
5784
-
5785
- def initialize(h={})
5786
-
5787
- options = {
5788
- enabled: true
5789
- }
5790
-
5791
- super(options.merge h)
5792
-
5793
- end
5794
-
5795
- def to_s(colour: false)
5796
- 'SpeakerPhoneConstraint ' + @h.inspect
5797
- end
5798
-
5799
- alias to_summary to_s
5800
- end
5801
-
5802
- # Category: Screen and Speaker
5803
- #
5804
- class DarkThemeConstraint < Constraint
5805
-
5806
- def initialize(h={})
5807
-
5808
- options = {
5809
- option: 0
5810
- }
5811
-
5812
- super(options.merge h)
5813
-
5814
- end
5815
-
5816
- def to_s(colour: false)
5817
- 'DarkThemeConstraint ' + @h.inspect
5818
- end
5819
-
5820
- alias to_summary to_s
5821
- end
5822
-
5823
- # Category: Screen and Speaker
5824
- #
5825
- class ScreenOnOffConstraint < Constraint
5826
-
5827
- def initialize(h={})
5828
-
5829
- options = {
5830
- a: true,
5831
- screen_on: true
5832
- }
5833
-
5834
- super(options.merge h)
5835
-
5836
- end
5837
-
5838
- def to_s(colour: false)
5839
- 'Screen ' + (@h[:screen_on] ? 'On' : 'Off')
5840
- end
5841
-
5842
- alias to_summary to_s
5843
-
5844
- end
5845
-
5846
- # Category: Screen and Speaker
5847
- #
5848
- class VolumeLevelConstraint < Constraint
5849
-
5850
- def initialize(h={})
5851
-
5852
- options = {
5853
- comparison: 0,
5854
- stream_index_array: [false, true, false, false, false, false, false],
5855
- volume: 42
5856
- }
5857
-
5858
- super(options.merge h)
5859
-
5860
- end
5861
-
5862
- def to_s(colour: false)
5863
- 'VolumeLevelConstraint ' + @h.inspect
5864
- end
5865
-
5866
- alias to_summary to_s
5867
- end
5868
-
5869
- # Category: Sensors
5870
- #
5871
- class FaceUpDownConstraint < Constraint
5872
-
5873
- def initialize(h={})
5874
-
5875
- options = {
5876
- option: -1,
5877
- selected_options: [true, false, true, false, false, false]
5878
- }
5879
-
5880
- super(options.merge h)
5881
-
5882
- end
5883
-
5884
- def to_s(colour: false)
5885
- 'FaceUpDownConstraint ' + @h.inspect
5886
- end
5887
-
5888
- alias to_summary to_s
5889
- end
5890
-
5891
- # Category: Sensors
5892
- #
5893
- class LightLevelConstraint < Constraint
5894
-
5895
- def initialize(h={})
5896
-
5897
- options = {
5898
- light_level: -1,
5899
- light_level_float: 5000.0,
5900
- option: 1
5901
- }
5902
-
5903
- super(options.merge h)
5904
-
5905
- end
5906
-
5907
- def to_s(colour: false)
5908
-
5909
- operator = @h[:light_level] == -1 ? 'Less than' : 'Greater than'
5910
- condition = operator + ' ' + @h[:light_level_float].to_s + 'lx'
5911
- 'Light Sensor ' + condition
5912
-
5913
- end
5914
-
5915
- end
5916
-
5917
- # Category: Sensors
5918
- #
5919
- class DeviceOrientationConstraint < Constraint
5920
-
5921
- def initialize(h={})
5922
-
5923
- options = {
5924
- portrait: true
5925
- }
5926
-
5927
- super(options.merge h)
5928
-
5929
- end
5930
-
5931
- def to_s(colour: false)
5932
- 'DeviceOrientationConstraint ' + @h.inspect
5933
- end
5934
-
5935
- alias to_summary to_s
5936
- end
5937
-
5938
- # Category: Sensors
5939
- #
5940
- class ProximitySensorConstraint < Constraint
5941
-
5942
- def initialize(h={})
5943
-
5944
- options = {
5945
- near: true
5946
- }
5947
-
5948
- super(options.merge h)
5949
-
5950
- end
5951
-
5952
- def to_s(colour: false)
5953
- 'Proximity Sensor: ' + (@h[:near] ? 'Near' : 'Far')
5954
- end
5955
-
5956
- end
5957
1036
 
5958
1037
 
5959
1038
  # ----------------------------------------------------------------------------