├── .gitignore ├── LICENSE ├── MIGRATION.md ├── README.md ├── app ├── .gitignore ├── build.gradle ├── lint.xml ├── proguard-rules.pro ├── release │ └── output.json └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── danielstone │ │ └── materialaboutlibrarydemo │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── ic_launcher-web.png │ ├── java │ │ └── com │ │ │ └── danielstone │ │ │ └── materialaboutlibrarydemo │ │ │ ├── Application.java │ │ │ ├── Demo.java │ │ │ ├── ExampleMaterialAboutActivity.java │ │ │ ├── ExampleMaterialAboutFragment.java │ │ │ ├── ExampleMaterialAboutFragmentActivity.java │ │ │ ├── ExampleMaterialAboutLicenseActivity.java │ │ │ ├── MainActivity.java │ │ │ └── custom │ │ │ ├── MyCustomItem.java │ │ │ └── MyViewTypeManager.java │ ├── res │ │ ├── layout │ │ │ ├── activity_example_material_about_fragment.xml │ │ │ ├── activity_main.xml │ │ │ ├── content_example_material_about_fragment.xml │ │ │ ├── content_main.xml │ │ │ ├── custom_item.xml │ │ │ ├── mal_material_about_action_item_overridefornoicons.xml │ │ │ └── mal_material_about_list_card_overrideforlistlayout.xml │ │ ├── menu │ │ │ ├── menu_example_material_about.xml │ │ │ └── menu_main.xml │ │ ├── mipmap-anydpi-v26 │ │ │ ├── ic_launcher.xml │ │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ ├── ic_launcher_foreground.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ ├── ic_launcher_foreground.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ ├── ic_launcher_foreground.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ ├── ic_launcher_foreground.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ ├── ic_launcher_foreground.png │ │ │ └── ic_launcher_round.png │ │ ├── values │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ ├── ic_launcher_background.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ └── xml │ │ │ └── backup_descriptor.xml │ └── web_hi_res_512.png │ └── test │ └── java │ └── com │ └── danielstone │ └── materialaboutlibrarydemo │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── library ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── danielstone │ │ └── materialaboutlibrary │ │ ├── ConvenienceBuilder.java │ │ ├── MaterialAboutActivity.java │ │ ├── MaterialAboutFragment.java │ │ ├── adapters │ │ ├── MaterialAboutItemAdapter.java │ │ └── MaterialAboutListAdapter.java │ │ ├── holders │ │ └── MaterialAboutItemViewHolder.java │ │ ├── items │ │ ├── MaterialAboutActionItem.java │ │ ├── MaterialAboutItem.java │ │ ├── MaterialAboutItemOnClickAction.java │ │ └── MaterialAboutTitleItem.java │ │ ├── model │ │ ├── MaterialAboutCard.java │ │ └── MaterialAboutList.java │ │ └── util │ │ ├── DefaultViewTypeManager.java │ │ ├── OpenSourceLicense.java │ │ └── ViewTypeManager.java │ └── res │ ├── color │ └── mal_stroke_color.xml │ ├── layout │ ├── mal_material_about_action_item.xml │ ├── mal_material_about_content.xml │ ├── mal_material_about_list_card.xml │ └── mal_material_about_title_item.xml │ ├── values-cs │ └── strings.xml │ ├── values-de │ └── strings.xml │ ├── values-es │ └── strings.xml │ ├── values-uk │ └── strings.xml │ └── values │ ├── attrs.xml │ ├── colors.xml │ ├── dimens.xml │ ├── open_source_licenses.xml │ ├── strings.xml │ └── styles.xml ├── screenshots ├── 1.png ├── 2.png └── 3.png └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows thumbnail db 2 | Thumbs.db 3 | 4 | # OSX files 5 | .DS_Store 6 | 7 | # built application files 8 | *.apk 9 | *.ap_ 10 | 11 | # files for the dex VM 12 | *.dex 13 | 14 | # Java class files 15 | *.class 16 | 17 | # generated files 18 | bin/ 19 | gen/ 20 | build/ 21 | 22 | # Local configuration file (sdk path, etc) 23 | local.properties 24 | 25 | # Eclipse project files 26 | .classpath 27 | .project 28 | 29 | # Android Studio 30 | .idea 31 | .gradle 32 | /*/local.properties 33 | /*/out 34 | /*/*/build 35 | build 36 | /*/*/production 37 | *.iml 38 | *.iws 39 | *.ipr 40 | *~ 41 | *.swp -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /MIGRATION.md: -------------------------------------------------------------------------------- 1 | # Migration Guide 2 | 3 | ### Release 3.2.0 4 | 5 | * RecycledViewPool is now used to improve performance in longer lists 6 | 7 | * Change back to old style of card with elevation and no outline with `.outline(false)` on your card builder. 8 | 9 | ### Release 3.1.0 10 | 11 | * New layout shouldn't cause any issues. 12 | 13 | * Themes no longer need to be extending a Mal prefixed theme - use MaterialComponents themes as in the following example. 14 | 15 | * Layout no longer includes a toolbar - use a theme which includes one: 16 | 17 | ```xml 18 | 24 | ``` 25 | 26 | * Custom card backgrounds can be defined as so: 27 | 28 | ```xml 29 | 41 | ``` 42 | 43 | * You no longer need to define colours for your icons - let the library handle this, or set a custom colour with `colorOnSurface` attribute in your theme. 44 | 45 | 46 | 47 | ### Release 2.3.0 48 | 49 | * Changed design of layout, check old layouts -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # material-about-library 2 | 3 | [![Release][101]][102] ![Downloads](https://jitpack.io/v/daniel-stoneuk/material-about-library/month.svg) [![GitHub license](https://img.shields.io/badge/license-Apache%202-blue.svg)](https://raw.githubusercontent.com/daniel-stoneuk/material-about-library/master/LICENSE) [![GitHub issues](https://img.shields.io/github/issues/daniel-stoneuk/material-about-library.svg)](https://github.com/daniel-stoneuk/material-about-library/issues) 4 | 5 | Makes it easy to create a beautiful about screen for your app. Generates an `Activity` or `Fragment`. 6 | 7 | Idea from here: [Heinrich Reimer's open-source-library-request-manager][6] 8 | 9 | Design inspired by [Phonograph](https://github.com/kabouzeid/Phonograph) 10 | 11 | If you use this library in your app, please let me know and I'll add it to the list. 12 | 13 | ## Demo 14 | 15 | Get it on Google Play 16 | 17 | ## Screenshots 18 | 19 | | Light | Dark | Custom Cardview Background | 20 | | ------------------------------ | ------------------------------ | ------------------------------ | 21 | | ![Demo App](screenshots/1.png) | ![Demo App](screenshots/2.png) | ![Demo App](screenshots/3.png) | 22 | 23 | ## Features 24 | 25 | - Material design 26 | - Modular backend 27 | - Easy to implement 28 | - Simple but intuitive API 29 | - Dynamic item support 30 | 31 | ## Dependency 32 | 33 | _material-about-library_ is available on [**jitpack.io**][1]. 34 | 35 | **Gradle dependency:** 36 | 37 | ```gradle 38 | allprojects { 39 | repositories { 40 | maven { url 'https://jitpack.io' } 41 | } 42 | } 43 | ``` 44 | 45 | ```gradle 46 | dependencies { 47 | implementation 'com.github.daniel-stoneuk:material-about-library:3.1.2' 48 | } 49 | ``` 50 | 51 | Help test `3.2.0` with shared views between adapters (may cause crashes): 52 | 53 | ```gradle 54 | dependencies { 55 | implementation 'com.github.daniel-stoneuk:material-about-library:3.2.0-rc01' 56 | } 57 | ``` 58 | 59 | ## Migration 60 | 61 | View the migration guide [here](/MIGRATION.md) 62 | 63 | ## Setup 64 | 65 | ### Activity 66 | 67 | Your `Activity` must extend [`MaterialAboutActivity`][materialaboutactivityjava] and be in your _AndroidManifest.xml_: 68 | 69 | ```java 70 | public class ExampleMaterialAboutActivity extends MaterialAboutActivity { 71 | 72 | @Override 73 | @NonNull 74 | protected MaterialAboutList getMaterialAboutList(@NonNull Context context) { 75 | return new MaterialAboutList.Builder() 76 | .build(); // This creates an empty screen, add cards with .addCard() 77 | } 78 | 79 | @Override 80 | protected CharSequence getActivityTitle() { 81 | return getString(R.string.mal_title_about); 82 | } 83 | 84 | } 85 | ``` 86 | 87 | Ensure that the theme extends a `MaterialComponents` theme, and apply primary & secondary colours: 88 | 89 | ```xml 90 | 91 | 92 | 94 | 95 | 96 | ``` 97 | 98 | ```xml 99 | 103 | ``` 104 | 105 | ### Fragment 106 | 107 | Your `Fragment` must extend [`MaterialAboutFragment`][materialaboutfragmentjava]. 108 | 109 | ```java 110 | public class ExampleMaterialAboutFragment extends MaterialAboutFragment { 111 | 112 | @Override 113 | protected MaterialAboutList getMaterialAboutList(final Context activityContext) { 114 | return new MaterialAboutList.Builder() 115 | .build(); // This creates an empty screen, add cards with .addCard() 116 | } 117 | 118 | } 119 | ``` 120 | 121 | Theming will follow the activity theme. 122 | 123 | ### Add Cards: 124 | 125 | Start building a "card" using [`MaterialAboutCard.Builder()`][8] 126 | 127 | ```java 128 | public class ExampleMaterialAboutActivity extends MaterialAboutActivity { 129 | 130 | @Override 131 | @NonNull 132 | protected MaterialAboutList getMaterialAboutList(@NonNull Context context) { 133 | MaterialAboutCard card = new MaterialAboutCard.Builder() 134 | // Configure card here 135 | .build(); 136 | 137 | return new MaterialAboutList.Builder() 138 | .addCard(card) 139 | .build(); 140 | } 141 | } 142 | ``` 143 | 144 | Give the card a title by calling `.title()` on the `MaterialAboutCard.Builder` 145 | 146 | ```java 147 | MaterialAboutCard card = new MaterialAboutCard.Builder() 148 | .title("Author") 149 | .build(); 150 | ``` 151 | 152 | 153 | Enable elevation and disable the outline to get a more classic design by calling `.outline(false)` on the `MaterialAboutCard.Builder` 154 | 155 | ```java 156 | MaterialAboutCard card = new MaterialAboutCard.Builder() 157 | .outline(false) 158 | .build(); 159 | ``` 160 | 161 | ### Add Items to a card: 162 | 163 | There are currently two types of items you can add to a card - [`MaterialAboutTitleItem`][9] and [`MaterialAboutActionItem`][10]. Other types of items are planned, for example "person" items which feature buttons to showcase a single person. Feel free to submit a PR or Issue for more item ideas. 164 | 165 | - `MaterialAboutActionItem`: Standard item with text, icon and optional subtext. 166 | - `MaterialAboutTitleItem`: Larger item with large icon (e.g. app icon) and larger text. 167 | 168 | [`MaterialAboutTitleItem`][9] is created with [`MaterialAboutTitleItem.Builder()`][9] and lets you specify **text** and an **icon**. 169 | 170 | ```java 171 | MaterialAboutCard.Builder cardBuilder = new MaterialAboutCard.Builder(); 172 | cardBuilder.addItem(new MaterialAboutTitleItem.Builder() 173 | .text("Material About Library") 174 | .icon(R.mipmap.ic_launcher) 175 | .build()); 176 | ``` 177 | 178 | [`MaterialAboutActionItem`][10] is created with [`MaterialAboutActionItem.Builder()`][10] and lets you specify **text**, **sub-text**, an **icon** and an **OnClickAction**. 179 | 180 | ```java 181 | cardBuilder.addItem(new MaterialAboutActionItem.Builder() 182 | .text("Version") 183 | .subText("1.0.0") 184 | .icon(R.drawable.ic_about_info) 185 | .setOnClickAction(new MaterialAboutActionItem.OnClickAction() { 186 | @Override 187 | public void onClick() { 188 | Toast.makeText(ExampleMaterialAboutActivity.this, "Version Tapped", Toast.LENGTH_SHORT) 189 | .show(); 190 | } 191 | }) 192 | .build()); 193 | ``` 194 | 195 | ### Return the list: 196 | 197 | Create a [`MaterialAboutList`][11] using [`MaterialAboutList.Builder()`][11], passing in the cards you would like to display. 198 | 199 | ```java 200 | MaterialAboutCard card = new MaterialAboutCard.Builder() 201 | .title("Hey! I'm a card") 202 | .build(); 203 | 204 | return new MaterialAboutList.Builder() 205 | .addCard(card) 206 | .build(); 207 | ``` 208 | 209 | Check out a working example in [`Demo.java`][3]. 210 | 211 | **Tip:** You can either use _Strings_ / _Drawables_ or _Resources_ when creating `MaterialAboutItem`'s 212 | 213 | **Tip:** Use [Android-Iconics][iconics] for icons. "Android-Iconics - Use any icon font, or vector (.svg) as drawable in your application." 214 | 215 | **Tip:** Use [ConvenienceBuilder][conveniencebuilderjava] to easily create items or OnClickActions. 216 | 217 | **Tip:** Customise text colour and card colour in your styles. Example below: 218 | 219 | ```xml 220 | 229 | ``` 230 | 231 | ### Custom Adapters: 232 | It is possible to replace the contents of a card with a custom adapter. If you do this, then none of the items associated with the card will be displayed. Check out the demo app, in which use [LicenseAdapter](https://github.com/yshrsmz/LicenseAdapter) (hence the INTERNET permission). 233 | 234 | ```java 235 | MaterialAboutCard.Builder customAdapterCardBuilder = new MaterialAboutCard.Builder(); 236 | // Create list of libraries 237 | List libraries = new ArrayList<>(); 238 | 239 | // Add libraries that are hosted on GitHub with an Apache v2 license. 240 | libraries.add(Licenses.fromGitHubApacheV2("yshrsmz/LicenseAdapter")); 241 | libraries.add(Licenses.fromGitHubApacheV2("daniel-stoneuk/material-about-library")); 242 | 243 | customAdapterCardBuilder.title("Custom Adapter (License Adapter)"); 244 | customAdapterCardBuilder.customAdapter(new LicenseAdapter(libraries)); 245 | }); 246 | ``` 247 | 248 | 249 | ### Dynamic items: 250 | It's possible to create dynamic items that either change on tap (or when any other event occurs). There are two examples in the sample application. Simply change the items in the list variable and then call `refreshMaterialAboutList()`. DiffUtil calculates the changes to animate in the RecyclerView. 251 | 252 | ```java 253 | final MaterialAboutActionItem item = new MaterialAboutActionItem.Builder() 254 | .text("Dynamic UI") 255 | .subText(subText) 256 | .icon(new IconicsDrawable(c) 257 | .icon(CommunityMaterial.Icon.cmd_refresh) 258 | .color(ContextCompat.getColor(c, R.color.mal_color_icon_dark_theme) 259 | ).sizeDp(18)) 260 | .build(); 261 | item.setOnClickAction(new MaterialAboutItemOnClickAction() { 262 | @Override 263 | public void onClick() { 264 | item.setSubText("Random number: " + ((int) (Math.random() * 10))); 265 | refreshMaterialAboutList(); 266 | } 267 | }); 268 | ``` 269 | 270 | ### Custom card and Action layout 271 | To get a layout that is similar to the 6th screenshot above simply override the files `mal_material_about_action_item` and `mal_material_about_list_card` by creating new layout resources with the same filename. See [here](https://github.com/daniel-stoneuk/material-about-library/tree/master/app/src/main/res/layout). 272 | 273 | ## Contributors 274 | 275 | - Daniel Stone ([@daniel-stoneuk](https://github.com/daniel-stoneuk)) 276 | - Robert Pösel ([@Robyer](https://github.com/Robyer)) 277 | - Jonas Uekötter ([@ueman](https://github.com/ueman)) 278 | - Rainer Lang ([@Rainer-Lang](https://github.com/rainer-lang)) 279 | - Sebastian Guillen ([@code-schreiber](https://github.com/code-schreiber)) 280 | - and [others](https://github.com/daniel-stoneuk/material-about-library/graphs/contributors) 281 | 282 | ## Apps using this library 283 | 284 | - [Monitor for EnergyHive & Engage][5] 285 | - [Crafting Assistant NMS](https://play.google.com/store/apps/details?id=biemann.android.craftingnms) 286 | - [ComicsDB Client](https://play.google.com/store/apps/details?id=cz.kutner.comicsdbclient.comicsdbclient), code available on [GitHub](https://github.com/tukak/comicsdbclient) 287 | - [Android About Box](https://github.com/eggheadgames/android-about-box) (library) - an opinionated About Box for Android 288 | - [Skin Widget for Minecraft](https://play.google.com/store/apps/details?id=com.rabross.android.minecraftskinwidget) 289 | - [FastHub for GitHub](https://play.google.com/store/apps/details?id=com.fastaccess.github) 290 | 291 | ## License 292 | 293 | ``` 294 | Copyright 2016-2020 Daniel Stone 295 | 296 | Licensed under the Apache License, Version 2.0 (the "License"); 297 | you may not use this file except in compliance with the License. 298 | You may obtain a copy of the License at 299 | 300 | http://www.apache.org/licenses/LICENSE-2.0 301 | 302 | Unless required by applicable law or agreed to in writing, software 303 | distributed under the License is distributed on an "AS IS" BASIS, 304 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 305 | See the License for the specific language governing permissions and 306 | limitations under the License. 307 | ``` 308 | 309 | [1]: https://jitpack.io/#daniel-stoneuk/material-about-library 310 | [2]: http://i.imgur.com/xXWDmLb.png 311 | [3]: https://github.com/daniel-stoneuk/material-about-library/blob/master/app/src/main/java/com/danielstone/materialaboutlibrarydemo/Demo.java 312 | [4]: http://i.imgur.com/HEm08Ax.png 313 | [5]: https://play.google.com/store/apps/details?id=com.danielstone.energyhive 314 | [6]: https://github.com/HeinrichReimer/open-source-library-request-manager/issues/3 315 | [8]: https://github.com/daniel-stoneuk/material-about-library/blob/master/library/src/main/java/com/danielstone/materialaboutlibrary/model/MaterialAboutCard.java 316 | [9]: https://github.com/daniel-stoneuk/material-about-library/blob/master/library/src/main/java/com/danielstone/materialaboutlibrary/model/MaterialAboutTitleItem.java 317 | [10]: https://github.com/daniel-stoneuk/material-about-library/blob/master/library/src/main/java/com/danielstone/materialaboutlibrary/model/MaterialAboutActionItem.java 318 | [11]: https://github.com/daniel-stoneuk/material-about-library/blob/master/library/src/main/java/com/danielstone/materialaboutlibrary/model/MaterialAboutList.java 319 | [101]: https://jitpack.io/v/daniel-stoneuk/material-about-library.svg 320 | [102]: https://jitpack.io/#daniel-stoneuk/material-about-library 321 | [conveniencebuilderjava]: https://github.com/daniel-stoneuk/material-about-library/blob/master/library/src/main/java/com/danielstone/materialaboutlibrary/ConvenienceBuilder.java 322 | [iconics]: https://github.com/mikepenz/Android-Iconics 323 | [materialaboutactivityjava]: https://github.com/daniel-stoneuk/material-about-library/blob/master/library/src/main/java/com/danielstone/materialaboutlibrary/MaterialAboutActivity.java 324 | [materialaboutfragmentjava]: https://github.com/daniel-stoneuk/material-about-library/blob/master/app/src/main/java/com/danielstone/materialaboutlibrarydemo/ExampleMaterialAboutFragment.java 325 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | def versionMajor = 3 4 | def versionMinor = 1 5 | def versionPatch = 2 6 | def versionBuild = 0 // bump for dogfood builds, public betas, etc. 7 | 8 | android { 9 | compileSdkVersion rootProject.ext.compileSdkVersion 10 | 11 | defaultConfig { 12 | applicationId "com.danielstone.materialaboutlibrarydemo" 13 | minSdkVersion 15 14 | targetSdkVersion rootProject.ext.targetSdkVersion 15 | versionCode versionMajor * 10000 + versionMinor * 1000 + versionPatch * 100 + versionBuild 16 | versionName "${versionMajor}.${versionMinor}" + (versionPatch == 0 ? "" : ".${versionPatch}") 17 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 18 | } 19 | buildTypes { 20 | release { 21 | minifyEnabled false 22 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 23 | } 24 | } 25 | } 26 | 27 | dependencies { 28 | implementation fileTree(dir: 'libs', include: ['*.jar']) 29 | androidTestImplementation('androidx.test.espresso:espresso-core:3.3.0-alpha04', { 30 | exclude group: 'com.android.support', module: 'support-annotations' 31 | }) 32 | 33 | implementation project(':library') 34 | implementation "androidx.appcompat:appcompat:$appCompatVersion" 35 | implementation "com.google.android.material:material:$materialVersion" 36 | implementation "com.mikepenz:iconics-core:2.9.5@aar" 37 | implementation 'com.mikepenz:community-material-typeface:2.0.46.1@aar' 38 | implementation 'net.yslibrary.licenseadapter:licenseadapter:3.0.0' 39 | 40 | testImplementation 'junit:junit:4.13' 41 | } 42 | -------------------------------------------------------------------------------- /app/lint.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/danielstone/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /app/release/output.json: -------------------------------------------------------------------------------- 1 | [{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":30000,"versionName":"3.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release","dirName":""},"path":"app-release.apk","properties":{}}] -------------------------------------------------------------------------------- /app/src/androidTest/java/com/danielstone/materialaboutlibrarydemo/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.danielstone.materialaboutlibrarydemo; 2 | 3 | import android.content.Context; 4 | import androidx.test.InstrumentationRegistry; 5 | import androidx.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.danielstone.materialaboutlibrarydemo", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 17 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 30 | 33 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /app/src/main/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daniel-stoneuk/material-about-library/f02ffaa20926f049cb902043f95d372a2f03d10c/app/src/main/ic_launcher-web.png -------------------------------------------------------------------------------- /app/src/main/java/com/danielstone/materialaboutlibrarydemo/Application.java: -------------------------------------------------------------------------------- 1 | package com.danielstone.materialaboutlibrarydemo; 2 | 3 | 4 | public class Application extends android.app.Application { 5 | 6 | @Override public void onCreate() { 7 | super.onCreate(); 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /app/src/main/java/com/danielstone/materialaboutlibrarydemo/Demo.java: -------------------------------------------------------------------------------- 1 | package com.danielstone.materialaboutlibrarydemo; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.graphics.Color; 6 | import android.net.Uri; 7 | 8 | import androidx.core.content.ContextCompat; 9 | 10 | import com.danielstone.materialaboutlibrary.ConvenienceBuilder; 11 | import com.danielstone.materialaboutlibrary.items.MaterialAboutActionItem; 12 | import com.danielstone.materialaboutlibrary.items.MaterialAboutItemOnClickAction; 13 | import com.danielstone.materialaboutlibrary.items.MaterialAboutTitleItem; 14 | import com.danielstone.materialaboutlibrary.model.MaterialAboutCard; 15 | import com.danielstone.materialaboutlibrary.model.MaterialAboutList; 16 | import com.danielstone.materialaboutlibrary.util.OpenSourceLicense; 17 | import com.mikepenz.community_material_typeface_library.CommunityMaterial; 18 | import com.mikepenz.iconics.IconicsDrawable; 19 | 20 | public class Demo { 21 | 22 | public static MaterialAboutList createMaterialAboutList(final Context c, final int theme) { 23 | MaterialAboutCard.Builder appCardBuilder = new MaterialAboutCard.Builder(); 24 | 25 | // Add items to card 26 | 27 | appCardBuilder.addItem(new MaterialAboutTitleItem.Builder() 28 | .text("Material About Library") 29 | .desc("© 2020 Daniel Stone") 30 | .icon(R.mipmap.ic_launcher) 31 | .build()); 32 | 33 | appCardBuilder.addItem(ConvenienceBuilder.createVersionActionItem(c, 34 | new IconicsDrawable(c) 35 | .icon(CommunityMaterial.Icon.cmd_information_outline) 36 | .sizeDp(18), 37 | "Version", 38 | false)); 39 | 40 | appCardBuilder.addItem(new MaterialAboutActionItem.Builder() 41 | .text("Changelog") 42 | .icon(new IconicsDrawable(c) 43 | .icon(CommunityMaterial.Icon.cmd_history) 44 | .sizeDp(18)) 45 | .setOnClickAction(ConvenienceBuilder.createWebViewDialogOnClickAction(c, "Releases", "https://github.com/daniel-stoneuk/material-about-library/releases", true, false)) 46 | .build()); 47 | 48 | appCardBuilder.addItem(new MaterialAboutActionItem.Builder() 49 | .text("Licenses") 50 | .icon(new IconicsDrawable(c) 51 | .icon(CommunityMaterial.Icon.cmd_book) 52 | .sizeDp(18)) 53 | .setOnClickAction(new MaterialAboutItemOnClickAction() { 54 | @Override 55 | public void onClick() { 56 | Intent intent = new Intent(c, ExampleMaterialAboutLicenseActivity.class); 57 | intent.putExtra(ExampleMaterialAboutActivity.THEME_EXTRA, theme); 58 | c.startActivity(intent); 59 | } 60 | }) 61 | .build()); 62 | 63 | MaterialAboutCard.Builder authorCardBuilder = new MaterialAboutCard.Builder(); 64 | authorCardBuilder.title("Author"); 65 | // authorCardBuilder.titleColor(ContextCompat.getColor(c, R.color.colorAccent)); 66 | 67 | authorCardBuilder.addItem(new MaterialAboutActionItem.Builder() 68 | .text("Daniel Stone") 69 | .subText("United Kingdom") 70 | .icon(new IconicsDrawable(c) 71 | .icon(CommunityMaterial.Icon.cmd_account) 72 | .sizeDp(18)) 73 | .build()); 74 | 75 | authorCardBuilder.addItem(new MaterialAboutActionItem.Builder() 76 | .text("Fork on GitHub") 77 | .icon(new IconicsDrawable(c) 78 | .icon(CommunityMaterial.Icon.cmd_github_circle) 79 | .sizeDp(18)) 80 | .setOnClickAction(ConvenienceBuilder.createWebsiteOnClickAction(c, Uri.parse("https://github.com/daniel-stoneuk"))) 81 | .build()); 82 | 83 | MaterialAboutCard.Builder convenienceCardBuilder = new MaterialAboutCard.Builder(); 84 | 85 | convenienceCardBuilder.title("Convenience Builder"); 86 | 87 | convenienceCardBuilder.addItem(ConvenienceBuilder.createVersionActionItem(c, 88 | new IconicsDrawable(c) 89 | .icon(CommunityMaterial.Icon.cmd_information_outline) 90 | .sizeDp(18), 91 | "Version", 92 | false)); 93 | 94 | convenienceCardBuilder.addItem(ConvenienceBuilder.createWebsiteActionItem(c, 95 | new IconicsDrawable(c) 96 | .icon(CommunityMaterial.Icon.cmd_earth) 97 | .sizeDp(18), 98 | "Visit Website", 99 | true, 100 | Uri.parse("http://danstone.uk"))); 101 | 102 | convenienceCardBuilder.addItem(ConvenienceBuilder.createRateActionItem(c, 103 | new IconicsDrawable(c) 104 | .icon(CommunityMaterial.Icon.cmd_star) 105 | .sizeDp(18), 106 | "Rate this app", 107 | null 108 | )); 109 | 110 | convenienceCardBuilder.addItem(ConvenienceBuilder.createEmailItem(c, 111 | new IconicsDrawable(c) 112 | .icon(CommunityMaterial.Icon.cmd_email) 113 | .sizeDp(18), 114 | "Send an email", 115 | true, 116 | "apps@danstone.uk", 117 | "Question concerning MaterialAboutLibrary")); 118 | 119 | convenienceCardBuilder.addItem(ConvenienceBuilder.createPhoneItem(c, 120 | new IconicsDrawable(c) 121 | .icon(CommunityMaterial.Icon.cmd_phone) 122 | .sizeDp(18), 123 | "Call me", 124 | true, 125 | "+44 12 3456 7890")); 126 | 127 | convenienceCardBuilder.addItem(ConvenienceBuilder.createMapItem(c, 128 | new IconicsDrawable(c) 129 | .icon(CommunityMaterial.Icon.cmd_map) 130 | .sizeDp(18), 131 | "Visit London", 132 | null, 133 | "London Eye")); 134 | 135 | MaterialAboutCard.Builder otherCardBuilder = new MaterialAboutCard.Builder(); 136 | otherCardBuilder.title("Other"); 137 | otherCardBuilder.outline(false); 138 | 139 | otherCardBuilder.cardColor(Color.parseColor("#c0cfff")); 140 | 141 | otherCardBuilder.addItem(new MaterialAboutActionItem.Builder() 142 | .icon(new IconicsDrawable(c) 143 | .icon(CommunityMaterial.Icon.cmd_language_html5) 144 | .sizeDp(18)) 145 | .text("HTML Formatted Sub Text") 146 | .subTextHtml("This is HTML formatted text
This is very cool because it allows lines to get very long which can lead to all kinds of possibilities.
And line breaks.
Oh and by the way, this card has a custom defined background.") 147 | .setIconGravity(MaterialAboutActionItem.GRAVITY_TOP) 148 | .build() 149 | ); 150 | 151 | return new MaterialAboutList(appCardBuilder.build(), authorCardBuilder.build(), convenienceCardBuilder.build(), otherCardBuilder.build()); 152 | } 153 | 154 | public static MaterialAboutList createMaterialAboutLicenseList(final Context c) { 155 | 156 | MaterialAboutCard materialAboutLibraryLicenseCard = ConvenienceBuilder.createLicenseCard(c, 157 | new IconicsDrawable(c) 158 | .icon(CommunityMaterial.Icon.cmd_book) 159 | .sizeDp(18), 160 | "material-about-library", "2016", "Daniel Stone", 161 | OpenSourceLicense.APACHE_2); 162 | 163 | MaterialAboutCard androidIconicsLicenseCard = ConvenienceBuilder.createLicenseCard(c, 164 | new IconicsDrawable(c) 165 | .icon(CommunityMaterial.Icon.cmd_book) 166 | .sizeDp(18), 167 | "Android Iconics", "2016", "Mike Penz", 168 | OpenSourceLicense.APACHE_2); 169 | 170 | MaterialAboutCard leakCanaryLicenseCard = ConvenienceBuilder.createLicenseCard(c, 171 | new IconicsDrawable(c) 172 | .icon(CommunityMaterial.Icon.cmd_book) 173 | .sizeDp(18), 174 | "LeakCanary", "2015", "Square, Inc", 175 | OpenSourceLicense.APACHE_2); 176 | 177 | MaterialAboutCard mitLicenseCard = ConvenienceBuilder.createLicenseCard(c, 178 | new IconicsDrawable(c) 179 | .icon(CommunityMaterial.Icon.cmd_book) 180 | .sizeDp(18), 181 | "MIT Example", "2017", "Matthew Ian Thomson", 182 | OpenSourceLicense.MIT); 183 | 184 | MaterialAboutCard gplLicenseCard = ConvenienceBuilder.createLicenseCard(c, 185 | new IconicsDrawable(c) 186 | .icon(CommunityMaterial.Icon.cmd_book) 187 | .sizeDp(18), 188 | "GPL Example", "2017", "George Perry Lindsay", 189 | OpenSourceLicense.GNU_GPL_3); 190 | 191 | return new MaterialAboutList(materialAboutLibraryLicenseCard, 192 | androidIconicsLicenseCard, 193 | leakCanaryLicenseCard, 194 | mitLicenseCard, 195 | gplLicenseCard); 196 | } 197 | } -------------------------------------------------------------------------------- /app/src/main/java/com/danielstone/materialaboutlibrarydemo/ExampleMaterialAboutActivity.java: -------------------------------------------------------------------------------- 1 | package com.danielstone.materialaboutlibrarydemo; 2 | 3 | import android.content.Context; 4 | import android.net.Uri; 5 | import android.os.Bundle; 6 | import androidx.annotation.NonNull; 7 | import androidx.annotation.Nullable; 8 | import com.google.android.material.snackbar.Snackbar; 9 | import androidx.core.content.ContextCompat; 10 | import android.util.Log; 11 | import android.view.Menu; 12 | import android.view.MenuItem; 13 | import android.widget.Toast; 14 | 15 | import com.danielstone.materialaboutlibrary.ConvenienceBuilder; 16 | import com.danielstone.materialaboutlibrary.MaterialAboutActivity; 17 | import com.danielstone.materialaboutlibrary.items.MaterialAboutActionItem; 18 | import com.danielstone.materialaboutlibrary.items.MaterialAboutItemOnClickAction; 19 | import com.danielstone.materialaboutlibrary.items.MaterialAboutTitleItem; 20 | import com.danielstone.materialaboutlibrary.model.MaterialAboutCard; 21 | import com.danielstone.materialaboutlibrary.model.MaterialAboutList; 22 | import com.danielstone.materialaboutlibrary.util.ViewTypeManager; 23 | import com.danielstone.materialaboutlibrarydemo.custom.MyCustomItem; 24 | import com.danielstone.materialaboutlibrarydemo.custom.MyViewTypeManager; 25 | import com.mikepenz.community_material_typeface_library.CommunityMaterial; 26 | import com.mikepenz.iconics.IconicsDrawable; 27 | 28 | import net.yslibrary.licenseadapter.Library; 29 | import net.yslibrary.licenseadapter.LicenseAdapter; 30 | import net.yslibrary.licenseadapter.Licenses; 31 | 32 | import java.util.ArrayList; 33 | import java.util.List; 34 | 35 | public class ExampleMaterialAboutActivity extends MaterialAboutActivity { 36 | 37 | public static final String THEME_EXTRA = ""; 38 | public static final int THEME_LIGHT = 0; 39 | public static final int THEME_DARK = 1; 40 | public static final int THEME_DAYNIGHT = 2; 41 | public static final int THEME_CUSTOM_CARDVIEW = 3; 42 | 43 | @NonNull 44 | @Override 45 | protected MaterialAboutList getMaterialAboutList(@NonNull final Context c) { 46 | MaterialAboutCard.Builder advancedCardBuilder = new MaterialAboutCard.Builder(); 47 | advancedCardBuilder.title("Advanced"); 48 | 49 | advancedCardBuilder.addItem(new MaterialAboutTitleItem.Builder() 50 | .text("TitleItem OnClickAction") 51 | .icon(R.mipmap.ic_launcher) 52 | .setOnClickAction(ConvenienceBuilder.createWebsiteOnClickAction(c, Uri.parse("http://www.danstone.uk"))) 53 | .build()); 54 | 55 | advancedCardBuilder.addItem(new MaterialAboutActionItem.Builder() 56 | .text("Snackbar demo") 57 | .icon(new IconicsDrawable(c) 58 | .icon(CommunityMaterial.Icon.cmd_code_tags) 59 | .sizeDp(18)) 60 | .setOnClickAction(new MaterialAboutItemOnClickAction() { 61 | @Override 62 | public void onClick() { 63 | Snackbar.make(getRecyclerView(), "Test", Snackbar.LENGTH_SHORT).show(); 64 | } 65 | }) 66 | .build()); 67 | 68 | advancedCardBuilder.addItem(new MaterialAboutActionItem.Builder() 69 | .text("OnLongClickAction demo") 70 | .icon(new IconicsDrawable(c) 71 | .icon(CommunityMaterial.Icon.cmd_hand_pointing_right) 72 | .sizeDp(18)) 73 | .setOnLongClickAction(new MaterialAboutItemOnClickAction() { 74 | @Override 75 | public void onClick() { 76 | Toast.makeText(c, "Long pressed", Toast.LENGTH_SHORT).show(); 77 | } 78 | }) 79 | .build()); 80 | 81 | advancedCardBuilder.addItem(new MyCustomItem.Builder() 82 | .text("Custom Item") 83 | .icon(new IconicsDrawable(c) 84 | .icon(CommunityMaterial.Icon.cmd_code_braces) 85 | .sizeDp(18)) 86 | .build()); 87 | 88 | advancedCardBuilder.addItem(createDynamicItem("Tap for a random number & swap position", c)); 89 | 90 | MaterialAboutCard.Builder customAdapterCardBuilder = new MaterialAboutCard.Builder(); 91 | // Create list of libraries 92 | List libraries = new ArrayList<>(); 93 | 94 | // Add libraries that are hosted on GitHub with an Apache v2 license. 95 | libraries.add(Licenses.fromGitHubApacheV2("yshrsmz/LicenseAdapter")); 96 | libraries.add(Licenses.fromGitHubApacheV2("daniel-stoneuk/material-about-library")); 97 | 98 | customAdapterCardBuilder.title("Custom Adapter (License Adapter)"); 99 | customAdapterCardBuilder.customAdapter(new LicenseAdapter(libraries)); 100 | 101 | return Demo.createMaterialAboutList(c, getIntent().getIntExtra(THEME_EXTRA, THEME_LIGHT)).addCard(advancedCardBuilder.build()).addCard(customAdapterCardBuilder.build()); 102 | } 103 | 104 | private MaterialAboutActionItem createDynamicItem(String subText, final Context c) { 105 | final MaterialAboutActionItem item = new MaterialAboutActionItem.Builder() 106 | .text("Dynamic UI") 107 | .subText(subText) 108 | .icon(new IconicsDrawable(c) 109 | .icon(CommunityMaterial.Icon.cmd_refresh) 110 | .sizeDp(18)) 111 | .build(); 112 | item.setOnClickAction(new MaterialAboutItemOnClickAction() { 113 | @Override 114 | public void onClick() { 115 | getList().getCards().get(4).getItems().remove(getList().getCards().get(4).getItems().indexOf(item)); 116 | int newIndex = ((int) (Math.random() * 5)); 117 | getList().getCards().get(4).getItems().add(newIndex, item); 118 | item.setSubText("Random number: " + ((int) (Math.random() * 10))); 119 | setMaterialAboutList(getList()); 120 | } 121 | }); 122 | 123 | return item; 124 | } 125 | 126 | 127 | @Override 128 | protected void onCreate(@Nullable Bundle savedInstanceState) { 129 | switch (getIntent().getIntExtra(THEME_EXTRA, THEME_LIGHT)) { 130 | case THEME_LIGHT: 131 | setTheme(R.style.AppTheme_MaterialAboutActivity_Light); 132 | break; 133 | case THEME_DARK: 134 | setTheme(R.style.AppTheme_MaterialAboutActivity_Dark); 135 | break; 136 | case THEME_DAYNIGHT: 137 | setTheme(R.style.AppTheme_MaterialAboutActivity_DayNight); 138 | break; 139 | case THEME_CUSTOM_CARDVIEW: 140 | setTheme(R.style.AppTheme_MaterialAboutActivity_Light_DarkActionBar_CustomCardView); 141 | break; 142 | } 143 | 144 | super.onCreate(savedInstanceState); 145 | 146 | // Call this method to let the scrollbar scroll off screen 147 | // setScrollToolbar(true); 148 | } 149 | 150 | @Override 151 | protected CharSequence getActivityTitle() { 152 | return getString(R.string.mal_title_about); 153 | } 154 | 155 | @NonNull 156 | @Override 157 | protected ViewTypeManager getViewTypeManager() { 158 | return new MyViewTypeManager(); 159 | } 160 | 161 | @Override 162 | public boolean onCreateOptionsMenu(Menu menu) { 163 | super.onCreateOptionsMenu(menu); 164 | getMenuInflater().inflate(R.menu.menu_example_material_about, menu); 165 | return true; 166 | } 167 | 168 | @Override 169 | public boolean onOptionsItemSelected(MenuItem item) { 170 | if (item.getItemId() == R.id.action_refresh) { 171 | refreshMaterialAboutList(); 172 | return true; 173 | } 174 | return super.onOptionsItemSelected(item); 175 | } 176 | } 177 | -------------------------------------------------------------------------------- /app/src/main/java/com/danielstone/materialaboutlibrarydemo/ExampleMaterialAboutFragment.java: -------------------------------------------------------------------------------- 1 | package com.danielstone.materialaboutlibrarydemo; 2 | 3 | import android.content.Context; 4 | import android.os.Handler; 5 | import androidx.core.content.ContextCompat; 6 | import android.util.Log; 7 | 8 | import com.danielstone.materialaboutlibrary.MaterialAboutFragment; 9 | import com.danielstone.materialaboutlibrary.items.MaterialAboutActionItem; 10 | import com.danielstone.materialaboutlibrary.items.MaterialAboutItemOnClickAction; 11 | import com.danielstone.materialaboutlibrary.model.MaterialAboutList; 12 | import com.mikepenz.community_material_typeface_library.CommunityMaterial; 13 | import com.mikepenz.iconics.IconicsDrawable; 14 | 15 | import static com.danielstone.materialaboutlibrarydemo.ExampleMaterialAboutActivity.THEME_LIGHT; 16 | 17 | 18 | public class ExampleMaterialAboutFragment extends MaterialAboutFragment { 19 | 20 | private MaterialAboutActionItem createDynamicItem(String subText, final Context c) { 21 | final MaterialAboutActionItem item = new MaterialAboutActionItem.Builder() 22 | .text("Dynamic UI") 23 | .subText(subText) 24 | .icon(new IconicsDrawable(c) 25 | .icon(CommunityMaterial.Icon.cmd_refresh) 26 | .sizeDp(18)) 27 | .build(); 28 | item.setOnClickAction(new MaterialAboutItemOnClickAction() { 29 | @Override 30 | public void onClick() { 31 | item.setSubText("Random number: " + ((int) (Math.random() * 10))); 32 | refreshMaterialAboutList(); 33 | } 34 | }); 35 | return item; 36 | 37 | } 38 | 39 | @Override 40 | protected MaterialAboutList getMaterialAboutList(final Context c) { 41 | MaterialAboutList list = Demo.createMaterialAboutList(c, THEME_LIGHT); 42 | 43 | list.getCards().get(2).getItems().add(createDynamicItem("Tap for a random number", c)); 44 | 45 | final MaterialAboutActionItem time = new MaterialAboutActionItem.Builder() 46 | .text("Unix Time In Millis") 47 | .subText("Time") 48 | .icon(new IconicsDrawable(c) 49 | .icon(CommunityMaterial.Icon.cmd_clock) 50 | .sizeDp(18)) 51 | .build(); 52 | list.getCards().get(2).getItems().add(time); 53 | 54 | return list; 55 | } 56 | 57 | final Handler handler = new Handler(); 58 | Runnable runnable = new Runnable() { 59 | @Override 60 | public void run() { 61 | Log.i("MaterialAboutFragment", "Updating with time"); 62 | if (getList().getCards().size() > 0) { 63 | ((MaterialAboutActionItem) getList().getCards().get(2).getItems().get(7)).setSubText("" + System.currentTimeMillis()); 64 | refreshMaterialAboutList(); 65 | } 66 | handler.postDelayed(this, 1000); 67 | } 68 | }; 69 | 70 | 71 | @Override 72 | public void onResume() { 73 | super.onResume(); 74 | runnable.run(); 75 | } 76 | 77 | @Override 78 | public void onPause() { 79 | super.onPause(); 80 | handler.removeCallbacks(runnable); 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /app/src/main/java/com/danielstone/materialaboutlibrarydemo/ExampleMaterialAboutFragmentActivity.java: -------------------------------------------------------------------------------- 1 | package com.danielstone.materialaboutlibrarydemo; 2 | 3 | import android.os.Bundle; 4 | import androidx.core.app.NavUtils; 5 | import androidx.appcompat.app.ActionBar; 6 | import androidx.appcompat.app.AppCompatActivity; 7 | import androidx.appcompat.widget.Toolbar; 8 | 9 | public class ExampleMaterialAboutFragmentActivity extends AppCompatActivity { 10 | 11 | @Override 12 | protected void onCreate(Bundle savedInstanceState) { 13 | super.onCreate(savedInstanceState); 14 | setContentView(R.layout.activity_example_material_about_fragment); 15 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 16 | setSupportActionBar(toolbar); 17 | getSupportFragmentManager().beginTransaction() 18 | .replace(R.id.container, ExampleMaterialAboutFragment.newInstance(new ExampleMaterialAboutFragment())) 19 | .commit(); 20 | 21 | setTitle("About Fragment Activity"); 22 | 23 | if (NavUtils.getParentActivityName(this) != null) { 24 | ActionBar actionBar = getSupportActionBar(); 25 | if (actionBar != null) { 26 | actionBar.setDisplayHomeAsUpEnabled(true); 27 | } 28 | } 29 | 30 | } 31 | 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /app/src/main/java/com/danielstone/materialaboutlibrarydemo/ExampleMaterialAboutLicenseActivity.java: -------------------------------------------------------------------------------- 1 | package com.danielstone.materialaboutlibrarydemo; 2 | 3 | import android.content.Context; 4 | import androidx.annotation.NonNull; 5 | import android.view.MenuItem; 6 | 7 | import com.danielstone.materialaboutlibrary.model.MaterialAboutList; 8 | 9 | public class ExampleMaterialAboutLicenseActivity extends ExampleMaterialAboutActivity { 10 | 11 | @NonNull @Override 12 | protected MaterialAboutList getMaterialAboutList(@NonNull final Context c) { 13 | return Demo.createMaterialAboutLicenseList(c); 14 | } 15 | 16 | @Override 17 | protected CharSequence getActivityTitle() { 18 | return getString(R.string.mal_title_licenses); 19 | } 20 | 21 | @Override 22 | public boolean onOptionsItemSelected(MenuItem item) { 23 | switch (item.getItemId()) { 24 | case android.R.id.home: 25 | finish(); 26 | return true; 27 | default: 28 | return false; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/danielstone/materialaboutlibrarydemo/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.danielstone.materialaboutlibrarydemo; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import androidx.appcompat.app.AppCompatActivity; 6 | import androidx.appcompat.widget.Toolbar; 7 | import android.view.Menu; 8 | import android.view.MenuItem; 9 | import android.view.View; 10 | import android.widget.Button; 11 | 12 | public class MainActivity extends AppCompatActivity { 13 | 14 | @Override 15 | protected void onCreate(Bundle savedInstanceState) { 16 | super.onCreate(savedInstanceState); 17 | setContentView(R.layout.activity_main); 18 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 19 | setSupportActionBar(toolbar); 20 | 21 | Button fragmentButton = (Button) findViewById(R.id.fragment_button); 22 | fragmentButton.setOnClickListener(new View.OnClickListener() { 23 | @Override 24 | public void onClick(View v) { 25 | Intent i = new Intent(MainActivity.this, ExampleMaterialAboutFragmentActivity.class); 26 | startActivity(i); 27 | } 28 | }); 29 | 30 | } 31 | 32 | public void onActivityButtonPressed(View view) { 33 | Intent i = new Intent(MainActivity.this, ExampleMaterialAboutActivity.class); 34 | i.putExtra(ExampleMaterialAboutActivity.THEME_EXTRA, Integer.parseInt(view.getTag().toString())); 35 | startActivity(i); 36 | } 37 | 38 | @Override 39 | public boolean onCreateOptionsMenu(Menu menu) { 40 | // Inflate the menu; this adds items to the action bar if it is present. 41 | getMenuInflater().inflate(R.menu.menu_main, menu); 42 | return true; 43 | } 44 | 45 | @Override 46 | public boolean onOptionsItemSelected(MenuItem item) { 47 | // Handle action bar item clicks here. The action bar will 48 | // automatically handle clicks on the Home/Up button, so long 49 | // as you specify a parent activity in AndroidManifest.xml. 50 | int id = item.getItemId(); 51 | 52 | //noinspection SimplifiableIfStatement 53 | if (id == R.id.action_settings) { 54 | Intent i = new Intent(this, ExampleMaterialAboutActivity.class); 55 | startActivity(i); 56 | return true; 57 | } 58 | 59 | return super.onOptionsItemSelected(item); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /app/src/main/java/com/danielstone/materialaboutlibrarydemo/custom/MyCustomItem.java: -------------------------------------------------------------------------------- 1 | package com.danielstone.materialaboutlibrarydemo.custom; 2 | 3 | import android.content.Context; 4 | import android.graphics.drawable.Drawable; 5 | import android.os.Build; 6 | import androidx.annotation.DrawableRes; 7 | import androidx.annotation.IntDef; 8 | import androidx.annotation.StringRes; 9 | import android.text.Html; 10 | import android.util.TypedValue; 11 | import android.view.Gravity; 12 | import android.view.View; 13 | import android.widget.ImageView; 14 | import android.widget.LinearLayout; 15 | import android.widget.TextView; 16 | 17 | import com.danielstone.materialaboutlibrary.R; 18 | import com.danielstone.materialaboutlibrary.holders.MaterialAboutItemViewHolder; 19 | import com.danielstone.materialaboutlibrary.items.MaterialAboutItem; 20 | 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | 24 | import static android.view.View.GONE; 25 | 26 | public class MyCustomItem extends MaterialAboutItem { 27 | 28 | public interface OnClickListener { 29 | void onClick(); 30 | } 31 | 32 | 33 | 34 | @Retention(RetentionPolicy.SOURCE) 35 | @IntDef({GRAVITY_TOP, GRAVITY_MIDDLE, GRAVITY_BOTTOM}) 36 | public @interface IconGravity { 37 | } 38 | 39 | public static final int GRAVITY_TOP = 0; 40 | public static final int GRAVITY_MIDDLE = 1; 41 | public static final int GRAVITY_BOTTOM = 2; 42 | 43 | 44 | private CharSequence text = null; 45 | private int textRes = 0; 46 | 47 | private CharSequence subText = null; 48 | private int subTextRes = 0; 49 | 50 | private Drawable icon = null; 51 | private int iconRes = 0; 52 | private boolean showIcon = true; 53 | private int iconGravity = GRAVITY_MIDDLE; 54 | 55 | private MyCustomItem.OnClickListener onClickListener = null; 56 | 57 | @Override 58 | public int getType() { 59 | return MyViewTypeManager.ItemType.CUSTOM_ITEM; 60 | } 61 | 62 | @Override 63 | public String getDetailString() { 64 | return "MyCustomItem{" + 65 | "text=" + text + 66 | ", textRes=" + textRes + 67 | ", subText=" + subText + 68 | ", subTextRes=" + subTextRes + 69 | ", icon=" + icon + 70 | ", iconRes=" + iconRes + 71 | ", showIcon=" + showIcon + 72 | ", iconGravity=" + iconGravity + 73 | ", onClickListener=" + onClickListener + 74 | '}'; 75 | } 76 | 77 | public MyCustomItem(MyCustomItem item) { 78 | this.id = item.getId(); 79 | this.text = item.getText(); 80 | this.textRes = item.getTextRes(); 81 | this.subText = item.getSubText(); 82 | this.subTextRes = item.getSubTextRes(); 83 | this.icon = item.getIcon(); 84 | this.iconRes = item.getIconRes(); 85 | this.showIcon = item.shouldShowIcon(); 86 | this.iconGravity = item.getIconGravity(); 87 | this.onClickListener = item.getOnClickListener(); 88 | } 89 | 90 | @Override 91 | public MyCustomItem clone() { 92 | return new MyCustomItem(this); 93 | } 94 | 95 | public static MaterialAboutItemViewHolder getViewHolder(View view) { 96 | return new MyCustomItemViewHolder(view); 97 | } 98 | 99 | public static class MyCustomItemViewHolder extends MaterialAboutItemViewHolder implements View.OnClickListener { 100 | public final View view; 101 | public final ImageView icon; 102 | public final TextView text; 103 | public final TextView subText; 104 | public MyCustomItem.OnClickListener onClickListener; 105 | 106 | MyCustomItemViewHolder(View view) { 107 | super(view); 108 | this.view = view; 109 | icon = (ImageView) view.findViewById(R.id.mal_item_image); 110 | text = (TextView) view.findViewById(R.id.mal_item_text); 111 | subText = (TextView) view.findViewById(R.id.mal_action_item_subtext); 112 | 113 | view.setOnClickListener(this); 114 | onClickListener = null; 115 | } 116 | 117 | @Override 118 | public void onClick(View v) { 119 | if (onClickListener != null) { 120 | onClickListener.onClick(); 121 | } 122 | } 123 | } 124 | 125 | private MyCustomItem(Builder builder) { 126 | this.text = builder.text; 127 | this.textRes = builder.textRes; 128 | 129 | this.subText = builder.subText; 130 | this.subTextRes = builder.subTextRes; 131 | 132 | this.icon = builder.icon; 133 | this.iconRes = builder.iconRes; 134 | 135 | this.showIcon = builder.showIcon; 136 | 137 | this.iconGravity = builder.iconGravity; 138 | 139 | this.onClickListener = builder.onClickListener; 140 | } 141 | 142 | public MyCustomItem(CharSequence text, CharSequence subText, Drawable icon, OnClickListener onClickListener) { 143 | this.text = text; 144 | this.subText = subText; 145 | this.icon = icon; 146 | this.onClickListener = onClickListener; 147 | } 148 | 149 | public MyCustomItem(CharSequence text, CharSequence subText, Drawable icon) { 150 | this.text = text; 151 | this.subText = subText; 152 | this.icon = icon; 153 | } 154 | 155 | public MyCustomItem(int textRes, int subTextRes, int iconRes, OnClickListener onClickListener) { 156 | this.textRes = textRes; 157 | this.subTextRes = subTextRes; 158 | this.iconRes = iconRes; 159 | this.onClickListener = onClickListener; 160 | } 161 | 162 | public MyCustomItem(int textRes, int subTextRes, int iconRes) { 163 | this.textRes = textRes; 164 | this.subTextRes = subTextRes; 165 | this.iconRes = iconRes; 166 | } 167 | 168 | public CharSequence getText() { 169 | return text; 170 | } 171 | 172 | public int getTextRes() { 173 | return textRes; 174 | } 175 | 176 | public CharSequence getSubText() { 177 | return subText; 178 | } 179 | 180 | public int getSubTextRes() { 181 | return subTextRes; 182 | } 183 | 184 | public Drawable getIcon() { 185 | return icon; 186 | } 187 | 188 | public int getIconRes() { 189 | return iconRes; 190 | } 191 | 192 | public boolean shouldShowIcon() { 193 | return showIcon; 194 | } 195 | 196 | @IconGravity 197 | public int getIconGravity() { 198 | return iconGravity; 199 | } 200 | 201 | public MyCustomItem.OnClickListener getOnClickListener() { 202 | return onClickListener; 203 | } 204 | 205 | public static void setupItem(MyCustomItemViewHolder holder, MyCustomItem item, Context context) { 206 | CharSequence text = item.getText(); 207 | int textRes = item.getTextRes(); 208 | 209 | holder.text.setVisibility(View.VISIBLE); 210 | if (text != null) { 211 | holder.text.setText(text); 212 | } else if (textRes != 0) { 213 | holder.text.setText(textRes); 214 | } else { 215 | holder.text.setVisibility(GONE); 216 | } 217 | 218 | CharSequence subText = item.getSubText(); 219 | int subTextRes = item.getSubTextRes(); 220 | 221 | holder.subText.setVisibility(View.VISIBLE); 222 | if (subText != null) { 223 | holder.subText.setText(subText); 224 | } else if (subTextRes != 0) { 225 | holder.subText.setText(subTextRes); 226 | } else { 227 | holder.subText.setVisibility(GONE); 228 | } 229 | 230 | if (item.shouldShowIcon()) { 231 | holder.icon.setVisibility(View.VISIBLE); 232 | Drawable drawable = item.getIcon(); 233 | int drawableRes = item.getIconRes(); 234 | if (drawable != null) { 235 | holder.icon.setImageDrawable(drawable); 236 | } else if (drawableRes != 0) { 237 | holder.icon.setImageResource(drawableRes); 238 | } 239 | } else { 240 | holder.icon.setVisibility(GONE); 241 | } 242 | 243 | LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) holder.icon.getLayoutParams(); 244 | switch (item.getIconGravity()) { 245 | case MyCustomItem.GRAVITY_TOP: 246 | params.gravity = Gravity.TOP; 247 | break; 248 | case MyCustomItem.GRAVITY_MIDDLE: 249 | params.gravity = Gravity.CENTER_VERTICAL; 250 | break; 251 | case MyCustomItem.GRAVITY_BOTTOM: 252 | params.gravity = Gravity.BOTTOM; 253 | break; 254 | } 255 | holder.icon.setLayoutParams(params); 256 | 257 | int pL = 0, pT = 0, pR = 0, pB = 0; 258 | if (Build.VERSION.SDK_INT < 21) { 259 | pL = holder.view.getPaddingLeft(); 260 | pT = holder.view.getPaddingTop(); 261 | pR = holder.view.getPaddingRight(); 262 | pB = holder.view.getPaddingBottom(); 263 | } 264 | 265 | if (item.getOnClickListener() != null) { 266 | TypedValue outValue = new TypedValue(); 267 | context.getTheme().resolveAttribute(R.attr.selectableItemBackground, outValue, true); 268 | holder.view.setBackgroundResource(outValue.resourceId); 269 | holder.onClickListener = item.getOnClickListener(); 270 | holder.view.setSoundEffectsEnabled(true); 271 | } else { 272 | TypedValue outValue = new TypedValue(); 273 | context.getTheme().resolveAttribute(R.attr.selectableItemBackground, outValue, false); 274 | holder.view.setBackgroundResource(outValue.resourceId); 275 | holder.onClickListener = null; 276 | holder.view.setSoundEffectsEnabled(false); 277 | } 278 | 279 | if (Build.VERSION.SDK_INT < 21) { 280 | holder.view.setPadding(pL, pT, pR, pB); 281 | } 282 | } 283 | 284 | public static class Builder { 285 | 286 | private CharSequence text = null; 287 | @StringRes 288 | private int textRes = 0; 289 | 290 | private CharSequence subText = null; 291 | @StringRes 292 | private int subTextRes = 0; 293 | 294 | private Drawable icon = null; 295 | @DrawableRes 296 | private int iconRes = 0; 297 | 298 | private boolean showIcon = true; 299 | 300 | @IconGravity 301 | private int iconGravity = GRAVITY_MIDDLE; 302 | 303 | MyCustomItem.OnClickListener onClickListener; 304 | 305 | public Builder text(CharSequence text) { 306 | this.text = text; 307 | this.textRes = 0; 308 | return this; 309 | } 310 | 311 | public Builder text(@StringRes int text) { 312 | this.textRes = text; 313 | this.text = null; 314 | return this; 315 | } 316 | 317 | public Builder subText(CharSequence subText) { 318 | this.subText = subText; 319 | this.subTextRes = 0; 320 | return this; 321 | } 322 | 323 | public Builder subText(@StringRes int subTextRes) { 324 | this.subText = null; 325 | this.subTextRes = subTextRes; 326 | return this; 327 | } 328 | 329 | public Builder subTextHtml(String subTextHtml) { 330 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { 331 | this.subText = Html.fromHtml(subTextHtml, Html.FROM_HTML_MODE_LEGACY); 332 | } else { 333 | //noinspection deprecation 334 | this.subText = Html.fromHtml(subTextHtml); 335 | } 336 | this.subTextRes = 0; 337 | return this; 338 | } 339 | 340 | public Builder icon(Drawable icon) { 341 | this.icon = icon; 342 | this.iconRes = 0; 343 | return this; 344 | } 345 | 346 | public Builder icon(@DrawableRes int iconRes) { 347 | this.icon = null; 348 | this.iconRes = iconRes; 349 | return this; 350 | } 351 | 352 | public Builder showIcon(boolean showIcon) { 353 | this.showIcon = showIcon; 354 | return this; 355 | } 356 | 357 | public Builder setIconGravity(@IconGravity int iconGravity) { 358 | this.iconGravity = iconGravity; 359 | return this; 360 | } 361 | 362 | public Builder setOnClickListener(MyCustomItem.OnClickListener onClickListener) { 363 | this.onClickListener = onClickListener; 364 | return this; 365 | } 366 | 367 | public MyCustomItem build() { 368 | return new MyCustomItem(this); 369 | } 370 | } 371 | } 372 | -------------------------------------------------------------------------------- /app/src/main/java/com/danielstone/materialaboutlibrarydemo/custom/MyViewTypeManager.java: -------------------------------------------------------------------------------- 1 | package com.danielstone.materialaboutlibrarydemo.custom; 2 | 3 | import android.content.Context; 4 | import android.view.View; 5 | 6 | import com.danielstone.materialaboutlibrary.holders.MaterialAboutItemViewHolder; 7 | import com.danielstone.materialaboutlibrary.items.MaterialAboutActionItem; 8 | import com.danielstone.materialaboutlibrary.items.MaterialAboutItem; 9 | import com.danielstone.materialaboutlibrary.items.MaterialAboutTitleItem; 10 | import com.danielstone.materialaboutlibrary.util.ViewTypeManager; 11 | import com.danielstone.materialaboutlibrarydemo.R; 12 | 13 | import static com.danielstone.materialaboutlibrarydemo.custom.MyViewTypeManager.ItemLayout.*; 14 | import static com.danielstone.materialaboutlibrarydemo.custom.MyViewTypeManager.ItemType.*; 15 | 16 | public class MyViewTypeManager extends ViewTypeManager { 17 | 18 | public static final class ItemType { 19 | public static final int ACTION_ITEM = ViewTypeManager.ItemType.ACTION_ITEM; 20 | public static final int TITLE_ITEM = ViewTypeManager.ItemType.TITLE_ITEM; 21 | public static final int CUSTOM_ITEM = 10; 22 | } 23 | 24 | public static final class ItemLayout { 25 | public static final int ACTION_LAYOUT = ViewTypeManager.ItemLayout.ACTION_LAYOUT; 26 | public static final int TITLE_LAYOUT = ViewTypeManager.ItemLayout.TITLE_LAYOUT; 27 | public static final int CUSTOM_LAYOUT = R.layout.custom_item; 28 | } 29 | 30 | 31 | public int getLayout(int itemType) { 32 | switch (itemType) { 33 | case ACTION_ITEM: 34 | return ACTION_LAYOUT; 35 | case TITLE_ITEM: 36 | return TITLE_LAYOUT; 37 | case CUSTOM_ITEM: 38 | return CUSTOM_LAYOUT; 39 | default: 40 | return -1; 41 | } 42 | } 43 | 44 | public MaterialAboutItemViewHolder getViewHolder(int itemType, View view) { 45 | switch (itemType) { 46 | case ACTION_ITEM: 47 | return MaterialAboutActionItem.getViewHolder(view); 48 | case TITLE_ITEM: 49 | return MaterialAboutTitleItem.getViewHolder(view); 50 | case CUSTOM_ITEM: 51 | return MyCustomItem.getViewHolder(view); 52 | default: 53 | return null; 54 | } 55 | } 56 | 57 | public void setupItem(int itemType, MaterialAboutItemViewHolder holder, MaterialAboutItem item, Context context) { 58 | switch (itemType) { 59 | case ACTION_ITEM: 60 | MaterialAboutActionItem.setupItem((MaterialAboutActionItem.MaterialAboutActionItemViewHolder) holder, (MaterialAboutActionItem) item, context); 61 | break; 62 | case TITLE_ITEM: 63 | MaterialAboutTitleItem.setupItem((MaterialAboutTitleItem.MaterialAboutTitleItemViewHolder) holder, (MaterialAboutTitleItem) item, context); 64 | break; 65 | case CUSTOM_ITEM: 66 | MyCustomItem.setupItem((MyCustomItem.MyCustomItemViewHolder) holder, (MyCustomItem) item, context); 67 | break; 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_example_material_about_fragment.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/layout/content_example_material_about_fragment.xml: -------------------------------------------------------------------------------- 1 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/layout/content_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 |