ruby-macrodroid 0.8.4 → 0.8.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -53,59 +53,10 @@ class Action < MacroObject
53
53
  "%s/%s: %s" % [@group, @type, s]
54
54
  end
55
55
 
56
- def to_s(colour: false)
57
-
58
- h = @h.clone
59
- h.delete :macro
60
- @s ||= "#<%s %s>" % [self.class, h.inspect]
61
- operator = @h[:is_or_condition] ? 'OR' : 'AND'
62
- constraints = @constraints.map \
63
- {|x| x.to_summary(colour: colour)}.join(" %s " % operator)
64
-
65
- @s + constraints
66
-
67
- end
68
56
 
69
57
  end
70
58
 
71
59
 
72
- class LocationAction < Action
73
-
74
- def initialize(h={})
75
- super(h)
76
- @group = 'location'
77
- end
78
-
79
- end
80
-
81
- # Category: Location
82
- #
83
- class ShareLocationAction < LocationAction
84
-
85
- def initialize(h={})
86
-
87
- super()
88
-
89
- options = {
90
- email: '',
91
- variable: {:m_stringValue=>"", :m_name=>"",
92
- :m_decimalValue=>0.0, :isLocal=>true, :m_booleanValue=>false,
93
- :excludeFromLog=>false, :m_intValue=>0, :m_type=>2},
94
- sim_id: 0,
95
- output_channel: 5,
96
- old_variable_format: true
97
- }
98
-
99
- super(options.merge h)
100
-
101
- end
102
-
103
- def to_s(colour: false)
104
- 'ShareLocationAction ' + @h.inspect
105
- end
106
-
107
- alias to_summary to_s
108
- end
109
60
 
110
61
 
111
62
  class ApplicationAction < Action
@@ -134,7 +85,7 @@ class LaunchActivityAction < ApplicationAction
134
85
 
135
86
  end
136
87
 
137
- def to_s(colour: false)
88
+ def to_s(colour: false, indent: 0)
138
89
  'Launch ' + @h[:application_name]
139
90
  end
140
91
 
@@ -155,7 +106,7 @@ class KillBackgroundAppAction < ApplicationAction
155
106
 
156
107
  end
157
108
 
158
- def to_s(colour: false)
109
+ def to_s(colour: false, indent: 0)
159
110
  'KillBackgroundAppAction ' + @h.inspect
160
111
  end
161
112
 
@@ -176,8 +127,8 @@ class LaunchShortcutAction < ApplicationAction
176
127
 
177
128
  end
178
129
 
179
- def to_s(colour: false)
180
- @s = "Launch Shortcut: " + @h[:app_name] + "\n " + @h[:name]
130
+ def to_s(colour: false, indent: 0)
131
+ @s = "Launch Shortcut: " + @h[:app_name] + "\n" + @h[:name]
181
132
  super()
182
133
  end
183
134
 
@@ -205,8 +156,9 @@ class OpenWebPageAction < ApplicationAction
205
156
 
206
157
  end
207
158
 
208
- def to_s(colour: false)
209
- "HTTP GET\n url: " + @h[:url_to_open]
159
+ def to_s(colour: false, indent: 0)
160
+ @s = "HTTP GET\nurl: " + @h[:url_to_open]
161
+ super()
210
162
  end
211
163
 
212
164
  end
@@ -236,7 +188,7 @@ class UploadPhotoAction < CameraAction
236
188
 
237
189
  end
238
190
 
239
- def to_s(colour: false)
191
+ def to_s(colour: false, indent: 0)
240
192
  'UploadPhotoAction ' + @h.inspect
241
193
  end
242
194
 
@@ -266,7 +218,7 @@ class TakePictureAction < CameraAction
266
218
  'take_photo :' + camera.to_s
267
219
  end
268
220
 
269
- def to_s(colour: false)
221
+ def to_s(colour: false, indent: 0)
270
222
  'Take Picture'
271
223
  end
272
224
 
@@ -293,7 +245,7 @@ class IfConfirmedThenAction < Action
293
245
 
294
246
  end
295
247
 
296
- def to_s(colour: false)
248
+ def to_s(colour: false, indent: 0)
297
249
 
298
250
  @s = "If Confirmed Then " #+ @constraints.map(&:to_s).join(" %s " % operator)
299
251
  super(colour: colour)
@@ -315,16 +267,26 @@ class LoopAction < Action
315
267
 
316
268
  super(h2)
317
269
 
318
- @label = 'WHILE / DO '
270
+ @label = 'DO / WHILE '
319
271
 
320
272
  end
321
273
 
322
- def to_s(colour: false)
274
+ def to_s(colour: false, indent: 0)
323
275
 
324
- @s = 'WHILE / DO '
325
- super()
276
+ h = @h.clone
277
+ h.delete :macro
278
+ @s = 'DO / WHILE '
279
+ operator = @h[:is_or_condition] ? 'OR' : 'AND'
280
+ constraints = @constraints.map \
281
+ {|x| ' ' * indent + x.to_summary(colour: colour)}.join(" %s " % operator)
326
282
 
327
- end
283
+ out = []
284
+ out << "; %s" % @h[:comment] if @h[:comment]
285
+ s = @s.lines.map {|x| (' ' * indent) + x}.join
286
+ out << s + constraints
287
+ out.join("\n")
288
+
289
+ end
328
290
  end
329
291
 
330
292
  # Conditions/Loops
@@ -345,7 +307,7 @@ class EndLoopAction < Action
345
307
 
346
308
  end
347
309
 
