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.



2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
# File 'lib/ruby-macrodroid/actions.rb', line 2586

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



2616
2617
2618
# File 'lib/ruby-macrodroid/actions.rb', line 2616

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

#to_pcObject



2620
2621
2622
# File 'lib/ruby-macrodroid/actions.rb', line 2620

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

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



2624
2625
2626
2627
# File 'lib/ruby-macrodroid/actions.rb', line 2624

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