mirror of
https://github.com/nextcloud/android.git
synced 2024-11-22 21:25:35 +03:00
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:
commit
41666b2d6c
6 changed files with 117 additions and 49 deletions
|
@ -17,11 +17,10 @@
|
|||
You should have received a copy of the GNU 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"
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical" >
|
||||
android:layout_weight="1" >
|
||||
|
||||
<android.support.v4.widget.SwipeRefreshLayout
|
||||
android:id="@+id/swipe_refresh_files"
|
||||
|
@ -31,18 +30,29 @@
|
|||
<com.owncloud.android.ui.ExtendedListView
|
||||
android:id="@+id/list_root"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dip"
|
||||
android:layout_weight="1" />
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</android.support.v4.widget.SwipeRefreshLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/empty_list_view"
|
||||
<android.support.v4.widget.SwipeRefreshLayout
|
||||
android:id="@+id/swipe_refresh_files_emptyView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical|center_horizontal"
|
||||
android:text="@string/file_list_empty"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
android:visibility="gone" >
|
||||
|
||||
</LinearLayout>
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/empty_list_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical|center_horizontal"
|
||||
android:text="@string/empty"
|
||||
android:layout_gravity="center"
|
||||
android:visibility="visible" />
|
||||
|
||||
</ScrollView>
|
||||
</android.support.v4.widget.SwipeRefreshLayout>
|
||||
</FrameLayout>
|
||||
|
|
|
@ -53,7 +53,9 @@
|
|||
<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_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_size">Size:</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_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>
|
||||
|
||||
<string name="forbidden_permissions">You do not have permission %s</string>
|
||||
<string name="forbidden_permissions_rename">to rename this file</string>
|
||||
|
|
|
@ -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
|
||||
|
||||
setBackgroundText();
|
||||
|
||||
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*/);
|
||||
|
||||
setBackgroundText();
|
||||
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -1529,6 +1550,8 @@ FileFragment.ContainerActivity, OnNavigationListener, OnSslUntrustedCertListener
|
|||
synchFolderOp.execute(getAccount(), this, null, null);
|
||||
|
||||
setSupportProgressBarIndeterminateVisibility(true);
|
||||
|
||||
setBackgroundText();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1630,5 +1653,5 @@ FileFragment.ContainerActivity, OnNavigationListener, OnSslUntrustedCertListener
|
|||
}
|
||||
onTransferStateChanged(file, false, false);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -18,21 +18,21 @@
|
|||
|
||||
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.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ListAdapter;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.ListAdapter;
|
||||
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
|
||||
|
@ -46,6 +46,8 @@ public class ExtendedListFragment extends SherlockFragment implements OnItemClic
|
|||
protected ExtendedListView mList;
|
||||
|
||||
private SwipeRefreshLayout mRefreshLayout;
|
||||
private SwipeRefreshLayout mRefreshEmptyLayout;
|
||||
private TextView mEmptyListMessage;
|
||||
|
||||
public void setListAdapter(ListAdapter listAdapter) {
|
||||
mList.setAdapter(listAdapter);
|
||||
|
@ -63,9 +65,10 @@ public class ExtendedListFragment extends SherlockFragment implements OnItemClic
|
|||
//mList = new ExtendedListView(getActivity());
|
||||
|
||||
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.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.setDividerHeight(1);
|
||||
|
||||
|
@ -76,12 +79,13 @@ public class ExtendedListFragment extends SherlockFragment implements OnItemClic
|
|||
|
||||
// Pull down refresh
|
||||
mRefreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.swipe_refresh_files);
|
||||
// Colors in animations: background
|
||||
mRefreshLayout.setColorScheme(R.color.background_color, R.color.background_color,
|
||||
R.color.background_color, R.color.background_color);
|
||||
mRefreshEmptyLayout = (SwipeRefreshLayout) v.findViewById(R.id.swipe_refresh_files_emptyView);
|
||||
|
||||
mRefreshLayout.setOnRefreshListener(this);
|
||||
onCreateSwipeToRefresh(mRefreshLayout);
|
||||
onCreateSwipeToRefresh(mRefreshEmptyLayout);
|
||||
|
||||
mList.setEmptyView(mRefreshEmptyLayout);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
|
@ -129,8 +133,9 @@ public class ExtendedListFragment extends SherlockFragment implements OnItemClic
|
|||
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
// to be @overriden
|
||||
// to be @overriden
|
||||
mRefreshLayout.setRefreshing(false);
|
||||
mRefreshEmptyLayout.setRefreshing(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -161,6 +166,31 @@ public class ExtendedListFragment extends SherlockFragment implements OnItemClic
|
|||
public void hideSwipeProgress() {
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,11 +19,6 @@ package com.owncloud.android.ui.fragment;
|
|||
|
||||
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.os.Bundle;
|
||||
import android.os.Environment;
|
||||
|
@ -35,6 +30,10 @@ import android.widget.AdapterView;
|
|||
import android.widget.ImageView;
|
||||
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.
|
||||
|
@ -78,6 +77,7 @@ public class LocalFileListFragment extends ExtendedListFragment {
|
|||
View v = super.onCreateView(inflater, container, savedInstanceState);
|
||||
getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
|
||||
disableSwipe(); // Disable pull refresh
|
||||
setMessageForEmptyList(getString(R.string.local_file_list_empty));
|
||||
Log_OC.i(TAG, "onCreateView() end");
|
||||
return v;
|
||||
}
|
||||
|
|
|
@ -20,19 +20,6 @@ package com.owncloud.android.ui.fragment;
|
|||
import java.io.File;
|
||||
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.os.Bundle;
|
||||
import android.view.ContextMenu;
|
||||
|
@ -42,6 +29,19 @@ import android.view.View;
|
|||
import android.widget.AdapterView;
|
||||
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.
|
||||
*
|
||||
|
@ -62,6 +62,7 @@ public class OCFileListFragment extends ExtendedListFragment {
|
|||
private static final String KEY_FIRST_POSITIONS= "FIRST_POSITIONS";
|
||||
private static final String KEY_TOPS = "TOPS";
|
||||
private static final String KEY_HEIGHT_CELL = "HEIGHT_CELL";
|
||||
private static final String KEY_EMPTY_LIST_MESSAGE = "EMPTY_LIST_MESSAGE";
|
||||
|
||||
private FileFragment.ContainerActivity mContainerActivity;
|
||||
|
||||
|
@ -115,6 +116,7 @@ public class OCFileListFragment extends ExtendedListFragment {
|
|||
mFirstPositions = savedInstanceState.getIntegerArrayList(KEY_FIRST_POSITIONS);
|
||||
mTops = savedInstanceState.getIntegerArrayList(KEY_TOPS);
|
||||
mHeightCell = savedInstanceState.getInt(KEY_HEIGHT_CELL);
|
||||
setMessageForEmptyList(savedInstanceState.getString(KEY_EMPTY_LIST_MESSAGE));
|
||||
|
||||
} else {
|
||||
mIndexes = new ArrayList<Integer>();
|
||||
|
@ -129,8 +131,7 @@ public class OCFileListFragment extends ExtendedListFragment {
|
|||
setListAdapter(mAdapter);
|
||||
|
||||
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_TOPS, mTops);
|
||||
outState.putInt(KEY_HEIGHT_CELL, mHeightCell);
|
||||
outState.putString(KEY_EMPTY_LIST_MESSAGE, getEmptyViewText());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue