Browse Source

#781 add icons to website/twitter on user info screen, cleanup

AndyScherzinger 8 years ago
parent
commit
9ffb4c6639

+ 99 - 0
ICONS.txt

@@ -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 - 0
drawable_resources/ic_twitter.svg

@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="24" height="24" viewBox="0 0 24 24"><path d="M22.46,6C21.69,6.35 20.86,6.58 20,6.69C20.88,6.16 21.56,5.32 21.88,4.31C21.05,4.81 20.13,5.16 19.16,5.36C18.37,4.5 17.26,4 16,4C13.65,4 11.73,5.92 11.73,8.29C11.73,8.63 11.77,8.96 11.84,9.27C8.28,9.09 5.11,7.38 3,4.79C2.63,5.42 2.42,6.16 2.42,6.94C2.42,8.43 3.17,9.75 4.33,10.5C3.62,10.5 2.96,10.3 2.38,10C2.38,10 2.38,10 2.38,10.03C2.38,12.11 3.86,13.85 5.82,14.24C5.46,14.34 5.08,14.39 4.69,14.39C4.42,14.39 4.15,14.36 3.89,14.31C4.43,16 6,17.26 7.89,17.29C6.43,18.45 4.58,19.13 2.56,19.13C2.22,19.13 1.88,19.11 1.54,19.07C3.44,20.29 5.7,21 8.12,21C16,21 20.33,14.46 20.33,8.79C20.33,8.6 20.33,8.42 20.32,8.23C21.16,7.63 21.88,6.87 22.46,6Z" /></svg>

+ 1 - 0
drawable_resources/ic_web.svg

@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="24" height="24" viewBox="0 0 24 24"><path d="M16.36,14C16.44,13.34 16.5,12.68 16.5,12C16.5,11.32 16.44,10.66 16.36,10H19.74C19.9,10.64 20,11.31 20,12C20,12.69 19.9,13.36 19.74,14M14.59,19.56C15.19,18.45 15.65,17.25 15.97,16H18.92C17.96,17.65 16.43,18.93 14.59,19.56M14.34,14H9.66C9.56,13.34 9.5,12.68 9.5,12C9.5,11.32 9.56,10.65 9.66,10H14.34C14.43,10.65 14.5,11.32 14.5,12C14.5,12.68 14.43,13.34 14.34,14M12,19.96C11.17,18.76 10.5,17.43 10.09,16H13.91C13.5,17.43 12.83,18.76 12,19.96M8,8H5.08C6.03,6.34 7.57,5.06 9.4,4.44C8.8,5.55 8.35,6.75 8,8M5.08,16H8C8.35,17.25 8.8,18.45 9.4,19.56C7.57,18.93 6.03,17.65 5.08,16M4.26,14C4.1,13.36 4,12.69 4,12C4,11.31 4.1,10.64 4.26,10H7.64C7.56,10.66 7.5,11.32 7.5,12C7.5,12.68 7.56,13.34 7.64,14M12,4.03C12.83,5.23 13.5,6.57 13.91,8H10.09C10.5,6.57 11.17,5.23 12,4.03M18.92,8H15.97C15.65,6.75 15.19,5.55 14.59,4.44C16.43,5.07 17.96,6.34 18.92,8M12,2C6.47,2 2,6.5 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z" /></svg>

+ 18 - 11
src/main/java/com/owncloud/android/ui/activity/UserInfoActivity.java

@@ -130,12 +130,18 @@ public class UserInfoActivity extends FileActivity {
     @BindView(R.id.website_address)
     @BindView(R.id.website_address)
     public TextView mWebsiteTextView;
     public TextView mWebsiteTextView;
 
 
+    @BindView(R.id.website_icon)
+    public ImageView mWebsiteIcon;
+
     @BindView(R.id.twitter_container)
     @BindView(R.id.twitter_container)
     public View mTwitterContainer;
     public View mTwitterContainer;
 
 
     @BindView(R.id.twitter_handle)
     @BindView(R.id.twitter_handle)
     public TextView mTwitterHandleTextView;
     public TextView mTwitterHandleTextView;
 
 
+    @BindView(R.id.twitter_icon)
+    public ImageView mTwitterIcon;
+
     @BindView(R.id.empty_list_progress)
     @BindView(R.id.empty_list_progress)
     public ProgressBar multiListProgressBar;
     public ProgressBar multiListProgressBar;
 
 
@@ -252,16 +258,18 @@ public class UserInfoActivity extends FileActivity {
             populateUserInfoElement(mEmailContainer, mEmailAddressTextView, userInfo.getEmail(), mEmailIcon, tint);
             populateUserInfoElement(mEmailContainer, mEmailAddressTextView, userInfo.getEmail(), mEmailIcon, tint);
             populateUserInfoElement(mAddressContainer, mAddressTextView, userInfo.getAddress(), mAddressIcon, 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);
         }
         }
     }
     }
 
 
@@ -275,7 +283,6 @@ public class UserInfoActivity extends FileActivity {
         }
         }
     }
     }
 
 
-
     private void changeAccountPassword(Account account) {
     private void changeAccountPassword(Account account) {
         Intent updateAccountCredentials = new Intent(UserInfoActivity.this, AuthenticatorActivity.class);
         Intent updateAccountCredentials = new Intent(UserInfoActivity.this, AuthenticatorActivity.class);
         updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, account);
         updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, account);

