Skip to content

Commit 9ffb4c6

Browse files
nextcloud#781 add icons to website/twitter on user info screen, cleanup
1 parent 28aa44b commit 9ffb4c6

File tree

17 files changed

+207
-57
lines changed

17 files changed

+207
-57
lines changed

ICONS.txt

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
Standard Google Material Design icons
2+
Copyright (c) 2014, Google (http://www.google.com/design/)
3+
uses the license at https://github.com/google/material-design-icons/blob/master/LICENSE
4+
5+
Twitter icon graphic
6+
Copyright (c) 2014, Austin Andrews (http://materialdesignicons.com/),
7+
with Reserved Font Name Material Design Icons.
8+
9+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
10+
This license is copied below, and is also available with a FAQ at:
11+
http://scripts.sil.org/OFL
12+
13+
14+
-----------------------------------------------------------
15+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
16+
-----------------------------------------------------------
17+
18+
PREAMBLE
19+
The goals of the Open Font License (OFL) are to stimulate worldwide
20+
development of collaborative font projects, to support the font creation
21+
efforts of academic and linguistic communities, and to provide a free and
22+
open framework in which fonts may be shared and improved in partnership
23+
with others.
24+
25+
The OFL allows the licensed fonts to be used, studied, modified and
26+
redistributed freely as long as they are not sold by themselves. The
27+
fonts, including any derivative works, can be bundled, embedded,
28+
redistributed and/or sold with any software provided that any reserved
29+
names are not used by derivative works. The fonts and derivatives,
30+
however, cannot be released under any other type of license. The
31+
requirement for fonts to remain under this license does not apply
32+
to any document created using the fonts or their derivatives.
33+
34+
DEFINITIONS
35+
"Font Software" refers to the set of files released by the Copyright
36+
Holder(s) under this license and clearly marked as such. This may
37+
include source files, build scripts and documentation.
38+
39+
"Reserved Font Name" refers to any names specified as such after the
40+
copyright statement(s).
41+
42+
"Original Version" refers to the collection of Font Software components as
43+
distributed by the Copyright Holder(s).
44+
45+
"Modified Version" refers to any derivative made by adding to, deleting,
46+
or substituting -- in part or in whole -- any of the components of the
47+
Original Version, by changing formats or by porting the Font Software to a
48+
new environment.
49+
50+
"Author" refers to any designer, engineer, programmer, technical
51+
writer or other person who contributed to the Font Software.
52+
53+
PERMISSION & CONDITIONS
54+
Permission is hereby granted, free of charge, to any person obtaining
55+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
56+
redistribute, and sell modified and unmodified copies of the Font
57+
Software, subject to the following conditions:
58+
59+
1) Neither the Font Software nor any of its individual components,
60+
in Original or Modified Versions, may be sold by itself.
61+
62+
2) Original or Modified Versions of the Font Software may be bundled,
63+
redistributed and/or sold with any software, provided that each copy
64+
contains the above copyright notice and this license. These can be
65+
included either as stand-alone text files, human-readable headers or
66+
in the appropriate machine-readable metadata fields within text or
67+
binary files as long as those fields can be easily viewed by the user.
68+
69+
3) No Modified Version of the Font Software may use the Reserved Font
70+
Name(s) unless explicit written permission is granted by the corresponding
71+
Copyright Holder. This restriction only applies to the primary font name as
72+
presented to the users.
73+
74+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
75+
Software shall not be used to promote, endorse or advertise any
76+
Modified Version, except to acknowledge the contribution(s) of the
77+
Copyright Holder(s) and the Author(s) or with their explicit written
78+
permission.
79+
80+
5) The Font Software, modified or unmodified, in part or in whole,
81+
must be distributed entirely under this license, and must not be
82+
distributed under any other license. The requirement for fonts to
83+
remain under this license does not apply to any document created
84+
using the Font Software.
85+
86+
TERMINATION
87+
This license becomes null and void if any of the above conditions are
88+
not met.
89+
90+
DISCLAIMER
91+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
92+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
93+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
94+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
95+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
96+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
97+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
98+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
99+
OTHER DEALINGS IN THE FONT SOFTWARE.

drawable_resources/ic_twitter.svg

+1
Loading

drawable_resources/ic_web.svg

+1
Loading

src/main/java/com/owncloud/android/ui/activity/UserInfoActivity.java

