Class: ToastAction

Inherits:
NotificationsAction show all
Defined in:
lib/ruby-macrodroid/actions.rb

Overview

Category: Notifications

Instance Attribute Summary

Attributes inherited from Action

#constraints

Attributes inherited from MacroObject

#options, #siguid, #type

Instance Method Summary collapse

Methods included from ObjectX

#action_to_object, #object_create, #varify

Methods inherited from MacroObject

#to_h

Constructor Details

#initialize(obj) ⇒ ToastAction

Returns a new instance of ToastAction.



2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
# File 'lib/ruby-macrodroid/actions.rb', line 2552

def initialize(obj)
  
  h = if obj.is_a? Hash then
    obj
  elsif obj.is_a? Array
    e, macro = obj
    txt = e.text('item/description')
    {msg: (txt || e.text)}
  end

  if h[:msg] then
    h[:message_text] = h[:msg]
    h.delete :msg
  end
  
  options = {
    message_text: '',
    image_resource_name: 'launcher_no_border',
    image_package_name: 'com.arlosoft.macrodroid',
    image_name: 'launcher_no_border',
    duration: 0,
    display_icon: true,
    background_color: -12434878,
    position: 0
  }

  super(options.merge h)

end

Instance Method Details

#invokeObject



2582
2583
2584
# File 'lib/ruby-macrodroid/actions.rb', line 2582

def invoke()
  super(msg: @h[:message_text])
end

#to_pcObject



2586
2587
2588
# File 'lib/ruby-macrodroid/actions.rb', line 2586

def to_pc()
  "popup_message '%s'" % @h[:message_text]
end

#to_s(colour: false, indent: 0) ⇒ Object



2590
2591
2592
2593
# File 'lib/ruby-macrodroid/actions.rb', line 2590

def to_s(colour: false, indent: 0)
  @s = "Popup Message\n%s" % @h[:message_text]
  super()
end