Merge branch 'master' of gitorious.org:owncloud/android-devel

This commit is contained in:
Bartek Przybylski 2012-05-19 19:08:39 +02:00
commit ef45634ffe
12 changed files with 291 additions and 232 deletions

View file

@ -17,7 +17,7 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android" android:exitFadeDuration="@android:integer/config_mediumAnimTime"> <selector xmlns:android="http://schemas.android.com/apk/res/android" android:exitFadeDuration="@android:integer/config_mediumAnimTime">
<item android:drawable="@color/filelist_backgorund" android:state_window_focused="false"/> <item android:drawable="@color/owncloud_white" android:state_window_focused="false"/>
<!-- Even though these two point to the same resource, have two states so the drawable will invalidate itself when coming out of pressed state. --> <!-- Even though these two point to the same resource, have two states so the drawable will invalidate itself when coming out of pressed state. -->
<item android:drawable="@android:color/holo_blue_bright" android:state_enabled="false" android:state_focused="true" android:state_pressed="true"/> <item android:drawable="@android:color/holo_blue_bright" android:state_enabled="false" android:state_focused="true" android:state_pressed="true"/>

View file

@ -17,7 +17,7 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android" android:exitFadeDuration="@android:integer/config_mediumAnimTime"> <selector xmlns:android="http://schemas.android.com/apk/res/android" android:exitFadeDuration="@android:integer/config_mediumAnimTime">
<item android:drawable="@color/filelist_backgorund" android:state_window_focused="false"/> <item android:drawable="@color/owncloud_white" android:state_window_focused="false"/>
<!-- Even though these two point to the same resource, have two states so the drawable will invalidate itself when coming out of pressed state. --> <!-- Even though these two point to the same resource, have two states so the drawable will invalidate itself when coming out of pressed state. -->
<item android:drawable="@android:color/holo_blue_bright" android:state_enabled="false" android:state_focused="true" android:state_pressed="true"/> <item android:drawable="@android:color/holo_blue_bright" android:state_enabled="false" android:state_focused="true" android:state_pressed="true"/>

View file

@ -19,12 +19,13 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:background="@color/owncloud_white"
android:orientation="horizontal" > android:orientation="horizontal" >
<LinearLayout <LinearLayout
android:id="@+id/file_list_container" android:id="@+id/file_list_container"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="fill_parent"
android:layout_weight="1" > android:layout_weight="1" >
<fragment <fragment
@ -39,17 +40,10 @@
<LinearLayout android:id="@+id/file_details_container" <LinearLayout android:id="@+id/file_details_container"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="fill_parent"
android:layout_weight="2" > android:layout_weight="2" >
<fragment
android:id="@+id/fileDetail"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
class="eu.alefzero.owncloud.ui.fragment.FileDetailFragment" >
<!-- Preview: layout=@layout/file_details_empty --> <!-- Preview: layout=@layout/file_details_empty -->
</fragment>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>

View file

@ -21,10 +21,11 @@
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical" > android:orientation="vertical" >
<fragment <LinearLayout
android:id="@+id/fileDetail" android:id="@+id/fragment"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent" >
class="eu.alefzero.owncloud.ui.fragment.FileDetailFragment" /> <!-- Preview: layout=@layout/file_details_fragment -->
</LinearLayout>
</LinearLayout> </LinearLayout>

View file