348
- def to_s(colour: false)
310
+ def to_s(colour: false, indent: 0)
349
311
 
350
312
  'End Loop '
351
313
 
@@ -356,7 +318,14 @@ end
356
318
  #
357
319
  class IfConditionAction < Action
358
320
 
359
- def initialize(h={})
321
+ def initialize(obj=nil)
322
+
323
+ h = if obj.is_a? Hash then
324
+ obj
325
+ else
326
+ # get the constraints
327
+
328
+ end
360
329
 
361
330
  options = {
362
331
  a: true,
@@ -372,12 +341,22 @@ class IfConditionAction < Action
372
341
 
373
342
  end
374
343
 
375
- def to_s(colour: false)
344
+ def to_s(colour: false, indent: 0)
376
345
 
377
- @s = "If " #+ @constraints.map(&:to_s).join(" %s " % operator)
378
- super(colour: colour)
346
+ h = @h.clone
347
+ h.delete :macro
348
+ @s = 'If '
349
+ operator = @h[:is_or_condition] ? 'OR' : 'AND'
350
+ constraints = @constraints.map \
351
+ {|x| ' ' * indent + x.to_summary(colour: colour)}.join(" %s " % operator)
379
352
 
380
- end
353
+ out = []
354
+ out << "; %s" % @h[:comment] if @h[:comment]
355
+ s = @s.lines.map {|x| (' ' * indent) + x}.join
356
+ out << s + constraints
357
+ out.join("\n")
358
+
359
+ end
381
360
  end
382
361
 
383
362
  class ElseAction < Action
@@ -393,7 +372,7 @@ class ElseAction < Action
393
372
 
394
373
  end
395
374
 
396
- def to_s(colour: false)
375
+ def to_s(colour: false, indent: 0)
397
376
  'Else'
398
377
  end
399
378
 
@@ -412,9 +391,25 @@ class ElseIfConditionAction < Action
412
391
 
413
392
  end
414
393
 
415
- def to_s(colour: false)
394
+ def to_s(colour: false, indent: 0)
395
+
396
+ h = @h.clone
397
+ h.delete :macro
416
398
  @s = 'Else If '
417
- super()
399
+ operator = @h[:is_or_condition] ? 'OR' : 'AND'
400
+ constraints = @constraints.map \
401
+ {|x| ' ' * indent + x.to_summary(colour: colour)}.join(" %s " % operator)
402
+
403
+ out = []
404
+ out << "; %s" % @h[:comment] if @h[:comment]
405
+ s = @s.lines.map {|x| (' ' * indent) + x}.join
406
+ out << s + constraints
407
+ out.join("\n")
408
+
409
+ end
410
+
411
+ def to_summary(colour: false)
412
+ 'foo'
418
413
  end
419
414
 
420
415
 
@@ -433,7 +428,7 @@ class EndIfAction < Action
433
428
 
434
429
  end
435
430
 
436
- def to_s(colour: false)
431
+ def to_s(colour: false, indent: 0)
437
432
  'End If'
438
433
  end
439
434
 
@@ -463,10 +458,10 @@ class SetAirplaneModeAction < ConnectivityAction
463
458
 
464
459
  end
465
460
 
466
- def to_s(colour: false)
461
+ def to_s(colour: false, indent: 0)
467
462
 
468
463
  state = ['On', 'Off', 'Toggle'][@h[:state]]
469
- @s = 'Airplane Mode ' + state + "\n"
464
+ @s = 'Airplane Mode ' + state
470
465
  super(colour: colour)
471
466
 
472
467
  end
@@ -489,7 +484,7 @@ class SetWifiAction < ConnectivityAction
489
484
 
490
485
  end
491
486
 
492
- def to_s(colour: false)
487
+ def to_s(colour: false, indent: 0)
493
488
  action = @h[:state] == 0 ? 'Enable' : 'Disable'
494
489
  action + ' Wifi'
495
490
  end
@@ -511,7 +506,7 @@ class SetBluetoothAction < ConnectivityAction
511
506
 
512
507
  end
513
508
 
514
- def to_s(colour: false)
509
+ def to_s(colour: false, indent: 0)
515
510
  'SetBluetoothAction ' + @h.inspect
516
511
  end
517
512
 
@@ -533,7 +528,7 @@ class SetBluetoothAction < ConnectivityAction
533
528
 
534
529
  end
535
530
 
536
- def to_s(colour: false)
531
+ def to_s(colour: false, indent: 0)
537
532
  'SetBluetoothAction ' + @h.inspect
538
533
  end
539
534
 
@@ -553,7 +548,7 @@ class SetHotspotAction < ConnectivityAction
553
548
 
554
549
  end
555
550
 
556
- def to_s(colour: false)
551
+ def to_s(colour: false, indent: 0)
557
552
  action = @h[:turn_wifi_on] ? 'Enable' : 'Disable'
558
553
  action + ' HotSpot'
559
554
  end
@@ -585,7 +580,7 @@ class SendIntentAction < ConnectivityAction
585
580
 
586
581
  end
587
582
 
588
- def to_s(colour: false)
583
+ def to_s(colour: false, indent: 0)
589
584
  'Send Intent ' + "\n " + @h[:action]
590
585
  end
591
586
 
@@ -625,7 +620,7 @@ class SetAlarmClockAction < DateTimeAction
625
620
 
626
621
  end
627
622
 
628
- def to_s(colour: false)
623
+ def to_s(colour: false, indent: 0)
629
624
  'SetAlarmClockAction ' + @h.inspect
630
625
  end
631
626
 
@@ -647,8 +642,11 @@ class StopWatchAction < DateTimeAction
647
642
 
648
643
  end
649
644
 
650
- def to_s(colour: false)
651
- 'StopWatchAction ' + @h.inspect
645
+ def to_s(colour: false, indent: 0)
646
+ option = ['Start', 'Pause','Reset','Reset and Restart'][@h[:option]]
647
+ name = @h[:stopwatch_name]
648
+ @s = "StopWatch (%s)" % option + "\n" + name #+ ' ' + @h.inspect
649
+ super()
652
650
  end
653
651
 
654
652
  alias to_summary to_s
@@ -678,7 +676,7 @@ class SayTimeAction < DateTimeAction
678
676
  'say current_time()'
679
677
  end
680
678
 
681
- def to_s(colour: false)
679
+ def to_s(colour: false, indent: 0)
682
680
  'Say Current Time'
683
681
  end
684
682
 
@@ -708,7 +706,7 @@ class AndroidShortcutsAction < DeviceAction
708
706
 
709
707
  end
710
708
 
711
- def to_s(colour: false)
709
+ def to_s(colour: false, indent: 0)
712
710
  'AndroidShortcutsAction ' + @h.inspect
713
711
  end
714
712
 
@@ -729,7 +727,7 @@ class ClipboardAction < DeviceAction
729
727
 
730
728
  end
731
729
 
732
- def to_s(colour: false)
730
+ def to_s(colour: false, indent: 0)
733
731
  'Fill Clipboard' + "\n " + @h[:clipboard_text] #+ @h.inspect
734
732
  end
735
733
 
@@ -749,7 +747,7 @@ class PressBackAction < DeviceAction
749
747
 
750
748
  end
751
749
 
752
- def to_s(colour: false)
750
+ def to_s(colour: false, indent: 0)
753
751
  'PressBackAction ' + @h.inspect
754
752
  end
755
753
 
@@ -777,7 +775,7 @@ class SpeakTextAction < DeviceAction
777
775
 
778
776
  end
779
777
 
780
- def to_s(colour: false)
778
+ def to_s(colour: false, indent: 0)
781
779
  "Speak Text (%s)" % @h[:text_to_say]
782
780
  end
783
781
 
@@ -798,8 +796,43 @@ class UIInteractionAction < DeviceAction
798
796
 
799
797
  end
800
798
 
801
- def to_s(colour: false)
802
- 'UIInteractionAction ' + @h.inspect
799
+ def to_s(colour: false, indent: 0)
800
+
801
+ ui = @h[:ui_interaction_configuration]
802
+
803
+ option = -> do
804
+ detail = case ui[:click_option]
805
+ when 0 # 'Current focus'
806
+ 'Current focus'
807
+ when 1 # 'Text content'
808
+ ui[:text_content]
809
+ when 2 # 'X, Y location'
810
+ "%s" % ui[:xy_point].values.join(',')
811
+ when 3 # 'Identify in app'
812
+ "id:%s" % ui[:view_id]
813
+ end
814
+ end
815
+
816
+ s = case @h[:action]
817
+ when 0 # 'Click'
818
+ 'Click' + " [%s]" % option.call
819
+ when 1 # 'Long Click'
820
+ 'Long Click' + " [%s]" % option.call
821
+ when 2 # 'Copy'
822
+ 'Copy'
823
+ when 3 # 'Cut'
824
+ 'Cut'
825
+ when 4 # 'Paste'
826
+ "Paste [%s]" % (ui[:use_clipboard] ? 'Clipboard text' : ui[:text])
827
+ when 5 # 'Clear selection'
828
+ 'Clear selection'
829
+ when 6 # 'Gesture'
830
+ detail = "%d ms: %d,%d -> %d,%d" % [ui[:duration_ms], ui[:start_x],
831
+ ui[:start_y], ui[:end_x], ui[:end_y]]
832
+ "Gesture [%s]" % detail
833
+ end
834
+
835
+ 'UI Interaction' + "\n " + s #+ ' ' + @h.inspect
803
836
  end
804
837
 
805
838
  alias to_summary to_s
@@ -818,7 +851,7 @@ class VoiceSearchAction < DeviceAction
818
851
 
819
852
  end
820
853
 
821
- def to_s(colour: false)
854
+ def to_s(colour: false, indent: 0)
822
855
  'VoiceSearchAction ' + @h.inspect
823
856
  end
824
857
 
@@ -849,7 +882,7 @@ class ExpandCollapseStatusBarAction < DeviceSettingsAction
849
882
 
850
883
  end
851
884
 
852
- def to_s(colour: false)
885
+ def to_s(colour: false, indent: 0)
853
886
  'ExpandCollapseStatusBarAction ' + @h.inspect
854
887
  end
855
888
 
@@ -869,7 +902,7 @@ class LaunchHomeScreenAction < DeviceSettingsAction
869
902
 
870
903
  end
871
904
 
872
- def to_s(colour: false)
905
+ def to_s(colour: false, indent: 0)
873
906
  'LaunchHomeScreenAction ' + @h.inspect
874
907
  end
875
908
 
@@ -900,7 +933,7 @@ class CameraFlashLightAction < DeviceSettingsAction
900
933
  ['torch :on', 'torch :off', 'torch :toggle'][@h[:state]]
901
934
  end
902
935
 
903
- def to_s(colour: false)
936
+ def to_s(colour: false, indent: 0)
904
937
  ['Torch On', 'Torch Off', 'Torch Toggle'][@h[:state]]
905
938
  end
906
939
 
@@ -920,7 +953,7 @@ class VibrateAction < DeviceSettingsAction
920
953
 
921
954
  end
922
955
 
923
- def to_s(colour: false)
956
+ def to_s(colour: false, indent: 0)
924
957
 
925
958
  pattern = [
926
959
  'Blip', 'Short Buzz', 'Long Buzz', 'Rapid', 'Slow', 'Increasing',
@@ -947,7 +980,7 @@ class SetAutoRotateAction < DeviceSettingsAction
947
980
 
948
981
  end
949
982
 
950
- def to_s(colour: false)
983
+ def to_s(colour: false, indent: 0)
951
984
  'SetAutoRotateAction ' + @h.inspect
952
985
  end
953
986
 
@@ -967,7 +1000,7 @@ class DayDreamAction < DeviceSettingsAction
967
1000
 
968
1001
  end
969
1002
 
970
- def to_s(colour: false)
1003
+ def to_s(colour: false, indent: 0)
971
1004
  'DayDreamAction ' + @h.inspect
972
1005
  end
973
1006
 
@@ -987,7 +1020,7 @@ class SetKeyboardAction < DeviceSettingsAction
987
1020
 
988
1021
  end
989
1022
 
990
- def to_s(colour: false)
1023
+ def to_s(colour: false, indent: 0)
991
1024
  'SetKeyboardAction ' + @h.inspect
992
1025
  end
993
1026
 
@@ -1008,7 +1041,7 @@ class SetKeyguardAction < DeviceSettingsAction
1008
1041
 
1009
1042
  end
1010
1043
 
1011
- def to_s(colour: false)
1044
+ def to_s(colour: false, indent: 0)
1012
1045
  'SetKeyguardAction ' + @h.inspect
1013
1046
  end
1014
1047
 
@@ -1029,7 +1062,7 @@ class CarModeAction < DeviceSettingsAction
1029
1062
 
1030
1063
  end
1031
1064
 
1032
- def to_s(colour: false)
1065
+ def to_s(colour: false, indent: 0)
1033
1066
  'CarModeAction ' + @h.inspect
1034
1067
  end
1035
1068
 
@@ -1051,7 +1084,7 @@ class ChangeKeyboardAction < DeviceSettingsAction
1051
1084
 
1052
1085
  end
1053
1086
 
1054
- def to_s(colour: false)
1087
+ def to_s(colour: false, indent: 0)
1055
1088
  'ChangeKeyboardAction ' + @h.inspect
1056
1089
  end
1057
1090
 
@@ -1077,7 +1110,7 @@ class SetWallpaperAction < DeviceSettingsAction
1077
1110
 
1078
1111
  end
1079
1112
 
1080
- def to_s(colour: false)
1113
+ def to_s(colour: false, indent: 0)
1081
1114
  'SetWallpaperAction ' + @h.inspect
1082
1115
  end
1083
1116
 
@@ -1093,6 +1126,40 @@ class FileAction < Action
1093
1126
 
1094
1127
  end
1095
1128
 
1129
+
1130
+
1131
+ # Category: Files
1132
+ #
1133
+ class FileOperationV21Action < FileAction
1134
+
1135
+ def initialize(h={})
1136
+
1137
+ options = {
1138
+ :app_name=>"", :class_name=>"", :package_name=>"", :file_path=>"",
1139
+ :file_extensions=>["jpg", "jpeg", "png", "raw", "bmp", "tif", "tiff",
1140
+ "gif"], :file_option=>2, :from_name=>"Sent",
1141
+ :from_uri_string=>"", :option=>2
1142
+ }
1143
+
1144
+ super(options.merge h)
1145
+
1146
+ end
1147
+
1148
+ def to_s(colour: false, indent: 0)
1149
+
1150
+ operation = ['Copy', 'Move', 'Delete', 'Create Folder']
1151
+ file = ['All Files', 'All Media Files', 'Images', 'Audio', 'Videos', 'Specify File Pattern', 'Folder']
1152
+
1153
+ detail = @h[:from_name]
1154
+ detail += ' to: ' + @h[:to_name] if @h[:option] == 1
1155
+ @s = "%s %s" % [operation[@h[:option]], file[@h[:file_option]]] \
1156
+ + "\n" + detail #+ @h.inspect
1157
+ super()
1158
+ end
1159
+
1160
+ alias to_summary to_s
1161
+ end
1162
+
1096
1163
  # Category: Files
1097
1164
  #
1098
1165
  class OpenFileAction < FileAction
@@ -1110,7 +1177,7 @@ class OpenFileAction < FileAction
1110
1177
 
1111
1178
  end
1112
1179
 
1113
- def to_s(colour: false)
1180
+ def to_s(colour: false, indent: 0)
1114
1181
  'OpenFileAction ' + @h.inspect
1115
1182
  end
1116
1183
 
@@ -1135,7 +1202,7 @@ class WriteToFileAction < FileAction
1135
1202
 
1136
1203
  end
1137
1204
 
1138
- def to_s(colour: false)
1205
+ def to_s(colour: false, indent: 0)
1139
1206
  'Write To File' + "\n " + @h[:filename] #+ @h.inspect
1140
1207
  end
1141
1208
 
@@ -1164,22 +1231,37 @@ class ForceLocationUpdateAction < LocationAction
1164
1231
 
1165
1232
  end
1166
1233
 
1167
- def to_s(colour: false)
1234
+ def to_s(colour: false, indent: 0)
1168
1235
  'ForceLocationUpdateAction ' + @h.inspect
1169
1236
  end
1170
1237
 
1171
1238
  alias to_summary to_s
1172
1239
  end
1173
1240
 
1241
+ # Category: Location
1242
+ #
1243
+ class LocationAction < Action
1244
+
1245
+ def initialize(h={})
1246
+ super(h)
1247
+ @group = 'location'
1248
+ end
1249
+
1250
+ end
1251
+
1174
1252
  # Category: Location
1175
1253
  #
1176
1254
  class ShareLocationAction < LocationAction
1177
1255
 
1178
1256
  def initialize(h={})
1257
+
1258
+ super()
1179
1259
 
1180
1260
  options = {
1181
1261
  email: '',
1182
- variable: {:m_stringValue=>"", :m_name=>"", :m_decimalValue=>0.0, :isLocal=>true, :m_booleanValue=>false, :excludeFromLog=>false, :m_intValue=>0, :m_type=>2},
1262
+ variable: {:m_stringValue=>"", :m_name=>"",
1263
+ :m_decimalValue=>0.0, :isLocal=>true, :m_booleanValue=>false,
1264
+ :excludeFromLog=>false, :m_intValue=>0, :m_type=>2},
1183
1265
  sim_id: 0,
1184
1266
  output_channel: 5,
1185
1267
  old_variable_format: true
@@ -1189,13 +1271,15 @@ class ShareLocationAction < LocationAction
1189
1271
 
1190
1272
  end
1191
1273
 
1192
- def to_s(colour: false)
1193
- 'ShareLocationAction ' + @h.inspect
1274
+ def to_s(colour: false, indent: 0)
1275
+ @s = 'Share Location' + "\nGPS" # + @h.inspect
1276
+ super()
1194
1277
  end
1195
1278
 
1196
1279
  alias to_summary to_s
1197
1280
  end
1198
1281
 
1282
+
1199
1283
  # Category: Location
1200
1284
  #
1201
1285
  class SetLocationUpdateRateAction < LocationAction
@@ -1211,7 +1295,7 @@ class SetLocationUpdateRateAction < LocationAction
1211
1295
 
1212
1296
  end
1213
1297
 
1214
- def to_s(colour: false)
1298
+ def to_s(colour: false, indent: 0)
1215
1299
  'SetLocationUpdateRateAction ' + @h.inspect
1216
1300
  end
1217
1301
 
@@ -1254,7 +1338,7 @@ class AddCalendarEntryAction < LoggingAction
1254
1338
 
1255
1339
  end
1256
1340
 
1257
- def to_s(colour: false)
1341
+ def to_s(colour: false, indent: 0)
1258
1342
  'AddCalendarEntryAction ' + @h.inspect
1259
1343
  end
1260
1344
 
@@ -1276,7 +1360,7 @@ class LogAction < LoggingAction
1276
1360
 
1277
1361
  end
1278
1362
 
1279
- def to_s(colour: false)
1363
+ def to_s(colour: false, indent: 0)
1280
1364
  'LogAction ' + @h.inspect
1281
1365
  end
1282
1366
 
@@ -1297,13 +1381,64 @@ class ClearLogAction < LoggingAction
1297
1381
 
1298
1382
  end
1299
1383
 
1300
- def to_s(colour: false)
1384
+ def to_s(colour: false, indent: 0)
1301
1385
  'ClearLogAction ' + @h.inspect
1302
1386
  end
1303
1387
 
1304
1388
  alias to_summary to_s
1305
1389
  end
1306
1390
 
1391
+
1392
+ # MacroDroid Specific
1393
+ #
1394
+ class CancelActiveMacroAction < Action
1395
+
1396
+ def initialize(h={})
1397
+
1398
+ options = {
1399
+
1400
+ }
1401
+
1402
+ super(h)
1403
+
1404
+ end
1405
+
1406
+ def to_s(colour: false, indent: 0)
1407
+ @s = 'Cancel Macro Actions' + "\n " + @h[:macro_name] #+ ' ' + @h.inspect
1408
+ super()
1409
+
1410
+ end
1411
+
1412
+ alias to_summary to_s
1413
+
1414
+ end
1415
+
1416
+ # MacroDroid Specific
1417
+ #
1418
+ class ConfirmNextAction < Action
1419
+
1420
+ def initialize(h={})
1421
+
1422
+ options = {
1423
+ :message=>"Do you want to fill the clipboard? ", :title=>"Fill clipboard? ", :negative_text=>"NO", :positive_text=>"YES", :class_type=>"ConfirmNextAction"
1424
+
1425
+ }
1426
+
1427
+ super(h)
1428
+
1429
+ end
1430
+
1431
+ def to_s(colour: false, indent: 0)
1432
+
1433
+ @s = 'Confirm Next' + "\n%s: %s" % [@h[:title], @h[:message]]
1434
+ super()
1435
+
1436
+ end
1437
+
1438
+ alias to_summary to_s
1439
+
1440
+ end
1441
+
1307
1442
  # MacroDroid Specific
1308
1443
  #
1309
1444
  class ExportMacrosAction < Action
@@ -1317,7 +1452,7 @@ class ExportMacrosAction < Action
1317
1452
 
1318
1453
  end
1319
1454
 
1320
- def to_s(colour: false)
1455
+ def to_s(colour: false, indent: 0)
1321
1456
 
1322
1457
  'Export macros'
1323
1458
 
@@ -1346,7 +1481,7 @@ class SetVariableAction < Action
1346
1481
 
1347
1482
  end
1348
1483
 
1349
- def to_s(colour: false)
1484
+ def to_s(colour: false, indent: 0)
1350
1485
 
1351
1486
  input = if @h[:user_prompt] then
1352
1487
  '[User Prompt]'
@@ -1379,7 +1514,7 @@ class SetVariableAction < Action
1379
1514
 
1380
1515
  end
1381
1516
 
1382
- @s = 'Set Variable' + ("\n %s: " % @h[:variable][:name]) + input #+ @h.inspect
1517
+ @s = 'Set Variable' + ("\n%s: " % @h[:variable][:name]) + input #+ @h.inspect
1383
1518
  super()
1384
1519
 
1385
1520
  end
@@ -1403,18 +1538,28 @@ class TextManipulationAction < Action
1403
1538
 
1404
1539
  end
1405
1540
 
1406
- def to_s(colour: false)
1407
-
1408
- tm = @h[:text_manipulation]
1541
+ def to_s(colour: false, indent: 0)
1409
1542
 
1410
- s = case tm[:type].to_sym
1411
- when :SubstringManipulation
1543
+ #tm = @h[:text_manipulation][:type]
1544
+
1545
+ #s = case tm[:type].to_sym
1546
+ s = case 3 # @h[:text_manipulation][:option].to_i
1547
+ when 0 # :SubstringManipulation
1412
1548
  "Substring(%s, %s)" % [@h[:text], tm[:params].join(', ')]
1549
+ when 1 # :ReplaceAllManipulation
1550
+ "Replace all(%s, %s, %s)" % [@h[:text], *tm[:params]]
1551
+ when 2 # :ExtractTextManipulation
1552
+ "Extract text(%s, %s)" % [@h[:text], tm[:params].join(', ')]
1553
+ when 3 # :UpperCaseManipulation
1554
+ "Upper case(%s)" % [@h[:text]]
1555
+ #'foo'
1556
+ when 4 # :LowerCaseManipulation
1557
+ "Lower case(%s)" % [@h[:text]]
1558
+ when 5 # :TrimWhitespaceManipulation
1559
+ "Trim whitespace(%s)" % [@h[:text]]
1413
1560
  end
1414
1561
 
1415
-
1416
- 'Text Manipulation' + "\n " + s #+ ' ' + @h.inspect
1417
-
1562
+ 'Text Manipulation' + "\n " + s.inspect #+ ' ' + @h.inspect
1418
1563
 
1419
1564
  end
1420
1565
 
@@ -1422,6 +1567,9 @@ class TextManipulationAction < Action
1422
1567
 
1423
1568
  end
1424
1569
 
1570
+
1571
+
1572
+
1425
1573
  class PauseAction < Action
1426
1574
 
1427
1575
  def initialize(h={})
@@ -1433,7 +1581,7 @@ class PauseAction < Action
1433
1581
 
1434
1582
  end
1435
1583
 
1436
- def to_s(colour: false)
1584
+ def to_s(colour: false, indent: 0)
1437
1585
 
1438
1586
  su = Subunit.new(units={minutes:60, hours:60},
1439
1587
  seconds: @h[:delay_in_seconds])
@@ -1477,7 +1625,7 @@ class RecordMicrophoneAction < MediaAction
1477
1625
 
1478
1626
  end
1479
1627
 
1480
- def to_s(colour: false)
1628
+ def to_s(colour: false, indent: 0)
1481
1629
  'RecordMicrophoneAction ' + @h.inspect
1482
1630
  end
1483
1631
 
@@ -1499,7 +1647,7 @@ class PlaySoundAction < MediaAction
1499
1647
 
1500
1648
  end
1501
1649
 
1502
- def to_s(colour: false)
1650
+ def to_s(colour: false, indent: 0)
1503
1651
  'Play: ' + @h[:file_path]
1504
1652
  end
1505
1653
 
@@ -1535,8 +1683,10 @@ class SendEmailAction < MessagingAction
1535
1683
 
1536
1684
  end
1537
1685
 
1538
- def to_s(colour: false)
1539
- 'SendEmailAction ' + @h.inspect
1686
+ def to_s(colour: false, indent: 0)
1687
+ recipient = @h[:email_address]
1688
+ @s = 'Send EmailAction' + "\nTo: " + recipient #+ ' ' + @h.inspect
1689
+ super()
1540
1690
  end
1541
1691
 
1542
1692
  alias to_summary to_s
@@ -1561,7 +1711,7 @@ class SendSMSAction < MessagingAction
1561
1711
 
1562
1712
  end
1563
1713
 
1564
- def to_s(colour: false)
1714
+ def to_s(colour: false, indent: 0)
1565
1715
  'SendSMSAction ' + @h.inspect
1566
1716
  end
1567
1717
 
@@ -1584,7 +1734,7 @@ class UDPCommandAction < MessagingAction
1584
1734
 
1585
1735
  end
1586
1736
 
1587
- def to_s(colour: false)
1737
+ def to_s(colour: false, indent: 0)
1588
1738
  'UDPCommandAction ' + @h.inspect
1589
1739
  end
1590
1740
 
@@ -1610,7 +1760,7 @@ class ClearNotificationsAction < NotificationsAction
1610
1760
  options = {
1611
1761
  package_name_list: [],
1612
1762
  match_text: '',
1613
- application_name_list: [],
1763
+ application_name_list: [],
1614
1764
  clear_persistent: false,
1615
1765
  excludes: false,
1616
1766
  match_option: 0,
@@ -1623,7 +1773,7 @@ class ClearNotificationsAction < NotificationsAction
1623
1773
 
1624
1774
  end
1625
1775
 
1626
- def to_s(colour: false)
1776
+ def to_s(colour: false, indent: 0)
1627
1777
  'ClearNotificationsAction ' + @h.inspect
1628
1778
  end
1629
1779
 
@@ -1655,7 +1805,7 @@ class MessageDialogAction < NotificationsAction
1655
1805
 
1656
1806
  end
1657
1807
 
1658
- def to_s(colour: false)
1808
+ def to_s(colour: false, indent: 0)
1659
1809
  'Display Dialog' + "\n Battery at: [battery]"
1660
1810
  end
1661
1811
 
@@ -1675,7 +1825,7 @@ class AllowLEDNotificationLightAction < NotificationsAction
1675
1825
 
1676
1826
  end
1677
1827
 
1678
- def to_s(colour: false)
1828
+ def to_s(colour: false, indent: 0)
1679
1829
  'AllowLEDNotificationLightAction ' + @h.inspect
1680
1830
  end
1681
1831
 
@@ -1696,7 +1846,7 @@ class SetNotificationSoundAction < NotificationsAction
1696
1846
 
1697
1847
  end
1698
1848
 
1699
- def to_s(colour: false)
1849
+ def to_s(colour: false, indent: 0)
1700
1850
  'SetNotificationSoundAction ' + @h.inspect
1701
1851
  end
1702
1852
 
@@ -1717,7 +1867,7 @@ class SetNotificationSoundAction < NotificationsAction
1717
1867
 
1718
1868
  end
1719
1869
 
1720
- def to_s(colour: false)
1870
+ def to_s(colour: false, indent: 0)
1721
1871
  'SetNotificationSoundAction ' + @h.inspect
1722
1872
  end
1723
1873
 
@@ -1738,7 +1888,7 @@ class SetNotificationSoundAction < NotificationsAction
1738
1888
 
1739
1889
  end
1740
1890
 
1741
- def to_s(colour: false)
1891
+ def to_s(colour: false, indent: 0)
1742
1892
  'SetNotificationSoundAction ' + @h.inspect
1743
1893
  end
1744
1894
 
@@ -1772,9 +1922,10 @@ class NotificationAction < NotificationsAction
1772
1922
 
1773
1923
  end
1774
1924
 
1775
- def to_s(colour: false)
1776
- "Display Notification\n " + \
1925
+ def to_s(colour: false, indent: 0)
1926
+ @s = "Display Notification\n" + \
1777
1927
  "%s: %s" % [@h[:notification_subject], @h[:notification_text]]
1928
+ super()
1778
1929
  end
1779
1930
 
1780
1931
  end
@@ -1787,6 +1938,9 @@ class ToastAction < NotificationsAction
1787
1938
 
1788
1939
  h = if obj.is_a? Hash then
1789
1940
  obj
1941
+ elsif obj.is_a? Rexle::Element
1942
+ txt = obj.text('item/description')
1943
+ {msg: (txt || obj.text)}
1790
1944
  else
1791
1945
  {msg: obj}
1792
1946
  end
@@ -1819,8 +1973,9 @@ class ToastAction < NotificationsAction
1819
1973
  "popup_message '%s'" % @h[:message_text]
1820
1974
  end
1821
1975
 
1822
- def to_s(colour: false)
1823
- @s = "Popup Message\n %s" % @h[:message_text]
1976
+ def to_s(colour: false, indent: 0)
1977
+ @s = "Popup Message\n%s" % @h[:message_text]
1978
+ super()
1824
1979
  end
1825
1980
 
1826
1981
  end
@@ -1849,8 +2004,8 @@ class AnswerCallAction < PhoneAction
1849
2004
 
1850
2005
  end
1851
2006
 
1852
- def to_s(colour: false)
1853
- @s = 'Answer Call' + "\n "
2007
+ def to_s(colour: false, indent: 0)
2008
+ @s = 'Answer Call'
1854
2009
  super()
1855
2010
  end
1856
2011
  end
@@ -1871,7 +2026,7 @@ class ClearCallLogAction < PhoneAction
1871
2026
 
1872
2027
  end
1873
2028
 
1874
- def to_s(colour: false)
2029
+ def to_s(colour: false, indent: 0)
1875
2030
  'ClearCallLogAction ' + @h.inspect
1876
2031
  end
1877
2032
 
@@ -1891,7 +2046,7 @@ class OpenCallLogAction < PhoneAction
1891
2046
 
1892
2047
  end
1893
2048
 
1894
- def to_s(colour: false)
2049
+ def to_s(colour: false, indent: 0)
1895
2050
  'OpenCallLogAction ' + @h.inspect
1896
2051
  end
1897
2052
 
@@ -1911,8 +2066,8 @@ class RejectCallAction < PhoneAction
1911
2066
 
1912
2067
  end
1913
2068
 
1914
- def to_s(colour: false)
1915
- @s = 'Call Reject' + "\n "
2069
+ def to_s(colour: false, indent: 0)
2070
+ @s = 'Call Reject'
1916
2071
  super()
1917
2072
  end
1918
2073
 
@@ -1933,7 +2088,7 @@ class MakeCallAction < PhoneAction
1933
2088
 
1934
2089
  end
1935
2090
 
1936
- def to_s(colour: false)
2091
+ def to_s(colour: false, indent: 0)
1937
2092
  'MakeCallAction ' + @h.inspect
1938
2093
  end
1939
2094
 
@@ -1955,7 +2110,7 @@ class SetRingtoneAction < PhoneAction
1955
2110
 
1956
2111
  end
1957
2112
 
1958
- def to_s(colour: false)
2113
+ def to_s(colour: false, indent: 0)
1959
2114
  'SetRingtoneAction ' + @h.inspect
1960
2115
  end
1961
2116
 
@@ -1987,8 +2142,10 @@ class SetBrightnessAction < ScreenAction
1987
2142
 
1988
2143
  end
1989
2144
 
1990
- def to_s(colour: false)
1991
- 'SetBrightnessAction ' + @h.inspect
2145
+ def to_s(colour: false, indent: 0)
2146
+ val = @h[:brightness_percent] > 100 ? 'Auto' : @h[:brightness_percent].to_s + '%'
2147
+ @s = 'Brightness' + "\n " + val #@h.inspect
2148
+ super()
1992
2149
  end
1993
2150
 
1994
2151
  alias to_summary to_s
@@ -2008,7 +2165,7 @@ class ForceScreenRotationAction < ScreenAction
2008
2165
 
2009
2166
  end
2010
2167
 
2011
- def to_s(colour: false)
2168
+ def to_s(colour: false, indent: 0)
2012
2169
  'ForceScreenRotationAction ' + @h.inspect
2013
2170
  end
2014
2171
 
@@ -2032,13 +2189,14 @@ class ScreenOnAction < ScreenAction
2032
2189
 
2033
2190
  end
2034
2191
 
2035
- def to_s(colour: false)
2192
+ def to_s(colour: false, indent: 0)
2036
2193
 
2037
2194
  state = @h[:screen_off] ? 'Off' : 'On'
2038
2195
  state += ' ' + 'No Lock (root only)' if @h[:screen_off_no_lock]
2039
2196
  #state += ' ' + '(Alternative)' if @h[:screen_on_alternative]
2040
2197
 
2041
- 'Screen ' + state
2198
+ @s = 'Screen ' + state
2199
+ super()
2042
2200
 
2043
2201
  end
2044
2202
 
@@ -2060,7 +2218,7 @@ class DimScreenAction < ScreenAction
2060
2218
 
2061
2219
  end
2062
2220
 
2063
- def to_s(colour: false)
2221
+ def to_s(colour: false, indent: 0)
2064
2222
  'DimScreenAction ' + @h.inspect
2065
2223
  end
2066
2224
 
@@ -2088,7 +2246,7 @@ class KeepAwakeAction < ScreenAction
2088
2246
 
2089
2247
  end
2090
2248
 
2091
- def to_s(colour: false)
2249
+ def to_s(colour: false, indent: 0)
2092
2250
 
2093
2251
  screen = @h[:screen_option] == 0 ? 'Screen On' : 'Screen Off'
2094
2252
 
@@ -2129,7 +2287,7 @@ class SetScreenTimeoutAction < ScreenAction
2129
2287
 
2130
2288
  end
2131
2289
 
2132
- def to_s(colour: false)
2290
+ def to_s(colour: false, indent: 0)
2133
2291
  'SetScreenTimeoutAction ' + @h.inspect
2134
2292
  end
2135
2293
 
@@ -2160,7 +2318,7 @@ class SilentModeVibrateOffAction < VolumeAction
2160
2318
 
2161
2319
  end
2162
2320
 
2163
- def to_s(colour: false)
2321
+ def to_s(colour: false, indent: 0)
2164
2322
  'SilentModeVibrateOffAction ' + @h.inspect
2165
2323
  end
2166
2324
 
@@ -2182,7 +2340,7 @@ class SetVibrateAction < VolumeAction
2182
2340
 
2183
2341
  end
2184
2342
 
2185
- def to_s(colour: false)
2343
+ def to_s(colour: false, indent: 0)
2186
2344
 
2187
2345
  a = [
2188
2346
  'Silent (Vibrate On)',
@@ -2193,7 +2351,7 @@ class SetVibrateAction < VolumeAction
2193
2351
  ]
2194
2352
 
2195
2353
  status = a[@h[:option_int]]
2196
- @s = 'Vibrate Enable/Disable ' + "\n " + status + "\n "
2354
+ @s = 'Vibrate Enable/Disable ' + "\n" + status
2197
2355
  super()
2198
2356
 
2199
2357
  end
@@ -2219,7 +2377,7 @@ class VolumeIncrementDecrementAction < VolumeAction
2219
2377
 
2220
2378
  end
2221
2379
 
2222
- def to_s(colour: false)
2380
+ def to_s(colour: false, indent: 0)
2223
2381
  'VolumeIncrementDecrementAction ' + @h.inspect
2224
2382
  end
2225
2383
 
@@ -2241,7 +2399,7 @@ class SpeakerPhoneAction < VolumeAction
2241
2399
 
2242
2400
  end
2243
2401
 
2244
- def to_s(colour: false)
2402
+ def to_s(colour: false, indent: 0)
2245
2403
  'SpeakerPhoneAction ' + @h.inspect
2246
2404
  end
2247
2405
 
@@ -2266,7 +2424,7 @@ class SetVolumeAction < VolumeAction
2266
2424
 
2267
2425
  end
2268
2426
 
2269
- def to_s(colour: false)
2427
+ def to_s(colour: false, indent: 0)
2270
2428
  volume = @h[:stream_index_array].zip(@h[:stream_volume_array]).to_h[true]
2271
2429
  'Volume Change ' + "Notification = %s%%" % volume
2272
2430
  end