+18-11
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,18 @@ public class UserInfoActivity extends FileActivity {
130130
@BindView(R.id.website_address)
131131
public TextView mWebsiteTextView;
132132

133+
@BindView(R.id.website_icon)
134+
public ImageView mWebsiteIcon;
135+
133136
@BindView(R.id.twitter_container)
134137
public View mTwitterContainer;
135138

136139
@BindView(R.id.twitter_handle)
137140
public TextView mTwitterHandleTextView;
138141

142+
@BindView(R.id.twitter_icon)
143+
public ImageView mTwitterIcon;
144+
139145
@BindView(R.id.empty_list_progress)
140146
public ProgressBar multiListProgressBar;
141147

@@ -252,16 +258,18 @@ private void populateUserInfoUi(UserInfo userInfo) {
252258
populateUserInfoElement(mEmailContainer, mEmailAddressTextView, userInfo.getEmail(), mEmailIcon, tint);
253259
populateUserInfoElement(mAddressContainer, mAddressTextView, userInfo.getAddress(), mAddressIcon, tint);
254260

255-
populateUserInfoElement(mWebsiteContainer, mWebsiteTextView, userInfo.getWebpage());
256-
populateUserInfoElement(mTwitterContainer, mTwitterHandleTextView, userInfo.getTwitter());
257-
}
258-
}
259-
260-
private void populateUserInfoElement(View container, TextView textView, String text) {
261-
if (!TextUtils.isEmpty(text)) {
262-
textView.setText(text);
263-
} else {
264-
container.setVisibility(View.GONE);
261+
populateUserInfoElement(
262+
mWebsiteContainer,
263+
mWebsiteTextView,
264+
DisplayUtils.beautifyURL(userInfo.getWebpage()),
265+
mWebsiteIcon,
266+
tint);
267+
populateUserInfoElement(
268+
mTwitterContainer,
269+
mTwitterHandleTextView,
270+
DisplayUtils.beautifyTwitterHandle(userInfo.getTwitter()),
271+
mTwitterIcon,
272+
tint);
265273
}
266274
}
267275

@@ -275,7 +283,6 @@ private void populateUserInfoElement(View container, TextView textView, String t
275283
}
276284
}
277285

278-
279286
private void changeAccountPassword(Account account) {
280287
Intent updateAccountCredentials = new Intent(UserInfoActivity.this, AuthenticatorActivity.class);
281288
updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, account);

src/main/java/com/owncloud/android/utils/DisplayUtils.java