+ 48 - 0
src/main/java/com/owncloud/android/utils/DisplayUtils.java

@@ -78,6 +78,10 @@ public class DisplayUtils {
     private static final int RELATIVE_THRESHOLD_CRITICAL = 95;
     private static final int RELATIVE_THRESHOLD_CRITICAL = 95;
     private static final String MIME_TYPE_UNKNOWN = "Unknown type";
     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;
     private static Map<String, String> mimeType2HumanReadable;
 
 
     static {
     static {
@@ -150,6 +154,50 @@ public class DisplayUtils {
         DateFormat df = DateFormat.getDateTimeInstance();
         DateFormat df = DateFormat.getDateTimeInstance();
         return df.format(date);
         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.
      * Converts an internationalized domain name (IDN) in an URL to and from ASCII/Unicode.

BIN
src/main/res/drawable-hdpi/ic_twitter.png


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


BIN
src/main/res/drawable-mdpi/ic_twitter.png


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


BIN
src/main/res/drawable-xhdpi/ic_twitter.png


BIN
src/main/res/drawable-xhdpi/ic_web.png


BIN
src/main/res/drawable-xxhdpi/ic_twitter.png


BIN
src/main/res/drawable-xxhdpi/ic_web.png


BIN
src/main/res/drawable-xxxhdpi/ic_twitter.png


BIN
src/main/res/drawable-xxxhdpi/ic_web.png


+ 40 - 15
src/main/res/layout/user_info_layout.xml

@@ -174,17 +174,27 @@
                         android:layout_height="wrap_content"
                         android:layout_height="wrap_content"
                         android:orientation="vertical">
                         android:orientation="vertical">
 
 
-                        <LinearLayout
+                        <RelativeLayout
                             android:id="@+id/website_container"
                             android:id="@+id/website_container"
                             android:layout_width="match_parent"
                             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
                             <TextView
                                 android:id="@+id/website_headline"
                                 android:id="@+id/website_headline"
                                 android:layout_width="match_parent"
                                 android:layout_width="match_parent"
                                 android:layout_height="wrap_content"
                                 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:text="@string/user_info_website"
                                 android:textAppearance="?android:attr/textAppearanceListItem"/>
                                 android:textAppearance="?android:attr/textAppearanceListItem"/>
 
 
@@ -192,31 +202,43 @@
                                 android:id="@+id/website_address"
                                 android:id="@+id/website_address"
                                 android:layout_width="match_parent"
                                 android:layout_width="match_parent"
                                 android:layout_height="wrap_content"
                                 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:maxLines="3"
-                                android:text="@string/user_info_twitter"
+                                android:text="@string/user_info_website"
                                 android:textColor="?android:attr/textColorSecondary"/>
                                 android:textColor="?android:attr/textColorSecondary"/>
 
 
-                        </LinearLayout>
+                        </RelativeLayout>
 
 
-                        <LinearLayout
+                        <RelativeLayout
                             android:id="@+id/twitter_container"
                             android:id="@+id/twitter_container"
                             android:layout_width="match_parent"
                             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
                             <View
                                 android:layout_width="match_parent"
                                 android:layout_width="match_parent"
                                 android:layout_height="1dp"
                                 android:layout_height="1dp"
-                                android:layout_marginBottom="@dimen/standard_margin"
                                 android:background="@color/list_divider_background"/>
                                 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
                             <TextView
                                 android:id="@+id/twitter_headline"
                                 android:id="@+id/twitter_headline"
                                 android:layout_width="match_parent"
                                 android:layout_width="match_parent"
                                 android:layout_height="wrap_content"
                                 android:layout_height="wrap_content"
                                 android:layout_marginRight="@dimen/standard_margin"
                                 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:text="Twitter"
                                 android:textAppearance="?android:attr/textAppearanceListItem"/>
                                 android:textAppearance="?android:attr/textAppearanceListItem"/>
 
 
@@ -225,12 +247,15 @@
                                 android:layout_width="match_parent"
                                 android:layout_width="match_parent"
                                 android:layout_height="wrap_content"
                                 android:layout_height="wrap_content"
                                 android:layout_marginRight="@dimen/standard_margin"
                                 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:text="@string/placeholder_filename"
                                 android:textColor="?android:attr/textColorSecondary"/>
                                 android:textColor="?android:attr/textColorSecondary"/>
 
 
-                        </LinearLayout>
+                        </RelativeLayout>
 
 
                     </LinearLayout>
                     </LinearLayout>
 
 

+ 0 - 31
src/main/res/layout/user_info_list_item.xml

@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-                android:id="@+id/user_info_item_layout"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:orientation="vertical">
-
-    <TextView
-        android:id="@+id/attribute_headline_tv"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_marginTop="8dp"
-        android:layout_marginRight="8dp"
-        android:layout_marginLeft="8dp"
-        android:layout_marginBottom="4dp"
-        android:textSize="20sp"
-        android:textStyle="bold"
-        android:text="@string/placeholder_filename"/>
-
-    <TextView
-        android:id="@+id/attribute_value_tv"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_below="@id/attribute_headline_tv"
-        android:layout_marginLeft="8dp"
-        android:layout_marginRight="8dp"
-        android:layout_marginBottom="8dp"
-        android:textSize="16sp"
-        android:text="@string/placeholder_filename"/>
-
-</RelativeLayout>