ruby-macrodroid 0.9.7 → 0.9.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3784001df302ddb9f8389ea019f860925803b96913f4531839df140f48634857
4
- data.tar.gz: 686838c12129f1cd329d72745f37a7cb81ed91d98cdea059a5b59938d6d8b9e3
3
+ metadata.gz: f79a66c628c78bab4c858805ac6486083331723153022cb23030485701b16eea
4
+ data.tar.gz: d2bf06bef9e246852f4ec40a31f267ce2f94b66293318fb82ea864a4d5c15e0e
5
5
  SHA512:
6
- metadata.gz: 948ceb9a759bf97fd4e4786fe35f95aee1a76d971ced0553c3984a885bae87155a18747a77c27d2daf7e928847cd503e19820e648956b0a93a62ef056a5992a9
7
- data.tar.gz: d9ae51714a522375bd2aa92410f4a9412d83903d29ca33892cdd55a61dfab08faf7d02da292bdda2506715ca6948cdd308e0be4a03eb16b8010f5b56dd291ce0
6
+ metadata.gz: 00ab9a577c80b81d017ebbb35d3e8a746d1d78ddde05473dd87be5c6a5365a3d7ed83e3501cf0402e3b2919be7dff1fe59f1e12c2f309649b69e3fd99e19824d
7
+ data.tar.gz: fa4786c3f3bc343b6e242f5c8abfb6a438edae01df19b623b3d7b27fb610bc4c56f323071ea76890700b6493ede5df714a55f9b2ef619f1c37104832a59d75f8
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -110,14 +110,16 @@ class MacroDroid
110
110
  using Params
111
111
 
112
112
  attr_reader :macros, :geofences, :yaml
113
- attr_accessor :deviceid, :remote_url
113
+ attr_accessor :deviceid, :remote_url, :picture_path
114
114
 
115
115
  # note: The deviceid can only be found from an existing Webhook trigger,
116
116
  # generated from MacroDroid itself.
117
117
 
118
- def initialize(obj=nil, deviceid: nil, remote_url: nil, debug: false)
118
+ def initialize(obj=nil, deviceid: nil, remote_url: nil,
119
+ picture_path: '/storage/emulated/0/Pictures', debug: false)
119
120
 
120
121
  @deviceid, @remote_url, @debug = deviceid, remote_url, debug
122
+ @picture_path = picture_path
121
123
 
122
124
  @geofences = {}
123
125
 
@@ -334,7 +336,8 @@ class MacroDroid
334
336
  # puts '@geofences: ' + @geofences.inspect if @debug
335
337
 
336
338
  m = Macro.new(geofences: @geofences.map(&:last), deviceid: @deviceid,
337
- remote_url: @remote_url, debug: @debug )
339
+ remote_url: @remote_url, picture_path: @picture_path,
340
+ debug: @debug )
338
341
  m.import_h(macro)
339
342
  m
340
343
 
@@ -356,7 +359,8 @@ class MacroDroid
356
359
  @macros = doc.root.xpath('item').map do |node|
357
360
  puts ('geofences: ' + geofences.inspect).highlight if @debug
358
361
  Macro.new(geofences: geofences.map(&:last), deviceid: @deviceid,
359
- remote_url: @remote_url, debug: @debug).import_xml(node)
362
+ remote_url: @remote_url, picture_path: @picture_path,
363
+ debug: @debug).import_xml(node)
360
364
 
361
365
  end
362
366
 
@@ -380,7 +384,7 @@ class MacroDroid
380
384
  @macros = doc.root.xpath('macro').map do |node|
381
385
  puts 'node: ' + node.inspect if @debug
382
386
  Macro.new(geofences: @geofences.map(&:last), deviceid: @deviceid,
383
- debug: @debug).import_xml(node)
387
+ picture_path: @picture_path, debug: @debug).import_xml(node)
384
388
 
385
389
  end
386
390
  end
@@ -284,11 +284,64 @@ end
284
284
  #
285
285
  class TakePictureAction < CameraAction
286
286
 
