Browse Source

initial (functionless) account switcher for the drawer header and display size depending header sizing

Andy Scherzinger 9 years ago
parent
commit
ce803aa4e0

BIN
res/drawable-hdpi/ic_down.png


BIN
res/drawable-hdpi/ic_up.png


BIN
res/drawable-mdpi/ic_down.png


BIN
res/drawable-mdpi/ic_up.png


BIN
res/drawable-xhdpi/ic_down.png


BIN
res/drawable-xhdpi/ic_up.png


BIN
res/drawable-xxhdpi/ic_down.png


BIN
res/drawable-xxhdpi/ic_up.png


+ 69 - 28
res/layout/drawer_header.xml

@@ -16,35 +16,76 @@
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
   -->
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="fill_parent"
-    android:layout_height="100dp"
-    android:paddingTop="@dimen/standard_padding"
-    android:paddingBottom="@dimen/standard_padding"
-    android:background="@color/drawer_header_color">
-
-    <ImageView
-        android:id="@+id/itemIcon"
-        android:layout_width="24dp"
-        android:layout_height="24dp"
-        android:layout_marginLeft="@dimen/standard_padding"
-        android:layout_marginBottom="3dp"
-        android:layout_gravity="bottom"
-        android:src="@drawable/ic_account_circle"
-        />
+              android:layout_width="match_parent"
+              android:layout_height="@dimen/nav_drawer_header_height"
+              android:paddingBottom="@dimen/standard_padding"
+              android:paddingRight="@dimen/standard_padding"
+              android:paddingLeft="@dimen/standard_padding"
+              android:background="@color/drawer_header_color">
 
-    <TextView
-        android:id="@+id/drawer_username"
-        android:layout_width="wrap_content"
+    <LinearLayout
+        android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:layout_gravity="bottom"
-        android:gravity="bottom"
-        android:orientation="vertical"
-        android:text="@string/app_name"
-        android:textColor="#FFF"
-        android:paddingLeft="22dp"
-        android:paddingRight="@dimen/standard_padding"
-        android:textSize="24sp"
-        android:ellipsize="end"
-        android:singleLine="true"
-        />
+        >
+
+        <ImageView
+            android:id="@+id/drawer_usericon"
+            android:layout_width="24dp"
+            android:layout_height="24dp"
+            android:layout_gravity="center_vertical"
+            android:src="@drawable/ic_account_circle"
+            />
+
+        <LinearLayout
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_weight="1"
+            android:gravity="center_vertical"
+            android:paddingLeft="@dimen/standard_half_padding"
+            android:paddingRight="@dimen/standard_half_padding"
+            android:orientation="vertical">
+
+            <TextView
+                android:id="@+id/drawer_username"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:ellipsize="end"
+                android:singleLine="true"
+                android:shadowColor="@color/black"
+                android:shadowDx="0.5"
+                android:shadowDy="0"
+                android:shadowRadius="2"
+                android:textColor="@android:color/white"
+                android:textSize="14sp"
+                android:text="@string/app_name"
+                android:textStyle="bold"/>
+
+            <TextView
+                android:id="@+id/drawer_username_full"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:ellipsize="end"
+                android:lines="1"
+                android:maxLines="1"
+                android:shadowColor="@color/black"
+                android:shadowDx="0.5"
+                android:shadowDy="0"
+                android:shadowRadius="2"
+                android:textColor="@android:color/white"
+                android:textSize="12sp"
+                android:text="@string/app_name"/>
+
+        </LinearLayout>
+
+        <ImageView
+            android:id="@+id/drawer_manage_accounts"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:contentDescription="@string/drawer_manage_accounts"
+            android:src="@drawable/ic_down"
+            android:layout_gravity="center_vertical"/>
+
+    </LinearLayout>
+
 </LinearLayout>

+ 22 - 0
res/values-sw360dp/dims.xml

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ownCloud Android client application
+
+  Copyright (C) 2016 ownCloud Inc.
+
+  This program is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License version 2,
+  as published by the Free Software Foundation.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+-->
+<resources>
+    <!-- Default screen margins, per the Android Design guidelines. -->
+    <dimen name="nav_drawer_header_height">164dp</dimen>
+</resources>

+ 1 - 0
res/values/dims.xml

@@ -21,6 +21,7 @@
     <dimen name="activity_horizontal_margin">@dimen/standard_padding</dimen>
     <dimen name="activity_vertical_margin">@dimen/standard_padding</dimen>
     <dimen name="nav_drawer_width">260dp</dimen>
+    <dimen name="nav_drawer_header_height">140dp</dimen>
 
     <dimen name="file_icon_size">32dp</dimen>
     <dimen name="file_icon_size_grid">128dp</dimen>

+ 1 - 0
res/values/strings.xml

@@ -347,6 +347,7 @@
 
     <string name="prefs_category_accounts">Accounts</string>
     <string name="prefs_add_account">Add account</string>
+    <string name="drawer_manage_accounts">Manage accounts</string>
     <string name="auth_redirect_non_secure_connection_title">Secure connection is redirected through an unsecured route.</string>
 
 	<string name="actionbar_logger">Logs</string>

+ 3 - 0
src/com/owncloud/android/ui/activity/DrawerActivity.java

@@ -181,6 +181,9 @@ public abstract class DrawerActivity extends ToolbarActivity {
         if (mDrawerLayout != null && accountName != null) {
             TextView username = (TextView) ((NavigationView) findViewById(R.id.nav_view))
                     .getHeaderView(0).findViewById(R.id.drawer_username);
+            TextView usernameFull = (TextView) ((NavigationView) findViewById(R.id.nav_view))
+                    .getHeaderView(0).findViewById(R.id.drawer_username_full);
+            usernameFull.setText(accountName);
             int lastAtPos = accountName.lastIndexOf("@");
             username.setText(accountName.substring(0, lastAtPos));
         }