Browse Source

change trashbin view to new layout

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
tobiasKaminsky 5 years ago
parent
commit
5a76122a94

+ 12 - 8
src/main/java/com/owncloud/android/ui/trashbin/TrashbinActivity.java

@@ -32,6 +32,7 @@ import android.widget.ImageView;
 import android.widget.PopupMenu;
 import android.widget.PopupMenu;
 import android.widget.TextView;
 import android.widget.TextView;
 
 
+import com.google.android.material.button.MaterialButton;
 import com.google.android.material.snackbar.Snackbar;
 import com.google.android.material.snackbar.Snackbar;
 import com.nextcloud.client.account.CurrentAccountProvider;
 import com.nextcloud.client.account.CurrentAccountProvider;
 import com.nextcloud.client.account.User;
 import com.nextcloud.client.account.User;
@@ -53,8 +54,6 @@ import java.util.List;
 
 
 import javax.inject.Inject;
 import javax.inject.Inject;
 
 
-import androidx.fragment.app.FragmentManager;
-import androidx.fragment.app.FragmentTransaction;
 import androidx.recyclerview.widget.LinearLayoutManager;
 import androidx.recyclerview.widget.LinearLayoutManager;
 import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
 import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
 import butterknife.BindString;
 import butterknife.BindString;
@@ -88,6 +87,9 @@ public class TrashbinActivity extends FileActivity implements
     @BindView(R.id.swipe_containing_list)
     @BindView(R.id.swipe_containing_list)
     public SwipeRefreshLayout swipeListRefreshLayout;
     public SwipeRefreshLayout swipeListRefreshLayout;
 
 
+    @BindView(R.id.sort_button)
+    public MaterialButton sortButton;
+
     @BindString(R.string.trashbin_empty_headline)
     @BindString(R.string.trashbin_empty_headline)
     public String noResultsHeadline;
     public String noResultsHeadline;
 
 
@@ -148,6 +150,13 @@ public class TrashbinActivity extends FileActivity implements
         ThemeUtils.colorSwipeRefreshLayout(this, swipeListRefreshLayout);
         ThemeUtils.colorSwipeRefreshLayout(this, swipeListRefreshLayout);
         swipeListRefreshLayout.setOnRefreshListener(this::loadFolder);
         swipeListRefreshLayout.setOnRefreshListener(this::loadFolder);
 
 
+        sortButton.setOnClickListener(l ->
+                                          openSortingOrderDialogFragment(getSupportFragmentManager(),
+                                                                         preferences.getSortOrderByType(
+                                                                             FileSortOrder.Type.trashBinView,
+                                                                             FileSortOrder.sort_new_to_old))
+                                     );
+
         loadFolder();
         loadFolder();
     }
     }
 
 
@@ -177,12 +186,7 @@ public class TrashbinActivity extends FileActivity implements
                     openDrawer();
                     openDrawer();
                 }
                 }
                 break;
                 break;
-            case R.id.action_sort: {
-                openSortingOrderDialogFragment(getSupportFragmentManager(),
-                                               preferences.getSortOrderByType(FileSortOrder.Type.trashBinView,
-                                                                              FileSortOrder.sort_new_to_old));
-                break;
-            }
+
             case R.id.action_empty_trashbin:
             case R.id.action_empty_trashbin:
                 trashbinPresenter.emptyTrashbin();
                 trashbinPresenter.emptyTrashbin();
                 break;
                 break;

+ 41 - 6
src/main/res/layout/trashbin_activity.xml

@@ -20,6 +20,7 @@
   along with this program. If not, see <https://www.gnu.org/licenses/>.
   along with this program. If not, see <https://www.gnu.org/licenses/>.
 -->
 -->
 <androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
 <androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
     android:id="@+id/drawer_layout"
     android:id="@+id/drawer_layout"
     android:layout_width="match_parent"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:layout_height="match_parent"
@@ -30,33 +31,67 @@
     <!-- The main content view -->
     <!-- The main content view -->
     <RelativeLayout
     <RelativeLayout
         android:layout_width="match_parent"
         android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:orientation="vertical">
+        android:layout_height="match_parent">
 
 
         <include layout="@layout/toolbar_standard" />
         <include layout="@layout/toolbar_standard" />
 
 
