Class: UIInteractionAction

Inherits:
DeviceAction show all
Defined in:
lib/ruby-macrodroid/actions.rb

Overview

Category: Device Actions

Instance Attribute Summary

Attributes inherited from Action

#constraints

Attributes inherited from MacroObject

#options, #siguid, #type

Instance Method Summary collapse

Methods inherited from Action

#invoke

Methods included from ObjectX

#action_to_object, #object_create, #varify

Methods inherited from MacroObject

#to_h

Constructor Details

#initialize(h = {}) ⇒ UIInteractionAction

Returns a new instance of UIInteractionAction.



928
929
930
931
932
933
934
935
936
937
# File 'lib/ruby-macrodroid/actions.rb', line 928

def initialize(h={})

  options = {
    ui_interaction_configuration: {:type=>"Copy"},
    action: 2
  }

  super(options.merge h)

end

Instance Method Details

#to_s(colour: false, indent: 0) ⇒ Object Also known as: to_summary



939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
# File 'lib/ruby-macrodroid/actions.rb', line 939

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
  
  'UI Interaction' + "\n  " + s #+ ' ' + @h.inspect
end