+48
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ public class DisplayUtils {
7878
private static final int RELATIVE_THRESHOLD_CRITICAL = 95;
7979
private static final String MIME_TYPE_UNKNOWN = "Unknown type";
8080

81+
private static final String HTTP_PROTOCOLL = "http://";
82+
private static final String HTTPS_PROTOCOLL = "https://";
83+
private static final String TWITTER_HANDLE_PREFIX = "@";
84+
8185
private static Map<String, String> mimeType2HumanReadable;
8286

8387
static {
@@ -150,6 +154,50 @@ public static String unixTimeToHumanReadable(long milliseconds) {
150154
DateFormat df = DateFormat.getDateTimeInstance();
151155
return df.format(date);
152156
}
157+
158+
/**
159+
* beautifies a given URL by removing any http/https protocol prefix.
160+
*
161+
* @param url to be beautified url
162+
* @return beautified url
163+
*/
164+
public static String beautifyURL(String url) {
165+
if (url == null) {
166+
return "";
167+
}
168+
169+
if (url.length() >= 7) {
170+
if (url.substring(0,7).equalsIgnoreCase(HTTP_PROTOCOLL)) {
171+
return url.substring(HTTP_PROTOCOLL.length());
172+
}
173+
}
174+
175+
if (url.length() >= 8) {
176+
if (url.substring(0,8).equalsIgnoreCase(HTTPS_PROTOCOLL)) {
177+
return url.substring(HTTPS_PROTOCOLL.length());
178+
}
179+
}
180+
181+
return url;
182+
}
183+
184+
/**
185+
* beautifies a given twitter handle by prefixing it with an @ in case it is missing.
186+
*
187+
* @param handle to be beautified twitter handle
188+
* @return beautified twitter handle
189+
*/
190+
public static String beautifyTwitterHandle(String handle) {
191+
if (handle == null) {
192+
return "";
193+
}
194+
195+
if (handle.startsWith(TWITTER_HANDLE_PREFIX)) {
196+
return handle;
197+
} else {
198+
return TWITTER_HANDLE_PREFIX + handle;
199+
}
200+
}
153201

154202
/**
155203
* Converts an internationalized domain name (IDN) in an URL to and from ASCII/Unicode.
958 Bytes
Loading

src/main/res/drawable-hdpi/ic_web.png

1.18 KB
Loading
664 Bytes
Loading

src/main/res/drawable-mdpi/ic_web.png

761 Bytes
Loading
1.25 KB
Loading
1.64 KB
Loading
1.85 KB
Loading
2.45 KB
Loading
2.43 KB
Loading
3.31 KB
Loading

src/main/res/layout/user_info_layout.xml

+40-15
Original file line numberDiff line numberDiff line change
@@ -174,49 +174,71 @@
174174
android:layout_height="wrap_content"
175175
android:orientation="vertical">
176176

177-
<LinearLayout
177+
<RelativeLayout
178178
android:id="@+id/website_container"
179179
android:layout_width="match_parent"
180-
android:layout_height="wrap_content"
181-
android:layout_margin="@dimen/standard_margin"
182-
android:orientation="vertical">
180+
android:layout_height="wrap_content">
181+
182+
<ImageView
183+
android:id="@+id/website_icon"
184+
android:layout_width="wrap_content"
185+
android:layout_height="wrap_content"
186+
android:src="@drawable/ic_web"
187+
android:layout_margin="@dimen/standard_margin"/>
183188

184189
<TextView
185190
android:id="@+id/website_headline"
186191
android:layout_width="match_parent"
187192
android:layout_height="wrap_content"
193+
android:layout_marginRight="@dimen/standard_margin"
194+
android:layout_marginTop="@dimen/standard_margin"
195+
android:layout_toEndOf="@id/website_icon"
196+
android:layout_toRightOf="@id/website_icon"
197+
android:maxLines="1"
188198
android:text="@string/user_info_website"
189199
android:textAppearance="?android:attr/textAppearanceListItem"/>
190200

191201
<TextView
192202
android:id="@+id/website_address"
193203
android:layout_width="match_parent"
194204
android:layout_height="wrap_content"
205+
android:layout_marginRight="@dimen/standard_margin"
206+
android:layout_marginBottom="@dimen/standard_margin"
207+
android:layout_below="@+id/website_headline"
208+
android:layout_toEndOf="@id/website_icon"
209+
android:layout_toRightOf="@id/website_icon"
195210
android:maxLines="3"
196-
android:text="@string/user_info_twitter"
211+
android:text="@string/user_info_website"
197212
android:textColor="?android:attr/textColorSecondary"/>
198213

199-
</LinearLayout>
214+
</RelativeLayout>
200215

201-
<LinearLayout
216+
<RelativeLayout
202217
android:id="@+id/twitter_container"
203218
android:layout_width="match_parent"
204-
android:layout_height="wrap_content"
205-
android:layout_marginBottom="@dimen/standard_margin"
206-
android:orientation="vertical">
219+
android:layout_height="wrap_content">
207220

208221
<View
209222
android:layout_width="match_parent"
210223
android:layout_height="1dp"
211-
android:layout_marginBottom="@dimen/standard_margin"
212224
android:background="@color/list_divider_background"/>
213225

226+
<ImageView
227+
android:id="@+id/twitter_icon"
228+
android:layout_width="wrap_content"
229+
android:layout_height="wrap_content"
230+
android:layout_margin="@dimen/standard_margin"
231+
android:src="@drawable/ic_twitter"/>
232+
214233
<TextView
215234
android:id="@+id/twitter_headline"
216235
android:layout_width="match_parent"
217236
android:layout_height="wrap_content"
218237
android:layout_marginRight="@dimen/standard_margin"
219-
android:layout_marginLeft="@dimen/standard_margin"
238+
android:layout_marginTop="@dimen/standard_margin"
239+
android:layout_toEndOf="@id/twitter_icon"
240+
android:layout_toRightOf="@id/twitter_icon"
241+
android:maxLines="1"
220242
android:text="Twitter"
221243
android:textAppearance="?android:attr/textAppearanceListItem"/>
222244

@@ -225,12 +247,15 @@
225247
android:layout_width="match_parent"
226248
android:layout_height="wrap_content"
227249
android:layout_marginRight="@dimen/standard_margin"
228-
android:layout_marginLeft="@dimen/standard_margin"
229-
android:maxLines="1"
250+
android:layout_marginBottom="@dimen/standard_margin"
251+
android:layout_below="@+id/twitter_headline"
252+
android:layout_toEndOf="@id/twitter_icon"
253+
android:layout_toRightOf="@id/twitter_icon"
254+
android:maxLines="3"
230255
android:text="@string/placeholder_filename"
231256
android:textColor="?android:attr/textColorSecondary"/>
232257

233-
</LinearLayout>
258+
</RelativeLayout>
234259

235260
</LinearLayout>
236261

src/main/res/layout/user_info_list_item.xml

-31
This file was deleted.

0 commit comments

Comments
 (0)