droiuby 0.1.6 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +7 -0
  2. data/lib/droiuby.rb +1 -1
  3. data/lib/droiuby/android.rb +59 -0
  4. data/lib/droiuby/application.rb +30 -0
  5. data/lib/droiuby/bootstrap.rb +263 -0
  6. data/lib/droiuby/droiuby.rb +47 -0
  7. data/lib/droiuby/loader.rb +36 -0
  8. data/lib/droiuby/plugins/plugins.rb +25 -0
  9. data/lib/droiuby/preload.rb +29 -0
  10. data/lib/droiuby/{project.rb → scripts/project.rb} +15 -6
  11. data/lib/droiuby/scripts/templates/ruby/Gemfile.erb +3 -0
  12. data/lib/droiuby/{templates → scripts/templates}/ruby/application.css.erb +0 -0
  13. data/lib/droiuby/{templates → scripts/templates}/ruby/config.droiuby.erb +0 -0
  14. data/lib/droiuby/{templates → scripts/templates}/ruby/gitignore.erb +0 -0
  15. data/lib/droiuby/{templates → scripts/templates}/ruby/index.rb.erb +0 -0
  16. data/lib/droiuby/{templates → scripts/templates}/ruby/index.xml.erb +0 -0
  17. data/lib/droiuby/support/asset.rb +47 -0
  18. data/lib/droiuby/support/autoload.rb +22 -0
  19. data/lib/droiuby/support/fixnum.rb +11 -0
  20. data/lib/droiuby/support/object.rb +11 -0
  21. data/lib/droiuby/support/string.rb +38 -0
  22. data/lib/droiuby/support/system.rb +14 -0
  23. data/lib/droiuby/support/thread.rb +17 -0
  24. data/lib/droiuby/support/to_query.rb +28 -0
  25. data/lib/droiuby/support/utils.rb +10 -0
  26. data/lib/droiuby/wrappers/accelerometer.rb +17 -0
  27. data/lib/droiuby/wrappers/activity.rb +64 -0
  28. data/lib/droiuby/wrappers/animation.rb +141 -0
  29. data/lib/droiuby/wrappers/async.rb +33 -0
  30. data/lib/droiuby/wrappers/button.rb +2 -0
  31. data/lib/droiuby/wrappers/canvas.rb +147 -0
  32. data/lib/droiuby/wrappers/collection/view_array.rb +21 -0
  33. data/lib/droiuby/wrappers/compound_button_wrapper.rb +25 -0
  34. data/lib/droiuby/wrappers/edit_text.rb +22 -0
  35. data/lib/droiuby/wrappers/image_button.rb +8 -0
  36. data/lib/droiuby/wrappers/intent.rb +24 -0
  37. data/lib/droiuby/wrappers/java_helpers/java_method_helper.rb +42 -0
  38. data/lib/droiuby/wrappers/java_helpers/view_helper.rb +84 -0
  39. data/lib/droiuby/wrappers/linear_layout.rb +15 -0
  40. data/lib/droiuby/wrappers/list_adapter_wrapper.rb +61 -0
  41. data/lib/droiuby/wrappers/list_view.rb +10 -0
  42. data/lib/droiuby/wrappers/listeners/auto_wrap.rb +72 -0
  43. data/lib/droiuby/wrappers/listeners/on_click_listener.rb +21 -0
  44. data/lib/droiuby/wrappers/listeners/on_web_console_ready_listener.rb +23 -0
  45. data/lib/droiuby/wrappers/motion_events.rb +34 -0
  46. data/lib/droiuby/wrappers/preferences.rb +59 -0
  47. data/lib/droiuby/wrappers/proxy_builder/interface_builder.rb +25 -0
  48. data/lib/droiuby/wrappers/runnable_wrapper.rb +16 -0
  49. data/lib/droiuby/wrappers/surface_view_wrapper.rb +59 -0
  50. data/lib/droiuby/wrappers/text_view.rb +28 -0
  51. data/lib/droiuby/wrappers/thread_pool.rb +18 -0
  52. data/lib/droiuby/wrappers/view_group_wrapper.rb +87 -0
  53. data/lib/droiuby/wrappers/view_wrapper.rb +221 -0
  54. data/lib/droiuby/wrappers/web_view.rb +16 -0
  55. data/lib/droiuby/wrappers/wrappers.rb +5 -0
  56. metadata +77 -51
