More refactoring
authorLennart Rosam <lennart@familie-rosam.de>
Sat, 4 Feb 2012 15:23:41 +0000 (16:23 +0100)
committerLennart Rosam <lennart@familie-rosam.de>
Sat, 4 Feb 2012 15:23:41 +0000 (16:23 +0100)
12 files changed:
res/layout-port/files.xml [new file with mode: 0644]
res/layout-port/main.xml [deleted file]
res/layout/file_activity_details.xml
res/layout/files.xml [new file with mode: 0644]
res/layout/landing_page.xml [deleted file]
res/layout/main.xml
src/eu/alefzero/owncloud/FileDetail.java [deleted file]
src/eu/alefzero/owncloud/ui/FileDetailActivity.java
src/eu/alefzero/owncloud/ui/FileDisplayActivity.java
src/eu/alefzero/owncloud/ui/LandingActivity.java
src/eu/alefzero/owncloud/ui/fragment/FileDetail.java [new file with mode: 0644]
src/eu/alefzero/owncloud/ui/fragment/FileList.java

diff --git a/res/layout-port/files.xml b/res/layout-port/files.xml
new file mode 100644 (file)
index 0000000..fbb30c3
--- /dev/null
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
+    android:layout_width="fill_parent"\r
+    android:layout_height="fill_parent"\r
+    android:background="#F7F7F7"\r
+    android:orientation="vertical" >\r
+\r
+    <fragment \r
+        android:id="@+id/actionBar"\r
+        android:layout_width="fill_parent"\r
+        android:layout_height="wrap_content"\r
+        class="eu.alefzero.owncloud.ui.fragment.ActionBar">\r
+        <!-- Preview: layout=@layout/action_bar -->\r
+    </fragment>\r
+\r
+    <fragment\r
+        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
+\r
+        <!-- Preview: layout=@layout/list_layout -->\r
+    </fragment>\r
+    <!-- </LinearLayout> -->\r
+\r
+</LinearLayout>
\ No newline at end of file
diff --git a/res/layout-port/main.xml b/res/layout-port/main.xml
deleted file mode 100644 (file)
index 881645e..0000000
+++ /dev/null
@@ -1,26 +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" >
-
-    <fragment 
-        android:id="@+id/actionBar"
-        android:layout_width="fill_parent"
-        android:layout_height="wrap_content"
-        class="eu.alefzero.owncloud.ui.fragment.ActionBar">
-        <!-- Preview: layout=@layout/action_bar -->
-    </fragment>
-
-    <fragment
-        android:id="@+id/fileList"
-        android:layout_width="fill_parent"
-        android:layout_height="fill_parent"
-        class="eu.alefzero.owncloud.ui.fragment.FileList" >
-
-        <!-- Preview: layout=@layout/list_layout -->
-    </fragment>
-    <!-- </LinearLayout> -->
-
-</LinearLayout>
\ No newline at end of file
index da5d312..3abab9d 100644 (file)
@@ -1,13 +1,13 @@
-<?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:orientation="vertical" >
-
-<fragment
-    android:id="@+id/fileDetail"
-    android:layout_width="fill_parent"
-    android:layout_height="fill_parent"
-    class="eu.alefzero.owncloud.FileDetail" />
-
+<?xml version="1.0" encoding="utf-8"?>\r
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
+    android:layout_width="fill_parent"\r
+    android:layout_height="fill_parent"\r
+    android:orientation="vertical" >\r
+\r
+<fragment\r
+    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
+\r
 </LinearLayout>
\ No newline at end of file
 </LinearLayout>
\ No newline at end of file
diff --git a/res/layout/files.xml b/res/layout/files.xml
new file mode 100644 (file)
index 0000000..012fb6e
--- /dev/null
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
+    android:layout_width="fill_parent"\r
+    android:layout_height="fill_parent"\r
+    android:background="#F7F7F7"\r
+    android:orientation="vertical" >\r
+\r
+    <LinearLayout\r
+        android:id="@+id/linearLayout1"\r
+        android:layout_width="fill_parent"\r
+        android:layout_height="fill_parent"\r
+        android:orientation="vertical" >\r
+\r
+        <fragment\r
+            android:id="@+id/actionBar"\r
+            android:layout_height="wrap_content"\r
+            android:layout_width="fill_parent"\r
+            class="eu.alefzero.owncloud.ui.fragment.ActionBar">\r
+            <!-- Preview: layout=@layout/action_bar -->\r
+        </fragment>\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
+\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
+    </LinearLayout>\r
+\r
+</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/landing_page.xml b/res/layout/landing_page.xml
deleted file mode 100644 (file)
index ef4705b..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>\r
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
-    android:layout_width="fill_parent"\r
-    android:layout_height="fill_parent"\r
-    android:background="#F7F7F7"\r
-    android:orientation="vertical" >
-\r
-    <fragment\r
-        android:id="@+id/actionBar"\r
-        android:layout_width="fill_parent"\r
-        android:layout_height="wrap_content"\r
-        class="eu.alefzero.owncloud.ui.fragment.ActionBar" >
-        <!-- Preview: layout=@layout/action_bar -->
-    </fragment>\r
-    \r
-    <fragment\r
-        android:id="@+id/landingPage"\r
-        android:layout_width="fill_parent"\r
-        android:layout_height="wrap_content"\r
-        class="eu.alefzero.owncloud.ui.fragment.LandingPageFragment" >\r
-        <!-- Preview: layout=@layout/landing_page_fragment -->\r
-    </fragment>\r
-\r
-    \r
-\r
-</LinearLayout>
\ No newline at end of file
index cddcacb..ef4705b 100644 (file)
@@ -1,49 +1,26 @@
-<?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"
+<?xml version="1.0" encoding="utf-8"?>\r
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
+    android:layout_width="fill_parent"\r
+    android:layout_height="fill_parent"\r
+    android:background="#F7F7F7"\r
     android:orientation="vertical" >
     android:orientation="vertical" >
