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 inherited from MacroObject

#to_h

Constructor Details

#initialize(obj) ⇒ ToastAction

Returns a new instance of ToastAction.



1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
# File 'lib/ruby-macrodroid/actions.rb', line 1853

def initialize(obj)
  
  h = if obj.is_a? Hash then
    obj
  else
    {msg: obj}
  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



1881
1882
1883
# File 'lib/ruby-macrodroid/actions.rb', line 1881

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

#to_pcObject



1885
1886
1887
# File 'lib/ruby-macrodroid/actions.rb', line 1885

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

#to_s(colour: false) ⇒ Object



1889
1890
1891
# File 'lib/ruby-macrodroid/actions.rb', line 1889

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