motion-ipkeyboard 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b4949a0af228eb1b7c07d11330bd2497f624ab7e
4
+ data.tar.gz: cb48cbfd1a54d26e8264ed201dd5fc0964de10a7
5
+ SHA512:
6
+ metadata.gz: 268c64055813f55d76d92a3f7d186bc56e71682d4054f2d40fc38467a72160c87e890356c1ccaf58c86196f099412da892ffa07d35fdf7f9aa1c2842de7ae57b
7
+ data.tar.gz: dd0358f1207550ab4a114ed177e3039c3430e94cad73fd1640daf98c1639328109c058d41d49c76bf36e872b48e603227bac40ad997fe2edc04e5fcb9643bdef
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Diogo André de Assumpção
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
File without changes
@@ -0,0 +1,126 @@
1
+ module RMIPKeyboard
2
+ class Keyboard < UIView
3
+ HEX_KEYBOARD_HEIGHT = 305
4
+ DEC_KEYBOARD_HEIGHT = 205
5
+ SGRAYCOLOUR = UIColor.lightTextColor
6
+
7
+ def initWithTextFieldAndLayout(textField, klayout="ipv6")
8
+ if klayout == "ipv6"
9
+ @keyboardHeight = HEX_KEYBOARD_HEIGHT
10
+ @numrows = 6.0
11
+ @dividerChar = ":"
12
+ @numberOfKeys = 15 # minus one
13
+ else
14
+ @keyboardHeight = DEC_KEYBOARD_HEIGHT
15
+ @numrows = 4.0
16
+ @dividerChar = "."
17
+ @numberOfKeys = 9 # minus one
18
+ end
19
+
20
+ self.initWithFrame(CGRectMake(0.0, 0.0, 320.0, @keyboardHeight))
21
+
22
+ @textField = WeakRef.new(textField)
23
+ self.backgroundColor = UIColor.lightGrayColor
24
+ self.createButtons
25
+
26
+ self
27
+ end
28
+
29
+ def createButtons
30
+ rect = CGRectMake(0.0, 0.0, ((self.bounds.size.width / 3.0) + 0.3).floor, (((@keyboardHeight - 5.0) / @numrows) + 0.3))
31
+
32
+ # Makes the numerical buttons
33
+ (1..@numberOfKeys).each do |num|
34
+ rect.origin = self.buttonOriginPointForNumber(num)
35
+
36
+ self.makeButtonWithRect(rect,self.buttonTitleForNumber(num),false)
37
+ end
38
+ # Makes the ':' button
39
+ rect.origin = self.buttonOriginPointForNumber(@numberOfKeys + 1)
40
+
41
+ self.makeButtonWithRect(rect,@dividerChar,true)
42
+
43
+ # Makes the '0' button
44
+ rect.origin = self.buttonOriginPointForNumber(@numberOfKeys + 2)
45
+
46
+ self.makeButtonWithRect(rect,"0",false)
47
+
48
+ # Makes the 'delete' button
49
+ rect.origin = self.buttonOriginPointForNumber(@numberOfKeys + 3)
50
+
51
+ button = UIButton.alloc.initWithFrame(rect)
52
+ button.tag = @numberOfKeys + 3
53
+ button.backgroundColor = SGRAYCOLOUR
54
+ button.setImage(UIImage.imageNamed("deleteButton"), forState:UIControlStateNormal)
55
+ button.addTarget(self, action:"changeButtonBackgroundColourForHighlight:", forControlEvents:(UIControlEventTouchDown|UIControlEventTouchDragEnter|UIControlEventTouchDragExit))
56
+ button.addTarget(self, action:"changeTextFieldText:", forControlEvents:UIControlEventTouchUpInside)
57
+
58
+ self.addSubview(button)
59
+ end
60
+
61
+ def makeButtonWithRect(rect, title, grayBackground)
62
+ button = UIButton.buttonWithType(UIButtonTypeCustom)
63
+ button.frame = rect
64
+ fontSize = 25.0
65
+
66
+ unless NSCharacterSet.decimalDigitCharacterSet.isSupersetOfSet(NSCharacterSet.characterSetWithCharactersInString(title))
67
+ fontSize = 20.0
68
+ end
69
+
70
+ button.backgroundColor = grayBackground ? SGRAYCOLOUR : UIColor.whiteColor
71
+ #button.backgroundColor = grayBackground ? UIColor.lightTextColor : UIColor.whiteColor
72
+ button.titleLabel.font = UIFont.systemFontOfSize(fontSize)
73
+ button.setTitleColor(UIColor.darkTextColor, forState:UIControlStateNormal)
74
+ button.setTitle(title, forState:UIControlStateNormal)
75
+ button.addTarget(self, action:"changeButtonBackgroundColourForHighlight:", forControlEvents: (UIControlEventTouchDown|UIControlEventTouchDragEnter|UIControlEventTouchDragExit))
76
+ button.addTarget(self, action:"changeTextFieldText:", forControlEvents: UIControlEventTouchUpInside)
77
+
78
+ self.addSubview(button)
79
+ end
80
+
81
+ def buttonTitleForNumber(num)
82
+ str = num.to_s
83
+ if num <= 15
84
+ if num >= 10
85
+ str = ["A", "B", "C", "D", "E", "F"][num - 10]
86
+ end
87
+ else
88
+ str = "F#%K"
89
+ end
90
+ str
91
+ end
92
+
93
+ def buttonOriginPointForNumber(num)
94
+ point = CGPointMake(0.0,0.0)
95
+
96
+ if (num % 3) == 2 # 2nd button in the row
97
+ point.x = (self.bounds.size.width / 3.0).ceil
98
+ elsif (num % 3) == 0 # 3rd button in the row
99
+ point.x = (self.bounds.size.width / 3.0 * 2.0).ceil
100
+ end
101
+
102
+ if num > 3 # The row multiplied by row's height
103
+ point.y = ((num - 1) / 3.0).floor * (@keyboardHeight / @numrows)
104
+ end
105
+ point
106
+ end
107
+
108
+ def changeButtonBackgroundColourForHighlight(button)
109
+ if button.backgroundColor == SGRAYCOLOUR
110
+ button.backgroundColor = UIColor.whiteColor
111
+ else
112
+ button.backgroundColor = SGRAYCOLOUR
113
+ end
114
+ end
115
+
116
+ def changeTextFieldText(button)
117
+ if button.tag == @numberOfKeys + 3
118
+ @textField.text = "#{@textField.text.chop}"
119
+ else
120
+ @textField.text = "#{@textField.text}#{button.titleLabel.text}"
121
+ end
122
+ self.changeButtonBackgroundColourForHighlight(button)
123
+ end
124
+
125
+ end
126
+ end
@@ -0,0 +1,10 @@
1
+ unless defined?(Motion::Project::Config)
2
+ raise "This file must be required within a RubyMotion project Rakefile."
3
+ end
4
+
5
+ Motion::Project::App.setup do |app|
6
+ Dir.glob(File.join(File.dirname(__FILE__), 'RMIPKeyboard/*.rb')).each do |file|
7
+ app.files.unshift(file)
8
+ app.resources_dirs << File.join(File.dirname(__FILE__), 'RMIPKeyboard/resources')
9
+ end
10
+ end
metadata ADDED
@@ -0,0 +1,47 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: motion-ipkeyboard
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Diogo André
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-19 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Custom iPhone keyboard. Made for iOS7
14
+ email: diogo@regattapix.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - README.md
20
+ - LICENSE
21
+ - lib/motion-ipkeyboard.rb
22
+ - lib/RMIPKeyboard/RMIPKeyboard.rb
23
+ homepage: https://github.com/diogoandre/motion-ipkeyboard
24
+ licenses:
25
+ - MIT
26
+ metadata: {}
27
+ post_install_message:
28
+ rdoc_options: []
29
+ require_paths:
30
+ - lib
31
+ required_ruby_version: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - '>='
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ required_rubygems_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ requirements: []
42
+ rubyforge_project:
43
+ rubygems_version: 2.0.6
44
+ signing_key:
45
+ specification_version: 4
46
+ summary: iPhone keyboards customized for typing IPv4 and IPv6 values
47
+ test_files: []