--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+ ownCloud Android client application\r
+\r
+ Copyright (C) 2012 Bartek Przybylski\r
+ Copyright (C) 2012-2013 ownCloud Inc.\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 version 2,\r
+ as published by the Free Software Foundation.\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
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
+ android:id="@+id/ListItemLayout"\r
+ android:layout_width="fill_parent"\r
+ android:layout_height="160dp"\r
+ android:background="@drawable/list_selector"\r
+ android:orientation="horizontal" >\r
+\r
+ <ImageView\r
+ android:id="@+id/imageView1"\r
+ android:layout_width="150dp"\r
+ android:layout_height="150dp"\r
+ android:layout_marginBottom="5dp"\r
+ android:layout_marginLeft="9dp"\r
+ android:layout_marginTop="5dp"\r
+ android:src="@drawable/ic_menu_archive" />\r
+\r
+ <ImageView\r
+ android:id="@+id/imageView2"\r
+ android:layout_width="40dp"\r
+ android:layout_height="22dp"\r
+ android:layout_marginLeft="22dp"\r
+ android:src="@drawable/local_file_indicator" />\r
+\r
+ <FrameLayout\r
+ android:id="@+id/imageItemFrame"\r
+ android:layout_width="56dp"\r
+ android:layout_height="56dp"\r
+ android:focusable="false"\r
+ android:focusableInTouchMode="false" >\r
+\r
+ <ImageView\r
+ android:id="@+id/sharedIcon"\r
+ android:layout_width="wrap_content"\r
+ android:layout_height="wrap_content"\r
+ android:layout_marginBottom="4dp"\r
+ android:layout_marginLeft="4dp"\r
+ android:layout_marginRight="4dp"\r
+ android:src="@drawable/sharedlink" />\r
+\r
+ <ImageView\r
+ android:id="@+id/sharedWithMeIcon"\r
+ android:layout_width="wrap_content"\r
+ android:layout_height="wrap_content"\r
+ android:layout_marginLeft="4dp"\r
+ android:layout_marginRight="4dp"\r
+ android:layout_marginTop="4dp"\r
+ android:src="@drawable/shared_with_me" />\r
+\r
+ <ImageView\r
+ android:id="@+id/custom_checkbox"\r
+ android:layout_width="wrap_content"\r
+ android:layout_height="wrap_content"\r
+ android:layout_marginLeft="4dp"\r
+ android:layout_marginRight="4dp"\r
+ android:src="@android:drawable/checkbox_off_background" />\r
+\r
+ <TextView\r
+ android:id="@+id/Filename"\r
+ android:layout_width="wrap_content"\r
+ android:layout_height="wrap_content"\r
+ android:layout_marginLeft="4dp"\r
+ android:layout_marginRight="4dp"\r
+ android:ellipsize="middle"\r
+ android:singleLine="true"\r
+ android:text="TextView"\r
+ android:textColor="#303030"\r
+ android:textSize="16dip" />\r
+\r
+ <ImageView\r
+ android:id="@+id/imageView3"\r
+ android:layout_width="wrap_content"\r
+ android:layout_height="wrap_content"\r
+ android:layout_gravity="bottom|right"\r
+ android:layout_marginBottom="10dp"\r
+ android:layout_marginRight="2dp"\r
+ android:src="@drawable/ic_favorite" />\r
+\r
+ <TextView\r
+ android:id="@+id/last_mod"\r
+ android:layout_width="wrap_content"\r
+ android:layout_height="wrap_content"\r
+ android:layout_weight=".5"\r
+ android:text="TextView"\r
+ android:textColor="@color/list_item_lastmod_and_filesize_text"\r
+ android:textSize="12dip" />\r
+\r
+ <TextView\r
+ android:id="@+id/file_size"\r
+ android:layout_width="wrap_content"\r
+ android:layout_height="wrap_content"\r
+ android:layout_weight=".5"\r
+ android:gravity="right"\r
+ android:text="TextView"\r
+ android:textColor="@color/list_item_lastmod_and_filesize_text"\r
+ android:textSize="12dip" />\r
+ </FrameLayout>\r
+\r
+</LinearLayout>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+ ownCloud Android client application\r
+\r
+ Copyright (C) 2012 Bartek Przybylski\r
+ Copyright (C) 2012-2013 ownCloud Inc.\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 version 2,\r
+ as published by the Free Software Foundation.\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
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
+ android:id="@+id/ListItemLayout"\r
+ android:layout_width="fill_parent"\r
+ android:layout_height="160dp"\r
+ android:background="@drawable/list_selector"\r
+ android:orientation="vertical" >\r
+\r
+ <ImageView\r
+ android:id="@+id/imageView1"\r
+ android:layout_width="90dp"\r
+ android:layout_height="93dp"\r
+ android:layout_marginBottom="5dp"\r
+ android:layout_marginLeft="9dp"\r
+ android:layout_marginTop="5dp"\r
+ android:src="@drawable/ic_menu_archive" />\r
+\r
+ <TextView\r
+ android:id="@+id/Filename"\r
+ android:layout_width="95dp"\r
+ android:layout_height="wrap_content"\r
+ android:layout_marginLeft="4dp"\r
+ android:layout_marginRight="4dp"\r
+ android:ellipsize="middle"\r
+ android:singleLine="true"\r
+ android:text="TextView"\r
+ android:textColor="#303030"\r
+ android:textSize="16dip" />\r
+\r
+ <ImageView\r
+ android:id="@+id/imageView2"\r
+ android:layout_width="40dp"\r
+ android:layout_height="22dp"\r
+ android:layout_marginLeft="22dp"\r
+ android:src="@drawable/local_file_indicator" />\r
+\r
+ <TextView\r
+ android:id="@+id/file_size"\r
+ android:layout_width="wrap_content"\r
+ android:layout_height="wrap_content"\r
+ android:layout_weight=".5"\r
+ android:gravity="right"\r
+ android:text="TextView"\r
+ android:textColor="@color/list_item_lastmod_and_filesize_text"\r
+ android:textSize="12dip" />\r
+\r
+ <FrameLayout\r
+ android:id="@+id/imageItemFrame"\r
+ android:layout_width="56dp"\r
+ android:layout_height="56dp"\r
+ android:focusable="false"\r
+ android:focusableInTouchMode="false" >\r
+\r
+ <ImageView\r
+ android:id="@+id/sharedIcon"\r
+ android:layout_width="wrap_content"\r
+ android:layout_height="wrap_content"\r
+ android:layout_marginBottom="4dp"\r
+ android:layout_marginLeft="4dp"\r
+ android:layout_marginRight="4dp"\r
+ android:src="@drawable/sharedlink" />\r
+\r
+ <ImageView\r
+ android:id="@+id/sharedWithMeIcon"\r
+ android:layout_width="wrap_content"\r
+ android:layout_height="wrap_content"\r
+ android:layout_marginLeft="4dp"\r
+ android:layout_marginRight="4dp"\r
+ android:layout_marginTop="4dp"\r
+ android:src="@drawable/shared_with_me" />\r
+\r
+ <ImageView\r
+ android:id="@+id/custom_checkbox"\r
+ android:layout_width="wrap_content"\r
+ android:layout_height="wrap_content"\r
+ android:layout_marginLeft="4dp"\r
+ android:layout_marginRight="4dp"\r
+ android:src="@android:drawable/checkbox_off_background" />\r
+\r
+ <ImageView\r
+ android:id="@+id/imageView3"\r
+ android:layout_width="wrap_content"\r
+ android:layout_height="wrap_content"\r
+ android:layout_gravity="bottom|right"\r
+ android:layout_marginBottom="10dp"\r
+ android:layout_marginRight="2dp"\r
+ android:src="@drawable/ic_favorite" />\r
+\r
+ <TextView\r
+ android:id="@+id/last_mod"\r
+ android:layout_width="wrap_content"\r
+ android:layout_height="wrap_content"\r
+ android:layout_weight=".5"\r
+ android:text="TextView"\r
+ android:textColor="@color/list_item_lastmod_and_filesize_text"\r
+ android:textSize="12dip" />\r
+ </FrameLayout>\r
+\r
+</LinearLayout>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
- ownCloud Android client application\r
-\r
- Copyright (C) 2012 Bartek Przybylski\r
- Copyright (C) 2012-2013 ownCloud Inc.\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 version 2,\r
- as published by the Free Software Foundation.\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
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
- android:id="@+id/ListItemLayout"\r
- android:layout_width="fill_parent"\r
- android:layout_height="160dp"\r
- android:background="@drawable/list_selector"\r
- android:orientation="horizontal" >\r
-\r
- <ImageView\r
- android:id="@+id/imageView1"\r
- android:layout_width="150dp"\r
- android:layout_height="150dp"\r
- android:layout_marginBottom="5dp"\r
- android:layout_marginLeft="9dp"\r
- android:layout_marginTop="5dp"\r
- android:src="@drawable/ic_menu_archive" />\r
-\r
- <FrameLayout\r
- android:id="@+id/imageItemFrame"\r
- android:layout_width="56dp"\r
- android:layout_height="56dp"\r
- android:focusable="false"\r
- android:focusableInTouchMode="false" >\r
-\r
- <ImageView\r
- android:id="@+id/sharedIcon"\r
- android:layout_width="wrap_content"\r
- android:layout_height="wrap_content"\r
- android:layout_marginBottom="4dp"\r
- android:layout_marginLeft="4dp"\r
- android:layout_marginRight="4dp"\r
- android:src="@drawable/sharedlink" />\r
-\r
- <ImageView\r
- android:id="@+id/sharedWithMeIcon"\r
- android:layout_width="wrap_content"\r
- android:layout_height="wrap_content"\r
- android:layout_marginLeft="4dp"\r
- android:layout_marginRight="4dp"\r
- android:layout_marginTop="4dp"\r
- android:src="@drawable/shared_with_me" />\r
-\r
- <ImageView\r
- android:id="@+id/custom_checkbox"\r
- android:layout_width="wrap_content"\r
- android:layout_height="wrap_content"\r
- android:layout_marginLeft="4dp"\r
- android:layout_marginRight="4dp"\r
- android:src="@android:drawable/checkbox_off_background" />\r
-\r
- <ImageView\r
- android:id="@+id/imageView2"\r
- android:layout_width="32dp"\r
- android:layout_height="32dp"\r
- android:layout_gravity="center_vertical"\r
- android:layout_marginLeft="22dp"\r
- android:src="@drawable/local_file_indicator" />\r
-\r
- <TextView\r
- android:id="@+id/Filename"\r
- android:layout_width="wrap_content"\r
- android:layout_height="wrap_content"\r
- android:layout_marginLeft="4dp"\r
- android:layout_marginRight="4dp"\r
- android:ellipsize="middle"\r
- android:singleLine="true"\r
- android:text="TextView"\r
- android:textColor="#303030"\r
- android:textSize="16dip" />\r
-\r
- <ImageView\r
- android:id="@+id/imageView3"\r
- android:layout_width="wrap_content"\r
- android:layout_height="wrap_content"\r
- android:layout_gravity="bottom|right"\r
- android:layout_marginBottom="10dp"\r
- android:layout_marginRight="2dp"\r
- android:src="@drawable/ic_favorite" />\r
-\r
- <TextView\r
- android:id="@+id/last_mod"\r
- android:layout_width="wrap_content"\r
- android:layout_height="wrap_content"\r
- android:layout_weight=".5"\r
- android:text="TextView"\r
- android:textColor="@color/list_item_lastmod_and_filesize_text"\r
- android:textSize="12dip" />\r
-\r
- <TextView\r
- android:id="@+id/file_size"\r
- android:layout_width="wrap_content"\r
- android:layout_height="wrap_content"\r
- android:layout_weight=".5"\r
- android:gravity="right"\r
- android:text="TextView"\r
- android:textColor="@color/list_item_lastmod_and_filesize_text"\r
- android:textSize="12dip" />\r
- </FrameLayout>\r
-\r
-</LinearLayout>
\ No newline at end of file
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="0dp"
+ android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<com.owncloud.android.ui.ExtendedListView
android:id="@+id/list_root"
android:layout_width="match_parent"
- android:layout_height="match_parent" />
+ android:layout_height="match_parent"
+ android:columnWidth="160dp"
+ android:gravity="center"
+ android:horizontalSpacing="10dp"
+ android:numColumns="auto_fit"
+ android:stretchMode="columnWidth"
+ android:verticalSpacing="10dp"
+ android:visibility="visible" />
</android.support.v4.widget.SwipeRefreshLayout>
<android.support.v4.widget.SwipeRefreshLayout
android:layout_height="match_parent"
android:visibility="gone" >
- <GridView
- android:id="@+id/grid_list_view"
- android:layout_width="fill_parent"
+ <TextView
+ android:id="@+id/empty_list_view"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:numColumns="1"
+ android:layout_gravity="center"
+ android:gravity="center_vertical|center_horizontal"
+ android:text="@string/empty"
android:visibility="visible" />
-
</android.support.v4.widget.SwipeRefreshLayout>
</FrameLayout>
\ No newline at end of file
import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
+import android.widget.GridView;
import android.widget.ListView;
/**
*
* @author David A. Velasco
*/
-public class ExtendedListView extends ListView {
+public class ExtendedListView extends GridView {
private int mPositionToSetAndCenter;
protected void onDraw (Canvas canvas) {
super.onDraw(canvas);
if (mPositionToSetAndCenter > 0) {
- this.setSelectionFromTop(mPositionToSetAndCenter, getHeight() / 2);
+ this.setSelection(mPositionToSetAndCenter);
+ //this.setSelectionFromTop(mPositionToSetAndCenter, getHeight() / 2);
mPositionToSetAndCenter = 0;
}
}
}\r
\r
View view = convertView;\r
+ OCFile file = null;\r
LayoutInflater inflator = (LayoutInflater) mContext\r
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);\r
+ \r
+ if (mFiles != null && mFiles.size() > position) {\r
+ file = mFiles.get(position);\r
+ }\r
+ \r
if (fileView){\r
view = inflator.inflate(R.layout.list_item, null);\r
} else {\r
- view = inflator.inflate(R.layout.image_item, null);\r
+ if (file.isImage()){\r
+ view = inflator.inflate(R.layout.grid_image, null);\r
+ } else {\r
+ view = inflator.inflate(R.layout.grid_item, null);\r
+ }\r
+ \r
View frame = view.findViewById(R.id.imageItemFrame);\r
frame.setVisibility(View.GONE);\r
}\r
-// }\r
view.invalidate();\r
\r
- if (mFiles != null && mFiles.size() > position) {\r
- OCFile file = mFiles.get(position);\r
+ if (file != null){\r
TextView fileName = (TextView) view.findViewById(R.id.Filename);\r
- if (!fileView){fileName.setVisibility(View.GONE);}\r
+ // if (!fileView){fileName.setVisibility(View.GONE);}\r
String name = file.getFileName();\r
\r
fileName.setText(name);\r
}\r
\r
GridView parentList = (GridView)parent;\r
- if (parentList.getChoiceMode() == ListView.CHOICE_MODE_NONE) { \r
+ if (parentList.getChoiceMode() == GridView.CHOICE_MODE_NONE) { \r
checkBoxV.setVisibility(View.GONE);\r
} else {\r
if (parentList.isItemChecked(position)) {\r
private static final String KEY_HEIGHT_CELL = "HEIGHT_CELL";
private static final String KEY_EMPTY_LIST_MESSAGE = "EMPTY_LIST_MESSAGE";
- protected ExtendedListView mList;
+ // protected ExtendedListView mList;
private SwipeRefreshLayout mRefreshLayout;
private SwipeRefreshLayout mRefreshEmptyLayout;
private SwipeRefreshLayout.OnRefreshListener mOnRefreshListener = null;
- private GridView imageView;
- private View fileView;
-
-
+ protected GridView imageView;
+
public void setListAdapter(ListAdapter listAdapter) {
imageView.setAdapter(listAdapter);
imageView.invalidate();
}
- public ListView getListView() {
- return mList;
+ public GridView getGridView() {
+ return imageView;
}
protected void switchImageView(){
- // TODO berechnen, wieviele Spalten
- imageView.setNumColumns(3);
- mList.invalidate();
+ imageView.setNumColumns(GridView.AUTO_FIT);
imageView.invalidate();
}
protected void switchFileView(){
- imageView.setNumColumns(1);
- mList.invalidate();
+ imageView.setNumColumns(1);
imageView.invalidate();
}
View v = inflater.inflate(R.layout.list_fragment, null);
- imageView = (GridView) v.findViewById(R.id.grid_list_view);
- imageView.setOnItemClickListener(this);
+// imageView = (GridView) v.findViewById(R.id.grid_list_view);
+// imageView.setOnItemClickListener(this);
// mEmptyListMessage = (TextView) v.findViewById(R.id.empty_list_view);
- mList = (ExtendedListView)(v.findViewById(R.id.list_root));
- // mList.setOnItemClickListener(this);
+ imageView = (ExtendedListView)(v.findViewById(R.id.list_root));
+ imageView.setOnItemClickListener(this);
- mList.setDivider(getResources().getDrawable(R.drawable.uploader_list_separator));
- mList.setDividerHeight(1);
+ //mList.set
+ //mList.setDivider(getResources().getDrawable(R.drawable.uploader_list_separator));
+ //mList.setDividerHeight(1);
if (savedInstanceState != null) {
int referencePosition = savedInstanceState.getInt(KEY_SAVED_LIST_POSITION);
onCreateSwipeToRefresh(mRefreshLayout);
onCreateSwipeToRefresh(mRefreshEmptyLayout);
- mList.setEmptyView(mRefreshEmptyLayout);
+// mList.setEmptyView(mRefreshEmptyLayout);
return v;
}
* @return The position in the list of the visible item in the center of the screen.
*/
protected int getReferencePosition() {
- if (mList != null) {
- return (mList.getFirstVisiblePosition() + mList.getLastVisiblePosition()) / 2;
+ if (imageView != null) {
+ return (imageView.getFirstVisiblePosition() + imageView.getLastVisiblePosition()) / 2;
} else {
return 0;
}
* @param position Reference position previously returned by {@link LocalFileListFragment#getReferencePosition()}
*/
protected void setReferencePosition(int position) {
- if (mList != null) {
- mList.setAndCenterSelection(position);
+ if (imageView != null) {
+ imageView.setSelection(position);
}
}
int top = mTops.remove(mTops.size() - 1);
- mList.setSelectionFromTop(firstPosition, top);
+ imageView.setSelection(firstPosition);
// Move the scroll if the selection is not visible
int indexPosition = mHeightCell*index;
- int height = mList.getHeight();
+ int height = imageView.getHeight();
if (indexPosition > height) {
if (android.os.Build.VERSION.SDK_INT >= 11)
{
- mList.smoothScrollToPosition(index);
+ imageView.smoothScrollToPosition(index);
}
else if (android.os.Build.VERSION.SDK_INT >= 8)
{
- mList.setSelectionFromTop(index, 0);
+ imageView.setSelection(index);
}
}
mIndexes.add(index);
- int firstPosition = mList.getFirstVisiblePosition();
+ int firstPosition = imageView.getFirstVisiblePosition();
mFirstPositions.add(firstPosition);
- View view = mList.getChildAt(0);
+ View view = imageView.getChildAt(0);
int top = (view == null) ? 0 : view.getTop() ;
mTops.add(top);
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Log_OC.i(TAG, "onCreateView() start");
View v = super.onCreateView(inflater, container, savedInstanceState);
- getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
+ getGridView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
disableSwipe(); // Disable pull refresh
setMessageForEmptyList(getString(R.string.local_file_list_empty));
Log_OC.i(TAG, "onCreateView() end");
} else { /// Click on a file
ImageView checkBoxV = (ImageView) v.findViewById(R.id.custom_checkbox);
if (checkBoxV != null) {
- if (getListView().isItemChecked(position)) {
+ if (getGridView().isItemChecked(position)) {
checkBoxV.setImageResource(android.R.drawable.checkbox_on_background);
} else {
checkBoxV.setImageResource(android.R.drawable.checkbox_off_background);
directory = directory.getParentFile();
}
- mList.clearChoices(); // by now, only files in the same directory will be kept as selected
+ imageView.clearChoices(); // by now, only files in the same directory will be kept as selected
mAdapter.swapDirectory(directory);
if (mDirectory == null || !mDirectory.equals(directory)) {
- mList.setSelectionFromTop(0, 0);
+ imageView.setSelection(0);
}
mDirectory = directory;
}
*/
public String[] getCheckedFilePaths() {
String [] result = null;
- SparseBooleanArray positions = mList.getCheckedItemPositions();
+ SparseBooleanArray positions = imageView.getCheckedItemPositions();
if (positions.size() > 0) {
Log_OC.d(TAG, "Returning " + positions.size() + " selected files");
result = new String[positions.size()];
for (int i=0; i<positions.size(); i++) {
- result[i] = ((File) mList.getItemAtPosition(positions.keyAt(i))).getAbsolutePath();
+ result[i] = ((File) imageView.getItemAtPosition(positions.keyAt(i))).getAbsolutePath();
}
}
return result;
);
setListAdapter(mAdapter);
- registerForContextMenu(getListView());
- getListView().setOnCreateContextMenuListener(this);
+ registerForContextMenu(getGridView());
+ getGridView().setOnCreateContextMenuListener(this);
}
/**
mAdapter.swapDirectory(directory, storageManager);
if (mFile == null || !mFile.equals(directory)) {
- mList.setSelectionFromTop(0, 0);
+ imageView.setSelection(0);
}
mFile = directory;