Merge pull request #578 from owncloud/show_message_for_empty_list

Show background message when list of files is empty
This commit is contained in:
David A. Velasco 2014-07-30 09:40:17 +02:00
commit 41666b2d6c
6 changed files with 117 additions and 49 deletions

View file

@ -17,11 +17,10 @@
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 <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
--> -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1" >
android:orientation="vertical" >
<android.support.v4.widget.SwipeRefreshLayout <android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh_files" android:id="@+id/swipe_refresh_files"
@ -31,18 +30,29 @@
<com.owncloud.android.ui.ExtendedListView <com.owncloud.android.ui.ExtendedListView
android:id="@+id/list_root" android:id="@+id/list_root"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dip" android:layout_height="match_parent" />
android:layout_weight="1" />
</android.support.v4.widget.SwipeRefreshLayout> </android.support.v4.widget.SwipeRefreshLayout>
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh_files_emptyView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView <TextView
android:id="@+id/empty_list_view" android:id="@+id/empty_list_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal" android:gravity="center_vertical|center_horizontal"
android:text="@string/file_list_empty" android:text="@string/empty"
android:visibility="gone" android:layout_gravity="center"
/> android:visibility="visible" />
</LinearLayout> </ScrollView>
</android.support.v4.widget.SwipeRefreshLayout>
</FrameLayout>

View file

@ -53,7 +53,9 @@
<string name="uploader_wrn_no_content_text">No content was received. Nothing to upload.</string> <string name="uploader_wrn_no_content_text">No content was received. Nothing to upload.</string>
<string name="uploader_error_forbidden_content">%1$s is not allowed to access the shared content</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="uploader_info_uploading">Uploading</string>
<string name="file_list_empty">There are no files in this folder.\nNew files can be added with the \"Upload\" menu option.</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_select_file">Tap on a file to display additional information.</string>
<string name="filedetails_size">Size:</string> <string name="filedetails_size">Size:</string>
<string name="filedetails_type">Type:</string> <string name="filedetails_type">Type:</string>
@ -269,6 +271,7 @@
<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_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_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_host_not_available">The operation couldn\'t be completed, server is unavailable</string>
<string name="empty"></string>
<string name="forbidden_permissions">You do not have permission %s</string> <string name="forbidden_permissions">You do not have permission %s</string>
<string name="forbidden_permissions_rename">to rename this file</string> <string name="forbidden_permissions_rename">to rename this file</string>

View file

