From: tobiasKaminsky Date: Fri, 21 Nov 2014 16:59:51 +0000 (+0100) Subject: Merge remote-tracking branch 'upstream/develop' into fileCount X-Git-Tag: oc-android-1.7.0_signed~91^2~2 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/ae6b686775ea4a16a1d756bcacec393dcd76d1da?hp=e901b609baa4dd5f681e2a5257c9e504997e3377 Merge remote-tracking branch 'upstream/develop' into fileCount --- diff --git a/res/layout/list_footer.xml b/res/layout/list_footer.xml new file mode 100644 index 00000000..a49874d6 --- /dev/null +++ b/res/layout/list_footer.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/res/layout/list_fragment.xml b/res/layout/list_fragment.xml index 4236d070..160edc1d 100644 --- a/res/layout/list_fragment.xml +++ b/res/layout/list_fragment.xml @@ -25,16 +25,18 @@ - + android:layout_height="match_parent" + android:layout_weight="1" + android:footerDividersEnabled="false" > + - + - - Nothing in here. Upload something! Loading... There are no files in this folder. + folder + folders + file + files Tap on a file to display additional information. Size: Type: diff --git a/src/com/owncloud/android/ui/fragment/ExtendedListFragment.java b/src/com/owncloud/android/ui/fragment/ExtendedListFragment.java index 5d3f7ace..1b7a1ddf 100644 --- a/src/com/owncloud/android/ui/fragment/ExtendedListFragment.java +++ b/src/com/owncloud/android/ui/fragment/ExtendedListFragment.java @@ -38,14 +38,14 @@ import com.owncloud.android.ui.ExtendedListView; import com.owncloud.android.ui.activity.OnEnforceableRefreshListener; /** - * TODO extending SherlockListFragment instead of SherlockFragment + * TODO extending SherlockListFragment instead of SherlockFragment */ public class ExtendedListFragment extends SherlockFragment implements OnItemClickListener, OnEnforceableRefreshListener { - + private static final String TAG = ExtendedListFragment.class.getSimpleName(); - private static final String KEY_SAVED_LIST_POSITION = "SAVED_LIST_POSITION"; + private static final String KEY_SAVED_LIST_POSITION = "SAVED_LIST_POSITION"; private static final String KEY_INDEXES = "INDEXES"; private static final String KEY_FIRST_POSITIONS= "FIRST_POSITIONS"; private static final String KEY_TOPS = "TOPS"; @@ -53,7 +53,7 @@ implements OnItemClickListener, OnEnforceableRefreshListener { private static final String KEY_EMPTY_LIST_MESSAGE = "EMPTY_LIST_MESSAGE"; protected ExtendedListView mList; - + private SwipeRefreshLayout mRefreshLayout; private SwipeRefreshLayout mRefreshEmptyLayout; private TextView mEmptyListMessage; @@ -72,18 +72,22 @@ implements OnItemClickListener, OnEnforceableRefreshListener { mList.invalidate(); } + public void setFooterView(View footer) { + mList.addFooterView(footer, null, false); + mList.invalidate(); + } + public ListView getListView() { return mList; } - - + @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log_OC.e(TAG, "onCreateView"); - + 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.setDivider(getResources().getDrawable(R.drawable.uploader_list_separator)); @@ -93,7 +97,7 @@ implements OnItemClickListener, OnEnforceableRefreshListener { int referencePosition = savedInstanceState.getInt(KEY_SAVED_LIST_POSITION); setReferencePosition(referencePosition); } - + // Pull down refresh mRefreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.swipe_refresh_files); mRefreshEmptyLayout = (SwipeRefreshLayout) v.findViewById(R.id.swipe_refresh_files_emptyView); @@ -106,7 +110,6 @@ implements OnItemClickListener, OnEnforceableRefreshListener { return v; } - /** * {@inheritDoc} */ @@ -142,14 +145,16 @@ implements OnItemClickListener, OnEnforceableRefreshListener { savedInstanceState.putString(KEY_EMPTY_LIST_MESSAGE, getEmptyViewText()); } - /** - * Calculates the position of the item that will be used as a reference to reposition the visible items in the list when - * the device is turned to other position. + * Calculates the position of the item that will be used as a reference to + * reposition the visible items in the list when the device is turned to + * other position. * - * THe current policy is take as a reference the visible item in the center of the screen. + * THe current policy is take as a reference the visible item in the center + * of the screen. * - * @return The position in the list of the visible item in the center of the screen. + * @return The position in the list of the visible item in the center of the + * screen. */ protected int getReferencePosition() { if (mList != null) { @@ -159,11 +164,11 @@ implements OnItemClickListener, OnEnforceableRefreshListener { } } - /** * Sets the visible part of the list from the reference position. * - * @param position Reference position previously returned by {@link LocalFileListFragment#getReferencePosition()} + * @param position Reference position previously returned by + * {@link LocalFileListFragment#getReferencePosition()} */ protected void setReferencePosition(int position) { if (mList != null) { @@ -227,7 +232,7 @@ implements OnItemClickListener, OnEnforceableRefreshListener { @Override public void onItemClick (AdapterView parent, View view, int position, long id) { - // to be @overriden + // to be @overriden } @Override @@ -240,7 +245,6 @@ implements OnItemClickListener, OnEnforceableRefreshListener { mOnRefreshListener.onRefresh(); } } - public void setOnRefreshListener(OnEnforceableRefreshListener listener) { mOnRefreshListener = listener; } diff --git a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java index 0b1059fc..34caa028 100644 --- a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java @@ -18,8 +18,10 @@ package com.owncloud.android.ui.fragment; import java.io.File; +import java.util.Vector; import android.app.Activity; +import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.v4.widget.SwipeRefreshLayout; @@ -29,6 +31,8 @@ import android.view.MenuItem; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.AdapterContextMenuInfo; +import android.widget.TextView; +import android.view.LayoutInflater; import com.owncloud.android.R; import com.owncloud.android.datamodel.FileDataStorageManager; @@ -70,6 +74,7 @@ public class OCFileListFragment extends ExtendedListFragment { private OCFile mFile = null; private FileListListAdapter mAdapter; + private View mFooterView; private OCFile mTargetFile; @@ -112,24 +117,28 @@ public class OCFileListFragment extends ExtendedListFragment { public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); Log_OC.e(TAG, "onActivityCreated() start"); - + if (savedInstanceState != null) { mFile = savedInstanceState.getParcelable(KEY_FILE); } - + + mFooterView = ((LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate( + R.layout.list_footer, null, false); + setFooterView(mFooterView); + Bundle args = getArguments(); boolean justFolders = (args == null) ? false : args.getBoolean(ARG_JUST_FOLDERS, false); mAdapter = new FileListListAdapter( justFolders, getSherlockActivity(), mContainerActivity - ); + ); setListAdapter(mAdapter); - + registerForContextMenu(getListView()); getListView().setOnCreateContextMenuListener(this); - } - + } + /** * Saves the current listed folder. */ @@ -384,7 +393,43 @@ public class OCFileListFragment extends ExtendedListFragment { mList.setSelectionFromTop(0, 0); } mFile = directory; + + // Update Footer + TextView footerText = (TextView) mFooterView.findViewById(R.id.footerText); + Log_OC.d("footer", String.valueOf(System.currentTimeMillis())); + footerText.setText(generateFooterText(directory)); + Log_OC.d("footer", String.valueOf(System.currentTimeMillis())); + } + } + + private String generateFooterText(OCFile directory) { + Integer files = 0; + Integer folders = 0; + + FileDataStorageManager storageManager = mContainerActivity.getStorageManager(); + Vector mFiles = storageManager.getFolderContent(mFile); + + for (OCFile ocFile : mFiles) { + if (ocFile.isFolder()) { + folders++; + } else { + files++; + } + } + + String output = ""; + + if (folders == 1) { + output = folders.toString() + " " + getResources().getString(R.string.file_list_folder) + ", "; + } else if (folders > 1) { + output = folders.toString() + " " + getResources().getString(R.string.file_list_folders) + ", "; + } + if (files == 1) { + output = output + files.toString() + " " + getResources().getString(R.string.file_list_file); + } else { + output = output + files.toString() + " " + getResources().getString(R.string.file_list_files); } + return output; } public void sortByName(boolean descending) {