--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="56dp"
+ android:layout_gravity="center_horizontal"
+ android:gravity="center_horizontal"
+ android:orientation="vertical"
+ android:showDividers="none" >
+
+ <TextView
+ android:id="@+id/footerText"
+ android:layout_width="match_parent"
+ android:layout_height="56dp"
+ android:layout_gravity="center"
+ android:gravity="center"
+ android:textColor="@color/setup_text_hint" />
+
+</LinearLayout>
\ No newline at end of file
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh_files"
android:layout_width="match_parent"
- android:layout_height="match_parent" >
-
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:footerDividersEnabled="false" >
+
<com.owncloud.android.ui.ExtendedListView
android:id="@+id/list_root"
android:layout_width="match_parent"
android:layout_height="match_parent" />
-
+
</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"
<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="file_list_folder">folder</string>
+ <string name="file_list_folders">folders</string>
+ <string name="file_list_file">file</string>
+ <string name="file_list_files">files</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>
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";
private static final String KEY_EMPTY_LIST_MESSAGE = "EMPTY_LIST_MESSAGE";
protected ExtendedListView mList;
-
+
private SwipeRefreshLayout mRefreshLayout;
private SwipeRefreshLayout mRefreshEmptyLayout;
private TextView mEmptyListMessage;
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));
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);
return v;
}
-
/**
* {@inheritDoc}
*/
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) {
}
}
-
/**
* 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) {
@Override
public void onItemClick (AdapterView<?> parent, View view, int position, long id) {
- // to be @overriden
+ // to be @overriden
}
@Override
mOnRefreshListener.onRefresh();
}
}
-
public void setOnRefreshListener(OnEnforceableRefreshListener listener) {
mOnRefreshListener = listener;
}
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;
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;
private OCFile mFile = null;
private FileListListAdapter mAdapter;
+ private View mFooterView;
private OCFile mTargetFile;
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.
*/
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<OCFile> 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) {