ruby-macrodroid 0.9.13 → 0.9.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/ruby-macrodroid/actions.rb +314 -22
- data/lib/ruby-macrodroid/actionsnlp.rb +82 -7
- data/lib/ruby-macrodroid/base.rb +5 -3
- data/lib/ruby-macrodroid/macro.rb +1 -1
- data/lib/ruby-macrodroid/triggers.rb +32 -0
- data/lib/ruby-macrodroid/triggersnlp.rb +23 -1
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98e47dfdd0c7a7f5eabe5a942e3d1ad19cbacbb8cdac3de74b301e51a6e9dbdc
|
4
|
+
data.tar.gz: 462bf9fa2ffdb85fc51b93448c1a43b9469bd81bbec42a34549fdde9518a07ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8e4d4e23d498cd394739002b387907209015e06fea55facfdccdd7983e72cf72372bf152427767388ca8c3ee031dfbbe7ff69be964e210025d54ac60be6e0ed
|
7
|
+
data.tar.gz: c8150eccb7ba454409f7ab6d56a7418f9508050c6ee76021c0508b21b1203529e5fce79ff9dfd1aeadfab0f3aced27d95c2def9151517d3bc4eff32ba8e1d6b0
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
@@ -32,6 +32,36 @@
|
|
32
32
|
#
|
33
33
|
|
34
34
|
|
35
|
+
APPS = {
|
36
|
+
'AutoBoy' => 'com.happyconz.blackbox',
|
37
|
+
'Amazon Alexa' => 'com.amazon.dee.app',
|
38
|
+
'Brave' => 'com.brave.browser',
|
39
|
+
'Camera' => 'com.mediatek.camera',
|
40
|
+
'Cast to TV' => 'cast.video.screenmirroring.casttotv',
|
41
|
+
'Calculator' => 'com.android.pri.calculator',
|
42
|
+
'Calendar' => 'com.google.android.calendar',
|
43
|
+
'Clock' => 'com.android.deskclock',
|
44
|
+
'File Manager' => 'com.alphainventor.filemanager',
|
45
|
+
'Firefox' => 'org.mozilla.firefox',
|
46
|
+
'Google Chrome' => 'com.google.android.chrome',
|
47
|
+
'Google Calendar' => 'com.google.android.calendar',
|
48
|
+
'Chrome' => 'com.google.android.chrome',
|
49
|
+
'Earth' => 'com.google.earth',
|
50
|
+
'Google Home' => 'com.google.android.apps.chromecast.app',
|
51
|
+
'Google Play Music' => 'com.google.android.music',
|
52
|
+
'MacroDroid' => 'com.arlosoft.macrodroid',
|
53
|
+
'QuickEdit Text Editor Pro' => 'com.rhmsoft.edit.pro',
|
54
|
+
'QR & Barcode Reader' => 'com.teacapps.barcodescanner',
|
55
|
+
'Settings' => 'com.android.settings',
|
56
|
+
'Chrome' => 'com.google.android.street',
|
57
|
+
'tinyCam PRO' => 'com.alexvas.dvr.pro',
|
58
|
+
'Tor Browser' => 'org.torproject.torbrowser',
|
59
|
+
'VLC' => 'org.videolan.vlc',
|
60
|
+
'WiFi FTP Server' => 'com.medhaapps.wififtpserver',
|
61
|
+
'YouTube' => 'com.google.android.youtube'
|
62
|
+
}
|
63
|
+
|
64
|
+
|
35
65
|
class Action < MacroObject
|
36
66
|
using ColouredText
|
37
67
|
using Params
|
@@ -75,20 +105,29 @@ end
|
|
75
105
|
class LaunchActivityAction < ApplicationAction
|
76
106
|
|
77
107
|
def initialize(h={})
|
78
|
-
|
108
|
+
|
109
|
+
# option 0 is by application name, 1 is launch by package name
|
110
|
+
#
|
79
111
|
options = {
|
80
112
|
application_name: 'Chrome',
|
81
113
|
package_to_launch: 'com.android.chrome',
|
82
114
|
exclude_from_recents: false,
|
83
|
-
start_new: false
|
115
|
+
start_new: false,
|
116
|
+
option: 0,
|
117
|
+
launch_by_package_name: ''
|
84
118
|
}
|
85
119
|
|
86
120
|
super(options.merge h)
|
121
|
+
|
122
|
+
@list = %w(option launchByPackageName)
|
87
123
|
|
88
124
|
end
|
89
125
|
|
90
126
|
def to_s(colour: false, indent: 0)
|
91
|
-
|
127
|
+
option = @h[:option] == 0 ? @h[:application_name] : \
|
128
|
+
@h[:launch_by_package_name]
|
129
|
+
@s = 'Launch ' + option
|
130
|
+
super()
|
92
131
|
end
|
93
132
|
|
94
133
|
end
|
@@ -119,13 +158,30 @@ end
|
|
119
158
|
#
|
120
159
|
class LaunchShortcutAction < ApplicationAction
|
121
160
|
|
122
|
-
def initialize(
|
161
|
+
def initialize(obj=nil)
|
123
162
|
|
163
|
+
puts 'obj: ' + obj.inspect
|
164
|
+
h = if obj.is_a? Hash then
|
165
|
+
obj
|
166
|
+
else
|
167
|
+
obj[2] || {}
|
168
|
+
end
|
169
|
+
|
170
|
+
if h[:shortcut] and h[:shortcut] =~ /Ask Alexa/i then
|
171
|
+
h = {
|
172
|
+
:app_name=>"Amazon Alexa", :intent_encoded=>"#Intent;action=com." +
|
173
|
+
"amazon.alexa.action.WIDGET_SHORTCUT;launchFlags=0x10000000;" +
|
174
|
+
"component=com.amazon.dee.app/.ui.voice.LaunchAlexaActivity;end",
|
175
|
+
:name=>"Ask Alexa"
|
176
|
+
}
|
177
|
+
end
|
124
178
|
options = {
|
125
179
|
:app_name=>"Amazon Alexa", :intent_encoded=>"", :name=>"Ask Alexa"
|
126
180
|
}
|
127
181
|
|
128
182
|
super(options.merge h)
|
183
|
+
|
184
|
+
#@list = %w(appName intentEncoded name)
|
129
185
|
|
130
186
|
end
|
131
187
|
|
@@ -150,17 +206,17 @@ class OpenWebPageAction < ApplicationAction
|
|
150
206
|
|
151
207
|
def initialize(obj={}, macro=nil)
|
152
208
|
|
153
|
-
$debug =
|
209
|
+
$debug = true
|
154
210
|
puts ('obj: ' + obj.inspect).debug if $debug
|
155
211
|
|
156
212
|
h = if obj.is_a? Hash then
|
157
213
|
|
158
|
-
obj.merge({macro: macro})
|
214
|
+
obj.merge({macro: macro}) #unless obj and obj[:macro]
|
159
215
|
|
160
216
|
elsif obj.is_a? Array
|
161
217
|
|
162
218
|
puts ('obj: ' + obj.inspect).debug if $debug
|
163
|
-
e, macro = obj
|
219
|
+
e, macro, h3 = obj
|
164
220
|
|
165
221
|
a = e.xpath('item/*')
|
166
222
|
|
@@ -181,7 +237,7 @@ class OpenWebPageAction < ApplicationAction
|
|
181
237
|
{url: (txt || e.text)}
|
182
238
|
end
|
183
239
|
|
184
|
-
h2.merge(macro: macro)
|
240
|
+
h2.merge(macro: macro).merge(h3)
|
185
241
|
|
186
242
|
end
|
187
243
|
|
@@ -219,6 +275,7 @@ class OpenWebPageAction < ApplicationAction
|
|
219
275
|
h[:macro].title.downcase.gsub(/ +/,'-')
|
220
276
|
|
221
277
|
end
|
278
|
+
puts 'url: ' + url.inspect if $debug
|
222
279
|
|
223
280
|
if h2 then
|
224
281
|
|
@@ -242,7 +299,8 @@ class OpenWebPageAction < ApplicationAction
|
|
242
299
|
end
|
243
300
|
|
244
301
|
def to_s(colour: false, indent: 0)
|
245
|
-
|
302
|
+
s = @h[:http_get] ? '' : 'Open Website / '
|
303
|
+
@s = s + "HTTP GET\nurl: " + @h[:url_to_open]
|
246
304
|
super()
|
247
305
|
end
|
248
306
|
|
@@ -378,6 +436,61 @@ class TakePictureAction < CameraAction
|
|
378
436
|
end
|
379
437
|
|
380
438
|
|
439
|
+
class TakeScreenshotAction < CameraAction
|
440
|
+
|
441
|
+
def initialize(obj=nil)
|
442
|
+
|
443
|
+
h = if obj.is_a? Hash then
|
444
|
+
obj
|
445
|
+
elsif obj.is_a? Array
|
446
|
+
|
447
|
+
e, macro = obj
|
448
|
+
|
449
|
+
a = [
|
450
|
+
'Save to device',
|
451
|
+
'Send via email',
|
452
|
+
'Share via intent'
|
453
|
+
]
|
454
|
+
|
455
|
+
s = e.text('item/description').to_s
|
456
|
+
index = a.map(&:downcase).index s.downcase
|
457
|
+
|
458
|
+
{option: index}
|
459
|
+
|
460
|
+
end
|
461
|
+
|
462
|
+
options = {
|
463
|
+
option: 0,
|
464
|
+
use_smtp_email: false,
|
465
|
+
mechanism_option: 0,
|
466
|
+
save_to_jpeg: false
|
467
|
+
}
|
468
|
+
|
469
|
+
super(options.merge h)
|
470
|
+
|
471
|
+
end
|
472
|
+
|
473
|
+
def to_s(colour: false, indent: 0)
|
474
|
+
|
475
|
+
@s = 'Take Screenshot' #+ @h.inspect
|
476
|
+
|
477
|
+
options = [
|
478
|
+
'Save to device',
|
479
|
+
'Send via email',
|
480
|
+
'Share via intent'
|
481
|
+
]
|
482
|
+
|
483
|
+
option = options[@h[:option]]
|
484
|
+
|
485
|
+
@s += "\n" + option
|
486
|
+
super()
|
487
|
+
|
488
|
+
end
|
489
|
+
|
490
|
+
alias to_summary to_s
|
491
|
+
end
|
492
|
+
|
493
|
+
|
381
494
|
# Conditions/Loops
|
382
495
|
#
|
383
496
|
class IfConfirmedThenAction < Action
|
@@ -961,8 +1074,15 @@ end
|
|
961
1074
|
#
|
962
1075
|
class ClipboardAction < DeviceAction
|
963
1076
|
|
964
|
-
def initialize(
|
1077
|
+
def initialize(obj=nil)
|
965
1078
|
|
1079
|
+
h = if obj.is_a? Hash then
|
1080
|
+
obj
|
1081
|
+
elsif obj.is_a? Array
|
1082
|
+
e, macro = obj
|
1083
|
+
{clipboard_text: e.text('item/description').to_s}
|
1084
|
+
end
|
1085
|
+
|
966
1086
|
options = {
|
967
1087
|
clipboard_text: ''
|
968
1088
|
}
|
@@ -1042,14 +1162,60 @@ end
|
|
1042
1162
|
#
|
1043
1163
|
class UIInteractionAction < DeviceAction
|
1044
1164
|
|
1045
|
-
def initialize(
|
1165
|
+
def initialize(obj=nil)
|
1046
1166
|
|
1167
|
+
if obj.is_a? Hash then
|
1168
|
+
h = obj
|
1169
|
+
elsif obj.is_a? Array
|
1170
|
+
|
1171
|
+
e, macro = obj
|
1172
|
+
s = e.text('item/description').to_s
|
1173
|
+
|
1174
|
+
r = s.match(/^(Click|Long Click) \[(.*)\]$/)
|
1175
|
+
|
1176
|
+
# [Current focus] # Current focus
|
1177
|
+
# [0,0] # x,y location
|
1178
|
+
# [274,186] # Identify in app
|
1179
|
+
# [fooo] # Text content
|
1180
|
+
|
1181
|
+
h = {
|
1182
|
+
ui_interaction_configuration: {
|
1183
|
+
:xy_point=>{:x=>0, :y=>0},
|
1184
|
+
:type=>"Click"}
|
1185
|
+
}
|
1186
|
+
h2 = h[:ui_interaction_configuration]
|
1187
|
+
|
1188
|
+
if r then
|
1189
|
+
|
1190
|
+
h[:action] = 0
|
1191
|
+
|
1192
|
+
click, detail = r.captures
|
1193
|
+
h2[:long_click] = false if click.downcase.to_sym == :click
|
1194
|
+
|
1195
|
+
if detail == 'Current focus' then
|
1196
|
+
h2[:click_option] = 0
|
1197
|
+
elsif detail =~ /\d+,\d+/
|
1198
|
+
# to-do
|
1199
|
+
else
|
1200
|
+
# text content
|
1201
|
+
h2[:click_option] = 1
|
1202
|
+
h2[:text_content] = detail
|
1203
|
+
end
|
1204
|
+
|
1205
|
+
#h[:ui_interaction_configuration] = h2
|
1206
|
+
end
|
1207
|
+
|
1208
|
+
end
|
1209
|
+
|
1047
1210
|
options = {
|
1048
1211
|
ui_interaction_configuration: {:type=>"Copy"},
|
1049
1212
|
action: 2
|
1050
1213
|
}
|
1051
1214
|
|
1052
|
-
|
1215
|
+
|
1216
|
+
super(options.merge h)
|
1217
|
+
|
1218
|
+
@list = %w(uiInteractionConfiguration action xyPoint textContent clickOption type longClick)
|
1053
1219
|
|
1054
1220
|
end
|
1055
1221
|
|
@@ -1089,7 +1255,8 @@ class UIInteractionAction < DeviceAction
|
|
1089
1255
|
"Gesture [%s]" % detail
|
1090
1256
|
end
|
1091
1257
|
|
1092
|
-
'UI Interaction' + "\n
|
1258
|
+
@s = 'UI Interaction' + "\n" + s #+ ' ' + @h.inspect
|
1259
|
+
super()
|
1093
1260
|
end
|
1094
1261
|
|
1095
1262
|
alias to_summary to_s
|
@@ -1109,7 +1276,10 @@ class VoiceSearchAction < DeviceAction
|
|
1109
1276
|
end
|
1110
1277
|
|
1111
1278
|
def to_s(colour: false, indent: 0)
|
1112
|
-
|
1279
|
+
|
1280
|
+
@s = 'Voice Search' # + @h.inspect
|
1281
|
+
super()
|
1282
|
+
|
1113
1283
|
end
|
1114
1284
|
|
1115
1285
|
alias to_summary to_s
|
@@ -1251,7 +1421,11 @@ class SetAutoRotateAction < DeviceSettingsAction
|
|
1251
1421
|
end
|
1252
1422
|
|
1253
1423
|
def to_s(colour: false, indent: 0)
|
1254
|
-
|
1424
|
+
|
1425
|
+
#'SetAutoRotateAction ' + @h.inspect
|
1426
|
+
@s = 'Auto Rotate ' + %w(On Off Toggle)[@h[:state]]
|
1427
|
+
super()
|
1428
|
+
|
1255
1429
|
end
|
1256
1430
|
|
1257
1431
|
alias to_summary to_s
|
@@ -1667,9 +1841,18 @@ class ClearLogAction < LoggingAction
|
|
1667
1841
|
end
|
1668
1842
|
|
1669
1843
|
|
1844
|
+
class MacroDroidAction < Action
|
1845
|
+
|
1846
|
+
def initialize(h={})
|
1847
|
+
super(h)
|
1848
|
+
@group = 'macrodroid'
|
1849
|
+
end
|
1850
|
+
|
1851
|
+
end
|
1852
|
+
|
1670
1853
|
# MacroDroid Specific
|
1671
1854
|
#
|
1672
|
-
class CancelActiveMacroAction <
|
1855
|
+
class CancelActiveMacroAction < MacroDroidAction
|
1673
1856
|
|
1674
1857
|
def initialize(h={})
|
1675
1858
|
|
@@ -1693,7 +1876,7 @@ end
|
|
1693
1876
|
|
1694
1877
|
# MacroDroid Specific
|
1695
1878
|
#
|
1696
|
-
class ConfirmNextAction <
|
1879
|
+
class ConfirmNextAction < MacroDroidAction
|
1697
1880
|
|
1698
1881
|
def initialize(h={})
|
1699
1882
|
|
@@ -1717,7 +1900,7 @@ class ConfirmNextAction < Action
|
|
1717
1900
|
|
1718
1901
|
end
|
1719
1902
|
|
1720
|
-
class DisableMacroAction <
|
1903
|
+
class DisableMacroAction < MacroDroidAction
|
1721
1904
|
|
1722
1905
|
def initialize(obj=nil)
|
1723
1906
|
|
@@ -1764,7 +1947,7 @@ end
|
|
1764
1947
|
|
1765
1948
|
# MacroDroid Specific
|
1766
1949
|
#
|
1767
|
-
class ExportMacrosAction <
|
1950
|
+
class ExportMacrosAction < MacroDroidAction
|
1768
1951
|
|
1769
1952
|
def initialize(h={})
|
1770
1953
|
|
@@ -1786,9 +1969,61 @@ class ExportMacrosAction < Action
|
|
1786
1969
|
end
|
1787
1970
|
|
1788
1971
|
|
1972
|
+
|
1973
|
+
class ForceMacroRunAction < MacroDroidAction
|
1974
|
+
|
1975
|
+
def initialize(obj=nil)
|
1976
|
+
|
1977
|
+
h = if obj.is_a? Hash then
|
1978
|
+
|
1979
|
+
obj
|
1980
|
+
|
1981
|
+
elsif obj.is_a? Array
|
1982
|
+
|
1983
|
+
e, macro, h2 = obj
|
1984
|
+
|
1985
|
+
# find the macro guid for the given name
|
1986
|
+
name = e.text('item/description').to_s
|
1987
|
+
found = macro.parent.macros.find {|macro| macro.title =~ /#{name}/ }
|
1988
|
+
|
1989
|
+
h3 = if found then
|
1990
|
+
{macro_name: found.title, GUID: found.guid}
|
1991
|
+
else
|
1992
|
+
{macro_name: name}
|
1993
|
+
end
|
1994
|
+
|
1995
|
+
h3.merge h2
|
1996
|
+
|
1997
|
+
end
|
1998
|
+
|
1999
|
+
options = {
|
2000
|
+
guid: nil, ignore_constraints: true,
|
2001
|
+
macro_name: "", use_off_status: false,
|
2002
|
+
user_prompt_title: "Run Macro"
|
2003
|
+
}
|
2004
|
+
super(options.merge h)
|
2005
|
+
|
2006
|
+
end
|
2007
|
+
|
2008
|
+
def invoke()
|
2009
|
+
super(macro_name: @h[:macro_name])
|
2010
|
+
end
|
2011
|
+
|
2012
|
+
def to_s(colour: false, indent: 0)
|
2013
|
+
|
2014
|
+
@s = 'Macro Run'# + @h.inspect
|
2015
|
+
@s += "\n" + @h[:macro_name]
|
2016
|
+
super()
|
2017
|
+
|
2018
|
+
end
|
2019
|
+
|
2020
|
+
alias to_summary to_s
|
2021
|
+
|
2022
|
+
end
|
2023
|
+
|
1789
2024
|
# MacroDroid Specific
|
1790
2025
|
#
|
1791
|
-
class SetVariableAction <
|
2026
|
+
class SetVariableAction < MacroDroidAction
|
1792
2027
|
using ColouredText
|
1793
2028
|
|
1794
2029
|
def initialize(obj=nil)
|
@@ -1878,7 +2113,7 @@ end
|
|
1878
2113
|
|
1879
2114
|
# MacroDroid Specific
|
1880
2115
|
#
|
1881
|
-
class TextManipulationAction <
|
2116
|
+
class TextManipulationAction < MacroDroidAction
|
1882
2117
|
|
1883
2118
|
def initialize(h={})
|
1884
2119
|
|
@@ -1921,7 +2156,7 @@ end
|
|
1921
2156
|
|
1922
2157
|
|
1923
2158
|
|
1924
|
-
class PauseAction <
|
2159
|
+
class PauseAction < MacroDroidAction
|
1925
2160
|
|
1926
2161
|
def initialize(h={})
|
1927
2162
|
|
@@ -1961,6 +2196,63 @@ end
|
|
1961
2196
|
|
1962
2197
|
# Category: Media
|
1963
2198
|
#
|
2199
|
+
|
2200
|
+
|
2201
|
+
# note: to find a package id from an App name, try searching for the name on
|
2202
|
+
# the Google Play Store and the id will be returned in the URL once the
|
2203
|
+
# correct app has been clicked. e.g.
|
2204
|
+
# https://play.google.com/store/apps/details?id=com.google.android.music
|
2205
|
+
#
|
2206
|
+
class ControlMediaAction < MediaAction
|
2207
|
+
|
2208
|
+
def initialize(obj=nil)
|
2209
|
+
|
2210
|
+
h = if obj.is_a? Hash then
|
2211
|
+
obj
|
2212
|
+
elsif obj.is_a? Array
|
2213
|
+
|
2214
|
+
e, macro, h2 = obj
|
2215
|
+
s = e.text('item/description').to_s
|
2216
|
+
app = s[/Simulate Media Button \(([^\)]+)/,1]
|
2217
|
+
|
2218
|
+
if app then
|
2219
|
+
|
2220
|
+
{
|
2221
|
+
application_name: app, package_name: APPS[app],
|
2222
|
+
simulate_media_button: true
|
2223
|
+
}.merge h2
|
2224
|
+
|
2225
|
+
else
|
2226
|
+
{}
|
2227
|
+
end
|
2228
|
+
end
|
2229
|
+
#puts 'h: ' + h.inspect
|
2230
|
+
|
2231
|
+
options = {
|
2232
|
+
application_name: "Google Play Music", option: "Play/Pause",
|
2233
|
+
package_name: "com.google.android.music",
|
2234
|
+
send_media_player_commands: false,
|
2235
|
+
simulate_media_button: true,
|
2236
|
+
}
|
2237
|
+
|
2238
|
+
super(options.merge h)
|
2239
|
+
|
2240
|
+
end
|
2241
|
+
|
2242
|
+
def to_s(colour: false, indent: 0)
|
2243
|
+
|
2244
|
+
@s = 'Media ' + @h[:option] #+ @h.inspect
|
2245
|
+
|
2246
|
+
if @h[:simulate_media_button] then
|
2247
|
+
@s += "\nSimulate Media Button (%s)" % @h[:application_name]
|
2248
|
+
end
|
2249
|
+
|
2250
|
+
super()
|
2251
|
+
end
|
2252
|
+
|
2253
|
+
alias to_summary to_s
|
2254
|
+
end
|
2255
|
+
|
1964
2256
|
class RecordMicrophoneAction < MediaAction
|
1965
2257
|
|
1966
2258
|
def initialize(h={})
|
@@ -86,10 +86,15 @@ class ActionsNlp
|
|
86
86
|
|
87
87
|
get /^take_picture/i do
|
88
88
|
[TakePictureAction, {}]
|
89
|
-
end
|
89
|
+
end
|
90
|
+
|
91
|
+
get /^Take Screenshot/i do
|
92
|
+
[TakeScreenshotAction, {}]
|
93
|
+
end
|
90
94
|
|
91
95
|
# -- DEVICE ACTIONS ------------------------------------------------------
|
92
96
|
|
97
|
+
#
|
93
98
|
get /^Speak text \(([^\)]+)\)/i do |text|
|
94
99
|
[SpeakTextAction, {text: text}]
|
95
100
|
end
|
@@ -100,7 +105,11 @@ class ActionsNlp
|
|
100
105
|
|
101
106
|
get /^Speak text$/i do |text|
|
102
107
|
[SpeakTextAction, {}]
|
103
|
-
end
|
108
|
+
end
|
109
|
+
|
110
|
+
get /^UI Interaction$/i do
|
111
|
+
[UIInteractionAction, {}]
|
112
|
+
end
|
104
113
|
|
105
114
|
get /^Vibrate \(([^\)]+)/i do |pattern|
|
106
115
|
[VibrateAction, {pattern: pattern}]
|
@@ -109,6 +118,19 @@ class ActionsNlp
|
|
109
118
|
get /^Vibrate$/i do |pattern|
|
110
119
|
[VibrateAction, {pattern: 'short buzz'}]
|
111
120
|
end
|
121
|
+
|
122
|
+
get /^Voice Search$/i do
|
123
|
+
[VoiceSearchAction, {}]
|
124
|
+
end
|
125
|
+
|
126
|
+
# -- Device settings ---------------------------------------
|
127
|
+
|
128
|
+
get /^Auto Rotate (On|Off|Toggle)$/i do |state|
|
129
|
+
|
130
|
+
a = %w(on off toggle)
|
131
|
+
|
132
|
+
[SetAutoRotateAction, {state: a.map(&:downcase).index(state.downcase)}]
|
133
|
+
end
|
112
134
|
|
113
135
|
# e.g. Display Notification: Hi there: This is the body of the message
|
114
136
|
get /^Display Notification: ([^:]+): [^$]+$/i do |subject, text|
|
@@ -123,6 +145,10 @@ class ActionsNlp
|
|
123
145
|
[SetWifiAction, {state: state}]
|
124
146
|
|
125
147
|
end
|
148
|
+
|
149
|
+
get /^Fill Clipboard$/i do
|
150
|
+
[ClipboardAction, {}]
|
151
|
+
end
|
126
152
|
|
127
153
|
# e.g. Play: Altair
|
128
154
|
get /^Play: (.*)$/i do |name|
|
@@ -130,14 +156,34 @@ class ActionsNlp
|
|
130
156
|
[PlaySoundAction, {file_path: name}]
|
131
157
|
|
132
158
|
end
|
159
|
+
|
160
|
+
get /^Launch Shortcut:? (?:Amazon|Ask) Alexa$/i do
|
161
|
+
[LaunchShortcutAction, {shortcut: 'Ask Alexa'}]
|
162
|
+
end
|
163
|
+
|
164
|
+
get /^Shortcut:? (?:Amazon|Ask) Alexa$/i do
|
165
|
+
[LaunchShortcutAction, {shortcut: 'Ask Alexa'}]
|
166
|
+
end
|
133
167
|
|
134
168
|
# e.g. Launch Settings
|
135
|
-
get /^Launch (.*)$/i do |
|
169
|
+
get /^Launch (.*)$/i do |s|
|
136
170
|
|
137
|
-
h = {
|
138
|
-
|
139
|
-
|
140
|
-
|
171
|
+
h = {}
|
172
|
+
|
173
|
+
if s[0] == '[' then
|
174
|
+
|
175
|
+
h[:launch_by_package_name] = s
|
176
|
+
h[:option] = 1
|
177
|
+
|
178
|
+
else
|
179
|
+
application = s
|
180
|
+
h[:application_name] = application
|
181
|
+
h[:package_to_launch] = APPS[application] || 'com.android.' +
|
182
|
+
application.downcase.split().join('.')
|
183
|
+
h[:option] = 0
|
184
|
+
|
185
|
+
end
|
186
|
+
|
141
187
|
[LaunchActivityAction, h]
|
142
188
|
|
143
189
|
end
|
@@ -155,6 +201,19 @@ class ActionsNlp
|
|
155
201
|
|
156
202
|
end
|
157
203
|
|
204
|
+
|
205
|
+
get /^Open Website \/ HTTP GET$/i do
|
206
|
+
|
207
|
+
[OpenWebPageAction, {http_get: false}]
|
208
|
+
|
209
|
+
end
|
210
|
+
|
211
|
+
get /^(?:open|goto) ((?:https?:\/\/|\[lv=)[^$]+)$/i do |url|
|
212
|
+
|
213
|
+
[OpenWebPageAction, url_to_open: url, http_get: false]
|
214
|
+
|
215
|
+
end
|
216
|
+
|
158
217
|
# e.g. webhook entered_kitchen
|
159
218
|
#
|
160
219
|
get /(?:webhook|HTTP GET) ([^$]+)$/i do |s|
|
@@ -221,6 +280,14 @@ class ActionsNlp
|
|
221
280
|
state = %w(enable disable toggle).index(rawstate.downcase)
|
222
281
|
[DisableMacroAction, {state: state}]
|
223
282
|
end
|
283
|
+
|
284
|
+
get /^Macro Run$/i do
|
285
|
+
[ForceMacroRunAction, {}]
|
286
|
+
end
|
287
|
+
|
288
|
+
get /^Run Macro$/i do
|
289
|
+
[ForceMacroRunAction, {}]
|
290
|
+
end
|
224
291
|
|
225
292
|
get /^Set Variable$/i do
|
226
293
|
[SetVariableAction, {}]
|
@@ -230,6 +297,14 @@ class ActionsNlp
|
|
230
297
|
[PauseAction, {delay_in_seconds: seconds.to_i}]
|
231
298
|
end
|
232
299
|
|
300
|
+
## -- Media -----------------------------------------
|
301
|
+
#
|
302
|
+
# options: Play/Pause, Previous, Next, Play, Pause, Stop
|
303
|
+
#
|
304
|
+
get /^Media ([^$]+)$/i do |option|
|
305
|
+
[ControlMediaAction, {option: option}]
|
306
|
+
end
|
307
|
+
|
233
308
|
# -- Screen ------------------------------------------------
|
234
309
|
#
|
235
310
|
get /^Screen (On|Off)$/i do |state|
|
data/lib/ruby-macrodroid/base.rb
CHANGED
@@ -12,7 +12,7 @@ module ObjectX
|
|
12
12
|
|
13
13
|
def action_to_object(ap, e, item, macro)
|
14
14
|
|
15
|
-
debug =
|
15
|
+
debug = true
|
16
16
|
|
17
17
|
puts 'inside action_to_object: item.xml: ' + item.xml if debug
|
18
18
|
|
@@ -34,7 +34,7 @@ module ObjectX
|
|
34
34
|
r = ap.find_action action
|
35
35
|
puts 'r: ' + r.inspect if debug
|
36
36
|
|
37
|
-
nested = description.element('item
|
37
|
+
nested = description.element('item/*')
|
38
38
|
puts 'nested: ' + nested.inspect if debug
|
39
39
|
|
40
40
|
if r[1].any? and not nested then
|
@@ -133,7 +133,8 @@ class MacroObject
|
|
133
133
|
end
|
134
134
|
|
135
135
|
def to_h()
|
136
|
-
|
136
|
+
|
137
|
+
@h.delete :macro
|
137
138
|
hashify(@h)
|
138
139
|
|
139
140
|
end
|
@@ -194,6 +195,7 @@ class MacroObject
|
|
194
195
|
|
195
196
|
end
|
196
197
|
|
198
|
+
|
197
199
|
private
|
198
200
|
|
199
201
|
def hashify(h)
|
@@ -1416,6 +1416,10 @@ class ActivityRecognitionTrigger < SensorsTrigger
|
|
1416
1416
|
|
1417
1417
|
end
|
1418
1418
|
|
1419
|
+
def match?(detail={})
|
1420
|
+
@h[:selected_index] == detail[:selected_index]
|
1421
|
+
end
|
1422
|
+
|
1419
1423
|
def to_s(colour: false)
|
1420
1424
|
|
1421
1425
|
activity = @activity[@h[:selected_index]]
|
@@ -1540,6 +1544,19 @@ class FlipDeviceTrigger < SensorsTrigger
|
|
1540
1544
|
|
1541
1545
|
end
|
1542
1546
|
|
1547
|
+
def match?(detail={})
|
1548
|
+
|
1549
|
+
fd = detail[:face_down]
|
1550
|
+
|
1551
|
+
b = if fd.is_a? String then
|
1552
|
+
fd.downcase == 'true'
|
1553
|
+
else
|
1554
|
+
fd
|
1555
|
+
end
|
1556
|
+
|
1557
|
+
@h[:face_down] == b
|
1558
|
+
end
|
1559
|
+
|
1543
1560
|
def to_pc()
|
1544
1561
|
@h[:face_down] ? 'flip_device_down?' : 'flip_device_up?'
|
1545
1562
|
end
|
@@ -1771,6 +1788,21 @@ class SwipeTrigger < Trigger
|
|
1771
1788
|
super(options.merge h)
|
1772
1789
|
|
1773
1790
|
end
|
1791
|
+
|
1792
|
+
def match?(detail={}, model=nil)
|
1793
|
+
|
1794
|
+
puts 'detail : ' + detail.inspect
|
1795
|
+
|
1796
|
+
return false if detail.empty?
|
1797
|
+
|
1798
|
+
detail[:swipe_start_area] = detail[:start]
|
1799
|
+
detail[:swipe_motion] = detail[:motion]
|
1800
|
+
return unless detail[:swipe_start_area] and detail[:swipe_motion]
|
1801
|
+
|
1802
|
+
@h[:swipe_start_area] == detail[:swipe_start_area].to_i and \
|
1803
|
+
@h[:swipe_motion] == detail[:swipe_motion].to_i
|
1804
|
+
|
1805
|
+
end
|
1774
1806
|
|
1775
1807
|
def to_s(colour: false)
|
1776
1808
|
|
@@ -67,6 +67,8 @@ class TriggersNlp
|
|
67
67
|
[WifiConnectionTrigger, {}]
|
68
68
|
end
|
69
69
|
|
70
|
+
|
71
|
+
|
70
72
|
# -- Device Events ----------------------------------------------------
|
71
73
|
|
72
74
|
get /^NFC Tag$/i do |state|
|
@@ -185,7 +187,27 @@ class TriggersNlp
|
|
185
187
|
|
186
188
|
get /^Swipe Screen$/i do
|
187
189
|
[SwipeTrigger, {}]
|
188
|
-
end
|
190
|
+
end
|
191
|
+
|
192
|
+
get /^Swipe (top left) (across|diagonal|down)$/i do |start, motion|
|
193
|
+
|
194
|
+
swipe_motion = case motion.downcase.to_sym
|
195
|
+
when :across
|
196
|
+
0
|
197
|
+
when :diagonal
|
198
|
+
1
|
199
|
+
when :down
|
200
|
+
2
|
201
|
+
end
|
202
|
+
|
203
|
+
h = {
|
204
|
+
swipe_start_area: (start.downcase == 'top left' ? 0 : 1),
|
205
|
+
swipe_motion: swipe_motion
|
206
|
+
}
|
207
|
+
|
208
|
+
[SwipeTrigger, h]
|
209
|
+
|
210
|
+
end
|
189
211
|
|
190
212
|
end
|
191
213
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-macrodroid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
NZ2kdBIUDnAM24e0/wXdVxg4HnsZbdymxyzMQ4P5pKYcpI6oisBxI37p/Xy+wAg3
|
36
36
|
SBHno3GEuuD8ZWj24IMJpfbp
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2020-10-
|
38
|
+
date: 2020-10-25 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: glw
|
metadata.gz.sig
CHANGED
Binary file
|