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.



2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
# File 'lib/ruby-macrodroid/actions.rb', line 2591

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



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

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

#to_pcObject



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

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

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



2629
2630
2631
2632
# File 'lib/ruby-macrodroid/actions.rb', line 2629

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