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.



2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
# File 'lib/ruby-macrodroid/actions.rb', line 2170

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



2200
2201
2202
# File 'lib/ruby-macrodroid/actions.rb', line 2200

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

#to_pcObject



2204
2205
2206
# File 'lib/ruby-macrodroid/actions.rb', line 2204

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

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



2208
2209
2210
2211
# File 'lib/ruby-macrodroid/actions.rb', line 2208

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