-
-    <LinearLayout
-        android:id="@+id/linearLayout1"
-        android:layout_width="fill_parent"
-        android:layout_height="fill_parent"
-        android:orientation="vertical" >
-
-        <fragment
-            android:id="@+id/actionBar"
-            android:layout_height="wrap_content"
-            android:layout_width="fill_parent"
-            class="eu.alefzero.owncloud.ui.fragment.ActionBar">
-            <!-- Preview: layout=@layout/action_bar -->
-        </fragment>
-
-        <LinearLayout
-            android:id="@+id/linearLayout2"
-            android:layout_width="fill_parent"
-            android:layout_height="wrap_content" >
-
-            <fragment
-                android:id="@+id/fileList"
-                android:layout_width="0dp"
-                android:layout_height="fill_parent"
-                android:layout_weight="1"
-                class="eu.alefzero.owncloud.ui.fragment.FileList" >
-
-                <!-- Preview: layout=@layout/list_layout -->
-            </fragment>
-
-            <fragment
-                android:id="@+id/fileDetail"
-                android:layout_width="0dp"
-                android:layout_height="fill_parent"
-                android:layout_weight="2"
-                class="eu.alefzero.owncloud.FileDetail" >
-
-                <!-- Preview: layout=@layout/file_details -->
-            </fragment>
-        </LinearLayout>
-    </LinearLayout>
-
+\r
+    <fragment\r
+        android:id="@+id/actionBar"\r
+        android:layout_width="fill_parent"\r
+        android:layout_height="wrap_content"\r
+        class="eu.alefzero.owncloud.ui.fragment.ActionBar" >
+        <!-- Preview: layout=@layout/action_bar -->
+    </fragment>\r
+    \r
+    <fragment\r
+        android:id="@+id/landingPage"\r
+        android:layout_width="fill_parent"\r
+        android:layout_height="wrap_content"\r
+        class="eu.alefzero.owncloud.ui.fragment.LandingPageFragment" >\r
+        <!-- Preview: layout=@layout/landing_page_fragment -->\r
+    </fragment>\r
+\r
+    \r
+\r
 </LinearLayout>
\ No newline at end of file
 </LinearLayout>