@ -196,6 +196,8 @@ FileFragment.ContainerActivity, OnNavigationListener, OnSslUntrustedCertListener
getSupportActionBar().setHomeButtonEnabled(true); // mandatory since Android ICS, according to the official documentation 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 setSupportProgressBarIndeterminateVisibility(mSyncInProgress /*|| mRefreshSharesInProgress*/); // always AFTER setContentView(...) ; to work around bug in its implementation
setBackgroundText();
Log_OC.d(TAG, "onCreate() end"); Log_OC.d(TAG, "onCreate() end");
} }
@ -961,6 +963,8 @@ FileFragment.ContainerActivity, OnNavigationListener, OnSslUntrustedCertListener
Log_OC.d(TAG, "Setting progress visibility to " + mSyncInProgress); Log_OC.d(TAG, "Setting progress visibility to " + mSyncInProgress);
setSupportProgressBarIndeterminateVisibility(mSyncInProgress /*|| mRefreshSharesInProgress*/); setSupportProgressBarIndeterminateVisibility(mSyncInProgress /*|| mRefreshSharesInProgress*/);
setBackgroundText();
} }
if (synchResult != null) { if (synchResult != null) {
@ -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 setBackgroundText() {
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.setMessageForEmptyList(getString(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); synchFolderOp.execute(getAccount(), this, null, null);
setSupportProgressBarIndeterminateVisibility(true); setSupportProgressBarIndeterminateVisibility(true);
setBackgroundText();
} }
/** /**

View file

@ -18,21 +18,21 @@
package com.owncloud.android.ui.fragment; package com.owncloud.android.ui.fragment;
import com.actionbarsherlock.app.SherlockFragment;
import com.owncloud.android.R;
import com.owncloud.android.ui.ExtendedListView;
import com.owncloud.android.utils.Log_OC;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.widget.SwipeRefreshLayout; import android.support.v4.widget.SwipeRefreshLayout;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.ListAdapter;
import android.widget.AdapterView.OnItemClickListener; import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListAdapter;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView;
import com.actionbarsherlock.app.SherlockFragment;
import com.owncloud.android.R;
import com.owncloud.android.ui.ExtendedListView;
import com.owncloud.android.utils.Log_OC;
/** /**
* TODO extending SherlockListFragment instead of SherlockFragment * TODO extending SherlockListFragment instead of SherlockFragment
@ -46,6 +46,8 @@ public class ExtendedListFragment extends SherlockFragment implements OnItemClic
protected ExtendedListView mList; protected ExtendedListView mList;
private SwipeRefreshLayout mRefreshLayout; private SwipeRefreshLayout mRefreshLayout;
private SwipeRefreshLayout mRefreshEmptyLayout;
private TextView mEmptyListMessage;
public void setListAdapter(ListAdapter listAdapter) { public void setListAdapter(ListAdapter listAdapter) {
mList.setAdapter(listAdapter); mList.setAdapter(listAdapter);
@ -63,9 +65,10 @@ public class ExtendedListFragment extends SherlockFragment implements OnItemClic
//mList = new ExtendedListView(getActivity()); //mList = new ExtendedListView(getActivity());
View v = inflater.inflate(R.layout.list_fragment, null); View v = inflater.inflate(R.layout.list_fragment, null);
mEmptyListMessage = (TextView) v.findViewById(R.id.empty_list_view);
mList = (ExtendedListView)(v.findViewById(R.id.list_root)); mList = (ExtendedListView)(v.findViewById(R.id.list_root));
mList.setOnItemClickListener(this); mList.setOnItemClickListener(this);
//mList.setEmptyView(v.findViewById(R.id.empty_list_view)); // looks like it's not a cool idea
mList.setDivider(getResources().getDrawable(R.drawable.uploader_list_separator)); mList.setDivider(getResources().getDrawable(R.drawable.uploader_list_separator));
mList.setDividerHeight(1); mList.setDividerHeight(1);
@ -76,11 +79,12 @@ public class ExtendedListFragment extends SherlockFragment implements OnItemClic
// Pull down refresh // Pull down refresh
mRefreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.swipe_refresh_files); mRefreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.swipe_refresh_files);
// Colors in animations: background mRefreshEmptyLayout = (SwipeRefreshLayout) v.findViewById(R.id.swipe_refresh_files_emptyView);
mRefreshLayout.setColorScheme(R.color.background_color, R.color.background_color,
R.color.background_color, R.color.background_color);
mRefreshLayout.setOnRefreshListener(this); onCreateSwipeToRefresh(mRefreshLayout);
onCreateSwipeToRefresh(mRefreshEmptyLayout);
mList.setEmptyView(mRefreshEmptyLayout);
return v; return v;
} }
@ -131,6 +135,7 @@ public class ExtendedListFragment extends SherlockFragment implements OnItemClic
public void onRefresh() { public void onRefresh() {
// to be @overriden // to be @overriden
mRefreshLayout.setRefreshing(false); mRefreshLayout.setRefreshing(false);
mRefreshEmptyLayout.setRefreshing(false);
} }
/** /**
@ -162,5 +167,30 @@ public class ExtendedListFragment extends SherlockFragment implements OnItemClic
mRefreshLayout.setRefreshing(false); mRefreshLayout.setRefreshing(false);
} }
/**
* Set message for empty list view
*/
public void setMessageForEmptyList(String message) {
if (mEmptyListMessage != null) {
mEmptyListMessage.setText(message);
}
}
/**
* Get the text of EmptyListMessage TextView
*
* @return String
*/
public String getEmptyViewText() {
return (mEmptyListMessage != null) ? mEmptyListMessage.getText().toString() : "";
}
private void onCreateSwipeToRefresh(SwipeRefreshLayout refreshLayout) {
// Colors in animations: background
refreshLayout.setColorScheme(R.color.background_color, R.color.background_color, R.color.background_color,
R.color.background_color);
refreshLayout.setOnRefreshListener(this);
}
} }

View file