@@ -0,0 +1,221 @@
1
+ require 'droiuby/wrappers/animation'
2
+ require 'droiuby/wrappers/java_helpers/view_helper'
3
+
4
+ class ViewWrapper
5
+
6
+ include JavaMethodHelper
7
+ include Droiuby::ViewHelper
8
+ include Droiuby::Wrappers::Listeners
9
+
10
+ java_fast_accessor Java::android.view.View, [Java::float], :x, :y
11
+
12
+ java_attr_accessor :right, :left, :top, :bottom, :alpha, :rotation, :pivot_x, :pivot_y, :translation_x,
13
+ :translation_y, :scroll_x, :scroll_y, :scale_x, :scale_y, :rotation_x, :rotation_y, :camera_distance,
14
+ :padding_left, :padding_top, :padding_right, :padding_bottom
15
+
16
+ java_attr_reader :id, :width, :height, :measured_width, :measured_height, :background
17
+ java_attr_writer :selected
18
+
19
+ java_attr_boolean_reader :selected
20
+
21
+
22
+ def initialize(view = nil)
23
+ unless view.nil?
24
+ @view = view
25
+ else
26
+ @view = Java::com.droiuby.wrappers.ViewRubyWrapper.new(_execution_bundle, self, _current_activity)
27
+ end
28
+ @builder = Java::com.droiuby.client.core.builder.ViewBuilder.new
29
+ @builder.setContext(_current_activity)
30
+ end
31
+
32
+ def native
33
+ @view
34
+ end
35
+
36
+ def builder
37
+ @builder
38
+ end
39
+
40
+ def background=(background)
41
+ if background.kind_of? DrawableWrapper
42
+ @view.setBackgroundDrawable(background.native)
43
+ else
44
+ builder.setProperty(native,'background', background.to_s)
45
+ end
46
+ end
47
+
48
+ def width=(width)
49
+ builder.setProperty(native,'width', width.to_s)
50
+ end
51
+
52
+ def height=(height)
53
+ builder.setProperty(native,'height', height.to_s)
54
+ end
55
+
56
+ def background_color=(value)
57
+ @view.setBackgroundColor(parse_color(value));
58
+ end
59
+
60
+ def gone=(flag)
61
+ @view.setVisibility(Java::android.view.View::GONE) if flag
62
+ end
63
+
64
+ def gone?
65
+ hidden?
66
+ end
67
+
68
+ def invalidate
69
+ @view.invalidate
70
+ end
71
+
72
+ def hidden?
73
+ @view.getVisibility == Java::android.view.View::GONE
74
+ end
75
+
76
+ def show!
77
+ @view.setVisibility(Java::android.view.View::VISIBLE)
78
+ end
79
+
80
+ def hide!
81
+ @view.setVisibility(Java::android.view.View::GONE)
82
+ end
83
+
84
+ def to_front!
85
+ @view.bringToFront
86
+ end
87
+
88
+ def visible=(flag)
89
+ @view.setVisibility(flag ? Java::android.view.View::VISIBLE : Java::android.view.View::INVISIBLE)
90
+ end
91
+
92
+ def visible?
93
+ @view.getVisibility == Java::android.view.View::VISIBLE
94
+ end
95
+
96
+ def enabled=(flag)
97
+ @view.setEnabled(flag)
98
+ end
99
+
100
+ def enabled?
101
+ @view.isEnabled
102
+ end
103
+
104
+ def parent
105
+ wrap_native_view(@view.getParent)
106
+ end
107
+
108
+ def blink
109
+ orig_alpha = self.alpha
110
+ view = self
111
+ self.animate { |a|
112
+ a.alpha 0, 1
113
+ }.on(:end) { |v|
114
+ view.alpha = orig_alpha
115
+ }.start
116
+ end
117
+
118
+ def find(selectors)
119
+ view = _activity_builder.findViewByName(selectors, self.native, false)
120
+ if (view.kind_of? Java::java.util.ArrayList)
121
+ view.toArray.to_a.collect do |element|
122
+ wrap_native_view(element)
123
+ end
124
+ else
125
+ wrap_native_view(view) if view
126
+ end
127
+ end
128
+
129
+ def animate(&block)
130
+ animator = Animator.new(self)
131
+ block.call(animator)
132
+ animator.done
133
+ animator
134
+ end
135
+
136
+ def to_native(target)
137
+ if child.kind_of? ViewWrapper
138
+ target.native
139
+ elsif target.kind_of? Java::android.view.View.new
140
+ target
141
+ end
142
+ end
143
+
144
+ def click
145
+ self.native.performClick
146
+ end
147
+
148
+ def p_tree(level = 0, extra_attributes = %w[measured_height measured_width])
149
+ spaces = ''
150
+ level.times { |i| spaces << ' '}
151
+
152
+ id_attr = self.id
153
+ name_attr = ""
154
+ class_attr = ""
155
+
156
+ if tag
157
+ id_attr = tag.getView_id
158
+ name_attr = tag.getView_name
159
+ class_attr = tag.getView_class
160
+ else
161
+ rid = reverse_resolve(id_attr)
162
+ id_attr = "^#{rid}" unless rid.nil?
163
+ end
164
+
165
+ data_attribute_list = []
166
+ if _extras
167
+ attributes = _extras.getDataAttributes
168
+
169
+ attributes.keySet.each do |key|
170
+ data_attribute_list << "data-#{key}=\"#{self.data(key)}\""
171
+ end
172
+ end
173
+
174
+ extra_attributes.each do |attr|
175
+ data_attribute_list << "#{attr.to_sym}=\"#{self.send(attr.to_sym)}\""
176
+ end
177
+
178
+ puts "#{spaces}#{self.class.name} id=\"#{id_attr}\" name=\"#{name_attr}\" class=\"#{class_attr}\" #{data_attribute_list.join(' ')}\n"
179
+ self.children.each { |c|
180
+ c.p_tree(level + 1, extra_attributes)
181
+ } if self.respond_to? :children
182
+ end
183
+
184
+ def tag
185
+ unless native.getTag.nil?
186
+ tag = native.getTag
187
+ if tag.kind_of? Java::com.droiuby.client.core.ViewExtras
188
+ return tag
189
+ end
190
+ end
191
+ nil
192
+ end
193
+
194
+ def data(key)
195
+ if _extras
196
+ data_attributes = _extras.getDataAttributes
197
+ if data_attributes.containsKey(key)
198
+ data_attributes.get(key)
199
+ end
200
+ end
201
+ end
202
+
203
+ protected
204
+
205
+ def parse_color(color_value)
206
+ if color_value.kind_of? String
207
+ Java::android.graphics.Color.parseColor(color_value);
208
+ else
209
+ color_value
210
+ end
211
+ end
212
+
213
+ def _extras
214
+ unless native.getTag.nil?
215
+ tag = native.getTag
216
+ if tag.kind_of? Java::com.droiuby.client.core.ViewExtras
217
+ tag
218
+ end
219
+ end
220
+ end
221
+ end
@@ -0,0 +1,16 @@
1
+ require 'droiuby/wrappers/view_wrapper'
2
+
3
+ class WebViewWrapper < ViewGroupWrapper
4
+ def src
5
+ @native.getUrl
6
+ end
7
+
8
+ def src=(url)
9
+ @native.loadUrl(url)
10
+ end
11
+
12
+ def reload!
13
+ @native.reload
14
+ end
15
+
16
+ end
@@ -0,0 +1,5 @@
1
+ module Droiuby
2
+ module Wrappers
3
+
4
+ end
5
+ end
metadata CHANGED
@@ -1,110 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: droiuby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Joseph Emmanuel Dayo
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-01-07 00:00:00.000000000 Z
11
+ date: 2014-02-13 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rake
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: thor
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rubyzip
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: 1.0.0
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: 1.0.0
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: multipart-post
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - ">="
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - ">="
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: properties-ruby
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - ">="
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :runtime
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - ">="
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: activesupport
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - ">="
100
88
  - !ruby/object:Gem::Version
