More cleanup / refactoring: Name Fragments consistantly way
authorLennart Rosam <lennart@familie-rosam.de>
Sat, 14 Apr 2012 16:55:15 +0000 (18:55 +0200)
committerLennart Rosam <lennart@familie-rosam.de>
Sat, 14 Apr 2012 16:55:15 +0000 (18:55 +0200)
AndroidManifest.xml
res/layout/file_activity_details.xml
res/layout/file_details.xml [deleted file]
res/layout/file_details_fragment.xml [new file with mode: 0644]
res/layout/files.xml
src/eu/alefzero/owncloud/ui/activity/FileDetailActivity.java
src/eu/alefzero/owncloud/ui/activity/FileDisplayActivity.java
src/eu/alefzero/owncloud/ui/fragment/FileDetail.java [deleted file]
src/eu/alefzero/owncloud/ui/fragment/FileDetailFragment.java [new file with mode: 0644]
src/eu/alefzero/owncloud/ui/fragment/FileList.java [deleted file]
src/eu/alefzero/owncloud/ui/fragment/FileListFragment.java [new file with mode: 0644]

index 493cbfe..c278a8e 100644 (file)
         <service android:name=".FileDownloader" >\r
         </service>\r
 \r
-        <activity android:name=".ui.activity.FileDetailActivity" >\r
+        <activity android:name=".ui.activity.FileDetailActivity" \r
+            android:theme="@style/Theme.ownCloud">\r
         </activity>\r
         <activity\r
             android:name=".ui.activity.LandingActivity"\r
index 3abab9d..304b97f 100644 (file)
@@ -8,6 +8,6 @@
     android:id="@+id/fileDetail"\r
     android:layout_width="fill_parent"\r
     android:layout_height="fill_parent"\r
-    class="eu.alefzero.owncloud.ui.fragment.FileDetail" />\r
+    class="eu.alefzero.owncloud.ui.fragment.FileDetailFragment" />\r
 \r
 </LinearLayout>
