From: masensio Date: Tue, 25 Jun 2013 13:16:25 +0000 (-0700) Subject: Merge pull request #195 from owncloud/fixed_crash_due_to_uploads_to_accounts_not_alre... X-Git-Tag: oc-android-1.4.3~14 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/2402e9ed4cdb6857c8d245ba652dfcb7bb88d120?hp=6ca1e170f7518e69dbebb4393e7899729c042ac6 Merge pull request #195 from owncloud/fixed_crash_due_to_uploads_to_accounts_not_already_existing Fixed crash due to uploads to accounts not already existing --- diff --git a/res/values/strings.xml b/res/values/strings.xml index b7a951a2..708fbfbb 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -16,7 +16,7 @@ There is no account set up on your device. In order to use this App, you need to create one. %1$s Android App version %1$s - Refresh + Refresh account Upload Content from other apps Files @@ -80,7 +80,7 @@ Created: Modified: Download - Refresh + Refresh file Redownload File was renamed to %1$s during upload Yes diff --git a/src/com/owncloud/android/authentication/AuthenticatorActivity.java b/src/com/owncloud/android/authentication/AuthenticatorActivity.java index 32ab860c..51185520 100644 --- a/src/com/owncloud/android/authentication/AuthenticatorActivity.java +++ b/src/com/owncloud/android/authentication/AuthenticatorActivity.java @@ -934,7 +934,33 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList finish(); - } else { + } else if (result.isServerFail() || result.isException()) { + /// if server fail or exception in authorization, the UI is updated as when a server check failed + mServerIsChecked = true; + mServerIsValid = false; + mIsSslConn = false; + mOcServerChkOperation = null; + mDiscoveredVersion = null; + mHostBaseUrl = normalizeUrl(mHostUrlInput.getText().toString()); + + // update status icon and text + updateServerStatusIconAndText(result); + showServerStatus(); + mAuthStatusIcon = 0; + mAuthStatusText = 0; + showAuthStatus(); + + // update input controls state + showRefreshButton(); + mOkButton.setEnabled(false); + + // very special case (TODO: move to a common place for all the remote operations) (dangerous here?) + if (result.getCode() == ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED) { + mLastSslUntrustedServerResult = result; + showDialog(DIALOG_SSL_VALIDATOR); + } + + } else { // authorization fail due to client side - probably wrong credentials updateAuthStatusIconAndText(result); showAuthStatus(); Log_OC.d(TAG, "Access failed: " + result.getLogMessage()); diff --git a/src/com/owncloud/android/operations/RemoteOperationResult.java b/src/com/owncloud/android/operations/RemoteOperationResult.java index 6f4f2910..1fc01799 100644 --- a/src/com/owncloud/android/operations/RemoteOperationResult.java +++ b/src/com/owncloud/android/operations/RemoteOperationResult.java @@ -287,4 +287,12 @@ public class RemoteOperationResult implements Serializable { } + public boolean isServerFail() { + return (mHttpCode >= HttpStatus.SC_INTERNAL_SERVER_ERROR); + } + + public boolean isException() { + return (mException != null); + } + } diff --git a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java index 9896a924..bcd62a38 100644 --- a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -222,7 +222,14 @@ public class FileDisplayActivity extends FileActivity implements /// Check whether the 'main' OCFile handled by the Activity is contained in the current Account OCFile file = getFile(); if (file != null) { - file = mStorageManager.getFileByPath(file.getRemotePath()); // currentDir = null if not in the current Account + if (file.isDown() && file.getLastSyncDateForProperties() == 0) { + // upload in progress - right now, files are not inserted in the local cache until the upload is successful + if (mStorageManager.getFileById(file.getParentId()) == null) { + file = null; // not able to know the directory where the file is uploading + } + } else { + file = mStorageManager.getFileByPath(file.getRemotePath()); // currentDir = null if not in the current Account + } } if (file == null) { // fall back to root folder @@ -273,7 +280,9 @@ public class FileDisplayActivity extends FileActivity implements private Fragment chooseInitialSecondFragment(OCFile file) { Fragment secondFragment = null; if (file != null && !file.isDirectory()) { - if (file.isDown() && PreviewMediaFragment.canBePreviewed(file)) { + if (file.isDown() && PreviewMediaFragment.canBePreviewed(file) + && file.getLastSyncDateForProperties() > 0 // temporal fix + ) { int startPlaybackPosition = getIntent().getIntExtra(PreviewVideoActivity.EXTRA_START_POSITION, 0); boolean autoplay = getIntent().getBooleanExtra(PreviewVideoActivity.EXTRA_AUTOPLAY, true); secondFragment = new PreviewMediaFragment(file, getAccount(), startPlaybackPosition, autoplay);