Skip to content

Commit

Permalink
nextcloud#781 add icons to website/twitter on user info screen, cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyScherzinger committed Mar 27, 2017
1 parent 28aa44b commit 9ffb4c6
Show file tree
Hide file tree
Showing 17 changed files with 207 additions and 57 deletions.
99 changes: 99 additions & 0 deletions ICONS.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
Standard Google Material Design icons
Copyright (c) 2014, Google (http://www.google.com/design/)
uses the license at https://github.com/google/material-design-icons/blob/master/LICENSE

Twitter icon graphic
Copyright (c) 2014, Austin Andrews (http://materialdesignicons.com/),
with Reserved Font Name Material Design Icons.

This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL


-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
1 change: 1 addition & 0 deletions drawable_resources/ic_twitter.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions drawable_resources/ic_web.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,18 @@ public class UserInfoActivity extends FileActivity {
@BindView(R.id.website_address)
public TextView mWebsiteTextView;

@BindView(R.id.website_icon)
public ImageView mWebsiteIcon;

@BindView(R.id.twitter_container)
public View mTwitterContainer;

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

@BindView(R.id.twitter_icon)
public ImageView mTwitterIcon;

@BindView(R.id.empty_list_progress)
public ProgressBar multiListProgressBar;

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

populateUserInfoElement(mWebsiteContainer, mWebsiteTextView, userInfo.getWebpage());
populateUserInfoElement(mTwitterContainer, mTwitterHandleTextView, userInfo.getTwitter());
}
}

private void populateUserInfoElement(View container, TextView textView, String text) {
if (!TextUtils.isEmpty(text)) {
textView.setText(text);
} else {
container.setVisibility(View.GONE);
populateUserInfoElement(
mWebsiteContainer,
mWebsiteTextView,
DisplayUtils.beautifyURL(userInfo.getWebpage()),
mWebsiteIcon,
tint);
populateUserInfoElement(
mTwitterContainer,
mTwitterHandleTextView,
DisplayUtils.beautifyTwitterHandle(userInfo.getTwitter()),
mTwitterIcon,
tint);
}
}

Expand All @@ -275,7 +283,6 @@ private void populateUserInfoElement(View container, TextView textView, String t
}
}


private void changeAccountPassword(Account account) {
Intent updateAccountCredentials = new Intent(UserInfoActivity.this, AuthenticatorActivity.class);
updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, account);
Expand Down
48 changes: 48 additions & 0 deletions src/main/java/com/owncloud/android/utils/DisplayUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ public class DisplayUtils {
private static final int RELATIVE_THRESHOLD_CRITICAL = 95;
private static final String MIME_TYPE_UNKNOWN = "Unknown type";

private static final String HTTP_PROTOCOLL = "http://";
private static final String HTTPS_PROTOCOLL = "https://";
private static final String TWITTER_HANDLE_PREFIX = "@";

private static Map<String, String> mimeType2HumanReadable;

static {
Expand Down Expand Up @@ -150,6 +154,50 @@ public static String unixTimeToHumanReadable(long milliseconds) {
DateFormat df = DateFormat.getDateTimeInstance();
return df.format(date);
}

/**
* beautifies a given URL by removing any http/https protocol prefix.
*
* @param url to be beautified url
* @return beautified url
*/
public static String beautifyURL(String url) {
if (url == null) {
return "";
}

if (url.length() >= 7) {
if (url.substring(0,7).equalsIgnoreCase(HTTP_PROTOCOLL)) {
return url.substring(HTTP_PROTOCOLL.length());
}
}

if (url.length() >= 8) {
if (url.substring(0,8).equalsIgnoreCase(HTTPS_PROTOCOLL)) {
return url.substring(HTTPS_PROTOCOLL.length());
}
}

return url;
}

/**
* beautifies a given twitter handle by prefixing it with an @ in case it is missing.
*
* @param handle to be beautified twitter handle
* @return beautified twitter handle
*/
public static String beautifyTwitterHandle(String handle) {
if (handle == null) {
return "";
}

if (handle.startsWith(TWITTER_HANDLE_PREFIX)) {
return handle;
} else {
return TWITTER_HANDLE_PREFIX + handle;
}
}

/**
* Converts an internationalized domain name (IDN) in an URL to and from ASCII/Unicode.
Expand Down
Binary file added src/main/res/drawable-hdpi/ic_twitter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/res/drawable-hdpi/ic_web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/res/drawable-mdpi/ic_twitter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/res/drawable-mdpi/ic_web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/res/drawable-xhdpi/ic_twitter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/res/drawable-xhdpi/ic_web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/res/drawable-xxhdpi/ic_twitter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/res/drawable-xxhdpi/ic_web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/res/drawable-xxxhdpi/ic_twitter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/res/drawable-xxxhdpi/ic_web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 40 additions & 15 deletions src/main/res/layout/user_info_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -174,49 +174,71 @@
android:layout_height="wrap_content"
android:orientation="vertical">

<LinearLayout
<RelativeLayout
android:id="@+id/website_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/standard_margin"
android:orientation="vertical">
android:layout_height="wrap_content">

<ImageView
android:id="@+id/website_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_web"
android:layout_margin="@dimen/standard_margin"/>

<TextView
android:id="@+id/website_headline"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/standard_margin"
android:layout_marginTop="@dimen/standard_margin"
android:layout_toEndOf="@id/website_icon"
android:layout_toRightOf="@id/website_icon"
android:maxLines="1"
android:text="@string/user_info_website"
android:textAppearance="?android:attr/textAppearanceListItem"/>

<TextView
android:id="@+id/website_address"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/standard_margin"
android:layout_marginBottom="@dimen/standard_margin"
android:layout_below="@+id/website_headline"
android:layout_toEndOf="@id/website_icon"
android:layout_toRightOf="@id/website_icon"
android:maxLines="3"
android:text="@string/user_info_twitter"
android:text="@string/user_info_website"
android:textColor="?android:attr/textColorSecondary"/>

</LinearLayout>
</RelativeLayout>

<LinearLayout
<RelativeLayout
android:id="@+id/twitter_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/standard_margin"
android:orientation="vertical">
android:layout_height="wrap_content">

<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginBottom="@dimen/standard_margin"
android:background="@color/list_divider_background"/>

<ImageView
android:id="@+id/twitter_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/standard_margin"
android:src="@drawable/ic_twitter"/>

<TextView
android:id="@+id/twitter_headline"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/standard_margin"
android:layout_marginLeft="@dimen/standard_margin"
android:layout_marginTop="@dimen/standard_margin"
android:layout_toEndOf="@id/twitter_icon"
android:layout_toRightOf="@id/twitter_icon"
android:maxLines="1"
android:text="Twitter"
android:textAppearance="?android:attr/textAppearanceListItem"/>

Expand All @@ -225,12 +247,15 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/standard_margin"
android:layout_marginLeft="@dimen/standard_margin"
android:maxLines="1"
android:layout_marginBottom="@dimen/standard_margin"
android:layout_below="@+id/twitter_headline"
android:layout_toEndOf="@id/twitter_icon"
android:layout_toRightOf="@id/twitter_icon"
android:maxLines="3"
android:text="@string/placeholder_filename"
android:textColor="?android:attr/textColorSecondary"/>

</LinearLayout>
</RelativeLayout>

</LinearLayout>

Expand Down
31 changes: 0 additions & 31 deletions src/main/res/layout/user_info_list_item.xml

This file was deleted.

0 comments on commit 9ffb4c6

Please sign in to comment.