@ -16,96 +16,150 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
--> -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:background="#F7F7F7" android:background="@color/owncloud_white" >
android:orientation="vertical" >
<LinearLayout <ScrollView
android:id="@+id/linearLayout1" android:id="@+id/fdScrollView"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" > android:layout_height="wrap_content" >
<LinearLayout <RelativeLayout
android:id="@+id/linearLayout2" android:id="@+id/fdFileHeaderContainer"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="fill_parent" > android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginTop="4dp" >
<ImageView <ImageView
android:id="@+id/imageView1" android:id="@+id/fdIcon"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:src="@drawable/icon" > android:src="@drawable/file" />
</ImageView>
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout3"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView <TextView
android:id="@+id/textView1" android:id="@+id/fdFilename"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="TextView" > android:layout_centerVertical="true"
</TextView> android:layout_toRightOf="@+id/fdIcon"
android:text="file.name"
android:textAppearance="?android:attr/textAppearanceLarge" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/fdDetailsContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/fdFileHeaderContainer" >
<RelativeLayout
android:id="@+id/fdLabelContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp" >
<TextView <TextView
android:id="@+id/textView2" android:id="@+id/fdTypeLabel"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="TextView" > android:layout_marginTop="24dp"
</TextView> android:text="@string/filedetails_type"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView <TextView
android:id="@+id/textView3" android:id="@+id/fdSizeLabel"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="TextView" > android:layout_below="@+id/fdTypeLabel"
</TextView> android:layout_marginTop="12dp"
android:text="@string/filedetails_size"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView <TextView
android:id="@+id/textView4" android:id="@+id/fdCreatedLabel"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="TextView" > android:layout_below="@+id/fdSizeLabel"
</TextView> android:layout_marginTop="12dp"
android:text="@string/filedetails_created"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/fdValueContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginLeft="4dp" >
<TextView <TextView
android:id="@+id/textView5" android:id="@+id/fdType"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="TextView" > android:layout_marginTop="24dp"
</TextView> android:text="JPG Image"
</LinearLayout> android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<LinearLayout <TextView
android:id="@+id/linearLayout4" android:id="@+id/fdSize"
android:layout_width="fill_parent" android:layout_width="wrap_content"
android:layout_height="fill_parent" > android:layout_height="wrap_content"
android:layout_below="@+id/fdType"
android:layout_marginTop="12dp"
android:text="389 KB"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/fdCreated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/fdSize"
android:layout_marginTop="12dp"
android:text="2012/05/18 12:23 PM"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/fdModified"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/fdCreated"
android:layout_marginTop="12dp"
android:text="2012/05/19 02:56 PM"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:id="@+id/fdPreviewAndDL"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/fdDetailsContainer" >
<ImageView <ImageView
android:id="@+id/imageView2" android:id="@+id/fdPreview"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:src="@drawable/action_item_btn" /> android:layout_centerHorizontal="true"
android:layout_marginTop="16dp"
android:src="@drawable/owncloud_logo" />
<VideoView <Button
android:id="@+id/videoView1" android:id="@+id/fdDownloadBtn"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" /> android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="@+id/fdPreview"
android:layout_marginTop="12dp"
android:text="@string/filedetails_download" />
</RelativeLayout>
</RelativeLayout>
</ScrollView>
<ListView </RelativeLayout>
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:divider="@drawable/uploader_list_separator"
android:dividerHeight="1dip" >
</ListView>
</LinearLayout>
</LinearLayout>

View file

@ -19,6 +19,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:background="@color/owncloud_white"
android:orientation="vertical" > android:orientation="vertical" >
<fragment <fragment

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<color name="filelist_icon_backgorund">#DDDDDD</color> <color name="filelist_icon_backgorund">#DDDDDD</color>
<color name="filelist_backgorund">#F7F7F7</color> <color name="owncloud_white">#F7F7F7</color>
</resources> </resources>

View file

@ -49,6 +49,11 @@
<string name="uploader_info_uploading">Uploading</string> <string name="uploader_info_uploading">Uploading</string>
<string name="uploader_btn_create_dir_text">Create dir for upload</string> <string name="uploader_btn_create_dir_text">Create dir for upload</string>
<string name="filedetails_select_file">Tap on a file to display additional information.</string> <string name="filedetails_select_file">Tap on a file to display additional information.</string>
<string name="filedetails_size">Size:</string>
<string name="filedetails_type">Type:</string>
<string name="filedetails_created">Created:</string>
<string name="filedetails_modified">Modified:</string>
<string name="filedetails_download">Download</string>
<string name="common_yes">Yes</string> <string name="common_yes">Yes</string>
<string name="common_no">No</string> <string name="common_no">No</string>
<string name="common_ok">OK</string> <string name="common_ok">OK</string>

View file

@ -35,7 +35,7 @@ public class DisplayUtils {
attachedsuff++; attachedsuff++;
} }
result = ((int) (result * 100)) / 100.; result = ((int) (result * 100)) / 100.;
return result + suffixes[attachedsuff]; return result + " " + suffixes[attachedsuff];
} }
public static String HtmlDecode(String s) { public static String HtmlDecode(String s) {

View file

@ -43,11 +43,19 @@ public class FileDetailActivity extends SherlockFragmentActivity {
getWindow().requestFeature(Window.FEATURE_NO_TITLE); getWindow().requestFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.file_activity_details); setContentView(R.layout.file_activity_details);
mFileDetail = new FileDetailFragment(getIntent());
FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.add(R.id.fileDetail, mFileDetail); mFileDetail = new FileDetailFragment();
ft.add(R.id.fragment, mFileDetail, "FileDetails");
ft.commit(); ft.commit();
} }
@Override
protected void onResume() {
super.onResume();
mFileDetail.updateFileDetails(getIntent());
}
} }

