Class: UIInteractionAction
- Inherits:
-
DeviceAction
- Object
- MacroObject
- Action
- DeviceAction
- UIInteractionAction
- Defined in:
- lib/ruby-macrodroid/actions.rb
Overview
Category: Device Actions
Instance Attribute Summary
Attributes inherited from Action
Attributes inherited from MacroObject
Instance Method Summary collapse
-
#initialize(obj = nil) ⇒ UIInteractionAction
constructor
A new instance of UIInteractionAction.
- #to_s(colour: false, indent: 0) ⇒ Object (also: #to_summary)
Methods inherited from Action
Methods included from ObjectX
#action_to_object, #object_create, #varify
Methods inherited from MacroObject
Constructor Details
#initialize(obj = nil) ⇒ UIInteractionAction
Returns a new instance of UIInteractionAction.
1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 |
# File 'lib/ruby-macrodroid/actions.rb', line 1167 def initialize(obj=nil) if obj.is_a? Hash then h = obj elsif obj.is_a? Array e, macro = obj s = e.text('item/description').to_s r = s.match(/^(Click|Long Click) \[(.*)\]$/) # [Current focus] # Current focus # [0,0] # x,y location # [274,186] # Identify in app # [fooo] # Text content h = { ui_interaction_configuration: { :xy_point=>{:x=>0, :y=>0}, :type=>"Click"} } h2 = h[:ui_interaction_configuration] if r then h[:action] = 0 click, detail = r.captures h2[:long_click] = false if click.downcase.to_sym == :click if detail == 'Current focus' then h2[:click_option] = 0 elsif detail =~ /\d+,\d+/ # to-do else # text content h2[:click_option] = 1 h2[:text_content] = detail end #h[:ui_interaction_configuration] = h2 end end = { ui_interaction_configuration: {:type=>"Copy"}, action: 2 } super(.merge h) @list = %w(uiInteractionConfiguration action xyPoint textContent clickOption type longClick) end |
Instance Method Details
#to_s(colour: false, indent: 0) ⇒ Object Also known as: to_summary
1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 |
# File 'lib/ruby-macrodroid/actions.rb', line 1224 def to_s(colour: false, indent: 0) ui = @h[:ui_interaction_configuration] option = -> do detail = case ui[:click_option] when 0 # 'Current focus' 'Current focus' when 1 # 'Text content' ui[:text_content] when 2 # 'X, Y location' "%s" % ui[:xy_point].values.join(',') when 3 # 'Identify in app' "id:%s" % ui[:view_id] end end s = case @h[:action] when 0 # 'Click' 'Click' + " [%s]" % option.call when 1 # 'Long Click' 'Long Click' + " [%s]" % option.call when 2 # 'Copy' 'Copy' when 3 # 'Cut' 'Cut' when 4 # 'Paste' "Paste [%s]" % (ui[:use_clipboard] ? 'Clipboard text' : ui[:text]) when 5 # 'Clear selection' 'Clear selection' when 6 # 'Gesture' detail = "%d ms: %d,%d -> %d,%d" % [ui[:duration_ms], ui[:start_x], ui[:start_y], ui[:end_x], ui[:end_y]] "Gesture [%s]" % detail end @s = 'UI Interaction' + "\n" + s #+ ' ' + @h.inspect super() end |