\ No newline at end of file
diff --git a/src/eu/alefzero/owncloud/FileDetail.java b/src/eu/alefzero/owncloud/FileDetail.java
deleted file mode 100644 (file)
index 23a4f6a..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-package eu.alefzero.owncloud;
-
-import android.content.Intent;
-import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.TextView;
-import android.widget.Toast;
-
-public class FileDetail extends Fragment {
-  
-  public Intent mIntent;
-  
-  public void setStuff(Intent intent) {
-    setStuff(intent, getView());
-  }
-  
-  private void setStuff(Intent intent, View view) {
-    String filename = intent.getStringExtra("FILE_NAME");
-    String filepath = intent.getStringExtra("FILE_PATH");
-    setFilename(filename, view);
-  }
-  
-  @Override
-  public void onCreate(Bundle savedInstanceState) {
-    // TODO Auto-generated method stub
-    super.onCreate(savedInstanceState);
-  }
-
-  @Override
-  public void onActivityCreated(Bundle savedInstanceState) {
-    // TODO Auto-generated method stub
-    super.onActivityCreated(savedInstanceState);
-  }
-
-  @Override
-  public View onCreateView(LayoutInflater inflater, ViewGroup container,
-      Bundle savedInstanceState) {
-    View v = inflater.inflate(R.layout.file_details, container, false);
-    
-    if (getActivity().getIntent() != null) setStuff(getActivity().getIntent(), v);
-    return v;
-  }
-
-  private void setFilename(String filename, View target_view) {
-    TextView tv = (TextView) target_view.findViewById(R.id.textView1);
-    if (tv != null) tv.setText(filename);
-  }
-  
-  public void setFilename(String filename) {
-    setFilename(filename, getView());
-  }
-}
index 96a457b..989a601 100644 (file)
@@ -1,38 +1,38 @@
-package eu.alefzero.owncloud.ui;
-
-
-import eu.alefzero.owncloud.FileDetail;
-import eu.alefzero.owncloud.R;
-import eu.alefzero.owncloud.R.id;
-import eu.alefzero.owncloud.R.layout;
-import eu.alefzero.owncloud.ui.fragment.ActionBar;
-import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.content.res.Configuration;
-import android.os.Bundle;
-import android.support.v4.app.FragmentActivity;
-import android.support.v4.app.FragmentTransaction;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.view.View;
-import android.view.Window;
-
-public class FileDetailActivity extends FragmentActivity {
-  private FileDetail mFileDetail;
-  
-@Override
-protected void onCreate(Bundle savedInstanceState) {
-  // TODO Auto-generated method stub
-  super.onCreate(savedInstanceState);
-  getWindow().requestFeature(Window.FEATURE_NO_TITLE);
-  setContentView(R.layout.file_activity_details);
-  
-  mFileDetail = new FileDetail();
-  FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
-  ft.add(R.id.fileDetail, mFileDetail);
-  ft.commit();
-  
-}
-
-}
+package eu.alefzero.owncloud.ui;\r
+\r
+\r
+import eu.alefzero.owncloud.R;\r
+import eu.alefzero.owncloud.R.id;\r
+import eu.alefzero.owncloud.R.layout;\r
+import eu.alefzero.owncloud.ui.fragment.ActionBar;\r
+import eu.alefzero.owncloud.ui.fragment.FileDetail;\r
+import android.app.Activity;\r
+import android.content.Context;\r
+import android.content.Intent;\r
+import android.content.res.Configuration;\r
+import android.os.Bundle;\r
+import android.support.v4.app.FragmentActivity;\r
+import android.support.v4.app.FragmentTransaction;\r
+import android.util.AttributeSet;\r
+import android.util.Log;\r
+import android.view.View;\r
+import android.view.Window;\r
+\r
+public class FileDetailActivity extends FragmentActivity {\r
+  private FileDetail mFileDetail;\r
+  \r
+@Override\r
+protected void onCreate(Bundle savedInstanceState) {\r
+  // TODO Auto-generated method stub\r
+  super.onCreate(savedInstanceState);\r
+  getWindow().requestFeature(Window.FEATURE_NO_TITLE);\r
+  setContentView(R.layout.file_activity_details);\r
+  \r
+  mFileDetail = new FileDetail();\r
+  FragmentTransaction ft = getSupportFragmentManager().beginTransaction();\r
+  ft.add(R.id.fileDetail, mFileDetail);\r
+  ft.commit();\r
+  \r
+}\r
+\r
+}\r
index 07b8425..eb882a0 100644 (file)
-/* ownCloud Android client application
- *   Copyright (C) 2011  Bartek Przybylski
- *
- *   This program is free software: you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation, either version 3 of the License, or
- *   (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-package eu.alefzero.owncloud.ui;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.LinkedList;
-import java.util.Stack;
-
-import android.accounts.Account;
-import android.accounts.AccountManager;
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.app.ListActivity;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.DialogInterface.OnCancelListener;
-import android.content.res.Configuration;
-import android.database.Cursor;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.Matrix;
-import android.net.Uri;
-import android.os.Bundle;
-import android.os.Environment;
-import android.support.v4.app.FragmentActivity;
-import android.support.v4.app.FragmentTransaction;
-import android.text.TextUtils;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.Window;
-import android.widget.ImageView;
-import android.widget.ListView;
-import android.widget.TextView;
-import eu.alefzero.owncloud.DbHandler;
-import eu.alefzero.owncloud.FileDetail;
-import eu.alefzero.owncloud.R;
-import eu.alefzero.owncloud.R.id;
-import eu.alefzero.owncloud.R.layout;
-import eu.alefzero.owncloud.R.menu;
-import eu.alefzero.owncloud.R.string;
-import eu.alefzero.owncloud.authenticator.AccountAuthenticator;
-import eu.alefzero.owncloud.db.ProviderMeta.ProviderTableMeta;
-import eu.alefzero.owncloud.ui.fragment.FileList;
-import eu.alefzero.owncloud.ui.fragment.ActionBar;
-public class FileDisplayActivity extends FragmentActivity {
-  private DbHandler mDBHandler;
-  private Stack<String> mParents;
-  private LinkedList<String> mPath;
-  private Account mAccount;
-  private Cursor mCursor;
-  private boolean mIsDisplayingFile;
-
-  private static final int DIALOG_CHOOSE_ACCOUNT = 0;
-
-  @Override
-  public void onCreate(Bundle savedInstanceState) {
-    super.onCreate(savedInstanceState);
-    getWindow().requestFeature(Window.FEATURE_NO_TITLE);
-    setContentView(R.layout.main);
-    
-    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
-    //ft.add(R.id.actionBar, new ActionBar());
-    ft.add(R.id.fileList, new FileList());
-    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
-      ft.add(R.id.fileDetail, new FileDetail());
-    }
-    ft.commit();
-
-    /*getSupportFragmentManager().beginTransaction().add(arg0, arg1);
-    FileList fl = new FileList();
-    ft.add(R.id.fileList, fl);
-    ft.commit();
-    /*
-
-    
-    if (savedInstanceState != null) {
-      mParents = (Stack<String>)savedInstanceState.getSerializable("parentsStack");
-      mIsDisplayingFile = savedInstanceState.getBoolean("isDisplayingFile");
-      mPath = (LinkedList<String>)savedInstanceState.getSerializable("path");
-    } else {
-      mParents = new Stack<String>();
-      mPath = new LinkedList<String>();
-      mIsDisplayingFile = false;
-    }
-
-    mDBHandler = new DbHandler(getBaseContext());
-    requestWindowFeature(Window.FEATURE_NO_TITLE);
-    setContentView(R.layout.main);
-
-    AccountManager accMan = AccountManager.get(this);
-    Account[] accounts = accMan.getAccountsByType(AccountAuthenticator.ACCOUNT_TYPE);
-
-    if (accounts.length == 0) {
-      // using string value since in API7 this constatn is not defined
-      // in API7 < this constatant is defined in Settings.ADD_ACCOUNT_SETTINGS
-      // and Settings.EXTRA_AUTHORITIES
-      Intent intent = new Intent("android.settings.ADD_ACCOUNT_SETTINGS");
-      intent.putExtra("authorities", new String[] {AccountAuthenticator.AUTH_TOKEN_TYPE});
-      startActivity(intent);
-    } else if (accounts.length > 1) {
-      showDialog(DIALOG_CHOOSE_ACCOUNT);
-    } else {
-      mAccount = accounts[0];
-      populateFileList();
-    }*/
-  }
-
-  @Override
-  public boolean onOptionsItemSelected(MenuItem item) {
-    switch (item.getItemId()) {
-      case R.id.settingsItem :
-        Intent i = new Intent(this, Preferences.class);
-        startActivity(i);
-        break;
-    }
-    return true;
-  }
-
-  @Override
-  protected Dialog onCreateDialog(int id) {
-    switch (id) {
-      case DIALOG_CHOOSE_ACCOUNT:
-        return createChooseAccountDialog();
-      default:
-        throw new IllegalArgumentException("Unknown dialog id: " + id);
-    }
-  }
-  
-  @Override
-  public boolean onCreateOptionsMenu(Menu menu) {
-    MenuInflater inflater = getMenuInflater();
-    inflater.inflate(R.menu.menu, menu);
-    return true;
-  }
-    
-  private Dialog createChooseAccountDialog() {
-    final AccountManager accMan = AccountManager.get(this);
-    CharSequence[] items = new CharSequence[accMan.getAccountsByType(AccountAuthenticator.ACCOUNT_TYPE).length];
-    int i = 0;
-    for (Account a : accMan.getAccountsByType(AccountAuthenticator.ACCOUNT_TYPE)) {
-      items[i++] = a.name;
-    }
-    
-    AlertDialog.Builder builder = new AlertDialog.Builder(this);
-    builder.setTitle(R.string.common_choose_account);
-    builder.setCancelable(true);
-    builder.setItems(items, new DialogInterface.OnClickListener() {
-        public void onClick(DialogInterface dialog, int item) {
-            mAccount = accMan.getAccountsByType(AccountAuthenticator.ACCOUNT_TYPE)[item];
-            dialog.dismiss();
-            populateFileList();
-        }
-    });
-    builder.setOnCancelListener(new OnCancelListener() {
-      public void onCancel(DialogInterface dialog) {
-        FileDisplayActivity.this.finish();
-      }
-    });
-    AlertDialog alert = builder.create();
-    return alert;
-  }
-
-  //@Override
-  //public void onBackPressed() {
-    /*PathLayout pl = (PathLayout) findViewById(R.id.pathLayout1);
-    if (mIsDisplayingFile) {
-      mIsDisplayingFile = false;
-      setContentView(R.layout.main);
-      pl = (PathLayout) findViewById(R.id.pathLayout1);
-      Uri uri;
-      if (mParents.empty()) {
-        uri = ProviderTableMeta.CONTENT_URI;
-      } else {
-        uri = Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_DIR, mParents.peek());
-      }
-      mCursor = managedQuery(uri,
-                             null,
-                             ProviderTableMeta.FILE_ACCOUNT_OWNER+"=?",
-                             new String[]{mAccount.name}, null);
-  
-      if (mCursor.moveToFirst()) {
-        String s = mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta.FILE_PATH));
-        for (String str : s.split("/")) {
-          if (!TextUtils.isEmpty(str))
-            pl.push(DisplayUtils.HtmlDecode(str));
-        }
-      }
-      getListView().setAdapter(new FileListListAdapter(mCursor, this));      
-      getListView().invalidate();
-      return;
-    }
-    if (mParents.size()==0) {
-      super.onBackPressed();
-      return;
-    } else if (mParents.size() == 1) {
-      mParents.pop();
-      mPath.removeLast();
-      pl.pop();
-      mCursor = managedQuery(ProviderTableMeta.CONTENT_URI,
-          null,
-          ProviderTableMeta.FILE_ACCOUNT_OWNER+"=?",
-          new String[]{mAccount.name},
-          null);
-    } else {
-      mParents.pop();
-      mPath.removeLast();
-      pl.pop();
-      mCursor = managedQuery(Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_DIR, mParents.peek()),
-          null,
-          ProviderTableMeta.FILE_ACCOUNT_OWNER+"=?",
-          new String[]{mAccount.name},
-          null);
-    }
-    
-    setListAdapter(new FileListListAdapter(mCursor, this));
-    getListView().invalidate();*/
-  //}
-
-  //@Override
-/*  protected void onListItemClick(ListView l, View v, int position, long id) {
-    super.onListItemClick(l, v, position, id);
-    /*PathLayout pl = (PathLayout) findViewById(R.id.pathLayout1);
-    if (!mCursor.moveToPosition(position)) {
-      throw new IndexOutOfBoundsException("Incorrect item selected");
-    }
-    if (!mIsDisplayingFile) {
-      if (mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta.FILE_CONTENT_TYPE)).equals("DIR")) {
-        String id_ = mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta._ID));
-        String dirname = mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta.FILE_NAME));
-        pl.push(DisplayUtils.HtmlDecode(dirname));
-        mPath.addLast(DisplayUtils.HtmlDecode(dirname));
-        mParents.push(id_);
-        mCursor = managedQuery(Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_DIR, id_),
-                               null,
-                               ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?",
-                               new String[]{mAccount.name}, null);
-        setListAdapter(new FileListListAdapter(mCursor, this));
-      } else {
-        mIsDisplayingFile = true;
-        setContentView(R.layout.file_display);
-        String id_ = mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta._ID));
-        mCursor = managedQuery(Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_FILE, id_),
-                               null,
-                               null,
-                               null,
-                               null);
-        mCursor.moveToFirst();
-        // filename
-        TextView tv = (TextView) findViewById(R.id.textView1);
-        tv.setText(mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta.FILE_NAME)));
-        // filetype
-        tv = (TextView) findViewById(R.id.textView2);
-        tv.setText(DisplayUtils.convertMIMEtoPrettyPrint(mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta.FILE_CONTENT_TYPE))));
-        // size
-        tv = (TextView) findViewById(R.id.textView3);
-        tv.setText(DisplayUtils.bitsToHumanReadable(mCursor.getLong(mCursor.getColumnIndex(ProviderTableMeta.FILE_CONTENT_LENGTH))));
-        // modified
-        tv = (TextView) findViewById(R.id.textView4);
-        tv.setText(mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta.FILE_MODIFIED)));
-        if (!TextUtils.isEmpty(mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta.FILE_STORAGE_PATH))) &&
-            mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta.FILE_CONTENT_TYPE)).matches("image/*")) {
-          ImageView iv = (ImageView) findViewById(R.id.imageView1);
-          Bitmap bmp = BitmapFactory.decodeFile(mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta.FILE_STORAGE_PATH)));
-          Matrix m = new Matrix();
-          float scale;
-          if (bmp.getWidth() > bmp.getHeight()) {
-            scale = (float) (200./bmp.getWidth());
-          } else {
-            scale = (float) (200./bmp.getHeight());
-          }
-          m.postScale(scale, scale);
-          Bitmap newBmp = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), m, true);
-          iv.setImageBitmap(newBmp);
-        }
-        setListAdapter(new FileListActionListAdapter(mCursor, this, mAccount));
-      }    
-      getListView().invalidate();
-    } else {
-        Intent i = (Intent) getListAdapter().getItem(position);
-        if (i.hasExtra("toDownload")) {
-          
-          Intent intent = new Intent(this, FileDownloader.class);
-          intent.putExtra(FileDownloader.EXTRA_FILE_PATH, "/"+((TextView)findViewById(R.id.textView1)).getText().toString());
-          intent.putExtra(FileDownloader.EXTRA_ACCOUNT, mAccount);
-          startService(intent);
-          /*
-          if (i.getBooleanExtra("toDownload", false)) {
-            startActivityForResult(i, 200);
-          } else {
-            startActivity(i);            
-          }*/
-       // }
-
-    //}
-//  }
-  
-  private void populateFileList() {
-    if (mParents.empty()) {
-      mCursor = getContentResolver().query(ProviderTableMeta.CONTENT_URI,
-                                           null,
-                                           ProviderTableMeta.FILE_ACCOUNT_OWNER+"=?",
-                                           new String[]{mAccount.name},
-                                           null);
-    } else {
-      mCursor = getContentResolver().query(Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_DIR, mParents.peek()),
-                                           null,
-                                           ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?",
-                                           new String[]{mAccount.name}, null);
-      if (!mIsDisplayingFile) {
-        //PathLayout pl = (PathLayout) findViewById(R.id.pathLayout1);
-        //for (String s : mPath) {
-        //  pl.push(s);
-       // }
-      }
-    }
-//    setListAdapter(new FileListListAdapter(mCursor, this));
-//    getListView().invalidate();
-  }
-  
-  //@Override
-  /*protected void onActivityResult(int requestCode, int resultCode, Intent data) {
-    super.onActivityResult(requestCode, resultCode, data);
-  }
-  
-  @Override
-  protected void onSaveInstanceState(Bundle outState) {
-    super.onSaveInstanceState(outState);
-    outState.putSerializable("parentsStack", mParents);
-    outState.putSerializable("path", mPath);
-    outState.putBoolean("isDisplayingFile", mIsDisplayingFile);
-  }*/
-
+/* 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
+\r
+package eu.alefzero.owncloud.ui;\r
+\r
+import java.io.File;\r
+import java.io.FileInputStream;\r
+import java.io.FileNotFoundException;\r
+import java.io.IOException;\r
+import java.util.LinkedList;\r
+import java.util.Stack;\r
+\r
+import android.accounts.Account;\r
+import android.accounts.AccountManager;\r
+import android.app.AlertDialog;\r
+import android.app.Dialog;\r
+import android.app.ListActivity;\r
+import android.content.DialogInterface;\r
+import android.content.Intent;\r
+import android.content.DialogInterface.OnCancelListener;\r
+import android.content.res.Configuration;\r
+import android.database.Cursor;\r
+import android.graphics.Bitmap;\r
+import android.graphics.BitmapFactory;\r
+import android.graphics.Matrix;\r
+import android.net.Uri;\r
+import android.os.Bundle;\r
+import android.os.Environment;\r
+import android.support.v4.app.FragmentActivity;\r
+import android.support.v4.app.FragmentTransaction;\r
+import android.text.TextUtils;\r
+import android.util.Log;\r
+import android.view.Menu;\r
+import android.view.MenuInflater;\r
+import android.view.MenuItem;\r
+import android.view.View;\r
+import android.view.Window;\r
+import android.widget.ImageView;\r
+import android.widget.ListView;\r
+import android.widget.TextView;\r
+import eu.alefzero.owncloud.DbHandler;\r
+import eu.alefzero.owncloud.R;\r
+import eu.alefzero.owncloud.R.id;\r
+import eu.alefzero.owncloud.R.layout;\r
+import eu.alefzero.owncloud.R.menu;\r
+import eu.alefzero.owncloud.R.string;\r
+import eu.alefzero.owncloud.authenticator.AccountAuthenticator;\r
+import eu.alefzero.owncloud.db.ProviderMeta.ProviderTableMeta;\r
+import eu.alefzero.owncloud.ui.fragment.FileDetail;\r
+import eu.alefzero.owncloud.ui.fragment.FileList;\r
+import eu.alefzero.owncloud.ui.fragment.ActionBar;\r
+public class FileDisplayActivity extends FragmentActivity {\r
+  private DbHandler mDBHandler;\r
+  private Stack<String> mParents;\r
+  private LinkedList<String> mPath;\r
+  private Account mAccount;\r
+  private Cursor mCursor;\r
+  private boolean mIsDisplayingFile;\r
+\r
+  private static final int DIALOG_CHOOSE_ACCOUNT = 0;\r
+\r
+  @Override\r
+  public void onCreate(Bundle savedInstanceState) {\r
+    super.onCreate(savedInstanceState);\r
+    getWindow().requestFeature(Window.FEATURE_NO_TITLE);\r
+    setContentView(R.layout.files);\r
+    \r
+    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();\r
+    //ft.add(R.id.actionBar, new ActionBar());\r
+    ft.add(R.id.fileList, new FileList());\r
+    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {\r
+      ft.add(R.id.fileDetail, new FileDetail());\r
+    }\r
+    ft.commit();\r
+\r
+    /*getSupportFragmentManager().beginTransaction().add(arg0, arg1);\r
+    FileList fl = new FileList();\r
+    ft.add(R.id.fileList, fl);\r
+    ft.commit();\r
+    /*\r
+\r
+    \r
+    if (savedInstanceState != null) {\r
+      mParents = (Stack<String>)savedInstanceState.getSerializable("parentsStack");\r
+      mIsDisplayingFile = savedInstanceState.getBoolean("isDisplayingFile");\r
+      mPath = (LinkedList<String>)savedInstanceState.getSerializable("path");\r
+    } else {\r
+      mParents = new Stack<String>();\r
+      mPath = new LinkedList<String>();\r
+      mIsDisplayingFile = false;\r
+    }\r
+\r
+    mDBHandler = new DbHandler(getBaseContext());\r
+    requestWindowFeature(Window.FEATURE_NO_TITLE);\r
+    setContentView(R.layout.main);\r
+\r
+    AccountManager accMan = AccountManager.get(this);\r
+    Account[] accounts = accMan.getAccountsByType(AccountAuthenticator.ACCOUNT_TYPE);\r
+\r
+    if (accounts.length == 0) {\r
+      // using string value since in API7 this constatn is not defined\r
+      // in API7 < this constatant is defined in Settings.ADD_ACCOUNT_SETTINGS\r
+      // and Settings.EXTRA_AUTHORITIES\r
+      Intent intent = new Intent("android.settings.ADD_ACCOUNT_SETTINGS");\r
+      intent.putExtra("authorities", new String[] {AccountAuthenticator.AUTH_TOKEN_TYPE});\r
+      startActivity(intent);\r
+    } else if (accounts.length > 1) {\r
+      showDialog(DIALOG_CHOOSE_ACCOUNT);\r
+    } else {\r
+      mAccount = accounts[0];\r
+      populateFileList();\r
+    }*/\r
+  }\r
+\r
+  @Override\r
+  public boolean onOptionsItemSelected(MenuItem item) {\r
+    switch (item.getItemId()) {\r
+      case R.id.settingsItem :\r
+        Intent i = new Intent(this, Preferences.class);\r
+        startActivity(i);\r
+        break;\r
+    }\r
+    return true;\r
+  }\r
+\r
+  @Override\r
+  protected Dialog onCreateDialog(int id) {\r
+    switch (id) {\r
+      case DIALOG_CHOOSE_ACCOUNT:\r
+        return createChooseAccountDialog();\r
+      default:\r
+        throw new IllegalArgumentException("Unknown dialog id: " + id);\r
+    }\r
+  }\r
+  \r
+  @Override\r
+  public boolean onCreateOptionsMenu(Menu menu) {\r
+    MenuInflater inflater = getMenuInflater();\r
+    inflater.inflate(R.menu.menu, menu);\r
+    return true;\r
+  }\r
+    \r
+  private Dialog createChooseAccountDialog() {\r
+    final AccountManager accMan = AccountManager.get(this);\r
+    CharSequence[] items = new CharSequence[accMan.getAccountsByType(AccountAuthenticator.ACCOUNT_TYPE).length];\r
+    int i = 0;\r
+    for (Account a : accMan.getAccountsByType(AccountAuthenticator.ACCOUNT_TYPE)) {\r
+      items[i++] = a.name;\r
+    }\r
+    \r
+    AlertDialog.Builder builder = new AlertDialog.Builder(this);\r
+    builder.setTitle(R.string.common_choose_account);\r
+    builder.setCancelable(true);\r
+    builder.setItems(items, new DialogInterface.OnClickListener() {\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
+      public void onCancel(DialogInterface dialog) {\r
+        FileDisplayActivity.this.finish();\r
+      }\r
+    });\r
+    AlertDialog alert = builder.create();\r
+    return alert;\r
+  }\r
+\r
+  //@Override\r
+  //public void onBackPressed() {\r
+    /*PathLayout pl = (PathLayout) findViewById(R.id.pathLayout1);\r
+    if (mIsDisplayingFile) {\r
+      mIsDisplayingFile = false;\r
+      setContentView(R.layout.main);\r
+      pl = (PathLayout) findViewById(R.id.pathLayout1);\r
+      Uri uri;\r
+      if (mParents.empty()) {\r
+        uri = ProviderTableMeta.CONTENT_URI;\r
+      } else {\r
+        uri = Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_DIR, mParents.peek());\r
+      }\r
+      mCursor = managedQuery(uri,\r
+                             null,\r
+                             ProviderTableMeta.FILE_ACCOUNT_OWNER+"=?",\r
+                             new String[]{mAccount.name}, null);\r
+  \r
+      if (mCursor.moveToFirst()) {\r
+        String s = mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta.FILE_PATH));\r
+        for (String str : s.split("/")) {\r
+          if (!TextUtils.isEmpty(str))\r
+            pl.push(DisplayUtils.HtmlDecode(str));\r
+        }\r
+      }\r
+      getListView().setAdapter(new FileListListAdapter(mCursor, this));      \r
+      getListView().invalidate();\r
+      return;\r
+    }\r
+    if (mParents.size()==0) {\r
+      super.onBackPressed();\r
+      return;\r
+    } else if (mParents.size() == 1) {\r
+      mParents.pop();\r
+      mPath.removeLast();\r
+      pl.pop();\r
+      mCursor = managedQuery(ProviderTableMeta.CONTENT_URI,\r
+          null,\r
+          ProviderTableMeta.FILE_ACCOUNT_OWNER+"=?",\r
+          new String[]{mAccount.name},\r
+          null);\r
+    } else {\r
+      mParents.pop();\r
+      mPath.removeLast();\r
+      pl.pop();\r
+      mCursor = managedQuery(Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_DIR, mParents.peek()),\r
+          null,\r
+          ProviderTableMeta.FILE_ACCOUNT_OWNER+"=?",\r
+          new String[]{mAccount.name},\r
+          null);\r
+    }\r
+    \r
+    setListAdapter(new FileListListAdapter(mCursor, this));\r
+    getListView().invalidate();*/\r
+  //}\r
+\r
+  //@Override\r
+/*  protected void onListItemClick(ListView l, View v, int position, long id) {\r
+    super.onListItemClick(l, v, position, id);\r
+    /*PathLayout pl = (PathLayout) findViewById(R.id.pathLayout1);\r
+    if (!mCursor.moveToPosition(position)) {\r
+      throw new IndexOutOfBoundsException("Incorrect item selected");\r
+    }\r
+    if (!mIsDisplayingFile) {\r
+      if (mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta.FILE_CONTENT_TYPE)).equals("DIR")) {\r
+        String id_ = mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta._ID));\r
+        String dirname = mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta.FILE_NAME));\r
+        pl.push(DisplayUtils.HtmlDecode(dirname));\r
+        mPath.addLast(DisplayUtils.HtmlDecode(dirname));\r
+        mParents.push(id_);\r
+        mCursor = 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, this));\r
+      } else {\r
+        mIsDisplayingFile = true;\r
+        setContentView(R.layout.file_display);\r
+        String id_ = mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta._ID));\r
+        mCursor = managedQuery(Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_FILE, id_),\r
+                               null,\r
+                               null,\r
+                               null,\r
+                               null);\r
+        mCursor.moveToFirst();\r
+        // filename\r
+        TextView tv = (TextView) findViewById(R.id.textView1);\r
+        tv.setText(mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta.FILE_NAME)));\r
+        // filetype\r
+        tv = (TextView) findViewById(R.id.textView2);\r
+        tv.setText(DisplayUtils.convertMIMEtoPrettyPrint(mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta.FILE_CONTENT_TYPE))));\r
+        // size\r
+        tv = (TextView) findViewById(R.id.textView3);\r
+        tv.setText(DisplayUtils.bitsToHumanReadable(mCursor.getLong(mCursor.getColumnIndex(ProviderTableMeta.FILE_CONTENT_LENGTH))));\r
+        // modified\r
+        tv = (TextView) findViewById(R.id.textView4);\r
+        tv.setText(mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta.FILE_MODIFIED)));\r
+        if (!TextUtils.isEmpty(mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta.FILE_STORAGE_PATH))) &&\r
+            mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta.FILE_CONTENT_TYPE)).matches("image/*")) {\r
+          ImageView iv = (ImageView) findViewById(R.id.imageView1);\r
+          Bitmap bmp = BitmapFactory.decodeFile(mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta.FILE_STORAGE_PATH)));\r
+          Matrix m = new Matrix();\r
+          float scale;\r
+          if (bmp.getWidth() > bmp.getHeight()) {\r
+            scale = (float) (200./bmp.getWidth());\r
+          } else {\r
+            scale = (float) (200./bmp.getHeight());\r
+          }\r
+          m.postScale(scale, scale);\r
+          Bitmap newBmp = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), m, true);\r
+          iv.setImageBitmap(newBmp);\r
+        }\r
+        setListAdapter(new FileListActionListAdapter(mCursor, this, mAccount));\r
+      }    \r
+      getListView().invalidate();\r
+    } else {\r
+        Intent i = (Intent) getListAdapter().getItem(position);\r
+        if (i.hasExtra("toDownload")) {\r
+          \r
+          Intent intent = new Intent(this, FileDownloader.class);\r
+          intent.putExtra(FileDownloader.EXTRA_FILE_PATH, "/"+((TextView)findViewById(R.id.textView1)).getText().toString());\r
+          intent.putExtra(FileDownloader.EXTRA_ACCOUNT, mAccount);\r
+          startService(intent);\r
+          /*\r
+          if (i.getBooleanExtra("toDownload", false)) {\r
+            startActivityForResult(i, 200);\r
+          } else {\r
+            startActivity(i);            \r
+          }*/\r
+       // }\r
+\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
+//    setListAdapter(new FileListListAdapter(mCursor, this));\r
+//    getListView().invalidate();\r
+  }\r
+  \r
+  //@Override\r
+  /*protected void onActivityResult(int requestCode, int resultCode, Intent data) {\r
+    super.onActivityResult(requestCode, resultCode, data);\r
+  }\r
+  \r
+  @Override\r
+  protected void onSaveInstanceState(Bundle outState) {\r
+    super.onSaveInstanceState(outState);\r
+    outState.putSerializable("parentsStack", mParents);\r
+    outState.putSerializable("path", mPath);\r
+    outState.putBoolean("isDisplayingFile", mIsDisplayingFile);\r
+  }*/\r
+\r
 }