View file

@ -17,7 +17,6 @@
*/ */
package eu.alefzero.owncloud.ui.fragment; package eu.alefzero.owncloud.ui.fragment;
import android.app.FragmentTransaction;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@ -29,10 +28,10 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import android.widget.VideoView;
import com.actionbarsherlock.app.SherlockFragment; import com.actionbarsherlock.app.SherlockFragment;
@ -52,33 +51,43 @@ public class FileDetailFragment extends SherlockFragment implements
public static final String FILE = "FILE"; public static final String FILE = "FILE";
private Intent mIntent;
private View mView;
private DownloadFinishReceiver mDownloadFinishReceiver; private DownloadFinishReceiver mDownloadFinishReceiver;
private Intent mIntent;
private int mLayout;
private View mView;
private OCFile mFile; private OCFile mFile;
private int mLayout;
private boolean mEmptyLayout;
/** /**
* Default constructor. When inflated by android -> display empty layout * Default constructor - contains real layout
*/ */
public FileDetailFragment(){ public FileDetailFragment(){
mLayout = R.layout.file_details_empty; mLayout = R.layout.file_details_fragment;
mEmptyLayout = true;
} }
/** /**
* Custom construtor. Use with a {@link FragmentTransaction}. The intent has * Creates a dummy layout. For use if the user never has
* to contain {@link FileDetailFragment#FILE} with an OCFile and also * tapped on a file before
* {@link FileDownloader#EXTRA_ACCOUNT} with the account.
* *
* @param nonEmptyFragment True, to enable file detail rendering * @param useEmptyView If true, use empty layout
*/ */
public FileDetailFragment(Intent intent) { public FileDetailFragment(boolean useEmptyView){
if(useEmptyView){
mLayout = R.layout.file_details_empty;
} else {
mLayout = R.layout.file_details_fragment;
}
}
/**
* Use this when creating the fragment and display
* a file at the same time
*
* @param showDetailsIntent The Intent with the required parameters
* @see FileDetailFragment#updateFileDetails(Intent)
*/
public FileDetailFragment(Intent showDetailsIntent) {
mIntent = showDetailsIntent;
mLayout = R.layout.file_details_fragment; mLayout = R.layout.file_details_fragment;
mIntent = intent;
mEmptyLayout = false;
} }
@Override @Override
@ -123,84 +132,62 @@ public class FileDetailFragment extends SherlockFragment implements
.getMimetype())); .getMimetype()));
setFilesize(mFile.getFileLength()); setFilesize(mFile.getFileLength());
// set file preview if available and possible // Update preview
VideoView videoView = (VideoView) mView if (mFile.getStoragePath() != null) {
.findViewById(R.id.videoView1);
videoView.setVisibility(View.INVISIBLE);
if (mFile.getStoragePath() == null) {
ImageView imageView = (ImageView) getView().findViewById(
R.id.imageView2);
imageView.setImageResource(R.drawable.download);
imageView.setOnClickListener(this);
} else {
if (mFile.getMimetype().startsWith("image/")) { if (mFile.getMimetype().startsWith("image/")) {
ImageView imageView = (ImageView) mView ImageView preview = (ImageView) getView().findViewById(
.findViewById(R.id.imageView2); R.id.fdPreview);
Bitmap bmp = BitmapFactory.decodeFile(mFile.getStoragePath()); Bitmap bmp = BitmapFactory.decodeFile(mFile.getStoragePath());
imageView.setImageBitmap(bmp); preview.setImageBitmap(bmp);
} else if (mFile.getMimetype().startsWith("video/")) {
videoView.setVisibility(View.VISIBLE);
videoView.setVideoPath(mFile.getStoragePath());
videoView.start();
} }
} }
// Make download button effective
Button downloadButton = (Button) getView().findViewById(R.id.fdDownloadBtn);
downloadButton.setOnClickListener(this);
} }
} }
private void setFilename(String filename) {
TextView tv = (TextView) getView().findViewById(R.id.fdFilename);
if (tv != null)
tv.setText(filename);
}
private void setFiletype(String mimetype) {
TextView tv = (TextView) getView().findViewById(R.id.fdType);
if (tv != null)
tv.setText(mimetype);
}
private void setFilesize(long filesize) {
TextView tv = (TextView) getView().findViewById(R.id.fdSize);
if (tv != null)
tv.setText(DisplayUtils.bitsToHumanReadable(filesize));
}
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
View view = null; View view = null;
view = inflater.inflate(mLayout, container, false); view = inflater.inflate(mLayout, container, false);
mIntent = getActivity().getIntent();
mView = view; mView = view;
if(mLayout == R.layout.file_details_fragment){
// make sure we are not using the empty layout // Phones will launch an activity with this intent
if (mEmptyLayout == false) { if(mIntent == null){
mIntent = getActivity().getIntent();
}
updateFileDetails(); updateFileDetails();
} }
return view; return view;
} }
@Override @Override
public View getView() { public View getView() {
return mView == null ? super.getView() : mView; return super.getView() == null ? mView : super.getView();
};
private void setFilename(String filename) {
TextView tv = (TextView) getView().findViewById(R.id.textView1);
if (tv != null)
tv.setText(filename);
}
private void setFiletype(String mimetype) {
TextView tv = (TextView) getView().findViewById(R.id.textView2);
if (tv != null)
tv.setText(mimetype);
}
private void setFilesize(long filesize) {
TextView tv = (TextView) getView().findViewById(R.id.textView3);
if (tv != null)
tv.setText(DisplayUtils.bitsToHumanReadable(filesize));
}
/**
* Use this to check if the correct layout is loaded. When android
* instanciates this class using the default constructor, the layout will be
* empty.
*
* Once a user touches a file for the first time, you must instanciate a new
* Fragment with the new FileDetailFragment(true) to inflate the actual
* details
*
* @return If the layout is empty, this method will return true, otherwise
* false
*/
public boolean isEmptyLayout() {
return mEmptyLayout;
} }
@Override @Override
@ -209,8 +196,7 @@ public class FileDetailFragment extends SherlockFragment implements
Intent i = new Intent(getActivity(), FileDownloader.class); Intent i = new Intent(getActivity(), FileDownloader.class);
i.putExtra(FileDownloader.EXTRA_ACCOUNT, i.putExtra(FileDownloader.EXTRA_ACCOUNT,
mIntent.getParcelableExtra(FileDownloader.EXTRA_ACCOUNT)); mIntent.getParcelableExtra(FileDownloader.EXTRA_ACCOUNT));
i.putExtra(FileDownloader.EXTRA_FILE_PATH, i.putExtra(FileDownloader.EXTRA_FILE_PATH, mFile.getPath());
mIntent.getStringExtra(FileDownloader.EXTRA_FILE_PATH));
getActivity().startService(i); getActivity().startService(i);
} }

