import android.os.Bundle;\r
import android.os.IBinder;\r
import android.support.v4.app.FragmentTransaction;\r
+import android.util.Log;\r
\r
import com.actionbarsherlock.app.ActionBar;\r
import com.actionbarsherlock.app.SherlockFragmentActivity;\r
import com.owncloud.android.datamodel.OCFile;\r
import com.owncloud.android.files.services.FileDownloader;\r
import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;\r
+import com.owncloud.android.files.services.FileUploader;\r
+import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;\r
import com.owncloud.android.ui.fragment.FileDetailFragment;\r
\r
import com.owncloud.android.R;\r
public class FileDetailActivity extends SherlockFragmentActivity implements FileDetailFragment.ContainerActivity {\r
\r
public static final int DIALOG_SHORT_WAIT = 0;\r
+\r
+ public static final String TAG = FileDetailActivity.class.getSimpleName();\r
\r
private boolean mConfigurationChangedToLandscape = false;\r
private FileDownloaderBinder mDownloaderBinder = null;\r
- private ServiceConnection mConnection = null;\r
+ private ServiceConnection mDownloadConnection, mUploadConnection = null;\r
+ private FileUploaderBinder mUploaderBinder = null;\r
+\r
\r
@Override\r
protected void onCreate(Bundle savedInstanceState) {\r
);\r
\r
if (!mConfigurationChangedToLandscape) {\r
- mConnection = new DetailsServiceConnection();\r
- bindService(new Intent(this, FileDownloader.class), mConnection, Context.BIND_AUTO_CREATE);\r
+ mDownloadConnection = new DetailsServiceConnection();\r
+ bindService(new Intent(this, FileDownloader.class), mDownloadConnection, Context.BIND_AUTO_CREATE);\r
+ mUploadConnection = new DetailsServiceConnection();\r
+ bindService(new Intent(this, FileUploader.class), mUploadConnection, Context.BIND_AUTO_CREATE);\r
\r
setContentView(R.layout.file_activity_details);\r
\r
actionBar.setDisplayHomeAsUpEnabled(true);\r
\r
OCFile file = getIntent().getParcelableExtra(FileDetailFragment.EXTRA_FILE);\r
- Account account = getIntent().getParcelableExtra(FileDownloader.EXTRA_ACCOUNT);\r
+ Account account = getIntent().getParcelableExtra(FileDetailFragment.EXTRA_ACCOUNT);\r
FileDetailFragment mFileDetail = new FileDetailFragment(file, account);\r
\r
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();\r
private class DetailsServiceConnection implements ServiceConnection {\r
\r
@Override\r
- public void onServiceConnected(ComponentName className, IBinder service) {\r
- mDownloaderBinder = (FileDownloaderBinder) service;\r
+ public void onServiceConnected(ComponentName component, IBinder service) {\r
+ if (component.equals(new ComponentName(FileDetailActivity.this, FileDownloader.class))) {\r
+ Log.d(TAG, "Download service connected");\r
+ mDownloaderBinder = (FileDownloaderBinder) service;\r
+ } else if (component.equals(new ComponentName(FileDetailActivity.this, FileUploader.class))) {\r
+ Log.d(TAG, "Upload service connected");\r
+ mUploaderBinder = (FileUploaderBinder) service;\r
+ } else {\r
+ return;\r
+ }\r
FileDetailFragment fragment = (FileDetailFragment) getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG);\r
if (fragment != null)\r
fragment.updateFileDetails(); // let the fragment gets the mDownloadBinder through getDownloadBinder() (see FileDetailFragment#updateFileDetais())\r
}\r
\r
@Override\r
- public void onServiceDisconnected(ComponentName arg0) {\r
- mDownloaderBinder = null;\r
+ public void onServiceDisconnected(ComponentName component) {\r
+ if (component.equals(new ComponentName(FileDetailActivity.this, FileDownloader.class))) {\r
+ Log.d(TAG, "Download service disconnected");\r
+ mDownloaderBinder = null;\r
+ } else if (component.equals(new ComponentName(FileDetailActivity.this, FileUploader.class))) {\r
+ Log.d(TAG, "Upload service disconnected");\r
+ mUploaderBinder = null;\r
+ }\r
}\r
}; \r
\r
@Override\r
public void onDestroy() {\r
super.onDestroy();\r
- if (mConnection != null) {\r
- unbindService(mConnection);\r
- mConnection = null;\r
+ if (mDownloadConnection != null) {\r
+ unbindService(mDownloadConnection);\r
+ mDownloadConnection = null;\r
+ }\r
+ if (mUploadConnection != null) {\r
+ unbindService(mUploadConnection);\r
+ mUploadConnection = null;\r
}\r
}\r
\r
Intent intent = new Intent(this, FileDisplayActivity.class);\r
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);\r
intent.putExtra(FileDetailFragment.EXTRA_FILE, getIntent().getParcelableExtra(FileDetailFragment.EXTRA_FILE));\r
+ intent.putExtra(FileDetailFragment.EXTRA_ACCOUNT, getIntent().getParcelableExtra(FileDetailFragment.EXTRA_ACCOUNT));\r
startActivity(intent);\r
finish();\r
}\r
public FileDownloaderBinder getFileDownloaderBinder() {\r
return mDownloaderBinder;\r
}\r
+\r
+\r
+ @Override\r
+ public FileUploaderBinder getFileUploaderBinder() {\r
+ return mUploaderBinder;\r
+ }\r
\r
}\r