148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
|
# File 'lib/ruby-macrodroid.rb', line 148
def actions(params)
get /^message popup: (.*)/i do |msg|
[ToastAction, {msg: msg}]
end
get /^Popup[ _]Message ['"]([^'"]+)/i do |msg|
[ToastAction, {msg: msg}]
end
get /^say current[ _]time/i do
[SayTimeAction, {}]
end
get /^Torch :?(.*)/i do |onoffstate|
state = onoffstate.downcase == 'on' ? 0 : 1
[CameraFlashLightAction, {state: state}]
end
get /^Take Picture/i do
[TakePictureAction, {}]
end
get /^take_picture/i do
[TakePictureAction, {}]
end
get /^Display Notification: ([^:]+): [^$]+$/i do |subject, text|
[NotificationAction, {subject: subject, text: text}]
end
get /^(Enable|Disable) Wifi$/i do |raw_state|
state = raw_state.downcase.to_sym == :enable ? 0 : 1
[SetWifiAction, {state: state}]
end
get /^Play: (.*)$/i do |name|
[PlaySoundAction, {file_path: name}]
end
get /^Launch (.*)$/i do |application|
h = {
application_name: application,
package_to_launch: 'com.android.' + application.downcase
}
[LaunchActivityAction, h]
end
get /^HTTP GET ([^$]+)$/i do |url|
[OpenWebPageAction, url_to_open: url]
end
get /webhook|HTTP GET/i do
[OpenWebPageAction, {}]
end
get /Keep Device Awake Screen On Until Disabled/i do
[KeepAwakeAction, {enabled: true, permanent: true, screen_option: 0}]
end
get /Keep Device Awake Screen On ([^$]+)/i do |duration|
a = duration.split.map(&:to_i)
secs = Subunit.new(units={minutes:60, hours:60, seconds: 60}, a).to_i
h = {
permanent: true, screen_option: 0, seconds_to_stay_awake_for: secs
}
[KeepAwakeAction, h]
end
get /Disable Keep Awake/i do
[KeepAwakeAction, {enabled: false, screen_option: 0}]
end
end
|