Przeglądaj źródła

add loading shimmer effect for auto upload

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Andy Scherzinger 4 lat temu
rodzic
commit
ae838f69cd

+ 48 - 0
src/main/java/com/nextcloud/ui/SquareLoaderImageView.java

@@ -0,0 +1,48 @@
+/*
+ * Nextcloud Android client application
+ *
+ * @author Andy Scherzinger
+ * Copyright (C) 2020 Andy Scherzinger
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * 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 AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * 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/>.
+ */
+
+package com.nextcloud.ui;
+
+import android.content.Context;
+import android.util.AttributeSet;
+
+import com.elyeproj.loaderviewlibrary.LoaderImageView;
+
+/**
+ * Square version of loader image.
+ */
+class SquareLoaderImageView extends LoaderImageView {
+    public SquareLoaderImageView(Context context) {
+        super(context);
+    }
+
+    public SquareLoaderImageView(Context context, AttributeSet attrs) {
+        super(context, attrs);
+    }
+
+    public SquareLoaderImageView(Context context, AttributeSet attrs, int defStyle) {
+        super(context, attrs, defStyle);
+    }
+
+    @Override
+    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+        super.onMeasure(widthMeasureSpec, widthMeasureSpec);
+    }
+}

+ 8 - 18
src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.java

@@ -159,6 +159,7 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
             mDrawerToggle.setDrawerIndicatorEnabled(false);
         }
 
+        // TODO: The content loading should be done asynchronously
         setupContent();
 
         if (ThemeUtils.themingEnabled(this)) {
@@ -491,6 +492,7 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
      */
     private void showList() {
         binding.list.setVisibility(View.VISIBLE);
+        binding.loadingContent.setVisibility(View.GONE);
         checkAndShowEmptyListContent();
     }
 
@@ -601,40 +603,28 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
         checkAndShowEmptyListContent();
     }
 
-    private void showEmptyContent(String headline, String message) {
-        showEmptyContent(headline, message, false);
-        binding.emptyList.emptyListViewAction.setVisibility(View.GONE);
-    }
-
     private void showEmptyContent(String headline, String message, String action) {
-        showEmptyContent(headline, message, false);
+        showEmptyContent(headline, message);
         binding.emptyList.emptyListViewAction.setText(action);
         binding.emptyList.emptyListViewAction.setVisibility(View.VISIBLE);
         binding.emptyList.emptyListViewText.setVisibility(View.GONE);
     }
 
     private void showLoadingContent() {
-        showEmptyContent(
-            getString(R.string.drawer_synced_folders),
-            getString(R.string.synced_folders_loading_folders),
-            true
-        );
+        binding.loadingContent.setVisibility(View.VISIBLE);
         binding.emptyList.emptyListViewAction.setVisibility(View.GONE);
     }
 
