moving from eu.alefzero.eu to com.owncloud.android
[pub/Android/ownCloud.git] / src / eu / alefzero / owncloud / ui / fragment / FileListFragment.java
diff --git a/src/eu/alefzero/owncloud/ui/fragment/FileListFragment.java b/src/eu/alefzero/owncloud/ui/fragment/FileListFragment.java
deleted file mode 100644 (file)
index 5647bf5..0000000
+++ /dev/null
@@ -1,209 +0,0 @@
-/* ownCloud Android client application\r
- *   Copyright (C) 2011  Bartek Przybylski\r
- *\r
- *   This program is free software: you can redistribute it and/or modify\r
- *   it under the terms of the GNU General Public License as published by\r
- *   the Free Software Foundation, either version 3 of the License, or\r
- *   (at your option) any later version.\r
- *\r
- *   This program is distributed in the hope that it will be useful,\r
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- *   GNU General Public License for more details.\r
- *\r
- *   You should have received a copy of the GNU General Public License\r
- *   along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
- *\r
- */\r
-package eu.alefzero.owncloud.ui.fragment;\r
-\r
-import java.util.Stack;\r
-import java.util.Vector;\r
-\r
-import android.accounts.Account;\r
-import android.content.ClipData;\r
-import android.content.ClipDescription;\r
-import android.content.Intent;\r
-import android.os.Bundle;\r
-import android.support.v4.app.FragmentTransaction;\r
-import android.util.Log;\r
-import android.view.View;\r
-import android.widget.AdapterView;\r
-import android.widget.Toast;\r
-import eu.alefzero.owncloud.AccountUtils;\r
-import eu.alefzero.owncloud.FileDownloader;\r
-import eu.alefzero.owncloud.R;\r
-import eu.alefzero.owncloud.datamodel.DataStorageManager;\r
-import eu.alefzero.owncloud.datamodel.FileDataStorageManager;\r
-import eu.alefzero.owncloud.datamodel.OCFile;\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
- * \r
- * @author Bartek Przybylski\r
- * \r
- */\r
-public class FileListFragment extends FragmentListView {\r
-    private Account mAccount;\r
-    private Stack<String> mDirNames;\r
-    private Vector<OCFile> mFiles;\r
-    private DataStorageManager mStorageManager;\r
-\r
-    public FileListFragment() {\r
-        mDirNames = new Stack<String>();\r
-    }\r
-\r
-    @Override\r
-    public void onCreate(Bundle savedInstanceState) {\r
-        super.onCreate(savedInstanceState);\r
-\r
-        mAccount = AccountUtils.getCurrentOwnCloudAccount(getActivity());\r
-        getListView().setDivider(\r
-                getResources().getDrawable(R.drawable.uploader_list_separator));\r
-        getListView().setDividerHeight(1);\r
-\r
-        populateFileList();\r
-    }\r
-\r
-    @Override\r
-    public void onItemClick(AdapterView<?> l, View v, int position, long id) {\r
-        if (mFiles.size() <= position) {\r
-            throw new IndexOutOfBoundsException("Incorrect item selected");\r
-        }\r
-        OCFile file = mFiles.get(position);\r
-\r
-        // Update ActionBarPath\r
-        if (file.getMimetype().equals("DIR")) {\r
-            String dirname = file.getFileName();\r
-\r
-            mDirNames.push(dirname);\r
-            ((FileDisplayActivity) getActivity()).pushPath(dirname);\r
-\r
-            populateFileList();\r
-            return;\r
-        }\r
-\r
-        Intent showDetailsIntent = new Intent(getActivity(),\r
-                FileDetailActivity.class);\r
-        showDetailsIntent.putExtra(FileDetailFragment.FILE, file);\r
-        showDetailsIntent.putExtra(FileDownloader.EXTRA_ACCOUNT, mAccount);\r
-\r
-        // Try to find by tag first\r
-        FileDetailFragment fd = (FileDetailFragment) getFragmentManager()\r
-                .findFragmentByTag("FileDetails");\r
-\r
-        // Could be the first time the user has touched a file. find by id\r
-        if (fd == null) {\r
-            fd = (FileDetailFragment) getFragmentManager().findFragmentById(\r
-                    R.id.fileDetail);\r
-        }\r
-\r
-        // Tablets will have this fragment, phones not. Could still be null\r
-        if (fd != null) {\r
-\r
-            if (fd.isEmptyLayout()) {\r
-                // True, if this is the first time a user taps on a file\r
-                fd = new FileDetailFragment(showDetailsIntent);\r
-                FragmentTransaction transaction = getFragmentManager()\r
-                        .beginTransaction();\r
-                transaction.replace(R.id.file_details_container, fd,\r
-                        "FileDetails");\r
-                transaction.commit();\r
-            } else {\r
-                fd.updateFileDetails(showDetailsIntent);\r
-            }\r
-\r
-        } else {\r
-            startActivity(showDetailsIntent);\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2,\r
-            long arg3) {\r
-        ClipData.Item item = new ClipData.Item("ASD");\r
-        ClipDescription cd = new ClipDescription("ASD",\r
-                new String[] { ClipDescription.MIMETYPE_TEXT_PLAIN });\r
-        ClipData dragData = new ClipData(cd, item);\r
-        arg1.startDrag(dragData,\r
-                new View.DragShadowBuilder(arg0.getChildAt(arg2)), null, 0);\r
-        return true;\r
-    }\r
-\r
-    /**\r
-     * Call this, when the user presses the up button\r
-     */\r
-    public void onNavigateUp() {\r
-        mDirNames.pop();\r
-        populateFileList();\r
-    }\r
-\r
-    /**\r
-     * Lists the directory\r
-     */\r
-    public void populateFileList() {\r
-        String s = "/";\r
-        for (String a : mDirNames)\r
-            s += a + "/";\r
-        Log.e("ASD", s);\r
-\r
-        mStorageManager = new FileDataStorageManager(mAccount, getActivity()\r
-                .getContentResolver());\r
-        OCFile file = mStorageManager.getFileByPath(s);\r
-        mFiles = mStorageManager.getDirectoryContent(file);\r
-        if (mFiles == null || mFiles.size() == 0) {\r
-            Toast.makeText(getActivity(), "There are no files here",\r
-                    Toast.LENGTH_LONG).show();\r
-        }\r
-        setListAdapter(new FileListListAdapter(file, mStorageManager,\r
-                getActivity()));\r
-    }\r
-\r
-    // TODO: Delete this testing stuff.\r
-    /*\r
-     * private void addContact(Account account, String name, String username) {\r
-     * Log.i("ASD", "Adding contact: " + name);\r
-     * ArrayList<ContentProviderOperation> operationList = new\r
-     * ArrayList<ContentProviderOperation>();\r
-     * \r
-     * //Create our RawContact ContentProviderOperation.Builder builder =\r
-     * ContentProviderOperation.newInsert(RawContacts.CONTENT_URI);\r
-     * builder.withValue(RawContacts.ACCOUNT_NAME, account.name);\r
-     * builder.withValue(RawContacts.ACCOUNT_TYPE, account.type);\r
-     * builder.withValue(RawContacts.SYNC1, username);\r
-     * operationList.add(builder.build());\r
-     * \r
-     * //Create a Data record of common type 'StructuredName' for our RawContact\r
-     * builder =\r
-     * ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI);\r
-     * builder\r
-     * .withValueBackReference(ContactsContract.CommonDataKinds.StructuredName\r
-     * .RAW_CONTACT_ID, 0); builder.withValue(ContactsContract.Data.MIMETYPE,\r
-     * ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE);\r
-     * builder\r
-     * .withValue(ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME,\r
-     * name); operationList.add(builder.build());\r
-     * \r
-     * //Create a Data record of custom type\r
-     * "vnd.android.cursor.item/vnd.fm.last.android.profile" to display a link\r
-     * to the Last.fm profile builder =\r
-     * ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI);\r
-     * builder.withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0);\r
-     * builder.withValue(ContactsContract.Data.MIMETYPE,\r
-     * "vnd.android.cursor.item/vnd.owncloud.contact.profile");\r
-     * builder.withValue(ContactsContract.Data.DATA1, username);\r
-     * builder.withValue(ContactsContract.Data.DATA2, "Last.fm Profile");\r
-     * builder.withValue(ContactsContract.Data.DATA3, "View profile");\r
-     * operationList.add(builder.build());\r
-     * \r
-     * try {\r
-     * getActivity().getContentResolver().applyBatch(ContactsContract.AUTHORITY,\r
-     * operationList); } catch (Exception e) { Log.e("ASD",\r
-     * "Something went wrong during creation! " + e); e.printStackTrace(); } }\r
-     */\r
-\r
-}\r