57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/codeView/src/main/java/com/smartown/codeView/KeyboardView.java:
--------------------------------------------------------------------------------
1 | package com.smartown.codeView;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.widget.FrameLayout;
8 |
9 | /**
10 | * Author:https://github.com/kungfubrother
11 | * Date:2017/1/7 21:39
12 | * Description:数字输入键盘
13 | */
14 | public class KeyboardView extends FrameLayout implements View.OnClickListener {
15 |
16 | private CodeView codeView;
17 | private Listener listener;
18 |
19 | public KeyboardView(Context context) {
20 | super(context);
21 | init();
22 | }
23 |
24 | public KeyboardView(Context context, AttributeSet attrs) {
25 | super(context, attrs);
26 | init();
27 | }
28 |
29 | public void setCodeView(CodeView codeView) {
30 | this.codeView = codeView;
31 | }
32 |
33 | private void init() {
34 | View view = LayoutInflater.from(getContext()).inflate(R.layout.layout_pwd_keyboard, null);
35 | view.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
36 | addView(view);
37 | view.findViewById(R.id.keyboard_0).setOnClickListener(this);
38 | view.findViewById(R.id.keyboard_1).setOnClickListener(this);
39 | view.findViewById(R.id.keyboard_2).setOnClickListener(this);
40 | view.findViewById(R.id.keyboard_3).setOnClickListener(this);
41 | view.findViewById(R.id.keyboard_4).setOnClickListener(this);
42 | view.findViewById(R.id.keyboard_5).setOnClickListener(this);
43 | view.findViewById(R.id.keyboard_6).setOnClickListener(this);
44 | view.findViewById(R.id.keyboard_7).setOnClickListener(this);
45 | view.findViewById(R.id.keyboard_8).setOnClickListener(this);
46 | view.findViewById(R.id.keyboard_9).setOnClickListener(this);
47 | view.findViewById(R.id.keyboard_hide).setOnClickListener(this);
48 | view.findViewById(R.id.keyboard_delete).setOnClickListener(this);
49 | }
50 |
51 | public void hide() {
52 | setVisibility(GONE);
53 | }
54 |
55 | public void show() {
56 | setVisibility(VISIBLE);
57 | }
58 |
59 | public void setListener(Listener listener) {
60 | this.listener = listener;
61 | }
62 |
63 | @Override
64 | public void onClick(View v) {
65 | final String tag = (String) v.getTag();
66 | if (tag != null) {
67 | switch (tag) {
68 | case "hide":
69 | hide();
70 | break;
71 | case "delete":
72 | if (codeView != null) {
73 | codeView.delete();
74 | }
75 | if (listener != null) {
76 | listener.onDelete();
77 | }
78 | break;
79 | default:
80 | if (codeView != null) {
81 | codeView.input(tag);
82 | }
83 | if (listener != null) {
84 | listener.onInput(tag);
85 | }
86 | break;
87 | }
88 | }
89 | }
90 |
91 | public interface Listener {
92 |
93 | public void onInput(String s);
94 |
95 | public void onDelete();
96 |
97 | }
98 |
99 | }
100 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/codeView/src/main/res/layout/layout_pwd_keyboard.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
17 |
20 |
21 |
26 |
27 |
35 |
36 |
39 |
40 |
48 |
49 |
52 |
53 |
61 |
62 |
63 |
64 |
67 |
68 |
73 |
74 |
82 |
83 |
86 |
87 |
95 |
96 |
99 |
100 |
108 |
109 |
110 |
111 |
114 |
115 |
120 |
121 |
129 |
130 |
133 |
134 |
142 |
143 |
146 |
147 |
155 |
156 |
157 |
158 |
161 |
162 |
167 |
168 |
172 |
173 |
176 |
177 |
185 |
186 |
189 |
190 |
200 |
201 |
202 |
203 |
--------------------------------------------------------------------------------
/codeView/src/main/java/com/smartown/codeView/CodeView.java:
--------------------------------------------------------------------------------
1 | package com.smartown.codeView;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Canvas;
6 | import android.graphics.Color;
7 | import android.graphics.Paint;
8 | import android.util.AttributeSet;
9 | import android.view.View;
10 |
11 | /**
12 | * Author:https://github.com/kungfubrother
13 | * Date:2017/1/7 20:12
14 | * Description:密码显示控件
15 | */
16 | public class CodeView extends View {
17 |
18 | public final static int SHOW_TYPE_WORD = 1;
19 | public final static int SHOW_TYPE_PASSWORD = 2;
20 |
21 | //密码长度,默认6位
22 | private int length;
23 | //描边颜色,默认#E1E1E1
24 | private int borderColor;
25 | //描边宽度,默认1px
26 | private float borderWidth;
27 | //分割线颜色,默认#E1E1E1
28 | private int dividerColor;
29 | //分割线宽度,默认1px
30 | private float dividerWidth;
31 | //默认文本,在XML设置后可预览效果
32 | private String code;
33 | //密码点颜色,默认#000000
34 | private int codeColor;
35 | //密码点半径,默认8dp
36 | private float pointRadius;
37 | //显示明文时的文字大小,默认unitWidth/2
38 | private float textSize;
39 | //显示类型,支持密码、明文,默认明文
40 | private int showType;
41 |
42 | private float unitWidth;
43 | private Paint paint;
44 | private Listener listener;
45 |
46 | public CodeView(Context context) {
47 | super(context);
48 | init(null);
49 | }
50 |
51 | public CodeView(Context context, AttributeSet attrs) {
52 | super(context, attrs);
53 | init(attrs);
54 | }
55 |
56 | @Override
57 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
58 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
59 | //根据宽度来计算单元格大小(高度)
60 | float width = getMeasuredWidth();
61 | //宽度-左右边宽-中间分割线宽度
62 | unitWidth = (width - (2 * borderWidth) - ((length - 1) * dividerWidth)) / length;
63 | if (textSize == 0) {
64 | textSize = unitWidth / 2;
65 | }
66 | setMeasuredDimension((int) width, (int) (unitWidth + (2 * borderWidth)));
67 | }
68 |
69 | private void init(AttributeSet attrs) {
70 | paint = new Paint();
71 | paint.setAntiAlias(true);
72 | paint.setTextAlign(Paint.Align.CENTER);
73 | if (attrs == null) {
74 | length = 6;
75 | borderColor = Color.parseColor("#E1E1E1");
76 | borderWidth = 1;
77 | dividerColor = Color.parseColor("#E1E1E1");
78 | dividerWidth = 1;
79 | code = "";
80 | codeColor = Color.parseColor("#000000");
81 | pointRadius = Util.dpToPx(getContext(), 8);
82 | showType = SHOW_TYPE_WORD;
83 | textSize = 0;
84 | } else {
85 | TypedArray typedArray = getResources().obtainAttributes(attrs, R.styleable.CodeView);
86 | length = typedArray.getInt(R.styleable.CodeView_length, 6);
87 | borderColor = typedArray.getColor(R.styleable.CodeView_borderColor, Color.parseColor("#E1E1E1"));
88 | borderWidth = typedArray.getDimensionPixelSize(R.styleable.CodeView_borderWidth, 1);
89 | dividerColor = typedArray.getColor(R.styleable.CodeView_dividerColor, Color.parseColor("#E1E1E1"));
90 | dividerWidth = typedArray.getDimensionPixelSize(R.styleable.CodeView_dividerWidth, 1);
91 | code = typedArray.getString(R.styleable.CodeView_code);
92 | if (code == null) {
93 | code = "";
94 | }
95 | codeColor = typedArray.getColor(R.styleable.CodeView_codeColor, Color.parseColor("#000000"));
96 | pointRadius = typedArray.getDimensionPixelSize(R.styleable.CodeView_pointRadius, Util.dpToPx(getContext(), 8));
97 | showType = typedArray.getInt(R.styleable.CodeView_showType, SHOW_TYPE_WORD);
98 | textSize = typedArray.getDimensionPixelSize(R.styleable.CodeView_textSize, 0);
99 | }
100 | }
101 |
102 | @Override
103 | protected void onDraw(Canvas canvas) {
104 | super.onDraw(canvas);
105 | drawDivider(canvas);
106 | drawBorder(canvas);
107 | switch (showType) {
108 | case SHOW_TYPE_PASSWORD:
109 | drawPoint(canvas);
110 | break;
111 | default:
112 | drawValue(canvas);
113 | break;
114 | }
115 | }
116 |
117 | /**
118 | * 描边
119 | */
120 | private void drawBorder(Canvas canvas) {
121 | if (borderWidth > 0) {
122 | paint.setColor(borderColor);
123 | canvas.drawRect(0, 0, getWidth(), borderWidth, paint);
124 | canvas.drawRect(0, getHeight() - borderWidth, getWidth(), getHeight(), paint);
125 | canvas.drawRect(0, 0, borderWidth, getHeight(), paint);
126 | canvas.drawRect(getWidth() - borderWidth, 0, getWidth(), getHeight(), paint);
127 | }
128 | }
129 |
130 | /**
131 | * 画分割线
132 | */
133 | private void drawDivider(Canvas canvas) {
134 | if (dividerWidth > 0) {
135 | paint.setColor(dividerColor);
136 | for (int i = 0; i < length - 1; i++) {
137 | final float left = unitWidth * (i + 1) + dividerWidth * i + borderWidth;
138 | canvas.drawRect(left, 0, left + dividerWidth, getHeight(), paint);
139 | }
140 | }
141 | }
142 |
143 | /**
144 | * 画输入文字
145 | */
146 | private void drawValue(Canvas canvas) {
147 | if (pointRadius > 0) {
148 | paint.setColor(codeColor);
149 | paint.setTextSize(textSize);
150 | for (int i = 0; i < code.length(); i++) {
151 | final float left = unitWidth * i + dividerWidth * i + borderWidth;
152 | canvas.drawText(code.charAt(i) + "",
153 | left + unitWidth / 2,
154 | Util.getTextBaseLine(0, getHeight(), paint),
155 | paint);
156 | }
157 | }
158 | }
159 |
160 | /**
161 | * 画密码点
162 | */
163 | private void drawPoint(Canvas canvas) {
164 | if (pointRadius > 0) {
165 | paint.setColor(codeColor);
166 | for (int i = 0; i < code.length(); i++) {
167 | final float left = unitWidth * i + dividerWidth * i + borderWidth;
168 | canvas.drawCircle(left + unitWidth / 2, getHeight() / 2, pointRadius, paint);
169 | }
170 | }
171 | }
172 |
173 | public void input(String number) {
174 | if (code.length() < length) {
175 | code += number;
176 | if (listener != null) {
177 | listener.onValueChanged(code);
178 | if (code.length() == length) {
179 | listener.onComplete(code);
180 | }
181 | }
182 | invalidate();
183 | }
184 | }
185 |
186 | public void delete() {
187 | if (code.length() > 0) {
188 | code = code.substring(0, code.length() - 1);
189 | if (listener != null) {
190 | listener.onValueChanged(code);
191 | }
192 | invalidate();
193 | }
194 | }
195 |
196 | public int getLength() {
197 | return length;
198 | }
199 |
200 | public void setLength(int length) {
201 | this.length = length;
202 | invalidate();
203 | }
204 |
205 | public int getBorderColor() {
206 | return borderColor;
207 | }
208 |
209 | public void setBorderColor(int borderColor) {
210 | this.borderColor = borderColor;
211 | invalidate();
212 | }
213 |
214 | public float getBorderWidth() {
215 | return borderWidth;
216 | }
217 |
218 | public void setBorderWidth(float borderWidth) {
219 | this.borderWidth = borderWidth;
220 | invalidate();
221 | }
222 |
223 | public int getDividerColor() {
224 | return dividerColor;
225 | }
226 |
227 | public void setDividerColor(int dividerColor) {
228 | this.dividerColor = dividerColor;
229 | invalidate();
230 | }
231 |
232 | public float getDividerWidth() {
233 | return dividerWidth;
234 | }
235 |
236 | public void setDividerWidth(float dividerWidth) {
237 | this.dividerWidth = dividerWidth;
238 | invalidate();
239 | }
240 |
241 | public String getCode() {
242 | return code;
243 | }
244 |
245 | public void setCode(String code) {
246 | this.code = code;
247 | invalidate();
248 | }
249 |
250 | public int getCodeColor() {
251 | return codeColor;
252 | }
253 |
254 | public void setCodeColor(int codeColor) {
255 | this.codeColor = codeColor;
256 | invalidate();
257 | }
258 |
259 | public float getPointRadius() {
260 | return pointRadius;
261 | }
262 |
263 | public void setPointRadius(float pointRadius) {
264 | this.pointRadius = pointRadius;
265 | invalidate();
266 | }
267 |
268 | public float getTextSize() {
269 | return textSize;
270 | }
271 |
272 | public void setTextSize(float textSize) {
273 | this.textSize = textSize;
274 | invalidate();
275 | }
276 |
277 | public int getShowType() {
278 | return showType;
279 | }
280 |
281 | public void setShowType(int showType) {
282 | this.showType = showType;
283 | invalidate();
284 | }
285 |
286 | public void setListener(Listener listener) {
287 | this.listener = listener;
288 | }
289 |
290 | public interface Listener {
291 |
292 | public void onValueChanged(String value);
293 |
294 | public void onComplete(String value);
295 |
296 | }
297 |
298 | }
299 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction, and
10 | distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by the copyright
13 | owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all other entities
16 | that control, are controlled by, or are under common control with that entity.
17 | For the purposes of this definition, "control" means (i) the power, direct or
18 | indirect, to cause the direction or management of such entity, whether by
19 | contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
20 | outstanding shares, or (iii) beneficial ownership of such entity.
21 |
22 | "You" (or "Your") shall mean an individual or Legal Entity exercising
23 | permissions granted by this License.
24 |
25 | "Source" form shall mean the preferred form for making modifications, including
26 | but not limited to software source code, documentation source, and configuration
27 | files.
28 |
29 | "Object" form shall mean any form resulting from mechanical transformation or
30 | translation of a Source form, including but not limited to compiled object code,
31 | generated documentation, and conversions to other media types.
32 |
33 | "Work" shall mean the work of authorship, whether in Source or Object form, made
34 | available under the License, as indicated by a copyright notice that is included
35 | in or attached to the work (an example is provided in the Appendix below).
36 |
37 | "Derivative Works" shall mean any work, whether in Source or Object form, that
38 | is based on (or derived from) the Work and for which the editorial revisions,
39 | annotations, elaborations, or other modifications represent, as a whole, an
40 | original work of authorship. For the purposes of this License, Derivative Works
41 | shall not include works that remain separable from, or merely link (or bind by
42 | name) to the interfaces of, the Work and Derivative Works thereof.
43 |
44 | "Contribution" shall mean any work of authorship, including the original version
45 | of the Work and any modifications or additions to that Work or Derivative Works
46 | thereof, that is intentionally submitted to Licensor for inclusion in the Work
47 | by the copyright owner or by an individual or Legal Entity authorized to submit
48 | on behalf of the copyright owner. For the purposes of this definition,
49 | "submitted" means any form of electronic, verbal, or written communication sent
50 | to the Licensor or its representatives, including but not limited to
51 | communication on electronic mailing lists, source code control systems, and
52 | issue tracking systems that are managed by, or on behalf of, the Licensor for
53 | the purpose of discussing and improving the Work, but excluding communication
54 | that is conspicuously marked or otherwise designated in writing by the copyright
55 | owner as "Not a Contribution."
56 |
57 | "Contributor" shall mean Licensor and any individual or Legal Entity on behalf
58 | of whom a Contribution has been received by Licensor and subsequently
59 | incorporated within the Work.
60 |
61 | 2. Grant of Copyright License.
62 |
63 | Subject to the terms and conditions of this License, each Contributor hereby
64 | grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
65 | irrevocable copyright license to reproduce, prepare Derivative Works of,
66 | publicly display, publicly perform, sublicense, and distribute the Work and such
67 | Derivative Works in Source or Object form.
68 |
69 | 3. Grant of Patent License.
70 |
71 | Subject to the terms and conditions of this License, each Contributor hereby
72 | grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
73 | irrevocable (except as stated in this section) patent license to make, have
74 | made, use, offer to sell, sell, import, and otherwise transfer the Work, where
75 | such license applies only to those patent claims licensable by such Contributor
76 | that are necessarily infringed by their Contribution(s) alone or by combination
77 | of their Contribution(s) with the Work to which such Contribution(s) was
78 | submitted. If You institute patent litigation against any entity (including a
79 | cross-claim or counterclaim in a lawsuit) alleging that the Work or a
80 | Contribution incorporated within the Work constitutes direct or contributory
81 | patent infringement, then any patent licenses granted to You under this License
82 | for that Work shall terminate as of the date such litigation is filed.
83 |
84 | 4. Redistribution.
85 |
86 | You may reproduce and distribute copies of the Work or Derivative Works thereof
87 | in any medium, with or without modifications, and in Source or Object form,
88 | provided that You meet the following conditions:
89 |
90 | You must give any other recipients of the Work or Derivative Works a copy of
91 | this License; and
92 | You must cause any modified files to carry prominent notices stating that You
93 | changed the files; and
94 | You must retain, in the Source form of any Derivative Works that You distribute,
95 | all copyright, patent, trademark, and attribution notices from the Source form
96 | of the Work, excluding those notices that do not pertain to any part of the
97 | Derivative Works; and
98 | If the Work includes a "NOTICE" text file as part of its distribution, then any
99 | Derivative Works that You distribute must include a readable copy of the
100 | attribution notices contained within such NOTICE file, excluding those notices
101 | that do not pertain to any part of the Derivative Works, in at least one of the
102 | following places: within a NOTICE text file distributed as part of the
103 | Derivative Works; within the Source form or documentation, if provided along
104 | with the Derivative Works; or, within a display generated by the Derivative
105 | Works, if and wherever such third-party notices normally appear. The contents of
106 | the NOTICE file are for informational purposes only and do not modify the
107 | License. You may add Your own attribution notices within Derivative Works that
108 | You distribute, alongside or as an addendum to the NOTICE text from the Work,
109 | provided that such additional attribution notices cannot be construed as
110 | modifying the License.
111 | You may add Your own copyright statement to Your modifications and may provide
112 | additional or different license terms and conditions for use, reproduction, or
113 | distribution of Your modifications, or for any such Derivative Works as a whole,
114 | provided Your use, reproduction, and distribution of the Work otherwise complies
115 | with the conditions stated in this License.
116 |
117 | 5. Submission of Contributions.
118 |
119 | Unless You explicitly state otherwise, any Contribution intentionally submitted
120 | for inclusion in the Work by You to the Licensor shall be under the terms and
121 | conditions of this License, without any additional terms or conditions.
122 | Notwithstanding the above, nothing herein shall supersede or modify the terms of
123 | any separate license agreement you may have executed with Licensor regarding
124 | such Contributions.
125 |
126 | 6. Trademarks.
127 |
128 | This License does not grant permission to use the trade names, trademarks,
129 | service marks, or product names of the Licensor, except as required for
130 | reasonable and customary use in describing the origin of the Work and
131 | reproducing the content of the NOTICE file.
132 |
133 | 7. Disclaimer of Warranty.
134 |
135 | Unless required by applicable law or agreed to in writing, Licensor provides the
136 | Work (and each Contributor provides its Contributions) on an "AS IS" BASIS,
137 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
138 | including, without limitation, any warranties or conditions of TITLE,
139 | NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
140 | solely responsible for determining the appropriateness of using or
141 | redistributing the Work and assume any risks associated with Your exercise of
142 | permissions under this License.
143 |
144 | 8. Limitation of Liability.
145 |
146 | In no event and under no legal theory, whether in tort (including negligence),
147 | contract, or otherwise, unless required by applicable law (such as deliberate
148 | and grossly negligent acts) or agreed to in writing, shall any Contributor be
149 | liable to You for damages, including any direct, indirect, special, incidental,
150 | or consequential damages of any character arising as a result of this License or
151 | out of the use or inability to use the Work (including but not limited to
152 | damages for loss of goodwill, work stoppage, computer failure or malfunction, or
153 | any and all other commercial damages or losses), even if such Contributor has
154 | been advised of the possibility of such damages.
155 |
156 | 9. Accepting Warranty or Additional Liability.
157 |
158 | While redistributing the Work or Derivative Works thereof, You may choose to
159 | offer, and charge a fee for, acceptance of support, warranty, indemnity, or
160 | other liability obligations and/or rights consistent with this License. However,
161 | in accepting such obligations, You may act only on Your own behalf and on Your
162 | sole responsibility, not on behalf of any other Contributor, and only if You
163 | agree to indemnify, defend, and hold each Contributor harmless for any liability
164 | incurred by, or claims asserted against, such Contributor by reason of your
165 | accepting any such warranty or additional liability.
166 |
167 | END OF TERMS AND CONDITIONS
168 |
169 | APPENDIX: How to apply the Apache License to your work
170 |
171 | To apply the Apache License to your work, attach the following boilerplate
172 | notice, with the fields enclosed by brackets "{}" replaced with your own
173 | identifying information. (Don't include the brackets!) The text should be
174 | enclosed in the appropriate comment syntax for the file format. We also
175 | recommend that a file or class name and description of purpose be included on
176 | the same "printed page" as the copyright notice for easier identification within
177 | third-party archives.
178 |
179 | Copyright 2017 Smartown
180 |
181 | Licensed under the Apache License, Version 2.0 (the "License");
182 | you may not use this file except in compliance with the License.
183 | You may obtain a copy of the License at
184 |
185 | http://www.apache.org/licenses/LICENSE-2.0
186 |
187 | Unless required by applicable law or agreed to in writing, software
188 | distributed under the License is distributed on an "AS IS" BASIS,
189 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190 | See the License for the specific language governing permissions and
191 | limitations under the License.
192 |
--------------------------------------------------------------------------------