View file

@ -52,6 +52,7 @@ public class FileListFragment extends FragmentListView {
private Stack<String> mDirNames; private Stack<String> mDirNames;
private Vector<OCFile> mFiles; private Vector<OCFile> mFiles;
private DataStorageManager mStorageManager; private DataStorageManager mStorageManager;
private boolean mIsLargeDevice = false;
public FileListFragment() { public FileListFragment() {
mDirNames = new Stack<String>(); mDirNames = new Stack<String>();
@ -62,13 +63,26 @@ public class FileListFragment extends FragmentListView {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
mAccount = AccountUtils.getCurrentOwnCloudAccount(getActivity()); mAccount = AccountUtils.getCurrentOwnCloudAccount(getActivity());
getListView().setDivider( getListView().setDivider(getResources().getDrawable(R.drawable.uploader_list_separator));
getResources().getDrawable(R.drawable.uploader_list_separator));
getListView().setDividerHeight(1); getListView().setDividerHeight(1);
populateFileList(); populateFileList();
} }
@Override
public void onStart() {
// Create a placeholder upon launch
View fragmentContainer = getActivity().findViewById(R.id.file_details_container);
if (fragmentContainer != null) {
mIsLargeDevice = true;
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.replace(R.id.file_details_container, new FileDetailFragment(true));
transaction.commit();
}
super.onStart();
}
@Override @Override
public void onItemClick(AdapterView<?> l, View v, int position, long id) { public void onItemClick(AdapterView<?> l, View v, int position, long id) {
if (mFiles.size() <= position) { if (mFiles.size() <= position) {
@ -84,53 +98,51 @@ public class FileListFragment extends FragmentListView {
((FileDisplayActivity) getActivity()).pushPath(dirname); ((FileDisplayActivity) getActivity()).pushPath(dirname);
populateFileList(); populateFileList();
resetFileFragment();
return; return;
} }
Intent showDetailsIntent = new Intent(getActivity(), Intent showDetailsIntent = new Intent(getActivity(), FileDetailActivity.class);
FileDetailActivity.class);
showDetailsIntent.putExtra(FileDetailFragment.FILE, file); showDetailsIntent.putExtra(FileDetailFragment.FILE, file);
showDetailsIntent.putExtra(FileDownloader.EXTRA_ACCOUNT, mAccount); showDetailsIntent.putExtra(FileDownloader.EXTRA_ACCOUNT, mAccount);
// Try to find by tag first // If we are on a large device -> update fragment
FileDetailFragment fd = (FileDetailFragment) getFragmentManager() if (mIsLargeDevice) {
.findFragmentByTag("FileDetails"); FileDetailFragment fileDetails = (FileDetailFragment) getFragmentManager().findFragmentByTag("FileDetails");
if (fileDetails == null) {
// Could be the first time the user has touched a file. find by id FragmentTransaction transaction = getFragmentManager().beginTransaction();
if (fd == null) { transaction.replace(R.id.file_details_container, new FileDetailFragment(showDetailsIntent), "FileDetails");
fd = (FileDetailFragment) getFragmentManager().findFragmentById( transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
R.id.fileDetail);
}
// Tablets will have this fragment, phones not. Could still be null
if (fd != null) {
if (fd.isEmptyLayout()) {
// True, if this is the first time a user taps on a file
fd = new FileDetailFragment(showDetailsIntent);
FragmentTransaction transaction = getFragmentManager()
.beginTransaction();
transaction.replace(R.id.file_details_container, fd,
"FileDetails");
transaction.commit(); transaction.commit();
} else { } else {
fd.updateFileDetails(showDetailsIntent); fileDetails.updateFileDetails(showDetailsIntent);
} }
} else { } else {
startActivity(showDetailsIntent); startActivity(showDetailsIntent);
} }
} }
/**
* Resets the FileDetailsFragment on Tablets so that it always displays
* "Tab on a file to display it's details"
*/
private void resetFileFragment() {
FileDetailFragment fileDetails = (FileDetailFragment) getFragmentManager().findFragmentByTag("FileDetails");
if (fileDetails != null) {
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.remove(fileDetails);
transaction.add(R.id.file_details_container, new FileDetailFragment(true));
transaction.commit();
}
}
@Override @Override
public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
long arg3) {
ClipData.Item item = new ClipData.Item("ASD"); ClipData.Item item = new ClipData.Item("ASD");
ClipDescription cd = new ClipDescription("ASD", ClipDescription cd = new ClipDescription("ASD", new String[] { ClipDescription.MIMETYPE_TEXT_PLAIN });
new String[] { ClipDescription.MIMETYPE_TEXT_PLAIN });
ClipData dragData = new ClipData(cd, item); ClipData dragData = new ClipData(cd, item);
arg1.startDrag(dragData, arg1.startDrag(dragData, new View.DragShadowBuilder(arg0.getChildAt(arg2)), null, 0);
new View.DragShadowBuilder(arg0.getChildAt(arg2)), null, 0);
return true; return true;
} }
@ -140,6 +152,7 @@ public class FileListFragment extends FragmentListView {
public void onNavigateUp() { public void onNavigateUp() {
mDirNames.pop(); mDirNames.pop();
populateFileList(); populateFileList();
resetFileFragment();
} }
/** /**
@ -151,16 +164,13 @@ public class FileListFragment extends FragmentListView {
s += a + "/"; s += a + "/";
Log.e("ASD", s); Log.e("ASD", s);
mStorageManager = new FileDataStorageManager(mAccount, getActivity() mStorageManager = new FileDataStorageManager(mAccount, getActivity().getContentResolver());
.getContentResolver());
OCFile file = mStorageManager.getFileByPath(s); OCFile file = mStorageManager.getFileByPath(s);
mFiles = mStorageManager.getDirectoryContent(file); mFiles = mStorageManager.getDirectoryContent(file);
if (mFiles == null || mFiles.size() == 0) { if (mFiles == null || mFiles.size() == 0) {
Toast.makeText(getActivity(), "There are no files here", Toast.makeText(getActivity(), "There are no files here", Toast.LENGTH_LONG).show();
Toast.LENGTH_LONG).show();
} }
setListAdapter(new FileListListAdapter(file, mStorageManager, setListAdapter(new FileListListAdapter(file, mStorageManager, getActivity()));
getActivity()));
} }
// TODO: Delete this testing stuff. // TODO: Delete this testing stuff.