\ No newline at end of file
 }
\ No newline at end of file
index a937212..afc7a3f 100644 (file)
@@ -41,7 +41,7 @@ public class LandingActivity extends FragmentActivity implements OnClickListener
        @Override\r
        protected void onCreate(Bundle savedInstanceState) {\r
                super.onCreate(savedInstanceState);\r
        @Override\r
        protected void onCreate(Bundle savedInstanceState) {\r
                super.onCreate(savedInstanceState);\r
-               setContentView(R.layout.landing_page);\r
+               setContentView(R.layout.main);\r
                \r
                // Check, if there are ownCloud accounts\r
                if(!accountsAreSetup()){\r
                \r
                // Check, if there are ownCloud accounts\r
                if(!accountsAreSetup()){\r
diff --git a/src/eu/alefzero/owncloud/ui/fragment/FileDetail.java b/src/eu/alefzero/owncloud/ui/fragment/FileDetail.java
new file mode 100644 (file)
index 0000000..de11bc6
--- /dev/null
@@ -0,0 +1,59 @@
+package eu.alefzero.owncloud.ui.fragment;\r
+\r
+import eu.alefzero.owncloud.R;\r
+import eu.alefzero.owncloud.R.id;\r
+import eu.alefzero.owncloud.R.layout;\r
+import android.content.Intent;\r
+import android.os.Bundle;\r
+import android.support.v4.app.Fragment;\r
+import android.util.Log;\r
+import android.view.LayoutInflater;\r
+import android.view.View;\r
+import android.view.ViewGroup;\r
+import android.widget.TextView;\r
+import android.widget.Toast;\r
+\r
+public class FileDetail extends Fragment {\r
+  \r
+  public Intent mIntent;\r
+  \r
+  public void setStuff(Intent intent) {\r
+    setStuff(intent, getView());\r
+  }\r
+  \r
+  private void setStuff(Intent intent, View view) {\r
+    String filename = intent.getStringExtra("FILE_NAME");\r
+    String filepath = intent.getStringExtra("FILE_PATH");\r
+    setFilename(filename, view);\r
+  }\r
+  \r
+  @Override\r
+  public void onCreate(Bundle savedInstanceState) {\r
+    // TODO Auto-generated method stub\r
+    super.onCreate(savedInstanceState);\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 View onCreateView(LayoutInflater inflater, ViewGroup container,\r
+      Bundle savedInstanceState) {\r
+    View v = inflater.inflate(R.layout.file_details, container, false);\r
+    \r
+    if (getActivity().getIntent() != null) setStuff(getActivity().getIntent(), v);\r
+    return v;\r
+  }\r
+\r
+  private void setFilename(String filename, View target_view) {\r
+    TextView tv = (TextView) target_view.findViewById(R.id.textView1);\r
+    if (tv != null) tv.setText(filename);\r
+  }\r
+  \r
+  public void setFilename(String filename) {\r
+    setFilename(filename, getView());\r
+  }\r
+}\r
index b1fbe8e..e3d1f26 100644 (file)
-package eu.alefzero.owncloud.ui.fragment;
-
-import eu.alefzero.owncloud.FileDetail;
-import eu.alefzero.owncloud.R;
-import eu.alefzero.owncloud.R.id;
-import eu.alefzero.owncloud.authenticator.AccountAuthenticator;
-import eu.alefzero.owncloud.db.ProviderMeta.ProviderTableMeta;
-import eu.alefzero.owncloud.ui.FileDetailActivity;
-import eu.alefzero.owncloud.ui.adapter.FileListListAdapter;
-import eu.alefzero.owncloud.ui.fragment.ActionBar;
-import android.accounts.Account;
-import android.accounts.AccountManager;
-import android.app.Activity;
-import android.app.Service;
-import android.content.Intent;
-import android.database.Cursor;
-import android.net.Uri;
-import android.os.Bundle;
-import android.support.v4.app.FragmentTransaction;
-import android.support.v4.app.ListFragment;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ArrayAdapter;
-import android.widget.ListView;
-import android.widget.TextView;
-import android.widget.Toast;
-
-public class FileList extends ListFragment {
-  private Cursor mCursor;
-  private Account mAccount;
-  private AccountManager mAccountManager;
-  private View mheaderView;
-
-  
-  @Override
-  public void onCreate(Bundle savedInstanceState) {
-    // TODO Auto-generated method stub
-    super.onCreate(savedInstanceState);
-    
-    mAccountManager = (AccountManager)getActivity().getSystemService(Service.ACCOUNT_SERVICE);
-    mAccount = mAccountManager.getAccountsByType(AccountAuthenticator.ACCOUNT_TYPE)[0];
-    populateFileList();
-  }
-  
-  @Override
-  public void onActivityCreated(Bundle savedInstanceState) {
-    // TODO Auto-generated method stub
-    super.onActivityCreated(savedInstanceState);
-  }
-  
-  @Override
-  public void onListItemClick(ListView l, View v, int position, long id) {
-    FileDetail fd = (FileDetail) getFragmentManager().findFragmentById(R.id.fileDetail);
-    ActionBar ab = (ActionBar) getFragmentManager().findFragmentById(R.id.actionBar);
-    
-    if (!mCursor.moveToPosition(position)) {
-      throw new IndexOutOfBoundsException("Incorrect item selected");
-    }
-    if (mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta.FILE_CONTENT_TYPE)).equals("DIR")) {
-        String id_ = mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta._ID));
-        String dirname = mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta.FILE_NAME));
-        //ab..push(DisplayUtils.HtmlDecode(dirname));
-        //mPath.addLast(DisplayUtils.HtmlDecode(dirname));
-        //mParents.push(id_);
-        mCursor = getActivity().managedQuery(Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_DIR, id_),
-                               null,
-                               ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?",
-                               new String[]{mAccount.name}, null);
-        setListAdapter(new FileListListAdapter(mCursor, getActivity()));
-        setListShown(false);
-        setListShown(true);
-        super.onListItemClick(l, v, position, id);
-        return;
-    }
-    Intent i = new Intent(getActivity(), FileDetailActivity.class);
-    i.putExtra("FILE_PATH", ab.getCurrentPath());
-    i.putExtra("FILE_NAME", ((TextView)v.findViewById(R.id.Filename)).getText());
-    if (fd != null) {
-      fd.setStuff(i);
-      //fd.use(((TextView)v.findViewById(R.id.Filename)).getText());
-    } else {
-      i.putExtra("FILE_PATH", ab.getCurrentPath());
-      i.putExtra("FILE_NAME", ((TextView)v.findViewById(R.id.Filename)).getText());
-      startActivity(i);
-    }
-    super.onListItemClick(l, v, position, id);
-
-  }
-  
-  @Override
-  public void onDestroyView() {
-    setListAdapter(null);
-    super.onDestroyView();
-  }
-  
-  private void populateFileList() {
-    mCursor = getActivity().getContentResolver().query(ProviderTableMeta.CONTENT_URI,
-        null,
-        ProviderTableMeta.FILE_ACCOUNT_OWNER+"=?",
-        new String[]{mAccount.name},
-        null);
-    
-    setListAdapter(new FileListListAdapter(mCursor, getActivity()));
-  }
-}
+package eu.alefzero.owncloud.ui.fragment;\r
+\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.FileDetailActivity;\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.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.ListFragment;\r
+import android.view.LayoutInflater;\r
+import android.view.View;\r
+import android.view.ViewGroup;\r
+import android.widget.ArrayAdapter;\r
+import android.widget.ListView;\r
+import android.widget.TextView;\r
+import android.widget.Toast;\r
+\r
+public class FileList extends ListFragment {\r
+  private Cursor mCursor;\r
+  private Account mAccount;\r
+  private AccountManager mAccountManager;\r
+  private View mheaderView;\r
+\r
+  \r
+  @Override\r
+  public void onCreate(Bundle savedInstanceState) {\r
+    // TODO Auto-generated method stub\r
+    super.onCreate(savedInstanceState);\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 onListItemClick(ListView l, View v, int position, long id) {\r
+    FileDetail fd = (FileDetail) getFragmentManager().findFragmentById(R.id.fileDetail);\r
+    ActionBar ab = (ActionBar) getFragmentManager().findFragmentById(R.id.actionBar);\r
+    \r
+    if (!mCursor.moveToPosition(position)) {\r
+      throw new IndexOutOfBoundsException("Incorrect item selected");\r
+    }\r
+    if (mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta.FILE_CONTENT_TYPE)).equals("DIR")) {\r
+        String id_ = mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta._ID));\r
+        String dirname = mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta.FILE_NAME));\r
+        //ab..push(DisplayUtils.HtmlDecode(dirname));\r
+        //mPath.addLast(DisplayUtils.HtmlDecode(dirname));\r
+        //mParents.push(id_);\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
+        setListShown(false);\r
+        setListShown(true);\r
+        super.onListItemClick(l, v, position, id);\r
+        return;\r
+    }\r
+    Intent i = new Intent(getActivity(), FileDetailActivity.class);\r
+    i.putExtra("FILE_PATH", ab.getCurrentPath());\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_PATH", ab.getCurrentPath());\r
+      i.putExtra("FILE_NAME", ((TextView)v.findViewById(R.id.Filename)).getText());\r
+      startActivity(i);\r
+    }\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
+        null,\r
+        ProviderTableMeta.FILE_ACCOUNT_OWNER+"=?",\r
+        new String[]{mAccount.name},\r
+        null);\r
+    \r
+    setListAdapter(new FileListListAdapter(mCursor, getActivity()));\r
+  }\r
+}\r