This commit is contained in:
Bartek Przybylski 2012-01-16 23:56:55 +01:00 коммит произвёл Lennart Rosam
Родитель 32ce46d9d8
Коммит 329080075e
6 изменённых файлов: 112 добавлений и 17 удалений

Просмотреть файл

@ -1,5 +1,6 @@
package eu.alefzero.owncloud;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
@ -10,11 +11,23 @@ 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);
Log.e("TEST", "TEST");
}
@Override
@ -27,12 +40,17 @@ public class FileDetail extends Fragment {
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;
}
public void use(CharSequence text) {
Toast.makeText(getActivity(), text, Toast.LENGTH_LONG).show();
// TODO Auto-generated method stub
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());
}
}

Просмотреть файл

@ -1,5 +1,6 @@
package eu.alefzero.owncloud;
import java.util.LinkedList;
import java.util.Stack;
import android.content.Context;
@ -12,7 +13,7 @@ import android.widget.TextView;
public class PathLayout extends LinearLayout {
private Stack<String> paths;
private LinkedList<String> paths;
ScrollView internalScroll;
LinearLayout view;
@ -27,7 +28,7 @@ public class PathLayout extends LinearLayout {
}
public String pop() {
if (paths.empty()) {
if (paths.size() == 0) {
return null;
}
int start = paths.size()*2-2;
@ -37,12 +38,16 @@ public class PathLayout extends LinearLayout {
count--;
}
view.removeViews(start, count);
return paths.pop();
return paths.removeLast();
}
public void addPath(String path) {
for (String s : path.split("/")) if (s.length() != 0) push(s);
}
public void push(String path) {
// its weird that we cannot declare static imgView as path separator
if (!paths.empty()) {
if (paths.size() != 0) {
ImageView iv = new ImageView(getContext());
iv.setImageDrawable(getResources().getDrawable(R.drawable.breadcrumb));
iv.setPadding(2, 0, 2, 0);
@ -54,15 +59,23 @@ public class PathLayout extends LinearLayout {
view.addView(tv);
HorizontalScrollView hsv = (HorizontalScrollView) internalScroll.getChildAt(0);
hsv.smoothScrollTo(hsv.getMaxScrollAmount()*2, 0);
paths.push(path);
paths.addLast(path);
}
public String peek() {
return paths.peek();
}
public String getFullPath() {
String ret = new String();
for (int i = 0; i < paths.size(); i++) {
ret += "/" + paths.get(i);
}
return ret;
}
private void initialize() {
paths = new Stack<String>();
paths = new LinkedList<String>();
internalScroll = new ScrollView(getContext());
internalScroll.setFillViewport(true);
HorizontalScrollView hsv = new HorizontalScrollView(getContext());

Просмотреть файл

@ -1,17 +1,26 @@
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
@ -19,9 +28,11 @@ protected void onCreate(Bundle 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, new FileDetail());
ft.add(R.id.fileDetail, mFileDetail);
ft.commit();
}
}

Просмотреть файл

@ -63,7 +63,7 @@ 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;
@ -81,6 +81,7 @@ public class FileDisplayActivity extends FragmentActivity {
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());

Просмотреть файл

@ -1,5 +1,6 @@
package eu.alefzero.owncloud.ui.fragment;
import eu.alefzero.owncloud.PathLayout;
import eu.alefzero.owncloud.R;
import android.app.Activity;
import android.os.Bundle;
@ -26,4 +27,19 @@ public class ActionBar extends Fragment {
public void onAttach(Activity activity) {
super.onAttach(activity);
}
public void setPath(String path) {
if (getPathLayout() != null)
getPathLayout().addPath(path);
}
public String getCurrentPath() {
if (getPathLayout() != null)
return getPathLayout().getFullPath();
return "";
}
private PathLayout getPathLayout() {
return (PathLayout) getActivity().findViewById(R.id.pathLayout1);
}
}

Просмотреть файл

@ -7,12 +7,14 @@ 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;
@ -28,6 +30,8 @@ public class FileList extends ListFragment {
private Cursor mCursor;
private Account mAccount;
private AccountManager mAccountManager;
private View mheaderView;
@Override
public void onCreate(Bundle savedInstanceState) {
@ -44,18 +48,50 @@ public class FileList extends ListFragment {
// 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);
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.use(((TextView)v.findViewById(R.id.Filename)).getText());
fd.setStuff(i);
//fd.use(((TextView)v.findViewById(R.id.Filename)).getText());
} else {
Intent i = new Intent(getActivity(), FileDetailActivity.class);
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() {