\ No newline at end of file
diff --git a/res/layout/file_details.xml b/res/layout/file_details.xml
deleted file mode 100644 (file)
index e02ed7c..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="fill_parent"
-    android:layout_height="fill_parent"
-    android:background="#F7F7F7"
-    android:orientation="vertical" >
-
-    <LinearLayout
-        android:id="@+id/linearLayout1"
-        android:layout_width="fill_parent"
-        android:layout_height="wrap_content" >
-
-        <LinearLayout
-            android:id="@+id/linearLayout2"
-            android:layout_width="wrap_content"
-            android:layout_height="fill_parent" >
-
-            <ImageView
-                android:id="@+id/imageView1"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:src="@drawable/icon" >
-            </ImageView>
-        </LinearLayout>
-
-        <LinearLayout
-            android:id="@+id/linearLayout3"
-            android:layout_width="wrap_content"
-            android:layout_height="fill_parent"
-            android:orientation="vertical" >
-
-            <TextView
-                android:id="@+id/textView1"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:text="TextView" >
-            </TextView>
-
-            <TextView
-                android:id="@+id/textView2"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:text="TextView" >
-            </TextView>
-
-            <TextView
-                android:id="@+id/textView3"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:text="TextView" >
-            </TextView>
-
-            <TextView
-                android:id="@+id/textView4"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:text="TextView" >
-            </TextView>
-
-            <TextView
-                android:id="@+id/textView5"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:text="TextView" >
-            </TextView>
-        </LinearLayout>
-    </LinearLayout>
-
-    <LinearLayout
-        android:id="@+id/linearLayout4"
-        android:layout_width="fill_parent"
-        android:layout_height="fill_parent" >
-
-        <ImageView
-            android:id="@+id/imageView2"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:src="@drawable/action_item_btn" />
-
-        <VideoView
-            android:id="@+id/videoView1"
-            android:layout_width="wrap_content"
-            android:layout_height="match_parent" />
-
-        <ListView
-            android:id="@android:id/list"
-            android:layout_width="fill_parent"
-            android:layout_height="fill_parent"
-            android:divider="@drawable/uploader_list_separator"
-            android:dividerHeight="1dip" >
-        </ListView>
-    </LinearLayout>
-
-</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/file_details_fragment.xml b/res/layout/file_details_fragment.xml
new file mode 100644 (file)
index 0000000..e02ed7c
--- /dev/null
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:background="#F7F7F7"
+    android:orientation="vertical" >
+
+    <LinearLayout
+        android:id="@+id/linearLayout1"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content" >
+
+        <LinearLayout
+            android:id="@+id/linearLayout2"
+            android:layout_width="wrap_content"
+            android:layout_height="fill_parent" >
+
+            <ImageView
+                android:id="@+id/imageView1"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:src="@drawable/icon" >
+            </ImageView>
+        </LinearLayout>
+
+        <LinearLayout
+            android:id="@+id/linearLayout3"
+            android:layout_width="wrap_content"
+            android:layout_height="fill_parent"
+            android:orientation="vertical" >
+
+            <TextView
+                android:id="@+id/textView1"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="TextView" >
+            </TextView>
+
+            <TextView
+                android:id="@+id/textView2"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="TextView" >
+            </TextView>
+
+            <TextView
+                android:id="@+id/textView3"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="TextView" >
+            </TextView>
+
+            <TextView
+                android:id="@+id/textView4"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="TextView" >
+            </TextView>
+
+            <TextView
+                android:id="@+id/textView5"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="TextView" >
+            </TextView>
+        </LinearLayout>
+    </LinearLayout>
+
+    <LinearLayout
+        android:id="@+id/linearLayout4"
+        android:layout_width="fill_parent"
+        android:layout_height="fill_parent" >
+
+        <ImageView
+            android:id="@+id/imageView2"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:src="@drawable/action_item_btn" />
+
+        <VideoView
+            android:id="@+id/videoView1"
+            android:layout_width="wrap_content"
+            android:layout_height="match_parent" />
+
+        <ListView
+            android:id="@android:id/list"
+            android:layout_width="fill_parent"
+            android:layout_height="fill_parent"
+            android:divider="@drawable/uploader_list_separator"
+            android:dividerHeight="1dip" >
+        </ListView>
+    </LinearLayout>
+
+</LinearLayout>
\ No newline at end of file
index c64e3e8..9cbd3bb 100644 (file)
@@ -8,7 +8,7 @@
                 android:id="@+id/fileList"\r
                 android:layout_width="fill_parent"\r
                 android:layout_height="fill_parent"\r
-                class="eu.alefzero.owncloud.ui.fragment.FileList" >\r
+                class="eu.alefzero.owncloud.ui.fragment.FileListFragment" >\r
                 <!-- Preview: layout=@layout/list_layout -->\r
             </fragment>\r
 </LinearLayout>
\ No newline at end of file
index 08710c5..f772e1d 100644 (file)
@@ -25,7 +25,7 @@ import android.view.Window;
 import com.actionbarsherlock.app.SherlockFragmentActivity;\r
 \r
 import eu.alefzero.owncloud.R;\r
