android:name="android.permission.READ_SYNC_SETTINGS" />
<uses-permission
android:name="android.permission.WRITE_SYNC_SETTINGS" />
- <uses-sdk android:minSdkVersion="7"></uses-sdk>
+ <uses-sdk android:minSdkVersion="7" android:targetSdkVersion="10" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<application android:icon="@drawable/icon" android:label="@string/app_name">
- <activity android:name=".OwnCloudMainScreen"
+ <activity android:name=".MainScreen"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<activity android:name=".authenticator.AuthenticatorActivity"></activity>
<service android:name="FileDownloader">
</service>
+ <activity android:name="FileDetailActivity"></activity>
</application>
</manifest>
\ No newline at end of file
--- /dev/null
+<?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.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.FileList" >
+
+ <!-- Preview: layout=@layout/list_layout -->
+ </fragment>
+ <!-- </LinearLayout> -->
+
+</LinearLayout>
\ No newline at end of file
--- /dev/null
+<?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="wrap_content"
+ android:background="#F7F7F7"
+ android:orientation="vertical" >
+
+ <LinearLayout
+ android:id="@+id/linearLayout1"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:orientation="vertical" >
+
+ <LinearLayout
+ android:id="@+id/linearLayout7"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:background="@drawable/main_header_bg"
+ android:gravity="top"
+ android:orientation="horizontal" >
+
+ <ImageView
+ android:id="@+id/main_header_small"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical|left"
+ android:src="@drawable/icon" >
+ </ImageView>
+
+ <eu.alefzero.owncloud.PathLayout
+ android:id="@+id/pathLayout1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical" >
+ </eu.alefzero.owncloud.PathLayout>
+ </LinearLayout>
+ </LinearLayout>
+</LinearLayout>
\ No newline at end of file
--- /dev/null
+<?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" />
+
+</LinearLayout>
\ No newline at end of file
--- /dev/null
+<?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" android:background="#F7F7F7">
+ <LinearLayout android:layout_width="fill_parent"
+ android:id="@+id/linearLayout1" android:layout_height="wrap_content">
+ <LinearLayout android:layout_width="wrap_content"
+ android:id="@+id/linearLayout2" android:layout_height="fill_parent">
+ <ImageView android:layout_width="wrap_content"
+ android:layout_height="wrap_content" android:src="@drawable/icon"
+ android:id="@+id/imageView1"></ImageView>
+ </LinearLayout>
+ <LinearLayout android:layout_width="wrap_content"
+ android:id="@+id/linearLayout3" android:layout_height="fill_parent"
+ android:orientation="vertical">
+ <TextView android:id="@+id/textView1" android:layout_height="wrap_content"
+ android:layout_width="wrap_content" android:text="TextView"></TextView>
+ <TextView android:id="@+id/textView2" android:layout_height="wrap_content"
+ android:layout_width="wrap_content" android:text="TextView"></TextView>
+ <TextView android:id="@+id/textView3" android:layout_height="wrap_content"
+ android:layout_width="wrap_content" android:text="TextView"></TextView>
+ <TextView android:id="@+id/textView4" android:layout_height="wrap_content"
+ android:layout_width="wrap_content" android:text="TextView"></TextView>
+ <TextView android:id="@+id/textView5" android:layout_height="wrap_content"
+ android:layout_width="wrap_content" android:text="TextView"></TextView>
+ </LinearLayout>
+ </LinearLayout>
+ <LinearLayout android:layout_width="fill_parent"
+ android:id="@+id/linearLayout4" android:layout_height="fill_parent">
+ <ListView android:layout_width="fill_parent" android:id="@android:id/list"
+ android:layout_height="fill_parent" android:divider="@drawable/uploader_list_separator"
+ android:dividerHeight="1dip"></ListView>
+ </LinearLayout>
+</LinearLayout>
+++ /dev/null
-<?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" android:background="#F7F7F7">
- <LinearLayout android:id="@+id/linearLayout7" android:paddingBottom="2pt" android:gravity="center_vertical|top" android:layout_gravity="top" android:layout_height="wrap_content" android:paddingTop="2pt" android:orientation="vertical" android:layout_width="fill_parent" android:background="#1D2D44">
- <ImageView android:id="@+id/main_header_small" android:src="@drawable/owncloud_logo_small_white" android:layout_gravity="center|center_vertical|center_horizontal" android:layout_height="wrap_content" android:layout_width="wrap_content" android:focusable="true"></ImageView>
- </LinearLayout>
- <LinearLayout android:layout_width="fill_parent"
- android:id="@+id/linearLayout1" android:layout_height="wrap_content">
- <LinearLayout android:layout_width="wrap_content"
- android:id="@+id/linearLayout2" android:layout_height="fill_parent">
- <ImageView android:layout_width="wrap_content"
- android:layout_height="wrap_content" android:src="@drawable/icon"
- android:id="@+id/imageView1"></ImageView>
- </LinearLayout>
- <LinearLayout android:layout_width="wrap_content"
- android:id="@+id/linearLayout3" android:layout_height="fill_parent"
- android:orientation="vertical">
- <TextView android:id="@+id/textView1" android:layout_height="wrap_content"
- android:layout_width="wrap_content" android:text="TextView"></TextView>
- <TextView android:id="@+id/textView2" android:layout_height="wrap_content"
- android:layout_width="wrap_content" android:text="TextView"></TextView>
- <TextView android:id="@+id/textView3" android:layout_height="wrap_content"
- android:layout_width="wrap_content" android:text="TextView"></TextView>
- <TextView android:id="@+id/textView4" android:layout_height="wrap_content"
- android:layout_width="wrap_content" android:text="TextView"></TextView>
- <TextView android:id="@+id/textView5" android:layout_height="wrap_content"
- android:layout_width="wrap_content" android:text="TextView"></TextView>
- </LinearLayout>
- </LinearLayout>
- <LinearLayout android:layout_width="fill_parent"
- android:id="@+id/linearLayout4" android:layout_height="fill_parent">
- <ListView android:layout_width="fill_parent" android:id="@android:id/list"
- android:layout_height="fill_parent" android:divider="@drawable/uploader_list_separator"
- android:dividerHeight="1dip"></ListView>
- </LinearLayout>
-</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent" android:background="#F7F7F7"
- android:orientation="vertical" android:layout_height="fill_parent">
- <LinearLayout android:layout_width="fill_parent"
- android:id="@+id/linearLayout7" android:background="@drawable/main_header_bg" android:gravity="top"
- android:layout_gravity="center_vertical" android:layout_height="wrap_content" android:orientation="horizontal">
- <ImageView android:layout_height="wrap_content"
- android:src="@drawable/icon"
- android:layout_width="wrap_content" android:layout_gravity="center_vertical|left"
- android:id="@+id/main_header_small"></ImageView>
- <eu.alefzero.owncloud.PathLayout android:id="@+id/pathLayout1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical"></eu.alefzero.owncloud.PathLayout>
- </LinearLayout>
- <FrameLayout android:layout_height="fill_parent"
- android:layout_width="fill_parent" android:id="@+id/frameLayout1">
- <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" android:fadingEdge="none"></ListView>
- </FrameLayout>
-</LinearLayout>
+ 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="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.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.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>
+
+</LinearLayout>
\ No newline at end of file
--- /dev/null
+package eu.alefzero.owncloud;
+
+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 {
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ // TODO Auto-generated method stub
+ super.onCreate(savedInstanceState);
+ Log.e("TEST", "TEST");
+ }
+
+ @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);
+ return v;
+ }
+
+ public void use(CharSequence text) {
+ Toast.makeText(getActivity(), text, Toast.LENGTH_LONG).show();
+ // TODO Auto-generated method stub
+
+ }
+}
--- /dev/null
+package eu.alefzero.owncloud;
+
+import android.app.Activity;
+import android.content.res.Configuration;
+import android.os.Bundle;
+import android.support.v4.app.FragmentActivity;
+import android.support.v4.app.FragmentTransaction;
+import android.view.Window;
+
+public class FileDetailActivity extends FragmentActivity {
+@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);
+
+ FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
+ ft.add(R.id.fileDetail, new FileDetail());
+ ft.commit();
+
+}
+}
package eu.alefzero.owncloud;
import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.net.UnknownHostException;
-import java.util.Date;
-
-import org.apache.http.HttpHost;
-import org.apache.http.HttpResponse;
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.UsernamePasswordCredentials;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.auth.BasicScheme;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.http.protocol.BasicHttpContext;
-
-import eu.alefzero.owncloud.authenticator.AccountAuthenticator;
-import eu.alefzero.webdav.HttpPropFind;
import android.accounts.Account;
import android.accounts.AccountManager;
-import android.accounts.AuthenticatorException;
-import android.accounts.OperationCanceledException;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.os.Environment;
import android.os.IBinder;
import android.util.Log;
-import android.widget.FrameLayout;
+import eu.alefzero.owncloud.authenticator.AccountAuthenticator;
public class FileDownloader extends Service {
static final String EXTRA_ACCOUNT = "ACCOUNT";
wdc.allowUnsignedCertificates();
Notification n = new Notification(R.drawable.icon, "Downloading file", System.currentTimeMillis());
- PendingIntent pi = PendingIntent.getActivity(this, 1, new Intent(this, OwnCloudMainScreen.class), 0);
+ PendingIntent pi = PendingIntent.getActivity(this, 1, new Intent(this, MainScreen.class), 0);
n.setLatestEventInfo(this, "A", "B", pi);
nm.notify(1, n);
return START_NOT_STICKY;
}
-
+
+
}
--- /dev/null
+package eu.alefzero.owncloud;
+
+import eu.alefzero.owncloud.authenticator.AccountAuthenticator;
+import eu.alefzero.owncloud.db.ProviderMeta.ProviderTableMeta;
+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.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;
+
+ @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) {
+ // TODO Auto-generated method stub
+ FileDetail fd = (FileDetail) getFragmentManager().findFragmentById(R.id.fileDetail);
+ if (fd != null) {
+ fd.use(((TextView)v.findViewById(R.id.Filename)).getText());
+ } else {
+ Intent i = new Intent(getActivity(), FileDetailActivity.class);
+ startActivity(i);
+ }
+ super.onListItemClick(l, v, position, id);
+ }
+
+ 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()));
+ }
+}
--- /dev/null
+/* 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;
+
+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.authenticator.AccountAuthenticator;
+import eu.alefzero.owncloud.db.ProviderMeta.ProviderTableMeta;
+
+public class MainScreen 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.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) {
+ MainScreen.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);
+ }*/
+
+}
\ No newline at end of file
+++ /dev/null
-/* 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;
-
-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.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.authenticator.AccountAuthenticator;
-import eu.alefzero.owncloud.db.ProviderMeta.ProviderTableMeta;
-
-public class OwnCloudMainScreen extends ListActivity {
- 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;
-
- @SuppressWarnings("unchecked")
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- 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;
- }
-
- @Override
- protected void onDestroy() {
- mDBHandler.close();
- super.onDestroy();
- }
-
- 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) {
- OwnCloudMainScreen.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);
- }
-
-}
\ No newline at end of file
--- /dev/null
+package eu.alefzero.owncloud.ui;
+
+import eu.alefzero.owncloud.R;
+import android.app.Activity;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+public class ActionBar extends Fragment {
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ }
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View v = inflater.inflate(R.layout.action_bar, container, false);
+ return v;
+ }
+
+ @Override
+ public void onAttach(Activity activity) {
+ super.onAttach(activity);
+ }
+}