├── .gitignore
├── LICENSE.txt
├── README.md
├── build.gradle
├── library
├── AndroidManifest.xml
├── Font-LICENSE.txt
├── Font-README.md
├── LICENSE.txt
├── README.md
├── RobotoSpecimenBook.pdf
├── build.gradle
├── lint.xml
├── proguard-project.txt
├── project.properties.sample
├── res
│ ├── drawable-xhdpi
│ │ └── ic_launcher.png
│ ├── layout
│ │ └── test_mytextview_activity.xml
│ ├── raw
│ │ ├── roboto_black.ttf
│ │ ├── roboto_black_italic.ttf
│ │ ├── roboto_bold.ttf
│ │ ├── roboto_bold_condensed.ttf
│ │ ├── roboto_bold_condensed_italic.ttf
│ │ ├── roboto_bold_italic.ttf
│ │ ├── roboto_condensed.ttf
│ │ ├── roboto_condensed_italic.ttf
│ │ ├── roboto_condensed_light.ttf
│ │ ├── roboto_condensed_light_italic.ttf
│ │ ├── roboto_light.ttf
│ │ ├── roboto_light_italic.ttf
│ │ ├── roboto_medium.ttf
│ │ ├── roboto_medium_italic.ttf
│ │ ├── roboto_regular.ttf
│ │ ├── roboto_regular_italic.ttf
│ │ ├── roboto_thin.ttf
│ │ └── roboto_thin_italic.ttf
│ ├── values-v11
│ │ └── styles.xml
│ └── values
│ │ ├── attrs.xml
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── sage42
│ │ └── android
│ │ └── view
│ │ ├── animations
│ │ ├── AnimateOpenAndClosed.java
│ │ └── ClickToOpenCloseLayout.java
│ │ ├── fonts
│ │ ├── FontManager.java
│ │ ├── MyAutoCompleteTextView.java
│ │ ├── MyButton.java
│ │ ├── MyCheckBox.java
│ │ ├── MyCheckedTextView.java
│ │ ├── MyChronometer.java
│ │ ├── MyCompoundButton.java
│ │ ├── MyEditText.java
│ │ ├── MyExtractEditText.java
│ │ ├── MyRadioButton.java
│ │ ├── MyScrollingTextView.java
│ │ ├── MyTextView.java
│ │ ├── MyToggleButton.java
│ │ └── RobotoTypes.java
│ │ ├── gestures
│ │ └── MyGestureDetector.java
│ │ ├── pager
│ │ └── CursorFragmentPagerAdapter.java
│ │ └── ui
│ │ ├── CircularProgressBar.java
│ │ ├── ExpandAndShrinkCardView.java
│ │ ├── ExpandAndShrinkCardsListViewAdapter.java
│ │ ├── ExpandAndShrinkLayoutStates.java
│ │ └── SegmentedProgressBar.java
│ └── test
│ └── java
│ └── com
│ └── sage42
│ └── android
│ └── view
│ └── activities
│ └── MyTextViewTestActivity.java
├── sample_apk
└── AndroidViewUtilsSamples.apk
├── samples
├── AndroidManifest.xml
├── LICENSE.txt
├── libs
│ └── android-support-v4.jar
├── lint.xml
├── proguard-project.txt
├── project.properties.sample
├── res
│ ├── drawable-xhdpi
│ │ └── ic_launcher.png
│ ├── layout
│ │ ├── circular_progress_bar_activity.xml
│ │ ├── custom_fonts_activity.xml
│ │ ├── marquee_text_activity.xml
│ │ ├── sample_expand_shrink_card_view.xml
│ │ ├── segmented_progress_bar_activity.xml
│ │ └── swipe_enabled_activity.xml
│ ├── raw
│ │ ├── baroque_script.ttf
│ │ └── kberry.ttf
│ ├── values-v11
│ │ └── styles.xml
│ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
└── src
│ └── main
│ └── java
│ └── com
│ └── sage42
│ └── android
│ └── view_samples
│ ├── MainActivity.java
│ ├── SwipeEnabledActivity.java
│ ├── custom_fonts
│ ├── CustomFontsActivity.java
│ └── MyFontManager.java
│ ├── marquee
│ └── MarqueeTextActivity.java
│ └── ui
│ ├── CircularProgressBarActivity.java
│ ├── ExpandShrinkListViewActivity.java
│ ├── SampleExpandAndShrinkCard.java
│ ├── SampleExpandShrinkListAdapter.java
│ └── SegmentedProgressBarActivity.java
├── settings.gradle
└── website
└── images
├── circ_progress_bar.png
├── custom_fonts.png
└── marquee_textview.png
/.gitignore:
--------------------------------------------------------------------------------
1 | # built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Android Annotations
6 | *.apt_generated
7 |
8 | # files for the dex VM
9 | *.dex
10 |
11 | # Java class files
12 | *.class
13 |
14 | # generated files
15 | bin/
16 | build/
17 | gen/
18 |
19 | # Local configuration file (sdk path, etc)
20 | local.properties
21 | project.properties
22 |
23 | # Eclipse project files
24 | .classpath
25 | .project
26 | .factorypath
27 | .settings/
28 |
29 | # More Eclipse crud
30 | hs_err_pid*.log
31 |
32 | # Android Studio Files
33 | *.iml
34 | .idea/
35 |
36 | # KDE file manager metadata
37 | .directory
38 |
39 | # Gradle files
40 | .gradle/*
41 |
42 | # Other
43 | **/.repository/*
44 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "[]"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright [yyyy] [name of copyright owner]
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
203 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | AndroidViewUtils
2 | ================
3 |
4 | A collection of UI elements and supporting code to ease Android UI implementation
5 |
6 | #### [Download Sample App](https://github.com/Sage42/AndroidViewUtils/raw/master/sample_apk/AndroidViewUtilsSamples.apk)
7 |
8 |
9 | Includes:
10 | --------
11 |
12 | ### Circular Progress Bar
13 |
14 | Just like a normal progress bar only in circle form. This is ideal for count down timers
15 |
16 | 
17 |
18 | * [Code](https://github.com/Sage42/AndroidViewUtils/blob/master/library/src/main/java/com/sage42/android/view/ui/CircularProgressBar.java)
19 | * [Sample (Java)](https://github.com/Sage42/AndroidViewUtils/blob/master/samples/src/main/java/com/sage42/android/view_samples/circular_pb/CircularProgressBarActivity.java)
20 | * [Sample (Layout)](https://github.com/Sage42/AndroidViewUtils/blob/master/samples/res/layout/circular_progress_bar_activity.xml)
21 |
22 |
23 | ### Custom Font Enabled View Elements
24 |
25 | Standard Android View Elements that can be used with custom fonts and a custom font manager.
26 |
27 | Included are the official Roboto fonts so that you have Roboto on older Android versions.
28 | It is possible to use your own custom fonts, please refer to the sample app.
29 | Not all of the UI elements have been enabled yet, so if there is something you need that is missing please submit a ticket or pull request.
30 |
31 | 
32 |
33 | * [Code - Text Based Widgets](https://github.com/Sage42/AndroidViewUtils/tree/master/library/src/main/java/com/sage42/android/view/fonts/)
34 | * [Sample (Java)](https://github.com/Sage42/AndroidViewUtils/tree/master/samples/src/main/java/com/sage42/android/view_samples/custom_fonts/)
35 | * [Sample (Layout)](https://github.com/Sage42/AndroidViewUtils/blob/master/samples/res/layout/custom_fonts_activity.xml)
36 |
37 |
38 | ### Scrolling (Marquee) TextView
39 |
40 | A custom font enabled TextView that is preconfigured to scroll or marquee the content when the size of the content exceeds the space available.
41 |
42 | 
43 |
44 | * [Code](https://github.com/Sage42/AndroidViewUtils/blob/master/library/src/main/java/com/sage42/android/view/fonts/MyScrollingTextView.java)
45 | * [Sample (Java)](https://github.com/Sage42/AndroidViewUtils/blob/master/samples/src/main/java/com/sage42/android/view_samples/marquee/MarqueeTextActivity.java)
46 | * [Sample (Layout)](https://github.com/Sage42/AndroidViewUtils/blob/master/samples/res/layout/marquee_text_activity.xml)
47 |
48 |
49 | Contributing
50 | ------------
51 |
52 | Questions, comments and abuse are all welcome.
53 |
54 | Please use the Github Issues, Pull-requests or contact the author(s) via Google+
55 |
56 |
57 | Author(s):
58 | ----------
59 | [Corey Scott](http://plus.google.com/115297926907967777909)
60 |
61 |
62 | License
63 | -------
64 |
65 | Licensed under the Apache License, Version 2.0 (the "License");
66 | you may not use this file except in compliance with the License.
67 | You may obtain a copy of the License at
68 |
69 | http://www.apache.org/licenses/LICENSE-2.0
70 |
71 | Unless required by applicable law or agreed to in writing, software
72 | distributed under the License is distributed on an "AS IS" BASIS,
73 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
74 | See the License for the specific language governing permissions and
75 | limitations under the License.
76 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can
2 | // add configuration options common
3 | // to all sub-projects/modules.
4 |
5 | buildscript
6 | {
7 | repositories
8 | {
9 | mavenLocal()
10 | mavenCentral()
11 | maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
12 | }
13 |
14 | dependencies
15 | {
16 | classpath 'com.android.tools.build:gradle:0.7.+'
17 | }
18 | }
19 |
20 | configure(allprojects) {
21 | ext.androidCompileSdkVersion = 19
22 | ext.androidMinSdkVersion = 8
23 | ext.androidTargetSdkVersion = 19
24 | ext.androidBuildToolsVersion = "19.0.1"
25 | ext.androidSupportVersion = "19.0.1"
26 | }
27 |
28 | configure(subprojects) { subproject ->
29 | repositories {
30 | mavenCentral()
31 | mavenLocal()
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/library/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
12 |
13 |
14 |
15 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/library/Font-LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2011-2012, The Android Open Source Project
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 |
6 | Unless required by applicable law or agreed to in writing, software
7 | distributed under the License is distributed on an "AS IS" BASIS,
8 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9 | See the License for the specific language governing permissions and
10 | limitations under the License.
11 |
12 |
13 | Apache License
14 | Version 2.0, January 2004
15 | http://www.apache.org/licenses/
16 |
17 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
18 |
19 | 1. Definitions.
20 |
21 | "License" shall mean the terms and conditions for use, reproduction,
22 | and distribution as defined by Sections 1 through 9 of this document.
23 |
24 | "Licensor" shall mean the copyright owner or entity authorized by
25 | the copyright owner that is granting the License.
26 |
27 | "Legal Entity" shall mean the union of the acting entity and all
28 | other entities that control, are controlled by, or are under common
29 | control with that entity. For the purposes of this definition,
30 | "control" means (i) the power, direct or indirect, to cause the
31 | direction or management of such entity, whether by contract or
32 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
33 | outstanding shares, or (iii) beneficial ownership of such entity.
34 |
35 | "You" (or "Your") shall mean an individual or Legal Entity
36 | exercising permissions granted by this License.
37 |
38 | "Source" form shall mean the preferred form for making modifications,
39 | including but not limited to software source code, documentation
40 | source, and configuration files.
41 |
42 | "Object" form shall mean any form resulting from mechanical
43 | transformation or translation of a Source form, including but
44 | not limited to compiled object code, generated documentation,
45 | and conversions to other media types.
46 |
47 | "Work" shall mean the work of authorship, whether in Source or
48 | Object form, made available under the License, as indicated by a
49 | copyright notice that is included in or attached to the work
50 | (an example is provided in the Appendix below).
51 |
52 | "Derivative Works" shall mean any work, whether in Source or Object
53 | form, that is based on (or derived from) the Work and for which the
54 | editorial revisions, annotations, elaborations, or other modifications
55 | represent, as a whole, an original work of authorship. For the purposes
56 | of this License, Derivative Works shall not include works that remain
57 | separable from, or merely link (or bind by name) to the interfaces of,
58 | the Work and Derivative Works thereof.
59 |
60 | "Contribution" shall mean any work of authorship, including
61 | the original version of the Work and any modifications or additions
62 | to that Work or Derivative Works thereof, that is intentionally
63 | submitted to Licensor for inclusion in the Work by the copyright owner
64 | or by an individual or Legal Entity authorized to submit on behalf of
65 | the copyright owner. For the purposes of this definition, "submitted"
66 | means any form of electronic, verbal, or written communication sent
67 | to the Licensor or its representatives, including but not limited to
68 | communication on electronic mailing lists, source code control systems,
69 | and issue tracking systems that are managed by, or on behalf of, the
70 | Licensor for the purpose of discussing and improving the Work, but
71 | excluding communication that is conspicuously marked or otherwise
72 | designated in writing by the copyright owner as "Not a Contribution."
73 |
74 | "Contributor" shall mean Licensor and any individual or Legal Entity
75 | on behalf of whom a Contribution has been received by Licensor and
76 | subsequently incorporated within the Work.
77 |
78 | 2. Grant of Copyright License. Subject to the terms and conditions of
79 | this License, each Contributor hereby grants to You a perpetual,
80 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
81 | copyright license to reproduce, prepare Derivative Works of,
82 | publicly display, publicly perform, sublicense, and distribute the
83 | Work and such Derivative Works in Source or Object form.
84 |
85 | 3. Grant of Patent License. Subject to the terms and conditions of
86 | this License, each Contributor hereby grants to You a perpetual,
87 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
88 | (except as stated in this section) patent license to make, have made,
89 | use, offer to sell, sell, import, and otherwise transfer the Work,
90 | where such license applies only to those patent claims licensable
91 | by such Contributor that are necessarily infringed by their
92 | Contribution(s) alone or by combination of their Contribution(s)
93 | with the Work to which such Contribution(s) was submitted. If You
94 | institute patent litigation against any entity (including a
95 | cross-claim or counterclaim in a lawsuit) alleging that the Work
96 | or a Contribution incorporated within the Work constitutes direct
97 | or contributory patent infringement, then any patent licenses
98 | granted to You under this License for that Work shall terminate
99 | as of the date such litigation is filed.
100 |
101 | 4. Redistribution. You may reproduce and distribute copies of the
102 | Work or Derivative Works thereof in any medium, with or without
103 | modifications, and in Source or Object form, provided that You
104 | meet the following conditions:
105 |
106 | (a) You must give any other recipients of the Work or
107 | Derivative Works a copy of this License; and
108 |
109 | (b) You must cause any modified files to carry prominent notices
110 | stating that You changed the files; and
111 |
112 | (c) You must retain, in the Source form of any Derivative Works
113 | that You distribute, all copyright, patent, trademark, and
114 | attribution notices from the Source form of the Work,
115 | excluding those notices that do not pertain to any part of
116 | the Derivative Works; and
117 |
118 | (d) If the Work includes a "NOTICE" text file as part of its
119 | distribution, then any Derivative Works that You distribute must
120 | include a readable copy of the attribution notices contained
121 | within such NOTICE file, excluding those notices that do not
122 | pertain to any part of the Derivative Works, in at least one
123 | of the following places: within a NOTICE text file distributed
124 | as part of the Derivative Works; within the Source form or
125 | documentation, if provided along with the Derivative Works; or,
126 | within a display generated by the Derivative Works, if and
127 | wherever such third-party notices normally appear. The contents
128 | of the NOTICE file are for informational purposes only and
129 | do not modify the License. You may add Your own attribution
130 | notices within Derivative Works that You distribute, alongside
131 | or as an addendum to the NOTICE text from the Work, provided
132 | that such additional attribution notices cannot be construed
133 | as modifying the License.
134 |
135 | You may add Your own copyright statement to Your modifications and
136 | may provide additional or different license terms and conditions
137 | for use, reproduction, or distribution of Your modifications, or
138 | for any such Derivative Works as a whole, provided Your use,
139 | reproduction, and distribution of the Work otherwise complies with
140 | the conditions stated in this License.
141 |
142 | 5. Submission of Contributions. Unless You explicitly state otherwise,
143 | any Contribution intentionally submitted for inclusion in the Work
144 | by You to the Licensor shall be under the terms and conditions of
145 | this License, without any additional terms or conditions.
146 | Notwithstanding the above, nothing herein shall supersede or modify
147 | the terms of any separate license agreement you may have executed
148 | with Licensor regarding such Contributions.
149 |
150 | 6. Trademarks. This License does not grant permission to use the trade
151 | names, trademarks, service marks, or product names of the Licensor,
152 | except as required for reasonable and customary use in describing the
153 | origin of the Work and reproducing the content of the NOTICE file.
154 |
155 | 7. Disclaimer of Warranty. Unless required by applicable law or
156 | agreed to in writing, Licensor provides the Work (and each
157 | Contributor provides its Contributions) on an "AS IS" BASIS,
158 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
159 | implied, including, without limitation, any warranties or conditions
160 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
161 | PARTICULAR PURPOSE. You are solely responsible for determining the
162 | appropriateness of using or redistributing the Work and assume any
163 | risks associated with Your exercise of permissions under this License.
164 |
165 | 8. Limitation of Liability. In no event and under no legal theory,
166 | whether in tort (including negligence), contract, or otherwise,
167 | unless required by applicable law (such as deliberate and grossly
168 | negligent acts) or agreed to in writing, shall any Contributor be
169 | liable to You for damages, including any direct, indirect, special,
170 | incidental, or consequential damages of any character arising as a
171 | result of this License or out of the use or inability to use the
172 | Work (including but not limited to damages for loss of goodwill,
173 | work stoppage, computer failure or malfunction, or any and all
174 | other commercial damages or losses), even if such Contributor
175 | has been advised of the possibility of such damages.
176 |
177 | 9. Accepting Warranty or Additional Liability. While redistributing
178 | the Work or Derivative Works thereof, You may choose to offer,
179 | and charge a fee for, acceptance of support, warranty, indemnity,
180 | or other liability obligations and/or rights consistent with this
181 | License. However, in accepting such obligations, You may act only
182 | on Your own behalf and on Your sole responsibility, not on behalf
183 | of any other Contributor, and only if You agree to indemnify,
184 | defend, and hold each Contributor harmless for any liability
185 | incurred by, or claims asserted against, such Contributor by reason
186 | of your accepting any such warranty or additional liability.
187 |
188 | END OF TERMS AND CONDITIONS
--------------------------------------------------------------------------------
/library/Font-README.md:
--------------------------------------------------------------------------------
1 | These fonts where provided free by Google and can be downloaded from:
2 | http://developer.android.com/design/style/typography.html
--------------------------------------------------------------------------------
/library/LICENSE.txt:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "[]"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright [yyyy] [name of copyright owner]
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
203 |
--------------------------------------------------------------------------------
/library/README.md:
--------------------------------------------------------------------------------
1 | AndroidViewUtils
2 | ================
3 |
4 | Setup
5 | -----
6 | I have intentionally excluded all the IDE related files or files that require specific paths.
7 | Therefore in order to get this code into your IDE you will need to use the "Create Project from Existing Code" or similar option.
8 | You will also need to copy the project.properties.sample file to project.properties and then customize (if needed).
9 |
10 | All of this is so that any other contributions are not poluted with developer or IDE related noise.
11 | I am sorry for any inconvenience.
12 |
13 |
14 | Notes
15 | ------
16 | - All android resources must be in lowercase, so please be mindful of this when adding your fonts to your /res/raw directory
17 |
--------------------------------------------------------------------------------
/library/RobotoSpecimenBook.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sage42/AndroidViewUtils/65a6952963901adccb24210c47183d948f4e19eb/library/RobotoSpecimenBook.pdf
--------------------------------------------------------------------------------
/library/build.gradle:
--------------------------------------------------------------------------------
1 | // Project properties
2 | project.group = 'com.sage42.android.view'
3 | project.version = '1.0.1'
4 |
5 | apply plugin: 'android-library'
6 | apply plugin: 'maven'
7 | apply plugin: 'signing'
8 |
9 | dependencies
10 | {
11 | compile "com.android.support:support-v4:$androidSupportVersion"
12 | }
13 |
14 | android
15 | {
16 | buildToolsVersion "$androidBuildToolsVersion"
17 | compileSdkVersion androidCompileSdkVersion
18 |
19 | defaultConfig
20 | {
21 | minSdkVersion androidMinSdkVersion
22 | targetSdkVersion androidTargetSdkVersion
23 | }
24 |
25 | sourceSets
26 | {
27 | main
28 | {
29 | manifest.srcFile 'AndroidManifest.xml'
30 | java.srcDirs = ['src/main/java']
31 | resources.srcDirs = ['src/main/resources']
32 | aidl.srcDirs = ['src/main/aidl']
33 | renderscript.srcDirs = ['src/main/rs']
34 | res.srcDirs = ['res']
35 | assets.srcDirs = ['assets']
36 | }
37 | }
38 | }
39 |
40 | apply plugin: 'maven'
41 | configurations
42 | {
43 | archives
44 | { extendsFrom configurations.default }
45 | }
46 |
47 | signing
48 | {
49 | required
50 | {
51 | has("release") && gradle.taskGraph.hasTask("uploadArchives")
52 | }
53 | sign configurations.archives
54 | }
55 |
56 | def localRepoPath = "file://" + new File(System.getProperty("user.home"), ".m2/repository").absolutePath
57 |
58 | uploadArchives
59 | {
60 | configuration = configurations.archives
61 | repositories.mavenDeployer
62 | {
63 | beforeDeployment
64 | {
65 | MavenDeployment deployment -> signing.signPom(deployment)
66 | }
67 |
68 | repository(url: localRepoPath)
69 |
70 | pom.project
71 | {
72 | packaging 'aar'
73 |
74 | licenses
75 | {
76 | license
77 | {
78 | name 'The Apache Software License, Version 2.0'
79 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
80 | distribution 'repo'
81 | }
82 | }
83 | }
84 | }
85 | }
86 |
87 | // Simple Local Sonar Config
88 | // To use: gradle sonarRunner
89 | apply plugin: 'sonar-runner'
90 | sonarRunner
91 | {
92 | sonarProperties
93 | {
94 | properties["sonar.sources"] = android.sourceSets.main.java.srcDirs
95 | properties["sonar.tests"] = android.sourceSets.instrumentTest.java.srcDirs
96 | properties["sonar.binaries"] = file("build/classes/debug")
97 |
98 | property "sonar.projectKey", "AndroidViewUtils"
99 | property "sonar.projectName", "Sage 42 - AndroidViewUtils"
100 | property "sonar.projectVersion", "1.0"
101 | property "sonar.java.target", "1.6"
102 | property "sonar.host.url", "http://localhost:9000"
103 | property "sonar.jdbc.url", "jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true"
104 | property "sonar.jdbc.driverClassName", "com.mysql.jdbc.Driver"
105 | property "sonar.jdbc.username", "sonar"
106 | property "sonar.jdbc.password", "sonar"
107 | property "sonar.dynamicAnalysis", "reuseReports"
108 | property "sonar.surefire.reportsPath", "build/instrumentTest-results/connected/"
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/library/lint.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/library/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # To enable ProGuard in your project, edit project.properties
2 | # to define the proguard.config property as described in that file.
3 | #
4 | # Add project specific ProGuard rules here.
5 | # By default, the flags in this file are appended to flags specified
6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 | # You can edit the include path and order by changing the ProGuard
8 | # include property in project.properties.
9 | #
10 | # For more details, see
11 | # http://developer.android.com/guide/developing/tools/proguard.html
12 |
13 | # Add any project specific keep options here:
14 |
15 | # If your project uses WebView with JS, uncomment the following
16 | # and specify the fully qualified class name to the JavaScript interface
17 | # class:
18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 | # public *;
20 | #}
21 |
--------------------------------------------------------------------------------
/library/project.properties.sample:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=Google Inc.:Google APIs:18
15 | android.library=true
16 | android.library.reference.1=..\\..\\ActionBarSherlock\\actionbarsherlock
17 |
--------------------------------------------------------------------------------
/library/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sage42/AndroidViewUtils/65a6952963901adccb24210c47183d948f4e19eb/library/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/library/res/layout/test_mytextview_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
18 |
19 |
--------------------------------------------------------------------------------
/library/res/raw/roboto_black.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sage42/AndroidViewUtils/65a6952963901adccb24210c47183d948f4e19eb/library/res/raw/roboto_black.ttf
--------------------------------------------------------------------------------
/library/res/raw/roboto_black_italic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sage42/AndroidViewUtils/65a6952963901adccb24210c47183d948f4e19eb/library/res/raw/roboto_black_italic.ttf
--------------------------------------------------------------------------------
/library/res/raw/roboto_bold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sage42/AndroidViewUtils/65a6952963901adccb24210c47183d948f4e19eb/library/res/raw/roboto_bold.ttf
--------------------------------------------------------------------------------
/library/res/raw/roboto_bold_condensed.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sage42/AndroidViewUtils/65a6952963901adccb24210c47183d948f4e19eb/library/res/raw/roboto_bold_condensed.ttf
--------------------------------------------------------------------------------
/library/res/raw/roboto_bold_condensed_italic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sage42/AndroidViewUtils/65a6952963901adccb24210c47183d948f4e19eb/library/res/raw/roboto_bold_condensed_italic.ttf
--------------------------------------------------------------------------------
/library/res/raw/roboto_bold_italic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sage42/AndroidViewUtils/65a6952963901adccb24210c47183d948f4e19eb/library/res/raw/roboto_bold_italic.ttf
--------------------------------------------------------------------------------
/library/res/raw/roboto_condensed.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sage42/AndroidViewUtils/65a6952963901adccb24210c47183d948f4e19eb/library/res/raw/roboto_condensed.ttf
--------------------------------------------------------------------------------
/library/res/raw/roboto_condensed_italic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sage42/AndroidViewUtils/65a6952963901adccb24210c47183d948f4e19eb/library/res/raw/roboto_condensed_italic.ttf
--------------------------------------------------------------------------------
/library/res/raw/roboto_condensed_light.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sage42/AndroidViewUtils/65a6952963901adccb24210c47183d948f4e19eb/library/res/raw/roboto_condensed_light.ttf
--------------------------------------------------------------------------------
/library/res/raw/roboto_condensed_light_italic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sage42/AndroidViewUtils/65a6952963901adccb24210c47183d948f4e19eb/library/res/raw/roboto_condensed_light_italic.ttf
--------------------------------------------------------------------------------
/library/res/raw/roboto_light.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sage42/AndroidViewUtils/65a6952963901adccb24210c47183d948f4e19eb/library/res/raw/roboto_light.ttf
--------------------------------------------------------------------------------
/library/res/raw/roboto_light_italic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sage42/AndroidViewUtils/65a6952963901adccb24210c47183d948f4e19eb/library/res/raw/roboto_light_italic.ttf
--------------------------------------------------------------------------------
/library/res/raw/roboto_medium.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sage42/AndroidViewUtils/65a6952963901adccb24210c47183d948f4e19eb/library/res/raw/roboto_medium.ttf
--------------------------------------------------------------------------------
/library/res/raw/roboto_medium_italic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sage42/AndroidViewUtils/65a6952963901adccb24210c47183d948f4e19eb/library/res/raw/roboto_medium_italic.ttf
--------------------------------------------------------------------------------
/library/res/raw/roboto_regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sage42/AndroidViewUtils/65a6952963901adccb24210c47183d948f4e19eb/library/res/raw/roboto_regular.ttf
--------------------------------------------------------------------------------
/library/res/raw/roboto_regular_italic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sage42/AndroidViewUtils/65a6952963901adccb24210c47183d948f4e19eb/library/res/raw/roboto_regular_italic.ttf
--------------------------------------------------------------------------------
/library/res/raw/roboto_thin.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sage42/AndroidViewUtils/65a6952963901adccb24210c47183d948f4e19eb/library/res/raw/roboto_thin.ttf
--------------------------------------------------------------------------------
/library/res/raw/roboto_thin_italic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sage42/AndroidViewUtils/65a6952963901adccb24210c47183d948f4e19eb/library/res/raw/roboto_thin_italic.ttf
--------------------------------------------------------------------------------
/library/res/values-v11/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/library/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/library/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | #FFFFFF
5 | #000000
6 | #CCCCCC
7 |
8 |
--------------------------------------------------------------------------------
/library/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Sage 42 View Utils - Lib
4 |
5 |
--------------------------------------------------------------------------------
/library/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
14 |
15 |
16 |
19 |
20 |
--------------------------------------------------------------------------------
/library/src/main/java/com/sage42/android/view/animations/AnimateOpenAndClosed.java:
--------------------------------------------------------------------------------
1 | package com.sage42.android.view.animations;
2 |
3 | import android.view.View;
4 | import android.view.animation.Animation;
5 | import android.view.animation.Transformation;
6 |
7 | /**
8 | * Copyright (C) 2013- Sage 42 App Sdn Bhd
9 | *
10 | * Licensed under the Apache License, Version 2.0 (the "License");
11 | * you may not use this file except in compliance with the License.
12 | * You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing, software
17 | * distributed under the License is distributed on an "AS IS" BASIS,
18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 | * See the License for the specific language governing permissions and
20 | * limitations under the License.
21 | *
22 | * @author Corey Scott (corey.scott@sage42.com)
23 | *
24 | */
25 | public class AnimateOpenAndClosed extends Animation
26 | {
27 | private final int mHeightOpen;
28 | private final int mHeightClose;
29 | private final View mView;
30 | private final boolean mIsOpening;
31 |
32 | public AnimateOpenAndClosed(final View view, final int openHeight, final int closedHeight, final boolean isOpening)
33 | {
34 | super();
35 |
36 | this.mView = view;
37 | this.mHeightOpen = openHeight;
38 | this.mHeightClose = closedHeight;
39 | this.mIsOpening = isOpening;
40 | }
41 |
42 | @Override
43 | protected void applyTransformation(final float interpolatedTime, final Transformation transformation)
44 | {
45 | int newHeight;
46 | final int diff = this.mHeightOpen - this.mHeightClose;
47 | if (this.mIsOpening)
48 | {
49 | newHeight = this.mHeightClose + (int) (diff * interpolatedTime);
50 | }
51 | else
52 | {
53 | newHeight = this.mHeightClose + (int) (diff * (1 - interpolatedTime));
54 | }
55 | this.mView.getLayoutParams().height = newHeight;
56 | this.mView.requestLayout();
57 | }
58 |
59 | @Override
60 | public boolean willChangeBounds()
61 | {
62 | return true;
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/library/src/main/java/com/sage42/android/view/fonts/FontManager.java:
--------------------------------------------------------------------------------
1 | package com.sage42.android.view.fonts;
2 |
3 | import java.io.BufferedOutputStream;
4 | import java.io.File;
5 | import java.io.FileOutputStream;
6 | import java.io.IOException;
7 | import java.io.InputStream;
8 | import java.util.ArrayList;
9 | import java.util.HashMap;
10 | import java.util.List;
11 | import java.util.Locale;
12 | import java.util.Map;
13 |
14 | import android.content.Context;
15 | import android.content.res.Resources.NotFoundException;
16 | import android.content.res.TypedArray;
17 | import android.graphics.Typeface;
18 | import android.util.AttributeSet;
19 | import android.util.Log;
20 |
21 | import com.sage42.android.view.R;
22 |
23 | /**
24 | * Copyright (C) 2013- Sage 42 App Sdn Bhd
25 | *
26 | * Licensed under the Apache License, Version 2.0 (the "License");
27 | * you may not use this file except in compliance with the License.
28 | * You may obtain a copy of the License at
29 | *
30 | * http://www.apache.org/licenses/LICENSE-2.0
31 | *
32 | * Unless required by applicable law or agreed to in writing, software
33 | * distributed under the License is distributed on an "AS IS" BASIS,
34 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
35 | * See the License for the specific language governing permissions and
36 | * limitations under the License.
37 | *
38 | * @author Corey Scott (corey.scott@sage42.com)
39 | *
40 | */
41 | public class FontManager
42 | {
43 | private static final String TAG = FontManager.class.getSimpleName();
44 |
45 | private final Map mFonts;
46 |
47 | // singleton instance
48 | private static FontManager mInstance;
49 |
50 | protected FontManager()
51 | {
52 | // enforce singleton
53 | super();
54 |
55 | this.mFonts = new HashMap();
56 | }
57 |
58 | public static synchronized FontManager getInstance()
59 | {
60 | if (FontManager.mInstance == null)
61 | {
62 | FontManager.mInstance = new FontManager();
63 | }
64 | return FontManager.mInstance;
65 | }
66 |
67 | @SuppressWarnings("synthetic-access")
68 | private Font addFont(final Context context, final String fontName, final Integer normalResId,
69 | final Integer italicResId)
70 | {
71 | final String fontNameLower = fontName.toLowerCase(Locale.US);
72 |
73 | final Font font = new Font();
74 |
75 | // a list of font-family names supported.
76 | font.families = new ArrayList();
77 | font.families.add(fontNameLower);
78 |
79 | // a list of files specifying the different styles.
80 | font.styles = new ArrayList();
81 |
82 | if (normalResId != null)
83 | {
84 | final FontStyle fontStyle = new FontStyle();
85 | fontStyle.font = this.getFontFromRes(context, normalResId);
86 | fontStyle.style = Typeface.NORMAL;
87 | font.styles.add(fontStyle);
88 | Log.d(FontManager.TAG, "Loaded (Normal): " + fontNameLower); //$NON-NLS-1$
89 | }
90 |
91 | if (italicResId != null)
92 | {
93 | final FontStyle fontStyle = new FontStyle();
94 | fontStyle.font = this.getFontFromRes(context, italicResId);
95 | fontStyle.style = Typeface.ITALIC;
96 | font.styles.add(fontStyle);
97 | Log.d(FontManager.TAG, "Loaded (Italic): " + fontNameLower); //$NON-NLS-1$
98 | }
99 |
100 | return font;
101 | }
102 |
103 | public Typeface get(final Context context, final String fontFamily, final int inStyle)
104 | {
105 | final String fontFamilyLower = fontFamily.toLowerCase(Locale.US);
106 |
107 | if (!this.mFonts.containsKey(fontFamilyLower))
108 | {
109 | // attempt to load font JIT at runtime
110 | this.loadFont(context, fontFamilyLower);
111 |
112 | // return null, if load failed
113 | if (!this.mFonts.containsKey(fontFamilyLower))
114 | {
115 | Log.e(FontManager.TAG, "Failed to load: " + fontFamilyLower); //$NON-NLS-1$
116 | return null;
117 | }
118 | }
119 |
120 | // default to normal style if not was supplied
121 | final int style = (inStyle >= 0) ? inStyle : Typeface.NORMAL;
122 |
123 | final Font font = this.mFonts.get(fontFamilyLower);
124 | for (final FontStyle fontStyle : font.styles)
125 | {
126 | if (fontStyle.style == style)
127 | {
128 | return fontStyle.font;
129 | }
130 | }
131 |
132 | return null;
133 | }
134 |
135 | private void loadFont(final Context context, final String fontFamily)
136 | {
137 | final String fontFamilyLower = fontFamily.toLowerCase(Locale.US);
138 |
139 | RobotoTypes type = RobotoTypes.getByFamilyName(fontFamily);
140 | if (type == null)
141 | {
142 | Log.e(FontManager.TAG, "Failed to load font, unknown fontFamily: " + fontFamilyLower); //$NON-NLS-1$
143 | }
144 | else
145 | {
146 | this.mFonts.put(fontFamilyLower,
147 | this.addFont(context, type.getFontName(), type.getNormalResId(), type.getItalicResId()));
148 | }
149 | }
150 |
151 | /**
152 | * Extend this class and override this method for custom error handling.
153 | *
154 | * @param exception
155 | */
156 | public void logError(final Exception exception)
157 | {
158 | Log.e(FontManager.TAG, exception.getMessage(), exception);
159 | }
160 |
161 | private Typeface getFontFromRes(final Context context, final int resource)
162 | {
163 | Typeface typeface = null;
164 | InputStream inputStream = null;
165 | try
166 | {
167 | inputStream = context.getResources().openRawResource(resource);
168 | if (inputStream == null)
169 | {
170 | return null;
171 | }
172 |
173 | final String outPath = context.getCacheDir() + "/tmp" + System.currentTimeMillis() + ".raw"; //$NON-NLS-1$ //$NON-NLS-2$
174 |
175 | final byte[] buffer = new byte[inputStream.available()];
176 | final BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(outPath));
177 |
178 | int length = 0;
179 | while ((length = inputStream.read(buffer)) > 0)
180 | {
181 | bos.write(buffer, 0, length);
182 | }
183 |
184 | bos.close();
185 |
186 | typeface = Typeface.createFromFile(outPath);
187 |
188 | // clean up
189 | new File(outPath).delete();
190 | }
191 | catch (final NotFoundException exception)
192 | {
193 | this.logError(exception);
194 | }
195 | catch (final IOException exception)
196 | {
197 | this.logError(exception);
198 | }
199 | finally
200 | {
201 | // clean up
202 | if (inputStream != null)
203 | {
204 | try
205 | {
206 | inputStream.close();
207 | }
208 | catch (final IOException exception)
209 | {
210 | this.logError(exception);
211 | }
212 | }
213 | }
214 |
215 | return typeface;
216 | }
217 |
218 | public void addCustomFont(final Context context, final String fontFamily, final Integer normalFontRes,
219 | final Integer italicFontRes)
220 | {
221 | final String fontFamilyLower = fontFamily.toLowerCase(Locale.US);
222 |
223 | if (this.mFonts.containsKey(fontFamilyLower))
224 | {
225 | // not need to load it again
226 | return;
227 | }
228 |
229 | this.mFonts.put(fontFamilyLower, this.addFont(context, fontFamilyLower, normalFontRes, italicFontRes));
230 | }
231 |
232 | public static Typeface extractTypeface(final Context context, final AttributeSet attrs)
233 | {
234 | // Fonts work as a combination of particular family and the style.
235 | final TypedArray args = context.obtainStyledAttributes(attrs, R.styleable.fonts);
236 | final String family = args.getString(R.styleable.fonts_fontFamily);
237 | final int style = args.getInt(R.styleable.fonts_android_textStyle, -1);
238 | args.recycle();
239 |
240 | if (family == null)
241 | {
242 | return null;
243 | }
244 | // Set the typeface based on the family and the style combination.
245 | return FontManager.getInstance().get(context, family, style);
246 | }
247 |
248 | private static class FontStyle
249 | {
250 | int style;
251 | Typeface font;
252 | }
253 |
254 | private static class Font
255 | {
256 | // different font-family names that this Font will respond to.
257 | List families;
258 |
259 | // different styles for this font.
260 | List styles;
261 | }
262 |
263 | }
264 |
--------------------------------------------------------------------------------
/library/src/main/java/com/sage42/android/view/fonts/MyAutoCompleteTextView.java:
--------------------------------------------------------------------------------
1 | package com.sage42.android.view.fonts;
2 |
3 | import android.content.Context;
4 | import android.graphics.Typeface;
5 | import android.util.AttributeSet;
6 | import android.widget.AutoCompleteTextView;
7 |
8 | /**
9 | * Copyright (C) 2013- Sage 42 App Sdn Bhd
10 | *
11 | * Licensed under the Apache License, Version 2.0 (the "License");
12 | * you may not use this file except in compliance with the License.
13 | * You may obtain a copy of the License at
14 | *
15 | * http://www.apache.org/licenses/LICENSE-2.0
16 | *
17 | * Unless required by applicable law or agreed to in writing, software
18 | * distributed under the License is distributed on an "AS IS" BASIS,
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 | * See the License for the specific language governing permissions and
21 | * limitations under the License.
22 | *
23 | * @author Corey Scott (corey.scott@sage42.com)
24 | *
25 | */
26 | public class MyAutoCompleteTextView extends AutoCompleteTextView
27 | {
28 |
29 | public MyAutoCompleteTextView(final Context context, final AttributeSet attrs, final int defStyle)
30 | {
31 | super(context, attrs, defStyle);
32 | this.initCustomFonts(context, attrs);
33 | }
34 |
35 | public MyAutoCompleteTextView(final Context context, final AttributeSet attrs)
36 | {
37 | super(context, attrs);
38 | this.initCustomFonts(context, attrs);
39 | }
40 |
41 | public MyAutoCompleteTextView(final Context context)
42 | {
43 | super(context);
44 | this.initCustomFonts(context, null);
45 | }
46 |
47 | /**
48 | * Extract any custom font related settings from supplied args.
49 | *
50 | * @param context
51 | * @param attrs
52 | */
53 | private void initCustomFonts(final Context context, final AttributeSet attrs)
54 | {
55 | if (this.isInEditMode())
56 | {
57 | // this is preview mode so we need to stop processing
58 | return;
59 | }
60 |
61 | // Fonts work as a combination of particular family and the style.
62 | final Typeface typeface = FontManager.extractTypeface(context, attrs);
63 | if (typeface != null)
64 | {
65 | this.setTypeface(typeface);
66 | }
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/library/src/main/java/com/sage42/android/view/fonts/MyButton.java:
--------------------------------------------------------------------------------
1 | package com.sage42.android.view.fonts;
2 |
3 | import android.content.Context;
4 | import android.graphics.Typeface;
5 | import android.util.AttributeSet;
6 | import android.widget.Button;
7 |
8 | /**
9 | * Copyright (C) 2013- Sage 42 App Sdn Bhd
10 | *
11 | * Licensed under the Apache License, Version 2.0 (the "License");
12 | * you may not use this file except in compliance with the License.
13 | * You may obtain a copy of the License at
14 | *
15 | * http://www.apache.org/licenses/LICENSE-2.0
16 | *
17 | * Unless required by applicable law or agreed to in writing, software
18 | * distributed under the License is distributed on an "AS IS" BASIS,
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 | * See the License for the specific language governing permissions and
21 | * limitations under the License.
22 | *
23 | * @author Corey Scott (corey.scott@sage42.com)
24 | *
25 | */
26 | public class MyButton extends Button
27 | {
28 |
29 | public MyButton(final Context context, final AttributeSet attrs, final int defStyle)
30 | {
31 | super(context, attrs, defStyle);
32 | this.initCustomFonts(context, attrs);
33 | }
34 |
35 | public MyButton(final Context context, final AttributeSet attrs)
36 | {
37 | super(context, attrs);
38 | this.initCustomFonts(context, attrs);
39 | }
40 |
41 | public MyButton(final Context context)
42 | {
43 | super(context);
44 | this.initCustomFonts(context, null);
45 | }
46 |
47 | /**
48 | * Extract any custom font related settings from supplied args.
49 | *
50 | * @param context
51 | * @param attrs
52 | */
53 | private void initCustomFonts(final Context context, final AttributeSet attrs)
54 | {
55 | if (this.isInEditMode())
56 | {
57 | // this is preview mode so we need to stop processing
58 | return;
59 | }
60 |
61 | final Typeface typeface = FontManager.extractTypeface(context, attrs);
62 | if (typeface != null)
63 | {
64 | this.setTypeface(typeface);
65 | }
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/library/src/main/java/com/sage42/android/view/fonts/MyCheckBox.java:
--------------------------------------------------------------------------------
1 | package com.sage42.android.view.fonts;
2 |
3 | import android.content.Context;
4 | import android.graphics.Typeface;
5 | import android.util.AttributeSet;
6 | import android.widget.CheckBox;
7 |
8 | /**
9 | * Copyright (C) 2013- Sage 42 App Sdn Bhd
10 | *
11 | * Licensed under the Apache License, Version 2.0 (the "License");
12 | * you may not use this file except in compliance with the License.
13 | * You may obtain a copy of the License at
14 | *
15 | * http://www.apache.org/licenses/LICENSE-2.0
16 | *
17 | * Unless required by applicable law or agreed to in writing, software
18 | * distributed under the License is distributed on an "AS IS" BASIS,
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 | * See the License for the specific language governing permissions and
21 | * limitations under the License.
22 | *
23 | * @author Corey Scott (corey.scott@sage42.com)
24 | *
25 | */
26 | public class MyCheckBox extends CheckBox
27 | {
28 |
29 | public MyCheckBox(final Context context, final AttributeSet attrs, final int defStyle)
30 | {
31 | super(context, attrs, defStyle);
32 | this.initCustomFonts(context, attrs);
33 | }
34 |
35 | public MyCheckBox(final Context context, final AttributeSet attrs)
36 | {
37 | super(context, attrs);
38 | this.initCustomFonts(context, attrs);
39 | }
40 |
41 | public MyCheckBox(final Context context)
42 | {
43 | super(context);
44 | this.initCustomFonts(context, null);
45 | }
46 |
47 | /**
48 | * Extract any custom font related settings from supplied args.
49 | *
50 | * @param context
51 | * @param attrs
52 | */
53 | private void initCustomFonts(final Context context, final AttributeSet attrs)
54 | {
55 | if (this.isInEditMode())
56 | {
57 | // this is preview mode so we need to stop processing
58 | return;
59 | }
60 |
61 | // Fonts work as a combination of particular family and the style.
62 | final Typeface typeface = FontManager.extractTypeface(context, attrs);
63 | if (typeface != null)
64 | {
65 | this.setTypeface(typeface);
66 | }
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/library/src/main/java/com/sage42/android/view/fonts/MyCheckedTextView.java:
--------------------------------------------------------------------------------
1 | package com.sage42.android.view.fonts;
2 |
3 | import android.content.Context;
4 | import android.graphics.Typeface;
5 | import android.util.AttributeSet;
6 | import android.widget.CheckedTextView;
7 |
8 | /**
9 | * Copyright (C) 2013- Sage 42 App Sdn Bhd
10 | *
11 | * Licensed under the Apache License, Version 2.0 (the "License");
12 | * you may not use this file except in compliance with the License.
13 | * You may obtain a copy of the License at
14 | *
15 | * http://www.apache.org/licenses/LICENSE-2.0
16 | *
17 | * Unless required by applicable law or agreed to in writing, software
18 | * distributed under the License is distributed on an "AS IS" BASIS,
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 | * See the License for the specific language governing permissions and
21 | * limitations under the License.
22 | *
23 | * @author Corey Scott (corey.scott@sage42.com)
24 | *
25 | */
26 | public class MyCheckedTextView extends CheckedTextView
27 | {
28 |
29 | public MyCheckedTextView(final Context context, final AttributeSet attrs, final int defStyle)
30 | {
31 | super(context, attrs, defStyle);
32 | this.initCustomFonts(context, attrs);
33 | }
34 |
35 | public MyCheckedTextView(final Context context, final AttributeSet attrs)
36 | {
37 | super(context, attrs);
38 | this.initCustomFonts(context, attrs);
39 | }
40 |
41 | public MyCheckedTextView(final Context context)
42 | {
43 | super(context);
44 | this.initCustomFonts(context, null);
45 | }
46 |
47 | /**
48 | * Extract any custom font related settings from supplied args.
49 | *
50 | * @param context
51 | * @param attrs
52 | */
53 | private void initCustomFonts(final Context context, final AttributeSet attrs)
54 | {
55 | if (this.isInEditMode())
56 | {
57 | // this is preview mode so we need to stop processing
58 | return;
59 | }
60 |
61 | // Fonts work as a combination of particular family and the style.
62 | final Typeface typeface = FontManager.extractTypeface(context, attrs);
63 | if (typeface != null)
64 | {
65 | this.setTypeface(typeface);
66 | }
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/library/src/main/java/com/sage42/android/view/fonts/MyChronometer.java:
--------------------------------------------------------------------------------
1 | package com.sage42.android.view.fonts;
2 |
3 | import android.content.Context;
4 | import android.graphics.Typeface;
5 | import android.util.AttributeSet;
6 | import android.widget.Chronometer;
7 |
8 | /**
9 | * Copyright (C) 2013- Sage 42 App Sdn Bhd
10 | *
11 | * Licensed under the Apache License, Version 2.0 (the "License");
12 | * you may not use this file except in compliance with the License.
13 | * You may obtain a copy of the License at
14 | *
15 | * http://www.apache.org/licenses/LICENSE-2.0
16 | *
17 | * Unless required by applicable law or agreed to in writing, software
18 | * distributed under the License is distributed on an "AS IS" BASIS,
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 | * See the License for the specific language governing permissions and
21 | * limitations under the License.
22 | *
23 | * @author Corey Scott (corey.scott@sage42.com)
24 | *
25 | */
26 | public class MyChronometer extends Chronometer
27 | {
28 |
29 | public MyChronometer(final Context context, final AttributeSet attrs, final int defStyle)
30 | {
31 | super(context, attrs, defStyle);
32 | this.initCustomFonts(context, attrs);
33 | }
34 |
35 | public MyChronometer(final Context context, final AttributeSet attrs)
36 | {
37 | super(context, attrs);
38 | this.initCustomFonts(context, attrs);
39 | }
40 |
41 | public MyChronometer(final Context context)
42 | {
43 | super(context);
44 | this.initCustomFonts(context, null);
45 | }
46 |
47 | /**
48 | * Extract any custom font related settings from supplied args.
49 | *
50 | * @param context
51 | * @param attrs
52 | */
53 | private void initCustomFonts(final Context context, final AttributeSet attrs)
54 | {
55 | if (this.isInEditMode())
56 | {
57 | // this is preview mode so we need to stop processing
58 | return;
59 | }
60 |
61 | // Fonts work as a combination of particular family and the style.
62 | final Typeface typeface = FontManager.extractTypeface(context, attrs);
63 | if (typeface != null)
64 | {
65 | this.setTypeface(typeface);
66 | }
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/library/src/main/java/com/sage42/android/view/fonts/MyCompoundButton.java:
--------------------------------------------------------------------------------
1 | package com.sage42.android.view.fonts;
2 |
3 | import android.content.Context;
4 | import android.graphics.Typeface;
5 | import android.util.AttributeSet;
6 | import android.widget.CompoundButton;
7 |
8 | /**
9 | * Copyright (C) 2013- Sage 42 App Sdn Bhd
10 | *
11 | * Licensed under the Apache License, Version 2.0 (the "License");
12 | * you may not use this file except in compliance with the License.
13 | * You may obtain a copy of the License at
14 | *
15 | * http://www.apache.org/licenses/LICENSE-2.0
16 | *
17 | * Unless required by applicable law or agreed to in writing, software
18 | * distributed under the License is distributed on an "AS IS" BASIS,
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 | * See the License for the specific language governing permissions and
21 | * limitations under the License.
22 | *
23 | * @author Corey Scott (corey.scott@sage42.com)
24 | *
25 | */
26 | public class MyCompoundButton extends CompoundButton
27 | {
28 |
29 | public MyCompoundButton(final Context context, final AttributeSet attrs, final int defStyle)
30 | {
31 | super(context, attrs, defStyle);
32 | this.initCustomFonts(context, attrs);
33 | }
34 |
35 | public MyCompoundButton(final Context context, final AttributeSet attrs)
36 | {
37 | super(context, attrs);
38 | this.initCustomFonts(context, attrs);
39 | }
40 |
41 | public MyCompoundButton(final Context context)
42 | {
43 | super(context);
44 | this.initCustomFonts(context, null);
45 | }
46 |
47 | /**
48 | * Extract any custom font related settings from supplied args.
49 | *
50 | * @param context
51 | * @param attrs
52 | */
53 | private void initCustomFonts(final Context context, final AttributeSet attrs)
54 | {
55 | if (this.isInEditMode())
56 | {
57 | // this is preview mode so we need to stop processing
58 | return;
59 | }
60 |
61 | // Fonts work as a combination of particular family and the style.
62 | final Typeface typeface = FontManager.extractTypeface(context, attrs);
63 | if (typeface != null)
64 | {
65 | this.setTypeface(typeface);
66 | }
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/library/src/main/java/com/sage42/android/view/fonts/MyEditText.java:
--------------------------------------------------------------------------------
1 | package com.sage42.android.view.fonts;
2 |
3 | import android.content.Context;
4 | import android.graphics.Typeface;
5 | import android.util.AttributeSet;
6 | import android.widget.EditText;
7 |
8 | /**
9 | * Copyright (C) 2013- Sage 42 App Sdn Bhd
10 | *
11 | * Licensed under the Apache License, Version 2.0 (the "License");
12 | * you may not use this file except in compliance with the License.
13 | * You may obtain a copy of the License at
14 | *
15 | * http://www.apache.org/licenses/LICENSE-2.0
16 | *
17 | * Unless required by applicable law or agreed to in writing, software
18 | * distributed under the License is distributed on an "AS IS" BASIS,
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 | * See the License for the specific language governing permissions and
21 | * limitations under the License.
22 | *
23 | * @author Corey Scott (corey.scott@sage42.com)
24 | *
25 | */
26 | public class MyEditText extends EditText
27 | {
28 |
29 | public MyEditText(final Context context, final AttributeSet attrs, final int defStyle)
30 | {
31 | super(context, attrs, defStyle);
32 | this.initCustomFonts(context, attrs);
33 | }
34 |
35 | public MyEditText(final Context context, final AttributeSet attrs)
36 | {
37 | super(context, attrs);
38 | this.initCustomFonts(context, attrs);
39 | }
40 |
41 | public MyEditText(final Context context)
42 | {
43 | super(context);
44 | this.initCustomFonts(context, null);
45 | }
46 |
47 | /**
48 | * Extract any custom font related settings from supplied args.
49 | *
50 | * @param context
51 | * @param attrs
52 | */
53 | private void initCustomFonts(final Context context, final AttributeSet attrs)
54 | {
55 | if (this.isInEditMode())
56 | {
57 | // this is preview mode so we need to stop processing
58 | return;
59 | }
60 |
61 | // Fonts work as a combination of particular family and the style.
62 | final Typeface typeface = FontManager.extractTypeface(context, attrs);
63 | if (typeface != null)
64 | {
65 | this.setTypeface(typeface);
66 | }
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/library/src/main/java/com/sage42/android/view/fonts/MyExtractEditText.java:
--------------------------------------------------------------------------------
1 | package com.sage42.android.view.fonts;
2 |
3 | import android.content.Context;
4 | import android.graphics.Typeface;
5 | import android.inputmethodservice.ExtractEditText;
6 | import android.util.AttributeSet;
7 |
8 | /**
9 | * Copyright (C) 2013- Sage 42 App Sdn Bhd
10 | *
11 | * Licensed under the Apache License, Version 2.0 (the "License");
12 | * you may not use this file except in compliance with the License.
13 | * You may obtain a copy of the License at
14 | *
15 | * http://www.apache.org/licenses/LICENSE-2.0
16 | *
17 | * Unless required by applicable law or agreed to in writing, software
18 | * distributed under the License is distributed on an "AS IS" BASIS,
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 | * See the License for the specific language governing permissions and
21 | * limitations under the License.
22 | *
23 | * @author Corey Scott (corey.scott@sage42.com)
24 | *
25 | */
26 | public class MyExtractEditText extends ExtractEditText
27 | {
28 |
29 | public MyExtractEditText(final Context context, final AttributeSet attrs, final int defStyle)
30 | {
31 | super(context, attrs, defStyle);
32 | this.initCustomFonts(context, attrs);
33 | }
34 |
35 | public MyExtractEditText(final Context context, final AttributeSet attrs)
36 | {
37 | super(context, attrs);
38 | this.initCustomFonts(context, attrs);
39 | }
40 |
41 | public MyExtractEditText(final Context context)
42 | {
43 | super(context);
44 | this.initCustomFonts(context, null);
45 | }
46 |
47 | /**
48 | * Extract any custom font related settings from supplied args.
49 | *
50 | * @param context
51 | * @param attrs
52 | */
53 | private void initCustomFonts(final Context context, final AttributeSet attrs)
54 | {
55 | if (this.isInEditMode())
56 | {
57 | // this is preview mode so we need to stop processing
58 | return;
59 | }
60 |
61 | // Fonts work as a combination of particular family and the style.
62 | final Typeface typeface = FontManager.extractTypeface(context, attrs);
63 | if (typeface != null)
64 | {
65 | this.setTypeface(typeface);
66 | }
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/library/src/main/java/com/sage42/android/view/fonts/MyRadioButton.java:
--------------------------------------------------------------------------------
1 | package com.sage42.android.view.fonts;
2 |
3 | import android.content.Context;
4 | import android.graphics.Typeface;
5 | import android.util.AttributeSet;
6 | import android.widget.RadioButton;
7 |
8 | /**
9 | * Copyright (C) 2013- Sage 42 App Sdn Bhd
10 | *
11 | * Licensed under the Apache License, Version 2.0 (the "License");
12 | * you may not use this file except in compliance with the License.
13 | * You may obtain a copy of the License at
14 | *
15 | * http://www.apache.org/licenses/LICENSE-2.0
16 | *
17 | * Unless required by applicable law or agreed to in writing, software
18 | * distributed under the License is distributed on an "AS IS" BASIS,
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 | * See the License for the specific language governing permissions and
21 | * limitations under the License.
22 | *
23 | * @author Corey Scott (corey.scott@sage42.com)
24 | *
25 | */
26 | public class MyRadioButton extends RadioButton
27 | {
28 |
29 | public MyRadioButton(final Context context, final AttributeSet attrs, final int defStyle)
30 | {
31 | super(context, attrs, defStyle);
32 | this.initCustomFonts(context, attrs);
33 | }
34 |
35 | public MyRadioButton(final Context context, final AttributeSet attrs)
36 | {
37 | super(context, attrs);
38 | this.initCustomFonts(context, attrs);
39 | }
40 |
41 | public MyRadioButton(final Context context)
42 | {
43 | super(context);
44 | this.initCustomFonts(context, null);
45 | }
46 |
47 | /**
48 | * Extract any custom font related settings from supplied args.
49 | *
50 | * @param context
51 | * @param attrs
52 | */
53 | private void initCustomFonts(final Context context, final AttributeSet attrs)
54 | {
55 | if (this.isInEditMode())
56 | {
57 | // this is preview mode so we need to stop processing
58 | return;
59 | }
60 |
61 | // Fonts work as a combination of particular family and the style.
62 | final Typeface typeface = FontManager.extractTypeface(context, attrs);
63 | if (typeface != null)
64 | {
65 | this.setTypeface(typeface);
66 | }
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/library/src/main/java/com/sage42/android/view/fonts/MyScrollingTextView.java:
--------------------------------------------------------------------------------
1 | package com.sage42.android.view.fonts;
2 |
3 | import android.content.Context;
4 | import android.graphics.Rect;
5 | import android.graphics.Typeface;
6 | import android.text.TextUtils.TruncateAt;
7 | import android.util.AttributeSet;
8 | import android.widget.TextView;
9 |
10 | /**
11 | * Copyright (C) 2013- Sage 42 App Sdn Bhd
12 | *
13 | * Licensed under the Apache License, Version 2.0 (the "License");
14 | * you may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at
16 | *
17 | * http://www.apache.org/licenses/LICENSE-2.0
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | *
25 | * @author Corey Scott (corey.scott@sage42.com)
26 | *
27 | */
28 | /**
29 | * Auto-Scrolling or Marquee TextView
30 | *
31 | * Notes:
32 | * Due to device/system limitations this may not work on when inside a RelativeLayout,
33 | * unfortunately the reason/excuse for this is beyond me.
34 | *
35 | * Reference: http://androidbears.stellarpc.net/?p=185
36 | *
37 | */
38 | public class MyScrollingTextView extends TextView
39 | {
40 |
41 | public MyScrollingTextView(final Context context, final AttributeSet attrs, final int defStyle)
42 | {
43 | super(context, attrs, defStyle);
44 | this.init();
45 | this.initCustomFonts(context, attrs);
46 | }
47 |
48 | public MyScrollingTextView(final Context context, final AttributeSet attrs)
49 | {
50 | super(context, attrs);
51 | this.init();
52 | this.initCustomFonts(context, attrs);
53 | }
54 |
55 | public MyScrollingTextView(final Context context)
56 | {
57 | super(context);
58 | this.init();
59 | this.initCustomFonts(context, null);
60 | }
61 |
62 | private void init()
63 | {
64 | // setup the other text view properties
65 | super.setSingleLine(true);
66 | super.setEllipsize(TruncateAt.MARQUEE);
67 | }
68 |
69 | @Override
70 | protected void onFocusChanged(final boolean focused, final int direction, final Rect previouslyFocusedRect)
71 | {
72 | if (focused)
73 | {
74 | super.onFocusChanged(focused, direction, previouslyFocusedRect);
75 | }
76 | }
77 |
78 | @Override
79 | public void onWindowFocusChanged(final boolean focused)
80 | {
81 | if (focused)
82 | {
83 | super.onWindowFocusChanged(focused);
84 | }
85 | }
86 |
87 | /**
88 | * Force this UI element to always think it is focused and therefore the marquee should play.
89 | *
90 | * @see android.view.View#isFocused()
91 | */
92 | @Override
93 | public boolean isFocused()
94 | {
95 | return true;
96 | }
97 |
98 | /**
99 | * Extract any custom font related settings from supplied args.
100 | *
101 | * @param context
102 | * @param attrs
103 | */
104 | private void initCustomFonts(final Context context, final AttributeSet attrs)
105 | {
106 | if (this.isInEditMode())
107 | {
108 | // this is preview mode so we need to stop processing
109 | return;
110 | }
111 |
112 | // Fonts work as a combination of particular family and the style.
113 | final Typeface typeface = FontManager.extractTypeface(context, attrs);
114 | if (typeface != null)
115 | {
116 | this.setTypeface(typeface);
117 | }
118 | }
119 |
120 | }
121 |
--------------------------------------------------------------------------------
/library/src/main/java/com/sage42/android/view/fonts/MyTextView.java:
--------------------------------------------------------------------------------
1 | package com.sage42.android.view.fonts;
2 |
3 | import android.content.Context;
4 | import android.graphics.Typeface;
5 | import android.util.AttributeSet;
6 | import android.widget.TextView;
7 |
8 | /**
9 | * Copyright (C) 2013- Sage 42 App Sdn Bhd
10 | *
11 | * Licensed under the Apache License, Version 2.0 (the "License");
12 | * you may not use this file except in compliance with the License.
13 | * You may obtain a copy of the License at
14 | *
15 | * http://www.apache.org/licenses/LICENSE-2.0
16 | *
17 | * Unless required by applicable law or agreed to in writing, software
18 | * distributed under the License is distributed on an "AS IS" BASIS,
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 | * See the License for the specific language governing permissions and
21 | * limitations under the License.
22 | *
23 | * @author Corey Scott (corey.scott@sage42.com)
24 | *
25 | */
26 | public class MyTextView extends TextView
27 | {
28 | public MyTextView(final Context context)
29 | {
30 | super(context);
31 | this.initCustomFonts(context, null);
32 | }
33 |
34 | public MyTextView(final Context context, final AttributeSet attrs)
35 | {
36 | super(context, attrs);
37 | this.initCustomFonts(context, attrs);
38 | }
39 |
40 | public MyTextView(final Context context, final AttributeSet attrs, final int defStyle)
41 | {
42 | super(context, attrs, defStyle);
43 | this.initCustomFonts(context, attrs);
44 | }
45 |
46 | /**
47 | * Extract any custom font related settings from supplied args.
48 | *
49 | * @param context
50 | * @param attrs
51 | */
52 | private void initCustomFonts(final Context context, final AttributeSet attrs)
53 | {
54 | if (this.isInEditMode())
55 | {
56 | // this is preview mode so we need to stop processing
57 | return;
58 | }
59 |
60 | // Fonts work as a combination of particular family and the style.
61 | final Typeface typeface = FontManager.extractTypeface(context, attrs);
62 | if (typeface != null)
63 | {
64 | this.setTypeface(typeface);
65 | }
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/library/src/main/java/com/sage42/android/view/fonts/MyToggleButton.java:
--------------------------------------------------------------------------------
1 | package com.sage42.android.view.fonts;
2 |
3 | import android.content.Context;
4 | import android.graphics.Typeface;
5 | import android.util.AttributeSet;
6 | import android.widget.ToggleButton;
7 |
8 | /**
9 | * Copyright (C) 2013- Sage 42 App Sdn Bhd
10 | *
11 | * Licensed under the Apache License, Version 2.0 (the "License");
12 | * you may not use this file except in compliance with the License.
13 | * You may obtain a copy of the License at
14 | *
15 | * http://www.apache.org/licenses/LICENSE-2.0
16 | *
17 | * Unless required by applicable law or agreed to in writing, software
18 | * distributed under the License is distributed on an "AS IS" BASIS,
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 | * See the License for the specific language governing permissions and
21 | * limitations under the License.
22 | *
23 | * @author Corey Scott (corey.scott@sage42.com)
24 | *
25 | */
26 | public class MyToggleButton extends ToggleButton
27 | {
28 |
29 | public MyToggleButton(final Context context, final AttributeSet attrs, final int defStyle)
30 | {
31 | super(context, attrs, defStyle);
32 | this.initCustomFonts(context, attrs);
33 | }
34 |
35 | public MyToggleButton(final Context context, final AttributeSet attrs)
36 | {
37 | super(context, attrs);
38 | this.initCustomFonts(context, attrs);
39 | }
40 |
41 | public MyToggleButton(final Context context)
42 | {
43 | super(context);
44 | this.initCustomFonts(context, null);
45 | }
46 |
47 | /**
48 | * Extract any custom font related settings from supplied args.
49 | *
50 | * @param context
51 | * @param attrs
52 | */
53 | private void initCustomFonts(final Context context, final AttributeSet attrs)
54 | {
55 | if (this.isInEditMode())
56 | {
57 | // this is preview mode so we need to stop processing
58 | return;
59 | }
60 |
61 | // Fonts work as a combination of particular family and the style.
62 | final Typeface typeface = FontManager.extractTypeface(context, attrs);
63 | if (typeface != null)
64 | {
65 | this.setTypeface(typeface);
66 | }
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/library/src/main/java/com/sage42/android/view/fonts/RobotoTypes.java:
--------------------------------------------------------------------------------
1 | package com.sage42.android.view.fonts;
2 |
3 | import java.util.Locale;
4 |
5 | import com.sage42.android.view.R;
6 |
7 | public enum RobotoTypes
8 | {
9 | BLACK("roboto-black", R.raw.roboto_black, R.raw.roboto_black_italic), //$NON-NLS-1$
10 | BOLD("roboto-bold", R.raw.roboto_bold, R.raw.roboto_bold_italic), //$NON-NLS-1$
11 | BOLD_CONDENSED("roboto-bold-condensed", R.raw.roboto_bold_condensed, R.raw.roboto_bold_condensed_italic), //$NON-NLS-1$
12 | CONDENSED("roboto-condensed", R.raw.roboto_condensed, R.raw.roboto_condensed_italic), //$NON-NLS-1$
13 | CONDENSED_LIGHT("roboto-condensed-light", R.raw.roboto_condensed_light, R.raw.roboto_condensed_light_italic), //$NON-NLS-1$
14 | LIGHT("roboto-light", R.raw.roboto_light, R.raw.roboto_light_italic), //$NON-NLS-1$
15 | MEDIUM("roboto-medium", R.raw.roboto_medium, R.raw.roboto_medium_italic), //$NON-NLS-1$
16 | REGULAR("roboto-regular", R.raw.roboto_regular, R.raw.roboto_regular_italic), //$NON-NLS-1$
17 | THIN("roboto-thin", R.raw.roboto_thin, R.raw.roboto_thin_italic); //$NON-NLS-1$
18 |
19 | private final String mFontName;
20 | private int mNormalResId;
21 | private int mItalicResId;
22 |
23 | private RobotoTypes(final String fontName, final int normalResId, final int italicResId)
24 | {
25 | this.mFontName = fontName;
26 | this.mNormalResId = normalResId;
27 | this.mItalicResId = italicResId;
28 | }
29 |
30 | public static RobotoTypes getByFamilyName(final String familyName)
31 | {
32 | if ((familyName == null) || (familyName.length() == 0))
33 | {
34 | // sanity check
35 | return null;
36 | }
37 |
38 | final String familyNameLower = familyName.toLowerCase(Locale.US);
39 | for (final RobotoTypes thisFamily : RobotoTypes.values())
40 | {
41 | if (thisFamily.getFontName().toLowerCase(Locale.US).equals(familyNameLower))
42 | {
43 | return thisFamily;
44 | }
45 | }
46 |
47 | return null;
48 | }
49 |
50 | /**
51 | * @return the fontName
52 | */
53 | public String getFontName()
54 | {
55 | return this.mFontName;
56 | }
57 |
58 | /**
59 | * @return the normalResId
60 | */
61 | public int getNormalResId()
62 | {
63 | return this.mNormalResId;
64 | }
65 |
66 | /**
67 | * @return the italicResId
68 | */
69 | public int getItalicResId()
70 | {
71 | return this.mItalicResId;
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/library/src/main/java/com/sage42/android/view/gestures/MyGestureDetector.java:
--------------------------------------------------------------------------------
1 | package com.sage42.android.view.gestures;
2 |
3 | import android.util.Log;
4 | import android.view.GestureDetector.SimpleOnGestureListener;
5 | import android.view.MotionEvent;
6 |
7 | import com.sage42.android.view.BuildConfig;
8 |
9 | public class MyGestureDetector extends SimpleOnGestureListener
10 | {
11 | private static final String TAG = MyGestureDetector.class.getSimpleName();
12 |
13 | private static final int SWIPE_MIN_DISTANCE = 120;
14 | private static final int SWIPE_MAX_OFF_PATH = 250;
15 | private static final int SWIPE_THRESHOLD_VELOCITY = 100;
16 |
17 | private final ISwipeCallbacks mCallback;
18 |
19 | public MyGestureDetector(final ISwipeCallbacks callback)
20 | {
21 | super();
22 | this.mCallback = callback;
23 | }
24 |
25 | @Override
26 | public boolean onFling(final MotionEvent event1, final MotionEvent event2, final float velocityX,
27 | final float velocityY)
28 | {
29 | try
30 | {
31 | final boolean isXDirectionOffpath = Math.abs(event1.getX() - event2.getX()) > MyGestureDetector.SWIPE_MAX_OFF_PATH;
32 | final boolean isYDirectionOffpath = Math.abs(event1.getY() - event2.getY()) > MyGestureDetector.SWIPE_MAX_OFF_PATH;
33 |
34 | final boolean isXDirectionMinDistance = Math.abs(event1.getX() - event2.getX()) > MyGestureDetector.SWIPE_MIN_DISTANCE;
35 | final boolean isYDirectionMinDistance = Math.abs(event1.getY() - event2.getY()) > MyGestureDetector.SWIPE_MIN_DISTANCE;
36 |
37 | final boolean isXVelocityExceedThreshold = Math.abs(velocityX) > MyGestureDetector.SWIPE_THRESHOLD_VELOCITY;
38 | final boolean isYVelocityExceedThreshold = Math.abs(velocityY) > MyGestureDetector.SWIPE_THRESHOLD_VELOCITY;
39 |
40 | final boolean swipeInXDirection = false;
41 | final boolean swipeInYDirection = false;
42 |
43 | SwipeDirection swipeDirection = null;
44 |
45 | // Check whether we have a swipe in the X direction
46 | if (isXDirectionMinDistance && isXVelocityExceedThreshold && !isYDirectionOffpath)
47 | {
48 | if (event1.getX() > event2.getX())
49 | {
50 | // right to left swipe
51 | swipeDirection = SwipeDirection.LEFT;
52 | }
53 | else if (event2.getX() > event1.getX())
54 | {
55 | // left to right swipe
56 | swipeDirection = SwipeDirection.RIGHT;
57 | }
58 | }
59 |
60 | // Check whether we have a swipe in the Y direction
61 | if (isYDirectionMinDistance && isYVelocityExceedThreshold && !isXDirectionOffpath)
62 | {
63 | if (event1.getY() > event2.getY())
64 | {
65 | // right to left swipe
66 | swipeDirection = SwipeDirection.UP;
67 | }
68 | else if (event2.getY() > event1.getY())
69 | {
70 | // left to right swipe
71 | swipeDirection = SwipeDirection.DOWN;
72 | }
73 | }
74 |
75 | if (swipeDirection != null)
76 | {
77 | this.mCallback.onSwipe(swipeDirection);
78 | }
79 |
80 | return (swipeDirection == null) ? false : true;
81 | }
82 | catch (final RuntimeException exception)
83 | {
84 | if (BuildConfig.DEBUG)
85 | {
86 | Log.e(MyGestureDetector.TAG, exception.getMessage(), exception);
87 | }
88 | }
89 |
90 | return false;
91 | }
92 |
93 | /**
94 | * This is needed so that we dont need to use an onClick listener in the activity.
95 | *
96 | * @see android.view.GestureDetector.SimpleOnGestureListener#onDown(android.view.MotionEvent)
97 | */
98 | @Override
99 | public boolean onDown(final MotionEvent event)
100 | {
101 | return true;
102 | }
103 |
104 | public interface ISwipeCallbacks
105 | {
106 | /**
107 | * Called on swipe, possible directions (LEFT, RIGHT)
108 | */
109 | void onSwipe(final SwipeDirection direction);
110 | }
111 |
112 | public enum SwipeDirection
113 | {
114 | LEFT, RIGHT, UP, DOWN;
115 | }
116 |
117 | }
118 |
--------------------------------------------------------------------------------
/library/src/main/java/com/sage42/android/view/pager/CursorFragmentPagerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.sage42.android.view.pager;
2 |
3 | import android.database.Cursor;
4 | import android.support.v4.app.Fragment;
5 | import android.support.v4.app.FragmentManager;
6 | import android.support.v4.app.FragmentStatePagerAdapter;
7 |
8 | /**
9 | * Original Code: http://stackoverflow.com/questions/12737222/viewpager-and-database
10 | */
11 | public abstract class CursorFragmentPagerAdapter extends FragmentStatePagerAdapter
12 | {
13 | protected Cursor mCursor;
14 |
15 | public CursorFragmentPagerAdapter(final FragmentManager fragmentManager, final Cursor cursor)
16 | {
17 | super(fragmentManager);
18 | this.mCursor = cursor;
19 | }
20 |
21 | @Override
22 | public Fragment getItem(final int position)
23 | {
24 | if (this.mCursor == null)
25 | {
26 | return null;
27 | }
28 |
29 | this.mCursor.moveToPosition(position);
30 | return this.getItem(this.mCursor);
31 | }
32 |
33 | public abstract Fragment getItem(final Cursor cursor);
34 |
35 | @Override
36 | public int getCount()
37 | {
38 | if (this.mCursor == null)
39 | {
40 | return 0;
41 | }
42 | return this.mCursor.getCount();
43 | }
44 |
45 | public void swapCursor(final Cursor cursor)
46 | {
47 | if (this.mCursor == cursor)
48 | {
49 | return;
50 | }
51 |
52 | this.mCursor = cursor;
53 | this.notifyDataSetChanged();
54 | }
55 |
56 | public Cursor getCursor()
57 | {
58 | return this.mCursor;
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/library/src/main/java/com/sage42/android/view/ui/CircularProgressBar.java:
--------------------------------------------------------------------------------
1 | package com.sage42.android.view.ui;
2 |
3 | import java.math.BigDecimal;
4 | import java.math.RoundingMode;
5 |
6 | import android.content.Context;
7 | import android.content.res.TypedArray;
8 | import android.graphics.Canvas;
9 | import android.graphics.Paint;
10 | import android.graphics.Paint.Align;
11 | import android.graphics.Paint.Style;
12 | import android.graphics.Rect;
13 | import android.graphics.RectF;
14 | import android.util.AttributeSet;
15 | import android.util.TypedValue;
16 | import android.view.View;
17 |
18 | import com.sage42.android.view.R;
19 |
20 | /**
21 | * Copyright (C) 2013- Sage 42 App Sdn Bhd
22 | *
23 | * Licensed under the Apache License, Version 2.0 (the "License");
24 | * you may not use this file except in compliance with the License.
25 | * You may obtain a copy of the License at
26 | *
27 | * http://www.apache.org/licenses/LICENSE-2.0
28 | *
29 | * Unless required by applicable law or agreed to in writing, software
30 | * distributed under the License is distributed on an "AS IS" BASIS,
31 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
32 | * See the License for the specific language governing permissions and
33 | * limitations under the License.
34 | *
35 | * @author Corey Scott (corey.scott@sage42.com)
36 | *
37 | */
38 | public class CircularProgressBar extends View
39 | {
40 | private static final int DEFAULT_MAX_VALUE = 100;
41 | private static final float ADJUST_FOR_12_OCLOCK = 270f;
42 |
43 | // properties for the background circle
44 | private final Paint mBgPaint;
45 |
46 | // properties for the progress circle
47 | private final Paint mProgressPaint;
48 |
49 | // text properties for the countdown text
50 | private boolean mShowText;
51 | private final Paint mTextPaint;
52 |
53 | // maximum number of points in the circle default is 100
54 | private int mMax;
55 |
56 | // current progress between 0 and mMax
57 | private int mProgress;
58 |
59 | // diameter (in dp) of the circle
60 | private float mDiameter;
61 |
62 | // margin between circle and edges (default is 4dp)
63 | // NOTE: you will need to include some margin to account for the stroke width, so min padding is strokeWidth/2
64 | private int mLayoutMargin;
65 |
66 | // area to draw the progress arc
67 | private RectF mArcBounds;
68 |
69 | // height taken to draw text with the current settings
70 | private Rect mTextBounds;
71 |
72 | public CircularProgressBar(final Context context, final AttributeSet attrs)
73 | {
74 | this(context, attrs, -1);
75 | }
76 |
77 | public CircularProgressBar(final Context context, final AttributeSet attrs, final int defStyle)
78 | {
79 | super(context, attrs, defStyle);
80 |
81 | // extract params (if provided)
82 | final TypedArray args = context.obtainStyledAttributes(attrs, R.styleable.circularProgressBar);
83 |
84 | final float defaultDiameter = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 64, this.getResources()
85 | .getDisplayMetrics());
86 | final float defaultStrokeWidth = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 3, this.getResources()
87 | .getDisplayMetrics());
88 | final float defaultMargin = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, this.getResources()
89 | .getDisplayMetrics());
90 | final float defaultTextSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 14, this.getResources()
91 | .getDisplayMetrics());
92 |
93 | try
94 | {
95 | final int bgColor = args.getColor(R.styleable.circularProgressBar_bgColor, R.color.black);
96 | final int bgStrokeWidth = args.getDimensionPixelSize(R.styleable.circularProgressBar_bgStrokeWidth,
97 | (int) defaultStrokeWidth);
98 |
99 | final int progressColor = args.getColor(R.styleable.circularProgressBar_progressColor, R.color.white);
100 | final int progressStrokeWidth = args.getDimensionPixelSize(
101 | R.styleable.circularProgressBar_progressStrokeWidth, (int) defaultStrokeWidth);
102 |
103 | this.mShowText = args.getBoolean(R.styleable.circularProgressBar_showText, false);
104 | final int textSize = args.getDimensionPixelSize(R.styleable.circularProgressBar_android_textSize,
105 | (int) defaultTextSize);
106 | final int textColor = args.getInt(R.styleable.circularProgressBar_android_textColor, R.color.white);
107 |
108 | this.mLayoutMargin = args.getDimensionPixelSize(R.styleable.circularProgressBar_android_layout_margin,
109 | (int) defaultMargin);
110 |
111 | this.mMax = args.getInt(R.styleable.circularProgressBar_max, DEFAULT_MAX_VALUE);
112 |
113 | this.mDiameter = args.getDimension(R.styleable.circularProgressBar_diameter, defaultDiameter);
114 |
115 | // create paint settings based on supplied args
116 | this.mBgPaint = new Paint();
117 | this.mBgPaint.setColor(bgColor);
118 | this.mBgPaint.setStyle(Style.STROKE);
119 | this.mBgPaint.setAntiAlias(true);
120 | this.mBgPaint.setStrokeWidth(bgStrokeWidth);
121 |
122 | this.mProgressPaint = new Paint();
123 | this.mProgressPaint.setColor(progressColor);
124 | this.mProgressPaint.setStyle(Style.STROKE);
125 | this.mProgressPaint.setAntiAlias(true);
126 | this.mProgressPaint.setStrokeWidth(progressStrokeWidth);
127 |
128 | this.mTextPaint = new Paint();
129 | this.mTextPaint.setColor(textColor);
130 | this.mTextPaint.setAntiAlias(true);
131 | this.mTextPaint.setStyle(Style.STROKE);
132 | this.mTextPaint.setTextAlign(Align.CENTER);
133 | this.mTextPaint.setTextSize(textSize);
134 | }
135 | finally
136 | {
137 | args.recycle();
138 | }
139 | }
140 |
141 | @Override
142 | protected void onDraw(final Canvas canvas)
143 | {
144 | if (this.mArcBounds == null)
145 | {
146 | // set view bounds for arc drawing
147 | this.mArcBounds = new RectF(this.mLayoutMargin, this.mLayoutMargin, this.mLayoutMargin + this.mDiameter,
148 | this.mLayoutMargin + this.mDiameter);
149 | }
150 |
151 | // draw bg circle in the center
152 | final float radius = this.mDiameter / 2;
153 | final float center = radius + this.mLayoutMargin;
154 | canvas.drawCircle(center, center, radius, this.mBgPaint);
155 |
156 | // draw any progress over the top
157 | // why is this BigDecimal crap even needed? java why?
158 | final BigDecimal percentage = BigDecimal.valueOf(this.mProgress).divide(BigDecimal.valueOf(this.mMax), 4,
159 | RoundingMode.HALF_DOWN);
160 | final BigDecimal sweepAngle = percentage.multiply(BigDecimal.valueOf(360));
161 |
162 | // bounds are same as the bg circle, so diameter width and height moved in by margin
163 | canvas.drawArc(this.mArcBounds, CircularProgressBar.ADJUST_FOR_12_OCLOCK, sweepAngle.floatValue(), false,
164 | this.mProgressPaint);
165 |
166 | if (this.mShowText)
167 | {
168 | if (this.mTextBounds == null)
169 | {
170 | // Reference: http://stackoverflow.com/questions/3654321/measuring-text-height-to-be-drawn-on-canvas-android
171 | // answer #2
172 | this.mTextBounds = new Rect();
173 | this.mTextPaint.getTextBounds("0", 0, 1, this.mTextBounds); //$NON-NLS-1$
174 | }
175 |
176 | // draw text in the center
177 | canvas.drawText(String.valueOf(this.mProgress), center, center + (this.mTextBounds.height() >> 1),
178 | this.mTextPaint);
179 | }
180 | }
181 |
182 | public void setProgress(final int progress)
183 | {
184 | this.mProgress = progress;
185 |
186 | // force redraw
187 | this.invalidate();
188 | }
189 |
190 | @Override
191 | protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec)
192 | {
193 | // size will always be diameter + margin on add sides
194 | final int size = (int) this.mDiameter + (this.mLayoutMargin * 2);
195 | this.setMeasuredDimension(size, size);
196 | }
197 |
198 | public void setMax(final int max)
199 | {
200 | this.mMax = max;
201 | }
202 |
203 | public void setBgColor(final int bgColor)
204 | {
205 | this.mBgPaint.setColor(bgColor);
206 | }
207 |
208 | public void setBgStrokeWidth(final int bgStrokeWidth)
209 | {
210 | this.mBgPaint.setStrokeWidth(bgStrokeWidth);
211 | }
212 |
213 | public void setProgressColor(final int progressColor)
214 | {
215 | this.mProgressPaint.setColor(progressColor);
216 | }
217 |
218 | public void setProgressStrokeWidth(final int progressStrokeWidth)
219 | {
220 | this.mProgressPaint.setStrokeWidth(progressStrokeWidth);
221 | }
222 |
223 | public void setShowText(final boolean showText)
224 | {
225 | this.mShowText = showText;
226 | }
227 |
228 | public void setTextSize(final int textSize)
229 | {
230 | this.mTextPaint.setTextSize(textSize);
231 | }
232 |
233 | public void setTextColor(final int textColor)
234 | {
235 | this.mTextPaint.setColor(textColor);
236 | }
237 |
238 | public void setDiameter(final float diameter)
239 | {
240 | this.mDiameter = diameter;
241 | }
242 |
243 | }
244 |
--------------------------------------------------------------------------------
/library/src/main/java/com/sage42/android/view/ui/ExpandAndShrinkCardView.java:
--------------------------------------------------------------------------------
1 | package com.sage42.android.view.ui;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.widget.RelativeLayout;
6 |
7 | import com.sage42.android.view.animations.ClickToOpenCloseLayout;
8 |
9 | public class ExpandAndShrinkCardView extends RelativeLayout
10 | {
11 | // unique index for this layout. Important for state preservations
12 | private long mUuid;
13 |
14 | private ClickToOpenCloseLayout mParentContainer;
15 |
16 | /**
17 | * Default constructor.
18 | *
19 | * @param context
20 | */
21 | public ExpandAndShrinkCardView(final Context context)
22 | {
23 | super(context);
24 | this.mUuid = 0;
25 | }
26 |
27 | /**
28 | * Default constructor.
29 | *
30 | * @param context
31 | * @param attrs
32 | */
33 | public ExpandAndShrinkCardView(final Context context, final AttributeSet attrs)
34 | {
35 | super(context, attrs);
36 | this.mUuid = 0;
37 | }
38 |
39 | /**
40 | * Default constructor.
41 | *
42 | * @param context
43 | * @param attrs
44 | * @param defStyle
45 | */
46 | public ExpandAndShrinkCardView(final Context context, final AttributeSet attrs, final int defStyle)
47 | {
48 | super(context, attrs, defStyle);
49 | this.mUuid = 0;
50 | }
51 |
52 | public long getUuid()
53 | {
54 | return this.mUuid;
55 | }
56 |
57 | public void setUuid(final long uuid)
58 | {
59 | this.mUuid = uuid;
60 | }
61 |
62 | public ClickToOpenCloseLayout getParentContainer()
63 | {
64 | return this.mParentContainer;
65 | }
66 |
67 | public void setParentContainer(final ClickToOpenCloseLayout parentContainer)
68 | {
69 | this.mParentContainer = parentContainer;
70 | }
71 |
72 | /**
73 | * Show/Hide display of this view.
74 | */
75 | public void toggleDisplay()
76 | {
77 | if (this.mParentContainer != null)
78 | {
79 | this.mParentContainer.toggleDisplay();
80 | }
81 | }
82 |
83 | }
84 |
--------------------------------------------------------------------------------
/library/src/main/java/com/sage42/android/view/ui/ExpandAndShrinkCardsListViewAdapter.java:
--------------------------------------------------------------------------------
1 | package com.sage42.android.view.ui;
2 |
3 | import java.util.HashMap;
4 |
5 | import android.content.Context;
6 | import android.database.Cursor;
7 | import android.support.v4.widget.CursorAdapter;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 |
11 | import com.sage42.android.view.animations.ClickToOpenCloseLayout;
12 | import com.sage42.android.view.animations.ClickToOpenCloseLayout.IClickToOpenCloseLayoutListener;
13 |
14 | public abstract class ExpandAndShrinkCardsListViewAdapter extends CursorAdapter implements
15 | IClickToOpenCloseLayoutListener
16 | {
17 | private final HashMap mListItemsState;
18 |
19 | public ExpandAndShrinkCardsListViewAdapter(final Context context, final Cursor cursor)
20 | {
21 | super(context, cursor, true);
22 | this.mListItemsState = new HashMap();
23 | }
24 |
25 | /*
26 | * (non-Javadoc)
27 | * @see android.support.v4.widget.CursorAdapter#bindView(android.view.View, android.content.Context,
28 | * android.database.Cursor)
29 | */
30 | @Override
31 | public final void bindView(final View view, final Context context, final Cursor cursor)
32 | {
33 | // Bind data first
34 | this.bindExpandAndShrinkView(view, context, cursor);
35 |
36 | //get the customview
37 | final View customView = this.setExpandAndSrinkView(view);
38 | if (customView instanceof ExpandAndShrinkCardView)
39 | {
40 | final ExpandAndShrinkCardView expandAndShrinkView = (ExpandAndShrinkCardView) customView;
41 | // Prepare view for reuse
42 | final ClickToOpenCloseLayout parentContainer = expandAndShrinkView.getParentContainer();
43 | if (parentContainer != null)
44 | {
45 | // Recalculate view properties
46 | parentContainer.setListener(this);
47 | parentContainer.onLayoutReuse(cursor.getPosition());
48 | }
49 | }
50 | }
51 |
52 | /*
53 | * (non-Javadoc)
54 | * @see android.support.v4.widget.CursorAdapter#newView(android.content.Context, android.database.Cursor,
55 | * android.view.ViewGroup)
56 | */
57 | @Override
58 | public final View newView(final Context context, final Cursor cursor, final ViewGroup parent)
59 | {
60 | // Get a new View from implementing class
61 | final View newView = this.newExpandAndShrinkView(context, cursor, parent);
62 |
63 | //Get click to open close layout from the view
64 | final ClickToOpenCloseLayout clickToOpenCloseLayout = this.setClickToOpenCloseLayout(newView);
65 |
66 | //Get ExpandAndShrinkCardView layout from the view
67 | final ExpandAndShrinkCardView customView = this.setExpandAndSrinkView(newView);
68 |
69 | //Set parent layout
70 | customView.setParentContainer(clickToOpenCloseLayout);
71 |
72 | // Get unique id
73 | final long uniqueId = cursor.getPosition();
74 |
75 | // Save the current view state in memory
76 | this.mListItemsState.put(uniqueId, ExpandAndShrinkLayoutStates.INITIAL);
77 | customView.setUuid(uniqueId);
78 | final ClickToOpenCloseLayout parentContainer = customView.getParentContainer();
79 | if (parentContainer != null)
80 | {
81 | customView.setUuid(uniqueId);
82 | parentContainer.setListener(this);
83 | }
84 |
85 | return newView;
86 | }
87 |
88 | @Override
89 | public void onLayoutStateChange(final long index, final ExpandAndShrinkLayoutStates newState)
90 | {
91 | // Check if the layout already have an existing state, if no, set to initial
92 | final ExpandAndShrinkLayoutStates currentState = this.mListItemsState.get(index);
93 |
94 | if (currentState != null && newState == ExpandAndShrinkLayoutStates.INITIAL)
95 | {
96 | // State Restoration, ignore change
97 | }
98 | else
99 | {
100 | // Remember this state transition
101 | this.mListItemsState.put(index, newState);
102 | }
103 | }
104 |
105 | @Override
106 | public ExpandAndShrinkLayoutStates getLayoutState(final long index)
107 | {
108 | final ExpandAndShrinkLayoutStates currentState = this.mListItemsState.get(index);
109 | if (currentState == null)
110 | {
111 | return ExpandAndShrinkLayoutStates.INVALID;
112 | }
113 |
114 | return currentState;
115 | }
116 |
117 | public abstract View newExpandAndShrinkView(final Context context, final Cursor cursor, final ViewGroup parent);
118 |
119 | public abstract ExpandAndShrinkCardView setExpandAndSrinkView(View v);
120 |
121 | public abstract ClickToOpenCloseLayout setClickToOpenCloseLayout(View v);
122 |
123 | public abstract void bindExpandAndShrinkView(final View view, final Context context, final Cursor cursor);
124 |
125 | }
126 |
--------------------------------------------------------------------------------
/library/src/main/java/com/sage42/android/view/ui/ExpandAndShrinkLayoutStates.java:
--------------------------------------------------------------------------------
1 | package com.sage42.android.view.ui;
2 |
3 | public enum ExpandAndShrinkLayoutStates
4 | {
5 | INITIAL, OPEN, CLOSE, INVALID;
6 | }
7 |
--------------------------------------------------------------------------------
/library/src/main/java/com/sage42/android/view/ui/SegmentedProgressBar.java:
--------------------------------------------------------------------------------
1 | package com.sage42.android.view.ui;
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.graphics.Paint.Style;
9 | import android.util.AttributeSet;
10 | import android.view.animation.LinearInterpolator;
11 | import android.widget.ProgressBar;
12 |
13 | import com.sage42.android.view.R;
14 |
15 | /**
16 | * Copyright (C) 2013- Sage 42 App Sdn Bhd
17 | *
18 | * Licensed under the Apache License, Version 2.0 (the "License");
19 | * you may not use this file except in compliance with the License.
20 | * You may obtain a copy of the License at
21 | *
22 | * http://www.apache.org/licenses/LICENSE-2.0
23 | *
24 | * Unless required by applicable law or agreed to in writing, software
25 | * distributed under the License is distributed on an "AS IS" BASIS,
26 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27 | * See the License for the specific language governing permissions and
28 | * limitations under the License.
29 | *
30 | * @author Corey Scott (corey.scott@sage42.com)
31 | *
32 | */
33 | /**
34 | * Draw a ProgressBar but instead of being solid make it "segmented". This class also supports adding a "gradient" to
35 | * the colors.
36 | */
37 | public class SegmentedProgressBar extends ProgressBar
38 | {
39 | private static final int DEFAULT_SEGMENT_COUNT = 40;
40 |
41 | // start of the color gradient (defaults to black)
42 | private final int mColorStartA;
43 | private final int mColorStartR;
44 | private final int mColorStartG;
45 | private final int mColorStartB;
46 |
47 | // end of the color gradient (defaults to startColor)
48 | private final int mColorEndA;
49 | private final int mColorEndR;
50 | private final int mColorEndG;
51 | private final int mColorEndB;
52 |
53 | // unfilled color gradient (defaults to gray)
54 | private final int mColorUnfilled;
55 |
56 | // interpolator used to calculate the color gradient (defaults to linear)
57 | private int mGradientInterpolatorResId;
58 |
59 | // number of visible segments to draw (default: 40)
60 | private int mSegmentCount;
61 |
62 | // paint used for drawing segments
63 | private Paint mPaintSegment;
64 |
65 | /**
66 | * Default constructor.
67 | *
68 | * @param context
69 | * @param attrs
70 | */
71 | public SegmentedProgressBar(final Context context, final AttributeSet attrs)
72 | {
73 | this(context, attrs, -1);
74 | }
75 |
76 | /**
77 | * Default constructor.
78 | *
79 | * @param context
80 | * @param attrs
81 | * @param defStyle
82 | */
83 | public SegmentedProgressBar(final Context context, final AttributeSet attrs, final int defStyle)
84 | {
85 | super(context, attrs, defStyle);
86 |
87 | // extract params (if provided)
88 | final TypedArray args = context.obtainStyledAttributes(attrs, R.styleable.segmentedProgressBar);
89 |
90 | try
91 | {
92 | // colors
93 | final int startColor = args.getColor(R.styleable.segmentedProgressBar_startColor, R.color.black);
94 | int endColor = args.getColor(R.styleable.segmentedProgressBar_endColor, -1);
95 | if (endColor == -1)
96 | {
97 | endColor = startColor;
98 | }
99 | final int unfilledColor = args.getColor(R.styleable.segmentedProgressBar_unfilledColor, R.color.gray);
100 |
101 | // interpolator
102 | this.mGradientInterpolatorResId = args.getResourceId(R.styleable.segmentedProgressBar_android_interpolator,
103 | -1);
104 | if (this.mGradientInterpolatorResId != -1)
105 | {
106 | this.setInterpolator(context, this.mGradientInterpolatorResId);
107 | }
108 | else
109 | {
110 | this.setInterpolator(new LinearInterpolator());
111 | }
112 |
113 | // other settings
114 | this.mSegmentCount = args.getInt(R.styleable.segmentedProgressBar_segmentCount,
115 | SegmentedProgressBar.DEFAULT_SEGMENT_COUNT);
116 |
117 | // create colors based on supplied args
118 | this.mColorStartA = Color.alpha(startColor);
119 | this.mColorStartR = Color.red(startColor);
120 | this.mColorStartG = Color.green(startColor);
121 | this.mColorStartB = Color.blue(startColor);
122 |
123 | this.mColorEndA = Color.alpha(endColor);
124 | this.mColorEndR = Color.red(endColor);
125 | this.mColorEndG = Color.green(endColor);
126 | this.mColorEndB = Color.blue(endColor);
127 |
128 | this.mColorUnfilled = Color.argb(Color.alpha(unfilledColor), Color.red(unfilledColor),
129 | Color.blue(unfilledColor), Color.green(unfilledColor));
130 |
131 | // init paints
132 | this.mPaintSegment = new Paint();
133 | this.mPaintSegment.setColor(startColor);
134 | this.mPaintSegment.setStyle(Style.FILL);
135 | this.mPaintSegment.setAntiAlias(true);
136 | }
137 | finally
138 | {
139 | args.recycle();
140 | }
141 | }
142 |
143 | @Override
144 | protected synchronized void onDraw(final Canvas canvas)
145 | {
146 | // retrieve the overall dimensions
147 | final int totalWidth = this.getWidth();
148 | final int segmentHeight = this.getHeight();
149 | final int top = this.getTop();
150 |
151 | // calculate the size of a "segment"
152 | // NOTE: there is no "invisible segment drawn after the last, hence the -1
153 | final int totalSegments = (this.mSegmentCount * 2) - 1;
154 | final double segmentWidth = totalWidth / (double) totalSegments;
155 |
156 | // calculate how much of the bar to fill
157 | final double progressPercentage = this.getProgress() / (double) this.getMax();
158 |
159 | // draw segments
160 | for (int currentSegment = 0; currentSegment < this.mSegmentCount; currentSegment++)
161 | {
162 | // calculate lateral position
163 | final double left = currentSegment * segmentWidth * 2;
164 |
165 | // get color for this segment
166 | final double position = currentSegment / (double) this.mSegmentCount;
167 | if (position < progressPercentage)
168 | {
169 | this.mPaintSegment.setColor(this.getColor(currentSegment));
170 | }
171 | else
172 | {
173 | this.mPaintSegment.setColor(this.mColorUnfilled);
174 | }
175 |
176 | // draw segment
177 | canvas.drawRect(Double.valueOf(left).floatValue(), Double.valueOf(top).floatValue(),
178 | Double.valueOf(left + segmentWidth).floatValue(), Double.valueOf(top + segmentHeight)
179 | .floatValue(), this.mPaintSegment);
180 | }
181 | }
182 |
183 | private int getColor(final int currentSegment)
184 | {
185 | final float percentage = this.getInterpolator().getInterpolation((float) currentSegment / this.mSegmentCount);
186 |
187 | final float alpha = ((this.mColorEndA - this.mColorStartA) * percentage) + this.mColorStartA;
188 | final float red = ((this.mColorEndR - this.mColorStartR) * percentage) + this.mColorStartR;
189 | final float green = ((this.mColorEndG - this.mColorStartG) * percentage) + this.mColorStartG;
190 | final float blue = ((this.mColorEndB - this.mColorStartB) * percentage) + this.mColorStartB;
191 |
192 | return Color.argb((int) alpha, (int) red, (int) green, (int) blue);
193 | }
194 | }
195 |
--------------------------------------------------------------------------------
/library/src/test/java/com/sage42/android/view/activities/MyTextViewTestActivity.java:
--------------------------------------------------------------------------------
1 | package com.sage42.android.view.activities;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 |
6 | import com.sage42.android.view.R;
7 |
8 | public class MyTextViewTestActivity extends Activity
9 | {
10 |
11 | @Override
12 | protected void onCreate(Bundle savedInstanceState)
13 | {
14 | super.onCreate(savedInstanceState);
15 |
16 | // init the layout
17 | this.setContentView(R.layout.test_mytextview_activity);
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/sample_apk/AndroidViewUtilsSamples.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sage42/AndroidViewUtils/65a6952963901adccb24210c47183d948f4e19eb/sample_apk/AndroidViewUtilsSamples.apk
--------------------------------------------------------------------------------
/samples/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
12 |
13 |
14 |
15 |
16 |
21 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
33 |
36 |
39 |
42 |
45 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/samples/LICENSE.txt:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "[]"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright [yyyy] [name of copyright owner]
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
203 |
--------------------------------------------------------------------------------
/samples/libs/android-support-v4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sage42/AndroidViewUtils/65a6952963901adccb24210c47183d948f4e19eb/samples/libs/android-support-v4.jar
--------------------------------------------------------------------------------
/samples/lint.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/samples/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # To enable ProGuard in your project, edit project.properties
2 | # to define the proguard.config property as described in that file.
3 | #
4 | # Add project specific ProGuard rules here.
5 | # By default, the flags in this file are appended to flags specified
6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 | # You can edit the include path and order by changing the ProGuard
8 | # include property in project.properties.
9 | #
10 | # For more details, see
11 | # http://developer.android.com/guide/developing/tools/proguard.html
12 |
13 | # Add any project specific keep options here:
14 |
15 | # If your project uses WebView with JS, uncomment the following
16 | # and specify the fully qualified class name to the JavaScript interface
17 | # class:
18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 | # public *;
20 | #}
21 |
--------------------------------------------------------------------------------
/samples/project.properties.sample:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=android-17
15 | android.library=false
16 |
--------------------------------------------------------------------------------
/samples/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sage42/AndroidViewUtils/65a6952963901adccb24210c47183d948f4e19eb/samples/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/samples/res/layout/circular_progress_bar_activity.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
15 |
16 |
24 |
25 |
30 |
31 |
45 |
46 |
62 |
63 |
77 |
78 |
79 |
87 |
88 |
93 |
94 |
108 |
109 |
125 |
126 |
140 |
141 |
142 |
150 |
151 |
156 |
157 |
171 |
172 |
188 |
189 |
203 |
204 |
205 |
206 |
207 |
--------------------------------------------------------------------------------
/samples/res/layout/custom_fonts_activity.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
15 |
16 |
24 |
25 |
34 |
35 |
43 |
44 |
53 |
54 |
62 |
63 |
72 |
73 |
81 |
82 |
91 |
92 |
100 |
101 |
110 |
111 |
119 |
120 |
129 |
130 |
138 |
139 |
148 |
149 |
157 |
158 |
167 |
168 |
176 |
177 |
186 |
187 |
195 |
196 |
204 |
205 |
206 |
--------------------------------------------------------------------------------
/samples/res/layout/marquee_text_activity.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
15 |
16 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/samples/res/layout/sample_expand_shrink_card_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
18 |
19 |
27 |
28 |
33 |
34 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/samples/res/layout/segmented_progress_bar_activity.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
15 |
16 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/samples/res/layout/swipe_enabled_activity.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
15 |
16 |
17 |
21 |
22 |
--------------------------------------------------------------------------------
/samples/res/raw/baroque_script.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sage42/AndroidViewUtils/65a6952963901adccb24210c47183d948f4e19eb/samples/res/raw/baroque_script.ttf
--------------------------------------------------------------------------------
/samples/res/raw/kberry.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sage42/AndroidViewUtils/65a6952963901adccb24210c47183d948f4e19eb/samples/res/raw/kberry.ttf
--------------------------------------------------------------------------------
/samples/res/values-v11/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/samples/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #00aeef
4 |
5 |
6 |
--------------------------------------------------------------------------------
/samples/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 12dp
5 | 2dp
6 |
7 |
8 |
--------------------------------------------------------------------------------
/samples/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Sage 42 View Utils
5 | Sage 42 View Utils
6 | Circular Progress Bar
7 | Segmented Progress Bar
8 | Custom Font View Elements
9 | Marquee/Scrolling TextView
10 | Expand/Shrink ListView
11 | Counting down
12 | Counting up
13 | Counting up/down without text
14 | SwipeEnabledActivity
15 | Swipe left detected
16 | Swipe right detected
17 | Roboto Thin
18 | Roboto Thin Italic
19 | Roboto Light
20 | Roboto Light Italic
21 | Roboto Regular
22 | Roboto Regular Italic
23 | Roboto Medium
24 | Roboto Medium Italic
25 | Roboto Bold
26 | Roboto Bold Italic
27 | Roboto Black
28 | Roboto Black Italic
29 | Roboto Condensed
30 | Roboto Condensed Italic
31 | Roboto Condensed Light
32 | Roboto Condensed Light Italic
33 | Roboto Bold Condensed
34 | Roboto Bold Condensed Italic
35 | Baroque Script from www.1001freefonts.com
36 | Katy Berry from www.1001freefonts.com
37 | The quick brown fox jumped over the lazy dog.
38 |
39 |
40 | - Waalwijk
41 | - Lambersart
42 | - Duque de Caxias
43 | - Fallais
44 | - Stewart
45 | - Denderbelle
46 | - Khanpur
47 | - Golspie
48 | - Portsmouth
49 | - San Massimo
50 | - Saint-Pierre
51 | - Ceppaloni
52 | - Okotoks
53 | - Hafizabad
54 | - Husum
55 | - Cranbrook
56 | - Piringen
57 | - Bear
58 | - Maple Creek
59 | - Falciano del Massico
60 |
61 |
62 |
63 | - in, cursus et, eros. Proin ultrices. Duis volutpat nunc sit amet metus. Aliquam erat volutpat. Nulla facilisis. Suspendisse commodo tincidunt nibh. Phasellus nulla.
64 | - purus sapien, gravida non, sollicitudin a, malesuada id, erat. Etiam vestibulum massa
65 | - malesuada augue ut lacus. Nulla tincidunt, neque vitae semper egestas, urna justo
66 | - interdum. Curabitur dictum. Phasellus in felis. Nulla tempor augue ac
67 | - congue, elit sed consequat auctor, nunc nulla vulputate dui, nec tempus mauris erat eget ipsum. Suspendisse sagittis. Nullam vitae diam.
68 | - lorem semper auctor. Mauris vel turpis. Aliquam adipiscing lobortis risus. In mi pede, nonummy ut, molestie
69 | - Phasellus nulla. Integer vulputate, risus a ultricies adipiscing, enim mi tempor lorem, eget mollis lectus pede et risus. Quisque libero lacus, varius
70 | - libero at auctor ullamcorper, nisl arcu iaculis enim, sit amet ornare lectus
71 | - iaculis quis, pede. Praesent eu dui. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aenean eget magna. Suspendisse tristique neque venenatis
72 | - ligula. Aenean euismod mauris eu elit. Nulla facilisi. Sed neque. Sed eget lacus.
73 | - massa lobortis ultrices. Vivamus rhoncus. Donec est. Nunc ullamcorper, velit in aliquet lobortis, nisi nibh lacinia orci,
74 | - semper. Nam tempor diam dictum sapien. Aenean massa. Integer vitae nibh. Donec est mauris, rhoncus id, mollis nec, cursus
75 | - consequat auctor, nunc nulla vulputate dui, nec tempus mauris erat eget ipsum. Suspendisse sagittis. Nullam vitae diam. Proin
76 | - Curabitur sed tortor. Integer aliquam adipiscing lacus. Ut nec urna et arcu imperdiet ullamcorper.
77 | - justo faucibus lectus, a sollicitudin orci sem eget massa. Suspendisse eleifend. Cras sed leo. Cras vehicula aliquet libero. Integer
78 | - enim consequat purus. Maecenas libero est, congue a, aliquet vel, vulputate eu,
79 | - Duis dignissim tempor arcu. Vestibulum ut eros non enim commodo hendrerit. Donec porttitor tellus non magna. Nam ligula elit,
80 | - nulla. Integer vulputate, risus a ultricies adipiscing, enim mi tempor lorem, eget mollis lectus pede et risus.
81 | - ligula eu enim. Etiam imperdiet dictum magna. Ut tincidunt orci quis lectus. Nullam suscipit, est ac facilisis facilisis, magna tellus faucibus leo,
82 | - fermentum metus. Aenean sed pede nec ante blandit viverra. Donec
83 |
84 |
85 |
--------------------------------------------------------------------------------
/samples/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
14 |
15 |
16 |
19 |
20 |
--------------------------------------------------------------------------------
/samples/src/main/java/com/sage42/android/view_samples/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.sage42.android.view_samples;
2 |
3 | import android.app.ListActivity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.view.View;
7 | import android.widget.ArrayAdapter;
8 | import android.widget.ListView;
9 |
10 | import com.sage42.android.view_samples.custom_fonts.CustomFontsActivity;
11 | import com.sage42.android.view_samples.marquee.MarqueeTextActivity;
12 | import com.sage42.android.view_samples.ui.CircularProgressBarActivity;
13 | import com.sage42.android.view_samples.ui.ExpandShrinkListViewActivity;
14 | import com.sage42.android.view_samples.ui.SegmentedProgressBarActivity;
15 |
16 | /**
17 | * Copyright (C) 2013- Sage 42 App Sdn Bhd
18 | *
19 | * Licensed under the Apache License, Version 2.0 (the "License");
20 | * you may not use this file except in compliance with the License.
21 | * You may obtain a copy of the License at
22 | *
23 | * http://www.apache.org/licenses/LICENSE-2.0
24 | *
25 | * Unless required by applicable law or agreed to in writing, software
26 | * distributed under the License is distributed on an "AS IS" BASIS,
27 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28 | * See the License for the specific language governing permissions and
29 | * limitations under the License.
30 | *
31 | * @author Corey Scott (corey.scott@sage42.com)
32 | *
33 | */
34 | public class MainActivity extends ListActivity
35 | {
36 | // constants to map menu positions to something more readable
37 | private static final int MENU_CIRCULAR_PROGRESS_BAR = 0;
38 | private static final int MENU_SEGMENTED_PROGRESS_BAR = 1;
39 | private static final int MENU_CUSTOM_FONT_VIEWS = 2;
40 | private static final int MENU_MARQUEE_TEXT = 3;
41 | private static final int MENU_EXPAND_AND_SHRINK_LIST = 4;
42 |
43 | @Override
44 | protected void onCreate(final Bundle savedInstanceState)
45 | {
46 | super.onCreate(savedInstanceState);
47 |
48 | // populate the "menu" list
49 | final String[] values = new String[]
50 | { this.getString(R.string.menu_circular_progress_bar), this.getString(R.string.menu_segmented_progress_bar),
51 | this.getString(R.string.menu_custom_font_views), this.getString(R.string.menu_marquee_text),
52 | this.getString(R.string.menu_expand_shrink_list) };
53 | final ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, values);
54 | this.setListAdapter(adapter);
55 | }
56 |
57 | @Override
58 | protected void onListItemClick(final ListView listView, final View view, final int position, final long id)
59 | {
60 | switch (position)
61 | {
62 | case MENU_CIRCULAR_PROGRESS_BAR:
63 | this.startActivity(new Intent(this, CircularProgressBarActivity.class));
64 | return;
65 |
66 | case MENU_SEGMENTED_PROGRESS_BAR:
67 | this.startActivity(new Intent(this, SegmentedProgressBarActivity.class));
68 | return;
69 |
70 | case MENU_CUSTOM_FONT_VIEWS:
71 | this.startActivity(new Intent(this, CustomFontsActivity.class));
72 | return;
73 |
74 | case MENU_MARQUEE_TEXT:
75 | this.startActivity(new Intent(this, MarqueeTextActivity.class));
76 | return;
77 |
78 | case MENU_EXPAND_AND_SHRINK_LIST:
79 | this.startActivity(new Intent(this, ExpandShrinkListViewActivity.class));
80 | return;
81 |
82 | default:
83 | // do nothing
84 | break;
85 | }
86 |
87 | super.onListItemClick(listView, view, position, id);
88 | }
89 |
90 | }
91 |
--------------------------------------------------------------------------------
/samples/src/main/java/com/sage42/android/view_samples/SwipeEnabledActivity.java:
--------------------------------------------------------------------------------
1 | package com.sage42.android.view_samples;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.view.GestureDetector;
6 | import android.view.MotionEvent;
7 | import android.view.View;
8 | import android.widget.Toast;
9 |
10 | import com.sage42.android.view.gestures.MyGestureDetector;
11 | import com.sage42.android.view.gestures.MyGestureDetector.ISwipeCallbacks;
12 | import com.sage42.android.view.gestures.MyGestureDetector.SwipeDirection;
13 |
14 | public class SwipeEnabledActivity extends Activity implements ISwipeCallbacks
15 | {
16 | // Gesture Detection
17 | private View mGestureOverlay;
18 | private GestureDetector mGestureDetector;
19 | private View.OnTouchListener mGestureListener;
20 |
21 | @Override
22 | protected void onCreate(final Bundle savedInstanceState)
23 | {
24 | super.onCreate(savedInstanceState);
25 |
26 | // wire up the layout
27 | this.setContentView(R.layout.swipe_enabled_activity);
28 |
29 | // Gesture detection
30 | this.mGestureOverlay = this.findViewById(R.id.gesture_overlay);
31 | this.mGestureDetector = new GestureDetector(this, new MyGestureDetector(this));
32 | this.mGestureListener = new View.OnTouchListener()
33 | {
34 | @SuppressWarnings("synthetic-access")
35 | @Override
36 | public boolean onTouch(final View v, final MotionEvent event)
37 | {
38 | return SwipeEnabledActivity.this.mGestureDetector.onTouchEvent(event);
39 | }
40 | };
41 | // wire gestures to the gesture detection view
42 | this.mGestureOverlay.setOnTouchListener(this.mGestureListener);
43 | }
44 |
45 | @Override
46 | public void onSwipe(final SwipeDirection direction)
47 | {
48 | switch (direction)
49 | {
50 | case LEFT:
51 | Toast.makeText(this, R.string.swipe_left, Toast.LENGTH_SHORT).show();
52 | break;
53 |
54 | case RIGHT:
55 | Toast.makeText(this, R.string.swipe_right, Toast.LENGTH_SHORT).show();
56 | break;
57 |
58 | default:
59 | break;
60 | }
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/samples/src/main/java/com/sage42/android/view_samples/custom_fonts/CustomFontsActivity.java:
--------------------------------------------------------------------------------
1 | package com.sage42.android.view_samples.custom_fonts;
2 |
3 | import android.annotation.TargetApi;
4 | import android.app.Activity;
5 | import android.os.Build;
6 | import android.os.Bundle;
7 | import android.view.MenuItem;
8 |
9 | import com.sage42.android.view_samples.R;
10 |
11 | public class CustomFontsActivity extends Activity
12 | {
13 | @Override
14 | protected void onCreate(final Bundle savedInstanceState)
15 | {
16 | super.onCreate(savedInstanceState);
17 |
18 | // needed to ensure the custom fonts can be found/loaded
19 | MyFontManager.loadMyFonts(this);
20 |
21 | // wire up the layout
22 | this.setContentView(R.layout.custom_fonts_activity);
23 |
24 | // enable the back btn on newer phones
25 | if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB)
26 | {
27 | this.enableUpButton();
28 | }
29 | }
30 |
31 | @TargetApi(Build.VERSION_CODES.HONEYCOMB)
32 | private void enableUpButton()
33 | {
34 | this.getActionBar().setDisplayHomeAsUpEnabled(true);
35 | }
36 |
37 | @Override
38 | public boolean onOptionsItemSelected(final MenuItem item)
39 | {
40 | switch (item.getItemId())
41 | {
42 | case android.R.id.home:
43 | // Respond to the action bar's Up/Home button
44 | this.finish();
45 | return true;
46 |
47 | default:
48 | return super.onOptionsItemSelected(item);
49 | }
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/samples/src/main/java/com/sage42/android/view_samples/custom_fonts/MyFontManager.java:
--------------------------------------------------------------------------------
1 | package com.sage42.android.view_samples.custom_fonts;
2 |
3 | import android.content.Context;
4 |
5 | import com.sage42.android.view.fonts.FontManager;
6 | import com.sage42.android.view_samples.R;
7 |
8 | public class MyFontManager extends FontManager
9 | {
10 | protected MyFontManager()
11 | {
12 | super();
13 | }
14 |
15 | // These strings will be the values needed in the layout.xml files
16 | private static final String BAROQUE_SCRIPT = "baroqueScript"; //$NON-NLS-1$
17 | private static final String KATY_BERRY = "katyBerry"; //$NON-NLS-1$
18 |
19 | public static void loadMyFonts(final Context context)
20 | {
21 | // add more fonts here
22 | FontManager.getInstance().addCustomFont(context, BAROQUE_SCRIPT, R.raw.baroque_script, null);
23 | FontManager.getInstance().addCustomFont(context, KATY_BERRY, R.raw.kberry, null);
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/samples/src/main/java/com/sage42/android/view_samples/marquee/MarqueeTextActivity.java:
--------------------------------------------------------------------------------
1 | package com.sage42.android.view_samples.marquee;
2 |
3 | import android.annotation.TargetApi;
4 | import android.app.Activity;
5 | import android.os.Build;
6 | import android.os.Bundle;
7 | import android.view.MenuItem;
8 |
9 | import com.sage42.android.view_samples.R;
10 |
11 | public class MarqueeTextActivity extends Activity
12 | {
13 | @Override
14 | protected void onCreate(final Bundle savedInstanceState)
15 | {
16 | super.onCreate(savedInstanceState);
17 |
18 | // wire up the layout
19 | this.setContentView(R.layout.marquee_text_activity);
20 |
21 | // enable the back btn on newer phones
22 | if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB)
23 | {
24 | this.enableUpButton();
25 | }
26 | }
27 |
28 | @TargetApi(Build.VERSION_CODES.HONEYCOMB)
29 | private void enableUpButton()
30 | {
31 | this.getActionBar().setDisplayHomeAsUpEnabled(true);
32 | }
33 |
34 | @Override
35 | public boolean onOptionsItemSelected(final MenuItem item)
36 | {
37 | switch (item.getItemId())
38 | {
39 | case android.R.id.home:
40 | // Respond to the action bar's Up/Home button
41 | this.finish();
42 | return true;
43 |
44 | default:
45 | return super.onOptionsItemSelected(item);
46 | }
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/samples/src/main/java/com/sage42/android/view_samples/ui/CircularProgressBarActivity.java:
--------------------------------------------------------------------------------
1 | package com.sage42.android.view_samples.ui;
2 |
3 | import android.annotation.TargetApi;
4 | import android.app.Activity;
5 | import android.os.Build;
6 | import android.os.Bundle;
7 | import android.os.CountDownTimer;
8 | import android.view.MenuItem;
9 | import android.view.View;
10 |
11 | import com.sage42.android.view.ui.CircularProgressBar;
12 | import com.sage42.android.view_samples.R;
13 |
14 | /**
15 | * Copyright (C) 2013- Sage 42 App Sdn Bhd
16 | *
17 | * Licensed under the Apache License, Version 2.0 (the "License");
18 | * you may not use this file except in compliance with the License.
19 | * You may obtain a copy of the License at
20 | *
21 | * http://www.apache.org/licenses/LICENSE-2.0
22 | *
23 | * Unless required by applicable law or agreed to in writing, software
24 | * distributed under the License is distributed on an "AS IS" BASIS,
25 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26 | * See the License for the specific language governing permissions and
27 | * limitations under the License.
28 | *
29 | * @author Corey Scott (corey.scott@sage42.com)
30 | *
31 | */
32 | public class CircularProgressBarActivity extends Activity
33 | {
34 | private static final int ONE_SECOND_IN_MS = 1000;
35 |
36 | // view elements
37 | private CircularProgressBar mCountdownBar1;
38 | private CircularProgressBar mCountdownBar2;
39 | private CircularProgressBar mCountdownBar3;
40 |
41 | private CircularProgressBar mCountUpBar1;
42 | private CircularProgressBar mCountUpBar2;
43 | private CircularProgressBar mCountUpBar3;
44 |
45 | private CircularProgressBar mCounterNoText1;
46 | private CircularProgressBar mCounterNoText2;
47 | private CircularProgressBar mCounterNoText3;
48 |
49 | // some countdown timers to provide a little action
50 | private CountDownTimer mTimerCountDown;
51 | private CountDownTimer mTimerCountUp;
52 |
53 | @Override
54 | protected void onCreate(final Bundle savedInstanceState)
55 | {
56 | super.onCreate(savedInstanceState);
57 |
58 | // wire up the layout
59 | this.setContentView(R.layout.circular_progress_bar_activity);
60 |
61 | // wire up the ui elements
62 | this.mCountdownBar1 = (CircularProgressBar) this.findViewById(R.id.countdown_bar1);
63 | this.mCountdownBar2 = (CircularProgressBar) this.findViewById(R.id.countdown_bar2);
64 | this.mCountdownBar3 = (CircularProgressBar) this.findViewById(R.id.countdown_bar3);
65 |
66 | this.mCountUpBar1 = (CircularProgressBar) this.findViewById(R.id.countup_bar1);
67 | this.mCountUpBar2 = (CircularProgressBar) this.findViewById(R.id.countup_bar2);
68 | this.mCountUpBar3 = (CircularProgressBar) this.findViewById(R.id.countup_bar3);
69 |
70 | this.mCounterNoText1 = (CircularProgressBar) this.findViewById(R.id.counter_no_text1);
71 | this.mCounterNoText2 = (CircularProgressBar) this.findViewById(R.id.counter_no_text2);
72 | this.mCounterNoText3 = (CircularProgressBar) this.findViewById(R.id.counter_no_text3);
73 |
74 | // enable the back btn on newer phones
75 | if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB)
76 | {
77 | this.enableUpButton();
78 | }
79 | }
80 |
81 | @TargetApi(Build.VERSION_CODES.HONEYCOMB)
82 | private void enableUpButton()
83 | {
84 | this.getActionBar().setDisplayHomeAsUpEnabled(true);
85 | }
86 |
87 | @Override
88 | @SuppressWarnings("synthetic-access")
89 | protected void onResume()
90 | {
91 | super.onResume();
92 |
93 | // start some timers so that things move
94 | this.mTimerCountDown = new CountDownTimer(30 * ONE_SECOND_IN_MS, ONE_SECOND_IN_MS)
95 | {
96 | @Override
97 | public void onTick(final long millisUntilFinished)
98 | {
99 | final int secondsRemaining = (int) (millisUntilFinished / ONE_SECOND_IN_MS);
100 | CircularProgressBarActivity.this.mCountdownBar1.setProgress(secondsRemaining);
101 | CircularProgressBarActivity.this.mCountdownBar2.setProgress(secondsRemaining);
102 | CircularProgressBarActivity.this.mCountdownBar3.setProgress(secondsRemaining);
103 |
104 | CircularProgressBarActivity.this.mCounterNoText1.setProgress(secondsRemaining);
105 | CircularProgressBarActivity.this.mCounterNoText3.setProgress(secondsRemaining);
106 | }
107 |
108 | @Override
109 | public void onFinish()
110 | {
111 | CircularProgressBarActivity.this.mCountdownBar1.setProgress(0);
112 | CircularProgressBarActivity.this.mCountdownBar2.setProgress(0);
113 | CircularProgressBarActivity.this.mCountdownBar3.setProgress(0);
114 |
115 | CircularProgressBarActivity.this.mCounterNoText1.setProgress(0);
116 | CircularProgressBarActivity.this.mCounterNoText3.setProgress(0);
117 |
118 | // make it disappear (because we can)
119 | CircularProgressBarActivity.this.mCountdownBar3.setVisibility(View.INVISIBLE);
120 | }
121 | }.start();
122 |
123 | this.mTimerCountUp = new CountDownTimer(30 * ONE_SECOND_IN_MS, ONE_SECOND_IN_MS)
124 | {
125 | @Override
126 | public void onTick(final long millisUntilFinished)
127 | {
128 | final int secondsElapsed = 30 - ((int) (millisUntilFinished / ONE_SECOND_IN_MS));
129 | CircularProgressBarActivity.this.mCountUpBar1.setProgress(secondsElapsed);
130 | CircularProgressBarActivity.this.mCountUpBar2.setProgress(secondsElapsed);
131 | CircularProgressBarActivity.this.mCountUpBar3.setProgress(secondsElapsed);
132 |
133 | CircularProgressBarActivity.this.mCounterNoText2.setProgress(secondsElapsed);
134 | }
135 |
136 | @Override
137 | public void onFinish()
138 | {
139 | CircularProgressBarActivity.this.mCountUpBar1.setProgress(30);
140 | CircularProgressBarActivity.this.mCountUpBar2.setProgress(30);
141 | CircularProgressBarActivity.this.mCountUpBar3.setProgress(30);
142 |
143 | CircularProgressBarActivity.this.mCounterNoText2.setProgress(30);
144 |
145 | // make it disappear (because we can)
146 | CircularProgressBarActivity.this.mCountUpBar3.setVisibility(View.INVISIBLE);
147 | }
148 | }.start();
149 | }
150 |
151 | @Override
152 | protected void onPause()
153 | {
154 | super.onPause();
155 |
156 | // stop any running timers
157 | // there are needed to be clear and be sure that the timers dont cause exceptions when this activity is not in focus
158 | if (this.mTimerCountDown != null)
159 | {
160 | this.mTimerCountDown.cancel();
161 | }
162 | if (this.mTimerCountUp != null)
163 | {
164 | this.mTimerCountUp.cancel();
165 | }
166 | }
167 |
168 | @Override
169 | public boolean onOptionsItemSelected(final MenuItem item)
170 | {
171 | switch (item.getItemId())
172 | {
173 | case android.R.id.home:
174 | // Respond to the action bar's Up/Home button
175 | this.finish();
176 | return true;
177 |
178 | default:
179 | return super.onOptionsItemSelected(item);
180 | }
181 | }
182 | }
183 |
--------------------------------------------------------------------------------
/samples/src/main/java/com/sage42/android/view_samples/ui/ExpandShrinkListViewActivity.java:
--------------------------------------------------------------------------------
1 | package com.sage42.android.view_samples.ui;
2 |
3 | import android.annotation.TargetApi;
4 | import android.app.ListActivity;
5 | import android.database.Cursor;
6 | import android.database.MatrixCursor;
7 | import android.os.Build;
8 | import android.os.Bundle;
9 | import android.view.MenuItem;
10 | import android.view.View;
11 | import android.widget.ListView;
12 |
13 | import com.sage42.android.view_samples.R;
14 |
15 | public class ExpandShrinkListViewActivity extends ListActivity
16 | {
17 | public static final String COLUMN_NAME_TITLE = "title"; //$NON-NLS-1$
18 | public static final String COLUMN_NAME_TEXT = "text"; //$NON-NLS-1$
19 |
20 | @Override
21 | protected void onCreate(final Bundle savedInstanceState)
22 | {
23 | super.onCreate(savedInstanceState);
24 |
25 | // enable the back btn on newer phones
26 | if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB)
27 | {
28 | this.enableUpButton();
29 | }
30 |
31 | // Setup adapter
32 | final SampleExpandShrinkListAdapter adapter = new SampleExpandShrinkListAdapter(this, this.getHardCodedCursor());
33 | this.setListAdapter(adapter);
34 | }
35 |
36 | @TargetApi(Build.VERSION_CODES.HONEYCOMB)
37 | private void enableUpButton()
38 | {
39 | this.getActionBar().setDisplayHomeAsUpEnabled(true);
40 | }
41 |
42 | @Override
43 | public boolean onOptionsItemSelected(final MenuItem item)
44 | {
45 | switch (item.getItemId())
46 | {
47 | case android.R.id.home:
48 | // Respond to the action bar's Up/Home button
49 | this.finish();
50 | return true;
51 |
52 | default:
53 | return super.onOptionsItemSelected(item);
54 | }
55 | }
56 |
57 | @Override
58 | protected void onResume()
59 | {
60 | super.onResume();
61 | }
62 |
63 | @Override
64 | protected void onListItemClick(final ListView listView, final View view, final int position, final long id)
65 | {
66 | if (view instanceof SampleExpandAndShrinkCard)
67 | {
68 | final SampleExpandAndShrinkCard card = (SampleExpandAndShrinkCard) view;
69 | card.toggleDisplay();
70 | }
71 | }
72 |
73 | private Cursor getHardCodedCursor()
74 | {
75 | final String[] columns = new String[]
76 | { "_id", ExpandShrinkListViewActivity.COLUMN_NAME_TITLE, ExpandShrinkListViewActivity.COLUMN_NAME_TEXT }; //$NON-NLS-1$
77 |
78 | final MatrixCursor matrixCursor = new MatrixCursor(columns);
79 | this.startManagingCursor(matrixCursor);
80 |
81 | // Get String resources
82 | final String[] titles = this.getResources().getStringArray(R.array.expand_shrink_list_view_title);
83 | final String[] texts = this.getResources().getStringArray(R.array.expand_shrink_list_view_text);
84 |
85 | if (titles.length == texts.length)
86 | {
87 | for (int i = 0; i < titles.length; i++)
88 | {
89 | matrixCursor.addRow(new Object[]
90 | { i, titles[i], texts[i] });
91 | }
92 | }
93 |
94 | return matrixCursor;
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/samples/src/main/java/com/sage42/android/view_samples/ui/SampleExpandAndShrinkCard.java:
--------------------------------------------------------------------------------
1 | package com.sage42.android.view_samples.ui;
2 |
3 | import android.content.Context;
4 | import android.database.Cursor;
5 | import android.util.AttributeSet;
6 |
7 | import com.sage42.android.view.ui.ExpandAndShrinkCardView;
8 | import com.sage42.android.view_samples.ui.SampleExpandShrinkListAdapter.ViewHolder;
9 |
10 | public class SampleExpandAndShrinkCard extends ExpandAndShrinkCardView
11 | {
12 |
13 | /**
14 | * Default constructor.
15 | *
16 | * @param context
17 | */
18 | public SampleExpandAndShrinkCard(final Context context)
19 | {
20 | super(context);
21 | }
22 |
23 | /**
24 | * Default constructor.
25 | *
26 | * @param context
27 | * @param attrs
28 | */
29 | public SampleExpandAndShrinkCard(final Context context, final AttributeSet attrs)
30 | {
31 | super(context, attrs);
32 | }
33 |
34 | /**
35 | * Default constructor.
36 | *
37 | * @param context
38 | * @param attrs
39 | * @param defStyle
40 | */
41 | public SampleExpandAndShrinkCard(final Context context, final AttributeSet attrs, final int defStyle)
42 | {
43 | super(context, attrs, defStyle);
44 | }
45 |
46 | /*
47 | * Bind the sample title and text into our card view
48 | */
49 | public void bind(final Cursor cursor)
50 | {
51 | final Object tag = this.getTag();
52 | if (tag != null && tag instanceof ViewHolder)
53 | {
54 | final ViewHolder viewHolder = (ViewHolder) tag;
55 |
56 | // Get Title and Text
57 | if (cursor != null)
58 | {
59 | final String title = cursor.getString(cursor
60 | .getColumnIndexOrThrow(ExpandShrinkListViewActivity.COLUMN_NAME_TITLE));
61 | final String text = cursor.getString(cursor
62 | .getColumnIndexOrThrow(ExpandShrinkListViewActivity.COLUMN_NAME_TEXT));
63 | viewHolder.title.setText(title);
64 | viewHolder.text.setText(text);
65 | }
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/samples/src/main/java/com/sage42/android/view_samples/ui/SampleExpandShrinkListAdapter.java:
--------------------------------------------------------------------------------
1 | package com.sage42.android.view_samples.ui;
2 |
3 | import android.content.Context;
4 | import android.database.Cursor;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.TextView;
9 |
10 | import com.sage42.android.view.animations.ClickToOpenCloseLayout;
11 | import com.sage42.android.view.ui.ExpandAndShrinkCardView;
12 | import com.sage42.android.view.ui.ExpandAndShrinkCardsListViewAdapter;
13 | import com.sage42.android.view_samples.R;
14 |
15 | public class SampleExpandShrinkListAdapter extends ExpandAndShrinkCardsListViewAdapter
16 | {
17 |
18 | public SampleExpandShrinkListAdapter(final Context context, final Cursor cursor)
19 | {
20 | super(context, cursor);
21 | }
22 |
23 | static class ViewHolder
24 | {
25 | public TextView title;
26 | public TextView text;
27 | }
28 |
29 | @Override
30 | public SampleExpandAndShrinkCard newExpandAndShrinkView(final Context context, final Cursor cursor,
31 | final ViewGroup parent)
32 | {
33 | final LayoutInflater inflater = LayoutInflater.from(this.mContext);
34 | final SampleExpandAndShrinkCard rootView = (SampleExpandAndShrinkCard) inflater.inflate(
35 | R.layout.sample_expand_shrink_card_view, parent, false);
36 |
37 | // Setup ViewHolder
38 | final ViewHolder viewHolder = new ViewHolder();
39 | viewHolder.title = (TextView) rootView.findViewById(R.id.card_title);
40 | viewHolder.text = (TextView) rootView.findViewById(R.id.card_text);
41 | rootView.setTag(viewHolder);
42 |
43 | return rootView;
44 | }
45 |
46 | @Override
47 | public void bindExpandAndShrinkView(final View view, final Context arg1, final Cursor cursor)
48 | {
49 |
50 | if (view instanceof SampleExpandAndShrinkCard)
51 | {
52 | final SampleExpandAndShrinkCard sampleCard = (SampleExpandAndShrinkCard) view;
53 | sampleCard.bind(cursor);
54 | }
55 | return;
56 |
57 | }
58 |
59 | @Override
60 | public ClickToOpenCloseLayout setClickToOpenCloseLayout(final View view)
61 | {
62 |
63 | // return ClickToOpenCloseLayout from your layout by using findViewById
64 | return ((ClickToOpenCloseLayout) view.findViewById(R.id.main_container));
65 | }
66 |
67 | @Override
68 | public ExpandAndShrinkCardView setExpandAndSrinkView(final View view)
69 | {
70 |
71 | // return ExpandAndShrinkCardView from your layout by using findViewById
72 | return ((ExpandAndShrinkCardView) view.findViewById(R.id.root_view));
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/samples/src/main/java/com/sage42/android/view_samples/ui/SegmentedProgressBarActivity.java:
--------------------------------------------------------------------------------
1 | package com.sage42.android.view_samples.ui;
2 |
3 | import android.annotation.TargetApi;
4 | import android.app.Activity;
5 | import android.os.Build;
6 | import android.os.Bundle;
7 | import android.os.CountDownTimer;
8 | import android.view.MenuItem;
9 |
10 | import com.sage42.android.view.ui.SegmentedProgressBar;
11 | import com.sage42.android.view_samples.R;
12 |
13 | /**
14 | * Copyright (C) 2013- Sage 42 App Sdn Bhd
15 | *
16 | * Licensed under the Apache License, Version 2.0 (the "License");
17 | * you may not use this file except in compliance with the License.
18 | * You may obtain a copy of the License at
19 | *
20 | * http://www.apache.org/licenses/LICENSE-2.0
21 | *
22 | * Unless required by applicable law or agreed to in writing, software
23 | * distributed under the License is distributed on an "AS IS" BASIS,
24 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25 | * See the License for the specific language governing permissions and
26 | * limitations under the License.
27 | *
28 | * @author Corey Scott (corey.scott@sage42.com)
29 | *
30 | */
31 | public class SegmentedProgressBarActivity extends Activity
32 | {
33 | private static final int TOTAL_TIME_IN_SEC = 20;
34 |
35 | private static final int ONE_SECOND_IN_MS = 1000;
36 |
37 | // view elements
38 | private SegmentedProgressBar mProgressBar1;
39 |
40 | // a countdown timer to provide a little action
41 | private CountDownTimer mTimerCountUp;
42 |
43 | @Override
44 | protected void onCreate(final Bundle savedInstanceState)
45 | {
46 | super.onCreate(savedInstanceState);
47 |
48 | // wire up the layout
49 | this.setContentView(R.layout.segmented_progress_bar_activity);
50 |
51 | // wire up the ui elements
52 | this.mProgressBar1 = (SegmentedProgressBar) this.findViewById(R.id.segmented_bar1);
53 |
54 | // enable the back btn on newer phones
55 | if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB)
56 | {
57 | this.enableUpButton();
58 | }
59 | }
60 |
61 | @TargetApi(Build.VERSION_CODES.HONEYCOMB)
62 | private void enableUpButton()
63 | {
64 | this.getActionBar().setDisplayHomeAsUpEnabled(true);
65 | }
66 |
67 | @Override
68 | public boolean onOptionsItemSelected(final MenuItem item)
69 | {
70 | switch (item.getItemId())
71 | {
72 | case android.R.id.home:
73 | // Respond to the action bar's Up/Home button
74 | this.finish();
75 | return true;
76 |
77 | default:
78 | return super.onOptionsItemSelected(item);
79 | }
80 | }
81 |
82 | @Override
83 | @SuppressWarnings("synthetic-access")
84 | protected void onResume()
85 | {
86 | super.onResume();
87 |
88 | // start some timers so that things move
89 | this.mTimerCountUp = new CountDownTimer(TOTAL_TIME_IN_SEC * ONE_SECOND_IN_MS, ONE_SECOND_IN_MS)
90 | {
91 | @Override
92 | public void onTick(final long millisUntilFinished)
93 | {
94 | final double progress = ((TOTAL_TIME_IN_SEC - (millisUntilFinished / (double) ONE_SECOND_IN_MS)) / TOTAL_TIME_IN_SEC) * 100;
95 | SegmentedProgressBarActivity.this.mProgressBar1.setProgress((int) progress);
96 | }
97 |
98 | @Override
99 | public void onFinish()
100 | {
101 | SegmentedProgressBarActivity.this.mProgressBar1
102 | .setProgress(SegmentedProgressBarActivity.this.mProgressBar1.getMax());
103 | }
104 | }.start();
105 | }
106 |
107 | @Override
108 | protected void onPause()
109 | {
110 | super.onPause();
111 |
112 | // stop any running timers
113 | // there are needed to be clear and be sure that the timers don't cause exceptions when this activity is not in focus
114 | if (this.mTimerCountUp != null)
115 | {
116 | this.mTimerCountUp.cancel();
117 | }
118 | }
119 |
120 | }
121 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':library'
2 |
--------------------------------------------------------------------------------
/website/images/circ_progress_bar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sage42/AndroidViewUtils/65a6952963901adccb24210c47183d948f4e19eb/website/images/circ_progress_bar.png
--------------------------------------------------------------------------------
/website/images/custom_fonts.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sage42/AndroidViewUtils/65a6952963901adccb24210c47183d948f4e19eb/website/images/custom_fonts.png
--------------------------------------------------------------------------------
/website/images/marquee_textview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sage42/AndroidViewUtils/65a6952963901adccb24210c47183d948f4e19eb/website/images/marquee_textview.png
--------------------------------------------------------------------------------