Selaa lähdekoodia

Only show new app bar for "all_files"

Signed-off-by: Joris Bodin <joris.bodin@infomaniak.com>
Joris Bodin 5 vuotta sitten
vanhempi
commit
96f03d1ec6

+ 8 - 1
src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java

@@ -258,7 +258,7 @@ public class FileDisplayActivity extends FileActivity
         setContentView(R.layout.files);
 
         // setup toolbar
-        setupToolbar();
+        setupToolbar(true);
 
         mMenuButton.setOnClickListener(v -> {
             openDrawer();
@@ -1255,10 +1255,17 @@ public class FileDisplayActivity extends FileActivity
         if (menuItemId == -1) {
             if (MainApp.isOnlyOnDevice()) {
                 setDrawerMenuItemChecked(R.id.nav_on_device);
+                setupToolbar(false);
             } else {
                 setDrawerMenuItemChecked(R.id.nav_all_files);
+                setupToolbar(true);
             }
         } else {
+            if (menuItemId == R.id.nav_all_files) {
+                setupToolbar(true);
+            } else {
+                setupToolbar(false);
+            }
             setDrawerMenuItemChecked(menuItemId);
         }
 

+ 43 - 17
src/main/java/com/owncloud/android/ui/activity/ToolbarActivity.java

@@ -22,9 +22,12 @@
 
 package com.owncloud.android.ui.activity;
 
+import android.animation.AnimatorInflater;
+import android.annotation.SuppressLint;
 import android.graphics.Bitmap;
 import android.graphics.PorterDuff;
 import android.graphics.drawable.Drawable;
+import android.os.Build;
 import android.os.Bundle;
 import android.view.View;
 import android.widget.FrameLayout;
@@ -44,14 +47,17 @@ import com.owncloud.android.utils.ThemeUtils;
 import androidx.annotation.StringRes;
 import androidx.appcompat.app.ActionBar;
 import androidx.appcompat.widget.Toolbar;
+import androidx.core.view.ViewCompat;
 
 /**
- * Base class providing toolbar registration functionality, see {@link #setupToolbar()}.
+ * Base class providing toolbar registration functionality, see {@link #setupToolbar(boolean)}.
  */
 public abstract class ToolbarActivity extends BaseActivity {
     private AppBarLayout mAppBar;
+
     private RelativeLayout mDefaultToolbar;
-    private MaterialCardView mHomeToolbar;
+
+    private MaterialCardView mHomeSearchToolbar;
     protected MaterialButton mMenuButton;
     private MaterialTextView mSearchText;
     protected MaterialButton mSwitchAccountButton;
@@ -60,6 +66,9 @@ public abstract class ToolbarActivity extends BaseActivity {
     private LinearLayout mInfoBox;
     private TextView mInfoBoxMessage;
 
+    private boolean isHomeSearchToolbarShow = false;
+    private boolean isUserInfo = false;
+
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -69,7 +78,7 @@ public abstract class ToolbarActivity extends BaseActivity {
      * Toolbar setup that must be called in implementer's {@link #onCreate} after {@link #setContentView} if they want
      * to use the toolbar.
      */
-    protected void setupToolbar(boolean useBackgroundImage) {
+    protected void setupToolbar(boolean isUserInfo, boolean isHomeSearchToolbarShow) {
         int primaryColor = ThemeUtils.primaryAppbarColor(this);
         int fontColor = ThemeUtils.appBarPrimaryFontColor(this);
 
@@ -78,14 +87,14 @@ public abstract class ToolbarActivity extends BaseActivity {
 
         mAppBar = findViewById(R.id.appbar);
         mDefaultToolbar = findViewById(R.id.default_toolbar);
-        mHomeToolbar = findViewById(R.id.home_toolbar);
+        mHomeSearchToolbar = findViewById(R.id.home_toolbar);
         mMenuButton = findViewById(R.id.menu_button);
         mSearchText = findViewById(R.id.search_text);
         mSwitchAccountButton = findViewById(R.id.switch_account_button);
 
-        if (mAppBar != null) {
-            mAppBar.setElevation(getResources().getDimension(R.dimen.default_appbar_elevation));
-        }
+        this.isHomeSearchToolbarShow = isHomeSearchToolbarShow;
+        this.isUserInfo = isUserInfo;
+        updateActionBarTitleAndHomeButton(null);
 
         mInfoBox = findViewById(R.id.info_box);
         mInfoBoxMessage = findViewById(R.id.info_box_message);
@@ -102,14 +111,14 @@ public abstract class ToolbarActivity extends BaseActivity {
         if (toolbar.getNavigationIcon() != null) {
             ThemeUtils.tintDrawable(toolbar.getNavigationIcon(), fontColor);
         }
-
-        if (!useBackgroundImage) {
-            toolbar.setBackgroundColor(primaryColor);
-        }
     }
 
     public void setupToolbar() {
-        setupToolbar(false);
+        setupToolbar(false, false);
+    }
+
+    public void setupToolbar(boolean homeSearchToolbarShow) {
+        setupToolbar(false, homeSearchToolbarShow);
     }
 
     /**
@@ -122,15 +131,32 @@ public abstract class ToolbarActivity extends BaseActivity {
         title = isRoot ? ThemeUtils.getDefaultDisplayNameForRootFolder(this) : chosenFile.getFileName();
         updateActionBarTitleAndHomeButtonByString(title);
 
-        if (isRoot) {
-            mAppBar.setElevation(0);
+        if (!isUserInfo) {
+            showHomeSearchToolbar(title, isRoot);
+        }
+    }
+
+    @SuppressLint("PrivateResource")
+    private void showHomeSearchToolbar(String title, boolean isRoot) {
+        if (isHomeSearchToolbarShow && isRoot) {
+            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+                mAppBar.setStateListAnimator(AnimatorInflater.loadStateListAnimator(mAppBar.getContext(),
+                                                                                    R.animator.appbar_elevation_off));
+            } else {
+                ViewCompat.setElevation(mAppBar, 0);
+            }
             mDefaultToolbar.setVisibility(View.GONE);
-            mHomeToolbar.setVisibility(View.VISIBLE);
+            mHomeSearchToolbar.setVisibility(View.VISIBLE);
             mSearchText.setText(String.format("Search in %s", title));
         } else {
-            mAppBar.setElevation(getResources().getDimension(R.dimen.default_appbar_elevation));
+            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+                mAppBar.setStateListAnimator(AnimatorInflater.loadStateListAnimator(mAppBar.getContext(),
+                                                                                    R.animator.appbar_elevation_on));
+            } else {
+                ViewCompat.setElevation(mAppBar, getResources().getDimension(R.dimen.design_appbar_elevation));
+            }
             mDefaultToolbar.setVisibility(View.VISIBLE);
-            mHomeToolbar.setVisibility(View.GONE);
+            mHomeSearchToolbar.setVisibility(View.GONE);
         }
     }
 

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

@@ -146,7 +146,7 @@ public class UserInfoActivity extends FileActivity implements Injectable {
         boolean useBackgroundImage = URLUtil.isValidUrl(
                 getStorageManager().getCapability(user.getAccountName()).getServerBackground());
 
-        setupToolbar(useBackgroundImage);
+        setupToolbar(useBackgroundImage, false);
 
 
         // set the back button from action bar

+ 11 - 0
src/main/res/animator/appbar_elevation_off.xml

@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    tools:ignore="PrivateResource">
+    <item>
+        <objectAnimator
+            android:propertyName="elevation"
+            android:valueTo="0dp"
+            android:valueType="floatType" />
+    </item>
+</selector>

+ 11 - 0
src/main/res/animator/appbar_elevation_on.xml

@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    tools:ignore="PrivateResource">
+    <item>
+        <objectAnimator
+            android:propertyName="elevation"
+            android:valueTo="@dimen/design_appbar_elevation"
+            android:valueType="floatType" />
+    </item>
+</selector>

+ 6 - 7
src/main/res/layout/accounts_layout.xml

@@ -26,13 +26,12 @@
 	android:layout_height="fill_parent"
 	android:orientation="vertical">
 
-	<include
-		layout="@layout/toolbar_standard"/>
+    <include layout="@layout/toolbar_standard" />
 
-	<androidx.recyclerview.widget.RecyclerView
-		android:id="@+id/account_list"
-		android:layout_width="fill_parent"
-		android:layout_height="fill_parent"
-		android:divider="@null" />
+    <androidx.recyclerview.widget.RecyclerView
+        android:id="@+id/account_list"
+        android:layout_width="fill_parent"
+        android:layout_height="fill_parent"
+        android:divider="@null" />
 
 </LinearLayout>

+ 2 - 4
src/main/res/layout/activity_list_layout.xml

@@ -30,14 +30,12 @@
         android:layout_height="match_parent"
         android:orientation="vertical">
 
-        <include
-            android:id="@+id/navigation_bar"
-            layout="@layout/toolbar_standard" />
+        <include layout="@layout/toolbar_standard" />
 
         <FrameLayout
             android:layout_width="match_parent"
             android:layout_height="match_parent"
-            android:layout_below="@+id/navigation_bar">
+            android:layout_below="@id/appbar">
 
             <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
                 android:id="@+id/swipe_containing_list"

+ 1 - 2
src/main/res/layout/community_layout.xml

@@ -32,8 +32,7 @@
         android:layout_height="match_parent"
         android:orientation="vertical">
 
-        <include
-            layout="@layout/toolbar_standard"/>
+        <include layout="@layout/toolbar_standard" />
 
         <ScrollView
             android:id="@+id/scrollView"

+ 3 - 5
src/main/res/layout/contacts_preference.xml

@@ -32,15 +32,13 @@
         android:layout_height="match_parent"
         android:orientation="vertical">
 
-        <include
-            android:id="@+id/navigation_bar"
-            layout="@layout/toolbar_standard"/>
+        <include layout="@layout/toolbar_standard" />
 
         <FrameLayout
+            android:id="@+id/frame_container"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
-            android:layout_below="@+id/navigation_bar"
-            android:id="@+id/frame_container">
+            android:layout_below="@id/appbar">
 
         </FrameLayout>
     </RelativeLayout>

+ 2 - 3
src/main/res/layout/externalsite_webview.xml

@@ -32,13 +32,12 @@
         android:layout_height="match_parent"
         android:orientation="vertical">
 
-        <include
-            layout="@layout/toolbar_standard"/>
+        <include layout="@layout/toolbar_standard" />
 
         <WebView
             android:id="@+id/webView"
             android:layout_width="match_parent"
-            android:layout_height="match_parent"/>
+            android:layout_height="match_parent" />
 
     </LinearLayout>
 

+ 6 - 7
src/main/res/layout/files_folder_picker.xml

@@ -22,14 +22,13 @@
     android:layout_height="match_parent"
     android:orientation="vertical">
 
-    <include
-        layout="@layout/toolbar_standard" />
+    <include layout="@layout/toolbar_standard" />
 
-	<FrameLayout
-		android:layout_width="match_parent"
-		android:layout_height="0dp"
-        android:layout_weight="1"
-		android:id="@+id/fragment_container" />
+    <FrameLayout
+        android:id="@+id/fragment_container"
+        android:layout_width="match_parent"
+        android:layout_height="0dp"
+        android:layout_weight="1" />
 
 	<LinearLayout
 		android:layout_width="match_parent"

+ 2 - 3
src/main/res/layout/files_picker.xml

@@ -25,14 +25,13 @@
     xmlns:app="http://schemas.android.com/apk/res-auto"
     android:orientation="vertical">
 
-    <include
-        layout="@layout/toolbar_standard"/>
+    <include layout="@layout/toolbar_standard" />
 
     <FrameLayout
         android:id="@+id/fragment_container"
         android:layout_width="match_parent"
         android:layout_height="0dp"
-        android:layout_weight="1"/>
+        android:layout_weight="1" />
 
     <LinearLayout
         android:layout_width="match_parent"

+ 2 - 4
src/main/res/layout/notifications_layout.xml

@@ -31,14 +31,12 @@
         android:layout_height="match_parent"
         android:orientation="vertical">
 
-        <include
-            android:id="@+id/navigation_bar"
-            layout="@layout/toolbar_standard"/>
+        <include layout="@layout/toolbar_standard" />
 
         <FrameLayout
             android:layout_width="match_parent"
             android:layout_height="match_parent"
-            android:layout_below="@+id/navigation_bar">
+            android:layout_below="@id/appbar">
 
             <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
                 android:id="@+id/swipe_containing_list"

+ 2 - 1
src/main/res/layout/toolbar_standard.xml

@@ -24,7 +24,7 @@
     android:id="@+id/appbar"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
-    android:background="@color/appbar"
+    android:background="@color/bg_default"
     android:theme="@style/ThemeOverlay.MaterialComponents.Dark.ActionBar"
     tools:viewBindingIgnore="true">
 
@@ -68,6 +68,7 @@
         android:layout_marginTop="6dp"
         android:layout_marginEnd="16dp"
         android:visibility="gone"
+        app:background="@color/appbar"
         app:strokeColor="#E0E0E0"
         app:strokeWidth="1dp">
 

+ 10 - 12
src/main/res/layout/toolbar_user_information.xml

@@ -1,5 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
+<?xml version="1.0" encoding="utf-8"?><!--
   Nextcloud Android client application
 
   Copyright (C) 2017 Andy Scherzinger
@@ -18,8 +17,7 @@
   You should have received a copy of the GNU Affero General Public
   License along with this program.  If not, see <http://www.gnu.org/licenses/>.
 -->
-<com.google.android.material.appbar.AppBarLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
+<com.google.android.material.appbar.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
     android:id="@+id/appbar"
@@ -36,7 +34,7 @@
             android:layout_width="match_parent"
             android:layout_height="match_parent"
             android:contentDescription="@string/drawer_header_background"
-            android:scaleType="centerCrop"/>
+            android:scaleType="centerCrop" />
 
         <androidx.appcompat.widget.Toolbar
             android:id="@id/toolbar"
@@ -53,9 +51,9 @@
             <RelativeLayout
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:layout_marginBottom="@dimen/toolbar_user_information_layout_margin"
-                android:layout_marginEnd="@dimen/standard_half_margin"
                 android:layout_marginStart="@dimen/toolbar_user_information_layout_margin"
+                android:layout_marginEnd="@dimen/standard_half_margin"
+                android:layout_marginBottom="@dimen/toolbar_user_information_layout_margin"
                 android:gravity="bottom"
                 android:orientation="horizontal"
                 android:weightSum="1">
@@ -70,7 +68,7 @@
                         android:layout_width="@dimen/nav_drawer_header_avatar"
                         android:layout_height="@dimen/nav_drawer_header_avatar"
                         android:contentDescription="@string/avatar"
-                        android:src="@drawable/account_circle_white"/>
+                        android:src="@drawable/account_circle_white" />
                 </FrameLayout>
 
                 <LinearLayout
@@ -95,7 +93,7 @@
                         android:textColor="@color/white"
                         android:textSize="@dimen/drawer_header_text"
                         android:textStyle="bold"
-                        tools:text="Max Mustermann"/>
+                        tools:text="Max Mustermann" />
 
                     <TextView
                         android:id="@+id/userinfo_username"
@@ -110,14 +108,14 @@
                         android:shadowRadius="2"
                         android:textColor="@color/white"
                         android:textSize="@dimen/drawer_header_subtext"
-                        tools:text="max@127.0.0.1/nextcloud"/>
+                        tools:text="max@127.0.0.1/nextcloud" />
                 </LinearLayout>
 
             </RelativeLayout>
 
-        <include layout="@layout/info_box"/>
+            <include layout="@layout/info_box" />
 
-    </LinearLayout>
+        </LinearLayout>
     </RelativeLayout>
 
 </com.google.android.material.appbar.AppBarLayout>

+ 2 - 4
src/main/res/layout/trashbin_activity.xml

@@ -33,14 +33,12 @@
         android:layout_height="match_parent"
         android:orientation="vertical">
 
-        <include
-            android:id="@+id/navigation_bar"
-            layout="@layout/toolbar_standard"/>
+        <include layout="@layout/toolbar_standard" />
 
         <FrameLayout
             android:layout_width="match_parent"
             android:layout_height="match_parent"
-            android:layout_below="@+id/navigation_bar">
+            android:layout_below="@id/appbar">
 
             <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
                 android:id="@+id/swipe_containing_list"

+ 3 - 4
src/main/res/layout/upload_files_layout.xml

@@ -23,15 +23,14 @@
     android:layout_height="fill_parent"
     android:orientation="vertical">
 
-    <include
-        layout="@layout/toolbar_standard" />
+    <include layout="@layout/toolbar_standard" />
 
     <fragment
         android:id="@+id/local_files_list"
+        class="com.owncloud.android.ui.fragment.LocalFileListFragment"
         android:layout_width="match_parent"
         android:layout_height="0dp"
-        android:layout_weight="1"
-        class="com.owncloud.android.ui.fragment.LocalFileListFragment" />
+        android:layout_weight="1" />
 
     <LinearLayout
         android:layout_width="match_parent"

+ 2 - 4
src/main/res/layout/upload_list_layout.xml

@@ -30,14 +30,12 @@
         android:layout_height="match_parent"
         android:orientation="vertical">
 
-        <include
-            android:id="@+id/navigation_bar"
-            layout="@layout/toolbar_standard"/>
+        <include layout="@layout/toolbar_standard" />
 
         <FrameLayout
             android:layout_width="match_parent"
             android:layout_height="match_parent"
-            android:layout_below="@+id/navigation_bar">
+            android:layout_below="@id/appbar">
 
             <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
                 android:id="@+id/swipe_containing_list"

+ 6 - 6
src/main/res/layout/uploader_layout.xml

@@ -24,13 +24,13 @@
     android:layout_height="fill_parent"
     android:orientation="vertical">
 
-    <include
-        layout="@layout/toolbar_standard" />
+    <include layout="@layout/toolbar_standard" />
 
-	<FrameLayout android:layout_height="0dp"
-		android:layout_width="fill_parent"
-		android:id="@+id/frameLayout1"
-		android:layout_weight="1">
+    <FrameLayout
+        android:id="@+id/frameLayout1"
+        android:layout_width="fill_parent"
+        android:layout_height="0dp"
+        android:layout_weight="1">
 
 		<ListView android:id="@android:id/list"
 			android:layout_width="fill_parent"

+ 2 - 3
src/main/res/layout/user_info_layout.xml

@@ -25,10 +25,9 @@
                                                  android:layout_height="match_parent"
                                                  android:background="@color/bg_default">
 
-    <include
-        layout="@layout/toolbar_user_information"/>
+    <include layout="@layout/toolbar_user_information" />
 
-    <include layout="@layout/empty_list"/>
+    <include layout="@layout/empty_list" />
 
     <androidx.core.widget.NestedScrollView
         android:layout_width="match_parent"

+ 0 - 1
src/main/res/values/dims.xml

@@ -145,5 +145,4 @@
     <dimen name="button_corner_radius">24dp</dimen>
     <integer name="media_grid_width">4</integer>
     <dimen name="copy_internal_link_padding">10dp</dimen>
-    <dimen name="default_appbar_elevation">4dp</dimen>
 </resources>