-
Notifications
You must be signed in to change notification settings - Fork 138
/
Copy pathDemo.java
197 lines (165 loc) · 8.6 KB
/
Demo.java
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
package com.danielstone.materialaboutlibrarydemo;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import androidx.core.content.ContextCompat;
import com.danielstone.materialaboutlibrary.ConvenienceBuilder;
import com.danielstone.materialaboutlibrary.items.MaterialAboutActionItem;
import com.danielstone.materialaboutlibrary.items.MaterialAboutItemOnClickAction;
import com.danielstone.materialaboutlibrary.items.MaterialAboutTitleItem;
import com.danielstone.materialaboutlibrary.model.MaterialAboutCard;
import com.danielstone.materialaboutlibrary.model.MaterialAboutList;
import com.danielstone.materialaboutlibrary.util.OpenSourceLicense;
import com.mikepenz.community_material_typeface_library.CommunityMaterial;
import com.mikepenz.iconics.IconicsDrawable;
public class Demo {
public static MaterialAboutList createMaterialAboutList(final Context c, final int theme) {
MaterialAboutCard.Builder appCardBuilder = new MaterialAboutCard.Builder();
// Add items to card
appCardBuilder.addItem(new MaterialAboutTitleItem.Builder()
.text("Material About Library")
.desc("© 2020 Daniel Stone")
.icon(R.mipmap.ic_launcher)
.build());
appCardBuilder.addItem(ConvenienceBuilder.createVersionActionItem(c,
new IconicsDrawable(c)
.icon(CommunityMaterial.Icon.cmd_information_outline)
.sizeDp(18),
"Version",
false));
appCardBuilder.addItem(new MaterialAboutActionItem.Builder()
.text("Changelog")
.icon(new IconicsDrawable(c)
.icon(CommunityMaterial.Icon.cmd_history)
.sizeDp(18))
.setOnClickAction(ConvenienceBuilder.createWebViewDialogOnClickAction(c, "Releases", "https://github.com/daniel-stoneuk/material-about-library/releases", true, false))
.build());
appCardBuilder.addItem(new MaterialAboutActionItem.Builder()
.text("Licenses")
.icon(new IconicsDrawable(c)
.icon(CommunityMaterial.Icon.cmd_book)
.sizeDp(18))
.setOnClickAction(new MaterialAboutItemOnClickAction() {
@Override
public void onClick() {
Intent intent = new Intent(c, ExampleMaterialAboutLicenseActivity.class);
intent.putExtra(ExampleMaterialAboutActivity.THEME_EXTRA, theme);
c.startActivity(intent);
}
})
.build());
MaterialAboutCard.Builder authorCardBuilder = new MaterialAboutCard.Builder();
authorCardBuilder.title("Author");
// authorCardBuilder.titleColor(ContextCompat.getColor(c, R.color.colorAccent));
authorCardBuilder.addItem(new MaterialAboutActionItem.Builder()
.text("Daniel Stone")
.subText("United Kingdom")
.icon(new IconicsDrawable(c)
.icon(CommunityMaterial.Icon.cmd_account)
.sizeDp(18))
.build());
authorCardBuilder.addItem(new MaterialAboutActionItem.Builder()
.text("Fork on GitHub")
.icon(new IconicsDrawable(c)
.icon(CommunityMaterial.Icon.cmd_github_circle)
.sizeDp(18))
.setOnClickAction(ConvenienceBuilder.createWebsiteOnClickAction(c, Uri.parse("https://github.com/daniel-stoneuk")))
.build());
MaterialAboutCard.Builder convenienceCardBuilder = new MaterialAboutCard.Builder();
convenienceCardBuilder.title("Convenience Builder");
convenienceCardBuilder.addItem(ConvenienceBuilder.createVersionActionItem(c,
new IconicsDrawable(c)
.icon(CommunityMaterial.Icon.cmd_information_outline)
.sizeDp(18),
"Version",
false));
convenienceCardBuilder.addItem(ConvenienceBuilder.createWebsiteActionItem(c,
new IconicsDrawable(c)
.icon(CommunityMaterial.Icon.cmd_earth)
.sizeDp(18),
"Visit Website",
true,
Uri.parse("http://danstone.uk")));
convenienceCardBuilder.addItem(ConvenienceBuilder.createRateActionItem(c,
new IconicsDrawable(c)
.icon(CommunityMaterial.Icon.cmd_star)
.sizeDp(18),
"Rate this app",
null
));
convenienceCardBuilder.addItem(ConvenienceBuilder.createEmailItem(c,
new IconicsDrawable(c)
.icon(CommunityMaterial.Icon.cmd_email)
.sizeDp(18),
"Send an email",
true,
"Question concerning MaterialAboutLibrary"));
convenienceCardBuilder.addItem(ConvenienceBuilder.createPhoneItem(c,
new IconicsDrawable(c)
.icon(CommunityMaterial.Icon.cmd_phone)
.sizeDp(18),
"Call me",
true,
"+44 12 3456 7890"));
convenienceCardBuilder.addItem(ConvenienceBuilder.createMapItem(c,
new IconicsDrawable(c)
.icon(CommunityMaterial.Icon.cmd_map)
.sizeDp(18),
"Visit London",
null,
"London Eye"));
MaterialAboutCard.Builder otherCardBuilder = new MaterialAboutCard.Builder();
otherCardBuilder.title("Other");
otherCardBuilder.outline(false);
otherCardBuilder.cardColor(Color.parseColor("#c0cfff"));
otherCardBuilder.addItem(new MaterialAboutActionItem.Builder()
.icon(new IconicsDrawable(c)
.icon(CommunityMaterial.Icon.cmd_language_html5)
.sizeDp(18))
.text("HTML Formatted Sub Text")
.subTextHtml("This is <b>HTML</b> formatted <i>text</i> <br /> This is very cool because it allows lines to get very long which can lead to all kinds of possibilities. <br /> And line breaks. <br /> Oh and by the way, this card has a custom defined background.")
.setIconGravity(MaterialAboutActionItem.GRAVITY_TOP)
.build()
);
return new MaterialAboutList(appCardBuilder.build(), authorCardBuilder.build(), convenienceCardBuilder.build(), otherCardBuilder.build());
}
public static MaterialAboutList createMaterialAboutLicenseList(final Context c) {
MaterialAboutCard materialAboutLibraryLicenseCard = ConvenienceBuilder.createLicenseCard(c,
new IconicsDrawable(c)
.icon(CommunityMaterial.Icon.cmd_book)
.sizeDp(18),
"material-about-library", "2016", "Daniel Stone",
OpenSourceLicense.APACHE_2);
MaterialAboutCard androidIconicsLicenseCard = ConvenienceBuilder.createLicenseCard(c,
new IconicsDrawable(c)
.icon(CommunityMaterial.Icon.cmd_book)
.sizeDp(18),
"Android Iconics", "2016", "Mike Penz",
OpenSourceLicense.APACHE_2);
MaterialAboutCard leakCanaryLicenseCard = ConvenienceBuilder.createLicenseCard(c,
new IconicsDrawable(c)
.icon(CommunityMaterial.Icon.cmd_book)
.sizeDp(18),
"LeakCanary", "2015", "Square, Inc",
OpenSourceLicense.APACHE_2);
MaterialAboutCard mitLicenseCard = ConvenienceBuilder.createLicenseCard(c,
new IconicsDrawable(c)
.icon(CommunityMaterial.Icon.cmd_book)
.sizeDp(18),
"MIT Example", "2017", "Matthew Ian Thomson",
OpenSourceLicense.MIT);
MaterialAboutCard gplLicenseCard = ConvenienceBuilder.createLicenseCard(c,
new IconicsDrawable(c)
.icon(CommunityMaterial.Icon.cmd_book)
.sizeDp(18),
"GPL Example", "2017", "George Perry Lindsay",
OpenSourceLicense.GNU_GPL_3);
return new MaterialAboutList(materialAboutLibraryLicenseCard,
androidIconicsLicenseCard,
leakCanaryLicenseCard,
mitLicenseCard,
gplLicenseCard);
}
}