@@ -3,8 +3,7 @@ module Android
3
3
# @private
4
4
# http://nokogiri.org/Nokogiri/XML/SAX.html
5
5
class AndroidElements < Nokogiri ::XML ::SAX ::Document
6
- # TODO: Support strings.xml ids
7
- attr_reader :result , :keys
6
+ attr_reader :result , :keys , :instance
8
7
9
8
def filter
10
9
@filter
@@ -20,17 +19,22 @@ def filter= value
20
19
def initialize
21
20
reset
22
21
@filter = false
22
+ @instance = Hash . new -1
23
23
end
24
24
25
25
def reset
26
26
@result = ''
27
27
@keys = %w[ text resource-id content-desc ]
28
+ @instance = Hash . new -1
28
29
end
29
30
30
31
# http://nokogiri.org/Nokogiri/XML/SAX/Document.html
31
32
def start_element name , attrs = [ ]
32
33
return if filter && !name . downcase . include? ( filter )
33
34
35
+ # instance numbers start at 0.
36
+ number = instance [ name ] += 1
37
+
34
38
attributes = { }
35
39
36
40
attrs . each do |key , value |
@@ -75,7 +79,7 @@ def start_element name, attrs = []
75
79
string += " id: #{ id } \n " unless id . nil?
76
80
string += " strings.xml: #{ string_ids } " unless string_ids . nil?
77
81
78
- @result += "\n #{ name } \n #{ string } " unless attributes . empty?
82
+ @result += "\n #{ name } ( #{ number } ) \n #{ string } " unless attributes . empty?
79
83
end
80
84
end # class AndroidElements
81
85
0 commit comments