101
89
  version: '0'
102
90
  type: :runtime
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - ">="
108
95
  - !ruby/object:Gem::Version
109
96
  version: '0'
110
97
  description: Android development and rapid prototyping using ruby
@@ -114,55 +101,94 @@ executables:
114
101
  extensions: []
115
102
  extra_rdoc_files: []
116
103
  files:
117
- - lib/droiuby.rb
118
- - lib/droiuby/project.rb
119
- - lib/droiuby/templates/ruby/gitignore.erb
120
- - lib/droiuby/templates/ruby/config.droiuby.erb
121
- - lib/droiuby/templates/ruby/application.css.erb
122
- - lib/droiuby/templates/ruby/index.rb.erb
123
- - lib/droiuby/templates/ruby/index.xml.erb
124
104
  - bin/drby
105
+ - lib/droiuby.rb
106
+ - lib/droiuby/android.rb
107
+ - lib/droiuby/application.rb
108
+ - lib/droiuby/bootstrap.rb
109
+ - lib/droiuby/droiuby.rb
110
+ - lib/droiuby/loader.rb
111
+ - lib/droiuby/plugins/plugins.rb
112
+ - lib/droiuby/preload.rb
113
+ - lib/droiuby/scripts/project.rb
114
+ - lib/droiuby/scripts/templates/ruby/Gemfile.erb
115
+ - lib/droiuby/scripts/templates/ruby/application.css.erb
116
+ - lib/droiuby/scripts/templates/ruby/config.droiuby.erb
117
+ - lib/droiuby/scripts/templates/ruby/gitignore.erb
118
+ - lib/droiuby/scripts/templates/ruby/index.rb.erb
119
+ - lib/droiuby/scripts/templates/ruby/index.xml.erb
120
+ - lib/droiuby/support/asset.rb
121
+ - lib/droiuby/support/autoload.rb
122
+ - lib/droiuby/support/fixnum.rb
123
+ - lib/droiuby/support/object.rb
124
+ - lib/droiuby/support/string.rb
125
+ - lib/droiuby/support/system.rb
126
+ - lib/droiuby/support/thread.rb
127
+ - lib/droiuby/support/to_query.rb
128
+ - lib/droiuby/support/utils.rb
129
+ - lib/droiuby/wrappers/accelerometer.rb
130
+ - lib/droiuby/wrappers/activity.rb
131
+ - lib/droiuby/wrappers/animation.rb
132
+ - lib/droiuby/wrappers/async.rb
133
+ - lib/droiuby/wrappers/button.rb
134
+ - lib/droiuby/wrappers/canvas.rb
135
+ - lib/droiuby/wrappers/collection/view_array.rb
136
+ - lib/droiuby/wrappers/compound_button_wrapper.rb
137
+ - lib/droiuby/wrappers/edit_text.rb
138
+ - lib/droiuby/wrappers/image_button.rb
139
+ - lib/droiuby/wrappers/intent.rb
140
+ - lib/droiuby/wrappers/java_helpers/java_method_helper.rb
141
+ - lib/droiuby/wrappers/java_helpers/view_helper.rb
142
+ - lib/droiuby/wrappers/linear_layout.rb
143
+ - lib/droiuby/wrappers/list_adapter_wrapper.rb
144
+ - lib/droiuby/wrappers/list_view.rb
145
+ - lib/droiuby/wrappers/listeners/auto_wrap.rb
146
+ - lib/droiuby/wrappers/listeners/on_click_listener.rb
147
+ - lib/droiuby/wrappers/listeners/on_web_console_ready_listener.rb
148
+ - lib/droiuby/wrappers/motion_events.rb
149
+ - lib/droiuby/wrappers/preferences.rb
150
+ - lib/droiuby/wrappers/proxy_builder/interface_builder.rb
151
+ - lib/droiuby/wrappers/runnable_wrapper.rb
152
+ - lib/droiuby/wrappers/surface_view_wrapper.rb
153
+ - lib/droiuby/wrappers/text_view.rb
154
+ - lib/droiuby/wrappers/thread_pool.rb
155
+ - lib/droiuby/wrappers/view_group_wrapper.rb
156
+ - lib/droiuby/wrappers/view_wrapper.rb
157
+ - lib/droiuby/wrappers/web_view.rb
158
+ - lib/droiuby/wrappers/wrappers.rb
125
159
  homepage: https://github.com/jedld/droiuby-doo
