Class: ScreenOnAction

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

Overview

Category: Screen

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(obj = nil) ⇒ ScreenOnAction

Returns a new instance of ScreenOnAction.



2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
# File 'lib/ruby-macrodroid/actions.rb', line 2794

def initialize(obj=nil)
  
  debug = false
  
  h = if obj.is_a? Hash then
  
    obj
    
  elsif obj.is_a? Array
=begin      
    puts 'obj: ' + obj.inspect if debug
    e, macro = obj
    puts ('e: ' + e.xml.inspect).debug if debug
    a = e.xpath('item/*')

    txt = e.text.to_s
    puts ('txt: ' + txt.inspect).debug if debug
    state = txt[/Screen (On|Off)/i,1]
    
    {screen_off: state.downcase == 'off'}
=end      

    {}
  end    

  options = {
    pie_lock_screen: false,
    screen_off: true,
    screen_off_no_lock: false,
    screen_on_alternative: false
  }

  super(options.merge h)

end

Instance Method Details

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



2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
# File 'lib/ruby-macrodroid/actions.rb', line 2829

def to_s(colour: false, indent: 0)
  
  state = @h[:screen_off] ? 'Off' : 'On'
  state += ' ' + 'No Lock (root only)' if @h[:screen_off_no_lock]
  #state += ' ' + '(Alternative)' if @h[:screen_on_alternative]
  
  @s = 'Screen ' + state
  super()
  
end