Show message when the file list is being loading and when it is empty
authorjabarros <jabarros@solidgear.es>
Fri, 25 Jul 2014 11:13:58 +0000 (13:13 +0200)
committerjabarros <jabarros@solidgear.es>
Fri, 25 Jul 2014 11:13:58 +0000 (13:13 +0200)
res/layout/list_fragment.xml
res/values/strings.xml
src/com/owncloud/android/ui/activity/FileDisplayActivity.java
src/com/owncloud/android/ui/fragment/ExtendedListFragment.java
src/com/owncloud/android/ui/fragment/OCFileListFragment.java

index d03aa32..95673e1 100644 (file)
@@ -39,7 +39,7 @@
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:gravity="center_vertical|center_horizontal"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:gravity="center_vertical|center_horizontal"
-        android:text="@string/file_list_empty"
+        android:text="@string/empty"
         android:visibility="gone"
        />
 
         android:visibility="gone"
        />
 
index c76ef4f..9895b47 100644 (file)
@@ -54,6 +54,7 @@
     <string name="uploader_error_forbidden_content">%1$s is not allowed to access the shared content</string>
     <string name="uploader_info_uploading">Uploading</string>
     <string name="file_list_empty">Nothing in here. Upload something!</string>
     <string name="uploader_error_forbidden_content">%1$s is not allowed to access the shared content</string>
     <string name="uploader_info_uploading">Uploading</string>
     <string name="file_list_empty">Nothing in here. Upload something!</string>
+    <string name="file_list_loading">Loading...</string>
     <string name="local_file_list_empty">There are no files in this folder.</string>
     <string name="filedetails_select_file">Tap on a file to display additional information.</string>
     <string name="filedetails_size">Size:</string>
     <string name="local_file_list_empty">There are no files in this folder.</string>
     <string name="filedetails_select_file">Tap on a file to display additional information.</string>
     <string name="filedetails_size">Size:</string>
        <string name="network_error_socket_timeout_exception">An error occurred while waiting for the server, the operation couldn\'t have been done</string>
        <string name="network_error_connect_timeout_exception">An error occurred while waiting for the server, the operation couldn\'t have been done</string>
        <string name="network_host_not_available">The operation couldn\'t be completed, server is unavailable</string>
        <string name="network_error_socket_timeout_exception">An error occurred while waiting for the server, the operation couldn\'t have been done</string>
        <string name="network_error_connect_timeout_exception">An error occurred while waiting for the server, the operation couldn\'t have been done</string>
        <string name="network_host_not_available">The operation couldn\'t be completed, server is unavailable</string>
+       <string name="empty"></string>
        
 </resources>
        
 </resources>
index e263b95..53fa1f1 100644 (file)
@@ -196,6 +196,8 @@ FileFragment.ContainerActivity, OnNavigationListener, OnSslUntrustedCertListener
         getSupportActionBar().setHomeButtonEnabled(true);       // mandatory since Android ICS, according to the official documentation
         setSupportProgressBarIndeterminateVisibility(mSyncInProgress /*|| mRefreshSharesInProgress*/);    // always AFTER setContentView(...) ; to work around bug in its implementation
         
         getSupportActionBar().setHomeButtonEnabled(true);       // mandatory since Android ICS, according to the official documentation
         setSupportProgressBarIndeterminateVisibility(mSyncInProgress /*|| mRefreshSharesInProgress*/);    // always AFTER setContentView(...) ; to work around bug in its implementation
         
+        showMessageView();
+
         Log_OC.d(TAG, "onCreate() end");
     }
     
         Log_OC.d(TAG, "onCreate() end");
     }
     
@@ -960,6 +962,8 @@ FileFragment.ContainerActivity, OnNavigationListener, OnSslUntrustedCertListener
                     removeStickyBroadcast(intent);
                     Log_OC.d(TAG, "Setting progress visibility to " + mSyncInProgress);
                     setSupportProgressBarIndeterminateVisibility(mSyncInProgress /*|| mRefreshSharesInProgress*/);
                     removeStickyBroadcast(intent);
                     Log_OC.d(TAG, "Setting progress visibility to " + mSyncInProgress);
                     setSupportProgressBarIndeterminateVisibility(mSyncInProgress /*|| mRefreshSharesInProgress*/);
+
+                    showMessageView();
                         
                 }
                 
                         
                 }
                 
@@ -976,6 +980,23 @@ FileFragment.ContainerActivity, OnNavigationListener, OnSslUntrustedCertListener
         }
     }
     
         }
     }
     
+    /**
+     * Show a text message on screen view for notifying user if content is
+     * loading or folder is empty
+     */
+    private void showMessageView() {
+        OCFileListFragment ocFileListFragment = getListOfFilesFragment();
+        if (ocFileListFragment != null) {
+            int message = R.string.file_list_loading;
+            if (!mSyncInProgress) {
+                // In case file list is empty
+                message = R.string.file_list_empty;
+            }
+            ocFileListFragment.setMessageforEmptyView(message);
+        } else {
+            Log.e(TAG, "OCFileListFragment is null");
+        }
+    }
 
     /**
      * Once the file upload has finished -> update view
 
     /**
      * Once the file upload has finished -> update view
@@ -1529,6 +1550,8 @@ FileFragment.ContainerActivity, OnNavigationListener, OnSslUntrustedCertListener
         synchFolderOp.execute(getAccount(), this, null, null);
         
         setSupportProgressBarIndeterminateVisibility(true);
         synchFolderOp.execute(getAccount(), this, null, null);
         
         setSupportProgressBarIndeterminateVisibility(true);
+
+        showMessageView();
     }
 
     /**
     }
 
     /**
index 69704c9..5cb737b 100644 (file)
@@ -168,7 +168,9 @@ public class ExtendedListFragment extends SherlockFragment implements OnItemClic
      * Set message for empty list view
      */
     public void setMessageforEmptyView(int message) {
      * Set message for empty list view
      */
     public void setMessageforEmptyView(int message) {
-        mEmptyListMessage.setText(message);
+        if (mEmptyListMessage != null) {
+            mEmptyListMessage.setText(message);
+        }
     }
  
     
     }
  
     
index 0c8ffca..ebe9a91 100644 (file)
@@ -107,8 +107,6 @@ public class OCFileListFragment extends ExtendedListFragment {
         super.onActivityCreated(savedInstanceState);
         Log_OC.e(TAG, "onActivityCreated() start");
         
         super.onActivityCreated(savedInstanceState);
         Log_OC.e(TAG, "onActivityCreated() start");
         
-        setMessageforEmptyView(R.string.file_list_empty);
-
         mAdapter = new FileListListAdapter(getSherlockActivity(), mContainerActivity); 
                 
         if (savedInstanceState != null) {
         mAdapter = new FileListListAdapter(getSherlockActivity(), mContainerActivity); 
                 
         if (savedInstanceState != null) {