-    private void showEmptyContent(String headline, String message, boolean loading) {
+    private void showEmptyContent(String headline, String message) {
+        binding.emptyList.emptyListViewAction.setVisibility(View.GONE);
         binding.emptyList.emptyListView.setVisibility(View.VISIBLE);
         binding.list.setVisibility(View.GONE);
+        binding.loadingContent.setVisibility(View.GONE);
 
         binding.emptyList.emptyListViewHeadline.setText(headline);
         binding.emptyList.emptyListViewText.setText(message);
         binding.emptyList.emptyListViewText.setVisibility(View.VISIBLE);
-
-        if (loading) {
-            binding.emptyList.emptyListIcon.setVisibility(View.GONE);
-        } else {
-            binding.emptyList.emptyListIcon.setVisibility(View.VISIBLE);
-        }
+        binding.emptyList.emptyListIcon.setVisibility(View.VISIBLE);
     }
 
     @Override

+ 16 - 4
src/main/res/layout/synced_folders_layout.xml

@@ -40,10 +40,6 @@
             android:orientation="vertical"
             app:layout_behavior="@string/appbar_scrolling_view_behavior">
 
-            <include
-                android:id="@+id/emptyList"
-                layout="@layout/empty_list" />
-
             <androidx.recyclerview.widget.RecyclerView
                 android:id="@android:id/list"
                 android:layout_width="match_parent"
@@ -55,6 +51,22 @@
                 android:scrollbarStyle="outsideOverlay"
                 android:scrollbars="vertical"
                 android:visibility="visible" />
+
+            <include
+                android:id="@+id/emptyList"
+                layout="@layout/empty_list" />
+
+            <LinearLayout
+                android:id="@+id/loading_content"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="vertical"
+                android:visibility="gone">
+
+                <include layout="@layout/synced_folders_list_item_shimmer" />
+                <include layout="@layout/synced_folders_list_item_shimmer" />
+
+            </LinearLayout>
         </FrameLayout>
 
     </androidx.coordinatorlayout.widget.CoordinatorLayout>

+ 160 - 0
src/main/res/layout/synced_folders_list_item_shimmer.xml

@@ -0,0 +1,160 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+  Nextcloud Android client application
+
+  Copyright (C) 2020 Andy Scherzinger
+
+  This program is free software; you can redistribute it and/or
+  modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+  License as published by the Free Software Foundation; either
+  version 3 of the License, or any later version.
+
+  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 AFFERO GENERAL PUBLIC LICENSE for more details.
+
+  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/>.
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:orientation="vertical">
+
+    <RelativeLayout
+        android:id="@+id/header_container"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginStart="@dimen/standard_margin"
+        android:layout_marginTop="12dp"
+        android:layout_marginEnd="@dimen/zero"
+        android:layout_marginBottom="11dp">
+
+        <LinearLayout
+            android:id="@+id/title_container"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_alignTop="@+id/buttonBar"
+            android:layout_alignBottom="@+id/buttonBar"
+            android:layout_alignParentStart="true"
+            android:layout_toStartOf="@+id/buttonBar">
+
+            <com.elyeproj.loaderviewlibrary.LoaderImageView
+                android:id="@+id/type"
+                android:layout_width="@dimen/synced_folders_item_type_layout_width"
+                android:layout_height="@dimen/synced_folders_item_type_layout_height"
+                android:layout_gravity="start|center_vertical"
+                android:layout_marginEnd="@dimen/synced_folders_item_type_layout_right_end_margin"
+                android:contentDescription="@null"
+                app:corners="100" />
+
+            <com.elyeproj.loaderviewlibrary.LoaderTextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_gravity="start|center_vertical"
+                android:textStyle="bold" />
+
+        </LinearLayout>
+
+        <LinearLayout
+            android:id="@+id/buttonBar"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_alignParentEnd="true">
+
+            <com.elyeproj.loaderviewlibrary.LoaderImageView
+                android:id="@+id/syncStatusButton"
+                android:layout_width="@dimen/synced_folders_item_type_layout_width"
+                android:layout_height="@dimen/synced_folders_item_type_layout_height"
+                android:layout_gravity="start|center_vertical"
+                android:layout_marginStart="@dimen/standard_margin"
+                android:layout_marginEnd="@dimen/standard_margin"
+                android:contentDescription="@null"
+                app:corners="100" />
+
+            <com.elyeproj.loaderviewlibrary.LoaderImageView
+                android:id="@+id/settingsButton"
+                android:layout_width="16dp"
+                android:layout_height="@dimen/synced_folders_item_type_layout_height"
+                android:layout_gravity="start|center_vertical"
+                android:layout_marginEnd="@dimen/standard_margin"
+                android:contentDescription="@null" />
+
+        </LinearLayout>
+    </RelativeLayout>
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginEnd="-3dp"
+        android:orientation="horizontal">
+
+        <com.nextcloud.ui.SquareLoaderImageView
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_marginEnd="3dp"
+            android:layout_weight="1"
+            android:contentDescription="@null" />
+
+        <com.nextcloud.ui.SquareLoaderImageView
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_marginEnd="3dp"
+            android:layout_weight="1"
+            android:contentDescription="@null" />
+
+        <com.nextcloud.ui.SquareLoaderImageView
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_marginEnd="3dp"
+            android:layout_weight="1"
+            android:contentDescription="@null" />
+
+        <com.nextcloud.ui.SquareLoaderImageView
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_marginEnd="3dp"
+            android:layout_weight="1"
+            android:contentDescription="@null" />
+
+    </LinearLayout>
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="3dp"
+        android:layout_marginEnd="-3dp"
+        android:orientation="horizontal">
+
+        <com.nextcloud.ui.SquareLoaderImageView
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_marginEnd="3dp"
+            android:layout_weight="1"
+            android:contentDescription="@null" />
+
+        <com.nextcloud.ui.SquareLoaderImageView
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_marginEnd="3dp"
+            android:layout_weight="1"
+            android:contentDescription="@null" />
+
+        <com.nextcloud.ui.SquareLoaderImageView
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_marginEnd="3dp"
+            android:layout_weight="1"
+            android:contentDescription="@null" />
+
+        <com.nextcloud.ui.SquareLoaderImageView
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_marginEnd="3dp"
+            android:layout_weight="1"
+            android:contentDescription="@null" />
+
+    </LinearLayout>
+
+</LinearLayout>