From: David A. Velasco Date: Wed, 30 Jul 2014 07:40:17 +0000 (+0200) Subject: Merge pull request #578 from owncloud/show_message_for_empty_list X-Git-Tag: oc-android-1.7.0_signed~238 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/41666b2d6cdb5235164f0e2a06ea77b2313426b2?hp=5756dd8ac4fc96d7508511fad7c382c4f12edf6e Merge pull request #578 from owncloud/show_message_for_empty_list Show background message when list of files is empty --- diff --git a/res/layout/list_fragment.xml b/res/layout/list_fragment.xml index c5dbef12..4236d070 100644 --- a/res/layout/list_fragment.xml +++ b/res/layout/list_fragment.xml @@ -17,11 +17,10 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . --> - + android:layout_weight="1" > + android:layout_height="match_parent" /> - + android:visibility="gone" > - + + + + + + + diff --git a/res/values/strings.xml b/res/values/strings.xml index a8da038c..6e41e3a1 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -53,7 +53,9 @@ No content was received. Nothing to upload. %1$s is not allowed to access the shared content Uploading - There are no files in this folder.\nNew files can be added with the \"Upload\" menu option. + Nothing in here. Upload something! + Loading... + There are no files in this folder. Tap on a file to display additional information. Size: Type: @@ -269,6 +271,7 @@ An error occurred while waiting for the server, the operation couldn\'t have been done An error occurred while waiting for the server, the operation couldn\'t have been done The operation couldn\'t be completed, server is unavailable + You do not have permission %s to rename this file diff --git a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java index e263b953..a7a25382 100644 --- a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -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); } - + } diff --git a/src/com/owncloud/android/ui/fragment/ExtendedListFragment.java b/src/com/owncloud/android/ui/fragment/ExtendedListFragment.java index 5915ab42..6c52c6e0 100644 --- a/src/com/owncloud/android/ui/fragment/ExtendedListFragment.java +++ b/src/com/owncloud/android/ui/fragment/ExtendedListFragment.java @@ -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); + } + } diff --git a/src/com/owncloud/android/ui/fragment/LocalFileListFragment.java b/src/com/owncloud/android/ui/fragment/LocalFileListFragment.java index bc466016..3d547cbb 100644 --- a/src/com/owncloud/android/ui/fragment/LocalFileListFragment.java +++ b/src/com/owncloud/android/ui/fragment/LocalFileListFragment.java @@ -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; } diff --git a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java index c53b3781..52598074 100644 --- a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java @@ -20,12 +20,21 @@ package com.owncloud.android.ui.fragment; import java.io.File; import java.util.ArrayList; +import android.app.Activity; +import android.os.Bundle; +import android.view.ContextMenu; +import android.view.MenuInflater; +import android.view.MenuItem; +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.adapter.FileListListAdapter; 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; @@ -33,15 +42,6 @@ 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; -import android.view.MenuInflater; -import android.view.MenuItem; -import android.view.View; -import android.widget.AdapterView; -import android.widget.AdapterView.AdapterContextMenuInfo; - /** * 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(); @@ -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()); } /**