Browse Source

Fix activity

Mario Danic 8 years ago
parent
commit
8099055fe9

+ 5 - 0
build.gradle

@@ -32,6 +32,11 @@ ext {
     preDexEnabled = "true".equals(System.getProperty("pre-dex", "true"))
 }
 
+configurations.all {
+    // Check for updates every build
+    resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
+}
+
 repositories {
     jcenter()
     maven { url "https://jitpack.io" }

+ 48 - 3
src/main/java/com/owncloud/android/ui/activity/ActivitiesListActivity.java

@@ -23,7 +23,9 @@
 package com.owncloud.android.ui.activity;
 
 import android.accounts.Account;
+import android.content.Intent;
 import android.os.Bundle;
+import android.support.v4.widget.SwipeRefreshLayout;
 import android.support.v7.widget.DividerItemDecoration;
 import android.support.v7.widget.LinearLayoutManager;
 import android.support.v7.widget.RecyclerView;
@@ -60,6 +62,12 @@ public class ActivitiesListActivity extends FileActivity {
     @BindView(R.id.empty_list_view)
     public LinearLayout emptyContentContainer;
 
+    @BindView(R.id.swipe_containing_list)
+    public SwipeRefreshLayout swipeListRefreshLayout;
+
+    @BindView(R.id.swipe_containing_empty)
+    public SwipeRefreshLayout swipeEmptyListRefreshLayout;
+
     @BindView(R.id.empty_list_view_text)
     public TextView emptyContentMessage;
 
@@ -98,6 +106,22 @@ public class ActivitiesListActivity extends FileActivity {
         setupDrawer(R.id.nav_activity);
         getSupportActionBar().setTitle(getString(R.string.drawer_item_activities));
 
+        swipeListRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
+            @Override
+            public void onRefresh() {
+                setLoadingMessage();
+                fetchAndSetData();
+            }
+        });
+
+        swipeEmptyListRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
+            @Override
+            public void onRefresh() {
+                setLoadingMessage();
+                fetchAndSetData();
+
+            }
+        });
         setupContent();
     }
 
@@ -106,6 +130,14 @@ public class ActivitiesListActivity extends FileActivity {
         unbinder.unbind();
     }
 
+    @Override
+    public void showFiles(boolean onDeviceOnly) {
+        super.showFiles(onDeviceOnly);
+        Intent i = new Intent(getApplicationContext(), FileDisplayActivity.class);
+        i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+        startActivity(i);
+    }
+
     /**
      * sets up the UI elements and loads all activity items.
      */
@@ -143,8 +175,8 @@ public class ActivitiesListActivity extends FileActivity {
                         public void run() {
                             if (activities.size() > 0) {
                                 populateList(activities);
-                                emptyContentContainer.setVisibility(View.GONE);
-                                recyclerView.setVisibility(View.VISIBLE);
+                                swipeEmptyListRefreshLayout.setVisibility(View.GONE);
+                                swipeListRefreshLayout.setVisibility(View.VISIBLE);
                             } else {
                                 setEmptyContent(noResultsHeadline, noResultsMessage);
                             }
@@ -153,13 +185,26 @@ public class ActivitiesListActivity extends FileActivity {
                 } else {
                     Log_OC.d(TAG, result.getLogMessage());
                     // show error
+                    String logMessage = result.getLogMessage();
+                    if (result.getHttpCode() == 304) {
+                        logMessage = noResultsMessage;
+                    }
+                    final String finalLogMessage = logMessage;
                     runOnUiThread(new Runnable() {
                         @Override
                         public void run() {
-                            setEmptyContent(noResultsHeadline, result.getLogMessage());
+                            setEmptyContent(noResultsHeadline, finalLogMessage);
                         }
                     });
                 }
+
+                runOnUiThread(new Runnable() {
+                    @Override
+                    public void run() {
+                        swipeListRefreshLayout.setRefreshing(false);
+                        swipeEmptyListRefreshLayout.setRefreshing(false);
+                    }
+                });
             }
         });
 

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

@@ -307,6 +307,7 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
                 break;
             case R.id.nav_activity:
                 Intent activityIntent = new Intent(getApplicationContext(), ActivitiesListActivity.class);
+                activityIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                 startActivity(activityIntent);
                 break;
             case R.id.nav_folder_sync:

+ 40 - 59
src/main/res/layout/activity_list_item.xml

@@ -22,70 +22,51 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
-    android:orientation="horizontal"
-    android:weightSum="1">
+    android:orientation="horizontal">
 
-    <FrameLayout
-        android:id="@+id/activity_icon_container"
-        android:layout_width="@dimen/account_item_layout_height"
-        android:layout_height="wrap_content"
-        android:layout_alignParentLeft="true"
-        android:layout_alignParentStart="true">
-
-        <ImageView
-            android:id="@+id/activity_icon"
-            android:layout_width="@dimen/user_icon_size"
-            android:layout_height="@dimen/user_icon_size"
-            android:layout_marginLeft="@dimen/standard_margin"
-            android:layout_gravity="top|left"
-            android:layout_marginTop="@dimen/standard_half_margin"
-            android:src="@drawable/ic_menu_archive"/>
+    <ImageView
+        android:id="@+id/activity_icon"
+        android:layout_width="@dimen/user_icon_size"
+        android:layout_height="@dimen/user_icon_size"
+        android:layout_centerVertical="true"
+        android:layout_margin="@dimen/standard_quarter_margin"
+        android:src="@drawable/ic_activity"/>
 
-    </FrameLayout>
-d
-    <LinearLayout
+    <TextView
+        android:id="@+id/activity_subject"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:layout_centerInParent="true"
-        android:layout_toEndOf="@id/activity_icon_container"
-        android:layout_toRightOf="@id/activity_icon_container"
-        android:orientation="vertical">
-
-        <TextView
-            android:id="@+id/activity_subject"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_marginRight="@dimen/standard_margin"
-            android:layout_marginTop="@dimen/standard_half_margin"
-            android:ellipsize="end"
-            android:gravity="bottom"
-            android:maxLines="2"
-            android:text="@string/placeholder_filename"
-            android:textAppearance="?android:attr/textAppearanceListItem"/>
+        android:layout_margin="@dimen/standard_quarter_margin"
+        android:layout_toRightOf="@id/activity_icon"
+        android:layout_alignTop="@id/activity_icon"
+        android:ellipsize="end"
+        android:gravity="bottom"
+        android:maxLines="2"
+        android:text="@string/placeholder_filename"
+        android:textAppearance="?android:attr/textAppearanceListItem"/>
 
-        <TextView
-            android:id="@+id/activity_message"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_marginBottom="4dp"
-            android:layout_marginRight="@dimen/standard_margin"
-            android:ellipsize="end"
-            android:gravity="top"
-            android:maxLines="3"
-            android:text="@string/placeholder_sentence"
-            android:textColor="?android:attr/textColorSecondary"/>
+    <TextView
+        android:id="@+id/activity_message"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_below="@id/activity_subject"
+        android:layout_margin="@dimen/standard_quarter_margin"
+        android:layout_toRightOf="@id/activity_icon"
+        android:ellipsize="end"
+        android:gravity="top"
+        android:maxLines="3"
+        android:text="@string/placeholder_sentence"
+        android:textColor="?android:attr/textColorSecondary"/>
 
-        <TextView
-            android:id="@+id/activity_datetime"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_marginBottom="@dimen/standard_half_margin"
-            android:layout_marginRight="@dimen/standard_margin"
-            android:ellipsize="end"
-            android:gravity="right"
-            android:maxLines="3"
-            android:text="@string/placeholder_sentence"
-            android:textColor="?android:attr/textColorSecondary"/>
+    <TextView
+        android:id="@+id/activity_datetime"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentRight="true"
+        android:layout_alignParentBottom="true"
+        android:layout_margin="@dimen/standard_quarter_margin"
+        android:ellipsize="end"
+        android:text="@string/placeholder_sentence"
+        android:textColor="?android:attr/textColorSecondary"/>
 
-    </LinearLayout>
 </RelativeLayout>

+ 31 - 13
src/main/res/layout/activity_list_layout.xml

@@ -17,8 +17,8 @@
   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/>.
 -->
-<android.support.v4.widget.DrawerLayout android:id="@+id/drawer_layout"
-                                        xmlns:android="http://schemas.android.com/apk/res/android"
+<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                                        android:id="@+id/drawer_layout"
                                         android:layout_width="match_parent"
                                         android:layout_height="match_parent"
                                         android:clickable="true"
@@ -37,19 +37,37 @@
             android:layout_width="match_parent"
             android:layout_height="match_parent">
 
-            <android.support.v7.widget.RecyclerView
-                android:id="@android:id/list"
+            <android.support.v4.widget.SwipeRefreshLayout
+                android:id="@+id/swipe_containing_list"
                 android:layout_width="match_parent"
                 android:layout_height="match_parent"
-                android:clipToPadding="false"
-                android:scrollbarStyle="outsideOverlay"
-                android:scrollbars="vertical"
-                android:visibility="visible"
-                android:layout_marginRight="-3dp"
-                android:layout_marginLeft="-3dp"
-                android:layout_marginBottom="-3dp"/>
-
-            <include layout="@layout/empty_list"/>
+                android:footerDividersEnabled="false"
+                android:visibility="visible">
+
+                <android.support.v7.widget.RecyclerView
+                    android:id="@android:id/list"
+                    android:layout_width="match_parent"
+                    android:layout_height="match_parent"
+                    android:layout_marginBottom="-3dp"
+                    android:layout_marginLeft="-3dp"
+                    android:layout_marginRight="-3dp"
+                    android:clipToPadding="false"
+                    android:scrollbarStyle="outsideOverlay"
+                    android:scrollbars="vertical"
+                    android:visibility="visible"/>
+
+            </android.support.v4.widget.SwipeRefreshLayout>
+
+            <android.support.v4.widget.SwipeRefreshLayout
+                android:id="@+id/swipe_containing_empty"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:footerDividersEnabled="false"
+                android:visibility="visible">
+
+                <include layout="@layout/empty_list"/>
+            </android.support.v4.widget.SwipeRefreshLayout>
+
         </FrameLayout>
 
     </LinearLayout>