-import eu.alefzero.owncloud.ui.fragment.FileDetail;\r
+import eu.alefzero.owncloud.ui.fragment.FileDetailFragment;\r
 \r
 /**\r
  * This activity displays the details of a file like\r
@@ -34,7 +34,7 @@ import eu.alefzero.owncloud.ui.fragment.FileDetail;
  *\r
  */\r
 public class FileDetailActivity extends SherlockFragmentActivity {\r
-  private FileDetail mFileDetail;\r
+  private FileDetailFragment mFileDetail;\r
   \r
 @Override\r
 protected void onCreate(Bundle savedInstanceState) {\r
@@ -43,7 +43,7 @@ protected void onCreate(Bundle savedInstanceState) {
   getWindow().requestFeature(Window.FEATURE_NO_TITLE);\r
   setContentView(R.layout.file_activity_details);\r
   \r
-  mFileDetail = new FileDetail();\r
+  mFileDetail = new FileDetailFragment();\r
   FragmentTransaction ft = getSupportFragmentManager().beginTransaction();\r
   ft.add(R.id.fileDetail, mFileDetail);\r
   ft.commit();\r
index 5656d3f..0d04251 100644 (file)
@@ -46,7 +46,7 @@ import eu.alefzero.owncloud.R;
 import eu.alefzero.owncloud.authenticator.AccountAuthenticator;\r
 import eu.alefzero.owncloud.authenticator.AuthUtils;\r
 import eu.alefzero.owncloud.datamodel.OCFile;\r
-import eu.alefzero.owncloud.ui.fragment.FileList;\r
+import eu.alefzero.owncloud.ui.fragment.FileListFragment;\r
 import eu.alefzero.webdav.WebdavClient;\r
 \r
 /**\r
@@ -154,7 +154,7 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements
                        startActivity(intent);\r
                        return;\r
                }\r
-               ((FileList) getSupportFragmentManager().findFragmentById(R.id.fileList))\r
+               ((FileListFragment) getSupportFragmentManager().findFragmentById(R.id.fileList))\r
                                .onNavigateUp();\r
        }\r
 \r
diff --git a/src/eu/alefzero/owncloud/ui/fragment/FileDetail.java b/src/eu/alefzero/owncloud/ui/fragment/FileDetail.java
deleted file mode 100644 (file)
index 5e729ff..0000000
+++ /dev/null
@@ -1,147 +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 android.accounts.Account;\r
-import android.content.Intent;\r
-import android.database.Cursor;\r
-import android.graphics.Bitmap;\r
-import android.graphics.BitmapFactory;\r
-import android.net.Uri;\r
-import android.os.Bundle;\r
-import android.view.LayoutInflater;\r
-import android.view.View;\r
-import android.view.View.OnClickListener;\r
-import android.view.ViewGroup;\r
-import android.widget.ImageView;\r
-import android.widget.TextView;\r
-import android.widget.Toast;\r
-import android.widget.VideoView;\r
-\r
-import com.actionbarsherlock.app.SherlockFragment;\r
-\r
-import eu.alefzero.owncloud.DisplayUtils;\r
-import eu.alefzero.owncloud.FileDownloader;\r
-import eu.alefzero.owncloud.R;\r
-import eu.alefzero.owncloud.db.ProviderMeta.ProviderTableMeta;\r
-\r
-/**\r
- * This Fragment is used to display the details about a file.\r
- * @author Bartek Przybylski\r
- *\r
- */\r
-public class FileDetail extends SherlockFragment implements OnClickListener {\r
-  \r
-  private Intent mIntent;\r
-  private View mView;\r
-  \r
-  public void setStuff(Intent intent) {\r
-    mIntent = intent;\r
-    setStuff(getView());\r
-  }\r
-  \r
-  private void setStuff(View view) {\r
-    mView = view;\r
-    String id = mIntent.getStringExtra("FILE_ID");\r
-    Account account = mIntent.getParcelableExtra("ACCOUNT");\r
-    String account_name = account.name;\r
-    Cursor c = getActivity().managedQuery(\r
-        Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_FILE, id),\r
-        null,\r
-        ProviderTableMeta.FILE_ACCOUNT_OWNER+"=?",\r
-        new String[]{account_name},\r
-        null);\r
-    c.moveToFirst();\r
-\r
-    // Retrieve details from DB\r
-    String filename = c.getString(c.getColumnIndex(ProviderTableMeta.FILE_NAME));\r
-    String mimetype = c.getString(c.getColumnIndex(ProviderTableMeta.FILE_CONTENT_TYPE));\r
-    String path = c.getString(c.getColumnIndex(ProviderTableMeta.FILE_STORAGE_PATH));\r
-    long filesize = c.getLong(c.getColumnIndex(ProviderTableMeta.FILE_CONTENT_LENGTH));\r
-\r
-    // set file details\r
-    setFilename(filename);\r
-    setFiletype(DisplayUtils.convertMIMEtoPrettyPrint(mimetype));\r
-    setFilesize(filesize);\r
-    \r
-    // set file preview if available and possible\r
-    View w = view.findViewById(R.id.videoView1);\r
-    w.setVisibility(View.INVISIBLE);\r
-    if (path == null) {\r
-      ImageView v = (ImageView) getView().findViewById(R.id.imageView2);\r
-      v.setImageResource(R.drawable.download);\r
-      v.setOnClickListener(this);\r
-    } else {\r
-      if (mimetype.startsWith("image/")) {\r
-        ImageView v = (ImageView) view.findViewById(R.id.imageView2);\r
-        Bitmap bmp = BitmapFactory.decodeFile(path);\r
-        v.setImageBitmap(bmp);\r
-      } else if (mimetype.startsWith("video/")) {\r
-        VideoView v = (VideoView) view.findViewById(R.id.videoView1);\r
-        v.setVisibility(View.VISIBLE);\r
-        v.setVideoPath(path);\r
-        v.start();\r
-      }\r
-    }\r
-  }\r
-\r
-  @Override\r
-  public View onCreateView(LayoutInflater inflater, ViewGroup container,\r
-      Bundle savedInstanceState) {\r
-    View v = null;\r
-    \r
-    if (getActivity().getIntent() != null && getActivity().getIntent().getStringExtra("FILE_ID") != null) {\r
-       v = inflater.inflate(R.layout.file_details, container, false);\r
-       mIntent = getActivity().getIntent();\r
-       setStuff(v);\r
-    } else {\r
-       v = inflater.inflate(R.layout.file_details_empty, container, false);\r
-    }\r
-    return v;\r
-  }\r
-\r
-  @Override\r
-  public View getView() {\r
-    return mView == null ? super.getView() : mView;\r
-  };\r
-  \r
-  public void setFilename(String filename) {\r
-    TextView tv = (TextView) getView().findViewById(R.id.textView1);\r
-    if (tv != null) tv.setText(filename);\r
-  }\r
-  \r
-  public void setFiletype(String mimetype) {\r
-    TextView tv = (TextView) getView().findViewById(R.id.textView2);\r
-    if (tv != null) tv.setText(mimetype);\r
-  }\r
-  \r
-  public void setFilesize(long filesize) {\r
-    TextView tv = (TextView) getView().findViewById(R.id.textView3);\r
-    if (tv != null) tv.setText(DisplayUtils.bitsToHumanReadable(filesize));\r
-  }\r
-\r
-  @Override\r
-  public void onClick(View v) {\r
-    Toast.makeText(getActivity(), "Downloading", Toast.LENGTH_LONG).show();\r
-    Intent i = new Intent(getActivity(), FileDownloader.class);\r
-    i.putExtra(FileDownloader.EXTRA_ACCOUNT, mIntent.getParcelableExtra("ACCOUNT"));\r
-    i.putExtra(FileDownloader.EXTRA_FILE_PATH, mIntent.getStringExtra("FULL_PATH"));\r
-    getActivity().startService(i);\r
-  }\r
-  \r
-}\r
diff --git a/src/eu/alefzero/owncloud/ui/fragment/FileDetailFragment.java b/src/eu/alefzero/owncloud/ui/fragment/FileDetailFragment.java
new file mode 100644 (file)
index 0000000..fac9fa4
--- /dev/null
@@ -0,0 +1,147 @@
+/* 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 android.accounts.Account;\r
+import android.content.Intent;\r
+import android.database.Cursor;\r
+import android.graphics.Bitmap;\r
+import android.graphics.BitmapFactory;\r
+import android.net.Uri;\r
+import android.os.Bundle;\r
+import android.view.LayoutInflater;\r
+import android.view.View;\r
+import android.view.View.OnClickListener;\r
+import android.view.ViewGroup;\r
+import android.widget.ImageView;\r
+import android.widget.TextView;\r
+import android.widget.Toast;\r
+import android.widget.VideoView;\r
+\r
+import com.actionbarsherlock.app.SherlockFragment;\r
+\r
+import eu.alefzero.owncloud.DisplayUtils;\r
+import eu.alefzero.owncloud.FileDownloader;\r
+import eu.alefzero.owncloud.R;\r
+import eu.alefzero.owncloud.db.ProviderMeta.ProviderTableMeta;\r
+\r
+/**\r
+ * This Fragment is used to display the details about a file.\r
+ * @author Bartek Przybylski\r
+ *\r
+ */\r
+public class FileDetailFragment extends SherlockFragment implements OnClickListener {\r
+  \r
+  private Intent mIntent;\r
+  private View mView;\r
+  \r
+  public void setStuff(Intent intent) {\r
+    mIntent = intent;\r
+    setStuff(getView());\r
+  }\r
+  \r
+  private void setStuff(View view) {\r
+    mView = view;\r
+    String id = mIntent.getStringExtra("FILE_ID");\r
+    Account account = mIntent.getParcelableExtra("ACCOUNT");\r
+    String account_name = account.name;\r
+    Cursor c = getActivity().managedQuery(\r
+        Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_FILE, id),\r
+        null,\r
+        ProviderTableMeta.FILE_ACCOUNT_OWNER+"=?",\r
+        new String[]{account_name},\r
+        null);\r
+    c.moveToFirst();\r
+\r
+    // Retrieve details from DB\r
+    String filename = c.getString(c.getColumnIndex(ProviderTableMeta.FILE_NAME));\r
+    String mimetype = c.getString(c.getColumnIndex(ProviderTableMeta.FILE_CONTENT_TYPE));\r
+    String path = c.getString(c.getColumnIndex(ProviderTableMeta.FILE_STORAGE_PATH));\r
+    long filesize = c.getLong(c.getColumnIndex(ProviderTableMeta.FILE_CONTENT_LENGTH));\r
+\r
+    // set file details\r
+    setFilename(filename);\r
+    setFiletype(DisplayUtils.convertMIMEtoPrettyPrint(mimetype));\r
+    setFilesize(filesize);\r
+    \r
+    // set file preview if available and possible\r
+    View w = view.findViewById(R.id.videoView1);\r
+    w.setVisibility(View.INVISIBLE);\r
+    if (path == null) {\r
+      ImageView v = (ImageView) getView().findViewById(R.id.imageView2);\r
+      v.setImageResource(R.drawable.download);\r
+      v.setOnClickListener(this);\r
+    } else {\r
+      if (mimetype.startsWith("image/")) {\r
+        ImageView v = (ImageView) view.findViewById(R.id.imageView2);\r
+        Bitmap bmp = BitmapFactory.decodeFile(path);\r
+        v.setImageBitmap(bmp);\r
+      } else if (mimetype.startsWith("video/")) {\r
+        VideoView v = (VideoView) view.findViewById(R.id.videoView1);\r
+        v.setVisibility(View.VISIBLE);\r
+        v.setVideoPath(path);\r
+        v.start();\r
+      }\r
+    }\r
+  }\r
+\r
+  @Override\r
+  public View onCreateView(LayoutInflater inflater, ViewGroup container,\r
+      Bundle savedInstanceState) {\r
+    View v = null;\r
+    \r
+    if (getActivity().getIntent() != null && getActivity().getIntent().getStringExtra("FILE_ID") != null) {\r
+       v = inflater.inflate(R.layout.file_details_fragment, container, false);\r
+       mIntent = getActivity().getIntent();\r
+       setStuff(v);\r
+    } else {\r
+       v = inflater.inflate(R.layout.file_details_empty, container, false);\r
+    }\r
+    return v;\r
+  }\r
+\r
+  @Override\r
+  public View getView() {\r
+    return mView == null ? super.getView() : mView;\r
+  };\r
+  \r
+  public void setFilename(String filename) {\r
+    TextView tv = (TextView) getView().findViewById(R.id.textView1);\r
+    if (tv != null) tv.setText(filename);\r
+  }\r
+  \r
+  public void setFiletype(String mimetype) {\r
+    TextView tv = (TextView) getView().findViewById(R.id.textView2);\r
+    if (tv != null) tv.setText(mimetype);\r
+  }\r
+  \r
+  public void setFilesize(long filesize) {\r
+    TextView tv = (TextView) getView().findViewById(R.id.textView3);\r
+    if (tv != null) tv.setText(DisplayUtils.bitsToHumanReadable(filesize));\r
+  }\r
+\r
+  @Override\r
+  public void onClick(View v) {\r
+    Toast.makeText(getActivity(), "Downloading", Toast.LENGTH_LONG).show();\r
+    Intent i = new Intent(getActivity(), FileDownloader.class);\r
+    i.putExtra(FileDownloader.EXTRA_ACCOUNT, mIntent.getParcelableExtra("ACCOUNT"));\r
+    i.putExtra(FileDownloader.EXTRA_FILE_PATH, mIntent.getStringExtra("FULL_PATH"));\r
+    getActivity().startService(i);\r
+  }\r
+  \r
+}\r
diff --git a/src/eu/alefzero/owncloud/ui/fragment/FileList.java b/src/eu/alefzero/owncloud/ui/fragment/FileList.java
deleted file mode 100644 (file)
index 785b6ba..0000000
+++ /dev/null
@@ -1,146 +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.Intent;\r
-import android.os.Bundle;\r
-import android.view.View;\r
-import android.widget.AdapterView;\r
-import eu.alefzero.owncloud.R;\r
-import eu.alefzero.owncloud.authenticator.AuthUtils;\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
- * @author Bartek Przybylski\r
- *\r
- */\r
-public class FileList extends FragmentListView {\r
-  private Account mAccount;\r
-  private Stack<String> mDirNames;\r
-  private Vector<OCFile> mFiles;\r
-\r
-  public FileList() {\r
-    mDirNames = new Stack<String>();\r
-  }\r
-  \r
-  @Override\r
-  public void onCreate(Bundle savedInstanceState) {\r
-    super.onCreate(savedInstanceState);\r
-\r
-    mAccount = AuthUtils.getCurrentOwnCloudAccount(getActivity());\r
-    populateFileList();\r
-    // TODO: Remove this testing stuff\r
-    //addContact(mAccount, "Bartek Przybylski", "czlowiek");\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
-    String id_ = String.valueOf(file.getFileId());\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
-    Intent i = new Intent(getActivity(), FileDetailActivity.class);\r
-    i.putExtra("FILE_NAME", file.getFileName());\r
-    i.putExtra("FULL_PATH", file.getPath());\r
-    i.putExtra("FILE_ID", id_);\r
-    i.putExtra("ACCOUNT", mAccount);\r
-    FileDetail fd = (FileDetail) getFragmentManager().findFragmentById(R.id.fileDetail);\r
-    if (fd != null) {\r
-      fd.setStuff(i);\r
-    } else {\r
-      startActivity(i);\r
-    }\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
-  private void populateFileList() {\r
-    String s = "/";\r
-    for (String a : mDirNames)\r
-      s+= a+"/";\r
-\r
-    OCFile file = new OCFile(getActivity().getContentResolver(), mAccount, s);\r
-    mFiles = file.getDirectoryContent();\r
-    setListAdapter(new FileListListAdapter(file, getActivity()));\r
-  }\r
-  \r
-  //TODO: Delete this testing stuff.\r
-  /*private  void addContact(Account account, String name, String username) {\r
-    Log.i("ASD", "Adding contact: " + name);\r
-    ArrayList<ContentProviderOperation> operationList = new ArrayList<ContentProviderOperation>();\r
-    \r
-    //Create our RawContact\r
-    ContentProviderOperation.Builder builder = 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 = ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI);\r
-    builder.withValueBackReference(ContactsContract.CommonDataKinds.StructuredName.RAW_CONTACT_ID, 0);\r
-    builder.withValue(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE);\r
-    builder.withValue(ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME, name);\r
-    operationList.add(builder.build());\r
-    \r
-    //Create a Data record of custom type "vnd.android.cursor.item/vnd.fm.last.android.profile" to display a link to the Last.fm profile\r
-    builder = ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI);\r
-    builder.withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0);\r
-    builder.withValue(ContactsContract.Data.MIMETYPE, "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, operationList);\r
-    } catch (Exception e) {\r
-     Log.e("ASD", "Something went wrong during creation! " + e);\r
-     e.printStackTrace();\r
-    }\r
-   }*/\r
-  \r
-}\r
diff --git a/src/eu/alefzero/owncloud/ui/fragment/FileListFragment.java b/src/eu/alefzero/owncloud/ui/fragment/FileListFragment.java
new file mode 100644 (file)
index 0000000..a8bc9d3
--- /dev/null
@@ -0,0 +1,146 @@
+/* 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.Intent;\r
+import android.os.Bundle;\r
+import android.view.View;\r
+import android.widget.AdapterView;\r
+import eu.alefzero.owncloud.R;\r
+import eu.alefzero.owncloud.authenticator.AuthUtils;\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
+ * @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
+\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 = AuthUtils.getCurrentOwnCloudAccount(getActivity());\r
+    populateFileList();\r
+    // TODO: Remove this testing stuff\r
+    //addContact(mAccount, "Bartek Przybylski", "czlowiek");\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
+    String id_ = String.valueOf(file.getFileId());\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
+    Intent i = new Intent(getActivity(), FileDetailActivity.class);\r
+    i.putExtra("FILE_NAME", file.getFileName());\r
+    i.putExtra("FULL_PATH", file.getPath());\r
+    i.putExtra("FILE_ID", id_);\r
+    i.putExtra("ACCOUNT", mAccount);\r
+    FileDetailFragment fd = (FileDetailFragment) getFragmentManager().findFragmentById(R.id.fileDetail);\r
+    if (fd != null) {\r
+      fd.setStuff(i);\r
+    } else {\r
+      startActivity(i);\r
+    }\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
+  private void populateFileList() {\r
+    String s = "/";\r
+    for (String a : mDirNames)\r
+      s+= a+"/";\r
+\r
+    OCFile file = new OCFile(getActivity().getContentResolver(), mAccount, s);\r
+    mFiles = file.getDirectoryContent();\r
+    setListAdapter(new FileListListAdapter(file, getActivity()));\r
+  }\r
+  \r
+  //TODO: Delete this testing stuff.\r
+  /*private  void addContact(Account account, String name, String username) {\r
+    Log.i("ASD", "Adding contact: " + name);\r
+    ArrayList<ContentProviderOperation> operationList = new ArrayList<ContentProviderOperation>();\r
+    \r
+    //Create our RawContact\r
+    ContentProviderOperation.Builder builder = 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 = ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI);\r
+    builder.withValueBackReference(ContactsContract.CommonDataKinds.StructuredName.RAW_CONTACT_ID, 0);\r
+    builder.withValue(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE);\r
+    builder.withValue(ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME, name);\r
+    operationList.add(builder.build());\r
+    \r
+    //Create a Data record of custom type "vnd.android.cursor.item/vnd.fm.last.android.profile" to display a link to the Last.fm profile\r
+    builder = ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI);\r
+    builder.withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0);\r
+    builder.withValue(ContactsContract.Data.MIMETYPE, "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, operationList);\r
+    } catch (Exception e) {\r
+     Log.e("ASD", "Something went wrong during creation! " + e);\r
+     e.printStackTrace();\r
+    }\r
+   }*/\r
+  \r
+}\r