@ -19,11 +19,6 @@ package com.owncloud.android.ui.fragment;
import java.io.File; import java.io.File;
import com.owncloud.android.R;
import com.owncloud.android.ui.adapter.LocalFileListAdapter;
import com.owncloud.android.utils.Log_OC;
import android.app.Activity; import android.app.Activity;
import android.os.Bundle; import android.os.Bundle;
import android.os.Environment; import android.os.Environment;
@ -35,6 +30,10 @@ import android.widget.AdapterView;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.ListView; import android.widget.ListView;
import com.owncloud.android.R;
import com.owncloud.android.ui.adapter.LocalFileListAdapter;
import com.owncloud.android.utils.Log_OC;
/** /**
* A Fragment that lists all files and folders in a given LOCAL path. * A Fragment that lists all files and folders in a given LOCAL path.
@ -78,6 +77,7 @@ public class LocalFileListFragment extends ExtendedListFragment {
View v = super.onCreateView(inflater, container, savedInstanceState); View v = super.onCreateView(inflater, container, savedInstanceState);
getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
disableSwipe(); // Disable pull refresh disableSwipe(); // Disable pull refresh
setMessageForEmptyList(getString(R.string.local_file_list_empty));
Log_OC.i(TAG, "onCreateView() end"); Log_OC.i(TAG, "onCreateView() end");
return v; return v;
} }

View file

@ -20,19 +20,6 @@ package com.owncloud.android.ui.fragment;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.files.FileMenuFilter;
import com.owncloud.android.ui.adapter.FileListListAdapter;
import com.owncloud.android.ui.activity.FileDisplayActivity;
import com.owncloud.android.ui.dialog.ConfirmationDialogFragment;
import com.owncloud.android.ui.dialog.RemoveFileDialogFragment;
import com.owncloud.android.ui.dialog.RenameFileDialogFragment;
import com.owncloud.android.ui.preview.PreviewImageFragment;
import com.owncloud.android.ui.preview.PreviewMediaFragment;
import com.owncloud.android.utils.Log_OC;
import android.app.Activity; import android.app.Activity;
import android.os.Bundle; import android.os.Bundle;
import android.view.ContextMenu; import android.view.ContextMenu;
@ -42,6 +29,19 @@ import android.view.View;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.AdapterView.AdapterContextMenuInfo; import android.widget.AdapterView.AdapterContextMenuInfo;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.files.FileMenuFilter;
import com.owncloud.android.ui.activity.FileDisplayActivity;
import com.owncloud.android.ui.adapter.FileListListAdapter;
import com.owncloud.android.ui.dialog.ConfirmationDialogFragment;
import com.owncloud.android.ui.dialog.RemoveFileDialogFragment;
import com.owncloud.android.ui.dialog.RenameFileDialogFragment;
import com.owncloud.android.ui.preview.PreviewImageFragment;
import com.owncloud.android.ui.preview.PreviewMediaFragment;
import com.owncloud.android.utils.Log_OC;
/** /**
* A Fragment that lists all files and folders in a given path. * A Fragment that lists all files and folders in a given path.
* *
@ -62,6 +62,7 @@ public class OCFileListFragment extends ExtendedListFragment {
private static final String KEY_FIRST_POSITIONS= "FIRST_POSITIONS"; private static final String KEY_FIRST_POSITIONS= "FIRST_POSITIONS";
private static final String KEY_TOPS = "TOPS"; private static final String KEY_TOPS = "TOPS";
private static final String KEY_HEIGHT_CELL = "HEIGHT_CELL"; private static final String KEY_HEIGHT_CELL = "HEIGHT_CELL";
private static final String KEY_EMPTY_LIST_MESSAGE = "EMPTY_LIST_MESSAGE";
private FileFragment.ContainerActivity mContainerActivity; private FileFragment.ContainerActivity mContainerActivity;
@ -115,6 +116,7 @@ public class OCFileListFragment extends ExtendedListFragment {
mFirstPositions = savedInstanceState.getIntegerArrayList(KEY_FIRST_POSITIONS); mFirstPositions = savedInstanceState.getIntegerArrayList(KEY_FIRST_POSITIONS);
mTops = savedInstanceState.getIntegerArrayList(KEY_TOPS); mTops = savedInstanceState.getIntegerArrayList(KEY_TOPS);
mHeightCell = savedInstanceState.getInt(KEY_HEIGHT_CELL); mHeightCell = savedInstanceState.getInt(KEY_HEIGHT_CELL);
setMessageForEmptyList(savedInstanceState.getString(KEY_EMPTY_LIST_MESSAGE));
} else { } else {
mIndexes = new ArrayList<Integer>(); mIndexes = new ArrayList<Integer>();
@ -130,7 +132,6 @@ public class OCFileListFragment extends ExtendedListFragment {
registerForContextMenu(getListView()); registerForContextMenu(getListView());
getListView().setOnCreateContextMenuListener(this); getListView().setOnCreateContextMenuListener(this);
} }
/** /**
@ -144,6 +145,7 @@ public class OCFileListFragment extends ExtendedListFragment {
outState.putIntegerArrayList(KEY_FIRST_POSITIONS, mFirstPositions); outState.putIntegerArrayList(KEY_FIRST_POSITIONS, mFirstPositions);
outState.putIntegerArrayList(KEY_TOPS, mTops); outState.putIntegerArrayList(KEY_TOPS, mTops);
outState.putInt(KEY_HEIGHT_CELL, mHeightCell); outState.putInt(KEY_HEIGHT_CELL, mHeightCell);
outState.putString(KEY_EMPTY_LIST_MESSAGE, getEmptyViewText());
} }
/** /**