-        <FrameLayout
+        <androidx.coordinatorlayout.widget.CoordinatorLayout
+            android:id="@+id/list_fragment_layout"
             android:layout_width="match_parent"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
             android:layout_height="match_parent"
             android:layout_below="@id/appbar">
             android:layout_below="@id/appbar">
 
 
+            <com.google.android.material.appbar.AppBarLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:background="@color/bg_default"
+                app:elevation="0dp">
+
+                <androidx.constraintlayout.widget.ConstraintLayout
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    app:layout_scrollFlags="scroll|enterAlways|snap">
+
+                    <com.google.android.material.button.MaterialButton
+                        android:id="@+id/sort_button"
+                        style="@style/Widget.MaterialComponents.Button.TextButton"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_marginStart="8dp"
+                        android:contentDescription="@string/actionbar_sort"
+                        android:minWidth="0dp"
+                        android:text="@string/menu_item_sort_by_date_newest_first"
+                        android:textAlignment="textStart"
+                        android:textAllCaps="false"
+                        android:textColor="@color/fontAppbar"
+                        android:textSize="14sp"
+                        app:icon="@drawable/ic_keyboard_arrow_down"
+                        app:iconGravity="textEnd"
+                        app:iconSize="16dp"
+                        app:iconTint="@color/fontAppbar"
+                        app:layout_constraintBottom_toBottomOf="parent"
+                        app:layout_constraintStart_toStartOf="parent"
+                        app:layout_constraintTop_toTopOf="parent" />
+                </androidx.constraintlayout.widget.ConstraintLayout>
+            </com.google.android.material.appbar.AppBarLayout>
+
             <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
             <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
                 android:id="@+id/swipe_containing_list"
                 android:id="@+id/swipe_containing_list"
                 android:layout_width="match_parent"
                 android:layout_width="match_parent"
                 android:layout_height="match_parent"
                 android:layout_height="match_parent"
                 android:footerDividersEnabled="false"
                 android:footerDividersEnabled="false"
-                android:visibility="visible">
+                android:visibility="visible"
+                app:layout_behavior="@string/appbar_scrolling_view_behavior">
 
 
                 <com.owncloud.android.ui.EmptyRecyclerView
                 <com.owncloud.android.ui.EmptyRecyclerView
                     android:id="@android:id/list"
                     android:id="@android:id/list"
                     android:layout_width="match_parent"
                     android:layout_width="match_parent"
                     android:layout_height="match_parent"/>
                     android:layout_height="match_parent"/>
-
             </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
             </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
 
 
             <include layout="@layout/empty_list"/>
             <include layout="@layout/empty_list"/>
 
 
-        </FrameLayout>
+        </androidx.coordinatorlayout.widget.CoordinatorLayout>
 
 
     </RelativeLayout>
     </RelativeLayout>
 
 

+ 3 - 11
src/main/res/menu/activity_trashbin.xml

@@ -5,17 +5,17 @@
   @author Tobias Kaminsky
   @author Tobias Kaminsky
   Copyright (C) 2018 Tobias Kaminsky
   Copyright (C) 2018 Tobias Kaminsky
   Copyright (C) 2018 Nextcloud GmbH.
   Copyright (C) 2018 Nextcloud GmbH.
- 
+
   This program is free software: you can redistribute it and/or modify
   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.
   (at your option) any later version.
- 
+
   This program is distributed in the hope that it will be useful,
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   GNU General Public License for more details.
   GNU General Public License for more details.
- 
+
   You should have received a copy of the GNU General Public License
   You should have received a copy of the GNU General Public License
   along with this program. If not, see <https://www.gnu.org/licenses/>.
   along with this program. If not, see <https://www.gnu.org/licenses/>.
 -->
 -->
@@ -24,14 +24,6 @@
       xmlns:tools="http://schemas.android.com/tools"
       xmlns:tools="http://schemas.android.com/tools"
       tools:ignore="AppCompatResource">
       tools:ignore="AppCompatResource">
 
 
-    <item
-        android:id="@+id/action_sort"
-        android:contentDescription="@string/actionbar_sort"
-        android:icon="@drawable/ic_sort_variant"
-        android:orderInCategory="1"
-        android:title="@string/actionbar_sort"
-        app:showAsAction="never"/>
-
     <item
     <item
         android:id="@+id/action_empty_trashbin"
         android:id="@+id/action_empty_trashbin"
         android:contentDescription="@string/action_empty_trashbin"
         android:contentDescription="@string/action_empty_trashbin"