android:id="@+id/linearLayout1"\r
android:layout_width="fill_parent"\r
android:layout_height="fill_parent"\r
- android:orientation="vertical" >\r
+ android:orientation="horizontal" >\r
\r
<LinearLayout\r
- android:id="@+id/linearLayout2"\r
- android:layout_width="fill_parent"\r
- android:layout_height="wrap_content" >\r
-\r
- <fragment\r
- android:id="@+id/fileList"\r
- android:layout_width="0dp"\r
- android:layout_height="fill_parent"\r
- android:layout_weight="1"\r
- class="eu.alefzero.owncloud.ui.fragment.FileList" >\r
-\r
- <!-- Preview: layout=@layout/list_layout -->\r
- </fragment>\r
+ android:id="@+id/file_list_container"\r
+ android:layout_width="0dp"\r
+ android:layout_height="wrap_content" \r
+ android:layout_weight="1">\r
+ </LinearLayout>\r
\r
- <fragment\r
- android:id="@+id/fileDetail"\r
- android:layout_width="0dp"\r
- android:layout_height="fill_parent"\r
- android:layout_weight="2"\r
- class="eu.alefzero.owncloud.ui.fragment.FileDetail" >\r
+ <fragment\r
+ android:id="@+id/fileDetail"\r
+ android:layout_width="0dp"\r
+ android:layout_height="fill_parent"\r
+ android:layout_weight="2"\r
+ class="eu.alefzero.owncloud.ui.fragment.FileDetail" >\r
\r
- <!-- Preview: layout=@layout/file_details -->\r
- </fragment>\r
- </LinearLayout>\r
+ <!-- Preview: layout=@layout/file_details -->\r
+ </fragment>\r
</LinearLayout>\r
\r
</LinearLayout>
\ No newline at end of file
getActionBar().setListNavigationCallbacks(mDirectories, this);\r
\r
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();\r
- ft.add(R.id.fileList, mFileList);\r
+ ft.add(R.id.file_list_container, mFileList);\r
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {\r
ft.add(R.id.fileDetail, new FileDetail());\r
}\r
public void onClick(DialogInterface dialog, int item) {\r
mAccount = accMan.getAccountsByType(AccountAuthenticator.ACCOUNT_TYPE)[item];\r
dialog.dismiss();\r
- populateFileList();\r
}\r
});\r
builder.setOnCancelListener(new OnCancelListener() {\r
//}\r
// }\r
\r
- private void populateFileList() {\r
- if (mParents.empty()) {\r
- mCursor = getContentResolver().query(ProviderTableMeta.CONTENT_URI,\r
- null,\r
- ProviderTableMeta.FILE_ACCOUNT_OWNER+"=?",\r
- new String[]{mAccount.name},\r
- null);\r
- } else {\r
- mCursor = getContentResolver().query(Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_DIR, mParents.peek()),\r
- null,\r
- ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?",\r
- new String[]{mAccount.name}, null);\r
- if (!mIsDisplayingFile) {\r
- //PathLayout pl = (PathLayout) findViewById(R.id.pathLayout1);\r
- //for (String s : mPath) {\r
- // pl.push(s);\r
- // }\r
- }\r
- }\r
+ \r
// setListAdapter(new FileListListAdapter(mCursor, this));\r
// getListView().invalidate();\r
- }\r
\r
@Override\r
public boolean onNavigationItemSelected(int itemPosition, long itemId) {\r
int i = itemPosition;\r
while (i-- != 0) {\r
popPath();\r
- mFileList.onBackPressed();\r
+ //mFileList.onBackPressed();\r
}\r
return true;\r
}\r
@Override\r
public void onBackPressed() {\r
popPath();\r
- if (mDirectories.isEmpty()) {\r
- super.onBackPressed();\r
- }\r
- mFileList.onBackPressed();\r
+ //getSupportFragmentManager().popBackStack();\r
+ //super.onBackPressed();\r
+ getSupportFragmentManager().popBackStackImmediate();\r
}\r
\r
//@Override\r
outState.putSerializable("path", mPath);\r
outState.putBoolean("isDisplayingFile", mIsDisplayingFile);\r
}*/\r
-\r
}
\ No newline at end of file
*/\r
package eu.alefzero.owncloud.ui.fragment;\r
\r
-import java.util.ListIterator;\r
-import java.util.Stack;\r
-\r
-import eu.alefzero.owncloud.DisplayUtils;\r
-import eu.alefzero.owncloud.R;\r
-import eu.alefzero.owncloud.R.id;\r
-import eu.alefzero.owncloud.authenticator.AccountAuthenticator;\r
-import eu.alefzero.owncloud.db.ProviderMeta.ProviderTableMeta;\r
-import eu.alefzero.owncloud.ui.FragmentListView;\r
-import eu.alefzero.owncloud.ui.activity.FileDetailActivity;\r
-import eu.alefzero.owncloud.ui.activity.FileDisplayActivity;\r
-import eu.alefzero.owncloud.ui.adapter.FileListListAdapter;\r
-import eu.alefzero.owncloud.ui.fragment.ActionBar;\r
import android.accounts.Account;\r
import android.accounts.AccountManager;\r
-import android.app.Activity;\r
+import android.app.FragmentManager;\r
import android.app.Service;\r
import android.content.Intent;\r
import android.database.Cursor;\r
import android.net.Uri;\r
import android.os.Bundle;\r
import android.support.v4.app.FragmentTransaction;\r
-import android.support.v4.app.Fragment;\r
-import android.support.v4.app.ListFragment;\r
-import android.util.Log;\r
import android.view.LayoutInflater;\r
import android.view.View;\r
import android.view.ViewGroup;\r
import android.widget.AdapterView;\r
-import android.widget.ArrayAdapter;\r
-import android.widget.ListView;\r
import android.widget.TextView;\r
-import android.widget.Toast;\r
-import android.widget.AdapterView.OnItemClickListener;\r
+import eu.alefzero.owncloud.R;\r
+import eu.alefzero.owncloud.authenticator.AccountAuthenticator;\r
+import eu.alefzero.owncloud.db.ProviderMeta.ProviderTableMeta;\r
+import eu.alefzero.owncloud.ui.FragmentListView;\r
+import eu.alefzero.owncloud.ui.activity.FileDetailActivity;\r
+import eu.alefzero.owncloud.ui.activity.FileDisplayActivity;\r
+import eu.alefzero.owncloud.ui.adapter.FileListListAdapter;\r
\r
/**\r
* A Fragment that lists all files and folders in a given path.\r
private Cursor mCursor;\r
private Account mAccount;\r
private AccountManager mAccountManager;\r
- private View mheaderView;\r
- private Stack<String> mParentsIds;\r
- private Stack<String> mDirNames;\r
+ private String mDirName;\r
+ private String mParentId;\r
+\r
+ public FileList() {\r
+ mDirName = null;\r
+ mParentId = null;\r
+ }\r
\r
+ public FileList(String dirName, String parentId) {\r
+ mDirName = dirName;\r
+ mParentId = parentId;\r
+ }\r
+ \r
@Override\r
public void onCreate(Bundle savedInstanceState) {\r
- // TODO Auto-generated method stub\r
super.onCreate(savedInstanceState);\r
- \r
- mParentsIds = new Stack<String>();\r
- mDirNames = new Stack<String>();\r
+\r
mAccountManager = (AccountManager)getActivity().getSystemService(Service.ACCOUNT_SERVICE);\r
mAccount = mAccountManager.getAccountsByType(AccountAuthenticator.ACCOUNT_TYPE)[0];\r
populateFileList();\r
}\r
\r
@Override\r
- public void onActivityCreated(Bundle savedInstanceState) {\r
- // TODO Auto-generated method stub\r
- super.onActivityCreated(savedInstanceState);\r
- }\r
- \r
- @Override\r
public void onItemClick(AdapterView<?> l, View v, int position, long id) {\r
- FileDetail fd = (FileDetail) getFragmentManager().findFragmentById(R.id.fileDetail);\r
+ FileDetail fd = (FileDetail) getFragmentManager().findFragmentById(R.id.fileDetail); \r
if (!mCursor.moveToPosition(position)) {\r
throw new IndexOutOfBoundsException("Incorrect item selected");\r
}\r
\r
if (mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta.FILE_CONTENT_TYPE)).equals("DIR")) {\r
String id_ = mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta._ID));\r
- mParentsIds.push(id_);\r
String dirname = mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta.FILE_NAME));\r
- mDirNames.push(dirname);\r
- ((FileDisplayActivity)getActivity()).pushPath(DisplayUtils.HtmlDecode(dirname));\r
- mCursor = getActivity().managedQuery(Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_DIR, id_),\r
- null,\r
- ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?",\r
- new String[]{mAccount.name}, null);\r
- setListAdapter(new FileListListAdapter(mCursor, getActivity()));\r
- //super.onListItemClick(l, v, position, id);\r
+\r
+ FileList fl = new FileList(dirname, id_);\r
+ ((FileDisplayActivity)getActivity()).pushPath(dirname);\r
+\r
+ FragmentTransaction ft = getSupportFragmentManager().beginTransaction();\r
+ ft.addToBackStack(null);\r
+ ft.replace(R.id.file_list_container, fl);\r
+ ft.commit();\r
+ getSupportFragmentManager().executePendingTransactions();\r
return;\r
}\r
Intent i = new Intent(getActivity(), FileDetailActivity.class);\r
i.putExtra("FILE_NAME", ((TextView)v.findViewById(R.id.Filename)).getText());\r
if (fd != null) {\r
fd.setStuff(i);\r
- //fd.use(((TextView)v.findViewById(R.id.Filename)).getText());\r
} else {\r
- i.putExtra("FILE_NAME", ((TextView)v.findViewById(R.id.Filename)).getText());\r
startActivity(i);\r
}\r
- FragmentTransaction ft = getFragmentManager().beginTransaction();\r
- ft.replace(R.id.fileList, this);\r
- ft.commitAllowingStateLoss();\r
- //super.onListItemClick(l, v, position, id);\r
- \r
- }\r
- \r
- @Override\r
- public void onDestroyView() {\r
- setListAdapter(null);\r
- super.onDestroyView();\r
}\r
\r
private void populateFileList() {\r
- mCursor = getActivity().getContentResolver().query(ProviderTableMeta.CONTENT_URI,\r
+ if (mParentId == null || mDirName == null) {\r
+ mCursor = getActivity().getContentResolver().query(ProviderTableMeta.CONTENT_URI,\r
null,\r
ProviderTableMeta.FILE_ACCOUNT_OWNER+"=?",\r
new String[]{mAccount.name},\r
null);\r
- \r
- setListAdapter(new FileListListAdapter(mCursor, getActivity()));\r
- }\r
- \r
- public void onBackPressed() {\r
- if (!mParentsIds.empty()) {\r
- mParentsIds.pop();\r
- mDirNames.pop();\r
- }\r
- if (!mParentsIds.empty()) {\r
- \r
- String id_ = mParentsIds.peek();\r
- String dirname = mDirNames.peek();\r
- mCursor = getActivity().managedQuery(Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_DIR, id_),\r
- null,\r
- ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?",\r
- new String[]{mAccount.name}, null);\r
- setListAdapter(new FileListListAdapter(mCursor, getActivity()));\r
} else {\r
- populateFileList();\r
+ mCursor = getActivity().managedQuery(Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_DIR, mParentId),\r
+ null,\r
+ ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?",\r
+ new String[]{mAccount.name}, null);\r
}\r
- \r
+ setListAdapter(new FileListListAdapter(mCursor, getActivity()));\r
}\r
}\r