X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/2be23eaec586972a5ff86c4f9c34d95188231821..7f7af85f124517c674b52f09f100e90a58eb148b:/src/com/owncloud/android/ui/preview/FileDownloadFragment.java diff --git a/src/com/owncloud/android/ui/preview/FileDownloadFragment.java b/src/com/owncloud/android/ui/preview/FileDownloadFragment.java index da8c5f9d..99a4d444 100644 --- a/src/com/owncloud/android/ui/preview/FileDownloadFragment.java +++ b/src/com/owncloud/android/ui/preview/FileDownloadFragment.java @@ -1,6 +1,8 @@ -/* ownCloud Android client application - * - * Copyright (C) 2012-2013 ownCloud Inc. +/** + * ownCloud Android client application + * + * @author David A. Velasco + * Copyright (C) 2015 ownCloud Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2, @@ -19,8 +21,12 @@ package com.owncloud.android.ui.preview; import java.lang.ref.WeakReference; +import com.owncloud.android.R; +import com.owncloud.android.datamodel.OCFile; +import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder; +import com.owncloud.android.ui.fragment.FileFragment; + import android.accounts.Account; -import android.app.Activity; import android.os.Bundle; import android.support.v4.app.FragmentStatePagerAdapter; import android.view.LayoutInflater; @@ -28,22 +34,16 @@ import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.ImageButton; +import android.widget.LinearLayout; import android.widget.ProgressBar; import android.widget.TextView; -import com.owncloud.android.datamodel.OCFile; -import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder; -import com.owncloud.android.network.webdav.OnDatatransferProgressListener; -import com.owncloud.android.ui.fragment.FileFragment; - -import com.owncloud.android.Log_OC; -import com.owncloud.android.R; +import com.owncloud.android.lib.common.network.OnDatatransferProgressListener; +import com.owncloud.android.lib.common.utils.Log_OC; /** * This Fragment is used to monitor the progress of a file downloading. - * - * @author David A. Velasco */ public class FileDownloadFragment extends FileFragment implements OnClickListener { @@ -51,8 +51,6 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene public static final String EXTRA_ACCOUNT = "ACCOUNT"; private static final String EXTRA_ERROR = "ERROR"; - private FileFragment.ContainerActivity mContainerActivity; - private View mView; private Account mAccount; @@ -129,6 +127,13 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene ((ImageButton)mView.findViewById(R.id.cancelBtn)).setOnClickListener(this); + ((LinearLayout)mView.findViewById(R.id.fileDownloadLL)).setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + ((PreviewImageActivity) getActivity()).toggleFullScreen(); + } + }); + if (mError) { setButtonsForRemote(); } else { @@ -139,33 +144,6 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene } - /** - * {@inheritDoc} - */ - @Override - public void onAttach(Activity activity) { - super.onAttach(activity); - try { - mContainerActivity = (ContainerActivity) activity; - - } catch (ClassCastException e) { - throw new ClassCastException(activity.toString() + " must implement " + FileFragment.ContainerActivity.class.getSimpleName()); - } - } - - - /** - * {@inheritDoc} - */ - @Override - public void onActivityCreated(Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); - if (mAccount != null) { - //mStorageManager = new FileDataStorageManager(mAccount, getActivity().getApplicationContext().getContentResolver());; - } - } - - @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); @@ -194,8 +172,8 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene @Override public void onStop() { - super.onStop(); leaveTransferProgress(); + super.onStop(); } @Override @@ -217,19 +195,8 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene public void onClick(View v) { switch (v.getId()) { case R.id.cancelBtn: { - FileDownloaderBinder downloaderBinder = mContainerActivity.getFileDownloaderBinder(); - if (downloaderBinder != null && downloaderBinder.isDownloading(mAccount, getFile())) { - downloaderBinder.cancel(mAccount, getFile()); - getActivity().finish(); // :) - /* - leaveTransferProgress(); - if (mFile.isDown()) { - setButtonsForDown(); - } else { - setButtonsForRemote(); - } - */ - } + mContainerActivity.getFileOperationsHelper().cancelTransference(getFile()); + getActivity().finish(); break; } default: @@ -244,10 +211,11 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene * @param transferring When true, the view must be updated assuming that the holded file is * downloading, no matter what the downloaderBinder says. */ + /* public void updateView(boolean transferring) { // configure UI for depending upon local state of the file - FileDownloaderBinder downloaderBinder = (mContainerActivity == null) ? null : mContainerActivity.getFileDownloaderBinder(); - if (transferring || (downloaderBinder != null && downloaderBinder.isDownloading(mAccount, getFile()))) { + // TODO remove + if (transferring || getFile().isDownloading()) { setButtonsForTransferring(); } else if (getFile().isDown()) { @@ -260,7 +228,7 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene getView().invalidate(); } - + */ /** * Enables or disables buttons for a file being downloaded @@ -340,9 +308,7 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene /** - * Helper class responsible for updating the progress bar shown for file uploading or downloading - * - * @author David A. Velasco + * Helper class responsible for updating the progress bar shown for file uploading or downloading */ private class ProgressListener implements OnDatatransferProgressListener { int mLastPercent = 0; @@ -353,11 +319,6 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene } @Override - public void onTransferProgress(long progressRate) { - // old method, nothing here - }; - - @Override public void onTransferProgress(long progressRate, long totalTransferredSoFar, long totalToTransfer, String filename) { int percent = (int)(100.0*((double)totalTransferredSoFar)/((double)totalToTransfer)); if (percent != mLastPercent) {