287
- def initialize(h={})
287
+ def initialize(obj=nil)
288
+
289
+
290
+ h = if obj.is_a? Hash then
291
+
292
+ macro = obj[:macro]
293
+ obj.delete :macro
294
+ obj
295
+
296
+
297
+ elsif obj.is_a? Array
298
+
299
+ e, macro = obj
300
+
301
+ puts 'e: ' + e.xml.inspect
302
+
303
+ a = e.xpath('item/*')
304
+
305
+ if a.any? then
306
+
307
+ h2 = a.map {|node| [node.name.to_sym, node.text.to_s.strip]}.to_h
308
+
309
+ desc = ''
310
+
311
+ if h2[:description] then
312
+
313
+ desc = h2[:description]
314
+ h2.delete :description
315
+ puts 'desc: ' + desc.inspect
316
+
317
+ if desc.length > 1 then
318
+
319
+ flash = case desc
320
+ when /Flash On/i
321
+ 1
322
+ when /Flash Auto/i
323
+ 2
324
+ else
325
+ 0
326
+ end
327
+
288
328
 
329
+ end
330
+
331
+ end
332
+
333
+ {
334
+ use_front_camera: (desc =~ /Front Facing/ ? true : false),
335
+ flash_option: flash
336
+ }.merge(h2)
337
+
338
+
339
+ end
340
+ end
341
+
289
342
  options = {
290
- new_path: '/storage/sdcard1/DCIM/Camera',
291
- path: '/storage/sdcard1/DCIM/Camera',
343
+ new_path: macro.picture_path,
344
+ path: macro.picture_path,
292
345
  show_icon: true,
293
346
  use_front_camera: true,
294
347
  flash_option: 0
@@ -304,7 +357,22 @@ class TakePictureAction < CameraAction
304
357
  end
305
358
 
306
359
  def to_s(colour: false, indent: 0)
307
- 'Take Picture'
360
+
361
+ flash = case @h[:flash_option]
362
+ when 0
363
+ ''
364
+ when 1
365
+ 'Flash On'
366
+ when 2
367
+ 'Flash Auto'
368
+ end
369
+
370
+ @s = 'Take Picture'# + @h.inspect
371
+ a = [@h[:use_front_camera] ? 'Front Facing' : 'Rear Facing']
372
+ a << flash if flash.length > 0
373
+ @s += "\n" + a.join(', ')
374
+ super()
375
+
308
376
  end
309
377
 
310
378
  end
@@ -68,7 +68,14 @@ class TriggersNlp
68
68
  }
69
69
 
70
70
  [ExternalPowerTrigger, h]
71
- end
71
+ end
72
+
73
+ # -- Device Events ----------------------------------------------------
74
+
75
+ get /^Screen[ _](On|Off)/i do |state|
76
+ [ScreenOnOffTrigger, {screen_on: state.downcase == 'on'}]
77
+ end
78
+
72
79
  # e.g. at 7:30pm daily
73
80
  get /^(?:at )?(\d+:\d+(?:[ap]m)?) daily/i do |time, days|
74
81
  [TimerTrigger, {time: time,
@@ -465,13 +472,13 @@ class Macro
465
472
 
466
473
  attr_reader :local_variables, :triggers, :actions, :constraints,
467
474
  :guid, :deviceid
468
- attr_accessor :title, :description, :remote_url
475
+ attr_accessor :title, :description, :remote_url, :picture_path
469
476
 
470
- def initialize(name=nil, geofences: nil, deviceid: nil, remote_url: nil,
471
- debug: false)
477
+ def initialize(name=nil, geofences: nil, deviceid: nil, remote_url: nil, \
478
+ picture_path: nil, debug: false)
472
479
 
473
480
  @title, @geofences, @deviceid, @debug = name, geofences, deviceid, debug
474
- @remote_url = remote_url
481
+ @remote_url, @picture_path = remote_url, picture_path
475
482
 
476
483
  puts 'inside Macro#initialize' if @debug
477
484
 
@@ -1199,6 +1199,11 @@ class ScreenOnOffTrigger < DeviceEventsTrigger
1199
1199
 
1200
1200
  end
1201
1201
 
1202
+ def match?(detail={}, model=nil)
1203
+ #@h[:screen_on] == detail[:screen_on]
1204
+ true
1205
+ end
1206
+
1202
1207
  def to_s(colour: false)
1203
1208
  'Screen ' + (@h[:screen_on] ? 'On' : 'Off')
1204
1209
  end
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.7
4
+ version: 0.9.8
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-14 00:00:00.000000000 Z
38
+ date: 2020-10-16 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: glw
metadata.gz.sig CHANGED
Binary file