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.



2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
# File 'lib/ruby-macrodroid/actions.rb', line 2118

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



2148
2149
2150
# File 'lib/ruby-macrodroid/actions.rb', line 2148

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

#to_pcObject



2152
2153
2154
# File 'lib/ruby-macrodroid/actions.rb', line 2152

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

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



2156
2157
2158
2159
# File 'lib/ruby-macrodroid/actions.rb', line 2156

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