X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/be3b6a53b938c07f593a2bd8ddfe6f72d3524117..1fbc44b5743380523af7999c072299aad79fb65b:/src/com/owncloud/android/ui/activity/FileDisplayActivity.java diff --git a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java index 240d146f..9348f367 100644 --- a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -116,8 +116,6 @@ public class FileDisplayActivity extends HookActivity implements FileFragment.ContainerActivity, OnSslUntrustedCertListener, OnEnforceableRefreshListener { - - private SyncBroadcastReceiver mSyncBroadcastReceiver; private UploadFinishReceiver mUploadFinishReceiver; private DownloadFinishReceiver mDownloadFinishReceiver; @@ -1048,7 +1046,11 @@ public class FileDisplayActivity extends HookActivity (uploadedRemotePath.startsWith(currentDir.getRemotePath())); if (sameAccount && isDescendant) { - refreshListOfFilesFragment(); + String linkedToRemotePath = + intent.getStringExtra(FileDownloader.EXTRA_LINKED_TO_PATH); + if (linkedToRemotePath == null || isAscendant(linkedToRemotePath)) { + refreshListOfFilesFragment(); + } } boolean uploadWasFine = intent.getBooleanExtra(FileUploader.EXTRA_UPLOAD_RESULT, @@ -1101,6 +1103,16 @@ public class FileDisplayActivity extends HookActivity } + // TODO refactor this receiver, and maybe DownloadFinishReceiver; this method is duplicated :S + private boolean isAscendant(String linkedToRemotePath) { + OCFile currentDir = getCurrentDir(); + return ( + currentDir != null && + currentDir.getRemotePath().startsWith(linkedToRemotePath) + ); + } + + } @@ -1112,11 +1124,10 @@ public class FileDisplayActivity extends HookActivity */ private class DownloadFinishReceiver extends BroadcastReceiver { - //int refreshCounter = 0; @Override public void onReceive(Context context, Intent intent) { try { - boolean sameAccount = isSameAccount(context, intent); + boolean sameAccount = isSameAccount(intent); String downloadedRemotePath = intent.getStringExtra(FileDownloader.EXTRA_REMOTE_PATH); boolean isDescendant = isDescendant(downloadedRemotePath); @@ -1125,7 +1136,6 @@ public class FileDisplayActivity extends HookActivity String linkedToRemotePath = intent.getStringExtra(FileDownloader.EXTRA_LINKED_TO_PATH); if (linkedToRemotePath == null || isAscendant(linkedToRemotePath)) { - //Log_OC.v(TAG, "refresh #" + ++refreshCounter); refreshListOfFilesFragment(); } refreshSecondFragment( @@ -1167,7 +1177,7 @@ public class FileDisplayActivity extends HookActivity ); } - private boolean isSameAccount(Context context, Intent intent) { + private boolean isSameAccount(Intent intent) { String accountName = intent.getStringExtra(FileDownloader.ACCOUNT_NAME); return (accountName != null && getAccount() != null && accountName.equals(getAccount().name)); @@ -1217,6 +1227,20 @@ public class FileDisplayActivity extends HookActivity setFile(file); } + /** + * Shows the share view for sharing {@link OCFile} received as a + * parameter in the second fragment. + * + * @param file {@link OCFile} File to share with + */ + @Override + public void showShareFile(OCFile file) { + Intent intent = new Intent(this, ShareActivity.class); + intent.putExtra(EXTRA_FILE, file); + intent.putExtra(EXTRA_ACCOUNT, getAccount()); + startActivity(intent); + } + @Override protected void updateActionBarTitleAndHomeButton(OCFile chosenFile) { if (mDualPane) {