126
160
  licenses:
127
161
  - Apache License, Version 2.0
128
- post_install_message: ! 'Droiuby Gem Installed!
129
-
162
+ metadata: {}
163
+ post_install_message: |-
164
+ Droiuby Gem Installed!
130
165
 
131
166
  Post Install work:
132
167
 
133
-
134
168
  1.Go install the droiuby development app on your phone here: https://play.google.com/store/apps/details?id=com.droiuby.application
135
-
136
169
  2. Download the android sdk (http://developer.android.com/sdk/index.html)
137
-
138
- 3. Setup your PATH to include <sdk directory>/sdk/platform-tools (make sure adb
139
- works)
140
-
170
+ 3. Setup your PATH to include <sdk directory>/sdk/platform-tools (make sure adb works)
141
171
  4. Attach your android phone to your PC via USB
142
-
143
172
  5. visit https://github.com/jedld/droiuby-doo for the quick start tutorial
144
173
 
145
-
146
- Details can be found in the README'
174
+ Details can be found in the README
147
175
  rdoc_options: []
148
176
  require_paths:
149
177
  - lib
150
178
  required_ruby_version: !ruby/object:Gem::Requirement
151
- none: false
152
179
  requirements:
153
- - - ! '>='
180
+ - - ">="
154
181
  - !ruby/object:Gem::Version
155
182
  version: '0'
156
183
  required_rubygems_version: !ruby/object:Gem::Requirement
157
- none: false
158
184
  requirements:
159
- - - ! '>='
185
+ - - ">="
160
186
  - !ruby/object:Gem::Version
161
187
  version: '0'
162
188
  requirements: []
163
189
  rubyforge_project:
164
- rubygems_version: 1.8.24
190
+ rubygems_version: 2.2.2
165
191
  signing_key:
166
- specification_version: 3
192
+ specification_version: 4
167
193
  summary: Droiuby GEM
168
194
  test_files: []